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

unexpected unfolding of a notation #12788

Open
Casteran opened this issue Aug 3, 2020 · 6 comments
Open

unexpected unfolding of a notation #12788

Casteran opened this issue Aug 3, 2020 · 6 comments
Labels

Comments

@Casteran
Copy link

Casteran commented Aug 3, 2020

Description of the problem

Hello,

In the following script, the tactic "split" replaces the notation "omega" with its expansion (inr 0).
This not a serious bug, since the actual script still compiles, but it makes the sub-goals less readable.

Definition t : Type := (nat + nat)%type.
Declare Scope oo_scope.

Notation "'omega'" := (inr 0:t) : oo_scope.
Parameter P : t -> Prop.
Open Scope oo_scope.

Lemma P_iff (alpha:t) : P alpha <-> alpha = omega.
Proof.
split.

Coq Version

V8.12.0 (MacOS)

@Zimmi48 Zimmi48 added part: notations The notation system. part: tactics labels Aug 3, 2020
@Casteran
Copy link
Author

Casteran commented Aug 3, 2020

In fact, it looks to be a problem with "constructor" or, more generally "apply", which unfolds the type t and replaces it with (nat + nat)%type. So, the notation "omega", which expects a term of type t, becomes useless. Perhaps, it's a lack of knowledge about "apply": which constants are unfolded, even if unnecessary ?

@Casteran Casteran closed this as completed Aug 3, 2020
@Zimmi48
Copy link
Member

Zimmi48 commented Aug 3, 2020

I don't know if you should close this though. For one, it's not just about t getting unfolded, because if you manually unfold t everywhere (and remove the definition), this still behaves the same.

@Casteran
Copy link
Author

Casteran commented Aug 3, 2020 via email

@Zimmi48
Copy link
Member

Zimmi48 commented Aug 3, 2020

No need!

@Zimmi48 Zimmi48 reopened this Aug 3, 2020
@herbelin
Copy link
Member

Hi @Casteran, I suggest you don't use a cast (i.e. : t) in the notation, as tactics only weakly preserve casts. The following works and has (almost) the same effect (assuming this is compatible with what you are doing with t).

Definition t : Type := (nat + nat)%type.
Declare Scope oo_scope.

Notation "'omega'" := (@inr nat nat 0) : oo_scope.
Parameter P : t -> Prop.
Open Scope oo_scope.

Lemma P_iff (alpha:t) : P alpha <-> alpha = omega.
Proof.
split.

Another solution is to have both:

Notation "'omega'" := (inr 0:t) : oo_scope.
Notation "'omega'" := (@inr nat nat 0) (only printing) : oo_scope.

[On the other side, letting tactics preserve cast would probably induce some incompatibilities (though it might be tried).]

@Casteran
Copy link
Author

Casteran commented Aug 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants