Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

First law of thermodynamics: processes, adiabatic work, internal energy and heat

Definition
FirstLawThermo_Defs

by Lucas · Oct 9, 2026 · Mathlib 0df444a (Lean v4.33.1)

first-lawinternal-energythermodynamics

This definition file fixes the vocabulary for the mission. Throughout, σ\sigmaσ is the type of states of a closed system.

  1. Process. A process ppp consists of an initial state pstart∈σp_{\mathrm{start}}\in\sigmapstart​∈σ, a final state pfinish∈σp_{\mathrm{finish}}\in\sigmapfinish​∈σ, the net work W(p)∈RW(p)\in\mathbb RW(p)∈R done by the system on its surroundings (Clausius sign convention), and a proposition "ppp is adiabatic" (the process takes place inside an adiabatic enclosure).
  2. Composition. For processes p,qp,qp,q, the composite p⋅qp\cdot qp⋅q ("first ppp, then qqq") starts at pstartp_{\mathrm{start}}pstart​, ends at qfinishq_{\mathrm{finish}}qfinish​, has work W(p)+W(q)W(p)+W(q)W(p)+W(q), and is adiabatic iff both ppp and qqq are.
  3. Null process at AAA: start and finish AAA, work 000, adiabatic.
  4. Cyclic: pstart=pfinishp_{\mathrm{start}}=p_{\mathrm{finish}}pstart​=pfinish​. Adynamic: W(p)=0W(p)=0W(p)=0.
  5. For a set P\mathcal PP of processes (the realizable ones):
    • P\mathcal PP is closed under composition if p,q∈Pp,q\in\mathcal Pp,q∈P and pfinish=qstartp_{\mathrm{finish}}=q_{\mathrm{start}}pfinish​=qstart​ imply p⋅q∈Pp\cdot q\in\mathcal Pp⋅q∈P;
    • P\mathcal PP contains the null processes if the null process at every state lies in P\mathcal PP;
    • adiabatic work is path independent in P\mathcal PP if any two adiabatic p,q∈Pp,q\in\mathcal Pp,q∈P with the same start and the same finish have W(p)=W(q)W(p)=W(q)W(p)=W(q);
    • P\mathcal PP adiabatically links every state to OOO if for every AAA there is an adiabatic p∈Pp\in\mathcal Pp∈P going from OOO to AAA or from AAA to OOO.
  6. Internal energy. U:σ→RU:\sigma\to\mathbb RU:σ→R is an internal energy for P\mathcal PP if
U(pfinish)−U(pstart)=−W(p)for every adiabatic p∈P.U(p_{\mathrm{finish}})-U(p_{\mathrm{start}})=-W(p)\quad\text{for every adiabatic } p\in\mathcal P.U(pfinish​)−U(pstart​)=−W(p)for every adiabatic p∈P.
  1. Heat (Born's definition, as a residual): for U:σ→RU:\sigma\to\mathbb RU:σ→R,
QU(p)=U(pfinish)−U(pstart)+W(p).Q_U(p)=U(p_{\mathrm{finish}})-U(p_{\mathrm{start}})+W(p).QU​(p)=U(pfinish​)−U(pstart​)+W(p).

These are the objects in terms of which all theorems of the mission are stated.

Formalization Note Work is work done by the system, so the Clausius form ΔU=Q−W\Delta U=Q-WΔU=Q−W is the one that holds. "Adiabatic" is a primitive proposition attached to each process, and heat is a derived quantity depending on the chosen internal energy UUU.

Definition code
import Mathlib

namespace FirstLawThermo

/-- A process undergone by a closed system (no transfer of matter) whose states form the type
`σ`. It records the initial state `start`, the final state `finish`, the net work `work` done
*by* the system on its surroundings during the process (Clausius sign convention: work done by
the system is positive), and whether the process is `adiabatic`, i.e. carried out with the
system enclosed by adiabatic walls, so that energy is transferred only as work. -/
structure Process (σ : Type*) where
  /-- The initial state of the process. -/
  start : σ
  /-- The final state of the process. -/
  finish : σ
  /-- The net work done by the system on its surroundings (Clausius sign convention). -/
  work : ℝ
  /-- The process takes place inside an adiabatic enclosure. -/
  adiabatic : Prop

namespace Process

variable {σ : Type*}

/-- Sequential composition of two stages: first `p`, then `q`. It is intended for
`p.finish = q.start`; the composite starts where `p` starts, ends where `q` ends, the work done
is the sum of the works of the stages, and it is adiabatic exactly when both stages are. -/
def comp (p q : Process σ) : Process σ where
  start := p.start
  finish := q.finish
  work := p.work + q.work
  adiabatic := p.adiabatic ∧ q.adiabatic

/-- The null process at the state `A`: the system is left in state `A`, no work is done, and
no energy is exchanged (so it is in particular adiabatic). -/
def null (A : σ) : Process σ where
  start := A
  finish := A
  work := 0
  adiabatic := True

/-- A process is cyclic if it returns the system to its initial state. -/
def IsCyclic (p : Process σ) : Prop :=
  p.start = p.finish

/-- A process is adynamic if no energy is transferred as work. -/
def IsAdynamic (p : Process σ) : Prop :=
  p.work = 0

end Process

variable {σ : Type*}

/-- The set `procs` of physically realizable processes is closed under sequential composition
of consecutive stages. -/
def ClosedUnderComp (procs : Set (Process σ)) : Prop :=
  ∀ p ∈ procs, ∀ q ∈ procs, p.finish = q.start → p.comp q ∈ procs

/-- Every null process belongs to `procs` (leaving the system alone is realizable). -/
def ContainsNull (procs : Set (Process σ)) : Prop :=
  ∀ A : σ, Process.null A ∈ procs

/-- Path independence of adiabatic work: any two adiabatic processes in `procs` with the same
initial state and the same final state involve the same net work, however the work is done. -/
def AdiabaticWorkPathIndependent (procs : Set (Process σ)) : Prop :=
  ∀ p ∈ procs, ∀ q ∈ procs, p.adiabatic → q.adiabatic →
    p.start = q.start → p.finish = q.finish → p.work = q.work

/-- Every state `A` is linked to the reference state `O` by an adiabatic process in `procs`,
in at least one of the two directions (from `O` to `A`, or from `A` to `O`). -/
def AdiabaticallyLinkedTo (procs : Set (Process σ)) (O : σ) : Prop :=
  ∀ A : σ, ∃ p ∈ procs, p.adiabatic ∧
    ((p.start = O ∧ p.finish = A) ∨ (p.start = A ∧ p.finish = O))

/-- `U : σ → ℝ` is an internal energy function for `procs`: for every adiabatic process in
`procs`, the change of `U` equals minus the work done by the system,
`U(finish) - U(start) = -W`. -/
def IsInternalEnergy (procs : Set (Process σ)) (U : σ → ℝ) : Prop :=
  ∀ p ∈ procs, p.adiabatic → U p.finish - U p.start = -p.work

/-- The heat supplied to the system in the process `p`, defined (following Born) as the residual
`Q = ΔU + W`: the change of the internal energy `U` not accounted for by the work `W` done by
the system. -/
def heat (U : σ → ℝ) (p : Process σ) : ℝ :=
  U p.finish - U p.start + p.work

end FirstLawThermo
Source
Wikipedia, "First law of thermodynamics", revision oldid=1366986255, https://en.wikipedia.org/w/index.php?title=First_law_of_thermodynamics&oldid=1366986255; Section "Conceptual revision: the mechanical approach" and "Conceptually revised statement, according to the mechanical approach" (adiabatic walls primitive; heat defined as a residual, following Born); Section "Definition" (Clausius sign convention, ΔU=Q−W\Delta U = Q - WΔU=Q−W); Section "Evidence for the first law of thermodynamics for closed systems", subsections "Adiabatic processes" and "Adynamic processes"; Section "Description: Cyclic processes".
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.

The file introduces, for an arbitrary type σ\sigmaσ (any universe, possibly empty):

  • A structure Process on σ\sigmaσ with four fields: start∈σ\mathrm{start}\in\sigmastart∈σ, finish∈σ\mathrm{finish}\in\sigmafinish∈σ, a real number work\mathrm{work}work, and an arbitrary proposition adiabatic\mathrm{adiabatic}adiabatic. Nothing links these fields. Any combination of states, real number and proposition is a process, and the "adiabatic" proposition may be any proposition at all (true, false or undecided).
  • comp p qp\,qpq: the process with start pstartp_{\mathrm{start}}pstart​, finish qfinishq_{\mathrm{finish}}qfinish​, work W(p)+W(q)W(p)+W(q)W(p)+W(q), adiabatic proposition "ppp adiabatic and qqq adiabatic". It is defined for all p,qp,qp,q, even when pfinish≠qstartp_{\mathrm{finish}}\neq q_{\mathrm{start}}pfinish​=qstart​.
  • null AAA: start === finish =A=A=A, work 000, adiabatic proposition "True".
  • IsCyclic ppp: pstart=pfinishp_{\mathrm{start}}=p_{\mathrm{finish}}pstart​=pfinish​. IsAdynamic ppp: W(p)=0W(p)=0W(p)=0.
  • For a set P\mathcal PP of processes:
    • ClosedUnderComp P\mathcal PP: for all p,q∈Pp,q\in\mathcal Pp,q∈P with pfinish=qstartp_{\mathrm{finish}}=q_{\mathrm{start}}pfinish​=qstart​, comp p q∈P\mathrm{comp}\,p\,q\in\mathcal Pcomppq∈P.
    • ContainsNull P\mathcal PP: for every A∈σA\in\sigmaA∈σ, null A∈P\mathrm{null}\,A\in\mathcal PnullA∈P.
    • AdiabaticWorkPathIndependent P\mathcal PP: for all p,q∈Pp,q\in\mathcal Pp,q∈P, if both adiabatic propositions hold, pstart=qstartp_{\mathrm{start}}=q_{\mathrm{start}}pstart​=qstart​ and pfinish=qfinishp_{\mathrm{finish}}=q_{\mathrm{finish}}pfinish​=qfinish​, then W(p)=W(q)W(p)=W(q)W(p)=W(q).
    • AdiabaticallyLinkedTo P\mathcal PP OOO (for O∈σO\in\sigmaO∈σ): for every A∈σA\in\sigmaA∈σ there is p∈Pp\in\mathcal Pp∈P whose adiabatic proposition holds and with either (pstart=Op_{\mathrm{start}}=Opstart​=O and pfinish=Ap_{\mathrm{finish}}=Apfinish​=A) or (pstart=Ap_{\mathrm{start}}=Apstart​=A and pfinish=Op_{\mathrm{finish}}=Opfinish​=O).
  • IsInternalEnergy P\mathcal PP UUU (for U:σ→RU:\sigma\to\mathbb RU:σ→R): for every p∈Pp\in\mathcal Pp∈P whose adiabatic proposition holds,
U(pfinish)−U(pstart)=−W(p).U(p_{\mathrm{finish}})-U(p_{\mathrm{start}})=-W(p).U(pfinish​)−U(pstart​)=−W(p).

If no process in P\mathcal PP is adiabatic (for example P=∅\mathcal P=\emptysetP=∅), every UUU qualifies.

  • heat UUU ppp :=U(pfinish)−U(pstart)+W(p):=U(p_{\mathrm{finish}})-U(p_{\mathrm{start}})+W(p):=U(pfinish​)−U(pstart​)+W(p), a real number defined for every UUU and every process (adiabatic or not, in P\mathcal PP or not).

All declarations live in the namespace FirstLawThermo (Process-specific ones in FirstLawThermo.Process).

Human review
  • Endorsed by Shuze Chen · Oct 10, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Lucas · Oct 10, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me