math / data /lean /OAI /Computability /DepthThree /HardSliceProbability.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.46 kB
import OAI.Computability.DepthThree.HardSliceMoment
import OAI.Computability.DepthThree.SparseCorrelation
import OAI.Computability.DepthThree.HashProbability
import OAI.Computability.DepthThree.AlgebraQuotient
import Mathlib.Tactic.Positivity
namespace OAI
noncomputable section
open scoped BigOperators Classical
namespace DepthThreeLowerBound
def hardSliceSparseConstant (b : β„•) (hb : 1 ≀ b) : β„• :=
Classical.choose (exists_sparse_correlation_constant.{0} b hb)
theorem hardSliceSparseConstant_pos (b : β„•) (hb : 1 ≀ b) :
0 < hardSliceSparseConstant b hb :=
(Classical.choose_spec (exists_sparse_correlation_constant.{0} b hb)).1
theorem hardSliceSparseConstant_spec (b : β„•) (hb : 1 ≀ b)
(V : Type) [Fintype V] [DecidableEq V] (G : Cube V β†’ ℝ)
(htests : βˆ€ H : CNF V, H.Normalized β†’ H.WidthAtMost b β†’
H.length ≀ hardSliceSparseConstant b hb * Fintype.card V β†’
|finiteAvg (fun x => G x * indicator (H.eval x))| ≀
(2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) :
corr b G ≀ (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8) :=
(Classical.choose_spec (exists_sparse_correlation_constant.{0} b hb)).2 V G htests
theorem sparseMomentBound_nonneg (m b L h : β„•) (Ξ΄ : ℝ) :
0 ≀ sparseMomentBound m b L h Ξ΄ := by
unfold sparseMomentBound
apply mul_nonneg (Nat.cast_nonneg _)
apply div_nonneg
Β· positivity
Β· rw [pow_mul]
exact pow_nonneg (sq_nonneg (Ξ΄ * ((2 ^ m : β„•) : ℝ))) h
theorem coefficient_corr_failure_le {F V : Type} [Field F]
[Module BinaryAlgebra.F2 F] [Fintype F] [Fintype V]
(ell : F β†’β‚—[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1)
(a : Cube V β†’ F) (ha : Function.Injective a)
(b : β„•) (hb : 1 ≀ b) (h : β„•) (hh : 0 < h) :
finiteProb (fun Ξ² : Fin (2 * h) β†’ F =>
Β¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) a Ξ² x)) ≀
(2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8)) ≀
sparseMomentBound (Fintype.card V) b
(hardSliceSparseConstant b hb * Fintype.card V) h
((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) := by
apply le_trans _ (coefficient_sparse_cnfs_gt_le ell hOne a ha b
(hardSliceSparseConstant b hb * Fintype.card V) h hh
((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) (Real.rpow_pos_of_pos (by norm_num) _))
apply finiteProb_mono
intro Ξ² hΞ²
by_contra hnone
apply hΞ²
apply hardSliceSparseConstant_spec b hb V
intro H _ hw hlen
by_contra hfail
exact hnone ⟨H, hw, hlen, lt_of_not_ge hfail⟩
theorem hash_coefficient_corr_failure_le {F V U : Type} [Field F]
[Module BinaryAlgebra.F2 F] [Fintype F] [Fintype V]
[Fintype U] [Nonempty U]
(ell : F β†’β‚—[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1)
(a : U β†’ Cube V β†’ F) (b : β„•) (hb : 1 ≀ b) (h : β„•) (hh : 0 < h) :
finiteProb (fun Ο‰ : U Γ— (Fin (2 * h) β†’ F) =>
Β¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) (a Ο‰.1) Ο‰.2 x)) ≀
(2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8)) ≀
finiteProb (fun u => Β¬ Function.Injective (a u)) +
sparseMomentBound (Fintype.card V) b
(hardSliceSparseConstant b hb * Fintype.card V) h
((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) := by
let B := sparseMomentBound (Fintype.card V) b
(hardSliceSparseConstant b hb * Fintype.card V) h
((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4))
have hB : 0 ≀ B := sparseMomentBound_nonneg _ _ _ _ _
change finiteAvg _ ≀ finiteProb _ + B
rw [finiteAvg_product]
calc
_ ≀ finiteAvg (fun u : U => (if Β¬ Function.Injective (a u) then 1 else 0) + B) := by
apply finiteAvg_mono
intro u
by_cases hu : Function.Injective (a u)
Β· simpa only [finiteProb, B, hu, not_true_eq_false, ite_false, zero_add] using
coefficient_corr_failure_le ell hOne (a u) hu b hb h hh
Β· have hone := finiteProb_le_one (fun Ξ² : Fin (2 * h) β†’ F =>
Β¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) (a u) Ξ² x)) ≀
(2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8))
simpa only [finiteProb, hu, not_false_eq_true, ite_true] using
hone.trans (le_add_of_nonneg_right hB)
_ = finiteProb (fun u => Β¬ Function.Injective (a u)) + B := by
rw [finiteAvg_add, finiteAvg_const]
apply congrArg (fun z : ℝ => z + B)
apply finiteAvg_congr
intro u
exact (ite_eq_ite _ _ _).mpr trivial
def encodedHash {d r : β„•} (p : Fin r β†’ Bool)
(u : Fin (d + r - 1) β†’ Bool) (x : Cube (Fin d)) : BinaryAlgebra.BitQuotient p :=
BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i))
(fun i => BinaryAlgebra.bitValue (BinaryHash.hashBool u x i))
theorem encodedHash_fill_injective {d r : β„•} (p : Fin r β†’ Bool)
(u : Fin (d + r - 1) β†’ Bool) (Οƒ : Restriction (Fin d))
(hu : Function.Injective (fun z : Cube (Live Οƒ) => BinaryHash.hashBool u (fill Οƒ z))) :
Function.Injective (fun z : Cube (Live Οƒ) => encodedHash p u (fill Οƒ z)) := by
intro x y hxy
apply hu
apply (BinaryAlgebra.bitsEquivF2 (Fin r)).injective
exact BinaryAlgebra.encode_injective _ hxy
def hashAcceptance {d r : β„•} (p : Fin r β†’ Bool)
[Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))]
(t : β„•) (u : Fin (d + r - 1) β†’ Bool)
(Ξ² : Fin t β†’ BinaryAlgebra.BitQuotient p) : Cube (Fin d) β†’ Bool :=
Interpolation.acceptEval
(BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) t
(encodedHash p u) Ξ²
theorem actual_hash_coefficient_failure_le {d r : β„•} (p : Fin r β†’ Bool)
[Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))]
(hr : 0 < r) (Οƒ : Restriction (Fin d))
(b : β„•) (hb : 1 ≀ b) (h : β„•) (hh : 0 < h) :
finiteProb (fun Ο‰ : (Fin (d + r - 1) β†’ Bool) Γ—
(Fin (2 * h) β†’ BinaryAlgebra.BitQuotient p) =>
Β¬ corr b (fun z => sign (hashAcceptance p (2 * h) Ο‰.1 Ο‰.2 (fill Οƒ z))) ≀
(2 : ℝ) ^ (-(Fintype.card (Live Οƒ) : ℝ) / 8)) ≀
(2 : ℝ) ^ Fintype.card (Live Οƒ) / (2 : ℝ) ^ r +
sparseMomentBound (Fintype.card (Live Οƒ)) b
(hardSliceSparseConstant b hb * Fintype.card (Live Οƒ)) h
((2 : ℝ) ^ (-(Fintype.card (Live Οƒ) : ℝ) / 4)) := by
let : Field (BinaryAlgebra.BitQuotient p) :=
AdjoinRoot.instField (f := BinaryAlgebra.inputPolynomialBits p)
let : Module BinaryAlgebra.F2 (BinaryAlgebra.BitQuotient p) :=
inferInstanceAs (Module BinaryAlgebra.F2
(AdjoinRoot (BinaryAlgebra.inputPolynomialBits p)))
have hOne : BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)
(1 : BinaryAlgebra.BitQuotient p) = 1 :=
BinaryAlgebra.degreeZero_one _ (by simpa using hr)
have hhash : finiteProb (fun u : Fin (d + r - 1) β†’ Bool =>
Β¬ Function.Injective (fun z : Cube (Live Οƒ) => encodedHash p u (fill Οƒ z))) ≀
(2 : ℝ) ^ Fintype.card (Live Οƒ) / (2 : ℝ) ^ r := by
apply le_trans _ (BinaryHash.hashBool_restriction_failure_le_pow (r := r) Οƒ)
apply finiteProb_mono
intro u hu hinj
exact hu (encodedHash_fill_injective p u Οƒ hinj)
exact (hash_coefficient_corr_failure_le (F := BinaryAlgebra.BitQuotient p)
(V := Live Οƒ) (U := Fin (d + r - 1) β†’ Bool)
(BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) hOne
(fun u z => encodedHash p u (fill Οƒ z)) b hb h hh).trans
(add_le_add_left hhash _)
end DepthThreeLowerBound
end
end OAI