Cyclic heat-engine model: cycles, realizable cones, the Clausius and Kelvin statements, Carnot engines
DefinitionSecondLawThermo_DefsThroughout, is a type of empirical temperatures carrying a linear order ( means the reservoir at is colder than the one at ), and a cycle is a finitely supported function : for each reservoir temperature , the number is the net heat absorbed by the device from the reservoir at in one complete cycle (negative when heat is rejected to it), and only finitely many reservoirs are touched. The work delivered in the cycle is
which is the first law for a device returning to its initial state. A set of cycles stands for the physically realizable ones; it is assumed to be a convex cone: , (run two devices side by side), and for (scale a device). A cycle is reversible when and . A cycle operates between and when for every . A Carnot engine between a hot reservoir and a cold reservoir is a reversible cycle operating between and with , and . The efficiency relative to the hot reservoir is .
Two impossibility statements are expressed in this language.
Clausius statement ("Heat can never pass from a colder to a warmer body without some other change, connected therewith, occurring at the same time."): for all temperatures , every realizable cycle operating between and with satisfies — a device whose only effect is to run through a cycle, exchanging heat with just these two reservoirs and doing no net work, cannot take heat out of the colder one.
Kelvin statement ("It is impossible for any system to operate in a thermodynamic cycle and deliver a net amount of energy by work to its surroundings while receiving energy by heat transfer from a single thermal reservoir."): every realizable cycle that exchanges heat with a single reservoir satisfies .
Finally, admits Carnot engines when for every pair there is a Carnot engine between and .
Formalization Note Cycles are modelled as finitely supported real-valued functions on the temperature type, so that running devices side by side is addition and scaling a device is scalar multiplication; the heat sign convention is "positive into the device". "Adiabatic enclosure", working substance, and the internal mechanism of a device play no role: a device is recorded only by the heat it draws from each reservoir.
import Mathlib
namespace SecondLawThermo
/-- A cyclic process (one complete cycle of a cyclically operating device) exchanging heat with
finitely many thermal reservoirs. Reservoirs are labelled by their empirical temperature, an
element of the linearly ordered type `Θ` (`s < t` means that the reservoir at `s` is colder than
the one at `t`). The value `c t` is the net heat absorbed by the device from the reservoir at
temperature `t` during one cycle (heat entering the device is positive, heat leaving it is
negative); all but finitely many values vanish. -/
abbrev Cycle (Θ : Type*) := Θ →₀ ℝ
variable {Θ : Type*}
/-- The net work delivered by the device to its surroundings during one cycle. Since the device
returns to its initial state, the first law of thermodynamics makes it equal to the total net
heat absorbed from all reservoirs. -/
noncomputable def work (c : Cycle Θ) : ℝ := c.sum fun _ q => q
/-- The set `𝒞` of cycles that can actually be realized forms a convex cone: doing nothing is
realizable, two realizable devices may be run side by side (their heat exchanges add up), and a
realizable device may be scaled by any nonnegative factor. -/
structure IsCycleCone (𝒞 : Set (Cycle Θ)) : Prop where
zero_mem : (0 : Cycle Θ) ∈ 𝒞
add_mem : ∀ c d, c ∈ 𝒞 → d ∈ 𝒞 → c + d ∈ 𝒞
smul_mem : ∀ (r : ℝ) (c : Cycle Θ), 0 ≤ r → c ∈ 𝒞 → r • c ∈ 𝒞
/-- A cycle is reversible (with respect to the realizable cycles `𝒞`) if both it and the exactly
reversed cycle, in which every heat exchange changes sign, are realizable. -/
def IsReversible (𝒞 : Set (Cycle Θ)) (c : Cycle Θ) : Prop := c ∈ 𝒞 ∧ -c ∈ 𝒞
/-- The cycle `c` exchanges heat only with the reservoirs at temperatures `h` and `k`. -/
def OperatesBetween (c : Cycle Θ) (h k : Θ) : Prop := ∀ t, t ≠ h → t ≠ k → c t = 0
/-- **Clausius statement.** Heat can never pass from a colder to a warmer body without some other
change: no realizable cycle that exchanges heat only with a hotter reservoir at `h` and a colder
reservoir at `k < h`, and produces no net work, absorbs a positive amount of heat from the colder
reservoir. -/
def ClausiusStatement [LinearOrder Θ] (𝒞 : Set (Cycle Θ)) : Prop :=
∀ h k : Θ, k < h → ∀ c ∈ 𝒞, OperatesBetween c h k → work c = 0 → c k ≤ 0
/-- **Kelvin statement.** No realizable cycle that exchanges heat with a single thermal reservoir
delivers a positive net amount of work. -/
def KelvinStatement (𝒞 : Set (Cycle Θ)) : Prop :=
∀ t : Θ, ∀ c ∈ 𝒞, (∀ s, s ≠ t → c s = 0) → work c ≤ 0
/-- A **Carnot engine** between the hot reservoir `h` and the cold reservoir `k`: a reversible
cycle exchanging heat only with these two reservoirs, absorbing a positive heat `q_H = c h` from
the hot reservoir, rejecting heat to the cold one (`q_C = c k < 0`) and delivering positive net
work. -/
def IsCarnotEngine (𝒞 : Set (Cycle Θ)) (c : Cycle Θ) (h k : Θ) : Prop :=
IsReversible 𝒞 c ∧ OperatesBetween c h k ∧ 0 < c h ∧ c k < 0 ∧ 0 < work c
/-- Every pair of reservoirs at different temperatures admits a Carnot engine operating between
them. -/
def CarnotEnginesExist [LinearOrder Θ] (𝒞 : Set (Cycle Θ)) : Prop :=
∀ h k : Θ, k < h → ∃ c, IsCarnotEngine 𝒞 c h k
/-- The efficiency `η = W / q_H` of a cycle, relative to its hot reservoir `h`: net work per cycle
divided by the heat absorbed from `h` (meaningful when `c h > 0`). -/
noncomputable def efficiency (c : Cycle Θ) (h : Θ) : ℝ := work c / c h
end SecondLawThermo
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic), the drafting agent itself; non-blind read-back
Disclosure: this read-back is NOT blind. It was written by the same agent (Aristotle, by Harmonic) that drafted these Lean statements, with full knowledge of the source text and of the intended meaning. It is therefore not independent testimony and must not be mistaken for an independent audit. Reviewers should check the Lean code against the source themselves.
This bundle declares, for an arbitrary type :
-
Cycle. is the type of finitely supported functions : a function assigning a real number to each , with for all but finitely many .
-
Work. is the sum of the values of over its (finite) support. For this is .
-
Cycle cone. For a set of cycles, is the conjunction of three clauses: the zero function lies in ; for all , if and then ; and for every real and every cycle , if and then . Nothing requires to be closed under negation, nor to be topologically closed.
-
Reversibility. is the conjunction and , where for every .
-
Two-reservoir support. says: for every , if and then . It does not require , nor or ; the zero cycle satisfies it for every pair, and if it says that is supported in .
-
Clausius statement (needs a linear order on ). says: for all with , and every such that for all and , one has . The inequality is non-strict, so is allowed. Nothing is said about cycles with nonzero net work, about cycles touching three or more reservoirs, or about beyond what forces.
-
Kelvin statement. says: for every and every such that for all , one has , which here is the same as . No order on is used.
-
Carnot engine. is the conjunction of five clauses: and ; for ; ; ; and . The last three force and . The predicate does not itself require any order relation between and .
-
Existence of Carnot engines (needs a linear order). says: for all with there is a with . If has at most one element, this holds vacuously.
-
Efficiency. . This is a total function: when , Lean's division gives it the junk value .
These are definitions only. The bundle asserts and proves nothing.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.