Download data/lean/OAI/LinearAlgebra/CirculantHadamard/MatrixBridge.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.01 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/CirculantHadamard/MatrixBridge.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/CirculantHadamard/MatrixBridge.lean
-
curl -L -o MatrixBridge.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/CirculantHadamard/MatrixBridge.lean
6.01 kB
Lean 4 Β· 10
declarations fullstatements
| import OAI.LinearAlgebra.CirculantHadamard.Basic | |
| namespace OAI | |
| universe uR | |
| /-! | |
| # From real sign matrices to integer cyclic autocorrelation | |
| The Gram entry is reindexed using translation in `Fin n`. The real/integer | |
| bridge uses the injective coefficient map `β€ β β`; it does not assume any | |
| classification or any group-ring norm statement. | |
| -/ | |
| namespace CirculantHadamard | |
| open scoped BigOperators | |
| variable {n : β} | |
| /-- An integer sign row with the full Hadamard Gram equation. -/ | |
| def IsIntegerSignRow (h : Fin n β β€) : Prop := | |
| (β j, IsSign (h j)) β§ | |
| rowCirculant h * (rowCirculant h).transpose = | |
| (n : β€) β’ (1 : Matrix (Fin n) (Fin n) β€) | |
| /-- The Gram entry at `(i,a)` is the cyclic autocorrelation at `a-i`. -/ | |
| theorem rowCirculant_gram_apply [NeZero n] {R : Type uR} [CommRing R] | |
| (h : Fin n β R) (i a : Fin n) : | |
| (rowCirculant h * (rowCirculant h).transpose) i a = | |
| β j, h j * h (j - (a - i)) := by | |
| classical | |
| let e : Fin n β Fin n := | |
| { toFun := fun j => j - i | |
| invFun := fun j => j + i | |
| left_inv := fun j => sub_add_cancel j i | |
| right_inv := fun j => add_sub_cancel_right j i } | |
| simp only [Matrix.mul_apply, Matrix.transpose_apply, rowCirculant_apply] | |
| apply Fintype.sum_equiv e | |
| intro j | |
| change h (j - i) * h (j - a) = h (j - i) * h ((j - i) - (a - i)) | |
| simp only [sub_sub_sub_cancel_right] | |
| /-- The full Gram equation is exactly the cyclic autocorrelation system. -/ | |
| theorem gram_eq_iff_autocorrelation [NeZero n] {R : Type uR} [CommRing R] | |
| (h : Fin n β R) : | |
| rowCirculant h * (rowCirculant h).transpose = | |
| (n : R) β’ (1 : Matrix (Fin n) (Fin n) R) β | |
| β a : Fin n, β j, h j * h (j - a) = if a = 0 then (n : R) else 0 := by | |
| classical | |
| constructor | |
| Β· intro hGram a | |
| have ha := congrArg (fun M : Matrix (Fin n) (Fin n) R => M 0 a) hGram | |
| rw [rowCirculant_gram_apply] at ha | |
| simpa [Matrix.smul_apply, Matrix.one_apply, eq_comm] using ha | |
| Β· intro hCorr | |
| ext i a | |
| rw [rowCirculant_gram_apply, hCorr] | |
| by_cases hia : i = a | |
| Β· subst a | |
| simp | |
| Β· have hai : a - i β 0 := sub_ne_zero.mpr (Ne.symm hia) | |
| simp [hia, hai, Matrix.smul_apply] | |
| /-- Casting the integer Gram matrix agrees entry by entry with taking the | |
| Gram matrix after casting the row. -/ | |
| theorem intCast_gram_apply (h : Fin n β β€) (i j : Fin n) : | |
| ((rowCirculant h * (rowCirculant h).transpose) i j : β) = | |
| (rowCirculant (fun a => (h a : β)) * | |
| (rowCirculant (fun a => (h a : β))).transpose) i j := by | |
| simp [Matrix.mul_apply, Matrix.transpose_apply, rowCirculant, Int.cast_sum, | |
| Int.cast_mul] | |
| private theorem intCast_scaled_identity_apply (i j : Fin n) : | |
| (((n : β€) β’ (1 : Matrix (Fin n) (Fin n) β€)) i j : β) = | |
| ((n : β) β’ (1 : Matrix (Fin n) (Fin n) β)) i j := by | |
| by_cases hij : i = j <;> simp [Matrix.smul_apply, hij] | |
| /-- The real coefficient embedding preserves and reflects the entire Gram | |
| identity, including the diagonal value. -/ | |
| theorem gram_intCast_iff (h : Fin n β β€) : | |
| rowCirculant (fun a => (h a : β)) * | |
| (rowCirculant (fun a => (h a : β))).transpose = | |
| (n : β) β’ (1 : Matrix (Fin n) (Fin n) β) β | |
| rowCirculant h * (rowCirculant h).transpose = | |
| (n : β€) β’ (1 : Matrix (Fin n) (Fin n) β€) := by | |
| constructor | |
| Β· intro hGram | |
| ext i j | |
| apply Int.cast_injective (Ξ± := β) | |
| rw [intCast_gram_apply, intCast_scaled_identity_apply] | |
| exact congrArg (fun M : Matrix (Fin n) (Fin n) β => M i j) hGram | |
| Β· intro hGram | |
| ext i j | |
| rw [β intCast_gram_apply, β intCast_scaled_identity_apply] | |
| exact congrArg (fun M : Matrix (Fin n) (Fin n) β€ => (M i j : β)) hGram | |
| /-- Every integer sign row gives the actual real circulant Hadamard matrix. -/ | |
| theorem IsIntegerSignRow.exists_real {h : Fin n β β€} (hh : IsIntegerSignRow h) : | |
| ExistsRealCirculantHadamard n := by | |
| refine β¨rowCirculant (fun a => (h a : β)), rowCirculant_isCirculant _, ?_, | |
| (gram_intCast_iff h).mpr hh.2β© | |
| intro i j | |
| rcases hh.1 (j - i) with hpos | hneg | |
| Β· left | |
| simp only [rowCirculant_apply, hpos, Int.cast_one] | |
| Β· right | |
| simp only [rowCirculant_apply, hneg, Int.cast_neg, Int.cast_one] | |
| /-- A real sign matrix determines an integer sign row without approximation. -/ | |
| theorem ExistsRealCirculantHadamard.exists_integerSignRow [NeZero n] | |
| (hH : ExistsRealCirculantHadamard n) : β h : Fin n β β€, IsIntegerSignRow h := by | |
| classical | |
| rcases hH with β¨H, β¨h, hrowβ©, hsign, hGramβ© | |
| have hsignRow : β j, IsSign (h j) := by | |
| intro j | |
| simpa only [hrow, sub_zero] using hsign 0 j | |
| let z : Fin n β β€ := fun j => if h j = 1 then 1 else -1 | |
| have hzcast : β j, (z j : β) = h j := by | |
| intro j | |
| by_cases hj : h j = 1 | |
| Β· simp [z, hj] | |
| Β· have hneg := (hsignRow j).resolve_left hj | |
| simp only [z, ite_eq_right hj, Int.cast_neg, Int.cast_one, hneg] | |
| have hzsign : β j, IsSign (z j) := by | |
| intro j | |
| dsimp [z, IsSign] | |
| split_ifs <;> simp | |
| have hzH : rowCirculant (fun j => (z j : β)) = H := by | |
| ext i j | |
| rw [rowCirculant_apply, hzcast, hrow] | |
| refine β¨z, hzsign, (gram_intCast_iff z).mp ?_β© | |
| simpa only [hzH] using hGram | |
| /-- Equivalence between the public real matrix problem and integer sign rows. -/ | |
| theorem integerSignRow_iff_real [NeZero n] : | |
| (β h : Fin n β β€, IsIntegerSignRow h) β ExistsRealCirculantHadamard n := by | |
| constructor | |
| Β· rintro β¨h, hhβ© | |
| exact hh.exists_real | |
| Β· exact ExistsRealCirculantHadamard.exists_integerSignRow | |
| /-- A direct integer autocorrelation presentation of the real matrix problem. -/ | |
| theorem existsReal_iff_integer_autocorrelation [NeZero n] : | |
| ExistsRealCirculantHadamard n β | |
| β h : Fin n β β€, (β j, IsSign (h j)) β§ | |
| β a : Fin n, β j, h j * h (j - a) = if a = 0 then (n : β€) else 0 := by | |
| rw [β integerSignRow_iff_real] | |
| simp only [IsIntegerSignRow, gram_eq_iff_autocorrelation] | |
| end CirculantHadamard | |
| end OAI | |
Outline
- def
IsIntegerSignRow22 - theorem
rowCirculant_gram_apply28 - theorem
gram_eq_iff_autocorrelation45 - theorem
intCast_gram_apply67 - theorem
intCast_scaled_identity_apply74 - theorem
gram_intCast_iff81 - theorem
IsIntegerSignRow.exists_real99 - theorem
ExistsRealCirculantHadamard.exists_integerSignRow111 - theorem
integerSignRow_iff_real136 - theorem
existsReal_iff_integer_autocorrelation144