Stafford38/Weyl/PaperRightMonic.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Stafford38.MathlibCompat.MvPolynomialCoeff
3 public import Stafford38.Weyl.OuterOreMonic
4 public import AlgebraicAnalysis.Ore.RightPBW
5 
6 @[expose] public section
7 
8 set_option maxHeartbeats 1000000
9 
10 /-!
11 # Paper-facing right-coefficient monic normal form
12 
13 This file connects the checked PBW monicity statement to the right-coefficient
14 normal form used in the paper.  In particular, coefficient bounds are proved
15 through the change from coefficient-left Ore form, rather than assumed.
16 -/
17 
18 namespace Stafford38.WeylPaperRightMonic
19 
20 open AlgebraicAnalysis
21 open AlgebraicAnalysis.OreDivision
22 open AlgebraicAnalysis.OreAssociativity
23 open AlgebraicAnalysis.OreRightPBW
24 open AlgebraicAnalysis.OreRightQuotient
25 open Stafford38.Characteristic
26 open Stafford38.OreCoordinateStage
27 open Stafford38.OreIteratedPairStage
28 open Stafford38.OreLinearNormalForm
29 open Stafford38.OrePairStage
30 open Stafford38.OreScalarAlgebra
31 open Stafford38.WeylFiltration
32 open Stafford38.WeylIteratedEquivalence
33 open Stafford38.WeylOuterOreMonic
34 open Stafford38.WeylPBW
35 open Stafford38.WeylPBWMonicBridge
36 
37 universe u
38 variable {k : Type u} [Field k]
39 
40 private theorem polynomialMapRangeLinearEquiv_derivative
41     {R S : Type u} [Ring R] [CommRing S] [Algebra k R] [Algebra k S]
42     (e : R ≃ₗ[k] S) (q : Polynomial R) :
43     polynomialMapRangeLinearEquiv e q.derivative =
44       (polynomialMapRangeLinearEquiv e q).derivative := by
45   apply Polynomial.ext
46   intro a
47   calc
48     _ = e ((q.derivative).coeff a) :=
49       coeff_polynomialMapRangeLinearEquiv k e q.derivative a
50     _ = e (q.coeff (a + 1) * (a + 1)) := by
51       rw [Polynomial.coeff_derivative]
52     _ = e (q.coeff (a + 1)) * (a + 1) := by
53       calc
54             _ = e ((a + 1) • q.coeff (a + 1)) := by
55               rw [← Nat.cast_smul_eq_nsmul R (a + 1) (q.coeff (a + 1)), smul_eq_mul]
56               congr 1
57               simpa only [Nat.cast_succ] using
58                 (Nat.cast_commute (a + 1) (q.coeff (a + 1))).eq.symm
59         _ = (a + 1) • e (q.coeff (a + 1)) := map_nsmul e _ _
60         _ = _ := by
61               rw [← Nat.cast_smul_eq_nsmul S (a + 1) (e (q.coeff (a + 1))), smul_eq_mul]
62               simpa only [Nat.cast_succ] using
63                 (Nat.cast_commute (a + 1) (e (q.coeff (a + 1)))).eq
64     _ = _ := by
65       rw [Polynomial.coeff_derivative,
66         coeff_polynomialMapRangeLinearEquiv k]
67 
68 noncomputable section
69 variable (k : Type u) [Field k]
70 
71 local instance (n : ℕ) : Algebra k (IteratedPairStage k n) :=
72   iteratedPairStageAlgebra k n
73 
74 local instance (n : ℕ) :
75     Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
76   coordinateStageAlgebra
77 
78 local instance (n : ℕ) :
79     Algebra k (PairStage (B := IteratedPairStage k n)) :=
80   pairStageAlgebra
81 
82 local instance (n : ℕ) :
83     Nontrivial (IteratedPairStage k n) := by
84   induction n with
85   | zero =>
86       change Nontrivial k
87       infer_instance
88   | succ n ih =>
89       letI : Nontrivial (IteratedPairStage k n) := ih
90       change Nontrivial (PairStage (B := IteratedPairStage k n))
91       unfold PairStage CoordinateStage
92       infer_instance
93 
94 local instance (n : ℕ) :
95     Nontrivial (CoordinateStage (B := IteratedPairStage k n)) := by
96   unfold CoordinateStage
97   infer_instance
98 
99 /-- The coefficient ring of the newest momentum maps to the iterated pair
100 stage by the checked coefficient inclusion. -/
101 def coordinateStageToIterated (n : ℕ) :
102     CoordinateStage (B := IteratedPairStage k n) →ₐ[k]
103       IteratedPairStage k (n + 1) := by
104   letI : Algebra k (IteratedPairStage k n) := iteratedPairStageAlgebra k n
105   letI : Algebra k (CoordinateStage (B := IteratedPairStage k n)) :=
106     coordinateStageAlgebra
107   letI : Algebra k (PairStage (B := IteratedPairStage k n)) := pairStageAlgebra
108   exact
109     { toRingHom := normalCoefficient coordinateDerivation
110       commutes' := by
111         intro c
112         rfl }
113 
114 theorem coordinateStageToIterated_injective (n : ℕ) :
115     Function.Injective (coordinateStageToIterated k n) := by
116   intro x y h
117   exact normalCoefficient_injective coordinateDerivation h
118 
119 /-- The coefficient ring embeds into the presented Weyl algebra through the
120 checked iterated-Ore/presented equivalence. -/
121 def coordinateStageToPresented (n : ℕ) :
122     CoordinateStage (B := IteratedPairStage k n) →ₐ[k]
123       PresentedWeyl k (n + 1) :=
124   (iteratedToPresented k (n + 1)).comp (coordinateStageToIterated k n)
125 
126 theorem coordinateStageToPresented_normalForm (n : ℕ)
127     (z : CoordinateStage (B := IteratedPairStage k n)) :
128     presentedNormalFormLinearEquiv k (n + 1)
129         (coordinateStageToPresented k n z) =
130       flattenPairSymbols k n
131         (Polynomial.C (coordinateCoefficientNormalForm k n z)) := by
132   have hpair :
133       iteratedNormalFormLinearEquiv k (n + 1)
134           (coordinateStageToIterated k n z) =
135         flattenPairSymbols k n
136           (Polynomial.C (coordinateCoefficientNormalForm k n z)) := by
137     rw [iteratedNormalFormLinearEquiv]
138     let hInner : algebraMap k (CoordinateStage (B := IteratedPairStage k n)) =
139         (normalCoefficient zeroDerivation).comp
140           (algebraMap k (IteratedPairStage k n)) :=
141       normalOreAlgebra_algebraMap zeroDerivation (fun c => by
142         exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
143     let hOuter : algebraMap k (PairStage (B := IteratedPairStage k n)) =
144         (normalCoefficient coordinateDerivation).comp
145           (algebraMap k (CoordinateStage (B := IteratedPairStage k n))) :=
146       normalOreAlgebra_algebraMap coordinateDerivation
147         (coordinateDerivation_algebraMap (B := IteratedPairStage k n))
148     change flattenPairSymbols k n
149         (pairNormalFormLinearEquiv hInner hOuter
150           (iteratedNormalFormLinearEquiv k n)
151           (normalCoefficient (coordinateDerivation
152             (B := IteratedPairStage k n)) z)) = _
153     simp [pairNormalFormLinearEquiv, coordinateCoefficientNormalForm,
154       normalFormLinearEquiv_symm_coefficient]
155     rfl
156   simp only [presentedNormalFormLinearEquiv, LinearEquiv.trans_apply,
157     AlgEquiv.toLinearEquiv_apply, coordinateStageToPresented,
158     presentedIteratedEquiv, AlgHom.comp_apply]
159   change iteratedNormalFormLinearEquiv k (n + 1)
160     (presentedToIterated k (n + 1)
161       (iteratedToPresented k (n + 1) (coordinateStageToIterated k n z))) = _
162   rw [← AlgHom.comp_apply,
163     presentedToIterated_comp_iteratedToPresented k (n + 1)]
164   exact hpair
165 
166 /-- The coefficient ring of the newest momentum inherits the canonical
167 rank-`n+1` Bernstein filtration along its checked Weyl-algebra inclusion. -/
168 def coordinateBernsteinPiece (n L : ℕ) :
169     Submodule k (CoordinateStage (B := IteratedPairStage k n)) :=
170   (Stafford38.WeylFiltration.bernsteinPiece k (n + 1) L).comap
171     (coordinateStageToPresented k n).toLinearMap
172 
173 @[simp] theorem mem_coordinateBernsteinPiece (n L : ℕ)
174     (z : CoordinateStage (B := IteratedPairStage k n)) :
175     z ∈ coordinateBernsteinPiece k n L ↔
176       ∀ a m,
177         MvPolynomial.coeff m
178           ((coordinateCoefficientNormalForm k n z).coeff a) ≠ 0 →
179           a + monomialWeight (@bernsteinWeight n) m ≤ L := by
180   change coordinateStageToPresented k n z ∈
181     Stafford38.WeylFiltration.bernsteinPiece k (n + 1) L ↔ _
182   rw [Stafford38.WeylFiltration.bernsteinPiece, mem_presentedWeightPiece,
183     coordinateStageToPresented_normalForm]
184   constructor
185   · intro h a m hm
186     have hnonzero : MvPolynomial.coeff (pairExponent n a 0 m)
187         (flattenPairSymbols k n
188           (Polynomial.C (coordinateCoefficientNormalForm k n z))) ≠ 0 := by
189       change AddMonoidAlgebra.coeff
190         (flattenPairSymbols k n
191           (Polynomial.C (coordinateCoefficientNormalForm k n z)))
192         (pairExponent n a 0 m) ≠ 0
193       rw [coeff_flattenPairSymbols]
194       simpa [Polynomial.coeff_C] using hm
195     have hbound := h (pairExponent n a 0 m) hnonzero
196     have hweight : monomialWeight (@bernsteinWeight (n + 1))
197         (pairExponent n a 0 m) =
198           monomialWeight (@bernsteinWeight n) m + a := by
199       simpa [pairExponent, extendPhaseExponent, add_comm, add_left_comm,
200         add_assoc] using
201           (monomialWeight_extend_bernstein n a 0 m).symm
202     omega
203   · intro h q hq
204     let aq : Fin (n + 1) → ℕ := fun i => q (.inl i)
205     let pq : Fin (n + 1) → ℕ := fun i => q (.inr i)
206     let old : PhaseVar n →₀ ℕ :=
207       phaseExponent (fun i => aq i.succ) (fun i => pq i.succ)
208     have hqsplit : q = pairExponent n (aq 0) (pq 0) old := by
209       have hphase : phaseExponent aq pq = q := by
210         ext i <;> cases i <;> simp [phaseExponent, aq, pq]
211       rw [← hphase, phaseExponent_succ]
212       rfl
213     have hpzero : pq 0 = 0 := by
214       by_contra hp
215       have hz : MvPolynomial.coeff q
216           (flattenPairSymbols k n
217             (Polynomial.C (coordinateCoefficientNormalForm k n z))) = 0 := by
218         change AddMonoidAlgebra.coeff
219           (flattenPairSymbols k n
220             (Polynomial.C (coordinateCoefficientNormalForm k n z))) q = 0
221         rw [hqsplit, coeff_flattenPairSymbols]
222         simp [Polynomial.coeff_C, hp]
223       exact hq hz
224     have hsource : MvPolynomial.coeff old
225         ((coordinateCoefficientNormalForm k n z).coeff (aq 0)) ≠ 0 := by
226       have := hq
227       change AddMonoidAlgebra.coeff
228         (flattenPairSymbols k n
229           (Polynomial.C (coordinateCoefficientNormalForm k n z))) q ≠ 0 at this
230       rw [hqsplit, coeff_flattenPairSymbols] at this
231       simpa [Polynomial.coeff_C, hpzero] using this
232     have hbound := h (aq 0) old hsource
233     have hweight : monomialWeight (@bernsteinWeight (n + 1)) q =
234         monomialWeight (@bernsteinWeight n) old + aq 0 := by
235       rw [hqsplit]
236       simpa [pairExponent, extendPhaseExponent, hpzero, add_comm,
237         add_left_comm, add_assoc] using
238           (monomialWeight_extend_bernstein n (aq 0) 0 old).symm
239     omega
240 
241 theorem coordinateBernsteinPiece_mono (n L M : ℕ) (hLM : L ≤ M)
242     {z : CoordinateStage (B := IteratedPairStage k n)}
243     (hz : z ∈ coordinateBernsteinPiece k n L) :
244     z ∈ coordinateBernsteinPiece k n M := by
245   rw [mem_coordinateBernsteinPiece] at hz ⊢
246   intro a m hm
247   exact (hz a m hm).trans hLM
248 
249 theorem coordinateCoefficientNormalForm_derivative (n : ℕ)
250     (z : CoordinateStage (B := IteratedPairStage k n)) :
251     coordinateCoefficientNormalForm k n (coordinateDerivation z) =
252       (coordinateCoefficientNormalForm k n z).derivative := by
253   let D : OreDivisionDerivation (IteratedPairStage k n) := zeroDerivation
254   let hAlg : algebraMap k (NormalOre D) =
255       (normalCoefficient D).comp (algebraMap k (IteratedPairStage k n)) :=
256     normalOreAlgebra_algebraMap D (fun c => by
257       exact zeroDerivation_apply (algebraMap k (IteratedPairStage k n) c))
258   change (polynomialMapRangeLinearEquiv
259       (iteratedNormalFormLinearEquiv k n))
260       ((normalFormLinearEquiv D hAlg).symm
261         (normalForm D (Polynomial.derivative
262           ((normalFormAddEquiv D).symm z)))) = _
263   have hsymm : (normalFormLinearEquiv D hAlg).symm z =
264       (normalFormAddEquiv D).symm z := rfl
265   rw [normalFormLinearEquiv_symm_normalForm]
266   rw [← hsymm]
267   change (polynomialMapRangeLinearEquiv
268       (iteratedNormalFormLinearEquiv k n))
269       (Polynomial.derivative ((normalFormLinearEquiv D hAlg).symm z)) =
270     (polynomialMapRangeLinearEquiv
271       (iteratedNormalFormLinearEquiv k n)
272         ((normalFormLinearEquiv D hAlg).symm z)).derivative
273   exact (polynomialMapRangeLinearEquiv_derivative
274     (k := k) (iteratedNormalFormLinearEquiv k n)
275       ((normalFormLinearEquiv D hAlg).symm z))
276 
277 theorem coordinateDerivation_mem_coordinateBernsteinPiece {n L : ℕ}
278     {z : CoordinateStage (B := IteratedPairStage k n)}
279     (hz : z ∈ coordinateBernsteinPiece k n L) :
280     coordinateDerivation z ∈ coordinateBernsteinPiece k n L := by
281   rw [mem_coordinateBernsteinPiece] at hz
282   rw [mem_coordinateBernsteinPiece, coordinateCoefficientNormalForm_derivative]
283   intro a m hm
284   have hsource : MvPolynomial.coeff m
285       ((coordinateCoefficientNormalForm k n z).coeff (a + 1)) ≠ 0 := by
286     intro hzero
287     apply hm
288     rw [Polynomial.coeff_derivative]
289     have hcast : ((coordinateCoefficientNormalForm k n z).coeff (a + 1)) *
290         (↑(a + 1) : SymbolRing k n) = (a + 1 : k) •
291           ((coordinateCoefficientNormalForm k n z).coeff (a + 1)) := by
292       rw [mul_comm, Algebra.smul_def]
293       congr 1
294       simp
295     rw [← Nat.cast_succ, hcast]
296     simp [MvPolynomial.coeff, AddMonoidAlgebra.coeff_smul_apply, hzero]
297   have hbound := hz (a + 1) m hsource
298   simp only [monomialWeight, bernsteinWeight] at hbound ⊢
299   omega
300 
301 theorem coordinateDerivation_iterate_mem_coordinateBernsteinPiece
302     {n L r : ℕ} {z : CoordinateStage (B := IteratedPairStage k n)}
303     (hz : z ∈ coordinateBernsteinPiece k n L) :
304     (coordinateDerivation^[r]) z ∈ coordinateBernsteinPiece k n L := by
305   induction r with
306   | zero => simpa using hz
307   | succ r ih =>
308       rw [Function.iterate_succ_apply']
309       exact coordinateDerivation_mem_coordinateBernsteinPiece (k := k) ih
310 
311 theorem presentedOuterCoefficient_mem_coordinateBernsteinPiece
312     (n N p : ℕ) (d : PresentedWeyl k (n + 1))
313     (hd : d ∈ bernsteinPiece k (n + 1) N) :
314     (presentedOuterPolynomial k n d).coeff p ∈
315       coordinateBernsteinPiece k n (N - p) := by
316   rw [mem_coordinateBernsteinPiece]
317   intro a m hm
318   have hnested : MvPolynomial.coeff m
319       (((presentedNestedNormalForm k n d).coeff p).coeff a) ≠ 0 := by
320     simpa only [presentedNestedNormalForm_coeff] using hm
321   have hfull : MvPolynomial.coeff (pairExponent n a p m)
322       (presentedNormalFormLinearEquiv k (n + 1) d) ≠ 0 := by
323     change AddMonoidAlgebra.coeff
324       (presentedNormalFormLinearEquiv k (n + 1) d)
325       (pairExponent n a p m) ≠ 0
326     rw [← flatten_presentedNestedNormalForm k n d,
327       coeff_flattenPairSymbols]
328     exact hnested
329   have htotal : monomialWeight (@bernsteinWeight (n + 1))
330       (pairExponent n a p m) ≤ N := by
331     exact (mem_presentedWeightPiece k (@bernsteinWeight (n + 1)) N d).mp
332       (by simpa [bernsteinPiece] using hd) _ hfull
333   have hweight : monomialWeight (@bernsteinWeight n) m + a + p ≤ N := by
334     have hEq : monomialWeight (@bernsteinWeight (n + 1))
335           (pairExponent n a p m) =
336         monomialWeight (@bernsteinWeight n) m + a + p := by
337       simpa [pairExponent, extendPhaseExponent, add_comm, add_left_comm,
338         add_assoc] using
339         (monomialWeight_extend_bernstein n a p m).symm
340     rw [hEq] at htotal
341     exact htotal
342   omega
343 
344 def rightBernsteinBound (n N : ℕ)
345     (c : ℕ →₀ (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ) : Prop :=
346   ∀ j, MulOpposite.unop (c j) ∈ coordinateBernsteinPiece k n (N - j)
347 
348 theorem rightBernsteinBound_zero (n N : ℕ) :
349     rightBernsteinBound k n N 0 := by
350   intro j
351   exact (coordinateBernsteinPiece k n (N - j)).zero_mem
352 
353 theorem rightBernsteinBound_add (n N : ℕ)
354     {c d : ℕ →₀ (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ}
355     (hc : rightBernsteinBound k n N c)
356     (hd : rightBernsteinBound k n N d) :
357     rightBernsteinBound k n N (c + d) := by
358   intro j
359   change MulOpposite.unop (c j + d j) ∈ _
360   rw [MulOpposite.unop_add]
361   exact (coordinateBernsteinPiece k n (N - j)).add_mem (hc j) (hd j)
362 
363 theorem rightBernsteinBound_nsmul (n N r : ℕ)
364     {c : ℕ →₀ (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ}
365     (hc : rightBernsteinBound k n N c) :
366     rightBernsteinBound k n N (r • c) := by
367   intro j
368   change MulOpposite.unop (r • c j) ∈ _
369   induction r with
370   | zero => simp
371   | succ r ih =>
372       rw [succ_nsmul, MulOpposite.unop_add]
373       exact (coordinateBernsteinPiece k n (N - j)).add_mem ih (hc j)
374 
375 theorem rightBernsteinBound_neg (n N : ℕ)
376     {c : ℕ →₀ (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ}
377     (hc : rightBernsteinBound k n N c) :
378     rightBernsteinBound k n N (-c) := by
379   intro j
380   change MulOpposite.unop (-c j) ∈ _
381   rw [MulOpposite.unop_neg]
382   exact (coordinateBernsteinPiece k n (N - j)).neg_mem (hc j)
383 
384 theorem rightBernsteinBound_single (n N j : ℕ)
385     {b : (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ}
386     (hb : MulOpposite.unop b ∈ coordinateBernsteinPiece k n (N - j)) :
387     rightBernsteinBound k n N (Finsupp.single j b) := by
388   intro q
389   by_cases hq : q = j
390   · subst q
391     simpa using hb
392   · simp [Finsupp.single_apply, hq]
393 
394 private theorem rightBernsteinBound_sum (n N : ℕ) {α : Type*}
395     (s : Finset α)
396     (f : α → ℕ →₀ (CoordinateStage (B := IteratedPairStage k n))ᵐᵒᵖ)
397     (hf : ∀ a ∈ s, rightBernsteinBound k n N (f a)) :
398     rightBernsteinBound k n N (∑ a ∈ s, f a) := by
399   classical
400   induction s using Finset.induction_on with
401   | empty =>
402       simpa using rightBernsteinBound_zero k n N
403   | @insert a s has ih =>
404       rw [Finset.sum_insert has]
405       apply rightBernsteinBound_add k n N
406       · exact hf a (Finset.mem_insert_self a s)
407       · apply ih
408         intro b hb
409         exact hf b (Finset.mem_insert_of_mem hb)
410 
411 private theorem rightPBWBasis_repr_single
412     {B : Type*} [Ring B] [Nontrivial B]
413     (D : OreDivisionDerivation B) (j : ℕ) (b : B) :
414     (rightOrePBWBasis D).repr
415         (MulOpposite.op b • rightPBWMonomial D j) =
416       Finsupp.single j (MulOpposite.op b) := by
417   rw [← rightOrePBWBasis_repr_symm_single D j (MulOpposite.op b)]
418   exact LinearEquiv.apply_symm_apply _ _
419 
420 private theorem rightPBWBasis_repr_monomial
421     {B : Type*} [Ring B] [Nontrivial B]
422     (D : OreDivisionDerivation B) (l : ℕ) (b : B) :
423     (rightOrePBWBasis D).repr (normalForm D (Polynomial.monomial l b)) =
424       ∑ ij ∈ Finset.HasAntidiagonal.antidiagonal l,
425         l.choose ij.1 •
426           (if Even ij.1 then Finsupp.single ij.2 (MulOpposite.op
427               ((D^[ij.1]) b))
428           else -Finsupp.single ij.2 (MulOpposite.op
429               ((D^[ij.1]) b))) := by
430   rw [normalForm_monomial_reverse]
431   simp only [map_sum, map_nsmul]
432   apply Finset.sum_congr rfl
433   intro ij hij
434   by_cases he : Even ij.1
435   · rw [he.neg_one_pow, one_mul]
436     change l.choose ij.1 •
437       (rightOrePBWBasis D).repr
438         (MulOpposite.op ((D^[ij.1]) b) • rightPBWMonomial D ij.2) = _
439     rw [rightPBWBasis_repr_single, if_pos he]
440   · have ho : Odd ij.1 := Nat.not_even_iff_odd.mp he
441     rw [ho.neg_one_pow, neg_one_mul, map_neg]
442     change l.choose ij.1 • -((rightOrePBWBasis D).repr
443       (MulOpposite.op ((D^[ij.1]) b) • rightPBWMonomial D ij.2)) = _
444     rw [rightPBWBasis_repr_single, if_neg he]
445 
446 private theorem rightPBWBasis_repr_monomial_coeff_top
447     {B : Type*} [Ring B] [Nontrivial B]
448     (D : OreDivisionDerivation B) (l : ℕ) (b : B) :
449     ((rightOrePBWBasis D).repr
450       (normalForm D (Polynomial.monomial l b))) l = MulOpposite.op b := by
451   rw [rightPBWBasis_repr_monomial]
452   have hmem : (0, l) ∈ Finset.HasAntidiagonal.antidiagonal l := by
453     exact Finset.HasAntidiagonal.mem_antidiagonal.mpr (by simp)
454   rw [Finset.sum_apply']
455   rw [Finset.sum_eq_single (0, l)]
456   · simp [Nat.choose_zero_right]
457   · intro ij hij hne
458     have hadd := Finset.HasAntidiagonal.mem_antidiagonal.mp hij
459     have hsecond : ij.2 ≠ l := by
460       intro h
461       apply hne
462       apply Prod.ext
463       · omega
464       · exact h
465     by_cases he : Even ij.1
466     · simp [he, hsecond]
467     · simp [he, hsecond]
468   · intro hnot
469     exact (hnot hmem).elim
470 
471 private theorem rightPBWBasis_repr_monomial_coeff_zero_of_lt
472     {B : Type*} [Ring B] [Nontrivial B]
473     (D : OreDivisionDerivation B) (l j : ℕ) (b : B) (hlj : l < j) :
474     ((rightOrePBWBasis D).repr
475       (normalForm D (Polynomial.monomial l b))) j = 0 := by
476   rw [rightPBWBasis_repr_monomial, Finset.sum_apply']
477   apply Finset.sum_eq_zero
478   intro ij hij
479   have hadd : ij.1 + ij.2 = l :=
480     Finset.HasAntidiagonal.mem_antidiagonal.mp hij
481   have hsecond : ij.2 ≠ j := by
482     intro h
483     subst j
484     omega
485   by_cases he : Even ij.1
486   · rw [if_pos he]
487     rw [Finsupp.smul_single]
488     simp [Finsupp.single_apply, hsecond]
489   · rw [if_neg he]
490     simp only [smul_neg]
491     rw [Finsupp.smul_single]
492     simp [Finsupp.single_apply, hsecond]
493 
494 private theorem pairRightBasis_repr_monomial_bound (n N l : ℕ)
495     (b : CoordinateStage (B := IteratedPairStage k n))
496     (hl : l ≤ N)
497     (hb : b ∈ coordinateBernsteinPiece k n (N - l)) :
498     rightBernsteinBound k n N
499       ((pairStage_rightOrePBWBasis (B := IteratedPairStage k n)).repr
500         (normalForm (coordinateDerivation :
501           OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)))
502           (Polynomial.monomial l b))) := by
503   change rightBernsteinBound k n N
504     ((rightOrePBWBasis (coordinateDerivation :
505       OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)))).repr
506       (normalForm (coordinateDerivation :
507         OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)))
508         (Polynomial.monomial l b)))
509   rw [rightPBWBasis_repr_monomial]
510   apply rightBernsteinBound_sum k n N
511   intro ij hij
512   have hadd : ij.1 + ij.2 = l :=
513     Finset.HasAntidiagonal.mem_antidiagonal.mp hij
514   have hderiv : (((coordinateDerivation :
515       OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)))^[ij.1]) b) ∈
516       coordinateBernsteinPiece k n (N - ij.2) := by
517     apply coordinateBernsteinPiece_mono k n (N - l) (N - ij.2) (by omega)
518     exact coordinateDerivation_iterate_mem_coordinateBernsteinPiece k hb
519   have hsingle : rightBernsteinBound k n N
520       (Finsupp.single ij.2 (MulOpposite.op
521         (((coordinateDerivation :
522           OreDivisionDerivation (CoordinateStage
523             (B := IteratedPairStage k n)))^[ij.1]) b))) := by
524     apply rightBernsteinBound_single k n N ij.2
525     simpa using hderiv
526   have hsign : rightBernsteinBound k n N
527       (if Even ij.1 then Finsupp.single ij.2 (MulOpposite.op
528           (((coordinateDerivation :
529             OreDivisionDerivation (CoordinateStage
530               (B := IteratedPairStage k n)))^[ij.1]) b))
531        else -Finsupp.single ij.2 (MulOpposite.op
532           (((coordinateDerivation :
533             OreDivisionDerivation (CoordinateStage
534               (B := IteratedPairStage k n)))^[ij.1]) b))) := by
535     split_ifs with he
536     · exact hsingle
537     · exact rightBernsteinBound_neg k n N hsingle
538   exact rightBernsteinBound_nsmul k n N (Nat.choose l ij.1) hsign
539 
540 theorem presentedOuterRightBernsteinBound (n N : ℕ)
541     (d : PresentedWeyl k (n + 1))
542     (hd : IsPBWMonicAt k (.inr (0 : Fin (n + 1))) N d) :
543     rightBernsteinBound k n N
544       ((pairStage_rightOrePBWBasis (B := IteratedPairStage k n)).repr
545         (presentedToIterated k (n + 1) d)) := by
546   let H := presentedOuterPolynomial k n d
547   let D : OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)) :=
548     coordinateDerivation
549   have hnormal : normalForm D H = presentedToIterated k (n + 1) d := by
550     dsimp [D, H, presentedOuterPolynomial]
551     exact (normalFormAddEquiv coordinateDerivation).apply_symm_apply _
552   rw [← hnormal]
553   change rightBernsteinBound k n N
554     ((rightOrePBWBasis D).repr (normalForm D H))
555   have hsum : H = ∑ l ∈ H.support, Polynomial.monomial l (H.coeff l) := by
556     simpa [Polynomial.sum_def] using (Polynomial.sum_monomial_eq H).symm
557   rw [hsum]
558   have hrepr :
559       (rightOrePBWBasis D).repr
560           (normalForm D (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) =
561         ∑ l ∈ H.support,
562           (rightOrePBWBasis D).repr (normalForm D (Polynomial.monomial l (H.coeff l))) := by
563     change (rightOrePBWBasis D).repr
564         ((normalFormAddEquiv D)
565           (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) = _
566     rw [map_sum]
567     rw [map_sum]
568     rfl
569   rw [hrepr]
570   apply rightBernsteinBound_sum k n N
571   intro l hl
572   have hcoeff : H.coeff l ≠ 0 := (Polynomial.mem_support_iff.mp hl)
573   have hlN : l ≤ N := by
574     by_contra h
575     have hzero := outer_coeff_eq_zero_of_exponent_gt k n N hd (by omega : N < l)
576     exact hcoeff (by simpa [H] using hzero)
577   exact pairRightBasis_repr_monomial_bound k n N l (H.coeff l) hlN
578     (presentedOuterCoefficient_mem_coordinateBernsteinPiece k n N l d hd.1)
579 
580 /-- Right-momentum coefficients above the outer monic degree vanish. -/
581 theorem presentedOuterRightBasis_coeff_zero_of_gt (n N p : ℕ)
582     (d : PresentedWeyl k (n + 1))
583     (hd : IsPBWMonicAt k (.inr (0 : Fin (n + 1))) N d) (hp : N < p) :
584     ((pairStage_rightOrePBWBasis (B := IteratedPairStage k n)).repr
585       (presentedToIterated k (n + 1) d)) p = 0 := by
586   let D : OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)) :=
587     coordinateDerivation
588   let H := presentedOuterPolynomial k n d
589   have hnormal : normalForm D H = presentedToIterated k (n + 1) d := by
590     dsimp [D, H, presentedOuterPolynomial]
591     exact (normalFormAddEquiv coordinateDerivation).apply_symm_apply _
592   rw [← hnormal]
593   change ((rightOrePBWBasis D).repr (normalForm D H)) p = 0
594   have hsum : H = ∑ l ∈ H.support, Polynomial.monomial l (H.coeff l) := by
595     simpa [Polynomial.sum_def] using (Polynomial.sum_monomial_eq H).symm
596   rw [hsum]
597   have hrepr :
598       (rightOrePBWBasis D).repr
599           (normalForm D (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) =
600         ∑ l ∈ H.support,
601           (rightOrePBWBasis D).repr (normalForm D (Polynomial.monomial l (H.coeff l))) := by
602     change (rightOrePBWBasis D).repr
603         ((normalFormAddEquiv D)
604           (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) = _
605     rw [map_sum]
606     rw [map_sum]
607     rfl
608   rw [hrepr, Finset.sum_apply']
609   apply Finset.sum_eq_zero
610   intro l hl
611   have hlN : l ≤ N := by
612     by_contra h
613     have hzero := outer_coeff_eq_zero_of_exponent_gt k n N hd (by omega : N < l)
614     exact (Polynomial.mem_support_iff.mp hl) (by simpa [H] using hzero)
615   exact rightPBWBasis_repr_monomial_coeff_zero_of_lt D l p (H.coeff l)
616     (lt_of_le_of_lt hlN hp)
617 
618 /-- The coefficient at the outer degree is exactly one in right PBW normal form. -/
619 theorem presentedOuterRightBasis_coeff_at_bound (n N : ℕ)
620     (d : PresentedWeyl k (n + 1))
621     (hd : IsPBWMonicAt k (.inr (0 : Fin (n + 1))) N d) :
622     ((pairStage_rightOrePBWBasis (B := IteratedPairStage k n)).repr
623       (presentedToIterated k (n + 1) d)) N = MulOpposite.op (1 : CoordinateStage
624         (B := IteratedPairStage k n)) := by
625   let D : OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)) :=
626     coordinateDerivation
627   let H := presentedOuterPolynomial k n d
628   have hnormal : normalForm D H = presentedToIterated k (n + 1) d := by
629     dsimp [D, H, presentedOuterPolynomial]
630     exact (normalFormAddEquiv coordinateDerivation).apply_symm_apply _
631   rw [← hnormal]
632   change ((rightOrePBWBasis D).repr (normalForm D H)) N =
633     MulOpposite.op (1 : CoordinateStage (B := IteratedPairStage k n))
634   have hNcoeff : H.coeff N = 1 := by
635     dsimp [H]
636     exact outer_coeff_eq_one_at_bound k n N hd
637   have hNmem : N ∈ H.support := by
638     rw [Polynomial.mem_support_iff, hNcoeff]
639     exact one_ne_zero
640   have hsum : H = ∑ l ∈ H.support, Polynomial.monomial l (H.coeff l) := by
641     simpa [Polynomial.sum_def] using (Polynomial.sum_monomial_eq H).symm
642   rw [hsum]
643   have hrepr :
644       (rightOrePBWBasis D).repr
645           (normalForm D (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) =
646         ∑ l ∈ H.support,
647           (rightOrePBWBasis D).repr (normalForm D (Polynomial.monomial l (H.coeff l))) := by
648     change (rightOrePBWBasis D).repr
649         ((normalFormAddEquiv D)
650           (∑ l ∈ H.support, Polynomial.monomial l (H.coeff l))) = _
651     rw [map_sum]
652     rw [map_sum]
653     rfl
654   rw [hrepr, Finset.sum_apply']
655   rw [Finset.sum_eq_single N]
656   · rw [rightPBWBasis_repr_monomial_coeff_top, hNcoeff]
657   · intro l hl hne
658     have hlN : l ≤ N := by
659       by_contra h
660       have hzero := outer_coeff_eq_zero_of_exponent_gt k n N hd (by omega : N < l)
661       exact (Polynomial.mem_support_iff.mp hl) (by simpa [H] using hzero)
662     have hlt : l < N := by omega
663     exact rightPBWBasis_repr_monomial_coeff_zero_of_lt D l N (H.coeff l) hlt
664   · intro hnot
665     exact (hnot hNmem).elim
666 
667 /-- The PBW monic normal form with right coefficients, including the degree
668 bound on every lower coefficient. -/
669 theorem presentedOuter_right_monic_decomposition (n N : ℕ)
670     (d : PresentedWeyl k (n + 1))
671     (hd : IsPBWMonicAt k (.inr (0 : Fin (n + 1))) N d) :
672     ∃ a : ℕ → CoordinateStage (B := IteratedPairStage k n),
673       (∀ j, j < N → a j ∈ coordinateBernsteinPiece k n (N - j)) ∧
674       presentedToIterated k (n + 1) d =
675         rightPBWMonomial (coordinateDerivation :
676           OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n))) N +
677         ∑ j ∈ Finset.range N,
678           MulOpposite.op (a j) • rightPBWMonomial (coordinateDerivation :
679             OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n))) j := by
680   let D : OreDivisionDerivation (CoordinateStage (B := IteratedPairStage k n)) :=
681     coordinateDerivation
682   let b := pairStage_rightOrePBWBasis (B := IteratedPairStage k n)
683   let c := b.repr (normalForm D (presentedOuterPolynomial k n d))
684   have hnormal : normalForm D (presentedOuterPolynomial k n d) =
685       presentedToIterated k (n + 1) d := by
686     dsimp [D, presentedOuterPolynomial]
687     exact (normalFormAddEquiv coordinateDerivation).apply_symm_apply _
688   have hcTop : c N = MulOpposite.op (1 : CoordinateStage
689       (B := IteratedPairStage k n)) := by
690     simpa [c, b, D, hnormal, pairStage_rightOrePBWBasis] using
691       presentedOuterRightBasis_coeff_at_bound k n N d hd
692   have hcAbove (j : ℕ) (hNj : N < j) : c j = 0 := by
693     simpa [c, b, D, hnormal, pairStage_rightOrePBWBasis] using
694       presentedOuterRightBasis_coeff_zero_of_gt k n N j d hd hNj
695   have heraseSupport : (Finsupp.erase N c).support ⊆ Finset.range N := by
696     intro j hj
697     rw [Finsupp.support_erase, Finset.mem_erase] at hj
698     rcases hj with ⟨hne, hmem⟩
699     have hcnz : c j ≠ 0 := Finsupp.mem_support_iff.mp hmem
700     have hjN : j < N := by
701       by_contra hjN
702       have hNj : N < j := by omega
703       exact hcnz (hcAbove j hNj)
704     exact Finset.mem_range.mpr hjN
705   have heraseSum :
706       Finsupp.sum (Finsupp.erase N c) (fun j a => a • b j) =
707         ∑ j ∈ Finset.range N, (Finsupp.erase N c) j • b j := by
708     exact Finsupp.sum_of_support_subset (Finsupp.erase N c) heraseSupport
709       (fun j a => a • b j) (by intro j hj; simp)
710   have hdecomp : b.repr.symm c = c N • b N +
711       ∑ j ∈ Finset.range N, c j • b j := by
712     have hsingle : (Finsupp.linearCombination
713         (MulOpposite (CoordinateStage (B := IteratedPairStage k n))) b
714         (Finsupp.single N (c N))) = c N • b N := by
715       rw [Finsupp.linearCombination_apply]
716       exact Finsupp.sum_single_index (by simp)
717     calc
718       b.repr.symm c = Finsupp.linearCombination
719           (MulOpposite (CoordinateStage (B := IteratedPairStage k n))) b c :=
720             b.repr_symm_apply c
721       _ = Finsupp.linearCombination
722           (MulOpposite (CoordinateStage (B := IteratedPairStage k n))) b
723           (Finsupp.single N (c N) + Finsupp.erase N c) := by
724             rw [Finsupp.single_add_erase]
725       _ = _ := by
726             rw [map_add]
727             rw [hsingle]
728             rw [Finsupp.linearCombination_apply]
729             rw [heraseSum]
730             congr 1
731             apply Finset.sum_congr rfl
732             intro j hj
733             rw [Finsupp.erase_apply]
734             have hjlt : j < N := Finset.mem_range.mp hj
735             have hjne : j ≠ N := by omega
736             simp [hjne]
737   have hback : presentedToIterated k (n + 1) d = b.repr.symm c := by
738     dsimp [c]
739     rw [← hnormal]
740     exact (b.repr.symm_apply_apply _).symm
741   have hbasis (j : ℕ) : b j = rightPBWMonomial D j := by
742     simp [b, D, pairStage_rightOrePBWBasis]
743   have hdecomp' : b.repr.symm c = c N • rightPBWMonomial D N +
744       ∑ j ∈ Finset.range N, c j • rightPBWMonomial D j := by
745     calc
746       b.repr.symm c = c N • b N + ∑ j ∈ Finset.range N, c j • b j := hdecomp
747       _ = c N • rightPBWMonomial D N +
748           ∑ j ∈ Finset.range N, c j • rightPBWMonomial D j := by
749             rw [hbasis N]
750             congr 1
751             apply Finset.sum_congr rfl
752             intro j hj
753             rw [hbasis j]
754   let a : ℕ → CoordinateStage (B := IteratedPairStage k n) :=
755     fun j => MulOpposite.unop (c j)
756   refine ⟨a, ?_, ?_⟩
757   · intro j hj
758     dsimp [a]
759     simpa [c, b, D, hnormal, pairStage_rightOrePBWBasis] using
760       (presentedOuterRightBernsteinBound k n N d hd) j
761   · rw [hback, hdecomp', hcTop]
762     simp [a, D] <;> rfl
763 
764 end
765 
766 end Stafford38.WeylPaperRightMonic
767