Skip to content

Commit 2019acb

Browse files
committed
uninterpreted functions with Boolean codomain
This adds support for uninterpreted functions that have a Boolean codomain.
1 parent 0a5d531 commit 2019acb

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

regression/cbmc/uninterpreted_function/uf2.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
int __CPROVER_uninterpreted_f(int, int);
2+
__CPROVER_bool __CPROVER_uninterpreted_g(int, int);
23

34
main()
45
{
@@ -8,5 +9,11 @@ main()
89
int inst2 = __CPROVER_uninterpreted_f(1, b);
910

1011
if(a == b)
11-
__CPROVER_assert(inst1 == inst2, "functional consistency");
12+
__CPROVER_assert(inst1 == inst2, "functional consistency for f");
13+
14+
int inst3 = __CPROVER_uninterpreted_g(1, a);
15+
int inst4 = __CPROVER_uninterpreted_g(1, b);
16+
17+
if(a == b)
18+
__CPROVER_assert(inst3 == inst4, "functional consistency for g");
1219
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
boolean_uf1.smt2
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^unsat$
7+
--
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(set-logic QF_UFBV)
2+
3+
(declare-fun myfun ((_ BitVec 32)) Bool)
4+
5+
(assert (myfun (_ bv10 32)))
6+
7+
(declare-const x (_ BitVec 32))
8+
(assert (= x (_ bv10 32)))
9+
(assert (not (myfun x)))
10+
11+
(check-sat)

src/solvers/flattening/boolbv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ literalt boolbvt::convert_rest(const exprt &expr)
565565
else if(op.type().id() == ID_fixedbv)
566566
return const_literal(true);
567567
}
568+
else if(expr.id() == ID_function_application)
569+
{
570+
functions.record(to_function_application_expr(expr));
571+
return prop.new_variable();
572+
}
568573

569574
return SUB::convert_rest(expr);
570575
}

0 commit comments

Comments
 (0)