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

Loading…

Book of methods · tactics

Use gcongr (or bound) to compare two expressions of the same shape

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

Problem

You must prove f(a) ≤ f(b) for a compound expression (sums, products, powers, divisions) and applying monotonicity lemmas by hand is tedious.

Method

gcongr matches the two sides of an inequality, finds the varying positions, and reduces the goal to inequalities between them, applying @[gcongr] lemmas. Main goals are closed by assumption when possible; side goals (like 0 ≤ c for multiplication) go to a positivity-based discharger and otherwise are left to you. Use a pattern to say what varies: gcongr ?_ * c + 1. It also works under ∑ and with <, ⊆, ∣. bound is an Aesop-based alternative that recurses through the expression, can switch between 0 ≤ x and x ≤ y goals, and accepts extra facts bound [h1, h2 n]; Mathlib notes gcongr is faster and more specialised. In a calc chain, by gcongr per step is the idiomatic way to justify monotone steps.

Lean

example (a b c : ℝ) (h : a ≤ b) : a * c ^ 2 + 1 ≤ b * c ^ 2 + 1 := by
  gcongr            -- side goal 0 ≤ c ^ 2 closed by positivity

example (f : ℕ → ℝ) (n : ℕ) (h : ∀ i, f i ≤ 1) :
    ∑ i ∈ Finset.range n, f i ≤ ∑ i ∈ Finset.range n, (1 : ℝ) := by
  gcongr with i hi
  exact h i

example (x y : ℝ) (hx : 0 ≤ x) (h : x ≤ y) : x ^ 2 ≤ y ^ 2 := by
  bound

Examples

Provenance

Lean 4 / Mathlib documentation (paraphrased) · leanprover-community.github.io/mathlib4_docs/Mathlib/Tactic/Bound.html · licence original

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "gcongr-and-bound-for-monotone-inequalities" }] (CLI: --cite book:gcongr-and-bound-for-monotone-inequalities).