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 Viper plugin #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Adding a Viper plugin #2

wants to merge 6 commits into from

Conversation

marcoeilers
Copy link
Contributor

  • Making the SIF transformation available via a plugin
  • Defining a simple parser extension for that purpose
  • Adding a SIFRelExp(e, i) expression that refers to the value of expression e in execution i, where i is 0 or 1. @JonasAlaif asked for this.
  • Bumping the SBT version
  • Also adding something I added for Nagini ages a while ago, namely the possibility of using domain func apps to create low and lowEvent expressions.

… line. Also added a rel(e, i) expression to refer to expression e in execution i, where i is 0 or 1.
"-feature", // Warn on features that requires explicit import
"-Wunused", // Warn on unused imports
"-Ypatmat-exhaust-depth", "40", // Increase depth of pattern matching analysis
// "-Xfatal-warnings", // Treat Warnings as errors to guarantee code quality in future changes

Choose a reason for hiding this comment

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

Is this intentionally commented out?


override def typ: Type = exp.typ

override def verifyExtExp(): VerificationResult = ???

Choose a reason for hiding this comment

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

Would be good to comment why this can be unimplemented or instead throw some error message.

@@ -125,6 +125,21 @@ case class SIFLowExp(exp: Exp, comparator: Option[String] = None, typVarMap: Map
override val extensionIsPure: Boolean = exp.isPure
}

case class SIFRelExp(exp: Exp, i: IntLit)

Choose a reason for hiding this comment

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

Are you using IntLit instead of Int so that Viper's rewriter is not breaking? Does it make sense to document this? Also, you should comment which index corresponds to which execution.

Comment on lines -137 to +139
p.copy(domains = newDomains, fields = newFields, functions = newFunctions, predicates = newPredicates,
val res = p.copy(domains = newDomains, fields = newFields, functions = newFunctions, predicates = newPredicates,
methods = newMethods)(p.pos, p.info, p.errT)
res

Choose a reason for hiding this comment

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

intentionally?

// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2011-2020 ETH Zurich.

Choose a reason for hiding this comment

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

not 2023?

// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2011-2020 ETH Zurich.

Choose a reason for hiding this comment

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

not 2023?

if (expected == TypeHelper.Bool)
None
else
Some(Seq(s"Expected type ${expected}, but got Bool"))

Choose a reason for hiding this comment

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

Just making sure that all error messages intentionally do not end with a period.

Comment on lines +36 to +38
override def beforeVerify(input: Program): Program = {
SIFExtendedTransformer.transform(input, false)
}

Choose a reason for hiding this comment

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

I am not familiar with how we deal with these things in plugins. To my knowledge, the plugin does not support magic wands or gotos jumping outside of loops. Should programs containing unsupported features cause a warning?

@tillarnold
Copy link

As expected using rel(r,0) as a trigger results in an error message like { rel(r, 0) } is not a valid Trigger however the example below results in Exceptions being thrown for both Carbon as well as Silicon.

function get(v: Ref, idx: Int): Bool  { true }

method t(r: Ref)
    { assert forall i: Int :: {get(rel(r,0), i)}  get(rel(r,0), i) }

Carbon:
Exception in thread "main" java.lang.RuntimeException: Viper expression didn't match any existing case.

Silicon:
Verification aborted exceptionally: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: Unexpected expression rel(r, 0) cannot be symbolically evaluate

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.

4 participants