Skip to content

Commit 3e61b88

Browse files
committed
Missing function: yices_model_set_bv_from_array
1 parent fc0440e commit 3e61b88

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/api/yices_api.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10070,11 +10070,47 @@ int32_t _o_yices_model_set_bv_mpz(model_t *model, term_t var, mpz_t val) {
1007010070
}
1007110071

1007210072
yices_model_set_bvconstant(model, var, &bv0);
10073+
1007310074
return 0;
1007410075
}
1007510076

1007610077

1007710078

10079+
/*
10080+
* Assign a bitvector variable using an array of bits.
10081+
* - var = bitvector variable
10082+
* - a = array of n bits
10083+
* - var must be an uninterpreted term of type (bitvector n)
10084+
* (and var must not have a value in model).
10085+
*
10086+
* Elements of a are interpreted as in yices_bvconst_from_array:
10087+
* - bit i is 0 if a[i] == 0 and bit i is 1 if a[i] != 0
10088+
* - a[0] is the low-order bit
10089+
* - a[n-1] is the high-order bit
10090+
*/
10091+
EXPORTED int32_t yices_model_set_bv_from_array(model_t *model, term_t var, uint32_t n, const int32_t a[]) {
10092+
MT_PROTECT(int32_t, __yices_globals.lock, _o_yices_model_set_bv_from_array(model, var, n, a));
10093+
}
10094+
10095+
int32_t _o_yices_model_set_bv_from_array(model_t *model, term_t var, uint32_t n, const int32_t a[]) {
10096+
uint32_t nbits;
10097+
10098+
nbits = check_var_and_get_bitsize(model, var);
10099+
if (nbits == 0) return -1;
10100+
10101+
if (n != nbits) {
10102+
// could also report EMPTY_BITVECTOR if n == 0
10103+
set_error_code(INCOMPATIBLE_BVSIZES);
10104+
return -1;
10105+
}
10106+
10107+
bvconstant_set_bitsize(&bv0, n);
10108+
bvconst_set_array(bv0.data, a, n);
10109+
yices_model_set_bvconstant(model, var, &bv0);
10110+
10111+
return 0;
10112+
}
10113+
1007810114

1007910115
/*
1008010116
* Export the list of uninterpreted terms that have a value in mdl.

src/api/yices_api_lock_free.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ extern int32_t _o_yices_model_set_bv_uint64(model_t *model, term_t var, uint64_t
629629

630630
extern int32_t _o_yices_model_set_bv_mpz(model_t *model, term_t var, mpz_t val);
631631

632+
extern int32_t _o_yices_model_set_bv_from_array(model_t *model, term_t var, uint32_t n, const int32_t a[]);
632633

633634
/************************
634635
* VALUES IN A MODEL *

src/include/yices_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ typedef enum error_code {
530530
* TYPE_MISMATCH term1, type1
531531
* INCOMPATIBLE_TYPES term1, type1, term2, type2
532532
* DUPLICATE_VARIABLE term1
533-
* INCOMPATIBLE_BVSIZES term1, type1, term2, type2
533+
* INCOMPATIBLE_BVSIZES none
534534
* EMPTY_BITVECTOR none
535-
* ARITHCONSTANT_REQUIRED term1
535+
* ARITHCONSTANT_REQUIRED term1
536536
* INVALID_MACRO badval
537537
* TOO_MANY_MACRO_PARAMS badval
538538
* TYPE_VAR_REQUIRED type1

src/terms/bv_constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ extern void bvconstant_set_all_one(bvconstant_t *b, uint32_t n);
133133
*/
134134
extern void bvconstant_copy(bvconstant_t *b, uint32_t n, const uint32_t *a);
135135

136+
136137
/*
137138
* Variant: initialize with a 64bit constant a, and normalize.
138139
* - n = number of bits

0 commit comments

Comments
 (0)