Skip to content

Quantifier test: The second assertion does not hold [blocks: #2574, #3725, #3924] #3724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion regression/cbmc/Quantifiers-assertion/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ int main()
c[1][0]=1;
c[1][1]=2;

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assert(__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "Exists-Exists: successful");

__CPROVER_assert(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotExists-NotExists: successful");
// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assert(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotExists-NotExists: failed");

__CPROVER_assert(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotExists-Exists: failed");

Expand All @@ -18,6 +21,7 @@ int main()
__CPROVER_assert(!__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotForall-Forall: successful");

__CPROVER_assert(!__CPROVER_forall { int i; (i>=0 && i<2) ==> (!__CPROVER_forall{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotForall-NotForall: successful");
// clang-format on

return 0;
}
8 changes: 5 additions & 3 deletions regression/cbmc/Quantifiers-assertion/test.desc
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
CORE
KNOWNBUG
main.c

^\*\* Results:$
^\[main.assertion.1\] .* Exists-Exists: successful: SUCCESS$
^\[main.assertion.2\] .* NotExists-NotExists: successful: SUCCESS$
^\[main.assertion.2\] .* NotExists-NotExists: failed: FAILURE$
^\[main.assertion.3\] .* NotExists-Exists: failed: FAILURE$
^\[main.assertion.4\] .* NotExists-Forall: failed: FAILURE$
^\[main.assertion.5\] .* NotForall-Forall: successful: SUCCESS$
^\[main.assertion.6\] .* NotForall-NotForall: successful: SUCCESS$
^\*\* 2 of 6 failed
^\*\* 3 of 6 failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-assignment/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ int main()
a[0]=1;
a[1]=2;

// clang-format off
// clang-format would rewrite the "==>" as "== >"
int x=__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 };
int y=__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<2 };
int z1=__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<1.5 };
int z2=__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<2*10 };
// clang-format on

assert(x);
assert(y);
Expand Down
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-assignment/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ main.c
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-copy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ int main()
a[3]=3;
a[4]=4;

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> b[i]==a[i]});
// clang-format on

assert(b[0]==0);
assert(b[1]==1);
Expand Down
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-copy/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ main.c
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-if/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ int main()
a[0]=1;
a[1]=2;

// clang-format off
// clang-format would rewrite the "==>" as "== >"
if(__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 })
__CPROVER_assert(0, "failure 1");

Expand All @@ -18,6 +20,7 @@ int main()

if(__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 })
__CPROVER_assert(0, "success 2");
// clang-format on

return 0;
}
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-if/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ main.c
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-initialisation/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ int main()
{
int a[5];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> a[i]==i+1});
// clang-format on

assert(a[0]==1);
assert(a[1]==2);
Expand Down
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-initialisation/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ main.c
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-initialisation2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ int main()
int a[10];
int c[10];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
// C# style
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<9+1) ==> a[i]>=1 && a[i]<=10 });
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<10) ==> __CPROVER_forall{int j; (j>i && j<10) ==> a[j]>a[i]} });
Expand All @@ -14,5 +16,6 @@ int main()
assert(a[2]>a[3]);
__CPROVER_assert(__CPROVER_forall {unsigned i; (i>=1 && i<10) ==> c[i-1]<=c[i]}, "forall c[]");
assert(c[3]>=c[1]);
// clang-format on
return 0;
}
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-initialisation2/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ main.c
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-invalid-var-range/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ int main()
{

int a[3][3];
// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> __CPROVER_exists{int j; (j>=i && j<3) ==> a[i][j]==10} });
// clang-format on

assert(a[0][0]==10||a[0][1]==10||a[0][2]==10);

Expand Down
7 changes: 6 additions & 1 deletion regression/cbmc/Quantifiers-invalid-var-range/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
CORE
KNOWNBUG
main.c

^\*\* Results:$
^\*\* 0 of 1 failed
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
--
This produces the expected verification result, but actually ignores some
quantifiers.
42 changes: 42 additions & 0 deletions regression/cbmc/Quantifiers-not-exists/fixed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
int main()
{
int a[2][2];
int b[2][2];
int c[2][2];
int d[2][2];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) && (__CPROVER_exists{int j; (j>=0 && j<2) && a[i][j]<=10}) });

assert(0);

// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) && b[i][j]>=1 && b[i][j]<=10}) });

assert(0);

// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) && (!__CPROVER_exists{int j; (j>=0 && j<2) && (c[i][j]==0 || c[i][j]<=10)}) });

assert(0);

// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) && (__CPROVER_forall{int j; (j>=0 && j<2) ==> d[i][j]>=1 && d[i][j]<=10}) });
// clang-format on

assert(0);

assert(a[0][0] > 10);

assert((b[0][0] < 1 || b[0][0] > 10) && (b[0][1] < 1 || b[0][1] > 10));
assert((b[1][0] < 1 || b[1][0] > 10) && (b[1][1] < 1 || b[1][1] > 10));

assert(c[0][0] == 0 || c[0][1] == 0 || c[1][0] <= 10 || c[1][1] <= 10);

assert(((d[0][0] < 1 || d[0][0] > 10) || (d[0][1] < 1 || d[0][1] > 10)));
assert(((d[1][0] < 1 || d[1][0] > 10) || (d[1][1] < 1 || d[1][1] > 10)));

return 0;
}
16 changes: 16 additions & 0 deletions regression/cbmc/Quantifiers-not-exists/fixed.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CORE
fixed.c

^\*\* Results:$
^\[main.assertion.5\] line 31 assertion a\[.*\]\[.*\] > 10: SUCCESS$
^\[main.assertion.6\] line 33 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.7\] line 34 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.8\] line 36 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.9\] line 38 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.10\] line 39 assertion tmp_if_expr\$\d+: SUCCESS$
^\*\* 4 of 10 failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
10 changes: 10 additions & 0 deletions regression/cbmc/Quantifiers-not-exists/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ int main()
int c[2][2];
int d[2][2];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> a[i][j]<=10}) });

assert(0);

__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> b[i][j]>=1 && b[i][j]<=10}) });

assert(0);

__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) });

assert(0);

__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> d[i][j]>=1 && d[i][j]<=10}) });
// clang-format on

assert(0);

assert(a[0][0]>10);

Expand Down
22 changes: 14 additions & 8 deletions regression/cbmc/Quantifiers-not-exists/test.desc
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
CORE
KNOWNBUG
main.c

^\*\* Results:$
^\[main.assertion.1\] line 18 assertion a\[.*\]\[.*\] > 10: SUCCESS$
^\[main.assertion.2\] line 20 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.3\] line 21 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.4\] line 23 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.5\] line 25 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.6\] line 26 assertion tmp_if_expr\$\d+: SUCCESS$
^\*\* 0 of 6 failed
^\[main.assertion.5\] line 28 assertion a\[.*\]\[.*\] > 10: SUCCESS$
^\[main.assertion.6\] line 30 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.7\] line 31 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.8\] line 33 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.9\] line 35 assertion tmp_if_expr\$\d+: SUCCESS$
^\[main.assertion.10\] line 36 assertion tmp_if_expr\$\d+: SUCCESS$
^\*\* 0 of 10 failed
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
--
All assertions are unreachable as each of the __CPROVER_assume evaluate to false
(!exists i. i>=0 && i<2 ==> ... is equivalent to forall i. i>=0 && i<2 && ...,
where neither i>=0 nor i<2 is actually true for all values of i).
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-not/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ int main()
a[0]=1;
a[1]=2;

// clang-format off
// clang-format would rewrite the "==>" as "== >"
if(!__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 })
__CPROVER_assert(0, "success 1");

Expand All @@ -18,6 +20,7 @@ int main()

if(!__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 })
__CPROVER_assert(0, "failure 2");
// clang-format on

return 0;
}
2 changes: 2 additions & 0 deletions regression/cbmc/Quantifiers-not/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ main.c
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
20 changes: 20 additions & 0 deletions regression/cbmc/Quantifiers-two-dimension-array/fixed.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
int main()
{
int a[2][2];
int b[2][2];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> a[i][j]==i+j}) });
// NOLINTNEXTLINE(whitespace/line_length)
__CPROVER_assume(__CPROVER_exists { int i; (i>=0 && i<2) && (__CPROVER_exists{int j; (j>=0 && j<2) && b[i][j]==i+j+1}) });
// clang-format on

assert(a[0][0] == 0);
assert(a[0][1] == 1);
assert(a[1][0] == 1);
assert(a[1][1] == 2);
assert(b[0][0] == 1 || b[0][1] == 2 || b[1][0] == 2 || b[1][1] == 3);
return 0;
}
15 changes: 15 additions & 0 deletions regression/cbmc/Quantifiers-two-dimension-array/fixed.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CORE
fixed.c

^\*\* Results:$
^\[main.assertion.1\] line 14 assertion a\[.*\]\[.*\] == 0: SUCCESS$
^\[main.assertion.2\] line 15 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.3\] line 16 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.4\] line 17 assertion a\[.*\]\[.*\] == 2: SUCCESS$
^\[main.assertion.5\] line 18 assertion tmp_if_expr\$\d+: SUCCESS$
^\*\* 0 of 5 failed
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-two-dimension-array/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ int main()
int a[2][2];
int b[2][2];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> a[i][j]==i+j}) });
__CPROVER_assume(__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> b[i][j]==i+j+1}) });
// clang-format on

assert(a[0][0]==0);
assert(a[0][1]==1);
Expand Down
23 changes: 14 additions & 9 deletions regression/cbmc/Quantifiers-two-dimension-array/test.desc
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
CORE
KNOWNBUG
main.c

^\*\* Results:$
^\[main.assertion.1\] line 9 assertion a\[.*\]\[.*\] == 0: SUCCESS$
^\[main.assertion.2\] line 10 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.3\] line 11 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.4\] line 12 assertion a\[.*\]\[.*\] == 2: SUCCESS$
^\[main.assertion.5\] line 13 assertion tmp_if_expr\$\d+: SUCCESS$
^\*\* 0 of 5 failed
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^\[main.assertion.1\] line 12 assertion a\[.*\]\[.*\] == 0: SUCCESS$
^\[main.assertion.2\] line 13 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.3\] line 14 assertion a\[.*\]\[.*\] == 1: SUCCESS$
^\[main.assertion.4\] line 15 assertion a\[.*\]\[.*\] == 2: SUCCESS$
^\[main.assertion.5\] line 16 assertion tmp_if_expr\$\d+: FAILURE$
^\*\* 1 of 5 failed
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
^warning: ignoring
--
The assertion on line 13 need not hold as the assume can be satisfied by picking
a value for i that does not fulfil the left-hand side of the implication.
3 changes: 3 additions & 0 deletions regression/cbmc/Quantifiers-type/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ int main()
int a[2];
int b[2];

// clang-format off
// clang-format would rewrite the "==>" as "== >"
__CPROVER_assume( __CPROVER_forall { float i; (i>=0 && i<2) ==> a[i]>=10 && a[i]<=10 } );
__CPROVER_assume( __CPROVER_forall { char i; (i>=0 && i<2) ==> b[i]>=10 && b[i]<=10 } );
// clang-format on

assert(a[0]==10 && a[1]==10);
assert(b[0]==10 && b[1]==10);
Expand Down
Loading