lean4-htt/stage0/src
Leonardo de Moura efb398b040
feat: new grind pattern inference heuristic and code action (#10422)
This PR implements the new E-matching pattern inference heuristic for
`grind`. It is not enabled yet. You can activate the new behavior using
`set_option backward.grind.inferPattern false`. Here is a summary of the
new behavior.

* `[grind =]`, `[grind =_]`, `[grind _=_]`, `[grind <-=]`: no changes;
we keep the current behavior.
  
* `[grind ->]`, `[grind <-]`, `[grind =>]`, `[grind <=]`: we stop using
the *minimal indexable subexpression* and instead use the first
indexable one.

* `[grind! <mod>]`: behaves like `[grind <mod>]` but uses the minimal
indexable subexpression restriction. We generate an error if the user
writes `[grind! =]`, `[grind! =_]`, `[grind! _=_]`, or `[grind! <-=]`,
since there is no pattern search in these cases.
  
* `[grind]`: it tries `=`, `=_`, `<-`, `->`, `<=`, `=>` with and without
the minimal indexable subexpression restriction. For the ones that work,
we generate a code action to encourage users to select the one they
prefer.

* `[grind!]`: it tries `<-`, `->`, `<=`, `=>` using the minimal
indexable subexpression restriction. For the ones that work, we generate
a code action to encourage users to select the one they prefer.

* `[grind? <mod>]`: where `<mod>` is one of the modifiers above, it
behaves like `[grind <mod>]` but also displays the pattern.
  
Example:
```lean
/--
info: Try these:
  • [grind =] for pattern: [f (g #0)]
  • [grind =_] for pattern: [r #0 #0]
  • [grind! ←] for pattern: [g #0]
-/
#guard_msgs in
@[grind] axiom fg₇ : f (g x) = r x x
```
2025-09-17 02:44:11 +00:00
..
bin chore: update stage0 2025-02-10 11:58:06 +00:00
cmake chore: update stage0 2025-08-22 08:30:43 +00:00
include/lean chore: update stage0 2025-08-12 05:06:58 +00:00
initialize chore: update stage0 2025-07-11 08:18:55 +00:00
kernel chore: update stage0 2025-08-12 21:07:52 +00:00
lake chore: update stage0 2025-05-14 16:03:07 +00:00
Lean chore: update stage0 2025-06-24 05:02:20 +00:00
library chore: update stage0 2025-09-11 12:27:01 +00:00
runtime chore: update stage0 2025-09-15 15:31:41 +00:00
shell chore: update stage0 2025-09-10 07:49:18 +00:00
util chore: update stage0 2025-08-27 09:58:40 +00:00
cadical.mk chore: update stage0 2025-05-03 00:16:43 +00:00
CMakeLists.txt chore: update stage0 2025-09-16 09:49:47 +00:00
config.h.in chore: update stage0 2025-04-03 03:26:05 +00:00
githash.h.in
lakefile.toml.in chore: update stage0 2025-09-14 08:05:12 +00:00
lean-toolchain chore: update stage0 (#3041) 2023-12-08 12:14:47 +00:00
lean.mk.in chore: update stage0 2025-08-26 17:42:03 +00:00
out chore: update stage0 2025-08-27 09:58:40 +00:00
stdlib.make.in chore: further split libleanshared on Windows to avoid symbol limit (#10136) 2025-08-26 16:01:57 +00:00
stdlib_flags.h feat: new grind pattern inference heuristic and code action (#10422) 2025-09-17 02:44:11 +00:00
version.h.in chore: update stage0 2025-03-12 10:19:24 +00:00