@@ -11,10 +11,16 @@ import Init.Grind
1111public section
1212namespace Lean.Meta.Grind
1313
14+ abbrev PropagatorMap := Std.HashMap Name (List Propagator)
15+
16+ def PropagatorMap.insert (m : PropagatorMap) (declName : Name) (p : Propagator) : PropagatorMap :=
17+ let ps := m[declName]? |>.getD []
18+ Std.HashMap.insert m declName (p :: ps)
19+
1420/-- Builtin propagators. -/
1521structure BuiltinPropagators where
16- up : Std.HashMap Name Propagator := {}
17- down : Std.HashMap Name Propagator := {}
22+ up : PropagatorMap := {}
23+ down : PropagatorMap := {}
1824 deriving Inhabited
1925
2026builtin_initialize builtinPropagatorsRef : IO.Ref BuiltinPropagators ← IO.mkRef {}
@@ -23,12 +29,8 @@ private def registerBuiltinPropagatorCore (declName : Name) (up : Bool) (proc :
2329 unless (← initializing) do
2430 throw (IO.userError s! "invalid builtin `grind` propagator declaration, it can only be registered during initialization" )
2531 if up then
26- if (← builtinPropagatorsRef.get).up.contains declName then
27- throw (IO.userError s! "invalid builtin `grind` upward propagator `{ declName} `, it has already been declared" )
2832 builtinPropagatorsRef.modify fun { up, down } => { up := up.insert declName proc, down }
2933 else
30- if (← builtinPropagatorsRef.get).down.contains declName then
31- throw (IO.userError s! "invalid builtin `grind` downward propagator `{ declName} `, it has already been declared" )
3234 builtinPropagatorsRef.modify fun { up, down } => { up, down := down.insert declName proc }
3335
3436def registerBuiltinUpwardPropagator (declName : Name) (proc : Propagator) : IO Unit :=
0 commit comments