Download data/lean/OAI/Geometry/Cannon/Flows/Node.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 26.2 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/Cannon/Flows/Node.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/Cannon/Flows/Node.lean
-
curl -L -o Node.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/Cannon/Flows/Node.lean
26.2 kB
| import Mathlib | |
| import OAI.Geometry.Cannon.Flows.GoodCandidates | |
| import OAI.Geometry.Cannon.Modulus.AnnularNet | |
| import OAI.Geometry.Cannon.CirclePacking.Radius | |
| namespace OAI | |
| section | |
| section | |
| section | |
| noncomputable section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| namespace CannonNode | |
| open Set Metric | |
| structure SourceNode {X : Type*} [MetricSpace X] (f : X β β) (xβ : X) | |
| (Ξ΅ ell cβ B : β) (kmin : β) where | |
| center : X | |
| depth : β | |
| lowerDepth : kmin β€ depth | |
| a : β | |
| b : β | |
| apos : 0 < a | |
| ab : a < b | |
| bone : b < 1 | |
| straddle : lower f center (cβ*radius ell depth) β€ a β§ | |
| b β€ upper f center (cβ*radius ell depth) | |
| reserve : dist center xβ+2*B*radius ell depth β€ Ξ΅ | |
| variable {X : Type*} [MetricSpace X] {f : X β β} {xβ : X} | |
| {Ξ΅ ell cβ B : β} {kmin : β} | |
| namespace SourceNode | |
| def length (v : SourceNode f xβ Ξ΅ ell cβ B kmin) : β := v.b-v.a | |
| lemma length_pos (v : SourceNode f xβ Ξ΅ ell cβ B kmin) : 0 < v.length := sub_pos.mpr v.ab | |
| def child (v : SourceNode f xβ Ξ΅ ell cβ B kmin) (D : β) (y : X) | |
| (hB : 0 β€ B) (hΞΈ : radius ell D β€ 1/2) | |
| (hy : dist y v.center β€ B*radius ell v.depth) | |
| (ht : 0 < fraction v.a v.b (lower f y (cβ*radius ell (v.depth+D))) | |
| (upper f y (cβ*radius ell (v.depth+D)))) : | |
| SourceNode f xβ Ξ΅ ell cβ B kmin where | |
| center := y | |
| depth := v.depth+D | |
| lowerDepth := v.lowerDepth.trans (Nat.le_add_right _ _) | |
| a := childLower v.a (lower f y (cβ*radius ell (v.depth+D))) | |
| b := childUpper v.b (upper f y (cβ*radius ell (v.depth+D))) | |
| apos := v.apos.trans_le (le_max_left _ _) | |
| ab := (fraction_pos_iff v.ab).mp ht | |
| bone := (min_le_left _ _).trans_lt v.bone | |
| straddle := β¨le_max_right _ _,min_le_right _ _β© | |
| reserve := by | |
| have hR := radius_pos ell v.depth | |
| have htR := mul_le_mul_of_nonneg_right hΞΈ hR.le | |
| have hB' := mul_le_mul_of_nonneg_left htR (mul_nonneg (by norm_num : (0:β) β€ 2) hB) | |
| have htri := dist_triangle y v.center xβ | |
| rw [radius_add] | |
| nlinarith only [v.reserve,hy,htri,hB'] | |
| lemma child_length (v : SourceNode f xβ Ξ΅ ell cβ B kmin) (D : β) (y : X) | |
| (hB : 0 β€ B) (hΞΈ : radius ell D β€ 1/2) | |
| (hy : dist y v.center β€ B*radius ell v.depth) | |
| (ht : 0 < fraction v.a v.b (lower f y (cβ*radius ell (v.depth+D))) | |
| (upper f y (cβ*radius ell (v.depth+D)))) : | |
| (v.child D y hB hΞΈ hy ht).length = v.length * | |
| fraction v.a v.b (lower f y (cβ*radius ell (v.depth+D))) | |
| (upper f y (cβ*radius ell (v.depth+D))) := by | |
| exact positive_child_length v.ab ht | |
| lemma center_mem (v : SourceNode f xβ Ξ΅ ell cβ B kmin) (hB : 0 β€ B) : | |
| v.center β closedBall xβ Ξ΅ := by | |
| have hh : 0 β€ 2*B*radius ell v.depth := mul_nonneg (mul_nonneg (by norm_num) hB) (radius_pos ell v.depth).le | |
| exact mem_closedBall.mpr (by linarith only [v.reserve,hh]) | |
| lemma root (k : β) (hk : kmin β€ k) (a b : β) (ha : 0 < a) | |
| (hab : a < b) (hb : b < 1) | |
| (hs : lower f xβ (cβ*radius ell k) β€ a β§ b β€ upper f xβ (cβ*radius ell k)) | |
| (hroom : 2*B*radius ell k β€ Ξ΅) : | |
| Nonempty (SourceNode f xβ Ξ΅ ell cβ B kmin) := | |
| β¨β¨xβ,k,hk,a,b,ha,hab,hb,hs,by simpa only [dist_self,zero_add] using hroomβ©β© | |
| end SourceNode | |
| end CannonNode | |
| end | |
| section | |
| open Set Metric | |
| namespace CannonMagnification | |
| def Expansion {X : Type*} [MetricSpace X] (h : X ββ X) (x : X) | |
| (r C L : β) : Prop := | |
| β y z, | |
| dist (h y) (h z) * max r (dist x y) * max r (dist x z) β€ C*r*dist y z β§ | |
| r*dist y z β€ L*dist (h y) (h z) * max r (dist x y) * max r (dist x z) | |
| lemma expansion_ball_bounds {X : Type*} [MetricSpace X] (h : X ββ X) | |
| (x : X) (r C L B : β) (hr : 0 < r) (hL : 0 < L) (hB : 1 β€ B) | |
| (hexp : Expansion h x r C L) (y z : X) | |
| (hy : dist y x β€ B*r) (hz : dist z x β€ B*r) : | |
| dist (h y) (h z) β€ C/r*dist y z β§ | |
| (1/(L*B^2))/r*dist y z β€ dist (h y) (h z) := by | |
| have hE : 0 β€ dist (h y) (h z) := dist_nonneg | |
| have hBr : r β€ B*r := by nlinarith | |
| have hby : max r (dist x y) β€ B*r := max_le hBr (by simpa only [dist_comm] using hy) | |
| have hbz : max r (dist x z) β€ B*r := max_le hBr (by simpa only [dist_comm] using hz) | |
| have hmy : 0 β€ max r (dist x y) := hr.le.trans (le_max_left _ _) | |
| have hmz : 0 β€ max r (dist x z) := hr.le.trans (le_max_left _ _) | |
| have hβ : dist (h y) (h z)*r*r β€ C*r*dist y z := by | |
| exact (mul_le_mul (mul_le_mul_of_nonneg_left (le_max_left _ _) hE) | |
| (le_max_left _ _) hr.le (mul_nonneg hE hmy)).trans (hexp y z).1 | |
| have hβ : r*dist y z β€ L*dist (h y) (h z)*(B*r)*(B*r) := by | |
| exact (hexp y z).2.trans (mul_le_mul (mul_le_mul_of_nonneg_left hby (mul_nonneg hL.le hE)) | |
| hbz hmz (by positivity)) | |
| constructor | |
| Β· rw [div_mul_eq_mul_div] | |
| apply (le_div_iffβ hr).mpr | |
| have hh : (dist (h y) (h z)*r)*r β€ (C*dist y z)*r := by nlinarith [hβ] | |
| exact (mul_le_mul_iff_leftβ hr).mp hh | |
| Β· have hden : 0 < L*B^2*r := mul_pos (mul_pos hL (sq_pos_of_pos (zero_lt_one.trans_le hB))) hr | |
| have hraw : dist y z β€ dist (h y) (h z)*(L*B^2*r) := by | |
| apply (mul_le_mul_iff_leftβ hr).mp | |
| nlinarith [hβ] | |
| have hdiv : dist y z/(L*B^2*r) β€ dist (h y) (h z) := (div_le_iffβ hden).mpr hraw | |
| convert hdiv using 1; ring | |
| end CannonMagnification | |
| end | |
| section | |
| open Set Metric | |
| namespace CannonNode | |
| open Set Metric | |
| theorem node_level_hits {X : Type*} [MetricSpace X] [ProperSpace X] | |
| (f : X β β) (Ξ© : Set X) (K : β β Set X) (x : X) (R cβ L a b : β) | |
| (hR : 0 < R) (hcβ : 0 < cβ) (hL : 1 β€ L) | |
| (hf : ContinuousOn f Ξ©) (hloc : closedBall x (L*cβ*R) β Ξ©) | |
| (hnode : lower f x (cβ*R) β€ a β§ b β€ upper f x (cβ*R)) | |
| (hpaths : β u v, u β closedBall x (cβ*R) β v β closedBall x (cβ*R) β | |
| JoinedIn (ball x (L*cβ*R)) u v) | |
| (hhit : β t β Ioo a b, β u v, β p : Path u v, Set.range p β Ξ© β | |
| f u < t β t < f v β (K t β© Set.range p).Nonempty) : | |
| β t β Ioo a b, β y β K t, dist y x β€ L*cβ*R := by | |
| have hsub : closedBall x (cβ*R) β closedBall x (L*cβ*R) := | |
| closedBall_subset_closedBall (by nlinarith only [hL,mul_pos hcβ hR]) | |
| obtain β¨β¨u,hu,huvβ©,β¨v,hv,hvvβ©β© := ball_extrema (mul_pos hcβ hR).le (hf.mono (hsub.trans hloc)) | |
| obtain β¨p,hpβ© := hpaths u v hu hv | |
| have hpΞ© : range p β Ξ© := by | |
| rintro _ β¨t,rflβ© | |
| exact hloc (ball_subset_closedBall (hp t)) | |
| intro t ht | |
| have hu' : f u < t := by rw [huv]; exact hnode.1.trans_lt ht.1 | |
| have hv' : t < f v := by rw [hvv]; exact ht.2.trans_le hnode.2 | |
| obtain β¨z,hz,β¨s,rflβ©β© := hhit t ht u v p hpΞ© hu' hv' | |
| exact β¨p s,hz,(mem_ball.mp (hp s)).leβ© | |
| lemma exists_node_interval {X : Type*} [MetricSpace X] [ProperSpace X] | |
| (f : X β β) (x : X) (r : β) (hr : 0 β€ r) | |
| (hf : ContinuousOn f (closedBall x r)) | |
| (hunit : β y β closedBall x r, f y β Icc (0:β) 1) | |
| (hvar : β y β closedBall x r, β z β closedBall x r, f y β f z) : | |
| β a b : β, 0 < a β§ a < b β§ b < 1 β§ lower f x r < a β§ b < upper f x r := by | |
| obtain β¨β¨v,hv,hvvβ©,β¨w,hw,hwwβ©β© := ball_extrema hr hf | |
| have hlu : lower f x r < upper f x r := by | |
| obtain β¨y,hy,z,hz,hneqβ© := hvar | |
| have hylu := ball_range hf hy | |
| have hzlu := ball_range hf hz | |
| by_contra hn | |
| have hh := le_of_not_gt hn | |
| have hyz : f y=f z := by linarith only [hylu.1,hylu.2,hzlu.1,hzlu.2,hh] | |
| exact hneq hyz | |
| have hl : 0 β€ lower f x r := by rw [β hvv]; exact (hunit v hv).1 | |
| have hu : upper f x r β€ 1 := by rw [β hww]; exact (hunit w hw).2 | |
| refine β¨(2*lower f x r+upper f x r)/3,(lower f x r+2*upper f x r)/3,?_,?_,?_,?_,?_β© <;> | |
| linarith only [hlu,hl,hu] | |
| end CannonNode | |
| end | |
| namespace CannonNode | |
| open Set Metric Finset Filter Topology CannonPacking CannonAnnular CannonMagnification | |
| attribute [local instance] Classical.propDecidable | |
| def LiteralGood {X : Type*} [MetricSpace X] (f : X β β) (Y : Finset X) | |
| (cβ r a b ΞΊ : β) : Prop := | |
| GoodCandidates (fun y : Y => lower f y (2*r)) (fun y : Y => upper f y (2*r)) | |
| (fun y : Y => lower f y (cβ*r)) (fun y : Y => upper f y (cβ*r)) a b ΞΊ | |
| def LiteralTransitions {X : Type*} [MetricSpace X] (f : X β β) (Y : Finset X) | |
| (cβ r a b ΞΊ H L Qg Qb : β) : Prop := | |
| β S : Finset Y, | |
| (β y β S, 0 < fraction a b (lower f y (cβ*r)) (upper f y (cβ*r))) β§ | |
| (β y β S, β z β S, y β z β H*r < dist (y:X) z) β§ | |
| β p : S β β, (β y, 0 < p y) β§ (β y, p y = 1) β§ | |
| (β y, p y β€ L*fraction a b (lower f (y.val:X) (cβ*r)) (upper f (y.val:X) (cβ*r))) β§ | |
| β y, p y β€ (if LiteralGood f Y cβ r a b ΞΊ then Qg else Qb)* | |
| (fraction a b (lower f (y.val:X) (cβ*r)) (upper f (y.val:X) (cβ*r)))^2 | |
| lemma candidate_slack {X : Type*} [MetricSpace X] (Q : β) (CP B ell : β) | |
| (hCP : 0 β€ CP) (hB : 0 β€ B) (D : β) : | |
| β ΞΊ : β, 0 < ΞΊ β§ β (Y : Finset X) (R r : β), 0 < r β | |
| (Y.card:β) β€ CP*((B+1)*R/r)^Q β R/r=Real.exp (ell*D) β | |
| (Y.card:β)*ΞΊ β€ 1/8 := by | |
| let C := CP*(B+1)^Q | |
| have hC : 0 β€ C := by dsimp [C]; positivity | |
| let E := Real.exp (ell*D)^Q | |
| have hE : 0 < E := pow_pos (Real.exp_pos _) _ | |
| let ΞΊ := 1/(8*max C 1*E) | |
| have hmax : 0 < max C 1 := zero_lt_one.trans_le (le_max_right _ _) | |
| have hden : 0 < 8*max C 1*E := by positivity | |
| refine β¨ΞΊ,one_div_pos.mpr hden,?_β© | |
| intro Y R r _hr hcard hratio | |
| have hcard' : (Y.card:β) β€ C*E := by | |
| convert hcard using 1 | |
| rw [mul_div_assoc, hratio,mul_pow] | |
| dsimp [C,E] | |
| ring | |
| have hh : (Y.card:β) β€ max C 1*E := hcard'.trans | |
| (mul_le_mul_of_nonneg_right (le_max_left _ _) hE.le) | |
| change (Y.card:β)*(1/(8*max C 1*E)) β€ 1/8 | |
| rw [mul_one_div] | |
| apply (div_le_iffβ hden).mpr | |
| nlinarith only [hh] | |
| theorem eventually_scaled_subdivision {X : Type*} [MetricSpace X] [CompactSpace X] | |
| [LocallyPathConnectedSpace X] (qdim : β) (CP A B H cβ C LE dβ ell : β) | |
| (hpack : PolynomialPacking (X:=X) qdim CP) (hCP : 0 β€ CP) | |
| (hA : 1 β€ A) (hAB : A+3 β€ B) (hH : 0 < H) (hcβ : 2 β€ cβ) | |
| (hC : 0 β€ C) (hLE : 0 < LE) (hdc : dβ β€ 1/(9*LE)) (hell : 0 < ell) | |
| (M : β β β) (hMnon : β j, 0 β€ M j) | |
| (hM : β lam : β, 1 < lam β β C : β, 0 < C β§ β j, M j β€ C*lam^j) | |
| (Ξ΄ : β β Type*) [β j, Fintype (Ξ΄ j)] (ΞΎ : β j, Ξ΄ j β X) | |
| (hΞΎ : β j i i', i β i' β radius ell j β€ dist (ΞΎ j i) (ΞΎ j i')) | |
| (Ο : β j, Ξ΄ j β β) (hΟ : β j, MacroscopicAdmissible (ΞΎ j) (radius ell j) dβ (Ο j)) | |
| (hΟmass : β j, (β i, (Ο j i)^2) β€ M j) | |
| (h : X β β β X ββ X) | |
| (hexp : β x k, Expansion (h x k) x (radius ell k) C LE) : | |
| βαΆ n : β in atTop, 0 < n β§ radius ell (160*(qdim+1)*n) < 1/4 β§ | |
| β ΞΊ : β, 0 < ΞΊ β§ β (x : X) (k : β) (Y : Finset X) | |
| (Ξ© : Set X) (f : X β β) (K : β β Set X) (a b : β), | |
| let R := radius ell k | |
| let r := radius ell (k+160*(qdim+1)*n) | |
| a < b β (B+1)*R β€ 1 β max H 1*R β€ 1 β 3*R β€ 1 β | |
| (β y β Y, (A-1)*R β€ dist y x β§ dist y x β€ (B+1)*R) β | |
| (β y β Y, β z β Y, y β z β r β€ dist y z) β | |
| (β v, (A-1)*R β€ dist v x β dist v x β€ (B+1)*R β β y β Y, dist v y β€ r) β | |
| (β v, dist v x β€ (B+2)*R β v β Ξ©) β ContinuousOn f Ξ© β | |
| (β v β Ioo a b, IsPreconnected (K v)) β | |
| (β v β Ioo a b, β y β K v, dist y x β€ A*R) β | |
| (β v β Ioo a b, 2*B*R < diam (K v)) β | |
| (β v β Ioo a b, β y β K v, y β Ξ© β f y=v) β | |
| LiteralTransitions f Y cβ r a b ΞΊ H (Real.exp (-ell*n)) | |
| (Real.exp (8*(qdim+1)*ell*n)) (Real.exp (-((80*(qdim+1):β)*ell*n))) := by | |
| have hB : 0 β€ B := by linarith only [hA,hAB] | |
| have hc : 0 < 1/(9*LE) := by positivity | |
| have hs := uniform_literal_subdivision qdim CP A B H cβ C (1/(9*LE)) dβ ell | |
| hpack hCP hA hAB hH hcβ hC hc hdc hell M hMnon hM | |
| have hsc := eventually_flow_scales qdim ell cβ H (max (C+2) (max (1/(9*LE)) 1)) hell | |
| filter_upwards [hs,hsc] with n hn hscale | |
| obtain β¨ΞΊ,hΞΊ,hΞΊcountβ© := candidate_slack (X:=X) qdim CP B ell hCP hB (160*(qdim+1)*n) | |
| refine β¨hscale.1,hscale.2.1,ΞΊ,hΞΊ,?_β© | |
| intro x k Y Ξ© f K a b | |
| dsimp only | |
| let R := radius ell k | |
| let r := radius ell (k+160*(qdim+1)*n) | |
| let s := radius ell (k+2*n) | |
| have hR : 0 < R := radius_pos _ _ | |
| have hr : 0 < r := radius_pos _ _ | |
| have hsp : 0 < s := radius_pos _ _ | |
| intro hab hRone hCone hthree hY hYsep hYnet hΞ© hf hK hinner hdiam hlevel | |
| have hd : 2 β€ 160*(qdim+1) := by omega | |
| have hdr : 2*n β€ 160*(qdim+1)*n := Nat.mul_le_mul_right n hd | |
| have hrs : r β€ s := radius_antitone hell.le (Nat.add_le_add_left hdr k) | |
| have hsR : s β€ R := radius_antitone hell.le (Nat.le_add_right k (2*n)) | |
| have hrR : r β€ R := hrs.trans hsR | |
| have hSR : s β€ R/4 := by | |
| dsimp [s,R] | |
| rw [radius_add] | |
| nlinarith only [mul_le_mul_of_nonneg_right hscale.2.2.2.2.1 hR.le] | |
| have hcR : cβ*r β€ R := by | |
| dsimp [r,R] | |
| rw [radius_add] | |
| nlinarith only [mul_le_mul_of_nonneg_right hscale.2.2.1 hR.le] | |
| have hHR : 2*((H+3)*r) β€ R := by | |
| dsimp [r,R] | |
| rw [radius_add] | |
| nlinarith only [mul_le_mul_of_nonneg_right hscale.2.2.2.1 hR.le] | |
| have hratioS : R/s=Real.exp (2*ell*n) := by | |
| dsimp [R,s] | |
| rw [radius_ratio] | |
| congr 1 | |
| push_cast | |
| ring | |
| have hratioR : R/r=Real.exp ((160*(qdim+1):β)*ell*n) := by | |
| dsimp [R,r] | |
| rw [radius_ratio] | |
| congr 1 | |
| push_cast | |
| ring | |
| have hrr : r/s=radius ell ((160*(qdim+1)-2)*n) := by | |
| dsimp [r,s] | |
| rw [radius_sub_ratio ell k _ _ hdr, Nat.sub_mul] | |
| have hΞΊY : (Fintype.card Y:β)*ΞΊ β€ 1/8 := by | |
| rw [Fintype.card_coe] | |
| apply hΞΊcount Y R r hr | |
| Β· exact hpack x ((B+1)*R) r hr (hrR.trans (by nlinarith only [hB,hR])) hRone Y | |
| (fun y hy => by simpa only [dist_comm] using (hY y hy).2) hYsep | |
| Β· dsimp [R,r] | |
| exact radius_ratio _ _ _ | |
| obtain β¨T,hT,hTsep,hTnetβ© := annular_net x A B R s hsp | |
| have htrans : max (C+2) (max (1/(9*LE)) 1)*(r/s) β€ 1 := by | |
| rw [hrr] | |
| exact hscale.2.2.2.2.2 | |
| have hmap (z : T) (v v' : X) (hv : dist v (z:X) β€ 3*s) (hv' : dist v' (z:X) β€ 3*s) : | |
| dist (h z (k+2*n) v) (h z (k+2*n) v') β€ C/s*dist v v' β§ | |
| (1/(9*LE))/s*dist v v' β€ dist (h z (k+2*n) v) (h z (k+2*n) v') := by | |
| have hh := expansion_ball_bounds (h z (k+2*n)) z s C LE 3 hsp hLE (by norm_num) | |
| (hexp z (k+2*n)) v v' hv hv' | |
| simpa only [show (3 : β)^2 = 9 by norm_num, mul_comm LE 9] using hh | |
| have htarget : β i j, i β j β r/s β€ dist (ΞΎ ((160*(qdim+1)-2)*n) i) (ΞΎ ((160*(qdim+1)-2)*n) j) := by | |
| rw [hrr] | |
| exact hΞΎ _ | |
| have hweight : MacroscopicAdmissible (ΞΎ ((160*(qdim+1)-2)*n)) (r/s) dβ | |
| (Ο ((160*(qdim+1)-2)*n)) := by rw [hrr]; exact hΟ _ | |
| exact hn (fun y : Y => (y:X)) (fun z : T => (z:X)) (ΞΎ ((160*(qdim+1)-2)*n)) | |
| (fun z : T => h z (k+2*n)) x Ξ© f K a b ΞΊ R r s hab hΞΊ hΞΊY hR hr hsp hrs hSR hcR hHR | |
| hRone ((mul_le_mul_of_nonneg_left hrR (le_max_right H 1 |>.trans' zero_le_one)).trans hCone) | |
| ((mul_le_mul_of_nonneg_left hsR (by norm_num : (0:β) β€ 3)).trans hthree) htrans hratioS hratioR | |
| (fun y => (hY y y.property).2) | |
| (fun y z hyz => hYsep y y.property z z.property (fun he => hyz (Subtype.ext he))) | |
| (fun y z hyz => hTsep y y.property z z.property (fun he => hyz (Subtype.ext he))) | |
| htarget (fun z => by simpa only [dist_comm] using (hT z z.property).2) | |
| (fun v hl hu => by obtain β¨y,hy,hdβ© := hYnet v hl hu; exact β¨β¨y,hyβ©,by simpa only [dist_comm] using hdβ©) | |
| (fun v hl hu => by obtain β¨z,hz,hdβ© := hTnet v hl hu; exact β¨β¨z,hzβ©,hdβ©) | |
| hΞ© hf hK hinner hdiam hlevel hmap (Ο ((160*(qdim+1)-2)*n)) hweight (hΟmass _) | |
| end CannonNode | |
| end | |
| section | |
| section | |
| open Set Filter Finset | |
| namespace CannonFlow | |
| structure FiniteFlow where | |
| size : β β β | |
| parent : (n : β) β Fin (size (n+1)) β Fin (size n) | |
| weight : (n : β) β Fin (size n) β β | |
| nonneg : β n v, 0 β€ weight n v | |
| root_mass : β v, weight 0 v = 1 | |
| conserves : β n v, weight n v = β w, if parent n w = v then weight (n+1) w else 0 | |
| good : (n : β) β Fin (size n) β Prop | |
| namespace FiniteFlow | |
| attribute [local instance] Classical.propDecidable | |
| variable (T : FiniteFlow) | |
| lemma conserve_expectation (n : β) (f : Fin (T.size n) β β) : | |
| β v, T.weight n v * f v = β w, T.weight (n+1) w * f (T.parent n w) := by | |
| classical | |
| simp_rw [T.conserves n, sum_mul] | |
| rw [sum_comm] | |
| apply sum_congr rfl | |
| intro w hw | |
| simp only [ite_mul, zero_mul] | |
| simp | |
| lemma total_mass (n : β) : β v, T.weight n v = 1 := by | |
| induction n with | |
| | zero => exact T.root_mass | |
| | succ n ih => | |
| have h := T.conserve_expectation n (fun _ => 1) | |
| simpa only [mul_one] using h.symm.trans (by simpa only [mul_one] using ih) | |
| def badCount : (n : β) β Fin (T.size n) β β | |
| | 0, _ => 0 | |
| | n+1, v => badCount n (T.parent n v) + if T.good n (T.parent n v) then 0 else 1 | |
| def expectedBad (n : β) : β := β v, T.weight n v * (T.badCount n v : β) | |
| def badMass (n : β) : β := β v, T.weight n v * if T.good n v then 0 else 1 | |
| def goodMass (n : β) : β := β v, T.weight n v * if T.good n v then 1 else 0 | |
| lemma badMass_nonneg (n : β) : 0 β€ T.badMass n := by | |
| classical | |
| apply sum_nonneg | |
| intro v hv | |
| exact mul_nonneg (T.nonneg n v) (by split_ifs <;> norm_num) | |
| lemma good_add_bad (n : β) : T.goodMass n + T.badMass n = 1 := by | |
| classical | |
| unfold goodMass badMass | |
| rw [β sum_add_distrib] | |
| convert T.total_mass n using 1 | |
| apply sum_congr rfl | |
| intro v hv | |
| split_ifs <;> ring | |
| lemma expectedBad_succ (n : β) : T.expectedBad (n+1) = T.expectedBad n + T.badMass n := by | |
| classical | |
| unfold expectedBad badMass | |
| simp only [badCount, Nat.cast_add, Nat.cast_ite, Nat.cast_zero, Nat.cast_one, mul_add, sum_add_distrib] | |
| exact congrArgβ (Β· + Β·) | |
| (T.conserve_expectation n (fun v => (T.badCount n v : β))).symm | |
| (T.conserve_expectation n (fun v => if T.good n v then 0 else 1)).symm | |
| lemma expectedBad_eq_sum (n : β) : T.expectedBad n = β k β range n, T.badMass k := by | |
| induction n with | |
| | zero => simp [expectedBad, badCount] | |
| | succ n ih => rw [T.expectedBad_succ, ih, sum_range_succ] | |
| lemma expectedBad_bound {c E : β} (_hc : 0 < c) | |
| (henergy : β n, β v, T.weight n v * | |
| Real.exp (c * ((11 / 20 : β) * T.badCount n v - (1 / 20 : β) * n)) β€ E) | |
| (n : β) : c * ((11 / 20 : β) * T.expectedBad n - (1 / 20 : β) * n) + 1 β€ E := by | |
| have htan : β v, T.weight n v * | |
| (c * ((11 / 20 : β) * T.badCount n v - (1 / 20 : β) * n) + 1) β€ E := by | |
| apply le_trans _ (henergy n) | |
| apply sum_le_sum | |
| intro v hv | |
| exact mul_le_mul_of_nonneg_left (Real.add_one_le_exp _) (T.nonneg n v) | |
| have heq : (β v, T.weight n v * | |
| (c * ((11 / 20 : β) * T.badCount n v - (1 / 20 : β) * n) + 1)) = | |
| c * ((11 / 20 : β) * T.expectedBad n - (1 / 20 : β) * n) + 1 := by | |
| calc | |
| _ = β v, ((c * (11 / 20 : β)) * (T.weight n v * T.badCount n v) + | |
| (1 - c * (1 / 20 : β) * n) * T.weight n v) := by | |
| apply sum_congr rfl | |
| intro v hv | |
| ring | |
| _ = _ := by rw [sum_add_distrib, β mul_sum, β mul_sum, T.total_mass]; unfold expectedBad; ring | |
| rwa [heq] at htan | |
| theorem arbitrarily_late_good_levels {c E : β} (hc : 0 < c) | |
| (henergy : β n, β v, T.weight n v * | |
| Real.exp (c * ((11 / 20 : β) * T.badCount n v - (1 / 20 : β) * n)) β€ E) : | |
| β N : β, β n β₯ N, (1 / 2 : β) β€ T.goodMass n := by | |
| classical | |
| intro N | |
| by_contra hn | |
| have hbad : β n, N β€ n β (1 / 2 : β) β€ T.badMass n := by | |
| intro n hnN | |
| have hg : T.goodMass n < 1 / 2 := lt_of_not_ge (fun h => hn β¨n,hnN,hβ©) | |
| linarith [T.good_add_bad n] | |
| have hlarge : β n : β, N β€ n β§ E + c * (11 / 40 : β) * N < c * (9 / 40 : β) * n + 1 := by | |
| obtain β¨m,hmβ© := exists_nat_gt ((E + c * (11 / 40 : β) * N) / (c * (9 / 40 : β))) | |
| refine β¨max m N,le_max_right _ _,?_β© | |
| have hd : 0 < c * (9 / 40 : β) := by positivity | |
| have hh : E + c * (11 / 40 : β) * N < c * (9 / 40 : β) * m := by simpa [mul_comm] using (div_lt_iffβ hd).mp hm | |
| have hmn : (m : β) β€ max m N := by exact_mod_cast le_max_left m N | |
| nlinarith | |
| obtain β¨n,hnN,hnEβ© := hlarge | |
| have hsum : ((n - N : β) : β) * (1 / 2 : β) β€ T.expectedBad n := by | |
| rw [T.expectedBad_eq_sum] | |
| have he := sum_le_sum (s := Ico N n) (fun k hk => hbad k (mem_Ico.mp hk).1) | |
| have hs : β k β Ico N n, T.badMass k β€ β k β range n, T.badMass k := | |
| sum_le_sum_of_subset_of_nonneg (by intro k hk; exact mem_range.mpr (mem_Ico.mp hk).2) | |
| (fun k _ _ => T.badMass_nonneg k) | |
| simpa using he.trans hs | |
| rw [Nat.cast_sub hnN] at hsum | |
| have hb := T.expectedBad_bound hc henergy n | |
| nlinarith | |
| end FiniteFlow | |
| lemma probabilities_of_capacity {ΞΉ : Type*} [Fintype ΞΉ] (cap : ΞΉ β β) | |
| (hcap : β i, 0 β€ cap i) (hmass : 1 β€ β i, cap i) : | |
| β p : ΞΉ β β, (β i, 0 β€ p i) β§ (β i, p i = 1) β§ β i, p i β€ cap i := by | |
| let S := β i, cap i | |
| have hS : 0 < S := lt_of_lt_of_le (by norm_num) hmass | |
| refine β¨fun i => cap i / S, fun i => div_nonneg (hcap i) hS.le, ?_, ?_β© | |
| Β· rw [β Finset.sum_div] | |
| exact div_self hS.ne' | |
| Β· intro i | |
| exact (div_le_iffβ hS).mpr (by nlinarith [hcap i]) | |
| lemma probabilities_of_mixed_capacity {ΞΉ : Type*} [Fintype ΞΉ] | |
| (t : ΞΉ β β) {L Q : β} (ht : β i, 0 β€ t i) (hL : 0 β€ L) (hQ : 0 β€ Q) | |
| (hc : 1 β€ β i, min (L * t i) (Q * (t i)^2)) : | |
| β p : ΞΉ β β, (β i, 0 β€ p i) β§ (β i, p i = 1) β§ | |
| (β i, p i β€ L * t i) β§ β i, p i β€ Q * (t i)^2 := by | |
| obtain β¨p,hp,hsum,hboundβ© := probabilities_of_capacity | |
| (fun i => min (L*t i) (Q*(t i)^2)) | |
| (fun i => le_min (mul_nonneg hL (ht i)) (mul_nonneg hQ (sq_nonneg _))) hc | |
| exact β¨p,hp,hsum,fun i => (hbound i).trans (min_le_left _ _), | |
| fun i => (hbound i).trans (min_le_right _ _)β© | |
| namespace FiniteFlow | |
| attribute [local instance] Classical.propDecidable | |
| variable (T : FiniteFlow) | |
| lemma weight_le_one (n : β) (v : Fin (T.size n)) : T.weight n v β€ 1 := by | |
| rw [β T.total_mass n] | |
| exact Finset.single_le_sum (fun w _ => T.nonneg n w) (Finset.mem_univ v) | |
| lemma linear_transition_product | |
| (p : (n : β) β Fin (T.size (n+1)) β β) | |
| (Ξ : (n : β) β Fin (T.size n) β β) {Ξβ Ξ± : β} | |
| (hΞβ : 0 β€ Ξβ) (hΞ± : 0 β€ Ξ±) (hroot : β v, Ξ 0 v = Ξβ) | |
| (hp : β n v, 0 β€ p n v) | |
| (hstep : β n v, T.weight (n+1) v = p n v * T.weight n (T.parent n v)) | |
| (hlin : β n v, p n v * Ξ n (T.parent n v) β€ Ξ± * Ξ (n+1) v) : | |
| β n v, Ξβ * T.weight n v β€ Ξ±^n * Ξ n v := by | |
| intro n | |
| induction n with | |
| | zero => | |
| intro v | |
| simpa [hroot] using mul_le_mul_of_nonneg_left (T.weight_le_one 0 v) hΞβ | |
| | succ n ih => | |
| intro v | |
| calc | |
| Ξβ * T.weight (n+1) v = p n v * (Ξβ * T.weight n (T.parent n v)) := by | |
| rw [hstep]; ring | |
| _ β€ p n v * (Ξ±^n * Ξ n (T.parent n v)) := | |
| mul_le_mul_of_nonneg_left (ih _) (hp n v) | |
| _ = Ξ±^n * (p n v * Ξ n (T.parent n v)) := by ring | |
| _ β€ Ξ±^n * (Ξ± * Ξ (n+1) v) := | |
| mul_le_mul_of_nonneg_left (hlin n v) (pow_nonneg hΞ± n) | |
| _ = _ := by rw [pow_succ]; ring | |
| lemma badCount_exp_succ (c : β) (n : β) (v : Fin (T.size (n+1))) : | |
| Real.exp (c * ((11/20:β) * T.badCount (n+1) v - (1/20:β) * (n+1))) = | |
| Real.exp (c * ((11/20:β) * T.badCount n (T.parent n v) - (1/20:β)*n)) * | |
| Real.exp (c * (if T.good n (T.parent n v) then -(1/20:β) else 1/2)) := by | |
| rw [β Real.exp_add] | |
| congr 1 | |
| simp only [badCount, Nat.cast_add, Nat.cast_ite, Nat.cast_zero, Nat.cast_one] | |
| split_ifs <;> ring | |
| lemma quadratic_transition_product | |
| (p : (n : β) β Fin (T.size (n+1)) β β) | |
| (Ξ : (n : β) β Fin (T.size n) β β) {Ξβ c : β} | |
| (hroot : β v, Ξ 0 v = Ξβ) (hp : β n v, 0 β€ p n v) | |
| (hstep : β n v, T.weight (n+1) v = p n v * T.weight n (T.parent n v)) | |
| (hq : β n v, p n v * | |
| Real.exp (c * (if T.good n (T.parent n v) then -(1/20:β) else 1/2)) * | |
| (Ξ n (T.parent n v))^2 β€ (Ξ (n+1) v)^2) : | |
| β n v, Ξβ^2 * T.weight n v * | |
| Real.exp (c * ((11/20:β) * T.badCount n v - (1/20:β) * n)) β€ (Ξ n v)^2 := by | |
| intro n | |
| induction n with | |
| | zero => | |
| intro v | |
| simpa [badCount,hroot] using | |
| mul_le_mul_of_nonneg_left (T.weight_le_one 0 v) (sq_nonneg Ξβ) | |
| | succ n ih => | |
| intro v | |
| rw [hstep, Nat.cast_add, Nat.cast_one, T.badCount_exp_succ] | |
| calc | |
| _ = (p n v * Real.exp (c * (if T.good n (T.parent n v) then -(1/20:β) else 1/2))) * | |
| (Ξβ^2 * T.weight n (T.parent n v) * | |
| Real.exp (c * ((11/20:β) * T.badCount n (T.parent n v) - (1/20:β) * n))) := by ring | |
| _ β€ (p n v * Real.exp (c * (if T.good n (T.parent n v) then -(1/20:β) else 1/2))) * | |
| (Ξ n (T.parent n v))^2 := | |
| mul_le_mul_of_nonneg_left (ih _) (mul_nonneg (hp n v) (Real.exp_pos _).le) | |
| _ β€ _ := hq n v | |
| theorem good_levels_of_transitions | |
| (p : (n : β) β Fin (T.size (n+1)) β β) | |
| (Ξ : (n : β) β Fin (T.size n) β β) {Ξβ c E : β} | |
| (hΞβ : 0 < Ξβ) (hc : 0 < c) | |
| (hroot : β v, Ξ 0 v = Ξβ) (hp : β n v, 0 β€ p n v) | |
| (hstep : β n v, T.weight (n+1) v = p n v * T.weight n (T.parent n v)) | |
| (hq : β n v, p n v * | |
| Real.exp (c * (if T.good n (T.parent n v) then -(1/20:β) else 1/2)) * | |
| (Ξ n (T.parent n v))^2 β€ (Ξ (n+1) v)^2) | |
| (henergy : β n, β v, (Ξ n v)^2 β€ E) : | |
| β N : β, β n β₯ N, (1/2:β) β€ T.goodMass n := by | |
| apply T.arbitrarily_late_good_levels hc (E := E / Ξβ^2) | |
| intro n | |
| apply (le_div_iffβ (sq_pos_of_pos hΞβ)).mpr | |
| have h := (Finset.sum_le_sum fun v _ => | |
| T.quadratic_transition_product p Ξ hroot hp hstep hq n v).trans (henergy n) | |
| convert h using 1 | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro v hv | |
| ring | |
| end FiniteFlow | |
| end CannonFlow | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |