Download data/lean/OAI/Probability/CoordinateSweeps/Kernel.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 42.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CoordinateSweeps/Kernel.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CoordinateSweeps/Kernel.lean
-
curl -L -o Kernel.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CoordinateSweeps/Kernel.lean
42.8 kB
| import Mathlib | |
| import OAI.Probability.CoordinateSweeps.Conditioning | |
| import OAI.Combinatorics.Graphs.Coverage | |
| namespace OAI | |
| /-! | |
| All definitions are finite and use the source's ordinary probability and trace | |
| normalizations. | |
| -/ | |
| noncomputable section | |
| open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder | |
| attribute [local instance] Classical.propDecidable | |
| /-! The alternating placement kernel from 04-sparse:eq7. | |
| Endpoints below need not be injections; invalid specifications have probability | |
| zero automatically. On valid endpoint placements this is exactly the source Q. -/ | |
| namespace CoordinateSweeps | |
| namespace Grid | |
| variable (G : Grid) | |
| /- The unique auxiliary trajectory joining two slots. -/ | |
| def pathBetween (x y : G.Slot) (t : Fin (G.b+1)) : G.Slot := | |
| fun j => if j.val < t.val then y j else x j | |
| @[simp] theorem pathBetween_zero (x y : G.Slot) : G.pathBetween x y 0 = x := by | |
| ext j | |
| simp [pathBetween] | |
| @[simp] theorem pathBetween_last (x y : G.Slot) : | |
| G.pathBetween x y (Fin.last G.b) = y := by | |
| ext j | |
| simp [pathBetween, j.isLt] | |
| @[simp] theorem pathBetween_input (x y : G.Slot) (j : Fin G.b) : | |
| G.pathBetween x y j.castSucc j = x j := by | |
| simp [pathBetween] | |
| @[simp] theorem pathBetween_output (x y : G.Slot) (j : Fin G.b) : | |
| G.pathBetween x y j.succ j = y j := by | |
| simp [pathBetween] | |
| theorem pathBetween_step (x y : G.Slot) (j k : Fin G.b) (hne : k β j) : | |
| G.pathBetween x y j.succ k = G.pathBetween x y j.castSucc k := by | |
| have hne' : k.val β j.val := fun he => hne (Fin.ext he) | |
| simp only [pathBetween, Fin.val_succ, Fin.val_castSucc] | |
| have hi : k.val < j.val+1 β k.val < j.val := by omega | |
| simp only [hi] | |
| /- The stage-decorated line used by the auxiliary trajectory. -/ | |
| def pathLine (x y : G.Slot) (j : Fin G.b) : G.Line j := | |
| fun k => G.pathBetween x y j.castSucc k | |
| /- Endpoint events are equivalent to the unique additional trajectory's | |
| line assignments. No feasibility or injectivity is postulated. -/ | |
| def endpointEvent {k : β} (x y : Fin k β G.Slot) (A : Finset (Fin k)) | |
| (Ο : G.Choices) : Prop := β i β A, G.sweep Ο (x i) = y i | |
| /- A direct finite constraint event on one line for the extra particles. -/ | |
| def extraLineEvent {k : β} (x y : Fin k β G.Slot) (A : Finset (Fin k)) | |
| (j : Fin G.b) (L : G.Line j) (Ο : Equiv.Perm (Cube (G.bits j))) : Prop := | |
| β i β A, G.pathLine (x i) (y i) j = L β Ο (x i j) = y i j | |
| namespace Holes | |
| variable {G} {h k : β} | |
| /- Exact one-line probability after the hole assignments are prescribed. -/ | |
| def localExtraProbability (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (j : Fin G.b) (L : G.Line j) | |
| (ΞΌ : FiniteLaw (Equiv.Perm (Cube (G.bits j)))) : β := | |
| (β Ο, if H.LineCompatible j L Ο β§ G.extraLineEvent x y A j L Ο then ΞΌ Ο else 0) / | |
| (β Ο, if H.LineCompatible j L Ο then ΞΌ Ο else 0) | |
| /- Product form of the exact conditional endpoint probability. The bridge to | |
| the original conditioned sweep event is proved below, not assumed. -/ | |
| def extraProbability (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) : β := | |
| β j, β L : G.Line j, H.localExtraProbability x y A j L (ΞΌ j) | |
| /- The path-weight alternating placement matrix Q, with counting measure and | |
| s, not s-h, in its normalization, exactly as 04-sparse:eq7. -/ | |
| def placementKernel (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) : β := | |
| (G.size : β)β»ΒΉ ^ k * β A β (Finset.univ : Finset (Fin k)).powerset, | |
| (-1 : β) ^ (k-A.card) * (G.size : β)^A.card * H.extraProbability x y A ΞΌ | |
| /- A line-isolated additional trajectory, relative to all other additional | |
| paths AND the prescribed holes. Stage indices are never conflated. -/ | |
| def LineIsolated (H : G.Holes h) (x y : Fin k β G.Slot) (i : Fin k) : Prop := | |
| (β j (a : Fin h), Β¬ H.OnLine j (G.pathLine (x i) (y i) j) a) β§ | |
| (β j (a : Fin k), a β i β | |
| G.pathLine (x a) (y a) j β G.pathLine (x i) (y i) j) | |
| theorem lineCompatible_of_empty (H : G.Holes h) (j : Fin G.b) (L : G.Line j) | |
| (he : β i, Β¬ H.OnLine j L i) (Ο : Equiv.Perm (Cube (G.bits j))) : | |
| H.LineCompatible j L Ο := by | |
| intro i | |
| exact (he i.val i.property).elim | |
| theorem localExtraProbability_no_paths (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (j : Fin G.b) (L : G.Line j) | |
| (ΞΌ : FiniteLaw (Equiv.Perm (Cube (G.bits j)))) | |
| (he : β i, Β¬ H.OnLine j L i) | |
| (ha : β i β A, G.pathLine (x i) (y i) j β L) : | |
| H.localExtraProbability x y A j L ΞΌ = 1 := by | |
| have hr : β Ο, G.extraLineEvent x y A j L Ο := by | |
| intro Ο i hi hL | |
| exact (ha i hi hL).elim | |
| simp [localExtraProbability, H.lineCompatible_of_empty j L he, hr, ΞΌ.sum_mass] | |
| theorem extraLineEvent_insert {G : Grid} {k : β} (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (j : Fin G.b) (L : G.Line j) | |
| (Ο : Equiv.Perm (Cube (G.bits j))) : | |
| G.extraLineEvent x y (insert i A) j L Ο β | |
| ((G.pathLine (x i) (y i) j = L β Ο (x i j) = y i j) β§ | |
| G.extraLineEvent x y A j L Ο) := by | |
| simp [extraLineEvent] | |
| /- The source's one-card marginal property, stated for a line law. This is | |
| proved for both U and the actual binary law below, not a main-proof assumption. -/ | |
| def OneCardUniform {d : β} (ΞΌ : FiniteLaw (Equiv.Perm (Cube d))) : Prop := | |
| β u v : Cube d, (β Ο, if Ο u = v then ΞΌ Ο else 0) = (2^d : β)β»ΒΉ | |
| theorem extraLineEvent_insert_off {G : Grid} {k : β} (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (j : Fin G.b) (L : G.Line j) | |
| (hne : G.pathLine (x i) (y i) j β L) | |
| (Ο : Equiv.Perm (Cube (G.bits j))) : | |
| G.extraLineEvent x y (insert i A) j L Ο β G.extraLineEvent x y A j L Ο := by | |
| rw [extraLineEvent_insert] | |
| simp [hne] | |
| theorem localExtraProbability_insert_off (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (j : Fin G.b) (L : G.Line j) | |
| (ΞΌ : FiniteLaw (Equiv.Perm (Cube (G.bits j)))) | |
| (hne : G.pathLine (x i) (y i) j β L) : | |
| H.localExtraProbability x y (insert i A) j L ΞΌ = | |
| H.localExtraProbability x y A j L ΞΌ := by | |
| simp only [localExtraProbability, extraLineEvent_insert_off x y A i j L hne] | |
| theorem localExtraProbability_isolated_insert (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (hi : i β A) | |
| (his : H.LineIsolated x y i) (j : Fin G.b) | |
| (ΞΌ : FiniteLaw (Equiv.Perm (Cube (G.bits j)))) (hΞΌ : OneCardUniform ΞΌ) : | |
| H.localExtraProbability x y (insert i A) j (G.pathLine (x i) (y i) j) ΞΌ = | |
| (2^G.bits j : β)β»ΒΉ := by | |
| have he : β Ο, H.LineCompatible j (G.pathLine (x i) (y i) j) Ο := | |
| H.lineCompatible_of_empty j _ (his.1 j) | |
| have ha : β Ο, G.extraLineEvent x y A j (G.pathLine (x i) (y i) j) Ο := by | |
| intro Ο a ha hL | |
| exact (his.2 j a (by intro he; subst a; exact hi ha) hL).elim | |
| simp only [localExtraProbability, he, true_and, extraLineEvent_insert, ha, | |
| and_true, true_implies, ite_true, ΞΌ.sum_mass, div_one] | |
| exact hΞΌ (x i j) (y i j) | |
| theorem stageExtraProbability_isolated_insert (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (hi : i β A) | |
| (his : H.LineIsolated x y i) (j : Fin G.b) | |
| (ΞΌ : FiniteLaw (Equiv.Perm (Cube (G.bits j)))) (hΞΌ : OneCardUniform ΞΌ) : | |
| (β L : G.Line j, H.localExtraProbability x y (insert i A) j L ΞΌ) = | |
| (2^G.bits j : β)β»ΒΉ * β L : G.Line j, H.localExtraProbability x y A j L ΞΌ := by | |
| let Lβ := G.pathLine (x i) (y i) j | |
| have hs := H.localExtraProbability_isolated_insert x y A i hi his j ΞΌ hΞΌ | |
| have he : H.localExtraProbability x y A j Lβ ΞΌ = 1 := by | |
| apply H.localExtraProbability_no_paths x y A j Lβ ΞΌ (his.1 j) | |
| intro a ha | |
| exact his.2 j a (by intro he; subst a; exact hi ha) | |
| have hprod : (β L β Finset.univ.erase Lβ, H.localExtraProbability x y (insert i A) j L ΞΌ) = | |
| β L β Finset.univ.erase Lβ, H.localExtraProbability x y A j L ΞΌ := by | |
| apply Finset.prod_congr rfl | |
| intro L hL | |
| exact H.localExtraProbability_insert_off x y A i j L ΞΌ | |
| (Ne.symm (Finset.mem_erase.mp hL).1) | |
| rw [β Finset.mul_prod_erase _ _ (Finset.mem_univ Lβ), | |
| β Finset.mul_prod_erase _ _ (Finset.mem_univ Lβ), hs, he, one_mul, hprod] | |
| theorem extraProbability_isolated_insert (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (i : Fin k) (hi : i β A) | |
| (his : H.LineIsolated x y i) | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) | |
| (hΞΌ : β j, OneCardUniform (ΞΌ j)) : | |
| H.extraProbability x y (insert i A) ΞΌ = | |
| (G.size : β)β»ΒΉ * H.extraProbability x y A ΞΌ := by | |
| unfold extraProbability | |
| simp_rw [H.stageExtraProbability_isolated_insert x y A i hi his _ _ (hΞΌ _)] | |
| rw [Finset.prod_mul_distrib, Finset.prod_inv_distrib] | |
| congr 1 | |
| simp [size, Nat.cast_prod, Nat.cast_pow] | |
| /- Elementary pairing identity for the alternating sum. -/ | |
| lemma alternating_cancel {ΞΉ : Type*} [DecidableEq ΞΉ] (s : Finset ΞΉ) (i : ΞΉ) (hi : i β s) | |
| (P : Finset ΞΉ β β) | |
| (hP : β A β s.erase i, P (insert i A) = P A) : | |
| β A β s.powerset, (-1 : β) ^ A.card * P A = 0 := by | |
| have hs : s = insert i (s.erase i) := (Finset.insert_erase hi).symm | |
| rw [hs, Finset.sum_powerset_insert (Finset.notMem_erase i s)] | |
| have hh : (β A β (s.erase i).powerset, (-1 : β) ^ (insert i A).card * P (insert i A)) = | |
| -(β A β (s.erase i).powerset, (-1 : β) ^ A.card * P A) := by | |
| rw [β Finset.sum_neg_distrib] | |
| apply Finset.sum_congr rfl | |
| intro A hA | |
| have hsub : A β s.erase i := Finset.mem_powerset.mp hA | |
| have hni : i β A := fun hh => Finset.notMem_erase i s (hsub hh) | |
| rw [Finset.card_insert_of_notMem hni, hP A hsub, pow_succ] | |
| ring | |
| rw [hh] | |
| ring | |
| /- Isolated-path cancellation for the actual product conditional kernel. | |
| There is no independence assumption between auxiliary particle factors. -/ | |
| theorem placementKernel_eq_zero_of_isolated (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (i : Fin k) (his : H.LineIsolated x y i) | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) | |
| (hΞΌ : β j, OneCardUniform (ΞΌ j)) : H.placementKernel x y ΞΌ = 0 := by | |
| have hsize : (G.size : β) β 0 := by | |
| apply ne_of_gt | |
| exact_mod_cast (Finset.prod_pos (fun j _ => pow_pos (by decide : 0 < (2:β)) _)) | |
| have hc := alternating_cancel (Finset.univ : Finset (Fin k)) i (Finset.mem_univ _) | |
| (fun A => (G.size : β)^A.card * H.extraProbability x y A ΞΌ) (by | |
| intro A hA | |
| have hi : i β A := fun hi => Finset.notMem_erase i _ (hA hi) | |
| rw [Finset.card_insert_of_notMem hi, pow_succ, | |
| H.extraProbability_isolated_insert x y A i hi his ΞΌ hΞΌ] | |
| field_simp) | |
| have he : (β A β (Finset.univ : Finset (Fin k)).powerset, | |
| (-1 : β)^(k-A.card) * (G.size : β)^A.card * H.extraProbability x y A ΞΌ) = | |
| (-1 : β)^k * β A β (Finset.univ : Finset (Fin k)).powerset, | |
| (-1 : β)^A.card * ((G.size : β)^A.card * H.extraProbability x y A ΞΌ) := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro A hA | |
| have hAk : A.card β€ k := by simpa using Finset.card_le_univ A | |
| have hp : (-1 : β)^(k-A.card) = (-1 : β)^k * (-1 : β)^A.card := by | |
| have h := pow_add (-1 : β) (k-A.card) A.card | |
| rw [Nat.sub_add_cancel hAk] at h | |
| have hsq : (-1 : β)^A.card * (-1 : β)^A.card = 1 := by | |
| rw [β mul_pow] | |
| norm_num | |
| rw [h, mul_assoc, hsq, mul_one] | |
| rw [hp] | |
| ring | |
| rw [placementKernel, he, hc, mul_zero, mul_zero] | |
| end Holes | |
| end Grid | |
| end CoordinateSweeps | |
| namespace CoordinateSweeps.Grid | |
| variable (G : Grid) | |
| theorem boundary_coordinate_before (Ο : G.Choices) (x : G.Slot) (k : Fin G.b) | |
| (t : β) (ht : t β€ k.val) : G.boundary Ο t x k = x k := by | |
| induction t with | |
| | zero => simp | |
| | succ t ih => | |
| have htb : t < G.b := by omega | |
| rw [G.boundary_succ Ο htb] | |
| change G.stage Ο β¨t,htbβ© (G.boundary Ο t x) k = _ | |
| rw [G.stage_apply_ne Ο _ k (by intro he; have := congrArg Fin.val he; dsimp at this; omega)] | |
| exact ih (by omega) | |
| theorem boundary_coordinate_stable (Ο : G.Choices) (x : G.Slot) (k : Fin G.b) | |
| (u v : β) (hku : k.val < u) (huv : u β€ v) (hvb : v β€ G.b) : | |
| G.boundary Ο v x k = G.boundary Ο u x k := by | |
| induction v, huv using Nat.le_induction with | |
| | base => rfl | |
| | succ v huv ih => | |
| have hvb' : v < G.b := by omega | |
| rw [G.boundary_succ Ο hvb'] | |
| change G.stage Ο β¨v,hvb'β© (G.boundary Ο v x) k = _ | |
| rw [G.stage_apply_ne Ο _ k (by intro he; have := congrArg Fin.val he; dsimp at this; omega)] | |
| exact ih (by omega) | |
| theorem boundary_eq_pathBetween (Ο : G.Choices) (x : G.Slot) (t : Fin (G.b+1)) : | |
| G.boundary Ο t x = G.pathBetween x (G.sweep Ο x) t := by | |
| funext k | |
| unfold pathBetween | |
| split_ifs with hkt | |
| Β· exact (G.boundary_coordinate_stable Ο x k t G.b hkt (by omega) le_rfl).symm | |
| Β· exact G.boundary_coordinate_before Ο x k t (by omega) | |
| /- Actual endpoint events are exactly the auxiliary path constraints. -/ | |
| theorem sweep_eq_iff_line_assignments (Ο : G.Choices) (x y : G.Slot) : | |
| G.sweep Ο x = y β | |
| β j, Ο j (G.pathLine x y j) (x j) = y j := by | |
| constructor | |
| Β· intro hxy j | |
| have hs := congrArg (fun p : Equiv.Perm G.Slot => p x j) | |
| (G.boundary_succ Ο j.isLt) | |
| change G.boundary Ο (j.val+1) x j = G.stage Ο j (G.boundary Ο j x) j at hs | |
| rw [show G.boundary Ο (j.val+1) x = G.pathBetween x y j.succ by | |
| simpa [hxy] using G.boundary_eq_pathBetween Ο x j.succ, | |
| show G.boundary Ο j.val x = G.pathBetween x y j.castSucc by | |
| simpa [hxy] using G.boundary_eq_pathBetween Ο x j.castSucc] at hs | |
| change (Ο j (fun k => G.pathBetween x y j.castSucc k)) (x j) = y j | |
| simpa only [G.stage_apply_same, G.pathBetween_input, G.pathBetween_output] using hs.symm | |
| Β· intro hxy | |
| have hb : β t (ht : t β€ G.b), | |
| G.boundary Ο t x = G.pathBetween x y β¨t,by omegaβ© := by | |
| intro t | |
| induction t with | |
| | zero => intro ht; simp | |
| | succ t ih => | |
| intro ht | |
| have htb : t < G.b := by omega | |
| rw [G.boundary_succ Ο htb] | |
| change G.stage Ο β¨t,htbβ© (G.boundary Ο t x) = _ | |
| rw [ih (by omega)] | |
| funext k | |
| by_cases hkt : k = β¨t,htbβ© | |
| Β· subst k | |
| have hi := hxy β¨t,htbβ© | |
| change Ο β¨t,htbβ© (fun k => G.pathBetween x y β¨t,by omegaβ© k) (x β¨t,htbβ©) = y β¨t,htbβ© at hi | |
| simpa only [stage_apply_same, pathBetween, Fin.val_mk, lt_self_iff_false, | |
| ite_false, Nat.lt_succ_self, ite_true] using hi | |
| Β· rw [G.stage_apply_ne Ο _ k hkt] | |
| exact (G.pathBetween_step x y β¨t,htbβ© k hkt).symm | |
| have hh := hb G.b le_rfl | |
| change G.sweep Ο x = G.pathBetween x y (Fin.last G.b) at hh | |
| rw [G.pathBetween_last] at hh | |
| exact hh | |
| theorem endpointEvent_iff_lines {k : β} (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) (Ο : G.Choices) : | |
| G.endpointEvent x y A Ο β β j L, G.extraLineEvent x y A j L (Ο j L) := by | |
| constructor | |
| Β· intro he j L i hi hL | |
| have h := (G.sweep_eq_iff_line_assignments Ο (x i) (y i)).mp (he i hi) j | |
| simpa [hL] using h | |
| Β· intro he i hi | |
| apply (G.sweep_eq_iff_line_assignments Ο (x i) (y i)).mpr | |
| intro j | |
| exact he j (G.pathLine (x i) (y i) j) i hi rfl | |
| end CoordinateSweeps.Grid | |
| namespace CoordinateSweeps | |
| /- Finite independence, keeping an arbitrary local constraint at every factor. -/ | |
| theorem sum_prod_ite_all {ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ] | |
| {X : ΞΉ β Type*} [β i, Fintype (X i)] | |
| (w : β i, X i β β) (P : β i, X i β Prop) : | |
| (β x : β i, X i, if β i, P i (x i) then β i, w i (x i) else 0) = | |
| β i, β y, if P i y then w i y else 0 := by | |
| rw [Fintype.prod_sum] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hx : β i, P i (x i) | |
| Β· simp [hx] | |
| Β· obtain β¨i, hiβ© := not_forall.mp hx | |
| rw [ite_eq_right hx] | |
| symm | |
| apply Finset.prod_eq_zero (Finset.mem_univ i) | |
| simp [hi] | |
| namespace Grid | |
| variable (G : Grid) | |
| def productLineMass | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) (Ο : G.Choices) : β := | |
| β j, β L, ΞΌ j (Ο j L) | |
| theorem sum_productLineMass_event | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) | |
| (P : β j : Fin G.b, G.Line j β Equiv.Perm (Cube (G.bits j)) β Prop) : | |
| (β Ο, if β j L, P j L (Ο j L) then G.productLineMass ΞΌ Ο else 0) = | |
| β j, β L, β Ο, if P j L Ο then ΞΌ j Ο else 0 := by | |
| unfold productLineMass | |
| calc | |
| _ = β j, β Ο : G.Line j β Equiv.Perm (Cube (G.bits j)), | |
| if β L, P j L (Ο L) then β L, ΞΌ j (Ο L) else 0 := by | |
| convert sum_prod_ite_all | |
| (fun j (Ο : G.Line j β Equiv.Perm (Cube (G.bits j))) => β L, ΞΌ j (Ο L)) | |
| (fun j (Ο : G.Line j β Equiv.Perm (Cube (G.bits j))) => β L, P j L (Ο L)) using 1 <;> | |
| congr! | |
| _ = _ := by | |
| apply Finset.prod_congr rfl | |
| intro j _ | |
| convert sum_prod_ite_all (fun _ Ο => ΞΌ j Ο) (P j) using 1 | |
| namespace Holes | |
| variable {G} {h k : β} | |
| /- Conditional probability of an endpoint specification, from the original | |
| independent line sample space; the full trajectories of the holes are retained. -/ | |
| def conditionalEndpointProbability (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) : β := | |
| (β Ο, if H.Compatible Ο β§ G.endpointEvent x y A Ο then G.productLineMass ΞΌ Ο else 0) / | |
| (β Ο, if H.Compatible Ο then G.productLineMass ΞΌ Ο else 0) | |
| /- The kernel's product formula really is the conditioned sweep probability; | |
| no independence of different layers of the auxiliary paths is used. -/ | |
| theorem extraProbability_eq_conditionalEndpoint (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (A : Finset (Fin k)) | |
| (ΞΌ : β j : Fin G.b, FiniteLaw (Equiv.Perm (Cube (G.bits j)))) : | |
| H.extraProbability x y A ΞΌ = H.conditionalEndpointProbability x y A ΞΌ := by | |
| have he : β Ο : G.Choices, | |
| H.Compatible Ο β§ G.endpointEvent x y A Ο β | |
| β j L, H.LineCompatible j L (Ο j L) β§ G.extraLineEvent x y A j L (Ο j L) := by | |
| intro Ο | |
| rw [H.compatible_iff_lines, G.endpointEvent_iff_lines] | |
| constructor | |
| Β· intro h j L | |
| exact β¨h.1 j L, h.2 j Lβ© | |
| Β· intro h | |
| exact β¨fun j L => (h j L).1, fun j L => (h j L).2β© | |
| unfold conditionalEndpointProbability | |
| simp only [he] | |
| simp only [H.compatible_iff_lines] | |
| have hn : (β Ο : G.Choices, | |
| if β j L, H.LineCompatible j L (Ο j L) β§ G.extraLineEvent x y A j L (Ο j L) | |
| then G.productLineMass ΞΌ Ο else 0) = | |
| β j, β L, β Ο, if H.LineCompatible j L Ο β§ G.extraLineEvent x y A j L Ο | |
| then ΞΌ j Ο else 0 := by | |
| convert G.sum_productLineMass_event ΞΌ (fun j L Ο => | |
| H.LineCompatible j L Ο β§ G.extraLineEvent x y A j L Ο) using 1 <;> | |
| congr! | |
| have hd : (β Ο : G.Choices, if β j L, H.LineCompatible j L (Ο j L) | |
| then G.productLineMass ΞΌ Ο else 0) = | |
| β j, β L, β Ο, if H.LineCompatible j L Ο then ΞΌ j Ο else 0 := by | |
| convert G.sum_productLineMass_event ΞΌ H.LineCompatible using 1 | |
| rw [hn, hd] | |
| simp only [extraProbability, localExtraProbability, Finset.prod_div_distrib] | |
| /- At the source law, the denominator in the direct event formula is exactly | |
| the source normalizer (with all prescribed paths, not just endpoints). -/ | |
| theorem lineMass_hole_normalizer (H : G.Holes h) {z : β} | |
| (hz : 0 β€ z) (hz' : z β€ 1) : | |
| (β Ο, if H.Compatible Ο then | |
| G.productLineMass (fun j => lineLaw (G.bits j) z hz hz') Ο else 0) = | |
| H.probability z := by | |
| symm | |
| exact sum_subtype_eq_sum_ite_of_iff (fun _ => Iff.rfl) (G.choiceWeight z) | |
| end Holes | |
| end Grid | |
| end CoordinateSweeps | |
| namespace CoordinateSweeps | |
| def binaryBoundary {d : β} (bits : BinaryChoices d) (t : β) : Equiv.Perm (Cube d) := | |
| ((List.ofFn (fun j => binaryLayer j (bits j))).take t).reverse.prod | |
| @[simp] theorem binaryBoundary_zero {d : β} (bits : BinaryChoices d) : | |
| binaryBoundary bits 0 = 1 := by simp [binaryBoundary] | |
| @[simp] theorem binaryBoundary_last {d : β} (bits : BinaryChoices d) : | |
| binaryBoundary bits d = binarySweep d bits := by | |
| simp only [binaryBoundary, binarySweep, orderedProduct] | |
| rw [List.take_of_length_le (by simp)] | |
| theorem binaryBoundary_succ {d : β} (bits : BinaryChoices d) {t : β} (ht : t < d) : | |
| binaryBoundary bits (t+1) = binaryLayer β¨t,htβ© (bits β¨t,htβ©) * binaryBoundary bits t := by | |
| unfold binaryBoundary | |
| rw [List.take_succ_eq_append_getElem (by simpa using ht)] | |
| simp [List.reverse_append] | |
| @[simp] theorem binaryLayer_apply_same {d : β} (j : Fin d) | |
| (bits : ({k : Fin d // k β j} β Bool) β Bool) (x : Cube d) : | |
| binaryLayer j bits x j = Bool.xor (x j) (bits (fun k => x k)) := by | |
| simp [binaryLayer, pairSwitch, Equiv.funSplitAt_apply, Equiv.funSplitAt_symm_apply] | |
| theorem binaryLayer_apply_ne {d : β} (j k : Fin d) (hne : k β j) | |
| (bits : ({k : Fin d // k β j} β Bool) β Bool) (x : Cube d) : | |
| binaryLayer j bits x k = x k := by | |
| simp [binaryLayer, pairSwitch, Equiv.funSplitAt_apply, Equiv.funSplitAt_symm_apply, hne] | |
| def binaryPath {d : β} (x y : Cube d) (t : β) : Cube d := | |
| fun k => if k.val < t then y k else x k | |
| def binaryPathLine {d : β} (x y : Cube d) (j : Fin d) : {k : Fin d // k β j} β Bool := | |
| fun k => binaryPath x y j.val k | |
| @[simp] theorem binaryPath_zero {d : β} (x y : Cube d) : binaryPath x y 0 = x := by | |
| funext k; simp [binaryPath] | |
| @[simp] theorem binaryPath_last {d : β} (x y : Cube d) : binaryPath x y d = y := by | |
| funext k; simp [binaryPath, k.isLt] | |
| theorem binaryBoundary_before {d : β} (bits : BinaryChoices d) (x : Cube d) (k : Fin d) | |
| (t : β) (ht : t β€ k.val) : binaryBoundary bits t x k = x k := by | |
| induction t with | |
| | zero => simp | |
| | succ t ih => | |
| have htb : t < d := by omega | |
| rw [binaryBoundary_succ bits htb] | |
| change binaryLayer β¨t,htbβ© (bits β¨t,htbβ©) (binaryBoundary bits t x) k = _ | |
| rw [binaryLayer_apply_ne _ k (by intro he; have := congrArg Fin.val he; dsimp at this; omega)] | |
| exact ih (by omega) | |
| theorem binaryBoundary_stable {d : β} (bits : BinaryChoices d) (x : Cube d) (k : Fin d) | |
| (u v : β) (hku : k.val < u) (huv : u β€ v) (hvd : v β€ d) : | |
| binaryBoundary bits v x k = binaryBoundary bits u x k := by | |
| induction v, huv using Nat.le_induction with | |
| | base => rfl | |
| | succ v huv ih => | |
| have hvd' : v < d := by omega | |
| rw [binaryBoundary_succ bits hvd'] | |
| change binaryLayer β¨v,hvd'β© (bits β¨v,hvd'β©) (binaryBoundary bits v x) k = _ | |
| rw [binaryLayer_apply_ne _ k (by intro he; have := congrArg Fin.val he; dsimp at this; omega)] | |
| exact ih (by omega) | |
| theorem binaryBoundary_eq_path {d : β} (bits : BinaryChoices d) (x : Cube d) | |
| (t : β) (ht : t β€ d) : | |
| binaryBoundary bits t x = binaryPath x (binarySweep d bits x) t := by | |
| funext k | |
| unfold binaryPath | |
| split_ifs with hkt | |
| Β· simpa using (binaryBoundary_stable bits x k t d hkt ht le_rfl).symm | |
| Β· exact binaryBoundary_before bits x k t (by omega) | |
| theorem binarySweep_eq_iff_coins {d : β} (bits : BinaryChoices d) (x y : Cube d) : | |
| binarySweep d bits x = y β | |
| β j, bits j (binaryPathLine x y j) = Bool.xor (x j) (y j) := by | |
| have hxor : β a b c : Bool, Bool.xor a b = c β b = Bool.xor a c := by decide | |
| constructor | |
| Β· intro hxy j | |
| have hs := congrArg (fun p : Equiv.Perm (Cube d) => p x j) | |
| (binaryBoundary_succ bits j.isLt) | |
| change binaryBoundary bits (j.val+1) x j = | |
| binaryLayer j (bits j) (binaryBoundary bits j.val x) j at hs | |
| rw [binaryBoundary_eq_path bits x (j.val+1) (by omega), | |
| binaryBoundary_eq_path bits x j.val (by omega), hxy, | |
| binaryLayer_apply_same] at hs | |
| have hh : Bool.xor (x j) (bits j (binaryPathLine x y j)) = y j := by | |
| change Bool.xor (x j) (bits j (fun k => if k.val.val < j.val then y k else x k)) = y j | |
| simpa only [binaryPath, Nat.lt_succ_self, ite_true, lt_self_iff_false, ite_false] using hs.symm | |
| exact (hxor _ _ _).mp hh | |
| Β· intro hxy | |
| have hb : β t (ht : t β€ d), binaryBoundary bits t x = binaryPath x y t := by | |
| intro t | |
| induction t with | |
| | zero => intro ht; simp | |
| | succ t ih => | |
| intro ht | |
| have htd : t < d := by omega | |
| rw [binaryBoundary_succ bits htd] | |
| change binaryLayer β¨t,htdβ© (bits β¨t,htdβ©) (binaryBoundary bits t x) = _ | |
| rw [ih (by omega)] | |
| funext k | |
| by_cases hkt : k = β¨t,htdβ© | |
| Β· subst k | |
| rw [binaryLayer_apply_same] | |
| have hi := (hxor _ _ _).mpr (hxy β¨t,htdβ©) | |
| change Bool.xor (x β¨t,htdβ©) (bits β¨t,htdβ© (fun k => if k.val.val < t then y k else x k)) = y β¨t,htdβ© at hi | |
| simpa only [binaryPath, Nat.lt_succ_self, ite_true, lt_self_iff_false, ite_false] using hi | |
| Β· rw [binaryLayer_apply_ne _ k hkt] | |
| have hne : k.val β t := fun he => hkt (Fin.ext he) | |
| simp only [binaryPath] | |
| have he : k.val < t+1 β k.val < t := by omega | |
| simp [he] | |
| simpa using hb d le_rfl | |
| end CoordinateSweeps | |
| namespace CoordinateSweeps | |
| namespace FiniteLaw | |
| /- Independent uniform choices coincide with the uniform law on a finite | |
| product, including dependent factors. -/ | |
| theorem uniform_pi {ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ] | |
| {X : ΞΉ β Type*} [β i, Fintype (X i)] [β i, Nonempty (X i)] : | |
| uniform (β i, X i) = independent (fun i => uniform (X i)) := by | |
| ext x | |
| change (Fintype.card (β i, X i) : β)β»ΒΉ = β i, (Fintype.card (X i) : β)β»ΒΉ | |
| simp [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib] | |
| /- One specified coordinate of a uniform random function is uniform. -/ | |
| theorem uniform_eval {A B : Type*} [Fintype A] [DecidableEq A] [Fintype B] | |
| [Nonempty B] (a : A) (b : B) : | |
| (β f : A β B, if f a = b then uniform (A β B) f else 0) = | |
| (Fintype.card B : β)β»ΒΉ := by | |
| let e := Equiv.funSplitAt a B | |
| rw [β Equiv.sum_comp e.symm] | |
| have hc : Fintype.card (A β B) = Fintype.card B * Fintype.card ({j : A // j β a} β B) := by | |
| simpa using Fintype.card_congr e | |
| simp only [uniform_apply, Fintype.sum_prod_type, e, Equiv.funSplitAt_symm_apply] | |
| rw [hc, Nat.cast_mul] | |
| have hB : (Fintype.card B : β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| have hA : (Fintype.card ({j : A // j β a} β B) : β) β 0 := by | |
| exact_mod_cast Fintype.card_ne_zero | |
| field_simp | |
| simp | |
| /- Exact pushforward probability identity. -/ | |
| theorem map_event {A B : Type*} [Fintype A] [Fintype B] | |
| (ΞΌ : FiniteLaw A) (f : A β B) (P : B β Prop) : | |
| (β b, if P b then ΞΌ.map f b else 0) = β a, if P (f a) then ΞΌ a else 0 := by | |
| simp only [map_apply] | |
| have hi : β b, (if P b then β a, if f a = b then ΞΌ a else 0 else 0) = | |
| β a, if P b then (if f a = b then ΞΌ a else 0) else 0 := by | |
| intro b; by_cases hb : P b <;> simp [hb] | |
| simp only [hi] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| have h : β b, (if P b then (if f a = b then ΞΌ a else 0) else 0) = | |
| if f a = b then (if P (f a) then ΞΌ a else 0) else 0 := by | |
| intro b | |
| by_cases hb : f a = b | |
| Β· subst b; simp | |
| Β· simp [hb] | |
| simp only [h, Finset.sum_ite_eq, Finset.mem_univ, ite_true] | |
| end FiniteLaw | |
| /- The actual fair-switch binary sweep sends every given slot uniformly. | |
| In particular this is not imported as a hypothesis on the line law. -/ | |
| theorem binaryLaw_one_card (d : β) (x y : Cube d) : | |
| (β Ο, if Ο x = y then binaryLaw d Ο else 0) = (2^d : β)β»ΒΉ := by | |
| unfold binaryLaw | |
| have hm := FiniteLaw.map_event (FiniteLaw.uniform (BinaryChoices d)) (binarySweep d) (fun Ο => Ο x = y) | |
| have he : (β Ο, if Ο x = y then | |
| (FiniteLaw.uniform (BinaryChoices d)).map (binarySweep d) Ο else 0) = | |
| β bits : BinaryChoices d, if binarySweep d bits x = y then | |
| FiniteLaw.uniform (BinaryChoices d) bits else 0 := by | |
| convert hm using 1 <;> congr! | |
| rw [he, FiniteLaw.uniform_pi] | |
| simp only [binarySweep_eq_iff_coins] | |
| change (β bits : BinaryChoices d, | |
| if β j, bits j (binaryPathLine x y j) = Bool.xor (x j) (y j) then | |
| β j, FiniteLaw.uniform (({k : Fin d // k β j} β Bool) β Bool) (bits j) else 0) = _ | |
| have hs := sum_prod_ite_all | |
| (fun j (b : ({k : Fin d // k β j} β Bool) β Bool) => FiniteLaw.uniform _ b) | |
| (fun j (b : ({k : Fin d // k β j} β Bool) β Bool) => | |
| b (binaryPathLine x y j) = Bool.xor (x j) (y j)) | |
| calc | |
| _ = β j : Fin d, β b : ({k : Fin d // k β j} β Bool) β Bool, | |
| if b (binaryPathLine x y j) = Bool.xor (x j) (y j) then FiniteLaw.uniform _ b else 0 := by | |
| convert hs using 1 <;> congr! | |
| _ = β _j : Fin d, (2 : β)β»ΒΉ := by | |
| apply Finset.prod_congr rfl | |
| intro j _ | |
| have hu := FiniteLaw.uniform_eval (binaryPathLine x y j) (Bool.xor (x j) (y j)) | |
| convert hu using 1 <;> congr! | |
| _ = _ := by simp [β inv_pow] | |
| end CoordinateSweeps | |
| namespace CoordinateSweeps | |
| /- The uniform permutation law has the same exact one-card marginal. -/ | |
| theorem uniformLaw_one_card (d : β) (x y : Cube d) : | |
| (β Ο : Equiv.Perm (Cube d), if Ο x = y then FiniteLaw.uniform _ Ο else 0) = | |
| (2^d : β)β»ΒΉ := by | |
| let ex : Fin 1 βͺ Cube d := β¨fun _ => x, fun _ _ _ => Subsingleton.elim _ _β© | |
| let ey : Fin 1 βͺ Cube d := β¨fun _ => y, fun _ _ _ => Subsingleton.elim _ _β© | |
| have hu := FiniteLaw.uniform_assignments ex ey | |
| have hp : β Ο : Equiv.Perm (Cube d), ex.trans Ο.toEmbedding = ey β Ο x = y := by | |
| intro Ο | |
| constructor | |
| Β· intro he | |
| have hh := congrArg (fun e : Fin 1 βͺ Cube d => e 0) he | |
| exact hh | |
| Β· intro he | |
| apply Function.Embedding.ext | |
| intro i | |
| exact he | |
| simp only [FiniteLaw.assignments, hp] at hu | |
| have hc : Fintype.card (Cube d) = 2^d := by simp [Cube] | |
| simp only [hc, Nat.descFactorial_one, Nat.cast_pow, Nat.cast_ofNat] at hu | |
| convert hu using 1 | |
| /- No auxiliary marginal hypothesis remains: this is the manuscript's real | |
| line law, including either endpoint value of the mixture parameter. -/ | |
| theorem lineLaw_one_card (d : β) (z : β) (hz : 0 β€ z) (hz' : z β€ 1) : | |
| Grid.Holes.OneCardUniform (lineLaw d z hz hz') := by | |
| intro x y | |
| change (β Ο, if Ο x = y then | |
| (1-z) * FiniteLaw.uniform _ Ο + z * binaryLaw d Ο else 0) = _ | |
| have hi : β Ο : Equiv.Perm (Cube d), | |
| (if Ο x = y then (1-z) * FiniteLaw.uniform _ Ο + z * binaryLaw d Ο else 0) = | |
| (1-z) * (if Ο x = y then FiniteLaw.uniform _ Ο else 0) + | |
| z * (if Ο x = y then binaryLaw d Ο else 0) := by | |
| intro Ο; by_cases h : Ο x = y <;> simp [h] | |
| simp only [hi, Finset.sum_add_distrib, β Finset.mul_sum] | |
| have hu : (β Ο : Equiv.Perm (Cube d), if Ο x = y then FiniteLaw.uniform _ Ο else 0) = | |
| (2^d : β)β»ΒΉ := uniformLaw_one_card d x y | |
| have hb : (β Ο : Equiv.Perm (Cube d), if Ο x = y then binaryLaw d Ο else 0) = | |
| (2^d : β)β»ΒΉ := binaryLaw_one_card d x y | |
| rw [hu, hb] | |
| ring | |
| /- Isolated-path cancellation, now for the literal conditioned sweep law. -/ | |
| theorem Grid.Holes.placementKernel_lineLaw_eq_zero_of_isolated | |
| {G : Grid} {h k : β} (H : G.Holes h) (x y : Fin k β G.Slot) | |
| (i : Fin k) (his : H.LineIsolated x y i) | |
| (z : β) (hz : 0 β€ z) (hz' : z β€ 1) : | |
| H.placementKernel x y (fun j => lineLaw (G.bits j) z hz hz') = 0 := by | |
| exact H.placementKernel_eq_zero_of_isolated x y i his _ | |
| (fun j => lineLaw_one_card (G.bits j) z hz hz') | |
| end CoordinateSweeps | |
| noncomputable section | |
| open scoped BigOperators | |
| attribute [local instance] Classical.propDecidable | |
| namespace CoordinateSweeps.Grid | |
| variable (G : Grid) | |
| def spliceEquiv (t : Fin (G.b+1)) : (G.Slot Γ G.Slot) β (G.Slot Γ G.Slot) where | |
| toFun p := (G.pathBetween p.1 p.2 t, G.pathBetween p.2 p.1 t) | |
| invFun p := (G.pathBetween p.1 p.2 t, G.pathBetween p.2 p.1 t) | |
| left_inv p := by | |
| apply Prod.ext <;> funext j <;> simp only [pathBetween] <;> split_ifs <;> rfl | |
| right_inv p := by | |
| apply Prod.ext <;> funext j <;> simp only [pathBetween] <;> split_ifs <;> rfl | |
| /- Exact counting identity for one layer of an independent endpoint pair. -/ | |
| theorem sum_pathBetween (t : Fin (G.b+1)) (f : G.Slot β β) : | |
| (β p : G.Slot Γ G.Slot, f (G.pathBetween p.1 p.2 t)) = | |
| (G.size : β) * β x : G.Slot, f x := by | |
| calc | |
| _ = β p : G.Slot Γ G.Slot, f p.1 := by | |
| exact Equiv.sum_comp (G.spliceEquiv t) (fun p => f p.1) | |
| _ = _ := by | |
| rw [Fintype.sum_prod_type] | |
| simp only [Finset.sum_const, Finset.card_univ, G.card_slot, nsmul_eq_mul] | |
| rw [Finset.mul_sum] | |
| /- A uniform slot chooses each stage-line with probability m_j/s. -/ | |
| theorem sum_slot_line (j : Fin G.b) (L : G.Line j) (c : β) : | |
| (β x : G.Slot, if (fun k : {k : Fin G.b // k β j} => x k) = L then c else 0) = | |
| (2^G.bits j : β) * c := by | |
| let e := Equiv.piSplitAt j (fun k => Cube (G.bits k)) | |
| rw [β Equiv.sum_comp e.symm, Fintype.sum_prod_type] | |
| have he : β u : Cube (G.bits j), β v : G.Line j, | |
| (fun k : {k : Fin G.b // k β j} => e.symm (u,v) k) = v := by | |
| intro u v | |
| funext k | |
| simp [e, Equiv.piSplitAt_symm_apply, k.property] | |
| simp only [he, Finset.sum_ite_eq', Finset.mem_univ, ite_true, | |
| Finset.sum_const, Finset.card_univ, nsmul_eq_mul] | |
| simp [Cube] | |
| /- Uniform product weight on the full pair of endpoints, with replacement. -/ | |
| def endpointWeight (p : G.Slot Γ G.Slot) : β := FiniteLaw.uniform _ p | |
| theorem endpointWeight_nonneg (p : G.Slot Γ G.Slot) : 0 β€ G.endpointWeight p := | |
| (FiniteLaw.uniform _).nonneg p | |
| theorem endpointWeight_total : β p, G.endpointWeight p = 1 := FiniteLaw.sum_mass _ | |
| /- A single fixed vertex-sharing event has exact probability 1/s. -/ | |
| theorem probability_path_vertex (t : Fin (G.b+1)) (v : G.Slot) : | |
| (β p : G.Slot Γ G.Slot, if G.pathBetween p.1 p.2 t = v then G.endpointWeight p else 0) = | |
| (G.size : β)β»ΒΉ := by | |
| have hs := G.sum_pathBetween t (fun x => if x = v then | |
| (Fintype.card (G.Slot Γ G.Slot) : β)β»ΒΉ else 0) | |
| have hn : (G.size : β) β 0 := by | |
| exact_mod_cast (show G.size β 0 by rw [β G.card_slot]; exact Fintype.card_ne_zero) | |
| calc | |
| _ = (G.size : β) * β x : G.Slot, if x = v then | |
| (Fintype.card (G.Slot Γ G.Slot) : β)β»ΒΉ else 0 := by | |
| convert hs using 1 | |
| congr! | |
| _ = _ := by | |
| simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, Fintype.card_prod, G.card_slot, | |
| Nat.cast_mul] | |
| field_simp | |
| /- A single stage-line-sharing event has exact probability m_j/s. -/ | |
| theorem probability_path_line (j : Fin G.b) (L : G.Line j) : | |
| (β p : G.Slot Γ G.Slot, if G.pathLine p.1 p.2 j = L then G.endpointWeight p else 0) = | |
| (2^G.bits j : β) / G.size := by | |
| have hs := G.sum_pathBetween j.castSucc (fun x => | |
| if (fun k : {k : Fin G.b // k β j} => x k) = L then | |
| (Fintype.card (G.Slot Γ G.Slot) : β)β»ΒΉ else 0) | |
| have hn : (G.size : β) β 0 := by | |
| exact_mod_cast (show G.size β 0 by rw [β G.card_slot]; exact Fintype.card_ne_zero) | |
| calc | |
| _ = (G.size : β) * β x : G.Slot, | |
| if (fun k : {k : Fin G.b // k β j} => x k) = L then | |
| (Fintype.card (G.Slot Γ G.Slot) : β)β»ΒΉ else 0 := by | |
| convert hs using 1 | |
| congr! | |
| _ = _ := by | |
| rw [G.sum_slot_line] | |
| simp only [Fintype.card_prod, G.card_slot, Nat.cast_mul] | |
| field_simp | |
| end CoordinateSweeps.Grid | |
| namespace CoordinateSweeps.Coverage | |
| /- The union bound on a single finite random datum. -/ | |
| theorem sum_ite_exists_le {X J : Type*} [Fintype X] [Fintype J] | |
| (w : X β β) (hw : β x, 0 β€ w x) (P : J β X β Prop) : | |
| (β x, if β j, P j x then w x else 0) β€ β j, β x, if P j x then w x else 0 := by | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| have hpj : β j, 0 β€ (if P j x then w x else 0) := by | |
| intro j; split_ifs; exact hw x; exact le_rfl | |
| by_cases he : β j, P j x | |
| Β· obtain β¨j,hjβ© := he | |
| rw [ite_eq_left β¨j,hjβ©] | |
| have hh := Finset.single_le_sum (fun j _ => hpj j) (Finset.mem_univ j) | |
| simpa only [ite_eq_left hj] using hh | |
| Β· rw [ite_eq_right he] | |
| exact Finset.sum_nonneg (fun j _ => hpj j) | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Grid | |
| variable (G : Grid) | |
| /- Sharing means using the same decorated line at the same stage. -/ | |
| def lineShares (p q : G.Slot Γ G.Slot) : Prop := | |
| β j : Fin G.b, G.pathLine p.1 p.2 j = G.pathLine q.1 q.2 j | |
| /- Vertex sharing means the same slot at one fixed stage boundary. -/ | |
| def vertexShares (p q : G.Slot Γ G.Slot) : Prop := | |
| β t : Fin (G.b+1), G.pathBetween p.1 p.2 t = G.pathBetween q.1 q.2 t | |
| theorem lineShares_symm : β β¦left rightβ¦, G.lineShares left right β G.lineShares right left := by | |
| rintro p q β¨j,hjβ© | |
| exact β¨j,hj.symmβ© | |
| theorem vertexShares_symm : β β¦left rightβ¦, G.vertexShares left right β G.vertexShares right left := by | |
| rintro p q β¨j,hjβ© | |
| exact β¨j,hj.symmβ© | |
| def lineSharingRate : β := β j : Fin G.b, (2^G.bits j : β) / G.size | |
| def vertexSharingRate : β := (G.b+1 : β) / (G.size : β) | |
| theorem lineSharingRate_nonneg : 0 β€ G.lineSharingRate := by | |
| apply Finset.sum_nonneg | |
| intro j _ | |
| positivity | |
| theorem vertexSharingRate_nonneg : 0 β€ G.vertexSharingRate := by | |
| unfold vertexSharingRate | |
| positivity | |
| theorem probability_lineShares_le (q : G.Slot Γ G.Slot) : | |
| (β p, if G.lineShares p q then G.endpointWeight p else 0) β€ G.lineSharingRate := by | |
| have hu := Coverage.sum_ite_exists_le G.endpointWeight G.endpointWeight_nonneg | |
| (fun j : Fin G.b => fun p : G.Slot Γ G.Slot => | |
| G.pathLine p.1 p.2 j = G.pathLine q.1 q.2 j) | |
| calc | |
| _ β€ β j : Fin G.b, β p : G.Slot Γ G.Slot, | |
| if G.pathLine p.1 p.2 j = G.pathLine q.1 q.2 j then G.endpointWeight p else 0 := by | |
| convert hu using 1 <;> congr! | |
| _ = _ := by | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| exact G.probability_path_line j (G.pathLine q.1 q.2 j) | |
| theorem probability_vertexShares_le (q : G.Slot Γ G.Slot) : | |
| (β p, if G.vertexShares p q then G.endpointWeight p else 0) β€ G.vertexSharingRate := by | |
| have hu := Coverage.sum_ite_exists_le G.endpointWeight G.endpointWeight_nonneg | |
| (fun j : Fin (G.b+1) => fun p : G.Slot Γ G.Slot => | |
| G.pathBetween p.1 p.2 j = G.pathBetween q.1 q.2 j) | |
| calc | |
| _ β€ β j : Fin (G.b+1), β p : G.Slot Γ G.Slot, | |
| if G.pathBetween p.1 p.2 j = G.pathBetween q.1 q.2 j then G.endpointWeight p else 0 := by | |
| convert hu using 1 <;> congr! | |
| _ = β _j : Fin (G.b+1), (G.size : β)β»ΒΉ := by | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| exact G.probability_path_vertex j (G.pathBetween q.1 q.2 j) | |
| _ = _ := by simp [vertexSharingRate, div_eq_mul_inv] | |
| namespace Holes | |
| variable {G} {h k : β} | |
| /- Keep the actual prescribed hole paths, recording their endpoints. -/ | |
| def endpointData (H : G.Holes h) (i : Fin h) : G.Slot Γ G.Slot := | |
| (H.path i 0, H.path i (Fin.last G.b)) | |
| /- The source's feasibility ensures these endpoints reconstruct the entire | |
| prescribed trajectory, not merely an unrelated bridge between its endpoints. -/ | |
| theorem path_eq_pathBetween (H : G.Holes h) (hH : H.Feasible) | |
| (i : Fin h) (t : Fin (G.b+1)) : | |
| H.path i t = G.pathBetween (H.endpointData i).1 (H.endpointData i).2 t := by | |
| obtain β¨Ο,hΟβ© := hH | |
| have hb := G.boundary_eq_pathBetween Ο (H.path i 0) t | |
| have hl := hΟ i (Fin.last G.b) | |
| change G.sweep Ο (H.path i 0) = H.path i (Fin.last G.b) at hl | |
| rw [hΟ i t, hl] at hb | |
| exact hb | |
| /- A card not covered by any line-sharing has exactly the isolation property | |
| needed for the alternating probability kernel. -/ | |
| theorem lineIsolated_of_not_covered (H : G.Holes h) (hH : H.Feasible) | |
| (x : Fin k β G.Slot Γ G.Slot) (i : Fin k) | |
| (hi : i β Coverage.sharingCoverage G.lineShares H.endpointData x) : | |
| H.LineIsolated (fun a => (x a).1) (fun a => (x a).2) i := by | |
| have h0 : Β¬ ((β a : Fin k, i β a β§ G.lineShares (x i) (x a)) β¨ | |
| β a : Fin h, G.lineShares (x i) (H.endpointData a)) := by | |
| simpa only [Coverage.sharingCoverage, Coverage.mem_covered] using hi | |
| constructor | |
| Β· intro j a ha | |
| apply h0 | |
| right | |
| refine β¨a,j,?_β© | |
| change (fun k : {k : Fin G.b // k β j} => H.path a j.castSucc k) = G.pathLine (x i).1 (x i).2 j at ha | |
| rw [H.path_eq_pathBetween hH a j.castSucc] at ha | |
| exact ha.symm | |
| Β· intro j a hai ha | |
| apply h0 | |
| left | |
| exact β¨a,hai.symm,j,ha.symmβ© | |
| /- Nonzero Q entries require coverage of every auxiliary particle, for the | |
| literal real line mixture and full feasible path conditioning. -/ | |
| theorem placementKernel_ne_zero_coverage (H : G.Holes h) (hH : H.Feasible) | |
| (x : Fin k β G.Slot Γ G.Slot) (z : β) (hz : 0 β€ z) (hz' : z β€ 1) | |
| (hQ : H.placementKernel (fun a => (x a).1) (fun a => (x a).2) | |
| (fun j => lineLaw (G.bits j) z hz hz') β 0) : | |
| (Coverage.sharingCoverage G.lineShares H.endpointData x).card = k := by | |
| have hall : Coverage.sharingCoverage G.lineShares H.endpointData x = Finset.univ := by | |
| apply Finset.eq_univ_of_forall | |
| intro i | |
| by_contra hi | |
| exact hQ (H.placementKernel_lineLaw_eq_zero_of_isolated _ _ i | |
| (H.lineIsolated_of_not_covered hH x i hi) z hz hz') | |
| simp [hall] | |
| /- The exact full-array probability bound needed to estimate the counting | |
| Hilbert--Schmidt norm in the many-coordinate sparse case. -/ | |
| theorem probability_nonzero_placementKernel_le (H : G.Holes h) (hH : H.Feasible) | |
| (z : β) (hz : 0 β€ z) (hz' : z β€ 1) | |
| (hsmall : ((k+h : β) : β) * G.lineSharingRate β€ 1) : | |
| Coverage.probability G.endpointWeight (fun x : Fin k β G.Slot Γ G.Slot => | |
| H.placementKernel (fun a => (x a).1) (fun a => (x a).2) | |
| (fun j => lineLaw (G.bits j) z hz hz') β 0) β€ | |
| (2 : β)^k * (((k+h : β) : β) * G.lineSharingRate)^((k : β)/2) := by | |
| have ht := Coverage.probability_coverage_le (I := Fin k) G.lineShares G.lineShares_symm H.endpointData | |
| G.endpointWeight G.endpointWeight_nonneg G.endpointWeight_total | |
| G.lineSharingRate G.lineSharingRate_nonneg G.probability_lineShares_le | |
| (by simpa using hsmall) k | |
| calc | |
| _ β€ Coverage.probability G.endpointWeight (fun x : Fin k β G.Slot Γ G.Slot => | |
| k β€ (Coverage.sharingCoverage G.lineShares H.endpointData x).card) := | |
| Coverage.probability_mono G.endpointWeight G.endpointWeight_nonneg | |
| (fun x hx => (H.placementKernel_ne_zero_coverage hH x z hz hz' hx).ge) | |
| _ β€ _ := by simpa using ht | |
| end Holes | |
| end CoordinateSweeps.Grid | |
| end | |
| end | |
| open scoped Matrix.Norms.L2Operator | |
| end OAI | |