| 1 |
From elpi.apps Require Import tc. |
| 2 |
|
| 3 |
Elpi TC Solver Override TC.Solver All. |
| 4 |
|
| 5 |
(* TODO: How to add the #[deterministic] pragma in front of the class? *) |
| 6 |
(* #[deterministic] Class A (T : Type) := {succ : T -> T}. *) |
| 7 |
Class A (T : Type) := {succ : T -> T}. |
| 8 |
#[local] Instance B : A nat := {succ n := S n}. |
| 9 |
Instance C : A bool := {succ b := negb b}. |
| 10 |
Instance Prod (X Y: Type) `(A X, A Y) : A (X * Y) := |
| 11 |
{succ b := match b with (a, b) => (succ a, succ b) end}. |
| 12 |
|
| 13 |
Elpi Accumulate TC.Solver lp:{{ |
| 14 |
:after "firstHook" |
| 15 |
solve _ _ :- coq.say "Solving in ELPI!", fail. |
| 16 |
}}. |
| 17 |
|
| 18 |
Goal A (nat * (nat * bool)). apply _. Qed. |
| 19 |
|
| 20 |
Module M. |
| 21 |
Class B (T : nat). |
| 22 |
Section A. |
| 23 |
Instance X : B 1. Qed. |
| 24 |
Goal B 1. apply _. Qed. |
| 25 |
|
| 26 |
Global Instance Y : B 2. Qed. |
| 27 |
Goal B 2. apply _. Qed. |
| 28 |
End A. |
| 29 |
Goal B 1. Proof. Fail apply _. Abort. |
| 30 |
Goal B 2. Proof. apply _. Qed. |
| 31 |
|
| 32 |
Section B. |
| 33 |
Variable V : nat. |
| 34 |
Global Instance Z : `(B 0) -> B V. Qed. |
| 35 |
Global Instance W : B 0. Qed. |
| 36 |
End B. |
| 37 |
|
| 38 |
Goal B 0. apply _. Qed. |
| 39 |
Goal B 10. apply _. Qed. |
| 40 |
End M. |
| 41 |
|
| 42 |
Goal M.B 1. apply M.X. Qed. |
| 43 |
Goal M.B 0. apply _. Qed. |
| 44 |
Goal M.B 10. apply _. Qed. |
| 45 |
|
| 46 |
Elpi Query TC.Solver lp:{{ |
| 47 |
% Small test for instance order |
| 48 |
sigma I L\ |
| 49 |
std.findall (tc.instance _ _ _ _) I, |
| 50 |
std.map-filter I (x\y\ x = tc.instance _ y {{:gref M.B}} _) |
| 51 |
[{{:gref M.W}}, {{:gref M.Y}}, {{:gref M.Z}}]. |
| 52 |
}}. |
| 53 |
|
| 54 |
Module S. |
| 55 |
Class Cl (i: nat). |
| 56 |
#[local] Instance Cl1 : Cl 1. Qed. |
| 57 |
#[global] Instance Cl2 : Cl 2. Qed. |
| 58 |
#[export] Instance Cl3 : Cl 3. Qed. |
| 59 |
End S. |
| 60 |
|
| 61 |
Elpi TC Solver Override TC.Solver None. |
| 62 |
Goal S.Cl 1 /\ S.Cl 2 /\ S.Cl 3. |
| 63 |
Proof. |
| 64 |
split. all:cycle 1. |
| 65 |
split. |
| 66 |
apply _. |
| 67 |
Fail apply _. |
| 68 |
Import S. |
| 69 |
apply _. |
| 70 |
Fail apply _. |
| 71 |
Abort. |