Skip to content

Commit 4abc443

Browse files
authored
refactor: ENodeKey => ExprPtr (#8674)
1 parent d46188d commit 4abc443

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/Lean/Meta/Tactic/Grind/AlphaShareCommon.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Leonardo de Moura
55
-/
66
prelude
7-
import Lean.Meta.Tactic.Grind.ENodeKey
7+
import Lean.Meta.Tactic.Grind.ExprPtr
88

99
namespace Lean.Meta.Grind
1010

@@ -58,7 +58,7 @@ instance : BEq AlphaKey where
5858
beq k₁ k₂ := alphaEq k₁.expr k₂.expr
5959

6060
structure AlphaShareCommon.State where
61-
map : PHashMap ENodeKey Expr := {}
61+
map : PHashMap ExprPtr Expr := {}
6262
set : PHashSet AlphaKey := {}
6363

6464
abbrev AlphaShareCommonM := StateM AlphaShareCommon.State

src/Lean/Meta/Tactic/Grind/Arith/CommRing/Types.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura
66
prelude
77
import Lean.Data.PersistentArray
88
import Lean.Data.RBTree
9-
import Lean.Meta.Tactic.Grind.ENodeKey
9+
import Lean.Meta.Tactic.Grind.ExprPtr
1010
import Lean.Meta.Tactic.Grind.Arith.Util
1111
import Lean.Meta.Tactic.Grind.Arith.CommRing.Poly
1212

@@ -155,9 +155,9 @@ structure Ring where
155155
-/
156156
vars : PArray Expr := {}
157157
/-- Mapping from `Expr` to a variable representing it. -/
158-
varMap : PHashMap ENodeKey Var := {}
158+
varMap : PHashMap ExprPtr Var := {}
159159
/-- Mapping from Lean expressions to their representations as `RingExpr` -/
160-
denote : PHashMap ENodeKey RingExpr := {}
160+
denote : PHashMap ExprPtr RingExpr := {}
161161
/-- Next unique id for `EqCnstr`s. -/
162162
nextId : Nat := 0
163163
/-- Number of "steps": simplification and superposition. -/
@@ -189,9 +189,9 @@ structure State where
189189
/--
190190
Mapping from types to its "ring id". We cache failures using `none`.
191191
`typeIdOf[type]` is `some id`, then `id < rings.size`. -/
192-
typeIdOf : PHashMap ENodeKey (Option Nat) := {}
192+
typeIdOf : PHashMap ExprPtr (Option Nat) := {}
193193
/- Mapping from expressions/terms to their ring ids. -/
194-
exprToRingId : PHashMap ENodeKey Nat := {}
194+
exprToRingId : PHashMap ExprPtr Nat := {}
195195
steps := 0
196196
deriving Inhabited
197197

src/Lean/Meta/Tactic/Grind/Arith/Cutsat/Types.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ prelude
77
import Init.Data.Int.Linear
88
import Std.Internal.Rat
99
import Lean.Data.PersistentArray
10-
import Lean.Meta.Tactic.Grind.ENodeKey
10+
import Lean.Meta.Tactic.Grind.ExprPtr
1111
import Lean.Meta.Tactic.Grind.Arith.Util
1212

1313
namespace Lean.Meta.Grind.Arith.Cutsat
@@ -231,18 +231,18 @@ structure State where
231231
/-- Mapping from variables to their denotations. -/
232232
vars : PArray Expr := {}
233233
/-- Mapping from `Expr` to a variable representing it. -/
234-
varMap : PHashMap ENodeKey Var := {}
234+
varMap : PHashMap ExprPtr Var := {}
235235
/--
236236
Mapping from foreign terms to their variable and type (e.g., `Nat`). They are also marked using `markAsCutsatTerm`.
237237
-/
238-
foreignVarMap : PHashMap ENodeKey (Var × ForeignType) := {}
238+
foreignVarMap : PHashMap ExprPtr (Var × ForeignType) := {}
239239
foreignVars : PHashMap ForeignType (PArray Expr) := {}
240240
/--
241241
Some foreign variables encode nested terms such as `b+1`.
242242
This is a mapping from this kind of variable to the integer variable
243243
representing `natCast (b+1)`.
244244
-/
245-
foreignDef : PHashMap ENodeKey Var := {}
245+
foreignDef : PHashMap ExprPtr Var := {}
246246
/--
247247
Mapping from variables to divisibility constraints. Recall that we keep the divisibility constraint in solved form.
248248
Thus, we have at most one divisibility per variable. -/

src/Lean/Meta/Tactic/Grind/Arith/Offset/Types.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura
66
prelude
77
import Lean.Data.AssocList
88
import Lean.Data.PersistentArray
9-
import Lean.Meta.Tactic.Grind.ENodeKey
9+
import Lean.Meta.Tactic.Grind.ExprPtr
1010
import Lean.Meta.Tactic.Grind.Arith.Util
1111
import Lean.Meta.Tactic.Grind.Arith.Offset.Util
1212

@@ -43,9 +43,9 @@ structure State where
4343
/-- Mapping from `NodeId` to the `Expr` represented by the node. -/
4444
nodes : PArray Expr := {}
4545
/-- Mapping from `Expr` to a node representing it. -/
46-
nodeMap : PHashMap ENodeKey NodeId := {}
46+
nodeMap : PHashMap ExprPtr NodeId := {}
4747
/-- Mapping from `Expr` representing inequalites to constraints. -/
48-
cnstrs : PHashMap ENodeKey (Cnstr NodeId) := {}
48+
cnstrs : PHashMap ExprPtr (Cnstr NodeId) := {}
4949
/--
5050
Mapping from pairs `(u, v)` to a list of offset constraints on `u` and `v`.
5151
We use this mapping to implement exhaustive constraint propagation.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ namespace Lean.Meta.Grind
1414
unsafe ptrEq a b
1515

1616
/--
17-
Key for the `ENodeMap` and `ParentMap` map.
17+
Key for the `ENodeMap`, `ParentMap`, and other maps and sets.
1818
We use pointer addresses and rely on the fact all internalized expressions
1919
have been hash-consed, i.e., we have applied `shareCommon`.
2020
-/
21-
structure ENodeKey where
21+
structure ExprPtr where
2222
expr : Expr
2323

2424
abbrev hashPtrExpr (e : Expr) : UInt64 :=
2525
unsafe (ptrAddrUnsafe e >>> 3).toUInt64
2626

27-
instance : Hashable ENodeKey where
27+
instance : Hashable ExprPtr where
2828
hash k := hashPtrExpr k.expr
2929

30-
instance : BEq ENodeKey where
30+
instance : BEq ExprPtr where
3131
beq k₁ k₂ := isSameExpr k₁.expr k₂.expr
3232

3333
end Lean.Meta.Grind

src/Lean/Meta/Tactic/Grind/Types.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Lean.Meta.AbstractNestedProofs
1414
import Lean.Meta.Tactic.Simp.Types
1515
import Lean.Meta.Tactic.Util
1616
import Lean.Meta.Tactic.Ext
17-
import Lean.Meta.Tactic.Grind.ENodeKey
17+
import Lean.Meta.Tactic.Grind.ExprPtr
1818
import Lean.Meta.Tactic.Grind.AlphaShareCommon
1919
import Lean.Meta.Tactic.Grind.Attr
2020
import Lean.Meta.Tactic.Grind.ExtAttr
@@ -418,7 +418,7 @@ inductive NewFact where
418418
| eq (lhs rhs proof : Expr) (isHEq : Bool)
419419
| fact (prop proof : Expr) (generation : Nat)
420420

421-
abbrev ENodeMap := PHashMap ENodeKey ENode
421+
abbrev ENodeMap := PHashMap ExprPtr ENode
422422

423423
/--
424424
Key for the congruence table.
@@ -503,7 +503,7 @@ abbrev CongrTable (enodeMap : ENodeMap) := PHashSet (CongrKey enodeMap)
503503

504504
-- Remark: we cannot use pointer addresses here because we have to traverse the tree.
505505
abbrev ParentSet := Std.TreeSet Expr Expr.quickComp
506-
abbrev ParentMap := PHashMap ENodeKey ParentSet
506+
abbrev ParentMap := PHashMap ExprPtr ParentSet
507507

508508
/--
509509
The E-matching module instantiates theorems using the `EMatchTheorem proof` and a (partial) assignment.
@@ -650,7 +650,7 @@ structure Split.State where
650650
/-- Case-splits that have been inserted at `candidates` at some point. -/
651651
added : Std.HashSet SplitInfo := {}
652652
/-- Case-splits that have already been performed, or that do not have to be performed anymore. -/
653-
resolved : PHashSet ENodeKey := {}
653+
resolved : PHashSet ExprPtr := {}
654654
/--
655655
Sequence of cases steps that generated this goal. We only use this information for diagnostics.
656656
Remark: `casesTrace.length ≥ numSplits` because we don't increase the counter for `cases`
@@ -707,7 +707,7 @@ structure Goal where
707707
/-- Asserted facts -/
708708
facts : PArray Expr := {}
709709
/-- Cached extensionality theorems for types. -/
710-
extThms : PHashMap ENodeKey (Array Ext.ExtTheorem) := {}
710+
extThms : PHashMap ExprPtr (Array Ext.ExtTheorem) := {}
711711
/-- State of the E-matching module. -/
712712
ematch : EMatch.State
713713
/-- State of the case-splitting module. -/

0 commit comments

Comments
 (0)