field_simp
Simplify expressions involving division by clearing denominators.field_simp transforms field equations into polynomial equations that ring can solve.
❗
field_simp requires Mathlib. Add import Mathlib.Tactic.FieldSimp to use this tactic.Basic Usage
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- field_simp clears denominators5example (a b : ℚ) (ha : a ≠ 0) (hb : b ≠ 0) : 6 1/a + 1/b = (a + b)/(a * b) := by7 field_simp8 ring910-- It handles complex fractions11example (x : ℚ) (hx : x ≠ 0) : (1 + 1/x) * x = x + 1 := by12 field_simp13 ringKey Takeaway
field_simp multiplies through by denominators to eliminate division, then you typically use ringto finish the proof.Handling Division
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- x/x = 1 when x ≠ 05example (x : ℚ) (hx : x ≠ 0) : x / x = 1 := by6 field_simp78-- Nested fractions9example (a b : ℚ) (ha : a ≠ 0) (hb : b ≠ 0) :10 (a/b) / (b/a) = a^2 / b^2 := by11 field_simp12 ring1314-- Adding fractions15example (x y : ℚ) (hx : x ≠ 0) (hy : y ≠ 0) :16 1/x - 1/y = (y - x) / (x * y) := by17 field_simp18 ringNon-Zero Conditions
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- field_simp uses hypotheses that terms are non-zero5example (a : ℚ) (ha : a ≠ 0) : a * (1/a) = 1 := by6 field_simp -- Uses ha to know a ≠ 078-- Without the hypothesis, it can't simplify fully9-- example (a : ℚ) : a * (1/a) = 1 := by field_simp -- Leaves goal1011-- You can provide side conditions12example (a b : ℚ) (h : a * b ≠ 0) : 1/(a*b) = 1/a * (1/b) := by13 field_simp14 ringℹ
field_simp automatically uses hypotheses of the form x ≠ 0 to justify clearing denominators.The field_simp + ring Pattern
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- This combination solves most field equations5example (x y : ℚ) (hx : x ≠ 0) (hy : y ≠ 0) (hxy : x + y ≠ 0) :6 (x^2 - y^2) / (x + y) = x - y := by7 field_simp8 ring910-- Complex algebraic identity11example (a b : ℚ) (ha : a ≠ 0) (hb : b ≠ 0) (hab : a - b ≠ 0) :12 1/(a - b) * (1/b - 1/a) = 1/(a*b) := by13 field_simp14 ringDeep Dive: How field_simp Works
field_simp performs these transformations:
- Finds all division operations in the goal
- Computes the least common denominator
- Multiplies both sides by this denominator
- Simplifies using field axioms (assuming denominators ≠ 0)
- May generate side goals for non-zero conditions
Side Goals
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- Sometimes field_simp generates side goals5example (x : ℚ) : (x^2 + 1) / (x^2 + 1) = 1 := by6 field_simp7 -- May need to prove x^2 + 1 ≠ 08 -- In ℚ, x^2 + 1 > 0 for all x910-- Using positivity to handle side goals11-- example (x : ℚ) : (x^2 + 1) / (x^2 + 1) = 1 := by12-- field_simp13-- positivity -- From Mathlib.Tactic.PositivityReal-World Examples
Harmonic Series Manipulation
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- Telescoping fractions5theorem telescope (n : ℚ) (hn : n ≠ 0) (hn1 : n + 1 ≠ 0) :6 1/n - 1/(n+1) = 1/(n*(n+1)) := by7 field_simp8 ringPhysics Formula
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- Lens equation: 1/f = 1/u + 1/v5-- Prove: f = uv/(u+v)6theorem lens_equation (u v f : ℚ) 7 (hu : u ≠ 0) (hv : v ≠ 0) (huv : u + v ≠ 0)8 (h : 1/f = 1/u + 1/v) : f = (u*v)/(u+v) := by9 have hf : f ≠ 0 := by10 intro hf11 simp [hf] at h12 field_simp at h13 linarith14 field_simp at h ⊢15 linarithCommon Patterns
lean
1import Mathlib.Tactic.FieldSimp2import Mathlib.Tactic.Ring34-- Reciprocal of reciprocal5example (x : ℚ) (hx : x ≠ 0) : 1 / (1/x) = x := by6 field_simp78-- Sum to product9example (a b : ℚ) (ha : a ≠ 0) (hb : b ≠ 0) :10 (a + b) / (a * b) = 1/a + 1/b := by11 field_simp12 ring1314-- Difference quotient15example (x h : ℚ) (hh : h ≠ 0) :16 ((x + h)^2 - x^2) / h = 2*x + h := by17 field_simp18 ring