| 1 |
From elpi Require Import elpi. |
| 2 |
|
| 3 |
Elpi Command section. |
| 4 |
|
| 5 |
(* section *) |
| 6 |
|
| 7 |
Section SA. |
| 8 |
Unset Auto Template Polymorphism. |
| 9 |
Variable a : nat. |
| 10 |
Inductive ind := K. |
| 11 |
Section SB. |
| 12 |
Variable b : nat. |
| 13 |
Let c := b. |
| 14 |
Elpi Query lp:{{ |
| 15 |
coq.env.section-variables [CA, CB, CC], |
| 16 |
coq.locate "a" (const CA), |
| 17 |
coq.locate "b" (const CB), |
| 18 |
coq.locate "c" (const CC), |
| 19 |
coq.env.const CC (some (global (const CB))) _, |
| 20 |
coq.env.add-section-variable "d" _ {{ nat }} _, |
| 21 |
coq.env.add-section-variable "d1" _ {{ nat }} _, |
| 22 |
@local! => coq.env.add-const "e" {{ 3 }} {{ nat }} _ _. |
| 23 |
}}. |
| 24 |
About d. |
| 25 |
Definition e2 := e. |
| 26 |
End SB. |
| 27 |
Fail Check d. |
| 28 |
Fail Check d1. |
| 29 |
Check eq_refl : e2 = 3. |
| 30 |
End SA. |
| 31 |
|
| 32 |
Elpi Query lp:{{ |
| 33 |
std.do! [ coq.env.begin-section "Foo", coq.env.end-section ] |
| 34 |
}} lp:{{ |
| 35 |
coq.env.begin-section "Foo", |
| 36 |
coq.env.add-section-variable "x" _ {{ nat }} X, |
| 37 |
coq.env.section-variables [X], |
| 38 |
coq.env.add-const "fx" (global (const X)) _ _ _, |
| 39 |
coq.env.end-section. |
| 40 |
}}. |
| 41 |
|
| 42 |
Check fx : nat -> nat. |
| 43 |
|
| 44 |
Elpi Query lp:{{ |
| 45 |
coq.env.add-const "opaque_3" {{ 3 }} _ @opaque! _ |
| 46 |
}}. |
| 47 |
|
| 48 |
About opaque_3. |
| 49 |
|
| 50 |
Fail Elpi Query lp:{{ |
| 51 |
coq.env.add-const "opaque_illtyped" {{ 3 3 }} _ @opaque! _ |
| 52 |
}}. |
| 53 |
Fail Elpi Query lp:{{ |
| 54 |
coq.env.add-const "opaque_illtyped" {{ S True }} _ @opaque! _ |
| 55 |
}}. |
| 56 |
|
| 57 |
(************* using ********************) |
| 58 |
Section Using. |
| 59 |
Variable A : bool. |
| 60 |
Elpi Query lp:{{ coq.env.add-const "foo" {{ 3 }} {{ nat }} @transparent! _ }}. |
| 61 |
Elpi Query lp:{{ @using! "All" => coq.env.add-const "bar" {{ 3 }} {{ nat }} @transparent! _ }}. |
| 62 |
End Using. |
| 63 |
Check foo : nat. |
| 64 |
Check bar : bool -> nat. |
| 65 |
|
| 66 |
(* section inspection *) |
| 67 |
|
| 68 |
Section Foo. |
| 69 |
|
| 70 |
Variable x : nat. |
| 71 |
Definition a := x + 1. |
| 72 |
|
| 73 |
Section Bar. |
| 74 |
|
| 75 |
Definition b := a. |
| 76 |
Inductive C := . |
| 77 |
|
| 78 |
Elpi Query lp:{{ |
| 79 |
coq.env.section-contents L, |
| 80 |
std.assert! (L = [ |
| 81 |
|
| 82 |
[ {{:gref C_sind }}, {{:gref C_rec }}, {{:gref C_ind }}, {{:gref C_rect }}, {{:gref C }}, {{:gref b }}, ], |
| 83 |
|
| 84 |
[ {{:gref a }}] |
| 85 |
|
| 86 |
]) "bad section listing". |
| 87 |
}}. |
| 88 |
|
| 89 |
End Bar. |
| 90 |
End Foo. |