Download data/lean/OAI/AlgebraicGeometry/CycleClass/Geometric/BarycentricMesh.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.84 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/AlgebraicGeometry/CycleClass/Geometric/BarycentricMesh.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/AlgebraicGeometry/CycleClass/Geometric/BarycentricMesh.lean
-
curl -L -o BarycentricMesh.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/AlgebraicGeometry/CycleClass/Geometric/BarycentricMesh.lean
9.84 kB
| import Mathlib.Analysis.Convex.Combination | |
| import Mathlib.Analysis.Normed.Module.Convex | |
| /-! # Barycentric Mesh -/ | |
| namespace OAI.AlgebraicGeometry.CycleClass.Geometric.BarycentricMesh | |
| noncomputable section | |
| /-! | |
| # Quantitative mesh estimates for barycenters of nested faces | |
| The points are actual vectors in a real normed space and their barycenters are | |
| mathlib's `Finset.centroid`. No simplex mesh estimate is assumed. | |
| -/ | |
| open scoped BigOperators | |
| variable {ΞΉ E : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| /-- The centroid of a nonempty finite set is the arithmetic mean of its vertices. -/ | |
| theorem centroid_eq_inv_card_sum (s : Finset ΞΉ) (hs : s.Nonempty) (v : ΞΉ β E) : | |
| s.centroid β v = (s.card : β)β»ΒΉ β’ β i β s, v i := by | |
| rw [s.centroid_eq_centerMass hs, | |
| s.centerMass_eq_of_sum_1 v (s.sum_centroidWeights_eq_one_of_nonempty β hs)] | |
| simp only [Finset.centroidWeights_apply, Finset.smul_sum] | |
| /-- Subtracting a point commutes with taking the arithmetic mean. -/ | |
| theorem centroid_sub_eq_inv_card_sum (s : Finset ΞΉ) (hs : s.Nonempty) | |
| (v : ΞΉ β E) (x : E) : | |
| s.centroid β v - x = (s.card : β)β»ΒΉ β’ β i β s, (v i - x) := by | |
| have hcard : (s.card : β) β 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hs.card_pos) | |
| rw [centroid_eq_inv_card_sum s hs v, Finset.sum_sub_distrib, smul_sub, | |
| Finset.sum_const, β Nat.cast_smul_eq_nsmul β, smul_smul, | |
| inv_mul_cancelβ hcard, one_smul] | |
| /-- The sum of vertex displacements from their centroid is zero. -/ | |
| theorem sum_sub_centroid_eq_zero (s : Finset ΞΉ) (hs : s.Nonempty) (v : ΞΉ β E) : | |
| β i β s, (v i - s.centroid β v) = 0 := by | |
| have hcard : (s.card : β) β 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hs.card_pos) | |
| rw [Finset.sum_sub_distrib, Finset.sum_const, β Nat.cast_smul_eq_nsmul β, | |
| centroid_eq_inv_card_sum s hs v, smul_smul, mul_inv_cancelβ hcard, | |
| one_smul, sub_self] | |
| /-- A centroid remains within every closed ball containing all its vertices. -/ | |
| theorem dist_centroid_point_le (s : Finset ΞΉ) (hs : s.Nonempty) (v : ΞΉ β E) | |
| (x : E) (D : β) (hD : β i β s, dist (v i) x β€ D) : | |
| dist (s.centroid β v) x β€ D := by | |
| have hcard : (s.card : β) β 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hs.card_pos) | |
| have hnonneg : 0 β€ (s.card : β)β»ΒΉ := inv_nonneg.mpr (Nat.cast_nonneg _) | |
| calc | |
| dist (s.centroid β v) x = | |
| β(s.card : β)β»ΒΉ β’ β i β s, (v i - x)β := by | |
| rw [dist_eq_norm, centroid_sub_eq_inv_card_sum s hs v x] | |
| _ = (s.card : β)β»ΒΉ * ββ i β s, (v i - x)β := by | |
| rw [norm_smul, Real.norm_of_nonneg hnonneg] | |
| _ β€ (s.card : β)β»ΒΉ * β i β s, βv i - xβ := | |
| mul_le_mul_of_nonneg_left (norm_sum_le s _) hnonneg | |
| _ β€ (s.card : β)β»ΒΉ * β _i β s, D := by | |
| apply mul_le_mul_of_nonneg_left _ hnonneg | |
| exact Finset.sum_le_sum (fun i hi => by simpa only [dist_eq_norm] using hD i hi) | |
| _ = D := by | |
| rw [Finset.sum_const, nsmul_eq_mul, β mul_assoc, inv_mul_cancelβ hcard, one_mul] | |
| /-- Nested faces have barycenters closer by the exact missing-vertex proportion. -/ | |
| theorem dist_centroid_le_card_sdiff_div [DecidableEq ΞΉ] | |
| (v : ΞΉ β E) (A B : Finset ΞΉ) (hA : A.Nonempty) (hAB : A β B) | |
| (D : β) (hD : β i β B, β j β B, dist (v i) (v j) β€ D) : | |
| dist (A.centroid β v) (B.centroid β v) β€ | |
| ((B \ A).card : β) / (B.card : β) * D := by | |
| have hB : B.Nonempty := hA.mono hAB | |
| have hnonneg : 0 β€ (B.card : β)β»ΒΉ := inv_nonneg.mpr (Nat.cast_nonneg _) | |
| have hsum : (β i β B, (v i - A.centroid β v)) = | |
| β i β B \ A, (v i - A.centroid β v) := by | |
| rw [β Finset.sum_sdiff hAB, sum_sub_centroid_eq_zero A hA v, add_zero] | |
| have hpoint (j : ΞΉ) (hj : j β B) : βv j - A.centroid β vβ β€ D := by | |
| rw [β dist_eq_norm, dist_comm] | |
| exact dist_centroid_point_le A hA v (v j) D (fun i hi => hD i (hAB hi) j hj) | |
| calc | |
| dist (A.centroid β v) (B.centroid β v) = | |
| β(B.card : β)β»ΒΉ β’ β i β B \ A, (v i - A.centroid β v)β := by | |
| rw [dist_comm, dist_eq_norm, centroid_sub_eq_inv_card_sum B hB v, hsum] | |
| _ = (B.card : β)β»ΒΉ * ββ i β B \ A, (v i - A.centroid β v)β := by | |
| rw [norm_smul, Real.norm_of_nonneg hnonneg] | |
| _ β€ (B.card : β)β»ΒΉ * β i β B \ A, βv i - A.centroid β vβ := | |
| mul_le_mul_of_nonneg_left (norm_sum_le (B \ A) _) hnonneg | |
| _ β€ (B.card : β)β»ΒΉ * β _i β B \ A, D := by | |
| apply mul_le_mul_of_nonneg_left _ hnonneg | |
| exact Finset.sum_le_sum (fun i hi => hpoint i (Finset.mem_sdiff.mp hi).1) | |
| _ = ((B \ A).card : β) / (B.card : β) * D := by | |
| rw [Finset.sum_const, nsmul_eq_mul, div_eq_mul_inv] | |
| ring | |
| /-- The exact estimate expressed as the difference of the two face cardinalities. -/ | |
| theorem dist_centroid_le_card_sub_div [DecidableEq ΞΉ] | |
| (v : ΞΉ β E) (A B : Finset ΞΉ) (hA : A.Nonempty) (hAB : A β B) | |
| (D : β) (hD : β i β B, β j β B, dist (v i) (v j) β€ D) : | |
| dist (A.centroid β v) (B.centroid β v) β€ | |
| ((B.card : β) - (A.card : β)) / (B.card : β) * D := by | |
| simpa only [Finset.card_sdiff_of_subset hAB, Nat.cast_sub (Finset.card_le_card hAB)] | |
| using dist_centroid_le_card_sdiff_div v A B hA hAB D hD | |
| /-- A nonempty nested pair of faces with at most `n+1` vertices contracts by `n/(n+1)`. -/ | |
| theorem dist_centroid_le_dimension_factor_of_subset [DecidableEq ΞΉ] | |
| (v : ΞΉ β E) (A B : Finset ΞΉ) (hA : A.Nonempty) (hAB : A β B) | |
| (n : β) (hcard : B.card β€ n + 1) | |
| (D : β) (hD : β i β B, β j β B, dist (v i) (v j) β€ D) : | |
| dist (A.centroid β v) (B.centroid β v) β€ (n : β) / (n + 1) * D := by | |
| have hD0 : 0 β€ D := by | |
| obtain β¨i, hiβ© := hA | |
| simpa only [dist_self] using hD i (hAB hi) i (hAB hi) | |
| have ha1 : (1 : β) β€ (A.card : β) := by | |
| exact_mod_cast Nat.succ_le_of_lt hA.card_pos | |
| have hbpos : (0 : β) < (B.card : β) := by | |
| exact_mod_cast (hA.mono hAB).card_pos | |
| have hbn : (B.card : β) β€ (n : β) + 1 := by exact_mod_cast hcard | |
| have hn : (0 : β) < (n : β) + 1 := by positivity | |
| have hproduct : (B.card : β) β€ (A.card : β) * ((n : β) + 1) := by | |
| have hmul := mul_le_mul_of_nonneg_right ha1 (le_of_lt hn) | |
| nlinarith | |
| have hratio : ((B.card : β) - (A.card : β)) / (B.card : β) β€ | |
| (n : β) / (n + 1) := by | |
| apply (div_le_div_iffβ hbpos hn).2 | |
| nlinarith | |
| exact (dist_centroid_le_card_sub_div v A B hA hAB D hD).trans | |
| (mul_le_mul_of_nonneg_right hratio hD0) | |
| /-- Any two comparable nonempty faces of `n+1` actual vertices satisfy the mesh bound. -/ | |
| theorem dist_centroid_le_dimension_factor {n : β} | |
| (v : Fin (n + 1) β E) (A B : Finset (Fin (n + 1))) | |
| (hA : A.Nonempty) (hB : B.Nonempty) (hAB : A β B β¨ B β A) | |
| (D : β) (hD : β i j, dist (v i) (v j) β€ D) : | |
| dist (A.centroid β v) (B.centroid β v) β€ (n : β) / (n + 1) * D := by | |
| have hcard (C : Finset (Fin (n + 1))) : C.card β€ n + 1 := by | |
| simpa only [Fintype.card_fin] using C.card_le_univ | |
| rcases hAB with hAB | hBA | |
| Β· exact dist_centroid_le_dimension_factor_of_subset v A B hA hAB n (hcard B) D | |
| (fun i _ j _ => hD i j) | |
| Β· rw [dist_comm] | |
| exact dist_centroid_le_dimension_factor_of_subset v B A hB hBA n (hcard A) D | |
| (fun i _ j _ => hD i j) | |
| /-- The same mesh bound holds throughout the convex hull of a chain of face barycenters. -/ | |
| theorem dist_convexHull_centroids_le_dimension_factor {ΞΊ : Type*} {n : β} | |
| (v : Fin (n + 1) β E) (faces : ΞΊ β Finset (Fin (n + 1))) | |
| (hne : β k, (faces k).Nonempty) | |
| (hchain : β k l, faces k β faces l β¨ faces l β faces k) | |
| (D : β) (hD : β i j, dist (v i) (v j) β€ D) | |
| {x y : E} | |
| (hx : x β convexHull β (Set.range fun k => (faces k).centroid β v)) | |
| (hy : y β convexHull β (Set.range fun k => (faces k).centroid β v)) : | |
| dist x y β€ (n : β) / (n + 1) * D := by | |
| obtain β¨x', β¨k, rflβ©, y', β¨l, rflβ©, hxyβ© := convexHull_exists_dist_ge2 hx hy | |
| exact hxy.trans | |
| (dist_centroid_le_dimension_factor v (faces k) (faces l) (hne k) (hne l) | |
| (hchain k l) D hD) | |
| /-- Barycentric subdivision of a finite simplex has mesh at most `n/(n+1)` times its vertex bound. -/ | |
| theorem diam_convexHull_centroids_le_dimension_factor {ΞΊ : Type*} {n : β} | |
| (v : Fin (n + 1) β E) (faces : ΞΊ β Finset (Fin (n + 1))) | |
| (hne : β k, (faces k).Nonempty) | |
| (hchain : β k l, faces k β faces l β¨ faces l β faces k) | |
| (D : β) (hD : β i j, dist (v i) (v j) β€ D) : | |
| Metric.diam (convexHull β (Set.range fun k => (faces k).centroid β v)) β€ | |
| (n : β) / (n + 1) * D := by | |
| have hD0 : 0 β€ D := by simpa only [dist_self] using hD 0 0 | |
| apply Metric.diam_le_of_forall_dist_le (by positivity) | |
| intro x hx y hy | |
| exact dist_convexHull_centroids_le_dimension_factor v faces hne hchain D hD hx hy | |
| /-- The geometric mesh estimate with the actual diameter of the original simplex. -/ | |
| theorem diam_face_chain_le_simplex_diam {ΞΊ : Type*} {n : β} | |
| (v : Fin (n + 1) β E) (faces : ΞΊ β Finset (Fin (n + 1))) | |
| (hne : β k, (faces k).Nonempty) | |
| (hchain : β k l, faces k β faces l β¨ faces l β faces k) : | |
| Metric.diam (convexHull β (Set.range fun k => (faces k).centroid β v)) β€ | |
| (n : β) / (n + 1) * Metric.diam (convexHull β (Set.range v)) := by | |
| have hD (i j : Fin (n + 1)) : dist (v i) (v j) β€ Metric.diam (Set.range v) := | |
| Metric.dist_le_diam_of_mem (Set.finite_range v).isBounded | |
| (Set.mem_range_self i) (Set.mem_range_self j) | |
| simpa only [convexHull_diam] using | |
| diam_convexHull_centroids_le_dimension_factor v faces hne hchain | |
| (Metric.diam (Set.range v)) hD | |
| end | |
| end OAI.AlgebraicGeometry.CycleClass.Geometric.BarycentricMesh | |