Documentation

Mathlib.Tactic.GRewrite.Elab

The generalized rewriting tactic #

This file defines the tactics that use the backend defined in Mathlib.Tactic.GRewrite.Core:

Apply the grewrite tactic to the current goal.

Equations
  • One or more equations did not get rendered due to their size.

Apply the grewrite tactic to a local hypothesis.

Equations
  • One or more equations did not get rendered due to their size.

Function elaborating GRewrite.Config.

Equations
  • One or more equations did not get rendered due to their size.

grewrite [e] works just like rewrite [e], but e can be a relation other than = or .

For example,

example (h₁ : a < b) (h₂ : b ≤ c) : a + d ≤ c + d := by
  grewrite [h₁, h₂]; rfl

example (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
  grewrite [h]; rfl

example : (h₁ : a ∣ b) (h₂ : c ∣ a * d) : a ∣ b * d := by
  grewrite [h₁]
  exact h₂

To be able to use grewrite, the relevant lemmas need to be tagged with @[gcongr]. To rewrite inside a transitive relation, you can also give it an IsTrans instance.

Equations
  • One or more equations did not get rendered due to their size.

grewrite [e] works just like rewrite [e], but e can be a relation other than = or .

For example,

example (h₁ : a < b) (h₂ : b ≤ c) : a + d ≤ c + d := by
  grewrite [h₁, h₂]; rfl

example (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
  grewrite [h]; rfl

example : (h₁ : a ∣ b) (h₂ : c ∣ a * d) : a ∣ b * d := by
  grewrite [h₁]
  exact h₂

To be able to use grewrite, the relevant lemmas need to be tagged with @[gcongr]. To rewrite inside a transitive relation, you can also give it an IsTrans instance.

Equations
  • One or more equations did not get rendered due to their size.

grw [e] works just like rw [e], but e can be a relation other than = or .

For example,

example (h₁ : a < b) (h₂ : b ≤ c) : a + d ≤ c + d := by
  grw [h₁, h₂]

example (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
  grw [h]

example : (h₁ : a ∣ b) (h₂ : c ∣ a * d) : a ∣ b * d := by
  grw [h₁]
  exact h₂

To be able to use grw, the relevant lemmas need to be tagged with @[gcongr]. To rewrite inside a transitive relation, you can also give it an IsTrans instance.

Equations
  • One or more equations did not get rendered due to their size.

apply_rewrite [rules] is a shorthand for grewrite +implicationHyp [rules].

Equations
  • One or more equations did not get rendered due to their size.

apply_rw [rules] is a shorthand for grw +implicationHyp [rules].

Equations
  • One or more equations did not get rendered due to their size.

nth_grewrite is just like nth_rewrite, but for grewrite.

Equations
  • One or more equations did not get rendered due to their size.

nth_grw is just like nth_rw, but for grw.

Equations
  • One or more equations did not get rendered due to their size.