Skip to content

Commit 0e4bf05

Browse files
authored
Merge pull request #6517 from tautschnig/quantifiers-unsigned
Flattening: support quantifiers over unsigned variables
2 parents 6aeac5e + 3d6021f commit 0e4bf05

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
int main()
22
{
33
int a[2];
4-
int b[2];
54

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

1210
assert(a[0]==10 && a[1]==10);
13-
assert(b[0]==10 && b[1]==10);
1411

1512
return 0;
1613
}

regression/cbmc/Quantifiers-type/test.desc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ main.c
33

44
^\*\* Results:$
55
^\[main.assertion.1\] line 12 assertion tmp_if_expr(\$\d+)?: FAILURE$
6-
^\[main.assertion.2\] line 13 assertion tmp_if_expr\$\d+: SUCCESS$
7-
^\*\* 1 of 2 failed
6+
^\*\* 1 of 1 failed
87
^VERIFICATION FAILED$
98
^EXIT=10$
109
^SIGNAL=0$
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
int main()
2+
{
3+
int b[2];
4+
int c[2];
5+
6+
// clang-format off
7+
// clang-format would rewrite the "==>" as "== >"
8+
__CPROVER_assume( __CPROVER_forall { char i; (i>=0 && i<2) ==> b[i]>=10 && b[i]<=10 } );
9+
__CPROVER_assume( __CPROVER_forall { unsigned i; (i>=0 && i<2) ==> c[i]>=10 && c[i]<=10 } );
10+
// clang-format on
11+
12+
assert(b[0] == 10 && b[1] == 10);
13+
assert(c[0] == 10 && c[1] == 10);
14+
15+
return 0;
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^\*\* Results:$
5+
^\[main.assertion.1\] line 12 assertion tmp_if_expr(\$\d+)?: SUCCESS$
6+
^\[main.assertion.2\] line 13 assertion tmp_if_expr\$\d+: SUCCESS$
7+
^VERIFICATION SUCCESSFUL$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
11+
^warning: ignoring

src/solvers/flattening/boolbv_quantifier.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ get_quantifier_var_min(const exprt &var_expr, const exprt &quantifier_expr)
4848
return to_constant_expr(y_binary.rhs());
4949
}
5050
}
51+
52+
if(var_expr.type().id() == ID_unsignedbv)
53+
return from_integer(0, var_expr.type());
5154
}
5255
else if(quantifier_expr.id() == ID_and)
5356
{
@@ -66,6 +69,9 @@ get_quantifier_var_min(const exprt &var_expr, const exprt &quantifier_expr)
6669
return to_constant_expr(x_binary.rhs());
6770
}
6871
}
72+
73+
if(var_expr.type().id() == ID_unsignedbv)
74+
return from_integer(0, var_expr.type());
6975
}
7076

7177
return {};

0 commit comments

Comments
 (0)