Skip to content

First-Order Ribet Denominator Bounds and Existence of Regular Twist Families ​

This page explains the two culminating landmarks of Stage 07—and of the entire 8-pillar proof: src/New/Congruences/FirstOrder/DenominatorBound.lean (07_congruences/denominator_bound, 37 declarations, 0 stub truncations) — which constructs Taylor–Wiles prime triangles bypassing Vandiver's conjecture and assembles diagonal Ribet clearing operators — and src/New/Congruences/FitTwistsExist.lean (07_congruences/fit_twists_exist, 19 declarations, 1 let-type stub truncation documented verbatim below, while New.exists_isRegularFamily extracts completely untruncated) — which sums all prime-by-prime budgets inside D.denominatorBudget and closes the final black box of Stage 05 — Regular Twist Families and the Assembly of Theorem C. Return to the Stage 07 Overview, or revisit Crystalline Lifting, Kummer Charts, and Local Dual Defect and Galois Main Summands and the Anticyclotomic Selmer Twisting Theorem.

Level 1 · First-Principles

Level 1 — First-Principles ​

We now hold every local and global ingredient at a primeprime number ℓ: uniform crystalline dual defectcrystalline dual defect bounds from CrystallineDefect.lean, finitely many twist-independent Galois main summandsGalois main summand from RowsFromEigensystems.lean, and an m-fold twist τ from anticyclotomic Selmer twistinganticyclotomic Selmer twisting (TwistingTheorem.lean) whose powers ϑ=τj make all twisted Selmer groups and ramified partial Hecke L-value ratiosHecke L-value ratio bounded by twistError ℓ D.

Two decisive steps remain to prove New.exists_isRegularFamily:

  1. Convert those Selmer and local-defect bounds into an explicit linear operator Λ clearing the ℓ-adic denominators of orthogonal projection onto the theta-lift subspace Z (DenominatorBound.lean)—without ever falling into Vandiver's conjecture.
  2. Apply that operator to both the rank-r good lifts and the rank-1 main-pair lines, sum every prime's budget weighted by log⁡ℓ inside D.denominatorBudget, and assemble the full regular twist familyregular twist family θ (FitTwistsExist.lean).

Culminating assembly diagram of Stage 07 from upper-triangular auxiliary primes eliminating even cyclotomic classes through the trace-ideal polynomial family, diagonal denominator-clearing operator, and prime-weighted budget ledger into New.exists_isRegularFamily plugging into Stage 05 LongForms.lean

Part 1: Bypassing Vandiver's conjecture and clearing denominators (DenominatorBound.lean) ​

When Ribet's method analyzes congruences between the inverse-cyclotomic string ∑e=0t′−1χcyc−e and itself, cohomology classes appear in the Tate twists (O/ℓν)(−e) (0<e<t′) over the CM field E. Under complex conjugation, those classes split sharply:

  • Odd classes (shaOdd): Unconditionally bounded by Lib/Cyclotomic/OddSha.lean::exists_length_shaOdd_le (following Mazur–Wiles 1984 and Greither 1992), giving the integer odd class bound oddClassBound(D)≤24(Ncyc+t+3)27hE.
  • Even cyclotomic classes (evenClasses): Living over the totally real subfield E+, where bounding their orders unconditionally is equivalent to Vandiver's conjecture. Stage 07 never bounds the order of evenClasses.

Instead, exists_taylorWilesPlaces_hasRootChain builds an upper-triangular Taylor–Wiles prime triangleTaylor–Wiles prime triangle (IsPrimeTriangle) of auxiliary places Qj of norm qj≡1(modℓν), ordered monotonically by exponent 0<e(j)<t′:

  • Using a cyclotomic topological generator g1 separating powers ua−1∣ℓh (exists_cyclotomicChar_pow_sub_one_dvd, with h≤vℓ(D.chosenGroupOrder) and h=0 for ℓ>h22), the Kummer reciprocity map over E+ eliminates every even Tate-twist class algebraically in triangular order with total separation loss h222h, completely independent of the cardinality of evenClasses.
  • Simultaneously, Chebotarev density (exists_eventually_hasRootChain_mostFrobeniiAt) preserves weak-lift root chains ∏i<t′(X−qji)⋅ej(X) (ej integral, ej(1)=1) at every place Qj for every weak liftRibet clearing operator (IsWeakLift) congruent modulo ℓ to the target lift x0.

Feeding that prime triangle into the trace ideal produces a common Ribet element (exists_isCommonRibetElement_ellVal_le) whose leading coefficient d at x0 satisfies the lift valuation bound

vℓ(N2d)≤liftValuationBound(ℓ,O,ram,sel)=sel+2O.rankDiff⋅ram+(cardr)⋅localDefectBound(D,ℓ)+denominatorError(D,ℓ),

where localDefectBound(D,ℓ)=4f⋅defectBound(D,ℓ) and

denominatorError(D,ℓ)=tvℓ(oddClassBound(D))+(8ft+2+(4t+1)h222+h2)vℓ(N),N=D.chosenGroupOrder.

Now false-lift orthogonalityfalse-lift period closes the linear-algebra step (typeProjection_sub_starProjection_mem_of_isOrthogonalToFalseLifts): for any ιℓ-integral form y orthogonal to false lifts, y−prZy has zero component on every weak lift outside Z. Assembling the Hecke-diagonal clearing operators across all lift generators (IsLiftGenerator) spanning Z builds a Ribet clearing operator Λ0 on Z with all eigenvalue valuations ≤liftValuationBound (exists_operator_ellVal_le_liftValuationBound). Rescaling Λ=N⋅Λ0 (exists_operator_det_clearingBound) guarantees pairing integrality against forms integral at all places above ℓ—adding one +vℓ(N) term to form the exact clearing bound

clearingBound(D,ℓ)=localDefectBound(D,ℓ)+(1+2t)eℓ′+denominatorError(D,ℓ)+vℓ(N)

and proving New.Selmer.denominatorLe_clearingBound (DenominatorLe with exponent β=clearingBound(D,ℓ)log⁡ℓ).

Part 2: Prime-weighted budget ledger and New.exists_isRegularFamily (FitTwistsExist.lean) ​

FitTwistsExist.lean stitches all of Stage 07 together in three final steps:

  1. Join rank-r and rank-1 families (exists_isMainSummand_mainPair, range_goodLift_le_span_hasLiftHeckePolynomial, exists_mFoldTwist_selmerLengthLe_inv_ratio_le): Combining the finitely many rank-r main summands of D.goodForms (D.spaceW D.m) (from RowsFromEigensystems.lean) with the finitely many rank-1 main summands of main pairs (built from the trivial rank-1 representation via isRepOfType_one), exists_mFoldTwist_selmerLengthLe_inv_ratio_le chooses one m-fold twist τ controlling both families and all ramified L-value ratios simultaneously. Applying denominatorLe_clearingBound clears both range (D.goodLift ϑ j) (denominatorLe_range_goodLift) and every rank-1 main-pair line (denominatorLe_span_trivialLift), proving exists_mFoldTwist_hasDenominatorsLe at (ℓ,ι) with per-prime exponent clearingBound D ℓ * log ℓ + v_ℓ(|StdClasses_{U(1)}(D.chosenLevel)|) * log ℓ.
  2. Sum every error budget weighted by log⁡ℓ (sum_clearingBound_add_padicValNat_le): Over any finite set T of primes ℓ, every term in the prime-weighted sum is bounded explicitly:
    • Local crystalline defect (sum_localDefectBound_mul_log_le): ≤4⋅106e180f(m/k)blog⁡b;
    • Odd classes (isNegligible_padicValNat_oddClassBound): ≤D.x2000;
    • Twist error (isNegligible_twistError): ≤D.x999 (which simultaneously upgrades to ≤D.x1 for HasSmallRatios in global arithmetic heightarithmetic height);
    • Denominator error (isNegligible_denominatorError): ≤D.x4000;
    • U(1) class number (isNegligible_padicValNat_card_stdClasses): ≤D.x30. Because a=xb supplies an extra factor of x vastly exceeding m2e180 and all polynomial powers of x, sum_clearingBound_add_padicValNat_le proves
    ∑ℓ∈T(clearingBound(D,ℓ)+vℓ(|StdClassesU(1)(D.chosenLevel)|))log⁡ℓ≤D.denominatorBudget=falog3⁡bmk.
  3. Sealing all 8 pillars (New.exists_isRegularFamily): Selecting θ(κ):D.MFoldTwist independently for each κ : PrimePadicIso from exists_mFoldTwist_hasDenominatorsLe yields New.exists_isRegularFamily: ∃ θ : PrimePadicIso → D.MFoldTwist, D.IsRegularFamily θ. Plugging θ directly into Stage 05 — Regular Twist Families and the Assembly of Theorem C (05_determinant/long_forms, paired with Stage 06 — Single-Lift Height) discharges Theorem C (New.Data.integral_forms_long), which meets Theorems A and B in Stage 01 — The Main Cancellation Inequality (New.star_inequality) to establish New.grh and all five headline theorems of Stage 00 — The Five Entry Theorems.

Where this analogy breaks ​

Presenting FitTwistsExist.lean as "sum five budgets and call Classical.choose" compresses the real miracle of DenominatorBound.lean: why the clearing operator Λ does not depend on the unknown size of evenClasses or on the arbitrary number of auxiliary Taylor–Wiles primes |J|. In exists_taylorWilesPlaces_hasRootChain, the number of primes |J| and test points depends only on the finite module dimensions at a fixed ℓ, yet inside RibetElement.lean, the valuation bound h₂²² * h depends only on the cyclotomic separation h≤vℓ(N) and h2=r8, remaining uniformly polynomial in x across all primes ℓ.

Level 2 · Undergrad Bridge

Level 2 — Undergrad Bridge ​

1. Walkthrough of all 37 declarations in DenominatorBound.lean (0 truncations) ​

SectionDeclarations (Count)Exact Mechanism
Cyclotomic separation & lift predicatesexists_isUnit_cyclotomicChar_pow_sub_one, exists_cyclotomicChar_pow_sub_one_dvd_pow_padicValNat, exists_cyclotomicChar_pow_sub_one_dvd, IsWeakLift, IsNonzeroIn, IsLiftWithTwistedLattice, liftValuationBound, invAvatar_eq_one_of_mem_inertiaAbove (8)Finds cyclotomic generator g1 with ua−1∣ℓh (h≤vℓ(N), h=0 for ℓ>h22), defines IsWeakLift and liftValuationBound, and checks ϑ.invAvatar kills inertia above M.
Taylor–Wiles prime triangle & non-weak-lift eliminationexists_eventually_hasRootChain_mostFrobeniiAt, exists_taylorWilesPlaces_hasRootChain, norm_charpoly_coeff_le_one_of_continuous, exists_det_one_sub_ne_zero, exists_prod_sub_det_one_sub_eq_zero, exists_dvd_prime_pow_succ, normalizingAvatar_tameGenerator (7)Builds TaylorWilesPlaces satisfying IsPrimeTriangle (loss h222h) and uniform HasRootChain for all weak lifts congruent to x0, and constructs finite determinant products killing every non-weak lift.
Common Ribet element & diagonal base-level operatorexists_isCommonRibetElement_ellVal_le, exists_ellVal_le_and_diagOp_mem_ellIntegralForms (2)Produces IsCommonRibetElement with vℓ(N2d)≤liftValuationBound, lifting to a base-level diagonal operator B.diagOp s keeping N² • B.diagOp s y ℓ-integral whenever l and y agree outside non-weak lifts.
False-lift orthogonality & lift-generator spanexists_heckePolyOnForms_eq_zero, typeProjection_sub_starProjection_mem, IsLiftGenerator, IsLiftGenerator.mono, span_mem_invtSubmodule_heckePolyOnForms, IsLiftGenerator.typeProjection_eq_zero_or_mem_range, IsLiftGenerator.exists_isMainSummandLike, span_isLiftGenerator_mem_invtSubmodule_heckePolyOnForms, span_isLiftGenerator_mem_invtSubmodule_typeProjection, span_isLiftGenerator_mem_invtSubmodule, typeProjection_sub_starProjection_mem_of_isOrthogonalToFalseLifts, mem_integralForms_ofIso_iff, IsLiftGenerator.exists_isMainSummandLike_hasTwistedLattice, diagOp_toSmoothForm_typeProjection, diagOp_typeProjection_eq_zero_of_mem_span (15)Proves the span of IsLiftGenerators is invariant under heckePolyOnForms and typeProjection O c, uses IsOrthogonalToFalseLifts to show typeProjection O c (y - pr_Z y) misses all weak lifts outside Z, and matches integralForms with BaseLevel.ellIntegralForms.
Operator assembly & DenominatorLeexists_linearMap_eq_smul_mem_integralForms, exists_operator_ellVal_le_liftValuationBound, exp_le_norm_det_smul_of_ellVal_le, exists_operator_det_clearingBound, denominatorLe_clearingBound (5)Builds one clearing map per generator, assembles Λ0 on Z, multiplies by N=D.chosenGroupOrder to clear pairings against forms integral at all places above ℓ, and proves DenominatorLe ι.ιℓ O E Z (clearingBound D ℓ * log ℓ).

2. Walkthrough of all 19 declarations in FitTwistsExist.lean (1 truncation) ​

  1. Prime-weighted budget sums & projection-clearing bridge (11 decls): DenominatorLe.clearsProjection (bridging DenominatorLe to D.ClearsProjection), sum_padicValNat_mul_log_le, sum_half_pow_mul_log_le (∑2−llog⁡l≤2), prod_Ioc_natB_le_pow, sum_defectBound_mul_log_le, sum_localDefectBound_mul_log_le (≤4⋅106e180f(m/k)blog⁡b), isNegligible_padicValNat_oddClassBound (x2000), isNegligible_twistError (x999), isNegligible_denominatorError (x4000), isNegligible_padicValNat_card_stdClasses (x30), and sum_clearingBound_add_padicValNat_le (≤D.denominatorBudget).
  2. Main summands & lift splitting (3 decls): isRepOfType_one, exists_isMainSummand_mainPair, range_goodLift_le_span_hasLiftHeckePolynomial (proves (D.goodLift ϑ j).range is spanned by forms in admissible typeProjections lifting good eigensystems on Wm).
  3. Two-family twisting, denominator clearing & final theorem (5 decls): exists_mFoldTwist_selmerLengthLe_inv_ratio_le (1 let-type stub truncation), denominatorLe_range_goodLift, denominatorLe_span_trivialLift, exists_mFoldTwist_hasDenominatorsLe, and New.exists_isRegularFamily (untruncated, closing all 8 pillars).
Level 3 · Formal Lean Contract

Level 3 — Formal Lean Contract ​

skeleton/07_congruences/denominator_bound.lean (37 declarations, 0 stub truncations) and skeleton/07_congruences/fit_twists_exist.lean (19 declarations, 1 let-type stub truncation) mirror src/New/Congruences/FirstOrder/DenominatorBound.lean and src/New/Congruences/FitTwistsExist.lean at pinned upstream commit 41c2716658c42ba08eb0648994a2efe83082a95c. All 37 declarations in denominator_bound.lean and New.exists_isRegularFamily in fit_twists_exist.lean extract completely untruncated.

Stub-Truncation Disclosure (1 Truncation in fit_twists_exist.lean; 0 in denominator_bound.lean) ​

In skeleton/07_congruences/fit_twists_exist.lean, 1 declaration — New.Selmer.exists_mFoldTwist_selmerLengthLe_inv_ratio_le (decl starts L183, truncated at let ϑ : D.Twist := on L189) — is cut at its let ... := return-type binding by rh-extract's depth-0 := splitter. Its exact untruncated signature from pinned upstream src/New/Congruences/FitTwistsExist.lean:382–395 is:

lean
-- Verbatim from upstream src/New/Congruences/FitTwistsExist.lean:382-395
lemma New.Selmer.exists_mFoldTwist_selmerLengthLe_inv_ratio_le {P : Parameters} (D : Data P) {ℓ : ℕ}
    [ThePrime ℓ] (ι : PadicIso ℓ) {A B : Type} [Finite A] [Finite B]
    {R : A → GalRep ℓ D.E D.RowIndex} {R₁ : B → GalRep ℓ D.E Unit}
    (hR : ∀ a : A, ∃ (t : ℕ) (J : (D.E →+* ℂ) → Multiset ℤ), IsMainSummandLike D t J (R a))
    (hR₁ : ∀ b : B, ∃ (t : ℕ) (J : (D.E →+* ℂ) → Multiset ℤ), IsMainSummandLike D t J (R₁ b)) :
    ∃ τ : D.MFoldTwist, ∀ j : D.LiftIndex,
      let ϑ : D.Twist := τ.powTwist j
      IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D) ∧
      (∀ a : A, ∃ γ : AbsGal D,
        HasDivisibleSelmerLengthLe ϑ.invAvatar (R a) ϑ.Q γ (twistError ℓ D)) ∧
      (∀ b : B, ∃ γ : AbsGal D,
        HasDivisibleSelmerLengthLe ϑ.invAvatar (R₁ b) ϑ.Q γ (twistError ℓ D)) ∧
      ∀ (p : D.CriticalPair) (s : ℤˣ), p.IsRamified →
        ‖ι.ιℓ (p.ratio ϑ s)⁻¹‖ ≤ exp (twistError ℓ D * log ℓ)

All 18 remaining declarations in fit_twists_exist.lean (including sum_clearingBound_add_padicValNat_le, exists_mFoldTwist_hasDenominatorsLe, and New.exists_isRegularFamily) and all 37 declarations in denominator_bound.lean extract completely untruncated.

Headline Untruncated Signatures ​

lean
-- skeleton/07_congruences/denominator_bound.lean (upstream DenominatorBound.lean:1269-1293)
theorem New.Selmer.denominatorLe_clearingBound {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    (ι : PadicIso ℓ) (ϑ : D.Twist)
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D))
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    (h_span : Z ≤ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z (twistError ℓ D) y}) :
    DenominatorLe ι.ιℓ O E Z (clearingBound D ℓ * log ℓ)

-- skeleton/07_congruences/fit_twists_exist.lean (upstream FitTwistsExist.lean:230-260, 520-543)
lemma New.Selmer.sum_clearingBound_add_padicValNat_le {P : Parameters} (D : Data P) (T : Finset ℕ)
    (hT : ∀ l ∈ T, l.Prime) :
    ∑ l ∈ T, (clearingBound D l * log l +
      padicValNat l (Nat.card (StdClasses (n := Unit) D.chosenLevel)) * log l) ≤
        D.denominatorBudget

lemma New.exists_isRegularFamily {P : Parameters} (D : Data P) :
    ∃ θ : PrimePadicIso → D.MFoldTwist, D.IsRegularFamily θ
  • Handoff closing all 8 pillars: New.exists_isRegularFamily (fit_twists_exist.lean:254–259, upstream FitTwistsExist.lean:520–543) is consumed directly by 05_determinant/long_forms (New.Data.exists_hasSmallRatios_heightLe_liftDeterminant_div in Regular Twist Families and the Assembly of Theorem C), discharging Theorem C (New.Data.integral_forms_long) into Stage 01 main-inequality (New.star_inequality) and completing the entire proof of GRH and RH in Stage 00 main-theorems.
  • Verification status (audit/verification-status.json): Local Lean compilation and kernel replay remain build_status: unverified-locally at pinned commit 41c2716658c42ba08eb0648994a2efe83082a95c (41c2716658c4). Static token scanning has scan_scope: entry, covering only Challenge.lean, src/Main.lean, and src/Statements.lean. Neither DenominatorBound.lean nor FitTwistsExist.lean has been locally compiled, kernel-checked, or statically scanned here.

lemma New.Selmer.exists_isUnit_cyclotomicChar_pow_sub_one — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L63-L95)

lean
/-- Let the prime `ℓ` exceed the square of `D.halfGap = D.r ^ 8`. Then some element `γ` of the
absolute Galois group of `D.E` has an `ℓ`-adic cyclotomic character `u` with `u ^ a - 1` a unit of
`ℤ_ℓ` for `0 < a < D.t`, where `D.t = 5 * D.r`. -/
lemma New.Selmer.exists_isUnit_cyclotomicChar_pow_sub_one {P : Parameters} (D : Data P) {ℓ : ℕ} [ThePrime ℓ]
    (hℓ : D.halfGap ^ 2 < ℓ) :
    ∃ γ : AbsGal D, ∀ a ∈ Set.Ioo 0 D.t, IsUnit ((cyclotomicChar Ω ℓ γ ^ a).val - 1) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:63-95 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=28 body_sha256=318ca698f5b96a537ebda48929fc8746fccc00607785638231f9be93267b8d1d]

lemma New.Selmer.exists_cyclotomicChar_pow_sub_one_dvd_pow_padicValNat — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L97-L122)

lean
/-- Some element `φ` of the absolute Galois group of `D.E` has an `ℓ`-adic cyclotomic character `u`
such that for `0 < a < D.t` the number `u ^ a - 1` divides, in `ℤ_ℓ`, the `ℓ`-part of
`D.chosenGroupOrder`, the product of the orders of `GL (D.r * D.t)` over the residue fields of the
chosen places. -/
lemma New.Selmer.exists_cyclotomicChar_pow_sub_one_dvd_pow_padicValNat {P : Parameters} (D : Data P) (ℓ : ℕ)
    [ThePrime ℓ] :
    ∃ φ : AbsGal D, ∀ a ∈ Set.Ioo 0 D.t,
      (cyclotomicChar Ω ℓ φ ^ a).val - 1 ∣ ℓ ^ padicValNat ℓ D.chosenGroupOrder := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:97-122 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=19 body_sha256=0f63b2b2c43bbd7bff5b829f63522ff1061c6d51c92eea57f6baefa9b2abde28]

lemma New.Selmer.exists_cyclotomicChar_pow_sub_one_dvd — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L124-L146)

lean
/-- There are `h`, at most the `ℓ`-adic valuation of `D.chosenGroupOrder` and zero unless
`ℓ ≤ D.halfGap ^ 2`, and a topological generator `γ` of the Galois group of `D.E` modulo the kernel
of the cyclotomic character such that `u ^ a - 1` divides `ℓ ^ h` in `ℤ_ℓ` for `0 < a < D.t`, where
`u` is the cyclotomic character of `γ`. -/
lemma New.Selmer.exists_cyclotomicChar_pow_sub_one_dvd {P : Parameters} (D : Data P) (ℓ : ℕ) [ThePrime ℓ] :
    ∃ h ≤ padicValNat ℓ D.chosenGroupOrder,
      (ℓ ≤ D.halfGap ^ 2 ∨ h = 0) ∧
      ∃ γ : AbsGal D, (cyclotomicChar Ω ℓ).IsGeneratorModKer γ ∧
        ∀ a ∈ Set.Ioo 0 D.t, (cyclotomicChar Ω ℓ γ ^ a).val - 1 ∣ ℓ ^ h := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:124-146 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=15 body_sha256=26cffa53e6ab9e1c86e715ed7d2a89f1b4649d14ba07db3257f5186cdaaecd7f]

def New.Selmer.IsWeakLift — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L148-L153)

lean
/-- The system `x` (an isotypic space of forms for the descent pair `O`) is a weak lift: at every
Galois element the characteristic polynomial of its normalised representation has the root `1`. -/
def New.Selmer.IsWeakLift {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ] {r n : Type}
    [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] (O : DescentPair D.E r n)
    (x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)) : Prop := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:148-153 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=d77095378da645d252e6351172666da7b56d5f0062551566d7edff322b8ebdb9]

structure New.Selmer.IsNonzeroIn — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L155-L162)

lean
/-- The form `v` of the descent pair `O` is a nonzero form of the isotypic space `x`. -/
structure New.Selmer.IsNonzeroIn {P : Parameters} {D : Data P} {r n : Type} [Fintype r] [DecidableEq r]
    [Fintype n] [DecidableEq n] {O : DescentPair D.E r n} (v : O.FormV)
    (x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)) : Prop where
  /-- The algebraic form `v.toSmoothForm` of `v` lies in `x`. -/
  mem : v.toSmoothForm ∈ x.val
  /-- The algebraic form `v.toSmoothForm` of `v` is not zero. -/
  ne_zero : v.toSmoothForm ≠ 0

abbrev New.Selmer.IsLiftWithTwistedLattice — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L163-L176)

lean
/-- The system `x` lifts a row `R` (`IsMainSummandLike`: a representation of rank `r` with the
properties of a main summand): the trace of its normalised representation is that of `R` twisted
by `ϑ.invAvatar` plus the powers `e < O.rankDiff` of the inverse cyclotomic character. The twist
has a lattice on which some `γ` acts by a scalar `y` and, if `x = x₀`, its Selmer group with
divisible coefficients has length at most `sel`. -/
abbrev New.Selmer.IsLiftWithTwistedLattice {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ]
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] (O : DescentPair D.E r n)
    (ϑ : D.Twist) (sel : ENNReal)
    (x₀ x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)) : Prop := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:163-176 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=5 body_sha256=493babfac6459ed0bbfa9e0d370ab65a326ff10e77a49291740371f0ed3e292b]

def New.Selmer.liftValuationBound — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L179-L186)

lean
/-- The bound `sel + 2 t′ ram + r′ loc + err` for the valuations of the eigenvalues of the operator
that clears denominators. Here `r′ = card r`, `t′ = O.rankDiff`, `loc = localDefectBound D ℓ` and
`err = denominatorError D ℓ`; `ram` bounds the ramification of the twist and `sel` the lengths of
the Selmer groups. -/
noncomputable def New.Selmer.liftValuationBound {P : Parameters} {D : Data P} (ℓ : ℕ) [ThePrime ℓ]
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] (O : DescentPair D.E r n)
    (ram sel : ENNReal) : ENNReal := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:179-186 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=1 body_sha256=9f47ca782d2b683d93da4a1abe2a38bb407565ac25fc988f784c91193d8baa99]

lemma New.Selmer.invAvatar_eq_one_of_mem_inertiaAbove — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L188-L207)

lean
/-- Let `ϑ` be an auxiliary twist of the data `D`, with ramification at most `ram` (`IsAuxTwist`):
the places of `ϑ.Q` and their conjugates avoid `badPlaces D ℓ`, and `ϑ.invAvatar`, the `ℓ`-adic
Galois character of `ϑ⁻¹`, is anticyclotomic with modulus `ϑ.Q`. Then `ϑ.invAvatar` kills the
inertia groups at the places in `placesAboveM D`, those above the two primes `D.levelPrime i`. -/
lemma New.Selmer.invAvatar_eq_one_of_mem_inertiaAbove {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {ϑ : D.Twist} {ram : ENNReal}
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram) {γ : AbsGal D}
    (hγ : γ ∈ inertiaAbove (placesAboveM D)) : ϑ.invAvatar γ = 1 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:188-207 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=13 body_sha256=b4a60e487ff8b9b95b9a3ed2f2daa638908730bcb537322978beeb6f3194b329]

lemma New.Selmer.exists_eventually_hasRootChain_mostFrobeniiAt — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L209-L281)

lean
/-- Let `ϑ` be an auxiliary twist of ramification at most `ram` and `B` base data whose systems, the
Hecke eigenspaces of level `![]`, have normalised Galois representations with integral
characteristic polynomials. Let `R` be a row of weights `wt` (`IsMainSummandLike`). For every `ν`
and `g` there is `δ` with trivial cyclotomic character such that, along the filter `mostFrobeniiAt`
at `δ ^ ℓ ^ ν * g`, a place `y.place` with Frobenius `y.frob` satisfies: (a) the place avoids
`badPlaces D ℓ` and is off the base level; (b) if the system `x` is a weak lift and its polynomial
at the Frobenius is congruent to `∏ (X - cyclotomicInv φ ^ i)`, `φ = y.frob`, `i < O.rankDiff`,
times some `S` with `1 ≤ ‖S 1‖`, then its Hecke polynomial at the place, with the variable rescaled
by `normalizingAvatar O φ` read in `ℂ` by the fixed isomorphism `ιℓ`, is the chain `∏ (X - q ^ i)`,
`q` the norm of the place, times a divisor of an integral `e` with `e 1 = 1`; (c) the characteristic
polynomial of the twist of `R` by `ϑ.invAvatar` at the Frobenius has a value of norm at least `1` at
`1`. -/
lemma New.Selmer.exists_eventually_hasRootChain_mostFrobeniiAt {P : Parameters} {D : Data P} {ℓ : ℕ}
    [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] [Nonempty n]
    {O : DescentPair D.E r n} {ϑ : D.Twist} {ram : ENNReal}
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram)
    (B : BaseLevel (stdSpace D.E n) (O.columnCount, O.detExp) D.chosenGroupOrder)
    (h_int : ∀ (x : B.Eigensystem ![]) (g : Gal(Ω/D.E)) (i : ℕ),
      ‖(normalisedRep O x.val.galRep g).val.charpoly.coeff i‖ ≤ 1)
    {wt : (D.E →+* ℂ) → Multiset ℤ} {R : GalRep ℓ D.E r} (hR : IsMainSummandLike D O.rankDiff wt R)
    (ν : ℕ) (g : AbsGal D) :
    ∃ δ : Gal(Ω/D.E), cyclotomicChar Ω ℓ δ = 1 ∧
      ∀ᶠ y : FrobeniusDatum D.E in mostFrobeniiAt D.E (δ ^ ℓ ^ ν * g),
        -- (a)
        y.place ∉ badPlaces D ℓ ∧
        B.IsOffLevel ![] y.place ∧
        -- (b)
        (∀ x : B.Eigensystem ![], IsWeakLift O x.val →
          ∀ S : (PadicAlgCl ℓ)[X], 1 ≤ ‖S.eval 1‖ →
          (∀ k : ℕ, ‖(normalisedRep O x.val.galRep y.frob).val.charpoly.coeff k -
            (S * ∏ i ∈ Finset.range O.rankDiff,
              (X - C (cyclotomicInv ℓ D.E (PadicAlgCl ℓ) y.frob ^ i))).coeff k‖ < 1) →
          ∃ e : EllAdicIntegers[X],
            HasRootChain (x.val.heckePolyAt y.place) (e.map (algebraMap EllAdicIntegers ℂ))
              y.place.q (ιℓ.symm (normalizingAvatar O y.frob).val)⁻¹ O.rankDiff ∧
            e.eval 1 = 1) ∧
        -- (c)
        1 ≤ ‖(ϑ.invAvatar y.frob • (R y.frob).val).charpoly.eval 1‖ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:209-281 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=35 body_sha256=a3de459db5a92297e9a58c094c205fabe6b9c11c78efcc1ba72eff5964cc9435]

lemma New.Selmer.exists_taylorWilesPlaces_hasRootChain — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L283-L391)

lean
/-- The auxiliary places of the Taylor–Wiles method. Let the types `c` form a lift setting for the
pair of hermitian spaces `O` and the auxiliary twist `ϑ` of ramification at most `ram`, and let the
systems of the base data `B` have integral characteristic polynomials. Let `x₀` lift the row `R` of
weights `wt`: the trace of its normalised representation is that of the twist of `R` plus the powers
`cyclotomicInv ^ e`, `e < O.rankDiff` (`HasLiftTrace`). Let `g₁` generate the Galois group of `D.E`
topologically modulo the kernel of the cyclotomic character, let `u ^ a - 1` divide `ℓ ^ h` in `ℤ_ℓ`
for `0 < a < D.t = 5 * D.r`, where `u` is the cyclotomic character of `g₁`, and let
`ℓ ≤ D.halfGap ^ 2` (`D.halfGap = D.r ^ 8`) or `h = 0`. Then there are a finite linear order `J` and
a monotone map `exponent` to the exponents `0 < e < O.rankDiff` such that for each `ν > 0` some
places `Q` of norm `1` modulo `ℓ ^ ν`, indexed by `J`, satisfy: (a) they form a triangle for the
generator `g₁⁻¹` (`IsPrimeTriangle`): the Frobenius elements of exponent `e` and finitely many test
points detect the Galois cohomology classes of twist `-e` unramified off `ℓ`, the powers `u ^ e`
being separated up to `ℓ ^ (D.halfGap * h)`, with total loss `D.halfGap ^ 22 * h`; (b) they avoid
`badPlaces D ℓ` and are off the base level, so are unramified for the forms of `B`; (c) for every
weak lift `x` of base level congruent to `x₀`, the Hecke polynomial at the place of index `j` and
norm `q`, with the variable rescaled by the normalising character, is the chain `∏ (X - q ^ i)`,
`i < O.rankDiff`, times a divisor of an integral `e j` that has value `1` at `1` and does not depend
on `x`. -/
lemma New.Selmer.exists_taylorWilesPlaces_hasRootChain {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] [Nonempty n]
    {O : DescentPair D.E r n} {ϑ : D.Twist}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]} (hc : IsLiftSetting O c ϑ)
    {ram : ENNReal} (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram)
    (B : BaseLevel (stdSpace D.E n) (O.columnCount, O.detExp) D.chosenGroupOrder)
    (h_int : ∀ (x : B.Eigensystem ![]) (g : Gal(Ω/D.E)) (i : ℕ),
      ‖(normalisedRep O x.val.galRep g).val.charpoly.coeff i‖ ≤ 1)
    {x₀ : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)} {wt : (D.E →+* ℂ) → Multiset ℤ}
    {R : GalRep ℓ D.E r} (hR : IsMainSummandLike D O.rankDiff wt R)
    (h_trace : HasLiftTrace ϑ.invAvatar R O.rankDiff (normalisedRep O x₀.galRep))
    {h : ℕ} {g₁ : AbsGal D} (hℓ : ℓ ≤ D.halfGap ^ 2 ∨ h = 0)
    (hg₁_gen : (cyclotomicChar Ω ℓ).IsGeneratorModKer g₁)
    (hg₁ : ∀ a ∈ Set.Ioo 0 D.t, (cyclotomicChar Ω ℓ g₁ ^ a).val - 1 ∣ ℓ ^ h) :
    ∃ (J : Type) (_ : Fintype J) (_ : LinearOrder J)
      (exponent : J →o {e : Fin O.rankDiff // 0 < (e : ℕ)}),
      ∀ ν > (0 : ℕ), ∃ Q : TaylorWilesPlaces D.E J (ℓ ^ ν),
      -- (a)
      IsPrimeTriangle ν Q.place (fun j : J ↦ (Q.frobData j).isPlaceOver.tameGenerator)
        (fun j : J ↦ (Q.frobData j).frob) g₁⁻¹ O.rankDiff exponent (D.halfGap * h)
        (D.halfGap ^ 22 * h) ∧
      -- (b)
      (∀ j : J, Q.place j ∉ badPlaces D ℓ) ∧
      (∀ j : J, B.IsOffLevel ![] (Q.place j)) ∧
      -- (c)
      ∃ e : J → EllAdicIntegers[X], (∀ j : J, (e j).eval 1 = 1) ∧
        ∀ (j : J) (x : B.Eigensystem ![]),
        (∀ (g : Gal(Ω/D.E)) (k : ℕ), ‖(normalisedRep O x.val.galRep g).val.charpoly.coeff k -
          (normalisedRep O x₀.galRep g).val.charpoly.coeff k‖ < 1) →
        IsWeakLift O x.val →
        HasRootChain (x.val.heckePolyAt (Q.place j)) ((e j).map (algebraMap EllAdicIntegers ℂ))
          (Q.place j).q (ιℓ.symm (normalizingAvatar O (Q.frobData j).frob).val)⁻¹ O.rankDiff := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:283-391 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=60 body_sha256=ff99eae0a0371b324965781bb13b9994eb4df164d920db05273abc016f1b9b40]

lemma New.Selmer.norm_charpoly_coeff_le_one_of_continuous — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L393-L401)

lean
/-- A continuous representation of a compact group over `ℚ̄_ℓ` keeps a lattice, so its
characteristic polynomials have integral coefficients. -/
lemma New.Selmer.norm_charpoly_coeff_le_one_of_continuous {ℓ : ℕ} [ThePrime ℓ] {G n : Type} [Group G]
    [TopologicalSpace G] [IsTopologicalGroup G] [CompactSpace G] [Fintype n] [DecidableEq n]
    {ρ : G →* GL n (PadicAlgCl ℓ)} (hρ : Continuous ρ) (g : G) (i : ℕ) :
    ‖(ρ g).val.charpoly.coeff i‖ ≤ 1 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:393-401 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=c339d22698aad1183c93631130d934d025eedcc9657a979e524347a6e95e1cf6]

lemma New.Selmer.exists_det_one_sub_ne_zero — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L403-L426)

lean
/-- Let `u x g` be matrices over `ℚ̄_ℓ` with integral characteristic polynomials, and suppose that
for each `x` some `u x g` does not have the eigenvalue `1`. Then for each `x` there is `elt x` such
that `det (1 - u x (elt x))` is a nonzero element `value x` of the valuation ring of `ℚ̄_ℓ`. -/
lemma New.Selmer.exists_det_one_sub_ne_zero {ℓ : ℕ} [ThePrime ℓ] {Y G n : Type} [Fintype n] [DecidableEq n]
    (u : Y → G → Matrix n n (PadicAlgCl ℓ))
    (h_int : ∀ (x : Y) (g : G) (i : ℕ), ‖(u x g).charpoly.coeff i‖ ≤ 1)
    (h_reg : ∀ x : Y, ∃ g : G, ¬(u x g).charpoly.IsRoot 1) :
    ∃ (elt : Y → G) (value : Y → EllAdicIntegers),
      (∀ x : Y, algebraMap EllAdicIntegers (PadicAlgCl ℓ) (value x) = (1 - u x (elt x)).det) ∧
      ∀ x : Y, value x ≠ 0 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:403-426 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=15 body_sha256=169cc0ddc8862109f203bef2c0277fbcf27217798dc09dcd21cdff4e037e865c]

lemma New.Selmer.exists_prod_sub_det_one_sub_eq_zero — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L428-L449)

lean
/-- Let `u x g` be matrices over `ℚ̄_ℓ` with integral characteristic polynomials, `x` in a finite
type. There are finitely many elements `elt k` and nonzero elements `value k` of the valuation ring
of `ℚ̄_ℓ` such that the product of the `value k - det (1 - u x (elt k))` vanishes at every `x` for
which some `u x g` does not have the eigenvalue `1`. -/
lemma New.Selmer.exists_prod_sub_det_one_sub_eq_zero {ℓ : ℕ} [ThePrime ℓ] {Y G n : Type} [Finite Y] [Fintype n]
    [DecidableEq n] (u : Y → G → Matrix n n (PadicAlgCl ℓ))
    (h_int : ∀ (x : Y) (g : G) (i : ℕ), ‖(u x g).charpoly.coeff i‖ ≤ 1) :
    ∃ (K : Type) (_ : Fintype K) (elt : K → G) (value : K → EllAdicIntegers),
      (∀ k : K, value k ≠ 0) ∧
      ∀ x : Y, (∃ g : G, ¬(u x g).charpoly.IsRoot 1) →
        ∏ k : K,
          (algebraMap EllAdicIntegers (PadicAlgCl ℓ) (value k) - (1 - u x (elt k)).det) = 0 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:428-449 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=11 body_sha256=bcc079975791e2d22442607f16ce681a6a34892d6a0c770b69a69c2fdb06dd07]

lemma New.Selmer.exists_dvd_prime_pow_succ — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L451-L457)

lean
/-- A nonzero `ℓ`-adic integer divides a positive power of `ℓ`. -/
lemma New.Selmer.exists_dvd_prime_pow_succ {ℓ : ℕ} [ThePrime ℓ] {b : EllAdicIntegers} (hb : b.val ≠ 0) :
    ∃ ν : ℕ, b ∣ (ℓ : EllAdicIntegers) ^ (ν + 1) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:451-457 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=5 body_sha256=7776b3a6eb016083e139d8a3b8fea65b6f74eec93289c45d3d02ac2704ed56ac]

lemma New.Selmer.normalizingAvatar_tameGenerator — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L459-L466)

lean
/-- The character `normalizingAvatar O` is unramified away from `ℓ`, so it is trivial at the tame
generator of a place `A` over `w ∤ ℓ`. -/
lemma New.Selmer.normalizingAvatar_tameGenerator {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ]
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] (O : DescentPair D.E r n)
    {w : FinPlace D.E} {A : ClosurePlace} (hA : IsPlaceOver A w) (hw : ↑ℓ ∉ w.asIdeal) :
    (normalizingAvatar O hA.tameGenerator : PadicAlgCl ℓ) = 1 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:459-466 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=2 body_sha256=e170e516ebd116c2d4464d68ef89db70f8465da2d71029e1c5cdbdfc1a0361bc]

lemma New.Selmer.exists_isCommonRibetElement_ellVal_le — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L468-L521)

lean
/-- There is a common Ribet element for a finite family `sys` of systems, with normalised Galois
representations `N x`. Assume the following. The types `c` form a lift setting for `O` and the twist
`ϑ`, whose ramification is at most `ram`. The places `w j`, with tame generators `tame j` and
Frobenius elements `φ j`, form a triangle (`IsPrimeTriangle`) with bounds `D.halfGap * h` and
`D.halfGap ^ 22 * h`, where `h` is at most the valuation of `D.chosenGroupOrder`, the product of the
orders of general linear groups over the chosen residue fields. Each `N x` has the weights `wt` and
the type made from `c` and `O.rankDiff` eigenvalues `1` (`IsRepOfType`), and
`(N x g - ϑ.invAvatar g) (N x g - 1) = 0` on inertia above `ϑ.Q` and its conjugate. Each system in
`𝓧` lifts a row with a twisted lattice, and for `sys x₀` the Selmer length of the twisted row is at
most the finite `sel` (`IsLiftWithTwistedLattice`). The module `𝒥` holds `ℓ ^ ν` times all traces of
the `N x`, and the traces of the relations, with polynomials `e j` of value `1` at `1`, that tie
`tame j` to `φ j` (`IsTraceIdeal`). Then one family `f` of polynomials in the `X j` multiplies every
family `x ↦ det (1 - N x g)` into `𝒥`, has on `𝓧` no monomial properly dividing `∏ X j`, and has at
`x₀` a coefficient `d` of `∏ X j` with `D.chosenGroupOrder ^ 2 * d` of valuation at most
`liftValuationBound ℓ O ram sel`. -/
lemma New.Selmer.exists_isCommonRibetElement_ellVal_le {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    {O : DescentPair D.E r n} {ϑ : D.Twist}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]} (hc : IsLiftSetting O c ϑ)
    {ram : ENNReal} (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram)
    {J : Type} [Fintype J] [LinearOrder J] {ν h : ℕ} {w : J → FinPlace D.E} {tame φ : J → AbsGal D}
    {exponent : J →o {e : Fin O.rankDiff // 0 < (e : ℕ)}} {g₀ : AbsGal D}
    (h_le : h ≤ padicValNat ℓ D.chosenGroupOrder)
    (h_tri : IsPrimeTriangle ν w tame φ g₀ O.rankDiff exponent (D.halfGap * h) (D.halfGap ^ 22 * h))
    {Y : Type} [Fintype Y] {sys : Y → Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)}
    {wt : (D.E →+* ℂ) → Multiset ℤ}
    (h_isRepOfType : ∀ x : Y, IsRepOfType O O.rankDiff wt
      (fun i : O.ChosenIndex ↦ scaledTypePoly O c i * (X - 1) ^ O.rankDiff)
      (Set.conjClosure ϑ.Q ∪ (Set.range w).conjClosure) (normalisedRep O (sys x).galRep))
    (h_quad : ∀ x : Y, ∀ g ∈ inertiaAbove (Set.conjClosure ϑ.Q),
      ((normalisedRep O (sys x).galRep g).val - ϑ.invAvatar g • 1) *
        ((normalisedRep O (sys x).galRep g).val - 1) = 0)
    {𝓧 : Set (Isotypic (stdSpace D.E n) (O.columnCount, O.detExp))} (x₀ : sys ⁻¹' 𝓧) {sel : ENNReal}
    (h_lift : ∀ x ∈ 𝓧, IsLiftWithTwistedLattice O ϑ sel (sys x₀) x)
    (h_sel_ne_top : sel ≠ ⊤) {S : Subalgebra EllAdicIntegers (Y → MvPolynomial J (PadicAlgCl ℓ))}
    {𝒥 : Submodule S (Y → MvPolynomial J (PadicAlgCl ℓ))} {e : J → EllAdicIntegers[X]}
    (h𝒥 : IsTraceIdeal 𝒥 (fun (x : Y) (g : AbsGal D) ↦ (normalisedRep O (sys x).galRep g).val)
      (ℓ ^ ν : EllAdicIntegers) tame φ (fun j : J ↦ j) e)
    (he : ∀ j : J, (e j).eval 1 = 1) :
    ∃ d : PadicAlgCl ℓ,
      IsCommonRibetElement 𝒥
        (fun (g : AbsGal D) (x : Y) ↦ (1 - (normalisedRep O (sys x).galRep g).val).det) x₀ d ∧
      ellVal (ℓ := ℓ) (D.chosenGroupOrder ^ 2 * d) ≤ liftValuationBound ℓ O ram sel := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:468-521 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=12 body_sha256=1dd0145b8b575e6ac366dc289990737bb234e9bef5dc6a6108171be6811d0f5a]

lemma New.Selmer.exists_ellVal_le_and_diagOp_mem_ellIntegralForms — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L523-L645)

lean
/-- The operator at a base system `x₀ ∈ 𝓧`. Let the types `c` form a lift setting for the pair `O`
and the twist `ϑ`, of ramification at most `ram`. Let each system in `𝓧` lift a row with a twisted
lattice, the Selmer length for `x₀` being at most the finite `sel`. Let `B` be base data. At every
level made of places outside `badPlaces D ℓ`, let each system of `B` have as normalised
representation `N x` one of the weights `wt` and the type made from `c` (`IsRepOfType`), with
`(N x g - ϑ.invAvatar g) (N x g - 1)` zero on inertia above `ϑ.Q` and its conjugate. Then at some
level `L` there are eigenvalues `s` such that: (a) `D.chosenGroupOrder ^ 2 * s x₀` has valuation at
most `liftValuationBound ℓ O ram sel = sel + 2 * O.rankDiff * ram + card r * localDefectBound D
ℓ + denominatorError D ℓ`; (b) if `l` and `y` are forms of base level, `D.chosenGroupOrder • l` is
integral, `y` is supported on `𝓧` and `l`, `y` have the same components outside the base systems
that are not weak lifts (weak lift: all characteristic polynomials have the root `1`), then
`D.chosenGroupOrder • D.chosenGroupOrder • B.diagOp s y` is integral. Here `B.diagOp s` scales each
system `x` by `s x`, and `D.chosenGroupOrder` is the product of the orders of general linear groups
over the chosen residue fields. -/
lemma New.Selmer.exists_ellVal_le_and_diagOp_mem_ellIntegralForms {P : Parameters} {D : Data P} {ℓ : ℕ}
    [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] [Nonempty n]
    {O : DescentPair D.E r n} {ϑ : D.Twist}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]} (hc : IsLiftSetting O c ϑ)
    {ram : ENNReal} (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram)
    {𝓧 : Set (Isotypic (stdSpace D.E n) (O.columnCount, O.detExp))} {sel : ENNReal}
    {x₀ : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)}
    (h_lift : ∀ x ∈ 𝓧, IsLiftWithTwistedLattice O ϑ sel x₀ x)
    (h_sel_ne_top : sel ≠ ⊤) {wt : (D.E →+* ℂ) → Multiset ℤ}
    (B : BaseLevel (stdSpace D.E n) (O.columnCount, O.detExp) D.chosenGroupOrder)
    (h_isRepOfType : ∀ (K : Type) [Finite K] (u : K → FinPlace D.E),
      (∀ k : K, u k ∉ badPlaces D ℓ) →
      ∀ x ∈ B.Eigensystem u, IsRepOfType O O.rankDiff wt
        (fun i : O.ChosenIndex ↦ scaledTypePoly O c i * (X - 1) ^ O.rankDiff)
        (Set.conjClosure ϑ.Q ∪ (Set.range u).conjClosure) (normalisedRep O x.galRep))
    (h_quad : ∀ (K : Type) [Finite K] (u : K → FinPlace D.E), (∀ k : K, u k ∉ badPlaces D ℓ) →
      ∀ x ∈ B.Eigensystem u, ∀ g ∈ inertiaAbove (Set.conjClosure ϑ.Q),
        ((normalisedRep O x.galRep g).val - ϑ.invAvatar g • 1) *
          ((normalisedRep O x.galRep g).val - 1) = 0)
    (hx₀ : x₀ ∈ 𝓧) (hx₀B : x₀ ∈ B.Eigensystem ![]) :
    ∃ J : Type, ∃ (_ : Finite J) (L : J → FinPlace D.E) (s : B.Eigensystem L → PadicAlgCl ℓ),
      -- (a)
      (∀ x : B.Eigensystem L, x.val = x₀ →
        ellVal (ℓ := ℓ) (D.chosenGroupOrder ^ 2 * s x) ≤ liftValuationBound ℓ O ram sel) ∧
      -- (b)
      ∀ l ∈ B.formsOfLevel ![], D.chosenGroupOrder • l ∈ BaseLevel.ellIntegralForms →
        ∀ y ∈ B.formsOfLevel ![],
        (∀ s₁ : B.Eigensystem L → PadicAlgCl ℓ,
          (∀ x : B.Eigensystem L, x.val ∈ 𝓧 → s₁ x = 0) → B.diagOp s₁ y = 0) →
        (∀ s₁ : B.Eigensystem L → PadicAlgCl ℓ,
          (∀ x : B.Eigensystem L, x.val ∈ B.Eigensystem ![] → ¬IsWeakLift O x.val → s₁ x = 0) →
          B.diagOp s₁ l = B.diagOp s₁ y) →
        D.chosenGroupOrder • D.chosenGroupOrder • B.diagOp s y ∈ BaseLevel.ellIntegralForms := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:523-645 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=76 body_sha256=d4d0a68975d19878d19c9aeaa34dd6e76d292ddc8eacf0284f38452e67ed78ed]

lemma New.Selmer.exists_heckePolyOnForms_eq_zero — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L647-L685)

lean
/-- There is a split place `w`, off the places of `O` and their conjugates, at which the Hecke
polynomial operator, evaluated at the number `O.liftHeckeRoot w` (the inverse of the largest root
`υ q ^ (O.rankDiff - 1)` of the chain that a theta lift has in its Hecke polynomial, with `q` the
norm of `w` and `υ` the Frobenius value of `O.charW`), kills every nonzero form `v` of base level
that lies in a system `x` which is a weak lift: at every Galois element the characteristic
polynomial of the normalised representation of `x` has the root `1`. -/
lemma New.Selmer.exists_heckePolyOnForms_eq_zero {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] [Nonempty n]
    {O : DescentPair D.E r n} (B : BaseLevel (stdSpace D.E n) (O.columnCount, O.detExp)
      D.chosenGroupOrder) :
    ∃ (w : FinPlace D.E) (hw : star w ≠ w) (hS : w ∉ O.places.conjClosure),
      ∀ (x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)) (v : O.FormV),
      v.toSmoothForm ∈ x.val ⊓ B.formsOfLevel ![] →
      v.toSmoothForm ≠ 0 →
      IsWeakLift O x →
      O.heckePolyOnForms hw hS (O.liftHeckeRoot w) v = 0 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:647-685 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=24 body_sha256=ca5d48ec421b04f9689605710fde937de050726455ce8d73c5b1e175359a7f78]

lemma New.Selmer.typeProjection_sub_starProjection_mem — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L689-L742)

lean
/-- Let `typeProjection O c` be the action on forms of the idempotent of the tuple of types `c`,
with range in the image of the element `E` of the group algebra. Let `Z` be stable under it and
under the Hecke polynomial operators `O.heckePolyOnForms`, and let `y` be orthogonal to the false
lifts: the forms in `Zᗮ` and the image of `E` that, at some split place, the Hecke polynomial
operator at its lift Hecke root `O.liftHeckeRoot`, the value expected of a lift, kills. If at one
split place `w` this operator kills the nonzero isotypic forms in the range of `typeProjection O c`
that lie outside `M`, then `typeProjection O c` takes the component of `y` orthogonal to `Z` into
`M`. -/
lemma New.Selmer.typeProjection_sub_starProjection_mem {P : Parameters} {D : Data P} {r n : Type} [Fintype r]
    [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z M : Submodule ℂ O.FormV} {y : O.FormV}
    (hZ_hecke : ∀ (w : FinPlace D.E) (hw : star w ≠ w) (hS : w ∉ O.places.conjClosure) (ξ : ℂ),
      Z ∈ (O.heckePolyOnForms (w := w) hw hS ξ).invtSubmodule)
    (hZ_type : Z ∈ (typeProjection O c).invtSubmodule)
    (h_le : (typeProjection O c).range ≤ (O.groupAlgAction E).range)
    (hy : O.IsOrthogonalToFalseLifts E Zᗮ y)
    {w : FinPlace D.E} {hw : star w ≠ w} {hS : w ∉ O.places.conjClosure}
    (h_kill : ∀ x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp),
      ∀ v ∈ (typeProjection O c).range,
      IsNonzeroIn v x → v ∉ M → O.heckePolyOnForms hw hS (O.liftHeckeRoot w) v = 0) :
    typeProjection O c (y - Z.starProjection y) ∈ M := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:689-742 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=33 body_sha256=8e26854f7958d87cf2df4dc3b7591fd2cd79ce0a0183420b60da7e4ddb80640f]

structure New.Selmer.IsLiftGenerator — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L744-L764)

lean
/-- A lift generator of `Z`: a form in `Z`, in the range of an apt projection inside the image of
`E`, that lifts a system with a main summand whose twist by `ϑ.invAvatar` has a Selmer group with
divisible coefficients of length at most `sel` (`HasDivisibleSelmerLengthLe`). -/
structure New.Selmer.IsLiftGenerator {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ]
    (ϑ : D.Twist) {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    (O : DescentPair D.E r n) (E : MonoidAlgebra ℂ (O.ChosenGL r)) (Z : Submodule ℂ O.FormV)
    (sel : ENNReal) (y : O.FormV) : Prop where
  /-- The form lies in `Z`. -/
  mem : y ∈ Z
  /-- The form is in the range of `typeProjection O c` for a type `c` in lift setting, inside the
  image of `E`. -/
  exists_type : ∃ c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X],
    y ∈ (typeProjection O c).range ∧ IsLiftSetting O c ϑ ∧
    (typeProjection O c).range ≤ (O.groupAlgAction E).range
  /-- The form lifts a system with a main summand `R` for a pair `V` with
  `O.u1Char = V.u1Char * ϑ.toAutChar`, and the Selmer group with divisible coefficients of the
  twisted main summand has length at most `sel`. -/
  exists_hasLiftHeckePolynomial : ∃ z : FinPlace D.E → ℕ → ℂ, O.HasLiftHeckePolynomial y z ∧
    ∃ (R : GalRep ℓ D.E r) (V : DescentPair D.E r n),
      IsMainSummand V z R ∧ O.u1Char = V.u1Char * ϑ.toAutChar ∧
      ∃ γ : AbsGal D, HasDivisibleSelmerLengthLe ϑ.invAvatar R ϑ.Q γ sel

lemma New.Selmer.IsLiftGenerator.mono — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L766-L774)

lean
/-- A lift generator for the bound `sel` on the length of its Selmer group is one for every larger
bound. -/
lemma New.Selmer.IsLiftGenerator.mono {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ]
    {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    {sel sel' : ENNReal} {y : O.FormV} (hy : IsLiftGenerator ϑ O E Z sel y) (h_le : sel ≤ sel') :
    IsLiftGenerator ϑ O E Z sel' y := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:766-774 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=a4b0e59dd754c4a2b3ca5487687981aa0f844c8d2120fb71a74230130ada5a24]

lemma New.Selmer.span_mem_invtSubmodule_heckePolyOnForms — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L776-L788)

lean
/-- A lift (`O.HasLiftHeckePolynomial`: a form whose Hecke polynomials are those of the lift of some
eigenvalues `z`) is an eigenvector of every Hecke polynomial operator, so the span of a set of lifts
is stable under these operators. -/
lemma New.Selmer.span_mem_invtSubmodule_heckePolyOnForms {P : Parameters} {D : Data P} {r n : Type}
    [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {S : Set O.FormV} (hS : ∀ y ∈ S, ∃ z : FinPlace D.E → ℕ → ℂ, O.HasLiftHeckePolynomial y z)
    (w : FinPlace D.E) (hw : star w ≠ w) (hw_off : w ∉ O.places.conjClosure) (ξ : ℂ) :
    span ℂ S ∈ (O.heckePolyOnForms (w := w) hw hw_off ξ).invtSubmodule := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:776-788 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=6 body_sha256=04ade8b7eed921ef322667fd7364946cef82ed33b9da7b01a5ff0c7ca7e03d57]

lemma New.Selmer.IsLiftGenerator.typeProjection_eq_zero_or_mem_range — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L790-L829)

lean
/-- Let `v` be a lift generator (`IsLiftGenerator`) for the pair of hermitian spaces `O`: a form in
`Z`, in the range of `typeProjection O c'` for some tuple of types `c'` compatible with the twist
`ϑ` (a lift setting) and with this range in the image of `E`, that lifts Hecke eigenvalues of a
rank-`r` main summand whose twisted Selmer group has length at most `sel`. Then for every `c`,
either `typeProjection O c` kills `v`, or `v` lies in its range and is a nonzero form of some system
`x`, a space of forms with given Hecke eigenvalues. -/
lemma New.Selmer.IsLiftGenerator.typeProjection_eq_zero_or_mem_range {P : Parameters} {D : Data P} {ℓ : ℕ}
    [ThePrime ℓ] [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n]
    [DecidableEq n]
    {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    {sel : ENNReal} {v : O.FormV} (hv : IsLiftGenerator ϑ O E Z sel v)
    (c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]) :
    typeProjection O c v = 0 ∨
      v ∈ (typeProjection O c).range ∧
      ∃ x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp), IsNonzeroIn v x := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:790-829 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=26 body_sha256=f1f107556fa01c9144bfdc4ba4a10f9b6ccda7b29f7afd0ef454a3acf698f3a8]

lemma New.Selmer.IsLiftGenerator.exists_isMainSummandLike — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L831-L854)

lean
/-- Let `v` be a lift generator (`IsLiftGenerator`): a form in `Z`, of a type forming a lift setting
for `ϑ` whose forms all lie in the image of `E`, that lifts Hecke eigenvalues with a main summand
whose twist has a Selmer group of length at most `sel`. Let `v` be a nonzero form of the system `x`.
Then `x` lifts an `r`-dimensional Galois representation `R` with the properties of a main summand
for weights `wt` (`IsMainSummandLike`): the trace of the normalised representation of `x` is that of
`R` twisted by `ϑ.invAvatar`, the avatar of `ϑ⁻¹`, plus the first `O.rankDiff` powers of the inverse
cyclotomic character (`HasLiftTrace`). For some Galois element `γ` that acts on a lattice in the
twist by the scalar `y`, the Selmer group with divisible coefficients of the twist, with auxiliary
places `ϑ.Q`, has length at most `sel`. -/
lemma New.Selmer.IsLiftGenerator.exists_isMainSummandLike {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    [Nonempty n] {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)}
    {Z : Submodule ℂ O.FormV} {sel : ENNReal} {v : O.FormV} (hv : IsLiftGenerator ϑ O E Z sel v)
    {x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)} (hvx : IsNonzeroIn v x) :
    ∃ (wt : (D.E →+* ℂ) → Multiset ℤ) (R : GalRep ℓ D.E r),
      IsMainSummandLike (n := r) D O.rankDiff wt R ∧
      HasLiftTrace ϑ.invAvatar R O.rankDiff (normalisedRep O x.galRep) ∧
      ∃ γ : AbsGal D, HasDivisibleSelmerLengthLe ϑ.invAvatar R ϑ.Q γ sel := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:831-854 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=7 body_sha256=19596d17d4f4918e60e688cd501bbb2059bbbae7797ab2faa4a49d7c9cb679be]

lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule_heckePolyOnForms — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L856-L871)

lean
/-- Let `w` be a split place such that neither `w` nor its conjugate lies in `O.places`, the places
of the level of the pair `O`, and let `ξ` be any complex number. The Hecke polynomial operator at
`w`, evaluated at `ξ`, preserves the span of the lift generators (`IsLiftGenerator`): the forms in
`Z`, of a type compatible with the twist `ϑ` (a lift setting) whose forms all lie in the image of
`E`, that lift Hecke eigenvalues of a rank-`r` main summand whose twist has a Selmer group of length
at most `sel`. -/
lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule_heckePolyOnForms {P : Parameters} {D : Data P}
    {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r]
    [Fintype n] [DecidableEq n] {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)}
    {Z : Submodule ℂ O.FormV} {sel : ENNReal} (w : FinPlace D.E) (hw : star w ≠ w)
    (hw_off : w ∉ O.places.conjClosure) (ξ : ℂ) :
    span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y} ∈
      (O.heckePolyOnForms (w := w) hw hw_off ξ).invtSubmodule := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:856-871 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=4 body_sha256=ffae4041498aec42e04e2831a81bce903140fd52d1055a8e8133aa97d069571c]

lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule_typeProjection — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L873-L889)

lean
/-- For every tuple `c` of types, the action `typeProjection O c` on forms of the idempotent of `c`
preserves the span of the lift generators (`IsLiftGenerator`): the forms in `Z`, of a type
compatible with the twist `ϑ` (a lift setting) whose forms all lie in the image of `E`, that lift
Hecke eigenvalues of a rank-`r` main summand whose twist has a Selmer group of length at most
`sel`. -/
lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule_typeProjection {P : Parameters} {D : Data P} {ℓ : ℕ}
    [ThePrime ℓ] [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n]
    [DecidableEq n] {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)}
    {Z : Submodule ℂ O.FormV} {sel : ENNReal}
    (c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]) :
    span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y} ∈ (typeProjection O c).invtSubmodule := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:873-889 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=7 body_sha256=98e0119c768783075f52d373a1492c0392d761ea48d9ba023d6bc0553eb58f36]

lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L891-L907)

lean
/-- Consider the span of the lift generators (`IsLiftGenerator`): the forms in `Z`, of a type
compatible with the twist `ϑ` (a lift setting) whose forms all lie in the image of `E`, that lift
Hecke eigenvalues of a rank-`r` main summand whose twist has a Selmer group of length at most
`sel`. It is stable under the Hecke polynomial operators `O.heckePolyOnForms`, at every value `ξ`
and every split place `w` (`star w ≠ w`) such that neither `w` nor its conjugate lies in
`O.places`, the places of the level. It is also stable under `typeProjection O c`, the action on
forms of the idempotent of the tuple of types `c`. -/
lemma New.Selmer.span_isLiftGenerator_mem_invtSubmodule {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    {sel : ENNReal} (c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]) :
    (∀ (w : FinPlace D.E) (hw : star w ≠ w) (hS : w ∉ O.places.conjClosure) (ξ : ℂ),
      span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y} ∈
        (O.heckePolyOnForms (w := w) hw hS ξ).invtSubmodule) ∧
    span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y} ∈ (typeProjection O c).invtSubmodule := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:891-907 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=2 body_sha256=7f406f504e2fb1fd2135150f33b18f797021090ed803d49287eb240a36727ba5]

lemma New.Selmer.typeProjection_sub_starProjection_mem_of_isOrthogonalToFalseLifts — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L909-L940)

lean
/-- Let the types `c` form a lift setting for the pair `O` and the twist `ϑ`, auxiliary for the bad
places with ramification at most `ram`. Let `Z` be stable under the Hecke polynomials and under
`typeProjection O c`, whose range lies in the image of `E`, and let `y` be orthogonal to the false
lifts: the forms in `Zᗮ` and the image of `E` that a Hecke polynomial at its lift Hecke root kills.
If every nonzero isotypic form in the range of `typeProjection O c` outside `M` belongs to a weak
lift, then `typeProjection O c (y - Z.starProjection y)` lies in `M`. -/
lemma New.Selmer.typeProjection_sub_starProjection_mem_of_isOrthogonalToFalseLifts {P : Parameters}
    {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ] (ϑ : D.Twist) {ram : ENNReal}
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram)
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]} (hc : IsLiftSetting O c ϑ)
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z M : Submodule ℂ O.FormV} {y : O.FormV}
    (hZ_hecke : ∀ (w : FinPlace D.E) (hw : star w ≠ w) (hS : w ∉ O.places.conjClosure) (ξ : ℂ),
      Z ∈ (O.heckePolyOnForms (w := w) hw hS ξ).invtSubmodule)
    (hZ_type : Z ∈ (typeProjection O c).invtSubmodule)
    (h_le : (typeProjection O c).range ≤ (O.groupAlgAction E).range)
    (hy : O.IsOrthogonalToFalseLifts E Zᗮ y)
    (h_weak : ∀ x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp),
      ∀ v ∈ (typeProjection O c).range,
      IsNonzeroIn v x → v ∉ M → IsWeakLift O x) :
    typeProjection O c (y - Z.starProjection y) ∈ M := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:909-940 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=12 body_sha256=a732553edc96e682e43f42e61be6ac195e8e754a8546cd4f8e183834a558965a]

lemma New.Selmer.mem_integralForms_ofIso_iff — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L942-L955)

lean
/-- A form is integral at the place of `ℂ_ℓ` given by `ιℓ` (gauge at most `1` everywhere) if and
only if its algebraic form has `ℓ`-integral coordinates at the points integral above `ℓ`. -/
lemma New.Selmer.mem_integralForms_ofIso_iff {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ]
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {y : O.FormV} :
    y ∈ integralForms (PadicPlace.ofIso ιℓ) ↔ y.toSmoothForm ∈ BaseLevel.ellIntegralForms := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:942-955 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=824a267ba19d74cca044a9b531fbe3ff400924c081908ce9e8ac7f183398e649]

lemma New.Selmer.IsLiftGenerator.exists_isMainSummandLike_hasTwistedLattice — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L957-L981)

lean
/-- Let `v₀` be a lift generator for the bound `sel` on the Selmer length, and a nonzero form
(`IsNonzeroIn`) of the system `x₀`. Every system `x` that contains a nonzero lift generator, with no
bound on the Selmer length, lifts a row `R` (`IsMainSummandLike`) with a twisted lattice
(`HasTwistedLattice`): the trace of the normalised representation of `x` is that of `R` twisted by
`ϑ.invAvatar`, the avatar of `ϑ⁻¹`, plus the powers `e < O.rankDiff` of the inverse cyclotomic
character, some Galois element acts on a lattice in this twist by a scalar, and for `x = x₀` the
Selmer group with divisible coefficients of the twist can be taken of length at most `sel`. -/
lemma New.Selmer.IsLiftGenerator.exists_isMainSummandLike_hasTwistedLattice {P : Parameters} {D : Data P}
    {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r]
    [Fintype n] [DecidableEq n] [Nonempty n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV} {sel : ENNReal} {v₀ v : O.FormV}
    {x₀ x : Isotypic (stdSpace D.E n) (O.columnCount, O.detExp)}
    (hv₀ : IsLiftGenerator ϑ O E Z sel v₀) (hx₀ : IsNonzeroIn v₀ x₀)
    (hv : IsLiftGenerator ϑ O E Z ⊤ v) (hx : IsNonzeroIn v x) :
    ∃ (wt : (D.E →+* ℂ) → Multiset ℤ) (R : GalRep ℓ D.E r),
      IsMainSummandLike (n := r) D O.rankDiff wt R ∧
      HasLiftTrace ϑ.invAvatar R O.rankDiff (normalisedRep O x.galRep) ∧
      ∃ γ : AbsGal D, HasTwistedLattice ϑ.invAvatar R γ ∧
        (x = x₀ → HasDivisibleSelmerLengthLe ϑ.invAvatar R ϑ.Q γ sel) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:957-981 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=7 body_sha256=ed4c6cc4b83e6c319fb8bbd2a01b39e99904829dfe15095e659abe5f26e2d789]

lemma New.Selmer.diagOp_toSmoothForm_typeProjection — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L983-L995)

lean
/-- At each system `x`, `B.diagOp s' ∘ toSmoothForm ∘ typeProjection O c` multiplies a form of `x`
in the range of `typeProjection O c` by `ιℓ.symm (s' x)`. -/
lemma New.Selmer.diagOp_toSmoothForm_typeProjection {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    {O : DescentPair D.E r n} {B : BaseLevel (stdSpace D.E n) (O.columnCount,
      O.detExp) D.chosenGroupOrder}
    {J : Type} {L : J → FinPlace D.E}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]}
    (s' : B.Eigensystem L → PadicAlgCl ℓ) (x : B.Eigensystem L) {v : O.FormV}
    (hv : v ∈ (typeProjection O c).range) (hx : IsNonzeroIn v x.val) :
    B.diagOp s' (typeProjection O c v).toSmoothForm = ιℓ.symm (s' x) • v.toSmoothForm := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:983-995 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=3 body_sha256=0be1273917742a384eff2cfd6150a8fd76534cc126135c90724bd20387ca97b2]

lemma New.Selmer.diagOp_typeProjection_eq_zero_of_mem_span — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L997-L1023)

lean
/-- Let `L` be a family of places and `s` a function on `B.Eigensystem L`, the systems that contain
a nonzero form of level `L` over the base data `B`; the operator `B.diagOp s` scales each such
system `x` by `ιℓ.symm (s x)`. Let the forms of type `c`, the range of `typeProjection O c`, have
base level, and let `s` vanish at every system that contains a nonzero lift generator of `Z` for the
twist `ϑ`. Then `B.diagOp s` kills the component `typeProjection O c z` of type `c` of every form
`z` in the span of these lift generators. -/
lemma New.Selmer.diagOp_typeProjection_eq_zero_of_mem_span {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {ϑ : D.Twist} {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n]
    {O : DescentPair D.E r n} {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    {sel : ENNReal} {B : BaseLevel (stdSpace D.E n) (O.columnCount, O.detExp) D.chosenGroupOrder}
    {J : Type} [Finite J] {L : J → FinPlace D.E}
    {c : ∀ i : O.ChosenIndex, (ResField (O.chosenPlace i))[X]}
    (h_base : ∀ y ∈ (typeProjection O c).range, y.toSmoothForm ∈ B.formsOfLevel ![])
    {s : B.Eigensystem L → PadicAlgCl ℓ}
    (hs : ∀ x : B.Eigensystem L,
      (∃ v : O.FormV, IsLiftGenerator ϑ O E Z sel v ∧ IsNonzeroIn v x.val) → s x = 0)
    {z : O.FormV} (hz : z ∈ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y}) :
    B.diagOp s (typeProjection O c z).toSmoothForm = 0 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:997-1023 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=10 body_sha256=65b71bbc877e0ac0c2fb5a5ede7a1f5421e426edbb42a250784067284a8f31bf]

lemma New.Selmer.exists_linearMap_eq_smul_mem_integralForms — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L1025-L1114)

lean
/-- An operator for one lift generator. Let `ϑ` have ramification at most `ram` (`IsAuxTwist`), let
`Z` be spanned by lift generators for the bound `⊤`, and let `v₀ ≠ 0` be one for the finite `sel`.
Then a linear map `G` from the forms `O.FormV` to their algebraic forms has every lift generator as
an eigenvector, with an eigenvalue at `v₀` of `ℓ`-adic valuation at most
`liftValuationBound ℓ O ram sel`, which is `sel + 2 * O.rankDiff * ram + card r * localDefectBound D
ℓ + denominatorError D ℓ`. Let `y` be integral at `ιℓ` and orthogonal to the false lifts: the forms
in `Zᗮ` and the image of `E` that, at some split place, the Hecke polynomial at `O.liftHeckeRoot`
kills. Then every form whose algebraic form is `G` of the projection of `y` to `Z` is integral at
`ιℓ`. -/
lemma New.Selmer.exists_linearMap_eq_smul_mem_integralForms {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] (ϑ : D.Twist) {ram sel : ENNReal}
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram) (h_sel_ne_top : sel ≠ ⊤)
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    (h_span : Z ≤ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z ⊤ y})
    {v₀ : O.FormV} (hv₀ : IsLiftGenerator ϑ O E Z sel v₀) (hv₀_ne : v₀ ≠ 0) :
    ∃ G : O.FormV →ₗ[ℂ] (stdSpace D.E n).forms (O.columnCount, O.detExp),
      (∀ v : O.FormV, IsLiftGenerator ϑ O E Z ⊤ v → ∃ μ : ℂ, G v = μ • v.toSmoothForm) ∧
      (∀ μ : ℂ, G v₀ = μ • v₀.toSmoothForm →
        ellVal (ℓ := ℓ) (ιℓ μ) ≤ liftValuationBound ℓ O ram sel) ∧
      ∀ y : O.FormV, y ∈ integralForms (PadicPlace.ofIso ιℓ) → O.IsOrthogonalToFalseLifts E Zᗮ y →
        ∀ w : O.FormV, w.toSmoothForm = G (Z.starProjection y) →
          w ∈ integralForms (PadicPlace.ofIso ιℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:1025-1114 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=68 body_sha256=dbe18b53501b83e90e4e9ff65a3559db20a5b19b75729c2cc5aafa96ba641fe3]

theorem New.Selmer.exists_operator_ellVal_le_liftValuationBound — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L1116-L1181)

lean
/-- Bound for denominators. Let the twist `ϑ` have ramification at most `ram` (`IsAuxTwist`), let
`sel` be finite, and let `Z` be spanned by lift generators: forms in `Z`, of a type compatible with
`ϑ` (a lift setting) inside the image of the group-algebra element `E`, that lift Hecke eigenvalues
with main summands whose twisted Selmer groups with divisible coefficients have length at most
`sel`. Then an operator `Λ` on `Z` has eigenvalues of valuation at most
`liftValuationBound ℓ O ram sel`, which is `sel + 2 * O.rankDiff * ram + card r * localDefectBound D
ℓ + denominatorError D ℓ`, and takes to forms integral at `ιℓ` the projections to `Z` of forms
integral at `ιℓ` and orthogonal to the false lifts, which are the forms in `Zᗮ` and the image of `E`
that, at some split place, the Hecke polynomial at `O.liftHeckeRoot`, the value expected of a lift,
kills. Here `ιℓ` is the fixed isomorphism from `ℂ` to the algebraic closure of `ℚ_ℓ`. -/
theorem New.Selmer.exists_operator_ellVal_le_liftValuationBound {P : Parameters} {D : Data P} {ℓ : ℕ}
    [ThePrime ℓ] [PadicIso ℓ] (ϑ : D.Twist) {ram sel : ENNReal}
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar ram) (h_sel_ne_top : sel ≠ ⊤)
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    (h_span : Z ≤ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z sel y}) :
    ∃ Λ : Module.End ℂ Z,
      (∀ μ : ℂ, Λ.HasEigenvalue μ → ellVal (ℓ := ℓ) (ιℓ μ) ≤ liftValuationBound ℓ O ram sel) ∧
      ∀ y : O.FormV, y ∈ integralForms (PadicPlace.ofIso ιℓ) → O.IsOrthogonalToFalseLifts E Zᗮ y →
        (Λ (Z.orthogonalProjectionOnto y) : O.FormV) ∈ integralForms (PadicPlace.ofIso ιℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:1116-1181 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=47 body_sha256=3b0854062869e0509ba44751d68525834cf58e3f5cf50d2984147affd4cb98e7]

lemma New.Selmer.exp_le_norm_det_smul_of_ellVal_le — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L1183-L1200)

lean
/-- If `N * ιℓ μ` has `ℓ`-adic valuation at most `B` for every eigenvalue `μ` of `Λ`, then the
determinant of `N • Λ` has `ℓ`-adic norm at least `exp (-(finrank ℂ Z * (B * log ℓ)))`. -/
lemma New.Selmer.exp_le_norm_det_smul_of_ellVal_le {ℓ : ℕ} [ThePrime ℓ] [PadicIso ℓ] {Z : Type}
    [AddCommGroup Z] [Module ℂ Z] [Module.Finite ℂ Z] (N : ℕ) (Λ : Module.End ℂ Z) (B : NNReal)
    (h_eig : ∀ μ : ℂ, Λ.HasEigenvalue μ → ellVal ((N : PadicAlgCl ℓ) * ιℓ μ) ≤ B) :
    exp (-(finrank ℂ Z * (B * log ℓ))) ≤ ‖ιℓ (LinearMap.det ((N : ℂ) • Λ))‖ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:1183-1200 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=13 body_sha256=c3f1d54d7d2d796eb689910e5bf50192fc7fdc01da0eb76e1d3a9e97209cdf0b]

theorem New.Selmer.exists_operator_det_clearingBound — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L1202-L1267)

lean
/-- The operator form of the bound for denominators with the clearing bound. Let the twist `ϑ` have
ramification at most `twistError ℓ D`, the small number `(4 f + 3) r v_ℓ(N) + 2 ^ (-ℓ)` with
`N = D.chosenGroupOrder`, with respect to the places above `ℓ` and the level (`badPlaces D ℓ`), and
let `Z` be spanned by lift generators (`IsLiftGenerator`): forms in `Z` of suitable type that lift
Hecke eigenvalues with main summands whose twisted Selmer groups have length at most
`twistError ℓ D`. Then some operator `Λ` on `Z` has a determinant of `ℓ`-adic norm at least
`exp (-(finrank ℂ Z * (card r * (β * log ℓ))))`, where `β = clearingBound D ℓ` adds the local
losses, error terms and `v_ℓ(N)`. It takes the projection to `Z` of every form `y'` integral at `ιℓ`
and orthogonal to the false lifts to a form integral at `ιℓ`, whose pairings with the forms integral
at all places above `ℓ` are integral. -/
theorem New.Selmer.exists_operator_det_clearingBound {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] (ϑ : D.Twist) (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D))
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    (h_span : Z ≤ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z (twistError ℓ D) y}) :
    ∃ Λ : Module.End ℂ Z,
      exp (-(finrank ℂ Z * (card r * (clearingBound D ℓ * log ℓ)))) ≤ ‖ιℓ (LinearMap.det Λ)‖ ∧
      (∀ y' : O.FormV, y' ∈ integralForms (PadicPlace.ofIso ιℓ) → O.IsOrthogonalToFalseLifts E Zᗮ y'
        →
        (Λ (Z.orthogonalProjectionOnto y') : O.FormV) ∈ integralForms (PadicPlace.ofIso ιℓ)) ∧
      ∀ y y' : O.FormV, (∀ j : PadicPlace ℓ, y ∈ integralForms j) →
        y' ∈ integralForms (PadicPlace.ofIso ιℓ) → O.IsOrthogonalToFalseLifts E Zᗮ y' →
        ‖ιℓ (inner ℂ y (Λ (Z.orthogonalProjectionOnto y') : O.FormV))‖ ≤ 1 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:1202-1267 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=44 body_sha256=afaed4b5bd6e1bb84f0944c3eab290e69f1665a85837417206a8dc69a530e684]

theorem New.Selmer.denominatorLe_clearingBound — Upstream source (src/New/Congruences/FirstOrder/DenominatorBound.lean L1269-L1293)

lean
/-- Denominators for a good twist. Let `ι.ιℓ` be the isomorphism from `ℂ` to the algebraic closure
of `ℚ_ℓ` that `ι` chooses, and `ψ = ϑ.invAvatar` the `ℓ`-adic avatar of `ϑ⁻¹` for it. Let
`β = clearingBound D ℓ`, the sum of the local losses, the error terms and the valuation of
`D.chosenGroupOrder`; the small number `twistError ℓ D` is one of these terms. Assume: (i) the set
`ϑ.Q` is auxiliary for `ψ` and the places above `ℓ` and the level (`badPlaces D ℓ`), with
ramification at most `twistError ℓ D` (`IsAuxTwist`); (ii) `Z` is spanned by lift generators
(`IsLiftGenerator`): vectors of `Z` of a type `c` that forms a lift setting inside the image of `E`,
each lifting Hecke eigenvalues `z` with a main summand `R` for some pair `V` with
`O.u1Char = V.u1Char * ϑ.toAutChar`, where the Selmer group of `ψ R` with divisible coefficients has
length at most `twistError ℓ D`. Then `DenominatorLe` holds for `E` and `Z` with exponent `β log ℓ`:
some operator on `Z` with determinant of `ℓ`-adic norm at least
`exp (-(finrank ℂ Z * (card r * (β * log ℓ))))` takes the projection to `Z` of each form integral at
`ι.ιℓ` and orthogonal to the false lifts to a form that is integral at `ι.ιℓ` and has integral
pairings with the forms integral at all places above `ℓ`. -/
theorem New.Selmer.denominatorLe_clearingBound {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    (ι : PadicIso ℓ) (ϑ : D.Twist)
    (hϑ : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D))
    {r n : Type} [Fintype r] [DecidableEq r] [Fintype n] [DecidableEq n] {O : DescentPair D.E r n}
    {E : MonoidAlgebra ℂ (O.ChosenGL r)} {Z : Submodule ℂ O.FormV}
    (h_span : Z ≤ span ℂ {y : O.FormV | IsLiftGenerator ϑ O E Z (twistError ℓ D) y}) :
    DenominatorLe ι.ιℓ O E Z (clearingBound D ℓ * log ℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FirstOrder/DenominatorBound.lean:1269-1293 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=5 body_sha256=536e09db93a35e077647aed256b01b31bb94bb4a1e16f9151b732508a08f446a]

lemma New.Selmer.DenominatorLe.clearsProjection — Upstream source (src/New/Congruences/FitTwistsExist.lean L51-L65)

lean
/-- Let the projection to the space `Z` of lifts have denominator at most `exp β` per dimension of
`Z` and per unit of the rank `r` of the source (`DenominatorLe`). If `β ≤ β'`, then some operator
with determinant of norm at least `exp (-(dim Z · r · β'))` clears this denominator
(`New.Data.ClearsProjection`). -/
lemma New.Selmer.DenominatorLe.clearsProjection {P : Parameters} {D : Data P} {ℓ : ℕ}
    [Fact ℓ.Prime] {ι : ℂ ≃+* PadicAlgCl ℓ} {ϑ : D.Twist} {j : ℕ} {β β' : ℝ}
    (h_denom : DenominatorLe ι (D.descentPair ϑ j) D.e₀ (D.goodLift ϑ j).range β) (hββ' : β ≤ β') :
    D.ClearsProjection ι ϑ j β' := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:51-65 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=8 body_sha256=243045cf9f46868c503fff28445aa0703f11c3b74c03de59b53d0d61bf32cf95]

lemma New.Selmer.sum_padicValNat_mul_log_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L67-L80)

lean
/-- Summed over a finite set `T` of primes `l` with weights `log l`, the `l`-adic valuations of a
natural number `a` are at most `log b` for every natural number `b ≥ a`. -/
lemma New.Selmer.sum_padicValNat_mul_log_le (T : Finset ℕ) (hT : ∀ l ∈ T, l.Prime) {a b : ℕ}
    (hab : a ≤ b) : ∑ l ∈ T, (padicValNat l a : ℝ) * log l ≤ log b := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:67-80 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=10 body_sha256=8ca3907edc3eeb81849fe9cf141cdc114b4ec01e20a296ad67ed9731660837b4]

lemma New.Selmer.sum_half_pow_mul_log_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L82-L88)

lean
lemma New.Selmer.sum_half_pow_mul_log_le (T : Finset ℕ) :
    ∑ l ∈ T, (1 / 2 : ℝ) ^ l * log l ≤ 2 := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:82-88 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=5 body_sha256=87d6c2b5f27dadf32d016799f736ba35fe45c726b697b30829658ee095cd6ef4]

lemma New.Selmer.prod_Ioc_natB_le_pow — Upstream source (src/New/Congruences/FitTwistsExist.lean L90-L104)

lean
/-- Let `natB` be the weight `b` of the data `D` as a natural number, and `halfGap = r ^ 8`. The
product of the natural numbers `k` with `natB - 30 halfGap³ < k ≤ natB + 30 halfGap³` (truncated
subtraction), which enters the crystalline loss `crystallineLoss`, is at most
`(natB + 30 halfGap³) ^ (60 halfGap³)`. -/
lemma New.Selmer.prod_Ioc_natB_le_pow {P : Parameters} (D : Data P) :
    ∏ k ∈ Finset.Ioc (D.natB - 30 * D.halfGap ^ 3) (D.natB + 30 * D.halfGap ^ 3), k ≤
      (D.natB + 30 * D.halfGap ^ 3) ^ (60 * D.halfGap ^ 3) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:90-104 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=6b99cd31653faf6899bd0b708060273fcc49841f9f2c9cde778b2bc25218986e]

lemma New.Selmer.sum_defectBound_mul_log_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L106-L134)

lean
/-- Let `m` be the number of lifts, `r` the rank of the target, `k = r + 1 - m` the rank of the
source, `b = D.natB` the weight as a natural number, `h = D.halfGap = r ^ 8`, and `M = D.M` the
product of the two level primes. The local loss `defectBound D l` is
`10⁶ (m / k) (b v_l(M) + v_l((2 b)! Π ^ h³))`, where `v_l` is the `l`-adic valuation and `Π` is the
product of the positive integers in `(b - 30 h³, b + 30 h³]`. Summed over any finite set `T` of
primes `l` with weights `log l`, these losses are at most
`10⁶ (m / k) (b log M + log ((2 b)! (b + 30 h³) ^ (60 h⁶)))`. -/
lemma New.Selmer.sum_defectBound_mul_log_le {P : Parameters} (D : Data P) (T : Finset ℕ)
    (hT : ∀ l ∈ T, l.Prime) :
    ∑ l ∈ T, (defectBound D l : ℝ) * log l ≤
      10 ^ 6 * ((D.m : ℝ) / D.k) * (D.natB * log D.M +
        log ((2 * D.natB).factorial *
          ((D.natB + 30 * D.halfGap ^ 3) ^ (60 * D.halfGap ^ 3)) ^ D.halfGap ^ 3 : ℕ)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:106-134 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=17 body_sha256=f2c8a340d706f7b0739deeaa442e5f2e330383091fbfa2425404e2a3bd93123b]

lemma New.Selmer.sum_localDefectBound_mul_log_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L136-L155)

lean
/-- **Bound for the local loss.** The numbers `localDefectBound D l = 4 f · defectBound D l` have
`∑ localDefectBound D l · log l ≤ 4 · 10⁶ e¹⁸⁰ f (m / k) b log b` over every finite set `T` of
primes. Here `f` is the number of infinite places of `D.E`, `m` the number of lifts, `k = r + 1 - m`
the rank of the source, `b = exp D.logB` the weight, and `defectBound D l` is `10⁶ (m / k)` times a
sum of `l`-adic valuations of integers attached to `D`. -/
lemma New.Selmer.sum_localDefectBound_mul_log_le {P : Parameters} (D : Data P) (T : Finset ℕ)
    (hT : ∀ l ∈ T, l.Prime) :
    ∑ l ∈ T, (localDefectBound D l : ℝ) * log l ≤
      4 * 10 ^ 6 * exp 180 * (D.f * ((D.m : ℝ) / D.k) * D.b * D.logB) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:136-155 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=12 body_sha256=bd01a0d51833576eda145e3aebd12d30e4476572fef1fdb3a0e03c054d5c5667]

lemma New.Selmer.isNegligible_padicValNat_oddClassBound — Upstream source (src/New/Congruences/FitTwistsExist.lean L157-L176)

lean
/-- **The odd classes are few.** The integer `oddClassBound D` is at most `2 ^ (4 (N + t + 3) ^ 27)`
times the class number of `D.E`, for the cyclotomic conductor `N`. Its `l`-adic valuation bounds the
lengths of the groups of odd classes (`shaOdd`), Galois cohomology classes of `D.E` with
coefficients in Tate twists of `O/l^ν`. These valuations are negligible with the exponent `2000`:
with weights `log l` they sum to at most `D.x ^ 2000` over every finite set of primes. -/
lemma New.Selmer.isNegligible_padicValNat_oddClassBound {P : Parameters} (D : Data P) :
    D.IsNegligible 2000 fun l : ℕ ↦ padicValNat l (oddClassBound D) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:157-176 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=14 body_sha256=8f0ab6f0c242b3ea4a246632ad09a3e983cc8cc89f0fcc7f1ff47de8dcf88710]

lemma New.Selmer.isNegligible_twistError — Upstream source (src/New/Congruences/FitTwistsExist.lean L178-L190)

lean
/-- The numbers `twistError l D = (4 f + 3) r v_l(D.chosenGroupOrder) + 2⁻ˡ` are negligible with
the exponent `999`: with weights `log l` they sum to at most `D.x ^ 999` over every finite set of
primes. -/
lemma New.Selmer.isNegligible_twistError {P : Parameters} (D : Data P) :
    D.IsNegligible 999 fun l : ℕ ↦ twistError l D := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:178-190 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=d627eb57ad1d8b7f79087774369baa9071445ff6fb9e75daa96739982ca02b75]

lemma New.Selmer.isNegligible_denominatorError — Upstream source (src/New/Congruences/FitTwistsExist.lean L192-L213)

lean
/-- The error term `denominatorError D l` of the bound for the denominators of projections to lifts
is finite: it is an explicit combination of the `l`-adic valuations of `oddClassBound D`, the bound
for odd Galois cohomology classes, and `D.chosenGroupOrder`, the order of a product of general
linear groups over residue fields. These terms are negligible with the exponent `4000`: with weights
`log l` they sum to at most `D.x ^ 4000` over every finite set of primes. -/
lemma New.Selmer.isNegligible_denominatorError {P : Parameters} (D : Data P) :
    D.IsNegligible 4000 fun l : ℕ ↦ (denominatorError D l).toReal := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:192-213 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=16 body_sha256=60e8cf2704027a0802aa431dc4832fe49d0617609016b993f792a2c70b71ccb0]

lemma New.Selmer.isNegligible_padicValNat_card_stdClasses — Upstream source (src/New/Congruences/FitTwistsExist.lean L215-L228)

lean
/-- The `l`-adic valuations of the class number of `U(1)` at the level `D.chosenLevel` (the number
of double cosets `StdClasses`) are negligible with the exponent `30`: with weights `log l` they sum
to at most `D.x ^ 30` over every finite set of primes. -/
lemma New.Selmer.isNegligible_padicValNat_card_stdClasses {P : Parameters} (D : Data P) :
    D.IsNegligible 30 fun l : ℕ ↦
      padicValNat l (Nat.card (StdClasses (n := Unit) D.chosenLevel)) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:215-228 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=9 body_sha256=0ffaa972edb56ef073508b2b75ff8764f0cd6e242e3377001b6d8cbc69f11258]

lemma New.Selmer.sum_clearingBound_add_padicValNat_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L230-L260)

lean
/-- The number `clearingBound D l` is the bound for the exponent of `l` in the denominator of a
projection to lifts, per dimension and per unit of rank of the source: a sum of the local loss
`localDefectBound D l`, multiples of the twist and error terms, and the valuation of
`D.chosenGroupOrder`. The number of `StdClasses` at the level `D.chosenLevel` is the class number of
`U(1)` there. Summed over a finite set `T` of primes `l` with weights `log l`, the clearing bounds
and the `l`-adic valuations of this class number are at most
`D.denominatorBudget = D.errorUnit / (m k)`, for `m` the number of lifts and `k = r + 1 - m`. -/
lemma New.Selmer.sum_clearingBound_add_padicValNat_le {P : Parameters} (D : Data P) (T : Finset ℕ)
    (hT : ∀ l ∈ T, l.Prime) :
    ∑ l ∈ T, (clearingBound D l * log l +
      padicValNat l (Nat.card (StdClasses (n := Unit) D.chosenLevel)) * log l) ≤
        D.denominatorBudget := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:230-260 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=20 body_sha256=53420fd4673f0c5f08958ecc7ee2f4135523ecab17bd5b387a2d3a01a8736553]

lemma New.Selmer.isRepOfType_one — Upstream source (src/New/Congruences/FitTwistsExist.lean L262-L291)

lean
/-- A descent pair `O` consists of the data of a theta lift from a hermitian space `W` to one of
rank `#n`: a finite set of level places, a character of `U(1)` with its weight and tame part, and
the weight of the forms. Here `W` has rank one (index type `Unit`), and `O.ChosenIndex` indexes the
chosen places of `O`. The label of each chosen place, a polynomial over its residue field, is taken
to be `X - 1`. Then the trivial `ℓ`-adic representation of rank one satisfies `IsRepOfType`: it is
conjugate self-dual with the parameter `1`, meets the local conditions of `IsConjSelfDualOfLevel` at
all finite places (the level is `∅`) with the single jump `0` at each embedding of `D.E` in `ℂ`, and
inertia at each chosen place acts through the root of the label. -/
lemma New.Selmer.isRepOfType_one {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    [PadicIso ℓ] {n : Type} [Fintype n] (O : DescentPair D.E Unit n) :
    IsRepOfType O (Fintype.card Unit) (fun _ : D.E →+* ℂ ↦ {0})
      (fun _ : O.ChosenIndex ↦ Polynomial.X - 1) ∅ (1 : GalRep ℓ D.E Unit) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:262-291 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=19 body_sha256=1b6c0b3c9c66ea1f2a2432baac805a821c564b8aa07bc24104ebf4a622189a57]

lemma New.Selmer.exists_isMainSummand_mainPair — Upstream source (src/New/Congruences/FitTwistsExist.lean L293-L318)

lean
/-- A critical pair `(ν, z)` is a main pair for an index `1 ≤ j ≤ m` if `m < z ≤ r`, the tame part
of `ν` is `D.chiMLocal ^ j`, and the weight `-c` of `ν` has `w + r - t ≤ c ≤ w` at each infinite
place, for `w = D.liftWeight j`. Here `m` is the number of lifts, `r = D.r`, `t = D.t`, and
`D.chiMLocal` is the fixed family of residue characters that is trivial off the chosen places. The
data `lValueData` describe the theta lift of `ν`, untwisted, from `U(1)` to `U(2 z)`. Then there is
an `ℓ`-adic representation `T` of rank one that is a main summand (`IsMainSummand`) for this lift
and the constant system `1` of Hecke eigenvalues: `T` satisfies `IsMainSummandLike`, and for every
twist of the lift the Galois representations attached to lifted eigenforms have, up to
normalisation, the trace of the twisted `T` plus a string of characters. -/
lemma New.Selmer.exists_isMainSummand_mainPair {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    {ι : PadicIso ℓ} (p : {p : D.CriticalPair × D.LiftIndex // p.1.IsMainPair p.2}) :
    ∃ T : GalRep ℓ D.E Unit,
      IsMainSummand (p.val.1.lValueData p.prop.hasLiftRank (1 : D.Twist)).descentPair 1 T := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:293-318 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=14 body_sha256=b969fb62b2eb3d33771318d7ae3f9e34ac5c46074c6d6f1afcacdc2a0af2bd77]

theorem New.Selmer.range_goodLift_le_span_hasLiftHeckePolynomial — Upstream source (src/New/Congruences/FitTwistsExist.lean L320-L359)

lean
/-- **Splitting, pairs of rank `r`.** Let `ϑ` be a twist and `1 ≤ j ≤ m`. The map `D.goodLift ϑ j`
is the theta lift, for the data `D.descentPair ϑ j`, of the good forms on the rank `r` space
`W_j = D.spaceW j`; good forms have principal level at the chosen places and lie in the image of the
idempotent `D.e₀`. Its range, the space of lifts, is spanned by its forms `y` with two properties.
* There is a tuple `c` of labels, one polynomial over the residue field at each chosen place, that
  satisfies `IsLiftSetting`: each label has degree `r`, some label over each level prime is
  primitive, and no twisted label has the root `1`. The form `y` lies in the image of the idempotent
  of `c` (`typeProjection`), which is contained in that of `D.e₀`.
* There is a system `q (w, i)` of Hecke eigenvalues, one for each finite place `w` and number `i` of
  the Hecke operator, that occurs in a good form on `W_m`, such that at the split places outside the
  level the Hecke polynomial of `y` is that of a lift of `q`. -/
theorem New.Selmer.range_goodLift_le_span_hasLiftHeckePolynomial {P : Parameters} {D : Data P}
    (j : D.LiftIndex) (ϑ : D.Twist) :
    (D.goodLift ϑ j).range ≤ span ℂ {y ∈ (D.goodLift ϑ j).range |
      (∃ c : ∀ i : (D.descentPair ϑ j).ChosenIndex,
        (ResField ((D.descentPair ϑ j).chosenPlace i))[X],
        y ∈ (typeProjection (D.descentPair ϑ j) c).range ∧
        IsLiftSetting (D.descentPair ϑ j) c ϑ ∧
        (typeProjection (D.descentPair ϑ j) c).range ≤
          ((D.descentPair ϑ j).groupAlgAction D.e₀).range) ∧
      ∃ q : FinPlace D.E × ℕ → ℂ,
        D.goodForms (D.spaceW D.m) ⊓ D.eigenPart (D.spaceW D.m) q ≠ ⊥ ∧
        (D.descentPair ϑ j).HasLiftHeckePolynomial y fun (w : FinPlace D.E) (i : ℕ) ↦
          q (w, i)} := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:320-359 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=17 body_sha256=109ec395262c23fa2cdce369fc76a3190e82ba5caf22e22affc522ed41285c67]

lemma New.Selmer.exists_mFoldTwist_selmerLengthLe_inv_ratio_le — Upstream source (src/New/Congruences/FitTwistsExist.lean L361-L408)

lean
/-- **The twisting theorem for two families of main summands.** Let `ℓ` be a prime,
`ι : ℂ ≃ ℚ̄_ℓ`, and `e = twistError ℓ D = (4 f + 3) r v_ℓ(D.chosenGroupOrder) + 2 ^ (-ℓ)`, where
`f` is the number of infinite places of `D.E` and `D.chosenGroupOrder` the order of a product of
general linear groups over residue fields. Let `R a` and `R₁ b` be finitely many Galois
representations of rank `r` and one, each satisfying the conditions `IsMainSummandLike` on main
summands for some self-duality parameter `t` and some multisets `J` of Hodge–Tate jumps. There is a
twist `τ`, whose tame part has nontrivial powers up to `m` at each place of its modulus
(`MFoldTwist`), such that each power `ϑ = τ ^ j`, `1 ≤ j ≤ m`, has the following properties, where
`ψ = ϑ.invAvatar` is the `ℓ`-adic Galois character of `ϑ⁻¹`.
* The modulus `ϑ.Q` is auxiliary for the places dividing `ℓ p₀ p₁ N`, for the two level primes
  `p₀, p₁` and the level `N` (`badPlaces`): its places have prime norm, avoid these places and
  their conjugates, and no two are conjugate. The character `ψ` comes from the norm-one torus, and
  the valuations of `ψ σ - 1`, for tame generators `σ` at the places of `ϑ.Q`, sum to at most `e`
  (`IsAuxTwist`).
* For each given representation, some Galois element `γ` acts on a lattice in its twist by `ψ` as a
  scalar `ζ`, and the crystalline Selmer group of that lattice with coefficients in `Frac O / O`
  has length at most `e`, normalised so that `O / ℓ` has length one, for all large coefficient
  rings `O` (`HasDivisibleSelmerLengthLe`).
* For each pair `p = (ν, z)` ramified exactly at the chosen places and each sign `s`, the inverse of
  `p.ratio ϑ s = |L(z, (ν ϑ ^ s)⁻¹)| / |L(z, ν⁻¹)|`, a ratio of partial `L`-values, has norm at most
  `ℓ ^ e` at `ι`. -/
lemma New.Selmer.exists_mFoldTwist_selmerLengthLe_inv_ratio_le {P : Parameters} (D : Data P) {ℓ : ℕ}
    [ThePrime ℓ] (ι : PadicIso ℓ) {A B : Type} [Finite A] [Finite B]
    {R : A → GalRep ℓ D.E D.RowIndex} {R₁ : B → GalRep ℓ D.E Unit}
    (hR : ∀ a : A, ∃ (t : ℕ) (J : (D.E →+* ℂ) → Multiset ℤ), IsMainSummandLike D t J (R a))
    (hR₁ : ∀ b : B, ∃ (t : ℕ) (J : (D.E →+* ℂ) → Multiset ℤ), IsMainSummandLike D t J (R₁ b)) :
    ∃ τ : D.MFoldTwist, ∀ j : D.LiftIndex,
      let ϑ : D.Twist := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:361-408 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=21 body_sha256=44efb89fe62d1ce2d4120e132f11dd79986bbf7aa8f81a90c8ac43f3a7ac06d0]

lemma New.Selmer.denominatorLe_range_goodLift — Upstream source (src/New/Congruences/FitTwistsExist.lean L410-L439)

lean
/-- **Denominator for the space of lifts.** Let the modulus of the twist `ϑ` be auxiliary and its
ramification at most `twistError ℓ D` (`IsAuxTwist`). Suppose that every Hecke eigensystem `q` of
good forms on `W_m = D.spaceW D.m` has a main summand for the `j`-th descent pair of the trivial
twist `TameChar.one`. That is, there is a Galois representation `R` giving the traces attached to
all twisted lifts of `q` (`IsMainSummand`), and the twist of `R` by `ϑ⁻¹` has a short Selmer group
with divisible coefficients. Let `Z = (D.goodLift ϑ j).range` be the space of lifts for `ϑ` and `j`,
and let `r` be the size of `D.RowIndex`, the rank of `W_m`. Then some operator with determinant of
norm at least `ℓ ^ (-(dim Z · r · clearingBound D ℓ))` clears the denominators of the projection to
`Z` on integral forms orthogonal to the false lifts for the idempotent `D.e₀` of the good forms
(`DenominatorLe`). -/
lemma New.Selmer.denominatorLe_range_goodLift {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    (ι : PadicIso ℓ) {ϑ : D.Twist} (j : D.LiftIndex)
    (h_aux : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D))
    (h_summand : ∀ q : FinPlace D.E × ℕ → ℂ,
      D.goodForms (D.spaceW D.m) ⊓ D.eigenPart (D.spaceW D.m) q ≠ ⊥ →
      ∃ R : GalRep ℓ D.E D.RowIndex,
        IsMainSummand (D.descentPair TameChar.one j) (fun (w : FinPlace D.E) (i : ℕ) ↦ q (w, i)) R ∧
        ∃ γ : AbsGal D,
          HasDivisibleSelmerLengthLe ϑ.invAvatar R ϑ.Q γ (twistError ℓ D)) :
    DenominatorLe ι.ιℓ (D.descentPair ϑ j) D.e₀ (D.goodLift ϑ j).range
      (clearingBound D ℓ * log ℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:410-439 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=10 body_sha256=6563eb50bed727264dd6fc59045f909fa1d36495a6ed5d79237afbde592d94db]

lemma New.Selmer.denominatorLe_span_trivialLift — Upstream source (src/New/Congruences/FitTwistsExist.lean L441-L469)

lean
/-- **Denominator for the line of a main pair.** Let the modulus of the twist `ϑ` be auxiliary and
its ramification at most `twistError ℓ D` (`IsAuxTwist`). Let `p = (ν, z)` be a main pair for `j`
(`IsMainPair`), with `lValueData` the data of the theta lift of `ν ϑ` from `U(1)` to `U(2 z)` and
`trivialLift` the lifted form. Let `R` be a main summand for the untwisted lift and the trivial
eigensystem whose twist by `ϑ⁻¹` has a short Selmer group with divisible coefficients. Then an
operator with determinant of norm at least `ℓ ^ (-clearingBound D ℓ)` clears the denominators of the
projection to the line of `trivialLift` on integral forms orthogonal to the false lifts for the
idempotent of the labels `X - 1` at the chosen places (`DenominatorLe`). -/
lemma New.Selmer.denominatorLe_span_trivialLift {P : Parameters} {D : Data P} {ℓ : ℕ} [ThePrime ℓ]
    (ι : PadicIso ℓ) {ϑ : D.Twist} {p : D.CriticalPair} {j : ℕ} (hp : p.IsMainPair j)
    (h_aux : IsAuxTwist (badPlaces D ℓ) ϑ.Q ϑ.invAvatar (twistError ℓ D)) {R : GalRep ℓ D.E Unit}
    (hR : IsMainSummand (p.lValueData hp.hasLiftRank (1 : D.Twist)).descentPair 1 R)
    (h_selmer : ∃ γ : AbsGal D,
      HasDivisibleSelmerLengthLe ϑ.invAvatar R ϑ.Q γ (twistError ℓ D)) :
    open scoped Classical in
    DenominatorLe ι.ιℓ (p.lValueData hp.hasLiftRank ϑ).descentPair
      (tupleIdem Unit fun _ : (p.lValueData hp.hasLiftRank ϑ).descentPair.ChosenIndex ↦
        Polynomial.X - 1)
      (ℂ ∙ (p.lValueData hp.hasLiftRank ϑ).trivialLift) (clearingBound D ℓ * log ℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:441-469 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=11 body_sha256=2de181ef5289d1acbbca1beab00d284970949953499a52c1045149ba76831b87]

lemma New.Selmer.exists_mFoldTwist_hasDenominatorsLe — Upstream source (src/New/Congruences/FitTwistsExist.lean L471-L518)

lean
/-- **A twist with few congruences at one prime.** For a prime `ℓ` and `ι : ℂ ≃ ℚ̄_ℓ` there is an
`m`-fold twist `τ` (`D.MFoldTwist`) with three properties, where `ϑ = τ ^ j` (`τ.powTwist j`) and
`j : D.LiftIndex`, so `1 ≤ j ≤ m`. The product `τ.normQ` of the norms of the places in the set `Q`
of `τ` is prime to `ℓ`. Take each ramified pair `p = (ν, z)` (`p.IsRamified`: the tame part of `ν`
is nontrivial exactly at the places dividing `D.piM`, of norm `p₀ p₁`) and each sign `s`. The
inverse of `p.ratio ϑ s = |L(z, (ν ϑ ^ s)⁻¹)| / |L(z, ν⁻¹)|` (partial `L`-values) has norm at most
`ℓ ^ e` under `ι.ιℓ`, where `e = twistError ℓ D = (4 f + 3) r v_ℓ(D.chosenGroupOrder) + 2 ^ (-ℓ)`.
For each `j`, `D.HasDenominatorsLe ι.ιℓ ϑ j β` holds, with `exp β` equal to `ℓ ^ clearingBound D ℓ`
times the `ℓ`-part of the number of classes `StdClasses` of `U(1)` at level `D.chosenLevel`. -/
lemma New.Selmer.exists_mFoldTwist_hasDenominatorsLe {P : Parameters} (D : Data P) {ℓ : ℕ}
    [ThePrime ℓ] (ι : PadicIso ℓ) :
    ∃ τ : D.MFoldTwist, ℓ.Coprime τ.normQ ∧
      (∀ (j : D.LiftIndex) (p : D.CriticalPair) (s : ℤˣ), p.IsRamified →
        ‖ι.ιℓ (p.ratio (τ.powTwist j) s)⁻¹‖ ≤ exp (twistError ℓ D * log ℓ)) ∧
      ∀ j : D.LiftIndex, D.HasDenominatorsLe ι.ιℓ (τ.powTwist j) j (clearingBound D ℓ * log ℓ +
        padicValNat ℓ (Nat.card (StdClasses (n := Unit) D.chosenLevel)) * log ℓ) := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:471-518 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=33 body_sha256=9503815b73eac75f56623bcf044900c9808d1c4e49ed971818fb3ebd7d4813f1]

lemma New.exists_isRegularFamily — Upstream source (src/New/Congruences/FitTwistsExist.lean L520-L543)

lean
/-- **Twists with few congruences.** All data `D` have a regular family of `m`-fold twists `θ κ`,
one for each pair `κ` of a prime `ℓ` and an isomorphism `ℂ ≃ ℚ̄_ℓ`. The modulus of `θ κ` is prime to
`ℓ`. -/
lemma New.exists_isRegularFamily {P : Parameters} (D : Data P) :
    ∃ θ : PrimePadicIso → D.MFoldTwist, D.IsRegularFamily θ := by
  sorry -- [EXTRACTED_STUB upstream=src/New/Congruences/FitTwistsExist.lean:520-543 commit=41c2716658c42ba08eb0648994a2efe83082a95c body_lines=20 body_sha256=7dc9514fd6312e16ba99229ea83d603b4eab77580f87aaa0a81aa51b242439ae]

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.
crystalline dual defect
The normalized length of crystalline cocycles of a summand's Tate dual modulo those cup-orthogonal to congruent lattices, uniformly bounded at every prime l by [G_l : Gamma] * rank(L_c) * defectBound(D, l) / x and summing across all primes well inside D.denominatorBudget.
Galois main summand
The fixed, twist-independent rank-r (or rank-1) l-adic Galois representation R extracted from a Hecke eigensystem whose trace, after twisting by theta^(-1) and adding the inverse-cyclotomic string sum_{e < t} chi_cyc^(-e), matches every twisted theta lift.
anticyclotomic Selmer twisting
Choosing one finite-order anticyclotomic m-fold twist tau on auxiliary places Q so that all powers xi = tau^j (1 <= j <= m) simultaneously keep ramification, divisible crystalline Selmer lengths of finitely many main summands, and all ramified Hecke L-value ratio valuations within twistError l D = (4f + 3)r v_l(chosenGroupOrder) + 2^(-l).
Hecke L-value ratio
The ratio |L^S(z, (nu * theta^s)^-1)| / |L^S(z, nu^-1)| of twisted to untwisted partial Hecke L-values at a critical pair (nu, z), tracking how Siegel–Weil exchange constants scale under twisting across chain quotients and grid turns.
regular twist family
A prime-by-prime family of m-fold anticyclotomic twists theta(iota) with modulus coprime to l, inverse L-value ratios of height at most x_1, and lift/projection denominators summing within f*a*(log b)^3 / (m*k).
Taylor–Wiles prime triangle
An upper-triangular family of auxiliary primes Q_j (norm 1 mod l^nu) ordered by Tate-twist exponent e in (0, t') whose Frobenius and tame-inertia Kummer reciprocity laws eliminate every even Tate-twist cohomology class algebraically—bypassing Vandiver's conjecture—while preserving weak-lift root chains.
Ribet clearing operator
A linear operator Lambda on the theta-lift subspace Z built from a common Ribet element and Taylor–Wiles tie relations whose eigenvalues satisfy liftValuationBound and whose rescaled determinant norm is at least l^(-dim Z * r * clearingBound D l), clearing all l-adic projection denominators on integral forms orthogonal to false lifts.
false-lift period
The theta period over a complementary block I_l of an algebraic form Xi that mimics a lift in level and Hecke eigenvalue yet sits orthogonal to true lifts—forced to vanish by climbing a hyperbolic-plane descent tower when 2r + 2N + 3 < n.
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.