Skip to content

Commit 8896f3d

Browse files
authored
Merge pull request #8324 from tautschnig/bugfixes/mathematical-types
Fix support for mathematical types
2 parents 5f4c82d + 3e649e6 commit 8896f3d

File tree

25 files changed

+513
-116
lines changed

25 files changed

+513
-116
lines changed

regression/cbmc/rational1/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int main()
2+
{
3+
__CPROVER_rational x;
4+
__CPROVER_rational y;
5+
x = 6 / 10;
6+
y = 3 / 5;
7+
8+
__CPROVER_assert(y + 1 != x, "should pass");
9+
__CPROVER_assert(y != x, "should fail");
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE smt-backend broken-cprover-smt-backend no-new-smt
2+
main.c
3+
--trace --smt2
4+
^\[main.assertion.2\] line 9 should fail: FAILURE$
5+
^\s*x=3/5
6+
^\s*y=3/5
7+
^\*\* 1 of 2 failed
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--show-goto-functions
4+
^[[:space:]]*ASSIGN main::1::x := 3/5
5+
^[[:space:]]*ASSIGN main::1::y := 3/5
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
int main()
2+
{
3+
__CPROVER_real a, b;
4+
a = 0;
5+
b = a;
6+
b++;
7+
b *= 100;
8+
__CPROVER_assert(0, "");
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE smt-backend broken-cprover-smt-backend no-new-smt
2+
main.c
3+
--trace --smt2
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^ b=100
7+
--
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--show-goto-functions
4+
^[[:space:]]*ASSIGN main::1::b := main::1::b \* cast\(100, ℝ\)$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^[[:space:]]*ASSIGN main::1::b := main::1::b \* 100$
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int main()
2+
{
3+
__CPROVER_real a;
4+
__CPROVER_real a2 = a * a;
5+
__CPROVER_assert(a2 != 2, "");
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE smt-backend broken-cprover-smt-backend no-new-smt
2+
main.c
3+
--trace --smt2
4+
^ a=x ∈ ℝ\.\(x\^2 \+ -2 = 0\)
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
8+
--

regression/validate-trace-xml-schema/check.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
['enum_is_in_range', 'enum_test3-simplified.desc'],
3030
['enum_is_in_range', 'format.desc'],
3131
['r_w_ok9', 'simplify.desc'],
32+
['rational1', 'typecheck.desc'],
3233
['reachability-slice-interproc2', 'test.desc'],
34+
['real-assignments1', 'typecheck.desc'],
3335
['saturating_arithmetric', 'output-goto.desc'],
3436
# this one wants show-properties instead producing a trace
3537
['show_properties1', 'test.desc'],
@@ -80,7 +82,9 @@
8082
['integer-assignments1', 'test.desc'],
8183
# this test is expected to abort, thus producing invalid XML
8284
['String_Abstraction17', 'test.desc'],
83-
['Quantifiers1', 'quantifier-with-side-effect.desc']
85+
['Quantifiers1', 'quantifier-with-side-effect.desc'],
86+
# this test produces unicode output that cannot be decoded as ASCII
87+
['real-irrational1', 'test.desc']
8488
]))
8589

8690
# TODO maybe consider looking them up on PATH, but direct paths are

src/ansi-c/ansi_c_internal_additions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ void ansi_c_internal_additions(std::string &code, bool support_float16_type)
144144
" " CPROVER_PREFIX "ssize_t;\n"
145145
"const unsigned " CPROVER_PREFIX "constant_infinity_uint;\n"
146146
"typedef void " CPROVER_PREFIX "integer;\n"
147+
"typedef void " CPROVER_PREFIX "natural;\n"
147148
"typedef void " CPROVER_PREFIX "rational;\n"
149+
"typedef void " CPROVER_PREFIX "real;\n"
148150
"extern unsigned char " CPROVER_PREFIX "memory["
149151
CPROVER_PREFIX "constant_infinity_uint];\n"
150152

0 commit comments

Comments
 (0)