Skip to content

Commit

Permalink
feat: add appMap field to Goal
Browse files Browse the repository at this point in the history
  • Loading branch information
leodemoura committed Dec 29, 2024
1 parent 58943bc commit 7b59c38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Lean/Meta/Tactic/Grind/Internalize.lean
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def addCongrTable (e : Expr) : GoalM Unit := do
else
modify fun s => { s with congrTable := s.congrTable.insert { e } }

private def updateAppMap (e : Expr) : GoalM Unit := do
let key := e.toHeadIndex
modify fun s => { s with
appMap := if let some es := s.appMap.find? key then
s.appMap.insert key (e :: es)
else
s.appMap.insert key [e]
}

partial def internalize (e : Expr) (generation : Nat) : GoalM Unit := do
if (← alreadyInternalized e) then return ()
match e with
Expand Down Expand Up @@ -63,6 +72,7 @@ partial def internalize (e : Expr) (generation : Nat) : GoalM Unit := do
registerParent e arg
mkENode e generation
addCongrTable e
updateAppMap e
propagateUp e

end Lean.Meta.Grind
7 changes: 7 additions & 0 deletions src/Lean/Meta/Tactic/Grind/Types.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Leonardo de Moura
-/
prelude
import Lean.Util.ShareCommon
import Lean.HeadIndex
import Lean.Meta.Basic
import Lean.Meta.CongrTheorems
import Lean.Meta.AbstractNestedProofs
Expand Down Expand Up @@ -258,6 +259,12 @@ structure Goal where
enodes : ENodes := {}
parents : ParentMap := {}
congrTable : CongrTable enodes := {}
/--
A mapping from each function application index (`HeadIndex`) to a list of applications with that index.
Recall that the `HeadIndex` for a constant is its constant name, and for a free variable,
it is its unique id.
-/
appMap : PHashMap HeadIndex (List Expr) := {}
/-- Equations to be processed. -/
newEqs : Array NewEq := #[]
/-- `inconsistent := true` if `ENode`s for `True` and `False` are in the same equivalence class. -/
Expand Down

0 comments on commit 7b59c38

Please sign in to comment.