Offline · exact source
Exact Lean source

GeneralSymmetricCounting

formalization/Cloning/GeneralSymmetricCounting.lean

Source hash: aaa540fa18f17d332c225c51f35d6f346fb196e9bb6193cec7475c715787dc5c

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.GeneralSymmetricOccupation
2 
3/-! # Exact occupation-fiber counting for the Werner output
4 
5For any occupation and any set of `n` tensor slots, the proportion of its
6computational words having the reference letter on those slots is
7`choose(reference multiplicity, n) / choose(total length, n)`. The proof
8double-counts pairs of a word and a subset of its reference-letter slots.
9-/
10noncomputable section
11set_option synthInstance.maxHeartbeats 200000
12set_option maxHeartbeats 1000000
13open scoped BigOperators
14 
15namespace Cloning.GeneralSymmetricOccupation
16 
17/-- Words of a prescribed occupation. -/
18def fiber {L d : ℕ} (q : Occupation L d) : Finset (Word L d) :=
19  Finset.univ.filter (fun w => label w = q)
20 
21@[simp] theorem mem_fiber {L d : ℕ} (q : Occupation L d) (w : Word L d) :
22    w ∈ fiber q ↔ label w = q := by simp [fiber]
23 
24@[simp] theorem fiber_card {L d : ℕ} (q : Occupation L d) :
25    (fiber q).card = multiplicity q := rfl
26 
27/-- Slots carrying one fixed one-particle basis vector. -/
28def letterSlots {L d : ℕ} (w : Word L d) (a : Fin d) : Finset (Fin L) :=
29  Finset.univ.filter (fun i => w i = a)
30 
31@[simp] theorem mem_letterSlots {L d : ℕ} (w : Word L d) (a : Fin d) (i : Fin L) :
32    i ∈ letterSlots w a ↔ w i = a := by simp [letterSlots]
33 
34theorem letterSlots_card {L d : ℕ} (w : Word L d) (a : Fin d) :
35    (letterSlots w a).card = profile w a := by
36  simp [letterSlots, profile, Fintype.card_subtype]
37 
38/-- The part of an occupation fiber surviving a fixed-slot pure input projector. -/
39def accepted {L d : ℕ} (q : Occupation L d) (a : Fin d) (S : Finset (Fin L)) :
40    Finset (Word L d) := (fiber q).filter (fun w => S ⊆ letterSlots w a)
41 
42@[simp] theorem mem_accepted {L d : ℕ} (q : Occupation L d) (a : Fin d)
43    (S : Finset (Fin L)) (w : Word L d) :
44    w ∈ accepted q a S ↔ label w = q ∧ ∀ i ∈ S, w i = a := by
45  simp [accepted, Finset.subset_iff]
46 
47/-- Permuting slots gives a genuine bijection between the accepted word sets. -/
48theorem accepted_card_eq_of_card_eq {L d : ℕ} (q : Occupation L d) (a : Fin d)
49    (S T : Finset (Fin L)) (hST : S.card = T.card) :
50    (accepted q a S).card = (accepted q a T).card := by
51  classical
52  let e : ↥S ≃ ↥T := Finset.equivOfCardEq hST
53  let σ : Equiv.Perm (Fin L) := e.extendSubtype
54  have hσ : ∀ i : Fin L, i ∈ S ↔ σ i ∈ T := by
55    intro i
56    exact ⟨e.extendSubtype_mem i, fun h => by
57      by_contra hi
58      exact e.extendSubtype_not_mem i hi h⟩
59  let E : Word L d ≃ Word L d :=
60    { toFun := fun w => w ∘ σ.symm
61      invFun := fun w => w ∘ σ
62      left_inv := fun w => by funext i; simp
63      right_inv := fun w => by funext i; simp }
64  apply Finset.card_equiv E
65  intro w
66  simp only [mem_accepted]
67  change (label w = q ∧ ∀ i ∈ S, w i = a) ↔
68    (label (w ∘ σ.symm) = q ∧ ∀ i ∈ T, w (σ.symm i) = a)
69  rw [label_permute]
70  refine and_congr_right (fun _ => ⟨?_, ?_⟩)
71  · intro h i hi
72    apply h (σ.symm i)
73    exact (hσ _).mpr (by simpa using hi)
74  · intro h i hi
75    simpa using h (σ i) ((hσ i).mp hi)
76 
77private theorem subset_sum {L d : ℕ} (w : Word L d) (a : Fin d) (n : ℕ) :
78    (∑ S ∈ Finset.powersetCard n (Finset.univ : Finset (Fin L)),
79      if S ⊆ letterSlots w a then (1 : ℕ) else 0) = (profile w a).choose n := by
80  classical
81  have hf : (Finset.powersetCard n (Finset.univ : Finset (Fin L))).filter
82      (fun S => S ⊆ letterSlots w a) = Finset.powersetCard n (letterSlots w a) := by
83    ext S
84    simp only [Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and]
85    tauto
86  rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one, hf,
87    Finset.card_powersetCard, letterSlots_card]
88  norm_cast
89 
90/-- Exact finite double-counting identity underlying the occupation eigenvalue. -/
91theorem accepted_card_mul_choose {L d : ℕ} (q : Occupation L d) (a : Fin d)
92    (S : Finset (Fin L)) :
93    (accepted q a S).card * L.choose S.card =
94      multiplicity q * (q.val a).choose S.card := by
95  classical
96  let sets := Finset.powersetCard S.card (Finset.univ : Finset (Fin L))
97  have hconstant : (∑ T ∈ sets, (accepted q a T).card) =
98      (accepted q a S).card * L.choose S.card := by
99    calc
100      _ = ∑ _T ∈ sets, (accepted q a S).card := by
101        apply Finset.sum_congr rfl
102        intro T hT
103        apply accepted_card_eq_of_card_eq
104        exact (Finset.mem_powersetCard.mp hT).2
105      _ = _ := by simp [sets, Finset.card_powersetCard, mul_comm]
106  rw [← hconstant]
107  have hf : ∀ T, (accepted q a T).card =
108      ∑ w ∈ fiber q, if T ⊆ letterSlots w a then (1 : ℕ) else 0 := by
109    intro T
110    rw [accepted, Finset.card_eq_sum_ones, Finset.sum_filter]
111  simp_rw [hf]
112  rw [Finset.sum_comm]
113  calc
114    _ = ∑ w ∈ fiber q, (profile w a).choose S.card := by
115      apply Finset.sum_congr rfl
116      intro w hw
117      exact subset_sum w a S.card
118    _ = ∑ _w ∈ fiber q, (q.val a).choose S.card := by
119      apply Finset.sum_congr rfl
120      intro w hw
121      have h := congrArg (fun r : Occupation L d => r.val a) (mem_fiber q w |>.mp hw)
122      exact congrArg (fun k : ℕ => k.choose S.card) h
123    _ = _ := by simp
124 
125/-- The physical occupation probability of passing a fixed-slot input projector. -/
126theorem accepted_proportion {L d : ℕ} (q : Occupation L d) (a : Fin d)
127    (S : Finset (Fin L)) :
128    ((accepted q a S).card : ℝ) / multiplicity q =
129      ((q.val a).choose S.card : ℝ) / L.choose S.card := by
130  have hmul : ((accepted q a S).card : ℝ) * (L.choose S.card : ℝ) =
131      (multiplicity q : ℝ) * ((q.val a).choose S.card : ℝ) := by
132    exact_mod_cast accepted_card_mul_choose q a S
133  have hm : (multiplicity q : ℝ) ≠ 0 := by exact_mod_cast (multiplicity_pos q).ne'
134  have hc : (L.choose S.card : ℝ) ≠ 0 := by
135    exact_mod_cast (Nat.choose_pos (by simpa using Finset.card_le_univ S)).ne'
136  apply (div_eq_div_iff hm hc).mpr
137  simpa [mul_comm] using hmul
138 
139end Cloning.GeneralSymmetricOccupation