File size: 31,675 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedActive
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedPoint
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedZ
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXYPoint
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXZPoint
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.XYFactors
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.PrescribedCompositeCompact
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.PointIsogenyComparison
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedCoordinateKernel
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointBound
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointCompact
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCompactPoint
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralKernelPresentation
import OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointIsogeny
import OAI.AlgebraicGeometry.AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport

/-! # Parameter Eq -/

namespace OAI

noncomputable section

namespace AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferencePoints

/-! Every original disjoint active line specializes to the independent
canonical Y quotient at its constructed geometric line label. -/

open _root_.CategoryTheory _root_.AlgebraicGeometry
open scoped _root_.CategoryTheory.MonObj _root_.CategoryTheory.Obj

open OAI.AlgebraicGeometry.AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport.Construction OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.Lifts OAI.AlgebraicGeometry.Isogenies.NeighborCounting.ConstructedActiveEvaluation
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.ParameterEnumeration OAI.AlgebraicGeometry.Isogenies.NeighborCounting.HeckeExponents OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.ActiveCoordinateEquiv
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinateSubspaces OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralActiveKernels
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotients OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotientKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntrinsicNeighbors.ReferenceIntrinsic OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.GenericSameKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralKernelPresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.QuotientTargets
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.KernelBound

variable {E K : Type} [Field E] [NumberField E] [Algebra ℚ E] [IsGalois ℚ E]
  [NumberField.IsCMField E] [Field K] [NumberField K]
  {s N : ℕ} {P : AbelianModuli.ReferenceFamily.Datum.RankThreePELDatum E (s + 1)}
  {iota : E →+* K} {κ : K →+* ℂ}
  {M : Over (Spec (.of K))} {U : AbelianModuli.ReferenceFamily.PEL.Objects.PELObject P iota N M}
  {B : PELModuli.IntegralModel.Base.ArithmeticBaseExtension K κ} {q : ℕ} [Fact q.Prime]
  {D : AbelianScheme.FrobeniusKernel.Integral.Construction.SplitPELReduction P iota κ M U B q}
  (j : PELModuli.CMPoints.Arithmetic.QadicChoice K κ q) (hsplit : j.HasSplitCoordinates iota)
  (labels : (Fin (s + 1) × Bool) ≃ Gal(E/ℚ))
  (O : D.OrdinaryKernelData j iota hsplit labels)
  {R L : Type} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
  [IsAdicComplete (IsLocalRing.maximalIdeal R) R]
  [Field L] [CharZero L] [Algebra R L] [IsFractionRing R L]
  {b : B.R →+* R} {residueIso : AbelianScheme.FrobeniusKernel.ModuliPoint.Construction.residueClosure q ≃+* IsLocalRing.ResidueField R}
  {x : D.OrdinaryPoint} (l : Lifts.IntegralLift D R b residueIso x.val) (hTorsionQuotient : AbelianScheme.IsogenyQuotient.Unit.Construction.TorsionQuotientInput)

local instance neighborProjector_group (i : Fin 3) (v : Fin (s + 1)) :
    IsMonHom (Intrinsic.ParameterEnumeration.originalNeighborProjectors (L := L) j hsplit labels l i v) :=
  (l.genericAction (L := L)).preservesGroup
    (j.projector iota hsplit (HeckeExponents.neighborLevel i) (labels (v, false)))

variable (a : ConstructedActiveEvaluation.LiftedActiveEvaluation (L := L) j hsplit labels O l hTorsionQuotient)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedCoordinateKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors.ReferencePresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointBound OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointCompact
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCompactPoint

variable (hlabels : ∀ v : Fin (s + 1),
  labels (v, true) = PELModuli.CMPoints.Arithmetic.rationalConjugation E * labels (v, false))
  (C0 : D.CompactKernelPrescription j iota hsplit labels)
  (hC0 : D.CompactKernelCondition j iota hsplit labels O C0)
  (hgood : D.IsGoodCompletelySplitReduction)
  (hbase : Lifts.ResidueCompatible D R b residueIso)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCoordinates.X OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues.CoordinateCases
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedActive.ReferenceXPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedPoint.ReferenceY OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedZ.ReferencePoint
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXYPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXZPoint

variable (X0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (Yquotient : D.OrdinaryPoint → AbelianScheme.FrobeniusKernel.EtaleSubgroups.Construction.ActiveEtaleLine q → D.OrdinaryPoint)
  (Z0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (QX : D.PrescribedOrdinaryQuotient x q (D.prescribedFullXKernel j iota hsplit labels O C0 x) (X0 x))
  (hY : ∀ y J, D.CanonicalOrdinaryQuotient y q
    (D.prescribedFullYKernel j iota hsplit labels O C0 y J) (Yquotient y J))
  (hZ : ∀ y, D.CanonicalOrdinaryQuotient y (q ^ 2)
    (D.prescribedFullZKernel j iota hsplit labels O C0 y) (Z0 y))
  (hFrob : ∀ (T : Over D.integralGeometricBase.left)
    (a : T ⟶ (D.pointDatum x.val).data.polarized.abelian.scheme),
    D.prescribedFullXKernel j iota hsplit labels O C0 x T a ↔ D.relativeFrobeniusKernelCondition x T a)

def originalCanonicalParameterValue :=
  Parameter.CanonicalValues.canonicalParameterValue (X0 x).val (Z0 x).val (Z0 (X0 x)).val
    (fun J => (Yquotient x J).val) (fun J => (Yquotient (X0 x) J).val)
    (CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a)
    ((CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a).trans
      (Canonical.ActiveCoordinates.X.canonicalXLineEquiv j hsplit labels O C0 QX hFrob))

attribute [local irreducible] ReducedPoint.originalReducedPoint CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv
  IntrinsicNeighbors.ReferenceIntrinsic.originalNativeNeighbor CoordinateSubspaces.originalCoordinateKernelParameters
  Canonical.ActiveCoordinates.X.canonicalXLineEquiv

include hY hC0 in
theorem originalReducedPoint_parameter_value_zero
    (p : ULift (Fin (a.evaluation.count (some 0)))) :
    ReducedPoint.originalReducedPoint j hsplit labels O l hTorsionQuotient a hlabels 0 p hgood hbase =
      originalCanonicalParameterValue j hsplit labels O l hTorsionQuotient a C0 X0 Yquotient Z0 QX hFrob 0
        (CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 0 p)
        (CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 0 p) := by
  classical
  unfold originalCanonicalParameterValue
  rcases Parameter.CanonicalValues.CoordinateCases.line_projection_cases
      (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 0 p).val
      (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 0 p).property with
      ⟨hp, hf⟩ | ⟨J, hp, hf⟩
  · change CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 0 p = ⊥ at hp
    change CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 0 p = true at hf
    have h := ReferenceReducedActive.ReferenceXPoint.originalReducedPoint_eq_X j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase p hp hf QX
    simpa only [Parameter.CanonicalValues.canonicalParameterValue_zero, hf, ↓reduceIte] using h
  · change CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 0 p = J.val at hp
    change CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 0 p = false at hf
    have h := ReferenceReducedPoint.ReferenceY.originalReducedPoint_eq_Y j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase p J hp hf
      (Classical.choice (hY x (CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a J)).1)
    simpa only [Parameter.CanonicalValues.canonicalParameterValue_zero, hp, hf, Bool.false_eq_true, ↓reduceIte,
      Parameter.CanonicalValues.lineParameterValue_line] using h

include hY hZ hC0 in
theorem originalReducedPoint_parameter_value_one
    (p : ULift (Fin (a.evaluation.count (some 1)))) :
    ReducedPoint.originalReducedPoint j hsplit labels O l hTorsionQuotient a hlabels 1 p hgood hbase =
      originalCanonicalParameterValue j hsplit labels O l hTorsionQuotient a C0 X0 Yquotient Z0 QX hFrob 1
        (CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 1 p)
        (CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 1 p) := by
  classical
  unfold originalCanonicalParameterValue
  rcases Parameter.CanonicalValues.CoordinateCases.plane_projection_cases
      (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 1 p).val
      (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 1 p).property with
      ⟨J, hp, hf⟩ | ⟨hp, hf⟩
  · change CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 1 p = J.val at hp
    change CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 1 p = true at hf
    have h := ReducedXYPoint.originalReducedPoint_eq_XY j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase
      QX hFrob p J hp hf
      (Classical.choice (hY (X0 x) (Canonical.ActiveCoordinates.X.canonicalXLineEquiv j hsplit labels O C0 QX hFrob
        (CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a J))).1)
    simpa only [Parameter.CanonicalValues.canonicalParameterValue_one, hp, hf, ↓reduceIte,
      Parameter.CanonicalValues.lineParameterValue_line, Equiv.trans_apply] using h
  · change CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 1 p = ⊤ at hp
    change CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 1 p = false at hf
    have h := ReducedZ.ReferencePoint.originalReducedPoint_eq_Z j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase
      p hp hf (Classical.choice (hZ x).1)
    simpa only [Parameter.CanonicalValues.canonicalParameterValue_one, hf, Bool.false_eq_true, ↓reduceIte] using h

include hZ hC0 in
theorem originalReducedPoint_parameter_value_two
    (p : ULift (Fin (a.evaluation.count (some 2)))) :
    ReducedPoint.originalReducedPoint j hsplit labels O l hTorsionQuotient a hlabels 2 p hgood hbase =
      originalCanonicalParameterValue j hsplit labels O l hTorsionQuotient a C0 X0 Yquotient Z0 QX hFrob 2
        (CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 2 p)
        (CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 2 p) := by
  classical
  unfold originalCanonicalParameterValue
  obtain ⟨hp, hf⟩ := Parameter.CanonicalValues.CoordinateCases.full_projection_case
    (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 2 p).val
    (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a 2 p).property
  change CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a 2 p = ⊤ at hp
  change CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a 2 p = true at hf
  exact ReducedXZPoint.originalReducedPoint_eq_XZ j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase
    QX hFrob p hp hf (Classical.choice (hZ (X0 x)).1)

include hY hZ hC0 hgood hbase in
theorem originalReducedPoint_parameter_value (i : Fin 3)
    (p : ULift (Fin (a.evaluation.count (some i)))) :
    ReducedPoint.originalReducedPoint j hsplit labels O l hTorsionQuotient a hlabels i p hgood hbase =
      originalCanonicalParameterValue j hsplit labels O l hTorsionQuotient a C0 X0 Yquotient Z0 QX hFrob i
        (CoordinatePointFactors.ReferencePresentation.originalProjection j hsplit labels O l hTorsionQuotient a i p)
        (CoordinatePointFactors.ReferencePresentation.originalIdentityFlag j hsplit labels O l hTorsionQuotient a i p) := by
  revert p
  refine Fin.cases ?_ ?_ i
  · exact originalReducedPoint_parameter_value_zero j hsplit labels O l hTorsionQuotient a hlabels
      C0 hC0 hgood hbase X0 Yquotient Z0 QX hY hFrob
  · intro i
    refine Fin.cases ?_ ?_ i
    · exact originalReducedPoint_parameter_value_one j hsplit labels O l hTorsionQuotient a hlabels
        C0 hC0 hgood hbase X0 Yquotient Z0 QX hY hZ hFrob
    · intro i
      refine Fin.cases ?_ (fun e => Fin.elim0 e) i
      exact originalReducedPoint_parameter_value_two j hsplit labels O l hTorsionQuotient a hlabels
        C0 hC0 hgood hbase X0 Yquotient Z0 QX hZ hFrob

end AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferencePoints

namespace AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferenceReducedCounts

/-! Exact multiplicities of all three original reduced neighbor families,
using the independent canonical X, Y, and Z quotients. -/

open _root_.CategoryTheory _root_.AlgebraicGeometry
open scoped _root_.CategoryTheory.MonObj _root_.CategoryTheory.Obj

open OAI.AlgebraicGeometry.AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport.Construction OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.Lifts OAI.AlgebraicGeometry.Isogenies.NeighborCounting.ConstructedActiveEvaluation
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.ParameterEnumeration OAI.AlgebraicGeometry.Isogenies.NeighborCounting.HeckeExponents OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.ActiveCoordinateEquiv
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinateSubspaces OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralActiveKernels
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotients OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotientKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntrinsicNeighbors.ReferenceIntrinsic OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.GenericSameKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralKernelPresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.QuotientTargets
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.KernelBound

variable {E K : Type} [Field E] [NumberField E] [Algebra ℚ E] [IsGalois ℚ E]
  [NumberField.IsCMField E] [Field K] [NumberField K]
  {s N : ℕ} {P : AbelianModuli.ReferenceFamily.Datum.RankThreePELDatum E (s + 1)}
  {iota : E →+* K} {κ : K →+* ℂ}
  {M : Over (Spec (.of K))} {U : AbelianModuli.ReferenceFamily.PEL.Objects.PELObject P iota N M}
  {B : PELModuli.IntegralModel.Base.ArithmeticBaseExtension K κ} {q : ℕ} [Fact q.Prime]
  {D : AbelianScheme.FrobeniusKernel.Integral.Construction.SplitPELReduction P iota κ M U B q}
  (j : PELModuli.CMPoints.Arithmetic.QadicChoice K κ q) (hsplit : j.HasSplitCoordinates iota)
  (labels : (Fin (s + 1) × Bool) ≃ Gal(E/ℚ))
  (O : D.OrdinaryKernelData j iota hsplit labels)
  {R L : Type} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
  [IsAdicComplete (IsLocalRing.maximalIdeal R) R]
  [Field L] [CharZero L] [Algebra R L] [IsFractionRing R L]
  {b : B.R →+* R} {residueIso : AbelianScheme.FrobeniusKernel.ModuliPoint.Construction.residueClosure q ≃+* IsLocalRing.ResidueField R}
  {x : D.OrdinaryPoint} (l : Lifts.IntegralLift D R b residueIso x.val) (hTorsionQuotient : AbelianScheme.IsogenyQuotient.Unit.Construction.TorsionQuotientInput)

local instance neighborProjector_group (i : Fin 3) (v : Fin (s + 1)) :
    IsMonHom (Intrinsic.ParameterEnumeration.originalNeighborProjectors (L := L) j hsplit labels l i v) :=
  (l.genericAction (L := L)).preservesGroup
    (j.projector iota hsplit (HeckeExponents.neighborLevel i) (labels (v, false)))

variable (a : ConstructedActiveEvaluation.LiftedActiveEvaluation (L := L) j hsplit labels O l hTorsionQuotient)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedCoordinateKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors.ReferencePresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointBound OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointCompact
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCompactPoint

variable (hlabels : ∀ v : Fin (s + 1),
  labels (v, true) = PELModuli.CMPoints.Arithmetic.rationalConjugation E * labels (v, false))
  (C0 : D.CompactKernelPrescription j iota hsplit labels)
  (hC0 : D.CompactKernelCondition j iota hsplit labels O C0)
  (hgood : D.IsGoodCompletelySplitReduction)
  (hbase : Lifts.ResidueCompatible D R b residueIso)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCoordinates.X OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues.CoordinateCases
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedActive.ReferenceXPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedPoint.ReferenceY OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedZ.ReferencePoint
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXYPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXZPoint

variable (X0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (Yquotient : D.OrdinaryPoint → AbelianScheme.FrobeniusKernel.EtaleSubgroups.Construction.ActiveEtaleLine q → D.OrdinaryPoint)
  (Z0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (QX : D.PrescribedOrdinaryQuotient x q (D.prescribedFullXKernel j iota hsplit labels O C0 x) (X0 x))
  (hY : ∀ y J, D.CanonicalOrdinaryQuotient y q
    (D.prescribedFullYKernel j iota hsplit labels O C0 y J) (Yquotient y J))
  (hZ : ∀ y, D.CanonicalOrdinaryQuotient y (q ^ 2)
    (D.prescribedFullZKernel j iota hsplit labels O C0 y) (Z0 y))
  (hFrob : ∀ (T : Over D.integralGeometricBase.left)
    (a : T ⟶ (D.pointDatum x.val).data.polarized.abelian.scheme),
    D.prescribedFullXKernel j iota hsplit labels O C0 x T a ↔ D.relativeFrobeniusKernelCondition x T a)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferencePoints OAI.AlgebraicGeometry.Isogenies.NeighborCounting.ThreeParameterCounts

def originalReducedMultiset (i : Fin 3) : Multiset D.GeometricPoint :=
  Finset.univ.val.map (fun p => ReducedPoint.originalReducedPoint j hsplit labels O l hTorsionQuotient a hlabels i p hgood hbase)

attribute [local irreducible] ReducedPoint.originalReducedPoint CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv
  IntrinsicNeighbors.ReferenceIntrinsic.originalNativeNeighbor CoordinateSubspaces.originalCoordinateKernelParameters
  Canonical.ActiveCoordinates.X.canonicalXLineEquiv

include hY hZ hC0 in
theorem originalReducedMultiset_parameter_eq (i : Fin 3) :
    originalReducedMultiset j hsplit labels O l hTorsionQuotient a hlabels hgood hbase i =
      ThreeParameterCounts.originalLabeledParameters (fun i : Fin 3 => ULift (Fin (a.evaluation.count (some i))))
        (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a)
        (ReferencePoints.originalCanonicalParameterValue j hsplit labels O l hTorsionQuotient a C0 X0 Yquotient Z0 QX hFrob) i := by
  unfold originalReducedMultiset ThreeParameterCounts.originalLabeledParameters
  apply Multiset.map_congr rfl
  intro p _
  exact ReferencePoints.originalReducedPoint_parameter_value j hsplit labels O l hTorsionQuotient a hlabels C0 hC0 hgood hbase
    X0 Yquotient Z0 QX hY hZ hFrob i p

include hY hZ hC0 QX hFrob in
theorem originalReducedMultiset_counts :
    originalReducedMultiset j hsplit labels O l hTorsionQuotient a hlabels hgood hbase 0 =
      {(X0 x).val} + q • ((AbelianScheme.FrobeniusKernel.OperatorSpecification.Construction.etaleLineMultiset (Yquotient x)).map Subtype.val) ∧
    originalReducedMultiset j hsplit labels O l hTorsionQuotient a hlabels hgood hbase 1 =
      ((AbelianScheme.FrobeniusKernel.OperatorSpecification.Construction.etaleLineMultiset (Yquotient (X0 x))).map Subtype.val) + q ^ 2 • {(Z0 x).val} ∧
    originalReducedMultiset j hsplit labels O l hTorsionQuotient a hlabels hgood hbase 2 = {(Z0 (X0 x)).val} := by
  have h := Parameter.CanonicalValues.original_canonical_parameter_counts
    (fun i : Fin 3 => ULift (Fin (a.evaluation.count (some i))))
    (CoordinateSubspaces.originalCoordinateSubspaceEquiv j hsplit labels O l hTorsionQuotient a)
    (X0 x).val (Z0 x).val (Z0 (X0 x)).val
    (fun J => (Yquotient x J).val) (fun J => (Yquotient (X0 x) J).val)
    (CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a)
    ((CoordinatePointFactors.ReferencePresentation.originalSpecialLineEquiv j hsplit labels O l hTorsionQuotient a).trans
      (Canonical.ActiveCoordinates.X.canonicalXLineEquiv j hsplit labels O C0 QX hFrob))
  have he := originalReducedMultiset_parameter_eq j hsplit labels O l hTorsionQuotient a hlabels
    C0 hC0 hgood hbase X0 Yquotient Z0 QX hY hZ hFrob
  have hy0 := AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport.Construction.etaleLineMultiset_map (Yquotient x)
    (Subtype.val : D.OrdinaryPoint → D.GeometricPoint)
  have hy1 := AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport.Construction.etaleLineMultiset_map (Yquotient (X0 x))
    (Subtype.val : D.OrdinaryPoint → D.GeometricPoint)
  refine ⟨(he 0).trans (h.1.trans ?_), (he 1).trans (h.2.1.trans ?_),
    (he 2).trans h.2.2⟩
  · exact congrArg (fun m => {(X0 x).val} + q • m) hy0.symm
  · exact congrArg (fun m => m + q ^ 2 • {(Z0 x).val}) hy1.symm

end AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferenceReducedCounts

namespace AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferenceIntrinsicReduction

/-! Package the constructed evaluation field, DVR, original full PEL
neighbors, and proved multiplicities into the native reduction result. -/

open _root_.CategoryTheory _root_.AlgebraicGeometry
open scoped _root_.CategoryTheory.MonObj _root_.CategoryTheory.Obj

open OAI.AlgebraicGeometry.AbelianScheme.FrobeniusKernel.EtaleLineMultisetTransport.Construction OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.Lifts OAI.AlgebraicGeometry.Isogenies.NeighborCounting.ConstructedActiveEvaluation
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.ParameterEnumeration OAI.AlgebraicGeometry.Isogenies.NeighborCounting.HeckeExponents OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.ActiveCoordinateEquiv
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinateSubspaces OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralActiveKernels
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotients OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralQuotientKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntrinsicNeighbors.ReferenceIntrinsic OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.GenericSameKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.IntegralKernelPresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.QuotientTargets
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Evaluated.PointIsogeny.KernelBound

variable {E K : Type} [Field E] [NumberField E] [Algebra ℚ E] [IsGalois ℚ E]
  [NumberField.IsCMField E] [Field K] [NumberField K]
  {s N : ℕ} {P : AbelianModuli.ReferenceFamily.Datum.RankThreePELDatum E (s + 1)}
  {iota : E →+* K} {κ : K →+* ℂ}
  {M : Over (Spec (.of K))} {U : AbelianModuli.ReferenceFamily.PEL.Objects.PELObject P iota N M}
  {B : PELModuli.IntegralModel.Base.ArithmeticBaseExtension K κ} {q : ℕ} [Fact q.Prime]
  {D : AbelianScheme.FrobeniusKernel.Integral.Construction.SplitPELReduction P iota κ M U B q}
  (j : PELModuli.CMPoints.Arithmetic.QadicChoice K κ q) (hsplit : j.HasSplitCoordinates iota)
  (labels : (Fin (s + 1) × Bool) ≃ Gal(E/ℚ))
  (O : D.OrdinaryKernelData j iota hsplit labels)
  {R L : Type} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
  [IsAdicComplete (IsLocalRing.maximalIdeal R) R]
  [Field L] [CharZero L] [Algebra R L] [IsFractionRing R L]
  {b : B.R →+* R} {residueIso : AbelianScheme.FrobeniusKernel.ModuliPoint.Construction.residueClosure q ≃+* IsLocalRing.ResidueField R}
  {x : D.OrdinaryPoint} (l : Lifts.IntegralLift D R b residueIso x.val) (hTorsionQuotient : AbelianScheme.IsogenyQuotient.Unit.Construction.TorsionQuotientInput)

local instance neighborProjector_group (i : Fin 3) (v : Fin (s + 1)) :
    IsMonHom (Intrinsic.ParameterEnumeration.originalNeighborProjectors (L := L) j hsplit labels l i v) :=
  (l.genericAction (L := L)).preservesGroup
    (j.projector iota hsplit (HeckeExponents.neighborLevel i) (labels (v, false)))

variable (a : ConstructedActiveEvaluation.LiftedActiveEvaluation (L := L) j hsplit labels O l hTorsionQuotient)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedCoordinateKernel
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors.ReferencePresentation OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.CoordinatePointFactors
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointBound OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.SpecialPointCompact
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCompactPoint

variable (hlabels : ∀ v : Fin (s + 1),
  labels (v, true) = PELModuli.CMPoints.Arithmetic.rationalConjugation E * labels (v, false))
  (C0 : D.CompactKernelPrescription j iota hsplit labels)
  (hC0 : D.CompactKernelCondition j iota hsplit labels O C0)
  (hgood : D.IsGoodCompletelySplitReduction)
  (hbase : Lifts.ResidueCompatible D R b residueIso)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Canonical.ActiveCoordinates.X OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Parameter.CanonicalValues.CoordinateCases
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedActive.ReferenceXPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReferenceReducedPoint.ReferenceY OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedZ.ReferencePoint
open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXYPoint OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ReducedXZPoint

variable (X0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (Yquotient : D.OrdinaryPoint → AbelianScheme.FrobeniusKernel.EtaleSubgroups.Construction.ActiveEtaleLine q → D.OrdinaryPoint)
  (Z0 : D.OrdinaryPoint → D.OrdinaryPoint)
  (QX : D.PrescribedOrdinaryQuotient x q (D.prescribedFullXKernel j iota hsplit labels O C0 x) (X0 x))
  (hY : ∀ y J, D.CanonicalOrdinaryQuotient y q
    (D.prescribedFullYKernel j iota hsplit labels O C0 y J) (Yquotient y J))
  (hZ : ∀ y, D.CanonicalOrdinaryQuotient y (q ^ 2)
    (D.prescribedFullZKernel j iota hsplit labels O C0 y) (Z0 y))
  (hFrob : ∀ (T : Over D.integralGeometricBase.left)
    (a : T ⟶ (D.pointDatum x.val).data.polarized.abelian.scheme),
    D.prescribedFullXKernel j iota hsplit labels O C0 x T a ↔ D.relativeFrobeniusKernelCondition x T a)

open OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferenceReducedCounts OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.ReductionSpecification OAI.AlgebraicGeometry.Isogenies.NeighborCounting.Intrinsic.KernelLabels

include a hlabels hgood QX hFrob hY hZ hC0 in
theorem nativeReductionResult_of_activeEvaluation :
    Intrinsic.ReductionSpecification.NativeReductionResult (L := L) j hsplit (Intrinsic.KernelLabels.nativeKernelLabels labels) 0 (Fin.cases false (O.compact x))
      hTorsionQuotient hbase X0 (fun y => AbelianScheme.FrobeniusKernel.OperatorSpecification.Construction.etaleLineMultiset (Yquotient y)) Z0 x l := by
  refine ⟨a.evaluation, ?_⟩
  let := a.evaluation.scalarAlgebra R
  let := a.evaluation.scalarTower R
  let v := ConstructedActiveEvaluation.activeEvaluationDVR j hsplit labels O l hTorsionQuotient a
  refine ⟨v, ⟨l.overEvaluationDVR v⟩,
    (fun i p => IntrinsicNeighbors.ReferenceIntrinsic.originalNativeNeighbor j hsplit labels O l hTorsionQuotient a hlabels i p hgood), ?_⟩
  exact ReferenceReducedCounts.originalReducedMultiset_counts j hsplit labels O l hTorsionQuotient a hlabels
    C0 hC0 hgood hbase X0 Yquotient Z0 QX hY hZ hFrob

end AlgebraicGeometry.Isogenies.NeighborCounting.Reference.ParameterEq.ReferenceIntrinsicReduction

end

end OAI