Adding a case for type instantiation#184
Open
mario-bucev wants to merge 1 commit intoepfl-lara:mainfrom
Open
Conversation
samarion
reviewed
Dec 6, 2022
Comment on lines
+75
to
+83
| case (adt1: ADTType, refn: RefinementType) => | ||
| refn.getType match { | ||
| case adt2: ADTType => | ||
| // ADT(X1, ..., Xn) -> { vd: ADT(A1, ..., An) | prop } | ||
| // ~> | ||
| // X1 -> A1, ..., Xn -> An | ||
| rec(adt1, adt2) | ||
| case _ => throw new Failure | ||
| } |
Member
There was a problem hiding this comment.
I think you could make it a bit more general with:
case (_, RefinementType(vd, _)) =>
rec(from, vd.tpe)Also, we probably need cases for SigmaType and PiType:
case (TupleType(tps), SigmaType(vds, elem)) =>
val vars = vds.map(_.toVariable).toSet
(tps zip (vds.map(_.tpe) +: elem)).foldLeft[Instantiation](Map.empty) {
case (inst, (tp1, tp2)) =>
unify(inst, rec(tp1, if ((exprOps.variablesOf(tp2) & vars).nonEmpty) tp2.getType else tp2))
}(and same for PiType).
Finally, you should probably make sure the from type isn't a dependent type by using from.getType in the call to rec below.
Collaborator
Author
There was a problem hiding this comment.
Thank you for the suggestions! I'll go back to this PR afterwards :)
Contributor
|
Is there a test case for this, @mario-bucev ? |
Collaborator
Author
|
Not directly, but it is necessary for the extractor |
Contributor
|
So it's too cumbersome to generate tests at the level of Inox? |
Collaborator
Author
|
We should be able to unit test this part |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Concerns the case
ADTType -> RefinementType. However, we drop theproppart, so maybe this is incorrect?