68 From \(a=a\) to \(x^{2}=x\)

step from
1 \(a=a\); write \(1\) the source
2 \(1\,;1=1\) cut: join \(a=a\) to \(a=a\) and remove the middle \(a\)
3 \(0\,;0=0\) nothing joined to nothing is nothing
4 \(x\,;x=x\) for every value \(x\) the values are \(1\) and \(0\) (C21); steps 2, 3
5 \(x^{2}=x\) read the join of values as their product

The same by the diagonal: a statement \(x\) has at most one witness, so \(\Delta :x\to x\times x\) and \(\pi _1:x\times x\to x\) undo each other, and \(x\times x\cong x\). One line further, with \(u+u=0\) for the two values:

\[ (x+y)^{2}=x+y\ \Rightarrow \ x\,y+y\,x=0\ \Rightarrow \ x\,y=y\,x , \]
so the order of a product of values is forgotten because each value joined to itself is itself: the source’s own equation \(1\,;1=1\).

The chain is checked in Lean 4 (Figure 11, Listing 2).

68.1 Lean 4 — Verified

PIC

Figure 11: The file Idempotent.lean in the Lean 4 web editor (Lean v4.36.0-rc2): no errors and no warnings for the chain from \(a=a\) to \(x^{2}=x\) and \(x\,y=y\,x\).

Listing 2: Idempotent.lean: from \(a=a\) to \(x^{2}=x\).

Idempotent.lean

/-
  From a = a to x^2 = x.  Core Lean 4, no Mathlib.
-/

namespace Idempotent

/-! ## Steps 1-2: the source joined to itself is itself (cut) -/

theorem cut_source {A : Type} (a : A) : (rfl : a = a).trans rfl = rfl := rfl

/-! ## Steps 3-5: on the two values, every value joined to itself is itself -/

/-- join of values, read as product: "and" -/
def mul (x y : Bool) : Bool := x && y
/-- "differ": the sum of the two values -/
def add (x y : Bool) : Bool := x != y

theorem one_one : mul true true = true := rfl
theorem zero_zero : mul false false = false := rfl

/-- x^2 = x -/
theorem idem (x : Bool) : mul x x = x := by
  cases x <;> rfl

/-! ## The same by the diagonal: a statement and itself is the statement -/

theorem diag (p : Prop) : (p ∧ p) ↔ p := ⟨fun h => h.1, fun h => ⟨h, h⟩⟩

/-! ## One line further: the order of a product is forgotten -/

theorem char2 (u : Bool) : add u u = false := by
  cases u <;> rfl

theorem expand (x y : Bool) : mul (add x y) (add x y) = add x y := idem (add x y)

theorem cross_zero (x y : Bool) : add (mul x y) (mul y x) = false := by
  cases x <;> cases y <;> rfl

theorem comm (x y : Bool) : mul x y = mul y x := by
  cases x <;> cases y <;> rfl

end Idempotent