Skip to content

Commit

Permalink
Add arry-uf options into goto-synthesizer
Browse files Browse the repository at this point in the history
  • Loading branch information
qinheping committed Jul 29, 2023
1 parent 50dd2a2 commit 1bf2c96
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/man/goto-synthesizer.1
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ output smt incremental formula to the given file
.TP
\fB\-\-write\-solver\-stats\-to\fR json\-file
collect the solver query complexity
.TP
\fB\-\-arrays\-uf\-never\fR
never turn arrays into uninterpreted functions
.TP
\fB\-\-arrays\-uf\-always\fR
always turn arrays into uninterpreted functions
.SS "User-interface options:"
.TP
\fB\-\-xml\-ui\fR
Expand Down
35 changes: 35 additions & 0 deletions regression/goto-synthesizer/array_uf/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdlib.h>

inline int memcmp(const char *s1, const char *s2, unsigned n)
{
int res = 0;
const unsigned char *sc1 = s1, *sc2 = s2;
for(; n != 0; n--)
// clang-format off
__CPROVER_loop_invariant(n <= __CPROVER_loop_entry(n))
__CPROVER_loop_invariant(__CPROVER_same_object(sc1, __CPROVER_loop_entry(sc1)))
__CPROVER_loop_invariant(__CPROVER_same_object(sc2, __CPROVER_loop_entry(sc2)))
__CPROVER_loop_invariant(sc1 <= s1 + __CPROVER_loop_entry(n))
__CPROVER_loop_invariant(sc2 <= s2 + __CPROVER_loop_entry(n))
__CPROVER_loop_invariant(res == 0)
__CPROVER_loop_invariant(sc1 -(const unsigned char*)s1 == sc2 -(const unsigned char*)s2
&& sc1 -(const unsigned char*)s1== __CPROVER_loop_entry(n) - n)
// clang-format on
{
res = (*sc1++) - (*sc2++);
long d1 = sc1 - (const unsigned char *)s1;
long d2 = sc2 - (const unsigned char *)s2;
if(res != 0)
return res;
}
return res;
}

int main()
{
const unsigned SIZE = 4096;
unsigned char *a = malloc(SIZE);
unsigned char *b = malloc(SIZE);
memcpy(b, a, SIZE);
assert(memcmp(a, b, SIZE) == 0);
}
11 changes: 11 additions & 0 deletions regression/goto-synthesizer/array_uf/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--pointer-check _ --arrays-uf-always _ --arrays-uf-always
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
Check if the flag --array-uf-always is correctly passed from the synthesizer
to the verifier. Note that there is no loop contracts synthesized in this test.
9 changes: 8 additions & 1 deletion src/goto-synthesizer/goto_synthesizer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,18 @@ optionst goto_synthesizer_parse_optionst::get_options()
options.set_option("built-in-assertions", true);
options.set_option("assertions", true);
options.set_option("assumptions", true);
options.set_option("arrays-uf", "auto");
options.set_option("depth", UINT32_MAX);
options.set_option("exploration-strategy", "lifo");
options.set_option("symex-cache-dereferences", false);
options.set_option("rewrite-union", true);
options.set_option("self-loops-to-assumptions", true);

options.set_option("arrays-uf", "auto");
if(cmdline.isset("arrays-uf-always"))
options.set_option("arrays-uf", "always");
else if(cmdline.isset("arrays-uf-never"))
options.set_option("arrays-uf", "never");

Check warning on line 208 in src/goto-synthesizer/goto_synthesizer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-synthesizer/goto_synthesizer_parse_options.cpp#L208

Added line #L208 was not covered by tests

// Generating trace for counterexamples.
options.set_option("trace", true);

Expand Down Expand Up @@ -233,6 +238,8 @@ void goto_synthesizer_parse_optionst::help()
HELP_CONFIG_BACKEND
HELP_SOLVER
"\n"
" --arrays-uf-never never turn arrays into uninterpreted functions\n" // NOLINT(*)
" --arrays-uf-always always turn arrays into uninterpreted functions\n" // NOLINT(*)
"Other options:\n"
" --version show version and exit\n"
" --xml-ui use XML-formatted output\n"
Expand Down
1 change: 1 addition & 0 deletions src/goto-synthesizer/goto_synthesizer_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Author: Qinheping Hu
"(" FLAG_LOOP_CONTRACTS_NO_UNWIND ")" \
OPT_CONFIG_BACKEND \
OPT_SOLVER \
"(arrays-uf-always)(arrays-uf-never)" \
"(verbosity):(version)(xml-ui)(json-ui)" \
// empty last line

Expand Down

0 comments on commit 1bf2c96

Please sign in to comment.