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
Minimize the set of multiple inheritance (coercion) paths to check for conversion #13909
Conversation
BTW, I still do not understand the following things in coercionops.ml:
|
I'm OK with that. BTW, if you are going to refactor the code, in spite of #13902 being merged, I still don't have an API that given a GlobRef.t tells me the number of parameters and the src/tgt classes. Would you mind making it possible? (adding the missing fields to coe_info_typ should suffice)
If I'm not mistake these are not "loops" but rather a form of "identity coercions": indexing looking just at the head constant is too simplistic. |
Sure. I will do that first and then redo this PR on top of it.
I don't think so. In the following condition, Line 341 in 4a0cf0f
|
fa3716a
to
f990327
Compare
I think you can nor rebase on top of the refactoring PR which was merged |
f990327
to
97c4592
Compare
The table of coercion classes (`class_tab`) has been extended with information about reachability. The conversion checking of a pair of multiple inheritance paths (of coercions) will be skipped if these paths can be reduced to smaller adjoining pairs of multiple inheritance paths, and this reduction will be determined based on that reachability information.
97c4592
to
2727087
Compare
I don't think I have to update the reference manual in accordance with this change. So this PR is ready for review. |
@pi8027 can you take of the request by @SkySkimmer ? Otherwise this seems ready to me. |
Yes. I will do that by the end of this week. |
@coqbot merge now |
@gares: You can't merge the PR because you're not among the assignees and no milestone is set. |
@coqbot merge now |
The coercion mechanism reports a pair of inheritance paths sharing the same source and target classes (hereinafter a diamond) as ambiguous paths if they are inconvertible, to let the user ensure the coherence of the inheritance graph. In general, we do not necessarily have to check all the diamonds in an inheritance graph to verify its coherence. For example, it is sufficient to check two (small) diamonds
([f1; g2], [g1, f2])
and([f2; h2], [h1; f3])
in the following diagram, since commutations of other (large) diamonds can be deduced from those of small ones using basic equational reasoning. In practice, not checking such large diamonds may reduce the number of ambiguous path warnings.This PR implements the most general way to do such reduction I could find, which is proved correct in the sense that the inheritance graph is coherent if Coq does not report any ambiguous path. (I also have a draft paper briefly explain this, which I think I can partially share if needed.) To check if a diamond is reducible or not, the table of coercion classes (
class_tab
) has been extended with:cl_reachable_from
) and to (cl_reachable_to
) the class, respectively, andcl_repr
).(I will add more explanations later depending on what reviewers request. Let me run CI first.)
Kind: enhancement.
Corresponding documentation was added / updated (including any warning and error messages added / removed / modified).