mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 19:05:51 +00:00
other components
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
e9eab22e5c
commit
68269c43a6
250 changed files with 70871 additions and 0 deletions
95
Microsoft.Z3/Probe.cs
Normal file
95
Microsoft.Z3/Probe.cs
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Probe.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Probes
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Probes are used to inspect a goal (aka problem) and collect information that may be used to decide
|
||||
/// which solver and/or preprocessing step will be used.
|
||||
/// The complete list of probes may be obtained using the procedures <c>Context.NumProbes</c>
|
||||
/// and <c>Context.ProbeNames</c>.
|
||||
/// It may also be obtained using the command <c>(help-tactics)</c> in the SMT 2.0 front-end.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Probe : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Execute the probe over the goal.
|
||||
/// </summary>
|
||||
/// <returns>A probe always produce a double value.
|
||||
/// "Boolean" probes return 0.0 for false, and a value different from 0.0 for true.</returns>
|
||||
public double Apply(Goal g)
|
||||
{
|
||||
Contract.Requires(g != null);
|
||||
|
||||
Context.CheckContextMatch(g);
|
||||
return Native.Z3_probe_apply(Context.nCtx, NativeObject, g.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply the probe to a goal.
|
||||
/// </summary>
|
||||
public double this[Goal g] { get {
|
||||
Contract.Requires(g != null);
|
||||
|
||||
return Apply(g); } }
|
||||
|
||||
#region Internal
|
||||
internal Probe(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal Probe(Context ctx, string name)
|
||||
: base(ctx, Native.Z3_mk_probe(ctx.nCtx, name))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_probe_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_probe_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Probe_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Probe_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue