import Mathlib import OAI.MeasureTheory.Falconer.Estimates.ActualFarBuffer import OAI.MeasureTheory.Falconer.Geometry.BinBands import OAI.MeasureTheory.Falconer.Model import OAI.MeasureTheory.Falconer.Recursion.BranchTransitions import OAI.MeasureTheory.Falconer.Recursion.InteriorPolicy import OAI.MeasureTheory.Falconer.Recursion.Ledger import OAI.MeasureTheory.Falconer.Recursion.PolicyDescriptors import OAI.MeasureTheory.FalconerCompletion.Angular.PowerDivCap import OAI.MeasureTheory.FalconerCompletion.Recursion.OccupiedDescendantPath import OAI.MeasureTheory.FalconerCompletion.Recursion.RecursiveUnit import OAI.MeasureTheory.FalconerCompletion.Shells.PrefixHighShell namespace OAI /-! Recursive policies and quantitative depth estimates. -/ open _root_.OAI.PlanarFalconer section section open Set MeasureTheory open scoped ComplexConjugate RealInnerProductSpace namespace GraphLiteralSupport.CurrentFalconer.TreeND open Set MeasureTheory Filter PlanarFalconer open scoped ContDiff Classical variable {n : ℕ} theorem uniform_recursive_suffix_rule {sig : ℝ} (hsig : 0 recursiveUnit_jets l w) (fun l _ w _ => recursiveUnit_jets l w) let p := descriptorAnchor b let exponent := DimensionalPolicy.branchExponentND e.profile (recursiveLoss n e.C) sig sig eps (.H a₀ t₀ a v i) .direct (.H a₀ t₀ p v i) have hstep : DimensionalPolicy.BranchStep e.profile e.N e.q offset sig (.H a₀ t₀ a v i) .direct (.H a₀ t₀ p v i) := .direct hw hb have hRp : 0<((2:ℝ)^e.N)^exponent := by positivity have hcap : r.reachedChildren p L₁ L₂ f g recursiveUnit recursiveUnit Ψ≤M/((2:ℝ)^e.N)^exponent := by apply r.reachedChildren_le _ _ _ _ _ _ _ _ _ (by positivity) intro U V hU hV hou hov have hh := hchildren _ _ hstep _ (r.successor_energy_mem K W total Ψ p U V hU hV hou hov L₁ L₂ f g hf hg hfn hgn hw₁ hw₂ ht₁ ht₂) exact (le_div_iff₀ hRp).mpr (by simpa only [mul_comm] using hh) have hr := hrem e.N (by omega) r rfl he (show IsFiniteMeasure e.ρ from inferInstance) hq p hb.anchor_gt.le L₁ L₂ f g recursiveUnit recursiveUnit hf hg hfn hgn hw₁ hw₂ ht₁ ht₂ (fun _ _ => by norm_num [recursiveUnit]) (fun _ _ => by norm_num [recursiveUnit]) Ψ (hiΨ.comp_div (by positivity)) hΨ0 have hr' := hr.trans (mul_le_mul_of_nonneg_left hcap (by positivity : 0≤D^(4*total))) have heq : r.graphFactor p=((2:ℝ)^e.N)^(-2*(e.profile p-e.profile a)+height e.profile a p+ (e.C+36*(n+1:ℝ)+5)*sig) := by simp only [RecursiveAngularND.graphFactor,r,RecursiveEnvironmentND.angularData,he]; rfl have hexp : -2*(e.profile p-e.profile a)+height e.profile a p+(e.C+36*(n+1:ℝ)+5)*sig≤exponent := by unfold exponent DimensionalPolicy.branchExponentND DimensionalPolicy.branchCost simp only [BranchState.start,show BranchLabel.direct ≠ .low by decide,↓reduceIte] have hh := mul_le_mul_of_nonneg_right (recursiveLoss_graph n e.C) hsig.le nlinarith have hpay : r.graphFactor p*(M/((2:ℝ)^e.N)^exponent)≤M := by rw [heq]; exact power_div_cap hM hexp have hgain : r.graphFactor p*r.sameSymbolChildren p L₁ L₂ f g recursiveUnit recursiveUnit Ψ≤D^(4*total)*M := by calc _≤r.graphFactor p*(D^(4*total)*(M/((2:ℝ)^e.N)^exponent)) := mul_le_mul_of_nonneg_left hr' (by rw [heq]; positivity) _=D^(4*total)*(r.graphFactor p*(M/((2:ℝ)^e.N)^exponent)) := by ring _≤D^(4*total)*M := mul_le_mul_of_nonneg_left hpay (by positivity) exact hgraph.trans (add_le_add hgain le_rfl) end GraphLiteralSupport.CurrentFalconer.TreeND end end section section open Set MeasureTheory open scoped ComplexConjugate RealInnerProductSpace namespace GraphLiteralSupport.CurrentFalconer.TreeND open Set MeasureTheory Filter PlanarFalconer open scoped ContDiff Classical variable {n : ℕ} theorem uniform_recursive_near_far_rule (Ψ : ℝ → ℝ) (hΨ : ContDiff ℝ ∞ Ψ) (hsupp : tsupport Ψ⊆Ioo (1/4:ℝ) 4) (hΨ0 : ∀ r,0≤Ψ r) {sig : ℝ} (hsig : 0 DimensionalPolicy.branchExponentND e.profile (recursiveLoss n e.C) sig sig eps (.H a₀ t₀ a v i) .far (.D b v (i+1)) have hhv : h+ell+2.sup descriptorLength) v a hnear simpa only [h,BranchState.nearDepth,BranchState.finish,Nat.add_assoc] using hh have hhN : h+ell+2≤e.N := (Nat.le_of_lt hhv).trans (hv.2.2.1.trans hv.2.2.2.1) have hdepth : ((h+ell+2:ℕ):ℝ)≤(v:ℝ)-2*(max ((r.retainedList a).sup descriptorLength) (Nat.ceil (10*sig*e.N)):ℕ)+(ell+2:ℝ) := by let b := sourceFarBuffer e.N (((BranchState.H a₀ t₀ a v i).descriptors e.profile e.N e.q).sup descriptorLength) sig have hh : h=v-2*b := rfl have hvb : 2*b≤v := by dsimp only [h] at hh; omega have hh' : (h:ℝ)=(v:ℝ)-2*(b:ℝ) := by rw [hh,Nat.cast_sub hvb]; push_cast; rfl change ((h+ell+2:ℕ):ℝ)≤(v:ℝ)-2*(b:ℝ)+(ell+2:ℝ) push_cast linarith have hncap (U V : CellPath (n+1)) (hU : U∈dyadicPaths h) (hV : V∈dyadicPaths h) (hou : 0 (pathIndex U j:ℤ)) (fun j => (pathIndex V j:ℤ))) : (e.distanceData b v (i+1) U V).coincidence.toReal≤M/((2:ℝ)^e.N)^(expf b) := by have hh := hchildren _ _ (.far hw hnear (by simpa only [Nat.add_assoc] using hb)) _ (e.distance_mem ((2:ℝ)^ell) W total Ψ b v (i+1) U V hU hV hou hov hs) exact (le_div_iff₀ (by positivity : 0<((2:ℝ)^e.N)^(expf b))).mpr (by simpa only [mul_comm] using hh) have hb := hnf r (show N₁≤e.N by omega) he hJe B₀ s hd hq hv.2.2.2.1 hv.1 hv.2.2.1 h hnear hhN hdepth hX hY hox hoy L₁ L₂ f g recursiveUnit recursiveUnit (M/((2:ℝ)^e.N)^expn) (fun b => M/((2:ℝ)^e.N)^(expf b)) hf hg hfn hgn hw₁ hw₂ ht₁ ht₂ (fun l _ w _ => recursiveUnit_jets l w) (fun l _ w _ => recursiveUnit_jets l w) hncap (fun _ _ => by positivity) hfcap have hdim := mul_le_mul_of_nonneg_right (recursiveLoss_dim n e.C) hsig.le have hnexp : -2*(e.profile h-e.profile a)+4*(n+2:ℝ)*sig≤expn := by dsimp only [expn,DimensionalPolicy.branchExponentND,DimensionalPolicy.branchCost,BranchState.start] simp only [show BranchLabel.near ≠ .low by decide,↓reduceIte] nlinarith have hfexp (b : ℕ) : -2*(e.profile b-e.profile a)+4*(n+2:ℝ)*sig≤expf b := by dsimp only [expf,DimensionalPolicy.branchExponentND,DimensionalPolicy.branchCost,BranchState.start] simp only [show BranchLabel.far ≠ .low by decide,↓reduceIte] nlinarith have hnpay := power_div_cap (N:=e.N) hM hnexp have hfpay : (∑ b∈Finset.Icc (a+1) (h+ell+2),((2:ℝ)^e.N)^(-2*(e.profile b-e.profile a)+4*(n+2:ℝ)*sig)* (M/((2:ℝ)^e.N)^(expf b)))≤(e.N:ℝ)*M := by calc _≤∑ b∈Finset.Icc (a+1) (h+ell+2),M := Finset.sum_le_sum (fun b _ => power_div_cap hM (hfexp b)) _=((Finset.Icc (a+1) (h+ell+2)).card:ℝ)*M := by simp _≤(e.N:ℝ)*M := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (by rw [Nat.card_Icc]; omega)) hM have hbound : Cnear*(((2:ℝ)^e.N)^(-2*(e.profile h-e.profile a)+4*(n+2:ℝ)*sig)*(M/((2:ℝ)^e.N)^expn))+ H*(∑ b∈Finset.Icc (a+1) (h+ell+2),((2:ℝ)^e.N)^(-2*(e.profile b-e.profile a)+4*(n+2:ℝ)*sig)*(M/((2:ℝ)^e.N)^(expf b)))≤ (Cnear+H)*((e.N:ℝ)+1)*M := by have hh₁ := mul_le_mul_of_nonneg_left hnpay (by dsimp only [Cnear]; positivity : 0≤Cnear) have hh₂ := mul_le_mul_of_nonneg_left hfpay hH have hh₃ : 0≤Cnear*(e.N:ℝ)*M+H*M := by dsimp only [Cnear]; positivity nlinarith only [hh₁,hh₂,hh₃] have hb' : (e.angularData a₀ t₀ a v i X Y).energy L₁ L₂ f g recursiveUnit recursiveUnit Ψ ≤ Cnear*(((2:ℝ)^e.N)^(-2*(e.profile h-e.profile a)+4*(n+2:ℝ)*sig)*(M/((2:ℝ)^e.N)^expn))+ H*(∑ b∈Finset.Icc (a+1) (h+ell+2),((2:ℝ)^e.N)^(-2*(e.profile b-e.profile a)+4*(n+2:ℝ)*sig)*(M/((2:ℝ)^e.N)^(expf b)))+ ((2:ℝ)^e.N)^(-T) := by simpa only [r,RecursiveEnvironmentND.angularData,RecursiveAngularND.profile,Cnear,mul_assoc] using hb exact hb'.trans (add_le_add hbound le_rfl) end GraphLiteralSupport.CurrentFalconer.TreeND end end end OAI