Download data/lean/OAI/LinearAlgebra/MatrixFields/Histories/InverseLinearRecovery.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 28.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/InverseLinearRecovery.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/InverseLinearRecovery.lean
-
curl -L -o InverseLinearRecovery.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Histories/InverseLinearRecovery.lean
28.8 kB
| import Mathlib | |
| import OAI.LinearAlgebra.MatrixFields.Construction.FiniteCover | |
| import OAI.LinearAlgebra.MatrixFields.Tensors.ComplexDotPairing | |
| namespace OAI | |
| namespace MatrixAllFields | |
| open scoped BigOperators Topology Polynomial | |
| section | |
| open scoped BigOperators | |
| open MatrixMultiplication.Foundation | |
| namespace MatrixMultiplication.ExactRecovery | |
| variable {K X Y Z I A B C : Type*} [CommSemiring K] | |
| def delete (Q : Tensor K X Y Z) (px : X β Prop) (py : Y β Prop) | |
| (pz : Z β Prop) [DecidablePred px] [DecidablePred py] [DecidablePred pz] : | |
| Tensor K X Y Z := fun x y z => if px x β§ py y β§ pz z then Q x y z else 0 | |
| def presence [Fintype I] [DecidableEq I] (p : I β X β Prop) | |
| [β i, DecidablePred (p i)] (x : X) : Finset I := | |
| Finset.univ.filter fun i => p i x | |
| @[simp] theorem mem_presence [Fintype I] [DecidableEq I] (p : I β X β Prop) | |
| [β i, DecidablePred (p i)] (x : X) (i : I) : | |
| i β presence p x β p i x := by simp [presence] | |
| theorem restrict_rectangles | |
| [Fintype X] [Fintype Y] [Fintype Z] | |
| [Fintype A] [Fintype B] [Fintype C] | |
| [DecidableEq X] [DecidableEq Y] [DecidableEq Z] | |
| [DecidableEq A] [DecidableEq B] [DecidableEq C] | |
| (Q H : Tensor K X Y Z) (cx : X β A) (cy : Y β B) (cz : Z β C) | |
| (fx : A Γ B Γ C β X β X) (fy : A Γ B Γ C β Y β Y) | |
| (fz : A Γ B Γ C β Z β Z) | |
| (h : β x y z, H (fx (cx x, cy y, cz z) x) | |
| (fy (cx x, cy y, cz z) y) (fz (cx x, cy y, cz z) z) = Q x y z) : | |
| Tensor.restrict | |
| (fun x s => if cx x = s.1.1 β§ s.2 = fx s.1 x then (1 : K) else 0) | |
| (fun y s => if cy y = s.1.2.1 β§ s.2 = fy s.1 y then (1 : K) else 0) | |
| (fun z s => if cz z = s.1.2.2 β§ s.2 = fz s.1 z then (1 : K) else 0) | |
| (Tensor.directSum (fun _ : A Γ B Γ C => H)) = Q := by | |
| funext x y z | |
| simp [Tensor.restrict, Tensor.directSum, Fintype.sum_prod_type, | |
| ite_and, ite_mul, mul_ite, h] | |
| theorem repair_of_cover | |
| [Fintype X] [Fintype Y] [Fintype Z] [Fintype I] [DecidableEq I] [Nonempty I] | |
| (Q H : Tensor K X Y Z) | |
| (px : I β X β Prop) (py : I β Y β Prop) (pz : I β Z β Prop) | |
| (fx : I β X β X) (fy : I β Y β Y) (fz : I β Z β Z) | |
| (hshift : β i x y z, H (fx i x) (fy i y) (fz i z) = | |
| K X Y Z _ Q (px i) (py i) (pz i) | |
| (Classical.decPred _) (Classical.decPred _) (Classical.decPred _) x y z) | |
| (hcover : β x y z, Q x y z β 0 β β i, px i x β§ py i y β§ pz i z) : | |
| β (a : X β ((Finset I Γ Finset I Γ Finset I) Γ X) β K) | |
| (b : Y β ((Finset I Γ Finset I Γ Finset I) Γ Y) β K) | |
| (c : Z β ((Finset I Γ Finset I Γ Finset I) Γ Z) β K), | |
| Tensor.restrict a b c | |
| (Tensor.directSum (fun _ : Finset I Γ Finset I Γ Finset I => H)) = Q := by | |
| classical | |
| let pick : Finset I Γ Finset I Γ Finset I β I := fun r => | |
| if h : β i, i β r.1 β§ i β r.2.1 β§ i β r.2.2 then Classical.choose h | |
| else Classical.choice inferInstance | |
| have hpick (r : Finset I Γ Finset I Γ Finset I) | |
| (hr : β i, i β r.1 β§ i β r.2.1 β§ i β r.2.2) : | |
| pick r β r.1 β§ pick r β r.2.1 β§ pick r β r.2.2 := by | |
| simpa [pick, hr] using Classical.choose_spec hr | |
| let cx := presence px | |
| let cy := presence py | |
| let cz := presence pz | |
| have hrect (x : X) (y : Y) (z : Z) : | |
| H (fx (pick (cx x, cy y, cz z)) x) | |
| (fy (pick (cx x, cy y, cz z)) y) | |
| (fz (pick (cx x, cy y, cz z)) z) = Q x y z := by | |
| rw [hshift] | |
| by_cases hq : Q x y z = 0 | |
| Β· simp [delete, hq] | |
| Β· rcases hcover x y z hq with β¨i, hix, hiy, hizβ© | |
| have hp := hpick (cx x, cy y, cz z) | |
| β¨i, by simpa [cx] using hix, by simpa [cy] using hiy, | |
| by simpa [cz] using hizβ© | |
| have hpx : px (pick (cx x, cy y, cz z)) x := by simpa [cx] using hp.1 | |
| have hpy : py (pick (cx x, cy y, cz z)) y := by simpa [cy] using hp.2.1 | |
| have hpz : pz (pick (cx x, cy y, cz z)) z := by simpa [cz] using hp.2.2 | |
| simp [delete, hpx, hpy, hpz] | |
| exact β¨_, _, _, restrict_rectangles Q H cx cy cz | |
| (fun r => fx (pick r)) (fun r => fy (pick r)) (fun r => fz (pick r)) hrectβ© | |
| theorem card_mask_rectangles [Fintype I] : | |
| Fintype.card (Finset I Γ Finset I Γ Finset I) = 2 ^ (3 * Fintype.card I) := by | |
| classical | |
| simp only [Fintype.card_prod, Fintype.card_finset] | |
| rw [Nat.mul_comm 3 (Fintype.card I), pow_mul] | |
| simp [pow_succ, mul_assoc] | |
| theorem repair_of_counting | |
| [Fintype X] [Fintype Y] [Fintype Z] [Fintype I] | |
| [DecidableEq X] [DecidableEq Y] [DecidableEq Z] [DecidableEq I] | |
| (Q H : Tensor K X Y Z) | |
| (px : I β X β Prop) (py : I β Y β Prop) (pz : I β Z β Prop) | |
| (fx : I β X β X) (fy : I β Y β Y) (fz : I β Z β Z) | |
| (hshift : β i x y z, H (fx i x) (fy i y) (fz i z) = | |
| K X Y Z _ Q (px i) (py i) (pz i) | |
| (Classical.decPred _) (Classical.decPred _) (Classical.decPred _) x y z) | |
| (t L : β) (hL : 0 < L) | |
| (hbad : β x y z, Q x y z β 0 β | |
| (.filter I (fun i => Β¬(px i x β§ py i y β§ pz i z)) | |
| (Classical.decPred _) Finset.univ).card β€ t) | |
| (hbudget : (.filter (X Γ Y Γ Z) | |
| (fun p => Q p.1 p.2.1 p.2.2 β 0) (Classical.decPred _) Finset.univ).card * t ^ L < | |
| Fintype.card I ^ L) : | |
| β (a : X β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ X) β K) | |
| (b : Y β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ Y) β K) | |
| (c : Z β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ Z) β K), | |
| Tensor.restrict a b c | |
| (Tensor.directSum (fun _ : Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L) => H)) = Q := by | |
| classical | |
| let support : Finset (X Γ Y Γ Z) := .filter (X Γ Y Γ Z) | |
| (fun p => Q p.1 p.2.1 p.2.2 β 0) (Classical.decPred _) Finset.univ | |
| let good (i : I) (p : X Γ Y Γ Z) : Prop := px i p.1 β§ py i p.2.1 β§ pz i p.2.2 | |
| have hbad' : β p β support, (Finset.univ.filter fun i => Β¬good i p).card β€ t := by | |
| intro p hp | |
| have heq : (Finset.univ.filter fun i => Β¬good i p) = | |
| @Finset.filter I (fun i => Β¬(px i p.1 β§ py i p.2.1 β§ pz i p.2.2)) | |
| (Classical.decPred _) Finset.univ := by | |
| ext i | |
| simp only [Finset.mem_filter, good] | |
| rw [heq] | |
| apply hbad p.1 p.2.1 p.2.2 | |
| simpa only [support, Finset.mem_filter, Finset.mem_univ, true_and] using hp | |
| obtain β¨f, hfβ© := FiniteCover.exists_cover support good t L hbad' hbudget | |
| let : Nonempty (Fin L) := β¨β¨0, hLβ©β© | |
| exact repair_of_cover Q H (fun i => px (f i)) (fun i => py (f i)) | |
| (fun i => pz (f i)) (fun i => fx (f i)) (fun i => fy (f i)) | |
| (fun i => fz (f i)) (fun i => hshift (f i)) | |
| (fun x y z hq => hf (x, y, z) (by simp [support, hq])) | |
| end MatrixMultiplication.ExactRecovery | |
| end | |
| section | |
| open scoped BigOperators | |
| namespace MatrixMultiplication.OrbitCounting | |
| variable {G X : Type*} [Group G] [MulAction G X] [Fintype G] [DecidableEq X] | |
| def orbitSet (x : X) : Finset X := Finset.univ.image fun g : G => g β’ x | |
| @[simp] theorem smul_mem_orbitSet (x : X) (g : G) : g β’ x β orbitSet (G := G) x := by | |
| exact Finset.mem_image.mpr β¨g, Finset.mem_univ _, rflβ© | |
| theorem card_fiber_eq (x y : X) (hy : y β orbitSet (G := G) x) : | |
| Fintype.card {g : G // g β’ x = y} = Fintype.card {g : G // g β’ x = x} := by | |
| classical | |
| obtain β¨r, _, hrβ© := Finset.mem_image.mp hy | |
| let e : {g : G // g β’ x = y} β {g : G // g β’ x = x} := | |
| { toFun := fun g => β¨rβ»ΒΉ * g.1, by | |
| rw [mul_smul, g.2, β hr, inv_smul_smul]β© | |
| invFun := fun g => β¨r * g.1, by | |
| rw [mul_smul, g.2, hr]β© | |
| left_inv := by intro g; apply Subtype.ext; simp | |
| right_inv := by intro g; apply Subtype.ext; simp } | |
| exact Fintype.card_congr e | |
| theorem card_group (x : X) : | |
| Fintype.card G = (orbitSet (G := G) x).card * | |
| Fintype.card {g : G // g β’ x = x} := by | |
| classical | |
| let e := Equiv.sigmaSubtypeFiberEquiv (fun g : G => g β’ x) | |
| (fun y => y β orbitSet (G := G) x) (smul_mem_orbitSet x) | |
| calc | |
| Fintype.card G = Fintype.card (Ξ£ y : {y // y β orbitSet (G := G) x}, | |
| {g : G // g β’ x = y.1}) := (Fintype.card_congr e).symm | |
| _ = β y : {y // y β orbitSet (G := G) x}, | |
| Fintype.card {g : G // g β’ x = y.1} := Fintype.card_sigma | |
| _ = β _y : {y // y β orbitSet (G := G) x}, | |
| Fintype.card {g : G // g β’ x = x} := by | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| exact card_fiber_eq x y.1 y.2 | |
| _ = _ := by simp | |
| theorem bad_shift_count (x : X) (bad : X β Prop) [DecidablePred bad] : | |
| (Finset.univ.filter fun g : G => bad (g β’ x)).card = | |
| ((orbitSet (G := G) x).filter bad).card * | |
| Fintype.card {g : G // g β’ x = x} := by | |
| classical | |
| let e := Equiv.sigmaSubtypeFiberEquivSubtype (fun g : G => g β’ x) | |
| (p := fun g => bad (g β’ x)) | |
| (q := fun y => y β (orbitSet (G := G) x).filter bad) | |
| (fun g => by simp) | |
| calc | |
| (Finset.univ.filter fun g : G => bad (g β’ x)).card = | |
| Fintype.card {g : G // bad (g β’ x)} := (Fintype.card_subtype _).symm | |
| _ = Fintype.card (Ξ£ y : {y // y β (orbitSet (G := G) x).filter bad}, | |
| {g : G // g β’ x = y.1}) := (Fintype.card_congr e).symm | |
| _ = β y : {y // y β (orbitSet (G := G) x).filter bad}, | |
| Fintype.card {g : G // g β’ x = y.1} := Fintype.card_sigma | |
| _ = β _y : {y // y β (orbitSet (G := G) x).filter bad}, | |
| Fintype.card {g : G // g β’ x = x} := by | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| exact card_fiber_eq x y.1 (Finset.mem_filter.mp y.2).1 | |
| _ = _ := by simp | |
| theorem bad_shift_bound (x : X) (bad : X β Prop) [DecidablePred bad] (N C : β) | |
| (h : N * ((orbitSet (G := G) x).filter bad).card β€ C * (orbitSet (G := G) x).card) : | |
| N * (Finset.univ.filter fun g : G => bad (g β’ x)).card β€ C * Fintype.card G := by | |
| rw [bad_shift_count, card_group (G := G) x] | |
| simpa only [Nat.mul_assoc] using Nat.mul_le_mul_right | |
| (Fintype.card {g : G // g β’ x = x}) h | |
| theorem bad_shift_fraction (x : X) (bad : X β Prop) [DecidablePred bad] : | |
| ((Finset.univ.filter fun g : G => bad (g β’ x)).card : β) / Fintype.card G = | |
| (((orbitSet (G := G) x).filter bad).card : β) / (orbitSet (G := G) x).card := by | |
| have hsNat : 0 < Fintype.card {g : G // g β’ x = x} := | |
| Fintype.card_pos_iff.mpr β¨β¨1, one_smul G xβ©β© | |
| have hs : (Fintype.card {g : G // g β’ x = x} : β) β 0 := | |
| Nat.cast_ne_zero.mpr (Nat.ne_of_gt hsNat) | |
| rw [bad_shift_count, card_group (G := G) x] | |
| simp only [Nat.cast_mul] | |
| exact mul_div_mul_right _ _ hs | |
| end MatrixMultiplication.OrbitCounting | |
| end | |
| section | |
| open scoped BigOperators | |
| open MatrixMultiplication.Foundation | |
| namespace MatrixMultiplication.OrbitRecovery | |
| variable {G X Y Z : Type*} [Group G] [Fintype G] | |
| [MulAction G X] [MulAction G Y] [MulAction G Z] | |
| [DecidableEq X] [DecidableEq Y] [DecidableEq Z] | |
| def badShifts (px : X β Prop) (py : Y β Prop) (pz : Z β Prop) | |
| [DecidablePred px] [DecidablePred py] [DecidablePred pz] | |
| (x : X) (y : Y) (z : Z) : Finset G := | |
| Finset.univ.filter fun g => Β¬(px (g β’ x) β§ py (g β’ y) β§ pz (g β’ z)) | |
| omit [DecidableEq X] [DecidableEq Y] [DecidableEq Z] in | |
| theorem badShifts_card_le (px : X β Prop) (py : Y β Prop) (pz : Z β Prop) | |
| [DecidablePred px] [DecidablePred py] [DecidablePred pz] | |
| (x : X) (y : Y) (z : Z) : | |
| (badShifts (G := G) px py pz x y z).card β€ | |
| (Finset.univ.filter fun g : G => Β¬px (g β’ x)).card + | |
| (Finset.univ.filter fun g : G => Β¬py (g β’ y)).card + | |
| (Finset.univ.filter fun g : G => Β¬pz (g β’ z)).card := by | |
| classical | |
| have heq : badShifts (G := G) px py pz x y z = | |
| (Finset.univ.filter fun g : G => Β¬px (g β’ x)) βͺ | |
| ((Finset.univ.filter fun g : G => Β¬py (g β’ y)) βͺ | |
| (Finset.univ.filter fun g : G => Β¬pz (g β’ z))) := by | |
| ext g | |
| by_cases hx : px (g β’ x) <;> by_cases hy : py (g β’ y) <;> | |
| by_cases hz : pz (g β’ z) <;> simp [badShifts, hx, hy, hz] | |
| rw [heq] | |
| exact (Finset.card_union_le _ _).trans | |
| ((Nat.add_le_add_left (Finset.card_union_le _ _) _).trans (le_of_eq (Nat.add_assoc _ _ _).symm)) | |
| theorem badShifts_fraction_le_at (px : X β Prop) (py : Y β Prop) (pz : Z β Prop) | |
| [DecidablePred px] [DecidablePred py] [DecidablePred pz] | |
| (Ξ³ : β) (x : X) (y : Y) (z : Z) | |
| (hx : (((OrbitCounting.orbitSet (G := G) x).filter fun v => Β¬px v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) x).card β€ Ξ³) | |
| (hy : (((OrbitCounting.orbitSet (G := G) y).filter fun v => Β¬py v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) y).card β€ Ξ³) | |
| (hz : (((OrbitCounting.orbitSet (G := G) z).filter fun v => Β¬pz v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) z).card β€ Ξ³) | |
| : | |
| ((badShifts (G := G) px py pz x y z).card : β) / Fintype.card G β€ 3 * Ξ³ := by | |
| have hg : (0 : β) < Fintype.card G := Nat.cast_pos.mpr Fintype.card_pos | |
| have hx' := hx | |
| have hy' := hy | |
| have hz' := hz | |
| rw [β OrbitCounting.bad_shift_fraction (G := G) x (fun v => Β¬px v)] at hx' | |
| rw [β OrbitCounting.bad_shift_fraction (G := G) y (fun v => Β¬py v)] at hy' | |
| rw [β OrbitCounting.bad_shift_fraction (G := G) z (fun v => Β¬pz v)] at hz' | |
| have hxc := (div_le_iffβ hg).mp hx' | |
| have hyc := (div_le_iffβ hg).mp hy' | |
| have hzc := (div_le_iffβ hg).mp hz' | |
| have hc : ((badShifts (G := G) px py pz x y z).card : β) β€ | |
| ((Finset.univ.filter fun g : G => Β¬px (g β’ x)).card : β) + | |
| ((Finset.univ.filter fun g : G => Β¬py (g β’ y)).card : β) + | |
| ((Finset.univ.filter fun g : G => Β¬pz (g β’ z)).card : β) := by | |
| exact_mod_cast badShifts_card_le (G := G) px py pz x y z | |
| apply (div_le_iffβ hg).mpr | |
| linarith | |
| theorem floor_loss_fraction (Ξ³ : β) (hΞ³ : 0 β€ Ξ³) : | |
| (Nat.floor (3 * Ξ³ * Fintype.card G) : β) / Fintype.card G β€ 3 * Ξ³ := by | |
| have hg : (0 : β) < Fintype.card G := Nat.cast_pos.mpr Fintype.card_pos | |
| apply (div_le_iffβ hg).mpr | |
| exact Nat.floor_le (by positivity) | |
| theorem repair_from_orbit_loss | |
| {K : Type*} [CommSemiring K] [Fintype X] [Fintype Y] [Fintype Z] | |
| (Q : Tensor K X Y Z) | |
| (px : X β Prop) (py : Y β Prop) (pz : Z β Prop) | |
| [DecidablePred px] [DecidablePred py] [DecidablePred pz] | |
| (hpreserve : β (g : G) x y z, Q (g β’ x) (g β’ y) (g β’ z) = Q x y z) | |
| (Ξ³ : β) | |
| (hx : β x, (β y z, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) x).filter fun v => Β¬px v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) x).card β€ Ξ³) | |
| (hy : β y, (β x z, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) y).filter fun v => Β¬py v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) y).card β€ Ξ³) | |
| (hz : β z, (β x y, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) z).filter fun v => Β¬pz v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) z).card β€ Ξ³) | |
| (L : β) (hL : 0 < L) | |
| (hbudget : (@Finset.filter (X Γ Y Γ Z) | |
| (fun p => Q p.1 p.2.1 p.2.2 β 0) (Classical.decPred _) Finset.univ).card * | |
| Nat.floor (3 * Ξ³ * Fintype.card G) ^ L < Fintype.card G ^ L) : | |
| β (a : X β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ X) β K) | |
| (b : Y β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ Y) β K) | |
| (c : Z β ((Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L)) Γ Z) β K), | |
| Tensor.restrict a b c (Tensor.directSum | |
| (fun _ : Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L) => | |
| ExactRecovery.delete Q px py pz)) = Q := by | |
| classical | |
| apply ExactRecovery.repair_of_counting (I := G) Q (ExactRecovery.delete Q px py pz) | |
| (fun g x => px (g β’ x)) (fun g y => py (g β’ y)) (fun g z => pz (g β’ z)) | |
| (fun g x => g β’ x) (fun g y => g β’ y) (fun g z => g β’ z) | |
| (fun g x y z => by simp [ExactRecovery.delete, hpreserve]) | |
| (Nat.floor (3 * Ξ³ * Fintype.card G)) L hL ?_ hbudget | |
| intro x y z hq | |
| have heq : (@Finset.filter G | |
| (fun g => Β¬(px (g β’ x) β§ py (g β’ y) β§ pz (g β’ z))) | |
| (Classical.decPred _) Finset.univ) = badShifts (G := G) px py pz x y z := by | |
| ext g | |
| simp only [badShifts, Finset.mem_filter] | |
| rw [heq] | |
| apply Nat.le_floor | |
| have hg : (0 : β) < Fintype.card G := Nat.cast_pos.mpr Fintype.card_pos | |
| exact (div_le_iffβ hg).mp (badShifts_fraction_le_at (G := G) px py pz Ξ³ x y z | |
| (hx x β¨y, z, hqβ©) (hy y β¨x, z, hqβ©) (hz z β¨x, y, hqβ©)) | |
| end MatrixMultiplication.OrbitRecovery | |
| end | |
| section | |
| noncomputable section | |
| namespace MatrixMultiplication.RecoveryGrowth | |
| open Filter | |
| open scoped Topology BigOperators | |
| def shiftCount (b C : β) (N : β) : β := | |
| β(b + 1) * (N : β) / Real.log ((N : β) / (3 * C))ββ | |
| def replicationCount (b C : β) (N : β) : β := | |
| 2 ^ (3 * shiftCount b C N) | |
| theorem shiftCount_pos {b C : β} {N : β} | |
| (hb : 0 β€ b) (hC : 0 < C) (hN : 3 * C < (N : β)) : | |
| 0 < shiftCount b C N := by | |
| have hC3 : 0 < 3 * C := by linarith | |
| have hN0 : 0 < (N : β) := hC3.trans hN | |
| have hlog : 0 < Real.log ((N : β) / (3 * C)) := | |
| Real.log_pos ((one_lt_div hC3).2 hN) | |
| exact Nat.ceil_pos.2 (div_pos (mul_pos (by linarith) hN0) hlog) | |
| theorem support_loss_bound {b C : β} {N : β} | |
| (hC : 0 < C) (hN : 3 * C < (N : β)) : | |
| Real.exp (b * N) * (3 * C / (N : β)) ^ shiftCount b C N β€ | |
| Real.exp (-(N : β)) := by | |
| have hC3 : 0 < 3 * C := by linarith | |
| have hN0 : 0 < (N : β) := hC3.trans hN | |
| have hlog : 0 < Real.log ((N : β) / (3 * C)) := | |
| Real.log_pos ((one_lt_div hC3).2 hN) | |
| have hceil : (b + 1) * (N : β) β€ | |
| (shiftCount b C N : β) * Real.log ((N : β) / (3 * C)) := by | |
| exact (div_le_iffβ hlog).1 (Nat.le_ceil _) | |
| have hbase : 3 * C / (N : β) = | |
| Real.exp (-Real.log ((N : β) / (3 * C))) := by | |
| rw [Real.exp_neg, Real.exp_log (div_pos hN0 hC3)] | |
| simp | |
| rw [hbase, β Real.exp_nat_mul, β Real.exp_add] | |
| apply Real.exp_le_exp.mpr | |
| nlinarith | |
| theorem cardinal_budget {b C : β} {N S t g : β} | |
| (hC : 0 < C) (hN : 3 * C < (N : β)) (hg : 0 < g) | |
| (hS : (S : β) β€ Real.exp (b * N)) | |
| (ht : (t : β) / (g : β) β€ 3 * C / (N : β)) : | |
| S * t ^ shiftCount b C N < g ^ shiftCount b C N := by | |
| have hgr : 0 < (g : β) := by exact_mod_cast hg | |
| have hN0 : 0 < (N : β) := by linarith | |
| have hpow := pow_le_pow_leftβ | |
| (div_nonneg (Nat.cast_nonneg t) hgr.le) ht (shiftCount b C N) | |
| have hprob : (S : β) * ((t : β) / (g : β)) ^ shiftCount b C N < 1 := by | |
| calc | |
| (S : β) * ((t : β) / (g : β)) ^ shiftCount b C N β€ | |
| Real.exp (b * N) * (3 * C / (N : β)) ^ shiftCount b C N := | |
| mul_le_mul hS hpow (pow_nonneg (div_nonneg (Nat.cast_nonneg t) hgr.le) _) | |
| (Real.exp_pos _).le | |
| _ β€ Real.exp (-(N : β)) := support_loss_bound hC hN | |
| _ < 1 := by rw [Real.exp_lt_one_iff]; linarith | |
| rw [div_pow, β mul_div_assoc] at hprob | |
| have hreal := (div_lt_iffβ (pow_pos hgr (shiftCount b C N))).1 hprob | |
| simp only [one_mul] at hreal | |
| exact_mod_cast hreal | |
| theorem exists_cover {M G : Type*} [Fintype G] [Nonempty G] | |
| [DecidableEq G] [DecidableEq M] | |
| (s : Finset M) (good : G β M β Prop) [β g, DecidablePred (good g)] | |
| {b C : β} {N : β} (hC : 0 < C) (hN : 3 * C < (N : β)) | |
| (hs : (s.card : β) β€ Real.exp (b * N)) | |
| (hbad : β m β s, | |
| ((Finset.univ.filter fun g => Β¬good g m).card : β) / Fintype.card G β€ | |
| 3 * C / (N : β)) : | |
| β f : Fin (shiftCount b C N) β G, β m β s, β i, good (f i) m := by | |
| let t := β(3 * C / (N : β)) * Fintype.card Gββ | |
| have hg : 0 < (Fintype.card G : β) := by exact_mod_cast Fintype.card_pos | |
| have harg : 0 β€ (3 * C / (N : β)) * Fintype.card G := by | |
| exact mul_nonneg (div_nonneg (by linarith) (Nat.cast_nonneg N)) hg.le | |
| apply FiniteCover.exists_cover s good t (shiftCount b C N) | |
| Β· intro m hm | |
| exact Nat.le_floor ((div_le_iffβ hg).1 (hbad m hm)) | |
| Β· apply cardinal_budget hC hN Fintype.card_pos hs | |
| exact (div_le_iffβ hg).2 (Nat.floor_le harg) | |
| theorem shiftCount_div_nat_le {b C : β} {N : β} | |
| (hb : 0 < b) (hC : 0 < C) (hN : 3 * C < (N : β)) : | |
| (shiftCount b C N : β) / (N : β) β€ | |
| (b + 1) / Real.log ((N : β) / (3 * C)) + 1 / (N : β) := by | |
| have hC3 : 0 < 3 * C := by linarith | |
| have hN0 : 0 < (N : β) := hC3.trans hN | |
| have hlog : 0 < Real.log ((N : β) / (3 * C)) := | |
| Real.log_pos ((one_lt_div hC3).2 hN) | |
| have harg : 0 β€ (b + 1) * (N : β) / Real.log ((N : β) / (3 * C)) := | |
| div_nonneg (mul_nonneg (by linarith) hN0.le) hlog.le | |
| have hceil := div_le_div_of_nonneg_right (Nat.ceil_lt_add_one harg).le hN0.le | |
| change (shiftCount b C N : β) / (N : β) β€ _ at hceil | |
| convert hceil using 1 | |
| field_simp [hN0.ne', hlog.ne'] | |
| theorem tendsto_shiftCount_div_nat {b C : β} (hb : 0 < b) (hC : 0 < C) : | |
| Tendsto (fun N : β => (shiftCount b C N : β) / (N : β)) atTop (π 0) := by | |
| have hnat : Tendsto (fun N : β => (N : β)) atTop atTop := | |
| tendsto_natCast_atTop_atTop | |
| have hlog : Tendsto (fun N : β => Real.log ((N : β) / (3 * C))) atTop atTop := | |
| Real.tendsto_log_atTop.comp (hnat.atTop_div_const (by linarith)) | |
| have hmain : Tendsto (fun N : β => | |
| (b + 1) / Real.log ((N : β) / (3 * C))) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop hlog | |
| have herr : Tendsto (fun N : β => 1 / (N : β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop hnat | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds | |
| (by simpa only [add_zero] using hmain.add herr) | |
| Β· exact Eventually.of_forall fun N => div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) | |
| Β· filter_upwards [hnat.eventually_gt_atTop (3 * C)] with N hN | |
| exact shiftCount_div_nat_le hb hC hN | |
| theorem eventually_shiftCount_div_nat_le_log {b C : β} (hb : 0 < b) (hC : 0 < C) : | |
| βαΆ N : β in atTop, (shiftCount b C N : β) / (N : β) β€ | |
| (2 * b + 3) / Real.log (N : β) := by | |
| have hnat : Tendsto (fun N : β => (N : β)) atTop atTop := | |
| tendsto_natCast_atTop_atTop | |
| have hlognat := Real.tendsto_log_atTop.comp hnat | |
| filter_upwards [hnat.eventually_gt_atTop (3 * C), hnat.eventually_gt_atTop 1, | |
| hlognat.eventually_ge_atTop (2 * Real.log (3 * C))] with N hN hN1 hlarge | |
| change 2 * Real.log (3 * C) β€ Real.log (N : β) at hlarge | |
| have hN0 : 0 < (N : β) := lt_trans zero_lt_one hN1 | |
| have hC3 : 0 < 3 * C := by linarith | |
| have hlog : 0 < Real.log (N : β) := Real.log_pos hN1 | |
| have hden : 0 < Real.log ((N : β) / (3 * C)) := | |
| Real.log_pos ((one_lt_div hC3).2 hN) | |
| have hhalf : Real.log (N : β) β€ 2 * Real.log ((N : β) / (3 * C)) := by | |
| rw [Real.log_div hN0.ne' hC3.ne'] | |
| linarith | |
| have hmain : (b + 1) / Real.log ((N : β) / (3 * C)) β€ | |
| (2 * (b + 1)) / Real.log (N : β) := by | |
| apply (div_le_div_iffβ hden hlog).2 | |
| nlinarith [mul_le_mul_of_nonneg_left hhalf (show 0 β€ b + 1 by linarith)] | |
| have herr : 1 / (N : β) β€ 1 / Real.log (N : β) := | |
| div_le_div_of_nonneg_left zero_le_one hlog (Real.log_le_self hN0.le) | |
| calc | |
| (shiftCount b C N : β) / (N : β) β€ | |
| (b + 1) / Real.log ((N : β) / (3 * C)) + 1 / (N : β) := | |
| shiftCount_div_nat_le hb hC hN | |
| _ β€ (2 * (b + 1)) / Real.log (N : β) + 1 / Real.log (N : β) := | |
| add_le_add hmain herr | |
| _ = (2 * b + 3) / Real.log (N : β) := by ring | |
| theorem log_replicationCount (b C : β) (N : β) : | |
| Real.log (replicationCount b C N : β) = | |
| (3 * Real.log 2) * (shiftCount b C N : β) := by | |
| simp only [replicationCount, Nat.cast_pow, Real.log_pow, Nat.cast_mul, Nat.cast_ofNat] | |
| ring | |
| theorem eventually_log_replicationCount_div_nat_le_log {b C : β} | |
| (hb : 0 < b) (hC : 0 < C) : | |
| βαΆ N : β in atTop, Real.log (replicationCount b C N : β) / (N : β) β€ | |
| (3 * Real.log 2 * (2 * b + 3)) / Real.log (N : β) := by | |
| filter_upwards [eventually_shiftCount_div_nat_le_log hb hC] with N hN | |
| have hlog2 : 0 β€ 3 * Real.log 2 := | |
| mul_nonneg (by norm_num) (Real.log_nonneg (by norm_num)) | |
| simpa only [log_replicationCount, mul_div_assoc] using | |
| mul_le_mul_of_nonneg_left hN hlog2 | |
| theorem tendsto_log_replicationCount_div_nat {b C : β} (hb : 0 < b) (hC : 0 < C) : | |
| Tendsto (fun N : β => Real.log (replicationCount b C N : β) / (N : β)) | |
| atTop (π 0) := by | |
| have h := (tendsto_shiftCount_div_nat hb hC).const_mul (3 * Real.log 2) | |
| simp only [mul_zero] at h | |
| convert h using 1 | |
| ext N | |
| simp only [log_replicationCount] | |
| ring | |
| theorem eventually_replicationCount_le_exp {b C Ξ΅ : β} | |
| (hb : 0 < b) (hC : 0 < C) (hΞ΅ : 0 < Ξ΅) : | |
| βαΆ N : β in atTop, (replicationCount b C N : β) β€ Real.exp (Ξ΅ * N) := by | |
| filter_upwards [(tendsto_log_replicationCount_div_nat hb hC).eventually_lt_const hΞ΅, | |
| eventually_gt_atTop (0 : β)] with N hrate hN | |
| have hN0 : 0 < (N : β) := by exact_mod_cast hN | |
| have hrep : 0 < (replicationCount b C N : β) := by | |
| simp only [replicationCount, Nat.cast_pow, Nat.cast_ofNat] | |
| exact pow_pos (by norm_num) _ | |
| exact (Real.log_le_iff_le_exp hrep).1 ((div_lt_iffβ hN0).1 hrate).le | |
| theorem tendsto_log_prod_div_nat {J : Type*} (s : Finset J) | |
| {r : J β β β β} | |
| (hr : β j β s, β N, 0 < r j N) | |
| (hlim : β j β s, Tendsto (fun N => Real.log (r j N : β) / (N : β)) | |
| atTop (π 0)) : | |
| Tendsto (fun N => Real.log ((β j β s, r j N : β) : β) / (N : β)) | |
| atTop (π 0) := by | |
| have hsum := tendsto_finsetSum s hlim | |
| simp only [Finset.sum_const_zero] at hsum | |
| apply hsum.congr | |
| intro N | |
| rw [Nat.cast_prod, Real.log_prod | |
| (fun j hj => Nat.cast_ne_zero.mpr (Nat.ne_of_gt (hr j hj N)))] | |
| simp only [div_eq_mul_inv, Finset.sum_mul] | |
| end MatrixMultiplication.RecoveryGrowth | |
| end | |
| end | |
| section | |
| open MatrixMultiplication.Foundation | |
| namespace MatrixMultiplication.InverseLinearRecovery | |
| abbrev MaskRectangles (L : β) := Finset (Fin L) Γ Finset (Fin L) Γ Finset (Fin L) | |
| def RecoveredBy {K X Y Z : Type*} [CommSemiring K] | |
| [Fintype X] [Fintype Y] [Fintype Z] | |
| (Q H : Tensor K X Y Z) (L : β) : Prop := | |
| β (a : X β (MaskRectangles L Γ X) β K) | |
| (b : Y β (MaskRectangles L Γ Y) β K) | |
| (c : Z β (MaskRectangles L Γ Z) β K), | |
| Tensor.restrict a b c (Tensor.directSum (fun _ : MaskRectangles L => H)) = Q | |
| theorem repair_inverse_linear | |
| {K G X Y Z : Type*} [CommSemiring K] [Group G] [Fintype G] | |
| [MulAction G X] [MulAction G Y] [MulAction G Z] | |
| [Fintype X] [Fintype Y] [Fintype Z] | |
| [DecidableEq X] [DecidableEq Y] [DecidableEq Z] | |
| (Q : Tensor K X Y Z) | |
| (px : X β Prop) (py : Y β Prop) (pz : Z β Prop) | |
| [DecidablePred px] [DecidablePred py] [DecidablePred pz] | |
| (hpreserve : β (g : G) x y z, Q (g β’ x) (g β’ y) (g β’ z) = Q x y z) | |
| {b C : β} {N : β} (hb : 0 β€ b) (hC : 0 < C) (hN : 3 * C < (N : β)) | |
| (hsupport : ((.filter (X Γ Y Γ Z) | |
| (fun p => Q p.1 p.2.1 p.2.2 β 0) (Classical.decPred _) Finset.univ).card : β) β€ | |
| Real.exp (b * N)) | |
| (hx : β x, (β y z, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) x).filter fun v => Β¬px v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) x).card β€ C / N) | |
| (hy : β y, (β x z, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) y).filter fun v => Β¬py v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) y).card β€ C / N) | |
| (hz : β z, (β x y, Q x y z β 0) β (((OrbitCounting.orbitSet (G := G) z).filter fun v => Β¬pz v).card : β) / | |
| (OrbitCounting.orbitSet (G := G) z).card β€ C / N) : | |
| RecoveredBy Q (ExactRecovery.delete Q px py pz) (RecoveryGrowth.shiftCount b C N) := by | |
| classical | |
| apply OrbitRecovery.repair_from_orbit_loss Q px py pz hpreserve (C / N) hx hy hz | |
| (RecoveryGrowth.shiftCount b C N) (RecoveryGrowth.shiftCount_pos hb hC hN) | |
| apply RecoveryGrowth.cardinal_budget hC hN Fintype.card_pos hsupport | |
| simpa only [mul_div_assoc] using | |
| OrbitRecovery.floor_loss_fraction (G := G) (C / N) | |
| (div_nonneg hC.le (Nat.cast_nonneg N)) | |
| theorem card_recovery_copies (b C : β) (N : β) : | |
| Fintype.card (MaskRectangles (RecoveryGrowth.shiftCount b C N)) = | |
| RecoveryGrowth.replicationCount b C N := by | |
| simpa only [MaskRectangles, Fintype.card_fin, RecoveryGrowth.replicationCount] using | |
| (ExactRecovery.card_mask_rectangles (I := Fin (RecoveryGrowth.shiftCount b C N))) | |
| theorem subexponential_copies {b C : β} (hb : 0 < b) (hC : 0 < C) : | |
| Filter.Tendsto (fun N : β => | |
| Real.log (Fintype.card (MaskRectangles (RecoveryGrowth.shiftCount b C N))) / N) | |
| Filter.atTop (nhds 0) := by | |
| simp_rw [card_recovery_copies] | |
| exact RecoveryGrowth.tendsto_log_replicationCount_div_nat hb hC | |
| end MatrixMultiplication.InverseLinearRecovery | |
| end | |
| end MatrixAllFields | |
| end OAI | |