File: .lake/packages/lean4/src/lean/Init/Conv.lean

full_name: Lean.Parser.Category.conv
code: /-- `conv` is the syntax category for a "conv tactic", where "conv" is short
for conversion. A conv tactic is a program which receives a target, printed as
`| a`, and is tasked with coming up with some term `b` and a proof of `a = b`.
It is mainly used for doing targeted term transformations, for example rewriting
only on the left side of an equality. -/
declare_syntax_cat conv (behavior := both)
goal: Lean.Parser.Category

full_name: Lean.Parser.Tactic.Conv.convSeq1Indented
code: syntax convSeq1Indented := sepBy1IndentSemicolon(conv)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convSeqBracketed
code: syntax convSeqBracketed := "{" withoutPosition(sepByIndentSemicolon(conv)) "}"
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convSeq
code: syntax convSeq := convSeqBracketed <|> convSeq1Indented
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.occsWildcard
code: /-- The `*` occurrence list means to apply to all occurrences of the pattern. -/
syntax occsWildcard := "*"
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.occsIndexed
code: /--
A list `1 2 4` of occurrences means to apply to the first, second, and fourth
occurrence of the pattern.
-/
syntax occsIndexed := num+
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.occs
code: /-- An occurrence specification, either `*` or a list of numbers. The default is `[1]`. -/
syntax occs := atomic("(" &"occs") " := " (occsWildcard <|> occsIndexed) ") "
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.withAnnotateState
code: /--
`with_annotate_state stx t` annotates the lexical range of `stx : Syntax` with
the initial and final state of running tactic `t`.
-/
scoped syntax (name := withAnnotateState)
  "with_annotate_state " rawStx ppSpace conv : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.skip
code: /-- `skip` does nothing. -/
syntax (name := skip) "skip" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.lhs
code: /-- Traverses into the left subterm of a binary operator.
(In general, for an `n`-ary operator, it traverses into the second to last argument.) -/
syntax (name := lhs) "lhs" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.rhs
code: /-- Traverses into the right subterm of a binary operator.
(In general, for an `n`-ary operator, it traverses into the last argument.) -/
syntax (name := rhs) "rhs" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.fun
code: /-- Traverses into the function of a (unary) function application.
For example, `| f a b` turns into `| f a`. (Use `arg 0` to traverse into `f`.)  -/
syntax (name := «fun») "fun" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.whnf
code: /-- Reduces the target to Weak Head Normal Form. This reduces definitions
in "head position" until a constructor is exposed. For example, `List.map f [a, b, c]`
weak head normalizes to `f a :: List.map f [b, c]`. -/
syntax (name := whnf) "whnf" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.zeta
code: /-- Expands let-declarations and let-variables. -/
syntax (name := zeta) "zeta" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.reduce
code: /-- Puts term in normal form, this tactic is meant for debugging purposes only. -/
syntax (name := reduce) "reduce" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.congr
code: /-- Performs one step of "congruence", which takes a term and produces
subgoals for all the function arguments. For example, if the target is `f x y` then
`congr` produces two subgoals, one for `x` and one for `y`. -/
syntax (name := congr) "congr" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.arg
code: /--
* `arg i` traverses into the `i`'th argument of the target. For example if the
  target is `f a b c d` then `arg 1` traverses to `a` and `arg 3` traverses to `c`.
* `arg @i` is the same as `arg i` but it counts all arguments instead of just the
  explicit arguments.
* `arg 0` traverses into the function. If the target is `f a b c d`, `arg 0` traverses into `f`. -/
syntax (name := arg) "arg " "@"? num : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.ext
code: /-- `ext x` traverses into a binder (a `fun x => e` or `∀ x, e` expression)
to target `e`, introducing name `x` in the process. -/
syntax (name := ext) "ext" (ppSpace colGt ident)* : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.change
code: /-- `change t'` replaces the target `t` with `t'`,
assuming `t` and `t'` are definitionally equal. -/
syntax (name := change) "change " term : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.delta
code: /-- `delta id1 id2 ...` unfolds all occurrences of `id1`, `id2`, ... in the target.
Like the `delta` tactic, this ignores any definitional equations and uses
primitive delta-reduction instead, which may result in leaking implementation details.
Users should prefer `unfold` for unfolding definitions. -/
syntax (name := delta) "delta" (ppSpace colGt ident)+ : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.unfold
code: /--
* `unfold foo` unfolds all occurrences of `foo` in the target.
* `unfold id1 id2 ...` is equivalent to `unfold id1; unfold id2; ...`.
Like the `unfold` tactic, this uses equational lemmas for the chosen definition
to rewrite the target. For recursive definitions,
only one layer of unfolding is performed. -/
syntax (name := unfold) "unfold" (ppSpace colGt ident)+ : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.pattern
code: /--
* `pattern pat` traverses to the first subterm of the target that matches `pat`.
* `pattern (occs := *) pat` traverses to every subterm of the target that matches `pat`
  which is not contained in another match of `pat`. It generates one subgoal for each matching
  subterm.
* `pattern (occs := 1 2 4) pat` matches occurrences `1, 2, 4` of `pat` and produces three subgoals.
  Occurrences are numbered left to right from the outside in.

Note that skipping an occurrence of `pat` will traverse inside that subexpression, which means
it may find more matches and this can affect the numbering of subsequent pattern matches.
For example, if we are searching for `f _` in `f (f a) = f b`:
* `occs := 1 2` (and `occs := *`) returns `| f (f a)` and `| f b`
* `occs := 2` returns `| f a`
* `occs := 2 3` returns `| f a` and `| f b`
* `occs := 1 3` is an error, because after skipping `f b` there is no third match.
-/
syntax (name := pattern) "pattern " (occs)? term : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.rewrite
code: /-- `rw [thm]` rewrites the target using `thm`. See the `rw` tactic for more information. -/
syntax (name := rewrite) "rewrite" (config)? rwRuleSeq : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.simp
code: /-- `simp [thm]` performs simplification using `thm` and marked `@[simp]` lemmas.
See the `simp` tactic for more information. -/
syntax (name := simp) "simp" (config)? (discharger)? (&" only")?
  (" [" withoutPosition((simpStar <|> simpErase <|> simpLemma),*) "]")? : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.dsimp
code: /--
`dsimp` is the definitional simplifier in `conv`-mode. It differs from `simp` in that it only
applies theorems that hold by reflexivity.

Examples:

```lean
example (a : Nat): (0 + 0) = a - a := by
  conv =>
    lhs
    dsimp
    rw [← Nat.sub_self a]
```
-/
syntax (name := dsimp) "dsimp" (config)? (discharger)? (&" only")?
  (" [" withoutPosition((simpErase <|> simpLemma),*) "]")? : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.simpMatch
code: /-- `simp_match` simplifies match expressions. For example,
```
match [a, b] with
| [] => 0
| hd :: tl => hd
```
simplifies to `a`. -/
syntax (name := simpMatch) "simp_match" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.nestedTacticCore
code: /-- Executes the given tactic block without converting `conv` goal into a regular goal. -/
syntax (name := nestedTacticCore) "tactic'" " => " tacticSeq : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.nestedTactic
code: /-- Focuses, converts the `conv` goal `⊢ lhs` into a regular goal `⊢ lhs = rhs`, and then executes the given tactic block. -/
syntax (name := nestedTactic) "tactic" " => " tacticSeq : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convTactic
code: /-- Executes the given conv block without converting regular goal into a `conv` goal. -/
syntax (name := convTactic) "conv'" " => " convSeq : tactic
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.nestedConv
code: /-- `{ convs }` runs the list of `convs` on the current target, and any subgoals that
remain are trivially closed by `skip`. -/
syntax (name := nestedConv) convSeqBracketed : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.paren
code: /-- `(convs)` runs the `convs` in sequence on the current list of targets.
This is pure grouping with no added effects. -/
syntax (name := paren) "(" withoutPosition(convSeq) ")" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convRfl
code: macro "rfl" : conv => `(conv| tactic => rfl)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convRfl_1»
code: macro "rfl" : conv => `(conv| tactic => rfl)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convDone_1»
code: macro "done" : conv => `(conv| tactic' => done)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convDone
code: macro "done" : conv => `(conv| tactic' => done)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convTrace_state
code: macro "trace_state" : conv => `(conv| tactic' => trace_state)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convTrace_state_1»
code: macro "trace_state" : conv => `(conv| tactic' => trace_state)
goal: Lean.Macro

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

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_allGoals_1»
code: macro (name := allGoals) tk:"all_goals " s:convSeq : conv =>
  `(conv| tactic' => all_goals%$tk conv' => $s)
goal: Lean.Macro

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

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_anyGoals_1»
code: macro (name := anyGoals) tk:"any_goals " s:convSeq : conv =>
  `(conv| tactic' => any_goals%$tk conv' => $s)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_case_1»
code: macro (name := case) tk:"case " args:sepBy1(caseArg, "|") arr:" => " s:convSeq : conv =>
  `(conv| tactic' => case%$tk $args|* =>%$arr conv' => ($s); all_goals rfl)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.case
code: macro (name := case) tk:"case " args:sepBy1(caseArg, "|") arr:" => " s:convSeq : conv =>
  `(conv| tactic' => case%$tk $args|* =>%$arr conv' => ($s); all_goals rfl)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_case'_1»
code: macro (name := case') tk:"case' " args:sepBy1(caseArg, "|") arr:" => " s:convSeq : conv =>
  `(conv| tactic' => case'%$tk $args|* =>%$arr conv' => $s)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.case'
code: macro (name := case') tk:"case' " args:sepBy1(caseArg, "|") arr:" => " s:convSeq : conv =>
  `(conv| tactic' => case'%$tk $args|* =>%$arr conv' => $s)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convNext__=>__1»
code: macro "next" args:(ppSpace binderIdent)* " => " tac:convSeq : conv => `(conv| case _ $args* => $tac)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«convNext__=>_»
code: macro "next" args:(ppSpace binderIdent)* " => " tac:convSeq : conv => `(conv| case _ $args* => $tac)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_focus_1»
code: macro (name := focus) tk:"focus " s:convSeq : conv => `(conv| tactic' => focus%$tk conv' => $s)
goal: Lean.Macro

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

full_name: Lean.Parser.Tactic.Conv.convConvSeq
code: /-- `conv => cs` runs `cs` in sequence on the target `t`,
resulting in `t'`, which becomes the new target subgoal. -/
syntax (name := convConvSeq) "conv" " => " convSeq : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_conv·.__1»
code: macro dot:patternIgnore("·" <|> ".") s:convSeq : conv => `(conv| {%$dot ($s) })
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«conv·._»
code: macro dot:patternIgnore("·" <|> ".") s:convSeq : conv => `(conv| {%$dot ($s) })
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_failIfSuccess_1»
code: macro (name := failIfSuccess) tk:"fail_if_success " s:convSeq : conv =>
  `(conv| tactic' => fail_if_success%$tk conv' => $s)
goal: Lean.Macro

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

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convRw___1»
code: macro "rw" c:(config)? s:rwRuleSeq : conv => `(conv| rewrite $[$c]? $s)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convRw__
code: macro "rw" c:(config)? s:rwRuleSeq : conv => `(conv| rewrite $[$c]? $s)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convErw__1»
code: macro "erw" s:rwRuleSeq : conv => `(conv| rw (config := { transparency := .default }) $s)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convErw_
code: macro "erw" s:rwRuleSeq : conv => `(conv| rw (config := { transparency := .default }) $s)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convArgs_1»
code: macro "args" : conv => `(conv| congr)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convArgs
code: macro "args" : conv => `(conv| congr)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convLeft_1»
code: macro "left" : conv => `(conv| lhs)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convLeft
code: macro "left" : conv => `(conv| lhs)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convRight_1»
code: macro "right" : conv => `(conv| rhs)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convRight
code: macro "right" : conv => `(conv| rhs)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.convIntro___
code: macro "intro" xs:(ppSpace colGt ident)* : conv => `(conv| ext $xs*)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convIntro____1»
code: macro "intro" xs:(ppSpace colGt ident)* : conv => `(conv| ext $xs*)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.enterArg
code: syntax enterArg := ident <|> ("@"? num)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«convEnter[_]»
code: /-- `enter [arg, ...]` is a compact way to describe a path to a subterm.
It is a shorthand for other conv tactics as follows:
* `enter [i]` is equivalent to `arg i`.
* `enter [@i]` is equivalent to `arg @i`.
* `enter [x]` (where `x` is an identifier) is equivalent to `ext x`.
For example, given the target `f (g a (fun x => x b))`, `enter [1, 2, x, 1]`
will traverse to the subterm `b`. -/
syntax "enter" " [" withoutPosition(enterArg,+) "]" : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convEnter[_]_1»
code: macro_rules
  | `(conv| enter [$i:num]) => `(conv| arg $i)
  | `(conv| enter [@$i]) => `(conv| arg @$i)
  | `(conv| enter [$id:ident]) => `(conv| ext $id)
  | `(conv| enter [$arg, $args,*]) => `(conv| (enter [$arg]; enter [$args,*]))
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convApply__1»
code: macro "apply " e:term : conv => `(conv| tactic => apply $e)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convApply_
code: macro "apply " e:term : conv => `(conv| tactic => apply $e)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.first
code: /-- `first | conv | ...` runs each `conv` until one succeeds, or else fails. -/
syntax (name := first) "first " withPosition((ppDedent(ppLine) colGe "| " convSeq)+) : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convTry__1»
code: macro "try " t:convSeq : conv => `(conv| first | $t | skip)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.convTry_
code: macro "try " t:convSeq : conv => `(conv| first | $t | skip)
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_conv_<;>__1»
code: macro:1 x:conv tk:" <;> " y:conv:0 : conv =>
  `(conv| tactic' => (conv' => $x:conv) <;>%$tk (conv' => $y:conv))
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.«conv_<;>_»
code: macro:1 x:conv tk:" <;> " y:conv:0 : conv =>
  `(conv| tactic' => (conv' => $x:conv) <;>%$tk (conv' => $y:conv))
goal: Lean.TrailingParserDescr

full_name: Lean.Parser.Tactic.Conv.convRepeat_
code: /-- `repeat convs` runs the sequence `convs` repeatedly until it fails to apply. -/
syntax "repeat " convSeq : conv
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.«_aux_.lake_packages_lean4_src_lean_Init_Conv___macroRules_Lean_Parser_Tactic_Conv_convRepeat__1»
code: macro_rules
  | `(conv| repeat $seq) => `(conv| first | ($seq); repeat $seq | skip)
goal: Lean.Macro

full_name: Lean.Parser.Tactic.Conv.conv
code: /--
`conv => ...` allows the user to perform targeted rewriting on a goal or hypothesis,
by focusing on particular subexpressions.

See <https://lean-lang.org/theorem_proving_in_lean4/conv.html> for more details.

Basic forms:
* `conv => cs` will rewrite the goal with conv tactics `cs`.
* `conv at h => cs` will rewrite hypothesis `h`.
* `conv in pat => cs` will rewrite the first subexpression matching `pat` (see `pattern`).
-/
-- HACK: put this at the end so that references to `conv` above
-- refer to the syntax category instead of this syntax
syntax (name := conv) "conv" (" at " ident)? (" in " (occs)? term)? " => " convSeq : tactic
goal: Lean.ParserDescr

full_name: Lean.Parser.Tactic.Conv.normCast
code: /-- `norm_cast` tactic in `conv` mode. -/
syntax (name := normCast) "norm_cast" : conv
goal: Lean.ParserDescr