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

Add options to assume Injectivity On Inhale and to disable it #442

Merged
merged 3 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/main/scala/viper/gobra/backend/ViperBackends.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ object ViperBackends {
options ++= Vector("--logLevel", "ERROR")
options ++= Vector("--disableCatchingExceptions")
options ++= Vector("--enableMoreCompleteExhale")
options ++= Vector("--assumeInjectivityOnInhale")
if (config.assumeInjectivityOnInhale) {
options ++= Vector("--assumeInjectivityOnInhale")
}
options ++= exePaths

new Silicon(options)
Expand All @@ -35,7 +37,9 @@ object ViperBackends {
def create(exePaths: Vector[String], config: Config)(implicit executor: GobraExecutionContext): Carbon = {
var options: Vector[String] = Vector.empty
// options ++= Vector("--logLevel", "ERROR")
options ++= Vector("--assumeInjectivityOnInhale")
if (config.assumeInjectivityOnInhale) {
options ++= Vector("--assumeInjectivityOnInhale")
}
options ++= exePaths

new Carbon(options)
Expand Down Expand Up @@ -88,7 +92,9 @@ object ViperBackends {
options ++= Vector("--logLevel", "ERROR")
options ++= Vector("--disableCatchingExceptions")
options ++= Vector("--enableMoreCompleteExhale")
options ++= Vector("--assumeInjectivityOnInhale")
if (config.assumeInjectivityOnInhale) {
options ++= Vector("--assumeInjectivityOnInhale")
}
options ++= exePaths
ViperServerConfig.ConfigWithSilicon(options.toList)
}
Expand All @@ -98,7 +104,9 @@ object ViperBackends {
override def getViperVerifierConfig(exePaths: Vector[String], config: Config): ViperVerifierConfig = {
var options: Vector[String] = Vector.empty
options ++= Vector("--logLevel", "ERROR")
options ++= Vector("--assumeInjectivityOnInhale")
if (config.assumeInjectivityOnInhale) {
options ++= Vector("--assumeInjectivityOnInhale")
}
options ++= exePaths
ViperServerConfig.ConfigWithCarbon(options.toList)
}
Expand Down
19 changes: 17 additions & 2 deletions src/main/scala/viper/gobra/frontend/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ object ConfigDefaults {
lazy val DefaultOnlyFilesWithHeader: Boolean = false
lazy val DefaultGobraDirectory: String = ".gobra"
lazy val DefaultTaskName: String = "gobra-task"
lazy val DefaultAssumeInjectivityOnInhale: Boolean = true
}

case class Config(
Expand Down Expand Up @@ -100,6 +101,8 @@ case class Config(
// or when the goal is to gradually verify part of a package without having to provide an explicit list of the files
// to verify.
onlyFilesWithHeader: Boolean = ConfigDefaults.DefaultOnlyFilesWithHeader,
// if enabled, Gobra assumes injectivity on inhale, as done by Viper versions before 2022.2.
assumeInjectivityOnInhale: Boolean = ConfigDefaults.DefaultAssumeInjectivityOnInhale,
) {

def merge(other: Config): Config = {
Expand Down Expand Up @@ -138,6 +141,7 @@ case class Config(
int32bit = int32bit || other.int32bit,
checkConsistency = checkConsistency || other.checkConsistency,
onlyFilesWithHeader = onlyFilesWithHeader || other.onlyFilesWithHeader,
assumeInjectivityOnInhale = assumeInjectivityOnInhale || other.assumeInjectivityOnInhale,
)
}

Expand Down Expand Up @@ -176,6 +180,7 @@ case class BaseConfig(moduleName: String = ConfigDefaults.DefaultModuleName,
int32bit: Boolean = ConfigDefaults.DefaultInt32bit,
cacheParser: Boolean = ConfigDefaults.DefaultCacheParser,
onlyFilesWithHeader: Boolean = ConfigDefaults.DefaultOnlyFilesWithHeader,
assumeInjectivityOnInhale: Boolean = ConfigDefaults.DefaultAssumeInjectivityOnInhale,
) {
def shouldParse: Boolean = true
def shouldTypeCheck: Boolean = !shouldParseOnly
Expand Down Expand Up @@ -221,7 +226,9 @@ trait RawConfig {
shouldChop = baseConfig.shouldChop,
int32bit = baseConfig.int32bit,
cacheParser = baseConfig.cacheParser,
onlyFilesWithHeader = baseConfig.onlyFilesWithHeader)
onlyFilesWithHeader = baseConfig.onlyFilesWithHeader,
assumeInjectivityOnInhale = baseConfig.assumeInjectivityOnInhale,
)
}

/**
Expand Down Expand Up @@ -540,6 +547,13 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
noshort = true
)

val assumeInjectivityOnInhale: ScallopOption[Boolean] = toggle(
name = "assumeInjectivityOnInhale",
descrYes = "Assumes injectivity of predicates on inhale, like in Viper versions previous to 2022.02 (default)",
jcp19 marked this conversation as resolved.
Show resolved Hide resolved
descrNo = "Does not assume injectivity on inhales (this will become the default in future versions)",
default = Some(true),
jcp19 marked this conversation as resolved.
Show resolved Hide resolved
noshort = true
)

/**
* Exception handling
Expand Down Expand Up @@ -641,6 +655,7 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
checkConsistency = checkConsistency(),
int32bit = int32Bit(),
cacheParser = false, // caching does not make sense when using the CLI. Thus, we simply set it to `false`
onlyFilesWithHeader = onlyFilesWithHeader()
onlyFilesWithHeader = onlyFilesWithHeader(),
assumeInjectivityOnInhale = assumeInjectivityOnInhale(),
)
}