cfahlgren1's picture
download
raw
3.79 kB
import Mathlib.Data.Fintype.CardEmbedding
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import OAI.Analysis.MutuallyUnbiased.Moments.Averages
import OAI.Analysis.MutuallyUnbiased.Moments.Sampling
namespace OAI
noncomputable section
open scoped BigOperators
attribute [local instance] Classical.propDecidable
namespace MUB6.Sampling
theorem unused_card {p n : ℕ} (e : Fin p ↪ Fin n)
[Fintype {i // i ∉ Set.range e}] :
Fintype.card {i // i ∉ Set.range e} = n - p := by
rw [Fintype.card_subtype_compl]
have hr : Fintype.card {i // i ∈ Set.range e} = p := by
rw [Fintype.card_range, Fintype.card_fin]
rw [hr, Fintype.card_fin]
theorem embedding_succ_card (p n : ℕ) :
Fintype.card (Fin (p + 1) ↪ Fin n) =
Fintype.card (Fin p ↪ Fin n) * (n - p) := by
rw [Fintype.card_congr (Equiv.embeddingFinSucc p (Fin n)), Fintype.card_sigma]
simp only [unused_card, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Nat.cast_id]
theorem sum_dropFirst {p n : ℕ} (f : (Fin p ↪ Fin n) → ℝ) :
(∑ e : Fin (p + 1) ↪ Fin n, f (dropFirst e)) =
(n - p : ℕ) * ∑ e, f e := by
have hs := sum_injective_extension (fun e (_ : Fin n) => f e)
rw [hs]
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro e _
rw [Fintype.card_subtype_compl, Fintype.card_range, Fintype.card_fin, Fintype.card_fin]
/-- Deleting a coordinate of a uniform injection leaves a uniform injection. -/
theorem average_dropFirst {p n : ℕ} (hp : p < n) (f : (Fin p ↪ Fin n) → ℝ) :
average (fun e : Fin (p + 1) ↪ Fin n => f (dropFirst e)) = average f := by
have hd : ((n - p : ℕ) : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt (Nat.sub_pos_of_lt hp)
unfold average
rw [embedding_succ_card, Nat.cast_mul, sum_dropFirst, mul_inv_rev]
calc
_ = (((n - p : ℕ) : ℝ)⁻¹ * (n - p : ℕ)) *
((Fintype.card (Fin p ↪ Fin n) : ℝ)⁻¹ * ∑ e, f e) := by ring
_ = _ := by rw [inv_mul_cancel₀ hd, one_mul]
/-- The normalized counting identity used for an order-one contraction.
At most n rows are sampled; the saturated boundary case is separate. -/
theorem average_contraction {p n : ℕ} (hp : p < n)
(f : (Fin p ↪ Fin n) → Fin n → ℝ) (h : ∀ e, ∑ b, f e b = 0) :
((n - p : ℕ) : ℝ) *
average (fun e : Fin (p + 1) ↪ Fin n => f (dropFirst e) (e 0)) +
(∑ j : Fin p, average (fun e : Fin p ↪ Fin n => f e (e j))) = 0 := by
have hd : ((n - p : ℕ) : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt (Nat.sub_pos_of_lt hp)
have hc : ((n - p : ℕ) : ℝ) * (Fintype.card (Fin (p + 1) ↪ Fin n) : ℝ)⁻¹ =
(Fintype.card (Fin p ↪ Fin n) : ℝ)⁻¹ := by
rw [embedding_succ_card, Nat.cast_mul, mul_inv_rev]
rw [← mul_assoc, mul_inv_cancel₀ hd, one_mul]
have hs := sum_contraction f h
simp only [average]
rw [← mul_assoc, hc, ← Finset.mul_sum, ← mul_add]
rw [add_comm] at hs
rw [hs, mul_zero]
/-- At saturation the old labels exhaust the population, so only the occupied
contractions occur. This statement never defines a seven-row moment. -/
theorem saturated_average_contraction (n : ℕ)
(f : (Fin n ↪ Fin n) → Fin n → ℝ) (h : ∀ e, ∑ b, f e b = 0) :
(∑ j : Fin n, average (fun e : Fin n ↪ Fin n => f e (e j))) = 0 := by
simp only [average]
rw [← Finset.mul_sum, Finset.sum_comm]
have hs : (∑ e : Fin n ↪ Fin n, ∑ j : Fin n, f e (e j)) = 0 := by
apply Finset.sum_eq_zero
intro e _
have he : Function.Bijective e :=
⟨e.injective, Finite.surjective_of_injective e.injective⟩
rw [he.sum_comp]
exact h e
rw [hs, mul_zero]
end MUB6.Sampling
end
end OAI

Xet Storage Details

Size:
3.79 kB
·
Xet hash:
b33f2ba2be1e09202973101b14cb2eea055450e9a0864ce785ed91205c0b6549

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