| 1 |
(* coq-prog-args: ("-top" "ArgumentsScope") *) |
| 2 |
(* A few tests to check Global Argument Scope command *) |
| 3 |
|
| 4 |
Section A. |
| 5 |
Variable a : bool -> bool. |
| 6 |
Definition negb' := negb. |
| 7 |
Section B. |
| 8 |
Variable b : bool -> bool. |
| 9 |
Definition negb'' := negb. |
| 10 |
About a. |
| 11 |
About b. |
| 12 |
About negb''. |
| 13 |
About negb'. |
| 14 |
About negb. |
| 15 |
Global Arguments negb'' _ : clear scopes. |
| 16 |
Global Arguments negb' _ : clear scopes. |
| 17 |
Global Arguments negb _ : clear scopes. |
| 18 |
Global Arguments a _ : clear scopes. |
| 19 |
Global Arguments b _ : clear scopes. |
| 20 |
About a. |
| 21 |
About b. |
| 22 |
About negb. |
| 23 |
About negb'. |
| 24 |
About negb''. |
| 25 |
End B. |
| 26 |
About a. |
| 27 |
End A. |
| 28 |
About negb. |
| 29 |
About negb'. |
| 30 |
About negb''. |
| 31 |
|
| 32 |
(* Check multiple scopes *) |
| 33 |
|
| 34 |
Declare Scope A_scope. |
| 35 |
Delimit Scope A_scope with A. |
| 36 |
Declare Scope B_scope. |
| 37 |
Delimit Scope B_scope with B. |
| 38 |
Notation "'tt'" := true : A_scope. |
| 39 |
Notation "'tt'" := false : B_scope. |
| 40 |
|
| 41 |
Definition f (x : bool) := x. |
| 42 |
|
| 43 |
Arguments f x%_A%_B. |
| 44 |
About f. |
| 45 |
|
| 46 |
Check f tt. |
| 47 |
Set Printing All. |
| 48 |
Check f tt. |
| 49 |
Unset Printing All. |
| 50 |
|
| 51 |
Arguments f x%_B%_A. |
| 52 |
About f. |
| 53 |
|
| 54 |
Check f tt. |
| 55 |
Set Printing All. |
| 56 |
Check f tt. |
| 57 |
Unset Printing All. |
| 58 |
|
| 59 |
(* Check binding scope inside/outside *) |
| 60 |
|
| 61 |
Bind Scope A_scope with bool. |
| 62 |
#[add_bottom] Bind Scope B_scope with bool. |
| 63 |
|
| 64 |
Definition g (x : bool) := x. |
| 65 |
|
| 66 |
About g. |
| 67 |
|
| 68 |
Bind Scope A_scope with nat. |
| 69 |
#[add_top] Bind Scope B_scope with nat. |
| 70 |
|
| 71 |
Definition g' (x : nat) := x. |
| 72 |
|
| 73 |
About g'. |
| 74 |
|
| 75 |
Bind Scope A_scope with unit. |
| 76 |
Bind Scope B_scope with unit. (* default: reset *) |
| 77 |
|
| 78 |
Definition g'' (x : unit) := x. |
| 79 |
|
| 80 |
About g''. |
| 81 |
|
| 82 |
Module SectionTest1. |
| 83 |
|
| 84 |
Inductive A :=. |
| 85 |
Inductive B :=. |
| 86 |
Declare Scope X. |
| 87 |
Section S. |
| 88 |
Declare Scope Y. |
| 89 |
Bind Scope X with A. |
| 90 |
Bind Scope Y with B. |
| 91 |
Definition f : A -> B -> A := fun x _ => x. |
| 92 |
About f. |
| 93 |
End S. |
| 94 |
(* In section, Bind Scope do not survive the section nor have a persistent effect: |
| 95 |
outside the section, f does not know any more about X and Y, even thoug X exists outside the section *) |
| 96 |
About f. |
| 97 |
|
| 98 |
End SectionTest1. |
| 99 |
|
| 100 |
Module SectionTest2. |
| 101 |
|
| 102 |
Inductive A :=. |
| 103 |
Module M. |
| 104 |
Declare Scope X. |
| 105 |
Bind Scope X with A. |
| 106 |
End M. |
| 107 |
Module N. |
| 108 |
Import M. |
| 109 |
Section S. |
| 110 |
Axiom f : A -> A. |
| 111 |
End S. |
| 112 |
End N. |
| 113 |
(* In modules, Bind Scope has a persistent effect even if not imported: |
| 114 |
f knows about X even if M not imported *) |
| 115 |
About N.f. |
| 116 |
Axiom g : A -> A. |
| 117 |
(* Without the Import, Bind Scope has however no effect on declarations not |
| 118 |
already aware of this binding *) |
| 119 |
About g. |
| 120 |
|
| 121 |
End SectionTest2. |