doc-next-gen

Init.Grind.Tactics

Module docstring

{"grind tactic and related tactics. "}

Lean.Parser.Attr.grindEq definition
: Lean.ParserDescr✝
Full source
syntax grindEq     := "= "
Grind equality attribute syntax
Informal description
The syntax definition for the `grindEq` attribute, which matches patterns of the form `= _` (equality with an arbitrary right-hand side term).
Lean.Parser.Attr.grindEqBoth definition
: Lean.ParserDescr✝
Full source
syntax grindEqBoth := atomic("_" "=" "_ ")
Grind equality both attribute syntax
Informal description
The syntax definition for the `grindEqBoth` attribute, which matches patterns of the form `_ = _` (equality between two arbitrary terms).
Lean.Parser.Attr.grindEqRhs definition
: Lean.ParserDescr✝
Full source
syntax grindEqRhs  := atomic("=" "_ ")
Grind equality right-hand side attribute syntax
Informal description
The syntax definition for the `grindEqRhs` attribute, which matches patterns of the form `= _` (equality with an arbitrary right-hand side term).
Lean.Parser.Attr.grindEqBwd definition
: Lean.ParserDescr✝
Full source
syntax grindEqBwd  := atomic("←" "= ") <|> atomic("<-" "= ")
Backward equality grinding tactic notation
Informal description
The syntax definition for the backward equality grinding tactic notation, which accepts either the symbol "← =" or "<- =" as input.
Lean.Parser.Attr.grindBwd definition
: Lean.ParserDescr✝
Full source
syntax grindBwd    := "← " <|> "-> "
Backward grinding tactic notation parser
Informal description
The parser descriptor for the backward grinding tactic notation, which accepts either the symbol "←" or "->" as input.
Lean.Parser.Attr.grindFwd definition
: Lean.ParserDescr✝
Full source
syntax grindFwd    := "→ " <|> "<- "
Forward grinding tactic notation
Informal description
The syntax definition for the forward grinding tactic notation, which accepts either the symbol "→" or "<-" as input.
Lean.Parser.Attr.grindRL definition
: Lean.ParserDescr✝
Full source
syntax grindRL     := "⇐ " <|> "<= "
`grindRL` attribute syntax
Informal description
The syntax definition for the `grindRL` attribute, which parses either the symbol `⇐` or `<=`.
Lean.Parser.Attr.grindLR definition
: Lean.ParserDescr✝
Full source
syntax grindLR     := "⇒ " <|> "=> "
`grindLR` attribute syntax
Informal description
The syntax definition for the `grindLR` attribute, which parses either the symbol `⇒` or `=>`.
Lean.Parser.Attr.grindUsr definition
: Lean.ParserDescr✝
Full source
syntax grindUsr    := &"usr "
`grindUsr` attribute syntax
Informal description
The syntax definition for the `grindUsr` attribute, which parses the keyword `"usr"` in the context of the `grind` tactic family.
Lean.Parser.Attr.grindCases definition
: Lean.ParserDescr✝
Full source
syntax grindCases  := &"cases "
`grindCases` attribute syntax
Informal description
The syntax definition for the `grindCases` attribute, which parses the keyword `"cases"` in the context of the `grind` tactic family.
Lean.Parser.Attr.grindCasesEager definition
: Lean.ParserDescr✝
Full source
syntax grindCasesEager := atomic(&"cases" &"eager ")
`cases eager` attribute parser
Informal description
The parser descriptor for the `cases eager` attribute in the `grind` tactic family.
Lean.Parser.Attr.grindIntro definition
: Lean.ParserDescr✝
Full source
syntax grindIntro  := &"intro "
`intro` attribute parser for grind tactic
Informal description
The syntax definition for the `grindIntro` attribute, which parses the keyword `"intro"` in the context of the `grind` tactic family.
Lean.Parser.Attr.grindMod definition
: Lean.ParserDescr✝
Full source
syntax grindMod := grindEqBoth <|> grindEqRhs <|> grindEq <|> grindEqBwd <|> grindBwd <|> grindFwd <|> grindRL <|> grindLR <|> grindUsr <|> grindCasesEager <|> grindCases <|> grindIntro
Grind tactic modifier syntax
Informal description
The syntax definition for the `grindMod` attribute, which combines various grinding tactic modifiers including equality handling (`grindEqBoth`, `grindEqRhs`, `grindEq`, `grindEqBwd`), directionality (`grindBwd`, `grindFwd`, `grindRL`, `grindLR`), and other operations (`grindUsr`, `grindCasesEager`, `grindCases`, `grindIntro`).
Lean.Parser.Attr.grind definition
: Lean.ParserDescr✝
Full source
syntax (name := grind) "grind" (grindMod)? : attr
Grind tactic attribute syntax
Informal description
The syntax definition for the `grind` attribute, which parses the keyword `"grind"` optionally followed by modifiers for the `grind` tactic.
Lean.Grind.Config structure
Full source
/--
The configuration for `grind`.
Passed to `grind` using, for example, the `grind (config := { matchEqs := true })` syntax.
-/
structure Config where
  /-- If `trace` is `true`, `grind` records used E-matching theorems and case-splits. -/
  trace : Bool := false
  /-- Maximum number of case-splits in a proof search branch. It does not include splits performed during normalization. -/
  splits : Nat := 8
  /-- Maximum number of E-matching (aka heuristic theorem instantiation) rounds before each case split. -/
  ematch : Nat := 5
  /--
  Maximum term generation.
  The input goal terms have generation 0. When we instantiate a theorem using a term from generation `n`,
  the new terms have generation `n+1`. Thus, this parameter limits the length of an instantiation chain. -/
  gen : Nat := 5
  /-- Maximum number of theorem instances generated using E-matching in a proof search tree branch. -/
  instances : Nat := 1000
  /-- If `matchEqs` is `true`, `grind` uses `match`-equations as E-matching theorems. -/
  matchEqs : Bool := true
  /-- If `splitMatch` is `true`, `grind` performs case-splitting on `match`-expressions during the search. -/
  splitMatch : Bool := true
  /-- If `splitIte` is `true`, `grind` performs case-splitting on `if-then-else` expressions during the search. -/
  splitIte : Bool := true
  /--
  If `splitIndPred` is `true`, `grind` performs case-splitting on inductive predicates.
  Otherwise, it performs case-splitting only on types marked with `[grind cases]` attribute. -/
  splitIndPred : Bool := false
  /-- By default, `grind` halts as soon as it encounters a sub-goal where no further progress can be made. -/
  failures : Nat := 1
  /-- Maximum number of heartbeats (in thousands) the canonicalizer can spend per definitional equality test. -/
  canonHeartbeats : Nat := 1000
  /-- If `ext` is `true`, `grind` uses extensionality theorems available in the environment. -/
  ext : Bool := true
  /-- If `verbose` is `false`, additional diagnostics information is not collected. -/
  verbose : Bool := true
  /-- If `clean` is `true`, `grind` uses `expose_names` and only generates accessible names. -/
  clean : Bool := true
  /--
  If `qlia` is `true`, `grind` may generate counterexamples for integer constraints
  using rational numbers, and ignoring divisibility constraints.
  This approach is cheaper but incomplete. -/
  qlia : Bool := false
  /--
  If `mbtc` is `true`, `grind` will use model-based theory commbination for creating new case splits.
  See paper "Model-based Theory Combination" for details.
  -/
  mbtc : Bool := true
  /--
  When set to `true` (default: `true`), local definitions are unfolded during normalization and internalization.
  In other words, given a local context with an entry `x : t := e`, the free variable `x` is reduced to `e`.
  Note that this behavior is also available in `simp`, but there its default is `false` because `simp` is not
  always used as a terminal tactic, and it important to preserve the abstractions introduced by users.
  Additionally, in `grind` we observed that `zetaDelta` is particularly important when combined with function induction.
  In such scenarios, the same let-expressions can be introduced by function induction and also by unfolding the
  corresponding definition. We want to avoid a situation in which `zetaDelta` is not applied to let-declarations
  introduced by function induction while `zeta` unfolds the definition, causing a mismatch.
  Finally, note that congruence closure is less effective on terms containing many binders such as
  `lambda` and `let` expressions.
  -/
  zetaDelta := true
  /--
  When `true` (default: `true`), performs zeta reduction of let expressions during normalization.
  That is, `let x := v; e[x]` reduces to `e[v]`. See also `zetaDelta`.
  -/
  zeta := true
  deriving Inhabited, BEq
Configuration for the `grind` tactic
Informal description
The structure representing the configuration options for the `grind` tactic, which can be passed to `grind` using syntax like `grind (config := { matchEqs := true })`.
Lean.Grind.instInhabitedConfig instance
: Inhabited✝ (@Lean.Grind.Config)
Full source
Inhabited, BEq
Default Configuration for the `grind` Tactic
Informal description
The configuration structure for the `grind` tactic is inhabited, with a default configuration.
Lean.Grind.instBEqConfig instance
: BEq✝ (@Lean.Grind.Config✝)
Full source
BEq
Boolean Equality for Grind Configuration
Informal description
The configuration structure for the `grind` tactic is equipped with a boolean equality relation.
Lean.Parser.Tactic.grindErase definition
: Lean.ParserDescr✝
Full source
syntax grindErase := "-" ident
`grindErase` syntax for identifier removal
Informal description
The parser descriptor for the `grindErase` tactic syntax, which allows removing an identifier from consideration in the `grind` tactic by prefixing it with a minus sign `-`.
Lean.Parser.Tactic.grindLemma definition
: Lean.ParserDescr✝
Full source
syntax grindLemma := (Attr.grindMod)? ident
`grindLemma` syntax for lemma specification in grinding tactic
Informal description
The syntax definition for the `grindLemma` tactic, which allows specifying a lemma to be used by the `grind` tactic, optionally preceded by a modifier attribute (`grindMod`).
Lean.Parser.Tactic.grindParam definition
: Lean.ParserDescr✝
Full source
syntax grindParam := grindErase <|> grindLemma
`grindParam` syntax for identifier removal or lemma specification
Informal description
The syntax definition for `grindParam` specifies that it can be either a `grindErase` (removing an identifier from consideration) or a `grindLemma` (specifying a lemma to be used by the `grind` tactic).
Lean.Parser.Tactic.grind definition
: Lean.ParserDescr✝
Full source
syntax (name := grind)
  "grind" optConfig (&" only")?
  (" [" withoutPosition(grindParam,*) "]")?
  ("on_failure " term)? : tactic
`grind` tactic syntax
Informal description
The `grind` tactic is a syntax definition for a tactic that can be configured with optional parameters, including a restriction to only certain operations (`only`), a list of parameters (either identifiers to remove or lemmas to use), and an optional fallback term to execute if the tactic fails.
Lean.Parser.Tactic.grindTrace definition
: Lean.ParserDescr✝
Full source
syntax (name := grindTrace)
  "grind?" optConfig (&" only")?
  (" [" withoutPosition(grindParam,*) "]")?
  ("on_failure " term)? : tactic
`grind?` tactic syntax with optional parameters and failure handling
Informal description
The syntax definition for the `grind?` tactic, which can optionally include configuration settings, a restriction to only certain parameters, a list of parameters (either for removal or lemma specification), and a term to execute on failure.