diff --git a/src/api/dotnet/NativeModel.cs b/src/api/dotnet/NativeModel.cs
index 8a31af32f..234f3759d 100644
--- a/src/api/dotnet/NativeModel.cs
+++ b/src/api/dotnet/NativeModel.cs
@@ -37,7 +37,7 @@ namespace Microsoft.Z3
///
/// A Model contains interpretations (assignments) of constants and functions.
///
- public class NativeModel
+ public class NativeModel : IDisposable
{
///
/// Retrieves the interpretation (the assignment) of in the model.
@@ -155,28 +155,28 @@ namespace Microsoft.Z3
get { return Native.Z3_model_get_num_funcs(Context.nCtx, NativeObject); }
}
-#if false
///
/// The function declarations of the function interpretations in the model.
///
- public FuncDecl[] FuncDecls
+ public Z3_func_decl[] FuncDecls
{
get
{
uint n = NumFuncs;
- FuncDecl[] res = new FuncDecl[n];
+ Z3_func_decl[] res = new Z3_func_decl[n];
for (uint i = 0; i < n; i++)
- res[i] = new FuncDecl(Context, Native.Z3_model_get_func_decl(Context.nCtx, NativeObject, i));
+ res[i] = Native.Z3_model_get_func_decl(Context.nCtx, NativeObject, i);
return res;
}
}
+
///
/// All symbols that have an interpretation in the model.
///
- public FuncDecl[] Decls
+ public Z3_func_decl[] Decls
{
get
{
@@ -184,11 +184,11 @@ namespace Microsoft.Z3
uint nFuncs = NumFuncs;
uint nConsts = NumConsts;
uint n = nFuncs + nConsts;
- FuncDecl[] res = new FuncDecl[n];
+ Z3_func_decl[] res = new Z3_func_decl[n];
for (uint i = 0; i < nConsts; i++)
- res[i] = new FuncDecl(Context, Native.Z3_model_get_const_decl(Context.nCtx, NativeObject, i));
+ res[i] = Native.Z3_model_get_const_decl(Context.nCtx, NativeObject, i);
for (uint i = 0; i < nFuncs; i++)
- res[nConsts + i] = new FuncDecl(Context, Native.Z3_model_get_func_decl(Context.nCtx, NativeObject, i));
+ res[nConsts + i] = Native.Z3_model_get_func_decl(Context.nCtx, NativeObject, i);
return res;
}
}
@@ -204,6 +204,7 @@ namespace Microsoft.Z3
public ModelEvaluationFailedException() : base() { }
}
+
///
/// Evaluates the expression in the current model.
///
@@ -220,24 +221,19 @@ namespace Microsoft.Z3
/// The evaluation of in the model.
public Z3_ast Eval(Z3_ast t, bool completion = false)
{
- Debug.Assert(t != null);
IntPtr v = IntPtr.Zero;
- if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (byte)(completion ? 1 : 0), ref v) == (byte)0)
+ if (Native.Z3_model_eval(Context.nCtx, NativeObject, t, (byte)(completion ? 1 : 0), ref v) == (byte)0)
throw new ModelEvaluationFailedException();
else
- return Z3_ast.Create(Context, v);
+ return v;
}
///
/// Alias for Eval.
///
- public Z3_ast Evaluate(Z3_ast t, bool completion = false)
- {
- Debug.Assert(t != null);
+ public Z3_ast Evaluate(Z3_ast t, bool completion = false) => Eval(t, completion);
- return Eval(t, completion);
- }
///
/// Evaluate expression to a double, assuming it is a numeral already.
@@ -252,6 +248,7 @@ namespace Microsoft.Z3
///
public uint NumSorts { get { return Native.Z3_model_get_num_sorts(Context.nCtx, NativeObject); } }
+
///
/// The uninterpreted sorts that the model has an interpretation for.
///
@@ -262,20 +259,19 @@ namespace Microsoft.Z3
///
///
///
- public Sort[] Sorts
+ public Z3_sort[] Sorts
{
get
{
uint n = NumSorts;
- Sort[] res = new Sort[n];
+ Z3_sort[] res = new Z3_sort[n];
for (uint i = 0; i < n; i++)
- res[i] = Sort.Create(Context, Native.Z3_model_get_sort(Context.nCtx, NativeObject, i));
+ res[i] = Native.Z3_model_get_sort(Context.nCtx, NativeObject, i);
return res;
}
}
-#endif
///
/// Conversion of models to strings.
@@ -287,7 +283,6 @@ namespace Microsoft.Z3
}
-
IntPtr NativeObject;
NativeContext Context;