Download data/lean/OAI/LinearAlgebra/Barker/PeriodicModFour.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Barker/PeriodicModFour.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/Barker/PeriodicModFour.lean
-
curl -L -o PeriodicModFour.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/Barker/PeriodicModFour.lean
2.27 kB
| import OAI.LinearAlgebra.Barker.Model | |
| import Mathlib.Tactic.NormNum | |
| import Mathlib.Tactic.Ring | |
| namespace OAI | |
| namespace CirculantHadamard.Barker | |
| open scoped BigOperators | |
| def negativeBit {n : β} (h : Fin n β β€) (j : Fin n) : β€ := | |
| if h j = -1 then 1 else 0 | |
| theorem sign_eq_one_sub_two_bit {n : β} (h : Fin n β β€) | |
| (hs : β j, IsSign (h j)) (j : Fin n) : | |
| h j = 1 - 2 * negativeBit h j := by | |
| rcases hs j with hj | hj <;> norm_num [negativeBit, hj] | |
| def cyclicSubtractEquiv {n : β} [NeZero n] (a : Fin n) : Fin n β Fin n where | |
| toFun j := j - a | |
| invFun j := j + a | |
| left_inv j := sub_add_cancel j a | |
| right_inv j := add_sub_cancel_right j a | |
| theorem sum_negativeBit_shift {n : β} [NeZero n] (h : Fin n β β€) (a : Fin n) : | |
| (β j, negativeBit h (j - a)) = β j, negativeBit h j := by | |
| exact (cyclicSubtractEquiv a).sum_comp (negativeBit h) | |
| theorem periodic_bit_identity {n : β} [NeZero n] (h : Fin n β β€) | |
| (hs : β j, IsSign (h j)) (a : Fin n) : | |
| periodic h a = (n : β€) + 4 * | |
| ((β j, negativeBit h j * negativeBit h (j - a)) - β j, negativeBit h j) := by | |
| have hterm (j : Fin n) : h j * h (j - a) = | |
| 1 - 2 * negativeBit h j - 2 * negativeBit h (j - a) + | |
| 4 * (negativeBit h j * negativeBit h (j - a)) := by | |
| rw [sign_eq_one_sub_two_bit h hs j, sign_eq_one_sub_two_bit h hs (j - a)] | |
| ring | |
| calc | |
| periodic h a = β j : Fin n, | |
| (1 - 2 * negativeBit h j - 2 * negativeBit h (j - a) + | |
| 4 * (negativeBit h j * negativeBit h (j - a))) := by | |
| unfold periodic | |
| exact Finset.sum_congr rfl (fun j _ => hterm j) | |
| _ = (n : β€) - 2 * (β j, negativeBit h j) - | |
| 2 * (β j, negativeBit h (j - a)) + | |
| 4 * (β j, negativeBit h j * negativeBit h (j - a)) := by | |
| simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, β Finset.mul_sum] | |
| simp | |
| _ = _ := by rw [sum_negativeBit_shift]; ring | |
| theorem periodic_mod_four {n : β} [NeZero n] (h : Fin n β β€) | |
| (hs : β j, IsSign (h j)) (a : Fin n) : | |
| (4 : β€) β£ periodic h a - (n : β€) := by | |
| refine β¨(β j, negativeBit h j * negativeBit h (j - a)) - | |
| β j, negativeBit h j, ?_β© | |
| rw [periodic_bit_identity h hs a] | |
| ring | |
| end CirculantHadamard.Barker | |
| end OAI | |