| 1 |
From elpi.apps Require Import tc. |
| 2 |
Elpi Debug "simple-compiler". |
| 3 |
Set TC NameShortPath. |
| 4 |
|
| 5 |
Elpi TC Solver Override TC.Solver All. |
| 6 |
|
| 7 |
Class A (T1 : Type). |
| 8 |
Class B (T1 : Type). |
| 9 |
|
| 10 |
Global Instance instA' (T1 : Type) (T2 : Type) : A bool. Qed. |
| 11 |
Global Instance instA (T1 : Type) `(B T1) : A T1. Qed. |
| 12 |
|
| 13 |
Global Instance instB (T1 : Type) `(A T1) : B T1. Qed. |
| 14 |
Global Instance instB' : B nat . Qed. |
| 15 |
|
| 16 |
Elpi Accumulate tc.db lp:{{ |
| 17 |
pred explored_gref o:gref. |
| 18 |
|
| 19 |
pred should_fail i:list gref, i:gref, i:gref. |
| 20 |
should_fail [] _ _. |
| 21 |
should_fail [Current | Tl] Current BlackElt :- !, |
| 22 |
if (std.mem Tl BlackElt) fail true. |
| 23 |
should_fail [_ | Tl] Current BlackElt :- !, |
| 24 |
should_fail Tl Current BlackElt. |
| 25 |
|
| 26 |
pred already_explored i:gref, i:gref. |
| 27 |
already_explored Current BlackElt :- |
| 28 |
std.findall (explored_gref _) As, |
| 29 |
std.map As (x\r\ x = explored_gref r) As', |
| 30 |
should_fail As' Current BlackElt. |
| 31 |
|
| 32 |
pred get_other i:gref, o:gref. |
| 33 |
|
| 34 |
pred under_extra i:gref, i:list prop, o:list prop. |
| 35 |
under_extra A B C :- std.map B (x\r\ (explored_gref A => x) = r) C1, |
| 36 |
C = [sigma x\ get_other A x, already_explored A x | C1]. |
| 37 |
|
| 38 |
:after "firstHook" |
| 39 |
tc.make-tc IsHead Ty Inst Hyp Clause :- !, |
| 40 |
app [global TC | TL] = Ty, |
| 41 |
tc.gref->pred-name TC TC_Str, |
| 42 |
std.append TL [Inst] Args, |
| 43 |
coq.elpi.predicate TC_Str Args Q, |
| 44 |
if (not IsHead) (Hyp = Hyp') (under_extra TC Hyp Hyp'), |
| 45 |
Clause = (Q :- Hyp'). |
| 46 |
}}. |
| 47 |
|
| 48 |
|
| 49 |
Elpi AddAllClasses. |
| 50 |
Elpi AddAllInstances. |
| 51 |
|
| 52 |
Elpi Command AddRecursivelyDependantTC. |
| 53 |
Elpi Accumulate Db tc.db. |
| 54 |
Elpi Accumulate lp:{{ |
| 55 |
main [trm (global A), trm (global B)] :- |
| 56 |
coq.elpi.accumulate _ "tc.db" |
| 57 |
(clause _ _ (get_other A B)), |
| 58 |
coq.elpi.accumulate _ "tc.db" |
| 59 |
(clause _ _ (get_other B A)). |
| 60 |
main L :- coq.say L. |
| 61 |
}}. |
| 62 |
|
| 63 |
|
| 64 |
Elpi AddRecursivelyDependantTC (A) (B). |
| 65 |
|
| 66 |
Elpi Bound Steps 10000. |
| 67 |
Check (_ : B bool). |
| 68 |
Check (_ : A nat). |
| 69 |
|