3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-30 04:15:51 +00:00

Merge branch 'unstable' of https://git01.codeplex.com/z3 into unstable

This commit is contained in:
Leonardo de Moura 2012-11-27 09:20:15 -08:00
commit 41a59325d9
159 changed files with 12259 additions and 10647 deletions

View file

@ -519,6 +519,9 @@ def get_c_files(path):
def get_cs_files(path):
return filter(lambda f: f.endswith('.cs'), os.listdir(path))
def get_java_files(path):
return filter(lambda f: f.endswith('.java'), os.listdir(path))
def find_all_deps(name, deps):
new_deps = []
for dep in deps:
@ -957,20 +960,20 @@ class JavaDLLComponent(Component):
def mk_makefile(self, out):
if is_java_enabled():
dllfile = '%s$(SO_EXT)' % self.dll_name
out.write('%s: %s/Z3Native.java %s$(SO_EXT)\n' % (dllfile, self.to_src_dir, get_component('api_dll').dll_name))
if IS_WINDOWS:
out.write('\tcd %s && %s Z3Native.java\n' % (unix_path2dos(self.to_src_dir), JAVAC))
out.write('\tmove %s\\*.class .\n' % unix_path2dos(self.to_src_dir))
out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I"%s/include/win32" -I%s %s/Z3Native.c\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir))
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) Z3Native$(OBJ_EXT) libz3.lib\n' % dllfile)
else:
out.write('\tcd %s; %s Z3Native.java\n' % (self.to_src_dir, JAVAC))
out.write('\tmv %s/*.class .\n' % self.to_src_dir)
out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I%s %s/Z3Native.c\n' % (JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir))
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) -L. Z3Native$(OBJ_EXT) -lz3\n' % dllfile)
out.write('%s: %s\n\n' % (self.name, dllfile))
# TODO: Compile and package all the .class files.
dllfile = '%s$(SO_EXT)' % self.dll_name
out.write('libz3java$(SO_EXT): libz3$(SO_EXT) ../src/api/java/Native.cpp\n')
out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Native$(OBJ_EXT) -I"%s/include" -I"%s/include/win32" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir))
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3.lib\n')
out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name)
# for java_file in get_java_files(self.src_dir):
# out.write('%s ' % java_file)
# for java_file in get_java_files((self.src_dir + "/%s/Enumerations") % subdir):
# out.write('%s ' % java_file)
out.write('\n')
out.write(('\t%s %s/Enumerations/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\"))
out.write(('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\"))
out.write('\tjar cf %s.jar api/java/\n' % self.package_name)
out.write('java: %s.jar\n\n' % self.package_name)
def main_component(self):
return is_java_enabled()
@ -1822,7 +1825,7 @@ def mk_z3consts_java(api_files):
java = get_component(JAVA_COMPONENT)
DeprecatedEnums = [ 'Z3_search_failure' ]
gendir = java.src_dir + "/" + java.package_name.replace(".", "/") + "/Enumerations"
gendir = java.src_dir + "/Enumerations"
if not os.path.exists(gendir):
os.mkdir(gendir)
@ -1873,15 +1876,32 @@ def mk_z3consts_java(api_files):
if name not in DeprecatedEnums:
efile = open('%s/%s.java' % (gendir, name), 'w')
efile.write('/**\n * Automatically generated file\n **/\n\n')
efile.write('package %s;\n\n' % java.package_name);
efile.write('package %s.Enumerations;\n\n' % java.package_name);
efile.write('/**\n')
efile.write(' * %s\n' % name)
efile.write(' **/\n')
efile.write('public enum %s {\n' % name)
efile.write
first = True
for k, i in decls.iteritems():
efile.write('%s (%s),\n' % (k, i))
if first:
first = False
else:
efile.write(',\n')
efile.write(' %s (%s)' % (k, i))
efile.write(";\n")
efile.write('\n private final int intValue;\n\n')
efile.write(' %s(int v) {\n' % name)
efile.write(' this.intValue = v;\n')
efile.write(' }\n\n')
efile.write(' public static final %s fromInt(int v) {\n' % name)
efile.write(' for (%s k: values()) \n' % name)
efile.write(' if (k.intValue == v) return k;\n')
efile.write(' return values()[0];\n')
efile.write(' }\n\n')
efile.write(' public final int toInt() { return this.intValue; }\n')
# efile.write(';\n %s(int v) {}\n' % name)
efile.write('}\n\n')
efile.close()
mode = SEARCHING

View file

@ -252,11 +252,11 @@ def param2java(p):
k = param_kind(p)
if k == OUT:
if param_type(p) == INT or param_type(p) == UINT:
return "Integer"
return "IntPtr"
elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) >= FIRST_OBJ_ID:
return "Long"
return "LongPtr"
elif param_type(p) == STRING:
return "String"
return "StringPtr"
else:
print "ERROR: unreachable code"
assert(False)
@ -496,19 +496,16 @@ def mk_java():
if not is_java_enabled():
return
java_dir = get_component('java').src_dir
try:
os.mkdir('%s/com/Microsoft/Z3/' % java_dir)
except:
pass # OK if it exists already.
java_nativef = '%s/com/Microsoft/Z3/Native.java' % java_dir
java_wrapperf = '%s/com/Microsoft/Z3/Native.c' % java_dir
java_nativef = '%s/Native.java' % java_dir
java_wrapperf = '%s/Native.cpp' % java_dir
java_native = open(java_nativef, 'w')
java_native.write('// Automatically generated file\n')
java_native.write('package com.Microsoft.Z3;\n')
java_native.write('package %s;\n' % get_component('java').package_name)
java_native.write('public final class Native {\n')
java_native.write(' public static class IntPtr { public int value; }\n')
java_native.write(' public static class LongPtr { public long value; }\n')
java_native.write(' public static class StringPtr { public String value; }\n')
java_native.write(' public static class errorHandler { public long ptr; }\n')
if is_windows():
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java'))

View file

@ -37,7 +37,6 @@ namespace Microsoft.Z3
#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
};
}

View file

@ -193,7 +193,7 @@ namespace Microsoft.Z3
{
Contract.Ensures(Contract.Result<BitVecSort>() != null);
return new BitVecSort(this, size);
return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size));
}
/// <summary>
@ -388,7 +388,7 @@ namespace Microsoft.Z3
IntPtr[] n_constr = new IntPtr[n];
for (uint i = 0; i < n; i++)
{
var constructor = c[i];
Constructor[] constructor = c[i];
Contract.Assume(Contract.ForAll(constructor, arr => arr != null), "Clousot does not support yet quantified formula on multidimensional arrays");
CheckContextMatch(constructor);
cla[i] = new ConstructorList(this, constructor);

View file

@ -433,7 +433,8 @@ namespace Microsoft.Z3
get
{
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_ARRAY_SORT);
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
== Z3_sort_kind.Z3_ARRAY_SORT);
}
}
@ -1308,7 +1309,8 @@ namespace Microsoft.Z3
get
{
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_RELATION_SORT);
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
== (uint)Z3_sort_kind.Z3_RELATION_SORT);
}
}
@ -1429,7 +1431,7 @@ namespace Microsoft.Z3
get
{
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT);
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FINITE_DOMAIN_SORT);
}
}
@ -1489,8 +1491,8 @@ namespace Microsoft.Z3
internal override void CheckNativeObject(IntPtr obj)
{
if (Native.Z3_is_app(Context.nCtx, obj) == 0 &&
(Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_VAR_AST &&
(Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST)
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_VAR_AST &&
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_QUANTIFIER_AST)
throw new Z3Exception("Underlying object is not a term");
base.CheckNativeObject(obj);
}
@ -1531,6 +1533,7 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj);
case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
case Z3_sort_kind.Z3_UNKNOWN_SORT: throw new Z3Exception("Unknown Sort");
}
}
@ -1542,6 +1545,7 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj);
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj);
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
case Z3_sort_kind.Z3_UNKNOWN_SORT: throw new Z3Exception("Unknown Sort");
}
return new Expr(ctx, obj);

View file

@ -110,7 +110,7 @@ namespace Microsoft.Z3
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
var n = DomainSize;
uint n = DomainSize;
Sort[] res = new Sort[n];
for (uint i = 0; i < n; i++)

View file

@ -184,10 +184,10 @@ namespace Microsoft.Z3
{
Tactic t = Context.MkTactic("simplify");
ApplyResult res = t.Apply(this, p);
if (res.NumSubgoals == 0)
return Context.MkGoal();
else
throw new Z3Exception("No subgoals");
else
return res.Subgoals[0];
}

View file

@ -165,8 +165,8 @@ namespace Microsoft.Z3
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
var nFuncs = NumFuncs;
var nConsts = NumConsts;
uint nFuncs = NumFuncs;
uint nConsts = NumConsts;
uint n = nFuncs + nConsts;
FuncDecl[] res = new FuncDecl[n];
for (uint i = 0; i < nConsts; i++)

View file

@ -181,8 +181,6 @@ namespace Microsoft.Z3
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,

228
src/api/java/AST.java Normal file
View file

@ -0,0 +1,228 @@
/**
* This file was automatically generated from AST.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* The abstract syntax tree (AST) class.
**/
public class AST extends Z3Object
{
/**
* Comparison operator. <param name="a">An AST</param> <param name="b">An
* AST</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
* the same context and represent the same sort; false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Comparison operator. <param name="a">An AST</param> <param name="b">An
* AST</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
* from the same context or represent different sorts; false
* otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Object comparison.
**/
public boolean Equals(Object o)
{
AST casted = (AST) o;
if (casted == null)
return false;
return this == casted;
}
/**
* Object Comparison. <param name="other">Another AST</param>
*
* @return Negative if the object should be sorted before <paramref
* name="other"/>, positive if after else zero.
**/
public int CompareTo(Object other) throws Z3Exception
{
if (other == null)
return 1;
AST oAST = (AST) other;
if (oAST == null)
return 1;
else
{
if (Id() < oAST.Id())
return -1;
else if (Id() > oAST.Id())
return +1;
else
return 0;
}
}
/**
* The AST's hash code.
*
* @return A hash code
**/
public int GetHashCode() throws Z3Exception
{
return (int) Native.getAstHash(Context().nCtx(), NativeObject());
}
/**
* A unique identifier for the AST (unique among all ASTs).
**/
public int Id() throws Z3Exception
{
return Native.getAstId(Context().nCtx(), NativeObject());
}
/**
* Translates (copies) the AST to the Context <paramref name="ctx"/>. <param
* name="ctx">A context</param>
*
* @return A copy of the AST which is associated with <paramref name="ctx"/>
**/
public AST Translate(Context ctx) throws Z3Exception
{
if (Context() == ctx)
return this;
else
return new AST(ctx, Native.translate(Context().nCtx(),
NativeObject(), ctx.nCtx()));
}
/**
* The kind of the AST.
**/
public Z3_ast_kind ASTKind()
{
return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(),
NativeObject()));
}
/**
* Indicates whether the AST is an Expr
**/
public boolean IsExpr() throws Z3Exception
{
switch (ASTKind())
{
case Z3_APP_AST:
case Z3_NUMERAL_AST:
case Z3_QUANTIFIER_AST:
case Z3_VAR_AST:
return true;
default:
return false;
}
}
/**
* Indicates whether the AST is a BoundVariable
**/
public boolean IsVar() throws Z3Exception
{
return this.ASTKind() == Z3_ast_kind.Z3_VAR_AST;
}
/**
* Indicates whether the AST is a Quantifier
**/
public boolean IsQuantifier() throws Z3Exception
{
return this.ASTKind() == Z3_ast_kind.Z3_QUANTIFIER_AST;
}
/**
* Indicates whether the AST is a Sort
**/
public boolean IsSort() throws Z3Exception
{
return this.ASTKind() == Z3_ast_kind.Z3_SORT_AST;
}
/**
* Indicates whether the AST is a FunctionDeclaration
**/
public boolean IsFuncDecl() throws Z3Exception
{
return this.ASTKind() == Z3_ast_kind.Z3_FUNC_DECL_AST;
}
/**
* A string representation of the AST.
**/
public String toString()
{
return Native.astToString(Context().nCtx(), NativeObject());
}
/**
* A string representation of the AST in s-expression notation.
**/
public String SExpr() throws Z3Exception
{
return Native.astToString(Context().nCtx(), NativeObject());
}
AST(Context ctx)
{
super(ctx);
}
AST(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
// Console.WriteLine("AST IncRef()");
if (Context() == null)
throw new Z3Exception("inc() called on null context");
if (o == 0)
throw new Z3Exception("inc() called on null AST");
Context().AST_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
// Console.WriteLine("AST DecRef()");
if (Context() == null)
throw new Z3Exception("dec() called on null context");
if (o == 0)
throw new Z3Exception("dec() called on null AST");
Context().AST_DRQ().Add(o);
super.DecRef(o);
}
static AST Create(Context ctx, long obj) throws Z3Exception
{
switch (Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)))
{
case Z3_FUNC_DECL_AST:
return new FuncDecl(ctx, obj);
case Z3_QUANTIFIER_AST:
return new Quantifier(ctx, obj);
case Z3_SORT_AST:
return Sort.Create(ctx, obj);
case Z3_APP_AST:
case Z3_NUMERAL_AST:
case Z3_VAR_AST:
return Expr.Create(ctx, obj);
default:
throw new Z3Exception("Unknown AST kind");
}
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
public class ASTDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.incRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.decRef(ctx.nCtx(), obj);
}
};

116
src/api/java/ASTMap.java Normal file
View file

@ -0,0 +1,116 @@
/**
* This file was automatically generated from ASTMap.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Map from AST to AST
**/
class ASTMap extends Z3Object
{
/**
* Checks whether the map contains the key <paramref name="k"/>. <param
* name="k">An AST</param>
*
* @return True if <paramref name="k"/> is a key in the map, false
* otherwise.
**/
public boolean Contains(AST k)
{
return Native.astMapContains(Context().nCtx(), NativeObject(),
k.NativeObject());
}
/**
* Finds the value associated with the key <paramref name="k"/>. <remarks>
* This function signs an error when <paramref name="k"/> is not a key in
* the map. </remarks> <param name="k">An AST</param>
* @throws Z3Exception
**/
public AST Find(AST k) throws Z3Exception
{
return new AST(Context(), Native.astMapFind(Context().nCtx(),
NativeObject(), k.NativeObject()));
}
/**
* Stores or replaces a new key/value pair in the map. <param name="k">The
* key AST</param> <param name="v">The value AST</param>
**/
public void Insert(AST k, AST v)
{
Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(),
v.NativeObject());
}
/**
* Erases the key <paramref name="k"/> from the map. <param name="k">An
* AST</param>
**/
public void Erase(AST k)
{
Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject());
}
/**
* Removes all keys from the map.
**/
public void Reset()
{
Native.astMapReset(Context().nCtx(), NativeObject());
}
/**
* The size of the map
**/
public int Size()
{
return Native.astMapSize(Context().nCtx(), NativeObject());
}
/**
* The keys stored in the map.
* @throws Z3Exception
**/
public ASTVector Keys() throws Z3Exception
{
return new ASTVector(Context(), Native.astMapKeys(Context().nCtx(),
NativeObject()));
}
/**
* Retrieves a string representation of the map.
**/
public String toString()
{
return Native.astMapToString(Context().nCtx(), NativeObject());
}
ASTMap(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ASTMap(Context ctx) throws Z3Exception
{
super(ctx, Native.mkAstMap(ctx.nCtx()));
}
void IncRef(long o) throws Z3Exception
{
Context().ASTMap_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().ASTMap_DRQ().Add(o);
super.DecRef(o);
}
}

104
src/api/java/ASTVector.java Normal file
View file

@ -0,0 +1,104 @@
/**
* This file was automatically generated from ASTVector.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Vectors of ASTs.
**/
class ASTVector extends Z3Object
{
/**
* The size of the vector
**/
public int Size()
{
return Native.astVectorSize(Context().nCtx(), NativeObject());
}
/**
* Retrieves the i-th object in the vector. <remarks>May throw an
* IndexOutOfBoundsException when <paramref name="i"/> is out of
* range.</remarks> <param name="i">Index</param>
*
* @return An AST
* @throws Z3Exception
**/
public AST get(int i) throws Z3Exception
{
return new AST(Context(), Native.astVectorGet(Context().nCtx(),
NativeObject(), i));
}
public void set(int i, AST value)
{
Native.astVectorSet(Context().nCtx(), NativeObject(), i,
value.NativeObject());
}
/**
* Resize the vector to <paramref name="newSize"/>. <param
* name="newSize">The new size of the vector.</param>
**/
public void Resize(int newSize)
{
Native.astVectorResize(Context().nCtx(), NativeObject(), newSize);
}
/**
* Add the AST <paramref name="a"/> to the back of the vector. The size is
* increased by 1. <param name="a">An AST</param>
**/
public void Push(AST a)
{
Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject());
}
/**
* Translates all ASTs in the vector to <paramref name="ctx"/>. <param
* name="ctx">A context</param>
*
* @return A new ASTVector
* @throws Z3Exception
**/
public ASTVector Translate(Context ctx) throws Z3Exception
{
return new ASTVector(Context(), Native.astVectorTranslate(Context()
.nCtx(), NativeObject(), ctx.nCtx()));
}
/**
* Retrieves a string representation of the vector.
**/
public String toString()
{
return Native.astVectorToString(Context().nCtx(), NativeObject());
}
ASTVector(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ASTVector(Context ctx) throws Z3Exception
{
super(ctx, Native.mkAstVector(ctx.nCtx()));
}
void IncRef(long o) throws Z3Exception
{
Context().ASTVector_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().ASTVector_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,59 @@
/**
* This file was automatically generated from AlgebraicNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Algebraic numbers
**/
public class AlgebraicNum extends ArithExpr
{
/**
* 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"/> <param name="precision">the
* precision of the result</param>
*
* @return A numeral Expr of sort Real
**/
public RatNum ToUpper(int precision) throws Z3Exception
{
return new RatNum(Context(), Native.getAlgebraicNumberUpper(Context()
.nCtx(), NativeObject(), precision));
}
/**
* 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"/> <param name="precision"></param>
*
* @return A numeral Expr of sort Real
**/
public RatNum ToLower(int precision) throws Z3Exception
{
return new RatNum(Context(), Native.getAlgebraicNumberLower(Context()
.nCtx(), NativeObject(), precision));
}
/**
* Returns a string representation in decimal notation. <remarks>The result
* has at most <paramref name="precision"/> decimal places.</remarks>
**/
public String ToDecimal(int precision) throws Z3Exception
{
return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(),
precision);
}
AlgebraicNum(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,75 @@
/**
* This file was automatically generated from ApplyResult.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* ApplyResult objects represent the result of an application of a tactic to a
* goal. It contains the subgoals that were produced.
**/
public class ApplyResult extends Z3Object
{
/**
* The number of Subgoals.
**/
public int NumSubgoals()
{
return Native.applyResultGetNumSubgoals(Context().nCtx(),
NativeObject());
}
/**
* Retrieves the subgoals from the ApplyResult.
* @throws Z3Exception
**/
public Goal[] Subgoals() throws Z3Exception
{
int n = NumSubgoals();
Goal[] res = new Goal[n];
for (int i = 0; i < n; i++)
res[i] = new Goal(Context(), Native.applyResultGetSubgoal(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* Convert a model for the subgoal <paramref name="i"/> into a model for the
* original goal <code>g</code>, that the ApplyResult was obtained from.
*
* @return A model for <code>g</code>
* @throws Z3Exception
**/
public Model ConvertModel(int i, Model m) throws Z3Exception
{
return new Model(Context(), Native.applyResultConvertModel(Context()
.nCtx(), NativeObject(), i, m.NativeObject()));
}
/**
* A string representation of the ApplyResult.
**/
public String toString()
{
return Native.applyResultToString(Context().nCtx(), NativeObject());
}
ApplyResult(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().ApplyResult_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().ApplyResult_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ApplyResultDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.applyResultIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.applyResultDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,26 @@
/**
* This file was automatically generated from ArithExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
* **/
package com.Microsoft.Z3;
/**
* Arithmetic expressions (int/real)
**/
public class ArithExpr extends Expr
{
/**
* Constructor for ArithExpr </summary>
**/
protected ArithExpr(Context ctx)
{
super(ctx);
}
ArithExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,18 @@
/**
* This file was automatically generated from ArithSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* An arithmetic sort, i.e., Int or Real.
**/
public class ArithSort extends Sort
{
ArithSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
};

View file

@ -0,0 +1,27 @@
/**
* This file was automatically generated from ArrayExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Array expressions
**/
public class ArrayExpr extends Expr
{
/**
* Constructor for ArrayExpr </summary>
**/
protected ArrayExpr(Context ctx)
{
super(ctx);
}
ArrayExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,44 @@
/**
* This file was automatically generated from ArraySort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Array sorts.
**/
public class ArraySort extends Sort
{
/**
* The domain of the array sort.
* @throws Z3Exception
**/
public Sort Domain() throws Z3Exception
{
return Sort.Create(Context(),
Native.getArraySortDomain(Context().nCtx(), NativeObject()));
}
/**
* The range of the array sort.
* @throws Z3Exception
**/
public Sort Range() throws Z3Exception
{
return Sort.Create(Context(),
Native.getArraySortRange(Context().nCtx(), NativeObject()));
}
ArraySort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ArraySort(Context ctx, Sort domain, Sort range) throws Z3Exception
{
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.NativeObject(),
range.NativeObject()));
}
};

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ASTMapDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.astMapIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.astMapDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ASTVectorDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.astVectorIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.astVectorDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,36 @@
/**
* This file was automatically generated from BitVecExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Bit-vector expressions
**/
public class BitVecExpr extends Expr
{
/**
* The size of the sort of a bit-vector term.
* @throws Z3Exception
**/
public int SortSize() throws Z3Exception
{
return ((BitVecSort) Sort()).Size();
}
/**
* Constructor for BitVecExpr </summary>
**/
protected BitVecExpr(Context ctx)
{
super(ctx);
}
BitVecExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,62 @@
/**
* This file was automatically generated from BitVecNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import java.math.BigInteger;
/**
* Bit-vector numerals
**/
public class BitVecNum extends BitVecExpr
{
/**
* Retrieve the int value.
*
* @throws Z3Exception
**/
public int Int() throws Z3Exception
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int");
return res.value;
}
/**
* Retrieve the 64-bit int value.
*
* @throws Z3Exception
**/
public long Long() throws Z3Exception
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int64");
return res.value;
}
/**
* Retrieve the BigInteger value.
**/
public BigInteger BigInteger()
{
return new BigInteger(this.toString());
}
/**
* Returns a string representation of the numeral.
**/
public String toString()
{
return Native.getNumeralString(Context().nCtx(), NativeObject());
}
BitVecNum(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,25 @@
/**
* This file was automatically generated from BitVecSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Bit-vector sorts.
**/
public class BitVecSort extends Sort
{
/**
* The size of the bit-vector sort.
**/
public int Size()
{
return Native.getBvSortSize(Context().nCtx(), NativeObject());
}
BitVecSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
};

View file

@ -0,0 +1,30 @@
/**
* This file was automatically generated from BoolExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Boolean expressions
**/
public class BoolExpr extends Expr
{
/**
* Constructor for BoolExpr </summary>
**/
protected BoolExpr(Context ctx)
{
super(ctx);
}
/**
* Constructor for BoolExpr </summary>
* @throws Z3Exception
**/
BoolExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,16 @@
/**
* This file was automatically generated from BoolSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* A Boolean sort.
**/
public class BoolSort extends Sort
{
BoolSort(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }}
BoolSort(Context ctx) throws Z3Exception { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
};

View file

@ -0,0 +1,107 @@
/**
* This file was automatically generated from Constructor.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Constructors are used for datatype sorts.
**/
public class Constructor extends Z3Object
{
/**
* The number of fields of the constructor.
* @throws Z3Exception
**/
public int NumFields() throws Z3Exception
{
init();
return n;
}
/**
* The function declaration of the constructor.
* @throws Z3Exception
**/
public FuncDecl ConstructorDecl() throws Z3Exception
{
init();
return m_constructorDecl;
}
/**
* The function declaration of the tester.
* @throws Z3Exception
**/
public FuncDecl TesterDecl() throws Z3Exception
{
init();
return m_testerDecl;
}
/**
* The function declarations of the accessors
* @throws Z3Exception
**/
public FuncDecl[] AccessorDecls() throws Z3Exception
{
init();
return m_accessorDecls;
}
/**
* Destructor.
**/
protected void finalize()
{
Native.delConstructor(Context().nCtx(), NativeObject());
}
private int n = 0;
private FuncDecl m_testerDecl = null;
private FuncDecl m_constructorDecl = null;
private FuncDecl[] m_accessorDecls = null;
Constructor(Context ctx, Symbol name, Symbol recognizer,
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
throws Z3Exception
{
super(ctx);
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 int[n];
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.NativeObject(),
recognizer.NativeObject(), n, Symbol.ArrayToNative(fieldNames),
Sort.ArrayToNative(sorts), sortRefs));
}
private void init() throws Z3Exception
{
if (m_testerDecl != null)
return;
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(Context().nCtx(), NativeObject(), n,
constructor, tester, accessors);
m_constructorDecl = new FuncDecl(Context(), constructor.value);
m_testerDecl = new FuncDecl(Context(), tester.value);
m_accessorDecls = new FuncDecl[n];
for (int i = 0; i < n; i++)
m_accessorDecls[i] = new FuncDecl(Context(), accessors[i]);
}
}

View file

@ -0,0 +1,35 @@
/**
* This file was automatically generated from ConstructorList.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Lists of constructors
**/
public class ConstructorList extends Z3Object
{
/**
* Destructor.
**/
protected void finalize()
{
Native.delConstructorList(Context().nCtx(), NativeObject());
}
ConstructorList(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ConstructorList(Context ctx, Constructor[] constructors) throws Z3Exception
{
super(ctx);
setNativeObject(Native.mkConstructorList(Context().nCtx(),
(int) constructors.length,
Constructor.ArrayToNative(constructors)));
}
}

3112
src/api/java/Context.java Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/**
* This file was automatically generated from DatatypeExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Datatype expressions
**/
public class DatatypeExpr extends Expr
{
/**
* Constructor for DatatypeExpr </summary>
**/
protected DatatypeExpr(Context ctx)
{
super(ctx);
}
DatatypeExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,91 @@
/**
* This file was automatically generated from DatatypeSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Datatype sorts.
**/
public class DatatypeSort extends Sort
{
/**
* The number of constructors of the datatype sort.
**/
public int NumConstructors()
{
return Native.getDatatypeSortNumConstructors(Context().nCtx(),
NativeObject());
}
/**
* The constructors.
*
* @throws Z3Exception
**/
public FuncDecl[] Constructors() throws Z3Exception
{
int n = NumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(Context(), Native.getDatatypeSortConstructor(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The recognizers.
*
* @throws Z3Exception
**/
public FuncDecl[] Recognizers() throws Z3Exception
{
int n = NumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(Context(), Native.getDatatypeSortRecognizer(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The constructor accessors.
*
* @throws Z3Exception
**/
public FuncDecl[][] Accessors() throws Z3Exception
{
int n = NumConstructors();
FuncDecl[][] res = new FuncDecl[n][];
for (int i = 0; i < n; i++)
{
FuncDecl fd = new FuncDecl(Context(),
Native.getDatatypeSortConstructor(Context().nCtx(),
NativeObject(), i));
int ds = fd.DomainSize();
FuncDecl[] tmp = new FuncDecl[ds];
for (int j = 0; j < ds; j++)
tmp[j] = new FuncDecl(Context(),
Native.getDatatypeSortConstructorAccessor(Context()
.nCtx(), NativeObject(), i, j));
res[i] = tmp;
}
return res;
}
DatatypeSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
throws Z3Exception
{
super(ctx, Native.mkDatatype(ctx.nCtx(), name.NativeObject(),
(int) constructors.length, ArrayToNative(constructors)));
}
};

View file

@ -0,0 +1,64 @@
/**
* This file was automatically generated from EnumSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Enumeration sorts.
**/
public class EnumSort extends Sort
{
/**
* The function declarations of the constants in the enumeration.
**/
public FuncDecl[] ConstDecls()
{
return _constdecls;
}
/**
* The constants in the enumeration.
**/
public Expr[] Consts()
{
return _consts;
}
/**
* The test predicates for the constants in the enumeration.
**/
public FuncDecl[] TesterDecls()
{
return _testerdecls;
}
private FuncDecl[] _constdecls = null, _testerdecls = null;
private Expr[] _consts = null;
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
{
super(ctx);
int n = enumNames.length;
long[] n_constdecls = new long[n];
long[] n_testers = new long[n];
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
name.NativeObject(), (int) n, Symbol.ArrayToNative(enumNames),
n_constdecls, n_testers));
_constdecls = new FuncDecl[n];
for (int i = 0; i < n; i++)
_constdecls[i] = new FuncDecl(ctx, n_constdecls[i]);
_testerdecls = new FuncDecl[n];
for (int i = 0; i < n; i++)
_testerdecls[i] = new FuncDecl(ctx, n_testers[i]);
_consts = new Expr[n];
for (int i = 0; i < n; i++)
_consts[i] = ctx.MkApp(_constdecls[i], null);
}
};

View file

@ -0,0 +1,33 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_ast_kind
**/
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);
private final int intValue;
Z3_ast_kind(int v) {
this.intValue = v;
}
public static final Z3_ast_kind fromInt(int v) {
for (Z3_ast_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,30 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_ast_print_mode
**/
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);
private final int intValue;
Z3_ast_print_mode(int v) {
this.intValue = v;
}
public static final Z3_ast_print_mode fromInt(int v) {
for (Z3_ast_print_mode k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,178 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_decl_kind
**/
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);
private final int intValue;
Z3_decl_kind(int v) {
this.intValue = v;
}
public static final Z3_decl_kind fromInt(int v) {
for (Z3_decl_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,39 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_error_code
**/
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);
private final int intValue;
Z3_error_code(int v) {
this.intValue = v;
}
public static final Z3_error_code fromInt(int v) {
for (Z3_error_code k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,30 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_goal_prec
**/
public enum Z3_goal_prec {
Z3_GOAL_UNDER (1),
Z3_GOAL_PRECISE (0),
Z3_GOAL_UNDER_OVER (3),
Z3_GOAL_OVER (2);
private final int intValue;
Z3_goal_prec(int v) {
this.intValue = v;
}
public static final Z3_goal_prec fromInt(int v) {
for (Z3_goal_prec k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,29 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_lbool
**/
public enum Z3_lbool {
Z3_L_TRUE (1),
Z3_L_UNDEF (0),
Z3_L_FALSE (-1);
private final int intValue;
Z3_lbool(int v) {
this.intValue = v;
}
public static final Z3_lbool fromInt(int v) {
for (Z3_lbool k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,33 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_param_kind
**/
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);
private final int intValue;
Z3_param_kind(int v) {
this.intValue = v;
}
public static final Z3_param_kind fromInt(int v) {
for (Z3_param_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,33 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_parameter_kind
**/
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);
private final int intValue;
Z3_parameter_kind(int v) {
this.intValue = v;
}
public static final Z3_parameter_kind fromInt(int v) {
for (Z3_parameter_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,36 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_sort_kind
**/
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);
private final int intValue;
Z3_sort_kind(int v) {
this.intValue = v;
}
public static final Z3_sort_kind fromInt(int v) {
for (Z3_sort_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

View file

@ -0,0 +1,28 @@
/**
* Automatically generated file
**/
package com.Microsoft.Z3.Enumerations;
/**
* Z3_symbol_kind
**/
public enum Z3_symbol_kind {
Z3_INT_SYMBOL (0),
Z3_STRING_SYMBOL (1);
private final int intValue;
Z3_symbol_kind(int v) {
this.intValue = v;
}
public static final Z3_symbol_kind fromInt(int v) {
for (Z3_symbol_kind k: values())
if (k.intValue == v) return k;
return values()[0];
}
public final int toInt() { return this.intValue; }
}

1807
src/api/java/Expr.java Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
/**
* This file was automatically generated from FiniteDomainSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Finite domain sorts.
**/
public class FiniteDomainSort extends Sort
{
/**
* The size of the finite domain sort.
**/
public long Size()
{
Native.LongPtr res = new Native.LongPtr();
Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res);
return res.value;
}
FiniteDomainSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
FiniteDomainSort(Context ctx, Symbol name, long size) throws Z3Exception
{
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.NativeObject(),
size));
}
}

View file

@ -0,0 +1,327 @@
/**
* This file was automatically generated from Fixedpoint.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Object for managing fixedpoints
**/
public class Fixedpoint extends Z3Object
{
/**
* A string that describes all available fixedpoint solver parameters.
**/
public String Help()
{
return Native.fixedpointGetHelp(Context().nCtx(), NativeObject());
}
/**
* Sets the fixedpoint solver parameters.
*
* @throws Z3Exception
**/
public void setParameters(Params value) throws Z3Exception
{
Context().CheckContextMatch(value);
Native.fixedpointSetParams(Context().nCtx(), NativeObject(),
value.NativeObject());
}
/**
* Retrieves parameter descriptions for Fixedpoint solver.
* @throws Z3Exception
**/
public ParamDescrs ParameterDescriptions() throws Z3Exception
{
return new ParamDescrs(Context(), Native.fixedpointGetParamDescrs(
Context().nCtx(), NativeObject()));
}
/**
* Assert a constraint (or multiple) into the fixedpoint solver.
*
* @throws Z3Exception
**/
public void Assert(BoolExpr[] constraints) throws Z3Exception
{
Context().CheckContextMatch(constraints);
for (BoolExpr a : constraints)
{
Native.fixedpointAssert(Context().nCtx(), NativeObject(),
a.NativeObject());
}
}
/**
* Register predicate as recursive relation.
*
* @throws Z3Exception
**/
public void RegisterRelation(FuncDecl f) throws Z3Exception
{
Context().CheckContextMatch(f);
Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(),
f.NativeObject());
}
/**
* Add rule into the fixedpoint solver.
*
* @throws Z3Exception
**/
public void AddRule(BoolExpr rule, Symbol name) throws Z3Exception
{
Context().CheckContextMatch(rule);
Native.fixedpointAddRule(Context().nCtx(), NativeObject(),
rule.NativeObject(), AST.GetNativeObject(name));
}
/**
* Add table fact to the fixedpoint solver.
*
* @throws Z3Exception
**/
public void AddFact(FuncDecl pred, int[] args) throws Z3Exception
{
Context().CheckContextMatch(pred);
Native.fixedpointAddFact(Context().nCtx(), NativeObject(),
pred.NativeObject(), (int) args.length, args);
}
/**
* 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.
*
* @throws Z3Exception
**/
public Status Query(BoolExpr query) throws Z3Exception
{
Context().CheckContextMatch(query);
Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQuery(Context().nCtx(),
NativeObject(), query.NativeObject()));
switch (r)
{
case Z3_L_TRUE:
return Status.SATISFIABLE;
case Z3_L_FALSE:
return Status.UNSATISFIABLE;
default:
return Status.UNKNOWN;
}
}
/**
* 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.
*
* @throws Z3Exception
**/
public Status Query(FuncDecl[] relations) throws Z3Exception
{
Context().CheckContextMatch(relations);
Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQueryRelations(Context()
.nCtx(), NativeObject(), AST.ArrayLength(relations), AST
.ArrayToNative(relations)));
switch (r)
{
case Z3_L_TRUE:
return Status.SATISFIABLE;
case Z3_L_FALSE:
return Status.UNSATISFIABLE;
default:
return Status.UNKNOWN;
}
}
/**
* Creates a backtracking point. <seealso cref="Pop"/>
**/
public void Push()
{
Native.fixedpointPush(Context().nCtx(), NativeObject());
}
/**
* Backtrack one backtracking point. <remarks>Note that an exception is
* thrown if Pop is called without a corresponding <code>Push</code>
* </remarks> <seealso cref="Push"/>
**/
public void Pop()
{
Native.fixedpointPop(Context().nCtx(), NativeObject());
}
/**
* Update named rule into in the fixedpoint solver.
*
* @throws Z3Exception
**/
public void UpdateRule(BoolExpr rule, Symbol name) throws Z3Exception
{
Context().CheckContextMatch(rule);
Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(),
rule.NativeObject(), AST.GetNativeObject(name));
}
/**
* Retrieve satisfying instance or instances of solver, or definitions for
* the recursive predicates that show unsatisfiability.
*
* @throws Z3Exception
**/
public Expr GetAnswer() throws Z3Exception
{
long ans = Native.fixedpointGetAnswer(Context().nCtx(), NativeObject());
return (ans == 0) ? null : Expr.Create(Context(), ans);
}
/**
* Retrieve explanation why fixedpoint engine returned status Unknown.
**/
public String GetReasonUnknown()
{
return Native.fixedpointGetReasonUnknown(Context().nCtx(),
NativeObject());
}
/**
* Retrieve the number of levels explored for a given predicate.
**/
public int GetNumLevels(FuncDecl predicate)
{
return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(),
predicate.NativeObject());
}
/**
* Retrieve the cover of a predicate.
*
* @throws Z3Exception
**/
public Expr GetCoverDelta(int level, FuncDecl predicate) throws Z3Exception
{
long res = Native.fixedpointGetCoverDelta(Context().nCtx(),
NativeObject(), level, predicate.NativeObject());
return (res == 0) ? null : Expr.Create(Context(), res);
}
/**
* Add <tt>property</tt> about the <tt>predicate</tt>. The property is added
* at <tt>level</tt>.
**/
public void AddCover(int level, FuncDecl predicate, Expr property)
{
Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level,
predicate.NativeObject(), property.NativeObject());
}
/**
* Retrieve internal string representation of fixedpoint object.
**/
public String toString()
{
return Native.fixedpointToString(Context().nCtx(), NativeObject(), 0,
null);
}
/**
* Instrument the Datalog engine on which table representation to use for
* recursive predicate.
**/
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds)
{
Native.fixedpointSetPredicateRepresentation(Context().nCtx(),
NativeObject(), f.NativeObject(), AST.ArrayLength(kinds),
Symbol.ArrayToNative(kinds));
}
/**
* Convert benchmark given as set of axioms, rules and queries to a string.
**/
public String toString(BoolExpr[] queries)
{
return Native.fixedpointToString(Context().nCtx(), NativeObject(),
AST.ArrayLength(queries), AST.ArrayToNative(queries));
}
/**
* Retrieve set of rules added to fixedpoint context.
*
* @throws Z3Exception
**/
public BoolExpr[] Rules() throws Z3Exception
{
ASTVector v = new ASTVector(Context(), Native.fixedpointGetRules(
Context().nCtx(), NativeObject()));
int n = v.Size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(Context(), v.get(i).NativeObject());
return res;
}
/**
* Retrieve set of assertions added to fixedpoint context.
*
* @throws Z3Exception
**/
public BoolExpr[] Assertions() throws Z3Exception
{
ASTVector v = new ASTVector(Context(), Native.fixedpointGetAssertions(
Context().nCtx(), NativeObject()));
int n = v.Size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(Context(), v.get(i).NativeObject());
return res;
}
Fixedpoint(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Fixedpoint(Context ctx) throws Z3Exception
{
super(ctx, Native.mkFixedpoint(ctx.nCtx()));
}
void IncRef(long o) throws Z3Exception
{
Context().Fixedpoint_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Fixedpoint_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class FixedpointDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.fixedpointIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.fixedpointDecRef(ctx.nCtx(), obj);
}
};

379
src/api/java/FuncDecl.java Normal file
View file

@ -0,0 +1,379 @@
/**
* This file was automatically generated from FuncDecl.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Function declarations.
**/
public class FuncDecl extends AST
{
/**
* Comparison operator.
*
* @return True if <paramref name="a"/> and <paramref name="b"/> share the
* same context and are equal, false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Comparison operator.
*
* @return True if <paramref name="a"/> and <paramref name="b"/> do not
* share the same context or are not equal, false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Object comparison.
**/
public boolean Equals(Object o)
{
FuncDecl casted = (FuncDecl) o;
if (casted == null)
return false;
return this == casted;
}
/**
* A hash code.
**/
public int GetHashCode() throws Z3Exception
{
return super.GetHashCode();
}
/**
* A string representations of the function declaration.
**/
public String toString()
{
return Native.funcDeclToString(Context().nCtx(), NativeObject());
}
/**
* Returns a unique identifier for the function declaration.
**/
public int Id() throws Z3Exception
{
return Native.getFuncDeclId(Context().nCtx(), NativeObject());
}
/**
* The arity of the function declaration
**/
public int Arity() throws Z3Exception
{
return Native.getArity(Context().nCtx(), NativeObject());
}
/**
* The size of the domain of the function declaration <seealso
* cref="Arity"/>
**/
public int DomainSize()
{
return Native.getDomainSize(Context().nCtx(), NativeObject());
}
/**
* The domain of the function declaration
**/
public Sort[] Domain() throws Z3Exception
{
int n = DomainSize();
Sort[] res = new Sort[n];
for (int i = 0; i < n; i++)
res[i] = Sort.Create(Context(),
Native.getDomain(Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The range of the function declaration
**/
public Sort Range() throws Z3Exception
{
return Sort.Create(Context(),
Native.getRange(Context().nCtx(), NativeObject()));
}
/**
* The kind of the function declaration.
**/
public Z3_decl_kind DeclKind() throws Z3Exception
{
return Z3_decl_kind.fromInt(Native.getDeclKind(Context().nCtx(),
NativeObject()));
}
/**
* The name of the function declaration
**/
public Symbol Name() throws Z3Exception
{
return Symbol.Create(Context(),
Native.getDeclName(Context().nCtx(), NativeObject()));
}
/**
* The number of parameters of the function declaration
**/
public int NumParameters() throws Z3Exception
{
return Native.getDeclNumParameters(Context().nCtx(), NativeObject());
}
/**
* The parameters of the function declaration
**/
public Parameter[] Parameters() throws Z3Exception
{
int num = NumParameters();
Parameter[] res = new Parameter[num];
for (int i = 0; i < num; i++)
{
Z3_parameter_kind k = Z3_parameter_kind.fromInt(Native
.getDeclParameterKind(Context().nCtx(), NativeObject(), i));
switch (k)
{
case Z3_PARAMETER_INT:
res[i] = new Parameter(k, Native.getDeclIntParameter(Context()
.nCtx(), NativeObject(), i));
break;
case Z3_PARAMETER_DOUBLE:
res[i] = new Parameter(k, Native.getDeclDoubleParameter(
Context().nCtx(), NativeObject(), i));
break;
case Z3_PARAMETER_SYMBOL:
res[i] = new Parameter(k, Symbol.Create(Context(), Native
.getDeclSymbolParameter(Context().nCtx(),
NativeObject(), i)));
break;
case Z3_PARAMETER_SORT:
res[i] = new Parameter(k, Sort.Create(Context(), Native
.getDeclSortParameter(Context().nCtx(), NativeObject(),
i)));
break;
case Z3_PARAMETER_AST:
res[i] = new Parameter(k, new AST(Context(),
Native.getDeclAstParameter(Context().nCtx(),
NativeObject(), i)));
break;
case Z3_PARAMETER_FUNC_DECL:
res[i] = new Parameter(k, new FuncDecl(Context(),
Native.getDeclFuncDeclParameter(Context().nCtx(),
NativeObject(), i)));
break;
case Z3_PARAMETER_RATIONAL:
res[i] = new Parameter(k, Native.getDeclRationalParameter(
Context().nCtx(), NativeObject(), i));
break;
default:
throw new Z3Exception(
"Unknown function declaration parameter kind encountered");
}
}
return res;
}
/**
* Function declarations can have Parameters associated with them.
**/
public class Parameter
{
private Z3_parameter_kind kind;
private int i;
private double d;
private Symbol sym;
private Sort srt;
private AST ast;
private FuncDecl fd;
private String r;
/**
* The int value of the parameter.</summary>
**/
public int Int() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_INT)
throw new Z3Exception("parameter is not an int");
return i;
}
/**
* The double value of the parameter.</summary>
**/
public double Double() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_DOUBLE)
throw new Z3Exception("parameter is not a double ");
return d;
}
/**
* The Symbol value of the parameter.</summary>
**/
public Symbol Symbol() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SYMBOL)
throw new Z3Exception("parameter is not a Symbol");
return sym;
}
/**
* The Sort value of the parameter.</summary>
**/
public Sort Sort() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SORT)
throw new Z3Exception("parameter is not a Sort");
return srt;
}
/**
* The AST value of the parameter.</summary>
**/
public AST AST() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_AST)
throw new Z3Exception("parameter is not an AST");
return ast;
}
/**
* The FunctionDeclaration value of the parameter.</summary>
**/
public FuncDecl FuncDecl() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL)
throw new Z3Exception("parameter is not a function declaration");
return fd;
}
/**
* The rational string value of the parameter.</summary>
**/
public String Rational() throws Z3Exception
{
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_RATIONAL)
throw new Z3Exception("parameter is not a rational String");
return r;
}
/**
* The kind of the parameter.
**/
public Z3_parameter_kind ParameterKind() throws Z3Exception
{
return kind;
}
Parameter(Z3_parameter_kind k, int i)
{
this.kind = k;
this.i = i;
}
Parameter(Z3_parameter_kind k, double d)
{
this.kind = k;
this.d = d;
}
Parameter(Z3_parameter_kind k, Symbol s)
{
this.kind = k;
this.sym = s;
}
Parameter(Z3_parameter_kind k, Sort s)
{
this.kind = k;
this.srt = s;
}
Parameter(Z3_parameter_kind k, AST a)
{
this.kind = k;
this.ast = a;
}
Parameter(Z3_parameter_kind k, FuncDecl fd)
{
this.kind = k;
this.fd = fd;
}
Parameter(Z3_parameter_kind k, String r)
{
this.kind = k;
this.r = r;
}
}
FuncDecl(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
throws Z3Exception
{
super(ctx, Native.mkFuncDecl(ctx.nCtx(), name.NativeObject(),
AST.ArrayLength(domain), AST.ArrayToNative(domain),
range.NativeObject()));
}
FuncDecl(Context ctx, String prefix, Sort[] domain, Sort range)
throws Z3Exception
{
super(ctx, Native.mkFreshFuncDecl(ctx.nCtx(), prefix,
AST.ArrayLength(domain), AST.ArrayToNative(domain),
range.NativeObject()));
}
void CheckNativeObject(long obj) throws Z3Exception
{
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_FUNC_DECL_AST
.toInt())
throw new Z3Exception(
"Underlying object is not a function declaration");
super.CheckNativeObject(obj);
}
/**
* Create expression that applies function to arguments. <param
* name="args"></param>
*
* @return
**/
/* operator this[] not translated */
/**
* Create expression that applies function to arguments. <param
* name="args"></param>
*
* @return
**/
public Expr Apply(Expr[] args) throws Z3Exception
{
Context().CheckContextMatch(args);
return Expr.Create(Context(), this, args);
}
}

View file

@ -0,0 +1,185 @@
/**
* This file was automatically generated from FuncInterp.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* 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.
**/
public class FuncInterp extends Z3Object
{
/**
* An Entry object represents an element in the finite map used to encode a
* function interpretation.
**/
public class Entry extends Z3Object
{
/**
* Return the (symbolic) value of this entry.
*
* @throws Z3Exception
**/
public Expr Value() throws Z3Exception
{
return Expr.Create(Context(),
Native.funcEntryGetValue(Context().nCtx(), NativeObject()));
}
/**
* The number of arguments of the entry.
**/
public int NumArgs()
{
return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject());
}
/**
* The arguments of the function entry.
*
* @throws Z3Exception
**/
public Expr[] Args() throws Z3Exception
{
int n = NumArgs();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.Create(Context(), Native.funcEntryGetArg(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* A string representation of the function entry.
**/
public String toString()
{
try
{
int n = NumArgs();
String res = "[";
Expr[] args = Args();
for (int i = 0; i < n; i++)
res += args[i] + ", ";
return res + Value() + "]";
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
Entry(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().FuncEntry_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().FuncEntry_DRQ().Add(o);
super.DecRef(o);
}
};
/**
* The number of entries in the function interpretation.
**/
public int NumEntries()
{
return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject());
}
/**
* The entries in the function interpretation
*
* @throws Z3Exception
**/
public Entry[] Entries() throws Z3Exception
{
int n = NumEntries();
Entry[] res = new Entry[n];
for (int i = 0; i < n; i++)
res[i] = new Entry(Context(), Native.funcInterpGetEntry(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* The (symbolic) `else' value of the function interpretation.
*
* @throws Z3Exception
**/
public Expr Else() throws Z3Exception
{
return Expr.Create(Context(),
Native.funcInterpGetElse(Context().nCtx(), NativeObject()));
}
/**
* The arity of the function interpretation
**/
public int Arity()
{
return Native.funcInterpGetArity(Context().nCtx(), NativeObject());
}
/**
* A string representation of the function interpretation.
**/
public String toString()
{
try
{
String res = "";
res += "[";
for (Entry e : Entries())
{
int n = e.NumArgs();
if (n > 1)
res += "[";
Expr[] args = e.Args();
for (int 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;
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
FuncInterp(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().FuncInterp_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().FuncInterp_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class FuncInterpDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.funcInterpIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.funcInterpDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class FuncInterpEntryDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.funcEntryIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.funcEntryDecRef(ctx.nCtx(), obj);
}
};

211
src/api/java/Goal.java Normal file
View file

@ -0,0 +1,211 @@
/**
* This file was automatically generated from Goal.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* A goal (aka problem). A goal is essentially a set of formulas, that can be
* solved and/or transformed using tactics and solvers.
**/
public class Goal extends Z3Object
{
/**
* The precision of the goal. <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()
{
return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(),
NativeObject()));
}
/**
* Indicates whether the goal is precise.
**/
public boolean IsPrecise()
{
return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE;
}
/**
* Indicates whether the goal is an under-approximation.
**/
public boolean IsUnderApproximation()
{
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER;
}
/**
* Indicates whether the goal is an over-approximation.
**/
public boolean IsOverApproximation()
{
return Precision() == Z3_goal_prec.Z3_GOAL_OVER;
}
/**
* Indicates whether the goal is garbage (i.e., the product of over- and
* under-approximations).
**/
public boolean IsGarbage()
{
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
}
/**
* Adds the <paramref name="constraints"/> to the given goal.
* @throws Z3Exception
**/
public void Assert(BoolExpr[] constraints) throws Z3Exception
{
Context().CheckContextMatch(constraints);
for (BoolExpr c : constraints)
{
// It was an assume, now made an assert just to be sure we do not
// regress
Native.goalAssert(Context().nCtx(), NativeObject(),
c.NativeObject());
}
}
/**
* Indicates whether the goal contains `false'.
**/
public boolean Inconsistent()
{
return Native.goalInconsistent(Context().nCtx(), NativeObject());
}
/**
* The depth of the goal. <remarks> This tracks how many transformations
* were applied to it. </remarks>
**/
public int Depth()
{
return Native.goalDepth(Context().nCtx(), NativeObject());
}
/**
* Erases all formulas from the given goal.
**/
public void Reset()
{
Native.goalReset(Context().nCtx(), NativeObject());
}
/**
* The number of formulas in the goal.
**/
public int Size()
{
return Native.goalSize(Context().nCtx(), NativeObject());
}
/**
* The formulas in the goal.
* @throws Z3Exception
**/
public BoolExpr[] Formulas() throws Z3Exception
{
int n = Size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(Context(), Native.goalFormula(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* The number of formulas, subformulas and terms in the goal.
**/
public int NumExprs()
{
return Native.goalNumExprs(Context().nCtx(), NativeObject());
}
/**
* Indicates whether the goal is empty, and it is precise or the product of
* an under approximation.
**/
public boolean IsDecidedSat()
{
return Native.goalIsDecidedSat(Context().nCtx(), NativeObject());
}
/**
* Indicates whether the goal contains `false', and it is precise or the
* product of an over approximation.
**/
public boolean IsDecidedUnsat()
{
return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject());
}
/**
* Translates (copies) the Goal to the target Context <paramref
* name="ctx"/>.
* @throws Z3Exception
**/
public Goal Translate(Context ctx) throws Z3Exception
{
return new Goal(ctx, Native.goalTranslate(Context().nCtx(),
NativeObject(), ctx.nCtx()));
}
/**
* Simplifies the goal. <remarks>Essentially invokes the `simplify' tactic
* on the goal.</remarks>
**/
public Goal Simplify(Params p) throws Z3Exception
{
Tactic t = Context().MkTactic("simplify");
ApplyResult res = t.Apply(this, p);
if (res.NumSubgoals() == 0)
throw new Z3Exception("No subgoals");
else
return res.Subgoals()[0];
}
/**
* Goal to string conversion.
*
* @return A string representation of the Goal.
**/
public String toString()
{
return Native.goalToString(Context().nCtx(), NativeObject());
}
Goal(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) throws Z3Exception
{
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
(unsatCores) ? true : false, (proofs) ? true : false));
}
void IncRef(long o) throws Z3Exception
{
Context().Goal_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Goal_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class GoalDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.goalIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.goalDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,48 @@
/**
* This file was automatically generated from IDecRefQueue.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import java.util.*;
abstract class IDecRefQueue
{
protected Object m_lock = new Object();
protected LinkedList<Long> m_queue = new LinkedList<Long>();
final int m_move_limit = 1024;
public abstract void IncRef(Context ctx, long obj);
public abstract void DecRef(Context ctx, long obj);
public void IncAndClear(Context ctx, long o)
{
IncRef(ctx, o);
if (m_queue.size() >= m_move_limit)
Clear(ctx);
}
public void Add(long o)
{
if (o == 0)
return;
synchronized (m_lock)
{
m_queue.add(o);
}
}
public void Clear(Context ctx)
{
synchronized (m_lock)
{
for (Long o : m_queue)
DecRef(ctx, o);
m_queue.clear();
}
}
}

View file

@ -21,5 +21,7 @@ package com.Microsoft.Z3;
public class IDisposable
{
public void Dispose() {}
public void Dispose() throws Z3Exception
{
}
}

26
src/api/java/IntExpr.java Normal file
View file

@ -0,0 +1,26 @@
/**
* This file was automatically generated from IntExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Int expressions
**/
public class IntExpr extends ArithExpr
{
/**
* Constructor for IntExpr </summary>
**/
protected IntExpr(Context ctx) throws Z3Exception
{
super(ctx);
}
IntExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

59
src/api/java/IntNum.java Normal file
View file

@ -0,0 +1,59 @@
/**
* This file was automatically generated from IntNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import java.math.BigInteger;
/**
* Integer Numerals
**/
public class IntNum extends IntExpr
{
IntNum(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Retrieve the int value.
**/
public int Int() throws Z3Exception
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int");
return res.value;
}
/**
* Retrieve the 64-bit int value.
**/
public long Int64() throws Z3Exception
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int64");
return res.value;
}
/**
* Retrieve the BigInteger value.
**/
public BigInteger BigInteger() throws Z3Exception
{
return new BigInteger(this.toString());
}
/**
* Returns a string representation of the numeral.
**/
public String toString()
{
return Native.getNumeralString(Context().nCtx(), NativeObject());
}
}

23
src/api/java/IntSort.java Normal file
View file

@ -0,0 +1,23 @@
/**
* This file was automatically generated from IntSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* An Integer sort
**/
public class IntSort extends ArithSort
{
IntSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
IntSort(Context ctx) throws Z3Exception
{
super(ctx, Native.mkIntSort(ctx.nCtx()));
}
}

View file

@ -0,0 +1,44 @@
/**
* This file was automatically generated from IntSymbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Numbered symbols
**/
public class IntSymbol extends Symbol
{
/**
* The int value of the symbol. <remarks>Throws an exception if the symbol
* is not of int kind. </remarks>
**/
public int Int() throws Z3Exception
{
if (!IsIntSymbol())
throw new Z3Exception("Int requested from non-Int symbol");
return Native.getSymbolInt(Context().nCtx(), NativeObject());
}
IntSymbol(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
IntSymbol(Context ctx, int i) throws Z3Exception
{
super(ctx, Native.mkIntSymbol(ctx.nCtx(), i));
}
void CheckNativeObject(long obj) throws Z3Exception
{
if (Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_INT_SYMBOL
.toInt())
throw new Z3Exception("Symbol is not of integer kind");
super.CheckNativeObject(obj);
}
}

101
src/api/java/ListSort.java Normal file
View file

@ -0,0 +1,101 @@
/**
* This file was automatically generated from ListSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* List sorts.
**/
public class ListSort extends Sort
{
/**
* The declaration of the nil function of this list sort.
**/
public FuncDecl NilDecl()
{
return nilDecl;
}
/**
* The empty list.
**/
public Expr Nil()
{
return nilConst;
}
/**
* The declaration of the isNil function of this list sort.
**/
public FuncDecl IsNilDecl()
{
return isNilDecl;
}
/**
* The declaration of the cons function of this list sort.
**/
public FuncDecl ConsDecl()
{
return consDecl;
}
/**
* The declaration of the isCons function of this list sort.
*
**/
public FuncDecl IsConsDecl()
{
return isConsDecl;
}
/**
* The declaration of the head function of this list sort.
**/
public FuncDecl HeadDecl()
{
return headDecl;
}
/**
* The declaration of the tail function of this list sort.
**/
public FuncDecl TailDecl()
{
return tailDecl;
}
private FuncDecl nilDecl, isNilDecl, consDecl, isConsDecl, headDecl,
tailDecl;
private Expr nilConst;
ListSort(Context ctx, Symbol name, Sort elemSort) throws Z3Exception
{
super(ctx);
Native.LongPtr inil = new Native.LongPtr(), iisnil = new Native.LongPtr();
Native.LongPtr icons = new Native.LongPtr(), iiscons = new Native.LongPtr();
Native.LongPtr ihead = new Native.LongPtr(), itail = new Native.LongPtr();
setNativeObject(Native.mkListSort(ctx.nCtx(), name.NativeObject(),
elemSort.NativeObject(), inil, iisnil, icons, iiscons, ihead,
itail));
nilDecl = new FuncDecl(ctx, inil.value);
isNilDecl = new FuncDecl(ctx, iisnil.value);
consDecl = new FuncDecl(ctx, icons.value);
isConsDecl = new FuncDecl(ctx, iiscons.value);
headDecl = new FuncDecl(ctx, ihead.value);
tailDecl = new FuncDecl(ctx, itail.value);
nilConst = ctx.MkConst(nilDecl);
}
};

60
src/api/java/Log.java Normal file
View file

@ -0,0 +1,60 @@
/**
* This file was automatically generated from Log.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Interaction logging for Z3. <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>
**/
public final class Log
{
private boolean m_is_open = false;
/**
* Open an interaction log file. <param name="filename">the name of the file
* to open</param>
*
* @return True if opening the log file succeeds, false otherwise.
**/
public boolean Open(String filename)
{
m_is_open = true;
return Native.openLog(filename) == 1;
}
/**
* Closes the interaction log.
**/
public void Close()
{
m_is_open = false;
Native.closeLog();
}
/**
* Appends the user-provided string <paramref name="s"/> to the interaction
* log.
* @throws Z3Exception
**/
public void Append(String s) throws Z3Exception
{
if (!m_is_open)
throw new Z3Exception("Log cannot be closed.");
Native.appendLog(s);
}
/**
* Checks whether the interaction log is opened.
*
* @return True if the interaction log is open, false otherwise.
**/
public boolean isOpen()
{
return m_is_open;
}
}

291
src/api/java/Model.java Normal file
View file

@ -0,0 +1,291 @@
/**
* This file was automatically generated from Model.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* A Model contains interpretations (assignments) of constants and functions.
**/
public class Model extends Z3Object
{
/**
* Retrieves the interpretation (the assignment) of <paramref name="a"/> in
* the model. <param name="a">A Constant</param>
*
* @return An expression if the constant has an interpretation in the model,
* null otherwise.
* @throws Z3Exception
**/
public Expr ConstInterp(Expr a) throws Z3Exception
{
Context().CheckContextMatch(a);
return ConstInterp(a.FuncDecl());
}
/**
* Retrieves the interpretation (the assignment) of <paramref name="f"/> in
* the model. <param name="f">A function declaration of zero arity</param>
*
* @return An expression if the function has an interpretation in the model,
* null otherwise.
* @throws Z3Exception
**/
public Expr ConstInterp(FuncDecl f) throws Z3Exception
{
Context().CheckContextMatch(f);
if (f.Arity() != 0
|| Native.getSortKind(Context().nCtx(),
Native.getRange(Context().nCtx(), f.NativeObject())) == Z3_sort_kind.Z3_ARRAY_SORT
.toInt())
throw new Z3Exception(
"Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp.");
long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(),
f.NativeObject());
if (n == 0)
return null;
else
return Expr.Create(Context(), n);
}
/**
* Retrieves the interpretation (the assignment) of a non-constant <paramref
* name="f"/> in the model. <param name="f">A function declaration of
* non-zero arity</param>
*
* @return A FunctionInterpretation if the function has an interpretation in
* the model, null otherwise.
* @throws Z3Exception
**/
public FuncInterp FuncInterp(FuncDecl f) throws Z3Exception
{
Context().CheckContextMatch(f);
Z3_sort_kind sk = Z3_sort_kind.fromInt(Native.getSortKind(Context()
.nCtx(), Native.getRange(Context().nCtx(), f.NativeObject())));
if (f.Arity() == 0)
{
long n = Native.modelGetConstInterp(Context().nCtx(),
NativeObject(), f.NativeObject());
if (sk == Z3_sort_kind.Z3_ARRAY_SORT)
{
if (n == 0)
return null;
else
{
if (Native.isAsArray(Context().nCtx(), n) ^ true)
throw new Z3Exception(
"Argument was not an array constant");
long fd = Native.getAsArrayFuncDecl(Context().nCtx(), n);
return FuncInterp(new FuncDecl(Context(), fd));
}
} else
{
throw new Z3Exception(
"Constant functions do not have a function interpretation; use ConstInterp");
}
} else
{
long n = Native.modelGetFuncInterp(Context().nCtx(),
NativeObject(), f.NativeObject());
if (n == 0)
return null;
else
return new FuncInterp(Context(), n);
}
}
/**
* The number of constants that have an interpretation in the model.
**/
public int NumConsts()
{
return Native.modelGetNumConsts(Context().nCtx(), NativeObject());
}
/**
* The function declarations of the constants in the model.
* @throws Z3Exception
**/
public FuncDecl[] ConstDecls() throws Z3Exception
{
int n = NumConsts();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(Context(), Native.modelGetConstDecl(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* The number of function interpretations in the model.
**/
public int NumFuncs()
{
return Native.modelGetNumFuncs(Context().nCtx(), NativeObject());
}
/**
* The function declarations of the function interpretations in the model.
* @throws Z3Exception
**/
public FuncDecl[] FuncDecls() throws Z3Exception
{
int n = NumFuncs();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(Context(), Native.modelGetFuncDecl(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* All symbols that have an interpretation in the model.
* @throws Z3Exception
**/
public FuncDecl[] Decls() throws Z3Exception
{
int nFuncs = NumFuncs();
int nConsts = NumConsts();
int n = nFuncs + nConsts;
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < nConsts; i++)
res[i] = new FuncDecl(Context(), Native.modelGetConstDecl(Context()
.nCtx(), NativeObject(), i));
for (int i = 0; i < nFuncs; i++)
res[nConsts + i] = new FuncDecl(Context(), Native.modelGetFuncDecl(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* A ModelEvaluationFailedException is thrown when an expression cannot be
* evaluated by the model.
**/
@SuppressWarnings("serial")
public class ModelEvaluationFailedException extends Z3Exception
{
/**
* An exception that is thrown when model evaluation fails.
**/
public ModelEvaluationFailedException()
{
super();
}
}
/**
* Evaluates the expression <paramref name="t"/> in the current model.
* <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
* <code>ModelEvaluationFailedException</code> 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>
*
* @return The evaluation of <paramref name="t"/> in the model.
* @throws Z3Exception
**/
public Expr Eval(Expr t, boolean completion) throws Z3Exception
{
Native.LongPtr v = new Native.LongPtr();
if (Native.modelEval(Context().nCtx(), NativeObject(),
t.NativeObject(), (completion) ? true : false, v) ^ true)
throw new ModelEvaluationFailedException();
else
return Expr.Create(Context(), v.value);
}
/**
* Alias for <code>Eval</code>.
* @throws Z3Exception
**/
public Expr Evaluate(Expr t, boolean completion) throws Z3Exception
{
return Eval(t, completion);
}
/**
* The number of uninterpreted sorts that the model has an interpretation
* for.
**/
public int NumSorts()
{
return Native.modelGetNumSorts(Context().nCtx(), NativeObject());
}
/**
* The uninterpreted sorts that the model has an interpretation for.
* <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"/>
* @throws Z3Exception
**/
public Sort[] Sorts() throws Z3Exception
{
int n = NumSorts();
Sort[] res = new Sort[n];
for (int i = 0; i < n; i++)
res[i] = Sort.Create(Context(),
Native.modelGetSort(Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The finite set of distinct values that represent the interpretation for
* sort <paramref name="s"/>. <seealso cref="Sorts"/> <param name="s">An
* uninterpreted sort</param>
*
* @return An array of expressions, where each is an element of the universe
* of <paramref name="s"/>
* @throws Z3Exception
**/
public Expr[] SortUniverse(Sort s) throws Z3Exception
{
ASTVector nUniv = new ASTVector(Context(), Native.modelGetSortUniverse(
Context().nCtx(), NativeObject(), s.NativeObject()));
int n = nUniv.Size();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.Create(Context(), nUniv.get(i).NativeObject());
return res;
}
/**
* Conversion of models to strings.
*
* @return A string representation of the model.
**/
public String toString()
{
return Native.modelToString(Context().nCtx(), NativeObject());
}
Model(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().Model_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Model_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ModelDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.modelIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.modelDecRef(ctx.nCtx(), obj);
}
};

View file

@ -4,7 +4,8 @@ public final class Native {
public static class IntPtr { public int value; }
public static class LongPtr { public long value; }
public static class StringPtr { public String value; }
static { System.loadLibrary("<mk_util.JavaDLLComponent instance at 0x0251B738>"); }
public static class errorHandler { public long ptr; }
static { System.loadLibrary("<mk_util.JavaDLLComponent instance at 0x026CDA08>"); }
public static native long mkConfig();
public static native void delConfig(long a0);
public static native void setParamValue(long a0, String a1, String a2);
@ -14,7 +15,7 @@ public final class Native {
public static native void incRef(long a0, long a1);
public static native void decRef(long a0, long a1);
public static native void updateParamValue(long a0, String a1, String a2);
public static native boolean getParamValue(long a0, String a1, String a2);
public static native boolean getParamValue(long a0, String a1, StringPtr a2);
public static native void interrupt(long a0);
public static native long mkParams(long a0);
public static native void paramsIncRef(long a0, long a1);
@ -40,16 +41,16 @@ public final class Native {
public static native long mkBvSort(long a0, int a1);
public static native long mkFiniteDomainSort(long a0, long a1, long a2);
public static native long mkArraySort(long a0, long a1, long a2);
public static native long mkTupleSort(long a0, long a1, int a2, long[] a3, long[] a4, Long a5, long[] a6);
public static native long mkTupleSort(long a0, long a1, int a2, long[] a3, long[] a4, LongPtr a5, long[] a6);
public static native long mkEnumerationSort(long a0, long a1, int a2, long[] a3, long[] a4, long[] a5);
public static native long mkListSort(long a0, long a1, long a2, Long a3, Long a4, Long a5, Long a6, Long a7, Long a8);
public static native long mkListSort(long a0, long a1, long a2, LongPtr a3, LongPtr a4, LongPtr a5, LongPtr a6, LongPtr a7, LongPtr a8);
public static native long mkConstructor(long a0, long a1, long a2, int a3, long[] a4, long[] a5, int[] a6);
public static native void delConstructor(long a0, long a1);
public static native long mkDatatype(long a0, long a1, int a2, long[] a3);
public static native long mkConstructorList(long a0, int a1, long[] a2);
public static native void delConstructorList(long a0, long a1);
public static native void mkDatatypes(long a0, int a1, long[] a2, long[] a3, long[] a4);
public static native void queryConstructor(long a0, long a1, int a2, Long a3, Long a4, long[] a5);
public static native void queryConstructor(long a0, long a1, int a2, LongPtr a3, LongPtr a4, long[] a5);
public static native long mkFuncDecl(long a0, long a1, int a2, long[] a3, long a4);
public static native long mkApp(long a0, long a1, int a2, long[] a3);
public static native long mkConst(long a0, long a1, long a2);
@ -170,7 +171,7 @@ public final class Native {
public static native boolean isEqSort(long a0, long a1, long a2);
public static native int getSortKind(long a0, long a1);
public static native int getBvSortSize(long a0, long a1);
public static native boolean getFiniteDomainSortSize(long a0, long a1, Long a2);
public static native boolean getFiniteDomainSortSize(long a0, long a1, LongPtr a2);
public static native long getArraySortDomain(long a0, long a1);
public static native long getArraySortRange(long a0, long a1);
public static native long getTupleSortMkDecl(long a0, long a1);
@ -220,12 +221,12 @@ public final class Native {
public static native String getNumeralDecimalString(long a0, long a1, int a2);
public static native long getNumerator(long a0, long a1);
public static native long getDenominator(long a0, long a1);
public static native boolean getNumeralSmall(long a0, long a1, Long a2, Long a3);
public static native boolean getNumeralInt(long a0, long a1, Integer a2);
public static native boolean getNumeralUint(long a0, long a1, Integer a2);
public static native boolean getNumeralUint64(long a0, long a1, Long a2);
public static native boolean getNumeralInt64(long a0, long a1, Long a2);
public static native boolean getNumeralRationalInt64(long a0, long a1, Long a2, Long a3);
public static native boolean getNumeralSmall(long a0, long a1, LongPtr a2, LongPtr a3);
public static native boolean getNumeralInt(long a0, long a1, IntPtr a2);
public static native boolean getNumeralUint(long a0, long a1, IntPtr a2);
public static native boolean getNumeralUint64(long a0, long a1, LongPtr a2);
public static native boolean getNumeralInt64(long a0, long a1, LongPtr a2);
public static native boolean getNumeralRationalInt64(long a0, long a1, LongPtr a2, LongPtr a3);
public static native long getAlgebraicNumberLower(long a0, long a1, int a2);
public static native long getAlgebraicNumberUpper(long a0, long a1, int a2);
public static native long patternToAst(long a0, long a1);
@ -252,7 +253,7 @@ public final class Native {
public static native long translate(long a0, long a1, long a2);
public static native void modelIncRef(long a0, long a1);
public static native void modelDecRef(long a0, long a1);
public static native boolean modelEval(long a0, long a1, long a2, boolean a3, Long a4);
public static native boolean modelEval(long a0, long a1, long a2, boolean a3, LongPtr a4);
public static native long modelGetConstInterp(long a0, long a1, long a2);
public static native long modelGetFuncInterp(long a0, long a1, long a2);
public static native int modelGetNumConsts(long a0, long a1);
@ -303,7 +304,7 @@ public final class Native {
public static native void setError(long a0, int a1);
public static native String getErrorMsg(int a0);
public static native String getErrorMsgEx(long a0, int a1);
public static native void getVersion(Integer a0, Integer a1, Integer a2, Integer a3);
public static native void getVersion(IntPtr a0, IntPtr a1, IntPtr a2, IntPtr a3);
public static native void enableTrace(String a0);
public static native void disableTrace(String a0);
public static native void resetMemory();
@ -455,9 +456,9 @@ public final class Native {
public static native int getNumScopes(long a0);
public static native void persistAst(long a0, long a1, int a2);
public static native void assertCnstr(long a0, long a1);
public static native int checkAndGetModel(long a0, Long a1);
public static native int checkAndGetModel(long a0, LongPtr a1);
public static native int check(long a0);
public static native int checkAssumptions(long a0, int a1, long[] a2, Long a3, Long a4, Integer a5, long[] a6);
public static native int checkAssumptions(long a0, int a1, long[] a2, LongPtr a3, LongPtr a4, IntPtr a5, long[] a6);
public static native int getImpliedEqualities(long a0, int a1, long[] a2, int[] a3);
public static native void delModel(long a0, long a1);
public static native void softCheckCancel(long a0);
@ -476,16 +477,16 @@ public final class Native {
public static native long getModelConstant(long a0, long a1, int a2);
public static native int getModelNumFuncs(long a0, long a1);
public static native long getModelFuncDecl(long a0, long a1, int a2);
public static native boolean evalFuncDecl(long a0, long a1, long a2, Long a3);
public static native boolean isArrayValue(long a0, long a1, long a2, Integer a3);
public static native void getArrayValue(long a0, long a1, long a2, int a3, long[] a4, long[] a5, Long a6);
public static native boolean evalFuncDecl(long a0, long a1, long a2, LongPtr a3);
public static native boolean isArrayValue(long a0, long a1, long a2, IntPtr a3);
public static native void getArrayValue(long a0, long a1, long a2, int a3, long[] a4, long[] a5, LongPtr a6);
public static native long getModelFuncElse(long a0, long a1, int a2);
public static native int getModelFuncNumEntries(long a0, long a1, int a2);
public static native int getModelFuncEntryNumArgs(long a0, long a1, int a2, int a3);
public static native long getModelFuncEntryArg(long a0, long a1, int a2, int a3, int a4);
public static native long getModelFuncEntryValue(long a0, long a1, int a2, int a3);
public static native boolean eval(long a0, long a1, long a2, Long a3);
public static native boolean evalDecl(long a0, long a1, long a2, int a3, long[] a4, Long a5);
public static native boolean eval(long a0, long a1, long a2, LongPtr a3);
public static native boolean evalDecl(long a0, long a1, long a2, int a3, long[] a4, LongPtr a5);
public static native String contextToString(long a0);
public static native String statisticsToString(long a0);
public static native long getContextAssignment(long a0);

View file

@ -0,0 +1,85 @@
/**
* This file was automatically generated from ParamDescrs.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* A ParamDescrs describes a set of parameters.
**/
public class ParamDescrs extends Z3Object
{
/**
* validate a set of parameters.
**/
public void Validate(Params p)
{
Native.paramsValidate(Context().nCtx(), p.NativeObject(),
NativeObject());
}
/**
* Retrieve kind of parameter.
**/
public Z3_param_kind GetKind(Symbol name)
{
return Z3_param_kind.fromInt(Native.paramDescrsGetKind(
Context().nCtx(), NativeObject(), name.NativeObject()));
}
/**
* Retrieve all names of parameters.
*
* @throws Z3Exception
**/
public Symbol[] Names() throws Z3Exception
{
int sz = Native.paramDescrsSize(Context().nCtx(), NativeObject());
Symbol[] names = new Symbol[sz];
for (int i = 0; i < sz; ++i)
{
names[i] = Symbol.Create(Context(), Native.paramDescrsGetName(
Context().nCtx(), NativeObject(), i));
}
return names;
}
/**
* The size of the ParamDescrs.
**/
public int Size()
{
return Native.paramDescrsSize(Context().nCtx(), NativeObject());
}
/**
* Retrieves a string representation of the ParamDescrs.
**/
public String toString()
{
return Native.paramDescrsToString(Context().nCtx(), NativeObject());
}
ParamDescrs(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().ParamDescrs_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().ParamDescrs_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ParamDescrsDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.paramDescrsIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.paramDescrsDecRef(ctx.nCtx(), obj);
}
};

102
src/api/java/Params.java Normal file
View file

@ -0,0 +1,102 @@
/**
* This file was automatically generated from Params.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* A ParameterSet represents a configuration in the form of Symbol/value pairs.
**/
public class Params extends Z3Object
{
/**
* Adds a parameter setting.
**/
public void Add(Symbol name, boolean value) throws Z3Exception
{
Native.paramsSetBool(Context().nCtx(), NativeObject(),
name.NativeObject(), (value) ? true : false);
}
/**
* Adds a parameter setting.
**/
public void Add(Symbol name, double value) throws Z3Exception
{
Native.paramsSetDouble(Context().nCtx(), NativeObject(),
name.NativeObject(), value);
}
/**
* Adds a parameter setting.
**/
public void Add(Symbol name, Symbol value) throws Z3Exception
{
Native.paramsSetSymbol(Context().nCtx(), NativeObject(),
name.NativeObject(), value.NativeObject());
}
/**
* Adds a parameter setting.
**/
public void Add(String name, boolean value) throws Z3Exception
{
Native.paramsSetBool(Context().nCtx(), NativeObject(), Context()
.MkSymbol(name).NativeObject(), (value) ? true : false);
}
/**
* Adds a parameter setting.
**/
public void Add(String name, int value) throws Z3Exception
{
Native.paramsSetUint(Context().nCtx(), NativeObject(), Context()
.MkSymbol(name).NativeObject(), value);
}
/**
* Adds a parameter setting.
**/
public void Add(String name, double value) throws Z3Exception
{
Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context()
.MkSymbol(name).NativeObject(), value);
}
/**
* Adds a parameter setting.
**/
public void Add(String name, Symbol value) throws Z3Exception
{
Native.paramsSetSymbol(Context().nCtx(), NativeObject(), Context()
.MkSymbol(name).NativeObject(), value.NativeObject());
}
/**
* A string representation of the parameter set.
**/
public String toString()
{
return Native.paramsToString(Context().nCtx(), NativeObject());
}
Params(Context ctx) throws Z3Exception
{
super(ctx, Native.mkParams(ctx.nCtx()));
}
void IncRef(long o) throws Z3Exception
{
Context().Params_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Params_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ParamsDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.paramsIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.paramsDecRef(ctx.nCtx(), obj);
}
};

51
src/api/java/Pattern.java Normal file
View file

@ -0,0 +1,51 @@
/**
* This file was automatically generated from Pattern.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* 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.
**/
public class Pattern extends AST
{
/**
* The number of terms in the pattern.
**/
public int NumTerms()
{
return Native.getPatternNumTerms(Context().nCtx(), NativeObject());
}
/**
* The terms in the pattern.
*
* @throws Z3Exception
**/
public Expr[] Terms() throws Z3Exception
{
int n = NumTerms();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.Create(Context(),
Native.getPattern(Context().nCtx(), NativeObject(), i));
return res;
}
/**
* A string representation of the pattern.
**/
public String toString()
{
return Native.patternToString(Context().nCtx(), NativeObject());
}
Pattern(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

63
src/api/java/Probe.java Normal file
View file

@ -0,0 +1,63 @@
/**
* This file was automatically generated from Probe.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* 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
* <code>Context.NumProbes</code> and <code>Context.ProbeNames</code>. It may
* also be obtained using the command <code>(help-tactics)</code> in the SMT 2.0
* front-end.
**/
public class Probe extends Z3Object
{
/**
* Execute the probe over the goal.
*
* @return A probe always produce a double value. "Boolean" probes return
* 0.0 for false, and a value different from 0.0 for true.
* @throws Z3Exception
**/
public double Apply(Goal g) throws Z3Exception
{
Context().CheckContextMatch(g);
return Native.probeApply(Context().nCtx(), NativeObject(),
g.NativeObject());
}
/**
* Apply the probe to a goal.
* @throws Z3Exception
**/
public double get(Goal g) throws Z3Exception
{
return Apply(g);
}
Probe(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Probe(Context ctx, String name) throws Z3Exception
{
super(ctx, Native.mkProbe(ctx.nCtx(), name));
}
void IncRef(long o) throws Z3Exception
{
Context().Probe_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Probe_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class ProbeDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.probeIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.probeDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,213 @@
/**
* This file was automatically generated from Quantifier.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Quantifier expressions.
**/
public class Quantifier extends BoolExpr
{
/**
* Indicates whether the quantifier is universal.
**/
public boolean IsUniversal()
{
return Native.isQuantifierForall(Context().nCtx(), NativeObject());
}
/**
* Indicates whether the quantifier is existential.
**/
public boolean IsExistential()
{
return !IsUniversal();
}
/**
* The weight of the quantifier.
**/
public int Weight()
{
return Native.getQuantifierWeight(Context().nCtx(), NativeObject());
}
/**
* The number of patterns.
**/
public int NumPatterns()
{
return Native
.getQuantifierNumPatterns(Context().nCtx(), NativeObject());
}
/**
* The patterns.
*
* @throws Z3Exception
**/
public Pattern[] Patterns() throws Z3Exception
{
int n = NumPatterns();
Pattern[] res = new Pattern[n];
for (int i = 0; i < n; i++)
res[i] = new Pattern(Context(), Native.getQuantifierPatternAst(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The number of no-patterns.
**/
public int NumNoPatterns()
{
return Native.getQuantifierNumNoPatterns(Context().nCtx(),
NativeObject());
}
/**
* The no-patterns.
*
* @throws Z3Exception
**/
public Pattern[] NoPatterns() throws Z3Exception
{
int n = NumNoPatterns();
Pattern[] res = new Pattern[n];
for (int i = 0; i < n; i++)
res[i] = new Pattern(Context(), Native.getQuantifierNoPatternAst(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The number of bound variables.
**/
public int NumBound()
{
return Native.getQuantifierNumBound(Context().nCtx(), NativeObject());
}
/**
* The symbols for the bound variables.
*
* @throws Z3Exception
**/
public Symbol[] BoundVariableNames() throws Z3Exception
{
int n = NumBound();
Symbol[] res = new Symbol[n];
for (int i = 0; i < n; i++)
res[i] = Symbol.Create(Context(), Native.getQuantifierBoundName(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The sorts of the bound variables.
*
* @throws Z3Exception
**/
public Sort[] BoundVariableSorts() throws Z3Exception
{
int n = NumBound();
Sort[] res = new Sort[n];
for (int i = 0; i < n; i++)
res[i] = Sort.Create(Context(), Native.getQuantifierBoundSort(
Context().nCtx(), NativeObject(), i));
return res;
}
/**
* The body of the quantifier.
*
* @throws Z3Exception
**/
public BoolExpr Body() throws Z3Exception
{
return new BoolExpr(Context(), Native.getQuantifierBody(Context()
.nCtx(), NativeObject()));
}
Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names,
Expr body, int weight, Pattern[] patterns, Expr[] noPatterns,
Symbol quantifierID, Symbol skolemID) throws Z3Exception
{
super(ctx);
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");
if (noPatterns == null && quantifierID == null && skolemID == null)
{
setNativeObject(Native.mkQuantifier(ctx.nCtx(), (isForall) ? true
: false, weight, AST.ArrayLength(patterns), AST
.ArrayToNative(patterns), AST.ArrayLength(sorts), AST
.ArrayToNative(sorts), Symbol.ArrayToNative(names), body
.NativeObject()));
} else
{
setNativeObject(Native.mkQuantifierEx(ctx.nCtx(), (isForall) ? true
: false, 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()));
}
}
Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body,
int weight, Pattern[] patterns, Expr[] noPatterns,
Symbol quantifierID, Symbol skolemID) throws Z3Exception
{
super(ctx);
Context().CheckContextMatch(noPatterns);
Context().CheckContextMatch(patterns);
// Context().CheckContextMatch(bound);
Context().CheckContextMatch(body);
if (noPatterns == null && quantifierID == null && skolemID == null)
{
setNativeObject(Native.mkQuantifierConst(ctx.nCtx(),
(isForall) ? true : false, weight, AST.ArrayLength(bound),
AST.ArrayToNative(bound), AST.ArrayLength(patterns),
AST.ArrayToNative(patterns), body.NativeObject()));
} else
{
setNativeObject(Native.mkQuantifierConstEx(ctx.nCtx(),
(isForall) ? true : false, 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()));
}
}
Quantifier(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void CheckNativeObject(long obj) throws Z3Exception
{
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST
.toInt())
throw new Z3Exception("Underlying object is not a quantifier");
super.CheckNativeObject(obj);
}
}

73
src/api/java/RatNum.java Normal file
View file

@ -0,0 +1,73 @@
/**
* This file was automatically generated from RatNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import java.math.BigInteger;
/**
* Rational Numerals
**/
public class RatNum extends RealExpr
{
/**
* The numerator of a rational numeral.
**/
public IntNum Numerator() throws Z3Exception
{
return new IntNum(Context(), Native.getNumerator(Context().nCtx(),
NativeObject()));
}
/**
* The denominator of a rational numeral.
**/
public IntNum Denominator() throws Z3Exception
{
return new IntNum(Context(), Native.getDenominator(Context().nCtx(),
NativeObject()));
}
/**
* Converts the numerator of the rational to a BigInteger
**/
public BigInteger BigIntNumerator() throws Z3Exception
{
IntNum n = Numerator();
return new BigInteger(n.toString());
}
/**
* Converts the denominator of the rational to a BigInteger
**/
public BigInteger BigIntDenominator() throws Z3Exception
{
IntNum n = Denominator();
return new BigInteger(n.toString());
}
/**
* Returns a string representation in decimal notation. <remarks>The result
* has at most <paramref name="precision"/> decimal places.</remarks>
**/
public String ToDecimalString(int precision) throws Z3Exception
{
return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(),
precision);
}
/**
* Returns a string representation of the numeral.
**/
public String toString()
{
return Native.getNumeralString(Context().nCtx(), NativeObject());
}
RatNum(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,26 @@
/**
* This file was automatically generated from RealExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Real expressions
**/
public class RealExpr extends ArithExpr
{
/**
* Constructor for RealExpr </summary>
**/
protected RealExpr(Context ctx)
{
super(ctx);
}
RealExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,23 @@
/**
* This file was automatically generated from RealSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* A real sort
**/
public class RealSort extends ArithSort
{
RealSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
RealSort(Context ctx) throws Z3Exception
{
super(ctx, Native.mkRealSort(ctx.nCtx()));
}
}

View file

@ -0,0 +1,46 @@
/**
* This file was automatically generated from RelationSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Relation sorts.
**/
public class RelationSort extends Sort
{
/**
* The arity of the relation sort.
**/
public int Arity()
{
return Native.getRelationArity(Context().nCtx(), NativeObject());
}
/**
* The sorts of the columns of the relation sort.
* @throws Z3Exception
**/
public Sort[] ColumnSorts() throws Z3Exception
{
if (m_columnSorts != null)
return m_columnSorts;
int n = Arity();
Sort[] res = new Sort[n];
for (int i = 0; i < n; i++)
res[i] = Sort.Create(Context(), Native.getRelationColumn(Context()
.nCtx(), NativeObject(), i));
return res;
}
private Sort[] m_columnSorts = null;
RelationSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
}

23
src/api/java/SetSort.java Normal file
View file

@ -0,0 +1,23 @@
/**
* This file was automatically generated from SetSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Set sorts.
**/
public class SetSort extends Sort
{
SetSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
SetSort(Context ctx, Sort ty) throws Z3Exception
{
super(ctx, Native.mkSetSort(ctx.nCtx(), ty.NativeObject()));
}
}

242
src/api/java/Solver.java Normal file
View file

@ -0,0 +1,242 @@
/**
* This file was automatically generated from Solver.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Solvers.
**/
public class Solver extends Z3Object
{
/**
* A string that describes all available solver parameters.
**/
public String Help()
{
return Native.solverGetHelp(Context().nCtx(), NativeObject());
}
/**
* Sets the solver parameters.
* @throws Z3Exception
**/
public void setParameters(Params value) throws Z3Exception
{
Context().CheckContextMatch(value);
Native.solverSetParams(Context().nCtx(), NativeObject(),
value.NativeObject());
}
/**
* Retrieves parameter descriptions for solver.
* @throws Z3Exception
**/
public ParamDescrs ParameterDescriptions() throws Z3Exception
{
return new ParamDescrs(Context(), Native.solverGetParamDescrs(Context()
.nCtx(), NativeObject()));
}
/**
* The current number of backtracking points (scopes). <seealso cref="Pop"/>
* <seealso cref="Push"/>
**/
public int NumScopes()
{
return Native.solverGetNumScopes(Context().nCtx(), NativeObject());
}
/**
* Creates a backtracking point. <seealso cref="Pop"/>
**/
public void Push()
{
Native.solverPush(Context().nCtx(), NativeObject());
}
/**
* Backtracks <paramref name="n"/> backtracking points. <remarks>Note that
* an exception is thrown if <paramref name="n"/> is not smaller than
* <code>NumScopes</code></remarks> <seealso cref="Push"/>
**/
public void Pop(int n)
{
Native.solverPop(Context().nCtx(), NativeObject(), n);
}
/**
* Resets the Solver. <remarks>This removes all assertions from the
* solver.</remarks>
**/
public void Reset()
{
Native.solverReset(Context().nCtx(), NativeObject());
}
/**
* Assert a constraint (or multiple) into the solver.
* @throws Z3Exception
**/
public void Assert(BoolExpr[] constraints) throws Z3Exception
{
Context().CheckContextMatch(constraints);
for (BoolExpr a : constraints)
{
Native.solverAssert(Context().nCtx(), NativeObject(),
a.NativeObject());
}
}
/**
* The number of assertions in the solver.
* @throws Z3Exception
**/
public int NumAssertions() throws Z3Exception
{
ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(
Context().nCtx(), NativeObject()));
return ass.Size();
}
/**
* The set of asserted formulas.
* @throws Z3Exception
**/
public BoolExpr[] Assertions() throws Z3Exception
{
ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(
Context().nCtx(), NativeObject()));
int n = ass.Size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(Context(), ass.get(i).NativeObject());
return res;
}
/**
* Checks whether the assertions in the solver are consistent or not.
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
* cref="Proof"/> </remarks>
**/
public Status Check(Expr[] assumptions)
{
Z3_lbool r;
if (assumptions == null)
r = Z3_lbool.fromInt(Native.solverCheck(Context().nCtx(),
NativeObject()));
else
r = Z3_lbool.fromInt(Native.solverCheckAssumptions(
Context().nCtx(), NativeObject(), (int) assumptions.length,
AST.ArrayToNative(assumptions)));
switch (r)
{
case Z3_L_TRUE:
return Status.SATISFIABLE;
case Z3_L_FALSE:
return Status.UNSATISFIABLE;
default:
return Status.UNKNOWN;
}
}
/**
* The model of the last <code>Check</code>. <remarks> The result is
* <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>SATISFIABLE</code>, or if model production is not
* enabled. </remarks>
* @throws Z3Exception
**/
public Model Model() throws Z3Exception
{
long x = Native.solverGetModel(Context().nCtx(), NativeObject());
if (x == 0)
return null;
else
return new Model(Context(), x);
}
/**
* The proof of the last <code>Check</code>. <remarks> The result is
* <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>UNSATISFIABLE</code>, or if proof production is
* disabled. </remarks>
* @throws Z3Exception
**/
public Expr Proof() throws Z3Exception
{
long x = Native.solverGetProof(Context().nCtx(), NativeObject());
if (x == 0)
return null;
else
return Expr.Create(Context(), x);
}
/**
* The unsat core of the last <code>Check</code>. <remarks> The unsat core
* is a subset of <code>Assertions</code> The result is empty if
* <code>Check</code> was not invoked before, if its results was not
* <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks>
* @throws Z3Exception
**/
public Expr[] UnsatCore() throws Z3Exception
{
ASTVector core = new ASTVector(Context(), Native.solverGetUnsatCore(
Context().nCtx(), NativeObject()));
int n = core.Size();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.Create(Context(), core.get(i).NativeObject());
return res;
}
/**
* A brief justification of why the last call to <code>Check</code> returned
* <code>UNKNOWN</code>.
**/
public String ReasonUnknown()
{
return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject());
}
/**
* Solver statistics.
* @throws Z3Exception
**/
public Statistics Statistics() throws Z3Exception
{
return new Statistics(Context(), Native.solverGetStatistics(Context()
.nCtx(), NativeObject()));
}
/**
* A string representation of the solver.
**/
public String toString()
{
return Native.solverToString(Context().nCtx(), NativeObject());
}
Solver(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().Solver_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Solver_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class SolverDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.solverIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.solverDecRef(ctx.nCtx(), obj);
}
};

143
src/api/java/Sort.java Normal file
View file

@ -0,0 +1,143 @@
/**
* This file was automatically generated from Sort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* The Sort class implements type information for ASTs.
**/
public class Sort extends AST
{
/**
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
* Sort</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
* the same context and represent the same sort; false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
* Sort</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
* from the same context or represent different sorts; false
* otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Equality operator for objects of type Sort. <param name="o"></param>
*
* @return
**/
public boolean Equals(Object o)
{
Sort casted = (Sort) o;
if (casted == null)
return false;
return this == casted;
}
/**
* Hash code generation for Sorts
*
* @return A hash code
**/
public int GetHashCode() throws Z3Exception
{
return super.GetHashCode();
}
/**
* Returns a unique identifier for the sort.
**/
public int Id() throws Z3Exception
{
return Native.getSortId(Context().nCtx(), NativeObject());
}
/**
* The kind of the sort.
**/
public Z3_sort_kind SortKind() throws Z3Exception
{
return Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(),
NativeObject()));
}
/**
* The name of the sort
**/
public Symbol Name() throws Z3Exception
{
return Symbol.Create(Context(),
Native.getSortName(Context().nCtx(), NativeObject()));
}
/**
* A string representation of the sort.
**/
public String toString()
{
return Native.sortToString(Context().nCtx(), NativeObject());
}
/**
* Sort constructor
**/
protected Sort(Context ctx) throws Z3Exception
{
super(ctx);
{
}
}
Sort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
{
}
}
void CheckNativeObject(long obj) throws Z3Exception
{
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_SORT_AST
.toInt())
throw new Z3Exception("Underlying object is not a sort");
super.CheckNativeObject(obj);
}
static Sort Create(Context ctx, long obj) throws Z3Exception
{
switch (Z3_sort_kind.fromInt(Native.getSortKind(ctx.nCtx(), obj)))
{
case Z3_ARRAY_SORT:
return new ArraySort(ctx, obj);
case Z3_BOOL_SORT:
return new BoolSort(ctx, obj);
case Z3_BV_SORT:
return new BitVecSort(ctx, obj);
case Z3_DATATYPE_SORT:
return new DatatypeSort(ctx, obj);
case Z3_INT_SORT:
return new IntSort(ctx, obj);
case Z3_REAL_SORT:
return new RealSort(ctx, obj);
case Z3_UNINTERPRETED_SORT:
return new UninterpretedSort(ctx, obj);
case Z3_FINITE_DOMAIN_SORT:
return new FiniteDomainSort(ctx, obj);
case Z3_RELATION_SORT:
return new RelationSort(ctx, obj);
default:
throw new Z3Exception("Unknown sort kind");
}
}
}

View file

@ -0,0 +1,190 @@
/**
* This file was automatically generated from Statistics.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Objects of this class track statistical information about solvers.
**/
public class Statistics extends Z3Object
{
/**
* Statistical data is organized into pairs of [Key, Entry], where every
* Entry is either a <code>DoubleEntry</code> or a <code>UIntEntry</code>
**/
public class Entry
{
/**
* The key of the entry.
**/
public String Key;
/**
* The uint-value of the entry.
**/
public int UIntValue()
{
return m_int;
}
/**
* The double-value of the entry.
**/
public double DoubleValue()
{
return m_double;
}
/**
* True if the entry is uint-valued.
**/
public boolean IsUInt()
{
return m_is_int;
}
/**
* True if the entry is double-valued.
**/
public boolean IsDouble()
{
return m_is_double;
}
/**
* The string representation of the the entry's value.
* @throws Z3Exception
**/
public String Value() throws Z3Exception
{
if (IsUInt())
return Integer.toString(m_int);
else if (IsDouble())
return Double.toString(m_double);
else
throw new Z3Exception("Unknown statistical entry type");
}
/**
* The string representation of the Entry.
**/
public String toString()
{
try
{
return Key + ": " + Value();
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
private boolean m_is_int = false;
private boolean m_is_double = false;
private int m_int = 0;
private double m_double = 0.0;
Entry(String k, int v)
{
Key = k;
m_is_int = true;
m_int = v;
}
Entry(String k, double v)
{
Key = k;
m_is_double = true;
m_double = v;
}
}
/**
* A string representation of the statistical data.
**/
public String toString()
{
return Native.statsToString(Context().nCtx(), NativeObject());
}
/**
* The number of statistical data.
**/
public int Size()
{
return Native.statsSize(Context().nCtx(), NativeObject());
}
/**
* The data entries.
* @throws Z3Exception
**/
public Entry[] Entries() throws Z3Exception
{
int n = Size();
Entry[] res = new Entry[n];
for (int i = 0; i < n; i++)
{
Entry e;
String k = Native.statsGetKey(Context().nCtx(), NativeObject(), i);
if (Native.statsIsUint(Context().nCtx(), NativeObject(), i))
e = new Entry(k, Native.statsGetUintValue(Context().nCtx(),
NativeObject(), i));
else if (Native.statsIsDouble(Context().nCtx(), NativeObject(), i))
e = new Entry(k, Native.statsGetDoubleValue(Context().nCtx(),
NativeObject(), i));
else
throw new Z3Exception("Unknown data entry value");
res[i] = e;
}
return res;
}
/**
* The statistical counters.
**/
public String[] Keys()
{
int n = Size();
String[] res = new String[n];
for (int i = 0; i < n; i++)
res[i] = Native.statsGetKey(Context().nCtx(), NativeObject(), i);
return res;
}
/**
* The value of a particular statistical counter. <remarks>Returns null if
* the key is unknown.</remarks>
* @throws Z3Exception
**/
public Entry get(String key) throws Z3Exception
{
int n = Size();
Entry[] es = Entries();
for (int i = 0; i < n; i++)
if (es[i].Key == key)
return es[i];
return null;
}
Statistics(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
void IncRef(long o) throws Z3Exception
{
Context().Statistics_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Statistics_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class StatisticsDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.statsIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.statsDecRef(ctx.nCtx(), obj);
}
};

42
src/api/java/Status.java Normal file
View file

@ -0,0 +1,42 @@
/**
* This file was automatically generated from Status.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Status values.
**/
public enum Status
{
// / Used to signify an unsatisfiable status.
UNSATISFIABLE(1),
// / Used to signify an unknown status.
UNKNOWN(0),
// / Used to signify a satisfiable status.
SATISFIABLE(1);
private final int intValue;
Status(int v)
{
this.intValue = v;
}
public static final Status fromInt(int v)
{
for (Status k : values())
if (k.intValue == v)
return k;
return values()[0];
}
public final int toInt()
{
return this.intValue;
}
}

View file

@ -0,0 +1,43 @@
/**
* This file was automatically generated from StringSymbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Named symbols
**/
public class StringSymbol extends Symbol
{
/**
* The string value of the symbol. <remarks>Throws an exception if the
* symbol is not of string kind.</remarks>
**/
public String String() throws Z3Exception
{
return Native.getSymbolString(Context().nCtx(), NativeObject());
}
StringSymbol(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
StringSymbol(Context ctx, String s) throws Z3Exception
{
super(ctx, Native.mkStringSymbol(ctx.nCtx(), s));
}
void CheckNativeObject(long obj) throws Z3Exception
{
if (Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL
.toInt())
throw new Z3Exception("Symbol is not of String kind");
super.CheckNativeObject(obj);
}
}

81
src/api/java/Symbol.java Normal file
View file

@ -0,0 +1,81 @@
/**
* This file was automatically generated from Symbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* Symbols are used to name several term and type constructors.
**/
public class Symbol extends Z3Object
{
/**
* The kind of the symbol (int or string)
**/
protected Z3_symbol_kind Kind()
{
return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(),
NativeObject()));
}
/**
* Indicates whether the symbol is of Int kind
**/
public boolean IsIntSymbol()
{
return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL;
}
/**
* Indicates whether the symbol is of string kind.
**/
public boolean IsStringSymbol()
{
return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
}
/**
* A string representation of the symbol.
**/
public String toString()
{
try
{
if (IsIntSymbol())
return Integer.toString(((IntSymbol) this).Int());
else if (IsStringSymbol())
return ((StringSymbol) this).String();
else
return new String(
"Z3Exception: Unknown symbol kind encountered.");
} catch (Z3Exception ex)
{
return new String("Z3Exception: " + ex.getMessage());
}
}
/**
* Symbol constructor
**/
protected Symbol(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
static Symbol Create(Context ctx, long obj) throws Z3Exception
{
switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj)))
{
case Z3_INT_SYMBOL:
return new IntSymbol(ctx, obj);
case Z3_STRING_SYMBOL:
return new StringSymbol(ctx, obj);
default:
throw new Z3Exception("Unknown symbol kind encountered");
}
}
}

98
src/api/java/Tactic.java Normal file
View file

@ -0,0 +1,98 @@
/**
* This file was automatically generated from Tactic.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Tactics are the basic building block for creating custom solvers for specific
* problem domains. The complete list of tactics may be obtained using
* <code>Context.NumTactics</code> and <code>Context.TacticNames</code>. It may
* also be obtained using the command <code>(help-tactics)</code> in the SMT 2.0
* front-end.
**/
public class Tactic extends Z3Object
{
/**
* A string containing a description of parameters accepted by the tactic.
**/
public String Help()
{
return Native.tacticGetHelp(Context().nCtx(), NativeObject());
}
/**
* Retrieves parameter descriptions for Tactics.
* @throws Z3Exception
**/
public ParamDescrs ParameterDescriptions() throws Z3Exception
{
return new ParamDescrs(Context(), Native.tacticGetParamDescrs(Context()
.nCtx(), NativeObject()));
}
/**
* Execute the tactic over the goal.
* @throws Z3Exception
**/
public ApplyResult Apply(Goal g, Params p) throws Z3Exception
{
Context().CheckContextMatch(g);
if (p == null)
return new ApplyResult(Context(), Native.tacticApply(Context()
.nCtx(), NativeObject(), g.NativeObject()));
else
{
Context().CheckContextMatch(p);
return new ApplyResult(Context(),
Native.tacticApplyEx(Context().nCtx(), NativeObject(),
g.NativeObject(), p.NativeObject()));
}
}
/**
* Apply the tactic to a goal.
* @throws Z3Exception
**/
public ApplyResult get(Goal g) throws Z3Exception
{
return Apply(g, null);
}
/**
* Creates a solver that is implemented using the given tactic. <seealso
* cref="Context.MkSolver(Tactic)"/>
* @throws Z3Exception
**/
public Solver Solver() throws Z3Exception
{
return Context().MkSolver(this);
}
Tactic(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Tactic(Context ctx, String name) throws Z3Exception
{
super(ctx, Native.mkTactic(ctx.nCtx(), name));
}
void IncRef(long o) throws Z3Exception
{
Context().Tactic_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Tactic_DRQ().Add(o);
super.DecRef(o);
}
}

View file

@ -0,0 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
class TacticDecRefQueue extends IDecRefQueue
{
public void IncRef(Context ctx, long obj)
{
Native.tacticIncRef(ctx.nCtx(), obj);
}
public void DecRef(Context ctx, long obj)
{
Native.tacticDecRef(ctx.nCtx(), obj);
}
};

View file

@ -0,0 +1,58 @@
/**
* This file was automatically generated from TupleSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Tuple sorts.
**/
public class TupleSort extends Sort
{
/**
* The constructor function of the tuple.
* @throws Z3Exception
**/
public FuncDecl MkDecl() throws Z3Exception
{
return new FuncDecl(Context(), Native.getTupleSortMkDecl(Context()
.nCtx(), NativeObject()));
}
/**
* The number of fields in the tuple.
**/
public int NumFields()
{
return Native.getTupleSortNumFields(Context().nCtx(), NativeObject());
}
/**
* The field declarations.
* @throws Z3Exception
**/
public FuncDecl[] FieldDecls() throws Z3Exception
{
int n = NumFields();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(Context(), Native.getTupleSortFieldDecl(
Context().nCtx(), NativeObject(), i));
return res;
}
TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames,
Sort[] fieldSorts) throws Z3Exception
{
super(ctx);
Native.LongPtr t = new Native.LongPtr();
setNativeObject(Native.mkTupleSort(ctx.nCtx(), name.NativeObject(),
numFields, Symbol.ArrayToNative(fieldNames),
AST.ArrayToNative(fieldSorts), t, new long[numFields]));
}
};

View file

@ -0,0 +1,23 @@
/**
* This file was automatically generated from UninterpretedSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Uninterpreted Sorts
**/
public class UninterpretedSort extends Sort
{
UninterpretedSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
UninterpretedSort(Context ctx, Symbol s) throws Z3Exception
{
super(ctx, Native.mkUninterpretedSort(ctx.nCtx(), s.NativeObject()));
}
}

68
src/api/java/Version.java Normal file
View file

@ -0,0 +1,68 @@
/**
* This file was automatically generated from Version.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Version information. <remarks>Note that this class is static.</remarks>
**/
public final class Version
{
Version()
{
}
/**
* The major version
**/
public int Major()
{
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
Native.getVersion(major, minor, build, revision);
return major.value;
}
/**
* The minor version
**/
public int Minor()
{
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
Native.getVersion(major, minor, build, revision);
return minor.value;
}
/**
* The build version
**/
public int Build()
{
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
Native.getVersion(major, minor, build, revision);
return build.value;
}
/**
* The revision
**/
public int Revision()
{
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
Native.getVersion(major, minor, build, revision);
return revision.value;
}
/**
* A string representation of the version information.
**/
public String toString()
{
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
Native.getVersion(major, minor, build, revision);
return Integer.toString(major.value) + "." + Integer.toString(minor.value) + "."
+ Integer.toString(build.value) + "." + Integer.toString(revision.value);
}
}

View file

@ -0,0 +1,40 @@
/**
* This file was automatically generated from Z3Exception.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import java.lang.Exception;
/**
* The exception base class for error reporting from Z3
**/
@SuppressWarnings("serial")
public class Z3Exception extends Exception
{
/**
* Constructor.
**/
public Z3Exception()
{
super();
}
/**
* Constructor.
**/
public Z3Exception(String message)
{
super(message);
}
/**
* Constructor.
**/
public Z3Exception(String message, Exception inner)
{
super(message, inner);
}
}

116
src/api/java/Z3Object.java Normal file
View file

@ -0,0 +1,116 @@
/**
* This file was automatically generated from Z3Object.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
/**
* Internal base class for interfacing with native Z3 objects. Should not be
* used externally.
**/
public class Z3Object extends IDisposable
{
/**
* Finalizer.
**/
protected void finalize() throws Z3Exception
{
Dispose();
}
/**
* Disposes of the underlying native Z3 object.
**/
public void Dispose() throws Z3Exception
{
if (m_n_obj != 0)
{
DecRef(m_n_obj);
m_n_obj = 0;
}
if (m_ctx != null)
{
m_ctx.m_refCount--;
m_ctx = null;
}
}
private Context m_ctx = null;
private long m_n_obj = 0;
Z3Object(Context ctx)
{
ctx.m_refCount++;
m_ctx = ctx;
}
Z3Object(Context ctx, long obj) throws Z3Exception
{
ctx.m_refCount++;
m_ctx = ctx;
IncRef(obj);
m_n_obj = obj;
}
void IncRef(long o) throws Z3Exception
{
}
void DecRef(long o) throws Z3Exception
{
}
void CheckNativeObject(long obj) throws Z3Exception
{
}
long NativeObject()
{
return m_n_obj;
}
void setNativeObject(long value) throws Z3Exception
{
if (value != 0)
{
CheckNativeObject(value);
IncRef(value);
}
if (m_n_obj != 0)
{
DecRef(m_n_obj);
}
m_n_obj = value;
}
static long GetNativeObject(Z3Object s)
{
if (s == null)
return 0;
return s.NativeObject();
}
Context Context()
{
return m_ctx;
}
static long[] ArrayToNative(Z3Object[] a)
{
if (a == null)
return null;
long[] an = new long[a.length];
for (int i = 0; i < a.length; i++)
if (a[i] != null)
an[i] = a[i].NativeObject();
return an;
}
static int ArrayLength(Z3Object[] a)
{
return (a == null) ? 0 : (int) a.length;
}
}

View file

@ -1,209 +0,0 @@
/**
* This file was automatically generated from AST.cs
**/
package com.Microsoft.Z3;
/* using System; */
/* using System.Collections; */
/* using System.Collections.Generic; */
/**
* The abstract syntax tree (AST) class.
**/
public class AST extends Z3Object
{
/**
* Comparison operator.
* <param name="a">An AST</param>
* <param name="b">An AST</param>
* @return True if <paramref name="a"/> and <paramref name="b"/> are from the same context
* and represent the same sort; false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Comparison operator.
* <param name="a">An AST</param>
* <param name="b">An AST</param>
* @return True if <paramref name="a"/> and <paramref name="b"/> are not from the same context
* or represent different sorts; false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Object comparison.
**/
public boolean Equals(object o)
{
AST casted = (AST) o;
if (casted == null) return false;
return this == casted;
}
/**
* Object Comparison.
* <param name="other">Another AST</param>
* @return Negative if the object should be sorted before <paramref name="other"/>, positive if after else zero.
**/
public int CompareTo(object other)
{
if (other == null) return 1;
AST oAST = (AST) other;
if (oAST == null)
return 1;
else
{
if (Id < oAST.Id)
return -1;
else if (Id > oAST.Id)
return +1;
else
return 0;
}
}
/**
* The AST's hash code.
* @return A hash code
**/
public int GetHashCode()
{
return (int)Native.getAstHash(Context.nCtx, NativeObject);
}
/**
* A unique identifier for the AST (unique among all ASTs).
**/
public long Id() { return Native.getAstId(Context.nCtx, NativeObject); }
/**
* Translates (copies) the AST to the Context <paramref name="ctx"/>.
* <param name="ctx">A context</param>
* @return A copy of the AST which is associated with <paramref name="ctx"/>
**/
public AST Translate(Context ctx)
{
if (ReferenceEquals(Context, ctx))
return this;
else
return new AST(ctx, Native.translate(Context.nCtx, NativeObject, ctx.nCtx));
}
/**
* The kind of the AST.
**/
public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context.nCtx, NativeObject); }
/**
* Indicates whether the AST is an Expr
**/
public boolean IsExpr()
{
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;
}
}
/**
* Indicates whether the AST is a BoundVariable
**/
public boolean IsVar() { return this.ASTKind == Z3_ast_kind.Z3_VAR_AST; }
/**
* Indicates whether the AST is a Quantifier
**/
public boolean IsQuantifier() { return this.ASTKind == Z3_ast_kind.Z3_QUANTIFIER_AST; }
/**
* Indicates whether the AST is a Sort
**/
public boolean IsSort() { return this.ASTKind == Z3_ast_kind.Z3_SORT_AST; }
/**
* Indicates whether the AST is a FunctionDeclaration
**/
public boolean IsFuncDecl() { return this.ASTKind == Z3_ast_kind.Z3_FUNC_DECL_AST; }
/**
* A string representation of the AST.
**/
public String toString()
{
return Native.asttoString(Context.nCtx, NativeObject);
}
/**
* A string representation of the AST in s-expression notation.
**/
public String SExpr()
{
return Native.asttoString(Context.nCtx, NativeObject);
}
AST(Context ctx) { super(ctx); }
AST(Context ctx, IntPtr obj) { super(ctx, obj); }
class DecRefQueue extends Z3.DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj)
{
Native.incRef(ctx.nCtx, obj);
}
public void DecRef(Context ctx, IntPtr obj)
{
Native.decRef(ctx.nCtx, obj);
}
};
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);
super.IncRef(o);
}
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);
super.DecRef(o);
}
static AST Create(Context ctx, IntPtr obj)
{
switch ((Z3_ast_kind)Native.getAstKind(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");
}
}
}

View file

@ -1,127 +0,0 @@
/**
* This file was automatically generated from ASTMap.cs
**/
package com.Microsoft.Z3;
/* using System; */
/**
* Map from AST to AST
**/
class ASTMap extends Z3Object
{
/**
* Checks whether the map contains the key <paramref name="k"/>.
* <param name="k">An AST</param>
* @return True if <paramref name="k"/> is a key in the map, false otherwise.
**/
public boolean Contains(AST k)
{
return Native.astMapContains(Context.nCtx, NativeObject, k.NativeObject) != 0;
}
/**
* Finds the value associated with the key <paramref name="k"/>.
* <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)
{
return new AST(Context, Native.astMapFind(Context.nCtx, NativeObject, k.NativeObject));
}
/**
* Stores or replaces a new key/value pair in the map.
* <param name="k">The key AST</param>
* <param name="v">The value AST</param>
**/
public void Insert(AST k, AST v)
{
Native.astMapInsert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject);
}
/**
* Erases the key <paramref name="k"/> from the map.
* <param name="k">An AST</param>
**/
public void Erase(AST k)
{
Native.astMapErase(Context.nCtx, NativeObject, k.NativeObject);
}
/**
* Removes all keys from the map.
**/
public void Reset()
{
Native.astMapReset(Context.nCtx, NativeObject);
}
/**
* The size of the map
**/
public long Size() { return Native.astMapSize(Context.nCtx, NativeObject); }
/**
* The keys stored in the map.
**/
public ASTVector Keys()
{
return new ASTVector(Context, Native.astMapKeys(Context.nCtx, NativeObject));
}
/**
* Retrieves a string representation of the map.
**/
public String toString()
{
return Native.astMaptoString(Context.nCtx, NativeObject);
}
ASTMap(Context ctx, IntPtr obj)
{ super(ctx, obj);
}
ASTMap(Context ctx)
{ super(ctx, Native.mkAstMap(ctx.nCtx));
}
class DecRefQueue extends Z3.DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj)
{
Native.astMapIncRef(ctx.nCtx, obj);
}
public void DecRef(Context ctx, IntPtr obj)
{
Native.astMapDecRef(ctx.nCtx, obj);
}
};
void IncRef(IntPtr o)
{
Context.ASTMap_DRQ.IncAndClear(Context, o);
super.IncRef(o);
}
void DecRef(IntPtr o)
{
Context.ASTMap_DRQ.Add(o);
super.DecRef(o);
}
}

View file

@ -1,107 +0,0 @@
/**
* This file was automatically generated from ASTVector.cs
**/
package com.Microsoft.Z3;
/* using System; */
/**
* Vectors of ASTs.
**/
class ASTVector extends Z3Object
{
/**
* The size of the vector
**/
public long Size() { return Native.astVectorSize(Context.nCtx, NativeObject); }
/**
* Retrieves the i-th object in the vector.
* <remarks>May throw an IndexOutOfBoundsException when <paramref name="i"/> is out of range.</remarks>
* <param name="i">Index</param>
* @return An AST
**/
public AST get(long i)
{
return new AST(Context, Native.astVectorGet(Context.nCtx, NativeObject, i));
}
public void set(long i, AST value)
{
Native.astVectorSet(Context.nCtx, NativeObject, i, value.NativeObject);
}
/**
* Resize the vector to <paramref name="newSize"/>.
* <param name="newSize">The new size of the vector.</param>
**/
public void Resize(long newSize)
{
Native.astVectorResize(Context.nCtx, NativeObject, newSize);
}
/**
* Add the AST <paramref name="a"/> to the back of the vector. The size
* is increased by 1.
* <param name="a">An AST</param>
**/
public void Push(AST a)
{
Native.astVectorPush(Context.nCtx, NativeObject, a.NativeObject);
}
/**
* Translates all ASTs in the vector to <paramref name="ctx"/>.
* <param name="ctx">A context</param>
* @return A new ASTVector
**/
public ASTVector Translate(Context ctx)
{
return new ASTVector(Context, Native.astVectorTranslate(Context.nCtx, NativeObject, ctx.nCtx));
}
/**
* Retrieves a string representation of the vector.
**/
public String toString()
{
return Native.astVectortoString(Context.nCtx, NativeObject);
}
ASTVector(Context ctx, IntPtr obj) { super(ctx, obj); }
ASTVector(Context ctx) { super(ctx, Native.mkAstVector(ctx.nCtx)); }
class DecRefQueue extends Z3.DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj)
{
Native.astVectorIncRef(ctx.nCtx, obj);
}
public void DecRef(Context ctx, IntPtr obj)
{
Native.astVectorDecRef(ctx.nCtx, obj);
}
};
void IncRef(IntPtr o)
{
Context.ASTVector_DRQ.IncAndClear(Context, o);
super.IncRef(o);
}
void DecRef(IntPtr o)
{
Context.ASTVector_DRQ.Add(o);
super.DecRef(o);
}
}

View file

@ -1,84 +0,0 @@
/**
* This file was automatically generated from ApplyResult.cs
**/
package com.Microsoft.Z3;
/* using System; */
/**
* ApplyResult objects represent the result of an application of a
* tactic to a goal. It contains the subgoals that were produced.
**/
public class ApplyResult extends Z3Object
{
/**
* The number of Subgoals.
**/
public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context.nCtx, NativeObject); }
/**
* Retrieves the subgoals from the ApplyResult.
**/
public Goal[] Subgoals()
{
long n = NumSubgoals;
Goal[] res = new Goal[n];
for (long i = 0; i < n; i++)
res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context.nCtx, NativeObject, i));
return res;
}
/**
* Convert a model for the subgoal <paramref name="i"/> into a model for the original
* goal <code>g</code>, that the ApplyResult was obtained from.
* @return A model for <code>g</code>
**/
public Model ConvertModel(long i, Model m)
{
return new Model(Context, Native.applyResultConvertModel(Context.nCtx, NativeObject, i, m.NativeObject));
}
/**
* A string representation of the ApplyResult.
**/
public String toString()
{
return Native.applyResulttoString(Context.nCtx, NativeObject);
}
ApplyResult(Context ctx, IntPtr obj) { super(ctx, obj);
}
class DecRefQueue extends Z3.DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj)
{
Native.applyResultIncRef(ctx.nCtx, obj);
}
public void DecRef(Context ctx, IntPtr obj)
{
Native.applyResultDecRef(ctx.nCtx, obj);
}
};
void IncRef(IntPtr o)
{
Context.ApplyResult_DRQ.IncAndClear(Context, o);
super.IncRef(o);
}
void DecRef(IntPtr o)
{
Context.ApplyResult_DRQ.Add(o);
super.DecRef(o);
}
}

View file

@ -1,143 +0,0 @@
/**
* This file was automatically generated from Constructor.cs
**/
package com.Microsoft.Z3;
/* using System; */
/**
* Constructors are used for datatype sorts.
**/
public class Constructor extends Z3Object
{
/**
* The number of fields of the constructor.
**/
public long NumFields()
{
init();
return n;
}
/**
* The function declaration of the constructor.
**/
public FuncDecl ConstructorDecl()
{
init();
return m_constructorDecl;
}
/**
* The function declaration of the tester.
**/
public FuncDecl TesterDecl()
{
init();
return m_testerDecl;
}
/**
* The function declarations of the accessors
**/
public FuncDecl[] AccessorDecls()
{
init();
return m_accessorDecls;
}
/**
* Destructor.
**/
protected void finalize()
{
Native.delConstructor(Context.nCtx, NativeObject);
}
private void ObjectInvariant()
{
}
private long n = 0;
private FuncDecl m_testerDecl = null;
private FuncDecl m_constructorDecl = null;
private FuncDecl[] m_accessorDecls = null;
Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames,
Sort[] sorts, long[] sortRefs)
{ super(ctx);
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 long[n];
NativeObject = Native.mkConstructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject,
n,
Symbol.ArrayToNative(fieldNames),
Sort.ArrayToNative(sorts),
sortRefs);
}
private void init()
{
if (m_testerDecl != null) return;
IntPtr constructor = IntPtr.Zero;
IntPtr tester = IntPtr.Zero;
IntPtr[] accessors = new IntPtr[n];
Native.queryConstructor(Context.nCtx, NativeObject, n, constructor, tester, accessors);
m_constructorDecl = new FuncDecl(Context, constructor);
m_testerDecl = new FuncDecl(Context, tester);
m_accessorDecls = new FuncDecl[n];
for (long i = 0; i < n; i++)
m_accessorDecls[i] = new FuncDecl(Context, accessors[i]);
}
}
/**
* Lists of constructors
**/
public class ConstructorList extends Z3Object
{
/**
* Destructor.
**/
protected void finalize()
{
Native.delConstructorList(Context.nCtx, NativeObject);
}
ConstructorList(Context ctx, IntPtr obj)
{ super(ctx, obj);
}
ConstructorList(Context ctx, Constructor[] constructors)
{ super(ctx);
NativeObject = Native.mkConstructorList(Context.nCtx, (long)constructors.Length, Constructor.ArrayToNative(constructors));
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,70 +0,0 @@
/**
* This file was automatically generated from DecRefQUeue.cs
**/
package com.Microsoft.Z3;
/* using System; */
/* using System.Collections; */
/* using System.Collections.Generic; */
/* using System.Threading; */
abstract class DecRefQueue
{
private void ObjectInvariant()
{
}
protected Object m_lock = new Object();
protected List<IntPtr> m_queue = new List<IntPtr>();
final long 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)
{
IncRef(ctx, o);
if (m_queue.Count >= m_move_limit) Clear(ctx);
}
public void Add(IntPtr o)
{
if (o == IntPtr.Zero) return;
synchronized (m_lock)
{
m_queue.Add(o);
}
}
public void Clear(Context ctx)
{
synchronized (m_lock)
{
for (IntPtr.Iterator o = m_queue.iterator(); o.hasNext(); )
DecRef(ctx, o);
m_queue.Clear();
}
}
}
abstract class DecRefQueueContracts extends DecRefQueue
{
public void IncRef(Context ctx, IntPtr obj)
{
}
public void DecRef(Context ctx, IntPtr obj)
{
}
}

Some files were not shown because too many files have changed in this diff Show more