Skip to content

Commit

Permalink
Replacing boolector with bitwuzla, introducing explicit Bool type in …
Browse files Browse the repository at this point in the history
…monster
  • Loading branch information
ckirsch committed Dec 31, 2024
1 parent 64e7456 commit 149934a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ rotor-btor2: $(rotors) selfie-rotorized.btor2 synthesize
btor2: beator-btor2 rotor-btor2

# Consider these targets as targets, not files
.PHONY: spike qemu assemble beator-32 rotor-32 32-bit boolector beator-btormc rotor-btormc btormc extras
.PHONY: spike qemu assemble beator-32 rotor-32 32-bit bitwuzla beator-btormc rotor-btormc btormc extras

# Run everything that requires non-standard tools
extras: spike qemu assemble beator-32 rotor-32 32-bit
extras: spike qemu assemble beator-32 rotor-32 32-bit bitwuzla

# Run selfie on spike
spike: selfie.m selfie.s
Expand Down Expand Up @@ -391,11 +391,11 @@ rotor-32: tools/rotor.c selfie.h
./beator-32 -c selfie.h tools/beator.c - 0 --check-block-access
./rotor-32 -c selfie.h tools/rotor.c - $(rotor)

# Run boolector SMT solver on SMT-LIB files generated by monster
boolector: smt
$(foreach file, $(smts-1), [ $$(boolector $(file) -e 0 | grep -c ^sat$$) -eq 1 ] &&) true
$(foreach file, $(smts-2), [ $$(boolector $(file) -e 0 | grep -c ^sat$$) -eq 2 ] &&) true
$(foreach file, $(smts-3), [ $$(boolector $(file) -e 0 | grep -c ^sat$$) -eq 3 ] &&) true
# Run bitwuzla SMT solver on SMT-LIB files generated by monster
bitwuzla: smt
$(foreach file, $(smts-1), [ $$(bitwuzla $(file) | grep -c ^sat$$) -eq 1 ] &&) true
$(foreach file, $(smts-2), [ $$(bitwuzla $(file) | grep -c ^sat$$) -eq 2 ] &&) true
$(foreach file, $(smts-3), [ $$(bitwuzla $(file) | grep -c ^sat$$) -eq 3 ] &&) true

# Run btormc bounded model checker on BTOR2 files generated by beator
beator-btormc: beator-btor2
Expand Down
9 changes: 6 additions & 3 deletions tools/monster.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ void constrain_add_sub_mul_divu_remu_sltu(char* operator) {
void zero_extend_sltu() {
if (rd != REG_ZR)
if (*(reg_sym + rd))
*(reg_sym + rd) = (uint64_t) smt_unary(bv_zero_extension(1), (char*) *(reg_sym + rd));
*(reg_sym + rd) = (uint64_t) smt_ternary("ite", (char*) *(reg_sym + rd), bv_constant(1), bv_constant(0));
}

void constrain_load() {
Expand Down Expand Up @@ -876,7 +876,7 @@ void constrain_beq() {
bvar = smt_variable("b", 1);

w = w
+ dprintf(output_fd, "(assert (= %s %s)); beq in ", bvar, smt_binary("bvcomp", op1, op2))
+ dprintf(output_fd, "(assert (= %s %s)); beq in ", bvar, smt_binary("=", op1, op2))
+ print_code_context_for_instruction(pc)
+ dprintf(output_fd, "\n");

Expand Down Expand Up @@ -1284,6 +1284,9 @@ char* bv_constant(uint64_t value) {
char* bv_variable(uint64_t bits) {
char* string;

if (bits == 1)
return "Bool";

string = string_alloc(10 + 2); // up to 64-bit variables require up to 2 decimal digits

sprintf(string, "(_ BitVec %lu)", bits);
Expand Down Expand Up @@ -1316,7 +1319,7 @@ char* smt_variable(char* prefix, uint64_t bits) {
sprintf(svar, "%s%lu", prefix, variable_version);

w = w
+ dprintf(output_fd, "(declare-fun %s () (_ BitVec %lu)); variable for ", svar, bits)
+ dprintf(output_fd, "(declare-fun %s () %s); variable for ", svar, bv_variable(bits))
+ print_code_context_for_instruction(pc)
+ dprintf(output_fd, "\n");

Expand Down

0 comments on commit 149934a

Please sign in to comment.