zmod_two_add_val_int
For elements $x, y \in \mathbb{F}_2$, viewing their values in $\{0, 1\}$ as integers, the integer value of $x + y$ in $\mathbb{F}_2$ equals $x + y - 2 x y$ in $\mathbb{Z}$.
Statement
lemma zmod_two_add_val_int (x y : ZMod 2) :
((x + y).val : ℤ) = (x.val : ℤ) + (y.val : ℤ) - 2 * (x.val : ℤ) * (y.val : ℤ)- Source
- arXiv:2611.02063 Lemma 3.1
- Verified
- 07 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
Read back from the Lean
For all elements $x, y \in \mathbb{Z}/2\mathbb{Z}$, the canonical representative in $\mathbb{N}$ of $x + y$ (given by ZMod.val), cast to the integers, is equal to $(x\text{.val} : \mathbb{Z}) + (y\text{.val} : \mathbb{Z}) - 2 \cdot (x\text{.val} : \mathbb{Z}) \cdot (y\text{.val} : \mathbb{Z})$.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
The proof, explained
The theorem is proved by exhaustive case analysis. Since $\mathbb{Z}/2\mathbb{Z}$ has only two elements, there are four possible pairs $(x, y)$, and in each case both sides evaluate definitionally to the same integer.
The identity holds for all $x, y \in \mathbb{Z}/2\mathbb{Z}$.
Since $\mathbb{Z}/2\mathbb{Z}$ has only two elements ($0$ and $1$), `fin_cases` exhaustively checks the four possible combinations of $(x, y) \in \{0, 1\}^2$. In each case, both the modular sum's integer representative and the arithmetic expression $x + y - 2xy$ evaluate to the same integer ($0$ for $(0,0)$ and $(1,1)$, and $1$ for $(0,1)$ and $(1,0)$), so each case is verified by reflexivity (`rfl`).
fin_cases x <;> fin_cases y <;> rfl
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
/-- Over the integers, the value of the sum in ZMod 2 is x + y - 2xy. -/lemma zmod_two_add_val_int (x y : ZMod 2) : ((x + y).val : ℤ) = (x.val : ℤ) + (y.val : ℤ) - 2 * (x.val : ℤ) * (y.val : ℤ) := by fin_cases x <;> fin_cases y <;> rfl