Skip to content

Commit

Permalink
[Civl] Enhance quantifier elimination (#829)
Browse files Browse the repository at this point in the history
TryElimination looks for a substitution for the lhs of single-static
assignments on a path-by-path basis through an atomic action. If an
assignment is of the form ```x := v``` where both x and v are variables,
it is possible that x is defined but v is not. In such a case, the code
change interprets the assignment as an equality and infers a definition
```v <-- x```.
  • Loading branch information
shazqadeer authored Jan 2, 2024
1 parent 2d83955 commit 9494987
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Concurrency/TransitionRelationComputation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ private void TryElimination(IEnumerable<Variable> extraDefinedVariables)
varToExpr[assignment.Var] = SubstitutionHelper.Apply(varToExpr, assignment.Expr);
changed = true;
}
else if (Defined(assignment.Var) && assignment.Expr is IdentifierExpr ie && !Defined(ie.Decl))
{
varToExpr[ie.Decl] = SubstitutionHelper.Apply(varToExpr, Expr.Ident(assignment.Var));
changed = true;
}
else
{
remainingAssignments.Add(assignment);
Expand Down
14 changes: 14 additions & 0 deletions Test/civl/regression-tests/qelim1.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %parallel-boogie "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

atomic action {:layer 2} AtomicFoo() returns (o: int)
{
var y: int;
o := y;
}
yield procedure {:layer 1} Foo() returns (o: int)
refines AtomicFoo;
{
var x: int;
o := x;
}
2 changes: 2 additions & 0 deletions Test/civl/regression-tests/qelim1.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Boogie program verifier finished with 1 verified, 0 errors

0 comments on commit 9494987

Please sign in to comment.