Stafford38/Geometry/ProjectiveChartCoordinates.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Mathlib.Data.Fin.Tuple.Basic
3 public import Mathlib.Algebra.MvPolynomial.Eval
4 public import Mathlib.Algebra.MvPolynomial.Monad
5 public import Mathlib.Algebra.MvPolynomial.Rename
6 public import Mathlib.RingTheory.MvPolynomial.Homogeneous
7 
8 @[expose] public section
9 
10 /-!
11 # Shared coordinates for projective affine charts
12 
13 The point insertion and polynomial dehomogenization maps are owned here so
14 that fixed-chart algebra and arbitrary-chart geometry use one construction.
15 The complement equivalence is an explicit parameter: this preserves the
16 existing arbitrary-chart ordering while allowing the zeroth chart to use the
17 usual `Fin.succ` ordering.
18 -/
19 
20 namespace Stafford38.Geometry.ProjectiveChartCoordinates
21 
22 noncomputable section
23 
24 universe u
25 
26 variable {K : Type u} [Field K]
27 
28 /-- Indices in the projective coordinate set other than the selected chart. -/
29 abbrev ChartAffineIndex (ι : Type*) (chart : ι) := {i : ι // i ≠ chart}
30 
31 /-- Insert a normalized projective chart coordinate and fill the complement
32 using the explicitly chosen affine-coordinate ordering. -/
33 def insertProjectiveChart {m : ℕ} (chart : Fin (m + 1))
34     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) chart)
35     (y : Fin m → K) : Fin (m + 1) → K :=
36   fun a ↦ if h : a = chart then 1 else y (e.symm ⟨a, h⟩)
37 
38 /-- Differential of a normalized projective coordinate `q_i / q_chart` in
39 the projective direction `w`.  This single formula owns both the arbitrary
40 chart and fixed zeroth-chart tangent columns. -/
41 def dehomogenizedTangentColumn {ι : Type*} (chart : ι)
42     (q w : ι → K) : ChartAffineIndex ι chart → K :=
43   fun i ↦ (w i.1 * q chart - q i.1 * w chart) / q chart ^ 2
44 
45 @[simp] theorem dehomogenizedTangentColumn_apply {ι : Type*} (chart : ι)
46     (q w : ι → K) (i : ChartAffineIndex ι chart) :
47     dehomogenizedTangentColumn chart q w i =
48       (w i.1 * q chart - q i.1 * w chart) / q chart ^ 2 := rfl
49 
50 /-- Dehomogenize a projective polynomial in a selected chart, using the same
51 explicit ordering of complementary coordinates as `insertProjectiveChart`. -/
52 def dehomogenizeProjectiveChart {m : ℕ} (chart : Fin (m + 1))
53     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) chart) :
54     MvPolynomial (Fin (m + 1)) K →ₐ[K] MvPolynomial (Fin m) K :=
55   MvPolynomial.aeval fun a ↦
56     if h : a = chart then 1 else MvPolynomial.X (e.symm ⟨a, h⟩)
57 
58 /-- Evaluation after dehomogenization is evaluation at the inserted chart
59 point. -/
60 theorem eval_dehomogenizeProjectiveChart {m : ℕ} (chart : Fin (m + 1))
61     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) chart)
62     (p : MvPolynomial (Fin (m + 1)) K) (y : Fin m → K) :
63     MvPolynomial.eval y (dehomogenizeProjectiveChart chart e p) =
64       MvPolynomial.eval (insertProjectiveChart chart e y) p := by
65   rw [show dehomogenizeProjectiveChart chart e p = MvPolynomial.bind₁
66       (fun a ↦ if h : a = chart then 1 else MvPolynomial.X (e.symm ⟨a, h⟩)) p by rfl]
67   rw [MvPolynomial.hom_bind₁]
68   change MvPolynomial.eval₂ _ _ p = MvPolynomial.eval₂ _ _ p
69   have hcoeff : (MvPolynomial.eval y).comp MvPolynomial.C = RingHom.id K := by
70     ext a
71     simp
72   rw [hcoeff]
73   apply MvPolynomial.eval₂_congr
74   intro a
75   by_cases h : a = chart
76   · subst a
77     simp [insertProjectiveChart]
78   · simp [insertProjectiveChart, h]
79 
80 /-- The affine ideal generated by a family of equations after dehomogenizing
81 in one chosen projective chart.  This is the shared owner for fixed-chart and
82 arbitrary-chart equation ideals. -/
83 def dehomogenizedEquationIdeal {m : ℕ} {ι : Type*}
84     (chart : Fin (m + 1))
85     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) chart)
86     (equations : ι → MvPolynomial (Fin (m + 1)) K) :
87     Ideal (MvPolynomial (Fin m) K) :=
88   Ideal.span (Set.range fun i ↦ dehomogenizeProjectiveChart chart e (equations i))
89 
90 /-- Every member of the chart-dehomogenized equation ideal vanishes at an
91 affine point whenever all inserted projective generators vanish there. -/
92 theorem eval_eq_zero_of_mem_dehomogenizedEquationIdeal
93     {m : ℕ} {ι : Type*} (chart : Fin (m + 1))
94     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) chart)
95     (equations : ι → MvPolynomial (Fin (m + 1)) K)
96     (y : Fin m → K)
97     (hvanish : ∀ i,
98       MvPolynomial.eval (insertProjectiveChart chart e y) (equations i) = 0)
99     (f : MvPolynomial (Fin m) K)
100     (hf : f ∈ dehomogenizedEquationIdeal chart e equations) :
101     MvPolynomial.eval y f = 0 := by
102   have hle : dehomogenizedEquationIdeal chart e equations ≤
103       RingHom.ker (MvPolynomial.eval y) := by
104     apply Ideal.span_le.mpr
105     rintro _ ⟨i, rfl⟩
106     change MvPolynomial.eval y (dehomogenizeProjectiveChart chart e (equations i)) = 0
107     rw [eval_dehomogenizeProjectiveChart]
108     exact hvanish i
109   exact hle hf
110 
111 /-- The canonical complementary ordering for the zeroth chart. -/
112 def zerothChartEquiv {m : ℕ} :
113     Fin m ≃ ChartAffineIndex (Fin (m + 1)) (0 : Fin (m + 1)) :=
114   Equiv.ofBijective
115     (fun i ↦ (⟨i.succ, Fin.succ_ne_zero i⟩ :
116       ChartAffineIndex (Fin (m + 1)) (0 : Fin (m + 1))))
117     ⟨by
118       intro i j h
119       exact (Fin.succ_injective _ ) (congrArg Subtype.val h),
120      by
121       intro ⟨j, hj⟩
122       rcases Fin.eq_zero_or_eq_succ j with hzero | ⟨i, hi⟩
123       · exact (hj hzero).elim
124       · refine ⟨i, ?_⟩
125         apply Subtype.ext
126         exact hi.symm⟩
127 
128 @[simp] theorem zerothChartEquiv_apply {m : ℕ} (i : Fin m) :
129     zerothChartEquiv (m := m) i = ⟨i.succ, Fin.succ_ne_zero i⟩ := rfl
130 
131 @[simp] theorem zerothChartEquiv_symm_apply_succ {m : ℕ} (i : Fin m) :
132     (zerothChartEquiv (m := m)).symm ⟨i.succ, Fin.succ_ne_zero i⟩ = i :=
133   Equiv.apply_symm_apply _ i
134 
135 /-- The zeroth-chart specialization is exactly the standard tuple
136 `(1,y₀,…,y_{m-1})`. -/
137 @[simp] theorem insertProjectiveChart_zero {m : ℕ} (y : Fin m → K) :
138     insertProjectiveChart (0 : Fin (m + 1)) (zerothChartEquiv (m := m)) y =
139       Fin.cases 1 y := by
140   funext a
141   refine Fin.cases ?_ (fun i ↦ ?_) a
142   · simp [insertProjectiveChart]
143   · simp [insertProjectiveChart]
144 
145 /-- Changing the chosen zeroth-chart complement ordering only reindexes the
146 affine tuple; the inserted projective point is unchanged. -/
147 theorem insertProjectiveChart_zero_transport {m : ℕ}
148     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) (0 : Fin (m + 1)))
149     (y : Fin m → K) :
150     insertProjectiveChart (0 : Fin (m + 1)) e y =
151       insertProjectiveChart (0 : Fin (m + 1)) (zerothChartEquiv (m := m))
152         (fun i ↦ y ((zerothChartEquiv (m := m)).trans e.symm i)) := by
153   funext a
154   rcases Fin.eq_zero_or_eq_succ a with rfl | ⟨i, rfl⟩
155   · simp [insertProjectiveChart]
156   · simp [insertProjectiveChart]
157 
158 /-- The zeroth-chart polynomial map is exactly substitution
159 `X₀ ↦ 1`, `X_(i+1) ↦ X_i`. -/
160 @[simp] theorem dehomogenizeProjectiveChart_zero {m : ℕ}
161     : dehomogenizeProjectiveChart (0 : Fin (m + 1)) (zerothChartEquiv (m := m)) =
162       MvPolynomial.aeval (R := K) (S₁ := MvPolynomial (Fin m) K)
163         (Fin.cases (1 : MvPolynomial (Fin m) K) fun i ↦ MvPolynomial.X i) := by
164   apply MvPolynomial.algHom_ext
165   intro a
166   refine Fin.cases ?_ (fun i ↦ ?_) a
167   · simp [dehomogenizeProjectiveChart]
168   · simp [dehomogenizeProjectiveChart]
169 
170 /-- Changing the chosen zeroth-chart complement ordering changes the
171 dehomogenization map only by the corresponding affine-variable renaming. -/
172 theorem dehomogenizeProjectiveChart_zero_transport {m : ℕ}
173     (e : Fin m ≃ ChartAffineIndex (Fin (m + 1)) (0 : Fin (m + 1))) :
174     (MvPolynomial.renameEquiv K
175         ((zerothChartEquiv (m := m)).trans e.symm)).toAlgHom.comp
176         (dehomogenizeProjectiveChart (0 : Fin (m + 1))
177           (zerothChartEquiv (m := m))) =
178       dehomogenizeProjectiveChart (0 : Fin (m + 1)) e := by
179   apply MvPolynomial.algHom_ext
180   intro a
181   rcases Fin.eq_zero_or_eq_succ a with rfl | ⟨i, rfl⟩
182   · simp [dehomogenizeProjectiveChart]
183   · simp [dehomogenizeProjectiveChart]
184 
185 #print axioms eval_dehomogenizeProjectiveChart
186 #print axioms insertProjectiveChart_zero
187 #print axioms insertProjectiveChart_zero_transport
188 #print axioms dehomogenizeProjectiveChart_zero
189 #print axioms dehomogenizeProjectiveChart_zero_transport
190 
191 end
192 end Stafford38.Geometry.ProjectiveChartCoordinates
193