cfahlgren1/math / lean /OAI /Combinatorics /EditApproximation /Binary /BinaryLocalGuardWork.lean
cfahlgren1's picture
download
raw
4.16 kB
import OAI.Combinatorics.EditApproximation.Binary.BinaryLocalGroupActions
import OAI.Combinatorics.EditApproximation.Binary.BinaryAffineGuard
namespace OAI
/-! Every local eligibility test is charged at the bit level, including
its rational divisions and the construction of its two thresholds. -/
namespace EditApproximation
namespace BinaryFraction
def localEligibilityBitBudget (B : ℕ) : ℕ :=
4000 * (B + 1) ^ 2 + 2100 * (4 * B + 4) ^ 2 + 2000 * (4 * B + 3) ^ 2 +
2 * (1000 * (16 * B + 13) ^ 2 + 1) + 2 * B + 8
theorem centerEligibilityWithWork_cost (b F B : ℕ) (a initial : BinaryFraction)
(hB : 6 ≤ B) (hb : Nat.size b + 2 ≤ B) (hF : Nat.size F + 2 ≤ B)
(ha : a.width ≤ B) (hi : initial.width ≤ B) :
(centerEligibilityWithWork b F a initial).2 ≤ localEligibilityBitBudget B := by
have hfour : (nat 4).width ≤ B := (nat_width_le 4).trans (by
have h : Nat.size 4 = 3 := by decide
omega)
have height : (nat 8).width ≤ B := (nat_width_le 8).trans (by
have h : Nat.size 8 = 4 := by decide
omega)
have hbn := (nat_width_le b).trans hb
have hFn := (nat_width_le F).trans hF
have hdw := canonicalMulWithWork_width (nat 4) a B hfour ha
have hdc := canonicalMulWithWork_cost (nat 4) a B hfour ha
have hlw := divWithWork_width_uniform (nat b) (canonicalMulWithWork (nat 4) a).1
(4 * B + 2) (by omega) hdw
have hlc := divWithWork_cost (nat b) (canonicalMulWithWork (nat 4) a).1
(4 * B + 2) (by omega) hdw
have hfw := canonicalMulWithWork_width (nat 8) (nat F) B height hFn
have hfc := canonicalMulWithWork_cost (nat 8) (nat F) B height hFn
have huw := canonicalMulWithWork_width (canonicalMulWithWork (nat 8) (nat F)).1 (nat b)
(4 * B + 2) hfw (by omega)
have huc := canonicalMulWithWork_cost (canonicalMulWithWork (nat 8) (nat F)).1 (nat b)
(4 * B + 2) hfw (by omega)
have hlow := leWithWork_cost (divWithWork (nat b) (canonicalMulWithWork (nat 4) a).1).1
initial (16 * B + 12) (by omega) (by omega)
have hhigh := leWithWork_cost initial
(canonicalMulWithWork (canonicalMulWithWork (nat 8) (nat F)).1 (nat b)).1
(16 * B + 12) (by omega) (by omega)
simp only [Nat.add_assoc, Nat.reduceAdd] at hlc huc hlow hhigh
change _ + _ + _ + _ + _ + _ + Nat.size b + Nat.size F + 8 ≤ _
unfold localEligibilityBitBudget
omega
theorem refinementScaleGuardWithWork_cost (F b B : ℕ) (a w : BinaryFraction)
(hB : 7 ≤ B) (hb : Nat.size b + 2 ≤ B) (hF : Nat.size F + 2 ≤ B)
(ha : a.width ≤ B) (hw : w.width ≤ B) :
(refinementScaleGuardWithWork F b a w).2 ≤ localEligibilityBitBudget B := by
have hsixteen : (nat 16).width ≤ B := (nat_width_le 16).trans (by
have h : Nat.size 16 = 5 := by decide
omega)
have height : (nat 8).width ≤ B := (nat_width_le 8).trans (by
have h : Nat.size 8 = 4 := by decide
omega)
have hbn := (nat_width_le b).trans hb
have hFn := (nat_width_le F).trans hF
have hdw := canonicalMulWithWork_width (nat 16) (nat F) B hsixteen hFn
have hdc := canonicalMulWithWork_cost (nat 16) (nat F) B hsixteen hFn
have hlw := divWithWork_width_uniform w (canonicalMulWithWork (nat 16) (nat F)).1
(4 * B + 2) (by omega) hdw
have hlc := divWithWork_cost w (canonicalMulWithWork (nat 16) (nat F)).1
(4 * B + 2) (by omega) hdw
have hfw := canonicalMulWithWork_width (nat 8) a B height ha
have hfc := canonicalMulWithWork_cost (nat 8) a B height ha
have huw := canonicalMulWithWork_width (canonicalMulWithWork (nat 8) a).1 w
(4 * B + 2) hfw (by omega)
have huc := canonicalMulWithWork_cost (canonicalMulWithWork (nat 8) a).1 w
(4 * B + 2) hfw (by omega)
have hlow := leWithWork_cost (divWithWork w (canonicalMulWithWork (nat 16) (nat F)).1).1
(nat b) (16 * B + 12) (by omega) (by omega)
have hhigh := leWithWork_cost (nat b)
(canonicalMulWithWork (canonicalMulWithWork (nat 8) a).1 w).1
(16 * B + 12) (by omega) (by omega)
simp only [Nat.add_assoc, Nat.reduceAdd] at hlc huc hlow hhigh
change _ + _ + _ + _ + _ + _ + Nat.size b + Nat.size F + 8 ≤ _
unfold localEligibilityBitBudget
omega
end BinaryFraction
end EditApproximation
end OAI

Xet Storage Details

Size:
4.16 kB
·
Xet hash:
426162e74231cab27667fe09b1729659f5da81693895e98984753ee83a341e83

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.