is_hadamard_matrix_order_two
The matrix [[1, 1], [1, -1]] is a Hadamard matrix of order 2.
Statement
theorem is_hadamard_matrix_order_two : IsHadamardMatrix !![(1 : ℤ), 1; 1, -1]- Source
- sanity lemma for IsHadamardMatrix
- Verified
- 22 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- IsHadamardMatrixA square integer matrix H indexed by a finite type of size n is a Hadamard matrix when every entry is 1 or -1 and H Hᵀ = n I.
The proof, explained
The proof verifies directly from the definition that the given $2 \times 2$ matrix $H$ is Hadamard by checking two conditions. First, it exhaustively inspects all four entries to confirm each is either $1$ or $-1$. Second, it checks entrywise that $H H^T = 2 I_2$, expanding the matrix product and the identity matrix definitions and evaluating the resulting arithmetic for all four index pairs.
It suffices to show that each entry of $H$ is $\pm 1$ and that $H H^T = 2 I_2$.
By definition, an integer matrix $H$ of order $n$ is a Hadamard matrix if all its entries belong to $\{1, -1\}$ and $H H^T = n I_n$, where $n = |\operatorname{Fin} 2| = 2$. Applying the constructor for conjunction splits the proof into these two independent obligations.
refine ⟨?_, ?_⟩Every entry of $H$ is equal to $1$ or $-1$.
We introduce row and column indices $i, j \in \operatorname{Fin} 2$. Performing an exhaustive case analysis on $i \in \{0, 1\}$ and $j \in \{0, 1\}$ produces four cases. In each case, evaluating the concrete matrix entry yields $1$ or $-1$, which immediately satisfies the disjunction $H_{i, j} = 1 \lor H_{i, j} = -1$.
· intro i j fin_cases i <;> fin_cases j <;> simp
The matrix identity $H H^T = 2 I_2$ holds.
By matrix extensionality, it suffices to show that $(H H^T)_{i, j} = (2 I)_{i, j}$ for all indices $i, j \in \operatorname{Fin} 2$. We case-split exhaustively over all four pairs $(i, j) \in \{0, 1\}^2$. In each case, `Matrix.mul_apply` expands the matrix product into a sum of two terms, `Matrix.one_apply` evaluates the identity matrix entry, and simplification performs the arithmetic ($1 \cdot 1 + 1 \cdot 1 = 2$ on the diagonal, and $1 \cdot 1 + 1 \cdot (-1) = 0$ off the diagonal).
uses
Matrix.mul_apply,Matrix.one_apply· ext i j fin_cases i <;> fin_cases j <;> simp [Matrix.mul_apply, Matrix.one_apply]
Matrix.mul_apply- The $(i, k)$-th entry of a matrix product $M N$ equals the sum $\sum_j M_{i, j} N_{j, k}$.
Matrix.one_apply- The $(i, j)$-th entry of the identity matrix is $1$ if $i = j$ and $0$ otherwise.
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.
theorem is_hadamard_matrix_order_two : IsHadamardMatrix !![(1 : ℤ), 1; 1, -1] := by refine ⟨?_, ?_⟩ · intro i j fin_cases i <;> fin_cases j <;> simp · ext i j fin_cases i <;> fin_cases j <;> simp [Matrix.mul_apply, Matrix.one_apply]