Skip to content

Commit ee82001

Browse files
authored
update yices2.6.5 api (#6)
1 parent ff48993 commit ee82001

File tree

4 files changed

+104
-4
lines changed

4 files changed

+104
-4
lines changed

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2019 Ian A Mason
4+
Copyright (c) 2024 Ahmed Irfan
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
description='Python Bindings for the Yices SMT Solver',
2323
long_description=long_description,
2424
url='https://github.com/SRI-CSL/yices2_python_bindings',
25-
author='Sam Owre, Ian A. Mason, Bruno Dutertre.',
26-
author_email='iam@csl.sri.com',
25+
author='Sam Owre, Ian A. Mason, Bruno Dutertre, Ahmed Irfan.',
26+
author_email='ahmed.irfan@sri.com',
2727

2828

2929
include_package_data=True,

yices/Context.py

+31
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,37 @@ def check_context_with_model(self, params, model, python_array_or_tuple):
133133
raise YicesException('check_context_with_model')
134134
return status
135135

136+
def check_context_with_model_and_hint(self, params, model, python_array_or_tuple, python_array_or_tuple_hints):
137+
assert self.context is not None
138+
assert model is not None
139+
m = len(python_array_or_tuple)
140+
alist = list(python_array_or_tuple) + list(python_array_or_tuple_hints)
141+
alen = len(alist)
142+
a = yapi.make_term_array(alist)
143+
status = yapi.yices_check_context_with_model_and_hint(self.context, params, model.model, alen, a, m)
144+
if status == Status.ERROR:
145+
raise YicesException('check_context_with_model')
146+
return status
147+
148+
149+
def mcsat_set_fixed_var_order(self, python_array_or_tuple):
150+
assert self.context is not None
151+
alen = len(python_array_or_tuple)
152+
a = yapi.make_term_array(python_array_or_tuple)
153+
status = yapi.yices_mcsat_set_fixed_var_order(self.context, alen, a)
154+
if status == Status.ERROR:
155+
raise YicesException('mcsat_set_fixed_var_order')
156+
return status
157+
158+
def mcsat_set_initial_var_order(self, python_array_or_tuple):
159+
assert self.context is not None
160+
alen = len(python_array_or_tuple)
161+
a = yapi.make_term_array(python_array_or_tuple)
162+
status = yapi.yices_mcsat_set_initial_var_order(self.context, alen, a)
163+
if status == Status.ERROR:
164+
raise YicesException('mcsat_set_initial_var_order')
165+
return status
166+
136167

137168
def get_unsat_core(self):
138169
retval = []

yices_api.py

+70-2
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,21 @@ def yices_python_info_main():
105105
# 1.1.3 - 2.6.2 - 05/20/2020 - new API routines (not sure where 2.6.1 was?) #
106106
# 1.1.4 - 2.6.2 - 07/10/2020 - Profiling stuff #
107107
# 1.1.5 - 2.6.4 - 12/06/2021 - new 2.6.4 API routines #
108+
# 1.1.6 - 2.6.5 - 12/16/2024 - new 2.6.5 API routines #
108109
################################################################################################
109110

110111
#
111112
# when the dust settles we can synch this with the library, but
112113
# while the bindings are moving so fast we should keep them separate.
113114
#
114115
#
115-
yices_python_version = '1.1.5'
116+
yices_python_version = '1.1.6'
116117

117118
#
118119
# 1.0.1 needs yices_has_mcsat
119120
# 1.0.1-7 needs the _fd api additions that appear in 2.5.4
120121
# 1.1.0 hooks into the new unsat core stuff
121-
yices_recommended_version = '2.6.4'
122+
yices_recommended_version = '2.6.5'
122123

123124
#iam: 10/4/2017 try to make the user experience a little more pythony.
124125
#BD suggests doing this in the loadYices routine; he might be right
@@ -4552,6 +4553,73 @@ def yices_check_context_with_model(ctx, params, mdl, n, t):
45524553
assert ctx is not None
45534554
return libyices.yices_check_context_with_model(ctx, params, mdl, n, t)
45544555

4556+
# new in 2.6.5
4557+
#smt_status_t yices_check_context_with_model_and_hint(context_t *ctx, const param_t *params, model_t *mdl, uint32_t n, const term_t t[], uint32_t m);
4558+
libyices.yices_check_context_with_model_and_hint.restype = smt_status_t
4559+
libyices.yices_check_context_with_model_and_hint.argtypes = [context_t, param_t, model_t, c_uint32, POINTER(term_t), c_uint32]
4560+
@catch_error(-1)
4561+
def yices_check_context_with_model_and_hint(ctx, params, mdl, n, t, m):
4562+
"""Check satisfiability modulo a model and hints.
4563+
4564+
Check whether the assertions stored in ctx conjoined with a model are satisfiable.
4565+
- ctx must be a context initialized with support for MCSAT
4566+
(see yices_new_context, yices_new_config, yices_set_config).
4567+
- params is an optional structure to store heuristic parameters
4568+
if params is NULL, default parameter settings are used.
4569+
- mdl is a model
4570+
- t is an array of n terms
4571+
- the terms t[0] ... t[n-1] must all be uninterpreted terms
4572+
4573+
This function checks statisfiability of the constraints in ctx
4574+
conjoined with a conjunction of equalities defined by first m terms
4575+
in t and their model values, namely,
4576+
4577+
t[0] = v_0 /\ .... /\ t[m-1] = v_{m-1}
4578+
4579+
and the remaining n-m terms in t are provided with hints from the
4580+
model, i.e.
4581+
4582+
t[m], ... , t[n-1] will be given v_{m}, ... , v_{n-1} values when deciding
4583+
4584+
where v_i is the value of t[i] in mdl.
4585+
"""
4586+
assert ctx is not None
4587+
return libyices.yices_check_context_with_model_and_hint(ctx, params, mdl, n, t, m)
4588+
4589+
# new in 2.6.5
4590+
#smt_status_t yices_mcsat_set_fixed_var_order(context_t *ctx, uint32_t n, const term_t t[]);
4591+
libyices.yices_mcsat_set_fixed_var_order.restype = smt_status_t
4592+
libyices.yices_mcsat_set_fixed_var_order.argtypes = [context_t, c_uint32, POINTER(term_t)]
4593+
@catch_error(-1)
4594+
def yices_mcsat_set_fixed_var_order(ctx, n, t):
4595+
"""Set a fixed variable ordering for making mcsat decisions. MCSAT
4596+
will always first decide these variables in the given order.
4597+
4598+
- ctx must be a context initialized with support for MCSAT
4599+
(see yices_new_context, yices_new_config, yices_set_config).
4600+
- t is an array of n terms
4601+
4602+
NOTE: This will overwrite the previously set ordering.
4603+
"""
4604+
assert ctx is not None
4605+
return libyices.yices_mcsat_set_fixed_var_order(ctx, n, t)
4606+
4607+
# new in 2.6.5
4608+
#smt_status_t yices_mcsat_set_initial_var_order(context_t *ctx, uint32_t n, const term_t t[]);
4609+
libyices.yices_mcsat_set_initial_var_order.restype = smt_status_t
4610+
libyices.yices_mcsat_set_initial_var_order.argtypes = [context_t, c_uint32, POINTER(term_t)]
4611+
@catch_error(-1)
4612+
def yices_mcsat_set_initial_var_order(ctx, n, t):
4613+
"""Set initial variable ordering for making mcsat decisions. This is
4614+
one-time ordering that is done initially in the MCSAT search.
4615+
4616+
- ctx must be a context initialized with support for MCSAT
4617+
(see yices_new_context, yices_new_config, yices_set_config).
4618+
- t is an array of n terms
4619+
"""
4620+
assert ctx is not None
4621+
return libyices.yices_mcsat_set_initial_var_order(ctx, n, t)
4622+
45554623
# new in 2.6.4
45564624
# smt_status_t yices_check_context_with_interpolation(interpolation_context_t *ctx, const param_t *params, int32_t build_model);
45574625
libyices.yices_check_context_with_interpolation.restype = smt_status_t

0 commit comments

Comments
 (0)