| 1 |
From Corelib Require Import ssreflect. |
| 2 |
From elpi.apps Require Import locker. |
| 3 |
|
| 4 |
(* ----------------------- *) |
| 5 |
|
| 6 |
lock Definition d1 := 3. |
| 7 |
|
| 8 |
Lemma test_1_0 : d1 = 3. |
| 9 |
Proof. rewrite unlock. match goal with |- 3 = 3 => by [] end. Qed. |
| 10 |
Lemma test_1_1 : d1 = 3. |
| 11 |
Proof. unfold d1. match goal with |- locked_with d1_key_subproof 3 = 3 => by rewrite unlock end. Qed. |
| 12 |
|
| 13 |
(* ----------------------- *) |
| 14 |
|
| 15 |
Fail lock Axiom d2 : nat. |
| 16 |
|
| 17 |
(* ----------------------- *) |
| 18 |
|
| 19 |
Section S1. |
| 20 |
Variable T : Type. |
| 21 |
#[key="foo"] lock Definition d2 (x : T) := x. |
| 22 |
End S1. |
| 23 |
|
| 24 |
Lemma test_2_0 : d2 nat 3 = 3. |
| 25 |
Proof. unfold d2. match goal with |- locked_with foo (fun x => x) 3 = 3 => by rewrite unlock end. Qed. |
| 26 |
|
| 27 |
|
| 28 |
(* ----------------------- *) |
| 29 |
|
| 30 |
mlock Definition d3 := 3. |
| 31 |
|
| 32 |
Print Module d3. |
| 33 |
Print Module Type d3_Locked. |
| 34 |
Lemma test_3_0 : d3 = 3. |
| 35 |
Proof. rewrite unlock. match goal with |- 3 = 3 => by [] end. Qed. |
| 36 |
Lemma test_3_1 : d3 = 3. |
| 37 |
Proof. Fail unfold d3. rewrite d3.unlock. by []. Qed. |
| 38 |
|
| 39 |
(* ----------------------- *) |
| 40 |
|
| 41 |
Section S2. |
| 42 |
Fail mlock Definition d4 := 3. |
| 43 |
End S2. |
| 44 |
|
| 45 |
(* #286 ----------------------- *) |
| 46 |
|
| 47 |
Module Bug_286. |
| 48 |
Module Import lock_container. |
| 49 |
Unset Implicit Arguments. |
| 50 |
lock Definition cons2 {A} x xs := @cons A x xs. |
| 51 |
End lock_container. |
| 52 |
About cons2. |
| 53 |
Definition foo := cons2 0 nil. |
| 54 |
Class EqDecision (A : Type) := { f : A -> A -> bool }. |
| 55 |
#[local] Instance xx : EqDecision nat := {| f := (fun _ _ => true) |}. |
| 56 |
Module Import lock_container2. |
| 57 |
lock Definition cons3 [A] `{EqDecision A} x xs := @cons A x xs. |
| 58 |
End lock_container2. |
| 59 |
Definition foo3 := cons3 0 nil. |
| 60 |
About cons3. |
| 61 |
End Bug_286. |
| 62 |
|
| 63 |
Module test_286_global_implicits. |
| 64 |
Unset Implicit Arguments. |
| 65 |
Module mlock_container. |
| 66 |
mlock Definition def {A} (a : A) := a. |
| 67 |
End mlock_container. |
| 68 |
|
| 69 |
Fail Definition user1 {A} (a : A) := mlock_container.def _ a. |
| 70 |
Definition user1 {A} (a : A) := mlock_container.def a. |
| 71 |
|
| 72 |
Import mlock_container. |
| 73 |
Fail Definition user2 {A} (a : A) := def _ a. |
| 74 |
Definition user2 {A} (a : A) := def a. |
| 75 |
End test_286_global_implicits. |
| 76 |
|
| 77 |
(* https://coq.zulipchat.com/#narrow/stream/253928-Elpi-users-.26-devs/topic/Reifying.20terms.20with.20ltac.20.2F.20if-then-else.20.2F.20complex.20match *) |
| 78 |
|
| 79 |
Module elab. |
| 80 |
mlock Definition y (z : nat) := ltac:(exact z). |
| 81 |
mlock Definition q (b : bool) := if b then 1 else 0. |
| 82 |
End elab. |
| 83 |
|
| 84 |
(* ----------------------- *) |
| 85 |
|
| 86 |
Elpi Command test. (* for queries *) |
| 87 |
|
| 88 |
Set Printing Universes. |
| 89 |
|
| 90 |
lock #[universes(polymorphic)] Definition id1@{u} (T : Type@{u}) (x : T) := x. |
| 91 |
About id1. |
| 92 |
Elpi Query lp:{{ coq.locate "id1" GR, coq.env.univpoly? GR 1 }}. |
| 93 |
|
| 94 |
|
| 95 |
mlock #[universes(polymorphic)] Definition id2@{u} (T : Type@{u}) (x : T) := x. |
| 96 |
About id2.body. |
| 97 |
Elpi Query lp:{{ coq.locate "id2" GR, coq.env.univpoly? GR 1 }}. |
| 98 |
|
| 99 |
Set Universe Polymorphism. |
| 100 |
|
| 101 |
mlock Definition up1 (T : Type) (x : T) := x. |
| 102 |
About up1.body. |
| 103 |
Elpi Query lp:{{ coq.locate "up1" GR, coq.env.univpoly? GR 1 }}. |
| 104 |
|
| 105 |
mlock #[universes(polymorphic=no)] Definition nup1 (T : Type) (x : T) := x. |
| 106 |
About nup1.body. |
| 107 |
Elpi Query lp:{{ coq.locate "nup1" GR, not(coq.env.univpoly? GR _) }}. |
| 108 |
|
| 109 |
mlock Definition up2@{u +} (T : Type@{u}) (W : Type) (x : T) := x. |
| 110 |
About up2.body. |
| 111 |
Elpi Query lp:{{ coq.locate "up2" GR, coq.env.univpoly? GR 2 }}. |
| 112 |
|
| 113 |
Fail mlock Definition up3@{u} (T : Type@{u}) (W : Type) (x : T) := x. |
| 114 |
|
| 115 |
(* #704 ----------------------- *) |
| 116 |
|
| 117 |
Set Universe Polymorphism. |
| 118 |
mlock Definition Bla (T : bool) : Type := nat. |