mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 05:18:44 +00:00
Merge branch 'unstable' of https://github.com/Z3Prover/z3 into unstable
This commit is contained in:
commit
227c8870d6
|
@ -47,13 +47,13 @@ class ComplexExpr:
|
|||
return ComplexExpr(other.r*self.r - other.i*self.i, other.i*self.r + other.r*self.i)
|
||||
|
||||
def __pow__(self, k):
|
||||
if k == 0:
|
||||
return ComplexExpr(1, 0)
|
||||
if k == 1:
|
||||
return self
|
||||
if k < 0:
|
||||
return (self ** (-k)).inv()
|
||||
return reduce(lambda x, y: x * y, [self for _ in xrange(k)], ComplexExpr(1, 0))
|
||||
if k == 0:
|
||||
return ComplexExpr(1, 0)
|
||||
if k == 1:
|
||||
return self
|
||||
if k < 0:
|
||||
return (self ** (-k)).inv()
|
||||
return reduce(lambda x, y: x * y, [self for _ in xrange(k)], ComplexExpr(1, 0))
|
||||
|
||||
def inv(self):
|
||||
den = self.r*self.r + self.i*self.i
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
<Compile Include="IntSymbol.cs" />
|
||||
<Compile Include="ListSort.cs" />
|
||||
<Compile Include="Model.cs" />
|
||||
<Compile Include="Optimize.cs" />
|
||||
<Compile Include="Params.cs" />
|
||||
<Compile Include="ParamDescrs.cs" />
|
||||
<Compile Include="Pattern.cs" />
|
||||
|
|
|
@ -85,43 +85,43 @@ namespace Microsoft.Z3
|
|||
Assert(constraints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle to objectives returned by objective functions.
|
||||
/// </summary>
|
||||
public class Handle
|
||||
/// <summary>
|
||||
/// Handle to objectives returned by objective functions.
|
||||
/// </summary>
|
||||
public class Handle
|
||||
{
|
||||
Optimize opt;
|
||||
uint handle;
|
||||
internal Handle(Optimize opt, uint h)
|
||||
{
|
||||
this.opt = opt;
|
||||
this.handle = h;
|
||||
}
|
||||
Optimize opt;
|
||||
uint handle;
|
||||
internal Handle(Optimize opt, uint h)
|
||||
{
|
||||
this.opt = opt;
|
||||
this.handle = h;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a lower bound for the objective handle.
|
||||
/// </summary>
|
||||
public ArithExpr Lower
|
||||
{
|
||||
get { return opt.GetLower(handle); }
|
||||
}
|
||||
public ArithExpr Lower
|
||||
{
|
||||
get { return opt.GetLower(handle); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an upper bound for the objective handle.
|
||||
/// </summary>
|
||||
public ArithExpr Upper
|
||||
{
|
||||
get { return opt.GetUpper(handle); }
|
||||
}
|
||||
public ArithExpr Upper
|
||||
{
|
||||
get { return opt.GetUpper(handle); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the value of an objective.
|
||||
/// </summary>
|
||||
public ArithExpr Value
|
||||
{
|
||||
get { return Lower; }
|
||||
}
|
||||
}
|
||||
public ArithExpr Value
|
||||
{
|
||||
get { return Lower; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assert soft constraint
|
||||
|
@ -132,29 +132,29 @@ namespace Microsoft.Z3
|
|||
public Handle AssertSoft(BoolExpr constraint, uint weight, string group)
|
||||
{
|
||||
Context.CheckContextMatch(constraint);
|
||||
Symbol s = Context.MkSymbol(group);
|
||||
return new Handle(this, Native.Z3_optimize_assert_soft(Context.nCtx, NativeObject, constraint.NativeObject, weight.ToString(), s.NativeObject));
|
||||
Symbol s = Context.MkSymbol(group);
|
||||
return new Handle(this, Native.Z3_optimize_assert_soft(Context.nCtx, NativeObject, constraint.NativeObject, weight.ToString(), s.NativeObject));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// <summary>
|
||||
/// Check satisfiability of asserted constraints.
|
||||
/// Produce a model that (when the objectives are bounded and
|
||||
/// don't use strict inequalities) meets the objectives.
|
||||
/// </summary>
|
||||
///
|
||||
public Status Check() {
|
||||
Z3_lbool r = (Z3_lbool)Native.Z3_optimize_check(Context.nCtx, NativeObject);
|
||||
|
||||
/// <summary>
|
||||
/// Check satisfiability of asserted constraints.
|
||||
/// Produce a model that (when the objectives are bounded and
|
||||
/// don't use strict inequalities) meets the objectives.
|
||||
/// </summary>
|
||||
///
|
||||
public Status Check()
|
||||
{
|
||||
Z3_lbool r = (Z3_lbool)Native.Z3_optimize_check(Context.nCtx, NativeObject);
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE:
|
||||
case Z3_lbool.Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE:
|
||||
case Z3_lbool.Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -198,27 +198,27 @@ namespace Microsoft.Z3
|
|||
|
||||
/// <summary>
|
||||
/// Declare an arithmetical maximization objective.
|
||||
/// Return a handle to the objective. The handle is used as
|
||||
/// to retrieve the values of objectives after calling Check.
|
||||
/// Return a handle to the objective. The handle is used as
|
||||
/// to retrieve the values of objectives after calling Check.
|
||||
/// </summary>
|
||||
public Handle MkMaximize(ArithExpr e)
|
||||
public Handle MkMaximize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
}
|
||||
return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Declare an arithmetical minimization objective.
|
||||
/// Similar to MkMaximize.
|
||||
/// Similar to MkMaximize.
|
||||
/// </summary>
|
||||
public Handle MkMinimize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a lower bound for the objective handle.
|
||||
/// </summary>
|
||||
private ArithExpr GetLower(uint index)
|
||||
private ArithExpr GetLower(uint index)
|
||||
{
|
||||
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Print the context to a string (SMT-LIB parseable benchmark).
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
|
|
@ -500,6 +500,7 @@ bool cmd_context::logic_has_arith_core(symbol const & s) const {
|
|||
s == "QF_RDL" ||
|
||||
s == "QF_IDL" ||
|
||||
s == "QF_AUFLIA" ||
|
||||
s == "QF_ALIA" ||
|
||||
s == "QF_AUFLIRA" ||
|
||||
s == "QF_AUFNIA" ||
|
||||
s == "QF_AUFNIRA" ||
|
||||
|
@ -550,9 +551,7 @@ bool cmd_context::logic_has_bv_core(symbol const & s) const {
|
|||
}
|
||||
|
||||
bool cmd_context::logic_has_horn(symbol const& s) const {
|
||||
return
|
||||
s == "HORN";
|
||||
|
||||
return s == "HORN";
|
||||
}
|
||||
|
||||
bool cmd_context::logic_has_bv() const {
|
||||
|
@ -560,24 +559,26 @@ bool cmd_context::logic_has_bv() const {
|
|||
}
|
||||
|
||||
bool cmd_context::logic_has_seq_core(symbol const& s) const {
|
||||
return
|
||||
s == "QF_BVRE";
|
||||
|
||||
return s == "QF_BVRE";
|
||||
}
|
||||
|
||||
bool cmd_context::logic_has_seq() const {
|
||||
return !has_logic() || logic_has_seq_core(m_logic);
|
||||
}
|
||||
|
||||
bool cmd_context::logic_has_fpa() const {
|
||||
return !has_logic() || m_logic == "QF_FP" || m_logic == "QF_FPBV";
|
||||
bool cmd_context::logic_has_fpa_core(symbol const& s) const {
|
||||
return s == "QF_FP" || s == "QF_FPBV" || s == "QF_BVFP";
|
||||
}
|
||||
|
||||
bool cmd_context::logic_has_fpa() const {
|
||||
return !has_logic() || logic_has_fpa_core(m_logic);
|
||||
}
|
||||
|
||||
bool cmd_context::logic_has_array_core(symbol const & s) const {
|
||||
return
|
||||
s == "QF_AX" ||
|
||||
s == "QF_AUFLIA" ||
|
||||
s == "QF_ALIA" ||
|
||||
s == "QF_AUFLIRA" ||
|
||||
s == "QF_AUFNIA" ||
|
||||
s == "QF_AUFNIRA" ||
|
||||
|
@ -682,8 +683,7 @@ bool cmd_context::supported_logic(symbol const & s) const {
|
|||
return s == "QF_UF" || s == "UF" ||
|
||||
logic_has_arith_core(s) || logic_has_bv_core(s) ||
|
||||
logic_has_array_core(s) || logic_has_seq_core(s) ||
|
||||
logic_has_horn(s) ||
|
||||
s == "QF_FP" || s == "QF_FPBV";
|
||||
logic_has_horn(s) || logic_has_fpa_core(s);
|
||||
}
|
||||
|
||||
bool cmd_context::set_logic(symbol const & s) {
|
||||
|
|
|
@ -250,6 +250,7 @@ protected:
|
|||
bool logic_has_bv_core(symbol const & s) const;
|
||||
bool logic_has_array_core(symbol const & s) const;
|
||||
bool logic_has_seq_core(symbol const & s) const;
|
||||
bool logic_has_fpa_core(symbol const & s) const;
|
||||
bool logic_has_horn(symbol const& s) const;
|
||||
bool logic_has_arith() const;
|
||||
bool logic_has_bv() const;
|
||||
|
|
Loading…
Reference in a new issue