Debian Codegraph @

apps/tc/tests/test_backtrack_several_goals.v

raw
1 Module M.
2 Class C (i: nat).
3 Instance i1: C 1 := {}.
4 Instance i2: C 2 := {}.
5 Class E (i: nat).
6 Instance e1 : E 1 := {}.
7
8 Lemma m {i} {H : C i} {H1 : E i}: C i. Admitted.
9
10 Class D (i:nat) (o: C i).
11 Instance d1 (H: C 1) : D 1 H := {}.
12
13 Goal exists i, C i.
14 eexists.
15 Set Typeclasses Debug.
16 (* Here backtracking is done *)
17 apply m.
18 Qed.
19 End M.
20
21 Module M1.
22 Class C (i: nat).
23 Instance i1: C 1 := {}.
24 Instance i2: C 2 := {}.
25 Class E (i: nat).
26 Instance e1 : E 1 := {}.
27
28 Lemma m {i} (H : C i) (H1 : E i): C i. Admitted.
29
30 Class D (i:nat) (o: C i).
31 Instance d1 (H: C 1) : D 1 H := {}.
32
33 Goal exists i, C i.
34 eexists.
35 Set Typeclasses Debug.
36 apply m.
37 (*
38 Note: in coq the following command fails since apply is a single entry
39 command, i.e. it cannot receive multiple goal at the same time.
40 Therefore `apply _` will be triggered on the `n` goals.
41 *)
42 Fail all: apply _.
43 all: typeclasses eauto.
44 Qed.
45 End M1.
46
47 (* Here similar problems using the rocq-elpi solver *)
48 From elpi Require Import elpi tc.
49
50 Module ElpiBt.
51 Class C (i: nat).
52 Instance i1: C 1 := {}.
53 Instance i2: C 2 := {}.
54 Class E (i: nat).
55 Instance e1 : E 1 := {}.
56
57 Elpi Tactic T.
58
59 Elpi Accumulate lp:{{
60 msolve A B :- coq.say A, coq.ltac.all (coq.ltac.open solve-aux) A B.
61
62 pred solve-aux i:goal, o:list sealed-goal.
63 solve-aux (goal _ _ G _ _ as GG) L :-
64 coq.say "Goal is" {coq.term->string G},
65 solvee G S,
66 coq.say "Solution for" {coq.term->string G} "is" {coq.term->string S},
67 refine S GG L.
68
69 pred solvee o:term, o:term.
70 solvee {{C 2}} {{i2}}.
71 solvee {{C 1}} {{i1}}.
72 solvee {{E 1}} {{e1}}.
73 }}.
74
75
76 Goal exists i, C i /\ E i.
77 eexists.
78 split.
79 all : elpi T.
80 Qed.
81 End ElpiBt.
82
83 Module M_in_elpi.
84 Class C (i: nat).
85 Instance c0: C 0 := {}.
86 Instance c1: C 1 := {}.
87 Class E (i: nat).
88 Instance e0 : E 0 := {}.
89
90 Lemma m {i} {H : C i} {H1 : E i}: C i. Admitted.
91
92 Goal exists i, C i.
93 eexists.
94 apply m.
95 Qed.
96 End M_in_elpi.