The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.Ring.RingNF

50 declarations. Mathlib docs · Source

ring_nf tactic

A tactic which uses ring to rewrite expressions. This can be used non-terminally to normalize ring expressions in the goal such as ⊢ P (x + x + x) ~> ⊢ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

We register ring with the hint tactic.

def Mathlib.Tactic.RingNF.Config.ctorIdx E1 #

Mathlib.Tactic.RingNF.Config → ℕ

theorem Mathlib.Tactic.RingNF.Config.mk.injEq E0 #

∀ (toConfig : Mathlib.Tactic.AtomM.Recurse.Config) (ifUnchanged : Mathlib.Tactic.BehaviorIfUnchanged)
  (mode : Mathlib.Tactic.RingNF.RingMode) (toConfig_1 : Mathlib.Tactic.AtomM.Recurse.Config)
  (ifUnchanged_1 : Mathlib.Tactic.BehaviorIfUnchanged) (mode_1 : Mathlib.Tactic.RingNF.RingMode),
  ({ toConfig := toConfig, ifUnchanged := ifUnchanged, mode := mode } =
      { toConfig := toConfig_1, ifUnchanged := ifUnchanged_1, mode := mode_1 }) =
    (toConfig = toConfig_1 ∧ ifUnchanged = ifUnchanged_1 ∧ mode = mode_1)

def Mathlib.Tactic.RingNF.instInhabitedConfig.default E1 #

Mathlib.Tactic.RingNF.Config

def Mathlib.Tactic.RingNF.instInhabitedRingMode.default E1 #

Mathlib.Tactic.RingNF.RingMode

abbrev Mathlib.Tactic.RingNF.RingMode.ctorElimType E1 #

{motive : Mathlib.Tactic.RingNF.RingMode → Sort u} → ℕ → Sort (max 1 u)

theorem Mathlib.Tactic.RingNF.Config.mk.inj E1 #

∀ {toConfig : Mathlib.Tactic.AtomM.Recurse.Config} {ifUnchanged : Mathlib.Tactic.BehaviorIfUnchanged}
  {mode : Mathlib.Tactic.RingNF.RingMode} {toConfig_1 : Mathlib.Tactic.AtomM.Recurse.Config}
  {ifUnchanged_1 : Mathlib.Tactic.BehaviorIfUnchanged} {mode_1 : Mathlib.Tactic.RingNF.RingMode},
  { toConfig := toConfig, ifUnchanged := ifUnchanged, mode := mode } =
      { toConfig := toConfig_1, ifUnchanged := ifUnchanged_1, mode := mode_1 } →
    toConfig = toConfig_1 ∧ ifUnchanged = ifUnchanged_1 ∧ mode = mode_1

def Mathlib.Tactic.RingNF.RingMode.ctorIdx E1 #

Mathlib.Tactic.RingNF.RingMode → ℕ

inductive Mathlib.Tactic.RingNF.RingMode E1 #

Type

The normalization style for ring_nf.

ctor Mathlib.Tactic.RingNF.RingMode.SOP E0 #

Mathlib.Tactic.RingNF.RingMode

Sum-of-products form, like x + x * y * 2 + z ^ 2.

ctor Mathlib.Tactic.RingNF.RingMode.raw E0 #

Mathlib.Tactic.RingNF.RingMode

Raw form: the representation ring uses internally.

def Mathlib.Tactic.RingNF.instBEqRingMode.beq E1 #

Mathlib.Tactic.RingNF.RingMode → Mathlib.Tactic.RingNF.RingMode → Bool

def Mathlib.Tactic.RingNF.instReprRingMode.repr E1 #

Mathlib.Tactic.RingNF.RingMode → ℕ → Std.Format

instance Mathlib.Tactic.RingNF.instInhabitedRingMode E0 #

Inhabited Mathlib.Tactic.RingNF.RingMode

instance Mathlib.Tactic.RingNF.instReprRingMode E0 #

Repr Mathlib.Tactic.RingNF.RingMode

instance Mathlib.Tactic.RingNF.instBEqRingMode E0 #

BEq Mathlib.Tactic.RingNF.RingMode

structure Mathlib.Tactic.RingNF.Config E1 #

Type

Configuration for ring_nf.

ctor Mathlib.Tactic.RingNF.Config.mk E0 #

Mathlib.Tactic.AtomM.Recurse.Config →
  Mathlib.Tactic.BehaviorIfUnchanged → Mathlib.Tactic.RingNF.RingMode → Mathlib.Tactic.RingNF.Config

abbrev Mathlib.Tactic.RingNF.Config.toConfig E1 #

Mathlib.Tactic.RingNF.Config → Mathlib.Tactic.AtomM.Recurse.Config

abbrev Mathlib.Tactic.RingNF.Config.ifUnchanged E1 #

Mathlib.Tactic.RingNF.Config → Mathlib.Tactic.BehaviorIfUnchanged

How to behave if no progress is made: warn, error or keep silent. Default to error

abbrev Mathlib.Tactic.RingNF.Config.mode E1 #

Mathlib.Tactic.RingNF.Config → Mathlib.Tactic.RingNF.RingMode

The normalization style.

def Mathlib.Tactic.RingNF.instBEqConfig.beq E1 #

Mathlib.Tactic.RingNF.Config → Mathlib.Tactic.RingNF.Config → Bool

instance Mathlib.Tactic.RingNF.instInhabitedConfig E0 #

Inhabited Mathlib.Tactic.RingNF.Config

instance Mathlib.Tactic.RingNF.instReprConfig E0 #

Repr Mathlib.Tactic.RingNF.Config

def Mathlib.Tactic.RingNF.instReprConfig.repr E1 #

Mathlib.Tactic.RingNF.Config → ℕ → Std.Format

instance Mathlib.Tactic.RingNF.instBEqConfig E0 #

BEq Mathlib.Tactic.RingNF.Config

def Mathlib.Tactic.RingNF.elabConfig E1 #

Lean.Syntax →
  optParam Mathlib.Tactic.RingNF.Config { } → optParam Bool true → Lean.Elab.Tactic.TacticM Mathlib.Tactic.RingNF.Config

Function elaborating RingNF.Config.

def Mathlib.Tactic.RingNF.evalExpr? E1 #

Lean.Expr → Mathlib.Tactic.AtomM (Option Lean.Meta.Simp.Result)

Evaluates an expression e into a normalized representation as a polynomial, returning none when the type of e is not a commutative semiring, or when e is an atom for the ring tactic.

This is a variant of Mathlib.Tactic.Ring.eval, the main driver of the ring tactic, operating on Expr (input) and Simp.Result (output) rather than typed Qq versions of these.

def Mathlib.Tactic.RingNF.evalExpr E1 #

Lean.Expr → Mathlib.Tactic.AtomM Lean.Meta.Simp.Result

Evaluates an expression e into a normalized representation as a polynomial.

This is a variant of Mathlib.Tactic.Ring.eval, the main driver of the ring tactic. It differs in

  • operating on Expr (input) and Simp.Result (output), rather than typed Qq versions of these;
  • throwing an error if the expression e is an atom for the ring tactic.

theorem Mathlib.Tactic.RingNF.add_assoc_rev E1 #

∀ {R : Type u_1} [inst : CommSemiring R] (a b c : R), a + (b + c) = a + b + c

theorem Mathlib.Tactic.RingNF.mul_assoc_rev E1 #

∀ {R : Type u_1} [inst : CommSemiring R] (a b c : R), a * (b * c) = a * b * c

theorem Mathlib.Tactic.RingNF.mul_neg E1 #

∀ {R : Type u_2} [inst : Ring R] (a b : R), a * -b = -(a * b)

theorem Mathlib.Tactic.RingNF.add_neg E1 #

∀ {R : Type u_2} [inst : Ring R] (a b : R), a + -b = a - b

theorem Mathlib.Tactic.RingNF.nat_rawCast_0 E1 #

∀ {R : Type u_1} [inst : CommSemiring R], Nat.rawCast 0 = 0

theorem Mathlib.Tactic.RingNF.nat_rawCast_1 E1 #

∀ {R : Type u_1} [inst : CommSemiring R], Nat.rawCast 1 = 1

theorem Mathlib.Tactic.RingNF.nat_rawCast_2 E1 #

∀ {R : Type u_1} [inst : CommSemiring R] {n : ℕ} [inst_1 : n.AtLeastTwo], n.rawCast = OfNat.ofNat n

theorem Mathlib.Tactic.RingNF.int_rawCast_neg E1 #

∀ {n : ℕ} {R : Type u_2} [inst : Ring R], (Int.negOfNat n).rawCast = -n.rawCast

theorem Mathlib.Tactic.RingNF.nnrat_rawCast E1 #

∀ {n d : ℕ} {R : Type u_2} [inst : DivisionSemiring R], NNRat.rawCast n d = n.rawCast / d.rawCast

theorem Mathlib.Tactic.RingNF.rat_rawCast_neg E1 #

∀ {n d : ℕ} {R : Type u_2} [inst : DivisionRing R],
  Rat.rawCast (Int.negOfNat n) d = (Int.negOfNat n).rawCast / d.rawCast

def Mathlib.Tactic.RingNF.cleanup E1 #

Mathlib.Tactic.RingNF.Config → Lean.Meta.Simp.Result → Lean.MetaM Lean.Meta.Simp.Result

A cleanup routine, which simplifies normalized polynomials to a more human-friendly format.

def Mathlib.Tactic.RingNF.ringNF E1 #

Lean.ParserDescr

ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

ring_nf works as both a tactic and a conv tactic.

See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

  • ring_nf! will use a more aggressive reducibility setting to identify atoms.
  • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
    • red: the reducibility setting (overridden by !)
    • zetaDelta: if true, local let variables can be unfolded (overridden by !)
    • recursive: if true, ring_nf will also recurse into atoms
  • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊢ P (x + x + x) ~> ⊢ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

def Mathlib.Tactic.RingNF.tacticRing_nf!__ E1 #

Lean.ParserDescr

ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

ring_nf works as both a tactic and a conv tactic.

See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

  • ring_nf! will use a more aggressive reducibility setting to identify atoms.
  • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
    • red: the reducibility setting (overridden by !)
    • zetaDelta: if true, local let variables can be unfolded (overridden by !)
    • recursive: if true, ring_nf will also recurse into atoms
  • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊢ P (x + x + x) ~> ⊢ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

def Mathlib.Tactic.RingNF.ringNFConv E1 #

Lean.ParserDescr

ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

ring_nf works as both a tactic and a conv tactic.

See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

  • ring_nf! will use a more aggressive reducibility setting to identify atoms.
  • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
    • red: the reducibility setting (overridden by !)
    • zetaDelta: if true, local let variables can be unfolded (overridden by !)
    • recursive: if true, ring_nf will also recurse into atoms
  • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊢ P (x + x + x) ~> ⊢ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

def Mathlib.Tactic.RingNF.ring1NF E1 #

Lean.ParserDescr

ring1 solves the goal when it is an equality in commutative (semi)rings, allowing variables in the exponent.

This version of ring fails if the target is not an equality.

  • ring1! uses a more aggressive reducibility setting to determine equality of atoms.

Extensions:

    • ring1_nf additionally uses ring_nf to simplify in atoms.
    • ring1_nf! will use a more aggressive reducibility setting to determine equality of atoms.

def Mathlib.Tactic.RingNF.tacticRing1_nf!_ E1 #

Lean.ParserDescr

ring1 solves the goal when it is an equality in commutative (semi)rings, allowing variables in the exponent.

This version of ring fails if the target is not an equality.

  • ring1! uses a more aggressive reducibility setting to determine equality of atoms.

Extensions:

    • ring1_nf additionally uses ring_nf to simplify in atoms.
    • ring1_nf! will use a more aggressive reducibility setting to determine equality of atoms.

def Mathlib.Tactic.RingNF.elabRingNFConv E1 #

Lean.Elab.Tactic.Tactic

Elaborator for the ring_nf tactic.

def Mathlib.Tactic.RingNF.convRing_nf!_ E1 #

Lean.ParserDescr

ring_nf simplifies expressions in the language of commutative (semi)rings, which rewrites all ring expressions into a normal form, allowing variables in the exponents.

ring_nf works as both a tactic and a conv tactic.

See also the ring tactic for solving a goal which is an equation in the language of commutative (semi)rings.

  • ring_nf! will use a more aggressive reducibility setting to identify atoms.
  • ring_nf (config := cfg) allows for additional configuration (see RingNF.Config):
    • red: the reducibility setting (overridden by !)
    • zetaDelta: if true, local let variables can be unfolded (overridden by !)
    • recursive: if true, ring_nf will also recurse into atoms
  • ring_nf at l1 l2 ... can be used to rewrite at the given locations.

Examples: This can be used non-terminally to normalize ring expressions in the goal such as ⊢ P (x + x + x) ~> ⊢ P (x * 3), as well as being able to prove some equations that ring cannot because they involve ring reasoning inside a subterm, such as sin (x + y) + sin (y + x) = 2 * sin (x + y).

def Mathlib.Tactic.RingNF.ring E1 #

Lean.ParserDescr

ring solves equations in commutative (semi)rings, allowing for variables in the exponent. If the goal is not appropriate for ring (e.g. not an equality) ring_nf will be suggested. See also ring1, which fails if the goal is not an equality.

  • ring! will use a more aggressive reducibility setting to determine equality of atoms.

Examples:

example (n : ℕ) (m : ℤ) : 2^(n+1) * m = 2 * 2^n * m := by ring
example (a b : ℤ) (n : ℕ) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring
example (x y : ℕ) : x + id y = y + id x := by ring!
example (x : ℕ) (h : x * 2 > 5): x + x > 5 := by ring; assumption -- suggests ring_nf

def Mathlib.Tactic.RingNF.tacticRing! E1 #

Lean.ParserDescr

ring solves equations in commutative (semi)rings, allowing for variables in the exponent. If the goal is not appropriate for ring (e.g. not an equality) ring_nf will be suggested. See also ring1, which fails if the goal is not an equality.

  • ring! will use a more aggressive reducibility setting to determine equality of atoms.

Examples:

example (n : ℕ) (m : ℤ) : 2^(n+1) * m = 2 * 2^n * m := by ring
example (a b : ℤ) (n : ℕ) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring
example (x y : ℕ) : x + id y = y + id x := by ring!
example (x : ℕ) (h : x * 2 > 5): x + x > 5 := by ring; assumption -- suggests ring_nf

def Mathlib.Tactic.RingNF.ringConv E1 #

Lean.ParserDescr

The tactic ring evaluates expressions in commutative (semi)rings. This is the conv tactic version, which rewrites a target which is a ring equality to True.

See also the ring tactic.

def Mathlib.Tactic.RingNF.convRing! E1 #

Lean.ParserDescr

The tactic ring evaluates expressions in commutative (semi)rings. This is the conv tactic version, which rewrites a target which is a ring equality to True.

See also the ring tactic.