mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
add shorthand for enumerating constants in a model
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2908ab4069
commit
efd5727676
|
@ -19,6 +19,7 @@ Notes:
|
|||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
|
@ -131,6 +132,24 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumerate constants in model.
|
||||
/// </summary>
|
||||
public IEnumerable<KeyValuePair<FuncDecl, Expr>> Consts
|
||||
{
|
||||
get
|
||||
{
|
||||
uint nc = NumConsts;
|
||||
for (uint i = 0; i < nc; ++i)
|
||||
{
|
||||
var f = new FuncDecl(Context, Native.Z3_model_get_const_decl(Context.nCtx, NativeObject, i));
|
||||
IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject);
|
||||
if (n == IntPtr.Zero) continue;
|
||||
yield return new KeyValuePair<FuncDecl, Expr>(f, Expr.Create(Context, n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of function interpretations in the model.
|
||||
/// </summary>
|
||||
|
|
|
@ -326,7 +326,6 @@ public:
|
|||
return l_true;
|
||||
}
|
||||
|
||||
|
||||
virtual std::string reason_unknown() const {
|
||||
return m_unknown;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue