attr ::= ...
| Marks a theorem or definition for use by the `grind` tactic.
An optional modifier (e.g. `=`, `→`, `←`, `cases`, `intro`, `ext`, `inj`, etc.)
controls how `grind` uses the declaration:
* whether it is applied forwards, backwards, or both,
* whether equalities are used on the left, right, or both sides,
* whether case-splits, constructors, extensionality, or injectivity are applied,
* or whether custom instantiation patterns are used.
See the individual modifier docstrings for details.
grind grindMod?
The grind
attribute automatically generates an E-matching pattern for a theorem, using a strategy determined by the provided modifier.
If no modifier is provided, then grind
suggests suitable modifiers, displaying the resulting patterns.
attr ::= ...
| Like `@[grind]`, but enforces the **minimal indexable subexpression condition**:
when several subterms cover the same free variables, `grind!` chooses the smallest one.
This influences E-matching pattern selection.
### Example
```lean
theorem fg_eq (h : x > 0) : f (g x) = x
@[grind <-] theorem fg_eq (h : x > 0) : f (g x) = x
-- Pattern selected: `f (g x)`
-- With minimal subexpression:
@[grind! <-] theorem fg_eq (h : x > 0) : f (g x) = x
-- Pattern selected: `g x`
grind! grindMod?
The grind!
attribute automatically generates an E-matching pattern for a theorem, using a strategy determined by the provided modifier.
It additionally enforces the condition that the selected pattern(s) should be minimal indexable subexpressions.
attr ::= ...
| Like `@[grind]`, but also prints the pattern(s) selected by `grind`
as info messages. Useful for debugging annotations and modifiers.
grind? grindMod?
The grind?
displays the pattern that was generated.
attr ::= ...
| Like `@[grind!]`, but also prints the pattern(s) selected by `grind`
as info messages. Combines minimal subexpression selection with debugging output.
grind!? grindMod?
The grind!?
attribute is equivalent to grind!
, except it displays the resulting pattern for inspection.
Without any modifier, @[grind]
traverses the conclusion and then the hypotheses from left to right, adding patterns as they increase the coverage, stopping when all arguments are covered.
This default strategy can be explicitly requested using the Lean.Parser.Attr.grindDef
The `.` modifier instructs `grind` to select a multi-pattern by traversing the conclusion of the
theorem, and then the hypotheses from eft to right. We say this is the default modifier.
Each time it encounters a subexpression which covers an argument which was not
previously covered, it adds that subexpression as a pattern, until all arguments have been covered.
If `grind!` is used, then only minimal indexable subexpressions are considered.
.
modifier.
In addition to using the default strategy, the attribute checks which other strategies could be applied, and displays all of the resulting patterns.