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

what's the problem? #75

Closed
wants to merge 1 commit into from
Closed

what's the problem? #75

wants to merge 1 commit into from

Conversation

HuStmpHrrr
Copy link
Member

What exactly is going wrong here?

@HuStmpHrrr HuStmpHrrr requested a review from Ailrun May 10, 2024 01:14
Print Instances PER.
Typeclasses eauto := debug.
Set Typeclasses Debug.
typeclasses eauto.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type class resolution fails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eauto with typeclass_instances succeeds. anyway to fix this? typeclass resolution doesn't look at the context at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check the trace with typeclasses eauto || idtac. For this specific case, the following is the trace:

Debug: 1: looking for (PER R) without backtracking
Debug: 1.1: simple eapply @per_elem_PER on (PER R), 1 subgoal(s)
Debug: 1.1-1 : (per_univ_elem ?i ?A ?B R)
Debug: 1.1-1: looking for (per_univ_elem ?i ?A ?B R) with backtracking
Debug: 1.1-1: no match for (per_univ_elem ?i ?A ?B R), 0 possibilities
Debug: 1.2: simple apply @Equivalence_PER on (PER R), 1 subgoal(s)
Debug: 1.2-1 : (Equivalence R)
Debug: 1.2-1: looking for (Equivalence R) without backtracking
Debug: 1.2-1: no match for (Equivalence R), 0 possibilities

In other words, it fails to find per_univ_elem ?i ?A ?B R), unlike eauto. So indeed, it seems like it ignores the local context.

Copy link
Member

@Ailrun Ailrun May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the documentation says like this...

When considering local hypotheses, we use the transparent state of the first hint database given. Using an empty database (created with Create HintDb for example) with unfoldable variables and constants as the first argument of typeclasses eauto hence makes resolution with the local hypotheses use full conversion during unification.

which is confusing. It seems like it considers local hypothesis, but then why does it fails to find per_univ_elem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I don't get it. It might just look for classes in the local contexts.

Copy link
Member Author

@HuStmpHrrr HuStmpHrrr May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add

#[global]
  Hint Extern 1 => eassumption : typeclass_instances.

What do you think?

Copy link
Member

@Ailrun Ailrun May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds OK, we don't need to use typeclasses eauto in the proofs very often anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also very tempting to swap the order of per_univ_elem. How many times do we have to use PER properties later?

@HuStmpHrrr HuStmpHrrr closed this May 14, 2024
@HuStmpHrrr HuStmpHrrr deleted the typeclass_problem branch May 16, 2024 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants