Skip to content

Basic CHC Encoding #6807

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 3 commits into from
Apr 25, 2022
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
1 change: 1 addition & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ add_subdirectory(cbmc-incr-smt2)
add_subdirectory(cbmc-incr)
add_subdirectory(cbmc-with-incr)
add_subdirectory(array-refinement-with-incr)
add_subdirectory(goto-instrument-chc)
add_subdirectory(goto-instrument-json)
add_subdirectory(goto-instrument-wmm-core)
add_subdirectory(goto-instrument-typedef)
Expand Down
1 change: 1 addition & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ DIRS = cbmc \
cbmc-incr \
cbmc-with-incr \
array-refinement-with-incr \
goto-instrument-chc \
goto-instrument-json \
goto-instrument-wmm-core \
goto-instrument-typedef \
Expand Down
3 changes: 3 additions & 0 deletions regression/goto-instrument-chc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_test_pl_tests(
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-instrument>"
)
28 changes: 28 additions & 0 deletions regression/goto-instrument-chc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
default: tests.log

include ../../src/config.inc
include ../../src/common

ifeq ($(BUILD_ENV_),MSVC)
exe=../../../src/goto-cc/goto-cl
is_windows=true
else
exe=../../../src/goto-cc/goto-cc
is_windows=false
endif

test:
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument'

tests.log:
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-instrument/goto-instrument'

clean:
@for dir in *; do \
$(RM) tests.log; \
if [ -d "$$dir" ]; then \
cd "$$dir"; \
$(RM) *.out *.gb; \
cd ..; \
fi \
done
10 changes: 10 additions & 0 deletions regression/goto-instrument-chc/basic/basic5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
int main()
{
int x;
__CPROVER_bool c1 = (x >= 10);
__CPROVER_bool c2 = (x >= 5);
// clang-format off
__CPROVER_assert(c1 ==> c2, "property 1"); // passes
__CPROVER_assert(c2 ==> c1, "property 2"); // fails
return 0;
}
9 changes: 9 additions & 0 deletions regression/goto-instrument-chc/basic/basic5.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
basic5.c
--horn
^EXIT=0$
^SIGNAL=0$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|main::1::c1| Bool\) \(|main::1::c2| Bool\) \(|main::1::x| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \) \(=> \(|S31.24| |__CPROVER_rounding_mode| |main::1::c1| |main::1::c2| |main::1::x| |return_value|\) \(|S32Entry| |__CPROVER_rounding_mode| |main::1::c1| |main::1::c2| |main::1::x| |return_value|\)\)\)\)$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|main::1::c1| Bool\) \(|main::1::c2| Bool\) \(|main::1::x| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \) \(=> \(|S32Entry| |__CPROVER_rounding_mode| |main::1::c1| |main::1::c2| |main::1::x| |return_value|\) \(|S32.2| |__CPROVER_rounding_mode| \(bvsge |main::1::x| \(_ bv10 32\)\) |main::1::c2| |main::1::x| |return_value|\)\)\)\)$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|main::1::c1| Bool\) \(|main::1::c2| Bool\) \(|main::1::x| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \) \(=> \(|S32.2| |__CPROVER_rounding_mode| |main::1::c1| |main::1::c2| |main::1::x| |return_value|\) \(|S32.4| |__CPROVER_rounding_mode| |main::1::c1| \(bvsge |main::1::x| \(_ bv5 32\)\) |main::1::x| |return_value|\)\)\)\)$
--
12 changes: 12 additions & 0 deletions regression/goto-instrument-chc/basic/basic6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
int x;

int main()
{
x = 1;
x++;
x++;
x++;
x++;
__CPROVER_assert(x == 5, "property 1");
return 0;
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-chc/basic/basic6.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
basic6.c
--horn
^EXIT=0$
^SIGNAL=0$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \(|x| \(_ BitVec 32\)\) \) \(=> \(|S11Entry| |__CPROVER_rounding_mode| |return_value| |x|\) \(|S11\.0| |__CPROVER_rounding_mode| |return_value| \(_ bv1 32\)\)\)\)\)$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \(|x| \(_ BitVec 32\)\) \) \(=> \(|S11\.0| |__CPROVER_rounding_mode| |return_value| |x|\) \(|S11\.1| |__CPROVER_rounding_mode| |return_value| \(bvadd |x| \(_ bv1 32\)\)\)\)\)\)$
--
14 changes: 14 additions & 0 deletions regression/goto-instrument-chc/basic/nondet1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
int nondet_int();

int main()
{
int x, y;

x = nondet_int();
__CPROVER_assert(x == 20, "property 1"); // fails

y = nondet_int();
__CPROVER_assert(x == y, "property 2"); // fails

return 0;
}
8 changes: 8 additions & 0 deletions regression/goto-instrument-chc/basic/nondet1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
nondet1.c
--horn
^EXIT=0$
^SIGNAL=0$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|main::1::x| \(_ BitVec 32\)\) \(|main::1::y| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \) \(=> \(|S30Entry| |__CPROVER_rounding_mode| |main::1::x| |main::1::y| |return_value|\) \(|S30\.2| |__CPROVER_rounding_mode| |nondet::S30\.2| |main::1::y| |return_value|\)\)\)\)$
^\(assert \(forall \( \(|__CPROVER_rounding_mode| \(_ BitVec 32\)\) \(|main::1::x| \(_ BitVec 32\)\) \(|main::1::y| \(_ BitVec 32\)\) \(|return_value| \(_ BitVec 32\)\) \) \(=> \(|S30\.2| |__CPROVER_rounding_mode| |main::1::x| |main::1::y| |return_value|\) \(= |main::1::x| \(_ bv20 32\)\)\)\)\)$
--
23 changes: 23 additions & 0 deletions regression/goto-instrument-chc/chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

goto_cc=$1
goto_instrument=$2

sources=${*:$#}
args=${*:3:$#-3}

set -- $sources
target=${*:$#}
target=${target%.c}

if [[ `basename "${goto_cc}"` == "goto-cl" || `basename "${goto_cc}"` == "goto-cl.exe" ]]; then
$goto_cc ${sources} "/Fe${target}.gb"
else
$goto_cc -o ${target}.gb ${sources}
fi

echo DOING: $goto_instrument ${args} "${target}.gb"

$goto_instrument ${args} "${target}.gb"
2 changes: 1 addition & 1 deletion src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ int goto_instrument_parse_optionst::doit()
remove_skip(goto_model);
}

if(cmdline.isset("horn-encoding"))
if(cmdline.isset("horn"))
{
log.status() << "Horn-clause encoding" << messaget::eom;
namespacet ns(goto_model.symbol_table);
Expand Down
Loading