| 1 |
(** This file tests how locality attributes affect usual vernacular commands. |
| 2 |
PLEASE, when this file fails to compute following a voluntary change in |
| 3 |
Coq's behaviour, modify accordingly the tables in [sections.rst] and |
| 4 |
[modules.rst] in [doc/sphinx/language/core] |
| 5 |
|
| 6 |
Also look at the corresponding discussions about locality attributes in the |
| 7 |
refman (directory doc/sphinx) |
| 8 |
- For Definition, Lemma, ..., look at language/core/definitions.rst |
| 9 |
- For Axiom, Conjecture, ..., look at language/core/assumptions.rst |
| 10 |
- For abbreviations, look at user-extensions/syntax-extensions.rst |
| 11 |
- For Notations, look at user-extensions/syntax-extensions.rst |
| 12 |
- For Tactic Notations, look at user-extensions/syntax-extensions.rst |
| 13 |
- For Ltac, look at proof-engine/ltac.rst |
| 14 |
- For Canonical Structures, look at language/extensions/canonical.rst |
| 15 |
- For Hints, look at proofs/automatic-tactics/auto.rst |
| 16 |
- For Coercions, look at addendum/implicit-coercions.rst |
| 17 |
- For Ltac2, look at proof-engine/ltac2.rst |
| 18 |
- For Ltac2 Notations, look at proof-engine/ltac2.rst |
| 19 |
- For Set, look at language/core/basic.rst |
| 20 |
*) |
| 21 |
|
| 22 |
From Ltac2 Require Import Ltac2. |
| 23 |
|
| 24 |
(** ** Tests for modules and visibility attributes with Ltac2 *) |
| 25 |
|
| 26 |
(* A parameter: *) |
| 27 |
Parameter (secret : nat). |
| 28 |
(* An axiom: *) |
| 29 |
Axiom secret_is_42 : secret = 42. |
| 30 |
|
| 31 |
(** *** Without attribute (default) *) |
| 32 |
|
| 33 |
Module InModuleDefault. |
| 34 |
|
| 35 |
Module Bar. |
| 36 |
(* A custom tactic: *) |
| 37 |
Ltac2 find_secret () := rewrite secret_is_42. |
| 38 |
Ltac2 Notation "rfl" := reflexivity. |
| 39 |
End Bar. |
| 40 |
|
| 41 |
(** **** Without importing: *) |
| 42 |
|
| 43 |
(* Availability of the tactic *) |
| 44 |
Fail Print find_secret. |
| 45 |
Print Bar.find_secret. |
| 46 |
(* Availability of the tactic notation *) |
| 47 |
Lemma plop_ni : 2 + 2 = 4. |
| 48 |
Proof. Fail rfl. Admitted. |
| 49 |
|
| 50 |
(** **** After importing: *) |
| 51 |
|
| 52 |
Import Bar. |
| 53 |
(* Availability of the tactic *) |
| 54 |
Print find_secret. |
| 55 |
Print Bar.find_secret. |
| 56 |
(* Availability of the tactic notation *) |
| 57 |
Lemma plop_i : 2 + 2 = 4. |
| 58 |
Proof. rfl. Qed. |
| 59 |
|
| 60 |
End InModuleDefault. |
| 61 |
|
| 62 |
Module InModuleLocal. |
| 63 |
Module Bar. |
| 64 |
#[local] |
| 65 |
Ltac2 find_secret () := rewrite secret_is_42. |
| 66 |
#[local] |
| 67 |
Ltac2 Notation "rfl" := reflexivity. |
| 68 |
End Bar. |
| 69 |
|
| 70 |
(** **** Without importing: *) |
| 71 |
|
| 72 |
(* Availability of the tactic *) |
| 73 |
Fail Print find_secret. |
| 74 |
Fail Print Bar.find_secret. |
| 75 |
(* Availability of the tactic notation *) |
| 76 |
Lemma plop_ni : 2 + 2 = 4. |
| 77 |
Proof. Fail rfl. Admitted. |
| 78 |
|
| 79 |
(** **** After importing: *) |
| 80 |
|
| 81 |
Import Bar. |
| 82 |
(* Availability of the tactic *) |
| 83 |
Fail Print find_secret. |
| 84 |
Fail Print Bar.find_secret. |
| 85 |
(* Availability of the tactic notation *) |
| 86 |
Lemma plop_i : 2 + 2 = 4. |
| 87 |
Proof. Fail rfl. Admitted. |
| 88 |
|
| 89 |
End InModuleLocal. |
| 90 |
|
| 91 |
Module InModuleExport. |
| 92 |
Module Bar. |
| 93 |
(* A custom tactic: *) |
| 94 |
Fail #[export] |
| 95 |
Ltac2 find_secret := reflexivity. |
| 96 |
(* A tactic notation: *) |
| 97 |
Fail #[export] |
| 98 |
Ltac2 Notation "rfl" := reflexivity. |
| 99 |
End Bar. |
| 100 |
|
| 101 |
(** Nothing to check, Ltac2 and Ltac2 Notation do not support the [export] |
| 102 |
attribute. *) |
| 103 |
|
| 104 |
End InModuleExport. |
| 105 |
|
| 106 |
Module InModuleGlobal. |
| 107 |
Module Bar. |
| 108 |
#[global] |
| 109 |
Ltac2 find_secret () := rewrite secret_is_42. |
| 110 |
(* A tactic notation: *) |
| 111 |
#[global] |
| 112 |
Ltac2 Notation "rfl" := reflexivity. |
| 113 |
End Bar. |
| 114 |
|
| 115 |
(** **** Without importing: *) |
| 116 |
|
| 117 |
(* Availability of the tactic *) |
| 118 |
Fail Print find_secret. |
| 119 |
Print Bar.find_secret. |
| 120 |
(* Availability of the tactic notation *) |
| 121 |
Lemma plop_ni : 2 + 2 = 4. |
| 122 |
Proof. Fail rfl. Admitted. |
| 123 |
|
| 124 |
(** **** After importing: *) |
| 125 |
|
| 126 |
Import Bar. |
| 127 |
Print find_secret. |
| 128 |
Print Bar.find_secret. |
| 129 |
(* Availability of the tactic notation *) |
| 130 |
Lemma plop_i : 2 + 2 = 4. |
| 131 |
Proof. rfl. Qed. |
| 132 |
End InModuleGlobal. |