introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.63 kB
import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.MaskedAssignment
import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.OrdinarySelection
namespace OAI
/-! Joint tensor extraction, compatibility and entropy estimates. -/
noncomputable section
namespace MatrixMultiplication.JointMaskedRates
open Filter JointCoarseHashing JointExtractionRates JointMaskedSelection
open JointOrdinarySelection (hashLevel hashSet)
open scoped Topology
attribute [local instance] Classical.propDecidable
def errorBound (degree : β„• β†’ β„•) (B p : β„•) (H : ℝ) (N : β„•) : ℝ :=
(degree N : ℝ) / (hashModulus H N : ℝ) *
(1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * (N : ℝ))
theorem polynomialFactor_le (B p N : β„•) :
1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * (N : ℝ) ≀
((B : ℝ) + 1) * ((N : ℝ) + 1) ^ (p + 1) := by
have hN : (0 : ℝ) ≀ N := Nat.cast_nonneg _
have hx : (0 : ℝ) ≀ (N : ℝ) + 1 := by linarith
have hpower : (1 : ℝ) ≀ ((N : ℝ) + 1) ^ (p + 1) :=
one_le_powβ‚€ (by linarith : (1 : ℝ) ≀ (N : ℝ) + 1)
calc
_ ≀ 1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * ((N : ℝ) + 1) :=
add_le_add le_rfl (mul_le_mul_of_nonneg_left (by linarith)
(mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hx _)))
_ = 1 + (B : ℝ) * ((N : ℝ) + 1) ^ (p + 1) := by rw [pow_succ]; ring
_ ≀ ((N : ℝ) + 1) ^ (p + 1) + (B : ℝ) * ((N : ℝ) + 1) ^ (p + 1) :=
add_le_add hpower le_rfl
_ = _ := by ring
theorem eventually_errorBound_le_half (degree : β„• β†’ β„•) (B p : β„•)
{D H : ℝ} (hH : 0 ≀ H) (hgap : D < H)
(hdegreeRate : βˆ€ Ξ· : ℝ, 0 < Ξ· β†’
βˆ€αΆ  N in atTop, Real.log (degree N : ℝ) / (N : ℝ) ≀ D + Ξ·) :
βˆ€αΆ  N in atTop, errorBound degree B p H N ≀ 1 / 2 := by
let c : ℝ := (H - D) / 2
have hc : 0 < c := by dsimp [c]; linarith
have hclt : c < H - D := by dsimp [c]; linarith
have hratio := eventually_degree_div_hashModulus_le_exp hH hdegreeRate hclt
apply eventually_error_le_half ((B : ℝ) + 1) (p + 1) hc
filter_upwards [hratio] with N hN
have hx : (0 : ℝ) ≀ (N : ℝ) + 1 := add_nonneg (Nat.cast_nonneg N) zero_le_one
have hfactor : 0 ≀ 1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * (N : ℝ) :=
add_nonneg zero_le_one
(mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hx _)) (Nat.cast_nonneg _))
calc
errorBound degree B p H N ≀ Real.exp (-c * (N : ℝ)) *
(1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * (N : ℝ)) :=
mul_le_mul_of_nonneg_right hN hfactor
_ ≀ Real.exp (-c * (N : ℝ)) * (((B : ℝ) + 1) * ((N : ℝ) + 1) ^ (p + 1)) :=
mul_le_mul_of_nonneg_left (polynomialFactor_le B p N) (Real.exp_pos _).le
_ = ((B : ℝ) + 1) * (((N : ℝ) + 1) ^ (p + 1) * Real.exp (-c * (N : ℝ))) := by ring
theorem count_error_le_envelope {P E O V : Type*} (d : OrbitData P E O V)
(e : E) (degree B p N M : β„•)
(heligibility : (d.eligibilityCompetitors e).card ≀ degree)
(horbits : (d.orbits e).card ≀ B * (N + 1) ^ p) :
((d.eligibilityCompetitors e).card : ℝ) / (M : ℝ) +
((d.orbits e).card : ℝ) * (N : ℝ) * ((degree : ℝ) / (M : ℝ)) ≀
(degree : ℝ) / (M : ℝ) * (1 + (B : ℝ) * ((N : ℝ) + 1) ^ p * (N : ℝ)) := by
have hdegreeR : ((d.eligibilityCompetitors e).card : ℝ) ≀ (degree : ℝ) := by
exact_mod_cast heligibility
have horbitsR : ((d.orbits e).card : ℝ) ≀ (B : ℝ) * ((N : ℝ) + 1) ^ p := by
exact_mod_cast horbits
have hratio : (0 : ℝ) ≀ (degree : ℝ) / (M : ℝ) :=
div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)
calc
_ ≀ (degree : ℝ) / (M : ℝ) +
((B : ℝ) * ((N : ℝ) + 1) ^ p) * (N : ℝ) * ((degree : ℝ) / (M : ℝ)) :=
add_le_add (div_le_div_of_nonneg_right hdegreeR (Nat.cast_nonneg _))
(mul_le_mul_of_nonneg_right
(mul_le_mul_of_nonneg_right horbitsR (Nat.cast_nonneg _)) hratio)
_ = _ := by ring
theorem eventually_exists_selection
{P E O V : β„• β†’ Type*} [βˆ€ N, Fintype (P N)] [βˆ€ N, Fintype (E N)]
(d : βˆ€ N, OrbitData (P N) (E N) (O N) (V N))
(hinj : βˆ€ N, Function.Injective (d N).coarse)
(degree : β„• β†’ β„•) (B p : β„•)
(heligibility : βˆ€ N e, ((d N).eligibilityCompetitors e).card ≀ degree N)
(hdegree : βˆ€ N e, βˆ€ o ∈ (d N).orbits e, βˆ€ v ∈ (d N).passing e o,
((d N).competitors e o v).card ≀ degree N)
(horbits : βˆ€ N e, ((d N).orbits e).card ≀ B * (N + 1) ^ p)
{A D H Cβ‚€ : ℝ} (hH : 0 ≀ H) (hgap : D < H)
(hdegreeRate : βˆ€ Ξ· : ℝ, 0 < Ξ· β†’
βˆ€αΆ  N in atTop, Real.log (degree N : ℝ) / (N : ℝ) ≀ D + Ξ·)
(hdet : βˆ€αΆ  N in atTop, βˆ€ e, βˆ€ o ∈ (d N).orbits e,
JointLossCounts.deterministicLossFraction ((d N).full e o) ((d N).passing e o) ≀
Cβ‚€ / (N : ℝ))
(hpos : βˆ€αΆ  N in atTop, 0 < Fintype.card (E N))
(hE : Tendsto (fun N => Real.log (Fintype.card (E N) : ℝ) / (N : ℝ)) atTop (𝓝 A))
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) :
βˆ€αΆ  N in atTop, βˆƒ (s : Sample (P N) (hashLevel H N)) (G : Finset (E N)),
G.card = ⌊Real.exp ((N : ℝ) * (A - H - Ξ΅))βŒ‹β‚Š ∧
(βˆ€ e ∈ G, (d N).Good (hashLevel H N) (hashSet H N) (N : ℝ) e s) ∧
(βˆ€ e ∈ G, βˆ€ f ∈ G, e β‰  f β†’ ((d N).coarse e).1 β‰  ((d N).coarse f).1) ∧
βˆ€ e ∈ G, βˆ€ o ∈ (d N).orbits e,
JointLossCounts.missingFraction ((d N).full e o) ((d N).passing e o)
((d N).variableBad (hashLevel H N) (hashSet H N) e o) s ≀ (Cβ‚€ + 1) / (N : ℝ) := by
classical
have huniform := eventually_errorBound_le_half degree B p hH hgap hdegreeRate
have hsmall : βˆ€αΆ  N in atTop, βˆ€ e,
(((d N).eligibilityCompetitors e).card : ℝ) / (hashModulus H N : ℝ) +
(((d N).orbits e).card : ℝ) * (N : ℝ) *
((degree N : ℝ) / (hashModulus H N : ℝ)) ≀ 1 / 2 := by
filter_upwards [huniform] with N hN e
exact (count_error_le_envelope (d N) e (degree N) B p N (hashModulus H N)
(heligibility N e) (horbits N e)).trans hN
have hpositive : βˆ€αΆ  N : β„• in atTop, (0 : ℝ) < N := by
filter_upwards [eventually_gt_atTop (0 : β„•)] with N hN
exact_mod_cast hN
let good := fun N (s : Sample (P N) (hashLevel H N)) (e : E N) =>
(d N).Good (hashLevel H N) (hashSet H N) (N : ℝ) e s
have hinc : βˆ€αΆ  N in atTop, βˆ€ e,
(((JointAPFree.modularSet (hashModulus H N)).card : ℝ) /
(hashModulus H N : ℝ) ^ 2 / 2) *
(Fintype.card (Sample (P N) (hashLevel H N)) : ℝ) ≀
(goodIncidence (good N) e : ℝ) := by
filter_upwards [hsmall, hpositive] with N hN hNpos e
rw [show goodIncidence (good N) e =
((d N).goodEvent (hashLevel H N) (hashSet H N) (N : ℝ) e).card from
(d N).goodIncidence_eq _ _ _ _]
exact (d N).goodEvent_card_lower (hashLevel H N) (hashSet H N) (N : ℝ) hNpos e
(degree N) (hdegree N e) (hN e)
have hyield := eventually_exists_many_good_explicit good hH hpos hinc hE hΞ΅
have hselection := eventually_exists_good_subfamily good
(fun N => ⌊Real.exp ((N : ℝ) * (A - H - Ξ΅))βŒ‹β‚Š) hyield
filter_upwards [hselection, hdet] with N hN hdetN
obtain ⟨s, G, hcard, hgood⟩ := hN
refine ⟨s, G, hcard, hgood, ?_, ?_⟩
Β· intro e he f hf hne
exact (d N).good_no_shared_x (hashLevel H N) (hashSet H N) (N : ℝ) f e s
(hgood f hf) (hgood e he) (fun h => hne ((hinj N) h))
Β· intro e he o ho
exact (d N).good_missingFraction_le (hashLevel H N) (hashSet H N) Cβ‚€ (N : ℝ) e s
(hgood e he) (hdetN e) o ho
end MatrixMultiplication.JointMaskedRates
end
end OAI