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

Do not extend NamedVar with Kind.Identifier in DPIA #190

Merged
merged 8 commits into from
Jun 21, 2021

Conversation

umazalakain
Copy link
Contributor

@umazalakain umazalakain commented Jun 19, 2021

This way NamedVars are uniform across RISE, DPIA, and arithexpr. This accomplishes two things:

  • it is a first step towards the unification of types across RISE and DPIA
  • it renders the set of bugs product of DPIA -> arithexpr -> DPIA translations irrelevant.

@umazalakain umazalakain marked this pull request as ready for review June 20, 2021 21:11
@umazalakain
Copy link
Contributor Author

umazalakain commented Jun 20, 2021

Comment on lines -135 to -163
def renaming[X <: PhraseType](p: Phrase[X]): Phrase[X] = {
case class Renaming(idMap: Map[String, String]) extends VisitAndRebuild.Visitor {
override def phrase[T <: PhraseType](p: Phrase[T]): Result[Phrase[T]] = p match {
case Identifier(name, t) => Stop(
Identifier(idMap.getOrElse(name, name),
VisitAndRebuild.visitPhraseTypeAndRebuild(t, this)).asInstanceOf[Phrase[T]])
case l @ Lambda(x, _) =>
val newMap = idMap + (x.name -> freshName(x.name.takeWhile(_.isLetter)))
Continue(l, Renaming(newMap))
case dl @ DepLambda(_, x, _) =>
val newMap = idMap + (x.name -> freshName(x.name.takeWhile(_.isLetter)))
Continue(dl, Renaming(newMap))
case _ => Continue(p, this)
}

override def nat[N <: Nat](n: N): N = n.visitAndRebuild({
case i: NatIdentifier =>
NatIdentifier(idMap.getOrElse(i.name, i.name))
case ae => ae
}).asInstanceOf[N]

override def data[T <: DataType](dt: T): T = (dt match {
case i: DataTypeIdentifier =>
DataTypeIdentifier(idMap.getOrElse(i.name, i.name))
case dt => dt
}).asInstanceOf[T]
}
VisitAndRebuild(p, Renaming(Map()))
}
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 that if we don't try to enforce unique names anymore, we should use proper capture-avoiding substitution here?

Copy link
Member

Choose a reason for hiding this comment

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

@Bastacyclop can you create an issue for that, please?

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines -82 to +86
case pf@ParForNat(level, dim, _, name) if (eliminateVars(pf.body.asInstanceOf[DepLambda[_, _ <: Kind.Identifier, _]].x.name)) =>
case pf@ParForNat(level, dim, _, name) if (eliminateVars(Kind.idName(
pf.body.asInstanceOf[DepLambda[_, _, _ <: Kind.Identifier, _]].kind,
pf.body.asInstanceOf[DepLambda[_, _, _ <: Kind.Identifier, _]].x))) =>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe there is a better way to write this to avoid triple casting.

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