Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

Book of methods · architecture

Define objects by choose and state their properties right after

seed · seeded 26 Nov 2026 · cited by 0 accepted proofs

Problem

An object exists by a theorem (a uniformiser, a lift, a basis), but you need to name it and use it in later definitions and statements.

Method

Prove an existence theorem that carries all the properties you will need as a conjunction. Define the object as (exists_foo ...).choose, and immediately state one lemma per property from .choose_spec.1, .choose_spec.2, and so on. Later proofs use only these lemmas and never unfold the definition. The definition is noncomputable, and its value is unspecified beyond the stated properties, so make the existence theorem strong enough at the start. The GRH guide warns that many objects come from choose and that "the lemmas next to them give their properties". Optionally mark the definition irreducible, or tag the spec lemmas @[simp] or grind, so automation finds them.

Lean

theorem exists_prime_gt (n : ℕ) : ∃ p, p.Prime ∧ n < p :=
  (Nat.exists_infinite_primes (n + 1)).imp fun _ hp ↦ ⟨hp.2, hp.1⟩

/-- A chosen prime above `n`. -/
noncomputable def primeAbove (n : ℕ) : ℕ := (exists_prime_gt n).choose

lemma primeAbove_prime (n : ℕ) : (primeAbove n).Prime := (exists_prime_gt n).choose_spec.1

lemma lt_primeAbove (n : ℕ) : n < primeAbove n := (exists_prime_gt n).choose_spec.2

attribute [irreducible] primeAbove

Examples

Provenance

GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/src/Lib/General/NumberTheory/PadicLimitsValuation.lean · licence Apache-2.0

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "choose-definition-with-spec-lemmas" }] (CLI: --cite book:choose-definition-with-spec-lemmas).

Define objects by choose and state their properties right after — Book of methods | nosorry