The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Conv
12 declarations. Mathlib docs · Source
Additional conversion tactics
This file defines additional tactics related to the conversion tactic mode.
Main definitions
Top-level commands
Tactics to enter the conversion mode
Tactics used inside the conversion mode
def Mathlib.Tactic.Conv.convLHS E1 #
Lean.ParserDescr
conv_lhs => cs runs the conv tactic sequence cs on the left hand side of the target.
In general, for an n-ary operator as the target, it traverses into the second to last argument.
It is a synonym for conv => arg -2; cs.
conv_lhs at h => csrunscson the left hand side of hypothesish.conv_lhs in pat => csfirst looks for a subexpression matchingpat(see also thepatternconv tactic) and then traverses into the left hand side of this subexpression. This syntax also supports theoccsclause for the pattern.
def Mathlib.Tactic.Conv.convRHS E1 #
Lean.ParserDescr
conv_rhs => cs runs the conv tactic sequence cs on the right hand side of the target.
In general, for an n-ary operator as the target, it traverses into the last argument.
It is a synonym for conv => arg -1; cs.
conv_rhs at h => csrunscson the right hand side of hypothesish.conv_rhs in pat => csfirst looks for a subexpression matchingpat(see thepatternconv tactic) and then traverses into the right hand side of this subexpression. This syntax also supports theoccsclause for the pattern.
def Mathlib.Tactic.Conv.convRun_conv_ E1 #
Lean.ParserDescr
def Mathlib.Tactic.Conv.convInConv E1 #
Lean.ParserDescr
conv in pat => cs runs the conv tactic sequence cs
on the first subexpression matching the pattern pat in the target.
The converted expression becomes the new target subgoal, like conv => cs.
The arguments in are the same as those as the in pattern.
In fact, conv in pat => cs is a macro for conv => pattern pat; cs.
The syntax also supports the occs clause. Example:
conv in (occs := *) x + y => rw [add_comm]
def Mathlib.Tactic.Conv.dischargeConv E1 #
Lean.ParserDescr
discharge => tacis a conv tactic which rewrites targetptoTrueiftacis a tactic which proves the goal⊢ p.dischargewithout argument returns⊢ pas a subgoal.
def Mathlib.Tactic.Conv.elabDischargeConv E1 #
Lean.Elab.Tactic.Tactic
Elaborator for the discharge tactic.
def Mathlib.Tactic.Conv.refineConv E1 #
Lean.ParserDescr
Use refine in conv mode.
def Mathlib.Tactic.Conv.convCmd E1 #
Lean.ParserDescr
The command #conv tac => e will run a conv tactic tac on e, and display the resulting
expression (discarding the proof).
For example, #conv rw [true_and] => True ∧ False displays False.
There are also shorthand commands for several common conv tactics:
#whnf eis short for#conv whnf => e#simp eis short for#conv simp => e#norm_num eis short for#conv norm_num => e#push c => eis short for#conv push c => e
def Mathlib.Tactic.Conv.withReducible E1 #
Lean.ParserDescr
with_reducible tacs executes tacs using the reducible transparency setting.
In this setting only definitions tagged as [reducible] are unfolded.
def Mathlib.Tactic.Conv.whnfCmd E1 #
Lean.ParserDescr
The command #whnf e evaluates e to Weak Head Normal Form, which means that the "head"
of the expression is reduced to a primitive - a lambda or forall, or an axiom or inductive type.
It is similar to #reduce e, but it does not reduce the expression completely,
only until the first constructor is exposed. For example:
open Nat List
set_option pp.notation false
#whnf [1, 2, 3].map succ
-- cons (succ 1) (map succ (cons 2 (cons 3 nil)))
#reduce [1, 2, 3].map succ
-- cons 2 (cons 3 (cons 4 nil))
The head of this expression is the List.cons constructor,
so we can see from this much that the list is not empty,
but the subterms Nat.succ 1 and List.map Nat.succ (List.cons 2 (List.cons 3 List.nil)) are
still unevaluated. #reduce is equivalent to using #whnf on every subexpression.
def Mathlib.Tactic.Conv.whnfRCmd E1 #
Lean.ParserDescr
The command #whnfR e evaluates e to Weak Head Normal Form with Reducible transparency,
that is, it uses whnf but only unfolding reducible definitions.
def Mathlib.Tactic.Conv.simpCmd E1 #
Lean.ParserDescr
#simp => erunssimpon the expressioneand displays the resulting expression after simplification.#simp only [lems] => erunssimp only [lems]one.- The
=>is optional, so#simp eand#simp only [lems] ehave the same behavior. It is mostly useful for disambiguating the expressionefrom the lemmas.