coq / coq

Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
https://coq.inria.fr/
GNU Lesser General Public License v2.1
4.86k stars 650 forks source link

Comparing printing of notations and numeral notations #13066

Open proux01 opened 4 years ago

proux01 commented 4 years ago

Attempting to merge printing of notations and numeral notations (following a discussion in https://github.com/coq/coq/pull/12163 ), I compared them. Here is a small example illustrating differences.

Notations:

Declare Scope A.
Declare Scope B.
Delimit Scope A with A.
Delimit Scope B with B.
Notation "0" := tt : A.
Notation "1" := tt : B.
Definition f x : unit := x.
Arguments f x%A.
Check f tt.  (* prints f 1%B *)
Open Scope A.
Check tt.  (* prints 1%B *)
Open Scope B.
Notation "1" := true.
Check tt.  (* prints 1 *)

Numeral Notations:

Declare Scope A.
Declare Scope B.
Delimit Scope A with A.
Delimit Scope B with B.
Definition to_unit (v : Numeral.uint) : option unit := Some tt.
Definition of_unit (v : unit) : Numeral.uint := Nat.to_num_uint 0.
Definition of_unit' (v : unit) : Numeral.uint := Nat.to_num_uint 1.
Number Notation unit to_unit of_unit : A.
Number Notation unit to_unit of_unit' : B.
Definition f x : unit := x.
Arguments f x%A.
Check f tt.  (* prints f 0 *)
Open Scope A.
Check tt.  (* prints 0 *)
Open Scope B.
Notation "1" := true.
Check tt.  (* prints 1%B *)

To sum up:

Are these differences expected ? If not, which behavior should be favored ?

Coq Version

master

proux01 commented 4 years ago

@herbelin you may have an opinion here.

herbelin commented 4 years ago

I feel the numeral notation choice more intuitive (see also #8187).