Skip to content

Commit

Permalink
Improve precision of abstract interpreter for modulo operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
wuestholz committed Dec 29, 2015
1 parent 1c16dc8 commit dd8e69b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Source/AbsInt/IntervalDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,10 @@ public override Expr VisitNAryExpr(NAryExpr node) {
if (lo0 != null && lo1 != null && 0 <= (BigInteger)lo0 && 0 <= (BigInteger)lo1) {
Lo = BigInteger.Zero;
Hi = hi1;
if (lo0 < lo1 && hi0 != null && hi0 < lo1) {
Lo = lo0;
Hi = hi0;
}
}
break;
case BinaryOperator.Opcode.RealDiv:
Expand Down
15 changes: 15 additions & 0 deletions Test/aitest0/Intervals.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,18 @@ procedure W0(N: real)
assert N - i <= bf0 - 1.0;
}
}

// mod

procedure Mod0(n: int)
requires 10 < n;
{
var i: int;

i := 0;
while (i < 10)
{
i := (i mod n) + 1;
}
assert i == 10;
}
2 changes: 1 addition & 1 deletion Test/aitest0/Intervals.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ Execution trace:
Intervals.bpl(303,3): anon3_LoopHead
Intervals.bpl(303,3): anon3_LoopDone

Boogie program verifier finished with 16 verified, 11 errors
Boogie program verifier finished with 17 verified, 11 errors

0 comments on commit dd8e69b

Please sign in to comment.