Buckets:
cfahlgren1/math / lean /OAI /Computability /PerfectCompleteness /Algebra /BilinearWitnessLemmas.lean
| import Mathlib.Algebra.Field.ZMod | |
| import Mathlib.LinearAlgebra.Pi | |
| import OAI.Computability.PerfectCompleteness.Decoding.CollisionAveragingLemmas | |
| import OAI.Computability.PerfectCompleteness.Sampling.DensityVariation | |
| namespace OAI | |
| namespace PerfectCompleteness.BilinearWitness | |
| open scoped BigOperators | |
| noncomputable section | |
| variable {π I H : Type*} [Field π] [Fintype I] [DecidableEq I] | |
| [AddCommGroup H] [Module π H] | |
| {V : I β Type*} [β i, AddCommGroup (V i)] [β i, Module π (V i)] | |
| def assemble (f : (i : I) β V i ββ[π] H) (x : (i : I) β V i) : H := | |
| β i, f i (x i) | |
| omit [DecidableEq I] in | |
| theorem exists_child_pair (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) (B : H ββ[π] H ββ[π] π) | |
| (nonzero : B β 0) : β i j, β (x : V i) (y : V j), B (f i x) (f j y) β 0 := by | |
| classical | |
| by_contra h | |
| push Not at h | |
| apply nonzero | |
| ext u v | |
| obtain β¨x, rflβ© := spans u | |
| obtain β¨y, rflβ© := spans v | |
| simp only [assemble, map_sum, LinearMap.sum_apply] | |
| simp only [h, Finset.sum_const_zero, LinearMap.zero_apply] | |
| def Witness (f : (i : I) β V i ββ[π] H) (B : H ββ[π] H ββ[π] π) := | |
| { w : (Ξ£ i : I, Ξ£ j : I, V i Γ V j) // B (f w.1 w.2.2.1) (f w.2.1 w.2.2.2) β 0 } | |
| def chooseWitness (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) (B : H ββ[π] H ββ[π] π) | |
| (nonzero : B β 0) : Witness f B := by | |
| classical | |
| apply Classical.choice | |
| obtain β¨i, j, x, y, hβ© := exists_child_pair f spans B nonzero | |
| exact β¨β¨β¨i, j, x, yβ©, hβ©β© | |
| def selected (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) (B : H ββ[π] H ββ[π] π) : Finset I := by | |
| classical | |
| exact if h : B = 0 then β else | |
| { (chooseWitness f spans B h).val.1, (chooseWitness f spans B h).val.2.1 } | |
| theorem selected_card_le (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) (B : H ββ[π] H ββ[π] π) : | |
| (selected f spans B).card β€ 2 := by | |
| classical | |
| unfold selected | |
| split | |
| Β· simp | |
| Β· exact (Finset.card_insert_le _ _).trans (by simp) | |
| theorem marked_of_restriction_zero (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) (B : H ββ[π] H ββ[π] π) | |
| (nonzero : B β 0) (mask : I β Bool) (U : Submodule π H) | |
| (unchanged : β i, mask i = false β β x, f i x β U) | |
| (vanishes : β x β U, β y β U, B x y = 0) : | |
| β i β selected f spans B, mask i = true := by | |
| classical | |
| let w := chooseWitness f spans B nonzero | |
| have hselect : selected f spans B = {w.val.1, w.val.2.1} := by | |
| simp only [selected, dite_eq_right nonzero, w] | |
| rw [hselect] | |
| by_cases hi : mask w.val.1 = true | |
| Β· exact β¨w.val.1, by simp, hiβ© | |
| by_cases hj : mask w.val.2.1 = true | |
| Β· exact β¨w.val.2.1, by simp, hjβ© | |
| have hif : mask w.val.1 = false := Bool.eq_false_of_not_eq_true hi | |
| have hjf : mask w.val.2.1 = false := Bool.eq_false_of_not_eq_true hj | |
| exact False.elim (w.property (vanishes _ (unchanged _ hif _) _ (unchanged _ hjf _))) | |
| end | |
| end PerfectCompleteness.BilinearWitness | |
| namespace PerfectCompleteness.BilinearProjection | |
| open scoped BigOperators | |
| open scoped Classical | |
| open UniqueGamesTheorem.Foundations.Games | |
| open PerfectCompleteness ProjectionPosterior AdaptiveProjection BilinearWitness | |
| noncomputable section | |
| variable {π I H : Type*} [Field π] [Fintype I] [DecidableEq I] | |
| [AddCommGroup H] [Module π H] | |
| {V : I β Type*} [β i, AddCommGroup (V i)] [β i, Module π (V i)] | |
| {Ξ© : I β Type*} [β i, Fintype (Ξ© i)] | |
| theorem disagreement_probability (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) | |
| (Fβ Fβ : ((i : I) β Ξ© i) β (H ββ[π] H ββ[π] π)) | |
| (U : ((i : I) β Ξ© i) β (I β Bool) β Submodule π H) | |
| (unchanged : β x mask i, mask i = false β β v, f i v β U x mask) | |
| (P : (i : I) β FiniteDistribution (Ξ© i)) | |
| (q : (i : I) β Ξ© i β β) (nonnegative : β i x, 0 β€ q i x) | |
| (mean : β i, (P i).expectation (q i) = 1) | |
| (Ξ² : β) (hΞ² : 0 β€ Ξ²) (hΞ²' : Ξ² < 1) | |
| (L : β) (hL : 0 β€ L) (bound : β i x, q i x β€ L) : | |
| (forward P q nonnegative mean Ξ² hΞ² hΞ²').probability | |
| (fun z => decide (Fβ z.2 β Fβ z.2 β§ | |
| β v β U z.2 z.1, β w β U z.2 z.1, Fβ z.2 v w = Fβ z.2 v w)) β€ | |
| 2 * (Ξ² * L / (1 - Ξ²)) := by | |
| classical | |
| let select := fun x => selected f spans (Fβ x - Fβ x) | |
| have inclusion : β z : (I β Bool) Γ ((i : I) β Ξ© i), | |
| decide (Fβ z.2 β Fβ z.2 β§ | |
| β v β U z.2 z.1, β w β U z.2 z.1, Fβ z.2 v w = Fβ z.2 v w) = true β | |
| decide (β i β select z.2, z.1 i = true) = true := by | |
| intro z hz | |
| have h := of_decide_eq_true hz | |
| apply decide_eq_true | |
| apply marked_of_restriction_zero f spans (Fβ z.2 - Fβ z.2) | |
| (sub_ne_zero.mpr h.1) z.1 (U z.2 z.1) (unchanged z.2 z.1) | |
| intro v hv w hw | |
| simpa only [LinearMap.sub_apply, sub_eq_zero] using h.2 v hv w hw | |
| exact ((forward P q nonnegative mean Ξ² hΞ² hΞ²').probability_mono inclusion).trans | |
| (by simpa only [Nat.cast_ofNat] using | |
| (adaptive_selection P q nonnegative mean Ξ² hΞ² hΞ²' L hL bound select 2 | |
| (fun x => selected_card_le f spans (Fβ x - Fβ x)))) | |
| end | |
| end PerfectCompleteness.BilinearProjection | |
| namespace PerfectCompleteness.BilinearCollisionTransfer | |
| open scoped BigOperators Classical | |
| open UniqueGamesTheorem.Foundations.Games | |
| open PerfectCompleteness ProjectionPosterior BilinearWitness | |
| noncomputable section | |
| theorem probability_le_add_of_imp {X : Type*} [Fintype X] | |
| (ΞΌ : FiniteDistribution X) (p q r : X β Bool) | |
| (h : β x, p x = true β q x = true β¨ r x = true) : | |
| ΞΌ.probability p β€ ΞΌ.probability q + ΞΌ.probability r := by | |
| simp only [FiniteDistribution.probability, β Finset.sum_add_distrib] | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| cases hp : p x <;> cases hq : q x <;> cases hr : r x <;> | |
| simp only [Bool.false_eq_true, ite_false, ite_true, zero_add, add_zero] | |
| all_goals first | exact ΞΌ.nonnegative x | linarith [ΞΌ.nonnegative x] | | |
| exact False.elim (by simpa [hq, hr] using h x hp) | |
| variable {π I H : Type*} [Field π] [Fintype I] [DecidableEq I] | |
| [AddCommGroup H] [Module π H] | |
| {V : I β Type*} [β i, AddCommGroup (V i)] [β i, Module π (V i)] | |
| {Ξ© : I β Type*} [β i, Fintype (Ξ© i)] | |
| abbrev Form := H ββ[π] H ββ[π] π | |
| def fullCollision (a b : Option (Form (π := π) (H := H))) : Bool := | |
| decide (β F, a = some F β§ b = some F) | |
| def restrictedCollision (a b : Option (Form (π := π) (H := H))) | |
| (U : Submodule π H) : Bool := | |
| decide (β F G, a = some F β§ b = some G β§ | |
| β v β U, β w β U, F v w = G v w) | |
| theorem collision_split (a b : Option (Form (π := π) (H := H))) | |
| (U : Submodule π H) (h : restrictedCollision a b U = true) : | |
| fullCollision a b = true β¨ | |
| decide (a.getD 0 β b.getD 0 β§ | |
| β v β U, β w β U, a.getD 0 v w = b.getD 0 v w) = true := by | |
| obtain β¨F, G, ha, hb, heqβ© := of_decide_eq_true h | |
| subst a b | |
| by_cases hFG : F = G | |
| Β· left | |
| apply decide_eq_true | |
| exact β¨F, rfl, congrArg some hFG.symmβ© | |
| Β· right | |
| simpa only [Option.getD_some, decide_eq_true_eq] using And.intro hFG heq | |
| theorem restricted_le_full_add (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) | |
| (Fβ Fβ : ((i : I) β Ξ© i) β Option (Form (π := π) (H := H))) | |
| (U : ((i : I) β Ξ© i) β (I β Bool) β Submodule π H) | |
| (unchanged : β x mask i, mask i = false β β v, f i v β U x mask) | |
| (P : (i : I) β FiniteDistribution (Ξ© i)) | |
| (q : (i : I) β Ξ© i β β) (nonnegative : β i x, 0 β€ q i x) | |
| (mean : β i, (P i).expectation (q i) = 1) | |
| (Ξ² : β) (hΞ² : 0 β€ Ξ²) (hΞ²' : Ξ² < 1) | |
| (L : β) (hL : 0 β€ L) (bound : β i x, q i x β€ L) : | |
| (forward P q nonnegative mean Ξ² hΞ² hΞ²').probability | |
| (fun z => restrictedCollision (Fβ z.2) (Fβ z.2) (U z.2 z.1)) β€ | |
| ((forward P q nonnegative mean Ξ² hΞ² hΞ²').pushforward Prod.snd).probability | |
| (fun x => fullCollision (Fβ x) (Fβ x)) + 2 * (Ξ² * L / (1 - Ξ²)) := by | |
| have hsplit := probability_le_add_of_imp (forward P q nonnegative mean Ξ² hΞ² hΞ²') | |
| (fun z => restrictedCollision (Fβ z.2) (Fβ z.2) (U z.2 z.1)) | |
| (fun z => fullCollision (Fβ z.2) (Fβ z.2)) | |
| (fun z => decide ((Fβ z.2).getD 0 β (Fβ z.2).getD 0 β§ | |
| β v β U z.2 z.1, β w β U z.2 z.1, | |
| (Fβ z.2).getD 0 v w = (Fβ z.2).getD 0 v w)) | |
| (fun z => collision_split (Fβ z.2) (Fβ z.2) (U z.2 z.1)) | |
| have hbad := BilinearProjection.disagreement_probability f spans | |
| (fun x => (Fβ x).getD 0) (fun x => (Fβ x).getD 0) U unchanged | |
| P q nonnegative mean Ξ² hΞ² hΞ²' L hL bound | |
| rw [FiniteDistribution.probability_pushforward] | |
| exact hsplit.trans (add_le_add (le_refl _) hbad) | |
| theorem full_collision_transfer (f : (i : I) β V i ββ[π] H) | |
| (spans : Function.Surjective (assemble f)) | |
| (Fβ Fβ : ((i : I) β Ξ© i) β Option (Form (π := π) (H := H))) | |
| (U : ((i : I) β Ξ© i) β (I β Bool) β Submodule π H) | |
| (unchanged : β x mask i, mask i = false β β v, f i v β U x mask) | |
| (P : (i : I) β FiniteDistribution (Ξ© i)) | |
| (q : (i : I) β Ξ© i β β) (nonnegative : β i x, 0 β€ q i x) | |
| (mean : β i, (P i).expectation (q i) = 1) | |
| (Ξ² : β) (hΞ² : 0 β€ Ξ²) (hΞ²' : Ξ² < 1) | |
| (L : β) (hL : 0 β€ L) (bound : β i x, q i x β€ L) | |
| (Ξ½ : FiniteDistribution ((i : I) β Ξ© i)) : | |
| (forward P q nonnegative mean Ξ² hΞ² hΞ²').probability | |
| (fun z => restrictedCollision (Fβ z.2) (Fβ z.2) (U z.2 z.1)) - | |
| 2 * (Ξ² * L / (1 - Ξ²)) - | |
| ((forward P q nonnegative mean Ξ² hΞ² hΞ²').pushforward Prod.snd).totalVariation Ξ½ β€ | |
| Ξ½.probability (fun x => fullCollision (Fβ x) (Fβ x)) := by | |
| have h := restricted_le_full_add f spans Fβ Fβ U unchanged | |
| P q nonnegative mean Ξ² hΞ² hΞ²' L hL bound | |
| have htv := FiniteDistribution.probability_le_add_totalVariation | |
| ((forward P q nonnegative mean Ξ² hΞ² hΞ²').pushforward Prod.snd) Ξ½ | |
| (fun x => fullCollision (Fβ x) (Fβ x)) | |
| linarith | |
| end | |
| end PerfectCompleteness.BilinearCollisionTransfer | |
| end OAI | |
Xet Storage Details
- Size:
- 10.5 kB
- Xet hash:
- 481085c1df35b78ce342ab808f66b1f239415793aa3b4f25ad0edf5df75da438
Β·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.