MathLabs
TheoremProved

Symmetry of equality from Eq.rec

Statement

There is a term Eq.symm:a=b→b=a\mathrm{Eq.symm} : a = b \to b = a built only from refla:a=a\mathrm{refl}_a : a = a and Eq.rec\mathsf{Eq.rec}; symmetry is a theorem of CIC, not an extra axiom.

Why is it true?

If equality needed a separate axiom for symmetry, transitivity, congruence, and so on, the trusted kernel would grow with every new fact about ==. Deriving them all from one eliminator keeps the kernel tiny.

Proof sketch

Fix aa. We want a function taking h:a=bh : a = b (for arbitrary bb) to a proof of b=ab = a. Apply Eq.rec\mathsf{Eq.rec} with the motive C(y,h):=(y=a)C(y, h) := (y = a) — a family of propositions indexed by the point yy and the proof hh connecting aa to yy.

The eliminator asks for a proof of the base case C(a,refl a)C(a, \mathrm{refl}\,a), i.e. of a=aa = a; supply refl a\mathrm{refl}\,a itself. This is legal because the base case is always indexed by refl\mathrm{refl} at the starting point aa.

Eq.rec\mathsf{Eq.rec} then returns, for every yy and every h:a=yh : a = y, a proof of C(y,h)=(y=a)C(y,h) = (y = a). Instantiate y:=b, h:=hy := b,\ h := h: we obtain exactly a proof of b=ab = a.

Packaging this as Eq.symm h:=Eq.rec (C:=λy h, y=a) (refl a) b h\mathrm{Eq.symm}\,h := \mathsf{Eq.rec}\,(C := \lambda y\, h,\, y = a)\,(\mathrm{refl}\,a)\,b\,h gives the term of type Eq.symm:a=b→b=a\mathrm{Eq.symm} : a = b \to b = a. The kernel accepts it purely by matching this application against the type signature of Eq.rec\mathsf{Eq.rec} — no reasoning about "symmetry" as a concept is needed at the kernel level.

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Leonardo de Moura, Sebastian Ullrich (2021). The Lean 4 Theorem Prover and Programming Language
  2. Xavier Leroy (2009). Formal verification of a realistic compiler
  3. Terence Tao, et al. (2023). A Proof of the Polynomial Freiman-Ruzsa Conjecture · arXiv:2311.05762