math / data /lean /OAI /Combinatorics /EditApproximation /Coarse /CoarseGridInvariant.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.67 kB
import OAI.Combinatorics.EditApproximation.Coarse.CoarsePrecision
import OAI.Combinatorics.EditApproximation.Coarse.CoarseGlobalSeed
namespace OAI
namespace EditApproximation
/-- One descended allowance acquires only one factor of the fixed root
base in its denominator. This includes the literal sampled child label. -/
theorem coarseChildAllowance_grid (B q L j : β„•) (allowance : β„š) (draw : Fin B)
(hB : 0 < B) (hq : 0 < q) (hL : 0 < L)
(ha : allowance.den ∣ (L * B * q) ^ j) :
((1 / (L : β„š)) * coarseChildThreshold B q allowance draw).den ∣
(L * B * q) ^ (j + 1) := by
have ht : (coarseChildThreshold B q allowance draw).den ∣
(L * B * q) ^ j * (B * q) := by
simpa only [coarseChildThreshold, Nat.cast_mul] using
coarse_rat_div_nat_den_dvd (allowance * ((draw.val + 1 : β„•) : β„š)) (B * q) ((L * B * q) ^ j)
(Nat.mul_pos hB hq) (coarse_rat_mul_nat_den_dvd allowance (draw.val + 1) _ ha)
have heq : (1 / (L : β„š)) * coarseChildThreshold B q allowance draw =
coarseChildThreshold B q allowance draw / L := by ring
rw [heq]
convert coarse_rat_div_nat_den_dvd _ L _ hL ht using 1
rw [pow_succ]
ring
/-- Every descendant array lives on the same denominator constructed for
its root; it is unnecessary to normalize any array sum by a gcd. -/
theorem coarseDescendant_grid {B d : β„•} {Ξ± : Type*} [DecidableEq Ξ±]
(k q L j : β„•) (frame : List (Option Ξ±)) (tree : CoarseSourceTree B Ξ± d)
(draws : CoarseThresholdDraws B d) (allowance : β„š)
(hB : 0 < B) (hq : 0 < q) (hL : 0 < L)
(ha : allowance.den ∣ (L * B * q) ^ j) (start : β„•) (shift : Fin (2 * k + 1)) :
(coarseThresholdEstimate k q (1 / L) frame tree draws allowance start shift).den ∣
coarseCommonDenominator 1 q L B (j + d) := by
have h := coarseThresholdEstimate_den_dvd k q L frame tree draws allowance
((L * B * q) ^ j) hB hq hL (pow_pos (by positivity) _) ha start shift
convert h using 1
simp only [coarseCommonDenominator, one_mul, pow_add]
ring
/-- Uniform root magnitude for every descendant and pruning outcome. -/
theorem coarseDescendant_magnitude {B d : β„•} {Ξ± : Type*} [DecidableEq Ξ±]
(k q L D n : β„•) (frame : List (Option Ξ±)) (tree : CoarseSourceTree B Ξ± d)
(draws : CoarseThresholdDraws B d) (allowance : β„š)
(hB : 2 ≀ B) (hq : 0 < q) (hL : 0 < L) (hd : d ≀ D)
(hn : tree.word.length ≀ n) (ha : 0 ≀ allowance) (hak : allowance ≀ k)
(start : β„•) (shift : Fin (2 * k + 1)) :
|coarseThresholdEstimate k q (1 / L) frame tree draws allowance start shift| ≀
((n + B * k * B ^ D : β„•) : β„š) := by
have hqQ : (1 : β„š) ≀ q := by exact_mod_cast hq
have hLQ : (1 : β„š) ≀ L := by exact_mod_cast hL
have hLpos : (0 : β„š) < L := by exact_mod_cast hL
have hnode : coarseInternalNodes B d ≀ B ^ D :=
(Nat.le_of_succ_le (coarseInternalNodes_add_one_le_pow B d hB)).trans
(Nat.pow_le_pow_right (by omega) hd)
have hm := coarseThresholdEstimate_magnitude k q (1 / L) frame tree draws allowance hqQ
(by positivity) ((div_le_one hLpos).mpr hLQ) ha start shift
rw [abs_of_nonneg (coarseThresholdEstimate_nonneg k q (1 / L) frame tree draws allowance start shift
(by positivity) ha)]
apply hm.trans
have hs : (B : β„š) * allowance / q ≀ B * k := by
exact (div_le_self (by positivity) hqQ).trans
(mul_le_mul_of_nonneg_left hak (by positivity))
have hh := mul_le_mul hs (by exact_mod_cast hnode : (coarseInternalNodes B d : β„š) ≀ B ^ D)
(by positivity) (by positivity : (0 : β„š) ≀ B * k)
push_cast
exact add_le_add (by exact_mod_cast hn) hh
end EditApproximation
end OAI