-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pattern normalization in the
grind
tactic (#6538)
This PR ensures patterns provided by users are normalized. See new test to understand why this is needed.
- Loading branch information
1 parent
7b29f48
commit fd091d1
Showing
6 changed files
with
78 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/- | ||
Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Leonardo de Moura | ||
-/ | ||
prelude | ||
import Lean.Meta.Tactic.Simp.Simproc | ||
import Lean.Meta.Tactic.Grind.Simp | ||
import Lean.Meta.Tactic.Grind.DoNotSimp | ||
|
||
namespace Lean.Meta.Grind | ||
|
||
/-- Returns the array of simprocs used by `grind`. -/ | ||
protected def getSimprocs : MetaM (Array Simprocs) := do | ||
let s ← grindNormSimprocExt.getSimprocs | ||
let s ← addDoNotSimp s | ||
return #[s, (← Simp.getSEvalSimprocs)] | ||
|
||
/-- Returns the simplification context used by `grind`. -/ | ||
protected def getSimpContext : MetaM Simp.Context := do | ||
let thms ← grindNormExt.getTheorems | ||
Simp.mkContext | ||
(config := { arith := true }) | ||
(simpTheorems := #[thms]) | ||
(congrTheorems := (← getSimpCongrTheorems)) | ||
|
||
@[export lean_grind_normalize] | ||
def normalizeImp (e : Expr) : MetaM Expr := do | ||
let (r, _) ← Meta.simp e (← Grind.getSimpContext) (← Grind.getSimprocs) | ||
return r.expr | ||
|
||
end Lean.Meta.Grind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters