| 1 |
From elpi.apps Require Import tc. |
| 2 |
|
| 3 |
Elpi TC Solver Override TC.Solver All. |
| 4 |
|
| 5 |
(* Base test *) |
| 6 |
Section S1. |
| 7 |
|
| 8 |
TC.Declare Class class1 (n : nat). |
| 9 |
|
| 10 |
(* TODO: here coq can solve the goal without applying Build_class1 *) |
| 11 |
Instance inst1 : class1 3. Proof. apply Build_class1. Qed. |
| 12 |
|
| 13 |
Goal exists x, class1 x. Proof. eexists. apply _. Qed. |
| 14 |
|
| 15 |
End S1. |
| 16 |
|
| 17 |
(* Deterministic class test *) |
| 18 |
Section S2. |
| 19 |
|
| 20 |
#[deterministic] TC.Declare Class class2 (n : nat). |
| 21 |
|
| 22 |
Instance inst2 : class2 1 | 0. Proof. apply Build_class2. Qed. |
| 23 |
Instance inst2' : class2 2 | 1. Proof. apply Build_class2. Qed. |
| 24 |
|
| 25 |
Class aux (i: nat). |
| 26 |
|
| 27 |
Instance inst_aux : forall n, class2 n -> aux n -> aux 3. Qed. |
| 28 |
Section S2'. |
| 29 |
Local Instance inst_aux' : aux 1. Qed. |
| 30 |
Goal aux 3. apply _. Qed. |
| 31 |
End S2'. |
| 32 |
|
| 33 |
Section S2'. |
| 34 |
Local Instance inst_aux'' : aux 2. Qed. |
| 35 |
Goal aux 3. |
| 36 |
Proof. |
| 37 |
Succeed apply (inst_aux 2 inst2' inst_aux''). |
| 38 |
(* Note: since class2 is deterministic we cannot backtrack. |
| 39 |
The first hypothesis of inst_aux is unified to inst2, |
| 40 |
this causes `aux 2` to fail. The instance inst2' is not tried |
| 41 |
due to the deterministic class *) |
| 42 |
Fail apply _. |
| 43 |
Abort. |
| 44 |
End S2'. |
| 45 |
|
| 46 |
End S2. |
| 47 |
|
| 48 |
(* Mode test *) |
| 49 |
Section S3. |
| 50 |
#[mode(i)] TC.Declare Class class3 (n : nat). |
| 51 |
Instance inst3 : class3 0. Proof. apply Build_class3. Qed. |
| 52 |
|
| 53 |
(* Elpi Print TC.Solver "elpi.apps.tc.examples/TC.Solver". *) |
| 54 |
|
| 55 |
Goal exists x, class3 x. |
| 56 |
Proof. |
| 57 |
eexists. |
| 58 |
Succeed apply inst3. |
| 59 |
Fail apply _. |
| 60 |
Abort. |
| 61 |
|
| 62 |
End S3. |
| 63 |
|
| 64 |
Section S31. |
| 65 |
#[mode(o=ff)] TC.Declare Class class31 (n : nat). |
| 66 |
Instance inst31 : class31 0. Proof. apply Build_class31. Qed. |
| 67 |
|
| 68 |
Goal exists x, class31 x. |
| 69 |
Proof. |
| 70 |
eexists. |
| 71 |
Succeed apply inst31. |
| 72 |
Fail apply _. |
| 73 |
Abort. |
| 74 |
|
| 75 |
End S31. |
| 76 |
|