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

TC search considers Opaque constants transparent & Hint Opaque solution requires annoying workaround #12566

Open
Janno opened this issue Jun 22, 2020 · 3 comments
Labels
kind: bug An error, flaw, fault or unintended behaviour. part: typeclasses The typeclass mechanism.

Comments

@Janno
Copy link
Contributor

Janno commented Jun 22, 2020

Description of the problem

In the example below one can see that a constant marked Opaque is considered transparent for TC search and that one cannot simply mark it Hint Opaque without first making it Transparent (and then making it Opaque again afterwards). I suppose both of these are bugs but the latter wouldn't be a big issue if the TC search considered Opaque constants Hint Opaque by default.

Class Inh (A : Prop) := inh : A.

Definition True' : Prop := True.
Opaque True'.

Instance Inh_True' : Inh True' | 1 := id I.
Instance Inh_True : Inh True | 100 := I.

Set Typeclasses Debug.
Set Typeclasses Debug Verbosity 2.

Goal True.
  apply inh.                (* wrongly picks [Inh_True'] *)
Qed.

Existing Instance Inh_True | 0.

Goal True'.
  apply inh.                    (* wrongly picks [Inh_True] *)
Qed.

Existing Instance Inh_True | 100. (* Restore initial instance priorities *)

(* Cannote declare [True'] opaque for TC search because it is already opaque :( *)
Fail Hint Opaque True' : typeclass_instances.

(* But we can change that. *)
Transparent True'.
Hint Opaque True' : typeclass_instances.
Opaque True'.

Goal True.
  apply inh.                (* correctly picks [Inh_True] *)
Qed.

Existing Instance Inh_True | 0.

Goal True'.
  apply inh.                    (* correctly picks [Inh_True'] *)
Qed.

Let me know if I should pull these apart into two issues.

Coq Version

8.11, master

@Janno Janno changed the title TC search considers Opaque constants transparent & Hint Opaque solution needs annoying workaround TC search considers Opaque constants transparent & Hint Opaque solution requires annoying workaround Jun 22, 2020
@Janno
Copy link
Contributor Author

Janno commented Jun 23, 2020

@ppedrot any chance this is as easy to fix as the one about axioms?

@ppedrot
Copy link
Member

ppedrot commented Jun 23, 2020

This has strong interactions with the stuff I've been working on recently, so expect progress on this soon.

@SkySkimmer
Copy link
Contributor

#12573 may help

SkySkimmer added a commit to SkySkimmer/coq that referenced this issue Jun 29, 2020
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue Jul 1, 2020
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue Jul 7, 2020
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue Jul 23, 2020
Mbodin pushed a commit to Mbodin/coq that referenced this issue Aug 6, 2020
fajb pushed a commit to fajb/coq that referenced this issue Aug 24, 2020
liyishuai pushed a commit to liyishuai/coq that referenced this issue Aug 29, 2020
@Alizter Alizter added part: typeclasses The typeclass mechanism. kind: bug An error, flaw, fault or unintended behaviour. labels Sep 29, 2021
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: typeclasses The typeclass mechanism.
Projects
None yet
Development

No branches or pull requests

4 participants