Download data/lean/OAI/Geometry/CylinderCovering/Radial/Projection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.52 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/CylinderCovering/Radial/Projection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Geometry/CylinderCovering/Radial/Projection.lean
-
curl -L -o Projection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Geometry/CylinderCovering/Radial/Projection.lean
9.52 kB
| import OAI.Geometry.TriangularCovering.Main | |
| import OAI.Geometry.CylinderCovering.Radial.Triangle | |
| namespace OAI | |
| noncomputable section | |
| namespace RadialProjection | |
| open TriangularCovering Set MeasureTheory | |
| open scoped InnerProductSpace | |
| lemma cross3_cross_right (u v w : Space) : | |
| cross3 u (cross3 v w) = (inner β u w) β’ v - (inner β u v) β’ w := by | |
| ext i | |
| fin_cases i <;> simp [cross3_coord, inner_coord] <;> ring | |
| lemma cross3_normal {e a b : Space} (he : βeβ = 1) | |
| (ha : inner β e a = 0) (hb : inner β e b = 0) : | |
| cross3 a b = (inner β e (cross3 a b)) β’ e := by | |
| have hc : cross3 e (cross3 a b) = 0 := by | |
| rw [cross3_cross_right, ha, hb] | |
| simp | |
| have hh := cross3_cross_right e e (cross3 a b) | |
| rw [hc] at hh | |
| have hz : cross3 e 0 = 0 := by | |
| ext i | |
| fin_cases i <;> simp [cross3_coord] | |
| rw [hz, real_inner_self_eq_norm_sq, he, one_pow, one_smul] at hh | |
| exact (sub_eq_zero.mp hh.symm).symm | |
| lemma sideways_norm {e w : Space} (he : βeβ = 1) | |
| (hw : inner β e w = 0) : βe + wβ = Real.sqrt (1 + βwβ ^ 2) := by | |
| have hsq : βe + wβ ^ 2 = 1 + βwβ ^ 2 := by | |
| rw [norm_add_sq_real, he, hw] | |
| ring | |
| rw [β hsq, Real.sqrt_sq (norm_nonneg _)] | |
| lemma sideways_ne_zero {e w : Space} (he : βeβ = 1) | |
| (hw : inner β e w = 0) : e + w β 0 := by | |
| intro h | |
| have hn := sideways_norm he hw | |
| rw [h, norm_zero] at hn | |
| have hp : 0 < Real.sqrt (1 + βwβ ^ 2) := by positivity | |
| linarith | |
| lemma normal_cross_abs {e a b : Space} (he : βeβ = 1) | |
| (ha : inner β e a = 0) (hb : inner β e b = 0) : | |
| |inner β e (cross3 a b)| = | |
| Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) := by | |
| have hh := triple_gram_identity e a b | |
| rw [ha, hb, real_inner_self_eq_norm_sq e, he] at hh | |
| norm_num at hh | |
| rw [real_inner_self_eq_norm_sq a, real_inner_self_eq_norm_sq b, | |
| β hh, Real.sqrt_sq_eq_abs] | |
| theorem normal_projection_factor {e a b w : Space} (he : βeβ = 1) | |
| (ha : inner β e a = 0) (hb : inner β e b = 0) | |
| (hw : inner β e w = 0) : | |
| |inner β (unit (e + w)) (cross3 a b)| = | |
| Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) / | |
| Real.sqrt (1 + βwβ ^ 2) := by | |
| have hcrossw : inner β w (cross3 a b) = 0 := by | |
| rw [cross3_normal he ha hb, inner_smul_right, real_inner_comm e w, hw] | |
| simp | |
| rw [TriangularCovering.unit, inner_smul_left, inner_add_left, hcrossw, add_zero] | |
| simp only [conj_trivial, abs_mul, abs_inv, abs_norm] | |
| rw [normal_cross_abs he ha hb, sideways_norm he hw] | |
| ring | |
| lemma cross3_coordinates (a b : Space) (uβ vβ uβ vβ : β) : | |
| cross3 (uβ β’ a + vβ β’ b) (uβ β’ a + vβ β’ b) = | |
| (uβ * vβ - vβ * uβ) β’ cross3 a b := by | |
| ext i | |
| fin_cases i <;> simp [cross3_coord] <;> ring | |
| lemma collar_cross (pβ a b : Space) (l r m d : β) : | |
| cross3 | |
| ((pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b)) | |
| ((pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b)) = | |
| (d * (r - l) ^ 2) β’ cross3 a b := by | |
| have hβ : (pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b) = | |
| (r - l) β’ a + (m * (r - l) - d / 2 * (r - l)) β’ b := by module | |
| have hβ : (pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b) = | |
| (r - l) β’ a + (m * (r - l) + d / 2 * (r - l)) β’ b := by module | |
| rw [hβ, hβ, cross3_coordinates] | |
| congr 1 | |
| ring | |
| theorem collar_projection_area (pβ e a b w : Space) (l r m d : β) | |
| (he : βeβ = 1) (ha : inner β e a = 0) (hb : inner β e b = 0) | |
| (hw : inner β e w = 0) (hd : 0 β€ d) : | |
| area (projection (TriangularCovering.unit (e + w)) '' triangle | |
| (pβ + l β’ a + (m * l) β’ b) | |
| (pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) | |
| (pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b)) = | |
| Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) * | |
| d * (r - l) ^ 2 / (2 * Real.sqrt (1 + βwβ ^ 2)) := by | |
| unfold area | |
| rw [projection_triangle_measure (unit_norm (sideways_ne_zero he hw)), | |
| ENNReal.toReal_ofReal (by positivity), collar_cross, inner_smul_right, | |
| abs_mul, abs_of_nonneg (mul_nonneg hd (sq_nonneg _)), | |
| normal_projection_factor he ha hb hw] | |
| ring | |
| theorem collar_projection_nondegenerate (pβ e a b w : Space) (l r m d : β) | |
| (he : βeβ = 1) (ha : inner β e a = 0) (hb : inner β e b = 0) | |
| (hw : inner β e w = 0) (hd : 0 < d) (hlr : l < r) | |
| (hΞΊ : 0 < Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2)) : | |
| inner β (TriangularCovering.unit (e + w)) | |
| (cross3 | |
| ((pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b)) | |
| ((pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b) - | |
| (pβ + l β’ a + (m * l) β’ b))) β 0 := by | |
| rw [β abs_pos, collar_cross, inner_smul_right, abs_mul, | |
| abs_of_nonneg (mul_nonneg hd.le (sq_nonneg _)), normal_projection_factor he ha hb hw] | |
| exact mul_pos (mul_pos hd (sq_pos_of_pos (sub_pos.mpr hlr))) (div_pos hΞΊ (by positivity)) | |
| lemma gram_sqrt_pos {a b : Space} | |
| (hab : LinearIndependent β (![a, b] : Fin 2 β Space)) : | |
| 0 < Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) := by | |
| have hpi : LinearIndependent β (![a.ofLp, b.ofLp] : Fin 2 β (Fin 3 β β)) := by | |
| have hh := hab.map' (EuclideanSpace.equiv (Fin 3) β).toLinearMap | |
| (LinearMap.ker_eq_bot.mpr (EuclideanSpace.equiv (Fin 3) β).injective) | |
| have hfun : (EuclideanSpace.equiv (Fin 3) β).toLinearMap β | |
| (![a, b] : Fin 2 β Space) = ![a.ofLp, b.ofLp] := by | |
| funext i | |
| fin_cases i <;> rfl | |
| rw [hfun] at hh | |
| exact hh | |
| have hc : cross3 a b β 0 := by | |
| intro hz | |
| apply (crossProduct_ne_zero_iff_linearIndependent.mpr hpi) | |
| simpa [cross3] using congrArg WithLp.ofLp hz | |
| rw [β cross3_gram, real_inner_self_eq_norm_sq, Real.sqrt_sq (norm_nonneg _)] | |
| exact norm_pos_iff.mpr hc | |
| def coordinateAffine (pβ a b : Space) : (β Γ β) βα΅[β] Space where | |
| toFun := fun p => pβ + p.1 β’ a + p.2 β’ b | |
| linear := (LinearMap.fst β β β).smulRight a + (LinearMap.snd β β β).smulRight b | |
| map_vadd' := by | |
| intro p v | |
| simp only [vadd_eq_add, Prod.fst_add, Prod.snd_add, LinearMap.add_apply, | |
| LinearMap.smulRight_apply, LinearMap.fst_apply, LinearMap.snd_apply] | |
| module | |
| lemma coordinate_region_image (pβ a b : Space) {l r m d : β} | |
| (hlr : l < r) (hd : 0 < d) : | |
| coordinateAffine pβ a b '' CylinderCovering.RadialTriangle.region l r m d = | |
| triangle (pβ + l β’ a + (m * l) β’ b) | |
| (pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) | |
| (pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b) := by | |
| rw [CylinderCovering.RadialTriangle.region_eq_convexHull hlr hd, | |
| (coordinateAffine pβ a b).image_convexHull, triangle] | |
| congr 1 | |
| rw [β Set.range_comp] | |
| congr 1 | |
| funext i | |
| fin_cases i <;> rfl | |
| theorem exists_collar_cylinder_exact (pβ e a b w : Space) (l r m d : β) | |
| (he : βeβ = 1) (ha : inner β e a = 0) (hb : inner β e b = 0) | |
| (hw : inner β e w = 0) (hd : 0 < d) (hlr : l < r) | |
| (hab : LinearIndependent β (![a, b] : Fin 2 β Space)) : | |
| β c : TriCylinder, | |
| c.axis = TriangularCovering.unit (e + w) β§ | |
| c.base = projection (TriangularCovering.unit (e + w)) '' triangle | |
| (pβ + l β’ a + (m * l) β’ b) | |
| (pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b) | |
| (pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b) β§ | |
| area c.base = Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) * | |
| d * (r - l) ^ 2 / (2 * Real.sqrt (1 + βwβ ^ 2)) β§ | |
| β u v s : β, l β€ u β u β€ r β |v - m * u| β€ d / 2 * (u - l) β | |
| pβ + u β’ a + v β’ b + s β’ (e + w) β c.carrier := by | |
| let P := pβ + l β’ a + (m * l) β’ b | |
| let Q := pβ + r β’ a + (m * r - d / 2 * (r - l)) β’ b | |
| let R := pβ + r β’ a + (m * r + d / 2 * (r - l)) β’ b | |
| have hv := sideways_ne_zero he hw | |
| have hcross := collar_projection_nondegenerate pβ e a b w l r m d | |
| he ha hb hw hd hlr (gram_sqrt_pos hab) | |
| refine β¨projectedCylinder (TriangularCovering.unit (e + w)) (unit_norm hv) | |
| P Q R hcross, rfl, rfl, ?_, ?_β© | |
| Β· exact collar_projection_area pβ e a b w l r m d he ha hb hw hd.le | |
| Β· intro u v s hlu hur huv | |
| have hp : pβ + u β’ a + v β’ b β triangle P Q R := by | |
| rw [β coordinate_region_image pβ a b hlr hd] | |
| exact β¨(u, v), β¨hlu, hur, huvβ©, rflβ© | |
| exact projectedCylinder_mem_direction (e + w) hv P Q R hcross hp s rfl | |
| theorem exists_collar_cylinder (pβ e a b w : Space) (l r m d : β) | |
| (he : βeβ = 1) (ha : inner β e a = 0) (hb : inner β e b = 0) | |
| (hw : inner β e w = 0) (hd : 0 < d) (hlr : l < r) | |
| (hab : LinearIndependent β (![a, b] : Fin 2 β Space)) : | |
| β c : TriCylinder, | |
| c.axis = TriangularCovering.unit (e + w) β§ | |
| area c.base = Real.sqrt (inner β a a * inner β b b - (inner β a b) ^ 2) * | |
| d * (r - l) ^ 2 / (2 * Real.sqrt (1 + βwβ ^ 2)) β§ | |
| β u v s : β, l β€ u β u β€ r β |v - m * u| β€ d / 2 * (u - l) β | |
| pβ + u β’ a + v β’ b + s β’ (e + w) β c.carrier := by | |
| obtain β¨c, haxis, _, harea, hcoverβ© := | |
| exists_collar_cylinder_exact pβ e a b w l r m d he ha hb hw hd hlr hab | |
| exact β¨c, haxis, harea, hcoverβ© | |
| end RadialProjection | |
| end | |
| end OAI | |