Download data/lean/OAI/Geometry/CAT0Fillings/Reconstruction/AtomGraphs.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 16.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/CAT0Fillings/Reconstruction/AtomGraphs.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/CAT0Fillings/Reconstruction/AtomGraphs.lean
-
curl -L -o AtomGraphs.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/CAT0Fillings/Reconstruction/AtomGraphs.lean
16.5 kB
| import Mathlib | |
| import OAI.Geometry.CAT0Fillings.Currents.FiniteAtoms | |
| namespace OAI | |
| section | |
| open Set Filter MeasureTheory Metric | |
| open scoped Topology NNReal | |
| namespace CAT0Fillings.SliceReconstruction | |
| attribute [local instance] Classical.propDecidable | |
| variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma zeroChart_exists_supported_atom [Nonempty X] (C : IntegerChart X 0) : | |
| β a : β€, β x : X, (a β 0 β x β C.image) β§ C.action = atomCurrent a x := by | |
| by_cases h : (0 : Euc 0) β C.domain | |
| Β· exact β¨C.multiplicity 0, C.param β¨0, hβ©, | |
| fun _ => β¨β¨0, hβ©, rflβ©, C.zero_action hβ© | |
| Β· refine β¨0, Classical.arbitrary X, fun ha => (ha rfl).elim, ?_β© | |
| rw [C.zero_action_eq_zero h] | |
| funext b Ο | |
| simp only [atomCurrent, Int.cast_zero, zero_mul, ite_self, Pi.zero_apply] | |
| theorem integerRectifiable_zero_distinct_representation [CompactSpace X] [Nonempty X] | |
| {T : Functional X 0} (hT : IsMetricCurrent T) (hI : IntegerRectifiable T) : | |
| β (m : β) (a : Fin m β β€) (x : Fin m β X), | |
| (β i, a i β 0) β§ Function.Injective x β§ | |
| β b Ο, T b Ο = β i, atomCurrent (a i) (x i) b Ο := by | |
| classical | |
| obtain β¨C, hd, hC, hCS, heqβ© := hI | |
| choose a x hsupp hact using fun i => zeroChart_exists_supported_atom (C i) | |
| have hmass i : mass (C i).action = |(a i : β)| := by | |
| rw [hact i, mass_atomCurrent] | |
| have haS : Summable (fun i => |(a i : β)|) := by simpa only [hmass] using hCS | |
| have hfinite := finite_support_int_of_summable_abs a haS | |
| let s := hfinite.toFinset | |
| have hs : β i, i β s β a i β 0 := fun i => hfinite.mem_toFinset | |
| let e := s.equivFin.symm | |
| have hezero : β i, a (e i) β 0 := fun i => (hs _).mp (e i).property | |
| refine β¨s.card, fun i => a (e i), fun i => x (e i), hezero, ?_, ?_β© | |
| Β· intro i j hij | |
| apply e.injective | |
| apply Subtype.ext | |
| by_contra hne | |
| have hi : x (e i) β (C (e i)).image := hsupp _ (hezero i) | |
| have hj : x (e i) β (C (e j)).image := by | |
| simpa only [hij] using hsupp _ (hezero j) | |
| exact Set.disjoint_left.mp (hd hne) hi hj | |
| Β· intro b Ο | |
| by_cases hadm : Admissible b Ο | |
| Β· rw [heq] | |
| simp_rw [hact] | |
| rw [tsum_eq_sum (s := s) (fun i hi => by | |
| have hai : a i = 0 := not_not.mp (fun hn => hi ((hs i).mpr hn)) | |
| simp only [atomCurrent, hai, Int.cast_zero, zero_mul, ite_self])] | |
| rw [β Finset.sum_attach] | |
| exact (e.sum_comp (fun i : s => atomCurrent (a i) (x i) b Ο)).symm | |
| Β· simp only [hT.offDomain b Ο hadm, atomCurrent, ite_eq_right hadm, Finset.sum_const_zero] | |
| def atomicTent (p : X) (r : β) (z : X) : β := | |
| min (dist z p) (max 0 (r - dist z p)) | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma atomicTent_lipschitz (p : X) (r : β) : LipschitzWith 1 (atomicTent p r) := by | |
| have hdist : LipschitzWith 1 (fun z : X => dist z p) := LipschitzWith.dist_left p | |
| have hsub : LipschitzWith 1 (fun z : X => r - dist z p) := by | |
| simpa using (LipschitzWith.const r).sub hdist | |
| have hother : LipschitzWith 1 (fun z : X => max 0 (r - dist z p)) := | |
| hsub.const_max 0 | |
| change LipschitzWith 1 (fun z : X => min (dist z p) (max 0 (r - dist z p))) | |
| simpa only [max_self] using hdist.min hother | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma atomicTent_unit_bound (p : X) {r : β} (hr : r β€ 1) (z : X) : | |
| |atomicTent p r z| β€ 1 := by | |
| have h0 : 0 β€ atomicTent p r z := le_min dist_nonneg (le_max_left _ _) | |
| rw [abs_of_nonneg h0] | |
| exact (min_le_right _ _).trans (max_le (by norm_num) | |
| ((sub_le_self _ dist_nonneg).trans hr)) | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| @[simp] lemma atomicTent_center (p : X) (r : β) : atomicTent p r p = 0 := by | |
| simp [atomicTent] | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma atomicTent_near {p z : X} {r : β} (h : 2 * dist z p β€ r) : | |
| atomicTent p r z = dist z p := by | |
| exact min_eq_left ((by linarith : dist z p β€ r - dist z p).trans (le_max_right _ _)) | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma atomicTent_far {p z : X} {r : β} (h : r β€ dist z p) : | |
| atomicTent p r z = 0 := by | |
| simp only [atomicTent, max_eq_left (sub_nonpos.mpr h), min_eq_right dist_nonneg] | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma matched_atom_distance_le {m : β} {S U : Functional X 0} | |
| (a a' : Fin m β β€) (x y : Fin m β X) | |
| (hS : β b Ο, S b Ο = β j, atomCurrent (a j) (x j) b Ο) | |
| (hU : β b Ο, U b Ο = β j, atomCurrent (a' j) (y j) b Ο) | |
| (i : Fin m) (hai : a' i β 0) {r D : β} (hr : r β€ 1) | |
| (hnear : 2 * dist (y i) (x i) β€ r) | |
| (hx : β j, j β i β r β€ dist (x j) (x i)) | |
| (hy : β j, j β i β r β€ dist (y j) (x i)) | |
| (hD : β b : X β β, LipschitzWith 1 b β (β z, |b z| β€ 1) β | |
| |S b (fun j => Fin.elim0 j) - U b (fun j => Fin.elim0 j)| β€ D) : | |
| dist (x i) (y i) β€ D := by | |
| classical | |
| let b := atomicTent (x i) r | |
| have hbl : BoundedLip b := | |
| β¨β¨1, atomicTent_lipschitz _ _β©, 1, atomicTent_unit_bound _ hrβ© | |
| have hbx j : b (x j) = 0 := by | |
| by_cases hji : j = i | |
| Β· subst j; exact atomicTent_center _ _ | |
| Β· exact atomicTent_far (hx j hji) | |
| have hby (j : Fin m) (hji : j β i) : b (y j) = 0 := atomicTent_far (hy j hji) | |
| have hsi : S b (fun j => Fin.elim0 j) = 0 := by | |
| rw [hS] | |
| apply Finset.sum_eq_zero | |
| intro j _ | |
| rw [atomCurrent_apply _ _ hbl, hbx, mul_zero] | |
| have hui : U b (fun j => Fin.elim0 j) = (a' i : β) * dist (y i) (x i) := by | |
| rw [hU, Finset.sum_eq_single i] | |
| Β· rw [atomCurrent_apply _ _ hbl] | |
| change _ * atomicTent (x i) r (y i) = _ | |
| rw [atomicTent_near hnear] | |
| Β· intro j _ hji | |
| rw [atomCurrent_apply _ _ hbl, hby j hji, mul_zero] | |
| Β· simp | |
| have hbound := hD b (atomicTent_lipschitz _ _) (atomicTent_unit_bound _ hr) | |
| rw [hsi, hui, zero_sub, abs_neg, abs_mul, abs_of_nonneg dist_nonneg] at hbound | |
| have ha1 : (1 : β) β€ |(a' i : β)| := by exact_mod_cast Int.one_le_abs hai | |
| calc | |
| dist (x i) (y i) = 1 * dist (y i) (x i) := by simp [dist_comm] | |
| _ β€ |(a' i : β)| * dist (y i) (x i) := mul_le_mul_of_nonneg_right ha1 dist_nonneg | |
| _ β€ D := hbound | |
| end CAT0Fillings.SliceReconstruction | |
| end | |
| section | |
| open Set Filter MeasureTheory Metric TopologicalSpace | |
| open scoped Topology NNReal | |
| namespace CAT0Fillings.SliceReconstruction | |
| attribute [local instance] Classical.propDecidable | |
| variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] | |
| def UnitRepresentation {m : β} (S : Functional X 0) (a : Fin m β β€) (x : Fin m β X) : Prop := | |
| β b : X β β, LipschitzWith 1 b β (β z, |b z| β€ 1) β | |
| S b (fun j => Fin.elim0 j) = β j, (a j : β) * b (x j) | |
| abbrev AtomCode := Ξ£ m : β, (Fin m β β€) Γ (Fin m β β) Γ β | |
| namespace AtomCode | |
| abbrev size (c : AtomCode) := c.1 | |
| abbrev weights (c : AtomCode) : Fin c.size β β€ := c.2.1 | |
| abbrev centers (c : AtomCode) : Fin c.size β β := c.2.2.1 | |
| abbrev radius (c : AtomCode) : β := (c.2.2.2 : β) | |
| def Valid [SeparableSpace X] [Nonempty X] (c : AtomCode) : Prop := | |
| 0 < c.radius β§ 4 * c.radius β€ 1 β§ (β i, c.weights i β 0) β§ | |
| β i j, i β j β 8 * c.radius β€ | |
| dist (TopologicalSpace.denseSeq X (c.centers i)) (TopologicalSpace.denseSeq X (c.centers j)) | |
| end AtomCode | |
| lemma atomCode_countable : Countable AtomCode := inferInstance | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma exists_separated_center_code [SeparableSpace X] [Nonempty X] | |
| {m : β} (x : Fin m β X) (hx : Function.Injective x) : | |
| β (r : β) (c : Fin m β β), 0 < (r : β) β§ 4 * (r : β) β€ 1 β§ | |
| (β i, dist (x i) (TopologicalSpace.denseSeq X (c i)) β€ (r : β)) β§ | |
| β i j, i β j β 8 * (r : β) β€ | |
| dist (TopologicalSpace.denseSeq X (c i)) (TopologicalSpace.denseSeq X (c j)) := by | |
| have he : βαΆ r : β in π 0, r < 1 / 4 β§ | |
| β i j : Fin m, i β j β 10 * r < dist (x i) (x j) := by | |
| refine (eventually_lt_nhds (by norm_num : (0 : β) < 1 / 4)).and ?_ | |
| simp only [Filter.eventually_all] | |
| intro i j hij | |
| have hd : 0 < dist (x i) (x j) := dist_pos.mpr (fun h => hij (hx h)) | |
| filter_upwards [eventually_lt_nhds (by positivity : (0 : β) < dist (x i) (x j) / 10)] with r hr | |
| linarith | |
| obtain β¨Ξ΄, hΞ΄, hballβ© := Metric.mem_nhds_iff.mp he | |
| obtain β¨r, hr0, hrΞ΄β© := exists_pos_rat_lt hΞ΄ | |
| have hr0' : (0 : β) < r := by exact_mod_cast hr0 | |
| have hr := hball (show (r : β) β ball (0 : β) Ξ΄ by | |
| simpa only [mem_ball, Real.dist_eq, sub_zero, abs_of_pos hr0'] using hrΞ΄) | |
| choose c hc using fun i : Fin m => | |
| (TopologicalSpace.denseRange_denseSeq X).exists_dist_lt (x i) hr0' | |
| refine β¨r, c, hr0', by linarith [hr.1], fun i => (hc i).le, ?_β© | |
| intro i j hij | |
| have hd := hr.2 i j hij | |
| have htri : dist (x i) (x j) β€ | |
| dist (x i) (TopologicalSpace.denseSeq X (c i)) + | |
| dist (TopologicalSpace.denseSeq X (c i)) (TopologicalSpace.denseSeq X (c j)) + | |
| dist (x j) (TopologicalSpace.denseSeq X (c j)) := by | |
| calc | |
| _ β€ dist (x i) (TopologicalSpace.denseSeq X (c i)) + | |
| dist (TopologicalSpace.denseSeq X (c i)) (x j) := dist_triangle _ _ _ | |
| _ β€ _ := by | |
| have := dist_triangle (TopologicalSpace.denseSeq X (c i)) | |
| (TopologicalSpace.denseSeq X (c j)) (x j) | |
| rw [dist_comm (TopologicalSpace.denseSeq X (c j)) (x j)] at this | |
| linarith | |
| linarith [hc i, hc j] | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma unitRepresentation_matched_distance [SeparableSpace X] [Nonempty X] | |
| {S U : Functional X 0} (c : AtomCode) (hc : c.Valid (X := X)) | |
| (x y : Fin c.size β X) | |
| (hx : β i, dist (x i) (TopologicalSpace.denseSeq X (c.centers i)) β€ c.radius) | |
| (hy : β i, dist (y i) (TopologicalSpace.denseSeq X (c.centers i)) β€ c.radius) | |
| (hS : UnitRepresentation S c.weights x) (hU : UnitRepresentation U c.weights y) | |
| {D : β} | |
| (hD : β b : X β β, LipschitzWith 1 b β (β z, |b z| β€ 1) β | |
| |S b (fun j => Fin.elim0 j) - U b (fun j => Fin.elim0 j)| β€ D) | |
| (i : Fin c.size) : dist (x i) (y i) β€ D := by | |
| classical | |
| let p j := TopologicalSpace.denseSeq X (c.centers j) | |
| have hnear : 2 * dist (y i) (x i) β€ 4 * c.radius := by | |
| have ht := dist_triangle_right (y i) (x i) (p i) | |
| linarith [hx i, hy i] | |
| have hfar (z : Fin c.size β X) (hz : β j, dist (z j) (p j) β€ c.radius) | |
| (j : Fin c.size) (hji : j β i) : 4 * c.radius β€ dist (z j) (x i) := by | |
| have ht : dist (p j) (p i) β€ dist (z j) (p j) + dist (z j) (x i) + dist (x i) (p i) := by | |
| calc | |
| _ β€ dist (p j) (z j) + dist (z j) (p i) := dist_triangle _ _ _ | |
| _ β€ _ := by | |
| have := dist_triangle (z j) (x i) (p i) | |
| rw [dist_comm (p j) (z j)] | |
| linarith | |
| linarith [hc.2.2.2 j i hji, hz j, hx i, hc.1] | |
| let b := atomicTent (x i) (4 * c.radius) | |
| have hbx j : b (x j) = 0 := by | |
| by_cases hji : j = i | |
| Β· subst j; exact atomicTent_center _ _ | |
| Β· exact atomicTent_far (hfar x hx j hji) | |
| have hsi : S b (fun j => Fin.elim0 j) = 0 := by | |
| rw [hS b (atomicTent_lipschitz _ _) (atomicTent_unit_bound _ hc.2.1)] | |
| apply Finset.sum_eq_zero | |
| intro j _ | |
| rw [hbx, mul_zero] | |
| have hui : U b (fun j => Fin.elim0 j) = (c.weights i : β) * dist (y i) (x i) := by | |
| rw [hU b (atomicTent_lipschitz _ _) (atomicTent_unit_bound _ hc.2.1), Finset.sum_eq_single i] | |
| Β· change _ * atomicTent _ _ _ = _ | |
| rw [atomicTent_near hnear] | |
| Β· intro j _ hji | |
| change _ * atomicTent _ _ _ = _ | |
| rw [atomicTent_far (hfar y hy j hji), mul_zero] | |
| Β· simp | |
| have hbound := hD b (atomicTent_lipschitz _ _) (atomicTent_unit_bound _ hc.2.1) | |
| rw [hsi, hui, zero_sub, abs_neg, abs_mul, abs_of_nonneg dist_nonneg] at hbound | |
| have ha1 : (1 : β) β€ |(c.weights i : β)| := by exact_mod_cast Int.one_le_abs (hc.2.2.1 i) | |
| calc | |
| dist (x i) (y i) = 1 * dist (y i) (x i) := by simp [dist_comm] | |
| _ β€ |(c.weights i : β)| * dist (y i) (x i) := mul_le_mul_of_nonneg_right ha1 dist_nonneg | |
| _ β€ D := hbound | |
| variable {P : Type*} [MetricSpace P] | |
| def atomDomain [SeparableSpace X] [Nonempty X] | |
| (S : P β Functional X 0) (E : Set P) (c : AtomCode) : Set P := | |
| {t | t β E β§ c.Valid (X := X) β§ β x : Fin c.size β X, | |
| (β i, dist (x i) (TopologicalSpace.denseSeq X (c.centers i)) β€ c.radius) β§ | |
| UnitRepresentation (S t) c.weights x} | |
| omit [MeasurableSpace X] [BorelSpace X] [MetricSpace P] in | |
| lemma atomDomain_subset [SeparableSpace X] [Nonempty X] | |
| (S : P β Functional X 0) (E : Set P) (c : AtomCode) : atomDomain S E c β E := | |
| fun _ h => h.1 | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma isCompact_atomDomain [CompactSpace X] [Nonempty X] | |
| (S : P β Functional X 0) {E : Set P} (hE : IsCompact E) (c : AtomCode) | |
| (hS : β b : X β β, LipschitzWith 1 b β (β z, |b z| β€ 1) β | |
| ContinuousOn (fun t => S t b (fun j => Fin.elim0 j)) E) : | |
| IsCompact (atomDomain S E c) := by | |
| apply hE.of_isClosed_subset _ (atomDomain_subset S E c) | |
| apply IsSeqClosed.isClosed | |
| intro z t hz hzt | |
| have htE : t β E := hE.isClosed.mem_of_tendsto hzt (Eventually.of_forall fun j => (hz j).1) | |
| choose x hx hrepr using fun j => (hz j).2.2 | |
| obtain β¨y, Ο, hΟ, hyβ© := CompactSpace.tendsto_subseq x | |
| have hyi i : Tendsto (fun j => x (Ο j) i) atTop (π (y i)) := | |
| (continuous_apply i).tendsto _ |>.comp hy | |
| refine β¨htE, (hz 0).2.1, y, ?_, ?_β© | |
| Β· intro i | |
| exact le_of_tendsto ((hyi i).dist tendsto_const_nhds) | |
| (Eventually.of_forall fun j => hx (Ο j) i) | |
| Β· intro b hb hb1 | |
| have hztE : Tendsto z atTop (π[E] t) := tendsto_nhdsWithin_iff.mpr | |
| β¨hzt, Eventually.of_forall fun j => (hz j).1β© | |
| have hL := ((hS b hb hb1 t htE).tendsto.comp hztE).comp hΟ.tendsto_atTop | |
| have hR : Tendsto (fun j => β i, (c.weights i : β) * b (x (Ο j) i)) atTop | |
| (π (β i, (c.weights i : β) * b (y i))) := by | |
| apply tendsto_finsetSum | |
| intro i _ | |
| exact tendsto_const_nhds.mul ((hb.continuous.tendsto _).comp (hyi i)) | |
| have hL' : Tendsto (fun j => β i, (c.weights i : β) * b (x (Ο j) i)) atTop | |
| (π (S t b (fun j => Fin.elim0 j))) := by | |
| convert hL using 1 | |
| funext j | |
| exact (hrepr (Ο j) b hb hb1).symm | |
| exact tendsto_nhds_unique hL' hR | |
| omit [MetricSpace P] in | |
| lemma integral_mem_atomDomain [CompactSpace X] [Nonempty X] | |
| (S : P β Functional X 0) {E : Set P} {t : P} (ht : t β E) | |
| (hI : IsIntegral 0 (S t)) : β c : AtomCode, t β atomDomain S E c := by | |
| classical | |
| obtain β¨m, a, x, ha, hinj, hreprβ© := integerRectifiable_zero_distinct_representation hI.1 hI.2 | |
| obtain β¨r, centers, hr0, hr1, hx, hsepβ© := exists_separated_center_code x hinj | |
| let c : AtomCode := β¨m, a, centers, rβ© | |
| refine β¨c, ht, β¨hr0, hr1, ha, hsepβ©, x, hx, ?_β© | |
| intro b hb hb1 | |
| rw [hrepr] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| exact atomCurrent_apply _ _ β¨β¨1, hbβ©, 1, hb1β© | |
| noncomputable def selectedAtom [SeparableSpace X] [Nonempty X] | |
| (S : P β Functional X 0) (E : Set P) (c : AtomCode) | |
| (t : atomDomain S E c) : Fin c.size β X := Classical.choose t.property.2.2 | |
| omit [MeasurableSpace X] [BorelSpace X] [MetricSpace P] in | |
| lemma selectedAtom_spec [SeparableSpace X] [Nonempty X] | |
| (S : P β Functional X 0) (E : Set P) (c : AtomCode) (t : atomDomain S E c) : | |
| (β i, dist (selectedAtom S E c t i) (TopologicalSpace.denseSeq X (c.centers i)) β€ c.radius) β§ | |
| UnitRepresentation (S t) c.weights (selectedAtom S E c t) := Classical.choose_spec t.property.2.2 | |
| omit [MeasurableSpace X] [BorelSpace X] in | |
| lemma selectedAtom_lipschitz [SeparableSpace X] [Nonempty X] | |
| (S : P β Functional X 0) (E : Set P) (c : AtomCode) {K : ββ₯0} | |
| (hS : β b : X β β, LipschitzWith 1 b β (β z, |b z| β€ 1) β | |
| LipschitzOnWith K (fun t => S t b (fun j => Fin.elim0 j)) E) | |
| (i : Fin c.size) : LipschitzWith K (fun t : atomDomain S E c => selectedAtom S E c t i) := by | |
| rw [lipschitzWith_iff_dist_le_mul] | |
| intro s t | |
| apply unitRepresentation_matched_distance c s.property.2.1 | |
| (selectedAtom S E c s) (selectedAtom S E c t) | |
| (selectedAtom_spec S E c s).1 (selectedAtom_spec S E c t).1 | |
| (selectedAtom_spec S E c s).2 (selectedAtom_spec S E c t).2 | |
| intro b hb hb1 | |
| simpa only [Real.dist_eq, Subtype.dist_eq] using (hS b hb hb1).dist_le_mul s s.property.1 t t.property.1 | |
| end CAT0Fillings.SliceReconstruction | |
| end | |
| end OAI | |