Skip to content
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

fix registration-queue error in mcsat-model-hint #477

Merged
merged 3 commits into from
Nov 18, 2023
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 src/mcsat/solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2551,6 +2551,7 @@ void mcsat_set_model_hint(mcsat_solver_t* mcsat, model_t* mdl, uint32_t n_mdl_fi
assert(x_value >= 0);
trail_add_propagation(mcsat->trail, x_var, &value, plugin_i, mcsat->trail->decision_level);
mcsat_value_destruct(&value);
mcsat_process_registeration_queue(mcsat);
}

mcsat_pop(mcsat);
Expand Down
42 changes: 42 additions & 0 deletions tests/api/test_model_hint.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ static context_t *make_mcsat_context(void) {
return NULL;
}

static term_t make_simple_eq_constraint(term_t var[2]) {
type_t integer;
term_t x, y, p;

integer = yices_int_type();
x = yices_new_uninterpreted_term(integer);
yices_set_term_name(x, "x");
y = yices_new_uninterpreted_term(integer);
yices_set_term_name(y, "y");

var[0] = x;
var[1] = y;

p = yices_arith_eq_atom(x, y); // p is x = y
return p;
}

/*
* Create assertion x^2 + y^2 < 1
* - return terms x and y in var:
Expand Down Expand Up @@ -208,11 +225,36 @@ static void check_unsat_with_model(bool use_hint) {
yices_free_context(ctx);
}

void check_simple() {
context_t *ctx;
model_t *model;
term_t vars[2];
term_t assertion;
int32_t code;

ctx = make_mcsat_context();
assertion = make_simple_eq_constraint(vars);

model = yices_new_model();
code = yices_model_set_int32(model, vars[1], 4);
if (code < 0) {
yices_print_error(stderr);
exit(1);
}

smt_status_t status;
status = check_with_model_and_hint(ctx, model, assertion, 1, vars, 0);
assert(status == STATUS_SAT);

yices_free_model(model);
yices_free_context(ctx);
}

int main(void) {
yices_init();
if (yices_has_mcsat()) {
printf("MCSAT supported\n");
check_simple();
check_with_sat_model(false);
check_with_sat_model(true);
check_with_unsat_model(false);
Expand Down