mirror of
https://github.com/Z3Prover/z3
synced 2025-07-18 02:16:40 +00:00
reorganizing the code
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
61bd5a69ec
commit
12a255e36b
195 changed files with 11 additions and 526 deletions
260
src/bindings/dotnet/Microsoft.Z3/AST.cs
Normal file
260
src/bindings/dotnet/Microsoft.Z3/AST.cs
Normal file
|
@ -0,0 +1,260 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
AST.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: ASTs
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The abstract syntax tree (AST) class.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class AST : Z3Object, IComparable
|
||||
{
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <param name="a">An AST</param>
|
||||
/// <param name="b">An AST</param>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> are from the same context
|
||||
/// and represent the same sort; false otherwise.</returns>
|
||||
public static bool operator ==(AST a, AST b)
|
||||
{
|
||||
return Object.ReferenceEquals(a, b) ||
|
||||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context.nCtx == b.Context.nCtx &&
|
||||
Native.Z3_is_eq_ast(a.Context.nCtx, a.NativeObject, b.NativeObject) != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <param name="a">An AST</param>
|
||||
/// <param name="b">An AST</param>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> are not from the same context
|
||||
/// or represent different sorts; false otherwise.</returns>
|
||||
public static bool operator !=(AST a, AST b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object comparison.
|
||||
/// </summary>
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
AST casted = o as AST;
|
||||
if (casted == null) return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object Comparison.
|
||||
/// </summary>
|
||||
/// <param name="other">Another AST</param>
|
||||
/// <returns>Negative if the object should be sorted before <paramref name="other"/>, positive if after else zero.</returns>
|
||||
public virtual int CompareTo(object other)
|
||||
{
|
||||
if (other == null) return 1;
|
||||
AST oAST = other as AST;
|
||||
if (oAST == null)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if (Id < oAST.Id)
|
||||
return -1;
|
||||
else if (Id > oAST.Id)
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The AST's hash code.
|
||||
/// </summary>
|
||||
/// <returns>A hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)Native.Z3_get_ast_hash(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A unique identifier for the AST (unique among all ASTs).
|
||||
/// </summary>
|
||||
public uint Id
|
||||
{
|
||||
get { return Native.Z3_get_ast_id(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates (copies) the AST to the Context <paramref name="ctx"/>.
|
||||
/// </summary>
|
||||
/// <param name="ctx">A context</param>
|
||||
/// <returns>A copy of the AST which is associated with <paramref name="ctx"/></returns>
|
||||
public AST Translate(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Ensures(Contract.Result<AST>() != null);
|
||||
|
||||
if (ReferenceEquals(Context, ctx))
|
||||
return this;
|
||||
else
|
||||
return new AST(ctx, Native.Z3_translate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the AST.
|
||||
/// </summary>
|
||||
public Z3_ast_kind ASTKind
|
||||
{
|
||||
get { return (Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the AST is an Expr
|
||||
/// </summary>
|
||||
public bool IsExpr
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (ASTKind)
|
||||
{
|
||||
case Z3_ast_kind.Z3_APP_AST:
|
||||
case Z3_ast_kind.Z3_NUMERAL_AST:
|
||||
case Z3_ast_kind.Z3_QUANTIFIER_AST:
|
||||
case Z3_ast_kind.Z3_VAR_AST: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the AST is a BoundVariable
|
||||
/// </summary>
|
||||
public bool IsVar
|
||||
{
|
||||
get { return this.ASTKind == Z3_ast_kind.Z3_VAR_AST; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the AST is a Quantifier
|
||||
/// </summary>
|
||||
public bool IsQuantifier
|
||||
{
|
||||
get { return this.ASTKind == Z3_ast_kind.Z3_QUANTIFIER_AST; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the AST is a Sort
|
||||
/// </summary>
|
||||
public bool IsSort
|
||||
{
|
||||
get { return this.ASTKind == Z3_ast_kind.Z3_SORT_AST; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the AST is a FunctionDeclaration
|
||||
/// </summary>
|
||||
public bool IsFuncDecl
|
||||
{
|
||||
get { return this.ASTKind == Z3_ast_kind.Z3_FUNC_DECL_AST; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the AST.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_ast_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the AST in s-expression notation.
|
||||
/// </summary>
|
||||
public string SExpr()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_ast_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal AST(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
internal AST(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST IncRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("inc() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("inc() called on null AST");
|
||||
Context.AST_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST DecRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("dec() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("dec() called on null AST");
|
||||
Context.AST_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
|
||||
internal static AST Create(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Ensures(Contract.Result<AST>() != null);
|
||||
|
||||
switch ((Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj))
|
||||
{
|
||||
case Z3_ast_kind.Z3_FUNC_DECL_AST: return new FuncDecl(ctx, obj);
|
||||
case Z3_ast_kind.Z3_QUANTIFIER_AST: return new Quantifier(ctx, obj);
|
||||
case Z3_ast_kind.Z3_SORT_AST: return Sort.Create(ctx, obj);
|
||||
case Z3_ast_kind.Z3_APP_AST:
|
||||
case Z3_ast_kind.Z3_NUMERAL_AST:
|
||||
case Z3_ast_kind.Z3_VAR_AST: return Expr.Create(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown AST kind");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
155
src/bindings/dotnet/Microsoft.Z3/ASTMap.cs
Normal file
155
src/bindings/dotnet/Microsoft.Z3/ASTMap.cs
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ASTMap.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: AST Maps
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Map from AST to AST
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
internal class ASTMap : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks whether the map contains the key <paramref name="k"/>.
|
||||
/// </summary>
|
||||
/// <param name="k">An AST</param>
|
||||
/// <returns>True if <paramref name="k"/> is a key in the map, false otherwise.</returns>
|
||||
public bool Contains(AST k)
|
||||
{
|
||||
Contract.Requires(k != null);
|
||||
|
||||
return Native.Z3_ast_map_contains(Context.nCtx, NativeObject, k.NativeObject) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the value associated with the key <paramref name="k"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function signs an error when <paramref name="k"/> is not a key in the map.
|
||||
/// </remarks>
|
||||
/// <param name="k">An AST</param>
|
||||
public AST Find(AST k)
|
||||
{
|
||||
Contract.Requires(k != null);
|
||||
Contract.Ensures(Contract.Result<AST>() != null);
|
||||
|
||||
return new AST(Context, Native.Z3_ast_map_find(Context.nCtx, NativeObject, k.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores or replaces a new key/value pair in the map.
|
||||
/// </summary>
|
||||
/// <param name="k">The key AST</param>
|
||||
/// <param name="v">The value AST</param>
|
||||
public void Insert(AST k, AST v)
|
||||
{
|
||||
Contract.Requires(k != null);
|
||||
Contract.Requires(v != null);
|
||||
|
||||
Native.Z3_ast_map_insert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases the key <paramref name="k"/> from the map.
|
||||
/// </summary>
|
||||
/// <param name="k">An AST</param>
|
||||
public void Erase(AST k)
|
||||
{
|
||||
Contract.Requires(k != null);
|
||||
|
||||
Native.Z3_ast_map_erase(Context.nCtx, NativeObject, k.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all keys from the map.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
Native.Z3_ast_map_reset(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The size of the map
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_ast_map_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The keys stored in the map.
|
||||
/// </summary>
|
||||
public ASTVector Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ASTVector(Context, Native.Z3_ast_map_keys(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a string representation of the map.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_ast_map_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ASTMap(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal ASTMap(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_ast_map(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_map_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_map_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ASTMap_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ASTMap_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
132
src/bindings/dotnet/Microsoft.Z3/ASTVector.cs
Normal file
132
src/bindings/dotnet/Microsoft.Z3/ASTVector.cs
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ASTVector.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: AST Vectors
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Vectors of ASTs.
|
||||
/// </summary>
|
||||
internal class ASTVector : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the vector
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_ast_vector_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the i-th object in the vector.
|
||||
/// </summary>
|
||||
/// <remarks>May throw an IndexOutOfBoundsException when <paramref name="i"/> is out of range.</remarks>
|
||||
/// <param name="i">Index</param>
|
||||
/// <returns>An AST</returns>
|
||||
public AST this[uint i]
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<AST>() != null);
|
||||
|
||||
return new AST(Context, Native.Z3_ast_vector_get(Context.nCtx, NativeObject, i));
|
||||
}
|
||||
set
|
||||
{
|
||||
Contract.Requires(value!= null);
|
||||
|
||||
Native.Z3_ast_vector_set(Context.nCtx, NativeObject, i, value.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resize the vector to <paramref name="newSize"/>.
|
||||
/// </summary>
|
||||
/// <param name="newSize">The new size of the vector.</param>
|
||||
public void Resize(uint newSize)
|
||||
{
|
||||
Native.Z3_ast_vector_resize(Context.nCtx, NativeObject, newSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the AST <paramref name="a"/> to the back of the vector. The size
|
||||
/// is increased by 1.
|
||||
/// </summary>
|
||||
/// <param name="a">An AST</param>
|
||||
public void Push(AST a)
|
||||
{
|
||||
Contract.Requires(a != null);
|
||||
|
||||
Native.Z3_ast_vector_push(Context.nCtx, NativeObject, a.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates all ASTs in the vector to <paramref name="ctx"/>.
|
||||
/// </summary>
|
||||
/// <param name="ctx">A context</param>
|
||||
/// <returns>A new ASTVector</returns>
|
||||
public ASTVector Translate(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Ensures(Contract.Result<ASTVector>() != null);
|
||||
|
||||
return new ASTVector(Context, Native.Z3_ast_vector_translate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a string representation of the vector.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_ast_vector_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_vector_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_vector_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ASTVector_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ASTVector_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
111
src/bindings/dotnet/Microsoft.Z3/ApplyResult.cs
Normal file
111
src/bindings/dotnet/Microsoft.Z3/ApplyResult.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ApplyResult.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Result object for tactic applications
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// ApplyResult objects represent the result of an application of a
|
||||
/// tactic to a goal. It contains the subgoals that were produced.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class ApplyResult : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of Subgoals.
|
||||
/// </summary>
|
||||
public uint NumSubgoals
|
||||
{
|
||||
get { return Native.Z3_apply_result_get_num_subgoals(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the subgoals from the ApplyResult.
|
||||
/// </summary>
|
||||
public Goal[] Subgoals
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Goal[]>() != null);
|
||||
Contract.Ensures(Contract.Result<Goal[]>().Length == this.NumSubgoals);
|
||||
|
||||
uint n = NumSubgoals;
|
||||
Goal[] res = new Goal[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new Goal(Context, Native.Z3_apply_result_get_subgoal(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a model for the subgoal <paramref name="i"/> into a model for the original
|
||||
/// goal <c>g</c>, that the ApplyResult was obtained from.
|
||||
/// </summary>
|
||||
/// <returns>A model for <c>g</c></returns>
|
||||
public Model ConvertModel(uint i, Model m)
|
||||
{
|
||||
Contract.Requires(m != null);
|
||||
Contract.Ensures(Contract.Result<Model>() != null);
|
||||
|
||||
return new Model(Context, Native.Z3_apply_result_convert_model(Context.nCtx, NativeObject, i, m.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the ApplyResult.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_apply_result_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ApplyResult(Context ctx, IntPtr obj) : base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_apply_result_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_apply_result_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ApplyResult_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ApplyResult_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
170
src/bindings/dotnet/Microsoft.Z3/Constructor.cs
Normal file
170
src/bindings/dotnet/Microsoft.Z3/Constructor.cs
Normal file
|
@ -0,0 +1,170 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Constructor.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Constructors
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-22
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructors are used for datatype sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Constructor : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of fields of the constructor.
|
||||
/// </summary>
|
||||
public uint NumFields
|
||||
{
|
||||
get { init(); return n; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The function declaration of the constructor.
|
||||
/// </summary>
|
||||
public FuncDecl ConstructorDecl
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
init(); return m_constructorDecl; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The function declaration of the tester.
|
||||
/// </summary>
|
||||
public FuncDecl TesterDecl
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
init(); return m_testerDecl; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The function declarations of the accessors
|
||||
/// </summary>
|
||||
public FuncDecl[] AccessorDecls
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
init(); return m_accessorDecls; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destructor.
|
||||
/// </summary>
|
||||
~Constructor()
|
||||
{
|
||||
Native.Z3_del_constructor(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Object invariant
|
||||
|
||||
[ContractInvariantMethod]
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(m_testerDecl == null || m_constructorDecl != null);
|
||||
Contract.Invariant(m_testerDecl == null || m_accessorDecls != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
readonly private uint n = 0;
|
||||
private FuncDecl m_testerDecl = null;
|
||||
private FuncDecl m_constructorDecl = null;
|
||||
private FuncDecl[] m_accessorDecls = null;
|
||||
|
||||
internal Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames,
|
||||
Sort[] sorts, uint[] sortRefs)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(recognizer != null);
|
||||
|
||||
n = AST.ArrayLength(fieldNames);
|
||||
|
||||
if (n != AST.ArrayLength(sorts))
|
||||
throw new Z3Exception("Number of field names does not match number of sorts");
|
||||
if (sortRefs != null && sortRefs.Length != n)
|
||||
throw new Z3Exception("Number of field names does not match number of sort refs");
|
||||
|
||||
if (sortRefs == null) sortRefs = new uint[n];
|
||||
|
||||
NativeObject = Native.Z3_mk_constructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject,
|
||||
n,
|
||||
Symbol.ArrayToNative(fieldNames),
|
||||
Sort.ArrayToNative(sorts),
|
||||
sortRefs);
|
||||
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
Contract.Ensures(m_constructorDecl != null);
|
||||
Contract.Ensures(m_testerDecl != null);
|
||||
Contract.Ensures(m_accessorDecls != null);
|
||||
|
||||
if (m_testerDecl != null) return;
|
||||
IntPtr constructor = IntPtr.Zero;
|
||||
IntPtr tester = IntPtr.Zero;
|
||||
IntPtr[] accessors = new IntPtr[n];
|
||||
Native.Z3_query_constructor(Context.nCtx, NativeObject, n, ref constructor, ref tester, accessors);
|
||||
m_constructorDecl = new FuncDecl(Context, constructor);
|
||||
m_testerDecl = new FuncDecl(Context, tester);
|
||||
m_accessorDecls = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
m_accessorDecls[i] = new FuncDecl(Context, accessors[i]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists of constructors
|
||||
/// </summary>
|
||||
public class ConstructorList : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Destructor.
|
||||
/// </summary>
|
||||
~ConstructorList()
|
||||
{
|
||||
Native.Z3_del_constructor_list(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ConstructorList(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal ConstructorList(Context ctx, Constructor[] constructors)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(constructors != null);
|
||||
|
||||
NativeObject = Native.Z3_mk_constructor_list(Context.nCtx, (uint)constructors.Length, Constructor.ArrayToNative(constructors));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
3690
src/bindings/dotnet/Microsoft.Z3/Context.cs
Normal file
3690
src/bindings/dotnet/Microsoft.Z3/Context.cs
Normal file
File diff suppressed because it is too large
Load diff
92
src/bindings/dotnet/Microsoft.Z3/DecRefQUeue.cs
Normal file
92
src/bindings/dotnet/Microsoft.Z3/DecRefQUeue.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
DecRefQueue.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: DecRef Queues
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
[ContractClass(typeof(DecRefQueueContracts))]
|
||||
internal abstract class DecRefQueue
|
||||
{
|
||||
#region Object invariant
|
||||
|
||||
[ContractInvariantMethod]
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(this.m_queue != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
readonly internal protected Object m_lock = new Object();
|
||||
readonly internal protected List<IntPtr> m_queue = new List<IntPtr>();
|
||||
internal const uint m_move_limit = 1024;
|
||||
|
||||
public abstract void IncRef(Context ctx, IntPtr obj);
|
||||
public abstract void DecRef(Context ctx, IntPtr obj);
|
||||
|
||||
public void IncAndClear(Context ctx, IntPtr o)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
IncRef(ctx, o);
|
||||
if (m_queue.Count >= m_move_limit) Clear(ctx);
|
||||
}
|
||||
|
||||
public void Add(IntPtr o)
|
||||
{
|
||||
if (o == IntPtr.Zero) return;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
m_queue.Add(o);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
foreach (IntPtr o in m_queue)
|
||||
DecRef(ctx, o);
|
||||
m_queue.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ContractClassFor(typeof(DecRefQueue))]
|
||||
abstract class DecRefQueueContracts : DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
}
|
||||
}
|
258
src/bindings/dotnet/Microsoft.Z3/Enumerations.cs
Normal file
258
src/bindings/dotnet/Microsoft.Z3/Enumerations.cs
Normal file
|
@ -0,0 +1,258 @@
|
|||
// Automatically generated file, generator: update_api.py
|
||||
|
||||
using System;
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>Z3_lbool</summary>
|
||||
public enum Z3_lbool {
|
||||
Z3_L_TRUE = 1,
|
||||
Z3_L_UNDEF = 0,
|
||||
Z3_L_FALSE = -1,
|
||||
}
|
||||
|
||||
/// <summary>Z3_symbol_kind</summary>
|
||||
public enum Z3_symbol_kind {
|
||||
Z3_INT_SYMBOL = 0,
|
||||
Z3_STRING_SYMBOL = 1,
|
||||
}
|
||||
|
||||
/// <summary>Z3_parameter_kind</summary>
|
||||
public enum Z3_parameter_kind {
|
||||
Z3_PARAMETER_FUNC_DECL = 6,
|
||||
Z3_PARAMETER_DOUBLE = 1,
|
||||
Z3_PARAMETER_SYMBOL = 3,
|
||||
Z3_PARAMETER_INT = 0,
|
||||
Z3_PARAMETER_AST = 5,
|
||||
Z3_PARAMETER_SORT = 4,
|
||||
Z3_PARAMETER_RATIONAL = 2,
|
||||
}
|
||||
|
||||
/// <summary>Z3_sort_kind</summary>
|
||||
public enum Z3_sort_kind {
|
||||
Z3_BV_SORT = 4,
|
||||
Z3_FINITE_DOMAIN_SORT = 8,
|
||||
Z3_ARRAY_SORT = 5,
|
||||
Z3_UNKNOWN_SORT = 1000,
|
||||
Z3_RELATION_SORT = 7,
|
||||
Z3_REAL_SORT = 3,
|
||||
Z3_INT_SORT = 2,
|
||||
Z3_UNINTERPRETED_SORT = 0,
|
||||
Z3_BOOL_SORT = 1,
|
||||
Z3_DATATYPE_SORT = 6,
|
||||
}
|
||||
|
||||
/// <summary>Z3_ast_kind</summary>
|
||||
public enum Z3_ast_kind {
|
||||
Z3_VAR_AST = 2,
|
||||
Z3_SORT_AST = 4,
|
||||
Z3_QUANTIFIER_AST = 3,
|
||||
Z3_UNKNOWN_AST = 1000,
|
||||
Z3_FUNC_DECL_AST = 5,
|
||||
Z3_NUMERAL_AST = 0,
|
||||
Z3_APP_AST = 1,
|
||||
}
|
||||
|
||||
/// <summary>Z3_decl_kind</summary>
|
||||
public enum Z3_decl_kind {
|
||||
Z3_OP_LABEL = 1792,
|
||||
Z3_OP_PR_REWRITE = 1294,
|
||||
Z3_OP_UNINTERPRETED = 2051,
|
||||
Z3_OP_SUB = 519,
|
||||
Z3_OP_ZERO_EXT = 1058,
|
||||
Z3_OP_ADD = 518,
|
||||
Z3_OP_IS_INT = 528,
|
||||
Z3_OP_BREDOR = 1061,
|
||||
Z3_OP_BNOT = 1051,
|
||||
Z3_OP_BNOR = 1054,
|
||||
Z3_OP_PR_CNF_STAR = 1315,
|
||||
Z3_OP_RA_JOIN = 1539,
|
||||
Z3_OP_LE = 514,
|
||||
Z3_OP_SET_UNION = 773,
|
||||
Z3_OP_PR_UNDEF = 1280,
|
||||
Z3_OP_BREDAND = 1062,
|
||||
Z3_OP_LT = 516,
|
||||
Z3_OP_RA_UNION = 1540,
|
||||
Z3_OP_BADD = 1028,
|
||||
Z3_OP_BUREM0 = 1039,
|
||||
Z3_OP_OEQ = 267,
|
||||
Z3_OP_PR_MODUS_PONENS = 1284,
|
||||
Z3_OP_RA_CLONE = 1548,
|
||||
Z3_OP_REPEAT = 1060,
|
||||
Z3_OP_RA_NEGATION_FILTER = 1544,
|
||||
Z3_OP_BSMOD0 = 1040,
|
||||
Z3_OP_BLSHR = 1065,
|
||||
Z3_OP_BASHR = 1066,
|
||||
Z3_OP_PR_UNIT_RESOLUTION = 1304,
|
||||
Z3_OP_ROTATE_RIGHT = 1068,
|
||||
Z3_OP_ARRAY_DEFAULT = 772,
|
||||
Z3_OP_PR_PULL_QUANT = 1296,
|
||||
Z3_OP_PR_APPLY_DEF = 1310,
|
||||
Z3_OP_PR_REWRITE_STAR = 1295,
|
||||
Z3_OP_IDIV = 523,
|
||||
Z3_OP_PR_GOAL = 1283,
|
||||
Z3_OP_PR_IFF_TRUE = 1305,
|
||||
Z3_OP_LABEL_LIT = 1793,
|
||||
Z3_OP_BOR = 1050,
|
||||
Z3_OP_PR_SYMMETRY = 1286,
|
||||
Z3_OP_TRUE = 256,
|
||||
Z3_OP_SET_COMPLEMENT = 776,
|
||||
Z3_OP_CONCAT = 1056,
|
||||
Z3_OP_PR_NOT_OR_ELIM = 1293,
|
||||
Z3_OP_IFF = 263,
|
||||
Z3_OP_BSHL = 1064,
|
||||
Z3_OP_PR_TRANSITIVITY = 1287,
|
||||
Z3_OP_SGT = 1048,
|
||||
Z3_OP_RA_WIDEN = 1541,
|
||||
Z3_OP_PR_DEF_INTRO = 1309,
|
||||
Z3_OP_NOT = 265,
|
||||
Z3_OP_PR_QUANT_INTRO = 1290,
|
||||
Z3_OP_UGT = 1047,
|
||||
Z3_OP_DT_RECOGNISER = 2049,
|
||||
Z3_OP_SET_INTERSECT = 774,
|
||||
Z3_OP_BSREM = 1033,
|
||||
Z3_OP_RA_STORE = 1536,
|
||||
Z3_OP_SLT = 1046,
|
||||
Z3_OP_ROTATE_LEFT = 1067,
|
||||
Z3_OP_PR_NNF_NEG = 1313,
|
||||
Z3_OP_PR_REFLEXIVITY = 1285,
|
||||
Z3_OP_ULEQ = 1041,
|
||||
Z3_OP_BIT1 = 1025,
|
||||
Z3_OP_BIT0 = 1026,
|
||||
Z3_OP_EQ = 258,
|
||||
Z3_OP_BMUL = 1030,
|
||||
Z3_OP_ARRAY_MAP = 771,
|
||||
Z3_OP_STORE = 768,
|
||||
Z3_OP_PR_HYPOTHESIS = 1302,
|
||||
Z3_OP_RA_RENAME = 1545,
|
||||
Z3_OP_AND = 261,
|
||||
Z3_OP_TO_REAL = 526,
|
||||
Z3_OP_PR_NNF_POS = 1312,
|
||||
Z3_OP_PR_AND_ELIM = 1292,
|
||||
Z3_OP_MOD = 525,
|
||||
Z3_OP_BUDIV0 = 1037,
|
||||
Z3_OP_PR_TRUE = 1281,
|
||||
Z3_OP_BNAND = 1053,
|
||||
Z3_OP_PR_ELIM_UNUSED_VARS = 1299,
|
||||
Z3_OP_RA_FILTER = 1543,
|
||||
Z3_OP_FD_LT = 1549,
|
||||
Z3_OP_RA_EMPTY = 1537,
|
||||
Z3_OP_DIV = 522,
|
||||
Z3_OP_ANUM = 512,
|
||||
Z3_OP_MUL = 521,
|
||||
Z3_OP_UGEQ = 1043,
|
||||
Z3_OP_BSREM0 = 1038,
|
||||
Z3_OP_PR_TH_LEMMA = 1318,
|
||||
Z3_OP_BXOR = 1052,
|
||||
Z3_OP_DISTINCT = 259,
|
||||
Z3_OP_PR_IFF_FALSE = 1306,
|
||||
Z3_OP_BV2INT = 1072,
|
||||
Z3_OP_EXT_ROTATE_LEFT = 1069,
|
||||
Z3_OP_PR_PULL_QUANT_STAR = 1297,
|
||||
Z3_OP_BSUB = 1029,
|
||||
Z3_OP_PR_ASSERTED = 1282,
|
||||
Z3_OP_BXNOR = 1055,
|
||||
Z3_OP_EXTRACT = 1059,
|
||||
Z3_OP_PR_DER = 1300,
|
||||
Z3_OP_DT_CONSTRUCTOR = 2048,
|
||||
Z3_OP_GT = 517,
|
||||
Z3_OP_BUREM = 1034,
|
||||
Z3_OP_IMPLIES = 266,
|
||||
Z3_OP_SLEQ = 1042,
|
||||
Z3_OP_GE = 515,
|
||||
Z3_OP_BAND = 1049,
|
||||
Z3_OP_ITE = 260,
|
||||
Z3_OP_AS_ARRAY = 778,
|
||||
Z3_OP_RA_SELECT = 1547,
|
||||
Z3_OP_CONST_ARRAY = 770,
|
||||
Z3_OP_BSDIV = 1031,
|
||||
Z3_OP_OR = 262,
|
||||
Z3_OP_PR_HYPER_RESOLVE = 1319,
|
||||
Z3_OP_AGNUM = 513,
|
||||
Z3_OP_PR_PUSH_QUANT = 1298,
|
||||
Z3_OP_BSMOD = 1035,
|
||||
Z3_OP_PR_IFF_OEQ = 1311,
|
||||
Z3_OP_PR_LEMMA = 1303,
|
||||
Z3_OP_SET_SUBSET = 777,
|
||||
Z3_OP_SELECT = 769,
|
||||
Z3_OP_RA_PROJECT = 1542,
|
||||
Z3_OP_BNEG = 1027,
|
||||
Z3_OP_UMINUS = 520,
|
||||
Z3_OP_REM = 524,
|
||||
Z3_OP_TO_INT = 527,
|
||||
Z3_OP_PR_QUANT_INST = 1301,
|
||||
Z3_OP_SGEQ = 1044,
|
||||
Z3_OP_POWER = 529,
|
||||
Z3_OP_XOR3 = 1074,
|
||||
Z3_OP_RA_IS_EMPTY = 1538,
|
||||
Z3_OP_CARRY = 1073,
|
||||
Z3_OP_DT_ACCESSOR = 2050,
|
||||
Z3_OP_PR_TRANSITIVITY_STAR = 1288,
|
||||
Z3_OP_PR_NNF_STAR = 1314,
|
||||
Z3_OP_PR_COMMUTATIVITY = 1307,
|
||||
Z3_OP_ULT = 1045,
|
||||
Z3_OP_BSDIV0 = 1036,
|
||||
Z3_OP_SET_DIFFERENCE = 775,
|
||||
Z3_OP_INT2BV = 1071,
|
||||
Z3_OP_XOR = 264,
|
||||
Z3_OP_PR_MODUS_PONENS_OEQ = 1317,
|
||||
Z3_OP_BNUM = 1024,
|
||||
Z3_OP_BUDIV = 1032,
|
||||
Z3_OP_PR_MONOTONICITY = 1289,
|
||||
Z3_OP_PR_DEF_AXIOM = 1308,
|
||||
Z3_OP_FALSE = 257,
|
||||
Z3_OP_EXT_ROTATE_RIGHT = 1070,
|
||||
Z3_OP_PR_DISTRIBUTIVITY = 1291,
|
||||
Z3_OP_SIGN_EXT = 1057,
|
||||
Z3_OP_PR_SKOLEMIZE = 1316,
|
||||
Z3_OP_BCOMP = 1063,
|
||||
Z3_OP_RA_COMPLEMENT = 1546,
|
||||
}
|
||||
|
||||
/// <summary>Z3_param_kind</summary>
|
||||
public enum Z3_param_kind {
|
||||
Z3_PK_BOOL = 1,
|
||||
Z3_PK_SYMBOL = 3,
|
||||
Z3_PK_OTHER = 5,
|
||||
Z3_PK_INVALID = 6,
|
||||
Z3_PK_UINT = 0,
|
||||
Z3_PK_STRING = 4,
|
||||
Z3_PK_DOUBLE = 2,
|
||||
}
|
||||
|
||||
/// <summary>Z3_ast_print_mode</summary>
|
||||
public enum Z3_ast_print_mode {
|
||||
Z3_PRINT_SMTLIB2_COMPLIANT = 3,
|
||||
Z3_PRINT_SMTLIB_COMPLIANT = 2,
|
||||
Z3_PRINT_SMTLIB_FULL = 0,
|
||||
Z3_PRINT_LOW_LEVEL = 1,
|
||||
}
|
||||
|
||||
/// <summary>Z3_error_code</summary>
|
||||
public enum Z3_error_code {
|
||||
Z3_INVALID_PATTERN = 6,
|
||||
Z3_MEMOUT_FAIL = 7,
|
||||
Z3_NO_PARSER = 5,
|
||||
Z3_OK = 0,
|
||||
Z3_INVALID_ARG = 3,
|
||||
Z3_EXCEPTION = 12,
|
||||
Z3_IOB = 2,
|
||||
Z3_INTERNAL_FATAL = 9,
|
||||
Z3_INVALID_USAGE = 10,
|
||||
Z3_FILE_ACCESS_ERROR = 8,
|
||||
Z3_SORT_ERROR = 1,
|
||||
Z3_PARSER_ERROR = 4,
|
||||
Z3_DEC_REF_ERROR = 11,
|
||||
}
|
||||
|
||||
/// <summary>Z3_goal_prec</summary>
|
||||
public enum Z3_goal_prec {
|
||||
Z3_GOAL_UNDER = 1,
|
||||
Z3_GOAL_PRECISE = 0,
|
||||
Z3_GOAL_UNDER_OVER = 3,
|
||||
Z3_GOAL_OVER = 2,
|
||||
}
|
||||
|
||||
}
|
1677
src/bindings/dotnet/Microsoft.Z3/Expr.cs
Normal file
1677
src/bindings/dotnet/Microsoft.Z3/Expr.cs
Normal file
File diff suppressed because it is too large
Load diff
303
src/bindings/dotnet/Microsoft.Z3/Fixedpoint.cs
Normal file
303
src/bindings/dotnet/Microsoft.Z3/Fixedpoint.cs
Normal file
|
@ -0,0 +1,303 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Fixedpoints.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Fixedpoints
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Object for managing fixedpoints
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Fixedpoint : Z3Object
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A string that describes all available fixedpoint solver parameters.
|
||||
/// </summary>
|
||||
public string Help
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
return Native.Z3_fixedpoint_get_help(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the fixedpoint solver parameters.
|
||||
/// </summary>
|
||||
public Params Parameters
|
||||
{
|
||||
set
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
Context.CheckContextMatch(value);
|
||||
Native.Z3_fixedpoint_set_params(Context.nCtx, NativeObject, value.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves parameter descriptions for Fixedpoint solver.
|
||||
/// </summary>
|
||||
public ParamDescrs ParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(Context, Native.Z3_fixedpoint_get_param_descrs(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Assert a constraint (or multiple) into the fixedpoint solver.
|
||||
/// </summary>
|
||||
public void Assert(params BoolExpr[] constraints)
|
||||
{
|
||||
Contract.Requires(constraints != null);
|
||||
Contract.Requires(Contract.ForAll(constraints, c => c != null));
|
||||
|
||||
Context.CheckContextMatch(constraints);
|
||||
foreach (BoolExpr a in constraints)
|
||||
{
|
||||
Native.Z3_fixedpoint_assert(Context.nCtx, NativeObject, a.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register predicate as recursive relation.
|
||||
/// </summary>
|
||||
public void RegisterRelation(FuncDecl f)
|
||||
{
|
||||
Contract.Requires(f != null);
|
||||
|
||||
Context.CheckContextMatch(f);
|
||||
Native.Z3_fixedpoint_register_relation(Context.nCtx, NativeObject, f.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add rule into the fixedpoint solver.
|
||||
/// </summary>
|
||||
public void AddRule(BoolExpr rule, Symbol name = null)
|
||||
{
|
||||
Contract.Requires(rule != null);
|
||||
|
||||
Context.CheckContextMatch(rule);
|
||||
Native.Z3_fixedpoint_add_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add table fact to the fixedpoint solver.
|
||||
/// </summary>
|
||||
public void AddFact(FuncDecl pred, params uint[] args)
|
||||
{
|
||||
Contract.Requires(pred != null);
|
||||
Contract.Requires(args != null);
|
||||
|
||||
Context.CheckContextMatch(pred);
|
||||
Native.Z3_fixedpoint_add_fact(Context.nCtx, NativeObject, pred.NativeObject, (uint)args.Length, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query the fixedpoint solver.
|
||||
/// A query is a conjunction of constraints. The constraints may include the recursively defined relations.
|
||||
/// The query is satisfiable if there is an instance of the query variables and a derivation for it.
|
||||
/// The query is unsatisfiable if there are no derivations satisfying the query variables.
|
||||
/// </summary>
|
||||
public Status Query(BoolExpr query)
|
||||
{
|
||||
Contract.Requires(query != null);
|
||||
|
||||
Context.CheckContextMatch(query);
|
||||
Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query(Context.nCtx, NativeObject, query.NativeObject);
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
|
||||
default: return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query the fixedpoint solver.
|
||||
/// A query is an array of relations.
|
||||
/// The query is satisfiable if there is an instance of some relation that is non-empty.
|
||||
/// The query is unsatisfiable if there are no derivations satisfying any of the relations.
|
||||
/// </summary>
|
||||
public Status Query(FuncDecl[] relations)
|
||||
{
|
||||
Contract.Requires(relations != null);
|
||||
Contract.Requires(Contract.ForAll(0, relations.Length, i => relations[i] != null));
|
||||
|
||||
Context.CheckContextMatch(relations);
|
||||
Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query_relations(Context.nCtx, NativeObject,
|
||||
AST.ArrayLength(relations), AST.ArrayToNative(relations));
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
|
||||
default: return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backtracking point.
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
public void Push()
|
||||
{
|
||||
Native.Z3_fixedpoint_push(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Backtrack one backtracking point.
|
||||
/// </summary>
|
||||
/// <remarks>Note that an exception is thrown if Pop is called without a corresponding <c>Push</c></remarks>
|
||||
/// <seealso cref="Push"/>
|
||||
public void Pop()
|
||||
{
|
||||
Native.Z3_fixedpoint_pop(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update named rule into in the fixedpoint solver.
|
||||
/// </summary>
|
||||
public void UpdateRule(BoolExpr rule, Symbol name)
|
||||
{
|
||||
Contract.Requires(rule != null);
|
||||
|
||||
Context.CheckContextMatch(rule);
|
||||
Native.Z3_fixedpoint_update_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve satisfying instance or instances of solver,
|
||||
/// or definitions for the recursive predicates that show unsatisfiability.
|
||||
/// </summary>
|
||||
public Expr GetAnswer()
|
||||
{
|
||||
IntPtr ans = Native.Z3_fixedpoint_get_answer(Context.nCtx, NativeObject);
|
||||
return (ans == IntPtr.Zero) ? null : Expr.Create(Context, ans);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve explanation why fixedpoint engine returned status Unknown.
|
||||
/// </summary>
|
||||
public string GetReasonUnknown()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_fixedpoint_get_reason_unknown(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the number of levels explored for a given predicate.
|
||||
/// </summary>
|
||||
public uint GetNumLevels(FuncDecl predicate)
|
||||
{
|
||||
return Native.Z3_fixedpoint_get_num_levels(Context.nCtx, NativeObject, predicate.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the cover of a predicate.
|
||||
/// </summary>
|
||||
public Expr GetCoverDelta(int level, FuncDecl predicate)
|
||||
{
|
||||
IntPtr res = Native.Z3_fixedpoint_get_cover_delta(Context.nCtx, NativeObject, level, predicate.NativeObject);
|
||||
return (res == IntPtr.Zero) ? null : Expr.Create(Context, res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add <tt>property</tt> about the <tt>predicate</tt>.
|
||||
/// The property is added at <tt>level</tt>.
|
||||
/// </summary>
|
||||
public void AddCover(int level, FuncDecl predicate, Expr property)
|
||||
{
|
||||
Native.Z3_fixedpoint_add_cover(Context.nCtx, NativeObject, level, predicate.NativeObject, property.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve internal string representation of fixedpoint object.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_fixedpoint_to_string(Context.nCtx, NativeObject, 0, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instrument the Datalog engine on which table representation to use for recursive predicate.
|
||||
/// </summary>
|
||||
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds)
|
||||
{
|
||||
Contract.Requires(f != null);
|
||||
|
||||
Native.Z3_fixedpoint_set_predicate_representation(Context.nCtx, NativeObject,
|
||||
f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert benchmark given as set of axioms, rules and queries to a string.
|
||||
/// </summary>
|
||||
public string ToString(BoolExpr[] queries)
|
||||
{
|
||||
|
||||
return Native.Z3_fixedpoint_to_string(Context.nCtx, NativeObject,
|
||||
AST.ArrayLength(queries), AST.ArrayToNative(queries));
|
||||
}
|
||||
|
||||
|
||||
#region Internal
|
||||
internal Fixedpoint(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal Fixedpoint(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_fixedpoint(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_fixedpoint_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_fixedpoint_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Fixedpoint_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Fixedpoint_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
344
src/bindings/dotnet/Microsoft.Z3/FuncDecl.cs
Normal file
344
src/bindings/dotnet/Microsoft.Z3/FuncDecl.cs
Normal file
|
@ -0,0 +1,344 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncDecl.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Function Declarations
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Function declarations.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class FuncDecl : AST
|
||||
{
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> share the same context and are equal, false otherwise.</returns>
|
||||
public static bool operator ==(FuncDecl a, FuncDecl b)
|
||||
{
|
||||
return Object.ReferenceEquals(a, b) ||
|
||||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context.nCtx == b.Context.nCtx &&
|
||||
Native.Z3_is_eq_func_decl(a.Context.nCtx, a.NativeObject, b.NativeObject) != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> do not share the same context or are not equal, false otherwise.</returns>
|
||||
public static bool operator !=(FuncDecl a, FuncDecl b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object comparison.
|
||||
/// </summary>
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
FuncDecl casted = o as FuncDecl;
|
||||
if (casted == null) return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A hash code.
|
||||
/// </summary>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representations of the function declaration.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_func_decl_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a unique identifier for the function declaration.
|
||||
/// </summary>
|
||||
new public uint Id
|
||||
{
|
||||
get { return Native.Z3_get_func_decl_id(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The arity of the function declaration
|
||||
/// </summary>
|
||||
public uint Arity
|
||||
{
|
||||
get { return Native.Z3_get_arity(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The size of the domain of the function declaration
|
||||
/// <seealso cref="Arity"/>
|
||||
/// </summary>
|
||||
public uint DomainSize
|
||||
{
|
||||
get { return Native.Z3_get_domain_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The domain of the function declaration
|
||||
/// </summary>
|
||||
public Sort[] Domain
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Sort[]>() != null);
|
||||
|
||||
var n = DomainSize;
|
||||
|
||||
Sort[] res = new Sort[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context, Native.Z3_get_domain(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The range of the function declaration
|
||||
/// </summary>
|
||||
public Sort Range
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Sort>() != null);
|
||||
return Sort.Create(Context, Native.Z3_get_range(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the function declaration.
|
||||
/// </summary>
|
||||
public Z3_decl_kind DeclKind
|
||||
{
|
||||
get { return (Z3_decl_kind)Native.Z3_get_decl_kind(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the function declaration
|
||||
/// </summary>
|
||||
public Symbol Name
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Symbol>() != null);
|
||||
return Symbol.Create(Context, Native.Z3_get_decl_name(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of parameters of the function declaration
|
||||
/// </summary>
|
||||
public uint NumParameters
|
||||
{
|
||||
get { return Native.Z3_get_decl_num_parameters(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The parameters of the function declaration
|
||||
/// </summary>
|
||||
public Parameter[] Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Parameter[]>() != null);
|
||||
|
||||
uint num = NumParameters;
|
||||
Parameter[] res = new Parameter[num];
|
||||
for (uint i = 0; i < num; i++)
|
||||
{
|
||||
Z3_parameter_kind k = (Z3_parameter_kind)Native.Z3_get_decl_parameter_kind(Context.nCtx, NativeObject, i);
|
||||
switch (k)
|
||||
{
|
||||
case Z3_parameter_kind.Z3_PARAMETER_INT:
|
||||
res[i] = new Parameter(k, Native.Z3_get_decl_int_parameter(Context.nCtx, NativeObject, i));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_DOUBLE:
|
||||
res[i] = new Parameter(k, Native.Z3_get_decl_double_parameter(Context.nCtx, NativeObject, i));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_SYMBOL:
|
||||
res[i] = new Parameter(k, Symbol.Create(Context, Native.Z3_get_decl_symbol_parameter(Context.nCtx, NativeObject, i)));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_SORT:
|
||||
res[i] = new Parameter(k, Sort.Create(Context, Native.Z3_get_decl_sort_parameter(Context.nCtx, NativeObject, i)));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_AST:
|
||||
res[i] = new Parameter(k, new AST(Context, Native.Z3_get_decl_ast_parameter(Context.nCtx, NativeObject, i)));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL:
|
||||
res[i] = new Parameter(k, new FuncDecl(Context, Native.Z3_get_decl_func_decl_parameter(Context.nCtx, NativeObject, i)));
|
||||
break;
|
||||
case Z3_parameter_kind.Z3_PARAMETER_RATIONAL:
|
||||
res[i] = new Parameter(k, Native.Z3_get_decl_rational_parameter(Context.nCtx, NativeObject, i));
|
||||
break;
|
||||
default:
|
||||
throw new Z3Exception("Unknown function declaration parameter kind encountered");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function declarations can have Parameters associated with them.
|
||||
/// </summary>
|
||||
public class Parameter
|
||||
{
|
||||
readonly private Z3_parameter_kind kind;
|
||||
readonly private int i;
|
||||
readonly private double d;
|
||||
readonly private Symbol sym;
|
||||
readonly private Sort srt;
|
||||
readonly private AST ast;
|
||||
readonly private FuncDecl fd;
|
||||
readonly private string r;
|
||||
|
||||
/// <summary>The int value of the parameter.</summary>
|
||||
public int Int { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_INT) throw new Z3Exception("parameter is not an int"); return i; } }
|
||||
/// <summary>The double value of the parameter.</summary>
|
||||
public double Double { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_DOUBLE) throw new Z3Exception("parameter is not a double "); return d; } }
|
||||
/// <summary>The Symbol value of the parameter.</summary>
|
||||
public Symbol Symbol { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_SYMBOL) throw new Z3Exception("parameter is not a Symbol"); return sym; } }
|
||||
/// <summary>The Sort value of the parameter.</summary>
|
||||
public Sort Sort { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_SORT) throw new Z3Exception("parameter is not a Sort"); return srt; } }
|
||||
/// <summary>The AST value of the parameter.</summary>
|
||||
public AST AST { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_AST) throw new Z3Exception("parameter is not an AST"); return ast; } }
|
||||
/// <summary>The FunctionDeclaration value of the parameter.</summary>
|
||||
public FuncDecl FuncDecl { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL) throw new Z3Exception("parameter is not a function declaration"); return fd; } }
|
||||
/// <summary>The rational string value of the parameter.</summary>
|
||||
public string Rational { get { if (ParameterKind != Z3_parameter_kind.Z3_PARAMETER_RATIONAL) throw new Z3Exception("parameter is not a rational string"); return r; } }
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the parameter.
|
||||
/// </summary>
|
||||
public Z3_parameter_kind ParameterKind { get { return kind; } }
|
||||
|
||||
#region Internal
|
||||
internal Parameter(Z3_parameter_kind k, int i)
|
||||
{
|
||||
this.kind = k;
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, double d)
|
||||
{
|
||||
this.kind = k;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, Symbol s)
|
||||
{
|
||||
this.kind = k;
|
||||
this.sym = s;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, Sort s)
|
||||
{
|
||||
this.kind = k;
|
||||
this.srt = s;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, AST a)
|
||||
{
|
||||
this.kind = k;
|
||||
this.ast = a;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, FuncDecl fd)
|
||||
{
|
||||
this.kind = k;
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
internal Parameter(Z3_parameter_kind k, string r)
|
||||
{
|
||||
this.kind = k;
|
||||
this.r = r;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal FuncDecl(Context ctx, IntPtr obj) : base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
|
||||
: base(ctx, Native.Z3_mk_func_decl(ctx.nCtx, name.NativeObject,
|
||||
AST.ArrayLength(domain), AST.ArrayToNative(domain),
|
||||
range.NativeObject))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(range != null);
|
||||
}
|
||||
|
||||
internal FuncDecl(Context ctx, string prefix, Sort[] domain, Sort range)
|
||||
: base(ctx, Native.Z3_mk_fresh_func_decl(ctx.nCtx, prefix,
|
||||
AST.ArrayLength(domain), AST.ArrayToNative(domain),
|
||||
range.NativeObject))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(range != null);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if (Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_FUNC_DECL_AST)
|
||||
throw new Z3Exception("Underlying object is not a function declaration");
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Create expression that applies function to arguments.
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public Expr this[params Expr[] args] {
|
||||
get {
|
||||
Contract.Requires(args == null || Contract.ForAll(args, a => a != null));
|
||||
|
||||
return Apply(args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create expression that applies function to arguments.
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public Expr Apply(params Expr[] args)
|
||||
{
|
||||
Contract.Requires(args == null || Contract.ForAll(args, a => a != null));
|
||||
|
||||
Context.CheckContextMatch(args);
|
||||
return Expr.Create(Context, this, args);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
221
src/bindings/dotnet/Microsoft.Z3/FuncInterp.cs
Normal file
221
src/bindings/dotnet/Microsoft.Z3/FuncInterp.cs
Normal file
|
@ -0,0 +1,221 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FuncInterp.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Function Interpretations
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A function interpretation is represented as a finite map and an 'else' value.
|
||||
/// Each entry in the finite map represents the value of a function given a set of arguments.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class FuncInterp : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// An Entry object represents an element in the finite map used to encode
|
||||
/// a function interpretation.
|
||||
/// </summary>
|
||||
public class Entry : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the (symbolic) value of this entry.
|
||||
/// </summary>
|
||||
public Expr Value
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
return Expr.Create(Context, Native.Z3_func_entry_get_value(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of arguments of the entry.
|
||||
/// </summary>
|
||||
public uint NumArgs
|
||||
{
|
||||
get { return Native.Z3_func_entry_get_num_args(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The arguments of the function entry.
|
||||
/// </summary>
|
||||
public Expr[] Args
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
Contract.Ensures(Contract.Result<Expr[]>().Length == this.NumArgs);
|
||||
|
||||
uint n = NumArgs;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, Native.Z3_func_entry_get_arg(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the function entry.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
uint n = NumArgs;
|
||||
string res = "[";
|
||||
Expr[] args = Args;
|
||||
for (uint i = 0; i < n; i++)
|
||||
res += args[i] + ", ";
|
||||
return res + Value + "]";
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Entry(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_entry_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_entry_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.FuncEntry_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.FuncEntry_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The number of entries in the function interpretation.
|
||||
/// </summary>
|
||||
public uint NumEntries
|
||||
{
|
||||
get { return Native.Z3_func_interp_get_num_entries(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The entries in the function interpretation
|
||||
/// </summary>
|
||||
public Entry[] Entries
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Entry[]>() != null);
|
||||
Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length,
|
||||
j => Contract.Result<Entry[]>()[j] != null));
|
||||
|
||||
uint n = NumEntries;
|
||||
Entry[] res = new Entry[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new Entry(Context, Native.Z3_func_interp_get_entry(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The (symbolic) `else' value of the function interpretation.
|
||||
/// </summary>
|
||||
public Expr Else
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
return Expr.Create(Context, Native.Z3_func_interp_get_else(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The arity of the function interpretation
|
||||
/// </summary>
|
||||
public uint Arity
|
||||
{
|
||||
get { return Native.Z3_func_interp_get_arity(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the function interpretation.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
string res = "";
|
||||
res += "[";
|
||||
foreach (Entry e in Entries)
|
||||
{
|
||||
uint n = e.NumArgs;
|
||||
if (n > 1) res += "[";
|
||||
Expr[] args = e.Args;
|
||||
for (uint i = 0; i < n; i++)
|
||||
{
|
||||
if (i != 0) res += ", ";
|
||||
res += args[i];
|
||||
}
|
||||
if (n > 1) res += "]";
|
||||
res += " -> " + e.Value + ", ";
|
||||
}
|
||||
res += "else -> " + Else;
|
||||
res += "]";
|
||||
return res;
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal FuncInterp(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_interp_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_interp_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.FuncInterp_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.FuncInterp_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
239
src/bindings/dotnet/Microsoft.Z3/Goal.cs
Normal file
239
src/bindings/dotnet/Microsoft.Z3/Goal.cs
Normal file
|
@ -0,0 +1,239 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Goal.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Goal
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A goal (aka problem). A goal is essentially a set
|
||||
/// of formulas, that can be solved and/or transformed using
|
||||
/// tactics and solvers.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Goal : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The precision of the goal.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Goals can be transformed using over and under approximations.
|
||||
/// An under approximation is applied when the objective is to find a model for a given goal.
|
||||
/// An over approximation is applied when the objective is to find a proof for a given goal.
|
||||
/// </remarks>
|
||||
public Z3_goal_prec Precision
|
||||
{
|
||||
get { return (Z3_goal_prec)Native.Z3_goal_precision(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal is precise.
|
||||
/// </summary>
|
||||
public bool IsPrecise
|
||||
{
|
||||
get { return Precision == Z3_goal_prec.Z3_GOAL_PRECISE; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicates whether the goal is an under-approximation.
|
||||
/// </summary>
|
||||
public bool IsUnderApproximation
|
||||
{
|
||||
get { return Precision == Z3_goal_prec.Z3_GOAL_UNDER; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal is an over-approximation.
|
||||
/// </summary>
|
||||
public bool IsOverApproximation
|
||||
{
|
||||
get { return Precision == Z3_goal_prec.Z3_GOAL_OVER; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal is garbage (i.e., the product of over- and under-approximations).
|
||||
/// </summary>
|
||||
public bool IsGarbage
|
||||
{
|
||||
get { return Precision == Z3_goal_prec.Z3_GOAL_UNDER_OVER; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <paramref name="constraints"/> to the given goal.
|
||||
/// </summary>
|
||||
public void Assert(params BoolExpr[] constraints)
|
||||
{
|
||||
Contract.Requires(constraints != null);
|
||||
Contract.Requires(Contract.ForAll(constraints, c => c != null));
|
||||
|
||||
Context.CheckContextMatch(constraints);
|
||||
foreach (BoolExpr c in constraints)
|
||||
{
|
||||
Contract.Assert(c != null); // It was an assume, now made an assert just to be sure we do not regress
|
||||
Native.Z3_goal_assert(Context.nCtx, NativeObject, c.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal contains `false'.
|
||||
/// </summary>
|
||||
public bool Inconsistent
|
||||
{
|
||||
get { return Native.Z3_goal_inconsistent(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The depth of the goal.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This tracks how many transformations were applied to it.
|
||||
/// </remarks>
|
||||
public uint Depth
|
||||
{
|
||||
get { return Native.Z3_goal_depth(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases all formulas from the given goal.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
Native.Z3_goal_reset(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of formulas in the goal.
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_goal_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The formulas in the goal.
|
||||
/// </summary>
|
||||
public BoolExpr[] Formulas
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
|
||||
|
||||
uint n = Size;
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context, Native.Z3_goal_formula(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of formulas, subformulas and terms in the goal.
|
||||
/// </summary>
|
||||
public uint NumExprs
|
||||
{
|
||||
get { return Native.Z3_goal_num_exprs(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal is empty, and it is precise or the product of an under approximation.
|
||||
/// </summary>
|
||||
public bool IsDecidedSat
|
||||
{
|
||||
get { return Native.Z3_goal_is_decided_sat(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the goal contains `false', and it is precise or the product of an over approximation.
|
||||
/// </summary>
|
||||
public bool IsDecidedUnsat
|
||||
{
|
||||
get { return Native.Z3_goal_is_decided_unsat(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates (copies) the Goal to the target Context <paramref name="ctx"/>.
|
||||
/// </summary>
|
||||
public Goal Translate(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
return new Goal(ctx, Native.Z3_goal_translate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplifies the goal.
|
||||
/// </summary>
|
||||
/// <remarks>Essentially invokes the `simplify' tactic on the goal.</remarks>
|
||||
public Goal Simplify(Params p = null)
|
||||
{
|
||||
Tactic t = Context.MkTactic("simplify");
|
||||
ApplyResult res = t.Apply(this, p);
|
||||
|
||||
if (res.NumSubgoals == 0)
|
||||
return Context.MkGoal();
|
||||
else
|
||||
return res.Subgoals[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Goal to string conversion.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the Goal.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_goal_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal Goal(Context ctx, bool models, bool unsatCores, bool proofs)
|
||||
: base(ctx, Native.Z3_mk_goal(ctx.nCtx, (models) ? 1 : 0, (unsatCores) ? 1 : 0, (proofs) ? 1 : 0))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_goal_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_goal_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Goal_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Goal_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
79
src/bindings/dotnet/Microsoft.Z3/Log.cs
Normal file
79
src/bindings/dotnet/Microsoft.Z3/Log.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Log.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Log
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logging for Z3.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that this is a global, static log and if multiple Context
|
||||
/// objects are created, it logs the interaction with all of them.
|
||||
/// </remarks>
|
||||
[ContractVerification(true)]
|
||||
public static class Log
|
||||
{
|
||||
private static bool m_is_open = false;
|
||||
|
||||
/// <summary>
|
||||
/// Open an interaction log file.
|
||||
/// </summary>
|
||||
/// <param name="filename">the name of the file to open</param>
|
||||
/// <returns>True if opening the log file succeeds, false otherwise.</returns>
|
||||
public static bool Open(string filename)
|
||||
{
|
||||
m_is_open = true;
|
||||
return Native.Z3_open_log(filename) == 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the interaction log.
|
||||
/// </summary>
|
||||
public static void Close()
|
||||
{
|
||||
m_is_open = false;
|
||||
Native.Z3_close_log();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the user-provided string <paramref name="s"/> to the interaction log.
|
||||
/// </summary>
|
||||
public static void Append(string s)
|
||||
{
|
||||
Contract.Requires(isOpen());
|
||||
|
||||
if (!m_is_open)
|
||||
throw new Z3Exception("Log cannot be closed.");
|
||||
Native.Z3_append_log(s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the interaction log is opened.
|
||||
/// </summary>
|
||||
/// <returns>True if the interaction log is open, false otherwise.</returns>
|
||||
[Pure]
|
||||
public static bool isOpen()
|
||||
{
|
||||
return m_is_open;
|
||||
}
|
||||
}
|
||||
}
|
309
src/bindings/dotnet/Microsoft.Z3/Microsoft.Z3.csproj
Normal file
309
src/bindings/dotnet/Microsoft.Z3/Microsoft.Z3.csproj
Normal file
|
@ -0,0 +1,309 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EC3DB697-B734-42F7-9468-5B62821EEB5A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Z3</RootNamespace>
|
||||
<AssemblyName>Microsoft.Z3</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<CodeContractsAssemblyMode>0</CodeContractsAssemblyMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>True</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsDisjunctiveRequires>True</CodeContractsDisjunctiveRequires>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions />
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\external\</OutputPath>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'external|AnyCPU' ">
|
||||
<OutputPath>..\external\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>False</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>False</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions />
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>False</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>..\x64\external_64\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>True</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions>-repro</CodeContractsExtraAnalysisOptions>
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'">
|
||||
<OutputPath>..\x64\external\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'">
|
||||
<OutputPath>..\Release_delaysign\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<DefineConstants>DELAYSIGN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'">
|
||||
<OutputPath>bin\x64\Release_delaysign\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplyResult.cs" />
|
||||
<Compile Include="AST.cs" />
|
||||
<Compile Include="ASTMap.cs" />
|
||||
<Compile Include="ASTVector.cs" />
|
||||
<Compile Include="Constructor.cs" />
|
||||
<Compile Include="DecRefQueue.cs" />
|
||||
<Compile Include="Enumerations.cs" />
|
||||
<Compile Include="Expr.cs" />
|
||||
<Compile Include="Fixedpoint.cs" />
|
||||
<Compile Include="FuncDecl.cs" />
|
||||
<Compile Include="FuncInterp.cs" />
|
||||
<Compile Include="Goal.cs" />
|
||||
<Compile Include="Model.cs" />
|
||||
<Compile Include="Numeral.cs" />
|
||||
<Compile Include="Params.cs" />
|
||||
<Compile Include="ParamDescrs.cs" />
|
||||
<Compile Include="Pattern.cs" />
|
||||
<Compile Include="Statistics.cs" />
|
||||
<Compile Include="Status.cs" />
|
||||
<Compile Include="Context.cs" />
|
||||
<Compile Include="Probe.cs" />
|
||||
<Compile Include="Solver.cs" />
|
||||
<Compile Include="Tactic.cs" />
|
||||
<Compile Include="Z3Exception.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Native.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Quantifier.cs" />
|
||||
<Compile Include="Sort.cs" />
|
||||
<Compile Include="Symbol.cs" />
|
||||
<Compile Include="Version.cs" />
|
||||
<Compile Include="Z3Object.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
403
src/bindings/dotnet/Microsoft.Z3/Microsoft.Z3_35.csproj
Normal file
403
src/bindings/dotnet/Microsoft.Z3/Microsoft.Z3_35.csproj
Normal file
|
@ -0,0 +1,403 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EC3DB697-B734-42F7-9468-5B62821EEB5A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.Z3</RootNamespace>
|
||||
<AssemblyName>Microsoft.Z3</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<CodeContractsAssemblyMode>0</CodeContractsAssemblyMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin35\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>True</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsDisjunctiveRequires>True</CodeContractsDisjunctiveRequires>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions />
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin35\external\bin\</OutputPath>
|
||||
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'external|AnyCPU' ">
|
||||
<OutputPath>bin35\external\bin\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'external|Win32' ">
|
||||
<OutputPath>bin35\external\bin\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin35\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>False</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>False</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions />
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>False</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin35\external\x64\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>True</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions>-repro</CodeContractsExtraAnalysisOptions>
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'">
|
||||
<OutputPath>bin35\external\x64</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external_64|AnyCPU'">
|
||||
<OutputPath>bin35\external_64\x64</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external_64|x64'">
|
||||
<OutputPath>bin35\external_64\x64</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
|
||||
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
|
||||
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
|
||||
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
|
||||
<CodeContractsBoundsObligations>False</CodeContractsBoundsObligations>
|
||||
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
|
||||
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
|
||||
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
|
||||
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
|
||||
<CodeContractsInferRequires>False</CodeContractsInferRequires>
|
||||
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
|
||||
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
|
||||
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
|
||||
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
|
||||
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
|
||||
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
|
||||
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
|
||||
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
|
||||
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
|
||||
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
|
||||
<CodeContractsCustomRewriterAssembly />
|
||||
<CodeContractsCustomRewriterClass />
|
||||
<CodeContractsLibPaths />
|
||||
<CodeContractsExtraRewriteOptions />
|
||||
<CodeContractsExtraAnalysisOptions />
|
||||
<CodeContractsBaseLineFile />
|
||||
<CodeContractsCacheAnalysisResults>False</CodeContractsCacheAnalysisResults>
|
||||
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
|
||||
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
|
||||
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
|
||||
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>z3.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'">
|
||||
<OutputPath>bin35\Release_delaysign\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
<DefineConstants>DELAYSIGN</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'">
|
||||
<OutputPath>bin\x64\Release_delaysign\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440c9b414ea16, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\Program Files\Microsoft\Contracts\Contracts\v3.5\Microsoft.Contracts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplyResult.cs" />
|
||||
<Compile Include="AST.cs" />
|
||||
<Compile Include="ASTMap.cs" />
|
||||
<Compile Include="ASTVector.cs" />
|
||||
<Compile Include="Constructor.cs" />
|
||||
<Compile Include="DecRefQueue.cs" />
|
||||
<Compile Include="Enumerations.cs" />
|
||||
<Compile Include="Expr.cs" />
|
||||
<Compile Include="Fixedpoint.cs" />
|
||||
<Compile Include="FuncDecl.cs" />
|
||||
<Compile Include="FuncInterp.cs" />
|
||||
<Compile Include="Goal.cs" />
|
||||
<Compile Include="Model.cs" />
|
||||
<Compile Include="Numeral.cs" />
|
||||
<Compile Include="Params.cs" />
|
||||
<Compile Include="Pattern.cs" />
|
||||
<Compile Include="Statistics.cs" />
|
||||
<Compile Include="Status.cs" />
|
||||
<Compile Include="Context.cs" />
|
||||
<Compile Include="Probe.cs" />
|
||||
<Compile Include="Solver.cs" />
|
||||
<Compile Include="Tactic.cs" />
|
||||
<Compile Include="Z3Exception.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Native.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Quantifier.cs" />
|
||||
<Compile Include="Sort.cs" />
|
||||
<Compile Include="Symbol.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="Version.cs" />
|
||||
<Compile Include="Z3Object.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="z3.snk" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
318
src/bindings/dotnet/Microsoft.Z3/Model.cs
Normal file
318
src/bindings/dotnet/Microsoft.Z3/Model.cs
Normal file
|
@ -0,0 +1,318 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Model.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Models
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A Model contains interpretations (assignments) of constants and functions.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Model : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the interpretation (the assignment) of <paramref name="a"/> in the model.
|
||||
/// </summary>
|
||||
/// <param name="a">A Constant</param>
|
||||
/// <returns>An expression if the constant has an interpretation in the model, null otherwise.</returns>
|
||||
public Expr ConstInterp(Expr a)
|
||||
{
|
||||
Contract.Requires(a != null);
|
||||
|
||||
Context.CheckContextMatch(a);
|
||||
return ConstInterp(a.FuncDecl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the interpretation (the assignment) of <paramref name="f"/> in the model.
|
||||
/// </summary>
|
||||
/// <param name="f">A function declaration of zero arity</param>
|
||||
/// <returns>An expression if the function has an interpretation in the model, null otherwise.</returns>
|
||||
public Expr ConstInterp(FuncDecl f)
|
||||
{
|
||||
Contract.Requires(f != null);
|
||||
|
||||
Context.CheckContextMatch(f);
|
||||
if (f.Arity != 0 ||
|
||||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f.NativeObject)) == (uint)Z3_sort_kind.Z3_ARRAY_SORT)
|
||||
throw new Z3Exception("Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp.");
|
||||
|
||||
IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject);
|
||||
if (n == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return Expr.Create(Context, n);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the interpretation (the assignment) of a non-constant <paramref name="f"/> in the model.
|
||||
/// </summary>
|
||||
/// <param name="f">A function declaration of non-zero arity</param>
|
||||
/// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns>
|
||||
public FuncInterp FuncInterp(FuncDecl f)
|
||||
{
|
||||
Contract.Requires(f != null);
|
||||
|
||||
Context.CheckContextMatch(f);
|
||||
|
||||
Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f.NativeObject));
|
||||
|
||||
if (f.Arity == 0)
|
||||
{
|
||||
IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject);
|
||||
|
||||
if (sk == Z3_sort_kind.Z3_ARRAY_SORT)
|
||||
{
|
||||
if (n == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
if (Native.Z3_is_as_array(Context.nCtx, n) == 0)
|
||||
throw new Z3Exception("Argument was not an array constant");
|
||||
IntPtr fd = Native.Z3_get_as_array_func_decl(Context.nCtx, n);
|
||||
return FuncInterp(new FuncDecl(Context, fd));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Z3Exception("Constant functions do not have a function interpretation; use ConstInterp");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IntPtr n = Native.Z3_model_get_func_interp(Context.nCtx, NativeObject, f.NativeObject);
|
||||
if (n == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return new FuncInterp(Context, n);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of constants that have an interpretation in the model.
|
||||
/// </summary>
|
||||
public uint NumConsts
|
||||
{
|
||||
get { return Native.Z3_model_get_num_consts(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The function declarations of the constants in the model.
|
||||
/// </summary>
|
||||
public FuncDecl[] ConstDecls
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
uint n = NumConsts;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context, Native.Z3_model_get_const_decl(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of function interpretations in the model.
|
||||
/// </summary>
|
||||
public uint NumFuncs
|
||||
{
|
||||
get { return Native.Z3_model_get_num_funcs(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The function declarations of the function interpretations in the model.
|
||||
/// </summary>
|
||||
public FuncDecl[] FuncDecls
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
uint n = NumFuncs;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context, Native.Z3_model_get_func_decl(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All symbols that have an interpretation in the model.
|
||||
/// </summary>
|
||||
public FuncDecl[] Decls
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
var nFuncs = NumFuncs;
|
||||
var nConsts = NumConsts;
|
||||
uint n = nFuncs + nConsts;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < nConsts; i++)
|
||||
res[i] = new FuncDecl(Context, 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));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A ModelEvaluationFailedException is thrown when an expression cannot be evaluated by the model.
|
||||
/// </summary>
|
||||
public class ModelEvaluationFailedException : Z3Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// An exception that is thrown when model evaluation fails.
|
||||
/// </summary>
|
||||
public ModelEvaluationFailedException() : base() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the expression <paramref name="t"/> in the current model.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function may fail if <paramref name="t"/> contains quantifiers,
|
||||
/// is partial (MODEL_PARTIAL enabled), or if <paramref name="t"/> is not well-sorted.
|
||||
/// In this case a <c>ModelEvaluationFailedException</c> is thrown.
|
||||
/// </remarks>
|
||||
/// <param name="t">An expression</param>
|
||||
/// <param name="completion">
|
||||
/// When this flag is enabled, a model value will be assigned to any constant
|
||||
/// or function that does not have an interpretation in the model.
|
||||
/// </param>
|
||||
/// <returns>The evaluation of <paramref name="t"/> in the model.</returns>
|
||||
public Expr Eval(Expr t, bool completion = false)
|
||||
{
|
||||
Contract.Requires(t != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
IntPtr v = IntPtr.Zero;
|
||||
if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (completion) ? 1 : 0, ref v) == 0)
|
||||
throw new ModelEvaluationFailedException();
|
||||
else
|
||||
return Expr.Create(Context, v);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alias for <c>Eval</c>.
|
||||
/// </summary>
|
||||
public Expr Evaluate(Expr t, bool completion = false)
|
||||
{
|
||||
Contract.Requires(t != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
return Eval(t, completion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of uninterpreted sorts that the model has an interpretation for.
|
||||
/// </summary>
|
||||
public uint NumSorts { get { return Native.Z3_model_get_num_sorts(Context.nCtx, NativeObject); } }
|
||||
|
||||
/// <summary>
|
||||
/// The uninterpreted sorts that the model has an interpretation for.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Z3 also provides an intepretation for uninterpreted sorts used in a formula.
|
||||
/// The interpretation for a sort is a finite set of distinct values. We say this finite set is
|
||||
/// the "universe" of the sort.
|
||||
/// </remarks>
|
||||
/// <seealso cref="NumSorts"/>
|
||||
/// <seealso cref="SortUniverse"/>
|
||||
public Sort[] Sorts
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Sort[]>() != null);
|
||||
|
||||
uint n = NumSorts;
|
||||
Sort[] res = new Sort[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context, Native.Z3_model_get_sort(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The finite set of distinct values that represent the interpretation for sort <paramref name="s"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="Sorts"/>
|
||||
/// <param name="s">An uninterpreted sort</param>
|
||||
/// <returns>An array of expressions, where each is an element of the universe of <paramref name="s"/></returns>
|
||||
public Expr[] SortUniverse(Sort s)
|
||||
{
|
||||
Contract.Requires(s != null);
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
ASTVector nUniv = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject));
|
||||
uint n = nUniv.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, nUniv[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of models to strings.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the model.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_model_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Model(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_model_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_model_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Model_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Model_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
5283
src/bindings/dotnet/Microsoft.Z3/Native.cs
Normal file
5283
src/bindings/dotnet/Microsoft.Z3/Native.cs
Normal file
File diff suppressed because it is too large
Load diff
344
src/bindings/dotnet/Microsoft.Z3/Numeral.cs
Normal file
344
src/bindings/dotnet/Microsoft.Z3/Numeral.cs
Normal file
|
@ -0,0 +1,344 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Numeral.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Numerals
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-20
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
using System.Numerics;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Integer Numerals
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class IntNum : IntExpr
|
||||
{
|
||||
|
||||
#region Internal
|
||||
internal IntNum(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit unsigned integer value.
|
||||
/// </summary>
|
||||
public UInt64 UInt64
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public int Int
|
||||
{
|
||||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit int value.
|
||||
/// </summary>
|
||||
public Int64 Int64
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public uint UInt
|
||||
{
|
||||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
/// <summary>
|
||||
/// Retrieve the BigInteger value.
|
||||
/// </summary>
|
||||
public BigInteger BigInteger
|
||||
{
|
||||
get
|
||||
{
|
||||
return BigInteger.Parse(this.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rational Numerals
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class RatNum : RealExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// The numerator of a rational numeral.
|
||||
/// </summary>
|
||||
public IntNum Numerator
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<IntNum>() != null);
|
||||
|
||||
return new IntNum(Context, Native.Z3_get_numerator(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The denominator of a rational numeral.
|
||||
/// </summary>
|
||||
public IntNum Denominator
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<IntNum>() != null);
|
||||
|
||||
return new IntNum(Context, Native.Z3_get_denominator(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
/// <summary>
|
||||
/// Converts the numerator of the rational to a BigInteger
|
||||
/// </summary>
|
||||
public BigInteger BigIntNumerator
|
||||
{
|
||||
get
|
||||
{
|
||||
IntNum n = Numerator;
|
||||
return BigInteger.Parse(n.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the denominator of the rational to a BigInteger
|
||||
/// </summary>
|
||||
public BigInteger BigIntDenominator
|
||||
{
|
||||
get
|
||||
{
|
||||
IntNum n = Denominator;
|
||||
return BigInteger.Parse(n.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation in decimal notation.
|
||||
/// </summary>
|
||||
/// <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
|
||||
public string ToDecimalString(uint precision)
|
||||
{
|
||||
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal RatNum(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bit-vector numerals
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class BitVecNum : BitVecExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit unsigned integer value.
|
||||
/// </summary>
|
||||
public UInt64 UInt64
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt64 res = 0;
|
||||
if (Native.Z3_get_numeral_uint64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a 64 bit unsigned");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public int Int
|
||||
{
|
||||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_get_numeral_int(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the 64-bit int value.
|
||||
/// </summary>
|
||||
public Int64 Int64
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 res = 0;
|
||||
if (Native.Z3_get_numeral_int64(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the int value.
|
||||
/// </summary>
|
||||
public uint UInt
|
||||
{
|
||||
get
|
||||
{
|
||||
uint res = 0;
|
||||
if (Native.Z3_get_numeral_uint(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Numeral is not a uint");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#if !FRAMEWORK_LT_4
|
||||
/// <summary>
|
||||
/// Retrieve the BigInteger value.
|
||||
/// </summary>
|
||||
public BigInteger BigInteger
|
||||
{
|
||||
get
|
||||
{
|
||||
return BigInteger.Parse(this.ToString());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Algebraic numbers
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class AlgebraicNum : ArithExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Return a upper bound for a given real algebraic number.
|
||||
/// The interval isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
/// <seealso cref="Expr.IsAlgebraicNumber"/>
|
||||
/// </summary>
|
||||
/// <param name="precision">the precision of the result</param>
|
||||
/// <returns>A numeral Expr of sort Real</returns>
|
||||
public RatNum ToUpper(uint precision)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<RatNum>() != null);
|
||||
|
||||
return new RatNum(Context, Native.Z3_get_algebraic_number_upper(Context.nCtx, NativeObject, precision));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a lower bound for the given real algebraic number.
|
||||
/// The interval isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
/// <seealso cref="Expr.IsAlgebraicNumber"/>
|
||||
/// </summary>
|
||||
/// <param name="precision"></param>
|
||||
/// <returns>A numeral Expr of sort Real</returns>
|
||||
public RatNum ToLower(uint precision)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<RatNum>() != null);
|
||||
|
||||
return new RatNum(Context, Native.Z3_get_algebraic_number_lower(Context.nCtx, NativeObject, precision));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation in decimal notation.
|
||||
/// </summary>
|
||||
/// <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
|
||||
public string ToDecimal(uint precision)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal AlgebraicNum(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
114
src/bindings/dotnet/Microsoft.Z3/ParamDescrs.cs
Normal file
114
src/bindings/dotnet/Microsoft.Z3/ParamDescrs.cs
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Parameter.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Parameter Descriptions
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-20
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A ParamDescrs describes a set of parameters.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class ParamDescrs : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// validate a set of parameters.
|
||||
/// </summary>
|
||||
public void Validate(Params p)
|
||||
{
|
||||
Contract.Requires(p != null);
|
||||
Native.Z3_params_validate(Context.nCtx, p.NativeObject, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve kind of parameter.
|
||||
/// </summary>
|
||||
public Z3_param_kind GetKind(Symbol name)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
return (Z3_param_kind)Native.Z3_param_descrs_get_kind(Context.nCtx, NativeObject, name.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all names of parameters.
|
||||
/// </summary>
|
||||
public Symbol[] Names
|
||||
{
|
||||
get
|
||||
{
|
||||
uint sz = Native.Z3_param_descrs_size(Context.nCtx, NativeObject);
|
||||
Symbol[] names = new Symbol[sz];
|
||||
for (uint i = 0; i < sz; ++i) {
|
||||
names[i] = Symbol.Create(Context, Native.Z3_param_descrs_get_name(Context.nCtx, NativeObject, i));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The size of the ParamDescrs.
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_param_descrs_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a string representation of the ParamDescrs.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_param_descrs_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ParamDescrs(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ParamDescrs_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ParamDescrs_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
147
src/bindings/dotnet/Microsoft.Z3/Params.cs
Normal file
147
src/bindings/dotnet/Microsoft.Z3/Params.cs
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Parameter.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Parameters
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-20
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Params : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(Symbol name, bool value)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (value) ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(Symbol name, uint value)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
|
||||
Native.Z3_params_set_uint(Context.nCtx, NativeObject, name.NativeObject, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(Symbol name, double value)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
|
||||
Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(Symbol name, Symbol value)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(string name, bool value)
|
||||
{
|
||||
Native.Z3_params_set_bool(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (value) ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(string name, uint value)
|
||||
{
|
||||
Native.Z3_params_set_uint(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(string name, double value)
|
||||
{
|
||||
Native.Z3_params_set_double(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
public void Add(string name, Symbol value)
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the parameter set.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_params_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Params(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_params(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_params_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_params_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Params_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Params_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
75
src/bindings/dotnet/Microsoft.Z3/Pattern.cs
Normal file
75
src/bindings/dotnet/Microsoft.Z3/Pattern.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Pattern.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Patterns
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Patterns comprise a list of terms. The list should be
|
||||
/// non-empty. If the list comprises of more than one term, it is
|
||||
/// also called a multi-pattern.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Pattern : AST
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of terms in the pattern.
|
||||
/// </summary>
|
||||
public uint NumTerms
|
||||
{
|
||||
get { return Native.Z3_get_pattern_num_terms(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The terms in the pattern.
|
||||
/// </summary>
|
||||
public Expr[] Terms
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
uint n = NumTerms;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, Native.Z3_get_pattern(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the pattern.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_pattern_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Pattern(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
95
src/bindings/dotnet/Microsoft.Z3/Probe.cs
Normal file
95
src/bindings/dotnet/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
|
||||
}
|
||||
}
|
39
src/bindings/dotnet/Microsoft.Z3/Properties/AssemblyInfo.cs
Normal file
39
src/bindings/dotnet/Microsoft.Z3/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Z3 .NET Interface")]
|
||||
[assembly: AssemblyDescription(".NET Interface to the Z3 Theorem Prover")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft Corporation")]
|
||||
[assembly: AssemblyProduct("Z3")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2006")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("4853ed71-2078-40f4-8117-bc46646bce0e")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("4.2.0.0")]
|
||||
[assembly: AssemblyVersion("4.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.2.0.0")]
|
||||
|
257
src/bindings/dotnet/Microsoft.Z3/Quantifier.cs
Normal file
257
src/bindings/dotnet/Microsoft.Z3/Quantifier.cs
Normal file
|
@ -0,0 +1,257 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Quantifier.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Quantifiers
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-19
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Quantifier expressions.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Quantifier : BoolExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the quantifier is universal.
|
||||
/// </summary>
|
||||
public bool IsUniversal
|
||||
{
|
||||
get { return Native.Z3_is_quantifier_forall(Context.nCtx, NativeObject) != 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the quantifier is existential.
|
||||
/// </summary>
|
||||
public bool IsExistential
|
||||
{
|
||||
get { return !IsUniversal; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The weight of the quantifier.
|
||||
/// </summary>
|
||||
public uint Weight
|
||||
{
|
||||
get { return Native.Z3_get_quantifier_weight(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of patterns.
|
||||
/// </summary>
|
||||
public uint NumPatterns
|
||||
{
|
||||
get { return Native.Z3_get_quantifier_num_patterns(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The patterns.
|
||||
/// </summary>
|
||||
public Pattern[] Patterns
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Pattern[]>() != null);
|
||||
|
||||
uint n = NumPatterns;
|
||||
Pattern[] res = new Pattern[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new Pattern(Context, Native.Z3_get_quantifier_pattern_ast(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of no-patterns.
|
||||
/// </summary>
|
||||
public uint NumNoPatterns
|
||||
{
|
||||
get { return Native.Z3_get_quantifier_num_no_patterns(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The no-patterns.
|
||||
/// </summary>
|
||||
public Pattern[] NoPatterns
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Pattern[]>() != null);
|
||||
|
||||
uint n = NumNoPatterns;
|
||||
Pattern[] res = new Pattern[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new Pattern(Context, Native.Z3_get_quantifier_no_pattern_ast(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of bound variables.
|
||||
/// </summary>
|
||||
public uint NumBound
|
||||
{
|
||||
get { return Native.Z3_get_quantifier_num_bound(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The symbols for the bound variables.
|
||||
/// </summary>
|
||||
public Symbol[] BoundVariableNames
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Symbol[]>() != null);
|
||||
|
||||
uint n = NumBound;
|
||||
Symbol[] res = new Symbol[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Symbol.Create(Context, Native.Z3_get_quantifier_bound_name(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sorts of the bound variables.
|
||||
/// </summary>
|
||||
public Sort[] BoundVariableSorts
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Sort[]>() != null);
|
||||
|
||||
uint n = NumBound;
|
||||
Sort[] res = new Sort[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context, Native.Z3_get_quantifier_bound_sort(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The body of the quantifier.
|
||||
/// </summary>
|
||||
public BoolExpr Body
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
|
||||
return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
#region Internal
|
||||
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
|
||||
internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body,
|
||||
uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null,
|
||||
Symbol quantifierID = null, Symbol skolemID = null
|
||||
)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(sorts != null);
|
||||
Contract.Requires(names != null);
|
||||
Contract.Requires(body != null);
|
||||
Contract.Requires(sorts.Length == names.Length);
|
||||
Contract.Requires(Contract.ForAll(sorts, s => s != null));
|
||||
Contract.Requires(Contract.ForAll(names, n => n != null));
|
||||
Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
|
||||
Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));
|
||||
|
||||
Context.CheckContextMatch(patterns);
|
||||
Context.CheckContextMatch(noPatterns);
|
||||
Context.CheckContextMatch(sorts);
|
||||
Context.CheckContextMatch(names);
|
||||
Context.CheckContextMatch(body);
|
||||
|
||||
if (sorts.Length != names.Length)
|
||||
throw new Z3Exception("Number of sorts does not match number of names");
|
||||
|
||||
IntPtr[] _patterns = AST.ArrayToNative(patterns);
|
||||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight,
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
|
||||
Symbol.ArrayToNative(names),
|
||||
body.NativeObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_ex(ctx.nCtx, (isForall) ? 1 : 0, weight,
|
||||
AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
|
||||
AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
|
||||
Symbol.ArrayToNative(names),
|
||||
body.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
|
||||
internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body,
|
||||
uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null,
|
||||
Symbol quantifierID = null, Symbol skolemID = null
|
||||
)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(body != null);
|
||||
|
||||
Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
|
||||
Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));
|
||||
Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null));
|
||||
|
||||
Context.CheckContextMatch(noPatterns);
|
||||
Context.CheckContextMatch(patterns);
|
||||
//Context.CheckContextMatch(bound);
|
||||
Context.CheckContextMatch(body);
|
||||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_const(ctx.nCtx, (isForall) ? 1 : 0, weight,
|
||||
AST.ArrayLength(bound), AST.ArrayToNative(bound),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
body.NativeObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier_const_ex(ctx.nCtx, (isForall) ? 1 : 0, weight,
|
||||
AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID),
|
||||
AST.ArrayLength(bound), AST.ArrayToNative(bound),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
|
||||
body.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal Quantifier(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
#if DEBUG
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if ((Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST)
|
||||
throw new Z3Exception("Underlying object is not a quantifier");
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
301
src/bindings/dotnet/Microsoft.Z3/Solver.cs
Normal file
301
src/bindings/dotnet/Microsoft.Z3/Solver.cs
Normal file
|
@ -0,0 +1,301 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Solver.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Solvers
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-22
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Solvers.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Solver : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// A string that describes all available solver parameters.
|
||||
/// </summary>
|
||||
public string Help
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_solver_get_help(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the solver parameters.
|
||||
/// </summary>
|
||||
public Params Parameters
|
||||
{
|
||||
set
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Context.CheckContextMatch(value);
|
||||
Native.Z3_solver_set_params(Context.nCtx, NativeObject, value.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves parameter descriptions for solver.
|
||||
/// </summary>
|
||||
public ParamDescrs ParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(Context, Native.Z3_solver_get_param_descrs(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The current number of backtracking points (scopes).
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
/// <seealso cref="Push"/>
|
||||
public uint NumScopes
|
||||
{
|
||||
get { return Native.Z3_solver_get_num_scopes(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backtracking point.
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
public void Push()
|
||||
{
|
||||
Native.Z3_solver_push(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the Solver.
|
||||
/// </summary>
|
||||
/// <remarks>This removes all assertions from the solver.</remarks>
|
||||
public void Reset()
|
||||
{
|
||||
Native.Z3_solver_reset(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assert a constraint (or multiple) into the solver.
|
||||
/// </summary>
|
||||
public void Assert(params BoolExpr[] constraints)
|
||||
{
|
||||
Contract.Requires(constraints != null);
|
||||
Contract.Requires(Contract.ForAll(constraints, c => c != null));
|
||||
|
||||
Context.CheckContextMatch(constraints);
|
||||
foreach (BoolExpr a in constraints)
|
||||
{
|
||||
Native.Z3_solver_assert(Context.nCtx, NativeObject, a.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of assertions in the solver.
|
||||
/// </summary>
|
||||
public uint NumAssertions
|
||||
{
|
||||
get
|
||||
{
|
||||
ASTVector ass = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
return ass.Size;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The set of asserted formulas.
|
||||
/// </summary>
|
||||
public BoolExpr[] Assertions
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
|
||||
|
||||
ASTVector ass = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
uint n = ass.Size;
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context, ass[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the assertions in the solver are consistent or not.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <seealso cref="Model"/>
|
||||
/// <seealso cref="UnsatCore"/>
|
||||
/// <seealso cref="Proof"/>
|
||||
/// </remarks>
|
||||
public Status Check(params Expr[] assumptions)
|
||||
{
|
||||
Z3_lbool r;
|
||||
if (assumptions == null)
|
||||
r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject);
|
||||
else
|
||||
r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)assumptions.Length, AST.ArrayToNative(assumptions));
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
|
||||
default: return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The model of the last <c>Check</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The result is <c>null</c> if <c>Check</c> was not invoked before,
|
||||
/// if its results was not <c>SATISFIABLE</c>, or if model production is not enabled.
|
||||
/// </remarks>
|
||||
public Model Model
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr x = Native.Z3_solver_get_model(Context.nCtx, NativeObject);
|
||||
if (x == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return new Model(Context, x);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The proof of the last <c>Check</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The result is <c>null</c> if <c>Check</c> was not invoked before,
|
||||
/// if its results was not <c>UNSATISFIABLE</c>, or if proof production is disabled.
|
||||
/// </remarks>
|
||||
public Expr Proof
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr x = Native.Z3_solver_get_proof(Context.nCtx, NativeObject);
|
||||
if (x == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return Expr.Create(Context, x);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The unsat core of the last <c>Check</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The unsat core is a subset of <c>Assertions</c>
|
||||
/// The result is empty if <c>Check</c> was not invoked before,
|
||||
/// if its results was not <c>UNSATISFIABLE</c>, or if core production is disabled.
|
||||
/// </remarks>
|
||||
public Expr[] UnsatCore
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
ASTVector core = new ASTVector(Context, Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject));
|
||||
uint n = core.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, core[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A brief justification of why the last call to <c>Check</c> returned <c>UNKNOWN</c>.
|
||||
/// </summary>
|
||||
public string ReasonUnknown
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_solver_get_reason_unknown(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solver statistics.
|
||||
/// </summary>
|
||||
public Statistics Statistics
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Statistics>() != null);
|
||||
|
||||
return new Statistics(Context, Native.Z3_solver_get_statistics(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the solver.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_solver_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Solver(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_solver_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Solver_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Solver_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
745
src/bindings/dotnet/Microsoft.Z3/Sort.cs
Normal file
745
src/bindings/dotnet/Microsoft.Z3/Sort.cs
Normal file
|
@ -0,0 +1,745 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Sort.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Sorts
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The Sort class implements type information for ASTs.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Sort : AST
|
||||
{
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <param name="a">A Sort</param>
|
||||
/// <param name="b">A Sort</param>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> are from the same context
|
||||
/// and represent the same sort; false otherwise.</returns>
|
||||
public static bool operator ==(Sort a, Sort b)
|
||||
{
|
||||
return Object.ReferenceEquals(a, b) ||
|
||||
(!Object.ReferenceEquals(a, null) &&
|
||||
!Object.ReferenceEquals(b, null) &&
|
||||
a.Context == b.Context &&
|
||||
Native.Z3_is_eq_sort(a.Context.nCtx, a.NativeObject, b.NativeObject) != 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comparison operator.
|
||||
/// </summary>
|
||||
/// <param name="a">A Sort</param>
|
||||
/// <param name="b">A Sort</param>
|
||||
/// <returns>True if <paramref name="a"/> and <paramref name="b"/> are not from the same context
|
||||
/// or represent different sorts; false otherwise.</returns>
|
||||
public static bool operator !=(Sort a, Sort b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality operator for objects of type Sort.
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
Sort casted = o as Sort;
|
||||
if (casted == null) return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash code generation for Sorts
|
||||
/// </summary>
|
||||
/// <returns>A hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a unique identifier for the sort.
|
||||
/// </summary>
|
||||
new public uint Id
|
||||
{
|
||||
get { return Native.Z3_get_sort_id(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the sort.
|
||||
/// </summary>
|
||||
public Z3_sort_kind SortKind
|
||||
{
|
||||
get { return (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sort
|
||||
/// </summary>
|
||||
public Symbol Name
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Symbol>() != null);
|
||||
return Symbol.Create(Context, Native.Z3_get_sort_name(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the sort.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_sort_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
/// <summary>
|
||||
/// Sort constructor
|
||||
/// </summary>
|
||||
internal protected Sort(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
#if DEBUG
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if (Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_SORT_AST)
|
||||
throw new Z3Exception("Underlying object is not a sort");
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
[ContractVerification(true)]
|
||||
new internal static Sort Create(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Ensures(Contract.Result<Sort>() != null);
|
||||
|
||||
switch ((Z3_sort_kind)Native.Z3_get_sort_kind(ctx.nCtx, obj))
|
||||
{
|
||||
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArraySort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BOOL_SORT: return new BoolSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_INT_SORT: return new IntSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_REAL_SORT: return new RealSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown sort kind");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Boolean sort.
|
||||
/// </summary>
|
||||
public class BoolSort : Sort
|
||||
{
|
||||
#region Internal
|
||||
internal BoolSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx)) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// An arithmetic sort, i.e., Int or Real.
|
||||
/// </summary>
|
||||
public class ArithSort : Sort
|
||||
{
|
||||
#region Internal
|
||||
internal ArithSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// An Integer sort
|
||||
/// </summary>
|
||||
public class IntSort : ArithSort
|
||||
{
|
||||
#region Internal
|
||||
internal IntSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal IntSort(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_int_sort(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A real sort
|
||||
/// </summary>
|
||||
public class RealSort : ArithSort
|
||||
{
|
||||
#region Internal
|
||||
internal RealSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal RealSort(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_real_sort(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bit-vector sorts.
|
||||
/// </summary>
|
||||
public class BitVecSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the bit-vector sort.
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_get_bv_sort_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal BitVecSort(Context ctx, uint size) : base(ctx, Native.Z3_mk_bv_sort(ctx.nCtx, size)) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Array sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class ArraySort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The domain of the array sort.
|
||||
/// </summary>
|
||||
public Sort Domain
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Sort>() != null);
|
||||
|
||||
return Sort.Create(Context, Native.Z3_get_array_sort_domain(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The range of the array sort.
|
||||
/// </summary>
|
||||
public Sort Range
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Sort>() != null);
|
||||
|
||||
return Sort.Create(Context, Native.Z3_get_array_sort_range(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ArraySort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal ArraySort(Context ctx, Sort domain, Sort range)
|
||||
: base(ctx, Native.Z3_mk_array_sort(ctx.nCtx, domain.NativeObject, range.NativeObject))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(domain != null);
|
||||
Contract.Requires(range != null);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Datatype sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class DatatypeSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of constructors of the datatype sort.
|
||||
/// </summary>
|
||||
public uint NumConstructors
|
||||
{
|
||||
get { return Native.Z3_get_datatype_sort_num_constructors(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructors.
|
||||
/// </summary>
|
||||
public FuncDecl[] Constructors
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
uint n = NumConstructors;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The recognizers.
|
||||
/// </summary>
|
||||
public FuncDecl[] Recognizers
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
uint n = NumConstructors;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor accessors.
|
||||
/// </summary>
|
||||
public FuncDecl[][] Accessors
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[][]>() != null);
|
||||
|
||||
uint n = NumConstructors;
|
||||
FuncDecl[][] res = new FuncDecl[n][];
|
||||
for (uint i = 0; i < n; i++)
|
||||
{
|
||||
FuncDecl fd = new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, i));
|
||||
uint ds = fd.DomainSize;
|
||||
FuncDecl[] tmp = new FuncDecl[ds];
|
||||
for (uint j = 0; j < ds; j++)
|
||||
tmp[j] = new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor_accessor(Context.nCtx, NativeObject, i, j));
|
||||
res[i] = tmp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal DatatypeSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
internal DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
|
||||
: base(ctx, Native.Z3_mk_datatype(ctx.nCtx, name.NativeObject, (uint)constructors.Length, ArrayToNative(constructors)))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(constructors != null);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Uninterpreted Sorts
|
||||
/// </summary>
|
||||
public class UninterpretedSort : Sort
|
||||
{
|
||||
#region Internal
|
||||
internal UninterpretedSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal UninterpretedSort(Context ctx, Symbol s)
|
||||
: base(ctx, Native.Z3_mk_uninterpreted_sort(ctx.nCtx, s.NativeObject))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(s != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tuple sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class TupleSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor function of the tuple.
|
||||
/// </summary>
|
||||
public FuncDecl MkDecl
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
|
||||
return new FuncDecl(Context, Native.Z3_get_tuple_sort_mk_decl(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of fields in the tuple.
|
||||
/// </summary>
|
||||
public uint NumFields
|
||||
{
|
||||
get { return Native.Z3_get_tuple_sort_num_fields(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The field declarations.
|
||||
/// </summary>
|
||||
public FuncDecl[] FieldDecls
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
uint n = NumFields;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context, Native.Z3_get_tuple_sort_field_decl(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
|
||||
IntPtr t = IntPtr.Zero;
|
||||
NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
|
||||
Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
|
||||
ref t, new IntPtr[numFields]);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class EnumSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The function declarations of the constants in the enumeration.
|
||||
/// </summary>
|
||||
public FuncDecl[] ConstDecls
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
return _constdecls; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constants in the enumeration.
|
||||
/// </summary>
|
||||
public Expr[] Consts
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
return _consts; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test predicates for the constants in the enumeration.
|
||||
/// </summary>
|
||||
public FuncDecl[] TesterDecls
|
||||
{
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
return _testerdecls;
|
||||
}
|
||||
}
|
||||
|
||||
#region Object Invariant
|
||||
|
||||
[ContractInvariantMethod]
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(this._constdecls != null);
|
||||
Contract.Invariant(this._testerdecls != null);
|
||||
Contract.Invariant(this._consts != null);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
readonly private FuncDecl[] _constdecls = null, _testerdecls = null;
|
||||
readonly private Expr[] _consts = null;
|
||||
|
||||
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(enumNames != null);
|
||||
|
||||
int n = enumNames.Length;
|
||||
IntPtr[] n_constdecls = new IntPtr[n];
|
||||
IntPtr[] n_testers = new IntPtr[n];
|
||||
NativeObject = Native.Z3_mk_enumeration_sort(ctx.nCtx, name.NativeObject, (uint)n,
|
||||
Symbol.ArrayToNative(enumNames), n_constdecls, n_testers);
|
||||
_constdecls = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
_constdecls[i] = new FuncDecl(ctx, n_constdecls[i]);
|
||||
_testerdecls = new FuncDecl[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
_testerdecls[i] = new FuncDecl(ctx, n_testers[i]);
|
||||
_consts = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
_consts[i] = ctx.MkApp(_constdecls[i]);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// List sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class ListSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The declaration of the nil function of this list sort.
|
||||
/// </summary>
|
||||
public FuncDecl NilDecl { get {
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return nilDecl; } }
|
||||
|
||||
/// <summary>
|
||||
/// The empty list.
|
||||
/// </summary>
|
||||
public Expr Nil
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
return nilConst;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The declaration of the isNil function of this list sort.
|
||||
/// </summary>
|
||||
public FuncDecl IsNilDecl
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return isNilDecl;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The declaration of the cons function of this list sort.
|
||||
/// </summary>
|
||||
public FuncDecl ConsDecl
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return consDecl;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The declaration of the isCons function of this list sort.
|
||||
/// </summary>
|
||||
///
|
||||
public FuncDecl IsConsDecl
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return isConsDecl;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The declaration of the head function of this list sort.
|
||||
/// </summary>
|
||||
public FuncDecl HeadDecl
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return headDecl;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The declaration of the tail function of this list sort.
|
||||
/// </summary>
|
||||
public FuncDecl TailDecl
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl>() != null);
|
||||
return tailDecl;
|
||||
}
|
||||
}
|
||||
|
||||
#region Object Invariant
|
||||
|
||||
[ContractInvariantMethod]
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(nilConst != null);
|
||||
Contract.Invariant(nilDecl != null);
|
||||
Contract.Invariant(isNilDecl != null);
|
||||
Contract.Invariant(consDecl != null);
|
||||
Contract.Invariant(isConsDecl != null);
|
||||
Contract.Invariant(headDecl != null);
|
||||
Contract.Invariant(tailDecl != null);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
readonly private FuncDecl nilDecl, isNilDecl, consDecl, isConsDecl, headDecl, tailDecl;
|
||||
readonly private Expr nilConst;
|
||||
|
||||
internal ListSort(Context ctx, Symbol name, Sort elemSort)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(elemSort != null);
|
||||
|
||||
IntPtr inil = IntPtr.Zero,
|
||||
iisnil = IntPtr.Zero,
|
||||
icons = IntPtr.Zero,
|
||||
iiscons = IntPtr.Zero,
|
||||
ihead = IntPtr.Zero,
|
||||
itail = IntPtr.Zero;
|
||||
|
||||
NativeObject = Native.Z3_mk_list_sort(ctx.nCtx, name.NativeObject, elemSort.NativeObject,
|
||||
ref inil, ref iisnil, ref icons, ref iiscons, ref ihead, ref itail);
|
||||
nilDecl = new FuncDecl(ctx, inil);
|
||||
isNilDecl = new FuncDecl(ctx, iisnil);
|
||||
consDecl = new FuncDecl(ctx, icons);
|
||||
isConsDecl = new FuncDecl(ctx, iiscons);
|
||||
headDecl = new FuncDecl(ctx, ihead);
|
||||
tailDecl = new FuncDecl(ctx, itail);
|
||||
nilConst = ctx.MkConst(nilDecl);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Relation sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class RelationSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The arity of the relation sort.
|
||||
/// </summary>
|
||||
public uint Arity
|
||||
{
|
||||
get { return Native.Z3_get_relation_arity(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sorts of the columns of the relation sort.
|
||||
/// </summary>
|
||||
public Sort[] ColumnSorts
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Sort[]>() != null);
|
||||
|
||||
if (m_columnSorts != null)
|
||||
return m_columnSorts;
|
||||
|
||||
uint n = Arity;
|
||||
Sort[] res = new Sort[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context, Native.Z3_get_relation_column(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
private Sort[] m_columnSorts = null;
|
||||
|
||||
internal RelationSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finite domain sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class FiniteDomainSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the finite domain sort.
|
||||
/// </summary>
|
||||
public ulong Size
|
||||
{
|
||||
get { ulong res = 0; Native.Z3_get_finite_domain_sort_size(Context.nCtx, NativeObject, ref res); return res; }
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal FiniteDomainSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal FiniteDomainSort(Context ctx, Symbol name, ulong size)
|
||||
: base(ctx, Native.Z3_mk_finite_domain_sort(ctx.nCtx, name.NativeObject, size))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set sorts.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class SetSort : Sort
|
||||
{
|
||||
#region Internal
|
||||
internal SetSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal SetSort(Context ctx, Sort ty)
|
||||
: base(ctx, Native.Z3_mk_set_sort(ctx.nCtx, ty.NativeObject))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(ty != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
206
src/bindings/dotnet/Microsoft.Z3/Statistics.cs
Normal file
206
src/bindings/dotnet/Microsoft.Z3/Statistics.cs
Normal file
|
@ -0,0 +1,206 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Statistics.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Statistics
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-22
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Objects of this class track statistical information about solvers.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Statistics : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// Statistical data is organized into pairs of [Key, Entry], where every
|
||||
/// Entry is either a <c>DoubleEntry</c> or a <c>UIntEntry</c>
|
||||
/// </summary>
|
||||
public class Entry
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of the entry.
|
||||
/// </summary>
|
||||
readonly public string Key;
|
||||
/// <summary>
|
||||
/// The uint-value of the entry.
|
||||
/// </summary>
|
||||
public uint UIntValue { get { return m_uint; } }
|
||||
/// <summary>
|
||||
/// The double-value of the entry.
|
||||
/// </summary>
|
||||
public double DoubleValue { get { return m_double; } }
|
||||
/// <summary>
|
||||
/// True if the entry is uint-valued.
|
||||
/// </summary>
|
||||
public bool IsUInt { get { return m_is_uint; } }
|
||||
/// <summary>
|
||||
/// True if the entry is double-valued.
|
||||
/// </summary>
|
||||
public bool IsDouble { get { return m_is_double; } }
|
||||
|
||||
/// <summary>
|
||||
/// The string representation of the the entry's value.
|
||||
/// </summary>
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
if (IsUInt)
|
||||
return m_uint.ToString();
|
||||
else if (IsDouble)
|
||||
return m_double.ToString();
|
||||
else
|
||||
throw new Z3Exception("Unknown statistical entry type");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The string representation of the Entry.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Key + ": " + Value;
|
||||
}
|
||||
|
||||
#region Internal
|
||||
readonly private bool m_is_uint = false;
|
||||
readonly private bool m_is_double = false;
|
||||
readonly private uint m_uint = 0;
|
||||
readonly private double m_double = 0.0;
|
||||
internal Entry(string k, uint v) { Key = k; m_is_uint = true; m_uint = v; }
|
||||
internal Entry(string k, double v) { Key = k; m_is_double = true; m_double = v; }
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the statistical data.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_stats_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of statistical data.
|
||||
/// </summary>
|
||||
public uint Size
|
||||
{
|
||||
get { return Native.Z3_stats_size(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data entries.
|
||||
/// </summary>
|
||||
public Entry[] Entries
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Entry[]>() != null);
|
||||
Contract.Ensures(Contract.Result<Entry[]>().Length == this.Size);
|
||||
Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length, j => Contract.Result<Entry[]>()[j] != null));
|
||||
|
||||
uint n = Size;
|
||||
Entry[] res = new Entry[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
{
|
||||
Entry e;
|
||||
string k = Native.Z3_stats_get_key(Context.nCtx, NativeObject, i);
|
||||
if (Native.Z3_stats_is_uint(Context.nCtx, NativeObject, i) != 0)
|
||||
e = new Entry(k, Native.Z3_stats_get_uint_value(Context.nCtx, NativeObject, i));
|
||||
else if (Native.Z3_stats_is_double(Context.nCtx, NativeObject, i) != 0)
|
||||
e = new Entry(k, Native.Z3_stats_get_double_value(Context.nCtx, NativeObject, i));
|
||||
else
|
||||
throw new Z3Exception("Unknown data entry value");
|
||||
res[i] = e;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The statistical counters.
|
||||
/// </summary>
|
||||
public string[] Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string[]>() != null);
|
||||
|
||||
uint n = Size;
|
||||
string[] res = new string[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Native.Z3_stats_get_key(Context.nCtx, NativeObject, i);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The value of a particular statistical counter.
|
||||
/// </summary>
|
||||
/// <remarks>Returns null if the key is unknown.</remarks>
|
||||
public Entry this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
uint n = Size;
|
||||
Entry[] es = Entries;
|
||||
for (uint i = 0; i < n; i++)
|
||||
if (es[i].Key == key)
|
||||
return es[i];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Statistics(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_stats_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_stats_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Statistics_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Statistics_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
45
src/bindings/dotnet/Microsoft.Z3/Status.cs
Normal file
45
src/bindings/dotnet/Microsoft.Z3/Status.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Status.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Status
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Status values.
|
||||
/// </summary>
|
||||
public enum Status
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to signify an unsatisfiable status.
|
||||
/// </summary>
|
||||
UNSATISFIABLE = -1,
|
||||
|
||||
/// <summary>
|
||||
/// Used to signify an unknown status.
|
||||
/// </summary>
|
||||
UNKNOWN = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Used to signify a satisfiable status.
|
||||
/// </summary>
|
||||
SATISFIABLE = 1
|
||||
}
|
||||
|
||||
}
|
181
src/bindings/dotnet/Microsoft.Z3/Symbol.cs
Normal file
181
src/bindings/dotnet/Microsoft.Z3/Symbol.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Symbol.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Symbols
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Symbols are used to name several term and type constructors.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Symbol : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The kind of the symbol (int or string)
|
||||
/// </summary>
|
||||
protected Z3_symbol_kind Kind
|
||||
{
|
||||
get { return (Z3_symbol_kind)Native.Z3_get_symbol_kind(Context.nCtx, NativeObject); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the symbol is of Int kind
|
||||
/// </summary>
|
||||
public bool IsIntSymbol()
|
||||
{
|
||||
return Kind == Z3_symbol_kind.Z3_INT_SYMBOL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the symbol is of string kind.
|
||||
/// </summary>
|
||||
public bool IsStringSymbol()
|
||||
{
|
||||
return Kind == Z3_symbol_kind.Z3_STRING_SYMBOL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the symbol.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
if (IsIntSymbol())
|
||||
return ((IntSymbol)this).Int.ToString();
|
||||
else if (IsStringSymbol())
|
||||
return ((StringSymbol)this).String;
|
||||
else
|
||||
throw new Z3Exception("Unknown symbol kind encountered");
|
||||
}
|
||||
|
||||
#region Internal
|
||||
/// <summary>
|
||||
/// Symbol constructor
|
||||
/// </summary>
|
||||
internal protected Symbol(Context ctx, IntPtr obj) : base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal static Symbol Create(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Ensures(Contract.Result<Symbol>() != null);
|
||||
|
||||
switch ((Z3_symbol_kind)Native.Z3_get_symbol_kind(ctx.nCtx, obj))
|
||||
{
|
||||
case Z3_symbol_kind.Z3_INT_SYMBOL: return new IntSymbol(ctx, obj);
|
||||
case Z3_symbol_kind.Z3_STRING_SYMBOL: return new StringSymbol(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown symbol kind encountered");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Numbered symbols
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class IntSymbol : Symbol
|
||||
{
|
||||
/// <summary>
|
||||
/// The int value of the symbol.
|
||||
/// </summary>
|
||||
/// <remarks>Throws an exception if the symbol is not of int kind. </remarks>
|
||||
public int Int
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsIntSymbol())
|
||||
throw new Z3Exception("Int requested from non-Int symbol");
|
||||
return Native.Z3_get_symbol_int(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal IntSymbol(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal IntSymbol(Context ctx, int i)
|
||||
: base(ctx, Native.Z3_mk_int_symbol(ctx.nCtx, i))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if ((Z3_symbol_kind)Native.Z3_get_symbol_kind(Context.nCtx, obj) != Z3_symbol_kind.Z3_INT_SYMBOL)
|
||||
throw new Z3Exception("Symbol is not of integer kind");
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Named symbols
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class StringSymbol : Symbol
|
||||
{
|
||||
/// <summary>
|
||||
/// The string value of the symbol.
|
||||
/// </summary>
|
||||
/// <remarks>Throws an exception if the symbol is not of string kind.</remarks>
|
||||
public string String
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
if (!IsStringSymbol())
|
||||
throw new Z3Exception("String requested from non-String symbol");
|
||||
return Native.Z3_get_symbol_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal StringSymbol(Context ctx, IntPtr obj) : base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal StringSymbol(Context ctx, string s) : base(ctx, Native.Z3_mk_string_symbol(ctx.nCtx, s))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if ((Z3_symbol_kind)Native.Z3_get_symbol_kind(Context.nCtx, obj) != Z3_symbol_kind.Z3_STRING_SYMBOL)
|
||||
throw new Z3Exception("Symbol is not of string kind");
|
||||
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
141
src/bindings/dotnet/Microsoft.Z3/Tactic.cs
Normal file
141
src/bindings/dotnet/Microsoft.Z3/Tactic.cs
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Tactic.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Tactics
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Tactics are the basic building block for creating custom solvers for specific problem domains.
|
||||
/// The complete list of tactics may be obtained using <c>Context.NumTactics</c>
|
||||
/// and <c>Context.TacticNames</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 Tactic : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// A string containing a description of parameters accepted by the tactic.
|
||||
/// </summary>
|
||||
public string Help
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
return Native.Z3_tactic_get_help(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves parameter descriptions for Tactics.
|
||||
/// </summary>
|
||||
public ParamDescrs ParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(Context, Native.Z3_tactic_get_param_descrs(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Execute the tactic over the goal.
|
||||
/// </summary>
|
||||
public ApplyResult Apply(Goal g, Params p = null)
|
||||
{
|
||||
Contract.Requires(g != null);
|
||||
Contract.Ensures(Contract.Result<ApplyResult>() != null);
|
||||
|
||||
Context.CheckContextMatch(g);
|
||||
if (p == null)
|
||||
return new ApplyResult(Context, Native.Z3_tactic_apply(Context.nCtx, NativeObject, g.NativeObject));
|
||||
else
|
||||
{
|
||||
Context.CheckContextMatch(p);
|
||||
return new ApplyResult(Context, Native.Z3_tactic_apply_ex(Context.nCtx, NativeObject, g.NativeObject, p.NativeObject));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply the tactic to a goal.
|
||||
/// </summary>
|
||||
public ApplyResult this[Goal g]
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Requires(g != null);
|
||||
Contract.Ensures(Contract.Result<ApplyResult>() != null);
|
||||
|
||||
return Apply(g);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a solver that is implemented using the given tactic.
|
||||
/// </summary>
|
||||
/// <seealso cref="Context.MkSolver(Tactic)"/>
|
||||
public Solver Solver
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Solver>() != null);
|
||||
|
||||
return Context.MkSolver(this);
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Tactic(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal Tactic(Context ctx, string name)
|
||||
: base(ctx, Native.Z3_mk_tactic(ctx.nCtx, name))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : Z3.DecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_tactic_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_tactic_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Tactic_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Tactic_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
98
src/bindings/dotnet/Microsoft.Z3/Version.cs
Normal file
98
src/bindings/dotnet/Microsoft.Z3/Version.cs
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Version.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Version information
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Version information.
|
||||
/// </summary>
|
||||
/// <remarks>Note that this class is static.</remarks>
|
||||
[ContractVerification(true)]
|
||||
public static class Version
|
||||
{
|
||||
static Version() { }
|
||||
|
||||
/// <summary>
|
||||
/// The major version
|
||||
/// </summary>
|
||||
public static uint Major
|
||||
{
|
||||
get
|
||||
{
|
||||
uint major = 0, minor = 0, build = 0, revision = 0;
|
||||
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);
|
||||
return major;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minor version
|
||||
/// </summary>
|
||||
public static uint Minor
|
||||
{
|
||||
get
|
||||
{
|
||||
uint major = 0, minor = 0, build = 0, revision = 0;
|
||||
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);
|
||||
return minor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The build version
|
||||
/// </summary>
|
||||
public static uint Build
|
||||
{
|
||||
get
|
||||
{
|
||||
uint major = 0, minor = 0, build = 0, revision = 0;
|
||||
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The revision
|
||||
/// </summary>
|
||||
public static uint Revision
|
||||
{
|
||||
get
|
||||
{
|
||||
uint major = 0, minor = 0, build = 0, revision = 0;
|
||||
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);
|
||||
return revision;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string representation of the version information.
|
||||
/// </summary>
|
||||
new public static string ToString()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
|
||||
uint major = 0, minor = 0, build = 0, revision = 0;
|
||||
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);
|
||||
return major.ToString() + "." + minor.ToString() + "." + build.ToString() + "." + revision.ToString();
|
||||
}
|
||||
}
|
||||
}
|
44
src/bindings/dotnet/Microsoft.Z3/Z3Exception.cs
Normal file
44
src/bindings/dotnet/Microsoft.Z3/Z3Exception.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Exception.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Exceptions
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception base class for error reporting from Z3
|
||||
/// </summary>
|
||||
public class Z3Exception : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public Z3Exception() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public Z3Exception(string message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public Z3Exception(string message, System.Exception inner) : base(message, inner) { }
|
||||
}
|
||||
}
|
145
src/bindings/dotnet/Microsoft.Z3/Z3Object.cs
Normal file
145
src/bindings/dotnet/Microsoft.Z3/Z3Object.cs
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Z3Object.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Internal Z3 Objects
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-21
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal base class for interfacing with native Z3 objects.
|
||||
/// Should not be used externally.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Z3Object : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Finalizer.
|
||||
/// </summary>
|
||||
~Z3Object()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes of the underlying native Z3 object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (m_n_obj != IntPtr.Zero)
|
||||
{
|
||||
DecRef(m_n_obj);
|
||||
m_n_obj = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (m_ctx != null)
|
||||
{
|
||||
m_ctx.refCount--;
|
||||
if (m_ctx.refCount == 0)
|
||||
GC.ReRegisterForFinalize(m_ctx);
|
||||
m_ctx = null;
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#region Object Invariant
|
||||
|
||||
[ContractInvariantMethod]
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
Contract.Invariant(this.m_ctx != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
private Context m_ctx = null;
|
||||
private IntPtr m_n_obj = IntPtr.Zero;
|
||||
|
||||
internal Z3Object(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
ctx.refCount++;
|
||||
m_ctx = ctx;
|
||||
}
|
||||
|
||||
internal Z3Object(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
ctx.refCount++;
|
||||
m_ctx = ctx;
|
||||
IncRef(obj);
|
||||
m_n_obj = obj;
|
||||
}
|
||||
|
||||
internal virtual void IncRef(IntPtr o) { }
|
||||
internal virtual void DecRef(IntPtr o) { }
|
||||
|
||||
internal virtual void CheckNativeObject(IntPtr obj) { }
|
||||
|
||||
internal virtual IntPtr NativeObject
|
||||
{
|
||||
get { return m_n_obj; }
|
||||
set
|
||||
{
|
||||
if (value != IntPtr.Zero) { CheckNativeObject(value); IncRef(value); }
|
||||
if (m_n_obj != IntPtr.Zero) { DecRef(m_n_obj); }
|
||||
m_n_obj = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static IntPtr GetNativeObject(Z3Object s)
|
||||
{
|
||||
if (s == null) return new IntPtr();
|
||||
return s.NativeObject;
|
||||
}
|
||||
|
||||
internal Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Context>() != null);
|
||||
return m_ctx;
|
||||
}
|
||||
}
|
||||
|
||||
[Pure]
|
||||
internal static IntPtr[] ArrayToNative(Z3Object[] a)
|
||||
{
|
||||
Contract.Ensures(a == null || Contract.Result<IntPtr[]>() != null);
|
||||
Contract.Ensures(a == null || Contract.Result<IntPtr[]>().Length == a.Length);
|
||||
|
||||
if (a == null) return null;
|
||||
IntPtr[] an = new IntPtr[a.Length];
|
||||
for (uint i = 0; i < a.Length; i++)
|
||||
if (a[i] != null) an[i] = a[i].NativeObject;
|
||||
return an;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
internal static uint ArrayLength(Z3Object[] a)
|
||||
{
|
||||
return (a == null)?0:(uint)a.Length;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
34
src/bindings/dotnet/Microsoft.Z3V3/AssemblyInfo.cpp
Normal file
34
src/bindings/dotnet/Microsoft.Z3V3/AssemblyInfo.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
using namespace System;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::Security::Permissions;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly:AssemblyTitleAttribute("Z3 .NET Interface")];
|
||||
[assembly:AssemblyDescriptionAttribute(".NET Interface to the Z3 Theorem Prover")];
|
||||
[assembly:AssemblyConfigurationAttribute("")];
|
||||
[assembly:AssemblyCompanyAttribute("Microsoft Corporation")];
|
||||
[assembly:AssemblyProductAttribute("Z3")];
|
||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) Microsoft Corporation 2006")];
|
||||
[assembly:AssemblyTrademarkAttribute("")];
|
||||
[assembly:AssemblyCultureAttribute("")];
|
||||
|
||||
[assembly:ComVisible(false)];
|
||||
[assembly:CLSCompliantAttribute(true)];
|
||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
||||
|
||||
[assembly:AssemblyVersionAttribute("4.2.0.0")];
|
||||
[assembly:AssemblyFileVersionAttribute("4.2.0.0")];
|
||||
|
||||
//#ifdef DELAYSIGN
|
||||
//[assembly:AssemblyKeyFile("35MSSharedLib1024.snk")];
|
||||
//[assembly:AssemblyDelaySign(true)];
|
||||
//#else
|
||||
//[assembly:AssemblyKeyFile("z3.snk")];
|
||||
//[assembly:AssemblyDelaySign(true)];
|
||||
//#endif
|
3260
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.cpp
Normal file
3260
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.cpp
Normal file
File diff suppressed because it is too large
Load diff
4775
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.h
Normal file
4775
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.h
Normal file
File diff suppressed because it is too large
Load diff
555
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.vcxproj
Normal file
555
src/bindings/dotnet/Microsoft.Z3V3/Microsoft.Z3V3.vcxproj
Normal file
|
@ -0,0 +1,555 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="commercial|Win32">
|
||||
<Configuration>commercial</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="commercial|x64">
|
||||
<Configuration>commercial</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="external|Win32">
|
||||
<Configuration>external</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="external|x64">
|
||||
<Configuration>external</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_mt|Win32">
|
||||
<Configuration>release_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_mt|x64">
|
||||
<Configuration>release_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Trace|Win32">
|
||||
<Configuration>Trace</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Trace|x64">
|
||||
<Configuration>Trace</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F008F2C4-D652-4A58-8DEF-DB83E2355454}</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Z3V3</RootNamespace>
|
||||
<Keyword>ManagedCProj</Keyword>
|
||||
<ProjectName>Microsoft.Z3V3</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='external|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='external|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='commercial|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Trace|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='external|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='external|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='commercial|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Trace|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Trace|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Trace|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Trace|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='external|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='external|Win32'">$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='external|Win32'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='external|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='commercial|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='external|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='commercial|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='external|x64'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='commercial|x64'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='commercial_64|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='external|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='external|Win32'" />
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='external|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='external|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='commercial|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='external|x64'" />
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='commercial|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='external|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='commercial|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Trace|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Trace|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Trace|x64'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_WINDOWS;_TRACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_TRACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Trace|Win32'">
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Trace|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|Win32'">
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='external|Win32'">
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_EXTERNAL_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<Profile>true</Profile>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='commercial|Win32'">
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_Z3_COMMERCIAL;_EXTERNAL_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='external|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_EXTERNAL_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<Profile>true</Profile>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='commercial|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_Z3_COMMERCIAL;_AMD64_;_EXTERNAL_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)Microsoft.Z3V3.dll</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'">
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_mt|x64'">
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Xml">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
<ClCompile Include="Microsoft.Z3V3.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Microsoft.Z3V3.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\lib\lib.vcxproj">
|
||||
<Project>{4a7e5a93-19d8-4382-8950-fb2edec7a76e}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
src/bindings/ml/README-linux
Normal file
22
src/bindings/ml/README-linux
Normal file
|
@ -0,0 +1,22 @@
|
|||
The OCaml API for Z3 was tested using OCaml 3.12.1.
|
||||
You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- To build the OCaml API for Z3:
|
||||
./build-lib.sh
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
|
||||
Remark: Building the OCaml API copies some pathnames into files,
|
||||
so the OCaml API must be recompiled if the Z3 library files are moved.
|
||||
|
||||
See ../examples/ocaml/build-test.sh for an example of how to compile and link with Z3.
|
||||
|
||||
Acknowledgements:
|
||||
The OCaml interface for Z3 was written by Josh Berdine and Jakob Lichtenberg.
|
||||
Many thanks to them!
|
22
src/bindings/ml/README-osx
Normal file
22
src/bindings/ml/README-osx
Normal file
|
@ -0,0 +1,22 @@
|
|||
The OCaml API for Z3 was tested using OCaml 3.12.1.
|
||||
You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- To build the OCaml API for Z3:
|
||||
./build-lib.sh
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
|
||||
Remark: Building the OCaml API copies some pathnames into files,
|
||||
so the OCaml API must be recompiled if the Z3 library files are moved.
|
||||
|
||||
See ../examples/ocaml/build-test.sh for an example of how to compile and link with Z3.
|
||||
|
||||
Acknowledgements:
|
||||
The OCaml interface for Z3 was written by Josh Berdine and Jakob Lichtenberg.
|
||||
Many thanks to them!
|
17
src/bindings/ml/README-test-linux
Normal file
17
src/bindings/ml/README-test-linux
Normal file
|
@ -0,0 +1,17 @@
|
|||
This directory contains scripts to build the test application using
|
||||
OCaml. You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- One must build the OCaml library before compiling the example.
|
||||
Go to directory ../ocaml
|
||||
|
||||
- Use 'build-test.sh' to build the test application using the OCaml compiler.
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
|
||||
- Use 'exec.sh' to execute test_mlapi. The script sets LD_LIBRARY_PATH, and invokes test_mlapi.
|
17
src/bindings/ml/README-test-osx
Normal file
17
src/bindings/ml/README-test-osx
Normal file
|
@ -0,0 +1,17 @@
|
|||
This directory contains scripts to build the test application using
|
||||
OCaml. You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- One must build the OCaml library before compiling the example.
|
||||
Go to directory ../ocaml
|
||||
|
||||
- Use 'build-test.sh' to build the test application using the OCaml compiler.
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
|
||||
- Use 'exec.sh' to execute test_mlapi. The script sets DYLD_LIBRARY_PATH, and invokes test_mlapi.
|
23
src/bindings/ml/README-test-win
Normal file
23
src/bindings/ml/README-test-win
Normal file
|
@ -0,0 +1,23 @@
|
|||
This directory contains scripts to build the test application using
|
||||
OCaml. You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- One must build the OCaml library before compiling the example.
|
||||
Go to directory ../ocaml
|
||||
|
||||
- Use 'build-test.cmd' to build the test application using the OCaml compiler.
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
Running from the Visual Studio Command Prompt configures the Microsoft C compiler.
|
||||
|
||||
- The script 'exec.cmd' adds the bin directory to the path. So,
|
||||
test_mlapi.exe can find z3.dll.
|
||||
|
||||
|
||||
|
||||
|
23
src/bindings/ml/README-win
Normal file
23
src/bindings/ml/README-win
Normal file
|
@ -0,0 +1,23 @@
|
|||
The OCaml API for Z3 was tested using OCaml 3.12.1.
|
||||
You also need CamlIDL to be able to generate the OCaml API.
|
||||
|
||||
- To download OCaml:
|
||||
http://caml.inria.fr/ocaml/
|
||||
|
||||
- To download CamlIDL:
|
||||
http://forge.ocamlcore.org/projects/camlidl/
|
||||
|
||||
- To build the OCaml API for Z3:
|
||||
.\build-lib.cmd
|
||||
|
||||
Remark: The OCaml and C compiler tool chains must be configured in your environment.
|
||||
Running from the Visual Studio Command Prompt configures the Microsoft C compiler.
|
||||
|
||||
Remark: Building the OCaml API copies some pathnames into files,
|
||||
so the OCaml API must be recompiled if the Z3 library files are moved.
|
||||
|
||||
See ..\examples\ocaml\build-test.cmd for an example of how to compile and link with Z3.
|
||||
|
||||
Acknowledgements:
|
||||
The OCaml interface for Z3 was written by Josh Berdine and Jakob Lichtenberg.
|
||||
Many thanks to them!
|
2
src/bindings/ml/add_error_checking.V3.sed
Normal file
2
src/bindings/ml/add_error_checking.V3.sed
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Customize error handling for contexts created in ML:
|
||||
s/Z3_API Z3_mk_context\(_rc\|\)(\(.*\))/Z3_API Z3_mk_context\1(\2) quote(dealloc,\"Z3_set_error_handler(_res, caml_z3_error_handler);\")/g
|
86
src/bindings/ml/add_error_checking.sed
Normal file
86
src/bindings/ml/add_error_checking.sed
Normal file
|
@ -0,0 +1,86 @@
|
|||
# Do not add epilogue to Z3_del_context
|
||||
/Z3_API .*Z3_del_context.*/b endt
|
||||
|
||||
# Add error checking epilogue for all Z3_API functions that accept two Z3_contexts
|
||||
:begincc
|
||||
# add epilogue for two Z3_context parameters
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\")\7/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with two Z3_contexts
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endcc
|
||||
|
||||
# if incomplete prototype
|
||||
/Z3_API .*(.*/{
|
||||
|
||||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for two Z3_context parameters
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")\7/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
t endt
|
||||
|
||||
# else keep looking for two Z3_contexts
|
||||
b begincc
|
||||
}
|
||||
:endcc
|
||||
|
||||
# Add error checking epilogue for all Z3_API functions that accept one Z3_context
|
||||
:beginc
|
||||
# add epilogue for one Z3_context parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with all Z3_contexts
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endc
|
||||
|
||||
# if incomplete prototype
|
||||
/Z3_API .*(.*/{
|
||||
|
||||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for one Z3_context parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
t endt
|
||||
|
||||
# else keep looking for one Z3_context
|
||||
b beginc
|
||||
}
|
||||
:endc
|
||||
|
||||
|
||||
# Add error checking epilogue for all Z3_API functions that accept a Z3_theory
|
||||
:begint
|
||||
# add epilogue for one Z3_theory parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_contexts and Z3_theorys
|
||||
t endt
|
||||
|
||||
# if complete prototype, done with all Z3_theorys
|
||||
/Z3_API .*(.*)\(;\|\)[ ]*$/b endt
|
||||
|
||||
/Z3_API .*(.*/{
|
||||
|
||||
# read another line
|
||||
N
|
||||
|
||||
# add epilogue for one Z3_theory parameter
|
||||
s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g
|
||||
|
||||
# if a match was found, done with all Z3_theorys
|
||||
t endt
|
||||
|
||||
# else keep looking for one Z3_theory
|
||||
b begint
|
||||
}
|
||||
:endt
|
3
src/bindings/ml/build-lib.cmd
Executable file
3
src/bindings/ml/build-lib.cmd
Executable file
|
@ -0,0 +1,3 @@
|
|||
@echo off
|
||||
|
||||
call .\compile_mlapi.cmd ..\include ..\bin ..\bin
|
31
src/bindings/ml/build-lib.sh
Normal file
31
src/bindings/ml/build-lib.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to compile the Z3 OCaml API
|
||||
# Expects to find ../lib/libz3{,_dbg}.{a,so,dylib}
|
||||
|
||||
CFLAGS="-ccopt -Wno-discard-qual -ccopt -I../include"
|
||||
XCDBG="-g -ccopt -g $CFLAGS"
|
||||
XCOPT="-ccopt -O3 -ccopt -fomit-frame-pointer $CFLAGS"
|
||||
|
||||
|
||||
ocamlc -c $XCDBG z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
|
||||
ocamlopt -c $XCDBG z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
|
||||
ar rcs libz3stubs_dbg.a z3.o z3_stubs.o z3_theory_stubs.o
|
||||
|
||||
ocamlopt -c $XCOPT z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
|
||||
ar rcs libz3stubs.a z3.o z3_stubs.o z3_theory_stubs.o
|
||||
|
||||
ocamlc -custom -a $XCDBG -cclib -L$PWD/../lib -cclib -lz3_dbg -cclib -lcamlidl -cclib -lz3stubs_dbg z3.cmo -o z3_dbg.cma
|
||||
|
||||
ocamlc -custom -a $XCDBG -cclib -L$PWD/../lib -cclib -lz3 -cclib -lcamlidl -cclib -lz3stubs z3.cmo -o z3.cma
|
||||
|
||||
ocamlopt -a $XCDBG -cclib -L$PWD/../lib -cclib -lz3_dbg -cclib -lcamlidl -cclib -lz3stubs_dbg z3.cmx -o z3_dbg.cmxa
|
||||
|
||||
ocamlopt -a $XCOPT -cclib -L$PWD/../lib -cclib -lz3 -cclib -lcamlidl -cclib -lz3stubs z3.cmx -o z3.cmxa
|
||||
|
||||
ocamlmktop -o ocamlz3 z3.cma -cclib -L.
|
||||
|
||||
rm z3.cm{o,x} *.o
|
19
src/bindings/ml/build-test.cmd
Executable file
19
src/bindings/ml/build-test.cmd
Executable file
|
@ -0,0 +1,19 @@
|
|||
@echo off
|
||||
|
||||
if not exist ..\..\ocaml\z3.cmxa (
|
||||
echo "YOU MUST BUILD OCAML API! Go to directory ..\ocaml"
|
||||
goto :EOF
|
||||
)
|
||||
|
||||
REM ocaml (>= 3.11) calls the linker through flexlink
|
||||
ocamlc -version >> ocaml_version
|
||||
set /p OCAML_VERSION= <ocaml_version
|
||||
if %OCAML_VERSION% GEQ 3.11 (
|
||||
set XCFLAGS=
|
||||
) else (
|
||||
set XCFLAGS=/nologo /MT /DWIN32
|
||||
)
|
||||
|
||||
ocamlc -w A -ccopt "%XCFLAGS%" -o test_mlapi_byte.exe -I ..\..\ocaml z3.cma test_mlapi.ml
|
||||
|
||||
ocamlopt -w A -ccopt "%XCFLAGS%" -o test_mlapi.exe -I ..\..\ocaml z3.cmxa test_mlapi.ml
|
6
src/bindings/ml/build-test.sh
Normal file
6
src/bindings/ml/build-test.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
ocamlc -o test_mlapi.byte -I ../../ocaml/ z3.cma test_mlapi.ml
|
||||
ocamlopt -o test_mlapi -I ../../ocaml/ z3.cmxa test_mlapi.ml
|
||||
|
||||
rm *.cm{i,o,x} *.o
|
53
src/bindings/ml/build.cmd
Executable file
53
src/bindings/ml/build.cmd
Executable file
|
@ -0,0 +1,53 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
REM Script to generate, compile, test, and document the Z3 OCaml API
|
||||
REM
|
||||
REM Assumes that environment variables are set to provide access to the C and OCaml compilers, including flexdll and camlidl, as well as the following commands: diff, dos2unix, grep, sed, unix2dos
|
||||
REM
|
||||
REM usage: build.cmd [32|64] [-D UNSAFE_ERRORS] [-D LEAK_CONTEXTS]
|
||||
REM
|
||||
REM Invoke with "-D UNSAFE_ERRORS" to build version that does not support recoverable errors, but avoids some error-checking overhead.
|
||||
REM Invoke with "-D LEAK_CONTEXTS" to build version that leaks Z3_context objects, but avoids some garbage-collection overhead.
|
||||
|
||||
if ""%1 == "" (
|
||||
set BITS=32
|
||||
) else (
|
||||
set BITS=%1
|
||||
)
|
||||
|
||||
if %BITS% == 32 (
|
||||
set ARCH=x86
|
||||
set Z3BIN= ..\external
|
||||
set Z3DBG= ..\Debug
|
||||
) else (
|
||||
set ARCH=x64
|
||||
set Z3BIN= ..\x64\external_64
|
||||
set Z3DBG= ..\x64\Debug
|
||||
)
|
||||
|
||||
echo { Cleaning
|
||||
call .\clean.cmd
|
||||
echo }
|
||||
|
||||
echo { Generating OCaml API %3 %5
|
||||
call .\generate_mlapi.cmd %2 %3 %4 %5
|
||||
if errorlevel 1 goto :EOF
|
||||
echo }
|
||||
|
||||
echo { Compiling OCaml API
|
||||
call .\compile_mlapi.cmd ..\lib %Z3BIN% %Z3DBG%
|
||||
if errorlevel 1 goto :EOF
|
||||
echo }
|
||||
|
||||
echo { Testing OCaml API
|
||||
call .\test_mlapi.cmd ..\lib %Z3BIN% %Z3DBG%
|
||||
if errorlevel 1 goto :EOF
|
||||
echo }
|
||||
|
||||
echo { Generating OCaml API documentation
|
||||
call .\update-ml-doc.cmd ..\doc
|
||||
if errorlevel 1 goto :EOF
|
||||
echo }
|
||||
|
||||
ENDLOCAL
|
82
src/bindings/ml/build.sed
Normal file
82
src/bindings/ml/build.sed
Normal file
|
@ -0,0 +1,82 @@
|
|||
# attempt to clean up the mess with 'unsigned'
|
||||
s/__in unsigned __/__in __/g
|
||||
s/__out unsigned __/__out __/g
|
||||
s/__out_opt unsigned __/__out_opt __/g
|
||||
|
||||
|
||||
# '@name ' -> 'Section: '
|
||||
# '\sa ' -> 'See also: '
|
||||
# '\brief ' -> 'Summary: '
|
||||
# '\remark ' -> 'Remark: '
|
||||
# '\pre ' -> 'Precondition: '
|
||||
# '\param ' -> '@param'
|
||||
# '\warning ' -> 'Warning: '
|
||||
# '\code' -> 'C Example:'
|
||||
# '\endcode' -> ''
|
||||
/\\pre/s/(/ /g;/\\pre/s/,//g;/\\pre/s/)//g;s/\\pre /- {b Precondition}: /g
|
||||
/\\ccode/s/(/ /g;/\\ccode/s/\\,//g;/\\ccode/s/)//g;s/\\ccode{\(.*\)}/\[\1\]/g
|
||||
s/\\defgroup .*//g
|
||||
s/@name \(.*\)/{2 {L \1}}/g
|
||||
s/\\sa \(.*\)/- {b See also}: {!Z3.\1}/g
|
||||
s/\\see \(.*\)/- {b See}: {!Z3.\1}/g
|
||||
s/<tt>/{e /g
|
||||
s|</tt>| }|g
|
||||
s/\\nicebox{/{e/g
|
||||
s/\\brief /Summary: /g
|
||||
s/\\remark /- {b Remarks}: /g
|
||||
s/\\pre /- {b Precondition}: /g
|
||||
s/\\param /@param /g
|
||||
s/\\conly .*//g
|
||||
s/\\warning /- {b Warning}: /g
|
||||
s/\\code/{v /g
|
||||
s/\\endcode/ v}/g
|
||||
s/\\verbatim/{v /g
|
||||
s/\\endverbatim/ v}/g
|
||||
s/\\mlonly//g
|
||||
s/\\endmlonly//g
|
||||
s/\\mlh/\\\[ \[/g
|
||||
s/\\endmlh/\] \\\]/g
|
||||
s/\\deprecated/@deprecated/g
|
||||
s/\\ / /g
|
||||
|
||||
# '\c code ' -> '[code]'
|
||||
s/\\c \([^ .,:]*\)/[\1]/g
|
||||
|
||||
# '#Z3_' -> 'Z3.'
|
||||
s/#Z3_\([^ \n\.\t,)]*\)/{!Z3.\1}/g
|
||||
|
||||
# '/*@}*/' -> ''
|
||||
s/\/\*@{\*\///g
|
||||
|
||||
# '/*@{*/' -> ''
|
||||
s/\/\*@}\*\///g
|
||||
|
||||
# '/*...*/' -> ''
|
||||
s/\/\*.*\*\///g
|
||||
|
||||
s|(\*\*/\*\*)|(\*\*%\*\*)|g
|
||||
|
||||
# '/**' -> 'quote(mli,"(**'
|
||||
s|/\*\*|quote(mli,\"(**|g
|
||||
|
||||
# '...*/' -> '*)");'
|
||||
s|[ ]*\*/|*)\");|g
|
||||
|
||||
s|(\*\*%\*\*)|(\*\*/\*\*)|g
|
||||
|
||||
# 'extern "C"' -> 'extern ~~C~~'
|
||||
# 'quote(foo,"bar")' -> quote(foo,~~bar~~)
|
||||
# mltype("foo") -> mltype(~~foo~~)
|
||||
s/extern \"C\"/extern ~~C~~/g
|
||||
s/quote(\(.*\),\"\(.*\)\")/quote(\1,~~\2~~)/g
|
||||
s/quote(\(.*\),\"/quote(\1,~~/g
|
||||
s/\")\;/~~);/g
|
||||
s/\;\"/;~~/g
|
||||
s/mltype(\"\(.*\)\")/mltype(~~\1~~)/g
|
||||
|
||||
# '"' -> '\"'
|
||||
s/\\\"/\"/g
|
||||
s/\"/\\\"/g
|
||||
|
||||
# '~~' -> '"'
|
||||
s/~~/\"/g
|
13
src/bindings/ml/clean.cmd
Executable file
13
src/bindings/ml/clean.cmd
Executable file
|
@ -0,0 +1,13 @@
|
|||
@echo off
|
||||
|
||||
REM Script to delete generated Z3 OCaml API files
|
||||
|
||||
call .\cleantmp.cmd
|
||||
|
||||
REM files produced by generate_mlapi.cmd
|
||||
del /q 2>NUL z3_stubs.c z3.mli z3.ml z3V3_stubs.*.c z3V3.*.mli z3V3.*.ml
|
||||
|
||||
REM files produced by update-ml-doc.cmd
|
||||
rd 2>NUL /s /q doc
|
||||
|
||||
exit /B 0
|
15
src/bindings/ml/cleantmp.cmd
Executable file
15
src/bindings/ml/cleantmp.cmd
Executable file
|
@ -0,0 +1,15 @@
|
|||
@echo off
|
||||
|
||||
REM Script to delete intermediate temporary files from generating Z3 OCaml API
|
||||
|
||||
REM files produced by generate_mlapi.cmd
|
||||
del /q 2>NUL z3_api.idl
|
||||
|
||||
REM files produced by compile_mlapi.cmd
|
||||
del /q 2>NUL *.cmi *.cmo *.cmx *.cma *.cmxa *.obj *.lib *.pdb ocamlz3.exe
|
||||
|
||||
REM files produced by test_mlapi.cmd
|
||||
del /q 2>NUL test*.exe queen*.exe test_*api.out test_*apiV3.out test_*api.err test_*apiV3.err queen.out queen.err z3.log ml.log test_mlapi.log .z3-trace
|
||||
|
||||
REM backup files
|
||||
del /q 2>NUL *~
|
98
src/bindings/ml/compile_mlapi.cmd
Executable file
98
src/bindings/ml/compile_mlapi.cmd
Executable file
|
@ -0,0 +1,98 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
REM Script to compile the Z3 OCaml API
|
||||
REM
|
||||
REM Compiles byte and debug native code versions with debug info, optimized native code versions without
|
||||
REM
|
||||
REM Assumes that environment variables are set to provide access to the C and OCaml compilers
|
||||
|
||||
REM directory containing z3_api.h
|
||||
set Z3SRC=%1
|
||||
|
||||
REM directory containing z3.dll
|
||||
set Z3BIN=%2
|
||||
|
||||
REM directory containing debug z3.dll
|
||||
set Z3BINDBG=%3
|
||||
|
||||
REM link Z3 statically or dynamically
|
||||
set STATIC=false
|
||||
REM set STATIC=true
|
||||
|
||||
if %STATIC% == true (
|
||||
set Z3LIB=z3lib.lib
|
||||
set Z3DBGLIB=z3lib.lib
|
||||
) else (
|
||||
set Z3LIB=z3.lib
|
||||
set Z3DBGLIB=z3.lib
|
||||
)
|
||||
|
||||
REM ocaml 3.11 and later calls the linker through flexlink
|
||||
ocamlc -version >> ocaml_version
|
||||
set /p OCAML_VERSION= <ocaml_version
|
||||
del ocaml_version
|
||||
if %OCAML_VERSION% GEQ 3.11 (
|
||||
set XCFLAGS=
|
||||
) else (
|
||||
REM add /MT if building the multithreaded version
|
||||
set XCFLAGS=/nologo /DWIN32
|
||||
)
|
||||
|
||||
set XINCLUDE=-ccopt -I%Z3SRC%
|
||||
set XLIBPATH=/LIBPATH:%Z3BIN%
|
||||
set XCDBG=-g %XCFLAGS% %XINCLUDE%
|
||||
set XCOPT=-ccopt /Ox -ccopt /Oy- %XCFLAGS% %XINCLUDE%
|
||||
|
||||
|
||||
REM z3_stubs.c z3_theory_stubs.c z3.mli z3.ml -> DBG z3_stubs.obj z3.{cmi,cmo,obj}
|
||||
ocamlc -c %XCDBG% z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM z3_stubs.c z3_theory_stubs.c z3.mli z3.ml -> DBG z3_stubs.obj z3.{cmi,cmx,obj}
|
||||
ocamlopt -c %XCDBG% z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM %Z3DBGLIB% z3.obj z3_stubs.obj z3_theory_stubs.obj -> libz3_dbg.lib:
|
||||
lib /nologo %XLIBPATH% /out:libz3_dbg.lib %Z3BINDBG%\%Z3DBGLIB% z3.obj z3_stubs.obj z3_theory_stubs.obj
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM z3_stubs.c z3_theory_stubs.c z3.mli z3.ml -> OPT z3_stubs.obj z3.{cmi,cmx,obj}
|
||||
ocamlopt -c %XCOPT% z3_stubs.c z3_theory_stubs.c z3.mli z3.ml
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM %Z3LIB% z3.obj z3_stubs.obj z3_theory_stubs.obj -> libz3.lib:
|
||||
lib /nologo %XLIBPATH% /out:libz3.lib %Z3BIN%\%Z3LIB% z3.obj z3_stubs.obj z3_theory_stubs.obj
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
|
||||
REM ole32.lib is needed by camlidl
|
||||
REM camlidl.lib is the runtime library for camlidl
|
||||
REM psapi.lib is needed when statically linking Z3 for process statistics functions
|
||||
|
||||
REM libz3_dbg.lib ole32.lib camlidl.lib z3.cmo -> z3_dbg.cma
|
||||
ocamlc -custom -a %XCDBG% -cclib -L"%CD%\..\bin" -cclib -lz3_dbg -cclib ole32.lib -cclib -lcamlidl -cclib psapi.lib z3.cmo -o z3_dbg.cma
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM libz3.lib ole32.lib camlidl.lib z3.cmo -> z3.cma
|
||||
ocamlc -custom -a -cclib -L"%CD%\..\bin" -cclib -lz3 -cclib ole32.lib -cclib -lcamlidl -cclib psapi.lib z3.cmo -o z3.cma
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
|
||||
REM libz3_dbg.lib ole32.lib camlidl.lib z3.cmx -> z3_dbg.cmxa
|
||||
ocamlopt -a -cclib -L"%CD%\..\bin" -cclib -lz3_dbg -cclib ole32.lib -cclib -lcamlidl -cclib psapi.lib z3.cmx -o z3_dbg.cmxa
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM libz3.lib ole32.lib camlidl.lib z3.cmx -> z3.cmxa
|
||||
ocamlopt -a -cclib -L"%CD%\..\bin" -cclib -lz3 -cclib ole32.lib -cclib -lcamlidl -cclib psapi.lib z3.cmx -o z3.cmxa
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
|
||||
REM build OCaml toplevel 'ocamlz3' pre-linked with Z3
|
||||
ocamlmktop -o ocamlz3 z3.cma
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
|
||||
del /q 2>NUL z3.cmo z3.cmx *.obj
|
||||
|
||||
ENDLOCAL
|
162
src/bindings/ml/error_handling.idl
Normal file
162
src/bindings/ml/error_handling.idl
Normal file
|
@ -0,0 +1,162 @@
|
|||
/*++
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
error_handling
|
||||
|
||||
Abstract:
|
||||
|
||||
Error handling in the OCaml API for Z3.
|
||||
|
||||
The wrapper of each Z3 API routine that takes a Z3_context or a Z3_theory
|
||||
argument calls check_error_code before returning. (These calls are added
|
||||
in generate_mlapi.cmd using the build.sed script.)
|
||||
|
||||
There are two error handling schemes implemented, depending on whether
|
||||
(UN)SAFE_ERRORS is set.
|
||||
|
||||
- SAFE_ERRORS checks Z3_error_code after each call and raises an OCaml
|
||||
exception in error conditions. Z3_set_error_handler is not exposed by
|
||||
the SAFE_ERRORS version.
|
||||
|
||||
- UNSAFE_ERRORS sets a Z3 error handler routine that either calls a
|
||||
globally registered OCaml function or, by default, raises an OCaml
|
||||
exception. This avoids overhead of repeatedly checking
|
||||
Z3_get_error_code, but leaves Z3 in a broken state.
|
||||
|
||||
Notes:
|
||||
|
||||
The current SAFE_ERRORS implementation interacts badly with theory plugin
|
||||
callbacks. Z3 errors are converted into OCaml exceptions, which the
|
||||
wrappers of theory plugin callbacks are not expecting. Therefore, if a
|
||||
theory plugin calls a Z3 API routine that triggers an error, an OCaml
|
||||
exception will be raised and bypass any C++ destructors pushed onto the
|
||||
stack by Z3 before the call to the plugin and after the preceding OCaml
|
||||
exception handler. One solution to this would be to modify the theory
|
||||
plugin callback registration functions to wrap callbacks in an OCaml
|
||||
exception handler. Since OCaml exceptions are cheap to raise at the
|
||||
expense of some cost to install a handler, this may not be desirable.
|
||||
Another solution would be to modify check_error_code to detect if it is
|
||||
executing in a plugin callback and simply maintain the Z3_error_code, or
|
||||
raise a C++ exception, instead of raising an OCaml exception.
|
||||
|
||||
Author:
|
||||
|
||||
Josh Berdine (jjb) 2012-03-21
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
#if !defined(UNSAFE_ERRORS) && !defined(SAFE_ERRORS)
|
||||
#define SAFE_ERRORS
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SAFE_ERRORS
|
||||
|
||||
quote(mlmli,"
|
||||
(** Exceptions raised by Z3. It is safe to continue interacting with Z3 after
|
||||
catching [Error] exceptions.
|
||||
|
||||
- {b See also}: {!get_error_msg}
|
||||
*)
|
||||
exception Error of context * error_code
|
||||
");
|
||||
quote(ml,"
|
||||
/* Register dynamically-generated exception tag for use from C */
|
||||
let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK))
|
||||
");
|
||||
|
||||
quote(c,"
|
||||
value camlidl_c2ml_z3_Z3_error_code(Z3_error_code * _c2, camlidl_ctx _ctx);
|
||||
|
||||
/* Error checking routine that raises OCaml Error exceptions */
|
||||
void check_error_code (Z3_context c)
|
||||
{
|
||||
static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
|
||||
value* exn_tag = NULL;
|
||||
value ctx_err[2];
|
||||
Z3_error_code e;
|
||||
e = Z3_get_error_code(c);
|
||||
if (e != Z3_OK) {
|
||||
ctx_err[0] = c2ml_Z3_context(&c);
|
||||
ctx_err[1] = camlidl_c2ml_z3_Z3_error_code(&e, &_ctxs);
|
||||
exn_tag = caml_named_value(\"Z3.Error\");
|
||||
if (*exn_tag == 0) {
|
||||
fprintf(stderr, \"Z3.Error not found\");
|
||||
exit(1);
|
||||
}
|
||||
caml_raise_with_args(*exn_tag, 2, ctx_err);
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable default error handler, all error checking is done by check_error_code */
|
||||
void* error_handler_static = NULL;
|
||||
");
|
||||
|
||||
#else
|
||||
|
||||
quote(mlmli,"
|
||||
(** Exceptions raised by Z3. {b Warning}: It is unsafe to continue
|
||||
interacting with Z3 after catching [Error] exceptions. To recover from
|
||||
error conditions, use {!set_error_handler} to set an error handler that
|
||||
does nothing, and then test {!get_error_code} after every call to Z3.
|
||||
|
||||
- {b See also}: {!get_error_msg}
|
||||
*)
|
||||
exception Error of context * error_code
|
||||
");
|
||||
quote(ml,"
|
||||
/* Register dynamically-generated exception tag for use from C */
|
||||
let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK))
|
||||
");
|
||||
|
||||
quote(c,"
|
||||
/* Error checking routine that does nothing */
|
||||
void check_error_code(Z3_context c) {}
|
||||
|
||||
/* All contexts share the same handler */
|
||||
static value caml_error_handler = 0;
|
||||
|
||||
static void error_handler_static (Z3_context c, Z3_error_code e)
|
||||
{
|
||||
static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
|
||||
value* exn_tag = NULL;
|
||||
value ctx_err[2];
|
||||
ctx_err[0] = c2ml_Z3_context(&c);
|
||||
ctx_err[1] = camlidl_c2ml_z3_Z3_error_code(&e, &_ctxs);
|
||||
if (caml_error_handler) {
|
||||
caml_callback2(caml_error_handler, ctx_err[0], ctx_err[1]);
|
||||
} else {
|
||||
/* if no handler set, raise OCaml Error exception */
|
||||
exn_tag = caml_named_value(\"Z3.Error\");
|
||||
if (*exn_tag == 0) {
|
||||
fprintf(stderr, \"Z3.Error not found\");
|
||||
exit(1);
|
||||
}
|
||||
caml_raise_with_args(*exn_tag, 2, ctx_err);
|
||||
}
|
||||
}
|
||||
|
||||
void ml2c_Z3_error_handler (value ml_handler, void* c_handler)
|
||||
{
|
||||
caml_error_handler = ml_handler;
|
||||
c_handler = (void*)error_handler_static;
|
||||
}
|
||||
|
||||
/* Never called */
|
||||
value c2ml_Z3_error_handler (void* _)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
");
|
||||
|
||||
typedef [mltype("context -> error_code -> unit"),
|
||||
ml2c(ml2c_Z3_error_handler),
|
||||
c2ml(c2ml_Z3_error_handler)
|
||||
] void Z3_error_handler;
|
||||
|
||||
quote(c,"#define Z3_error_handler void*");
|
||||
|
||||
#endif
|
5
src/bindings/ml/exec.cmd
Executable file
5
src/bindings/ml/exec.cmd
Executable file
|
@ -0,0 +1,5 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
set PATH=..\..\bin;%PATH%
|
||||
test_mlapi.exe
|
||||
ENDLOCAL
|
4
src/bindings/ml/exec.sh
Normal file
4
src/bindings/ml/exec.sh
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
export LD_LIBRARY_PATH=../../lib:$LD_LIBRARY_PATH # for linux
|
||||
export DYLD_LIBRARY_PATH=../../lib:$DYLD_LIBRARY_PATH # for osx
|
||||
./test_mlapi
|
72
src/bindings/ml/generate_mlapi.cmd
Executable file
72
src/bindings/ml/generate_mlapi.cmd
Executable file
|
@ -0,0 +1,72 @@
|
|||
@echo off
|
||||
|
||||
REM Script to generate the Z3 OCaml API
|
||||
REM
|
||||
REM Assumes that environment variables are set to provide access to the following commands: camlidl, dos2unix, grep, sed, unix2dos
|
||||
REM
|
||||
REM Invoke with "-D UNSAFE_ERRORS" to build version that does not support recoverable errors, but avoids some error-checking overhead.
|
||||
REM Invoke with "-D LEAK_CONTEXTS" to build version that leaks Z3_context objects, but avoids some garbage-collection overhead.
|
||||
|
||||
REM ../lib/z3_api.h -> z3V3_api.idl using add_error_checking.V3.sed and build.sed
|
||||
sed -f add_error_checking.V3.sed ../lib/z3_api.h | sed -f build.sed >z3V3_api.idl
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM z3.idl -> z3V3_stubs.c, z3V3.mli, z3V3.ml
|
||||
camlidl -D MLAPIV3 %* z3.idl
|
||||
move >NUL z3_stubs.c z3V3_stubs.c
|
||||
move >NUL z3.ml z3V3.ml
|
||||
move >NUL z3.mli z3V3.mli
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM ../lib/z3_api.h -> z3_api.idl
|
||||
REM add calls to error checking routine
|
||||
REM convert from doxygen to ocamldoc markup and other syntactic munging
|
||||
sed <../lib/z3_api.h -f add_error_checking.sed | ^
|
||||
sed -f build.sed >z3_api.idl
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM z3.idl -> z3_stubs.c, z3.mli, z3.ml
|
||||
camlidl %* z3.idl
|
||||
if errorlevel 1 goto :EOF
|
||||
|
||||
REM sometimes z3_stubs.c can be generated with mixed line endings, which can confuse sed and grep
|
||||
dos2unix 2>NUL z3V3_stubs.c ; unix2dos 2>NUL z3V3_stubs.c
|
||||
dos2unix 2>NUL z3_stubs.c ; unix2dos 2>NUL z3_stubs.c
|
||||
|
||||
REM modify generated z3.ml{,i} to remove "Z3_" prefix from names
|
||||
move >NUL z3V3.mli z3V3.1.mli && sed "s/{\!Z3\./{!/g;s/\<[zZ]3_//g" z3V3.1.mli >z3V3.mli && del z3V3.1.mli
|
||||
move >NUL z3V3.ml z3V3.1.ml && sed "s/{\!Z3\./{!/g;s/\<[zZ]3_//g" z3V3.1.ml >z3V3.ml && del z3V3.1.ml
|
||||
move >NUL z3.mli z3.1.mli && sed "s/{\!Z3\./{!/g;s/\<[zZ]3_//g" z3.1.mli >z3.mli && del z3.1.mli
|
||||
move >NUL z3.ml z3.1.ml && sed "s/{\!Z3\./{!/g;s/\<[zZ]3_//g" z3.1.ml >z3.ml && del z3.1.ml
|
||||
|
||||
REM modify generated z3V3 files to rename z3_ to z3V3_
|
||||
move >NUL z3V3.mli z3V3.2.mli && sed "s/camlidl\(.*\)_z3_/camlidl\1_z3V3_/g" z3V3.2.mli >z3V3.mli && del z3V3.2.mli
|
||||
move >NUL z3V3.ml z3V3.2.ml && sed "s/camlidl\(.*\)_z3_/camlidl\1_z3V3_/g" z3V3.2.ml >z3V3.ml && del z3V3.2.ml
|
||||
move >NUL z3V3_stubs.c z3V3_stubs.2.c && sed "s/camlidl\(.*\)_z3_/camlidl\1_z3V3_/g" z3V3_stubs.2.c >z3V3_stubs.c && del z3V3_stubs.2.c
|
||||
|
||||
|
||||
REM substitute out type equations for enums and options
|
||||
REM reverse order of substitution of enums to avoid matching prefixes such as enum_1 of enum_10
|
||||
grep "^and \([a-z][a-zA-Z_]*\) = \([a-z][a-zA-Z_]*[0-9]*\)$" z3.mli | sed "s|and \([a-zA-Z_]*\) = \([ a-zA-Z_0-9]*\)|s/\2/\1/g|g" | sed "1!G;h;$!d" >rename.sed
|
||||
grep "^and \([a-z][a-zA-Z_]*\) = \([a-z][a-zA-Z_]* option*\)$" z3.mli | sed "s|and \([a-zA-Z_]*\) = \([ a-zA-Z_0-9]*\)|s/\1/\2/g|g" >>rename.sed
|
||||
move >NUL z3.mli z3.3.mli && sed -f rename.sed z3.3.mli >z3.mli && del z3.3.mli
|
||||
move >NUL z3.ml z3.3.ml && sed -f rename.sed z3.3.ml >z3.ml && del z3.3.ml
|
||||
del rename.sed
|
||||
|
||||
grep "^and \([a-z][a-zA-Z_]*\) = \([a-z][a-zA-Z_]*[0-9]*\)$" z3V3.mli | sed "s|and \([a-zA-Z_]*\) = \([ a-zA-Z_0-9]*\)|s/\2/\1/g|g" | sed "1!G;h;$!d" >rename.sed
|
||||
grep "^and \([a-z][a-zA-Z_]*\) = \([a-z][a-zA-Z_]* option*\)$" z3V3.mli | sed "s|and \([a-zA-Z_]*\) = \([ a-zA-Z_0-9]*\)|s/\1/\2/g|g" >>rename.sed
|
||||
move >NUL z3V3.mli z3V3.3.mli && sed -f rename.sed z3V3.3.mli >z3V3.mli && del z3V3.3.mli
|
||||
move >NUL z3V3.ml z3V3.3.ml && sed -f rename.sed z3V3.3.ml >z3V3.ml && del z3V3.3.ml
|
||||
del rename.sed
|
||||
|
||||
REM remove cyclic definitions introduced by substituting type equations
|
||||
move >NUL z3V3.mli z3V3.4.mli && sed "s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g" z3V3.4.mli >z3V3.mli && del z3V3.4.mli
|
||||
move >NUL z3V3.ml z3V3.4.ml && sed "s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g" z3V3.4.ml >z3V3.ml && del z3V3.4.ml
|
||||
move >NUL z3.mli z3.4.mli && sed "s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g" z3.4.mli >z3.mli && del z3.4.mli
|
||||
move >NUL z3.ml z3.4.ml && sed "s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g" z3.4.ml >z3.ml && del z3.4.ml
|
||||
|
||||
REM append Z3.V3 module onto Z3 module
|
||||
type z3V3.ml >> z3.ml
|
||||
type z3V3.mli >> z3.mli
|
||||
sed "1,22d" z3V3_stubs.c >> z3_stubs.c
|
||||
del /q 2>NUL z3V3_api.idl z3V3.ml z3V3.mli z3V3_stubs.c
|
55
src/bindings/ml/import.cmd
Executable file
55
src/bindings/ml/import.cmd
Executable file
|
@ -0,0 +1,55 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
:CHECKARG1
|
||||
if not "%1"=="" (
|
||||
set SDTROOT=%1
|
||||
goto :CHECKARG2
|
||||
)
|
||||
|
||||
goto :FAIL
|
||||
|
||||
|
||||
:CHECKARG2
|
||||
if "%2"=="" (
|
||||
goto :IMPORT
|
||||
)
|
||||
|
||||
goto :FAIL
|
||||
|
||||
|
||||
:IMPORT
|
||||
cd import
|
||||
sd edit ...
|
||||
del z3.h z3_api.h z3_macros.h z3lib.lib msbig_rational.lib z3.exe test_capi.c test_mlapi_header.html z3_mlapi_header.html mldoc_footer.html tabs.css z3.png z3_ml.css
|
||||
copy %SDTROOT%\lib\z3.h
|
||||
copy %SDTROOT%\lib\z3_api.h
|
||||
copy %SDTROOT%\lib\z3_macros.h
|
||||
copy %SDTROOT%\release_mt\z3lib.lib
|
||||
copy %SDTROOT%\release_mt\msbig_rational.lib
|
||||
copy %SDTROOT%\release_mt\z3.exe
|
||||
copy %SDTROOT%\test_capi\test_capi.c
|
||||
copy %SDTROOT%\doc\test_mlapi_header.html
|
||||
copy %SDTROOT%\doc\z3_mlapi_header.html
|
||||
copy %SDTROOT%\doc\mldoc_footer.html
|
||||
copy %SDTROOT%\doc\html\tabs.css
|
||||
copy %SDTROOT%\doc\z3.png
|
||||
copy %SDTROOT%\doc\z3_ml.css
|
||||
sd add ...
|
||||
sd revert -a ...
|
||||
cd ..
|
||||
goto :END
|
||||
|
||||
:FAIL
|
||||
echo "Usage:"
|
||||
echo " %0 SDTROOT"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " %0 \\risebuild\drops\z32\2.0.51220.7"
|
||||
echo " %0 \\risebuild\drops\z32\latest"
|
||||
echo " %0 J:\SD\other\sdt1\src\z3_2"
|
||||
echo ""
|
||||
goto :END
|
||||
|
||||
:END
|
||||
ENDLOCAL
|
11
src/bindings/ml/mlx_get_app_args.idl
Normal file
11
src/bindings/ml/mlx_get_app_args.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_app_args c a ] \] is the array of arguments of an application. If [t] is a constant, then the array is empty.
|
||||
|
||||
- {b See also}: {!get_app_num_args}
|
||||
- {b See also}: {!get_app_arg}
|
||||
*)
|
||||
val get_app_args: context -> app -> ast array
|
||||
");
|
11
src/bindings/ml/mlx_get_array_sort.idl
Normal file
11
src/bindings/ml/mlx_get_array_sort.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_array_sort c t ] \] is the domain and the range of [t].
|
||||
|
||||
- {b See also}: {!get_array_sort_domain}
|
||||
- {b See also}: {!get_array_sort_range}
|
||||
*)
|
||||
val get_array_sort: context -> sort -> sort * sort
|
||||
");
|
13
src/bindings/ml/mlx_get_datatype_sort.idl
Normal file
13
src/bindings/ml/mlx_get_datatype_sort.idl
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_datatype_sort c ty ] \] is the array of triples [(constructor, recognizer, fields)] where [constructor] is the constructor declaration of [ty], [recognizer] is the recognizer for the [constructor], and [fields] is the array of fields in [ty].
|
||||
|
||||
- {b See also}: {!get_datatype_sort_num_constructors}
|
||||
- {b See also}: {!get_datatype_sort_constructor}
|
||||
- {b See also}: {!get_datatype_sort_recognizer}
|
||||
- {b See also}: {!get_datatype_sort_constructor_accessor}
|
||||
*)
|
||||
val get_datatype_sort: context -> sort -> datatype_constructor array
|
||||
");
|
11
src/bindings/ml/mlx_get_domains.idl
Normal file
11
src/bindings/ml/mlx_get_domains.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_domains c d ] \] is the array of parameters of [d].
|
||||
|
||||
- {b See also}: {!get_domain_size}
|
||||
- {b See also}: {!get_domain}
|
||||
*)
|
||||
val get_domains: context -> func_decl -> sort array
|
||||
");
|
6
src/bindings/ml/mlx_get_error_msg.idl
Normal file
6
src/bindings/ml/mlx_get_error_msg.idl
Normal file
|
@ -0,0 +1,6 @@
|
|||
quote(mli,"
|
||||
(**
|
||||
Summary: Return a string describing the given error code.
|
||||
*)
|
||||
val get_error_msg: context -> error_code -> string
|
||||
");
|
11
src/bindings/ml/mlx_get_pattern_terms.idl
Normal file
11
src/bindings/ml/mlx_get_pattern_terms.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_pattern_terms c p ] \] is the ast's in pattern.
|
||||
|
||||
- {b See also}: {!get_pattern_num_terms}
|
||||
- {b See also}: {!get_pattern}
|
||||
*)
|
||||
val get_pattern_terms: context -> pattern -> ast array;;
|
||||
");
|
12
src/bindings/ml/mlx_get_tuple_sort.idl
Normal file
12
src/bindings/ml/mlx_get_tuple_sort.idl
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ get_tuple_sort c ty ] \] is the pair [(mk_decl, fields)] where [mk_decl] is the constructor declaration of [ty], and [fields] is the array of fields in [ty].
|
||||
|
||||
- {b See also}: {!get_tuple_sort_mk_decl}
|
||||
- {b See also}: {!get_tuple_sort_num_fields}
|
||||
- {b See also}: {!get_tuple_sort_field_decl}
|
||||
*)
|
||||
val get_tuple_sort: context -> sort -> (func_decl * func_decl array)
|
||||
");
|
36
src/bindings/ml/mlx_mk_context_x.idl
Normal file
36
src/bindings/ml/mlx_mk_context_x.idl
Normal file
|
@ -0,0 +1,36 @@
|
|||
quote(mlmli,"external mk_context: (string * string) list -> context = \"caml_z3_mk_context\"
|
||||
");
|
||||
// Note: lack of whitespace and comments in the previous 2 lines is important for the documentation generation
|
||||
quote(c,"
|
||||
value caml_z3_mk_context(value key_val_list)
|
||||
{
|
||||
CAMLparam1( key_val_list );
|
||||
CAMLlocal4( item, vkey, vval, _vres );
|
||||
char * ckey;
|
||||
char * cval;
|
||||
Z3_config cfg;
|
||||
Z3_context _res;
|
||||
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
|
||||
camlidl_ctx _ctx = &_ctxs;
|
||||
|
||||
cfg = Z3_mk_config();
|
||||
|
||||
while (key_val_list != Val_emptylist)
|
||||
{
|
||||
item = Field(key_val_list, 0);
|
||||
vkey = Field(item, 0);
|
||||
vval = Field(item, 1);
|
||||
ckey = camlidl_malloc_string(vkey, _ctx);
|
||||
cval = camlidl_malloc_string(vval, _ctx);
|
||||
Z3_set_param_value(cfg, ckey, cval);
|
||||
key_val_list = Field(key_val_list, 1);
|
||||
}
|
||||
|
||||
_res = Z3_mk_context_rc(cfg);
|
||||
Z3_del_config(cfg);
|
||||
_vres = camlidl_c2ml_z3_Z3_context(&_res, _ctx);
|
||||
camlidl_free(_ctx);
|
||||
Z3_set_error_handler(_res, error_handler_static);
|
||||
CAMLreturn(_vres);
|
||||
}
|
||||
");
|
28
src/bindings/ml/mlx_mk_datatypes.idl
Normal file
28
src/bindings/ml/mlx_mk_datatypes.idl
Normal file
|
@ -0,0 +1,28 @@
|
|||
quote(mlmli,"
|
||||
(** A constructor of a datatype is described by: *)
|
||||
type datatype_constructor_desc = {
|
||||
constructor_desc : symbol; (** name of the constructor function *)
|
||||
recognizer_desc : symbol; (** name of the recognizer function *)
|
||||
accessor_descs : (symbol * sort) array; (** names and sorts of the fields *)
|
||||
}
|
||||
|
||||
(** A datatype is described by a name and constructor descriptors. *)
|
||||
type datatype_desc = symbol * datatype_constructor_desc array
|
||||
|
||||
(** A constructor of a datatype is represented by: *)
|
||||
type datatype_constructor = {
|
||||
constructor : func_decl; (** constructor function *)
|
||||
recognizer : func_decl; (** recognizer function *)
|
||||
accessors : func_decl array; (** field accessor functions *)
|
||||
}
|
||||
|
||||
(** A datatype is represented by a sort and constructors. *)
|
||||
type datatype = sort * datatype_constructor array
|
||||
");
|
||||
|
||||
quote(mli,"
|
||||
(** [mk_datatypes ctx sorts_to_descriptors] creates mutually recursive datatypes described by
|
||||
[sorts_to_descriptors], which is a function from the sorts of the datatypes to be created to
|
||||
descriptors of the datatypes' constructors. {b See also}: {!Test_mlapi.forest_example} *)
|
||||
val mk_datatypes: context -> (sort array -> (datatype_desc array) option) -> datatype array
|
||||
");
|
21
src/bindings/ml/mlx_mk_numeral.idl
Normal file
21
src/bindings/ml/mlx_mk_numeral.idl
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mlmli,"
|
||||
(**
|
||||
Summary: \[ [ numeral_refined ] \] is the refined view of a numeral .
|
||||
*)
|
||||
type numeral_refined =
|
||||
| Numeral_int of int * sort
|
||||
| Numeral_int64 of int64 * sort
|
||||
| Numeral_large of string * sort
|
||||
| Numeral_rational of numeral_refined * numeral_refined
|
||||
");
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ embed_numeral c nr ] \] constructs the numeral described by [nr].
|
||||
|
||||
- {b See also}: {!numeral_refine}
|
||||
*)
|
||||
val embed_numeral: context -> numeral_refined -> ast
|
||||
");
|
69
src/bindings/ml/mlx_mk_sort.idl
Normal file
69
src/bindings/ml/mlx_mk_sort.idl
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mlmli,"
|
||||
(**
|
||||
A datatype constructor descriptor.
|
||||
*)
|
||||
type datatype_constructor_desc = {
|
||||
constructor_desc : symbol; (** name of the constructor function *)
|
||||
recognizer_desc : symbol; (** name of the recognizer function *)
|
||||
accessor_descs : (symbol * sort) array; (** names and sorts of the fields *)
|
||||
}
|
||||
|
||||
(**
|
||||
A datatype is described by a name and constructor descriptors.
|
||||
*)
|
||||
type datatype_desc = symbol * datatype_constructor_desc array
|
||||
|
||||
(**
|
||||
A datatype constructor representation.
|
||||
*)
|
||||
type datatype_constructor = {
|
||||
constructor : func_decl; (** constructor function *)
|
||||
recognizer : func_decl; (** recognizer function *)
|
||||
accessors : func_decl array; (** field accessor functions *)
|
||||
}
|
||||
|
||||
(**
|
||||
A datatype is represented by a sort and constructors.
|
||||
*)
|
||||
type datatype = sort * datatype_constructor array
|
||||
|
||||
(**
|
||||
Refined view of a {!sort}.
|
||||
|
||||
- {b See also}: {!mk_sort}
|
||||
- {b See also}: {!sort_refine}
|
||||
*)
|
||||
type sort_refined =
|
||||
| Sort_uninterpreted of symbol
|
||||
| Sort_bool
|
||||
| Sort_int
|
||||
| Sort_bv of int
|
||||
| Sort_finite_domain of symbol * int64
|
||||
| Sort_real
|
||||
| Sort_array of sort * sort
|
||||
| Sort_datatype of datatype_constructor array
|
||||
| Sort_relation of sort array
|
||||
| Sort_unknown
|
||||
");
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ mk_sort c sr ] \] constructs the sort described by [sr].
|
||||
|
||||
- {b Precondition}: [sr] is not of form [Sort_relation] or [Sort_unknown], which cannot be directly constructed
|
||||
- {b See also}: {!mk_datatypes}
|
||||
- {b See also}: {!sort_refine}
|
||||
*)
|
||||
val mk_sort: context -> sort_refined -> sort
|
||||
|
||||
(**
|
||||
\[ [mk_datatypes ctx sorts_to_descriptors] \] creates mutually recursive datatypes described by
|
||||
[sorts_to_descriptors], which is a function from the sorts of the datatypes to be created to
|
||||
descriptors of the datatypes' constructors.
|
||||
|
||||
- {b See also}: {!Test_mlapi.forest_example}
|
||||
*)
|
||||
val mk_datatypes: context -> (sort array -> (datatype_desc array) option) -> datatype array
|
||||
");
|
22
src/bindings/ml/mlx_mk_symbol.idl
Normal file
22
src/bindings/ml/mlx_mk_symbol.idl
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mlmli,"
|
||||
(**
|
||||
Refined view of a {!symbol}.
|
||||
|
||||
- {b See also}: {!mk_symbol}
|
||||
- {b See also}: {!symbol_refine}
|
||||
*)
|
||||
type symbol_refined =
|
||||
| Symbol_int of int
|
||||
| Symbol_string of string
|
||||
");
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ mk_symbol c sr ] \] constructs the symbol described by [sr].
|
||||
|
||||
- {b See also}: {!symbol_refine}
|
||||
*)
|
||||
val mk_symbol: context -> symbol_refined -> symbol
|
||||
");
|
19
src/bindings/ml/mlx_model.idl
Normal file
19
src/bindings/ml/mlx_model.idl
Normal file
|
@ -0,0 +1,19 @@
|
|||
quote(mlmli,"
|
||||
(**
|
||||
A model assigns uninterpreted sorts to finite universes of distinct values, constants to values,
|
||||
and arrays and functions to finite maps from argument values to result values plus a default
|
||||
value for all other arguments.
|
||||
*)
|
||||
type model_refined = {
|
||||
sorts : (sort, ast_vector) Hashtbl.t;
|
||||
consts : (func_decl, ast) Hashtbl.t;
|
||||
arrays : (func_decl, (ast, ast) Hashtbl.t * ast) Hashtbl.t;
|
||||
funcs : (func_decl, (ast array, ast) Hashtbl.t * ast) Hashtbl.t;
|
||||
}
|
||||
");
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: [model_refine c m] is the refined model of [m].
|
||||
*)
|
||||
val model_refine : context -> model -> model_refined
|
||||
");
|
10
src/bindings/ml/mlx_numeral_refine.idl
Normal file
10
src/bindings/ml/mlx_numeral_refine.idl
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ numeral_refine c a ] \] is the refined view of [a].
|
||||
|
||||
- {b Precondition}: [get_ast_kind c a = NUMERAL_AST]
|
||||
*)
|
||||
val numeral_refine : context -> ast -> numeral_refined
|
||||
");
|
40
src/bindings/ml/mlx_parse_smtlib.idl
Normal file
40
src/bindings/ml/mlx_parse_smtlib.idl
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ parse_smtlib_string_x c str sort_names sorts decl_names decls ] \]
|
||||
|
||||
Parse the given string using the SMT-LIB parser.
|
||||
|
||||
The symbol table of the parser can be initialized using the given sorts and declarations.
|
||||
The symbols in the arrays [sort_names] and [decl_names] don't need to match the names
|
||||
of the sorts and declarations in the arrays [sorts] and [decls]. This is an useful feature
|
||||
since we can use arbitrary names to reference sorts and declarations defined using the API.
|
||||
|
||||
- {b See also}: {!parse_smtlib_file_x}
|
||||
*)
|
||||
val parse_smtlib_string_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array)
|
||||
|
||||
(**
|
||||
Summary: Similar to {!parse_smtlib_string_x}, but reads the benchmark from a file.
|
||||
|
||||
- {b See also}: {!parse_smtlib_string_x}
|
||||
*)
|
||||
val parse_smtlib_file_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array)
|
||||
|
||||
(**
|
||||
Summary: \[ [ parse_smtlib_string_formula c ... ] \] calls [(parse_smtlib_string c ...)] and returns the single formula produced.
|
||||
|
||||
- {b See also}: {!parse_smtlib_file_formula}
|
||||
- {b See also}: {!parse_smtlib_string_x}
|
||||
*)
|
||||
val parse_smtlib_string_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
|
||||
|
||||
(**
|
||||
Summary: \[ [ parse_smtlib_file_formula c ... ] \] calls [(parse_smtlib_file c ...)] and returns the single formula produced.
|
||||
|
||||
- {b See also}: {!parse_smtlib_string_formula}
|
||||
- {b See also}: {!parse_smtlib_file_x}
|
||||
*)
|
||||
val parse_smtlib_file_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
|
||||
");
|
8
src/bindings/ml/mlx_sort_refine.idl
Normal file
8
src/bindings/ml/mlx_sort_refine.idl
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ sort_refine c s ] \] is the refined view of [s].
|
||||
*)
|
||||
val sort_refine: context -> sort -> sort_refined
|
||||
");
|
10
src/bindings/ml/mlx_statistics.idl
Normal file
10
src/bindings/ml/mlx_statistics.idl
Normal file
|
@ -0,0 +1,10 @@
|
|||
quote(mlmli,"
|
||||
type stat_datum = Stat_int of int | Stat_float of float
|
||||
type stats_refined = (string, stat_datum) Hashtbl.t
|
||||
");
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: [stats_refine c s] is the refined stats of [s].
|
||||
*)
|
||||
val stats_refine : context -> stats -> stats_refined
|
||||
");
|
8
src/bindings/ml/mlx_symbol_refine.idl
Normal file
8
src/bindings/ml/mlx_symbol_refine.idl
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ symbol_refine c s ] \] is the refined view of [s].
|
||||
*)
|
||||
val symbol_refine: context -> symbol -> symbol_refined
|
||||
");
|
37
src/bindings/ml/mlx_term_refine.idl
Normal file
37
src/bindings/ml/mlx_term_refine.idl
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote(mlmli,"
|
||||
(**
|
||||
Summary: \[ [ binder_type ] \] is a universal or existential quantifier.
|
||||
|
||||
- {b See also}: {!term_refined}
|
||||
*)
|
||||
type binder_type = Forall | Exists
|
||||
|
||||
(**
|
||||
Summary: \[ [ term_refined ] \] is the refinement of a {!ast} .
|
||||
|
||||
- {b See also}: {!term_refine}
|
||||
*)
|
||||
type term_refined =
|
||||
| Term_numeral of numeral_refined
|
||||
| Term_app of decl_kind * func_decl * ast array
|
||||
| Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast
|
||||
| Term_var of int * sort
|
||||
");
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
Summary: \[ [ mk_term c tr ] \] constructs the term described by [tr].
|
||||
|
||||
- {b Precondition}: [tr] is not of form
|
||||
- {b See also}: {!term_refine}
|
||||
*)
|
||||
(* val mk_term: context -> term_refined -> ast *)
|
||||
|
||||
|
||||
(**
|
||||
Summary: \[ [ term_refine c a ] \] is the refined view of [a].
|
||||
*)
|
||||
val term_refine : context -> ast -> term_refined
|
||||
");
|
112
src/bindings/ml/queen.ml
Normal file
112
src/bindings/ml/queen.ml
Normal file
|
@ -0,0 +1,112 @@
|
|||
(*
|
||||
queen.exe - JakobL@2007-09-22
|
||||
|
||||
Demonstration of how Z3 can be used to find solutions to the
|
||||
N-Queens problem.
|
||||
|
||||
See: http://en.wikipedia.org/wiki/Eight_queens_puzzle
|
||||
|
||||
Problem specification: Is the following constraint system satisfiable,
|
||||
for increasing n>=1, what are the models?
|
||||
|
||||
constant
|
||||
n: 8;
|
||||
|
||||
variable
|
||||
row: array n of [0..n-1];
|
||||
|
||||
rule
|
||||
forall i in [0..n-2]:
|
||||
(forall j in [i+1..n-1]:
|
||||
((row[i] <> row[j]) and
|
||||
(i+row[i]) <> (j+row[j]) and
|
||||
(i+row[j]) <> (j+row[i])));
|
||||
|
||||
The answer is yes for n different from 2 and 3. The number of solutions are:
|
||||
* n=1: 1
|
||||
* n=2: 0
|
||||
* n=3: 0
|
||||
* n=4: 2
|
||||
* n=5: 10
|
||||
* n=6: 4
|
||||
* n=7: 40
|
||||
* n=8: 92
|
||||
* n=9: 352
|
||||
* n=10: 724
|
||||
...
|
||||
*)
|
||||
|
||||
module Z3 = Z3.V3
|
||||
|
||||
(* Auxillary functions *)
|
||||
let ( |> ) x f = f x;;
|
||||
let printf = Printf.printf;;
|
||||
let mk_var ctx name ty = Z3.mk_const ctx (Z3.mk_int_symbol ctx name) ty;;
|
||||
let mk_int_var ctx name = Z3.mk_int_sort ctx |> mk_var ctx name;;
|
||||
let mk_int ctx v = Z3.mk_int ctx v (Z3.mk_int_sort ctx);;
|
||||
let checkreturn v = match v with | (true,r) -> r | _ -> failwith "checkreturn";;
|
||||
let get_numeral_value_int a1 a2 = Z3.get_numeral_int a1 a2 |> checkreturn;;
|
||||
let iterate_x lower upper f = for i = lower to upper do f i done;;
|
||||
let forall_x ctx lower upper f = Z3.mk_and ctx (Array.init (1+upper-lower) (fun i->f (i+lower)))
|
||||
let exist_x ctx lower upper f = Z3.mk_or ctx (Array.init (1+upper-lower) (fun i->f (i+lower)))
|
||||
let get_value ctx model f = let (ok, v) = Z3.eval_func_decl ctx model f in (assert ok; v)
|
||||
|
||||
let queen_n n =
|
||||
let ctx = Z3.mk_context_x
|
||||
[|("MODEL","true");
|
||||
("RELEVANCY","0")|] in
|
||||
let ( &&& ) x y = Z3.mk_and ctx [|x;y|] in
|
||||
let ( <~> ) x y = Z3.mk_not ctx (Z3.mk_eq ctx x y) in
|
||||
let ( <<= ) x y = Z3.mk_le ctx x y in
|
||||
let ( +++ ) x y = Z3.mk_add ctx [|x;y|] in
|
||||
let row = Array.init n (fun i->mk_int_var ctx i) in
|
||||
let c x = mk_int ctx x in (* make constant *)
|
||||
let v x = row.(x) in (* make variable *)
|
||||
let constraint_domain=forall_x ctx (0) (n-1) (fun x-> ((c 0) <<= (v x)) &&& ((v x) <<= (c (n-1)))) in
|
||||
let constraint_queen=
|
||||
forall_x ctx (0) (n-2) (fun i->
|
||||
forall_x ctx (i+1) (n-1) (fun j->
|
||||
((v i) <~> (v j)) &&&
|
||||
(((c i)+++(v i)) <~> ((c j)+++(v j))) &&&
|
||||
(((c i)+++(v j)) <~> ((c j)+++(v i)))
|
||||
)
|
||||
) in
|
||||
let res = constraint_domain &&& constraint_queen in
|
||||
Z3.assert_cnstr ctx res;
|
||||
let rec f i =
|
||||
(match Z3.check_and_get_model ctx with
|
||||
| (Z3.L_FALSE,_) ->
|
||||
printf "queen %d, total models: %d\n" n i;
|
||||
flush stdout;
|
||||
| (Z3.L_UNDEF,_) -> failwith "Z3.L_UNDEF"
|
||||
| (Z3.L_TRUE,model) ->
|
||||
begin
|
||||
let model_constants=Z3.get_model_constants ctx model in
|
||||
let vars=Array.map (fun mc->Z3.mk_app ctx mc [||]) model_constants in
|
||||
let vals=Array.map (fun mc->get_value ctx model mc |> get_numeral_value_int ctx) model_constants in
|
||||
Z3.del_model ctx model;
|
||||
|
||||
let line = String.make n '-' in
|
||||
let q_line i = let r = String.make n ' ' in String.set r i 'Q'; r in
|
||||
printf "queen %d, model #%d:\n" n (i+1);
|
||||
printf "\n";
|
||||
printf " /%s\\\n" line;
|
||||
iterate_x 0 (n-1) (fun x->printf " |%s|\n" (q_line (vals.(x))));
|
||||
printf " \\%s/\n" line;
|
||||
printf "\n";
|
||||
flush stdout;
|
||||
let negated_model = exist_x ctx 0 (n-1) (fun x->(vars.(x)) <~> (c (vals.(x)))) in
|
||||
Z3.assert_cnstr ctx negated_model;
|
||||
f (i+1);
|
||||
end
|
||||
) in
|
||||
f 0;
|
||||
Z3.del_context ctx;
|
||||
();;
|
||||
|
||||
let queen() =
|
||||
for n = 1 to 8 do
|
||||
queen_n n
|
||||
done;;
|
||||
|
||||
let _ = queen();;
|
0
src/bindings/ml/queen.regress.err
Normal file
0
src/bindings/ml/queen.regress.err
Normal file
1852
src/bindings/ml/queen.regress.out
Normal file
1852
src/bindings/ml/queen.regress.out
Normal file
File diff suppressed because it is too large
Load diff
5
src/bindings/ml/test_capi.regress.err
Normal file
5
src/bindings/ml/test_capi.regress.err
Normal file
|
@ -0,0 +1,5 @@
|
|||
WARNING: invalid function application, sort mismatch on argument at position 1
|
||||
WARNING: (define iff Bool Bool Bool) applied to:
|
||||
x of sort Int
|
||||
y of sort Bool
|
||||
|
386
src/bindings/ml/test_capi.regress.out
Normal file
386
src/bindings/ml/test_capi.regress.out
Normal file
|
@ -0,0 +1,386 @@
|
|||
Z3 4.2.0.0
|
||||
|
||||
simple_example
|
||||
CONTEXT:
|
||||
(solver)END OF CONTEXT
|
||||
|
||||
DeMorgan
|
||||
DeMorgan is valid
|
||||
|
||||
find_model_example1
|
||||
model for: x xor y
|
||||
sat
|
||||
y -> false
|
||||
x -> true
|
||||
|
||||
|
||||
find_model_example2
|
||||
model for: x < y + 1, x > 2
|
||||
sat
|
||||
y -> 3
|
||||
x -> 3
|
||||
|
||||
model for: x < y + 1, x > 2, not(x = y)
|
||||
sat
|
||||
y -> 4
|
||||
x -> 3
|
||||
|
||||
|
||||
prove_example1
|
||||
prove: x = y implies g(x) = g(y)
|
||||
valid
|
||||
disprove: x = y implies g(g(x)) = g(y)
|
||||
invalid
|
||||
counterexample:
|
||||
y -> U!val!0
|
||||
x -> U!val!0
|
||||
g -> {
|
||||
U!val!0 -> U!val!1
|
||||
U!val!1 -> U!val!2
|
||||
else -> U!val!1
|
||||
}
|
||||
|
||||
|
||||
prove_example2
|
||||
prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0
|
||||
valid
|
||||
disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1
|
||||
invalid
|
||||
counterexample:
|
||||
z -> (- 1)
|
||||
y -> (- 7719)
|
||||
x -> (- 7719)
|
||||
g -> {
|
||||
(- 7719) -> 0
|
||||
0 -> 2
|
||||
(- 1) -> 3
|
||||
else -> 0
|
||||
}
|
||||
|
||||
|
||||
push_pop_example1
|
||||
assert: x >= 'big number'
|
||||
push
|
||||
number of scopes: 1
|
||||
assert: x <= 3
|
||||
unsat
|
||||
pop
|
||||
number of scopes: 0
|
||||
sat
|
||||
x = 1000000000000000000000000000000000000000000000000000000:int
|
||||
function interpretations:
|
||||
assert: y > x
|
||||
sat
|
||||
y = 1000000000000000000000000000000000000000000000000000001:int
|
||||
x = 1000000000000000000000000000000000000000000000000000000:int
|
||||
function interpretations:
|
||||
|
||||
quantifier_example1
|
||||
pattern: {(f #0 #1)}
|
||||
|
||||
assert axiom:
|
||||
(forall (k!0 Int) (k!1 Int) (= (inv!0 (f k!1 k!0)) k!0) :pat {(f k!1 k!0)})
|
||||
prove: f(x, y) = f(w, v) implies y = v
|
||||
valid
|
||||
disprove: f(x, y) = f(w, v) implies x = w
|
||||
that is: not(f(x, y) = f(w, v) implies x = w) is satisfiable
|
||||
unknown
|
||||
potential model:
|
||||
w = 2:int
|
||||
v = 1:int
|
||||
y = 1:int
|
||||
x = 0:int
|
||||
function interpretations:
|
||||
f = {(else|->(define f!52 Int Int Int)[(define k!50 Int Int)[#unknown], (define k!51 Int Int)[#unknown]])}
|
||||
#51 = {(2:int|->2:int), (1:int|->1:int), (15:int|->15:int), (11:int|->11:int), (0:int|->0:int), (19:int|->19:int), (else|->2:int)}
|
||||
f!52 = {(0:int, 1:int|->3:int), (2:int, 1:int|->3:int), (0:int, 0:int|->4:int), (2:int, 0:int|->5:int), (6:int, 2:int|->7:int), (2:int, 2:int|->8:int), (0:int, 2:int|->9:int), (6:int, 0:int|->10:int), (0:int, 11:int|->12:int), (2:int, 11:int|->13:int), (6:int, 11:int|->14:int), (0:int, 15:int|->16:int), (2:int, 15:int|->17:int), (6:int, 15:int|->18:int), (0:int, 19:int|->20:int), (6:int, 19:int|->21:int), (2:int, 19:int|->22:int), (else|->3:int)}
|
||||
inv!0 = {(3:int|->1:int), (4:int|->0:int), (5:int|->0:int), (7:int|->2:int), (8:int|->2:int), (9:int|->2:int), (10:int|->0:int), (12:int|->11:int), (13:int|->11:int), (14:int|->11:int), (16:int|->15:int), (17:int|->15:int), (18:int|->15:int), (20:int|->19:int), (21:int|->19:int), (22:int|->19:int), (else|->2:int)}
|
||||
#50 = {(2:int|->2:int), (6:int|->6:int), (0:int|->0:int), (else|->2:int)}
|
||||
reason for last failure: 7 (7 = quantifiers)
|
||||
|
||||
array_example1
|
||||
prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))
|
||||
(=> (= (store a1 i1 v1) (store a2 i2 v2))
|
||||
(or (= i1 i3) (= i2 i3) (= (select a1 i3) (select a2 i3))))
|
||||
valid
|
||||
|
||||
array_example2
|
||||
n = 2
|
||||
(distinct k!0 k!1)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#1 = {((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 3
|
||||
(distinct k!0 k!1 k!2)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
#2 = (define as-array[k!2] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define false Bool)), (else|->(define true Bool))}
|
||||
#1 = {((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#2 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 4
|
||||
(distinct k!0 k!1 k!2 k!3)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
#2 = (define as-array[k!2] (Array Bool Bool))
|
||||
#3 = (define as-array[k!3] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define true Bool)), (else|->(define false Bool))}
|
||||
#1 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define false Bool)), (else|->(define true Bool))}
|
||||
#2 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#3 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 5
|
||||
(distinct k!0 k!1 k!2 k!3 k!4)
|
||||
unsat
|
||||
|
||||
array_example3
|
||||
domain: int
|
||||
range: bool
|
||||
|
||||
tuple_example1
|
||||
tuple_sort: (real, real)
|
||||
prove: get_x(mk_pair(x, y)) = 1 implies x = 1
|
||||
valid
|
||||
disprove: get_x(mk_pair(x, y)) = 1 implies y = 1
|
||||
invalid
|
||||
counterexample:
|
||||
y -> 0
|
||||
x -> 1
|
||||
|
||||
prove: get_x(p1) = get_x(p2) and get_y(p1) = get_y(p2) implies p1 = p2
|
||||
valid
|
||||
disprove: get_x(p1) = get_x(p2) implies p1 = p2
|
||||
invalid
|
||||
counterexample:
|
||||
p1 -> (mk_pair 1 0)
|
||||
p2 -> (mk_pair 1 2)
|
||||
|
||||
prove: p2 = update(p1, 0, 10) implies get_x(p2) = 10
|
||||
valid
|
||||
disprove: p2 = update(p1, 0, 10) implies get_y(p2) = 10
|
||||
invalid
|
||||
counterexample:
|
||||
p2 -> (mk_pair 10 1)
|
||||
p1 -> (mk_pair 0 1)
|
||||
|
||||
|
||||
bitvector_example1
|
||||
disprove: x - 10 <= 0 IFF x <= 10 for (32-bit) machine integers
|
||||
invalid
|
||||
counterexample:
|
||||
x -> bv2147483656[32]
|
||||
|
||||
|
||||
bitvector_example2
|
||||
find values of x and y, such that x ^ y - 103 == x * y
|
||||
sat
|
||||
y -> bv3905735879[32]
|
||||
x -> bv3787456528[32]
|
||||
|
||||
|
||||
eval_example1
|
||||
MODEL:
|
||||
y -> 4
|
||||
x -> 3
|
||||
|
||||
evaluating x+y
|
||||
result = 7:int
|
||||
|
||||
two_contexts_example1
|
||||
k!0
|
||||
|
||||
error_code_example1
|
||||
last call succeeded.
|
||||
last call failed.
|
||||
|
||||
error_code_example2
|
||||
before Z3_mk_iff
|
||||
Z3 error: type error.
|
||||
|
||||
parser_example1
|
||||
formula 0: (> x y)
|
||||
formula 1: (> x 0)
|
||||
sat
|
||||
y -> 0
|
||||
x -> 1
|
||||
|
||||
|
||||
parser_example2
|
||||
formula: (> x y)
|
||||
sat
|
||||
y -> (- 1)
|
||||
x -> 0
|
||||
|
||||
|
||||
parser_example3
|
||||
assert axiom:
|
||||
(forall (x Int) (y Int) (= (g x y) (g y x)) :qid {k!1})
|
||||
formula: (forall (x Int) (y Int) (=> (= x y) (= (g x 0) (g 0 y))) :qid {k!1})
|
||||
valid
|
||||
|
||||
parser_example4
|
||||
declaration 0: (define y Int)
|
||||
declaration 1: (define sk_hack Bool Bool)
|
||||
declaration 2: (define x Int)
|
||||
assumption 0: (= x 20)
|
||||
formula 0: (> x y)
|
||||
formula 1: (> x 0)
|
||||
|
||||
parser_example5
|
||||
Z3 error: parser error.
|
||||
Error message: 'ERROR: line 1 column 41: could not find sort symbol 'y'.
|
||||
'.
|
||||
|
||||
numeral_example
|
||||
Numerals n1:1/2 n2:1/2
|
||||
valid
|
||||
Numerals n1:(- 1/3) n2:(- 33333333333333333333333333333333333333333333333333/100000000000000000000000000000000000000000000000000)
|
||||
valid
|
||||
|
||||
ite_example
|
||||
term: (if false 1 0)
|
||||
|
||||
list_example
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
Formula (=> (is_cons u) (= u (cons (head u) (tail u))))
|
||||
valid
|
||||
invalid
|
||||
counterexample:
|
||||
u -> nil
|
||||
|
||||
|
||||
tree_example
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
Formula (=> (is_cons u) (= u (cons (car u) (cdr u))))
|
||||
valid
|
||||
invalid
|
||||
counterexample:
|
||||
u -> nil
|
||||
|
||||
|
||||
forest_example
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
|
||||
binary_tree_example
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
|
||||
enum_example
|
||||
(define apple[fruit:0] fruit)
|
||||
(define banana[fruit:1] fruit)
|
||||
(define orange[fruit:2] fruit)
|
||||
(define is_apple[fruit:0] fruit Bool)
|
||||
(define is_banana[fruit:1] fruit Bool)
|
||||
(define is_orange[fruit:2] fruit Bool)
|
||||
valid
|
||||
valid
|
||||
invalid
|
||||
counterexample:
|
||||
|
||||
valid
|
||||
valid
|
||||
|
||||
unsat_core_and_proof_example
|
||||
unsat
|
||||
proof: [unit-resolution
|
||||
[def-axiom (or (or (not PredA) PredB (not PredC)) (not PredB))]
|
||||
[unit-resolution
|
||||
[def-axiom (or (or (not PredA) (not PredB) (not PredC)) PredB)]
|
||||
[unit-resolution
|
||||
[mp
|
||||
[asserted (or (and PredA PredB PredC) P1)]
|
||||
[monotonicity
|
||||
[rewrite
|
||||
(iff (and PredA PredB PredC)
|
||||
(not (or (not PredA) (not PredB) (not PredC))))]
|
||||
(iff (or (and PredA PredB PredC) P1)
|
||||
(or (not (or (not PredA) (not PredB) (not PredC))) P1))]
|
||||
(or (not (or (not PredA) (not PredB) (not PredC))) P1)]
|
||||
[asserted (not P1)]
|
||||
(not (or (not PredA) (not PredB) (not PredC)))]
|
||||
PredB]
|
||||
[unit-resolution
|
||||
[mp
|
||||
[asserted (or (and PredA (not PredB) PredC) P2)]
|
||||
[monotonicity
|
||||
[rewrite
|
||||
(iff (and PredA (not PredB) PredC)
|
||||
(not (or (not PredA) PredB (not PredC))))]
|
||||
(iff (or (and PredA (not PredB) PredC) P2)
|
||||
(or (not (or (not PredA) PredB (not PredC))) P2))]
|
||||
(or (not (or (not PredA) PredB (not PredC))) P2)]
|
||||
[asserted (not P2)]
|
||||
(not (or (not PredA) PredB (not PredC)))]
|
||||
false]
|
||||
|
||||
core:
|
||||
(not P1)
|
||||
(not P2)
|
||||
|
||||
|
||||
get_implied_equalities example
|
||||
Class a |-> 0
|
||||
Class b |-> 0
|
||||
Class c |-> 0
|
||||
Class d |-> 3
|
||||
Class (f a) |-> 0
|
||||
Class (f b) |-> 0
|
||||
Class (f c) |-> 0
|
||||
asserting f(a) <= b
|
||||
Class a |-> 0
|
||||
Class b |-> 0
|
||||
Class c |-> 0
|
||||
Class d |-> 3
|
||||
Class (f a) |-> 0
|
||||
Class (f b) |-> 0
|
||||
Class (f c) |-> 0
|
||||
|
||||
incremental_example1
|
||||
unsat core: 0 2 3
|
||||
unsat
|
||||
sat
|
||||
unsat core: 0 2 3
|
||||
unsat
|
||||
unsat core: 0 2 3
|
||||
unsat
|
||||
sat
|
||||
|
||||
reference_counter_example
|
||||
model for: x xor y
|
||||
sat
|
||||
y -> false
|
||||
x -> true
|
||||
|
||||
|
||||
smt2parser_example
|
||||
formulas: (and (bvuge a bv16[8]) (bvule a bv240[8]))
|
||||
|
||||
substitute_example
|
||||
substitution result: (f (f a 0) 1)
|
||||
|
||||
substitute_vars_example
|
||||
substitution result: (f (f a (g b)) a)
|
61
src/bindings/ml/test_mlapi.cmd
Executable file
61
src/bindings/ml/test_mlapi.cmd
Executable file
|
@ -0,0 +1,61 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
REM Script to test the Z3 OCaml API
|
||||
REM
|
||||
REM Assumes that environment variables are set to provide access to the C and OCaml compilers, as well as the following commands: diff, dos2unix, sed
|
||||
|
||||
REM directory containing z3_api.h
|
||||
set Z3SRC=%1
|
||||
|
||||
REM directory containing z3.dll and z3.lib
|
||||
set Z3BIN=%2
|
||||
|
||||
REM directory containing debug z3.dll
|
||||
set Z3BINDBG=%3
|
||||
|
||||
set PATH=.;%2;%3;%PATH%
|
||||
|
||||
echo Build test_capi
|
||||
cl /nologo /I %Z3SRC% %Z3BIN%\z3.lib ..\test_capi\test_capi.c
|
||||
|
||||
echo Build test_mlapi
|
||||
ocamlc -w -a -o test_mlapi.byte.exe z3.cma test_mlapi.ml
|
||||
ocamlopt -w -a -o test_mlapi.exe z3.cmxa test_mlapi.ml
|
||||
ocamlc -g -w -a -o test_mlapi.byte.dbg.exe z3_dbg.cma test_mlapi.ml
|
||||
ocamlopt -g -w -a -o test_mlapi.dbg.exe z3_dbg.cmxa test_mlapi.ml
|
||||
|
||||
echo Build test_mlapiV3
|
||||
ocamlopt -g -w -a -o test_mlapiV3.dbg.exe z3_dbg.cmxa test_mlapiV3.ml
|
||||
|
||||
echo Build test_theory
|
||||
ocamlopt -g -w -a -o test_theory.dbg.exe z3_dbg.cmxa test_theory.ml
|
||||
|
||||
echo Build queen
|
||||
ocamlopt -g -w -a -o queen.exe z3_dbg.cmxa queen.ml
|
||||
|
||||
echo Execute test_capi, test_mlapi, test_mlapiV3 and queen
|
||||
test_capi.exe >test_capi.out 2>test_capi.orig.err
|
||||
test_mlapi.dbg.exe >test_mlapi.out 2>test_mlapi.orig.err
|
||||
test_mlapiV3.dbg.exe >test_mlapiV3.out 2>test_mlapiV3.orig.err
|
||||
queen.exe >queen.out 2>queen.orig.err
|
||||
|
||||
REM Strip pointers as they will always differ
|
||||
sed <test_capi.orig.err >test_capi.err "s/ \[.*\]/ [...]/g"
|
||||
sed <test_mlapi.orig.err >test_mlapi.err "s/ \[.*\]/ [...]/g"
|
||||
sed <test_mlapiV3.orig.err >test_mlapiV3.err "s/ \[.*\]/ [...]/g"
|
||||
sed <queen.orig.err >queen.err "s/ \[.*\]/ [...]/g"
|
||||
del test_capi.orig.err test_mlapi.orig.err test_mlapiV3.orig.err queen.orig.err
|
||||
|
||||
REM Compare with regressions
|
||||
dos2unix *.out *.err 2>NUL
|
||||
diff test_capi.regress.out test_capi.out >NUL || echo Regression failed, see: diff test_capi.regress.out test_capi.out
|
||||
diff test_mlapi.regress.out test_mlapi.out >NUL || echo Regression failed, see: diff test_mlapi.regress.out test_mlapi.out
|
||||
diff test_mlapiV3.regress.out test_mlapiV3.out >NUL || echo Regression failed, see: diff test_mlapiV3.regress.out test_mlapiV3.out
|
||||
diff test_capi.regress.err test_capi.err >NUL || echo Regression failed, see: diff test_capi.regress.err test_capi.err
|
||||
diff test_mlapi.regress.err test_mlapi.err >NUL || echo Regression failed, see: diff test_mlapi.regress.err test_mlapi.err
|
||||
diff test_mlapiV3.regress.err test_mlapiV3.err >NUL || echo Regression failed, see: diff test_mlapiV3.regress.err test_mlapiV3.err
|
||||
diff queen.regress.out queen.out >NUL || echo Regression failed, see: diff queen.regress.out queen.out
|
||||
diff queen.regress.err queen.err >NUL || echo Regression failed, see: diff queen.regress.err queen.err
|
||||
|
||||
ENDLOCAL
|
209
src/bindings/ml/test_mlapi.ml
Normal file
209
src/bindings/ml/test_mlapi.ml
Normal file
|
@ -0,0 +1,209 @@
|
|||
(** Examples of using the OCaml API for Z3. *)
|
||||
|
||||
(**/**)
|
||||
(* pause documentation *)
|
||||
|
||||
(*
|
||||
@name Auxiliary Functions
|
||||
*)
|
||||
|
||||
(**
|
||||
printf
|
||||
*)
|
||||
let printf = Printf.printf
|
||||
;;
|
||||
|
||||
(**
|
||||
fprintf
|
||||
*)
|
||||
let fprintf = Printf.fprintf
|
||||
;;
|
||||
|
||||
(**
|
||||
Exit gracefully in case of error.
|
||||
*)
|
||||
let exitf message = fprintf stderr "BUG: %s.\n" message ; exit 1
|
||||
;;
|
||||
|
||||
(**
|
||||
Create and print datatypes
|
||||
*)
|
||||
let mk_datatypes ctx generator =
|
||||
let datatypes = Z3.mk_datatypes ctx generator in
|
||||
printf "datatype created:\n%!" ;
|
||||
Array.iter (fun (sort, ctors) ->
|
||||
printf "sort: %s\n%!" (Z3.sort_to_string ctx sort) ;
|
||||
Array.iter (fun {Z3.constructor; recognizer; accessors} ->
|
||||
printf "constructor: %s%! recognizer: %s%! accessors:"
|
||||
(Z3.func_decl_to_string ctx constructor)
|
||||
(Z3.func_decl_to_string ctx recognizer) ;
|
||||
Array.iter (fun accessor ->
|
||||
printf " %s%!" (Z3.func_decl_to_string ctx accessor)
|
||||
) accessors ;
|
||||
printf "\n"
|
||||
) ctors
|
||||
) datatypes ;
|
||||
printf "\n" ;
|
||||
datatypes
|
||||
;;
|
||||
|
||||
|
||||
(**
|
||||
Create a variable using the given name and type.
|
||||
*)
|
||||
let mk_var ctx name ty = Z3.mk_const ctx (Z3.mk_string_symbol ctx name) ty
|
||||
;;
|
||||
|
||||
(* resume documentation *)
|
||||
(**/**)
|
||||
|
||||
|
||||
(**
|
||||
Prove that the constraints already asserted into the logical
|
||||
context implies the given formula. The result of the proof is
|
||||
displayed.
|
||||
Z3 is a satisfiability checker. So, one can prove {e f } by showing
|
||||
that {e (not f) } is unsatisfiable.
|
||||
The context {e ctx } is not modified by this function.
|
||||
*)
|
||||
let prove ctx slv f is_valid =
|
||||
(* save the current state of the context *)
|
||||
Z3.solver_push ctx slv ;
|
||||
|
||||
let not_f = Z3.mk_not ctx f in
|
||||
Z3.solver_assert ctx slv not_f ;
|
||||
|
||||
(match Z3.solver_check ctx slv with
|
||||
| Z3.L_FALSE ->
|
||||
(* proved *)
|
||||
printf "valid\n" ;
|
||||
if not is_valid then exitf "unexpected result"
|
||||
| Z3.L_UNDEF ->
|
||||
(* Z3 failed to prove/disprove f. *)
|
||||
printf "unknown\n" ;
|
||||
let m = Z3.solver_get_model ctx slv in
|
||||
(* m should be viewed as a potential counterexample. *)
|
||||
printf "potential counterexample:\n%s\n" (Z3.model_to_string ctx m) ;
|
||||
if is_valid then exitf "unexpected result"
|
||||
| Z3.L_TRUE ->
|
||||
(* disproved *)
|
||||
printf "invalid\n" ;
|
||||
let m = Z3.solver_get_model ctx slv in
|
||||
(* the model returned by Z3 is a counterexample *)
|
||||
printf "counterexample:\n%s\n" (Z3.model_to_string ctx m) ;
|
||||
if is_valid then exitf "unexpected result"
|
||||
);
|
||||
(* restore context *)
|
||||
Z3.solver_pop ctx slv 1
|
||||
;;
|
||||
|
||||
|
||||
(* n-ary trees and forests in OCaml *)
|
||||
type tree = Leaf of int | Node of forest
|
||||
and forest = tree list
|
||||
|
||||
(**
|
||||
Demonstrates the usage of {!Z3.mk_datatypes} with an example of forests of trees.
|
||||
*)
|
||||
let forest_example () =
|
||||
let ctx = Z3.mk_context [] in
|
||||
let slv = Z3.mk_solver ctx
|
||||
in
|
||||
let int_sort = Z3.mk_int_sort ctx in
|
||||
let sym name = Z3.mk_string_symbol ctx name
|
||||
in
|
||||
(* n-ary trees and forests in Z3 *)
|
||||
match
|
||||
mk_datatypes ctx
|
||||
(function [|tree; forest|] -> Some
|
||||
[|(sym"tree",
|
||||
[|{Z3.constructor_desc= sym"leaf"; recognizer_desc= sym"is_leaf"; accessor_descs= [|(sym"data", int_sort)|]};
|
||||
{Z3.constructor_desc= sym"node"; recognizer_desc= sym"is_node"; accessor_descs= [|(sym"children", forest)|]}|]);
|
||||
(sym"forest",
|
||||
[|{Z3.constructor_desc= sym"nil" ; recognizer_desc= sym"is_nil" ; accessor_descs= [||]};
|
||||
{Z3.constructor_desc= sym"cons"; recognizer_desc= sym"is_cons"; accessor_descs= [|(sym"hd", tree); (sym"tl", forest)|]}|])|]
|
||||
| _ -> None
|
||||
)
|
||||
with
|
||||
[|(tree,
|
||||
[|{Z3.constructor= leaf; recognizer= is_leaf; accessors= [|data|]};
|
||||
{Z3.constructor= node; recognizer= is_node; accessors= [|children|]}|]);
|
||||
(forest,
|
||||
[|{Z3.constructor= nil ; recognizer= is_nil ; accessors= [||]};
|
||||
{Z3.constructor= cons; recognizer= is_cons; accessors= [|hd; tl|]}|])|]
|
||||
->
|
||||
(* translate from OCaml to Z3 *)
|
||||
let rec ml2z3_tree = function
|
||||
| Leaf(i) -> Z3.mk_app ctx leaf [|Z3.mk_int ctx i (Z3.mk_int_sort ctx)|]
|
||||
| Node(f) -> Z3.mk_app ctx node [|ml2z3_forest f|]
|
||||
|
||||
and ml2z3_forest = function
|
||||
| [] -> Z3.mk_app ctx nil [||]
|
||||
| t :: f -> Z3.mk_app ctx cons [|ml2z3_tree t; ml2z3_forest f|]
|
||||
in
|
||||
|
||||
(* construct some OCaml trees *)
|
||||
let t0 = Leaf 0 in
|
||||
let t12 = Node [Leaf 1; Leaf 2] in
|
||||
let t123 = Node [t12; Leaf 3] in
|
||||
let t1212 = Node [t12; t12] in
|
||||
let t412 = Node [Leaf 4; t12] in
|
||||
|
||||
(* construct some Z3 trees using the translation from OCaml *)
|
||||
let t1 = ml2z3_tree t12 in printf "t1: %s\n%!" (Z3.ast_to_string ctx t1) ;
|
||||
let t2 = ml2z3_tree t123 in printf "t2: %s\n%!" (Z3.ast_to_string ctx t2) ;
|
||||
let t3 = ml2z3_tree t1212 in printf "t3: %s\n%!" (Z3.ast_to_string ctx t3) ;
|
||||
let t4 = ml2z3_tree t412 in printf "t4: %s\n%!" (Z3.ast_to_string ctx t4) ;
|
||||
let f1 = ml2z3_forest [t0] in printf "f1: %s\n%!" (Z3.ast_to_string ctx f1) ;
|
||||
let f2 = ml2z3_forest [t12] in printf "f2: %s\n%!" (Z3.ast_to_string ctx f2) ;
|
||||
let f3 = ml2z3_forest [t12; t0] in printf "f3: %s\n%!" (Z3.ast_to_string ctx f3) ;
|
||||
|
||||
(* or using the Z3 API *)
|
||||
let nil = Z3.mk_app ctx nil [||] in
|
||||
let cons t f = Z3.mk_app ctx cons [|t; f|] in
|
||||
let leaf i = Z3.mk_app ctx leaf [|Z3.mk_int ctx i (Z3.mk_int_sort ctx)|] in
|
||||
let node f = Z3.mk_app ctx node [|f|] in
|
||||
|
||||
let t0 = leaf 0 in
|
||||
let t12 = node (cons (leaf 1) (cons (leaf 2) nil)) in
|
||||
let t123 = node (cons t12 (cons (leaf 3) nil)) in
|
||||
let t1212 = node (cons t12 (cons t12 nil)) in
|
||||
let t412 = node (cons (leaf 4) (cons t12 nil)) in
|
||||
|
||||
let t1 = t12 in printf "t1: %s\n%!" (Z3.ast_to_string ctx t1) ;
|
||||
let t2 = t123 in printf "t2: %s\n%!" (Z3.ast_to_string ctx t2) ;
|
||||
let t3 = t1212 in printf "t3: %s\n%!" (Z3.ast_to_string ctx t3) ;
|
||||
let t4 = t412 in printf "t4: %s\n%!" (Z3.ast_to_string ctx t4) ;
|
||||
let f1 = cons t0 nil in printf "f1: %s\n%!" (Z3.ast_to_string ctx f1) ;
|
||||
let f2 = cons t12 nil in printf "f2: %s\n%!" (Z3.ast_to_string ctx f2) ;
|
||||
let f3 = cons t12 f1 in printf "f3: %s\n%!" (Z3.ast_to_string ctx f3) ;
|
||||
|
||||
(* nil != cons(nil,nil) *)
|
||||
prove ctx slv (Z3.mk_not ctx (Z3.mk_eq ctx nil f1)) true ;
|
||||
prove ctx slv (Z3.mk_not ctx (Z3.mk_eq ctx (leaf 5) t1)) true ;
|
||||
|
||||
(* cons(x,u) = cons(x, v) => u = v *)
|
||||
let u = mk_var ctx "u" forest in
|
||||
let v = mk_var ctx "v" forest in
|
||||
let x = mk_var ctx "x" tree in
|
||||
let y = mk_var ctx "y" tree in
|
||||
let l1 = cons x u in printf "l1: %s\n%!" (Z3.ast_to_string ctx l1) ;
|
||||
let l2 = cons y v in printf "l2: %s\n%!" (Z3.ast_to_string ctx l2) ;
|
||||
|
||||
prove ctx slv (Z3.mk_implies ctx (Z3.mk_eq ctx l1 l2) (Z3.mk_eq ctx u v)) true ;
|
||||
prove ctx slv (Z3.mk_implies ctx (Z3.mk_eq ctx l1 l2) (Z3.mk_eq ctx x y)) true ;
|
||||
|
||||
(* is_nil(u) or is_cons(u) *)
|
||||
prove ctx slv (Z3.mk_or ctx [|Z3.mk_app ctx is_nil [|u|]; Z3.mk_app ctx is_cons [|u|]|]) true ;
|
||||
|
||||
(* occurs check u != cons(x,u) *)
|
||||
prove ctx slv (Z3.mk_not ctx (Z3.mk_eq ctx u l1)) true ;
|
||||
|
||||
| _ ->
|
||||
exitf "unexpected datatype signature"
|
||||
;;
|
||||
|
||||
let _ =
|
||||
ignore( Z3.open_log "test_mlapi.log" );
|
||||
forest_example () ;
|
||||
;;
|
0
src/bindings/ml/test_mlapi.regress.err
Normal file
0
src/bindings/ml/test_mlapi.regress.err
Normal file
32
src/bindings/ml/test_mlapi.regress.out
Normal file
32
src/bindings/ml/test_mlapi.regress.out
Normal file
|
@ -0,0 +1,32 @@
|
|||
datatype created:
|
||||
sort: tree
|
||||
constructor: (define leaf[tree:0] Int tree) recognizer: (define is_leaf[tree:0] tree Bool) accessors: (define data[tree:0:0] tree Int)
|
||||
constructor: (define node[tree:1] forest tree) recognizer: (define is_node[tree:1] tree Bool) accessors: (define children[tree:1:0] tree forest)
|
||||
sort: forest
|
||||
constructor: (define nil[forest:0] forest) recognizer: (define is_nil[forest:0] forest Bool) accessors:
|
||||
constructor: (define cons[forest:1] tree forest forest) recognizer: (define is_cons[forest:1] forest Bool) accessors: (define hd[forest:1:0] forest tree) (define tl[forest:1:1] forest forest)
|
||||
|
||||
t1: (node (cons (leaf 1) (cons (leaf 2) nil)))
|
||||
t2: (node (cons (node (cons (leaf 1) (cons (leaf 2) nil))) (cons (leaf 3) nil)))
|
||||
t3: (node (cons (node (cons (leaf 1) (cons (leaf 2) nil)))
|
||||
(cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)))
|
||||
t4: (node (cons (leaf 4) (cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)))
|
||||
f1: (cons (leaf 0) nil)
|
||||
f2: (cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)
|
||||
f3: (cons (node (cons (leaf 1) (cons (leaf 2) nil))) (cons (leaf 0) nil))
|
||||
t1: (node (cons (leaf 1) (cons (leaf 2) nil)))
|
||||
t2: (node (cons (node (cons (leaf 1) (cons (leaf 2) nil))) (cons (leaf 3) nil)))
|
||||
t3: (node (cons (node (cons (leaf 1) (cons (leaf 2) nil)))
|
||||
(cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)))
|
||||
t4: (node (cons (leaf 4) (cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)))
|
||||
f1: (cons (leaf 0) nil)
|
||||
f2: (cons (node (cons (leaf 1) (cons (leaf 2) nil))) nil)
|
||||
f3: (cons (node (cons (leaf 1) (cons (leaf 2) nil))) (cons (leaf 0) nil))
|
||||
valid
|
||||
valid
|
||||
l1: (cons x u)
|
||||
l2: (cons y v)
|
||||
valid
|
||||
valid
|
||||
valid
|
||||
valid
|
1418
src/bindings/ml/test_mlapiV3.ml
Normal file
1418
src/bindings/ml/test_mlapiV3.ml
Normal file
File diff suppressed because it is too large
Load diff
5
src/bindings/ml/test_mlapiV3.regress.err
Normal file
5
src/bindings/ml/test_mlapiV3.regress.err
Normal file
|
@ -0,0 +1,5 @@
|
|||
WARNING: invalid function application, sort mismatch on argument at position 1
|
||||
WARNING: (define iff Bool Bool Bool) applied to:
|
||||
x of sort Int
|
||||
y of sort Bool
|
||||
|
315
src/bindings/ml/test_mlapiV3.regress.out
Normal file
315
src/bindings/ml/test_mlapiV3.regress.out
Normal file
|
@ -0,0 +1,315 @@
|
|||
Z3 4.2.0.0
|
||||
|
||||
simple_example
|
||||
CONTEXT:
|
||||
(solver)END OF CONTEXT
|
||||
|
||||
DeMorgan
|
||||
DeMorgan is valid
|
||||
|
||||
find_model_example1
|
||||
model for: x xor y
|
||||
sat
|
||||
y -> false
|
||||
x -> true
|
||||
|
||||
|
||||
find_model_example2
|
||||
model for: x < y + 1, x > 2
|
||||
sat
|
||||
y -> 3
|
||||
x -> 3
|
||||
|
||||
model for: x < y + 1, x > 2, not(x = y)
|
||||
sat
|
||||
y -> 4
|
||||
x -> 3
|
||||
|
||||
|
||||
prove_example1
|
||||
prove: x = y implies g(x) = g(y)
|
||||
valid
|
||||
disprove: x = y implies g(g(x)) = g(y)
|
||||
invalid
|
||||
counterexample:
|
||||
y -> U!val!0
|
||||
x -> U!val!0
|
||||
g -> {
|
||||
U!val!0 -> U!val!1
|
||||
U!val!1 -> U!val!2
|
||||
else -> U!val!1
|
||||
}
|
||||
|
||||
|
||||
prove_example2
|
||||
prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0
|
||||
valid
|
||||
disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1
|
||||
invalid
|
||||
counterexample:
|
||||
z -> (- 1)
|
||||
y -> (- 7719)
|
||||
x -> (- 7719)
|
||||
g -> {
|
||||
(- 7719) -> 0
|
||||
0 -> 2
|
||||
(- 1) -> 3
|
||||
else -> 0
|
||||
}
|
||||
|
||||
|
||||
push_pop_example1
|
||||
assert: x >= 'big number'
|
||||
push
|
||||
number of scopes: 1
|
||||
assert: x <= 3
|
||||
unsat
|
||||
pop
|
||||
number of scopes: 0
|
||||
sat
|
||||
x = 1000000000000000000000000000000000000000000000000000000:int
|
||||
function interpretations:
|
||||
assert: y > x
|
||||
sat
|
||||
y = 1000000000000000000000000000000000000000000000000000001:int
|
||||
x = 1000000000000000000000000000000000000000000000000000000:int
|
||||
function interpretations:
|
||||
|
||||
quantifier_example1
|
||||
pattern: {(f #0 #1)}
|
||||
|
||||
assert axiom:
|
||||
(forall (k!0 Int) (k!1 Int) (= (inv!0 (f k!1 k!0)) k!0) :pat {(f k!1 k!0)})
|
||||
prove: f(x, y) = f(w, v) implies y = v
|
||||
valid
|
||||
disprove: f(x, y) = f(w, v) implies x = w
|
||||
that is: not(f(x, y) = f(w, v) implies x = w) is satisfiable
|
||||
unknown
|
||||
potential model:
|
||||
w = 2:int
|
||||
v = 1:int
|
||||
y = 1:int
|
||||
x = 0:int
|
||||
function interpretations:
|
||||
f = {(else|->(define f!52 Int Int Int)[(define k!50 Int Int)[#unknown], (define k!51 Int Int)[#unknown]])}
|
||||
#51 = {(2:int|->2:int), (1:int|->1:int), (15:int|->15:int), (11:int|->11:int), (0:int|->0:int), (19:int|->19:int), (else|->2:int)}
|
||||
f!52 = {(0:int, 1:int|->3:int), (2:int, 1:int|->3:int), (0:int, 0:int|->4:int), (2:int, 0:int|->5:int), (6:int, 2:int|->7:int), (2:int, 2:int|->8:int), (0:int, 2:int|->9:int), (6:int, 0:int|->10:int), (0:int, 11:int|->12:int), (2:int, 11:int|->13:int), (6:int, 11:int|->14:int), (0:int, 15:int|->16:int), (2:int, 15:int|->17:int), (6:int, 15:int|->18:int), (0:int, 19:int|->20:int), (6:int, 19:int|->21:int), (2:int, 19:int|->22:int), (else|->3:int)}
|
||||
inv!0 = {(3:int|->1:int), (4:int|->0:int), (5:int|->0:int), (7:int|->2:int), (8:int|->2:int), (9:int|->2:int), (10:int|->0:int), (12:int|->11:int), (13:int|->11:int), (14:int|->11:int), (16:int|->15:int), (17:int|->15:int), (18:int|->15:int), (20:int|->19:int), (21:int|->19:int), (22:int|->19:int), (else|->2:int)}
|
||||
#50 = {(2:int|->2:int), (6:int|->6:int), (0:int|->0:int), (else|->2:int)}
|
||||
reason for last failure: 7 (7 = quantifiers)
|
||||
|
||||
array_example1
|
||||
prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))
|
||||
(=> (= (store a1 i1 v1) (store a2 i2 v2))
|
||||
(or (= i1 i3) (= i2 i3) (= (select a1 i3) (select a2 i3))))
|
||||
valid
|
||||
|
||||
array_example2
|
||||
n = 2
|
||||
(distinct k!0 k!1)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#1 = {((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 3
|
||||
(distinct k!0 k!1 k!2)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
#2 = (define as-array[k!2] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define false Bool)), (else|->(define true Bool))}
|
||||
#1 = {((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#2 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 4
|
||||
(distinct k!0 k!1 k!2 k!3)
|
||||
sat
|
||||
#0 = (define as-array[k!0] (Array Bool Bool))
|
||||
#1 = (define as-array[k!1] (Array Bool Bool))
|
||||
#2 = (define as-array[k!2] (Array Bool Bool))
|
||||
#3 = (define as-array[k!3] (Array Bool Bool))
|
||||
function interpretations:
|
||||
#0 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define true Bool)), (else|->(define false Bool))}
|
||||
#1 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define false Bool)), (else|->(define true Bool))}
|
||||
#2 = {((define true Bool)|->(define true Bool)), ((define false Bool)|->(define true Bool)), (else|->(define true Bool))}
|
||||
#3 = {((define true Bool)|->(define false Bool)), ((define false Bool)|->(define false Bool)), (else|->(define false Bool))}
|
||||
n = 5
|
||||
(distinct k!0 k!1 k!2 k!3 k!4)
|
||||
unsat
|
||||
|
||||
array_example3
|
||||
domain: int
|
||||
range: bool
|
||||
|
||||
tuple_example1
|
||||
tuple_sort: (real, real)
|
||||
prove: get_x(mk_pair(x, y)) = 1 implies x = 1
|
||||
valid
|
||||
disprove: get_x(mk_pair(x, y)) = 1 implies y = 1
|
||||
invalid
|
||||
counterexample:
|
||||
y -> 0
|
||||
x -> 1
|
||||
|
||||
prove: get_x(p1) = get_x(p2) and get_y(p1) = get_y(p2) implies p1 = p2
|
||||
valid
|
||||
disprove: get_x(p1) = get_x(p2) implies p1 = p2
|
||||
invalid
|
||||
counterexample:
|
||||
p1 -> (mk_pair 1 0)
|
||||
p2 -> (mk_pair 1 2)
|
||||
|
||||
prove: p2 = update(p1, 0, 10) implies get_x(p2) = 10
|
||||
valid
|
||||
disprove: p2 = update(p1, 0, 10) implies get_y(p2) = 10
|
||||
invalid
|
||||
counterexample:
|
||||
p2 -> (mk_pair 10 1)
|
||||
p1 -> (mk_pair 0 1)
|
||||
|
||||
|
||||
bitvector_example1
|
||||
disprove: x - 10 <= 0 IFF x <= 10 for (32-bit) machine integers
|
||||
invalid
|
||||
counterexample:
|
||||
x -> bv2147483656[32]
|
||||
|
||||
|
||||
bitvector_example2
|
||||
find values of x and y, such that x ^ y - 103 == x * y
|
||||
sat
|
||||
y -> bv3905735879[32]
|
||||
x -> bv3787456528[32]
|
||||
|
||||
|
||||
eval_example1
|
||||
MODEL:
|
||||
y -> 4
|
||||
x -> 3
|
||||
|
||||
evaluating x+y
|
||||
result = 7:int
|
||||
|
||||
two_contexts_example1
|
||||
k!0
|
||||
|
||||
error_code_example1
|
||||
last call succeeded.
|
||||
last call failed.
|
||||
|
||||
error_code_example2
|
||||
before Z3_mk_iff
|
||||
Z3 error: type error.
|
||||
|
||||
parser_example1
|
||||
formula 0: (> x y)
|
||||
formula 1: (> x 0)
|
||||
sat
|
||||
y -> 0
|
||||
x -> 1
|
||||
|
||||
|
||||
parser_example2
|
||||
formula: (> x y)
|
||||
sat
|
||||
y -> (- 1)
|
||||
x -> 0
|
||||
|
||||
|
||||
parser_example3
|
||||
assert axiom:
|
||||
(forall (x Int) (y Int) (= (g x y) (g y x)) :qid {k!1})
|
||||
formula: (forall (x Int) (y Int) (=> (= x y) (= (g x 0) (g 0 y))) :qid {k!1})
|
||||
valid
|
||||
|
||||
parser_example4
|
||||
declaration 0: (define y Int)
|
||||
declaration 1: (define sk_hack Bool Bool)
|
||||
declaration 2: (define x Int)
|
||||
assumption 0: (= x 20)
|
||||
formula 0: (> x y)
|
||||
formula 1: (> x 0)
|
||||
|
||||
parser_example5
|
||||
Z3 error: parser error.
|
||||
Error message: 'ERROR: line 1 column 41: could not find sort symbol 'y'.
|
||||
'.
|
||||
|
||||
ite_example
|
||||
term: (if false 1 0)
|
||||
|
||||
enum_example
|
||||
(define apple[fruit:0] fruit)
|
||||
(define banana[fruit:1] fruit)
|
||||
(define orange[fruit:2] fruit)
|
||||
(define is_apple[fruit:0] fruit Bool)
|
||||
(define is_banana[fruit:1] fruit Bool)
|
||||
(define is_orange[fruit:2] fruit Bool)
|
||||
valid
|
||||
valid
|
||||
invalid
|
||||
counterexample:
|
||||
|
||||
valid
|
||||
valid
|
||||
|
||||
unsat_core_and_proof_example
|
||||
unsat
|
||||
proof: [unit-resolution
|
||||
[def-axiom (or (or (not PredA) PredC (not PredB)) (not PredC))]
|
||||
[unit-resolution
|
||||
[def-axiom (or (or (not PredA) (not PredB) (not PredC)) PredC)]
|
||||
[unit-resolution
|
||||
[mp
|
||||
[asserted (or (and PredA PredB PredC) P1)]
|
||||
[monotonicity
|
||||
[rewrite
|
||||
(iff (and PredA PredB PredC)
|
||||
(not (or (not PredA) (not PredB) (not PredC))))]
|
||||
(iff (or (and PredA PredB PredC) P1)
|
||||
(or (not (or (not PredA) (not PredB) (not PredC))) P1))]
|
||||
(or (not (or (not PredA) (not PredB) (not PredC))) P1)]
|
||||
[asserted (not P1)]
|
||||
(not (or (not PredA) (not PredB) (not PredC)))]
|
||||
PredC]
|
||||
[unit-resolution
|
||||
[mp
|
||||
[asserted (or (and PredA (not PredC) PredB) P2)]
|
||||
[monotonicity
|
||||
[rewrite
|
||||
(iff (and PredA (not PredC) PredB)
|
||||
(not (or (not PredA) PredC (not PredB))))]
|
||||
(iff (or (and PredA (not PredC) PredB) P2)
|
||||
(or (not (or (not PredA) PredC (not PredB))) P2))]
|
||||
(or (not (or (not PredA) PredC (not PredB))) P2)]
|
||||
[asserted (not P2)]
|
||||
(not (or (not PredA) PredC (not PredB)))]
|
||||
false]
|
||||
|
||||
core:
|
||||
(not P2)
|
||||
(not P1)
|
||||
|
||||
|
||||
abstract_example
|
||||
formula: (> x y)
|
||||
abstracted formula: (> #0 y)
|
||||
|
||||
get_implied_equalities example
|
||||
Class a |-> 0
|
||||
Class b |-> 0
|
||||
Class c |-> 0
|
||||
Class d |-> 3
|
||||
Class (f a) |-> 0
|
||||
Class (f b) |-> 0
|
||||
Class (f c) |-> 0
|
||||
asserting f(a) <= b
|
||||
Class a |-> 0
|
||||
Class b |-> 0
|
||||
Class c |-> 0
|
||||
Class d |-> 3
|
||||
Class (f a) |-> 0
|
||||
Class (f b) |-> 0
|
||||
Class (f c) |-> 0
|
42
src/bindings/ml/test_theory.ml
Normal file
42
src/bindings/ml/test_theory.ml
Normal file
|
@ -0,0 +1,42 @@
|
|||
module Z3 = Z3.V3
|
||||
|
||||
let print_lbool lb =
|
||||
match lb with
|
||||
| Z3.L_FALSE -> Printf.printf "false\n"
|
||||
| Z3.L_TRUE -> Printf.printf "true\n"
|
||||
| Z3.L_UNDEF -> Printf.printf "undef\n"
|
||||
|
||||
(* simple sanity test of theory plugin *)
|
||||
let test_theory() =
|
||||
let ctx = Z3.mk_context_x [| |] in
|
||||
let th = Z3.mk_theory ctx "test-theory" in
|
||||
let _ = Z3.set_push_callback th (fun () -> Printf.printf "push\n") in
|
||||
let _ = Z3.set_pop_callback th (fun () -> Printf.printf "pop\n") in
|
||||
let _ = Z3.set_delete_callback th (fun () -> Printf.printf "delete\n") in
|
||||
let _ = Z3.set_final_check_callback th (fun () -> (Printf.printf "final\n"; true)) in
|
||||
let _ = Z3.set_delete_callback th (fun () -> Printf.printf "deleted\n") in
|
||||
let f_sym = Z3.mk_string_symbol ctx "f" in
|
||||
let a_sym = Z3.mk_string_symbol ctx "a" in
|
||||
let b_sym = Z3.mk_string_symbol ctx "b" in
|
||||
let int_sort = Z3.mk_int_sort ctx in
|
||||
let f = Z3.theory_mk_func_decl ctx th f_sym [|int_sort |] int_sort in
|
||||
let a = Z3.theory_mk_constant ctx th a_sym int_sort in
|
||||
let b = Z3.theory_mk_constant ctx th b_sym int_sort in
|
||||
let reduce_f g args =
|
||||
Printf.printf "reduce %s\n" (Z3.func_decl_to_string ctx g);
|
||||
match g, args with
|
||||
| _, [| a' |] when Z3.is_eq_func_decl ctx g f && Z3.is_eq_ast ctx a' a -> Some b
|
||||
| _, _ -> None
|
||||
in
|
||||
let _ = Z3.set_reduce_app_callback th reduce_f in
|
||||
(* b != f(b) is consistent *)
|
||||
let _ = Z3.assert_cnstr ctx (Z3.mk_not ctx (Z3.mk_eq ctx b (Z3.mk_app ctx f [| b |]))) in
|
||||
let res = Z3.check ctx in
|
||||
print_lbool res;
|
||||
(* b != f(a) is not consistent *)
|
||||
let _ = Z3.assert_cnstr ctx (Z3.mk_not ctx (Z3.mk_eq ctx b (Z3.mk_app ctx f [| a |]))) in
|
||||
let res = Z3.check ctx in
|
||||
print_lbool res;
|
||||
Z3.del_context ctx
|
||||
|
||||
let _ = test_theory()
|
38
src/bindings/ml/update-ml-doc.cmd
Executable file
38
src/bindings/ml/update-ml-doc.cmd
Executable file
|
@ -0,0 +1,38 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
REM Script to generate Z3 OCaml API documentation
|
||||
REM
|
||||
REM Assumes that environment variables are set to provide access to the OCaml compilers, as well as the following commands: sed
|
||||
|
||||
rd 2>NUL /s /q doc
|
||||
md doc
|
||||
cd doc
|
||||
set MLDIR=..
|
||||
set DOCDIR=..\%1
|
||||
|
||||
ocamldoc.opt -hide Z3,Z3.V3,Test_mlapi -html -css-style z3_ml.css -I %MLDIR% %MLDIR%\test_mlapi.ml %MLDIR%\z3.mli
|
||||
|
||||
sed "s|<pre><span class=\"keyword\">val\(.*\)</pre>|<div class=\"function\"><span class=\"keyword\">val\1</div>|g;s|<pre><span class=\"keyword\">type\(.*\)</pre>|<div class=\"function\"><span class=\"keyword\">type\1</div>|g;s|<code><span class=\"keyword\">type\(.*\) = </code>|<div class=\"function\"><span class=\"keyword\">type\1 = </div>|g" Z3.html > Z3.new.html
|
||||
move >NUL Z3.new.html Z3.html
|
||||
|
||||
sed "s|<pre><span class=\"keyword\">val\(.*\)</pre>|<div class=\"function\"><span class=\"keyword\">val\1</div>|g" Test_mlapi.html > Test_mlapi.new.html
|
||||
move >NUL Test_mlapi.new.html Test_mlapi.html
|
||||
|
||||
sed "s|<h1>Index of values</h1>|<h1>OCaml: Index</h1>|" Index_values.html > Index_values.new.html
|
||||
move >NUL Index_values.new.html Index_values.html
|
||||
|
||||
copy >NUL %DOCDIR%\tabs.css
|
||||
copy >NUL %DOCDIR%\z3.png
|
||||
copy >NUL %DOCDIR%\z3_ml.css
|
||||
|
||||
sed "1,23d" Test_mlapi.html | sed "$d" > Test_mlapi.new.html
|
||||
|
||||
type 2>NUL %DOCDIR%\test_mlapi_header.html Test_mlapi.new.html %DOCDIR%\mldoc_footer.html >Test_mlapi.html
|
||||
|
||||
sed "1,37d" Z3.html > Z3.new.html
|
||||
|
||||
type 2>NUL %DOCDIR%\z3_mlapi_header.html Z3.new.html >Z3.html
|
||||
|
||||
exit /B 0
|
||||
ENDLOCAL
|
366
src/bindings/ml/x3.ml
Normal file
366
src/bindings/ml/x3.ml
Normal file
|
@ -0,0 +1,366 @@
|
|||
/* Copyright (c) Microsoft Corporation */
|
||||
|
||||
quote (ml,"
|
||||
|
||||
(* Internal auxiliary functions: *)
|
||||
(*
|
||||
(* Transform a pair of arrays into an array of pairs *)
|
||||
let array_combine a b =
|
||||
if Array.length a <> Array.length b then raise (Invalid_argument \"array_combine\");
|
||||
Array.init (Array.length a) (fun i -> (a.(i), b.(i)))
|
||||
|
||||
(* [a |> b] is the pipeline operator for [b(a)] *)
|
||||
let ( |> ) x f = f x
|
||||
*)
|
||||
|
||||
(* Find the index of an element in an array, raises Not_found is missing *)
|
||||
let find equal x a =
|
||||
let len = Array.length a in
|
||||
let rec find_ i =
|
||||
if i >= len then
|
||||
raise Not_found
|
||||
else
|
||||
if equal x a.(i) then
|
||||
i
|
||||
else
|
||||
find_ (i+1)
|
||||
in
|
||||
find_ 0
|
||||
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
let symbol_refine c s =
|
||||
match get_symbol_kind c s with
|
||||
| INT_SYMBOL -> Symbol_int (get_symbol_int c s)
|
||||
| STRING_SYMBOL -> Symbol_string (get_symbol_string c s)
|
||||
|
||||
let mk_symbol c = function
|
||||
| Symbol_int(i) -> mk_int_symbol c i
|
||||
| Symbol_string(s) -> mk_string_symbol c s
|
||||
|
||||
|
||||
(* Sorts *)
|
||||
|
||||
let get_datatype_sort c s =
|
||||
Array.init (get_datatype_sort_num_constructors c s) (fun i ->
|
||||
let constructor = get_datatype_sort_constructor c s i in
|
||||
let recognizer = get_datatype_sort_recognizer c s i in
|
||||
let accessors =
|
||||
Array.init (get_domain_size c constructor) (fun j ->
|
||||
get_datatype_sort_constructor_accessor c s i j
|
||||
) in
|
||||
{constructor; recognizer; accessors}
|
||||
)
|
||||
|
||||
let sort_refine c s =
|
||||
match get_sort_kind c s with
|
||||
| UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c s)
|
||||
| BOOL_SORT -> Sort_bool
|
||||
| INT_SORT -> Sort_int
|
||||
| BV_SORT -> Sort_bv (get_bv_sort_size c s)
|
||||
| FINITE_DOMAIN_SORT ->
|
||||
(match get_finite_domain_sort_size c s with
|
||||
| Some(sz) -> Sort_finite_domain (get_sort_name c s, sz)
|
||||
| None -> failwith \"Z3.sort_refine: failed to get size of finite-domain sort\"
|
||||
)
|
||||
| REAL_SORT -> Sort_real
|
||||
| ARRAY_SORT -> Sort_array (get_array_sort_domain c s, get_array_sort_range c s)
|
||||
| DATATYPE_SORT -> Sort_datatype (get_datatype_sort c s)
|
||||
| RELATION_SORT -> Sort_relation (Array.init (get_relation_arity c s) (fun i -> get_relation_column c s i))
|
||||
| UNKNOWN_SORT -> Sort_unknown
|
||||
|
||||
let mk_sort c = function
|
||||
| Sort_uninterpreted(s) -> mk_uninterpreted_sort c s
|
||||
| Sort_bool -> mk_bool_sort c
|
||||
| Sort_int -> mk_int_sort c
|
||||
| Sort_bv(size) -> mk_bv_sort c size
|
||||
| Sort_finite_domain(name,size) -> mk_finite_domain_sort c name size
|
||||
| Sort_real -> mk_real_sort c
|
||||
| Sort_array(domain,range) -> mk_array_sort c domain range
|
||||
| Sort_datatype(constructors) -> get_range c constructors.(0).constructor
|
||||
| Sort_relation(_) -> invalid_arg \"Z3.mk_sort: cannot construct relation sorts\"
|
||||
| Sort_unknown(_) -> invalid_arg \"Z3.mk_sort: cannot construct unknown sorts\"
|
||||
|
||||
|
||||
(* Replacement datatypes creation API *)
|
||||
|
||||
let mk_datatypes ctx generator =
|
||||
let usort0 = mk_uninterpreted_sort ctx (mk_int_symbol ctx 0)
|
||||
in
|
||||
let rec find_num_sorts i =
|
||||
if i = max_int then invalid_arg \"mk_datatypes: too many sorts\"
|
||||
else
|
||||
match generator (Array.make i usort0) with
|
||||
| None -> find_num_sorts (i+1)
|
||||
| Some(a) when Array.length a = i -> i
|
||||
| Some _ -> invalid_arg \"mk_datatypes: number of sorts and datatype descriptors must be equal\"
|
||||
in
|
||||
let num_sorts = find_num_sorts 0
|
||||
in
|
||||
let sorts0 = Array.init num_sorts (fun i -> mk_uninterpreted_sort ctx (mk_int_symbol ctx i))
|
||||
in
|
||||
let ctorss_descriptors =
|
||||
match generator sorts0 with
|
||||
| Some(ctorss_descriptors) -> ctorss_descriptors
|
||||
| None -> invalid_arg \"mk_datatypes: generator failed\"
|
||||
in
|
||||
let names = Array.map fst ctorss_descriptors
|
||||
in
|
||||
let ctorss =
|
||||
Array.map (fun (_, ctors_descriptor) ->
|
||||
Array.map (fun {constructor_desc; recognizer_desc; accessor_descs} ->
|
||||
let field_names = Array.map fst accessor_descs
|
||||
in
|
||||
let sort_refs = Array.make (Array.length accessor_descs) 0
|
||||
in
|
||||
let field_sorts =
|
||||
Array.mapi (fun i (_, sort) ->
|
||||
try
|
||||
let j = find (fun s t -> is_eq_sort ctx s t) sort sorts0 in
|
||||
sort_refs.(i) <- j ;
|
||||
None
|
||||
with Not_found ->
|
||||
Some(sort)
|
||||
) accessor_descs
|
||||
in
|
||||
mk_constructor ctx constructor_desc recognizer_desc field_names field_sorts sort_refs
|
||||
) ctors_descriptor
|
||||
) ctorss_descriptors
|
||||
in
|
||||
let constructor_lists = Array.map (mk_constructor_list ctx) ctorss
|
||||
in
|
||||
let sorts,_ = mk_datatypes ctx names constructor_lists
|
||||
in
|
||||
let datatypes =
|
||||
Array.mapi (fun i sort ->
|
||||
(sort,
|
||||
Array.mapi (fun j ctor ->
|
||||
let num_fields = Array.length (snd ctorss_descriptors.(i)).(j).accessor_descs in
|
||||
let constructor, recognizer, accessors = query_constructor ctx ctor num_fields in
|
||||
{constructor; recognizer; accessors}
|
||||
) ctorss.(i))
|
||||
) sorts
|
||||
in
|
||||
Array.iter (fun ctor_list ->
|
||||
del_constructor_list ctx ctor_list
|
||||
) constructor_lists
|
||||
;
|
||||
Array.iter (fun ctors ->
|
||||
Array.iter (fun ctor ->
|
||||
del_constructor ctx ctor
|
||||
) ctors
|
||||
) ctorss
|
||||
;
|
||||
datatypes
|
||||
|
||||
|
||||
(* Numerals *)
|
||||
|
||||
let rec numeral_refine c t =
|
||||
assert( get_ast_kind c t = NUMERAL_AST );
|
||||
let sort = get_sort c t in
|
||||
let is_int, i = get_numeral_int c t in
|
||||
if is_int then
|
||||
Numeral_int (i, sort)
|
||||
else
|
||||
let is_int64, i = get_numeral_int64 c t in
|
||||
if is_int64 then
|
||||
Numeral_int64 (i, sort)
|
||||
else
|
||||
if get_sort_kind c sort <> REAL_SORT then
|
||||
Numeral_large (get_numeral_string c t, sort)
|
||||
else
|
||||
let n = numeral_refine c (get_numerator c t) in
|
||||
let d = numeral_refine c (get_denominator c t) in
|
||||
Numeral_rational (n, d)
|
||||
|
||||
|
||||
let to_real c x =
|
||||
if get_sort_kind c (get_sort c x) = REAL_SORT then
|
||||
x
|
||||
else
|
||||
mk_int2real c x
|
||||
|
||||
let rec embed_numeral c = function
|
||||
| Numeral_int (i, s) -> mk_int c i s
|
||||
| Numeral_int64 (i, s) -> mk_int64 c i s
|
||||
| Numeral_large (l, s) -> mk_numeral c l s
|
||||
| Numeral_rational (Numeral_int(n,_), Numeral_int(d,_)) -> mk_real c n d
|
||||
| Numeral_rational (n, d) ->
|
||||
mk_div c (to_real c (embed_numeral c n)) (to_real c (embed_numeral c d))
|
||||
(* Or should the following be used instead?
|
||||
let n_str = get_numeral_string c (embed_numeral c n) in
|
||||
let d_str = get_numeral_string c (embed_numeral c d) in
|
||||
mk_numeral c (n_str ^ \" / \" ^ d_str) (mk_real_sort c)
|
||||
*)
|
||||
|
||||
(* Terms *)
|
||||
|
||||
let get_app_args c a =
|
||||
Array.init (get_app_num_args c a) (get_app_arg c a);;
|
||||
|
||||
let get_domains c d =
|
||||
Array.init (get_domain_size c d) (get_domain c d);;
|
||||
|
||||
|
||||
let get_pattern_terms c p =
|
||||
Array.init (get_pattern_num_terms c p) (get_pattern c p)
|
||||
|
||||
|
||||
let term_refine c t =
|
||||
match get_ast_kind c t with
|
||||
| NUMERAL_AST ->
|
||||
Term_numeral (numeral_refine c t)
|
||||
| APP_AST ->
|
||||
let t' = to_app c t in
|
||||
let f = get_app_decl c t' in
|
||||
let num_args = get_app_num_args c t' in
|
||||
let args = Array.init num_args (get_app_arg c t') in
|
||||
let k = get_decl_kind c f in
|
||||
Term_app (k, f, args)
|
||||
| QUANTIFIER_AST ->
|
||||
let bt = if is_quantifier_forall c t then Forall else Exists in
|
||||
let w = get_quantifier_weight c t in
|
||||
let np = get_quantifier_num_patterns c t in
|
||||
let pats = Array.init np (get_quantifier_pattern_ast c t) in
|
||||
let pats = Array.map (get_pattern_terms c) pats in
|
||||
let nb = get_quantifier_num_bound c t in
|
||||
let bound =
|
||||
Array.init nb (fun i ->
|
||||
(get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)
|
||||
) in
|
||||
let body = get_quantifier_body c t in
|
||||
Term_quantifier (bt, w, pats, bound, body)
|
||||
| VAR_AST ->
|
||||
Term_var (get_index_value c t, get_sort c t)
|
||||
| _ ->
|
||||
assert false
|
||||
|
||||
|
||||
(* let mk_term c = function *)
|
||||
(* | Term_numeral (numeral, sort) -> mk_numeral c numeral sort *)
|
||||
(* | Term_app (kind, decl, args) -> *)
|
||||
(* | Term_quantifier (strength, weight, pats, bound, body) -> *)
|
||||
(* | Term_var (index, sort) -> *)
|
||||
|
||||
|
||||
|
||||
(* Refined model API *)
|
||||
|
||||
let model_refine c m =
|
||||
let num_sorts = model_get_num_sorts c m in
|
||||
let sorts = Hashtbl.create num_sorts in
|
||||
for i = 0 to num_sorts - 1 do
|
||||
let sort = model_get_sort c m i in
|
||||
let universe = model_get_sort_universe c m sort in
|
||||
Hashtbl.add sorts sort universe
|
||||
done;
|
||||
let num_consts = model_get_num_consts c m in
|
||||
let consts = Hashtbl.create num_consts in
|
||||
let arrays = Hashtbl.create 0 in
|
||||
for i = 0 to num_consts - 1 do
|
||||
let const_decl = model_get_const_decl c m i in
|
||||
match model_get_const_interp c m const_decl with
|
||||
| Some(const_interp) ->
|
||||
if is_as_array c const_interp then
|
||||
let array_decl = get_as_array_func_decl c const_interp in
|
||||
match model_get_func_interp c m array_decl with
|
||||
| Some(array_interp) ->
|
||||
let num_entries = func_interp_get_num_entries c array_interp in
|
||||
let tbl = Hashtbl.create num_entries in
|
||||
for i = 0 to num_entries - 1 do
|
||||
let entry = func_interp_get_entry c array_interp i in
|
||||
assert( func_entry_get_num_args c entry = 1 );
|
||||
let arg = func_entry_get_arg c entry 0 in
|
||||
let value = func_entry_get_value c entry in
|
||||
Hashtbl.add tbl arg value
|
||||
done;
|
||||
let default = func_interp_get_else c array_interp in
|
||||
Hashtbl.add arrays const_decl (tbl, default)
|
||||
| None ->
|
||||
()
|
||||
else
|
||||
Hashtbl.add consts const_decl const_interp
|
||||
| None ->
|
||||
()
|
||||
done;
|
||||
let num_funcs = model_get_num_funcs c m in
|
||||
let funcs = Hashtbl.create num_funcs in
|
||||
for i = 0 to num_funcs - 1 do
|
||||
let func_decl = model_get_func_decl c m i in
|
||||
if not (Hashtbl.mem arrays func_decl) then
|
||||
match model_get_func_interp c m func_decl with
|
||||
| Some(func_interp) ->
|
||||
let num_entries = func_interp_get_num_entries c func_interp in
|
||||
let tbl = Hashtbl.create num_entries in
|
||||
for i = 0 to num_entries - 1 do
|
||||
let entry = func_interp_get_entry c func_interp i in
|
||||
let num_args = func_entry_get_num_args c entry in
|
||||
let args = Array.init num_args (fun i -> func_entry_get_arg c entry i) in
|
||||
let value = func_entry_get_value c entry in
|
||||
Hashtbl.add tbl args value
|
||||
done;
|
||||
let default = func_interp_get_else c func_interp in
|
||||
Hashtbl.add funcs func_decl (tbl, default)
|
||||
| None ->
|
||||
()
|
||||
done;
|
||||
{sorts; consts; arrays; funcs}
|
||||
|
||||
|
||||
(* Extended parser API *)
|
||||
|
||||
let get_smtlib_formulas c =
|
||||
Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c)
|
||||
|
||||
let get_smtlib_assumptions c =
|
||||
Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c)
|
||||
|
||||
let get_smtlib_decls c =
|
||||
Array.init (get_smtlib_num_decls c) (get_smtlib_decl c)
|
||||
|
||||
let get_smtlib_parse_results c =
|
||||
(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c)
|
||||
|
||||
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
|
||||
parse_smtlib_string c a1 a2 a3 a4 a5 ;
|
||||
get_smtlib_parse_results c
|
||||
|
||||
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
|
||||
parse_smtlib_file c a1 a2 a3 a4 a5 ;
|
||||
get_smtlib_parse_results c
|
||||
|
||||
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
|
||||
parse_smtlib_string c a1 a2 a3 a4 a5 ;
|
||||
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith \"Z3: parse_smtlib_string_formula\"
|
||||
|
||||
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
|
||||
parse_smtlib_file c a1 a2 a3 a4 a5 ;
|
||||
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith \"Z3: parse_smtlib_file_formula\"
|
||||
|
||||
|
||||
(* Error handling *)
|
||||
|
||||
let get_error_msg c e =
|
||||
match e with
|
||||
| PARSER_ERROR -> (get_error_msg_ex c e) ^ \": \" ^ (get_smtlib_error c)
|
||||
| _ -> get_error_msg_ex c e
|
||||
|
||||
|
||||
(* Refined stats API *)
|
||||
|
||||
let stats_refine c s =
|
||||
let num_stats = stats_size c s in
|
||||
let tbl = Hashtbl.create num_stats in
|
||||
for i = 0 to num_stats - 1 do
|
||||
let key = stats_get_key c s i in
|
||||
let datum =
|
||||
if stats_is_uint c s i then
|
||||
Stat_int(stats_get_uint_value c s i)
|
||||
else
|
||||
Stat_float(stats_get_double_value c s i) in
|
||||
Hashtbl.add tbl key datum
|
||||
done;
|
||||
tbl
|
||||
");
|
378
src/bindings/ml/x3V3.ml
Normal file
378
src/bindings/ml/x3V3.ml
Normal file
|
@ -0,0 +1,378 @@
|
|||
quote (ml,"
|
||||
|
||||
|
||||
(* Internal auxillary functions: *)
|
||||
|
||||
(* Transform a pair of arrays into an array of pairs *)
|
||||
let array_combine a b =
|
||||
if Array.length a <> Array.length b then raise (Invalid_argument \"array_combine\");
|
||||
Array.init (Array.length a) (fun i->(a.(i),b.(i)));;
|
||||
|
||||
(* [a |> b] is the pipeline operator for [b(a)] *)
|
||||
let ( |> ) x f = f x;;
|
||||
|
||||
|
||||
(* Extensions, except for refinement: *)
|
||||
let mk_context_x configs =
|
||||
let config = mk_config() in
|
||||
let f(param_id,param_value) = set_param_value config param_id param_value in
|
||||
Array.iter f configs;
|
||||
let context = mk_context config in
|
||||
del_config config;
|
||||
context;;
|
||||
|
||||
let get_app_args c a =
|
||||
Array.init (get_app_num_args c a) (get_app_arg c a);;
|
||||
|
||||
let get_domains c d =
|
||||
Array.init (get_domain_size c d) (get_domain c d);;
|
||||
|
||||
let get_array_sort c t = (get_array_sort_domain c t, get_array_sort_range c t);;
|
||||
|
||||
let get_tuple_sort c ty =
|
||||
(get_tuple_sort_mk_decl c ty,
|
||||
Array.init (get_tuple_sort_num_fields c ty) (get_tuple_sort_field_decl c ty));;
|
||||
|
||||
type datatype_constructor_refined = {
|
||||
constructor : func_decl;
|
||||
recognizer : func_decl;
|
||||
accessors : func_decl array
|
||||
}
|
||||
|
||||
let get_datatype_sort c ty =
|
||||
Array.init (get_datatype_sort_num_constructors c ty)
|
||||
(fun idx_c ->
|
||||
let constr = get_datatype_sort_constructor c ty idx_c in
|
||||
let recog = get_datatype_sort_recognizer c ty idx_c in
|
||||
let num_acc = get_domain_size c constr in
|
||||
{ constructor = constr;
|
||||
recognizer = recog;
|
||||
accessors = Array.init num_acc (get_datatype_sort_constructor_accessor c ty idx_c);
|
||||
})
|
||||
|
||||
let get_model_constants c m =
|
||||
Array.init (get_model_num_constants c m) (get_model_constant c m);;
|
||||
|
||||
|
||||
let get_model_func_entry c m i j =
|
||||
(Array.init
|
||||
(get_model_func_entry_num_args c m i j)
|
||||
(get_model_func_entry_arg c m i j),
|
||||
get_model_func_entry_value c m i j);;
|
||||
|
||||
let get_model_func_entries c m i =
|
||||
Array.init (get_model_func_num_entries c m i) (get_model_func_entry c m i);;
|
||||
|
||||
let get_model_funcs c m =
|
||||
Array.init (get_model_num_funcs c m)
|
||||
(fun i->(get_model_func_decl c m i |> get_decl_name c,
|
||||
get_model_func_entries c m i,
|
||||
get_model_func_else c m i));;
|
||||
|
||||
let get_smtlib_formulas c =
|
||||
Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c);;
|
||||
|
||||
let get_smtlib_assumptions c =
|
||||
Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c);;
|
||||
|
||||
let get_smtlib_decls c =
|
||||
Array.init (get_smtlib_num_decls c) (get_smtlib_decl c);;
|
||||
|
||||
let get_smtlib_parse_results c =
|
||||
(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c);;
|
||||
|
||||
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
|
||||
(parse_smtlib_string c a1 a2 a3 a4 a5;
|
||||
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith \"Z3: parse_smtlib_string_formula\");;
|
||||
|
||||
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
|
||||
(parse_smtlib_file c a1 a2 a3 a4 a5;
|
||||
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith \"Z3: parse_smtlib_file_formula\");;
|
||||
|
||||
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
|
||||
(parse_smtlib_string c a1 a2 a3 a4 a5; get_smtlib_parse_results c);;
|
||||
|
||||
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
|
||||
(parse_smtlib_file c a1 a2 a3 a4 a5; get_smtlib_parse_results c);;
|
||||
|
||||
(* Refinement: *)
|
||||
|
||||
type symbol_refined =
|
||||
| Symbol_int of int
|
||||
| Symbol_string of string
|
||||
| Symbol_unknown;;
|
||||
|
||||
let symbol_refine c s =
|
||||
match get_symbol_kind c s with
|
||||
| INT_SYMBOL -> Symbol_int (get_symbol_int c s)
|
||||
| STRING_SYMBOL -> Symbol_string (get_symbol_string c s);;
|
||||
|
||||
type sort_refined =
|
||||
| Sort_uninterpreted of symbol
|
||||
| Sort_bool
|
||||
| Sort_int
|
||||
| Sort_real
|
||||
| Sort_bv of int
|
||||
| Sort_array of (sort * sort)
|
||||
| Sort_datatype of datatype_constructor_refined array
|
||||
| Sort_relation
|
||||
| Sort_finite_domain
|
||||
| Sort_unknown of symbol;;
|
||||
|
||||
let sort_refine c ty =
|
||||
match get_sort_kind c ty with
|
||||
| UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c ty)
|
||||
| BOOL_SORT -> Sort_bool
|
||||
| INT_SORT -> Sort_int
|
||||
| REAL_SORT -> Sort_real
|
||||
| BV_SORT -> Sort_bv (get_bv_sort_size c ty)
|
||||
| ARRAY_SORT -> Sort_array (get_array_sort_domain c ty, get_array_sort_range c ty)
|
||||
| DATATYPE_SORT -> Sort_datatype (get_datatype_sort c ty)
|
||||
| RELATION_SORT -> Sort_relation
|
||||
| FINITE_DOMAIN_SORT -> Sort_finite_domain
|
||||
| UNKNOWN_SORT -> Sort_unknown (get_sort_name c ty);;
|
||||
|
||||
let get_pattern_terms c p =
|
||||
Array.init (get_pattern_num_terms c p) (get_pattern c p)
|
||||
|
||||
type binder_type = | Forall | Exists
|
||||
|
||||
type numeral_refined =
|
||||
| Numeral_small of int64 * int64
|
||||
| Numeral_large of string
|
||||
|
||||
type term_refined =
|
||||
| Term_app of decl_kind * func_decl * ast array
|
||||
| Term_quantifier of binder_type * int * ast array array * (symbol *sort) array * ast
|
||||
| Term_numeral of numeral_refined * sort
|
||||
| Term_var of int * sort
|
||||
|
||||
let term_refine c t =
|
||||
match get_ast_kind c t with
|
||||
| NUMERAL_AST ->
|
||||
let (is_small, n, d) = get_numeral_small c t in
|
||||
if is_small then
|
||||
Term_numeral(Numeral_small(n,d), get_sort c t)
|
||||
else
|
||||
Term_numeral(Numeral_large(get_numeral_string c t), get_sort c t)
|
||||
| APP_AST ->
|
||||
let t' = to_app c t in
|
||||
let f = get_app_decl c t' in
|
||||
let num_args = get_app_num_args c t' in
|
||||
let args = Array.init num_args (get_app_arg c t') in
|
||||
let k = get_decl_kind c f in
|
||||
Term_app (k, f, args)
|
||||
| QUANTIFIER_AST ->
|
||||
let bt = if is_quantifier_forall c t then Forall else Exists in
|
||||
let w = get_quantifier_weight c t in
|
||||
let np = get_quantifier_num_patterns c t in
|
||||
let pats = Array.init np (get_quantifier_pattern_ast c t) in
|
||||
let pats = Array.map (get_pattern_terms c) pats in
|
||||
let nb = get_quantifier_num_bound c t in
|
||||
let bound = Array.init nb
|
||||
(fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)) in
|
||||
let body = get_quantifier_body c t in
|
||||
Term_quantifier(bt, w, pats, bound, body)
|
||||
| VAR_AST ->
|
||||
Term_var(get_index_value c t, get_sort c t)
|
||||
| _ -> assert false
|
||||
|
||||
type theory_callbacks =
|
||||
{
|
||||
mutable delete_theory : unit -> unit;
|
||||
mutable reduce_eq : ast -> ast -> ast option;
|
||||
mutable reduce_app : func_decl -> ast array -> ast option;
|
||||
mutable reduce_distinct : ast array -> ast option;
|
||||
mutable final_check : unit -> bool;
|
||||
mutable new_app : ast -> unit;
|
||||
mutable new_elem : ast -> unit;
|
||||
mutable init_search: unit -> unit;
|
||||
mutable push: unit -> unit;
|
||||
mutable pop: unit -> unit;
|
||||
mutable restart : unit -> unit;
|
||||
mutable reset: unit -> unit;
|
||||
mutable new_eq : ast -> ast -> unit;
|
||||
mutable new_diseq : ast -> ast -> unit;
|
||||
mutable new_assignment: ast -> bool -> unit;
|
||||
mutable new_relevant : ast -> unit;
|
||||
}
|
||||
|
||||
let mk_theory_callbacks() =
|
||||
{
|
||||
delete_theory = (fun () -> ());
|
||||
reduce_eq = (fun _ _ -> None);
|
||||
reduce_app = (fun _ _ -> None);
|
||||
reduce_distinct = (fun _ -> None);
|
||||
final_check = (fun _ -> true);
|
||||
new_app = (fun _ -> ());
|
||||
new_elem = (fun _ -> ());
|
||||
init_search= (fun () -> ());
|
||||
push= (fun () -> ());
|
||||
pop= (fun () -> ());
|
||||
restart = (fun () -> ());
|
||||
reset= (fun () -> ());
|
||||
new_eq = (fun _ _ -> ());
|
||||
new_diseq = (fun _ _ -> ());
|
||||
new_assignment = (fun _ _ -> ());
|
||||
new_relevant = (fun _ -> ());
|
||||
}
|
||||
|
||||
|
||||
external get_theory_callbacks : theory -> theory_callbacks = \"get_theory_callbacks\"
|
||||
external mk_theory_register : context -> string -> theory_callbacks -> theory = \"mk_theory_register\"
|
||||
external set_delete_callback_register : theory -> unit = \"set_delete_callback_register\"
|
||||
external set_reduce_app_callback_register : theory -> unit = \"set_reduce_app_callback_register\"
|
||||
external set_reduce_eq_callback_register : theory -> unit = \"set_reduce_eq_callback_register\"
|
||||
external set_reduce_distinct_callback_register : theory -> unit = \"set_reduce_distinct_callback_register\"
|
||||
external set_new_app_callback_register : theory -> unit = \"set_new_app_callback_register\"
|
||||
external set_new_elem_callback_register : theory -> unit = \"set_new_elem_callback_register\"
|
||||
external set_init_search_callback_register : theory -> unit = \"set_init_search_callback_register\"
|
||||
external set_push_callback_register : theory -> unit = \"set_push_callback_register\"
|
||||
external set_pop_callback_register : theory -> unit = \"set_pop_callback_register\"
|
||||
external set_restart_callback_register : theory -> unit = \"set_restart_callback_register\"
|
||||
external set_reset_callback_register : theory -> unit = \"set_reset_callback_register\"
|
||||
external set_final_check_callback_register : theory -> unit = \"set_final_check_callback_register\"
|
||||
external set_new_eq_callback_register : theory -> unit = \"set_new_eq_callback_register\"
|
||||
external set_new_diseq_callback_register : theory -> unit = \"set_new_diseq_callback_register\"
|
||||
external set_new_assignment_callback_register : theory -> unit = \"set_new_assignment_callback_register\"
|
||||
external set_new_relevant_callback_register : theory -> unit = \"set_new_relevant_callback_register\"
|
||||
|
||||
let is_some opt =
|
||||
match opt with
|
||||
| Some v -> true
|
||||
| None -> false
|
||||
|
||||
let get_some opt =
|
||||
match opt with
|
||||
| Some v -> v
|
||||
| None -> failwith \"None unexpected\"
|
||||
|
||||
|
||||
|
||||
|
||||
let apply_delete (th:theory_callbacks) = th.delete_theory ()
|
||||
let set_delete_callback th cb =
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.delete_theory <- cb;
|
||||
set_delete_callback_register th
|
||||
|
||||
let mk_theory context name =
|
||||
Callback.register \"is_some\" is_some;
|
||||
Callback.register \"get_some\" get_some;
|
||||
Callback.register \"apply_delete\" apply_delete;
|
||||
let cbs = mk_theory_callbacks() in
|
||||
mk_theory_register context name cbs
|
||||
|
||||
|
||||
let apply_reduce_app (th:theory_callbacks) f args = th.reduce_app f args
|
||||
let set_reduce_app_callback th cb =
|
||||
Callback.register \"apply_reduce_app\" apply_reduce_app;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.reduce_app <- cb;
|
||||
set_reduce_app_callback_register th
|
||||
|
||||
let apply_reduce_eq (th:theory_callbacks) a b = th.reduce_eq a b
|
||||
let set_reduce_eq_callback th cb =
|
||||
Callback.register \"apply_reduce_eq\" apply_reduce_eq;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.reduce_eq <- cb;
|
||||
set_reduce_eq_callback_register th
|
||||
|
||||
let apply_reduce_distinct (th:theory_callbacks) args = th.reduce_distinct args
|
||||
let set_reduce_distinct_callback th cb =
|
||||
Callback.register \"apply_reduce_distinct\" apply_reduce_distinct;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.reduce_distinct <- cb;
|
||||
set_reduce_distinct_callback_register th
|
||||
|
||||
|
||||
let apply_new_app (th:theory_callbacks) a = th.new_app a
|
||||
let set_new_app_callback th cb =
|
||||
Callback.register \"apply_new_app\" apply_new_app;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_app <- cb;
|
||||
set_new_app_callback_register th
|
||||
|
||||
let apply_new_elem (th:theory_callbacks) a = th.new_elem a
|
||||
let set_new_elem_callback th cb =
|
||||
Callback.register \"apply_new_elem\" apply_new_elem;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_elem <- cb;
|
||||
set_new_elem_callback_register th
|
||||
|
||||
|
||||
let apply_init_search (th:theory_callbacks) = th.init_search()
|
||||
let set_init_search_callback th cb =
|
||||
Callback.register \"apply_init_search\" apply_init_search;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.init_search <- cb;
|
||||
set_init_search_callback_register th
|
||||
|
||||
|
||||
let apply_push (th:theory_callbacks) = th.push()
|
||||
let set_push_callback th cb =
|
||||
Callback.register \"apply_push\" apply_push;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.push <- cb;
|
||||
set_push_callback_register th
|
||||
|
||||
let apply_pop (th:theory_callbacks) = th.pop()
|
||||
let set_pop_callback th cb =
|
||||
Callback.register \"apply_pop\" apply_pop;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.pop <- cb;
|
||||
set_pop_callback_register th
|
||||
|
||||
|
||||
let apply_restart (th:theory_callbacks) = th.restart()
|
||||
let set_restart_callback th cb =
|
||||
Callback.register \"apply_restart\" apply_restart;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.restart <- cb;
|
||||
set_restart_callback_register th
|
||||
|
||||
|
||||
let apply_reset (th:theory_callbacks) = th.reset()
|
||||
let set_reset_callback th cb =
|
||||
Callback.register \"apply_reset\" apply_reset;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.reset <- cb;
|
||||
set_reset_callback_register th
|
||||
|
||||
let apply_final_check (th:theory_callbacks) = th.final_check()
|
||||
let set_final_check_callback th cb =
|
||||
Callback.register \"apply_final_check\" apply_final_check;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.final_check <- cb;
|
||||
set_final_check_callback_register th
|
||||
|
||||
let apply_new_eq (th:theory_callbacks) a b = th.new_eq a b
|
||||
let set_new_eq_callback th cb =
|
||||
Callback.register \"apply_new_eq\" apply_new_eq;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_eq <- cb;
|
||||
set_new_eq_callback_register th
|
||||
|
||||
|
||||
let apply_new_diseq (th:theory_callbacks) a b = th.new_diseq a b
|
||||
let set_new_diseq_callback th cb =
|
||||
Callback.register \"apply_new_diseq\" apply_new_diseq;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_diseq <- cb;
|
||||
set_new_diseq_callback_register th
|
||||
|
||||
let apply_new_assignment (th:theory_callbacks) a b = th.new_assignment a b
|
||||
let set_new_assignment_callback th cb =
|
||||
Callback.register \"apply_new_assignment\" apply_new_assignment;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_assignment <- cb;
|
||||
set_new_assignment_callback_register th
|
||||
|
||||
let apply_new_relevant (th:theory_callbacks) a = th.new_relevant a
|
||||
let set_new_relevant_callback th cb =
|
||||
Callback.register \"apply_new_relevant\" apply_new_relevant;
|
||||
let cbs = get_theory_callbacks th in
|
||||
cbs.new_relevant <- cb;
|
||||
set_new_relevant_callback_register th
|
||||
|
||||
");
|
361
src/bindings/ml/x3V3.mli
Normal file
361
src/bindings/ml/x3V3.mli
Normal file
|
@ -0,0 +1,361 @@
|
|||
|
||||
quote (mli,"
|
||||
|
||||
(** {2 {L ML Extensions}} *)
|
||||
|
||||
(**
|
||||
\[ [ mk_context_x configs] \] is a shorthand for the context with configurations in [configs].
|
||||
*)
|
||||
val mk_context_x: (string * string) array -> context;;
|
||||
|
||||
(**
|
||||
\[ [ get_app_args c a ] \] is the array of arguments of an application. If [t] is a constant, then the array is empty.
|
||||
|
||||
- {b See also}: {!Z3.get_app_num_args}
|
||||
- {b See also}: {!Z3.get_app_arg}
|
||||
*)
|
||||
val get_app_args: context -> app -> ast array
|
||||
|
||||
(**
|
||||
\[ [ get_app_args c d ] \] is the array of parameters of [d].
|
||||
|
||||
- {b See also}: {!Z3.get_domain_size}
|
||||
- {b See also}: {!Z3.get_domain}
|
||||
*)
|
||||
val get_domains: context -> func_decl -> sort array
|
||||
|
||||
(**
|
||||
\[ [ get_array_sort c t ] \] is the domain and the range of [t].
|
||||
|
||||
- {b See also}: {!Z3.get_array_sort_domain}
|
||||
- {b See also}: {!Z3.get_array_sort_range}
|
||||
*)
|
||||
val get_array_sort: context -> sort -> sort * sort
|
||||
|
||||
(**
|
||||
\[ [ get_tuple_sort c ty ] \] is the pair [(mk_decl, fields)] where [mk_decl] is the constructor declaration of [ty], and [fields] is the array of fields in [ty].
|
||||
|
||||
- {b See also}: {!Z3.get_tuple_sort_mk_decl}
|
||||
- {b See also}: {!Z3.get_tuple_sort_num_fields}
|
||||
- {b See also}: {!Z3.get_tuple_sort_field_decl}
|
||||
*)
|
||||
val get_tuple_sort: context -> sort -> (func_decl * func_decl array)
|
||||
|
||||
(**
|
||||
\[ [ datatype_constructor_refined ] \] is the refinement of a datatype constructor.
|
||||
|
||||
It contains the constructor declaration, recognizer, and list of accessor functions.
|
||||
*)
|
||||
type datatype_constructor_refined = {
|
||||
constructor : func_decl;
|
||||
recognizer : func_decl;
|
||||
accessors : func_decl array
|
||||
}
|
||||
|
||||
(**
|
||||
\[ [ get_datatype_sort c ty ] \] is the array of triples [(constructor, recognizer, fields)] where [constructor] is the constructor declaration of [ty], [recognizer] is the recognizer for the [constructor], and [fields] is the array of fields in [ty].
|
||||
|
||||
- {b See also}: {!Z3.get_datatype_sort_num_constructors}
|
||||
- {b See also}: {!Z3.get_datatype_sort_constructor}
|
||||
- {b See also}: {!Z3.get_datatype_sort_recognizer}
|
||||
- {b See also}: {!Z3.get_datatype_sort_constructor_accessor}
|
||||
*)
|
||||
|
||||
|
||||
val get_datatype_sort: context -> sort -> datatype_constructor_refined array
|
||||
|
||||
(**
|
||||
\[ [ get_model_constants c m ] \] is the array of constants in the model [m].
|
||||
|
||||
- {b See also}: {!Z3.get_model_num_constants}
|
||||
- {b See also}: {!Z3.get_model_constant}
|
||||
*)
|
||||
val get_model_constants: context -> model -> func_decl array
|
||||
|
||||
|
||||
(**
|
||||
\[ [ get_model_func_entry c m i j ] \] is the [j]'th entry in the [i]'th function in the model [m].
|
||||
|
||||
- {b See also}: {!Z3.get_model_func_entry_num_args}
|
||||
- {b See also}: {!Z3.get_model_func_entry_arg}
|
||||
- {b See also}: {!Z3.get_model_func_entry_value}
|
||||
*)
|
||||
val get_model_func_entry: context -> model -> int -> int -> (ast array * ast);;
|
||||
|
||||
(**
|
||||
\[ [ get_model_func_entries c m i ] \] is the array of entries in the [i]'th function in the model [m].
|
||||
|
||||
- {b See also}: {!Z3.get_model_func_num_entries}
|
||||
- {b See also}: {!Z3.get_model_func_entry}
|
||||
*)
|
||||
val get_model_func_entries: context -> model -> int -> (ast array * ast) array;;
|
||||
|
||||
(**
|
||||
\[ [ get_model_funcs c m ] \] is the array of functions in the model [m]. Each function is represented by the triple [(decl, entries, else)], where [decl] is the declaration name for the function, [entries] is the array of entries in the function, and [else] is the default (else) value for the function.
|
||||
|
||||
- {b See also}: {!Z3.get_model_num_funcs}
|
||||
- {b See also}: {!Z3.get_model_func_decl}
|
||||
- {b See also}: {!Z3.get_model_func_entries}
|
||||
- {b See also}: {!Z3.get_model_func_else}
|
||||
*)
|
||||
val get_model_funcs: context -> model ->
|
||||
(symbol *
|
||||
(ast array * ast) array *
|
||||
ast) array
|
||||
|
||||
(**
|
||||
\[ [ get_smtlib_formulas c ] \] is the array of formulas created by a preceding call to {!Z3.parse_smtlib_string} or {!Z3.parse_smtlib_file}.
|
||||
|
||||
Recommend use {!Z3.parse_smtlib_string_x} or {!Z3.parse_smtlib_file_x} for functional style interface to the SMT-LIB parser.
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_string}
|
||||
- {b See also}: {!Z3.parse_smtlib_file}
|
||||
- {b See also}: {!Z3.get_smtlib_num_formulas}
|
||||
- {b See also}: {!Z3.get_smtlib_formula}
|
||||
*)
|
||||
val get_smtlib_formulas: context -> ast array
|
||||
|
||||
(**
|
||||
\[ [get_smtlib_assumptions c] \] is the array of assumptions created by a preceding call to {!Z3.parse_smtlib_string} or {!Z3.parse_smtlib_file}.
|
||||
|
||||
Recommend use {!Z3.parse_smtlib_string_x} or {!Z3.parse_smtlib_file_x} for functional style interface to the SMT-LIB parser.
|
||||
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_string}
|
||||
- {b See also}: {!Z3.parse_smtlib_file}
|
||||
- {b See also}: {!Z3.get_smtlib_num_assumptions}
|
||||
- {b See also}: {!Z3.get_smtlib_assumption}
|
||||
*)
|
||||
val get_smtlib_assumptions: context -> ast array
|
||||
|
||||
(**
|
||||
\[ [ get_smtlib_decls c ] \] is the array of declarations created by a preceding call to {!Z3.parse_smtlib_string} or {!Z3.parse_smtlib_file}.
|
||||
|
||||
Recommend use {!Z3.parse_smtlib_string_x} or {!Z3.parse_smtlib_file_x} for functional style interface to the SMT-LIB parser.
|
||||
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_string}
|
||||
- {b See also}: {!Z3.parse_smtlib_file}
|
||||
- {b See also}: {!Z3.get_smtlib_num_decls}
|
||||
- {b See also}: {!Z3.get_smtlib_decl}
|
||||
*)
|
||||
val get_smtlib_decls: context -> func_decl array
|
||||
|
||||
(**
|
||||
\[ [ get_smtlib_parse_results c ] \] is the triple [(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c)].
|
||||
|
||||
Recommend use {!Z3.parse_smtlib_string_x} or {!Z3.parse_smtlib_file_x} for functional style interface to the SMT-LIB parser.
|
||||
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_string}
|
||||
- {b See also}: {!Z3.parse_smtlib_file}
|
||||
- {b See also}: {!Z3.get_smtlib_formulas}
|
||||
- {b See also}: {!Z3.get_smtlib_assumptions}
|
||||
- {b See also}: {!Z3.get_smtlib_decls}
|
||||
*)
|
||||
val get_smtlib_parse_results: context -> (ast array * ast array * func_decl array)
|
||||
|
||||
(**
|
||||
\[ [ parse_smtlib_string_formula c ... ] \] calls [(parse_smtlib_string c ...)] and returns the single formula produced.
|
||||
|
||||
Recommended for functional style interface to the SMT-LIB parser.
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_file_formula}
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
*)
|
||||
val parse_smtlib_string_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
|
||||
|
||||
(**
|
||||
\[ [ parse_smtlib_file_formula c ... ] \] calls [(parse_smtlib_file c ...)] and returns the single formula produced.
|
||||
|
||||
Recommended for functional style interface to the SMT-LIB parser.
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_file_formula}
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
*)
|
||||
val parse_smtlib_file_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
|
||||
|
||||
(**
|
||||
\[ [ parse_smtlib_string_x c ... ] \] is [(parse_smtlib_string c ...; get_smtlib_parse_results c)]
|
||||
|
||||
Recommended for functional style interface to the SMT-LIB parser.
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_file_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_string}
|
||||
- {b See also}: {!Z3.get_smtlib_parse_results}
|
||||
*)
|
||||
val parse_smtlib_string_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array)
|
||||
|
||||
(**
|
||||
\[ [ parse_smtlib_file_x c ... ] \] is [(parse_smtlib_file c ...; get_smtlib_parse_results c)]
|
||||
|
||||
Recommended for functional style interface to the SMT-LIB parser.
|
||||
|
||||
- {b See also}: {!Z3.parse_smtlib_string_x}
|
||||
- {b See also}: {!Z3.parse_smtlib_file}
|
||||
- {b See also}: {!Z3.get_smtlib_parse_results}
|
||||
*)
|
||||
val parse_smtlib_file_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array)
|
||||
|
||||
(**
|
||||
\[ [ symbol_refined ] \] is the refinement of a {!Z3.symbol} .
|
||||
|
||||
- {b See also}: {!Z3.symbol_refine}
|
||||
- {b See also}: {!Z3.get_symbol_kind}
|
||||
*)
|
||||
type symbol_refined =
|
||||
| Symbol_int of int
|
||||
| Symbol_string of string
|
||||
| Symbol_unknown;;
|
||||
|
||||
(**
|
||||
\[ [ symbol_refine c s ] \] is the refined symbol of [s].
|
||||
|
||||
- {b See also}: {!Z3.symbol_refined}
|
||||
- {b See also}: {!Z3.get_symbol_kind}
|
||||
*)
|
||||
val symbol_refine: context -> symbol -> symbol_refined;;
|
||||
|
||||
(**
|
||||
\[ [ sort_refined ] \] is the refinement of a {!Z3.sort} .
|
||||
|
||||
- {b See also}: {!Z3.sort_refine}
|
||||
- {b See also}: {!Z3.get_sort_kind}
|
||||
*)
|
||||
|
||||
|
||||
type sort_refined =
|
||||
| Sort_uninterpreted of symbol
|
||||
| Sort_bool
|
||||
| Sort_int
|
||||
| Sort_real
|
||||
| Sort_bv of int
|
||||
| Sort_array of (sort * sort)
|
||||
| Sort_datatype of datatype_constructor_refined array
|
||||
| Sort_relation
|
||||
| Sort_finite_domain
|
||||
| Sort_unknown of symbol
|
||||
|
||||
(**
|
||||
\[ [ sort_refine c t ] \] is the refined sort of [t].
|
||||
|
||||
- {b See also}: {!Z3.sort_refined}
|
||||
- {b See also}: {!Z3.get_sort_kind}
|
||||
*)
|
||||
val sort_refine: context -> sort -> sort_refined;;
|
||||
|
||||
(**
|
||||
\[ [ binder_type ] \] is a universal or existential quantifier.
|
||||
|
||||
- {b See also}: {!Z3.term_refined}
|
||||
*)
|
||||
type binder_type = | Forall | Exists
|
||||
|
||||
(**
|
||||
\[ [ numeral_refined ] \] is the refinement of a numeral .
|
||||
|
||||
Numerals whose fractional representation can be fit with
|
||||
64 bit integers are treated as small.
|
||||
|
||||
*)
|
||||
type numeral_refined =
|
||||
| Numeral_small of int64 * int64
|
||||
| Numeral_large of string
|
||||
|
||||
(**
|
||||
\[ [ term_refined ] \] is the refinement of a {!Z3.ast} .
|
||||
|
||||
- {b See also}: {!Z3.term_refine}
|
||||
*)
|
||||
type term_refined =
|
||||
| Term_app of decl_kind * func_decl * ast array
|
||||
| Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast
|
||||
| Term_numeral of numeral_refined * sort
|
||||
| Term_var of int * sort
|
||||
|
||||
(**
|
||||
\[ [ term_refine c a ] \] is the refined term of [a].
|
||||
|
||||
- {b See also}: {!Z3.term_refined}
|
||||
*)
|
||||
val term_refine : context -> ast -> term_refined
|
||||
|
||||
(**
|
||||
\[ [mk_theory c name ] \] create a custom theory.
|
||||
|
||||
*)
|
||||
val mk_theory : context -> string -> theory
|
||||
|
||||
(**
|
||||
\[ [set_delete_callback th cb] \] set callback when theory gets deleted.
|
||||
*)
|
||||
val set_delete_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_reduce_app_callback th cb] \] set callback for simplifying theory terms.
|
||||
*)
|
||||
val set_reduce_app_callback : theory -> (func_decl -> ast array -> ast option) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_reduce_eq_callback th cb] \] set callback for simplifying equalities over theory terms.
|
||||
*)
|
||||
val set_reduce_eq_callback : theory -> (ast -> ast -> ast option) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_reduce_distinct_callback th cb] \] set callback for simplifying disequalities over theory terms.
|
||||
*)
|
||||
val set_reduce_distinct_callback : theory -> (ast array -> ast option) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_new_app_callback th cb] \] set callback for registering new application.
|
||||
*)
|
||||
val set_new_app_callback : theory -> (ast -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_new_elem_callback th cb] \] set callback for registering new element.
|
||||
|
||||
- {b See also}: the help for the corresponding C API function.
|
||||
*)
|
||||
val set_new_elem_callback : theory -> (ast -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_init_search_callback th cb] \] set callback when Z3 starts searching for a satisfying assignment.
|
||||
*)
|
||||
val set_init_search_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_push_callback th cb] \] set callback for a logical context push.
|
||||
*)
|
||||
val set_push_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_pop_callback th cb] \] set callback for a logical context pop.
|
||||
*)
|
||||
val set_pop_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
(**
|
||||
\[ [set_restart_callback th cb] \] set callback for search restart.
|
||||
*)
|
||||
val set_restart_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
val set_reset_callback : theory -> (unit -> unit) -> unit
|
||||
|
||||
val set_final_check_callback : theory -> (unit -> bool) -> unit
|
||||
|
||||
val set_new_eq_callback : theory -> (ast -> ast -> unit) -> unit
|
||||
|
||||
val set_new_diseq_callback : theory -> (ast -> ast -> unit) -> unit
|
||||
|
||||
val set_new_assignment_callback : theory -> (ast -> bool -> unit) -> unit
|
||||
|
||||
val set_new_relevant_callback : theory -> (ast -> unit) -> unit
|
||||
|
||||
");
|
607
src/bindings/ml/z3.idl
Normal file
607
src/bindings/ml/z3.idl
Normal file
|
@ -0,0 +1,607 @@
|
|||
/*++
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Z3
|
||||
|
||||
Abstract:
|
||||
|
||||
OCaml API for Z3.
|
||||
|
||||
The following design is used for the treatment of reference counting:
|
||||
|
||||
- The conversion of Z3_context from ML to C remembers the Z3 context, and
|
||||
registers a finalizer using Gc.finalize that calls Z3_del_context.
|
||||
|
||||
- The conversion of Z3_ast and other reference counted types from C to ML:
|
||||
|
||||
+ stores the last translated context with the Z3_ast in the wrapper
|
||||
object;
|
||||
|
||||
+ registers a finalizer using Gc.finalize that decrements the reference
|
||||
counter of the Z3_ast;
|
||||
|
||||
+ increments the reference count of the Z3_ast.
|
||||
|
||||
The finalizers are registered using (the C interface to) Gc.finalize,
|
||||
not attaching a finalizer to a custom block. The finalizers registered
|
||||
by Gc.finalize are guaranteed to be called in reverse
|
||||
registration-order, which is necessary to ensure that Z3_context's are
|
||||
finalized only after all the Z3_ast's within them.
|
||||
|
||||
- ML Z3.ast (and subtypes) are given generic hash and comparison
|
||||
operations using Z3_get_ast_hash and Z3_get_ast_id. Other types could
|
||||
be handled similarly if analogous hash and id operations were exported
|
||||
by the C API.
|
||||
|
||||
- The wrapper for Z3_mk_context is customized (using quote(call,...) in
|
||||
z3_api.patched.h) to call Z3_mk_context_rc, and the ML API does not
|
||||
include mk_context_rc.
|
||||
|
||||
This scheme relies on the property that all reference counted values
|
||||
returned from C to ML are in the Z3_context that was last sent from ML to
|
||||
C. This is normally straightforward, but note that it depends on the
|
||||
argument order of e.g. the Z3_*translate functions.
|
||||
|
||||
Non-reference counted Z3 types that have delete operations have finalizers
|
||||
that call the delete operations. The exposed delete operations are
|
||||
shadowed by nop functions. The types whose delete operation accepts a
|
||||
context use Gc.finalize while those that do not use custom block
|
||||
finalizers.
|
||||
|
||||
Custom c2ml functions check the Z3 error code prior to allocating ML
|
||||
values or registering finalizers. Other functions check the Z3 error code
|
||||
after making a Z3 library call.
|
||||
|
||||
Some operations return NULL pointers when operations fail, or accept NULL
|
||||
pointers. To handle these cases Z3_{ast,func_interp,sort}_opt types are
|
||||
introduced. These are synonyms of Z3_{ast,func_interp,sort} but are
|
||||
translated into OCaml option types. If the NULL pointers were passed to
|
||||
ML, even if the user does not access them, they will have finalizers
|
||||
registered, so when they die the OCaml GC will crash trying to call
|
||||
dec_ref on NULL.
|
||||
|
||||
There is an alternate implementation, enabled by setting LEAK_CONTEXTS,
|
||||
that avoids the overhead of Gc.finalize finalizers, but at the price of
|
||||
leaking Z3_context objects.
|
||||
|
||||
Notes:
|
||||
|
||||
OCaml does not support unsigned types, so CamlIDL conflates signed and
|
||||
unsigned types of the same size. Therefore, functions in the C API
|
||||
operating on unsigned values that become redundant after this conflation
|
||||
are excluded from the ML API using [#ifndef CAMLIDL] in z3_api.h.
|
||||
|
||||
CamlIDL does not support function pointers, so functions in the C API with
|
||||
function pointer arguments are handled manually.
|
||||
|
||||
Author:
|
||||
|
||||
Jakob Lichtenberg (JakobL) 2007-08-08
|
||||
Josh Berdine (jjb) 2012-03-21
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
// cpp trick to include expanded macro arguments in string literals
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
quote(c,"#define xstr(s) str(s)");
|
||||
quote(c,"#define str(s) #s");
|
||||
|
||||
|
||||
// CamlIDL (1.05) has a bug where it does not accept [unsigned] as a type,
|
||||
// only as a specifier, so unsigned is defined to be unsigned int.
|
||||
#define unsigned unsigned int
|
||||
|
||||
|
||||
// Suppress "warning C4090: 'function' : different 'const' qualifiers" as
|
||||
// CamlIDL does not seem to get this right.
|
||||
quote(c,"#pragma warning(disable:4090)");
|
||||
|
||||
|
||||
#ifndef MLAPIV3
|
||||
|
||||
#define DEFINE_TYPE(T) typedef [abstract] void* T
|
||||
#define DEFINE_VOID(T) typedef [abstract] void* T
|
||||
|
||||
#define BEGIN_MLAPI_EXCLUDE quote(mli,"(*");
|
||||
#define END_MLAPI_EXCLUDE quote(mli,"*)");
|
||||
|
||||
#ifdef LEAK_CONTEXTS
|
||||
|
||||
// Declare pointer type with custom conversion functions.
|
||||
#define DEFINE_CUST_TYPE(T) \
|
||||
typedef [abstract, ml2c(ml2c_Z3_ ## T), c2ml(c2ml_Z3_ ## T)] void* Z3_ ## T
|
||||
|
||||
#else
|
||||
|
||||
// Declare pointer type with custom conversion functions.
|
||||
// Register an OCaml closure that just calls a C finalization function.
|
||||
#define DEFINE_CUST_TYPE(T) \
|
||||
quote(ml,xstr(\
|
||||
external finalize_Z3_ ## T : T -> unit = xstr(finalize_Z3_ ## T);; \
|
||||
let _ = Callback.register xstr(finalize_Z3_ ## T) finalize_Z3_ ## T \
|
||||
)); \
|
||||
typedef [abstract, ml2c(ml2c_Z3_ ## T), c2ml(c2ml_Z3_ ## T)] void* Z3_ ## T
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Z3_context
|
||||
quote(c,"
|
||||
void check_error_code (Z3_context c);
|
||||
|
||||
Z3_context last_ctx;
|
||||
");
|
||||
|
||||
#ifdef LEAK_CONTEXTS
|
||||
|
||||
quote(c,"
|
||||
value c2ml_Z3_context(Z3_context* c)
|
||||
{
|
||||
value v;
|
||||
v = caml_alloc_small(1, Abstract_tag);
|
||||
*((Z3_context *) Bp_val(v)) = *c;
|
||||
return v;
|
||||
}
|
||||
|
||||
void ml2c_Z3_context(value v, Z3_context* c)
|
||||
{
|
||||
*c = *((Z3_context *) Bp_val(v));
|
||||
last_ctx = *c;
|
||||
}
|
||||
");
|
||||
|
||||
#else
|
||||
|
||||
quote(c,"
|
||||
// caml_final_register is the implementation of Gc.finalize
|
||||
value caml_final_register (value f, value v);
|
||||
|
||||
void register_finalizer(value** closure, char* name, Z3_context ctx, value v)
|
||||
{
|
||||
if (*closure == NULL) {
|
||||
*closure = caml_named_value(name);
|
||||
if (*closure == NULL) {
|
||||
Z3_set_error(ctx, Z3_INTERNAL_FATAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
caml_final_register(**closure, v);
|
||||
}
|
||||
|
||||
value c2ml_Z3_context (Z3_context* c)
|
||||
{
|
||||
static value* finalize_Z3_context_closure = NULL;
|
||||
value v;
|
||||
v = caml_alloc_small(1, Abstract_tag);
|
||||
Field(v, 0) = (value) *c;
|
||||
register_finalizer(&finalize_Z3_context_closure, \"finalize_Z3_context\",
|
||||
(Z3_context) *c, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
void ml2c_Z3_context (value v, Z3_context* c)
|
||||
{
|
||||
*c = (Z3_context) Field(v, 0);
|
||||
last_ctx = *c;
|
||||
}
|
||||
|
||||
value finalize_Z3_context (value v)
|
||||
{
|
||||
Z3_context c;
|
||||
c = (Z3_context) Field(v, 0);
|
||||
Z3_del_context(c);
|
||||
return Val_unit;
|
||||
}
|
||||
");
|
||||
|
||||
#endif
|
||||
|
||||
DEFINE_CUST_TYPE(context);
|
||||
|
||||
|
||||
// Z3_symbol
|
||||
typedef [abstract] void* Z3_symbol;
|
||||
|
||||
|
||||
// Z3_ast: reference counted type with hashing and comparison
|
||||
quote(c,"
|
||||
typedef struct _Z3_ast_context {
|
||||
Z3_ast ast;
|
||||
Z3_context ctx;
|
||||
} Z3_ast_context;
|
||||
|
||||
void ml2c_Z3_ast (value v, Z3_ast* c)
|
||||
{
|
||||
*c = ((Z3_ast_context*) Data_custom_val(v))->ast;
|
||||
}
|
||||
|
||||
static int compare_Z3_ast (value v1, value v2)
|
||||
{
|
||||
Z3_ast_context* ac1;
|
||||
Z3_ast_context* ac2;
|
||||
unsigned id1, id2;
|
||||
ac1 = Data_custom_val(v1);
|
||||
ac2 = Data_custom_val(v2);
|
||||
id1 = Z3_get_ast_id(ac1->ctx, ac1->ast);
|
||||
check_error_code(ac1->ctx);
|
||||
id2 = Z3_get_ast_id(ac2->ctx, ac2->ast);
|
||||
check_error_code(ac2->ctx);
|
||||
return id2 - id1;
|
||||
}
|
||||
|
||||
static intnat hash_Z3_ast (value v)
|
||||
{
|
||||
Z3_ast_context* ac;
|
||||
unsigned hash;
|
||||
ac = Data_custom_val(v);
|
||||
hash = Z3_get_ast_hash(ac->ctx, ac->ast);
|
||||
check_error_code(ac->ctx);
|
||||
return hash;
|
||||
}
|
||||
");
|
||||
|
||||
#ifdef LEAK_CONTEXTS
|
||||
|
||||
quote(c,"
|
||||
static void finalize_Z3_ast (value v)
|
||||
{
|
||||
Z3_ast_context* ac;
|
||||
ac = Data_custom_val(v);
|
||||
Z3_dec_ref(ac->ctx, ac->ast);
|
||||
check_error_code(ac->ctx);
|
||||
}
|
||||
|
||||
static struct custom_operations cops_Z3_ast = {
|
||||
NULL,
|
||||
finalize_Z3_ast,
|
||||
compare_Z3_ast,
|
||||
hash_Z3_ast,
|
||||
custom_serialize_default,
|
||||
custom_deserialize_default
|
||||
};
|
||||
|
||||
value c2ml_Z3_ast (Z3_ast* c)
|
||||
{
|
||||
value v;
|
||||
Z3_ast_context* ac;
|
||||
check_error_code(last_ctx);
|
||||
v = alloc_custom(&cops_Z3_ast, sizeof(Z3_ast_context), 0, 1);
|
||||
ac = Data_custom_val(v);
|
||||
ac->ctx = last_ctx;
|
||||
ac->ast = *c;
|
||||
Z3_inc_ref(ac->ctx, ac->ast);
|
||||
return v;
|
||||
}
|
||||
");
|
||||
|
||||
#else
|
||||
|
||||
quote(c,"
|
||||
value finalize_Z3_ast (value v)
|
||||
{
|
||||
Z3_ast_context* ac;
|
||||
ac = Data_custom_val(v);
|
||||
Z3_dec_ref(ac->ctx, ac->ast);
|
||||
check_error_code(ac->ctx);
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
static struct custom_operations cops_Z3_ast = {
|
||||
NULL,
|
||||
custom_finalize_default,
|
||||
compare_Z3_ast,
|
||||
hash_Z3_ast,
|
||||
custom_serialize_default,
|
||||
custom_deserialize_default
|
||||
};
|
||||
|
||||
value c2ml_Z3_ast (Z3_ast* c)
|
||||
{
|
||||
static value* finalize_Z3_ast_closure = NULL;
|
||||
value v;
|
||||
Z3_ast_context* ac;
|
||||
check_error_code(last_ctx);
|
||||
v = caml_alloc_custom(&cops_Z3_ast, sizeof(Z3_ast_context), 0, 1);
|
||||
ac = Data_custom_val(v);
|
||||
ac->ast = *c;
|
||||
ac->ctx = last_ctx;
|
||||
register_finalizer(&finalize_Z3_ast_closure, \"finalize_Z3_ast\",
|
||||
(Z3_context) *c, v);
|
||||
Z3_inc_ref(last_ctx, *c);
|
||||
return v;
|
||||
}
|
||||
");
|
||||
|
||||
#endif
|
||||
|
||||
DEFINE_CUST_TYPE(ast);
|
||||
|
||||
|
||||
// subtypes of Z3_ast
|
||||
quote(c,"\
|
||||
#define DEFINE_SUBAST_OPS(T) \
|
||||
void ml2c_ ## T (value v, T * a) \
|
||||
{ \
|
||||
ml2c_Z3_ast(v, (Z3_ast*) a); \
|
||||
} \
|
||||
\
|
||||
value c2ml_ ## T (T * a) \
|
||||
{ \
|
||||
return c2ml_Z3_ast((Z3_ast*) a); \
|
||||
} \
|
||||
");
|
||||
|
||||
#define DEFINE_SUBAST(T) \
|
||||
typedef [mltype("private ast"), ml2c(ml2c_ ## T), c2ml(c2ml_ ## T)] Z3_ast T
|
||||
|
||||
quote(c,"DEFINE_SUBAST_OPS(Z3_sort)"); DEFINE_SUBAST(Z3_sort);
|
||||
quote(c,"DEFINE_SUBAST_OPS(Z3_func_decl)"); DEFINE_SUBAST(Z3_func_decl);
|
||||
quote(c,"DEFINE_SUBAST_OPS(Z3_app)"); DEFINE_SUBAST(Z3_app);
|
||||
quote(c,"DEFINE_SUBAST_OPS(Z3_pattern)"); DEFINE_SUBAST(Z3_pattern);
|
||||
|
||||
|
||||
// reference counted types without hashing and comparison
|
||||
#ifdef LEAK_CONTEXTS
|
||||
|
||||
quote(c,"\
|
||||
#define DEFINE_RC_OPS(T) \
|
||||
typedef struct _ ## T ## _context { \
|
||||
T dat; \
|
||||
Z3_context ctx; \
|
||||
} T ## _context; \
|
||||
\
|
||||
static void finalize_ ## T (value v) \
|
||||
{ \
|
||||
T ## _context* ac; \
|
||||
ac = Data_custom_val(v); \
|
||||
T ## _dec_ref(ac->ctx, ac->dat); \
|
||||
check_error_code(ac->ctx); \
|
||||
} \
|
||||
\
|
||||
static struct custom_operations cops_ ## T = { \
|
||||
NULL, \
|
||||
finalize_ ## T, \
|
||||
custom_compare_default, \
|
||||
custom_hash_default, \
|
||||
custom_serialize_default, \
|
||||
custom_deserialize_default \
|
||||
}; \
|
||||
\
|
||||
value c2ml_ ## T (T * c) \
|
||||
{ \
|
||||
value v; \
|
||||
T ## _context* ac; \
|
||||
check_error_code(last_ctx); \
|
||||
v = alloc_custom(&cops_ ## T, sizeof(T ## _context), 0, 1); \
|
||||
ac = Data_custom_val(v); \
|
||||
ac->dat = *c; \
|
||||
ac->ctx = last_ctx; \
|
||||
T ## _inc_ref(ac->ctx, ac->dat); \
|
||||
return v; \
|
||||
} \
|
||||
\
|
||||
void ml2c_ ## T (value v, T * c) \
|
||||
{ \
|
||||
*c = ((T ## _context*) Data_custom_val(v))->dat; \
|
||||
} \
|
||||
");
|
||||
|
||||
#else
|
||||
|
||||
quote(c,"\
|
||||
#define DEFINE_RC_OPS(T) \
|
||||
value c2ml_ ## T (T * c) \
|
||||
{ \
|
||||
static value* finalize_ ## T ## _closure = NULL; \
|
||||
value v; \
|
||||
check_error_code(last_ctx); \
|
||||
v = caml_alloc_small(2, Abstract_tag); \
|
||||
Field(v, 0) = (value) *c; \
|
||||
Field(v, 1) = (value) last_ctx; \
|
||||
register_finalizer(&finalize_ ## T ## _closure, xstr(finalize_ ## T), \
|
||||
(Z3_context) *c, v); \
|
||||
T ## _inc_ref(last_ctx, *c); \
|
||||
return v; \
|
||||
} \
|
||||
\
|
||||
void ml2c_ ## T (value v, T * c) \
|
||||
{ \
|
||||
*c = (T) Field(v, 0); \
|
||||
} \
|
||||
\
|
||||
value finalize_ ## T (value v) \
|
||||
{ \
|
||||
Z3_context c; \
|
||||
c = (Z3_context) Field(v, 1); \
|
||||
T ## _dec_ref(c, (T) Field(v, 0)); \
|
||||
check_error_code(c); \
|
||||
return Val_unit; \
|
||||
} \
|
||||
");
|
||||
|
||||
#endif
|
||||
|
||||
quote(c,"DEFINE_RC_OPS(Z3_params)"); DEFINE_CUST_TYPE(params);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_param_descrs)"); DEFINE_CUST_TYPE(param_descrs);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_model)"); DEFINE_CUST_TYPE(model);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_func_interp)"); DEFINE_CUST_TYPE(func_interp);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_func_entry)"); DEFINE_CUST_TYPE(func_entry);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_fixedpoint)"); DEFINE_CUST_TYPE(fixedpoint);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_ast_vector)"); DEFINE_CUST_TYPE(ast_vector);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_ast_map)"); DEFINE_CUST_TYPE(ast_map);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_goal)"); DEFINE_CUST_TYPE(goal);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_tactic)"); DEFINE_CUST_TYPE(tactic);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_probe)"); DEFINE_CUST_TYPE(probe);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_apply_result)"); DEFINE_CUST_TYPE(apply_result);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_solver)"); DEFINE_CUST_TYPE(solver);
|
||||
quote(c,"DEFINE_RC_OPS(Z3_stats)"); DEFINE_CUST_TYPE(stats);
|
||||
|
||||
|
||||
// possibly-NULL pointer types, translated to OCaml option types
|
||||
quote(c,"\
|
||||
#define DEFINE_OPT_OPS(T) \
|
||||
void ml2c_ ## T ## _opt (value v, T* c) \
|
||||
{ \
|
||||
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; \
|
||||
camlidl_ctx _ctx = &_ctxs; \
|
||||
if (v != Val_int(0)) { \
|
||||
camlidl_ml2c_z3_ ## T(Field(v, 0), c, _ctx); \
|
||||
} else { \
|
||||
*c = NULL; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
value c2ml_ ## T ## _opt (T* c) \
|
||||
{ \
|
||||
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; \
|
||||
camlidl_ctx _ctx = &_ctxs; \
|
||||
value v; \
|
||||
value a; \
|
||||
if (*c) { \
|
||||
a = camlidl_c2ml_z3_ ## T(c, _ctx); \
|
||||
Begin_root(a) \
|
||||
v = caml_alloc_small(1, 0); \
|
||||
Field(v, 0) = a; \
|
||||
End_roots(); \
|
||||
} else { \
|
||||
v = Val_int(0); \
|
||||
} \
|
||||
return v; \
|
||||
}
|
||||
");
|
||||
|
||||
#define DEFINE_OPT_TYPE(T) \
|
||||
typedef [mltype(xstr(T option)), \
|
||||
ml2c(ml2c_Z3_ ## T ## _opt), \
|
||||
c2ml(c2ml_Z3_ ## T ## _opt) \
|
||||
] Z3_ ## T Z3_ ## T ## _opt
|
||||
|
||||
quote(c,"DEFINE_OPT_OPS(Z3_ast)");
|
||||
DEFINE_OPT_TYPE(ast);
|
||||
|
||||
quote(c,"DEFINE_OPT_OPS(Z3_sort)");
|
||||
DEFINE_OPT_TYPE(sort);
|
||||
|
||||
quote(c,"DEFINE_OPT_OPS(Z3_func_interp)");
|
||||
DEFINE_OPT_TYPE(func_interp);
|
||||
|
||||
|
||||
// ToDo: these unnecessarily appear in the API documentation
|
||||
DEFINE_TYPE(Z3_constructor);
|
||||
DEFINE_TYPE(Z3_constructor_list);
|
||||
|
||||
|
||||
// shadow delete operations with nops
|
||||
quote(ml,"
|
||||
let del_constructor _ _ = ()
|
||||
let del_constructor_list _ _ = ()
|
||||
let del_model _ _ = ()
|
||||
let del_context _ = ()
|
||||
let reset_memory () = ()
|
||||
");
|
||||
|
||||
|
||||
#else // MLAPIV3
|
||||
|
||||
// Provide custom error handler:
|
||||
quote (c,"Z3_error_handler caml_z3_error_handler;");
|
||||
quote (c,"void caml_z3_error_handler(Z3_context c, Z3_error_code e) { static char buffer[128]; char * msg = Z3_get_error_msg_ex(c, e); if (strlen(msg) > 100) { failwith(\"Z3: error message is too big to fit in buffer\"); } else { sprintf(buffer, \"Z3: %s\", msg); failwith(buffer); } }");
|
||||
|
||||
|
||||
#define DEFINE_TYPE(T) typedef [abstract] void* T
|
||||
#define DEFINE_VOID(T) typedef [abstract] void* T
|
||||
|
||||
#define BEGIN_MLAPI_EXCLUDE
|
||||
#define END_MLAPI_EXCLUDE
|
||||
|
||||
#endif // MLAPIV3
|
||||
|
||||
|
||||
|
||||
#ifndef __in
|
||||
#define __in [in]
|
||||
#endif
|
||||
|
||||
#ifndef __out
|
||||
#define __out [out]
|
||||
#endif
|
||||
|
||||
#ifndef __out_opt
|
||||
#define __out_opt [out,unique]
|
||||
#endif
|
||||
|
||||
#ifndef __ecount
|
||||
#define __ecount(num_args) [NOT_SUPPORTED]
|
||||
#endif
|
||||
|
||||
#ifndef __in_ecount
|
||||
#define __in_ecount(num_args) [in, size_is(num_args), length_is(num_args)]
|
||||
#endif
|
||||
|
||||
#ifndef __out_ecount
|
||||
#define __out_ecount(num_args) [out, size_is(num_args), length_is(num_args)]
|
||||
#endif
|
||||
|
||||
#ifndef __inout_ecount
|
||||
#define __inout_ecount(num_args) [in, out, size_is(num_args), length_is(num_args)]
|
||||
#endif
|
||||
|
||||
#ifndef __inout
|
||||
#define __inout [in, out]
|
||||
#endif
|
||||
|
||||
#ifndef Z3_bool_opt
|
||||
#define Z3_bool_opt void
|
||||
#endif
|
||||
|
||||
|
||||
#define Z3_API
|
||||
|
||||
#ifdef MLAPIV3
|
||||
|
||||
#include "z3V3_api.idl"
|
||||
#include "x3V3.mli"
|
||||
#include "x3V3.ml"
|
||||
|
||||
#else
|
||||
|
||||
#include "z3_api.idl"
|
||||
#include "x3.ml"
|
||||
|
||||
quote(ml,"
|
||||
let _ =
|
||||
Printexc.register_printer (function
|
||||
| Error(c,e) -> Some (\"Z3 \"^(get_error_msg c e))
|
||||
| _ -> None
|
||||
)
|
||||
");
|
||||
|
||||
|
||||
quote(mli,"
|
||||
(**
|
||||
{2 {L Legacy V3 API}}
|
||||
*)
|
||||
|
||||
module V3 : sig
|
||||
(**
|
||||
{2 {L Legacy V3 API}}
|
||||
*)
|
||||
");
|
||||
|
||||
quote(ml,"
|
||||
module V3 = struct
|
||||
");
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MLAPIV3
|
||||
|
||||
quote(mlmli,"
|
||||
end
|
||||
");
|
||||
|
||||
#endif
|
3503
src/bindings/ml/z3.ml
Normal file
3503
src/bindings/ml/z3.ml
Normal file
File diff suppressed because it is too large
Load diff
11485
src/bindings/ml/z3.mli
Normal file
11485
src/bindings/ml/z3.mli
Normal file
File diff suppressed because it is too large
Load diff
18990
src/bindings/ml/z3_stubs.c
Normal file
18990
src/bindings/ml/z3_stubs.c
Normal file
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue