Debian Codegraph @

tests/test_API_proof.v.in

raw
1 From elpi Require Import elpi.
2
3 Elpi Command lemma.
4 Elpi Accumulate lp:{{
5 main-interp-proof [str S, str ":", trm T] _ P GL S :-
6 coq.typecheck P T ok,
7 coq.ltac.collect-goals P GL _.
8 }}.
9
10 #[proof="begin"]
11 Elpi Export lemma.
12
13 Elpi Command lemma_ctx.
14 Elpi Accumulate lp:{{
15 main-interp-proof [const-decl S none (parameter ID _ TY p\arity (A p))] _ (fun N TY P) GL S :-
16 std.map {coq.env.section-variables} (x\coq.gref->id (const x)) LID,
17 std.assert! (not(std.mem LID ID)) "name collision",
18 coq.id->name ID N,
19 @pi-parameter ID TY p\
20 coq.typecheck (P p) (A p) ok,
21 coq.ltac.collect-goals (P p) GL _.
22 main-interp-proof [const-decl S (some (fun _ _ P)) (parameter ID _ TY p\arity (A p))] _ (fun N TY P) GL S :-
23 std.map {coq.env.section-variables} (x\coq.gref->id (const x)) LID,
24 std.assert! (not(std.mem LID ID)) "name collision",
25 coq.id->name ID N,
26 @pi-parameter ID TY p\
27 coq.typecheck (P p) (A p) ok,
28 coq.ltac.collect-goals (P p) GL _.
29
30 }}.
31
32 #[proof="begin"]
33 Elpi Export lemma_ctx.
34
35
36 Elpi Command qed.
37 Elpi Accumulate lp:{{
38 main-interp-qed _ _ _ [seal (goal _ IT _ _ _)] S :-
39 if (var S) (S = "xx") true,
40 if (not(ground_term IT)) (coq.error "not finished") true,
41 coq.env.add-const S IT _ _ _.
42 main-interp-qed _ _ P [] S :-
43 coq.env.add-const S P _ _ _.
44 }}.
45
46
47 #[proof="end"]
48 Elpi Export qed.
49
50 Elpi Command qed_ctx.
51 Elpi Accumulate lp:{{
52 main-interp-qed _ _ P _ S :-
53 if (var S) (S = "xx") true,
54 coq.env.add-const S P _ _ _.
55 }}.
56
57
58 #[proof="end"]
59 Elpi Export qed_ctx.
60
61
62
63 Fail qed.
64
65 lemma it : (True).
66 Proof.
67 exact I.
68 qed.
69
70 Succeed Print it.
71
72 lemma it2 : (True).
73 Proof.
74 Fail qed.
75 Abort.
76
77 lemma it2 : (True /\ _).
78 Succeed Show. (* yes! *)
79 split.
80 exact I.
81 exact I.
82 qed.
83
84 Succeed Print it2.
85
86 lemma_ctx Lemma it3 x : x + 0 = x.
87 auto.
88 qed_ctx.
89
90 Succeed Print it3.
91
92 Axiom plus_comm : forall x y : nat, x + y = y + x.
93
94 lemma_ctx Lemma it4 x : x + 0 = x := @eq_trans _ _ (0+x) _ _ _.
95 - now rewrite plus_comm.
96 - now rewrite plus_n_O.
97 qed_ctx.
98
99 Succeed Print it4.
100
101 lemma_ctx Lemma it5 (x : nat) : x = x := eq_refl _.
102 qed_ctx.
103
104 Succeed Print it5.
105
106 Section A.
107 Variable x : nat.
108 Fail lemma_ctx Lemma it6 (x : nat) : x = x := eq_refl _.
109 End A.
110
111
112 Lemma foo : True.
113 trivial.
114 qed.
115
116 Succeed Print foo.
117
118 lemma foo2 : (True).
119 trivial.
120 Fail Qed. Abort.
121
122 Elpi Command lemma_if.
123 Elpi Accumulate lp:{{
124 main-interp-proof [str S, str ":", trm T] _ P GL S :- /* 9.1 */
125 coq.typecheck P T ok,
126 coq.ltac.collect-goals P GL _.
127 main _.
128 }}.
129
130 #[skip="9.0"] #[proof(begin_if="interactive")]
131 #[skip="9.0"] Elpi Export lemma_if.
132 #[skip="9.0"] #[interactive]
133 #[skip="9.0"] lemma_if it3 : (True).
134 #[skip="9.0"] Succeed Show.
135 #[skip="9.0"] Abort.
136 #[skip="9.0"] lemma_if it4 : (True).
137 #[skip="9.0"] Fail Show.