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

Counterexamples (WIP) #258

Draft
wants to merge 96 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
817090d
testfork
fabioali Feb 23, 2021
a9d4f85
Merge branch 'master' of https:/fabioali/gobra
fabioali Feb 23, 2021
e972bea
sync
fabioali Feb 25, 2021
77ef28f
added playgound
fabioali Feb 28, 2021
19a4f1e
created counterexample interface
fabioali Mar 1, 2021
9de06ac
added ppipeline and always-on counterexamples for silicon
fabioali Mar 2, 2021
7d9563f
something is happening: Backtranslator has a print statement
fabioali Mar 2, 2021
40a9c0d
added counterexample to VerifierError, Cleanup of backtranslator and …
fabioali Mar 3, 2021
0f3840d
cleanup of config
fabioali Mar 5, 2021
be18224
changed the varible names of the output
fabioali Mar 5, 2021
bf0203a
added parsing, function selection,some filtering
fabioali Mar 11, 2021
ac0e190
found relevant function
fabioali Mar 12, 2021
4ee340e
fixed shortName path problem
fabioali Mar 22, 2021
d89b741
added diffs from Felix
fabioali Mar 22, 2021
faed81a
modified for simplicity
fabioali Mar 22, 2021
4a4667c
found function that is important using types
fabioali Mar 22, 2021
127cae1
sourcemodel, mappings and such
fabioali Mar 26, 2021
43e050a
added entries
fabioali Mar 30, 2021
9e0a15c
cleanup
fabioali Mar 30, 2021
9e882a8
prettyprint
fabioali Apr 1, 2021
afb3cd7
counterexample config
fabioali Apr 6, 2021
a7476b0
Gobra interpreter, options and master interpreter
fabioali Apr 12, 2021
2292284
changed to use Gobra Interpreter instead
fabioali Apr 12, 2021
d82c5fd
Product interpreter
fabioali Apr 14, 2021
8614480
added debug by means of native counterexample
fabioali Apr 14, 2021
5ff1f8d
added translation out of Util, and subverted Pnode overlap issue
fabioali Apr 14, 2021
5151cdb
cleanup
fabioali Apr 14, 2021
6cf2631
added sfetycheck to option
fabioali Apr 14, 2021
c7979c3
added unboxin (experimental)
fabioali Apr 14, 2021
0695bc3
sync
fabioali Apr 16, 2021
bcdabdc
fixed Pnode overlap (by ignoring invalids)
fabioali Apr 16, 2021
fe1df32
Merge branch 'master' of https:/viperproject/gobra
fabioali Apr 16, 2021
1a63e4b
added Slices and Idexed interpreter
fabioali Apr 19, 2021
b190b0e
added lit string entry
fabioali Apr 19, 2021
0a171d0
added interpreters to mater interpreter
fabioali Apr 19, 2021
5cd39ad
Added Strings to Entries and backtranslation,
fabioali Apr 19, 2021
ae45520
added names for in-domain functions
fabioali Apr 20, 2021
cc5a1a4
added names to interpreter
fabioali Apr 20, 2021
d8469a6
added pointers interpreter (WIP)
fabioali Apr 20, 2021
59add40
cleanup of direcory
fabioali Apr 20, 2021
d7456a1
cleanup gitignore
fabioali Apr 20, 2021
d0c4bc0
lazyness for debugging
fabioali Apr 23, 2021
ccbd308
improved pointers
fabioali Apr 23, 2021
b001d69
added default entries for types
fabioali Apr 23, 2021
d198faa
imrpved pointer interpreter
fabioali Apr 23, 2021
973c091
resoved recursive calls
fabioali Apr 25, 2021
997b35b
cleanup
fabioali Apr 26, 2021
ec82097
separated shared struct and normal struct
fabioali Apr 27, 2021
9886258
fixed test by propagating typeinfo
fabioali Apr 27, 2021
de72fa8
pointer domains distinction
fabioali Apr 28, 2021
c204aa9
added return (which is different than returnLabel)
fabioali Apr 28, 2021
a8a11dd
sanatized decalared adresses
fabioali Apr 29, 2021
5682058
mitigated adressable variables
fabioali Apr 29, 2021
29f2e35
sanitation of values
fabioali Apr 29, 2021
308a59a
imroved prettyprint
fabioali May 3, 2021
9f64b9b
shared struct improvement
fabioali May 3, 2021
cb5de9e
improved fieldname
fabioali May 3, 2021
c611817
iproved addresses of shared Structs
fabioali May 4, 2021
0300315
pretty struct,
fabioali May 4, 2021
c86c0b4
whitespaceless fix
fabioali May 4, 2021
0a61951
fixed addressed pointer issue
fabioali May 7, 2021
294abee
sorted test output for easier checking
fabioali May 7, 2021
8e3c0a8
fields
fabioali May 8, 2021
4d17871
named types for literals
fabioali May 8, 2021
b54c4df
interface begin
fabioali May 10, 2021
010831f
removed asresses from test string
fabioali May 10, 2021
91927a0
Slices no longer depend on all of the original
fabioali May 14, 2021
c42275e
moved adressed outside of array
fabioali May 14, 2021
ed11954
cleanup
fabioali May 14, 2021
7792b8c
removed pointer values from test string
fabioali May 14, 2021
4b1b5ee
start of interface interpreter
fabioali May 17, 2021
e694f9d
added interfaces fo any non pointer types
fabioali May 22, 2021
d0cc22a
added sequences, improved named types
fabioali May 25, 2021
e4abbe0
added possibility for unresolved interfaces
fabioali May 26, 2021
41b008b
improved interfaces
fabioali May 30, 2021
5f64756
correct interface poly matching
fabioali May 30, 2021
f99d1fe
better filterning of unnecessary values
fabioali May 30, 2021
3d8acb1
added channels
fabioali Jun 9, 2021
4a1816c
added perms and heap entries
fabioali Jun 11, 2021
091ff89
improved channel interpretation
fabioali Jun 11, 2021
c84d95e
added predicate translation
fabioali Jun 21, 2021
ee9a593
made permission an option
fabioali Jun 21, 2021
9c623cd
added predicate interpreteation
fabioali Jun 27, 2021
79cbb78
Channel improvements
fabioali Jun 28, 2021
66e1c91
Merge branch 'master' of https:/viperproject/gobra
fabioali Jun 28, 2021
365e54a
cleanup after merge
fabioali Jul 5, 2021
5a6ad0a
added sparsity
fabioali Jul 6, 2021
bba2cb5
sync
fabioali Jul 8, 2021
cf5ba7d
ghost slices, cleanup of sparsity
fabioali Jul 9, 2021
02acdf8
Added better support for Gobra IDE
fabioali Jul 14, 2021
fdb776a
Added translation for UserDomains
fabioali Jul 18, 2021
1f9af32
addded string concatination to translation
fabioali Jul 21, 2021
d8c9caa
reduced counterexamples
fabioali Jul 23, 2021
2bbfbc7
added reduced option
fabioali Aug 6, 2021
a19c351
cleanup
fabioali Aug 19, 2021
f28dcdb
added unit test to master
fabioali Aug 19, 2021
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
27 changes: 25 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ silver
silicon
viperserver
logger.log

*.log
*.go.*
*.gobra.*
*.gobra.*

playground
.metals
.vscode
.vscode/launch.json
.metals/metals.lock.db
.metals/readonly/scala/package.scala
.metals/metals.h2.db
.metals/metals.log
.vscode/settings.json
project/.bloop
project/.bloop/*
fvf_finder.sh
.gitignore
csv
warmup
congregated_date.ods
.~lock.congregated_date.ods#
asserionerrors
eval_nErrors
n_Errors_2
replicateFile.sh
numars
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<img src=".github/docs/gobra.png" height="250">

[![Test Status](https:/viperproject/gobra/workflows/test/badge.svg?branch=master)](https:/viperproject/gobra/actions?query=workflow%3Atest+branch%3Amaster)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](./LICENSE)

Expand Down
18 changes: 18 additions & 0 deletions project/.bloop/bloop.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"semanticDBVersion": "4.4.13",
"supportedScalaVersions": [
"2.13.5",
"2.12.13",
"2.12.12",
"2.12.11",
"2.12.10",
"2.13.3",
"2.13.4",
"2.11.12",
"2.12.8",
"2.12.9",
"2.13.0",
"2.13.1",
"2.13.2"
]
}
2,147 changes: 2,147 additions & 0 deletions project/.bloop/gobra-build.json

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/main/scala/viper/gobra/Gobra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import viper.gobra.ast.frontend.PPackage
import viper.gobra.ast.internal.Program
import viper.gobra.ast.internal.transform.OverflowChecksTransform
import viper.gobra.backend.BackendVerifier
import viper.gobra.reporting.BackTranslator.VerificationBackTrackInfo
import viper.gobra.frontend.info.{Info, TypeInfo}
import viper.gobra.frontend.{Config, Desugar, Parser, ScallopGobraConfig}
import viper.gobra.reporting.{AppliedInternalTransformsMessage, BackTranslator, CopyrightReport, VerifierError, VerifierResult}
Expand Down Expand Up @@ -77,8 +78,20 @@ class Gobra extends GoVerifier with GoIdeVerifier {
typeInfo <- performTypeChecking(parsedPackage, finalConfig)
program <- performDesugaring(parsedPackage, typeInfo, finalConfig)
program <- performInternalTransformations(program, finalConfig)
viperTask <- performViperEncoding(program, finalConfig)
} yield (viperTask, finalConfig)
programWithBackInfo <- performViperEncoding(program, finalConfig,typeInfo)

(encodedProgram, encodingBackInfo) = (programWithBackInfo.program,programWithBackInfo.backtrack)
task = BackendVerifier.Task(
encodedProgram,
BackTranslator.BackTrackInfo(
encodingBackInfo.errorT,
encodingBackInfo.reasonT,
encodedProgram,
typeInfo,
config
)
)
} yield (task, finalConfig)
}

task.flatMap{
Expand Down Expand Up @@ -183,9 +196,9 @@ class Gobra extends GoVerifier with GoIdeVerifier {
}
}

private def performViperEncoding(program: Program, config: Config): Either[Vector[VerifierError], BackendVerifier.Task] = {
private def performViperEncoding(program: Program, config: Config,typeInfo:viper.gobra.frontend.info.TypeInfo): Either[Vector[VerifierError], BackendVerifier.Task] = {
if (config.shouldViperEncode) {
Right(Translator.translate(program)(config))
Right(Translator.translate(program)(config,typeInfo))
} else {
Left(Vector())
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/viper/gobra/backend/BackendVerifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ object BackendVerifier {
case _ =>
}

if(config.counterexample.isDefined){
exePaths ++= Vector("--counterexample", "mapped")
}

(config.backend, config.boogieExe) match {
case (Carbon, Some(boogieExe)) =>
exePaths ++= Vector("--boogieExe", boogieExe)
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/viper/gobra/backend/ViperBackends.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ object ViperBackends {
def create(exePaths: Vector[String]): Silicon = {

var options: Vector[String] = Vector.empty

options ++= Vector("--logLevel", "ERROR")
options ++= Vector("--disableCatchingExceptions")
options ++= Vector("--enableMoreCompleteExhale")
options ++= exePaths


new Silicon(options)
}
Expand Down
28 changes: 24 additions & 4 deletions src/main/scala/viper/gobra/frontend/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import org.slf4j.LoggerFactory
import viper.gobra.backend.{ViperBackend, ViperBackends, ViperVerifierConfig}
import viper.gobra.GoVerifier
import viper.gobra.frontend.PackageResolver.{FileResource, RegularImport}
import viper.gobra.reporting.{FileWriterReporter, GobraReporter, StdIOReporter}
import viper.gobra.reporting.{FileWriterReporter, GobraReporter, StdIOReporter,CounterexampleConfigs}
import viper.gobra.util.{TypeBounds, Violation}
import org.scalactic.Bool
import _root_.viper.gobra.reporting.CounterexampleConfig


object LoggerDefaults {
Expand All @@ -41,10 +43,12 @@ case class Config(
checkOverflows: Boolean = false,
checkConsistency: Boolean = false,
shouldVerify: Boolean = true,

// The go language specification states that int and uint variables can have either 32bit or 64, as long
// as they have the same size. This flag allows users to pick the size of int's and uints's: 32 if true,
// 64 bit otherwise.
int32bit: Boolean = false
int32bit: Boolean = false,
counterexample :Option[CounterexampleConfig] = None
) {
def merge(other: Config): Config = {
// this config takes precedence over other config
Expand All @@ -63,7 +67,8 @@ case class Config(
shouldViperEncode = shouldViperEncode,
checkOverflows = checkOverflows || other.checkOverflows,
shouldVerify = shouldVerify,
int32bit = int32bit || other.int32bit
int32bit = int32bit || other.int32bit,
counterexample=counterexample
)
}

Expand Down Expand Up @@ -207,6 +212,20 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
noshort = false
)

val counterexample:ScallopOption[CounterexampleConfig] = opt[CounterexampleConfig](
name = "counterexample",
descr = "Adds counterexamples to output can be run with: mapped, native, reduced, extended (default: no counterexample)"
+"curently works witch SILICON as a backend",
default = None,
noshort = false
)(singleArgConverter({
case "mapped" => CounterexampleConfigs.MappedCounterexamples
case "native" => CounterexampleConfigs.NativeCounterexamples
case "reduced" => CounterexampleConfigs.ReducedCounterexamples
case "extended" => CounterexampleConfigs.ExtendedCounterexamples
case _ => CounterexampleConfigs.MappedCounterexamples
}))


/**
* Exception handling
Expand Down Expand Up @@ -379,6 +398,7 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals
shouldViperEncode = shouldViperEncode,
checkOverflows = checkOverflows(),
int32bit = int32Bit(),
shouldVerify = shouldVerify
shouldVerify = shouldVerify,
counterexample=counterexample.toOption
)
}
24 changes: 17 additions & 7 deletions src/main/scala/viper/gobra/reporting/BackTranslator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
// Copyright (c) 2011-2020 ETH Zurich.

package viper.gobra.reporting
import viper.gobra.ast.frontend._
import viper.gobra.frontend.info.TypeInfo
import viper.gobra.backend.BackendVerifier
import viper.gobra.frontend.Config
import viper.gobra.frontend.{Config,Parser}
import viper.silver.{ast => vpr}
import viper.silver
import java.nio.file.{Path,Paths}

import scala.annotation.unused

Expand All @@ -18,20 +21,27 @@ object BackTranslator {
def translate(error: silver.verifier.VerificationError): VerificationError
def translate(reason: silver.verifier.ErrorReason): VerificationErrorReason
}

case class BackTrackInfo(
case class VerificationBackTrackInfo(
errorT: Seq[BackTranslator.ErrorTransformer],
reasonT: Seq[BackTranslator.ReasonTransformer]
)
case class BackTrackInfo(
errorT: Seq[BackTranslator.ErrorTransformer],
reasonT: Seq[BackTranslator.ReasonTransformer],
viperprogram:vpr.Program,
typeInfo:TypeInfo,
config:Config
)

type ErrorTransformer = PartialFunction[silver.verifier.VerificationError, VerificationError]
type ReasonTransformer = PartialFunction[silver.verifier.ErrorReason, VerificationErrorReason]

def backTranslate(result: BackendVerifier.Result)(@unused config: Config): VerifierResult = result match {
def backTranslate(result: BackendVerifier.Result)(/* @unused */ config: Config): VerifierResult =
result match {
case BackendVerifier.Success => VerifierResult.Success
case BackendVerifier.Failure(errors, backtrack) =>
val errorTranslator = new DefaultErrorBackTranslator(backtrack)
VerifierResult.Failure(errors map errorTranslator.translate)
case BackendVerifier.Failure(errors, backtrack) =>
val errorTranslator = new DefaultErrorBackTranslator(backtrack.copy(config=config)) //TODO make this more clean e.g. remove config from backtrack Info
VerifierResult.Failure(errors map errorTranslator.translate)
}

implicit class RichErrorMessage(error: silver.verifier.ErrorMessage) {
Expand Down
Loading