Download data/lean/OAI/MeasureTheory/FalconerCompletion/Recursion/ProfileLipschitz.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/FalconerCompletion/Recursion/ProfileLipschitz.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MeasureTheory/FalconerCompletion/Recursion/ProfileLipschitz.lean
-
curl -L -o ProfileLipschitz.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/FalconerCompletion/Recursion/ProfileLipschitz.lean
16.7 kB
| import Mathlib | |
| import OAI.MeasureTheory.Falconer.Estimates.ActualDirectBuffer | |
| import OAI.MeasureTheory.Falconer.Estimates.ActualFarBuffer | |
| import OAI.MeasureTheory.Falconer.Estimates.ActualOuterMasks | |
| import OAI.MeasureTheory.Falconer.Model | |
| import OAI.MeasureTheory.Falconer.Recursion.BranchCounts | |
| import OAI.MeasureTheory.Falconer.Recursion.BranchExponent | |
| import OAI.MeasureTheory.Falconer.Recursion.BranchPotential | |
| import OAI.MeasureTheory.Falconer.Recursion.BranchTransitions | |
| import OAI.MeasureTheory.Falconer.Recursion.DirectPolicyWitness | |
| import OAI.MeasureTheory.Falconer.Recursion.InheritedPolicyState | |
| import OAI.MeasureTheory.Falconer.Recursion.InteriorPolicy | |
| import OAI.MeasureTheory.Falconer.Recursion.Ledger | |
| import OAI.MeasureTheory.Falconer.Recursion.PolicyDescriptors | |
| import OAI.MeasureTheory.Falconer.Recursion.Potential | |
| import OAI.MeasureTheory.Falconer.Recursion.SourceBranchDepth | |
| import OAI.MeasureTheory.FalconerCompletion.Recursion.HighDepthGap | |
| namespace OAI | |
| /-! Recursive policies and quantitative depth estimates. -/ | |
| open _root_.OAI.PlanarFalconer | |
| section | |
| section | |
| open Set MeasureTheory | |
| open scoped ComplexConjugate RealInnerProductSpace | |
| namespace GraphLiteralSupport | |
| namespace CurrentFalconer.DimensionalPolicy | |
| open PlanarFalconer | |
| def ProfileLipschitzND (A : β β β) (N : β) (L : β) : Prop := | |
| β i β€ N, β j β€ N, |A i-A j| β€ L*|(i:β)-j|/(N:β) | |
| lemma adjusted_profile_lipschitzND (m : β β β) {N : β} {d : β} | |
| (hN : 0 < N) (_hd : 0 β€ d) | |
| (hinc : β i j, i β€ j β j β€ N β | |
| 0 β€ m j-m i β§ m j-m i β€ d*((j:β)-i)/(N:β)) : | |
| ProfileLipschitzND (fun n => m n-(d/2)*(n:β)/N) N (d/2) := by | |
| intro i hi j hj | |
| have hNr : 0 < (N:β) := by exact_mod_cast hN | |
| rcases le_total i j with hij | hji | |
| Β· have hh := hinc i j hij hj | |
| have hdij : (i:β) β€ j := by exact_mod_cast hij | |
| rw [abs_of_nonpos (sub_nonpos.mpr hdij)] | |
| dsimp only | |
| simp only [div_eq_mul_inv] at hh β’ | |
| apply abs_le.mpr | |
| constructor <;> nlinarith [hh.1,hh.2] | |
| Β· have hh := hinc j i hji hi | |
| have hdji : (j:β) β€ i := by exact_mod_cast hji | |
| rw [abs_of_nonneg (sub_nonneg.mpr hdji)] | |
| dsimp only | |
| simp only [div_eq_mul_inv] at hh β’ | |
| apply abs_le.mpr | |
| constructor <;> nlinarith [hh.1,hh.2] | |
| lemma potential_le_final_startND {A : β β β} {N a t f Q : β} {L : β} | |
| (hN : 0 < N) (hL : 0 β€ L) (hA : ProfileLipschitzND A N L) | |
| (hQ : 0 < Q) (hw : a+Q β€ t) (ht : t β€ N) (haf : a β€ f) (hft : f β€ t) : | |
| potential A a t Q β€ 2*A f+2*L*(Q:β)/N := by | |
| have hNR : (0:β) < N := Nat.cast_pos.mpr hN | |
| have hb := potential_near_final A hQ hw haf hft (e := L*(Q:β)/N) ?_ | |
| Β· convert hb using 1; ring | |
| intro j _ hjt hjf hfj | |
| have hd : |(j:β)-f| β€ (Q:β) := by | |
| have hjR : (j:β) β€ (f:β)+Q := by exact_mod_cast hjf | |
| have hfR : (f:β) β€ (j:β)+Q := by exact_mod_cast hfj | |
| exact abs_le.mpr β¨by linarith,by linarithβ© | |
| have hh := (hA j (hjt.trans ht) f (hft.trans ht)).trans | |
| (div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hd hL) hNR.le) | |
| have hh' := (le_abs_self (A j-A f)).trans hh | |
| linarith | |
| theorem policy_costs_le_final_startND {A : β β β} {N q n offset : β} {sig L : β} | |
| (b : PolicyBranch A N q offset sig n) (hN : 0 < N) (hq : 0 < q) | |
| (hslack : sig*(N:β) β€ q) (hL : 0 β€ L) (hA : ProfileLipschitzND A N L) | |
| (hinit : (b.state 0).start+10*q β€ (b.state 0).finish) : | |
| β j β Finset.range n, branchCost A (b.state j) (b.label j) (b.state (j+1)) β€ | |
| 2*A (b.state n).start+20*L*(q:β)/N- | |
| potential A (b.state 0).start (b.state 0).finish (10*q) := by | |
| have hQ : 0 < 10*q := by omega | |
| have hfinal := BranchState.valid_depths (b.valid n le_rfl) | |
| by_cases hw : (b.state n).start+10*q β€ (b.state n).finish | |
| Β· have hc := b.costs_le_potential hq hslack hw | |
| have hf := potential_le_final_startND hN hL hA hQ hw hfinal.2 (le_refl _) hfinal.1 | |
| norm_num only [Nat.cast_mul,Nat.cast_ofNat] at hf | |
| linear_combination hc+hf | |
| Β· cases n with | |
| | zero => exact (hw hinit).elim | |
| | succ n => | |
| have hs := b.step n (by omega) | |
| have hn := hs.nested hq (b.valid n (by omega)) | |
| have hp := hs.nonterminal | |
| have hpwide : (b.state n).start+10*q β€ (b.state n).finish := by omega | |
| have hd := BranchState.valid_depths (b.valid n (by omega)) | |
| have hc := (b.initialSegment n (by omega)).costs_le_potential hq hslack hpwide | |
| dsimp only [PolicyBranch.initialSegment] at hc | |
| have hz := hs.short_cost_zero hq (b.valid n (by omega)) hslack (by omega) | |
| have hf := potential_le_final_startND hN hL hA hQ hpwide hd.2 hn.1 | |
| (hfinal.1.trans hn.2) | |
| norm_num only [Nat.cast_mul,Nat.cast_ofNat] at hf | |
| rw [Finset.sum_range_succ,hz,add_zero] | |
| linear_combination hc+hf | |
| noncomputable def branchExponentND (A : β β β) (C lam sig eps : β) | |
| (s : BranchState) (label : BranchLabel) (u : BranchState) : β := | |
| -2*(A u.start-A s.start)+branchCost A s label u+ | |
| (if label = .low then 0 else C*(lam+sig))+eps | |
| lemma branch_exponent_sumND (A : β β β) (C lam sig eps : β) | |
| (state : β β BranchState) (label : β β BranchLabel) (n : β) : | |
| (β j β Finset.range n, branchExponentND A C lam sig eps | |
| (state j) (label j) (state (j+1))) = | |
| 2*A (state 0).start-2*A (state n).start+ | |
| (β j β Finset.range n, branchCost A (state j) (label j) (state (j+1)))+ | |
| (branchNonlowCount label n:β)*(C*(lam+sig))+(n:β)*eps := by | |
| simp only [branchExponentND,Finset.sum_add_distrib] | |
| rw [profile_increments_telescope A (fun j => (state j).start) n,branch_nonlow_loss_sum] | |
| simp [branchNonlowCount,PlanarFalconer.branchNonlowCount,branchCount,PlanarFalconer.branchCount] | |
| theorem source_branch_exponentND {A : β β β} {N n offset : β} {lam sig kap eta L C : β} | |
| (hN : 0 < N) (hlam : 0 β€ lam) (hsig : 0 < sig) (hkap : 0 < kap) (hkap1 : kap β€ 1) | |
| (heta : 0 < eta) (hL : 0 β€ L) (hC : 0 β€ C) | |
| (hceil : β10*sig*(N:β)ββ < sourcePolicyBlock N kap) | |
| (hslack : sig*(N:β) β€ sourcePolicyBlock N kap) | |
| (hqratio : (sourcePolicyBlock N kap:β)/(N:β) β€ 2*kap) | |
| (hA : ProfileLipschitzND A N L) | |
| (b : PolicyBranch A N (sourcePolicyBlock N kap) offset sig n) | |
| (hinit : (b.state 0).start+10*sourcePolicyBlock N kap β€ (b.state 0).finish) : | |
| let eps := eta/(2*(1+20/kap+1/sig)) | |
| (β j β Finset.range n, branchExponentND A C lam sig eps | |
| (b.state j) (b.label j) (b.state (j+1)))+ | |
| (200*L*(sourcePolicyBlock N kap:β)/N+C*lam+eta/2) β€ | |
| 2*A (b.state 0).start-potential A (b.state 0).start (b.state 0).finish | |
| (10*sourcePolicyBlock N kap)+500*L*kap+100*C*(lam+sig)/kap+eta := by | |
| dsimp only | |
| have hq := sourcePolicyBlock_pos hN hkap | |
| have hc := policy_costs_le_final_startND b hN hq hslack hL hA hinit | |
| have hb := source_branch_count_bounds hN hsig hkap hkap1 hceil b | |
| let D : β := 1+20/kap+1/sig | |
| have hD : 0 < D := by dsimp [D]; positivity | |
| have heps : 0 β€ eta/(2*D) := by positivity | |
| have htime : (n:β)*(eta/(2*D)) β€ eta/2 := by | |
| have hn : (n:β) β€ D := by dsimp [D]; linarith [hb.2.2] | |
| calc | |
| _ β€ D*(eta/(2*D)) := mul_le_mul_of_nonneg_right hn heps | |
| _ = eta/2 := by field_simp | |
| have hloss : (branchNonlowCount b.label n:β)*(C*(lam+sig)) β€ 20*C*(lam+sig)/kap := by | |
| calc | |
| _ β€ (20/kap)*(C*(lam+sig)) := mul_le_mul_of_nonneg_right hb.1 (by positivity) | |
| _ = _ := by ring | |
| have hlamK : C*lam β€ C*(lam+sig)/kap := by | |
| apply (le_div_iffβ hkap).mpr | |
| have hh := mul_le_mul_of_nonneg_left hkap1 (mul_nonneg hC hlam) | |
| have hcs := mul_nonneg hC hsig.le | |
| nlinarith | |
| have hbudget : 0 β€ C*(lam+sig)/kap := by positivity | |
| have hwidth := mul_le_mul_of_nonneg_left hqratio (show 0 β€ 220*L by positivity) | |
| have hLK : 0 β€ L*kap := by positivity | |
| rw [branch_exponent_sumND] | |
| dsimp only [D] at htime | |
| simp only [mul_div_assoc] at hc hloss hlamK hbudget hwidth β’ | |
| nlinarith | |
| theorem uniform_source_branch_exponentND (offset : β) {lam sig kap eta L C : β} | |
| (hlam : 0 β€ lam) (hsig : 0 < sig) (hkap : 0 < kap) (hkap1 : kap β€ 1) | |
| (hgap : sig < kap/1000) (heta : 0 < eta) (hL : 0 β€ L) (hC : 0 β€ C) : | |
| β Nβ : β, 0 < Nβ β§ β N β₯ Nβ, β A : β β β, | |
| ProfileLipschitzND A N L β β n : β, | |
| β b : PolicyBranch A N (sourcePolicyBlock N kap) offset sig n, | |
| (b.state 0).start+10*sourcePolicyBlock N kap β€ (b.state 0).finish β | |
| (β j β Finset.range n, branchExponentND A C lam sig (eta/(2*(1+20/kap+1/sig))) | |
| (b.state j) (b.label j) (b.state (j+1)))+ | |
| (200*L*(sourcePolicyBlock N kap:β)/N+C*lam+eta/2) β€ | |
| 2*A (b.state 0).start-potential A (b.state 0).start (b.state 0).finish | |
| (10*sourcePolicyBlock N kap)+500*L*kap+100*C*(lam+sig)/kap+eta := by | |
| obtain β¨Nβ,hNβ,hββ© := uniform_source_ceiling_slack hsig hgap | |
| obtain β¨Nβ,hNββ© := exists_nat_gt (1/kap) | |
| refine β¨max Nβ Nβ,by omega,?_β© | |
| intro N hN A hA n b hi | |
| have hNp : 0 < N := by omega | |
| have hNR : (0:β) < N := Nat.cast_pos.mpr hNp | |
| have hkn : 1 < kap*(N:β) := by | |
| have hh := (div_lt_iffβ hkap).mp (hNβ.trans_le (Nat.cast_le.mpr (show Nβ β€ N by omega))) | |
| linarith | |
| have hq : (sourcePolicyBlock N kap:β) < kap*N+1 := | |
| Nat.ceil_lt_add_one (mul_nonneg hkap.le hNR.le) | |
| have hqr : (sourcePolicyBlock N kap:β)/(N:β) β€ 2*kap := | |
| (div_le_iffβ hNR).mpr (by linarith) | |
| exact source_branch_exponentND hNp hlam hsig hkap hkap1 heta hL hC | |
| (hβ N (by omega)).1 (hβ N (by omega)).2.2 hqr hA b hi | |
| end CurrentFalconer.DimensionalPolicy | |
| end GraphLiteralSupport | |
| end | |
| end | |
| section | |
| section | |
| open Set MeasureTheory | |
| open scoped ComplexConjugate RealInnerProductSpace | |
| namespace GraphLiteralSupport | |
| namespace CurrentFalconer.DimensionalPolicy | |
| open PlanarFalconer | |
| theorem BranchStep.strict_progress {A : β β β} {N q offset : β} {sig : β} | |
| (hN : 0 < N) (hq : 0 < q) (hsig : 0 < sig) | |
| {s u : BranchState} {label : BranchLabel} | |
| (h : BranchStep A N q offset sig s label u) (hv : s.Valid N sig) : | |
| s.start < u.start β¨ u.finish < s.finish := by | |
| cases h with | |
| | suffix hw hs => | |
| have hp := policyDepth_interior A hq (policyBlocks_nonempty hq hv.2 hw) | |
| right | |
| dsimp [BranchState.finish] | |
| omega | |
| | @low a t i v hw hm hg => | |
| right | |
| have hpos : 0 < sig*(N:β) := mul_pos hsig (Nat.cast_pos.mpr hN) | |
| dsimp [BranchState.finish] | |
| exact_mod_cast (show (v : β) < t by linarith [hg]) | |
| | high hw hs hm hg => | |
| have hp := policyDepth_interior A hq (policyBlocks_nonempty hq hv.2 hw) | |
| left | |
| dsimp [BranchState.start] | |
| omega | |
| | near hw hs => exact Or.inl hs | |
| | far hw hs hm => | |
| left | |
| have hh := (Finset.mem_Icc.mp hm).1 | |
| dsimp [BranchState.start] | |
| omega | |
| | direct hw hd => exact Or.inl hd.anchor_gt | |
| theorem BranchStep.width_decreases {A : β β β} {N q offset : β} {sig : β} | |
| (hN : 0 < N) (hq : 0 < q) (hsig : 0 < sig) | |
| {s u : BranchState} {label : BranchLabel} | |
| (h : BranchStep A N q offset sig s label u) (hv : s.Valid N sig) | |
| (hu : u.Valid N sig) : | |
| u.finish-u.start < s.finish-s.start := by | |
| have hn := h.nested hq hv | |
| have hp := h.strict_progress hN hq hsig hv | |
| have hd := BranchState.valid_depths hu | |
| omega | |
| theorem valid_step_wellFounded (A : β β β) {N q offset : β} {sig : β} | |
| (hN : 0 < N) (hq : 0 < q) (hsig : 0 < sig) : | |
| WellFounded (fun (u s : {s : BranchState // s.Valid N sig}) => | |
| β label, BranchStep A N q offset sig s.1 label u.1) := by | |
| apply Subrelation.wf (r := (measure fun (s : {s : BranchState // s.Valid N sig}) => | |
| s.1.finish-s.1.start).rel) ?_ (measure _).wf | |
| intro u s h | |
| obtain β¨label,hhβ© := h | |
| exact hh.width_decreases hN hq hsig s.2 u.2 | |
| theorem nonterminal_has_step (A : β β β) {N q offset : β} {sig : β} | |
| (hN : 0 < N) (hq : 0 < q) (hsig : 0 < sig) | |
| (hceil : β10*sig*(N:β)ββ < q) | |
| (hslack : sig*(N:β) β€ q) (hslack10 : 10*sig*(N:β) β€ q) | |
| (s : BranchState) (hv : s.Valid N sig) (hw : s.start+100*q < s.finish) : | |
| β label u, BranchStep A N q offset sig s label u := by | |
| cases s with | |
| | D a t i => | |
| by_cases hs : a+t < 2*policyDepth A N q a t | |
| Β· exact β¨.suffix,_,.suffix hw hsβ© | |
| Β· refine β¨.high,_,.high (v := t) hw (by omega) ?_ ?_β© | |
| Β· exact Finset.mem_Ioc.mpr β¨by change a+100*q<t at hw; omega,le_rflβ© | |
| Β· have hh : 0 < sig*(N:β) := mul_pos hsig (Nat.cast_pos.mpr hN) | |
| simpa only [sub_self] using hh | |
| | H aβ tβ a t i => | |
| by_cases hh : a < (BranchState.H aβ tβ a t i).nearDepth A N q sig | |
| Β· exact β¨.near,_,.near hw hhβ© | |
| Β· have hdir : t-2*sourceFarBuffer N | |
| ((remainingPolicyDescriptors A N q aβ tβ a).sup descriptorLength) sig β€ a := by | |
| simpa only [BranchState.nearDepth,BranchState.finish,BranchState.descriptors] using | |
| (not_lt.mp hh) | |
| obtain β¨e,heβ© := actual_direct_policy_witness A hsig.le hq hceil hslack hslack10 | |
| hv.2.2.2.2 hw hdir | |
| exact β¨.direct,_,.direct hw heβ© | |
| namespace PolicyBranch | |
| def prepend {A : β β β} {N q offset n : β} {sig : β} | |
| (b : PolicyBranch A N q offset sig n) (s : BranchState) (label : BranchLabel) | |
| (hs : s.Valid N sig) (hstep : BranchStep A N q offset sig s label (b.state 0)) : | |
| PolicyBranch A N q offset sig (n+1) where | |
| state := fun j => match j with | 0 => s | k+1 => b.state k | |
| label := fun j => match j with | 0 => label | k+1 => b.label k | |
| valid := by | |
| intro j hj | |
| cases j with | |
| | zero => exact hs | |
| | succ k => exact b.valid k (by omega) | |
| step := by | |
| intro j hj | |
| cases j with | |
| | zero => exact hstep | |
| | succ k => exact b.step k (by omega) | |
| end PolicyBranch | |
| theorem exists_terminal_branch (A : β β β) {N q offset : β} {sig : β} | |
| (hN : 0 < N) (hq : 0 < q) (hsig : 0 < sig) | |
| (hceil : β10*sig*(N:β)ββ < q) | |
| (hslack : sig*(N:β) β€ q) (hslack10 : 10*sig*(N:β) β€ q) | |
| (hbuffer : β L t a : β, a < t-2*sourceFarBuffer N L sig β | |
| t-2*sourceFarBuffer N L sig+offset < t) | |
| (s : BranchState) (hs : s.Valid N sig) : | |
| β n, β b : PolicyBranch A N q offset sig n, | |
| b.state 0 = s β§ (b.state n).finish β€ (b.state n).start+100*q := by | |
| have wf := valid_step_wellFounded A (offset := offset) hN hq hsig | |
| suffices hh : β x : {s : BranchState // s.Valid N sig}, | |
| β n, β b : PolicyBranch A N q offset sig n, | |
| b.state 0 = x.1 β§ (b.state n).finish β€ (b.state n).start+100*q from hh β¨s,hsβ© | |
| intro x | |
| induction x using wf.induction with | |
| | h x ih => | |
| by_cases hw : x.1.start+100*q < x.1.finish | |
| Β· obtain β¨label,u,huβ© := nonterminal_has_step A hN hq hsig hceil hslack hslack10 x.1 x.2 hw | |
| have huv := hu.valid_successor hq hslack hbuffer x.2 | |
| obtain β¨n,b,hb,htβ© := ih β¨u,huvβ© β¨label,huβ© | |
| have hh : BranchStep A N q offset sig x.1 label (b.state 0) := by rw [hb]; exact hu | |
| exact β¨n+1,b.prepend x.1 label x.2 hh,rfl,htβ© | |
| Β· let b : PolicyBranch A N q offset sig 0 := | |
| β¨fun _ => x.1,fun _ => .near,fun _ _ => x.2,fun j hj => (Nat.not_lt_zero j hj).elimβ© | |
| exact β¨0,b,rfl,not_lt.mp hwβ© | |
| theorem uniform_terminal_branch (offset : β) {sig kap : β} | |
| (hsig : 0 < sig) (hkap : 0 < kap) (hkap1 : kap β€ 1) (hgap : sig < kap/1000) : | |
| β Nβ : β, 0 < Nβ β§ β N β₯ Nβ, β A : β β β, β s : BranchState, | |
| s.Valid N sig β s.index = 0 β | |
| β n, β b : PolicyBranch A N (sourcePolicyBlock N kap) offset sig n, | |
| b.state 0 = s β§ (b.state n).finish β€ (b.state n).start+100*sourcePolicyBlock N kap β§ | |
| (branchNonlowCount b.label n:β) β€ 20/kap β§ | |
| (branchCount b.label n .low:β) β€ 1/sig β§ (n:β) β€ 20/kap+1/sig β§ | |
| β j β€ n, (b.state j).index+1 < sourceSmoothingLevels sig kap := by | |
| obtain β¨Nβ,hNβ,hββ© := uniform_source_ceiling_slack hsig hgap | |
| obtain β¨Nβ,hββ© := uniform_far_offset_buffer hsig offset | |
| refine β¨max Nβ Nβ,by omega,?_β© | |
| intro N hN A s hs hi | |
| have hNp : 0 < N := by omega | |
| have hq := sourcePolicyBlock_pos hNp hkap | |
| obtain β¨hc,hs10,hslβ© := hβ N (by omega) | |
| obtain β¨n,b,hb,htβ© := exists_terminal_branch A hNp hq hsig hc hsl hs10 | |
| (hβ N (by omega)) s hs | |
| have hcounts := source_branch_count_bounds hNp hsig hkap hkap1 hc b | |
| refine β¨n,b,hb,ht,hcounts.1,hcounts.2.1,hcounts.2.2,?_β© | |
| intro j hj | |
| exact (source_branch_index_bound hNp hsig hkap hkap1 hc b (by rw [hb]; exact hi) hj).2 | |
| end CurrentFalconer.DimensionalPolicy | |
| end GraphLiteralSupport | |
| end | |
| end | |
| end OAI | |