Download data/lean/OAI/Analysis/DiamondDistortion/ForestModels.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/DiamondDistortion/ForestModels.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/DiamondDistortion/ForestModels.lean
-
curl -L -o ForestModels.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/DiamondDistortion/ForestModels.lean
13.3 kB
| import OAI.Analysis.DiamondDistortion.Orthogonality | |
| namespace OAI | |
| universe u v | |
| noncomputable section | |
| open scoped BigOperators Classical Topology | |
| open Set | |
| namespace DiamondDistortion | |
| def ForestNode := {hw : β Γ List β // 1 β€ hw.1 β§ hw.2.length β€ hw.1} | |
| def ForestAncestor (a b : ForestNode) : Prop := | |
| a.val.1 = b.val.1 β§ a.val.2.IsPrefix b.val.2 | |
| @[instance_reducible] def forestAncestry : Ancestry ForestNode where | |
| le := ForestAncestor | |
| lt a b := ForestAncestor a b β§ Β¬ ForestAncestor b a | |
| le_refl a := β¨rfl, List.prefix_refl _β© | |
| le_trans _ _ _ hab hbc := β¨hab.1.trans hbc.1, hab.2.trans hbc.2β© | |
| le_antisymm a b hab hba := by | |
| apply Subtype.ext | |
| exact Prod.ext hab.1 (hab.2.sublist.antisymm hba.2.sublist) | |
| predecessors_total hab hac := by | |
| rcases List.prefix_or_prefix_of_prefix hab.2 hac.2 with h | h | |
| Β· exact Or.inl β¨hab.1.trans hac.1.symm, hβ© | |
| Β· exact Or.inr β¨hac.1.trans hab.1.symm, hβ© | |
| def forestSegments : SegmentSystem ForestNode := | |
| Ancestry.segments (A := forestAncestry) | |
| /-- Prefix order on all finite words, explicitly distinct from their lexicographic order. -/ | |
| @[instance_reducible] def infiniteAncestry : Ancestry (List β) where | |
| le := List.IsPrefix | |
| lt a b := a.IsPrefix b β§ Β¬ b.IsPrefix a | |
| le_refl := List.prefix_refl | |
| le_trans _ _ _ := List.IsPrefix.trans | |
| le_antisymm _ _ hab hba := hab.sublist.antisymm hba.sublist | |
| predecessors_total := List.prefix_or_prefix_of_prefix | |
| /-- The infinite-height tree of all finite words; this includes the empty root. -/ | |
| def infiniteSegments : SegmentSystem (List β) := | |
| Ancestry.segments (A := infiniteAncestry) | |
| lemma infinite_finite_heads : β S : Finset (List β), β K : Finset (List β), | |
| S β K β§ Ancestry.Ancestral (A := infiniteAncestry) (K : Set (List β)) := by | |
| apply Ancestry.finite_heads_of_predecessors (A := infiniteAncestry) | |
| intro b | |
| exact b.inits.toFinset.finite_toSet.subset (by | |
| intro a ha | |
| exact List.mem_toFinset.mpr ((List.mem_inits a b).mpr ha)) | |
| lemma forest_finite_heads : β S : Finset ForestNode, β K : Finset ForestNode, | |
| S β K β§ Ancestry.Ancestral (A := forestAncestry) (K : Set ForestNode) := by | |
| apply Ancestry.finite_heads_of_predecessors (A := forestAncestry) | |
| intro b | |
| have hfin : (({b.val.1} : Set β) ΓΛ’ (b.val.2.inits.toFinset : Set (List β))).Finite := | |
| (Set.finite_singleton _).prod b.val.2.inits.toFinset.finite_toSet | |
| have hpre := hfin.preimage (f := (Subtype.val : ForestNode β β Γ List β)) Subtype.val_injective.injOn | |
| apply hpre.subset | |
| intro a ha | |
| exact β¨ha.1, List.mem_toFinset.mpr ((List.mem_inits _ _).mpr ha.2)β© | |
| namespace Forest | |
| def component (v : ForestNode) : β := v.val.1 | |
| lemma same_component (S : Finset ForestNode) (hS : forestSegments.IsSegment S) | |
| (u : ForestNode) (hu : u β S) (v : ForestNode) (hv : v β S) : | |
| component u=component v := by | |
| obtain β¨a,b,_,hmβ© := hS | |
| exact ((hm u).mp hu).2.1.trans ((hm v).mp hv).2.1.symm | |
| lemma segment_card_le (S : Finset ForestNode) (hS : forestSegments.IsSegment S) | |
| (u : ForestNode) (hu : u β S) : S.card β€ component u+1 := by | |
| obtain β¨a,b,_,hmβ© := hS | |
| have hcard : S.card β€ (Finset.range (component b+1)).card := by | |
| apply Finset.card_le_card_of_injOn (fun v : ForestNode => v.val.2.length) | |
| Β· intro v hv | |
| have hvb := ((hm v).mp hv).2 | |
| apply Finset.mem_range.mpr | |
| exact Nat.lt_succ_of_le (hvb.2.length_le.trans b.property.2) | |
| Β· intro v hv w hw he | |
| have hvb := ((hm v).mp hv).2 | |
| have hwb := ((hm w).mp hw).2 | |
| have hword : v.val.2=w.val.2 := by | |
| rcases List.prefix_or_prefix_of_prefix hvb.2 hwb.2 with h | h | |
| Β· exact h.eq_of_length he | |
| Β· exact (h.eq_of_length he.symm).symm | |
| exact Subtype.ext (Prod.ext (hvb.1.trans hwb.1.symm) hword) | |
| rw [Finset.card_range] at hcard | |
| have he : component u=component b := ((hm u).mp hu).2.1 | |
| rwa [he] | |
| lemma primal_sq_bounded_components (C : Finset β) (p : ForestNode ββ β) | |
| (hp : β v β p.support, component v β C) : | |
| (forestSegments.primalSeminorm p)^2 β€ (((C.sup (id : β β β) : β) : β)+1)*(β v β p.support,p v^2) := by | |
| apply forestSegments.primal_sq_le_of_segment p (by positivity) | |
| intro S hS | |
| by_cases hz : (β v β S,p v)=0 | |
| Β· rw [hz,zero_pow (by decide : (2 : β) β 0)] | |
| positivity | |
| obtain β¨u,hu,hpuβ© := Finset.exists_ne_zero_of_sum_ne_zero hz | |
| have hcu := hp u (Finsupp.mem_support_iff.mpr hpu) | |
| have hcard : (S.card : β) β€ ((C.sup (id : β β β) : β) : β)+1 := by | |
| have h := (segment_card_le S hS u hu).trans (Nat.add_le_add_right (Finset.le_sup (f := id) hcu) 1) | |
| exact_mod_cast h | |
| exact sq_sum_le_card_mul_sum_sq.trans (mul_le_mul_of_nonneg_right hcard | |
| (Finset.sum_nonneg (fun _ _ => sq_nonneg _))) | |
| def coefficients (C : Finset β) (x : forestSegments.Dual) (v : ForestNode) : β := | |
| if component v β C then x (forestSegments.unitVector v) else 0 | |
| lemma coefficients_bounded (C : Finset β) (x : forestSegments.Dual) (S : Finset ForestNode) : | |
| (β v β S,coefficients C x v^2) β€ (((C.sup (id : β β β) : β) : β)+1)*βxβ^2 := by | |
| classical | |
| let a := coefficients C x | |
| let p := SegmentSystem.finiteArray S a | |
| let B := β v β S,a v^2 | |
| have hB : 0 β€ B := Finset.sum_nonneg (fun _ _ => sq_nonneg _) | |
| have hp : β v β p.support,component v β C := by | |
| intro v hv | |
| by_contra hn | |
| have hav : a v=0 := ite_eq_right hn | |
| have hpv : p v=0 := by rw [SegmentSystem.finiteArray_apply,hav]; split_ifs <;> rfl | |
| exact (Finsupp.mem_support_iff.mp hv) hpv | |
| have hpenergy := primal_sq_bounded_components C p hp | |
| rw [SegmentSystem.finiteArray_energy] at hpenergy | |
| have he : x (forestSegments.finiteEmbedding p)=B := by | |
| rw [forestSegments.finiteArray_pairing] | |
| apply Finset.sum_congr rfl | |
| intro v _ | |
| dsimp [a,coefficients] | |
| split_ifs <;> ring | |
| have hval : B β€ βxβ*forestSegments.primalSeminorm p := by | |
| rw [β he] | |
| exact (Real.le_norm_self _).trans (by | |
| simpa only [SegmentSystem.finiteEmbedding_norm] using x.le_opNorm (forestSegments.finiteEmbedding p)) | |
| have hsq := (sq_le_sqβ hB | |
| (mul_nonneg (norm_nonneg _) (apply_nonneg _ _))).2 hval | |
| have hmul := mul_le_mul_of_nonneg_left hpenergy (sq_nonneg βxβ) | |
| change B β€ (((C.sup (id : β β β) : β) : β)+1)*βxβ^2 | |
| by_contra hn | |
| have hpos : 0 < B := lt_of_le_of_lt (by positivity) (lt_of_not_ge hn) | |
| have hc := mul_pos hpos (sub_pos.mpr (lt_of_not_ge hn)) | |
| change (forestSegments.primalSeminorm p)^2 β€ (((C.sup (id : β β β) : β) : β)+1)*B at hpenergy | |
| change βxβ^2*(forestSegments.primalSeminorm p)^2 β€ βxβ^2*((((C.sup (id : β β β) : β) : β)+1)*B) at hmul | |
| nlinarith only [hsq,hmul,hc] | |
| lemma finite_component_tail (C : Finset β) (x : forestSegments.Dual) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| β S : Finset ForestNode, β p : ForestNode ββ β, | |
| (β v β p.support, component v β C) β (β v β p.support,v β S) β | |
| |x (forestSegments.finiteEmbedding p)| β€ Ξ΅*forestSegments.primalSeminorm p := by | |
| classical | |
| obtain β¨S,hSβ© := SegmentSystem.finite_square_tails (coefficients C x) | |
| (coefficients_bounded C x) (sq_pos_of_pos hΞ΅) | |
| refine β¨S,?_β© | |
| intro p hp hout | |
| have hd : Disjoint S p.support := Finset.disjoint_left.mpr (fun v hv hvs => hout v hvs hv) | |
| have ha : Real.sqrt (β v β p.support,coefficients C x v^2) β€ Ξ΅ := | |
| (Real.sqrt_le_left hΞ΅.le).mpr (hS p.support hd).le | |
| have hb : Real.sqrt (β v β p.support,p v^2) β€ forestSegments.primalSeminorm p := | |
| (Real.sqrt_le_left (apply_nonneg _ _)).mpr (forestSegments.coordinate_energy_le p p.support) | |
| have he : x (forestSegments.finiteEmbedding p) = | |
| β v β p.support,p v*coefficients C x v := by | |
| rw [SegmentSystem.finiteEmbedding_apply,SegmentSystem.dual_coe_apply] | |
| apply Finset.sum_congr rfl | |
| intro v hv | |
| rw [coefficients,ite_eq_left (hp v hv)] | |
| rfl | |
| rw [he] | |
| calc | |
| _ β€ β v β p.support, |p v| * |coefficients C x v| := by | |
| simpa only [abs_mul] using Finset.abs_sum_le_sum_abs (fun v => p v*coefficients C x v) p.support | |
| _ β€ Real.sqrt (β v β p.support,p v^2) * Real.sqrt (β v β p.support,coefficients C x v^2) := by | |
| simpa only [sq_abs] using Real.sum_mul_le_sqrt_mul_sqrt p.support | |
| (fun v => |p v|) (fun v => |coefficients C x v|) | |
| _ β€ forestSegments.primalSeminorm p * Ξ΅ := mul_le_mul hb ha (Real.sqrt_nonneg _) (apply_nonneg _ _) | |
| _ = _ := mul_comm _ _ | |
| lemma component_set_ancestral (C : Finset β) : | |
| Ancestry.Ancestral (A := forestAncestry) {v : ForestNode | component v β C} := by | |
| intro a b hab hb | |
| change ForestAncestor a b at hab | |
| change component a β C | |
| change component b β C at hb | |
| have he : component a=component b := hab.1 | |
| rwa [he] | |
| /-- The full finite-height forest dual really has finite ancestral head | |
| approximation. Both the component tail and coordinate tail arguments are | |
| proved from its disjoint-segment norm, rather than imposed as hypotheses. -/ | |
| lemma full_dual_approximation (x : forestSegments.Dual) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| β H : Finset ForestNode, Ancestry.Ancestral (A := forestAncestry) (H : Set ForestNode) β§ | |
| βforestSegments.tailDual H xβ < Ξ΅ := by | |
| classical | |
| have hd : 0 < Ξ΅/4 := by positivity | |
| obtain β¨C,hCβ© := forestSegments.small_color_tail component same_component x hd | |
| obtain β¨S,hSβ© := finite_component_tail C x hd | |
| obtain β¨H,hSH,hHβ© := forest_finite_heads S | |
| refine β¨H,hH,?_β© | |
| have hbound : βforestSegments.tailDual H xβ β€ Ξ΅/2 := by | |
| apply ContinuousLinearMap.opNorm_le_bound _ (by positivity) | |
| intro u | |
| induction u using UniformSpace.Completion.induction_on with | |
| | hp => exact isClosed_le (by fun_prop) (by fun_prop) | |
| | ih u => | |
| let p := forestSegments.ofPrimal u | |
| let q := p.filter (fun v => v β H) | |
| let qi := q.filter (fun v => component v β C) | |
| let qo := q.filter (fun v => component v β C) | |
| have hqi : β v β qi.support,component v β C := by | |
| intro v hv | |
| rw [Finsupp.support_filter] at hv | |
| exact (Finset.mem_filter.mp hv).2 | |
| have hqiS : β v β qi.support,v β S := by | |
| intro v hv hvs | |
| rw [Finsupp.support_filter] at hv | |
| have hvq := (Finset.mem_filter.mp hv).1 | |
| rw [Finsupp.support_filter] at hvq | |
| exact (Finset.mem_filter.mp hvq).2 (hSH hvs) | |
| have hqo : β v β qo.support,component v β C := by | |
| intro v hv | |
| rw [Finsupp.support_filter] at hv | |
| exact (Finset.mem_filter.mp hv).2 | |
| have hi := hS qi hqi hqiS | |
| have ho := hC qo hqo | |
| have hqin : forestSegments.primalSeminorm qi β€ forestSegments.primalSeminorm q := by | |
| change (Ancestry.segments (A := forestAncestry)).primalSeminorm qi β€ | |
| (Ancestry.segments (A := forestAncestry)).primalSeminorm q | |
| convert Ancestry.primal_filter_le (A := forestAncestry) (component_set_ancestral C) q using 1 | |
| all_goals dsimp [qi,qo]; congr | |
| have hqon : forestSegments.primalSeminorm qo β€ forestSegments.primalSeminorm q := by | |
| change (Ancestry.segments (A := forestAncestry)).primalSeminorm qo β€ | |
| (Ancestry.segments (A := forestAncestry)).primalSeminorm q | |
| convert Ancestry.primal_filter_tail_le (A := forestAncestry) (component_set_ancestral C) q using 1 | |
| all_goals dsimp [qi,qo]; congr | |
| have hqn : forestSegments.primalSeminorm q β€ forestSegments.primalSeminorm p := by | |
| change (Ancestry.segments (A := forestAncestry)).primalSeminorm q β€ | |
| (Ancestry.segments (A := forestAncestry)).primalSeminorm p | |
| convert Ancestry.primal_filter_tail_le (A := forestAncestry) hH p using 1 | |
| all_goals dsimp [q]; congr | |
| have hsum : qi+qo=q := by | |
| apply Finsupp.ext | |
| intro v | |
| by_cases hv : component v β C <;> simp [qi,qo] | |
| have he : forestSegments.tailDual H x (u : forestSegments.JamesSpace) = | |
| x (forestSegments.finiteEmbedding q) := by | |
| rw [SegmentSystem.tailDual_apply_apply,SegmentSystem.headPrimal_coe, | |
| β UniformSpace.Completion.coe_sub,SegmentSystem.sub_filterPrimal] | |
| congr 2 | |
| apply Finsupp.ext | |
| intro v | |
| simp [SegmentSystem.filterPrimal,q,p,SegmentSystem.ofPrimal] | |
| congr | |
| rw [he,Real.norm_eq_abs,UniformSpace.Completion.norm_coe,SegmentSystem.norm_eq_primal] | |
| calc | |
| _ = |x (forestSegments.finiteEmbedding qi)+x (forestSegments.finiteEmbedding qo)| := by | |
| rw [β hsum,map_add,map_add] | |
| _ β€ |x (forestSegments.finiteEmbedding qi)|+|x (forestSegments.finiteEmbedding qo)| := abs_add_le _ _ | |
| _ β€ (Ξ΅/4)*forestSegments.primalSeminorm qi+(Ξ΅/4)*forestSegments.primalSeminorm qo := add_le_add hi ho | |
| _ β€ (Ξ΅/4)*forestSegments.primalSeminorm q+(Ξ΅/4)*forestSegments.primalSeminorm q := | |
| add_le_add (mul_le_mul_of_nonneg_left hqin hd.le) (mul_le_mul_of_nonneg_left hqon hd.le) | |
| _ β€ _ := by nlinarith [mul_le_mul_of_nonneg_left hqn hd.le] | |
| exact lt_of_le_of_lt hbound (by linarith) | |
| end Forest | |
| abbrev ForestDual := forestSegments.Dual | |
| abbrev InfinitePredual := infiniteSegments.CoordinatePredual | |
| end DiamondDistortion | |
| end | |
| end OAI | |