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

Coq uses wrong notations using custom entries #18223

Closed
amblafont opened this issue Oct 30, 2023 · 2 comments · Fixed by #18230
Closed

Coq uses wrong notations using custom entries #18223

amblafont opened this issue Oct 30, 2023 · 2 comments · Fixed by #18230
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: custom The custom notation system. part: notations The notation system.
Milestone

Comments

@amblafont
Copy link
Contributor

amblafont commented Oct 30, 2023

Description of the problem

Coq displays a goal using a notation defined in another custom entry (see the end of the code below).

Declare Custom Entry foo.
Declare Custom Entry bar.

Section example.

Context (A : Type).
Context (Q : A -> A -> A).
Context (P : A -> A).


Notation "< x >" := (P x) (x custom foo).
(* Should not be allowed in a foo expression *)
Notation "| x |" := (x) (x custom bar).

Notation "{ x }" := (x) (in custom foo, x constr).

(* If moving the above notation |-| here, the issue disappears
*)


Notation "x y" := (Q x y)  (in custom bar at level 1, right associativity).
Notation "x" := x (in custom bar at level 0, x global).

Check (fun a b => < {Q b a} >).
(*  returns fun (a : A) (b : B) => < | {b a} | > 
The | - | notation should not be used! And indeed it is not accepted as input, as seen below.
*)
Fail Check (fun a b =>  < | {b a} | >).
End example.

Coq Version

8.18.0

@herbelin
Copy link
Member

Looks strange indeed. Maybe a bug in the computation of the transitive closure of "coercions" between entries. In any cases, thanks for reporting.

@herbelin herbelin added part: notations The notation system. kind: bug An error, flaw, fault or unintended behaviour. part: custom The custom notation system. labels Oct 30, 2023
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 30, 2023
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 30, 2023
@herbelin
Copy link
Member

The order of chaining of entry coercions (such as | x | or { x }) was indeed wrong when combining them by transitivity on one side. It was correct when applying transitivity on the other side and this is why the problem was only when | x | came before { x }.

Fixed in #18230 where it now prints fun a b => < {| b a |} > in both cases.

Thanks again!

coqbot-app bot added a commit that referenced this issue Nov 3, 2023
…d in the wrong order depending on the order in which coercions were declared

Reviewed-by: proux01
Co-authored-by: proux01 <proux01@users.noreply.github.com>
@coqbot-app coqbot-app bot added this to the 8.19+rc1 milestone Nov 3, 2023
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: custom The custom notation system. part: notations The notation system.
Projects
None yet
2 participants