File: Mathlib/Tactic/Conv.lean

full_name: Mathlib.Tactic.Conv.convLHS
code: syntax (name := convLHS) "conv_lhs" (" at " ident)? (" in " (occs)? term)? " => " convSeq : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv._aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_convLHS_1
code: macro_rules
  | `(tactic| conv_lhs $[at $id]? $[in $[$occs]? $pat]? => $seq) =>
    `(tactic| conv $[at $id]? $[in $[$occs]? $pat]? => lhs; ($seq:convSeq))
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.convRHS
code: syntax (name := convRHS) "conv_rhs" (" at " ident)? (" in " (occs)? term)? " => " convSeq : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv._aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_convRHS_1
code: macro_rules
  | `(tactic| conv_rhs $[at $id]? $[in $[$occs]? $pat]? => $seq) =>
    `(tactic| conv $[at $id]? $[in $[$occs]? $pat]? => rhs; ($seq:convSeq))
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv._aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_convRun_conv__1
code: macro "run_conv" e:doSeq : conv => `(conv| tactic' => run_tac $e)
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.convRun_conv_
code: macro "run_conv" e:doSeq : conv => `(conv| tactic' => run_tac $e)
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«convConvIn__=>_»
code: macro "conv" " in " occs?:(occs)? p:term " => " code:convSeq : conv =>
  `(conv| conv => pattern $[$occs?]? $p; ($code:convSeq))
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«_aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_convConvIn__=>__1»
code: macro "conv" " in " occs?:(occs)? p:term " => " code:convSeq : conv =>
  `(conv| conv => pattern $[$occs?]? $p; ($code:convSeq))
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.dischargeConv
code: /--
* `discharge => tac` is a conv tactic which rewrites target `p` to `True` if `tac` is a tactic
  which proves the goal `⊢ p`.
* `discharge` without argument returns `⊢ p` as a subgoal.
-/
syntax (name := dischargeConv) "discharge" (" => " tacticSeq)? : conv
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.elabDischargeConv
code: /-- Elaborator for the `discharge` tactic. -/
@[tactic dischargeConv] def elabDischargeConv : Tactic 
goal: Lean.Elab.Tactic.Tactic

full_name: Mathlib.Tactic.Conv._aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_convRefine__1
code: macro "refine " e:term : conv => `(conv| tactic => refine $e)
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.convRefine_
code: macro "refine " e:term : conv => `(conv| tactic => refine $e)
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«_aux_Mathlib_Tactic_Conv___elabRules_Mathlib_Tactic_Conv_command#conv_=>__1»
code: /--
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 e` is short for `#conv whnf => e`
* `#simp e` is short for `#conv simp => e`
* `#norm_num e` is short for `#conv norm_num => e`
* `#push_neg e` is short for `#conv push_neg => e`
-/
elab tk:"#conv " conv:conv " => " e:term : command =>
  Command.runTermElabM fun _ ↦ do
    let e ← Elab.Term.elabTermAndSynthesize e none
    let (rhs, g) ← Conv.mkConvGoalFor e
    _ ← Tactic.run g.mvarId! do
      evalTactic conv
      for mvarId in (← getGoals) do
        liftM <| mvarId.refl <|> mvarId.inferInstance <|> pure ()
      pruneSolvedGoals
      let e' ← instantiateMVars rhs
      logInfoAt tk e'
goal: Lean.Elab.Command.CommandElab

full_name: Mathlib.Tactic.Conv.«command#conv_=>_»
code: /--
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 e` is short for `#conv whnf => e`
* `#simp e` is short for `#conv simp => e`
* `#norm_num e` is short for `#conv norm_num => e`
* `#push_neg e` is short for `#conv push_neg => e`
-/
elab tk:"#conv " conv:conv " => " e:term : command =>
  Command.runTermElabM fun _ ↦ do
    let e ← Elab.Term.elabTermAndSynthesize e none
    let (rhs, g) ← Conv.mkConvGoalFor e
    _ ← Tactic.run g.mvarId! do
      evalTactic conv
      for mvarId in (← getGoals) do
        liftM <| mvarId.refl <|> mvarId.inferInstance <|> pure ()
      pruneSolvedGoals
      let e' ← instantiateMVars rhs
      logInfoAt tk e'
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.withReducible
code: macro (name := withReducible) tk:"with_reducible " s:convSeq : conv =>
  `(conv| tactic' => with_reducible%$tk conv' => $s)
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv._aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_withReducible_1
code: macro (name := withReducible) tk:"with_reducible " s:convSeq : conv =>
  `(conv| tactic' => with_reducible%$tk conv' => $s)
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.«command#whnf_»
code: macro tk:"#whnf " e:term : command => `(command| #conv%$tk whnf => $e)
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«_aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_command#whnf__1»
code: macro tk:"#whnf " e:term : command => `(command| #conv%$tk whnf => $e)
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.«_aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_command#whnfR__1»
code: macro tk:"#whnfR " e:term : command => `(command| #conv%$tk with_reducible whnf => $e)
goal: Lean.Macro

full_name: Mathlib.Tactic.Conv.«command#whnfR_»
code: macro tk:"#whnfR " e:term : command => `(command| #conv%$tk with_reducible whnf => $e)
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«command#simpOnly_=>__»
code: /--
* `#simp => e` runs `simp` on the expression `e` and displays the resulting expression after
  simplification.
* `#simp only [lems] => e` runs `simp only [lems]` on `e`.
* The `=>` is optional, so `#simp e` and `#simp only [lems] e` have the same behavior.
  It is mostly useful for disambiguating the expression `e` from the lemmas.
-/
syntax "#simp" (&" only")? (simpArgs)? " =>"? ppSpace term : command
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Conv.«_aux_Mathlib_Tactic_Conv___macroRules_Mathlib_Tactic_Conv_command#simpOnly_=>___1»
code: macro_rules
  | `(#simp%$tk $[only%$o]? $[[$args,*]]? $[=>]? $e) =>
    `(#conv%$tk simp $[only%$o]? $[[$args,*]]? => $e)
goal: Lean.Macro