Skip to content

Commit 08298a7

Browse files
committed
Merge
2 parents 15eb574 + 8e1c013 commit 08298a7

67 files changed

Lines changed: 1482 additions & 685 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

silver

Submodule silver updated 111 files

src/main/resources/field_value_functions_axioms.smt2

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@
1111
; The axiom therefore needs to be emitted after the sort wrappers have
1212
; been emitted.
1313

14-
(assert (forall ((vs $FVF<$T$>) (ws $FVF<$T$>)) (!
14+
(assert (forall ((vs $FVF<$FLD$>) (ws $FVF<$FLD$>)) (!
1515
(=>
1616
(and
1717
(Set_equal ($FVF.domain_$FLD$ vs) ($FVF.domain_$FLD$ ws))
1818
(forall ((x $Ref)) (!
1919
(=>
2020
(Set_in x ($FVF.domain_$FLD$ vs))
2121
(= ($FVF.lookup_$FLD$ vs x) ($FVF.lookup_$FLD$ ws x)))
22-
; :pattern ((Set_in x ($FVF.domain_$FLD$ vs)))
2322
:pattern (($FVF.lookup_$FLD$ vs x) ($FVF.lookup_$FLD$ ws x))
24-
:qid |qp.$FVF<$T$>-eq-inner|
23+
:qid |qp.$FVF<$FLD$>-eq-inner|
2524
)))
2625
(= vs ws))
27-
:pattern (($SortWrappers.$FVF<$T$>To$Snap vs)
28-
($SortWrappers.$FVF<$T$>To$Snap ws)
29-
; ($FVF.after_$FLD$ vs ws)
26+
:pattern (($SortWrappers.$FVF<$FLD$>To$Snap vs)
27+
($SortWrappers.$FVF<$FLD$>To$Snap ws)
3028
)
31-
:qid |qp.$FVF<$T$>-eq-outer|
29+
:qid |qp.$FVF<$FLD$>-eq-outer|
3230
)))
3331

3432
(assert (forall ((r $Ref) (pm $FPM)) (!

src/main/resources/field_value_functions_declarations.smt2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
; - $S$ is the sort corresponding to the type of the field
88
; - $T$ is the sanitized name of the sort corresponding to the type of the field
99

10-
(declare-fun $FVF.domain_$FLD$ ($FVF<$T$>) Set<$Ref>)
11-
(declare-fun $FVF.lookup_$FLD$ ($FVF<$T$> $Ref) $S$)
12-
(declare-fun $FVF.after_$FLD$ ($FVF<$T$> $FVF<$T$>) Bool)
10+
(declare-fun $FVF.domain_$FLD$ ($FVF<$FLD$>) Set<$Ref>)
11+
(declare-fun $FVF.lookup_$FLD$ ($FVF<$FLD$> $Ref) $S$)
12+
(declare-fun $FVF.after_$FLD$ ($FVF<$FLD$> $FVF<$FLD$>) Bool)
1313
(declare-fun $FVF.loc_$FLD$ ($S$ $Ref) Bool)
1414
(declare-fun $FVF.perm_$FLD$ ($FPM $Ref) $Perm)
15-
(declare-const $fvfTOP_$FLD$ $FVF<$T$>)
15+
(declare-const $fvfTOP_$FLD$ $FVF<$FLD$>)

src/main/resources/predicate_snap_functions_axioms.smt2

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
; The axiom therefore needs to be emitted after the sort wrappers have
1111
; been emitted.
1212

13-
(assert (forall ((vs $PSF<$S$>) (ws $PSF<$S$>)) (!
13+
(assert (forall ((vs $PSF<$PRD$>) (ws $PSF<$PRD$>)) (!
1414
(=>
1515
(and
1616
(Set_equal ($PSF.domain_$PRD$ vs) ($PSF.domain_$PRD$ ws))
@@ -20,14 +20,14 @@
2020
(= ($PSF.lookup_$PRD$ vs x) ($PSF.lookup_$PRD$ ws x)))
2121
; :pattern ((Set_in x ($PSF.domain_$PRD$ vs)))
2222
:pattern (($PSF.lookup_$PRD$ vs x) ($PSF.lookup_$PRD$ ws x))
23-
:qid |qp.$PSF<$S$>-eq-inner|
23+
:qid |qp.$PSF<$PRD$>-eq-inner|
2424
)))
2525
(= vs ws))
26-
:pattern (($SortWrappers.$PSF<$S$>To$Snap vs)
27-
($SortWrappers.$PSF<$S$>To$Snap ws)
26+
:pattern (($SortWrappers.$PSF<$PRD$>To$Snap vs)
27+
($SortWrappers.$PSF<$PRD$>To$Snap ws)
2828
; ($PSF.after_$PRD$ vs ws)
2929
)
30-
:qid |qp.$PSF<$S$>-eq-outer|
30+
:qid |qp.$PSF<$PRD$>-eq-outer|
3131
)))
3232

3333
(assert (forall ((s $Snap) (pm $PPM)) (!

src/main/resources/predicate_snap_functions_declarations.smt2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
; - $PRD$ is a Silver predicate name
77
; - $S$ is the sort corresponding to the type of the predicate arguments
88

9-
(declare-fun $PSF.domain_$PRD$ ($PSF<$S$>) Set<$Snap>)
10-
(declare-fun $PSF.lookup_$PRD$ ($PSF<$S$> $Snap) $S$)
11-
(declare-fun $PSF.after_$PRD$ ($PSF<$S$> $PSF<$S$>) Bool)
9+
(declare-fun $PSF.domain_$PRD$ ($PSF<$PRD$>) Set<$Snap>)
10+
(declare-fun $PSF.lookup_$PRD$ ($PSF<$PRD$> $Snap) $S$)
11+
(declare-fun $PSF.after_$PRD$ ($PSF<$PRD$> $PSF<$PRD$>) Bool)
1212
(declare-fun $PSF.loc_$PRD$ ($S$ $Snap) Bool)
1313
(declare-fun $PSF.perm_$PRD$ ($PPM $Snap) $Perm)
14-
(declare-const $psfTOP_$PRD$ $PSF<$S$>)
14+
(declare-const $psfTOP_$PRD$ $PSF<$PRD$>)

src/main/scala/Config.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class Config(args: Seq[String]) extends SilFrontendConfig(args, "Silicon") {
565565

566566
val assertionMode: ScallopOption[AssertionMode] = opt[AssertionMode]("assertionMode",
567567
descr = ( "Determines how assertion checks are encoded in SMTLIB. Options are "
568-
+ "'pp' (push-pop) and 'cs' (soft constraints) (default: cs)."),
568+
+ "'pp' (push-pop) and 'sc' (soft constraints) (default: pp)."),
569569
default = Some(AssertionMode.PushPop),
570570
noshort = true
571571
)(assertionModeConverter)
@@ -643,7 +643,7 @@ class Config(args: Seq[String]) extends SilFrontendConfig(args, "Silicon") {
643643

644644
val numberOfParallelVerifiers: ScallopOption[Int] = opt[Int]("numberOfParallelVerifiers",
645645
descr = ( "Number of verifiers run in parallel. This number plus one is the number of provers "
646-
+ s"run in parallel (default: ${Runtime.getRuntime.availableProcessors()}"),
646+
+ s"run in parallel (default: ${Runtime.getRuntime.availableProcessors()})"),
647647
default = Some(Runtime.getRuntime.availableProcessors()),
648648
noshort = true
649649
)
@@ -754,19 +754,21 @@ class Config(args: Seq[String]) extends SilFrontendConfig(args, "Silicon") {
754754
case _ => Right(())
755755
}
756756

757-
validateOpt(ideModeAdvanced, numberOfParallelVerifiers) {
758-
case (Some(false), _) =>
759-
Right(())
760-
case (Some(true), Some(n)) =>
761-
if (n == 1)
762-
Right(())
763-
else
764-
Left( s"Option ${ideModeAdvanced.name} requires setting "
765-
+ s"${numberOfParallelVerifiers.name} to 1")
757+
validateOpt(ideModeAdvanced, parallelizeBranches) {
758+
case (Some(false), _) => Right(())
759+
case (_, Some(false)) => Right(())
760+
case (Some(true), Some(true)) =>
761+
Left(s"Option ${ideModeAdvanced.name} is not supported in combination with ${parallelizeBranches.name}")
766762
case other =>
767763
sys.error(s"Unexpected combination: $other")
768764
}
769-
765+
766+
validateOpt(assertionMode, parallelizeBranches) {
767+
case (Some(AssertionMode.SoftConstraints), Some(true)) =>
768+
Left(s"Assertion mode SoftConstraints is not supported in combination with ${parallelizeBranches.name}")
769+
case _ => Right()
770+
}
771+
770772
validateOpt(counterexample, enableMoreCompleteExhale) {
771773
case (Some(_), Some(false)) => Left( s"Option ${counterexample.name} requires setting "
772774
+ s"flag ${enableMoreCompleteExhale.name}")

src/main/scala/Silicon.scala

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package viper.silicon
88

99
import java.text.SimpleDateFormat
1010
import java.util.concurrent.{Callable, Executors, TimeUnit, TimeoutException}
11-
1211
import scala.collection.immutable.ArraySeq
1312
import scala.util.{Left, Right}
1413
import ch.qos.logback.classic.{Level, Logger}
@@ -19,7 +18,7 @@ import viper.silver.frontend.{DefaultStates, SilFrontend}
1918
import viper.silver.reporter._
2019
import viper.silver.verifier.{AbstractVerificationError => SilAbstractVerificationError, Failure => SilFailure, Success => SilSuccess, TimeoutOccurred => SilTimeoutOccurred, VerificationResult => SilVerificationResult, Verifier => SilVerifier}
2120
import viper.silicon.interfaces.Failure
22-
import viper.silicon.logger.SymbExLogger
21+
import viper.silicon.logger.{MemberSymbExLogger, SymbExLogger}
2322
import viper.silicon.reporting.{MultiRunRecorders, condenseToViperResult}
2423
import viper.silicon.verifier.DefaultMainVerifier
2524
import viper.silicon.decider.{Cvc5ProverStdIO, Z3ProverStdIO}
@@ -93,6 +92,10 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
9392
private var _config: Config = _
9493
final def config = _config
9594

95+
private var _symbExLog: SymbExLogger[_ <: MemberSymbExLogger] = _
96+
final def symbExLog = _symbExLog
97+
final def symbExLog_=(log: SymbExLogger[_ <: MemberSymbExLogger]) = { _symbExLog = log }
98+
9699
private sealed trait LifetimeState
97100

98101
private object LifetimeState {
@@ -113,6 +116,7 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
113116
lifetimeState = LifetimeState.Configured
114117

115118
_config = new Config(args)
119+
_symbExLog = SymbExLogger.ofConfig(_config)
116120
}
117121

118122
def debugInfo(debugInfo: Seq[(String, Any)]): Unit = { this.debugInfo = debugInfo }
@@ -129,7 +133,7 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
129133

130134
setLogLevelsFromConfig()
131135

132-
verifier = new DefaultMainVerifier(config, reporter)
136+
verifier = new DefaultMainVerifier(config, reporter, symbExLog)
133137
verifier.start()
134138
}
135139

@@ -202,10 +206,9 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
202206
result = Some(condenseToViperResult(failures))
203207
} catch { /* Catch exceptions thrown during verification (errors are not caught) */
204208
case _: TimeoutException =>
205-
// verification was interrupted, therefore close the current member's scope:
206-
SymbExLogger.currentLog().closeMemberScope()
207209
if (config.ideModeAdvanced()) {
208-
reporter report ExecutionTraceReport(SymbExLogger.memberList, List(), List())
210+
symbExLog.close()
211+
reporter report ExecutionTraceReport(symbExLog.logs.toSeq, List(), List())
209212
}
210213
result = Some(SilFailure(SilTimeoutOccurred(config.timeout(), "second(s)") :: Nil))
211214
case exception: Exception if !config.disableCatchingExceptions() =>
@@ -240,21 +243,23 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
240243

241244
/*verifier.bookkeeper.*/elapsedMillis = System.currentTimeMillis() - /*verifier.bookkeeper.*/startTime
242245

243-
val failures =
244-
results.flatMap(r => r :: r.previous.toList)
245-
.collect{ case f: Failure => f } /* Ignore successes */
246-
.pipe(allResults => {
247-
/* If branchconditions are to be reported we collect the different failure contexts
248-
* of all failures that report the same error (but on different branches, with different CounterExample)
249-
* and put those into one failure */
250-
if (config.enableBranchconditionReporting())
251-
allResults.groupBy(failureFilterAndGroupingCriterion).map{case (_: String, fs:List[Failure]) =>
252-
fs.head.message.failureContexts = fs.flatMap(_.message.failureContexts)
253-
Failure(fs.head.message)
254-
}.toList
255-
else allResults.distinctBy(failureFilterAndGroupingCriterion)
256-
})
257-
.sortBy(failureSortingCriterion)
246+
val failures = results
247+
// note that we do not extract 'previous' verification errors from VerificationResult's `previous` field
248+
// because this is expected to have already been done in `verifier.verify` (for each member).
249+
.collect{ case f: Failure => f } /* Ignore successes */
250+
.pipe(allResults => {
251+
/* If branchconditions are to be reported we collect the different failure contexts
252+
* of all failures that report the same error (but on different branches, with different CounterExample)
253+
* and put those into one failure
254+
*/
255+
if (config.enableBranchconditionReporting())
256+
allResults.groupBy(failureFilterAndGroupingCriterion).map{case (_: String, fs:List[Failure]) =>
257+
fs.head.message.failureContexts = fs.flatMap(_.message.failureContexts)
258+
Failure(fs.head.message)
259+
}.toList
260+
else allResults.distinctBy(failureFilterAndGroupingCriterion)
261+
})
262+
.sortBy(failureSortingCriterion)
258263

259264
// if (config.showStatistics.isDefined) {
260265
// val proverStats = verifier.decider.statistics()
@@ -335,6 +340,8 @@ class SiliconFrontend(override val reporter: Reporter,
335340

336341
protected var siliconInstance: Silicon = _
337342

343+
override def backendTypeFormat: Option[String] = Some("SMTLIB")
344+
338345
def createVerifier(fullCmd: String) = {
339346
siliconInstance = new Silicon(reporter, Seq("args" -> fullCmd))
340347

@@ -344,7 +351,7 @@ class SiliconFrontend(override val reporter: Reporter,
344351
def configureVerifier(args: Seq[String]) = {
345352
siliconInstance.parseCommandLine(args)
346353

347-
if (siliconInstance.config.error.isEmpty) {
354+
if (siliconInstance.config.error.isEmpty && !siliconInstance.config.exit) {
348355
/** Parsing the provided command-line options might fail, in which the resulting error
349356
* is recorded in `siliconInstance.config.error`
350357
* (see also [[viper.silver.frontend.SilFrontendConfig.onError]]).

src/main/scala/decider/Decider.scala

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import viper.silicon._
1515
import viper.silicon.common.collections.immutable.InsertionOrderedSet
1616
import viper.silicon.interfaces._
1717
import viper.silicon.interfaces.decider._
18-
import viper.silicon.logger.SymbExLogger
1918
import viper.silicon.logger.records.data.{DeciderAssertRecord, DeciderAssumeRecord, ProverAssertRecord}
2019
import viper.silicon.state._
2120
import viper.silicon.state.terms._
@@ -183,18 +182,18 @@ trait DefaultDeciderProvider extends VerifierComponent { this: Verifier =>
183182

184183
def pushScope(): Unit = {
185184
//val commentRecord = new CommentRecord("push", null, null)
186-
//val sepIdentifier = SymbExLogger.currentLog().openScope(commentRecord)
185+
//val sepIdentifier = symbExLog.openScope(commentRecord)
187186
pathConditions.pushScope()
188187
_prover.push(timeout = Verifier.config.pushTimeout.toOption)
189-
//SymbExLogger.currentLog().closeScope(sepIdentifier)
188+
//symbExLog.closeScope(sepIdentifier)
190189
}
191190

192191
def popScope(): Unit = {
193192
//val commentRecord = new CommentRecord("pop", null, null)
194-
//val sepIdentifier = SymbExLogger.currentLog().openScope(commentRecord)
193+
//val sepIdentifier = symbExLog.openScope(commentRecord)
195194
_prover.pop()
196195
pathConditions.popScope()
197-
//SymbExLogger.currentLog().closeScope(sepIdentifier)
196+
//symbExLog.closeScope(sepIdentifier)
198197
}
199198

200199
def setCurrentBranchCondition(t: Term, te: Option[ast.Exp] = None): Unit = {
@@ -223,15 +222,15 @@ trait DefaultDeciderProvider extends VerifierComponent { this: Verifier =>
223222

224223
private def assumeWithoutSmokeChecks(terms: InsertionOrderedSet[Term]) = {
225224
val assumeRecord = new DeciderAssumeRecord(terms)
226-
val sepIdentifier = SymbExLogger.currentLog().openScope(assumeRecord)
225+
val sepIdentifier = symbExLog.openScope(assumeRecord)
227226

228227
/* Add terms to Silicon-managed path conditions */
229228
terms foreach pathConditions.add
230229

231230
/* Add terms to the prover's assumptions */
232231
terms foreach prover.assume
233232

234-
SymbExLogger.currentLog().closeScope(sepIdentifier)
233+
symbExLog.closeScope(sepIdentifier)
235234
None
236235
}
237236

@@ -252,21 +251,21 @@ trait DefaultDeciderProvider extends VerifierComponent { this: Verifier =>
252251
// previously (it did not cause a verification failure) and ignore the
253252
// current one, because it cannot cause a verification error.
254253
if (success)
255-
SymbExLogger.currentLog().discardSMTQuery()
254+
symbExLog.discardSMTQuery()
256255
else
257-
SymbExLogger.currentLog().setSMTQuery(t)
256+
symbExLog.setSMTQuery(t)
258257

259258
Q(success)
260259
}
261260

262261
private def deciderAssert(t: Term, timeout: Option[Int]) = {
263262
val assertRecord = new DeciderAssertRecord(t, timeout)
264-
val sepIdentifier = SymbExLogger.currentLog().openScope(assertRecord)
263+
val sepIdentifier = symbExLog.openScope(assertRecord)
265264

266265
val asserted = isKnownToBeTrue(t)
267266
val result = asserted || proverAssert(t, timeout)
268267

269-
SymbExLogger.currentLog().closeScope(sepIdentifier)
268+
symbExLog.closeScope(sepIdentifier)
270269
result
271270
}
272271

@@ -280,17 +279,15 @@ trait DefaultDeciderProvider extends VerifierComponent { this: Verifier =>
280279

281280
private def proverAssert(t: Term, timeout: Option[Int]) = {
282281
val assertRecord = new ProverAssertRecord(t, timeout)
283-
val sepIdentifier = SymbExLogger.currentLog().openScope(assertRecord)
282+
val sepIdentifier = symbExLog.openScope(assertRecord)
284283

285284
val result = prover.assert(t, timeout)
286285

287-
if (SymbExLogger.enabled) {
288-
val statistics = prover.statistics()
289-
val deltaStatistics = SymbExLogger.getDeltaSmtStatistics(statistics)
290-
assertRecord.statistics = Some(statistics ++ deltaStatistics)
286+
symbExLog.whenEnabled {
287+
assertRecord.statistics = Some(symbExLog.deltaStatistics(prover.statistics()))
291288
}
292289

293-
SymbExLogger.currentLog().closeScope(sepIdentifier)
290+
symbExLog.closeScope(sepIdentifier)
294291

295292
result
296293
}

src/main/scala/decider/ProverStdIO.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,13 @@ abstract class ProverStdIO(uniqueId: String,
297297
setTimeout(timeout)
298298

299299
val guard = fresh("grd", Nil, sorts.Bool)
300+
val guardApp = App(guard, Nil)
300301

301-
writeLine(s"(assert (=> $guard (not $goal)))")
302+
writeLine(s"(assert (=> $guardApp (not $goal)))")
302303
readSuccess()
303304

304305
val startTime = System.currentTimeMillis()
305-
writeLine(s"(check-sat $guard)")
306+
writeLine(s"(check-sat $guardApp)")
306307
val result = readUnsat()
307308
val endTime = System.currentTimeMillis()
308309

0 commit comments

Comments
 (0)