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

Adding a case for type instantiation #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mario-bucev
Copy link
Collaborator

Concerns the case ADTType -> RefinementType. However, we drop the prop part, so maybe this is incorrect?

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
}
Copy link
Member

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.

Copy link
Collaborator Author

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 :)

@vkuncak
Copy link
Contributor

vkuncak commented Dec 14, 2022

Is there a test case for this, @mario-bucev ?

@mario-bucev
Copy link
Collaborator Author

Not directly, but it is necessary for the extractor :: to work when nested.

@vkuncak
Copy link
Contributor

vkuncak commented Dec 14, 2022

So it's too cumbersome to generate tests at the level of Inox?

@mario-bucev
Copy link
Collaborator Author

We should be able to unit test this part

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.

3 participants