Download data/lean/OAI/Computability/UniqueGames/PCP/HonestTestLemmas.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 31.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/PCP/HonestTestLemmas.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/UniqueGames/PCP/HonestTestLemmas.lean
-
curl -L -o HonestTestLemmas.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/PCP/HonestTestLemmas.lean
31.1 kB
| import Mathlib.Logic.Equiv.Prod | |
| import OAI.Computability.UniqueGames.Foundations.SamplingLemmas | |
| import OAI.Computability.UniqueGames.PCP.ClauseVerifierLemmas | |
| import OAI.Computability.UniqueGames.PCP.FourierResponseLemmas | |
| import OAI.Computability.UniqueGames.PCP.SourceNoiseParameterLemmas | |
| import OAI.Computability.UniqueGames.Reduction.ExplicitLemmas | |
| namespace OAI | |
| section | |
| /-! Honest completeness of the actual three-query test. Compatible coordinate | |
| dictators cancel the two uniform query tables, leaving exactly one noise bit. | |
| The finite-tape form uses the proved product-noise pushforward law. -/ | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Foundations.Hastad | |
| open scoped BigOperators | |
| open UniqueGamesTheorem.Reduction.FiniteNoise | |
| variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] | |
| omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in | |
| /-- For compatible honest coordinates, the test parity is precisely the | |
| selected noise coordinate, for every individual choice of query tables. -/ | |
| theorem dictator_test_parity (Ο : J β I) (i : I) (j : J) (hΟ : Ο j = i) | |
| (f : Cube I) (g ΞΌ : Cube J) : | |
| (f i ^^ g j ^^ (thirdQuery Ο f g ΞΌ) j) = ΞΌ j := by | |
| simp only [thirdQuery, cubeXor, hΟ] | |
| cases f i <;> cases g j <;> cases ΞΌ j <;> rfl | |
| /-- The product noise law has the specified sign bias in every coordinate. -/ | |
| theorem noise_coordinate_sign (Ξ΅ : β) (j : J) : | |
| (β ΞΌ : Cube J, noiseWeight Ξ΅ ΞΌ * bitSign (ΞΌ j)) = 1 - 2 * Ξ΅ := by | |
| have hs : support (coordinateMask j) = {j} := by | |
| ext k | |
| simp [support, coordinateMask] | |
| have h := noise_walsh Ξ΅ (coordinateMask j) | |
| simp_rw [walsh_symm (coordinateMask j), walsh_coordinateMask] at h | |
| simpa only [hs, Finset.card_singleton, pow_one] using h | |
| /-- The probability of a false noise bit is exactly `1 - Ξ΅`. This is an | |
| algebraic identity of the explicit product weights, valid for every real Ξ΅. -/ | |
| theorem noise_coordinate_false (Ξ΅ : β) (j : J) : | |
| (β ΞΌ : Cube J, noiseWeight Ξ΅ ΞΌ * if ΞΌ j then (0 : β) else 1) = 1 - Ξ΅ := by | |
| have hind (b : Bool) : (if b then (0 : β) else 1) = | |
| (1 + bitSign b) * (2 : β)β»ΒΉ := by | |
| cases b <;> norm_num [bitSign] | |
| have ht (ΞΌ : Cube J) : noiseWeight Ξ΅ ΞΌ * (if ΞΌ j then (0 : β) else 1) = | |
| (noiseWeight Ξ΅ ΞΌ + noiseWeight Ξ΅ ΞΌ * bitSign (ΞΌ j)) * (2 : β)β»ΒΉ := by | |
| rw [hind] | |
| ring | |
| simp_rw [ht] | |
| rw [β Finset.sum_mul, Finset.sum_add_distrib, noiseWeight_sum, noise_coordinate_sign] | |
| ring | |
| /-- Exact honest acceptance for the actual three-bit test. -/ | |
| theorem testAcceptance_dictator (Ξ΅ : β) (Ο : J β I) | |
| (i : I) (j : J) (hΟ : Ο j = i) : | |
| testAcceptance Ξ΅ Ο (fun f => f i) (fun g => g j) = 1 - Ξ΅ := by | |
| have hg (f : Cube I) (ΞΌ : Cube J) : | |
| (πΌ g : Cube J, if f i ^^ g j ^^ (thirdQuery Ο f g ΞΌ) j then (0 : β) else 1) = | |
| if ΞΌ j then 0 else 1 := by | |
| calc | |
| _ = πΌ _g : Cube J, if ΞΌ j then (0 : β) else 1 := by | |
| apply Finset.expect_congr rfl | |
| intro g _ | |
| rw [dictator_test_parity Ο i j hΟ f g ΞΌ] | |
| _ = _ := Fintype.expect_const _ | |
| change (πΌ f : Cube I, β ΞΌ : Cube J, noiseWeight Ξ΅ ΞΌ * | |
| (πΌ g : Cube J, if f i ^^ g j ^^ (thirdQuery Ο f g ΞΌ) j then (0 : β) else 1)) = _ | |
| simp_rw [hg] | |
| rw [Fintype.expect_const] | |
| exact noise_coordinate_false Ξ΅ j | |
| /-- Storing an honest dictator in the actual half-table representation gives | |
| the same acceptance after applying the explicit folding correction. -/ | |
| theorem testAcceptance_folded_dictators (Ξ΅ : β) (Ο : J β I) | |
| (iβ i : I) (jβ j : J) (hΟ : Ο j = i) : | |
| testAcceptance Ξ΅ Ο (foldedAnswer iβ (fun h => h.val i)) | |
| (foldedAnswer jβ (fun h => h.val j)) = 1 - Ξ΅ := by | |
| have hA : foldedAnswer iβ (fun h => h.val i) = (fun f : Cube I => f i) := | |
| funext (foldedAnswer_dictator iβ i) | |
| have hB : foldedAnswer jβ (fun h => h.val j) = (fun g : Cube J => g j) := | |
| funext (foldedAnswer_dictator jβ j) | |
| rw [hA, hB] | |
| exact testAcceptance_dictator Ξ΅ Ο i j hΟ | |
| /-- Honest valid local assignments remain dictators after both conditioning | |
| and folding, so the concrete conditioned tables have the same completeness. -/ | |
| theorem testAcceptance_conditioned_dictators (Ξ΅ : β) (Ο : J β I) | |
| (validI : I β Bool) (validJ : J β Bool) | |
| (iβ i : {i : I // validI i = true}) (jβ j : {j : J // validJ j = true}) | |
| (hΟ : Ο j.val = i.val) : | |
| testAcceptance Ξ΅ Ο | |
| (conditionedFoldedAnswer validI iβ (fun h => h.val i)) | |
| (conditionedFoldedAnswer validJ jβ (fun h => h.val j)) = 1 - Ξ΅ := by | |
| have hA : conditionedFoldedAnswer validI iβ (fun h => h.val i) = | |
| (fun f : Cube I => f i.val) := | |
| funext (conditionedFoldedAnswer_dictator validI iβ i) | |
| have hB : conditionedFoldedAnswer validJ jβ (fun h => h.val j) = | |
| (fun g : Cube J => g j.val) := | |
| funext (conditionedFoldedAnswer_dictator validJ jβ j) | |
| rw [hA, hB] | |
| exact testAcceptance_dictator Ξ΅ Ο i.val j.val hΟ | |
| theorem testAcceptance_folded_conditioned_dictators (Ξ΅ : β) (Ο : J β I) | |
| (iβ i : I) (valid : J β Bool) | |
| (jβ j : {j : J // valid j = true}) (hΟ : Ο j.val = i) : | |
| testAcceptance Ξ΅ Ο (foldedAnswer iβ (fun h => h.val i)) | |
| (conditionedFoldedAnswer valid jβ (fun h => h.val j)) = 1 - Ξ΅ := by | |
| have hA : foldedAnswer iβ (fun h => h.val i) = (fun f : Cube I => f i) := | |
| funext (foldedAnswer_dictator iβ i) | |
| have hB : conditionedFoldedAnswer valid jβ (fun h => h.val j) = | |
| (fun g : Cube J => g j.val) := | |
| funext (conditionedFoldedAnswer_dictator valid jβ j) | |
| rw [hA, hB] | |
| exact testAcceptance_dictator Ξ΅ Ο i j.val hΟ | |
| /-- The actual test using one uniform `Fin D` tape entry per noise coordinate. -/ | |
| def realizedTestAcceptance (D : Nat) (Ο : J β I) | |
| (A : Cube I β Bool) (B : Cube J β Bool) : β := | |
| πΌ f : Cube I, πΌ z : J β Fin D, πΌ g : Cube J, | |
| if A f ^^ B g ^^ B (thirdQuery Ο f g (realizedNoise z)) then 0 else 1 | |
| /-- Exact equality between the finite uniform tape and the weighted product | |
| noise test; no distributional acceptance premise is assumed. -/ | |
| theorem realizedTestAcceptance_eq_testAcceptance {D : Nat} (positive : 0 < D) | |
| (Ο : J β I) (A : Cube I β Bool) (B : Cube J β Bool) : | |
| realizedTestAcceptance D Ο A B = testAcceptance ((D : β)β»ΒΉ) Ο A B := by | |
| unfold realizedTestAcceptance testAcceptance | |
| apply Finset.expect_congr rfl | |
| intro f _ | |
| exact expect_realizedNoise positive | |
| (fun ΞΌ => πΌ g : Cube J, if A f ^^ B g ^^ B (thirdQuery Ο f g ΞΌ) then 0 else 1) | |
| /-- Exact honest completeness of the uniformly sampled finite-tape test. -/ | |
| theorem realizedTestAcceptance_dictator {D : Nat} (positive : 0 < D) | |
| (Ο : J β I) (i : I) (j : J) (hΟ : Ο j = i) : | |
| realizedTestAcceptance D Ο (fun f => f i) (fun g => g j) = 1 - (D : β)β»ΒΉ := by | |
| rw [realizedTestAcceptance_eq_testAcceptance positive] | |
| exact testAcceptance_dictator _ Ο i j hΟ | |
| theorem realizedTestAcceptance_folded_dictators {D : Nat} (positive : 0 < D) | |
| (Ο : J β I) (iβ i : I) (jβ j : J) (hΟ : Ο j = i) : | |
| realizedTestAcceptance D Ο (foldedAnswer iβ (fun h => h.val i)) | |
| (foldedAnswer jβ (fun h => h.val j)) = 1 - (D : β)β»ΒΉ := by | |
| rw [realizedTestAcceptance_eq_testAcceptance positive] | |
| exact testAcceptance_folded_dictators _ Ο iβ i jβ j hΟ | |
| theorem realizedTestAcceptance_conditioned_dictators {D : Nat} (positive : 0 < D) | |
| (Ο : J β I) (validI : I β Bool) (validJ : J β Bool) | |
| (iβ i : {i : I // validI i = true}) (jβ j : {j : J // validJ j = true}) | |
| (hΟ : Ο j.val = i.val) : | |
| realizedTestAcceptance D Ο | |
| (conditionedFoldedAnswer validI iβ (fun h => h.val i)) | |
| (conditionedFoldedAnswer validJ jβ (fun h => h.val j)) = 1 - (D : β)β»ΒΉ := by | |
| rw [realizedTestAcceptance_eq_testAcceptance positive] | |
| exact testAcceptance_conditioned_dictators _ Ο validI validJ iβ i jβ j hΟ | |
| theorem realizedTestAcceptance_folded_conditioned_dictators {D : Nat} (positive : 0 < D) | |
| (Ο : J β I) (iβ i : I) (valid : J β Bool) | |
| (jβ j : {j : J // valid j = true}) (hΟ : Ο j.val = i) : | |
| realizedTestAcceptance D Ο (foldedAnswer iβ (fun h => h.val i)) | |
| (conditionedFoldedAnswer valid jβ (fun h => h.val j)) = 1 - (D : β)β»ΒΉ := by | |
| rw [realizedTestAcceptance_eq_testAcceptance positive] | |
| exact testAcceptance_folded_conditioned_dictators _ Ο iβ i valid jβ j hΟ | |
| end UniqueGamesTheorem.Foundations.Hastad | |
| end | |
| end | |
| section | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Foundations.Hastad.SourceTape | |
| open scoped BigOperators | |
| open UniqueGamesTheorem.Reduction.FiniteNoise | |
| /-- Two full Boolean query tables and one finite noise entry per right index. -/ | |
| abbrev TestTape (I J : Type*) (D : β) := | |
| Cube I Γ ((J β Fin D) Γ Cube J) | |
| abbrev FairTestTape (I J : Type*) (D : β) := TestTape I J D Γ Bool | |
| section Expectations | |
| variable {X Y : Type*} [Fintype X] [Fintype Y] | |
| theorem expect_prod (H : X Γ Y β β) : | |
| (πΌ p : X Γ Y, H p) = πΌ x : X, πΌ y : Y, H (x, y) := by | |
| simpa only [Finset.univ_product_univ] using | |
| (Finset.expect_product (Finset.univ : Finset X) (Finset.univ : Finset Y) H) | |
| end Expectations | |
| section Tape | |
| variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {D : β} | |
| theorem card_testTape : | |
| Fintype.card (TestTape I J D) = | |
| 2 ^ Fintype.card I * (D ^ Fintype.card J * 2 ^ Fintype.card J) := by | |
| simp [TestTape, Cube] | |
| theorem card_fairTestTape : | |
| Fintype.card (FairTestTape I J D) = | |
| (2 ^ Fintype.card I * (D ^ Fintype.card J * 2 ^ Fintype.card J)) * 2 := by | |
| rw [Fintype.card_prod, card_testTape] | |
| rfl | |
| theorem expect_testTape (H : TestTape I J D β β) : | |
| (πΌ t : TestTape I J D, H t) = | |
| πΌ f : Cube I, πΌ z : J β Fin D, πΌ g : Cube J, H (f, z, g) := by | |
| rw [expect_prod] | |
| apply Finset.expect_congr rfl | |
| intro f _ | |
| exact expect_prod _ | |
| /-- Any explicit finite enumeration equivalence preserves the exact tape law. -/ | |
| theorem expect_equivTape {E : Type*} [Fintype E] | |
| (e : E β TestTape I J D) (H : TestTape I J D β β) : | |
| (πΌ s : E, H (e s)) = πΌ t : TestTape I J D, H t := | |
| Fintype.expect_equiv e _ _ (fun _ => rfl) | |
| theorem expect_fairTestTape (H : FairTestTape I J D β β) : | |
| (πΌ t : FairTestTape I J D, H t) = | |
| πΌ t : TestTape I J D, (H (t, false) + H (t, true)) / 2 := by | |
| rw [expect_prod] | |
| apply Finset.expect_congr rfl | |
| intro t _ | |
| rw [Fintype.expect_eq_sum_div_card] | |
| simp [add_comm] | |
| theorem expect_fairTestTape_ignore (H : TestTape I J D β β) : | |
| (πΌ t : FairTestTape I J D, H t.1) = πΌ t : TestTape I J D, H t := by | |
| rw [expect_prod] | |
| simp only [Fintype.expect_const] | |
| /-- The three actual query tables read from a uniform finite tape. -/ | |
| def tapeQueries (Ο : J β I) (t : TestTape I J D) : Cube I Γ Cube J Γ Cube J := | |
| (t.1, t.2.2, thirdQuery Ο t.1 t.2.2 (realizedNoise t.2.1)) | |
| /-- Exact joint law of all three queries, for every real-valued observable. -/ | |
| theorem expect_tapeQueries (positive : 0 < D) (Ο : J β I) | |
| (H : Cube I Γ Cube J Γ Cube J β β) : | |
| (πΌ t : TestTape I J D, H (tapeQueries Ο t)) = | |
| πΌ f : Cube I, β ΞΌ : Cube J, noiseWeight ((D : β)β»ΒΉ) ΞΌ * | |
| (πΌ g : Cube J, H (f, g, thirdQuery Ο f g ΞΌ)) := by | |
| rw [expect_testTape] | |
| apply Finset.expect_congr rfl | |
| intro f _ | |
| exact expect_realizedNoise positive | |
| (fun ΞΌ => πΌ g : Cube J, H (f, g, thirdQuery Ο f g ΞΌ)) | |
| def tapeAcceptance (D : β) (Ο : J β I) | |
| (A : Cube I β Bool) (B : Cube J β Bool) : β := | |
| πΌ t : TestTape I J D, | |
| if A t.1 ^^ B t.2.2 ^^ B (thirdQuery Ο t.1 t.2.2 (realizedNoise t.2.1)) | |
| then 0 else 1 | |
| theorem tapeAcceptance_eq_realizedTestAcceptance (D : β) (Ο : J β I) | |
| (A : Cube I β Bool) (B : Cube J β Bool) : | |
| tapeAcceptance D Ο A B = realizedTestAcceptance D Ο A B := | |
| expect_testTape _ | |
| theorem tapeAcceptance_eq_testAcceptance (positive : 0 < D) (Ο : J β I) | |
| (A : Cube I β Bool) (B : Cube J β Bool) : | |
| tapeAcceptance D Ο A B = testAcceptance ((D : β)β»ΒΉ) Ο A B := by | |
| rw [tapeAcceptance_eq_realizedTestAcceptance, | |
| realizedTestAcceptance_eq_testAcceptance positive] | |
| theorem tapeAcceptance_eq_sum_div_card (D : β) (Ο : J β I) | |
| (A : Cube I β Bool) (B : Cube J β Bool) : | |
| tapeAcceptance D Ο A B = | |
| (β t : TestTape I J D, | |
| if A t.1 ^^ B t.2.2 ^^ B (thirdQuery Ο t.1 t.2.2 (realizedNoise t.2.1)) | |
| then (0 : β) else 1) / Fintype.card (TestTape I J D) := | |
| Fintype.expect_eq_sum_div_card _ | |
| end Tape | |
| section Restriction | |
| variable {X Ξ : Type*} | |
| def restrictFunction (P : X β Prop) (f : X β Ξ) : {x : X // P x} β Ξ := | |
| fun x => f x.val | |
| /-- Uniform full functions push forward to uniform functions on any subtype. | |
| Nonempty values ensure that the unused coordinates can be filled. -/ | |
| theorem expect_restrictFunction [Fintype X] [DecidableEq X] [Fintype Ξ] [Nonempty Ξ] | |
| (P : X β Prop) [DecidablePred P] (H : ({x : X // P x} β Ξ) β β) : | |
| (πΌ f : X β Ξ, H (restrictFunction P f)) = | |
| πΌ g : {x : X // P x} β Ξ, H g := by | |
| classical | |
| calc | |
| _ = πΌ p : ({x : X // P x} β Ξ) Γ ({x : X // Β¬ P x} β Ξ), H p.1 := | |
| Fintype.expect_equiv (Equiv.piEquivPiSubtypeProd P (fun _ => Ξ)) _ _ | |
| (fun _ => rfl) | |
| _ = _ := by | |
| rw [expect_prod] | |
| simp only [Fintype.expect_const] | |
| variable {I J : Type*} | |
| def restrictTape (P : I β Prop) (Q : J β Prop) {D : β} | |
| (t : TestTape I J D) : TestTape {i : I // P i} {j : J // Q j} D := | |
| (restrictFunction P t.1, restrictFunction Q t.2.1, restrictFunction Q t.2.2) | |
| theorem expect_restrictTape [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] | |
| (P : I β Prop) (Q : J β Prop) [DecidablePred P] [DecidablePred Q] | |
| {D : β} (positive : 0 < D) | |
| (H : TestTape {i : I // P i} {j : J // Q j} D β β) : | |
| (πΌ t : TestTape I J D, H (restrictTape P Q t)) = | |
| πΌ t : TestTape {i : I // P i} {j : J // Q j} D, H t := by | |
| let : Nonempty (Fin D) := β¨β¨0, positiveβ©β© | |
| rw [expect_testTape, expect_testTape] | |
| change (πΌ f : Cube I, πΌ z : J β Fin D, πΌ g : Cube J, | |
| H (restrictFunction P f, restrictFunction Q z, restrictFunction Q g)) = _ | |
| have hg (f : Cube I) (z : J β Fin D) : | |
| (πΌ g : Cube J, | |
| H (restrictFunction P f, restrictFunction Q z, restrictFunction Q g)) = | |
| πΌ g : Cube {j : J // Q j}, H (restrictFunction P f, restrictFunction Q z, g) := | |
| expect_restrictFunction (Ξ := Bool) Q | |
| (fun g => H (restrictFunction P f, restrictFunction Q z, g)) | |
| simp_rw [hg] | |
| have hz (f : Cube I) : | |
| (πΌ z : J β Fin D, πΌ g : Cube {j : J // Q j}, | |
| H (restrictFunction P f, restrictFunction Q z, g)) = | |
| πΌ z : {j : J // Q j} β Fin D, πΌ g : Cube {j : J // Q j}, | |
| H (restrictFunction P f, z, g) := | |
| expect_restrictFunction (Ξ := Fin D) Q | |
| (fun z => πΌ g : Cube {j : J // Q j}, H (restrictFunction P f, z, g)) | |
| simp_rw [hz] | |
| exact expect_restrictFunction (Ξ := Bool) P | |
| (fun f => πΌ z : {j : J // Q j} β Fin D, πΌ g : Cube {j : J // Q j}, H (f, z, g)) | |
| def restrictedProjection (P : I β Prop) (Q : J β Prop) (Ο : J β I) | |
| (hΟ : β j, Q j β P (Ο j)) : {j : J // Q j} β {i : I // P i} := | |
| fun j => β¨Ο j.val, hΟ j.val j.propertyβ© | |
| theorem restrict_realizedNoise (Q : J β Prop) {D : β} (z : J β Fin D) : | |
| restrictFunction Q (realizedNoise z) = realizedNoise (restrictFunction Q z) := rfl | |
| theorem restrict_thirdQuery (P : I β Prop) (Q : J β Prop) (Ο : J β I) | |
| (hΟ : β j, Q j β P (Ο j)) (f : Cube I) (g ΞΌ : Cube J) : | |
| restrictFunction Q (thirdQuery Ο f g ΞΌ) = | |
| thirdQuery (restrictedProjection P Q Ο hΟ) | |
| (restrictFunction P f) (restrictFunction Q g) (restrictFunction Q ΞΌ) := rfl | |
| /-- The contextual three-query law is the same joint law as sampling directly | |
| on the contextual domains, whenever the contextual projection is defined. -/ | |
| theorem expect_restricted_queries [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] | |
| (P : I β Prop) (Q : J β Prop) [DecidablePred P] [DecidablePred Q] | |
| (Ο : J β I) (hΟ : β j, Q j β P (Ο j)) {D : β} (positive : 0 < D) | |
| (H : Cube {i : I // P i} Γ Cube {j : J // Q j} Γ Cube {j : J // Q j} β β) : | |
| (πΌ t : TestTape I J D, | |
| H (restrictFunction P t.1, restrictFunction Q t.2.2, | |
| restrictFunction Q (thirdQuery Ο t.1 t.2.2 (realizedNoise t.2.1)))) = | |
| πΌ t : TestTape {i : I // P i} {j : J // Q j} D, | |
| H (tapeQueries (restrictedProjection P Q Ο hΟ) t) := by | |
| exact expect_restrictTape P Q positive | |
| (fun t => H (tapeQueries (restrictedProjection P Q Ο hΟ) t)) | |
| def restrictRightTape (Q : J β Prop) {D : β} (t : TestTape I J D) : | |
| TestTape I {j : J // Q j} D := | |
| (t.1, restrictFunction Q t.2.1, restrictFunction Q t.2.2) | |
| theorem expect_restrictRightTape [Fintype I] [DecidableEq I] | |
| [Fintype J] [DecidableEq J] (Q : J β Prop) [DecidablePred Q] | |
| {D : β} (positive : 0 < D) (H : TestTape I {j : J // Q j} D β β) : | |
| (πΌ t : TestTape I J D, H (restrictRightTape Q t)) = | |
| πΌ t : TestTape I {j : J // Q j} D, H t := by | |
| let : Nonempty (Fin D) := β¨β¨0, positiveβ©β© | |
| rw [expect_testTape, expect_testTape] | |
| apply Finset.expect_congr rfl | |
| intro f _ | |
| change (πΌ z : J β Fin D, πΌ g : Cube J, | |
| H (f, restrictFunction Q z, restrictFunction Q g)) = _ | |
| have hg (z : J β Fin D) : | |
| (πΌ g : Cube J, H (f, restrictFunction Q z, restrictFunction Q g)) = | |
| πΌ g : Cube {j : J // Q j}, H (f, restrictFunction Q z, g) := | |
| expect_restrictFunction (Ξ := Bool) Q (fun g => H (f, restrictFunction Q z, g)) | |
| simp_rw [hg] | |
| exact expect_restrictFunction (Ξ := Fin D) Q | |
| (fun z => πΌ g : Cube {j : J // Q j}, H (f, z, g)) | |
| /-- Joint contextual law with the full left domain unchanged. No compatibility | |
| premise is needed: the right projection is simply restricted to valid indices. -/ | |
| theorem expect_rightRestricted_queries [Fintype I] [DecidableEq I] | |
| [Fintype J] [DecidableEq J] (Q : J β Prop) [DecidablePred Q] | |
| (Ο : J β I) {D : β} (positive : 0 < D) | |
| (H : Cube I Γ Cube {j : J // Q j} Γ Cube {j : J // Q j} β β) : | |
| (πΌ t : TestTape I J D, | |
| H (t.1, restrictFunction Q t.2.2, | |
| restrictFunction Q (thirdQuery Ο t.1 t.2.2 (realizedNoise t.2.1)))) = | |
| πΌ t : TestTape I {j : J // Q j} D, | |
| H (tapeQueries (fun j => Ο j.val) t) := by | |
| exact expect_restrictRightTape Q positive | |
| (fun t => H (tapeQueries (fun j => Ο j.val) t)) | |
| end Restriction | |
| end UniqueGamesTheorem.Foundations.Hastad.SourceTape | |
| end | |
| end | |
| section | |
| noncomputable section | |
| namespace UniqueGamesTheorem.Foundations.Hastad.SourceGame | |
| open scoped BigOperators | |
| open Target PCP Games SourceContexts | |
| theorem event_nonempty (F : Formula) (hne : F.clauses β []) : | |
| Nonempty (RandomEvent F) := | |
| β¨(β¨0, List.length_pos_iff.mpr hneβ©, .first)β© | |
| def eventLaw (F : Formula) (hne : F.clauses β []) : | |
| FiniteDistribution (RandomEvent F) := by | |
| let : Nonempty (RandomEvent F) := event_nonempty F hne | |
| exact FiniteDistribution.uniform _ | |
| def visibleQuestion (F : Formula) (e : RandomEvent F) : | |
| Fin F.variables Γ Fin F.clauses.length := | |
| (nameAt (clauseAt F e.1) e.2, e.1) | |
| def baseGame (F : Formula) (hne : F.clauses β []) : | |
| Game (Fin F.variables) (Fin F.clauses.length) Bool ClauseAnswer where | |
| questions := (eventLaw F hne).pushforward (visibleQuestion F) | |
| accepts := baseAccepts F | |
| @[simp] theorem baseGame_accepts (F : Formula) (hne : F.clauses β []) | |
| (v : Fin F.variables) (c : Fin F.clauses.length) (i : Bool) (j : ClauseAnswer) : | |
| (baseGame F hne).accepts v c i j = baseAccepts F v c i j := rfl | |
| theorem eventLaw_probability (F : Formula) (hne : F.clauses β []) | |
| (P : RandomEvent F β Bool) : | |
| (eventLaw F hne).probability P = | |
| (β e : RandomEvent F, if P e then (1 : β) else 0) / | |
| (3 * F.clauses.length : β) := by | |
| classical | |
| simp only [eventLaw, FiniteDistribution.uniform, FiniteDistribution.probability] | |
| simp_rw [div_eq_mul_inv] | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro e _ | |
| cases P e <;> simp [RandomEvent, Fintype.card_prod, card_slot, Nat.mul_comm] | |
| theorem sum_slots (H : Slot β β) : | |
| (β s : Slot, H s) = H .first + H .second + H .third := by | |
| have hu : (Finset.univ : Finset Slot) = {.first, .second, .third} := by | |
| ext s | |
| cases s <;> simp | |
| rw [hu] | |
| simp only [Finset.sum_insert, Finset.mem_insert, Finset.mem_singleton, | |
| reduceCtorEq, or_self, not_false_eq_true, Finset.sum_singleton] | |
| ring | |
| theorem sum_slot_accepts (F : Formula) (alice : AliceStrategy F) | |
| (bob : BobStrategy F) (c : Fin F.clauses.length) : | |
| (β s : Slot, if accepts F alice bob (c,s) then (1 : β) else 0) = | |
| (acceptedSlots (clauseAt F c) (alice c) | |
| (honestAnswer (clauseAt F c) bob) : β) := by | |
| rw [sum_slots] | |
| by_cases hs : localSatisfies (clauseAt F c) (alice c) = true | |
| Β· by_cases hβ : (alice c).first = bob (clauseAt F c)[0].variableIndex <;> | |
| by_cases hβ : (alice c).second = bob (clauseAt F c)[1].variableIndex <;> | |
| by_cases hβ : (alice c).third = bob (clauseAt F c)[2].variableIndex <;> | |
| norm_num [accepts, hs, acceptedSlots, matchingSlots, honestAnswer, answerAt, nameAt, | |
| hβ, hβ, hβ] | |
| Β· simp [accepts, acceptedSlots, hs] | |
| theorem failureCount_eq_sum_map (F : Formula) (bob : BobStrategy F) | |
| (cs : List (Fin F.clauses.length)) : | |
| failureCount F bob cs = | |
| (cs.map (fun c => clauseFailure (clauseAt F c) bob)).sum := by | |
| induction cs with | |
| | nil => rfl | |
| | cons c cs ih => simp only [failureCount, List.map_cons, List.sum_cons, ih] | |
| theorem failureCount_allIndices (F : Formula) (bob : BobStrategy F) : | |
| failureCount F bob (allIndices F) = | |
| β c : Fin F.clauses.length, clauseFailure (clauseAt F c) bob := by | |
| rw [failureCount_eq_sum_map] | |
| unfold allIndices | |
| rw [β List.sum_toFinset _ (List.nodup_finRange _), List.toFinset_finRange] | |
| /-- The local three-slot rejection inequality controls the actual uniform | |
| incidence law, including repeated variable names and repeated clauses. -/ | |
| theorem verifier_probability_plus_failure (F : Formula) (hne : F.clauses β []) | |
| (alice : AliceStrategy F) (bob : BobStrategy F) : | |
| (eventLaw F hne).probability (accepts F alice bob) + | |
| (failureCount F bob (allIndices F) : β) / (3 * F.clauses.length : β) β€ 1 := by | |
| have hm : (0 : β) < (3 * F.clauses.length : β) := by | |
| exact_mod_cast Nat.mul_pos (by decide : 0 < 3) (List.length_pos_iff.mpr hne) | |
| have hlocal (c : Fin F.clauses.length) : | |
| (β s : Slot, if accepts F alice bob (c,s) then (1 : β) else 0) + | |
| (clauseFailure (clauseAt F c) bob : β) β€ 3 := by | |
| rw [sum_slot_accepts] | |
| exact_mod_cast local_rejection_bound (clauseAt F c) (alice c) bob | |
| have hsum := Finset.sum_le_sum (fun c (_ : c β (Finset.univ : Finset _)) => hlocal c) | |
| simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, | |
| Fintype.card_fin, nsmul_eq_mul] at hsum | |
| rw [eventLaw_probability, failureCount_allIndices] | |
| push_cast | |
| push_cast at hm | |
| rw [Fintype.sum_prod_type, β add_div] | |
| apply (div_le_one hm).mpr | |
| simpa only [Nat.cast_mul, Nat.cast_ofNat, mul_comm] using hsum | |
| theorem base_success_le_verifier (F : Formula) (hne : F.clauses β []) | |
| (strategy : Strategy (Fin F.variables) (Fin F.clauses.length) Bool ClauseAnswer) : | |
| (baseGame F hne).success strategy β€ | |
| (eventLaw F hne).probability (accepts F strategy.2 strategy.1) := by | |
| unfold Game.success baseGame | |
| rw [FiniteDistribution.probability_pushforward] | |
| apply FiniteDistribution.probability_mono | |
| intro e he | |
| exact baseAccepts_implies_sampled F e.1 e.2 _ _ he | |
| /-- A concrete clause-count gap supplies the base-game value bound. -/ | |
| theorem base_value_le_of_clause_gap (F : Formula) (hne : F.clauses β []) | |
| (Ξ΄ : β) (hgap : β bob : BobStrategy F, | |
| Ξ΄ * F.clauses.length β€ (failureCount F bob (allIndices F) : β)) : | |
| (baseGame F hne).value β€ 1 - Ξ΄ / 3 := by | |
| apply (Game.value_le_iff _ _).mpr | |
| intro strategy | |
| have hbase := base_success_le_verifier F hne strategy | |
| have hprob := verifier_probability_plus_failure F hne strategy.2 strategy.1 | |
| have hm : (0 : β) < F.clauses.length := | |
| Nat.cast_pos.mpr (List.length_pos_iff.mpr hne) | |
| have hg : Ξ΄ / 3 β€ (failureCount F strategy.1 (allIndices F) : β) / | |
| (3 * F.clauses.length : β) := by | |
| have hden : (0 : β) < (3 * F.clauses.length : β) := by | |
| exact_mod_cast Nat.mul_pos (by decide : 0 < 3) (List.length_pos_iff.mpr hne) | |
| apply (le_div_iffβ hden).mpr | |
| calc | |
| Ξ΄ / 3 * (3 * F.clauses.length : β) = Ξ΄ * F.clauses.length := by push_cast; ring | |
| _ β€ _ := hgap strategy.1 | |
| linarith | |
| theorem pushforward_comp {X Y Z : Type*} [Fintype X] [Fintype Y] [Fintype Z] | |
| (ΞΌ : FiniteDistribution X) (f : X β Y) (g : Y β Z) : | |
| (ΞΌ.pushforward f).pushforward g = ΞΌ.pushforward (g β f) := by | |
| classical | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro z | |
| simp only [FiniteDistribution.pushforward] | |
| calc | |
| _ = β y : Y, β x : X, if f x = y then | |
| (if g y = z then ΞΌ.weight x else 0) else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| by_cases h : g y = z <;> simp [h] | |
| _ = _ := by rw [Finset.sum_comm]; simp | |
| theorem expectation_pushforward {X Y : Type*} [Fintype X] [Fintype Y] | |
| (ΞΌ : FiniteDistribution X) (f : X β Y) (H : Y β β) : | |
| (ΞΌ.pushforward f).expectation H = ΞΌ.expectation (H β f) := by | |
| classical | |
| simp only [FiniteDistribution.expectation, FiniteDistribution.pushforward, | |
| Finset.sum_mul] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| simp [ite_mul] | |
| def repeatedVisible (F : Formula) (u : β) (events : Fin u β RandomEvent F) : | |
| VariableContext F u Γ ClauseContext F u := | |
| (fun t => nameAt (clauseAt F (events t).1) (events t).2, | |
| fun t => (events t).1) | |
| /-- This identifies the repeated game law with the actual uniformly sampled | |
| incidence tuples, retaining all collisions of their visible questions. -/ | |
| theorem repeated_questions (F : Formula) (hne : F.clauses β []) (u : β) : | |
| ((baseGame F hne).repetition u).questions = | |
| ((eventLaw F hne).iid u).pushforward (repeatedVisible F u) := by | |
| change (((eventLaw F hne).pushforward (visibleQuestion F)).iid u).transport | |
| (Game.tupleQuestionEquiv u) = _ | |
| rw [FiniteDistribution.iid_pushforward, β FiniteDistribution.pushforward_equiv, | |
| pushforward_comp] | |
| rfl | |
| theorem repeated_expectation (F : Formula) (hne : F.clauses β []) (u : β) | |
| (H : VariableContext F u Γ ClauseContext F u β β) : | |
| ((baseGame F hne).repetition u).questions.expectation H = | |
| πΌ events : Fin u β RandomEvent F, H (repeatedVisible F u events) := by | |
| let : Nonempty (RandomEvent F) := event_nonempty F hne | |
| rw [repeated_questions, expectation_pushforward] | |
| change ((FiniteDistribution.uniform (RandomEvent F)).iid u).expectation _ = _ | |
| rw [FiniteDistribution.iid_uniform, FiniteDistribution.expectation_uniform, | |
| Fintype.expect_eq_sum_div_card] | |
| rfl | |
| /-- The concrete constructor enumerates clause tuples and slot tuples as | |
| separate lexicographic factors; this is exactly the same question law. -/ | |
| theorem repeated_expectation_split (F : Formula) (hne : F.clauses β []) (u : β) | |
| (H : VariableContext F u Γ ClauseContext F u β β) : | |
| ((baseGame F hne).repetition u).questions.expectation H = | |
| πΌ c : ClauseContext F u, πΌ s : SlotContext u, | |
| H (sampledVariables F c s, c) := by | |
| rw [repeated_expectation] | |
| calc | |
| _ = πΌ p : ClauseContext F u Γ SlotContext u, | |
| H (sampledVariables F p.1 p.2, p.1) := | |
| Fintype.expect_equiv | |
| (Game.tupleQuestionEquiv (Qβ := Fin F.clauses.length) (Qβ := Slot) u) | |
| _ _ (fun _ => rfl) | |
| _ = _ := SourceTape.expect_prod _ | |
| def sourceProjectionGame (F : Formula) (hne : F.clauses β []) (u : β) : | |
| Game (VariableContext F u) (ClauseContext F u) (I u) (J u) := | |
| projectionGame ((baseGame F hne).repetition u).questions | |
| (fun v c => pi F c v) (validJ F) | |
| /-- The projection game has exactly the repeated question law, and its | |
| legal right answers satisfy every coordinate of the original game. -/ | |
| theorem projection_value_le_repetition (F : Formula) (hne : F.clauses β []) | |
| (u : β) : | |
| (sourceProjectionGame F hne u).value β€ ((baseGame F hne).repetition u).value := by | |
| apply (Game.value_le_iff _ _).mpr | |
| intro strategy | |
| have h : (sourceProjectionGame F hne u).success strategy β€ | |
| ((baseGame F hne).repetition u).success strategy := by | |
| apply FiniteDistribution.probability_mono | |
| intro q hq | |
| have hlegal : pi F q.2 q.1 (strategy.2 q.2) = strategy.1 q.1 β§ | |
| validJ F q.2 (strategy.2 q.2) = true := by | |
| simpa only [Game.wins, sourceProjectionGame, projectionGame, | |
| decide_eq_true_eq] using hq | |
| apply (Game.repetition_accepts_iff _ _ _ _ _ _).mpr | |
| intro t | |
| exact projection_implies_coordinate_accepts F q.2 q.1 | |
| (strategy.1 q.1) (strategy.2 q.2) hlegal.2 hlegal.1 t | |
| exact h.trans (Game.success_le_value _ strategy) | |
| theorem source_acceptance_le (F : Formula) (hne : F.clauses β []) (u : β) | |
| (Ξ΅ Ξ΄ : β) (iβ : VariableContext F u β I u) | |
| (tableA : β v, HalfCube (iβ v) β Bool) | |
| (right : β c : ClauseContext F u, ConditionedOracle (validJ F c)) | |
| (hΞ΅ : 0 < Ξ΅) (hΞ΅' : Ξ΅ β€ 1 / 2) (hΞ΄ : 0 β€ Ξ΄) | |
| (hvalue : ((baseGame F hne).repetition u).value β€ 4 * Ξ΅ * Ξ΄ ^ 2) : | |
| (πΌ events : Fin u β RandomEvent F, | |
| questionAcceptance Ξ΅ (fun v c => pi F c v) | |
| (fun v => foldedAnswer (iβ v) (tableA v)) (fun c => (right c).answer) | |
| (repeatedVisible F u events)) β€ (1 + Ξ΄) / 2 := by | |
| rw [β repeated_expectation F hne u] | |
| exact conditionedOracle_acceptance_bound _ Ξ΅ Ξ΄ _ (validJ F) iβ tableA | |
| (fun _ => default) right hΞ΅ hΞ΅' hΞ΄ | |
| ((projection_value_le_repetition F hne u).trans hvalue) | |
| theorem source_acceptance_le_split (F : Formula) (hne : F.clauses β []) (u : β) | |
| (Ξ΅ Ξ΄ : β) (iβ : VariableContext F u β I u) | |
| (tableA : β v, HalfCube (iβ v) β Bool) | |
| (right : β c : ClauseContext F u, ConditionedOracle (validJ F c)) | |
| (hΞ΅ : 0 < Ξ΅) (hΞ΅' : Ξ΅ β€ 1 / 2) (hΞ΄ : 0 β€ Ξ΄) | |
| (hvalue : ((baseGame F hne).repetition u).value β€ 4 * Ξ΅ * Ξ΄ ^ 2) : | |
| (πΌ c : ClauseContext F u, πΌ s : SlotContext u, | |
| testAcceptance Ξ΅ (pi F c (sampledVariables F c s)) | |
| (foldedAnswer (iβ (sampledVariables F c s)) (tableA (sampledVariables F c s))) | |
| (right c).answer) β€ (1 + Ξ΄) / 2 := by | |
| have h := conditionedOracle_acceptance_bound | |
| ((baseGame F hne).repetition u).questions Ξ΅ Ξ΄ (fun v c => pi F c v) | |
| (validJ F) iβ tableA (fun _ => default) right hΞ΅ hΞ΅' hΞ΄ | |
| ((projection_value_le_repetition F hne u).trans hvalue) | |
| rw [repeated_expectation_split] at h | |
| exact h | |
| end UniqueGamesTheorem.Foundations.Hastad.SourceGame | |
| end | |
| end | |
| end OAI | |