| 1 |
From elpi.apps Require Import derive.std. |
| 2 |
|
| 3 |
Module example1. |
| 4 |
derive Inductive peano := Zero | Succ (p : peano). |
| 5 |
|
| 6 |
Print peano. |
| 7 |
(* Inductive peano : Set := Zero : peano | Succ : peano -> peano *) |
| 8 |
|
| 9 |
Eval compute in peano_eqb Zero (Succ Zero). |
| 10 |
(* = false : bool *) |
| 11 |
|
| 12 |
Check peano_eqb_OK. |
| 13 |
(* peano_eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 14 |
End example1. |
| 15 |
|
| 16 |
Module example2. |
| 17 |
#[module] |
| 18 |
derive Inductive peano := Zero | Succ (p : peano). |
| 19 |
|
| 20 |
Print peano. |
| 21 |
(* Notation peano := peano.peano *) |
| 22 |
|
| 23 |
Print peano.peano. |
| 24 |
(* Inductive peano : Set := Zero : peano | Succ : peano -> peano *) |
| 25 |
|
| 26 |
Eval compute in peano.eqb Zero (Succ Zero). |
| 27 |
(* = false : bool *) |
| 28 |
|
| 29 |
Check peano.eqb_OK. |
| 30 |
(* peano.eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 31 |
End example2. |
| 32 |
|
| 33 |
Module example3. |
| 34 |
#[module="Peano"] |
| 35 |
derive Inductive peano := Zero | Succ (p : peano). |
| 36 |
|
| 37 |
Print peano. |
| 38 |
(* Notation peano := Peano.peano *) |
| 39 |
|
| 40 |
Print Peano.peano. |
| 41 |
(* Inductive peano : Set := Zero : peano | Succ : peano -> peano *) |
| 42 |
|
| 43 |
Eval compute in Peano.eqb Zero (Succ Zero). |
| 44 |
(* = false : bool *) |
| 45 |
|
| 46 |
Check Peano.eqb_OK. |
| 47 |
(* Peano.eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 48 |
End example3. |
| 49 |
|
| 50 |
Module example4. |
| 51 |
#[module="Peano",prefix="Peano_"] |
| 52 |
derive Inductive peano := Zero | Succ (p : peano). |
| 53 |
|
| 54 |
Print peano. |
| 55 |
(* Notation Peano := Peano.peano *) |
| 56 |
|
| 57 |
Print Peano.peano. |
| 58 |
(* Inductive peano : Set := Zero : peano | Succ : peano -> peano *) |
| 59 |
|
| 60 |
Print Module Peano. |
| 61 |
|
| 62 |
Eval compute in Peano.Peano_eqb Zero (Succ Zero). |
| 63 |
(* = false : bool *) |
| 64 |
|
| 65 |
Check Peano.Peano_eqb_OK. |
| 66 |
(* Peano.Peano_eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 67 |
End example4. |
| 68 |
|
| 69 |
Module example5. |
| 70 |
#[prefix=""] |
| 71 |
derive Inductive peano := Zero | Succ (p : peano). |
| 72 |
|
| 73 |
Print peano. |
| 74 |
(* Inductive peano : Set := Zero : peano | Succ : peano -> peano *) |
| 75 |
|
| 76 |
Eval compute in eqb Zero (Succ Zero). |
| 77 |
(* = false : bool *) |
| 78 |
|
| 79 |
Check eqb_OK. |
| 80 |
(* eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 81 |
End example5. |
| 82 |
|
| 83 |
Module example6. |
| 84 |
#[module=Peano,no_alias] |
| 85 |
derive Inductive peano := Zero | Succ (p : peano). |
| 86 |
|
| 87 |
Fail Print peano. |
| 88 |
|
| 89 |
Print Peano.peano. |
| 90 |
(* Inductive peano : Set := Peano.Zero : peano | Peano.Succ : peano -> peano *) |
| 91 |
|
| 92 |
Eval compute in Peano.eqb Peano.Zero (Peano.Succ Peano.Zero). |
| 93 |
(* = false : bool *) |
| 94 |
|
| 95 |
Check Peano.eqb_OK. |
| 96 |
(* Peano.eqb_OK : forall x1 x2 : peano, reflect (x1 = x2) (eqb x1 x2) *) |
| 97 |
End example6. |
| 98 |
|
| 99 |
Fail #[no_alias] |
| 100 |
derive Inductive peano := Zero | Succ (p : peano). |