mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
NativeContext, NativeSolver, NativeModel - updates for Pex (#5878)
* WiP: Disposable, MkAdd, MkApp, MkBool, MkBoolSort, MkBound, MkBvSort, MkFalse, MkTrue, MkIntSort * WiP: Native z3 mk_ functions * WiP: mk_ functions for NativeContext * WiP: add utility functions for getting values * WiP: Adding more native utility functions * native model pull * WiP: NativeContext additions for array access * WiP: use Z3_symbol in place of managed Symbol * WiP: add solver, model, and array methods * WiP: MkSimpleSolver, MkReal * WiP: GetDomain GetRange * WiP: MkExists * Override for MkFuncDecl * MkConstArray, MkSelect * WiP: code cleanup * migrate Context reference to NativeContext * remove local signing from PR * minor code cleanup Co-authored-by: jfleisher <jofleish@microsoft.com>
This commit is contained in:
parent
811cd9d48d
commit
a08be497f7
|
@ -231,7 +231,6 @@ namespace Microsoft.Z3
|
|||
return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a new sequence sort.
|
||||
/// </summary>
|
||||
|
@ -485,7 +484,7 @@ namespace Microsoft.Z3
|
|||
/// The function performs a record update at t. The field
|
||||
/// that is passed in as argument is updated with value v,
|
||||
/// the remaining fields of t are unchanged.
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
public Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
|
||||
{
|
||||
return Expr.Create(this, Native.Z3_datatype_update_field(
|
||||
|
@ -560,14 +559,14 @@ namespace Microsoft.Z3
|
|||
/// MkRecFuncDecl. The body may contain recursive uses of the function or
|
||||
/// other mutually recursive functions.
|
||||
/// </summary>
|
||||
public void AddRecDef(FuncDecl f, Expr[] args, Expr body)
|
||||
{
|
||||
CheckContextMatch(f);
|
||||
CheckContextMatch<Expr>(args);
|
||||
CheckContextMatch(body);
|
||||
public void AddRecDef(FuncDecl f, Expr[] args, Expr body)
|
||||
{
|
||||
CheckContextMatch(f);
|
||||
CheckContextMatch<Expr>(args);
|
||||
CheckContextMatch(body);
|
||||
IntPtr[] argsNative = AST.ArrayToNative(args);
|
||||
Native.Z3_add_rec_def(nCtx, f.NativeObject, (uint)args.Length, argsNative, body.NativeObject);
|
||||
}
|
||||
Native.Z3_add_rec_def(nCtx, f.NativeObject, (uint)args.Length, argsNative, body.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new function declaration.
|
||||
|
@ -811,7 +810,7 @@ namespace Microsoft.Z3
|
|||
public Expr MkApp(FuncDecl f, IEnumerable<Expr> args)
|
||||
{
|
||||
Debug.Assert(f != null);
|
||||
Debug.Assert(args == null || args.All( a => a != null));
|
||||
Debug.Assert(args == null || args.All(a => a != null));
|
||||
|
||||
CheckContextMatch(f);
|
||||
CheckContextMatch(args);
|
||||
|
@ -949,14 +948,15 @@ namespace Microsoft.Z3
|
|||
Debug.Assert(ts.All(a => a != null));
|
||||
CheckContextMatch<BoolExpr>(ts);
|
||||
BoolExpr r = null;
|
||||
foreach (var t in ts) {
|
||||
if (r == null)
|
||||
r = t;
|
||||
foreach (var t in ts)
|
||||
{
|
||||
if (r == null)
|
||||
r = t;
|
||||
else
|
||||
r = MkXor(r, t);
|
||||
r = MkXor(r, t);
|
||||
}
|
||||
if (r == null)
|
||||
r = MkTrue();
|
||||
if (r == null)
|
||||
r = MkTrue();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -2343,7 +2343,7 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(elem);
|
||||
CheckContextMatch(set);
|
||||
return (BoolExpr) Expr.Create(this, Native.Z3_mk_set_member(nCtx, elem.NativeObject, set.NativeObject));
|
||||
return (BoolExpr)Expr.Create(this, Native.Z3_mk_set_member(nCtx, elem.NativeObject, set.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2356,7 +2356,7 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(arg1);
|
||||
CheckContextMatch(arg2);
|
||||
return (BoolExpr) Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
return (BoolExpr)Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2366,7 +2366,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create the empty sequence.
|
||||
/// </summary>
|
||||
public SeqExpr MkEmptySeq(Sort s)
|
||||
public SeqExpr MkEmptySeq(Sort s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return new SeqExpr(this, Native.Z3_mk_seq_empty(nCtx, s.NativeObject));
|
||||
|
@ -2375,7 +2375,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create the singleton sequence.
|
||||
/// </summary>
|
||||
public SeqExpr MkUnit(Expr elem)
|
||||
public SeqExpr MkUnit(Expr elem)
|
||||
{
|
||||
Debug.Assert(elem != null);
|
||||
return new SeqExpr(this, Native.Z3_mk_seq_unit(nCtx, elem.NativeObject));
|
||||
|
@ -2384,7 +2384,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a string constant.
|
||||
/// </summary>
|
||||
public SeqExpr MkString(string s)
|
||||
public SeqExpr MkString(string s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return new SeqExpr(this, Native.Z3_mk_string(nCtx, s));
|
||||
|
@ -2393,7 +2393,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Convert an integer expression to a string.
|
||||
/// </summary>
|
||||
public SeqExpr IntToString(Expr e)
|
||||
public SeqExpr IntToString(Expr e)
|
||||
{
|
||||
Debug.Assert(e != null);
|
||||
Debug.Assert(e is ArithExpr);
|
||||
|
@ -2413,7 +2413,8 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Convert a bit-vector expression, represented as an signed number, to a string.
|
||||
/// </summary>
|
||||
public SeqExpr SbvToString(Expr e) {
|
||||
public SeqExpr SbvToString(Expr e)
|
||||
{
|
||||
Debug.Assert(e != null);
|
||||
Debug.Assert(e is ArithExpr);
|
||||
return new SeqExpr(this, Native.Z3_mk_sbv_to_str(nCtx, e.NativeObject));
|
||||
|
@ -2422,7 +2423,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Convert an integer expression to a string.
|
||||
/// </summary>
|
||||
public IntExpr StringToInt(Expr e)
|
||||
public IntExpr StringToInt(Expr e)
|
||||
{
|
||||
Debug.Assert(e != null);
|
||||
Debug.Assert(e is SeqExpr);
|
||||
|
@ -2449,13 +2450,13 @@ namespace Microsoft.Z3
|
|||
public IntExpr MkLength(SeqExpr s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return (IntExpr) Expr.Create(this, Native.Z3_mk_seq_length(nCtx, s.NativeObject));
|
||||
return (IntExpr)Expr.Create(this, Native.Z3_mk_seq_length(nCtx, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for sequence prefix.
|
||||
/// </summary>
|
||||
public BoolExpr MkPrefixOf(SeqExpr s1, SeqExpr s2)
|
||||
public BoolExpr MkPrefixOf(SeqExpr s1, SeqExpr s2)
|
||||
{
|
||||
Debug.Assert(s1 != null);
|
||||
Debug.Assert(s2 != null);
|
||||
|
@ -2466,7 +2467,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Check for sequence suffix.
|
||||
/// </summary>
|
||||
public BoolExpr MkSuffixOf(SeqExpr s1, SeqExpr s2)
|
||||
public BoolExpr MkSuffixOf(SeqExpr s1, SeqExpr s2)
|
||||
{
|
||||
Debug.Assert(s1 != null);
|
||||
Debug.Assert(s2 != null);
|
||||
|
@ -2477,7 +2478,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Check for sequence containment of s2 in s1.
|
||||
/// </summary>
|
||||
public BoolExpr MkContains(SeqExpr s1, SeqExpr s2)
|
||||
public BoolExpr MkContains(SeqExpr s1, SeqExpr s2)
|
||||
{
|
||||
Debug.Assert(s1 != null);
|
||||
Debug.Assert(s2 != null);
|
||||
|
@ -2488,7 +2489,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Check if the string s1 is lexicographically strictly less than s2.
|
||||
/// </summary>
|
||||
public BoolExpr MkStringLt(SeqExpr s1, SeqExpr s2)
|
||||
public BoolExpr MkStringLt(SeqExpr s1, SeqExpr s2)
|
||||
{
|
||||
Debug.Assert(s1 != null);
|
||||
Debug.Assert(s2 != null);
|
||||
|
@ -2499,7 +2500,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Check if the string s1 is lexicographically less or equal to s2.
|
||||
/// </summary>
|
||||
public BoolExpr MkStringLe(SeqExpr s1, SeqExpr s2)
|
||||
public BoolExpr MkStringLe(SeqExpr s1, SeqExpr s2)
|
||||
{
|
||||
Debug.Assert(s1 != null);
|
||||
Debug.Assert(s2 != null);
|
||||
|
@ -2568,10 +2569,10 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Convert a regular expression that accepts sequence s.
|
||||
/// </summary>
|
||||
public ReExpr MkToRe(SeqExpr s)
|
||||
public ReExpr MkToRe(SeqExpr s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return new ReExpr(this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject));
|
||||
return new ReExpr(this, Native.Z3_mk_seq_to_re(nCtx, s.NativeObject));
|
||||
}
|
||||
|
||||
|
||||
|
@ -2583,7 +2584,7 @@ namespace Microsoft.Z3
|
|||
Debug.Assert(s != null);
|
||||
Debug.Assert(re != null);
|
||||
CheckContextMatch(s, re);
|
||||
return new BoolExpr(this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject));
|
||||
return new BoolExpr(this, Native.Z3_mk_seq_in_re(nCtx, s.NativeObject, re.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2592,7 +2593,7 @@ namespace Microsoft.Z3
|
|||
public ReExpr MkStar(ReExpr re)
|
||||
{
|
||||
Debug.Assert(re != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_star(nCtx, re.NativeObject));
|
||||
return new ReExpr(this, Native.Z3_mk_re_star(nCtx, re.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2601,7 +2602,7 @@ namespace Microsoft.Z3
|
|||
public ReExpr MkLoop(ReExpr re, uint lo, uint hi = 0)
|
||||
{
|
||||
Debug.Assert(re != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi));
|
||||
return new ReExpr(this, Native.Z3_mk_re_loop(nCtx, re.NativeObject, lo, hi));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2610,7 +2611,7 @@ namespace Microsoft.Z3
|
|||
public ReExpr MkPlus(ReExpr re)
|
||||
{
|
||||
Debug.Assert(re != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_plus(nCtx, re.NativeObject));
|
||||
return new ReExpr(this, Native.Z3_mk_re_plus(nCtx, re.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2619,7 +2620,7 @@ namespace Microsoft.Z3
|
|||
public ReExpr MkOption(ReExpr re)
|
||||
{
|
||||
Debug.Assert(re != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_option(nCtx, re.NativeObject));
|
||||
return new ReExpr(this, Native.Z3_mk_re_option(nCtx, re.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2628,7 +2629,7 @@ namespace Microsoft.Z3
|
|||
public ReExpr MkComplement(ReExpr re)
|
||||
{
|
||||
Debug.Assert(re != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_complement(nCtx, re.NativeObject));
|
||||
return new ReExpr(this, Native.Z3_mk_re_complement(nCtx, re.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2670,7 +2671,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a difference regular expression.
|
||||
/// </summary>
|
||||
public ReExpr MkDiff(ReExpr a, ReExpr b)
|
||||
public ReExpr MkDiff(ReExpr a, ReExpr b)
|
||||
{
|
||||
Debug.Assert(a != null);
|
||||
Debug.Assert(b != null);
|
||||
|
@ -2682,7 +2683,7 @@ namespace Microsoft.Z3
|
|||
/// Create the empty regular expression.
|
||||
/// The sort s should be a regular expression.
|
||||
/// </summary>
|
||||
public ReExpr MkEmptyRe(Sort s)
|
||||
public ReExpr MkEmptyRe(Sort s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_empty(nCtx, s.NativeObject));
|
||||
|
@ -2692,7 +2693,7 @@ namespace Microsoft.Z3
|
|||
/// Create the full regular expression.
|
||||
/// The sort s should be a regular expression.
|
||||
/// </summary>
|
||||
public ReExpr MkFullRe(Sort s)
|
||||
public ReExpr MkFullRe(Sort s)
|
||||
{
|
||||
Debug.Assert(s != null);
|
||||
return new ReExpr(this, Native.Z3_mk_re_full(nCtx, s.NativeObject));
|
||||
|
@ -2702,7 +2703,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a range expression.
|
||||
/// </summary>
|
||||
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
||||
public ReExpr MkRange(SeqExpr lo, SeqExpr hi)
|
||||
{
|
||||
Debug.Assert(lo != null);
|
||||
Debug.Assert(hi != null);
|
||||
|
@ -2713,7 +2714,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create less than or equal to between two characters.
|
||||
/// </summary>
|
||||
public BoolExpr MkCharLe(Expr ch1, Expr ch2)
|
||||
public BoolExpr MkCharLe(Expr ch1, Expr ch2)
|
||||
{
|
||||
Debug.Assert(ch1 != null);
|
||||
Debug.Assert(ch2 != null);
|
||||
|
@ -2723,7 +2724,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create an integer (code point) from character.
|
||||
/// </summary>
|
||||
public IntExpr CharToInt(Expr ch)
|
||||
public IntExpr CharToInt(Expr ch)
|
||||
{
|
||||
Debug.Assert(ch != null);
|
||||
return new IntExpr(this, Native.Z3_mk_char_to_int(nCtx, ch.NativeObject));
|
||||
|
@ -2732,7 +2733,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a bit-vector (code point) from character.
|
||||
/// </summary>
|
||||
public BitVecExpr CharToBV(Expr ch)
|
||||
public BitVecExpr CharToBV(Expr ch)
|
||||
{
|
||||
Debug.Assert(ch != null);
|
||||
return new BitVecExpr(this, Native.Z3_mk_char_to_bv(nCtx, ch.NativeObject));
|
||||
|
@ -2741,7 +2742,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a character from a bit-vector (code point).
|
||||
/// </summary>
|
||||
public Expr CharFromBV(BitVecExpr bv)
|
||||
public Expr CharFromBV(BitVecExpr bv)
|
||||
{
|
||||
Debug.Assert(bv != null);
|
||||
return new Expr(this, Native.Z3_mk_char_from_bv(nCtx, bv.NativeObject));
|
||||
|
@ -2750,7 +2751,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create a check if the character is a digit.
|
||||
/// </summary>
|
||||
public BoolExpr MkIsDigit(Expr ch)
|
||||
public BoolExpr MkIsDigit(Expr ch)
|
||||
{
|
||||
Debug.Assert(ch != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_char_is_digit(nCtx, ch.NativeObject));
|
||||
|
@ -2768,7 +2769,7 @@ namespace Microsoft.Z3
|
|||
Debug.Assert(args != null);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
var ts = args.ToArray();
|
||||
return new BoolExpr(this, Native.Z3_mk_atmost(nCtx, (uint) ts.Length,
|
||||
return new BoolExpr(this, Native.Z3_mk_atmost(nCtx, (uint)ts.Length,
|
||||
AST.ArrayToNative(ts), k));
|
||||
}
|
||||
|
||||
|
@ -2780,7 +2781,7 @@ namespace Microsoft.Z3
|
|||
Debug.Assert(args != null);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
var ts = args.ToArray();
|
||||
return new BoolExpr(this, Native.Z3_mk_atleast(nCtx, (uint) ts.Length,
|
||||
return new BoolExpr(this, Native.Z3_mk_atleast(nCtx, (uint)ts.Length,
|
||||
AST.ArrayToNative(ts), k));
|
||||
}
|
||||
|
||||
|
@ -2789,13 +2790,13 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k)
|
||||
{
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pble(nCtx, (uint) args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pble(nCtx, (uint)args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2803,26 +2804,26 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public BoolExpr MkPBGe(int[] coeffs, BoolExpr[] args, int k)
|
||||
{
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pbge(nCtx, (uint) args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pbge(nCtx, (uint)args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a pseudo-Boolean equal constraint.
|
||||
/// </summary>
|
||||
public BoolExpr MkPBEq(int[] coeffs, BoolExpr[] args, int k)
|
||||
{
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pbeq(nCtx, (uint) args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
Debug.Assert(args != null);
|
||||
Debug.Assert(coeffs != null);
|
||||
Debug.Assert(args.Length == coeffs.Length);
|
||||
CheckContextMatch<BoolExpr>(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pbeq(nCtx, (uint)args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -4085,7 +4086,7 @@ namespace Microsoft.Z3
|
|||
/// <param name="negative">indicates whether the result should be negative.</param>
|
||||
public FPNum MkFPZero(FPSort s, bool negative)
|
||||
{
|
||||
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, (byte)(negative ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4127,7 +4128,7 @@ namespace Microsoft.Z3
|
|||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
|
||||
{
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4139,7 +4140,7 @@ namespace Microsoft.Z3
|
|||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
|
||||
{
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, (byte)(sgn ? 1 : 0), exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -4825,12 +4826,12 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// ASTVector DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ASTVector_DRQ { get { return m_ASTVector_DRQ; } }
|
||||
public IDecRefQueue ASTVector_DRQ { get { return m_ASTVector_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// ApplyResult DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ApplyResult_DRQ { get { return m_ApplyResult_DRQ; } }
|
||||
public IDecRefQueue ApplyResult_DRQ { get { return m_ApplyResult_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// FuncEntry DRQ
|
||||
|
@ -4937,7 +4938,7 @@ namespace Microsoft.Z3
|
|||
m_ctx = IntPtr.Zero;
|
||||
Native.Z3_del_context(ctx);
|
||||
}
|
||||
else
|
||||
else
|
||||
GC.ReRegisterForFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,20 +19,11 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
using Z3_context = System.IntPtr;
|
||||
using Z3_ast = System.IntPtr;
|
||||
using Z3_app = System.IntPtr;
|
||||
using Z3_sort = System.IntPtr;
|
||||
using Z3_func_decl = System.IntPtr;
|
||||
using Z3_model = System.IntPtr;
|
||||
using Z3_func_interp = System.IntPtr;
|
||||
using Z3_func_entry = System.IntPtr;
|
||||
using Z3_sort = System.IntPtr;
|
||||
|
||||
/// <summary>
|
||||
/// A Model contains interpretations (assignments) of constants and functions.
|
||||
|
@ -67,7 +58,6 @@ namespace Microsoft.Z3
|
|||
/// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns>
|
||||
public NativeFuncInterp FuncInterp(Z3_func_decl f)
|
||||
{
|
||||
|
||||
Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f));
|
||||
|
||||
if (Native.Z3_get_arity(Context.nCtx, f) == 0)
|
||||
|
@ -235,7 +225,6 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public Z3_ast Evaluate(Z3_ast t, bool completion = false) => Eval(t, completion);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Evaluate expression to a double, assuming it is a numeral already.
|
||||
/// </summary>
|
||||
|
@ -253,12 +242,16 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// One dimensional array of indices where the array is updated
|
||||
/// </summary>
|
||||
public KeyValuePair<Z3_ast,Z3_ast>[] Updates;
|
||||
public KeyValuePair<Z3_ast, Z3_ast>[] Updates;
|
||||
|
||||
/// <summary>
|
||||
/// default Else case
|
||||
/// </summary>
|
||||
public Z3_ast Else;
|
||||
|
||||
public Z3_sort[] Domain;
|
||||
|
||||
public Z3_sort[] Range;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -266,26 +259,34 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns>null if the argument does evaluate to a sequence of stores to an array</returns>
|
||||
public ArrayValue TryGetArrayValue(Z3_ast t)
|
||||
public bool TryGetArrayValue(Z3_ast t, out ArrayValue result)
|
||||
{
|
||||
var r = Eval(t, true);
|
||||
// check that r is a sequence of store over a constant default array.
|
||||
var updates = new List<KeyValuePair<Z3_ast, Z3_ast>>();
|
||||
var result = new ArrayValue();
|
||||
while (true)
|
||||
{
|
||||
// check that r is an app, and the decl-kind is Z3_OP_ARRAY_CONST or Z3_OP_ARRAY_STORE
|
||||
// if it is Z3_OP_ARRAY_CONST then set result.Else and break;
|
||||
// if it is ARRAY_STORE, then append to 'updates' and continue
|
||||
// in other cases return null
|
||||
return null;
|
||||
|
||||
//while (true)
|
||||
//{
|
||||
// // check that r is an app, and the decl-kind is Z3_OP_ARRAY_CONST or Z3_OP_ARRAY_STORE
|
||||
// // if it is Z3_OP_ARRAY_CONST then set result.Else and break;
|
||||
// // if it is ARRAY_STORE, then append to 'updates' and continue
|
||||
// // in other cases return null
|
||||
// return false;
|
||||
|
||||
//}
|
||||
|
||||
if (updates.Any())
|
||||
{
|
||||
result = new ArrayValue()
|
||||
{
|
||||
Updates = updates.ToArray()
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
#if false
|
||||
result.Updates = updates.ToArray();
|
||||
|
||||
return null;
|
||||
#endif
|
||||
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -18,24 +18,16 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
|
||||
using Z3_context = System.IntPtr;
|
||||
using Z3_ast = System.IntPtr;
|
||||
using Z3_app = System.IntPtr;
|
||||
using Z3_sort = System.IntPtr;
|
||||
using Z3_context = System.IntPtr;
|
||||
using Z3_func_decl = System.IntPtr;
|
||||
using Z3_model = System.IntPtr;
|
||||
using Z3_ast_vector = System.IntPtr;
|
||||
using Z3_solver = System.IntPtr;
|
||||
using Z3_symbol = System.IntPtr;
|
||||
using Z3_params = System.IntPtr;
|
||||
using Z3_solver = System.IntPtr;
|
||||
using Z3_sort = System.IntPtr;
|
||||
using Z3_symbol = System.IntPtr;
|
||||
|
||||
/// <summary>
|
||||
/// Solvers.
|
||||
|
@ -45,21 +37,15 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// A string that describes all available solver parameters.
|
||||
/// </summary>
|
||||
public string Help
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.Z3_solver_get_help(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
public string Help => Native.Z3_solver_get_help(nCtx, z3solver);
|
||||
|
||||
private void SetParam(Action<Z3_params> setter)
|
||||
{
|
||||
Z3_params p = Native.Z3_mk_params(Context.nCtx);
|
||||
Native.Z3_params_inc_ref(Context.nCtx, p);
|
||||
Z3_params p = Native.Z3_mk_params(nCtx);
|
||||
Native.Z3_params_inc_ref(nCtx, p);
|
||||
setter(p);
|
||||
Native.Z3_solver_set_params(Context.nCtx, NativeObject, p);
|
||||
Native.Z3_params_dec_ref(Context.nCtx, p);
|
||||
Native.Z3_solver_set_params(nCtx, z3solver, p);
|
||||
Native.Z3_params_dec_ref(nCtx, p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -67,7 +53,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Set(string name, bool value)
|
||||
{
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_bool(Context.nCtx, p, Native.Z3_mk_string_symbol(Context.nCtx, name), (byte)(value ? 1 : 0)));
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_bool(nCtx, p, Native.Z3_mk_string_symbol(nCtx, name), (byte)(value ? 1 : 0)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -75,7 +61,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Set(string name, uint value)
|
||||
{
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_uint(Context.nCtx, p, Native.Z3_mk_string_symbol(Context.nCtx, name), value));
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_uint(nCtx, p, Native.Z3_mk_string_symbol(nCtx, name), value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -83,7 +69,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Set(string name, double value)
|
||||
{
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_double(Context.nCtx, p, Native.Z3_mk_string_symbol(Context.nCtx, name), value));
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_double(nCtx, p, Native.Z3_mk_string_symbol(nCtx, name), value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -91,43 +77,43 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Set(string name, string value)
|
||||
{
|
||||
var value_sym = Native.Z3_mk_string_symbol(Context.nCtx, value);
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_symbol(Context.nCtx, p, Native.Z3_mk_string_symbol(Context.nCtx, name), value_sym));
|
||||
var value_sym = Native.Z3_mk_string_symbol(nCtx, value);
|
||||
SetParam((Z3_params p) => Native.Z3_params_set_symbol(nCtx, p, Native.Z3_mk_string_symbol(nCtx, name), value_sym));
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(string name, Symbol value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, bool value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, uint value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, double value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, string value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, Symbol value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(string name, Symbol value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, bool value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, uint value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, double value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, string value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
/// <summary>
|
||||
/// Sets parameter on the solver
|
||||
/// </summary>
|
||||
public void Set(Symbol name, Symbol value) { Parameters = Context.MkParams().Add(name, value); }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves parameter descriptions for solver.
|
||||
/// </summary>
|
||||
public ParamDescrs ParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(Context, Native.Z3_solver_get_param_descrs(Context.nCtx, NativeObject)); }
|
||||
get { return new ParamDescrs(Context, Native.Z3_solver_get_param_descrs(nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
@ -135,38 +121,26 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
/// <seealso cref="Push"/>
|
||||
public uint NumScopes
|
||||
{
|
||||
get { return Native.Z3_solver_get_num_scopes(Context.nCtx, NativeObject); }
|
||||
}
|
||||
public uint NumScopes => Native.Z3_solver_get_num_scopes(nCtx, z3solver);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backtracking point.
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
public void Push()
|
||||
{
|
||||
Native.Z3_solver_push(Context.nCtx, NativeObject);
|
||||
}
|
||||
public void Push() => Native.Z3_solver_push(nCtx, z3solver);
|
||||
|
||||
/// <summary>
|
||||
/// Backtracks <paramref name="n"/> backtracking points.
|
||||
/// </summary>
|
||||
/// <remarks>Note that an exception is thrown if <paramref name="n"/> is not smaller than <c>NumScopes</c></remarks>
|
||||
/// <seealso cref="Push"/>
|
||||
public void Pop(uint n = 1)
|
||||
{
|
||||
Native.Z3_solver_pop(Context.nCtx, NativeObject, n);
|
||||
}
|
||||
public void Pop(uint n = 1) => Native.Z3_solver_pop(nCtx, z3solver, n);
|
||||
|
||||
/// <summary>
|
||||
/// Resets the Solver.
|
||||
/// </summary>
|
||||
/// <remarks>This removes all assertions from the solver.</remarks>
|
||||
public void Reset()
|
||||
{
|
||||
Native.Z3_solver_reset(Context.nCtx, NativeObject);
|
||||
}
|
||||
public void Reset() => Native.Z3_solver_reset(nCtx, z3solver);
|
||||
|
||||
/// <summary>
|
||||
/// Assert a constraint (or multiple) into the solver.
|
||||
|
@ -178,25 +152,19 @@ namespace Microsoft.Z3
|
|||
|
||||
foreach (Z3_ast a in constraints)
|
||||
{
|
||||
Native.Z3_solver_assert(Context.nCtx, NativeObject, a);
|
||||
Native.Z3_solver_assert(nCtx, z3solver, a);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alias for Assert.
|
||||
/// </summary>
|
||||
public void Add(params Z3_ast[] constraints)
|
||||
{
|
||||
Assert(constraints);
|
||||
}
|
||||
public void Add(params Z3_ast[] constraints) => Assert(constraints);
|
||||
|
||||
/// <summary>
|
||||
/// Alias for Assert.
|
||||
/// </summary>
|
||||
public void Add(IEnumerable<Z3_ast> constraints)
|
||||
{
|
||||
Assert(constraints.ToArray());
|
||||
}
|
||||
public void Add(IEnumerable<Z3_ast> constraints) => Assert(constraints.ToArray());
|
||||
|
||||
/// <summary>
|
||||
/// Add constraints to ensure the function f can only be injective.
|
||||
|
@ -209,28 +177,26 @@ namespace Microsoft.Z3
|
|||
/// <param name="f"></param>
|
||||
public void AssertInjective(Z3_func_decl f)
|
||||
{
|
||||
uint arity = Native.Z3_get_arity(Context.nCtx, f);
|
||||
Z3_sort range = Native.Z3_get_range(Context.nCtx, f);
|
||||
uint arity = Native.Z3_get_arity(nCtx, f);
|
||||
Z3_sort range = Native.Z3_get_range(nCtx, f);
|
||||
Z3_ast[] vars = new Z3_ast[arity];
|
||||
Z3_sort[] sorts = new Z3_sort[arity];
|
||||
Z3_symbol[] names = new Z3_symbol[arity];
|
||||
for (uint i = 0; i < arity; ++i)
|
||||
{
|
||||
Z3_sort domain = Native.Z3_get_domain(Context.nCtx, f, i);
|
||||
//vars[i] = Context.MkBound(arity - i - 1, domain);
|
||||
Z3_sort domain = Native.Z3_get_domain(nCtx, f, i);
|
||||
vars[i] = ntvContext.MkBound(arity - i - 1, domain);
|
||||
sorts[i] = domain;
|
||||
names[i] = Native.Z3_mk_int_symbol(Context.nCtx, (int)i);
|
||||
names[i] = Native.Z3_mk_int_symbol(nCtx, (int)i);
|
||||
}
|
||||
Z3_ast app_f = IntPtr.Zero; // Context.MkApp(f, vars);
|
||||
for (uint i = 0; i < arity; ++i)
|
||||
{
|
||||
Z3_sort domain = Native.Z3_get_domain(Context.nCtx, f, i);
|
||||
#if false
|
||||
Z3_func_decl proj = Native.Z3_mk_fresh_func_decl("inv", new Z3_sort[] { range }, domain);
|
||||
Z3_ast body = Context.MkEq(vars[i], Context.MkApp(proj, app_f));
|
||||
Z3_ast q = Context.MkForall(names, sorts, body);
|
||||
Z3_sort domain = Native.Z3_get_domain(nCtx, f, i);
|
||||
Z3_func_decl proj = ntvContext.MkFreshFuncDecl("inv", new Z3_sort[] { range }, domain);
|
||||
Z3_ast body = ntvContext.MkEq(vars[i], ntvContext.MkApp(proj, app_f));
|
||||
Z3_ast q = ntvContext.MkForall(names, sorts, body);
|
||||
Assert(q);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +220,7 @@ namespace Microsoft.Z3
|
|||
throw new Z3Exception("Argument size mismatch");
|
||||
|
||||
for (int i = 0; i < constraints.Length; i++)
|
||||
Native.Z3_solver_assert_and_track(Context.nCtx, NativeObject, constraints[i], ps[i]);
|
||||
Native.Z3_solver_assert_and_track(nCtx, z3solver, constraints[i], ps[i]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -273,57 +239,38 @@ namespace Microsoft.Z3
|
|||
Debug.Assert(constraint != null);
|
||||
Debug.Assert(p != null);
|
||||
|
||||
Native.Z3_solver_assert_and_track(Context.nCtx, NativeObject, constraint, p);
|
||||
Native.Z3_solver_assert_and_track(nCtx, z3solver, constraint, p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load solver assertions from a file.
|
||||
/// </summary>
|
||||
public void FromFile(string file)
|
||||
{
|
||||
Native.Z3_solver_from_file(Context.nCtx, NativeObject, file);
|
||||
}
|
||||
=> Native.Z3_solver_from_file(nCtx, z3solver, file);
|
||||
|
||||
/// <summary>
|
||||
/// Load solver assertions from a string.
|
||||
/// </summary>
|
||||
public void FromString(string str)
|
||||
{
|
||||
Native.Z3_solver_from_string(Context.nCtx, NativeObject, str);
|
||||
}
|
||||
=> Native.Z3_solver_from_string(nCtx, z3solver, str);
|
||||
|
||||
/// <summary>
|
||||
/// The number of assertions in the solver.
|
||||
/// </summary>
|
||||
public uint NumAssertions
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint)Context.ToArray(Native.Z3_solver_get_assertions(Context.nCtx, NativeObject)).Length;
|
||||
}
|
||||
}
|
||||
=> (uint)ntvContext.ToArray(Native.Z3_solver_get_assertions(nCtx, z3solver)).Length;
|
||||
|
||||
/// <summary>
|
||||
/// The set of asserted formulas.
|
||||
/// </summary>
|
||||
public Z3_ast[] Assertions
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.ToArray(Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
=> ntvContext.ToArray(Native.Z3_solver_get_assertions(nCtx, z3solver));
|
||||
|
||||
/// <summary>
|
||||
/// Currently inferred units.
|
||||
/// </summary>
|
||||
public Z3_ast[] Units
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.ToArray(Native.Z3_solver_get_units(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
=> ntvContext.ToArray(Native.Z3_solver_get_units(nCtx, z3solver));
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the assertions in the solver are consistent or not.
|
||||
|
@ -337,9 +284,9 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Z3_lbool r;
|
||||
if (assumptions == null || assumptions.Length == 0)
|
||||
r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject);
|
||||
r = (Z3_lbool)Native.Z3_solver_check(nCtx, z3solver);
|
||||
else
|
||||
r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)assumptions.Length, assumptions);
|
||||
r = (Z3_lbool)Native.Z3_solver_check_assumptions(nCtx, z3solver, (uint)assumptions.Length, assumptions);
|
||||
return lboolToStatus(r);
|
||||
}
|
||||
|
||||
|
@ -356,13 +303,12 @@ namespace Microsoft.Z3
|
|||
Z3_lbool r;
|
||||
Z3_ast[] asms = assumptions.ToArray();
|
||||
if (asms.Length == 0)
|
||||
r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject);
|
||||
r = (Z3_lbool)Native.Z3_solver_check(nCtx, z3solver);
|
||||
else
|
||||
r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)asms.Length, asms);
|
||||
r = (Z3_lbool)Native.Z3_solver_check_assumptions(nCtx, z3solver, (uint)asms.Length, asms);
|
||||
return lboolToStatus(r);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The model of the last <c>Check(params Expr[] assumptions)</c>.
|
||||
/// </summary>
|
||||
|
@ -374,11 +320,10 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
IntPtr x = Native.Z3_solver_get_model(Context.nCtx, NativeObject);
|
||||
if (x == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return new NativeModel(Context, x);
|
||||
IntPtr x = Native.Z3_solver_get_model(nCtx, z3solver);
|
||||
return x == IntPtr.Zero
|
||||
? null
|
||||
: new NativeModel(ntvContext, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,12 +335,7 @@ namespace Microsoft.Z3
|
|||
/// if its results was not <c>UNSATISFIABLE</c>, or if proof production is disabled.
|
||||
/// </remarks>
|
||||
public Z3_ast Proof
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.Z3_solver_get_proof(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
=> Native.Z3_solver_get_proof(nCtx, z3solver);
|
||||
|
||||
/// <summary>
|
||||
/// The unsat core of the last <c>Check</c>.
|
||||
|
@ -406,23 +346,13 @@ namespace Microsoft.Z3
|
|||
/// if its results was not <c>UNSATISFIABLE</c>, or if core production is disabled.
|
||||
/// </remarks>
|
||||
public Z3_ast[] UnsatCore
|
||||
{
|
||||
get
|
||||
{
|
||||
return Context.ToArray(Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
=> ntvContext.ToArray(Native.Z3_solver_get_unsat_core(nCtx, z3solver));
|
||||
|
||||
/// <summary>
|
||||
/// A brief justification of why the last call to <c>Check</c> returned <c>UNKNOWN</c>.
|
||||
/// </summary>
|
||||
public string ReasonUnknown
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.Z3_solver_get_reason_unknown(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
=> Native.Z3_solver_get_reason_unknown(nCtx, z3solver);
|
||||
|
||||
/// <summary>
|
||||
/// Create a clone of the current solver with respect to <c>ctx</c>.
|
||||
|
@ -430,7 +360,7 @@ namespace Microsoft.Z3
|
|||
public NativeSolver Translate(NativeContext ctx)
|
||||
{
|
||||
Debug.Assert(ctx != null);
|
||||
return new NativeSolver(ctx, Native.Z3_solver_translate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
return new NativeSolver(ctx, Native.Z3_solver_translate(nCtx, z3solver, ctx.nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -438,9 +368,10 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void ImportModelConverter(NativeSolver src)
|
||||
{
|
||||
Native.Z3_solver_import_model_converter(Context.nCtx, src.NativeObject, NativeObject);
|
||||
}
|
||||
Debug.Assert(src != null);
|
||||
|
||||
Native.Z3_solver_import_model_converter(nCtx, src.z3solver, z3solver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solver statistics.
|
||||
|
@ -449,8 +380,8 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
var stats = Native.Z3_solver_get_statistics(Context.nCtx, NativeObject);
|
||||
return Context.GetStatistics(stats);
|
||||
var stats = Native.Z3_solver_get_statistics(nCtx, z3solver);
|
||||
return ntvContext.GetStatistics(stats);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,19 +390,23 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_solver_to_string(Context.nCtx, NativeObject);
|
||||
return Native.Z3_solver_to_string(nCtx, z3solver);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
NativeContext Context;
|
||||
IntPtr NativeObject;
|
||||
internal NativeSolver(NativeContext ctx, Z3_solver obj)
|
||||
{
|
||||
Context = ctx;
|
||||
NativeObject = obj;
|
||||
readonly NativeContext ntvContext;
|
||||
Z3_solver z3solver;
|
||||
Z3_context nCtx => ntvContext.nCtx;
|
||||
|
||||
Debug.Assert(ctx != null);
|
||||
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
|
||||
internal NativeSolver(NativeContext nativeCtx, Z3_solver z3solver)
|
||||
{
|
||||
Debug.Assert(nCtx != IntPtr.Zero);
|
||||
Debug.Assert(z3solver != IntPtr.Zero);
|
||||
|
||||
this.ntvContext = nativeCtx;
|
||||
this.z3solver = z3solver;
|
||||
|
||||
Native.Z3_solver_inc_ref(nCtx, z3solver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -487,10 +422,10 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (NativeObject != IntPtr.Zero)
|
||||
if (z3solver != IntPtr.Zero)
|
||||
{
|
||||
Native.Z3_solver_dec_ref(Context.nCtx, NativeObject);
|
||||
NativeObject = IntPtr.Zero;
|
||||
Native.Z3_solver_dec_ref(nCtx, z3solver);
|
||||
z3solver = IntPtr.Zero;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue