Skip to content

Commit

Permalink
Fix assuming perm bounds in predicates, support flag to get old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoeilers committed Oct 15, 2024
1 parent c999815 commit 6048e9e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/scala/viper/carbon/CarbonVerifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ case class CarbonVerifier(override val reporter: Reporter,
}
else false

def respectFunctionPrecPermAmounts: Boolean = if (config != null) config.respectFunctionPrecPermAmounts.toOption match {
case Some(b) => b
case None => false
}
else false

override def usePolyMapsInEncoding =
if (config != null) {
config.desugarPolymorphicMaps.toOption match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ with DefinednessComponent with ExhaleComponent with InhaleComponent {
env = Environment(verifier, f)
ErrorMemberMapping.currentMember = f

val oldPermOnlyState = permModule.setCheckReadPermissionOnlyState(true)
val oldPermOnlyState = permModule.setCheckReadPermissionOnlyState(!verifier.respectFunctionPrecPermAmounts)
val res = MaybeCommentedDecl(s"Translation of function ${f.name}",
MaybeCommentedDecl("Uninterpreted function definitions", functionDefinitions(f), size = 1) ++
(if (f.isAbstract) Nil else
Expand Down Expand Up @@ -668,7 +668,7 @@ with DefinednessComponent with ExhaleComponent with InhaleComponent {

val args = p.formalArgs map translateLocalVarDecl
val init : Stmt = MaybeCommentBlock("Initializing the state",
stateModule.initBoogieState ++ assumeAllFunctionDefinitions ++ (p.formalArgs map (a => allAssumptionsAboutValue(a.typ,mainModule.translateLocalVarDecl(a),true)))
stateModule.initBoogieState ++ assumeAllFunctionDefinitions ++ permModule.assumePermUpperBounds ++ (p.formalArgs map (a => allAssumptionsAboutValue(a.typ,mainModule.translateLocalVarDecl(a),true)))
)

val predicateBody = p.body.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ class QuantifiedPermModule(val verifier: Verifier)
Trigger(Seq(staticGoodState)),
staticGoodState ==> staticGoodMask)) ++ {
val perm = currentPermission(obj.l, field.l)
val shouldAssumePermUpperBound = if (verifier.respectFunctionPrecPermAmounts) TrueLit() else assumePermUpperBound
Axiom(Forall(staticStateContributions(true, true) ++ obj ++ field,
Trigger(Seq(staticGoodMask, perm)),
// permissions are non-negative
((staticGoodMask && assumePermUpperBound) ==> ( perm >= noPerm &&
((staticGoodMask && shouldAssumePermUpperBound) ==> ( perm >= noPerm &&
// permissions for fields which aren't predicates are smaller than 1
// permissions for fields which aren't predicates or wands are smaller than 1
((staticGoodMask && heapModule.isPredicateField(field.l).not && heapModule.isWandField(field.l).not) ==> perm <= fullPerm )))
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/viper/carbon/verifier/Verifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ trait Verifier {

def usePolyMapsInEncoding: Boolean

def respectFunctionPrecPermAmounts: Boolean

}

0 comments on commit 6048e9e

Please sign in to comment.