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

Join declaration unstable under renaming #465

Open
Tragicus opened this issue Nov 28, 2024 · 5 comments
Open

Join declaration unstable under renaming #465

Tragicus opened this issue Nov 28, 2024 · 5 comments

Comments

@Tragicus
Copy link

Tragicus commented Nov 28, 2024

The joins HB declares depend on the name of the structures, which breaks things when we want to rename structures. Here is a MWE, where the first Check uses the join of A and B, and the second one uses the coercion from S0 to B.

From HB Require Import structures.

HB.mixin Record isA (T : Type) := {}.
HB.mixin Record isB (T : Type) := {}.
HB.mixin Record isC (T : Type) := {}.

HB.structure Definition A := {T of isA T}.
HB.structure Definition B := {T of isB T}.
HB.structure Definition C := {T of isC T}.

HB.structure Definition S := {T of A T & B T}.
HB.structure Definition S0 := {T of C T & B T}.

Set Printing All.
Check fun (T : S.type) => (T : A.type) : B.type.
Check fun (T : S0.type) => (T : C.type) : B.type.
@Tragicus Tragicus changed the title HB join declaration unstable under renaming Join declaration unstable under renaming Nov 28, 2024
@CohenCyril
Copy link
Member

CohenCyril commented Nov 28, 2024

I'm not sure what breaks and shouldn't. Could you provide a MWE with a failure at definition time or during proofs? (using e.g. Fail ... to highlight it)

@Tragicus
Copy link
Author

In the following code, the first rewrite rewrites the first occurrence of fb _ while the second one rewrites the second one.

From HB Require Import structures.
From mathcomp Require Import ssreflect.

HB.mixin Record isA (T : Type) := {fa : T -> T}.
HB.mixin Record isB (T : Type) := {xb : T; fb : T -> T}.
HB.mixin Record isC (T : Type) := {fc : T -> T}.

HB.structure Definition A := {T of isA T}.
HB.structure Definition B := {T of isB T}.
HB.structure Definition C := {T of isC T}.

HB.structure Definition S := {T of A T & B T}.
HB.structure Definition S0 := {T of C T & B T}.

Axiom fbS0E : forall (T : S0.type) (x : T), fb x = xb.

Goal forall (T : S0.type) (x : T), fb (fc x) = fb x.
Proof. move=> T x; rewrite fbS0E.
Abort.

Axiom fbSE : forall (T : S.type) (x : T), fb x = xb.

Goal forall (T : S.type) (x : T), fb (fa x) = fb x.
Proof. move=> T x; rewrite fbSE.

@CohenCyril
Copy link
Member

CohenCyril commented Dec 10, 2024

I think this is not a HB problem, and rather this Rocq problem

@Tragicus
Copy link
Author

I believe this non-local name-dependent behavior of HB is an issue, even if the example also illustrates an issue with Rocq.

@pi8027
Copy link
Member

pi8027 commented Dec 10, 2024

Declaring join instances in both directions should also solve (or at least mitigate) the issue: math-comp/math-comp#1256 (comment) math-comp/math-comp#1125 (comment)

@CohenCyril CohenCyril added medium priority Priority: intermediate high priority High priority low priority Low priority medium difficulty and removed medium priority Priority: intermediate high priority High priority labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants