From e25dac8edab3e3f23db7c83b393ed388840d239f Mon Sep 17 00:00:00 2001 From: Valentin Wüstholz Date: Tue, 17 Nov 2015 14:03:06 -0600 Subject: Fix issue #25. --- Source/AbsInt/IntervalDomain.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Source/AbsInt/IntervalDomain.cs') diff --git a/Source/AbsInt/IntervalDomain.cs b/Source/AbsInt/IntervalDomain.cs index 0d2676f2..ee9d632b 100644 --- a/Source/AbsInt/IntervalDomain.cs +++ b/Source/AbsInt/IntervalDomain.cs @@ -698,9 +698,13 @@ namespace Microsoft.Boogie.AbstractInterpretation lo = Lo; hi = Hi; if (hi != null) { Lo = node.Type.IsReal ? -hi : 1 - hi; + } else { + Lo = null; } if (lo != null) { Hi = node.Type.IsReal ? -lo : 1 - lo; + } else { + Hi = null; } } else if (op.Op == UnaryOperator.Opcode.Not) { -- cgit v1.2.3 From dd8e69b7b71a9375b7206a70633deae234175ef8 Mon Sep 17 00:00:00 2001 From: Valentin Wüstholz Date: Mon, 28 Dec 2015 20:22:03 -0600 Subject: Improve precision of abstract interpreter for modulo operations. --- Source/AbsInt/IntervalDomain.cs | 4 ++++ Test/aitest0/Intervals.bpl | 15 +++++++++++++++ Test/aitest0/Intervals.bpl.expect | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'Source/AbsInt/IntervalDomain.cs') diff --git a/Source/AbsInt/IntervalDomain.cs b/Source/AbsInt/IntervalDomain.cs index ee9d632b..2fd37463 100644 --- a/Source/AbsInt/IntervalDomain.cs +++ b/Source/AbsInt/IntervalDomain.cs @@ -884,6 +884,10 @@ namespace Microsoft.Boogie.AbstractInterpretation 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: diff --git a/Test/aitest0/Intervals.bpl b/Test/aitest0/Intervals.bpl index fddce05a..8d40b81d 100644 --- a/Test/aitest0/Intervals.bpl +++ b/Test/aitest0/Intervals.bpl @@ -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; +} diff --git a/Test/aitest0/Intervals.bpl.expect b/Test/aitest0/Intervals.bpl.expect index a0769ec5..980593a9 100644 --- a/Test/aitest0/Intervals.bpl.expect +++ b/Test/aitest0/Intervals.bpl.expect @@ -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 -- cgit v1.2.3