Download data/lean/OAI/Computability/MinUncut/PCP/GraphTableComplexity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 30.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/PCP/GraphTableComplexity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MinUncut/PCP/GraphTableComplexity.lean
-
curl -L -o GraphTableComplexity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/PCP/GraphTableComplexity.lean
30.8 kB
| import Mathlib | |
| import OAI.Computability.MinUncut.PCP.RawInitialTables | |
| namespace OAI | |
| section | |
| namespace MinUncutGames.Foundations.PCP.GraphTableComplexity | |
| open MinUncutGames.Foundations.Complexity | |
| open Polynomial | |
| noncomputable def encodingPolynomial (q : Nat) : Polynomial Nat := | |
| X ^ 2 + C (2 * (q * q) + 1) * X + C 2 | |
| theorem encodingPolynomial_eval (q n : Nat) : | |
| (encodingPolynomial q).eval n = n ^ 2 + (2 * (q * q) + 1) * n + 2 := by | |
| simp [encodingPolynomial] | |
| theorem encodingPolynomial_mono (q : Nat) {n m : Nat} (hnm : n β€ m) : | |
| (encodingPolynomial q).eval n β€ (encodingPolynomial q).eval m := by | |
| rw [encodingPolynomial_eval, encodingPolynomial_eval] | |
| exact Nat.add_le_add_right | |
| (Nat.add_le_add (Nat.pow_le_pow_left hnm 2) (Nat.mul_le_mul_left _ hnm)) 2 | |
| theorem rowBound_le_polynomial (q vertices darts : Nat) : | |
| vertices + darts + 2 + darts * (vertices + darts + 2 * (q * q)) β€ | |
| (encodingPolynomial q).eval (vertices + darts) := by | |
| have hd : darts β€ vertices + darts := Nat.le_add_left darts vertices | |
| calc | |
| _ β€ vertices + darts + 2 + | |
| (vertices + darts) * (vertices + darts + 2 * (q * q)) := | |
| Nat.add_le_add_left (Nat.mul_le_mul_right _ hd) _ | |
| _ = _ := by rw [encodingPolynomial_eval]; ring | |
| theorem generic_size_add_two_le_bits {q : Nat} (table : GenericGraphTables.Table q) : | |
| table.vertices + table.darts + 2 β€ (GenericGraphTables.tableBits table).length := by | |
| simp only [GenericGraphTables.tableBits, GenericGraphTables.tableWords, | |
| encodeWords_append, List.length_append, encodeWords, encodeWord_length, List.length_nil] | |
| omega | |
| theorem generic_bits_le_polynomial {q : Nat} (table : GenericGraphTables.Table q) : | |
| (GenericGraphTables.tableBits table).length β€ | |
| (encodingPolynomial q).eval (table.vertices + table.darts) := | |
| (GenericGraphTables.tableBits_length_le table).trans | |
| (rowBound_le_polynomial q table.vertices table.darts) | |
| theorem generic_bits_le_of_size_le {q N : Nat} (table : GenericGraphTables.Table q) | |
| (hsize : table.vertices + table.darts β€ N) : | |
| (GenericGraphTables.tableBits table).length β€ (encodingPolynomial q).eval N := | |
| (generic_bits_le_polynomial table).trans (encodingPolynomial_mono q hsize) | |
| theorem size_add_two_le_bits (table : GraphTables.Table) : | |
| table.vertices + table.darts + 2 β€ (GraphTables.tableBits table).length := by | |
| simp only [GraphTables.tableBits, GraphTables.tableWords, | |
| encodeWords_append, List.length_append, encodeWords, encodeWord_length, List.length_nil] | |
| omega | |
| theorem bits_le_polynomial (table : GraphTables.Table) : | |
| (GraphTables.tableBits table).length β€ | |
| (encodingPolynomial 64).eval (table.vertices + table.darts) := | |
| (GraphTables.tableBits_length_le table).trans | |
| (rowBound_le_polynomial 64 table.vertices table.darts) | |
| theorem bits_le_of_size_le {N : Nat} (table : GraphTables.Table) | |
| (hsize : table.vertices + table.darts β€ N) : | |
| (GraphTables.tableBits table).length β€ (encodingPolynomial 64).eval N := | |
| (bits_le_polynomial table).trans (encodingPolynomial_mono 64 hsize) | |
| end MinUncutGames.Foundations.PCP.GraphTableComplexity | |
| end | |
| section | |
| noncomputable section | |
| namespace MinUncutGames.Foundations.PCP.AmplificationRound | |
| abbrev Label := QueryIncidence.Label 6 | |
| abbrev Addresses := PoweringLabels.PortWords Preprocessing.Port FinalConstants.walkLength | |
| abbrev PoweredAlphabet := | |
| PoweringLabels.PaddedLabel Preprocessing.Port FinalConstants.walkLength Label | |
| instance : Fintype PoweredAlphabet := Fintype.ofFinite _ | |
| instance : DecidableEq PoweredAlphabet := Classical.decEq _ | |
| variable {V E : Type*} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| [Nonempty E] | |
| abbrev PoweredDart (G : ConstraintGraph V E Label) := | |
| PoweringTest.Dart (Preprocessing.Vertex G) Preprocessing.Port | |
| (2 * FinalConstants.endpointLength) | |
| instance (G : ConstraintGraph V E Label) : DecidableEq (PoweredDart G) := Classical.decEq _ | |
| def selectors (addresses : List Addresses) (complete : β w, w β addresses) | |
| (G : ConstraintGraph V E Label) (v : Preprocessing.Vertex G) : | |
| PoweringLabels.AddressSelector (Preprocessing.portGraph G) | |
| FinalConstants.walkLength v := | |
| PoweringLabels.listSelector (Preprocessing.portGraph G) FinalConstants.walkLength | |
| v addresses complete | |
| def powered (addresses : List Addresses) (complete : β w, w β addresses) | |
| (G : ConstraintGraph V E Label) : | |
| ConstraintGraph (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet := | |
| PoweringTest.poweredGraph (Preprocessing.portGraph G) (Preprocessing.graph G).accepts | |
| (2 * FinalConstants.endpointLength) (selectors addresses complete G) | |
| abbrev Vertex (G : ConstraintGraph V E Label) := | |
| QueryIncidence.Vertex | |
| (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) | |
| (AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) | |
| abbrev Dart (G : ConstraintGraph V E Label) := | |
| QueryIncidence.Dart (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) 6 | |
| instance (G : ConstraintGraph V E Label) : Fintype (Vertex G) := by | |
| letI : Fintype (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet) := inferInstance | |
| letI : Fintype | |
| (AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) := | |
| inferInstance | |
| change Fintype | |
| (AlphabetGraph.Event (PoweredDart G) PoweredAlphabet β | |
| AlphabetGraph.Address (Preprocessing.Vertex G) (PoweredDart G) PoweredAlphabet) | |
| infer_instance | |
| instance (G : ConstraintGraph V E Label) : Fintype (Dart G) := by | |
| change Fintype ((AlphabetGraph.Event (PoweredDart G) PoweredAlphabet Γ Fin 6) Γ Bool) | |
| infer_instance | |
| instance (G : ConstraintGraph V E Label) : DecidableEq (Vertex G) := Classical.decEq _ | |
| def graph (addresses : List Addresses) (complete : β w, w β addresses) | |
| (G : ConstraintGraph V E Label) : ConstraintGraph (Vertex G) (Dart G) Label := | |
| AlphabetGraph.graph (powered addresses complete G) | |
| omit [Nonempty E] in | |
| theorem powered_completeness (addresses : List Addresses) | |
| (complete : β w, w β addresses) (G : ConstraintGraph V E Label) | |
| (satisfied : G.Satisfiable) : (powered addresses complete G).Satisfiable := by | |
| obtain β¨assignment, hassignmentβ© := Preprocessing.completeness G satisfied | |
| refine β¨PoweringOpinions.honestLabels (Preprocessing.portGraph G) | |
| FinalConstants.walkLength assignment, ?_β© | |
| apply PoweringTest.perfect_completeness (Preprocessing.portGraph G) | |
| (Preprocessing.graph G).accepts (2 * FinalConstants.endpointLength) | |
| (selectors addresses complete G) assignment | |
| intro e | |
| exact hassignment e | |
| omit [Nonempty E] in | |
| theorem completeness (addresses : List Addresses) | |
| (complete : β w, w β addresses) (G : ConstraintGraph V E Label) | |
| (satisfied : G.Satisfiable) : (graph addresses complete G).Satisfiable := | |
| AlphabetGraph.perfect_completeness _ | |
| (powered_completeness addresses complete G satisfied) | |
| end MinUncutGames.Foundations.PCP.AmplificationRound | |
| end | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringWitness | |
| open PoweringWalks SpectralReturn PoweringReturn PoweringLazy | |
| open PoweringMoment (bit) | |
| variable {V D : Type*} | |
| theorem iterate_mul_const [Fintype D] (G : PortGraph V D) | |
| (n : Nat) (c : β) (h : V β β) : | |
| iterateOperator G n (fun x => c * h x) = | |
| fun x => c * iterateOperator G n h x := by | |
| induction n with | |
| | zero => rfl | |
| | succ n ih => | |
| change averagingOperator G (iterateOperator G n (fun x => c * h x)) = | |
| fun x => c * averagingOperator G (iterateOperator G n h) x | |
| rw [ih] | |
| funext v | |
| exact mean_mul_left c (fun d => iterateOperator G n h (G.rot (v, d)).1) | |
| noncomputable def endpointWitness (G : PortGraph V D) (bad : Edge V D β Bool) | |
| (Ο Ο : Edge V D β V β β) (n : Nat) (k : Fin (n + 1)) | |
| (w : Walk V D (n + 1)) : β := | |
| bit (bad (edgeAt G n w k) = true) * | |
| Ο (edgeAt G n w k) w.1 * Ο (edgeAt G n w k) (endpoint G w) | |
| noncomputable def vertexWitness (G : PortGraph V D) (bad : Edge V D β Bool) | |
| (f : V β V β β) (n : Nat) (k : Fin (n + 1)) : | |
| Walk V D (n + 1) β β := | |
| endpointWitness G bad (fun e => f e.1) (fun e => f (next G e.1 e.2)) n k | |
| theorem endpoint_lower_bound [Fintype V] [Fintype D] [Nonempty D] | |
| (G : PortGraph V D) (n : Nat) (k : Fin (n + 1)) (bad : Edge V D β Bool) | |
| (Ο Ο : Edge V D β V β β) (a : β) (ha : 0 β€ a) | |
| (hL : β e, bad e = true β a β€ iterateOperator G k.val (Ο e) e.1) | |
| (hR : β e, bad e = true β | |
| a β€ iterateOperator G (n - k.val) (Ο e) (next G e.1 e.2)) : | |
| edgeDensity bad * a ^ 2 β€ mean (endpointWitness G bad Ο Ο n k) := by | |
| have hfactor : mean (endpointWitness G bad Ο Ο n k) = | |
| mean (fun e : Edge V D => | |
| (bit (bad e = true) * iterateOperator G k.val (Ο e) e.1) * | |
| iterateOperator G (n - k.val) (Ο e) (next G e.1 e.2)) := by | |
| unfold endpointWitness | |
| rw [mean_edge_endpoints G n k (fun e x => bit (bad e = true) * Ο e x) Ο] | |
| simp_rw [iterate_mul_const] | |
| have hbitMean : mean (fun e : Edge V D => bit (bad e = true)) = edgeDensity bad := by | |
| calc | |
| _ = mean (fun v : V => mean (fun d : D => bit (bad (v, d) = true))) := | |
| mean_prod (A := V) (B := D) (fun e => bit (bad e = true)) | |
| _ = edgeDensity bad := by simp only [mean_edge_bit, edgeDensity] | |
| calc | |
| edgeDensity bad * a ^ 2 = | |
| mean (fun e : Edge V D => bit (bad e = true) * a ^ 2) := by | |
| rw [mean_mul_right, hbitMean] | |
| _ β€ mean (fun e : Edge V D => | |
| (bit (bad e = true) * iterateOperator G k.val (Ο e) e.1) * | |
| iterateOperator G (n - k.val) (Ο e) (next G e.1 e.2)) := by | |
| apply mean_mono | |
| intro e | |
| cases hb : bad e with | |
| | false => simp [bit] | |
| | true => | |
| have hprod := mul_le_mul (hL e hb) (hR e hb) ha (ha.trans (hL e hb)) | |
| simpa [bit, hb, pow_two] using hprod | |
| _ = mean (endpointWitness G bad Ο Ο n k) := hfactor.symm | |
| theorem lazy_middle_witness_mean [Fintype V] [Fintype D] [Nonempty D] | |
| (G : PortGraph V D) (q M : Nat) (hq : 1 β€ q) (hM : 1 β€ M) | |
| (k : Fin (2 * (4 * q * M) ^ 2 + 1)) | |
| (hlo : (4 * q * M) ^ 2 - M β€ k.val) | |
| (hhi : k.val β€ (4 * q * M) ^ 2 + M) | |
| (bad : Edge V (Bool Γ D) β Bool) (f : V β V β β) | |
| (hf : β u w, f u w β Set.Icc (0 : β) 1) | |
| (hmodal : β u, 1 / (q : β) β€ | |
| iterateOperator (lazyGraph G) ((4 * q * M) ^ 2) (f u) u) : | |
| edgeDensity bad / (4 * (q : β) ^ 2) β€ | |
| mean (vertexWitness (lazyGraph G) bad f (2 * (4 * q * M) ^ 2) k) := by | |
| have hk : k.val β€ 2 * (4 * q * M) ^ 2 := Nat.le_of_lt_succ k.isLt | |
| have hslo : (4 * q * M) ^ 2 - M β€ 2 * (4 * q * M) ^ 2 - k.val := by omega | |
| have hshi : 2 * (4 * q * M) ^ 2 - k.val β€ (4 * q * M) ^ 2 + M := by omega | |
| have ha : (0 : β) β€ 1 / (2 * (q : β)) := by positivity | |
| have hbound := endpoint_lower_bound (lazyGraph G) (2 * (4 * q * M) ^ 2) k bad | |
| (fun e => f e.1) (fun e => f (next (lazyGraph G) e.1 e.2)) | |
| (1 / (2 * (q : β))) ha | |
| (by | |
| intro e _ | |
| exact lazy_endpoint_modal_transfer G q M k.val hq hM hlo hhi | |
| (f e.1) (hf e.1) e.1 (hmodal e.1)) | |
| (by | |
| intro e _ | |
| exact lazy_endpoint_modal_transfer G q M (2 * (4 * q * M) ^ 2 - k.val) | |
| hq hM hslo hshi (f (next (lazyGraph G) e.1 e.2)) | |
| (hf (next (lazyGraph G) e.1 e.2)) (next (lazyGraph G) e.1 e.2) | |
| (hmodal (next (lazyGraph G) e.1 e.2))) | |
| have hscale : edgeDensity bad * (1 / (2 * (q : β))) ^ 2 = | |
| edgeDensity bad / (4 * (q : β) ^ 2) := by ring | |
| simpa only [vertexWitness, hscale] using hbound | |
| end MinUncutGames.Foundations.PCP.PoweringWitness | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringMomentBound | |
| open scoped BigOperators | |
| open PoweringWalks SpectralReturn PoweringReturn | |
| open PoweringMoment (bit hits) | |
| theorem symmetric_gap_matrix_sum (Ξ΅ : β) (r : Nat β β) : | |
| β (m : Nat) (f : Fin m β Fin m β β), | |
| (β i j, f i j = f j i) β (β i, f i i = Ξ΅) β | |
| (β i j, i.val < j.val β f i j = r (j.val - i.val - 1)) β | |
| (β i, β j, f i j) = (m : β) * Ξ΅ + | |
| 2 * β j β Finset.range m, β gap β Finset.range j, r gap := by | |
| intro m | |
| induction m with | |
| | zero => intro f _hSym _hDiag _hUpper; simp | |
| | succ m ih => | |
| intro f hSym hDiag hUpper | |
| have hOld : (β i : Fin m, β j : Fin m, f i.castSucc j.castSucc) = | |
| (m : β) * Ξ΅ + 2 * β j β Finset.range m, β gap β Finset.range j, r gap := by | |
| apply ih (fun i j => f i.castSucc j.castSucc) | |
| Β· intro i j; exact hSym i.castSucc j.castSucc | |
| Β· intro i; exact hDiag i.castSucc | |
| Β· intro i j hij; exact hUpper i.castSucc j.castSucc hij | |
| have hLast : (β i : Fin m, f i.castSucc (Fin.last m)) = | |
| β gap β Finset.range m, r gap := by | |
| calc | |
| _ = β i : Fin m, r (m - 1 - i.val) := by | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| rw [hUpper i.castSucc (Fin.last m) i.isLt] | |
| simp only [Fin.val_last, Fin.val_castSucc] | |
| congr 1 | |
| omega | |
| _ = β i β Finset.range m, r (m - 1 - i) := | |
| Fin.sum_univ_eq_sum_range (fun i => r (m - 1 - i)) m | |
| _ = _ := Finset.sum_range_reflect r m | |
| have hLastRow : (β j : Fin m, f (Fin.last m) j.castSucc) = | |
| β gap β Finset.range m, r gap := by | |
| calc | |
| _ = β j : Fin m, f j.castSucc (Fin.last m) := by | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| exact hSym (Fin.last m) j.castSucc | |
| _ = _ := hLast | |
| calc | |
| (β i, β j, f i j) = | |
| (β i : Fin m, β j : Fin m, f i.castSucc j.castSucc) + | |
| (β i : Fin m, f i.castSucc (Fin.last m)) + | |
| (β j : Fin m, f (Fin.last m) j.castSucc) + f (Fin.last m) (Fin.last m) := by | |
| simp only [Fin.sum_univ_castSucc, Finset.sum_add_distrib] | |
| ring | |
| _ = (m : β) * Ξ΅ + | |
| 2 * (β j β Finset.range m, β gap β Finset.range j, r gap) + | |
| (β gap β Finset.range m, r gap) + (β gap β Finset.range m, r gap) + Ξ΅ := by | |
| rw [hOld, hLast, hLastRow, hDiag] | |
| _ = ((m + 1 : Nat) : β) * Ξ΅ + | |
| 2 * β j β Finset.range (m + 1), β gap β Finset.range j, r gap := by | |
| rw [Finset.sum_range_succ] | |
| simp only [Nat.cast_add, Nat.cast_one] | |
| ring | |
| def windowIndex (n start m : Nat) (h : start + m β€ n + 1) (i : Fin m) : Fin (n + 1) := | |
| β¨start + i.val, (Nat.add_lt_add_left i.isLt start).trans_le hβ© | |
| variable {V D : Type*} [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] | |
| def windowEvent (G : PortGraph V D) (bad : V Γ D β Bool) | |
| (n start m : Nat) (h : start + m β€ n + 1) (i : Fin m) (w : Walk V D (n + 1)) : Prop := | |
| bad (edgeAt G n w (windowIndex n start m h i)) = true | |
| theorem window_second_moment_eq (G : PortGraph V D) (bad : V Γ D β Bool) | |
| (n start m : Nat) (h : start + m β€ n + 1) : | |
| mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) = | |
| (m : β) * edgeDensity bad + | |
| 2 * β j β Finset.range m, β gap β Finset.range j, returnMass G bad gap := by | |
| rw [show mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) = | |
| β i, β j, mean (fun w => bit (windowEvent G bad n start m h i w β§ | |
| windowEvent G bad n start m h j w)) from | |
| PoweringMoment.second_moment_eq (windowEvent G bad n start m h)] | |
| apply symmetric_gap_matrix_sum | |
| Β· intro i j | |
| congr 1 | |
| funext w | |
| simp only [and_comm] | |
| Β· intro i | |
| simp only [and_self] | |
| exact hit_mean G bad n (windowIndex n start m h i) | |
| Β· intro i j hij | |
| have hwin : windowIndex n start m h i < windowIndex n start m h j := | |
| Nat.add_lt_add_left hij start | |
| have hp := pair_event_mean G bad n (windowIndex n start m h i) | |
| (windowIndex n start m h j) hwin | |
| simpa only [windowEvent, windowIndex, Nat.add_sub_add_left] using hp | |
| theorem window_second_moment_le (G : PortGraph V D) (lambda : β) | |
| (certificate : SpectralCertificate G lambda) (bad : V Γ D β Bool) | |
| (reversal : β e, bad (G.rot e) = bad e) | |
| (n start m : Nat) (h : start + m β€ n + 1) : | |
| mean (fun w => hits (windowEvent G bad n start m h) w ^ 2) β€ | |
| (m : β) * edgeDensity bad * | |
| (1 + 2 / (1 - lambda) + ((m : β) - 1) * edgeDensity bad) := by | |
| rw [window_second_moment_eq] | |
| exact secondMoment_return_envelope G lambda certificate bad reversal m | |
| end MinUncutGames.Foundations.PCP.PoweringMomentBound | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringNumeric | |
| theorem min_density_ratio (Ξ΅ C k t : β) | |
| (hΞ΅ : 0 < Ξ΅) (hC : 0 < C) (hk : 0 β€ k) | |
| (ht : 0 < t) (hkt : k β€ t) : | |
| min Ξ΅ (1 / t) / (C + 1) β€ Ξ΅ / (C + k * Ξ΅) := by | |
| have hx : 0 β€ min Ξ΅ (1 / t) := | |
| le_min hΞ΅.le (one_div_nonneg.mpr ht.le) | |
| have hxt : min Ξ΅ (1 / t) * t β€ 1 := | |
| (le_div_iffβ ht).mp (min_le_right Ξ΅ (1 / t)) | |
| have hkx : k * min Ξ΅ (1 / t) β€ 1 := by | |
| calc | |
| k * min Ξ΅ (1 / t) β€ t * min Ξ΅ (1 / t) := | |
| mul_le_mul_of_nonneg_right hkt hx | |
| _ β€ 1 := by simpa only [mul_comm] using hxt | |
| have hC1 : 0 < C + 1 := by positivity | |
| have hden : 0 < C + k * Ξ΅ := | |
| add_pos_of_pos_of_nonneg hC (mul_nonneg hk hΞ΅.le) | |
| apply (div_le_div_iffβ hC1 hden).2 | |
| calc | |
| min Ξ΅ (1 / t) * (C + k * Ξ΅) = | |
| C * min Ξ΅ (1 / t) + Ξ΅ * (k * min Ξ΅ (1 / t)) := by ring | |
| _ β€ C * Ξ΅ + Ξ΅ * 1 := | |
| add_le_add | |
| (mul_le_mul_of_nonneg_left (min_le_left Ξ΅ (1 / t)) hC.le) | |
| (mul_le_mul_of_nonneg_left hkx hΞ΅.le) | |
| _ = Ξ΅ * (C + 1) := by ring | |
| theorem count_moment_ratio_lower (Ξ± Ξ΅ C t : β) (m : β) | |
| (hm : 0 < m) (hΞ΅ : 0 < Ξ΅) (hC : 0 < C) (ht : 0 < t) | |
| (hmt : (m : β) - 1 β€ t) : | |
| (Ξ± ^ 4 * (m : β) / (C + 1)) * min Ξ΅ (1 / t) β€ | |
| (Ξ± ^ 2 * (m : β) * Ξ΅) ^ 2 / | |
| ((m : β) * Ξ΅ * (C + ((m : β) - 1) * Ξ΅)) := by | |
| have hm0 : (0 : β) < (m : β) := Nat.cast_pos.mpr hm | |
| have hm1 : (1 : β) β€ (m : β) := by | |
| exact_mod_cast (Nat.succ_le_iff.mpr hm) | |
| have hk : 0 β€ (m : β) - 1 := sub_nonneg.mpr hm1 | |
| have hden : 0 < C + ((m : β) - 1) * Ξ΅ := | |
| add_pos_of_pos_of_nonneg hC (mul_nonneg hk hΞ΅.le) | |
| have hΞ±m : 0 β€ Ξ± ^ 4 * (m : β) := by positivity | |
| have hratio := min_density_ratio Ξ΅ C ((m : β) - 1) t hΞ΅ hC hk ht hmt | |
| calc | |
| (Ξ± ^ 4 * (m : β) / (C + 1)) * min Ξ΅ (1 / t) = | |
| (Ξ± ^ 4 * (m : β)) * (min Ξ΅ (1 / t) / (C + 1)) := by ring | |
| _ β€ (Ξ± ^ 4 * (m : β)) * (Ξ΅ / (C + ((m : β) - 1) * Ξ΅)) := | |
| mul_le_mul_of_nonneg_left hratio hΞ±m | |
| _ = (Ξ± ^ 2 * (m : β) * Ξ΅) ^ 2 / | |
| ((m : β) * Ξ΅ * (C + ((m : β) - 1) * Ξ΅)) := by | |
| field_simp [ne_of_gt hm0, ne_of_gt hΞ΅, ne_of_gt hden] | |
| end MinUncutGames.Foundations.PCP.PoweringNumeric | |
| end | |
| section | |
| noncomputable section | |
| namespace MinUncutGames.Foundations.PCP.PoweringSoundness | |
| open scoped BigOperators | |
| open PoweringWalks PoweringLabels PoweringOpinions PoweringTest | |
| open SpectralReturn PoweringWitness PoweringMomentBound | |
| open PoweringMoment (bit hits) | |
| variable {V D A : Type*} | |
| def center (q M : Nat) : Nat := (4 * q * M) ^ 2 | |
| theorem le_center (q M : Nat) (hq : 1 β€ q) (hM : 1 β€ M) : M β€ center q M := by | |
| have hfour : 1 β€ 4 * q := by omega | |
| have hx : M β€ 4 * q * M := by simpa only [Nat.one_mul] using Nat.mul_le_mul_right M hfour | |
| have hone : 1 β€ 4 * q * M := hM.trans hx | |
| have hsquare : 4 * q * M β€ (4 * q * M) * (4 * q * M) := by | |
| simpa only [Nat.mul_one] using Nat.mul_le_mul_left (4 * q * M) hone | |
| exact hx.trans (by simpa only [center, pow_two] using hsquare) | |
| def gain (q M : Nat) (lambda : β) : β := | |
| (1 / (2 * (q : β))) ^ 4 * ((2 * M + 1 : Nat) : β) / | |
| ((1 + 2 / (1 - lambda)) + 1) | |
| variable [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] | |
| [Fintype A] [Nonempty A] | |
| def decodedError (G : PortGraph V D) (accepts : Edge V D β A β A β Bool) | |
| (n N : Nat) (selectors : β v, AddressSelector G (n + 1) v) | |
| (labels : V β PaddedLabel D (n + 1) A) (fallback : A) : β := | |
| edgeDensity (decodedBad G accepts (decoded G (n + 1) N selectors labels fallback)) | |
| def poweredRejection (G : PortGraph V D) (accepts : Edge V D β A β A β Bool) | |
| (n : Nat) (selectors : β v, AddressSelector G (n + 1) v) | |
| (labels : V β PaddedLabel D (n + 1) A) : β := | |
| mean (fun d : Dart V D n => bit ((poweredGraph G accepts n selectors).edgeSatisfied labels d = false)) | |
| omit [Fintype V] [Nonempty V] [Nonempty D] in | |
| theorem witness_bit_eq (G : PortGraph V D) (accepts : Edge V D β A β A β Bool) | |
| (n N : Nat) (selectors : β v, AddressSelector G (n + 1) v) | |
| (labels : V β PaddedLabel D (n + 1) A) (fallback : A) | |
| (w : Walk V D (n + 1)) (k : Fin (n + 1)) : | |
| bit (witness G accepts n selectors labels fallback | |
| (decoded G (n + 1) N selectors labels fallback) w k) = | |
| vertexWitness G | |
| (decodedBad G accepts (decoded G (n + 1) N selectors labels fallback)) | |
| (matchFn G (n + 1) N selectors labels fallback) n k w := by | |
| simp only [witness, vertexWitness, endpointWitness, matchFn, | |
| PoweringMoment.bit_mul, next, and_assoc] | |
| omit [Nonempty V] in | |
| theorem modal_witness_mean (G : PortGraph V D) (M : Nat) (hM : 1 β€ M) | |
| (accepts : Edge V (Bool Γ D) β A β A β Bool) | |
| (selectors : β v, AddressSelector (lazyGraph G) (2 * center (Fintype.card A) M + 1) v) | |
| (labels : V β PaddedLabel (Bool Γ D) (2 * center (Fintype.card A) M + 1) A) | |
| (fallback : A) (k : Fin (2 * center (Fintype.card A) M + 1)) | |
| (hlo : center (Fintype.card A) M - M β€ k.val) | |
| (hhi : k.val β€ center (Fintype.card A) M + M) : | |
| decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) | |
| (center (Fintype.card A) M) selectors labels fallback / (4 * (Fintype.card A : β) ^ 2) β€ | |
| mean (fun w => bit (witness (lazyGraph G) accepts (2 * center (Fintype.card A) M) | |
| selectors labels fallback (decoded (lazyGraph G) (2 * center (Fintype.card A) M + 1) | |
| (center (Fintype.card A) M) selectors labels fallback) w k)) := by | |
| have h := lazy_middle_witness_mean G (Fintype.card A) M Fintype.card_pos hM k hlo hhi | |
| (decodedBad (lazyGraph G) accepts | |
| (decoded (lazyGraph G) (2 * center (Fintype.card A) M + 1) | |
| (center (Fintype.card A) M) selectors labels fallback)) | |
| (matchFn (lazyGraph G) (2 * center (Fintype.card A) M + 1) | |
| (center (Fintype.card A) M) selectors labels fallback) | |
| (matchFn_mem_Icc (lazyGraph G) (2 * center (Fintype.card A) M + 1) | |
| (center (Fintype.card A) M) selectors labels fallback) | |
| (decoded_modal_baseline (lazyGraph G) (2 * center (Fintype.card A) M + 1) | |
| (center (Fintype.card A) M) selectors labels fallback) | |
| simp_rw [witness_bit_eq] | |
| convert h using 1 <;> rfl | |
| theorem rejection_lower_bound (G : PortGraph V D) (lambda : β) | |
| (certificate : SpectralCertificate (lazyGraph G) lambda) | |
| (accepts : Edge V (Bool Γ D) β A β A β Bool) | |
| (reverse_accepts : β e a b, accepts ((lazyGraph G).rot e) b a = accepts e a b) | |
| (M : Nat) (hM : 1 β€ M) | |
| (selectors : β v, AddressSelector (lazyGraph G) (2 * center (Fintype.card A) M + 1) v) | |
| (labels : V β PaddedLabel (Bool Γ D) (2 * center (Fintype.card A) M + 1) A) | |
| (fallback : A) | |
| (hΞ΅ : 0 < decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) | |
| (center (Fintype.card A) M) selectors labels fallback) : | |
| gain (Fintype.card A) M lambda * | |
| min (decodedError (lazyGraph G) accepts (2 * center (Fintype.card A) M) | |
| (center (Fintype.card A) M) selectors labels fallback) | |
| (1 / ((2 * center (Fintype.card A) M + 1 : Nat) : β)) β€ | |
| poweredRejection (lazyGraph G) accepts (2 * center (Fintype.card A) M) selectors labels := by | |
| let q := Fintype.card A | |
| let N := center q M | |
| let n := 2 * N | |
| let m := 2 * M + 1 | |
| let start := N - M | |
| let L := lazyGraph G | |
| let assignment := decoded L (n + 1) N selectors labels fallback | |
| let bad := decodedBad L accepts assignment | |
| let Ξ΅ := edgeDensity bad | |
| let Ξ± : β := 1 / (2 * (q : β)) | |
| let C : β := 1 + 2 / (1 - lambda) | |
| have hNM : M β€ N := le_center q M Fintype.card_pos hM | |
| have hw : start + m β€ n + 1 := by dsimp [start, m, n]; omega | |
| let E := windowEvent L bad n start m hw | |
| let W : Fin m β Walk V (Bool Γ D) (n + 1) β Prop := fun i w => | |
| witness L accepts n selectors labels fallback assignment w (windowIndex n start m hw i) | |
| let R : Walk V (Bool Γ D) (n + 1) β Prop := fun w => | |
| pathAccepts L accepts n selectors w (labels w.1) (labels (endpoint L w)) = false | |
| have hWE : β i w, W i w β E i w := by | |
| intro i w h | |
| exact h.1 | |
| have hWR : β i w, W i w β R w := by | |
| intro i w h | |
| exact witness_implies_path_rejection L accepts n selectors labels fallback assignment w | |
| (windowIndex n start m hw i) h | |
| have hpoint (i : Fin m) : Ξ΅ / (4 * (q : β) ^ 2) β€ mean (fun w => bit (W i w)) := by | |
| have hlo : N - M β€ (windowIndex n start m hw i).val := by | |
| dsimp [windowIndex, start] | |
| omega | |
| have hhi : (windowIndex n start m hw i).val β€ N + M := by | |
| have hi := i.isLt | |
| dsimp [windowIndex, start] | |
| dsimp [m] at hi | |
| omega | |
| exact modal_witness_mean G M hM accepts selectors labels fallback | |
| (windowIndex n start m hw i) hlo hhi | |
| have hfirst : Ξ± ^ 2 * (m : β) * Ξ΅ β€ mean (hits W) := by | |
| change Ξ± ^ 2 * (m : β) * Ξ΅ β€ PoweringMoment.mean (hits W) | |
| rw [PoweringMoment.mean_hits] | |
| calc | |
| _ = β _i : Fin m, Ξ΅ / (4 * (q : β) ^ 2) := by | |
| simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] | |
| dsimp [Ξ±] | |
| ring | |
| _ β€ _ := Finset.sum_le_sum (fun i _ => hpoint i) | |
| have hsecond : mean (fun w => hits E w ^ 2) β€ | |
| (m : β) * Ξ΅ * (C + ((m : β) - 1) * Ξ΅) := | |
| window_second_moment_le L lambda certificate bad | |
| (decodedBad_rot L accepts reverse_accepts assignment) n start m hw | |
| have hΞ΅' : 0 < Ξ΅ := hΞ΅ | |
| have hm : 0 < m := by dsimp [m]; omega | |
| have hmReal : (0 : β) < m := Nat.cast_pos.mpr hm | |
| have hqReal : (0 : β) < q := Nat.cast_pos.mpr Fintype.card_pos | |
| have hden : 0 < 1 - lambda := sub_pos.mpr certificate.lt_one | |
| have hC : 0 < C := by dsimp [C]; positivity | |
| have hmOne : (1 : β) β€ m := by exact_mod_cast hm | |
| have hΞ± : 0 < Ξ± := by dsimp [Ξ±]; positivity | |
| have ha : 0 < Ξ± ^ 2 * (m : β) * Ξ΅ := by positivity | |
| have hb : 0 < (m : β) * Ξ΅ * (C + ((m : β) - 1) * Ξ΅) := by | |
| have hdiff : 0 β€ (m : β) - 1 := sub_nonneg.mpr hmOne | |
| positivity | |
| have hCS := PoweringMoment.rejection_lower_bound E W R hWE hWR | |
| (Ξ± ^ 2 * (m : β) * Ξ΅) ((m : β) * Ξ΅ * (C + ((m : β) - 1) * Ξ΅)) | |
| ha hb hfirst hsecond | |
| have ht : (0 : β) < ((n + 1 : Nat) : β) := Nat.cast_pos.mpr (Nat.succ_pos n) | |
| have hmn : m β€ n + 1 := by dsimp [m, n]; omega | |
| have hmt : (m : β) - 1 β€ ((n + 1 : Nat) : β) := by | |
| have hmnReal : (m : β) β€ ((n + 1 : Nat) : β) := by exact_mod_cast hmn | |
| linarith | |
| have hratio := PoweringNumeric.count_moment_ratio_lower Ξ± Ξ΅ C ((n + 1 : Nat) : β) | |
| m hm hΞ΅' hC ht hmt | |
| change (Ξ± ^ 4 * (m : β) / (C + 1)) * min Ξ΅ (1 / ((n + 1 : Nat) : β)) β€ _ | |
| change _ β€ mean (fun d : Dart V (Bool Γ D) n => | |
| bit ((poweredGraph L accepts n selectors).edgeSatisfied labels d = false)) | |
| rw [rejection_mean_eq_path_mean] | |
| exact hratio.trans hCS | |
| end MinUncutGames.Foundations.PCP.PoweringSoundness | |
| end | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringGap | |
| open PoweringWalks PoweringLabels PoweringOpinions PoweringTest | |
| open SpectralReturn PoweringSoundness PoweringCounting | |
| variable {V D A : Type*} | |
| theorem gain_nonneg (q M : Nat) (lambda : β) (hlambda : lambda < 1) : | |
| 0 β€ gain q M lambda := by | |
| have hden : 0 < 1 - lambda := sub_pos.mpr hlambda | |
| unfold gain | |
| positivity | |
| variable [Fintype V] [Fintype D] [Nonempty V] [Nonempty D] | |
| [Fintype A] [Nonempty A] | |
| theorem uniform_count_gap (G : PortGraph V D) (lambda : β) | |
| (certificate : SpectralCertificate (lazyGraph G) lambda) | |
| (accepts : Edge V (Bool Γ D) β A β A β Bool) | |
| (reverse_accepts : β e a b, accepts ((lazyGraph G).rot e) b a = accepts e a b) | |
| (M : Nat) (hM : 1 β€ M) | |
| (selectors : β v, AddressSelector (lazyGraph G) | |
| (2 * center (Fintype.card A) M + 1) v) | |
| (epsilon : β) (hepsilon : 0 β€ epsilon) | |
| (hgap : β assignment : V β A, | |
| epsilon * (Fintype.card (Edge V (Bool Γ D)) : β) β€ | |
| ((baseGraph (lazyGraph G) accepts reverse_accepts).rejectionCount assignment : β)) | |
| (labels : V β PaddedLabel (Bool Γ D) (2 * center (Fintype.card A) M + 1) A) : | |
| (gain (Fintype.card A) M lambda * | |
| min epsilon (1 / ((2 * center (Fintype.card A) M + 1 : Nat) : β))) * | |
| (Fintype.card (Dart V (Bool Γ D) (2 * center (Fintype.card A) M)) : β) β€ | |
| ((poweredGraph (lazyGraph G) accepts (2 * center (Fintype.card A) M) | |
| selectors).rejectionCount labels : β) := by | |
| classical | |
| let L := lazyGraph G | |
| let N := center (Fintype.card A) M | |
| let n := 2 * N | |
| let H := poweredGraph L accepts n selectors | |
| change (gain (Fintype.card A) M lambda * | |
| min epsilon (1 / ((n + 1 : Nat) : β))) * | |
| (Fintype.card (Dart V (Bool Γ D) n) : β) β€ | |
| (H.rejectionCount labels : β) | |
| rcases eq_or_lt_of_le hepsilon with hzero | hpositive | |
| Β· rw [β hzero] | |
| have hcap : (0 : β) β€ 1 / ((n + 1 : Nat) : β) := by positivity | |
| rw [min_eq_left hcap, mul_zero, zero_mul] | |
| exact Nat.cast_nonneg _ | |
| Β· let fallback : A := Classical.choice (inferInstance : Nonempty A) | |
| let assignment := decoded L (n + 1) N selectors labels fallback | |
| have hdecoded : epsilon β€ decodedError L accepts n N selectors labels fallback := by | |
| change epsilon β€ edgeDensity (decodedBad L accepts assignment) | |
| exact base_count_lower_to_density L accepts reverse_accepts assignment | |
| Fintype.card_pos epsilon (hgap assignment) | |
| have herror : 0 < decodedError L accepts n N selectors labels fallback := | |
| hpositive.trans_le hdecoded | |
| have hsound := PoweringSoundness.rejection_lower_bound G lambda certificate | |
| accepts reverse_accepts M hM selectors labels fallback herror | |
| have hgain : 0 β€ gain (Fintype.card A) M lambda := | |
| gain_nonneg (Fintype.card A) M lambda certificate.lt_one | |
| have hmin : min epsilon (1 / ((n + 1 : Nat) : β)) β€ | |
| min (decodedError L accepts n N selectors labels fallback) | |
| (1 / ((n + 1 : Nat) : β)) := | |
| min_le_min hdecoded (le_refl _) | |
| have hlower : gain (Fintype.card A) M lambda * | |
| min epsilon (1 / ((n + 1 : Nat) : β)) β€ | |
| poweredRejection L accepts n selectors labels := | |
| (mul_le_mul_of_nonneg_left hmin hgain).trans hsound | |
| exact (constraint_rejection_lower_iff H labels Fintype.card_pos | |
| (gain (Fintype.card A) M lambda * | |
| min epsilon (1 / ((n + 1 : Nat) : β)))).mp hlower | |
| end MinUncutGames.Foundations.PCP.PoweringGap | |
| end | |
| end OAI | |