Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Residue criterion.

Proved
Computation.DegreeMonoid.mem_iff_residue_le

by raver1975 · Sep 13, 2026 · Mathlib c5ea003 (Lean v4.30.0)

aether-catalogspeculative

Residue criterion. If b < p is the residue of n (i.e. b*q ≡ n (mod p)), then n lies in ⟨p,q⟩ exactly when b*q ≤ n.

theorem Computation.DegreeMonoid.mem_iff_residue_le(cop : Nat.Coprime p q) {n b : ℕ} (hb : b < p)
    (hdvd : (p : ℤ) ∣ (n : ℤ) - (b : ℤ) * (q : ℤ)) :
    n ∈ AddSubmonoid.closure ({p, q} : Set ℕ) ↔ b * q ≤ n := by sorry

Formalization Note Transplanted verbatim from the Aether Catalog source Speculative/AutoResearch/DegreeMonoidSylvester.lean; the statement is byte-identical to the source declaration, elaborated with autoImplicit disabled in the platform environment.

Preamble
-- Thm stub generated from Speculative/AutoResearch/DegreeMonoidSylvester.lean
import Mathlib
import Definitions.Def_Speculative_AutoResearch_DegreeMonoidRealisation
import Definitions.Def_Speculative_AutoResearch_DegreeMonoidStructure
/-
# Sylvester's gap count for two-loop machines

`Computation.DegreeMonoidStructure` shows that the two-loop chain machine of coprime
`p, q > 1` has a largest unrealisable computation length `p*q - p - q` (the Frobenius
number).  This file computes the *whole* obstruction, not just its maximum: the number of
computation lengths that the machine cannot realise is exactly `(p-1)*(q-1)/2`
(`sylvester_gap_ncard`), Sylvester's classical count, here proved from scratch through:

* `mem_pair_closure_iff` — membership in `⟨p,q⟩` as a two-variable representation problem;
* `exists_residue` / `mem_iff_residue_le` — the **residue criterion**: writing `b` for the
  unique residue in `[0,p)` with `b*q ≡ n (mod p)`, one has `n ∈ ⟨p,q⟩ ↔ b*q ≤ n`;
* `frobenius_symmetry` — the **symmetry of the numerical semigroup**: for `0 ≤ n ≤ F` exactly
  one of `n` and `F - n` is realisable (this is the statement that `⟨p,q⟩` is a symmetric
  numerical semigroup);
* the resulting involution `n ↦ F - n` pairs gaps with non-gaps below `F`, giving the count.

All results are proved with no `sorry`.
-/

open Computation
open DegreeMonoid


variable {p q : ℕ}
Formal statement
theorem Computation.DegreeMonoid.mem_iff_residue_le(cop : Nat.Coprime p q) {n b : ℕ} (hb : b < p)
    (hdvd : (p : ℤ) ∣ (n : ℤ) - (b : ℤ) * (q : ℤ)) :
    n ∈ AddSubmonoid.closure ({p, q} : Set ℕ) ↔ b * q ≤ n := by sorry
Source
https://github.com/paulklemstine/Lean/blob/53c2925a02/Catalog/Speculative/AutoResearch/DegreeMonoidSylvester.lean#L58

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