| 1 |
From elpi Require Import elpi. |
| 2 |
|
| 3 |
Elpi Tactic data_passing. |
| 4 |
Elpi Accumulate lp:{{ |
| 5 |
shorten coq.ltac.{ open , thenl , set-goal-arguments }. |
| 6 |
|
| 7 |
pred dup i:goal, o:list sealed-goal. |
| 8 |
dup (goal _ _ _ _ [trm T] as G) GS :- |
| 9 |
refine {{ _ lp:T }} G GL, |
| 10 |
std.map GL (set-goal-arguments [trm T] G) GS. % passing an argument to subgoals |
| 11 |
|
| 12 |
|
| 13 |
pred clear i:goal, o:list sealed-goal. |
| 14 |
clear (goal C _ _ E [trm T]) _ :- |
| 15 |
std.map C (x\r\x = decl r _ _) Names, |
| 16 |
std.filter Names (x\not (x = T)) InScope, |
| 17 |
prune E InScope. |
| 18 |
|
| 19 |
solve (goal _ _ _ _ [trm T] as G) GL :- name T, |
| 20 |
thenl [open dup, open clear] (seal G) GL. |
| 21 |
|
| 22 |
}}. |
| 23 |
|
| 24 |
|
| 25 |
Goal forall z x : nat, True. |
| 26 |
intros z x. |
| 27 |
elpi data_passing (x). |
| 28 |
Fail Check x. |
| 29 |
Check z. |
| 30 |
intro y. |
| 31 |
Abort. |
| 32 |
|
| 33 |
|
| 34 |
(* Abstract *) |
| 35 |
|
| 36 |
Ltac horror := abstract (exact I). |
| 37 |
|
| 38 |
Elpi Command define_it. |
| 39 |
Elpi Accumulate lp:{{ |
| 40 |
main [] :- |
| 41 |
coq.elaborate-skeleton _ {{ True }} Bo ok, |
| 42 |
coq.ltac.collect-goals Bo [SealedGoal] [], |
| 43 |
coq.ltac.open (g\gl\coq.ltac.call "horror" [] g gl ok) SealedGoal [], |
| 44 |
coq.locate "elpi_subproof" _, |
| 45 |
coq.env.add-const "it" Bo _ @transparent! C_. |
| 46 |
|
| 47 |
}}. |
| 48 |
|
| 49 |
Elpi define_it. |
| 50 |
|
| 51 |
Print it. |
| 52 |
About it. |
| 53 |
|
| 54 |
Print elpi_subproof. |
| 55 |
About elpi_subproof. |
| 56 |
|
| 57 |
Print Assumptions it. |
| 58 |
|
| 59 |
|
| 60 |
Elpi Tactic test_dep. |
| 61 |
Elpi Accumulate lp:{{ |
| 62 |
solve (goal _ _ {{ _ -> _ }} _ _) _. |
| 63 |
}}. |
| 64 |
|
| 65 |
Goal nat -> nat. |
| 66 |
elpi test_dep. |
| 67 |
Abort. |
| 68 |
|
| 69 |
Goal forall T : Type, T -> T. |
| 70 |
Fail elpi test_dep. |
| 71 |
intro T. |
| 72 |
elpi test_dep. |
| 73 |
Abort. |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
Elpi Tactic barendregt. |
| 78 |
Elpi Accumulate lp:{{ |
| 79 |
solve (goal _ _ Ty _ Args as G) GL :- |
| 80 |
coq.say Ty, |
| 81 |
((pi N N' T F ID ID1\ |
| 82 |
copy (fun N T F) (fun N' T1 F1) :- !, |
| 83 |
coq.name->id N ID, |
| 84 |
coq.ltac.fresh-id ID T ID1, |
| 85 |
if (Args = []) true (std.assert! (ID = ID1) "collision"), |
| 86 |
coq.id->name ID1 N', |
| 87 |
copy T T1, |
| 88 |
@pi-decl N T x\ copy (F x) (F1 x)) => |
| 89 |
copy Ty Ty'), |
| 90 |
refine {{ _ : lp:Ty' }} G GL. |
| 91 |
}}. |
| 92 |
|
| 93 |
Axiom map : (nat -> nat) -> nat. |
| 94 |
Lemma test x : map (fun x => x + 1) = x. |
| 95 |
Proof. |
| 96 |
Fail elpi barendregt True. |
| 97 |
elpi barendregt. |
| 98 |
elpi barendregt True. |
| 99 |
Abort. |
| 100 |
|
| 101 |
|
| 102 |
(*******************) |
| 103 |
|
| 104 |
Elpi Tactic simple. |
| 105 |
Elpi Accumulate lp:{{ |
| 106 |
solve G GL :- |
| 107 |
coq.say G, |
| 108 |
coq.ltac.simple.refine.elaborate {{ conj _ _ }} G GL', |
| 109 |
coq.say GL', |
| 110 |
std.map GL' (x\r\r = seal x) GL. |
| 111 |
solve G GL :- |
| 112 |
coq.say G, |
| 113 |
coq.ltac.simple.refine.elaborate {{ ex_intro _ (fun w => _) _ }} G GL', |
| 114 |
coq.say GL', |
| 115 |
std.map GL' (x\r\r = seal x) GL. |
| 116 |
|
| 117 |
}}. |
| 118 |
|
| 119 |
Goal True -> False -> True /\ False. |
| 120 |
intros. |
| 121 |
elpi simple. |
| 122 |
assumption. |
| 123 |
assumption. |
| 124 |
Abort. |
| 125 |
|
| 126 |
Goal exists f : nat -> nat, forall y, y = f 1. |
| 127 |
intros. |
| 128 |
elpi simple. |
| 129 |
Unshelve. |
| 130 |
admit. |
| 131 |
Show. |
| 132 |
Abort. |
| 133 |
|
| 134 |
|
| 135 |
Elpi Tactic dummy. |
| 136 |
Elpi Accumulate lp:{{ solve _ _. }}. |
| 137 |
|
| 138 |
(* bug #968 *) |
| 139 |
Goal O = O /\ 1 = 1. |
| 140 |
split. |
| 141 |
Show Existentials. |
| 142 |
Set Debug "elpi". |
| 143 |
|
| 144 |
elpi dummy. |
| 145 |
Unshelve. |
| 146 |
Fail 3: idtac. |
| 147 |
Abort. |
| 148 |
|
| 149 |
(********************) |
| 150 |
|
| 151 |
Elpi Tactic call. |
| 152 |
Elpi Accumulate lp:{{ |
| 153 |
solve (goal C A TY B [tac T] as G) GL :- |
| 154 |
std.assert-ok! (d\coq.ltac.call-ltac1 T (goal C A TY B []) GL d) "err". |
| 155 |
|
| 156 |
}}. |
| 157 |
Tactic Notation "callx" tactic(ta) := |
| 158 |
elpi call ltac_tactic:(ta). |
| 159 |
|
| 160 |
Goal True. |
| 161 |
callx (exact I). |
| 162 |
Qed. |