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

Loading…

Book of methods · tactics

Clear denominators with field_simp, then finish with ring or linear_combination

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

Problem

An identity between rational expressions in ℝ or ℂ (q / 2 * (1/k + 1/(q - k)) = …) does not close with ring, because of division and nonzero conditions.

Method

First move casts into place: rw [Nat.cast_sub h] for natural subtraction, then push_cast. Then call field_simp, which multiplies out the denominators. It needs to know each one is nonzero, so have hypotheses hq : (q : ℝ) ≠ 0 in context or pass them, field_simp [hq.ne']. Close with ring, or with linear_combination (coeff) * h when the identity uses a hypothesis equation. Recent Mathlib also has a one-step finisher field (the GRH sources use field, field [NeZero.ne] and simp [..., field]). If it is not available on the verifier, field_simp followed by ring is the portable form. When field_simp leaves a goal in a strange shape, it is usually missing a nonzero fact. Look for leftover x / y terms.

Lean

example (q k : ℝ) (hk : 0 < k) (hkq : k < q) :
    q / 2 * (1 / k + 1 / (q - k)) = q ^ 2 / (2 * k * (q - k)) := by
  have h1 : k ≠ 0 := hk.ne'
  have h2 : q - k ≠ 0 := (sub_pos.2 hkq).ne'
  field_simp
  ring

example (n : ℕ) (H : ℝ) (hH : 0 < H) : ((n + 1 : ℕ) : ℝ) / H * H = n + 1 := by
  push_cast
  exact div_mul_cancel₀ _ hH.ne'

Examples

Provenance

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

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "clear-denominators-with-field-simp-then-ring" }] (CLI: --cite book:clear-denominators-with-field-simp-then-ring).