Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions of Tests.Regression

Definition
TypeDensity_Tests_Regression

by asving · Oct 16, 2026 · Mathlib 0df444a (Lean v4.33.1)

type-density

Regression guards for the universal density expressions

Pins the statement-level definitions of TypeDensity.Basic (the recursion stateLaw, the global laws and the universal expressions monicExpr n σ, projectiveExpr n σ) to independently known numbers, and turns them, via TypeDensity.main_dvr, into explicit density statements. Any change to the definitions that alters these values breaks this file.

Main results

  • TypeDensity.Tests.monicExpr_two_eval, TypeDensity.Tests.projectiveExpr_two_eval: the quadratic expressions as rational functions of q > 1.
  • TypeDensity.Tests.monicExpr_three_eval: the cubic monic expressions for q > 1.
  • TypeDensity.Tests.monicExpr_four_eval_two, TypeDensity.Tests.projectiveExpr_four_eval_two: all quartic values at q = 2.
  • Point values, e.g. TypeDensity.Tests.monicExpr_three_totally_ramified_eval_three (10/121), TypeDensity.Tests.monicExpr_four_totally_ramified_eval_two (107/1533), TypeDensity.Tests.projectiveExpr_four_totally_ramified_eval_two (856/15841).
  • Density corollaries, e.g. TypeDensity.Tests.monicDensity_two_ramified (1/(q+1) over every complete DVR with residue field of order q), TypeDensity.Tests.monicDensity_four_totally_ramified_of_card_eq_two, and the end-to-end TypeDensity.Tests.monicDensity_powerSeries_zmod_two_four_totally_ramified over 𝔽₂⟦X⟧.

Implementation notes

The expressions are not computable by brute force (allowedPatterns filters a Fintype of size about 5^19 with classical decidability), so the values are computed by unfolding the recursion state by state: the coefficient algebra of laws, a one-step unfolding of stateLaw (re-derived here: fuel stability and the rank decrease of children), explicit enumerations of the allowed tangent and residue patterns (children lists are computed by decide through an explicit enumeration of the cells), and the laws of the small states S(a;1), S(a;2), T(a,b;1,h), T(a,b;c,1), T(1,1;2,2), S(1;3) and (at q = 2) S(1;4). Final identities are checked as linear combinations of type indicators. All of this is private and depends only on TypeDensity.Basic (plus main_dvr for the corollaries).

Provenance: port of the certified Prove2Me theorems SurfaceBlowupV2.{quadratic_monic_formula, quadratic_projective_formula, cubic_monic_formula, quartic_monic_law_at_two, quartic_projective_law_at_two} and their point-value corollaries, with their helper closure.

Definition code
-- Generated by the TypeDensity exporter from Tests/Regression.lean (namespace TypeDensity); do not edit.
import Definitions.Def_TypeDensity_Basic
import Definitions.Def_TypeDensity_Blowup_Directions
import Definitions.Def_TypeDensity_Measure_AdicCylinders
import Definitions.Def_TypeDensity_Formula_LawAlgebra
import Definitions.Def_TypeDensity_Measure_HenselProducts
import Definitions.Def_TypeDensity_Surfaces_Lengths
import Definitions.Def_TypeDensity_Surfaces_PowerSeries
import Definitions.Def_TypeDensity_Formula_FiniteFieldCounts
import Definitions.Def_TypeDensity_Formula_StateCombinatorics
import Definitions.Def_TypeDensity_Formula_PatternCounts
import Definitions.Def_TypeDensity_Unramified_Extension
import Definitions.Def_TypeDensity_Blowup_Charts
import Definitions.Def_TypeDensity_Algebra_AlgebraType
import Definitions.Def_TypeDensity_Measure_PrimitiveLocus
import Definitions.Def_TypeDensity_Algebra_FactorInvariant
import Definitions.Def_TypeDensity_Surfaces_TruncatedSeries
import Definitions.Def_TypeDensity_Blowup_TwoChartCurveData
import Definitions.Def_TypeDensity_Surfaces_ConcreteAtlas
import Definitions.Def_TypeDensity_Recursion_Members
import Definitions.Def_TypeDensity_Measure_MemberCharts
import Definitions.Def_TypeDensity_Recursion_Termination
import Definitions.Def_TypeDensity_Recursion_OrderDefect
import Definitions.Def_TypeDensity_Assembly_NullBridges
import Definitions.Def_TypeDensity_Assembly_TypeEvents
import Definitions.Def_TypeDensity_Assembly_MonicCells
import Definitions.Def_TypeDensity_Blowup_DivisorPoints
import Definitions.Def_TypeDensity_Measure_MemberBoxes
import Definitions.Def_TypeDensity_Recursion_ChildMembers
import Definitions.Def_TypeDensity_Recursion_RootCellLaw
import Definitions.Def_TypeDensity_Reciprocity_Defs
import Definitions.Def_TypeDensity_Reciprocity_Quantum
import Definitions.Def_TypeDensity_Reciprocity_Patterns
import Definitions.Def_TypeDensity_Tests_NonVacuity
import Mathlib.FieldTheory.RatFunc.Basic
import Mathlib.MeasureTheory.Measure.Haar.Unique
import Mathlib.NumberTheory.ArithmeticFunction.Moebius
import Mathlib.NumberTheory.Padics.PadicIntegers
import Mathlib.RingTheory.IntegralClosure.IntegralRestrict
import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.RingTheory.RamificationInertia.Basic
import Mathlib.Topology.Algebra.Nonarchimedean.AdicTopology
import Mathlib.Topology.Algebra.MvPolynomial
import Mathlib.FieldTheory.Finite.GaloisField
import Mathlib.RingTheory.AdicCompletion.Algebra
import Mathlib.RingTheory.RegularLocalRing.Defs
import Mathlib.Algebra.Group.Pi.Units
import Mathlib.Order.CompletePartialOrder
import Mathlib.RingTheory.Henselian
import Mathlib.RingTheory.Polynomial.Resultant.Basic
import Mathlib.RingTheory.SimpleRing.Principal
import Mathlib.FieldTheory.Finite.Extension
import Mathlib.RingTheory.AdicCompletion.Noetherian
import Mathlib.RingTheory.MvPowerSeries.Equiv
import Mathlib.RingTheory.PicardGroup
import Mathlib.FieldTheory.RatFunc.AsPolynomial
import Mathlib.RingTheory.AdicCompletion.Completeness
import Mathlib.Algebra.GroupWithZero.Submonoid.CancelMulZero
import Mathlib.Algebra.Module.StablyFree.Basic
import Mathlib.NumberTheory.Padics.RingHoms
import Mathlib.Algebra.Azumaya.Basic
import Mathlib.RingTheory.AdicCompletion.RingHom
import Mathlib.RingTheory.TotallySplit
import Mathlib.RingTheory.AdicCompletion.LocalRing
import Mathlib.RingTheory.KrullDimension.NonZeroDivisors
import Mathlib.Algebra.Group.NatPowAssoc
import Mathlib.Algebra.Order.Ring.Star
import Mathlib.Data.Int.Star
import Mathlib.LinearAlgebra.Dimension.Torsion.Finite
import Mathlib.RingTheory.PowerSeries.Expand
import Mathlib.RingTheory.PowerSeries.Log
import Mathlib.RingTheory.PowerSeries.PiTopology
import Mathlib.Data.Finsupp.Encodable
import Mathlib.Topology.Connected.Separation
import Mathlib.Topology.Instances.ZMod
import Mathlib.Topology.Separation.Lemmas
set_option autoImplicit false

set_option autoImplicit false

open scoped BigOperators ENNReal

namespace TypeDensity.Tests

section Coefficients

/-- The coefficient of `σ` in the law `M` with all types shifted by `τ`. -/
noncomputable def shiftedCoeff (q : ℚ) (M : Law) (τ σ : FactorType) : ℚ :=
  (M.map fun w ↦ if τ + w.1 = σ then w.2.eval q else 0).sum

/-- The indicator `[σ = K]`. -/
def indicator (σ K : FactorType) : ℚ := if σ = K then 1 else 0

end Coefficients

section Patterns

/-- The pattern with the single nonzero entry `v` at `ij₀`. -/
def spat {n : ℕ} (ij₀ : Fin n × Fin n) (v : Fin (n + 1)) : Pattern n :=
  fun ij ↦ if ij = ij₀ then v else 0

/-- `otherChildren` with an explicit enumeration of the cells (computable by `decide`). -/
def otherChildrenList {n : ℕ} (a : ℕ) (m : Pattern n) : List (ℕ × State) :=
  (List.finRange n ×ˢ List.finRange n).flatMap fun ij ↦
    List.replicate (m ij).val (ij.1.val+1, State.single a (ij.2.val+1))

/-- The product of the descended laws of a list of children. -/
noncomputable def childProd (l : List (ℕ × State)) : Law :=
  lawProd (l.map fun z ↦ lawDescend z.1 (stateLaw z.2))

end Patterns

section Recursion

open scoped Classical in
/-- The recursion sum of a state with fuel `k` for the children. -/
noncomputable def exitLawFuel (k : ℕ) (s : State) : Law :=
  (allowedPatterns s).toList.flatMap fun P ↦
    if SelfPattern s P then [] else
      lawScale (.mul (tangentCount s P) (divisorProbability s P.d.val))
        (lawProd ((children s P).map fun z ↦ lawDescend z.1 (stateLawFuel k z.2)))

open scoped Classical in
/-- The non-self part of the recursion sum of a state, with the children's laws `stateLaw`. -/
noncomputable def exitLaw (s : State) : Law :=
  (allowedPatterns s).toList.flatMap fun P ↦
    if SelfPattern s P then [] else
      lawScale (.mul (tangentCount s P) (divisorProbability s P.d.val))
        (lawProd ((children s P).map fun z ↦ lawDescend z.1 (stateLaw z.2)))

/-- One step of the fuelled recursion at a non-terminal state `s`: the recursion sum
`exitLawFuel k s`, scaled by `(1 - returnWeight c)⁻¹` when `s` is a single state of contact `c`. -/
noncomputable def stateLawFuelStep (k : ℕ) (s : State) : Law :=
  match s with
  | .single _ c => lawScale (.inv (.sub (.const 1) (returnWeight c))) (exitLawFuel k s)
  | .crossing _ _ _ _ => exitLawFuel k s

end Recursion

section DegreeThree

/-- One rational point of contact three (the self pattern of `S(1;3)`). -/
abbrev m3Contact : Pattern 3 := fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 2 then 1 else 0

/-- One point of degree three. -/
abbrev m3Inert : Pattern 3 := fun ij ↦ if ij.1.val = 2 ∧ ij.2.val = 0 then 1 else 0

/-- Two rational points, of contacts one and two. -/
abbrev m3Tangent : Pattern 3 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else if ij.1.val = 0 ∧ ij.2.val = 1 then 1 else 0

/-- A rational point and a point of degree two. -/
abbrev m3Quadratic : Pattern 3 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else if ij.1.val = 1 ∧ ij.2.val = 0 then 1 else 0

/-- Three rational points. -/
abbrev m3Split : Pattern 3 := fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 3 else 0

open scoped Classical in
def allowedThree : Finset (TangentPattern (State.single 1 3).degree) :=
  {⟨1, 1, 0, fun _ ↦ 0⟩, ⟨2, 2, 0, fun _ ↦ 0⟩,
    ⟨2, 1, 0, fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else 0⟩, ⟨3, 0, 0, m3Inert⟩,
    ⟨3, 0, 0, m3Quadratic⟩, ⟨3, 0, 0, m3Tangent⟩, ⟨3, 0, 0, m3Split⟩, ⟨3, 0, 0, m3Contact⟩}

end DegreeThree

section DegreeFour

/-- One rational point of contact four (the self pattern of `S(1;4)`). -/
abbrev m4Contact : Pattern 4 := fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 3 then 1 else 0

/-- One point of degree two and contact two. -/
abbrev m4QuadraticContact : Pattern 4 := fun ij ↦
  if ij.1.val = 1 ∧ ij.2.val = 1 then 1 else 0

/-- One point of degree four. -/
abbrev m4Inert : Pattern 4 := fun ij ↦ if ij.1.val = 3 ∧ ij.2.val = 0 then 1 else 0

/-- A rational point of contact two and a point of degree two. -/
abbrev m4TangentQuadratic : Pattern 4 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 1 then 1 else if ij.1.val = 1 ∧ ij.2.val = 0 then 1 else 0

/-- Two rational points of contact two. -/
abbrev m4TwoTangent : Pattern 4 := fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 1 then 2 else 0

/-- Two points of degree two. -/
abbrev m4TwoQuadratic : Pattern 4 := fun ij ↦
  if ij.1.val = 1 ∧ ij.2.val = 0 then 2 else 0

/-- A rational point and a rational point of contact three. -/
abbrev m4ContactThree : Pattern 4 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else if ij.1.val = 0 ∧ ij.2.val = 2 then 1 else 0

/-- A rational point and a point of degree three. -/
abbrev m4Cubic : Pattern 4 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else if ij.1.val = 2 ∧ ij.2.val = 0 then 1 else 0

/-- Two rational points and a rational point of contact two. -/
abbrev m4SplitTangent : Pattern 4 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 2 else if ij.1.val = 0 ∧ ij.2.val = 1 then 1 else 0

/-- Two rational points and a point of degree two. -/
abbrev m4SplitQuadratic : Pattern 4 := fun ij ↦
  if ij.1.val = 0 ∧ ij.2.val = 0 then 2 else if ij.1.val = 1 ∧ ij.2.val = 0 then 1 else 0

/-- Four rational points. -/
abbrev m4Split : Pattern 4 := fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 4 else 0

open scoped Classical in
/-- The allowed patterns of `S(1;4)`. -/
def allowedFour : Finset (TangentPattern (State.single 1 4).degree) :=
  {⟨1, 1, 0, fun _ ↦ 0⟩, ⟨2, 2, 0, fun _ ↦ 0⟩,
    ⟨2, 1, 0, fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else 0⟩, ⟨3, 3, 0, fun _ ↦ 0⟩,
    ⟨3, 2, 0, fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 1 else 0⟩,
    ⟨3, 1, 0, fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 0 then 2 else 0⟩,
    ⟨3, 1, 0, fun ij ↦ if ij.1.val = 0 ∧ ij.2.val = 1 then 1 else 0⟩,
    ⟨3, 1, 0, fun ij ↦ if ij.1.val = 1 ∧ ij.2.val = 0 then 1 else 0⟩,
    ⟨4, 0, 0, m4Split⟩, ⟨4, 0, 0, m4SplitTangent⟩, ⟨4, 0, 0, m4SplitQuadratic⟩,
    ⟨4, 0, 0, m4ContactThree⟩, ⟨4, 0, 0, m4Cubic⟩, ⟨4, 0, 0, m4TwoTangent⟩,
    ⟨4, 0, 0, m4TangentQuadratic⟩, ⟨4, 0, 0, m4TwoQuadratic⟩, ⟨4, 0, 0, m4QuadraticContact⟩,
    ⟨4, 0, 0, m4Inert⟩, ⟨4, 0, 0, m4Contact⟩}

end DegreeFour

end TypeDensity.Tests

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me