From eb812f0fad3de3baa4e1be34f6b5c6d96afb4500 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 23 Nov 2012 19:24:56 +0000 Subject: [PATCH 01/17] Java API: Updates, this is still work in progress. Signed-off-by: Christoph M. Wintersteiger --- src/api/java/com/Microsoft/Z3/AST.java | 56 +- src/api/java/com/Microsoft/Z3/ASTMap.java | 40 +- src/api/java/com/Microsoft/Z3/ASTVector.java | 36 +- .../java/com/Microsoft/Z3/AlgebraicNum.java | 62 +++ .../java/com/Microsoft/Z3/ApplyResult.java | 37 +- src/api/java/com/Microsoft/Z3/ArithExpr.java | 31 ++ src/api/java/com/Microsoft/Z3/ArithSort.java | 19 + src/api/java/com/Microsoft/Z3/ArrayExpr.java | 31 ++ src/api/java/com/Microsoft/Z3/ArraySort.java | 46 ++ src/api/java/com/Microsoft/Z3/BitVecExpr.java | 31 ++ src/api/java/com/Microsoft/Z3/BitVecNum.java | 80 +++ src/api/java/com/Microsoft/Z3/BitVecSort.java | 25 + src/api/java/com/Microsoft/Z3/BoolExpr.java | 27 + src/api/java/com/Microsoft/Z3/BoolSort.java | 20 + .../java/com/Microsoft/Z3/Constructor.java | 47 +- .../com/Microsoft/Z3/ConstructorList.java | 42 ++ src/api/java/com/Microsoft/Z3/Context.java | 90 ++-- .../java/com/Microsoft/Z3/DatatypeExpr.java | 31 ++ .../java/com/Microsoft/Z3/DatatypeSort.java | 80 +++ src/api/java/com/Microsoft/Z3/EnumSort.java | 82 +++ src/api/java/com/Microsoft/Z3/Expr.java | 205 ++----- .../com/Microsoft/Z3/FiniteDomainSort.java | 38 ++ src/api/java/com/Microsoft/Z3/Fixedpoint.java | 86 +-- src/api/java/com/Microsoft/Z3/FuncDecl.java | 74 ++- src/api/java/com/Microsoft/Z3/FuncInterp.java | 79 +-- src/api/java/com/Microsoft/Z3/Goal.java | 50 +- .../{DecRefQUeue.java => IDecRefQueue.java} | 28 +- src/api/java/com/Microsoft/Z3/IntExpr.java | 31 ++ src/api/java/com/Microsoft/Z3/IntNum.java | 85 +++ src/api/java/com/Microsoft/Z3/IntSort.java | 26 + src/api/java/com/Microsoft/Z3/IntSymbol.java | 45 ++ src/api/java/com/Microsoft/Z3/ListSort.java | 122 +++++ src/api/java/com/Microsoft/Z3/Log.java | 4 + src/api/java/com/Microsoft/Z3/Model.java | 80 +-- src/api/java/com/Microsoft/Z3/Native.java | 3 +- src/api/java/com/Microsoft/Z3/Numeral.java | 264 --------- .../java/com/Microsoft/Z3/ParamDescrs.java | 36 +- src/api/java/com/Microsoft/Z3/Params.java | 38 +- src/api/java/com/Microsoft/Z3/Pattern.java | 16 +- src/api/java/com/Microsoft/Z3/Probe.java | 37 +- src/api/java/com/Microsoft/Z3/Quantifier.java | 76 +-- src/api/java/com/Microsoft/Z3/RatNum.java | 78 +++ src/api/java/com/Microsoft/Z3/RealExpr.java | 31 ++ src/api/java/com/Microsoft/Z3/RealSort.java | 26 + .../java/com/Microsoft/Z3/RelationSort.java | 46 ++ src/api/java/com/Microsoft/Z3/SetSort.java | 27 + src/api/java/com/Microsoft/Z3/Solver.java | 74 +-- src/api/java/com/Microsoft/Z3/Sort.java | 508 +----------------- src/api/java/com/Microsoft/Z3/Statistics.java | 62 ++- src/api/java/com/Microsoft/Z3/Status.java | 31 +- .../java/com/Microsoft/Z3/StringSymbol.java | 50 ++ src/api/java/com/Microsoft/Z3/Symbol.java | 85 +-- src/api/java/com/Microsoft/Z3/Tactic.java | 32 +- src/api/java/com/Microsoft/Z3/TupleSort.java | 57 ++ .../com/Microsoft/Z3/UninterpretedSort.java | 27 + src/api/java/com/Microsoft/Z3/Version.java | 6 +- .../java/com/Microsoft/Z3/Z3Exception.java | 10 +- src/api/java/com/Microsoft/Z3/Z3Object.java | 56 +- src/api/java/mk_java.py | 133 ++++- 59 files changed, 2105 insertions(+), 1570 deletions(-) create mode 100644 src/api/java/com/Microsoft/Z3/AlgebraicNum.java create mode 100644 src/api/java/com/Microsoft/Z3/ArithExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/ArithSort.java create mode 100644 src/api/java/com/Microsoft/Z3/ArrayExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/ArraySort.java create mode 100644 src/api/java/com/Microsoft/Z3/BitVecExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/BitVecNum.java create mode 100644 src/api/java/com/Microsoft/Z3/BitVecSort.java create mode 100644 src/api/java/com/Microsoft/Z3/BoolExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/BoolSort.java create mode 100644 src/api/java/com/Microsoft/Z3/ConstructorList.java create mode 100644 src/api/java/com/Microsoft/Z3/DatatypeExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/DatatypeSort.java create mode 100644 src/api/java/com/Microsoft/Z3/EnumSort.java create mode 100644 src/api/java/com/Microsoft/Z3/FiniteDomainSort.java rename src/api/java/com/Microsoft/Z3/{DecRefQUeue.java => IDecRefQueue.java} (55%) create mode 100644 src/api/java/com/Microsoft/Z3/IntExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/IntNum.java create mode 100644 src/api/java/com/Microsoft/Z3/IntSort.java create mode 100644 src/api/java/com/Microsoft/Z3/IntSymbol.java create mode 100644 src/api/java/com/Microsoft/Z3/ListSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Numeral.java create mode 100644 src/api/java/com/Microsoft/Z3/RatNum.java create mode 100644 src/api/java/com/Microsoft/Z3/RealExpr.java create mode 100644 src/api/java/com/Microsoft/Z3/RealSort.java create mode 100644 src/api/java/com/Microsoft/Z3/RelationSort.java create mode 100644 src/api/java/com/Microsoft/Z3/SetSort.java create mode 100644 src/api/java/com/Microsoft/Z3/StringSymbol.java create mode 100644 src/api/java/com/Microsoft/Z3/TupleSort.java create mode 100644 src/api/java/com/Microsoft/Z3/UninterpretedSort.java diff --git a/src/api/java/com/Microsoft/Z3/AST.java b/src/api/java/com/Microsoft/Z3/AST.java index ad4c9d94a..c8471e2e8 100644 --- a/src/api/java/com/Microsoft/Z3/AST.java +++ b/src/api/java/com/Microsoft/Z3/AST.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Collections; */ /* using System.Collections.Generic; */ @@ -34,7 +38,7 @@ package com.Microsoft.Z3; /** * Object comparison. **/ - public boolean Equals(object o) + public boolean Equals(Object o) { AST casted = (AST) o; if (casted == null) return false; @@ -46,7 +50,7 @@ package com.Microsoft.Z3; * Another AST * @return Negative if the object should be sorted before , positive if after else zero. **/ - public int CompareTo(object other) + public int CompareTo(Object other) { if (other == null) return 1; AST oAST = (AST) other; @@ -69,13 +73,13 @@ package com.Microsoft.Z3; **/ public int GetHashCode() { - return (int)Native.getAstHash(Context.nCtx, NativeObject); + return (int)Native.getAstHash(Context().nCtx(), NativeObject()); } /** * A unique identifier for the AST (unique among all ASTs). **/ - public long Id() { return Native.getAstId(Context.nCtx, NativeObject); } + public long Id() { return Native.getAstId(Context().nCtx(), NativeObject()); } /** * Translates (copies) the AST to the Context . @@ -90,20 +94,20 @@ package com.Microsoft.Z3; if (ReferenceEquals(Context, ctx)) return this; else - return new AST(ctx, Native.translate(Context.nCtx, NativeObject, ctx.nCtx)); + return new AST(ctx, Native.translate(Context().nCtx(), NativeObject(), ctx.nCtx())); } /** * The kind of the AST. **/ - public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context.nCtx, NativeObject); } + public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context().nCtx(), NativeObject()); } /** * Indicates whether the AST is an Expr **/ public boolean IsExpr() { - switch (ASTKind) + switch (ASTKind()) { case Z3_ast_kind.Z3_APP_AST: case Z3_ast_kind.Z3_NUMERAL_AST: @@ -116,29 +120,29 @@ package com.Microsoft.Z3; /** * Indicates whether the AST is a BoundVariable **/ - public boolean IsVar() { return this.ASTKind == Z3_ast_kind.Z3_VAR_AST; } + 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; } + 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; } + 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; } + 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); + return Native.astToString(Context().nCtx(), NativeObject()); } /** @@ -148,53 +152,53 @@ package com.Microsoft.Z3; { - return Native.asttoString(Context.nCtx, NativeObject); + return Native.astToString(Context().nCtx(), NativeObject()); } - AST(Context ctx) { super(ctx); } - AST(Context ctx, IntPtr obj) { super(ctx, obj); } + AST(Context ctx) { super(ctx); { }} + AST(Context ctx, long obj) { super(ctx, obj); { }} - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.incRef(ctx.nCtx, obj); + Native.incRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.decRef(ctx.nCtx, obj); + Native.decRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { // Console.WriteLine("AST IncRef()"); if (Context == null) throw new Z3Exception("inc() called on null context"); - if (o == IntPtr.Zero) + if (o == 0) throw new Z3Exception("inc() called on null AST"); Context.AST_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr o) + void DecRef(long o) { // Console.WriteLine("AST DecRef()"); if (Context == null) throw new Z3Exception("dec() called on null context"); - if (o == IntPtr.Zero) + if (o == 0) throw new Z3Exception("dec() called on null AST"); Context.AST_DRQ.Add(o); super.DecRef(o); } - static AST Create(Context ctx, IntPtr obj) + static AST Create(Context ctx, long obj) { - switch ((Z3_ast_kind)Native.getAstKind(ctx.nCtx, obj)) + switch ((Z3_ast_kind)Native.getAstKind(ctx.nCtx(), obj)) { case Z3_ast_kind.Z3_FUNC_DECL_AST: return new FuncDecl(ctx, obj); case Z3_ast_kind.Z3_QUANTIFIER_AST: return new Quantifier(ctx, obj); diff --git a/src/api/java/com/Microsoft/Z3/ASTMap.java b/src/api/java/com/Microsoft/Z3/ASTMap.java index 7b95861b4..837779234 100644 --- a/src/api/java/com/Microsoft/Z3/ASTMap.java +++ b/src/api/java/com/Microsoft/Z3/ASTMap.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -20,7 +24,7 @@ package com.Microsoft.Z3; { - return Native.astMapContains(Context.nCtx, NativeObject, k.NativeObject) != 0; + return Native.astMapContains(Context().nCtx(), NativeObject(), k.NativeObject) != 0; } /** @@ -35,7 +39,7 @@ package com.Microsoft.Z3; - return new AST(Context, Native.astMapFind(Context.nCtx, NativeObject, k.NativeObject)); + return new AST(Context, Native.astMapFind(Context().nCtx(), NativeObject(), k.NativeObject)); } /** @@ -48,7 +52,7 @@ package com.Microsoft.Z3; - Native.astMapInsert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject); + Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject, v.NativeObject); } /** @@ -59,7 +63,7 @@ package com.Microsoft.Z3; { - Native.astMapErase(Context.nCtx, NativeObject, k.NativeObject); + Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject); } /** @@ -67,20 +71,20 @@ package com.Microsoft.Z3; **/ public void Reset() { - Native.astMapReset(Context.nCtx, NativeObject); + Native.astMapReset(Context().nCtx(), NativeObject()); } /** * The size of the map **/ - public long Size() { return Native.astMapSize(Context.nCtx, NativeObject); } + public long Size() { return Native.astMapSize(Context().nCtx(), NativeObject()); } /** * The keys stored in the map. **/ public ASTVector Keys() { - return new ASTVector(Context, Native.astMapKeys(Context.nCtx, NativeObject)); + return new ASTVector(Context, Native.astMapKeys(Context().nCtx(), NativeObject())); } /** @@ -88,38 +92,38 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.astMaptoString(Context.nCtx, NativeObject); + return Native.astMapToString(Context().nCtx(), NativeObject()); } - ASTMap(Context ctx, IntPtr obj) - { super(ctx, obj); + ASTMap(Context ctx, long obj) + { super(ctx, obj); } ASTMap(Context ctx) - { super(ctx, Native.mkAstMap(ctx.nCtx)); + { super(ctx, Native.mkAstMap(ctx.nCtx())); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.astMapIncRef(ctx.nCtx, obj); + Native.astMapIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.astMapDecRef(ctx.nCtx, obj); + Native.astMapDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.ASTMap_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 0ae2ff20a..2bb1ab3e0 100644 --- a/src/api/java/com/Microsoft/Z3/ASTVector.java +++ b/src/api/java/com/Microsoft/Z3/ASTVector.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -14,7 +18,7 @@ package com.Microsoft.Z3; /** * The size of the vector **/ - public long Size() { return Native.astVectorSize(Context.nCtx, NativeObject); } + public long Size() { return Native.astVectorSize(Context().nCtx(), NativeObject()); } /** * Retrieves the i-th object in the vector. @@ -26,13 +30,13 @@ package com.Microsoft.Z3; { - return new AST(Context, Native.astVectorGet(Context.nCtx, NativeObject, i)); + return new AST(Context, Native.astVectorGet(Context().nCtx(), NativeObject(), i)); } public void set(long i, AST value) { - Native.astVectorSet(Context.nCtx, NativeObject, i, value.NativeObject); + Native.astVectorSet(Context().nCtx(), NativeObject(), i, value.NativeObject); } /** @@ -41,7 +45,7 @@ package com.Microsoft.Z3; **/ public void Resize(long newSize) { - Native.astVectorResize(Context.nCtx, NativeObject, newSize); + Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); } /** @@ -53,7 +57,7 @@ package com.Microsoft.Z3; { - Native.astVectorPush(Context.nCtx, NativeObject, a.NativeObject); + Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject); } /** @@ -66,7 +70,7 @@ package com.Microsoft.Z3; - return new ASTVector(Context, Native.astVectorTranslate(Context.nCtx, NativeObject, ctx.nCtx)); + return new ASTVector(Context, Native.astVectorTranslate(Context().nCtx(), NativeObject(), ctx.nCtx())); } /** @@ -74,32 +78,32 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.astVectortoString(Context.nCtx, NativeObject); + return Native.astVectorToString(Context().nCtx(), NativeObject()); } - ASTVector(Context ctx, IntPtr obj) { super(ctx, obj); } - ASTVector(Context ctx) { super(ctx, Native.mkAstVector(ctx.nCtx)); } + ASTVector(Context ctx, long obj) { super(ctx, obj); { }} + ASTVector(Context ctx) { super(ctx, Native.mkAstVector(ctx.nCtx())); { }} - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.astVectorIncRef(ctx.nCtx, obj); + Native.astVectorIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.astVectorDecRef(ctx.nCtx, obj); + Native.astVectorDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.ASTVector_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 new file mode 100644 index 000000000..eccd15556 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/AlgebraicNum.java @@ -0,0 +1,62 @@ +/** + * This file was automatically generated from AlgebraicNum.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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(long precision) + { + + + 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(long precision) + { + + + 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(long precision) + { + + + return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(), precision); + } + + AlgebraicNum(Context ctx, long obj) + { super(ctx, obj); + + } + } diff --git a/src/api/java/com/Microsoft/Z3/ApplyResult.java b/src/api/java/com/Microsoft/Z3/ApplyResult.java index 9bd613930..51be63496 100644 --- a/src/api/java/com/Microsoft/Z3/ApplyResult.java +++ b/src/api/java/com/Microsoft/Z3/ApplyResult.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -15,20 +19,20 @@ package com.Microsoft.Z3; /** * The number of Subgoals. **/ - public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context.nCtx, NativeObject); } + public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context().nCtx(), NativeObject()); } /** * Retrieves the subgoals from the ApplyResult. **/ public Goal[] Subgoals() { - - + + long n = NumSubgoals; Goal[] res = new Goal[n]; - for (long i = 0; i < n; i++) - res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context().nCtx(), NativeObject(), i)); return res; } @@ -42,7 +46,7 @@ package com.Microsoft.Z3; - return new Model(Context, Native.applyResultConvertModel(Context.nCtx, NativeObject, i, m.NativeObject)); + return new Model(Context, Native.applyResultConvertModel(Context().nCtx(), NativeObject(), i, m.NativeObject)); } /** @@ -50,33 +54,34 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.applyResulttoString(Context.nCtx, NativeObject); + return Native.applyResultToString(Context().nCtx(), NativeObject()); } - ApplyResult(Context ctx, IntPtr obj) { super(ctx, obj); + ApplyResult(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.applyResultIncRef(ctx.nCtx, obj); + Native.applyResultIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.applyResultDecRef(ctx.nCtx, obj); + Native.applyResultDecRef(ctx.nCtx(), obj); } - }; + }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.ApplyResult_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 new file mode 100644 index 000000000..7920bdded --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ArithExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from ArithExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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) + { super(ctx, obj); + + } + } diff --git a/src/api/java/com/Microsoft/Z3/ArithSort.java b/src/api/java/com/Microsoft/Z3/ArithSort.java new file mode 100644 index 000000000..a6e339e30 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ArithSort.java @@ -0,0 +1,19 @@ +/** + * This file was automatically generated from ArithSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 new file mode 100644 index 000000000..bc03135aa --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ArrayExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from ArrayExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 new file mode 100644 index 000000000..cd00df084 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ArraySort.java @@ -0,0 +1,46 @@ +/** + * This file was automatically generated from ArraySort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 new file mode 100644 index 000000000..62a03cd06 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/BitVecExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from BitVecExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 long 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 new file mode 100644 index 000000000..81389dd4b --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/BitVecNum.java @@ -0,0 +1,80 @@ +/** + * This file was automatically generated from BitVecNum.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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.getNumeralLong64(Context().nCtx(), NativeObject(), res) == 0) + 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) == 0) + 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) == 0) + throw new Z3Exception("Numeral is not an int64"); + return res; + } + + /** + * Retrieve the int value. + **/ + public long UInt() + { + long res = 0; + if (Native.getNumeralLong(Context().nCtx(), NativeObject(), res) == 0) + throw new Z3Exception("Numeral is not a long"); + return res; + } + + /** + * Retrieve the BigInteger value. + **/ + public BigInteger BigInteger() + { + return BigInteger.Parse(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 new file mode 100644 index 000000000..0ed24573a --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/BitVecSort.java @@ -0,0 +1,25 @@ +/** + * This file was automatically generated from BitVecSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* using System; */ + + /** + * Bit-vector sorts. + **/ + public class BitVecSort extends Sort + { + /** + * The size of the bit-vector sort. + **/ + public long Size() { return Native.getBvSortSize(Context().nCtx(), NativeObject()); } + + BitVecSort(Context ctx, long obj) { super(ctx, obj); { }} + BitVecSort(Context ctx, long size) { super(ctx, Native.mkBvSort(ctx.nCtx(), size)); { }} + }; diff --git a/src/api/java/com/Microsoft/Z3/BoolExpr.java b/src/api/java/com/Microsoft/Z3/BoolExpr.java new file mode 100644 index 000000000..65778ba44 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/BoolExpr.java @@ -0,0 +1,27 @@ +/** + * This file was automatically generated from BoolExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 new file mode 100644 index 000000000..9b05607ac --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/BoolSort.java @@ -0,0 +1,20 @@ +/** + * This file was automatically generated from BoolSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 index 7c9b2a85c..caead4737 100644 --- a/src/api/java/com/Microsoft/Z3/Constructor.java +++ b/src/api/java/com/Microsoft/Z3/Constructor.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -55,7 +59,7 @@ package com.Microsoft.Z3; **/ protected void finalize() { - Native.delConstructor(Context.nCtx, NativeObject); + Native.delConstructor(Context().nCtx(), NativeObject()); } @@ -73,7 +77,7 @@ package com.Microsoft.Z3; Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, long[] sortRefs) - { super(ctx); + { super(ctx); @@ -87,7 +91,7 @@ package com.Microsoft.Z3; if (sortRefs == null) sortRefs = new long[n]; - NativeObject = Native.mkConstructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject, + NativeObject() = Native.mkConstructor(ctx.nCtx(), name.NativeObject, recognizer.NativeObject, n, Symbol.ArrayToNative(fieldNames), Sort.ArrayToNative(sorts), @@ -102,42 +106,15 @@ package com.Microsoft.Z3; if (m_testerDecl != null) return; - IntPtr constructor = IntPtr.Zero; - IntPtr tester = IntPtr.Zero; - IntPtr[] accessors = new IntPtr[n]; - Native.queryConstructor(Context.nCtx, NativeObject, n, constructor, tester, accessors); + 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 (long i = 0; i < n; i++) + for (long i; i < n; i++) m_accessorDecls[i] = new FuncDecl(Context, accessors[i]); } } - - /** - * Lists of constructors - **/ - public class ConstructorList extends Z3Object - { - /** - * Destructor. - **/ - protected void finalize() - { - Native.delConstructorList(Context.nCtx, NativeObject); - } - - ConstructorList(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - - ConstructorList(Context ctx, Constructor[] constructors) - { super(ctx); - - - - NativeObject = Native.mkConstructorList(Context.nCtx, (long)constructors.Length, Constructor.ArrayToNative(constructors)); - } - } diff --git a/src/api/java/com/Microsoft/Z3/ConstructorList.java b/src/api/java/com/Microsoft/Z3/ConstructorList.java new file mode 100644 index 000000000..05b85e664 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ConstructorList.java @@ -0,0 +1,42 @@ +/** + * This file was automatically generated from ConstructorList.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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(), (long)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 index c18fb7414..69a01cb86 100644 --- a/src/api/java/com/Microsoft/Z3/Context.java +++ b/src/api/java/com/Microsoft/Z3/Context.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Collections.Generic; */ /* using System.Runtime.InteropServices; */ @@ -17,20 +21,20 @@ package com.Microsoft.Z3; * Constructor. **/ public Context() - { super(); - m_ctx = Native.mkContextRc(IntPtr.Zero); + { super(); + m_ctx = Native.mkContextRc(0); InitContext(); } /** * Constructor. **/ - public Context(Dictionary settings) - { super(); + public Context(Map settings) + { super(); - IntPtr cfg = Native.mkConfig(); - for (KeyValuePair.Iterator kv = settings.iterator(); kv.hasNext(); ) + long cfg = Native.mkConfig(); + for (Iterator kv = settings.iterator(); kv.hasNext(); ) Native.setParamValue(cfg, kv.Key, kv.Value); m_ctx = Native.mkContextRc(cfg); Native.delConfig(cfg); @@ -73,11 +77,11 @@ package com.Microsoft.Z3; if (names == null) return null; Symbol[] result = new Symbol[names.Length]; - for (int i = 0; i < names.Length; ++i) result[i] = MkSymbol(names[i]); + for (int i; i < names.Length; ++i) result[i] = MkSymbol(names[i]); return result; } - private BoolSort m_booleanSort = null; + private BoolSort m_boolSort = null; private IntSort m_intSort = null; private RealSort m_realSort = null; @@ -88,7 +92,7 @@ package com.Microsoft.Z3; { - if (m_booleanSort == null) m_booleanSort = new BoolSort(this); return m_booleanSort; + if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort; } /** @@ -253,7 +257,7 @@ package com.Microsoft.Z3; /** * Create a new finite domain sort. **/ - public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size) + public FiniteDomainSort MkFiniteDomainSort(Symbol name, long size) { @@ -265,7 +269,7 @@ package com.Microsoft.Z3; /** * Create a new finite domain sort. **/ - public FiniteDomainSort MkFiniteDomainSort(String name, ulong size) + public FiniteDomainSort MkFiniteDomainSort(String name, long size) { @@ -354,19 +358,19 @@ package com.Microsoft.Z3; CheckContextMatch(names); long n = (long)names.Length; ConstructorList[] cla = new ConstructorList[n]; - IntPtr[] n_constr = new IntPtr[n]; - for (long i = 0; i < n; i++) + long[] n_constr = new long[n]; + for (long i; i < n; i++) { var constructor = c[i]; CheckContextMatch(constructor); cla[i] = new ConstructorList(this, constructor); - n_constr[i] = cla[i].NativeObject; + n_constr[i] = cla[i].NativeObject(); } - IntPtr[] n_res = new IntPtr[n]; + long[] n_res = new long[n]; Native.mkDatatypes(nCtx, n, Symbol.ArrayToNative(names), n_res, n_constr); DatatypeSort[] res = new DatatypeSort[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = new DatatypeSort(this, n_res[i]); return res; } @@ -534,7 +538,7 @@ package com.Microsoft.Z3; - IntPtr[] termsNative = AST.ArrayToNative(terms); + long[] termsNative = AST.ArrayToNative(terms); return new Pattern(this, Native.mkPattern(nCtx, (long)terms.Length, termsNative)); } @@ -2239,7 +2243,7 @@ package com.Microsoft.Z3; * Sort of the numeral * @return A Term with value and type **/ - public Expr MkNumeral(ulong v, Sort ty) + public Expr MkNumeral(long v, Sort ty) { @@ -2319,7 +2323,7 @@ package com.Microsoft.Z3; * value of the numeral. * @return A Term with value and sort Real **/ - public RatNum MkReal(ulong v) + public RatNum MkReal(long v) { @@ -2378,7 +2382,7 @@ package com.Microsoft.Z3; * value of the numeral. * @return A Term with value and sort Integer **/ - public IntNum MkInt(ulong v) + public IntNum MkInt(long v) { @@ -2438,7 +2442,7 @@ package com.Microsoft.Z3; * value of the numeral. * the size of the bit-vector **/ - public BitVecNum MkBV(ulong v, long size) + public BitVecNum MkBV(long v, long size) { @@ -2668,7 +2672,7 @@ package com.Microsoft.Z3; long n = NumSMTLIBFormulas; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibFormula(nCtx, i)); return res; } @@ -2687,7 +2691,7 @@ package com.Microsoft.Z3; long n = NumSMTLIBAssumptions; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibAssumption(nCtx, i)); return res; } @@ -2706,7 +2710,7 @@ package com.Microsoft.Z3; long n = NumSMTLIBDecls; FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx, i)); return res; } @@ -2725,7 +2729,7 @@ package com.Microsoft.Z3; long n = NumSMTLIBSorts; Sort[] res = new Sort[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx, i)); return res; } @@ -2810,7 +2814,7 @@ package com.Microsoft.Z3; long n = NumTactics; String[] res = new String[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = Native.getTacticName(nCtx, i); return res; } @@ -2851,14 +2855,14 @@ package com.Microsoft.Z3; CheckContextMatch(t2); CheckContextMatch(ts); - IntPtr last = IntPtr.Zero; + long last = 0; if (ts != null && ts.Length > 0) { - last = ts[ts.Length - 1].NativeObject; + 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 != IntPtr.Zero) + if (last != 0) { last = Native.tacticAndThen(nCtx, t2.NativeObject, last); return new Tactic(this, Native.tacticAndThen(nCtx, t1.NativeObject, last)); @@ -3082,7 +3086,7 @@ package com.Microsoft.Z3; long n = NumProbes; String[] res = new String[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = Native.getProbeName(nCtx, i); return res; } @@ -3310,7 +3314,7 @@ package com.Microsoft.Z3; * * The native pointer to wrap. **/ - public AST WrapAST(IntPtr nativeObject) + public AST WrapAST(long nativeObject) { return AST.Create(this, nativeObject); @@ -3327,9 +3331,9 @@ package com.Microsoft.Z3; * * The AST to unwrap. **/ - public IntPtr UnwrapAST(AST a) + public long UnwrapAST(AST a) { - return a.NativeObject; + return a.NativeObject(); } /** @@ -3395,20 +3399,20 @@ package com.Microsoft.Z3; **/ public String GetParamValue(String id) { - Native.IntPtr res = new Native.IntPtr(); + long res = 0; int r = Native.getParamValue(nCtx, id, res); - if (r == (int)Z3_lboolean.Z3_L_FALSE) + if (r == (int)Z3_lbool.Z3_L_FALSE) return null; else - return Marshal.PtrtoStringAnsi(res); + return Marshal.PtrToStringAnsi(res); } - IntPtr m_ctx = IntPtr.Zero; + long m_ctx = 0; Native.errorHandler mNErrHandler = null; - IntPtr nCtx () { return m_ctx; } + long nCtx () { return m_ctx; } - void NativeErrorHandler(IntPtr ctx, Z3_error_code errorCode) + void NativeErrorHandler(long ctx, Z3_error_code errorCode) { // Do-nothing error handler. The wrappers in Z3.Native will throw exceptions upon errors. } @@ -3418,7 +3422,7 @@ package com.Microsoft.Z3; PrintMode = 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); - GC.SuppressFinalize(this); + } void CheckContextMatch(Z3Object other) @@ -3435,7 +3439,7 @@ package com.Microsoft.Z3; if (arr != null) { - for (Z3Object.Iterator a = arr.iterator(); a.hasNext(); ) + for (Iterator a = arr.iterator(); a.hasNext(); ) { // It was an assume, now we added the precondition, and we made it into an assert CheckContextMatch(a); @@ -3509,7 +3513,7 @@ package com.Microsoft.Z3; { m_n_err_handler = null; Native.delContext(m_ctx); - m_ctx = IntPtr.Zero; + m_ctx = 0; } else GC.ReRegisterForFinalize(this); @@ -3536,7 +3540,7 @@ package com.Microsoft.Z3; Tactic_DRQ.Clear(this); Fixedpoint_DRQ.Clear(this); - m_booleanSort = null; + 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 new file mode 100644 index 000000000..4b18635cc --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/DatatypeExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from DatatypeExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 new file mode 100644 index 000000000..c108c3de9 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/DatatypeSort.java @@ -0,0 +1,80 @@ +/** + * This file was automatically generated from DatatypeSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* using System; */ + + /** + * Datatype sorts. + **/ + public class DatatypeSort extends Sort + { + /** + * The number of constructors of the datatype sort. + **/ + public long NumConstructors() { return Native.getDatatypeSortNumConstructors(Context().nCtx(), NativeObject()); } + + /** + * The constructors. + **/ + public FuncDecl[] Constructors() + { + + + long n = NumConstructors; + FuncDecl[] res = new FuncDecl[n]; + for (long i; i < n; i++) + res[i] = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); + return res; + } + + /** + * The recognizers. + **/ + public FuncDecl[] Recognizers() + { + + + long n = NumConstructors; + FuncDecl[] res = new FuncDecl[n]; + for (long i; i < n; i++) + res[i] = new FuncDecl(Context, Native.getDatatypeSortRecognizer(Context().nCtx(), NativeObject(), i)); + return res; + } + + /** + * The constructor accessors. + **/ + public FuncDecl[][] Accessors() + { + + + long n = NumConstructors; + FuncDecl[][] res = new FuncDecl[n][]; + for (long i; i < n; i++) + { + FuncDecl fd = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); + long ds = fd.DomainSize; + FuncDecl[] tmp = new FuncDecl[ds]; + for (long j; 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, (long)constructors.Length, ArrayToNative(constructors))); + + + + } + }; diff --git a/src/api/java/com/Microsoft/Z3/EnumSort.java b/src/api/java/com/Microsoft/Z3/EnumSort.java new file mode 100644 index 000000000..77e0ac057 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/EnumSort.java @@ -0,0 +1,82 @@ +/** + * This file was automatically generated from EnumSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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]; + NativeObject() = Native.mkEnumerationSort(ctx.nCtx(), name.NativeObject, (long)n, + Symbol.ArrayToNative(enumNames), n_constdecls, n_testers); + _constdecls = new FuncDecl[n]; + for (long i; i < n; i++) + _constdecls[i] = new FuncDecl(ctx, n_constdecls[i]); + _testerdecls = new FuncDecl[n]; + for (long i; i < n; i++) + _testerdecls[i] = new FuncDecl(ctx, n_testers[i]); + _consts = new Expr[n]; + for (long i; i < n; i++) + _consts[i] = ctx.MkApp(_constdecls[i]); + } + }; diff --git a/src/api/java/com/Microsoft/Z3/Expr.java b/src/api/java/com/Microsoft/Z3/Expr.java index 760fe813d..13aa0bc1c 100644 --- a/src/api/java/com/Microsoft/Z3/Expr.java +++ b/src/api/java/com/Microsoft/Z3/Expr.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -21,9 +25,9 @@ package com.Microsoft.Z3; if (p == null) - return Expr.Create(Context, Native.simplify(Context.nCtx, NativeObject)); + return Expr.Create(Context, Native.simplify(Context().nCtx(), NativeObject())); else - return Expr.Create(Context, Native.simplifyEx(Context.nCtx, NativeObject, p.NativeObject)); + return Expr.Create(Context, Native.simplifyEx(Context().nCtx(), NativeObject(), p.NativeObject)); } /** @@ -32,19 +36,19 @@ package com.Microsoft.Z3; public FuncDecl FuncDecl() { - return new FuncDecl(Context, Native.getAppDecl(Context.nCtx, NativeObject)); + 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_lboolean BoolValue() { return (Z3_lboolean)Native.getBooleanValue(Context.nCtx, NativeObject); } + public Z3_lbool BoolValue() { return (Z3_lbool)Native.getBoolValue(Context().nCtx(), NativeObject()); } /** * The number of arguments of the expression. **/ - public long NumArgs() { return Native.getAppNumArgs(Context.nCtx, NativeObject); } + public long NumArgs() { return Native.getAppNumArgs(Context().nCtx(), NativeObject()); } /** * The arguments of the expression. @@ -55,8 +59,8 @@ package com.Microsoft.Z3; long n = NumArgs; Expr[] res = new Expr[n]; - for (long i = 0; i < n; i++) - res[i] = Expr.Create(Context, Native.getAppArg(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Expr.Create(Context, Native.getAppArg(Context().nCtx(), NativeObject(), i)); return res; } @@ -72,7 +76,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(args); if (args.Length != NumArgs) throw new Z3Exception("Number of arguments does not match"); - NativeObject = Native.updateTerm(Context.nCtx, NativeObject, (long)args.Length, Expr.ArrayToNative(args)); + setNativeObject(Native.updateTerm(Context().nCtx(), NativeObject(), (long)args.Length, Expr.ArrayToNative(args))); } /** @@ -95,7 +99,7 @@ package com.Microsoft.Z3; 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, (long)from.Length, Expr.ArrayToNative(from), Expr.ArrayToNative(to))); + return Expr.Create(Context, Native.substitute(Context().nCtx(), NativeObject(), (long)from.Length, Expr.ArrayToNative(from), Expr.ArrayToNative(to))); } /** @@ -124,7 +128,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(to); - return Expr.Create(Context, Native.substituteVars(Context.nCtx, NativeObject, (long)to.Length, Expr.ArrayToNative(to))); + return Expr.Create(Context, Native.substituteVars(Context().nCtx(), NativeObject(), (long)to.Length, Expr.ArrayToNative(to))); } /** @@ -140,7 +144,7 @@ package com.Microsoft.Z3; if (ReferenceEquals(Context, ctx)) return this; else - return Expr.Create(ctx, Native.translate(Context.nCtx, NativeObject, ctx.nCtx)); + return Expr.Create(ctx, Native.translate(Context().nCtx(), NativeObject(), ctx.nCtx())); } /** @@ -148,19 +152,19 @@ package com.Microsoft.Z3; **/ public String toString() { - return super.toString(); + return super.ToString(); } /** * Indicates whether the term is a numeral **/ - public boolean IsNumeral() { return Native.isNumeralAst(Context.nCtx, NativeObject) != 0; } + public boolean IsNumeral() { return Native.isNumeralAst(Context().nCtx(), NativeObject()) != 0; } /** * 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) != 0; } + public boolean IsWellSorted() { return Native.isWellSorted(Context().nCtx(), NativeObject()) != 0; } /** * The Sort of the term. @@ -168,7 +172,7 @@ package com.Microsoft.Z3; public Sort Sort() { - return Sort.Create(Context, Native.getSort(Context.nCtx, NativeObject)); + return Sort.Create(Context, Native.getSort(Context().nCtx(), NativeObject())); } /** @@ -189,7 +193,7 @@ package com.Microsoft.Z3; /** * Indicates whether the term is an algebraic number **/ - public boolean IsAlgebraicNumber() { return Native.isAlgebraicNumber(Context.nCtx, NativeObject) != 0; } + public boolean IsAlgebraicNumber() { return Native.isAlgebraicNumber(Context().nCtx(), NativeObject()) != 0; } /** @@ -198,9 +202,9 @@ package com.Microsoft.Z3; public boolean IsBool() { return (IsExpr && - Native.isEqSort(Context.nCtx, - Native.mkBooleanSort(Context.nCtx), - Native.getSort(Context.nCtx, NativeObject)) != 0); + Native.isEqSort(Context().nCtx(), + Native.mkBoolSort(Context().nCtx()), + Native.getSort(Context().nCtx(), NativeObject())) != 0); } /** @@ -263,14 +267,14 @@ package com.Microsoft.Z3; **/ public boolean IsInt() { - return (Native.isNumeralAst(Context.nCtx, NativeObject) != 0 && - Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == (long)Z3_sort_kind.Z3_INT_SORT); + return (Native.isNumeralAst(Context().nCtx(), NativeObject()) != 0 && + Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == (long)Z3_sort_kind.Z3_INT_SORT); } /** * Indicates whether the term is of sort real. **/ - public boolean IsReal() { return Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == (long)Z3_sort_kind.Z3_REAL_SORT; } + public boolean IsReal() { return Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == (long)Z3_sort_kind.Z3_REAL_SORT; } /** * Indicates whether the term is an arithmetic numeral. @@ -357,8 +361,8 @@ package com.Microsoft.Z3; **/ public boolean IsArray() { - return (Native.isApp(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_ARRAY_SORT); + return (Native.isApp(Context().nCtx(), NativeObject()) != 0 && + (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_ARRAY_SORT); } /** @@ -426,7 +430,7 @@ package com.Microsoft.Z3; /** * Indicates whether the terms is of bit-vector sort. **/ - public boolean IsBV() { return Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == (long)Z3_sort_kind.Z3_BV_SORT; } + public boolean IsBV() { return Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == (long)Z3_sort_kind.Z3_BV_SORT; } /** * Indicates whether the term is a bit-vector numeral @@ -1216,8 +1220,8 @@ package com.Microsoft.Z3; **/ public boolean IsRelation() { - return (Native.isApp(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_RELATION_SORT); + return (Native.isApp(Context().nCtx(), NativeObject()) != 0 && + (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_RELATION_SORT); } /** @@ -1332,8 +1336,8 @@ package com.Microsoft.Z3; **/ public boolean IsFiniteDomain() { - return (Native.isApp(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.getSortKind(Context.nCtx, Native.getSort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT); + return (Native.isApp(Context().nCtx(), NativeObject()) != 0 && + (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT); } /** @@ -1367,23 +1371,23 @@ package com.Microsoft.Z3; - return Native.getIndexValue(Context.nCtx, NativeObject); + return Native.getIndexValue(Context().nCtx(), NativeObject()); } /** * Constructor for Expr **/ - protected Expr(Context ctx) { super(ctx); } + protected Expr(Context ctx) { super(ctx); { }} /** * Constructor for Expr **/ - protected Expr(Context ctx, IntPtr obj) { super(ctx, obj); } + protected Expr(Context ctx, long obj) { super(ctx, obj); { }} - void CheckNativeObject(IntPtr obj) + void CheckNativeObject(long obj) { - if (Native.isApp(Context.nCtx, obj) == 0 && - (Z3_ast_kind)Native.getAstKind(Context.nCtx, obj) != Z3_ast_kind.Z3_VAR_AST && - (Z3_ast_kind)Native.getAstKind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) + if (Native.isApp(Context().nCtx(), obj) == 0 && + (Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST && + (Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) throw new Z3Exception("Underlying object is not a term"); super.CheckNativeObject(obj); } @@ -1394,27 +1398,27 @@ package com.Microsoft.Z3; - IntPtr obj = Native.mkApp(ctx.nCtx, f.NativeObject, + long obj = Native.mkApp(ctx.nCtx(), f.NativeObject, AST.ArrayLength(arguments), AST.ArrayToNative(arguments)); return Create(ctx, obj); } - static Expr Create(Context ctx, IntPtr obj) + static Expr Create(Context ctx, long obj) { - Z3_ast_kind k = (Z3_ast_kind)Native.getAstKind(ctx.nCtx, obj); + Z3_ast_kind k = (Z3_ast_kind)Native.getAstKind(ctx.nCtx(), obj); if (k == Z3_ast_kind.Z3_QUANTIFIER_AST) return new Quantifier(ctx, obj); - IntPtr s = Native.getSort(ctx.nCtx, obj); - Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(ctx.nCtx, s); + long s = Native.getSort(ctx.nCtx(), obj); + Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(ctx.nCtx(), s); - if (Native.isAlgebraicNumber(ctx.nCtx, obj) != 0) // is this a numeral ast? + if (Native.isAlgebraicNumber(ctx.nCtx(), obj) != 0) // is this a numeral ast? return new AlgebraicNum(ctx, obj); - if (Native.isNumeralAst(ctx.nCtx, obj) != 0) + if (Native.isNumeralAst(ctx.nCtx(), obj) != 0) { switch (sk) { @@ -1437,118 +1441,3 @@ package com.Microsoft.Z3; return new Expr(ctx, obj); } } - - /** - * Boolean expressions - **/ - public class BoolExpr extends Expr - { - /** Constructor for BoolExpr - **/ - protected BoolExpr(Context ctx) { super(ctx); } - /** Constructor for BoolExpr - **/ - BoolExpr(Context ctx, IntPtr obj) { super(ctx, obj); } - } - - /** - * Arithmetic expressions (int/real) - **/ - public class ArithExpr extends Expr - { - /** Constructor for ArithExpr - **/ - protected ArithExpr(Context ctx) - { super(ctx); - - } - ArithExpr(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } - - /** - * Int expressions - **/ - public class IntExpr extends ArithExpr - { - /** Constructor for IntExpr - **/ - protected IntExpr(Context ctx) - { super(ctx); - - } - IntExpr(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } - - /** - * Real expressions - **/ - public class RealExpr extends ArithExpr - { - /** Constructor for RealExpr - **/ - protected RealExpr(Context ctx) - { super(ctx); - - } - RealExpr(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } - - /** - * Bit-vector expressions - **/ - public class BitVecExpr extends Expr - { - - /** - * The size of the sort of a bit-vector term. - **/ - public long SortSize() { return ((BitVecSort)Sort).Size; } - - /** Constructor for BitVecExpr - **/ - protected BitVecExpr(Context ctx) { super(ctx); } - BitVecExpr(Context ctx, IntPtr obj) { super(ctx, obj); } - } - - /** - * Array expressions - **/ - public class ArrayExpr extends Expr - { - /** Constructor for ArrayExpr - **/ - protected ArrayExpr(Context ctx) - { super(ctx); - - } - ArrayExpr(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } - - /** - * Datatype expressions - **/ - public class DatatypeExpr extends Expr - { - /** Constructor for DatatypeExpr - **/ - protected DatatypeExpr(Context ctx) - { super(ctx); - - } - DatatypeExpr(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java b/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java new file mode 100644 index 000000000..016d0fecc --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java @@ -0,0 +1,38 @@ +/** + * This file was automatically generated from FiniteDomainSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 index 77ce576ac..0c38f9679 100644 --- a/src/api/java/com/Microsoft/Z3/Fixedpoint.java +++ b/src/api/java/com/Microsoft/Z3/Fixedpoint.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -18,7 +22,7 @@ package com.Microsoft.Z3; public String Help() { - return Native.fixedpointGetHelp(Context.nCtx, NativeObject); + return Native.fixedpointGetHelp(Context().nCtx(), NativeObject()); } /** @@ -28,13 +32,13 @@ package com.Microsoft.Z3; { Context.CheckContextMatch(value); - Native.fixedpointSetParams(Context.nCtx, NativeObject, value.NativeObject); + 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)); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.fixedpointGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -46,9 +50,9 @@ package com.Microsoft.Z3; Context.CheckContextMatch(constraints); - for (BoolExpr.Iterator a = constraints.iterator(); a.hasNext(); ) + for (Iterator a = constraints.iterator(); a.hasNext(); ) { - Native.fixedpointAssert(Context.nCtx, NativeObject, a.NativeObject); + Native.fixedpointAssert(Context().nCtx(), NativeObject(), a.NativeObject); } } @@ -60,7 +64,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(f); - Native.fixedpointRegisterRelation(Context.nCtx, NativeObject, f.NativeObject); + Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), f.NativeObject); } /** @@ -71,7 +75,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(rule); - Native.fixedpointAddRule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name)); + Native.fixedpointAddRule(Context().nCtx(), NativeObject(), rule.NativeObject, AST.GetNativeObject(name)); } /** @@ -83,7 +87,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(pred); - Native.fixedpointAddFact(Context.nCtx, NativeObject, pred.NativeObject, (long)args.Length, args); + Native.fixedpointAddFact(Context().nCtx(), NativeObject(), pred.NativeObject, (long)args.Length, args); } /** @@ -97,11 +101,11 @@ package com.Microsoft.Z3; Context.CheckContextMatch(query); - Z3_lboolean r = (Z3_lboolean)Native.fixedpointQuery(Context.nCtx, NativeObject, query.NativeObject); + Z3_lbool r = (Z3_lbool)Native.fixedpointQuery(Context().nCtx(), NativeObject(), query.NativeObject); switch (r) { - case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -118,12 +122,12 @@ package com.Microsoft.Z3; Context.CheckContextMatch(relations); - Z3_lboolean r = (Z3_lboolean)Native.fixedpointQueryRelations(Context.nCtx, NativeObject, + Z3_lbool r = (Z3_lbool)Native.fixedpointQueryRelations(Context().nCtx(), NativeObject(), AST.ArrayLength(relations), AST.ArrayToNative(relations)); switch (r) { - case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -134,7 +138,7 @@ package com.Microsoft.Z3; **/ public void Push() { - Native.fixedpointPush(Context.nCtx, NativeObject); + Native.fixedpointPush(Context().nCtx(), NativeObject()); } /** @@ -144,7 +148,7 @@ package com.Microsoft.Z3; **/ public void Pop() { - Native.fixedpointPop(Context.nCtx, NativeObject); + Native.fixedpointPop(Context().nCtx(), NativeObject()); } @@ -156,7 +160,7 @@ package com.Microsoft.Z3; Context.CheckContextMatch(rule); - Native.fixedpointUpdateRule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name)); + Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(), rule.NativeObject, AST.GetNativeObject(name)); } /** @@ -165,8 +169,8 @@ package com.Microsoft.Z3; **/ public Expr GetAnswer() { - IntPtr ans = Native.fixedpointGetAnswer(Context.nCtx, NativeObject); - return (ans == IntPtr.Zero) ? null : Expr.Create(Context, ans); + long ans = Native.fixedpointGetAnswer(Context().nCtx(), NativeObject()); + return (ans == 0) ? null : Expr.Create(Context, ans); } /** @@ -176,7 +180,7 @@ package com.Microsoft.Z3; { - return Native.fixedpointGetReasonUnknown(Context.nCtx, NativeObject); + return Native.fixedpointGetReasonUnknown(Context().nCtx(), NativeObject()); } /** @@ -184,7 +188,7 @@ package com.Microsoft.Z3; **/ public long GetNumLevels(FuncDecl predicate) { - return Native.fixedpointGetNumLevels(Context.nCtx, NativeObject, predicate.NativeObject); + return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), predicate.NativeObject); } /** @@ -192,8 +196,8 @@ package com.Microsoft.Z3; **/ public Expr GetCoverDelta(int level, FuncDecl predicate) { - IntPtr res = Native.fixedpointGetCoverDelta(Context.nCtx, NativeObject, level, predicate.NativeObject); - return (res == IntPtr.Zero) ? null : Expr.Create(Context, res); + long res = Native.fixedpointGetCoverDelta(Context().nCtx(), NativeObject(), level, predicate.NativeObject); + return (res == 0) ? null : Expr.Create(Context, res); } /** @@ -202,7 +206,7 @@ package com.Microsoft.Z3; **/ public void AddCover(int level, FuncDecl predicate, Expr property) { - Native.fixedpointAddCover(Context.nCtx, NativeObject, level, predicate.NativeObject, property.NativeObject); + Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, predicate.NativeObject, property.NativeObject); } /** @@ -210,7 +214,7 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.fixedpointtoString(Context.nCtx, NativeObject, 0, null); + return Native.fixedpointToString(Context().nCtx(), NativeObject(), 0, null); } /** @@ -220,7 +224,7 @@ package com.Microsoft.Z3; { - Native.fixedpointSetPredicateRepresentation(Context.nCtx, NativeObject, + Native.fixedpointSetPredicateRepresentation(Context().nCtx(), NativeObject(), f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds)); } @@ -231,7 +235,7 @@ package com.Microsoft.Z3; public String toString(BoolExpr[] queries) { - return Native.fixedpointtoString(Context.nCtx, NativeObject, + return Native.fixedpointToString(Context().nCtx(), NativeObject(), AST.ArrayLength(queries), AST.ArrayToNative(queries)); } @@ -242,10 +246,10 @@ package com.Microsoft.Z3; { - ASTVector v = new ASTVector(Context, Native.fixedpointGetRules(Context.nCtx, NativeObject)); + ASTVector v = new ASTVector(Context, Native.fixedpointGetRules(Context().nCtx(), NativeObject())); long n = v.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = new BoolExpr(Context, v[i].NativeObject); return res; } @@ -257,44 +261,44 @@ package com.Microsoft.Z3; { - ASTVector v = new ASTVector(Context, Native.fixedpointGetAssertions(Context.nCtx, NativeObject)); + ASTVector v = new ASTVector(Context, Native.fixedpointGetAssertions(Context().nCtx(), NativeObject())); long n = v.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = new BoolExpr(Context, v[i].NativeObject); return res; } - Fixedpoint(Context ctx, IntPtr obj) - { super(ctx, obj); + Fixedpoint(Context ctx, long obj) + { super(ctx, obj); } Fixedpoint(Context ctx) - { super(ctx, Native.mkFixedpoint(ctx.nCtx)); + { super(ctx, Native.mkFixedpoint(ctx.nCtx())); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.fixedpointIncRef(ctx.nCtx, obj); + Native.fixedpointIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.fixedpointDecRef(ctx.nCtx, obj); + Native.fixedpointDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Fixedpoint_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index ddedcf4ee..91579b085 100644 --- a/src/api/java/com/Microsoft/Z3/FuncDecl.java +++ b/src/api/java/com/Microsoft/Z3/FuncDecl.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -26,7 +30,7 @@ package com.Microsoft.Z3; /** * Object comparison. **/ - public boolean Equals(object o) + public boolean Equals(Object o) { FuncDecl casted = (FuncDecl) o; if (casted == null) return false; @@ -46,24 +50,24 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.funcDecltoString(Context.nCtx, NativeObject); + return Native.funcDeclToString(Context().nCtx(), NativeObject()); } /** * Returns a unique identifier for the function declaration. **/ - public long Id() { return Native.getFuncDeclId(Context.nCtx, NativeObject); } + public long Id() { return Native.getFuncDeclId(Context().nCtx(), NativeObject()); } /** * The arity of the function declaration **/ - public long Arity() { return Native.getArity(Context.nCtx, NativeObject); } + public long Arity() { return Native.getArity(Context().nCtx(), NativeObject()); } /** * The size of the domain of the function declaration * **/ - public long DomainSize() { return Native.getDomainSize(Context.nCtx, NativeObject); } + public long DomainSize() { return Native.getDomainSize(Context().nCtx(), NativeObject()); } /** * The domain of the function declaration @@ -75,8 +79,8 @@ package com.Microsoft.Z3; var n = DomainSize; Sort[] res = new Sort[n]; - for (long i = 0; i < n; i++) - res[i] = Sort.Create(Context, Native.getDomain(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Sort.Create(Context, Native.getDomain(Context().nCtx(), NativeObject(), i)); return res; } @@ -86,13 +90,13 @@ package com.Microsoft.Z3; public Sort Range() { - return Sort.Create(Context, Native.getRange(Context.nCtx, NativeObject)); + return Sort.Create(Context, Native.getRange(Context().nCtx(), NativeObject())); } /** * The kind of the function declaration. **/ - public Z3_decl_kind DeclKind() { return (Z3_decl_kind)Native.getDeclKind(Context.nCtx, NativeObject); } + public Z3_decl_kind DeclKind() { return (Z3_decl_kind)Native.getDeclKind(Context().nCtx(), NativeObject()); } /** * The name of the function declaration @@ -100,13 +104,13 @@ package com.Microsoft.Z3; public Symbol Name() { - return Symbol.Create(Context, Native.getDeclName(Context.nCtx, NativeObject)); + return Symbol.Create(Context, Native.getDeclName(Context().nCtx(), NativeObject())); } /** * The number of parameters of the function declaration **/ - public long NumParameters() { return Native.getDeclNumParameters(Context.nCtx, NativeObject); } + public long NumParameters() { return Native.getDeclNumParameters(Context().nCtx(), NativeObject()); } /** * The parameters of the function declaration @@ -117,31 +121,31 @@ package com.Microsoft.Z3; long num = NumParameters; Parameter[] res = new Parameter[num]; - for (long i = 0; i < num; i++) + for (long i; i < num; i++) { - Z3_parameter_kind k = (Z3_parameter_kind)Native.getDeclParameterKind(Context.nCtx, NativeObject, i); + Z3_parameter_kind k = (Z3_parameter_kind)Native.getDeclParameterKind(Context().nCtx(), NativeObject(), i); switch (k) { case Z3_parameter_kind.Z3_PARAMETER_INT: - res[i] = new Parameter(k, Native.getDeclIntParameter(Context.nCtx, NativeObject, i)); + res[i] = new Parameter(k, Native.getDeclIntParameter(Context().nCtx(), NativeObject(), i)); break; case Z3_parameter_kind.Z3_PARAMETER_DOUBLE: - res[i] = new Parameter(k, Native.getDeclDoubleParameter(Context.nCtx, NativeObject, i)); + res[i] = new Parameter(k, Native.getDeclDoubleParameter(Context().nCtx(), NativeObject(), i)); break; case Z3_parameter_kind.Z3_PARAMETER_SYMBOL: - res[i] = new Parameter(k, Symbol.Create(Context, Native.getDeclSymbolParameter(Context.nCtx, NativeObject, i))); + res[i] = new Parameter(k, Symbol.Create(Context, Native.getDeclSymbolParameter(Context().nCtx(), NativeObject(), i))); break; case Z3_parameter_kind.Z3_PARAMETER_SORT: - res[i] = new Parameter(k, Sort.Create(Context, Native.getDeclSortParameter(Context.nCtx, NativeObject, i))); + res[i] = new Parameter(k, Sort.Create(Context, Native.getDeclSortParameter(Context().nCtx(), NativeObject(), i))); break; case Z3_parameter_kind.Z3_PARAMETER_AST: - res[i] = new Parameter(k, new AST(Context, Native.getDeclAstParameter(Context.nCtx, NativeObject, i))); + res[i] = new Parameter(k, new AST(Context, Native.getDeclAstParameter(Context().nCtx(), NativeObject(), i))); break; case Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL: - res[i] = new Parameter(k, new FuncDecl(Context, Native.getDeclFuncDeclParameter(Context.nCtx, NativeObject, i))); + res[i] = new Parameter(k, new FuncDecl(Context, Native.getDeclFuncDeclParameter(Context().nCtx(), NativeObject(), i))); break; case Z3_parameter_kind.Z3_PARAMETER_RATIONAL: - res[i] = new Parameter(k, Native.getDeclRationalParameter(Context.nCtx, NativeObject, i)); + res[i] = new Parameter(k, Native.getDeclRationalParameter(Context().nCtx(), NativeObject(), i)); break; default: throw new Z3Exception("Unknown function declaration parameter kind encountered"); @@ -195,7 +199,8 @@ package com.Microsoft.Z3; { this.kind = k; this.i = i; - } + } + Parameter(Z3_parameter_kind k, double d) { this.kind = k; @@ -233,31 +238,27 @@ package com.Microsoft.Z3; } } - FuncDecl(Context ctx, IntPtr obj) - { super(ctx, obj); + FuncDecl(Context ctx, long obj) + { super(ctx, obj); } FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range) - : base(ctx, Native.mkFuncDecl(ctx.nCtx, name.NativeObject, - AST.ArrayLength(domain), AST.ArrayToNative(domain), - range.NativeObject)) + { 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) - : base(ctx, Native.mkFreshFuncDecl(ctx.nCtx, prefix, - AST.ArrayLength(domain), AST.ArrayToNative(domain), - range.NativeObject)) + { super(ctx, Native.mkFreshFuncDecl(ctx.nCtx(), prefix, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject)); } - void CheckNativeObject(IntPtr obj) + void CheckNativeObject(long obj) { - if (Native.getAstKind(Context.nCtx, obj) != (long)Z3_ast_kind.Z3_FUNC_DECL_AST) + if (Native.getAstKind(Context().nCtx(), obj) != (long)Z3_ast_kind.Z3_FUNC_DECL_AST) throw new Z3Exception("Underlying object is not a function declaration"); super.CheckNativeObject(obj); } @@ -267,15 +268,8 @@ package com.Microsoft.Z3; * * @return **/ - public Expr this[params() lic Expr this[params Expr[] args - { - public Expr this[params() - { - - - return Apply(args); - } - + /* operator this[] not translated */ + /** * Create expression that applies function to arguments. * diff --git a/src/api/java/com/Microsoft/Z3/FuncInterp.java b/src/api/java/com/Microsoft/Z3/FuncInterp.java index 6aeb33759..7544aba11 100644 --- a/src/api/java/com/Microsoft/Z3/FuncInterp.java +++ b/src/api/java/com/Microsoft/Z3/FuncInterp.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -21,15 +25,16 @@ package com.Microsoft.Z3; /** * Return the (symbolic) value of this entry. **/ - public Expr Value() { + public Expr Value() + { - return Expr.Create(Context, Native.funcEntryGetValue(Context.nCtx, NativeObject)); } - } + return Expr.Create(Context, Native.funcEntryGetValue(Context().nCtx(), NativeObject())); + } /** * The number of arguments of the entry. **/ - public long NumArgs() { return Native.funcEntryGetNumArgs(Context.nCtx, NativeObject); } + public long NumArgs() { return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); } /** * The arguments of the function entry. @@ -41,8 +46,8 @@ package com.Microsoft.Z3; long n = NumArgs; Expr[] res = new Expr[n]; - for (long i = 0; i < n; i++) - res[i] = Expr.Create(Context, Native.funcEntryGetArg(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Expr.Create(Context, Native.funcEntryGetArg(Context().nCtx(), NativeObject(), i)); return res; } @@ -54,33 +59,33 @@ package com.Microsoft.Z3; long n = NumArgs; String res = "["; Expr[] args = Args; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res += args[i] + ", "; return res + Value + "]"; } - Entry(Context ctx, IntPtr obj) { super(ctx, obj); } + Entry(Context ctx, long obj) { super(ctx, obj); { }} - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.funcEntryIncRef(ctx.nCtx, obj); + Native.funcEntryIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.funcEntryDecRef(ctx.nCtx, obj); + Native.funcEntryDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.FuncEntry_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr o) + void DecRef(long o) { Context.FuncEntry_DRQ.Add(o); super.DecRef(o); @@ -90,7 +95,7 @@ package com.Microsoft.Z3; /** * The number of entries in the function interpretation. **/ - public long NumEntries() { return Native.funcInterpGetNumEntries(Context.nCtx, NativeObject); } + public long NumEntries() { return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); } /** * The entries in the function interpretation @@ -98,29 +103,29 @@ package com.Microsoft.Z3; public Entry[] Entries() { - Contract.Ensures(Contract.ForAll(0, Contract.Result().Length, - j => Contract.Result()[j] != null)); + long n = NumEntries; Entry[] res = new Entry[n]; - for (long i = 0; i < n; i++) - res[i] = new Entry(Context, Native.funcInterpGetEntry(Context.nCtx, NativeObject, i)); + for (long i; 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() { + public Expr Else() + { - return Expr.Create(Context, Native.funcInterpGetElse(Context.nCtx, NativeObject)); } - } + return Expr.Create(Context, Native.funcInterpGetElse(Context().nCtx(), NativeObject())); + } /** * The arity of the function interpretation **/ - public long Arity() { return Native.funcInterpGetArity(Context.nCtx, NativeObject); } + public long Arity() { return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); } /** * A string representation of the function interpretation. @@ -129,12 +134,12 @@ package com.Microsoft.Z3; { String res = ""; res += "["; - for (Entry.Iterator e = Entries.iterator(); e.hasNext(); ) + for (Iterator e = Entries.iterator(); e.hasNext(); ) { - long n = e.NumArgs; + long n = e.NumArgs; if (n > 1) res += "["; Expr[] args = e.Args; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) { if (i != 0) res += ", "; res += args[i]; @@ -147,31 +152,31 @@ package com.Microsoft.Z3; return res; } - FuncInterp(Context ctx, IntPtr obj) - { super(ctx, obj); + FuncInterp(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.funcInterpIncRef(ctx.nCtx, obj); + Native.funcInterpIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.funcInterpDecRef(ctx.nCtx, obj); + Native.funcInterpDecRef(ctx.nCtx(), obj); } - }; + }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.FuncInterp_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 171b81d47..bfbefa203 100644 --- a/src/api/java/com/Microsoft/Z3/Goal.java +++ b/src/api/java/com/Microsoft/Z3/Goal.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -21,7 +25,7 @@ package com.Microsoft.Z3; * 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)Native.goalPrecision(Context.nCtx, NativeObject); } + public Z3_goal_prec Precision() { return (Z3_goal_prec)Native.goalPrecision(Context().nCtx(), NativeObject()); } /** * Indicates whether the goal is precise. @@ -51,17 +55,17 @@ package com.Microsoft.Z3; Context.CheckContextMatch(constraints); - for (BoolExpr.Iterator c = constraints.iterator(); c.hasNext(); ) + for (Iterator c = constraints.iterator(); c.hasNext(); ) { // It was an assume, now made an assert just to be sure we do not regress - Native.goalAssert(Context.nCtx, NativeObject, c.NativeObject); + Native.goalAssert(Context().nCtx(), NativeObject(), c.NativeObject); } } /** * Indicates whether the goal contains `false'. **/ - public boolean Inconsistent() { return Native.goalInconsistent(Context.nCtx, NativeObject) != 0; } + public boolean Inconsistent() { return Native.goalInconsistent(Context().nCtx(), NativeObject()) != 0; } /** * The depth of the goal. @@ -69,20 +73,20 @@ package com.Microsoft.Z3; * This tracks how many transformations were applied to it. * **/ - public long Depth() { return Native.goalDepth(Context.nCtx, NativeObject); } + public long Depth() { return Native.goalDepth(Context().nCtx(), NativeObject()); } /** * Erases all formulas from the given goal. **/ public void Reset() { - Native.goalReset(Context.nCtx, NativeObject); + Native.goalReset(Context().nCtx(), NativeObject()); } /** * The number of formulas in the goal. **/ - public long Size() { return Native.goalSize(Context.nCtx, NativeObject); } + public long Size() { return Native.goalSize(Context().nCtx(), NativeObject()); } /** * The formulas in the goal. @@ -93,25 +97,25 @@ package com.Microsoft.Z3; long n = Size; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) - res[i] = new BoolExpr(Context, Native.goalFormula(Context.nCtx, NativeObject, i)); + for (long i; 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 long NumExprs() { return Native.goalNumExprs(Context.nCtx, NativeObject); } + public long 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) != 0; } + public boolean IsDecidedSat() { return Native.goalIsDecidedSat(Context().nCtx(), NativeObject()) != 0; } /** * 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) != 0; } + public boolean IsDecidedUnsat() { return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject()) != 0; } /** * Translates (copies) the Goal to the target Context . @@ -120,7 +124,7 @@ package com.Microsoft.Z3; { - return new Goal(ctx, Native.goalTranslate(Context.nCtx, NativeObject, ctx.nCtx)); + return new Goal(ctx, Native.goalTranslate(Context().nCtx(), NativeObject(), ctx.nCtx())); } /** @@ -144,36 +148,36 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.goaltoString(Context.nCtx, NativeObject); + return Native.goalToString(Context().nCtx(), NativeObject()); } - Goal(Context ctx, IntPtr obj) { super(ctx, obj); } + Goal(Context ctx, long obj) { super(ctx, obj); { }} Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) - { super(ctx, Native.mkGoal(ctx.nCtx, (models); ? 1 : 0, (unsatCores) ? 1 : 0, (proofs) ? 1 : 0)) + { super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? 1 : 0, (unsatCores) ? 1 : 0, (proofs) ? 1 : 0)); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.goalIncRef(ctx.nCtx, obj); + Native.goalIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.goalDecRef(ctx.nCtx, obj); + Native.goalDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Goal_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr o) + void DecRef(long o) { Context.Goal_DRQ.Add(o); super.DecRef(o); diff --git a/src/api/java/com/Microsoft/Z3/DecRefQUeue.java b/src/api/java/com/Microsoft/Z3/IDecRefQueue.java similarity index 55% rename from src/api/java/com/Microsoft/Z3/DecRefQUeue.java rename to src/api/java/com/Microsoft/Z3/IDecRefQueue.java index 279887a7c..1b6291ce7 100644 --- a/src/api/java/com/Microsoft/Z3/DecRefQUeue.java +++ b/src/api/java/com/Microsoft/Z3/IDecRefQueue.java @@ -1,15 +1,19 @@ /** - * This file was automatically generated from DecRefQUeue.cs + * This file was automatically generated from IDecRefQueue.cs **/ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Collections; */ /* using System.Collections.Generic; */ /* using System.Threading; */ - abstract class DecRefQueue + abstract class IDecRefQueue { private void ObjectInvariant() @@ -19,13 +23,13 @@ package com.Microsoft.Z3; protected Object m_lock = new Object(); - protected List m_queue = new List(); + protected List m_queue = new List(); final long m_move_limit = 1024; - public abstract void IncRef(Context ctx, IntPtr obj); - public abstract void DecRef(Context ctx, IntPtr obj); + public abstract void IncRef(Context ctx, long obj); + public abstract void DecRef(Context ctx, long obj); - public void IncAndClear(Context ctx, IntPtr o) + public void IncAndClear(Context ctx, long o) { @@ -33,9 +37,9 @@ package com.Microsoft.Z3; if (m_queue.Count >= m_move_limit) Clear(ctx); } - public void Add(IntPtr o) + public void Add(long o) { - if (o == IntPtr.Zero) return; + if (o == 0) return; synchronized (m_lock) { @@ -49,21 +53,21 @@ package com.Microsoft.Z3; synchronized (m_lock) { - for (IntPtr.Iterator o = m_queue.iterator(); o.hasNext(); ) + for (Iterator o = m_queue.iterator(); o.hasNext(); ) DecRef(ctx, o); m_queue.Clear(); } } } - abstract class DecRefQueueContracts extends DecRefQueue + abstract class DecRefQueueContracts extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { } - public void DecRef(Context ctx, IntPtr 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 new file mode 100644 index 000000000..888e441b3 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/IntExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from IntExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 new file mode 100644 index 000000000..e4d0e72e2 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/IntNum.java @@ -0,0 +1,85 @@ +/** + * This file was automatically generated from IntNum.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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.getNumeralLong64(Context().nCtx(), NativeObject(), res) == 0) + 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) == 0) + 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) == 0) + throw new Z3Exception("Numeral is not an int64"); + return res; + } + + /** + * Retrieve the int value. + **/ + public long UInt() + { + long res = 0; + if (Native.getNumeralLong(Context().nCtx(), NativeObject(), res) == 0) + throw new Z3Exception("Numeral is not a long"); + return res; + } + + /** + * Retrieve the BigInteger value. + **/ + public BigInteger BigInteger() + { + return BigInteger.Parse(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 new file mode 100644 index 000000000..29ff35136 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/IntSort.java @@ -0,0 +1,26 @@ +/** + * This file was automatically generated from IntSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 new file mode 100644 index 000000000..0132def21 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/IntSymbol.java @@ -0,0 +1,45 @@ +/** + * This file was automatically generated from IntSymbol.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 ((Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_INT_SYMBOL) + 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 new file mode 100644 index 000000000..96829c11e --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/ListSort.java @@ -0,0 +1,122 @@ +/** + * This file was automatically generated from ListSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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; + + NativeObject() = 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 index 35ac0e022..bfcc2b1c5 100644 --- a/src/api/java/com/Microsoft/Z3/Log.java +++ b/src/api/java/com/Microsoft/Z3/Log.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** diff --git a/src/api/java/com/Microsoft/Z3/Model.java b/src/api/java/com/Microsoft/Z3/Model.java index edd774f56..e20a9d575 100644 --- a/src/api/java/com/Microsoft/Z3/Model.java +++ b/src/api/java/com/Microsoft/Z3/Model.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -35,11 +39,11 @@ package com.Microsoft.Z3; Context.CheckContextMatch(f); if (f.Arity != 0 || - Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject)) == (long)Z3_sort_kind.Z3_ARRAY_SORT) + Native.getSortKind(Context().nCtx(), Native.getRange(Context().nCtx(), f.NativeObject)) == (long)Z3_sort_kind.Z3_ARRAY_SORT) throw new Z3Exception("Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp."); - IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject); - if (n == IntPtr.Zero) + long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(), f.NativeObject); + if (n == 0) return null; else return Expr.Create(Context, n); @@ -56,21 +60,21 @@ package com.Microsoft.Z3; Context.CheckContextMatch(f); - Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(Context.nCtx, Native.getRange(Context.nCtx, f.NativeObject)); + Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getRange(Context().nCtx(), f.NativeObject)); if (f.Arity == 0) { - IntPtr n = Native.modelGetConstInterp(Context.nCtx, NativeObject, f.NativeObject); + long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(), f.NativeObject); if (sk == Z3_sort_kind.Z3_ARRAY_SORT) { - if (n == IntPtr.Zero) + if (n == 0) return null; else { - if (Native.isAsArray(Context.nCtx, n) == 0) + if (Native.isAsArray(Context().nCtx(), n) == 0) throw new Z3Exception("Argument was not an array constant"); - IntPtr fd = Native.getAsArrayFuncDecl(Context.nCtx, n); + long fd = Native.getAsArrayFuncDecl(Context().nCtx(), n); return FuncInterp(new FuncDecl(Context, fd)); } } @@ -81,8 +85,8 @@ package com.Microsoft.Z3; } else { - IntPtr n = Native.modelGetFuncInterp(Context.nCtx, NativeObject, f.NativeObject); - if (n == IntPtr.Zero) + long n = Native.modelGetFuncInterp(Context().nCtx(), NativeObject(), f.NativeObject); + if (n == 0) return null; else return new FuncInterp(Context, n); @@ -92,7 +96,7 @@ package com.Microsoft.Z3; /** * The number of constants that have an interpretation in the model. **/ - public long NumConsts() { return Native.modelGetNumConsts(Context.nCtx, NativeObject); } + public long NumConsts() { return Native.modelGetNumConsts(Context().nCtx(), NativeObject()); } /** * The function declarations of the constants in the model. @@ -103,15 +107,15 @@ package com.Microsoft.Z3; long n = NumConsts; FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) - res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i)); + for (long i; 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 long NumFuncs() { return Native.modelGetNumFuncs(Context.nCtx, NativeObject); } + public long NumFuncs() { return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); } /** * The function declarations of the function interpretations in the model. @@ -122,8 +126,8 @@ package com.Microsoft.Z3; long n = NumFuncs; FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) - res[i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context().nCtx(), NativeObject(), i)); return res; } @@ -138,10 +142,10 @@ package com.Microsoft.Z3; var nConsts = NumConsts; long n = nFuncs + nConsts; FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < nConsts; i++) - res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context.nCtx, NativeObject, i)); - for (long i = 0; i < nFuncs; i++) - res[nConsts + i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context.nCtx, NativeObject, i)); + for (long i; i < nConsts; i++) + res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context().nCtx(), NativeObject(), i)); + for (long i; i < nFuncs; i++) + res[nConsts + i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context().nCtx(), NativeObject(), i)); return res; } @@ -153,7 +157,7 @@ package com.Microsoft.Z3; /** * An exception that is thrown when model evaluation fails. **/ - public ModelEvaluationFailedException() { super(); } + public ModelEvaluationFailedException() { super(); { }} } /** @@ -175,8 +179,8 @@ package com.Microsoft.Z3; - IntPtr v = IntPtr.Zero; - if (Native.modelEval(Context.nCtx, NativeObject, t.NativeObject, (completion) ? 1 : 0, v) == 0) + long v = 0; + if (Native.modelEval(Context().nCtx(), NativeObject(), t.NativeObject, (completion) ? 1 : 0, v) == 0) throw new ModelEvaluationFailedException(); else return Expr.Create(Context, v); @@ -196,7 +200,7 @@ package com.Microsoft.Z3; /** * The number of uninterpreted sorts that the model has an interpretation for. **/ - public long NumSorts () { return Native.modelGetNumSorts(Context.nCtx, NativeObject); } + public long NumSorts () { return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); } /** * The uninterpreted sorts that the model has an interpretation for. @@ -214,8 +218,8 @@ package com.Microsoft.Z3; long n = NumSorts; Sort[] res = new Sort[n]; - for (long i = 0; i < n; i++) - res[i] = Sort.Create(Context, Native.modelGetSort(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Sort.Create(Context, Native.modelGetSort(Context().nCtx(), NativeObject(), i)); return res; } @@ -230,10 +234,10 @@ package com.Microsoft.Z3; - ASTVector nUniv = new ASTVector(Context, Native.modelGetSortUniverse(Context.nCtx, NativeObject, s.NativeObject)); + ASTVector nUniv = new ASTVector(Context, Native.modelGetSortUniverse(Context().nCtx(), NativeObject(), s.NativeObject)); long n = nUniv.Size; Expr[] res = new Expr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = Expr.Create(Context, nUniv[i].NativeObject); return res; } @@ -244,34 +248,34 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.modeltoString(Context.nCtx, NativeObject); + return Native.modelToString(Context().nCtx(), NativeObject()); } - Model(Context ctx, IntPtr obj) - { super(ctx, obj); + Model(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.modelIncRef(ctx.nCtx, obj); + Native.modelIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.modelDecRef(ctx.nCtx, obj); + Native.modelDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Model_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr o) + void DecRef(long o) { Context.Model_DRQ.Add(o); super.DecRef(o); diff --git a/src/api/java/com/Microsoft/Z3/Native.java b/src/api/java/com/Microsoft/Z3/Native.java index 31ca6f4bc..261e0663f 100644 --- a/src/api/java/com/Microsoft/Z3/Native.java +++ b/src/api/java/com/Microsoft/Z3/Native.java @@ -4,7 +4,8 @@ public final class Native { public static class IntPtr { public int value; } public static class LongPtr { public long value; } public static class StringPtr { public String value; } - static { System.loadLibrary(""); } + public static class errorHandler {}; + 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); diff --git a/src/api/java/com/Microsoft/Z3/Numeral.java b/src/api/java/com/Microsoft/Z3/Numeral.java deleted file mode 100644 index d0ed20dc9..000000000 --- a/src/api/java/com/Microsoft/Z3/Numeral.java +++ /dev/null @@ -1,264 +0,0 @@ -/** - * This file was automatically generated from Numeral.cs - **/ - -package com.Microsoft.Z3; -/* using System; */ - -/* using System.Numerics; */ - - /** - * Integer Numerals - **/ - public class IntNum extends IntExpr - { - - IntNum(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - - - /** - * Retrieve the 64-bit unsigned integer value. - **/ - public UInt64 UInt64() - { - UInt64 res = 0; - if (Native.getNumeralLong64(Context.nCtx, NativeObject, res) == 0) - 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) == 0) - throw new Z3Exception("Numeral is not an int"); - return res; - } - - /** - * Retrieve the 64-bit int value. - **/ - public Int64 Int64() - { - Int64 res = 0; - if (Native.getNumeralInt64(Context.nCtx, NativeObject, res) == 0) - throw new Z3Exception("Numeral is not an int64"); - return res; - } - - /** - * Retrieve the int value. - **/ - public long UInt() - { - long res = 0; - if (Native.getNumeralLong(Context.nCtx, NativeObject, res) == 0) - throw new Z3Exception("Numeral is not a long"); - return res; - } - - /** - * Retrieve the BigInteger value. - **/ - public BigInteger BigInteger() - { - return BigInteger.Parse(this.toString()); - } - - /** - * Returns a string representation of the numeral. - **/ - public String toString() - { - return Native.getNumeralString(Context.nCtx, NativeObject); - } - } - - /** - * 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 BigInteger.Parse(n.toString()); - } - - /** - * Converts the denominator of the rational to a BigInteger - **/ - public BigInteger BigIntDenominator() - { - IntNum n = Denominator; - return BigInteger.Parse(n.toString()); - } - - /** - * Returns a string representation in decimal notation. - * The result has at most decimal places. - **/ - public String ToDecimalString(long 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, IntPtr obj) - { super(ctx, obj); - - } - } - - - /** - * Bit-vector numerals - **/ - public class BitVecNum extends BitVecExpr - { - /** - * Retrieve the 64-bit unsigned integer value. - **/ - public UInt64 UInt64() - { - UInt64 res = 0; - if (Native.getNumeralLong64(Context.nCtx, NativeObject, res) == 0) - 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) == 0) - throw new Z3Exception("Numeral is not an int"); - return res; - } - - /** - * Retrieve the 64-bit int value. - **/ - public Int64 Int64() - { - Int64 res = 0; - if (Native.getNumeralInt64(Context.nCtx, NativeObject, res) == 0) - throw new Z3Exception("Numeral is not an int64"); - return res; - } - - /** - * Retrieve the int value. - **/ - public long UInt() - { - long res = 0; - if (Native.getNumeralLong(Context.nCtx, NativeObject, res) == 0) - throw new Z3Exception("Numeral is not a long"); - return res; - } - - /** - * Retrieve the BigInteger value. - **/ - public BigInteger BigInteger() - { - return BigInteger.Parse(this.toString()); - } - - /** - * Returns a string representation of the numeral. - **/ - public String toString() - { - return Native.getNumeralString(Context.nCtx, NativeObject); - } - - BitVecNum(Context ctx, IntPtr obj) { super(ctx, obj); } - } - - /** - * 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(long precision) - { - - - 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(long precision) - { - - - 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(long precision) - { - - - return Native.getNumeralDecimalString(Context.nCtx, NativeObject, precision); - } - - AlgebraicNum(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - } diff --git a/src/api/java/com/Microsoft/Z3/ParamDescrs.java b/src/api/java/com/Microsoft/Z3/ParamDescrs.java index abade80b2..37ee77b7e 100644 --- a/src/api/java/com/Microsoft/Z3/ParamDescrs.java +++ b/src/api/java/com/Microsoft/Z3/ParamDescrs.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -17,7 +21,7 @@ package com.Microsoft.Z3; public void Validate(Params p) { - Native.paramsValidate(Context.nCtx, p.NativeObject, NativeObject); + Native.paramsValidate(Context().nCtx(), p.NativeObject, NativeObject()); } /** @@ -26,7 +30,7 @@ package com.Microsoft.Z3; public Z3_param_kind GetKind(Symbol name) { - return (Z3_param_kind)Native.paramDescrsGetKind(Context.nCtx, NativeObject, name.NativeObject); + return (Z3_param_kind)Native.paramDescrsGetKind(Context().nCtx(), NativeObject(), name.NativeObject); } /** @@ -34,10 +38,10 @@ package com.Microsoft.Z3; **/ public Symbol[] Names() { - long sz = Native.paramDescrsSize(Context.nCtx, NativeObject); + long sz = Native.paramDescrsSize(Context().nCtx(), NativeObject()); Symbol[] names = new Symbol[sz]; - for (long i = 0; i < sz; ++i) { - names[i] = Symbol.Create(Context, Native.paramDescrsGetName(Context.nCtx, NativeObject, i)); + for (long i; i < sz; ++i) { + names[i] = Symbol.Create(Context, Native.paramDescrsGetName(Context().nCtx(), NativeObject(), i)); } return names; } @@ -45,41 +49,41 @@ package com.Microsoft.Z3; /** * The size of the ParamDescrs. **/ - public long Size() { return Native.paramDescrsSize(Context.nCtx, NativeObject); } + public long Size() { return Native.paramDescrsSize(Context().nCtx(), NativeObject()); } /** * Retrieves a string representation of the ParamDescrs. **/ public String toString() { - return Native.paramDescrstoString(Context.nCtx, NativeObject); + return Native.paramDescrsToString(Context().nCtx(), NativeObject()); } - ParamDescrs(Context ctx, IntPtr obj) - { super(ctx, obj); + ParamDescrs(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.paramDescrsIncRef(ctx.nCtx, obj); + Native.paramDescrsIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.paramDescrsDecRef(ctx.nCtx, obj); + Native.paramDescrsDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.ParamDescrs_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 040b6d67d..d5c042d74 100644 --- a/src/api/java/com/Microsoft/Z3/Params.java +++ b/src/api/java/com/Microsoft/Z3/Params.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -18,7 +22,7 @@ package com.Microsoft.Z3; { - Native.paramsSetBoolean(Context.nCtx, NativeObject, name.NativeObject, (value) ? 1 : 0); + Native.paramsSetBool(Context().nCtx(), NativeObject(), name.NativeObject, (value) ? 1 : 0); } /** @@ -28,7 +32,7 @@ package com.Microsoft.Z3; { - Native.paramsSetLong(Context.nCtx, NativeObject, name.NativeObject, value); + Native.paramsSetLong(Context().nCtx(), NativeObject(), name.NativeObject, value); } /** @@ -38,7 +42,7 @@ package com.Microsoft.Z3; { - Native.paramsSetDouble(Context.nCtx, NativeObject, name.NativeObject, value); + Native.paramsSetDouble(Context().nCtx(), NativeObject(), name.NativeObject, value); } /** @@ -49,7 +53,7 @@ package com.Microsoft.Z3; - Native.paramsSetSymbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject); + Native.paramsSetSymbol(Context().nCtx(), NativeObject(), name.NativeObject, value.NativeObject); } /** @@ -57,7 +61,7 @@ package com.Microsoft.Z3; **/ public void Add(String name, boolean value) { - Native.paramsSetBoolean(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (value) ? 1 : 0); + Native.paramsSetBool(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, (value) ? 1 : 0); } /** @@ -65,7 +69,7 @@ package com.Microsoft.Z3; **/ public void Add(String name, long value) { - Native.paramsSetLong(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value); + Native.paramsSetLong(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value); } /** @@ -73,7 +77,7 @@ package com.Microsoft.Z3; **/ public void Add(String name, double value) { - Native.paramsSetDouble(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value); + Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value); } /** @@ -83,7 +87,7 @@ package com.Microsoft.Z3; { - Native.paramsSetSymbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject); + Native.paramsSetSymbol(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value.NativeObject); } /** @@ -91,34 +95,34 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.paramstoString(Context.nCtx, NativeObject); + return Native.paramsToString(Context().nCtx(), NativeObject()); } Params(Context ctx) - { super(ctx, Native.mkParams(ctx.nCtx)); + { super(ctx, Native.mkParams(ctx.nCtx())); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.paramsIncRef(ctx.nCtx, obj); + Native.paramsIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.paramsDecRef(ctx.nCtx, obj); + Native.paramsDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Params_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index edc772dcf..0e87dc254 100644 --- a/src/api/java/com/Microsoft/Z3/Pattern.java +++ b/src/api/java/com/Microsoft/Z3/Pattern.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Runtime.InteropServices; */ @@ -17,7 +21,7 @@ package com.Microsoft.Z3; /** * The number of terms in the pattern. **/ - public long NumTerms() { return Native.getPatternNumTerms(Context.nCtx, NativeObject); } + public long NumTerms() { return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); } /** * The terms in the pattern. @@ -28,8 +32,8 @@ package com.Microsoft.Z3; long n = NumTerms; Expr[] res = new Expr[n]; - for (long i = 0; i < n; i++) - res[i] = Expr.Create(Context, Native.getPattern(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Expr.Create(Context, Native.getPattern(Context().nCtx(), NativeObject(), i)); return res; } @@ -38,11 +42,11 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.patterntoString(Context.nCtx, NativeObject); + return Native.patternToString(Context().nCtx(), NativeObject()); } - Pattern(Context ctx, IntPtr obj) - { super(ctx, obj); + 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 index 36f949966..537e9ef7f 100644 --- a/src/api/java/com/Microsoft/Z3/Probe.java +++ b/src/api/java/com/Microsoft/Z3/Probe.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Runtime.InteropServices; */ @@ -26,45 +30,48 @@ package com.Microsoft.Z3; Context.CheckContextMatch(g); - return Native.probeApply(Context.nCtx, NativeObject, g.NativeObject); + return Native.probeApply(Context().nCtx(), NativeObject(), g.NativeObject); } /** * Apply the probe to a goal. **/ - public double this[Goal() - + public double get(Goal g) + { + - return Apply(g); } } + return Apply(g); + } - Probe(Context ctx, IntPtr obj) - { super(ctx, obj); + Probe(Context ctx, long obj) + { super(ctx, obj); + } Probe(Context ctx, String name) - { super(ctx, Native.mkProbe(ctx.nCtx, name)); + { super(ctx, Native.mkProbe(ctx.nCtx(), name)); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.probeIncRef(ctx.nCtx, obj); + Native.probeIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.probeDecRef(ctx.nCtx, obj); + Native.probeDecRef(ctx.nCtx(), obj); } - }; + }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Probe_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 6c7c91be7..8b4df947e 100644 --- a/src/api/java/com/Microsoft/Z3/Quantifier.java +++ b/src/api/java/com/Microsoft/Z3/Quantifier.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -14,7 +18,7 @@ package com.Microsoft.Z3; /** * Indicates whether the quantifier is universal. **/ - public boolean IsUniversal() { return Native.isQuantifierForall(Context.nCtx, NativeObject) != 0; } + public boolean IsUniversal() { return Native.isQuantifierForall(Context().nCtx(), NativeObject()) != 0; } /** * Indicates whether the quantifier is existential. @@ -24,12 +28,12 @@ package com.Microsoft.Z3; /** * The weight of the quantifier. **/ - public long Weight() { return Native.getQuantifierWeight(Context.nCtx, NativeObject); } + public long Weight() { return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); } /** * The number of patterns. **/ - public long NumPatterns() { return Native.getQuantifierNumPatterns(Context.nCtx, NativeObject); } + public long NumPatterns() { return Native.getQuantifierNumPatterns(Context().nCtx(), NativeObject()); } /** * The patterns. @@ -40,15 +44,15 @@ package com.Microsoft.Z3; long n = NumPatterns; Pattern[] res = new Pattern[n]; - for (long i = 0; i < n; i++) - res[i] = new Pattern(Context, Native.getQuantifierPatternAst(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = new Pattern(Context, Native.getQuantifierPatternAst(Context().nCtx(), NativeObject(), i)); return res; } /** * The number of no-patterns. **/ - public long NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context.nCtx, NativeObject); } + public long NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context().nCtx(), NativeObject()); } /** * The no-patterns. @@ -59,15 +63,15 @@ package com.Microsoft.Z3; long n = NumNoPatterns; Pattern[] res = new Pattern[n]; - for (long i = 0; i < n; i++) - res[i] = new Pattern(Context, Native.getQuantifierNoPatternAst(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = new Pattern(Context, Native.getQuantifierNoPatternAst(Context().nCtx(), NativeObject(), i)); return res; } /** * The number of bound variables. **/ - public long NumBound() { return Native.getQuantifierNumBound(Context.nCtx, NativeObject); } + public long NumBound() { return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); } /** * The symbols for the bound variables. @@ -78,8 +82,8 @@ package com.Microsoft.Z3; long n = NumBound; Symbol[] res = new Symbol[n]; - for (long i = 0; i < n; i++) - res[i] = Symbol.Create(Context, Native.getQuantifierBoundName(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Symbol.Create(Context, Native.getQuantifierBoundName(Context().nCtx(), NativeObject(), i)); return res; } @@ -92,25 +96,23 @@ package com.Microsoft.Z3; long n = NumBound; Sort[] res = new Sort[n]; - for (long i = 0; i < n; i++) - res[i] = Sort.Create(Context, Native.getQuantifierBoundSort(Context.nCtx, NativeObject, i)); + for (long i; i < n; i++) + res[i] = Sort.Create(Context, Native.getQuantifierBoundSort(Context().nCtx(), NativeObject(), i)); return res; } /** * The body of the quantifier. **/ - public BoolExpr Body() { + public BoolExpr Body() + { - - return new BoolExpr(Context, Native.getQuantifierBody(Context.nCtx, NativeObject)); } - } - Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body, - long weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, - Symbol quantifierID = null, Symbol skolemID = null - ) - { super(ctx); + return new BoolExpr(Context, Native.getQuantifierBody(Context().nCtx(), NativeObject())); + } + + Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + { super(ctx); @@ -130,18 +132,19 @@ package com.Microsoft.Z3; if (sorts.Length != names.Length) throw new Z3Exception("Number of sorts does not match number of names"); - IntPtr[] _patterns = AST.ArrayToNative(patterns); + long[] _patterns = AST.ArrayToNative(patterns); if (noPatterns == null && quantifierID == null && skolemID == null) { - NativeObject = Native.mkQuantifier(ctx.nCtx, (isForall) ? 1 : 0, weight, - AST.ArrayLength(patterns), AST.ArrayToNative(patterns), + NativeObject() = Native.mkQuantifier(ctx.nCtx(), (isForall) ? 1 : 0, weight, + AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(sorts), AST.ArrayToNative(sorts), Symbol.ArrayToNative(names), body.NativeObject); + } else { - NativeObject = Native.mkQuantifierEx(ctx.nCtx, (isForall) ? 1 : 0, weight, + NativeObject() = Native.mkQuantifierEx(ctx.nCtx(), (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns), @@ -151,15 +154,12 @@ package com.Microsoft.Z3; } } - Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body, - long weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, - Symbol quantifierID = null, Symbol skolemID = null - ) - { super(ctx); + Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + { super(ctx); - + @@ -167,17 +167,17 @@ package com.Microsoft.Z3; Context.CheckContextMatch(patterns); //Context.CheckContextMatch(bound); Context.CheckContextMatch(body); - + if (noPatterns == null && quantifierID == null && skolemID == null) { - NativeObject = Native.mkQuantifierConst(ctx.nCtx, (isForall) ? 1 : 0, weight, + NativeObject() = Native.mkQuantifierConst(ctx.nCtx(), (isForall) ? 1 : 0, weight, AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), body.NativeObject); } else { - NativeObject = Native.mkQuantifierConstEx(ctx.nCtx, (isForall) ? 1 : 0, weight, + NativeObject() = Native.mkQuantifierConstEx(ctx.nCtx(), (isForall) ? 1 : 0, weight, AST.GetNativeObject(quantifierID), AST.GetNativeObject(skolemID), AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), @@ -187,11 +187,11 @@ package com.Microsoft.Z3; } - Quantifier(Context ctx, IntPtr obj) { super(ctx, obj); } + Quantifier(Context ctx, long obj) { super(ctx, obj); { }} - void CheckNativeObject(IntPtr obj) + void CheckNativeObject(long obj) { - if ((Z3_ast_kind)Native.getAstKind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) + if ((Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) 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 new file mode 100644 index 000000000..7921e70ef --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/RatNum.java @@ -0,0 +1,78 @@ +/** + * This file was automatically generated from RatNum.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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 BigInteger.Parse(n.ToString()); + } + + /** + * Converts the denominator of the rational to a BigInteger + **/ + public BigInteger BigIntDenominator() + { + IntNum n = Denominator; + return BigInteger.Parse(n.ToString()); + } + + /** + * Returns a string representation in decimal notation. + * The result has at most decimal places. + **/ + public String ToDecimalString(long 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) + { super(ctx, obj); + + } + } diff --git a/src/api/java/com/Microsoft/Z3/RealExpr.java b/src/api/java/com/Microsoft/Z3/RealExpr.java new file mode 100644 index 000000000..8f2b139bd --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/RealExpr.java @@ -0,0 +1,31 @@ +/** + * This file was automatically generated from RealExpr.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; +/* 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) + { super(ctx, obj); + + } + } diff --git a/src/api/java/com/Microsoft/Z3/RealSort.java b/src/api/java/com/Microsoft/Z3/RealSort.java new file mode 100644 index 000000000..39aa849ab --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/RealSort.java @@ -0,0 +1,26 @@ +/** + * This file was automatically generated from RealSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 new file mode 100644 index 000000000..3948e1651 --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/RelationSort.java @@ -0,0 +1,46 @@ +/** + * This file was automatically generated from RelationSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* using System; */ + + /** + * Relation sorts. + **/ + public class RelationSort extends Sort + { + /** + * The arity of the relation sort. + **/ + public long 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; + + long n = Arity; + Sort[] res = new Sort[n]; + for (long i; 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 new file mode 100644 index 000000000..2f008f4db --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/SetSort.java @@ -0,0 +1,27 @@ +/** + * This file was automatically generated from SetSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 index 787e115ab..a206114f1 100644 --- a/src/api/java/com/Microsoft/Z3/Solver.java +++ b/src/api/java/com/Microsoft/Z3/Solver.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -18,7 +22,7 @@ package com.Microsoft.Z3; { - return Native.solverGetHelp(Context.nCtx, NativeObject); + return Native.solverGetHelp(Context().nCtx(), NativeObject()); } /** @@ -29,13 +33,13 @@ package com.Microsoft.Z3; Context.CheckContextMatch(value); - Native.solverSetParams(Context.nCtx, NativeObject, value.NativeObject); + Native.solverSetParams(Context().nCtx(), NativeObject(), value.NativeObject); } /** * Retrieves parameter descriptions for solver. **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.solverGetParamDescrs(Context.nCtx, NativeObject)); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.solverGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -43,7 +47,7 @@ package com.Microsoft.Z3; * * **/ - public long NumScopes() { return Native.solverGetNumScopes(Context.nCtx, NativeObject); } + public long NumScopes() { return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); } /** * Creates a backtracking point. @@ -51,7 +55,7 @@ package com.Microsoft.Z3; **/ public void Push() { - Native.solverPush(Context.nCtx, NativeObject); + Native.solverPush(Context().nCtx(), NativeObject()); } /** @@ -61,7 +65,7 @@ package com.Microsoft.Z3; **/ public void Pop(long n) { - Native.solverPop(Context.nCtx, NativeObject, n); + Native.solverPop(Context().nCtx(), NativeObject(), n); } /** @@ -70,7 +74,7 @@ package com.Microsoft.Z3; **/ public void Reset() { - Native.solverReset(Context.nCtx, NativeObject); + Native.solverReset(Context().nCtx(), NativeObject()); } /** @@ -82,9 +86,9 @@ package com.Microsoft.Z3; Context.CheckContextMatch(constraints); - for (BoolExpr.Iterator a = constraints.iterator(); a.hasNext(); ) + for (Iterator a = constraints.iterator(); a.hasNext(); ) { - Native.solverAssert(Context.nCtx, NativeObject, a.NativeObject); + Native.solverAssert(Context().nCtx(), NativeObject(), a.NativeObject); } } @@ -93,7 +97,7 @@ package com.Microsoft.Z3; **/ public long NumAssertions() { - ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject)); + ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context().nCtx(), NativeObject())); return ass.Size; } @@ -104,10 +108,10 @@ package com.Microsoft.Z3; { - ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context.nCtx, NativeObject)); + ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context().nCtx(), NativeObject())); long n = ass.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = new BoolExpr(Context, ass[i].NativeObject); return res; } @@ -122,15 +126,15 @@ package com.Microsoft.Z3; **/ public Status Check(Expr[] assumptions) { - Z3_lboolean r; + Z3_lbool r; if (assumptions == null) - r = (Z3_lboolean)Native.solverCheck(Context.nCtx, NativeObject); + r = (Z3_lbool)Native.solverCheck(Context().nCtx(), NativeObject()); else - r = (Z3_lboolean)Native.solverCheckAssumptions(Context.nCtx, NativeObject, (long)assumptions.Length, AST.ArrayToNative(assumptions)); + r = (Z3_lbool)Native.solverCheckAssumptions(Context().nCtx(), NativeObject(), (long)assumptions.Length, AST.ArrayToNative(assumptions)); switch (r) { - case Z3_lboolean.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lboolean.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -144,8 +148,8 @@ package com.Microsoft.Z3; **/ public Model Model() { - IntPtr x = Native.solverGetModel(Context.nCtx, NativeObject); - if (x == IntPtr.Zero) + long x = Native.solverGetModel(Context().nCtx(), NativeObject()); + if (x == 0) return null; else return new Model(Context, x); @@ -160,8 +164,8 @@ package com.Microsoft.Z3; **/ public Expr Proof() { - IntPtr x = Native.solverGetProof(Context.nCtx, NativeObject); - if (x == IntPtr.Zero) + long x = Native.solverGetProof(Context().nCtx(), NativeObject()); + if (x == 0) return null; else return Expr.Create(Context, x); @@ -179,10 +183,10 @@ package com.Microsoft.Z3; { - ASTVector core = new ASTVector(Context, Native.solverGetUnsatCore(Context.nCtx, NativeObject)); + ASTVector core = new ASTVector(Context, Native.solverGetUnsatCore(Context().nCtx(), NativeObject())); long n = core.Size; Expr[] res = new Expr[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) res[i] = Expr.Create(Context, core[i].NativeObject); return res; } @@ -194,7 +198,7 @@ package com.Microsoft.Z3; { - return Native.solverGetReasonUnknown(Context.nCtx, NativeObject); + return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject()); } /** @@ -204,7 +208,7 @@ package com.Microsoft.Z3; { - return new Statistics(Context, Native.solverGetStatistics(Context.nCtx, NativeObject)); + return new Statistics(Context, Native.solverGetStatistics(Context().nCtx(), NativeObject())); } /** @@ -212,34 +216,34 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.solvertoString(Context.nCtx, NativeObject); + return Native.solverToString(Context().nCtx(), NativeObject()); } - Solver(Context ctx, IntPtr obj) - { super(ctx, obj); + Solver(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.solverIncRef(ctx.nCtx, obj); + Native.solverIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.solverDecRef(ctx.nCtx, obj); + Native.solverDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Solver_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 8e4735389..d328071dd 100644 --- a/src/api/java/com/Microsoft/Z3/Sort.java +++ b/src/api/java/com/Microsoft/Z3/Sort.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -34,9 +38,9 @@ package com.Microsoft.Z3; * * @return **/ - public boolean Equals(object o) + public boolean Equals(Object o) { - Sort casted = o as Sort; + Sort casted = (Sort) o; if (casted == null) return false; return this == casted; } @@ -53,47 +57,49 @@ package com.Microsoft.Z3; /** * Returns a unique identifier for the sort. **/ - public long Id() { return Native.getSortId(Context.nCtx, NativeObject); } + public long Id() { return Native.getSortId(Context().nCtx(), NativeObject()); } /** * The kind of the sort. **/ - public Z3_sort_kind SortKind() { return (Z3_sort_kind)Native.getSortKind(Context.nCtx, NativeObject); } + public Z3_sort_kind SortKind() { return (Z3_sort_kind)Native.getSortKind(Context().nCtx(), NativeObject()); } /** * The name of the sort **/ - public Symbol Name() { + public Symbol Name() + { - return Symbol.Create(Context, Native.getSortName(Context.nCtx, NativeObject)); } - } + return Symbol.Create(Context, Native.getSortName(Context().nCtx(), NativeObject())); + } /** * A string representation of the sort. **/ public String toString() { - return Native.sorttoString(Context.nCtx, NativeObject); + return Native.sortToString(Context().nCtx(), NativeObject()); + } /** * Sort constructor **/ - protected Sort(Context ctx) { super(ctx); } - Sort(Context ctx, IntPtr obj) { super(ctx, obj); } + protected Sort(Context ctx) { super(ctx); { }} + Sort(Context ctx, long obj) { super(ctx, obj); { }} - void CheckNativeObject(IntPtr obj) + void CheckNativeObject(long obj) { - if (Native.getAstKind(Context.nCtx, obj) != (long)Z3_ast_kind.Z3_SORT_AST) + if (Native.getAstKind(Context().nCtx(), obj) != (long)Z3_ast_kind.Z3_SORT_AST) throw new Z3Exception("Underlying object is not a sort"); super.CheckNativeObject(obj); } - static Sort Create(Context ctx, IntPtr obj) + static Sort Create(Context ctx, long obj) { - switch ((Z3_sort_kind)Native.getSortKind(ctx.nCtx, obj)) + switch ((Z3_sort_kind)Native.getSortKind(ctx.nCtx(), obj)) { case Z3_sort_kind.Z3_ARRAY_SORT: return new ArraySort(ctx, obj); case Z3_sort_kind.Z3_BOOL_SORT: return new BoolSort(ctx, obj); @@ -108,476 +114,4 @@ package com.Microsoft.Z3; throw new Z3Exception("Unknown sort kind"); } } - } - - /** - * A Boolean sort. - **/ - public class BoolSort extends Sort - { - BoolSort(Context ctx, IntPtr obj) { super(ctx, obj); } - BoolSort(Context ctx) { super(ctx, Native.mkBooleanSort(ctx.nCtx)); } - }; - - /** - * An arithmetic sort, i.e., Int or Real. - **/ - public class ArithSort extends Sort - { - ArithSort(Context ctx, IntPtr obj) { super(ctx, obj); } - }; - - /** - * An Integer sort - **/ - public class IntSort extends ArithSort - { - IntSort(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - IntSort(Context ctx) - { super(ctx, Native.mkIntSort(ctx.nCtx)); - - } - } - - /** - * A real sort - **/ - public class RealSort extends ArithSort - { - RealSort(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - RealSort(Context ctx) - { super(ctx, Native.mkRealSort(ctx.nCtx)); - - } - } - - /** - * Bit-vector sorts. - **/ - public class BitVecSort extends Sort - { - /** - * The size of the bit-vector sort. - **/ - public long Size() { return Native.getBvSortSize(Context.nCtx, NativeObject); } - - BitVecSort(Context ctx, IntPtr obj) { super(ctx, obj); } - BitVecSort(Context ctx, long size) { super(ctx, Native.mkBvSort(ctx.nCtx, size)); } - }; - - /** - * 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, IntPtr obj) { super(ctx, obj); } - ArraySort(Context ctx, Sort domain, Sort range) - { super(ctx, Native.mkArraySort(ctx.nCtx, domain.NativeObject, range.NativeObject)); - - - - }; - - /** - * Datatype sorts. - **/ - public class DatatypeSort extends Sort - { - /** - * The number of constructors of the datatype sort. - **/ - public long NumConstructors() { return Native.getDatatypeSortNumConstructors(Context.nCtx, NativeObject); } - - /** - * The constructors. - **/ - public FuncDecl[] Constructors() - { - - - long n = NumConstructors; - FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) - res[i] = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i)); - return res; - } - - /** - * The recognizers. - **/ - public FuncDecl[] Recognizers() - { - - - long n = NumConstructors; - FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) - res[i] = new FuncDecl(Context, Native.getDatatypeSortRecognizer(Context.nCtx, NativeObject, i)); - return res; - } - - /** - * The constructor accessors. - **/ - public FuncDecl[][] Accessors() - { - - - long n = NumConstructors; - FuncDecl[][] res = new FuncDecl[n][]; - for (long i = 0; i < n; i++) - { - FuncDecl fd = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context.nCtx, NativeObject, i)); - long ds = fd.DomainSize; - FuncDecl[] tmp = new FuncDecl[ds]; - for (long 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, IntPtr obj) { super(ctx, obj); } - - DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) - { super(ctx, Native.mkDatatype(ctx.nCtx, name.NativeObject, (long)constructors.Length, ArrayToNative(constructors))); - - - - } - }; - - /** - * Uninterpreted Sorts - **/ - public class UninterpretedSort extends Sort - { - UninterpretedSort(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - UninterpretedSort(Context ctx, Symbol s) - { super(ctx, Native.mkUninterpretedSort(ctx.nCtx, s.NativeObject)); - - - } - } - - /** - * 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 long NumFields() { return Native.getTupleSortNumFields(Context.nCtx, NativeObject); } - - /** - * The field declarations. - **/ - public FuncDecl[] FieldDecls() - { - - - long n = NumFields; - FuncDecl[] res = new FuncDecl[n]; - for (long i = 0; i < n; i++) - res[i] = new FuncDecl(Context, Native.getTupleSortFieldDecl(Context.nCtx, NativeObject, i)); - return res; - } - - TupleSort(Context ctx, Symbol name, long numFields, Symbol[] fieldNames, Sort[] fieldSorts) - { super(ctx); - - - - IntPtr t = IntPtr.Zero; - NativeObject = Native.mkTupleSort(ctx.nCtx, name.NativeObject, numFields, - Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts), - t, new IntPtr[numFields]); - } - }; - - /** - * 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; - IntPtr[] n_constdecls = new IntPtr[n]; - IntPtr[] n_testers = new IntPtr[n]; - NativeObject = Native.mkEnumerationSort(ctx.nCtx, name.NativeObject, (long)n, - Symbol.ArrayToNative(enumNames), n_constdecls, n_testers); - _constdecls = new FuncDecl[n]; - for (long i = 0; i < n; i++) - _constdecls[i] = new FuncDecl(ctx, n_constdecls[i]); - _testerdecls = new FuncDecl[n]; - for (long i = 0; i < n; i++) - _testerdecls[i] = new FuncDecl(ctx, n_testers[i]); - _consts = new Expr[n]; - for (long i = 0; i < n; i++) - _consts[i] = ctx.MkApp(_constdecls[i]); - } - }; - - /** - * 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); - - - - - IntPtr inil = IntPtr.Zero, - iisnil = IntPtr.Zero, - icons = IntPtr.Zero, - iiscons = IntPtr.Zero, - ihead = IntPtr.Zero, - itail = IntPtr.Zero; - - NativeObject = 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); - } - }; - - /** - * Relation sorts. - **/ - public class RelationSort extends Sort - { - /** - * The arity of the relation sort. - **/ - public long 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; - - long n = Arity; - Sort[] res = new Sort[n]; - for (long 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, IntPtr obj) - { super(ctx, obj); - - } - } - - /** - * Finite domain sorts. - **/ - public class FiniteDomainSort extends Sort - { - /** - * The size of the finite domain sort. - **/ - public ulong Size() { ulong res = 0; Native.getFiniteDomainSortSize(Context.nCtx, NativeObject, ref res); return res; } - - FiniteDomainSort(Context ctx, IntPtr obj) - { super(ctx, obj); - - } - FiniteDomainSort(Context ctx, Symbol name, ulong size) - { super(ctx, Native.mkFiniteDomainSort(ctx.nCtx, name.NativeObject, size)); - - - - } - } - - /** - * Set sorts. - **/ - public class SetSort extends Sort - { - SetSort(Context ctx, IntPtr 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/Statistics.java b/src/api/java/com/Microsoft/Z3/Statistics.java index d9aac9d67..d0f4021ed 100644 --- a/src/api/java/com/Microsoft/Z3/Statistics.java +++ b/src/api/java/com/Microsoft/Z3/Statistics.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -45,9 +49,9 @@ package com.Microsoft.Z3; if (IsUInt) - return m_long.toString(); + return m_long.ToString(); else if (IsDouble) - return m_double.toString(); + return m_double.ToString(); else throw new Z3Exception("Unknown statistical entry type"); } @@ -64,8 +68,18 @@ package com.Microsoft.Z3; private boolean m_is_double = false; private long m_long = 0; private double m_double = 0.0; - Entry(String k, long v) { Key = k; m_is_long = true; m_long = v; } - Entry(String k, double v) { Key = k; m_is_double = true; m_double = v; } + Entry(String k, long v) + { + Key = k; + m_is_long = true; + m_long = v; + } + Entry(String k, double v) + { + Key = k; + m_is_double = true; + m_double = v; + } } /** @@ -73,13 +87,13 @@ package com.Microsoft.Z3; **/ public String toString() { - return Native.statstoString(Context.nCtx, NativeObject); + return Native.statsToString(Context().nCtx(), NativeObject()); } /** * The number of statistical data. **/ - public long Size() { return Native.statsSize(Context.nCtx, NativeObject); } + public long Size() { return Native.statsSize(Context().nCtx(), NativeObject()); } /** * The data entries. @@ -92,14 +106,14 @@ package com.Microsoft.Z3; long n = Size; Entry[] res = new Entry[n]; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) { Entry e; - String k = Native.statsGetKey(Context.nCtx, NativeObject, i); - if (Native.statsIsLong(Context.nCtx, NativeObject, i) != 0) - e = new Entry(k, Native.statsGetLongValue(Context.nCtx, NativeObject, i)); - else if (Native.statsIsDouble(Context.nCtx, NativeObject, i) != 0) - e = new Entry(k, Native.statsGetDoubleValue(Context.nCtx, NativeObject, i)); + String k = Native.statsGetKey(Context().nCtx(), NativeObject(), i); + if (Native.statsIsLong(Context().nCtx(), NativeObject(), i) != 0) + e = new Entry(k, Native.statsGetLongValue(Context().nCtx(), NativeObject(), i)); + else if (Native.statsIsDouble(Context().nCtx(), NativeObject(), i) != 0) + e = new Entry(k, Native.statsGetDoubleValue(Context().nCtx(), NativeObject(), i)); else throw new Z3Exception("Unknown data entry value"); res[i] = e; @@ -116,8 +130,8 @@ package com.Microsoft.Z3; long n = Size; String[] res = new String[n]; - for (long i = 0; i < n; i++) - res[i] = Native.statsGetKey(Context.nCtx, NativeObject, i); + for (long i; i < n; i++) + res[i] = Native.statsGetKey(Context().nCtx(), NativeObject(), i); return res; } @@ -129,37 +143,37 @@ package com.Microsoft.Z3; { long n = Size; Entry[] es = Entries; - for (long i = 0; i < n; i++) + for (long i; i < n; i++) if (es[i].Key == key) return es[i]; return null; } - Statistics(Context ctx, IntPtr obj) - { super(ctx, obj); + Statistics(Context ctx, long obj) + { super(ctx, obj); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.statsIncRef(ctx.nCtx, obj); + Native.statsIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.statsDecRef(ctx.nCtx, obj); + Native.statsDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Statistics_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 index 86c902285..9eb75060c 100644 --- a/src/api/java/com/Microsoft/Z3/Status.java +++ b/src/api/java/com/Microsoft/Z3/Status.java @@ -4,23 +4,30 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** * Status values. **/ - /** - * Used to signify an unsatisfiable status. - **/ - UNSATISFIABLE = -1, + public enum Status + { + /// + /// Used to signify an unsatisfiable status. + /// + UNSATISFIABLE (1), - /** - * Used to signify an unknown status. - **/ - UNKNOWN = 0, + /// + /// Used to signify an unknown status. + /// + UNKNOWN (0), - /** - * Used to signify a satisfiable status. - **/ - SATISFIABLE = 1 + /// + /// Used to signify a satisfiable status. + /// + SATISFIABLE (1) + } diff --git a/src/api/java/com/Microsoft/Z3/StringSymbol.java b/src/api/java/com/Microsoft/Z3/StringSymbol.java new file mode 100644 index 000000000..27157599d --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/StringSymbol.java @@ -0,0 +1,50 @@ +/** + * This file was automatically generated from StringSymbol.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 ((Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL) + 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 index 972999e66..54caf9f1c 100644 --- a/src/api/java/com/Microsoft/Z3/Symbol.java +++ b/src/api/java/com/Microsoft/Z3/Symbol.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /* using System.Runtime.InteropServices; */ @@ -15,10 +19,7 @@ package com.Microsoft.Z3; /** * The kind of the symbol (int or string) **/ - protected Z3_symbol_kind Kind - { - get { return (Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, NativeObject); } - } + protected Z3_symbol_kind Kind() { return (Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), NativeObject()); } /** * Indicates whether the symbol is of Int kind @@ -42,7 +43,7 @@ package com.Microsoft.Z3; public String toString() { if (IsIntSymbol()) - return ((IntSymbol)this).Int.toString(); + return ((IntSymbol)this).Int.ToString(); else if (IsStringSymbol()) return ((StringSymbol)this).String; else @@ -52,16 +53,16 @@ package com.Microsoft.Z3; /** * Symbol constructor **/ - protected Symbol(Context ctx, IntPtr obj) { super(ctx, obj); + protected Symbol(Context ctx, long obj) { super(ctx, obj); } - static Symbol Create(Context ctx, IntPtr obj) + static Symbol Create(Context ctx, long obj) { - switch ((Z3_symbol_kind)Native.getSymbolKind(ctx.nCtx, obj)) + switch ((Z3_symbol_kind)Native.getSymbolKind(ctx.nCtx(), obj)) { case Z3_symbol_kind.Z3_INT_SYMBOL: return new IntSymbol(ctx, obj); case Z3_symbol_kind.Z3_STRING_SYMBOL: return new StringSymbol(ctx, obj); @@ -70,71 +71,3 @@ package com.Microsoft.Z3; } } } - - /** - * 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, IntPtr obj) - { super(ctx, obj); - - } - IntSymbol(Context ctx, int i) - { super(ctx, Native.mkIntSymbol(ctx.nCtx, i)); - - } - - void CheckNativeObject(IntPtr obj) - { - if ((Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, obj) != Z3_symbol_kind.Z3_INT_SYMBOL) - throw new Z3Exception("Symbol is not of integer kind"); - super.CheckNativeObject(obj); - } - } - - /** - * 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, IntPtr obj) { super(ctx, obj); - - } - - StringSymbol(Context ctx, String s) { super(ctx, Native.mkStringSymbol(ctx.nCtx, s)); - - } - - void CheckNativeObject(IntPtr obj) - { - if ((Z3_symbol_kind)Native.getSymbolKind(Context.nCtx, obj) != Z3_symbol_kind.Z3_STRING_SYMBOL) - throw new Z3Exception("Symbol is not of String kind"); - - super.CheckNativeObject(obj); - } - } diff --git a/src/api/java/com/Microsoft/Z3/Tactic.java b/src/api/java/com/Microsoft/Z3/Tactic.java index ae74c3a6b..275205be5 100644 --- a/src/api/java/com/Microsoft/Z3/Tactic.java +++ b/src/api/java/com/Microsoft/Z3/Tactic.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -21,14 +25,14 @@ package com.Microsoft.Z3; { - return Native.tacticGetHelp(Context.nCtx, NativeObject); + return Native.tacticGetHelp(Context().nCtx(), NativeObject()); } /** * Retrieves parameter descriptions for Tactics. **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.tacticGetParamDescrs(Context.nCtx, NativeObject)); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.tacticGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -41,11 +45,11 @@ package com.Microsoft.Z3; Context.CheckContextMatch(g); if (p == null) - return new ApplyResult(Context, Native.tacticApply(Context.nCtx, NativeObject, g.NativeObject)); + 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)); + return new ApplyResult(Context, Native.tacticApplyEx(Context().nCtx(), NativeObject(), g.NativeObject, p.NativeObject)); } } @@ -71,35 +75,35 @@ package com.Microsoft.Z3; return Context.MkSolver(this); } - Tactic(Context ctx, IntPtr obj) - { super(ctx, obj); + Tactic(Context ctx, long obj) + { super(ctx, obj); } Tactic(Context ctx, String name) - { super(ctx, Native.mkTactic(ctx.nCtx, name)); + { super(ctx, Native.mkTactic(ctx.nCtx(), name)); } - class DecRefQueue extends Z3.DecRefQueue + class DecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, IntPtr obj) + public void IncRef(Context ctx, long obj) { - Native.tacticIncRef(ctx.nCtx, obj); + Native.tacticIncRef(ctx.nCtx(), obj); } - public void DecRef(Context ctx, IntPtr obj) + public void DecRef(Context ctx, long obj) { - Native.tacticDecRef(ctx.nCtx, obj); + Native.tacticDecRef(ctx.nCtx(), obj); } }; - void IncRef(IntPtr o) + void IncRef(long o) { Context.Tactic_DRQ.IncAndClear(Context, o); super.IncRef(o); } - void DecRef(IntPtr 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 new file mode 100644 index 000000000..2e682343a --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/TupleSort.java @@ -0,0 +1,57 @@ +/** + * This file was automatically generated from TupleSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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 long NumFields() { return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); } + + /** + * The field declarations. + **/ + public FuncDecl[] FieldDecls() + { + + + long n = NumFields; + FuncDecl[] res = new FuncDecl[n]; + for (long i; i < n; i++) + res[i] = new FuncDecl(Context, Native.getTupleSortFieldDecl(Context().nCtx(), NativeObject(), i)); + return res; + } + + TupleSort(Context ctx, Symbol name, long numFields, Symbol[] fieldNames, Sort[] fieldSorts) + { super(ctx); + + + + long t = 0; + NativeObject() = 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 new file mode 100644 index 000000000..f8b91103c --- /dev/null +++ b/src/api/java/com/Microsoft/Z3/UninterpretedSort.java @@ -0,0 +1,27 @@ +/** + * This file was automatically generated from UninterpretedSort.cs + **/ + +package com.Microsoft.Z3; + +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + +/* 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.java b/src/api/java/com/Microsoft/Z3/Version.java index 8038f02d5..ecf451e2f 100644 --- a/src/api/java/com/Microsoft/Z3/Version.java +++ b/src/api/java/com/Microsoft/Z3/Version.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -63,6 +67,6 @@ package com.Microsoft.Z3; long major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); - return major.toString() + "." + minor.toString() + "." + build.toString() + "." + revision.toString(); + return major.ToString() + "." + minor.ToString() + "." + build.ToString() + "." + revision.ToString(); } } diff --git a/src/api/java/com/Microsoft/Z3/Z3Exception.java b/src/api/java/com/Microsoft/Z3/Z3Exception.java index 0e05add87..0bca047ab 100644 --- a/src/api/java/com/Microsoft/Z3/Z3Exception.java +++ b/src/api/java/com/Microsoft/Z3/Z3Exception.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -14,15 +18,15 @@ package com.Microsoft.Z3; /** * Constructor. **/ - public Z3Exception() { super(); } +public Z3Exception() { super(); { }} /** * Constructor. **/ - public Z3Exception(String message) { super(message); } +public Z3Exception(String message) { super(message); { }} /** * Constructor. **/ - public Z3Exception(String message, System.Exception inner) { super(message, inner); } +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 index ca4258980..6a8392a86 100644 --- a/src/api/java/com/Microsoft/Z3/Z3Object.java +++ b/src/api/java/com/Microsoft/Z3/Z3Object.java @@ -4,6 +4,10 @@ package com.Microsoft.Z3; +import java.math.BigInteger; +import java.util.*; +import java.lang.Exception; + /* using System; */ /** @@ -25,21 +29,21 @@ package com.Microsoft.Z3; **/ public void Dispose() { - if (m_n_obj != IntPtr.Zero) + if (m_n_obj != 0) { DecRef(m_n_obj); - m_n_obj = IntPtr.Zero; + m_n_obj = 0; } if (m_ctx != null) { m_ctx.refCount--; if (m_ctx.refCount == 0) - GC.ReRegisterForFinalize(m_ctx); + m_ctx = null; } - GC.SuppressFinalize(this); + } @@ -50,7 +54,7 @@ package com.Microsoft.Z3; private Context m_ctx = null; - private IntPtr m_n_obj = IntPtr.Zero; + private long m_n_obj = 0; Z3Object(Context ctx) { @@ -60,7 +64,7 @@ package com.Microsoft.Z3; m_ctx = ctx; } - Z3Object(Context ctx, IntPtr obj) + Z3Object(Context ctx, long obj) { @@ -70,46 +74,40 @@ package com.Microsoft.Z3; m_n_obj = obj; } - void IncRef(IntPtr o) { } - void DecRef(IntPtr o) { } + void IncRef(long o) { } + void DecRef(long o) { } - void CheckNativeObject(IntPtr obj) { } + void CheckNativeObject(long obj) { } - IntPtr NativeObject - { - get { return m_n_obj; } - set + long NativeObject() { return m_n_obj; } + void setNativeObject(long value) { - if (value != IntPtr.Zero) { CheckNativeObject(value); IncRef(value); } - if (m_n_obj != IntPtr.Zero) { DecRef(m_n_obj); } + 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(); } - static IntPtr GetNativeObject(Z3Object s) - { - if (s == null) return new IntPtr(); - return s.NativeObject; - } - - Context Context - { - get + Context Context() { return m_ctx; } - } - static IntPtr[] ArrayToNative(Z3Object[] a) + static long[] ArrayToNative(Z3Object[] a) { if (a == null) return null; - IntPtr[] an = new IntPtr[a.Length]; - for (long i = 0; i < a.Length; i++) - if (a[i] != null) an[i] = a[i].NativeObject; + long[] an = new long[a.Length]; + for (long i; i < a.Length; i++) + if (a[i] != null) an[i] = a[i].NativeObject(); return an; } diff --git a/src/api/java/mk_java.py b/src/api/java/mk_java.py index a2cc51274..81b4a08b6 100644 --- a/src/api/java/mk_java.py +++ b/src/api/java/mk_java.py @@ -29,9 +29,17 @@ def subst_getters(s, getters): s = s.replace(g, g + "()") def type_replace(s): - s = s.replace("bool", "boolean") + s = s.replace(" bool", " boolean") + s = s.replace("(bool", "(boolean") s = s.replace("uint", "long") + s = s.replace("ulong", "long") s = s.replace("string", "String") + s = s.replace("IntPtr", "long") + s = s.replace("Dictionary<", "Map<") + s = s.replace("UInt64", "long") + s = s.replace("Int64", "long") + s = s.replace("List", "List") + s = s.replace("System.Exception", "Exception") return s def rename_native(s): @@ -47,6 +55,13 @@ def rename_native(s): s = c0 + c1 + c2 return s +def replace_generals(a): + a = re.sub(" NativeObject", " NativeObject()", a) + a = re.sub(".NativeObject;", ".NativeObject();", a) + a = re.sub("Context.nCtx", "Context().nCtx()", a) + a = re.sub("ctx.nCtx", "ctx.nCtx()", a) + a = re.sub("ASTKind", "ASTKind()", a) + return a def translate(filename): tgtfn = OUTDIR + filename.replace(EXT, ".java") @@ -65,6 +80,8 @@ def translate(filename): in_bracket_op = 0 in_getter_get = 0 in_getter_set = 0 + had_ulong_res = 0 + in_enum = 0 for line in fileinput.input(os.path.join(CS, filename)): s = string.rstrip(string.lstrip(line)) if in_javadoc: @@ -98,8 +115,10 @@ def translate(filename): in_header = 0 tgt.write(" * This file was automatically generated from " + filename + " \n") tgt.write(" **/\n") - tgt.write("\npackage com.Microsoft.Z3;\n") - + tgt.write("\npackage com.Microsoft.Z3;\n\n") + tgt.write("import java.math.BigInteger;\n") + tgt.write("import java.util.*;\n") + tgt.write("import java.lang.Exception;\n") elif in_header == 1: # tgt.write(" * " + line.replace(filename, tgtfn)) pass @@ -113,10 +132,20 @@ def translate(filename): for i in range(0, line.find(s)+1): t += " " tgt.write(t + "/* Overloaded operators are not translated. */\n") - in_unsupported = 1; + in_unsupported = 1 + elif s.startswith("public enum"): + tgt.write(line) + in_enum = 1 + elif in_enum == 1: + if s == "}": + tgt.write(line) + in_enum = 0 + else: + tgt.write(re.sub("(?P.*)\W*=\W*(?P[^\n,])", "\g (\g)", line)) elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"): a = line.replace(":", "extends").replace("internal ", "") a = a.replace(", IComparable", "") + a = type_replace(a) tgt.write(a) in_class = 1 in_static_class = 0 @@ -129,10 +158,13 @@ def translate(filename): in_javadoc = 1 elif skip_brace and s == "{": skip_brace = 0 - elif s.find("public") != -1 and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1: + elif ((s.find("public") != -1 or s.find("protected") != -1) and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1) or s.startswith("internal virtual IntPtr NativeObject") or s.startswith("internal Context Context"): if (s.startswith("new")): s = s[3:] + s = s.replace("internal virtual", "") + s = s.replace("internal", "") tokens = s.split(" ") + print "TOKENS: " + str(len(tokens)) if len(tokens) == 3: in_getter = tokens[2] in_getter_type = type_replace((tokens[0] + " " + tokens[1])) @@ -140,6 +172,7 @@ def translate(filename): in_getter_type = in_getter_type.replace("static", "") lastindent = line.find(s) skip_brace = 1 + getters.append(in_getter) elif len(tokens) == 4: if tokens[2].startswith("this["): in_bracket_op = 1 @@ -152,21 +185,35 @@ def translate(filename): if in_static_class: in_getter_type = in_getter_type.replace("static", "") lastindent = line.find(s) - skip_brace = 1 + skip_brace = 1 + getters.append(in_getter) else: in_getter = tokens[2] in_getter_type = type_replace(tokens[0] + " " + tokens[1]) - if in_static_class: - in_getter_type = in_getter_type.replace("static", "") - rest = s[s.find("get ") + 4:-1] - subst_getters(rest, getters) - rest = type_replace(rest) - rest = rename_native(rest) - t = "" - for i in range(0, lastindent): - t += " " - tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n") - getters.append(in_getter) + if tokens[2].startswith("this["): + lastindent = line.find(s) + t = "" + for i in range(0, lastindent): t += " " + tgt.write(t + "/* operator this[] not translated */\n ") + in_unsupported = 1 + else: + if in_static_class: + in_getter_type = in_getter_type.replace("static", "") + rest = s[s.find("get ") + 4:-1] + subst_getters(rest, getters) + rest = type_replace(rest) + rest = rename_native(rest) + rest = replace_generals(rest) + t = "" + for i in range(0, lastindent): + t += " " + tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n") + if rest.find("}") == -1: + in_getter_get = 1 + else: + getters.append(in_getter) + in_getter = "" + in_getter_type = "" print "ACC: " + s + " --> " + in_getter elif s.find("{ get {") != -1: line = type_replace(line) @@ -177,6 +224,7 @@ def translate(filename): rest = re.sub("Contract.\w+\([\s\S]*\);", "", rest) subst_getters(rest, getters) rest = rename_native(rest) + rest = replace_generals(rest) if in_bracket_op: tgt.write(d + rest) else: @@ -185,12 +233,13 @@ def translate(filename): elif in_getter != "" and s.startswith("get"): t = "" for i in range(0, lastindent): - t += " " + t += " " if len(s) > 3: rest = s[3:] else: rest = "" subst_getters(rest, getters) rest = type_replace(rest) rest = rename_native(rest) + rest = replace_generals(rest) if in_bracket_op: tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n") else: @@ -207,6 +256,7 @@ def translate(filename): rest = rest.replace("(Integer)value", "Integer(value)") rest = type_replace(rest) rest = rename_native(rest) + rest = replace_generals(rest) ac_acc = in_getter_type[:in_getter_type.find(' ')] ac_type = in_getter_type[in_getter_type.find(' ')+1:] if in_bracket_op: @@ -216,13 +266,13 @@ def translate(filename): tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n") if rest.find("}") == -1: in_getter_set = 1 - elif in_getter != "" and in_getter_get and s == "}": + elif in_getter != "" and in_getter_get == 1 and s == "}": tgt.write(line) in_getter_get = 0 - elif in_getter != "" and in_getter_set and s == "}": + elif in_getter != "" and in_getter_set == 1 and s == "}": tgt.write(line) in_getter_set = 0 - elif in_getter != "" and not in_getter_get and not in_getter_set and s == "}": + elif in_getter != "" and in_getter_get == 0 and in_getter_set == 0 and s == "}": in_getter = "" in_getter_type == "" in_bracket_op = 0 @@ -232,19 +282,26 @@ def translate(filename): line = re.sub("(?P\w+)(?P[,;])", "\g\g", line) tgt.write(line); elif (not in_class and (s.startswith("{") or s.startswith("}"))) or s.startswith("[") or s.startswith("#"): - # print "Skipping: " + s; + # tgt.write("// Skipping: " + s) pass elif line == "}\n": pass else: # indent = line.find(s) + # tgt.write("// LINE: " + line) if line.find(": base") != -1: - line = re.sub(": base\((?P

[\w,.\(\) ]*)\)", "{ super(\g

);", line) - if line.find("; {") != -1: - line = line.replace("; {", ";") + line = re.sub(": base\((?P

[^\{]*)\)", "{ super(\g

);", line) + line = line[4:] + obraces = line.count("{") + cbraces = line.count("}") + mbraces = obraces - cbraces + # tgt.write("// obraces = " + str(obraces) + "\n") + if obraces == 1: + skip_brace = 1 else: - skip_brace = 1 - if s.startswith("public"): + for i in range(0, mbraces): + line = line.replace("\n", "}\n") + if s.find("(") != -1: line = re.sub(" = [\w.]+(?P[,;\)])", "\g", line) a = type_replace(line) a = re.sub("(?P[\(, ])params ", "\g", a) @@ -253,25 +310,43 @@ def translate(filename): a = rename_native(a) a = re.sub("~\w+\(\)", "protected void finalize()", a) a = re.sub("foreach\s*\((?P[\w <>,]+)\s+(?P\w+)\s+in\s+(?P\w+)\)", - "for (\g.Iterator \g = \g.iterator(); \g.hasNext(); )", a) + "for (Iterator \g = \g.iterator(); \g.hasNext(); )", a) a = a.replace("readonly ", "") a = a.replace("const ", "final ") - a = a.replace("ToString", "toString") + a = a.replace("String ToString", "String toString") a = a.replace("internal ", "") a = a.replace("new static", "static") a = a.replace("new public", "public") a = a.replace("override ", "") a = a.replace("virtual ", "") a = a.replace("o as AST", "(AST) o") + a = a.replace("o as Sort", "(Sort) o") a = a.replace("other as AST", "(AST) other") a = a.replace("o as FuncDecl", "(FuncDecl) o") + a = a.replace("IntPtr obj", "long obj") + a = a.replace("IntPtr o", "long o") + a = a.replace("new long()", "0") + a = a.replace("long.Zero", "0") + a = a.replace("object o", "Object o") + a = a.replace("object other", "Object other") a = a.replace("IntPtr res = IntPtr.Zero;", "Native.IntPtr res = new Native.IntPtr();") a = a.replace("out res", "res") + a = a.replace("GC.ReRegisterForFinalize(m_ctx);", "") + a = a.replace("GC.SuppressFinalize(this);", "") + if had_ulong_res == 0 and a.find("ulong res = 0") != -1: + a = a.replace("ulong res = 0;", "LongPtr res = new LongPtr();") + elif had_ulong_res == 1: + a = a.replace("ref res)", "res)") + if a.find("return res;") != -1: + a = a.replace("return res;", "return res.value;") + had_ulong_res = 0 a = a.replace("lock (", "synchronized (") if in_static_class: a = a.replace("static", "") a = re.sub("ref (?P\w+)", "\g", a) subst_getters(a, getters) + a = re.sub("NativeObject = (?P.*);", "setNativeObject(\g);", a) + a = replace_generals(a) tgt.write(a) tgt.close() From 93ad91d2f97f8c2077cb1fb2b2cfa15b5a57b005 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 25 Nov 2012 12:08:49 -0800 Subject: [PATCH 02/17] preparing handling of arrays/quantifiers, fix cover-related bugs reported by Arie Signed-off-by: Nikolaj Bjorner --- src/ast/array_decl_plugin.h | 14 + src/ast/dl_decl_plugin.cpp | 3 +- src/ast/dl_decl_plugin.h | 2 - src/model/model_evaluator.cpp | 2 +- src/muz_qe/dl_context.cpp | 2 + src/muz_qe/dl_mk_array_blast.cpp | 139 +++ src/muz_qe/dl_mk_array_blast.h | 61 + src/muz_qe/dl_mk_extract_quantifiers.cpp | 28 +- src/muz_qe/dl_util.h | 6 + src/muz_qe/equiv_proof_converter.h | 58 + src/muz_qe/pdr_context.cpp | 14 +- src/muz_qe/pdr_context.h | 1 + src/muz_qe/pdr_dl_interface.cpp | 18 +- src/muz_qe/pdr_quantifiers.cpp | 94 +- src/muz_qe/pdr_util.cpp | 1381 ++++++++++++---------- src/muz_qe/pdr_util.h | 16 +- 16 files changed, 1134 insertions(+), 705 deletions(-) create mode 100644 src/muz_qe/dl_mk_array_blast.cpp create mode 100644 src/muz_qe/dl_mk_array_blast.h create mode 100644 src/muz_qe/equiv_proof_converter.h diff --git a/src/ast/array_decl_plugin.h b/src/ast/array_decl_plugin.h index bd1e123e3..68c473560 100644 --- a/src/ast/array_decl_plugin.h +++ b/src/ast/array_decl_plugin.h @@ -144,7 +144,21 @@ public: bool is_map(expr* n) const { return is_app_of(n, m_fid, OP_ARRAY_MAP); } bool is_as_array(expr * n) const { return is_app_of(n, m_fid, OP_AS_ARRAY); } bool is_as_array_tree(expr * n); + bool is_select(func_decl* f) const { return is_decl_of(f, m_fid, OP_SELECT); } + bool is_store(func_decl* f) const { return is_decl_of(f, m_fid, OP_STORE); } + bool is_const(func_decl* f) const { return is_decl_of(f, m_fid, OP_CONST_ARRAY); } + bool is_map(func_decl* f) const { return is_decl_of(f, m_fid, OP_ARRAY_MAP); } + bool is_as_array(func_decl* f) const { return is_decl_of(f, m_fid, OP_AS_ARRAY); } func_decl * get_as_array_func_decl(app * n) const { SASSERT(is_as_array(n)); return to_func_decl(n->get_decl()->get_parameter(0).get_ast()); } + + app * mk_store(unsigned num_args, expr * const * args) { + return m_manager.mk_app(m_fid, OP_STORE, 0, 0, num_args, args); + } + + app * mk_select(unsigned num_args, expr * const * args) { + return m_manager.mk_app(m_fid, OP_SELECT, 0, 0, num_args, args); + } + app * mk_map(func_decl * f, unsigned num_args, expr * const * args) { parameter p(f); return m_manager.mk_app(m_fid, OP_ARRAY_MAP, 1, &p, num_args, args); diff --git a/src/ast/dl_decl_plugin.cpp b/src/ast/dl_decl_plugin.cpp index 76f34f316..5b73f944a 100644 --- a/src/ast/dl_decl_plugin.cpp +++ b/src/ast/dl_decl_plugin.cpp @@ -44,8 +44,7 @@ namespace datalog { m_num_sym("N"), m_lt_sym("<"), m_le_sym("<="), - m_rule_sym("R"), - m_hyper_resolve_sym("hyper-res") + m_rule_sym("R") { } diff --git a/src/ast/dl_decl_plugin.h b/src/ast/dl_decl_plugin.h index 6e824b639..32e3c6da9 100644 --- a/src/ast/dl_decl_plugin.h +++ b/src/ast/dl_decl_plugin.h @@ -69,7 +69,6 @@ namespace datalog { symbol m_lt_sym; symbol m_le_sym; symbol m_rule_sym; - symbol m_hyper_resolve_sym; bool check_bounds(char const* msg, unsigned low, unsigned up, unsigned val) const; bool check_domain(unsigned low, unsigned up, unsigned val) const; @@ -93,7 +92,6 @@ namespace datalog { func_decl * mk_compare(decl_kind k, symbol const& sym, sort*const* domain); func_decl * mk_clone(sort* r); func_decl * mk_rule(unsigned arity); - func_decl * mk_hyper_res(unsigned num_params, parameter const* params, unsigned arity, sort *const* domain); sort * mk_finite_sort(unsigned num_params, parameter const* params); sort * mk_relation_sort(unsigned num_params, parameter const* params); diff --git a/src/model/model_evaluator.cpp b/src/model/model_evaluator.cpp index bccade304..258590121 100644 --- a/src/model/model_evaluator.cpp +++ b/src/model/model_evaluator.cpp @@ -147,7 +147,7 @@ struct evaluator_cfg : public default_rewriter_cfg { return m_a_rw.mk_app_core(f, num, args, result); if (fid == m_bv_rw.get_fid()) return m_bv_rw.mk_app_core(f, num, args, result); - if (fid == m_ar_rw.get_fid()) + if (fid == m_ar_rw.get_fid()) return m_ar_rw.mk_app_core(f, num, args, result); if (fid == m_dt_rw.get_fid()) return m_dt_rw.mk_app_core(f, num, args, result); diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 91e396671..12c12c75a 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -54,6 +54,7 @@ Revision History: #include"expr_functors.h" #include"dl_mk_partial_equiv.h" #include"dl_mk_bit_blast.h" +#include"dl_mk_array_blast.h" #include"datatype_decl_plugin.h" #include"expr_abstract.h" @@ -944,6 +945,7 @@ namespace datalog { transf.register_plugin(alloc(datalog::mk_subsumption_checker, *this, 34880)); transf.register_plugin(alloc(datalog::mk_bit_blast, *this, 35000)); + transf.register_plugin(alloc(datalog::mk_array_blast, *this, 36000)); transform_rules(transf, mc, pc); } diff --git a/src/muz_qe/dl_mk_array_blast.cpp b/src/muz_qe/dl_mk_array_blast.cpp new file mode 100644 index 000000000..39223264c --- /dev/null +++ b/src/muz_qe/dl_mk_array_blast.cpp @@ -0,0 +1,139 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + dl_mk_array_blast.cpp + +Abstract: + + Remove array variables from rules. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-23 + +Revision History: + +--*/ + +#include "dl_mk_array_blast.h" +#include "expr_replacer.h" + +namespace datalog { + + + mk_array_blast::mk_array_blast(context & ctx, unsigned priority) : + rule_transformer::plugin(priority, false), + m_ctx(ctx), + m(ctx.get_manager()), + a(m), + rm(ctx.get_rule_manager()), + m_rewriter(m, m_params){ + m_params.set_bool(":expand-select-store",true); + m_rewriter.updt_params(m_params); + } + + mk_array_blast::~mk_array_blast() { + } + + bool mk_array_blast::is_store_def(expr* e, expr*& x, expr*& y) { + if (m.is_iff(e, x, y) || m.is_eq(e, x, y)) { + if (!a.is_store(y)) { + std::swap(x,y); + } + if (is_var(x) && a.is_store(y)) { + return true; + } + } + return false; + } + + bool mk_array_blast::blast(rule& r, rule_set& rules) { + unsigned utsz = r.get_uninterpreted_tail_size(); + unsigned tsz = r.get_tail_size(); + expr_ref_vector conjs(m), new_conjs(m); + for (unsigned i = 0; i < utsz; ++i) { + new_conjs.push_back(r.get_tail(i)); + } + for (unsigned i = utsz; i < tsz; ++i) { + conjs.push_back(r.get_tail(i)); + } + flatten_and(conjs); + expr_substitution sub(m); + uint_set lhs_vars, rhs_vars; + for (unsigned i = 0; i < conjs.size(); ++i) { + expr* x, *y; + if (is_store_def(conjs[i].get(), x, y)) { + // enforce topological order consistency: + uint_set lhs; + collect_vars(m, x, lhs_vars); + collect_vars(m, y, rhs_vars); + lhs = lhs_vars; + lhs &= rhs_vars; + if (!lhs.empty()) { + new_conjs.push_back(conjs[i].get()); + } + else { + sub.insert(x, y); + } + } + else { + new_conjs.push_back(conjs[i].get()); + } + } + if (sub.empty()) { + rules.add_rule(&r); + return false; + } + + rule_ref_vector new_rules(rm); + expr_ref fml1(m), fml2(m), body(m), head(m); + r.to_formula(fml1); + body = m.mk_and(new_conjs.size(), new_conjs.c_ptr()); + head = r.get_head(); + scoped_ptr replace = mk_default_expr_replacer(m); + replace->set_substitution(&sub); + (*replace)(body); + m_rewriter(body); + (*replace)(head); + m_rewriter(head); + fml2 = m.mk_implies(body, head); + rm.mk_rule(fml2, new_rules, r.name()); + SASSERT(new_rules.size() == 1); + + rules.add_rule(new_rules[0].get()); + if (m_pc) { + new_rules[0]->to_formula(fml2); + m_pc->insert(fml1, fml2); + } + return true; + } + + rule_set * mk_array_blast::operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc) { + ref epc; + if (pc) { + epc = alloc(equiv_proof_converter, m); + } + m_pc = epc.get(); + + rule_set* rules = alloc(rule_set, m_ctx); + rule_set::iterator it = source.begin(), end = source.end(); + bool change = false; + for (; it != end; ++it) { + change = blast(**it, *rules) || change; + } + if (!change) { + dealloc(rules); + rules = 0; + } + if (pc) { + pc = concat(pc.get(), epc.get()); + } + return rules; + + } + +}; + + diff --git a/src/muz_qe/dl_mk_array_blast.h b/src/muz_qe/dl_mk_array_blast.h new file mode 100644 index 000000000..858b9c778 --- /dev/null +++ b/src/muz_qe/dl_mk_array_blast.h @@ -0,0 +1,61 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + dl_mk_array_blast.h + +Abstract: + + Remove array variables from rules. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-23 + +Revision History: + +--*/ +#ifndef _DL_MK_ARRAY_BLAST_H_ +#define _DL_MK_ARRAY_BLAST_H_ + +#include"dl_context.h" +#include"dl_rule_set.h" +#include"dl_rule_transformer.h" +#include "equiv_proof_converter.h" +#include "array_decl_plugin.h" + +namespace datalog { + + /** + \brief Blast occurrences of arrays in rules + */ + class mk_array_blast : public rule_transformer::plugin { + context& m_ctx; + ast_manager& m; + array_util a; + rule_manager& rm; + params_ref m_params; + th_rewriter m_rewriter; + equiv_proof_converter* m_pc; + + bool blast(rule& r, rule_set& new_rules); + + bool is_store_def(expr* e, expr*& x, expr*& y); + + public: + /** + \brief Create rule transformer that extracts universal quantifiers (over recursive predicates). + */ + mk_array_blast(context & ctx, unsigned priority); + + virtual ~mk_array_blast(); + + rule_set * operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc); + + }; + +}; + +#endif /* _DL_MK_ARRAY_BLAST_H_ */ + diff --git a/src/muz_qe/dl_mk_extract_quantifiers.cpp b/src/muz_qe/dl_mk_extract_quantifiers.cpp index 614e9dbc8..f6755bb4f 100644 --- a/src/muz_qe/dl_mk_extract_quantifiers.cpp +++ b/src/muz_qe/dl_mk_extract_quantifiers.cpp @@ -40,29 +40,32 @@ namespace datalog { void mk_extract_quantifiers::extract(rule& r, rule_set& new_rules) { - app_ref_vector tail(m); - svector neg_tail; + expr_ref_vector tail(m); quantifier_ref_vector quantifiers(m); unsigned utsz = r.get_uninterpreted_tail_size(); unsigned tsz = r.get_tail_size(); for (unsigned i = 0; i < utsz; ++i) { tail.push_back(r.get_tail(i)); - neg_tail.push_back(r.is_neg_tail(i)); + if (r.is_neg_tail(i)) { + new_rules.add_rule(&r); + return; + } } for (unsigned i = utsz; i < tsz; ++i) { - SASSERT(!r.is_neg_tail(i)); app* t = r.get_tail(i); expr_ref_vector conjs(m); datalog::flatten_and(t, conjs); + quantifier_ref qe(m); + quantifier* q = 0; for (unsigned j = 0; j < conjs.size(); ++j) { expr* e = conjs[j].get(); - quantifier* q = 0; if (rule_manager::is_forall(m, e, q)) { quantifiers.push_back(q); + qe = m.mk_exists(q->get_num_decls(), q->get_decl_sorts(), q->get_decl_names(), q->get_expr()); + tail.push_back(qe); } else { - tail.push_back(is_app(e)?to_app(e):m.mk_eq(e, m.mk_true())); - neg_tail.push_back(false); + tail.push_back(e); } } } @@ -70,11 +73,16 @@ namespace datalog { new_rules.add_rule(&r); } else { - rule* new_rule = rm.mk(r.get_head(), tail.size(), tail.c_ptr(), neg_tail.c_ptr(), r.name(), false); - new_rules.add_rule(new_rule); + expr_ref fml(m); + rule_ref_vector rules(rm); + fml = m.mk_implies(m.mk_and(tail.size(), tail.c_ptr()), r.get_head()); + rm.mk_rule(fml, rules, r.name()); quantifier_ref_vector* qs = alloc(quantifier_ref_vector, quantifiers); - m_quantifiers.insert(new_rule, qs); m_refs.push_back(qs); + for (unsigned i = 0; i < rules.size(); ++i) { + m_quantifiers.insert(rules[i].get(), qs); + new_rules.add_rule(rules[i].get()); + } } } diff --git a/src/muz_qe/dl_util.h b/src/muz_qe/dl_util.h index 1685bec9c..f314b691d 100644 --- a/src/muz_qe/dl_util.h +++ b/src/muz_qe/dl_util.h @@ -196,6 +196,12 @@ namespace datalog { scoped_no_proof(ast_manager& m): scoped_proof_mode(m, PGM_DISABLED) {} }; + class scoped_restore_proof : public scoped_proof_mode { + public: + scoped_restore_proof(ast_manager& m): scoped_proof_mode(m, m.proof_mode()) {} + }; + + class variable_intersection diff --git a/src/muz_qe/equiv_proof_converter.h b/src/muz_qe/equiv_proof_converter.h new file mode 100644 index 000000000..94d6f4e04 --- /dev/null +++ b/src/muz_qe/equiv_proof_converter.h @@ -0,0 +1,58 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + equiv_proof_converter.h + +Abstract: + + Proof converter that applies equivalence rule to leaves. + + Given a proof P with occurrences of [asserted fml] + replace [asserted fml] by a proof of the form + [mp [asserted fml'] [~ fml fml']] + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-23 + +Revision History: + +--*/ + +#ifndef _EQUIV_PROOF_CONVERTER_H_ +#define _EQUIV_PROOF_CONVERTER_H_ + +#include "replace_proof_converter.h" + +class equiv_proof_converter : public proof_converter { + ast_manager& m; + replace_proof_converter m_replace; +public: + + equiv_proof_converter(ast_manager& m): m(m), m_replace(m) {} + + virtual ~equiv_proof_converter() {} + + virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + m_replace(m, num_source, source, result); + } + + virtual proof_converter * translate(ast_translation & translator) { + return m_replace.translate(translator); + } + + void insert(expr* fml1, expr* fml2) { + proof_ref p1(m), p2(m), p3(m); + p1 = m.mk_asserted(fml1); + p2 = m.mk_rewrite(fml1, fml2); + p3 = m.mk_modus_ponens(p1, p2); + m_replace.insert(p3); + } + + ast_manager& get_manager() { return m; } + +}; + +#endif diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index f056342a2..909a42625 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -35,7 +35,6 @@ Notes: #include "pdr_generalizers.h" #include "datatype_decl_plugin.h" #include "for_each_expr.h" -#include "model_v2_pp.h" #include "dl_rule_set.h" #include "unit_subsumption_tactic.h" #include "model_smt2_pp.h" @@ -146,7 +145,6 @@ namespace pdr { expr_ref vl(m); for (; it != end; ++it) { expr* pred = it->m_key; - TRACE("pdr", tout << mk_pp(pred, m) << "\n";); if (model.eval(to_app(pred)->get_decl(), vl) && m.is_true(vl)) { return *it->m_value; } @@ -362,7 +360,7 @@ namespace pdr { } // replace local constants by bound variables. expr_substitution sub(m); - for (unsigned i = 0; i < m_sig.size(); ++i) { + for (unsigned i = 0; i < sig_size(); ++i) { c = m.mk_const(pm.o2n(sig(i), 0)); v = m.mk_var(i, sig(i)->get_range()); sub.insert(c, v); @@ -397,7 +395,7 @@ namespace pdr { // replace bound variables by local constants. expr_ref result(property, m), v(m), c(m); expr_substitution sub(m); - for (unsigned i = 0; i < m_sig.size(); ++i) { + for (unsigned i = 0; i < sig_size(); ++i) { c = m.mk_const(pm.o2n(sig(i), 0)); v = m.mk_var(i, sig(i)->get_range()); sub.insert(v, c); @@ -602,6 +600,12 @@ namespace pdr { } m_rule2inst.insert(&rule,&var_reprs); m_rule2vars.insert(&rule, aux_vars); + TRACE("pdr", + tout << rule.get_decl()->get_name() << "\n"; + for (unsigned i = 0; i < var_reprs.size(); ++i) { + tout << mk_pp(var_reprs[i].get(), m) << " "; + } + tout << "\n";); } bool pred_transformer::check_filled(app_ref_vector const& v) const { @@ -723,7 +727,7 @@ namespace pdr { pred_transformer& p = pt(); ast_manager& m = p.get_manager(); manager& pm = p.get_pdr_manager(); - TRACE("pdr", model_v2_pp(tout, get_model());); + TRACE("pdr", model_smt2_pp(tout, m, get_model(), 0);); func_decl* f = p.head(); unsigned arity = f->get_arity(); expr_ref_vector args(m); diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index 4b578a188..c7f53752a 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -116,6 +116,7 @@ namespace pdr { ptr_vector const& rules() const { return m_rules; } func_decl* sig(unsigned i) { init_sig(); return m_sig[i].get(); } // signature func_decl* const* sig() { init_sig(); return m_sig.c_ptr(); } + unsigned sig_size() { init_sig(); return m_sig.size(); } expr* transition() const { return m_transition; } expr* initial_state() const { return m_initial_state; } expr* rule2tag(datalog::rule const* r) { return m_rule2tag.find(r); } diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index be31f4724..b047aaae0 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -58,18 +58,18 @@ dl_interface::~dl_interface() { // void dl_interface::check_reset() { datalog::rule_ref_vector const& new_rules = m_ctx.get_rules().get_rules(); - datalog::rule_ref_vector const& old_rules = m_old_rules.get_rules(); - for (unsigned i = 0; i < new_rules.size(); ++i) { - bool found = false; - for (unsigned j = 0; !found && j < old_rules.size(); ++j) { + datalog::rule_ref_vector const& old_rules = m_old_rules.get_rules(); + bool is_subsumed = !old_rules.empty(); + for (unsigned i = 0; is_subsumed && i < new_rules.size(); ++i) { + is_subsumed = false; + for (unsigned j = 0; !is_subsumed && j < old_rules.size(); ++j) { if (m_ctx.check_subsumes(*old_rules[j], *new_rules[i])) { - found = true; + is_subsumed = true; } } - if (!found) { - CTRACE("pdr", (old_rules.size() > 0), new_rules[i]->display(m_ctx, tout << "Fresh rule ");); + if (!is_subsumed) { + TRACE("pdr", new_rules[i]->display(m_ctx, tout << "Fresh rule ");); m_context->reset(); - break; } } m_old_rules.reset(); @@ -160,6 +160,8 @@ lbool dl_interface::query(expr * query) { m_ctx.replace_rules(old_rules); quantifier_model_checker quantifier_mc(*m_context, m, extract_quantifiers->quantifiers(), m_pdr_rules); + + datalog::scoped_restore_proof _sc(m); // update_rules may overwrite the proof mode. m_context->set_proof_converter(pc); m_context->set_model_converter(mc); diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index d52a0bf07..8b5f6fa1e 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -24,6 +24,7 @@ Revision History: #include "qe.h" #include "var_subst.h" #include "dl_rule_set.h" +#include "model_smt2_pp.h" namespace pdr { @@ -181,25 +182,21 @@ namespace pdr { bool found_instance = false; TRACE("pdr", tout << mk_pp(m_A,m) << "\n";); - ast_manager mp(PGM_COARSE); - ast_translation tr(m, mp); - ast_translation rev_tr(mp, m); - expr_ref_vector fmls(mp); + datalog::scoped_coarse_proof _scp(m); + + expr_ref_vector fmls(m); front_end_params fparams; fparams.m_proof_mode = PGM_COARSE; // TBD: does not work on integers: fparams.m_mbqi = true; - expr_ref C(m); - fmls.push_back(tr(m_A.get())); - for (unsigned i = 0; i < m_Bs.size(); ++i) { - C = m.update_quantifier(qs[i], m_Bs[i].get()); - fmls.push_back(tr(C.get())); - } + + fmls.push_back(m_A.get()); + fmls.append(m_Bs); TRACE("pdr", tout << "assert\n"; for (unsigned i = 0; i < fmls.size(); ++i) { - tout << mk_pp(fmls[i].get(), mp) << "\n"; + tout << mk_pp(fmls[i].get(), m) << "\n"; }); - smt::kernel solver(mp, fparams); + smt::kernel solver(m, fparams); for (unsigned i = 0; i < fmls.size(); ++i) { solver.assert_expr(fmls[i].get()); } @@ -216,8 +213,8 @@ namespace pdr { } proof* p = solver.get_proof(); - TRACE("pdr", tout << mk_ismt2_pp(p, mp) << "\n";); - collect_insts collector(mp); + TRACE("pdr", tout << mk_ismt2_pp(p, m) << "\n";); + collect_insts collector(m); for_each_expr(collector, p); ptr_vector const& quants = collector.quantifiers(); @@ -225,20 +222,20 @@ namespace pdr { symbol qid = quants[i]->get_qid(); if (!qid_map.find(qid, q)) { TRACE("pdr", tout << "Could not find quantifier " - << mk_pp(quants[i], mp) << "\n";); + << mk_pp(quants[i], m) << "\n";); continue; } expr_ref_vector const& binding = collector.bindings()[i]; - TRACE("pdr", tout << "Instantiating:\n" << mk_pp(quants[i], mp) << "\n"; + TRACE("pdr", tout << "Instantiating:\n" << mk_pp(quants[i], m) << "\n"; for (unsigned j = 0; j < binding.size(); ++j) { - tout << mk_pp(binding[j], mp) << " "; + tout << mk_pp(binding[j], m) << " "; } tout << "\n";); expr_ref_vector new_binding(m); for (unsigned j = 0; j < binding.size(); ++j) { - new_binding.push_back(rev_tr(binding[j])); + new_binding.push_back(binding[j]); } add_binding(q, new_binding); found_instance = true; @@ -258,11 +255,32 @@ namespace pdr { return found_instance; } + /** + Given node: + + - pt - predicate transformer for rule: + P(x) :- Body1(x,y) || Body2(x,z) & (Fa u . Q(u,x,z)). + - rule - P(x) :- Body2(x,z) + + - qis - Fa u . Q(u,x,z) + + - A := node.state(x) && Body2(x,y) + + - Bs := array of Bs of the form: + . Fa u . Q(u, P_x, P_y) - instantiate quantifier to P variables. + . B := inv(Q_0,Q_1,Q_2) + . B := inv(u, P_x, P_y) := B[u/Q_0, P_x/Q_1, P_y/Q_2] + . B := Fa u . inv(u, P_x, P_y) + + + */ + + void quantifier_model_checker::model_check_node(model_node& node) { TRACE("pdr", node.display(tout, 0);); pred_transformer& pt = node.pt(); manager& pm = pt.get_pdr_manager(); - expr_ref A(m), B(m), C(m); + expr_ref A(m), B(m), C(m), v(m); expr_ref_vector As(m); m_Bs.reset(); // @@ -285,8 +303,12 @@ namespace pdr { return; } unsigned level = node.level(); - unsigned previous_level = (level == 0)?0:(level-1); + if (level == 0) { + return; + } + unsigned previous_level = level - 1; + As.push_back(pt.get_propagation_formula(m_ctx.get_pred_transformers(), level)); As.push_back(node.state()); As.push_back(pt.rule2tag(m_current_rule)); @@ -296,28 +318,42 @@ namespace pdr { { datalog::scoped_no_proof _no_proof(m); + quantifier_ref q(m); scoped_ptr rep = mk_default_expr_replacer(m); for (unsigned j = 0; j < qis->size(); ++j) { - quantifier* q = (*qis)[j].get(); + q = (*qis)[j].get(); + app_ref_vector& inst = pt.get_inst(m_current_rule); + ptr_vector& aux_vars = pt.get_aux_vars(*m_current_rule); + TRACE("pdr", + tout << "q:\n" << mk_pp(q, m) << "\n"; + tout << "level: " << level << "\n"; + model_smt2_pp(tout, m, node.get_model(), 0); + m_current_rule->display(m_ctx.get_context(), tout << "rule:\n"); + + ); + + var_subst vs(m, false); + vs(q, inst.size(), (expr*const*)inst.c_ptr(), B); + q = to_quantifier(B); + TRACE("pdr", tout << "q instantiated:\n" << mk_pp(q, m) << "\n";); + app* a = to_app(q->get_expr()); func_decl* f = a->get_decl(); pred_transformer& pt2 = m_ctx.get_pred_transformer(f); B = pt2.get_formulas(previous_level, true); + TRACE("pdr", tout << "B:\n" << mk_pp(B, m) << "\n";); + expr_substitution sub(m); - expr_ref_vector refs(m); for (unsigned i = 0; i < a->get_num_args(); ++i) { - expr* v = m.mk_const(pm.o2n(pt2.sig(i),0)); + v = m.mk_const(pm.o2n(pt2.sig(i),0)); sub.insert(v, a->get_arg(i)); - refs.push_back(v); } rep->set_substitution(&sub); (*rep)(B); - app_ref_vector& inst = pt.get_inst(m_current_rule); - ptr_vector& aux_vars = pt.get_aux_vars(*m_current_rule); - pt.ground_free_vars(B, inst, aux_vars); - var_subst vs(m, false); - vs(B, inst.size(), (expr*const*)inst.c_ptr(), B); + TRACE("pdr", tout << "B substituted:\n" << mk_pp(B, m) << "\n";); + + B = m.update_quantifier(q, B); m_Bs.push_back(B); } } diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 512d94956..0840f1d73 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -86,559 +86,599 @@ namespace pdr { return res.str(); } + ///////////////////////// + // select elimination rewriter + // -///////////////////////// -// model_evaluator -// + class select_elim { + ast_manager& m; + array_util a; + model_ref m_model; + public: + select_elim(ast_manager& m, model_ref& md): m(m), a(m), m_model(md) {} + + br_status mk_app_core(func_decl* f, unsigned num_args, expr* const* args, expr_ref& result) { + if (a.is_select(f)) { + expr_ref tmp(m); + tmp = m.mk_app(f, num_args, args); + m_model->eval(tmp, result); + return BR_DONE; + } + else { + return BR_FAILED; + } + } + }; + + struct select_elim_cfg: public default_rewriter_cfg { + select_elim m_r; + bool rewrite_patterns() const { return false; } + br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) { + return m_r.mk_app_core(f, num, args, result); + } + select_elim_cfg(ast_manager & m, model_ref& md, params_ref const & p):m_r(m, md) {} + }; + + template class rewriter_tpl; + + class select_elim_star : public rewriter_tpl { + select_elim_cfg m_cfg; + public: + select_elim_star(ast_manager & m, model_ref& md, params_ref const & p = params_ref()): + rewriter_tpl(m, false, m_cfg), + m_cfg(m, md, p) {} + }; -void model_evaluator::assign_value(expr* e, expr* val) { - rational r; - if (m.is_true(val)) { - set_true(e); - } - else if (m.is_false(val)) { - set_false(e); - } - else if (m_arith.is_numeral(val, r)) { - set_number(e, r); - } - else if (m.is_value(val)) { - set_value(e, val); - } - else { - IF_VERBOSE(3, verbose_stream() << "Not evaluated " << mk_pp(e, m) << "\n";); - TRACE("pdr", tout << "Variable is not tracked: " << mk_pp(e, m) << "\n";); - set_x(e); - } -} -void model_evaluator::setup_model(model_ref& model) { - m_numbers.reset(); - m_values.reset(); - m_model = model; - rational r; - unsigned sz = model->get_num_constants(); - for (unsigned i = 0; i < sz; i++) { - func_decl * d = model->get_constant(i); - expr* val = model->get_const_interp(d); - expr* e = m.mk_const(d); - m_refs.push_back(e); - assign_value(e, val); - } -} - -void model_evaluator::reset() { - m1.reset(); - m2.reset(); - m_values.reset(); - m_visited.reset(); - m_numbers.reset(); - m_refs.reset(); - m_model = 0; -} - -expr_ref_vector model_evaluator::minimize_model(ptr_vector const & formulas, model_ref& mdl) { - setup_model(mdl); - - TRACE("pdr_verbose", - tout << "formulas:\n"; - for (unsigned i = 0; i < formulas.size(); ++i) tout << mk_pp(formulas[i], m) << "\n"; - ); - - expr_ref_vector model = prune_by_cone_of_influence(formulas); - TRACE("pdr_verbose", - tout << "pruned model:\n"; - for (unsigned i = 0; i < model.size(); ++i) tout << mk_pp(model[i].get(), m) << "\n";); - - reset(); - - DEBUG_CODE( - setup_model(mdl); - VERIFY(check_model(formulas)); - reset();); - - return model; -} - -expr_ref_vector model_evaluator::minimize_literals(ptr_vector const& formulas, model_ref& mdl) { - - TRACE("pdr", - tout << "formulas:\n"; - for (unsigned i = 0; i < formulas.size(); ++i) tout << mk_pp(formulas[i], m) << "\n"; - ); - - expr_ref_vector result(m); - ptr_vector tocollect; + ///////////////////////// + // model_evaluator + // - setup_model(mdl); - collect(formulas, tocollect); - for (unsigned i = 0; i < tocollect.size(); ++i) { - expr* e = tocollect[i]; - SASSERT(m.is_bool(e)); - SASSERT(is_true(e) || is_false(e)); - if (is_true(e)) { - result.push_back(e); + + void model_evaluator::assign_value(expr* e, expr* val) { + rational r; + if (m.is_true(val)) { + set_true(e); + } + else if (m.is_false(val)) { + set_false(e); + } + else if (m_arith.is_numeral(val, r)) { + set_number(e, r); + } + else if (m.is_value(val)) { + set_value(e, val); } else { - result.push_back(m.mk_not(e)); + IF_VERBOSE(3, verbose_stream() << "Not evaluated " << mk_pp(e, m) << "\n";); + TRACE("pdr", tout << "Variable is not tracked: " << mk_pp(e, m) << "\n";); + set_x(e); } } - reset(); - return result; -} -void model_evaluator::process_formula(app* e, ptr_vector& todo, ptr_vector& tocollect) { - SASSERT(m.is_bool(e)); - SASSERT(is_true(e) || is_false(e)); - unsigned v = is_true(e); - unsigned sz = e->get_num_args(); - expr* const* args = e->get_args(); - if (e->get_family_id() == m.get_basic_family_id()) { - switch(e->get_decl_kind()) { - case OP_TRUE: - break; - case OP_FALSE: - break; - case OP_EQ: - case OP_IFF: - if (args[0] == args[1]) { - SASSERT(v); - // no-op - } - else if (!m.is_bool(args[0])) { - tocollect.push_back(e); + void model_evaluator::setup_model(model_ref& model) { + m_numbers.reset(); + m_values.reset(); + m_model = model; + rational r; + unsigned sz = model->get_num_constants(); + for (unsigned i = 0; i < sz; i++) { + func_decl * d = model->get_constant(i); + expr* val = model->get_const_interp(d); + expr* e = m.mk_const(d); + m_refs.push_back(e); + assign_value(e, val); + } + } + + void model_evaluator::reset() { + m1.reset(); + m2.reset(); + m_values.reset(); + m_visited.reset(); + m_numbers.reset(); + m_refs.reset(); + m_model = 0; + } + + expr_ref_vector model_evaluator::minimize_model(ptr_vector const & formulas, model_ref& mdl) { + setup_model(mdl); + + TRACE("pdr_verbose", + tout << "formulas:\n"; + for (unsigned i = 0; i < formulas.size(); ++i) tout << mk_pp(formulas[i], m) << "\n"; + ); + + expr_ref_vector model = prune_by_cone_of_influence(formulas); + TRACE("pdr_verbose", + tout << "pruned model:\n"; + for (unsigned i = 0; i < model.size(); ++i) tout << mk_pp(model[i].get(), m) << "\n";); + + reset(); + + DEBUG_CODE( + setup_model(mdl); + VERIFY(check_model(formulas)); + reset();); + + return model; + } + + expr_ref_vector model_evaluator::minimize_literals(ptr_vector const& formulas, model_ref& mdl) { + + TRACE("pdr", + tout << "formulas:\n"; + for (unsigned i = 0; i < formulas.size(); ++i) tout << mk_pp(formulas[i], m) << "\n"; + ); + + expr_ref_vector result(m); + expr_ref tmp(m); + ptr_vector tocollect; + + setup_model(mdl); + collect(formulas, tocollect); + for (unsigned i = 0; i < tocollect.size(); ++i) { + expr* e = tocollect[i]; + SASSERT(m.is_bool(e)); + SASSERT(is_true(e) || is_false(e)); + if (is_true(e)) { + result.push_back(e); } else { - todo.append(sz, args); + result.push_back(m.mk_not(e)); } - break; - case OP_DISTINCT: - tocollect.push_back(e); - break; - case OP_ITE: - if (args[1] == args[2]) { - tocollect.push_back(args[1]); - } - else if (is_true(args[1]) && is_true(args[2])) { - todo.append(2, args+1); - } - else if (is_false(args[1]) && is_false(args[2])) { - todo.append(2, args+1); - } - else if (is_true(args[0])) { - todo.append(2, args); - } - else { - SASSERT(is_false(args[0])); - todo.push_back(args[0]); - todo.push_back(args[2]); - } - break; - case OP_AND: - if (v) { - todo.append(sz, args); - } - else { - unsigned i = 0; - for (; !is_false(args[i]) && i < sz; ++i); - if (i == sz) { - fatal_error(1); + } + select_elim_star select_elim(m, m_model); + for (unsigned i = 0; i < result.size(); ++i) { + select_elim(result[i].get(), tmp); + result[i] = tmp; + } + reset(); + TRACE("pdr", + tout << "minimized model:\n"; + for (unsigned i = 0; i < result.size(); ++i) tout << mk_pp(result[i].get(), m) << "\n"; + ); + + return result; + } + + void model_evaluator::process_formula(app* e, ptr_vector& todo, ptr_vector& tocollect) { + SASSERT(m.is_bool(e)); + SASSERT(is_true(e) || is_false(e)); + unsigned v = is_true(e); + unsigned sz = e->get_num_args(); + expr* const* args = e->get_args(); + if (e->get_family_id() == m.get_basic_family_id()) { + switch(e->get_decl_kind()) { + case OP_TRUE: + break; + case OP_FALSE: + break; + case OP_EQ: + case OP_IFF: + if (args[0] == args[1]) { + SASSERT(v); + // no-op } - VERIFY(i < sz); - todo.push_back(args[i]); - } - break; - case OP_OR: - if (v) { - unsigned i = 0; - for (; !is_true(args[i]) && i < sz; ++i); - if (i == sz) { - fatal_error(1); - } - VERIFY(i < sz); - todo.push_back(args[i]); - } - else { - todo.append(sz, args); - } - break; - case OP_XOR: - case OP_NOT: - todo.append(sz, args); - break; - case OP_IMPLIES: - if (v) { - if (is_true(args[1])) { - todo.push_back(args[1]); - } - else if (is_false(args[0])) { - todo.push_back(args[0]); + else if (!m.is_bool(args[0])) { + tocollect.push_back(e); } else { - IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); - UNREACHABLE(); + todo.append(sz, args); } + break; + case OP_DISTINCT: + tocollect.push_back(e); + break; + case OP_ITE: + if (args[1] == args[2]) { + tocollect.push_back(args[1]); + } + else if (is_true(args[1]) && is_true(args[2])) { + todo.append(2, args+1); + } + else if (is_false(args[1]) && is_false(args[2])) { + todo.append(2, args+1); + } + else if (is_true(args[0])) { + todo.append(2, args); + } + else { + SASSERT(is_false(args[0])); + todo.push_back(args[0]); + todo.push_back(args[2]); + } + break; + case OP_AND: + if (v) { + todo.append(sz, args); + } + else { + unsigned i = 0; + for (; !is_false(args[i]) && i < sz; ++i); + if (i == sz) { + fatal_error(1); + } + VERIFY(i < sz); + todo.push_back(args[i]); + } + break; + case OP_OR: + if (v) { + unsigned i = 0; + for (; !is_true(args[i]) && i < sz; ++i); + if (i == sz) { + fatal_error(1); + } + VERIFY(i < sz); + todo.push_back(args[i]); + } + else { + todo.append(sz, args); + } + break; + case OP_XOR: + case OP_NOT: + todo.append(sz, args); + break; + case OP_IMPLIES: + if (v) { + if (is_true(args[1])) { + todo.push_back(args[1]); + } + else if (is_false(args[0])) { + todo.push_back(args[0]); + } + else { + IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); + UNREACHABLE(); + } + } + else { + todo.append(sz, args); + } + break; + default: + IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); + UNREACHABLE(); + } + } + else { + tocollect.push_back(e); + } + } + + void model_evaluator::collect(ptr_vector const& formulas, ptr_vector& tocollect) { + ptr_vector todo; + todo.append(formulas); + m_visited.reset(); + + VERIFY(check_model(formulas)); + + while (!todo.empty()) { + app* e = to_app(todo.back()); + todo.pop_back(); + if (!m_visited.is_marked(e)) { + process_formula(e, todo, tocollect); + m_visited.mark(e, true); + } + } + m_visited.reset(); + } + + expr_ref_vector model_evaluator::prune_by_cone_of_influence(ptr_vector const & formulas) { + ptr_vector tocollect; + collect(formulas, tocollect); + m1.reset(); + m2.reset(); + for (unsigned i = 0; i < tocollect.size(); ++i) { + TRACE("pdr_verbose", tout << "collect: " << mk_pp(tocollect[i], m) << "\n";); + for_each_expr(*this, m_visited, tocollect[i]); + } + unsigned sz = m_model->get_num_constants(); + expr_ref e(m), eq(m); + expr_ref_vector model(m); + for (unsigned i = 0; i < sz; i++) { + func_decl * d = m_model->get_constant(i); + expr* val = m_model->get_const_interp(d); + e = m.mk_const(d); + if (m_visited.is_marked(e)) { + eq = m.mk_eq(e, val); + model.push_back(eq); + } + } + m_visited.reset(); + TRACE("pdr", tout << sz << " ==> " << model.size() << "\n";); + return model; + + } + + void model_evaluator::eval_arith(app* e) { + rational r, r2; + +#define ARG1 e->get_arg(0) +#define ARG2 e->get_arg(1) + + unsigned arity = e->get_num_args(); + for (unsigned i = 0; i < arity; ++i) { + expr* arg = e->get_arg(i); + if (is_x(arg)) { + set_x(e); + return; + } + SASSERT(!is_unknown(arg)); + } + switch(e->get_decl_kind()) { + case OP_NUM: + VERIFY(m_arith.is_numeral(e, r)); + set_number(e, r); + break; + case OP_IRRATIONAL_ALGEBRAIC_NUM: + set_x(e); + break; + case OP_LE: + set_bool(e, get_number(ARG1) <= get_number(ARG2)); + break; + case OP_GE: + set_bool(e, get_number(ARG1) >= get_number(ARG2)); + break; + case OP_LT: + set_bool(e, get_number(ARG1) < get_number(ARG2)); + break; + case OP_GT: + set_bool(e, get_number(ARG1) > get_number(ARG2)); + break; + case OP_ADD: + r = rational::zero(); + for (unsigned i = 0; i < arity; ++i) { + r += get_number(e->get_arg(i)); + } + set_number(e, r); + break; + case OP_SUB: + r = get_number(e->get_arg(0)); + for (unsigned i = 1; i < arity; ++i) { + r -= get_number(e->get_arg(i)); + } + set_number(e, r); + break; + case OP_UMINUS: + SASSERT(arity == 1); + set_number(e, get_number(e->get_arg(0))); + break; + case OP_MUL: + r = rational::one(); + for (unsigned i = 0; i < arity; ++i) { + r *= get_number(e->get_arg(i)); + } + set_number(e, r); + break; + case OP_DIV: + SASSERT(arity == 2); + r = get_number(ARG2); + if (r.is_zero()) { + set_x(e); } else { - todo.append(sz, args); + set_number(e, get_number(ARG1) / r); } + break; + case OP_IDIV: + SASSERT(arity == 2); + r = get_number(ARG2); + if (r.is_zero()) { + set_x(e); + } + else { + set_number(e, div(get_number(ARG1), r)); + } + break; + case OP_REM: + // rem(v1,v2) = if v2 >= 0 then mod(v1,v2) else -mod(v1,v2) + SASSERT(arity == 2); + r = get_number(ARG2); + if (r.is_zero()) { + set_x(e); + } + else { + r2 = mod(get_number(ARG1), r); + if (r.is_neg()) r2.neg(); + set_number(e, r2); + } + break; + case OP_MOD: + SASSERT(arity == 2); + r = get_number(ARG2); + if (r.is_zero()) { + set_x(e); + } + else { + set_number(e, mod(get_number(ARG1), r)); + } + break; + case OP_TO_REAL: + SASSERT(arity == 1); + set_number(e, get_number(ARG1)); + break; + case OP_TO_INT: + SASSERT(arity == 1); + set_number(e, floor(get_number(ARG1))); + break; + case OP_IS_INT: + SASSERT(arity == 1); + set_bool(e, get_number(ARG1).is_int()); + break; + case OP_POWER: + set_x(e); break; default: IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); UNREACHABLE(); + break; } } - else { - tocollect.push_back(e); - } -} - -void model_evaluator::collect(ptr_vector const& formulas, ptr_vector& tocollect) { - ptr_vector todo; - todo.append(formulas); - m_visited.reset(); - VERIFY(check_model(formulas)); - - while (!todo.empty()) { - app* e = to_app(todo.back()); - todo.pop_back(); - if (!m_visited.is_marked(e)) { - process_formula(e, todo, tocollect); - m_visited.mark(e, true); - } - } - m_visited.reset(); -} - -expr_ref_vector model_evaluator::prune_by_cone_of_influence(ptr_vector const & formulas) { - ptr_vector tocollect; - collect(formulas, tocollect); - m1.reset(); - m2.reset(); - for (unsigned i = 0; i < tocollect.size(); ++i) { - TRACE("pdr_verbose", tout << "collect: " << mk_pp(tocollect[i], m) << "\n";); - for_each_expr(*this, m_visited, tocollect[i]); - } - unsigned sz = m_model->get_num_constants(); - expr_ref e(m), eq(m); - expr_ref_vector model(m); - for (unsigned i = 0; i < sz; i++) { - func_decl * d = m_model->get_constant(i); - expr* val = m_model->get_const_interp(d); - e = m.mk_const(d); - if (m_visited.is_marked(e)) { - eq = m.mk_eq(e, val); - model.push_back(eq); - } - } - m_visited.reset(); - TRACE("pdr", tout << sz << " ==> " << model.size() << "\n";); - return model; - -} - -void model_evaluator::eval_arith(app* e) { - rational r, r2; - -#define ARG1 e->get_arg(0) -#define ARG2 e->get_arg(1) - - unsigned arity = e->get_num_args(); - for (unsigned i = 0; i < arity; ++i) { - expr* arg = e->get_arg(i); - if (is_x(arg)) { - set_x(e); - return; - } - SASSERT(!is_unknown(arg)); - } - switch(e->get_decl_kind()) { - case OP_NUM: - VERIFY(m_arith.is_numeral(e, r)); - set_number(e, r); - break; - case OP_IRRATIONAL_ALGEBRAIC_NUM: - set_x(e); - break; - case OP_LE: - set_bool(e, get_number(ARG1) <= get_number(ARG2)); - break; - case OP_GE: - set_bool(e, get_number(ARG1) >= get_number(ARG2)); - break; - case OP_LT: - set_bool(e, get_number(ARG1) < get_number(ARG2)); - break; - case OP_GT: - set_bool(e, get_number(ARG1) > get_number(ARG2)); - break; - case OP_ADD: - r = rational::zero(); - for (unsigned i = 0; i < arity; ++i) { - r += get_number(e->get_arg(i)); - } - set_number(e, r); - break; - case OP_SUB: - r = get_number(e->get_arg(0)); - for (unsigned i = 1; i < arity; ++i) { - r -= get_number(e->get_arg(i)); - } - set_number(e, r); - break; - case OP_UMINUS: - SASSERT(arity == 1); - set_number(e, get_number(e->get_arg(0))); - break; - case OP_MUL: - r = rational::one(); - for (unsigned i = 0; i < arity; ++i) { - r *= get_number(e->get_arg(i)); - } - set_number(e, r); - break; - case OP_DIV: - SASSERT(arity == 2); - r = get_number(ARG2); - if (r.is_zero()) { + void model_evaluator::inherit_value(expr* e, expr* v) { + expr* w; + SASSERT(!is_unknown(v)); + SASSERT(m.get_sort(e) == m.get_sort(v)); + if (is_x(v)) { set_x(e); } - else { - set_number(e, get_number(ARG1) / r); + else if (m.is_bool(e)) { + SASSERT(m.is_bool(v)); + if (is_true(v)) set_true(e); + else if (is_false(v)) set_false(e); + else { + TRACE("pdr", tout << "not inherited:\n" << mk_pp(e, m) << "\n" << mk_pp(v, m) << "\n";); + set_x(e); + } } - break; - case OP_IDIV: - SASSERT(arity == 2); - r = get_number(ARG2); - if (r.is_zero()) { - set_x(e); + else if (m_arith.is_int_real(e)) { + set_number(e, get_number(v)); } - else { - set_number(e, div(get_number(ARG1), r)); + else if (m.is_value(v)) { + set_value(e, v); } - break; - case OP_REM: - // rem(v1,v2) = if v2 >= 0 then mod(v1,v2) else -mod(v1,v2) - SASSERT(arity == 2); - r = get_number(ARG2); - if (r.is_zero()) { - set_x(e); + else if (m_values.find(v, w)) { + set_value(e, w); } - else { - r2 = mod(get_number(ARG1), r); - if (r.is_neg()) r2.neg(); - set_number(e, r2); - } - break; - case OP_MOD: - SASSERT(arity == 2); - r = get_number(ARG2); - if (r.is_zero()) { - set_x(e); - } - else { - set_number(e, mod(get_number(ARG1), r)); - } - break; - case OP_TO_REAL: - SASSERT(arity == 1); - set_number(e, get_number(ARG1)); - break; - case OP_TO_INT: - SASSERT(arity == 1); - set_number(e, floor(get_number(ARG1))); - break; - case OP_IS_INT: - SASSERT(arity == 1); - set_bool(e, get_number(ARG1).is_int()); - break; - case OP_POWER: - set_x(e); - break; - default: - IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); - UNREACHABLE(); - break; - } -} - -void model_evaluator::inherit_value(expr* e, expr* v) { - expr* w; - SASSERT(!is_unknown(v)); - SASSERT(m.get_sort(e) == m.get_sort(v)); - if (is_x(v)) { - set_x(e); - } - else if (m.is_bool(e)) { - SASSERT(m.is_bool(v)); - if (is_true(v)) set_true(e); - else if (is_false(v)) set_false(e); else { TRACE("pdr", tout << "not inherited:\n" << mk_pp(e, m) << "\n" << mk_pp(v, m) << "\n";); set_x(e); } } - else if (m_arith.is_int_real(e)) { - set_number(e, get_number(v)); - } - else if (m.is_value(v)) { - set_value(e, v); - } - else if (m_values.find(v, w)) { - set_value(e, w); - } - else { - TRACE("pdr", tout << "not inherited:\n" << mk_pp(e, m) << "\n" << mk_pp(v, m) << "\n";); - set_x(e); - } -} - -void model_evaluator::eval_iff(app* e, expr* arg1, expr* arg2) { - if (arg1 == arg2) { - set_true(e); - } - else if (is_x(arg1) || is_x(arg2)) { - set_x(e); - } - else { - bool val = is_true(arg1) == is_true(arg2); - SASSERT(val == (is_false(arg1) == is_false(arg2))); - if (val) { - set_true(e); + + bool model_evaluator::extract_array_func_interp(expr* a, vector& stores, expr_ref else_case) { + SASSERT(m_array.is_array(a)); + + while (m_array.is_store(a)) { + expr_ref_vector store(m); + store.append(to_app(a)->get_num_args()-1, to_app(a)->get_args()+1); + stores.push_back(store); + a = to_app(a)->get_arg(0); } - else { - set_false(e); - } - } -} - -void model_evaluator::eval_basic(app* e) { - expr* arg1, *arg2; - expr *argCond, *argThen, *argElse, *arg; - bool has_x = false; - unsigned arity = e->get_num_args(); - switch(e->get_decl_kind()) { - case OP_AND: - for (unsigned j = 0; j < arity; ++j) { - expr * arg = e->get_arg(j); - if (is_false(arg)) { - set_false(e); - return; + + if (m_array.is_const(a)) { + else_case = to_app(a)->get_arg(0); + return true; + } + + if (m_array.is_as_array(a)) { + func_decl* f = m_array.get_as_array_func_decl(to_app(a)); + func_interp* g = m_model->get_func_interp(f); + unsigned sz = g->num_entries(); + unsigned arity = f->get_arity(); + for (unsigned i = 0; i < sz; ++i) { + expr_ref_vector store(m); + func_entry const* fe = g->get_entry(i); + store.append(arity, fe->get_args()); + store.push_back(fe->get_result()); + for (unsigned j = 0; j < store.size(); ++j) { + if (!is_ground(store[j].get())) { + return false; + } + } + stores.push_back(store); + } + else_case = g->get_else(); + if (!is_ground(else_case)) { + return false; } - else if (is_x(arg)) { - has_x = true; + return true; + } + + return false; + } + + /** + best effort evaluator of extensional array equality. + */ + void model_evaluator::eval_array_eq(app* e, expr* arg1, expr* arg2) { + expr_ref v1(m), v2(m); + m_model->eval(arg1, v1); + m_model->eval(arg2, v2); + if (v1 == v2) { + set_true(e); + return; + } + sort* s = m.get_sort(arg1); + sort* r = get_array_range(s); + if (!r->is_infinite() && !r->is_very_big()) { + TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); + set_x(e); + return; + } + vector store; + expr_ref else1(m), else2(m); + if (!extract_array_func_interp(v1, store, else1) || + !extract_array_func_interp(v2, store, else2)) { + TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); + set_x(e); + return; + } + + if (else1 != else2) { + if (m.is_value(else1) && m.is_value(else2)) { + set_bool(e, false); } else { - SASSERT(is_true(arg)); - } - } - if (has_x) { - set_x(e); - } - else { - set_true(e); - } - break; - case OP_OR: - for (unsigned j = 0; j < arity; ++j) { - expr * arg = e->get_arg(j); - if (is_true(arg)) { - set_true(e); - return; - } - else if (is_x(arg)) { - has_x = true; - } - else { - SASSERT(is_false(arg)); - } - } - if (has_x) { - set_x(e); - } - else { - set_false(e); - } - break; - case OP_NOT: - VERIFY(m.is_not(e, arg)); - if (is_true(arg)) { - set_false(e); - } - else if (is_false(arg)) { - set_true(e); - } - else { - SASSERT(is_x(arg)); - set_x(e); - } - break; - case OP_IMPLIES: - VERIFY(m.is_implies(e, arg1, arg2)); - if (is_false(arg1) || is_true(arg2)) { - set_true(e); - } - else if (arg1 == arg2) { - set_true(e); - } - else if (is_true(arg1) && is_false(arg2)) { - set_false(e); - } - else { - SASSERT(is_x(arg1) || is_x(arg2)); - set_x(e); - } - break; - case OP_IFF: - VERIFY(m.is_iff(e, arg1, arg2)); - eval_iff(e, arg1, arg2); - break; - case OP_ITE: - VERIFY(m.is_ite(e, argCond, argThen, argElse)); - if (is_true(argCond)) { - inherit_value(e, argThen); - } - else if (is_false(argCond)) { - inherit_value(e, argElse); - } - else if (argThen == argElse) { - inherit_value(e, argThen); - } - else if (m.is_bool(e)) { - SASSERT(is_x(argCond)); - if (is_x(argThen) || is_x(argElse)) { + TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); set_x(e); } - else if (is_true(argThen) == is_true(argElse)) { - inherit_value(e, argThen); + return; + } + + expr_ref s1(m), s2(m), w1(m), w2(m); + expr_ref_vector args1(m), args2(m); + args1.push_back(v1); + args2.push_back(v2); + for (unsigned i = 0; i < store.size(); ++i) { + args1.resize(1); + args2.resize(1); + args1.append(store[i].size()-1, store[i].c_ptr()); + args2.append(store[i].size()-1, store[i].c_ptr()); + s1 = m_array.mk_select(args1.size(), args1.c_ptr()); + s2 = m_array.mk_select(args2.size(), args2.c_ptr()); + m_model->eval(s1, w1); + m_model->eval(s2, w2); + if (w1 == w2) { + continue; + } + else if (m.is_value(w1) && m.is_value(w2)) { + set_bool(e, false); + return; } else { + TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); set_x(e); + return; } } - else { - set_x(e); - } - break; - case OP_TRUE: - set_true(e); - break; - case OP_FALSE: - set_false(e); - break; - case OP_EQ: - VERIFY(m.is_eq(e, arg1, arg2)); - if (m.is_bool(arg1)) { - eval_iff(e, arg1, arg2); - } - else if (arg1 == arg2) { + set_bool(e, true); + } + + void model_evaluator::eval_eq(app* e, expr* arg1, expr* arg2) { + if (arg1 == arg2) { set_true(e); } + else if (m_array.is_array(arg1)) { + eval_array_eq(e, arg1, arg2); + } else if (is_x(arg1) || is_x(arg2)) { set_x(e); } + else if (m.is_bool(arg1)) { + bool val = is_true(arg1) == is_true(arg2); + SASSERT(val == (is_false(arg1) == is_false(arg2))); + if (val) { + set_true(e); + } + else { + set_false(e); + } + } else if (m_arith.is_int_real(arg1)) { set_bool(e, get_number(arg1) == get_number(arg2)); } @@ -648,164 +688,222 @@ void model_evaluator::eval_basic(app* e) { if (m.is_value(e1) && m.is_value(e2)) { set_bool(e, e1 == e2); } + else if (e1 == e2) { + set_bool(e, true); + } else { TRACE("pdr", tout << "not value equal:\n" << mk_pp(e1, m) << "\n" << mk_pp(e2, m) << "\n";); set_x(e); } } - break; - case OP_DISTINCT: { - vector values; - for (unsigned i = 0; i < arity; ++i) { - expr* arg = e->get_arg(i); - if (is_x(arg)) { + } + + void model_evaluator::eval_basic(app* e) { + expr* arg1, *arg2; + expr *argCond, *argThen, *argElse, *arg; + bool has_x = false; + unsigned arity = e->get_num_args(); + switch(e->get_decl_kind()) { + case OP_AND: + for (unsigned j = 0; j < arity; ++j) { + expr * arg = e->get_arg(j); + if (is_false(arg)) { + set_false(e); + return; + } + else if (is_x(arg)) { + has_x = true; + } + else { + SASSERT(is_true(arg)); + } + } + if (has_x) { set_x(e); - return; } - values.push_back(get_number(arg)); - } - std::sort(values.begin(), values.end()); - for (unsigned i = 0; i + 1 < values.size(); ++i) { - if (values[i] == values[i+1]) { + else { + set_true(e); + } + break; + case OP_OR: + for (unsigned j = 0; j < arity; ++j) { + expr * arg = e->get_arg(j); + if (is_true(arg)) { + set_true(e); + return; + } + else if (is_x(arg)) { + has_x = true; + } + else { + SASSERT(is_false(arg)); + } + } + if (has_x) { + set_x(e); + } + else { set_false(e); - return; } + break; + case OP_NOT: + VERIFY(m.is_not(e, arg)); + if (is_true(arg)) { + set_false(e); + } + else if (is_false(arg)) { + set_true(e); + } + else { + SASSERT(is_x(arg)); + set_x(e); + } + break; + case OP_IMPLIES: + VERIFY(m.is_implies(e, arg1, arg2)); + if (is_false(arg1) || is_true(arg2)) { + set_true(e); + } + else if (arg1 == arg2) { + set_true(e); + } + else if (is_true(arg1) && is_false(arg2)) { + set_false(e); + } + else { + SASSERT(is_x(arg1) || is_x(arg2)); + set_x(e); + } + break; + case OP_IFF: + VERIFY(m.is_iff(e, arg1, arg2)); + eval_eq(e, arg1, arg2); + break; + case OP_ITE: + VERIFY(m.is_ite(e, argCond, argThen, argElse)); + if (is_true(argCond)) { + inherit_value(e, argThen); + } + else if (is_false(argCond)) { + inherit_value(e, argElse); + } + else if (argThen == argElse) { + inherit_value(e, argThen); + } + else if (m.is_bool(e)) { + SASSERT(is_x(argCond)); + if (is_x(argThen) || is_x(argElse)) { + set_x(e); + } + else if (is_true(argThen) == is_true(argElse)) { + inherit_value(e, argThen); + } + else { + set_x(e); + } + } + else { + set_x(e); + } + break; + case OP_TRUE: + set_true(e); + break; + case OP_FALSE: + set_false(e); + break; + case OP_EQ: + VERIFY(m.is_eq(e, arg1, arg2)); + eval_eq(e, arg1, arg2); + break; + case OP_DISTINCT: { + vector values; + for (unsigned i = 0; i < arity; ++i) { + expr* arg = e->get_arg(i); + if (is_x(arg)) { + set_x(e); + return; + } + values.push_back(get_number(arg)); + } + std::sort(values.begin(), values.end()); + for (unsigned i = 0; i + 1 < values.size(); ++i) { + if (values[i] == values[i+1]) { + set_false(e); + return; + } + } + set_true(e); + break; + } + default: + IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); + UNREACHABLE(); } - set_true(e); - break; } - default: - IF_VERBOSE(0, verbose_stream() << "Term not handled " << mk_pp(e, m) << "\n";); - UNREACHABLE(); - } -} - -bool model_evaluator::check_model(ptr_vector const& formulas) { - ptr_vector todo(formulas); - - while (!todo.empty()) { - expr * curr_e = todo.back(); - - if (!is_app(curr_e)) { + + bool model_evaluator::check_model(ptr_vector const& formulas) { + ptr_vector todo(formulas); + + while (!todo.empty()) { + expr * curr_e = todo.back(); + + if (!is_app(curr_e)) { + todo.pop_back(); + continue; + } + app * curr = to_app(curr_e); + + if (!is_unknown(curr)) { + todo.pop_back(); + continue; + } + unsigned arity = curr->get_num_args(); + for (unsigned i = 0; i < arity; ++i) { + if (is_unknown(curr->get_arg(i))) { + todo.push_back(curr->get_arg(i)); + } + } + if (todo.back() != curr) { + continue; + } todo.pop_back(); - continue; + if (curr->get_family_id() == m_arith.get_family_id()) { + eval_arith(curr); + } + else if (curr->get_family_id() == m.get_basic_family_id()) { + eval_basic(curr); + } + else { + expr_ref vl(m); + m_model->eval(curr, vl); + assign_value(curr, vl); + } + + IF_VERBOSE(35,verbose_stream() << "assigned "<get_num_args(); - for (unsigned i = 0; i < arity; ++i) { - if (is_unknown(curr->get_arg(i))) { - todo.push_back(curr->get_arg(i)); + + bool has_x = false; + for (unsigned i = 0; i < formulas.size(); ++i) { + expr * form = formulas[i]; + SASSERT(!is_unknown(form)); + TRACE("pdr_verbose", + tout << "formula is " << (is_true(form) ? "true" : is_false(form) ? "false" : "unknown") << "\n" <get_family_id() == m_arith.get_family_id()) { - eval_arith(curr); - } - else if (curr->get_family_id() == m.get_basic_family_id()) { - eval_basic(curr); - } - else { - expr_ref vl(m); - m_model->eval(curr, vl); - assign_value(curr, vl); - } - - IF_VERBOSE(35,verbose_stream() << "assigned "<get_num_parameters(); - - ptr_vector domain; - domain.push_back(arr_sort); - - //we push params of the array as remaining arguments of the store. The first - //num_params-1 parameters are indices and the last one is the range of the array - for (unsigned i=0; iget_parameter(i).get_ast())); - } - - return m.mk_func_decl(array_fid, OP_STORE, - arr_sort->get_num_parameters(), arr_sort->get_parameters(), - domain.size(), domain.c_ptr(), arr_sort); + return !has_x; } - void get_as_array_value(const model_core & mdl, expr * arr_e, expr_ref& res) { - ast_manager& m = mdl.get_manager(); - array_util pl(m); - SASSERT(pl.is_as_array(arr_e)); - - app * arr = to_app(arr_e); - - unsigned sz = 0; - func_decl_ref f(pl.get_as_array_func_decl(arr), m); - sort * arr_sort = arr->get_decl()->get_range(); - func_interp* g = mdl.get_func_interp(f); - - res = pl.mk_const_array(arr_sort, g->get_else()); - - unsigned arity = f->get_arity(); - - sz = g->num_entries(); - if (sz) { - func_decl_ref store_fn(mk_store(m, arr_sort), m); - ptr_vector store_args; - for (unsigned i = 0; i < sz; ++i) { - const func_entry * fe = g->get_entry(i); - store_args.reset(); - store_args.push_back(res); - store_args.append(arity, fe->get_args()); - store_args.push_back(fe->get_result()); - res = m.mk_app(store_fn, store_args.size(), store_args.c_ptr()); - } - } - } - - void get_value_from_model(const model_core & mdl, func_decl * f, expr_ref& res) { - SASSERT(f->get_arity()==0); - ast_manager& m = mdl.get_manager(); - - res = mdl.get_const_interp(f); - - array_util pl(m); - - if (pl.is_as_array(res)) { - get_as_array_value(mdl, res, res); - } - } - void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml) { ast_manager& m = fml.get_manager(); expr_ref_vector conjs(m); @@ -914,8 +1012,7 @@ bool model_evaluator::check_model(ptr_vector const& formulas) { br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) { return m_r.mk_app_core(f, num, args, result); } - ite_hoister_cfg(ast_manager & m, params_ref const & p):m_r(m) {} - + ite_hoister_cfg(ast_manager & m, params_ref const & p):m_r(m) {} }; class ite_hoister_star : public rewriter_tpl { diff --git a/src/muz_qe/pdr_util.h b/src/muz_qe/pdr_util.h index 1d1e86262..bb9f74060 100644 --- a/src/muz_qe/pdr_util.h +++ b/src/muz_qe/pdr_util.h @@ -28,6 +28,7 @@ Revision History: #include "trace.h" #include "vector.h" #include "arith_decl_plugin.h" +#include "array_decl_plugin.h" #include "bv_decl_plugin.h" @@ -56,6 +57,7 @@ namespace pdr { class model_evaluator { ast_manager& m; arith_util m_arith; + array_util m_array; obj_map m_numbers; expr_ref_vector m_refs; obj_map m_values; @@ -78,7 +80,8 @@ namespace pdr { expr_ref_vector prune_by_cone_of_influence(ptr_vector const & formulas); void eval_arith(app* e); void eval_basic(app* e); - void eval_iff(app* e, expr* arg1, expr* arg2); + void eval_eq(app* e, expr* arg1, expr* arg2); + void eval_array_eq(app* e, expr* arg1, expr* arg2); void inherit_value(expr* e, expr* v); inline bool is_unknown(expr* x) { return !m1.is_marked(x) && !m2.is_marked(x); } @@ -99,9 +102,11 @@ namespace pdr { inline void set_value(expr* x, expr* v) { set_v(x); m_refs.push_back(v); m_values.insert(x, v); } bool check_model(ptr_vector const & formulas); + + bool extract_array_func_interp(expr* a, vector& stores, expr_ref else_case); public: - model_evaluator(ast_manager& m) : m(m), m_arith(m), m_refs(m) {} + model_evaluator(ast_manager& m) : m(m), m_arith(m), m_array(m), m_refs(m) {} /** \brief extract equalities from model that suffice to satisfy formula. @@ -118,13 +123,12 @@ namespace pdr { */ expr_ref_vector minimize_literals(ptr_vector const & formulas, model_ref& mdl); - - // for_each_expr visitor. + /** + for_each_expr visitor. + */ void operator()(expr* e) {} }; - void get_value_from_model(const model_core & mdl, func_decl * f, expr_ref& res); - /** \brief replace variables that are used in many disequalities by an equality using the model. From 008fc648c15cafb7561c3c089d828e62c9d4c677 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 25 Nov 2012 16:53:13 -0800 Subject: [PATCH 03/17] ensure there are enough variables Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 12c12c75a..f38999381 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -338,7 +338,7 @@ namespace datalog { expr_ref context::bind_variables(expr* fml, bool is_forall) { expr_ref result(m); - app_ref_vector const& vars = m_vars; + app_ref_vector & vars = m_vars; if (vars.empty()) { result = fml; } @@ -352,6 +352,9 @@ namespace datalog { else { svector names; for (unsigned i = 0; i < sorts.size(); ++i) { + if (vars.size() == i) { + vars.push_back(m.mk_fresh_const("x", m.mk_bool_sort())); + } if (!sorts[i]) { sorts[i] = vars[i]->get_decl()->get_range(); } From 682a725e1323d7ef4513a9a85ade0f4a44baea19 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 26 Nov 2012 13:47:26 +0000 Subject: [PATCH 04/17] Managed API: Refactoring, Formatting. Signed-off-by: Christoph M. Wintersteiger --- src/api/dotnet/BitVecSort.cs | 1 - src/api/dotnet/Context.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api/dotnet/BitVecSort.cs b/src/api/dotnet/BitVecSort.cs index 55ef4ae49..d865159f4 100644 --- a/src/api/dotnet/BitVecSort.cs +++ b/src/api/dotnet/BitVecSort.cs @@ -37,7 +37,6 @@ namespace Microsoft.Z3 #region Internal internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); } - internal BitVecSort(Context ctx, uint size) : base(ctx, Native.Z3_mk_bv_sort(ctx.nCtx, size)) { Contract.Requires(ctx != null); } #endregion }; } diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index 2aea1586c..30e5ece4f 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -193,7 +193,7 @@ namespace Microsoft.Z3 { Contract.Ensures(Contract.Result() != null); - return new BitVecSort(this, size); + return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size)); } ///

From f7825755db08d230142bedf7e98ddce33d2d4010 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 08:26:51 -0800 Subject: [PATCH 05/17] fix build problem, redo naming abstraction Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 19 +++++++++++++------ src/muz_qe/pdr_util.cpp | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index f38999381..77b391ef7 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -338,7 +338,7 @@ namespace datalog { expr_ref context::bind_variables(expr* fml, bool is_forall) { expr_ref result(m); - app_ref_vector & vars = m_vars; + app_ref_vector const & vars = m_vars; if (vars.empty()) { result = fml; } @@ -352,13 +352,20 @@ namespace datalog { else { svector names; for (unsigned i = 0; i < sorts.size(); ++i) { - if (vars.size() == i) { - vars.push_back(m.mk_fresh_const("x", m.mk_bool_sort())); - } if (!sorts[i]) { - sorts[i] = vars[i]->get_decl()->get_range(); + if (i < vars.size()) { + sorts[i] = vars[i]->get_decl()->get_range(); + } + else { + sorts[i] = m.mk_bool_sort(); + } + } + if (i < vars.size()) { + names.push_back(vars[i]->get_decl()->get_name()); + } + else { + names.push_back(symbol(i)); } - names.push_back(vars[i]->get_decl()->get_name()); } quantifier_ref q(m); sorts.reverse(); diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 0840f1d73..2c009dc25 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -119,7 +119,6 @@ namespace pdr { select_elim_cfg(ast_manager & m, model_ref& md, params_ref const & p):m_r(m, md) {} }; - template class rewriter_tpl; class select_elim_star : public rewriter_tpl { select_elim_cfg m_cfg; @@ -1205,5 +1204,6 @@ namespace pdr { template class rewriter_tpl; +template class rewriter_tpl; From 75b1278e9735d757e80fcc3f4ba86b0a9dc6c1e2 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 26 Nov 2012 21:02:22 +0000 Subject: [PATCH 06/17] Managed API: Refactoring. Signed-off-by: Christoph M. Wintersteiger --- src/api/dotnet/Context.cs | 2 +- src/api/dotnet/Expr.cs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index 30e5ece4f..3e438d69d 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -388,7 +388,7 @@ namespace Microsoft.Z3 IntPtr[] n_constr = new IntPtr[n]; for (uint i = 0; i < n; i++) { - var constructor = c[i]; + Constructor[] constructor = c[i]; Contract.Assume(Contract.ForAll(constructor, arr => arr != null), "Clousot does not support yet quantified formula on multidimensional arrays"); CheckContextMatch(constructor); cla[i] = new ConstructorList(this, constructor); diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index 22a506c71..6c2ebb3ad 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -433,7 +433,8 @@ namespace Microsoft.Z3 get { return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_ARRAY_SORT); + (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) + == Z3_sort_kind.Z3_ARRAY_SORT); } } @@ -1308,7 +1309,8 @@ namespace Microsoft.Z3 get { return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_RELATION_SORT); + Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) + == (uint)Z3_sort_kind.Z3_RELATION_SORT); } } @@ -1429,7 +1431,7 @@ namespace Microsoft.Z3 get { return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 && - (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT); + Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FINITE_DOMAIN_SORT); } } @@ -1489,8 +1491,8 @@ namespace Microsoft.Z3 internal override void CheckNativeObject(IntPtr obj) { if (Native.Z3_is_app(Context.nCtx, obj) == 0 && - (Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_VAR_AST && - (Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) + Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_VAR_AST && + Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_QUANTIFIER_AST) throw new Z3Exception("Underlying object is not a term"); base.CheckNativeObject(obj); } From 36d9a90d2a8ae7e033a5c01b1d292981b3452576 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 26 Nov 2012 21:03:35 +0000 Subject: [PATCH 07/17] Java API: more automatic translation from C#, but still unfinished. Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 19 +- scripts/update_api.py | 1 + src/api/java/com/Microsoft/Z3/AST.java | 41 +- src/api/java/com/Microsoft/Z3/ASTMap.java | 17 +- src/api/java/com/Microsoft/Z3/ASTVector.java | 21 +- .../java/com/Microsoft/Z3/AlgebraicNum.java | 11 +- .../java/com/Microsoft/Z3/ApplyResult.java | 17 +- src/api/java/com/Microsoft/Z3/ArithExpr.java | 1 + src/api/java/com/Microsoft/Z3/ArithSort.java | 1 + src/api/java/com/Microsoft/Z3/ArrayExpr.java | 1 + src/api/java/com/Microsoft/Z3/ArraySort.java | 7 +- src/api/java/com/Microsoft/Z3/BitVecExpr.java | 3 +- src/api/java/com/Microsoft/Z3/BitVecNum.java | 17 +- src/api/java/com/Microsoft/Z3/BitVecSort.java | 4 +- src/api/java/com/Microsoft/Z3/BoolExpr.java | 1 + src/api/java/com/Microsoft/Z3/BoolSort.java | 1 + .../java/com/Microsoft/Z3/Constructor.java | 21 +- .../com/Microsoft/Z3/ConstructorList.java | 3 +- src/api/java/com/Microsoft/Z3/Context.java | 571 ++++++++---------- .../java/com/Microsoft/Z3/DatatypeExpr.java | 1 + .../java/com/Microsoft/Z3/DatatypeSort.java | 29 +- src/api/java/com/Microsoft/Z3/EnumSort.java | 11 +- .../Z3/Enumerations/Z3_ast_kind.class | Bin 0 -> 1554 bytes .../Z3/Enumerations/Z3_ast_kind.java | 28 +- .../Z3/Enumerations/Z3_ast_print_mode.class | Bin 0 -> 1450 bytes .../Z3/Enumerations/Z3_ast_print_mode.java | 22 +- .../Z3/Enumerations/Z3_decl_kind.class | Bin 0 -> 11227 bytes .../Z3/Enumerations/Z3_decl_kind.java | 318 +++++----- .../Z3/Enumerations/Z3_error_code.class | Bin 0 -> 1961 bytes .../Z3/Enumerations/Z3_error_code.java | 40 +- .../Z3/Enumerations/Z3_goal_prec.class | Bin 0 -> 1379 bytes .../Z3/Enumerations/Z3_goal_prec.java | 22 +- .../Microsoft/Z3/Enumerations/Z3_lbool.class | Bin 0 -> 1270 bytes .../Microsoft/Z3/Enumerations/Z3_lbool.java | 20 +- .../Z3/Enumerations/Z3_param_kind.class | Bin 0 -> 1557 bytes .../Z3/Enumerations/Z3_param_kind.java | 28 +- .../Z3/Enumerations/Z3_parameter_kind.class | Bin 0 -> 1639 bytes .../Z3/Enumerations/Z3_parameter_kind.java | 28 +- .../Z3/Enumerations/Z3_sort_kind.class | Bin 0 -> 1770 bytes .../Z3/Enumerations/Z3_sort_kind.java | 34 +- .../Z3/Enumerations/Z3_symbol_kind.class | Bin 0 -> 1270 bytes .../Z3/Enumerations/Z3_symbol_kind.java | 18 +- src/api/java/com/Microsoft/Z3/Expr.java | 405 +++++++------ .../com/Microsoft/Z3/FiniteDomainSort.java | 3 +- src/api/java/com/Microsoft/Z3/Fixedpoint.java | 79 +-- src/api/java/com/Microsoft/Z3/FuncDecl.java | 57 +- src/api/java/com/Microsoft/Z3/FuncInterp.java | 41 +- src/api/java/com/Microsoft/Z3/Goal.java | 37 +- .../java/com/Microsoft/Z3/IDecRefQueue.java | 13 +- src/api/java/com/Microsoft/Z3/IntExpr.java | 1 + src/api/java/com/Microsoft/Z3/IntNum.java | 17 +- src/api/java/com/Microsoft/Z3/IntSort.java | 1 + src/api/java/com/Microsoft/Z3/IntSymbol.java | 1 + src/api/java/com/Microsoft/Z3/ListSort.java | 3 +- src/api/java/com/Microsoft/Z3/Log.java | 1 + src/api/java/com/Microsoft/Z3/Model.java | 79 +-- src/api/java/com/Microsoft/Z3/Native.java | 4 +- .../java/com/Microsoft/Z3/ParamDescrs.java | 17 +- src/api/java/com/Microsoft/Z3/Params.java | 25 +- src/api/java/com/Microsoft/Z3/Pattern.java | 9 +- src/api/java/com/Microsoft/Z3/Probe.java | 9 +- src/api/java/com/Microsoft/Z3/Quantifier.java | 77 +-- src/api/java/com/Microsoft/Z3/RatNum.java | 15 +- src/api/java/com/Microsoft/Z3/RealExpr.java | 1 + src/api/java/com/Microsoft/Z3/RealSort.java | 1 + .../java/com/Microsoft/Z3/RelationSort.java | 9 +- src/api/java/com/Microsoft/Z3/SetSort.java | 3 +- src/api/java/com/Microsoft/Z3/Solver.java | 55 +- src/api/java/com/Microsoft/Z3/Sort.java | 29 +- src/api/java/com/Microsoft/Z3/Statistics.java | 43 +- src/api/java/com/Microsoft/Z3/Status.java | 9 +- .../java/com/Microsoft/Z3/StringSymbol.java | 1 + src/api/java/com/Microsoft/Z3/Symbol.java | 11 +- src/api/java/com/Microsoft/Z3/Tactic.java | 17 +- src/api/java/com/Microsoft/Z3/TupleSort.java | 15 +- .../com/Microsoft/Z3/UninterpretedSort.java | 3 +- src/api/java/com/Microsoft/Z3/Version.java | 21 +- .../java/com/Microsoft/Z3/Z3Exception.java | 1 + src/api/java/com/Microsoft/Z3/Z3Object.java | 9 +- src/api/java/mk_java.py | 126 +++- 80 files changed, 1439 insertions(+), 1166 deletions(-) create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.class create mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.class diff --git a/scripts/mk_util.py b/scripts/mk_util.py index b69171a24..ae10d6740 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1854,8 +1854,25 @@ def mk_z3consts_java(api_files): efile.write(' **/\n') efile.write('public enum %s {\n' % name) efile.write + first = True for k, i in decls.iteritems(): - efile.write('%s (%s),\n' % (k, i)) + if first: + first = False + else: + efile.write(',\n') + efile.write(' %s (%s)' % (k, i)) + efile.write(";\n") + efile.write('\n private final int intValue;\n\n') + efile.write(' %s(int v) {\n' % name) + efile.write(' this.intValue = v;\n') + efile.write(' }\n\n') + efile.write(' public static final %s fromInt(int v) {\n' % name) + efile.write(' for (%s k: values()) \n' % name) + efile.write(' if (k.intValue == v) return k;\n') + efile.write(' return values()[0];\n') + efile.write(' }\n\n') + efile.write(' public final int toInt() { return this.intValue; }\n') + # efile.write(';\n %s(int v) {}\n' % name) efile.write('}\n\n') efile.close() mode = SEARCHING diff --git a/scripts/update_api.py b/scripts/update_api.py index 7e1439375..1eef11705 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -509,6 +509,7 @@ def mk_java(): java_native.write(' public static class IntPtr { public int value; }\n') java_native.write(' public static class LongPtr { public long value; }\n') java_native.write(' public static class StringPtr { public String value; }\n') + java_native.write(' public static class errorHandler { public long ptr; }\n') if is_windows(): java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java')) diff --git a/src/api/java/com/Microsoft/Z3/AST.java b/src/api/java/com/Microsoft/Z3/AST.java index c8471e2e8..069c07a4c 100644 --- a/src/api/java/com/Microsoft/Z3/AST.java +++ b/src/api/java/com/Microsoft/Z3/AST.java @@ -7,6 +7,7 @@ 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; */ @@ -58,9 +59,9 @@ import java.lang.Exception; return 1; else { - if (Id < oAST.Id) + if (Id() < oAST.Id()) return -1; - else if (Id > oAST.Id) + else if (Id() > oAST.Id()) return +1; else return 0; @@ -79,7 +80,7 @@ import java.lang.Exception; /** * A unique identifier for the AST (unique among all ASTs). **/ - public long Id() { return Native.getAstId(Context().nCtx(), NativeObject()); } + public int Id() { return Native.getAstId(Context().nCtx(), NativeObject()); } /** * Translates (copies) the AST to the Context . @@ -91,7 +92,7 @@ import java.lang.Exception; - if (ReferenceEquals(Context, ctx)) + if (Context() == ctx) return this; else return new AST(ctx, Native.translate(Context().nCtx(), NativeObject(), ctx.nCtx())); @@ -100,7 +101,7 @@ import java.lang.Exception; /** * The kind of the AST. **/ - public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context().nCtx(), NativeObject()); } + public Z3_ast_kind ASTKind() { return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(), NativeObject())); } /** * Indicates whether the AST is an Expr @@ -109,10 +110,10 @@ import java.lang.Exception; { switch (ASTKind()) { - case Z3_ast_kind.Z3_APP_AST: - case Z3_ast_kind.Z3_NUMERAL_AST: - case Z3_ast_kind.Z3_QUANTIFIER_AST: - case Z3_ast_kind.Z3_VAR_AST: return true; + case Z3_APP_AST: + case Z3_NUMERAL_AST: + case Z3_QUANTIFIER_AST: + case Z3_VAR_AST: return true; default: return false; } } @@ -174,22 +175,22 @@ import java.lang.Exception; void IncRef(long o) { // Console.WriteLine("AST IncRef()"); - if (Context == null) + 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); + Context().AST_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { // Console.WriteLine("AST DecRef()"); - if (Context == null) + 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); + Context().AST_DRQ().Add(o); super.DecRef(o); } @@ -198,14 +199,14 @@ import java.lang.Exception; - switch ((Z3_ast_kind)Native.getAstKind(ctx.nCtx(), obj)) + switch (Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj))) { - case Z3_ast_kind.Z3_FUNC_DECL_AST: return new FuncDecl(ctx, obj); - case Z3_ast_kind.Z3_QUANTIFIER_AST: return new Quantifier(ctx, obj); - case Z3_ast_kind.Z3_SORT_AST: return Sort.Create(ctx, obj); - case Z3_ast_kind.Z3_APP_AST: - case Z3_ast_kind.Z3_NUMERAL_AST: - case Z3_ast_kind.Z3_VAR_AST: return Expr.Create(ctx, obj); + 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 index 837779234..defd7e736 100644 --- a/src/api/java/com/Microsoft/Z3/ASTMap.java +++ b/src/api/java/com/Microsoft/Z3/ASTMap.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -24,7 +25,7 @@ import java.lang.Exception; { - return Native.astMapContains(Context().nCtx(), NativeObject(), k.NativeObject) != 0; + return Native.astMapContains(Context().nCtx(), NativeObject(), k.NativeObject()) ; } /** @@ -39,7 +40,7 @@ import java.lang.Exception; - return new AST(Context, Native.astMapFind(Context().nCtx(), NativeObject(), k.NativeObject)); + return new AST(Context(), Native.astMapFind(Context().nCtx(), NativeObject(), k.NativeObject())); } /** @@ -52,7 +53,7 @@ import java.lang.Exception; - Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject, v.NativeObject); + Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), v.NativeObject()); } /** @@ -63,7 +64,7 @@ import java.lang.Exception; { - Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject); + Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject()); } /** @@ -77,14 +78,14 @@ import java.lang.Exception; /** * The size of the map **/ - public long Size() { return Native.astMapSize(Context().nCtx(), NativeObject()); } + 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())); + return new ASTVector(Context(), Native.astMapKeys(Context().nCtx(), NativeObject())); } /** @@ -119,13 +120,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.ASTMap_DRQ.IncAndClear(Context, o); + Context().ASTMap_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.ASTMap_DRQ.Add(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 index 2bb1ab3e0..83d8173e6 100644 --- a/src/api/java/com/Microsoft/Z3/ASTVector.java +++ b/src/api/java/com/Microsoft/Z3/ASTVector.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,7 +19,7 @@ import java.lang.Exception; /** * The size of the vector **/ - public long Size() { return Native.astVectorSize(Context().nCtx(), NativeObject()); } + public int Size() { return Native.astVectorSize(Context().nCtx(), NativeObject()); } /** * Retrieves the i-th object in the vector. @@ -26,24 +27,24 @@ import java.lang.Exception; * Index * @return An AST **/ - public AST get(long i) + public AST get(int i) { - return new AST(Context, Native.astVectorGet(Context().nCtx(), NativeObject(), i)); + return new AST(Context(), Native.astVectorGet(Context().nCtx(), NativeObject(), i)); } - public void set(long i, AST value) + public void set(int i, AST value) { - Native.astVectorSet(Context().nCtx(), NativeObject(), i, value.NativeObject); + Native.astVectorSet(Context().nCtx(), NativeObject(), i, value.NativeObject()); } /** * Resize the vector to . * The new size of the vector. **/ - public void Resize(long newSize) + public void Resize(int newSize) { Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); } @@ -57,7 +58,7 @@ import java.lang.Exception; { - Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject); + Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); } /** @@ -70,7 +71,7 @@ import java.lang.Exception; - return new ASTVector(Context, Native.astVectorTranslate(Context().nCtx(), NativeObject(), ctx.nCtx())); + return new ASTVector(Context(), Native.astVectorTranslate(Context().nCtx(), NativeObject(), ctx.nCtx())); } /** @@ -99,13 +100,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.ASTVector_DRQ.IncAndClear(Context, o); + Context().ASTVector_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.ASTVector_DRQ.Add(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 index eccd15556..b9f5766ce 100644 --- a/src/api/java/com/Microsoft/Z3/AlgebraicNum.java +++ b/src/api/java/com/Microsoft/Z3/AlgebraicNum.java @@ -7,6 +7,7 @@ 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; */ @@ -23,11 +24,11 @@ import java.lang.Exception; * the precision of the result * @return A numeral Expr of sort Real **/ - public RatNum ToUpper(long precision) + public RatNum ToUpper(int precision) { - return new RatNum(Context, Native.getAlgebraicNumberUpper(Context().nCtx(), NativeObject(), precision)); + return new RatNum(Context(), Native.getAlgebraicNumberUpper(Context().nCtx(), NativeObject(), precision)); } /** @@ -37,18 +38,18 @@ import java.lang.Exception; * * @return A numeral Expr of sort Real **/ - public RatNum ToLower(long precision) + public RatNum ToLower(int precision) { - return new RatNum(Context, Native.getAlgebraicNumberLower(Context().nCtx(), NativeObject(), precision)); + 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(long precision) + public String ToDecimal(int precision) { diff --git a/src/api/java/com/Microsoft/Z3/ApplyResult.java b/src/api/java/com/Microsoft/Z3/ApplyResult.java index 51be63496..016b2f055 100644 --- a/src/api/java/com/Microsoft/Z3/ApplyResult.java +++ b/src/api/java/com/Microsoft/Z3/ApplyResult.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -19,7 +20,7 @@ import java.lang.Exception; /** * The number of Subgoals. **/ - public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context().nCtx(), NativeObject()); } + public int NumSubgoals() { return Native.applyResultGetNumSubgoals(Context().nCtx(), NativeObject()); } /** * Retrieves the subgoals from the ApplyResult. @@ -29,10 +30,10 @@ import java.lang.Exception; - long n = NumSubgoals; + int n = NumSubgoals(); Goal[] res = new Goal[n]; - for (long i; i < n; i++) - res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = new Goal(Context(), Native.applyResultGetSubgoal(Context().nCtx(), NativeObject(), i)); return res; } @@ -41,12 +42,12 @@ import java.lang.Exception; * goal g, that the ApplyResult was obtained from. * @return A model for g **/ - public Model ConvertModel(long i, Model m) + public Model ConvertModel(int i, Model m) { - return new Model(Context, Native.applyResultConvertModel(Context().nCtx(), NativeObject(), i, m.NativeObject)); + return new Model(Context(), Native.applyResultConvertModel(Context().nCtx(), NativeObject(), i, m.NativeObject())); } /** @@ -77,13 +78,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.ApplyResult_DRQ.IncAndClear(Context, o); + Context().ApplyResult_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.ApplyResult_DRQ.Add(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 index 7920bdded..8df3bb0a5 100644 --- a/src/api/java/com/Microsoft/Z3/ArithExpr.java +++ b/src/api/java/com/Microsoft/Z3/ArithExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/ArithSort.java b/src/api/java/com/Microsoft/Z3/ArithSort.java index a6e339e30..009112494 100644 --- a/src/api/java/com/Microsoft/Z3/ArithSort.java +++ b/src/api/java/com/Microsoft/Z3/ArithSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/ArrayExpr.java b/src/api/java/com/Microsoft/Z3/ArrayExpr.java index bc03135aa..27495fb64 100644 --- a/src/api/java/com/Microsoft/Z3/ArrayExpr.java +++ b/src/api/java/com/Microsoft/Z3/ArrayExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/ArraySort.java b/src/api/java/com/Microsoft/Z3/ArraySort.java index cd00df084..b3c5ee7c3 100644 --- a/src/api/java/com/Microsoft/Z3/ArraySort.java +++ b/src/api/java/com/Microsoft/Z3/ArraySort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -22,7 +23,7 @@ import java.lang.Exception; { - return Sort.Create(Context, Native.getArraySortDomain(Context().nCtx(), NativeObject())); + return Sort.Create(Context(), Native.getArraySortDomain(Context().nCtx(), NativeObject())); } /** @@ -32,12 +33,12 @@ import java.lang.Exception; { - return Sort.Create(Context, Native.getArraySortRange(Context().nCtx(), NativeObject())); + 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)); + { 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 index 62a03cd06..bbb13a873 100644 --- a/src/api/java/com/Microsoft/Z3/BitVecExpr.java +++ b/src/api/java/com/Microsoft/Z3/BitVecExpr.java @@ -7,6 +7,7 @@ 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; */ @@ -22,7 +23,7 @@ import java.lang.Exception; /** * The size of the sort of a bit-vector term. **/ - public long SortSize() { return ((BitVecSort)Sort).Size; } + public int SortSize() { return ((BitVecSort)Sort).Size; } /** Constructor for BitVecExpr **/ diff --git a/src/api/java/com/Microsoft/Z3/BitVecNum.java b/src/api/java/com/Microsoft/Z3/BitVecNum.java index 81389dd4b..6a46fc852 100644 --- a/src/api/java/com/Microsoft/Z3/BitVecNum.java +++ b/src/api/java/com/Microsoft/Z3/BitVecNum.java @@ -7,6 +7,7 @@ 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; */ @@ -22,7 +23,7 @@ import java.lang.Exception; public long UInt64() { long res = 0; - if (Native.getNumeralLong64(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not a 64 bit unsigned"); return res; } @@ -33,7 +34,7 @@ import java.lang.Exception; public int Int() { int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not an int"); return res; } @@ -44,7 +45,7 @@ import java.lang.Exception; public long Int64() { long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not an int64"); return res; } @@ -52,11 +53,11 @@ import java.lang.Exception; /** * Retrieve the int value. **/ - public long UInt() + public int UInt() { - long res = 0; - if (Native.getNumeralLong(Context().nCtx(), NativeObject(), res) == 0) - throw new Z3Exception("Numeral is not a long"); + int res = 0; + if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) + throw new Z3Exception("Numeral is not a int"); return res; } @@ -65,7 +66,7 @@ import java.lang.Exception; **/ public BigInteger BigInteger() { - return BigInteger.Parse(this.ToString()); + return new BigInteger(this.toString()); } /** diff --git a/src/api/java/com/Microsoft/Z3/BitVecSort.java b/src/api/java/com/Microsoft/Z3/BitVecSort.java index 0ed24573a..4f9f1a2e2 100644 --- a/src/api/java/com/Microsoft/Z3/BitVecSort.java +++ b/src/api/java/com/Microsoft/Z3/BitVecSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,8 +19,7 @@ import java.lang.Exception; /** * The size of the bit-vector sort. **/ - public long Size() { return Native.getBvSortSize(Context().nCtx(), NativeObject()); } + public int Size() { return Native.getBvSortSize(Context().nCtx(), NativeObject()); } BitVecSort(Context ctx, long obj) { super(ctx, obj); { }} - BitVecSort(Context ctx, long size) { super(ctx, Native.mkBvSort(ctx.nCtx(), size)); { }} }; diff --git a/src/api/java/com/Microsoft/Z3/BoolExpr.java b/src/api/java/com/Microsoft/Z3/BoolExpr.java index 65778ba44..7644b4400 100644 --- a/src/api/java/com/Microsoft/Z3/BoolExpr.java +++ b/src/api/java/com/Microsoft/Z3/BoolExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/BoolSort.java b/src/api/java/com/Microsoft/Z3/BoolSort.java index 9b05607ac..13d4f2f1d 100644 --- a/src/api/java/com/Microsoft/Z3/BoolSort.java +++ b/src/api/java/com/Microsoft/Z3/BoolSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/Constructor.java b/src/api/java/com/Microsoft/Z3/Constructor.java index caead4737..d7d534873 100644 --- a/src/api/java/com/Microsoft/Z3/Constructor.java +++ b/src/api/java/com/Microsoft/Z3/Constructor.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,7 +19,7 @@ import java.lang.Exception; /** * The number of fields of the constructor. **/ - public long NumFields() + public int NumFields() { init(); return n; @@ -70,13 +71,13 @@ import java.lang.Exception; } - private long n = 0; + 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, long[] sortRefs) + Sort[] sorts, int[] sortRefs) { super(ctx); @@ -86,12 +87,12 @@ import java.lang.Exception; if (n != AST.ArrayLength(sorts)) throw new Z3Exception("Number of field names does not match number of sorts"); - if (sortRefs != null && sortRefs.Length != n) + if (sortRefs != null && sortRefs.length != n) throw new Z3Exception("Number of field names does not match number of sort refs"); - if (sortRefs == null) sortRefs = new long[n]; + if (sortRefs == null) sortRefs = new int[n]; - NativeObject() = Native.mkConstructor(ctx.nCtx(), name.NativeObject, recognizer.NativeObject, + NativeObject() = Native.mkConstructor(ctx.nCtx(), name.NativeObject(), recognizer.NativeObject(), n, Symbol.ArrayToNative(fieldNames), Sort.ArrayToNative(sorts), @@ -110,11 +111,11 @@ import java.lang.Exception; 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_constructorDecl = new FuncDecl(Context(), constructor); + m_testerDecl = new FuncDecl(Context(), tester); m_accessorDecls = new FuncDecl[n]; - for (long i; i < n; i++) - m_accessorDecls[i] = new FuncDecl(Context, accessors[i]); + 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 index 05b85e664..cb8be3b38 100644 --- a/src/api/java/com/Microsoft/Z3/ConstructorList.java +++ b/src/api/java/com/Microsoft/Z3/ConstructorList.java @@ -7,6 +7,7 @@ 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; */ @@ -37,6 +38,6 @@ import java.lang.Exception; - setNativeObject(Native.mkConstructorList(Context().nCtx(), (long)constructors.Length, Constructor.ArrayToNative(constructors))); + 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 index 69a01cb86..079bcaf43 100644 --- a/src/api/java/com/Microsoft/Z3/Context.java +++ b/src/api/java/com/Microsoft/Z3/Context.java @@ -7,6 +7,7 @@ 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; */ @@ -34,7 +35,7 @@ import java.lang.Exception; long cfg = Native.mkConfig(); - for (Iterator kv = settings.iterator(); kv.hasNext(); ) + for (KeyValuePair kv: settings) Native.setParamValue(cfg, kv.Key, kv.Value); m_ctx = Native.mkContextRc(cfg); Native.delConfig(cfg); @@ -76,8 +77,8 @@ import java.lang.Exception; if (names == null) return null; - Symbol[] result = new Symbol[names.Length]; - for (int i; i < names.Length; ++i) result[i] = MkSymbol(names[i]); + Symbol[] result = new Symbol[names.length]; + for (int i = 0; i < names.length; ++i) result[i] = MkSymbol(names[i]); return result; } @@ -163,11 +164,11 @@ import java.lang.Exception; /** * Create a new bit-vector sort. **/ - public BitVecSort MkBitVecSort(long size) + public BitVecSort MkBitVecSort(int size) { - return new BitVecSort(this, size); + return new BitVecSort(this, Native.mkBvSort(nCtx(), size)); } /** @@ -198,7 +199,7 @@ import java.lang.Exception; CheckContextMatch(name); CheckContextMatch(fieldNames); CheckContextMatch(fieldSorts); - return new TupleSort(this, name, (long)fieldNames.Length, fieldNames, fieldSorts); + return new TupleSort(this, name, (int)fieldNames.length, fieldNames, fieldSorts); } /** @@ -287,7 +288,7 @@ import java.lang.Exception; * 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, long[] sortRefs) + public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames, Sort[] sorts, int[] sortRefs) { @@ -305,7 +306,7 @@ import java.lang.Exception; * * @return **/ - public Constructor MkConstructor(String name, String recognizer, String[] fieldNames, Sort[] sorts, long[] sortRefs) + public Constructor MkConstructor(String name, String recognizer, String[] fieldNames, Sort[] sorts, int[] sortRefs) { @@ -356,21 +357,21 @@ import java.lang.Exception; CheckContextMatch(names); - long n = (long)names.Length; + int n = (int)names.length; ConstructorList[] cla = new ConstructorList[n]; long[] n_constr = new long[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) { - var constructor = c[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); + Native.mkDatatypes(nCtx(), n, Symbol.ArrayToNative(names), n_res, n_constr); DatatypeSort[] res = new DatatypeSort[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) res[i] = new DatatypeSort(this, n_res[i]); return res; } @@ -517,12 +518,12 @@ import java.lang.Exception; * The de-Bruijn index of the variable * The sort of the variable **/ - public Expr MkBound(long index, Sort ty) + public Expr MkBound(int index, Sort ty) { - return Expr.Create(this, Native.mkBound(nCtx, index, ty.NativeObject)); + return Expr.Create(this, Native.mkBound(nCtx(), index, ty.NativeObject())); } /** @@ -531,7 +532,7 @@ import java.lang.Exception; public Pattern MkPattern(Expr[] terms) { - if (terms.Length == 0) + if (terms.length == 0) throw new Z3Exception("Cannot create a pattern from zero terms"); @@ -539,7 +540,7 @@ import java.lang.Exception; long[] termsNative = AST.ArrayToNative(terms); - return new Pattern(this, Native.mkPattern(nCtx, (long)terms.Length, termsNative)); + return new Pattern(this, Native.mkPattern(nCtx(), (int)terms.length, termsNative)); } /** @@ -554,7 +555,7 @@ import java.lang.Exception; CheckContextMatch(name); CheckContextMatch(range); - return Expr.Create(this, Native.mkConst(nCtx, name.NativeObject, range.NativeObject)); + return Expr.Create(this, Native.mkConst(nCtx(), name.NativeObject(), range.NativeObject())); } /** @@ -578,7 +579,7 @@ import java.lang.Exception; CheckContextMatch(range); - return Expr.Create(this, Native.mkFreshConst(nCtx, prefix, range.NativeObject)); + return Expr.Create(this, Native.mkFreshConst(nCtx(), prefix, range.NativeObject())); } /** @@ -601,7 +602,7 @@ import java.lang.Exception; - return (BoolExpr)MkConst(name, BoolSort); + return (BoolExpr)MkConst(name, BoolSort()); } /** @@ -611,7 +612,7 @@ import java.lang.Exception; { - return (BoolExpr)MkConst(MkSymbol(name), BoolSort); + return (BoolExpr)MkConst(MkSymbol(name), BoolSort()); } /** @@ -622,7 +623,7 @@ import java.lang.Exception; - return (IntExpr)MkConst(name, IntSort); + return (IntExpr)MkConst(name, IntSort()); } /** @@ -633,7 +634,7 @@ import java.lang.Exception; - return (IntExpr)MkConst(name, IntSort); + return (IntExpr)MkConst(name, IntSort()); } /** @@ -644,7 +645,7 @@ import java.lang.Exception; - return (RealExpr)MkConst(name, RealSort); + return (RealExpr)MkConst(name, RealSort()); } /** @@ -654,13 +655,13 @@ import java.lang.Exception; { - return (RealExpr)MkConst(name, RealSort); + return (RealExpr)MkConst(name, RealSort()); } /** * Creates a bit-vector constant. **/ - public BitVecExpr MkBVConst(Symbol name, long size) + public BitVecExpr MkBVConst(Symbol name, int size) { @@ -671,7 +672,7 @@ import java.lang.Exception; /** * Creates a bit-vector constant. **/ - public BitVecExpr MkBVConst(String name, long size) + public BitVecExpr MkBVConst(String name, int size) { @@ -699,7 +700,7 @@ import java.lang.Exception; { - return new BoolExpr(this, Native.mkTrue(nCtx)); + return new BoolExpr(this, Native.mkTrue(nCtx())); } /** @@ -709,7 +710,7 @@ import java.lang.Exception; { - return new BoolExpr(this, Native.mkFalse(nCtx)); + return new BoolExpr(this, Native.mkFalse(nCtx())); } /** @@ -733,7 +734,7 @@ import java.lang.Exception; CheckContextMatch(x); CheckContextMatch(y); - return new BoolExpr(this, Native.mkEq(nCtx, x.NativeObject, y.NativeObject)); + return new BoolExpr(this, Native.mkEq(nCtx(), x.NativeObject(), y.NativeObject())); } /** @@ -747,7 +748,7 @@ import java.lang.Exception; CheckContextMatch(args); - return new BoolExpr(this, Native.mkDistinct(nCtx, (long)args.Length, AST.ArrayToNative(args))); + return new BoolExpr(this, Native.mkDistinct(nCtx(), (int)args.length, AST.ArrayToNative(args))); } /** @@ -759,7 +760,7 @@ import java.lang.Exception; CheckContextMatch(a); - return new BoolExpr(this, Native.mkNot(nCtx, a.NativeObject)); + return new BoolExpr(this, Native.mkNot(nCtx(), a.NativeObject())); } /** @@ -778,7 +779,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); CheckContextMatch(t3); - return Expr.Create(this, Native.mkIte(nCtx, t1.NativeObject, t2.NativeObject, t3.NativeObject)); + return Expr.Create(this, Native.mkIte(nCtx(), t1.NativeObject(), t2.NativeObject(), t3.NativeObject())); } /** @@ -792,7 +793,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkIff(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkIff(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -806,7 +807,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkImplies(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkImplies(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -820,7 +821,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkXor(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkXor(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -833,7 +834,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BoolExpr(this, Native.mkAnd(nCtx, (long)t.Length, AST.ArrayToNative(t))); + return new BoolExpr(this, Native.mkAnd(nCtx(), (int)t.length, AST.ArrayToNative(t))); } /** @@ -846,7 +847,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BoolExpr(this, Native.mkOr(nCtx, (long)t.Length, AST.ArrayToNative(t))); + return new BoolExpr(this, Native.mkOr(nCtx(), (int)t.length, AST.ArrayToNative(t))); } /** @@ -859,7 +860,7 @@ import java.lang.Exception; CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkAdd(nCtx, (long)t.Length, AST.ArrayToNative(t))); + return (ArithExpr)Expr.Create(this, Native.mkAdd(nCtx(), (int)t.length, AST.ArrayToNative(t))); } /** @@ -872,7 +873,7 @@ import java.lang.Exception; CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkMul(nCtx, (long)t.Length, AST.ArrayToNative(t))); + return (ArithExpr)Expr.Create(this, Native.mkMul(nCtx(), (int)t.length, AST.ArrayToNative(t))); } /** @@ -885,7 +886,7 @@ import java.lang.Exception; CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkSub(nCtx, (long)t.Length, AST.ArrayToNative(t))); + return (ArithExpr)Expr.Create(this, Native.mkSub(nCtx(), (int)t.length, AST.ArrayToNative(t))); } /** @@ -897,7 +898,7 @@ import java.lang.Exception; CheckContextMatch(t); - return (ArithExpr)Expr.Create(this, Native.mkUnaryMinus(nCtx, t.NativeObject)); + return (ArithExpr)Expr.Create(this, Native.mkUnaryMinus(nCtx(), t.NativeObject())); } /** @@ -911,7 +912,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return (ArithExpr)Expr.Create(this, Native.mkDiv(nCtx, t1.NativeObject, t2.NativeObject)); + return (ArithExpr)Expr.Create(this, Native.mkDiv(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -926,7 +927,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new IntExpr(this, Native.mkMod(nCtx, t1.NativeObject, t2.NativeObject)); + return new IntExpr(this, Native.mkMod(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -941,7 +942,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new IntExpr(this, Native.mkRem(nCtx, t1.NativeObject, t2.NativeObject)); + return new IntExpr(this, Native.mkRem(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -955,7 +956,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return (ArithExpr)Expr.Create(this, Native.mkPower(nCtx, t1.NativeObject, t2.NativeObject)); + return (ArithExpr)Expr.Create(this, Native.mkPower(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -969,7 +970,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkLt(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkLt(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -983,7 +984,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkLe(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkLe(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -997,7 +998,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkGt(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkGt(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1011,7 +1012,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkGe(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkGe(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1030,7 +1031,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new RealExpr(this, Native.mkInt2real(nCtx, t.NativeObject)); + return new RealExpr(this, Native.mkInt2real(nCtx(), t.NativeObject())); } /** @@ -1046,7 +1047,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new IntExpr(this, Native.mkReal2int(nCtx, t.NativeObject)); + return new IntExpr(this, Native.mkReal2int(nCtx(), t.NativeObject())); } /** @@ -1058,7 +1059,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BoolExpr(this, Native.mkIsInt(nCtx, t.NativeObject)); + return new BoolExpr(this, Native.mkIsInt(nCtx(), t.NativeObject())); } /** @@ -1071,7 +1072,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvnot(nCtx, t.NativeObject)); + return new BitVecExpr(this, Native.mkBvnot(nCtx(), t.NativeObject())); } /** @@ -1084,7 +1085,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvredand(nCtx, t.NativeObject)); + return new BitVecExpr(this, Native.mkBvredand(nCtx(), t.NativeObject())); } /** @@ -1097,7 +1098,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvredor(nCtx, t.NativeObject)); + return new BitVecExpr(this, Native.mkBvredor(nCtx(), t.NativeObject())); } /** @@ -1112,7 +1113,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvand(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvand(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1127,7 +1128,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvor(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvor(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1142,7 +1143,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvxor(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvxor(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1157,7 +1158,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvnand(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvnand(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1172,7 +1173,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvnor(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvnor(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1187,7 +1188,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvxnor(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvxnor(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1200,7 +1201,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BitVecExpr(this, Native.mkBvneg(nCtx, t.NativeObject)); + return new BitVecExpr(this, Native.mkBvneg(nCtx(), t.NativeObject())); } /** @@ -1215,7 +1216,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvadd(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvadd(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1230,7 +1231,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsub(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvsub(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1245,7 +1246,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvmul(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvmul(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1265,7 +1266,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvudiv(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvudiv(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1289,7 +1290,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsdiv(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvsdiv(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1308,7 +1309,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvurem(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvurem(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1329,7 +1330,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsrem(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvsrem(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1347,7 +1348,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvsmod(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvsmod(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1364,7 +1365,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvult(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvult(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1381,7 +1382,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvslt(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvslt(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1398,7 +1399,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvule(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvule(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1415,7 +1416,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsle(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvsle(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1432,7 +1433,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvuge(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvuge(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1449,7 +1450,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsge(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvsge(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1466,7 +1467,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvugt(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvugt(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1483,7 +1484,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsgt(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvsgt(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1504,7 +1505,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkConcat(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkConcat(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1516,13 +1517,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkExtract(long high, long low, BitVecExpr t) + public BitVecExpr MkExtract(int high, int low, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkExtract(nCtx, high, low, t.NativeObject)); + return new BitVecExpr(this, Native.mkExtract(nCtx(), high, low, t.NativeObject())); } /** @@ -1533,13 +1534,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkSignExt(long i, BitVecExpr t) + public BitVecExpr MkSignExt(int i, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkSignExt(nCtx, i, t.NativeObject)); + return new BitVecExpr(this, Native.mkSignExt(nCtx(), i, t.NativeObject())); } /** @@ -1551,13 +1552,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkZeroExt(long i, BitVecExpr t) + public BitVecExpr MkZeroExt(int i, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkZeroExt(nCtx, i, t.NativeObject)); + return new BitVecExpr(this, Native.mkZeroExt(nCtx(), i, t.NativeObject())); } /** @@ -1566,13 +1567,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkRepeat(long i, BitVecExpr t) + public BitVecExpr MkRepeat(int i, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRepeat(nCtx, i, t.NativeObject)); + return new BitVecExpr(this, Native.mkRepeat(nCtx(), i, t.NativeObject())); } /** @@ -1595,7 +1596,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvshl(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvshl(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1618,7 +1619,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvlshr(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvlshr(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1643,7 +1644,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkBvashr(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkBvashr(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1653,13 +1654,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkBVRotateLeft(long i, BitVecExpr t) + public BitVecExpr MkBVRotateLeft(int i, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRotateLeft(nCtx, i, t.NativeObject)); + return new BitVecExpr(this, Native.mkRotateLeft(nCtx(), i, t.NativeObject())); } /** @@ -1669,13 +1670,13 @@ import java.lang.Exception; * The argument must have a bit-vector sort. * **/ - public BitVecExpr MkBVRotateRight(long i, BitVecExpr t) + public BitVecExpr MkBVRotateRight(int i, BitVecExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkRotateRight(nCtx, i, t.NativeObject)); + return new BitVecExpr(this, Native.mkRotateRight(nCtx(), i, t.NativeObject())); } /** @@ -1693,7 +1694,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkExtRotateLeft(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkExtRotateLeft(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1711,7 +1712,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BitVecExpr(this, Native.mkExtRotateRight(nCtx, t1.NativeObject, t2.NativeObject)); + return new BitVecExpr(this, Native.mkExtRotateRight(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1724,13 +1725,13 @@ import java.lang.Exception; * The argument must be of integer sort. * **/ - public BitVecExpr MkInt2BV(long n, IntExpr t) + public BitVecExpr MkInt2BV(int n, IntExpr t) { CheckContextMatch(t); - return new BitVecExpr(this, Native.mkInt2bv(nCtx, n, t.NativeObject)); + return new BitVecExpr(this, Native.mkInt2bv(nCtx(), n, t.NativeObject())); } /** @@ -1754,7 +1755,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new IntExpr(this, Native.mkBv2int(nCtx, t.NativeObject, (signed) ? 1 : 0)); + return new IntExpr(this, Native.mkBv2int(nCtx(), t.NativeObject(), (signed) ? true : false)); } /** @@ -1771,7 +1772,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvaddNoOverflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned) ? 1 : 0)); + return new BoolExpr(this, Native.mkBvaddNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); } /** @@ -1788,7 +1789,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvaddNoUnderflow(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvaddNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1805,7 +1806,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsubNoOverflow(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvsubNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1822,7 +1823,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsubNoUnderflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned) ? 1 : 0)); + return new BoolExpr(this, Native.mkBvsubNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); } /** @@ -1839,7 +1840,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvsdivNoOverflow(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvsdivNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1854,7 +1855,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new BoolExpr(this, Native.mkBvnegNoOverflow(nCtx, t.NativeObject)); + return new BoolExpr(this, Native.mkBvnegNoOverflow(nCtx(), t.NativeObject())); } /** @@ -1871,7 +1872,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvmulNoOverflow(nCtx, t1.NativeObject, t2.NativeObject, (isSigned) ? 1 : 0)); + return new BoolExpr(this, Native.mkBvmulNoOverflow(nCtx(), t1.NativeObject(), t2.NativeObject(), (isSigned) ? true : false)); } /** @@ -1888,7 +1889,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new BoolExpr(this, Native.mkBvmulNoUnderflow(nCtx, t1.NativeObject, t2.NativeObject)); + return new BoolExpr(this, Native.mkBvmulNoUnderflow(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -1937,7 +1938,7 @@ import java.lang.Exception; CheckContextMatch(a); CheckContextMatch(i); - return Expr.Create(this, Native.mkSelect(nCtx, a.NativeObject, i.NativeObject)); + return Expr.Create(this, Native.mkSelect(nCtx(), a.NativeObject(), i.NativeObject())); } /** @@ -1967,7 +1968,7 @@ import java.lang.Exception; CheckContextMatch(a); CheckContextMatch(i); CheckContextMatch(v); - return new ArrayExpr(this, Native.mkStore(nCtx, a.NativeObject, i.NativeObject, v.NativeObject)); + return new ArrayExpr(this, Native.mkStore(nCtx(), a.NativeObject(), i.NativeObject(), v.NativeObject())); } /** @@ -1987,7 +1988,7 @@ import java.lang.Exception; CheckContextMatch(domain); CheckContextMatch(v); - return new ArrayExpr(this, Native.mkConstArray(nCtx, domain.NativeObject, v.NativeObject)); + return new ArrayExpr(this, Native.mkConstArray(nCtx(), domain.NativeObject(), v.NativeObject())); } /** @@ -2009,7 +2010,7 @@ import java.lang.Exception; CheckContextMatch(f); CheckContextMatch(args); - return (ArrayExpr)Expr.Create(this, Native.mkMap(nCtx, f.NativeObject, AST.ArrayLength(args), AST.ArrayToNative(args))); + return (ArrayExpr)Expr.Create(this, Native.mkMap(nCtx(), f.NativeObject(), AST.ArrayLength(args), AST.ArrayToNative(args))); } /** @@ -2025,7 +2026,7 @@ import java.lang.Exception; CheckContextMatch(array); - return Expr.Create(this, Native.mkArrayDefault(nCtx, array.NativeObject)); + return Expr.Create(this, Native.mkArrayDefault(nCtx(), array.NativeObject())); } /** @@ -2049,7 +2050,7 @@ import java.lang.Exception; CheckContextMatch(domain); - return Expr.Create(this, Native.mkEmptySet(nCtx, domain.NativeObject)); + return Expr.Create(this, Native.mkEmptySet(nCtx(), domain.NativeObject())); } /** @@ -2061,7 +2062,7 @@ import java.lang.Exception; CheckContextMatch(domain); - return Expr.Create(this, Native.mkFullSet(nCtx, domain.NativeObject)); + return Expr.Create(this, Native.mkFullSet(nCtx(), domain.NativeObject())); } /** @@ -2075,7 +2076,7 @@ import java.lang.Exception; CheckContextMatch(set); CheckContextMatch(element); - return Expr.Create(this, Native.mkSetAdd(nCtx, set.NativeObject, element.NativeObject)); + return Expr.Create(this, Native.mkSetAdd(nCtx(), set.NativeObject(), element.NativeObject())); } @@ -2090,7 +2091,7 @@ import java.lang.Exception; CheckContextMatch(set); CheckContextMatch(element); - return Expr.Create(this, Native.mkSetDel(nCtx, set.NativeObject, element.NativeObject)); + return Expr.Create(this, Native.mkSetDel(nCtx(), set.NativeObject(), element.NativeObject())); } /** @@ -2102,7 +2103,7 @@ import java.lang.Exception; CheckContextMatch(args); - return Expr.Create(this, Native.mkSetUnion(nCtx, (long)args.Length, AST.ArrayToNative(args))); + return Expr.Create(this, Native.mkSetUnion(nCtx(), (int)args.length, AST.ArrayToNative(args))); } /** @@ -2115,7 +2116,7 @@ import java.lang.Exception; CheckContextMatch(args); - return Expr.Create(this, Native.mkSetIntersect(nCtx, (long)args.Length, AST.ArrayToNative(args))); + return Expr.Create(this, Native.mkSetIntersect(nCtx(), (int)args.length, AST.ArrayToNative(args))); } /** @@ -2129,7 +2130,7 @@ import java.lang.Exception; CheckContextMatch(arg1); CheckContextMatch(arg2); - return Expr.Create(this, Native.mkSetDifference(nCtx, arg1.NativeObject, arg2.NativeObject)); + return Expr.Create(this, Native.mkSetDifference(nCtx(), arg1.NativeObject(), arg2.NativeObject())); } /** @@ -2141,7 +2142,7 @@ import java.lang.Exception; CheckContextMatch(arg); - return Expr.Create(this, Native.mkSetComplement(nCtx, arg.NativeObject)); + return Expr.Create(this, Native.mkSetComplement(nCtx(), arg.NativeObject())); } /** @@ -2155,7 +2156,7 @@ import java.lang.Exception; CheckContextMatch(elem); CheckContextMatch(set); - return Expr.Create(this, Native.mkSetMember(nCtx, elem.NativeObject, set.NativeObject)); + return Expr.Create(this, Native.mkSetMember(nCtx(), elem.NativeObject(), set.NativeObject())); } /** @@ -2169,7 +2170,7 @@ import java.lang.Exception; CheckContextMatch(arg1); CheckContextMatch(arg2); - return Expr.Create(this, Native.mkSetSubset(nCtx, arg1.NativeObject, arg2.NativeObject)); + return Expr.Create(this, Native.mkSetSubset(nCtx(), arg1.NativeObject(), arg2.NativeObject())); } @@ -2185,7 +2186,7 @@ import java.lang.Exception; CheckContextMatch(ty); - return Expr.Create(this, Native.mkNumeral(nCtx, v, ty.NativeObject)); + return Expr.Create(this, Native.mkNumeral(nCtx(), v, ty.NativeObject())); } /** @@ -2201,9 +2202,18 @@ import java.lang.Exception; CheckContextMatch(ty); - return Expr.Create(this, Native.mkInt(nCtx, v, ty.NativeObject)); + 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 + **/ + /* Not translated because it would translate to a function with clashing types. */ + /** * 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. @@ -2217,7 +2227,7 @@ import java.lang.Exception; CheckContextMatch(ty); - return Expr.Create(this, Native.mkUnsignedInt(nCtx, v, ty.NativeObject)); + return Expr.Create(this, Native.mkInt64(nCtx(), v, ty.NativeObject())); } /** @@ -2227,30 +2237,7 @@ import java.lang.Exception; * 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 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.mkUnsignedInt64(nCtx, v, ty.NativeObject)); - } + /* Not translated because it would translate to a function with clashing types. */ /** * Create a real from a fraction. @@ -2267,7 +2254,7 @@ import java.lang.Exception; - return new RatNum(this, Native.mkReal(nCtx, num, den)); + return new RatNum(this, Native.mkReal(nCtx(), num, den)); } /** @@ -2279,7 +2266,7 @@ import java.lang.Exception; { - return new RatNum(this, Native.mkNumeral(nCtx, v, RealSort.NativeObject)); + return new RatNum(this, Native.mkNumeral(nCtx(), v, RealSort().NativeObject())); } /** @@ -2291,9 +2278,16 @@ import java.lang.Exception; { - return new RatNum(this, Native.mkInt(nCtx, v, RealSort.NativeObject)); + 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 + **/ + /* Not translated because it would translate to a function with clashing types. */ + /** * Create a real numeral. * value of the numeral. @@ -2303,7 +2297,7 @@ import java.lang.Exception; { - return new RatNum(this, Native.mkUnsignedInt(nCtx, v, RealSort.NativeObject)); + return new RatNum(this, Native.mkInt64(nCtx(), v, RealSort().NativeObject())); } /** @@ -2311,24 +2305,7 @@ import java.lang.Exception; * 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 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.mkUnsignedInt64(nCtx, v, RealSort.NativeObject)); - } + /* Not translated because it would translate to a function with clashing types. */ /** * Create an integer numeral. @@ -2338,7 +2315,7 @@ import java.lang.Exception; { - return new IntNum(this, Native.mkNumeral(nCtx, v, IntSort.NativeObject)); + return new IntNum(this, Native.mkNumeral(nCtx(), v, IntSort().NativeObject())); } /** @@ -2350,9 +2327,16 @@ import java.lang.Exception; { - return new IntNum(this, Native.mkInt(nCtx, v, IntSort.NativeObject)); + 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 + **/ + /* Not translated because it would translate to a function with clashing types. */ + /** * Create an integer numeral. * value of the numeral. @@ -2362,7 +2346,7 @@ import java.lang.Exception; { - return new IntNum(this, Native.mkUnsignedInt(nCtx, v, IntSort.NativeObject)); + return new IntNum(this, Native.mkInt64(nCtx(), v, IntSort().NativeObject())); } /** @@ -2370,31 +2354,14 @@ import java.lang.Exception; * 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 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.mkUnsignedInt64(nCtx, v, IntSort.NativeObject)); - } + /* Not translated because it would translate to a function with clashing types. */ /** * Create a bit-vector numeral. * A string representing the value in decimal notation. * the size of the bit-vector **/ - public BitVecNum MkBV(String v, long size) + public BitVecNum MkBV(String v, int size) { @@ -2406,7 +2373,7 @@ import java.lang.Exception; * value of the numeral. * the size of the bit-vector **/ - public BitVecNum MkBV(int v, long size) + public BitVecNum MkBV(int v, int size) { @@ -2418,19 +2385,14 @@ import java.lang.Exception; * value of the numeral. * the size of the bit-vector **/ - public BitVecNum MkBV(long v, long size) - { - - - return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); - } + /* Not translated because it would translate to a function with clashing types. */ /** * Create a bit-vector numeral. * value of the numeral. * * the size of the bit-vector **/ - public BitVecNum MkBV(long v, long size) + public BitVecNum MkBV(long v, int size) { @@ -2442,12 +2404,7 @@ import java.lang.Exception; * value of the numeral. * the size of the bit-vector **/ - public BitVecNum MkBV(long v, long size) - { - - - return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); - } + /* Not translated because it would translate to a function with clashing types. */ /** @@ -2469,7 +2426,7 @@ import java.lang.Exception; * optional symbol to track quantifier. * optional symbol to track skolem constants. **/ - public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkForall(Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2489,7 +2446,7 @@ import java.lang.Exception; /** * Create a universal Quantifier. **/ - public Quantifier MkForall(Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkForall(Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2505,7 +2462,7 @@ import java.lang.Exception; * Create an existential Quantifier. * **/ - public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2523,7 +2480,7 @@ import java.lang.Exception; /** * Create an existential Quantifier. **/ - public Quantifier MkExists(Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkExists(Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2538,7 +2495,7 @@ import java.lang.Exception; /** * Create a Quantifier. **/ - public Quantifier MkQuantifier(boolean universal, Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkQuantifier(boolean universal, Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2561,7 +2518,7 @@ import java.lang.Exception; /** * Create a Quantifier. **/ - public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + public Quantifier MkQuantifier(boolean universal, Expr[] boundConstants, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { @@ -2594,7 +2551,7 @@ import java.lang.Exception; * * **/ - public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx, (long)value); } + public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx(), (int)value); } /** * Convert a benchmark into an SMT-LIB formatted string. @@ -2613,9 +2570,9 @@ import java.lang.Exception; - return Native.benchmarkToSmtlibString(nCtx, name, logic, status, attributes, - (long)assumptions.Length, AST.ArrayToNative(assumptions), - formula.NativeObject); + return Native.benchmarkToSmtlibString(nCtx(), name, logic, status, attributes, + (int)assumptions.length, AST.ArrayToNative(assumptions), + formula.NativeObject()); } /** @@ -2630,13 +2587,13 @@ import java.lang.Exception; **/ public void ParseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) { - long csn = Symbol.ArrayLength(sortNames); - long cs = Sort.ArrayLength(sorts); - long cdn = Symbol.ArrayLength(declNames); - long cd = AST.ArrayLength(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, + Native.parseSmtlibString(nCtx(), str, AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); } @@ -2647,13 +2604,13 @@ import java.lang.Exception; **/ public void ParseSMTLIBFile(String fileName, Symbol[] sortNames, Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) { - long csn = Symbol.ArrayLength(sortNames); - long cs = Sort.ArrayLength(sorts); - long cdn = Symbol.ArrayLength(declNames); - long cd = AST.ArrayLength(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, + Native.parseSmtlibFile(nCtx(), fileName, AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); } @@ -2661,7 +2618,7 @@ import java.lang.Exception; /** * The number of SMTLIB formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. **/ - public long NumSMTLIBFormulas () { return Native.getSmtlibNumFormulas(nCtx); } + public int NumSMTLIBFormulas () { return Native.getSmtlibNumFormulas(nCtx()); } /** * The formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. @@ -2670,17 +2627,17 @@ import java.lang.Exception; { - long n = NumSMTLIBFormulas; + int n = NumSMTLIBFormulas(); BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibFormula(nCtx, i)); + 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 long NumSMTLIBAssumptions () { return Native.getSmtlibNumAssumptions(nCtx); } + public int NumSMTLIBAssumptions () { return Native.getSmtlibNumAssumptions(nCtx()); } /** * The assumptions parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. @@ -2689,17 +2646,17 @@ import java.lang.Exception; { - long n = NumSMTLIBAssumptions; + int n = NumSMTLIBAssumptions(); BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.getSmtlibAssumption(nCtx, i)); + 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 long NumSMTLIBDecls () { return Native.getSmtlibNumDecls(nCtx); } + public int NumSMTLIBDecls () { return Native.getSmtlibNumDecls(nCtx()); } /** * The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. @@ -2708,17 +2665,17 @@ import java.lang.Exception; { - long n = NumSMTLIBDecls; + int n = NumSMTLIBDecls(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx, i)); + 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 long NumSMTLIBSorts () { return Native.getSmtlibNumSorts(nCtx); } + public int NumSMTLIBSorts () { return Native.getSmtlibNumSorts(nCtx()); } /** * The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. @@ -2727,10 +2684,10 @@ import java.lang.Exception; { - long n = NumSMTLIBSorts; + int n = NumSMTLIBSorts(); Sort[] res = new Sort[n]; - for (long i; i < n; i++) - res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx, i)); + for (int i = 0; i < n; i++) + res[i] = Sort.Create(this, Native.getSmtlibSort(nCtx(), i)); return res; } @@ -2743,13 +2700,13 @@ import java.lang.Exception; { - long csn = Symbol.ArrayLength(sortNames); - long cs = Sort.ArrayLength(sorts); - long cdn = Symbol.ArrayLength(declNames); - long cd = AST.ArrayLength(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, + 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))); } @@ -2762,13 +2719,13 @@ import java.lang.Exception; { - long csn = Symbol.ArrayLength(sortNames); - long cs = Sort.ArrayLength(sorts); - long cdn = Symbol.ArrayLength(declNames); - long cd = AST.ArrayLength(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, + 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))); } @@ -2803,7 +2760,7 @@ import java.lang.Exception; /** * The number of supported tactics. **/ - public long NumTactics() { return Native.getNumTactics(nCtx); } + public int NumTactics() { return Native.getNumTactics(nCtx()); } /** * The names of all supported tactics. @@ -2812,10 +2769,10 @@ import java.lang.Exception; { - long n = NumTactics; + int n = NumTactics(); String[] res = new String[n]; - for (long i; i < n; i++) - res[i] = Native.getTacticName(nCtx, i); + for (int i = 0; i < n; i++) + res[i] = Native.getTacticName(nCtx(), i); return res; } @@ -2826,7 +2783,7 @@ import java.lang.Exception; { - return Native.tacticGetDescr(nCtx, name); + return Native.tacticGetDescr(nCtx(), name); } /** @@ -2856,19 +2813,19 @@ import java.lang.Exception; CheckContextMatch(ts); long last = 0; - if (ts != null && ts.Length > 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); + 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)); + 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)); + return new Tactic(this, Native.tacticAndThen(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -2900,7 +2857,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new Tactic(this, Native.tacticOrElse(nCtx, t1.NativeObject, t2.NativeObject)); + return new Tactic(this, Native.tacticOrElse(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -2909,13 +2866,13 @@ import java.lang.Exception; * If does not terminate within milliseconds, then it fails. * **/ - public Tactic TryFor(Tactic t, long ms) + public Tactic TryFor(Tactic t, int ms) { CheckContextMatch(t); - return new Tactic(this, Native.tacticTryFor(nCtx, t.NativeObject, ms)); + return new Tactic(this, Native.tacticTryFor(nCtx(), t.NativeObject(), ms)); } /** @@ -2933,7 +2890,7 @@ import java.lang.Exception; CheckContextMatch(t); CheckContextMatch(p); - return new Tactic(this, Native.tacticWhen(nCtx, p.NativeObject, t.NativeObject)); + return new Tactic(this, Native.tacticWhen(nCtx(), p.NativeObject(), t.NativeObject())); } /** @@ -2950,20 +2907,20 @@ import java.lang.Exception; CheckContextMatch(p); CheckContextMatch(t1); CheckContextMatch(t2); - return new Tactic(this, Native.tacticCond(nCtx, p.NativeObject, t1.NativeObject, t2.NativeObject)); + 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, long max) + public Tactic Repeat(Tactic t, int max) { CheckContextMatch(t); - return new Tactic(this, Native.tacticRepeat(nCtx, t.NativeObject, max)); + return new Tactic(this, Native.tacticRepeat(nCtx(), t.NativeObject(), max)); } /** @@ -2973,7 +2930,7 @@ import java.lang.Exception; { - return new Tactic(this, Native.tacticSkip(nCtx)); + return new Tactic(this, Native.tacticSkip(nCtx())); } /** @@ -2983,7 +2940,7 @@ import java.lang.Exception; { - return new Tactic(this, Native.tacticFail(nCtx)); + return new Tactic(this, Native.tacticFail(nCtx())); } /** @@ -2995,7 +2952,7 @@ import java.lang.Exception; CheckContextMatch(p); - return new Tactic(this, Native.tacticFailIf(nCtx, p.NativeObject)); + return new Tactic(this, Native.tacticFailIf(nCtx(), p.NativeObject())); } /** @@ -3006,7 +2963,7 @@ import java.lang.Exception; { - return new Tactic(this, Native.tacticFailIfNotDecided(nCtx)); + return new Tactic(this, Native.tacticFailIfNotDecided(nCtx())); } /** @@ -3020,7 +2977,7 @@ import java.lang.Exception; CheckContextMatch(t); CheckContextMatch(p); - return new Tactic(this, Native.tacticUsingParams(nCtx, t.NativeObject, p.NativeObject)); + return new Tactic(this, Native.tacticUsingParams(nCtx(), t.NativeObject(), p.NativeObject())); } /** @@ -3045,7 +3002,7 @@ import java.lang.Exception; CheckContextMatch(t); - return new Tactic(this, Native.tacticParOr(nCtx, Tactic.ArrayLength(t), Tactic.ArrayToNative(t))); + return new Tactic(this, Native.tacticParOr(nCtx(), Tactic.ArrayLength(t), Tactic.ArrayToNative(t))); } /** @@ -3060,7 +3017,7 @@ import java.lang.Exception; CheckContextMatch(t1); CheckContextMatch(t2); - return new Tactic(this, Native.tacticParAndThen(nCtx, t1.NativeObject, t2.NativeObject)); + return new Tactic(this, Native.tacticParAndThen(nCtx(), t1.NativeObject(), t2.NativeObject())); } /** @@ -3069,13 +3026,13 @@ import java.lang.Exception; **/ public void Interrupt() { - Native.interrupt(nCtx); + Native.interrupt(nCtx()); } /** * The number of supported Probes. **/ - public long NumProbes() { return Native.getNumProbes(nCtx); } + public int NumProbes() { return Native.getNumProbes(nCtx()); } /** * The names of all supported Probes. @@ -3084,10 +3041,10 @@ import java.lang.Exception; { - long n = NumProbes; + int n = NumProbes(); String[] res = new String[n]; - for (long i; i < n; i++) - res[i] = Native.getProbeName(nCtx, i); + for (int i = 0; i < n; i++) + res[i] = Native.getProbeName(nCtx(), i); return res; } @@ -3098,7 +3055,7 @@ import java.lang.Exception; { - return Native.probeGetDescr(nCtx, name); + return Native.probeGetDescr(nCtx(), name); } /** @@ -3118,7 +3075,7 @@ import java.lang.Exception; { - return new Probe(this, Native.probeConst(nCtx, val)); + return new Probe(this, Native.probeConst(nCtx(), val)); } /** @@ -3133,7 +3090,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeLt(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeLt(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3148,7 +3105,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeGt(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeGt(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3163,7 +3120,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeLe(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeLe(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3178,7 +3135,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeGe(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeGe(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3193,7 +3150,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeEq(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeEq(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3208,7 +3165,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeAnd(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeAnd(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3223,7 +3180,7 @@ import java.lang.Exception; CheckContextMatch(p1); CheckContextMatch(p2); - return new Probe(this, Native.probeOr(nCtx, p1.NativeObject, p2.NativeObject)); + return new Probe(this, Native.probeOr(nCtx(), p1.NativeObject(), p2.NativeObject())); } /** @@ -3236,7 +3193,7 @@ import java.lang.Exception; CheckContextMatch(p); - return new Probe(this, Native.probeNot(nCtx, p.NativeObject)); + return new Probe(this, Native.probeNot(nCtx(), p.NativeObject())); } /** @@ -3252,9 +3209,9 @@ import java.lang.Exception; if (logic == null) - return new Solver(this, Native.mkSolver(nCtx)); + return new Solver(this, Native.mkSolver(nCtx())); else - return new Solver(this, Native.mkSolverForLogic(nCtx, logic.NativeObject)); + return new Solver(this, Native.mkSolverForLogic(nCtx(), logic.NativeObject())); } /** @@ -3275,7 +3232,7 @@ import java.lang.Exception; { - return new Solver(this, Native.mkSimpleSolver(nCtx)); + return new Solver(this, Native.mkSimpleSolver(nCtx())); } /** @@ -3290,7 +3247,7 @@ import java.lang.Exception; - return new Solver(this, Native.mkSolverFromTactic(nCtx, t.NativeObject)); + return new Solver(this, Native.mkSolverFromTactic(nCtx(), t.NativeObject())); } /** @@ -3343,13 +3300,13 @@ import java.lang.Exception; { - return Native.simplifyGetHelp(nCtx); + return Native.simplifyGetHelp(nCtx()); } /** * Retrieves parameter descriptions for simplifier. **/ - public ParamDescrs SimplifyParameterDescriptions() { return new ParamDescrs(this, Native.simplifyGetParamDescrs(nCtx)); } + public ParamDescrs SimplifyParameterDescriptions() { return new ParamDescrs(this, Native.simplifyGetParamDescrs(nCtx())); } /** * Enable/disable printing of warning messages to the console. @@ -3358,7 +3315,7 @@ import java.lang.Exception; **/ public static void ToggleWarningMessages(boolean enabled) { - Native.toggleWarningMessages((enabled) ? 1 : 0); + Native.toggleWarningMessages((enabled) ? true : false); } ///// @@ -3387,7 +3344,7 @@ import java.lang.Exception; **/ public void UpdateParamValue(String id, String value) { - Native.updateParamValue(nCtx, id, value); + Native.updateParamValue(nCtx(), id, value); } /** @@ -3400,8 +3357,8 @@ import java.lang.Exception; public String GetParamValue(String id) { long res = 0; - int r = Native.getParamValue(nCtx, id, res); - if (r == (int)Z3_lbool.Z3_L_FALSE) + int r = Native.getParamValue(nCtx(), id, res); + if (r == Z3_lbool.Z3_L_FALSE.toInt()) return null; else return Marshal.PtrToStringAnsi(res); @@ -3439,7 +3396,7 @@ import java.lang.Exception; if (arr != null) { - for (Iterator a = arr.iterator(); a.hasNext(); ) + for (Z3Object a: arr) { // It was an assume, now we added the precondition, and we made it into an assert CheckContextMatch(a); @@ -3499,7 +3456,7 @@ import java.lang.Exception; Fixedpoint.DecRefQueue Fixedpoint_DRQ () { return m_Fixedpoint_DRQ; } - long refCount = 0; + int refCount = 0; /** * Finalizer. diff --git a/src/api/java/com/Microsoft/Z3/DatatypeExpr.java b/src/api/java/com/Microsoft/Z3/DatatypeExpr.java index 4b18635cc..32835baf5 100644 --- a/src/api/java/com/Microsoft/Z3/DatatypeExpr.java +++ b/src/api/java/com/Microsoft/Z3/DatatypeExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/DatatypeSort.java b/src/api/java/com/Microsoft/Z3/DatatypeSort.java index c108c3de9..4d2dd8992 100644 --- a/src/api/java/com/Microsoft/Z3/DatatypeSort.java +++ b/src/api/java/com/Microsoft/Z3/DatatypeSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,7 +19,7 @@ import java.lang.Exception; /** * The number of constructors of the datatype sort. **/ - public long NumConstructors() { return Native.getDatatypeSortNumConstructors(Context().nCtx(), NativeObject()); } + public int NumConstructors() { return Native.getDatatypeSortNumConstructors(Context().nCtx(), NativeObject()); } /** * The constructors. @@ -27,10 +28,10 @@ import java.lang.Exception; { - long n = NumConstructors; + int n = NumConstructors(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = new FuncDecl(Context(), Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); return res; } @@ -41,10 +42,10 @@ import java.lang.Exception; { - long n = NumConstructors; + int n = NumConstructors(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(Context, Native.getDatatypeSortRecognizer(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = new FuncDecl(Context(), Native.getDatatypeSortRecognizer(Context().nCtx(), NativeObject(), i)); return res; } @@ -55,15 +56,15 @@ import java.lang.Exception; { - long n = NumConstructors; + int n = NumConstructors(); FuncDecl[][] res = new FuncDecl[n][]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) { - FuncDecl fd = new FuncDecl(Context, Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); - long ds = fd.DomainSize; + FuncDecl fd = new FuncDecl(Context(), Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); + int ds = fd.DomainSize; FuncDecl[] tmp = new FuncDecl[ds]; - for (long j; j < ds; j++) - tmp[j] = new FuncDecl(Context, Native.getDatatypeSortConstructorAccessor(Context().nCtx(), NativeObject(), i, j)); + for (int j = 0; j < ds; j++) + tmp[j] = new FuncDecl(Context(), Native.getDatatypeSortConstructorAccessor(Context().nCtx(), NativeObject(), i, j)); res[i] = tmp; } return res; @@ -72,7 +73,7 @@ import java.lang.Exception; DatatypeSort(Context ctx, long obj) { super(ctx, obj); { }} DatatypeSort(Context ctx, Symbol name, Constructor[] constructors) - { super(ctx, Native.mkDatatype(ctx.nCtx(), name.NativeObject, (long)constructors.Length, ArrayToNative(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 index 77e0ac057..cfb9d099a 100644 --- a/src/api/java/com/Microsoft/Z3/EnumSort.java +++ b/src/api/java/com/Microsoft/Z3/EnumSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -64,19 +65,19 @@ import java.lang.Exception; - int n = enumNames.Length; + int n = enumNames.length; long[] n_constdecls = new long[n]; long[] n_testers = new long[n]; - NativeObject() = Native.mkEnumerationSort(ctx.nCtx(), name.NativeObject, (long)n, + NativeObject() = Native.mkEnumerationSort(ctx.nCtx(), name.NativeObject(), (int)n, Symbol.ArrayToNative(enumNames), n_constdecls, n_testers); _constdecls = new FuncDecl[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) _constdecls[i] = new FuncDecl(ctx, n_constdecls[i]); _testerdecls = new FuncDecl[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) _testerdecls[i] = new FuncDecl(ctx, n_testers[i]); _consts = new Expr[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) _consts[i] = ctx.MkApp(_constdecls[i]); } }; 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 new file mode 100644 index 0000000000000000000000000000000000000000..b94349266d87b21f5cf6913260d2d8b2706e7ef0 GIT binary patch literal 1554 zcmah}U2_s=6n@e7Joti zMDIGi=}j*zw$*8;j@O;(?`VHQuWZkGp-QKYVVLveIqx~|dCoa6`R(P;&jGBV5`c%08lVhh^&Nr?X@}-fBW6IUt!d`CdU=g|7w@0T&+x2Qr zXV4N5MFD-KmMc{Yw!qToC&|+uab92GTrzcHu$u4QryA3xw%aNXjt^SBednM<9$ns2 zITTn;mL52doNUK&kFvJcYr97qsS`zPw%xY3C9v>@>|!xh6A0MtBiHc;J*uWArAt5T zb&rd#$J&c0)|j$Ar}=Q#`9eyj_aWf-x-wl!rf6!$X0tPvK@KW;d7_hoJ2>8admCG{ zY}4)zdd=2On}@<{{P!VT;-OeL&(Ctj!Yz~p;%|F77E;)?kU`nPIV@YafOnW)v=Bwi z!WlMkHVHP1Y?j!ZMNA;{dIzkWT5Wc^E@?WIOigrEIe5@&dZhd6JIZnaLQ*V|L`x*y5=pv5QZJDjpv)QW8VJXDX2dlF zcmxo5m)J5Pf6O7oPw>5f@|c)FlB_1rOo~q-J&r#QpY#T2p{Ad~{{rg&6MQ^g3giM8 zp->BemCnSULQ5xpg#P`j5+OPT=BU&>f>^+N#C*6!t!8m~T(U_XKlwAyV3ab?uPIxJ z_&11U607TKRQ&;Z>}zOI_3@XA`1bEVC`eglNj}-bj4U3*EKQB)a)DNTg-)sPO9XVR z3NiN=T_2(Udhd@5CJ1>d{xn_w9sMymjwKkliVw!2ze{DnSHD25&jb|zQl+03f z$)+R=`8CO=B@1g2J>JU?Q-9N;% zUDt+)*mZq~S-WlwF=yAq*w_wuDMho~5 KA5p9iAO8c?E;F(K literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java index 2ba3f58ab..66841c073 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java @@ -8,12 +8,26 @@ package com.Microsoft.Z3; * Z3_ast_kind **/ public enum Z3_ast_kind { -Z3_VAR_AST (2), -Z3_SORT_AST (4), -Z3_QUANTIFIER_AST (3), -Z3_UNKNOWN_AST (1000), -Z3_FUNC_DECL_AST (5), -Z3_NUMERAL_AST (0), -Z3_APP_AST (1), + Z3_VAR_AST (2), + Z3_SORT_AST (4), + Z3_QUANTIFIER_AST (3), + Z3_UNKNOWN_AST (1000), + Z3_FUNC_DECL_AST (5), + Z3_NUMERAL_AST (0), + Z3_APP_AST (1); + + private final int intValue; + + Z3_ast_kind(int v) { + this.intValue = v; + } + + public static final Z3_ast_kind fromInt(int v) { + for (Z3_ast_kind k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..b146851186dd99083b4d89fb22e2806242d7b710 GIT binary patch literal 1450 zcma)5Sx*yD6#i~!I@4v?3beFrr?>unPGUY%!w-0$_+JR1PXB_ZyJL`at+c_2U41w+O)W+lZS|VkvCiM8ySSq%@ zx}nDx*Afhadb*g8u4dDvV!60$MYqT4O_^mYbx_I{tW>`EJTt@KztW?=MaR{>l}%k| z@LYuT^(QHPIk`+h2lY&vxk`qC#TnGWpi-yj{4$8eKYMeMmKzYn)+`2(ugXGyTM1XH&xHd9P5j({rr*P0Us*)M;98h8!GFCV><*xO$}C`lUQkZgj3M-2B-`!4c*qIHmVY4ACmDng8P{-pM8 z2qRJ($hG0B*u&KP9evcx(E|r@x?4+qDUbnAzd+vdI3?u-u4A}`r^$BVH3_fTE(xzi zc&&;oyf*bK6-rgOjV-x~CS%K9MT@beRMBP}gIy}+6_eZqoL|i*g4>KKxQON-%|;Lv Hr0@L(7U?iQ literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java index 4aa4a2716..bfbbadd96 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java @@ -8,9 +8,23 @@ package com.Microsoft.Z3; * Z3_ast_print_mode **/ public enum Z3_ast_print_mode { -Z3_PRINT_SMTLIB2_COMPLIANT (3), -Z3_PRINT_SMTLIB_COMPLIANT (2), -Z3_PRINT_SMTLIB_FULL (0), -Z3_PRINT_LOW_LEVEL (1), + Z3_PRINT_SMTLIB2_COMPLIANT (3), + Z3_PRINT_SMTLIB_COMPLIANT (2), + Z3_PRINT_SMTLIB_FULL (0), + Z3_PRINT_LOW_LEVEL (1); + + private final int intValue; + + Z3_ast_print_mode(int v) { + this.intValue = v; + } + + public static final Z3_ast_print_mode fromInt(int v) { + for (Z3_ast_print_mode k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..6ba48582b09a7ce99f5d1804b4315c22fd15a14f GIT binary patch literal 11227 zcmai)2Y6i7vBzh2@7+C;W&0fWiW|ngV~o33(n?x;rImLj+j3jWa+8bXPBHEc<8IS? z@Ac3j^xj(t=?NhO(nAOV!b^BFbC0y*z4tx7kMIA}{oiv>otb+j^Xh*ddlCS~gihvx zhkwq;zu;e^_(2r^mX8zgGnT*eozL@0{-JOp^9y$VscVdPW*UWanC%qSFxxAf%j}?V z90tkqXaZj#79wbF{*9m}3;4%RF7-7Uo!m=P}PvxRp6h;Wp-(3b!-I zE8M}Hpl~O1qQYIwNeXu}Co9~;oT6|qbE?99%xMbuGh+(RXBH|vz${XD0kc@)L1tXx zA!dof!^~2JN0?;_k1`Vqk1?k!JkFe<@B}ldkYhYluJA%;g~E%NDTNm^D-~YCoT>0q zW?JE8%#6aznN(?N%tZ=sVb&_VmAP2qZOl4_w=8G^h9hyl|MM*YO6(g^8;H6{P>8V5of(ovaG|RTZ zkC}K?mS&own{HOrL3KrOyrlVQ9y(S*Gi!R9Ms{tfWA|{=R9Y^fusR(tAKARRRD32v z$L3jqVBBsG=jwq>|O#8A3ZZK&mQM70;#~g|3{N*?$n)2F&|-3s9VM0 zqw;FnOqY;Btd++qn`iDO>Q+blR#sD)sw#_T5|lUYDN4k2ydqYfTaaX|%m1nr-Q~#o z?qVua)IlzE=!x$hIOS6=yQ(QvY4)y1nne&;O}kqm<8^J$ZjKzP4b_==aduWL{hgUM zC9Zq6q&Ul)p9_?Dd1Z?zk`!^<8LOzy#iQ(6)25g5e!9|G$VW|c%`L5}EK4C@9?KoY z98McIWN{)>m8jrY$>lI-UP&yO$yK7lS)-*OyP&7Ko&8Rr(+KGp&&n-JGKOxu{Gi~cyv@)t6j3BM#}%hXQ+Hf{o4ZR;+9%?4 z5N^vd5~nU2OKF`=AuA{8(n4NnZkuA6tORGvpv%OQl4NdCGNGncO|!_z3A%xJrk$Fj zgd#c4Z%!)1vuFnHiCC!|b1vX3t21RyWwyCjiOyU=^MT15#?6*?%N@CE!)1XEfY7|7 zO|y3`D2Xc5sp+zyrp=IqcLz{io}hqkE*Y}9?iOX31V?VpO|>gS!!_-=1gTpT)u*@g53Vo zyP&+9UU=WF+wziY&ZQvlTf9JuX{+N@ZHjWaL2DmfNN+M1HIiJpTF~-MADmJ1?s7Ue zohVnBmhY7E6uk~o6^SBwr{q$TUmLMGiB#@Um#A)CEi%)+#ydCf5T|-NQAqFn;7#R% zC6g$v2)@K}!(?WpD1Z`kb8%V7ug>Pz44qQTSE;IR*f^_p^`@l=m_Uf0IxCi}=5*^l z?|VNYBb)ib4G4V)4*LGqUQy!`8l`QrzF}#_rZtO~uCJ~3YE?eKY zCeg5wXP@}~L0V@v*4C{muU#vXravhl_!}GL`S8F&v~y}w-D)=vGHA?EE!Glm*tBNS z_bg-zeU|5E8aJ)4TUt`j`@%WU{LMa`H>Lo8#DB~9pdfTKbPS>A|NE6+fIkl%FTh`h zP88q|@%;k)G5&-u@mB>n5hoSkWR@u`Q(305#8?Vhidc$S;w&XBr7UGE36|+BGgy)= znJj6R3`-SDHOnlP*(`HdYFOs7%ww6)vVdhFOO|C3OD)S{mO7RtEK6CI zu`Fj;ImB|9kFq?*@;J*6Se{^clI1Cur&*q1d6wllmgiYs zV0n?{C69lIljSXzw^`m{d6(rqoJ1c^x$43hNhw^ny0L*$t;4`U zEwVMWc;(W%jg*dKTNad})wLToOl;Atxj=olS9-2f%jaA(Dmv3f(ccFr(4QwSpVpOg z5P&$@af;(q$7zl+$3n*<$7090V~Jy_W0_;Zak}FS$E0JqV})bNvC?s-W7;v}NVzQY zr*sxlMhhvag_PGqN^K!!w{V^#<+xlga9rq^bzJ0F>$upl&T)z3QpaVE%Ng#8Y0(Q9k)4d zciiE)({Y#MZpS^2dmZ;V?sq)j@qpt6jt3nNIUaUA;&{~YnB#HB6OJbxsTRrnsT>KZ zA_=J|38^j#sWb_xItj0Eq#7mHS2^a-i@2_JW)8YtIKI6mq4 zl;hKm&p1Bo_?+YOjxRXA==hT3%Z{%&zUugzN5e_#PA5@h1g< z?#5pvbRB^_{=NXjpVC!dKvIBw3-}O(o`&$fbcOgc(umy4r}jU`U%2-DAS7<9_TUYE z1pKGL``-_Q_}c|SGQdy>gGZee3?9!L9gfx(eZk z&=r4!AGsmxXh@&@A&-Dc4ta8NcuLP6*F(1lwA-~1>FV9PCycjz`w2A) zkLD?bWDV_P@H?PA+zGwl4(Jbe;cw|K4g4R-i{i(K9lxUP4gL;4aRc_G74ok5gQ@d7 z>4%ovaW5$R6n`HyHDQ?251ak}nk z{NRzXVw|BnnMi@O7$?S=y0h_46=S>@6Lc37QDRIKW0LM_ykH9_i!nuaGu|L+F;$Fd zy1VfPixCr}Q1>u?7cq*&DAqlVH&l$c7$y1?6AmU;Dn^;^W&B{2gc#FxZ{r8YFhh)_ z?qmF5wdG<|=)NWttTrV^rS50^;9O>kk=CagzpD(J5u-}?H&GO$T8vrxG~;y>W40J` z^Z?@r5mY0_Ts_cWaB}m+n6C$!aIirO#8{{Y8?U$YkriW+9%B5~V$_PUSPwNAgl(M| zOY|_~4U`s3#aO0?8$W2VT#OZZgz%>^EPd8p?F*b;?QIDm6LKS0^7@PGOCLApPEHTd3N8Cw z*pDq@oTtYduaoq#Rg7(Vg7Jokv0aQEdZO|Bh_O?QU3!x7gSG4yV~?I}JR>dkim^{m zF)dUpr;uOjDunv(lO%&Q$H-m5nX7)K{y;0h;o!r>Y*uGKS)7Z}%xalK9&KUnPzV%(_9jTfBlO=8@vD~#V>rhbbUx9XIM1OaoK z7`N+66A3!KLySB1OcMz@y-SR{b=ri2aJWZ|dv(Tyg8jHp46Cb5C|LgeVmzR$jTa32 zpcoJ7S;h;N|F9U3=-I{(>e!=VJf`OukKS8U(jOP&2fD^!a12j~@uZ$>{2=F^660w- z&v+x{k!QqsR?j!yFfpDJ<9WTn_(6QUAjXS&q49!qc}a|yb=LSnIJ_dpt9p^~dPyIz ziSfFwHC{h4-VozWz1a92#CS`Lw{@LS!G63W#=Cln2?e9PC&mx;QsV_%_`VoF(#s46 z#s^~jST8qTJL&W%V*FIEFri@iKNI8Uy54v}QTl}#ztk%Y2DR{4V*FaKGU1@p55@S6 zUTq>lrTa*X-|96c9IWkL zOgI?jYcc+%&o+@@V&91IU-}&51sn8lG5({^HKCxue#=IC`Ztm-CL}3^7&sw)o(ajz z0K8-}^$m>Hta3Xq}@#K6l8aPUCHz5fl%nO`+13Qd2S{`c^SOo@lnuu&JwhpW| z26h>5l(cFaSlYmDqk>i@u-X~eV|usRvoXMFkKz|Miy#lU{! z1#|BjSltYqZ@gg1-2l6bQ7;l7h-z%_s8#rh%m_(nz>TBST@%u}w zet~tWfy2g=P{;m(b((=A#tR-C5Lg2Z95ue2CJqX$!3K^QU(y?g1lCXk#|_F6m#kk1lH*WE;7D+j^Nn9I>W%l#*@Isae;NF zflEw85(LK^xbz7MlCXtVnHtYR>r9Prp>3unV!>o;q88d`YLtbJnHo)2X99U$31oIB z%5DF~xBeb^ApU}p_076>}g9zHf5Q4EVjL^=)2ts=cqX-==j3IQi zFqY8C!Z<=_3*!l0EKDSHwJ@2`&B9bdcMCB>4+}+vo)+SSQ!JDcdRa&idRv%5=wqRr z(APqW(9gn5!l@QAg#H$)38z_@O&DOIhA_~=Ji;Ig3kZWPWC=qo)DnhTs3Q!su#_;| z!g9h03-yGN7FH2PSy)3DZK07c#=<(n=@vE+##-1!IK#qOgmD(mA)IMp3t_y4t%L~{ zwi6~=*h!dVVK-s2g}sC+7WNaSS~x(MX5kFbE&PhG z%EE_))fPS?tg-Mhp~1o@ghmU$C#<#bN5VP_e$-)O zcj$pbp(jp;Q?LShVHSGhTIhp2p)a0*es}|%iVr}4d;w0wAHe|nJ$fL11%pC)FgVl= zhJ=Q|(9k3p7Al9~p@lFa)CeO(J784kIE)TmPyYkx{cw8dc^DgdAI=E<4#tJPgfqhm z#)rGYgz#XP7@i1|!bzAMUI0_V4KOvl9j1kkK`eY76jGrq3O@(M;U7Xg{4tb-{|TjD z6w16Vknje!&$iEkA{byjY|1Q+|AHfp;AFwpy z!?H*xSRNSwDIH8e)0dg z8>1dz$#JECvH&gh4* zEBbfXt-`QJb%4F9KkQTEV82Sh`Dz{C_7Ou>DAFjt2$u k2Cm6(1J~yFf$Q>5hwJl8A)o%z@@tB-5dH!GDE!lZ1Dv6rng9R* literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java index 3b0b01715..c9ae9aa35 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java @@ -8,157 +8,171 @@ package com.Microsoft.Z3; * Z3_decl_kind **/ public enum Z3_decl_kind { -Z3_OP_LABEL (1792), -Z3_OP_PR_REWRITE (1294), -Z3_OP_UNINTERPRETED (2051), -Z3_OP_SUB (519), -Z3_OP_ZERO_EXT (1058), -Z3_OP_ADD (518), -Z3_OP_IS_INT (528), -Z3_OP_BREDOR (1061), -Z3_OP_BNOT (1051), -Z3_OP_BNOR (1054), -Z3_OP_PR_CNF_STAR (1315), -Z3_OP_RA_JOIN (1539), -Z3_OP_LE (514), -Z3_OP_SET_UNION (773), -Z3_OP_PR_UNDEF (1280), -Z3_OP_BREDAND (1062), -Z3_OP_LT (516), -Z3_OP_RA_UNION (1540), -Z3_OP_BADD (1028), -Z3_OP_BUREM0 (1039), -Z3_OP_OEQ (267), -Z3_OP_PR_MODUS_PONENS (1284), -Z3_OP_RA_CLONE (1548), -Z3_OP_REPEAT (1060), -Z3_OP_RA_NEGATION_FILTER (1544), -Z3_OP_BSMOD0 (1040), -Z3_OP_BLSHR (1065), -Z3_OP_BASHR (1066), -Z3_OP_PR_UNIT_RESOLUTION (1304), -Z3_OP_ROTATE_RIGHT (1068), -Z3_OP_ARRAY_DEFAULT (772), -Z3_OP_PR_PULL_QUANT (1296), -Z3_OP_PR_APPLY_DEF (1310), -Z3_OP_PR_REWRITE_STAR (1295), -Z3_OP_IDIV (523), -Z3_OP_PR_GOAL (1283), -Z3_OP_PR_IFF_TRUE (1305), -Z3_OP_LABEL_LIT (1793), -Z3_OP_BOR (1050), -Z3_OP_PR_SYMMETRY (1286), -Z3_OP_TRUE (256), -Z3_OP_SET_COMPLEMENT (776), -Z3_OP_CONCAT (1056), -Z3_OP_PR_NOT_OR_ELIM (1293), -Z3_OP_IFF (263), -Z3_OP_BSHL (1064), -Z3_OP_PR_TRANSITIVITY (1287), -Z3_OP_SGT (1048), -Z3_OP_RA_WIDEN (1541), -Z3_OP_PR_DEF_INTRO (1309), -Z3_OP_NOT (265), -Z3_OP_PR_QUANT_INTRO (1290), -Z3_OP_UGT (1047), -Z3_OP_DT_RECOGNISER (2049), -Z3_OP_SET_INTERSECT (774), -Z3_OP_BSREM (1033), -Z3_OP_RA_STORE (1536), -Z3_OP_SLT (1046), -Z3_OP_ROTATE_LEFT (1067), -Z3_OP_PR_NNF_NEG (1313), -Z3_OP_PR_REFLEXIVITY (1285), -Z3_OP_ULEQ (1041), -Z3_OP_BIT1 (1025), -Z3_OP_BIT0 (1026), -Z3_OP_EQ (258), -Z3_OP_BMUL (1030), -Z3_OP_ARRAY_MAP (771), -Z3_OP_STORE (768), -Z3_OP_PR_HYPOTHESIS (1302), -Z3_OP_RA_RENAME (1545), -Z3_OP_AND (261), -Z3_OP_TO_REAL (526), -Z3_OP_PR_NNF_POS (1312), -Z3_OP_PR_AND_ELIM (1292), -Z3_OP_MOD (525), -Z3_OP_BUDIV0 (1037), -Z3_OP_PR_TRUE (1281), -Z3_OP_BNAND (1053), -Z3_OP_PR_ELIM_UNUSED_VARS (1299), -Z3_OP_RA_FILTER (1543), -Z3_OP_FD_LT (1549), -Z3_OP_RA_EMPTY (1537), -Z3_OP_DIV (522), -Z3_OP_ANUM (512), -Z3_OP_MUL (521), -Z3_OP_UGEQ (1043), -Z3_OP_BSREM0 (1038), -Z3_OP_PR_TH_LEMMA (1318), -Z3_OP_BXOR (1052), -Z3_OP_DISTINCT (259), -Z3_OP_PR_IFF_FALSE (1306), -Z3_OP_BV2INT (1072), -Z3_OP_EXT_ROTATE_LEFT (1069), -Z3_OP_PR_PULL_QUANT_STAR (1297), -Z3_OP_BSUB (1029), -Z3_OP_PR_ASSERTED (1282), -Z3_OP_BXNOR (1055), -Z3_OP_EXTRACT (1059), -Z3_OP_PR_DER (1300), -Z3_OP_DT_CONSTRUCTOR (2048), -Z3_OP_GT (517), -Z3_OP_BUREM (1034), -Z3_OP_IMPLIES (266), -Z3_OP_SLEQ (1042), -Z3_OP_GE (515), -Z3_OP_BAND (1049), -Z3_OP_ITE (260), -Z3_OP_AS_ARRAY (778), -Z3_OP_RA_SELECT (1547), -Z3_OP_CONST_ARRAY (770), -Z3_OP_BSDIV (1031), -Z3_OP_OR (262), -Z3_OP_PR_HYPER_RESOLVE (1319), -Z3_OP_AGNUM (513), -Z3_OP_PR_PUSH_QUANT (1298), -Z3_OP_BSMOD (1035), -Z3_OP_PR_IFF_OEQ (1311), -Z3_OP_PR_LEMMA (1303), -Z3_OP_SET_SUBSET (777), -Z3_OP_SELECT (769), -Z3_OP_RA_PROJECT (1542), -Z3_OP_BNEG (1027), -Z3_OP_UMINUS (520), -Z3_OP_REM (524), -Z3_OP_TO_INT (527), -Z3_OP_PR_QUANT_INST (1301), -Z3_OP_SGEQ (1044), -Z3_OP_POWER (529), -Z3_OP_XOR3 (1074), -Z3_OP_RA_IS_EMPTY (1538), -Z3_OP_CARRY (1073), -Z3_OP_DT_ACCESSOR (2050), -Z3_OP_PR_TRANSITIVITY_STAR (1288), -Z3_OP_PR_NNF_STAR (1314), -Z3_OP_PR_COMMUTATIVITY (1307), -Z3_OP_ULT (1045), -Z3_OP_BSDIV0 (1036), -Z3_OP_SET_DIFFERENCE (775), -Z3_OP_INT2BV (1071), -Z3_OP_XOR (264), -Z3_OP_PR_MODUS_PONENS_OEQ (1317), -Z3_OP_BNUM (1024), -Z3_OP_BUDIV (1032), -Z3_OP_PR_MONOTONICITY (1289), -Z3_OP_PR_DEF_AXIOM (1308), -Z3_OP_FALSE (257), -Z3_OP_EXT_ROTATE_RIGHT (1070), -Z3_OP_PR_DISTRIBUTIVITY (1291), -Z3_OP_SIGN_EXT (1057), -Z3_OP_PR_SKOLEMIZE (1316), -Z3_OP_BCOMP (1063), -Z3_OP_RA_COMPLEMENT (1546), + Z3_OP_LABEL (1792), + Z3_OP_PR_REWRITE (1294), + Z3_OP_UNINTERPRETED (2051), + Z3_OP_SUB (519), + Z3_OP_ZERO_EXT (1058), + Z3_OP_ADD (518), + Z3_OP_IS_INT (528), + Z3_OP_BREDOR (1061), + Z3_OP_BNOT (1051), + Z3_OP_BNOR (1054), + Z3_OP_PR_CNF_STAR (1315), + Z3_OP_RA_JOIN (1539), + Z3_OP_LE (514), + Z3_OP_SET_UNION (773), + Z3_OP_PR_UNDEF (1280), + Z3_OP_BREDAND (1062), + Z3_OP_LT (516), + Z3_OP_RA_UNION (1540), + Z3_OP_BADD (1028), + Z3_OP_BUREM0 (1039), + Z3_OP_OEQ (267), + Z3_OP_PR_MODUS_PONENS (1284), + Z3_OP_RA_CLONE (1548), + Z3_OP_REPEAT (1060), + Z3_OP_RA_NEGATION_FILTER (1544), + Z3_OP_BSMOD0 (1040), + Z3_OP_BLSHR (1065), + Z3_OP_BASHR (1066), + Z3_OP_PR_UNIT_RESOLUTION (1304), + Z3_OP_ROTATE_RIGHT (1068), + Z3_OP_ARRAY_DEFAULT (772), + Z3_OP_PR_PULL_QUANT (1296), + Z3_OP_PR_APPLY_DEF (1310), + Z3_OP_PR_REWRITE_STAR (1295), + Z3_OP_IDIV (523), + Z3_OP_PR_GOAL (1283), + Z3_OP_PR_IFF_TRUE (1305), + Z3_OP_LABEL_LIT (1793), + Z3_OP_BOR (1050), + Z3_OP_PR_SYMMETRY (1286), + Z3_OP_TRUE (256), + Z3_OP_SET_COMPLEMENT (776), + Z3_OP_CONCAT (1056), + Z3_OP_PR_NOT_OR_ELIM (1293), + Z3_OP_IFF (263), + Z3_OP_BSHL (1064), + Z3_OP_PR_TRANSITIVITY (1287), + Z3_OP_SGT (1048), + Z3_OP_RA_WIDEN (1541), + Z3_OP_PR_DEF_INTRO (1309), + Z3_OP_NOT (265), + Z3_OP_PR_QUANT_INTRO (1290), + Z3_OP_UGT (1047), + Z3_OP_DT_RECOGNISER (2049), + Z3_OP_SET_INTERSECT (774), + Z3_OP_BSREM (1033), + Z3_OP_RA_STORE (1536), + Z3_OP_SLT (1046), + Z3_OP_ROTATE_LEFT (1067), + Z3_OP_PR_NNF_NEG (1313), + Z3_OP_PR_REFLEXIVITY (1285), + Z3_OP_ULEQ (1041), + Z3_OP_BIT1 (1025), + Z3_OP_BIT0 (1026), + Z3_OP_EQ (258), + Z3_OP_BMUL (1030), + Z3_OP_ARRAY_MAP (771), + Z3_OP_STORE (768), + Z3_OP_PR_HYPOTHESIS (1302), + Z3_OP_RA_RENAME (1545), + Z3_OP_AND (261), + Z3_OP_TO_REAL (526), + Z3_OP_PR_NNF_POS (1312), + Z3_OP_PR_AND_ELIM (1292), + Z3_OP_MOD (525), + Z3_OP_BUDIV0 (1037), + Z3_OP_PR_TRUE (1281), + Z3_OP_BNAND (1053), + Z3_OP_PR_ELIM_UNUSED_VARS (1299), + Z3_OP_RA_FILTER (1543), + Z3_OP_FD_LT (1549), + Z3_OP_RA_EMPTY (1537), + Z3_OP_DIV (522), + Z3_OP_ANUM (512), + Z3_OP_MUL (521), + Z3_OP_UGEQ (1043), + Z3_OP_BSREM0 (1038), + Z3_OP_PR_TH_LEMMA (1318), + Z3_OP_BXOR (1052), + Z3_OP_DISTINCT (259), + Z3_OP_PR_IFF_FALSE (1306), + Z3_OP_BV2INT (1072), + Z3_OP_EXT_ROTATE_LEFT (1069), + Z3_OP_PR_PULL_QUANT_STAR (1297), + Z3_OP_BSUB (1029), + Z3_OP_PR_ASSERTED (1282), + Z3_OP_BXNOR (1055), + Z3_OP_EXTRACT (1059), + Z3_OP_PR_DER (1300), + Z3_OP_DT_CONSTRUCTOR (2048), + Z3_OP_GT (517), + Z3_OP_BUREM (1034), + Z3_OP_IMPLIES (266), + Z3_OP_SLEQ (1042), + Z3_OP_GE (515), + Z3_OP_BAND (1049), + Z3_OP_ITE (260), + Z3_OP_AS_ARRAY (778), + Z3_OP_RA_SELECT (1547), + Z3_OP_CONST_ARRAY (770), + Z3_OP_BSDIV (1031), + Z3_OP_OR (262), + Z3_OP_PR_HYPER_RESOLVE (1319), + Z3_OP_AGNUM (513), + Z3_OP_PR_PUSH_QUANT (1298), + Z3_OP_BSMOD (1035), + Z3_OP_PR_IFF_OEQ (1311), + Z3_OP_PR_LEMMA (1303), + Z3_OP_SET_SUBSET (777), + Z3_OP_SELECT (769), + Z3_OP_RA_PROJECT (1542), + Z3_OP_BNEG (1027), + Z3_OP_UMINUS (520), + Z3_OP_REM (524), + Z3_OP_TO_INT (527), + Z3_OP_PR_QUANT_INST (1301), + Z3_OP_SGEQ (1044), + Z3_OP_POWER (529), + Z3_OP_XOR3 (1074), + Z3_OP_RA_IS_EMPTY (1538), + Z3_OP_CARRY (1073), + Z3_OP_DT_ACCESSOR (2050), + Z3_OP_PR_TRANSITIVITY_STAR (1288), + Z3_OP_PR_NNF_STAR (1314), + Z3_OP_PR_COMMUTATIVITY (1307), + Z3_OP_ULT (1045), + Z3_OP_BSDIV0 (1036), + Z3_OP_SET_DIFFERENCE (775), + Z3_OP_INT2BV (1071), + Z3_OP_XOR (264), + Z3_OP_PR_MODUS_PONENS_OEQ (1317), + Z3_OP_BNUM (1024), + Z3_OP_BUDIV (1032), + Z3_OP_PR_MONOTONICITY (1289), + Z3_OP_PR_DEF_AXIOM (1308), + Z3_OP_FALSE (257), + Z3_OP_EXT_ROTATE_RIGHT (1070), + Z3_OP_PR_DISTRIBUTIVITY (1291), + Z3_OP_SIGN_EXT (1057), + Z3_OP_PR_SKOLEMIZE (1316), + Z3_OP_BCOMP (1063), + Z3_OP_RA_COMPLEMENT (1546); + + private final int intValue; + + Z3_decl_kind(int v) { + this.intValue = v; + } + + public static final Z3_decl_kind fromInt(int v) { + for (Z3_decl_kind k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..f9d486c4ee9c6aad166284c7a49b18c0422e5d60 GIT binary patch literal 1961 zcma)6T~k|S5Psg|BP*R|+3KU7h0gnv{<^}Ls z3uzU%RAjuE#x|P|`6TNlV{4dU%&})j!&Syz4PnN68X}DMHAETn8e)ul8fF7s zk%l?Ok2S;@KhbcVv7lj|@ly>8j71gu0zG?+1uMOqNLlNJ?L;nTX43-WsZ#wYzEvqT z>c{niW_)jv{tM+squwZ#>JQ7y0$t?TGPg22xxz-mN(t!XNM|TV);6;OE~1&c?YQ&& ziR@-O&b*&Aw{up8O1UY{%G?p?<_~GEpGZ;4T!L~M(${|6j-A*v1^URfVWrGMBAGO8 zyI^Ls87k)|x1Gu6&Ut`%`zhxh&b4kP3t4mH+@)1&&D~=4q%0sT0d<-x?U=T}#Dh0C zzbsN%Pq#nNY6 z#n0ulX@hCR&ALqB3`eMY+DfT<_7HMV(S;5*X6@u?7P+;``_f*F+$~tc2K&Nlu4IOXe9j2=~W^hHvRW@NZ5jIgaF*dVo zuCbY86K8Xs%{-e0T%pCjm=&v|c9g318ojzN9O+P=*?&|nHA&gc&gmqp#pC1UjGb2T*b4TfT&g(W4ZJcT;+HQYhv@fS|<-CuuDkaK~bO>#FHrJ59;e}c2JaL2B-Ir|mDDe3mrIi@AerHIO4cn|kJ`T2D_Ngr=<={%(gDNm zl5|kgw+z+rNFJ1Y$j}V0MvoQS(954nW5!{InrmG^zmg)WAI&!~w1BDGlsP^x-S?<68{iDF*QyyfoDI MhFJK3ayW4JZ;)?(^b literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java index ef5fa6f2c..0c1c22870 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java @@ -8,18 +8,32 @@ package com.Microsoft.Z3; * Z3_error_code **/ public enum Z3_error_code { -Z3_INVALID_PATTERN (6), -Z3_MEMOUT_FAIL (7), -Z3_NO_PARSER (5), -Z3_OK (0), -Z3_INVALID_ARG (3), -Z3_EXCEPTION (12), -Z3_IOB (2), -Z3_INTERNAL_FATAL (9), -Z3_INVALID_USAGE (10), -Z3_FILE_ACCESS_ERROR (8), -Z3_SORT_ERROR (1), -Z3_PARSER_ERROR (4), -Z3_DEC_REF_ERROR (11), + Z3_INVALID_PATTERN (6), + Z3_MEMOUT_FAIL (7), + Z3_NO_PARSER (5), + Z3_OK (0), + Z3_INVALID_ARG (3), + Z3_EXCEPTION (12), + Z3_IOB (2), + Z3_INTERNAL_FATAL (9), + Z3_INVALID_USAGE (10), + Z3_FILE_ACCESS_ERROR (8), + Z3_SORT_ERROR (1), + Z3_PARSER_ERROR (4), + Z3_DEC_REF_ERROR (11); + + private final int intValue; + + Z3_error_code(int v) { + this.intValue = v; + } + + public static final Z3_error_code fromInt(int v) { + for (Z3_error_code k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..0d278b16fc54b0b86a831a3a98adc4888b830de8 GIT binary patch literal 1379 zcmah|OHUI~6#i~!I@8CLM|qT26#=ymr9wrKmmpTtq<~?hvAAf4v5;b!A!W+ig+Ii& zapMAu3eiYd`$zl>uF!KY1!^>QGP!5IbI;>D-@WtwdoiXnLB5jFBlSzbsxbDly^(Q>jz zsZwBIX$EyDJC|8W=?wkP8+KH7dEySkKqT5YTAsIGP?zRR(JCxfw$=*er^Z@|JgO+O zw9b%>WHyamBT+J}jfC!$i`K?uv@wmTqE&QAv(P`%)9GlI!K)WHEW@dkshu1VE_J24Vvrji}63`vPe7Rt33(|DL3~t93`BEfG%6X>DQjG^WsOL!CEGet9HPv8{89GCs zZdb}?;Zc$6(prDO!(12*J^X6*YPgSChVXx{gob|1X&Ar*4PEHg(1$RGgBseMeO+~z8_a=@q=&)ufGj)>=5o_$bToexNa248{B|IQ~@m(?>m4J3x9(8;k-o? z?Q)6=4dExcLxfzoN`$ZBdab2N9yj^phwx1#T}#K@9Cpn zjy`y3rkl0USArSv>?`D4&@0IY@a@AdkS0q41q5nxD*`nO)S|crYE{2cqEv-n&≧ q^qjkjW<94=(W>u*T`1KlI{Aq>znTG}+k|oWXv|a1hLI3M-}()apcK>q literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java index 38e2fdf96..2d96c6e76 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java @@ -8,9 +8,23 @@ package com.Microsoft.Z3; * Z3_goal_prec **/ public enum Z3_goal_prec { -Z3_GOAL_UNDER (1), -Z3_GOAL_PRECISE (0), -Z3_GOAL_UNDER_OVER (3), -Z3_GOAL_OVER (2), + Z3_GOAL_UNDER (1), + Z3_GOAL_PRECISE (0), + Z3_GOAL_UNDER_OVER (3), + Z3_GOAL_OVER (2); + + private final int intValue; + + Z3_goal_prec(int v) { + this.intValue = v; + } + + public static final Z3_goal_prec fromInt(int v) { + for (Z3_goal_prec k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class new file mode 100644 index 0000000000000000000000000000000000000000..eeee15f26a211be42e8ed85f4922618494ee8ea2 GIT binary patch literal 1270 zcmaJA?XGFJ`~rW7 z@x>P(u&5A?glGSVf59ho&QhR8ZPT3DnKLurH{Y4>XJ1YLr18WD5#usaxF=yi!i0=2 zO!6bmZ|=)zikvP%g8XuPUiZ`Vs7ceS(-1XROi)AdqXqoWd@dKkVZD<3+p+RVdz=gj-Gv9 zRAaani?`1d7p&*hy|bX3<&}D+Sgx*VMS~)e(_(dpAr&j^Y5Q8r(9GSGYFBl0Hxq9U zKckzvon`3%M`=DE-yn5Veb?0NdX=EWm=ltAs#Ya$+MIR1JwQOUwbILF?Uh58UWvhN zTTZPIi<45`nUc}uKmo!VYndTu)+;k@2FUU^QLTElR9@1#7J-Y$8s|bN=;v!Opdf=8 zhVXx%RzVcA3a%ropbsGhVMMrlLqRu!3VQg_iy%YCmB5@FO;a)~laPC3@fPB%#l3RL zCU#S;x-J-6t(Iv?yL_WRyHZ`KwXT^)+RshU)^^eIyXV538bFrVIhF|0O^{CjbVc~^ znnY0r6+fjI3{GMRID&U-$d^Sp2P^ZoB{04$&!f{L3a z7O|vbPRA`1XR*xYYd%>q$=o)OV860-3-PLlrC@@{DHXHd(ui9!JH4obP2MhGwed4y<#_nU!-(M84dihRebCoN? zJy_nlTevR}=^?wcbGvA-A2;8&OIs(ETlekK#xYzkZ?6^$0*2?ecieiXCLnA9eU4ge z7aW1}4?j&xd&-qZ0<-DNDbm%o=043CDtdmc)M@P1T3ha3og%vIQ$7&5mM%VWpStmTNwcFXe*7c-|IvgG+*ds$%oKk98evm+34yhGn@cUm-0P0Nse&}uepzs>yZQ%s3C zZMXV((|sao)9VljwwtnnlFpEN#!|K3Cqe-lIzO;Y!S6JdKDEj+UA5^nJFRN%j>po( zKY9q4SsV+q{4nP%+ygy@$^U;l7BbkhkVDDBdCXY2fX^6Sw2(m3!Z|h*Y*K6{*-WvS zMp7VpavRK_7OvKtKJhw}&J65U-g{K5wu$@oLH*b2?$OcWK-%$ze%zJn#s=&9X>>;` zSLp|HmVTF^l?2lT$P;7fiL~^@TY91{J+YUb7NE*FZwWZ5elsUSlQgfOK92D zuh4%!9ucKeV3bCUA&hZcA{4-7S~ZU={gG9Q1Sy_-1*4dIb4yuHP5gjlE;WBsO{l*> zPks+Ap+0}6h#x=vO-af;Qwqo(;&ONrBcvMZa)GY;DxK2c_Xz2j7h?1swI8PceAoH| zQ{-8dV3wNyM1Ks*F$DwH@kKxNFUbt}?hmMyct}xS!hC_SM3$;a6p<(zG$b05D5k}F zhr<%abwwVINOZ=~B^s4zET#n|9FOU*X^PTC*r}*pM4U>niy^0?busKz^e#r6iqXZW wQ;AV%+<5_UqVx>$25B4xzxD`SXcRXvgbl>7P3!N&B*}XEe~GUsH-H=e0K9lLV*mgE literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java index e3d8c0e77..81b8ef7bd 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java @@ -8,12 +8,26 @@ package com.Microsoft.Z3; * Z3_param_kind **/ public enum Z3_param_kind { -Z3_PK_BOOL (1), -Z3_PK_SYMBOL (3), -Z3_PK_OTHER (5), -Z3_PK_INVALID (6), -Z3_PK_UINT (0), -Z3_PK_STRING (4), -Z3_PK_DOUBLE (2), + Z3_PK_BOOL (1), + Z3_PK_SYMBOL (3), + Z3_PK_OTHER (5), + Z3_PK_INVALID (6), + Z3_PK_UINT (0), + Z3_PK_STRING (4), + Z3_PK_DOUBLE (2); + + private final int intValue; + + Z3_param_kind(int v) { + this.intValue = v; + } + + public static final Z3_param_kind fromInt(int v) { + for (Z3_param_kind k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..2a137da1ee2cd5556ac5df173b322fa0eabe7c2c GIT binary patch literal 1639 zcma)6T~iZh6n@_9W_J@72*iMiL@Yv^4{It^tAdmef{o2bhXrP0FEUFA%xbc6!p2|F zAJNNBZ+g=U8{6vW$avlHfA|-AWqZzRMibi^lgXTi=e+0pobcD1XQu#GPzgZA%^+5> zrejgZtsu@~oyFJuvJoVaH4tUoWKGV%ImRsmbBuWdamH-}=NWGsm}mUPzy-#FjynP~ zcUNlPWp}cr{BC}yw!K%*)wc4vqQGLY-fm?|PQBAUX&-r+yDRjqJ+M1=tKl^|wfl~H zxGE4H^53fLZ5Hz%YOQK%vqB+5L$-zT?uV+ZMXISGE32|Yy2y}jC%apyl(Q7ka9nTS zZgv|2q9C9z?q`d8c}rmF`_anR9p1T5YI4Ma)*RRI)&*w&Cq|)=+!qK~&arEI-45kc6H=ug zb=s|h>v1225i^Zjo?X9RvLDFu>Ba>7URwrH5=ok-u~u*Piy;LizBbTR-tD&5MrmoC zjwEQcyPbMt+uCl8Go{ zCeE>#V-aU@p2a+i3y29!yx$P_Le1BkZI|jhlSmHqSvk1ZsC(4I)xmw_n)b=b>VVn1 zB@ag>znMY5z8URo;|l!*&(beFuo2~Q0Ya)+A{8x>>Xt~QOQh;0QUl~U&0Pbb7*CG4 zh5(NMbOgi}2>BE2LHr5dODKJr7vYoIu`txsQ}|y({jY6JM`F3(4y+29~AM+Kd;G1S>}>_vWIDzJcck$jpwpNtG+_7l=uw- zI+lfq{7vDf=zr;#{e*Eso{B$3!GEPc2FEcE16OgaZ~97B2K@LOYIQoGgtR9JKE{}& zrm9LdF4=_t?c1beAx)8QQ<6>VhGb#M&KSC65y@sknqSh{kp6Rkeq4tLpDz z(yD4bOj%XEhp<&OdWcxn5UFOZ#}Mx)y+Cz?W;_W#^l{qI1a1(!jS%*z{X+z4WN+vH L6|R%54>$e=sRB{1 literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java index 0de56c3cd..c009104ba 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java @@ -8,12 +8,26 @@ package com.Microsoft.Z3; * Z3_parameter_kind **/ public enum Z3_parameter_kind { -Z3_PARAMETER_FUNC_DECL (6), -Z3_PARAMETER_DOUBLE (1), -Z3_PARAMETER_SYMBOL (3), -Z3_PARAMETER_INT (0), -Z3_PARAMETER_AST (5), -Z3_PARAMETER_SORT (4), -Z3_PARAMETER_RATIONAL (2), + Z3_PARAMETER_FUNC_DECL (6), + Z3_PARAMETER_DOUBLE (1), + Z3_PARAMETER_SYMBOL (3), + Z3_PARAMETER_INT (0), + Z3_PARAMETER_AST (5), + Z3_PARAMETER_SORT (4), + Z3_PARAMETER_RATIONAL (2); + + private final int intValue; + + Z3_parameter_kind(int v) { + this.intValue = v; + } + + public static final Z3_parameter_kind fromInt(int v) { + for (Z3_parameter_kind k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..3a4c6b2199ef6426ecf5341a27bb0198987188cf GIT binary patch literal 1770 zcmah}%W@i55Iw^T%rFcv=wTTwgp6dHhb>|$&cn!xkc5)45hx6jjl7@`Mk;JHq+rk& zB%hFdDw}MwaBvd4l8Vb~e}uQmCuHTM?`0&DN-C(NK01B7Z};iG@cQj9F9EFJp%)T1 zRcs+I^Ar?ZX1Jpu&akLpfniC(BEww;R~UY-;3~ti zf@=&-1qp@~1xbc`GWG?i2P?IW{hC=SR|Lcgjm}ACr`70odYvOXbFf0cwO*%d*PgVj zM_B>W#J7#2QOVb~N;^5D=w$lIpDUMhRfh+O?-lPAOZU$rbn=w*gRw1i0-E&leL(nw+xQXght7gKFL!(UQ0NC#z$GtkH{6%}&4DXl}RI zTtc+1^XIh02BYCRd-XRo+{Xg}(f@sb8kSMj@IDSSq>$FIgbbs%G{i8k;W9IEW)_%P zWabJpSDCrSOoEvt<^=@a?S*L}@r`!Jq9&&j$q}8U!^h2rO+s#su41!Y@Aa}HVdty; z=dF}?VKmPPqjjy{q|e|SeFbRiVb(oBNCG&L296|yBProXVmOi>jwFdAsp3e&08Fsq z0D6SYmbeFAHYo^rk64_L{ip*7Kg0D3;!|R@T(Ta1rc(SeeKif^7vSPv-z22e3%FlF z`gekhZGi$=f$I=S8VO6KXP?89iv9%ohw~BvIt4CLsW5zq-~(bVd`RpgeC(8LkjG8_ z^b073^vgTqT6FeXMAFga+frEi5pv`kc*4@tFGb`=aSBEW*;L#qy8L_kXLKBKC|JWM!%$(4cLu!q6;gG= zE6UHIK7)@lP0|%k{hS8eLl)#r_k_eh_-Tmq30WWJPI5Y>c=+KoXBTvjo6{LiFY2<$ zX_(W9u1K6-;&fK`>cixyuKq@Ci39k|sx*M#thxsXnpMvLA+stEFlknm0jABWPOcdO z@`VY=d5OR~K-7E&;oZKLXiK2K05lq=pB`2KSp;zxIv&svkLkIc(y+h66uyQ^OBil+ K9XZN#VdHOV8(^&f literal 0 HcmV?d00001 diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java index 59a69b4c0..43f5b2f14 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java @@ -8,15 +8,29 @@ package com.Microsoft.Z3; * Z3_sort_kind **/ public enum Z3_sort_kind { -Z3_BV_SORT (4), -Z3_FINITE_DOMAIN_SORT (8), -Z3_ARRAY_SORT (5), -Z3_UNKNOWN_SORT (1000), -Z3_RELATION_SORT (7), -Z3_REAL_SORT (3), -Z3_INT_SORT (2), -Z3_UNINTERPRETED_SORT (0), -Z3_BOOL_SORT (1), -Z3_DATATYPE_SORT (6), + Z3_BV_SORT (4), + Z3_FINITE_DOMAIN_SORT (8), + Z3_ARRAY_SORT (5), + Z3_UNKNOWN_SORT (1000), + Z3_RELATION_SORT (7), + Z3_REAL_SORT (3), + Z3_INT_SORT (2), + Z3_UNINTERPRETED_SORT (0), + Z3_BOOL_SORT (1), + Z3_DATATYPE_SORT (6); + + private final int intValue; + + Z3_sort_kind(int v) { + this.intValue = v; + } + + public static final Z3_sort_kind fromInt(int v) { + for (Z3_sort_kind k: values()) + if (k.intValue == v) return k; + return values()[0]; + } + + public final int toInt() { return this.intValue; } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..6623e4b8d5e9a1c36ea65d2d8d1116342276eec9 GIT binary patch literal 1270 zcma)5+fEZv6kVq??X=TrX$u8gsmMj`1u0PRLXn^ZO_Kt~!6x8CGcAP-v@@oilKAe2 z7+-wx0YQamBs}{g{(?{FK0|{=NodoY-F-QGt-bc?kCU%Q05ZsWAR;AW6t^XWC5*}N zBh8O-o|%y8m~^9y+YFD~aU;m>l!UtszO_s-x3p4JR~H{I=NSg`WwVxE)XR0VVQyII zwG4fWjn}o3SuJks#(I_^KoNE2d2Z?H*)_LrSOu-xtT3<~gEUfjlz*|HG7P=!prLDr zUu`gq#1oy=i}U6>A$8?-qq5Yjl`8cWtyHCmWH(ygV3>;Mx3nECUDb@uv})CLV>6rR zgvyL==+-Pl-vteFxkQ1%qw1T6W;N>sD8}uOv{5%}Im6-;HmeSVW;Tp$HK{MCdN z+{1l_flIcpAc_YH`Z28_gl+}B=;LloK^FoFf(S79|0>U!(rD$XX%K;)c%p5J<}+}GyVAYhi&m5<%uUei_S2t3oQrT)09hhNkq{>h1fqOu@?G%o z3BYiLydkpuBkzHIf#Vp$E_nq^F|u40XOfzKpdamWMB&Cw+-j9RvzYIt 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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())) == (long)Z3_sort_kind.Z3_BV_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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + public boolean IsProofGoal() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_GOAL; } /** * Indicates whether the term is proof via modus ponens @@ -740,7 +742,7 @@ import java.lang.Exception; * [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; } + 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. @@ -749,7 +751,7 @@ import java.lang.Exception; * 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; } + public boolean IsProofReflexivity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } /** * Indicates whether the term is proof by symmetricity of a relation @@ -760,7 +762,7 @@ import java.lang.Exception; * T1 is the antecedent of this proof object. * **/ - public boolean IsProofSymmetry() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } + 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 @@ -772,7 +774,7 @@ import java.lang.Exception; * [trans T1 T2]: (R t u) * **/ - public boolean IsProofTransitivity() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } + 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 @@ -793,7 +795,7 @@ import java.lang.Exception; * 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; } + public boolean IsProofTransitivityStar() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } /** @@ -807,7 +809,7 @@ import java.lang.Exception; * That is, reflexivity proofs are supressed to save space. * **/ - public boolean IsProofMonotonicity() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } + public boolean IsProofMonotonicity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } /** * Indicates whether the term is a quant-intro proof @@ -817,7 +819,7 @@ import java.lang.Exception; * [quant-intro T1]: (~ (forall (x) p) (forall (x) q)) * **/ - public boolean IsProofQuantIntro() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } + public boolean IsProofQuantIntro() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } /** * Indicates whether the term is a distributivity proof object. @@ -835,7 +837,7 @@ import java.lang.Exception; * instantiated by f = or, and g = and. * **/ - public boolean IsProofDistributivity() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } + public boolean IsProofDistributivity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } /** * Indicates whether the term is a proof by elimination of AND @@ -845,7 +847,7 @@ import java.lang.Exception; * [and-elim T1]: l_i * **/ - public boolean IsProofAndElimination() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } + 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 @@ -855,7 +857,7 @@ import java.lang.Exception; * [not-or-elim T1]: (not l_i) * **/ - public boolean IsProofOrElimination() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } + public boolean IsProofOrElimination() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } /** * Indicates whether the term is a proof by rewriting @@ -874,7 +876,7 @@ import java.lang.Exception; * (iff (or x false) x) * **/ - public boolean IsProofRewrite() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE; } + public boolean IsProofRewrite() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_REWRITE; } /** * Indicates whether the term is a proof by rewriting @@ -890,7 +892,7 @@ import java.lang.Exception; * - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true) * **/ - public boolean IsProofRewriteStar() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } + 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. @@ -898,7 +900,7 @@ import java.lang.Exception; * 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; } + 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. @@ -908,7 +910,7 @@ import java.lang.Exception; * This proof object has no antecedents * **/ - public boolean IsProofPullQuantStar() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } + 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. @@ -921,7 +923,7 @@ import java.lang.Exception; * This proof object has no antecedents * **/ - public boolean IsProofPushQuant() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } + 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. @@ -933,7 +935,7 @@ import java.lang.Exception; * This proof object has no antecedents. * **/ - public boolean IsProofElimUnusedVars() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } + 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 @@ -947,7 +949,7 @@ import java.lang.Exception; * Several variables can be eliminated simultaneously. * **/ - public boolean IsProofDER() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DER; } + public boolean IsProofDER() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_DER; } /** * Indicates whether the term is a proof for quantifier instantiation @@ -955,13 +957,13 @@ import java.lang.Exception; * 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; } + 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; } + public boolean IsProofHypothesis() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } /** * Indicates whether the term is a proof by lemma @@ -974,7 +976,7 @@ import java.lang.Exception; * when T1 contains the hypotheses: l_1, ..., l_n. * **/ - public boolean IsProofLemma() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_LEMMA; } + public boolean IsProofLemma() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_LEMMA; } /** * Indicates whether the term is a proof by unit resolution @@ -986,7 +988,7 @@ import java.lang.Exception; * [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; } + public boolean IsProofUnitResolution() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } /** * Indicates whether the term is a proof by iff-true @@ -995,7 +997,7 @@ import java.lang.Exception; * [iff-true T1]: (iff p true) * **/ - public boolean IsProofIFFTrue() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_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 @@ -1004,7 +1006,7 @@ import java.lang.Exception; * [iff-false T1]: (iff p false) * **/ - public boolean IsProofIFFFalse() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } + public boolean IsProofIFFFalse() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } /** * Indicates whether the term is a proof by commutativity @@ -1017,7 +1019,7 @@ import java.lang.Exception; * Remark: if f is bool, then = is iff. * **/ - public boolean IsProofCommutativity() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } + public boolean IsProofCommutativity() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } /** * Indicates whether the term is a proof for Tseitin-like axioms @@ -1053,7 +1055,7 @@ import java.lang.Exception; * bounded number of steps (=3). * **/ - public boolean IsProofDefAxiom() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } + 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 @@ -1076,7 +1078,7 @@ import java.lang.Exception; * [def-intro]: (= n e) * **/ - public boolean IsProofDefIntro() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } + 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 @@ -1086,7 +1088,7 @@ import java.lang.Exception; * n is a name for F. * **/ - public boolean IsProofApplyDef() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } + public boolean IsProofApplyDef() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } /** * Indicates whether the term is a proof iff-oeq @@ -1095,7 +1097,7 @@ import java.lang.Exception; * [iff~ T1]: (~ p q) * **/ - public boolean IsProofIFFOEQ() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } + 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 @@ -1123,7 +1125,7 @@ import java.lang.Exception; * over Boolean connectives 'and' and 'or'. * **/ - public boolean IsProofNNFPos() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_POS; } + 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 @@ -1148,7 +1150,7 @@ import java.lang.Exception; * (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; } + 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. @@ -1160,7 +1162,7 @@ import java.lang.Exception; * 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; } + 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. @@ -1170,7 +1172,7 @@ import java.lang.Exception; * 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; } + 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 @@ -1183,7 +1185,7 @@ import java.lang.Exception; * This proof object has no antecedents. * **/ - public boolean IsProofSkolemize() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } + 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. @@ -1194,7 +1196,7 @@ import java.lang.Exception; * [mp~ T1 T2]: q * **/ - public boolean IsProofModusPonensOEQ() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } + 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 @@ -1213,15 +1215,16 @@ import java.lang.Exception; * - 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; } + 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()) != 0 && - (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_RELATION_SORT); + return (Native.isApp(Context().nCtx(), NativeObject()) && + Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) + == Z3_sort_kind.Z3_RELATION_SORT.toInt()); } /** @@ -1232,40 +1235,40 @@ import java.lang.Exception; * correspond to the n columns of the relation. * **/ - public boolean IsRelationStore() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_STORE; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + public boolean IsRelationProject() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_PROJECT; } /** * Indicates whether the term is a relation filter @@ -1277,7 +1280,7 @@ import java.lang.Exception; * So the first column in the relation has index 0. * **/ - public boolean IsRelationFilter() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_FILTER; } + 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. @@ -1293,7 +1296,7 @@ import java.lang.Exception; * x on the columns c1, d1, .., cN, dN. * **/ - public boolean IsRelationNegationFilter() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } + 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 @@ -1302,12 +1305,12 @@ import java.lang.Exception; * The parameters contain the renaming as a cycle. * **/ - public boolean IsRelationRename() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_RENAME; } + 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; } + public boolean IsRelationComplement() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } /** * Indicates whether the term is a relational select @@ -1317,7 +1320,7 @@ import java.lang.Exception; * and the remaining n arguments correspond to a record. * **/ - public boolean IsRelationSelect() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_SELECT; } + public boolean IsRelationSelect() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_RA_SELECT; } /** * Indicates whether the term is a relational clone (copy) @@ -1329,21 +1332,21 @@ import java.lang.Exception; * to perform destructive updates to the first argument. * **/ - public boolean IsRelationClone() { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_CLONE; } + 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()) != 0 && - (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getSort(Context().nCtx(), NativeObject())) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT); + 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; } + public boolean IsFiniteDomainLT() { return FuncDecl().DeclKind() == Z3_decl_kind.Z3_OP_FD_LT; } /** * The de-Burijn index of a bound variable. @@ -1364,9 +1367,9 @@ import java.lang.Exception; * index. * **/ - public long Index() + public int Index() { - if (!IsVar) + if (!IsVar()) throw new Z3Exception("Term is not a bound variable."); @@ -1385,9 +1388,9 @@ import java.lang.Exception; void CheckNativeObject(long obj) { - if (Native.isApp(Context().nCtx(), obj) == 0 && - (Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST && - (Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) + 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); } @@ -1398,7 +1401,7 @@ import java.lang.Exception; - long obj = Native.mkApp(ctx.nCtx(), f.NativeObject, + long obj = Native.mkApp(ctx.nCtx(), f.NativeObject(), AST.ArrayLength(arguments), AST.ArrayToNative(arguments)); return Create(ctx, obj); @@ -1409,33 +1412,33 @@ import java.lang.Exception; - Z3_ast_kind k = (Z3_ast_kind)Native.getAstKind(ctx.nCtx(), obj); + 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)Native.getSortKind(ctx.nCtx(), s); + Z3_sort_kind sk = Z3_sort_kind.fromInt(Native.getSortKind(ctx.nCtx(), s)); - if (Native.isAlgebraicNumber(ctx.nCtx(), obj) != 0) // is this a numeral ast? + if (Native.isAlgebraicNumber(ctx.nCtx(), obj) ) // is this a numeral ast? return new AlgebraicNum(ctx, obj); - if (Native.isNumeralAst(ctx.nCtx(), obj) != 0) + if (Native.isNumeralAst(ctx.nCtx(), obj) ) { switch (sk) { - case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj); - case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj); - case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj); + case Z3_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_sort_kind.Z3_BOOL_SORT: return new BoolExpr(ctx, obj); - case Z3_sort_kind.Z3_INT_SORT: return new IntExpr(ctx, obj); - case Z3_sort_kind.Z3_REAL_SORT: return new RealExpr(ctx, obj); - case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj); - case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj); - case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj); + case Z3_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 index 016d0fecc..49a2c40c5 100644 --- a/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java +++ b/src/api/java/com/Microsoft/Z3/FiniteDomainSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -30,7 +31,7 @@ import java.lang.Exception; } FiniteDomainSort(Context ctx, Symbol name, long size) - { super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.NativeObject, 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 index 0c38f9679..104fd354c 100644 --- a/src/api/java/com/Microsoft/Z3/Fixedpoint.java +++ b/src/api/java/com/Microsoft/Z3/Fixedpoint.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -31,14 +32,14 @@ import java.lang.Exception; public void setParameters(Params value) { - Context.CheckContextMatch(value); - Native.fixedpointSetParams(Context().nCtx(), NativeObject(), value.NativeObject); + 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())); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.fixedpointGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -49,10 +50,10 @@ import java.lang.Exception; - Context.CheckContextMatch(constraints); - for (Iterator a = constraints.iterator(); a.hasNext(); ) + Context().CheckContextMatch(constraints); + for (BoolExpr a: constraints) { - Native.fixedpointAssert(Context().nCtx(), NativeObject(), a.NativeObject); + Native.fixedpointAssert(Context().nCtx(), NativeObject(), a.NativeObject()); } } @@ -63,8 +64,8 @@ import java.lang.Exception; { - Context.CheckContextMatch(f); - Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), f.NativeObject); + Context().CheckContextMatch(f); + Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), f.NativeObject()); } /** @@ -74,20 +75,20 @@ import java.lang.Exception; { - Context.CheckContextMatch(rule); - Native.fixedpointAddRule(Context().nCtx(), NativeObject(), rule.NativeObject, AST.GetNativeObject(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, long[] args) + public void AddFact(FuncDecl pred, int[] args) { - Context.CheckContextMatch(pred); - Native.fixedpointAddFact(Context().nCtx(), NativeObject(), pred.NativeObject, (long)args.Length, args); + Context().CheckContextMatch(pred); + Native.fixedpointAddFact(Context().nCtx(), NativeObject(), pred.NativeObject(), (int)args.length, args); } /** @@ -100,12 +101,12 @@ import java.lang.Exception; { - Context.CheckContextMatch(query); - Z3_lbool r = (Z3_lbool)Native.fixedpointQuery(Context().nCtx(), NativeObject(), query.NativeObject); + Context().CheckContextMatch(query); + Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQuery(Context().nCtx(), NativeObject(), query.NativeObject())); switch (r) { - case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -121,13 +122,13 @@ import java.lang.Exception; - Context.CheckContextMatch(relations); + Context().CheckContextMatch(relations); Z3_lbool r = (Z3_lbool)Native.fixedpointQueryRelations(Context().nCtx(), NativeObject(), AST.ArrayLength(relations), AST.ArrayToNative(relations)); switch (r) { - case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -159,8 +160,8 @@ import java.lang.Exception; { - Context.CheckContextMatch(rule); - Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(), rule.NativeObject, AST.GetNativeObject(name)); + Context().CheckContextMatch(rule); + Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(), rule.NativeObject(), AST.GetNativeObject(name)); } /** @@ -170,7 +171,7 @@ import java.lang.Exception; public Expr GetAnswer() { long ans = Native.fixedpointGetAnswer(Context().nCtx(), NativeObject()); - return (ans == 0) ? null : Expr.Create(Context, ans); + return (ans == 0) ? null : Expr.Create(Context(), ans); } /** @@ -186,9 +187,9 @@ import java.lang.Exception; /** * Retrieve the number of levels explored for a given predicate. **/ - public long GetNumLevels(FuncDecl predicate) + public int GetNumLevels(FuncDecl predicate) { - return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), predicate.NativeObject); + return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), predicate.NativeObject()); } /** @@ -196,8 +197,8 @@ import java.lang.Exception; **/ 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); + long res = Native.fixedpointGetCoverDelta(Context().nCtx(), NativeObject(), level, predicate.NativeObject()); + return (res == 0) ? null : Expr.Create(Context(), res); } /** @@ -206,7 +207,7 @@ import java.lang.Exception; **/ public void AddCover(int level, FuncDecl predicate, Expr property) { - Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, predicate.NativeObject, property.NativeObject); + Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, predicate.NativeObject(), property.NativeObject()); } /** @@ -225,7 +226,7 @@ import java.lang.Exception; Native.fixedpointSetPredicateRepresentation(Context().nCtx(), NativeObject(), - f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds)); + f.NativeObject(), AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds)); } @@ -246,11 +247,11 @@ import java.lang.Exception; { - ASTVector v = new ASTVector(Context, Native.fixedpointGetRules(Context().nCtx(), NativeObject())); - long n = v.Size; + ASTVector v = new ASTVector(Context(), Native.fixedpointGetRules(Context().nCtx(), NativeObject())); + int n = v.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = new BoolExpr(Context, v[i].NativeObject); + for (int i = 0; i < n; i++) + res[i] = new BoolExpr(Context(), v[i].NativeObject()); return res; } @@ -261,11 +262,11 @@ import java.lang.Exception; { - ASTVector v = new ASTVector(Context, Native.fixedpointGetAssertions(Context().nCtx(), NativeObject())); - long n = v.Size; + ASTVector v = new ASTVector(Context(), Native.fixedpointGetAssertions(Context().nCtx(), NativeObject())); + int n = v.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = new BoolExpr(Context, v[i].NativeObject); + for (int i = 0; i < n; i++) + res[i] = new BoolExpr(Context(), v[i].NativeObject()); return res; } @@ -294,13 +295,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Fixedpoint_DRQ.IncAndClear(Context, o); + Context().Fixedpoint_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Fixedpoint_DRQ.Add(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 index 91579b085..aa716c028 100644 --- a/src/api/java/com/Microsoft/Z3/FuncDecl.java +++ b/src/api/java/com/Microsoft/Z3/FuncDecl.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -56,18 +57,18 @@ import java.lang.Exception; /** * Returns a unique identifier for the function declaration. **/ - public long Id() { return Native.getFuncDeclId(Context().nCtx(), NativeObject()); } + public int Id() { return Native.getFuncDeclId(Context().nCtx(), NativeObject()); } /** * The arity of the function declaration **/ - public long Arity() { return Native.getArity(Context().nCtx(), NativeObject()); } + public int Arity() { return Native.getArity(Context().nCtx(), NativeObject()); } /** * The size of the domain of the function declaration * **/ - public long DomainSize() { return Native.getDomainSize(Context().nCtx(), NativeObject()); } + public int DomainSize() { return Native.getDomainSize(Context().nCtx(), NativeObject()); } /** * The domain of the function declaration @@ -79,8 +80,8 @@ import java.lang.Exception; var n = DomainSize; Sort[] res = new Sort[n]; - for (long i; i < n; i++) - res[i] = Sort.Create(Context, Native.getDomain(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Sort.Create(Context(), Native.getDomain(Context().nCtx(), NativeObject(), i)); return res; } @@ -90,13 +91,13 @@ import java.lang.Exception; public Sort Range() { - return Sort.Create(Context, Native.getRange(Context().nCtx(), NativeObject())); + return Sort.Create(Context(), Native.getRange(Context().nCtx(), NativeObject())); } /** * The kind of the function declaration. **/ - public Z3_decl_kind DeclKind() { return (Z3_decl_kind)Native.getDeclKind(Context().nCtx(), NativeObject()); } + public Z3_decl_kind DeclKind() { return Z3_decl_kind.fromInt(Native.getDeclKind(Context().nCtx(), NativeObject())); } /** * The name of the function declaration @@ -104,13 +105,13 @@ import java.lang.Exception; public Symbol Name() { - return Symbol.Create(Context, Native.getDeclName(Context().nCtx(), NativeObject())); + return Symbol.Create(Context(), Native.getDeclName(Context().nCtx(), NativeObject())); } /** * The number of parameters of the function declaration **/ - public long NumParameters() { return Native.getDeclNumParameters(Context().nCtx(), NativeObject()); } + public int NumParameters() { return Native.getDeclNumParameters(Context().nCtx(), NativeObject()); } /** * The parameters of the function declaration @@ -119,32 +120,32 @@ import java.lang.Exception; { - long num = NumParameters; + int num = NumParameters(); Parameter[] res = new Parameter[num]; - for (long i; i < num; i++) + for (int i = 0; i < num; i++) { - Z3_parameter_kind k = (Z3_parameter_kind)Native.getDeclParameterKind(Context().nCtx(), NativeObject(), i); + Z3_parameter_kind k = Z3_parameter_kind.fromInt(Native.getDeclParameterKind(Context().nCtx(), NativeObject(), i)); switch (k) { - case Z3_parameter_kind.Z3_PARAMETER_INT: + case Z3_PARAMETER_INT: res[i] = new Parameter(k, Native.getDeclIntParameter(Context().nCtx(), NativeObject(), i)); break; - case Z3_parameter_kind.Z3_PARAMETER_DOUBLE: + case Z3_PARAMETER_DOUBLE: res[i] = new Parameter(k, Native.getDeclDoubleParameter(Context().nCtx(), NativeObject(), i)); break; - case Z3_parameter_kind.Z3_PARAMETER_SYMBOL: - res[i] = new Parameter(k, Symbol.Create(Context, Native.getDeclSymbolParameter(Context().nCtx(), NativeObject(), i))); + case Z3_PARAMETER_SYMBOL: + res[i] = new Parameter(k, Symbol.Create(Context(), Native.getDeclSymbolParameter(Context().nCtx(), NativeObject(), i))); break; - case Z3_parameter_kind.Z3_PARAMETER_SORT: - res[i] = new Parameter(k, Sort.Create(Context, Native.getDeclSortParameter(Context().nCtx(), NativeObject(), i))); + case Z3_PARAMETER_SORT: + res[i] = new Parameter(k, Sort.Create(Context(), Native.getDeclSortParameter(Context().nCtx(), NativeObject(), i))); break; - case Z3_parameter_kind.Z3_PARAMETER_AST: - res[i] = new Parameter(k, new AST(Context, Native.getDeclAstParameter(Context().nCtx(), NativeObject(), i))); + case Z3_PARAMETER_AST: + res[i] = new Parameter(k, new AST(Context(), Native.getDeclAstParameter(Context().nCtx(), NativeObject(), i))); break; - case Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL: - res[i] = new Parameter(k, new FuncDecl(Context, Native.getDeclFuncDeclParameter(Context().nCtx(), NativeObject(), i))); + case Z3_PARAMETER_FUNC_DECL: + res[i] = new Parameter(k, new FuncDecl(Context(), Native.getDeclFuncDeclParameter(Context().nCtx(), NativeObject(), i))); break; - case Z3_parameter_kind.Z3_PARAMETER_RATIONAL: + case Z3_PARAMETER_RATIONAL: res[i] = new Parameter(k, Native.getDeclRationalParameter(Context().nCtx(), NativeObject(), i)); break; default: @@ -244,21 +245,21 @@ import java.lang.Exception; } 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)); + { 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)); + { 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) != (long)Z3_ast_kind.Z3_FUNC_DECL_AST) + 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); } @@ -279,8 +280,8 @@ import java.lang.Exception; { - Context.CheckContextMatch(args); - return Expr.Create(Context, this, 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 index 7544aba11..341b82ec5 100644 --- a/src/api/java/com/Microsoft/Z3/FuncInterp.java +++ b/src/api/java/com/Microsoft/Z3/FuncInterp.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -28,13 +29,13 @@ import java.lang.Exception; public Expr Value() { - return Expr.Create(Context, Native.funcEntryGetValue(Context().nCtx(), NativeObject())); + return Expr.Create(Context(), Native.funcEntryGetValue(Context().nCtx(), NativeObject())); } /** * The number of arguments of the entry. **/ - public long NumArgs() { return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); } + public int NumArgs() { return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); } /** * The arguments of the function entry. @@ -44,10 +45,10 @@ import java.lang.Exception; - long n = NumArgs; + int n = NumArgs(); Expr[] res = new Expr[n]; - for (long i; i < n; i++) - res[i] = Expr.Create(Context, Native.funcEntryGetArg(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Expr.Create(Context(), Native.funcEntryGetArg(Context().nCtx(), NativeObject(), i)); return res; } @@ -56,10 +57,10 @@ import java.lang.Exception; **/ public String toString() { - long n = NumArgs; + int n = NumArgs(); String res = "["; Expr[] args = Args; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) res += args[i] + ", "; return res + Value + "]"; } @@ -81,13 +82,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.FuncEntry_DRQ.IncAndClear(Context, o); + Context().FuncEntry_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.FuncEntry_DRQ.Add(o); + Context().FuncEntry_DRQ().Add(o); super.DecRef(o); } }; @@ -95,7 +96,7 @@ import java.lang.Exception; /** * The number of entries in the function interpretation. **/ - public long NumEntries() { return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); } + public int NumEntries() { return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); } /** * The entries in the function interpretation @@ -105,10 +106,10 @@ import java.lang.Exception; - long n = NumEntries; + int n = NumEntries(); Entry[] res = new Entry[n]; - for (long i; i < n; i++) - res[i] = new Entry(Context, Native.funcInterpGetEntry(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = new Entry(Context(), Native.funcInterpGetEntry(Context().nCtx(), NativeObject(), i)); return res; } @@ -119,13 +120,13 @@ import java.lang.Exception; { - return Expr.Create(Context, Native.funcInterpGetElse(Context().nCtx(), NativeObject())); + return Expr.Create(Context(), Native.funcInterpGetElse(Context().nCtx(), NativeObject())); } /** * The arity of the function interpretation **/ - public long Arity() { return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); } + public int Arity() { return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); } /** * A string representation of the function interpretation. @@ -134,12 +135,12 @@ import java.lang.Exception; { String res = ""; res += "["; - for (Iterator e = Entries.iterator(); e.hasNext(); ) + for (Entry e: Entries) { - long n = e.NumArgs; + int n = e.NumArgs; if (n > 1) res += "["; Expr[] args = e.Args; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) { if (i != 0) res += ", "; res += args[i]; @@ -172,13 +173,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.FuncInterp_DRQ.IncAndClear(Context, o); + Context().FuncInterp_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.FuncInterp_DRQ.Add(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 index bfbefa203..9f522a768 100644 --- a/src/api/java/com/Microsoft/Z3/Goal.java +++ b/src/api/java/com/Microsoft/Z3/Goal.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -25,7 +26,7 @@ import java.lang.Exception; * 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)Native.goalPrecision(Context().nCtx(), NativeObject()); } + public Z3_goal_prec Precision() { return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(), NativeObject())); } /** * Indicates whether the goal is precise. @@ -54,18 +55,18 @@ import java.lang.Exception; - Context.CheckContextMatch(constraints); - for (Iterator c = constraints.iterator(); c.hasNext(); ) + 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); + Native.goalAssert(Context().nCtx(), NativeObject(), c.NativeObject()); } } /** * Indicates whether the goal contains `false'. **/ - public boolean Inconsistent() { return Native.goalInconsistent(Context().nCtx(), NativeObject()) != 0; } + public boolean Inconsistent() { return Native.goalInconsistent(Context().nCtx(), NativeObject()) ; } /** * The depth of the goal. @@ -73,7 +74,7 @@ import java.lang.Exception; * This tracks how many transformations were applied to it. * **/ - public long Depth() { return Native.goalDepth(Context().nCtx(), NativeObject()); } + public int Depth() { return Native.goalDepth(Context().nCtx(), NativeObject()); } /** * Erases all formulas from the given goal. @@ -86,7 +87,7 @@ import java.lang.Exception; /** * The number of formulas in the goal. **/ - public long Size() { return Native.goalSize(Context().nCtx(), NativeObject()); } + public int Size() { return Native.goalSize(Context().nCtx(), NativeObject()); } /** * The formulas in the goal. @@ -95,27 +96,27 @@ import java.lang.Exception; { - long n = Size; + int n = Size; BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = new BoolExpr(Context, Native.goalFormula(Context().nCtx(), NativeObject(), i)); + 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 long NumExprs() { return Native.goalNumExprs(Context().nCtx(), NativeObject()); } + 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()) != 0; } + 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()) != 0; } + public boolean IsDecidedUnsat() { return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject()) ; } /** * Translates (copies) the Goal to the target Context . @@ -133,11 +134,11 @@ import java.lang.Exception; **/ public Goal Simplify(Params p) { - Tactic t = Context.MkTactic("simplify"); + Tactic t = Context().MkTactic("simplify"); ApplyResult res = t.Apply(this, p); if (res.NumSubgoals == 0) - return Context.MkGoal(); + return Context().MkGoal(); else return res.Subgoals[0]; } @@ -154,7 +155,7 @@ import java.lang.Exception; Goal(Context ctx, long obj) { super(ctx, obj); { }} Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) - { super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? 1 : 0, (unsatCores) ? 1 : 0, (proofs) ? 1 : 0)); + { super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false, (unsatCores) ? true : false, (proofs) ? true : false)); } @@ -173,13 +174,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Goal_DRQ.IncAndClear(Context, o); + Context().Goal_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Goal_DRQ.Add(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 index 1b6291ce7..4d40bf66a 100644 --- a/src/api/java/com/Microsoft/Z3/IDecRefQueue.java +++ b/src/api/java/com/Microsoft/Z3/IDecRefQueue.java @@ -7,6 +7,7 @@ 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; */ @@ -23,8 +24,8 @@ import java.lang.Exception; protected Object m_lock = new Object(); - protected List m_queue = new List(); - final long m_move_limit = 1024; + 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); @@ -34,7 +35,7 @@ import java.lang.Exception; IncRef(ctx, o); - if (m_queue.Count >= m_move_limit) Clear(ctx); + if (m_queue.size() >= m_move_limit) Clear(ctx); } public void Add(long o) @@ -43,7 +44,7 @@ import java.lang.Exception; synchronized (m_lock) { - m_queue.Add(o); + m_queue.add(o); } } @@ -53,9 +54,9 @@ import java.lang.Exception; synchronized (m_lock) { - for (Iterator o = m_queue.iterator(); o.hasNext(); ) + for (Long o: m_queue) DecRef(ctx, o); - m_queue.Clear(); + m_queue.clear(); } } } diff --git a/src/api/java/com/Microsoft/Z3/IntExpr.java b/src/api/java/com/Microsoft/Z3/IntExpr.java index 888e441b3..d493947d9 100644 --- a/src/api/java/com/Microsoft/Z3/IntExpr.java +++ b/src/api/java/com/Microsoft/Z3/IntExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/IntNum.java b/src/api/java/com/Microsoft/Z3/IntNum.java index e4d0e72e2..494ac316b 100644 --- a/src/api/java/com/Microsoft/Z3/IntNum.java +++ b/src/api/java/com/Microsoft/Z3/IntNum.java @@ -7,6 +7,7 @@ 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; */ @@ -29,7 +30,7 @@ import java.lang.Exception; public long UInt64() { long res = 0; - if (Native.getNumeralLong64(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not a 64 bit unsigned"); return res; } @@ -40,7 +41,7 @@ import java.lang.Exception; public int Int() { int res = 0; - if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not an int"); return res; } @@ -51,7 +52,7 @@ import java.lang.Exception; public long Int64() { long res = 0; - if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) == 0) + if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true) throw new Z3Exception("Numeral is not an int64"); return res; } @@ -59,11 +60,11 @@ import java.lang.Exception; /** * Retrieve the int value. **/ - public long UInt() + public int UInt() { - long res = 0; - if (Native.getNumeralLong(Context().nCtx(), NativeObject(), res) == 0) - throw new Z3Exception("Numeral is not a long"); + int res = 0; + if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true) + throw new Z3Exception("Numeral is not a int"); return res; } @@ -72,7 +73,7 @@ import java.lang.Exception; **/ public BigInteger BigInteger() { - return BigInteger.Parse(this.ToString()); + return new BigInteger(this.toString()); } /** diff --git a/src/api/java/com/Microsoft/Z3/IntSort.java b/src/api/java/com/Microsoft/Z3/IntSort.java index 29ff35136..b347cc149 100644 --- a/src/api/java/com/Microsoft/Z3/IntSort.java +++ b/src/api/java/com/Microsoft/Z3/IntSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/IntSymbol.java b/src/api/java/com/Microsoft/Z3/IntSymbol.java index 0132def21..1750d87e6 100644 --- a/src/api/java/com/Microsoft/Z3/IntSymbol.java +++ b/src/api/java/com/Microsoft/Z3/IntSymbol.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/ListSort.java b/src/api/java/com/Microsoft/Z3/ListSort.java index 96829c11e..4efee3783 100644 --- a/src/api/java/com/Microsoft/Z3/ListSort.java +++ b/src/api/java/com/Microsoft/Z3/ListSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -109,7 +110,7 @@ import java.lang.Exception; ihead = 0, itail = 0; - NativeObject() = Native.mkListSort(ctx.nCtx(), name.NativeObject, elemSort.NativeObject, + NativeObject() = Native.mkListSort(ctx.nCtx(), name.NativeObject(), elemSort.NativeObject(), inil, iisnil, icons, iiscons, ihead, itail); nilDecl = new FuncDecl(ctx, inil); isNilDecl = new FuncDecl(ctx, iisnil); diff --git a/src/api/java/com/Microsoft/Z3/Log.java b/src/api/java/com/Microsoft/Z3/Log.java index bfcc2b1c5..2572f9880 100644 --- a/src/api/java/com/Microsoft/Z3/Log.java +++ b/src/api/java/com/Microsoft/Z3/Log.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/Model.java b/src/api/java/com/Microsoft/Z3/Model.java index e20a9d575..c0c0e2852 100644 --- a/src/api/java/com/Microsoft/Z3/Model.java +++ b/src/api/java/com/Microsoft/Z3/Model.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -24,7 +25,7 @@ import java.lang.Exception; { - Context.CheckContextMatch(a); + Context().CheckContextMatch(a); return ConstInterp(a.FuncDecl); } @@ -37,16 +38,16 @@ import java.lang.Exception; { - Context.CheckContextMatch(f); + Context().CheckContextMatch(f); if (f.Arity != 0 || - Native.getSortKind(Context().nCtx(), Native.getRange(Context().nCtx(), f.NativeObject)) == (long)Z3_sort_kind.Z3_ARRAY_SORT) + 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); + long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(), f.NativeObject()); if (n == 0) return null; else - return Expr.Create(Context, n); + return Expr.Create(Context(), n); } /** @@ -58,13 +59,13 @@ import java.lang.Exception; { - Context.CheckContextMatch(f); + Context().CheckContextMatch(f); - Z3_sort_kind sk = (Z3_sort_kind)Native.getSortKind(Context().nCtx(), Native.getRange(Context().nCtx(), f.NativeObject)); + 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); + long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(), f.NativeObject()); if (sk == Z3_sort_kind.Z3_ARRAY_SORT) { @@ -72,10 +73,10 @@ import java.lang.Exception; return null; else { - if (Native.isAsArray(Context().nCtx(), n) == 0) + 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)); + return FuncInterp(new FuncDecl(Context(), fd)); } } else @@ -85,18 +86,18 @@ import java.lang.Exception; } else { - long n = Native.modelGetFuncInterp(Context().nCtx(), NativeObject(), f.NativeObject); + long n = Native.modelGetFuncInterp(Context().nCtx(), NativeObject(), f.NativeObject()); if (n == 0) return null; else - return new FuncInterp(Context, n); + return new FuncInterp(Context(), n); } } /** * The number of constants that have an interpretation in the model. **/ - public long NumConsts() { return Native.modelGetNumConsts(Context().nCtx(), NativeObject()); } + public int NumConsts() { return Native.modelGetNumConsts(Context().nCtx(), NativeObject()); } /** * The function declarations of the constants in the model. @@ -105,17 +106,17 @@ import java.lang.Exception; { - long n = NumConsts; + int n = NumConsts(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context().nCtx(), NativeObject(), i)); + 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 long NumFuncs() { return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); } + public int NumFuncs() { return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); } /** * The function declarations of the function interpretations in the model. @@ -124,10 +125,10 @@ import java.lang.Exception; { - long n = NumFuncs; + int n = NumFuncs(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = new FuncDecl(Context(), Native.modelGetFuncDecl(Context().nCtx(), NativeObject(), i)); return res; } @@ -138,14 +139,14 @@ import java.lang.Exception; { - var nFuncs = NumFuncs; - var nConsts = NumConsts; - long n = nFuncs + nConsts; + var nFuncs = NumFuncs(); + var nConsts = NumConsts(); + int n = nFuncs + nConsts; FuncDecl[] res = new FuncDecl[n]; - for (long i; i < nConsts; i++) - res[i] = new FuncDecl(Context, Native.modelGetConstDecl(Context().nCtx(), NativeObject(), i)); - for (long i; i < nFuncs; i++) - res[nConsts + i] = new FuncDecl(Context, Native.modelGetFuncDecl(Context().nCtx(), NativeObject(), i)); + 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; } @@ -180,10 +181,10 @@ import java.lang.Exception; long v = 0; - if (Native.modelEval(Context().nCtx(), NativeObject(), t.NativeObject, (completion) ? 1 : 0, v) == 0) + if (Native.modelEval(Context().nCtx(), NativeObject(), t.NativeObject(), (completion) ? true : false, v) ^ true) throw new ModelEvaluationFailedException(); else - return Expr.Create(Context, v); + return Expr.Create(Context(), v); } /** @@ -200,7 +201,7 @@ import java.lang.Exception; /** * The number of uninterpreted sorts that the model has an interpretation for. **/ - public long NumSorts () { return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); } + public int NumSorts () { return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); } /** * The uninterpreted sorts that the model has an interpretation for. @@ -216,10 +217,10 @@ import java.lang.Exception; { - long n = NumSorts; + int n = NumSorts(); Sort[] res = new Sort[n]; - for (long i; i < n; i++) - res[i] = Sort.Create(Context, Native.modelGetSort(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Sort.Create(Context(), Native.modelGetSort(Context().nCtx(), NativeObject(), i)); return res; } @@ -234,11 +235,11 @@ import java.lang.Exception; - ASTVector nUniv = new ASTVector(Context, Native.modelGetSortUniverse(Context().nCtx(), NativeObject(), s.NativeObject)); - long n = nUniv.Size; + ASTVector nUniv = new ASTVector(Context(), Native.modelGetSortUniverse(Context().nCtx(), NativeObject(), s.NativeObject())); + int n = nUniv.Size; Expr[] res = new Expr[n]; - for (long i; i < n; i++) - res[i] = Expr.Create(Context, nUniv[i].NativeObject); + for (int i = 0; i < n; i++) + res[i] = Expr.Create(Context(), nUniv[i].NativeObject()); return res; } @@ -271,13 +272,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Model_DRQ.IncAndClear(Context, o); + Context().Model_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Model_DRQ.Add(o); + Context().Model_DRQ().Add(o); super.DecRef(o); } } diff --git a/src/api/java/com/Microsoft/Z3/Native.java b/src/api/java/com/Microsoft/Z3/Native.java index 261e0663f..e42d8b7ba 100644 --- a/src/api/java/com/Microsoft/Z3/Native.java +++ b/src/api/java/com/Microsoft/Z3/Native.java @@ -4,8 +4,8 @@ public final class Native { public static class IntPtr { public int value; } public static class LongPtr { public long value; } public static class StringPtr { public String value; } - public static class errorHandler {}; - static { System.loadLibrary(""); } + public static class errorHandler { public long ptr; } + 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); diff --git a/src/api/java/com/Microsoft/Z3/ParamDescrs.java b/src/api/java/com/Microsoft/Z3/ParamDescrs.java index 37ee77b7e..edba1ceab 100644 --- a/src/api/java/com/Microsoft/Z3/ParamDescrs.java +++ b/src/api/java/com/Microsoft/Z3/ParamDescrs.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -21,7 +22,7 @@ import java.lang.Exception; public void Validate(Params p) { - Native.paramsValidate(Context().nCtx(), p.NativeObject, NativeObject()); + Native.paramsValidate(Context().nCtx(), p.NativeObject(), NativeObject()); } /** @@ -30,7 +31,7 @@ import java.lang.Exception; public Z3_param_kind GetKind(Symbol name) { - return (Z3_param_kind)Native.paramDescrsGetKind(Context().nCtx(), NativeObject(), name.NativeObject); + return Z3_param_kind.fromInt(Native.paramDescrsGetKind(Context().nCtx(), NativeObject(), name.NativeObject())); } /** @@ -38,10 +39,10 @@ import java.lang.Exception; **/ public Symbol[] Names() { - long sz = Native.paramDescrsSize(Context().nCtx(), NativeObject()); + int sz = Native.paramDescrsSize(Context().nCtx(), NativeObject()); Symbol[] names = new Symbol[sz]; - for (long i; i < sz; ++i) { - names[i] = Symbol.Create(Context, Native.paramDescrsGetName(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < sz; ++i) { + names[i] = Symbol.Create(Context(), Native.paramDescrsGetName(Context().nCtx(), NativeObject(), i)); } return names; } @@ -49,7 +50,7 @@ import java.lang.Exception; /** * The size of the ParamDescrs. **/ - public long Size() { return Native.paramDescrsSize(Context().nCtx(), NativeObject()); } + public int Size() { return Native.paramDescrsSize(Context().nCtx(), NativeObject()); } /** * Retrieves a string representation of the ParamDescrs. @@ -79,13 +80,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.ParamDescrs_DRQ.IncAndClear(Context, o); + Context().ParamDescrs_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.ParamDescrs_DRQ.Add(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 index d5c042d74..1107a80ee 100644 --- a/src/api/java/com/Microsoft/Z3/Params.java +++ b/src/api/java/com/Microsoft/Z3/Params.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -22,17 +23,17 @@ import java.lang.Exception; { - Native.paramsSetBool(Context().nCtx(), NativeObject(), name.NativeObject, (value) ? 1 : 0); + Native.paramsSetBool(Context().nCtx(), NativeObject(), name.NativeObject(), (value) ? true : false); } /** * Adds a parameter setting. **/ - public void Add(Symbol name, long value) + public void Add(Symbol name, int value) { - Native.paramsSetLong(Context().nCtx(), NativeObject(), name.NativeObject, value); + Native.paramsSetInt(Context().nCtx(), NativeObject(), name.NativeObject(), value); } /** @@ -42,7 +43,7 @@ import java.lang.Exception; { - Native.paramsSetDouble(Context().nCtx(), NativeObject(), name.NativeObject, value); + Native.paramsSetDouble(Context().nCtx(), NativeObject(), name.NativeObject(), value); } /** @@ -53,7 +54,7 @@ import java.lang.Exception; - Native.paramsSetSymbol(Context().nCtx(), NativeObject(), name.NativeObject, value.NativeObject); + Native.paramsSetSymbol(Context().nCtx(), NativeObject(), name.NativeObject(), value.NativeObject()); } /** @@ -61,15 +62,15 @@ import java.lang.Exception; **/ public void Add(String name, boolean value) { - Native.paramsSetBool(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, (value) ? 1 : 0); + Native.paramsSetBool(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), (value) ? true : false); } /** * Adds a parameter setting. **/ - public void Add(String name, long value) + public void Add(String name, int value) { - Native.paramsSetLong(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value); + Native.paramsSetInt(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); } /** @@ -77,7 +78,7 @@ import java.lang.Exception; **/ public void Add(String name, double value) { - Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value); + Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); } /** @@ -87,7 +88,7 @@ import java.lang.Exception; { - Native.paramsSetSymbol(Context().nCtx(), NativeObject(), Context.MkSymbol(name).NativeObject, value.NativeObject); + Native.paramsSetSymbol(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value.NativeObject()); } /** @@ -118,13 +119,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Params_DRQ.IncAndClear(Context, o); + Context().Params_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Params_DRQ.Add(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 index 0e87dc254..99fb53b9c 100644 --- a/src/api/java/com/Microsoft/Z3/Pattern.java +++ b/src/api/java/com/Microsoft/Z3/Pattern.java @@ -7,6 +7,7 @@ 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; */ @@ -21,7 +22,7 @@ import java.lang.Exception; /** * The number of terms in the pattern. **/ - public long NumTerms() { return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); } + public int NumTerms() { return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); } /** * The terms in the pattern. @@ -30,10 +31,10 @@ import java.lang.Exception; { - long n = NumTerms; + int n = NumTerms(); Expr[] res = new Expr[n]; - for (long i; i < n; i++) - res[i] = Expr.Create(Context, Native.getPattern(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Expr.Create(Context(), Native.getPattern(Context().nCtx(), NativeObject(), i)); return res; } diff --git a/src/api/java/com/Microsoft/Z3/Probe.java b/src/api/java/com/Microsoft/Z3/Probe.java index 537e9ef7f..8d1ba1a97 100644 --- a/src/api/java/com/Microsoft/Z3/Probe.java +++ b/src/api/java/com/Microsoft/Z3/Probe.java @@ -7,6 +7,7 @@ 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; */ @@ -29,8 +30,8 @@ import java.lang.Exception; { - Context.CheckContextMatch(g); - return Native.probeApply(Context().nCtx(), NativeObject(), g.NativeObject); + Context().CheckContextMatch(g); + return Native.probeApply(Context().nCtx(), NativeObject(), g.NativeObject()); } /** @@ -67,13 +68,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Probe_DRQ.IncAndClear(Context, o); + Context().Probe_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Probe_DRQ.Add(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 index 8b4df947e..ad05c544b 100644 --- a/src/api/java/com/Microsoft/Z3/Quantifier.java +++ b/src/api/java/com/Microsoft/Z3/Quantifier.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,7 +19,7 @@ import java.lang.Exception; /** * Indicates whether the quantifier is universal. **/ - public boolean IsUniversal() { return Native.isQuantifierForall(Context().nCtx(), NativeObject()) != 0; } + public boolean IsUniversal() { return Native.isQuantifierForall(Context().nCtx(), NativeObject()) ; } /** * Indicates whether the quantifier is existential. @@ -28,12 +29,12 @@ import java.lang.Exception; /** * The weight of the quantifier. **/ - public long Weight() { return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); } + public int Weight() { return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); } /** * The number of patterns. **/ - public long NumPatterns() { return Native.getQuantifierNumPatterns(Context().nCtx(), NativeObject()); } + public int NumPatterns() { return Native.getQuantifierNumPatterns(Context().nCtx(), NativeObject()); } /** * The patterns. @@ -42,17 +43,17 @@ import java.lang.Exception; { - long n = NumPatterns; + int n = NumPatterns(); Pattern[] res = new Pattern[n]; - for (long i; i < n; i++) - res[i] = new Pattern(Context, Native.getQuantifierPatternAst(Context().nCtx(), NativeObject(), i)); + 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 long NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context().nCtx(), NativeObject()); } + public int NumNoPatterns() { return Native.getQuantifierNumNoPatterns(Context().nCtx(), NativeObject()); } /** * The no-patterns. @@ -61,17 +62,17 @@ import java.lang.Exception; { - long n = NumNoPatterns; + int n = NumNoPatterns(); Pattern[] res = new Pattern[n]; - for (long i; i < n; i++) - res[i] = new Pattern(Context, Native.getQuantifierNoPatternAst(Context().nCtx(), NativeObject(), i)); + 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 long NumBound() { return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); } + public int NumBound() { return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); } /** * The symbols for the bound variables. @@ -80,10 +81,10 @@ import java.lang.Exception; { - long n = NumBound; + int n = NumBound(); Symbol[] res = new Symbol[n]; - for (long i; i < n; i++) - res[i] = Symbol.Create(Context, Native.getQuantifierBoundName(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Symbol.Create(Context(), Native.getQuantifierBoundName(Context().nCtx(), NativeObject(), i)); return res; } @@ -94,10 +95,10 @@ import java.lang.Exception; { - long n = NumBound; + int n = NumBound(); Sort[] res = new Sort[n]; - for (long i; i < n; i++) - res[i] = Sort.Create(Context, Native.getQuantifierBoundSort(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Sort.Create(Context(), Native.getQuantifierBoundSort(Context().nCtx(), NativeObject(), i)); return res; } @@ -108,10 +109,10 @@ import java.lang.Exception; { - return new BoolExpr(Context, Native.getQuantifierBody(Context().nCtx(), NativeObject())); + return new BoolExpr(Context(), Native.getQuantifierBody(Context().nCtx(), NativeObject())); } - Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { super(ctx); @@ -123,38 +124,38 @@ import java.lang.Exception; - Context.CheckContextMatch(patterns); - Context.CheckContextMatch(noPatterns); - Context.CheckContextMatch(sorts); - Context.CheckContextMatch(names); - Context.CheckContextMatch(body); + Context().CheckContextMatch(patterns); + Context().CheckContextMatch(noPatterns); + Context().CheckContextMatch(sorts); + Context().CheckContextMatch(names); + Context().CheckContextMatch(body); - if (sorts.Length != names.Length) + 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) { - NativeObject() = Native.mkQuantifier(ctx.nCtx(), (isForall) ? 1 : 0, weight, + NativeObject() = 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); + body.NativeObject()); } else { - NativeObject() = Native.mkQuantifierEx(ctx.nCtx(), (isForall) ? 1 : 0, weight, + NativeObject() = 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); + body.NativeObject()); } } - Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body, long weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) + Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body, int weight, Pattern[] patterns, Expr[] noPatterns, Symbol quantifierID, Symbol skolemID) { super(ctx); @@ -163,26 +164,26 @@ import java.lang.Exception; - Context.CheckContextMatch(noPatterns); - Context.CheckContextMatch(patterns); - //Context.CheckContextMatch(bound); - Context.CheckContextMatch(body); + Context().CheckContextMatch(noPatterns); + Context().CheckContextMatch(patterns); + //Context().CheckContextMatch(bound); + Context().CheckContextMatch(body); if (noPatterns == null && quantifierID == null && skolemID == null) { - NativeObject() = Native.mkQuantifierConst(ctx.nCtx(), (isForall) ? 1 : 0, weight, + NativeObject() = Native.mkQuantifierConst(ctx.nCtx(), (isForall) ? true : false, weight, AST.ArrayLength(bound), AST.ArrayToNative(bound), AST.ArrayLength(patterns), AST.ArrayToNative(patterns), - body.NativeObject); + body.NativeObject()); } else { - NativeObject() = Native.mkQuantifierConstEx(ctx.nCtx(), (isForall) ? 1 : 0, weight, + NativeObject() = 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); + body.NativeObject()); } } diff --git a/src/api/java/com/Microsoft/Z3/RatNum.java b/src/api/java/com/Microsoft/Z3/RatNum.java index 7921e70ef..ad0982a95 100644 --- a/src/api/java/com/Microsoft/Z3/RatNum.java +++ b/src/api/java/com/Microsoft/Z3/RatNum.java @@ -7,6 +7,7 @@ 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; */ @@ -23,7 +24,7 @@ import java.lang.Exception; { - return new IntNum(Context, Native.getNumerator(Context().nCtx(), NativeObject())); + return new IntNum(Context(), Native.getNumerator(Context().nCtx(), NativeObject())); } /** @@ -33,7 +34,7 @@ import java.lang.Exception; { - return new IntNum(Context, Native.getDenominator(Context().nCtx(), NativeObject())); + return new IntNum(Context(), Native.getDenominator(Context().nCtx(), NativeObject())); } /** @@ -41,8 +42,8 @@ import java.lang.Exception; **/ public BigInteger BigIntNumerator() { - IntNum n = Numerator; - return BigInteger.Parse(n.ToString()); + IntNum n = Numerator(); + return new BigInteger(n.toString()); } /** @@ -50,15 +51,15 @@ import java.lang.Exception; **/ public BigInteger BigIntDenominator() { - IntNum n = Denominator; - return BigInteger.Parse(n.ToString()); + 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(long precision) + public String ToDecimalString(int precision) { return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(), precision); } diff --git a/src/api/java/com/Microsoft/Z3/RealExpr.java b/src/api/java/com/Microsoft/Z3/RealExpr.java index 8f2b139bd..2f06e4643 100644 --- a/src/api/java/com/Microsoft/Z3/RealExpr.java +++ b/src/api/java/com/Microsoft/Z3/RealExpr.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/RealSort.java b/src/api/java/com/Microsoft/Z3/RealSort.java index 39aa849ab..d85aeccd1 100644 --- a/src/api/java/com/Microsoft/Z3/RealSort.java +++ b/src/api/java/com/Microsoft/Z3/RealSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/RelationSort.java b/src/api/java/com/Microsoft/Z3/RelationSort.java index 3948e1651..85f083b57 100644 --- a/src/api/java/com/Microsoft/Z3/RelationSort.java +++ b/src/api/java/com/Microsoft/Z3/RelationSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -18,7 +19,7 @@ import java.lang.Exception; /** * The arity of the relation sort. **/ - public long Arity() { return Native.getRelationArity(Context().nCtx(), NativeObject()); } + public int Arity() { return Native.getRelationArity(Context().nCtx(), NativeObject()); } /** * The sorts of the columns of the relation sort. @@ -30,10 +31,10 @@ import java.lang.Exception; if (m_columnSorts != null) return m_columnSorts; - long n = Arity; + int n = Arity; Sort[] res = new Sort[n]; - for (long i; i < n; i++) - res[i] = Sort.Create(Context, Native.getRelationColumn(Context().nCtx(), NativeObject(), i)); + for (int i = 0; i < n; i++) + res[i] = Sort.Create(Context(), Native.getRelationColumn(Context().nCtx(), NativeObject(), i)); return res; } diff --git a/src/api/java/com/Microsoft/Z3/SetSort.java b/src/api/java/com/Microsoft/Z3/SetSort.java index 2f008f4db..2ed16c09b 100644 --- a/src/api/java/com/Microsoft/Z3/SetSort.java +++ b/src/api/java/com/Microsoft/Z3/SetSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -20,7 +21,7 @@ import java.lang.Exception; } SetSort(Context ctx, Sort ty) - { super(ctx, Native.mkSetSort(ctx.nCtx(), ty.NativeObject)); + { 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 index a206114f1..5fda96bb1 100644 --- a/src/api/java/com/Microsoft/Z3/Solver.java +++ b/src/api/java/com/Microsoft/Z3/Solver.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -32,14 +33,14 @@ import java.lang.Exception; { - Context.CheckContextMatch(value); - Native.solverSetParams(Context().nCtx(), NativeObject(), value.NativeObject); + 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())); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.solverGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -47,7 +48,7 @@ import java.lang.Exception; * * **/ - public long NumScopes() { return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); } + public int NumScopes() { return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); } /** * Creates a backtracking point. @@ -63,7 +64,7 @@ import java.lang.Exception; * Note that an exception is thrown if is not smaller than NumScopes * **/ - public void Pop(long n) + public void Pop(int n) { Native.solverPop(Context().nCtx(), NativeObject(), n); } @@ -85,19 +86,19 @@ import java.lang.Exception; - Context.CheckContextMatch(constraints); - for (Iterator a = constraints.iterator(); a.hasNext(); ) + Context().CheckContextMatch(constraints); + for (BoolExpr a: constraints) { - Native.solverAssert(Context().nCtx(), NativeObject(), a.NativeObject); + Native.solverAssert(Context().nCtx(), NativeObject(), a.NativeObject()); } } /** * The number of assertions in the solver. **/ - public long NumAssertions() + public int NumAssertions() { - ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context().nCtx(), NativeObject())); + ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(Context().nCtx(), NativeObject())); return ass.Size; } @@ -108,11 +109,11 @@ import java.lang.Exception; { - ASTVector ass = new ASTVector(Context, Native.solverGetAssertions(Context().nCtx(), NativeObject())); - long n = ass.Size; + ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(Context().nCtx(), NativeObject())); + int n = ass.Size; BoolExpr[] res = new BoolExpr[n]; - for (long i; i < n; i++) - res[i] = new BoolExpr(Context, ass[i].NativeObject); + for (int i = 0; i < n; i++) + res[i] = new BoolExpr(Context(), ass[i].NativeObject()); return res; } @@ -128,13 +129,13 @@ import java.lang.Exception; { Z3_lbool r; if (assumptions == null) - r = (Z3_lbool)Native.solverCheck(Context().nCtx(), NativeObject()); + r = Z3_lbool.fromInt(Native.solverCheck(Context().nCtx(), NativeObject())); else - r = (Z3_lbool)Native.solverCheckAssumptions(Context().nCtx(), NativeObject(), (long)assumptions.Length, AST.ArrayToNative(assumptions)); + r = Z3_lbool.fromInt(Native.solverCheckAssumptions(Context().nCtx(), NativeObject(), (int)assumptions.length, AST.ArrayToNative(assumptions))); switch (r) { - case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE; - case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE; + case Z3_L_TRUE: return Status.SATISFIABLE; + case Z3_L_FALSE: return Status.UNSATISFIABLE; default: return Status.UNKNOWN; } } @@ -152,7 +153,7 @@ import java.lang.Exception; if (x == 0) return null; else - return new Model(Context, x); + return new Model(Context(), x); } /** @@ -168,7 +169,7 @@ import java.lang.Exception; if (x == 0) return null; else - return Expr.Create(Context, x); + return Expr.Create(Context(), x); } /** @@ -183,11 +184,11 @@ import java.lang.Exception; { - ASTVector core = new ASTVector(Context, Native.solverGetUnsatCore(Context().nCtx(), NativeObject())); - long n = core.Size; + ASTVector core = new ASTVector(Context(), Native.solverGetUnsatCore(Context().nCtx(), NativeObject())); + int n = core.Size; Expr[] res = new Expr[n]; - for (long i; i < n; i++) - res[i] = Expr.Create(Context, core[i].NativeObject); + for (int i = 0; i < n; i++) + res[i] = Expr.Create(Context(), core[i].NativeObject()); return res; } @@ -208,7 +209,7 @@ import java.lang.Exception; { - return new Statistics(Context, Native.solverGetStatistics(Context().nCtx(), NativeObject())); + return new Statistics(Context(), Native.solverGetStatistics(Context().nCtx(), NativeObject())); } /** @@ -239,13 +240,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Solver_DRQ.IncAndClear(Context, o); + Context().Solver_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Solver_DRQ.Add(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 index d328071dd..f1933fccd 100644 --- a/src/api/java/com/Microsoft/Z3/Sort.java +++ b/src/api/java/com/Microsoft/Z3/Sort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -57,12 +58,12 @@ import java.lang.Exception; /** * Returns a unique identifier for the sort. **/ - public long Id() { return Native.getSortId(Context().nCtx(), NativeObject()); } + public int Id() { return Native.getSortId(Context().nCtx(), NativeObject()); } /** * The kind of the sort. **/ - public Z3_sort_kind SortKind() { return (Z3_sort_kind)Native.getSortKind(Context().nCtx(), NativeObject()); } + public Z3_sort_kind SortKind() { return Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(), NativeObject())); } /** * The name of the sort @@ -70,7 +71,7 @@ import java.lang.Exception; public Symbol Name() { - return Symbol.Create(Context, Native.getSortName(Context().nCtx(), NativeObject())); + return Symbol.Create(Context(), Native.getSortName(Context().nCtx(), NativeObject())); } /** @@ -89,7 +90,7 @@ import java.lang.Exception; void CheckNativeObject(long obj) { - if (Native.getAstKind(Context().nCtx(), obj) != (long)Z3_ast_kind.Z3_SORT_AST) + 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); } @@ -99,17 +100,17 @@ import java.lang.Exception; - switch ((Z3_sort_kind)Native.getSortKind(ctx.nCtx(), obj)) + switch (Z3_sort_kind.fromInt(Native.getSortKind(ctx.nCtx(), obj))) { - case Z3_sort_kind.Z3_ARRAY_SORT: return new ArraySort(ctx, obj); - case Z3_sort_kind.Z3_BOOL_SORT: return new BoolSort(ctx, obj); - case Z3_sort_kind.Z3_BV_SORT: return new BitVecSort(ctx, obj); - case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeSort(ctx, obj); - case Z3_sort_kind.Z3_INT_SORT: return new IntSort(ctx, obj); - case Z3_sort_kind.Z3_REAL_SORT: return new RealSort(ctx, obj); - case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj); - case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj); - case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj); + 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 index d0f4021ed..ec64ee0b3 100644 --- a/src/api/java/com/Microsoft/Z3/Statistics.java +++ b/src/api/java/com/Microsoft/Z3/Statistics.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -27,7 +28,7 @@ import java.lang.Exception; /** * The uint-value of the entry. **/ - public long UIntValue() { return m_long; } + public int UIntValue() { return m_int; } /** * The double-value of the entry. **/ @@ -35,7 +36,7 @@ import java.lang.Exception; /** * True if the entry is uint-valued. **/ - public boolean IsUInt() { return m_is_long; } + public boolean IsUInt() { return m_is_int; } /** * True if the entry is double-valued. **/ @@ -49,9 +50,9 @@ import java.lang.Exception; if (IsUInt) - return m_long.ToString(); + return m_int.toString(); else if (IsDouble) - return m_double.ToString(); + return m_double.toString(); else throw new Z3Exception("Unknown statistical entry type"); } @@ -64,15 +65,15 @@ import java.lang.Exception; return Key + ": " + Value; } - private boolean m_is_long = false; + private boolean m_is_int = false; private boolean m_is_double = false; - private long m_long = 0; + private int m_int = 0; private double m_double = 0.0; - Entry(String k, long v) + Entry(String k, int v) { Key = k; - m_is_long = true; - m_long = v; + m_is_int = true; + m_int = v; } Entry(String k, double v) { @@ -93,7 +94,7 @@ import java.lang.Exception; /** * The number of statistical data. **/ - public long Size() { return Native.statsSize(Context().nCtx(), NativeObject()); } + public int Size() { return Native.statsSize(Context().nCtx(), NativeObject()); } /** * The data entries. @@ -104,15 +105,15 @@ import java.lang.Exception; - long n = Size; + int n = Size; Entry[] res = new Entry[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) { Entry e; String k = Native.statsGetKey(Context().nCtx(), NativeObject(), i); - if (Native.statsIsLong(Context().nCtx(), NativeObject(), i) != 0) - e = new Entry(k, Native.statsGetLongValue(Context().nCtx(), NativeObject(), i)); - else if (Native.statsIsDouble(Context().nCtx(), NativeObject(), i) != 0) + if (Native.statsIsInt(Context().nCtx(), NativeObject(), i) ) + e = new Entry(k, Native.statsGetIntValue(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"); @@ -128,9 +129,9 @@ import java.lang.Exception; { - long n = Size; + int n = Size; String[] res = new String[n]; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) res[i] = Native.statsGetKey(Context().nCtx(), NativeObject(), i); return res; } @@ -141,9 +142,9 @@ import java.lang.Exception; **/ public Entry get(String key) { - long n = Size; + int n = Size; Entry[] es = Entries; - for (long i; i < n; i++) + for (int i = 0; i < n; i++) if (es[i].Key == key) return es[i]; return null; @@ -169,13 +170,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Statistics_DRQ.IncAndClear(Context, o); + Context().Statistics_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Statistics_DRQ.Add(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 index 9eb75060c..64bd9f767 100644 --- a/src/api/java/com/Microsoft/Z3/Status.java +++ b/src/api/java/com/Microsoft/Z3/Status.java @@ -7,27 +7,28 @@ 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 + public class Status { /// /// Used to signify an unsatisfiable status. /// - UNSATISFIABLE (1), +public static final int UNSATISFIABLE = 1; /// /// Used to signify an unknown status. /// - UNKNOWN (0), +public static final int UNKNOWN = 0; /// /// Used to signify a satisfiable status. /// - SATISFIABLE (1) +public static final int SATISFIABLE = 1; } diff --git a/src/api/java/com/Microsoft/Z3/StringSymbol.java b/src/api/java/com/Microsoft/Z3/StringSymbol.java index 27157599d..1ff869002 100644 --- a/src/api/java/com/Microsoft/Z3/StringSymbol.java +++ b/src/api/java/com/Microsoft/Z3/StringSymbol.java @@ -7,6 +7,7 @@ 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; */ diff --git a/src/api/java/com/Microsoft/Z3/Symbol.java b/src/api/java/com/Microsoft/Z3/Symbol.java index 54caf9f1c..b7653414d 100644 --- a/src/api/java/com/Microsoft/Z3/Symbol.java +++ b/src/api/java/com/Microsoft/Z3/Symbol.java @@ -7,6 +7,7 @@ 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; */ @@ -19,7 +20,7 @@ import java.lang.Exception; /** * The kind of the symbol (int or string) **/ - protected Z3_symbol_kind Kind() { return (Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), NativeObject()); } + protected Z3_symbol_kind Kind() { return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(), NativeObject())); } /** * Indicates whether the symbol is of Int kind @@ -43,7 +44,7 @@ import java.lang.Exception; public String toString() { if (IsIntSymbol()) - return ((IntSymbol)this).Int.ToString(); + return ((IntSymbol)this).Int.toString(); else if (IsStringSymbol()) return ((StringSymbol)this).String; else @@ -62,10 +63,10 @@ import java.lang.Exception; - switch ((Z3_symbol_kind)Native.getSymbolKind(ctx.nCtx(), obj)) + switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj))) { - case Z3_symbol_kind.Z3_INT_SYMBOL: return new IntSymbol(ctx, obj); - case Z3_symbol_kind.Z3_STRING_SYMBOL: return new StringSymbol(ctx, obj); + 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 index 275205be5..fd560847a 100644 --- a/src/api/java/com/Microsoft/Z3/Tactic.java +++ b/src/api/java/com/Microsoft/Z3/Tactic.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -32,7 +33,7 @@ import java.lang.Exception; /** * Retrieves parameter descriptions for Tactics. **/ - public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context, Native.tacticGetParamDescrs(Context().nCtx(), NativeObject())); } + public ParamDescrs ParameterDescriptions() { return new ParamDescrs(Context(), Native.tacticGetParamDescrs(Context().nCtx(), NativeObject())); } /** @@ -43,13 +44,13 @@ import java.lang.Exception; - Context.CheckContextMatch(g); + Context().CheckContextMatch(g); if (p == null) - return new ApplyResult(Context, Native.tacticApply(Context().nCtx(), NativeObject(), g.NativeObject)); + 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)); + Context().CheckContextMatch(p); + return new ApplyResult(Context(), Native.tacticApplyEx(Context().nCtx(), NativeObject(), g.NativeObject(), p.NativeObject())); } } @@ -72,7 +73,7 @@ import java.lang.Exception; { - return Context.MkSolver(this); + return Context().MkSolver(this); } Tactic(Context ctx, long obj) @@ -99,13 +100,13 @@ import java.lang.Exception; void IncRef(long o) { - Context.Tactic_DRQ.IncAndClear(Context, o); + Context().Tactic_DRQ().IncAndClear(Context(), o); super.IncRef(o); } void DecRef(long o) { - Context.Tactic_DRQ.Add(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 index 2e682343a..0ac03bb88 100644 --- a/src/api/java/com/Microsoft/Z3/TupleSort.java +++ b/src/api/java/com/Microsoft/Z3/TupleSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -22,13 +23,13 @@ import java.lang.Exception; { - return new FuncDecl(Context, Native.getTupleSortMkDecl(Context().nCtx(), NativeObject())); + return new FuncDecl(Context(), Native.getTupleSortMkDecl(Context().nCtx(), NativeObject())); } /** * The number of fields in the tuple. **/ - public long NumFields() { return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); } + public int NumFields() { return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); } /** * The field declarations. @@ -37,20 +38,20 @@ import java.lang.Exception; { - long n = NumFields; + int n = NumFields(); FuncDecl[] res = new FuncDecl[n]; - for (long i; i < n; i++) - res[i] = new FuncDecl(Context, Native.getTupleSortFieldDecl(Context().nCtx(), NativeObject(), i)); + 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, long numFields, Symbol[] fieldNames, Sort[] fieldSorts) + TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames, Sort[] fieldSorts) { super(ctx); long t = 0; - NativeObject() = Native.mkTupleSort(ctx.nCtx(), name.NativeObject, numFields, + NativeObject() = 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 index f8b91103c..3c732901d 100644 --- a/src/api/java/com/Microsoft/Z3/UninterpretedSort.java +++ b/src/api/java/com/Microsoft/Z3/UninterpretedSort.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -20,7 +21,7 @@ import java.lang.Exception; } UninterpretedSort(Context ctx, Symbol s) - { super(ctx, Native.mkUninterpretedSort(ctx.nCtx(), s.NativeObject)); + { super(ctx, Native.mkUninterpretedSort(ctx.nCtx(), s.NativeObject())); } diff --git a/src/api/java/com/Microsoft/Z3/Version.java b/src/api/java/com/Microsoft/Z3/Version.java index ecf451e2f..c3fc4268d 100644 --- a/src/api/java/com/Microsoft/Z3/Version.java +++ b/src/api/java/com/Microsoft/Z3/Version.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -21,9 +22,9 @@ import java.lang.Exception; /** * The major version **/ - public long Major() + public int Major() { - long major = 0, minor = 0, build = 0, revision = 0; + int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); return major; } @@ -31,9 +32,9 @@ import java.lang.Exception; /** * The minor version **/ - public long Minor() + public int Minor() { - long major = 0, minor = 0, build = 0, revision = 0; + int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); return minor; } @@ -41,9 +42,9 @@ import java.lang.Exception; /** * The build version **/ - public long Build() + public int Build() { - long major = 0, minor = 0, build = 0, revision = 0; + int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); return build; } @@ -51,9 +52,9 @@ import java.lang.Exception; /** * The revision **/ - public long Revision() + public int Revision() { - long major = 0, minor = 0, build = 0, revision = 0; + int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); return revision; } @@ -65,8 +66,8 @@ import java.lang.Exception; { - long major = 0, minor = 0, build = 0, revision = 0; + int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); - return major.ToString() + "." + minor.ToString() + "." + build.ToString() + "." + revision.ToString(); + return major.toString() + "." + minor.toString() + "." + build.toString() + "." + revision.toString(); } } diff --git a/src/api/java/com/Microsoft/Z3/Z3Exception.java b/src/api/java/com/Microsoft/Z3/Z3Exception.java index 0bca047ab..7036558c7 100644 --- a/src/api/java/com/Microsoft/Z3/Z3Exception.java +++ b/src/api/java/com/Microsoft/Z3/Z3Exception.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ diff --git a/src/api/java/com/Microsoft/Z3/Z3Object.java b/src/api/java/com/Microsoft/Z3/Z3Object.java index 6a8392a86..d4bdf08f7 100644 --- a/src/api/java/com/Microsoft/Z3/Z3Object.java +++ b/src/api/java/com/Microsoft/Z3/Z3Object.java @@ -7,6 +7,7 @@ package com.Microsoft.Z3; import java.math.BigInteger; import java.util.*; import java.lang.Exception; +import com.Microsoft.Z3.Enumerations.*; /* using System; */ @@ -105,14 +106,14 @@ import java.lang.Exception; if (a == null) return null; - long[] an = new long[a.Length]; - for (long i; i < a.Length; i++) + 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 long ArrayLength(Z3Object[] a) + static int ArrayLength(Z3Object[] a) { - return (a == null)?0:(long)a.Length; + return (a == null)?0:(int)a.length; } } diff --git a/src/api/java/mk_java.py b/src/api/java/mk_java.py index 81b4a08b6..fe7f50a25 100644 --- a/src/api/java/mk_java.py +++ b/src/api/java/mk_java.py @@ -11,14 +11,29 @@ CS="../dotnet/" EXT=".cs" EXCLUDE=["Enumerations.cs", "Native.cs", "AssemblyInfo.cs"] OUTDIR="com/Microsoft/Z3/" +ENUMS_FILE = "Enumerations.cs" import os import fileinput import string import re +EXCLUDE_METHODS = [ [ "Context.cs", "public Expr MkNumeral(ulong" ], + [ "Context.cs", "public Expr MkNumeral(uint" ], + [ "Context.cs", "public RatNum MkReal(ulong" ], + [ "Context.cs", "public RatNum MkReal(uint" ], + [ "Context.cs", "public IntNum MkInt(ulong" ], + [ "Context.cs", "public IntNum MkInt(uint" ], + [ "Context.cs", "public BitVecNum MkBV(ulong" ], + [ "Context.cs", "public BitVecNum MkBV(uint" ], + ] + +ENUMS = [] + def mk_java_bindings(): - print "Generating Java bindings (from C# bindings in " + CS + ")." + print "Generating Java bindings (from C# bindings in " + CS + ")..." + print "Finding enumerations in " + ENUMS_FILE + "..." + find_enums(ENUMS_FILE) for root, dirs, files in os.walk(CS): for fn in files: if not fn in EXCLUDE and fn.endswith(EXT): @@ -31,14 +46,14 @@ def subst_getters(s, getters): def type_replace(s): s = s.replace(" bool", " boolean") s = s.replace("(bool", "(boolean") - s = s.replace("uint", "long") + s = s.replace("uint", "int") s = s.replace("ulong", "long") s = s.replace("string", "String") s = s.replace("IntPtr", "long") s = s.replace("Dictionary<", "Map<") s = s.replace("UInt64", "long") s = s.replace("Int64", "long") - s = s.replace("List", "List") + s = s.replace("List", "LinkedList") s = s.replace("System.Exception", "Exception") return s @@ -55,12 +70,54 @@ def rename_native(s): s = c0 + c1 + c2 return s +def find_enums(fn): + for line in fileinput.input(os.path.join(CS, fn)): + s = string.rstrip(string.lstrip(line)) + if s.startswith("public enum"): + ENUMS.append(s.split(" ")[2]) + + +def enum_replace(line): + for e in ENUMS: + if line.find("case") != -1: + line = line.replace(e + ".", "") + elif line.find("== (int)") != -1 or line.find("!= (int)") != -1: + line = re.sub("\(int\)" + e + "\.(?P[A-Z0-9_]*)", e + ".\g.toInt()", line) + elif line.find("==") != -1 or line.find("!=") != -1: + line = re.sub(e + "\.(?P[A-Z0-9_]*)", e + ".\g", line) + else: + # line = re.sub("\(\(" + e + "\)(?P.*\(.*)\)", "(" + e + ".values()[\g])", line) + line = re.sub("\(" + e + "\)(?P.*\(.*\))", e + ".fromInt(\g)", line) + return line + def replace_generals(a): a = re.sub(" NativeObject", " NativeObject()", a) - a = re.sub(".NativeObject;", ".NativeObject();", a) - a = re.sub("Context.nCtx", "Context().nCtx()", a) - a = re.sub("ctx.nCtx", "ctx.nCtx()", a) + a = re.sub("\.NativeObject", ".NativeObject()", a) + a = re.sub("(?P[\.\(])Id", "\gId()", a) + a = a.replace("(Context ==", "(Context() ==") + a = a.replace("(Context,", "(Context(),") + a = a.replace("Context.", "Context().") + a = a.replace(".nCtx", ".nCtx()") + a = a.replace("(nCtx", "(nCtx()") + a = re.sub("Context\(\).(?P[^_]*)_DRQ", "Context().\g_DRQ()", a) a = re.sub("ASTKind", "ASTKind()", a) + a = re.sub("IsExpr(?P[ ;])", "IsExpr()\g", a) + a = re.sub("IsNumeral(?P[ ;])", "IsNumeral()\g", a) + a = re.sub("IsInt(?P[ ;])", "IsInt()\g", a) + a = re.sub("IsReal(?P[ ;])", "IsReal()\g", a) + a = re.sub("IsVar(?P[ ;\)])", "IsVar()\g", a) + a = re.sub("FuncDecl.DeclKind", "FuncDecl().DeclKind()", a) + a = re.sub("FuncDecl.DomainSize", "FuncDecl().DomainSize()", a) + a = re.sub("(?P[=&]) Num(?P[a-zA-Z]*)", "\g Num\g()", a) + a = re.sub("= Denominator", "= Denominator()", a) + a = re.sub(", BoolSort(?P[\)\.])", ", BoolSort()\g", a) + a = re.sub(", RealSort(?P[\)\.])", ", RealSort()\g", a) + a = re.sub(", IntSort(?P[\)\.])", ", IntSort()\g", a) + a = a.replace("? 1 : 0", "? true : false") + if a.find("Native.") != -1 and a.find("!= 0") != -1: + a = a.replace("!= 0", "") + if a.find("Native.") != -1 and a.find("== 0") != -1: + a = a.replace("== 0", "^ true") return a def translate(filename): @@ -82,6 +139,8 @@ def translate(filename): in_getter_set = 0 had_ulong_res = 0 in_enum = 0 + missing_foreach_brace = 0 + foreach_opened_brace = 0 for line in fileinput.input(os.path.join(CS, filename)): s = string.rstrip(string.lstrip(line)) if in_javadoc: @@ -104,6 +163,13 @@ def translate(filename): tgt.write(t + " **/\n") in_javadoc = 0 + for i in range(0, len(EXCLUDE_METHODS)): + if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]): + tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n") + in_unsupported = 1 + break + + if in_unsupported: if s == "}": in_unsupported = 0 @@ -119,6 +185,7 @@ def translate(filename): tgt.write("import java.math.BigInteger;\n") tgt.write("import java.util.*;\n") tgt.write("import java.lang.Exception;\n") + tgt.write("import com.Microsoft.Z3.Enumerations.*;\n") elif in_header == 1: # tgt.write(" * " + line.replace(filename, tgtfn)) pass @@ -134,14 +201,15 @@ def translate(filename): tgt.write(t + "/* Overloaded operators are not translated. */\n") in_unsupported = 1 elif s.startswith("public enum"): - tgt.write(line) + tgt.write(line.replace("enum", "class")) in_enum = 1 elif in_enum == 1: if s == "}": tgt.write(line) in_enum = 0 else: - tgt.write(re.sub("(?P.*)\W*=\W*(?P[^\n,])", "\g (\g)", line)) + line = re.sub("(?P.*)\W*=\W*(?P[^\n,])", "public static final int \g = \g;", line) + tgt.write(line.replace(",","")) elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"): a = line.replace(":", "extends").replace("internal ", "") a = a.replace(", IComparable", "") @@ -164,7 +232,7 @@ def translate(filename): s = s.replace("internal virtual", "") s = s.replace("internal", "") tokens = s.split(" ") - print "TOKENS: " + str(len(tokens)) + # print "TOKENS: " + str(len(tokens)) if len(tokens) == 3: in_getter = tokens[2] in_getter_type = type_replace((tokens[0] + " " + tokens[1])) @@ -204,6 +272,7 @@ def translate(filename): rest = type_replace(rest) rest = rename_native(rest) rest = replace_generals(rest) + rest = enum_replace(rest) t = "" for i in range(0, lastindent): t += " " @@ -225,6 +294,7 @@ def translate(filename): subst_getters(rest, getters) rest = rename_native(rest) rest = replace_generals(rest) + rest = enum_replace(rest) if in_bracket_op: tgt.write(d + rest) else: @@ -240,6 +310,7 @@ def translate(filename): rest = type_replace(rest) rest = rename_native(rest) rest = replace_generals(rest) + rest = enum_replace(rest) if in_bracket_op: tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n") else: @@ -257,6 +328,7 @@ def translate(filename): rest = type_replace(rest) rest = rename_native(rest) rest = replace_generals(rest) + rest = enum_replace(rest) ac_acc = in_getter_type[:in_getter_type.find(' ')] ac_type = in_getter_type[in_getter_type.find(' ')+1:] if in_bracket_op: @@ -301,19 +373,43 @@ def translate(filename): else: for i in range(0, mbraces): line = line.replace("\n", "}\n") - if s.find("(") != -1: + if (s.find("public") != -1 or s.find("protected") != -1 or s.find("internal") != -1) and s.find("(") != -1: line = re.sub(" = [\w.]+(?P[,;\)])", "\g", line) a = type_replace(line) + a = enum_replace(a) a = re.sub("(?P[\(, ])params ", "\g", a) a = a.replace("base.", "super.") a = re.sub("Contract.\w+\([\s\S]*\);", "", a) a = rename_native(a) a = re.sub("~\w+\(\)", "protected void finalize()", a) + + if missing_foreach_brace == 1: + # a = a.replace("\n", " // checked " + str(foreach_opened_brace) + "\n") + if foreach_opened_brace == 0 and a.find("{") != -1: + foreach_opened_brace = 1 + elif foreach_opened_brace == 0 and a.find("}") == -1: + a = a.replace("\n", "}}\n") + foreach_opened_brace = 0 + missing_foreach_brace = 0 + elif foreach_opened_brace == 1 and a.find("}") != -1: + a = a.replace("\n", "}}\n") + foreach_opened_brace = 0 + missing_foreach_brace = 0 + +# if a.find("foreach") != -1: +# missing_foreach_brace = 1 +# a = re.sub("foreach\s*\((?P[\w <>,]+)\s+(?P\w+)\s+in\s+(?P\w+)\)", + # "{ Iterator fe_i = \g.iterator(); while (fe_i.hasNext()) { \g \g = (long)fe_i.next(); ", +# a) a = re.sub("foreach\s*\((?P[\w <>,]+)\s+(?P\w+)\s+in\s+(?P\w+)\)", - "for (Iterator \g = \g.iterator(); \g.hasNext(); )", a) + "for (\g \g: \g)", + a) + if a.find("long o: m_queue") != -1: + a = a.replace("long", "Long") a = a.replace("readonly ", "") a = a.replace("const ", "final ") a = a.replace("String ToString", "String toString") + a = a.replace(".ToString", ".toString") a = a.replace("internal ", "") a = a.replace("new static", "static") a = a.replace("new public", "public") @@ -333,6 +429,13 @@ def translate(filename): a = a.replace("out res", "res") a = a.replace("GC.ReRegisterForFinalize(m_ctx);", "") a = a.replace("GC.SuppressFinalize(this);", "") + a = a.replace(".Length", ".length") + a = a.replace("m_queue.Count", "m_queue.size()") + a = a.replace("m_queue.Add", "m_queue.add") + a = a.replace("m_queue.Clear", "m_queue.clear") + a = a.replace("for (long ", "for (int ") + a = a.replace("ReferenceEquals(Context, ctx)", "Context() == ctx") + a = a.replace("BigInteger.Parse", "new BigInteger") if had_ulong_res == 0 and a.find("ulong res = 0") != -1: a = a.replace("ulong res = 0;", "LongPtr res = new LongPtr();") elif had_ulong_res == 1: @@ -348,7 +451,6 @@ def translate(filename): a = re.sub("NativeObject = (?P.*);", "setNativeObject(\g);", a) a = replace_generals(a) tgt.write(a) - tgt.close() mk_java_bindings() From b456be1151e14d08501fb9b629f3d0382b6c9dbe Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 14:00:20 -0800 Subject: [PATCH 08/17] fix documentation string in python API Signed-off-by: Nikolaj Bjorner --- src/api/python/z3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/python/z3.py b/src/api/python/z3.py index a71db82c5..84724e51e 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -635,7 +635,7 @@ class FuncDeclRef(AstRef): args = _get_args(args) num = len(args) if __debug__: - _z3_assert(num == self.arity(), "Incorrect number of arguments") + _z3_assert(num == self.arity(), "Incorrect number of arguments to %s" % self) _args = (Ast * num)() saved = [] for i in range(num): @@ -1735,7 +1735,7 @@ class ArithSortRef(SortRef): """Real and Integer sorts.""" def is_real(self): - """Return `True` if `self` is the integer sort. + """Return `True` if `self` is of the sort Real. >>> x = Real('x') >>> x.is_real() @@ -1749,7 +1749,7 @@ class ArithSortRef(SortRef): return self.kind() == Z3_REAL_SORT def is_int(self): - """Return `True` if `self` is the real sort. + """Return `True` if `self` is of the sort Integer. >>> x = Int('x') >>> x.is_int() From 589665f00e20aedcad29065e2cc738167dd1fa3d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 14:01:06 -0800 Subject: [PATCH 09/17] set low-level pretty printer by default from fixedpoint context Signed-off-by: Nikolaj Bjorner --- src/ast/ast_smt_pp.cpp | 23 ++++++++++++++++++++++- src/ast/ast_smt_pp.h | 9 +++++---- src/muz_qe/dl_context.cpp | 23 +++++++++++------------ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index 713727f05..f18e6a78e 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -949,6 +949,10 @@ public: mark.mark(s, true); } + void operator()(sort* s) { + ast_mark mark; + pp_sort_decl(mark, s); + } void operator()(func_decl* d) { if (m_is_smt2) { @@ -962,7 +966,6 @@ public: m_out << ") "; visit_sort(d->get_range()); m_out << ")"; - newline(); } else { m_out << "("; @@ -1021,6 +1024,22 @@ void ast_smt_pp::display_expr_smt2(std::ostream& strm, expr* n, unsigned indent, p(n); } +void ast_smt_pp::display_ast_smt2(std::ostream& strm, ast* a, unsigned indent, unsigned num_var_names, char const* const* var_names) { + ptr_vector ql; + smt_renaming rn; + smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, indent, num_var_names, var_names); + if (is_expr(a)) { + p(to_expr(a)); + } + else if (is_func_decl(a)) { + p(to_func_decl(a)); + } + else { + SASSERT(is_sort(a)); + p(to_sort(a)); + } +} + void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { ptr_vector ql; @@ -1071,6 +1090,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { if (!(*m_is_declared)(d)) { smt_printer p(strm, m_manager, ql, rn, m_logic, true, true, m_simplify_implies, 0); p(d); + strm << "\n"; } } @@ -1079,6 +1099,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { if (!(*m_is_declared)(d)) { smt_printer p(strm, m_manager, ql, rn, m_logic, true, true, m_simplify_implies, 0); p(d); + strm << "\n"; } } diff --git a/src/ast/ast_smt_pp.h b/src/ast/ast_smt_pp.h index 36d4ced2e..97527759a 100644 --- a/src/ast/ast_smt_pp.h +++ b/src/ast/ast_smt_pp.h @@ -79,22 +79,23 @@ public: void display_smt2(std::ostream& strm, expr* n); void display_expr(std::ostream& strm, expr* n); void display_expr_smt2(std::ostream& strm, expr* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); + void display_ast_smt2(std::ostream& strm, ast* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); }; struct mk_smt_pp { - expr * m_expr; + ast* m_ast; ast_manager& m_manager; unsigned m_indent; unsigned m_num_var_names; char const* const* m_var_names; - mk_smt_pp(expr* e, ast_manager & m, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0) : - m_expr(e), m_manager(m), m_indent(indent), m_num_var_names(num_var_names), m_var_names(var_names) {} + mk_smt_pp(ast* e, ast_manager & m, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0) : + m_ast(e), m_manager(m), m_indent(indent), m_num_var_names(num_var_names), m_var_names(var_names) {} }; inline std::ostream& operator<<(std::ostream& out, const mk_smt_pp & p) { ast_smt_pp pp(p.m_manager); - pp.display_expr_smt2(out, p.m_expr, p.m_indent, p.m_num_var_names, p.m_var_names); + pp.display_ast_smt2(out, p.m_ast, p.m_indent, p.m_num_var_names, p.m_var_names); return out; } diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 77b391ef7..f11c9852d 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -994,6 +994,7 @@ namespace datalog { p.insert(":profile-timeout-milliseconds", CPK_UINT, "instructions and rules that took less than the threshold will not be printed when printed the instruction/rule list"); p.insert(":print-with-fixedpoint-extensions", CPK_BOOL, "(default true) use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, when printing rules"); + p.insert(":print-low-level-smt2", CPK_BOOL, "(default true) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); PRIVATE_PARAMS( p.insert(":dbg-fpr-nonempty-relation-signature", CPK_BOOL, @@ -1650,6 +1651,9 @@ namespace datalog { expr_ref_vector rules(m); svector names; bool use_fixedpoint_extensions = m_params.get_bool(":print-with-fixedpoint-extensions", true); + bool print_low_level = m_params.get_bool(":print-low-level-smt2", true); + +#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); get_rules_as_formulas(rules, names); @@ -1684,18 +1688,18 @@ namespace datalog { obj_hashtable& sorts = visitor.sorts(); obj_hashtable::iterator sit = sorts.begin(), send = sorts.end(); for (; sit != send; ++sit) { - ast_smt2_pp(out, *sit, env, params); + PP(*sit); } for (; it != end; ++it) { func_decl* f = *it; - ast_smt2_pp(out, f, env, params); + PP(f); out << "\n"; } it = rels.begin(); end = rels.end(); for (; it != end; ++it) { func_decl* f = *it; out << "(declare-rel " << f->get_name() << " ("; - for (unsigned i = 0; i < f->get_arity(); ++i) { + for (unsigned i = 0; i < f->get_arity(); ++i) { ast_smt2_pp(out, f->get_domain(i), env, params); if (i + 1 < f->get_arity()) { out << " "; @@ -1714,7 +1718,7 @@ namespace datalog { for (unsigned i = 0; i < num_axioms; ++i) { out << "(assert "; - ast_smt2_pp(out, axioms[i], env, params); + PP(axioms[i]); out << ")\n"; } for (unsigned i = 0; i < rules.size(); ++i) { @@ -1724,12 +1728,7 @@ namespace datalog { if (symbol::null != nm) { out << "(! "; } - if (use_fixedpoint_extensions) { - ast_smt2_pp(out, r, env, params); - } - else { - out << mk_smt_pp(r, m); - } + PP(r); if (symbol::null != nm) { while (fresh_names.contains(nm)) { std::ostringstream s; @@ -1744,7 +1743,7 @@ namespace datalog { if (use_fixedpoint_extensions) { for (unsigned i = 0; i < num_queries; ++i) { out << "(query "; - ast_smt2_pp(out, queries[i], env, params); + PP(queries[i]); out << ")\n"; } } @@ -1754,7 +1753,7 @@ namespace datalog { out << "(assert "; expr_ref q(m); q = m.mk_not(queries[i]); - ast_smt2_pp(out, q, env, params); + PP(q); out << ")\n"; out << "(check-sat)\n"; if (num_queries > 1) out << "(pop)\n"; From 521d975c84c40195d55ebe2560320fd2a6761898 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 14:18:20 -0800 Subject: [PATCH 10/17] additional array handling routines Signed-off-by: Nikolaj Bjorner --- src/muz_qe/pdr_context.cpp | 11 +++-- src/muz_qe/pdr_util.cpp | 1 + src/smt/smt_implied_equalities.cpp | 42 ++--------------- src/smt/smt_value_sort.cpp | 74 ++++++++++++++++++++++++++++++ src/smt/smt_value_sort.h | 37 +++++++++++++++ 5 files changed, 121 insertions(+), 44 deletions(-) create mode 100644 src/smt/smt_value_sort.cpp create mode 100644 src/smt/smt_value_sort.h diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 909a42625..227b1aee7 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -43,6 +43,7 @@ Notes: #include "qe_lite.h" #include "ast_ll_pp.h" #include "proof_checker.h" +#include "smt_value_sort.h" namespace pdr { @@ -1827,14 +1828,14 @@ namespace pdr { if (!vars.empty()) { // also fresh names for auxiliary variables in body? expr_substitution sub(m); - expr_ref_vector refs(m); expr_ref tmp(m); proof_ref pr(m); pr = m.mk_asserted(m.mk_true()); - for (unsigned i = 0; i < vars.size(); ++i) { - VERIFY (M->eval(vars[i].get(), tmp, true)); - refs.push_back(tmp); - sub.insert(vars[i].get(), tmp, pr); + for (unsigned i = 0; i < vars.size(); ++i) { + if (smt::is_value_sort(m, vars[i].get())) { + VERIFY (M->eval(vars[i].get(), tmp, true)); + sub.insert(vars[i].get(), tmp, pr); + } } if (!rep) rep = mk_expr_simp_replacer(m); rep->set_substitution(&sub); diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 0840f1d73..6907d82a0 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -904,6 +904,7 @@ namespace pdr { return !has_x; } + void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml) { ast_manager& m = fml.get_manager(); expr_ref_vector conjs(m); diff --git a/src/smt/smt_implied_equalities.cpp b/src/smt/smt_implied_equalities.cpp index ef8d27e2f..91784f5f5 100644 --- a/src/smt/smt_implied_equalities.cpp +++ b/src/smt/smt_implied_equalities.cpp @@ -29,6 +29,7 @@ Revision History: #include "array_decl_plugin.h" #include "uint_set.h" #include "model_v2_pp.h" +#include "smt_value_sort.h" namespace smt { @@ -134,44 +135,7 @@ namespace smt { } } } - } - - bool is_simple_type(sort* s) { - arith_util arith(m); - datatype_util data(m); - - ptr_vector sorts; - ast_mark mark; - sorts.push_back(s); - - while (!sorts.empty()) { - s = sorts.back(); - sorts.pop_back(); - if (mark.is_marked(s)) { - continue; - } - mark.mark(s, true); - if (arith.is_int_real(s)) { - // simple - } - else if (m.is_bool(s)) { - // simple - } - else if (data.is_datatype(s)) { - ptr_vector const& cs = *data.get_datatype_constructors(s); - for (unsigned i = 0; i < cs.size(); ++i) { - func_decl* f = cs[i]; - for (unsigned j = 0; j < f->get_arity(); ++j) { - sorts.push_back(f->get_domain(j)); - } - } - } - else { - return false; - } - } - return true; - } + } /** \brief Extract implied equalities for a collection of terms in the current context. @@ -216,7 +180,7 @@ namespace smt { uint_set non_values; - if (!is_simple_type(srt)) { + if (!is_value_sort(m, srt)) { for (unsigned i = 0; i < terms.size(); ++i) { non_values.insert(i); } diff --git a/src/smt/smt_value_sort.cpp b/src/smt/smt_value_sort.cpp new file mode 100644 index 000000000..a840b77b7 --- /dev/null +++ b/src/smt/smt_value_sort.cpp @@ -0,0 +1,74 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + smt_value_sort.cpp + +Abstract: + + Determine if elements of a given sort can be values. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-25 + +Revision History: + + +--*/ + +#include "smt_value_sort.h" +#include "bv_decl_plugin.h" +#include "arith_decl_plugin.h" +#include "datatype_decl_plugin.h" + +namespace smt { + + + bool is_value_sort(ast_manager& m, sort* s) { + arith_util arith(m); + datatype_util data(m); + bv_util bv(m); + + ptr_vector sorts; + ast_mark mark; + sorts.push_back(s); + + while (!sorts.empty()) { + s = sorts.back(); + sorts.pop_back(); + if (mark.is_marked(s)) { + continue; + } + mark.mark(s, true); + if (arith.is_int_real(s)) { + // simple + } + else if (m.is_bool(s)) { + // simple + } + else if (bv.is_bv_sort(s)) { + // simple + } + else if (data.is_datatype(s)) { + ptr_vector const& cs = *data.get_datatype_constructors(s); + for (unsigned i = 0; i < cs.size(); ++i) { + func_decl* f = cs[i]; + for (unsigned j = 0; j < f->get_arity(); ++j) { + sorts.push_back(f->get_domain(j)); + } + } + } + else { + return false; + } + } + return true; + } + + bool is_value_sort(ast_manager& m, expr* e) { + return is_value_sort(m, m.get_sort(e)); + } + +} diff --git a/src/smt/smt_value_sort.h b/src/smt/smt_value_sort.h new file mode 100644 index 000000000..ae32be62a --- /dev/null +++ b/src/smt/smt_value_sort.h @@ -0,0 +1,37 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + smt_value_sort.h + +Abstract: + + Determine if elements of a given sort can be values. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-25 + +Revision History: + + +--*/ + + +#ifndef __SMT_VALUE_SORT_H__ +#define __SMT_VALUE_SORT_H__ + +#include "ast.h" + + +namespace smt { + + bool is_value_sort(ast_manager& m, sort* s); + + bool is_value_sort(ast_manager& m, expr* e); + +}; + + +#endif From 8c32f6b01558b1ce34c89d6e29be030f84c66f63 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 00:38:19 +0000 Subject: [PATCH 11/17] Managed API: Refactoring Signed-off-by: Christoph M. Wintersteiger --- src/api/dotnet/FuncDecl.cs | 2 +- src/api/dotnet/Goal.cs | 6 +++--- src/api/dotnet/Model.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/dotnet/FuncDecl.cs b/src/api/dotnet/FuncDecl.cs index 37929e88f..15b6a59db 100644 --- a/src/api/dotnet/FuncDecl.cs +++ b/src/api/dotnet/FuncDecl.cs @@ -110,7 +110,7 @@ namespace Microsoft.Z3 { Contract.Ensures(Contract.Result() != null); - var n = DomainSize; + uint n = DomainSize; Sort[] res = new Sort[n]; for (uint i = 0; i < n; i++) diff --git a/src/api/dotnet/Goal.cs b/src/api/dotnet/Goal.cs index 6a0b253bb..e648ac80c 100644 --- a/src/api/dotnet/Goal.cs +++ b/src/api/dotnet/Goal.cs @@ -184,10 +184,10 @@ namespace Microsoft.Z3 { Tactic t = Context.MkTactic("simplify"); ApplyResult res = t.Apply(this, p); - + if (res.NumSubgoals == 0) - return Context.MkGoal(); - else + throw new Z3Exception("No subgoals"); + else return res.Subgoals[0]; } diff --git a/src/api/dotnet/Model.cs b/src/api/dotnet/Model.cs index 5529677dd..5c0bc24f8 100644 --- a/src/api/dotnet/Model.cs +++ b/src/api/dotnet/Model.cs @@ -165,8 +165,8 @@ namespace Microsoft.Z3 { Contract.Ensures(Contract.Result() != null); - var nFuncs = NumFuncs; - var nConsts = NumConsts; + uint nFuncs = NumFuncs; + uint nConsts = NumConsts; uint n = nFuncs + nConsts; FuncDecl[] res = new FuncDecl[n]; for (uint i = 0; i < nConsts; i++) From 1e8b45e653f1d424366be992602a078c3520d12f Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 00:39:23 +0000 Subject: [PATCH 12/17] Java API: Build system and Refactoring. Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 33 +++--- scripts/update_api.py | 2 +- .../{com/Microsoft/Z3/Native.c => Native.cpp} | 0 src/api/java/com/Microsoft/Z3/AST.java | 10 +- .../java/com/Microsoft/Z3/AlgebraicNum.java | 8 +- src/api/java/com/Microsoft/Z3/ArithExpr.java | 2 +- src/api/java/com/Microsoft/Z3/BitVecExpr.java | 2 +- .../java/com/Microsoft/Z3/Constructor.java | 10 +- src/api/java/com/Microsoft/Z3/Context.java | 104 +++--------------- .../java/com/Microsoft/Z3/DatatypeSort.java | 2 +- src/api/java/com/Microsoft/Z3/EnumSort.java | 6 +- .../Z3/Enumerations/Z3_ast_kind.java | 2 +- .../Z3/Enumerations/Z3_ast_print_mode.java | 2 +- .../Z3/Enumerations/Z3_decl_kind.java | 2 +- .../Z3/Enumerations/Z3_error_code.java | 2 +- .../Z3/Enumerations/Z3_goal_prec.java | 2 +- .../Microsoft/Z3/Enumerations/Z3_lbool.java | 2 +- .../Z3/Enumerations/Z3_param_kind.java | 2 +- .../Z3/Enumerations/Z3_parameter_kind.java | 2 +- .../Z3/Enumerations/Z3_sort_kind.java | 2 +- .../Z3/Enumerations/Z3_symbol_kind.java | 2 +- src/api/java/com/Microsoft/Z3/Expr.java | 24 ++-- src/api/java/com/Microsoft/Z3/Fixedpoint.java | 12 +- src/api/java/com/Microsoft/Z3/FuncDecl.java | 16 +-- src/api/java/com/Microsoft/Z3/FuncInterp.java | 14 +-- src/api/java/com/Microsoft/Z3/Goal.java | 24 ++-- .../java/com/Microsoft/Z3/IDisposable.java | 2 +- src/api/java/com/Microsoft/Z3/IntSymbol.java | 2 +- src/api/java/com/Microsoft/Z3/ListSort.java | 4 +- src/api/java/com/Microsoft/Z3/Model.java | 14 +-- src/api/java/com/Microsoft/Z3/Native.java | 2 +- src/api/java/com/Microsoft/Z3/Params.java | 12 +- src/api/java/com/Microsoft/Z3/Quantifier.java | 48 ++++---- src/api/java/com/Microsoft/Z3/RatNum.java | 2 +- src/api/java/com/Microsoft/Z3/RealExpr.java | 8 +- .../java/com/Microsoft/Z3/RelationSort.java | 2 +- src/api/java/com/Microsoft/Z3/Solver.java | 10 +- src/api/java/com/Microsoft/Z3/Statistics.java | 28 ++--- src/api/java/com/Microsoft/Z3/Status.java | 28 +++-- .../java/com/Microsoft/Z3/StringSymbol.java | 2 +- src/api/java/com/Microsoft/Z3/Symbol.java | 12 +- src/api/java/com/Microsoft/Z3/Tactic.java | 2 +- src/api/java/com/Microsoft/Z3/TupleSort.java | 6 +- src/api/java/com/Microsoft/Z3/Version.java | 2 +- src/api/java/com/Microsoft/Z3/Z3Object.java | 16 +-- src/api/java/mk_java.py | 10 +- 46 files changed, 218 insertions(+), 283 deletions(-) rename src/api/java/{com/Microsoft/Z3/Native.c => Native.cpp} (100%) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index ae10d6740..2ff414f78 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -493,6 +493,9 @@ def get_c_files(path): def get_cs_files(path): return filter(lambda f: f.endswith('.cs'), os.listdir(path)) +def get_java_files(path): + return filter(lambda f: f.endswith('.java'), os.listdir(path)) + def find_all_deps(name, deps): new_deps = [] for dep in deps: @@ -932,19 +935,21 @@ class JavaDLLComponent(Component): def mk_makefile(self, out): if is_java_enabled(): dllfile = '%s$(SO_EXT)' % self.dll_name - out.write('%s: %s/Z3Native.java %s$(SO_EXT)\n' % (dllfile, self.to_src_dir, get_component('api_dll').dll_name)) - if IS_WINDOWS: - out.write('\tcd %s && %s Z3Native.java\n' % (unix_path2dos(self.to_src_dir), JAVAC)) - out.write('\tmove %s\\*.class .\n' % unix_path2dos(self.to_src_dir)) - out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I"%s/include/win32" -I%s %s/Z3Native.c\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir)) - out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) Z3Native$(OBJ_EXT) libz3.lib\n' % dllfile) - else: - out.write('\tcd %s; %s Z3Native.java\n' % (self.to_src_dir, JAVAC)) - out.write('\tmv %s/*.class .\n' % self.to_src_dir) - out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Z3Native$(OBJ_EXT) -I"%s/include" -I%s %s/Z3Native.c\n' % (JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir)) - out.write('\t$(SLINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS) -L. Z3Native$(OBJ_EXT) -lz3\n' % dllfile) - out.write('%s: %s\n\n' % (self.name, dllfile)) - # TODO: Compile and package all the .class files. + subdir = self.package_name.replace(".","/") + out.write('libz3java$(SO_EXT): libz3$(SO_EXT) ../src/api/java/Native.cpp\n') + out.write('\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Native$(OBJ_EXT) -I"%s/include" -I"%s/include/win32" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir)) + out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3.lib\n') + out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name) + # for java_file in get_java_files(self.src_dir): + # out.write('%s ' % java_file) + # for java_file in get_java_files((self.src_dir + "/%s/Enumerations") % subdir): + # out.write('%s ' % java_file) + out.write('\n') + 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('\tjar cf %s.jar api/java/\n' % self.package_name) + out.write('java: %s.jar\n\n' % self.package_name) def main_component(self): return is_java_enabled() @@ -1847,7 +1852,7 @@ def mk_z3consts_java(api_files): if name not in DeprecatedEnums: efile = open('%s/%s.java' % (gendir, name), 'w') efile.write('/**\n * Automatically generated file\n **/\n\n') - efile.write('package %s;\n\n' % java.package_name); + efile.write('package %s.Enumerations;\n\n' % java.package_name); efile.write('/**\n') efile.write(' * %s\n' % name) diff --git a/scripts/update_api.py b/scripts/update_api.py index 1eef11705..10849aede 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -501,7 +501,7 @@ def mk_java(): except: pass # OK if it exists already. java_nativef = '%s/com/Microsoft/Z3/Native.java' % java_dir - java_wrapperf = '%s/com/Microsoft/Z3/Native.c' % java_dir + java_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') diff --git a/src/api/java/com/Microsoft/Z3/Native.c b/src/api/java/Native.cpp similarity index 100% rename from src/api/java/com/Microsoft/Z3/Native.c rename to src/api/java/Native.cpp diff --git a/src/api/java/com/Microsoft/Z3/AST.java b/src/api/java/com/Microsoft/Z3/AST.java index 069c07a4c..45e631694 100644 --- a/src/api/java/com/Microsoft/Z3/AST.java +++ b/src/api/java/com/Microsoft/Z3/AST.java @@ -87,7 +87,7 @@ import com.Microsoft.Z3.Enumerations.*; * A context * @return A copy of the AST which is associated with **/ - public AST Translate(Context ctx) + public AST Translate(Context ctx) throws Z3Exception { @@ -157,7 +157,7 @@ import com.Microsoft.Z3.Enumerations.*; } AST(Context ctx) { super(ctx); { }} - AST(Context ctx, long obj) { super(ctx, obj); { }} + AST(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }} class DecRefQueue extends IDecRefQueue { @@ -172,7 +172,7 @@ import com.Microsoft.Z3.Enumerations.*; } }; - void IncRef(long o) + void IncRef(long o) throws Z3Exception { // Console.WriteLine("AST IncRef()"); if (Context() == null) @@ -183,7 +183,7 @@ import com.Microsoft.Z3.Enumerations.*; super.IncRef(o); } - void DecRef(long o) + void DecRef(long o) throws Z3Exception { // Console.WriteLine("AST DecRef()"); if (Context() == null) @@ -194,7 +194,7 @@ import com.Microsoft.Z3.Enumerations.*; super.DecRef(o); } - static AST Create(Context ctx, long obj) + static AST Create(Context ctx, long obj) throws Z3Exception { diff --git a/src/api/java/com/Microsoft/Z3/AlgebraicNum.java b/src/api/java/com/Microsoft/Z3/AlgebraicNum.java index b9f5766ce..f98ccbce4 100644 --- a/src/api/java/com/Microsoft/Z3/AlgebraicNum.java +++ b/src/api/java/com/Microsoft/Z3/AlgebraicNum.java @@ -24,7 +24,7 @@ import com.Microsoft.Z3.Enumerations.*; * the precision of the result * @return A numeral Expr of sort Real **/ - public RatNum ToUpper(int precision) + public RatNum ToUpper(int precision) throws Z3Exception { @@ -38,7 +38,7 @@ import com.Microsoft.Z3.Enumerations.*; * * @return A numeral Expr of sort Real **/ - public RatNum ToLower(int precision) + public RatNum ToLower(int precision) throws Z3Exception { @@ -49,14 +49,14 @@ import com.Microsoft.Z3.Enumerations.*; * Returns a string representation in decimal notation. * The result has at most decimal places. **/ - public String ToDecimal(int precision) + public String ToDecimal(int precision) throws Z3Exception { return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(), precision); } - AlgebraicNum(Context ctx, long obj) + AlgebraicNum(Context ctx, long obj) throws Z3Exception { super(ctx, obj); } diff --git a/src/api/java/com/Microsoft/Z3/ArithExpr.java b/src/api/java/com/Microsoft/Z3/ArithExpr.java index 8df3bb0a5..fa87bf2f1 100644 --- a/src/api/java/com/Microsoft/Z3/ArithExpr.java +++ b/src/api/java/com/Microsoft/Z3/ArithExpr.java @@ -25,7 +25,7 @@ import com.Microsoft.Z3.Enumerations.*; { super(ctx); } - ArithExpr(Context ctx, long obj) + ArithExpr(Context ctx, long obj) throws Z3Exception { super(ctx, obj); } diff --git a/src/api/java/com/Microsoft/Z3/BitVecExpr.java b/src/api/java/com/Microsoft/Z3/BitVecExpr.java index bbb13a873..d7c43918e 100644 --- a/src/api/java/com/Microsoft/Z3/BitVecExpr.java +++ b/src/api/java/com/Microsoft/Z3/BitVecExpr.java @@ -23,7 +23,7 @@ import com.Microsoft.Z3.Enumerations.*; /** * The size of the sort of a bit-vector term. **/ - public int SortSize() { return ((BitVecSort)Sort).Size; } + public int SortSize() { return ((BitVecSort)Sort()).Size(); } /** Constructor for BitVecExpr **/ diff --git a/src/api/java/com/Microsoft/Z3/Constructor.java b/src/api/java/com/Microsoft/Z3/Constructor.java index d7d534873..bcf5654a4 100644 --- a/src/api/java/com/Microsoft/Z3/Constructor.java +++ b/src/api/java/com/Microsoft/Z3/Constructor.java @@ -92,11 +92,11 @@ import com.Microsoft.Z3.Enumerations.*; if (sortRefs == null) sortRefs = new int[n]; - NativeObject() = Native.mkConstructor(ctx.nCtx(), name.NativeObject(), recognizer.NativeObject(), - n, - Symbol.ArrayToNative(fieldNames), - Sort.ArrayToNative(sorts), - sortRefs); + setNativeObject(Native.mkConstructor(ctx.nCtx(), name.NativeObject(), recognizer.NativeObject(), + n, + Symbol.ArrayToNative(fieldNames), + Sort.ArrayToNative(sorts), + sortRefs)); } diff --git a/src/api/java/com/Microsoft/Z3/Context.java b/src/api/java/com/Microsoft/Z3/Context.java index 079bcaf43..8b83271a1 100644 --- a/src/api/java/com/Microsoft/Z3/Context.java +++ b/src/api/java/com/Microsoft/Z3/Context.java @@ -42,6 +42,12 @@ import com.Microsoft.Z3.Enumerations.*; InitContext(); } + private Context(long ctx) + { + super(); + this.m_ctx = ctx; + } + /** * Creates a new symbol using an integer. * @@ -591,7 +597,7 @@ import com.Microsoft.Z3.Enumerations.*; - return MkApp(f); + return MkApp(f, null); } /** @@ -2205,15 +2211,6 @@ import com.Microsoft.Z3.Enumerations.*; 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 - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * 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. @@ -2230,15 +2227,6 @@ import com.Microsoft.Z3.Enumerations.*; return Expr.Create(this, Native.mkInt64(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 - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create a real from a fraction. * numerator of rational. @@ -2281,13 +2269,6 @@ import com.Microsoft.Z3.Enumerations.*; 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 - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create a real numeral. * value of the numeral. @@ -2300,13 +2281,6 @@ import com.Microsoft.Z3.Enumerations.*; return new RatNum(this, Native.mkInt64(nCtx(), v, RealSort().NativeObject())); } - /** - * Create a real numeral. - * value of the numeral. - * @return A Term with value and sort Real - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create an integer numeral. * A string representing the Term value in decimal notation. @@ -2330,13 +2304,6 @@ import com.Microsoft.Z3.Enumerations.*; 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 - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create an integer numeral. * value of the numeral. @@ -2349,13 +2316,6 @@ import com.Microsoft.Z3.Enumerations.*; return new IntNum(this, Native.mkInt64(nCtx(), v, IntSort().NativeObject())); } - /** - * Create an integer numeral. - * value of the numeral. - * @return A Term with value and sort Integer - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create a bit-vector numeral. * A string representing the value in decimal notation. @@ -2380,13 +2340,6 @@ import com.Microsoft.Z3.Enumerations.*; return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } - /** - * Create a bit-vector numeral. - * value of the numeral. - * the size of the bit-vector - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create a bit-vector numeral. * value of the numeral. @@ -2399,13 +2352,6 @@ import com.Microsoft.Z3.Enumerations.*; return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } - /** - * Create a bit-vector numeral. - * value of the numeral. - * the size of the bit-vector - **/ - /* Not translated because it would translate to a function with clashing types. */ - /** * Create a universal Quantifier. @@ -2551,7 +2497,7 @@ import com.Microsoft.Z3.Enumerations.*; * * **/ - public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx(), (int)value); } + public void setPrintMode(Z3_ast_print_mode value) { Native.setAstPrintMode(nCtx(), value.toInt()); } /** * Convert a benchmark into an SMT-LIB formatted string. @@ -3356,12 +3302,12 @@ import com.Microsoft.Z3.Enumerations.*; **/ public String GetParamValue(String id) { - long res = 0; - int r = Native.getParamValue(nCtx(), id, res); - if (r == Z3_lbool.Z3_L_FALSE.toInt()) + String res = new String(); + boolean r = Native.getParamValue(nCtx(), id, res); + if (!r) return null; else - return Marshal.PtrToStringAnsi(res); + return res; } @@ -3376,7 +3322,7 @@ import com.Microsoft.Z3.Enumerations.*; void InitContext() { - PrintMode = Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT; + 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); @@ -3386,7 +3332,7 @@ import com.Microsoft.Z3.Enumerations.*; { - if (!ReferenceEquals(this, other.Context)) + if (this == other.Context()) throw new Z3Exception("Context mismatch"); } @@ -3402,25 +3348,6 @@ import com.Microsoft.Z3.Enumerations.*; CheckContextMatch(a); } } - } - - private void ObjectInvariant() - { - - - - - - - - - - - - - - - } private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue(); @@ -3473,7 +3400,8 @@ import com.Microsoft.Z3.Enumerations.*; m_ctx = 0; } else - GC.ReRegisterForFinalize(this); + /* re-queue the finalizer */ + new Context(m_ctx); } /** diff --git a/src/api/java/com/Microsoft/Z3/DatatypeSort.java b/src/api/java/com/Microsoft/Z3/DatatypeSort.java index 4d2dd8992..536bfa8bb 100644 --- a/src/api/java/com/Microsoft/Z3/DatatypeSort.java +++ b/src/api/java/com/Microsoft/Z3/DatatypeSort.java @@ -61,7 +61,7 @@ import com.Microsoft.Z3.Enumerations.*; for (int i = 0; i < n; i++) { FuncDecl fd = new FuncDecl(Context(), Native.getDatatypeSortConstructor(Context().nCtx(), NativeObject(), i)); - int ds = fd.DomainSize; + 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)); diff --git a/src/api/java/com/Microsoft/Z3/EnumSort.java b/src/api/java/com/Microsoft/Z3/EnumSort.java index cfb9d099a..ab0620003 100644 --- a/src/api/java/com/Microsoft/Z3/EnumSort.java +++ b/src/api/java/com/Microsoft/Z3/EnumSort.java @@ -68,8 +68,8 @@ import com.Microsoft.Z3.Enumerations.*; int n = enumNames.length; long[] n_constdecls = new long[n]; long[] n_testers = new long[n]; - NativeObject() = Native.mkEnumerationSort(ctx.nCtx(), name.NativeObject(), (int)n, - Symbol.ArrayToNative(enumNames), n_constdecls, n_testers); + 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]); @@ -78,6 +78,6 @@ import com.Microsoft.Z3.Enumerations.*; _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]); + _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/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java index 66841c073..931d70f62 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_ast_kind diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java index bfbbadd96..37da961d7 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_ast_print_mode diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java index c9ae9aa35..dd701c1e1 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_decl_kind diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java index 0c1c22870..2672c9325 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_error_code diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java index 2d96c6e76..f16fe51ec 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_goal_prec diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java index d31f5c238..55d5d7e17 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_lbool diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java index 81b8ef7bd..086622e95 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_param_kind diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java index c009104ba..021157183 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_parameter_kind diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java index 43f5b2f14..91559a58a 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_sort_kind diff --git a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java index 2f08236de..0866dc786 100644 --- a/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java +++ b/src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.java @@ -2,7 +2,7 @@ * Automatically generated file **/ -package com.Microsoft.Z3; +package com.Microsoft.Z3.Enumerations; /** * Z3_symbol_kind diff --git a/src/api/java/com/Microsoft/Z3/Expr.java b/src/api/java/com/Microsoft/Z3/Expr.java index 0851acf70..9cf25ed11 100644 --- a/src/api/java/com/Microsoft/Z3/Expr.java +++ b/src/api/java/com/Microsoft/Z3/Expr.java @@ -21,7 +21,7 @@ import com.Microsoft.Z3.Enumerations.*; * A set of parameters to configure the simplifier * **/ - public Expr Simplify(Params p) + public Expr Simplify(Params p) throws Z3Exception { @@ -54,7 +54,7 @@ import com.Microsoft.Z3.Enumerations.*; /** * The arguments of the expression. **/ - public Expr[] Args() + public Expr[] Args() throws Z3Exception { @@ -69,7 +69,7 @@ import com.Microsoft.Z3.Enumerations.*; * 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) + public void Update(Expr[] args) throws Z3Exception { @@ -88,7 +88,7 @@ import com.Microsoft.Z3.Enumerations.*; * sort of from[i] must be equal to sort of to[i]. * **/ - public Expr Substitute(Expr[] from, Expr[] to) + public Expr Substitute(Expr[] from, Expr[] to) throws Z3Exception { @@ -107,7 +107,7 @@ import com.Microsoft.Z3.Enumerations.*; * Substitute every occurrence of from in the expression with to. * **/ - public Expr Substitute(Expr from, Expr to) + public Expr Substitute(Expr from, Expr to) throws Z3Exception { @@ -122,7 +122,7 @@ import com.Microsoft.Z3.Enumerations.*; * 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) + public Expr SubstituteVars(Expr[] to) throws Z3Exception { @@ -137,7 +137,7 @@ import com.Microsoft.Z3.Enumerations.*; * A context * @return A copy of the term which is associated with **/ - public Expr Translate(Context ctx) + public Expr Translate(Context ctx) throws Z3Exception { @@ -1367,7 +1367,7 @@ import com.Microsoft.Z3.Enumerations.*; * index. * **/ - public int Index() + public int Index() throws Z3Exception { if (!IsVar()) throw new Z3Exception("Term is not a bound variable."); @@ -1384,9 +1384,9 @@ import com.Microsoft.Z3.Enumerations.*; /** * Constructor for Expr **/ - protected Expr(Context ctx, long obj) { super(ctx, obj); { }} + protected Expr(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }} - void CheckNativeObject(long 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() && @@ -1395,7 +1395,7 @@ import com.Microsoft.Z3.Enumerations.*; super.CheckNativeObject(obj); } - static Expr Create(Context ctx, FuncDecl f, Expr[] arguments) + static Expr Create(Context ctx, FuncDecl f, Expr[] arguments) throws Z3Exception { @@ -1407,7 +1407,7 @@ import com.Microsoft.Z3.Enumerations.*; return Create(ctx, obj); } - static Expr Create(Context ctx, long obj) + static Expr Create(Context ctx, long obj) throws Z3Exception { diff --git a/src/api/java/com/Microsoft/Z3/Fixedpoint.java b/src/api/java/com/Microsoft/Z3/Fixedpoint.java index 104fd354c..e2cc2a1e9 100644 --- a/src/api/java/com/Microsoft/Z3/Fixedpoint.java +++ b/src/api/java/com/Microsoft/Z3/Fixedpoint.java @@ -123,8 +123,8 @@ import com.Microsoft.Z3.Enumerations.*; Context().CheckContextMatch(relations); - Z3_lbool r = (Z3_lbool)Native.fixedpointQueryRelations(Context().nCtx(), NativeObject(), - AST.ArrayLength(relations), AST.ArrayToNative(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; @@ -248,10 +248,10 @@ import com.Microsoft.Z3.Enumerations.*; ASTVector v = new ASTVector(Context(), Native.fixedpointGetRules(Context().nCtx(), NativeObject())); - int n = v.Size; + int n = v.Size(); BoolExpr[] res = new BoolExpr[n]; for (int i = 0; i < n; i++) - res[i] = new BoolExpr(Context(), v[i].NativeObject()); + res[i] = new BoolExpr(Context(), v.get(i).NativeObject()); return res; } @@ -263,10 +263,10 @@ import com.Microsoft.Z3.Enumerations.*; ASTVector v = new ASTVector(Context(), Native.fixedpointGetAssertions(Context().nCtx(), NativeObject())); - int n = v.Size; + int n = v.Size(); BoolExpr[] res = new BoolExpr[n]; for (int i = 0; i < n; i++) - res[i] = new BoolExpr(Context(), v[i].NativeObject()); + res[i] = new BoolExpr(Context(), v.get(i).NativeObject()); return res; } diff --git a/src/api/java/com/Microsoft/Z3/FuncDecl.java b/src/api/java/com/Microsoft/Z3/FuncDecl.java index aa716c028..82cccc36f 100644 --- a/src/api/java/com/Microsoft/Z3/FuncDecl.java +++ b/src/api/java/com/Microsoft/Z3/FuncDecl.java @@ -77,7 +77,7 @@ import com.Microsoft.Z3.Enumerations.*; { - var n = DomainSize; + int n = DomainSize(); Sort[] res = new Sort[n]; for (int i = 0; i < n; i++) @@ -171,25 +171,25 @@ import com.Microsoft.Z3.Enumerations.*; /**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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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; } + 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. diff --git a/src/api/java/com/Microsoft/Z3/FuncInterp.java b/src/api/java/com/Microsoft/Z3/FuncInterp.java index 341b82ec5..17ff7d6bd 100644 --- a/src/api/java/com/Microsoft/Z3/FuncInterp.java +++ b/src/api/java/com/Microsoft/Z3/FuncInterp.java @@ -59,10 +59,10 @@ import com.Microsoft.Z3.Enumerations.*; { int n = NumArgs(); String res = "["; - Expr[] args = Args; + Expr[] args = Args(); for (int i = 0; i < n; i++) res += args[i] + ", "; - return res + Value + "]"; + return res + Value() + "]"; } Entry(Context ctx, long obj) { super(ctx, obj); { }} @@ -135,20 +135,20 @@ import com.Microsoft.Z3.Enumerations.*; { String res = ""; res += "["; - for (Entry e: Entries) + for (Entry e: Entries()) { - int n = e.NumArgs; + int n = e.NumArgs(); if (n > 1) res += "["; - Expr[] args = e.Args; + 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 += " -> " + e.Value() + ", "; } - res += "else -> " + Else; + res += "else -> " + Else(); res += "]"; return res; } diff --git a/src/api/java/com/Microsoft/Z3/Goal.java b/src/api/java/com/Microsoft/Z3/Goal.java index 9f522a768..9ca138140 100644 --- a/src/api/java/com/Microsoft/Z3/Goal.java +++ b/src/api/java/com/Microsoft/Z3/Goal.java @@ -31,21 +31,21 @@ import com.Microsoft.Z3.Enumerations.*; /** * Indicates whether the goal is precise. **/ - public boolean IsPrecise() { return Precision == Z3_goal_prec.Z3_GOAL_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; } + 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; } + 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; } + public boolean IsGarbage() { return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER; } /** * Adds the to the given goal. @@ -96,7 +96,7 @@ import com.Microsoft.Z3.Enumerations.*; { - int n = Size; + 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)); @@ -132,15 +132,15 @@ import com.Microsoft.Z3.Enumerations.*; * Simplifies the goal. * Essentially invokes the `simplify' tactic on the goal. **/ - public Goal Simplify(Params p) + public Goal Simplify(Params p) throws Z3Exception { Tactic t = Context().MkTactic("simplify"); ApplyResult res = t.Apply(this, p); - if (res.NumSubgoals == 0) - return Context().MkGoal(); + if (res.NumSubgoals() == 0) + throw new Z3Exception("No subgoals"); else - return res.Subgoals[0]; + return res.Subgoals()[0]; } /** @@ -152,11 +152,11 @@ import com.Microsoft.Z3.Enumerations.*; return Native.goalToString(Context().nCtx(), NativeObject()); } - Goal(Context ctx, long obj) { super(ctx, obj); { }} + 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)); - + { + super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false, (unsatCores) ? true : false, (proofs) ? true : false)); } class DecRefQueue extends IDecRefQueue diff --git a/src/api/java/com/Microsoft/Z3/IDisposable.java b/src/api/java/com/Microsoft/Z3/IDisposable.java index 03885d1e7..e0cbb84f0 100644 --- a/src/api/java/com/Microsoft/Z3/IDisposable.java +++ b/src/api/java/com/Microsoft/Z3/IDisposable.java @@ -21,5 +21,5 @@ package com.Microsoft.Z3; public class IDisposable { - public void Dispose() {} + public void Dispose() throws Z3Exception {} } diff --git a/src/api/java/com/Microsoft/Z3/IntSymbol.java b/src/api/java/com/Microsoft/Z3/IntSymbol.java index 1750d87e6..7b917c11d 100644 --- a/src/api/java/com/Microsoft/Z3/IntSymbol.java +++ b/src/api/java/com/Microsoft/Z3/IntSymbol.java @@ -39,7 +39,7 @@ import com.Microsoft.Z3.Enumerations.*; void CheckNativeObject(long obj) { - if ((Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_INT_SYMBOL) + 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 index 4efee3783..7e7b03f79 100644 --- a/src/api/java/com/Microsoft/Z3/ListSort.java +++ b/src/api/java/com/Microsoft/Z3/ListSort.java @@ -110,8 +110,8 @@ import com.Microsoft.Z3.Enumerations.*; ihead = 0, itail = 0; - NativeObject() = Native.mkListSort(ctx.nCtx(), name.NativeObject(), elemSort.NativeObject(), - inil, iisnil, icons, iiscons, ihead, itail); + 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); diff --git a/src/api/java/com/Microsoft/Z3/Model.java b/src/api/java/com/Microsoft/Z3/Model.java index c0c0e2852..f17dc1956 100644 --- a/src/api/java/com/Microsoft/Z3/Model.java +++ b/src/api/java/com/Microsoft/Z3/Model.java @@ -26,7 +26,7 @@ import com.Microsoft.Z3.Enumerations.*; Context().CheckContextMatch(a); - return ConstInterp(a.FuncDecl); + return ConstInterp(a.FuncDecl()); } /** @@ -39,7 +39,7 @@ import com.Microsoft.Z3.Enumerations.*; Context().CheckContextMatch(f); - if (f.Arity != 0 || + 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."); @@ -63,7 +63,7 @@ import com.Microsoft.Z3.Enumerations.*; Z3_sort_kind sk = Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(), Native.getRange(Context().nCtx(), f.NativeObject()))); - if (f.Arity == 0) + if (f.Arity() == 0) { long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(), f.NativeObject()); @@ -139,8 +139,8 @@ import com.Microsoft.Z3.Enumerations.*; { - var nFuncs = NumFuncs(); - var nConsts = NumConsts(); + int nFuncs = NumFuncs(); + int nConsts = NumConsts(); int n = nFuncs + nConsts; FuncDecl[] res = new FuncDecl[n]; for (int i = 0; i < nConsts; i++) @@ -236,10 +236,10 @@ import com.Microsoft.Z3.Enumerations.*; ASTVector nUniv = new ASTVector(Context(), Native.modelGetSortUniverse(Context().nCtx(), NativeObject(), s.NativeObject())); - int n = nUniv.Size; + int n = nUniv.Size(); Expr[] res = new Expr[n]; for (int i = 0; i < n; i++) - res[i] = Expr.Create(Context(), nUniv[i].NativeObject()); + res[i] = Expr.Create(Context(), nUniv.get(i).NativeObject()); return res; } diff --git a/src/api/java/com/Microsoft/Z3/Native.java b/src/api/java/com/Microsoft/Z3/Native.java index e42d8b7ba..8acf96cbf 100644 --- a/src/api/java/com/Microsoft/Z3/Native.java +++ b/src/api/java/com/Microsoft/Z3/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); diff --git a/src/api/java/com/Microsoft/Z3/Params.java b/src/api/java/com/Microsoft/Z3/Params.java index 1107a80ee..ab6401833 100644 --- a/src/api/java/com/Microsoft/Z3/Params.java +++ b/src/api/java/com/Microsoft/Z3/Params.java @@ -26,16 +26,6 @@ import com.Microsoft.Z3.Enumerations.*; Native.paramsSetBool(Context().nCtx(), NativeObject(), name.NativeObject(), (value) ? true : false); } - /** - * Adds a parameter setting. - **/ - public void Add(Symbol name, int value) - { - - - Native.paramsSetInt(Context().nCtx(), NativeObject(), name.NativeObject(), value); - } - /** * Adds a parameter setting. **/ @@ -70,7 +60,7 @@ import com.Microsoft.Z3.Enumerations.*; **/ public void Add(String name, int value) { - Native.paramsSetInt(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); + Native.paramsSetUint(Context().nCtx(), NativeObject(), Context().MkSymbol(name).NativeObject(), value); } /** diff --git a/src/api/java/com/Microsoft/Z3/Quantifier.java b/src/api/java/com/Microsoft/Z3/Quantifier.java index ad05c544b..b841623c2 100644 --- a/src/api/java/com/Microsoft/Z3/Quantifier.java +++ b/src/api/java/com/Microsoft/Z3/Quantifier.java @@ -24,7 +24,7 @@ import com.Microsoft.Z3.Enumerations.*; /** * Indicates whether the quantifier is existential. **/ - public boolean IsExistential() { return !IsUniversal; } + public boolean IsExistential() { return !IsUniversal(); } /** * The weight of the quantifier. @@ -137,21 +137,21 @@ import com.Microsoft.Z3.Enumerations.*; if (noPatterns == null && quantifierID == null && skolemID == null) { - NativeObject() = 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()); + 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 { - NativeObject() = 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()); + 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())); } } @@ -171,19 +171,19 @@ import com.Microsoft.Z3.Enumerations.*; if (noPatterns == null && quantifierID == null && skolemID == null) { - NativeObject() = Native.mkQuantifierConst(ctx.nCtx(), (isForall) ? true : false, weight, - AST.ArrayLength(bound), AST.ArrayToNative(bound), - AST.ArrayLength(patterns), AST.ArrayToNative(patterns), - body.NativeObject()); + setNativeObject(Native.mkQuantifierConst(ctx.nCtx(), (isForall) ? true : false, weight, + AST.ArrayLength(bound), AST.ArrayToNative(bound), + AST.ArrayLength(patterns), AST.ArrayToNative(patterns), + body.NativeObject())); } else { - NativeObject() = 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()); + 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())); } } @@ -192,7 +192,7 @@ import com.Microsoft.Z3.Enumerations.*; void CheckNativeObject(long obj) { - if ((Z3_ast_kind)Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST) + 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 index ad0982a95..ff0b3d18a 100644 --- a/src/api/java/com/Microsoft/Z3/RatNum.java +++ b/src/api/java/com/Microsoft/Z3/RatNum.java @@ -72,7 +72,7 @@ import com.Microsoft.Z3.Enumerations.*; return Native.getNumeralString(Context().nCtx(), NativeObject()); } - RatNum(Context ctx, long obj) + 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 index 2f06e4643..907148c2a 100644 --- a/src/api/java/com/Microsoft/Z3/RealExpr.java +++ b/src/api/java/com/Microsoft/Z3/RealExpr.java @@ -19,13 +19,15 @@ import com.Microsoft.Z3.Enumerations.*; **/ public class RealExpr extends ArithExpr { - /** Constructor for RealExpr - **/ + /** + * Constructor for RealExpr + **/ protected RealExpr(Context ctx) { super(ctx); } - RealExpr(Context ctx, long obj) + + RealExpr(Context ctx, long obj) throws Z3Exception { super(ctx, obj); } diff --git a/src/api/java/com/Microsoft/Z3/RelationSort.java b/src/api/java/com/Microsoft/Z3/RelationSort.java index 85f083b57..564c66eaf 100644 --- a/src/api/java/com/Microsoft/Z3/RelationSort.java +++ b/src/api/java/com/Microsoft/Z3/RelationSort.java @@ -31,7 +31,7 @@ import com.Microsoft.Z3.Enumerations.*; if (m_columnSorts != null) return m_columnSorts; - int n = Arity; + 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)); diff --git a/src/api/java/com/Microsoft/Z3/Solver.java b/src/api/java/com/Microsoft/Z3/Solver.java index 5fda96bb1..1f6f099b3 100644 --- a/src/api/java/com/Microsoft/Z3/Solver.java +++ b/src/api/java/com/Microsoft/Z3/Solver.java @@ -99,7 +99,7 @@ import com.Microsoft.Z3.Enumerations.*; public int NumAssertions() { ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(Context().nCtx(), NativeObject())); - return ass.Size; + return ass.Size(); } /** @@ -110,10 +110,10 @@ import com.Microsoft.Z3.Enumerations.*; ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(Context().nCtx(), NativeObject())); - int n = ass.Size; + int n = ass.Size(); BoolExpr[] res = new BoolExpr[n]; for (int i = 0; i < n; i++) - res[i] = new BoolExpr(Context(), ass[i].NativeObject()); + res[i] = new BoolExpr(Context(), ass.get(i).NativeObject()); return res; } @@ -185,10 +185,10 @@ import com.Microsoft.Z3.Enumerations.*; ASTVector core = new ASTVector(Context(), Native.solverGetUnsatCore(Context().nCtx(), NativeObject())); - int n = core.Size; + int n = core.Size(); Expr[] res = new Expr[n]; for (int i = 0; i < n; i++) - res[i] = Expr.Create(Context(), core[i].NativeObject()); + res[i] = Expr.Create(Context(), core.get(i).NativeObject()); return res; } diff --git a/src/api/java/com/Microsoft/Z3/Statistics.java b/src/api/java/com/Microsoft/Z3/Statistics.java index ec64ee0b3..93cd6e706 100644 --- a/src/api/java/com/Microsoft/Z3/Statistics.java +++ b/src/api/java/com/Microsoft/Z3/Statistics.java @@ -25,6 +25,8 @@ import com.Microsoft.Z3.Enumerations.*; /** * The key of the entry. **/ + public String Key; + /** * The uint-value of the entry. **/ @@ -49,10 +51,10 @@ import com.Microsoft.Z3.Enumerations.*; { - if (IsUInt) - return m_int.toString(); - else if (IsDouble) - return m_double.toString(); + if (IsUInt()) + return Integer.toString(m_int); + else if (IsDouble()) + return Double.toString(m_double); else throw new Z3Exception("Unknown statistical entry type"); } @@ -62,7 +64,7 @@ import com.Microsoft.Z3.Enumerations.*; **/ public String toString() { - return Key + ": " + Value; + return Key + ": " + Value(); } private boolean m_is_int = false; @@ -71,13 +73,13 @@ import com.Microsoft.Z3.Enumerations.*; private double m_double = 0.0; Entry(String k, int v) { - Key = k; + Key = k; m_is_int = true; m_int = v; } Entry(String k, double v) { - Key = k; + Key = k; m_is_double = true; m_double = v; } @@ -105,14 +107,14 @@ import com.Microsoft.Z3.Enumerations.*; - int n = Size; + 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.statsIsInt(Context().nCtx(), NativeObject(), i) ) - e = new Entry(k, Native.statsGetIntValue(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 @@ -129,7 +131,7 @@ import com.Microsoft.Z3.Enumerations.*; { - int n = Size; + int n = Size(); String[] res = new String[n]; for (int i = 0; i < n; i++) res[i] = Native.statsGetKey(Context().nCtx(), NativeObject(), i); @@ -142,8 +144,8 @@ import com.Microsoft.Z3.Enumerations.*; **/ public Entry get(String key) { - int n = Size; - Entry[] es = Entries; + int n = Size(); + Entry[] es = Entries(); for (int i = 0; i < n; i++) if (es[i].Key == key) return es[i]; diff --git a/src/api/java/com/Microsoft/Z3/Status.java b/src/api/java/com/Microsoft/Z3/Status.java index 64bd9f767..fdccb7376 100644 --- a/src/api/java/com/Microsoft/Z3/Status.java +++ b/src/api/java/com/Microsoft/Z3/Status.java @@ -14,21 +14,29 @@ import com.Microsoft.Z3.Enumerations.*; /** * Status values. **/ - public class Status + public enum Status { - /// /// Used to signify an unsatisfiable status. - /// -public static final int UNSATISFIABLE = 1; + UNSATISFIABLE (1), - /// /// Used to signify an unknown status. - /// -public static final int UNKNOWN = 0; + UNKNOWN (0), - /// /// Used to signify a satisfiable status. - /// -public static final int SATISFIABLE = 1; + 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 index 1ff869002..5788c0944 100644 --- a/src/api/java/com/Microsoft/Z3/StringSymbol.java +++ b/src/api/java/com/Microsoft/Z3/StringSymbol.java @@ -43,7 +43,7 @@ import com.Microsoft.Z3.Enumerations.*; void CheckNativeObject(long obj) { - if ((Z3_symbol_kind)Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL) + 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 index b7653414d..0cd0632de 100644 --- a/src/api/java/com/Microsoft/Z3/Symbol.java +++ b/src/api/java/com/Microsoft/Z3/Symbol.java @@ -27,7 +27,7 @@ import com.Microsoft.Z3.Enumerations.*; **/ public boolean IsIntSymbol() { - return Kind == Z3_symbol_kind.Z3_INT_SYMBOL; + return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL; } /** @@ -35,7 +35,7 @@ import com.Microsoft.Z3.Enumerations.*; **/ public boolean IsStringSymbol() { - return Kind == Z3_symbol_kind.Z3_STRING_SYMBOL; + return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL; } /** @@ -44,9 +44,9 @@ import com.Microsoft.Z3.Enumerations.*; public String toString() { if (IsIntSymbol()) - return ((IntSymbol)this).Int.toString(); + return Integer.toString(((IntSymbol)this).Int()); else if (IsStringSymbol()) - return ((StringSymbol)this).String; + return ((StringSymbol)this).String(); else throw new Z3Exception("Unknown symbol kind encountered"); } @@ -54,8 +54,8 @@ import com.Microsoft.Z3.Enumerations.*; /** * Symbol constructor **/ - protected Symbol(Context ctx, long obj) { super(ctx, obj); - + protected Symbol(Context ctx, long obj) { + super(ctx, obj); } static Symbol Create(Context ctx, long obj) diff --git a/src/api/java/com/Microsoft/Z3/Tactic.java b/src/api/java/com/Microsoft/Z3/Tactic.java index fd560847a..3ef1ab645 100644 --- a/src/api/java/com/Microsoft/Z3/Tactic.java +++ b/src/api/java/com/Microsoft/Z3/Tactic.java @@ -62,7 +62,7 @@ import com.Microsoft.Z3.Enumerations.*; - return Apply(g); + return Apply(g, null); } /** diff --git a/src/api/java/com/Microsoft/Z3/TupleSort.java b/src/api/java/com/Microsoft/Z3/TupleSort.java index 0ac03bb88..76a92f6c9 100644 --- a/src/api/java/com/Microsoft/Z3/TupleSort.java +++ b/src/api/java/com/Microsoft/Z3/TupleSort.java @@ -51,8 +51,8 @@ import com.Microsoft.Z3.Enumerations.*; long t = 0; - NativeObject() = Native.mkTupleSort(ctx.nCtx(), name.NativeObject(), numFields, - Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts), - t, new long[numFields]); + 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/Version.java b/src/api/java/com/Microsoft/Z3/Version.java index c3fc4268d..e9f883aaa 100644 --- a/src/api/java/com/Microsoft/Z3/Version.java +++ b/src/api/java/com/Microsoft/Z3/Version.java @@ -68,6 +68,6 @@ import com.Microsoft.Z3.Enumerations.*; int major = 0, minor = 0, build = 0, revision = 0; Native.getVersion(major, minor, build, revision); - return major.toString() + "." + minor.toString() + "." + build.toString() + "." + revision.toString(); + return Integer.toString(major) + "." + Integer.toString(minor) + "." + Integer.toString(build) + "." + Integer.toString(revision); } } diff --git a/src/api/java/com/Microsoft/Z3/Z3Object.java b/src/api/java/com/Microsoft/Z3/Z3Object.java index d4bdf08f7..1bbdbab8b 100644 --- a/src/api/java/com/Microsoft/Z3/Z3Object.java +++ b/src/api/java/com/Microsoft/Z3/Z3Object.java @@ -20,7 +20,7 @@ import com.Microsoft.Z3.Enumerations.*; /** * Finalizer. **/ - protected void finalize() + protected void finalize() throws Z3Exception { Dispose(); } @@ -28,7 +28,7 @@ import com.Microsoft.Z3.Enumerations.*; /** * Disposes of the underlying native Z3 object. **/ - public void Dispose() + public void Dispose() throws Z3Exception { if (m_n_obj != 0) { @@ -65,7 +65,7 @@ import com.Microsoft.Z3.Enumerations.*; m_ctx = ctx; } - Z3Object(Context ctx, long obj) + Z3Object(Context ctx, long obj) throws Z3Exception { @@ -75,13 +75,13 @@ import com.Microsoft.Z3.Enumerations.*; m_n_obj = obj; } - void IncRef(long o) { } - void DecRef(long o) { } + void IncRef(long o) throws Z3Exception { } + void DecRef(long o) throws Z3Exception { } - void CheckNativeObject(long obj) { } + void CheckNativeObject(long obj) throws Z3Exception { } - long NativeObject() { return m_n_obj; } - void setNativeObject(long value) + 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); } diff --git a/src/api/java/mk_java.py b/src/api/java/mk_java.py index fe7f50a25..1c59fc957 100644 --- a/src/api/java/mk_java.py +++ b/src/api/java/mk_java.py @@ -163,11 +163,11 @@ def translate(filename): tgt.write(t + " **/\n") in_javadoc = 0 - for i in range(0, len(EXCLUDE_METHODS)): - if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]): - tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n") - in_unsupported = 1 - break + # for i in range(0, len(EXCLUDE_METHODS)): + # if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]): + # tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n") + # in_unsupported = 1 + # break if in_unsupported: From 8612c89c54c3c6ab030fb54f43e47db3b6f0a926 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 17:55:40 -0800 Subject: [PATCH 13/17] working on quantifiers Signed-off-by: Nikolaj Bjorner --- src/ast/ast_smt_pp.cpp | 9 ++- src/muz_qe/dl_mk_extract_quantifiers.cpp | 73 +++++++++++++++++++----- src/muz_qe/dl_mk_extract_quantifiers.h | 4 ++ src/muz_qe/pdr_context.cpp | 20 +++---- src/muz_qe/pdr_quantifiers.cpp | 44 ++++++++++---- src/muz_qe/pdr_util.cpp | 31 +++++++++- src/muz_qe/pdr_util.h | 4 +- 7 files changed, 146 insertions(+), 39 deletions(-) diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index f18e6a78e..78a1caf68 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -67,8 +67,13 @@ symbol smt_renaming::fix_symbol(symbol s, int k) { buffer << s << k; return symbol(buffer.str().c_str()); } - - buffer << mk_smt2_quoted_symbol(s); + + if (is_smt2_quoted_symbol(s)) { + buffer << mk_smt2_quoted_symbol(s); + } + else { + buffer << s; + } if (k > 0) { buffer << k; } diff --git a/src/muz_qe/dl_mk_extract_quantifiers.cpp b/src/muz_qe/dl_mk_extract_quantifiers.cpp index f6755bb4f..5999b751c 100644 --- a/src/muz_qe/dl_mk_extract_quantifiers.cpp +++ b/src/muz_qe/dl_mk_extract_quantifiers.cpp @@ -38,12 +38,43 @@ namespace datalog { m_refs.reset(); } + app_ref mk_extract_quantifiers::ensure_app(expr* e) { + if (is_app(e)) { + return app_ref(to_app(e), m); + } + else { + return app_ref(m.mk_eq(e, m.mk_true()), m); + } + } + + void mk_extract_quantifiers::ensure_predicate(expr* e, unsigned& max_var, app_ref_vector& tail) { + SASSERT(is_app(e)); + SASSERT(to_app(e)->get_decl()->get_family_id() == null_family_id); + app* a = to_app(e); + expr_ref_vector args(m); + for (unsigned i = 0; i < a->get_num_args(); ++i) { + expr* arg = a->get_arg(i); + if (is_var(arg) || m.is_value(arg)) { + args.push_back(arg); + } + else { + expr_ref new_var(m); + new_var = m.mk_var(++max_var, m.get_sort(arg)); + args.push_back(new_var); + tail.push_back(m.mk_eq(new_var, arg)); + } + } + tail.push_back(m.mk_app(a->get_decl(), args.size(), args.c_ptr())); + } + void mk_extract_quantifiers::extract(rule& r, rule_set& new_rules) { - expr_ref_vector tail(m); + app_ref_vector tail(m); quantifier_ref_vector quantifiers(m); unsigned utsz = r.get_uninterpreted_tail_size(); unsigned tsz = r.get_tail_size(); + var_counter vc(true); + unsigned max_var = vc.get_max_var(r); for (unsigned i = 0; i < utsz; ++i) { tail.push_back(r.get_tail(i)); if (r.is_neg_tail(i)) { @@ -51,21 +82,37 @@ namespace datalog { return; } } + var_subst vs(m, true); for (unsigned i = utsz; i < tsz; ++i) { app* t = r.get_tail(i); expr_ref_vector conjs(m); datalog::flatten_and(t, conjs); - quantifier_ref qe(m); + expr_ref qe(m); quantifier* q = 0; for (unsigned j = 0; j < conjs.size(); ++j) { expr* e = conjs[j].get(); if (rule_manager::is_forall(m, e, q)) { quantifiers.push_back(q); - qe = m.mk_exists(q->get_num_decls(), q->get_decl_sorts(), q->get_decl_names(), q->get_expr()); - tail.push_back(qe); + expr_ref_vector sub(m); + ptr_vector fv; + unsigned num_decls = q->get_num_decls(); + get_free_vars(q, fv); + for (unsigned k = 0; k < fv.size(); ++k) { + unsigned idx = fv.size()-k-1; + if (!fv[idx]) { + fv[idx] = m.mk_bool_sort(); + } + sub.push_back(m.mk_var(idx, fv[idx])); + } + for (unsigned k = 0; k < num_decls; ++k) { + sub.push_back(m.mk_var(num_decls+max_var-k, q->get_decl_sort(k))); + } + max_var += num_decls; + vs(q->get_expr(), sub.size(), sub.c_ptr(), qe); + ensure_predicate(qe, max_var, tail); } else { - tail.push_back(e); + tail.push_back(ensure_app(e)); } } } @@ -73,16 +120,16 @@ namespace datalog { new_rules.add_rule(&r); } else { - expr_ref fml(m); - rule_ref_vector rules(rm); - fml = m.mk_implies(m.mk_and(tail.size(), tail.c_ptr()), r.get_head()); - rm.mk_rule(fml, rules, r.name()); + rule_ref new_rule(rm); + std::cout << mk_pp(r.get_head(), m) << " :- \n"; + for (unsigned i = 0; i < tail.size(); ++i) { + std::cout << " " << mk_pp(tail[i].get(), m) << "\n"; + } + new_rule = rm.mk(r.get_head(), tail.size(), tail.c_ptr(), 0, r.name(), false); quantifier_ref_vector* qs = alloc(quantifier_ref_vector, quantifiers); m_refs.push_back(qs); - for (unsigned i = 0; i < rules.size(); ++i) { - m_quantifiers.insert(rules[i].get(), qs); - new_rules.add_rule(rules[i].get()); - } + new_rules.add_rule(new_rule); + m_quantifiers.insert(new_rule, qs); } } diff --git a/src/muz_qe/dl_mk_extract_quantifiers.h b/src/muz_qe/dl_mk_extract_quantifiers.h index 512e386cd..4fc78c62c 100644 --- a/src/muz_qe/dl_mk_extract_quantifiers.h +++ b/src/muz_qe/dl_mk_extract_quantifiers.h @@ -37,6 +37,10 @@ namespace datalog { void extract(rule& r, rule_set& new_rules); + app_ref ensure_app(expr* e); + + void ensure_predicate(expr* e, unsigned& max_var, app_ref_vector& tail); + public: /** \brief Create rule transformer that extracts universal quantifiers (over recursive predicates). diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 227b1aee7..d5b495305 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -731,17 +731,15 @@ namespace pdr { TRACE("pdr", model_smt2_pp(tout, m, get_model(), 0);); func_decl* f = p.head(); unsigned arity = f->get_arity(); + model_ref model = get_model_ptr(); expr_ref_vector args(m); - func_decl_ref v(m); + expr_ref v(m); + model_evaluator mev(m); + for (unsigned i = 0; i < arity; ++i) { - v = pm.o2n(p.sig(i),0); - expr* e = get_model().get_const_interp(v); - if (e) { - args.push_back(e); - } - else { - args.push_back(m.mk_const(v)); - } + v = m.mk_const(pm.o2n(p.sig(i),0)); + expr_ref e = mev.eval(model, v); + args.push_back(e); } return expr_ref(m.mk_app(f, args.size(), args.c_ptr()), m); } @@ -1833,7 +1831,7 @@ namespace pdr { pr = m.mk_asserted(m.mk_true()); for (unsigned i = 0; i < vars.size(); ++i) { if (smt::is_value_sort(m, vars[i].get())) { - VERIFY (M->eval(vars[i].get(), tmp, true)); + tmp = mev.eval(M, vars[i].get()); sub.insert(vars[i].get(), tmp, pr); } } @@ -1866,7 +1864,7 @@ namespace pdr { for (unsigned j = 1; j < indices.size(); ++j) { ptr_vector const& vs = vars[indices[j]]; for (unsigned k = 0; k < vs.size(); ++k) { - M->eval(vs[k]->get_decl(), tmp); + tmp = mev.eval(M, vs[k]); sub.insert(vs[k], tmp, pr); child_states[indices[j]].push_back(m.mk_eq(vs[k], tmp)); } diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 8b5f6fa1e..04c189ca0 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -19,12 +19,13 @@ Revision History: #include "pdr_quantifiers.h" #include "pdr_context.h" -#include "model_smt2_pp.h" -#include "ast_smt2_pp.h" #include "qe.h" #include "var_subst.h" #include "dl_rule_set.h" +#include "ast_smt2_pp.h" #include "model_smt2_pp.h" +#include "ast_smt_pp.h" +#include "expr_abstract.h" namespace pdr { @@ -104,21 +105,34 @@ namespace pdr { } void quantifier_model_checker::apply_binding(quantifier* q, expr_ref_vector& binding) { + + datalog::scoped_no_proof _scp(m); + app_ref_vector& var_inst = m_current_pt->get_inst(m_current_rule); - expr_substitution sub(m); - for (unsigned i = 0; i < var_inst.size(); ++i) { - expr* v = var_inst[i].get(); - sub.insert(v, m.mk_var(i, m.get_sort(v))); - } - scoped_ptr rep = mk_default_expr_replacer(m); - rep->set_substitution(&sub); + + TRACE("pdr", tout << mk_pp(q, m) << "\n"; + tout << "binding\n"; + for (unsigned i = 0; i < binding.size(); ++i) { + tout << mk_pp(binding[i].get(), m) << " "; + } + tout << "\n"; + tout << "inst\n"; + for (unsigned i = 0; i < var_inst.size(); ++i) { + tout << mk_pp(var_inst[i].get(), m) << " "; + } + tout << "\n"; + ); + + expr_ref e(m); var_subst vs(m, false); + inv_var_shifter invsh(m); vs(q->get_expr(), binding.size(), binding.c_ptr(), e); - (*rep)(e); + invsh(e, q->get_num_decls(), e); + expr_abstract(m, 0, var_inst.size(), (expr*const*)var_inst.c_ptr(), e, e); + TRACE("pdr", tout << mk_pp(e, m) << "\n";); m_instantiated_rules.push_back(m_current_rule); m_instantiations.push_back(to_app(e)); - TRACE("pdr", tout << mk_pp(e, m) << "\n";); } @@ -187,6 +201,7 @@ namespace pdr { expr_ref_vector fmls(m); front_end_params fparams; fparams.m_proof_mode = PGM_COARSE; + fparams.m_mbqi = true; // TBD: does not work on integers: fparams.m_mbqi = true; fmls.push_back(m_A.get()); @@ -364,6 +379,12 @@ namespace pdr { for (unsigned i = 0; i < m_Bs.size(); ++i) { tout << mk_pp((*qis)[i].get(), m) << "\n" << mk_pp(m_Bs[i].get(), m) << "\n"; } + ast_smt_pp pp(m); + pp.add_assumption(m_A); + for (unsigned i = 0; i < m_Bs.size(); ++i) { + pp.add_assumption(m_Bs[i].get()); + } + pp.display_smt2(tout, m.mk_true()); ); find_instantiations(*qis, level); @@ -406,6 +427,7 @@ namespace pdr { m_quantifiers.remove(r); datalog::rule_ref_vector rules(rule_m); expr_ref rule(m.mk_implies(m.mk_and(body.size(), body.c_ptr()), r->get_head()), m); + std::cout << mk_pp(rule, m) << "\n"; rule_m.mk_rule(rule, rules, r->name()); for (unsigned i = 0; i < rules.size(); ++i) { new_rules.add_rule(rules[i].get()); diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 0fcb6c7c2..705b519a2 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -549,7 +549,7 @@ namespace pdr { } } - bool model_evaluator::extract_array_func_interp(expr* a, vector& stores, expr_ref else_case) { + bool model_evaluator::extract_array_func_interp(expr* a, vector& stores, expr_ref& else_case) { SASSERT(m_array.is_array(a)); while (m_array.is_store(a)) { @@ -582,6 +582,9 @@ namespace pdr { stores.push_back(store); } else_case = g->get_else(); + if (!else_case) { + return false; + } if (!is_ground(else_case)) { return false; } @@ -903,6 +906,32 @@ namespace pdr { return !has_x; } + expr_ref model_evaluator::eval(model_ref& model, expr* e) { + expr_ref result(m); + m_model = model; + VERIFY(m_model->eval(e, result, true)); + if (m_array.is_array(e)) { + vector stores; + expr_ref_vector args(m); + expr_ref else_case(m); + if (extract_array_func_interp(result, stores, else_case)) { + result = m_array.mk_const_array(m.get_sort(e), else_case); + while (!stores.empty() && stores.back().back() == else_case) { + stores.pop_back(); + } + for (unsigned i = stores.size(); i > 0; ) { + --i; + args.resize(1); + args[0] = result; + args.append(stores[i]); + result = m_array.mk_store(args.size(), args.c_ptr()); + } + return result; + } + } + return result; + } + void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml) { ast_manager& m = fml.get_manager(); diff --git a/src/muz_qe/pdr_util.h b/src/muz_qe/pdr_util.h index bb9f74060..89598d347 100644 --- a/src/muz_qe/pdr_util.h +++ b/src/muz_qe/pdr_util.h @@ -103,7 +103,7 @@ namespace pdr { bool check_model(ptr_vector const & formulas); - bool extract_array_func_interp(expr* a, vector& stores, expr_ref else_case); + bool extract_array_func_interp(expr* a, vector& stores, expr_ref& else_case); public: model_evaluator(ast_manager& m) : m(m), m_arith(m), m_array(m), m_refs(m) {} @@ -127,6 +127,8 @@ namespace pdr { for_each_expr visitor. */ void operator()(expr* e) {} + + expr_ref eval(model_ref& mdl, expr* e); }; /** From fb947f50fbee5d136a5a180358984a29f1c9076a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Nov 2012 20:47:09 -0800 Subject: [PATCH 14/17] fold properties at level infty into the other properties as suggested by Arie Signed-off-by: Nikolaj Bjorner --- src/muz_qe/pdr_context.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index d5b495305..9eda8a55e 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -299,6 +299,7 @@ namespace pdr { if (!m_invariants.contains(lemma)) { TRACE("pdr", tout << "property1: " << head()->get_name() << " " << mk_pp(lemma, m) << "\n";); m_invariants.push_back(lemma); + m_prop2level.insert(lemma, lvl); m_solver.add_formula(lemma); return true; } @@ -709,11 +710,6 @@ namespace pdr { for (; it != end; ++it) { add_property(it->m_key, it->m_value); } - for (unsigned i = 0; i < other.m_invariants.size(); ++i) { - expr* e = other.m_invariants[i].get(); - m_invariants.push_back(e); - m_solver.add_formula(e); - } } // ---------------- From c82deeaf3cd3b7b0eb84c2667db25b6c0a73dff0 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 27 Nov 2012 08:01:11 -0800 Subject: [PATCH 15/17] working on quantifiers Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_mk_array_blast.cpp | 26 +++++++++++------ src/muz_qe/dl_mk_extract_quantifiers.cpp | 9 +++--- src/muz_qe/dl_mk_extract_quantifiers.h | 4 +-- src/muz_qe/pdr_context.cpp | 4 +-- src/muz_qe/pdr_prop_solver.h | 2 +- src/muz_qe/pdr_quantifiers.cpp | 37 ++++++++++++++---------- 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/muz_qe/dl_mk_array_blast.cpp b/src/muz_qe/dl_mk_array_blast.cpp index 39223264c..d63528db3 100644 --- a/src/muz_qe/dl_mk_array_blast.cpp +++ b/src/muz_qe/dl_mk_array_blast.cpp @@ -7,7 +7,7 @@ Module Name: Abstract: - Remove array variables from rules. + Remove array stores from rules. Author: @@ -53,6 +53,11 @@ namespace datalog { unsigned utsz = r.get_uninterpreted_tail_size(); unsigned tsz = r.get_tail_size(); expr_ref_vector conjs(m), new_conjs(m); + expr_ref tmp(m); + expr_substitution sub(m); + uint_set lhs_vars, rhs_vars; + bool change = false; + for (unsigned i = 0; i < utsz; ++i) { new_conjs.push_back(r.get_tail(i)); } @@ -60,11 +65,10 @@ namespace datalog { conjs.push_back(r.get_tail(i)); } flatten_and(conjs); - expr_substitution sub(m); - uint_set lhs_vars, rhs_vars; for (unsigned i = 0; i < conjs.size(); ++i) { - expr* x, *y; - if (is_store_def(conjs[i].get(), x, y)) { + expr* x, *y, *e = conjs[i].get(); + + if (is_store_def(e, x, y)) { // enforce topological order consistency: uint_set lhs; collect_vars(m, x, lhs_vars); @@ -72,17 +76,20 @@ namespace datalog { lhs = lhs_vars; lhs &= rhs_vars; if (!lhs.empty()) { - new_conjs.push_back(conjs[i].get()); + TRACE("dl", tout << "unusable equality " << mk_pp(e, m) << "\n";); + new_conjs.push_back(e); } else { sub.insert(x, y); } } else { - new_conjs.push_back(conjs[i].get()); + m_rewriter(e, tmp); + change = change || (tmp != e); + new_conjs.push_back(tmp); } } - if (sub.empty()) { + if (sub.empty() && !change) { rules.add_rule(&r); return false; } @@ -101,6 +108,8 @@ namespace datalog { fml2 = m.mk_implies(body, head); rm.mk_rule(fml2, new_rules, r.name()); SASSERT(new_rules.size() == 1); + + TRACE("dl", tout << "new body " << mk_pp(fml2, m) << "\n";); rules.add_rule(new_rules[0].get()); if (m_pc) { @@ -131,7 +140,6 @@ namespace datalog { pc = concat(pc.get(), epc.get()); } return rules; - } }; diff --git a/src/muz_qe/dl_mk_extract_quantifiers.cpp b/src/muz_qe/dl_mk_extract_quantifiers.cpp index 5999b751c..d2b4f0cec 100644 --- a/src/muz_qe/dl_mk_extract_quantifiers.cpp +++ b/src/muz_qe/dl_mk_extract_quantifiers.cpp @@ -121,10 +121,11 @@ namespace datalog { } else { rule_ref new_rule(rm); - std::cout << mk_pp(r.get_head(), m) << " :- \n"; - for (unsigned i = 0; i < tail.size(); ++i) { - std::cout << " " << mk_pp(tail[i].get(), m) << "\n"; - } + TRACE("dl", + tout << mk_pp(r.get_head(), m) << " :- \n"; + for (unsigned i = 0; i < tail.size(); ++i) { + tout << " " << mk_pp(tail[i].get(), m) << "\n"; + }); new_rule = rm.mk(r.get_head(), tail.size(), tail.c_ptr(), 0, r.name(), false); quantifier_ref_vector* qs = alloc(quantifier_ref_vector, quantifiers); m_refs.push_back(qs); diff --git a/src/muz_qe/dl_mk_extract_quantifiers.h b/src/muz_qe/dl_mk_extract_quantifiers.h index 4fc78c62c..5da5d59d7 100644 --- a/src/muz_qe/dl_mk_extract_quantifiers.h +++ b/src/muz_qe/dl_mk_extract_quantifiers.h @@ -39,8 +39,6 @@ namespace datalog { app_ref ensure_app(expr* e); - void ensure_predicate(expr* e, unsigned& max_var, app_ref_vector& tail); - public: /** \brief Create rule transformer that extracts universal quantifiers (over recursive predicates). @@ -55,6 +53,8 @@ namespace datalog { bool has_quantifiers() const { return !m_quantifiers.empty(); } + void ensure_predicate(expr* e, unsigned& max_var, app_ref_vector& tail); + }; }; diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 9eda8a55e..798ee406d 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -442,6 +442,7 @@ namespace pdr { tmp = pm.mk_and(conj); prop_solver::scoped_level _sl(m_solver, level); m_solver.set_core(core); + m_solver.set_model(0); lbool r = m_solver.check_conjunction_as_assumptions(tmp); if (r == l_false) { assumes_level = m_solver.assumes_level(); @@ -705,8 +706,7 @@ namespace pdr { void pred_transformer::inherit_properties(pred_transformer& other) { SASSERT(m_head == other.m_head); obj_map::iterator it = other.m_prop2level.begin(); - obj_map::iterator end = other.m_prop2level.end(); - + obj_map::iterator end = other.m_prop2level.end(); for (; it != end; ++it) { add_property(it->m_key, it->m_value); } diff --git a/src/muz_qe/pdr_prop_solver.h b/src/muz_qe/pdr_prop_solver.h index 15122a21a..fcbfbd536 100644 --- a/src/muz_qe/pdr_prop_solver.h +++ b/src/muz_qe/pdr_prop_solver.h @@ -94,7 +94,7 @@ namespace pdr { scoped_level(prop_solver& ps, unsigned lvl):m_lev(ps.m_in_level) { SASSERT(!m_lev); m_lev = true; ps.m_current_level = lvl; } - ~scoped_level() { m_lev = false; } + ~scoped_level() { m_lev = false; } }; void add_formula(expr * form); diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 04c189ca0..47a1622f3 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -26,6 +26,7 @@ Revision History: #include "model_smt2_pp.h" #include "ast_smt_pp.h" #include "expr_abstract.h" +#include "dl_mk_extract_quantifiers.h" namespace pdr { @@ -129,7 +130,10 @@ namespace pdr { inv_var_shifter invsh(m); vs(q->get_expr(), binding.size(), binding.c_ptr(), e); invsh(e, q->get_num_decls(), e); - expr_abstract(m, 0, var_inst.size(), (expr*const*)var_inst.c_ptr(), e, e); + expr_ref_vector inst(m); + inst.append(var_inst.size(), (expr*const*)var_inst.c_ptr()); + inst.reverse(); + expr_abstract(m, 0, inst.size(), inst.c_ptr(), e, e); TRACE("pdr", tout << mk_pp(e, m) << "\n";); m_instantiated_rules.push_back(m_current_rule); m_instantiations.push_back(to_app(e)); @@ -403,16 +407,18 @@ namespace pdr { } void quantifier_model_checker::refine() { - IF_VERBOSE(1, verbose_stream() << "instantiating quantifiers\n";); - datalog::rule_manager& rule_m = m_rules.get_rule_manager(); + datalog::mk_extract_quantifiers eq(m_ctx.get_context()); + datalog::rule_manager& rm = m_rules.get_rule_manager(); datalog::rule_set new_rules(m_rules.get_context()); datalog::rule_set::iterator it = m_rules.begin(), end = m_rules.end(); for (; it != end; ++it) { datalog::rule* r = *it; - expr_ref_vector body(m); + datalog::var_counter vc(true); + unsigned max_var = vc.get_max_var(*r); + app_ref_vector body(m); for (unsigned i = 0; i < m_instantiations.size(); ++i) { if (r == m_instantiated_rules[i]) { - body.push_back(m_instantiations[i].get()); + eq.ensure_predicate(m_instantiations[i].get(), max_var, body); } } if (body.empty()) { @@ -424,18 +430,19 @@ namespace pdr { } quantifier_ref_vector* qs = 0; m_quantifiers.find(r, qs); - m_quantifiers.remove(r); - datalog::rule_ref_vector rules(rule_m); - expr_ref rule(m.mk_implies(m.mk_and(body.size(), body.c_ptr()), r->get_head()), m); - std::cout << mk_pp(rule, m) << "\n"; - rule_m.mk_rule(rule, rules, r->name()); - for (unsigned i = 0; i < rules.size(); ++i) { - new_rules.add_rule(rules[i].get()); - m_quantifiers.insert(rules[i].get(), qs); - } + m_quantifiers.remove(r); + datalog::rule_ref new_rule(rm); + new_rule = rm.mk(r->get_head(), body.size(), body.c_ptr(), 0, r->name(), false); + new_rules.add_rule(new_rule); + m_quantifiers.insert(new_rule, qs); + IF_VERBOSE(1, + verbose_stream() << "instantiating quantifiers\n"; + r->display(m_ctx.get_context(), verbose_stream()); + verbose_stream() << "replaced by\n"; + new_rule->display(m_ctx.get_context(), verbose_stream());); } } - new_rules.close(); + new_rules.close(); m_rules.reset(); m_rules.add_rules(new_rules); m_rules.close(); From c6303fc8f51919f7b07e1d4e655372fa6d53ecca Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 16:36:50 +0000 Subject: [PATCH 16/17] Java API: a first version that compiles. This is still untested. Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 10 +- scripts/update_api.py | 14 +- src/api/java/AST.java | 228 ++ src/api/java/ASTDecRefQueue.java | 19 + src/api/java/ASTMap.java | 116 + src/api/java/ASTVector.java | 104 + src/api/java/AlgebraicNum.java | 59 + src/api/java/ApplyResult.java | 75 + src/api/java/ApplyResultDecRefQueue.java | 19 + src/api/java/ArithExpr.java | 26 + src/api/java/ArithSort.java | 18 + src/api/java/ArrayExpr.java | 27 + src/api/java/ArraySort.java | 44 + src/api/java/AstMapDecRefQueue.java | 19 + src/api/java/AstVectorDecRefQueue.java | 19 + src/api/java/BitVecExpr.java | 36 + src/api/java/BitVecNum.java | 62 + src/api/java/BitVecSort.java | 25 + src/api/java/BoolExpr.java | 30 + src/api/java/BoolSort.java | 16 + src/api/java/Constructor.java | 107 + src/api/java/ConstructorList.java | 35 + src/api/java/Context.java | 3112 +++++++++++++++ src/api/java/DatatypeExpr.java | 26 + src/api/java/DatatypeSort.java | 91 + src/api/java/EnumSort.java | 64 + .../Z3 => }/Enumerations/Z3_ast_kind.java | 0 .../Enumerations/Z3_ast_print_mode.java | 0 .../Z3 => }/Enumerations/Z3_decl_kind.java | 0 .../Z3 => }/Enumerations/Z3_error_code.java | 0 .../Z3 => }/Enumerations/Z3_goal_prec.java | 0 .../Z3 => }/Enumerations/Z3_lbool.java | 0 .../Z3 => }/Enumerations/Z3_param_kind.java | 0 .../Enumerations/Z3_parameter_kind.java | 0 .../Z3 => }/Enumerations/Z3_sort_kind.java | 0 .../Z3 => }/Enumerations/Z3_symbol_kind.java | 0 src/api/java/Expr.java | 1807 +++++++++ src/api/java/FiniteDomainSort.java | 34 + src/api/java/Fixedpoint.java | 327 ++ src/api/java/FixedpointDecRefQueue.java | 19 + src/api/java/FuncDecl.java | 379 ++ src/api/java/FuncInterp.java | 185 + src/api/java/FuncInterpDecRefQueue.java | 19 + src/api/java/FuncInterpEntryDecRefQueue.java | 19 + src/api/java/Goal.java | 211 + src/api/java/GoalDecRefQueue.java | 19 + src/api/java/IDecRefQueue.java | 48 + .../{com/Microsoft/Z3 => }/IDisposable.java | 4 +- src/api/java/IntExpr.java | 26 + src/api/java/IntNum.java | 59 + src/api/java/IntSort.java | 23 + src/api/java/IntSymbol.java | 44 + src/api/java/ListSort.java | 101 + src/api/java/Log.java | 60 + src/api/java/Model.java | 291 ++ src/api/java/ModelDecRefQueue.java | 19 + .../java/{com/Microsoft/Z3 => }/Native.java | 42 +- src/api/java/ParamDescrs.java | 85 + src/api/java/ParamDescrsDecRefQueue.java | 19 + src/api/java/Params.java | 102 + src/api/java/ParamsDecRefQueue.java | 19 + src/api/java/Pattern.java | 51 + src/api/java/Probe.java | 63 + src/api/java/ProbeDecRefQueue.java | 19 + src/api/java/Quantifier.java | 213 + src/api/java/RatNum.java | 73 + src/api/java/RealExpr.java | 26 + src/api/java/RealSort.java | 23 + src/api/java/RelationSort.java | 46 + src/api/java/SetSort.java | 23 + src/api/java/Solver.java | 242 ++ src/api/java/SolverDecRefQueue.java | 19 + src/api/java/Sort.java | 143 + src/api/java/Statistics.java | 190 + src/api/java/StatisticsDecRefQueue.java | 19 + src/api/java/Status.java | 42 + src/api/java/StringSymbol.java | 43 + src/api/java/Symbol.java | 81 + src/api/java/Tactic.java | 98 + src/api/java/TacticDecRefQueue.java | 19 + src/api/java/TupleSort.java | 58 + src/api/java/UninterpretedSort.java | 23 + src/api/java/Version.java | 68 + src/api/java/Z3Exception.java | 40 + src/api/java/Z3Object.java | 116 + src/api/java/com/Microsoft/Z3/AST.java | 214 - src/api/java/com/Microsoft/Z3/ASTMap.java | 132 - src/api/java/com/Microsoft/Z3/ASTVector.java | 112 - .../java/com/Microsoft/Z3/AlgebraicNum.java | 63 - .../java/com/Microsoft/Z3/ApplyResult.java | 90 - src/api/java/com/Microsoft/Z3/ArithExpr.java | 32 - src/api/java/com/Microsoft/Z3/ArithSort.java | 20 - src/api/java/com/Microsoft/Z3/ArrayExpr.java | 32 - src/api/java/com/Microsoft/Z3/ArraySort.java | 47 - src/api/java/com/Microsoft/Z3/BitVecExpr.java | 32 - src/api/java/com/Microsoft/Z3/BitVecNum.java | 81 - src/api/java/com/Microsoft/Z3/BitVecSort.java | 25 - src/api/java/com/Microsoft/Z3/BoolExpr.java | 28 - src/api/java/com/Microsoft/Z3/BoolSort.java | 21 - .../java/com/Microsoft/Z3/Constructor.java | 121 - .../com/Microsoft/Z3/ConstructorList.java | 43 - src/api/java/com/Microsoft/Z3/Context.java | 3432 ----------------- .../java/com/Microsoft/Z3/DatatypeExpr.java | 32 - .../java/com/Microsoft/Z3/DatatypeSort.java | 81 - src/api/java/com/Microsoft/Z3/EnumSort.java | 83 - .../Z3/Enumerations/Z3_ast_kind.class | Bin 1554 -> 0 bytes .../Z3/Enumerations/Z3_ast_print_mode.class | Bin 1450 -> 0 bytes .../Z3/Enumerations/Z3_decl_kind.class | Bin 11227 -> 0 bytes .../Z3/Enumerations/Z3_error_code.class | Bin 1961 -> 0 bytes .../Z3/Enumerations/Z3_goal_prec.class | Bin 1379 -> 0 bytes .../Microsoft/Z3/Enumerations/Z3_lbool.class | Bin 1270 -> 0 bytes .../Z3/Enumerations/Z3_param_kind.class | Bin 1557 -> 0 bytes .../Z3/Enumerations/Z3_parameter_kind.class | Bin 1639 -> 0 bytes .../Z3/Enumerations/Z3_sort_kind.class | Bin 1770 -> 0 bytes .../Z3/Enumerations/Z3_symbol_kind.class | Bin 1270 -> 0 bytes src/api/java/com/Microsoft/Z3/Expr.java | 1446 ------- .../com/Microsoft/Z3/FiniteDomainSort.java | 39 - src/api/java/com/Microsoft/Z3/Fixedpoint.java | 307 -- src/api/java/com/Microsoft/Z3/FuncDecl.java | 287 -- src/api/java/com/Microsoft/Z3/FuncInterp.java | 185 - src/api/java/com/Microsoft/Z3/Goal.java | 187 - .../java/com/Microsoft/Z3/IDecRefQueue.java | 75 - src/api/java/com/Microsoft/Z3/IntExpr.java | 32 - src/api/java/com/Microsoft/Z3/IntNum.java | 86 - src/api/java/com/Microsoft/Z3/IntSort.java | 27 - src/api/java/com/Microsoft/Z3/IntSymbol.java | 46 - src/api/java/com/Microsoft/Z3/ListSort.java | 123 - src/api/java/com/Microsoft/Z3/Log.java | 65 - src/api/java/com/Microsoft/Z3/Model.java | 284 -- src/api/java/com/Microsoft/Z3/Native.class | Bin 14300 -> 0 bytes .../java/com/Microsoft/Z3/ParamDescrs.java | 92 - src/api/java/com/Microsoft/Z3/Params.java | 121 - src/api/java/com/Microsoft/Z3/Pattern.java | 53 - src/api/java/com/Microsoft/Z3/Probe.java | 80 - src/api/java/com/Microsoft/Z3/Quantifier.java | 199 - src/api/java/com/Microsoft/Z3/RatNum.java | 79 - src/api/java/com/Microsoft/Z3/RealExpr.java | 34 - src/api/java/com/Microsoft/Z3/RealSort.java | 27 - .../java/com/Microsoft/Z3/RelationSort.java | 47 - src/api/java/com/Microsoft/Z3/SetSort.java | 28 - src/api/java/com/Microsoft/Z3/Solver.java | 252 -- src/api/java/com/Microsoft/Z3/Sort.java | 118 - src/api/java/com/Microsoft/Z3/Statistics.java | 184 - src/api/java/com/Microsoft/Z3/Status.java | 42 - .../java/com/Microsoft/Z3/StringSymbol.java | 51 - src/api/java/com/Microsoft/Z3/Symbol.java | 74 - src/api/java/com/Microsoft/Z3/Tactic.java | 112 - src/api/java/com/Microsoft/Z3/TupleSort.java | 58 - .../com/Microsoft/Z3/UninterpretedSort.java | 28 - src/api/java/com/Microsoft/Z3/Version.class | Bin 1062 -> 0 bytes src/api/java/com/Microsoft/Z3/Version.java | 73 - .../java/com/Microsoft/Z3/Z3Exception.java | 33 - src/api/java/com/Microsoft/Z3/Z3Object.java | 119 - 153 files changed, 10063 insertions(+), 9851 deletions(-) create mode 100644 src/api/java/AST.java create mode 100644 src/api/java/ASTDecRefQueue.java create mode 100644 src/api/java/ASTMap.java create mode 100644 src/api/java/ASTVector.java create mode 100644 src/api/java/AlgebraicNum.java create mode 100644 src/api/java/ApplyResult.java create mode 100644 src/api/java/ApplyResultDecRefQueue.java create mode 100644 src/api/java/ArithExpr.java create mode 100644 src/api/java/ArithSort.java create mode 100644 src/api/java/ArrayExpr.java create mode 100644 src/api/java/ArraySort.java create mode 100644 src/api/java/AstMapDecRefQueue.java create mode 100644 src/api/java/AstVectorDecRefQueue.java create mode 100644 src/api/java/BitVecExpr.java create mode 100644 src/api/java/BitVecNum.java create mode 100644 src/api/java/BitVecSort.java create mode 100644 src/api/java/BoolExpr.java create mode 100644 src/api/java/BoolSort.java create mode 100644 src/api/java/Constructor.java create mode 100644 src/api/java/ConstructorList.java create mode 100644 src/api/java/Context.java create mode 100644 src/api/java/DatatypeExpr.java create mode 100644 src/api/java/DatatypeSort.java create mode 100644 src/api/java/EnumSort.java rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_ast_kind.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_ast_print_mode.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_decl_kind.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_error_code.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_goal_prec.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_lbool.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_param_kind.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_parameter_kind.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_sort_kind.java (100%) rename src/api/java/{com/Microsoft/Z3 => }/Enumerations/Z3_symbol_kind.java (100%) create mode 100644 src/api/java/Expr.java create mode 100644 src/api/java/FiniteDomainSort.java create mode 100644 src/api/java/Fixedpoint.java create mode 100644 src/api/java/FixedpointDecRefQueue.java create mode 100644 src/api/java/FuncDecl.java create mode 100644 src/api/java/FuncInterp.java create mode 100644 src/api/java/FuncInterpDecRefQueue.java create mode 100644 src/api/java/FuncInterpEntryDecRefQueue.java create mode 100644 src/api/java/Goal.java create mode 100644 src/api/java/GoalDecRefQueue.java create mode 100644 src/api/java/IDecRefQueue.java rename src/api/java/{com/Microsoft/Z3 => }/IDisposable.java (84%) create mode 100644 src/api/java/IntExpr.java create mode 100644 src/api/java/IntNum.java create mode 100644 src/api/java/IntSort.java create mode 100644 src/api/java/IntSymbol.java create mode 100644 src/api/java/ListSort.java create mode 100644 src/api/java/Log.java create mode 100644 src/api/java/Model.java create mode 100644 src/api/java/ModelDecRefQueue.java rename src/api/java/{com/Microsoft/Z3 => }/Native.java (97%) create mode 100644 src/api/java/ParamDescrs.java create mode 100644 src/api/java/ParamDescrsDecRefQueue.java create mode 100644 src/api/java/Params.java create mode 100644 src/api/java/ParamsDecRefQueue.java create mode 100644 src/api/java/Pattern.java create mode 100644 src/api/java/Probe.java create mode 100644 src/api/java/ProbeDecRefQueue.java create mode 100644 src/api/java/Quantifier.java create mode 100644 src/api/java/RatNum.java create mode 100644 src/api/java/RealExpr.java create mode 100644 src/api/java/RealSort.java create mode 100644 src/api/java/RelationSort.java create mode 100644 src/api/java/SetSort.java create mode 100644 src/api/java/Solver.java create mode 100644 src/api/java/SolverDecRefQueue.java create mode 100644 src/api/java/Sort.java create mode 100644 src/api/java/Statistics.java create mode 100644 src/api/java/StatisticsDecRefQueue.java create mode 100644 src/api/java/Status.java create mode 100644 src/api/java/StringSymbol.java create mode 100644 src/api/java/Symbol.java create mode 100644 src/api/java/Tactic.java create mode 100644 src/api/java/TacticDecRefQueue.java create mode 100644 src/api/java/TupleSort.java create mode 100644 src/api/java/UninterpretedSort.java create mode 100644 src/api/java/Version.java create mode 100644 src/api/java/Z3Exception.java create mode 100644 src/api/java/Z3Object.java delete mode 100644 src/api/java/com/Microsoft/Z3/AST.java delete mode 100644 src/api/java/com/Microsoft/Z3/ASTMap.java delete mode 100644 src/api/java/com/Microsoft/Z3/ASTVector.java delete mode 100644 src/api/java/com/Microsoft/Z3/AlgebraicNum.java delete mode 100644 src/api/java/com/Microsoft/Z3/ApplyResult.java delete mode 100644 src/api/java/com/Microsoft/Z3/ArithExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/ArithSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/ArrayExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/ArraySort.java delete mode 100644 src/api/java/com/Microsoft/Z3/BitVecExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/BitVecNum.java delete mode 100644 src/api/java/com/Microsoft/Z3/BitVecSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/BoolExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/BoolSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Constructor.java delete mode 100644 src/api/java/com/Microsoft/Z3/ConstructorList.java delete mode 100644 src/api/java/com/Microsoft/Z3/Context.java delete mode 100644 src/api/java/com/Microsoft/Z3/DatatypeExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/DatatypeSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/EnumSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_ast_print_mode.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_decl_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_error_code.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_goal_prec.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_lbool.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_param_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_parameter_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_sort_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Enumerations/Z3_symbol_kind.class delete mode 100644 src/api/java/com/Microsoft/Z3/Expr.java delete mode 100644 src/api/java/com/Microsoft/Z3/FiniteDomainSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Fixedpoint.java delete mode 100644 src/api/java/com/Microsoft/Z3/FuncDecl.java delete mode 100644 src/api/java/com/Microsoft/Z3/FuncInterp.java delete mode 100644 src/api/java/com/Microsoft/Z3/Goal.java delete mode 100644 src/api/java/com/Microsoft/Z3/IDecRefQueue.java delete mode 100644 src/api/java/com/Microsoft/Z3/IntExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/IntNum.java delete mode 100644 src/api/java/com/Microsoft/Z3/IntSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/IntSymbol.java delete mode 100644 src/api/java/com/Microsoft/Z3/ListSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Log.java delete mode 100644 src/api/java/com/Microsoft/Z3/Model.java delete mode 100644 src/api/java/com/Microsoft/Z3/Native.class delete mode 100644 src/api/java/com/Microsoft/Z3/ParamDescrs.java delete mode 100644 src/api/java/com/Microsoft/Z3/Params.java delete mode 100644 src/api/java/com/Microsoft/Z3/Pattern.java delete mode 100644 src/api/java/com/Microsoft/Z3/Probe.java delete mode 100644 src/api/java/com/Microsoft/Z3/Quantifier.java delete mode 100644 src/api/java/com/Microsoft/Z3/RatNum.java delete mode 100644 src/api/java/com/Microsoft/Z3/RealExpr.java delete mode 100644 src/api/java/com/Microsoft/Z3/RealSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/RelationSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/SetSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Solver.java delete mode 100644 src/api/java/com/Microsoft/Z3/Sort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Statistics.java delete mode 100644 src/api/java/com/Microsoft/Z3/Status.java delete mode 100644 src/api/java/com/Microsoft/Z3/StringSymbol.java delete mode 100644 src/api/java/com/Microsoft/Z3/Symbol.java delete mode 100644 src/api/java/com/Microsoft/Z3/Tactic.java delete mode 100644 src/api/java/com/Microsoft/Z3/TupleSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/UninterpretedSort.java delete mode 100644 src/api/java/com/Microsoft/Z3/Version.class delete mode 100644 src/api/java/com/Microsoft/Z3/Version.java delete mode 100644 src/api/java/com/Microsoft/Z3/Z3Exception.java delete mode 100644 src/api/java/com/Microsoft/Z3/Z3Object.java 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 b94349266d87b21f5cf6913260d2d8b2706e7ef0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1554 zcmah}U2_s=6n@e7Joti zMDIGi=}j*zw$*8;j@O;(?`VHQuWZkGp-QKYVVLveIqx~|dCoa6`R(P;&jGBV5`c%08lVhh^&Nr?X@}-fBW6IUt!d`CdU=g|7w@0T&+x2Qr zXV4N5MFD-KmMc{Yw!qToC&|+uab92GTrzcHu$u4QryA3xw%aNXjt^SBednM<9$ns2 zITTn;mL52doNUK&kFvJcYr97qsS`zPw%xY3C9v>@>|!xh6A0MtBiHc;J*uWArAt5T zb&rd#$J&c0)|j$Ar}=Q#`9eyj_aWf-x-wl!rf6!$X0tPvK@KW;d7_hoJ2>8admCG{ zY}4)zdd=2On}@<{{P!VT;-OeL&(Ctj!Yz~p;%|F77E;)?kU`nPIV@YafOnW)v=Bwi z!WlMkHVHP1Y?j!ZMNA;{dIzkWT5Wc^E@?WIOigrEIe5@&dZhd6JIZnaLQ*V|L`x*y5=pv5QZJDjpv)QW8VJXDX2dlF zcmxo5m)J5Pf6O7oPw>5f@|c)FlB_1rOo~q-J&r#QpY#T2p{Ad~{{rg&6MQ^g3giM8 zp->BemCnSULQ5xpg#P`j5+OPT=BU&>f>^+N#C*6!t!8m~T(U_XKlwAyV3ab?uPIxJ z_&11U607TKRQ&;Z>}zOI_3@XA`1bEVC`eglNj}-bj4U3*EKQB)a)DNTg-)sPO9XVR z3NiN=T_2(Udhd@5CJ1>d{xn_w9sMymjwKkliVw!2ze{DnSHD25&jb|zQl+03f z$)+R=`8CO=B@1g2J>JU?Q-9N;% zUDt+)*mZq~S-WlwF=yAq*w_wuDMho~5 KA5p9iAO8c?E;F(K 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 b146851186dd99083b4d89fb22e2806242d7b710..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1450 zcma)5Sx*yD6#i~!I@4v?3beFrr?>unPGUY%!w-0$_+JR1PXB_ZyJL`at+c_2U41w+O)W+lZS|VkvCiM8ySSq%@ zx}nDx*Afhadb*g8u4dDvV!60$MYqT4O_^mYbx_I{tW>`EJTt@KztW?=MaR{>l}%k| z@LYuT^(QHPIk`+h2lY&vxk`qC#TnGWpi-yj{4$8eKYMeMmKzYn)+`2(ugXGyTM1XH&xHd9P5j({rr*P0Us*)M;98h8!GFCV><*xO$}C`lUQkZgj3M-2B-`!4c*qIHmVY4ACmDng8P{-pM8 z2qRJ($hG0B*u&KP9evcx(E|r@x?4+qDUbnAzd+vdI3?u-u4A}`r^$BVH3_fTE(xzi zc&&;oyf*bK6-rgOjV-x~CS%K9MT@beRMBP}gIy}+6_eZqoL|i*g4>KKxQON-%|;Lv Hr0@L(7U?iQ 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 6ba48582b09a7ce99f5d1804b4315c22fd15a14f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11227 zcmai)2Y6i7vBzh2@7+C;W&0fWiW|ngV~o33(n?x;rImLj+j3jWa+8bXPBHEc<8IS? z@Ac3j^xj(t=?NhO(nAOV!b^BFbC0y*z4tx7kMIA}{oiv>otb+j^Xh*ddlCS~gihvx zhkwq;zu;e^_(2r^mX8zgGnT*eozL@0{-JOp^9y$VscVdPW*UWanC%qSFxxAf%j}?V z90tkqXaZj#79wbF{*9m}3;4%RF7-7Uo!m=P}PvxRp6h;Wp-(3b!-I zE8M}Hpl~O1qQYIwNeXu}Co9~;oT6|qbE?99%xMbuGh+(RXBH|vz${XD0kc@)L1tXx zA!dof!^~2JN0?;_k1`Vqk1?k!JkFe<@B}ldkYhYluJA%;g~E%NDTNm^D-~YCoT>0q zW?JE8%#6aznN(?N%tZ=sVb&_VmAP2qZOl4_w=8G^h9hyl|MM*YO6(g^8;H6{P>8V5of(ovaG|RTZ zkC}K?mS&own{HOrL3KrOyrlVQ9y(S*Gi!R9Ms{tfWA|{=R9Y^fusR(tAKARRRD32v z$L3jqVBBsG=jwq>|O#8A3ZZK&mQM70;#~g|3{N*?$n)2F&|-3s9VM0 zqw;FnOqY;Btd++qn`iDO>Q+blR#sD)sw#_T5|lUYDN4k2ydqYfTaaX|%m1nr-Q~#o z?qVua)IlzE=!x$hIOS6=yQ(QvY4)y1nne&;O}kqm<8^J$ZjKzP4b_==aduWL{hgUM zC9Zq6q&Ul)p9_?Dd1Z?zk`!^<8LOzy#iQ(6)25g5e!9|G$VW|c%`L5}EK4C@9?KoY z98McIWN{)>m8jrY$>lI-UP&yO$yK7lS)-*OyP&7Ko&8Rr(+KGp&&n-JGKOxu{Gi~cyv@)t6j3BM#}%hXQ+Hf{o4ZR;+9%?4 z5N^vd5~nU2OKF`=AuA{8(n4NnZkuA6tORGvpv%OQl4NdCGNGncO|!_z3A%xJrk$Fj zgd#c4Z%!)1vuFnHiCC!|b1vX3t21RyWwyCjiOyU=^MT15#?6*?%N@CE!)1XEfY7|7 zO|y3`D2Xc5sp+zyrp=IqcLz{io}hqkE*Y}9?iOX31V?VpO|>gS!!_-=1gTpT)u*@g53Vo zyP&+9UU=WF+wziY&ZQvlTf9JuX{+N@ZHjWaL2DmfNN+M1HIiJpTF~-MADmJ1?s7Ue zohVnBmhY7E6uk~o6^SBwr{q$TUmLMGiB#@Um#A)CEi%)+#ydCf5T|-NQAqFn;7#R% zC6g$v2)@K}!(?WpD1Z`kb8%V7ug>Pz44qQTSE;IR*f^_p^`@l=m_Uf0IxCi}=5*^l z?|VNYBb)ib4G4V)4*LGqUQy!`8l`QrzF}#_rZtO~uCJ~3YE?eKY zCeg5wXP@}~L0V@v*4C{muU#vXravhl_!}GL`S8F&v~y}w-D)=vGHA?EE!Glm*tBNS z_bg-zeU|5E8aJ)4TUt`j`@%WU{LMa`H>Lo8#DB~9pdfTKbPS>A|NE6+fIkl%FTh`h zP88q|@%;k)G5&-u@mB>n5hoSkWR@u`Q(305#8?Vhidc$S;w&XBr7UGE36|+BGgy)= znJj6R3`-SDHOnlP*(`HdYFOs7%ww6)vVdhFOO|C3OD)S{mO7RtEK6CI zu`Fj;ImB|9kFq?*@;J*6Se{^clI1Cur&*q1d6wllmgiYs zV0n?{C69lIljSXzw^`m{d6(rqoJ1c^x$43hNhw^ny0L*$t;4`U zEwVMWc;(W%jg*dKTNad})wLToOl;Atxj=olS9-2f%jaA(Dmv3f(ccFr(4QwSpVpOg z5P&$@af;(q$7zl+$3n*<$7090V~Jy_W0_;Zak}FS$E0JqV})bNvC?s-W7;v}NVzQY zr*sxlMhhvag_PGqN^K!!w{V^#<+xlga9rq^bzJ0F>$upl&T)z3QpaVE%Ng#8Y0(Q9k)4d zciiE)({Y#MZpS^2dmZ;V?sq)j@qpt6jt3nNIUaUA;&{~YnB#HB6OJbxsTRrnsT>KZ zA_=J|38^j#sWb_xItj0Eq#7mHS2^a-i@2_JW)8YtIKI6mq4 zl;hKm&p1Bo_?+YOjxRXA==hT3%Z{%&zUugzN5e_#PA5@h1g< z?#5pvbRB^_{=NXjpVC!dKvIBw3-}O(o`&$fbcOgc(umy4r}jU`U%2-DAS7<9_TUYE z1pKGL``-_Q_}c|SGQdy>gGZee3?9!L9gfx(eZk z&=r4!AGsmxXh@&@A&-Dc4ta8NcuLP6*F(1lwA-~1>FV9PCycjz`w2A) zkLD?bWDV_P@H?PA+zGwl4(Jbe;cw|K4g4R-i{i(K9lxUP4gL;4aRc_G74ok5gQ@d7 z>4%ovaW5$R6n`HyHDQ?251ak}nk z{NRzXVw|BnnMi@O7$?S=y0h_46=S>@6Lc37QDRIKW0LM_ykH9_i!nuaGu|L+F;$Fd zy1VfPixCr}Q1>u?7cq*&DAqlVH&l$c7$y1?6AmU;Dn^;^W&B{2gc#FxZ{r8YFhh)_ z?qmF5wdG<|=)NWttTrV^rS50^;9O>kk=CagzpD(J5u-}?H&GO$T8vrxG~;y>W40J` z^Z?@r5mY0_Ts_cWaB}m+n6C$!aIirO#8{{Y8?U$YkriW+9%B5~V$_PUSPwNAgl(M| zOY|_~4U`s3#aO0?8$W2VT#OZZgz%>^EPd8p?F*b;?QIDm6LKS0^7@PGOCLApPEHTd3N8Cw z*pDq@oTtYduaoq#Rg7(Vg7Jokv0aQEdZO|Bh_O?QU3!x7gSG4yV~?I}JR>dkim^{m zF)dUpr;uOjDunv(lO%&Q$H-m5nX7)K{y;0h;o!r>Y*uGKS)7Z}%xalK9&KUnPzV%(_9jTfBlO=8@vD~#V>rhbbUx9XIM1OaoK z7`N+66A3!KLySB1OcMz@y-SR{b=ri2aJWZ|dv(Tyg8jHp46Cb5C|LgeVmzR$jTa32 zpcoJ7S;h;N|F9U3=-I{(>e!=VJf`OukKS8U(jOP&2fD^!a12j~@uZ$>{2=F^660w- z&v+x{k!QqsR?j!yFfpDJ<9WTn_(6QUAjXS&q49!qc}a|yb=LSnIJ_dpt9p^~dPyIz ziSfFwHC{h4-VozWz1a92#CS`Lw{@LS!G63W#=Cln2?e9PC&mx;QsV_%_`VoF(#s46 z#s^~jST8qTJL&W%V*FIEFri@iKNI8Uy54v}QTl}#ztk%Y2DR{4V*FaKGU1@p55@S6 zUTq>lrTa*X-|96c9IWkL zOgI?jYcc+%&o+@@V&91IU-}&51sn8lG5({^HKCxue#=IC`Ztm-CL}3^7&sw)o(ajz z0K8-}^$m>Hta3Xq}@#K6l8aPUCHz5fl%nO`+13Qd2S{`c^SOo@lnuu&JwhpW| z26h>5l(cFaSlYmDqk>i@u-X~eV|usRvoXMFkKz|Miy#lU{! z1#|BjSltYqZ@gg1-2l6bQ7;l7h-z%_s8#rh%m_(nz>TBST@%u}w zet~tWfy2g=P{;m(b((=A#tR-C5Lg2Z95ue2CJqX$!3K^QU(y?g1lCXk#|_F6m#kk1lH*WE;7D+j^Nn9I>W%l#*@Isae;NF zflEw85(LK^xbz7MlCXtVnHtYR>r9Prp>3unV!>o;q88d`YLtbJnHo)2X99U$31oIB z%5DF~xBeb^ApU}p_076>}g9zHf5Q4EVjL^=)2ts=cqX-==j3IQi zFqY8C!Z<=_3*!l0EKDSHwJ@2`&B9bdcMCB>4+}+vo)+SSQ!JDcdRa&idRv%5=wqRr z(APqW(9gn5!l@QAg#H$)38z_@O&DOIhA_~=Ji;Ig3kZWPWC=qo)DnhTs3Q!su#_;| z!g9h03-yGN7FH2PSy)3DZK07c#=<(n=@vE+##-1!IK#qOgmD(mA)IMp3t_y4t%L~{ zwi6~=*h!dVVK-s2g}sC+7WNaSS~x(MX5kFbE&PhG z%EE_))fPS?tg-Mhp~1o@ghmU$C#<#bN5VP_e$-)O zcj$pbp(jp;Q?LShVHSGhTIhp2p)a0*es}|%iVr}4d;w0wAHe|nJ$fL11%pC)FgVl= zhJ=Q|(9k3p7Al9~p@lFa)CeO(J784kIE)TmPyYkx{cw8dc^DgdAI=E<4#tJPgfqhm z#)rGYgz#XP7@i1|!bzAMUI0_V4KOvl9j1kkK`eY76jGrq3O@(M;U7Xg{4tb-{|TjD z6w16Vknje!&$iEkA{byjY|1Q+|AHfp;AFwpy z!?H*xSRNSwDIH8e)0dg z8>1dz$#JECvH&gh4* zEBbfXt-`QJb%4F9KkQTEV82Sh`Dz{C_7Ou>DAFjt2$u k2Cm6(1J~yFf$Q>5hwJl8A)o%z@@tB-5dH!GDE!lZ1Dv6rng9R* 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 f9d486c4ee9c6aad166284c7a49b18c0422e5d60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1961 zcma)6T~k|S5Psg|BP*R|+3KU7h0gnv{<^}Ls z3uzU%RAjuE#x|P|`6TNlV{4dU%&})j!&Syz4PnN68X}DMHAETn8e)ul8fF7s zk%l?Ok2S;@KhbcVv7lj|@ly>8j71gu0zG?+1uMOqNLlNJ?L;nTX43-WsZ#wYzEvqT z>c{niW_)jv{tM+squwZ#>JQ7y0$t?TGPg22xxz-mN(t!XNM|TV);6;OE~1&c?YQ&& ziR@-O&b*&Aw{up8O1UY{%G?p?<_~GEpGZ;4T!L~M(${|6j-A*v1^URfVWrGMBAGO8 zyI^Ls87k)|x1Gu6&Ut`%`zhxh&b4kP3t4mH+@)1&&D~=4q%0sT0d<-x?U=T}#Dh0C zzbsN%Pq#nNY6 z#n0ulX@hCR&ALqB3`eMY+DfT<_7HMV(S;5*X6@u?7P+;``_f*F+$~tc2K&Nlu4IOXe9j2=~W^hHvRW@NZ5jIgaF*dVo zuCbY86K8Xs%{-e0T%pCjm=&v|c9g318ojzN9O+P=*?&|nHA&gc&gmqp#pC1UjGb2T*b4TfT&g(W4ZJcT;+HQYhv@fS|<-CuuDkaK~bO>#FHrJ59;e}c2JaL2B-Ir|mDDe3mrIi@AerHIO4cn|kJ`T2D_Ngr=<={%(gDNm zl5|kgw+z+rNFJ1Y$j}V0MvoQS(954nW5!{InrmG^zmg)WAI&!~w1BDGlsP^x-S?<68{iDF*QyyfoDI MhFJK3ayW4JZ;)?(^b 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 0d278b16fc54b0b86a831a3a98adc4888b830de8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1379 zcmah|OHUI~6#i~!I@8CLM|qT26#=ymr9wrKmmpTtq<~?hvAAf4v5;b!A!W+ig+Ii& zapMAu3eiYd`$zl>uF!KY1!^>QGP!5IbI;>D-@WtwdoiXnLB5jFBlSzbsxbDly^(Q>jz zsZwBIX$EyDJC|8W=?wkP8+KH7dEySkKqT5YTAsIGP?zRR(JCxfw$=*er^Z@|JgO+O zw9b%>WHyamBT+J}jfC!$i`K?uv@wmTqE&QAv(P`%)9GlI!K)WHEW@dkshu1VE_J24Vvrji}63`vPe7Rt33(|DL3~t93`BEfG%6X>DQjG^WsOL!CEGet9HPv8{89GCs zZdb}?;Zc$6(prDO!(12*J^X6*YPgSChVXx{gob|1X&Ar*4PEHg(1$RGgBseMeO+~z8_a=@q=&)ufGj)>=5o_$bToexNa248{B|IQ~@m(?>m4J3x9(8;k-o? z?Q)6=4dExcLxfzoN`$ZBdab2N9yj^phwx1#T}#K@9Cpn zjy`y3rkl0USArSv>?`D4&@0IY@a@AdkS0q41q5nxD*`nO)S|crYE{2cqEv-n&≧ q^qjkjW<94=(W>u*T`1KlI{Aq>znTG}+k|oWXv|a1hLI3M-}()apcK>q 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 eeee15f26a211be42e8ed85f4922618494ee8ea2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1270 zcmaJA?XGFJ`~rW7 z@x>P(u&5A?glGSVf59ho&QhR8ZPT3DnKLurH{Y4>XJ1YLr18WD5#usaxF=yi!i0=2 zO!6bmZ|=)zikvP%g8XuPUiZ`Vs7ceS(-1XROi)AdqXqoWd@dKkVZD<3+p+RVdz=gj-Gv9 zRAaani?`1d7p&*hy|bX3<&}D+Sgx*VMS~)e(_(dpAr&j^Y5Q8r(9GSGYFBl0Hxq9U zKckzvon`3%M`=DE-yn5Veb?0NdX=EWm=ltAs#Ya$+MIR1JwQOUwbILF?Uh58UWvhN zTTZPIi<45`nUc}uKmo!VYndTu)+;k@2FUU^QLTElR9@1#7J-Y$8s|bN=;v!Opdf=8 zhVXx%RzVcA3a%ropbsGhVMMrlLqRu!3VQg_iy%YCmB5@FO;a)~laPC3@fPB%#l3RL zCU#S;x-J-6t(Iv?yL_WRyHZ`KwXT^)+RshU)^^eIyXV538bFrVIhF|0O^{CjbVc~^ znnY0r6+fjI3{GMRID&U-$d^Sp2P^ZoB{04$&!f{L3a z7O|vbPRA`1XR*xYYd%>q$=o)OV860-3-PLlrC@@{DHXHd(ui9!JH4obP2MhGwed4y<#_nU!-(M84dihRebCoN? zJy_nlTevR}=^?wcbGvA-A2;8&OIs(ETlekK#xYzkZ?6^$0*2?ecieiXCLnA9eU4ge z7aW1}4?j&xd&-qZ0<-DNDbm%o=043CDtdmc)M@P1T3ha3og%vIQ$7&5mM%VWpStmTNwcFXe*7c-|IvgG+*ds$%oKk98evm+34yhGn@cUm-0P0Nse&}uepzs>yZQ%s3C zZMXV((|sao)9VljwwtnnlFpEN#!|K3Cqe-lIzO;Y!S6JdKDEj+UA5^nJFRN%j>po( zKY9q4SsV+q{4nP%+ygy@$^U;l7BbkhkVDDBdCXY2fX^6Sw2(m3!Z|h*Y*K6{*-WvS zMp7VpavRK_7OvKtKJhw}&J65U-g{K5wu$@oLH*b2?$OcWK-%$ze%zJn#s=&9X>>;` zSLp|HmVTF^l?2lT$P;7fiL~^@TY91{J+YUb7NE*FZwWZ5elsUSlQgfOK92D zuh4%!9ucKeV3bCUA&hZcA{4-7S~ZU={gG9Q1Sy_-1*4dIb4yuHP5gjlE;WBsO{l*> zPks+Ap+0}6h#x=vO-af;Qwqo(;&ONrBcvMZa)GY;DxK2c_Xz2j7h?1swI8PceAoH| zQ{-8dV3wNyM1Ks*F$DwH@kKxNFUbt}?hmMyct}xS!hC_SM3$;a6p<(zG$b05D5k}F zhr<%abwwVINOZ=~B^s4zET#n|9FOU*X^PTC*r}*pM4U>niy^0?busKz^e#r6iqXZW wQ;AV%+<5_UqVx>$25B4xzxD`SXcRXvgbl>7P3!N&B*}XEe~GUsH-H=e0K9lLV*mgE 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 2a137da1ee2cd5556ac5df173b322fa0eabe7c2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1639 zcma)6T~iZh6n@_9W_J@72*iMiL@Yv^4{It^tAdmef{o2bhXrP0FEUFA%xbc6!p2|F zAJNNBZ+g=U8{6vW$avlHfA|-AWqZzRMibi^lgXTi=e+0pobcD1XQu#GPzgZA%^+5> zrejgZtsu@~oyFJuvJoVaH4tUoWKGV%ImRsmbBuWdamH-}=NWGsm}mUPzy-#FjynP~ zcUNlPWp}cr{BC}yw!K%*)wc4vqQGLY-fm?|PQBAUX&-r+yDRjqJ+M1=tKl^|wfl~H zxGE4H^53fLZ5Hz%YOQK%vqB+5L$-zT?uV+ZMXISGE32|Yy2y}jC%apyl(Q7ka9nTS zZgv|2q9C9z?q`d8c}rmF`_anR9p1T5YI4Ma)*RRI)&*w&Cq|)=+!qK~&arEI-45kc6H=ug zb=s|h>v1225i^Zjo?X9RvLDFu>Ba>7URwrH5=ok-u~u*Piy;LizBbTR-tD&5MrmoC zjwEQcyPbMt+uCl8Go{ zCeE>#V-aU@p2a+i3y29!yx$P_Le1BkZI|jhlSmHqSvk1ZsC(4I)xmw_n)b=b>VVn1 zB@ag>znMY5z8URo;|l!*&(beFuo2~Q0Ya)+A{8x>>Xt~QOQh;0QUl~U&0Pbb7*CG4 zh5(NMbOgi}2>BE2LHr5dODKJr7vYoIu`txsQ}|y({jY6JM`F3(4y+29~AM+Kd;G1S>}>_vWIDzJcck$jpwpNtG+_7l=uw- zI+lfq{7vDf=zr;#{e*Eso{B$3!GEPc2FEcE16OgaZ~97B2K@LOYIQoGgtR9JKE{}& zrm9LdF4=_t?c1beAx)8QQ<6>VhGb#M&KSC65y@sknqSh{kp6Rkeq4tLpDz z(yD4bOj%XEhp<&OdWcxn5UFOZ#}Mx)y+Cz?W;_W#^l{qI1a1(!jS%*z{X+z4WN+vH L6|R%54>$e=sRB{1 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 3a4c6b2199ef6426ecf5341a27bb0198987188cf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1770 zcmah}%W@i55Iw^T%rFcv=wTTwgp6dHhb>|$&cn!xkc5)45hx6jjl7@`Mk;JHq+rk& zB%hFdDw}MwaBvd4l8Vb~e}uQmCuHTM?`0&DN-C(NK01B7Z};iG@cQj9F9EFJp%)T1 zRcs+I^Ar?ZX1Jpu&akLpfniC(BEww;R~UY-;3~ti zf@=&-1qp@~1xbc`GWG?i2P?IW{hC=SR|Lcgjm}ACr`70odYvOXbFf0cwO*%d*PgVj zM_B>W#J7#2QOVb~N;^5D=w$lIpDUMhRfh+O?-lPAOZU$rbn=w*gRw1i0-E&leL(nw+xQXght7gKFL!(UQ0NC#z$GtkH{6%}&4DXl}RI zTtc+1^XIh02BYCRd-XRo+{Xg}(f@sb8kSMj@IDSSq>$FIgbbs%G{i8k;W9IEW)_%P zWabJpSDCrSOoEvt<^=@a?S*L}@r`!Jq9&&j$q}8U!^h2rO+s#su41!Y@Aa}HVdty; z=dF}?VKmPPqjjy{q|e|SeFbRiVb(oBNCG&L296|yBProXVmOi>jwFdAsp3e&08Fsq z0D6SYmbeFAHYo^rk64_L{ip*7Kg0D3;!|R@T(Ta1rc(SeeKif^7vSPv-z22e3%FlF z`gekhZGi$=f$I=S8VO6KXP?89iv9%ohw~BvIt4CLsW5zq-~(bVd`RpgeC(8LkjG8_ z^b073^vgTqT6FeXMAFga+frEi5pv`kc*4@tFGb`=aSBEW*;L#qy8L_kXLKBKC|JWM!%$(4cLu!q6;gG= zE6UHIK7)@lP0|%k{hS8eLl)#r_k_eh_-Tmq30WWJPI5Y>c=+KoXBTvjo6{LiFY2<$ zX_(W9u1K6-;&fK`>cixyuKq@Ci39k|sx*M#thxsXnpMvLA+stEFlknm0jABWPOcdO z@`VY=d5OR~K-7E&;oZKLXiK2K05lq=pB`2KSp;zxIv&svkLkIc(y+h66uyQ^OBil+ K9XZN#VdHOV8(^&f 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 6623e4b8d5e9a1c36ea65d2d8d1116342276eec9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1270 zcma)5+fEZv6kVq??X=TrX$u8gsmMj`1u0PRLXn^ZO_Kt~!6x8CGcAP-v@@oilKAe2 z7+-wx0YQamBs}{g{(?{FK0|{=NodoY-F-QGt-bc?kCU%Q05ZsWAR;AW6t^XWC5*}N zBh8O-o|%y8m~^9y+YFD~aU;m>l!UtszO_s-x3p4JR~H{I=NSg`WwVxE)XR0VVQyII zwG4fWjn}o3SuJks#(I_^KoNE2d2Z?H*)_LrSOu-xtT3<~gEUfjlz*|HG7P=!prLDr zUu`gq#1oy=i}U6>A$8?-qq5Yjl`8cWtyHCmWH(ygV3>;Mx3nECUDb@uv})CLV>6rR zgvyL==+-Pl-vteFxkQ1%qw1T6W;N>sD8}uOv{5%}Im6-;HmeSVW;Tp$HK{MCdN z+{1l_flIcpAc_YH`Z28_gl+}B=;LloK^FoFf(S79|0>U!(rD$XX%K;)c%p5J<}+}GyVAYhi&m5<%uUei_S2t3oQrT)09hhNkq{>h1fqOu@?G%o z3BYiLydkpuBkzHIf#Vp$E_nq^F|u40XOfzKpdamWMB&Cw+-j9RvzYA 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 04e71cfb4443907d742e77c18c61c9117f42514b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14300 zcmb_i2Xq|Ak)0WWBq9NVS&^0{3sj<#Em@>xg9JbU0!Rp8kU-n=U@-tk*xgyp?m~cb z&N=7ovwcqIaJHOt&N;_(&N-)FRljEjAnu*--o3}inhITAT~%FO-HVU>{VnhCJnym~ zZuiy&6YardaJb!T50112M}uRn!S(Bd8`^`Z;CO3r*LINZwm!JK@2%S#SL4RjzPF}t z*HPbV*`LfrzSlh(SEGZ?%5;<-4yVhYv{vT#C)L?_P9;ZtuWcqOJ4#F6hz#zkM~(3? z4J${(auZ|v`bI`?3KzoN<*+)pd$N(n)ww+(7qv{xl>ZLSWQjzA?)mxA|5H+rit20i^uv>v? znT+p=2{bm~tQdDNtZ?>WiSnj`)_fU={cyG6)(cH4yP+~~>vRmP_T;sy*2?^mss^u? zMvZ7@GD+cYwFq;zSLP)&MnvYxR4M?*L==*NfbUx{dT(WZNVZ8dkW|9BYD9COC2D_~ zhD%0<>4%%Oa%9+P@bd8Sk>f=>M-yy=i-)T2X^V^t2feSsgb0>Wnx{(aSMfQ$6Nqr4up-cu~b8JTWtxV2rERDaB{K| z&3mX4Ztrq6#)b!-Dr~k61YaD80Z7)Ko10O(RM4nZW@Pw(@_~(pkweXD2^o!j*=9zn z9cwG|{k0k_qqWFqh^A5fL@s~IYRLxER6!@j)iU4PwwkO8u0wjHQXDbWP*|?xs|87L zvu5Q0+=J34salyom>3+E-KyolnL0d+(kFRasg>ghK7#c15+zxN>`G`nM05ry$YV{c z7;v&Vjrt|KBTSdZ;%d`I55x;5mYDcNR8b4ZlUpJvg1%80Bf#uEVAug*@G17sr78A} zBC>%l#n#jD!>B0swQr#+>w)yXg*2K8#Y`+g5iuR^*teimcxc~3Mp~3F-HKJ^s$4ZA zF6yTdBb-g9Mi#AKby=={Rm1_Rr#T~w)z5nV*-T~0MlF0+#38DnS#}GlXJ1V@8EvBM zt2vj^vajY`Hdekc3-Y8C;u9_yTx_JF#2hgm9@ZFxIvLMZ!O;qv5vQUwQ6e-dN&K&S9Z`BG?lNHfA&$%|aX-+t7)4?gVh;IW!g}dI}T@VLFNNwDX(AR|?=1 z_c&rVGjlLGv=F7U<>VG!47n(t(bZ_~BpRYz zr0HO#6*OWolTkTRkIR9QqzD+iq+3@Dxow3I^#CW1QU;>gP!m8R6XmDHV5Qbr0zm^g z)GU|vTW4tWOBUMaKxBIZTpUYDRTTq)Q=_!5rXUU=48*guQ5scCFv%$U6KwLR63I3~ zVT8@P*eQ&df=ozz2CoH!4SXps8QjtyxwoOSkG9y<@8qO{^xsKU%l8nsXyJCJ*kKWOm z4QqEgGhE%*ouSs3ASgmXFJWCy8?j+HuB{I8;iO*OMWNnG{EjW#f#0hle$TJblI+n3{I~=zZiAb!WI4aK| zuFL33H2E_i?+$HUf3u?AxBdYGPgx;Q;QHQ<70ijKl+0DpMIv?1TEQy}>@Ss~I^1g2 zW>_=52jUY^S^KH}G;S=}q8({}Qf^j|&|S0a0~nD`iAa9di~AiW!IR*~LM^Ng%R|M! zQ2X9i$Z}?hzjM8i>G91@TeC7QHwkp8DO}{p87*(Ihj*co-o#-@y-WlhKdE+cC@>_m zhIb9*5|+pX2{)kxtUz}2AXN+0?VQKCWfj(hdOa)`SZIV`L?J(IqwK*R2x~Puza6U4 zepx1o>wzHW`qMdhMSKVx2*NB;vK=JUdP8EPqw9@paNI!xblX^n=&=X|8EcCmrM*A4 zh3sHy{&_{^VDt3axQ>}16W3Wwb*_ydm*=ACG>l82Yw=y%NK~}FkvNB-IfZTxboD^? zElF5jT*2i+ufb-BakRnS0KtK%npEOys067kP8o)w-k!6{PA_;??*g*(#e*EFRcib4 zaiB$WQMyM&WmbyXm9($~A?V4F%V4Nb3X5_fFK|})YSdat8MA_Oq*jv+j_b3YGE4?3 zM?806+2JUyAPFQ)*8%8U!$Qbs<^}Oc0!%31jryh%}+mR&BsnAcQm_iK9S)^@w)@_3US%&Oy``@ZP?mf-!rDUY`RdGnFM}(7YpI;nBNJ&P zb93eBSeW85XKoCKeK;p>XzA1Uv~G01*l6QvTy2c$yQRJqK}SbeN3Z2dEne4HVH~Bi zuFaT3H3pI)`Is(^aE@=AMpu5K5~lN@RT|}Z+6@j@yX&94{C|a_uL&m$BJMTpugK=T z)J?o|wTX3eW;?W}IBqDGOR7BWIaU9vCU{g{DBUnqB;A8qgbYR5#XT$3*o;V|8owQ+K?^=+BFLm`;8`q6*Anbxr}XAIpl22V46y|C_R9F z+GBSs(uf@C?DTW2u35Z#>mn04DXF-4hFo1xj;*684SMA}RNNC%xa1Hn1p9wSlE<)) zs49>1hw*%Xz;@2W^#a;~*DJj&CQ>7C9~+7nqnTQQy@Ke>W{4{V1yWuMGAUeUC-k*r zV?GkJA$_=zmo%IT`jTBxgIGrL?Ao0Vxvq)VJKx*Bg5tV!1lT%Sc6cA2WaCW=~{upoOvVc5JCPmTje2k2E}e6V z%jT|3#xBmC8ICn$hh!+ik;PvsU&fe->UzVon-y5ON;9%I6UCl%jnKxNn4L&?De12_ z#^i}f=EaAzo2WB-gK^QqH1NX%!rg8JyanJ=lZ~~FCZ`@$4W^+qBg9~|tcT-l=|rxL zmY|VS|hCHtlFv&OdeuSg6#5?--{sCE^iplb3p zA^?X`yJGyZ*xAqzw>qM3eR%mAPm^i!XHB3JGt5bKnGQU@A3hOb*HX!$bWppo4r60u z9YV79WY|ji!|4*%jbNF?G1Wx`DIgIyj(hwiZ*o3HCJ`A5W5kYvf(+x=f~_{rQ2eq$ z|DhZh<47G1mTr8>F~Q5AkCTGDh!1 zQJ9uaNDaoXjVOxvIW?RXru@1)rOl>1^q@zK@Kb0*nMiQC9c4895dwaF0ae}?4m5Ek zj%G$PVh2pfF~06CC#Y8U2NZHaAsb1}3q(ffnl2|L{PlsGQhcBbL?P1C0Y<_SS(=g^ ztw4gLq)1UpaAYl(-HBzEb5#Cz<>aW!n=PJIVvax!`ZxS%4<=-%ShpMEa7-aN5~UC44Z(B4r_LTqyU0Ff?vmw5Q|KKz}Z z=l{S1%j?AdT|iF<^a0nN_a@JOt?<1K_9X7V23fTq3+D;k^j&O?V%UyD#DW2=7n$0Kx|nK8WKUO#C5)4<&pU;ll|ZLHJ0* zM-e`n@G*psC43y=;|ZTY_(Z}d5k8slDc)1n|4;LtuJ9Rz&m?>n<(^IW9Kz?4|2)Fy zll}t27n1%W@5QS3CEmX&d@1=aBYZjO|4#fB^v^3ve--JkCVUO^Q1_h4i;l{%yqHPWTSy^*gA0_x{td!!df!s|w<-4>!v7-tF6F+*dh~tbKOp`?!XJ4*Ry{u<|EHw?jCy{~`F}zF zFG>Fu@m~}EhVZu>|2xY4p7cL>f7E&YMEGa#FN*(_@_!@zJK;YJ;GRhR zwwPXjE#=mko&I{#TM64J-|ly)o=(!c2se=4P1r-Yk>h#^H(8wg&9r9=>01f6`P)_h z4qwkB|5U=$EKdIEglAChOxnGZ@HW(Q7VWw%>1Pu^hj!hL__>6Al-ou8JmTjQzkv9K zgcot1-Gmogp8J>hdXD**S)KPUxBckf-q-WYzk>Lcl)s~$EB;l4d;Gn+{yUL>HQ}9U z$6YvoKkcn`wRpH}&jKcg@rob~4vKS3D#Hz_`E z=e=JhULjs3o)E7QznOT-c-2X7(9Wj6pn7ld7Zsx8Rd_G1@7{#>;X3cjc;AnHx}lOd3lccZ=~Kg`M2u4 zZ>HQ^2;WNiw^7gAxgXv^`a3E2F5>Uzdfr3)y_A0+;rqF-KEQcDX#J@FA?o=s;YUdS zDDjUGew^b!LHJ2K7yVBW|1{_S4Drv}`R;#?^v~0OUm*M<4_+M3je2w_m z3BN)3O~P*xew*++ggpQJ?{Z&!kNe>J#D75ihxEgbXvdHJpXj_lCH$HHbH#r_y}#so zeno%$n(#N&^IQ7;cUad{0_oSvm@vtzJYi*VGrlqNZ8AHH`#d@Y!0@F zzk;oV+w7bVw%a)$?C`Ev{wcw!3Qx0pS#Y}5t>6rcPjDvJx0CbSCOAvwZ%h8!!8wZG zE;v_VALVvY-+7cfKhS$yaH07wContext.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 472674ff6ca10c7178e8a496e858220db480e6a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1062 zcmbV~ZBG+H5Xb*Z@1dS2PeLD5Y(dm(@5;rXz7Qj*i3v#`5+Ee|Jg)lSe4 z{B97o{oPRVHjlT|x(L;}{;4Or#|-H`-WTU03MrJ)zKliKW>~tmdzhuo)_&BBTl|Yq zO7SV3gX0(M@P}f8~2E8<3Fw9c4LY|S=%NJnZDWHo$*0@T} zk)6i^S@r8S-65TPA$5tFsxmcY>dL&+T(6SXE|GG-jUcl~QJkUk$&yZvFpGDDdDE~W z!Bz>jMzDu>gjJ?tWrDc`^9Z&yg6$-27H@4cuT9fl6YUMr-V%*&Bv~~yna~byrTv8V p^#Zy(fH8o%m?q;*#FdFSuMIy2xHnzFHtFtA1s_Q}OWHHY{RJ>#(3$`M 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; - } - } From c045214da2f25857134dcb203b343beb4c54d703 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 16:37:04 +0000 Subject: [PATCH 17/17] Managed API: Bugfixes and refactoring. Signed-off-by: Christoph M. Wintersteiger --- src/api/dotnet/Expr.cs | 2 ++ src/api/dotnet/Quantifier.cs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index 6c2ebb3ad..dade77eb1 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -1533,6 +1533,7 @@ namespace Microsoft.Z3 case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj); case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj); case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj); + case Z3_sort_kind.Z3_UNKNOWN_SORT: throw new Z3Exception("Unknown Sort"); } } @@ -1544,6 +1545,7 @@ namespace Microsoft.Z3 case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj); case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj); case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj); + case Z3_sort_kind.Z3_UNKNOWN_SORT: throw new Z3Exception("Unknown Sort"); } return new Expr(ctx, obj); diff --git a/src/api/dotnet/Quantifier.cs b/src/api/dotnet/Quantifier.cs index c6754e570..f59d0bda2 100644 --- a/src/api/dotnet/Quantifier.cs +++ b/src/api/dotnet/Quantifier.cs @@ -181,8 +181,6 @@ namespace Microsoft.Z3 if (sorts.Length != names.Length) throw new Z3Exception("Number of sorts does not match number of names"); - IntPtr[] _patterns = AST.ArrayToNative(patterns); - if (noPatterns == null && quantifierID == null && skolemID == null) { NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight,