cfahlgren1/math / lean /OAI /Analysis /MutuallyUnbiased /Fourier /ChargeDecomposition.lean
cfahlgren1's picture
download
raw
4.54 kB
import Mathlib.Data.Multiset.Replicate
import Mathlib.Data.Multiset.AddSub
import Lean.Elab.Tactic.Omega
import OAI.Analysis.MutuallyUnbiased.Matrix.Hadamard
namespace OAI
noncomputable section
open scoped BigOperators
namespace MUB6
def weightMultiset (w : Coord → ℕ) : Multiset Coord :=
∑ i, Multiset.replicate (w i) i
theorem weightMultiset_card (w : Coord → ℕ) :
(weightMultiset w).card = ∑ i, w i := by
have h (s : Finset Coord) : (∑ i ∈ s, Multiset.replicate (w i) i).card = ∑ i ∈ s, w i := by
induction s using Finset.induction_on with
| empty => simp
| @insert i s hi ih => simp [Finset.sum_insert hi, Multiset.card_add, ih]
exact h Finset.univ
theorem weightMultiset_count (w : Coord → ℕ) (k : Coord) :
(weightMultiset w).count k = w k := by
have h (s : Finset Coord) :
(∑ i ∈ s, Multiset.replicate (w i) i).count k = ∑ i ∈ s, if i = k then w i else 0 := by
induction s using Finset.induction_on with
| empty => simp
| @insert i s hi ih => simp [Finset.sum_insert hi, Multiset.count_add, Multiset.count_replicate, ih]
simpa [weightMultiset] using h Finset.univ
def positivePositions (a : Charge) : Multiset Coord := weightMultiset (fun i => (a i).toNat)
def negativePositions (a : Charge) : Multiset Coord := weightMultiset (fun i => (-a i).toNat)
theorem positivePositions_card (a : Charge) : (positivePositions a).card = order a :=
weightMultiset_card _
theorem negativePositions_card {a : Charge} (ha : Balanced a) :
(negativePositions a).card = order a := by
have h : (∑ i, ((a i).toNat : ℤ)) - ∑ i, ((-a i).toNat : ℤ) = 0 := by
rw [← Finset.sum_sub_distrib]
simpa only [Int.toNat_sub_toNat_neg] using (show ∑ i, a i = 0 from ha)
rw [negativePositions, weightMultiset_card, order]
exact_mod_cast (sub_eq_zero.mp h).symm
theorem charge_eq_counts (a : Charge) (k : Coord) :
a k = ((positivePositions a).count k : ℤ) - (negativePositions a).count k := by
rw [positivePositions, negativePositions, weightMultiset_count, weightMultiset_count]
exact (Int.toNat_sub_toNat_neg _).symm
theorem positive_negative_ne {a : Charge} {i j : Coord}
(hi : i ∈ positivePositions a) (hj : j ∈ negativePositions a) : i ≠ j := by
intro h
subst j
rw [← Multiset.count_pos, positivePositions, weightMultiset_count] at hi
rw [← Multiset.count_pos, negativePositions, weightMultiset_count] at hj
have hp := Int.pos_iff_toNat_pos.mpr hi
have hn := Int.pos_iff_toNat_pos.mpr hj
omega
/-- A balanced charge of order one is one positive and one negative coordinate. -/
theorem order_one_decomposition {a : Charge} (ha : Balanced a) (ho : order a = 1) :
∃ i j, i ≠ j ∧ a = difference i j := by
obtain ⟨i, hi⟩ := Multiset.card_eq_one.mp ((positivePositions_card a).trans ho)
obtain ⟨j, hj⟩ := Multiset.card_eq_one.mp ((negativePositions_card ha).trans ho)
refine ⟨i, j, positive_negative_ne (a := a) (by simp [hi]) (by simp [hj]), ?_⟩
funext k
rw [charge_eq_counts a k, hi, hj]
simp [difference, Pi.single_apply, Multiset.count_singleton, eq_comm]
/-- An order-two charge has two positive and two negative positions, allowing
repetitions on either side but no cancellation between the sides. -/
theorem order_two_decomposition {a : Charge} (ha : Balanced a) (ho : order a = 2) :
∃ i l j k, i ≠ j ∧ i ≠ k ∧ l ≠ j ∧ l ≠ k ∧
a = difference i j + difference l k := by
obtain ⟨i, l, hi⟩ := Multiset.card_eq_two.mp ((positivePositions_card a).trans ho)
obtain ⟨j, k, hj⟩ := Multiset.card_eq_two.mp ((negativePositions_card ha).trans ho)
have hip : i ∈ positivePositions a := by simp [hi]
have hlp : l ∈ positivePositions a := by simp [hi]
have hjn : j ∈ negativePositions a := by simp [hj]
have hkn : k ∈ negativePositions a := by simp [hj]
refine ⟨i, l, j, k, positive_negative_ne hip hjn, positive_negative_ne hip hkn,
positive_negative_ne hlp hjn, positive_negative_ne hlp hkn, ?_⟩
funext t
rw [charge_eq_counts a t, hi, hj]
simp only [Multiset.insert_eq_cons, Multiset.count_cons, Multiset.count_singleton,
Nat.cast_add, Nat.cast_ite, Nat.cast_one, Nat.cast_zero, Pi.add_apply,
difference, Pi.sub_apply, Pi.single_apply]
split_ifs <;> omega
theorem g_order_one {H : CMatrix} (hH : IsHadamard H) {a : Charge}
(ha : Balanced a) (ho : order a = 1) : g H a = 0 := by
obtain ⟨i, j, hij, rfl⟩ := order_one_decomposition ha ho
simp [g_difference hH, hij]
end MUB6
end
end OAI

Xet Storage Details

Size:
4.54 kB
·
Xet hash:
2422740f85dc6cd247d667438eb7697908cdfeaa5acfdbba7d1f893de05edc72

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