Skip to content

Prime-by-Prime Divisibility & Elementary Divisors of Edge Hecke Operators ​

This page unpacks the two non-Archimedean divisibility landmarks of Stage 03 — src/New/UpperBound/Divisibility/LocalDivisibility.lean (03_upper_bound/local_divisibility) and src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean (03_upper_bound/elementary_divisor_theorem) — together with their immediate upstream helper modules (MarkedPrimes.lean, MarkOperator.lean, ValuationAtNonSplitPrimes.lean, ValuationAtLevel.lean, ColengthAtLevel.lean, RootLemma.lean, AveragingMap.lean, and DefectCount.lean). Return to the Stage 03 Overview, revisit The Iterated Seesaw Identity, or continue to Short Columns & Archimedean Size.

Level 1 · First-Principles

Level 1 — First-Principles ​

In Stage 02, differentiating an elliptic theta series at a single non-split whole number greater than 1 with no smaller positive divisorsprime number p produced an extra divisibility slope γp. Stage 03 turns that derivative calculation into a global arithmetic upper bound on a matrix of automorphic periods. To do that, we fix an embedding ιp:C↪Cp from the two-dimensional field of real and imaginary scalarscomplex plane C into the p-adic completion and inspect every prime p one by one.

For a fixed prime p, we measure divisibility by powers of p — the exact prime-power divisibility exponentarithmetic height (the $p$-adic valuation) — across every coordinate of an automorphic form at once. That worst-case coordinate size is the form's maximum prime-power size across all coordinates of an automorphic formWeyl gauge (its $p$-adic gauge): saying a form has valuation at least v means its $p$-adic gauge is at most p−v. Stage 03 passes a source form through a chain of m successive lifting maps carrying source forms up through definite unitary spacestheta correspondence (an iterated theta lift, governed by a chain datum Ψ for a tame twist ϑ of conductor prime to p) and restricts the output from Xm to Ym.

A single theorem, exists_colengthDvd_gaugeLe_compositeLift, delivers the same uniform output at every prime p: a submodule S of the integral source forms M whose index in M divides a small prime power pl (l≤allowedLoss(p)⋅dim), such that on every ramified source form in S, the composite lift has valuation at least gain(p)−allowedLoss(p). The proof triages all primes p into four cases controlled by the cutoff x1, the level prime N, and the sign χK(p) recording whether p splits, stays inert, or ramifies in Kquadratic twist (χK(p)∈{+1,−1,0} for K=Q(−d)):

  1. Split or large primes (p≠N with χK(p)=1 or p≥x1): Nothing extra is demanded (gain(p)=0) and nothing is lost (allowedLoss(p)=0). Each individual lift preserves integrality, so we keep the full integral module S=M with index exponent l=0.
  2. Non-exceptional small non-split primes (p<x1, χK(p)≠1, not exceptional): Two distinguished infinite places (a-places) can collide under the Stage 02 Galois shift, costing a collision penalty on each of the m lifts. Outside the sparse exceptional primes, the single error budget loss(p) already pays for all m lifts of collisions on the full module S=M, again with l=0.
  3. Exceptional inert primes (p<x1, χK(p)=−1, p≢±1(modm), with odd order o0≤r): Collisions between a-places are now too heavy to absorb on all of M. To eliminate them, we choose one prime from each conjugate pair above p induced by the a-places (a full mark Λ) and form the product Y of one finite averaging operator summing a form over adjacent lattices at a prime above pHecke operator (each a scaled Hecke operator) per prime l∈Λ. Passing Ym through the m lifts cancels every collision on YmM, while multiplying directly by pjp pays for all collisions crudely on pjpM. Taking the sum S=YmM+pjpM achieves valuation at least gain(p)−2⋅loss(p) on S. What remains is to show that S fills almost all of M — equivalently, that the diagonal prime-power factors controlling the index of a submodule inside a full latticeelementary divisor of Y stay small outside a tiny fraction θ of coordinates, so the colength of YmM+pjpM in M is small.
  4. The level prime (p=N): Because x1≤N, the requested gain is zero (gain(N)=0), and denominators at N are traded for the level-raising operator Upm/2. Pulling back the submodule of forms whose Upm/2-image stays integral for the auxiliary lattice L0 at the conjugate primes ΣN gives a module S of colength exponent at most mfb⋅dim≤2mfb⋅dim on which the composite lift loses at most 2mfb powers of N.

Four-case prime triage feeding into the edge-factored operator pipeline and submodule index bound

Case 3 is the engine room of Stage 03, and it rests on a self-contained algebraic theorem in ElementaryDivisorTheorem.lean. At each marked prime above an exceptional inert prime p, the a-places inducing that prime or its conjugate arrange into a ring-homomorphism loop of N alternating letters where each step raises entries to the P-th power modulo pFrobenius cycle. On this loop, the scaled Hecke operator acts as an edge Hecke operator summing over cosets of a two-block parahoric subgroup (edges between lattices).

How do you prove that an operator A on a huge lattice is almost surjective modulo pm — that its elementary divisors have small average exponent outside a small share θ? Think of A as a three-step pipe:

M⊆Mall⊆Medge→AddN⊆M∘.

First, restrict each vertex function to all outgoing edges (M⊆Mall⊆Medge). Second, pair each edge function with dual-edge functions and sum over incoming edges (Add:Medge→N). Third, embed N back into the dual vertex lattice M∘. The two outer inclusions M⊆Mall and N⊆M∘ have small, directly computable determinant losses. In the middle, Add is far from square (there are many more edges than vertices), yet we construct an explicit near inverse Inv whose outputs satisfy strict congruences modulo wc — an edge condition enforced by averaging away monomials above a defect threshold — such that Add⋅Inv≡p2Nc0I(modwc). Over the residue field, Stepanov's count of zeros against degree bounds the dimension of the space of edge functions obeying those congruences to at most (1+θ) times the vertex dimension. Putting Mall and the image of Inv into Smith normal form relative to Mall and applying Nakayama's lemma shows that at most a θ-fraction of coordinates can fail to be hit up to p2Nc0, bounding the colength of A(M)+pmM in M.

One subtle ring-theoretic fact shapes every definition in both files: the coefficient ring O modeling p-integral scalars in C (under ιp:C↪Cp) is a characteristic-zero valuation domain, not a discrete valuation ring like Zp. Because its value group is dense (Q) and it is non-noetherian, a quotient M/S need not have finite module length, whereas the square root w=p already lives inside O. That is why Stage 03 measures submodule indices by determinant-divisibility (ColengthDvd) instead of module length.

Where this analogy breaks ​

Two simplifications in the pipe picture require care in the real proof. First, ColengthDvd M S (p^l) is not literally a finite quotient cardinality |M/S|: over the non-discrete, non-noetherian valuation domain embValRing, ideals are not generated by a single uniformizer, so the theorem certifies instead that every finite family of vectors in M can be combined into S by an O-matrix whose determinant divides pl. Second, the near inverse Inv does not invert Add modulo a power of p directly on all functions; it works modulo wc (with w2=p) only against forms in the halfway lattices of all edges (allEdgesForms), and because O is not discrete, the Nakayama elimination must step down by one factor of w from wc to wc−1 so that p2Nc0w∣wc−1.

Level 2 · Undergrad Bridge

Level 2 — Undergrad Bridge ​

1. Valuation domains, ColengthDvd, and IsOntoUpToColength ​

Fix a prime p and a chosen embedding ιp:C↪Cp ([PadicPlace p]). Write embValRing for the subring {z∈C∣∥ιp(z)∥≤1}. It is a valuation domain of characteristic zero: for any two elements x,y∈O, either x∣y or y∣x, so finite matrices over O admit a Smith normal form (isValuationPair_top.smith_normal_form). However, because ιp(C) contains algebraic numbers of arbitrary ramification over Qp, embValRing is neither discrete nor noetherian.

Accordingly, New.Reduction.Lattices.Colength defines two basis-free, length-free predicates over any commutative ring O:

  • ColengthDvd M N z: For every finite family Φ:Finn→V in M, there exists an n×n matrix m over O with detm∣z such that every row combination ∑kmikΦk lies in N. It is transitive (ColengthDvd.trans, multiplying the bounds), pulls back along linear maps (ColengthDvd.comap), pushes forward (ColengthDvd.map), and satisfies ColengthDvd.of_det_dvd for square matrices over a valuation domain.
  • IsOntoUpToColength p M n y c: An endomorphism y preserves the O-submodule M (y(M)⊆M), and there exists l∈N with (l:R)≤c such that ColengthDvd M (y(M) + p^n • M) (p^l). Crucially, the upper bounds c add under products of endomorphisms (IsOntoUpToColength.prod).

Over any valuation domain O of characteristic zero in which p is a non-unit and admits a square root w∈O with w2=p, the entire elementary-divisor argument works directly over O, specializing immediately to embValRing.

2. The 4-case prime triage (LocalDivisibility.lean) ​

Recall the Stage 03 prime parameters for admissible data D:DataP (with m=D.m lifts, f=D.f=|Φ| infinite places of E, long-row length a=D.a, weight parameter b=D.b, cutoff x1=D.x1, and level prime N=D.N≥x1):

  • gain p: the target valuation of the m-step composite lift at p (zero whenever χK(p)=1 or p≥x1).
  • loss p: fa(log⁡b)2/p, multiplied by m if p≡±1(modm).
  • allowedLoss p: 2⋅loss(p) if p<x1 and χK(p)≠1 (smallNonsplitPrimes); otherwise 2mfb if p=N, and 0 otherwise.
  • collisionSum p ev: ∑a/pe over collisions (τ,e) between a-places outside ev.
  • collisionExponent p: jp=⌈2mfa/p⌉.
  • IsExceptional p: χK(p)=−1, p≢±1(modm), and the multiplicative order o0=D.o0(p) of −p(modq0) is odd and at most r=ceilLogLiftsp=⌈logp⁡m⌉.

Away from p=N, every chain datum Ψ for a twist ϑ expands via exists_isWeakChainDatum_compositeLift_eq into a weak chain datum Ψ′ with compositeLift ϑ Ψ = restrictedChain ϑ Ψ'. The gauge helpers (GaugeLe.rpow_mono, .add, .smul, .zpow_neg_smul) and gaugeLe_restrictedChain_of_mem_raises then assemble the four cases of New.Data.exists_colengthDvd_gaugeLe_compositeLift:

CasePrime Conditiongain pallowedLoss pSubmodule S⊆MColength exponent lKey Valuation / Colength Lemmas
1p≠N and (χK(p)=1 or p≥x1)00M0gaugeLe_restrictedChain_one (uses p≠d, so standard data have ratio 1)
2p<x1, χK(p)≠1, ¬IsExceptionalpgain(p)2⋅loss(p)M0mul_collisionSum_le_loss (m⋅collisionSump∅≤loss(p)) + gaugeLe_restrictedChain_collisionSum
3p<x1, IsExceptionalp (inert)gain(p)2⋅loss(p)YmM+pjpM≤loss(p)dim≤2⋅loss(p)dimexists_isFullMark, gaugeLe_restrictedChain_of_isFullMark, gaugeLe_pow_collisionExponent_smul, gaugeLe_compositeLift_of_isFullMark, isOntoUpToColength_prod_scaledHeckeOperator_pow
4p=N (hence x1≤N)02mfbpullback of upIntegralForms≤mfbdim≤2mfbdimColengthAtLevel.lean::exists_colengthDvd_upIntegralForms_pow, ValuationAtLevel.lean::gaugeLe_compositeLift_at_N

Walking through the mechanics of Case 3 and Case 4:

  • Case 3 (Exceptional inert p<x1): Since p is exceptional, exists_isFullMark picks a finite set Λ of primes of E above p disjoint from its conjugate Λ¯ such that every a-place induces a prime in Λ∪Λ¯ (IsFullMark). For each l∈Λ, scaledHeckeOperator l is pAlTl,r where Al=heckeScalingExponent(l)=a⋅|{τ∈a-places∣inducedPlaceτ=l}|. Let Y=∏l∈ΛscaledHeckeOperator(l).
    • Valuation on YmM: ValuationAtNonSplitPrimes.lean::gaugeLe_scaledHeckeOperator_pow pushes one factor of Y through each of the m lifts onto the theta data, eliminating all collisions (collisionSum_placesInducing_eq_zero). At each step j<m, the surplus a/x1 at each a-place inducing Λ plus loss(p)/m pays for the low columns and transfer exponents (card_mul_transferExponent_add_sum_lowColumns_le), so summing over j<m proves gaugeLe_restrictedChain_of_isFullMark: valuation ≥gain(p)−2⋅loss(p) on YmM.
    • Crude valuation on pjpM: Since every collision has exponent e≥1, collisionSum p ∅ ≤ 2 f a / p, so m⋅collisionSump∅≤jp=⌈2mfa/p⌉. Scaling by pjp pays for all m lifts of collisions at once (gaugeLe_pow_collisionExponent_smul), giving valuation ≥gain(p)−loss(p)≥gain(p)−2⋅loss(p).
    • Combining the two pieces: Ultrametricity (GaugeLe.add) gives gaugeLe_compositeLift_of_isFullMark on S=YmM+pjpM.
    • Colength of S in M: For each l∈Λ, MarkOperator.lean::isOntoUpToColength_scaledHeckeOperator invokes ElementaryDivisorTheorem.lean::elementary_divisors (with θ=1/(m2f) and 3cdiv≤12Al/(mp)) to show that scaledHeckeOperator(l) is onto modulo pjp up to colength exponent (12Al/(mp)+jp/(m2f))⋅dim. Multiplying over m copies of Λ (IsOntoUpToColength.prod) and applying mul_sum_heckeScalingExponent_le_loss (using ∑l∈ΛAl≤af and |Λ|≤f) bounds the total colength exponent by loss(p)⋅dim≤2⋅loss(p)⋅dim (isOntoUpToColength_prod_scaledHeckeOperator_pow).
  • Case 4 (Level prime p=N): Because x1≤N, gain N = 0. In ColengthAtLevel.lean, comparing three integral modules at ΣN (standard lattice Aι, auxiliary lattice AL at δ0=diagPointN0, and dual lattice A∨ at δ0∨=dualPointN0) bounds the colength of upIntegralForms (A′, the preimage of AL under Upm/2) in Aι by Nl with l≤mfb⋅dim (exists_colengthDvd_upIntegralForms_pow). On ramified source forms (φ ∈ D.ramifiedSourceForms, the only place Case 4 uses ramification), ValuationAtLevel.lean::gaugeLe_compositeLift_at_N applies the split-level lift law to express the glued chain as a bounded scalar times the direct chain after Upm/2, losing at most 2mfb powers of N.

3. Frobenius cycles, edge coordinates, and factoring edgeHeckeOperator (ElementaryDivisorTheorem.lean) ​

Fix a local ring W with finite residue field of size q=PN, a characteristic-zero valuation domain O in which p is not a unit, and a Frobenius cycle T:FrobeniusCycleNWO:

  • a prime p=T.p with a square root w=T.sqrtPrime∈O (w2=p),
  • a prime power P=pfrobExp≥5,
  • N ring homomorphisms ("letters") ιs:W→O (s∈Z/NZ), alternating between even and odd (isEven_succ), satisfying ιs+1(x)≡ιs(x)P(modp).

Let k be the rank, n the degree in each letter, r the first block size (0<r≤k/2), and θ∈(0,1] the allowed fraction of exceptional elementary divisors. Monomials of degree n in k variables per letter are indexed by Exponents N k n. A matrix g∈GLk(W) acts on forms by ρ(g)=T.letterRepng (using ιs(g) at even letters and ιs(g−⊤) at odd letters). The depth of a monomial β counts its degree in the deep variables (indices ≥r at even letters and <r at odd letters), giving diagonal matrices D=depthScaling (wdepthβ) and D2=depthPower (pdepthβ).

The structure New.EdgeCoordinates W O k r X H abstracts the Hecke graph in coordinates:

  • X represents the finite set of lattice orbits; H indexes a basis of the auxiliary free O-module at each vertex; edges into x∈X are pairs e=(x,b)∈X×ParahoricCosetsWkr, where parahoric W (twoBlock k r) is the two-block parahoric subgroup of GLk(W).
  • Each edge carries origin e : X, adapted basis changes originBasisChange e : GL (Fin k) W and terminusBasisChange b : GL (Fin k) W, and a module transition transition e : GL H O.
  • The condition mk_terminusBasisChange_inv pins (terminusBasisChange b)⁻¹ to coset b, and eq_of_origin_eq encodes freeness of the group action — which immediately implies EdgeCoordinates.surjective_origin_originBasisChange (every origin–coset pair occurs as an edge).

For an edge pairing hb : T.IsEdgePairing b b' — weights b,b′:ExponentsNkn→O with b⋅b′=pNc0 (c0=T.multinomialExponentk=k2logp⁡q) such that ρ(g) and ρ(g⊤) are adjoint for (h,h′)↦h′⋅(bh) — the identity transpose_mul_diagonal_mul rewrites each edge's matrix:

(Dρ(γ))⊤diag(b)(Dρ(g⊤))=(ρ(g)D2ρ(γ))⊤diag(b).

Summing over edges proves IsEdgePairing.edgeHeckeOperator_regroup: under regroup J, the operator edgeHeckeOperator n J 𝓔 applied to b-weighted vectors factors as

M⊆Mall⊆Medge→AddN⊆M∘,

namely pairingMap 𝓔.transition b (edgeRestriction_dual) * edgeRestriction_origin, where edgeRestriction restricts vertex forms to edges in the adapted basis scaled by D, and pairingMap u b Q' (Add) pairs edge values with dual-edge restrictions using transition on OH and b on forms.

4. Edge conditions, Stepanov's count, averaging, and Pieri cone volume (exists_isEdgeCondition) ​

Under the standing size hypothesis T.IsLargeDegree k n r θ:

0<r≤k/2,0<θ≤1,n4≤q,(Nklog⁡qθ)5P3r≤n,

set the congruence precision c=congruencePrecisionk=5Nc0 and defect threshold c∗=defectThresholdkc=3kc. Theorem New.FrobeniusCycle.exists_isEdgeCondition constructs a triple (C,S,Av) satisfying IsEdgeCondition by assembling three upstream modules:

  1. Stepanov's count and extreme defect terms (RootLemma.lean): New.stepanov_count proves that if a nonzero polynomial Φ∈R[X] vanishes to order E at the image of every residue class of W under ι:W→R, then E⋅|ResidueFieldW|≤deg⁡Φ. Applying this along SL2(W) embedded in two rows/columns of GLk(W) yields defect_nonpos_of_extreme_term: any term of minimal w-adic order plus Gauss weight across all SL2(W)-translates has non-positive defect along the root.
  2. The averaging map (AveragingMap.lean): exists_average_mem_defectConditions_and_dvd_sub defines C=T.defectConditionsnar(wc)(3c∗) (forms whose Levi translates have all coefficients of defect >3c∗ divisible by wc). Using Levi-invariant linear forms on generic matrix polynomials applied one copy per letter, it constructs Av whose columns lie in C (average_mem), while against every h′∈T.allEdgesFormsknr (forms in the halfway lattices of all edges from a vertex),wc|h′⋅(b⋅Avh)−pNc0h′⋅(b⋅h)(pow_dvd_pairing_average). Meanwhile allEdgesForms_le_defectConditions guarantees T.allEdgesFormsknr≤C.
  3. Pieri cone volume and residue-field dimension (DefectCount.lean): Set S to be the defect-condition subspace over ResidueField O (zero ideal, threshold 3c∗). Dividing out wc−1 (mem_translatesIn_of_pow_smul_mem) shows that whenever wc−1h∈C, the reduction of h modulo the maximal ideal lies in S (residue_mem). Packing Frobenius powers (powerPacking) and mapping minimal-height Levi-translate exponents into the Pieri cone via full flags (exists_finrank_defectConditions_le_volume, using RootLemma.lean), index_mul_finrank_defectConditions_le (under mul_defectThreshold_le_mul_degree: 8Nkc∗P2r≤θn) proves the dimension bound:[GLk(W):Pr,k−r]⋅dimRes(O)⁡S≤(1+θ)⋅|ExponentsNkn|.

5. Near inverse, Smith normal form, Nakayama, and final colength bound ​

From exists_isEdgeCondition, the proof of New.FrobeniusCycle.elementary_divisors completes in five algebraic steps:

  1. Basis factorization at both ends (exists_basis_det_dvd, used twice): Because every origin–coset pair occurs among both the edges and the dual edges, exists_originFunctions_factorization_det_dvd and sum_finrank_deepForms_le factor both edgeRestriction maps as Qd and Q′d′ where RQ=1, R′Q′=1, the columns of Q,Q′ span originFunctions (lying in valuedIn _ allEdgesForms), anddetd|w|V|D,detd′|w|V|D,D=⌊cdiv|Exponents|⌋,where cdiv=T.divisorConstantknr=Nn(P−2r+r2/(kP)). Since w2=p, the two ends combine to det(d′⊤)det(d)∣p|V|D.
  2. Near inverse (pairingMap_mul_nearInverse_one, pow_dvd_mul_sub_smul_one): Define Inv=nearInverseuAvb′R′. Without Av (setting Av=1), b⋅b′=pNc0 and R′Q′=1 give Add⋅nearInverseu1b′R′=pNc0I. Inserting Av and summing the edgewise congruence pow_dvd_pairing_average yieldswc|(Add⋅Inv−p2Nc0I)i,j.Since c=5Nc0 and Nc0≥2, we have 2(2Nc0)+1≤c−1, so p2Nc0w∣wc−1.
  3. Smith normal form mod a direct summand + Nakayama (exists_elementary_divisors_mod_summand, card_add_card_le_mul_finrank, smul_top_le_of_le_sup_smul_top, exists_finset_card_le_smul_top_le_sup_span): Put Q (direct summand with left inverse R) and B=Inv together: exists_elementary_divisors_mod_summand uses Smith normal form over the valuation domain O on (B−QRB)R to write imQ+imB=imQ+span{tjU⋅j} with RU⋅j=0 whenever tj≠0. Split indices into J={j∣tj∣wc−1 and tj≠0} (the exceptional columns) and j∉J (where wc−1∣tj by totality of divisibility in a valuation domain).
    • For j∈J, wc−1U⋅j lies in valuedIn _ C, so every column of Q and every U⋅j (j∈J) reduces into S modulo the maximal ideal. Because these columns have dual rows (card_add_card_le_mul_finrank), |E|+|J|≤|H×Ed|⋅dim⁡S≤(1+θ)|E|, giving |J|≤θ|E|.
    • Setting s={Add(U⋅j)∣j∈J} and G=im(AddQ)+span(s), the near-inverse congruence implies p2Nc0OE⊆G+wc−1OE. Because p2Nc0w∣wc−1 and w∈mO, Nakayama's lemma (smul_top_le_of_le_sup_smul_top) cancels the wc−1OE tail:p2Nc0OE⊆im(AddQ)+span(s),|s|≤θ|V×Exponents|.
  4. Adding colengths along the product (colengthDvd_mul_mul_of_smul_top_le, exists_colengthDvd_range_pairingMap_mul_edgeRestriction): Rewriting Addfull⋅Res=d′⊤(Add⋅Q)d, colengthDvd_mul_mul_of_smul_top_le bounds the colength of its image plus pmOE bydet(d′⊤)⋅(p2Nc0)|E|⋅det(d)⋅(pm)|s||p|V|D+2Nc0|E|+m|s|.Under IsLargeDegree, Nc0≤cdiv (mul_multinomialExponent_le_divisorConstant), so the exponent is at most (cdiv+2cdiv+θm)|E|=(3cdiv+θm)|V×Exponents|.
  5. Pushing forward to M (elementary_divisors): Given any O-linear map f:(X→I→O)→M intertwining edgeHeckeOperator with Y∈EndO(M) (Y∘f=f∘A), pushing the colength bound forward along π=f∘regroupJ (using edgeHeckeOperator_regroup and ColengthDvd.map) shows that Y preserves L=im(f) and ColengthDvd L (Y L + p^m L) (p^l) for some l≤(3cdiv+θm)|X||I|.
Level 3 · Formal Lean Contract

Level 3 — Formal Lean Contract ​

The extracted Stage 03 skeletons embedded below correspond to src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean (54 declarations, 0 stub truncations) and src/New/UpperBound/Divisibility/LocalDivisibility.lean (15 declarations, 0 stub truncations) at pinned upstream commit 41c2716658c42ba08eb0648994a2efe83082a95c (41c2716658c4).

Headline Theorem Contracts ​

  1. New.Data.exists_colengthDvd_gaugeLe_compositeLift (src/New/UpperBound/Divisibility/LocalDivisibility.lean:409-481, 03_upper_bound/local_divisibility):
    • Hypotheses: Parameters P, admissible data D:DataP, prime p ([Fact p.Prime]), and a p-adic embedding ιp:C↪Cp ([PadicPlace p]).
    • Conclusion: Produces l∈N and an embValRing-submodule S of D.SourceForm (over the characteristic-zero, non-noetherian, non-discrete valuation domain embValRing) such that:
      • l≤D.allowedLossp⋅finrankC(D.SourceForm),
      • ColengthDvd D.integralSourceForms S (p ^ l) (determinant-divisibility replacing finite-module length), and
      • for every twist ϑ with gcd(p,ϑ.normQ)=1, every chain datum Ψ (IsChainDatum ϑ Ψ), and every φ∈S∩D.ramifiedSourceForms, GaugeLe 1 (p ^ (D.allowedLoss p - D.gain p)) (compositeLift ϑ Ψ φ).
  2. New.FrobeniusCycle.elementary_divisors (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:1167-1215, 03_upper_bound/elementary_divisor_theorem):
    • Hypotheses: A local ring W with finite residue field of size q=PN; a characteristic-zero valuation domain O ([CommRing O] [IsDomain O] [ValuationRing O] [CharZero O]) in which p=T.p is not a unit (hp) and has square root w=T.sqrtPrime∈O; a Frobenius cycle T:FrobeniusCycleNWO; h_large : T.IsLargeDegree k n r θ; EdgeCoordinates W O k r X H; an equivalence J:I≃ExponentsNkn×H; and an O-linear map f:(X→I→O)→OM intertwining Y:EndO(M) with T.edgeHeckeOperator n J 𝓔 (Y ∘ₗ f = f ∘ₗ T.edgeHeckeOperator n J 𝓔).
    • Conclusion: For every m∈N, IsOntoUpToColength (T.p : O) f.range m Y ((3 * T.divisorConstant k n r + θ * m) * (Nat.card X * Nat.card I)) — i.e., Y keeps L=f.range and ColengthDvd L (Y L + p^m L) (p^l) for some l≤(3cdiv+θm)|X||I|.

Verification status (audit/verification-status.json): Local Lean compilation and kernel replay remain build_status: unverified-locally at pinned upstream commit 41c2716658c42ba08eb0648994a2efe83082a95c (41c2716658c4). Static token scanning currently has scan_scope: entry, covering only Challenge.lean, src/Main.lean, and src/Statements.lean (0 forbidden tokens in solution files, 5 expected sorry tokens in Challenge.lean). Both extracted skeletons (elementary_divisor_theorem.lean with 54 declarations and local_divisibility.lean with 15 declarations) have 0 stub truncations; neither upstream Stage 03 file has been locally compiled, kernel-checked, or statically scanned here.

lemma New.exists_elementary_divisors_mod_summand — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L63-L102)

lean
/-- Let `O` be a valuation domain, let the matrix `Q` have the left inverse `R`, so that its image
is a direct summand of `O ^ K`, and let `A` be a matrix of the same shape as `Q`. There are an
invertible matrix `U` and scalars `t j` such that the images of `Q` and `A` span the same module as
the image of `Q` and the vectors `t j • U.col j`, and `R` kills the columns of `U` with
`t j ≠ 0`. -/
lemma New.exists_elementary_divisors_mod_summand {O E : Type*} [CommRing O] [IsDomain O]
    [ValuationRing O] [Fintype E] [DecidableEq E] {K : Type*} [Fintype K] [DecidableEq K]
    {Q : Matrix K E O} {R : Matrix E K O} (hR : R * Q = 1) (A : Matrix K E O) :
    ∃ (U : GL K O) (t : K → O),
      (∀ j : K, t j ≠ 0 → R *ᵥ U.val.col j = 0) ∧
      Q.mulVecLin.range ⊔ A.mulVecLin.range =
        Q.mulVecLin.range ⊔ span O (Set.range fun j : K ↦ t j • U.val.col j) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:63-102 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=29 body_sha256=a98b096e3a65717940d0ee72ebfeb07c239b3e189adf59d787491850ecbc795d]

def New.valuedIn — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L109-L111)

lean
/-- The functions on `X × I` whose values `i ↦ φ (x, i)` lie in `C` for every `x`. -/
def New.valuedIn (C : Submodule O (I → O)) : Submodule O (X × I → O) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:109-111 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=8ec5c0bc351454c5dea48101c7066f6b80dca2807275ca25a55a8350cdee8a92]

lemma New.mem_valuedIn — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L113-L114)

lean
lemma New.mem_valuedIn {C : Submodule O (I → O)} {φ : X × I → O} :
    φ ∈ valuedIn X C ↔ ∀ x : X, (fun i : I ↦ φ (x, i)) ∈ C := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:113-114 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=bda15dce6923c025940fb7efc74ee74a6c19bbbd7d7cffb17c4117e4bf797b2f]

lemma New.card_add_card_le_mul_finrank — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L118-L143)

lean
/-- Let `Q` have the left inverse `R`, and let `R` kill the columns `j ∈ J` of an invertible matrix
`U`. If the columns of `Q` and these columns of `U` have all their values in `S` modulo the maximal
ideal, then `#E + #J ≤ #X * dim S`, because they are independent modulo the maximal ideal. -/
lemma New.card_add_card_le_mul_finrank [Fintype X] [Fintype I] [DecidableEq X] [DecidableEq I]
    {Q : Matrix (X × I) E O} {R : Matrix E (X × I) O} {U : GL (X × I) O} {J : Finset (X × I)}
    {S : Submodule (ResidueField O) (I → ResidueField O)} (hR : R * Q = 1)
    (h_ker : ∀ j ∈ J, R *ᵥ U.val.col j = 0)
    (hQ : ∀ (j : E) (x : X), (fun i : I ↦ residue O (Q (x, i) j)) ∈ S)
    (hU : ∀ j ∈ J, ∀ x : X, (fun i : I ↦ residue O (U.val (x, i) j)) ∈ S) :
    Fintype.card E + #J ≤ Fintype.card X * finrank (ResidueField O) S := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:118-143 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=17 body_sha256=cda1863d0a043826370f2de74dac45a1767512d8d76d9c8a98179cb43ee81fa4]

lemma New.smul_top_le_of_le_sup_smul_top — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L146-L158)

lean
/-- If `u` is a multiple of `a * w` with `w` in the maximal ideal and `a • O ^ E` lies in
`G + u • O ^ E`, then `a • O ^ E` lies in `G`, by Nakayama's lemma. -/
lemma New.smul_top_le_of_le_sup_smul_top {a u w : O} {G : Submodule O (E → O)}
    (hw : w ∈ maximalIdeal O) (hu : a * w ∣ u)
    (h_le : a • (⊤ : Submodule O (E → O)) ≤ G ⊔ u • ⊤) :
    a • (⊤ : Submodule O (E → O)) ≤ G := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:146-158 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=8 body_sha256=51a453aae8ec4c84cc690ff77bbbb5634c075bc35d795ee37fdbd69e64dd1f5d]

lemma New.exists_finset_card_le_smul_top_le_sup_span — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L160-L231)

lean
/-- Let `O` be a valuation domain. Let the matrix `Q` have the left inverse `R`, so that its columns
are a basis of a direct summand of `O ^ (X × I)`, and let `B` be a near inverse of `A`: `A * B ≡ a`
modulo `u`, where `u` is a multiple of `a` times a non-unit `w`. Let every vector `φ` in the images
of `Q` and `B` have all its values `φ (x, ·)` in `C`, and let `h` reduce into `S` modulo the maximal
ideal whenever `u • h ∈ C`. Then `a • O ^ E` lies in the span of the image of `A * Q` and of at most
`#X * dim S - #E` further vectors. -/
lemma New.exists_finset_card_le_smul_top_le_sup_span [Fintype X] [Fintype I] [DecidableEq X]
    [DecidableEq I] {Q B : Matrix (X × I) E O} {R A : Matrix E (X × I) O}
    {a u w : O} {C : Submodule O (I → O)} {S : Submodule (ResidueField O) (I → ResidueField O)}
    (hR : R * Q = 1) (hw : w ∈ maximalIdeal O) (hu : a * w ∣ u)
    (h_near : ∀ i j : E, u ∣ (A * B - a • (1 : Matrix E E O)) i j)
    (hQ : Q.mulVecLin.range ≤ valuedIn X C) (hB : B.mulVecLin.range ≤ valuedIn X C)
    (hS : ∀ h : I → O, u • h ∈ C → (fun i : I ↦ residue O (h i)) ∈ S) :
    ∃ s : Finset (E → O),
      Fintype.card E + #s ≤ Fintype.card X * finrank (ResidueField O) S ∧
      a • (⊤ : Submodule O (E → O)) ≤ (A * Q).mulVecLin.range ⊔ span O (s : Set (E → O)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:160-231 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=57 body_sha256=e6b02f403a2f1f6326d8723c03b5cce0dfd391c427955d6892ba4e937e84cef2]

lemma New.colengthDvd_mul_mul_of_smul_top_le — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L233-L253)

lean
/-- The colengths add along a product. If `a • O ^ E` lies in the span of the image of `A` and of a
finite set `s`, then the colength of the image of `d' * A * d` plus `z • O ^ E` in `O ^ E` divides
`det d' * a ^ #E * det d * z ^ #s`. -/
lemma New.colengthDvd_mul_mul_of_smul_top_le (d' A d : Matrix E E O) {a : O} {s : Finset (E → O)}
    (h_le : a • (⊤ : Submodule O (E → O)) ≤ A.mulVecLin.range ⊔ span O (s : Set (E → O))) (z : O) :
    ColengthDvd ⊤ ((d' * A * d).mulVecLin.range ⊔ z • ⊤)
      (d'.det * (a ^ Fintype.card E * (d.det * z ^ #s))) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:233-253 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=15 body_sha256=c35428bb9d1f58a6542c3c201f4702676680caa46749758f99bd7f284a533bfa]

def New.regroup — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L263-L265)

lean
/-- A vector indexed by `(H × X) × L`, read as a function `X → I → O` through `I ≃ L × H`. -/
def New.regroup (J : I ≃ L × H) : ((H × X) × L → O) →ₗ[O] X → I → O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:263-265 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=4c8eb37b21d7fc2f1d0ab355cf3a434904c8df823c90cf9cffbbca02f813c595]

lemma New.regroup_apply — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L267-L268)

lean
lemma New.regroup_apply (J : I ≃ L × H) (F : (H × X) × L → O) (x : X) (i : I) :
    regroup J F x i = F (((J i).2, x), (J i).1) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:267-268 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=5a633da644c1afc6f5222be040e6a19d687c01104c0263cce32773e07376dfa8]

lemma New.regroup_surjective — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L270-L272)

lean
lemma New.regroup_surjective (J : I ≃ L × H) :
    Surjective (regroup J : ((H × X) × L → O) → X → I → O) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:270-272 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=3eb51f6b882f3ac90a4c23377a45d4d720a3c6d5b5ea065f6470ad312caa2bd2]

def New.edgewise — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L274-L277)

lean
/-- The map on functions of edges with values in `O ^ H ⊗ O ^ L` that acts on the value at the edge
`e` by `u e ⊗ A`. -/
def New.edgewise (u : Ed → Matrix H H O) (A : Matrix L L O) :
    Matrix ((H × Ed) × L) ((H × Ed) × L) O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:274-277 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=01ad1179da9b79482305e626de4666f52bcc6bb513b84b4dab2ce143a1ad506f]

lemma New.edgewise_mul — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L281-L283)

lean
lemma New.edgewise_mul (u u' : Ed → Matrix H H O) (A A' : Matrix L L O) :
    edgewise u A * edgewise u' A' = edgewise (fun e : Ed ↦ u e * u' e) (A * A') := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:281-283 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=2 body_sha256=440e5e9bf2df6a7269e2efa7219b1088a77fe6d9c6b74b63eb882a9c11cf510d]

lemma New.edgewise_mulVec — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L285-L293)

lean
/-- The value of `edgewise u A *ᵥ ψ` at `x = (h', e)` is `A` applied to the combination of the
values `ψ ((h, e), ·)` with the coefficients `u e h' h`. -/
lemma New.edgewise_mulVec (u : Ed → Matrix H H O) (A : Matrix L L O) (ψ : (H × Ed) × L → O)
    (x : H × Ed) :
    (fun l : L ↦ (edgewise u A *ᵥ ψ) (x, l)) =
      A *ᵥ ∑ h : H, u x.2 x.1 h • fun l : L ↦ ψ ((h, x.2), l) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:285-293 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=f185c040e5a7f2c921f52f9aa3a67754be73016b07fce1d26a5927189cfa8dd9]

def New.pairingMap — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L297-L302)

lean
/-- The map `Add` that sends a function on edges to its pairings with the columns of `Q'`, which
are functions on the dual edges. At the edge `e` the pairing is by `u e` on the factor `O ^ H` and
by `(h, h') ↦ h' ⬝ᵥ (b * h)` on the factor `O ^ L`. -/
def New.pairingMap (u : Ed → GL H O) (b : L → O) (Q' : Matrix ((H × Ed) × L) E O) :
    Matrix E ((H × Ed) × L) O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:297-302 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=b4ba2519b60c2913bc7a4aad8483c0fcaf543b7b6f2747b52adf3dfa11a8b4e5]

def New.nearInverse — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L304-L309)

lean
/-- The map `Inv` in the direction opposite to `New.pairingMap`. It applies `R'ᵀ`, and then at the
edge `e` it applies `(u e)⁻¹` on the factor `O ^ H` and multiplication by `b'` followed by `Av` on
the factor `O ^ L`. -/
def New.nearInverse (u : Ed → GL H O) (Av : Matrix L L O) (b' : L → O)
    (R' : Matrix E ((H × Ed) × L) O) : Matrix ((H × Ed) × L) E O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:304-309 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=4c10c9f4aeee87d1fc15688a70c2042c3be9567bfa3301f3e0ae7c0a04faeecc]

lemma New.pairingMap_mul_nearInverse_apply — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L311-L338)

lean
/-- Let `Ed` be the set of edges, so that a vector indexed by `(H × Ed) × L` is a function on edges
with values in `O ^ H ⊗ O ^ L`, and let `E` index the columns of `Q'` and the rows of `R'`. The
entry `(i, j)` of `Add * Inv`, for `Add = pairingMap u b Q'` and `Inv = nearInverse u Av b' R'`, is
a sum over `x ∈ H × Ed`: the vector `Av` of `b'` times the part at `x` of row `j` of `R'` is paired,
with the weights `b`, with the part at `x` of column `i` of `Q'`. -/
lemma New.pairingMap_mul_nearInverse_apply (u : Ed → GL H O) (Av : Matrix L L O) (b b' : L → O)
    (Q' : Matrix ((H × Ed) × L) E O) (R' : Matrix E ((H × Ed) × L) O) (i j : E) :
    (pairingMap u b Q' * nearInverse u Av b' R') i j =
      ∑ x : H × Ed, (fun l : L ↦ Q' (x, l) i) ⬝ᵥ (b * Av *ᵥ (b' * fun l : L ↦ R' j (x, l))) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:311-338 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=20 body_sha256=f9cb4dd44ffb002c2ee845f75c93898fc4d0fbd652fb45ccdb44857d8ac86c94]

structure New.EdgeCoordinates — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L342-L368)

lean
/-- The edges of a Hecke operator in coordinates. The situation in mind is this: `p` is a
uniformizer of `W`, and a group `Γ` acts freely, with finitely many orbits, on pairs of a
`W`-lattice of rank `k` and a free `O`-module with a basis indexed by `H`. The points of `X` are
representatives of the orbits, each with a basis of its lattice and of its module, and
`e = (x, b)` is the edge `b` into `x`. The origin of `e` is `δ` times the representative
`origin e` for one `δ ∈ Γ`. In the chosen bases
`δ⁻¹ = originBasisChange e * diag(p⁻¹, …, p⁻¹, 1, …, 1) * terminusBasisChange b`, with `r` entries
`p⁻¹`. Only coordinates are recorded: `p`, `Γ` and `δ` are no part of the structure. -/
structure New.EdgeCoordinates (W O : Type) [CommRing W] [IsLocalRing W] [CommRing O] (k r : ℕ)
    (X H : Type*) [Fintype H] [DecidableEq H] where
  /-- The representative of the origin of an edge. -/
  origin : X × ParahoricCosets W k r → X
  /-- The matrix whose columns are a basis of the lattice of `origin e` adapted to `δ⁻¹ e`. -/
  originBasisChange : X × ParahoricCosets W k r → GL (Fin k) W
  /-- The change of basis at the terminus of an edge. -/
  terminusBasisChange : ParahoricCosets W k r → GL (Fin k) W
  /-- The matrix of `δ` from the module at `origin e` to the module at `x`. -/
  transition : X × ParahoricCosets W k r → GL H O
  /-- The inverse of `terminusBasisChange b` represents the coset `b`. -/
  mk_terminusBasisChange_inv : ∀ b : ParahoricCosets W k r,
    QuotientGroup.mk (terminusBasisChange b)⁻¹ = b
  /-- An edge is determined by its origin and the coset of its transposed change of basis there;
  this is where the action of `Γ` has to be free. -/
  eq_of_origin_eq : ∀ e e' : X × ParahoricCosets W k r, origin e = origin e' →
    transposeGL (originBasisChange e) * (transposeGL (originBasisChange e'))⁻¹ ∈ parahoric W
      (twoBlock k r) →
      e = e'

structure New.FrobeniusCycle.IsLargeDegree — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L385-L399)

lean
/-- The size conditions in the theorem on elementary divisors, for the rank `k`, the degree `n`,
the size `r` of the first block and the proportion `θ` of exceptional elementary divisors. -/
structure New.FrobeniusCycle.IsLargeDegree (k n r : ℕ) (θ : ℝ) : Prop where
  /-- The first block is not empty. -/
  block_pos : 0 < r
  /-- The first block is at most half of the rank. -/
  two_mul_block_le : 2 * r ≤ k
  /-- The proportion `θ` is positive. -/
  proportion_pos : 0 < θ
  /-- The proportion `θ` is at most `1`. -/
  proportion_le_one : θ ≤ 1
  /-- The residue field is large against the degree. -/
  degree_pow_le : n ^ 4 ≤ T.q
  /-- The degree is large against `N k log q / θ` and `P ^ r`. -/
  le_degree : (N * k * Real.log T.q / θ) ^ 5 * T.P ^ (3 * r) ≤ n

lemma New.FrobeniusCycle.card_isEven_add_self — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L401-L405)

lean
/-- Half of the letters are even. -/
lemma New.FrobeniusCycle.card_isEven_add_self : #{s : ZMod N | T.isEven s} + #{s : ZMod N | T.isEven s} = N := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:401-405 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=046e8dbab198f1f013da54e15835cb86bb63a9e260a3360c846edb084cb8fdd5]

lemma New.FrobeniusCycle.two_le_card_letters — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L408-L410)

lean
/-- The number of letters is positive and even, hence at least `2`. -/
lemma New.FrobeniusCycle.two_le_card_letters : 2 ≤ N := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:408-410 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=2403d1326cf60de174eba9f4ade8ba30a297ae4de71be468a52ce0232ee36e0e]

def New.FrobeniusCycle.congruencePrecision — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L412-L414)

lean
/-- The precision `c = 5 N c₀`, with `c₀ = T.multinomialExponent k`, of the congruences modulo
`w ^ c` that are imposed on the value of a function at an edge. -/
def New.FrobeniusCycle.congruencePrecision (k : ℕ) : ℕ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:412-414 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=91f57fce343f973e93d83c24730bdc9788a20461f6b8fc5ce91cfc3c010c5913]

lemma New.FrobeniusCycle.two_le_mul_multinomialExponent — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L416-L423)

lean
/-- For rank `k ≥ 2` one has `N c₀ ≥ 2`, where `N` is the number of letters and
`c₀ = T.multinomialExponent k = k ^ 2 * (frobExp * N)` with `P = p ^ frobExp`. -/
lemma New.FrobeniusCycle.two_le_mul_multinomialExponent (hk : 2 ≤ k) : 2 ≤ N * T.multinomialExponent k := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:416-423 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=6 body_sha256=aed9dcef54b25c28f5c276106a3ff401e0dd424103006d88988fb6224cb1fb60]

lemma New.FrobeniusCycle.multinomialExponent_le_mul_log — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L426-L439)

lean
/-- Let `T` be a Frobenius cycle with `N` letters and prime `p = T.p`, and let
`q = T.q = p ^ (T.frobExp * N)` be the size of the residue field of `W`. Then the number
`c₀ = T.multinomialExponent k = k ^ 2 log_p q` is at most `3 / 2 * k ^ 2 * log q`, because
`log p ≥ log 2 ≥ 2 / 3`. -/
lemma New.FrobeniusCycle.multinomialExponent_le_mul_log (k : ℕ) :
    (T.multinomialExponent k : ℝ) ≤ 3 / 2 * k ^ 2 * Real.log T.q := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:426-439 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=e8454f262bee48cf70302ebf1ae2933c7f2494c76499d3fbe8c8b703efa090dc]

lemma New.FrobeniusCycle.congruencePrecision_le_mul_log — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L442-L445)

lean
lemma New.FrobeniusCycle.congruencePrecision_le_mul_log (k : ℕ) :
    (T.congruencePrecision k : ℝ) ≤ 15 / 2 * k ^ 2 * N * Real.log T.q := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:442-445 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=8153d59021c8a099cf5fef2bb9c59fa5cd8ab410568f6503a70288c5d812f772]

lemma New.FrobeniusCycle.IsLargeDegree.two_le_rank — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L452-L455)

lean
/-- Large degree (`New.FrobeniusCycle.IsLargeDegree`) forces the rank `k ≥ 2 r` to be at least
`2`. -/
lemma New.FrobeniusCycle.IsLargeDegree.two_le_rank (h_large : T.IsLargeDegree k n r θ) : 2 ≤ k := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:452-455 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=2 body_sha256=6c2f39d4dc8c3372b97b4d6b73be2a06dfcbc2c4971ea537228a402c8b798504]

lemma New.FrobeniusCycle.IsLargeDegree.four_le_mul — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L457-L458)

lean
lemma New.FrobeniusCycle.IsLargeDegree.four_le_mul (h_large : T.IsLargeDegree k n r θ) : 4 ≤ N * k := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:457-458 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=ec181c51231c6675b27b7984057057daf9229202ad81ae1c556f50c4354dfc6b]

lemma New.FrobeniusCycle.IsLargeDegree.mul_log_le_div — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L461-L465)

lean
/-- Dividing `N k log q` by the proportion `θ ∈ (0, 1]` of exceptional elementary divisors does not
make it smaller; here `q = P ^ N` is the size of the residue field. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_log_le_div (h_large : T.IsLargeDegree k n r θ) :
    N * k * Real.log T.q ≤ N * k * Real.log T.q / θ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:461-465 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=ba4acc3d7ee7e85bcc4916ac0d30bb21eaf8ace9157928ca21ebf4b52327542b]

lemma New.FrobeniusCycle.IsLargeDegree.mul_pow_le_degree — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L467-L482)

lean
/-- Let `T` be a Frobenius cycle: a prime `p`, a power `P = T.P` of `p` and `N` ring maps `W → O`
(the letters), each the `P`-th power of the one before modulo `p`, where the residue field of `W`
has `q = P ^ N` elements. Let the degree `n` be large: `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n`. Then `(N k) ^ 5 ≤ n`, because `log q ≥ 1`. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_pow_le_degree (h_large : T.IsLargeDegree k n r θ) : (N * k) ^ 5 ≤ n := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:467-482 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=12 body_sha256=d65e4db365916199aede41eae08a9abce5ed1c2818cc45d5930354e07b27549e]

lemma New.FrobeniusCycle.IsLargeDegree.twenty_seven_le_log_q — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L484-L493)

lean
/-- Under the size conditions `h_large`, `27 ≤ log T.q`: from `T.q ≥ n ^ 4` and
`n ≥ (N k) ^ 5 ≥ 4 ^ 5` follows `log T.q ≥ 40 log 2 ≥ 27`. -/
lemma New.FrobeniusCycle.IsLargeDegree.twenty_seven_le_log_q (h_large : T.IsLargeDegree k n r θ) : 27 ≤ Real.log T.q := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:484-493 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=8 body_sha256=cfdbba292248d9fd1de4780e3b08d0814d332d0d7870cbef99716eaca01bc5a2]

lemma New.FrobeniusCycle.IsLargeDegree.mul_degree_add_lt_P_pow — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L495-L518)

lean
/-- Let `T` be a Frobenius cycle: a prime `p`, a power `P = T.P` of `p` and `N` ring maps `W → O`
(the letters), each the `P`-th power of the one before modulo `p`, where the residue field of `W`
has `q = P ^ N` elements. Let the degree `n` be large: `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n`. For `2 ℓ = N` one has `N k (ℓ + 2) n + n + k < P ^ ℓ`, because
`P ^ ℓ = √q ≥ n ^ 2` and `n ≥ (N k) ^ 2 + 2`. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_degree_add_lt_P_pow (h_large : T.IsLargeDegree k n r θ) {ℓ : ℕ} (hℓ : ℓ + ℓ = N) :
    N * k * (ℓ + 2) * n + n + k < T.P ^ ℓ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:495-518 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=18 body_sha256=27afeeddef207ca06788b9a491c0793637a8b0ff876d2a7fc711c0fc66d873e8]

lemma New.FrobeniusCycle.IsLargeDegree.one_lt_degree — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L520-L522)

lean
/-- A large degree `n` is greater than `1`, because `n ≥ (N k) ^ 5`. -/
lemma New.FrobeniusCycle.IsLargeDegree.one_lt_degree (h_large : T.IsLargeDegree k n r θ) : 1 < n := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:520-522 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=9e2dea1fb128737e51863ce8f374f1a0fe1656d0c38de2d327b6ecd6cbc112ac]

lemma New.FrobeniusCycle.IsLargeDegree.degree_lt_q — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L524-L526)

lean
/-- A large degree `n` is less than the size `q` of the residue field, because `n ^ 4 ≤ q`. -/
lemma New.FrobeniusCycle.IsLargeDegree.degree_lt_q (h_large : T.IsLargeDegree k n r θ) : n < T.q := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:524-526 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=bca0c28ff0ef474e3d29fa67efe1355a257729a67f247926ef620b99c3f94c44]

lemma New.FrobeniusCycle.IsLargeDegree.mul_log_pow_mul_le — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L529-L537)

lean
/-- Under the size conditions `h_large`, `(N k log T.q) ^ 5 T.P ^ (3 r) ≤ θ n`: clear the
denominator in the degree condition `(N k log T.q / θ) ^ 5 T.P ^ (3 r) ≤ n` and use `θ ^ 5 ≤ θ`. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_log_pow_mul_le (h_large : T.IsLargeDegree k n r θ) :
    (N * k * Real.log T.q) ^ 5 * T.P ^ (3 * r) ≤ θ * n := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:529-537 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=6 body_sha256=a091f24378031b5e4d825a356f68d33cb7e50962a8965dc72a22b93c1f9e9c6c]

lemma New.FrobeniusCycle.IsLargeDegree.multinomialExponent_mul_le_degree — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L539-L559)

lean
/-- Let `T` be a Frobenius cycle with `N` letters and the prime power `P = T.P`, and let
`q = P ^ N`. Let the degree `n` be large: `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n`. Then `c₀ P ^ (2 r) ≤ n`, where
`c₀ = T.multinomialExponent k = k ^ 2 log_p q` for the prime `p = T.p` of which `P` is a power. -/
lemma New.FrobeniusCycle.IsLargeDegree.multinomialExponent_mul_le_degree (h_large : T.IsLargeDegree k n r θ) :
    (T.multinomialExponent k : ℝ) * T.P ^ (2 * r) ≤ n := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:539-559 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=16 body_sha256=a898782fca03ccba82569af5261e2204c94f087bcab83deba6694b4073637a15]

lemma New.FrobeniusCycle.IsLargeDegree.mul_multinomialExponent_le_divisorConstant — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L561-L575)

lean
/-- Let `T` be a Frobenius cycle with `N` letters and the prime power `P = T.P`, and let
`q = P ^ N`. Let the degree `n` be large: `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n`. Then `N c₀ ≤ c_div`, where
`c₀ = T.multinomialExponent k = k ^ 2 log_p q` with `p = T.p`, and `c_div = T.divisorConstant k n
r = N n (1 / P ^ (2 r) + r ^ 2 / (k P))`. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_multinomialExponent_le_divisorConstant (h_large : T.IsLargeDegree k n r θ) :
    (N * T.multinomialExponent k : ℝ) ≤ T.divisorConstant k n r := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:561-575 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=ed6e36f0924334dc7724ee87482c84c72329688db2ed336df2b82f1c79624b82]

lemma New.FrobeniusCycle.IsLargeDegree.mul_defectThreshold_le_mul_degree — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L577-L610)

lean
/-- Let `T` be a Frobenius cycle with `N` letters and the prime power `P = T.P`, and let
`q = P ^ N`. Let the degree `n` be large: `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n`. Then `8 N k c* P ^ (2 r) ≤ θ n`, where
`c* = defectThreshold k c = 3 k c` for the precision
`c = T.congruencePrecision k = 5 N k ^ 2 log_p q`, `p = T.p`. -/
lemma New.FrobeniusCycle.IsLargeDegree.mul_defectThreshold_le_mul_degree (h_large : T.IsLargeDegree k n r θ) :
    8 * N * k * defectThreshold k (T.congruencePrecision k) * T.P ^ (2 * r) ≤ θ * n := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:577-610 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=28 body_sha256=3813424b2816731d142f7e212f1ec988564ef083c9a4b0156af6f542fbc5ab2e]

structure New.FrobeniusCycle.IsEdgeCondition — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L618-L643)

lean
/-- Conditions modulo `w ^ c` on the value of a function at an edge. Vectors are coefficients in the
normalized monomials, and `(h, h') ↦ h' ⬝ᵥ (b * h)` is the pairing with the dual edge. The module
`C` consists of the values that satisfy the conditions, `Av` is the averaging map, and `S` contains
the reductions of the vectors `h` with `w ^ (c - 1) • h ∈ C`. -/
structure New.FrobeniusCycle.IsEdgeCondition {N k n : ℕ} {W O : Type} [NeZero N] [CommRing W] [IsLocalRing W]
    [CommRing O] [IsDomain O] [ValuationRing O] (T : FrobeniusCycle N W O) (r c : ℕ) (θ : ℝ)
    (b : Exponents N k n → O)
    (C : Submodule O (Exponents N k n → O))
    (S : Submodule (ResidueField O) (Exponents N k n → ResidueField O))
    (Av : Matrix (Exponents N k n) (Exponents N k n) O) : Prop where
  /-- The conditions hold for the forms in the halfway lattices of all edges from the origin. -/
  allEdgesForms_le : T.allEdgesForms k n r ≤ C
  /-- The values of `Av` satisfy the conditions. -/
  average_mem : ∀ h : Exponents N k n → O, Av *ᵥ h ∈ C
  /-- Against the forms in the halfway lattices of all edges from the origin of the dual edge, `Av`
  is multiplication by `p ^ (N c₀)` modulo `w ^ c`, with `c₀ = T.multinomialExponent k`. -/
  pow_dvd_pairing_average : ∀ h : Exponents N k n → O, ∀ h' ∈ T.allEdgesForms k n r,
    T.sqrtPrime ^ c ∣ h' ⬝ᵥ (b * Av *ᵥ h) - (T.p : O) ^ (N * T.multinomialExponent k) * h' ⬝ᵥ
      (b * h)
  /-- If `w ^ (c - 1) • h` satisfies the conditions, then `h` reduces into `S`. -/
  residue_mem : ∀ h : Exponents N k n → O,
    T.sqrtPrime ^ (c - 1) • h ∈ C → (fun β : Exponents N k n ↦ residue O (h β)) ∈ S
  /-- The number of edges into a lattice times `dim S` is at most `1 + θ` times the number of
  monomials. -/
  index_mul_finrank_le : ((parahoric W (twoBlock k r)).index * finrank (ResidueField O) S : ℝ) ≤
    (1 + θ) * Fintype.card (Exponents N k n)

lemma New.FrobeniusCycle.mem_translatesIn_of_pow_smul_mem — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L646-L658)

lean
/-- The module `T.translatesIn n τ J B` consists of the vectors whose translates by the Levi
subgroup of `τ` have their coefficients at `B` in the ideal `J`. Let `0 < c`. If
`T.sqrtPrime ^ (c - 1) • h` lies in this module for the ideal `(T.sqrtPrime ^ c)`, then `h` lies in
it for every ideal `J` that contains `T.sqrtPrime`. -/
lemma New.FrobeniusCycle.mem_translatesIn_of_pow_smul_mem {τ : Fin k → ℕ} {B : Set (Exponents N k n)} {c : ℕ}
    (hc : 0 < c) {J : Ideal O} (hw : T.sqrtPrime ∈ J) {h : Exponents N k n → O}
    (h_mem : T.sqrtPrime ^ (c - 1) • h ∈ T.translatesIn n τ (span {T.sqrtPrime ^ c}) B) :
    h ∈ T.translatesIn n τ J B := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:646-658 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=6 body_sha256=2e6be3b77c4b40defc06babc71c9a5d5f710ee0dc991b6d1ab51335e0ef63ab6]

lemma New.FrobeniusCycle.sqrtPrime_mem_maximalIdeal — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L661-L665)

lean
/-- If the prime `T.p` is not a unit of the local ring `O`, then its square root `T.sqrtPrime` (with
`T.sqrtPrime ^ 2 = T.p`) lies in the maximal ideal `maximalIdeal O`. -/
lemma New.FrobeniusCycle.sqrtPrime_mem_maximalIdeal [IsLocalRing O] (hp : ¬IsUnit (T.p : O)) :
    T.sqrtPrime ∈ maximalIdeal O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:661-665 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=8d26296b303e99c640f9346ddee41a3bb5f59c253d86a3ac1a903fb17cf91113]

lemma New.FrobeniusCycle.charP_residueField — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L668-L673)

lean
/-- If `p` is not a unit of `O`, then the residue field of `O` has characteristic `p`, the prime of
the reduced Frobenius cycle. -/
lemma New.FrobeniusCycle.charP_residueField [IsLocalRing O] (hp : ¬IsUnit (T.p : O)) :
    CharP (ResidueField O) (T.map (residue O)).p := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:668-673 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=7ff731e3cf52f44b69442ef6c94639b48cb52be6b6dd7c112c877f5bfd446e03]

theorem New.FrobeniusCycle.exists_isEdgeCondition — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L675-L727)

lean
/-- Let `W` be a local ring, `O` a valuation domain of characteristic zero and `T` a Frobenius cycle
with `N` letters (ring maps `W → O`). Its prime `p = T.p = w ^ 2`, `w = T.sqrtPrime`, is not a unit
of `O`, and the residue field of `W` has `q = P ^ N` elements for the power `P = T.P` of `p`. Forms
have `k` variables and degree `n` in each letter and are given by their coefficients, and
`g ∈ GL_k(W)` acts on them by the matrix `ρ(g) = T.letterRep n g`. Let `0 < r ≤ k / 2`, `0 < θ ≤ 1`,
`n ^ 4 ≤ q` and `(N k log q / θ) ^ 5 P ^ (3 r) ≤ n` (`h_large`). Let `b` be weights such that `ρ(g)`
and `ρ(gᵀ)` are adjoint for `(h, h') ↦ h' ⬝ᵥ (b * h)`, with `b * b' = p ^ (N c₀)` for
`c₀ = T.multinomialExponent k` (`hb`). Put `c = T.congruencePrecision k = 5 N c₀`, and let
`M = T.allEdgesForms k n r` be the module of forms that lie in the halfway lattices of all edges
from a lattice. Then there are
* a module `C` of forms that contains `M`,
* a matrix `Av` with values in `C` that, paired against `M`, is multiplication by `p ^ (N c₀)`
  modulo `w ^ c`,
* a space `S` over the residue field of `O` that contains the reductions of the `h` with
  `w ^ (c - 1) • h ∈ C`, such that `dim S` times the index in `GL_k(W)` of the parahoric subgroup
  with blocks `r` and `k - r` is at most `1 + θ` times the number of monomials. -/
theorem New.FrobeniusCycle.exists_isEdgeCondition (hp : ¬IsUnit (T.p : O)) {r : ℕ} {θ : ℝ}
    (h_large : T.IsLargeDegree k n r θ) {b b' : Exponents N k n → O} (hb : T.IsEdgePairing b b') :
    ∃ (C : Submodule O (Exponents N k n → O))
      (S : Submodule (ResidueField O) (Exponents N k n → ResidueField O))
      (Av : Matrix (Exponents N k n) (Exponents N k n) O),
      T.IsEdgeCondition r (T.congruencePrecision k) θ b C S Av := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:675-727 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=32 body_sha256=e2268c44419e785bd0bf1841e4a046555fa142c5f2d4821df3f2c0506ce1084c]

abbrev New.FrobeniusCycle.depthPower — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L738-L740)

lean
/-- The diagonal matrix that multiplies the coefficient of a monomial by `p ^ depth`. -/
abbrev New.FrobeniusCycle.depthPower (k n r : ℕ) : Matrix (Exponents N k n) (Exponents N k n) O := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:738-740 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=d2660be2c62eab49b77caa314d7a0b8bb3eab63067efbdd368543fcf3767ade6]

def New.FrobeniusCycle.edgeHeckeOperator — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L742-L754)

lean
/-- The edge Hecke operator on functions `F : X → O ^ I`, in coordinates. Here `J` identifies `I`
with (exponents) × `H`, and the values of `F` are coefficients in the basis `(n! ^ N / β!) z ^ β`,
in which the substitution `h ↦ h ∘ g` has the matrix `ρ(g)ᵀ`, `ρ = T.letterRep n`. The value at `x`
is the sum over the edges `e = (x, b)` into `x` of the matrix `(ρ(originBasisChange e) p ^ depth
ρ(terminusBasisChange b))ᵀ ⊗ transition e` applied to `F (origin e)`. In terms of forms this is
`p ^ (N n / 2)` times the sum of the values at the origins of the edges, each carried to `x` by the
element `δ` of its edge. -/
def New.FrobeniusCycle.edgeHeckeOperator (n : ℕ) (J : I ≃ Exponents N k n × H) (𝓔 : EdgeCoordinates W O k r X H) :
    End O (X → I → O) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:742-754 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=9510076b0657735aee0c8c8fd8c146c783d24e3d961ca78fdf01c40b37bbf9b5]

lemma New.FrobeniusCycle.edgeHeckeOperator_apply — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L756-L767)

lean
/-- The edge Hecke operator entry by entry: at `x`, `i` it is the sum over `b`, `j` of
`𝓔.transition (x, b)` at `(J i).2`, `(J j).2`, times the `((J j).1, (J i).1)` entry of the matrix
product, times `F (𝓔.origin (x, b)) j`. -/
lemma New.FrobeniusCycle.edgeHeckeOperator_apply (n : ℕ) (J : I ≃ Exponents N k n × H)
    (𝓔 : EdgeCoordinates W O k r X H) (F : X → I → O) :
    T.edgeHeckeOperator n J 𝓔 F = fun (x : X) (i : I) ↦ ∑ b : ParahoricCosets W k r, ∑ j : I,
      𝓔.transition (x, b) (J i).2 (J j).2 *
        (T.letterRep n (𝓔.originBasisChange (x, b)) * T.depthPower k n r *
          T.letterRep n (𝓔.terminusBasisChange b)) (J j).1 (J i).1 * F (𝓔.origin (x, b)) j := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:756-767 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=45fa81dfa3c227bf94cafd652fba0fbb68cb70267bb369b4a0592c150d092900]

lemma New.FrobeniusCycle.IsEdgePairing.transpose_mul_diagonal_mul — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L771-L794)

lean
/-- Let `T` be a Frobenius cycle with `N` letters (ring maps `W → O`) and prime `p = w ^ 2`,
`w = T.sqrtPrime`. Let `ρ = T.letterRep n` be the representation of `GL_k(W)` on the forms with `k`
variables and degree `n` in each letter, and let `ρ(g)` and `ρ(gᵀ)` be adjoint for the pairing with
weights `b` (`hb`). Let `D = T.depthScaling k n r` be diagonal with entries `w ^ depth β`, where
`depth β` is the degree of the monomial `β` in the deep variables: those after the first `r` in an
even letter, and the first `r` in an odd letter. So `D ^ 2 = T.depthPower k n r` has entries
`p ^ depth β`. Then `(D ρ(γ))ᵀ diag(b) D ρ(gᵀ) = (ρ(g) D ^ 2 ρ(γ))ᵀ diag(b)`. -/
lemma New.FrobeniusCycle.IsEdgePairing.transpose_mul_diagonal_mul {b b' : Exponents N k n → O}
    (hb : T.IsEdgePairing b b') (g γ : GL (Fin k) W) :
    (T.depthScaling k n r * T.letterRep n γ)ᵀ * diagonal b *
        (T.depthScaling k n r * T.letterRep n (transposeGL g)) =
      (T.letterRep n g * T.depthPower k n r * T.letterRep n γ)ᵀ * diagonal b := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:771-794 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=13 body_sha256=0bb0afb8c566dac7363c45a884c66d16132aacb55aa0803f3927c4a79e004a0f]

lemma New.FrobeniusCycle.IsEdgePairing.edgeHeckeOperator_regroup — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L797-L865)

lean
/-- Let `T` be a Frobenius cycle with `N` letters, and let forms have `k` variables and degree `n`
in each letter. The points of `X` represent lattices of rank `k`, each with a free `O`-module with
basis indexed by `H`. An edge is a pair `e = (x, q)` of its terminus `x ∈ X` and a coset `q` of the
parahoric subgroup of `GL_k(W)` with blocks `r` and `k - r`. The coordinates `𝓔` give the origin of
`e`, bases adapted to `e` at both ends, and the matrix `𝓔.transition e` on `O ^ H`. The bijection
`J` splits the index set `I` into exponents and `H`, and `regroup J` reads a vector indexed by
`(H × X) × exponents` as a function `X → I → O`. The operator sums, over the edges into `x`, the
values at their origins carried to `x`. Let `b` be the weights of a pairing of forms for which `g`
and `gᵀ` act adjointly (`hb`). On vectors multiplied by `b` the operator is the restriction to
edges, which gives an edge the value at its origin in the adapted basis (`T.edgeRestriction`),
followed by the pairing with the functions restricted to the dual edges from their origins, which
are dual to the termini of the edges. -/
lemma New.FrobeniusCycle.IsEdgePairing.edgeHeckeOperator_regroup [Fintype X] [DecidableEq X]
    [DecidableEq (ParahoricCosets W k r)] {b b' : Exponents N k n → O} (hb : T.IsEdgePairing b b')
    (J : I ≃ Exponents N k n × H) (𝓔 : EdgeCoordinates W O k r X H)
    (F : (H × X) × Exponents N k n → O) :
    T.edgeHeckeOperator n J 𝓔 (regroup J fun y : (H × X) × Exponents N k n ↦ b y.2 * F y) =
      regroup J
        ((pairingMap 𝓔.transition b (T.edgeRestriction n r (Prod.map id Prod.fst)
            (𝓔.terminusBasisChange ∘ Prod.snd ∘ Prod.snd)) *
          T.edgeRestriction n r (Prod.map id 𝓔.origin)
            fun e : H × X × ParahoricCosets W k r ↦
              transposeGL (𝓔.originBasisChange e.2)) *ᵥ F) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:797-865 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=47 body_sha256=e65ed34eae701e0a375cab20a5ebb4e81a3872de666a4a5a5bc032f1a08016f9]

lemma New.FrobeniusCycle.divisorConstant_nonneg — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L872-L875)

lean
/-- The constant `T.divisorConstant k n r = N n (1 / P ^ (2 r) + r ^ 2 / (k P))` is nonnegative. -/
lemma New.FrobeniusCycle.divisorConstant_nonneg (k n r : ℕ) : 0 ≤ T.divisorConstant k n r := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:872-875 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=7e9c20b65bb799bbcfee136fceec71fe82fc274239066ac23b1ebf05ebd19c62]

lemma New.FrobeniusCycle.IsLargeDegree.exists_basis_det_dvd — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L878-L916)

lean
/-- Let `T` be a Frobenius cycle with `N` letters (ring maps `W → O`) whose prime `p = w ^ 2`,
`w = T.sqrtPrime`, is not a unit of `O`. Forms have `k` variables and degree `n` in each letter, and
their monomials are indexed by `Exponents N k n`. Let `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `n ^ 4 ≤ q` and
`(N k log q / θ) ^ 5 P ^ (3 r) ≤ n` for `P = T.P` and `q = P ^ N` (`h_large`). The edge `e ∈ E` has
the origin `src e ∈ X` and the basis change `g e`, and every edge from every origin occurs: each
pair of a point of `X` and a coset of the parahoric subgroup of `GL_k(W)` with blocks `r` and
`k - r` is `(src e, (g e)⁻¹)` for some `e`. The functions on edges that depend only on the origin
(`T.originFunctions`) are the image of a matrix `Q` with a left inverse, so its columns are a basis,
and the inclusion `T.edgeRestriction` of the integral functions on origins is `Q * d`, where `det d`
divides `w ^ l` and `l` is at most `c_div = T.divisorConstant k n r` times the rank. -/
lemma New.FrobeniusCycle.IsLargeDegree.exists_basis_det_dvd {r : ℕ} {θ : ℝ} (h_large : T.IsLargeDegree k n r θ)
    (hp : ¬IsUnit (T.p : O)) {X E : Type*} [Fintype X] [DecidableEq X] [Fintype E] [DecidableEq E]
    {src : E → X} {g : E → GL (Fin k) W}
    (h_surj : Surjective fun e : E ↦ ((src e, ↑(g e)⁻¹) : X × ParahoricCosets W k r)) :
    ∃ (Q : Matrix (E × Exponents N k n) (X × Exponents N k n) O)
      (R : Matrix (X × Exponents N k n) (E × Exponents N k n) O)
      (d : Matrix (X × Exponents N k n) (X × Exponents N k n) O),
      Q.mulVecLin.range = T.originFunctions n r src g ∧
      R * Q = 1 ∧
      Q * d = T.edgeRestriction n r src g ∧
      d.det ∣ T.sqrtPrime ^ (Fintype.card X * ⌊T.divisorConstant k n r * Fintype.card
        (Exponents N k n)⌋₊) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:878-916 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=18 body_sha256=9161fd9b320dc27605ac121372c7cdbc10b49c2d08d65232e718f016d0d77c13]

lemma New.FrobeniusCycle.IsEdgePairing.pairingMap_mul_nearInverse_one — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L920-L944)

lean
/-- The sums over the edges nearly fill the target of `Add = pairingMap u b Q'`. Let `T` be a
Frobenius cycle with `N` letters and prime `p`, and `c₀ = T.multinomialExponent k`. Forms are given
by their coefficients, indexed by `Exponents N k n`, and the weights `b` pair forms, with
`b * b' = p ^ (N c₀)` (`hb`). Let `Ed` be the set of edges and `u e` an invertible matrix on `O ^ H`
for each edge `e`. The columns of `Q'`, indexed by `ι`, are functions from `H × Ed` to forms, and
`R'` is a left inverse of `Q'`. The map `nearInverse u 1 b' R'` applies `R'ᵀ` and then, at each
edge, `(u e)⁻¹` on `O ^ H` and multiplication by `b'` on forms. It is a right inverse of `Add` up to
the factor `p ^ (N c₀)`. -/
lemma New.FrobeniusCycle.IsEdgePairing.pairingMap_mul_nearInverse_one {H Ed ι : Type*} [Fintype H] [DecidableEq H]
    [Fintype Ed] [DecidableEq Ed] [DecidableEq ι] {b b' : Exponents N k n → O}
    (hb : T.IsEdgePairing b b') (u : Ed → GL H O) {Q' : Matrix ((H × Ed) × Exponents N k n) ι O}
    {R' : Matrix ι ((H × Ed) × Exponents N k n) O} (hR' : R' * Q' = 1) :
    pairingMap u b Q' * nearInverse u 1 b' R' =
      (T.p : O) ^ (N * T.multinomialExponent k) • (1 : Matrix ι ι O) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:920-944 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=12 body_sha256=e787256321c12190d39eda9c76da527808285634be45bfef57583a66464837ba]

lemma New.FrobeniusCycle.IsEdgeCondition.pow_dvd_mul_sub_smul_one — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L946-L988)

lean
/-- A near inverse. Let `T` be a Frobenius cycle with `N` letters and prime `p = w ^ 2`, `k` the
rank, `n` the degree and `c₀ = T.multinomialExponent k`. The weights `b` pair forms, with
`b * b' = p ^ (N c₀)` (`hb`). Let `M = T.allEdgesForms k n r` be the module of forms that lie in the
halfway lattices of all edges from a lattice, where `r` is the size of the first block of the
parahoric subgroup. Let `C, S, Av` be conditions on an edge of precision `c` (`hC`). Only one of
their properties is used, which involves neither `C`, `S` nor `θ`: the matrix `Av`, paired against
`M`, is multiplication by `p ^ (N c₀)` modulo `w ^ c`. Let `Ed` be the set of edges and `u e` an
invertible matrix on `O ^ H` for each edge `e`. Let the columns of `Q'`, indexed by `ι`, be
functions from `H × Ed` to forms with all values in `M` (`hQ'`), and let `R'` be a left inverse of
`Q'`.
The map `Add = pairingMap u b Q'` sends a function on edges to its pairings with these columns, by
`u e` on `O ^ H` and by `b` on forms. The map `Inv = nearInverse u Av b' R'` applies `R'ᵀ` and then,
at each edge, `(u e)⁻¹` on `O ^ H` and multiplication by `b'` followed by `Av` on forms. Then
`Add * Inv ≡ p ^ (2 N c₀)` modulo `w ^ c`, entry by entry. -/
lemma New.FrobeniusCycle.IsEdgeCondition.pow_dvd_mul_sub_smul_one {N k n : ℕ} {W O : Type} [NeZero N] [CommRing W]
    [IsLocalRing W] [CommRing O] [IsDomain O] [ValuationRing O] {T : FrobeniusCycle N W O}
    {H Ed ι : Type*} [Fintype H] [DecidableEq H]
    [Fintype Ed] [DecidableEq Ed] [Fintype ι] [DecidableEq ι] {r c : ℕ} {θ : ℝ}
    {b b' : Exponents N k n → O} {C : Submodule O (Exponents N k n → O)}
    {S : Submodule (ResidueField O) (Exponents N k n → ResidueField O)}
    {Av : Matrix (Exponents N k n) (Exponents N k n) O} (hC : T.IsEdgeCondition r c θ b C S Av)
    (hb : T.IsEdgePairing b b') (u : Ed → GL H O) {Q' : Matrix ((H × Ed) × Exponents N k n) ι O}
    {R' : Matrix ι ((H × Ed) × Exponents N k n) O} (hR' : R' * Q' = 1)
    (hQ' : Q'.mulVecLin.range ≤ valuedIn (H × Ed) (T.allEdgesForms k n r)) (i j : ι) :
    T.sqrtPrime ^ c ∣ (pairingMap u b Q' * nearInverse u Av b' R' -
      (T.p : O) ^ (2 * (N * T.multinomialExponent k)) • (1 : Matrix ι ι O)) i j := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:946-988 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=18 body_sha256=7fc24206598f3c0f13837dbccde9f548a0db952412f2e904ea9eb56653c43558]

lemma New.FrobeniusCycle.IsEdgeCondition.exists_finset_smul_top_le_range_sup_span — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L992-L1065)

lean
/-- Few further generators for the image of a pairing matrix. Let `O` be a valuation domain of
characteristic zero and `T` a Frobenius cycle with `N` letters for `W` and `O`, whose prime
`p = w ^ 2`, `w = T.sqrtPrime`, is not a unit of `O`. Let `k ≥ 2` be the rank, `n` the degree and
`c₀ = T.multinomialExponent k`. A form is given by its coefficients, which are indexed by
`New.Exponents N k n`. The data are the following.
* The weights `b` pair forms by `(h, h') ↦ h' ⬝ᵥ (b * h)`, and `b * b' = p ^ (N c₀)` (`hb`).
* The module `C` of forms describes conditions modulo `w ^ c`, `c = 5 N c₀`, on the value of a
  function at an edge, and the averaging map `Av` has values in `C`. The space `S` over the residue
  field contains the reductions of the `h` with `w ^ (c - 1) • h ∈ C`, and `θ` bounds its dimension
  (`hC`, see `New.FrobeniusCycle.IsEdgeCondition`).
* A vector indexed by `(H × Ed) × exponents` is a function from `H × Ed` to forms, where `Ed` is
  the set of edges and `H` indexes a basis of the coefficient module. The columns of `Q` and `Q'`
  are such functions, indexed by `V × exponents` for a finite set `V` (the origins of the edges).
  Both matrices have left inverses, and their images have values in `T.allEdgesForms k n r`, the
  forms in the halfway lattices of all edges from a lattice.
* The number `|H × Ed|` is `|V|` times the index of the parahoric subgroup with blocks `r` and
  `k - r`.

The matrix `pairingMap u b Q' * Q` pairs the columns of `Q` with those of `Q'`, by `u e` on `O ^ H`
at the edge `e` and by `b` on forms. Then `p ^ (2 N c₀) O ^ (V × exponents)` lies in the span of its
image and of at most `θ |V × exponents|` further vectors. -/
lemma New.FrobeniusCycle.IsEdgeCondition.exists_finset_smul_top_le_range_sup_span {N k n : ℕ} {W O : Type} [NeZero N]
    [CommRing W] [IsLocalRing W] [CommRing O] [IsDomain O] [ValuationRing O]
    {T : FrobeniusCycle N W O} (hp : ¬IsUnit (T.p : O)) {r : ℕ} {θ : ℝ}
    (hk : 2 ≤ k) {b b' : Exponents N k n → O} {C : Submodule O (Exponents N k n → O)}
    {S : Submodule (ResidueField O) (Exponents N k n → ResidueField O)}
    {Av : Matrix (Exponents N k n) (Exponents N k n) O}
    (hC : T.IsEdgeCondition r (T.congruencePrecision k) θ b C S Av) (hb : T.IsEdgePairing b b')
    {V H Ed : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype Ed]
    [DecidableEq Ed] (u : Ed → GL H O)
    {Q Q' : Matrix ((H × Ed) × Exponents N k n) (V × Exponents N k n) O}
    {R R' : Matrix (V × Exponents N k n) ((H × Ed) × Exponents N k n) O}
    (hR : R * Q = 1) (hR' : R' * Q' = 1)
    (hQ : Q.mulVecLin.range ≤ valuedIn (H × Ed) (T.allEdgesForms k n r))
    (hQ' : Q'.mulVecLin.range ≤ valuedIn (H × Ed) (T.allEdgesForms k n r))
    (h_card : Fintype.card (H × Ed) = Fintype.card V * (parahoric W (twoBlock k r)).index) :
    ∃ s : Finset (V × Exponents N k n → O),
      (#s : ℝ) ≤ θ * (Fintype.card V * Fintype.card (Exponents N k n)) ∧
      (T.p : O) ^ (2 * (N * T.multinomialExponent k)) •
          (⊤ : Submodule O (V × Exponents N k n → O)) ≤
        (pairingMap u b Q' * Q).mulVecLin.range ⊔ span O (s : Set (V × Exponents N k n → O)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:992-1065 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=34 body_sha256=9601966e76da517ca7268da1dfe406fe005c69e604da2f191882680284af221b]

lemma New.FrobeniusCycle.exists_colengthDvd_range_pairingMap_mul_edgeRestriction — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L1067-L1142)

lean
/-- The elementary divisors of the operator factored through the functions on edges. Let `T` be a
Frobenius cycle with `N` letters whose prime `p = T.p` is not a unit of `O`. Forms have `k`
variables and degree `n` in each letter, and their monomials are indexed by `Exponents N k n`. Let
the degree be large for the size `r` of the first block and the proportion `θ ∈ (0, 1]` of
exceptional elementary divisors. Let `Ed` be a finite set of edges, let `H` index a basis of the
free module `O ^ H` of coefficients, and let `V` be a finite set of origins. A pair `e ∈ H × Ed` has
the origin `src e ∈ V` with basis change `g e`, and for the dual edge the origin `src' e ∈ V` with
basis change `g' e`. On both sides every pair of a point of `V` and a coset of the parahoric
subgroup of `GL_k(W)` with blocks `r` and `k - r` occurs, and there are no more pairs than that. The
weights `b` pair forms, with `b * b' = p ^ (N c₀)` for `c₀ = T.multinomialExponent k` (`hb`), and
`u` assigns to each edge an invertible matrix on `O ^ H`. Let `A` be the restriction to edges,
followed by the pairing with the functions restricted to the dual edges. Then the image of `A` plus
`p ^ m O ^ (V × exponents)` has colength dividing `p ^ l` (`New.ColengthDvd`) with `l` at most
`3 c_div + θ m` times `|V × exponents|`, where `c_div = T.divisorConstant k n r`. -/
lemma New.FrobeniusCycle.exists_colengthDvd_range_pairingMap_mul_edgeRestriction {N k n : ℕ} {W O : Type} [NeZero N]
    [CommRing W] [IsLocalRing W] [CommRing O] [IsDomain O] [ValuationRing O] [CharZero O]
    (T : FrobeniusCycle N W O) (hp : ¬IsUnit (T.p : O)) {r : ℕ} {θ : ℝ}
    (h_large : T.IsLargeDegree k n r θ) {b b' : Exponents N k n → O} (hb : T.IsEdgePairing b b')
    {V H Ed : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype Ed]
    [DecidableEq Ed] {src src' : H × Ed → V} {g g' : H × Ed → GL (Fin k) W} (u : Ed → GL H O)
    (h_origin : Surjective fun e : H × Ed ↦ ((src e, ↑(g e)⁻¹) : V × ParahoricCosets W k r))
    (h_dual : Surjective fun e : H × Ed ↦ ((src' e, ↑(g' e)⁻¹) : V × ParahoricCosets W k r))
    (h_card : Fintype.card (H × Ed) = Fintype.card V * (parahoric W (twoBlock k r)).index) (m : ℕ) :
    ∃ l : ℕ,
      l ≤ (3 * T.divisorConstant k n r + θ * m) *
        (Fintype.card V * Fintype.card (Exponents N k n)) ∧
      ColengthDvd ⊤
        ((pairingMap u b (T.edgeRestriction n r src' g') *
          T.edgeRestriction n r src g).mulVecLin.range ⊔ (T.p : O) ^ m • ⊤) ((T.p : O) ^ l) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:1067-1142 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=48 body_sha256=fe33f4021e46447e4ad1f50c8d0d3e5f09b930009220d38823c1221247c80c84]

lemma New.EdgeCoordinates.surjective_origin_originBasisChange — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L1146-L1157)

lean
/-- Every pair of a representative `x` and a coset of the parahoric subgroup is the origin and the
coset of the inverse transposed basis change of an edge of `𝓔`: this map is injective on a finite
set, hence onto. -/
lemma New.EdgeCoordinates.surjective_origin_originBasisChange {k : ℕ} {W O : Type}
    [CommRing W]
    [IsLocalRing W] [CommRing O] {r : ℕ} {X H : Type*} [Finite X] [Fintype H] [DecidableEq H]
    [Finite (ParahoricCosets W k r)] (𝓔 : EdgeCoordinates W O k r X H) :
    Surjective fun e : X × ParahoricCosets W k r ↦
      ((𝓔.origin e, ↑(transposeGL (𝓔.originBasisChange e))⁻¹) : X × ParahoricCosets W k r) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:1146-1157 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=cd312cc7f86a9d955d9815735140bb3733542f2e4c49220be90e17491ae44847]

theorem New.FrobeniusCycle.elementary_divisors — Upstream source (src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean L1159-L1215)

lean
/-- The theorem on elementary divisors. Let `O` be a valuation domain of characteristic zero and `T`
a Frobenius cycle with `N` letters, prime `p = T.p` and power `P = T.P` of `p`, so that the residue
field of `W` has `q = T.q = P ^ N` elements. Let `k` be the rank and `n` the degree in each letter,
and let `J` split the index set `I` into exponents and `H`. Let `p` be a non-unit of `O`, and let
`Y ∘ f = f ∘ A` for the edge Hecke operator `A` of the edges `𝓔` between the representatives `X`.
Let `0 < r ≤ k / 2`, `0 < θ ≤ 1`, `q ≥ n ^ 4` and `n ≥ (N k log q / θ) ^ 5 P ^ (3 r)`. Then `Y`
keeps the image `L` of `f`, and for every `m` the colength of `Y L + p ^ m L` in `L` divides `p ^ l`
for some `l ≤ (3 c_div + θ m) |X| |I|`, with `c_div = T.divisorConstant k n r`. -/
theorem New.FrobeniusCycle.elementary_divisors {N k n : ℕ} {W O : Type} [NeZero N] [CommRing W] [IsLocalRing W]
    [CommRing O] [IsDomain O] [ValuationRing O] [CharZero O] (T : FrobeniusCycle N W O)
    {X : Type*} [Fintype X] (hp : ¬IsUnit (T.p : O)) {r : ℕ} {θ : ℝ}
    (h_large : T.IsLargeDegree k n r θ) {H : Type*} {I M : Type} [Fintype H] [DecidableEq H]
    [Fintype (ParahoricCosets W k r)] [Fintype I] [AddCommGroup M] [Module O M]
    (J : I ≃ Exponents N k n × H) (𝓔 : EdgeCoordinates W O k r X H) (f : (X → I → O) →ₗ[O] M)
    {Y : End O M} (hY : Y ∘ₗ f = f ∘ₗ T.edgeHeckeOperator n J 𝓔) (m : ℕ) :
    IsOntoUpToColength (T.p : O) f.range m Y
      ((3 * T.divisorConstant k n r + θ * m) * (Nat.card X * Nat.card I)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/ElementaryDivisors/ElementaryDivisorTheorem.lean:1159-1215 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=41 body_sha256=7a707d2bbb49198246422609a78905bec84efac3f7f0ac35fd0644611ab6a0a6]

lemma New.GaugeLe.rpow_mono — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L92-L97)

lean
/-- Gauge bounds can be weakened. If the `p`-adic gauge of every value `φ g` of a form, taken at
`g * d` for a fixed adelic point `d` (`New.GaugeLe`), is at most `p ^ r`, then it is at most
`p ^ r'` for every `r' ≥ r`. -/
lemma New.GaugeLe.rpow_mono {r r' : ℝ} {φ : AlgForm (E := E) n κ e} (hφ : GaugeLe d (p ^ r) φ) (hr : r ≤ r') :
    GaugeLe d (p ^ r') φ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:92-97 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=bbe92d799c2584c30f9cf6a03d89173e43cac681116dca12450166f047a90634]

lemma New.GaugeLe.add — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L99-L105)

lean
/-- The `p`-adic gauge is ultrametric. If, for a fixed adelic point `d` and every `g`, the gauges of
the values of two forms at `g`, taken at `g * d` (`New.GaugeLe`), are at most `c`, then the same
holds for the sum of the two forms. -/
lemma New.GaugeLe.add {c : ℝ} {φ ψ : AlgForm (E := E) n κ e} (hφ : GaugeLe d c φ) (hψ : GaugeLe d c ψ) :
    GaugeLe d c (φ + ψ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:99-105 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=c5ebb04cf30f94328c84dd3e70ab09f7e78668cfaf11c3cdbe4789ff3c34378b]

lemma New.GaugeLe.smul — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L107-L113)

lean
/-- Let `c` bound, for a fixed adelic point `d` and every `g`, the `p`-adic gauge of the value `φ g`
at `g * d` (`New.GaugeLe`). Then the values of `a • φ` are bounded in the same sense by `c` times
the `p`-adic absolute value of the complex number `a`. -/
lemma New.GaugeLe.smul {c : ℝ} {φ : AlgForm (E := E) n κ e} (hφ : GaugeLe d c φ) (a : ℂ) :
    GaugeLe d (‖ιₚ a‖ * c) (a • φ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:107-113 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=d9d7c4082802cc24c466ca8cfa8d97a81167e6b17d40dc8a7805affd0b3d7643]

lemma New.GaugeLe.zpow_neg_smul — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L115-L125)

lean
/-- Let `p ^ r` bound, for a fixed adelic point `d` and every `g`, the `p`-adic gauge of the value
`φ g` at `g * d` (`New.GaugeLe`), and let `β` be an integer with `β ≤ -r`. Then `p ^ (-β) • φ` has
these gauges at most `1`. -/
lemma New.GaugeLe.zpow_neg_smul {r : ℝ} {β : ℤ} {φ : AlgForm (E := E) n κ e} (hφ : GaugeLe d (p ^ r) φ)
    (hβ : β ≤ -r) : GaugeLe d 1 ((p : ℂ) ^ (-β) • φ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:115-125 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=7 body_sha256=b4c9640f205097407b437442337b1ee1e082d949057046b6844450da16c6e79b]

lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_of_mem_raises — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L140-L155)

lean
/-- Let `Ψ` be a weak chain datum for the twist `ϑ`: coefficients, subject to integrality and
invariance conditions, of tuples `x` of translations. The datum `translateDatum x j` of the `j`-th
theta lift is the normalised vacuum vector translated by `x j`. That it lies in
`raises 1 1 (p ^ r j)` says that this lift, with both gauges based at the identity, multiplies
`p`-adic gauges by at most `p ^ r j`. Suppose this holds for every `x` in the support of `Ψ`, that
`p ≠ D.N`, and that `p` is prime to `ϑ.normQ`, the product of the norms of the places in the set Q
of `ϑ`. Then `restrictedChain ϑ Ψ`, the combination with coefficients `Ψ` of chains of `D.m` lifts,
sends an integral source form to a form of gauge at most `p ^ ∑ j < D.m, r j`. -/
lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_of_mem_raises (hΨ : IsWeakChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ) (hN : p ≠ D.N) {r : ℕ → ℝ}
    (h_raises : ∀ x ∈ Ψ.support, ∀ j : ℕ,
      D.translateDatum x j ∈ (D.liftKernel ϑ j).raises 1 1 (p ^ r j))
    {v : D.SourceForm} (hv : v ∈ D.integralSourceForms) :
    GaugeLe 1 (p ^ ∑ j ∈ range D.m, r j) (restrictedChain ϑ Ψ v) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:140-155 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=f18375316e803fd1ca82948c0fd16be10bd6b3c79a3544d3c7ced311838e97db]

lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_one — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L157-L183)

lean
/-- Let `Ψ` be a weak chain datum for the twist `ϑ`: coefficients, subject to integrality and
invariance conditions, of tuples of translations. Let `p` be a prime prime to the norm of the level
of `ϑ` and different from the level `N` and from `d`, the prime parameter that defines the quadratic
character `χ_K`. Then `restrictedChain ϑ Ψ`, the combination with coefficients `Ψ` of chains of `m`
theta lifts, sends an integral source form `v` to an integral form: in `GaugeLe 1 1`, the first `1`
is the base point, the second the bound on the `p`-adic gauge. -/
lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_one (hΨ : IsWeakChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ) {v : D.SourceForm}
    (hv : v ∈ D.integralSourceForms) (hN : p ≠ D.N) (hd : p ≠ P.d) :
    GaugeLe 1 1 (restrictedChain ϑ Ψ v) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:157-183 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=18 body_sha256=e0ead41c21a7fd85ca06df9833eb4e115efd9c9d851bed344494923a575f5bb4]

lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_collisionSum — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L185-L218)

lean
/-- Let `Ψ` be a weak chain datum for the twist `ϑ`, and `p < x₁` a non-split prime
(`IsSmallNonsplit`) prime to the norm of the level of `ϑ`. For an integral source form `v`, the
image under the combination `restrictedChain ϑ Ψ` of chains of `m` theta lifts has valuation at
least `gain p - loss p - m * collisionSum p ∅`.

Here `gain p` is the divisibility asked of the chain at `p` and `loss p = f a (log b)² / p`, times
`m` if `p ≡ ±1` modulo `m`. -/
lemma New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_collisionSum (hΨ : IsWeakChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ)
    {v : D.SourceForm} (hv : v ∈ D.integralSourceForms) (hp_small : D.IsSmallNonsplit p) :
    GaugeLe 1 (p ^ (D.m * D.collisionSum p ∅ + D.loss p - D.gain p)) (restrictedChain ϑ Ψ v) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:185-218 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=24 body_sha256=454793e09609e6fe8aa859e9c14a87cc94578960aaef31deb3cf075835ed94cc]

lemma New.Data.IsWeakChainDatum.gaugeLe_pow_collisionExponent_smul — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L220-L244)

lean
/-- The crude bound. Let `Ψ` be a weak chain datum for the twist `ϑ`, and `p < x₁` a non-split prime
(`IsSmallNonsplit`) prime to the norm of the level of `ϑ`. For an integral source form `v` and
`j_p = D.collisionExponent p = ⌈2 m f a / p⌉`, the image of `p ^ j_p • v` under the combination
`restrictedChain ϑ Ψ` of chains of `m` theta lifts has valuation at least `gain p - loss p`. -/
lemma New.Data.IsWeakChainDatum.gaugeLe_pow_collisionExponent_smul (hΨ : IsWeakChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ) {v : D.SourceForm} (hv : v ∈ D.integralSourceForms)
    (hp_small : D.IsSmallNonsplit p) :
    GaugeLe 1 (p ^ (D.loss p - D.gain p))
      (restrictedChain ϑ Ψ ((p : ℂ) ^ D.collisionExponent p • v)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:220-244 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=17 body_sha256=c938f4ca5a42b19c080f71c97b4f14f0c941c298050c2447e33a28ad616885f8]

theorem New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_of_isFullMark — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L246-L285)

lean
/-- **Valuation.** Let `Ψ` be a weak chain datum for the twist `ϑ` (`New.Data.IsWeakChainDatum`) and
let `p` be prime to the norm of the level of `ϑ`. Let `Λ` be a full mark: a set of primes above `p`,
disjoint from its conjugate and induced by a-places, that contains the prime of each a-place or its
conjugate, where `p < x₁` is exceptional and non-split. Let `Y` be the product over `l ∈ Λ` of
`scaledHeckeOperator l`, the Hecke operator at `l` of index `D.ceilLogLifts p` scaled by
`p ^ heckeScalingExponent l`.

For an integral source form `v`, the image of `(Y ^ m) v` under the combination
`restrictedChain ϑ Ψ` of chains of `m` theta lifts has valuation at least `gain p - 2 * loss p`,
that is, `p`-adic gauge at most `p ^ (2 * loss p - gain p)`. Here `gain p` is the divisibility asked
of the chain and `loss p = f a (log b)² / p`, times `m` if `p ≡ ±1` modulo `m`. -/
theorem New.Data.IsWeakChainDatum.gaugeLe_restrictedChain_of_isFullMark (hΨ : IsWeakChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ)
    {v : D.SourceForm} (hv : v ∈ D.integralSourceForms) (hΛ : D.IsFullMark Λ) :
    GaugeLe 1 (p ^ (2 * D.loss p - D.gain p))
      (restrictedChain ϑ Ψ (((Λ.attach.toList.map hΛ.scaledHeckeOperator).prod ^ D.m) v)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:246-285 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=25 body_sha256=d33ad5e10127f66b54f435e423d0fa1cc9cf4b2ee0fe4ae4ab75f6eee4a1f0ab]

lemma New.Data.IsMarked.mul_sum_heckeScalingExponent_le_loss — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L289-L326)

lean
/-- Let `Λ` be a marked set of primes of `E` above the exceptional non-split prime `p < x₁`: it is
disjoint from its conjugate and each of its primes is induced by an a-place. Let
`A_l = heckeScalingExponent l`, which is `a` times the number of a-places that induce `l`,
`j_p = collisionExponent p = ⌈2 m f a / p⌉`, `m` the number of lifts and `f` the number of infinite
places of `E`. Then `m` times the sum over `l ∈ Λ` of `12 A_l / (m p) + j_p / (m ^ 2 f)`, the
colength exponent per dimension of the scaled Hecke operator at `l`, is at most `loss p`, which is
`f a (log b)² / p`, times `m` if `p ≡ ±1` modulo `m`. -/
lemma New.Data.IsMarked.mul_sum_heckeScalingExponent_le_loss (hΛ : D.IsMarked Λ) :
    D.m * ∑ l ∈ Λ, (12 * D.heckeScalingExponent l / (D.m * p) +
      1 / (D.m ^ 2 * D.f) * D.collisionExponent p : ℝ) ≤ D.loss p := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:289-326 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=29 body_sha256=5d93b5240d3d5112dc187867b33ebc742081e5ef76846436fc89ecacba62cf52]

theorem New.Data.IsMarked.isOntoUpToColength_prod_scaledHeckeOperator_pow — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L328-L357)

lean
/-- **Colength.** Let `Λ` be a marked set of primes above the exceptional non-split prime `p < x₁`,
`Y` the product over `l ∈ Λ` of the Hecke operators at `l` scaled by `p ^ heckeScalingExponent l`,
and `M` the module of integral source forms. Then `Y ^ m`, with `m` the number of lifts, keeps `M`,
and the index of `Y ^ m M + p ^ j_p M` in `M` divides `p ^ c` for some natural number
`c ≤ loss p * dim (source forms)`. -/
theorem New.Data.IsMarked.isOntoUpToColength_prod_scaledHeckeOperator_pow (hΛ : D.IsMarked Λ) :
    IsOntoUpToColength ↑p D.integralSourceForms (D.collisionExponent p)
      ((Λ.attach.toList.map hΛ.scaledHeckeOperator).prod ^ D.m)
        (D.loss p * finrank ℂ D.SourceForm) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:328-357 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=22 body_sha256=8fce46602760a2940e38dd18adb130422d870873e992fef4b4fdedc589871f5f]

lemma New.Data.mem_smallNonsplitPrimes_iff_isSmallNonsplit — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L360-L363)

lean
/-- A prime `p` lies in `D.smallNonsplitPrimes` if and only if `p < x₁` and `χ_K(p) ≠ 1`. -/
lemma New.Data.mem_smallNonsplitPrimes_iff_isSmallNonsplit :
    p ∈ D.smallNonsplitPrimes ↔ D.IsSmallNonsplit p := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:360-363 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=2 body_sha256=2075e1dd6710ad433c5aec0200a3a75756c4338fdf570df74b0af6265d4f622e]

lemma New.Data.chiK_eq_one_or_le_of_notMem_smallNonsplitPrimes — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L366-L371)

lean
/-- A prime `p` outside `D.smallNonsplitPrimes` splits in `K`, that is `χ_K(p) = 1`, or is at least
`x₁`. -/
lemma New.Data.chiK_eq_one_or_le_of_notMem_smallNonsplitPrimes (h_notMem : p ∉ D.smallNonsplitPrimes) :
    chiK P.d p = 1 ∨ D.x₁ ≤ p := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:366-371 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=2f737d10134edb3c5e8856a3d26b06e9d43f531a0f7274be1d3e623f5d3fca44]

lemma New.Data.IsChainDatum.gaugeLe_compositeLift_of_isFullMark — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L374-L400)

lean
/-- Let `Ψ` be a chain datum for the twist `ϑ`, with `p` prime to the norm of the level of `ϑ`. Let
`Λ` be a full mark: a set of primes above the exceptional non-split prime `p < x₁`, disjoint from
its conjugate and induced by a-places, that contains the prime of each a-place or its conjugate. Let
`Y` be the product over `l ∈ Λ` of the Hecke operators at `l` scaled by
`p ^ heckeScalingExponent l`, `M` the module of integral source forms over the ring `embValRing` of
complex numbers that are `p`-integral under `ιₚ`, and `j_p = collisionExponent p = ⌈2 m f a / p⌉`.

The composite lift passes a source form through `m` theta lifts with the glued tensor of `Ψ` as data
and restricts the result from `X_m` to `Y_m`. For a source form in `Y ^ m M + p ^ j_p M` it has
valuation at least `gain p - 2 * loss p`. -/
lemma New.Data.IsChainDatum.gaugeLe_compositeLift_of_isFullMark (hΨ : IsChainDatum ϑ Ψ)
    (hQ : p.Coprime ϑ.normQ) (hΛ : D.IsFullMark Λ) {φ : D.SourceForm}
    (hφ : φ ∈ D.integralSourceForms.map ((Λ.attach.toList.map hΛ.scaledHeckeOperator).prod ^ D.m) ⊔
      (p : embValRing) ^ D.collisionExponent p • D.integralSourceForms) :
    GaugeLe 1 (p ^ (2 * D.loss p - D.gain p)) (compositeLift ϑ Ψ φ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:374-400 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=13 body_sha256=7ff898bd40d3f4d83e2ccbc079784b26535a418ca5a4f98d39f89d13110d2530]

theorem New.Data.exists_colengthDvd_gaugeLe_compositeLift — Upstream source (src/New/UpperBound/Divisibility/LocalDivisibility.lean L404-L481)

lean
/-- The divisibility at one prime. There are a natural number `l ≤ allowedLoss p * dim`, where `dim`
is the dimension of the space of source forms, and a module `S` of source forms whose integral
members have index dividing `p ^ l` in the integral source forms (`New.ColengthDvd`), such that for
every twist `ϑ` of level prime to `p` and every chain datum `Ψ` (`New.Data.IsChainDatum`) the
composite lift of a ramified source form in `S` has valuation at least `gain p - allowedLoss p`. -/
theorem New.Data.exists_colengthDvd_gaugeLe_compositeLift {P : Parameters} {D : Data P} {p : ℕ}
    [hp : Fact p.Prime] [PadicPlace p] :
    ∃ (l : ℕ) (S : Submodule embValRing D.SourceForm),
      l ≤ D.allowedLoss p * finrank ℂ D.SourceForm ∧
      ColengthDvd D.integralSourceForms S (p ^ l) ∧
      ∀ (ϑ : D.Twist) (Ψ : D.Translations →₀ ℂ), IsChainDatum ϑ Ψ → p.Coprime ϑ.normQ →
        ∀ φ ∈ S, φ ∈ D.ramifiedSourceForms →
          GaugeLe 1 (p ^ (D.allowedLoss p - D.gain p)) (compositeLift ϑ Ψ φ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/UpperBound/Divisibility/LocalDivisibility.lean:404-481 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=66 body_sha256=37a6f65f8d17418fbe0e266aac2401fb58a33d1bc6d0b1a47c581e0341a45656]

Page Glossary ​

prime number
A whole number greater than 1 whose only positive whole-number divisors are 1 and itself; every integer above 1 factors uniquely into a product of them.
complex plane
The two-dimensional coordinate plane of numbers s = σ + it, where the horizontal coordinate σ = Re(s) sets decay rate and the vertical coordinate t = Im(s) sets oscillation frequency.
arithmetic height
A logarithmic measure combining ordinary archimedean size with prime-by-prime p-adic divisibility, locked together by the product formula so a nonzero algebraic quantity cannot be simultaneously small at every place.
Weyl gauge
The p-adic coordinate norm of an algebraic modular form measured in the g-twisted Weyl lattice, paired with Galois-conjugate archimedean bounds to define B-short spanning sets and ramified source forms.
theta correspondence
An integral transform built from a two-variable theta kernel that carries automorphic forms from one unitary group to another, iterated along a ladder of Hermitian spaces and packaged via admissible chain data.
quadratic twist
Multiplying a Dirichlet character χ modulo N by the Legendre symbol (·/d) of an odd prime d coprime to N, yielding a non-principal character modulo N·d whose L-function family admits zero-density control.
Hecke operator
An averaging operator that sums values of an automorphic form over neighboring sublattices—indexed by cosets of a parahoric subgroup—which Stage 03 scales by powers of a prime to eliminate collision losses in the composite theta lift.
elementary divisor
The invariant prime-power factors diagonalizing a linear map between integral lattices—generalized over the non-noetherian valuation domain embValRing via determinant-divisibility colength and bounded for edge Hecke operators through a modulo-$w^c$ near inverse.
Frobenius cycle
A cyclic ring of $N$ Frobenius-twisted embeddings $W \to O$ alternating between standard and contragredient actions of $\mathrm{GL}_k(W)$, whose Stepanov zero counts and Levi-invariant averaging yield low-dimension edge conditions modulo $w^c$.