Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions of TypeDensity.Formula.LawAlgebra

Definition
TypeDensity_Formula_LawAlgebra

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

type-density

Expression and law algebra, children of tangent patterns

Basic algebra of the formal expressions Expr (evaluation and safety of sums, products, powers, substitutions, rational fractions) and of the formal laws Law (coefficients of products, scalings, descents and flat maps), together with the elementary combinatorics of the children of a tangent pattern and a handful of algebraic and topological facts used throughout (coordinate cylinders, coprimality of reductions, ramification of local extensions, finiteness of types of bounded degree).

Main results

  • TypeDensity.children_degree_identity: ∑ e · deg(child) = deg(s) over the children.
  • TypeDensity.children_valid: children of a valid state are valid.
  • TypeDensity.expression_fraction: evaluating a safe expression via its fraction.
  • TypeDensity.lawInterp_lawMul, TypeDensity.lawInterp_lawProd: the interpretation of a law in a monoid algebra (shared by the numerical and the rational-function readings) is multiplicative.
  • TypeDensity.law_coeff_mul, TypeDensity.law_coeff_prod_formula, TypeDensity.law_coeff_prod_descend: coefficient formulas for products of laws.
  • TypeDensity.law_coeff_nonneg_closure: nonnegativity of coefficients is preserved by the law operations.
  • TypeDensity.coordinate_cylinder_clopen: congruence cylinders are clopen.
  • TypeDensity.finite_flat_local_ramification_degree: e · f = rank for finite flat local extensions.

Provenance: Def_SurfaceBlowupV2_StateContact and Thm_SurfaceBlowupV2_* for children_degree_identity, children_residue_degree_pos, child_degree_le, children_valid, coordinate_cylinder_clopen, coprime_of_monic_reduction_one, density_value_arith, divisor_count_safe, expression_{fraction, pow_eval, pow_safe, prod_eval, regular, subst_eval, subst_safe, sum_eval, sum_safe}, divisor_probability_safe, finite_flat_local_ramification_degree, finite_types_of_degree, geometric_exit_sum, image_measurable_of_continuousOn_injOn_compact, integral_local_extension_unique_prime, law_coeff_{descend, flatMap, mul, prod_descend, prod_formula, scale, nonneg_closure}, law_safe_{descend, mul, scale}, list_get_fiber_card, monic_polynomial_degree, other_children_count, prime_power_ge_two, projective_normalizer_positive, rank_lt_of_degree_lt.

Definition code
-- Generated by the TypeDensity exporter from TypeDensity/Formula/LawAlgebra.lean (namespace TypeDensity); do not edit.
import Definitions.Def_TypeDensity_Basic
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.FieldTheory.Finite.GaloisField
import Mathlib.RingTheory.AdicCompletion.Algebra
import Mathlib.RingTheory.RegularLocalRing.Defs
set_option autoImplicit false

open scoped BigOperators ENNReal

namespace TypeDensity

namespace State

/-- The contact of a state with the old boundary t = 0 (paper: c in S(a;c) and T(a,b;c,h));
for a child produced by one blowup step this is its contact r_P with the exceptional divisor E,
equation (5.1). -/
def firstContact : State → ℕ
  | .single _ c => c
  | .crossing _ _ c _ => c

end State

/-- Evaluation of a formal power: `(x ^ n)(q) = x(q) ^ n`. -/
theorem expression_pow_eval (x : Expr) (q : ℚ) (n : ℕ) :
    (x.pow n).eval q = (x.eval q)^n := by
  induction n with
  | zero => simp [Expr.pow, Expr.eval]
  | succ n ih => simp [Expr.pow, Expr.eval, ih, pow_succ]

/-- Evaluation of a formal sum is the sum of the evaluations. -/
theorem expression_sum_eval (xs : List Expr) (q : ℚ) :
    (Expr.sum xs).eval q = (xs.map (Expr.eval q)).sum := by
  induction xs <;> simp_all [Expr.sum, Expr.eval]

/-- The interpretation of a law along a valuation `v` of expressions, as the element
`Σ_{z ∈ L} v(z.2) · Z^{z.1}` of the monoid algebra `S[FactorType]`. Numerical evaluation at `q`
and the rational-function interpretation of the reciprocity branch are both of this form. -/
noncomputable def lawInterp {S : Type*} [Semiring S] (v : Expr → S) (L : Law) :
    AddMonoidAlgebra S FactorType :=
  (L.map fun z ↦ AddMonoidAlgebra.single z.1 (v z.2)).sum

/-- There are finitely many valid factorization types of a given degree. -/
theorem finite_types_of_degree (n : ℕ) :
    Set.Finite {σ : FactorType | ValidType σ ∧ typeDegree σ = n} := by
  set s : Finset (ℕ × ℕ) := Finset.range (n+1) ×ˢ Finset.range (n+1)
  refine Set.Finite.subset ((n • s.val).powerset.toFinset.finite_toSet) ?_
  rintro σ ⟨hv, hd⟩
  simp only [Multiset.mem_toFinset, Multiset.mem_powerset, Finset.mem_coe]
  have hmem : ∀ z ∈ σ, z.1 * z.2 ≤ n := fun z hz ↦ hd ▸
    Multiset.le_sum_of_mem (Multiset.mem_map_of_mem (fun z : ℕ × ℕ ↦ z.1 * z.2) hz)
  have hcard : Multiset.card σ ≤ n := by
    rw [← hd, typeDegree]
    have : Multiset.card (σ.map fun z ↦ z.1 * z.2) • 1 ≤ (σ.map fun z ↦ z.1 * z.2).sum :=
      Multiset.card_nsmul_le_sum fun x hx ↦ by
        obtain ⟨z, hz, rfl⟩ := Multiset.mem_map.1 hx
        exact Nat.one_le_iff_ne_zero.2 (Nat.mul_ne_zero (hv z hz).1.ne' (hv z hz).2.ne')
    simpa using this
  refine Multiset.le_iff_count.2 fun z ↦ ?_
  rw [Multiset.count_nsmul]
  by_cases hz : z ∈ σ
  · have h1 := hv z hz
    have h2 := hmem z hz
    have hzs : z ∈ s := by
      have := Nat.le_mul_of_pos_right z.1 h1.2
      have := Nat.le_mul_of_pos_left z.2 h1.1
      simp only [s, Finset.mem_product, Finset.mem_range]
      omega
    rw [Multiset.count_eq_one_of_mem s.nodup hzs, mul_one]
    exact (Multiset.count_le_card _ _).trans hcard
  · simp [Multiset.count_eq_zero_of_notMem hz]

end TypeDensity

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