Download data/lean/OAI/Combinatorics/Graphs/Coverage.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 31.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Graphs/Coverage.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/Graphs/Coverage.lean
-
curl -L -o Coverage.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/Graphs/Coverage.lean
31.8 kB
| import Mathlib | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder | |
| attribute [local instance] Classical.propDecidable | |
| noncomputable section | |
| open scoped BigOperators | |
| attribute [local instance] Classical.propDecidable | |
| namespace CoordinateSweeps.Coverage | |
| variable {I H : Type*} [Fintype I] [DecidableEq I] | |
| /- Oriented edges crossing a two-color cut. -/ | |
| def cutEdges (R : I β I β Prop) (c : I β Bool) : Finset (I Γ I) := | |
| Finset.univ.filter (fun p => R p.1 p.2 β§ c p.1 β c p.2) | |
| omit [DecidableEq I] in | |
| @[simp] theorem mem_cutEdges (R : I β I β Prop) (c : I β Bool) (i j : I) : | |
| (i,j) β cutEdges R c β R i j β§ c i β c j := by simp [cutEdges] | |
| /- A maximum cut has an opposite-color neighbor at every nonisolated vertex. | |
| Only symmetry and absence of loops are used. -/ | |
| theorem exists_crossing_cut (R : I β I β Prop) | |
| (hsym : β β¦left rightβ¦, R left right β R right left) (hirr : β vertex, Β¬ R vertex vertex) : | |
| β c : I β Bool, β i, (β j, R i j) β β j, R i j β§ c i β c j := by | |
| obtain β¨c, _, hcβ© := Finset.exists_max_image | |
| (Finset.univ : Finset (I β Bool)) (fun c => (cutEdges R c).card) Finset.univ_nonempty | |
| refine β¨c, ?_β© | |
| intro i hi | |
| by_contra hh | |
| have hn : β j, R i j β c i = c j := by | |
| intro j hij | |
| by_contra hne | |
| exact hh β¨j,hij,hneβ© | |
| let c' := Function.update c i (!(c i)) | |
| have hsub : cutEdges R c β cutEdges R c' := by | |
| intro p hp | |
| obtain β¨hpR,hpneβ© := (mem_cutEdges R c p.1 p.2).mp hp | |
| have hpi : p.1 β i := by | |
| intro he; subst he | |
| exact hpne (hn _ hpR) | |
| have hpj : p.2 β i := by | |
| intro he | |
| have heq := hn p.1 (hsym (he βΈ hpR)) | |
| exact hpne (he βΈ heq.symm) | |
| apply (mem_cutEdges R c' p.1 p.2).mpr | |
| exact β¨hpR, by simpa [c', Function.update_of_ne hpi, Function.update_of_ne hpj] using hpneβ© | |
| obtain β¨j,hijβ© := hi | |
| have hji : j β i := by intro he; subst j; exact hirr i hij | |
| have hnew : (i,j) β cutEdges R c' := by | |
| rw [mem_cutEdges] | |
| refine β¨hij, ?_β© | |
| simp only [c', Function.update_self, Function.update_of_ne hji] | |
| rw [β hn j hij] | |
| cases c i <;> decide | |
| have hold : (i,j) β cutEdges R c := by simp [hn j hij] | |
| have hlt : (cutEdges R c).card < (cutEdges R c').card := | |
| Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr β¨hsub, by | |
| intro he; rw [he] at hold; exact hold hnewβ©) | |
| exact (not_lt_of_ge (hc c' (Finset.mem_univ _))) hlt | |
| /- Particles incident to a particle-sharing edge or a fixed hole. -/ | |
| def covered (R : I β I β Prop) (T : I β H β Prop) : Finset I := | |
| Finset.univ.filter (fun i => (β j, R i j) β¨ (β l, T i l)) | |
| omit [DecidableEq I] in | |
| @[simp] theorem mem_covered (R : I β I β Prop) (T : I β H β Prop) (i : I) : | |
| i β covered R T β (β j, R i j) β¨ (β l, T i l) := by simp [covered] | |
| /- A star forest supplies at least half as many distinct particle tails as | |
| there are covered particles, with all parents outside the chosen tails. -/ | |
| theorem exists_star_forest (R : I β I β Prop) (T : I β H β Prop) | |
| (hsym : β β¦left rightβ¦, R left right β R right left) (hirr : β vertex, Β¬ R vertex vertex) : | |
| β A : Finset I, A β covered R T β§ (covered R T).card β€ 2*A.card β§ | |
| β i β A, (β j, j β A β§ R i j) β¨ (β l, T i l) := by | |
| obtain β¨c,hcβ© := exists_crossing_cut R hsym hirr | |
| let A := (covered R T).filter (fun i => c i = false) | |
| let B := (covered R T).filter (fun i => c i = true) | |
| have hAB : (covered R T).card = A.card + B.card := by | |
| have hpart := Finset.card_filter_add_card_filter_not (s := covered R T) | |
| (p := fun i => c i = false) | |
| have he : B = (covered R T).filter (fun i => Β¬ c i = false) := by | |
| ext i | |
| simp only [B, Finset.mem_filter] | |
| cases c i <;> simp | |
| rw [he] | |
| exact hpart.symm | |
| have hA : β i β A, (β j, j β A β§ R i j) β¨ (β l, T i l) := by | |
| intro i hi | |
| obtain β¨hcov,hciβ© := Finset.mem_filter.mp hi | |
| rcases (mem_covered R T i).mp hcov with h | h | |
| Β· obtain β¨j,hij,hneβ© := hc i h | |
| left | |
| refine β¨j,?_,hijβ© | |
| intro hj | |
| have hcj := (Finset.mem_filter.mp hj).2 | |
| exact hne (hci.trans hcj.symm) | |
| Β· exact Or.inr h | |
| have hB : β i β B, (β j, j β B β§ R i j) β¨ (β l, T i l) := by | |
| intro i hi | |
| obtain β¨hcov,hciβ© := Finset.mem_filter.mp hi | |
| rcases (mem_covered R T i).mp hcov with h | h | |
| Β· obtain β¨j,hij,hneβ© := hc i h | |
| left | |
| refine β¨j,?_,hijβ© | |
| intro hj | |
| have hcj := (Finset.mem_filter.mp hj).2 | |
| exact hne (hci.trans hcj.symm) | |
| Β· exact Or.inr h | |
| by_cases hle : A.card β€ B.card | |
| Β· exact β¨B, Finset.filter_subset _ _, by omega, hBβ© | |
| Β· exact β¨A, Finset.filter_subset _ _, by omega, hAβ© | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] | |
| /- Product mass of independent particle data. -/ | |
| def productMass (w : X β β) (x : I β X) : β := β i, w (x i) | |
| /- Finite event probability, with the product law on the full endpoint array. -/ | |
| def probability (w : X β β) (P : (I β X) β Prop) : β := | |
| β x : I β X, if P x then productMass w x else 0 | |
| def glue (A : Finset I) (x : A β X) (y : {i : I // i β A} β X) : I β X := | |
| (Equiv.piEquivPiSubtypeProd (fun i => i β A) (fun _ => X)).symm (x,y) | |
| omit [Fintype I] [Fintype X] in | |
| @[simp] theorem glue_mem (A : Finset I) (x : A β X) (y : {i : I // i β A} β X) | |
| (i : A) : glue A x y i = x i := by | |
| simp [glue, Equiv.piEquivPiSubtypeProd_symm_apply, i.property] | |
| omit [Fintype I] [Fintype X] in | |
| @[simp] theorem glue_not_mem (A : Finset I) (x : A β X) (y : {i : I // i β A} β X) | |
| (i : {i : I // i β A}) : glue A x y i = y i := by | |
| simp [glue, Equiv.piEquivPiSubtypeProd_symm_apply, i.property] | |
| omit [Fintype X] in | |
| theorem productMass_glue (A : Finset I) (w : X β β) | |
| (x : A β X) (y : {i : I // i β A} β X) : | |
| productMass w (glue A x y) = (β i, w (x i)) * β j, w (y j) := by | |
| unfold productMass | |
| rw [β Fintype.prod_subtype_mul_prod_subtype (fun i => i β A)] | |
| simp only [glue_mem, glue_not_mem] | |
| congr! | |
| /- Reused elementary finite independence identity, inline. -/ | |
| theorem sum_prod_ite_all {J : Type*} [Fintype J] [DecidableEq J] | |
| {Y : J β Type*} [β j, Fintype (Y j)] | |
| (w : β j, Y j β β) (P : β j, Y j β Prop) : | |
| (β x : β j, Y j, if β j, P j (x j) then β j, w j (x j) else 0) = | |
| β j, β y, if P j y then w j y else 0 := by | |
| rw [Fintype.prod_sum] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hx : β j, P j (x j) | |
| Β· simp [hx] | |
| Β· obtain β¨j,hjβ© := not_forall.mp hx | |
| rw [ite_eq_right hx] | |
| symm | |
| apply Finset.prod_eq_zero (Finset.mem_univ j) | |
| simp [hj] | |
| /- Conditional on all roots, different star tails involve independent data. | |
| This is a factorization of the actual finite sum, not an independence axiom. -/ | |
| theorem probability_star_factorization (A : Finset I) (w : X β β) | |
| (P : ({i : I // i β A} β X) β A β X β Prop) : | |
| probability w (fun x : I β X => β i : A, P (fun j => x j) i (x i)) = | |
| β y : {i : I // i β A} β X, | |
| (β j, w (y j)) * β i : A, β t : X, if P y i t then w t else 0 := by | |
| unfold probability | |
| let e := Equiv.piEquivPiSubtypeProd (fun i => i β A) (fun _ => X) | |
| rw [β Equiv.sum_comp e.symm, Fintype.sum_prod_type, Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| have hg : β x : A β X, | |
| (if β i : A, P (fun j => e.symm (x,y) j) i (e.symm (x,y) i) | |
| then productMass w (e.symm (x,y)) else 0) = | |
| (β j, w (y j)) * (if β i : A, P y i (x i) then β i, w (x i) else 0) := by | |
| intro x | |
| change (if β i : A, P (fun j => glue A x y j) i (glue A x y i) | |
| then productMass w (glue A x y) else 0) = _ | |
| simp only [glue_mem, glue_not_mem, productMass_glue] | |
| split_ifs <;> ring | |
| calc | |
| _ = β x : A β X, (β j, w (y j)) * | |
| (if β i : A, P y i (x i) then β i, w (x i) else 0) := by | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| convert hg x using 1 | |
| congr! | |
| _ = (β j, w (y j)) * (β x : A β X, | |
| if β i : A, P y i (x i) then β i, w (x i) else 0) := by rw [Finset.mul_sum] | |
| _ = _ := by | |
| congr 1 | |
| exact sum_prod_ite_all (fun (_ : A) t => w t) (P y) | |
| /- The source's leaf elimination bound for the star witnesses selected above. -/ | |
| theorem probability_star_le (A : Finset I) (w : X β β) | |
| (hw : β x, 0 β€ w x) (hs : β x, w x = 1) (Ο : β) (hΟ : 0 β€ Ο) | |
| (P : ({i : I // i β A} β X) β A β X β Prop) | |
| (hP : β y i, (β t : X, if P y i t then w t else 0) β€ Ο) : | |
| probability w (fun x : I β X => β i : A, P (fun j => x j) i (x i)) β€ Ο^A.card := by | |
| rw [probability_star_factorization] | |
| have hprod : β y : {i : I // i β A} β X, | |
| (β i : A, β t : X, if P y i t then w t else 0) β€ Ο^A.card := by | |
| intro y | |
| calc | |
| _ β€ β _i : A, Ο := by | |
| apply Finset.prod_le_prodβ | |
| Β· intro i _; exact Finset.sum_nonneg (fun t _ => by split_ifs; exact hw t; exact le_rfl) | |
| Β· intro i _; exact hP y i | |
| _ = _ := by simp | |
| calc | |
| _ β€ β y : {i : I // i β A} β X, (β j, w (y j)) * Ο^A.card := by | |
| apply Finset.sum_le_sum | |
| intro y _ | |
| exact mul_le_mul_of_nonneg_left (hprod y) (Finset.prod_nonneg (fun j _ => hw _)) | |
| _ β€ 1 * Ο^A.card := by | |
| rw [β Finset.sum_mul] | |
| apply mul_le_mul_of_nonneg_right _ (pow_nonneg hΟ _) | |
| rw [β Fintype.prod_sum] | |
| simp [hs] | |
| _ = Ο^A.card := one_mul _ | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I H : Type*} [Fintype I] [DecidableEq I] | |
| /- A finite directed star system. Distinct tails are indexed by the subtype A; | |
| the parent lies outside A or is a hole. -/ | |
| def starSystem (R : I β I β Prop) (T : I β H β Prop) | |
| (A : Finset I) (p : A β I β H) : Prop := | |
| β i : A, match p i with | |
| | .inl j => j β A β§ R i j | |
| | .inr l => T i l | |
| /- The witness can be trimmed to any requested number of tails up to half | |
| (rounded up) of the number of covered particles. -/ | |
| theorem exists_star_system (R : I β I β Prop) (T : I β H β Prop) | |
| (hsym : β β¦left rightβ¦, R left right β R right left) (hirr : β vertex, Β¬ R vertex vertex) (j : β) | |
| (hj : j β€ ((covered R T).card + 1)/2) : | |
| β A : Finset I, A.card = j β§ β p : A β I β H, starSystem R T A p := by | |
| obtain β¨B,_,hB,hparβ© := exists_star_forest R T hsym hirr | |
| have hjB : j β€ B.card := by omega | |
| obtain β¨A,hAB,hAcβ© := Finset.exists_subset_card_eq hjB | |
| have hp : β i : A, β r : I β H, match r with | |
| | .inl l => l β A β§ R i l | |
| | .inr l => T i l := by | |
| intro i | |
| rcases hpar i (hAB i.property) with β¨l,hl,hRβ© | β¨l,hTβ© | |
| Β· exact β¨.inl l, fun hm => hl (hAB hm), hRβ© | |
| Β· exact β¨.inr l, hTβ© | |
| choose p hp using hp | |
| exact β¨A,hAc,p,hpβ© | |
| variable {X : Type*} [Fintype X] | |
| /- The sharing event of one directed system under the full independent data. | |
| Forbidden parent choices simply give an empty event. -/ | |
| def starEvent (S : X β X β Prop) (holes : H β X) | |
| (A : Finset I) (p : A β I β H) (x : I β X) : Prop := | |
| starSystem (fun i j => S (x i) (x j)) (fun i l => S (x i) (holes l)) A p | |
| /- A tail predicate with the values at all its possible roots fixed. -/ | |
| def rootPredicate (S : X β X β Prop) (holes : H β X) | |
| (A : Finset I) (p : A β I β H) | |
| (y : {i : I // i β A} β X) (i : A) (t : X) : Prop := | |
| match p i with | |
| | .inl j => if hj : j β A then S t (y β¨j,hjβ©) else False | |
| | .inr l => S t (holes l) | |
| omit [Fintype I] [Fintype X] in | |
| theorem starEvent_iff_root (S : X β X β Prop) (holes : H β X) | |
| (A : Finset I) (p : A β I β H) (x : I β X) : | |
| starEvent S holes A p x β | |
| β i : A, rootPredicate S holes A p (fun j => x j) i (x i) := by | |
| unfold starEvent starSystem rootPredicate | |
| apply forall_congr' | |
| intro i | |
| cases p i with | |
| | inl j => by_cases hj : j β A <;> simp [hj] | |
| | inr l => rfl | |
| /- For every particular system of j distinct tails toward non-tail parents, | |
| the sharing probability is at most Ο^j, with no layer independence premise. -/ | |
| theorem probability_starEvent_le (S : X β X β Prop) (holes : H β X) | |
| (A : Finset I) (p : A β I β H) (w : X β β) | |
| (hw : β x, 0 β€ w x) (hs : β x, w x = 1) (Ο : β) (hΟ : 0 β€ Ο) | |
| (hS : β y, (β t : X, if S t y then w t else 0) β€ Ο) : | |
| probability w (starEvent S holes A p) β€ Ο^A.card := by | |
| have he : starEvent S holes A p = | |
| (fun x : I β X => β i : A, rootPredicate S holes A p (fun j => x j) i (x i)) := by | |
| funext x | |
| exact propext (starEvent_iff_root S holes A p x) | |
| rw [he] | |
| apply probability_star_le A w hw hs Ο hΟ | |
| intro y i | |
| unfold rootPredicate | |
| cases hp : p i with | |
| | inl j => | |
| by_cases hj : j β A | |
| Β· simpa only [dite_eq_left hj] using hS (y β¨j,hjβ©) | |
| Β· simpa [hj] using hΟ | |
| | inr l => exact hS (holes l) | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] | |
| omit [DecidableEq I] [Fintype X] in | |
| theorem productMass_nonneg (w : X β β) (hw : β x, 0 β€ w x) (x : I β X) : | |
| 0 β€ productMass w x := Finset.prod_nonneg (fun i _ => hw (x i)) | |
| theorem probability_mono (w : X β β) (hw : β x, 0 β€ w x) | |
| {P Q : (I β X) β Prop} (hPQ : β x, P x β Q x) : | |
| probability w P β€ probability w Q := by | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| by_cases hp : P x | |
| Β· simp only [ite_eq_left hp, ite_eq_left (hPQ x hp)] | |
| exact le_rfl | |
| Β· simp only [ite_eq_right hp] | |
| split_ifs | |
| Β· exact productMass_nonneg w hw x | |
| Β· exact le_rfl | |
| theorem probability_exists_le {J : Type*} [Fintype J] | |
| (w : X β β) (hw : β x, 0 β€ w x) (P : J β (I β X) β Prop) : | |
| probability w (fun x => β j, P j x) β€ β j, probability w (P j) := by | |
| unfold probability | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| have hpj : β j, 0 β€ (if P j x then productMass w x else 0) := by | |
| intro j; split_ifs; exact productMass_nonneg w 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.Coverage | |
| variable {I H : Type*} [Fintype I] [DecidableEq I] [Fintype H] | |
| /- Data encoding exactly j distinct tails and one arbitrary parent per tail. | |
| The sub-event enforces the star/root restrictions. -/ | |
| abbrev Witness (I H : Type*) [Fintype I] (j : β) := | |
| Ξ£ A : {A : Finset I // A.card = j}, (A.val β I β H) | |
| theorem card_witness_le (j : β) : | |
| Fintype.card (Witness I H j) β€ | |
| 2^Fintype.card I * (Fintype.card I + Fintype.card H)^j := by | |
| have hc : β A : {A : Finset I // A.card = j}, | |
| Fintype.card (A.val β I β H) = (Fintype.card I + Fintype.card H)^j := by | |
| intro A | |
| simp [A.property] | |
| have hA : Fintype.card {A : Finset I // A.card = j} β€ 2^Fintype.card I := by | |
| simpa using Fintype.card_le_of_injective | |
| (fun A : {A : Finset I // A.card = j} => A.val) Subtype.val_injective | |
| calc | |
| _ = Fintype.card {A : Finset I // A.card = j} * | |
| (Fintype.card I + Fintype.card H)^j := by | |
| rw [Fintype.card_sigma] | |
| simp only [hc, Finset.sum_const, Finset.card_univ, smul_eq_mul] | |
| _ β€ _ := Nat.mul_le_mul_right _ hA | |
| variable {X : Type*} [Fintype X] | |
| /- Covered particles for the actual symmetric sharing relation on path data. -/ | |
| def sharingCoverage (S : X β X β Prop) (holes : H β X) (x : I β X) : Finset I := | |
| covered (fun i j => i β j β§ S (x i) (x j)) (fun i l => S (x i) (holes l)) | |
| omit [Fintype H] [Fintype X] in | |
| theorem sharingCoverage_witness (S : X β X β Prop) | |
| (hSsym : β β¦left rightβ¦, S left right β S right left) | |
| (holes : H β X) (x : I β X) (n : β) | |
| (hn : n β€ (sharingCoverage S holes x).card) : | |
| β W : Witness I H ((n+1)/2), starEvent S holes W.1.val W.2 x := by | |
| let R : I β I β Prop := fun i j => i β j β§ S (x i) (x j) | |
| let T : I β H β Prop := fun i l => S (x i) (holes l) | |
| have hsym : β β¦left rightβ¦, R left right β R right left := fun i j h => β¨h.1.symm, hSsym h.2β© | |
| have hirr : β vertex, Β¬ R vertex vertex := fun i h => h.1 rfl | |
| have hc : n β€ (covered R T).card := hn | |
| obtain β¨A,hAc,p,hpβ© := exists_star_system R T hsym hirr ((n+1)/2) (by omega) | |
| refine β¨β¨β¨A,hAcβ©,pβ©,?_β© | |
| intro i | |
| have hi := hp i | |
| cases hpi : p i with | |
| | inl j => | |
| simp only [hpi] at hi β’ | |
| exact β¨hi.1,hi.2.2β© | |
| | inr l => | |
| simpa only [hpi] using hi | |
| /- Source coverage bound with the slightly stronger integer exponent ceil(n/2). | |
| There is no independence assumption between different path layers. -/ | |
| theorem probability_coverage_le_nat (S : X β X β Prop) | |
| (hSsym : β β¦left rightβ¦, S left right β S right left) | |
| (holes : H β X) (w : X β β) (hw : β x, 0 β€ w x) (hs : β x, w x = 1) | |
| (Ο : β) (hΟ : 0 β€ Ο) | |
| (hS : β y, (β t : X, if S t y then w t else 0) β€ Ο) (n : β) : | |
| probability w (fun x : I β X => n β€ (sharingCoverage S holes x).card) β€ | |
| (2 : β)^Fintype.card I * | |
| (((Fintype.card I + Fintype.card H : β) : β) * Ο)^((n+1)/2) := by | |
| let j := (n+1)/2 | |
| let P : Witness I H j β (I β X) β Prop := | |
| fun W => starEvent S holes W.1.val W.2 | |
| calc | |
| _ β€ probability w (fun x : I β X => β W : Witness I H j, P W x) := | |
| probability_mono w hw (fun x hx => sharingCoverage_witness S hSsym holes x n hx) | |
| _ β€ β W : Witness I H j, probability w (P W) := probability_exists_le w hw P | |
| _ β€ β _W : Witness I H j, Ο^j := by | |
| apply Finset.sum_le_sum | |
| intro W _ | |
| simpa only [W.1.property] using | |
| probability_starEvent_le S holes W.1.val W.2 w hw hs Ο hΟ hS | |
| _ = (Fintype.card (Witness I H j) : β) * Ο^j := by simp | |
| _ β€ (2 : β)^Fintype.card I * | |
| (((Fintype.card I + Fintype.card H : β) : β)^j) * Ο^j := by | |
| apply mul_le_mul_of_nonneg_right _ (pow_nonneg hΟ _) | |
| exact_mod_cast (card_witness_le (I := I) (H := H) j) | |
| _ = _ := by rw [mul_assoc, β mul_pow] | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I H X : Type*} [Fintype I] [DecidableEq I] [Fintype H] [Fintype X] | |
| /- The literal source's coverage estimate (04:eq9), including zero sharing | |
| rate and zero requested coverage, with the real exponent n/2. -/ | |
| theorem probability_coverage_le (S : X β X β Prop) | |
| (hSsym : β β¦left rightβ¦, S left right β S right left) | |
| (holes : H β X) (w : X β β) (hw : β x, 0 β€ w x) (hs : β x, w x = 1) | |
| (Ο : β) (hΟ : 0 β€ Ο) | |
| (hS : β y, (β t : X, if S t y then w t else 0) β€ Ο) | |
| (hsmall : ((Fintype.card I + Fintype.card H : β) : β) * Ο β€ 1) (n : β) : | |
| probability w (fun x : I β X => n β€ (sharingCoverage S holes x).card) β€ | |
| (2 : β)^Fintype.card I * | |
| ((((Fintype.card I + Fintype.card H : β) : β) * Ο) ^ ((n : β)/2)) := by | |
| have hn : n β€ 2*((n+1)/2) := by omega | |
| have hn' : (n : β) β€ 2 * (((n+1)/2 : β) : β) := by exact_mod_cast hn | |
| have hr : | |
| ((((Fintype.card I + Fintype.card H : β) : β) * Ο) ^ ((n+1)/2 : β)) β€ | |
| ((((Fintype.card I + Fintype.card H : β) : β) * Ο) ^ ((n : β)/2)) := by | |
| rw [β Real.rpow_natCast] | |
| exact Real.rpow_le_rpow_of_exponent_ge' (by positivity) hsmall (by positivity) (by linarith) | |
| exact (probability_coverage_le_nat S hSsym holes w hw hs Ο hΟ hS n).trans | |
| (mul_le_mul_of_nonneg_left hr (by positivity)) | |
| end CoordinateSweeps.Coverage | |
| end | |
| end | |
| noncomputable section | |
| open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder | |
| attribute [local instance] Classical.propDecidable | |
| noncomputable section | |
| open scoped BigOperators | |
| attribute [local instance] Classical.propDecidable | |
| noncomputable section | |
| open scoped BigOperators | |
| open MvPolynomial | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Real Set Filter | |
| open scoped ENNReal NNReal BigOperators | |
| noncomputable section | |
| open scoped BigOperators | |
| namespace CoordinateSweeps.Coverage | |
| variable {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] | |
| /- Independent occupancy of a fixed measurable subset. The set is fixed | |
| BEFORE taking probability, exactly as required in source04:eq12. -/ | |
| theorem probability_many_hits_le (w : X β β) (hw : β x, 0 β€ w x) | |
| (hs : β x, w x = 1) (P : X β Prop) (p : β) (hp : 0 β€ p) | |
| (hP : (β x, if P x then w x else 0) β€ p) (n : β) : | |
| probability w (fun x : I β X => n β€ (Finset.univ.filter (fun i => P (x i))).card) β€ | |
| (2 : β)^Fintype.card I * p^n := by | |
| let W := {A : Finset I // A.card = n} | |
| have hcover (x : I β X) (hx : n β€ (Finset.univ.filter (fun i => P (x i))).card) : | |
| β A : W, β i : A.val, P (x i) := by | |
| obtain β¨A,hA,hAcβ© := Finset.exists_subset_card_eq hx | |
| exact β¨β¨A,hAcβ©, fun i => (Finset.mem_filter.mp (hA i.property)).2β© | |
| have hprob (A : W) : probability w (fun x : I β X => β i : A.val, P (x i)) β€ p^n := by | |
| simpa only [A.property] using probability_star_le A.val w hw hs p hp | |
| (fun _ _ x => P x) (fun _ _ => hP) | |
| calc | |
| _ β€ probability w (fun x : I β X => β A : W, β i : A.val, P (x i)) := | |
| probability_mono w hw hcover | |
| _ β€ β A : W, probability w (fun x : I β X => β i : A.val, P (x i)) := | |
| probability_exists_le w hw _ | |
| _ β€ β _A : W, p^n := Finset.sum_le_sum (fun A _ => hprob A) | |
| _ = (Fintype.card W : β)*p^n := by simp | |
| _ β€ _ := by | |
| apply mul_le_mul_of_nonneg_right _ (pow_nonneg hp _) | |
| exact_mod_cast (Fintype.card_subtype_le (fun A : Finset I => A.card = n)).trans_eq | |
| (Fintype.card_finset (Ξ± := I)) | |
| theorem probability_many_hits_le_rpow (w : X β β) (hw : β x, 0 β€ w x) | |
| (hs : β x, w x = 1) (P : X β Prop) (p : β) (hp : 0 β€ p) (hp1 : p β€ 1) | |
| (hP : (β x, if P x then w x else 0) β€ p) (u : β) (hu : 0 β€ u) : | |
| probability w (fun x : I β X => u β€ ((Finset.univ.filter (fun i => P (x i))).card : β)) β€ | |
| (2 : β)^Fintype.card I * p^u := by | |
| have he := probability_many_hits_le (I := I) w hw hs P p hp hP βuββ | |
| have hconv : (fun x : I β X => u β€ ((Finset.univ.filter (fun i => P (x i))).card : β)) = | |
| (fun x => βuββ β€ (Finset.univ.filter (fun i => P (x i))).card) := by | |
| funext x | |
| exact propext Nat.ceil_le.symm | |
| rw [hconv] | |
| apply he.trans | |
| apply mul_le_mul_of_nonneg_left _ (by positivity) | |
| rw [β Real.rpow_natCast] | |
| exact Real.rpow_le_rpow_of_exponent_ge' hp hp1 hu (Nat.le_ceil u) | |
| /- Canonical padded enumeration encodes a subset of size at most r in r | |
| optional entries. This supplies the source's (number-of-lines+1)^r union count. -/ | |
| def encodeSmallSet {L : Type*} [Fintype L] [DecidableEq L] (r : β) | |
| (S : {S : Finset L // S.card β€ r}) : Fin r β Option L := fun i => | |
| if hi : i.val < S.val.card then | |
| some (((Fintype.equivFinOfCardEq (Fintype.card_coe S.val)).symm β¨i.val,hiβ©).val) | |
| else none | |
| theorem mem_iff_encodeSmallSet {L : Type*} [Fintype L] [DecidableEq L] (r : β) | |
| (S : {S : Finset L // S.card β€ r}) (a : L) : | |
| a β S.val β β i, encodeSmallSet r S i = some a := by | |
| constructor | |
| Β· intro ha | |
| let e := Fintype.equivFinOfCardEq (Fintype.card_coe S.val) | |
| let j := e β¨a,haβ© | |
| let i : Fin r := β¨j.val, lt_of_lt_of_le j.isLt S.propertyβ© | |
| refine β¨i, ?_β© | |
| simp only [encodeSmallSet, i, dite_eq_left j.isLt] | |
| change some ((e.symm j).val) = some a | |
| simp [j] | |
| Β· rintro β¨i,hiβ© | |
| unfold encodeSmallSet at hi | |
| split_ifs at hi with hlt | |
| Β· have he := Option.some.inj hi | |
| rw [β he] | |
| exact ((Fintype.equivFinOfCardEq (Fintype.card_coe S.val)).symm β¨i.val,hltβ©).property | |
| theorem encodeSmallSet_injective {L : Type*} [Fintype L] [DecidableEq L] (r : β) : | |
| Function.Injective (encodeSmallSet (L := L) r) := by | |
| intro S T he | |
| apply Subtype.ext | |
| ext a | |
| rw [mem_iff_encodeSmallSet, mem_iff_encodeSmallSet] | |
| simp only [he] | |
| theorem card_smallSets_le {L : Type*} [Fintype L] [DecidableEq L] (r : β) : | |
| Fintype.card {S : Finset L // S.card β€ r} β€ (Fintype.card L+1)^r := by | |
| have he := Fintype.card_le_of_injective _ (encodeSmallSet_injective (L := L) r) | |
| simpa using he | |
| /- Uniform union bound over small sets of lines, without conditioning on a | |
| set chosen from the particle array. -/ | |
| theorem probability_smallSet_hits_le {L : Type*} [Fintype L] [DecidableEq L] | |
| (w : X β β) (hw : β x, 0 β€ w x) (hs : β x, w x = 1) (line : X β L) | |
| (r : β) (p : β) (hp : 0 β€ p) (hp1 : p β€ 1) | |
| (hprob : β S : Finset L, S.card β€ r β (β x, if line x β S then w x else 0) β€ p) | |
| (u : β) (hu : 0 β€ u) : | |
| probability w (fun x : I β X => β S : Finset L, S.card β€ r β§ | |
| u β€ ((Finset.univ.filter (fun i => line (x i) β S)).card : β)) β€ | |
| ((Fintype.card L+1 : β) : β)^r * (2 : β)^Fintype.card I * p^u := by | |
| let W := {S : Finset L // S.card β€ r} | |
| have he (x : I β X) : | |
| (β S : Finset L, S.card β€ r β§ u β€ ((Finset.univ.filter (fun i => line (x i) β S)).card : β)) β | |
| β S : W, u β€ ((Finset.univ.filter (fun i => line (x i) β S.val)).card : β) := by | |
| constructor | |
| Β· rintro β¨S,hS,hcβ©; exact β¨β¨S,hSβ©,hcβ© | |
| Β· rintro β¨S,hcβ©; exact β¨S.val,S.property,hcβ© | |
| simp only [he] | |
| calc | |
| _ β€ β S : W, probability w (fun x : I β X => | |
| u β€ ((Finset.univ.filter (fun i => line (x i) β S.val)).card : β)) := | |
| probability_exists_le w hw _ | |
| _ β€ β _S : W, (2 : β)^Fintype.card I*p^u := by | |
| apply Finset.sum_le_sum | |
| intro S _ | |
| convert probability_many_hits_le_rpow (I := I) w hw hs (fun x => line x β S.val) p hp hp1 | |
| (by convert hprob S.val S.property using 1; congr!) u hu using 1 | |
| congr! | |
| _ = (Fintype.card W : β)*((2 : β)^Fintype.card I*p^u) := by simp | |
| _ β€ _ := by | |
| rw [mul_assoc] | |
| apply mul_le_mul_of_nonneg_right _ (by positivity) | |
| exact_mod_cast card_smallSets_le (L := L) r | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I X L : Type*} [Fintype I] [DecidableEq I] [Fintype X] [Fintype L] [DecidableEq L] | |
| omit [Fintype L] in | |
| theorem sum_lineSet (w : X β β) (line : X β L) (S : Finset L) : | |
| (β x, if line x β S then w x else 0) = | |
| β l β S, β x, if line x = l then w x else 0 := by | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| simp | |
| omit [Fintype L] in | |
| theorem probability_lineSet_le (w : X β β) (line : X β L) (S : Finset L) | |
| (Ξ΄ : β) (hΞ΄ : β l, (β x, if line x = l then w x else 0) β€ Ξ΄) : | |
| (β x, if line x β S then w x else 0) β€ (S.card : β)*Ξ΄ := by | |
| rw [sum_lineSet] | |
| calc | |
| _ β€ β _l β S, Ξ΄ := Finset.sum_le_sum (fun l _ => hΞ΄ l) | |
| _ = _ := by simp | |
| def heavySet (t : L β β) (v : β) : Finset L := Finset.univ.filter (fun l => v < t l) | |
| omit [DecidableEq L] in | |
| theorem heavySet_card_mul_le (t : L β β) (v : β) : | |
| ((heavySet t v).card : β)*v β€ β l, (t l : β) := by | |
| calc | |
| _ = β _l β heavySet t v, v := by simp | |
| _ β€ β l β heavySet t v, (t l : β) := by | |
| apply Finset.sum_le_sum | |
| intro l hl | |
| exact (Finset.mem_filter.mp hl).2.le | |
| _ β€ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) | |
| (fun _ _ _ => Nat.cast_nonneg _) | |
| omit [DecidableEq L] in | |
| theorem heavySet_card_le_floor (t : L β β) {v : β} (hv : 0 < v) : | |
| (heavySet t v).card β€ β(β l, (t l : β))/vββ := by | |
| apply Nat.le_floor | |
| apply (le_div_iffβ hv).mpr | |
| exact heavySet_card_mul_le t v | |
| def occupancy (line : X β L) (x : I β X) (l : L) : β := | |
| (Finset.univ.filter (fun i => line (x i) = l)).card | |
| omit [DecidableEq I] [Fintype X] in | |
| theorem sum_occupancy (line : X β L) (x : I β X) : | |
| β l, occupancy line x l = Fintype.card I := by | |
| unfold occupancy | |
| simp only [Finset.card_eq_sum_ones, Finset.sum_filter] | |
| rw [Finset.sum_comm] | |
| simp | |
| /- Heavy line sets are small by deterministic occupancy counting. -/ | |
| omit [DecidableEq I] [Fintype X] in | |
| theorem heavy_occupancy_card_le (line : X β L) (x : I β X) {v : β} (hv : 0 < v) : | |
| (heavySet (occupancy line x) v).card β€ β(Fintype.card I : β)/vββ := by | |
| have hh := heavySet_card_le_floor (occupancy line x) hv | |
| simpa only [β Nat.cast_sum, sum_occupancy] using hh | |
| /- Probability of many particles in particle-heavy lines. The random line | |
| set is controlled by a union over ALL small deterministic sets. -/ | |
| theorem probability_heavy_occupancy_le (w : X β β) (hw : β x, 0 β€ w x) | |
| (hs : β x, w x = 1) (line : X β L) {v : β} (hv : 0 < v) | |
| (p Ξ΄ : β) (hΞ΄ : 0 β€ Ξ΄) (hp : 0 β€ p) (hp1 : p β€ 1) | |
| (hline : β l, (β x, if line x = l then w x else 0) β€ Ξ΄) | |
| (hrp : (β(Fintype.card I : β)/vββ : β)*Ξ΄ β€ p) | |
| (u : β) (hu : 0 β€ u) : | |
| probability w (fun x : I β X => | |
| u β€ ((Finset.univ.filter (fun i => line (x i) β heavySet (occupancy line x) v)).card : β)) β€ | |
| ((Fintype.card L+1 : β) : β)^β(Fintype.card I : β)/vββ * | |
| (2 : β)^Fintype.card I * p^u := by | |
| apply le_trans (probability_mono w hw (Q := fun x : I β X => | |
| β S : Finset L, S.card β€ β(Fintype.card I : β)/vββ β§ | |
| u β€ ((Finset.univ.filter (fun i => line (x i) β S)).card : β)) (fun x hx => | |
| β¨heavySet (occupancy line x) v, heavy_occupancy_card_le line x hv, hxβ©)) | |
| apply probability_smallSet_hits_le w hw hs line _ p hp hp1 _ u hu | |
| intro S hS | |
| have hle := probability_lineSet_le w line S Ξ΄ hline | |
| apply hle.trans | |
| apply le_trans _ hrp | |
| exact mul_le_mul_of_nonneg_right (by exact_mod_cast hS) hΞ΄ | |
| end CoordinateSweeps.Coverage | |
| namespace CoordinateSweeps.Coverage | |
| variable {I H X : Type*} [Fintype I] [DecidableEq I] [Fintype H] [Fintype X] | |
| theorem probability_or_le (w : X β β) (hw : β x, 0 β€ w x) (P Q : (I β X) β Prop) : | |
| probability w (fun x => P x β¨ Q x) β€ probability w P + probability w Q := by | |
| simp only [probability, β Finset.sum_add_distrib] | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| have hx := productMass_nonneg w hw x | |
| split_ifs <;> simp_all | |
| theorem probability_coverage_le_real (S : X β X β Prop) | |
| (hSsym : β β¦left rightβ¦, S left right β S right left) | |
| (holes : H β X) (w : X β β) (hw : β x, 0 β€ w x) (hs : β x, w x = 1) | |
| (Ο : β) (hΟ : 0 β€ Ο) | |
| (hS : β y, (β t : X, if S t y then w t else 0) β€ Ο) | |
| (hsmall : ((Fintype.card I + Fintype.card H : β) : β) * Ο β€ 1) | |
| (u : β) (hu : 0 β€ u) : | |
| probability w (fun x : I β X => u β€ ((sharingCoverage S holes x).card : β)) β€ | |
| (2 : β)^Fintype.card I * | |
| ((((Fintype.card I + Fintype.card H : β) : β)*Ο)^(u/2)) := by | |
| have hc : (fun x : I β X => u β€ ((sharingCoverage S holes x).card : β)) = | |
| (fun x => βuββ β€ (sharingCoverage S holes x).card) := by | |
| funext x | |
| exact propext Nat.ceil_le.symm | |
| rw [hc] | |
| apply (probability_coverage_le S hSsym holes w hw hs Ο hΟ hS hsmall βuββ).trans | |
| apply mul_le_mul_of_nonneg_left _ (by positivity) | |
| exact Real.rpow_le_rpow_of_exponent_ge' (by positivity) hsmall (by positivity) | |
| (div_le_div_of_nonneg_right (Nat.le_ceil u) (by norm_num)) | |
| end CoordinateSweeps.Coverage | |
| end | |
| end | |
| end | |
| end | |
| end | |
| open scoped Matrix.Norms.L2Operator | |
| end OAI | |