cfahlgren1/math / lean /OAI /LinearAlgebra /CirculantHadamard /TwoAdicDecomposition.lean
cfahlgren1's picture
download
raw
2.29 kB
import Mathlib.Data.Nat.Factorization.Basic
import Mathlib.Algebra.Group.Nat.Even
namespace OAI
/-!
# The two-adic form of a positive even square
Extract the power of two from an actual positive square root. Evenness of the
square forces a positive exponent in that root, so squaring gives the precise
form used at the start of the circulant Hadamard order reduction.
-/
namespace CirculantHadamard
/-- Extract the two-adic part from a specified positive square root. -/
theorem exists_two_adic_square_decomposition_of_eq_sq {n m : ℕ}
(hm : 0 < m) (hnm : n = m ^ 2) (heven : Even n) :
∃ s u : ℕ, 1 ≤ s ∧ 0 < u ∧ Odd u ∧ n = 2 ^ (2 * s) * u ^ 2 := by
obtain ⟨s, u, hu, hroot⟩ := Nat.exists_eq_two_pow_mul_odd hm.ne'
have hmEven : Even m := (Nat.even_pow.mp (hnm ▸ heven)).1
have hs : s ≠ 0 := by
intro hs0
have hmu : m = u := by simpa only [hs0, pow_zero, one_mul] using hroot
exact (Nat.not_even_iff_odd.mpr hu) (hmu ▸ hmEven)
have huPos : 0 < u := by
apply Nat.pos_of_ne_zero
intro hu0
have hm0 : m = 0 := by simpa only [hu0, mul_zero] using hroot
exact hm.ne' hm0
refine ⟨s, u, Nat.succ_le_of_lt (Nat.pos_of_ne_zero hs), huPos, hu, ?_⟩
rw [hnm, hroot, mul_pow, ← pow_mul, Nat.mul_comm s 2]
/-- Every positive even natural square has a positive odd part and a
nonzero, even power of two. -/
theorem exists_two_adic_square_decomposition {n : ℕ}
(hn : 0 < n) (hsquare : IsSquare n) (heven : Even n) :
∃ s u : ℕ, 1 ≤ s ∧ 0 < u ∧ Odd u ∧ n = 2 ^ (2 * s) * u ^ 2 := by
obtain ⟨m, hnm⟩ := hsquare.exists_sq
have hm : 0 < m := by
apply Nat.pos_of_ne_zero
intro hm0
have hn0 : n = 0 := by simpa only [hm0, zero_pow (by decide : 2 ≠ 0)] using hnm
exact hn.ne' hn0
exact exists_two_adic_square_decomposition_of_eq_sq hm hnm heven
/-- Interface for an order theorem that already supplies its positive root. -/
theorem exists_two_adic_square_decomposition_of_positive_square {n : ℕ}
(hsquare : ∃ m : ℕ, 0 < m ∧ n = m ^ 2) (heven : Even n) :
∃ s u : ℕ, 1 ≤ s ∧ 0 < u ∧ Odd u ∧ n = 2 ^ (2 * s) * u ^ 2 := by
obtain ⟨m, hm, hnm⟩ := hsquare
exact exists_two_adic_square_decomposition_of_eq_sq hm hnm heven
end CirculantHadamard
end OAI

Xet Storage Details

Size:
2.29 kB
·
Xet hash:
d8b97b40f0d6d3ba3f18ebfc11241c3f5f2c6a23beaeb684099b3d8d60d2f304

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.