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

Loading…

Book of methods · tactics

Rewrite with inequalities using grw inside calc steps

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

Problem

In a chain of estimates you want to replace a subterm by an upper bound inside a larger monotone expression. Doing it with gcongr plus exact, or with mul_le_mul by hand, is clumsy.

Method

grw [h] with h : a ≤ b replaces a by b (or by a for ← h) at every position where the goal is monotone in it. It uses the gcongr lemmas and closes side goals such as 0 ≤ c with positivity, which also uses hypotheses of the form 0 ≤ c from the context. Several bounds can go in one call, mixed with equalities and lemma instances: grw [norm_mul, hE v hv.le, le_abs_self C]. It is the second most used rewriting tactic in the GRH analytic files, more than 1,500 uses. The typical shape is calc _ ≤ _ := by grw [bound₁, bound₂] followed by _ = _ := by ring. If grw cannot see that the position is monotone (subtraction, division by a variable), state the step and use gcongr, which reports the side goals it could not close.

Lean

example {E : ℝ → ℝ} {C Y v : ℝ} (hC : 0 ≤ C) (hvY : v ≤ Y)
    (hE : ∀ w ≥ (0 : ℝ), |E w| ≤ C * Real.exp w) (hv : 0 ≤ v) :
    E v * Real.exp v ≤ C * Real.exp Y * Real.exp Y := by
  calc E v * Real.exp v ≤ C * Real.exp v * Real.exp v := by
        grw [le_abs_self (E v), hE v hv]
    _ ≤ C * Real.exp Y * Real.exp Y := by grw [hvY]

Examples

Provenance

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

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "grw-rewrite-with-inequalities-in-calc" }] (CLI: --cite book:grw-rewrite-with-inequalities-in-calc).