summaryrefslogtreecommitdiff
path: root/Test/triggers/loop-detection-is-not-too-strict.dfy
diff options
context:
space:
mode:
authorGravatar Clément Pit--Claudel <clement.pitclaudel@live.com>2015-08-19 22:16:02 -0700
committerGravatar Clément Pit--Claudel <clement.pitclaudel@live.com>2015-08-19 22:16:02 -0700
commit19c70cd0d7a65c46bcaafa66b13bde43316bc081 (patch)
treeec00ed370707ec35e818bdaacf45924b4dfaf9c8 /Test/triggers/loop-detection-is-not-too-strict.dfy
parentdd4f127f36ec24fbcedaaae0e61e0894b2bf5e83 (diff)
Add tests for quantifier splitting and trigger generation
Diffstat (limited to 'Test/triggers/loop-detection-is-not-too-strict.dfy')
-rw-r--r--Test/triggers/loop-detection-is-not-too-strict.dfy21
1 files changed, 21 insertions, 0 deletions
diff --git a/Test/triggers/loop-detection-is-not-too-strict.dfy b/Test/triggers/loop-detection-is-not-too-strict.dfy
new file mode 100644
index 00000000..c6722399
--- /dev/null
+++ b/Test/triggers/loop-detection-is-not-too-strict.dfy
@@ -0,0 +1,21 @@
+// RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" /autoTriggers:1 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+// This test shows that the loop detection engine makes compromises when looking
+// for subexpressions matching a trigger; in particular, it allows a
+// subexpression to match a trigger without reporting a loop and without being
+// equal to that trigger, as long as the only differences are variable
+
+predicate P(x: int, y: int)
+
+method Test() {
+ // P(x, y) and P(y, x) might look like they would cause a loop. Since they
+ // only differ by their variables, though, they won't raise flags.
+ assume forall x: int, y: int :: P(x, y) == P(y, x);
+
+ // This works independent of extra parentheses:
+ assume forall x: int, y: int :: P(x, y) == (P(y, x));
+
+ // Contrast with the following:
+ assume forall x: int, y: int :: P(x, y) == P(x, y+1);
+}