openAI-math-dataset / lean /OAI /Combinatorics /EditApproximation /Refinement /ComputedNumericalParameters.lean
roseking's picture
Add lean source and binary files (part 43)
e63eb7f verified
Raw History Blame Contribute Delete
4.11 kB
import OAI.Combinatorics.EditApproximation.Geometry.LocalOnlineMassBound
import OAI.Combinatorics.EditApproximation.Refinement.ComputedEarlierInputBudget
import OAI.Combinatorics.EditApproximation.Numerics.NumericalWork
namespace OAI
/-! All-seed numerical dimension and source-range bounds after substituting
the computed grid size. These bounds do not use an accuracy event. -/
namespace EditApproximation
theorem wide_coordinate_budget_le (H M P p : ℕ) (hH : 64 ≤ H) (hM : M ≤ H)
(hP : 1 ≤ P) (hPcap : P ≤ H ^ (p + 20)) :
M * (40 * P + 2) ^ 2 ≤ H ^ (2 * p + 45) := by
have hbox : 40 * P + 2 ≤ H ^ (p + 22) := by
have hconstant : 42 ≤ H ^ 2 := by nlinarith
calc
_ ≤ 42 * P := by omega
_ ≤ H ^ 2 * H ^ (p + 20) := Nat.mul_le_mul hconstant hPcap
_ = H ^ (2 + (p + 20)) := (pow_add H 2 (p + 20)).symm
_ = _ := by congr 1; omega
calc
_ ≤ H * (H ^ (p + 22)) ^ 2 := Nat.mul_le_mul hM (Nat.pow_le_pow_left hbox 2)
_ = H * H ^ ((p + 22) * 2) := by rw [pow_mul]
_ = H ^ ((p + 22) * 2 + 1) := (pow_succ' H _).symm
_ = _ := by congr 1; omega
theorem optimizer_parameter_budget_le (H M P p : ℕ) (hH : 64 ≤ H) (hM : M ≤ H)
(hP : 1 ≤ P) (hPcap : P ≤ H ^ (p + 20)) :
H + M * (40 * P + 2) ^ 2 + 4 ≤ H ^ (2 * p + 46) := by
have hdimension := wide_coordinate_budget_le H M P p hH hM hP hPcap
have hlarge : H ≤ H ^ (2 * p + 45) := Nat.le_pow (by omega)
have hfour : 4 ≤ H ^ (2 * p + 45) := (by omega : 4 ≤ H).trans hlarge
calc
_ ≤ 3 * H ^ (2 * p + 45) := by omega
_ ≤ H * H ^ (2 * p + 45) := Nat.mul_le_mul_right _ (by omega)
_ = H ^ (2 * p + 45 + 1) := (pow_succ' H _).symm
_ = _ := rfl
theorem optimizerTriangularMass_le_square (K : ℕ) : optimizerTriangularMass K ≤ K ^ 2 := by
have htwice := optimizerTriangularMass_twice K
have hpower : K ≤ K ^ 2 := Nat.le_pow (by decide)
nlinarith only [htwice, hpower]
theorem localOnlineMassBound_polynomial (H M P p : ℕ) (hH : 64 ≤ H) (hM : M ≤ H)
(hP : 1 ≤ P) (hPcap : P ≤ H ^ (p + 20)) :
localOnlineMassBound M P H ≤ H ^ (8000 * (p + 1)) := by
have hG : H + M * (40 * P + 2) ^ 2 + 2 ≤ H ^ (2 * p + 46) :=
(by omega : H + M * (40 * P + 2) ^ 2 + 2 ≤ H + M * (40 * P + 2) ^ 2 + 4).trans
(optimizer_parameter_budget_le H M P p hH hM hP hPcap)
calc
_ ≤ ((H + M * (40 * P + 2) ^ 2 + 2) ^ 80) ^ 2 := optimizerTriangularMass_le_square _
_ = (H + M * (40 * P + 2) ^ 2 + 2) ^ (80 * 2) := (pow_mul _ 80 2).symm
_ ≤ (H ^ (2 * p + 46)) ^ (80 * 2) := Nat.pow_le_pow_left hG _
_ = H ^ ((2 * p + 46) * (80 * 2)) := (pow_mul H _ _).symm
_ ≤ _ := Nat.pow_le_pow_right (by omega) (by omega)
theorem computed_localOnlineMassBound_polynomial (N : ℕ) (hH : 64 ≤ inputHeight N) :
localOnlineMassBound (integerParameters N).M (integerParameters N).P (inputHeight N) ≤
inputHeight N ^ (8000 * (coarseExponent (inputSmallLog N) + 1)) := by
apply localOnlineMassBound_polynomial _ _ _ _ hH
· exact Nat.pow_le_pow_right (by decide : 0 < (2 : ℕ)) (Nat.div_le_self _ _)
· exact Nat.one_le_pow _ _ (by omega)
· exact le_rfl
theorem computed_localOnlineMassBound_bits (N : ℕ) (hH : 64 ≤ inputHeight N) :
Nat.size (localOnlineMassBound (integerParameters N).M (integerParameters N).P (inputHeight N)) ≤
8000 * (coarseExponent (inputSmallLog N) + 1) * Nat.size (inputHeight N) + 1 :=
(Nat.size_le_size (computed_localOnlineMassBound_polynomial N hH)).trans
(natural_power_bit_length _ _)
theorem rejectionBitCount_le_size (B : ℕ) : rejectionBitCount B ≤ Nat.size B := by
apply Nat.clog_le_of_le_pow
exact (Nat.lt_size_self B).le
theorem computed_localOnlineMassBound_rejection_bits (N : ℕ) (hH : 64 ≤ inputHeight N) :
rejectionBitCount (localOnlineMassBound (integerParameters N).M (integerParameters N).P (inputHeight N)) ≤
8000 * (coarseExponent (inputSmallLog N) + 1) * Nat.size (inputHeight N) + 1 :=
(rejectionBitCount_le_size _).trans (computed_localOnlineMassBound_bits N hH)
end EditApproximation
end OAI