Compare commits

..

7 Commits

Author SHA1 Message Date
Leonardo de Moura
c35ec8668d fix: grind sort internalization
This PR ensures sorts are internalized by `grind`.
2025-09-20 11:24:22 -07:00
Leonardo de Moura
ec7add0b48 doc: ! modifier in grind parameters (#10474)
This PR adds a doc string for the `!` parameter modifier in `grind`.
2025-09-20 08:06:05 +00:00
Leonardo de Moura
9b842b7554 fix: message context in grind code actions (#10473)
This PR ensures the code action messages produced by `grind` include the
full context
2025-09-20 08:02:12 +00:00
Leonardo de Moura
fc718eac88 feat: code action for grind parameters (#10472)
This PR adds a code action for `grind` parameters. We need to use
`set_option grind.param.codeAction true` to enable the option. The PR
also adds a modifier to instruct `grind` to use the "default" pattern
inference strategy.
2025-09-20 07:30:39 +00:00
Michał Dobranowski
8b3c82cce2 fix: lake: GH action template condition (#10459)
This PR fixes a conditional check in a GitHub Action template generated
by Lake.

Closes #10420.
2025-09-20 06:33:42 +00:00
Mac Malone
0d1b7e6c88 chore: lake: fix tests/lean (#10470)
The ordering of the `--setup` JSON object changed at some point,
breaking this test. This PR fixes it by avoiding the potential for such
breakages.
2025-09-20 02:11:50 +00:00
Leonardo de Moura
d898c9ed17 fix: grind canonicalizer (#10469)
This PR fixes an incorrect optimization in the `grind` canonicalizer.
See the new test for an example that exposes the problem.
2025-09-20 01:24:54 +00:00
6 changed files with 32 additions and 5 deletions

View File

@@ -182,7 +182,10 @@ namespace Lean.Parser.Tactic
syntax grindErase := "-" ident
syntax grindLemma := ppGroup((Attr.grindMod ppSpace)? ident)
-- `!` for enabling minimal indexable subexpression restriction
/--
The `!` modifier instructs `grind` to consider only minimal indexable subexpressions
when selecting patterns.
-/
syntax grindLemmaMin := ppGroup("!" (Attr.grindMod ppSpace)? ident)
syntax grindParam := grindErase <|> grindLemma <|> grindLemmaMin

View File

@@ -1396,7 +1396,9 @@ def EMatchTheoremKind.toSyntax (kind : EMatchTheoremKind) : CoreM (TSyntax ``Par
private def save (ref : Syntax) (thm : EMatchTheorem) (isParam : Bool) (minIndexable : Bool) : SelectM Unit := do
-- We only save `thm` if the pattern is different from the ones that were already found.
if ( get).thms.all fun thm' => thm.patterns != thm'.patterns then
let pats thm.patterns.mapM fun p => (ppPattern p).toString
let pats thm.patterns.mapM fun p => do
let pats addMessageContextFull (ppPattern p)
pats.format
let openBracket := if isParam then "" else "["
let closeBracket := if isParam then "" else "]"
let msg := s!"{closeBracket} for pattern: {pats}"

View File

@@ -380,7 +380,13 @@ where
trace_goal[grind.internalize] "[{generation}] {e}"
match e with
| .bvar .. => unreachable!
| .sort .. => return ()
| .sort .. =>
/-
**Note**: It may seem wasteful to create ENodes for sorts, but it is useful for the E-matching module.
The E-matching module assumes that the arguments of an internalized application have also been internalized,
unless they are `grind` gadgets.
-/
mkENode' e generation
| .fvar .. =>
mkENode' e generation
checkAndAddSplitCandidate e

View File

@@ -296,7 +296,7 @@ jobs:
issues: write # Grants permission to create or update issues
pull-requests: write # Grants permission to create or update pull requests
needs: check-for-updates
if: ${{ needs.check-for-updates.outputs.is-update-available }}
if: ${{ needs.check-for-updates.outputs.is-update-available == 'true' }}
strategy: # Runs for each update discovered by the `check-for-updates` job.
max-parallel: 1 # Ensures that the PRs/issues are created in order.
matrix:

View File

@@ -17,7 +17,7 @@ test_out '"options":{"weak.foo":"bar"}' -v lean Lib/Basic.lean
# Test that imported workspace modules are pre-resolved
# for both other workspace modules and external files
test_out '"importArts":{"Lib.Basic":["' -v lean Lib.lean
test_out '"importArts":{"Lib.Basic":["' -v lean Test.lean
test_out '"importArts":{"Lib' -v lean Test.lean
# Test running a file works outside the workspace and working directory
test_out '"name":"_unknown"' -v lean ../../examples/hello/Hello.lean

View File

@@ -0,0 +1,16 @@
def f (α : Sort u) (_ : α) : Nat := 0
theorem feq : f (List α) x = 0 := rfl
/--
error: `grind` failed
case grind
h : ¬f Prop True = 0
⊢ False
-/
#guard_msgs in
example: f Prop True = 0 := by
grind -verbose [feq] -- must not produce error `Prop` has not been internalized
example: f Prop True = 0 := by
grind [f]