Stafford38/Ore/LinearNormalForm.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import AlgebraicAnalysis.Ore.Associativity
3 public import Stafford38.Ore.ScalarAlgebra
4 public import Stafford38.Ore.PairStage
5 public import Mathlib.Algebra.MvPolynomial.Equiv
6 public import Mathlib.Algebra.Polynomial.AlgebraMap
7 
8 @[expose] public section
9 
10 /-!
11 # Scalar-linear Ore normal forms
12 
13 The additive normal-form equivalence is linear over every central scalar ring
14 killed by the coefficient derivation.  This is the scalar interface needed to
15 turn the iterated Ore normal form into a PBW basis.
16 -/
17 
18 namespace Stafford38.OreLinearNormalForm
19 
20 open Polynomial
21 open AlgebraicAnalysis
22 open AlgebraicAnalysis.OreDivision
23 open AlgebraicAnalysis.OreAssociativity
24 open Stafford38.OreScalarAlgebra
25 open Stafford38.OreCoordinateStage
26 open Stafford38.OrePairStage
27 
28 noncomputable section
29 
30 /-- Polynomials are linearly equivalent to their coefficient finsupps. -/
31 def polynomialFinsuppLinearEquiv
32     {k R : Type*} [CommSemiring k] [Semiring R] [Algebra k R] :
33     Polynomial R ≃ₗ[k] (ℕ →₀ R) :=
34   { (Polynomial.toFinsuppIso R).toAddEquiv.trans
35       (AddMonoidAlgebra.coeffLinearEquiv k).toAddEquiv with
36     map_smul' := by
37       intro c p
38       rfl }
39 
40 /-- Apply a linear equivalence independently to every polynomial
41 coefficient. -/
42 def polynomialMapRangeLinearEquiv
43     {k R S : Type*} [CommSemiring k] [Semiring R] [Semiring S]
44     [Algebra k R] [Algebra k S] (e : R ≃ₗ[k] S) :
45     Polynomial R ≃ₗ[k] Polynomial S :=
46   (polynomialFinsuppLinearEquiv (k := k) (R := R)).trans
47     ((Finsupp.mapRange.linearEquiv e).trans
48       (polynomialFinsuppLinearEquiv (k := k) (R := S)).symm)
49 
50 @[simp] theorem polynomialMapRangeLinearEquiv_C
51     {k R S : Type*} [CommSemiring k] [Semiring R] [Semiring S]
52     [Algebra k R] [Algebra k S] (e : R ≃ₗ[k] S) (r : R) :
53     polynomialMapRangeLinearEquiv e (Polynomial.C r) =
54       Polynomial.C (e r) := by
55   apply (Polynomial.toFinsuppIso S).injective
56   simp [polynomialMapRangeLinearEquiv, polynomialFinsuppLinearEquiv]
57 
58 @[simp] theorem polynomialMapRangeLinearEquiv_monomial
59     {k R S : Type*} [CommSemiring k] [Semiring R] [Semiring S]
60     [Algebra k R] [Algebra k S] (e : R ≃ₗ[k] S) (n : ℕ) (r : R) :
61     polynomialMapRangeLinearEquiv e (Polynomial.monomial n r) =
62       Polynomial.monomial n (e r) := by
63   apply (Polynomial.toFinsuppIso S).injective
64   simp [polynomialMapRangeLinearEquiv, polynomialFinsuppLinearEquiv]
65 
66 @[simp] theorem polynomialMapRangeLinearEquiv_X
67     {k R S : Type*} [CommSemiring k] [Semiring R] [Semiring S]
68     [Algebra k R] [Algebra k S] (e : R ≃ₗ[k] S)
69     (h1 : e 1 = 1) :
70     polynomialMapRangeLinearEquiv e Polynomial.X = Polynomial.X := by
71   apply (Polynomial.toFinsuppIso S).injective
72   simp [polynomialMapRangeLinearEquiv, polynomialFinsuppLinearEquiv, h1]
73 
74 @[simp] theorem polynomialMapRangeLinearEquiv_one
75     {k R S : Type*} [CommSemiring k] [Semiring R] [Semiring S]
76     [Algebra k R] [Algebra k S] (e : R ≃ₗ[k] S)
77     (h1 : e 1 = 1) :
78     polynomialMapRangeLinearEquiv e 1 = 1 := by
79   change polynomialMapRangeLinearEquiv e (Polynomial.C 1) = Polynomial.C 1
80   rw [polynomialMapRangeLinearEquiv_C, h1]
81 
82 /-- A univariate polynomial is a multivariate polynomial in one `PUnit`
83 variable, linearly over any central ground ring. -/
84 def univariateMvPolynomialLinearEquiv
85     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] :
86     Polynomial R ≃ₗ[k] MvPolynomial PUnit.{1} R :=
87   ((MvPolynomial.pUnitAlgEquiv R).symm.toLinearEquiv).restrictScalars k
88 
89 @[simp] theorem univariateMvPolynomialLinearEquiv_C
90     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] (r : R) :
91     univariateMvPolynomialLinearEquiv (k := k) (R := R) (Polynomial.C r) =
92       MvPolynomial.C r := by
93   simp [univariateMvPolynomialLinearEquiv, MvPolynomial.pUnitAlgEquiv]
94 
95 @[simp] theorem univariateMvPolynomialLinearEquiv_X
96     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] :
97     univariateMvPolynomialLinearEquiv (k := k) (R := R) Polynomial.X =
98       MvPolynomial.X (PUnit.unit : PUnit.{1}) := by
99   simp [univariateMvPolynomialLinearEquiv, MvPolynomial.pUnitAlgEquiv]
100 
101 /-- Flatten two nested univariate polynomial layers into two commuting symbol
102 variables as an algebra equivalence over the coefficient ring. -/
103 def nestedPolynomialAlgEquiv (R : Type*) [CommRing R] :
104     Polynomial (Polynomial R) ≃ₐ[R]
105       MvPolynomial (PUnit.{1} ⊕ PUnit.{1}) R :=
106   (Polynomial.mapAlgEquiv ((MvPolynomial.pUnitAlgEquiv R).symm)).trans
107     ((((MvPolynomial.pUnitAlgEquiv (MvPolynomial PUnit.{1} R)).symm
108       ).restrictScalars R).trans
109         (MvPolynomial.sumAlgEquiv R PUnit.{1} PUnit.{1}).symm)
110 
111 /-- The scalar-linear form of `nestedPolynomialAlgEquiv`. -/
112 def nestedPolynomialLinearEquiv
113     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] :
114     Polynomial (Polynomial R) ≃ₗ[k]
115       MvPolynomial (PUnit.{1} ⊕ PUnit.{1}) R :=
116   (nestedPolynomialAlgEquiv R).toLinearEquiv.restrictScalars k
117 
118 @[simp] theorem nestedPolynomialLinearEquiv_constant
119     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] (r : R) :
120     nestedPolynomialLinearEquiv (k := k) (R := R)
121         (Polynomial.C (Polynomial.C r)) = MvPolynomial.C r := by
122   simp [nestedPolynomialLinearEquiv, nestedPolynomialAlgEquiv]
123 
124 @[simp] theorem nestedPolynomialLinearEquiv_coordinate
125     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] :
126     nestedPolynomialLinearEquiv (k := k) (R := R)
127         (Polynomial.C Polynomial.X) =
128       MvPolynomial.X (.inr (PUnit.unit : PUnit.{1})) := by
129   simp [nestedPolynomialLinearEquiv, nestedPolynomialAlgEquiv]
130 
131 @[simp] theorem nestedPolynomialLinearEquiv_momentum
132     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R] :
133     nestedPolynomialLinearEquiv (k := k) (R := R) Polynomial.X =
134       MvPolynomial.X (.inl (PUnit.unit : PUnit.{1})) := by
135   simp [nestedPolynomialLinearEquiv, nestedPolynomialAlgEquiv]
136 
137 private theorem nestedPolynomialLinearEquiv_mul
138     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R]
139     (f g : Polynomial (Polynomial R)) :
140     nestedPolynomialLinearEquiv (k := k) (R := R) (f * g) =
141       nestedPolynomialLinearEquiv (k := k) (R := R) f *
142         nestedPolynomialLinearEquiv (k := k) (R := R) g := by
143   change nestedPolynomialAlgEquiv R (f * g) =
144     nestedPolynomialAlgEquiv R f * nestedPolynomialAlgEquiv R g
145   exact map_mul (nestedPolynomialAlgEquiv R) f g
146 
147 private theorem nestedPolynomialLinearEquiv_pow
148     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R]
149     (f : Polynomial (Polynomial R)) (n : ℕ) :
150     nestedPolynomialLinearEquiv (k := k) (R := R) (f ^ n) =
151       nestedPolynomialLinearEquiv (k := k) (R := R) f ^ n := by
152   change nestedPolynomialAlgEquiv R (f ^ n) =
153     nestedPolynomialAlgEquiv R f ^ n
154   exact map_pow (nestedPolynomialAlgEquiv R) f n
155 
156 /-- Nested univariate monomials become the two corresponding commuting symbol
157 powers, with the outer polynomial variable in the left summand. -/
158 theorem nestedPolynomialLinearEquiv_monomial
159     {k R : Type*} [CommRing k] [CommRing R] [Algebra k R]
160     (r : R) (a p : ℕ) :
161     nestedPolynomialLinearEquiv (k := k) (R := R)
162         (Polynomial.monomial p (Polynomial.monomial a r)) =
163       MvPolynomial.X (.inl (PUnit.unit : PUnit.{1})) ^ p *
164       MvPolynomial.X (.inr (PUnit.unit : PUnit.{1})) ^ a *
165         MvPolynomial.C r := by
166   rw [← Polynomial.C_mul_X_pow_eq_monomial,
167     ← Polynomial.C_mul_X_pow_eq_monomial]
168   rw [show Polynomial.C (Polynomial.C r * Polynomial.X ^ a) =
169       Polynomial.C (Polynomial.C r) *
170         Polynomial.C Polynomial.X ^ a by rw [map_mul, map_pow]]
171   rw [nestedPolynomialLinearEquiv_mul,
172     nestedPolynomialLinearEquiv_mul,
173     nestedPolynomialLinearEquiv_pow,
174     nestedPolynomialLinearEquiv_pow,
175     nestedPolynomialLinearEquiv_constant,
176     nestedPolynomialLinearEquiv_coordinate,
177     nestedPolynomialLinearEquiv_momentum]
178   ring
179 
180 section OneVariable
181 
182 variable {k B : Type*} [CommRing k] [Ring B] [Algebra k B]
183 variable (D : OreDivisionDerivation B)
184 variable [Algebra k (NormalOre D)]
185 variable (hAlg : algebraMap k (NormalOre D) =
186   (normalCoefficient D).comp (algebraMap k B))
187 
188 include hAlg
189 
190 /-- The coefficient-left normal-form map respects central scalar
191 multiplication. -/
192 theorem normalForm_smul (c : k) (p : Polynomial B) :
193     normalForm D (c • p) = c • normalForm D p := by
194   induction p using Polynomial.induction_on' with
195   | add p q hp hq =>
196       rw [smul_add, normalForm_add, normalForm_add, hp, hq,
197         Algebra.smul_def, Algebra.smul_def, Algebra.smul_def, mul_add]
198   | monomial n b =>
199       rw [Polynomial.smul_monomial, normalForm_monomial,
200         normalForm_monomial]
201       rw [Algebra.smul_def c b]
202       have hs : c • (normalCoefficient D b * normalVariable D ^ n) =
203           algebraMap k (NormalOre D) c *
204             (normalCoefficient D b * normalVariable D ^ n) :=
205         Algebra.smul_def c _
206       rw [hs, hAlg]
207       change normalCoefficient D (algebraMap k B c * b) * normalVariable D ^ n =
208         normalCoefficient D (algebraMap k B c) *
209           (normalCoefficient D b * normalVariable D ^ n)
210       rw [map_mul, mul_assoc]
211 
212 /-- Ore normal forms are linearly equivalent to ordinary coefficient-left
213 polynomials. -/
214 def normalFormLinearEquiv : Polynomial B ≃ₗ[k] NormalOre D :=
215   { normalFormAddEquiv D with
216     map_smul' := normalForm_smul D hAlg }
217 
218 @[simp] theorem normalFormLinearEquiv_apply (p : Polynomial B) :
219     normalFormLinearEquiv D hAlg p = normalForm D p := rfl
220 
221 @[simp] theorem normalFormLinearEquiv_symm_normalForm (p : Polynomial B) :
222     (normalFormLinearEquiv D hAlg).symm (normalForm D p) = p :=
223   (normalFormLinearEquiv D hAlg).symm_apply_apply p
224 
225 @[simp] theorem normalFormLinearEquiv_symm_coefficient (b : B) :
226     (normalFormLinearEquiv D hAlg).symm (normalCoefficient D b) =
227       Polynomial.C b := by
228   rw [← normalForm_C, normalFormLinearEquiv_symm_normalForm]
229 
230 @[simp] theorem normalFormLinearEquiv_symm_variable :
231     (normalFormLinearEquiv D hAlg).symm (normalVariable D) =
232       Polynomial.X := by
233   rw [normalVariable, normalFormLinearEquiv_symm_normalForm]
234 
235 @[simp] theorem normalFormLinearEquiv_symm_one :
236     (normalFormLinearEquiv D hAlg).symm 1 = 1 := by
237   rw [← normalForm_one D, normalFormLinearEquiv_symm_normalForm]
238 
239 end OneVariable
240 
241 section Pair
242 
243 set_option synthInstance.maxHeartbeats 100000
244 set_option maxHeartbeats 1000000
245 
246 /-- Expose the two coefficient-left polynomial layers of a pair stage and
247 apply a chosen linear coordinate system to the old coefficients. -/
248 def pairNormalFormLinearEquiv
249     {k B S : Type*} [CommRing k] [Ring B] [Algebra k B]
250     [CommRing S] [Algebra k S]
251     [Algebra k (CoordinateStage (B := B))]
252     [Algebra k (PairStage (B := B))]
253     (hInner : algebraMap k (CoordinateStage (B := B)) =
254       (normalCoefficient zeroDerivation).comp (algebraMap k B))
255     (hOuter : algebraMap k (PairStage (B := B)) =
256       (normalCoefficient coordinateDerivation).comp
257         (algebraMap k (CoordinateStage (B := B))))
258     (e : B ≃ₗ[k] S) :
259     PairStage (B := B) ≃ₗ[k] Polynomial (Polynomial S) :=
260   (normalFormLinearEquiv coordinateDerivation hOuter).symm.trans
261     (polynomialMapRangeLinearEquiv
262       ((normalFormLinearEquiv zeroDerivation hInner).symm.trans
263         (polynomialMapRangeLinearEquiv e)))
264 
265 @[simp] theorem pairNormalFormLinearEquiv_coefficient
266     {k B S : Type*} [CommRing k] [Ring B] [Algebra k B]
267     [CommRing S] [Algebra k S]
268     [Algebra k (CoordinateStage (B := B))]
269     [Algebra k (PairStage (B := B))]
270     (hInner) (hOuter) (e : B ≃ₗ[k] S) (b : B) :
271     pairNormalFormLinearEquiv hInner hOuter e (pairCoefficient b) =
272       Polynomial.C (Polynomial.C (e b)) := by
273   simp [pairNormalFormLinearEquiv, pairCoefficient]
274 
275 @[simp] theorem pairNormalFormLinearEquiv_coordinate
276     {k B S : Type*} [CommRing k] [Ring B] [Algebra k B]
277     [CommRing S] [Algebra k S]
278     [Algebra k (CoordinateStage (B := B))]
279     [Algebra k (PairStage (B := B))]
280     (hInner) (hOuter) (e : B ≃ₗ[k] S) (h1 : e 1 = 1) :
281     pairNormalFormLinearEquiv hInner hOuter e pairCoordinate =
282       Polynomial.C Polynomial.X := by
283   simp [pairNormalFormLinearEquiv, pairCoordinate,
284     polynomialMapRangeLinearEquiv_X _ h1]
285 
286 @[simp] theorem pairNormalFormLinearEquiv_momentum
287     {k B S : Type*} [CommRing k] [Ring B] [Algebra k B]
288     [CommRing S] [Algebra k S]
289     [Algebra k (CoordinateStage (B := B))]
290     [Algebra k (PairStage (B := B))]
291     (hInner) (hOuter) (e : B ≃ₗ[k] S) (h1 : e 1 = 1) :
292     pairNormalFormLinearEquiv hInner hOuter e pairMomentum =
293       Polynomial.X := by
294   have hInnerOne :
295       ((normalFormLinearEquiv zeroDerivation hInner).symm.trans
296         (polynomialMapRangeLinearEquiv e)) 1 = 1 := by
297     simp [h1, polynomialMapRangeLinearEquiv_one]
298   simp [pairNormalFormLinearEquiv, pairMomentum,
299     polynomialMapRangeLinearEquiv_X _ hInnerOne]
300 
301 /-- The two-stage normal-form map sends a coefficient followed by powers of
302 the new coordinate and momentum to the corresponding nested monomial. -/
303 @[simp] theorem pairNormalFormLinearEquiv_orderedMonomial
304     {k B S : Type*} [CommRing k] [Ring B] [Algebra k B]
305     [CommRing S] [Algebra k S]
306     [Algebra k (CoordinateStage (B := B))]
307     [Algebra k (PairStage (B := B))]
308     (hInner : algebraMap k (CoordinateStage (B := B)) =
309       (normalCoefficient zeroDerivation).comp (algebraMap k B))
310     (hOuter : algebraMap k (PairStage (B := B)) =
311       (normalCoefficient coordinateDerivation).comp
312         (algebraMap k (CoordinateStage (B := B))))
313     (e : B ≃ₗ[k] S) (b : B) (a p : ℕ) :
314     pairNormalFormLinearEquiv hInner hOuter e
315         (pairCoefficient b * pairCoordinate ^ a * pairMomentum ^ p) =
316       Polynomial.monomial p (Polynomial.monomial a (e b)) := by
317   have hnormal :
318       pairCoefficient b * pairCoordinate ^ a * pairMomentum ^ p =
319         normalForm coordinateDerivation
320           (Polynomial.monomial p
321             (normalForm zeroDerivation (Polynomial.monomial a b))) := by
322     rw [normalForm_monomial, normalForm_monomial]
323     change
324       normalCoefficient coordinateDerivation (normalCoefficient zeroDerivation b) *
325           (normalCoefficient coordinateDerivation (normalVariable zeroDerivation)) ^ a *
326         normalVariable coordinateDerivation ^ p = _
327     rw [map_mul, map_pow]
328   rw [hnormal]
329   simp [pairNormalFormLinearEquiv]
330 
331 end Pair
332 
333 #print axioms normalForm_smul
334 #print axioms normalFormLinearEquiv
335 #print axioms nestedPolynomialAlgEquiv
336 #print axioms nestedPolynomialLinearEquiv_monomial
337 #print axioms pairNormalFormLinearEquiv
338 #print axioms pairNormalFormLinearEquiv_coefficient
339 #print axioms pairNormalFormLinearEquiv_coordinate
340 #print axioms pairNormalFormLinearEquiv_momentum
341 #print axioms pairNormalFormLinearEquiv_orderedMonomial
342 
343 end
344 
345 end Stafford38.OreLinearNormalForm
346