Skip to content

Commit b2eb4fc

Browse files
author
Joe Hendrix
committed
Bugfixes and cleanups to support backtracing in mcarith.
1 parent c017ba4 commit b2eb4fc

File tree

6 files changed

+197
-148
lines changed

6 files changed

+197
-148
lines changed

src/api/yices_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10772,9 +10772,11 @@ static void yices_get_arith_value(model_t *mdl, term_t t, arithval_struct_t *r)
1077210772
if (object_is_rational(vtbl, v)) {
1077310773
r->tag = ARITHVAL_RATIONAL;
1077410774
r->val.q = vtbl_rational(vtbl, v);
10775+
#ifdef HAVE_MCSAT
1077510776
} else if (object_is_algebraic(vtbl, v)) {
1077610777
r->tag = ARITHVAL_ALGEBRAIC;
1077710778
r->val.p = vtbl_algebraic_number(vtbl, v);
10779+
#endif
1077810780
} else {
1077910781
// should not happen since t is an arithmetic term
1078010782
set_error_code(INTERNAL_EXCEPTION);

src/context/context.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5349,6 +5349,7 @@ static void create_simplex_solver(context_t *ctx, bool automatic) {
53495349
* Create an initialize the simplex solver and attach it to the core
53505350
* or to the egraph if the egraph exists.
53515351
*/
5352+
#ifdef HAVE_MCSAT
53525353
static void create_mcarith_solver(context_t *ctx) {
53535354
mcarith_solver_t *solver;
53545355
smt_mode_t cmode;
@@ -5380,7 +5381,12 @@ static void create_mcarith_solver(context_t *ctx) {
53805381
ctx->arith_solver = solver;
53815382
ctx->arith = *mcarith_arith_interface(solver);
53825383
}
5383-
5384+
#else
5385+
static void create_mcarith_solver(context_t *ctx) {
5386+
fprintf(stderr, "mcarithmetic solver not supported.\n");
5387+
exit(-1);
5388+
}
5389+
#endif
53845390

53855391
/*
53865392
* Create IDL/SIMPLEX solver based on ctx->dl_profile
@@ -5777,9 +5783,6 @@ void init_context(context_t *ctx, term_table_t *terms, smt_logic_t logic,
57775783
ctx->en_quant = false;
57785784
}
57795785

5780-
5781-
void arithval_in_model_delete(arithval_in_model_t* v);
5782-
57835786
void arithval_in_model_delete(arithval_in_model_t* v) {
57845787
switch (v->tag) {
57855788
case ARITHVAL_RATIONAL:
@@ -5802,8 +5805,7 @@ void arithval_in_model_reset(arithval_in_model_t* v) {
58025805
break;
58035806
#ifdef HAVE_MCSAT
58045807
case ARITHVAL_ALGEBRAIC:
5805-
lp_algebraic_number_destruct(&v->
5806-
val.alg_number);
5808+
lp_algebraic_number_destruct(&v->val.alg_number);
58075809
v->tag = ARITHVAL_RATIONAL;
58085810
q_init(&v->val.q);
58095811
break;

src/context/context_solver.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ static value_t bool_value(context_t *ctx, value_table_t *vtbl, literal_t l) {
887887
return v;
888888
}
889889

890-
891890
/*
892891
* Value of arithmetic variable x in ctx->arith_solver
893892
*/

src/context/context_types.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,25 +258,14 @@ enum {
258258
typedef enum arithval_tag {
259259
ARITHVAL_ERROR,
260260
ARITHVAL_RATIONAL,
261-
#ifdef HAVE_MCSAT
262261
ARITHVAL_ALGEBRAIC,
263-
#endif
264262
} arithval_tag_t;
265263

266264
/*
267265
* Tagged union to represent pointers to either rational or algebraic numbers.
268266
* The flag can ERROR/RATIONAL/ALGEBRAIC
269267
*/
270-
typedef struct {
271-
arithval_tag_t tag;
272-
union {
273-
rational_t q;
274-
#ifdef HAVE_MCSAT
275-
lp_algebraic_number_t alg_number;
276-
#endif
277-
} val;
278-
} arithval_in_model_t;
279-
268+
typedef struct arithval_in_model_s arithval_in_model_t;
280269

281270
/**************************
282271
* ARITHMETIC INTERFACE *
@@ -662,6 +651,16 @@ typedef struct dl_data_s {
662651
* CONTEXT *
663652
*************/
664653

654+
struct arithval_in_model_s {
655+
arithval_tag_t tag;
656+
union {
657+
rational_t q;
658+
#ifdef HAVE_MCSAT
659+
lp_algebraic_number_t alg_number;
660+
#endif
661+
} val;
662+
};
663+
665664
struct context_s {
666665
// mode + architecture + logic code
667666
context_mode_t mode;

0 commit comments

Comments
 (0)