-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move simplifier support to
GrindM
This PR refactors `grind` and adds support for invokind the simplifier using the `GrindM` monad.
- Loading branch information
1 parent
f9f8abe
commit 7de9466
Showing
5 changed files
with
83 additions
and
58 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,40 @@ | ||
/- | ||
Copyright (c) 2024 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.Main | ||
import Lean.Meta.Tactic.Grind.Util | ||
import Lean.Meta.Tactic.Grind.Types | ||
import Lean.Meta.Tactic.Grind.MarkNestedProofs | ||
|
||
namespace Lean.Meta.Grind | ||
|
||
-- TODO: use congruence closure and decision procedures during pre-processing | ||
-- TODO: implement `simp` discharger using preprocessor state | ||
|
||
/-- Simplifies the given expression using the `grind` simprocs and normalization theorems. -/ | ||
def simp (e : Expr) : GrindM Simp.Result := do | ||
let simpStats := (← get).simpStats | ||
let (r, simpStats) ← Meta.simp e (← read).simp (← read).simprocs (stats := simpStats) | ||
modify fun s => { s with simpStats } | ||
return r | ||
|
||
/-- | ||
Simplifies `e` using `grind` normalization theorems and simprocs, | ||
and then applies several other preprocessing steps. | ||
-/ | ||
def pre (e : Expr) : GrindM Simp.Result := do | ||
let r ← simp e | ||
let e' := r.expr | ||
let e' ← markNestedProofs e' | ||
let e' ← unfoldReducible e' | ||
let e' ← eraseIrrelevantMData e' | ||
let e' ← foldProjs e' | ||
let e' ← normalizeLevels e' | ||
let e' ← canon e' | ||
let e' ← shareCommon e' | ||
return { r with expr := e' } | ||
|
||
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