Download data/lean/OAI/Computability/MaxCut/Encoding/PrivateFourier.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 41.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Encoding/PrivateFourier.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MaxCut/Encoding/PrivateFourier.lean
-
curl -L -o PrivateFourier.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Encoding/PrivateFourier.lean
41.4 kB
| import Mathlib | |
| import OAI.Computability.MaxCut.PCP.DistributionMaps | |
| import OAI.Computability.MaxCut.PCP.MatrixParityRow | |
| import OAI.Computability.MaxCut.Games.MatrixNoise | |
| namespace OAI | |
| noncomputable section | |
| namespace MaxCutGames.Decoder.PrivateFourier | |
| open MaxCutGames.Fourier.MatrixCharacters | |
| open MaxCutGames.Fourier.MatrixFourier | |
| open MaxCutGames.Fourier.MatrixParity | |
| open MaxCutGames.Fourier.MatrixParityRow | |
| open scoped BigOperators Classical | |
| section Signs | |
| /-- A real-valued binary character, with the uniform Fourier normalization. -/ | |
| def sign (a : F2) : β := (binarySign a).re | |
| @[simp] theorem sign_zero : sign 0 = 1 := by simp [sign] | |
| @[simp] theorem sign_one : sign 1 = -1 := by simp [sign] | |
| theorem sign_sq (a : F2) : sign a ^ 2 = 1 := by | |
| rcases Integration.BinaryLinear.scalar_cases a with rfl | rfl <;> simp | |
| @[simp] theorem sign_abs (a : F2) : |sign a| = 1 := by | |
| rcases Integration.BinaryLinear.scalar_cases a with rfl | rfl <;> simp | |
| theorem sign_add (a b : F2) : sign (a + b) = sign a * sign b := by | |
| simp [sign, binarySign_add, Complex.mul_re] | |
| theorem sign_add_one (a : F2) : sign (a + 1) = -sign a := by | |
| rw [sign_add, sign_one] | |
| ring | |
| end Signs | |
| section CharacterAverages | |
| variable {H K : Type*} [AddCommGroup H] [Module F2 H] | |
| [AddCommGroup K] [Module F2 K] | |
| theorem binary_neg_eq_self (x : K) : -x = x := by | |
| have htwo : (1 + 1 : F2) = 0 := by decide | |
| have hh := congrArg (fun a : F2 => a β’ x) htwo | |
| exact neg_eq_iff_add_eq_zero.mpr | |
| (by simpa only [add_smul, one_smul, zero_smul] using hh) | |
| theorem binary_add_eq_zero_iff (x y : K) : x + y = 0 β x = y := by | |
| rw [add_eq_zero_iff_eq_neg, binary_neg_eq_self] | |
| theorem average_sign_dual [Fintype (K ββ[F2] F2)] (x : K) : | |
| (πΌ Ο : K ββ[F2] F2, sign (Ο x)) = if x = 0 then 1 else 0 := by | |
| have h := congrArg Complex.re | |
| (MaxCutGames.Fourier.MatrixNoise.average_evaluationCharacter x) | |
| simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re, sign] using h | |
| theorem average_sign_primal [Fintype H] (Ο : H ββ[F2] F2) : | |
| (πΌ h : H, sign (Ο h)) = if Ο = 0 then 1 else 0 := by | |
| have h := congrArg Complex.re (expect_linearFunctionalCharacter Ο) | |
| simpa only [Complex.re_expect, apply_ite, Complex.one_re, Complex.zero_re, | |
| linearFunctionalCharacter_apply, sign] using h | |
| /-- Exact character expansion of equality in the actual output space. -/ | |
| theorem average_sign_equality [Fintype (K ββ[F2] F2)] (x y : K) : | |
| (πΌ Ο : K ββ[F2] F2, sign (Ο x) * sign (Ο y)) = | |
| if x = y then 1 else 0 := by | |
| simp_rw [β sign_add, β map_add] | |
| rw [average_sign_dual, binary_add_eq_zero_iff] | |
| /-- The ambient uniform character has trivial restriction to `H` with exactly | |
| the reciprocal cardinality of `H`. No conditioning on the private character | |
| is substituted for the real experiment. -/ | |
| theorem trivial_restriction_probability [Fintype H] [Fintype (K ββ[F2] F2)] | |
| (ΞΉ : H ββ[F2] K) (hΞΉ : Function.Injective ΞΉ) : | |
| (πΌ Ο : K ββ[F2] F2, if Ο.comp ΞΉ = 0 then (1 : β) else 0) = | |
| 1 / (Fintype.card H : β) := by | |
| calc | |
| _ = πΌ Ο : K ββ[F2] F2, πΌ h : H, sign (Ο (ΞΉ h)) := by | |
| apply Finset.expect_congr rfl | |
| intro Ο _ | |
| exact (average_sign_primal (Ο.comp ΞΉ)).symm | |
| _ = πΌ h : H, πΌ Ο : K ββ[F2] F2, sign (Ο (ΞΉ h)) := | |
| Finset.expect_comm _ _ _ | |
| _ = πΌ h : H, if h = 0 then (1 : β) else 0 := by | |
| apply Finset.expect_congr rfl | |
| intro h _ | |
| rw [average_sign_dual] | |
| have heq : ΞΉ h = 0 β h = 0 := by | |
| rw [β map_zero ΞΉ] | |
| exact hΞΉ.eq_iff | |
| rw [heq] | |
| _ = _ := by simp [] | |
| theorem trivial_restriction_probability_pow [Fintype H] | |
| [FiniteDimensional F2 H] [Fintype (K ββ[F2] F2)] | |
| (ΞΉ : H ββ[F2] K) (hΞΉ : Function.Injective ΞΉ) : | |
| (πΌ Ο : K ββ[F2] F2, if Ο.comp ΞΉ = 0 then (1 : β) else 0) = | |
| 1 / (2 : β) ^ Module.finrank F2 H := by | |
| rw [trivial_restriction_probability ΞΉ hΞΉ] | |
| have hc : Fintype.card H = 2 ^ Module.finrank F2 H := by | |
| simpa [F2, Integration.BinaryLinear.F2, ZMod.card] using | |
| Module.card_fintype (Module.finBasis F2 H) | |
| rw [hc] | |
| norm_cast | |
| end CharacterAverages | |
| section ActualFourier | |
| variable {E H K : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] | |
| variable [AddCommGroup K] [Module F2 K] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| /-- The private sign function, formed from the table on one visible row fiber. -/ | |
| def tableSign (F : (E ββ[F2] H) β K) (Ο : K ββ[F2] F2) | |
| (N : E ββ[F2] H) : β := sign (Ο (F N)) | |
| /-- The actual probability assigned to a reverse-map frequency. -/ | |
| def frequencyWeight (f : (E ββ[F2] H) β β) (Ξ¦ : H ββ[F2] E) : β := | |
| linearCoeff f Ξ¦ ^ 2 | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (H ββ[F2] E)] in | |
| theorem frequencyWeight_nonneg (f : (E ββ[F2] H) β β) (Ξ¦ : H ββ[F2] E) : | |
| 0 β€ frequencyWeight f Ξ¦ := sq_nonneg _ | |
| /-- Squared Fourier coefficients of the private sign form a probability law. -/ | |
| theorem tableSign_frequencyWeight_sum (F : (E ββ[F2] H) β K) | |
| (Ο : K ββ[F2] F2) : | |
| β Ξ¦ : H ββ[F2] E, frequencyWeight (tableSign F Ο) Ξ¦ = 1 := by | |
| simp only [frequencyWeight, linear_parseval, tableSign, sign_sq] | |
| exact Fintype.expect_const 1 | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] in | |
| theorem tableSign_antifold (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (Ο : E ββ[F2] F2) (Ο : K ββ[F2] F2) (h : H) | |
| (folded : β N, F (N + Ο.smulRight h) = F N + ΞΉ h) | |
| (hΟ : Ο (ΞΉ h) = 1) : | |
| β N, tableSign F Ο (N + Ο.smulRight h) = -tableSign F Ο N := by | |
| intro N | |
| simp only [tableSign, folded, map_add, hΟ, sign_add_one] | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (H ββ[F2] E)] in | |
| /-- Translation of the input multiplies a coefficient by its character. -/ | |
| theorem linearCoeff_translate (f : (E ββ[F2] H) β β) | |
| (D : E ββ[F2] H) (Ξ¦ : H ββ[F2] E) : | |
| linearCoeff (fun N => f (N + D)) Ξ¦ = | |
| linearCoeff f Ξ¦ * (linearTraceCharacter Ξ¦ D).re := by | |
| have hself : D + D = 0 := | |
| (linearMap_add_eq_zero_iff D D).2 rfl | |
| have hchange := Fintype.expect_equiv (Equiv.addRight D) | |
| (fun N => f (N + D) * (linearTraceCharacter Ξ¦ N).re) | |
| (fun N => f N * (linearTraceCharacter Ξ¦ (N + D)).re) | |
| (fun N => by simp only [Equiv.coe_addRight, add_assoc, hself, add_zero]) | |
| unfold linearCoeff | |
| rw [hchange] | |
| simp only [traceCharacter_re_add, β mul_assoc] | |
| exact (Finset.expect_mul _ _ _).symm | |
| omit [FiniteDimensional F2 E] [Fintype (H ββ[F2] E)] in | |
| /-- Anti-folding forces every positive-mass frequency to return first bit one. -/ | |
| theorem positive_frequency_first_bit (f : (E ββ[F2] H) β β) | |
| (Ο : E ββ[F2] F2) (h : H) (Ξ¦ : H ββ[F2] E) | |
| (folded : β N, f (N + Ο.smulRight h) = -f N) | |
| (positive : 0 < frequencyWeight f Ξ¦) : Ο (Ξ¦ h) = 1 := by | |
| have hcoeff : linearCoeff f Ξ¦ β 0 := by | |
| intro hz | |
| simp [frequencyWeight, hz] at positive | |
| have heq := linearCoeff_translate f (Ο.smulRight h) Ξ¦ | |
| have hneg : linearCoeff (fun N => f (N + Ο.smulRight h)) Ξ¦ = | |
| -linearCoeff f Ξ¦ := by | |
| simp only [linearCoeff, folded, neg_mul] | |
| simp [Fintype.expect_eq_sum_div_card] | |
| rw [hneg] at heq | |
| have hchar : (linearTraceCharacter Ξ¦ (Ο.smulRight h)).re = sign (Ο (Ξ¦ h)) := by | |
| simp only [linearTraceCharacter_apply, linearTracePair, trace_smulRight_comp, sign] | |
| rw [hchar] at heq | |
| rcases Integration.BinaryLinear.scalar_cases (Ο (Ξ¦ h)) with hz | hone | |
| Β· rw [hz, sign_zero, mul_one] at heq | |
| exact False.elim (hcoeff (by linarith)) | |
| Β· exact hone | |
| end ActualFourier | |
| section AffineSlice | |
| variable {E H V : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] | |
| variable [AddCommGroup V] [Module F2 V] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (V ββ[F2] H)] | |
| /-- Frequencies in the affine target's annihilator coset. With `q = Q.mkQ`, | |
| this is exactly `ΞΈ + Hom(H,Q)` in the ambient reverse-map space. -/ | |
| def frequencyCoset (q : E ββ[F2] V) (ΞΈ : H ββ[F2] E) : | |
| Finset (H ββ[F2] E) := Finset.univ.filter fun Ξ¦ => q.comp (Ξ¦ + ΞΈ) = 0 | |
| /-- Correlation on a genuine affine slice. `Nβ` is retained: its phase cannot | |
| be discarded when the witness has a nonzero affine intercept. -/ | |
| def sliceCorrelation (q : E ββ[F2] V) (Nβ : E ββ[F2] H) | |
| (f : (E ββ[F2] H) β β) (ΞΈ : H ββ[F2] E) : β := | |
| πΌ A : V ββ[F2] H, | |
| f (Nβ + A.comp q) * (linearTraceCharacter ΞΈ (Nβ + A.comp q)).re | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] in | |
| theorem traceCharacter_re_mul (Ξ¦ ΞΈ : H ββ[F2] E) (N : E ββ[F2] H) : | |
| (linearTraceCharacter Ξ¦ N).re * (linearTraceCharacter ΞΈ N).re = | |
| (linearTraceCharacter (Ξ¦ + ΞΈ) N).re := by | |
| rw [linearTraceCharacter_add, AddChar.add_apply, Complex.mul_re] | |
| simp [linearTraceCharacter_apply] | |
| /-- The exact Fourier coset expansion of the affine conditional correlation. -/ | |
| theorem sliceCorrelation_eq_coset (q : E ββ[F2] V) (Nβ : E ββ[F2] H) | |
| (f : (E ββ[F2] H) β β) (ΞΈ : H ββ[F2] E) : | |
| sliceCorrelation q Nβ f ΞΈ = | |
| β Ξ¦ β frequencyCoset q ΞΈ, | |
| linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ).re := by | |
| unfold sliceCorrelation | |
| calc | |
| _ = πΌ A : V ββ[F2] H, β Ξ¦ : H ββ[F2] E, | |
| linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) (Nβ + A.comp q)).re := by | |
| apply Finset.expect_congr rfl | |
| intro A _ | |
| rw [β linear_fourier_inversion f (Nβ + A.comp q), Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro Ξ¦ _ | |
| rw [mul_assoc, traceCharacter_re_mul] | |
| _ = β Ξ¦ : H ββ[F2] E, if q.comp (Ξ¦ + ΞΈ) = 0 then | |
| linearCoeff f Ξ¦ * (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ).re else 0 := by | |
| rw [Finset.expect_sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro Ξ¦ _ | |
| simp only [traceCharacter_re_add, β mul_assoc] | |
| rw [β Finset.mul_expect, row_character_average] | |
| split <;> simp | |
| _ = _ := by simp [frequencyCoset, Finset.sum_filter] | |
| /-- Cauchy--Schwarz bounds an affine correlation by the actual Fourier mass | |
| in its target coset; no spectral mass is assumed. -/ | |
| theorem sliceCorrelation_sq_le_coset_mass (q : E ββ[F2] V) | |
| (Nβ : E ββ[F2] H) (f : (E ββ[F2] H) β β) (ΞΈ : H ββ[F2] E) : | |
| sliceCorrelation q Nβ f ΞΈ ^ 2 β€ | |
| (frequencyCoset q ΞΈ).card * | |
| β Ξ¦ β frequencyCoset q ΞΈ, frequencyWeight f Ξ¦ := by | |
| rw [sliceCorrelation_eq_coset] | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq (frequencyCoset q ΞΈ) | |
| (linearCoeff f) (fun Ξ¦ => (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ).re) | |
| have hs : β Ξ¦ : H ββ[F2] E, | |
| (linearTraceCharacter (Ξ¦ + ΞΈ) Nβ).re ^ 2 = 1 := by | |
| intro Ξ¦ | |
| exact sign_sq _ | |
| simpa only [hs, Finset.sum_const, nsmul_eq_mul, mul_one, one_mul, | |
| frequencyWeight, mul_comm] using hcs | |
| end AffineSlice | |
| section AffineEquality | |
| variable {E H K V : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] | |
| variable [AddCommGroup K] [Module F2 K] [AddCommGroup V] [Module F2 V] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (V ββ[F2] H)] [Fintype (K ββ[F2] F2)] | |
| omit [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] in | |
| /-- The pure-tensor target character is literally evaluation at `z`. -/ | |
| theorem target_character (Ο : H ββ[F2] F2) (z : E) (N : E ββ[F2] H) : | |
| (linearTraceCharacter (Ο.smulRight z) N).re = sign (Ο (N z)) := by | |
| simp only [linearTraceCharacter_apply, sign] | |
| congr 2 | |
| rw [linearTracePair_swap] | |
| exact trace_smulRight_comp Ο z N | |
| omit [FiniteDimensional F2 V] in | |
| omit [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] in | |
| /-- Affine target equality expands into the correlations with the intercept | |
| phase `sign (Ο b)`. In the projected experiment `b = Mβ z + u`. -/ | |
| theorem affine_equality_character_expansion (q : E ββ[F2] V) | |
| (Nβ : E ββ[F2] H) (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (z : E) (b : K) : | |
| (πΌ A : V ββ[F2] H, | |
| if F (Nβ + A.comp q) = b + ΞΉ ((Nβ + A.comp q) z) then (1 : β) else 0) = | |
| πΌ Ο : K ββ[F2] F2, sign (Ο b) * | |
| sliceCorrelation q Nβ (tableSign F Ο) ((Ο.comp ΞΉ).smulRight z) := by | |
| calc | |
| _ = πΌ A : V ββ[F2] H, πΌ Ο : K ββ[F2] F2, | |
| sign (Ο (F (Nβ + A.comp q))) * | |
| sign (Ο (b + ΞΉ ((Nβ + A.comp q) z))) := by | |
| apply Finset.expect_congr rfl | |
| intro A _ | |
| exact (average_sign_equality _ _).symm | |
| _ = πΌ Ο : K ββ[F2] F2, πΌ A : V ββ[F2] H, | |
| sign (Ο (F (Nβ + A.comp q))) * | |
| sign (Ο (b + ΞΉ ((Nβ + A.comp q) z))) := Finset.expect_comm _ _ _ | |
| _ = _ := by | |
| apply Finset.expect_congr rfl | |
| intro Ο _ | |
| unfold sliceCorrelation | |
| rw [Finset.mul_expect] | |
| apply Finset.expect_congr rfl | |
| intro A _ | |
| simp only [map_add, sign_add, target_character, tableSign, LinearMap.comp_apply] | |
| ring | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] [FiniteDimensional F2 V] [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] [Fintype (K ββ[F2] F2)] in | |
| /-- Every slice correlation has absolute value at most one. -/ | |
| theorem sliceCorrelation_tableSign_abs_le_one (q : E ββ[F2] V) | |
| (Nβ : E ββ[F2] H) (F : (E ββ[F2] H) β K) | |
| (Ο : K ββ[F2] F2) (ΞΈ : H ββ[F2] E) : | |
| |sliceCorrelation q Nβ (tableSign F Ο) ΞΈ| β€ 1 := by | |
| unfold sliceCorrelation | |
| calc | |
| _ β€ πΌ A : V ββ[F2] H, | |
| |tableSign F Ο (Nβ + A.comp q) * | |
| (linearTraceCharacter ΞΈ (Nβ + A.comp q)).re| := Finset.abs_expect_le _ _ | |
| _ = 1 := by | |
| have hp (N : E ββ[F2] H) : |(linearTraceCharacter ΞΈ N).re| = 1 := sign_abs _ | |
| simp only [abs_mul, tableSign, sign_abs, hp, mul_one] | |
| exact Fintype.expect_const 1 | |
| omit [FiniteDimensional F2 V] in | |
| omit [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] in | |
| /-- Dropping the unit intercept phase can only increase the average absolute | |
| correlation; the hypothesis is the actual affine-slice agreement probability. -/ | |
| theorem agreement_le_average_abs_correlation (q : E ββ[F2] V) | |
| (Nβ : E ββ[F2] H) (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (z : E) (b : K) : | |
| (πΌ A : V ββ[F2] H, | |
| if F (Nβ + A.comp q) = b + ΞΉ ((Nβ + A.comp q) z) then (1 : β) else 0) β€ | |
| πΌ Ο : K ββ[F2] F2, | |
| |sliceCorrelation q Nβ (tableSign F Ο) ((Ο.comp ΞΉ).smulRight z)| := by | |
| rw [affine_equality_character_expansion] | |
| apply Finset.expect_le_expect | |
| intro Ο _ | |
| calc | |
| _ β€ |sign (Ο b) * | |
| sliceCorrelation q Nβ (tableSign F Ο) ((Ο.comp ΞΉ).smulRight z)| := le_abs_self _ | |
| _ = _ := by rw [abs_mul, sign_abs, one_mul] | |
| end AffineEquality | |
| section CosetCardinality | |
| variable {E H : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (H ββ[F2] E)] | |
| /-- The exact number of frequencies in the affine coset. Translation does not | |
| alter the annihilator cardinality, including when the target is nonzero. -/ | |
| theorem frequencyCoset_card (Q : Submodule F2 E) [Fintype (H ββ[F2] Q)] | |
| (ΞΈ : H ββ[F2] E) : | |
| (frequencyCoset Q.mkQ ΞΈ).card = | |
| 2 ^ (Module.finrank F2 H * Module.finrank F2 Q) := by | |
| classical | |
| rw [frequencyCoset, β Fintype.card_subtype] | |
| calc | |
| Fintype.card {Ξ¦ : H ββ[F2] E // Q.mkQ.comp (Ξ¦ + ΞΈ) = 0} = | |
| Fintype.card {Ξ¦ : H ββ[F2] E // Q.mkQ.comp Ξ¦ = 0} := | |
| Fintype.card_congr (Equiv.subtypeEquiv (Equiv.addRight ΞΈ) (fun _ => Iff.rfl)) | |
| _ = Fintype.card (H ββ[F2] Q) := | |
| MaxCutGames.Fourier.MatrixRestrictions.quotientKernel_card Q | |
| _ = _ := card_linearMaps | |
| theorem frequencyCoset_card_le (Q : Submodule F2 E) [Fintype (H ββ[F2] Q)] | |
| (ΞΈ : H ββ[F2] E) (β r : β) | |
| (hH : Module.finrank F2 H β€ β) (hQ : Module.finrank F2 Q β€ r) : | |
| (frequencyCoset Q.mkQ ΞΈ).card β€ 2 ^ (β * r) := by | |
| rw [frequencyCoset_card] | |
| exact Nat.pow_le_pow_right (by decide : 0 < 2) (Nat.mul_le_mul hH hQ) | |
| end CosetCardinality | |
| section Averaging | |
| variable {SigmaChar : Type*} [Fintype SigmaChar] [Nonempty SigmaChar] | |
| omit [Nonempty SigmaChar] in | |
| /-- Discarding a set of characters costs at most its actual uniform mass. -/ | |
| theorem remove_bad_characters (C : SigmaChar β β) (good : SigmaChar β Prop) | |
| (a b : β) (hC : β Ο, |C Ο| β€ 1) | |
| (hcorrelation : a β€ πΌ Ο, |C Ο|) | |
| (hbad : (πΌ Ο, if good Ο then (0 : β) else 1) β€ b) : | |
| a - b β€ πΌ Ο, if good Ο then |C Ο| else 0 := by | |
| classical | |
| have hp : (πΌ Ο, |C Ο|) β€ | |
| (πΌ Ο, if good Ο then |C Ο| else 0) + | |
| (πΌ Ο, if good Ο then (0 : β) else 1) := by | |
| rw [β Finset.expect_add_distrib] | |
| apply Finset.expect_le_expect | |
| intro Ο _ | |
| by_cases hg : good Ο | |
| Β· simp [hg] | |
| Β· simpa [hg] using hC Ο | |
| linarith | |
| /-- The second Cauchy--Schwarz step in private decoding. The first step is | |
| `sliceCorrelation_sq_le_coset_mass`; the mass is the actual sampled Fourier | |
| mass and `good` selects nontrivial output characters. -/ | |
| theorem average_coset_mass_lower (C mass : SigmaChar β β) (good : SigmaChar β Prop) | |
| (N c : β) (hN : 0 < N) (hc : 0 β€ c) | |
| (hcorrelation : c β€ πΌ Ο, if good Ο then |C Ο| else 0) | |
| (hpoint : β Ο, good Ο β C Ο ^ 2 β€ N * mass Ο) : | |
| c ^ 2 / N β€ πΌ Ο, if good Ο then mass Ο else 0 := by | |
| classical | |
| let d : SigmaChar β β := fun Ο => if good Ο then |C Ο| else 0 | |
| have hj := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ d (fun _ => (1 : β)) | |
| simp only [mul_one, one_pow, Fintype.expect_const] at hj | |
| have hp : (πΌ Ο, d Ο ^ 2) β€ N * (πΌ Ο, if good Ο then mass Ο else 0) := by | |
| rw [Finset.mul_expect] | |
| apply Finset.expect_le_expect | |
| intro Ο _ | |
| by_cases hg : good Ο | |
| Β· simpa [d, hg, sq_abs] using hpoint Ο hg | |
| Β· simp [d, hg] | |
| have hs : c ^ 2 β€ (πΌ Ο, d Ο) ^ 2 := by | |
| have hd : c β€ πΌ Ο, d Ο := hcorrelation | |
| nlinarith | |
| apply (div_le_iffβ hN).2 | |
| nlinarith | |
| end Averaging | |
| section Contraction | |
| variable {E H : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup H] [Module F2 H] | |
| /-- A frequency in the target coset contracts into `z + Q`. -/ | |
| theorem contraction_mem_target_coset (Q : Submodule F2 E) | |
| (Ο : H ββ[F2] F2) (z : E) (Ξ¦ : H ββ[F2] E) (h : H) | |
| (hΟ : Ο h = 1) (hcoset : Q.mkQ.comp (Ξ¦ + Ο.smulRight z) = 0) : | |
| Ξ¦ h - z β Q := by | |
| have hq := LinearMap.congr_fun hcoset h | |
| simp only [LinearMap.comp_apply, LinearMap.add_apply, LinearMap.smulRight_apply, | |
| hΟ, one_smul, LinearMap.zero_apply] at hq | |
| have hmem : Ξ¦ h + z β Q := by | |
| change Q.mkQ (Ξ¦ h + z) = 0 at hq | |
| exact (Submodule.Quotient.mk_eq_zero Q).mp hq | |
| have hz : -z = z := by | |
| have htwo : (1 + 1 : F2) = 0 := by decide | |
| have hzz : z + z = 0 := by | |
| have hh := congrArg (fun a : F2 => a β’ z) htwo | |
| simpa only [add_smul, one_smul, zero_smul] using hh | |
| exact neg_eq_iff_add_eq_zero.mpr hzz | |
| simpa only [sub_eq_add_neg, hz] using hmem | |
| end Contraction | |
| variable {U O Ξ© : Type*} [Fintype Ξ©] | |
| /-- If the returned projected answer has a preimage in the candidate set, the | |
| uniform, independently sampled candidate finds a preimage with this probability. -/ | |
| theorem uniform_preimage_probability (s : Finset U) (Ο : U β O) (b : O) | |
| (preimage : β u β s, Ο u = b) : | |
| 1 / (s.card : β) β€ πΌ u β s, if Ο u = b then (1 : β) else 0 := by | |
| classical | |
| obtain β¨u, hu, hΟβ© := preimage | |
| have hsum : (1 : β) β€ β v β s, if Ο v = b then (1 : β) else 0 := by | |
| have hnonneg : β v β s, (0 : β) β€ if Ο v = b then 1 else 0 := by | |
| intro v _ | |
| split <;> norm_num | |
| have h := Finset.single_le_sum hnonneg hu | |
| simpa only [hΟ, ite_true] using h | |
| rw [Finset.expect_eq_sum_div_card] | |
| exact div_le_div_of_nonneg_right hsum (Nat.cast_nonneg _) | |
| /-- An explicit product sampling law: the left strategy samples uniformly from | |
| `s`, independently of the right strategy's private sample. Only positive-mass | |
| good samples need a preimage; no private Fourier information is passed left. -/ | |
| theorem independent_agreement_lower (s : Finset U) (Ο : U β O) | |
| (answer : Ξ© β O) (weight : Ξ© β β) (good : Ξ© β Prop) | |
| (hweight : β Ο, 0 β€ weight Ο) | |
| (preimage : β Ο, good Ο β 0 < weight Ο β β u β s, Ο u = answer Ο) : | |
| (β Ο, if good Ο then weight Ο else 0) / (s.card : β) β€ | |
| β Ο, weight Ο * (πΌ u β s, if Ο u = answer Ο then (1 : β) else 0) := by | |
| classical | |
| rw [Finset.sum_div] | |
| apply Finset.sum_le_sum | |
| intro Ο _ | |
| have havg : 0 β€ πΌ u β s, if Ο u = answer Ο then (1 : β) else 0 := | |
| Finset.expect_nonneg fun _ _ => by positivity | |
| by_cases hg : good Ο | |
| Β· simp only [hg, ite_true] | |
| by_cases hw : 0 < weight Ο | |
| Β· have hb := uniform_preimage_probability s Ο (answer Ο) (preimage Ο hg hw) | |
| have := mul_le_mul_of_nonneg_left hb (hweight Ο) | |
| simpa only [div_eq_mul_inv, one_mul] using this | |
| Β· have hz : weight Ο = 0 := le_antisymm (le_of_not_gt hw) (hweight Ο) | |
| simp [hz] | |
| Β· simp only [hg, ite_false, zero_div] | |
| exact mul_nonneg (hweight Ο) havg | |
| end MaxCutGames.Decoder.PrivateFourier | |
| /-! | |
| # Actual private response laws for v2 Fourier decoding | |
| The right response law has only its row-fiber table, the inclusion of its hidden | |
| kernel, a first-bit map, and an actual fallback answer as arguments. In | |
| particular it has no column slice or witness. Zero-mass invalid frequencies | |
| are repaired to the fallback so that the response type always consists of | |
| actual answers. Witness data occur only in the success analysis. | |
| -/ | |
| namespace MaxCutGames.Decoder.PrivateStrategy | |
| attribute [local instance] Classical.propDecidable | |
| open PrivateFourier | |
| open MaxCutGames.Fourier.MatrixCharacters | |
| open MaxCutGames.Foundations.Games | |
| open scoped BigOperators Classical | |
| section Candidates | |
| variable {E E' : Type*} [AddCommGroup E] [Module F2 E] | |
| [AddCommGroup E'] [Module F2 E'] [Fintype E] | |
| def candidates (Z : Submodule F2 E) (z : E) (Ο : E ββ[F2] F2) : Finset E := | |
| Finset.univ.filter fun v => v - z β Z β§ Ο v = 1 | |
| theorem mem_candidates (Z : Submodule F2 E) (z v : E) (Ο : E ββ[F2] F2) : | |
| v β candidates Z z Ο β v - z β Z β§ Ο v = 1 := by simp [candidates] | |
| theorem candidates_nonempty (Z : Submodule F2 E) (z : E) | |
| (Ο : E ββ[F2] F2) (hz : Ο z = 1) : (candidates Z z Ο).Nonempty := by | |
| exact β¨z, (mem_candidates Z z z Ο).2 β¨by simp, hzβ©β© | |
| theorem candidates_card_le (Z : Submodule F2 E) [Fintype Z] (z : E) | |
| (Ο : E ββ[F2] F2) : (candidates Z z Ο).card β€ Fintype.card Z := by | |
| let f : {v // v β candidates Z z Ο} β Z := fun v => | |
| β¨v.1 - z, ((mem_candidates Z z v.1 Ο).1 v.2).1β© | |
| have hf : Function.Injective f := by | |
| intro x y h | |
| apply Subtype.ext | |
| have he := congrArg Subtype.val h | |
| change x.val - z = y.val - z at he | |
| exact sub_left_injective he | |
| simpa using Fintype.card_le_of_injective f hf | |
| theorem candidates_card_le_pow (Z : Submodule F2 E) [Fintype Z] | |
| [FiniteDimensional F2 Z] (z : E) (Ο : E ββ[F2] F2) | |
| (r : β) (hr : Module.finrank F2 Z β€ r) : | |
| (candidates Z z Ο).card β€ 2 ^ r := by | |
| have hc : Fintype.card Z = 2 ^ Module.finrank F2 Z := by | |
| simpa [F2, MaxCutGames.Integration.BinaryLinear.F2, ZMod.card] using | |
| Module.card_fintype (Module.finBasis F2 Z) | |
| calc | |
| _ β€ Fintype.card Z := candidates_card_le Z z Ο | |
| _ = 2 ^ Module.finrank F2 Z := hc | |
| _ β€ 2 ^ r := Nat.pow_le_pow_right (by decide : 0 < 2) hr | |
| /-- First-bit preservation converts a projected coset member into an actual | |
| answer in the left candidate set. -/ | |
| theorem candidate_preimage (Z : Submodule F2 E) (z : E) | |
| (Ο : E ββ[F2] E') (Ο : E ββ[F2] F2) (Ο' : E' ββ[F2] F2) | |
| (hΟ : Ο'.comp Ο = Ο) (y : E') (hy : y - Ο z β Z.map Ο) | |
| (hybit : Ο' y = 1) : β v β candidates Z z Ο, Ο v = y := by | |
| obtain β¨w, hw, hwΟβ© := Submodule.mem_map.mp hy | |
| have heq : Ο (z + w) = y := by | |
| rw [map_add, hwΟ] | |
| rw [add_comm, sub_add_cancel] | |
| refine β¨z + w, (mem_candidates Z z (z + w) Ο).2 β¨?_, ?_β©, heqβ© | |
| Β· simpa only [add_sub_cancel_left] using hw | |
| Β· rw [β hΟ, LinearMap.comp_apply, heq, hybit] | |
| end Candidates | |
| section RightRule | |
| variable {E H K : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [AddCommGroup H] [Module F2 H] | |
| variable [AddCommGroup K] [Module F2 K] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (K ββ[F2] F2)] | |
| omit [FiniteDimensional F2 H] in | |
| theorem exists_unit (Ο : H ββ[F2] F2) (hne : Ο β 0) : β h, Ο h = 1 := by | |
| have hn : β h, Ο h β 0 := by | |
| by_contra hh | |
| apply hne | |
| ext h | |
| by_contra hh' | |
| exact hh β¨h, hh'β© | |
| obtain β¨h, hhβ© := hn | |
| exact β¨h, (MaxCutGames.Integration.BinaryLinear.scalar_cases _).resolve_left hhβ© | |
| def chooseUnit (Ο : H ββ[F2] F2) (hne : Ο β 0) : H := | |
| Classical.choose (exists_unit Ο hne) | |
| omit [FiniteDimensional F2 H] in | |
| theorem chooseUnit_spec (Ο : H ββ[F2] F2) (hne : Ο β 0) : | |
| Ο (chooseUnit Ο hne) = 1 := Classical.choose_spec (exists_unit Ο hne) | |
| abbrev ActualAnswer (Ο : E ββ[F2] F2) := {v : E // Ο v = 1} | |
| /-- The uniform output character followed by its actual Fourier frequency. -/ | |
| def privateSeedLaw (F : (E ββ[F2] H) β K) : | |
| FiniteDistribution ((K ββ[F2] F2) Γ (H ββ[F2] E)) where | |
| weight p := frequencyWeight (tableSign F p.1) p.2 / | |
| (Fintype.card (K ββ[F2] F2) : β) | |
| nonnegative p := div_nonneg (frequencyWeight_nonneg _ _) (Nat.cast_nonneg _) | |
| normalized := by | |
| rw [Fintype.sum_prod_type] | |
| simp_rw [β Finset.sum_div, tableSign_frequencyWeight_sum] | |
| simp [Fintype.card_ne_zero] | |
| theorem privateSeedLaw_expectation (F : (E ββ[F2] H) β K) | |
| (g : ((K ββ[F2] F2) Γ (H ββ[F2] E)) β β) : | |
| (privateSeedLaw F).expectation g = | |
| πΌ Ο : K ββ[F2] F2, β Ξ¦ : H ββ[F2] E, | |
| frequencyWeight (tableSign F Ο) Ξ¦ * g (Ο, Ξ¦) := by | |
| simp only [FiniteDistribution.expectation, privateSeedLaw, Fintype.sum_prod_type, | |
| Fintype.expect_eq_sum_div_card] | |
| simp_rw [div_mul_eq_mul_div, β Finset.sum_div] | |
| /-- The decoder receives no left witness. The first-bit repair affects only | |
| zero-mass frequencies when the table is folded. -/ | |
| def privateOutput (ΞΉ : H ββ[F2] K) (Ο : E ββ[F2] F2) | |
| (fallback : ActualAnswer Ο) (p : (K ββ[F2] F2) Γ (H ββ[F2] E)) : | |
| ActualAnswer Ο := | |
| if hn : p.1.comp ΞΉ = 0 then fallback else | |
| let v := p.2 (chooseUnit (p.1.comp ΞΉ) hn) | |
| if hv : Ο v = 1 then β¨v, hvβ© else fallback | |
| omit [FiniteDimensional F2 E] [Fintype (H ββ[F2] E)] [Fintype (K ββ[F2] F2)] in | |
| theorem privateOutput_eq_contraction (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) | |
| (folded : β N h, F (N + Ο.smulRight h) = F N + ΞΉ h) | |
| (Ο : K ββ[F2] F2) (Ξ¦ : H ββ[F2] E) | |
| (hn : Ο.comp ΞΉ β 0) (hp : 0 < frequencyWeight (tableSign F Ο) Ξ¦) : | |
| (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).1 = Ξ¦ (chooseUnit (Ο.comp ΞΉ) hn) := by | |
| have hunit : Ο (ΞΉ (chooseUnit (Ο.comp ΞΉ) hn)) = 1 := chooseUnit_spec (Ο.comp ΞΉ) hn | |
| have hfold := tableSign_antifold F ΞΉ Ο Ο (chooseUnit (Ο.comp ΞΉ) hn) | |
| (fun N => folded N _) hunit | |
| have hbit := positive_frequency_first_bit (tableSign F Ο) Ο | |
| (chooseUnit (Ο.comp ΞΉ) hn) Ξ¦ hfold hp | |
| simp [privateOutput, hn, hbit] | |
| /-- This is an actual finite distribution on actual answers, for every visible | |
| row table. The sampler's normalization is Parseval, not a hypothesis. -/ | |
| def privateLaw [Fintype E] (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) : | |
| FiniteDistribution (ActualAnswer Ο) := | |
| (privateSeedLaw F).pushforward (privateOutput ΞΉ Ο fallback) | |
| theorem privateLaw_expectation [Fintype E] (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) | |
| (g : ActualAnswer Ο β β) : | |
| (privateLaw F ΞΉ Ο fallback).expectation g = | |
| πΌ Ο : K ββ[F2] F2, β Ξ¦ : H ββ[F2] E, | |
| frequencyWeight (tableSign F Ο) Ξ¦ * g (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)) := by | |
| rw [privateLaw, FiniteDistribution.expectation_pushforward, privateSeedLaw_expectation] | |
| end RightRule | |
| section LeftRule | |
| variable {E : Type*} [AddCommGroup E] [Module F2 E] [Fintype E] | |
| /-- The left rule is uniform on its own chosen affine-answer candidates. -/ | |
| def candidateLaw (Z : Submodule F2 E) (z : E) (Ο : E ββ[F2] F2) | |
| (hz : Ο z = 1) : FiniteDistribution (ActualAnswer Ο) := by | |
| letI : Nonempty {v // v β candidates Z z Ο} := | |
| β¨β¨z, (mem_candidates Z z z Ο).2 β¨by simp, hzβ©β©β© | |
| exact (FiniteDistribution.uniform {v // v β candidates Z z Ο}).pushforward | |
| (fun v => β¨v.1, ((mem_candidates Z z v.1 Ο).1 v.2).2β©) | |
| theorem candidateLaw_expectation (Z : Submodule F2 E) (z : E) | |
| (Ο : E ββ[F2] F2) (hz : Ο z = 1) (g : E β β) : | |
| (candidateLaw Z z Ο hz).expectation (fun v => g v.1) = | |
| πΌ v β candidates Z z Ο, g v := by | |
| let : Nonempty {v // v β candidates Z z Ο} := | |
| β¨β¨z, (mem_candidates Z z z Ο).2 β¨by simp, hzβ©β©β© | |
| unfold candidateLaw | |
| rw [FiniteDistribution.expectation_pushforward, FiniteDistribution.expectation_uniform, | |
| Finset.expect_eq_sum_div_card] | |
| simp only [Fintype.card_coe, Finset.sum_coe_sort] | |
| end LeftRule | |
| section ConditionalAgreement | |
| variable {U E H K : Type*} | |
| variable [AddCommGroup U] [Module F2 U] [Fintype U] | |
| variable [AddCommGroup E] [Module F2 E] [Fintype E] | |
| variable [AddCommGroup H] [Module F2 H] | |
| variable [AddCommGroup K] [Module F2 K] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (K ββ[F2] F2)] | |
| /-- Actual independent response-law success, with the literal projection test. -/ | |
| def conditionalAgreement (Z : Submodule F2 U) (z : U) | |
| (ΟU : U ββ[F2] F2) (hz : ΟU z = 1) (Ο : U ββ[F2] E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) | |
| (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) : β := | |
| ((candidateLaw Z z ΟU hz).product (privateLaw F ΞΉ Ο fallback)).probability | |
| (fun a => decide (Ο a.1.1 = a.2.1)) | |
| theorem conditionalAgreement_eq_sum (Z : Submodule F2 U) (z : U) | |
| (ΟU : U ββ[F2] F2) (hz : ΟU z = 1) (Ο : U ββ[F2] E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) | |
| (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) : | |
| conditionalAgreement Z z ΟU hz Ο F ΞΉ Ο fallback = | |
| πΌ Ο : K ββ[F2] F2, β Ξ¦ : H ββ[F2] E, | |
| frequencyWeight (tableSign F Ο) Ξ¦ * | |
| (πΌ v β candidates Z z ΟU, | |
| if Ο v = (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).1 then (1 : β) else 0) := by | |
| unfold conditionalAgreement | |
| have hp (ΞΌ : FiniteDistribution (ActualAnswer ΟU Γ ActualAnswer Ο)) : | |
| ΞΌ.probability (fun a => decide (Ο a.1.1 = a.2.1)) = | |
| ΞΌ.expectation (fun a => if Ο a.1.1 = a.2.1 then (1 : β) else 0) := by | |
| simp [FiniteDistribution.probability, FiniteDistribution.expectation, mul_ite] | |
| rw [hp, FiniteDistribution.expectation_product] | |
| simp_rw [privateLaw_expectation] | |
| rw [candidateLaw_expectation Z z ΟU hz (fun v => | |
| πΌ Ο : K ββ[F2] F2, β Ξ¦ : H ββ[F2] E, | |
| frequencyWeight (tableSign F Ο) Ξ¦ * | |
| (if Ο v = (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).1 then (1 : β) else 0)), | |
| Finset.expect_comm] | |
| apply Finset.expect_congr rfl | |
| intro Ο _ | |
| rw [Finset.expect_sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro Ξ¦ _ | |
| exact (Finset.mul_expect _ _ _).symm | |
| /-- The exact good Fourier mass in a witness coset; unlike the response law, | |
| this analysis-only quantity is allowed to mention the witness. -/ | |
| def goodCosetMass (Q : Submodule F2 E) (z' : E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) : β := | |
| πΌ Ο : K ββ[F2] F2, if Ο.comp ΞΉ β 0 then | |
| β Ξ¦ β frequencyCoset Q.mkQ ((Ο.comp ΞΉ).smulRight z'), | |
| frequencyWeight (tableSign F Ο) Ξ¦ else 0 | |
| omit [Fintype E] in | |
| omit [FiniteDimensional F2 E] [FiniteDimensional F2 H] in | |
| theorem goodCosetMass_nonneg (Q : Submodule F2 E) (z' : E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) : | |
| 0 β€ goodCosetMass Q z' F ΞΉ := by | |
| apply Finset.expect_nonneg | |
| intro Ο _ | |
| split | |
| Β· exact Finset.sum_nonneg fun _ _ => frequencyWeight_nonneg _ _ | |
| Β· exact le_rfl | |
| omit [Fintype E] in | |
| omit [FiniteDimensional F2 E] [Fintype (K ββ[F2] F2)] in | |
| /-- A good sampled frequency has a valid left preimage. Neither decoder is | |
| given the proof or the witness used here. -/ | |
| theorem good_frequency_preimage (Z : Submodule F2 U) (z : U) | |
| (ΟU : U ββ[F2] F2) (Ο : U ββ[F2] E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) | |
| (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) | |
| (hΟ : Ο.comp Ο = ΟU) | |
| (folded : β N h, F (N + Ο.smulRight h) = F N + ΞΉ h) | |
| (Ο : K ββ[F2] F2) (Ξ¦ : H ββ[F2] E) | |
| (hn : Ο.comp ΞΉ β 0) | |
| (hc : Ξ¦ β frequencyCoset (Z.map Ο).mkQ ((Ο.comp ΞΉ).smulRight (Ο z))) | |
| (hp : 0 < frequencyWeight (tableSign F Ο) Ξ¦) : | |
| β v β candidates Z z ΟU, Ο v = (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).1 := by | |
| have hout := privateOutput_eq_contraction F ΞΉ Ο fallback folded Ο Ξ¦ hn hp | |
| apply candidate_preimage Z z Ο ΟU Ο hΟ | |
| Β· rw [hout] | |
| apply contraction_mem_target_coset (Z.map Ο) (Ο.comp ΞΉ) (Ο z) Ξ¦ | |
| (chooseUnit (Ο.comp ΞΉ) hn) (chooseUnit_spec _ _) | |
| simpa [frequencyCoset] using hc | |
| Β· exact (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).2 | |
| /-- The actual independent policies agree with at least the good Fourier mass | |
| divided by the number of left candidates. -/ | |
| theorem conditionalAgreement_ge_mass_div_card (Z : Submodule F2 U) (z : U) | |
| (ΟU : U ββ[F2] F2) (hz : ΟU z = 1) (Ο : U ββ[F2] E) | |
| (F : (E ββ[F2] H) β K) (ΞΉ : H ββ[F2] K) | |
| (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) | |
| (hΟ : Ο.comp Ο = ΟU) | |
| (folded : β N h, F (N + Ο.smulRight h) = F N + ΞΉ h) : | |
| goodCosetMass (Z.map Ο) (Ο z) F ΞΉ / (candidates Z z ΟU).card β€ | |
| conditionalAgreement Z z ΟU hz Ο F ΞΉ Ο fallback := by | |
| rw [goodCosetMass, Finset.expect_div, conditionalAgreement_eq_sum] | |
| apply Finset.expect_le_expect | |
| intro Ο _ | |
| have hi := independent_agreement_lower (candidates Z z ΟU) Ο | |
| (fun Ξ¦ => (privateOutput ΞΉ Ο fallback (Ο, Ξ¦)).1) | |
| (frequencyWeight (tableSign F Ο)) | |
| (fun Ξ¦ => Ο.comp ΞΉ β 0 β§ | |
| Ξ¦ β frequencyCoset (Z.map Ο).mkQ ((Ο.comp ΞΉ).smulRight (Ο z))) | |
| (frequencyWeight_nonneg _) | |
| (fun Ξ¦ hΞ¦ hp => good_frequency_preimage Z z ΟU Ο F ΞΉ Ο fallback | |
| hΟ folded Ο Ξ¦ hΞ¦.1 hΞ¦.2 hp) | |
| by_cases hn : Ο.comp ΞΉ β 0 | |
| Β· simpa [hn, Finset.sum_filter] using hi | |
| Β· simpa [hn] using hi | |
| end ConditionalAgreement | |
| section SliceBound | |
| variable {E H K : Type*} | |
| variable [AddCommGroup E] [Module F2 E] [Fintype E] | |
| variable [AddCommGroup H] [Module F2 H] [Fintype H] | |
| variable [AddCommGroup K] [Module F2 K] | |
| variable [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (K ββ[F2] F2)] | |
| omit [Fintype E] in | |
| /-- The actual transferred affine-slice agreement supplies the sampled good | |
| Fourier mass, including removal of characters trivial on the hidden kernel. -/ | |
| theorem goodCosetMass_lower_from_slice (Q : Submodule F2 E) | |
| [Fintype (H ββ[F2] Q)] [Fintype ((E β§Έ Q) ββ[F2] H)] | |
| (Nβ : E ββ[F2] H) (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (hΞΉ : Function.Injective ΞΉ) (z' : E) (b : K) | |
| (Ξ± : β) (hΞ± : 0 β€ Ξ±) (β r : β) | |
| (hH : Module.finrank F2 H β€ β) (hQ : Module.finrank F2 Q β€ r) | |
| (hsmall : 1 / (Fintype.card H : β) β€ Ξ± / 8) | |
| (hagreement : Ξ± / 4 β€ πΌ A : (E β§Έ Q) ββ[F2] H, | |
| if F (Nβ + A.comp Q.mkQ) = b + ΞΉ ((Nβ + A.comp Q.mkQ) z') | |
| then (1 : β) else 0) : | |
| (Ξ± / 8) ^ 2 / (2 : β) ^ (β * r) β€ goodCosetMass Q z' F ΞΉ := by | |
| let good : (K ββ[F2] F2) β Prop := fun Ο => Ο.comp ΞΉ β 0 | |
| let : DecidablePred good := fun _ => Classical.propDecidable _ | |
| let C : (K ββ[F2] F2) β β := fun Ο => | |
| sliceCorrelation Q.mkQ Nβ (tableSign F Ο) ((Ο.comp ΞΉ).smulRight z') | |
| let mass : (K ββ[F2] F2) β β := fun Ο => | |
| β Ξ¦ β frequencyCoset Q.mkQ ((Ο.comp ΞΉ).smulRight z'), | |
| frequencyWeight (tableSign F Ο) Ξ¦ | |
| have habs : Ξ± / 4 β€ πΌ Ο : K ββ[F2] F2, |C Ο| := | |
| hagreement.trans (agreement_le_average_abs_correlation Q.mkQ Nβ F ΞΉ z' b) | |
| have hbad : (πΌ Ο : K ββ[F2] F2, | |
| if good Ο then (0 : β) else 1) β€ Ξ± / 8 := by | |
| have ht := trivial_restriction_probability ΞΉ hΞΉ | |
| have heq : (πΌ Ο : K ββ[F2] F2, | |
| if good Ο then (0 : β) else 1) = 1 / (Fintype.card H : β) := by | |
| calc | |
| _ = πΌ Ο : K ββ[F2] F2, if Ο.comp ΞΉ = 0 then (1 : β) else 0 := by | |
| apply Finset.expect_congr rfl | |
| intro Ο _ | |
| by_cases hn : Ο.comp ΞΉ = 0 <;> simp [good, hn] | |
| _ = _ := ht | |
| exact heq.le.trans hsmall | |
| have hselected : Ξ± / 8 β€ πΌ Ο : K ββ[F2] F2, | |
| if good Ο then |C Ο| else 0 := by | |
| have hh := remove_bad_characters C good (Ξ± / 4) (Ξ± / 8) | |
| (fun Ο => sliceCorrelation_tableSign_abs_le_one Q.mkQ Nβ F Ο | |
| ((Ο.comp ΞΉ).smulRight z')) habs hbad | |
| linarith | |
| have hbound := average_coset_mass_lower C mass good | |
| ((2 : β) ^ (β * r)) (Ξ± / 8) (by positivity) (by positivity) hselected | |
| (by | |
| intro Ο _ | |
| have hcs := sliceCorrelation_sq_le_coset_mass Q.mkQ Nβ (tableSign F Ο) | |
| ((Ο.comp ΞΉ).smulRight z') | |
| have hc : ((frequencyCoset Q.mkQ ((Ο.comp ΞΉ).smulRight z')).card : β) β€ | |
| (2 : β) ^ (β * r) := by | |
| exact_mod_cast frequencyCoset_card_le Q ((Ο.comp ΞΉ).smulRight z') β r hH hQ | |
| exact hcs.trans (mul_le_mul_of_nonneg_right hc | |
| (Finset.sum_nonneg fun _ _ => frequencyWeight_nonneg _ _))) | |
| calc | |
| _ β€ πΌ Ο : K ββ[F2] F2, if good Ο then mass Ο else 0 := hbound | |
| _ = goodCosetMass Q z' F ΞΉ := by | |
| unfold goodCosetMass | |
| apply Finset.expect_congr rfl | |
| intro Ο _ | |
| by_cases hn : Ο.comp ΞΉ = 0 <;> simp [good, mass, hn] | |
| end SliceBound | |
| variable {U E H K : Type*} | |
| variable [AddCommGroup U] [Module F2 U] [Fintype U] | |
| variable [AddCommGroup E] [Module F2 E] [Fintype E] | |
| variable [AddCommGroup H] [Module F2 H] [Fintype H] | |
| variable [AddCommGroup K] [Module F2 K] | |
| variable [FiniteDimensional F2 U] [FiniteDimensional F2 E] [FiniteDimensional F2 H] | |
| variable [Fintype (E ββ[F2] H)] [Fintype (H ββ[F2] E)] | |
| variable [Fintype (K ββ[F2] F2)] | |
| theorem conditionalAgreement_from_slice (Z : Submodule F2 U) [Fintype Z] | |
| (z : U) (ΟU : U ββ[F2] F2) (hz : ΟU z = 1) (Ο : U ββ[F2] E) | |
| [Fintype (H ββ[F2] Z.map Ο)] [Fintype ((E β§Έ Z.map Ο) ββ[F2] H)] | |
| (Nβ : E ββ[F2] H) (F : (E ββ[F2] H) β K) | |
| (ΞΉ : H ββ[F2] K) (hΞΉ : Function.Injective ΞΉ) | |
| (Ο : E ββ[F2] F2) (fallback : ActualAnswer Ο) (hΟ : Ο.comp Ο = ΟU) | |
| (folded : β N h, F (N + Ο.smulRight h) = F N + ΞΉ h) | |
| (b : K) (Ξ± : β) (hΞ± : 0 β€ Ξ±) (β r : β) | |
| (hH : Module.finrank F2 H β€ β) (hZ : Module.finrank F2 Z β€ r) | |
| (hsmall : 1 / (Fintype.card H : β) β€ Ξ± / 8) | |
| (hagreement : Ξ± / 4 β€ πΌ A : (E β§Έ Z.map Ο) ββ[F2] H, | |
| if F (Nβ + A.comp (Z.map Ο).mkQ) = | |
| b + ΞΉ ((Nβ + A.comp (Z.map Ο).mkQ) (Ο z)) then (1 : β) else 0) : | |
| (Ξ± / 8) ^ 2 / (2 : β) ^ (β * r) / (2 : β) ^ r β€ | |
| conditionalAgreement Z z ΟU hz Ο F ΞΉ Ο fallback := by | |
| have hQ : Module.finrank F2 (Z.map Ο) β€ r := | |
| (Submodule.finrank_map_le Ο Z).trans hZ | |
| have hmass := goodCosetMass_lower_from_slice (Z.map Ο) Nβ F ΞΉ hΞΉ (Ο z) b | |
| Ξ± hΞ± β r hH hQ hsmall hagreement | |
| have hcard : ((candidates Z z ΟU).card : β) β€ (2 : β) ^ r := by | |
| exact_mod_cast candidates_card_le_pow Z z ΟU r hZ | |
| have hcardpos : (0 : β) < (candidates Z z ΟU).card := | |
| Nat.cast_pos.mpr (Finset.card_pos.mpr (candidates_nonempty Z z ΟU hz)) | |
| calc | |
| _ β€ goodCosetMass (Z.map Ο) (Ο z) F ΞΉ / (2 : β) ^ r := | |
| div_le_div_of_nonneg_right hmass (by positivity) | |
| _ β€ goodCosetMass (Z.map Ο) (Ο z) F ΞΉ / (candidates Z z ΟU).card := | |
| div_le_div_of_nonneg_left (goodCosetMass_nonneg _ _ _ _) hcardpos hcard | |
| _ β€ _ := conditionalAgreement_ge_mass_div_card Z z ΟU hz Ο F ΞΉ Ο fallback hΟ folded | |
| end MaxCutGames.Decoder.PrivateStrategy | |
| end | |
| end OAI | |