math / data /lean /OAI /Combinatorics /EditApproximation /Coarse /CoarseIndexedEntryCost.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3 kB
import OAI.Combinatorics.EditApproximation.Refinement.ComputedCoarseIndexedWork
import OAI.Combinatorics.EditApproximation.Refinement.PhysicalCoarseSeedLaw
import OAI.Combinatorics.EditApproximation.Probability.FreshCoordinateCost
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
namespace EditApproximation
/-- Keep the branch dimensions symbolic when forming the finite source sum. -/
theorem coarseIndexedEntryBinaryCost_computed_bound :
βˆ€αΆ  N : β„• in Filter.atTop, βˆ€ B d : β„•, βˆ€ x y : List β„•,
B = (integerParameters N).B β†’ d = computedCoarseDepth N (coarseEntryWidth x y) β†’
coarseEntryWidth x y ≀ N β†’ (βˆ€ a ∈ x ++ y, Nat.size a ≀ inputHeight N ^ 3) β†’
βˆ€ (_hB : NeZero B) (draw : CoarseGuessIndex (coarseEntryWidth x y) β†’ CoarseThresholdDraws B d),
(coarseIndexedEntryBinaryCost N B d x y draw : ℝ) ≀ (inputHeight N : ℝ) ^ 40 *
((coarseInitialArrayWork B d (initialThresholdQ N) (initialLambda N) x y draw : ℝ) +
(x.length + 1 : β„•)) := by
filter_upwards [BinaryFraction.computedCoarseIndexedInitialWithWork_bound] with N hN
intro B d x y hB hd hxy hsymbols hinstance draw
have hb := hN B d x y hB hd hxy hsymbols
(Nat.pos_of_neZero _) (pow_pos (Nat.two_pow_pos _) _)
(Nat.mul_pos (by decide) (Nat.two_pow_pos _)) draw
exact_mod_cast hb
theorem coarseIndexedEntryCostSum_bound {M J B : β„•} [NeZero B] (source target : List β„•)
(N : β„•) (depth : PhysicalEntry M J target.length β†’ β„•)
(draw : PhysicalCoarseDraw source target B depth)
(selected : PhysicalEntry M J target.length β†’ Prop) (C : ℝ)
(hc : βˆ€ entry : PhysicalEntry M J target.length,
(coarseIndexedEntryBinaryCost N B (depth entry) (physicalSource source entry.1)
(substring target entry.2.lo entry.2.hi) (draw entry) : ℝ) ≀
C * ((coarseInitialArrayWork B (depth entry) (initialThresholdQ N) (initialLambda N)
(physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) (draw entry) : ℝ) +
((physicalSource source entry.1).length + 1 : β„•))) :
coarseIndexedEntryCostSum source target N depth draw selected ≀ C *
((βˆ‘ entry : PhysicalEntry M J target.length, selectionIndicator (selected entry) *
(coarseInitialArrayWork B (depth entry) (initialThresholdQ N) (initialLambda N)
(physicalSource source entry.1) (substring target entry.2.lo entry.2.hi) (draw entry) : ℝ)) +
βˆ‘ entry : PhysicalEntry M J target.length, selectionIndicator (selected entry) *
((physicalSource source entry.1).length + 1 : β„•)) := by
classical
rw [← Finset.sum_add_distrib, Finset.mul_sum]
unfold coarseIndexedEntryCostSum
apply Finset.sum_le_sum
intro entry _
have hs : 0 ≀ selectionIndicator (selected entry) := by
unfold selectionIndicator
split <;> norm_num
exact (mul_le_mul_of_nonneg_left (hc entry) hs).trans_eq (by ring)
end EditApproximation
end OAI