Skip to content

Commit e99bab2

Browse files
authored
Merge pull request #559 from Seasawher/auto-update-branch
2 parents 176991b + 1e81981 commit e99bab2

File tree

6 files changed

+415
-66
lines changed

6 files changed

+415
-66
lines changed

docs/attributes.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Attributes
22

3-
Mathlib version: `26fffffcccd7299b26cf63fac902165bc553fd56`
3+
Mathlib version: `3ea6690c3470d61c7d4fd71e7efd6336a6d05ffd`
44

55
## Std.Internal.tree_tac
66
simp theorems used by internal DTreeMap lemmas
@@ -827,7 +827,7 @@ Lemmas involving `<` or `≤` can also be marked `@[bound]` for use in the relat
827827
Generate the `.toCtorIdx` and `.ctor.elim` definitions for the given inductive.
828828
829829
This attribute is only meant to be used in `Init.Prelude` to build these constructions for
830-
types where we did not generate them imediatelly (due to `set_option genCtorIdx false`).
830+
types where we did not generate them immediately (due to `set_option genCtorIdx false`).
831831
832832
## ghost_simps
833833
Simplification rules for ghost equations.
@@ -1063,6 +1063,10 @@ This corresponds to the `instance (priority := prio)` notation.
10631063
## is_poly
10641064
A stub attribute for `is_poly`.
10651065

1066+
## library_suggestions
1067+
library suggestions selector
1068+
Attribute for registering library suggestions selectors.
1069+
10661070
## macro
10671071
macro elaborator
10681072
Registers a macro expander for a given syntax node kind.
@@ -1468,6 +1472,9 @@ specialized.
14681472
## stx_parser
14691473
parser
14701474

1475+
## suggest_for
1476+
suggest other (incorrect, not-existing) identifiers that someone might use when they actually want this definition
1477+
14711478
## symm
14721479
symmetric relation
14731480
Tags symmetry lemmas to be used by the `symm` tactic.
@@ -1501,6 +1508,11 @@ Attribute adding a tactic analysis pass from a `Config` structure.
15011508
## tactic_tag
15021509
Register a tactic parser as an alternative of an existing tactic, so they can be grouped together in documentation.
15031510

1511+
## tagged_return
1512+
mark extern definition to always return tagged values
1513+
Marks an extern definition to be guaranteed to always return tagged values.
1514+
This information is used to optimize reference counting in the compiler.
1515+
15041516
## term_elab
15051517
term elaborator
15061518
Registers a term elaborator for the given syntax node kind.

docs/commands.md

Lines changed: 139 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Commands
22

3-
Mathlib version: `26fffffcccd7299b26cf63fac902165bc553fd56`
3+
Mathlib version: `3ea6690c3470d61c7d4fd71e7efd6336a6d05ffd`
44

55
## \#adaptation_note
66
Defined in: `adaptationNoteCmd`
@@ -423,9 +423,14 @@ Defined in: `Lean.Grind.grindLintSkip`
423423
`#grind_lint skip thm₁ …` marks the given theorem(s) to be skipped entirely by `#grind_lint check`.
424424
Skipped theorems are neither analyzed nor reported, but may still be used for
425425
instantiation when analyzing other theorems.
426-
Example:
426+
427+
`#grind_lint skip suffix name₁ …` marks all theorems with the given suffix(es) to be skipped.
428+
For example, `#grind_lint skip suffix foo` will skip `bar.foo`, `qux.foo`, etc.
429+
430+
Examples:
427431
```lean
428432
#grind_lint skip Array.range_succ
433+
#grind_lint skip suffix append
429434
```
430435

431436
## \#grind_lint
@@ -592,7 +597,7 @@ Position reporting:
592597
`#guard_msgs` appears.
593598
- `positions := false` does not report position info.
594599

595-
For example, `#guard_msgs (error, drop all) in cmd` means to check warnings and drop
600+
For example, `#guard_msgs (error, drop all) in cmd` means to check errors and drop
596601
everything else.
597602

598603
The command elaborator has special support for `#guard_msgs` for linting.
@@ -1777,9 +1782,127 @@ inductive types defined at `Prelude.lean`.
17771782
Temporarily also controls the generation of the `ctorIdx` definition.
17781783
It is meant for bootstrapping purposes only.
17791784

1785+
## grind_annotated
1786+
Defined in: `Lean.Parser.Command.grindAnnotated`
1787+
1788+
`grind_annotated "YYYY-MM-DD"` marks the current file as having been manually annotated for `grind`.
1789+
1790+
When the LibrarySuggestion framework is called with `caller := "grind"` (as happens when using
1791+
`grind +suggestions`), theorems from grind-annotated files are excluded from premise selection.
1792+
This is because these files have already been manually reviewed and annotated with appropriate
1793+
`@[grind]` attributes.
1794+
1795+
The date argument (in YYYY-MM-DD format) records when the file was annotated. This is currently
1796+
informational only, but may be used in the future to detect files that have been significantly
1797+
modified since annotation and may need re-review.
1798+
1799+
Example:
1800+
```lean
1801+
grind_annotated "2025-01-15"
1802+
```
1803+
1804+
This command should typically appear near the top of a file, after imports.
1805+
17801806
## grind_pattern
17811807
Defined in: `Lean.Parser.Command.grindPattern`
17821808

1809+
The `grind_pattern` command can be used to manually select a pattern for theorem instantiation.
1810+
Enabling the option `trace.grind.ematch.instance` causes `grind` to print a trace message for each
1811+
theorem instance it generates, which can be helpful when determining patterns.
1812+
1813+
When multiple patterns are specified together, all of them must match in the current context before
1814+
`grind` attempts to instantiate the theorem. This is referred to as a *multi-pattern*.
1815+
This is useful for theorems such as transitivity rules, where multiple premises must be simultaneously
1816+
present for the rule to apply.
1817+
1818+
In the following example, `R` is a transitive binary relation over `Int`.
1819+
```
1820+
opaque R : Int → Int → Prop
1821+
axiom Rtrans {x y z : Int} : R x y → R y z → R x z
1822+
```
1823+
To use the fact that `R` is transitive, `grind` must already be able to satisfy both premises.
1824+
This is represented using a multi-pattern:
1825+
```lean
1826+
grind_pattern Rtrans => R x y, R y z
1827+
1828+
example {a b c d} : R a b → R b c → R c d → R a d := by
1829+
grind
1830+
```
1831+
The multi-pattern `R x y`, `R y z` instructs `grind` to instantiate `Rtrans` only when both `R x y`
1832+
and `R y z` are available in the context. In the example, `grind` applies `Rtrans` to derive `R a c`
1833+
from `R a b` and `R b c`, and can then repeat the same reasoning to deduce `R a d` from `R a c` and
1834+
`R c d`.
1835+
1836+
You can add constraints to restrict theorem instantiation. For example:
1837+
```lean
1838+
grind_pattern extract_extract => (as.extract i j).extract k l where
1839+
as =/= #[]
1840+
```
1841+
The constraint instructs `grind` to instantiate the theorem only if `as` is **not** definitionally equal
1842+
to `#[]`.
1843+
1844+
## Constraints
1845+
1846+
- `x =/= term`: The term bound to `x` (one of the theorem parameters) is **not** definitionally equal to `term`.
1847+
The term may contain holes (i.e., `_`).
1848+
1849+
- `x =?= term`: The term bound to `x` is definitionally equal to `term`.
1850+
The term may contain holes (i.e., `_`).
1851+
1852+
- `size x < n`: The term bound to `x` has size less than `n`. Implicit arguments
1853+
and binder types are ignored when computing the size.
1854+
1855+
- `depth x < n`: The term bound to `x` has depth less than `n`.
1856+
1857+
- `is_ground x`: The term bound to `x` does not contain local variables or meta-variables.
1858+
1859+
- `is_value x`: The term bound to `x` is a value. That is, it is a constructor fully applied to value arguments,
1860+
a literal (`Nat`, `Int`, `String`, etc.), or a lambda `fun x => t`.
1861+
1862+
- `is_strict_value x`: Similar to `is_value`, but without lambdas.
1863+
1864+
- `not_value x`: The term bound to `x` is a **not** value (see `is_value`).
1865+
1866+
- `not_strict_value x`: Similar to `not_value`, but without lambdas.
1867+
1868+
- `gen < n`: The theorem instance has generation less than `n`. Recall that each term is assigned a
1869+
generation, and terms produced by theorem instantiation have a generation that is one greater than
1870+
the maximal generation of all the terms used to instantiate the theorem. This constraint complements
1871+
the `gen` option available in `grind`.
1872+
1873+
- `max_insts < n`: A new instance is generated only if less than `n` instances have been generated so far.
1874+
1875+
- `guard e`: The instantiation is delayed until `grind` learns that `e` is `true` in this state.
1876+
1877+
- `check e`: Similar to `guard e`, but `grind` checks whether `e` is implied by its current state by
1878+
assuming `¬ e` and trying to deduce an inconsistency.
1879+
1880+
## Example
1881+
1882+
Consider the following example where `f` is a monotonic function
1883+
```
1884+
opaque f : Nat → Nat
1885+
axiom fMono : x ≤ y → f x ≤ f y
1886+
```
1887+
and you want to instruct `grind` to instantiate `fMono` for every pair of terms `f x` and `f y` when
1888+
`x ≤ y` and `x` is **not** definitionally equal to `y`. You can use
1889+
```
1890+
grind_pattern fMono => f x, f y where
1891+
guard x ≤ y
1892+
x =/= y
1893+
```
1894+
Then, in the following example, only three instances are generated.
1895+
```lean
1896+
/--
1897+
trace: [grind.ematch.instance] fMono: a ≤ f a → f a ≤ f (f a)
1898+
[grind.ematch.instance] fMono: f a ≤ f (f a) → f (f a) ≤ f (f (f a))
1899+
[grind.ematch.instance] fMono: a ≤ f (f a) → f a ≤ f (f (f a))
1900+
-/
1901+
#guard_msgs in
1902+
example : f b = f c → a ≤ f a → f (f a) ≤ f (f (f a)) := by
1903+
set_option trace.grind.ematch.instance true in
1904+
grind
1905+
```
17831906

17841907
## grind_propagator
17851908
Defined in: `Lean.Parser.«command_Grind_propagator___(_):=_»`
@@ -2853,6 +2976,19 @@ Defined in: `Mathlib.WhatsNew.commandWhatsnewIn__`
28532976
`whatsnew in $command` executes the command and then prints the
28542977
declarations that were added to the environment.
28552978

2979+
## with_weak_namespace
2980+
Defined in: `Lean.Parser.Command.withWeakNamespace`
2981+
2982+
`with_weak_namespace <id> <cmd>` changes the current namespace to `<id>` for the duration of
2983+
executing command `<cmd>`, without causing scoped things to go out of scope.
2984+
2985+
This is in contrast to `namespace <id>` which pushes a new scope and deactivates scoped entries
2986+
from the previous namespace. `with_weak_namespace` modifies the existing scope's namespace,
2987+
so scoped extensions remain active.
2988+
2989+
This is primarily useful for defining syntax extensions that should be scoped to a different
2990+
namespace than the current one.
2991+
28562992
## with_weak_namespace
28572993
Defined in: `Lean.Elab.Command.commandWith_weak_namespace__`
28582994

0 commit comments

Comments
 (0)