Stafford38/Weyl/PBW.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Mathlib.RingTheory.MvPolynomial.Basic
3 public import AlgebraicAnalysis.Ore.Associativity
4 public import Stafford38.Weyl.IteratedEquivalence
5 public import Stafford38.Ore.LinearNormalForm
6 public import Stafford38.Characteristic.Polynomial
7 public import Mathlib.LinearAlgebra.Basis.Basic
8 
9 @[expose] public section
10 
11 /-!
12 # Ordered PBW basis from Ore normal forms
13 
14 The checked iterated Ore normal form gives a scalar-linear equivalence with
15 the commutative polynomial symbol space.  Transport across the independently
16 proved presented/iterated algebra equivalence yields a free-module basis
17 indexed by commutative monomials, without using monomial independence in the
18 quotient presentation.  Recursive all-degree formulas identify those basis
19 vectors with ordered products of the named Weyl generators.
20 -/
21 
22 namespace Stafford38.WeylPBW
23 
24 open Stafford
25 open AlgebraicAnalysis
26 open AlgebraicAnalysis.OreDivision
27 open Stafford38.Characteristic
28 open AlgebraicAnalysis.OreAssociativity
29 open Stafford38.OreCoordinateStage
30 open Stafford38.OreIteratedPairStage
31 open Stafford38.OreLinearNormalForm
32 open Stafford38.OrePairStage
33 open Stafford38.OreScalarAlgebra
34 open Stafford38.WeylIteratedEquivalence
35 
36 noncomputable section
37 
38 universe u
39 
40 variable (k : Type u) [Field k]
41 
42 /-- Reindex the two newest symbol variables followed by the old variables to
43 the standard newest-first coordinate/momentum indexing. -/
44 def phaseSuccEquiv (n : Nat) :
45     ((PUnit.{1} ⊕ PUnit.{1}) ⊕ PhaseVar n) ≃ PhaseVar (n + 1) where
46   toFun
47     | .inl (.inl _) => .inr 0
48     | .inl (.inr _) => .inl 0
49     | .inr (.inl i) => .inl i.succ
50     | .inr (.inr i) => .inr i.succ
51   invFun
52     | .inl i => Fin.cases (.inl (.inr PUnit.unit))
53         (fun j => .inr (.inl j)) i
54     | .inr i => Fin.cases (.inl (.inl PUnit.unit))
55         (fun j => .inr (.inr j)) i
56   left_inv x := by
57     rcases x with (⟨⟨u⟩ | ⟨u⟩⟩ | ⟨i | i⟩) <;> rfl
58   right_inv x := by
59     rcases x with (i | i)
60     · exact Fin.cases rfl (fun _ => rfl) i
61     · exact Fin.cases rfl (fun _ => rfl) i
62 
63 @[simp] theorem phaseSuccEquiv_old (n : Nat) (i : PhaseVar n) :
64     phaseSuccEquiv n (.inr i) = oldIndex i := by
65   cases i <;> rfl
66 
67 /-- Flatten the two new univariate normal-form layers and the old symbol
68 coefficients into the standard rank-successor symbol ring. -/
69 def flattenPairSymbols (n : Nat) :
70     Polynomial (Polynomial (SymbolRing k n)) ≃ₗ[k] SymbolRing k (n + 1) :=
71   (nestedPolynomialLinearEquiv.{u, u}
72       (k := k) (R := SymbolRing k n)).trans
73     ((((MvPolynomial.sumAlgEquiv k (PUnit.{1} ⊕ PUnit.{1}) (PhaseVar n)).symm
74       ).toLinearEquiv).trans
75         (MvPolynomial.renameEquiv k (phaseSuccEquiv n)).toLinearEquiv)
76 
77 @[simp] theorem flattenPairSymbols_coordinate (n : Nat) :
78     flattenPairSymbols k n (Polynomial.C Polynomial.X) =
79       MvPolynomial.X (.inl (0 : Fin (n + 1))) := by
80   simp [flattenPairSymbols, nestedPolynomialLinearEquiv_coordinate,
81     MvPolynomial.sumAlgEquiv_symm_X]
82   rfl
83 
84 @[simp] theorem flattenPairSymbols_momentum (n : Nat) :
85     flattenPairSymbols k n Polynomial.X =
86       MvPolynomial.X (.inr (0 : Fin (n + 1))) := by
87   simp [flattenPairSymbols, nestedPolynomialLinearEquiv_momentum,
88     MvPolynomial.sumAlgEquiv_symm_X]
89   rfl
90 
91 @[simp] theorem flattenPairSymbols_one (n : Nat) :
92     flattenPairSymbols k n 1 = 1 := by
93   change flattenPairSymbols k n (Polynomial.C (Polynomial.C 1)) = 1
94   rw [flattenPairSymbols, LinearEquiv.trans_apply,
95     nestedPolynomialLinearEquiv_constant]
96   simp
97 
98 @[simp] theorem flattenPairSymbols_oldGenerator (n : Nat) (i : PhaseVar n) :
99     flattenPairSymbols k n
100         (Polynomial.C (Polynomial.C (MvPolynomial.X i))) =
101       MvPolynomial.X (oldIndex i) := by
102   simp [flattenPairSymbols, nestedPolynomialLinearEquiv_constant,
103     MvPolynomial.sumAlgEquiv_symm_C_X]
104 
105 theorem iterToSum_C_eq_rename {R S₁ S₂ : Type*} [CommSemiring R]
106     (r : MvPolynomial S₂ R) :
107     MvPolynomial.iterToSum R S₁ S₂ (MvPolynomial.C r) =
108       MvPolynomial.rename Sum.inr r := by
109   induction r using MvPolynomial.induction_on with
110   | C c =>
111       simpa only [MvPolynomial.rename_C] using
112         (MvPolynomial.iterToSum_C_C R S₁ S₂ c)
113   | add p q hp hq => simp [hp, hq]
114   | mul_X p i hp =>
115       simp only [map_mul, hp, MvPolynomial.iterToSum_C_X,
116         MvPolynomial.rename_X]
117 
118 private theorem sumAlgEquiv_symm_C_eq_rename
119     {R S₁ S₂ : Type*} [CommSemiring R] (r : MvPolynomial S₂ R) :
120     (MvPolynomial.sumAlgEquiv R S₁ S₂).symm (MvPolynomial.C r) =
121       MvPolynomial.rename Sum.inr r := by
122   induction r using MvPolynomial.induction_on with
123   | C c => simp
124   | add p q hp hq => simp [hp, hq]
125   | mul_X p i hp =>
126       simp only [map_mul, hp, MvPolynomial.sumAlgEquiv_symm_C_X,
127         MvPolynomial.rename_X]
128 
129 /-- Flattening a nested monomial preserves its two new exponents and embeds
130 the old symbol polynomial through `oldIndex`. -/
131 theorem flattenPairSymbols_monomial (n a p : ℕ) (r : SymbolRing k n) :
132     flattenPairSymbols k n
133         (Polynomial.monomial p (Polynomial.monomial a r)) =
134       MvPolynomial.X (.inr (0 : Fin (n + 1))) ^ p *
135         MvPolynomial.X (.inl (0 : Fin (n + 1))) ^ a *
136         MvPolynomial.rename oldIndex r := by
137   rw [flattenPairSymbols, LinearEquiv.trans_apply,
138     nestedPolynomialLinearEquiv_monomial]
139   simp only [LinearEquiv.trans_apply, AlgEquiv.toLinearEquiv_apply,
140     map_mul, map_pow, MvPolynomial.sumAlgEquiv_symm_X,
141     sumAlgEquiv_symm_C_eq_rename,
142     MvPolynomial.renameEquiv_apply, MvPolynomial.rename_X]
143   rw [MvPolynomial.rename_rename]
144   have hindex : (⇑(phaseSuccEquiv n) ∘ Sum.inr) = oldIndex := by
145     funext i
146     exact phaseSuccEquiv_old n i
147   rw [hindex]
148   rfl
149 
150 /-- The finite exponent vector with coordinate exponents `a` and momentum
151 exponents `p`. -/
152 def phaseExponent {n : ℕ} (a p : Fin n → ℕ) : PhaseVar n →₀ ℕ :=
153   Finsupp.equivFunOnFinite.symm (Sum.elim a p)
154 
155 @[simp] theorem phaseExponent_apply {n : ℕ} (a p : Fin n → ℕ)
156     (i : PhaseVar n) : phaseExponent a p i = Sum.elim a p i := rfl
157 
158 theorem oldIndex_injective {n : ℕ} :
159     Function.Injective (@oldIndex n) := by
160   intro i j h
161   cases i with
162   | inl i =>
163       cases j with
164       | inl j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at h; subst j; rfl
165       | inr j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at h
166   | inr i =>
167       cases j with
168       | inl j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at h
169       | inr j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at h; subst j; rfl
170 
171 theorem phaseExponent_succ (n : ℕ) (a p : Fin (n + 1) → ℕ) :
172     phaseExponent a p =
173       Finsupp.single (.inr (0 : Fin (n + 1))) (p 0) +
174         Finsupp.single (.inl (0 : Fin (n + 1))) (a 0) +
175         Finsupp.mapDomain oldIndex
176           (phaseExponent (fun i => a i.succ) (fun i => p i.succ)) := by
177   ext i
178   cases i with
179   | inl i =>
180       refine Fin.cases ?_ (fun j => ?_) i
181       · rw [Finsupp.add_apply, Finsupp.add_apply,
182           Finsupp.mapDomain_notin_range]
183         · simp [phaseExponent]
184         · rintro ⟨j, hj⟩
185           cases j with
186           | inl j => exact Fin.succ_ne_zero j (Sum.inl.inj hj)
187           | inr j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at hj
188       · change a j.succ = _ + _ +
189           Finsupp.mapDomain oldIndex
190             (phaseExponent (fun i => a i.succ) (fun i => p i.succ))
191               (oldIndex (.inl j))
192         rw [Finsupp.mapDomain_apply_of_injective oldIndex_injective]
193         simp [phaseExponent, oldIndex, Stafford38FixedSourceChallenge.oldIndex, Finsupp.single_apply,
194           Fin.succ_ne_zero]
195   | inr i =>
196       refine Fin.cases ?_ (fun j => ?_) i
197       · rw [Finsupp.add_apply, Finsupp.add_apply,
198           Finsupp.mapDomain_notin_range]
199         · simp [phaseExponent]
200         · rintro ⟨j, hj⟩
201           cases j with
202           | inl j => simp [oldIndex, Stafford38FixedSourceChallenge.oldIndex] at hj
203           | inr j => exact Fin.succ_ne_zero j (Sum.inr.inj hj)
204       · change p j.succ = _ + _ +
205           Finsupp.mapDomain oldIndex
206             (phaseExponent (fun i => a i.succ) (fun i => p i.succ))
207               (oldIndex (.inr j))
208         rw [Finsupp.mapDomain_apply_of_injective oldIndex_injective]
209         simp [phaseExponent, oldIndex, Stafford38FixedSourceChallenge.oldIndex, Finsupp.single_apply,
210           Fin.succ_ne_zero]
211 
212 /-- Ordered monomials in the iterated tower: all older pairs occur first, and
213 within each pair the coordinate power precedes the momentum power. -/
214 def iteratedOrderedMonomial :
215     (n : ℕ) → (Fin n → ℕ) → (Fin n → ℕ) → IteratedPairStage k n
216   | 0, _, _ => 1
217   | n + 1, a, p =>
218       stageEmbedding k n
219           (iteratedOrderedMonomial n (fun i => a i.succ) (fun i => p i.succ)) *
220         stageCoordinate k n ^ a 0 * stageMomentum k n ^ p 0
221 
222 theorem symbolMonomial_succ (n : ℕ) (a p : Fin (n + 1) → ℕ) :
223     MvPolynomial.X (.inr (0 : Fin (n + 1))) ^ p 0 *
224         MvPolynomial.X (.inl (0 : Fin (n + 1))) ^ a 0 *
225         MvPolynomial.rename oldIndex
226           (MvPolynomial.monomial
227             (phaseExponent (fun i => a i.succ) (fun i => p i.succ)) 1) =
228       MvPolynomial.monomial (phaseExponent a p) (1 : k) := by
229   rw [MvPolynomial.X_pow_eq_monomial, MvPolynomial.X_pow_eq_monomial,
230     MvPolynomial.rename_monomial, MvPolynomial.monomial_mul,
231     MvPolynomial.monomial_mul, mul_one, mul_one, phaseExponent_succ]
232 
233 /-- Scalar-linear normal-form coordinates for the recursively iterated Ore
234 tower. -/
235 def iteratedNormalFormLinearEquiv :
236     (n : Nat) → IteratedPairStage k n ≃ₗ[k] SymbolRing k n
237   | 0 => (MvPolynomial.isEmptyAlgEquiv k (PhaseVar 0)).symm.toLinearEquiv
238   | n + 1 => by
239       letI : Algebra k (IteratedPairStage k n) :=
240         iteratedPairStageAlgebra k n
241       letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
242         coordinateStageAlgebra
243       letI : Algebra k (PairStage (B := IteratedPairStage k n)) :=
244         pairStageAlgebra
245       change PairStage (B := IteratedPairStage k n) ≃ₗ[k] SymbolRing k (n + 1)
246       exact (pairNormalFormLinearEquiv
247         (normalOreAlgebra_algebraMap zeroDerivation (fun c => by
248           exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c)))
249         (normalOreAlgebra_algebraMap coordinateDerivation
250           coordinateDerivation_algebraMap)
251         (iteratedNormalFormLinearEquiv n)).trans (flattenPairSymbols k n)
252 
253 @[simp] theorem iteratedNormalFormLinearEquiv_one :
254     ∀ n : Nat, iteratedNormalFormLinearEquiv k n 1 = 1 := by
255   intro n
256   induction n with
257   | zero =>
258       rfl
259   | succ n ih =>
260       letI : Algebra k (IteratedPairStage k n) :=
261         iteratedPairStageAlgebra k n
262       letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
263         coordinateStageAlgebra
264       letI : Algebra k (PairStage (B := IteratedPairStage k n)) :=
265         pairStageAlgebra
266       let hInner : algebraMap k (CoordinateStage (B := IteratedPairStage k n)) =
267           (normalCoefficient zeroDerivation).comp
268             (algebraMap k (IteratedPairStage k n)) :=
269         normalOreAlgebra_algebraMap zeroDerivation (fun c : k => by
270           exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
271       let hOuter : algebraMap k (PairStage (B := IteratedPairStage k n)) =
272           (normalCoefficient coordinateDerivation).comp
273             (algebraMap k (CoordinateStage (B := IteratedPairStage k n))) :=
274         normalOreAlgebra_algebraMap coordinateDerivation
275           (fun c : k => coordinateDerivation_algebraMap
276             (B := IteratedPairStage k n) c)
277       rw [iteratedNormalFormLinearEquiv]
278       change flattenPairSymbols k n
279         (pairNormalFormLinearEquiv hInner hOuter
280           (iteratedNormalFormLinearEquiv k n) 1) = 1
281       have hone : (1 : PairStage (B := IteratedPairStage k n)) =
282           pairCoefficient (B := IteratedPairStage k n)
283             (1 : IteratedPairStage k n) := by
284         exact (pairCoefficient (B := IteratedPairStage k n)).map_one.symm
285       rw [hone, pairNormalFormLinearEquiv_coefficient, ih]
286       exact flattenPairSymbols_one k n
287 
288 /-- The recursive normal-form coordinate map sends each named Weyl generator
289 to its corresponding commutative symbol variable. -/
290 @[simp] theorem iteratedNormalFormLinearEquiv_generator :
291     ∀ (n : Nat) (i : PhaseVar n),
292       iteratedNormalFormLinearEquiv k n (iteratedGenerator k n i) =
293         MvPolynomial.X i := by
294   intro n
295   induction n with
296   | zero =>
297       intro i
298       exact Sum.elim Fin.elim0 Fin.elim0 i
299   | succ n ih =>
300       letI : Algebra k (IteratedPairStage k n) :=
301         iteratedPairStageAlgebra k n
302       letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
303         coordinateStageAlgebra
304       letI : Algebra k (PairStage (B := IteratedPairStage k n)) :=
305         pairStageAlgebra
306       let hInner : algebraMap k (CoordinateStage (B := IteratedPairStage k n)) =
307           (normalCoefficient zeroDerivation).comp
308             (algebraMap k (IteratedPairStage k n)) :=
309         normalOreAlgebra_algebraMap zeroDerivation (fun c : k => by
310           exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
311       let hOuter : algebraMap k (PairStage (B := IteratedPairStage k n)) =
312           (normalCoefficient coordinateDerivation).comp
313             (algebraMap k (CoordinateStage (B := IteratedPairStage k n))) :=
314         normalOreAlgebra_algebraMap coordinateDerivation
315           (fun c : k => coordinateDerivation_algebraMap
316             (B := IteratedPairStage k n) c)
317       intro i
318       cases i with
319       | inl i =>
320           refine Fin.cases ?_ (fun j => ?_) i
321           · change iteratedNormalFormLinearEquiv k (n + 1) (stageCoordinate k n) = _
322             rw [iteratedNormalFormLinearEquiv]
323             change flattenPairSymbols k n
324               (pairNormalFormLinearEquiv hInner hOuter
325                 (iteratedNormalFormLinearEquiv k n) pairCoordinate) = _
326             rw [pairNormalFormLinearEquiv_coordinate _ _ _
327               (iteratedNormalFormLinearEquiv_one k n)]
328             exact flattenPairSymbols_coordinate k n
329           · change iteratedNormalFormLinearEquiv k (n + 1)
330               (stageEmbedding k n (iteratedCoordinate k n j)) = _
331             rw [iteratedNormalFormLinearEquiv]
332             change flattenPairSymbols k n
333               (pairNormalFormLinearEquiv hInner hOuter
334                 (iteratedNormalFormLinearEquiv k n)
335                 (pairCoefficient (iteratedCoordinate k n j))) = _
336             have hij := ih (.inl j)
337             change iteratedNormalFormLinearEquiv k n (iteratedCoordinate k n j) =
338               MvPolynomial.X (.inl j) at hij
339             rw [pairNormalFormLinearEquiv_coefficient, hij,
340               flattenPairSymbols_oldGenerator]
341             rfl
342 
343       | inr i =>
344           refine Fin.cases ?_ (fun j => ?_) i
345           · change iteratedNormalFormLinearEquiv k (n + 1) (stageMomentum k n) = _
346             rw [iteratedNormalFormLinearEquiv]
347             change flattenPairSymbols k n
348               (pairNormalFormLinearEquiv hInner hOuter
349                 (iteratedNormalFormLinearEquiv k n) pairMomentum) = _
350             rw [pairNormalFormLinearEquiv_momentum _ _ _
351               (iteratedNormalFormLinearEquiv_one k n)]
352             exact flattenPairSymbols_momentum k n
353           · change iteratedNormalFormLinearEquiv k (n + 1)
354               (stageEmbedding k n (iteratedMomentum k n j)) = _
355             rw [iteratedNormalFormLinearEquiv]
356             change flattenPairSymbols k n
357               (pairNormalFormLinearEquiv hInner hOuter
358                 (iteratedNormalFormLinearEquiv k n)
359                 (pairCoefficient (iteratedMomentum k n j))) = _
360             have hij := ih (.inr j)
361             change iteratedNormalFormLinearEquiv k n (iteratedMomentum k n j) =
362               MvPolynomial.X (.inr j) at hij
363             rw [pairNormalFormLinearEquiv_coefficient, hij,
364               flattenPairSymbols_oldGenerator]
365             rfl
366 
367 /-- Every recursively ordered product of the named iterated generators has
368 exactly the corresponding commutative symbol monomial as its normal form. -/
369 theorem iteratedOrderedMonomial_normal :
370     ∀ (n : ℕ) (a p : Fin n → ℕ),
371       iteratedNormalFormLinearEquiv k n (iteratedOrderedMonomial k n a p) =
372         MvPolynomial.monomial (phaseExponent a p) 1 := by
373   intro n
374   induction n with
375   | zero =>
376       intro a p
377       change 1 = MvPolynomial.monomial (phaseExponent a p) 1
378       have hz : phaseExponent a p = 0 := by
379         ext i
380         exact Sum.elim Fin.elim0 Fin.elim0 i
381       rw [hz]
382       simp [MvPolynomial.monomial_zero']
383   | succ n ih =>
384       letI : Algebra k (IteratedPairStage k n) :=
385         iteratedPairStageAlgebra k n
386       letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
387         coordinateStageAlgebra
388       letI : Algebra k (PairStage (B := IteratedPairStage k n)) :=
389         pairStageAlgebra
390       let hInner : algebraMap k (CoordinateStage (B := IteratedPairStage k n)) =
391           (normalCoefficient zeroDerivation).comp
392             (algebraMap k (IteratedPairStage k n)) :=
393         normalOreAlgebra_algebraMap zeroDerivation (fun c : k => by
394           exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
395       let hOuter : algebraMap k (PairStage (B := IteratedPairStage k n)) =
396           (normalCoefficient coordinateDerivation).comp
397             (algebraMap k (CoordinateStage (B := IteratedPairStage k n))) :=
398         normalOreAlgebra_algebraMap coordinateDerivation
399           (fun c : k => coordinateDerivation_algebraMap
400             (B := IteratedPairStage k n) c)
401       intro a p
402       rw [iteratedOrderedMonomial, iteratedNormalFormLinearEquiv]
403       change flattenPairSymbols k n
404         (pairNormalFormLinearEquiv hInner hOuter
405           (iteratedNormalFormLinearEquiv k n)
406           (pairCoefficient (B := IteratedPairStage k n)
407               (iteratedOrderedMonomial k n
408                 (fun i => a i.succ) (fun i => p i.succ)) *
409             pairCoordinate (B := IteratedPairStage k n) ^ a 0 *
410             pairMomentum (B := IteratedPairStage k n) ^ p 0)) = _
411       rw [pairNormalFormLinearEquiv_orderedMonomial,
412         ih (fun i => a i.succ) (fun i => p i.succ),
413         flattenPairSymbols_monomial, symbolMonomial_succ]
414 
415 /-- Append powers of the newest coordinate and momentum to an arbitrary old
416 coefficient in normal order. -/
417 def iteratedCoefficientOrdered (n a p : ℕ) (z : IteratedPairStage k n) :
418     IteratedPairStage k (n + 1) :=
419   stageEmbedding k n z * stageCoordinate k n ^ a * stageMomentum k n ^ p
420 
421 /-- Appending a normal-ordered newest pair shifts the old symbol polynomial by
422 the corresponding two monomial powers. -/
423 theorem iteratedNormalFormLinearEquiv_coefficient_ordered
424     (n a p : ℕ) (z : IteratedPairStage k n) :
425     iteratedNormalFormLinearEquiv k (n + 1)
426         (iteratedCoefficientOrdered k n a p z) =
427       MvPolynomial.X (.inr (0 : Fin (n + 1))) ^ p *
428         MvPolynomial.X (.inl (0 : Fin (n + 1))) ^ a *
429         MvPolynomial.rename oldIndex (iteratedNormalFormLinearEquiv k n z) := by
430   letI : Algebra k (IteratedPairStage k n) := iteratedPairStageAlgebra k n
431   letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
432     coordinateStageAlgebra
433   letI : Algebra k (PairStage (B := IteratedPairStage k n)) := pairStageAlgebra
434   let hInner : algebraMap k (CoordinateStage (B := IteratedPairStage k n)) =
435       (normalCoefficient zeroDerivation).comp
436         (algebraMap k (IteratedPairStage k n)) :=
437     normalOreAlgebra_algebraMap zeroDerivation (fun c : k => by
438       exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
439   let hOuter : algebraMap k (PairStage (B := IteratedPairStage k n)) =
440       (normalCoefficient coordinateDerivation).comp
441         (algebraMap k (CoordinateStage (B := IteratedPairStage k n))) :=
442     normalOreAlgebra_algebraMap coordinateDerivation
443       (fun c : k => coordinateDerivation_algebraMap
444         (B := IteratedPairStage k n) c)
445   rw [iteratedCoefficientOrdered, iteratedNormalFormLinearEquiv]
446   change flattenPairSymbols k n
447       (pairNormalFormLinearEquiv (B := IteratedPairStage k n)
448         hInner hOuter (iteratedNormalFormLinearEquiv k n)
449         (stageEmbedding k n z * stageCoordinate k n ^ a *
450           stageMomentum k n ^ p)) = _
451   unfold stageEmbedding stageCoordinate stageMomentum
452   have hpair := pairNormalFormLinearEquiv_orderedMonomial hInner hOuter
453     (iteratedNormalFormLinearEquiv k n) z a p
454   have hflat := congrArg (flattenPairSymbols k n) hpair
455   rw [flattenPairSymbols_monomial] at hflat
456   exact hflat
457 
458 /-- Normal-form coordinates for the quotient presentation, obtained by
459 transport through the presented/iterated algebra equivalence. -/
460 def presentedNormalFormLinearEquiv (n : Nat) :
461     PresentedWeyl k n ≃ₗ[k] SymbolRing k n :=
462   (presentedIteratedEquiv k n).toLinearEquiv.trans
463     (iteratedNormalFormLinearEquiv k n)
464 
465 @[simp] theorem presentedNormalFormLinearEquiv_one (n : Nat) :
466     presentedNormalFormLinearEquiv k n 1 = 1 := by
467   rw [presentedNormalFormLinearEquiv, LinearEquiv.trans_apply,
468     AlgEquiv.toLinearEquiv_apply, map_one, iteratedNormalFormLinearEquiv_one]
469 
470 /-- The transported normal-form coordinates agree with the named generators
471 of the quotient presentation. -/
472 @[simp] theorem presentedNormalFormLinearEquiv_generator (n : Nat)
473     (i : PhaseVar n) :
474     presentedNormalFormLinearEquiv k n
475         (freeWeylGenerator (Matrix.J (Fin n) k) i) =
476       MvPolynomial.X i := by
477   rw [presentedNormalFormLinearEquiv, LinearEquiv.trans_apply,
478     AlgEquiv.toLinearEquiv_apply, presentedIteratedEquiv_generator,
479     iteratedNormalFormLinearEquiv_generator]
480 
481 /-- Append powers of the newest named coordinate and momentum to an arbitrary
482 old presentation element in normal order. -/
483 def presentedCoefficientOrdered (n a p : ℕ) (z : PresentedWeyl k n) :
484     PresentedWeyl k (n + 1) :=
485   previousWeylEmbedding k n z * presentedCoordinate k n ^ a *
486     presentedMomentum k n ^ p
487 
488 /-- Normal-form coordinates of an arbitrary old presentation element followed
489 by powers of the newest named coordinate and momentum. -/
490 theorem presentedNormalFormLinearEquiv_previous_ordered
491     (n a p : ℕ) (z : PresentedWeyl k n) :
492     presentedNormalFormLinearEquiv k (n + 1)
493         (presentedCoefficientOrdered k n a p z) =
494       MvPolynomial.X (.inr (0 : Fin (n + 1))) ^ p *
495         MvPolynomial.X (.inl (0 : Fin (n + 1))) ^ a *
496         MvPolynomial.rename oldIndex
497           (presentedNormalFormLinearEquiv k n z) := by
498   letI : Algebra k (IteratedPairStage k n) := iteratedPairStageAlgebra k n
499   letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
500     coordinateStageAlgebra
501   letI : Algebra k (PairStage (B := IteratedPairStage k n)) := pairStageAlgebra
502   rw [presentedCoefficientOrdered]
503   rw [presentedNormalFormLinearEquiv, LinearEquiv.trans_apply,
504     AlgEquiv.toLinearEquiv_apply]
505   have hmap : presentedIteratedEquiv k (n + 1)
506         (previousWeylEmbedding k n z *
507           presentedCoordinate k n ^ a * presentedMomentum k n ^ p) =
508       presentedIteratedEquiv k (n + 1) (previousWeylEmbedding k n z) *
509         presentedIteratedEquiv k (n + 1) (presentedCoordinate k n) ^ a *
510         presentedIteratedEquiv k (n + 1) (presentedMomentum k n) ^ p := by
511     simp only [map_mul, map_pow]
512   rw [hmap]
513   change iteratedNormalFormLinearEquiv k (n + 1)
514       (presentedToIterated k (n + 1) (previousWeylEmbedding k n z) *
515         presentedToIterated k (n + 1) (presentedCoordinate k n) ^ a *
516         presentedToIterated k (n + 1) (presentedMomentum k n) ^ p) = _
517   have hprevious := DFunLike.congr_fun (presentedToIterated_previous k n) z
518   rw [AlgHom.comp_apply, AlgHom.comp_apply] at hprevious
519   rw [hprevious, presentedToIterated_coordinate,
520     presentedToIterated_momentum]
521   change iteratedNormalFormLinearEquiv k (n + 1)
522     (iteratedCoefficientOrdered k n a p (presentedToIterated k n z)) = _
523   rw [iteratedNormalFormLinearEquiv_coefficient_ordered]
524   rfl
525 
526 /-- Exact normal-ordering formula for two newest-pair blocks.  Every correction
527 term lowers both the coordinate and momentum exponents by the same amount. -/
528 theorem presentedCoefficientOrdered_mul
529     (n a b c d : ℕ) (z₁ z₂ : PresentedWeyl k n) :
530     presentedCoefficientOrdered k n a b z₁ *
531         presentedCoefficientOrdered k n c d z₂ =
532       ∑ i ∈ Finset.range (b + 1),
533         if i ≤ c then
534           (b.choose i * c.descFactorial i) •
535             presentedCoefficientOrdered k n (a + c - i) (b + d - i) (z₁ * z₂)
536         else 0 := by
537   let X := presentedCoordinate k n
538   let P := presentedMomentum k n
539   let Z₁ := previousWeylEmbedding k n z₁
540   let Z₂ := previousWeylEmbedding k n z₂
541   have hX : Commute X Z₂ := presentedCoordinate_commutes_previous k n z₂
542   have hP : Commute P Z₂ := presentedMomentum_commutes_previous k n z₂
543   have hblock : Commute (X ^ a * P ^ b) Z₂ :=
544     (hX.pow_left a).mul_left (hP.pow_left b)
545   have hPX : P * X - X * P = 1 := by
546     rw [show P * X = X * P + 1 from presentedMomentum_mul_coordinate k n]
547     noncomm_ring
548   rw [presentedCoefficientOrdered, presentedCoefficientOrdered]
549   change (Z₁ * X ^ a * P ^ b) * (Z₂ * X ^ c * P ^ d) = _
550   calc
551     (Z₁ * X ^ a * P ^ b) * (Z₂ * X ^ c * P ^ d) =
552         Z₁ * ((X ^ a * P ^ b) * Z₂) * (X ^ c * P ^ d) := by
553       noncomm_ring
554     _ = (Z₁ * Z₂ * X ^ a) * (P ^ b * X ^ c) * P ^ d := by
555       rw [hblock.eq]
556       noncomm_ring
557     _ = (Z₁ * Z₂ * X ^ a) *
558           (∑ i ∈ Finset.range (b + 1),
559             if i ≤ c then
560               (b.choose i * c.descFactorial i) •
561                 (X ^ (c - i) * P ^ (b - i))
562             else 0) * P ^ d := by
563       rw [OreAmbient.commutator_pow_mul_pow P X hPX b c]
564     _ = _ := by
565       rw [Finset.mul_sum, Finset.sum_mul]
566       apply Finset.sum_congr rfl
567       intro i hi
568       have hib : i ≤ b := by
569         have := Finset.mem_range.mp hi
570         omega
571       by_cases hic : i ≤ c
572       · simp only [if_pos hic, OreAmbient.mul_nsmul_left,
573           OreAmbient.nsmul_mul_right, mul_nsmul]
574         congr 1
575         congr 1
576         change (Z₁ * Z₂ * X ^ a) * (X ^ (c - i) * P ^ (b - i)) * P ^ d =
577           previousWeylEmbedding k n (z₁ * z₂) * X ^ (a + c - i) *
578             P ^ (b + d - i)
579         rw [map_mul]
580         rw [show a + c - i = a + (c - i) by omega,
581           show b + d - i = (b - i) + d by omega,
582           pow_add, pow_add]
583         noncomm_ring
584       · simp [hic]
585 
586 -- Compile-time API contract: the exact contraction range, coefficient, and
587 -- exponent loss are part of the public normal-ordering statement.
588 example (n a b c d : ℕ) (z₁ z₂ : PresentedWeyl k n) :
589     presentedCoefficientOrdered k n a b z₁ *
590         presentedCoefficientOrdered k n c d z₂ =
591       ∑ i ∈ Finset.range (b + 1),
592         if i ≤ c then
593           (b.choose i * c.descFactorial i) •
594             presentedCoefficientOrdered k n (a + c - i) (b + d - i) (z₁ * z₂)
595         else 0 :=
596   presentedCoefficientOrdered_mul k n a b c d z₁ z₂
597 
598 /-- Ordered monomials built recursively from the named generators in the
599 quotient presentation.  Older coordinate/momentum pairs occur first; within
600 each pair the coordinate power precedes the momentum power. -/
601 def presentedOrderedMonomial :
602     (n : ℕ) → (Fin n → ℕ) → (Fin n → ℕ) → PresentedWeyl k n
603   | 0, _, _ => 1
604   | n + 1, a, p =>
605       previousWeylEmbedding k n
606           (presentedOrderedMonomial n
607             (fun i => a i.succ) (fun i => p i.succ)) *
608         presentedCoordinate k n ^ a 0 * presentedMomentum k n ^ p 0
609 
610 /-- The presentation/Ore equivalence preserves the recursively ordered
611 monomials, not merely the degree-one generators. -/
612 theorem presentedIteratedEquiv_orderedMonomial :
613     ∀ (n : ℕ) (a p : Fin n → ℕ),
614       presentedIteratedEquiv k n (presentedOrderedMonomial k n a p) =
615         iteratedOrderedMonomial k n a p := by
616   intro n
617   induction n with
618   | zero =>
619       intro a p
620       simp [presentedOrderedMonomial, iteratedOrderedMonomial]
621   | succ n ih =>
622       intro a p
623       rw [presentedOrderedMonomial, iteratedOrderedMonomial, map_mul, map_mul,
624         map_pow, map_pow, presentedIteratedEquiv]
625       change
626         presentedToIterated k (n + 1)
627               (previousWeylEmbedding k n
628                 (presentedOrderedMonomial k n
629                   (fun i => a i.succ) (fun i => p i.succ))) *
630             presentedToIterated k (n + 1) (presentedCoordinate k n) ^ a 0 *
631           presentedToIterated k (n + 1) (presentedMomentum k n) ^ p 0 = _
632       have hprevious := DFunLike.congr_fun
633         (presentedToIterated_previous k n)
634         (presentedOrderedMonomial k n
635           (fun i => a i.succ) (fun i => p i.succ))
636       rw [AlgHom.comp_apply, AlgHom.comp_apply] at hprevious
637       have hih := ih (fun i => a i.succ) (fun i => p i.succ)
638       change presentedToIterated k n
639           (presentedOrderedMonomial k n
640             (fun i => a i.succ) (fun i => p i.succ)) = _ at hih
641       rw [hprevious, hih, presentedToIterated_coordinate,
642         presentedToIterated_momentum]
643       rfl
644 
645 /-- Every ordered product of named presentation generators has the expected
646 commutative symbol monomial as its checked normal form. -/
647 theorem presentedOrderedMonomial_normal (n : ℕ) (a p : Fin n → ℕ) :
648     presentedNormalFormLinearEquiv k n
649         (presentedOrderedMonomial k n a p) =
650       MvPolynomial.monomial (phaseExponent a p) 1 := by
651   rw [presentedNormalFormLinearEquiv, LinearEquiv.trans_apply,
652     AlgEquiv.toLinearEquiv_apply, presentedIteratedEquiv_orderedMonomial,
653     iteratedOrderedMonomial_normal]
654 
655 /-- A free-module basis on the presented Weyl algebra, pulled back from the
656 standard monomial basis of the symbol polynomial space. -/
657 def presentedNormalFormBasis (n : Nat) :
658     Module.Basis (PhaseVar n →₀ ℕ) k (PresentedWeyl k n) :=
659   (MvPolynomial.basisMonomials (PhaseVar n) k).map
660     (presentedNormalFormLinearEquiv k n).symm
661 
662 @[simp] theorem presentedNormalFormBasis_apply (n : Nat)
663     (m : PhaseVar n →₀ ℕ) :
664     presentedNormalFormBasis k n m =
665       (presentedNormalFormLinearEquiv k n).symm (MvPolynomial.monomial m 1) := by
666   rfl
667 
668 /-- Split a finite phase exponent into its coordinate and momentum parts. -/
669 theorem phaseExponent_split {n : ℕ} (m : PhaseVar n →₀ ℕ) :
670     phaseExponent (fun i => m (.inl i)) (fun i => m (.inr i)) = m := by
671   ext i
672   cases i <;> rfl
673 
674 /-- The transported normal-form basis consists exactly of the recursively
675 ordered products of the named Weyl generators. -/
676 theorem presentedNormalFormBasis_eq_orderedMonomial (n : ℕ)
677     (m : PhaseVar n →₀ ℕ) :
678     presentedNormalFormBasis k n m =
679       presentedOrderedMonomial k n
680         (fun i => m (.inl i)) (fun i => m (.inr i)) := by
681   apply (presentedNormalFormLinearEquiv k n).injective
682   rw [presentedNormalFormBasis_apply, LinearEquiv.apply_symm_apply,
683     presentedOrderedMonomial_normal, phaseExponent_split]
684 
685 /-- The PBW basis of the presented Weyl algebra, indexed by coordinate and
686 momentum exponent vectors. -/
687 def presentedPBWBasis (n : Nat) :
688     Module.Basis (PhaseVar n →₀ ℕ) k (PresentedWeyl k n) :=
689   presentedNormalFormBasis k n
690 
691 @[simp] theorem presentedPBWBasis_apply (n : ℕ)
692     (m : PhaseVar n →₀ ℕ) :
693     presentedPBWBasis k n m =
694       presentedOrderedMonomial k n
695         (fun i => m (.inl i)) (fun i => m (.inr i)) := by
696   exact presentedNormalFormBasis_eq_orderedMonomial k n m
697 
698 #print axioms iteratedNormalFormLinearEquiv
699 #print axioms iteratedNormalFormLinearEquiv_one
700 #print axioms iteratedNormalFormLinearEquiv_generator
701 #print axioms iteratedOrderedMonomial_normal
702 #print axioms iteratedNormalFormLinearEquiv_coefficient_ordered
703 #print axioms presentedNormalFormLinearEquiv
704 #print axioms presentedNormalFormLinearEquiv_one
705 #print axioms presentedNormalFormLinearEquiv_generator
706 #print axioms presentedNormalFormLinearEquiv_previous_ordered
707 #print axioms AlgebraicAnalysis.OreDivision.OreAmbient.commutator_pow_mul_pow
708 #print axioms presentedCoefficientOrdered_mul
709 #print axioms presentedIteratedEquiv_orderedMonomial
710 #print axioms presentedOrderedMonomial_normal
711 #print axioms presentedNormalFormBasis
712 #print axioms presentedNormalFormBasis_apply
713 #print axioms presentedNormalFormBasis_eq_orderedMonomial
714 #print axioms presentedPBWBasis
715 #print axioms presentedPBWBasis_apply
716 
717 end
718 
719 end Stafford38.WeylPBW
720