Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number Notation typechecking shouldn't enable elaboration #15843

Closed
proux01 opened this issue Mar 22, 2022 · 5 comments · Fixed by #15884
Closed

Number Notation typechecking shouldn't enable elaboration #15843

proux01 opened this issue Mar 22, 2022 · 5 comments · Fixed by #15884
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: notations The notation system.
Milestone

Comments

@proux01
Copy link
Contributor

proux01 commented Mar 22, 2022

Coercion nat_of_option (u : option nat) : nat :=
  match u with Some u => u | None => 0 end.

Number Notation nat Nat.of_num_int Nat.to_num_int : nat_scope.

Check 3.  (* "Some 3 : option nat" instead of "3 : nat" *)

The issue is that Number Notation accept Nat.of_num_int as a complete function (of type _ -> nat) instead of a partial one (of type _ -> option nat) because its typechecking enable to elaborate the parsing function Nat.of_num_int to fun u => nat_of_option (Nat.of_num_int u) which is a complete parsing function, but still uses the unelaborated Nat.of_num_int as parsing function.

I think that Number Notation typechecking should just forbid elaboration (otherwise it elaborates new parsing/printing functions that are completely hidden to the user).

@proux01 proux01 added part: notations The notation system. kind: bug An error, flaw, fault or unintended behaviour. labels Mar 22, 2022
@gares
Copy link
Member

gares commented Mar 22, 2022

One option to fix this is wait for #15845 , then add an option to disable coercions to and finally use it in number notations.

Another option is to rewrite the code of number notation to not work with constr_expr, but rather constr, and hence short-circuit the elaborator (which does not seem to be needed, really).

@SkySkimmer
Copy link
Contributor

Another option is to rewrite the code of number notation to not work with constr_expr, but rather constr

Why not globref? Not sure why constr would work better tbh.

@proux01
Copy link
Contributor Author

proux01 commented Mar 22, 2022

Note that there are examples in the test-suite with holes, so not sure how constr would work here:

Notation eqO := (eq _ O) (only parsing).

@SkySkimmer
Copy link
Contributor

That's only on the type argument, not the functions though.

@gares
Copy link
Member

gares commented Mar 22, 2022

Why not globref? Not sure why constr would work better tbh.

The code does type check the two functions against T1 -> T2 or T1 -> option T2, so you need a data type which supports typing.

proux01 added a commit to proux01/coq that referenced this issue Mar 31, 2022
proux01 added a commit to proux01/coq that referenced this issue Mar 31, 2022
proux01 added a commit to proux01/coq that referenced this issue Apr 1, 2022
proux01 added a commit to proux01/coq that referenced this issue Apr 15, 2022
@coqbot-app coqbot-app bot added this to the 8.16+rc1 milestone Apr 15, 2022
ana-borges pushed a commit to ana-borges/coq that referenced this issue Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: notations The notation system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants