Skip to content

Commit bf6245d

Browse files
authored
Merge pull request #479 from smackers/cvc4_support
CVC4 support
2 parents 18f70e8 + 6b4a23d commit bf6245d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

bin/build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# Set these flags to control various installation options
2424
INSTALL_DEPENDENCIES=1
2525
INSTALL_Z3=1
26+
INSTALL_CVC4=1
2627
BUILD_BOOGIE=1
2728
BUILD_CORRAL=1
2829
BUILD_SYMBOOGLIX=1
@@ -40,6 +41,7 @@ INSTALL_RUST=0
4041
SMACK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
4142
ROOT="$( cd "${SMACK_DIR}" && cd .. && pwd )"
4243
Z3_DIR="${ROOT}/z3"
44+
CVC4_DIR="${ROOT}/cvc4"
4345
BOOGIE_DIR="${ROOT}/boogie"
4446
CORRAL_DIR="${ROOT}/corral"
4547
SYMBOOGLIX_DIR="${ROOT}/symbooglix"
@@ -405,6 +407,18 @@ if [ ${INSTALL_Z3} -eq 1 ] ; then
405407
fi
406408
fi
407409

410+
if [ ${INSTALL_CVC4} -eq 1 ] ; then
411+
if [ ! -d "$CVC4_DIR" ] ; then
412+
puts "Installing CVC4"
413+
mkdir -p ${CVC4_DIR}
414+
${WGET} https://github.com/CVC4/CVC4/releases/download/1.7/cvc4-1.7-x86_64-linux-opt -O cvc4
415+
chmod +x cvc4
416+
mv cvc4 ${CVC4_DIR}
417+
puts "Installed CVC4"
418+
else
419+
puts "CVC4 already installed"
420+
fi
421+
fi
408422

409423
if [ ${BUILD_BOOGIE} -eq 1 ] ; then
410424
if ! upToDate $BOOGIE_DIR $BOOGIE_COMMIT ; then
@@ -420,6 +434,7 @@ if [ ${BUILD_BOOGIE} -eq 1 ] ; then
420434
rm -rf /tmp/nuget/
421435
msbuild Boogie.sln /p:Configuration=Release
422436
ln -sf ${Z3_DIR}/bin/z3 ${BOOGIE_DIR}/Binaries/z3.exe
437+
ln -sf ${CVC4_DIR}/cvc4 ${BOOGIE_DIR}/Binaries/cvc4.exe
423438
puts "Built Boogie"
424439
else
425440
puts "Boogie already built"
@@ -439,6 +454,7 @@ if [ ${BUILD_CORRAL} -eq 1 ] ; then
439454
git submodule update
440455
msbuild cba.sln /p:Configuration=Release
441456
ln -sf ${Z3_DIR}/bin/z3 ${CORRAL_DIR}/bin/Release/z3.exe
457+
ln -sf ${CVC4_DIR}/cvc4 ${CORRAL_DIR}/bin/Release/cvc4.exe
442458
puts "Built Corral"
443459
else
444460
puts "Corral already built"

lib/smack/Prelude.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ void IntOpGen::generateArithOps(std::stringstream &s) const {
381381
bvBuiltinOp, true},
382382
{"sdiv", 2, intBuiltinOp, bvBuiltinOp, false},
383383
{"smod", 2, intBuiltinOp, bvBuiltinOp, false},
384-
{"srem", 2, intBuiltinOp, bvBuiltinOp, false},
385384
{"udiv", 2, intBuiltinOp, bvBuiltinOp, false},
386-
{"urem", 2, intBuiltinOp, bvBuiltinOp, false},
385+
{"srem", 2, uninterpretedOp, bvBuiltinOp, false},
386+
{"urem", 2, uninterpretedOp, bvBuiltinOp, false},
387387
{"shl", 2, uninterpretedOp, bvBuiltinOp, false},
388388
{"lshr", 2, uninterpretedOp, bvBuiltinOp, false},
389389
{"ashr", 2, uninterpretedOp, bvBuiltinOp, false},
@@ -731,7 +731,7 @@ void IntOpGen::generateBvIntConvs(std::stringstream &s) const {
731731
<< "\n";
732732
if (SmackOptions::BitPrecise && !SmackOptions::BitPrecisePointers) {
733733
s << Decl::function(indexedName("$bv2uint", {ptrSize}), {{"i", bt}}, it,
734-
nullptr, {makeBuiltinAttr("bv2int")})
734+
nullptr, {makeBuiltinAttr("bv2nat")})
735735
<< "\n";
736736
const Expr *arg = Expr::id("i");
737737
const Expr *uint = Expr::fn(indexedName("$bv2uint", {ptrSize}), arg);
@@ -753,7 +753,7 @@ void IntOpGen::generateBvIntConvs(std::stringstream &s) const {
753753
<< "\n";
754754
} else
755755
s << Decl::function(indexedName("$bv2int", {ptrSize}), {{"i", bt}}, it,
756-
nullptr, {makeBuiltinAttr("bv2int")})
756+
nullptr, {makeBuiltinAttr("bv2nat")})
757757
<< "\n";
758758
s << "\n";
759759
}

share/smack/top.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def arguments():
208208
choices=['boogie', 'corral', 'symbooglix', 'svcomp'], default='corral',
209209
help='back-end verification engine')
210210

211+
verifier_group.add_argument('--solver',
212+
choices=['z3', 'cvc4'], default='z3',
213+
help='back-end SMT solver')
214+
211215
verifier_group.add_argument('--unroll', metavar='N', default='1',
212216
type = lambda x: int(x) if int(x) > 0 else parser.error('Unroll bound has to be positive.'),
213217
help='loop/recursion unroll bound [default: %(default)s]')
@@ -460,6 +464,8 @@ def verify_bpl(args):
460464
command += ["/errorLimit:%s" % args.max_violations]
461465
if not args.modular:
462466
command += ["/loopUnroll:%d" % args.unroll]
467+
if args.solver == 'cvc4':
468+
command += ["/proverOpt:SOLVER=cvc4"]
463469

464470
elif args.verifier == 'corral':
465471
command = ["corral"]
@@ -471,7 +477,9 @@ def verify_bpl(args):
471477
command += ["/cex:%s" % args.max_violations]
472478
command += ["/maxStaticLoopBound:%d" % args.loop_limit]
473479
command += ["/recursionBound:%d" % args.unroll]
474-
480+
if args.solver == 'cvc4':
481+
command += ["/bopt:proverOpt:SOLVER=cvc4"]
482+
475483
elif args.verifier == 'symbooglix':
476484
command = ['symbooglix']
477485
command += [args.bpl_file]

0 commit comments

Comments
 (0)