diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 2ff414f78..0f8bea3d1 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -934,8 +934,7 @@ class JavaDLLComponent(Component): def mk_makefile(self, out): if is_java_enabled(): - dllfile = '%s$(SO_EXT)' % self.dll_name - subdir = self.package_name.replace(".","/") + 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') @@ -945,9 +944,8 @@ class JavaDLLComponent(Component): # for java_file in get_java_files((self.src_dir + "/%s/Enumerations") % subdir): # out.write('%s ' % java_file) out.write('\n') - src_wsub = self.to_src_dir + "/" + subdir; - out.write(('\tjavac %s/Enumerations/*.java -d api/java\n' % (src_wsub)).replace("/","\\")) - out.write(('\tjavac -cp api/java %s/*.java -d api/java\n' % (src_wsub)).replace("/","\\")) + 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) @@ -1801,7 +1799,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) diff --git a/scripts/update_api.py b/scripts/update_api.py index 10849aede..da760fbea 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -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,15 +496,11 @@ 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_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') diff --git a/src/api/java/AST.java b/src/api/java/AST.java new file mode 100644 index 000000000..e8017e020 --- /dev/null +++ b/src/api/java/AST.java @@ -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. An AST An + * AST + * + * @return True if and are from + * the same context and represent the same sort; false otherwise. + **/ + /* Overloaded operators are not translated. */ + + /** + * Comparison operator. An AST An + * AST + * + * @return True if and 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. Another AST + * + * @return Negative if the object should be sorted before , 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 . A context + * + * @return A copy of the AST which is associated with + **/ + 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"); + } + } +} diff --git a/src/api/java/ASTDecRefQueue.java b/src/api/java/ASTDecRefQueue.java new file mode 100644 index 000000000..1672dc14c --- /dev/null +++ b/src/api/java/ASTDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/ASTMap.java b/src/api/java/ASTMap.java new file mode 100644 index 000000000..51d4e02bb --- /dev/null +++ b/src/api/java/ASTMap.java @@ -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 . An AST + * + * @return True if 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 . + * This function signs an error when is not a key in + * the map. An AST + * @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. The + * key AST The value AST + **/ + public void Insert(AST k, AST v) + { + + Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), + v.NativeObject()); + } + + /** + * Erases the key from the map. An + * AST + **/ + 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); + } +} diff --git a/src/api/java/ASTVector.java b/src/api/java/ASTVector.java new file mode 100644 index 000000000..7451e93b3 --- /dev/null +++ b/src/api/java/ASTVector.java @@ -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. May throw an + * IndexOutOfBoundsException when is out of + * range. Index + * + * @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 . The new size of the vector. + **/ + public void Resize(int newSize) + { + Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); + } + + /** + * Add the AST to the back of the vector. The size is + * increased by 1. An AST + **/ + public void Push(AST a) + { + + Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); + } + + /** + * Translates all ASTs in the vector to . A context + * + * @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); + } +} diff --git a/src/api/java/AlgebraicNum.java b/src/api/java/AlgebraicNum.java new file mode 100644 index 000000000..2ed2d8315 --- /dev/null +++ b/src/api/java/AlgebraicNum.java @@ -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^. + * the + * precision of the result + * + * @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^. + * + * + * @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. The result + * has at most decimal places. + **/ + public String ToDecimal(int precision) throws Z3Exception + { + + return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(), + precision); + } + + AlgebraicNum(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + + } +} diff --git a/src/api/java/ApplyResult.java b/src/api/java/ApplyResult.java new file mode 100644 index 000000000..afcc3f0f7 --- /dev/null +++ b/src/api/java/ApplyResult.java @@ -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 into a model for the + * original goal g, that the ApplyResult was obtained from. + * + * @return A model for g + * @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); + } +} diff --git a/src/api/java/ApplyResultDecRefQueue.java b/src/api/java/ApplyResultDecRefQueue.java new file mode 100644 index 000000000..98d727522 --- /dev/null +++ b/src/api/java/ApplyResultDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/ArithExpr.java b/src/api/java/ArithExpr.java new file mode 100644 index 000000000..c15cf212e --- /dev/null +++ b/src/api/java/ArithExpr.java @@ -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 + **/ + protected ArithExpr(Context ctx) + { + super(ctx); + } + + ArithExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/ArithSort.java b/src/api/java/ArithSort.java new file mode 100644 index 000000000..bcaf5a88f --- /dev/null +++ b/src/api/java/ArithSort.java @@ -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); + } +}; diff --git a/src/api/java/ArrayExpr.java b/src/api/java/ArrayExpr.java new file mode 100644 index 000000000..7082bc64b --- /dev/null +++ b/src/api/java/ArrayExpr.java @@ -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 + **/ + protected ArrayExpr(Context ctx) + { + super(ctx); + } + + ArrayExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/ArraySort.java b/src/api/java/ArraySort.java new file mode 100644 index 000000000..2b7979468 --- /dev/null +++ b/src/api/java/ArraySort.java @@ -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())); + } +}; diff --git a/src/api/java/AstMapDecRefQueue.java b/src/api/java/AstMapDecRefQueue.java new file mode 100644 index 000000000..a6232866f --- /dev/null +++ b/src/api/java/AstMapDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/AstVectorDecRefQueue.java b/src/api/java/AstVectorDecRefQueue.java new file mode 100644 index 000000000..013cc5351 --- /dev/null +++ b/src/api/java/AstVectorDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/BitVecExpr.java b/src/api/java/BitVecExpr.java new file mode 100644 index 000000000..cd64cfc82 --- /dev/null +++ b/src/api/java/BitVecExpr.java @@ -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 + **/ + protected BitVecExpr(Context ctx) + { + super(ctx); + } + + BitVecExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/BitVecNum.java b/src/api/java/BitVecNum.java new file mode 100644 index 000000000..b1f12fae5 --- /dev/null +++ b/src/api/java/BitVecNum.java @@ -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); + } +} diff --git a/src/api/java/BitVecSort.java b/src/api/java/BitVecSort.java new file mode 100644 index 000000000..8ce31e7bb --- /dev/null +++ b/src/api/java/BitVecSort.java @@ -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); + } +}; diff --git a/src/api/java/BoolExpr.java b/src/api/java/BoolExpr.java new file mode 100644 index 000000000..ddabc81d9 --- /dev/null +++ b/src/api/java/BoolExpr.java @@ -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 + **/ + protected BoolExpr(Context ctx) + { + super(ctx); + } + + /** + * Constructor for BoolExpr + * @throws Z3Exception + **/ + BoolExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/BoolSort.java b/src/api/java/BoolSort.java new file mode 100644 index 000000000..501467bfc --- /dev/null +++ b/src/api/java/BoolSort.java @@ -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())); { }} +}; diff --git a/src/api/java/Constructor.java b/src/api/java/Constructor.java new file mode 100644 index 000000000..146c7daa0 --- /dev/null +++ b/src/api/java/Constructor.java @@ -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]); + } + +} diff --git a/src/api/java/ConstructorList.java b/src/api/java/ConstructorList.java new file mode 100644 index 000000000..a158240eb --- /dev/null +++ b/src/api/java/ConstructorList.java @@ -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))); + } +} diff --git a/src/api/java/Context.java b/src/api/java/Context.java new file mode 100644 index 000000000..f728f1b25 --- /dev/null +++ b/src/api/java/Context.java @@ -0,0 +1,3112 @@ +/** + * This file was automatically generated from Context.cs + * w/ further modifications by: + * @author Christoph M. Wintersteiger (cwinter) + **/ + +package com.Microsoft.Z3; + +import java.util.*; +import com.Microsoft.Z3.Enumerations.*; + +/** + * The main interaction with Z3 happens via the Context. + **/ +public class Context extends IDisposable +{ + /** + * Constructor. + **/ + public Context() throws Z3Exception + { + super(); + m_ctx = Native.mkContextRc(0); + InitContext(); + } + + /** + * Constructor. + **/ + public Context(Map settings) throws Z3Exception + { + super(); + long cfg = Native.mkConfig(); + for (Map.Entry kv : settings.entrySet()) + Native.setParamValue(cfg, kv.getKey(), kv.getValue()); + m_ctx = Native.mkContextRc(cfg); + Native.delConfig(cfg); + InitContext(); + } + + private Context(long ctx, long refCount, Native.errorHandler errh) + { + super(); + this.m_ctx = ctx; + this.m_refCount = refCount; + this.m_n_err_handler = errh; + } + + /** + * Creates a new symbol using an integer. Not all integers can be + * passed to this function. The legal range of unsigned integers is 0 to + * 2^30-1. + **/ + public IntSymbol MkSymbol(int i) throws Z3Exception + { + return new IntSymbol(this, i); + } + + /** + * Create a symbol using a string. + **/ + public StringSymbol MkSymbol(String name) throws Z3Exception + { + return new StringSymbol(this, name); + } + + /** + * Create an array of symbols. + **/ + Symbol[] MkSymbols(String[] names) throws Z3Exception + { + if (names == null) + return null; + Symbol[] result = new Symbol[names.length]; + for (int i = 0; i < names.length; ++i) + result[i] = MkSymbol(names[i]); + return result; + } + + private BoolSort m_boolSort = null; + private IntSort m_intSort = null; + private RealSort m_realSort = null; + + /** + * Retrieves the Boolean sort of the context. + **/ + public BoolSort BoolSort() throws Z3Exception + { + + if (m_boolSort == null) + m_boolSort = new BoolSort(this); + return m_boolSort; + } + + /** + * Retrieves the Integer sort of the context. + **/ + public IntSort IntSort() throws Z3Exception + { + + if (m_intSort == null) + m_intSort = new IntSort(this); + return m_intSort; + } + + /** + * Retrieves the Real sort of the context. + **/ + public RealSort RealSort() + { + return m_realSort; + } + + /** + * Create a new Boolean sort. + **/ + public BoolSort MkBoolSort() throws Z3Exception + { + + return new BoolSort(this); + } + + /** + * Create a new uninterpreted sort. + **/ + public UninterpretedSort MkUninterpretedSort(Symbol s) throws Z3Exception + { + + CheckContextMatch(s); + return new UninterpretedSort(this, s); + } + + /** + * Create a new uninterpreted sort. + **/ + public UninterpretedSort MkUninterpretedSort(String str) throws Z3Exception + { + + return MkUninterpretedSort(MkSymbol(str)); + } + + /** + * Create a new integer sort. + **/ + public IntSort MkIntSort() throws Z3Exception + { + + return new IntSort(this); + } + + /** + * Create a real sort. + **/ + public RealSort MkRealSort() throws Z3Exception + { + + return new RealSort(this); + } + + /** + * Create a new bit-vector sort. + **/ + public BitVecSort MkBitVecSort(int size) throws Z3Exception + { + + return new BitVecSort(this, Native.mkBvSort(nCtx(), size)); + } + + /** + * Create a new array sort. + **/ + public ArraySort MkArraySort(Sort domain, Sort range) throws Z3Exception + { + + CheckContextMatch(domain); + CheckContextMatch(range); + return new ArraySort(this, domain, range); + } + + /** + * Create a new tuple sort. + **/ + public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, + Sort[] fieldSorts) throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(fieldNames); + CheckContextMatch(fieldSorts); + return new TupleSort(this, name, (int) fieldNames.length, fieldNames, + fieldSorts); + } + + /** + * Create a new enumeration sort. + **/ + public EnumSort MkEnumSort(Symbol name, Symbol[] enumNames) + throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(enumNames); + return new EnumSort(this, name, enumNames); + } + + /** + * Create a new enumeration sort. + **/ + public EnumSort MkEnumSort(String name, String[] enumNames) + throws Z3Exception + { + + return new EnumSort(this, MkSymbol(name), MkSymbols(enumNames)); + } + + /** + * Create a new list sort. + **/ + public ListSort MkListSort(Symbol name, Sort elemSort) throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(elemSort); + return new ListSort(this, name, elemSort); + } + + /** + * Create a new list sort. + **/ + public ListSort MkListSort(String name, Sort elemSort) throws Z3Exception + { + + CheckContextMatch(elemSort); + return new ListSort(this, MkSymbol(name), elemSort); + } + + /** + * Create a new finite domain sort. + **/ + public FiniteDomainSort MkFiniteDomainSort(Symbol name, long size) + throws Z3Exception + { + + CheckContextMatch(name); + return new FiniteDomainSort(this, name, size); + } + + /** + * Create a new finite domain sort. + **/ + public FiniteDomainSort MkFiniteDomainSort(String name, long size) + throws Z3Exception + { + + return new FiniteDomainSort(this, MkSymbol(name), size); + } + + /** + * Create a datatype constructor. constructor + * name name of recognizer + * function. names of the constructor + * fields. field sorts, 0 if the field sort + * refers to a recursive sort. reference to + * datatype sort that is an argument to the constructor; if the + * corresponding sort reference is 0, then the value in sort_refs should be + * an index referring to one of the recursive datatypes that is + * declared. + **/ + public Constructor MkConstructor(Symbol name, Symbol recognizer, + Symbol[] fieldNames, Sort[] sorts, int[] sortRefs) + throws Z3Exception + { + + return new Constructor(this, name, recognizer, fieldNames, sorts, + sortRefs); + } + + /** + * Create a datatype constructor. + * + * @return + **/ + public Constructor MkConstructor(String name, String recognizer, + String[] fieldNames, Sort[] sorts, int[] sortRefs) + throws Z3Exception + { + + return new Constructor(this, MkSymbol(name), MkSymbol(recognizer), + MkSymbols(fieldNames), sorts, sortRefs); + } + + /** + * Create a new datatype sort. + **/ + public DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors) + throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(constructors); + return new DatatypeSort(this, name, constructors); + } + + /** + * Create a new datatype sort. + **/ + public DatatypeSort MkDatatypeSort(String name, Constructor[] constructors) + throws Z3Exception + { + + CheckContextMatch(constructors); + return new DatatypeSort(this, MkSymbol(name), constructors); + } + + /** + * Create mutually recursive datatypes. names of + * datatype sorts list of constructors, one list per + * sort. + **/ + public DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c) + throws Z3Exception + { + + CheckContextMatch(names); + int n = (int) names.length; + ConstructorList[] cla = new ConstructorList[n]; + long[] n_constr = new long[n]; + for (int i = 0; i < n; i++) + { + Constructor[] constructor = c[i]; + + CheckContextMatch(constructor); + cla[i] = new ConstructorList(this, constructor); + n_constr[i] = cla[i].NativeObject(); + } + long[] n_res = new long[n]; + Native.mkDatatypes(nCtx(), n, Symbol.ArrayToNative(names), n_res, + n_constr); + DatatypeSort[] res = new DatatypeSort[n]; + for (int i = 0; i < n; i++) + res[i] = new DatatypeSort(this, n_res[i]); + return res; + } + + /** + * Create mutually recursive data-types. + * + * @return + **/ + public DatatypeSort[] MkDatatypeSorts(String[] names, Constructor[][] c) + throws Z3Exception + { + + return MkDatatypeSorts(MkSymbols(names), c); + } + + /** + * Creates a new function declaration. + **/ + public FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range) + throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(domain); + CheckContextMatch(range); + return new FuncDecl(this, name, domain, range); + } + + /** + * Creates a new function declaration. + **/ + public FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range) + throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(domain); + CheckContextMatch(range); + Sort[] q = new Sort[] { domain }; + return new FuncDecl(this, name, q, range); + } + + /** + * Creates a new function declaration. + **/ + public FuncDecl MkFuncDecl(String name, Sort[] domain, Sort range) + throws Z3Exception + { + + CheckContextMatch(domain); + CheckContextMatch(range); + return new FuncDecl(this, MkSymbol(name), domain, range); + } + + /** + * Creates a new function declaration. + **/ + public FuncDecl MkFuncDecl(String name, Sort domain, Sort range) + throws Z3Exception + { + + CheckContextMatch(domain); + CheckContextMatch(range); + Sort[] q = new Sort[] { domain }; + return new FuncDecl(this, MkSymbol(name), q, range); + } + + /** + * Creates a fresh function declaration with a name prefixed with . + **/ + public FuncDecl MkFreshFuncDecl(String prefix, Sort[] domain, Sort range) + throws Z3Exception + { + + CheckContextMatch(domain); + CheckContextMatch(range); + return new FuncDecl(this, prefix, domain, range); + } + + /** + * Creates a new constant function declaration. + **/ + public FuncDecl MkConstDecl(Symbol name, Sort range) throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(range); + return new FuncDecl(this, name, null, range); + } + + /** + * Creates a new constant function declaration. + **/ + public FuncDecl MkConstDecl(String name, Sort range) throws Z3Exception + { + + CheckContextMatch(range); + return new FuncDecl(this, MkSymbol(name), null, range); + } + + /** + * Creates a fresh constant function declaration with a name prefixed with + * . + * + **/ + public FuncDecl MkFreshConstDecl(String prefix, Sort range) + throws Z3Exception + { + + CheckContextMatch(range); + return new FuncDecl(this, prefix, null, range); + } + + /** + * Creates a new bound variable. The de-Bruijn index of + * the variable The sort of the variable + **/ + public Expr MkBound(int index, Sort ty) throws Z3Exception + { + return Expr.Create(this, + Native.mkBound(nCtx(), index, ty.NativeObject())); + } + + /** + * Create a quantifier pattern. + **/ + public Pattern MkPattern(Expr[] terms) throws Z3Exception + { + if (terms.length == 0) + throw new Z3Exception("Cannot create a pattern from zero terms"); + + long[] termsNative = AST.ArrayToNative(terms); + return new Pattern(this, Native.mkPattern(nCtx(), (int) terms.length, + termsNative)); + } + + /** + * Creates a new Constant of sort and named + * . + **/ + public Expr MkConst(Symbol name, Sort range) throws Z3Exception + { + + CheckContextMatch(name); + CheckContextMatch(range); + + return Expr.Create( + this, + Native.mkConst(nCtx(), name.NativeObject(), + range.NativeObject())); + } + + /** + * Creates a new Constant of sort and named + * . + **/ + public Expr MkConst(String name, Sort range) throws Z3Exception + { + + return MkConst(MkSymbol(name), range); + } + + /** + * Creates a fresh Constant of sort and a name + * prefixed with . + **/ + public Expr MkFreshConst(String prefix, Sort range) throws Z3Exception + { + + CheckContextMatch(range); + return Expr.Create(this, + Native.mkFreshConst(nCtx(), prefix, range.NativeObject())); + } + + /** + * Creates a fresh constant from the FuncDecl . A decl of a 0-arity function + **/ + public Expr MkConst(FuncDecl f) throws Z3Exception + { + + return MkApp(f, null); + } + + /** + * Create a Boolean constant. + **/ + public BoolExpr MkBoolConst(Symbol name) throws Z3Exception + { + + return (BoolExpr) MkConst(name, BoolSort()); + } + + /** + * Create a Boolean constant. + **/ + public BoolExpr MkBoolConst(String name) throws Z3Exception + { + + return (BoolExpr) MkConst(MkSymbol(name), BoolSort()); + } + + /** + * Creates an integer constant. + **/ + public IntExpr MkIntConst(Symbol name) throws Z3Exception + { + + return (IntExpr) MkConst(name, IntSort()); + } + + /** + * Creates an integer constant. + **/ + public IntExpr MkIntConst(String name) throws Z3Exception + { + + return (IntExpr) MkConst(name, IntSort()); + } + + /** + * Creates a real constant. + **/ + public RealExpr MkRealConst(Symbol name) throws Z3Exception + { + + return (RealExpr) MkConst(name, RealSort()); + } + + /** + * Creates a real constant. + **/ + public RealExpr MkRealConst(String name) throws Z3Exception + { + + return (RealExpr) MkConst(name, RealSort()); + } + + /** + * Creates a bit-vector constant. + **/ + public BitVecExpr MkBVConst(Symbol name, int size) throws Z3Exception + { + + return (BitVecExpr) MkConst(name, MkBitVecSort(size)); + } + + /** + * Creates a bit-vector constant. + **/ + public BitVecExpr MkBVConst(String name, int size) throws Z3Exception + { + + return (BitVecExpr) MkConst(name, MkBitVecSort(size)); + } + + /** + * Create a new function application. + **/ + public Expr MkApp(FuncDecl f, Expr[] args) throws Z3Exception + { + + CheckContextMatch(f); + CheckContextMatch(args); + return Expr.Create(this, f, args); + } + + /** + * The true Term. + **/ + public BoolExpr MkTrue() throws Z3Exception + { + return new BoolExpr(this, Native.mkTrue(nCtx())); + } + + /** + * The false Term. + **/ + public BoolExpr MkFalse() throws Z3Exception + { + return new BoolExpr(this, Native.mkFalse(nCtx())); + } + + /** + * Creates a Boolean value. + **/ + public BoolExpr MkBool(boolean value) throws Z3Exception + { + return value ? MkTrue() : MkFalse(); + } + + /** + * Creates the equality = . + **/ + public BoolExpr MkEq(Expr x, Expr y) throws Z3Exception + { + CheckContextMatch(x); + CheckContextMatch(y); + return new BoolExpr(this, Native.mkEq(nCtx(), x.NativeObject(), + y.NativeObject())); + } + + /** + * Creates a distinct term. + **/ + public BoolExpr MkDistinct(Expr[] args) throws Z3Exception + { + CheckContextMatch(args); + return new BoolExpr(this, Native.mkDistinct(nCtx(), (int) args.length, + AST.ArrayToNative(args))); + } + + /** + * Mk an expression representing not(a). + **/ + public BoolExpr MkNot(BoolExpr a) throws Z3Exception + { + + CheckContextMatch(a); + return new BoolExpr(this, Native.mkNot(nCtx(), a.NativeObject())); + } + + /** + * Create an expression representing an if-then-else: + * ite(t1, t2, t3). An expression with Boolean + * sort An expression An + * expression with the same sort as + **/ + public Expr MkITE(BoolExpr t1, Expr t2, Expr t3) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + CheckContextMatch(t3); + return Expr.Create( + this, + Native.mkIte(nCtx(), t1.NativeObject(), t2.NativeObject(), + t3.NativeObject())); + } + + /** + * Create an expression representing t1 iff t2. + **/ + public BoolExpr MkIff(BoolExpr t1, BoolExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkIff(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 -> t2. + **/ + public BoolExpr MkImplies(BoolExpr t1, BoolExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkImplies(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 xor t2. + **/ + public BoolExpr MkXor(BoolExpr t1, BoolExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkXor(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t[0] and t[1] and .... + **/ + public BoolExpr MkAnd(BoolExpr[] t) throws Z3Exception + { + + CheckContextMatch(t); + return new BoolExpr(this, Native.mkAnd(nCtx(), (int) t.length, + AST.ArrayToNative(t))); + } + + /** + * Create an expression representing t[0] or t[1] or .... + **/ + public BoolExpr MkOr(BoolExpr[] t) throws Z3Exception + { + + CheckContextMatch(t); + return new BoolExpr(this, Native.mkOr(nCtx(), (int) t.length, + AST.ArrayToNative(t))); + } + + /** + * Create an expression representing t[0] + t[1] + .... + **/ + public ArithExpr MkAdd(ArithExpr[] t) throws Z3Exception + { + + CheckContextMatch(t); + return (ArithExpr) Expr.Create(this, + Native.mkAdd(nCtx(), (int) t.length, AST.ArrayToNative(t))); + } + + /** + * Create an expression representing t[0] * t[1] * .... + **/ + public ArithExpr MkMul(ArithExpr[] t) throws Z3Exception + { + + CheckContextMatch(t); + return (ArithExpr) Expr.Create(this, + Native.mkMul(nCtx(), (int) t.length, AST.ArrayToNative(t))); + } + + /** + * Create an expression representing t[0] - t[1] - .... + **/ + public ArithExpr MkSub(ArithExpr[] t) throws Z3Exception + { + + CheckContextMatch(t); + return (ArithExpr) Expr.Create(this, + Native.mkSub(nCtx(), (int) t.length, AST.ArrayToNative(t))); + } + + /** + * Create an expression representing -t. + **/ + public ArithExpr MkUnaryMinus(ArithExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return (ArithExpr) Expr.Create(this, + Native.mkUnaryMinus(nCtx(), t.NativeObject())); + } + + /** + * Create an expression representing t1 / t2. + **/ + public ArithExpr MkDiv(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return (ArithExpr) Expr.Create(this, + Native.mkDiv(nCtx(), t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create an expression representing t1 mod t2. The + * arguments must have int type. + **/ + public IntExpr MkMod(IntExpr t1, IntExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new IntExpr(this, Native.mkMod(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 rem t2. The + * arguments must have int type. + **/ + public IntExpr MkRem(IntExpr t1, IntExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new IntExpr(this, Native.mkRem(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 ^ t2. + **/ + public ArithExpr MkPower(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return (ArithExpr) Expr.Create(this, + Native.mkPower(nCtx(), t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create an expression representing t1 < t2 + **/ + public BoolExpr MkLt(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkLt(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 <= t2 + **/ + public BoolExpr MkLe(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkLe(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 > t2 + **/ + public BoolExpr MkGt(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkGt(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create an expression representing t1 >= t2 + **/ + public BoolExpr MkGe(ArithExpr t1, ArithExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkGe(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Coerce an integer to a real. There is also a converse operation + * exposed. It follows the semantics prescribed by the SMT-LIB standard. + * + * You can take the floor of a real by creating an auxiliary integer Term + * k and and asserting + * MakeInt2Real(k) <= t1 < MkInt2Real(k)+1. The argument + * must be of integer sort. + **/ + public RealExpr MkInt2Real(IntExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new RealExpr(this, Native.mkInt2real(nCtx(), t.NativeObject())); + } + + /** + * Coerce a real to an integer. The semantics of this function + * follows the SMT-LIB standard for the function to_int. The argument must + * be of real sort. + **/ + public IntExpr MkReal2Int(RealExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new IntExpr(this, Native.mkReal2int(nCtx(), t.NativeObject())); + } + + /** + * Creates an expression that checks whether a real number is an integer. + **/ + public BoolExpr MkIsInteger(RealExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BoolExpr(this, Native.mkIsInt(nCtx(), t.NativeObject())); + } + + /** + * Bitwise negation. The argument must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVNot(BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkBvnot(nCtx(), t.NativeObject())); + } + + /** + * Take conjunction of bits in a vector, return vector of length 1. + * The argument must have a bit-vector sort. + **/ + public BitVecExpr MkBVRedAND(BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkBvredand(nCtx(), t.NativeObject())); + } + + /** + * Take disjunction of bits in a vector, return vector of length 1. + * The argument must have a bit-vector sort. + **/ + public BitVecExpr MkBVRedOR(BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkBvredor(nCtx(), t.NativeObject())); + } + + /** + * Bitwise conjunction. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVAND(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvand(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bitwise disjunction. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVOR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvor(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bitwise XOR. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVXOR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvxor(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bitwise NAND. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVNAND(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvnand(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bitwise NOR. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVNOR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvnor(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bitwise XNOR. The arguments must have a bit-vector + * sort. + **/ + public BitVecExpr MkBVXNOR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvxnor(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Standard two's complement unary minus. The arguments must have a + * bit-vector sort. + **/ + public BitVecExpr MkBVNeg(BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkBvneg(nCtx(), t.NativeObject())); + } + + /** + * Two's complement addition. The arguments must have the same + * bit-vector sort. + **/ + public BitVecExpr MkBVAdd(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvadd(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement subtraction. The arguments must have the same + * bit-vector sort. + **/ + public BitVecExpr MkBVSub(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvsub(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement multiplication. The arguments must have the + * same bit-vector sort. + **/ + public BitVecExpr MkBVMul(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvmul(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned division. It is defined as the floor of + * t1/t2 if \c t2 is different from zero. If t2 is + * zero, then the result is undefined. The arguments must have the same + * bit-vector sort. + **/ + public BitVecExpr MkBVUDiv(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvudiv(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Signed division. It is defined in the following way: + * + * - The \c floor of t1/t2 if \c t2 is different from zero, and + * t1*t2 >= 0. + * + * - The \c ceiling of t1/t2 if \c t2 is different from zero, + * and t1*t2 < 0. + * + * If t2 is zero, then the result is undefined. The arguments + * must have the same bit-vector sort. + **/ + public BitVecExpr MkBVSDiv(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvsdiv(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned remainder. It is defined as + * t1 - (t1 /u t2) * t2, where /u represents + * unsigned division. If t2 is zero, then the result is + * undefined. The arguments must have the same bit-vector sort. + **/ + public BitVecExpr MkBVURem(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvurem(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Signed remainder. It is defined as + * t1 - (t1 /s t2) * t2, where /s represents + * signed division. The most significant bit (sign) of the result is equal + * to the most significant bit of \c t1. + * + * If t2 is zero, then the result is undefined. The arguments + * must have the same bit-vector sort. + **/ + public BitVecExpr MkBVSRem(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvsrem(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement signed remainder (sign follows divisor). If + * t2 is zero, then the result is undefined. The arguments must + * have the same bit-vector sort. + **/ + public BitVecExpr MkBVSMod(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvsmod(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned less-than The arguments must have the same bit-vector + * sort. + **/ + public BoolExpr MkBVULT(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvult(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement signed less-than The arguments must have the + * same bit-vector sort. + **/ + public BoolExpr MkBVSLT(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvslt(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned less-than or equal to. The arguments must have the + * same bit-vector sort. + **/ + public BoolExpr MkBVULE(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvule(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement signed less-than or equal to. The arguments + * must have the same bit-vector sort. + **/ + public BoolExpr MkBVSLE(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvsle(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned greater than or equal to. The arguments must have the + * same bit-vector sort. + **/ + public BoolExpr MkBVUGE(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvuge(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement signed greater than or equal to. The arguments + * must have the same bit-vector sort. + **/ + public BoolExpr MkBVSGE(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvsge(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Unsigned greater-than. The arguments must have the same + * bit-vector sort. + **/ + public BoolExpr MkBVUGT(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvugt(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Two's complement signed greater-than. The arguments must have + * the same bit-vector sort. + **/ + public BoolExpr MkBVSGT(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvsgt(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bit-vector concatenation. The arguments must have a bit-vector + * sort. + * + * @return The result is a bit-vector of size n1+n2, where + * n1 (n2) is the size of t1 + * (t2). + * + **/ + public BitVecExpr MkConcat(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkConcat(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Bit-vector extraction. Extract the bits + * down to from a bitvector of size m to + * yield a new bitvector of size n, where + * n = high - low + 1. The argument must + * have a bit-vector sort. + **/ + public BitVecExpr MkExtract(int high, int low, BitVecExpr t) + throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkExtract(nCtx(), high, low, + t.NativeObject())); + } + + /** + * Bit-vector sign extension. Sign-extends the given bit-vector to + * the (signed) equivalent bitvector of size m+i, where \c m is + * the size of the given bit-vector. The argument must + * have a bit-vector sort. + **/ + public BitVecExpr MkSignExt(int i, BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkSignExt(nCtx(), i, + t.NativeObject())); + } + + /** + * Bit-vector zero extension. Extend the given bit-vector with + * zeros to the (unsigned) equivalent bitvector of size m+i, + * where \c m is the size of the given bit-vector. The argument must have a bit-vector sort. + **/ + public BitVecExpr MkZeroExt(int i, BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkZeroExt(nCtx(), i, + t.NativeObject())); + } + + /** + * Bit-vector repetition. The argument must + * have a bit-vector sort. + **/ + public BitVecExpr MkRepeat(int i, BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, + Native.mkRepeat(nCtx(), i, t.NativeObject())); + } + + /** + * Shift left. It is equivalent to multiplication by + * 2^x where \c x is the value of . + * + * NB. The semantics of shift operations varies between environments. This + * definition does not necessarily capture directly the semantics of the + * programming language or assembly architecture you are modeling. + * + * The arguments must have a bit-vector sort. + **/ + public BitVecExpr MkBVSHL(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvshl(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Logical shift right It is equivalent to unsigned division by + * 2^x where \c x is the value of . + * + * NB. The semantics of shift operations varies between environments. This + * definition does not necessarily capture directly the semantics of the + * programming language or assembly architecture you are modeling. + * + * The arguments must have a bit-vector sort. + **/ + public BitVecExpr MkBVLSHR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvlshr(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Arithmetic shift right It is like logical shift right except + * that the most significant bits of the result always copy the most + * significant bit of the second argument. + * + * NB. The semantics of shift operations varies between environments. This + * definition does not necessarily capture directly the semantics of the + * programming language or assembly architecture you are modeling. + * + * The arguments must have a bit-vector sort. + **/ + public BitVecExpr MkBVASHR(BitVecExpr t1, BitVecExpr t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkBvashr(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Rotate Left. Rotate bits of \c t to the left \c i times. The + * argument must have a bit-vector sort. + **/ + public BitVecExpr MkBVRotateLeft(int i, BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkRotateLeft(nCtx(), i, + t.NativeObject())); + } + + /** + * Rotate Right. Rotate bits of \c t to the right \c i times. The + * argument must have a bit-vector sort. + **/ + public BitVecExpr MkBVRotateRight(int i, BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, Native.mkRotateRight(nCtx(), i, + t.NativeObject())); + } + + /** + * Rotate Left. Rotate bits of to the left + * times. The arguments must have the same bit-vector + * sort. + **/ + public BitVecExpr MkBVRotateLeft(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkExtRotateLeft(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Rotate Right. Rotate bits of to the + * right times. The arguments must have the same + * bit-vector sort. + **/ + public BitVecExpr MkBVRotateRight(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BitVecExpr(this, Native.mkExtRotateRight(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create an bit bit-vector from the integer argument + * . NB. This function is essentially treated + * as uninterpreted. So you cannot expect Z3 to precisely reflect the + * semantics of this function when solving constraints with this function. + * + * The argument must be of integer sort. + **/ + public BitVecExpr MkInt2BV(int n, IntExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BitVecExpr(this, + Native.mkInt2bv(nCtx(), n, t.NativeObject())); + } + + /** + * Create an integer from the bit-vector argument . + * If \c is_signed is false, then the bit-vector \c t1 is treated + * as unsigned. So the result is non-negative and in the range + * [0..2^N-1], where N are the number of bits in . If \c is_signed is true, \c t1 is treated as a signed + * bit-vector. + * + * NB. This function is essentially treated as uninterpreted. So you cannot + * expect Z3 to precisely reflect the semantics of this function when + * solving constraints with this function. + * + * The argument must be of bit-vector sort. + **/ + public IntExpr MkBV2Int(BitVecExpr t, boolean signed) throws Z3Exception + { + + CheckContextMatch(t); + return new IntExpr(this, Native.mkBv2int(nCtx(), t.NativeObject(), + (signed) ? true : false)); + } + + /** + * Create a predicate that checks that the bit-wise addition does not + * overflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, + boolean isSigned) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, + Native.mkBvaddNoOverflow(nCtx(), t1.NativeObject(), + t2.NativeObject(), (isSigned) ? true : false)); + } + + /** + * Create a predicate that checks that the bit-wise addition does not + * underflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVAddNoUnderflow(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvaddNoUnderflow(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create a predicate that checks that the bit-wise subtraction does not + * overflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVSubNoOverflow(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvsubNoOverflow(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create a predicate that checks that the bit-wise subtraction does not + * underflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, + boolean isSigned) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, + Native.mkBvsubNoUnderflow(nCtx(), t1.NativeObject(), + t2.NativeObject(), (isSigned) ? true : false)); + } + + /** + * Create a predicate that checks that the bit-wise signed division does not + * overflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVSDivNoOverflow(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvsdivNoOverflow(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create a predicate that checks that the bit-wise negation does not + * overflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVNegNoOverflow(BitVecExpr t) throws Z3Exception + { + + CheckContextMatch(t); + return new BoolExpr(this, Native.mkBvnegNoOverflow(nCtx(), + t.NativeObject())); + } + + /** + * Create a predicate that checks that the bit-wise multiplication does not + * overflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, + boolean isSigned) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, + Native.mkBvmulNoOverflow(nCtx(), t1.NativeObject(), + t2.NativeObject(), (isSigned) ? true : false)); + } + + /** + * Create a predicate that checks that the bit-wise multiplication does not + * underflow. The arguments must be of bit-vector sort. + **/ + public BoolExpr MkBVMulNoUnderflow(BitVecExpr t1, BitVecExpr t2) + throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new BoolExpr(this, Native.mkBvmulNoUnderflow(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create an array constant. + **/ + public ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range) + throws Z3Exception + { + + return (ArrayExpr) MkConst(name, MkArraySort(domain, range)); + } + + /** + * Create an array constant. + **/ + public ArrayExpr MkArrayConst(String name, Sort domain, Sort range) + throws Z3Exception + { + + return (ArrayExpr) MkConst(MkSymbol(name), MkArraySort(domain, range)); + } + + /** + * Array read. The argument a is the array and + * i is the index of the array that gets read. + * + * The node a must have an array sort + * [domain -> range], and i must have the sort + * domain. The sort of the result is range. + * + **/ + public Expr MkSelect(ArrayExpr a, Expr i) throws Z3Exception + { + + CheckContextMatch(a); + CheckContextMatch(i); + return Expr.Create(this, + Native.mkSelect(nCtx(), a.NativeObject(), i.NativeObject())); + } + + /** + * Array update. The node a must have an array sort + * [domain -> range], i must have sort + * domain, v must have sort range. The sort of the + * result is [domain -> range]. The semantics of this function + * is given by the theory of arrays described in the SMT-LIB standard. See + * http://smtlib.org for more details. The result of this function is an + * array that is equal to a (with respect to + * select) on all indices except for i, where it + * maps to v (and the select of a + * with respect to i may be a different value). + **/ + public ArrayExpr MkStore(ArrayExpr a, Expr i, Expr v) throws Z3Exception + { + + CheckContextMatch(a); + CheckContextMatch(i); + CheckContextMatch(v); + return new ArrayExpr(this, Native.mkStore(nCtx(), a.NativeObject(), + i.NativeObject(), v.NativeObject())); + } + + /** + * Create a constant array. The resulting term is an array, such + * that a selecton an arbitrary index produces the value + * v. + * + **/ + public ArrayExpr MkConstArray(Sort domain, Expr v) throws Z3Exception + { + + CheckContextMatch(domain); + CheckContextMatch(v); + return new ArrayExpr(this, Native.mkConstArray(nCtx(), + domain.NativeObject(), v.NativeObject())); + } + + /** + * Maps f on the argument arrays. Eeach element of + * args must be of an array sort + * [domain_i -> range_i]. The function declaration + * f must have type range_1 .. range_n -> range. + * v must have sort range. The sort of the result is + * [domain_i -> range]. + **/ + public ArrayExpr MkMap(FuncDecl f, ArrayExpr[] args) throws Z3Exception + { + + CheckContextMatch(f); + CheckContextMatch(args); + return (ArrayExpr) Expr.Create(this, Native.mkMap(nCtx(), + f.NativeObject(), AST.ArrayLength(args), + AST.ArrayToNative(args))); + } + + /** + * Access the array default value. Produces the default range + * value, for arrays that can be represented as finite maps with a default + * range value. + **/ + public Expr MkTermArray(ArrayExpr array) throws Z3Exception + { + + CheckContextMatch(array); + return Expr.Create(this, + Native.mkArrayDefault(nCtx(), array.NativeObject())); + } + + /** + * Create a set type. + **/ + public SetSort MkSetSort(Sort ty) throws Z3Exception + { + + CheckContextMatch(ty); + return new SetSort(this, ty); + } + + /** + * Create an empty set. + **/ + public Expr MkEmptySet(Sort domain) throws Z3Exception + { + + CheckContextMatch(domain); + return Expr.Create(this, + Native.mkEmptySet(nCtx(), domain.NativeObject())); + } + + /** + * Create the full set. + **/ + public Expr MkFullSet(Sort domain) throws Z3Exception + { + + CheckContextMatch(domain); + return Expr.Create(this, + Native.mkFullSet(nCtx(), domain.NativeObject())); + } + + /** + * Add an element to the set. + **/ + public Expr MkSetAdd(Expr set, Expr element) throws Z3Exception + { + + CheckContextMatch(set); + CheckContextMatch(element); + return Expr.Create( + this, + Native.mkSetAdd(nCtx(), set.NativeObject(), + element.NativeObject())); + } + + /** + * Remove an element from a set. + **/ + public Expr MkSetDel(Expr set, Expr element) throws Z3Exception + { + + CheckContextMatch(set); + CheckContextMatch(element); + return Expr.Create( + this, + Native.mkSetDel(nCtx(), set.NativeObject(), + element.NativeObject())); + } + + /** + * Take the union of a list of sets. + **/ + public Expr MkSetUnion(Expr[] args) throws Z3Exception + { + + CheckContextMatch(args); + return Expr.Create( + this, + Native.mkSetUnion(nCtx(), (int) args.length, + AST.ArrayToNative(args))); + } + + /** + * Take the intersection of a list of sets. + **/ + public Expr MkSetIntersection(Expr[] args) throws Z3Exception + { + + CheckContextMatch(args); + return Expr.Create( + this, + Native.mkSetIntersect(nCtx(), (int) args.length, + AST.ArrayToNative(args))); + } + + /** + * Take the difference between two sets. + **/ + public Expr MkSetDifference(Expr arg1, Expr arg2) throws Z3Exception + { + + CheckContextMatch(arg1); + CheckContextMatch(arg2); + return Expr.Create( + this, + Native.mkSetDifference(nCtx(), arg1.NativeObject(), + arg2.NativeObject())); + } + + /** + * Take the complement of a set. + **/ + public Expr MkSetComplement(Expr arg) throws Z3Exception + { + + CheckContextMatch(arg); + return Expr.Create(this, + Native.mkSetComplement(nCtx(), arg.NativeObject())); + } + + /** + * Check for set membership. + **/ + public Expr MkSetMembership(Expr elem, Expr set) throws Z3Exception + { + + CheckContextMatch(elem); + CheckContextMatch(set); + return Expr.Create( + this, + Native.mkSetMember(nCtx(), elem.NativeObject(), + set.NativeObject())); + } + + /** + * Check for subsetness of sets. + **/ + public Expr MkSetSubset(Expr arg1, Expr arg2) throws Z3Exception + { + + CheckContextMatch(arg1); + CheckContextMatch(arg2); + return Expr.Create( + this, + Native.mkSetSubset(nCtx(), arg1.NativeObject(), + arg2.NativeObject())); + } + + /** + * Create a Term of a given sort. A string representing the + * Term value in decimal notation. If the given sort is a real, then the + * Term can be a rational, that is, a string of the form + * [num]* / [num]*. The sort of the + * numeral. In the current implementation, the given sort can be an int, + * real, or bit-vectors of arbitrary size. + * + * @return A Term with value and sort + **/ + public Expr MkNumeral(String v, Sort ty) throws Z3Exception + { + + CheckContextMatch(ty); + return Expr + .Create(this, Native.mkNumeral(nCtx(), v, ty.NativeObject())); + } + + /** + * Create a Term of a given sort. This function can be use to create + * numerals that fit in a machine integer. It is slightly faster than + * MakeNumeral since it is not necessary to parse a string. + * Value of the numeral Sort of the + * numeral + * + * @return A Term with value and type + **/ + public Expr MkNumeral(int v, Sort ty) throws Z3Exception + { + + CheckContextMatch(ty); + return Expr.Create(this, Native.mkInt(nCtx(), v, ty.NativeObject())); + } + + /** + * Create a Term of a given sort. This function can be use to create + * numerals that fit in a machine integer. It is slightly faster than + * MakeNumeral since it is not necessary to parse a string. + * Value of the numeral Sort of the + * numeral + * + * @return A Term with value and type + **/ + public Expr MkNumeral(long v, Sort ty) throws Z3Exception + { + + CheckContextMatch(ty); + return Expr.Create(this, Native.mkInt64(nCtx(), v, ty.NativeObject())); + } + + /** + * Create a real from a fraction. numerator of + * rational. denominator of rational. + * + * @return A Term with value / + * and sort Real + **/ + public RatNum MkReal(int num, int den) throws Z3Exception + { + if (den == 0) + throw new Z3Exception("Denominator is zero"); + + return new RatNum(this, Native.mkReal(nCtx(), num, den)); + } + + /** + * Create a real numeral. A string representing the Term + * value in decimal notation. + * + * @return A Term with value and sort Real + **/ + public RatNum MkReal(String v) throws Z3Exception + { + + return new RatNum(this, Native.mkNumeral(nCtx(), v, RealSort() + .NativeObject())); + } + + /** + * Create a real numeral. value of the numeral. + * + * @return A Term with value and sort Real + **/ + public RatNum MkReal(int v) throws Z3Exception + { + + return new RatNum(this, Native.mkInt(nCtx(), v, RealSort() + .NativeObject())); + } + + /** + * Create a real numeral. value of the numeral. + * + * @return A Term with value and sort Real + **/ + public RatNum MkReal(long v) throws Z3Exception + { + + return new RatNum(this, Native.mkInt64(nCtx(), v, RealSort() + .NativeObject())); + } + + /** + * Create an integer numeral. A string representing the Term + * value in decimal notation. + **/ + public IntNum MkInt(String v) throws Z3Exception + { + + return new IntNum(this, Native.mkNumeral(nCtx(), v, IntSort() + .NativeObject())); + } + + /** + * Create an integer numeral. value of the numeral. + * + * @return A Term with value and sort Integer + **/ + public IntNum MkInt(int v) throws Z3Exception + { + + return new IntNum(this, Native.mkInt(nCtx(), v, IntSort() + .NativeObject())); + } + + /** + * Create an integer numeral. value of the numeral. + * + * @return A Term with value and sort Integer + **/ + public IntNum MkInt(long v) throws Z3Exception + { + + return new IntNum(this, Native.mkInt64(nCtx(), v, IntSort() + .NativeObject())); + } + + /** + * Create a bit-vector numeral. A string representing the + * value in decimal notation. the size of the + * bit-vector + **/ + public BitVecNum MkBV(String v, int size) throws Z3Exception + { + + return (BitVecNum) MkNumeral(v, MkBitVecSort(size)); + } + + /** + * Create a bit-vector numeral. value of the + * numeral. the size of the bit-vector + **/ + public BitVecNum MkBV(int v, int size) throws Z3Exception + { + + return (BitVecNum) MkNumeral(v, MkBitVecSort(size)); + } + + /** + * Create a bit-vector numeral. value of the + * numeral. * the size of the bit-vector + **/ + public BitVecNum MkBV(long v, int size) throws Z3Exception + { + + return (BitVecNum) MkNumeral(v, MkBitVecSort(size)); + } + + /** + * Create a universal Quantifier. Creates a forall formula, where + * is the weight, is + * an array of patterns, is an array with the sorts + * of the bound variables, is an array with the + * 'names' of the bound variables, and is the body + * of the quantifier. Quantifiers are associated with weights indicating the + * importance of using the quantifier during instantiation. + * the sorts of the bound variables. names of the bound variables the + * body of the quantifier. quantifiers are + * associated with weights indicating the importance of using the quantifier + * during instantiation. By default, pass the weight 0. array containing the patterns created using + * MkPattern. array containing + * the anti-patterns created using MkPattern. optional symbol to track quantifier. optional symbol to track skolem constants. + **/ + public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, + int weight, Pattern[] patterns, Expr[] noPatterns, + Symbol quantifierID, Symbol skolemID) throws Z3Exception + { + + return new Quantifier(this, true, sorts, names, body, weight, patterns, + noPatterns, quantifierID, skolemID); + } + + /** + * Create a universal Quantifier. + **/ + public Quantifier MkForall(Expr[] boundConstants, Expr body, int weight, + Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, + Symbol skolemID) throws Z3Exception + { + + return new Quantifier(this, true, boundConstants, body, weight, + patterns, noPatterns, quantifierID, skolemID); + } + + /** + * Create an existential Quantifier. + **/ + public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, + int weight, Pattern[] patterns, Expr[] noPatterns, + Symbol quantifierID, Symbol skolemID) throws Z3Exception + { + + return new Quantifier(this, false, sorts, names, body, weight, + patterns, noPatterns, quantifierID, skolemID); + } + + /** + * Create an existential Quantifier. + **/ + public Quantifier MkExists(Expr[] boundConstants, Expr body, int weight, + Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, + Symbol skolemID) throws Z3Exception + { + + return new Quantifier(this, false, boundConstants, body, weight, + patterns, noPatterns, quantifierID, skolemID); + } + + /** + * Create a Quantifier. + **/ + public Quantifier MkQuantifier(boolean universal, Sort[] sorts, + Symbol[] names, Expr body, int weight, Pattern[] patterns, + Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + throws Z3Exception + { + + if (universal) + return MkForall(sorts, names, body, weight, patterns, noPatterns, + quantifierID, skolemID); + else + return MkExists(sorts, names, body, weight, patterns, noPatterns, + quantifierID, skolemID); + } + + /** + * Create a Quantifier. + **/ + public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, + Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, + Symbol quantifierID, Symbol skolemID) throws Z3Exception + { + + if (universal) + return MkForall(boundConstants, body, weight, patterns, noPatterns, + quantifierID, skolemID); + else + return MkExists(boundConstants, body, weight, patterns, noPatterns, + quantifierID, skolemID); + } + + /** + * Selects the format used for pretty-printing expressions. The + * default mode for pretty printing expressions is to produce SMT-LIB style + * output where common subexpressions are printed at each occurrence. The + * mode is called Z3_PRINT_SMTLIB_FULL. To print shared common + * subexpressions only once, use the Z3_PRINT_LOW_LEVEL mode. To print in + * way that conforms to SMT-LIB standards and uses let expressions to share + * common sub-expressions use Z3_PRINT_SMTLIB_COMPLIANT. + **/ + public void setPrintMode(Z3_ast_print_mode value) throws Z3Exception + { + Native.setAstPrintMode(nCtx(), value.toInt()); + } + + /** + * Convert a benchmark into an SMT-LIB formatted string. Name of the benchmark. The argument is optional. + * The benchmark logic. The status string (sat, unsat, or unknown) Other attributes, such as source, difficulty or + * category. Auxiliary + * assumptions. Formula to be checked for + * consistency in conjunction with assumptions. + * + * @return A string representation of the benchmark. + **/ + public String BenchmarkToSMTString(String name, String logic, + String status, String attributes, BoolExpr[] assumptions, + BoolExpr formula) throws Z3Exception + { + + return Native.benchmarkToSmtlibString(nCtx(), name, logic, status, + attributes, (int) assumptions.length, + AST.ArrayToNative(assumptions), formula.NativeObject()); + } + + /** + * Parse the given string using the SMT-LIB parser. The symbol + * table of the parser can be initialized using the given sorts and + * declarations. The symbols in the arrays and + * don't need to match the names of the sorts + * and declarations in the arrays and . This is a useful feature since we can use arbitrary names + * to reference sorts and declarations. + **/ + public void ParseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, + Symbol[] declNames, FuncDecl[] decls) throws Z3Exception + { + int csn = Symbol.ArrayLength(sortNames); + int cs = Sort.ArrayLength(sorts); + int cdn = Symbol.ArrayLength(declNames); + int cd = AST.ArrayLength(decls); + if (csn != cs || cdn != cd) + throw new Z3Exception("Argument size mismatch"); + Native.parseSmtlibString(nCtx(), str, AST.ArrayLength(sorts), + Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), + AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), + AST.ArrayToNative(decls)); + } + + /** + * Parse the given file using the SMT-LIB parser. + **/ + public void ParseSMTLIBFile(String fileName, Symbol[] sortNames, + Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) + throws Z3Exception + { + int csn = Symbol.ArrayLength(sortNames); + int cs = Sort.ArrayLength(sorts); + int cdn = Symbol.ArrayLength(declNames); + int cd = AST.ArrayLength(decls); + if (csn != cs || cdn != cd) + throw new Z3Exception("Argument size mismatch"); + Native.parseSmtlibFile(nCtx(), fileName, AST.ArrayLength(sorts), + Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), + AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), + AST.ArrayToNative(decls)); + } + + /** + * The number of SMTLIB formulas parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public int NumSMTLIBFormulas() throws Z3Exception + { + return Native.getSmtlibNumFormulas(nCtx()); + } + + /** + * The formulas parsed by the last call to ParseSMTLIBString or + * ParseSMTLIBFile. + **/ + public BoolExpr[] SMTLIBFormulas() throws Z3Exception + { + + int n = NumSMTLIBFormulas(); + BoolExpr[] res = new BoolExpr[n]; + for (int i = 0; i < n; i++) + res[i] = (BoolExpr) Expr.Create(this, + Native.getSmtlibFormula(nCtx(), i)); + return res; + } + + /** + * The number of SMTLIB assumptions parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public int NumSMTLIBAssumptions() throws Z3Exception + { + return Native.getSmtlibNumAssumptions(nCtx()); + } + + /** + * The assumptions parsed by the last call to ParseSMTLIBString + * or ParseSMTLIBFile. + **/ + public BoolExpr[] SMTLIBAssumptions() throws Z3Exception + { + + int n = NumSMTLIBAssumptions(); + BoolExpr[] res = new BoolExpr[n]; + for (int i = 0; i < n; i++) + res[i] = (BoolExpr) Expr.Create(this, + Native.getSmtlibAssumption(nCtx(), i)); + return res; + } + + /** + * The number of SMTLIB declarations parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public int NumSMTLIBDecls() throws Z3Exception + { + return Native.getSmtlibNumDecls(nCtx()); + } + + /** + * The declarations parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public FuncDecl[] SMTLIBDecls() throws Z3Exception + { + + int n = NumSMTLIBDecls(); + FuncDecl[] res = new FuncDecl[n]; + for (int i = 0; i < n; i++) + res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx(), i)); + return res; + } + + /** + * The number of SMTLIB sorts parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public int NumSMTLIBSorts() throws Z3Exception + { + return Native.getSmtlibNumSorts(nCtx()); + } + + /** + * The declarations parsed by the last call to + * ParseSMTLIBString or ParseSMTLIBFile. + **/ + public Sort[] SMTLIBSorts() throws Z3Exception + { + + int n = NumSMTLIBSorts(); + Sort[] res = new Sort[n]; + for (int i = 0; i < n; i++) + res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx(), i)); + return res; + } + + /** + * Parse the given string using the SMT-LIB2 parser. + * + * @return A conjunction of assertions in the scope (up to push/pop) at the + * end of the string. + **/ + public BoolExpr ParseSMTLIB2String(String str, Symbol[] sortNames, + Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) + throws Z3Exception + { + + int csn = Symbol.ArrayLength(sortNames); + int cs = Sort.ArrayLength(sorts); + int cdn = Symbol.ArrayLength(declNames); + int cd = AST.ArrayLength(decls); + if (csn != cs || cdn != cd) + throw new Z3Exception("Argument size mismatch"); + return (BoolExpr) Expr.Create(this, Native.parseSmtlib2String(nCtx(), + str, AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), + AST.ArrayToNative(sorts), AST.ArrayLength(decls), + Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls))); + } + + /** + * Parse the given file using the SMT-LIB2 parser. + **/ + public BoolExpr ParseSMTLIB2File(String fileName, Symbol[] sortNames, + Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) + throws Z3Exception + { + + int csn = Symbol.ArrayLength(sortNames); + int cs = Sort.ArrayLength(sorts); + int cdn = Symbol.ArrayLength(declNames); + int cd = AST.ArrayLength(decls); + if (csn != cs || cdn != cd) + throw new Z3Exception("Argument size mismatch"); + return (BoolExpr) Expr.Create(this, Native.parseSmtlib2File(nCtx(), + fileName, AST.ArrayLength(sorts), + Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), + AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), + AST.ArrayToNative(decls))); + } + + /** + * Creates a new Goal. Note that the Context must have been + * created with proof generation support if is set + * to true here. Indicates whether model + * generation should be enabled. Indicates + * whether unsat core generation should be enabled. Indicates whether proof generation should be + * enabled. + **/ + public Goal MkGoal(boolean models, boolean unsatCores, boolean proofs) + throws Z3Exception + { + + return new Goal(this, models, unsatCores, proofs); + } + + /** + * Creates a new ParameterSet. + **/ + public Params MkParams() throws Z3Exception + { + + return new Params(this); + } + + /** + * The number of supported tactics. + **/ + public int NumTactics() throws Z3Exception + { + return Native.getNumTactics(nCtx()); + } + + /** + * The names of all supported tactics. + **/ + public String[] TacticNames() throws Z3Exception + { + + int n = NumTactics(); + String[] res = new String[n]; + for (int i = 0; i < n; i++) + res[i] = Native.getTacticName(nCtx(), i); + return res; + } + + /** + * Returns a string containing a description of the tactic with the given + * name. + **/ + public String TacticDescription(String name) throws Z3Exception + { + + return Native.tacticGetDescr(nCtx(), name); + } + + /** + * Creates a new Tactic. + **/ + public Tactic MkTactic(String name) throws Z3Exception + { + + return new Tactic(this, name); + } + + /** + * Create a tactic that applies to a Goal and then + * to every subgoal produced by . + **/ + public Tactic AndThen(Tactic t1, Tactic t2, Tactic[] ts) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + CheckContextMatch(ts); + + long last = 0; + if (ts != null && ts.length > 0) + { + last = ts[ts.length - 1].NativeObject(); + for (int i = ts.length - 2; i >= 0; i--) + last = Native.tacticAndThen(nCtx(), ts[i].NativeObject(), last); + } + if (last != 0) + { + last = Native.tacticAndThen(nCtx(), t2.NativeObject(), last); + return new Tactic(this, Native.tacticAndThen(nCtx(), + t1.NativeObject(), last)); + } else + return new Tactic(this, Native.tacticAndThen(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create a tactic that applies to a Goal and then + * to every subgoal produced by . + * Shorthand for AndThen. + **/ + public Tactic Then(Tactic t1, Tactic t2, Tactic[] ts) throws Z3Exception + { + + return AndThen(t1, t2, ts); + } + + /** + * Create a tactic that first applies to a Goal and if + * it fails then returns the result of applied to the + * Goal. + **/ + public Tactic OrElse(Tactic t1, Tactic t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new Tactic(this, Native.tacticOrElse(nCtx(), t1.NativeObject(), + t2.NativeObject())); + } + + /** + * Create a tactic that applies to a goal for milliseconds. If does not + * terminate within milliseconds, then it fails. + * + **/ + public Tactic TryFor(Tactic t, int ms) throws Z3Exception + { + + CheckContextMatch(t); + return new Tactic(this, Native.tacticTryFor(nCtx(), t.NativeObject(), + ms)); + } + + /** + * Create a tactic that applies to a given goal if the + * probe evaluates to true. If evaluates to false, then the new tactic behaves like the + * skip tactic. + **/ + public Tactic When(Probe p, Tactic t) throws Z3Exception + { + + CheckContextMatch(t); + CheckContextMatch(p); + return new Tactic(this, Native.tacticWhen(nCtx(), p.NativeObject(), + t.NativeObject())); + } + + /** + * Create a tactic that applies to a given goal if the + * probe evaluates to true and + * otherwise. + **/ + public Tactic Cond(Probe p, Tactic t1, Tactic t2) throws Z3Exception + { + + CheckContextMatch(p); + CheckContextMatch(t1); + CheckContextMatch(t2); + return new Tactic(this, Native.tacticCond(nCtx(), p.NativeObject(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Create a tactic that keeps applying until the goal + * is not modified anymore or the maximum number of iterations is reached. + **/ + public Tactic Repeat(Tactic t, int max) throws Z3Exception + { + + CheckContextMatch(t); + return new Tactic(this, Native.tacticRepeat(nCtx(), t.NativeObject(), + max)); + } + + /** + * Create a tactic that just returns the given goal. + **/ + public Tactic Skip() throws Z3Exception + { + + return new Tactic(this, Native.tacticSkip(nCtx())); + } + + /** + * Create a tactic always fails. + **/ + public Tactic Fail() throws Z3Exception + { + + return new Tactic(this, Native.tacticFail(nCtx())); + } + + /** + * Create a tactic that fails if the probe evaluates to + * false. + **/ + public Tactic FailIf(Probe p) throws Z3Exception + { + + CheckContextMatch(p); + return new Tactic(this, Native.tacticFailIf(nCtx(), p.NativeObject())); + } + + /** + * Create a tactic that fails if the goal is not triviall satisfiable (i.e., + * empty) or trivially unsatisfiable (i.e., contains `false'). + **/ + public Tactic FailIfNotDecided() throws Z3Exception + { + + return new Tactic(this, Native.tacticFailIfNotDecided(nCtx())); + } + + /** + * Create a tactic that applies using the given set of + * parameters . + **/ + public Tactic UsingParams(Tactic t, Params p) throws Z3Exception + { + + CheckContextMatch(t); + CheckContextMatch(p); + return new Tactic(this, Native.tacticUsingParams(nCtx(), + t.NativeObject(), p.NativeObject())); + } + + /** + * Create a tactic that applies using the given set of + * parameters . Alias for + * UsingParams + **/ + public Tactic With(Tactic t, Params p) throws Z3Exception + { + + return UsingParams(t, p); + } + + /** + * Create a tactic that applies the given tactics in parallel. + **/ + public Tactic ParOr(Tactic[] t) throws Z3Exception + { + + CheckContextMatch(t); + return new Tactic(this, Native.tacticParOr(nCtx(), + Tactic.ArrayLength(t), Tactic.ArrayToNative(t))); + } + + /** + * Create a tactic that applies to a given goal and + * then to every subgoal produced by . The subgoals are processed in parallel. + **/ + public Tactic ParAndThen(Tactic t1, Tactic t2) throws Z3Exception + { + + CheckContextMatch(t1); + CheckContextMatch(t2); + return new Tactic(this, Native.tacticParAndThen(nCtx(), + t1.NativeObject(), t2.NativeObject())); + } + + /** + * Interrupt the execution of a Z3 procedure. This procedure can be + * used to interrupt: solvers, simplifiers and tactics. + **/ + public void Interrupt() throws Z3Exception + { + Native.interrupt(nCtx()); + } + + /** + * The number of supported Probes. + **/ + public int NumProbes() throws Z3Exception + { + return Native.getNumProbes(nCtx()); + } + + /** + * The names of all supported Probes. + **/ + public String[] ProbeNames() throws Z3Exception + { + + int n = NumProbes(); + String[] res = new String[n]; + for (int i = 0; i < n; i++) + res[i] = Native.getProbeName(nCtx(), i); + return res; + } + + /** + * Returns a string containing a description of the probe with the given + * name. + **/ + public String ProbeDescription(String name) throws Z3Exception + { + + return Native.probeGetDescr(nCtx(), name); + } + + /** + * Creates a new Probe. + **/ + public Probe MkProbe(String name) throws Z3Exception + { + + return new Probe(this, name); + } + + /** + * Create a probe that always evaluates to . + **/ + public Probe Const(double val) throws Z3Exception + { + + return new Probe(this, Native.probeConst(nCtx(), val)); + } + + /** + * Create a probe that evaluates to "true" when the value returned by + * is less than the value returned by + **/ + public Probe Lt(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeLt(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value returned by + * is greater than the value returned by + **/ + public Probe Gt(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeGt(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value returned by + * is less than or equal the value returned by + * + **/ + public Probe Le(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeLe(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value returned by + * is greater than or equal the value returned by + * + **/ + public Probe Ge(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeGe(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value returned by + * is equal to the value returned by + **/ + public Probe Eq(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeEq(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value and evaluate to "true". + **/ + public Probe And(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeAnd(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value or evaluate to "true". + **/ + public Probe Or(Probe p1, Probe p2) throws Z3Exception + { + + CheckContextMatch(p1); + CheckContextMatch(p2); + return new Probe(this, Native.probeOr(nCtx(), p1.NativeObject(), + p2.NativeObject())); + } + + /** + * Create a probe that evaluates to "true" when the value does not evaluate to "true". + **/ + public Probe Not(Probe p) throws Z3Exception + { + + CheckContextMatch(p); + return new Probe(this, Native.probeNot(nCtx(), p.NativeObject())); + } + + /** + * Creates a new (incremental) solver. This solver also uses a set + * of builtin tactics for handling the first check-sat command, and + * check-sat commands that take more than a given number of milliseconds to + * be solved. + **/ + public Solver MkSolver(Symbol logic) throws Z3Exception + { + + if (logic == null) + return new Solver(this, Native.mkSolver(nCtx())); + else + return new Solver(this, Native.mkSolverForLogic(nCtx(), + logic.NativeObject())); + } + + /** + * Creates a new (incremental) solver. + **/ + public Solver MkSolver(String logic) throws Z3Exception + { + + return MkSolver(MkSymbol(logic)); + } + + /** + * Creates a new (incremental) solver. + **/ + public Solver MkSimpleSolver() throws Z3Exception + { + + return new Solver(this, Native.mkSimpleSolver(nCtx())); + } + + /** + * Creates a solver that is implemented using the given tactic. + * The solver supports the commands Push and Pop, + * but it will always solve each check from scratch. + **/ + public Solver MkSolver(Tactic t) throws Z3Exception + { + + return new Solver(this, Native.mkSolverFromTactic(nCtx(), + t.NativeObject())); + } + + /** + * Create a Fixedpoint context. + **/ + public Fixedpoint MkFixedpoint() throws Z3Exception + { + + return new Fixedpoint(this); + } + + /** + * Wraps an AST. This function is used for transitions between + * native and managed objects. Note that + * must be a native object obtained from Z3 (e.g., through ) and that it must have a correct reference count (see + * e.g., . The native pointer to + * wrap. + **/ + public AST WrapAST(long nativeObject) throws Z3Exception + { + + return AST.Create(this, nativeObject); + } + + /** + * Unwraps an AST. This function is used for transitions between + * native and managed objects. It returns the native pointer to the AST. + * Note that AST objects are reference counted and unwrapping an AST + * disables automatic reference counting, i.e., all references to the IntPtr + * that is returned must be handled externally and through native calls (see + * e.g., ). The AST to unwrap. + **/ + public long UnwrapAST(AST a) + { + return a.NativeObject(); + } + + /** + * Return a string describing all available parameters to + * Expr.Simplify. + **/ + public String SimplifyHelp() throws Z3Exception + { + + return Native.simplifyGetHelp(nCtx()); + } + + /** + * Retrieves parameter descriptions for simplifier. + **/ + public ParamDescrs SimplifyParameterDescriptions() throws Z3Exception + { + return new ParamDescrs(this, Native.simplifyGetParamDescrs(nCtx())); + } + + /** + * Enable/disable printing of warning messages to the console. Note + * that this function is static and effects the behaviour of all contexts + * globally. + **/ + public static void ToggleWarningMessages(boolean enabled) + throws Z3Exception + { + Native.toggleWarningMessages((enabled) ? true : false); + } + + // /// + // /// A delegate which is executed when an error is raised. + // /// + // /// + // /// Note that it is possible for memory leaks to occur if error handlers + // /// throw exceptions. + // /// + // public delegate void ErrorHandler(Context ctx, Z3_error_code errorCode, + // String errorString); + + // /// + // /// The OnError event. + // /// + // public event ErrorHandler OnError = null; + + /** + * Update a mutable configuration parameter. The list of all + * configuration parameters can be obtained using the Z3 executable: + * z3.exe -ini? Only a few configuration parameters are mutable + * once the context is created. An exception is thrown when trying to modify + * an immutable parameter. + **/ + public void UpdateParamValue(String id, String value) throws Z3Exception + { + Native.updateParamValue(nCtx(), id, value); + } + + /** + * Get a configuration parameter. Returns null if the parameter + * value does not exist. + **/ + public String GetParamValue(String id) throws Z3Exception + { + Native.StringPtr res = new Native.StringPtr(); + boolean r = Native.getParamValue(nCtx(), id, res); + if (!r) + return null; + else + return res.value; + } + + long m_ctx = 0; + Native.errorHandler m_n_err_handler = null; + + long nCtx() + { + return m_ctx; + } + + // void NativeErrorHandler(long ctx, Z3_error_code errorCode) + // { + // // Do-nothing error handler. The wrappers in Z3.Native will throw + // exceptions upon errors. + // } + + void InitContext() throws Z3Exception + { + setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT); + // m_n_err_handler = new Native.errorHandler(NativeErrorHandler); // + // keep reference so it doesn't get collected. + // if (m_n_err_handler != null) Native.setErrorHandler(m_ctx, + // m_n_err_handler); + } + + void CheckContextMatch(Z3Object other) throws Z3Exception + { + + if (this == other.Context()) + throw new Z3Exception("Context mismatch"); + } + + void CheckContextMatch(Z3Object[] arr) throws Z3Exception + { + + if (arr != null) + { + for (Z3Object a : arr) + { + // It was an assume, now we added the precondition, and we made + // it into an assert + CheckContextMatch(a); + } + } + } + + private ASTDecRefQueue m_AST_DRQ = new ASTDecRefQueue(); + private ASTMapDecRefQueue m_ASTMap_DRQ = new ASTMapDecRefQueue(); + private ASTVectorDecRefQueue m_ASTVector_DRQ = new ASTVectorDecRefQueue(); + private ApplyResultDecRefQueue m_ApplyResult_DRQ = new ApplyResultDecRefQueue(); + private FuncInterpEntryDecRefQueue m_FuncEntry_DRQ = new FuncInterpEntryDecRefQueue(); + private FuncInterpDecRefQueue m_FuncInterp_DRQ = new FuncInterpDecRefQueue(); + private GoalDecRefQueue m_Goal_DRQ = new GoalDecRefQueue(); + private ModelDecRefQueue m_Model_DRQ = new ModelDecRefQueue(); + private ParamsDecRefQueue m_Params_DRQ = new ParamsDecRefQueue(); + private ParamDescrsDecRefQueue m_ParamDescrs_DRQ = new ParamDescrsDecRefQueue(); + private ProbeDecRefQueue m_Probe_DRQ = new ProbeDecRefQueue(); + private SolverDecRefQueue m_Solver_DRQ = new SolverDecRefQueue(); + private StatisticsDecRefQueue m_Statistics_DRQ = new StatisticsDecRefQueue(); + private TacticDecRefQueue m_Tactic_DRQ = new TacticDecRefQueue(); + private FixedpointDecRefQueue m_Fixedpoint_DRQ = new FixedpointDecRefQueue(); + + ASTDecRefQueue AST_DRQ() + { + return m_AST_DRQ; + } + + ASTMapDecRefQueue ASTMap_DRQ() + { + return m_ASTMap_DRQ; + } + + ASTVectorDecRefQueue ASTVector_DRQ() + { + return m_ASTVector_DRQ; + } + + ApplyResultDecRefQueue ApplyResult_DRQ() + { + return m_ApplyResult_DRQ; + } + + FuncInterpEntryDecRefQueue FuncEntry_DRQ() + { + return m_FuncEntry_DRQ; + } + + FuncInterpDecRefQueue FuncInterp_DRQ() + { + return m_FuncInterp_DRQ; + } + + GoalDecRefQueue Goal_DRQ() + { + return m_Goal_DRQ; + } + + ModelDecRefQueue Model_DRQ() + { + return m_Model_DRQ; + } + + ParamsDecRefQueue Params_DRQ() + { + return m_Params_DRQ; + } + + ParamDescrsDecRefQueue ParamDescrs_DRQ() + { + return m_ParamDescrs_DRQ; + } + + ProbeDecRefQueue Probe_DRQ() + { + return m_Probe_DRQ; + } + + SolverDecRefQueue Solver_DRQ() + { + return m_Solver_DRQ; + } + + StatisticsDecRefQueue Statistics_DRQ() + { + return m_Statistics_DRQ; + } + + TacticDecRefQueue Tactic_DRQ() + { + return m_Tactic_DRQ; + } + + FixedpointDecRefQueue Fixedpoint_DRQ() + { + return m_Fixedpoint_DRQ; + } + + protected long m_refCount = 0; + + /** + * Finalizer. + **/ + protected void finalize() + { + // Console.WriteLine("Context Finalizer from " + + // System.Threading.Thread.CurrentThread.ManagedThreadId); + Dispose(); + + if (m_refCount == 0) + { + m_n_err_handler = null; + Native.delContext(m_ctx); + m_ctx = 0; + } else + /* re-queue the finalizer */ + new Context(m_ctx, m_refCount, m_n_err_handler); + } + + /** + * Disposes of the context. + **/ + public void Dispose() + { + // Console.WriteLine("Context Dispose from " + + // System.Threading.Thread.CurrentThread.ManagedThreadId); + m_AST_DRQ.Clear(this); + m_ASTMap_DRQ.Clear(this); + m_ASTVector_DRQ.Clear(this); + m_ApplyResult_DRQ.Clear(this); + m_FuncEntry_DRQ.Clear(this); + m_FuncInterp_DRQ.Clear(this); + m_Goal_DRQ.Clear(this); + m_Model_DRQ.Clear(this); + m_Params_DRQ.Clear(this); + m_Probe_DRQ.Clear(this); + m_Solver_DRQ.Clear(this); + m_Statistics_DRQ.Clear(this); + m_Tactic_DRQ.Clear(this); + m_Fixedpoint_DRQ.Clear(this); + + m_boolSort = null; + m_intSort = null; + m_realSort = null; + } +} diff --git a/src/api/java/DatatypeExpr.java b/src/api/java/DatatypeExpr.java new file mode 100644 index 000000000..c29507163 --- /dev/null +++ b/src/api/java/DatatypeExpr.java @@ -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 + **/ + protected DatatypeExpr(Context ctx) + { + super(ctx); + } + + DatatypeExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/DatatypeSort.java b/src/api/java/DatatypeSort.java new file mode 100644 index 000000000..30e9f9d4c --- /dev/null +++ b/src/api/java/DatatypeSort.java @@ -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))); + + } +}; diff --git a/src/api/java/EnumSort.java b/src/api/java/EnumSort.java new file mode 100644 index 000000000..0c4468b9c --- /dev/null +++ b/src/api/java/EnumSort.java @@ -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); + } +}; diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java b/src/api/java/Enumerations/Z3_ast_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java rename to src/api/java/Enumerations/Z3_ast_kind.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java b/src/api/java/Enumerations/Z3_ast_print_mode.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java rename to src/api/java/Enumerations/Z3_ast_print_mode.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java b/src/api/java/Enumerations/Z3_decl_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java rename to src/api/java/Enumerations/Z3_decl_kind.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java b/src/api/java/Enumerations/Z3_error_code.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java rename to src/api/java/Enumerations/Z3_error_code.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java b/src/api/java/Enumerations/Z3_goal_prec.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java rename to src/api/java/Enumerations/Z3_goal_prec.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java b/src/api/java/Enumerations/Z3_lbool.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java rename to src/api/java/Enumerations/Z3_lbool.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java b/src/api/java/Enumerations/Z3_param_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java rename to src/api/java/Enumerations/Z3_param_kind.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java b/src/api/java/Enumerations/Z3_parameter_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java rename to src/api/java/Enumerations/Z3_parameter_kind.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java b/src/api/java/Enumerations/Z3_sort_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java rename to src/api/java/Enumerations/Z3_sort_kind.java diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java b/src/api/java/Enumerations/Z3_symbol_kind.java similarity index 100% rename from src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java rename to src/api/java/Enumerations/Z3_symbol_kind.java diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java new file mode 100644 index 000000000..8442acf6a --- /dev/null +++ b/src/api/java/Expr.java @@ -0,0 +1,1807 @@ +/** + * This file was automatically generated from Expr.cs + * w/ further modifications by: + * @author Christoph M. Wintersteiger (cwinter) + **/ + +package com.Microsoft.Z3; + +import com.Microsoft.Z3.Enumerations.*; + +/* using System; */ + +/** + * Expressions are terms. + **/ +public class Expr extends AST +{ + /** + * Returns a simplified version of the expression. A set of + * parameters to configure the simplifier + **/ + public Expr Simplify(Params p) throws Z3Exception + { + + if (p == null) + return Expr.Create(Context(), + Native.simplify(Context().nCtx(), NativeObject())); + else + return Expr.Create( + Context(), + Native.simplifyEx(Context().nCtx(), NativeObject(), + p.NativeObject())); + } + + /** + * The function declaration of the function that is applied in this + * expression. + **/ + public FuncDecl FuncDecl() throws Z3Exception + { + + return new FuncDecl(Context(), Native.getAppDecl(Context().nCtx(), + NativeObject())); + } + + /** + * Indicates whether the expression is the true or false expression or + * something else (Z3_L_UNDEF). + **/ + public Z3_lbool BoolValue() throws Z3Exception + { + return Z3_lbool.fromInt(Native.getBoolValue(Context().nCtx(), + NativeObject())); + } + + /** + * The number of arguments of the expression. + **/ + public int NumArgs() throws Z3Exception + { + return Native.getAppNumArgs(Context().nCtx(), NativeObject()); + } + + /** + * The arguments of the expression. + **/ + 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.getAppArg(Context().nCtx(), NativeObject(), i)); + return res; + } + + /** + * Update the arguments of the expression using the arguments The number of new arguments should coincide with the + * current number of arguments. + **/ + public void Update(Expr[] args) throws Z3Exception + { + + Context().CheckContextMatch(args); + if (args.length != NumArgs()) + throw new Z3Exception("Number of arguments does not match"); + setNativeObject(Native.updateTerm(Context().nCtx(), NativeObject(), + (int) args.length, Expr.ArrayToNative(args))); + } + + /** + * Substitute every occurrence of from[i] in the expression + * with to[i], for i smaller than + * num_exprs. The result is the new expression. The + * arrays from and to must have size + * num_exprs. For every i smaller than + * num_exprs, we must have that sort of from[i] + * must be equal to sort of to[i]. + **/ + public Expr Substitute(Expr[] from, Expr[] to) throws Z3Exception + { + + Context().CheckContextMatch(from); + Context().CheckContextMatch(to); + if (from.length != to.length) + throw new Z3Exception("Argument sizes do not match"); + return Expr.Create(Context(), Native.substitute(Context().nCtx(), + NativeObject(), (int) from.length, Expr.ArrayToNative(from), + Expr.ArrayToNative(to))); + } + + /** + * Substitute every occurrence of from in the expression with + * to. + **/ + public Expr Substitute(Expr from, Expr to) throws Z3Exception + { + + return Substitute(new Expr[] { from }, new Expr[] { to }); + } + + /** + * Substitute the free variables in the expression with the expressions in + * For every i smaller than + * num_exprs, the variable with de-Bruijn index i + * is replaced with term to[i]. + **/ + public Expr SubstituteVars(Expr[] to) throws Z3Exception + { + + Context().CheckContextMatch(to); + return Expr.Create(Context(), Native.substituteVars(Context().nCtx(), + NativeObject(), (int) to.length, Expr.ArrayToNative(to))); + } + + /** + * Translates (copies) the term to the Context . + * A context + * + * @return A copy of the term which is associated with + **/ + public Expr Translate(Context ctx) throws Z3Exception + { + + if (Context() == ctx) + return this; + else + return Expr.Create( + ctx, + Native.translate(Context().nCtx(), NativeObject(), + ctx.nCtx())); + } + + /** + * Returns a string representation of the expression. + **/ + public String toString() + { + return super.toString(); + } + + /** + * Indicates whether the term is a numeral + **/ + public boolean IsNumeral() throws Z3Exception + { + return Native.isNumeralAst(Context().nCtx(), NativeObject()); + } + + /** + * Indicates whether the term is well-sorted. + * + * @return True if the term is well-sorted, false otherwise. + **/ + public boolean IsWellSorted() throws Z3Exception + { + return Native.isWellSorted(Context().nCtx(), NativeObject()); + } + + /** + * The Sort of the term. + **/ + public Sort Sort() throws Z3Exception + { + return Sort.Create(Context(), + Native.getSort(Context().nCtx(), NativeObject())); + } + + /** + * Indicates whether the term represents a constant. + **/ + public boolean IsConst() throws Z3Exception + { + return IsExpr() && NumArgs() == 0 && FuncDecl().DomainSize() == 0; + } + + /** + * Indicates whether the term is an integer numeral. + **/ + public boolean IsIntNum() throws Z3Exception + { + return IsNumeral() && IsInt(); + } + + /** + * Indicates whether the term is a real numeral. + **/ + public boolean IsRatNum() throws Z3Exception + { + return IsNumeral() && IsReal(); + } + + /** + * Indicates whether the term is an algebraic number + **/ + public boolean IsAlgebraicNumber() throws Z3Exception + { + return Native.isAlgebraicNumber(Context().nCtx(), NativeObject()); + } + + /** + * Indicates whether the term has Boolean sort. + **/ + public boolean IsBool() throws Z3Exception + { + return (IsExpr() && Native.isEqSort(Context().nCtx(), + Native.mkBoolSort(Context().nCtx()), + Native.getSort(Context().nCtx(), NativeObject()))); + } + + /** + * Indicates whether the term is the constant true. + **/ + public boolean IsTrue() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TRUE; + } + + /** + * Indicates whether the term is the constant false. + **/ + public boolean IsFalse() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_FALSE; + } + + /** + * Indicates whether the term is an equality predicate. + **/ + public boolean IsEq() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EQ; + } + + /** + * Indicates whether the term is an n-ary distinct predicate (every argument + * is mutually distinct). + **/ + public boolean IsDistinct() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_DISTINCT; + } + + /** + * Indicates whether the term is a ternary if-then-else term + **/ + public boolean IsITE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ITE; + } + + /** + * Indicates whether the term is an n-ary conjunction + **/ + public boolean IsAnd() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_AND; + } + + /** + * Indicates whether the term is an n-ary disjunction + **/ + public boolean IsOr() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_OR; + } + + /** + * Indicates whether the term is an if-and-only-if (Boolean equivalence, + * binary) + **/ + public boolean IsIff() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IFF; + } + + /** + * Indicates whether the term is an exclusive or + **/ + public boolean IsXor() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_XOR; + } + + /** + * Indicates whether the term is a negation + **/ + public boolean IsNot() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_NOT; + } + + /** + * Indicates whether the term is an implication + **/ + public boolean IsImplies() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IMPLIES; + } + + /** + * Indicates whether the term is of integer sort. + **/ + public boolean IsInt() throws Z3Exception + { + return (Native.isNumeralAst(Context().nCtx(), NativeObject()) && Native + .getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_INT_SORT + .toInt()); + } + + /** + * Indicates whether the term is of sort real. + **/ + public boolean IsReal() throws Z3Exception + { + return Native.getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_REAL_SORT + .toInt(); + } + + /** + * Indicates whether the term is an arithmetic numeral. + **/ + public boolean IsArithmeticNumeral() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ANUM; + } + + /** + * Indicates whether the term is a less-than-or-equal + **/ + public boolean IsLE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LE; + } + + /** + * Indicates whether the term is a greater-than-or-equal + **/ + public boolean IsGE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_GE; + } + + /** + * Indicates whether the term is a less-than + **/ + public boolean IsLT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LT; + } + + /** + * Indicates whether the term is a greater-than + **/ + public boolean IsGT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_GT; + } + + /** + * Indicates whether the term is addition (binary) + **/ + public boolean IsAdd() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ADD; + } + + /** + * Indicates whether the term is subtraction (binary) + **/ + public boolean IsSub() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SUB; + } + + /** + * Indicates whether the term is a unary minus + **/ + public boolean IsUMinus() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UMINUS; + } + + /** + * Indicates whether the term is multiplication (binary) + **/ + public boolean IsMul() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_MUL; + } + + /** + * Indicates whether the term is division (binary) + **/ + public boolean IsDiv() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_DIV; + } + + /** + * Indicates whether the term is integer division (binary) + **/ + public boolean IsIDiv() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IDIV; + } + + /** + * Indicates whether the term is remainder (binary) + **/ + public boolean IsRemainder() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_REM; + } + + /** + * Indicates whether the term is modulus (binary) + **/ + public boolean IsModulus() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_MOD; + } + + /** + * Indicates whether the term is a coercion of integer to real (unary) + **/ + public boolean IsIntToReal() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TO_REAL; + } + + /** + * Indicates whether the term is a coercion of real to integer (unary) + **/ + public boolean IsRealToInt() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TO_INT; + } + + /** + * Indicates whether the term is a check that tests whether a real is + * integral (unary) + **/ + public boolean IsRealIsInt() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IS_INT; + } + + /** + * Indicates whether the term is of an array sort. + **/ + public boolean IsArray() throws Z3Exception + { + return (Native.isApp(Context().nCtx(), NativeObject()) && Z3_sort_kind + .fromInt(Native.getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject()))) == Z3_sort_kind.Z3_ARRAY_SORT); + } + + /** + * Indicates whether the term is an array store. It satisfies + * select(store(a,i,v),j) = if i = j then v else select(a,j). Array store + * takes at least 3 arguments. + **/ + public boolean IsStore() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_STORE; + } + + /** + * Indicates whether the term is an array select. + **/ + public boolean IsSelect() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SELECT; + } + + /** + * Indicates whether the term is a constant array. For example, + * select(const(v),i) = v holds for every v and i. The function is + * unary. + **/ + public boolean IsConstantArray() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CONST_ARRAY; + } + + /** + * Indicates whether the term is a default array. For example + * default(const(v)) = v. The function is unary. + **/ + public boolean IsDefaultArray() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; + } + + /** + * Indicates whether the term is an array map. It satisfies + * map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i. + **/ + public boolean IsArrayMap() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ARRAY_MAP; + } + + /** + * Indicates whether the term is an as-array term. An as-array term + * is n array value that behaves as the function graph of the function + * passed as parameter. + **/ + public boolean IsAsArray() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_AS_ARRAY; + } + + /** + * Indicates whether the term is set union + **/ + public boolean IsSetUnion() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_UNION; + } + + /** + * Indicates whether the term is set intersection + **/ + public boolean IsSetIntersect() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_INTERSECT; + } + + /** + * Indicates whether the term is set difference + **/ + public boolean IsSetDifference() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; + } + + /** + * Indicates whether the term is set complement + **/ + public boolean IsSetComplement() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; + } + + /** + * Indicates whether the term is set subset + **/ + public boolean IsSetSubset() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_SUBSET; + } + + /** + * Indicates whether the terms is of bit-vector sort. + **/ + public boolean IsBV() throws Z3Exception + { + return Native.getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_BV_SORT + .toInt(); + } + + /** + * Indicates whether the term is a bit-vector numeral + **/ + public boolean IsBVNumeral() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNUM; + } + + /** + * Indicates whether the term is a one-bit bit-vector with value one + **/ + public boolean IsBVBitOne() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BIT1; + } + + /** + * Indicates whether the term is a one-bit bit-vector with value zero + **/ + public boolean IsBVBitZero() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BIT0; + } + + /** + * Indicates whether the term is a bit-vector unary minus + **/ + public boolean IsBVUMinus() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNEG; + } + + /** + * Indicates whether the term is a bit-vector addition (binary) + **/ + public boolean IsBVAdd() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BADD; + } + + /** + * Indicates whether the term is a bit-vector subtraction (binary) + **/ + public boolean IsBVSub() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSUB; + } + + /** + * Indicates whether the term is a bit-vector multiplication (binary) + **/ + public boolean IsBVMul() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BMUL; + } + + /** + * Indicates whether the term is a bit-vector signed division (binary) + **/ + public boolean IsBVSDiv() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSDIV; + } + + /** + * Indicates whether the term is a bit-vector unsigned division (binary) + **/ + public boolean IsBVUDiv() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUDIV; + } + + /** + * Indicates whether the term is a bit-vector signed remainder (binary) + **/ + public boolean IsBVSRem() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSREM; + } + + /** + * Indicates whether the term is a bit-vector unsigned remainder (binary) + **/ + public boolean IsBVURem() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUREM; + } + + /** + * Indicates whether the term is a bit-vector signed modulus + **/ + public boolean IsBVSMod() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSMOD; + } + + /** + * Indicates whether the term is a bit-vector signed division by zero + **/ + boolean IsBVSDiv0() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSDIV0; + } + + /** + * Indicates whether the term is a bit-vector unsigned division by zero + **/ + boolean IsBVUDiv0() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUDIV0; + } + + /** + * Indicates whether the term is a bit-vector signed remainder by zero + **/ + boolean IsBVSRem0() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSREM0; + } + + /** + * Indicates whether the term is a bit-vector unsigned remainder by zero + **/ + boolean IsBVURem0() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUREM0; + } + + /** + * Indicates whether the term is a bit-vector signed modulus by zero + **/ + boolean IsBVSMod0() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSMOD0; + } + + /** + * Indicates whether the term is an unsigned bit-vector less-than-or-equal + **/ + public boolean IsBVULE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ULEQ; + } + + /** + * Indicates whether the term is a signed bit-vector less-than-or-equal + **/ + public boolean IsBVSLE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SLEQ; + } + + /** + * Indicates whether the term is an unsigned bit-vector + * greater-than-or-equal + **/ + public boolean IsBVUGE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UGEQ; + } + + /** + * Indicates whether the term is a signed bit-vector greater-than-or-equal + **/ + public boolean IsBVSGE() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SGEQ; + } + + /** + * Indicates whether the term is an unsigned bit-vector less-than + **/ + public boolean IsBVULT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ULT; + } + + /** + * Indicates whether the term is a signed bit-vector less-than + **/ + public boolean IsBVSLT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SLT; + } + + /** + * Indicates whether the term is an unsigned bit-vector greater-than + **/ + public boolean IsBVUGT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UGT; + } + + /** + * Indicates whether the term is a signed bit-vector greater-than + **/ + public boolean IsBVSGT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SGT; + } + + /** + * Indicates whether the term is a bit-wise AND + **/ + public boolean IsBVAND() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BAND; + } + + /** + * Indicates whether the term is a bit-wise OR + **/ + public boolean IsBVOR() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BOR; + } + + /** + * Indicates whether the term is a bit-wise NOT + **/ + public boolean IsBVNOT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNOT; + } + + /** + * Indicates whether the term is a bit-wise XOR + **/ + public boolean IsBVXOR() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BXOR; + } + + /** + * Indicates whether the term is a bit-wise NAND + **/ + public boolean IsBVNAND() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNAND; + } + + /** + * Indicates whether the term is a bit-wise NOR + **/ + public boolean IsBVNOR() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNOR; + } + + /** + * Indicates whether the term is a bit-wise XNOR + **/ + public boolean IsBVXNOR() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BXNOR; + } + + /** + * Indicates whether the term is a bit-vector concatenation (binary) + **/ + public boolean IsBVConcat() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CONCAT; + } + + /** + * Indicates whether the term is a bit-vector sign extension + **/ + public boolean IsBVSignExtension() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SIGN_EXT; + } + + /** + * Indicates whether the term is a bit-vector zero extension + **/ + public boolean IsBVZeroExtension() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ZERO_EXT; + } + + /** + * Indicates whether the term is a bit-vector extraction + **/ + public boolean IsBVExtract() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXTRACT; + } + + /** + * Indicates whether the term is a bit-vector repetition + **/ + public boolean IsBVRepeat() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_REPEAT; + } + + /** + * Indicates whether the term is a bit-vector reduce OR + **/ + public boolean IsBVReduceOR() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BREDOR; + } + + /** + * Indicates whether the term is a bit-vector reduce AND + **/ + public boolean IsBVReduceAND() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BREDAND; + } + + /** + * Indicates whether the term is a bit-vector comparison + **/ + public boolean IsBVComp() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BCOMP; + } + + /** + * Indicates whether the term is a bit-vector shift left + **/ + public boolean IsBVShiftLeft() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSHL; + } + + /** + * Indicates whether the term is a bit-vector logical shift right + **/ + public boolean IsBVShiftRightLogical() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BLSHR; + } + + /** + * Indicates whether the term is a bit-vector arithmetic shift left + **/ + public boolean IsBVShiftRightArithmetic() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BASHR; + } + + /** + * Indicates whether the term is a bit-vector rotate left + **/ + public boolean IsBVRotateLeft() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ROTATE_LEFT; + } + + /** + * Indicates whether the term is a bit-vector rotate right + **/ + public boolean IsBVRotateRight() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; + } + + /** + * Indicates whether the term is a bit-vector rotate left (extended) + * Similar to Z3_OP_ROTATE_LEFT, but it is a binary operator + * instead of a parametric one. + **/ + public boolean IsBVRotateLeftExtended() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; + } + + /** + * Indicates whether the term is a bit-vector rotate right (extended) + * Similar to Z3_OP_ROTATE_RIGHT, but it is a binary operator + * instead of a parametric one. + **/ + public boolean IsBVRotateRightExtended() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; + } + + /** + * Indicates whether the term is a coercion from integer to bit-vector + * This function is not supported by the decision procedures. Only + * the most rudimentary simplification rules are applied to this + * function. + **/ + public boolean IsIntToBV() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_INT2BV; + } + + /** + * Indicates whether the term is a coercion from bit-vector to integer + * This function is not supported by the decision procedures. Only + * the most rudimentary simplification rules are applied to this + * function. + **/ + public boolean IsBVToInt() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BV2INT; + } + + /** + * Indicates whether the term is a bit-vector carry Compute the + * carry bit in a full-adder. The meaning is given by the equivalence (carry + * l1 l2 l3) <=> (or (and l1 l2) (and l1 l3) (and l2 l3))) + **/ + public boolean IsBVCarry() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CARRY; + } + + /** + * Indicates whether the term is a bit-vector ternary XOR The + * meaning is given by the equivalence (xor3 l1 l2 l3) <=> (xor (xor + * l1 l2) l3) + **/ + public boolean IsBVXOR3() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_XOR3; + } + + /** + * Indicates whether the term is a label (used by the Boogie Verification + * condition generator). The label has two parameters, a string and + * a Boolean polarity. It takes one argument, a formula. + **/ + public boolean IsLabel() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LABEL; + } + + /** + * Indicates whether the term is a label literal (used by the Boogie + * Verification condition generator). A label literal has a set of + * string parameters. It takes no arguments. + **/ + public boolean IsLabelLit() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LABEL_LIT; + } + + /** + * Indicates whether the term is a binary equivalence modulo namings. + * This binary predicate is used in proof terms. It captures + * equisatisfiability and equivalence modulo renamings. + **/ + public boolean IsOEQ() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_OEQ; + } + + /** + * Indicates whether the term is a Proof for the expression 'true'. + **/ + public boolean IsProofTrue() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRUE; + } + + /** + * Indicates whether the term is a proof for a fact asserted by the user. + **/ + public boolean IsProofAsserted() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_ASSERTED; + } + + /** + * Indicates whether the term is a proof for a fact (tagged as goal) + * asserted by the user. + **/ + public boolean IsProofGoal() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_GOAL; + } + + /** + * Indicates whether the term is proof via modus ponens Given a + * proof for p and a proof for (implies p q), produces a proof for q. T1: p + * T2: (implies p q) [mp T1 T2]: q The second antecedents may also be a + * proof for (iff p q). + **/ + public boolean IsProofModusPonens() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; + } + + /** + * Indicates whether the term is a proof for (R t t), where R is a reflexive + * relation. This proof object has no antecedents. The only + * reflexive relations that are used are equivalence modulo namings, + * equality and equivalence. That is, R is either '~', '=' or + * 'iff'. + **/ + public boolean IsProofReflexivity() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; + } + + /** + * Indicates whether the term is proof by symmetricity of a relation + * Given an symmetric relation R and a proof for (R t s), produces + * a proof for (R s t). T1: (R t s) [symmetry T1]: (R s t) T1 is the + * antecedent of this proof object. + **/ + public boolean IsProofSymmetry() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_SYMMETRY; + } + + /** + * Indicates whether the term is a proof by transitivity of a relation + * Given a transitive relation R, and proofs for (R t s) and (R s + * u), produces a proof for (R t u). T1: (R t s) T2: (R s u) [trans T1 T2]: + * (R t u) + **/ + public boolean IsProofTransitivity() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; + } + + /** + * Indicates whether the term is a proof by condensed transitivity of a + * relation Condensed transitivity proof. This proof object is + * only used if the parameter PROOF_MODE is 1. It combines several symmetry + * and transitivity proofs. Example: T1: (R a b) T2: (R c b) T3: (R c d) + * [trans* T1 T2 T3]: (R a d) R must be a symmetric and transitive relation. + * + * Assuming that this proof object is a proof for (R s t), then a proof + * checker must check if it is possible to prove (R s t) using the + * antecedents, symmetry and transitivity. That is, if there is a path from + * s to t, if we view every antecedent (R a b) as an edge between a and b. + * + **/ + public boolean IsProofTransitivityStar() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; + } + + /** + * Indicates whether the term is a monotonicity proof object. T1: + * (R t_1 s_1) ... Tn: (R t_n s_n) [monotonicity T1 ... Tn]: (R (f t_1 ... + * t_n) (f s_1 ... s_n)) Remark: if t_i == s_i, then the antecedent Ti is + * suppressed. That is, reflexivity proofs are supressed to save space. + * + **/ + public boolean IsProofMonotonicity() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; + } + + /** + * Indicates whether the term is a quant-intro proof Given a proof + * for (~ p q), produces a proof for (~ (forall (x) p) (forall (x) q)). T1: + * (~ p q) [quant-intro T1]: (~ (forall (x) p) (forall (x) q)) + **/ + public boolean IsProofQuantIntro() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; + } + + /** + * Indicates whether the term is a distributivity proof object. + * Given that f (= or) distributes over g (= and), produces a proof for (= + * (f a (g c d)) (g (f a c) (f a d))) If f and g are associative, this proof + * also justifies the following equality: (= (f (g a b) (g c d)) (g (f a c) + * (f a d) (f b c) (f b d))) where each f and g can have arbitrary number of + * arguments. + * + * This proof object has no antecedents. Remark. This rule is used by the + * CNF conversion pass and instantiated by f = or, and g = and. + **/ + public boolean IsProofDistributivity() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; + } + + /** + * Indicates whether the term is a proof by elimination of AND + * Given a proof for (and l_1 ... l_n), produces a proof for l_i T1: (and + * l_1 ... l_n) [and-elim T1]: l_i + **/ + public boolean IsProofAndElimination() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_AND_ELIM; + } + + /** + * Indicates whether the term is a proof by eliminiation of not-or + * Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). + * T1: (not (or l_1 ... l_n)) [not-or-elim T1]: (not l_i) + **/ + public boolean IsProofOrElimination() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; + } + + /** + * Indicates whether the term is a proof by rewriting A proof for + * a local rewriting step (= t s). The head function symbol of t is + * interpreted. + * + * This proof object has no antecedents. The conclusion of a rewrite rule is + * either an equality (= t s), an equivalence (iff t s), or + * equi-satisfiability (~ t s). Remark: if f is bool, then = is iff. + * + * Examples: (= (+ x 0) x) (= (+ x 1 2) (+ 3 x)) (iff (or x false) x) + * + **/ + public boolean IsProofRewrite() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE; + } + + /** + * Indicates whether the term is a proof by rewriting A proof for + * rewriting an expression t into an expression s. This proof object is used + * if the parameter PROOF_MODE is 1. This proof object can have n + * antecedents. The antecedents are proofs for equalities used as + * substitution rules. The object is also used in a few cases if the + * parameter PROOF_MODE is 2. The cases are: - When applying contextual + * simplification (CONTEXT_SIMPLIFIER=true) - When converting bit-vectors to + * Booleans (BIT2BOOL=true) - When pulling ite expression up + * (PULL_CHEAP_ITE_TREES=true) + **/ + public boolean IsProofRewriteStar() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; + } + + /** + * Indicates whether the term is a proof for pulling quantifiers out. + * A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) + * r))). This proof object has no antecedents. + **/ + public boolean IsProofPullQuant() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; + } + + /** + * Indicates whether the term is a proof for pulling quantifiers out. + * A proof for (iff P Q) where Q is in prenex normal form. This + * proof object is only used if the parameter PROOF_MODE is 1. This proof + * object has no antecedents + **/ + public boolean IsProofPullQuantStar() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; + } + + /** + * Indicates whether the term is a proof for pushing quantifiers in. + * A proof for: (iff (forall (x_1 ... x_m) (and p_1[x_1 ... x_m] + * ... p_n[x_1 ... x_m])) (and (forall (x_1 ... x_m) p_1[x_1 ... x_m]) ... + * (forall (x_1 ... x_m) p_n[x_1 ... x_m]))) This proof object has no + * antecedents + **/ + public boolean IsProofPushQuant() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; + } + + /** + * Indicates whether the term is a proof for elimination of unused + * variables. A proof for (iff (forall (x_1 ... x_n y_1 ... y_m) + * p[x_1 ... x_n]) (forall (x_1 ... x_n) p[x_1 ... x_n])) + * + * It is used to justify the elimination of unused variables. This proof + * object has no antecedents. + **/ + public boolean IsProofElimUnusedVars() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; + } + + /** + * Indicates whether the term is a proof for destructive equality resolution + * A proof for destructive equality resolution: (iff (forall (x) + * (or (not (= x t)) P[x])) P[t]) if x does not occur in t. + * + * This proof object has no antecedents. + * + * Several variables can be eliminated simultaneously. + **/ + public boolean IsProofDER() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DER; + } + + /** + * Indicates whether the term is a proof for quantifier instantiation + * A proof of (or (not (forall (x) (P x))) (P a)) + **/ + public boolean IsProofQuantInst() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INST; + } + + /** + * Indicates whether the term is a hypthesis marker. Mark a + * hypothesis in a natural deduction style proof. + **/ + public boolean IsProofHypothesis() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; + } + + /** + * Indicates whether the term is a proof by lemma T1: false [lemma + * T1]: (or (not l_1) ... (not l_n)) + * + * This proof object has one antecedent: a hypothetical proof for false. It + * converts the proof in a proof for (or (not l_1) ... (not l_n)), when T1 + * contains the hypotheses: l_1, ..., l_n. + **/ + public boolean IsProofLemma() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_LEMMA; + } + + /** + * Indicates whether the term is a proof by unit resolution T1: + * (or l_1 ... l_n l_1' ... l_m') T2: (not l_1) ... T(n+1): (not l_n) + * [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m') + **/ + public boolean IsProofUnitResolution() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; + } + + /** + * Indicates whether the term is a proof by iff-true T1: p + * [iff-true T1]: (iff p true) + **/ + public boolean IsProofIFFTrue() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; + } + + /** + * Indicates whether the term is a proof by iff-false T1: (not p) + * [iff-false T1]: (iff p false) + **/ + public boolean IsProofIFFFalse() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; + } + + /** + * Indicates whether the term is a proof by commutativity [comm]: + * (= (f a b) (f b a)) + * + * f is a commutative operator. + * + * This proof object has no antecedents. Remark: if f is bool, then = is + * iff. + **/ + public boolean IsProofCommutativity() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; + } + + /** + * Indicates whether the term is a proof for Tseitin-like axioms + * Proof object used to justify Tseitin's like axioms: + * + * (or (not (and p q)) p) (or (not (and p q)) q) (or (not (and p q r)) p) + * (or (not (and p q r)) q) (or (not (and p q r)) r) ... (or (and p q) (not + * p) (not q)) (or (not (or p q)) p q) (or (or p q) (not p)) (or (or p q) + * (not q)) (or (not (iff p q)) (not p) q) (or (not (iff p q)) p (not q)) + * (or (iff p q) (not p) (not q)) (or (iff p q) p q) (or (not (ite a b c)) + * (not a) b) (or (not (ite a b c)) a c) (or (ite a b c) (not a) (not b)) + * (or (ite a b c) a (not c)) (or (not (not a)) (not a)) (or (not a) a) + * + * This proof object has no antecedents. Note: all axioms are propositional + * tautologies. Note also that 'and' and 'or' can take multiple arguments. + * You can recover the propositional tautologies by unfolding the Boolean + * connectives in the axioms a small bounded number of steps (=3). + * + **/ + public boolean IsProofDefAxiom() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; + } + + /** + * Indicates whether the term is a proof for introduction of a name + * Introduces a name for a formula/term. Suppose e is an + * expression with free variables x, and def-intro introduces the name n(x). + * The possible cases are: + * + * When e is of Boolean type: [def-intro]: (and (or n (not e)) (or (not n) + * e)) + * + * or: [def-intro]: (or (not n) e) when e only occurs positively. + * + * When e is of the form (ite cond th el): [def-intro]: (and (or (not cond) + * (= n th)) (or cond (= n el))) + * + * Otherwise: [def-intro]: (= n e) + **/ + public boolean IsProofDefIntro() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; + } + + /** + * Indicates whether the term is a proof for application of a definition + * [apply-def T1]: F ~ n F is 'equivalent' to n, given that T1 is + * a proof that n is a name for F. + **/ + public boolean IsProofApplyDef() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; + } + + /** + * Indicates whether the term is a proof iff-oeq T1: (iff p q) + * [iff~ T1]: (~ p q) + **/ + public boolean IsProofIFFOEQ() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; + } + + /** + * Indicates whether the term is a proof for a positive NNF step + * Proof for a (positive) NNF step. Example: + * + * T1: (not s_1) ~ r_1 T2: (not s_2) ~ r_2 T3: s_1 ~ r_1' T4: s_2 ~ r_2' + * [nnf-pos T1 T2 T3 T4]: (~ (iff s_1 s_2) (and (or r_1 r_2') (or r_1' + * r_2))) + * + * The negation normal form steps NNF_POS and NNF_NEG are used in the + * following cases: (a) When creating the NNF of a positive force + * quantifier. The quantifier is retained (unless the bound variables are + * eliminated). Example T1: q ~ q_new [nnf-pos T1]: (~ (forall (x T) q) + * (forall (x T) q_new)) + * + * (b) When recursively creating NNF over Boolean formulas, where the + * top-level connective is changed during NNF conversion. The relevant + * Boolean connectives for NNF_POS are 'implies', 'iff', 'xor', 'ite'. + * NNF_NEG furthermore handles the case where negation is pushed over + * Boolean connectives 'and' and 'or'. + **/ + public boolean IsProofNNFPos() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_POS; + } + + /** + * Indicates whether the term is a proof for a negative NNF step + * Proof for a (negative) NNF step. Examples: + * + * T1: (not s_1) ~ r_1 ... Tn: (not s_n) ~ r_n [nnf-neg T1 ... Tn]: (not + * (and s_1 ... s_n)) ~ (or r_1 ... r_n) and T1: (not s_1) ~ r_1 ... Tn: + * (not s_n) ~ r_n [nnf-neg T1 ... Tn]: (not (or s_1 ... s_n)) ~ (and r_1 + * ... r_n) and T1: (not s_1) ~ r_1 T2: (not s_2) ~ r_2 T3: s_1 ~ r_1' T4: + * s_2 ~ r_2' [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2)) (and (or r_1 + * r_2) (or r_1' r_2'))) + **/ + public boolean IsProofNNFNeg() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_NEG; + } + + /** + * Indicates whether the term is a proof for (~ P Q) here Q is in negation + * normal form. A proof for (~ P Q) where Q is in negation normal + * form. + * + * This proof object is only used if the parameter PROOF_MODE is 1. + * + * This proof object may have n antecedents. Each antecedent is a + * PR_DEF_INTRO. + **/ + public boolean IsProofNNFStar() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_STAR; + } + + /** + * Indicates whether the term is a proof for (~ P Q) where Q is in + * conjunctive normal form. A proof for (~ P Q) where Q is in + * conjunctive normal form. This proof object is only used if the parameter + * PROOF_MODE is 1. This proof object may have n antecedents. Each + * antecedent is a PR_DEF_INTRO. + **/ + public boolean IsProofCNFStar() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_CNF_STAR; + } + + /** + * Indicates whether the term is a proof for a Skolemization step + * Proof for: + * + * [sk]: (~ (not (forall x (p x y))) (not (p (sk y) y))) [sk]: (~ (exists x + * (p x y)) (p (sk y) y)) + * + * This proof object has no antecedents. + **/ + public boolean IsProofSkolemize() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; + } + + /** + * Indicates whether the term is a proof by modus ponens for + * equi-satisfiability. Modus ponens style rule for + * equi-satisfiability. T1: p T2: (~ p q) [mp~ T1 T2]: q + **/ + public boolean IsProofModusPonensOEQ() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; + } + + /** + * Indicates whether the term is a proof for theory lemma Generic + * proof for theory lemmas. + * + * The theory lemma function comes with one or more parameters. The first + * parameter indicates the name of the theory. For the theory of arithmetic, + * additional parameters provide hints for checking the theory lemma. The + * hints for arithmetic are: - farkas - followed by rational coefficients. + * Multiply the coefficients to the inequalities in the lemma, add the + * (negated) inequalities and obtain a contradiction. - triangle-eq - + * Indicates a lemma related to the equivalence: (iff (= t1 t2) (and (<= + * t1 t2) (<= t2 t1))) - gcd-test - Indicates an integer linear + * arithmetic lemma that uses a gcd test. + **/ + public boolean IsProofTheoryLemma() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; + } + + /** + * Indicates whether the term is of an array sort. + **/ + public boolean IsRelation() throws Z3Exception + { + return (Native.isApp(Context().nCtx(), NativeObject()) && Native + .getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_RELATION_SORT + .toInt()); + } + + /** + * Indicates whether the term is an relation store Insert a record + * into a relation. The function takes n+1 arguments, where the + * first argument is the relation and the remaining n elements + * correspond to the n columns of the relation. + **/ + public boolean IsRelationStore() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_STORE; + } + + /** + * Indicates whether the term is an empty relation + **/ + public boolean IsEmptyRelation() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_EMPTY; + } + + /** + * Indicates whether the term is a test for the emptiness of a relation + **/ + public boolean IsIsEmptyRelation() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; + } + + /** + * Indicates whether the term is a relational join + **/ + public boolean IsRelationalJoin() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_JOIN; + } + + /** + * Indicates whether the term is the union or convex hull of two relations. + * The function takes two arguments. + **/ + public boolean IsRelationUnion() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_UNION; + } + + /** + * Indicates whether the term is the widening of two relations The + * function takes two arguments. + **/ + public boolean IsRelationWiden() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_WIDEN; + } + + /** + * Indicates whether the term is a projection of columns (provided as + * numbers in the parameters). The function takes one + * argument. + **/ + public boolean IsRelationProject() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_PROJECT; + } + + /** + * Indicates whether the term is a relation filter Filter + * (restrict) a relation with respect to a predicate. The first argument is + * a relation. The second argument is a predicate with free de-Brujin + * indices corresponding to the columns of the relation. So the first column + * in the relation has index 0. + **/ + public boolean IsRelationFilter() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_FILTER; + } + + /** + * Indicates whether the term is an intersection of a relation with the + * negation of another. Intersect the first relation with respect + * to negation of the second relation (the function takes two arguments). + * Logically, the specification can be described by a function + * + * target = filter_by_negation(pos, neg, columns) + * + * where columns are pairs c1, d1, .., cN, dN of columns from pos and neg, + * such that target are elements in x in pos, such that there is no y in neg + * that agrees with x on the columns c1, d1, .., cN, dN. + **/ + public boolean IsRelationNegationFilter() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; + } + + /** + * Indicates whether the term is the renaming of a column in a relation + * The function takes one argument. The parameters contain the + * renaming as a cycle. + **/ + public boolean IsRelationRename() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_RENAME; + } + + /** + * Indicates whether the term is the complement of a relation + **/ + public boolean IsRelationComplement() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; + } + + /** + * Indicates whether the term is a relational select Check if a + * record is an element of the relation. The function takes n+1 + * arguments, where the first argument is a relation, and the remaining + * n arguments correspond to a record. + **/ + public boolean IsRelationSelect() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_SELECT; + } + + /** + * Indicates whether the term is a relational clone (copy) Create + * a fresh copy (clone) of a relation. The function is logically the + * identity, but in the context of a register machine allows for terms of + * kind to perform destructive updates to + * the first argument. + **/ + public boolean IsRelationClone() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_CLONE; + } + + /** + * Indicates whether the term is of an array sort. + **/ + public boolean IsFiniteDomain() throws Z3Exception + { + return (Native.isApp(Context().nCtx(), NativeObject()) && Native + .getSortKind(Context().nCtx(), + Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT + .toInt()); + } + + /** + * Indicates whether the term is a less than predicate over a finite domain. + **/ + public boolean IsFiniteDomainLT() throws Z3Exception + { + return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_FD_LT; + } + + /** + * The de-Burijn index of a bound variable. Bound variables are + * indexed by de-Bruijn indices. It is perhaps easiest to explain the + * meaning of de-Bruijn indices by indicating the compilation process from + * non-de-Bruijn formulas to de-Bruijn format. + * abs(forall (x1) phi) = forall (x1) abs1(phi, x1, 0) + * abs(forall (x1, x2) phi) = abs(forall (x1) abs(forall (x2) phi)) + * abs1(x, x, n) = b_n + * abs1(y, x, n) = y + * abs1(f(t1,...,tn), x, n) = f(abs1(t1,x,n), ..., abs1(tn,x,n)) + * abs1(forall (x1) phi, x, n) = forall (x1) (abs1(phi, x, n+1)) + * The last line is significant: the index of a bound variable is + * different depending on the scope in which it appears. The deeper x + * appears, the higher is its index. + **/ + public int Index() throws Z3Exception + { + if (!IsVar()) + throw new Z3Exception("Term is not a bound variable."); + + return Native.getIndexValue(Context().nCtx(), NativeObject()); + } + + /** + * Constructor for Expr + **/ + protected Expr(Context ctx) + { + super(ctx); + { + } + } + + /** + * Constructor for Expr + **/ + protected Expr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + { + } + } + + void CheckNativeObject(long obj) throws Z3Exception + { + if (Native.isApp(Context().nCtx(), obj) + ^ true + && Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST + .toInt() + && Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST + .toInt()) + throw new Z3Exception("Underlying object is not a term"); + super.CheckNativeObject(obj); + } + + static Expr Create(Context ctx, FuncDecl f, Expr[] arguments) + throws Z3Exception + { + + long obj = Native.mkApp(ctx.nCtx(), f.NativeObject(), + AST.ArrayLength(arguments), AST.ArrayToNative(arguments)); + return Create(ctx, obj); + } + + static Expr Create(Context ctx, long obj) throws Z3Exception + { + + Z3_ast_kind k = Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)); + if (k == Z3_ast_kind.Z3_QUANTIFIER_AST) + return new Quantifier(ctx, obj); + long s = Native.getSort(ctx.nCtx(), obj); + Z3_sort_kind sk = Z3_sort_kind + .fromInt(Native.getSortKind(ctx.nCtx(), s)); + + if (Native.isAlgebraicNumber(ctx.nCtx(), obj)) // is this a numeral ast? + return new AlgebraicNum(ctx, obj); + + if (Native.isNumeralAst(ctx.nCtx(), obj)) + { + switch (sk) + { + case Z3_INT_SORT: + return new IntNum(ctx, obj); + case Z3_REAL_SORT: + return new RatNum(ctx, obj); + case Z3_BV_SORT: + return new BitVecNum(ctx, obj); + case Z3_UNKNOWN_SORT: + throw new Z3Exception("Unknown Sort"); + default: ; + } + } + + switch (sk) + { + case Z3_BOOL_SORT: + return new BoolExpr(ctx, obj); + case Z3_INT_SORT: + return new IntExpr(ctx, obj); + case Z3_REAL_SORT: + return new RealExpr(ctx, obj); + case Z3_BV_SORT: + return new BitVecExpr(ctx, obj); + case Z3_ARRAY_SORT: + return new ArrayExpr(ctx, obj); + case Z3_DATATYPE_SORT: + return new DatatypeExpr(ctx, obj); + case Z3_UNKNOWN_SORT: + throw new Z3Exception("Unknown Sort"); + default: ; + } + + return new Expr(ctx, obj); + } +} diff --git a/src/api/java/FiniteDomainSort.java b/src/api/java/FiniteDomainSort.java new file mode 100644 index 000000000..f9f3820af --- /dev/null +++ b/src/api/java/FiniteDomainSort.java @@ -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)); + } +} diff --git a/src/api/java/Fixedpoint.java b/src/api/java/Fixedpoint.java new file mode 100644 index 000000000..3ad42c0e9 --- /dev/null +++ b/src/api/java/Fixedpoint.java @@ -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. + **/ + public void Push() + { + Native.fixedpointPush(Context().nCtx(), NativeObject()); + } + + /** + * Backtrack one backtracking point. Note that an exception is + * thrown if Pop is called without a corresponding 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 property about the predicate. The property is added + * at level. + **/ + 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); + } +} diff --git a/src/api/java/FixedpointDecRefQueue.java b/src/api/java/FixedpointDecRefQueue.java new file mode 100644 index 000000000..7ed457bed --- /dev/null +++ b/src/api/java/FixedpointDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/FuncDecl.java b/src/api/java/FuncDecl.java new file mode 100644 index 000000000..79fc457f8 --- /dev/null +++ b/src/api/java/FuncDecl.java @@ -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 and share the + * same context and are equal, false otherwise. + **/ + /* Overloaded operators are not translated. */ + + /** + * Comparison operator. + * + * @return True if and 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 + **/ + 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. + **/ + 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. + **/ + 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. + **/ + 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. + **/ + 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. + **/ + 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. + **/ + 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. + **/ + 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. + * + * @return + **/ + /* operator this[] not translated */ + + /** + * Create expression that applies function to arguments. + * + * @return + **/ + public Expr Apply(Expr[] args) throws Z3Exception + { + + Context().CheckContextMatch(args); + return Expr.Create(Context(), this, args); + } + +} diff --git a/src/api/java/FuncInterp.java b/src/api/java/FuncInterp.java new file mode 100644 index 000000000..8c25508e7 --- /dev/null +++ b/src/api/java/FuncInterp.java @@ -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); + } +} diff --git a/src/api/java/FuncInterpDecRefQueue.java b/src/api/java/FuncInterpDecRefQueue.java new file mode 100644 index 000000000..968a642c8 --- /dev/null +++ b/src/api/java/FuncInterpDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/FuncInterpEntryDecRefQueue.java b/src/api/java/FuncInterpEntryDecRefQueue.java new file mode 100644 index 000000000..8d76f597c --- /dev/null +++ b/src/api/java/FuncInterpEntryDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Goal.java b/src/api/java/Goal.java new file mode 100644 index 000000000..f5d853fd5 --- /dev/null +++ b/src/api/java/Goal.java @@ -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. 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. + * + **/ + 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 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. This tracks how many transformations + * were applied to it. + **/ + 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 . + * @throws Z3Exception + **/ + public Goal Translate(Context ctx) throws Z3Exception + { + return new Goal(ctx, Native.goalTranslate(Context().nCtx(), + NativeObject(), ctx.nCtx())); + } + + /** + * Simplifies the goal. Essentially invokes the `simplify' tactic + * on the goal. + **/ + 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); + } + +} diff --git a/src/api/java/GoalDecRefQueue.java b/src/api/java/GoalDecRefQueue.java new file mode 100644 index 000000000..ac49d2484 --- /dev/null +++ b/src/api/java/GoalDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/IDecRefQueue.java b/src/api/java/IDecRefQueue.java new file mode 100644 index 000000000..1d1ef2c04 --- /dev/null +++ b/src/api/java/IDecRefQueue.java @@ -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 m_queue = new LinkedList(); + 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(); + } + } +} diff --git a/src/api/java/com/Microsoft/Z3/IDisposable.java b/src/api/java/IDisposable.java similarity index 84% rename from src/api/java/com/Microsoft/Z3/IDisposable.java rename to src/api/java/IDisposable.java index e0cbb84f0..ffae8ee33 100644 --- a/src/api/java/com/Microsoft/Z3/IDisposable.java +++ b/src/api/java/IDisposable.java @@ -21,5 +21,7 @@ package com.Microsoft.Z3; public class IDisposable { - public void Dispose() throws Z3Exception {} + public void Dispose() throws Z3Exception + { + } } diff --git a/src/api/java/IntExpr.java b/src/api/java/IntExpr.java new file mode 100644 index 000000000..4b9df2b99 --- /dev/null +++ b/src/api/java/IntExpr.java @@ -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 + **/ + protected IntExpr(Context ctx) throws Z3Exception + { + super(ctx); + } + + IntExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/IntNum.java b/src/api/java/IntNum.java new file mode 100644 index 000000000..7db80c7d9 --- /dev/null +++ b/src/api/java/IntNum.java @@ -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()); + } +} diff --git a/src/api/java/IntSort.java b/src/api/java/IntSort.java new file mode 100644 index 000000000..c07696216 --- /dev/null +++ b/src/api/java/IntSort.java @@ -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())); + } +} diff --git a/src/api/java/IntSymbol.java b/src/api/java/IntSymbol.java new file mode 100644 index 000000000..ca5653b4b --- /dev/null +++ b/src/api/java/IntSymbol.java @@ -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. Throws an exception if the symbol + * is not of int kind. + **/ + 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); + } +} diff --git a/src/api/java/ListSort.java b/src/api/java/ListSort.java new file mode 100644 index 000000000..e00d185ac --- /dev/null +++ b/src/api/java/ListSort.java @@ -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); + } +}; diff --git a/src/api/java/Log.java b/src/api/java/Log.java new file mode 100644 index 000000000..388bc836f --- /dev/null +++ b/src/api/java/Log.java @@ -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. Note that this is a global, static log + * and if multiple Context objects are created, it logs the interaction with all + * of them. + **/ +public final class Log +{ + private boolean m_is_open = false; + + /** + * Open an interaction log file. the name of the file + * to open + * + * @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 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; + } +} diff --git a/src/api/java/Model.java b/src/api/java/Model.java new file mode 100644 index 000000000..e15af9d0f --- /dev/null +++ b/src/api/java/Model.java @@ -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 in + * the model. A Constant + * + * @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 in + * the model. A function declaration of zero arity + * + * @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 in the model. A function declaration of + * non-zero arity + * + * @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 in the current model. + * This function may fail if contains + * quantifiers, is partial (MODEL_PARTIAL enabled), or if is not well-sorted. In this case a + * ModelEvaluationFailedException is thrown. An expression 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. + * + * @return The evaluation of 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 Eval. + * @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. + * 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. + * + * @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 . An + * uninterpreted sort + * + * @return An array of expressions, where each is an element of the universe + * of + * @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); + } +} diff --git a/src/api/java/ModelDecRefQueue.java b/src/api/java/ModelDecRefQueue.java new file mode 100644 index 000000000..52c035914 --- /dev/null +++ b/src/api/java/ModelDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/com/Microsoft/Z3/Native.java b/src/api/java/Native.java similarity index 97% rename from src/api/java/com/Microsoft/Z3/Native.java rename to src/api/java/Native.java index 8acf96cbf..fa326f5cf 100644 --- a/src/api/java/com/Microsoft/Z3/Native.java +++ b/src/api/java/Native.java @@ -5,7 +5,7 @@ public final class Native { public static class LongPtr { public long value; } public static class StringPtr { public String value; } public static class errorHandler { public long ptr; } - static { System.loadLibrary(""); } + static { System.loadLibrary(""); } public static native long mkConfig(); public static native void delConfig(long a0); public static native void setParamValue(long a0, String a1, String a2); @@ -15,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); @@ -41,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); @@ -171,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); @@ -221,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); @@ -253,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); @@ -304,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(); @@ -456,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); @@ -477,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); diff --git a/src/api/java/ParamDescrs.java b/src/api/java/ParamDescrs.java new file mode 100644 index 000000000..ba2ed6e94 --- /dev/null +++ b/src/api/java/ParamDescrs.java @@ -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); + } +} diff --git a/src/api/java/ParamDescrsDecRefQueue.java b/src/api/java/ParamDescrsDecRefQueue.java new file mode 100644 index 000000000..82d76c843 --- /dev/null +++ b/src/api/java/ParamDescrsDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Params.java b/src/api/java/Params.java new file mode 100644 index 000000000..b1bfdd516 --- /dev/null +++ b/src/api/java/Params.java @@ -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); + } +} diff --git a/src/api/java/ParamsDecRefQueue.java b/src/api/java/ParamsDecRefQueue.java new file mode 100644 index 000000000..88e40fb23 --- /dev/null +++ b/src/api/java/ParamsDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Pattern.java b/src/api/java/Pattern.java new file mode 100644 index 000000000..017aead97 --- /dev/null +++ b/src/api/java/Pattern.java @@ -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); + } +} diff --git a/src/api/java/Probe.java b/src/api/java/Probe.java new file mode 100644 index 000000000..a0fcfd3db --- /dev/null +++ b/src/api/java/Probe.java @@ -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 + * Context.NumProbes and Context.ProbeNames. It may + * also be obtained using the command (help-tactics) 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); + } +} diff --git a/src/api/java/ProbeDecRefQueue.java b/src/api/java/ProbeDecRefQueue.java new file mode 100644 index 000000000..2c3cd9783 --- /dev/null +++ b/src/api/java/ProbeDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Quantifier.java b/src/api/java/Quantifier.java new file mode 100644 index 000000000..2b7eba0d9 --- /dev/null +++ b/src/api/java/Quantifier.java @@ -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); + } +} diff --git a/src/api/java/RatNum.java b/src/api/java/RatNum.java new file mode 100644 index 000000000..7a762b361 --- /dev/null +++ b/src/api/java/RatNum.java @@ -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. The result + * has at most decimal places. + **/ + 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); + } +} diff --git a/src/api/java/RealExpr.java b/src/api/java/RealExpr.java new file mode 100644 index 000000000..9f2590fe1 --- /dev/null +++ b/src/api/java/RealExpr.java @@ -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 + **/ + protected RealExpr(Context ctx) + { + super(ctx); + } + + RealExpr(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } +} diff --git a/src/api/java/RealSort.java b/src/api/java/RealSort.java new file mode 100644 index 000000000..0b7f600b2 --- /dev/null +++ b/src/api/java/RealSort.java @@ -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())); + } +} diff --git a/src/api/java/RelationSort.java b/src/api/java/RelationSort.java new file mode 100644 index 000000000..1d0371fd1 --- /dev/null +++ b/src/api/java/RelationSort.java @@ -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); + } +} diff --git a/src/api/java/SetSort.java b/src/api/java/SetSort.java new file mode 100644 index 000000000..c211a597d --- /dev/null +++ b/src/api/java/SetSort.java @@ -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())); + } +} diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java new file mode 100644 index 000000000..613479053 --- /dev/null +++ b/src/api/java/Solver.java @@ -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). + * + **/ + public int NumScopes() + { + return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); + } + + /** + * Creates a backtracking point. + **/ + public void Push() + { + Native.solverPush(Context().nCtx(), NativeObject()); + } + + /** + * Backtracks backtracking points. Note that + * an exception is thrown if is not smaller than + * NumScopes + **/ + public void Pop(int n) + { + Native.solverPop(Context().nCtx(), NativeObject(), n); + } + + /** + * Resets the Solver. This removes all assertions from the + * solver. + **/ + 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. + * + **/ + 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 Check. The result is + * null if Check was not invoked before, if its + * results was not SATISFIABLE, or if model production is not + * enabled. + * @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 Check. The result is + * null if Check was not invoked before, if its + * results was not UNSATISFIABLE, or if proof production is + * disabled. + * @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 Check. The unsat core + * is a subset of Assertions The result is empty if + * Check was not invoked before, if its results was not + * UNSATISFIABLE, or if core production is disabled. + * @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 Check returned + * UNKNOWN. + **/ + 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); + } +} diff --git a/src/api/java/SolverDecRefQueue.java b/src/api/java/SolverDecRefQueue.java new file mode 100644 index 000000000..337c41898 --- /dev/null +++ b/src/api/java/SolverDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Sort.java b/src/api/java/Sort.java new file mode 100644 index 000000000..5cb76e17a --- /dev/null +++ b/src/api/java/Sort.java @@ -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. A Sort A + * Sort + * + * @return True if and are from + * the same context and represent the same sort; false otherwise. + **/ + /* Overloaded operators are not translated. */ + + /** + * Comparison operator. A Sort A + * Sort + * + * @return True if and are not + * from the same context or represent different sorts; false + * otherwise. + **/ + /* Overloaded operators are not translated. */ + + /** + * Equality operator for objects of type Sort. + * + * @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"); + } + } +} diff --git a/src/api/java/Statistics.java b/src/api/java/Statistics.java new file mode 100644 index 000000000..81a75fd48 --- /dev/null +++ b/src/api/java/Statistics.java @@ -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 DoubleEntry or a UIntEntry + **/ + 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. Returns null if + * the key is unknown. + * @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); + } +} diff --git a/src/api/java/StatisticsDecRefQueue.java b/src/api/java/StatisticsDecRefQueue.java new file mode 100644 index 000000000..4337d366d --- /dev/null +++ b/src/api/java/StatisticsDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/Status.java b/src/api/java/Status.java new file mode 100644 index 000000000..4f2d44e9d --- /dev/null +++ b/src/api/java/Status.java @@ -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; + } +} diff --git a/src/api/java/StringSymbol.java b/src/api/java/StringSymbol.java new file mode 100644 index 000000000..34e38c3c9 --- /dev/null +++ b/src/api/java/StringSymbol.java @@ -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. Throws an exception if the + * symbol is not of string kind. + **/ + 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); + } +} diff --git a/src/api/java/Symbol.java b/src/api/java/Symbol.java new file mode 100644 index 000000000..1576e17e1 --- /dev/null +++ b/src/api/java/Symbol.java @@ -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"); + } + } +} diff --git a/src/api/java/Tactic.java b/src/api/java/Tactic.java new file mode 100644 index 000000000..78c19a298 --- /dev/null +++ b/src/api/java/Tactic.java @@ -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 + * Context.NumTactics and Context.TacticNames. It may + * also be obtained using the command (help-tactics) 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. + * @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); + } +} diff --git a/src/api/java/TacticDecRefQueue.java b/src/api/java/TacticDecRefQueue.java new file mode 100644 index 000000000..1b3bd5a03 --- /dev/null +++ b/src/api/java/TacticDecRefQueue.java @@ -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); + } +}; diff --git a/src/api/java/TupleSort.java b/src/api/java/TupleSort.java new file mode 100644 index 000000000..d72d0b128 --- /dev/null +++ b/src/api/java/TupleSort.java @@ -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])); + } +}; diff --git a/src/api/java/UninterpretedSort.java b/src/api/java/UninterpretedSort.java new file mode 100644 index 000000000..4967b73f7 --- /dev/null +++ b/src/api/java/UninterpretedSort.java @@ -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())); + } +} diff --git a/src/api/java/Version.java b/src/api/java/Version.java new file mode 100644 index 000000000..7b20a5ff8 --- /dev/null +++ b/src/api/java/Version.java @@ -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. Note that this class is static. + **/ +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); + } +} diff --git a/src/api/java/Z3Exception.java b/src/api/java/Z3Exception.java new file mode 100644 index 000000000..6de94a5cf --- /dev/null +++ b/src/api/java/Z3Exception.java @@ -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); + } +} diff --git a/src/api/java/Z3Object.java b/src/api/java/Z3Object.java new file mode 100644 index 000000000..522423e01 --- /dev/null +++ b/src/api/java/Z3Object.java @@ -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; + } +} diff --git a/src/api/java/com/Microsoft/Z3/AST.java b/src/api/java/com/Microsoft/Z3/AST.java deleted file mode 100644 index 45e631694..000000000 --- a/src/api/java/com/Microsoft/Z3/AST.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - * This file was automatically generated from AST.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Collections; */ -/* using System.Collections.Generic; */ - - /** - * The abstract syntax tree (AST) class. - **/ - public class AST extends Z3Object - { - /** - * Comparison operator. - * An AST - * An AST - * @return True if and are from the same context - * and represent the same sort; false otherwise. - **/ - /* Overloaded operators are not translated. */ - - /** - * Comparison operator. - * An AST - * An AST - * @return True if and 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. - * Another AST - * @return Negative if the object should be sorted before , 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 int Id() { return Native.getAstId(Context().nCtx(), NativeObject()); } - - /** - * Translates (copies) the AST to the Context . - * A context - * @return A copy of the AST which is associated with - **/ - 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() - { - 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() { 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, long obj) throws Z3Exception { super(ctx, obj); { }} - - class DecRefQueue 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); - } - }; - - 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"); - } - } - } diff --git a/src/api/java/com/Microsoft/Z3/ASTMap.java b/src/api/java/com/Microsoft/Z3/ASTMap.java deleted file mode 100644 index defd7e736..000000000 --- a/src/api/java/com/Microsoft/Z3/ASTMap.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This file was automatically generated from ASTMap.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Map from AST to AST - **/ - class ASTMap extends Z3Object - { - /** - * Checks whether the map contains the key . - * An AST - * @return True if 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 . - * - * This function signs an error when is not a key in the map. - * - * An AST - **/ - 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. - * The key AST - * The value AST - **/ - public void Insert(AST k, AST v) - { - - - - Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), v.NativeObject()); - } - - /** - * Erases the key from the map. - * An AST - **/ - 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. - **/ - 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, long obj) - { super(ctx, obj); - - } - ASTMap(Context ctx) - { super(ctx, Native.mkAstMap(ctx.nCtx())); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().ASTMap_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().ASTMap_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/ASTVector.java b/src/api/java/com/Microsoft/Z3/ASTVector.java deleted file mode 100644 index 83d8173e6..000000000 --- a/src/api/java/com/Microsoft/Z3/ASTVector.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file was automatically generated from ASTVector.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - * May throw an IndexOutOfBoundsException when is out of range. - * Index - * @return An AST - **/ - public AST get(int i) - { - - - 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 . - * The new size of the vector. - **/ - public void Resize(int newSize) - { - Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); - } - - /** - * Add the AST to the back of the vector. The size - * is increased by 1. - * An AST - **/ - public void Push(AST a) - { - - - Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); - } - - /** - * Translates all ASTs in the vector to . - * A context - * @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, long obj) { super(ctx, obj); { }} - ASTVector(Context ctx) { super(ctx, Native.mkAstVector(ctx.nCtx())); { }} - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().ASTVector_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().ASTVector_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/AlgebraicNum.java b/src/api/java/com/Microsoft/Z3/AlgebraicNum.java deleted file mode 100644 index f98ccbce4..000000000 --- a/src/api/java/com/Microsoft/Z3/AlgebraicNum.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This file was automatically generated from AlgebraicNum.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ - -/* using System.Numerics; */ - - /** - * 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^. - * - * the precision of the result - * @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^. - * - * - * @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. - * The result has at most decimal places. - **/ - public String ToDecimal(int precision) throws Z3Exception - { - - - return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(), precision); - } - - AlgebraicNum(Context ctx, long obj) throws Z3Exception - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/ApplyResult.java b/src/api/java/com/Microsoft/Z3/ApplyResult.java deleted file mode 100644 index 016b2f055..000000000 --- a/src/api/java/com/Microsoft/Z3/ApplyResult.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * This file was automatically generated from ApplyResult.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* 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 int NumSubgoals() { return Native.applyResultGetNumSubgoals(Context().nCtx(), NativeObject()); } - - /** - * Retrieves the subgoals from the ApplyResult. - **/ - public Goal[] Subgoals() - { - - - - 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 into a model for the original - * goal g, that the ApplyResult was obtained from. - * @return A model for g - **/ - public Model ConvertModel(int 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, long obj) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().ApplyResult_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().ApplyResult_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/ArithExpr.java b/src/api/java/com/Microsoft/Z3/ArithExpr.java deleted file mode 100644 index fa87bf2f1..000000000 --- a/src/api/java/com/Microsoft/Z3/ArithExpr.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was automatically generated from ArithExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Arithmetic expressions (int/real) - **/ - public class ArithExpr extends Expr - { - /** Constructor for ArithExpr - **/ - protected ArithExpr(Context ctx) - { super(ctx); - - } - ArithExpr(Context ctx, long obj) throws Z3Exception - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/ArithSort.java b/src/api/java/com/Microsoft/Z3/ArithSort.java deleted file mode 100644 index 009112494..000000000 --- a/src/api/java/com/Microsoft/Z3/ArithSort.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was automatically generated from ArithSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * An arithmetic sort, i.e., Int or Real. - **/ - public class ArithSort extends Sort - { - ArithSort(Context ctx, long obj) { super(ctx, obj); { }} - }; diff --git a/src/api/java/com/Microsoft/Z3/ArrayExpr.java b/src/api/java/com/Microsoft/Z3/ArrayExpr.java deleted file mode 100644 index 27495fb64..000000000 --- a/src/api/java/com/Microsoft/Z3/ArrayExpr.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was automatically generated from ArrayExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Array expressions - **/ - public class ArrayExpr extends Expr - { - /** Constructor for ArrayExpr - **/ - protected ArrayExpr(Context ctx) - { super(ctx); - - } - ArrayExpr(Context ctx, long obj) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/ArraySort.java b/src/api/java/com/Microsoft/Z3/ArraySort.java deleted file mode 100644 index b3c5ee7c3..000000000 --- a/src/api/java/com/Microsoft/Z3/ArraySort.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file was automatically generated from ArraySort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Array sorts. - **/ - public class ArraySort extends Sort - { - /** - * The domain of the array sort. - **/ - public Sort Domain() - { - - - return Sort.Create(Context(), Native.getArraySortDomain(Context().nCtx(), NativeObject())); - } - - /** - * The range of the array sort. - **/ - public Sort Range() - { - - - return Sort.Create(Context(), Native.getArraySortRange(Context().nCtx(), NativeObject())); - } - - ArraySort(Context ctx, long obj) { super(ctx, obj); { }} - ArraySort(Context ctx, Sort domain, Sort range) - { super(ctx, Native.mkArraySort(ctx.nCtx(), domain.NativeObject(), range.NativeObject())); - - - - } - }; - diff --git a/src/api/java/com/Microsoft/Z3/BitVecExpr.java b/src/api/java/com/Microsoft/Z3/BitVecExpr.java deleted file mode 100644 index d7c43918e..000000000 --- a/src/api/java/com/Microsoft/Z3/BitVecExpr.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was automatically generated from BitVecExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Bit-vector expressions - **/ - public class BitVecExpr extends Expr - { - - /** - * The size of the sort of a bit-vector term. - **/ - public int SortSize() { return ((BitVecSort)Sort()).Size(); } - - /** Constructor for BitVecExpr - **/ - protected BitVecExpr(Context ctx) { super(ctx); { }} - BitVecExpr(Context ctx, long obj) { super(ctx, obj); { }} - } diff --git a/src/api/java/com/Microsoft/Z3/BitVecNum.java b/src/api/java/com/Microsoft/Z3/BitVecNum.java deleted file mode 100644 index 6a46fc852..000000000 --- a/src/api/java/com/Microsoft/Z3/BitVecNum.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * This file was automatically generated from BitVecNum.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ - -/* using System.Numerics; */ - - /** - * Bit-vector numerals - **/ - public class BitVecNum extends BitVecExpr - { - /** - * Retrieve the 64-bit unsigned integer value. - **/ - public long UInt64() - { - long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not a 64 bit unsigned"); - return res; - } - - /** - * Retrieve the int value. - **/ - public int Int() - { - int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not an int"); - return res; - } - - /** - * Retrieve the 64-bit int value. - **/ - public long Int64() - { - long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not an int64"); - return res; - } - - /** - * Retrieve the int value. - **/ - public int UInt() - { - int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not a int"); - return res; - } - - /** - * 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) { super(ctx, obj); { }} - } diff --git a/src/api/java/com/Microsoft/Z3/BitVecSort.java b/src/api/java/com/Microsoft/Z3/BitVecSort.java deleted file mode 100644 index 4f9f1a2e2..000000000 --- a/src/api/java/com/Microsoft/Z3/BitVecSort.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This file was automatically generated from BitVecSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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) { super(ctx, obj); { }} - }; diff --git a/src/api/java/com/Microsoft/Z3/BoolExpr.java b/src/api/java/com/Microsoft/Z3/BoolExpr.java deleted file mode 100644 index 7644b4400..000000000 --- a/src/api/java/com/Microsoft/Z3/BoolExpr.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was automatically generated from BoolExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Boolean expressions - **/ - public class BoolExpr extends Expr - { - /** Constructor for BoolExpr - **/ - protected BoolExpr(Context ctx) { super(ctx); { }} - /** Constructor for BoolExpr - **/ - BoolExpr(Context ctx, long obj) { super(ctx, obj); { }} - } diff --git a/src/api/java/com/Microsoft/Z3/BoolSort.java b/src/api/java/com/Microsoft/Z3/BoolSort.java deleted file mode 100644 index 13d4f2f1d..000000000 --- a/src/api/java/com/Microsoft/Z3/BoolSort.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * This file was automatically generated from BoolSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * A Boolean sort. - **/ - public class BoolSort extends Sort - { - BoolSort(Context ctx, long obj) { super(ctx, obj); { }} - BoolSort(Context ctx) { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }} - }; diff --git a/src/api/java/com/Microsoft/Z3/Constructor.java b/src/api/java/com/Microsoft/Z3/Constructor.java deleted file mode 100644 index bcf5654a4..000000000 --- a/src/api/java/com/Microsoft/Z3/Constructor.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was automatically generated from Constructor.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Constructors are used for datatype sorts. - **/ - public class Constructor extends Z3Object - { - /** - * The number of fields of the constructor. - **/ - public int 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 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) - { 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() - { - - - - - if (m_testerDecl != null) return; - long constructor = 0; - long tester = 0; - long[] accessors = new long[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 (int i = 0; i < n; i++) - m_accessorDecls[i] = new FuncDecl(Context(), accessors[i]); - } - - } diff --git a/src/api/java/com/Microsoft/Z3/ConstructorList.java b/src/api/java/com/Microsoft/Z3/ConstructorList.java deleted file mode 100644 index cb8be3b38..000000000 --- a/src/api/java/com/Microsoft/Z3/ConstructorList.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This file was automatically generated from ConstructorList.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Lists of constructors - **/ - public class ConstructorList extends Z3Object - { - /** - * Destructor. - **/ - protected void finalize() - { - Native.delConstructorList(Context().nCtx(), NativeObject()); - } - - ConstructorList(Context ctx, long obj) - { super(ctx, obj); - - } - - ConstructorList(Context ctx, Constructor[] constructors) - { super(ctx); - - - - setNativeObject(Native.mkConstructorList(Context().nCtx(), (int)constructors.length, Constructor.ArrayToNative(constructors))); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Context.java b/src/api/java/com/Microsoft/Z3/Context.java deleted file mode 100644 index 8b83271a1..000000000 --- a/src/api/java/com/Microsoft/Z3/Context.java +++ /dev/null @@ -1,3432 +0,0 @@ -/** - * This file was automatically generated from Context.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Runtime.InteropServices; */ - - /** - * The main interaction with Z3 happens via the Context. - **/ - public class Context extends IDisposable - { - /** - * Constructor. - **/ - public Context() - { super(); - m_ctx = Native.mkContextRc(0); - InitContext(); - } - - /** - * Constructor. - **/ - public Context(Map settings) - { super(); - - - long cfg = Native.mkConfig(); - for (KeyValuePair kv: settings) - Native.setParamValue(cfg, kv.Key, kv.Value); - m_ctx = Native.mkContextRc(cfg); - Native.delConfig(cfg); - InitContext(); - } - - private Context(long ctx) - { - super(); - this.m_ctx = ctx; - } - - /** - * Creates a new symbol using an integer. - * - * Not all integers can be passed to this function. - * The legal range of unsigned integers is 0 to 2^30-1. - * - **/ - public IntSymbol MkSymbol(int i) - { - - - return new IntSymbol(this, i); - } - - /** - * Create a symbol using a string. - **/ - public StringSymbol MkSymbol(String name) - { - - - return new StringSymbol(this, name); - } - - /** - * Create an array of symbols. - **/ - Symbol[] MkSymbols(String[] names) - { - - - - - - if (names == null) return null; - Symbol[] result = new Symbol[names.length]; - for (int i = 0; i < names.length; ++i) result[i] = MkSymbol(names[i]); - return result; - } - - private BoolSort m_boolSort = null; - private IntSort m_intSort = null; - private RealSort m_realSort = null; - - /** - * Retrieves the Boolean sort of the context. - **/ - public BoolSort BoolSort() - { - - - if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort; - } - - /** - * Retrieves the Integer sort of the context. - **/ - public IntSort IntSort() - { - - if (m_intSort == null) m_intSort = new IntSort(this); return m_intSort; - } - - - /** - * Retrieves the Real sort of the context. - **/ - public RealSort RealSort () { return m_realSort; } - - /** - * Create a new Boolean sort. - **/ - public BoolSort MkBoolSort() - { - - return new BoolSort(this); - } - - /** - * Create a new uninterpreted sort. - **/ - public UninterpretedSort MkUninterpretedSort(Symbol s) - { - - - - CheckContextMatch(s); - return new UninterpretedSort(this, s); - } - - /** - * Create a new uninterpreted sort. - **/ - public UninterpretedSort MkUninterpretedSort(String str) - { - - - return MkUninterpretedSort(MkSymbol(str)); - } - - /** - * Create a new integer sort. - **/ - public IntSort MkIntSort() - { - - - return new IntSort(this); - } - - /** - * Create a real sort. - **/ - public RealSort MkRealSort() - { - - return new RealSort(this); - } - - /** - * Create a new bit-vector sort. - **/ - public BitVecSort MkBitVecSort(int size) - { - - - return new BitVecSort(this, Native.mkBvSort(nCtx(), size)); - } - - /** - * Create a new array sort. - **/ - public ArraySort MkArraySort(Sort domain, Sort range) - { - - - - - CheckContextMatch(domain); - CheckContextMatch(range); - return new ArraySort(this, domain, range); - } - - /** - * Create a new tuple sort. - **/ - public TupleSort MkTupleSort(Symbol name, Symbol[] fieldNames, Sort[] fieldSorts) - { - - - - - - - CheckContextMatch(name); - CheckContextMatch(fieldNames); - CheckContextMatch(fieldSorts); - return new TupleSort(this, name, (int)fieldNames.length, fieldNames, fieldSorts); - } - - /** - * Create a new enumeration sort. - **/ - public EnumSort MkEnumSort(Symbol name, Symbol[] enumNames) - { - - - - - - - CheckContextMatch(name); - CheckContextMatch(enumNames); - return new EnumSort(this, name, enumNames); - } - - /** - * Create a new enumeration sort. - **/ - public EnumSort MkEnumSort(String name, String[] enumNames) - { - - - - return new EnumSort(this, MkSymbol(name), MkSymbols(enumNames)); - } - - /** - * Create a new list sort. - **/ - public ListSort MkListSort(Symbol name, Sort elemSort) - { - - - - - CheckContextMatch(name); - CheckContextMatch(elemSort); - return new ListSort(this, name, elemSort); - } - - /** - * Create a new list sort. - **/ - public ListSort MkListSort(String name, Sort elemSort) - { - - - - CheckContextMatch(elemSort); - return new ListSort(this, MkSymbol(name), elemSort); - } - - /** - * Create a new finite domain sort. - **/ - public FiniteDomainSort MkFiniteDomainSort(Symbol name, long size) - { - - - - CheckContextMatch(name); - return new FiniteDomainSort(this, name, size); - } - - /** - * Create a new finite domain sort. - **/ - public FiniteDomainSort MkFiniteDomainSort(String name, long size) - { - - - return new FiniteDomainSort(this, MkSymbol(name), size); - } - - - /** - * Create a datatype constructor. - * constructor name - * name of recognizer function. - * names of the constructor fields. - * field sorts, 0 if the field sort refers to a recursive sort. - * reference to datatype sort that is an argument to the constructor; - * if the corresponding sort reference is 0, then the value in sort_refs should be an index - * referring to one of the recursive datatypes that is declared. - **/ - public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, int[] sortRefs) - { - - - - - return new Constructor(this, name, recognizer, fieldNames, sorts, sortRefs); - } - - /** - * Create a datatype constructor. - * - * - * - * - * - * @return - **/ - public Constructor MkConstructor(String name, String recognizer, String[] fieldNames, Sort[] sorts, int[] sortRefs) - { - - - return new Constructor(this, MkSymbol(name), MkSymbol(recognizer), MkSymbols(fieldNames), sorts, sortRefs); - } - - /** - * Create a new datatype sort. - **/ - public DatatypeSort MkDatatypeSort(Symbol name, Constructor[] constructors) - { - - - - - - - CheckContextMatch(name); - CheckContextMatch(constructors); - return new DatatypeSort(this, name, constructors); - } - - /** - * Create a new datatype sort. - **/ - public DatatypeSort MkDatatypeSort(String name, Constructor[] constructors) - { - - - - - CheckContextMatch(constructors); - return new DatatypeSort(this, MkSymbol(name), constructors); - } - - /** - * Create mutually recursive datatypes. - * names of datatype sorts - * list of constructors, one list per sort. - **/ - public DatatypeSort[] MkDatatypeSorts(Symbol[] names, Constructor[][] c) - { - - - - - - - - CheckContextMatch(names); - int n = (int)names.length; - ConstructorList[] cla = new ConstructorList[n]; - long[] n_constr = new long[n]; - for (int i = 0; i < n; i++) - { - Constructor[] constructor = c[i]; - - CheckContextMatch(constructor); - cla[i] = new ConstructorList(this, constructor); - n_constr[i] = cla[i].NativeObject(); - } - long[] n_res = new long[n]; - Native.mkDatatypes(nCtx(), n, Symbol.ArrayToNative(names), n_res, n_constr); - DatatypeSort[] res = new DatatypeSort[n]; - for (int i = 0; i < n; i++) - res[i] = new DatatypeSort(this, n_res[i]); - return res; - } - - /** - * Create mutually recursive data-types. - * - * - * @return - **/ - public DatatypeSort[] MkDatatypeSorts(String[] names, Constructor[][] c) - { - - - - - - - - return MkDatatypeSorts(MkSymbols(names), c); - } - - - /** - * Creates a new function declaration. - **/ - public FuncDecl MkFuncDecl(Symbol name, Sort[] domain, Sort range) - { - - - - - - CheckContextMatch(name); - CheckContextMatch(domain); - CheckContextMatch(range); - return new FuncDecl(this, name, domain, range); - } - - /** - * Creates a new function declaration. - **/ - public FuncDecl MkFuncDecl(Symbol name, Sort domain, Sort range) - { - - - - - - CheckContextMatch(name); - CheckContextMatch(domain); - CheckContextMatch(range); - Sort[] q = new Sort[] { domain }; - return new FuncDecl(this, name, q, range); - } - - /** - * Creates a new function declaration. - **/ - public FuncDecl MkFuncDecl(String name, Sort[] domain, Sort range) - { - - - - - CheckContextMatch(domain); - CheckContextMatch(range); - return new FuncDecl(this, MkSymbol(name), domain, range); - } - - /** - * Creates a new function declaration. - **/ - public FuncDecl MkFuncDecl(String name, Sort domain, Sort range) - { - - - - - CheckContextMatch(domain); - CheckContextMatch(range); - Sort[] q = new Sort[] { domain }; - return new FuncDecl(this, MkSymbol(name), q, range); - } - - /** - * Creates a fresh function declaration with a name prefixed with . - * - * - **/ - public FuncDecl MkFreshFuncDecl(String prefix, Sort[] domain, Sort range) - { - - - - - CheckContextMatch(domain); - CheckContextMatch(range); - return new FuncDecl(this, prefix, domain, range); - } - - /** - * Creates a new constant function declaration. - **/ - public FuncDecl MkConstDecl(Symbol name, Sort range) - { - - - - - CheckContextMatch(name); - CheckContextMatch(range); - return new FuncDecl(this, name, null, range); - } - - /** - * Creates a new constant function declaration. - **/ - public FuncDecl MkConstDecl(String name, Sort range) - { - - - - CheckContextMatch(range); - return new FuncDecl(this, MkSymbol(name), null, range); - } - - /** - * Creates a fresh constant function declaration with a name prefixed with . - * - * - **/ - public FuncDecl MkFreshConstDecl(String prefix, Sort range) - { - - - - CheckContextMatch(range); - return new FuncDecl(this, prefix, null, range); - } - - /** - * Creates a new bound variable. - * The de-Bruijn index of the variable - * The sort of the variable - **/ - public Expr MkBound(int index, Sort ty) - { - - - - return Expr.Create(this, Native.mkBound(nCtx(), index, ty.NativeObject())); - } - - /** - * Create a quantifier pattern. - **/ - public Pattern MkPattern(Expr[] terms) - { - - if (terms.length == 0) - throw new Z3Exception("Cannot create a pattern from zero terms"); - - - - - - long[] termsNative = AST.ArrayToNative(terms); - return new Pattern(this, Native.mkPattern(nCtx(), (int)terms.length, termsNative)); - } - - /** - * Creates a new Constant of sort and named . - **/ - public Expr MkConst(Symbol name, Sort range) - { - - - - - CheckContextMatch(name); - CheckContextMatch(range); - - return Expr.Create(this, Native.mkConst(nCtx(), name.NativeObject(), range.NativeObject())); - } - - /** - * Creates a new Constant of sort and named . - **/ - public Expr MkConst(String name, Sort range) - { - - - - return MkConst(MkSymbol(name), range); - } - - /** - * Creates a fresh Constant of sort and a - * name prefixed with . - **/ - public Expr MkFreshConst(String prefix, Sort range) - { - - - - CheckContextMatch(range); - return Expr.Create(this, Native.mkFreshConst(nCtx(), prefix, range.NativeObject())); - } - - /** - * Creates a fresh constant from the FuncDecl . - * A decl of a 0-arity function - **/ - public Expr MkConst(FuncDecl f) - { - - - - return MkApp(f, null); - } - - /** - * Create a Boolean constant. - **/ - public BoolExpr MkBoolConst(Symbol name) - { - - - - return (BoolExpr)MkConst(name, BoolSort()); - } - - /** - * Create a Boolean constant. - **/ - public BoolExpr MkBoolConst(String name) - { - - - return (BoolExpr)MkConst(MkSymbol(name), BoolSort()); - } - - /** - * Creates an integer constant. - **/ - public IntExpr MkIntConst(Symbol name) - { - - - - return (IntExpr)MkConst(name, IntSort()); - } - - /** - * Creates an integer constant. - **/ - public IntExpr MkIntConst(String name) - { - - - - return (IntExpr)MkConst(name, IntSort()); - } - - /** - * Creates a real constant. - **/ - public RealExpr MkRealConst(Symbol name) - { - - - - return (RealExpr)MkConst(name, RealSort()); - } - - /** - * Creates a real constant. - **/ - public RealExpr MkRealConst(String name) - { - - - return (RealExpr)MkConst(name, RealSort()); - } - - /** - * Creates a bit-vector constant. - **/ - public BitVecExpr MkBVConst(Symbol name, int size) - { - - - - return (BitVecExpr)MkConst(name, MkBitVecSort(size)); - } - - /** - * Creates a bit-vector constant. - **/ - public BitVecExpr MkBVConst(String name, int size) - { - - - return (BitVecExpr)MkConst(name, MkBitVecSort(size)); - } - - /** - * Create a new function application. - **/ - public Expr MkApp(FuncDecl f, Expr[] args) - { - - - - - CheckContextMatch(f); - CheckContextMatch(args); - return Expr.Create(this, f, args); - } - - /** - * The true Term. - **/ - public BoolExpr MkTrue() - { - - - return new BoolExpr(this, Native.mkTrue(nCtx())); - } - - /** - * The false Term. - **/ - public BoolExpr MkFalse() - { - - - return new BoolExpr(this, Native.mkFalse(nCtx())); - } - - /** - * Creates a Boolean value. - **/ - public BoolExpr MkBool(boolean value) - { - - - return value ? MkTrue() : MkFalse(); - } - - /** - * Creates the equality = . - **/ - public BoolExpr MkEq(Expr x, Expr y) - { - - - - - CheckContextMatch(x); - CheckContextMatch(y); - return new BoolExpr(this, Native.mkEq(nCtx(), x.NativeObject(), y.NativeObject())); - } - - /** - * Creates a distinct term. - **/ - public BoolExpr MkDistinct(Expr[] args) - { - - - - - - CheckContextMatch(args); - return new BoolExpr(this, Native.mkDistinct(nCtx(), (int)args.length, AST.ArrayToNative(args))); - } - - /** - * Mk an expression representing not(a). - **/ - public BoolExpr MkNot(BoolExpr a) - { - - - - CheckContextMatch(a); - return new BoolExpr(this, Native.mkNot(nCtx(), a.NativeObject())); - } - - /** - * Create an expression representing an if-then-else: ite(t1, t2, t3). - * An expression with Boolean sort - * An expression - * An expression with the same sort as - **/ - public Expr MkITE(BoolExpr t1, Expr t2, Expr t3) - { - - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - CheckContextMatch(t3); - return Expr.Create(this, Native.mkIte(nCtx(), t1.NativeObject(), t2.NativeObject(), t3.NativeObject())); - } - - /** - * Create an expression representing t1 iff t2. - **/ - public BoolExpr MkIff(BoolExpr t1, BoolExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkIff(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 -> t2. - **/ - public BoolExpr MkImplies(BoolExpr t1, BoolExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkImplies(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 xor t2. - **/ - public BoolExpr MkXor(BoolExpr t1, BoolExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkXor(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t[0] and t[1] and .... - **/ - public BoolExpr MkAnd(BoolExpr[] t) - { - - - - - CheckContextMatch(t); - return new BoolExpr(this, Native.mkAnd(nCtx(), (int)t.length, AST.ArrayToNative(t))); - } - - /** - * Create an expression representing t[0] or t[1] or .... - **/ - public BoolExpr MkOr(BoolExpr[] t) - { - - - - - CheckContextMatch(t); - return new BoolExpr(this, Native.mkOr(nCtx(), (int)t.length, AST.ArrayToNative(t))); - } - - /** - * Create an expression representing t[0] + t[1] + .... - **/ - public ArithExpr MkAdd(ArithExpr[] t) - { - - - - - CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkAdd(nCtx(), (int)t.length, AST.ArrayToNative(t))); - } - - /** - * Create an expression representing t[0] * t[1] * .... - **/ - public ArithExpr MkMul(ArithExpr[] t) - { - - - - - CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkMul(nCtx(), (int)t.length, AST.ArrayToNative(t))); - } - - /** - * Create an expression representing t[0] - t[1] - .... - **/ - public ArithExpr MkSub(ArithExpr[] t) - { - - - - - CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkSub(nCtx(), (int)t.length, AST.ArrayToNative(t))); - } - - /** - * Create an expression representing -t. - **/ - public ArithExpr MkUnaryMinus(ArithExpr t) - { - - - - CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkUnaryMinus(nCtx(), t.NativeObject())); - } - - /** - * Create an expression representing t1 / t2. - **/ - public ArithExpr MkDiv(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return (ArithExpr)Expr.Create(this, Native.mkDiv(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 mod t2. - * The arguments must have int type. - **/ - public IntExpr MkMod(IntExpr t1, IntExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new IntExpr(this, Native.mkMod(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 rem t2. - * The arguments must have int type. - **/ - public IntExpr MkRem(IntExpr t1, IntExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new IntExpr(this, Native.mkRem(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 ^ t2. - **/ - public ArithExpr MkPower(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return (ArithExpr)Expr.Create(this, Native.mkPower(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 < t2 - **/ - public BoolExpr MkLt(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkLt(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 <= t2 - **/ - public BoolExpr MkLe(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkLe(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 > t2 - **/ - public BoolExpr MkGt(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkGt(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an expression representing t1 >= t2 - **/ - public BoolExpr MkGe(ArithExpr t1, ArithExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkGe(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Coerce an integer to a real. - * - * There is also a converse operation exposed. It follows the semantics prescribed by the SMT-LIB standard. - * - * You can take the floor of a real by creating an auxiliary integer Term k and - * and asserting MakeInt2Real(k) <= t1 < MkInt2Real(k)+1. - * The argument must be of integer sort. - * - **/ - public RealExpr MkInt2Real(IntExpr t) - { - - - - CheckContextMatch(t); - return new RealExpr(this, Native.mkInt2real(nCtx(), t.NativeObject())); - } - - /** - * Coerce a real to an integer. - * - * The semantics of this function follows the SMT-LIB standard for the function to_int. - * The argument must be of real sort. - * - **/ - public IntExpr MkReal2Int(RealExpr t) - { - - - - CheckContextMatch(t); - return new IntExpr(this, Native.mkReal2int(nCtx(), t.NativeObject())); - } - - /** - * Creates an expression that checks whether a real number is an integer. - **/ - public BoolExpr MkIsInteger(RealExpr t) - { - - - - CheckContextMatch(t); - return new BoolExpr(this, Native.mkIsInt(nCtx(), t.NativeObject())); - } - - /** - * Bitwise negation. - * The argument must have a bit-vector sort. - **/ - public BitVecExpr MkBVNot(BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvnot(nCtx(), t.NativeObject())); - } - - /** - * Take conjunction of bits in a vector, return vector of length 1. - * The argument must have a bit-vector sort. - **/ - public BitVecExpr MkBVRedAND(BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvredand(nCtx(), t.NativeObject())); - } - - /** - * Take disjunction of bits in a vector, return vector of length 1. - * The argument must have a bit-vector sort. - **/ - public BitVecExpr MkBVRedOR(BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvredor(nCtx(), t.NativeObject())); - } - - /** - * Bitwise conjunction. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVAND(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvand(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bitwise disjunction. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVOR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvor(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bitwise XOR. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVXOR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvxor(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bitwise NAND. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVNAND(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvnand(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bitwise NOR. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVNOR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvnor(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bitwise XNOR. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVXNOR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvxnor(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Standard two's complement unary minus. - * The arguments must have a bit-vector sort. - **/ - public BitVecExpr MkBVNeg(BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvneg(nCtx(), t.NativeObject())); - } - - /** - * Two's complement addition. - * The arguments must have the same bit-vector sort. - **/ - public BitVecExpr MkBVAdd(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvadd(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement subtraction. - * The arguments must have the same bit-vector sort. - **/ - public BitVecExpr MkBVSub(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsub(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement multiplication. - * The arguments must have the same bit-vector sort. - **/ - public BitVecExpr MkBVMul(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvmul(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned division. - * - * It is defined as the floor of t1/t2 if \c t2 is - * different from zero. If t2 is zero, then the result - * is undefined. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVUDiv(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvudiv(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Signed division. - * - * It is defined in the following way: - * - * - The \c floor of t1/t2 if \c t2 is different from zero, and t1*t2 >= 0. - * - * - The \c ceiling of t1/t2 if \c t2 is different from zero, and t1*t2 < 0. - * - * If t2 is zero, then the result is undefined. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVSDiv(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsdiv(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned remainder. - * - * It is defined as t1 - (t1 /u t2) * t2, where /u represents unsigned division. - * If t2 is zero, then the result is undefined. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVURem(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvurem(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Signed remainder. - * - * It is defined as t1 - (t1 /s t2) * t2, where /s represents signed division. - * The most significant bit (sign) of the result is equal to the most significant bit of \c t1. - * - * If t2 is zero, then the result is undefined. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVSRem(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsrem(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement signed remainder (sign follows divisor). - * - * If t2 is zero, then the result is undefined. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVSMod(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsmod(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned less-than - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVULT(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvult(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement signed less-than - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVSLT(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvslt(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned less-than or equal to. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVULE(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvule(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement signed less-than or equal to. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVSLE(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsle(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned greater than or equal to. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVUGE(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvuge(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement signed greater than or equal to. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVSGE(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsge(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Unsigned greater-than. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVUGT(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvugt(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Two's complement signed greater-than. - * - * The arguments must have the same bit-vector sort. - * - **/ - public BoolExpr MkBVSGT(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsgt(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bit-vector concatenation. - * - * The arguments must have a bit-vector sort. - * - * @return - * The result is a bit-vector of size n1+n2, where n1 (n2) - * is the size of t1 (t2). - * - **/ - public BitVecExpr MkConcat(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkConcat(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Bit-vector extraction. - * - * Extract the bits down to from a bitvector of - * size m to yield a new bitvector of size n, where - * n = high - low + 1. - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkExtract(int high, int low, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkExtract(nCtx(), high, low, t.NativeObject())); - } - - /** - * Bit-vector sign extension. - * - * Sign-extends the given bit-vector to the (signed) equivalent bitvector of - * size m+i, where \c m is the size of the given bit-vector. - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkSignExt(int i, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkSignExt(nCtx(), i, t.NativeObject())); - } - - /** - * Bit-vector zero extension. - * - * Extend the given bit-vector with zeros to the (unsigned) equivalent - * bitvector of size m+i, where \c m is the size of the - * given bit-vector. - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkZeroExt(int i, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkZeroExt(nCtx(), i, t.NativeObject())); - } - - /** - * Bit-vector repetition. - * - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkRepeat(int i, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRepeat(nCtx(), i, t.NativeObject())); - } - - /** - * Shift left. - * - * It is equivalent to multiplication by 2^x where \c x is the value of . - * - * NB. The semantics of shift operations varies between environments. This - * definition does not necessarily capture directly the semantics of the - * programming language or assembly architecture you are modeling. - * - * The arguments must have a bit-vector sort. - * - **/ - public BitVecExpr MkBVSHL(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvshl(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Logical shift right - * - * It is equivalent to unsigned division by 2^x where \c x is the value of . - * - * NB. The semantics of shift operations varies between environments. This - * definition does not necessarily capture directly the semantics of the - * programming language or assembly architecture you are modeling. - * - * The arguments must have a bit-vector sort. - * - **/ - public BitVecExpr MkBVLSHR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvlshr(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Arithmetic shift right - * - * It is like logical shift right except that the most significant - * bits of the result always copy the most significant bit of the - * second argument. - * - * NB. The semantics of shift operations varies between environments. This - * definition does not necessarily capture directly the semantics of the - * programming language or assembly architecture you are modeling. - * - * The arguments must have a bit-vector sort. - * - **/ - public BitVecExpr MkBVASHR(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvashr(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Rotate Left. - * - * Rotate bits of \c t to the left \c i times. - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkBVRotateLeft(int i, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRotateLeft(nCtx(), i, t.NativeObject())); - } - - /** - * Rotate Right. - * - * Rotate bits of \c t to the right \c i times. - * The argument must have a bit-vector sort. - * - **/ - public BitVecExpr MkBVRotateRight(int i, BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRotateRight(nCtx(), i, t.NativeObject())); - } - - /** - * Rotate Left. - * - * Rotate bits of to the left times. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVRotateLeft(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkExtRotateLeft(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Rotate Right. - * - * Rotate bits of to the right times. - * The arguments must have the same bit-vector sort. - * - **/ - public BitVecExpr MkBVRotateRight(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkExtRotateRight(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an bit bit-vector from the integer argument . - * - * NB. This function is essentially treated as uninterpreted. - * So you cannot expect Z3 to precisely reflect the semantics of this function - * when solving constraints with this function. - * - * The argument must be of integer sort. - * - **/ - public BitVecExpr MkInt2BV(int n, IntExpr t) - { - - - - CheckContextMatch(t); - return new BitVecExpr(this, Native.mkInt2bv(nCtx(), n, t.NativeObject())); - } - - /** - * Create an integer from the bit-vector argument . - * - * If \c is_signed is false, then the bit-vector \c t1 is treated as unsigned. - * So the result is non-negative and in the range [0..2^N-1], where - * N are the number of bits in . - * If \c is_signed is true, \c t1 is treated as a signed bit-vector. - * - * NB. This function is essentially treated as uninterpreted. - * So you cannot expect Z3 to precisely reflect the semantics of this function - * when solving constraints with this function. - * - * The argument must be of bit-vector sort. - * - **/ - public IntExpr MkBV2Int(BitVecExpr t, boolean signed) - { - - - - CheckContextMatch(t); - return new IntExpr(this, Native.mkBv2int(nCtx(), t.NativeObject(), (signed) ? true : false)); - } - - /** - * Create a predicate that checks that the bit-wise addition does not overflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVAddNoOverflow(BitVecExpr t1, BitVecExpr t2, boolean isSigned) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvaddNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); - } - - /** - * Create a predicate that checks that the bit-wise addition does not underflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVAddNoUnderflow(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvaddNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a predicate that checks that the bit-wise subtraction does not overflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVSubNoOverflow(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsubNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a predicate that checks that the bit-wise subtraction does not underflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVSubNoUnderflow(BitVecExpr t1, BitVecExpr t2, boolean isSigned) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsubNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); - } - - /** - * Create a predicate that checks that the bit-wise signed division does not overflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVSDivNoOverflow(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsdivNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a predicate that checks that the bit-wise negation does not overflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVNegNoOverflow(BitVecExpr t) - { - - - - CheckContextMatch(t); - return new BoolExpr(this, Native.mkBvnegNoOverflow(nCtx(), t.NativeObject())); - } - - /** - * Create a predicate that checks that the bit-wise multiplication does not overflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVMulNoOverflow(BitVecExpr t1, BitVecExpr t2, boolean isSigned) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvmulNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); - } - - /** - * Create a predicate that checks that the bit-wise multiplication does not underflow. - * - * The arguments must be of bit-vector sort. - * - **/ - public BoolExpr MkBVMulNoUnderflow(BitVecExpr t1, BitVecExpr t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvmulNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create an array constant. - **/ - public ArrayExpr MkArrayConst(Symbol name, Sort domain, Sort range) - { - - - - - - return (ArrayExpr)MkConst(name, MkArraySort(domain, range)); - } - - /** - * Create an array constant. - **/ - public ArrayExpr MkArrayConst(String name, Sort domain, Sort range) - { - - - - - return (ArrayExpr)MkConst(MkSymbol(name), MkArraySort(domain, range)); - } - - /** - * Array read. - * - * The argument a is the array and i is the index - * of the array that gets read. - * - * The node a must have an array sort [domain -> range], - * and i must have the sort domain. - * The sort of the result is range. - * - * - * - **/ - public Expr MkSelect(ArrayExpr a, Expr i) - { - - - - - CheckContextMatch(a); - CheckContextMatch(i); - return Expr.Create(this, Native.mkSelect(nCtx(), a.NativeObject(), i.NativeObject())); - } - - /** - * Array update. - * - * The node a must have an array sort [domain -> range], - * i must have sort domain, - * v must have sort range. The sort of the result is [domain -> range]. - * The semantics of this function is given by the theory of arrays described in the SMT-LIB - * standard. See http://smtlib.org for more details. - * The result of this function is an array that is equal to a - * (with respect to select) - * on all indices except for i, where it maps to v - * (and the select of a with - * respect to i may be a different value). - * - * - * - **/ - public ArrayExpr MkStore(ArrayExpr a, Expr i, Expr v) - { - - - - - - CheckContextMatch(a); - CheckContextMatch(i); - CheckContextMatch(v); - return new ArrayExpr(this, Native.mkStore(nCtx(), a.NativeObject(), i.NativeObject(), v.NativeObject())); - } - - /** - * Create a constant array. - * - * The resulting term is an array, such that a selecton an arbitrary index - * produces the value v. - * - * - * - **/ - public ArrayExpr MkConstArray(Sort domain, Expr v) - { - - - - - CheckContextMatch(domain); - CheckContextMatch(v); - return new ArrayExpr(this, Native.mkConstArray(nCtx(), domain.NativeObject(), v.NativeObject())); - } - - /** - * Maps f on the argument arrays. - * - * Eeach element of args must be of an array sort [domain_i -> range_i]. - * The function declaration f must have type range_1 .. range_n -> range. - * v must have sort range. The sort of the result is [domain_i -> range]. - * - * - * - * - **/ - public ArrayExpr MkMap(FuncDecl f, ArrayExpr[] args) - { - - - - - CheckContextMatch(f); - CheckContextMatch(args); - return (ArrayExpr)Expr.Create(this, Native.mkMap(nCtx(), f.NativeObject(), AST.ArrayLength(args), AST.ArrayToNative(args))); - } - - /** - * Access the array default value. - * - * Produces the default range value, for arrays that can be represented as - * finite maps with a default range value. - * - **/ - public Expr MkTermArray(ArrayExpr array) - { - - - - CheckContextMatch(array); - return Expr.Create(this, Native.mkArrayDefault(nCtx(), array.NativeObject())); - } - - /** - * Create a set type. - **/ - public SetSort MkSetSort(Sort ty) - { - - - - CheckContextMatch(ty); - return new SetSort(this, ty); - } - - /** - * Create an empty set. - **/ - public Expr MkEmptySet(Sort domain) - { - - - - CheckContextMatch(domain); - return Expr.Create(this, Native.mkEmptySet(nCtx(), domain.NativeObject())); - } - - /** - * Create the full set. - **/ - public Expr MkFullSet(Sort domain) - { - - - - CheckContextMatch(domain); - return Expr.Create(this, Native.mkFullSet(nCtx(), domain.NativeObject())); - } - - /** - * Add an element to the set. - **/ - public Expr MkSetAdd(Expr set, Expr element) - { - - - - - CheckContextMatch(set); - CheckContextMatch(element); - return Expr.Create(this, Native.mkSetAdd(nCtx(), set.NativeObject(), element.NativeObject())); - } - - - /** - * Remove an element from a set. - **/ - public Expr MkSetDel(Expr set, Expr element) - { - - - - - CheckContextMatch(set); - CheckContextMatch(element); - return Expr.Create(this, Native.mkSetDel(nCtx(), set.NativeObject(), element.NativeObject())); - } - - /** - * Take the union of a list of sets. - **/ - public Expr MkSetUnion(Expr[] args) - { - - - - CheckContextMatch(args); - return Expr.Create(this, Native.mkSetUnion(nCtx(), (int)args.length, AST.ArrayToNative(args))); - } - - /** - * Take the intersection of a list of sets. - **/ - public Expr MkSetIntersection(Expr[] args) - { - - - - - CheckContextMatch(args); - return Expr.Create(this, Native.mkSetIntersect(nCtx(), (int)args.length, AST.ArrayToNative(args))); - } - - /** - * Take the difference between two sets. - **/ - public Expr MkSetDifference(Expr arg1, Expr arg2) - { - - - - - CheckContextMatch(arg1); - CheckContextMatch(arg2); - return Expr.Create(this, Native.mkSetDifference(nCtx(), arg1.NativeObject(), arg2.NativeObject())); - } - - /** - * Take the complement of a set. - **/ - public Expr MkSetComplement(Expr arg) - { - - - - CheckContextMatch(arg); - return Expr.Create(this, Native.mkSetComplement(nCtx(), arg.NativeObject())); - } - - /** - * Check for set membership. - **/ - public Expr MkSetMembership(Expr elem, Expr set) - { - - - - - CheckContextMatch(elem); - CheckContextMatch(set); - return Expr.Create(this, Native.mkSetMember(nCtx(), elem.NativeObject(), set.NativeObject())); - } - - /** - * Check for subsetness of sets. - **/ - public Expr MkSetSubset(Expr arg1, Expr arg2) - { - - - - - CheckContextMatch(arg1); - CheckContextMatch(arg2); - return Expr.Create(this, Native.mkSetSubset(nCtx(), arg1.NativeObject(), arg2.NativeObject())); - } - - - /** - * Create a Term of a given sort. - * A string representing the Term value in decimal notation. If the given sort is a real, then the Term can be a rational, that is, a string of the form [num]* / [num]*. - * The sort of the numeral. In the current implementation, the given sort can be an int, real, or bit-vectors of arbitrary size. - * @return A Term with value and sort - **/ - public Expr MkNumeral(String v, Sort ty) - { - - - - CheckContextMatch(ty); - return Expr.Create(this, Native.mkNumeral(nCtx(), v, ty.NativeObject())); - } - - /** - * Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. - * It is slightly faster than MakeNumeral since it is not necessary to parse a string. - * Value of the numeral - * Sort of the numeral - * @return A Term with value and type - **/ - public Expr MkNumeral(int v, Sort ty) - { - - - - CheckContextMatch(ty); - return Expr.Create(this, Native.mkInt(nCtx(), v, ty.NativeObject())); - } - - /** - * Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. - * It is slightly faster than MakeNumeral since it is not necessary to parse a string. - * Value of the numeral - * Sort of the numeral - * @return A Term with value and type - **/ - public Expr MkNumeral(long v, Sort ty) - { - - - - CheckContextMatch(ty); - return Expr.Create(this, Native.mkInt64(nCtx(), v, ty.NativeObject())); - } - - /** - * Create a real from a fraction. - * numerator of rational. - * denominator of rational. - * @return A Term with value / and sort Real - * - **/ - public RatNum MkReal(int num, int den) - { - if (den == 0) - throw new Z3Exception("Denominator is zero"); - - - - - return new RatNum(this, Native.mkReal(nCtx(), num, den)); - } - - /** - * Create a real numeral. - * A string representing the Term value in decimal notation. - * @return A Term with value and sort Real - **/ - public RatNum MkReal(String v) - { - - - return new RatNum(this, Native.mkNumeral(nCtx(), v, RealSort().NativeObject())); - } - - /** - * Create a real numeral. - * value of the numeral. - * @return A Term with value and sort Real - **/ - public RatNum MkReal(int v) - { - - - return new RatNum(this, Native.mkInt(nCtx(), v, RealSort().NativeObject())); - } - - /** - * Create a real numeral. - * value of the numeral. - * @return A Term with value and sort Real - **/ - public RatNum MkReal(long v) - { - - - return new RatNum(this, Native.mkInt64(nCtx(), v, RealSort().NativeObject())); - } - - /** - * Create an integer numeral. - * A string representing the Term value in decimal notation. - **/ - public IntNum MkInt(String v) - { - - - return new IntNum(this, Native.mkNumeral(nCtx(), v, IntSort().NativeObject())); - } - - /** - * Create an integer numeral. - * value of the numeral. - * @return A Term with value and sort Integer - **/ - public IntNum MkInt(int v) - { - - - return new IntNum(this, Native.mkInt(nCtx(), v, IntSort().NativeObject())); - } - - /** - * Create an integer numeral. - * value of the numeral. - * @return A Term with value and sort Integer - **/ - public IntNum MkInt(long v) - { - - - return new IntNum(this, Native.mkInt64(nCtx(), v, IntSort().NativeObject())); - } - - /** - * Create a bit-vector numeral. - * A string representing the value in decimal notation. - * the size of the bit-vector - **/ - public BitVecNum MkBV(String v, int size) - { - - - return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); - } - - /** - * Create a bit-vector numeral. - * value of the numeral. - * the size of the bit-vector - **/ - public BitVecNum MkBV(int v, int size) - { - - - return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); - } - - /** - * Create a bit-vector numeral. - * value of the numeral. - * * the size of the bit-vector - **/ - public BitVecNum MkBV(long v, int size) - { - - - return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); - } - - - /** - * Create a universal Quantifier. - * - * Creates a forall formula, where is the weight, - * is an array of patterns, is an array - * with the sorts of the bound variables, is an array with the - * 'names' of the bound variables, and is the body of the - * quantifier. Quantifiers are associated with weights indicating - * the importance of using the quantifier during instantiation. - * - * the sorts of the bound variables. - * names of the bound variables - * the body of the quantifier. - * quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. - * array containing the patterns created using MkPattern. - * array containing the anti-patterns created using MkPattern. - * optional symbol to track quantifier. - * optional symbol to track skolem constants. - **/ - public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - - - - - - return new Quantifier(this, true, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - - /** - * Create a universal Quantifier. - **/ - public Quantifier MkForall(Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - - return new Quantifier(this, true, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - /** - * Create an existential Quantifier. - * - **/ - public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - - - - - return new Quantifier(this, false, sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - /** - * Create an existential Quantifier. - **/ - public Quantifier MkExists(Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - return new Quantifier(this, false, boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - - /** - * Create a Quantifier. - **/ - public Quantifier MkQuantifier(boolean universal, Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - - - - - - if (universal) - return MkForall(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); - else - return MkExists(sorts, names, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - - /** - * Create a Quantifier. - **/ - public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) - { - - - - - - - - if (universal) - return MkForall(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); - else - return MkExists(boundConstants, body, weight, patterns, noPatterns, quantifierID, skolemID); - } - - - - /** - * Selects the format used for pretty-printing expressions. - * - * The default mode for pretty printing expressions is to produce - * SMT-LIB style output where common subexpressions are printed - * at each occurrence. The mode is called Z3_PRINT_SMTLIB_FULL. - * To print shared common subexpressions only once, - * use the Z3_PRINT_LOW_LEVEL mode. - * To print in way that conforms to SMT-LIB standards and uses let - * expressions to share common sub-expressions use Z3_PRINT_SMTLIB_COMPLIANT. - * - * - * - * - * - **/ - public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx(), value.toInt()); } - - /** - * Convert a benchmark into an SMT-LIB formatted string. - * Name of the benchmark. The argument is optional. - * The benchmark logic. - * The status string (sat, unsat, or unknown) - * Other attributes, such as source, difficulty or category. - * Auxiliary assumptions. - * Formula to be checked for consistency in conjunction with assumptions. - * @return A string representation of the benchmark. - **/ - public String BenchmarkToSMTString(String name, String logic, String status, String attributes, - BoolExpr[] assumptions, BoolExpr formula) - { - - - - - return Native.benchmarkToSmtlibString(nCtx(), name, logic, status, attributes, - (int)assumptions.length, AST.ArrayToNative(assumptions), - formula.NativeObject()); - } - - /** - * Parse the given string using the SMT-LIB parser. - * - * The symbol table of the parser can be initialized using the given sorts and declarations. - * The symbols in the arrays and - * don't need to match the names of the sorts and declarations in the arrays - * and . This is a useful feature since we can use arbitrary names to - * reference sorts and declarations. - * - **/ - public void ParseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - { - int csn = Symbol.ArrayLength(sortNames); - int cs = Sort.ArrayLength(sorts); - int cdn = Symbol.ArrayLength(declNames); - int cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.parseSmtlibString(nCtx(), str, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); - } - - /** - * Parse the given file using the SMT-LIB parser. - * - **/ - public void ParseSMTLIBFile(String fileName, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - { - int csn = Symbol.ArrayLength(sortNames); - int cs = Sort.ArrayLength(sorts); - int cdn = Symbol.ArrayLength(declNames); - int cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.parseSmtlibFile(nCtx(), fileName, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); - } - - /** - * The number of SMTLIB formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public int NumSMTLIBFormulas () { return Native.getSmtlibNumFormulas(nCtx()); } - - /** - * The formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public BoolExpr[] SMTLIBFormulas() - { - - - int n = NumSMTLIBFormulas(); - BoolExpr[] res = new BoolExpr[n]; - for (int i = 0; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibFormula(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB assumptions parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public int NumSMTLIBAssumptions () { return Native.getSmtlibNumAssumptions(nCtx()); } - - /** - * The assumptions parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public BoolExpr[] SMTLIBAssumptions() - { - - - int n = NumSMTLIBAssumptions(); - BoolExpr[] res = new BoolExpr[n]; - for (int i = 0; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibAssumption(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public int NumSMTLIBDecls () { return Native.getSmtlibNumDecls(nCtx()); } - - /** - * The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public FuncDecl[] SMTLIBDecls() - { - - - int n = NumSMTLIBDecls(); - FuncDecl[] res = new FuncDecl[n]; - for (int i = 0; i < n; i++) - res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB sorts parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public int NumSMTLIBSorts () { return Native.getSmtlibNumSorts(nCtx()); } - - /** - * The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - **/ - public Sort[] SMTLIBSorts() - { - - - int n = NumSMTLIBSorts(); - Sort[] res = new Sort[n]; - for (int i = 0; i < n; i++) - res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx(), i)); - return res; - } - - /** - * Parse the given string using the SMT-LIB2 parser. - * - * @return A conjunction of assertions in the scope (up to push/pop) at the end of the string. - **/ - public BoolExpr ParseSMTLIB2String(String str, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - { - - - int csn = Symbol.ArrayLength(sortNames); - int cs = Sort.ArrayLength(sorts); - int cdn = Symbol.ArrayLength(declNames); - int cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - return (BoolExpr)Expr.Create(this, Native.parseSmtlib2String(nCtx(), str, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls))); - } - - /** - * Parse the given file using the SMT-LIB2 parser. - * - **/ - public BoolExpr ParseSMTLIB2File(String fileName, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - { - - - int csn = Symbol.ArrayLength(sortNames); - int cs = Sort.ArrayLength(sorts); - int cdn = Symbol.ArrayLength(declNames); - int cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - return (BoolExpr)Expr.Create(this, Native.parseSmtlib2File(nCtx(), fileName, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls))); - } - - /** - * Creates a new Goal. - * - * Note that the Context must have been created with proof generation support if - * is set to true here. - * - * Indicates whether model generation should be enabled. - * Indicates whether unsat core generation should be enabled. - * Indicates whether proof generation should be enabled. - **/ - public Goal MkGoal(boolean models, boolean unsatCores, boolean proofs) - { - - - return new Goal(this, models, unsatCores, proofs); - } - - /** - * Creates a new ParameterSet. - **/ - public Params MkParams() - { - - - return new Params(this); - } - - /** - * The number of supported tactics. - **/ - public int NumTactics() { return Native.getNumTactics(nCtx()); } - - /** - * The names of all supported tactics. - **/ - public String[] TacticNames() - { - - - int n = NumTactics(); - String[] res = new String[n]; - for (int i = 0; i < n; i++) - res[i] = Native.getTacticName(nCtx(), i); - return res; - } - - /** - * Returns a string containing a description of the tactic with the given name. - **/ - public String TacticDescription(String name) - { - - - return Native.tacticGetDescr(nCtx(), name); - } - - /** - * Creates a new Tactic. - **/ - public Tactic MkTactic(String name) - { - - - return new Tactic(this, name); - } - - /** - * Create a tactic that applies to a Goal and - * then to every subgoal produced by . - **/ - public Tactic AndThen(Tactic t1, Tactic t2, Tactic[] ts) - { - - - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - CheckContextMatch(ts); - - long last = 0; - if (ts != null && ts.length > 0) - { - last = ts[ts.length - 1].NativeObject(); - for (int i = ts.length - 2; i >= 0; i--) - last = Native.tacticAndThen(nCtx(), ts[i].NativeObject(), last); - } - if (last != 0) - { - last = Native.tacticAndThen(nCtx(), t2.NativeObject(), last); - return new Tactic(this, Native.tacticAndThen(nCtx(), t1.NativeObject(), last)); - } - else - return new Tactic(this, Native.tacticAndThen(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a tactic that applies to a Goal and - * then to every subgoal produced by . - * - * Shorthand for AndThen. - * - **/ - public Tactic Then(Tactic t1, Tactic t2, Tactic[] ts) - { - - - - - - return AndThen(t1, t2, ts); - } - - /** - * Create a tactic that first applies to a Goal and - * if it fails then returns the result of applied to the Goal. - **/ - public Tactic OrElse(Tactic t1, Tactic t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new Tactic(this, Native.tacticOrElse(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a tactic that applies to a goal for milliseconds. - * - * If does not terminate within milliseconds, then it fails. - * - **/ - public Tactic TryFor(Tactic t, int ms) - { - - - - CheckContextMatch(t); - return new Tactic(this, Native.tacticTryFor(nCtx(), t.NativeObject(), ms)); - } - - /** - * Create a tactic that applies to a given goal if the probe - * evaluates to true. - * - * If evaluates to false, then the new tactic behaves like the skip tactic. - * - **/ - public Tactic When(Probe p, Tactic t) - { - - - - - CheckContextMatch(t); - CheckContextMatch(p); - return new Tactic(this, Native.tacticWhen(nCtx(), p.NativeObject(), t.NativeObject())); - } - - /** - * Create a tactic that applies to a given goal if the probe - * evaluates to true and otherwise. - **/ - public Tactic Cond(Probe p, Tactic t1, Tactic t2) - { - - - - - - CheckContextMatch(p); - CheckContextMatch(t1); - CheckContextMatch(t2); - return new Tactic(this, Native.tacticCond(nCtx(), p.NativeObject(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Create a tactic that keeps applying until the goal is not - * modified anymore or the maximum number of iterations is reached. - **/ - public Tactic Repeat(Tactic t, int max) - { - - - - CheckContextMatch(t); - return new Tactic(this, Native.tacticRepeat(nCtx(), t.NativeObject(), max)); - } - - /** - * Create a tactic that just returns the given goal. - **/ - public Tactic Skip() - { - - - return new Tactic(this, Native.tacticSkip(nCtx())); - } - - /** - * Create a tactic always fails. - **/ - public Tactic Fail() - { - - - return new Tactic(this, Native.tacticFail(nCtx())); - } - - /** - * Create a tactic that fails if the probe evaluates to false. - **/ - public Tactic FailIf(Probe p) - { - - - - CheckContextMatch(p); - return new Tactic(this, Native.tacticFailIf(nCtx(), p.NativeObject())); - } - - /** - * Create a tactic that fails if the goal is not triviall satisfiable (i.e., empty) - * or trivially unsatisfiable (i.e., contains `false'). - **/ - public Tactic FailIfNotDecided() - { - - - return new Tactic(this, Native.tacticFailIfNotDecided(nCtx())); - } - - /** - * Create a tactic that applies using the given set of parameters . - **/ - public Tactic UsingParams(Tactic t, Params p) - { - - - - - CheckContextMatch(t); - CheckContextMatch(p); - return new Tactic(this, Native.tacticUsingParams(nCtx(), t.NativeObject(), p.NativeObject())); - } - - /** - * Create a tactic that applies using the given set of parameters . - * Alias for UsingParams - **/ - public Tactic With(Tactic t, Params p) - { - - - - - return UsingParams(t, p); - } - - /** - * Create a tactic that applies the given tactics in parallel. - **/ - public Tactic ParOr(Tactic[] t) - { - - - - CheckContextMatch(t); - return new Tactic(this, Native.tacticParOr(nCtx(), Tactic.ArrayLength(t), Tactic.ArrayToNative(t))); - } - - /** - * Create a tactic that applies to a given goal and then - * to every subgoal produced by . The subgoals are processed in parallel. - **/ - public Tactic ParAndThen(Tactic t1, Tactic t2) - { - - - - - CheckContextMatch(t1); - CheckContextMatch(t2); - return new Tactic(this, Native.tacticParAndThen(nCtx(), t1.NativeObject(), t2.NativeObject())); - } - - /** - * Interrupt the execution of a Z3 procedure. - * This procedure can be used to interrupt: solvers, simplifiers and tactics. - **/ - public void Interrupt() - { - Native.interrupt(nCtx()); - } - - /** - * The number of supported Probes. - **/ - public int NumProbes() { return Native.getNumProbes(nCtx()); } - - /** - * The names of all supported Probes. - **/ - public String[] ProbeNames() - { - - - int n = NumProbes(); - String[] res = new String[n]; - for (int i = 0; i < n; i++) - res[i] = Native.getProbeName(nCtx(), i); - return res; - } - - /** - * Returns a string containing a description of the probe with the given name. - **/ - public String ProbeDescription(String name) - { - - - return Native.probeGetDescr(nCtx(), name); - } - - /** - * Creates a new Probe. - **/ - public Probe MkProbe(String name) - { - - - return new Probe(this, name); - } - - /** - * Create a probe that always evaluates to . - **/ - public Probe Const(double val) - { - - - return new Probe(this, Native.probeConst(nCtx(), val)); - } - - /** - * Create a probe that evaluates to "true" when the value returned by - * is less than the value returned by - **/ - public Probe Lt(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeLt(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value returned by - * is greater than the value returned by - **/ - public Probe Gt(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeGt(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value returned by - * is less than or equal the value returned by - **/ - public Probe Le(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeLe(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value returned by - * is greater than or equal the value returned by - **/ - public Probe Ge(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeGe(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value returned by - * is equal to the value returned by - **/ - public Probe Eq(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeEq(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value - * and evaluate to "true". - **/ - public Probe And(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeAnd(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value - * or evaluate to "true". - **/ - public Probe Or(Probe p1, Probe p2) - { - - - - - CheckContextMatch(p1); - CheckContextMatch(p2); - return new Probe(this, Native.probeOr(nCtx(), p1.NativeObject(), p2.NativeObject())); - } - - /** - * Create a probe that evaluates to "true" when the value - * does not evaluate to "true". - **/ - public Probe Not(Probe p) - { - - - - CheckContextMatch(p); - return new Probe(this, Native.probeNot(nCtx(), p.NativeObject())); - } - - /** - * Creates a new (incremental) solver. - * - * This solver also uses a set of builtin tactics for handling the first - * check-sat command, and check-sat commands that take more than a given - * number of milliseconds to be solved. - * - **/ - public Solver MkSolver(Symbol logic) - { - - - if (logic == null) - return new Solver(this, Native.mkSolver(nCtx())); - else - return new Solver(this, Native.mkSolverForLogic(nCtx(), logic.NativeObject())); - } - - /** - * Creates a new (incremental) solver. - * - **/ - public Solver MkSolver(String logic) - { - - - return MkSolver(MkSymbol(logic)); - } - - /** - * Creates a new (incremental) solver. - **/ - public Solver MkSimpleSolver() - { - - - return new Solver(this, Native.mkSimpleSolver(nCtx())); - } - - /** - * Creates a solver that is implemented using the given tactic. - * - * The solver supports the commands Push and Pop, but it - * will always solve each check from scratch. - * - **/ - public Solver MkSolver(Tactic t) - { - - - - return new Solver(this, Native.mkSolverFromTactic(nCtx(), t.NativeObject())); - } - - /** - * Create a Fixedpoint context. - **/ - public Fixedpoint MkFixedpoint() - { - - - return new Fixedpoint(this); - } - - - /** - * Wraps an AST. - * This function is used for transitions between native and - * managed objects. Note that must be a - * native object obtained from Z3 (e.g., through ) - * and that it must have a correct reference count (see e.g., - * . - * - * The native pointer to wrap. - **/ - public AST WrapAST(long nativeObject) - { - - return AST.Create(this, nativeObject); - } - - /** - * Unwraps an AST. - * This function is used for transitions between native and - * managed objects. It returns the native pointer to the AST. Note that - * AST objects are reference counted and unwrapping an AST disables automatic - * reference counting, i.e., all references to the IntPtr that is returned - * must be handled externally and through native calls (see e.g., - * ). - * - * The AST to unwrap. - **/ - public long UnwrapAST(AST a) - { - return a.NativeObject(); - } - - /** - * Return a string describing all available parameters to Expr.Simplify. - **/ - public String SimplifyHelp() - { - - - return Native.simplifyGetHelp(nCtx()); - } - - /** - * Retrieves parameter descriptions for simplifier. - **/ - public ParamDescrs SimplifyParameterDescriptions() { return new ParamDescrs(this, Native.simplifyGetParamDescrs(nCtx())); } - - /** - * Enable/disable printing of warning messages to the console. - * Note that this function is static and effects the behaviour of - * all contexts globally. - **/ - public static void ToggleWarningMessages(boolean enabled) - { - Native.toggleWarningMessages((enabled) ? true : false); - } - - ///// - ///// A delegate which is executed when an error is raised. - ///// - ///// - ///// Note that it is possible for memory leaks to occur if error handlers - ///// throw exceptions. - ///// - //public delegate void ErrorHandler(Context ctx, Z3_error_code errorCode, String errorString); - - ///// - ///// The OnError event. - ///// - //public event ErrorHandler OnError = null; - - /** - * Update a mutable configuration parameter. - * - * The list of all configuration parameters can be obtained using the Z3 executable: - * z3.exe -ini? - * Only a few configuration parameters are mutable once the context is created. - * An exception is thrown when trying to modify an immutable parameter. - * - * - **/ - public void UpdateParamValue(String id, String value) - { - Native.updateParamValue(nCtx(), id, value); - } - - /** - * Get a configuration parameter. - * - * Returns null if the parameter value does not exist. - * - * - **/ - public String GetParamValue(String id) - { - String res = new String(); - boolean r = Native.getParamValue(nCtx(), id, res); - if (!r) - return null; - else - return res; - } - - - long m_ctx = 0; - Native.errorHandler mNErrHandler = null; - long nCtx () { return m_ctx; } - - void NativeErrorHandler(long ctx, Z3_error_code errorCode) - { - // Do-nothing error handler. The wrappers in Z3.Native will throw exceptions upon errors. - } - - void InitContext() - { - setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT); - m_n_err_handler = new Native.errorHandler(NativeErrorHandler); // keep reference so it doesn't get collected. - Native.setErrorHandler(m_ctx, m_n_err_handler); - - } - - void CheckContextMatch(Z3Object other) - { - - - if (this == other.Context()) - throw new Z3Exception("Context mismatch"); - } - - void CheckContextMatch(Z3Object[] arr) - { - - - if (arr != null) - { - for (Z3Object a: arr) - { - // It was an assume, now we added the precondition, and we made it into an assert - CheckContextMatch(a); - } - } - } - - private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue(); - private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue(); - private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue(); - private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue(); - private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue(); - private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue(); - private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue(); - private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue(); - private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue(); - private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue(); - private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue(); - private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue(); - private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue(); - private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(); - private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(); - - AST.DecRefQueue AST_DRQ () { return m_AST_DRQ; } - ASTMap.DecRefQueue ASTMap_DRQ () { return m_ASTMap_DRQ; } - ASTVector.DecRefQueue ASTVector_DRQ () { return m_ASTVector_DRQ; } - ApplyResult.DecRefQueue ApplyResult_DRQ () { return m_ApplyResult_DRQ; } - FuncInterp.Entry.DecRefQueue FuncEntry_DRQ () { return m_FuncEntry_DRQ; } - FuncInterp.DecRefQueue FuncInterp_DRQ () { return m_FuncInterp_DRQ; } - Goal.DecRefQueue Goal_DRQ () { return m_Goal_DRQ; } - Model.DecRefQueue Model_DRQ () { return m_Model_DRQ; } - Params.DecRefQueue Params_DRQ () { return m_Params_DRQ; } - ParamDescrs.DecRefQueue ParamDescrs_DRQ () { return m_ParamDescrs_DRQ; } - Probe.DecRefQueue Probe_DRQ () { return m_Probe_DRQ; } - Solver.DecRefQueue Solver_DRQ () { return m_Solver_DRQ; } - Statistics.DecRefQueue Statistics_DRQ () { return m_Statistics_DRQ; } - Tactic.DecRefQueue Tactic_DRQ () { return m_Tactic_DRQ; } - Fixedpoint.DecRefQueue Fixedpoint_DRQ () { return m_Fixedpoint_DRQ; } - - - int refCount = 0; - - /** - * Finalizer. - **/ - protected void finalize() - { - // Console.WriteLine("Context Finalizer from " + System.Threading.Thread.CurrentThread.ManagedThreadId); - Dispose(); - - if (refCount == 0) - { - m_n_err_handler = null; - Native.delContext(m_ctx); - m_ctx = 0; - } - else - /* re-queue the finalizer */ - new Context(m_ctx); - } - - /** - * Disposes of the context. - **/ - public void Dispose() - { - // Console.WriteLine("Context Dispose from " + System.Threading.Thread.CurrentThread.ManagedThreadId); - AST_DRQ.Clear(this); - ASTMap_DRQ.Clear(this); - ASTVector_DRQ.Clear(this); - ApplyResult_DRQ.Clear(this); - FuncEntry_DRQ.Clear(this); - FuncInterp_DRQ.Clear(this); - Goal_DRQ.Clear(this); - Model_DRQ.Clear(this); - Params_DRQ.Clear(this); - Probe_DRQ.Clear(this); - Solver_DRQ.Clear(this); - Statistics_DRQ.Clear(this); - Tactic_DRQ.Clear(this); - Fixedpoint_DRQ.Clear(this); - - m_boolSort = null; - m_intSort = null; - m_realSort = null; - } - } diff --git a/src/api/java/com/Microsoft/Z3/DatatypeExpr.java b/src/api/java/com/Microsoft/Z3/DatatypeExpr.java deleted file mode 100644 index 32835baf5..000000000 --- a/src/api/java/com/Microsoft/Z3/DatatypeExpr.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was automatically generated from DatatypeExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Datatype expressions - **/ - public class DatatypeExpr extends Expr - { - /** Constructor for DatatypeExpr - **/ - protected DatatypeExpr(Context ctx) - { super(ctx); - - } - DatatypeExpr(Context ctx, long obj) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/DatatypeSort.java b/src/api/java/com/Microsoft/Z3/DatatypeSort.java deleted file mode 100644 index 536bfa8bb..000000000 --- a/src/api/java/com/Microsoft/Z3/DatatypeSort.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * This file was automatically generated from DatatypeSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public FuncDecl[] Constructors() - { - - - 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. - **/ - public FuncDecl[] Recognizers() - { - - - 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. - **/ - public FuncDecl[][] Accessors() - { - - - 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) { super(ctx, obj); { }} - - DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) - { super(ctx, Native.mkDatatype(ctx.nCtx(), name.NativeObject(), (int)constructors.length, ArrayToNative(constructors))); - - - - } - }; diff --git a/src/api/java/com/Microsoft/Z3/EnumSort.java b/src/api/java/com/Microsoft/Z3/EnumSort.java deleted file mode 100644 index ab0620003..000000000 --- a/src/api/java/com/Microsoft/Z3/EnumSort.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was automatically generated from EnumSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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 void ObjectInvariant() - { - - - - } - - - - private FuncDecl[] _constdecls = null, _testerdecls = null; - private Expr[] _consts = null; - - EnumSort(Context ctx, Symbol name, Symbol[] enumNames) - { 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); - } - }; diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.class deleted file mode 100644 index b94349266..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.class deleted file mode 100644 index b14685118..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.class deleted file mode 100644 index 6ba48582b..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.class deleted file mode 100644 index f9d486c4e..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.class deleted file mode 100644 index 0d278b16f..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class deleted file mode 100644 index eeee15f26..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.class deleted file mode 100644 index 84887bc3c..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.class deleted file mode 100644 index 2a137da1e..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.class deleted file mode 100644 index 3a4c6b219..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.class deleted file mode 100644 index 6623e4b8d..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Expr.java b/src/api/java/com/Microsoft/Z3/Expr.java deleted file mode 100644 index 9cf25ed11..000000000 --- a/src/api/java/com/Microsoft/Z3/Expr.java +++ /dev/null @@ -1,1446 +0,0 @@ -/** - * This file was automatically generated from Expr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Expressions are terms. - **/ - public class Expr extends AST - { - /** - * Returns a simplified version of the expression. - * A set of parameters to configure the simplifier - * - **/ - public Expr Simplify(Params p) throws Z3Exception - { - - - if (p == null) - return Expr.Create(Context(), Native.simplify(Context().nCtx(), NativeObject())); - else - return Expr.Create(Context(), Native.simplifyEx(Context().nCtx(), NativeObject(), p.NativeObject())); - } - - /** - * The function declaration of the function that is applied in this expression. - **/ - public FuncDecl FuncDecl() - { - - return new FuncDecl(Context(), Native.getAppDecl(Context().nCtx(), NativeObject())); - } - - /** - * Indicates whether the expression is the true or false expression - * or something else (Z3_L_UNDEF). - **/ - public Z3_lbool BoolValue() { return Z3_lbool.fromInt(Native.getBoolValue(Context().nCtx(), NativeObject())); } - - /** - * The number of arguments of the expression. - **/ - public int NumArgs() { return Native.getAppNumArgs(Context().nCtx(), NativeObject()); } - - /** - * The arguments of the expression. - **/ - 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.getAppArg(Context().nCtx(), NativeObject(), i)); - return res; - } - - /** - * Update the arguments of the expression using the arguments - * The number of new arguments should coincide with the current number of arguments. - **/ - public void Update(Expr[] args) throws Z3Exception - { - - - - Context().CheckContextMatch(args); - if (args.length != NumArgs()) - throw new Z3Exception("Number of arguments does not match"); - setNativeObject(Native.updateTerm(Context().nCtx(), NativeObject(), (int)args.length, Expr.ArrayToNative(args))); - } - - /** - * Substitute every occurrence of from[i] in the expression with to[i], for i smaller than num_exprs. - * - * The result is the new expression. The arrays from and to must have size num_exprs. - * For every i smaller than num_exprs, we must have that - * sort of from[i] must be equal to sort of to[i]. - * - **/ - public Expr Substitute(Expr[] from, Expr[] to) throws Z3Exception - { - - - - - - - Context().CheckContextMatch(from); - Context().CheckContextMatch(to); - if (from.length != to.length) - throw new Z3Exception("Argument sizes do not match"); - return Expr.Create(Context(), Native.substitute(Context().nCtx(), NativeObject(), (int)from.length, Expr.ArrayToNative(from), Expr.ArrayToNative(to))); - } - - /** - * Substitute every occurrence of from in the expression with to. - * - **/ - public Expr Substitute(Expr from, Expr to) throws Z3Exception - { - - - - - return Substitute(new Expr[] { from }, new Expr[] { to }); - } - - /** - * Substitute the free variables in the expression with the expressions in - * - * For every i smaller than num_exprs, the variable with de-Bruijn index i is replaced with term to[i]. - * - **/ - public Expr SubstituteVars(Expr[] to) throws Z3Exception - { - - - - - Context().CheckContextMatch(to); - return Expr.Create(Context(), Native.substituteVars(Context().nCtx(), NativeObject(), (int)to.length, Expr.ArrayToNative(to))); - } - - /** - * Translates (copies) the term to the Context . - * A context - * @return A copy of the term which is associated with - **/ - public Expr Translate(Context ctx) throws Z3Exception - { - - - - if (Context() == ctx) - return this; - else - return Expr.Create(ctx, Native.translate(Context().nCtx(), NativeObject(), ctx.nCtx())); - } - - /** - * Returns a string representation of the expression. - **/ - public String toString() - { - return super.toString(); - } - - /** - * Indicates whether the term is a numeral - **/ - public boolean IsNumeral() { return Native.isNumeralAst(Context().nCtx(), NativeObject()) ; } - - /** - * Indicates whether the term is well-sorted. - * @return True if the term is well-sorted, false otherwise. - **/ - public boolean IsWellSorted() { return Native.isWellSorted(Context().nCtx(), NativeObject()) ; } - - /** - * The Sort of the term. - **/ - public Sort Sort() - { - - return Sort.Create(Context(), Native.getSort(Context().nCtx(), NativeObject())); - } - - /** - * Indicates whether the term represents a constant. - **/ - public boolean IsConst() { return IsExpr() && NumArgs() == 0 && FuncDecl().DomainSize() == 0; } - - /** - * Indicates whether the term is an integer numeral. - **/ - public boolean IsIntNum() { return IsNumeral() && IsInt(); } - - /** - * Indicates whether the term is a real numeral. - **/ - public boolean IsRatNum() { return IsNumeral() && IsReal(); } - - /** - * Indicates whether the term is an algebraic number - **/ - public boolean IsAlgebraicNumber() { return Native.isAlgebraicNumber(Context().nCtx(), NativeObject()) ; } - - - /** - * Indicates whether the term has Boolean sort. - **/ - public boolean IsBool() - { - return (IsExpr() && - Native.isEqSort(Context().nCtx(), - Native.mkBoolSort(Context().nCtx()), - Native.getSort(Context().nCtx(), NativeObject())) ); - } - - /** - * Indicates whether the term is the constant true. - **/ - public boolean IsTrue() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TRUE; } - - /** - * Indicates whether the term is the constant false. - **/ - public boolean IsFalse() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_FALSE; } - - /** - * Indicates whether the term is an equality predicate. - **/ - public boolean IsEq() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EQ; } - - /** - * Indicates whether the term is an n-ary distinct predicate (every argument is mutually distinct). - **/ - public boolean IsDistinct() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_DISTINCT; } - - /** - * Indicates whether the term is a ternary if-then-else term - **/ - public boolean IsITE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ITE; } - - /** - * Indicates whether the term is an n-ary conjunction - **/ - public boolean IsAnd() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_AND; } - - /** - * Indicates whether the term is an n-ary disjunction - **/ - public boolean IsOr() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_OR; } - - /** - * Indicates whether the term is an if-and-only-if (Boolean equivalence, binary) - **/ - public boolean IsIff() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IFF; } - - /** - * Indicates whether the term is an exclusive or - **/ - public boolean IsXor() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_XOR; } - - /** - * Indicates whether the term is a negation - **/ - public boolean IsNot() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_NOT; } - - /** - * Indicates whether the term is an implication - **/ - public boolean IsImplies() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IMPLIES; } - - /** - * Indicates whether the term is of integer sort. - **/ - public boolean IsInt() - { - return (Native.isNumeralAst(Context().nCtx(), NativeObject()) && - Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_INT_SORT.toInt()); - } - - /** - * Indicates whether the term is of sort real. - **/ - public boolean IsReal() { return Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_REAL_SORT.toInt(); } - - /** - * Indicates whether the term is an arithmetic numeral. - **/ - public boolean IsArithmeticNumeral() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ANUM; } - - /** - * Indicates whether the term is a less-than-or-equal - **/ - public boolean IsLE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LE; } - - /** - * Indicates whether the term is a greater-than-or-equal - **/ - public boolean IsGE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_GE; } - - /** - * Indicates whether the term is a less-than - **/ - public boolean IsLT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LT; } - - /** - * Indicates whether the term is a greater-than - **/ - public boolean IsGT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_GT; } - - /** - * Indicates whether the term is addition (binary) - **/ - public boolean IsAdd() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ADD; } - - /** - * Indicates whether the term is subtraction (binary) - **/ - public boolean IsSub() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SUB; } - - /** - * Indicates whether the term is a unary minus - **/ - public boolean IsUMinus() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UMINUS; } - - /** - * Indicates whether the term is multiplication (binary) - **/ - public boolean IsMul() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_MUL; } - - /** - * Indicates whether the term is division (binary) - **/ - public boolean IsDiv() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_DIV; } - - /** - * Indicates whether the term is integer division (binary) - **/ - public boolean IsIDiv() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IDIV; } - - /** - * Indicates whether the term is remainder (binary) - **/ - public boolean IsRemainder() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_REM; } - - /** - * Indicates whether the term is modulus (binary) - **/ - public boolean IsModulus() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_MOD; } - - /** - * Indicates whether the term is a coercion of integer to real (unary) - **/ - public boolean IsIntToReal() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TO_REAL; } - - /** - * Indicates whether the term is a coercion of real to integer (unary) - **/ - public boolean IsRealToInt() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_TO_INT; } - - /** - * Indicates whether the term is a check that tests whether a real is integral (unary) - **/ - public boolean IsRealIsInt() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_IS_INT; } - - /** - * Indicates whether the term is of an array sort. - **/ - public boolean IsArray() - { - return (Native.isApp(Context().nCtx(), NativeObject()) && - Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject()))) - == Z3_sort_kind.Z3_ARRAY_SORT); - } - - /** - * Indicates whether the term is an array store. - * It satisfies select(store(a,i,v),j) = if i = j then v else select(a,j). - * Array store takes at least 3 arguments. - **/ - public boolean IsStore() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_STORE; } - - /** - * Indicates whether the term is an array select. - **/ - public boolean IsSelect() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SELECT; } - - /** - * Indicates whether the term is a constant array. - * For example, select(const(v),i) = v holds for every v and i. The function is unary. - **/ - public boolean IsConstantArray() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CONST_ARRAY; } - - /** - * Indicates whether the term is a default array. - * For example default(const(v)) = v. The function is unary. - **/ - public boolean IsDefaultArray() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; } - - /** - * Indicates whether the term is an array map. - * It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i. - **/ - public boolean IsArrayMap() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ARRAY_MAP; } - - /** - * Indicates whether the term is an as-array term. - * An as-array term is n array value that behaves as the function graph of the - * function passed as parameter. - **/ - public boolean IsAsArray() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_AS_ARRAY; } - - /** - * Indicates whether the term is set union - **/ - public boolean IsSetUnion() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_UNION; } - - /** - * Indicates whether the term is set intersection - **/ - public boolean IsSetIntersect() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_INTERSECT; } - - /** - * Indicates whether the term is set difference - **/ - public boolean IsSetDifference() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; } - - /** - * Indicates whether the term is set complement - **/ - public boolean IsSetComplement() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; } - - /** - * Indicates whether the term is set subset - **/ - public boolean IsSetSubset() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SET_SUBSET; } - - /** - * Indicates whether the terms is of bit-vector sort. - **/ - public boolean IsBV() { return Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_BV_SORT.toInt(); } - - /** - * Indicates whether the term is a bit-vector numeral - **/ - public boolean IsBVNumeral() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNUM; } - - /** - * Indicates whether the term is a one-bit bit-vector with value one - **/ - public boolean IsBVBitOne() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BIT1; } - - /** - * Indicates whether the term is a one-bit bit-vector with value zero - **/ - public boolean IsBVBitZero() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BIT0; } - - /** - * Indicates whether the term is a bit-vector unary minus - **/ - public boolean IsBVUMinus() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNEG; } - - /** - * Indicates whether the term is a bit-vector addition (binary) - **/ - public boolean IsBVAdd() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BADD; } - - /** - * Indicates whether the term is a bit-vector subtraction (binary) - **/ - public boolean IsBVSub() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSUB; } - - /** - * Indicates whether the term is a bit-vector multiplication (binary) - **/ - public boolean IsBVMul() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BMUL; } - - /** - * Indicates whether the term is a bit-vector signed division (binary) - **/ - public boolean IsBVSDiv() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSDIV; } - - /** - * Indicates whether the term is a bit-vector unsigned division (binary) - **/ - public boolean IsBVUDiv() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUDIV; } - - /** - * Indicates whether the term is a bit-vector signed remainder (binary) - **/ - public boolean IsBVSRem() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSREM; } - - /** - * Indicates whether the term is a bit-vector unsigned remainder (binary) - **/ - public boolean IsBVURem() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUREM; } - - /** - * Indicates whether the term is a bit-vector signed modulus - **/ - public boolean IsBVSMod() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSMOD; } - - /** - * Indicates whether the term is a bit-vector signed division by zero - **/ - boolean IsBVSDiv0 () { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSDIV0; } - - /** - * Indicates whether the term is a bit-vector unsigned division by zero - **/ - boolean IsBVUDiv0 () { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUDIV0; } - - /** - * Indicates whether the term is a bit-vector signed remainder by zero - **/ - boolean IsBVSRem0 () { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSREM0; } - - /** - * Indicates whether the term is a bit-vector unsigned remainder by zero - **/ - boolean IsBVURem0 () { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BUREM0; } - - /** - * Indicates whether the term is a bit-vector signed modulus by zero - **/ - boolean IsBVSMod0 () { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSMOD0; } - - /** - * Indicates whether the term is an unsigned bit-vector less-than-or-equal - **/ - public boolean IsBVULE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ULEQ; } - - /** - * Indicates whether the term is a signed bit-vector less-than-or-equal - **/ - public boolean IsBVSLE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SLEQ; } - - /** - * Indicates whether the term is an unsigned bit-vector greater-than-or-equal - **/ - public boolean IsBVUGE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UGEQ; } - - /** - * Indicates whether the term is a signed bit-vector greater-than-or-equal - **/ - public boolean IsBVSGE() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SGEQ; } - - /** - * Indicates whether the term is an unsigned bit-vector less-than - **/ - public boolean IsBVULT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ULT; } - - /** - * Indicates whether the term is a signed bit-vector less-than - **/ - public boolean IsBVSLT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SLT; } - - /** - * Indicates whether the term is an unsigned bit-vector greater-than - **/ - public boolean IsBVUGT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_UGT; } - - /** - * Indicates whether the term is a signed bit-vector greater-than - **/ - public boolean IsBVSGT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SGT; } - - /** - * Indicates whether the term is a bit-wise AND - **/ - public boolean IsBVAND() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BAND; } - - /** - * Indicates whether the term is a bit-wise OR - **/ - public boolean IsBVOR() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BOR; } - - /** - * Indicates whether the term is a bit-wise NOT - **/ - public boolean IsBVNOT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNOT; } - - /** - * Indicates whether the term is a bit-wise XOR - **/ - public boolean IsBVXOR() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BXOR; } - - /** - * Indicates whether the term is a bit-wise NAND - **/ - public boolean IsBVNAND() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNAND; } - - /** - * Indicates whether the term is a bit-wise NOR - **/ - public boolean IsBVNOR() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BNOR; } - - /** - * Indicates whether the term is a bit-wise XNOR - **/ - public boolean IsBVXNOR() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BXNOR; } - - /** - * Indicates whether the term is a bit-vector concatenation (binary) - **/ - public boolean IsBVConcat() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CONCAT; } - - /** - * Indicates whether the term is a bit-vector sign extension - **/ - public boolean IsBVSignExtension() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_SIGN_EXT; } - - /** - * Indicates whether the term is a bit-vector zero extension - **/ - public boolean IsBVZeroExtension() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ZERO_EXT; } - - /** - * Indicates whether the term is a bit-vector extraction - **/ - public boolean IsBVExtract() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXTRACT; } - - /** - * Indicates whether the term is a bit-vector repetition - **/ - public boolean IsBVRepeat() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_REPEAT; } - - /** - * Indicates whether the term is a bit-vector reduce OR - **/ - public boolean IsBVReduceOR() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BREDOR; } - - /** - * Indicates whether the term is a bit-vector reduce AND - **/ - public boolean IsBVReduceAND() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BREDAND; } - - /** - * Indicates whether the term is a bit-vector comparison - **/ - public boolean IsBVComp() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BCOMP; } - - /** - * Indicates whether the term is a bit-vector shift left - **/ - public boolean IsBVShiftLeft() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BSHL; } - - /** - * Indicates whether the term is a bit-vector logical shift right - **/ - public boolean IsBVShiftRightLogical() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BLSHR; } - - /** - * Indicates whether the term is a bit-vector arithmetic shift left - **/ - public boolean IsBVShiftRightArithmetic() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BASHR; } - - /** - * Indicates whether the term is a bit-vector rotate left - **/ - public boolean IsBVRotateLeft() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ROTATE_LEFT; } - - /** - * Indicates whether the term is a bit-vector rotate right - **/ - public boolean IsBVRotateRight() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; } - - /** - * Indicates whether the term is a bit-vector rotate left (extended) - * Similar to Z3_OP_ROTATE_LEFT, but it is a binary operator instead of a parametric one. - **/ - public boolean IsBVRotateLeftExtended() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; } - - /** - * Indicates whether the term is a bit-vector rotate right (extended) - * Similar to Z3_OP_ROTATE_RIGHT, but it is a binary operator instead of a parametric one. - **/ - public boolean IsBVRotateRightExtended() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; } - - /** - * Indicates whether the term is a coercion from integer to bit-vector - * This function is not supported by the decision procedures. Only the most - * rudimentary simplification rules are applied to this function. - **/ - public boolean IsIntToBV() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_INT2BV; } - - /** - * Indicates whether the term is a coercion from bit-vector to integer - * This function is not supported by the decision procedures. Only the most - * rudimentary simplification rules are applied to this function. - **/ - public boolean IsBVToInt() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_BV2INT; } - - /** - * Indicates whether the term is a bit-vector carry - * Compute the carry bit in a full-adder. The meaning is given by the - * equivalence (carry l1 l2 l3) <=> (or (and l1 l2) (and l1 l3) (and l2 l3))) - **/ - public boolean IsBVCarry() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_CARRY; } - - /** - * Indicates whether the term is a bit-vector ternary XOR - * The meaning is given by the equivalence (xor3 l1 l2 l3) <=> (xor (xor l1 l2) l3) - **/ - public boolean IsBVXOR3() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_XOR3; } - - - /** - * Indicates whether the term is a label (used by the Boogie Verification condition generator). - * The label has two parameters, a string and a Boolean polarity. It takes one argument, a formula. - **/ - public boolean IsLabel() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LABEL; } - - /** - * Indicates whether the term is a label literal (used by the Boogie Verification condition generator). - * A label literal has a set of string parameters. It takes no arguments. - **/ - public boolean IsLabelLit() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_LABEL_LIT; } - - /** - * Indicates whether the term is a binary equivalence modulo namings. - * This binary predicate is used in proof terms. - * It captures equisatisfiability and equivalence modulo renamings. - **/ - public boolean IsOEQ() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_OEQ; } - - /** - * Indicates whether the term is a Proof for the expression 'true'. - **/ - public boolean IsProofTrue() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRUE; } - - /** - * Indicates whether the term is a proof for a fact asserted by the user. - **/ - public boolean IsProofAsserted() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_ASSERTED; } - - /** - * Indicates whether the term is a proof for a fact (tagged as goal) asserted by the user. - **/ - public boolean IsProofGoal() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_GOAL; } - - /** - * Indicates whether the term is proof via modus ponens - * - * Given a proof for p and a proof for (implies p q), produces a proof for q. - * T1: p - * T2: (implies p q) - * [mp T1 T2]: q - * The second antecedents may also be a proof for (iff p q). - **/ - public boolean IsProofModusPonens() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; } - - /** - * Indicates whether the term is a proof for (R t t), where R is a reflexive relation. - * This proof object has no antecedents. - * The only reflexive relations that are used are - * equivalence modulo namings, equality and equivalence. - * That is, R is either '~', '=' or 'iff'. - **/ - public boolean IsProofReflexivity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } - - /** - * Indicates whether the term is proof by symmetricity of a relation - * - * Given an symmetric relation R and a proof for (R t s), produces a proof for (R s t). - * T1: (R t s) - * [symmetry T1]: (R s t) - * T1 is the antecedent of this proof object. - * - **/ - public boolean IsProofSymmetry() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } - - /** - * Indicates whether the term is a proof by transitivity of a relation - * - * Given a transitive relation R, and proofs for (R t s) and (R s u), produces a proof - * for (R t u). - * T1: (R t s) - * T2: (R s u) - * [trans T1 T2]: (R t u) - * - **/ - public boolean IsProofTransitivity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } - - /** - * Indicates whether the term is a proof by condensed transitivity of a relation - * - * Condensed transitivity proof. This proof object is only used if the parameter PROOF_MODE is 1. - * It combines several symmetry and transitivity proofs. - * Example: - * T1: (R a b) - * T2: (R c b) - * T3: (R c d) - * [trans* T1 T2 T3]: (R a d) - * R must be a symmetric and transitive relation. - * - * Assuming that this proof object is a proof for (R s t), then - * a proof checker must check if it is possible to prove (R s t) - * using the antecedents, symmetry and transitivity. That is, - * if there is a path from s to t, if we view every - * antecedent (R a b) as an edge between a and b. - * - **/ - public boolean IsProofTransitivityStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } - - - /** - * Indicates whether the term is a monotonicity proof object. - * - * T1: (R t_1 s_1) - * ... - * Tn: (R t_n s_n) - * [monotonicity T1 ... Tn]: (R (f t_1 ... t_n) (f s_1 ... s_n)) - * Remark: if t_i == s_i, then the antecedent Ti is suppressed. - * That is, reflexivity proofs are supressed to save space. - * - **/ - public boolean IsProofMonotonicity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } - - /** - * Indicates whether the term is a quant-intro proof - * - * Given a proof for (~ p q), produces a proof for (~ (forall (x) p) (forall (x) q)). - * T1: (~ p q) - * [quant-intro T1]: (~ (forall (x) p) (forall (x) q)) - * - **/ - public boolean IsProofQuantIntro() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } - - /** - * Indicates whether the term is a distributivity proof object. - * - * Given that f (= or) distributes over g (= and), produces a proof for - * (= (f a (g c d)) - * (g (f a c) (f a d))) - * If f and g are associative, this proof also justifies the following equality: - * (= (f (g a b) (g c d)) - * (g (f a c) (f a d) (f b c) (f b d))) - * where each f and g can have arbitrary number of arguments. - * - * This proof object has no antecedents. - * Remark. This rule is used by the CNF conversion pass and - * instantiated by f = or, and g = and. - * - **/ - public boolean IsProofDistributivity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } - - /** - * Indicates whether the term is a proof by elimination of AND - * - * Given a proof for (and l_1 ... l_n), produces a proof for l_i - * T1: (and l_1 ... l_n) - * [and-elim T1]: l_i - * - **/ - public boolean IsProofAndElimination() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } - - /** - * Indicates whether the term is a proof by eliminiation of not-or - * - * Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). - * T1: (not (or l_1 ... l_n)) - * [not-or-elim T1]: (not l_i) - * - **/ - public boolean IsProofOrElimination() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } - - /** - * Indicates whether the term is a proof by rewriting - * - * A proof for a local rewriting step (= t s). - * The head function symbol of t is interpreted. - * - * This proof object has no antecedents. - * The conclusion of a rewrite rule is either an equality (= t s), - * an equivalence (iff t s), or equi-satisfiability (~ t s). - * Remark: if f is bool, then = is iff. - * - * Examples: - * (= (+ x 0) x) - * (= (+ x 1 2) (+ 3 x)) - * (iff (or x false) x) - * - **/ - public boolean IsProofRewrite() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE; } - - /** - * Indicates whether the term is a proof by rewriting - * - * A proof for rewriting an expression t into an expression s. - * This proof object is used if the parameter PROOF_MODE is 1. - * This proof object can have n antecedents. - * The antecedents are proofs for equalities used as substitution rules. - * The object is also used in a few cases if the parameter PROOF_MODE is 2. - * The cases are: - * - When applying contextual simplification (CONTEXT_SIMPLIFIER=true) - * - When converting bit-vectors to Booleans (BIT2BOOL=true) - * - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true) - * - **/ - public boolean IsProofRewriteStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } - - /** - * Indicates whether the term is a proof for pulling quantifiers out. - * - * A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. - * - **/ - public boolean IsProofPullQuant() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } - - /** - * Indicates whether the term is a proof for pulling quantifiers out. - * - * A proof for (iff P Q) where Q is in prenex normal form. - * This proof object is only used if the parameter PROOF_MODE is 1. - * This proof object has no antecedents - * - **/ - public boolean IsProofPullQuantStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } - - /** - * Indicates whether the term is a proof for pushing quantifiers in. - * - * A proof for: - * (iff (forall (x_1 ... x_m) (and p_1[x_1 ... x_m] ... p_n[x_1 ... x_m])) - * (and (forall (x_1 ... x_m) p_1[x_1 ... x_m]) - * ... - * (forall (x_1 ... x_m) p_n[x_1 ... x_m]))) - * This proof object has no antecedents - * - **/ - public boolean IsProofPushQuant() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } - - /** - * Indicates whether the term is a proof for elimination of unused variables. - * - * A proof for (iff (forall (x_1 ... x_n y_1 ... y_m) p[x_1 ... x_n]) - * (forall (x_1 ... x_n) p[x_1 ... x_n])) - * - * It is used to justify the elimination of unused variables. - * This proof object has no antecedents. - * - **/ - public boolean IsProofElimUnusedVars() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } - - /** - * Indicates whether the term is a proof for destructive equality resolution - * - * A proof for destructive equality resolution: - * (iff (forall (x) (or (not (= x t)) P[x])) P[t]) - * if x does not occur in t. - * - * This proof object has no antecedents. - * - * Several variables can be eliminated simultaneously. - * - **/ - public boolean IsProofDER() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DER; } - - /** - * Indicates whether the term is a proof for quantifier instantiation - * - * A proof of (or (not (forall (x) (P x))) (P a)) - * - **/ - public boolean IsProofQuantInst() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } - - /** - * Indicates whether the term is a hypthesis marker. - * Mark a hypothesis in a natural deduction style proof. - **/ - public boolean IsProofHypothesis() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } - - /** - * Indicates whether the term is a proof by lemma - * - * T1: false - * [lemma T1]: (or (not l_1) ... (not l_n)) - * - * This proof object has one antecedent: a hypothetical proof for false. - * It converts the proof in a proof for (or (not l_1) ... (not l_n)), - * when T1 contains the hypotheses: l_1, ..., l_n. - * - **/ - public boolean IsProofLemma() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_LEMMA; } - - /** - * Indicates whether the term is a proof by unit resolution - * - * T1: (or l_1 ... l_n l_1' ... l_m') - * T2: (not l_1) - * ... - * T(n+1): (not l_n) - * [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m') - * - **/ - public boolean IsProofUnitResolution() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } - - /** - * Indicates whether the term is a proof by iff-true - * - * T1: p - * [iff-true T1]: (iff p true) - * - **/ - public boolean IsProofIFFTrue() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; } - - /** - * Indicates whether the term is a proof by iff-false - * - * T1: (not p) - * [iff-false T1]: (iff p false) - * - **/ - public boolean IsProofIFFFalse() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } - - /** - * Indicates whether the term is a proof by commutativity - * - * [comm]: (= (f a b) (f b a)) - * - * f is a commutative operator. - * - * This proof object has no antecedents. - * Remark: if f is bool, then = is iff. - * - **/ - public boolean IsProofCommutativity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } - - /** - * Indicates whether the term is a proof for Tseitin-like axioms - * - * Proof object used to justify Tseitin's like axioms: - * - * (or (not (and p q)) p) - * (or (not (and p q)) q) - * (or (not (and p q r)) p) - * (or (not (and p q r)) q) - * (or (not (and p q r)) r) - * ... - * (or (and p q) (not p) (not q)) - * (or (not (or p q)) p q) - * (or (or p q) (not p)) - * (or (or p q) (not q)) - * (or (not (iff p q)) (not p) q) - * (or (not (iff p q)) p (not q)) - * (or (iff p q) (not p) (not q)) - * (or (iff p q) p q) - * (or (not (ite a b c)) (not a) b) - * (or (not (ite a b c)) a c) - * (or (ite a b c) (not a) (not b)) - * (or (ite a b c) a (not c)) - * (or (not (not a)) (not a)) - * (or (not a) a) - * - * This proof object has no antecedents. - * Note: all axioms are propositional tautologies. - * Note also that 'and' and 'or' can take multiple arguments. - * You can recover the propositional tautologies by - * unfolding the Boolean connectives in the axioms a small - * bounded number of steps (=3). - * - **/ - public boolean IsProofDefAxiom() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } - - /** - * Indicates whether the term is a proof for introduction of a name - * - * Introduces a name for a formula/term. - * Suppose e is an expression with free variables x, and def-intro - * introduces the name n(x). The possible cases are: - * - * When e is of Boolean type: - * [def-intro]: (and (or n (not e)) (or (not n) e)) - * - * or: - * [def-intro]: (or (not n) e) - * when e only occurs positively. - * - * When e is of the form (ite cond th el): - * [def-intro]: (and (or (not cond) (= n th)) (or cond (= n el))) - * - * Otherwise: - * [def-intro]: (= n e) - * - **/ - public boolean IsProofDefIntro() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } - - /** - * Indicates whether the term is a proof for application of a definition - * - * [apply-def T1]: F ~ n - * F is 'equivalent' to n, given that T1 is a proof that - * n is a name for F. - * - **/ - public boolean IsProofApplyDef() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } - - /** - * Indicates whether the term is a proof iff-oeq - * - * T1: (iff p q) - * [iff~ T1]: (~ p q) - * - **/ - public boolean IsProofIFFOEQ() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } - - /** - * Indicates whether the term is a proof for a positive NNF step - * - * Proof for a (positive) NNF step. Example: - * - * T1: (not s_1) ~ r_1 - * T2: (not s_2) ~ r_2 - * T3: s_1 ~ r_1' - * T4: s_2 ~ r_2' - * [nnf-pos T1 T2 T3 T4]: (~ (iff s_1 s_2) - * (and (or r_1 r_2') (or r_1' r_2))) - * - * The negation normal form steps NNF_POS and NNF_NEG are used in the following cases: - * (a) When creating the NNF of a positive force quantifier. - * The quantifier is retained (unless the bound variables are eliminated). - * Example - * T1: q ~ q_new - * [nnf-pos T1]: (~ (forall (x T) q) (forall (x T) q_new)) - * - * (b) When recursively creating NNF over Boolean formulas, where the top-level - * connective is changed during NNF conversion. The relevant Boolean connectives - * for NNF_POS are 'implies', 'iff', 'xor', 'ite'. - * NNF_NEG furthermore handles the case where negation is pushed - * over Boolean connectives 'and' and 'or'. - * - **/ - public boolean IsProofNNFPos() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_POS; } - - /** - * Indicates whether the term is a proof for a negative NNF step - * - * Proof for a (negative) NNF step. Examples: - * - * T1: (not s_1) ~ r_1 - * ... - * Tn: (not s_n) ~ r_n - * [nnf-neg T1 ... Tn]: (not (and s_1 ... s_n)) ~ (or r_1 ... r_n) - * and - * T1: (not s_1) ~ r_1 - * ... - * Tn: (not s_n) ~ r_n - * [nnf-neg T1 ... Tn]: (not (or s_1 ... s_n)) ~ (and r_1 ... r_n) - * and - * T1: (not s_1) ~ r_1 - * T2: (not s_2) ~ r_2 - * T3: s_1 ~ r_1' - * T4: s_2 ~ r_2' - * [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2)) - * (and (or r_1 r_2) (or r_1' r_2'))) - * - **/ - public boolean IsProofNNFNeg() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } - - /** - * Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form. - * - * A proof for (~ P Q) where Q is in negation normal form. - * - * This proof object is only used if the parameter PROOF_MODE is 1. - * - * This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - * - **/ - public boolean IsProofNNFStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } - - /** - * Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form. - * - * A proof for (~ P Q) where Q is in conjunctive normal form. - * This proof object is only used if the parameter PROOF_MODE is 1. - * This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - * - **/ - public boolean IsProofCNFStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } - - /** - * Indicates whether the term is a proof for a Skolemization step - * - * Proof for: - * - * [sk]: (~ (not (forall x (p x y))) (not (p (sk y) y))) - * [sk]: (~ (exists x (p x y)) (p (sk y) y)) - * - * This proof object has no antecedents. - * - **/ - public boolean IsProofSkolemize() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } - - /** - * Indicates whether the term is a proof by modus ponens for equi-satisfiability. - * - * Modus ponens style rule for equi-satisfiability. - * T1: p - * T2: (~ p q) - * [mp~ T1 T2]: q - * - **/ - public boolean IsProofModusPonensOEQ() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } - - /** - * Indicates whether the term is a proof for theory lemma - * - * Generic proof for theory lemmas. - * - * The theory lemma function comes with one or more parameters. - * The first parameter indicates the name of the theory. - * For the theory of arithmetic, additional parameters provide hints for - * checking the theory lemma. - * The hints for arithmetic are: - * - farkas - followed by rational coefficients. Multiply the coefficients to the - * inequalities in the lemma, add the (negated) inequalities and obtain a contradiction. - * - triangle-eq - Indicates a lemma related to the equivalence: - * (iff (= t1 t2) (and (<= t1 t2) (<= t2 t1))) - * - gcd-test - Indicates an integer linear arithmetic lemma that uses a gcd test. - * - **/ - public boolean IsProofTheoryLemma() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; } - - /** - * Indicates whether the term is of an array sort. - **/ - public boolean IsRelation() - { - return (Native.isApp(Context().nCtx(), NativeObject()) && - Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) - == Z3_sort_kind.Z3_RELATION_SORT.toInt()); - } - - /** - * Indicates whether the term is an relation store - * - * Insert a record into a relation. - * The function takes n+1 arguments, where the first argument is the relation and the remaining n elements - * correspond to the n columns of the relation. - * - **/ - public boolean IsRelationStore() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_STORE; } - - /** - * Indicates whether the term is an empty relation - **/ - public boolean IsEmptyRelation() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_EMPTY; } - - /** - * Indicates whether the term is a test for the emptiness of a relation - **/ - public boolean IsIsEmptyRelation() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; } - - /** - * Indicates whether the term is a relational join - **/ - public boolean IsRelationalJoin() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_JOIN; } - - /** - * Indicates whether the term is the union or convex hull of two relations. - * The function takes two arguments. - **/ - public boolean IsRelationUnion() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_UNION; } - - /** - * Indicates whether the term is the widening of two relations - * The function takes two arguments. - **/ - public boolean IsRelationWiden() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_WIDEN; } - - /** - * Indicates whether the term is a projection of columns (provided as numbers in the parameters). - * The function takes one argument. - **/ - public boolean IsRelationProject() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_PROJECT; } - - /** - * Indicates whether the term is a relation filter - * - * Filter (restrict) a relation with respect to a predicate. - * The first argument is a relation. - * The second argument is a predicate with free de-Brujin indices - * corresponding to the columns of the relation. - * So the first column in the relation has index 0. - * - **/ - public boolean IsRelationFilter() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_FILTER; } - - /** - * Indicates whether the term is an intersection of a relation with the negation of another. - * - * Intersect the first relation with respect to negation - * of the second relation (the function takes two arguments). - * Logically, the specification can be described by a function - * - * target = filter_by_negation(pos, neg, columns) - * - * where columns are pairs c1, d1, .., cN, dN of columns from pos and neg, such that - * target are elements in x in pos, such that there is no y in neg that agrees with - * x on the columns c1, d1, .., cN, dN. - * - **/ - public boolean IsRelationNegationFilter() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } - - /** - * Indicates whether the term is the renaming of a column in a relation - * - * The function takes one argument. - * The parameters contain the renaming as a cycle. - * - **/ - public boolean IsRelationRename() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_RENAME; } - - /** - * Indicates whether the term is the complement of a relation - **/ - public boolean IsRelationComplement() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } - - /** - * Indicates whether the term is a relational select - * - * Check if a record is an element of the relation. - * The function takes n+1 arguments, where the first argument is a relation, - * and the remaining n arguments correspond to a record. - * - **/ - public boolean IsRelationSelect() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_SELECT; } - - /** - * Indicates whether the term is a relational clone (copy) - * - * Create a fresh copy (clone) of a relation. - * The function is logically the identity, but - * in the context of a register machine allows - * for terms of kind - * to perform destructive updates to the first argument. - * - **/ - public boolean IsRelationClone() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_CLONE; } - - /** - * Indicates whether the term is of an array sort. - **/ - public boolean IsFiniteDomain() - { - return (Native.isApp(Context().nCtx(), NativeObject()) && - Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT.toInt()); - } - - /** - * Indicates whether the term is a less than predicate over a finite domain. - **/ - public boolean IsFiniteDomainLT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_FD_LT; } - - /** - * The de-Burijn index of a bound variable. - * - * Bound variables are indexed by de-Bruijn indices. It is perhaps easiest to explain - * the meaning of de-Bruijn indices by indicating the compilation process from - * non-de-Bruijn formulas to de-Bruijn format. - * - * abs(forall (x1) phi) = forall (x1) abs1(phi, x1, 0) - * abs(forall (x1, x2) phi) = abs(forall (x1) abs(forall (x2) phi)) - * abs1(x, x, n) = b_n - * abs1(y, x, n) = y - * abs1(f(t1,...,tn), x, n) = f(abs1(t1,x,n), ..., abs1(tn,x,n)) - * abs1(forall (x1) phi, x, n) = forall (x1) (abs1(phi, x, n+1)) - * - * The last line is significant: the index of a bound variable is different depending - * on the scope in which it appears. The deeper x appears, the higher is its - * index. - * - **/ - public int Index() throws Z3Exception - { - if (!IsVar()) - throw new Z3Exception("Term is not a bound variable."); - - - - return Native.getIndexValue(Context().nCtx(), NativeObject()); - } - - /** - * Constructor for Expr - **/ - protected Expr(Context ctx) { super(ctx); { }} - /** - * Constructor for Expr - **/ - protected Expr(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }} - - void CheckNativeObject(long obj) throws Z3Exception - { - if (Native.isApp(Context().nCtx(), obj) ^ true && - Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() && - Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) - throw new Z3Exception("Underlying object is not a term"); - super.CheckNativeObject(obj); - } - - static Expr Create(Context ctx, FuncDecl f, Expr[] arguments) throws Z3Exception - { - - - - - long obj = Native.mkApp(ctx.nCtx(), f.NativeObject(), - AST.ArrayLength(arguments), - AST.ArrayToNative(arguments)); - return Create(ctx, obj); - } - - static Expr Create(Context ctx, long obj) throws Z3Exception - { - - - - Z3_ast_kind k = Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)); - if (k == Z3_ast_kind.Z3_QUANTIFIER_AST) - return new Quantifier(ctx, obj); - long s = Native.getSort(ctx.nCtx(), obj); - Z3_sort_kind sk = Z3_sort_kind.fromInt(Native.getSortKind(ctx.nCtx(), s)); - - if (Native.isAlgebraicNumber(ctx.nCtx(), obj) ) // is this a numeral ast? - return new AlgebraicNum(ctx, obj); - - if (Native.isNumeralAst(ctx.nCtx(), obj) ) - { - switch (sk) - { - case Z3_INT_SORT: return new IntNum(ctx, obj); - case Z3_REAL_SORT: return new RatNum(ctx, obj); - case Z3_BV_SORT: return new BitVecNum(ctx, obj); - } - } - - switch (sk) - { - case Z3_BOOL_SORT: return new BoolExpr(ctx, obj); - case Z3_INT_SORT: return new IntExpr(ctx, obj); - case Z3_REAL_SORT: return new RealExpr(ctx, obj); - case Z3_BV_SORT: return new BitVecExpr(ctx, obj); - case Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj); - case Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj); - } - - return new Expr(ctx, obj); - } - } diff --git a/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java b/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java deleted file mode 100644 index 49a2c40c5..000000000 --- a/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file was automatically generated from FiniteDomainSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Finite domain sorts. - **/ - public class FiniteDomainSort extends Sort - { - /** - * The size of the finite domain sort. - **/ - public long Size() - { - long res = 0; - Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res); - return res; - } - - FiniteDomainSort(Context ctx, long obj) - { super(ctx, obj); - - } - FiniteDomainSort(Context ctx, Symbol name, long size) - { super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.NativeObject(), size)); - - - - } - } diff --git a/src/api/java/com/Microsoft/Z3/Fixedpoint.java b/src/api/java/com/Microsoft/Z3/Fixedpoint.java deleted file mode 100644 index e2cc2a1e9..000000000 --- a/src/api/java/com/Microsoft/Z3/Fixedpoint.java +++ /dev/null @@ -1,307 +0,0 @@ -/** - * This file was automatically generated from Fixedpoint.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public void setParameters(Params value) - { - - Context().CheckContextMatch(value); - Native.fixedpointSetParams(Context().nCtx(), NativeObject(), value.NativeObject()); - } - - /** - * Retrieves parameter descriptions for Fixedpoint solver. - **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.fixedpointGetParamDescrs(Context().nCtx(), NativeObject())); } - - - /** - * Assert a constraint (or multiple) into the fixedpoint solver. - **/ - public void Assert(BoolExpr[] constraints) - { - - - - Context().CheckContextMatch(constraints); - for (BoolExpr a: constraints) - { - Native.fixedpointAssert(Context().nCtx(), NativeObject(), a.NativeObject()); - } - } - - /** - * Register predicate as recursive relation. - **/ - public void RegisterRelation(FuncDecl f) - { - - - Context().CheckContextMatch(f); - Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), f.NativeObject()); - } - - /** - * Add rule into the fixedpoint solver. - **/ - public void AddRule(BoolExpr rule, Symbol name) - { - - - Context().CheckContextMatch(rule); - Native.fixedpointAddRule(Context().nCtx(), NativeObject(), rule.NativeObject(), AST.GetNativeObject(name)); - } - - /** - * Add table fact to the fixedpoint solver. - **/ - public void AddFact(FuncDecl pred, int[] args) - { - - - - 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. - **/ - public Status Query(BoolExpr query) - { - - - 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. - **/ - public Status Query(FuncDecl[] relations) - { - - - - 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. - * - **/ - public void Push() - { - Native.fixedpointPush(Context().nCtx(), NativeObject()); - } - - /** - * Backtrack one backtracking point. - * Note that an exception is thrown if Pop is called without a corresponding Push - * - **/ - public void Pop() - { - Native.fixedpointPop(Context().nCtx(), NativeObject()); - } - - - /** - * Update named rule into in the fixedpoint solver. - **/ - public void UpdateRule(BoolExpr rule, Symbol name) - { - - - 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. - **/ - public Expr GetAnswer() - { - 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. - **/ - public Expr GetCoverDelta(int level, FuncDecl predicate) - { - long res = Native.fixedpointGetCoverDelta(Context().nCtx(), NativeObject(), level, predicate.NativeObject()); - return (res == 0) ? null : Expr.Create(Context(), res); - } - - /** - * Add property about the predicate. - * The property is added at level. - **/ - 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. - **/ - public BoolExpr[] Rules() - { - - - 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. - **/ - public BoolExpr[] Assertions() - { - - - 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) - { super(ctx, obj); - - } - Fixedpoint(Context ctx) - { super(ctx, Native.mkFixedpoint(ctx.nCtx())); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Fixedpoint_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Fixedpoint_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/FuncDecl.java b/src/api/java/com/Microsoft/Z3/FuncDecl.java deleted file mode 100644 index 82cccc36f..000000000 --- a/src/api/java/com/Microsoft/Z3/FuncDecl.java +++ /dev/null @@ -1,287 +0,0 @@ -/** - * This file was automatically generated from FuncDecl.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Function declarations. - **/ - public class FuncDecl extends AST - { - /** - * Comparison operator. - * @return True if and share the same context and are equal, false otherwise. - **/ - /* Overloaded operators are not translated. */ - - /** - * Comparison operator. - * @return True if and 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() - { - 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() { return Native.getFuncDeclId(Context().nCtx(), NativeObject()); } - - /** - * The arity of the function declaration - **/ - public int Arity() { return Native.getArity(Context().nCtx(), NativeObject()); } - - /** - * The size of the domain of the function declaration - * - **/ - public int DomainSize() { return Native.getDomainSize(Context().nCtx(), NativeObject()); } - - /** - * The domain of the function declaration - **/ - public Sort[] Domain() - { - - - 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() - { - - return Sort.Create(Context(), Native.getRange(Context().nCtx(), NativeObject())); - } - - /** - * The kind of the function declaration. - **/ - public Z3_decl_kind DeclKind() { return Z3_decl_kind.fromInt(Native.getDeclKind(Context().nCtx(), NativeObject())); } - - /** - * The name of the function declaration - **/ - public Symbol Name() - { - - return Symbol.Create(Context(), Native.getDeclName(Context().nCtx(), NativeObject())); - } - - /** - * The number of parameters of the function declaration - **/ - public int NumParameters() { return Native.getDeclNumParameters(Context().nCtx(), NativeObject()); } - - /** - * The parameters of the function declaration - **/ - public Parameter[] Parameters() - { - - - 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. - **/ - public int Int () { if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_INT) throw new Z3Exception("parameter is not an int"); return i; } - /**The double value of the parameter. - **/ - public double Double () { if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_DOUBLE) throw new Z3Exception("parameter is not a double "); return d; } - /**The Symbol value of the parameter. - **/ - public Symbol Symbol () { if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SYMBOL) throw new Z3Exception("parameter is not a Symbol"); return sym; } - /**The Sort value of the parameter. - **/ - public Sort Sort () { if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SORT) throw new Z3Exception("parameter is not a Sort"); return srt; } - /**The AST value of the parameter. - **/ - public AST AST () { if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_AST) throw new Z3Exception("parameter is not an AST"); return ast; } - /**The FunctionDeclaration value of the parameter. - **/ - public FuncDecl FuncDecl () { 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. - **/ - public String Rational () { 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() { 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) - { super(ctx, obj); - - } - - FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range) - { 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) - { super(ctx, Native.mkFreshFuncDecl(ctx.nCtx(), prefix, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject())); - - - } - - void CheckNativeObject(long obj) - { - 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. - * - * @return - **/ - /* operator this[] not translated */ - - /** - * Create expression that applies function to arguments. - * - * @return - **/ - public Expr Apply(Expr[] args) - { - - - Context().CheckContextMatch(args); - return Expr.Create(Context(), this, args); - } - - } diff --git a/src/api/java/com/Microsoft/Z3/FuncInterp.java b/src/api/java/com/Microsoft/Z3/FuncInterp.java deleted file mode 100644 index 17ff7d6bd..000000000 --- a/src/api/java/com/Microsoft/Z3/FuncInterp.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * This file was automatically generated from FuncInterp.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public Expr Value() - { - - 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. - **/ - public Expr[] Args() - { - - - - 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() - { - int n = NumArgs(); - String res = "["; - Expr[] args = Args(); - for (int i = 0; i < n; i++) - res += args[i] + ", "; - return res + Value() + "]"; - } - - Entry(Context ctx, long obj) { super(ctx, obj); { }} - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().FuncEntry_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - 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 - **/ - public Entry[] Entries() - { - - - - 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. - **/ - public Expr Else() - { - - - 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() - { - 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; - } - - FuncInterp(Context ctx, long obj) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().FuncInterp_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().FuncInterp_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Goal.java b/src/api/java/com/Microsoft/Z3/Goal.java deleted file mode 100644 index 9ca138140..000000000 --- a/src/api/java/com/Microsoft/Z3/Goal.java +++ /dev/null @@ -1,187 +0,0 @@ -/** - * This file was automatically generated from Goal.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - * - * 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. - * - **/ - 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 to the given goal. - **/ - public void Assert(BoolExpr[] constraints) - { - - - - 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. - * - * This tracks how many transformations were applied to it. - * - **/ - 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. - **/ - public BoolExpr[] Formulas() - { - - - 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 . - **/ - public Goal Translate(Context ctx) - { - - - return new Goal(ctx, Native.goalTranslate(Context().nCtx(), NativeObject(), ctx.nCtx())); - } - - /** - * Simplifies the goal. - * Essentially invokes the `simplify' tactic on the goal. - **/ - 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) { super(ctx, obj); { }} - - Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) - { - super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false, (unsatCores) ? true : false, (proofs) ? true : false)); - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Goal_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Goal_DRQ().Add(o); - super.DecRef(o); - } - - } diff --git a/src/api/java/com/Microsoft/Z3/IDecRefQueue.java b/src/api/java/com/Microsoft/Z3/IDecRefQueue.java deleted file mode 100644 index 4d40bf66a..000000000 --- a/src/api/java/com/Microsoft/Z3/IDecRefQueue.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This file was automatically generated from IDecRefQueue.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Collections; */ -/* using System.Collections.Generic; */ -/* using System.Threading; */ - - abstract class IDecRefQueue - { - - private void ObjectInvariant() - { - - } - - - protected Object m_lock = new Object(); - protected LinkedList m_queue = new LinkedList(); - 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(); - } - } - } - - abstract class DecRefQueueContracts extends IDecRefQueue - { - public void IncRef(Context ctx, long obj) - { - - } - - public void DecRef(Context ctx, long obj) - { - - } - } diff --git a/src/api/java/com/Microsoft/Z3/IntExpr.java b/src/api/java/com/Microsoft/Z3/IntExpr.java deleted file mode 100644 index d493947d9..000000000 --- a/src/api/java/com/Microsoft/Z3/IntExpr.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was automatically generated from IntExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Int expressions - **/ - public class IntExpr extends ArithExpr - { - /** Constructor for IntExpr - **/ - protected IntExpr(Context ctx) - { super(ctx); - - } - IntExpr(Context ctx, long obj) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/IntNum.java b/src/api/java/com/Microsoft/Z3/IntNum.java deleted file mode 100644 index 494ac316b..000000000 --- a/src/api/java/com/Microsoft/Z3/IntNum.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This file was automatically generated from IntNum.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ - -/* using System.Numerics; */ - - /** - * Integer Numerals - **/ - public class IntNum extends IntExpr - { - - IntNum(Context ctx, long obj) - { super(ctx, obj); - - } - - - /** - * Retrieve the 64-bit unsigned integer value. - **/ - public long UInt64() - { - long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not a 64 bit unsigned"); - return res; - } - - /** - * Retrieve the int value. - **/ - public int Int() - { - int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not an int"); - return res; - } - - /** - * Retrieve the 64-bit int value. - **/ - public long Int64() - { - long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not an int64"); - return res; - } - - /** - * Retrieve the int value. - **/ - public int UInt() - { - int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) - throw new Z3Exception("Numeral is not a int"); - return res; - } - - /** - * 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()); - } - } diff --git a/src/api/java/com/Microsoft/Z3/IntSort.java b/src/api/java/com/Microsoft/Z3/IntSort.java deleted file mode 100644 index b347cc149..000000000 --- a/src/api/java/com/Microsoft/Z3/IntSort.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was automatically generated from IntSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * An Integer sort - **/ - public class IntSort extends ArithSort - { - IntSort(Context ctx, long obj) - { super(ctx, obj); - - } - IntSort(Context ctx) - { super(ctx, Native.mkIntSort(ctx.nCtx())); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/IntSymbol.java b/src/api/java/com/Microsoft/Z3/IntSymbol.java deleted file mode 100644 index 7b917c11d..000000000 --- a/src/api/java/com/Microsoft/Z3/IntSymbol.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This file was automatically generated from IntSymbol.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Runtime.InteropServices; */ - - /** - * Numbered symbols - **/ - public class IntSymbol extends Symbol - { - /** - * The int value of the symbol. - * Throws an exception if the symbol is not of int kind. - **/ - public int Int() - { - if (!IsIntSymbol()) - throw new Z3Exception("Int requested from non-Int symbol"); - return Native.getSymbolInt(Context().nCtx(), NativeObject()); - } - - IntSymbol(Context ctx, long obj) - { super(ctx, obj); - - } - IntSymbol(Context ctx, int i) - { super(ctx, Native.mkIntSymbol(ctx.nCtx(), i)); - - } - - void CheckNativeObject(long obj) - { - 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); - } - } diff --git a/src/api/java/com/Microsoft/Z3/ListSort.java b/src/api/java/com/Microsoft/Z3/ListSort.java deleted file mode 100644 index 7e7b03f79..000000000 --- a/src/api/java/com/Microsoft/Z3/ListSort.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was automatically generated from ListSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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 void ObjectInvariant() - { - - - - - - - - } - - - - private FuncDecl nilDecl, isNilDecl, consDecl, isConsDecl, headDecl, tailDecl; - private Expr nilConst; - - ListSort(Context ctx, Symbol name, Sort elemSort) - { super(ctx); - - - - - long inil = 0, - iisnil = 0, - icons = 0, - iiscons = 0, - ihead = 0, - itail = 0; - - setNativeObject(Native.mkListSort(ctx.nCtx(), name.NativeObject(), elemSort.NativeObject(), - inil, iisnil, icons, iiscons, ihead, itail)); - nilDecl = new FuncDecl(ctx, inil); - isNilDecl = new FuncDecl(ctx, iisnil); - consDecl = new FuncDecl(ctx, icons); - isConsDecl = new FuncDecl(ctx, iiscons); - headDecl = new FuncDecl(ctx, ihead); - tailDecl = new FuncDecl(ctx, itail); - nilConst = ctx.MkConst(nilDecl); - } - }; diff --git a/src/api/java/com/Microsoft/Z3/Log.java b/src/api/java/com/Microsoft/Z3/Log.java deleted file mode 100644 index 2572f9880..000000000 --- a/src/api/java/com/Microsoft/Z3/Log.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was automatically generated from Log.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Interaction logging for Z3. - * - * Note that this is a global, static log and if multiple Context - * objects are created, it logs the interaction with all of them. - * - **/ - public final class Log - { - private boolean m_is_open = false; - - /** - * Open an interaction log file. - * the name of the file to open - * @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 to the interaction log. - **/ - public void Append(String s) - { - - - 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; - } - } diff --git a/src/api/java/com/Microsoft/Z3/Model.java b/src/api/java/com/Microsoft/Z3/Model.java deleted file mode 100644 index f17dc1956..000000000 --- a/src/api/java/com/Microsoft/Z3/Model.java +++ /dev/null @@ -1,284 +0,0 @@ -/** - * This file was automatically generated from Model.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * A Model contains interpretations (assignments) of constants and functions. - **/ - public class Model extends Z3Object - { - /** - * Retrieves the interpretation (the assignment) of in the model. - * A Constant - * @return An expression if the constant has an interpretation in the model, null otherwise. - **/ - public Expr ConstInterp(Expr a) - { - - - Context().CheckContextMatch(a); - return ConstInterp(a.FuncDecl()); - } - - /** - * Retrieves the interpretation (the assignment) of in the model. - * A function declaration of zero arity - * @return An expression if the function has an interpretation in the model, null otherwise. - **/ - public Expr ConstInterp(FuncDecl f) - { - - - 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 in the model. - * A function declaration of non-zero arity - * @return A FunctionInterpretation if the function has an interpretation in the model, null otherwise. - **/ - public FuncInterp FuncInterp(FuncDecl f) - { - - - 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. - **/ - public FuncDecl[] ConstDecls() - { - - - 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. - **/ - public FuncDecl[] FuncDecls() - { - - - 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. - **/ - public FuncDecl[] Decls() - { - - - 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. - **/ - public class ModelEvaluationFailedException extends Z3Exception - { - /** - * An exception that is thrown when model evaluation fails. - **/ - public ModelEvaluationFailedException() { super(); { }} - } - - /** - * Evaluates the expression in the current model. - * - * This function may fail if contains quantifiers, - * is partial (MODEL_PARTIAL enabled), or if is not well-sorted. - * In this case a ModelEvaluationFailedException is thrown. - * - * An expression - * - * 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. - * - * @return The evaluation of in the model. - **/ - public Expr Eval(Expr t, boolean completion) - { - - - - long v = 0; - if (Native.modelEval(Context().nCtx(), NativeObject(), t.NativeObject(), (completion) ? true : false, v) ^ true) - throw new ModelEvaluationFailedException(); - else - return Expr.Create(Context(), v); - } - - /** - * Alias for Eval. - **/ - public Expr Evaluate(Expr t, boolean completion) - { - - - - 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. - * - * 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. - * - * - * - **/ - public Sort[] Sorts() - { - - - 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 . - * - * An uninterpreted sort - * @return An array of expressions, where each is an element of the universe of - **/ - public Expr[] SortUniverse(Sort s) - { - - - - 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) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Model_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Model_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Native.class b/src/api/java/com/Microsoft/Z3/Native.class deleted file mode 100644 index 04e71cfb4..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Native.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/ParamDescrs.java b/src/api/java/com/Microsoft/Z3/ParamDescrs.java deleted file mode 100644 index edba1ceab..000000000 --- a/src/api/java/com/Microsoft/Z3/ParamDescrs.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This file was automatically generated from ParamDescrs.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public Symbol[] Names() - { - 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) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().ParamDescrs_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().ParamDescrs_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Params.java b/src/api/java/com/Microsoft/Z3/Params.java deleted file mode 100644 index ab6401833..000000000 --- a/src/api/java/com/Microsoft/Z3/Params.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was automatically generated from Params.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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) - { - - - Native.paramsSetBool(Context().nCtx(), NativeObject(), name.NativeObject(), (value) ? true : false); - } - - /** - * Adds a parameter setting. - **/ - public void Add(Symbol name, double value) - { - - - Native.paramsSetDouble(Context().nCtx(), NativeObject(), name.NativeObject(), value); - } - - /** - * Adds a parameter setting. - **/ - public void Add(Symbol name, Symbol value) - { - - - - Native.paramsSetSymbol(Context().nCtx(), NativeObject(), name.NativeObject(), value.NativeObject()); - } - - /** - * Adds a parameter setting. - **/ - public void Add(String name, boolean value) - { - Native.paramsSetBool(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), (value) ? true : false); - } - - /** - * Adds a parameter setting. - **/ - public void Add(String name, int value) - { - Native.paramsSetUint(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); - } - - /** - * Adds a parameter setting. - **/ - public void Add(String name, double value) - { - Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); - } - - /** - * Adds a parameter setting. - **/ - public void Add(String name, Symbol value) - { - - - 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) - { super(ctx, Native.mkParams(ctx.nCtx())); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Params_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Params_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Pattern.java b/src/api/java/com/Microsoft/Z3/Pattern.java deleted file mode 100644 index 99fb53b9c..000000000 --- a/src/api/java/com/Microsoft/Z3/Pattern.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * This file was automatically generated from Pattern.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Runtime.InteropServices; */ - - /** - * 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. - **/ - public Expr[] Terms() - { - - - 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) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/Probe.java b/src/api/java/com/Microsoft/Z3/Probe.java deleted file mode 100644 index 8d1ba1a97..000000000 --- a/src/api/java/com/Microsoft/Z3/Probe.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * This file was automatically generated from Probe.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Runtime.InteropServices; */ - - /** - * 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 Context.NumProbes - * and Context.ProbeNames. - * It may also be obtained using the command (help-tactics) 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. - **/ - public double Apply(Goal g) - { - - - Context().CheckContextMatch(g); - return Native.probeApply(Context().nCtx(), NativeObject(), g.NativeObject()); - } - - /** - * Apply the probe to a goal. - **/ - public double get(Goal g) - { - - - return Apply(g); - } - - Probe(Context ctx, long obj) - { super(ctx, obj); - - } - Probe(Context ctx, String name) - { super(ctx, Native.mkProbe(ctx.nCtx(), name)); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Probe_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Probe_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Quantifier.java b/src/api/java/com/Microsoft/Z3/Quantifier.java deleted file mode 100644 index b841623c2..000000000 --- a/src/api/java/com/Microsoft/Z3/Quantifier.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * This file was automatically generated from Quantifier.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public Pattern[] Patterns() - { - - - 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. - **/ - public Pattern[] NoPatterns() - { - - - 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. - **/ - public Symbol[] BoundVariableNames() - { - - - 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. - **/ - public Sort[] BoundVariableSorts() - { - - - 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. - **/ - public BoolExpr Body() - { - - - 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) - { 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"); - - long[] _patterns = AST.ArrayToNative(patterns); - - 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) - { 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) { super(ctx, obj); { }} - - void CheckNativeObject(long obj) - { - 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); - } - } diff --git a/src/api/java/com/Microsoft/Z3/RatNum.java b/src/api/java/com/Microsoft/Z3/RatNum.java deleted file mode 100644 index ff0b3d18a..000000000 --- a/src/api/java/com/Microsoft/Z3/RatNum.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file was automatically generated from RatNum.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ - -/* using System.Numerics; */ - - /** - * Rational Numerals - **/ - public class RatNum extends RealExpr - { - /** - * The numerator of a rational numeral. - **/ - public IntNum Numerator() - { - - - return new IntNum(Context(), Native.getNumerator(Context().nCtx(), NativeObject())); - } - - /** - * The denominator of a rational numeral. - **/ - public IntNum Denominator() - { - - - return new IntNum(Context(), Native.getDenominator(Context().nCtx(), NativeObject())); - } - - /** - * Converts the numerator of the rational to a BigInteger - **/ - public BigInteger BigIntNumerator() - { - IntNum n = Numerator(); - return new BigInteger(n.toString()); - } - - /** - * Converts the denominator of the rational to a BigInteger - **/ - public BigInteger BigIntDenominator() - { - IntNum n = Denominator(); - return new BigInteger(n.toString()); - } - - /** - * Returns a string representation in decimal notation. - * The result has at most decimal places. - **/ - public String ToDecimalString(int precision) - { - 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); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/RealExpr.java b/src/api/java/com/Microsoft/Z3/RealExpr.java deleted file mode 100644 index 907148c2a..000000000 --- a/src/api/java/com/Microsoft/Z3/RealExpr.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was automatically generated from RealExpr.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; -/* using System; */ -/* using System.Collections.Generic; */ -/* using System.Linq; */ -/* using System.Text; */ - - - /** - * Real expressions - **/ - public class RealExpr extends ArithExpr - { - /** - * Constructor for RealExpr - **/ - protected RealExpr(Context ctx) - { super(ctx); - - } - - RealExpr(Context ctx, long obj) throws Z3Exception - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/RealSort.java b/src/api/java/com/Microsoft/Z3/RealSort.java deleted file mode 100644 index d85aeccd1..000000000 --- a/src/api/java/com/Microsoft/Z3/RealSort.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was automatically generated from RealSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * A real sort - **/ - public class RealSort extends ArithSort - { - RealSort(Context ctx, long obj) - { super(ctx, obj); - - } - RealSort(Context ctx) - { super(ctx, Native.mkRealSort(ctx.nCtx())); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/RelationSort.java b/src/api/java/com/Microsoft/Z3/RelationSort.java deleted file mode 100644 index 564c66eaf..000000000 --- a/src/api/java/com/Microsoft/Z3/RelationSort.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file was automatically generated from RelationSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public Sort[] ColumnSorts() - { - - - 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) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/SetSort.java b/src/api/java/com/Microsoft/Z3/SetSort.java deleted file mode 100644 index 2ed16c09b..000000000 --- a/src/api/java/com/Microsoft/Z3/SetSort.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was automatically generated from SetSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Set sorts. - **/ - public class SetSort extends Sort - { - SetSort(Context ctx, long obj) - { super(ctx, obj); - - } - SetSort(Context ctx, Sort ty) - { super(ctx, Native.mkSetSort(ctx.nCtx(), ty.NativeObject())); - - - } - } diff --git a/src/api/java/com/Microsoft/Z3/Solver.java b/src/api/java/com/Microsoft/Z3/Solver.java deleted file mode 100644 index 1f6f099b3..000000000 --- a/src/api/java/com/Microsoft/Z3/Solver.java +++ /dev/null @@ -1,252 +0,0 @@ -/** - * This file was automatically generated from Solver.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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. - **/ - public void setParameters(Params value) - { - - - Context().CheckContextMatch(value); - Native.solverSetParams(Context().nCtx(), NativeObject(), value.NativeObject()); - } - - /** - * Retrieves parameter descriptions for solver. - **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.solverGetParamDescrs(Context().nCtx(), NativeObject())); } - - - /** - * The current number of backtracking points (scopes). - * - * - **/ - public int NumScopes() { return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); } - - /** - * Creates a backtracking point. - * - **/ - public void Push() - { - Native.solverPush(Context().nCtx(), NativeObject()); - } - - /** - * Backtracks backtracking points. - * Note that an exception is thrown if is not smaller than NumScopes - * - **/ - public void Pop(int n) - { - Native.solverPop(Context().nCtx(), NativeObject(), n); - } - - /** - * Resets the Solver. - * This removes all assertions from the solver. - **/ - public void Reset() - { - Native.solverReset(Context().nCtx(), NativeObject()); - } - - /** - * Assert a constraint (or multiple) into the solver. - **/ - public void Assert(BoolExpr[] constraints) - { - - - - Context().CheckContextMatch(constraints); - for (BoolExpr a: constraints) - { - Native.solverAssert(Context().nCtx(), NativeObject(), a.NativeObject()); - } - } - - /** - * The number of assertions in the solver. - **/ - public int NumAssertions() - { - ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(Context().nCtx(), NativeObject())); - return ass.Size(); - } - - /** - * The set of asserted formulas. - **/ - public BoolExpr[] Assertions() - { - - - 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. - * - * - * - * - * - **/ - 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 Check. - * - * The result is null if Check was not invoked before, - * if its results was not SATISFIABLE, or if model production is not enabled. - * - **/ - public Model Model() - { - long x = Native.solverGetModel(Context().nCtx(), NativeObject()); - if (x == 0) - return null; - else - return new Model(Context(), x); - } - - /** - * The proof of the last Check. - * - * The result is null if Check was not invoked before, - * if its results was not UNSATISFIABLE, or if proof production is disabled. - * - **/ - public Expr Proof() - { - long x = Native.solverGetProof(Context().nCtx(), NativeObject()); - if (x == 0) - return null; - else - return Expr.Create(Context(), x); - } - - /** - * The unsat core of the last Check. - * - * The unsat core is a subset of Assertions - * The result is empty if Check was not invoked before, - * if its results was not UNSATISFIABLE, or if core production is disabled. - * - **/ - public Expr[] UnsatCore() - { - - - 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 Check returned UNKNOWN. - **/ - public String ReasonUnknown() - { - - - return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject()); - } - - /** - * Solver statistics. - **/ - public Statistics Statistics() - { - - - 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) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Solver_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Solver_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Sort.java b/src/api/java/com/Microsoft/Z3/Sort.java deleted file mode 100644 index f1933fccd..000000000 --- a/src/api/java/com/Microsoft/Z3/Sort.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was automatically generated from Sort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * The Sort class implements type information for ASTs. - **/ - public class Sort extends AST - { - /** - * Comparison operator. - * A Sort - * A Sort - * @return True if and are from the same context - * and represent the same sort; false otherwise. - **/ - /* Overloaded operators are not translated. */ - - /** - * Comparison operator. - * A Sort - * A Sort - * @return True if and are not from the same context - * or represent different sorts; false otherwise. - **/ - /* Overloaded operators are not translated. */ - - /** - * Equality operator for objects of type Sort. - * - * @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() - { - return super.GetHashCode(); - } - - /** - * Returns a unique identifier for the sort. - **/ - public int Id() { return Native.getSortId(Context().nCtx(), NativeObject()); } - - /** - * The kind of the sort. - **/ - public Z3_sort_kind SortKind() { return Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(), NativeObject())); } - - /** - * The name of the sort - **/ - public Symbol Name() - { - - 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) { super(ctx); { }} - Sort(Context ctx, long obj) { super(ctx, obj); { }} - - void CheckNativeObject(long obj) - { - 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) - { - - - - 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"); - } - } - } diff --git a/src/api/java/com/Microsoft/Z3/Statistics.java b/src/api/java/com/Microsoft/Z3/Statistics.java deleted file mode 100644 index 93cd6e706..000000000 --- a/src/api/java/com/Microsoft/Z3/Statistics.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * This file was automatically generated from Statistics.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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 DoubleEntry or a UIntEntry - **/ - 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. - **/ - public String Value() - { - - - 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() - { - return Key + ": " + Value(); - } - - 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. - **/ - public Entry[] Entries() - { - - - - - 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. - * Returns null if the key is unknown. - **/ - public Entry get(String key) - { - 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) - { super(ctx, obj); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Statistics_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Statistics_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Status.java b/src/api/java/com/Microsoft/Z3/Status.java deleted file mode 100644 index fdccb7376..000000000 --- a/src/api/java/com/Microsoft/Z3/Status.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This file was automatically generated from Status.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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; } - } - diff --git a/src/api/java/com/Microsoft/Z3/StringSymbol.java b/src/api/java/com/Microsoft/Z3/StringSymbol.java deleted file mode 100644 index 5788c0944..000000000 --- a/src/api/java/com/Microsoft/Z3/StringSymbol.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This file was automatically generated from StringSymbol.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Runtime.InteropServices; */ - - - /** - * Named symbols - **/ - public class StringSymbol extends Symbol - { - /** - * The string value of the symbol. - * Throws an exception if the symbol is not of string kind. - **/ - public String String() - { - - - if (!IsStringSymbol()) - throw new Z3Exception("String requested from non-String symbol"); - return Native.getSymbolString(Context().nCtx(), NativeObject()); - } - - StringSymbol(Context ctx, long obj) - { super(ctx, obj); - - } - - StringSymbol(Context ctx, String s) - { super(ctx, Native.mkStringSymbol(ctx.nCtx(), s)); - - } - - void CheckNativeObject(long obj) - { - 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); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Symbol.java b/src/api/java/com/Microsoft/Z3/Symbol.java deleted file mode 100644 index 0cd0632de..000000000 --- a/src/api/java/com/Microsoft/Z3/Symbol.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file was automatically generated from Symbol.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ -/* using System.Runtime.InteropServices; */ - - /** - * 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() - { - if (IsIntSymbol()) - return Integer.toString(((IntSymbol)this).Int()); - else if (IsStringSymbol()) - return ((StringSymbol)this).String(); - else - throw new Z3Exception("Unknown symbol kind encountered"); - } - - /** - * Symbol constructor - **/ - protected Symbol(Context ctx, long obj) { - super(ctx, obj); - } - - static Symbol Create(Context ctx, long obj) - { - - - - 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"); - } - } - } diff --git a/src/api/java/com/Microsoft/Z3/Tactic.java b/src/api/java/com/Microsoft/Z3/Tactic.java deleted file mode 100644 index 3ef1ab645..000000000 --- a/src/api/java/com/Microsoft/Z3/Tactic.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file was automatically generated from Tactic.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Tactics are the basic building block for creating custom solvers for specific problem domains. - * The complete list of tactics may be obtained using Context.NumTactics - * and Context.TacticNames. - * It may also be obtained using the command (help-tactics) 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. - **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.tacticGetParamDescrs(Context().nCtx(), NativeObject())); } - - - /** - * Execute the tactic over the goal. - **/ - public ApplyResult Apply(Goal g, Params p) - { - - - - 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. - **/ - public ApplyResult get(Goal g) - { - - - - return Apply(g, null); - } - - /** - * Creates a solver that is implemented using the given tactic. - * - **/ - public Solver Solver() - { - - - return Context().MkSolver(this); - } - - Tactic(Context ctx, long obj) - { super(ctx, obj); - - } - Tactic(Context ctx, String name) - { super(ctx, Native.mkTactic(ctx.nCtx(), name)); - - } - - class DecRefQueue 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); - } - }; - - void IncRef(long o) - { - Context().Tactic_DRQ().IncAndClear(Context(), o); - super.IncRef(o); - } - - void DecRef(long o) - { - Context().Tactic_DRQ().Add(o); - super.DecRef(o); - } - } diff --git a/src/api/java/com/Microsoft/Z3/TupleSort.java b/src/api/java/com/Microsoft/Z3/TupleSort.java deleted file mode 100644 index 76a92f6c9..000000000 --- a/src/api/java/com/Microsoft/Z3/TupleSort.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file was automatically generated from TupleSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Tuple sorts. - **/ - public class TupleSort extends Sort - { - /** - * The constructor function of the tuple. - **/ - public FuncDecl MkDecl() - { - - - 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. - **/ - public FuncDecl[] FieldDecls() - { - - - 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) - { super(ctx); - - - - long t = 0; - setNativeObject(Native.mkTupleSort(ctx.nCtx(), name.NativeObject(), numFields, - Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts), - t, new long[numFields])); - } - }; diff --git a/src/api/java/com/Microsoft/Z3/UninterpretedSort.java b/src/api/java/com/Microsoft/Z3/UninterpretedSort.java deleted file mode 100644 index 3c732901d..000000000 --- a/src/api/java/com/Microsoft/Z3/UninterpretedSort.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was automatically generated from UninterpretedSort.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Uninterpreted Sorts - **/ - public class UninterpretedSort extends Sort - { - UninterpretedSort(Context ctx, long obj) - { super(ctx, obj); - - } - UninterpretedSort(Context ctx, Symbol s) - { super(ctx, Native.mkUninterpretedSort(ctx.nCtx(), s.NativeObject())); - - - } - } diff --git a/src/api/java/com/Microsoft/Z3/Version.class b/src/api/java/com/Microsoft/Z3/Version.class deleted file mode 100644 index 472674ff6..000000000 Binary files a/src/api/java/com/Microsoft/Z3/Version.class and /dev/null differ diff --git a/src/api/java/com/Microsoft/Z3/Version.java b/src/api/java/com/Microsoft/Z3/Version.java deleted file mode 100644 index e9f883aaa..000000000 --- a/src/api/java/com/Microsoft/Z3/Version.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file was automatically generated from Version.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * Version information. - * Note that this class is static. - **/ - public final class Version - { - Version() { } - - /** - * The major version - **/ - public int Major() - { - int major = 0, minor = 0, build = 0, revision = 0; - Native.getVersion(major, minor, build, revision); - return major; - } - - /** - * The minor version - **/ - public int Minor() - { - int major = 0, minor = 0, build = 0, revision = 0; - Native.getVersion(major, minor, build, revision); - return minor; - } - - /** - * The build version - **/ - public int Build() - { - int major = 0, minor = 0, build = 0, revision = 0; - Native.getVersion(major, minor, build, revision); - return build; - } - - /** - * The revision - **/ - public int Revision() - { - int major = 0, minor = 0, build = 0, revision = 0; - Native.getVersion(major, minor, build, revision); - return revision; - } - - /** - * A string representation of the version information. - **/ - public String toString() - { - - - int major = 0, minor = 0, build = 0, revision = 0; - Native.getVersion(major, minor, build, revision); - return Integer.toString(major) + "." + Integer.toString(minor) + "." + Integer.toString(build) + "." + Integer.toString(revision); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Z3Exception.java b/src/api/java/com/Microsoft/Z3/Z3Exception.java deleted file mode 100644 index 7036558c7..000000000 --- a/src/api/java/com/Microsoft/Z3/Z3Exception.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file was automatically generated from Z3Exception.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * The exception base class for error reporting from Z3 - **/ - 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); { }} - } diff --git a/src/api/java/com/Microsoft/Z3/Z3Object.java b/src/api/java/com/Microsoft/Z3/Z3Object.java deleted file mode 100644 index 1bbdbab8b..000000000 --- a/src/api/java/com/Microsoft/Z3/Z3Object.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * This file was automatically generated from Z3Object.cs - **/ - -package com.Microsoft.Z3; - -import java.math.BigInteger; -import java.util.*; -import java.lang.Exception; -import com.Microsoft.Z3.Enumerations.*; - -/* using System; */ - - /** - * 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.refCount--; - if (m_ctx.refCount == 0) - - m_ctx = null; - } - - - } - - - private void ObjectInvariant() - { - - } - - - private Context m_ctx = null; - private long m_n_obj = 0; - - Z3Object(Context ctx) - { - - - ctx.refCount++; - m_ctx = ctx; - } - - Z3Object(Context ctx, long obj) throws Z3Exception - { - - - ctx.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; - } - }