(* Test that we fail, rather than raising anomalies, on opaque terms during interpretation *)
DeclareScope opaque_scope.
(* https://github.com/coq/coq/pull/8064#discussion_r202497516 *) Module Test1. Axiom hold : forall {A B C}, A -> B -> C. Definition opaque3 (x : Number.int) : Number.int := hold x (fix f (x : nat) : nat := match x with O => O | S n => S (f n) end).
Number Notation Number.int opaque3 opaque3 : opaque_scope. DelimitScope opaque_scope withopaque.
Fail Check 1%opaque. End Test1.
Module Test3. Inductive silly := SILLY (v : Number.uint) (f : forall A, A -> A). Definition to_silly (v : Number.uint) := SILLY v (fun _ x => x). Definition of_silly (v : silly) := match v with SILLY v _ => v end.
Number Notation silly to_silly of_silly : silly_scope. DelimitScope silly_scope with silly.
Fail Check 1%silly. End Test3.
Module Test4. DeclareScope opaque_scope. DeclareScope silly_scope. DeclareScope pto. DeclareScope ppo. DeclareScope ptp. DeclareScope ppp. DeclareScope uto. DeclareScope upo. DeclareScope utp. DeclareScope upp. DeclareScope ppps.
Polymorphic NonCumulative Inductive punit := ptt.
Polymorphic Definition pto_punit (v : Number.uint) : option punit := match Nat.of_num_uint v with O => Some ptt | _ => None end.
Polymorphic Definition pto_punit_all (v : Number.uint) : punit := ptt.
Polymorphic Definition pof_punit (v : punit) : Number.uint := Nat.to_num_uint 0. Definition to_punit (v : Number.uint) : option punit := match Nat.of_num_uint v with O => Some ptt | _ => None end. Definition of_punit (v : punit) : Number.uint := Nat.to_num_uint 0.
Polymorphic Definition pto_unit (v : Number.uint) : option unit := match Nat.of_num_uint v with O => Some tt | _ => None end.
Polymorphic Definition pof_unit (v : unit) : Number.uint := Nat.to_num_uint 0. Definition to_unit (v : Number.uint) : option unit := match Nat.of_num_uint v with O => Some tt | _ => None end. Definition of_unit (v : unit) : Number.uint := Nat.to_num_uint 0.
Number Notation punit to_punit of_punit : pto.
Number Notation punit pto_punit of_punit : ppo.
Number Notation punit to_punit pof_punit : ptp.
Number Notation punit pto_punit pof_punit : ppp.
Number Notation unit to_unit of_unit : uto. DelimitScope pto with pto. DelimitScope ppo with ppo. DelimitScope ptp with ptp. DelimitScope ppp with ppp. DelimitScope uto with uto. Checklet v := 0%pto in v : punit. Checklet v := 0%ppo in v : punit. Checklet v := 0%ptp in v : punit. Checklet v := 0%ppp in v : punit. Checklet v := 0%uto in v : unit.
Fail Check 1%uto.
Fail Check (-1)%uto.
Number Notation unit pto_unit of_unit : upo.
Number Notation unit to_unit pof_unit : utp.
Number Notation unit pto_unit pof_unit : upp. DelimitScope upo with upo. DelimitScope utp with utp. DelimitScope upp with upp. Checklet v := 0%upo in v : unit. Checklet v := 0%utp in v : unit. Checklet v := 0%upp in v : unit.
Polymorphic Definition pto_punits := pto_punit_all@{Set}.
Polymorphic Definition pof_punits := pof_punit@{Set}.
Number Notation punit pto_punits pof_punits (abstract after 0) : ppps. DelimitScope ppps with ppps.
Universe u.
Constraint Set < u. Checklet v := 0%ppps in v : punit@{u}. (* Check that universes are refreshed *)
Fail Checklet v := 1%ppps in v : punit@{u}. (* Note that universes are not refreshed here *) End Test4.
Module Test5. Check S. (* At one point gave Error: Anomaly "Uncaught exception Pretype_errors.PretypeError(_, _, _)." Please report at http://coq.inria.fr/bugs/. *) End Test5.
Module Test6. (* Check that number notations on enormous terms don't take forever to print/parse *) (* Ackerman definition from https://stackoverflow.com/a/10303475/377022 *) Fixpoint ack (n m : nat) : nat := match n with
| O => S m
| S p => letfix ackn (m : nat) := match m with
| O => ack p 1
| S q => ack p (ackn q) end
in ackn m end.
Timeout 1 Check (S (ack 4 4)). (* should be instantaneous *)
LocalSet Primitive Projections.
Record > wnat := wrap { unwrap :> nat }. Definition to_uint (x : wnat) : Number.uint := Nat.to_num_uint x. Definition of_uint (x : Number.uint) : wnat := Nat.of_num_uint x. ModuleExport Scopes. DeclareScope wnat_scope. DelimitScope wnat_scope with wnat. End Scopes. ModuleExport Notations. Export Scopes.
Number Notation wnat of_uint to_uint (abstract after 4999) : wnat_scope. End Notations. Set Printing Coercions. Checklet v := 0%wnat in v : wnat. Check wrap O.
Timeout 1 Check wrap (ack 4 4). (* should be instantaneous *) End Test6.
Module Test6_2. Import Test6.Scopes. Check Test6.wrap 0. Import Test6.Notations. Checklet v := 0%wnat in v : Test6.wnat. End Test6_2.
Module Test7. LocalSet Primitive Projections.
Record wuint := wrap { unwrap : Number.uint }. DeclareScope wuint_scope. DelimitScope wuint_scope with wuint.
Number Notation wuint wrap unwrap : wuint_scope. Checklet v := 0%wuint in v : wuint. Checklet v := 1%wuint in v : wuint. End Test7.
Module Test8. LocalSet Primitive Projections.
Record wuint := wrap { unwrap : Number.uint }. DeclareScope wuint8_scope. DeclareScope wuint8'_scope. DelimitScope wuint8_scope with wuint8. DelimitScope wuint8'_scopewith wuint8'. Section with_var.
Context (dummy : unit). Definition wrap' := let __ := dummy in wrap. Definition unwrap' := let __ := dummy in unwrap.
Number Notation wuint wrap' unwrap' : wuint8_scope. Checklet v := 0%wuint8 in v : wuint. End with_var. Checklet v := 0%wuint8 in v : nat.
Fail Checklet v := 0%wuint8 in v : wuint. Compute wrap (Nat.to_num_uint 0).
Notation wrap'' := wrap. Notation unwrap'' := unwrap.
Number Notation wuint wrap'' unwrap'' : wuint8'_scope. Checklet v := 0%wuint8' in v : wuint. End Test8.
Module Test9. DeclareScope wuint9_scope. DeclareScope wuint9'_scope. DelimitScope wuint9_scope with wuint9. DelimitScope wuint9'_scopewith wuint9'. Section with_let. LocalSet Primitive Projections.
Record wuint := wrap { unwrap : Number.uint }. Let wrap' := wrap. Let unwrap' := unwrap. LocalNotation wrap'' := wrap. LocalNotation unwrap'' := unwrap.
Number Notation wuint wrap' unwrap' : wuint9_scope. Checklet v := 0%wuint9 in v : wuint.
Number Notation wuint wrap'' unwrap'' : wuint9'_scope. Checklet v := 0%wuint9' in v : wuint. End with_let. Checklet v := 0%wuint9 in v : nat.
Fail Checklet v := 0%wuint9 in v : wuint. End Test9.
Module Test10. (* Test that it is only a warning to add abstract after to an optional parsing function *) Definition to_uint (v : unit) := Nat.to_num_uint 0. Definition of_uint (v : Number.uint) := match Nat.of_num_uint v with O => Some tt | _ => None end. Definition of_any_uint (v : Number.uint) := tt. DeclareScope unit_scope. DeclareScope unit2_scope. DelimitScope unit_scope with unit. DelimitScope unit2_scope with unit2.
Number Notation unit of_uint to_uint (abstract after 0) : unit_scope. LocalSet Warnings "+abstract-large-number-no-op". (* Check that there is actually a warning here *)
Fail Number Notation unit of_uint to_uint (abstract after 0) : unit2_scope. (* Check that there is no warning here *)
Number Notation unit of_any_uint to_uint (abstract after 0) : unit2_scope. End Test10.
Module Test12. (* Test for number notations on context variables *) DeclareScope test12_scope. DelimitScope test12_scope with test12. Section test12.
Context (to_uint : unit -> Number.uint) (of_uint : Number.uint -> unit).
Number Notation unit of_uint to_uint : test12_scope. Checklet v := 1%test12 in v : unit. End test12. End Test12.
Module Test13. (* Test for number notations on notations which do not denote references *) DeclareScope test13_scope. DeclareScope test13'_scope. DeclareScope test13''_scope. DelimitScope test13_scope with test13. DelimitScope test13'_scopewith test13'. DelimitScope test13''_scopewith test13''. Definition to_uint (x y : unit) : Number.uint := Nat.to_num_uint O. Definition of_uint (x : Number.uint) : unit := tt. Definition to_uint_good := to_uint tt. Notation to_uint' := (to_uint tt). Notation to_uint'' := (to_uint _).
Number Notation unit of_uint to_uint_good : test13_scope. Checklet v := 0%test13 in v : unit.
Fail Number Notation unit of_uint to_uint' : test13'_scope.
Fail Checklet v := 0%test13' in v : unit.
Fail Number Notation unit of_uint to_uint'' : test13''_scope.
Fail Checklet v := 0%test13'' in v : unit. End Test13.
Module Test14. (* Test that number notations follow [Import], not [Require], and also test that [Local Number Notation]s do not escape modules
nor sections. *) DeclareScope test14_scope. DeclareScope test14'_scope. DeclareScope test14''_scope. DeclareScope test14'''_scope. DelimitScope test14_scope with test14. DelimitScope test14'_scopewith test14'. DelimitScope test14''_scopewith test14''. DelimitScope test14'''_scopewith test14'''. Module Inner. Definition to_uint (x : unit) : Number.uint := Nat.to_num_uint O. Definition of_uint (x : Number.uint) : unit := tt. Local Number Notation unit of_uint to_uint : test14_scope. Global Number Notation unit of_uint to_uint : test14'_scope. Checklet v := 0%test14 in v : unit. Checklet v := 0%test14' in v : unit. End Inner.
Fail Checklet v := 0%test14 in v : unit.
Fail Checklet v := 0%test14' in v : unit. Import Inner.
Fail Checklet v := 0%test14 in v : unit. Checklet v := 0%test14' in v : unit. Section InnerSection. Definition to_uint (x : unit) : Number.uint := Nat.to_num_uint O. Definition of_uint (x : Number.uint) : unit := tt. Local Number Notation unit of_uint to_uint : test14''_scope.
Fail Global Number Notation unit of_uint to_uint : test14'''_scope. Checklet v := 0%test14'' in v : unit.
Fail Checklet v := 0%test14''' in v : unit. End InnerSection.
Fail Checklet v := 0%test14'' in v : unit.
Fail Checklet v := 0%test14''' in v : unit. End Test14.
Module Test15. (** Test module include *) DeclareScope test15_scope. DelimitScope test15_scope with test15. Module Inner. Definition to_uint (x : unit) : Number.uint := Nat.to_num_uint O. Definition of_uint (x : Number.uint) : unit := tt.
Number Notation unit of_uint to_uint : test15_scope. Checklet v := 0%test15 in v : unit. End Inner. Module Inner2.
Include Inner. Checklet v := 0%test15 in v : unit. End Inner2. Import Inner Inner2. Checklet v := 0%test15 in v : unit. End Test15.
Module Test16. (** Test functors *) DeclareScope test16_scope. DelimitScope test16_scope with test16. ModuleType A. Axiom T : Set. Axiom t : T. End A. Module F (a : A). Inductive Foo := foo (_ : a.T). Definition to_uint (x : Foo) : Number.uint := Nat.to_num_uint O. Definition of_uint (x : Number.uint) : Foo := foo a.t. Global Number Notation Foo of_uint to_uint : test16_scope. Checklet v := 0%test16 in v : Foo. End F. Module a <: A. Definition T : Set := unit. Definition t : T := tt. End a. ModuleImport f := F a. (** Ideally this should work, but it should definitely not anomaly *)
Fail Checklet v := 0%test16 in v : Foo. End Test16.
RequireImport PrimInt63. Module Test17. (** Test uint63 *) DeclareScope test17_scope. DeclareScope test17_scope. DelimitScope test17_scope with test17. LocalSet Primitive Projections.
Record myint63 := of_int { to_int : int }. Definition parse x := match x with Pos x => Some (of_int x) | Neg _ => None end. Definitionprint x := Pos (to_int x).
Number Notation myint63 parse print : test17_scope. Checklet v := 0%test17 in v : myint63. End Test17.
Module Test18. (** Test https://github.com/coq/coq/issues/9840 *)
Record Q := { num : nat ; den : nat ; reduced : Nat.gcd num den = 1 }. DeclareScope Q_scope. DelimitScope Q_scope with Q.
Checklet v := 0%Q in v : Q. Checklet v := 1%Q in v : Q. Checklet v := 2%Q in v : Q. Checklet v := 3%Q in v : Q. Checklet v := 4%Q in v : Q. Computelet v := 0%Q in (num v, den v). Computelet v := 1%Q in (num v, den v). Computelet v := 2%Q in (num v, den v). Computelet v := 3%Q in (num v, den v). Computelet v := 4%Q in (num v, den v). End Test18.
RequireImport Corelib.Lists.ListDef. RequireImport BinNums IntDef. Module Test19. (** Test another thing related to https://github.com/coq/coq/issues/9840 *)
Record Zlike := { summands : list Z }. DeclareScope Zlike_scope. DelimitScope Zlike_scope with Zlike.
Section Fold_Right_Recursor. Variables (A : Type) (B : Type). Variable f : B -> A -> A. Variable a0 : A.
Fixpoint fold_right (l:list B) : A := match l with
| nil => a0
| cons b t => f b (fold_right t) end. End Fold_Right_Recursor.
Number Notation Zlike Zlike_of_Z Z_of_Zlike : Zlike_scope.
Checklet v := (-1)%Zlike in v : Zlike. Checklet v := 0%Zlike in v : Zlike. Checklet v := 1%Zlike in v : Zlike. Checklet v := 2%Zlike in v : Zlike. Checklet v := 3%Zlike in v : Zlike. Checklet v := 4%Zlike in v : Zlike. Check {| summands := cons (Zpos xH) (cons (Zpos (xO xH)) (cons (Zneg xH) nil)) |}. Check {| summands := nil |}. End Test19.
Module Test20. (** Test Sorts *) LocalSet Universe Polymorphism. Inductive known_type : Type -> Type :=
| prop : known_type Prop
| set : known_type Set
| type : known_type Type
| zero : known_type Empty_set
| one : known_type unit
| two : known_type bool.
Existing Class known_type.
#[global]
Existing Instances zero one two prop.
#[global]
Existing Instanceset | 2.
#[global]
Existing Instancetype | 4.
Record > ty := { t : Type ; kt : known_type t }.
Definition ty_of_uint (x : Number.uint) : option ty
:= match Nat.of_num_uint x with
| 0 => @Some ty zero
| 1 => @Some ty one
| 2 => @Some ty two
| 3 => @Some ty prop
| 4 => @Some ty set
| 5 => @Some ty type
| _ => None end. Definition uint_of_ty (x : ty) : Number.uint
:= Nat.to_num_uint match kt x with
| prop => 3
| set => 4
| type => 5
| zero => 0
| one => 1
| two => 2 end.
DeclareScope kt_scope. DelimitScope kt_scope with kt.
Number Notation ty ty_of_uint uint_of_ty : kt_scope.
Checklet v := 0%kt in v : ty. Checklet v := 1%kt in v : ty. Checklet v := 2%kt in v : ty. Checklet v := 3%kt in v : ty. Checklet v := 4%kt in v : ty. Checklet v := 5%kt in v : ty.
Fail Checklet v := 6%kt in v : ty. Eval cbv in (_ : known_type Empty_set) : ty. Eval cbv in (_ : known_type unit) : ty. Eval cbv in (_ : known_type bool) : ty. Eval cbv in (_ : known_type Prop) : ty. Eval cbv in (_ : known_type Set) : ty. Eval cbv in (_ : known_type Type) : ty. LocalSet Printing All. Checklet v := 0%kt in v : ty. Checklet v := 1%kt in v : ty. Checklet v := 2%kt in v : ty. Checklet v := 3%kt in v : ty. Checklet v := 4%kt in v : ty. Checklet v := 5%kt in v : ty. End Test20.
(* To do: preserve parsing of -0: Require Import ZArith. Check (-0)%Z.
*)
End Test22.
(* Test the via ... mapping ... option *) Module Test23.
Inductive sum (A : Set) (B : Set) : Set := pair : A -> B -> sum A B.
Inductive I :=
| Iempty : I
| Iunit : I
| Isum : I -> I -> I.
Definition of_uint (x : Number.uint) : I := letfix f n := match n with
| O => Iempty
| S O => Iunit
| S n => Isum Iunit (f n) end in
f (Nat.of_num_uint x).
Definition to_uint (x : I) : Number.uint := letfix f i := match i with
| Iempty => O
| Iunit => 1
| Isum i1 i2 => f i1 + f i2 end in
Nat.to_num_uint (f x).
Notation nSet := (Set) (only parsing). (* needed as a reference is expected in Number Notation and Set is syntactically not a reference *)
Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum])
: type_scope.
LocalOpenScope type_scope.
Check Empty_set. Check unit. Check sum unit unit. Check sum unit (sum unit unit). Set Printing All. Check 0. Check 1. Check 2. Check 3. Unset Printing All.
(* Test error messages *)
(* missing constructor *)
Fail Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit])
: type_scope.
(* duplicate constructor *)
Fail Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum, unit => Iunit])
: type_scope.
(* not an inductive *)
Fail Number Notation nSet of_uint to_uint (via add
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum])
: type_scope.
(* not a constructor *)
Fail Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => add, sum => Isum])
: type_scope.
(* put constructors of the wrong inductive ~~> missing constructors *)
Fail Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => O, unit => S])
: type_scope.
(* wrong type mapping *)
Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, O => Iunit, sum => Isum])
: type_scope.
(* incompatibility with abstract (but warning is fine) *)
Fail Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum],
abstract after 11)
: type_scope.
Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum],
warning after 12)
: type_scope.
(* Test reduction of types when building the notation *)
Inductive foo := bar : match (true <: bool) with true => nat -> foo | false => True end.
Definition foo_of_uint (x : Number.uint) : foo := bar (Nat.of_num_uint x). Definition foo_to_uint (x : foo) : Number.uint := match x with
| bar x => Nat.to_num_uint x end.
Check cons tt (cons tt nil). Check cons O (cons O nil). (* printer not called on list nat *)
(* inductive with multiple parameters that are not the first
parameters and not in the same order for each constructor *) Inductive Ip : Type -> Type -> Type :=
| Ip0 : forall T T', nat -> Ip T T'
| Ip1 : forall T' T, nat -> Ip T T'
| Ip2 : forall T, nat -> forall T', Ip T T'
| Ip3 : nat -> forall T T', Ip T T'.
Definition Ip_of_uint (u : Number.uint) : option (Ip nat bool) := let f n := match n with
| O => Some (Ip0 nat bool O)
| S O => Some (Ip1 bool nat (S O))
| S (S O) => Some (Ip2 nat (S (S O)) bool)
| S (S (S O)) => Some (Ip3 (S (S (S O))) nat bool)
| _ => None end in
f (Nat.of_num_uint u).
Definition Ip_to_uint (l : Ip nat bool) : Number.uint := let f n := match n with
| Ip0 _ _ n => n
| Ip1 _ _ n => n
| Ip2 _ n _ => n
| Ip3 n _ _ => n end in
Nat.to_num_uint (f l).
Check 0. Check 1. Check 2. Check 3. Check Ip0 nat bool (S O). Check Ip1 bool nat (S O). Check Ip2 nat (S O) bool. Check Ip3 (S O) nat bool. Check Ip0 nat nat (S O). (* not printed *) Check Ip0 bool bool (S O). (* not printed *) Check Ip1 nat nat (S O). (* not printed *) Check Ip3 (S O) nat nat. (* not printed *) Set Printing All. Check 0. Check 1. Check 2. Check 3. Unset Printing All.
Notation eqO := (eq _ O) (only parsing). Definition eqO_of_uint (x : Number.uint) : eqO := eq_refl O. Definition eqO_to_uint (x : O = O) : Number.uint := match x with
| eq_refl _ => Nat.to_num_uint O end.
Number Notation eqO eqO_of_uint eqO_to_uint : nat_scope.
Check 42. Check eq_refl (S O). (* doesn't match eq _ O, printer not called *) Check eq_refl O. (* matches eq _ O, printer called *) Check eq_refl (id O). (* doesn't match eq _ O, printer not called *)
Check eq_refl (S O). (* matches eq _ _, printer called, but type incorrect *) Check eq_refl O. (* matches eq _ _, printer called *) Check eq_refl (id O). (* matches eq _ _, but contains a global constant, printer not called *)
Inductive extra_list : Type -> Type :=
| nil (n : nat) (v : Type) : extra_list v
| cons (n : nat) (t : Type) (x : t) : extra_list t -> extra_list t.
Definition extra_list_unit_of_uint (x : Number.uint) : extra_list unit := letfix f n := match n with
| O => nil O unit
| S n => cons O unit tt (f n) end in
f (Nat.of_num_uint x).
Definition extra_list_unit_to_uint (x : extra_list unit) : Number.uint := letfix f T (x : extra_list T) := match x with
| nil _ _ => O
| cons _ T _ x => S (f T x) end in
Nat.to_num_uint (f unit x).
Check 2. Set Printing All. Check 2. Unset Printing All.
End Test25.
(* Test the via ... mapping ... option with let-binders, beta-redexes, delta-redexes, etc *) Module Test26.
Inductive sum (A : Set) (B : Set) : Set := pair : A -> B -> sum A B.
Inductive I (dummy:=O) :=
| Iempty : let v := I in id v
| Iunit : (fun x => x) I
| Isum : let v := I in (fun A B => A -> B) (let v' := v in v') (forall x : match O with O => I | _ => Empty_set end, let dummy2 := x in I).
Definition of_uint (x : (fun x => let v := I in x) Number.uint) : (fun x => let v := I in x) I := letfix f n := match n with
| O => Iempty
| S O => Iunit
| S n => Isum Iunit (f n) end in
f (Nat.of_num_uint x).
Definition to_uint (x : (fun x => let v := x in v) I) : match O with O => Number.uint | _ => Empty_set end := letfix f i := match i with
| Iempty => O
| Iunit => 1
| Isum i1 i2 => f i1 + f i2 end in
Nat.to_num_uint (f x).
Notation nSet := (Set) (only parsing). (* needed as a reference is expected in Number Notation and Set is syntactically not a reference *)
Number Notation nSet of_uint to_uint (via I
mapping [Empty_set => Iempty, unit => Iunit, sum => Isum])
: type_scope.
LocalOpenScope type_scope.
Check Empty_set. Check unit. Check sum unit unit. Check sum unit (sum unit unit). Set Printing All. Check 0. Check 1. Check 2. Check 3. Unset Printing All. End Test26.
(* Test the via ... mapping ... option with implicit arguments with let binders, etc *) Module Test27.
Module Fin. Inductive t0 (x:=O) := with
t (x:=O) : forall y : nat, let z := y in Set :=
| F1 (y:=O) {n} : match y with O => t (S n) | _ => Empty_set end
| FS (y:=x) {n} (v:=n+y) (m:=n) : id (match y with O => id (t n) | _ => Empty_set end -> (fun x => x) t (S m)) with t' (x:=O) := . End Fin.
Inductive I (dummy:=O) :=
| I1 : I
| IS : let x := I in id x -> I.
Definition of_uint (x : Number.uint) : I := letfix f n := match n with
| O => I1
| S n => IS (f n) end in
f (Nat.of_num_uint x).
Definition to_uint (x : I) : Number.uint := letfix f i := match i with
| I1 => O
| IS n => S (f n) end in
Nat.to_num_uint (f x).
LocalOpenScope type_scope.
Number Notation Fin.t of_uint to_uint (via I
mapping [[Fin.F1] => I1, [Fin.FS] => IS])
: type_scope.
Check 2. Check NUnit (S (S O)). Check NUnit (S (S (S O))). Check NUnit O.
Check NUnit (S O + S O). (* doesn't print as 2, because (S O + S O) is not syntactically equal to (S (S O)), we could want to use a convertibility test rather
than a syntactic equality, but this could be more costly *)
End Test30.
Module Bug10878.
Definition Zto_pos_opt (v : Z) : option positive
:= match v with
| Zpos v => Some v
| _ => None end. DeclareScope mypos_scope. DeclareScope mypos_scope2.
Number Notation positive Zto_pos_opt Zpos : mypos_scope. (* success *) Arguments option {_}.
Number Notation positive Zto_pos_opt Zpos : mypos_scope2. (* was failing *)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.