3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

Merge branch 'master' of https://github.com/Z3Prover/z3 into new-ml-api

This commit is contained in:
Christoph M. Wintersteiger 2016-03-02 15:14:12 +00:00
commit b27977ea90
56 changed files with 2041 additions and 477 deletions

View file

@ -832,7 +832,7 @@ extern "C" {
pp_params params;
pp.set_simplify_implies(params.simplify_implies());
ast* a1 = to_ast(a);
pp.set_logic(mk_c(c)->fparams().m_smtlib_logic.c_str());
pp.set_logic(mk_c(c)->fparams().m_logic);
if (!is_expr(a1)) {
buffer << mk_pp(a1, mk_c(c)->m());
break;
@ -880,7 +880,7 @@ extern "C" {
std::ostringstream buffer;
ast_smt_pp pp(mk_c(c)->m());
pp.set_benchmark_name(name);
pp.set_logic(logic);
pp.set_logic(logic?symbol(logic):symbol::null);
pp.set_status(status);
pp.add_attributes(attributes);
pp_params params;

View file

@ -68,8 +68,10 @@ extern "C" {
(' ' == *m) || ('\n' == *m) ||
('.' == *m) || ('e' == *m) ||
('E' == *m) ||
('p' == *m && is_float) ||
('P' == *m && is_float))) {
(is_float &&
(('p' == *m) ||
('P' == *m) ||
('+' == *m))))) {
SET_ERROR_CODE(Z3_PARSER_ERROR);
return 0;
}

View file

@ -153,6 +153,11 @@ extern "C" {
LOG_Z3_solver_set_params(c, s, p);
RESET_ERROR_CODE();
symbol logic = to_param_ref(p).get_sym("smt.logic", symbol::null);
if (logic != symbol::null) {
to_solver(s)->m_logic = logic;
}
if (to_solver(s)->m_solver) {
bool old_model = to_solver(s)->m_params.get_bool("model", true);
bool new_model = to_param_ref(p).get_bool("model", true);

View file

@ -48,6 +48,7 @@ from z3printer import *
from fractions import Fraction
import sys
import io
import math
if sys.version < '3':
def _is_int(v):
@ -7963,7 +7964,7 @@ class FPSortRef(SortRef):
return int(Z3_fpa_get_ebits(self.ctx_ref(), self.ast))
def sbits(self):
"""Retrieves the number of bits reserved for the exponent in the FloatingPoint sort `self`.
"""Retrieves the number of bits reserved for the significand in the FloatingPoint sort `self`.
>>> b = FPSort(8, 24)
>>> b.sbits()
24
@ -7971,8 +7972,7 @@ class FPSortRef(SortRef):
return int(Z3_fpa_get_sbits(self.ctx_ref(), self.ast))
def cast(self, val):
"""Try to cast `val` as a Floating-point expression
"""Try to cast `val` as a floating-point expression.
>>> b = FPSort(8, 24)
>>> b.cast(1.0)
1
@ -8099,10 +8099,6 @@ class FPRef(ExprRef):
def __gt__(self, other):
return fpGT(self, other, self.ctx)
def __ne__(self, other):
return fpNEQ(self, other, self.ctx)
def __add__(self, other):
"""Create the Z3 expression `self + other`.
@ -8413,11 +8409,24 @@ def FPSort(ebits, sbits, ctx=None):
def _to_float_str(val, exp=0):
if isinstance(val, float):
v = val.as_integer_ratio()
num = v[0]
den = v[1]
rvs = str(num) + '/' + str(den)
res = rvs + 'p' + _to_int_str(exp)
if math.isnan(val):
res = "NaN"
elif val == 0.0:
sone = math.copysign(1.0, val)
if sone < 0.0:
return "-0.0"
else:
return "+0.0"
elif val == float("+inf"):
res = "+oo"
elif val == float("-inf"):
res = "-oo"
else:
v = val.as_integer_ratio()
num = v[0]
den = v[1]
rvs = str(num) + '/' + str(den)
res = rvs + 'p' + _to_int_str(exp)
elif isinstance(val, bool):
if val:
res = "1.0"
@ -8515,6 +8524,12 @@ def FPVal(sig, exp=None, fps=None, ctx=None):
>>> v = FPVal(-2.25, FPSort(8, 24))
>>> v
-1.125*(2**1)
>>> v = FPVal(-0.0, FPSort(8, 24))
-0.0
>>> v = FPVal(0.0, FPSort(8, 24))
+0.0
>>> v = FPVal(+0.0, FPSort(8, 24))
+0.0
"""
ctx = _get_ctx(ctx)
if is_fp_sort(exp):
@ -8526,7 +8541,18 @@ def FPVal(sig, exp=None, fps=None, ctx=None):
if exp == None:
exp = 0
val = _to_float_str(sig)
return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
if val == "NaN" or val == "nan":
return fpNaN(fps)
elif val == "-0.0":
return fpMinusZero(fps)
elif val == "0.0" or val == "+0.0":
return fpPlusZero(fps)
elif val == "+oo" or val == "+inf" or val == "+Inf":
return fpPlusInfinity(fps)
elif val == "-oo" or val == "-inf" or val == "-Inf":
return fpMinusInfinity(fps)
else:
return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
def FP(name, fpsort, ctx=None):
"""Return a floating-point constant named `name`.
@ -8824,13 +8850,13 @@ def _check_fp_args(a, b):
_z3_assert(is_fp(a) or is_fp(b), "At least one of the arguments must be a Z3 floating-point expression")
def fpLT(a, b, ctx=None):
"""Create the Z3 floating-point expression `other <= self`.
"""Create the Z3 floating-point expression `other < self`.
>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpLT(x, y)
x < y
>>> (x <= y).sexpr()
'(fp.leq x y)'
>>> (x < y).sexpr()
'(fp.lt x y)'
"""
return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
@ -8846,7 +8872,7 @@ def fpLEQ(a, b, ctx=None):
return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
def fpGT(a, b, ctx=None):
"""Create the Z3 floating-point expression `other <= self`.
"""Create the Z3 floating-point expression `other > self`.
>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpGT(x, y)
@ -8857,11 +8883,9 @@ def fpGT(a, b, ctx=None):
return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
def fpGEQ(a, b, ctx=None):
"""Create the Z3 floating-point expression `other <= self`.
"""Create the Z3 floating-point expression `other >= self`.
>>> x, y = FPs('x y', FPSort(8, 24))
>>> x + y
x + y
>>> fpGEQ(x, y)
x >= y
>>> (x >= y).sexpr()
@ -8870,7 +8894,7 @@ def fpGEQ(a, b, ctx=None):
return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
def fpEQ(a, b, ctx=None):
"""Create the Z3 floating-point expression `other <= self`.
"""Create the Z3 floating-point expression `fpEQ(other, self)`.
>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpEQ(x, y)
@ -8881,7 +8905,7 @@ def fpEQ(a, b, ctx=None):
return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
def fpNEQ(a, b, ctx=None):
"""Create the Z3 floating-point expression `other <= self`.
"""Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpNEQ(x, y)