| 1 |
(* Until recently, the Notation.declare_numeral_notation wasn't synchronized |
| 2 |
w.r.t. backtracking. This should be ok now. |
| 3 |
This test is pretty artificial (we must declare Z_scope for this to work). |
| 4 |
*) |
| 5 |
|
| 6 |
Delimit Scope Z_scope with Z. |
| 7 |
Open Scope Z_scope. |
| 8 |
Check let v := 0 in v : nat. |
| 9 |
(* let v := 0 in v : nat : nat *) |
| 10 |
Require BinInt. |
| 11 |
Check let v := 0 in v : BinNums.Z. |
| 12 |
(* let v := 0 in v : BinNums.Z : BinNums.Z *) |
| 13 |
Back 2. |
| 14 |
Check let v := 0 in v : nat. |
| 15 |
(* Expected answer: let v := 0 in v : nat : nat *) |
| 16 |
(* Used to fail with: |
| 17 |
Error: Cannot interpret in Z_scope without requiring first module BinNums. |
| 18 |
*) |
| 19 |
|
| 20 |
Local Set Universe Polymorphism. |
| 21 |
Delimit Scope punit_scope with punit. |
| 22 |
Delimit Scope pcunit_scope with pcunit. |
| 23 |
Delimit Scope int_scope with int. |
| 24 |
Number Notation Decimal.int Decimal.int_of_int Decimal.int_of_int : int_scope. |
| 25 |
Module A. |
| 26 |
NonCumulative Inductive punit@{u} : Type@{u} := ptt. |
| 27 |
Cumulative Inductive pcunit@{u} : Type@{u} := pctt. |
| 28 |
Definition to_punit : Decimal.int -> option punit |
| 29 |
:= fun v => match v with 0%int => Some ptt | _ => None end. |
| 30 |
Definition to_pcunit : Decimal.int -> option pcunit |
| 31 |
:= fun v => match v with 0%int => Some pctt | _ => None end. |
| 32 |
Definition of_punit : punit -> Decimal.uint := fun _ => Nat.to_uint 0. |
| 33 |
Definition of_pcunit : pcunit -> Decimal.uint := fun _ => Nat.to_uint 0. |
| 34 |
Number Notation punit to_punit of_punit : punit_scope. |
| 35 |
Check let v := 0%punit in v : punit. |
| 36 |
Back 2. |
| 37 |
Number Notation pcunit to_pcunit of_pcunit : punit_scope. |
| 38 |
Check let v := 0%punit in v : pcunit. |
| 39 |
End A. |
| 40 |
Reset A. |
| 41 |
Local Unset Universe Polymorphism. |
| 42 |
Module A. |
| 43 |
Inductive punit : Set := ptt. |
| 44 |
Definition to_punit : Decimal.int -> option punit |
| 45 |
:= fun v => match v with 0%int => Some ptt | _ => None end. |
| 46 |
Definition of_punit : punit -> Decimal.uint := fun _ => Nat.to_uint 0. |
| 47 |
Number Notation punit to_punit of_punit : punit_scope. |
| 48 |
Check let v := 0%punit in v : punit. |
| 49 |
End A. |
| 50 |
Local Set Universe Polymorphism. |
| 51 |
Inductive punit@{u} : Type@{u} := ptt. |
| 52 |
Definition to_punit : Decimal.int -> option punit |
| 53 |
:= fun v => match v with 0%int => Some ptt | _ => None end. |
| 54 |
Definition of_punit : punit -> Decimal.uint := fun _ => Nat.to_uint 0. |
| 55 |
Number Notation punit to_punit of_punit : punit_scope. |
| 56 |
Check let v := 0%punit in v : punit. |
| 57 |
Back 6. (* check backtracking of registering universe polymorphic constants *) |
| 58 |
Local Unset Universe Polymorphism. |
| 59 |
Inductive punit : Set := ptt. |
| 60 |
Definition to_punit : Decimal.int -> option punit |
| 61 |
:= fun v => match v with 0%int => Some ptt | _ => None end. |
| 62 |
Definition of_punit : punit -> Decimal.uint := fun _ => Nat.to_uint 0. |
| 63 |
Number Notation punit to_punit of_punit : punit_scope. |
| 64 |
Check let v := 0%punit in v : punit. |