Skip to content

Commit e721ac7

Browse files
Sketch of an extensible implementation of crush.
1 parent f1c41f8 commit e721ac7

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Require Ltac2.Ltac2.
2+
Require Import skylabs.ltac2.tc_dispatch.lookup.
3+
4+
(**
5+
[crush_ext] is An extensible version of [crush].
6+
7+
Users can add new tactics / strategies by adding [Ltac2Lookup] hints
8+
to the [crush_ext] database.
9+
*)
10+
11+
Create HintDb crush_ext discriminated.
12+
13+
Module ltac2.
14+
Import Ltac2.Init.
15+
Import Ltac2.Notations.
16+
Ltac2 crush2 () :=
17+
let dbs := Some [ident:(crush_ext)] in
18+
repeat (ltac2.goal_dispatch_with dbs).
19+
End ltac2.
20+
21+
Ltac crush_ext :=
22+
ltac2:(ltac2.crush2 ()).

rocq-ltac2-tc-dispatch/theories/lookup.v

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Module ltac2.
3737
| List.cons ?c ?cs => f c :: list_of_list_constr f cs
3838
end.
3939

40-
Ltac2 goal_dispatch () :=
40+
Ltac2 goal_dispatch_with (dbs : ident list option) :=
4141
let g := Control.goal () in
4242
let query := constr:(Ltac2Lookup $g) in
4343
(* let _ := printf "query=%t" query in *)
44-
let inst := Constr.Unsafe.make (TC.resolve None query) in
44+
let inst := Constr.Unsafe.make (TC.resolve dbs query) in
4545
(* let _ := printf "inst=%t" inst in *)
4646
let flags := RedFlags.all in
4747
let reduced_inst := Std.eval_cbv flags inst in
@@ -68,8 +68,9 @@ Module ltac2.
6868
| _ =>
6969
Control.zero (Tactic_failure (Some (Message.of_string "Could not reduce instance to record.")))
7070
end.
71+
7172
End ltac2.
7273

7374
Ltac goal_dispatch :=
7475
idtac;
75-
ltac2:(ltac2.goal_dispatch ()).
76+
ltac2:(ltac2.goal_dispatch_with None).

0 commit comments

Comments
 (0)