-
Notifications
You must be signed in to change notification settings - Fork 20
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
Adding a case for type instantiation #184
base: main
Are you sure you want to change the base?
Conversation
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestions! I'll go back to this PR afterwards :)
Is there a test case for this, @mario-bucev ? |
Not directly, but it is necessary for the extractor |
So it's too cumbersome to generate tests at the level of Inox? |
We should be able to unit test this part |
Concerns the case
ADTType -> RefinementType
. However, we drop theprop
part, so maybe this is incorrect?