From eb812f0fad3de3baa4e1be34f6b5c6d96afb4500 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 23 Nov 2012 19:24:56 +0000 Subject: [PATCH 001/133] 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 e217264fb4dd7914f4b787a5e625d897ac7d8415 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 23 Nov 2012 13:34:15 -0800 Subject: [PATCH 002/133] improving mk_make Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index b69171a24..bf28d06bd 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -484,6 +484,32 @@ def is_verbose(): def is_java_enabled(): return JAVA_ENABLED +def is_compiler(given, expected): + """ + Return True if the 'given' compiler is the expected one. + >>> is_compiler('g++', 'g++') + True + >>> is_compiler('/home/g++', 'g++') + True + >>> is_compiler(os.path.join('home', 'g++'), 'g++') + True + >>> is_compiler('clang++', 'g++') + False + >>> is_compiler(os.path.join('home', 'clang++'), 'clang++') + True + """ + if given == expected: + return True + if len(expected) < len(given): + return given[len(given) - len(expected) - 1] == os.sep and given[len(given) - len(expected):] == expected + return False + +def is_CXX_gpp(): + return is_compiler(CXX, 'g++') + +def is_CXX_clangpp(): + return is_compiler(CXX, 'clang++') + def get_cpp_files(path): return filter(lambda f: f.endswith('.cpp'), os.listdir(path)) @@ -1179,7 +1205,7 @@ def mk_config(): else: CPPFLAGS = '%s -D_MP_INTERNAL' % CPPFLAGS CXXFLAGS = '%s -c' % CXXFLAGS - if CXX == 'g++': + if is_CXX_gpp(): CXXFLAGS = '%s -fopenmp -mfpmath=sse' % CXXFLAGS LDFLAGS = '%s -fopenmp' % LDFLAGS SLIBEXTRAFLAGS = '-fopenmp' @@ -1193,7 +1219,7 @@ def mk_config(): SLIBFLAGS = '-dynamiclib' elif sysname == 'Linux': CXXFLAGS = '%s -fno-strict-aliasing -D_LINUX_' % CXXFLAGS - if CXX == 'clang++': + if is_CXX_clangpp(): CXXFLAGS = '%s -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value' % CXXFLAGS SO_EXT = '.so' LDFLAGS = '%s -lrt' % LDFLAGS @@ -1965,3 +1991,8 @@ def mk_win_dist(build_path, dist_path): for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(build_path)): shutil.copy('%s/%s' % (build_path, pyc), '%s/bin/%s' % (dist_path, pyc)) + + +if __name__ == '__main__': + import doctest + doctest.testmod() From 93ad91d2f97f8c2077cb1fb2b2cfa15b5a57b005 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 25 Nov 2012 12:08:49 -0800 Subject: [PATCH 003/133] 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 004/133] 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 005/133] 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 006/133] 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 007/133] 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 008/133] 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 009/133] 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 010/133] 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 011/133] 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 012/133] 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 013/133] 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 014/133] 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 015/133] 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 016/133] 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 017/133] 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 018/133] 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, From c00f20832a0de6ef68b58693284fefe331dc327e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 27 Nov 2012 09:23:44 -0800 Subject: [PATCH 019/133] fixed tab Signed-off-by: Leonardo de Moura --- src/api/python/z3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 84724e51e..94031cce6 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -632,7 +632,7 @@ class FuncDeclRef(AstRef): >>> f(x, x) f(x, ToReal(x)) """ - args = _get_args(args) + args = _get_args(args) num = len(args) if __debug__: _z3_assert(num == self.arity(), "Incorrect number of arguments to %s" % self) From 11ffbab0bd45db31f93f020c8bd9f1a407a17bea Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 18:47:30 +0000 Subject: [PATCH 020/133] Java API: Removed auto-generated files. Signed-off-by: Christoph M. Wintersteiger --- src/api/java/Enumerations/Z3_ast_kind.java | 33 - .../java/Enumerations/Z3_ast_print_mode.java | 30 - src/api/java/Enumerations/Z3_decl_kind.java | 178 -- src/api/java/Enumerations/Z3_error_code.java | 39 - src/api/java/Enumerations/Z3_goal_prec.java | 30 - src/api/java/Enumerations/Z3_lbool.java | 29 - src/api/java/Enumerations/Z3_param_kind.java | 33 - .../java/Enumerations/Z3_parameter_kind.java | 33 - src/api/java/Enumerations/Z3_sort_kind.java | 36 - src/api/java/Enumerations/Z3_symbol_kind.java | 28 - src/api/java/Native.cpp | 2259 ----------------- 11 files changed, 2728 deletions(-) delete mode 100644 src/api/java/Enumerations/Z3_ast_kind.java delete mode 100644 src/api/java/Enumerations/Z3_ast_print_mode.java delete mode 100644 src/api/java/Enumerations/Z3_decl_kind.java delete mode 100644 src/api/java/Enumerations/Z3_error_code.java delete mode 100644 src/api/java/Enumerations/Z3_goal_prec.java delete mode 100644 src/api/java/Enumerations/Z3_lbool.java delete mode 100644 src/api/java/Enumerations/Z3_param_kind.java delete mode 100644 src/api/java/Enumerations/Z3_parameter_kind.java delete mode 100644 src/api/java/Enumerations/Z3_sort_kind.java delete mode 100644 src/api/java/Enumerations/Z3_symbol_kind.java delete mode 100644 src/api/java/Native.cpp diff --git a/src/api/java/Enumerations/Z3_ast_kind.java b/src/api/java/Enumerations/Z3_ast_kind.java deleted file mode 100644 index 931d70f62..000000000 --- a/src/api/java/Enumerations/Z3_ast_kind.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_ast_kind - **/ -public enum Z3_ast_kind { - Z3_VAR_AST (2), - Z3_SORT_AST (4), - Z3_QUANTIFIER_AST (3), - Z3_UNKNOWN_AST (1000), - Z3_FUNC_DECL_AST (5), - Z3_NUMERAL_AST (0), - Z3_APP_AST (1); - - private final int intValue; - - Z3_ast_kind(int v) { - this.intValue = v; - } - - public static final Z3_ast_kind fromInt(int v) { - for (Z3_ast_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_ast_print_mode.java b/src/api/java/Enumerations/Z3_ast_print_mode.java deleted file mode 100644 index 37da961d7..000000000 --- a/src/api/java/Enumerations/Z3_ast_print_mode.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_ast_print_mode - **/ -public enum Z3_ast_print_mode { - Z3_PRINT_SMTLIB2_COMPLIANT (3), - Z3_PRINT_SMTLIB_COMPLIANT (2), - Z3_PRINT_SMTLIB_FULL (0), - Z3_PRINT_LOW_LEVEL (1); - - private final int intValue; - - Z3_ast_print_mode(int v) { - this.intValue = v; - } - - public static final Z3_ast_print_mode fromInt(int v) { - for (Z3_ast_print_mode k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_decl_kind.java b/src/api/java/Enumerations/Z3_decl_kind.java deleted file mode 100644 index dd701c1e1..000000000 --- a/src/api/java/Enumerations/Z3_decl_kind.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_decl_kind - **/ -public enum Z3_decl_kind { - Z3_OP_LABEL (1792), - Z3_OP_PR_REWRITE (1294), - Z3_OP_UNINTERPRETED (2051), - Z3_OP_SUB (519), - Z3_OP_ZERO_EXT (1058), - Z3_OP_ADD (518), - Z3_OP_IS_INT (528), - Z3_OP_BREDOR (1061), - Z3_OP_BNOT (1051), - Z3_OP_BNOR (1054), - Z3_OP_PR_CNF_STAR (1315), - Z3_OP_RA_JOIN (1539), - Z3_OP_LE (514), - Z3_OP_SET_UNION (773), - Z3_OP_PR_UNDEF (1280), - Z3_OP_BREDAND (1062), - Z3_OP_LT (516), - Z3_OP_RA_UNION (1540), - Z3_OP_BADD (1028), - Z3_OP_BUREM0 (1039), - Z3_OP_OEQ (267), - Z3_OP_PR_MODUS_PONENS (1284), - Z3_OP_RA_CLONE (1548), - Z3_OP_REPEAT (1060), - Z3_OP_RA_NEGATION_FILTER (1544), - Z3_OP_BSMOD0 (1040), - Z3_OP_BLSHR (1065), - Z3_OP_BASHR (1066), - Z3_OP_PR_UNIT_RESOLUTION (1304), - Z3_OP_ROTATE_RIGHT (1068), - Z3_OP_ARRAY_DEFAULT (772), - Z3_OP_PR_PULL_QUANT (1296), - Z3_OP_PR_APPLY_DEF (1310), - Z3_OP_PR_REWRITE_STAR (1295), - Z3_OP_IDIV (523), - Z3_OP_PR_GOAL (1283), - Z3_OP_PR_IFF_TRUE (1305), - Z3_OP_LABEL_LIT (1793), - Z3_OP_BOR (1050), - Z3_OP_PR_SYMMETRY (1286), - Z3_OP_TRUE (256), - Z3_OP_SET_COMPLEMENT (776), - Z3_OP_CONCAT (1056), - Z3_OP_PR_NOT_OR_ELIM (1293), - Z3_OP_IFF (263), - Z3_OP_BSHL (1064), - Z3_OP_PR_TRANSITIVITY (1287), - Z3_OP_SGT (1048), - Z3_OP_RA_WIDEN (1541), - Z3_OP_PR_DEF_INTRO (1309), - Z3_OP_NOT (265), - Z3_OP_PR_QUANT_INTRO (1290), - Z3_OP_UGT (1047), - Z3_OP_DT_RECOGNISER (2049), - Z3_OP_SET_INTERSECT (774), - Z3_OP_BSREM (1033), - Z3_OP_RA_STORE (1536), - Z3_OP_SLT (1046), - Z3_OP_ROTATE_LEFT (1067), - Z3_OP_PR_NNF_NEG (1313), - Z3_OP_PR_REFLEXIVITY (1285), - Z3_OP_ULEQ (1041), - Z3_OP_BIT1 (1025), - Z3_OP_BIT0 (1026), - Z3_OP_EQ (258), - Z3_OP_BMUL (1030), - Z3_OP_ARRAY_MAP (771), - Z3_OP_STORE (768), - Z3_OP_PR_HYPOTHESIS (1302), - Z3_OP_RA_RENAME (1545), - Z3_OP_AND (261), - Z3_OP_TO_REAL (526), - Z3_OP_PR_NNF_POS (1312), - Z3_OP_PR_AND_ELIM (1292), - Z3_OP_MOD (525), - Z3_OP_BUDIV0 (1037), - Z3_OP_PR_TRUE (1281), - Z3_OP_BNAND (1053), - Z3_OP_PR_ELIM_UNUSED_VARS (1299), - Z3_OP_RA_FILTER (1543), - Z3_OP_FD_LT (1549), - Z3_OP_RA_EMPTY (1537), - Z3_OP_DIV (522), - Z3_OP_ANUM (512), - Z3_OP_MUL (521), - Z3_OP_UGEQ (1043), - Z3_OP_BSREM0 (1038), - Z3_OP_PR_TH_LEMMA (1318), - Z3_OP_BXOR (1052), - Z3_OP_DISTINCT (259), - Z3_OP_PR_IFF_FALSE (1306), - Z3_OP_BV2INT (1072), - Z3_OP_EXT_ROTATE_LEFT (1069), - Z3_OP_PR_PULL_QUANT_STAR (1297), - Z3_OP_BSUB (1029), - Z3_OP_PR_ASSERTED (1282), - Z3_OP_BXNOR (1055), - Z3_OP_EXTRACT (1059), - Z3_OP_PR_DER (1300), - Z3_OP_DT_CONSTRUCTOR (2048), - Z3_OP_GT (517), - Z3_OP_BUREM (1034), - Z3_OP_IMPLIES (266), - Z3_OP_SLEQ (1042), - Z3_OP_GE (515), - Z3_OP_BAND (1049), - Z3_OP_ITE (260), - Z3_OP_AS_ARRAY (778), - Z3_OP_RA_SELECT (1547), - Z3_OP_CONST_ARRAY (770), - Z3_OP_BSDIV (1031), - Z3_OP_OR (262), - Z3_OP_PR_HYPER_RESOLVE (1319), - Z3_OP_AGNUM (513), - Z3_OP_PR_PUSH_QUANT (1298), - Z3_OP_BSMOD (1035), - Z3_OP_PR_IFF_OEQ (1311), - Z3_OP_PR_LEMMA (1303), - Z3_OP_SET_SUBSET (777), - Z3_OP_SELECT (769), - Z3_OP_RA_PROJECT (1542), - Z3_OP_BNEG (1027), - Z3_OP_UMINUS (520), - Z3_OP_REM (524), - Z3_OP_TO_INT (527), - Z3_OP_PR_QUANT_INST (1301), - Z3_OP_SGEQ (1044), - Z3_OP_POWER (529), - Z3_OP_XOR3 (1074), - Z3_OP_RA_IS_EMPTY (1538), - Z3_OP_CARRY (1073), - Z3_OP_DT_ACCESSOR (2050), - Z3_OP_PR_TRANSITIVITY_STAR (1288), - Z3_OP_PR_NNF_STAR (1314), - Z3_OP_PR_COMMUTATIVITY (1307), - Z3_OP_ULT (1045), - Z3_OP_BSDIV0 (1036), - Z3_OP_SET_DIFFERENCE (775), - Z3_OP_INT2BV (1071), - Z3_OP_XOR (264), - Z3_OP_PR_MODUS_PONENS_OEQ (1317), - Z3_OP_BNUM (1024), - Z3_OP_BUDIV (1032), - Z3_OP_PR_MONOTONICITY (1289), - Z3_OP_PR_DEF_AXIOM (1308), - Z3_OP_FALSE (257), - Z3_OP_EXT_ROTATE_RIGHT (1070), - Z3_OP_PR_DISTRIBUTIVITY (1291), - Z3_OP_SIGN_EXT (1057), - Z3_OP_PR_SKOLEMIZE (1316), - Z3_OP_BCOMP (1063), - Z3_OP_RA_COMPLEMENT (1546); - - private final int intValue; - - Z3_decl_kind(int v) { - this.intValue = v; - } - - public static final Z3_decl_kind fromInt(int v) { - for (Z3_decl_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_error_code.java b/src/api/java/Enumerations/Z3_error_code.java deleted file mode 100644 index 2672c9325..000000000 --- a/src/api/java/Enumerations/Z3_error_code.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_error_code - **/ -public enum Z3_error_code { - Z3_INVALID_PATTERN (6), - Z3_MEMOUT_FAIL (7), - Z3_NO_PARSER (5), - Z3_OK (0), - Z3_INVALID_ARG (3), - Z3_EXCEPTION (12), - Z3_IOB (2), - Z3_INTERNAL_FATAL (9), - Z3_INVALID_USAGE (10), - Z3_FILE_ACCESS_ERROR (8), - Z3_SORT_ERROR (1), - Z3_PARSER_ERROR (4), - Z3_DEC_REF_ERROR (11); - - private final int intValue; - - Z3_error_code(int v) { - this.intValue = v; - } - - public static final Z3_error_code fromInt(int v) { - for (Z3_error_code k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_goal_prec.java b/src/api/java/Enumerations/Z3_goal_prec.java deleted file mode 100644 index f16fe51ec..000000000 --- a/src/api/java/Enumerations/Z3_goal_prec.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_goal_prec - **/ -public enum Z3_goal_prec { - Z3_GOAL_UNDER (1), - Z3_GOAL_PRECISE (0), - Z3_GOAL_UNDER_OVER (3), - Z3_GOAL_OVER (2); - - private final int intValue; - - Z3_goal_prec(int v) { - this.intValue = v; - } - - public static final Z3_goal_prec fromInt(int v) { - for (Z3_goal_prec k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_lbool.java b/src/api/java/Enumerations/Z3_lbool.java deleted file mode 100644 index 55d5d7e17..000000000 --- a/src/api/java/Enumerations/Z3_lbool.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_lbool - **/ -public enum Z3_lbool { - Z3_L_TRUE (1), - Z3_L_UNDEF (0), - Z3_L_FALSE (-1); - - private final int intValue; - - Z3_lbool(int v) { - this.intValue = v; - } - - public static final Z3_lbool fromInt(int v) { - for (Z3_lbool k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_param_kind.java b/src/api/java/Enumerations/Z3_param_kind.java deleted file mode 100644 index 086622e95..000000000 --- a/src/api/java/Enumerations/Z3_param_kind.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_param_kind - **/ -public enum Z3_param_kind { - Z3_PK_BOOL (1), - Z3_PK_SYMBOL (3), - Z3_PK_OTHER (5), - Z3_PK_INVALID (6), - Z3_PK_UINT (0), - Z3_PK_STRING (4), - Z3_PK_DOUBLE (2); - - private final int intValue; - - Z3_param_kind(int v) { - this.intValue = v; - } - - public static final Z3_param_kind fromInt(int v) { - for (Z3_param_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_parameter_kind.java b/src/api/java/Enumerations/Z3_parameter_kind.java deleted file mode 100644 index 021157183..000000000 --- a/src/api/java/Enumerations/Z3_parameter_kind.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_parameter_kind - **/ -public enum Z3_parameter_kind { - Z3_PARAMETER_FUNC_DECL (6), - Z3_PARAMETER_DOUBLE (1), - Z3_PARAMETER_SYMBOL (3), - Z3_PARAMETER_INT (0), - Z3_PARAMETER_AST (5), - Z3_PARAMETER_SORT (4), - Z3_PARAMETER_RATIONAL (2); - - private final int intValue; - - Z3_parameter_kind(int v) { - this.intValue = v; - } - - public static final Z3_parameter_kind fromInt(int v) { - for (Z3_parameter_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_sort_kind.java b/src/api/java/Enumerations/Z3_sort_kind.java deleted file mode 100644 index 91559a58a..000000000 --- a/src/api/java/Enumerations/Z3_sort_kind.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_sort_kind - **/ -public enum Z3_sort_kind { - Z3_BV_SORT (4), - Z3_FINITE_DOMAIN_SORT (8), - Z3_ARRAY_SORT (5), - Z3_UNKNOWN_SORT (1000), - Z3_RELATION_SORT (7), - Z3_REAL_SORT (3), - Z3_INT_SORT (2), - Z3_UNINTERPRETED_SORT (0), - Z3_BOOL_SORT (1), - Z3_DATATYPE_SORT (6); - - private final int intValue; - - Z3_sort_kind(int v) { - this.intValue = v; - } - - public static final Z3_sort_kind fromInt(int v) { - for (Z3_sort_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Enumerations/Z3_symbol_kind.java b/src/api/java/Enumerations/Z3_symbol_kind.java deleted file mode 100644 index 0866dc786..000000000 --- a/src/api/java/Enumerations/Z3_symbol_kind.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Automatically generated file - **/ - -package com.Microsoft.Z3.Enumerations; - -/** - * Z3_symbol_kind - **/ -public enum Z3_symbol_kind { - Z3_INT_SYMBOL (0), - Z3_STRING_SYMBOL (1); - - private final int intValue; - - Z3_symbol_kind(int v) { - this.intValue = v; - } - - public static final Z3_symbol_kind fromInt(int v) { - for (Z3_symbol_kind k: values()) - if (k.intValue == v) return k; - return values()[0]; - } - - public final int toInt() { return this.intValue; } -} - diff --git a/src/api/java/Native.cpp b/src/api/java/Native.cpp deleted file mode 100644 index 653e32bc5..000000000 --- a/src/api/java/Native.cpp +++ /dev/null @@ -1,2259 +0,0 @@ -// Automatically generated file -#include -#include -#include"z3.h" -#ifdef __cplusplus -extern "C" { -#endif -JNIEXPORT jlong JNICALL Java_Z3Native_mkConfig(JNIEnv * jenv, jclass cls) { - Z3_config result = Z3_mk_config(); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delConfig(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_del_config((Z3_config)a0); -} -JNIEXPORT void JNICALL Java_Z3Native_setParamValue(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jstring a2) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string _a2 = (Z3_string) jenv->GetStringUTFChars(a2, NULL); - Z3_set_param_value((Z3_config)a0, _a1, _a2); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkContext(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_context result = Z3_mk_context((Z3_config)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkContextRc(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_context result = Z3_mk_context_rc((Z3_config)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delContext(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_del_context((Z3_context)a0); -} -JNIEXPORT void JNICALL Java_Z3Native_incRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_inc_ref((Z3_context)a0, (Z3_ast)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_decRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_dec_ref((Z3_context)a0, (Z3_ast)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_updateParamValue(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jstring a2) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string _a2 = (Z3_string) jenv->GetStringUTFChars(a2, NULL); - Z3_update_param_value((Z3_context)a0, _a1, _a2); -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getParamValue(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jobject a2) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string _a2; - Z3_bool result = Z3_get_param_value((Z3_context)a0, _a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - return (jboolean) result; -} -JNIEXPORT void JNICALL Java_Z3Native_interrupt(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_interrupt((Z3_context)a0); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkParams(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_params result = Z3_mk_params((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_paramsIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_params_inc_ref((Z3_context)a0, (Z3_params)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_params_dec_ref((Z3_context)a0, (Z3_params)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsSetBool(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jboolean a3) { - Z3_params_set_bool((Z3_context)a0, (Z3_params)a1, (Z3_symbol)a2, (Z3_bool)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsSetUint(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3) { - Z3_params_set_uint((Z3_context)a0, (Z3_params)a1, (Z3_symbol)a2, (unsigned)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsSetDouble(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jdouble a3) { - Z3_params_set_double((Z3_context)a0, (Z3_params)a1, (Z3_symbol)a2, (double)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsSetSymbol(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_params_set_symbol((Z3_context)a0, (Z3_params)a1, (Z3_symbol)a2, (Z3_symbol)a3); -} -JNIEXPORT jstring JNICALL Java_Z3Native_paramsToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_params_to_string((Z3_context)a0, (Z3_params)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT void JNICALL Java_Z3Native_paramsValidate(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_params_validate((Z3_context)a0, (Z3_params)a1, (Z3_param_descrs)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_paramDescrsIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_param_descrs_inc_ref((Z3_context)a0, (Z3_param_descrs)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_paramDescrsDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_param_descrs_dec_ref((Z3_context)a0, (Z3_param_descrs)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_paramDescrsGetKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - unsigned result = Z3_param_descrs_get_kind((Z3_context)a0, (Z3_param_descrs)a1, (Z3_symbol)a2); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_paramDescrsSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_param_descrs_size((Z3_context)a0, (Z3_param_descrs)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_paramDescrsGetName(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_symbol result = Z3_param_descrs_get_name((Z3_context)a0, (Z3_param_descrs)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_paramDescrsToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_param_descrs_to_string((Z3_context)a0, (Z3_param_descrs)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkIntSymbol(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_symbol result = Z3_mk_int_symbol((Z3_context)a0, (int)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkStringSymbol(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_symbol result = Z3_mk_string_symbol((Z3_context)a0, _a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkUninterpretedSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_mk_uninterpreted_sort((Z3_context)a0, (Z3_symbol)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBoolSort(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_sort result = Z3_mk_bool_sort((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkIntSort(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_sort result = Z3_mk_int_sort((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkRealSort(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_sort result = Z3_mk_real_sort((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvSort(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_sort result = Z3_mk_bv_sort((Z3_context)a0, (unsigned)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFiniteDomainSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_sort result = Z3_mk_finite_domain_sort((Z3_context)a0, (Z3_symbol)a1, (__uint64)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkArraySort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_sort result = Z3_mk_array_sort((Z3_context)a0, (Z3_sort)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkTupleSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3, jlongArray a4, jobject a5, jlongArray a6) { - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a4 = (Z3_sort *) jenv->GetLongArrayElements(a4, NULL); - Z3_func_decl _a5; - Z3_func_decl * _a6 = (Z3_func_decl *) malloc(((unsigned)a2) * sizeof(Z3_func_decl)); - Z3_sort result = Z3_mk_tuple_sort((Z3_context)a0, (Z3_symbol)a1, (unsigned)a2, _a3, _a4, &_a5, _a6); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - { - jclass mc = jenv->GetObjectClass(a5); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a5, fid, (jlong) _a5); - } - jenv->SetLongArrayRegion(a6, 0, (jsize)a2, (jlong *) _a6); - free(_a6); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkEnumerationSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3, jlongArray a4, jlongArray a5) { - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_func_decl * _a4 = (Z3_func_decl *) malloc(((unsigned)a2) * sizeof(Z3_func_decl)); - Z3_func_decl * _a5 = (Z3_func_decl *) malloc(((unsigned)a2) * sizeof(Z3_func_decl)); - Z3_sort result = Z3_mk_enumeration_sort((Z3_context)a0, (Z3_symbol)a1, (unsigned)a2, _a3, _a4, _a5); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->SetLongArrayRegion(a4, 0, (jsize)a2, (jlong *) _a4); - free(_a4); - jenv->SetLongArrayRegion(a5, 0, (jsize)a2, (jlong *) _a5); - free(_a5); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkListSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jobject a3, jobject a4, jobject a5, jobject a6, jobject a7, jobject a8) { - Z3_func_decl _a3; - Z3_func_decl _a4; - Z3_func_decl _a5; - Z3_func_decl _a6; - Z3_func_decl _a7; - Z3_func_decl _a8; - Z3_sort result = Z3_mk_list_sort((Z3_context)a0, (Z3_symbol)a1, (Z3_sort)a2, &_a3, &_a4, &_a5, &_a6, &_a7, &_a8); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - { - jclass mc = jenv->GetObjectClass(a4); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a4, fid, (jlong) _a4); - } - { - jclass mc = jenv->GetObjectClass(a5); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a5, fid, (jlong) _a5); - } - { - jclass mc = jenv->GetObjectClass(a6); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a6, fid, (jlong) _a6); - } - { - jclass mc = jenv->GetObjectClass(a7); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a7, fid, (jlong) _a7); - } - { - jclass mc = jenv->GetObjectClass(a8); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a8, fid, (jlong) _a8); - } - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkConstructor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3, jlongArray a4, jlongArray a5, jintArray a6) { - Z3_symbol * _a4 = (Z3_symbol *) jenv->GetLongArrayElements(a4, NULL); - Z3_sort * _a5 = (Z3_sort *) jenv->GetLongArrayElements(a5, NULL); - unsigned * _a6 = (unsigned *) jenv->GetIntArrayElements(a6, NULL); - Z3_constructor result = Z3_mk_constructor((Z3_context)a0, (Z3_symbol)a1, (Z3_symbol)a2, (unsigned)a3, _a4, _a5, _a6); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a5, (jlong *) _a5, JNI_ABORT); - jenv->ReleaseIntArrayElements(a6, (jint *) _a6, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delConstructor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_del_constructor((Z3_context)a0, (Z3_constructor)a1); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkDatatype(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_constructor * _a3 = (Z3_constructor *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort result = Z3_mk_datatype((Z3_context)a0, (Z3_symbol)a1, (unsigned)a2, _a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkConstructorList(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_constructor * _a2 = (Z3_constructor *) jenv->GetLongArrayElements(a2, NULL); - Z3_constructor_list result = Z3_mk_constructor_list((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delConstructorList(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_del_constructor_list((Z3_context)a0, (Z3_constructor_list)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_mkDatatypes(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2, jlongArray a3, jlongArray a4) { - Z3_symbol * _a2 = (Z3_symbol *) jenv->GetLongArrayElements(a2, NULL); - Z3_sort * _a3 = (Z3_sort *) malloc(((unsigned)a1) * sizeof(Z3_sort)); - Z3_constructor_list * _a4 = (Z3_constructor_list *) jenv->GetLongArrayElements(a4, NULL); - Z3_mk_datatypes((Z3_context)a0, (unsigned)a1, _a2, _a3, _a4); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - jenv->SetLongArrayRegion(a3, 0, (jsize)a1, (jlong *) _a3); - free(_a3); -} -JNIEXPORT void JNICALL Java_Z3Native_queryConstructor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jobject a3, jobject a4, jlongArray a5) { - Z3_func_decl _a3; - Z3_func_decl _a4; - Z3_func_decl * _a5 = (Z3_func_decl *) malloc(((unsigned)a2) * sizeof(Z3_func_decl)); - Z3_query_constructor((Z3_context)a0, (Z3_constructor)a1, (unsigned)a2, &_a3, &_a4, _a5); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - { - jclass mc = jenv->GetObjectClass(a4); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a4, fid, (jlong) _a4); - } - jenv->SetLongArrayRegion(a5, 0, (jsize)a2, (jlong *) _a5); - free(_a5); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3, jlong a4) { - Z3_sort * _a3 = (Z3_sort *) jenv->GetLongArrayElements(a3, NULL); - Z3_func_decl result = Z3_mk_func_decl((Z3_context)a0, (Z3_symbol)a1, (unsigned)a2, _a3, (Z3_sort)a4); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkApp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_ast result = Z3_mk_app((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkConst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_const((Z3_context)a0, (Z3_symbol)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFreshFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jint a2, jlongArray a3, jlong a4) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_sort * _a3 = (Z3_sort *) jenv->GetLongArrayElements(a3, NULL); - Z3_func_decl result = Z3_mk_fresh_func_decl((Z3_context)a0, _a1, (unsigned)a2, _a3, (Z3_sort)a4); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFreshConst(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jlong a2) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_ast result = Z3_mk_fresh_const((Z3_context)a0, _a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkTrue(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_ast result = Z3_mk_true((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFalse(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_ast result = Z3_mk_false((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkEq(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_eq((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkDistinct(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_distinct((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkNot(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_not((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkIte(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_ast result = Z3_mk_ite((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2, (Z3_ast)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkIff(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_iff((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkImplies(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_implies((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkXor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_xor((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkAnd(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_and((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkOr(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_or((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkAdd(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_add((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkMul(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_mul((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSub(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_sub((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkUnaryMinus(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_unary_minus((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkDiv(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_div((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkMod(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_mod((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkRem(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_rem((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkPower(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_power((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkLt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_lt((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkLe(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_le((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkGt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_gt((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkGe(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_ge((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkInt2real(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_int2real((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkReal2int(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_real2int((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkIsInt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_is_int((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvnot(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_bvnot((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvredand(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_bvredand((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvredor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_bvredor((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvand(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvand((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvor((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvxor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvxor((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvnand(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvnand((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvnor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvnor((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvxnor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvxnor((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvneg(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_bvneg((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvadd(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvadd((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsub(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsub((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvmul(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvmul((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvudiv(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvudiv((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsdiv(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsdiv((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvurem(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvurem((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsrem(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsrem((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsmod(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsmod((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvult(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvult((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvslt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvslt((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvule(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvule((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsle(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsle((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvuge(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvuge((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsge(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsge((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvugt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvugt((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsgt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsgt((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkConcat(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_concat((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkExtract(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2, jlong a3) { - Z3_ast result = Z3_mk_extract((Z3_context)a0, (unsigned)a1, (unsigned)a2, (Z3_ast)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSignExt(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_sign_ext((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkZeroExt(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_zero_ext((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkRepeat(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_repeat((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvshl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvshl((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvlshr(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvlshr((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvashr(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvashr((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkRotateLeft(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_rotate_left((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkRotateRight(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_rotate_right((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkExtRotateLeft(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_ext_rotate_left((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkExtRotateRight(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_ext_rotate_right((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkInt2bv(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_int2bv((Z3_context)a0, (unsigned)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBv2int(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jboolean a2) { - Z3_ast result = Z3_mk_bv2int((Z3_context)a0, (Z3_ast)a1, (Z3_bool)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvaddNoOverflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jboolean a3) { - Z3_ast result = Z3_mk_bvadd_no_overflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2, (Z3_bool)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvaddNoUnderflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvadd_no_underflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsubNoOverflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsub_no_overflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsubNoUnderflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jboolean a3) { - Z3_ast result = Z3_mk_bvsub_no_underflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2, (Z3_bool)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvsdivNoOverflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvsdiv_no_overflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvnegNoOverflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_bvneg_no_overflow((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvmulNoOverflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jboolean a3) { - Z3_ast result = Z3_mk_bvmul_no_overflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2, (Z3_bool)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBvmulNoUnderflow(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_bvmul_no_underflow((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSelect(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_select((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkStore(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_ast result = Z3_mk_store((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2, (Z3_ast)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkConstArray(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_const_array((Z3_context)a0, (Z3_sort)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkMap(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_ast result = Z3_mk_map((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkArrayDefault(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_array_default((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_mk_set_sort((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkEmptySet(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_empty_set((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFullSet(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_full_set((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetAdd(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_set_add((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetDel(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_set_del((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetUnion(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_set_union((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetIntersect(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_ast result = Z3_mk_set_intersect((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetDifference(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_set_difference((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetComplement(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_mk_set_complement((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetMember(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_set_member((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSetSubset(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_set_subset((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkNumeral(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jlong a2) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_ast result = Z3_mk_numeral((Z3_context)a0, _a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkReal(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2) { - Z3_ast result = Z3_mk_real((Z3_context)a0, (int)a1, (int)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkInt(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_int((Z3_context)a0, (int)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkUnsignedInt(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_unsigned_int((Z3_context)a0, (unsigned)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkInt64(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_int64((Z3_context)a0, (__int64)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkUnsignedInt64(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_mk_unsigned_int64((Z3_context)a0, (__uint64)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkPattern(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_pattern result = Z3_mk_pattern((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkBound(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlong a2) { - Z3_ast result = Z3_mk_bound((Z3_context)a0, (unsigned)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkForall(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2, jlongArray a3, jint a4, jlongArray a5, jlongArray a6, jlong a7) { - Z3_pattern * _a3 = (Z3_pattern *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a5 = (Z3_sort *) jenv->GetLongArrayElements(a5, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_ast result = Z3_mk_forall((Z3_context)a0, (unsigned)a1, (unsigned)a2, _a3, (unsigned)a4, _a5, _a6, (Z3_ast)a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a5, (jlong *) _a5, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkExists(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2, jlongArray a3, jint a4, jlongArray a5, jlongArray a6, jlong a7) { - Z3_pattern * _a3 = (Z3_pattern *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a5 = (Z3_sort *) jenv->GetLongArrayElements(a5, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_ast result = Z3_mk_exists((Z3_context)a0, (unsigned)a1, (unsigned)a2, _a3, (unsigned)a4, _a5, _a6, (Z3_ast)a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a5, (jlong *) _a5, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkQuantifier(JNIEnv * jenv, jclass cls, jlong a0, jboolean a1, jint a2, jint a3, jlongArray a4, jint a5, jlongArray a6, jlongArray a7, jlong a8) { - Z3_pattern * _a4 = (Z3_pattern *) jenv->GetLongArrayElements(a4, NULL); - Z3_sort * _a6 = (Z3_sort *) jenv->GetLongArrayElements(a6, NULL); - Z3_symbol * _a7 = (Z3_symbol *) jenv->GetLongArrayElements(a7, NULL); - Z3_ast result = Z3_mk_quantifier((Z3_context)a0, (Z3_bool)a1, (unsigned)a2, (unsigned)a3, _a4, (unsigned)a5, _a6, _a7, (Z3_ast)a8); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a7, (jlong *) _a7, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkQuantifierEx(JNIEnv * jenv, jclass cls, jlong a0, jboolean a1, jint a2, jlong a3, jlong a4, jint a5, jlongArray a6, jint a7, jlongArray a8, jint a9, jlongArray a10, jlongArray a11, jlong a12) { - Z3_pattern * _a6 = (Z3_pattern *) jenv->GetLongArrayElements(a6, NULL); - Z3_ast * _a8 = (Z3_ast *) jenv->GetLongArrayElements(a8, NULL); - Z3_sort * _a10 = (Z3_sort *) jenv->GetLongArrayElements(a10, NULL); - Z3_symbol * _a11 = (Z3_symbol *) jenv->GetLongArrayElements(a11, NULL); - Z3_ast result = Z3_mk_quantifier_ex((Z3_context)a0, (Z3_bool)a1, (unsigned)a2, (Z3_symbol)a3, (Z3_symbol)a4, (unsigned)a5, _a6, (unsigned)a7, _a8, (unsigned)a9, _a10, _a11, (Z3_ast)a12); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a8, (jlong *) _a8, JNI_ABORT); - jenv->ReleaseLongArrayElements(a10, (jlong *) _a10, JNI_ABORT); - jenv->ReleaseLongArrayElements(a11, (jlong *) _a11, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkForallConst(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2, jlongArray a3, jint a4, jlongArray a5, jlong a6) { - Z3_app * _a3 = (Z3_app *) jenv->GetLongArrayElements(a3, NULL); - Z3_pattern * _a5 = (Z3_pattern *) jenv->GetLongArrayElements(a5, NULL); - Z3_ast result = Z3_mk_forall_const((Z3_context)a0, (unsigned)a1, (unsigned)a2, _a3, (unsigned)a4, _a5, (Z3_ast)a6); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a5, (jlong *) _a5, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkExistsConst(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jint a2, jlongArray a3, jint a4, jlongArray a5, jlong a6) { - Z3_app * _a3 = (Z3_app *) jenv->GetLongArrayElements(a3, NULL); - Z3_pattern * _a5 = (Z3_pattern *) jenv->GetLongArrayElements(a5, NULL); - Z3_ast result = Z3_mk_exists_const((Z3_context)a0, (unsigned)a1, (unsigned)a2, _a3, (unsigned)a4, _a5, (Z3_ast)a6); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a5, (jlong *) _a5, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkQuantifierConst(JNIEnv * jenv, jclass cls, jlong a0, jboolean a1, jint a2, jint a3, jlongArray a4, jint a5, jlongArray a6, jlong a7) { - Z3_app * _a4 = (Z3_app *) jenv->GetLongArrayElements(a4, NULL); - Z3_pattern * _a6 = (Z3_pattern *) jenv->GetLongArrayElements(a6, NULL); - Z3_ast result = Z3_mk_quantifier_const((Z3_context)a0, (Z3_bool)a1, (unsigned)a2, (unsigned)a3, _a4, (unsigned)a5, _a6, (Z3_ast)a7); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkQuantifierConstEx(JNIEnv * jenv, jclass cls, jlong a0, jboolean a1, jint a2, jlong a3, jlong a4, jint a5, jlongArray a6, jint a7, jlongArray a8, jint a9, jlongArray a10, jlong a11) { - Z3_app * _a6 = (Z3_app *) jenv->GetLongArrayElements(a6, NULL); - Z3_pattern * _a8 = (Z3_pattern *) jenv->GetLongArrayElements(a8, NULL); - Z3_ast * _a10 = (Z3_ast *) jenv->GetLongArrayElements(a10, NULL); - Z3_ast result = Z3_mk_quantifier_const_ex((Z3_context)a0, (Z3_bool)a1, (unsigned)a2, (Z3_symbol)a3, (Z3_symbol)a4, (unsigned)a5, _a6, (unsigned)a7, _a8, (unsigned)a9, _a10, (Z3_ast)a11); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a8, (jlong *) _a8, JNI_ABORT); - jenv->ReleaseLongArrayElements(a10, (jlong *) _a10, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSymbolKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_symbol_kind((Z3_context)a0, (Z3_symbol)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSymbolInt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - int result = Z3_get_symbol_int((Z3_context)a0, (Z3_symbol)a1); - return (jint) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getSymbolString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_get_symbol_string((Z3_context)a0, (Z3_symbol)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSortName(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_symbol result = Z3_get_sort_name((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSortId(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_sort_id((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_sortToAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_sort_to_ast((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isEqSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_bool result = Z3_is_eq_sort((Z3_context)a0, (Z3_sort)a1, (Z3_sort)a2); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSortKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_sort_kind((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getBvSortSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_bv_sort_size((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getFiniteDomainSortSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2) { - __uint64 _a2; - Z3_bool result = Z3_get_finite_domain_sort_size((Z3_context)a0, (Z3_sort)a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getArraySortDomain(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_get_array_sort_domain((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getArraySortRange(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_get_array_sort_range((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getTupleSortMkDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_decl result = Z3_get_tuple_sort_mk_decl((Z3_context)a0, (Z3_sort)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getTupleSortNumFields(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_tuple_sort_num_fields((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getTupleSortFieldDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_tuple_sort_field_decl((Z3_context)a0, (Z3_sort)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDatatypeSortNumConstructors(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_datatype_sort_num_constructors((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDatatypeSortConstructor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_datatype_sort_constructor((Z3_context)a0, (Z3_sort)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDatatypeSortRecognizer(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_datatype_sort_recognizer((Z3_context)a0, (Z3_sort)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDatatypeSortConstructorAccessor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jint a3) { - Z3_func_decl result = Z3_get_datatype_sort_constructor_accessor((Z3_context)a0, (Z3_sort)a1, (unsigned)a2, (unsigned)a3); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getRelationArity(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_relation_arity((Z3_context)a0, (Z3_sort)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getRelationColumn(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_sort result = Z3_get_relation_column((Z3_context)a0, (Z3_sort)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_funcDeclToAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_func_decl_to_ast((Z3_context)a0, (Z3_func_decl)a1); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isEqFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_bool result = Z3_is_eq_func_decl((Z3_context)a0, (Z3_func_decl)a1, (Z3_func_decl)a2); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getFuncDeclId(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_func_decl_id((Z3_context)a0, (Z3_func_decl)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDeclName(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_symbol result = Z3_get_decl_name((Z3_context)a0, (Z3_func_decl)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDeclKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_decl_kind((Z3_context)a0, (Z3_func_decl)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDomainSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_domain_size((Z3_context)a0, (Z3_func_decl)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getArity(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_arity((Z3_context)a0, (Z3_func_decl)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDomain(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_sort result = Z3_get_domain((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getRange(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_get_range((Z3_context)a0, (Z3_func_decl)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDeclNumParameters(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_decl_num_parameters((Z3_context)a0, (Z3_func_decl)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDeclParameterKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - unsigned result = Z3_get_decl_parameter_kind((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getDeclIntParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - int result = Z3_get_decl_int_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jint) result; -} -JNIEXPORT jdouble JNICALL Java_Z3Native_getDeclDoubleParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - double result = Z3_get_decl_double_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jdouble) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDeclSymbolParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_symbol result = Z3_get_decl_symbol_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDeclSortParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_sort result = Z3_get_decl_sort_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDeclAstParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_decl_ast_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDeclFuncDeclParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_decl_func_decl_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getDeclRationalParameter(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_string result = Z3_get_decl_rational_parameter((Z3_context)a0, (Z3_func_decl)a1, (unsigned)a2); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_appToAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_app_to_ast((Z3_context)a0, (Z3_app)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getAppDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_decl result = Z3_get_app_decl((Z3_context)a0, (Z3_app)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getAppNumArgs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_app_num_args((Z3_context)a0, (Z3_app)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getAppArg(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_app_arg((Z3_context)a0, (Z3_app)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isEqAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_bool result = Z3_is_eq_ast((Z3_context)a0, (Z3_ast)a1, (Z3_ast)a2); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getAstId(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_ast_id((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getAstHash(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_ast_hash((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_sort result = Z3_get_sort((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isWellSorted(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_well_sorted((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getBoolValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_bool_value((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getAstKind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_ast_kind((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isApp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_app((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isNumeralAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_numeral_ast((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isAlgebraicNumber(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_algebraic_number((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_toApp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_app result = Z3_to_app((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_toFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_decl result = Z3_to_func_decl((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getNumeralString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_get_numeral_string((Z3_context)a0, (Z3_ast)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_getNumeralDecimalString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_string result = Z3_get_numeral_decimal_string((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_getNumerator(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_get_numerator((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getDenominator(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_get_denominator((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralSmall(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2, jobject a3) { - __int64 _a2; - __int64 _a3; - Z3_bool result = Z3_get_numeral_small((Z3_context)a0, (Z3_ast)a1, &_a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralInt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2) { - int _a2; - Z3_bool result = Z3_get_numeral_int((Z3_context)a0, (Z3_ast)a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a2, fid, (jint) _a2); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralUint(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2) { - unsigned _a2; - Z3_bool result = Z3_get_numeral_uint((Z3_context)a0, (Z3_ast)a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a2, fid, (jint) _a2); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralUint64(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2) { - __uint64 _a2; - Z3_bool result = Z3_get_numeral_uint64((Z3_context)a0, (Z3_ast)a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralInt64(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2) { - __int64 _a2; - Z3_bool result = Z3_get_numeral_int64((Z3_context)a0, (Z3_ast)a1, &_a2); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_getNumeralRationalInt64(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jobject a2, jobject a3) { - __int64 _a2; - __int64 _a3; - Z3_bool result = Z3_get_numeral_rational_int64((Z3_context)a0, (Z3_ast)a1, &_a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a2, fid, (jlong) _a2); - } - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getAlgebraicNumberLower(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_algebraic_number_lower((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getAlgebraicNumberUpper(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_algebraic_number_upper((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_patternToAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_pattern_to_ast((Z3_context)a0, (Z3_pattern)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getPatternNumTerms(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_pattern_num_terms((Z3_context)a0, (Z3_pattern)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getPattern(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_pattern((Z3_context)a0, (Z3_pattern)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getIndexValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_index_value((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isQuantifierForall(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_quantifier_forall((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getQuantifierWeight(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_quantifier_weight((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getQuantifierNumPatterns(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_quantifier_num_patterns((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getQuantifierPatternAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_pattern result = Z3_get_quantifier_pattern_ast((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getQuantifierNumNoPatterns(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_quantifier_num_no_patterns((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getQuantifierNoPatternAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_quantifier_no_pattern_ast((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getQuantifierNumBound(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_quantifier_num_bound((Z3_context)a0, (Z3_ast)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getQuantifierBoundName(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_symbol result = Z3_get_quantifier_bound_name((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getQuantifierBoundSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_sort result = Z3_get_quantifier_bound_sort((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getQuantifierBody(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_get_quantifier_body((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_simplify(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_simplify((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_simplifyEx(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_simplify_ex((Z3_context)a0, (Z3_ast)a1, (Z3_params)a2); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_simplifyGetHelp(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_string result = Z3_simplify_get_help((Z3_context)a0); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_simplifyGetParamDescrs(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_param_descrs result = Z3_simplify_get_param_descrs((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_updateTerm(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_ast result = Z3_update_term((Z3_context)a0, (Z3_ast)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_substitute(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3, jlongArray a4) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_ast * _a4 = (Z3_ast *) jenv->GetLongArrayElements(a4, NULL); - Z3_ast result = Z3_substitute((Z3_context)a0, (Z3_ast)a1, (unsigned)a2, _a3, _a4); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_substituteVars(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_ast result = Z3_substitute_vars((Z3_context)a0, (Z3_ast)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_translate(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_translate((Z3_context)a0, (Z3_ast)a1, (Z3_context)a2); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_modelIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_model_inc_ref((Z3_context)a0, (Z3_model)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_modelDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_model_dec_ref((Z3_context)a0, (Z3_model)a1); -} -JNIEXPORT jboolean JNICALL Java_Z3Native_modelEval(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jboolean a3, jobject a4) { - Z3_ast _a4; - Z3_bool result = Z3_model_eval((Z3_context)a0, (Z3_model)a1, (Z3_ast)a2, (Z3_bool)a3, &_a4); - { - jclass mc = jenv->GetObjectClass(a4); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a4, fid, (jlong) _a4); - } - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetConstInterp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_model_get_const_interp((Z3_context)a0, (Z3_model)a1, (Z3_func_decl)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetFuncInterp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_func_interp result = Z3_model_get_func_interp((Z3_context)a0, (Z3_model)a1, (Z3_func_decl)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_modelGetNumConsts(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_model_get_num_consts((Z3_context)a0, (Z3_model)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetConstDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_model_get_const_decl((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_modelGetNumFuncs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_model_get_num_funcs((Z3_context)a0, (Z3_model)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_model_get_func_decl((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_modelGetNumSorts(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_model_get_num_sorts((Z3_context)a0, (Z3_model)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetSort(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_sort result = Z3_model_get_sort((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_modelGetSortUniverse(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast_vector result = Z3_model_get_sort_universe((Z3_context)a0, (Z3_model)a1, (Z3_sort)a2); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isAsArray(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_is_as_array((Z3_context)a0, (Z3_ast)a1); - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getAsArrayFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_decl result = Z3_get_as_array_func_decl((Z3_context)a0, (Z3_ast)a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_funcInterpIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_interp_inc_ref((Z3_context)a0, (Z3_func_interp)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_funcInterpDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_interp_dec_ref((Z3_context)a0, (Z3_func_interp)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_funcInterpGetNumEntries(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_func_interp_get_num_entries((Z3_context)a0, (Z3_func_interp)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_funcInterpGetEntry(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_entry result = Z3_func_interp_get_entry((Z3_context)a0, (Z3_func_interp)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_funcInterpGetElse(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_func_interp_get_else((Z3_context)a0, (Z3_func_interp)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_funcInterpGetArity(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_func_interp_get_arity((Z3_context)a0, (Z3_func_interp)a1); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_funcEntryIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_entry_inc_ref((Z3_context)a0, (Z3_func_entry)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_funcEntryDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_func_entry_dec_ref((Z3_context)a0, (Z3_func_entry)a1); -} -JNIEXPORT jlong JNICALL Java_Z3Native_funcEntryGetValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_func_entry_get_value((Z3_context)a0, (Z3_func_entry)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_funcEntryGetNumArgs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_func_entry_get_num_args((Z3_context)a0, (Z3_func_entry)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_funcEntryGetArg(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_func_entry_get_arg((Z3_context)a0, (Z3_func_entry)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_openLog(JNIEnv * jenv, jclass cls, jstring a0) { - Z3_string _a0 = (Z3_string) jenv->GetStringUTFChars(a0, NULL); - int result = Z3_open_log(_a0); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_appendLog(JNIEnv * jenv, jclass cls, jstring a0) { - Z3_string _a0 = (Z3_string) jenv->GetStringUTFChars(a0, NULL); - Z3_append_log(_a0); -} -JNIEXPORT void JNICALL Java_Z3Native_closeLog(JNIEnv * jenv, jclass cls) { - Z3_close_log(); -} -JNIEXPORT void JNICALL Java_Z3Native_toggleWarningMessages(JNIEnv * jenv, jclass cls, jboolean a0) { - Z3_toggle_warning_messages((Z3_bool)a0); -} -JNIEXPORT void JNICALL Java_Z3Native_setAstPrintMode(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_set_ast_print_mode((Z3_context)a0, (Z3_ast_print_mode)a1); -} -JNIEXPORT jstring JNICALL Java_Z3Native_astToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_ast_to_string((Z3_context)a0, (Z3_ast)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_patternToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_pattern_to_string((Z3_context)a0, (Z3_pattern)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_sortToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_sort_to_string((Z3_context)a0, (Z3_sort)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_funcDeclToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_func_decl_to_string((Z3_context)a0, (Z3_func_decl)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_modelToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_model_to_string((Z3_context)a0, (Z3_model)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_benchmarkToSmtlibString(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jstring a2, jstring a3, jstring a4, jint a5, jlongArray a6, jlong a7) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string _a2 = (Z3_string) jenv->GetStringUTFChars(a2, NULL); - Z3_string _a3 = (Z3_string) jenv->GetStringUTFChars(a3, NULL); - Z3_string _a4 = (Z3_string) jenv->GetStringUTFChars(a4, NULL); - Z3_ast * _a6 = (Z3_ast *) jenv->GetLongArrayElements(a6, NULL); - Z3_string result = Z3_benchmark_to_smtlib_string((Z3_context)a0, _a1, _a2, _a3, _a4, (unsigned)a5, _a6, (Z3_ast)a7); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_parseSmtlib2String(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jint a2, jlongArray a3, jlongArray a4, jint a5, jlongArray a6, jlongArray a7) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a4 = (Z3_sort *) jenv->GetLongArrayElements(a4, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_func_decl * _a7 = (Z3_func_decl *) jenv->GetLongArrayElements(a7, NULL); - Z3_ast result = Z3_parse_smtlib2_string((Z3_context)a0, _a1, (unsigned)a2, _a3, _a4, (unsigned)a5, _a6, _a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a7, (jlong *) _a7, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_parseSmtlib2File(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jint a2, jlongArray a3, jlongArray a4, jint a5, jlongArray a6, jlongArray a7) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a4 = (Z3_sort *) jenv->GetLongArrayElements(a4, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_func_decl * _a7 = (Z3_func_decl *) jenv->GetLongArrayElements(a7, NULL); - Z3_ast result = Z3_parse_smtlib2_file((Z3_context)a0, _a1, (unsigned)a2, _a3, _a4, (unsigned)a5, _a6, _a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a7, (jlong *) _a7, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_parseSmtlibString(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jint a2, jlongArray a3, jlongArray a4, jint a5, jlongArray a6, jlongArray a7) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a4 = (Z3_sort *) jenv->GetLongArrayElements(a4, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_func_decl * _a7 = (Z3_func_decl *) jenv->GetLongArrayElements(a7, NULL); - Z3_parse_smtlib_string((Z3_context)a0, _a1, (unsigned)a2, _a3, _a4, (unsigned)a5, _a6, _a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a7, (jlong *) _a7, JNI_ABORT); -} -JNIEXPORT void JNICALL Java_Z3Native_parseSmtlibFile(JNIEnv * jenv, jclass cls, jlong a0, jstring a1, jint a2, jlongArray a3, jlongArray a4, jint a5, jlongArray a6, jlongArray a7) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_symbol * _a3 = (Z3_symbol *) jenv->GetLongArrayElements(a3, NULL); - Z3_sort * _a4 = (Z3_sort *) jenv->GetLongArrayElements(a4, NULL); - Z3_symbol * _a6 = (Z3_symbol *) jenv->GetLongArrayElements(a6, NULL); - Z3_func_decl * _a7 = (Z3_func_decl *) jenv->GetLongArrayElements(a7, NULL); - Z3_parse_smtlib_file((Z3_context)a0, _a1, (unsigned)a2, _a3, _a4, (unsigned)a5, _a6, _a7); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - jenv->ReleaseLongArrayElements(a6, (jlong *) _a6, JNI_ABORT); - jenv->ReleaseLongArrayElements(a7, (jlong *) _a7, JNI_ABORT); -} -JNIEXPORT jint JNICALL Java_Z3Native_getSmtlibNumFormulas(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_smtlib_num_formulas((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSmtlibFormula(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_ast result = Z3_get_smtlib_formula((Z3_context)a0, (unsigned)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSmtlibNumAssumptions(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_smtlib_num_assumptions((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSmtlibAssumption(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_ast result = Z3_get_smtlib_assumption((Z3_context)a0, (unsigned)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSmtlibNumDecls(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_smtlib_num_decls((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSmtlibDecl(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_func_decl result = Z3_get_smtlib_decl((Z3_context)a0, (unsigned)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getSmtlibNumSorts(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_smtlib_num_sorts((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getSmtlibSort(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_sort result = Z3_get_smtlib_sort((Z3_context)a0, (unsigned)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getSmtlibError(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_string result = Z3_get_smtlib_error((Z3_context)a0); - return jenv->NewStringUTF(result); -} -JNIEXPORT jint JNICALL Java_Z3Native_getErrorCode(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_error_code((Z3_context)a0); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_setError(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_set_error((Z3_context)a0, (Z3_error_code)a1); -} -JNIEXPORT jstring JNICALL Java_Z3Native_getErrorMsg(JNIEnv * jenv, jclass cls, jint a0) { - Z3_string result = Z3_get_error_msg((Z3_error_code)a0); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_getErrorMsgEx(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_string result = Z3_get_error_msg_ex((Z3_context)a0, (Z3_error_code)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT void JNICALL Java_Z3Native_getVersion(JNIEnv * jenv, jclass cls, jobject a0, jobject a1, jobject a2, jobject a3) { - unsigned _a0; - unsigned _a1; - unsigned _a2; - unsigned _a3; - Z3_get_version(&_a0, &_a1, &_a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a0); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a0, fid, (jint) _a0); - } - { - jclass mc = jenv->GetObjectClass(a1); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a1, fid, (jint) _a1); - } - { - jclass mc = jenv->GetObjectClass(a2); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a2, fid, (jint) _a2); - } - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a3, fid, (jint) _a3); - } -} -JNIEXPORT void JNICALL Java_Z3Native_enableTrace(JNIEnv * jenv, jclass cls, jstring a0) { - Z3_string _a0 = (Z3_string) jenv->GetStringUTFChars(a0, NULL); - Z3_enable_trace(_a0); -} -JNIEXPORT void JNICALL Java_Z3Native_disableTrace(JNIEnv * jenv, jclass cls, jstring a0) { - Z3_string _a0 = (Z3_string) jenv->GetStringUTFChars(a0, NULL); - Z3_disable_trace(_a0); -} -JNIEXPORT void JNICALL Java_Z3Native_resetMemory(JNIEnv * jenv, jclass cls) { - Z3_reset_memory(); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkFixedpoint(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_fixedpoint result = Z3_mk_fixedpoint((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_fixedpoint_inc_ref((Z3_context)a0, (Z3_fixedpoint)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_fixedpoint_dec_ref((Z3_context)a0, (Z3_fixedpoint)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointAddRule(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_fixedpoint_add_rule((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_ast)a2, (Z3_symbol)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointAddFact(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3, jintArray a4) { - unsigned * _a4 = (unsigned *) jenv->GetIntArrayElements(a4, NULL); - Z3_fixedpoint_add_fact((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_func_decl)a2, (unsigned)a3, _a4); - jenv->ReleaseIntArrayElements(a4, (jint *) _a4, JNI_ABORT); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointAssert(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_fixedpoint_assert((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_ast)a2); -} -JNIEXPORT jint JNICALL Java_Z3Native_fixedpointQuery(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - int result = Z3_fixedpoint_query((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_ast)a2); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_fixedpointQueryRelations(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_func_decl * _a3 = (Z3_func_decl *) jenv->GetLongArrayElements(a3, NULL); - int result = Z3_fixedpoint_query_relations((Z3_context)a0, (Z3_fixedpoint)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetAnswer(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_fixedpoint_get_answer((Z3_context)a0, (Z3_fixedpoint)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_fixedpointGetReasonUnknown(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_fixedpoint_get_reason_unknown((Z3_context)a0, (Z3_fixedpoint)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointUpdateRule(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_fixedpoint_update_rule((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_ast)a2, (Z3_symbol)a3); -} -JNIEXPORT jint JNICALL Java_Z3Native_fixedpointGetNumLevels(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - unsigned result = Z3_fixedpoint_get_num_levels((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_func_decl)a2); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetCoverDelta(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlong a3) { - Z3_ast result = Z3_fixedpoint_get_cover_delta((Z3_context)a0, (Z3_fixedpoint)a1, (int)a2, (Z3_func_decl)a3); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointAddCover(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlong a3, jlong a4) { - Z3_fixedpoint_add_cover((Z3_context)a0, (Z3_fixedpoint)a1, (int)a2, (Z3_func_decl)a3, (Z3_ast)a4); -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetStatistics(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_stats result = Z3_fixedpoint_get_statistics((Z3_context)a0, (Z3_fixedpoint)a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointRegisterRelation(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_fixedpoint_register_relation((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_func_decl)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointSetPredicateRepresentation(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3, jlongArray a4) { - Z3_symbol * _a4 = (Z3_symbol *) jenv->GetLongArrayElements(a4, NULL); - Z3_fixedpoint_set_predicate_representation((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_func_decl)a2, (unsigned)a3, _a4); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetRules(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector result = Z3_fixedpoint_get_rules((Z3_context)a0, (Z3_fixedpoint)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetAssertions(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector result = Z3_fixedpoint_get_assertions((Z3_context)a0, (Z3_fixedpoint)a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointSetParams(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_fixedpoint_set_params((Z3_context)a0, (Z3_fixedpoint)a1, (Z3_params)a2); -} -JNIEXPORT jstring JNICALL Java_Z3Native_fixedpointGetHelp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_fixedpoint_get_help((Z3_context)a0, (Z3_fixedpoint)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointGetParamDescrs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_param_descrs result = Z3_fixedpoint_get_param_descrs((Z3_context)a0, (Z3_fixedpoint)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_fixedpointToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - Z3_string result = Z3_fixedpoint_to_string((Z3_context)a0, (Z3_fixedpoint)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointFromString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jstring a2) { - Z3_string _a2 = (Z3_string) jenv->GetStringUTFChars(a2, NULL); - Z3_ast_vector result = Z3_fixedpoint_from_string((Z3_context)a0, (Z3_fixedpoint)a1, _a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_fixedpointFromFile(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jstring a2) { - Z3_string _a2 = (Z3_string) jenv->GetStringUTFChars(a2, NULL); - Z3_ast_vector result = Z3_fixedpoint_from_file((Z3_context)a0, (Z3_fixedpoint)a1, _a2); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointPush(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_fixedpoint_push((Z3_context)a0, (Z3_fixedpoint)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_fixedpointPop(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_fixedpoint_pop((Z3_context)a0, (Z3_fixedpoint)a1); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkAstVector(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_ast_vector result = Z3_mk_ast_vector((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_astVectorIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector_inc_ref((Z3_context)a0, (Z3_ast_vector)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_astVectorDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector_dec_ref((Z3_context)a0, (Z3_ast_vector)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_astVectorSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_ast_vector_size((Z3_context)a0, (Z3_ast_vector)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_astVectorGet(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_ast_vector_get((Z3_context)a0, (Z3_ast_vector)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_astVectorSet(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlong a3) { - Z3_ast_vector_set((Z3_context)a0, (Z3_ast_vector)a1, (unsigned)a2, (Z3_ast)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_astVectorResize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast_vector_resize((Z3_context)a0, (Z3_ast_vector)a1, (unsigned)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_astVectorPush(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast_vector_push((Z3_context)a0, (Z3_ast_vector)a1, (Z3_ast)a2); -} -JNIEXPORT jlong JNICALL Java_Z3Native_astVectorTranslate(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast_vector result = Z3_ast_vector_translate((Z3_context)a0, (Z3_ast_vector)a1, (Z3_context)a2); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_astVectorToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_ast_vector_to_string((Z3_context)a0, (Z3_ast_vector)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkAstMap(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_ast_map result = Z3_mk_ast_map((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_astMapIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_map_inc_ref((Z3_context)a0, (Z3_ast_map)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_astMapDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_map_dec_ref((Z3_context)a0, (Z3_ast_map)a1); -} -JNIEXPORT jboolean JNICALL Java_Z3Native_astMapContains(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_bool result = Z3_ast_map_contains((Z3_context)a0, (Z3_ast_map)a1, (Z3_ast)a2); - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_astMapFind(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast result = Z3_ast_map_find((Z3_context)a0, (Z3_ast_map)a1, (Z3_ast)a2); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_astMapInsert(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_ast_map_insert((Z3_context)a0, (Z3_ast_map)a1, (Z3_ast)a2, (Z3_ast)a3); -} -JNIEXPORT void JNICALL Java_Z3Native_astMapErase(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_ast_map_erase((Z3_context)a0, (Z3_ast_map)a1, (Z3_ast)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_astMapReset(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_map_reset((Z3_context)a0, (Z3_ast_map)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_astMapSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_ast_map_size((Z3_context)a0, (Z3_ast_map)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_astMapKeys(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector result = Z3_ast_map_keys((Z3_context)a0, (Z3_ast_map)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_astMapToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_ast_map_to_string((Z3_context)a0, (Z3_ast_map)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkGoal(JNIEnv * jenv, jclass cls, jlong a0, jboolean a1, jboolean a2, jboolean a3) { - Z3_goal result = Z3_mk_goal((Z3_context)a0, (Z3_bool)a1, (Z3_bool)a2, (Z3_bool)a3); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_goalIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_goal_inc_ref((Z3_context)a0, (Z3_goal)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_goalDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_goal_dec_ref((Z3_context)a0, (Z3_goal)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_goalPrecision(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_goal_precision((Z3_context)a0, (Z3_goal)a1); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_goalAssert(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_goal_assert((Z3_context)a0, (Z3_goal)a1, (Z3_ast)a2); -} -JNIEXPORT jboolean JNICALL Java_Z3Native_goalInconsistent(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_goal_inconsistent((Z3_context)a0, (Z3_goal)a1); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_goalDepth(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_goal_depth((Z3_context)a0, (Z3_goal)a1); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_goalReset(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_goal_reset((Z3_context)a0, (Z3_goal)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_goalSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_goal_size((Z3_context)a0, (Z3_goal)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_goalFormula(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_goal_formula((Z3_context)a0, (Z3_goal)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_goalNumExprs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_goal_num_exprs((Z3_context)a0, (Z3_goal)a1); - return (jint) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_goalIsDecidedSat(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_goal_is_decided_sat((Z3_context)a0, (Z3_goal)a1); - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_goalIsDecidedUnsat(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_bool result = Z3_goal_is_decided_unsat((Z3_context)a0, (Z3_goal)a1); - return (jboolean) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_goalTranslate(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_goal result = Z3_goal_translate((Z3_context)a0, (Z3_goal)a1, (Z3_context)a2); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_goalToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_goal_to_string((Z3_context)a0, (Z3_goal)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkTactic(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_tactic result = Z3_mk_tactic((Z3_context)a0, _a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_tacticIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_tactic_inc_ref((Z3_context)a0, (Z3_tactic)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_tacticDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_tactic_dec_ref((Z3_context)a0, (Z3_tactic)a1); -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkProbe(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_probe result = Z3_mk_probe((Z3_context)a0, _a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_probeIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_probe_inc_ref((Z3_context)a0, (Z3_probe)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_probeDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_probe_dec_ref((Z3_context)a0, (Z3_probe)a1); -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticAndThen(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_tactic result = Z3_tactic_and_then((Z3_context)a0, (Z3_tactic)a1, (Z3_tactic)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticOrElse(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_tactic result = Z3_tactic_or_else((Z3_context)a0, (Z3_tactic)a1, (Z3_tactic)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticParOr(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2) { - Z3_tactic * _a2 = (Z3_tactic *) jenv->GetLongArrayElements(a2, NULL); - Z3_tactic result = Z3_tactic_par_or((Z3_context)a0, (unsigned)a1, _a2); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticParAndThen(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_tactic result = Z3_tactic_par_and_then((Z3_context)a0, (Z3_tactic)a1, (Z3_tactic)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticTryFor(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_tactic result = Z3_tactic_try_for((Z3_context)a0, (Z3_tactic)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticWhen(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_tactic result = Z3_tactic_when((Z3_context)a0, (Z3_probe)a1, (Z3_tactic)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticCond(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_tactic result = Z3_tactic_cond((Z3_context)a0, (Z3_probe)a1, (Z3_tactic)a2, (Z3_tactic)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticRepeat(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_tactic result = Z3_tactic_repeat((Z3_context)a0, (Z3_tactic)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticSkip(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_tactic result = Z3_tactic_skip((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticFail(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_tactic result = Z3_tactic_fail((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticFailIf(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_tactic result = Z3_tactic_fail_if((Z3_context)a0, (Z3_probe)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticFailIfNotDecided(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_tactic result = Z3_tactic_fail_if_not_decided((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticUsingParams(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_tactic result = Z3_tactic_using_params((Z3_context)a0, (Z3_tactic)a1, (Z3_params)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeConst(JNIEnv * jenv, jclass cls, jlong a0, jdouble a1) { - Z3_probe result = Z3_probe_const((Z3_context)a0, (double)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeLt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_lt((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeGt(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_gt((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeLe(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_le((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeGe(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_ge((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeEq(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_eq((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeAnd(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_and((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeOr(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_probe result = Z3_probe_or((Z3_context)a0, (Z3_probe)a1, (Z3_probe)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_probeNot(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_probe result = Z3_probe_not((Z3_context)a0, (Z3_probe)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getNumTactics(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_num_tactics((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getTacticName(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_string result = Z3_get_tactic_name((Z3_context)a0, (unsigned)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jint JNICALL Java_Z3Native_getNumProbes(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_num_probes((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_getProbeName(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_string result = Z3_get_probe_name((Z3_context)a0, (unsigned)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_tacticGetHelp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_tactic_get_help((Z3_context)a0, (Z3_tactic)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticGetParamDescrs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_param_descrs result = Z3_tactic_get_param_descrs((Z3_context)a0, (Z3_tactic)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_tacticGetDescr(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string result = Z3_tactic_get_descr((Z3_context)a0, _a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_probeGetDescr(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_string result = Z3_probe_get_descr((Z3_context)a0, _a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jdouble JNICALL Java_Z3Native_probeApply(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - double result = Z3_probe_apply((Z3_context)a0, (Z3_probe)a1, (Z3_goal)a2); - return (jdouble) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticApply(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_apply_result result = Z3_tactic_apply((Z3_context)a0, (Z3_tactic)a1, (Z3_goal)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_tacticApplyEx(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_apply_result result = Z3_tactic_apply_ex((Z3_context)a0, (Z3_tactic)a1, (Z3_goal)a2, (Z3_params)a3); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_applyResultIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_apply_result_inc_ref((Z3_context)a0, (Z3_apply_result)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_applyResultDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_apply_result_dec_ref((Z3_context)a0, (Z3_apply_result)a1); -} -JNIEXPORT jstring JNICALL Java_Z3Native_applyResultToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_apply_result_to_string((Z3_context)a0, (Z3_apply_result)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jint JNICALL Java_Z3Native_applyResultGetNumSubgoals(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_apply_result_get_num_subgoals((Z3_context)a0, (Z3_apply_result)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_applyResultGetSubgoal(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_goal result = Z3_apply_result_get_subgoal((Z3_context)a0, (Z3_apply_result)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_applyResultConvertModel(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlong a3) { - Z3_model result = Z3_apply_result_convert_model((Z3_context)a0, (Z3_apply_result)a1, (unsigned)a2, (Z3_model)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSolver(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_solver result = Z3_mk_solver((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSimpleSolver(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_solver result = Z3_mk_simple_solver((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSolverForLogic(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver result = Z3_mk_solver_for_logic((Z3_context)a0, (Z3_symbol)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkSolverFromTactic(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver result = Z3_mk_solver_from_tactic((Z3_context)a0, (Z3_tactic)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_solverGetHelp(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_solver_get_help((Z3_context)a0, (Z3_solver)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetParamDescrs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_param_descrs result = Z3_solver_get_param_descrs((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_solverSetParams(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_solver_set_params((Z3_context)a0, (Z3_solver)a1, (Z3_params)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_solverIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver_inc_ref((Z3_context)a0, (Z3_solver)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_solverDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver_dec_ref((Z3_context)a0, (Z3_solver)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_solverPush(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver_push((Z3_context)a0, (Z3_solver)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_solverPop(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_solver_pop((Z3_context)a0, (Z3_solver)a1, (unsigned)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_solverReset(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_solver_reset((Z3_context)a0, (Z3_solver)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_solverGetNumScopes(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_solver_get_num_scopes((Z3_context)a0, (Z3_solver)a1); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_solverAssert(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2) { - Z3_solver_assert((Z3_context)a0, (Z3_solver)a1, (Z3_ast)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_solverAssertAndTrack(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jlong a3) { - Z3_solver_assert_and_track((Z3_context)a0, (Z3_solver)a1, (Z3_ast)a2, (Z3_ast)a3); -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetAssertions(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector result = Z3_solver_get_assertions((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_solverCheck(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - int result = Z3_solver_check((Z3_context)a0, (Z3_solver)a1); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_solverCheckAssumptions(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3) { - Z3_ast * _a3 = (Z3_ast *) jenv->GetLongArrayElements(a3, NULL); - int result = Z3_solver_check_assumptions((Z3_context)a0, (Z3_solver)a1, (unsigned)a2, _a3); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetModel(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_model result = Z3_solver_get_model((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetProof(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast result = Z3_solver_get_proof((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetUnsatCore(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_ast_vector result = Z3_solver_get_unsat_core((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_solverGetReasonUnknown(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_solver_get_reason_unknown((Z3_context)a0, (Z3_solver)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_solverGetStatistics(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_stats result = Z3_solver_get_statistics((Z3_context)a0, (Z3_solver)a1); - return (jlong) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_solverToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_solver_to_string((Z3_context)a0, (Z3_solver)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_statsToString(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_string result = Z3_stats_to_string((Z3_context)a0, (Z3_stats)a1); - return jenv->NewStringUTF(result); -} -JNIEXPORT void JNICALL Java_Z3Native_statsIncRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_stats_inc_ref((Z3_context)a0, (Z3_stats)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_statsDecRef(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_stats_dec_ref((Z3_context)a0, (Z3_stats)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_statsSize(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_stats_size((Z3_context)a0, (Z3_stats)a1); - return (jint) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_statsGetKey(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_string result = Z3_stats_get_key((Z3_context)a0, (Z3_stats)a1, (unsigned)a2); - return jenv->NewStringUTF(result); -} -JNIEXPORT jboolean JNICALL Java_Z3Native_statsIsUint(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_bool result = Z3_stats_is_uint((Z3_context)a0, (Z3_stats)a1, (unsigned)a2); - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_statsIsDouble(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_bool result = Z3_stats_is_double((Z3_context)a0, (Z3_stats)a1, (unsigned)a2); - return (jboolean) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_statsGetUintValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - unsigned result = Z3_stats_get_uint_value((Z3_context)a0, (Z3_stats)a1, (unsigned)a2); - return (jint) result; -} -JNIEXPORT jdouble JNICALL Java_Z3Native_statsGetDoubleValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - double result = Z3_stats_get_double_value((Z3_context)a0, (Z3_stats)a1, (unsigned)a2); - return (jdouble) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkInjectiveFunction(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jlongArray a3, jlong a4) { - Z3_sort * _a3 = (Z3_sort *) jenv->GetLongArrayElements(a3, NULL); - Z3_func_decl result = Z3_mk_injective_function((Z3_context)a0, (Z3_symbol)a1, (unsigned)a2, _a3, (Z3_sort)a4); - jenv->ReleaseLongArrayElements(a3, (jlong *) _a3, JNI_ABORT); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_setLogic(JNIEnv * jenv, jclass cls, jlong a0, jstring a1) { - Z3_string _a1 = (Z3_string) jenv->GetStringUTFChars(a1, NULL); - Z3_set_logic((Z3_context)a0, _a1); -} -JNIEXPORT void JNICALL Java_Z3Native_push(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_push((Z3_context)a0); -} -JNIEXPORT void JNICALL Java_Z3Native_pop(JNIEnv * jenv, jclass cls, jlong a0, jint a1) { - Z3_pop((Z3_context)a0, (unsigned)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_getNumScopes(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_num_scopes((Z3_context)a0); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_persistAst(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_persist_ast((Z3_context)a0, (Z3_ast)a1, (unsigned)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_assertCnstr(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_assert_cnstr((Z3_context)a0, (Z3_ast)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_checkAndGetModel(JNIEnv * jenv, jclass cls, jlong a0, jobject a1) { - Z3_model _a1; - int result = Z3_check_and_get_model((Z3_context)a0, &_a1); - { - jclass mc = jenv->GetObjectClass(a1); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a1, fid, (jlong) _a1); - } - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_check(JNIEnv * jenv, jclass cls, jlong a0) { - int result = Z3_check((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_checkAssumptions(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2, jobject a3, jobject a4, jobject a5, jlongArray a6) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - Z3_model _a3; - Z3_ast _a4; - unsigned _a5; - Z3_ast * _a6 = (Z3_ast *) malloc(((unsigned)a1) * sizeof(Z3_ast)); - int result = Z3_check_assumptions((Z3_context)a0, (unsigned)a1, _a2, &_a3, &_a4, &_a5, _a6); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - { - jclass mc = jenv->GetObjectClass(a4); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a4, fid, (jlong) _a4); - } - { - jclass mc = jenv->GetObjectClass(a5); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a5, fid, (jint) _a5); - } - jenv->SetLongArrayRegion(a6, 0, (jsize)a1, (jlong *) _a6); - free(_a6); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getImpliedEqualities(JNIEnv * jenv, jclass cls, jlong a0, jint a1, jlongArray a2, jintArray a3) { - Z3_ast * _a2 = (Z3_ast *) jenv->GetLongArrayElements(a2, NULL); - unsigned * _a3 = (unsigned *) malloc(((unsigned)a1) * sizeof(unsigned)); - unsigned result = Z3_get_implied_equalities((Z3_context)a0, (unsigned)a1, _a2, _a3); - jenv->ReleaseLongArrayElements(a2, (jlong *) _a2, JNI_ABORT); - jenv->SetIntArrayRegion(a3, 0, (jsize)a1, (jint *) _a3); - free(_a3); - return (jint) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delModel(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_del_model((Z3_context)a0, (Z3_model)a1); -} -JNIEXPORT void JNICALL Java_Z3Native_softCheckCancel(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_soft_check_cancel((Z3_context)a0); -} -JNIEXPORT jint JNICALL Java_Z3Native_getSearchFailure(JNIEnv * jenv, jclass cls, jlong a0) { - unsigned result = Z3_get_search_failure((Z3_context)a0); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_mkLabel(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jboolean a2, jlong a3) { - Z3_ast result = Z3_mk_label((Z3_context)a0, (Z3_symbol)a1, (Z3_bool)a2, (Z3_ast)a3); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getRelevantLabels(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_literals result = Z3_get_relevant_labels((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getRelevantLiterals(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_literals result = Z3_get_relevant_literals((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getGuessedLiterals(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_literals result = Z3_get_guessed_literals((Z3_context)a0); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_delLiterals(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_del_literals((Z3_context)a0, (Z3_literals)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_getNumLiterals(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_num_literals((Z3_context)a0, (Z3_literals)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getLabelSymbol(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_symbol result = Z3_get_label_symbol((Z3_context)a0, (Z3_literals)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getLiteral(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_literal((Z3_context)a0, (Z3_literals)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT void JNICALL Java_Z3Native_disableLiteral(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_disable_literal((Z3_context)a0, (Z3_literals)a1, (unsigned)a2); -} -JNIEXPORT void JNICALL Java_Z3Native_blockLiterals(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - Z3_block_literals((Z3_context)a0, (Z3_literals)a1); -} -JNIEXPORT jint JNICALL Java_Z3Native_getModelNumConstants(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_model_num_constants((Z3_context)a0, (Z3_model)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getModelConstant(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_model_constant((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getModelNumFuncs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1) { - unsigned result = Z3_get_model_num_funcs((Z3_context)a0, (Z3_model)a1); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getModelFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_func_decl result = Z3_get_model_func_decl((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_evalFuncDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jobject a3) { - Z3_ast _a3; - Z3_bool result = Z3_eval_func_decl((Z3_context)a0, (Z3_model)a1, (Z3_func_decl)a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_isArrayValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jobject a3) { - unsigned _a3; - Z3_bool result = Z3_is_array_value((Z3_context)a0, (Z3_model)a1, (Z3_ast)a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "I"); - jenv->SetIntField(a3, fid, (jint) _a3); - } - return (jboolean) result; -} -JNIEXPORT void JNICALL Java_Z3Native_getArrayValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3, jlongArray a4, jlongArray a5, jobject a6) { - Z3_ast * _a4 = (Z3_ast *) malloc(((unsigned)a3) * sizeof(Z3_ast)); - Z3_ast * _a5 = (Z3_ast *) malloc(((unsigned)a3) * sizeof(Z3_ast)); - Z3_ast _a6; - Z3_get_array_value((Z3_context)a0, (Z3_model)a1, (Z3_ast)a2, (unsigned)a3, _a4, _a5, &_a6); - jenv->SetLongArrayRegion(a4, 0, (jsize)a3, (jlong *) _a4); - free(_a4); - jenv->SetLongArrayRegion(a5, 0, (jsize)a3, (jlong *) _a5); - free(_a5); - { - jclass mc = jenv->GetObjectClass(a6); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a6, fid, (jlong) _a6); - } -} -JNIEXPORT jlong JNICALL Java_Z3Native_getModelFuncElse(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - Z3_ast result = Z3_get_model_func_else((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jlong) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getModelFuncNumEntries(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2) { - unsigned result = Z3_get_model_func_num_entries((Z3_context)a0, (Z3_model)a1, (unsigned)a2); - return (jint) result; -} -JNIEXPORT jint JNICALL Java_Z3Native_getModelFuncEntryNumArgs(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jint a3) { - unsigned result = Z3_get_model_func_entry_num_args((Z3_context)a0, (Z3_model)a1, (unsigned)a2, (unsigned)a3); - return (jint) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getModelFuncEntryArg(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jint a3, jint a4) { - Z3_ast result = Z3_get_model_func_entry_arg((Z3_context)a0, (Z3_model)a1, (unsigned)a2, (unsigned)a3, (unsigned)a4); - return (jlong) result; -} -JNIEXPORT jlong JNICALL Java_Z3Native_getModelFuncEntryValue(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jint a2, jint a3) { - Z3_ast result = Z3_get_model_func_entry_value((Z3_context)a0, (Z3_model)a1, (unsigned)a2, (unsigned)a3); - return (jlong) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_eval(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jobject a3) { - Z3_ast _a3; - Z3_bool result = Z3_eval((Z3_context)a0, (Z3_model)a1, (Z3_ast)a2, &_a3); - { - jclass mc = jenv->GetObjectClass(a3); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a3, fid, (jlong) _a3); - } - return (jboolean) result; -} -JNIEXPORT jboolean JNICALL Java_Z3Native_evalDecl(JNIEnv * jenv, jclass cls, jlong a0, jlong a1, jlong a2, jint a3, jlongArray a4, jobject a5) { - Z3_ast * _a4 = (Z3_ast *) jenv->GetLongArrayElements(a4, NULL); - Z3_ast _a5; - Z3_bool result = Z3_eval_decl((Z3_context)a0, (Z3_model)a1, (Z3_func_decl)a2, (unsigned)a3, _a4, &_a5); - jenv->ReleaseLongArrayElements(a4, (jlong *) _a4, JNI_ABORT); - { - jclass mc = jenv->GetObjectClass(a5); - jfieldID fid = jenv->GetFieldID(mc, "value", "J"); - jenv->SetLongField(a5, fid, (jlong) _a5); - } - return (jboolean) result; -} -JNIEXPORT jstring JNICALL Java_Z3Native_contextToString(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_string result = Z3_context_to_string((Z3_context)a0); - return jenv->NewStringUTF(result); -} -JNIEXPORT jstring JNICALL Java_Z3Native_statisticsToString(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_string result = Z3_statistics_to_string((Z3_context)a0); - return jenv->NewStringUTF(result); -} -JNIEXPORT jlong JNICALL Java_Z3Native_getContextAssignment(JNIEnv * jenv, jclass cls, jlong a0) { - Z3_ast result = Z3_get_context_assignment((Z3_context)a0); - return (jlong) result; -} -#ifdef __cplusplus -} -#endif From c1bd6cb2fa9a0d1fc5814b36bd5778dc8d5c3c00 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 18:48:42 +0000 Subject: [PATCH 021/133] Java API: Removed auto-generated files. Signed-off-by: Christoph M. Wintersteiger --- src/api/java/Native.java | 498 --------------------------------------- 1 file changed, 498 deletions(-) delete mode 100644 src/api/java/Native.java diff --git a/src/api/java/Native.java b/src/api/java/Native.java deleted file mode 100644 index fa326f5cf..000000000 --- a/src/api/java/Native.java +++ /dev/null @@ -1,498 +0,0 @@ -// Automatically generated file -package com.Microsoft.Z3; -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 { 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); - public static native long mkContext(long a0); - public static native long mkContextRc(long a0); - public static native void delContext(long a0); - 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, 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); - public static native void paramsDecRef(long a0, long a1); - public static native void paramsSetBool(long a0, long a1, long a2, boolean a3); - public static native void paramsSetUint(long a0, long a1, long a2, int a3); - public static native void paramsSetDouble(long a0, long a1, long a2, double a3); - public static native void paramsSetSymbol(long a0, long a1, long a2, long a3); - public static native String paramsToString(long a0, long a1); - public static native void paramsValidate(long a0, long a1, long a2); - public static native void paramDescrsIncRef(long a0, long a1); - public static native void paramDescrsDecRef(long a0, long a1); - public static native int paramDescrsGetKind(long a0, long a1, long a2); - public static native int paramDescrsSize(long a0, long a1); - public static native long paramDescrsGetName(long a0, long a1, int a2); - public static native String paramDescrsToString(long a0, long a1); - public static native long mkIntSymbol(long a0, int a1); - public static native long mkStringSymbol(long a0, String a1); - public static native long mkUninterpretedSort(long a0, long a1); - public static native long mkBoolSort(long a0); - public static native long mkIntSort(long a0); - public static native long mkRealSort(long a0); - 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, 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, 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, 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); - public static native long mkFreshFuncDecl(long a0, String a1, int a2, long[] a3, long a4); - public static native long mkFreshConst(long a0, String a1, long a2); - public static native long mkTrue(long a0); - public static native long mkFalse(long a0); - public static native long mkEq(long a0, long a1, long a2); - public static native long mkDistinct(long a0, int a1, long[] a2); - public static native long mkNot(long a0, long a1); - public static native long mkIte(long a0, long a1, long a2, long a3); - public static native long mkIff(long a0, long a1, long a2); - public static native long mkImplies(long a0, long a1, long a2); - public static native long mkXor(long a0, long a1, long a2); - public static native long mkAnd(long a0, int a1, long[] a2); - public static native long mkOr(long a0, int a1, long[] a2); - public static native long mkAdd(long a0, int a1, long[] a2); - public static native long mkMul(long a0, int a1, long[] a2); - public static native long mkSub(long a0, int a1, long[] a2); - public static native long mkUnaryMinus(long a0, long a1); - public static native long mkDiv(long a0, long a1, long a2); - public static native long mkMod(long a0, long a1, long a2); - public static native long mkRem(long a0, long a1, long a2); - public static native long mkPower(long a0, long a1, long a2); - public static native long mkLt(long a0, long a1, long a2); - public static native long mkLe(long a0, long a1, long a2); - public static native long mkGt(long a0, long a1, long a2); - public static native long mkGe(long a0, long a1, long a2); - public static native long mkInt2real(long a0, long a1); - public static native long mkReal2int(long a0, long a1); - public static native long mkIsInt(long a0, long a1); - public static native long mkBvnot(long a0, long a1); - public static native long mkBvredand(long a0, long a1); - public static native long mkBvredor(long a0, long a1); - public static native long mkBvand(long a0, long a1, long a2); - public static native long mkBvor(long a0, long a1, long a2); - public static native long mkBvxor(long a0, long a1, long a2); - public static native long mkBvnand(long a0, long a1, long a2); - public static native long mkBvnor(long a0, long a1, long a2); - public static native long mkBvxnor(long a0, long a1, long a2); - public static native long mkBvneg(long a0, long a1); - public static native long mkBvadd(long a0, long a1, long a2); - public static native long mkBvsub(long a0, long a1, long a2); - public static native long mkBvmul(long a0, long a1, long a2); - public static native long mkBvudiv(long a0, long a1, long a2); - public static native long mkBvsdiv(long a0, long a1, long a2); - public static native long mkBvurem(long a0, long a1, long a2); - public static native long mkBvsrem(long a0, long a1, long a2); - public static native long mkBvsmod(long a0, long a1, long a2); - public static native long mkBvult(long a0, long a1, long a2); - public static native long mkBvslt(long a0, long a1, long a2); - public static native long mkBvule(long a0, long a1, long a2); - public static native long mkBvsle(long a0, long a1, long a2); - public static native long mkBvuge(long a0, long a1, long a2); - public static native long mkBvsge(long a0, long a1, long a2); - public static native long mkBvugt(long a0, long a1, long a2); - public static native long mkBvsgt(long a0, long a1, long a2); - public static native long mkConcat(long a0, long a1, long a2); - public static native long mkExtract(long a0, int a1, int a2, long a3); - public static native long mkSignExt(long a0, int a1, long a2); - public static native long mkZeroExt(long a0, int a1, long a2); - public static native long mkRepeat(long a0, int a1, long a2); - public static native long mkBvshl(long a0, long a1, long a2); - public static native long mkBvlshr(long a0, long a1, long a2); - public static native long mkBvashr(long a0, long a1, long a2); - public static native long mkRotateLeft(long a0, int a1, long a2); - public static native long mkRotateRight(long a0, int a1, long a2); - public static native long mkExtRotateLeft(long a0, long a1, long a2); - public static native long mkExtRotateRight(long a0, long a1, long a2); - public static native long mkInt2bv(long a0, int a1, long a2); - public static native long mkBv2int(long a0, long a1, boolean a2); - public static native long mkBvaddNoOverflow(long a0, long a1, long a2, boolean a3); - public static native long mkBvaddNoUnderflow(long a0, long a1, long a2); - public static native long mkBvsubNoOverflow(long a0, long a1, long a2); - public static native long mkBvsubNoUnderflow(long a0, long a1, long a2, boolean a3); - public static native long mkBvsdivNoOverflow(long a0, long a1, long a2); - public static native long mkBvnegNoOverflow(long a0, long a1); - public static native long mkBvmulNoOverflow(long a0, long a1, long a2, boolean a3); - public static native long mkBvmulNoUnderflow(long a0, long a1, long a2); - public static native long mkSelect(long a0, long a1, long a2); - public static native long mkStore(long a0, long a1, long a2, long a3); - public static native long mkConstArray(long a0, long a1, long a2); - public static native long mkMap(long a0, long a1, int a2, long[] a3); - public static native long mkArrayDefault(long a0, long a1); - public static native long mkSetSort(long a0, long a1); - public static native long mkEmptySet(long a0, long a1); - public static native long mkFullSet(long a0, long a1); - public static native long mkSetAdd(long a0, long a1, long a2); - public static native long mkSetDel(long a0, long a1, long a2); - public static native long mkSetUnion(long a0, int a1, long[] a2); - public static native long mkSetIntersect(long a0, int a1, long[] a2); - public static native long mkSetDifference(long a0, long a1, long a2); - public static native long mkSetComplement(long a0, long a1); - public static native long mkSetMember(long a0, long a1, long a2); - public static native long mkSetSubset(long a0, long a1, long a2); - public static native long mkNumeral(long a0, String a1, long a2); - public static native long mkReal(long a0, int a1, int a2); - public static native long mkInt(long a0, int a1, long a2); - public static native long mkUnsignedInt(long a0, int a1, long a2); - public static native long mkInt64(long a0, long a1, long a2); - public static native long mkUnsignedInt64(long a0, long a1, long a2); - public static native long mkPattern(long a0, int a1, long[] a2); - public static native long mkBound(long a0, int a1, long a2); - public static native long mkForall(long a0, int a1, int a2, long[] a3, int a4, long[] a5, long[] a6, long a7); - public static native long mkExists(long a0, int a1, int a2, long[] a3, int a4, long[] a5, long[] a6, long a7); - public static native long mkQuantifier(long a0, boolean a1, int a2, int a3, long[] a4, int a5, long[] a6, long[] a7, long a8); - public static native long mkQuantifierEx(long a0, boolean a1, int a2, long a3, long a4, int a5, long[] a6, int a7, long[] a8, int a9, long[] a10, long[] a11, long a12); - public static native long mkForallConst(long a0, int a1, int a2, long[] a3, int a4, long[] a5, long a6); - public static native long mkExistsConst(long a0, int a1, int a2, long[] a3, int a4, long[] a5, long a6); - public static native long mkQuantifierConst(long a0, boolean a1, int a2, int a3, long[] a4, int a5, long[] a6, long a7); - public static native long mkQuantifierConstEx(long a0, boolean a1, int a2, long a3, long a4, int a5, long[] a6, int a7, long[] a8, int a9, long[] a10, long a11); - public static native int getSymbolKind(long a0, long a1); - public static native int getSymbolInt(long a0, long a1); - public static native String getSymbolString(long a0, long a1); - public static native long getSortName(long a0, long a1); - public static native int getSortId(long a0, long a1); - public static native long sortToAst(long a0, long a1); - 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, 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); - public static native int getTupleSortNumFields(long a0, long a1); - public static native long getTupleSortFieldDecl(long a0, long a1, int a2); - public static native int getDatatypeSortNumConstructors(long a0, long a1); - public static native long getDatatypeSortConstructor(long a0, long a1, int a2); - public static native long getDatatypeSortRecognizer(long a0, long a1, int a2); - public static native long getDatatypeSortConstructorAccessor(long a0, long a1, int a2, int a3); - public static native int getRelationArity(long a0, long a1); - public static native long getRelationColumn(long a0, long a1, int a2); - public static native long funcDeclToAst(long a0, long a1); - public static native boolean isEqFuncDecl(long a0, long a1, long a2); - public static native int getFuncDeclId(long a0, long a1); - public static native long getDeclName(long a0, long a1); - public static native int getDeclKind(long a0, long a1); - public static native int getDomainSize(long a0, long a1); - public static native int getArity(long a0, long a1); - public static native long getDomain(long a0, long a1, int a2); - public static native long getRange(long a0, long a1); - public static native int getDeclNumParameters(long a0, long a1); - public static native int getDeclParameterKind(long a0, long a1, int a2); - public static native int getDeclIntParameter(long a0, long a1, int a2); - public static native double getDeclDoubleParameter(long a0, long a1, int a2); - public static native long getDeclSymbolParameter(long a0, long a1, int a2); - public static native long getDeclSortParameter(long a0, long a1, int a2); - public static native long getDeclAstParameter(long a0, long a1, int a2); - public static native long getDeclFuncDeclParameter(long a0, long a1, int a2); - public static native String getDeclRationalParameter(long a0, long a1, int a2); - public static native long appToAst(long a0, long a1); - public static native long getAppDecl(long a0, long a1); - public static native int getAppNumArgs(long a0, long a1); - public static native long getAppArg(long a0, long a1, int a2); - public static native boolean isEqAst(long a0, long a1, long a2); - public static native int getAstId(long a0, long a1); - public static native int getAstHash(long a0, long a1); - public static native long getSort(long a0, long a1); - public static native boolean isWellSorted(long a0, long a1); - public static native int getBoolValue(long a0, long a1); - public static native int getAstKind(long a0, long a1); - public static native boolean isApp(long a0, long a1); - public static native boolean isNumeralAst(long a0, long a1); - public static native boolean isAlgebraicNumber(long a0, long a1); - public static native long toApp(long a0, long a1); - public static native long toFuncDecl(long a0, long a1); - public static native String getNumeralString(long a0, long a1); - 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, 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); - public static native int getPatternNumTerms(long a0, long a1); - public static native long getPattern(long a0, long a1, int a2); - public static native int getIndexValue(long a0, long a1); - public static native boolean isQuantifierForall(long a0, long a1); - public static native int getQuantifierWeight(long a0, long a1); - public static native int getQuantifierNumPatterns(long a0, long a1); - public static native long getQuantifierPatternAst(long a0, long a1, int a2); - public static native int getQuantifierNumNoPatterns(long a0, long a1); - public static native long getQuantifierNoPatternAst(long a0, long a1, int a2); - public static native int getQuantifierNumBound(long a0, long a1); - public static native long getQuantifierBoundName(long a0, long a1, int a2); - public static native long getQuantifierBoundSort(long a0, long a1, int a2); - public static native long getQuantifierBody(long a0, long a1); - public static native long simplify(long a0, long a1); - public static native long simplifyEx(long a0, long a1, long a2); - public static native String simplifyGetHelp(long a0); - public static native long simplifyGetParamDescrs(long a0); - public static native long updateTerm(long a0, long a1, int a2, long[] a3); - public static native long substitute(long a0, long a1, int a2, long[] a3, long[] a4); - public static native long substituteVars(long a0, long a1, int a2, long[] a3); - 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, 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); - public static native long modelGetConstDecl(long a0, long a1, int a2); - public static native int modelGetNumFuncs(long a0, long a1); - public static native long modelGetFuncDecl(long a0, long a1, int a2); - public static native int modelGetNumSorts(long a0, long a1); - public static native long modelGetSort(long a0, long a1, int a2); - public static native long modelGetSortUniverse(long a0, long a1, long a2); - public static native boolean isAsArray(long a0, long a1); - public static native long getAsArrayFuncDecl(long a0, long a1); - public static native void funcInterpIncRef(long a0, long a1); - public static native void funcInterpDecRef(long a0, long a1); - public static native int funcInterpGetNumEntries(long a0, long a1); - public static native long funcInterpGetEntry(long a0, long a1, int a2); - public static native long funcInterpGetElse(long a0, long a1); - public static native int funcInterpGetArity(long a0, long a1); - public static native void funcEntryIncRef(long a0, long a1); - public static native void funcEntryDecRef(long a0, long a1); - public static native long funcEntryGetValue(long a0, long a1); - public static native int funcEntryGetNumArgs(long a0, long a1); - public static native long funcEntryGetArg(long a0, long a1, int a2); - public static native int openLog(String a0); - public static native void appendLog(String a0); - public static native void closeLog(); - public static native void toggleWarningMessages(boolean a0); - public static native void setAstPrintMode(long a0, int a1); - public static native String astToString(long a0, long a1); - public static native String patternToString(long a0, long a1); - public static native String sortToString(long a0, long a1); - public static native String funcDeclToString(long a0, long a1); - public static native String modelToString(long a0, long a1); - public static native String benchmarkToSmtlibString(long a0, String a1, String a2, String a3, String a4, int a5, long[] a6, long a7); - public static native long parseSmtlib2String(long a0, String a1, int a2, long[] a3, long[] a4, int a5, long[] a6, long[] a7); - public static native long parseSmtlib2File(long a0, String a1, int a2, long[] a3, long[] a4, int a5, long[] a6, long[] a7); - public static native void parseSmtlibString(long a0, String a1, int a2, long[] a3, long[] a4, int a5, long[] a6, long[] a7); - public static native void parseSmtlibFile(long a0, String a1, int a2, long[] a3, long[] a4, int a5, long[] a6, long[] a7); - public static native int getSmtlibNumFormulas(long a0); - public static native long getSmtlibFormula(long a0, int a1); - public static native int getSmtlibNumAssumptions(long a0); - public static native long getSmtlibAssumption(long a0, int a1); - public static native int getSmtlibNumDecls(long a0); - public static native long getSmtlibDecl(long a0, int a1); - public static native int getSmtlibNumSorts(long a0); - public static native long getSmtlibSort(long a0, int a1); - public static native String getSmtlibError(long a0); - public static native int getErrorCode(long a0); - 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(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(); - public static native long mkFixedpoint(long a0); - public static native void fixedpointIncRef(long a0, long a1); - public static native void fixedpointDecRef(long a0, long a1); - public static native void fixedpointAddRule(long a0, long a1, long a2, long a3); - public static native void fixedpointAddFact(long a0, long a1, long a2, int a3, int[] a4); - public static native void fixedpointAssert(long a0, long a1, long a2); - public static native int fixedpointQuery(long a0, long a1, long a2); - public static native int fixedpointQueryRelations(long a0, long a1, int a2, long[] a3); - public static native long fixedpointGetAnswer(long a0, long a1); - public static native String fixedpointGetReasonUnknown(long a0, long a1); - public static native void fixedpointUpdateRule(long a0, long a1, long a2, long a3); - public static native int fixedpointGetNumLevels(long a0, long a1, long a2); - public static native long fixedpointGetCoverDelta(long a0, long a1, int a2, long a3); - public static native void fixedpointAddCover(long a0, long a1, int a2, long a3, long a4); - public static native long fixedpointGetStatistics(long a0, long a1); - public static native void fixedpointRegisterRelation(long a0, long a1, long a2); - public static native void fixedpointSetPredicateRepresentation(long a0, long a1, long a2, int a3, long[] a4); - public static native long fixedpointGetRules(long a0, long a1); - public static native long fixedpointGetAssertions(long a0, long a1); - public static native void fixedpointSetParams(long a0, long a1, long a2); - public static native String fixedpointGetHelp(long a0, long a1); - public static native long fixedpointGetParamDescrs(long a0, long a1); - public static native String fixedpointToString(long a0, long a1, int a2, long[] a3); - public static native long fixedpointFromString(long a0, long a1, String a2); - public static native long fixedpointFromFile(long a0, long a1, String a2); - public static native void fixedpointPush(long a0, long a1); - public static native void fixedpointPop(long a0, long a1); - public static native long mkAstVector(long a0); - public static native void astVectorIncRef(long a0, long a1); - public static native void astVectorDecRef(long a0, long a1); - public static native int astVectorSize(long a0, long a1); - public static native long astVectorGet(long a0, long a1, int a2); - public static native void astVectorSet(long a0, long a1, int a2, long a3); - public static native void astVectorResize(long a0, long a1, int a2); - public static native void astVectorPush(long a0, long a1, long a2); - public static native long astVectorTranslate(long a0, long a1, long a2); - public static native String astVectorToString(long a0, long a1); - public static native long mkAstMap(long a0); - public static native void astMapIncRef(long a0, long a1); - public static native void astMapDecRef(long a0, long a1); - public static native boolean astMapContains(long a0, long a1, long a2); - public static native long astMapFind(long a0, long a1, long a2); - public static native void astMapInsert(long a0, long a1, long a2, long a3); - public static native void astMapErase(long a0, long a1, long a2); - public static native void astMapReset(long a0, long a1); - public static native int astMapSize(long a0, long a1); - public static native long astMapKeys(long a0, long a1); - public static native String astMapToString(long a0, long a1); - public static native long mkGoal(long a0, boolean a1, boolean a2, boolean a3); - public static native void goalIncRef(long a0, long a1); - public static native void goalDecRef(long a0, long a1); - public static native int goalPrecision(long a0, long a1); - public static native void goalAssert(long a0, long a1, long a2); - public static native boolean goalInconsistent(long a0, long a1); - public static native int goalDepth(long a0, long a1); - public static native void goalReset(long a0, long a1); - public static native int goalSize(long a0, long a1); - public static native long goalFormula(long a0, long a1, int a2); - public static native int goalNumExprs(long a0, long a1); - public static native boolean goalIsDecidedSat(long a0, long a1); - public static native boolean goalIsDecidedUnsat(long a0, long a1); - public static native long goalTranslate(long a0, long a1, long a2); - public static native String goalToString(long a0, long a1); - public static native long mkTactic(long a0, String a1); - public static native void tacticIncRef(long a0, long a1); - public static native void tacticDecRef(long a0, long a1); - public static native long mkProbe(long a0, String a1); - public static native void probeIncRef(long a0, long a1); - public static native void probeDecRef(long a0, long a1); - public static native long tacticAndThen(long a0, long a1, long a2); - public static native long tacticOrElse(long a0, long a1, long a2); - public static native long tacticParOr(long a0, int a1, long[] a2); - public static native long tacticParAndThen(long a0, long a1, long a2); - public static native long tacticTryFor(long a0, long a1, int a2); - public static native long tacticWhen(long a0, long a1, long a2); - public static native long tacticCond(long a0, long a1, long a2, long a3); - public static native long tacticRepeat(long a0, long a1, int a2); - public static native long tacticSkip(long a0); - public static native long tacticFail(long a0); - public static native long tacticFailIf(long a0, long a1); - public static native long tacticFailIfNotDecided(long a0); - public static native long tacticUsingParams(long a0, long a1, long a2); - public static native long probeConst(long a0, double a1); - public static native long probeLt(long a0, long a1, long a2); - public static native long probeGt(long a0, long a1, long a2); - public static native long probeLe(long a0, long a1, long a2); - public static native long probeGe(long a0, long a1, long a2); - public static native long probeEq(long a0, long a1, long a2); - public static native long probeAnd(long a0, long a1, long a2); - public static native long probeOr(long a0, long a1, long a2); - public static native long probeNot(long a0, long a1); - public static native int getNumTactics(long a0); - public static native String getTacticName(long a0, int a1); - public static native int getNumProbes(long a0); - public static native String getProbeName(long a0, int a1); - public static native String tacticGetHelp(long a0, long a1); - public static native long tacticGetParamDescrs(long a0, long a1); - public static native String tacticGetDescr(long a0, String a1); - public static native String probeGetDescr(long a0, String a1); - public static native double probeApply(long a0, long a1, long a2); - public static native long tacticApply(long a0, long a1, long a2); - public static native long tacticApplyEx(long a0, long a1, long a2, long a3); - public static native void applyResultIncRef(long a0, long a1); - public static native void applyResultDecRef(long a0, long a1); - public static native String applyResultToString(long a0, long a1); - public static native int applyResultGetNumSubgoals(long a0, long a1); - public static native long applyResultGetSubgoal(long a0, long a1, int a2); - public static native long applyResultConvertModel(long a0, long a1, int a2, long a3); - public static native long mkSolver(long a0); - public static native long mkSimpleSolver(long a0); - public static native long mkSolverForLogic(long a0, long a1); - public static native long mkSolverFromTactic(long a0, long a1); - public static native String solverGetHelp(long a0, long a1); - public static native long solverGetParamDescrs(long a0, long a1); - public static native void solverSetParams(long a0, long a1, long a2); - public static native void solverIncRef(long a0, long a1); - public static native void solverDecRef(long a0, long a1); - public static native void solverPush(long a0, long a1); - public static native void solverPop(long a0, long a1, int a2); - public static native void solverReset(long a0, long a1); - public static native int solverGetNumScopes(long a0, long a1); - public static native void solverAssert(long a0, long a1, long a2); - public static native void solverAssertAndTrack(long a0, long a1, long a2, long a3); - public static native long solverGetAssertions(long a0, long a1); - public static native int solverCheck(long a0, long a1); - public static native int solverCheckAssumptions(long a0, long a1, int a2, long[] a3); - public static native long solverGetModel(long a0, long a1); - public static native long solverGetProof(long a0, long a1); - public static native long solverGetUnsatCore(long a0, long a1); - public static native String solverGetReasonUnknown(long a0, long a1); - public static native long solverGetStatistics(long a0, long a1); - public static native String solverToString(long a0, long a1); - public static native String statsToString(long a0, long a1); - public static native void statsIncRef(long a0, long a1); - public static native void statsDecRef(long a0, long a1); - public static native int statsSize(long a0, long a1); - public static native String statsGetKey(long a0, long a1, int a2); - public static native boolean statsIsUint(long a0, long a1, int a2); - public static native boolean statsIsDouble(long a0, long a1, int a2); - public static native int statsGetUintValue(long a0, long a1, int a2); - public static native double statsGetDoubleValue(long a0, long a1, int a2); - public static native long mkInjectiveFunction(long a0, long a1, int a2, long[] a3, long a4); - public static native void setLogic(long a0, String a1); - public static native void push(long a0); - public static native void pop(long a0, int a1); - 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, LongPtr a1); - public static native int check(long a0); - 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); - public static native int getSearchFailure(long a0); - public static native long mkLabel(long a0, long a1, boolean a2, long a3); - public static native long getRelevantLabels(long a0); - public static native long getRelevantLiterals(long a0); - public static native long getGuessedLiterals(long a0); - public static native void delLiterals(long a0, long a1); - public static native int getNumLiterals(long a0, long a1); - public static native long getLabelSymbol(long a0, long a1, int a2); - public static native long getLiteral(long a0, long a1, int a2); - public static native void disableLiteral(long a0, long a1, int a2); - public static native void blockLiterals(long a0, long a1); - public static native int getModelNumConstants(long a0, long a1); - 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, 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, 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); - public static void main(String[] args) { - IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr(); - getVersion(major, minor, build, revision); - System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value); - } -} From 2976fcbfd8d0826f472ba08ccfbe0e3d1aaf21d5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:01:03 +0000 Subject: [PATCH 022/133] Java API: Build system update. Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_project.py | 2 +- scripts/mk_util.py | 23 ++++++++++++++--------- src/api/java/manifest | 2 ++ 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/api/java/manifest diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 862a0915b..57d6ecac0 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -71,7 +71,7 @@ def init_project_def(): static=build_static_lib(), export_files=API_files) add_dot_net_dll('dotnet', ['api_dll'], 'api/dotnet', dll_name='Microsoft.Z3', assembly_info_dir='Properties') - add_java_dll('java', ['api_dll'], 'api/java', dll_name='libz3java', package_name="com.Microsoft.Z3") + add_java_dll('java', ['api_dll'], 'api/java', dll_name='libz3java', package_name="com.microsoft.z3", manifest_file='manifest') add_hlib('cpp', 'api/c++', includes2install=['z3++.h']) set_z3py_dir('api/python') # Examples diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 0f8bea3d1..7eee87d0d 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -925,12 +925,13 @@ class DotNetDLLComponent(Component): class JavaDLLComponent(Component): - def __init__(self, name, dll_name, package_name, path, deps): + def __init__(self, name, dll_name, package_name, manifest_file, path, deps): Component.__init__(self, name, path, deps) if dll_name == None: dll_name = name self.dll_name = dll_name self.package_name = package_name + self.manifest_file = manifest_file def mk_makefile(self, out): if is_java_enabled(): @@ -941,12 +942,16 @@ class JavaDLLComponent(Component): 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): + # for java_file in get_java_files((self.src_dir + "/%s/enumerations") % subdir): # out.write('%s ' % java_file) out.write('\n') - out.write(('\t%s %s/Enumerations/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\")) - out.write(('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\")) - out.write('\tjar cf %s.jar api/java/\n' % self.package_name) + t = ('\t%s %s/enumerations/*.java -d api/java\n' % (JAVAC, self.to_src_dir)) + if IS_WINDOWS: t = t.replace("/","\\") + out.write(t) + t = ('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\") + if IS_WINDOWS: t = t.replace("/","\\") + out.write(t) + out.write('\tjar cfm %s.jar %s/manifest -C api/java .\n' % (self.package_name, self.to_src_dir)) out.write('java: %s.jar\n\n' % self.package_name) def main_component(self): @@ -1086,8 +1091,8 @@ def add_dot_net_dll(name, deps=[], path=None, dll_name=None, assembly_info_dir=N c = DotNetDLLComponent(name, dll_name, path, deps, assembly_info_dir) reg_component(name, c) -def add_java_dll(name, deps=[], path=None, dll_name=None, package_name=None): - c = JavaDLLComponent(name, dll_name, package_name, path, deps) +def add_java_dll(name, deps=[], path=None, dll_name=None, package_name=None, manifest_file=None): + c = JavaDLLComponent(name, dll_name, package_name, manifest_file, path, deps) reg_component(name, c) def add_cpp_example(name, path=None): @@ -1799,7 +1804,7 @@ def mk_z3consts_java(api_files): java = get_component(JAVA_COMPONENT) DeprecatedEnums = [ 'Z3_search_failure' ] - gendir = java.src_dir + "/Enumerations" + gendir = java.src_dir + "/enumerations" if not os.path.exists(gendir): os.mkdir(gendir) @@ -1850,7 +1855,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.Enumerations;\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/src/api/java/manifest b/src/api/java/manifest new file mode 100644 index 000000000..b54445cf2 --- /dev/null +++ b/src/api/java/manifest @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Created-By: 4.3.0 (Microsoft Research LTD.) From 3f548c7610b43104499d9ff64726b3d2c00a7f51 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:01:30 +0000 Subject: [PATCH 023/133] Java API: .gitignored auto-generated files and java class files. Signed-off-by: Christoph M. Wintersteiger --- .gitignore | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 505601597..95ecec810 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ *.cmi *.cmxa ocamlz3 +# Java generated files +*.class +*.jar # Emacs temp files \#*\# # Directories with generated code and documentation @@ -49,5 +52,6 @@ src/api/python/z3consts.py src/api/python/z3core.py src/ast/pattern/database.h src/util/version.h -src/api/java/Z3Native.c -src/api/java/Z3Native.java \ No newline at end of file +src/api/java/Z3Native.cpp +src/api/java/Z3Native.java +src/api/java/enumerations/*.java From 9b9b7a6980f6ed391e8049e89552b4c5435e3297 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:02:15 +0000 Subject: [PATCH 024/133] Java API: .gitignore updated Signed-off-by: Christoph M. Wintersteiger --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 95ecec810..d380fe06f 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,6 @@ src/api/python/z3consts.py src/api/python/z3core.py src/ast/pattern/database.h src/util/version.h -src/api/java/Z3Native.cpp -src/api/java/Z3Native.java +src/api/java/Native.cpp +src/api/java/Native.java src/api/java/enumerations/*.java From eee3bf886d1def967b386b67b8e7237d82ded96b Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:09:30 +0000 Subject: [PATCH 025/133] Java API: package renaming. Signed-off-by: Christoph M. Wintersteiger --- src/api/java/AST.java | 4 ++-- src/api/java/ASTDecRefQueue.java | 2 +- src/api/java/ASTMap.java | 2 +- src/api/java/ASTVector.java | 2 +- src/api/java/AlgebraicNum.java | 2 +- src/api/java/ApplyResult.java | 2 +- src/api/java/ApplyResultDecRefQueue.java | 2 +- src/api/java/ArithExpr.java | 2 +- src/api/java/ArithSort.java | 2 +- src/api/java/ArrayExpr.java | 2 +- src/api/java/ArraySort.java | 2 +- src/api/java/AstMapDecRefQueue.java | 2 +- src/api/java/AstVectorDecRefQueue.java | 2 +- src/api/java/BitVecExpr.java | 2 +- src/api/java/BitVecNum.java | 2 +- src/api/java/BitVecSort.java | 2 +- src/api/java/BoolExpr.java | 2 +- src/api/java/BoolSort.java | 2 +- src/api/java/Constructor.java | 2 +- src/api/java/ConstructorList.java | 2 +- src/api/java/Context.java | 4 ++-- src/api/java/DatatypeExpr.java | 2 +- src/api/java/DatatypeSort.java | 2 +- src/api/java/EnumSort.java | 2 +- src/api/java/Expr.java | 4 ++-- src/api/java/FiniteDomainSort.java | 2 +- src/api/java/Fixedpoint.java | 4 ++-- src/api/java/FixedpointDecRefQueue.java | 2 +- src/api/java/FuncDecl.java | 4 ++-- src/api/java/FuncInterp.java | 2 +- src/api/java/FuncInterpDecRefQueue.java | 2 +- src/api/java/FuncInterpEntryDecRefQueue.java | 2 +- src/api/java/Goal.java | 4 ++-- src/api/java/GoalDecRefQueue.java | 2 +- src/api/java/IDecRefQueue.java | 2 +- src/api/java/IDisposable.java | 2 +- src/api/java/IntExpr.java | 2 +- src/api/java/IntNum.java | 2 +- src/api/java/IntSort.java | 2 +- src/api/java/IntSymbol.java | 4 ++-- src/api/java/ListSort.java | 2 +- src/api/java/Log.java | 2 +- src/api/java/Model.java | 4 ++-- src/api/java/ModelDecRefQueue.java | 2 +- src/api/java/ParamDescrs.java | 4 ++-- src/api/java/ParamDescrsDecRefQueue.java | 2 +- src/api/java/Params.java | 2 +- src/api/java/ParamsDecRefQueue.java | 2 +- src/api/java/Pattern.java | 2 +- src/api/java/Probe.java | 2 +- src/api/java/ProbeDecRefQueue.java | 2 +- src/api/java/Quantifier.java | 4 ++-- src/api/java/RatNum.java | 2 +- src/api/java/RealExpr.java | 2 +- src/api/java/RealSort.java | 2 +- src/api/java/RelationSort.java | 2 +- src/api/java/SetSort.java | 2 +- src/api/java/Solver.java | 4 ++-- src/api/java/SolverDecRefQueue.java | 2 +- src/api/java/Sort.java | 4 ++-- src/api/java/Statistics.java | 2 +- src/api/java/StatisticsDecRefQueue.java | 2 +- src/api/java/Status.java | 2 +- src/api/java/StringSymbol.java | 4 ++-- src/api/java/Symbol.java | 4 ++-- src/api/java/Tactic.java | 2 +- src/api/java/TacticDecRefQueue.java | 2 +- src/api/java/TupleSort.java | 2 +- src/api/java/UninterpretedSort.java | 2 +- src/api/java/Version.java | 2 +- src/api/java/Z3Exception.java | 2 +- src/api/java/Z3Object.java | 2 +- src/api/java/mk_java.py | 11 +++++++++-- 73 files changed, 95 insertions(+), 88 deletions(-) diff --git a/src/api/java/AST.java b/src/api/java/AST.java index e8017e020..f30e67673 100644 --- a/src/api/java/AST.java +++ b/src/api/java/AST.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * The abstract syntax tree (AST) class. diff --git a/src/api/java/ASTDecRefQueue.java b/src/api/java/ASTDecRefQueue.java index 1672dc14c..720e90a4c 100644 --- a/src/api/java/ASTDecRefQueue.java +++ b/src/api/java/ASTDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; public class ASTDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/ASTMap.java b/src/api/java/ASTMap.java index 51d4e02bb..a2d334b0e 100644 --- a/src/api/java/ASTMap.java +++ b/src/api/java/ASTMap.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Map from AST to AST diff --git a/src/api/java/ASTVector.java b/src/api/java/ASTVector.java index 7451e93b3..b93c9f4bd 100644 --- a/src/api/java/ASTVector.java +++ b/src/api/java/ASTVector.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Vectors of ASTs. diff --git a/src/api/java/AlgebraicNum.java b/src/api/java/AlgebraicNum.java index 2ed2d8315..9aee64e65 100644 --- a/src/api/java/AlgebraicNum.java +++ b/src/api/java/AlgebraicNum.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Algebraic numbers diff --git a/src/api/java/ApplyResult.java b/src/api/java/ApplyResult.java index afcc3f0f7..feb8dc5ea 100644 --- a/src/api/java/ApplyResult.java +++ b/src/api/java/ApplyResult.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * ApplyResult objects represent the result of an application of a tactic to a diff --git a/src/api/java/ApplyResultDecRefQueue.java b/src/api/java/ApplyResultDecRefQueue.java index 98d727522..96d18bef1 100644 --- a/src/api/java/ApplyResultDecRefQueue.java +++ b/src/api/java/ApplyResultDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ApplyResultDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/ArithExpr.java b/src/api/java/ArithExpr.java index c15cf212e..c429f2322 100644 --- a/src/api/java/ArithExpr.java +++ b/src/api/java/ArithExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) * **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Arithmetic expressions (int/real) diff --git a/src/api/java/ArithSort.java b/src/api/java/ArithSort.java index bcaf5a88f..5e1780539 100644 --- a/src/api/java/ArithSort.java +++ b/src/api/java/ArithSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * An arithmetic sort, i.e., Int or Real. diff --git a/src/api/java/ArrayExpr.java b/src/api/java/ArrayExpr.java index 7082bc64b..b3bbb8d75 100644 --- a/src/api/java/ArrayExpr.java +++ b/src/api/java/ArrayExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** diff --git a/src/api/java/ArraySort.java b/src/api/java/ArraySort.java index 2b7979468..cd126443c 100644 --- a/src/api/java/ArraySort.java +++ b/src/api/java/ArraySort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Array sorts. diff --git a/src/api/java/AstMapDecRefQueue.java b/src/api/java/AstMapDecRefQueue.java index a6232866f..23cb3c6fd 100644 --- a/src/api/java/AstMapDecRefQueue.java +++ b/src/api/java/AstMapDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ASTMapDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/AstVectorDecRefQueue.java b/src/api/java/AstVectorDecRefQueue.java index 013cc5351..4496c092e 100644 --- a/src/api/java/AstVectorDecRefQueue.java +++ b/src/api/java/AstVectorDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ASTVectorDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/BitVecExpr.java b/src/api/java/BitVecExpr.java index cd64cfc82..fb0f4d72a 100644 --- a/src/api/java/BitVecExpr.java +++ b/src/api/java/BitVecExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Bit-vector expressions diff --git a/src/api/java/BitVecNum.java b/src/api/java/BitVecNum.java index b1f12fae5..10dad6423 100644 --- a/src/api/java/BitVecNum.java +++ b/src/api/java/BitVecNum.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.math.BigInteger; diff --git a/src/api/java/BitVecSort.java b/src/api/java/BitVecSort.java index 8ce31e7bb..e8cd0af27 100644 --- a/src/api/java/BitVecSort.java +++ b/src/api/java/BitVecSort.java @@ -3,7 +3,7 @@ * w/ further modifications by: * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Bit-vector sorts. diff --git a/src/api/java/BoolExpr.java b/src/api/java/BoolExpr.java index ddabc81d9..40786f76d 100644 --- a/src/api/java/BoolExpr.java +++ b/src/api/java/BoolExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Boolean expressions diff --git a/src/api/java/BoolSort.java b/src/api/java/BoolSort.java index 501467bfc..03711289a 100644 --- a/src/api/java/BoolSort.java +++ b/src/api/java/BoolSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * A Boolean sort. diff --git a/src/api/java/Constructor.java b/src/api/java/Constructor.java index 146c7daa0..3ddb8664b 100644 --- a/src/api/java/Constructor.java +++ b/src/api/java/Constructor.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Constructors are used for datatype sorts. diff --git a/src/api/java/ConstructorList.java b/src/api/java/ConstructorList.java index a158240eb..857ec3cf0 100644 --- a/src/api/java/ConstructorList.java +++ b/src/api/java/ConstructorList.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Lists of constructors diff --git a/src/api/java/Context.java b/src/api/java/Context.java index f728f1b25..ef82eba35 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -4,10 +4,10 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.util.*; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * The main interaction with Z3 happens via the Context. diff --git a/src/api/java/DatatypeExpr.java b/src/api/java/DatatypeExpr.java index c29507163..63cb02f80 100644 --- a/src/api/java/DatatypeExpr.java +++ b/src/api/java/DatatypeExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Datatype expressions diff --git a/src/api/java/DatatypeSort.java b/src/api/java/DatatypeSort.java index 30e9f9d4c..1ff123706 100644 --- a/src/api/java/DatatypeSort.java +++ b/src/api/java/DatatypeSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Datatype sorts. diff --git a/src/api/java/EnumSort.java b/src/api/java/EnumSort.java index 0c4468b9c..8c9eeb16a 100644 --- a/src/api/java/EnumSort.java +++ b/src/api/java/EnumSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Enumeration sorts. diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index 8442acf6a..4bc7f6842 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /* using System; */ diff --git a/src/api/java/FiniteDomainSort.java b/src/api/java/FiniteDomainSort.java index f9f3820af..0183bec60 100644 --- a/src/api/java/FiniteDomainSort.java +++ b/src/api/java/FiniteDomainSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Finite domain sorts. diff --git a/src/api/java/Fixedpoint.java b/src/api/java/Fixedpoint.java index 3ad42c0e9..860629eec 100644 --- a/src/api/java/Fixedpoint.java +++ b/src/api/java/Fixedpoint.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Object for managing fixedpoints diff --git a/src/api/java/FixedpointDecRefQueue.java b/src/api/java/FixedpointDecRefQueue.java index 7ed457bed..3d436eafb 100644 --- a/src/api/java/FixedpointDecRefQueue.java +++ b/src/api/java/FixedpointDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class FixedpointDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/FuncDecl.java b/src/api/java/FuncDecl.java index 79fc457f8..d64ce3cf9 100644 --- a/src/api/java/FuncDecl.java +++ b/src/api/java/FuncDecl.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Function declarations. diff --git a/src/api/java/FuncInterp.java b/src/api/java/FuncInterp.java index 8c25508e7..25d3fe1c8 100644 --- a/src/api/java/FuncInterp.java +++ b/src/api/java/FuncInterp.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * A function interpretation is represented as a finite map and an 'else' value. diff --git a/src/api/java/FuncInterpDecRefQueue.java b/src/api/java/FuncInterpDecRefQueue.java index 968a642c8..e41551b66 100644 --- a/src/api/java/FuncInterpDecRefQueue.java +++ b/src/api/java/FuncInterpDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class FuncInterpDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/FuncInterpEntryDecRefQueue.java b/src/api/java/FuncInterpEntryDecRefQueue.java index 8d76f597c..8d642217f 100644 --- a/src/api/java/FuncInterpEntryDecRefQueue.java +++ b/src/api/java/FuncInterpEntryDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class FuncInterpEntryDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Goal.java b/src/api/java/Goal.java index f5d853fd5..d4b242a03 100644 --- a/src/api/java/Goal.java +++ b/src/api/java/Goal.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * A goal (aka problem). A goal is essentially a set of formulas, that can be diff --git a/src/api/java/GoalDecRefQueue.java b/src/api/java/GoalDecRefQueue.java index ac49d2484..9bd2b79db 100644 --- a/src/api/java/GoalDecRefQueue.java +++ b/src/api/java/GoalDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class GoalDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/IDecRefQueue.java b/src/api/java/IDecRefQueue.java index 1d1ef2c04..e4eec7f4f 100644 --- a/src/api/java/IDecRefQueue.java +++ b/src/api/java/IDecRefQueue.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.util.*; diff --git a/src/api/java/IDisposable.java b/src/api/java/IDisposable.java index ffae8ee33..02bbb0ad5 100644 --- a/src/api/java/IDisposable.java +++ b/src/api/java/IDisposable.java @@ -17,7 +17,7 @@ Notes: --*/ -package com.Microsoft.Z3; +package com.microsoft.z3; public class IDisposable { diff --git a/src/api/java/IntExpr.java b/src/api/java/IntExpr.java index 4b9df2b99..78cc15f90 100644 --- a/src/api/java/IntExpr.java +++ b/src/api/java/IntExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Int expressions diff --git a/src/api/java/IntNum.java b/src/api/java/IntNum.java index 7db80c7d9..aecf68ee7 100644 --- a/src/api/java/IntNum.java +++ b/src/api/java/IntNum.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.math.BigInteger; diff --git a/src/api/java/IntSort.java b/src/api/java/IntSort.java index c07696216..44e48ccd1 100644 --- a/src/api/java/IntSort.java +++ b/src/api/java/IntSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * An Integer sort diff --git a/src/api/java/IntSymbol.java b/src/api/java/IntSymbol.java index ca5653b4b..3dbdfaf73 100644 --- a/src/api/java/IntSymbol.java +++ b/src/api/java/IntSymbol.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Numbered symbols diff --git a/src/api/java/ListSort.java b/src/api/java/ListSort.java index e00d185ac..98292b6ae 100644 --- a/src/api/java/ListSort.java +++ b/src/api/java/ListSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * List sorts. diff --git a/src/api/java/Log.java b/src/api/java/Log.java index 388bc836f..bd85d021c 100644 --- a/src/api/java/Log.java +++ b/src/api/java/Log.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Interaction logging for Z3. Note that this is a global, static log diff --git a/src/api/java/Model.java b/src/api/java/Model.java index e15af9d0f..2616f26be 100644 --- a/src/api/java/Model.java +++ b/src/api/java/Model.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * A Model contains interpretations (assignments) of constants and functions. diff --git a/src/api/java/ModelDecRefQueue.java b/src/api/java/ModelDecRefQueue.java index 52c035914..89a0bbd78 100644 --- a/src/api/java/ModelDecRefQueue.java +++ b/src/api/java/ModelDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ModelDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/ParamDescrs.java b/src/api/java/ParamDescrs.java index ba2ed6e94..11a8ee8b2 100644 --- a/src/api/java/ParamDescrs.java +++ b/src/api/java/ParamDescrs.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * A ParamDescrs describes a set of parameters. diff --git a/src/api/java/ParamDescrsDecRefQueue.java b/src/api/java/ParamDescrsDecRefQueue.java index 82d76c843..f36d302ba 100644 --- a/src/api/java/ParamDescrsDecRefQueue.java +++ b/src/api/java/ParamDescrsDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ParamDescrsDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Params.java b/src/api/java/Params.java index b1bfdd516..33ca34a23 100644 --- a/src/api/java/Params.java +++ b/src/api/java/Params.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * A ParameterSet represents a configuration in the form of Symbol/value pairs. diff --git a/src/api/java/ParamsDecRefQueue.java b/src/api/java/ParamsDecRefQueue.java index 88e40fb23..27fa3cadd 100644 --- a/src/api/java/ParamsDecRefQueue.java +++ b/src/api/java/ParamsDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ParamsDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Pattern.java b/src/api/java/Pattern.java index 017aead97..47f4a7c6a 100644 --- a/src/api/java/Pattern.java +++ b/src/api/java/Pattern.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Patterns comprise a list of terms. The list should be non-empty. If the list diff --git a/src/api/java/Probe.java b/src/api/java/Probe.java index a0fcfd3db..80ac55b70 100644 --- a/src/api/java/Probe.java +++ b/src/api/java/Probe.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Probes are used to inspect a goal (aka problem) and collect information that diff --git a/src/api/java/ProbeDecRefQueue.java b/src/api/java/ProbeDecRefQueue.java index 2c3cd9783..01d2e3852 100644 --- a/src/api/java/ProbeDecRefQueue.java +++ b/src/api/java/ProbeDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class ProbeDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Quantifier.java b/src/api/java/Quantifier.java index 2b7eba0d9..a0b5c9e6a 100644 --- a/src/api/java/Quantifier.java +++ b/src/api/java/Quantifier.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Quantifier expressions. diff --git a/src/api/java/RatNum.java b/src/api/java/RatNum.java index 7a762b361..045416973 100644 --- a/src/api/java/RatNum.java +++ b/src/api/java/RatNum.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.math.BigInteger; /** diff --git a/src/api/java/RealExpr.java b/src/api/java/RealExpr.java index 9f2590fe1..20d603d9a 100644 --- a/src/api/java/RealExpr.java +++ b/src/api/java/RealExpr.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Real expressions diff --git a/src/api/java/RealSort.java b/src/api/java/RealSort.java index 0b7f600b2..ce7295ead 100644 --- a/src/api/java/RealSort.java +++ b/src/api/java/RealSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * A real sort diff --git a/src/api/java/RelationSort.java b/src/api/java/RelationSort.java index 1d0371fd1..2880eadc9 100644 --- a/src/api/java/RelationSort.java +++ b/src/api/java/RelationSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Relation sorts. diff --git a/src/api/java/SetSort.java b/src/api/java/SetSort.java index c211a597d..ffeebfd3d 100644 --- a/src/api/java/SetSort.java +++ b/src/api/java/SetSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Set sorts. diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java index 613479053..703f22be4 100644 --- a/src/api/java/Solver.java +++ b/src/api/java/Solver.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Solvers. diff --git a/src/api/java/SolverDecRefQueue.java b/src/api/java/SolverDecRefQueue.java index 337c41898..11a670732 100644 --- a/src/api/java/SolverDecRefQueue.java +++ b/src/api/java/SolverDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class SolverDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Sort.java b/src/api/java/Sort.java index 5cb76e17a..9a6f8aa9a 100644 --- a/src/api/java/Sort.java +++ b/src/api/java/Sort.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * The Sort class implements type information for ASTs. diff --git a/src/api/java/Statistics.java b/src/api/java/Statistics.java index 81a75fd48..07a573940 100644 --- a/src/api/java/Statistics.java +++ b/src/api/java/Statistics.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Objects of this class track statistical information about solvers. diff --git a/src/api/java/StatisticsDecRefQueue.java b/src/api/java/StatisticsDecRefQueue.java index 4337d366d..0bbd7914a 100644 --- a/src/api/java/StatisticsDecRefQueue.java +++ b/src/api/java/StatisticsDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class StatisticsDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/Status.java b/src/api/java/Status.java index 4f2d44e9d..117618426 100644 --- a/src/api/java/Status.java +++ b/src/api/java/Status.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Status values. diff --git a/src/api/java/StringSymbol.java b/src/api/java/StringSymbol.java index 34e38c3c9..81ada78a4 100644 --- a/src/api/java/StringSymbol.java +++ b/src/api/java/StringSymbol.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Named symbols diff --git a/src/api/java/Symbol.java b/src/api/java/Symbol.java index 1576e17e1..526960e88 100644 --- a/src/api/java/Symbol.java +++ b/src/api/java/Symbol.java @@ -4,9 +4,9 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; -import com.Microsoft.Z3.Enumerations.*; +import com.microsoft.z3.enumerations.*; /** * Symbols are used to name several term and type constructors. diff --git a/src/api/java/Tactic.java b/src/api/java/Tactic.java index 78c19a298..90e728087 100644 --- a/src/api/java/Tactic.java +++ b/src/api/java/Tactic.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Tactics are the basic building block for creating custom solvers for specific diff --git a/src/api/java/TacticDecRefQueue.java b/src/api/java/TacticDecRefQueue.java index 1b3bd5a03..ff0e27b5c 100644 --- a/src/api/java/TacticDecRefQueue.java +++ b/src/api/java/TacticDecRefQueue.java @@ -3,7 +3,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; class TacticDecRefQueue extends IDecRefQueue { diff --git a/src/api/java/TupleSort.java b/src/api/java/TupleSort.java index d72d0b128..f05885f35 100644 --- a/src/api/java/TupleSort.java +++ b/src/api/java/TupleSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Tuple sorts. diff --git a/src/api/java/UninterpretedSort.java b/src/api/java/UninterpretedSort.java index 4967b73f7..bc062cb50 100644 --- a/src/api/java/UninterpretedSort.java +++ b/src/api/java/UninterpretedSort.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Uninterpreted Sorts diff --git a/src/api/java/Version.java b/src/api/java/Version.java index 7b20a5ff8..51fad896c 100644 --- a/src/api/java/Version.java +++ b/src/api/java/Version.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Version information. Note that this class is static. diff --git a/src/api/java/Z3Exception.java b/src/api/java/Z3Exception.java index 6de94a5cf..ae7046c90 100644 --- a/src/api/java/Z3Exception.java +++ b/src/api/java/Z3Exception.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; import java.lang.Exception; diff --git a/src/api/java/Z3Object.java b/src/api/java/Z3Object.java index 522423e01..e5e4af3c2 100644 --- a/src/api/java/Z3Object.java +++ b/src/api/java/Z3Object.java @@ -4,7 +4,7 @@ * @author Christoph M. Wintersteiger (cwinter) **/ -package com.Microsoft.Z3; +package com.microsoft.z3; /** * Internal base class for interfacing with native Z3 objects. Should not be diff --git a/src/api/java/mk_java.py b/src/api/java/mk_java.py index 1c59fc957..87f3e274a 100644 --- a/src/api/java/mk_java.py +++ b/src/api/java/mk_java.py @@ -1,11 +1,18 @@ -############################################ +###################################################### # Copyright (c) 2012 Microsoft Corporation # # Auxiliary scripts for generating Java bindings # from the managed API. # # Author: Christoph M. Wintersteiger (cwinter) -############################################ +###################################################### + + +### +# DO NOT USE THIS SCRIPT! +# This script creates a rough draft of a Java API from +# the managed API, but does not automated the process. +### CS="../dotnet/" EXT=".cs" From a74088fac06a0446ec3295b0e8ad8542f24493dc Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:34:57 +0000 Subject: [PATCH 026/133] Java API: Build system updates. Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 6a3b73c15..9ee0d8a4b 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -56,6 +56,8 @@ JAVA_COMPONENT='java' CPP_COMPONENT='cpp' ##################### IS_WINDOWS=False +IS_LINUX=False +IS_OSX=False VERBOSE=True DEBUG_MODE=False SHOW_CPPS = True @@ -75,7 +77,13 @@ PREFIX='/usr' GMP=False def is_windows(): - return IS_WINDOWS + return IS_WINDOWS + +def is_linux(): + return IS_LINUX + +def is_osx(): + return IS_OSX def unix_path2dos(path): return string.join(path.split('/'), '\\') @@ -317,6 +325,11 @@ if os.name == 'nt': SHOW_CPPS=False # Enable .Net bindings by default on windows DOTNET_ENABLED=True +elif os.name == 'posix': + if os.uname()[0] == 'Darwin': + IS_OSX=True + elif os.uname()[0] == 'Linux': + IS_LINUX=True def display_help(exit_code): print "mk_make.py: Z3 Makefile generator\n" @@ -963,8 +976,15 @@ class JavaDLLComponent(Component): if is_java_enabled(): 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') + t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Native$(OBJ_EXT) -I"%s/include" -I"%s/include/PLATFORM" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir) + if IS_OSX: + t.replace('PLATFORM', 'darwin') + elif IS_LINUX: + t.replace('PLATFORM', 'linux') + else: + t.replace('PLATFORM', 'win32') + out.write(t) + out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3$(SO_EXT)\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) @@ -972,10 +992,10 @@ class JavaDLLComponent(Component): # out.write('%s ' % java_file) out.write('\n') t = ('\t%s %s/enumerations/*.java -d api/java\n' % (JAVAC, self.to_src_dir)) - if IS_WINDOWS: t = t.replace("/","\\") + if IS_WINDOWS: t = t.replace('/','\\') out.write(t) - t = ('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)).replace("/","\\") - if IS_WINDOWS: t = t.replace("/","\\") + t = ('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)) + if IS_WINDOWS: t = t.replace('/','\\') out.write(t) out.write('\tjar cfm %s.jar %s/manifest -C api/java .\n' % (self.package_name, self.to_src_dir)) out.write('java: %s.jar\n\n' % self.package_name) From 9424f61ee35be23feaf19a8a3677c848fbfbfa37 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:38:19 +0000 Subject: [PATCH 027/133] Java API: build bugfix Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 9ee0d8a4b..87f32364c 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -978,11 +978,11 @@ class JavaDLLComponent(Component): out.write('libz3java$(SO_EXT): libz3$(SO_EXT) ../src/api/java/Native.cpp\n') t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Native$(OBJ_EXT) -I"%s/include" -I"%s/include/PLATFORM" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir) if IS_OSX: - t.replace('PLATFORM', 'darwin') + t = t.replace('PLATFORM', 'darwin') elif IS_LINUX: - t.replace('PLATFORM', 'linux') + t = t.replace('PLATFORM', 'linux') else: - t.replace('PLATFORM', 'win32') + t = t.replace('PLATFORM', 'win32') out.write(t) out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3$(SO_EXT)\n') out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name) From 2dab8147f1788f535c6a282d5fd00ae6973316cd Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 19:58:52 +0000 Subject: [PATCH 028/133] Java API: build system bugfixes Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 87f32364c..6d2c1f0af 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -974,9 +974,10 @@ class JavaDLLComponent(Component): def mk_makefile(self, out): if is_java_enabled(): + mk_dir(BUILD_DIR+'/api/java/classes') dllfile = '%s$(SO_EXT)' % self.dll_name - out.write('libz3java$(SO_EXT): libz3$(SO_EXT) ../src/api/java/Native.cpp\n') - t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)Native$(OBJ_EXT) -I"%s/include" -I"%s/include/PLATFORM" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir) + out.write('libz3java$(SO_EXT): libz3$(SO_EXT) %s/Native.cpp\n' % self.to_src_dir) + t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)api/java/Native$(OBJ_EXT) -I"%s/include" -I"%s/include/PLATFORM" -I%s %s/Native.cpp\n' % (JAVA_HOME, JAVA_HOME, get_component('api').to_src_dir, self.to_src_dir) if IS_OSX: t = t.replace('PLATFORM', 'darwin') elif IS_LINUX: @@ -984,20 +985,20 @@ class JavaDLLComponent(Component): else: t = t.replace('PLATFORM', 'win32') out.write(t) - out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3$(SO_EXT)\n') + out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3$(LIB_EXT)\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') - t = ('\t%s %s/enumerations/*.java -d api/java\n' % (JAVAC, self.to_src_dir)) + t = ('\t%s %s/enumerations/*.java -d api/java/classes\n' % (JAVAC, self.to_src_dir)) if IS_WINDOWS: t = t.replace('/','\\') out.write(t) - t = ('\t%s -cp api/java %s/*.java -d api/java\n' % (JAVAC, self.to_src_dir)) + t = ('\t%s -cp api/java/classes %s/*.java -d api/java/classes\n' % (JAVAC, self.to_src_dir)) if IS_WINDOWS: t = t.replace('/','\\') out.write(t) - out.write('\tjar cfm %s.jar %s/manifest -C api/java .\n' % (self.package_name, self.to_src_dir)) + out.write('\tjar cfm %s.jar %s/manifest -C api/java/classes .\n' % (self.package_name, self.to_src_dir)) out.write('java: %s.jar\n\n' % self.package_name) def main_component(self): From a9883e972fd397c42f2a1f40d85c9f7c167015f5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 23:06:35 +0000 Subject: [PATCH 029/133] Java API: Bugfixes and Example. Signed-off-by: Christoph M. Wintersteiger --- examples/java/JavaExample.java | 2219 ++++++++++++++++++++++++++++++++ examples/java/README | 10 + scripts/mk_project.py | 1 + scripts/mk_util.py | 28 +- src/api/java/Context.java | 24 +- src/api/java/EnumSort.java | 2 +- src/api/java/Expr.java | 15 +- src/api/java/FuncDecl.java | 22 +- src/api/java/Goal.java | 17 +- src/api/java/Log.java | 10 +- src/api/java/Solver.java | 30 +- src/api/java/Tactic.java | 9 + src/api/java/Version.java | 16 +- 13 files changed, 2372 insertions(+), 31 deletions(-) create mode 100644 examples/java/JavaExample.java create mode 100644 examples/java/README diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java new file mode 100644 index 000000000..a721c53d2 --- /dev/null +++ b/examples/java/JavaExample.java @@ -0,0 +1,2219 @@ +/*++ + Copyright (c) 2012 Microsoft Corporation + +Module Name: + + Program.java + +Abstract: + + Z3 Java API: Example program + +Author: + + Christoph Wintersteiger (cwinter) 2012-11-27 + +Notes: + +--*/ + +import java.util.*; + +import com.microsoft.z3.*; + +class JavaExample +{ + @SuppressWarnings("serial") + class TestFailedException extends Exception + { + public TestFailedException() + { + super("Check FAILED"); + } + }; + + // / Create axiom: function f is injective in the i-th argument. + + // / + // / The following axiom is produced: + // / + // / forall (x_0, ..., x_n) finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i + // / + // / Where, finvis a fresh function declaration. + + public BoolExpr InjAxiom(Context ctx, FuncDecl f, int i) throws Z3Exception + { + Sort[] domain = f.Domain(); + int sz = f.DomainSize(); + + if (i >= sz) + { + System.out.println("failed to create inj axiom"); + return null; + } + + /* declare the i-th inverse of f: finv */ + Sort finv_domain = f.Range(); + Sort finv_range = domain[i]; + FuncDecl finv = ctx.MkFuncDecl("f_fresh", finv_domain, finv_range); + + /* allocate temporary arrays */ + Expr[] xs = new Expr[sz]; + Symbol[] names = new Symbol[sz]; + Sort[] types = new Sort[sz]; + + /* fill types, names and xs */ + + for (int j = 0; j < sz; j++) + { + types[j] = domain[j]; + names[j] = ctx.MkSymbol("x_" + Integer.toString(j)); + xs[j] = ctx.MkBound(j, types[j]); + } + Expr x_i = xs[i]; + + /* create f(x_0, ..., x_i, ..., x_{n-1}) */ + Expr fxs = f.Apply(xs); + + /* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */ + Expr finv_fxs = finv.Apply(fxs); + + /* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */ + Expr eq = ctx.MkEq(finv_fxs, x_i); + + /* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */ + Pattern p = ctx.MkPattern(new Expr[] { fxs }); + + /* create & assert quantifier */ + BoolExpr q = ctx.MkForall(types, /* types of quantified variables */ + names, /* names of quantified variables */ + eq, 1, new Pattern[] { p } /* patterns */, null, null, null); + + return q; + } + + // / Create axiom: function f is injective in the i-th argument. + + // / + // / The following axiom is produced: + // / + // / forall (x_0, ..., x_n) finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i + // / + // / Where, finvis a fresh function declaration. + + public BoolExpr InjAxiomAbs(Context ctx, FuncDecl f, int i) + throws Z3Exception + { + Sort[] domain = f.Domain(); + int sz = f.DomainSize(); + + if (i >= sz) + { + System.out.println("failed to create inj axiom"); + return null; + } + + /* declare the i-th inverse of f: finv */ + Sort finv_domain = f.Range(); + Sort finv_range = domain[i]; + FuncDecl finv = ctx.MkFuncDecl("f_fresh", finv_domain, finv_range); + + /* allocate temporary arrays */ + Expr[] xs = new Expr[sz]; + + /* fill types, names and xs */ + for (int j = 0; j < sz; j++) + { + xs[j] = ctx.MkConst("x_" + Integer.toString(j), domain[j]); + } + Expr x_i = xs[i]; + + /* create f(x_0, ..., x_i, ..., x_{n-1}) */ + Expr fxs = f.Apply(xs); + + /* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */ + Expr finv_fxs = finv.Apply(fxs); + + /* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */ + Expr eq = ctx.MkEq(finv_fxs, x_i); + + /* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */ + Pattern p = ctx.MkPattern(new Expr[] { fxs }); + + /* create & assert quantifier */ + BoolExpr q = ctx.MkForall(xs, /* types of quantified variables */ + eq, /* names of quantified variables */ + 1, new Pattern[] { p } /* patterns */, null, null, null); + + return q; + } + + // / Assert the axiom: function f is commutative. + + // / + // / This example uses the SMT-LIB parser to simplify the axiom + // construction. + // / + private BoolExpr CommAxiom(Context ctx, FuncDecl f) throws Exception + { + Sort t = f.Range(); + Sort[] dom = f.Domain(); + + if (dom.length != 2 || !t.Equals(dom[0]) || !t.Equals(dom[1])) + { + System.out.println(Integer.toString(dom.length) + " " + + dom[0].toString() + " " + dom[1].toString() + " " + + t.toString()); + throw new Exception( + "function must be binary, and argument types must be equal to return type"); + } + + String bench = "(benchmark comm :formula (forall (x " + t.Name() + + ") (y " + t.Name() + ") (= (" + f.Name() + " x y) (" + + f.Name() + " y x))))"; + ctx.ParseSMTLIBString(bench, new Symbol[] { t.Name() }, + new Sort[] { t }, new Symbol[] { f.Name() }, + new FuncDecl[] { f }); + return ctx.SMTLIBFormulas()[0]; + } + + // / "Hello world" example: create a Z3 logical context, and delete it. + + public void SimpleExample() throws Z3Exception + { + System.out.println("SimpleExample"); + + { + Context ctx = new Context(); + /* do something with the context */ + + /* be kind to dispose manually and not wait for the GC. */ + ctx.Dispose(); + } + } + + Model Check(Context ctx, BoolExpr f, Status sat) throws Z3Exception, + TestFailedException + { + Solver s = ctx.MkSolver(); + s.Assert(f); + if (s.Check() != sat) + throw new TestFailedException(); + if (sat == Status.SATISFIABLE) + return s.Model(); + else + return null; + } + + void SolveTactical(Context ctx, Tactic t, Goal g, Status sat) + throws Z3Exception, TestFailedException + { + Solver s = ctx.MkSolver(t); + System.out.println("\nTactical solver: " + s); + + for (BoolExpr a : g.Formulas()) + s.Assert(a); + System.out.println("Solver: " + s); + + if (s.Check() != sat) + throw new TestFailedException(); + } + + ApplyResult ApplyTactic(Context ctx, Tactic t, Goal g) throws Z3Exception + { + System.out.println("\nGoal: " + g); + + ApplyResult res = t.Apply(g); + System.out.println("Application result: " + res); + + Status q = Status.UNKNOWN; + for (Goal sg : res.Subgoals()) + if (sg.IsDecidedSat()) + q = Status.SATISFIABLE; + else if (sg.IsDecidedUnsat()) + q = Status.UNSATISFIABLE; + + switch (q) + { + case UNKNOWN: + System.out.println("Tactic result: Undecided"); + break; + case SATISFIABLE: + System.out.println("Tactic result: SAT"); + break; + case UNSATISFIABLE: + System.out.println("Tactic result: UNSAT"); + break; + } + + return res; + } + + void Prove(Context ctx, BoolExpr f) throws Z3Exception, TestFailedException + { + BoolExpr[] assumptions = new BoolExpr[0]; + Prove(ctx, f, assumptions); + } + + void Prove(Context ctx, BoolExpr f, BoolExpr assumption) + throws Z3Exception, TestFailedException + { + BoolExpr[] assumptions = { assumption }; + Prove(ctx, f, assumptions); + } + + void Prove(Context ctx, BoolExpr f, BoolExpr[] assumptions) + throws Z3Exception, TestFailedException + { + System.out.println("Proving: " + f); + Solver s = ctx.MkSolver(); + for (BoolExpr a : assumptions) + s.Assert(a); + s.Assert(ctx.MkNot(f)); + Status q = s.Check(); + + switch (q) + { + case UNKNOWN: + System.out.println("Unknown because: " + s.ReasonUnknown()); + break; + case SATISFIABLE: + throw new TestFailedException(); + case UNSATISFIABLE: + System.out.println("OK, proof: " + s.Proof()); + break; + } + } + + void Disprove(Context ctx, BoolExpr f) throws Z3Exception, + TestFailedException + { + BoolExpr[] a = {}; + Disprove(ctx, f, a); + } + + void Disprove(Context ctx, BoolExpr f, BoolExpr assumption) + throws Z3Exception, TestFailedException + { + BoolExpr[] a = { assumption }; + Disprove(ctx, f, a); + } + + void Disprove(Context ctx, BoolExpr f, BoolExpr[] assumptions) + throws Z3Exception, TestFailedException + { + System.out.println("Disproving: " + f); + Solver s = ctx.MkSolver(); + for (BoolExpr a : assumptions) + s.Assert(a); + s.Assert(ctx.MkNot(f)); + Status q = s.Check(); + + switch (q) + { + case UNKNOWN: + System.out.println("Unknown because: " + s.ReasonUnknown()); + break; + case SATISFIABLE: + System.out.println("OK, model: " + s.Model()); + break; + case UNSATISFIABLE: + throw new TestFailedException(); + } + } + + void ModelConverterTest(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ModelConverterTest"); + + ArithExpr xr = (ArithExpr) ctx.MkConst(ctx.MkSymbol("x"), + ctx.MkRealSort()); + ArithExpr yr = (ArithExpr) ctx.MkConst(ctx.MkSymbol("y"), + ctx.MkRealSort()); + Goal g4 = ctx.MkGoal(true, false, true); + g4.Assert(ctx.MkGt(xr, ctx.MkReal(10, 1))); + g4.Assert(ctx.MkEq(yr, + ctx.MkAdd(new ArithExpr[] { xr, ctx.MkReal(1, 1) }))); + g4.Assert(ctx.MkGt(yr, ctx.MkReal(1, 1))); + + ApplyResult ar = ApplyTactic(ctx, ctx.MkTactic("simplify"), g4); + if (ar.NumSubgoals() == 1 + && (ar.Subgoals()[0].IsDecidedSat() || ar.Subgoals()[0] + .IsDecidedUnsat())) + throw new TestFailedException(); + + ar = ApplyTactic(ctx, ctx.AndThen(ctx.MkTactic("simplify"), + ctx.MkTactic("solve-eqs"), null), g4); + if (ar.NumSubgoals() == 1 + && (ar.Subgoals()[0].IsDecidedSat() || ar.Subgoals()[0] + .IsDecidedUnsat())) + throw new TestFailedException(); + + Solver s = ctx.MkSolver(); + for (BoolExpr e : ar.Subgoals()[0].Formulas()) + s.Assert(e); + Status q = s.Check(); + System.out.println("Solver says: " + q); + System.out.println("Model: \n" + s.Model()); + System.out.println("Converted Model: \n" + + ar.ConvertModel(0, s.Model())); + if (q != Status.SATISFIABLE) + throw new TestFailedException(); + } + + // / A simple array example. + + void ArrayExample1(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("ArrayExample1"); + + Goal g = ctx.MkGoal(true, false, false); + ArraySort asort = ctx.MkArraySort(ctx.IntSort(), ctx.MkBitVecSort(32)); + ArrayExpr aex = (ArrayExpr) ctx.MkConst(ctx.MkSymbol("MyArray"), asort); + Expr sel = ctx.MkSelect(aex, ctx.MkInt(0)); + g.Assert(ctx.MkEq(sel, ctx.MkBV(42, 32))); + Symbol xs = ctx.MkSymbol("x"); + IntExpr xc = (IntExpr) ctx.MkConst(xs, ctx.IntSort()); + + Symbol fname = ctx.MkSymbol("f"); + Sort[] domain = { ctx.IntSort() }; + FuncDecl fd = ctx.MkFuncDecl(fname, domain, ctx.IntSort()); + Expr[] fargs = { ctx.MkConst(xs, ctx.IntSort()) }; + IntExpr fapp = (IntExpr) ctx.MkApp(fd, fargs); + + g.Assert(ctx.MkEq(ctx.MkAdd(new ArithExpr[] { xc, fapp }), + ctx.MkInt(123))); + + Solver s = ctx.MkSolver(); + for (BoolExpr a : g.Formulas()) + s.Assert(a); + System.out.println("Solver: " + s); + + Status q = s.Check(); + System.out.println("Status: " + q); + + if (q != Status.SATISFIABLE) + throw new TestFailedException(); + + System.out.println("Model = " + s.Model()); + + System.out.println("Interpretation of MyArray:\n" + + s.Model().FuncInterp(aex.FuncDecl())); + System.out + .println("Interpretation of x:\n" + s.Model().ConstInterp(xc)); + System.out.println("Interpretation of f:\n" + s.Model().FuncInterp(fd)); + System.out.println("Interpretation of MyArray as Term:\n" + + s.Model().FuncInterp(aex.FuncDecl())); + } + + // / Prove store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 + // = i3 or select(a1, i3) = select(a2, i3)). + + // / This example demonstrates how to use the array + // theory. + public void ArrayExample2(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ArrayExample2"); + + Sort int_type = ctx.IntSort(); + Sort array_type = ctx.MkArraySort(int_type, int_type); + + ArrayExpr a1 = (ArrayExpr) ctx.MkConst("a1", array_type); + ArrayExpr a2 = ctx.MkArrayConst("a2", int_type, int_type); + Expr i1 = ctx.MkConst("i1", int_type); + Expr i2 = ctx.MkConst("i2", int_type); + Expr i3 = ctx.MkConst("i3", int_type); + Expr v1 = ctx.MkConst("v1", int_type); + Expr v2 = ctx.MkConst("v2", int_type); + + Expr st1 = ctx.MkStore(a1, i1, v1); + Expr st2 = ctx.MkStore(a2, i2, v2); + + Expr sel1 = ctx.MkSelect(a1, i3); + Expr sel2 = ctx.MkSelect(a2, i3); + + /* create antecedent */ + BoolExpr antecedent = ctx.MkEq(st1, st2); + + /* + * create consequent: i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, + * i3) + */ + BoolExpr consequent = ctx.MkOr(new BoolExpr[] { ctx.MkEq(i1, i3), + ctx.MkEq(i2, i3), ctx.MkEq(sel1, sel2) }); + + /* + * prove store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = + * i3 or select(a1, i3) = select(a2, i3)) + */ + BoolExpr thm = ctx.MkImplies(antecedent, consequent); + System.out + .println("prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))"); + System.out.println(thm); + Prove(ctx, thm); + } + + // / Show that distinct(a_0, ... , a_n) is + // / unsatisfiable when a_i's are arrays from boolean to + // / boolean and n > 4. + + // / This example also shows how to use the distinct + // construct. + public void ArrayExample3(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ArrayExample3"); + + for (int n = 2; n <= 5; n++) + { + System.out.println("n = " + Integer.toString(n)); + + Sort bool_type = ctx.MkBoolSort(); + Sort array_type = ctx.MkArraySort(bool_type, bool_type); + Expr[] a = new Expr[n]; + + /* create arrays */ + for (int i = 0; i < n; i++) + { + a[i] = ctx.MkConst("array_" + Integer.toString(i), array_type); + } + + /* assert distinct(a[0], ..., a[n]) */ + BoolExpr d = ctx.MkDistinct(a); + System.out.println(d); + + /* context is satisfiable if n < 5 */ + Model model = Check(ctx, d, n < 5 ? Status.SATISFIABLE + : Status.UNSATISFIABLE); + if (n < 5) + { + for (int i = 0; i < n; i++) + { + System.out.println(a[i].toString() + " = " + + model.Evaluate(a[i], false)); + } + } + } + } + + // / Sudoku solving example. + + void SudokuExample(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("SudokuExample"); + + // 9x9 matrix of integer variables + IntExpr[][] X = new IntExpr[9][]; + for (int i = 0; i < 9; i++) + { + X[i] = new IntExpr[9]; + for (int j = 0; j < 9; j++) + X[i][j] = (IntExpr) ctx.MkConst( + ctx.MkSymbol("x_" + (i + 1) + "_" + (j + 1)), + ctx.IntSort()); + } + + // each cell contains a value in {1, ..., 9} + BoolExpr[][] cells_c = new BoolExpr[9][]; + for (int i = 0; i < 9; i++) + { + cells_c[i] = new BoolExpr[9]; + for (int j = 0; j < 9; j++) + cells_c[i][j] = ctx.MkAnd(new BoolExpr[] { + ctx.MkLe(ctx.MkInt(1), X[i][j]), + ctx.MkLe(X[i][j], ctx.MkInt(9)) }); + } + + // each row contains a digit at most once + BoolExpr[] rows_c = new BoolExpr[9]; + for (int i = 0; i < 9; i++) + rows_c[i] = ctx.MkDistinct(X[i]); + + // each column contains a digit at most once + BoolExpr[] cols_c = new BoolExpr[9]; + for (int j = 0; j < 9; j++) + cols_c[j] = ctx.MkDistinct(X[j]); + + // each 3x3 square contains a digit at most once + BoolExpr[][] sq_c = new BoolExpr[3][]; + for (int i0 = 0; i0 < 3; i0++) + { + sq_c[i0] = new BoolExpr[3]; + for (int j0 = 0; j0 < 3; j0++) + { + IntExpr[] square = new IntExpr[9]; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + square[3 * i + j] = X[3 * i0 + i][3 * j0 + j]; + sq_c[i0][j0] = ctx.MkDistinct(square); + } + } + + BoolExpr sudoku_c = ctx.MkTrue(); + for (BoolExpr[] t : cells_c) + sudoku_c = ctx.MkAnd(new BoolExpr[] { ctx.MkAnd(t), sudoku_c }); + sudoku_c = ctx.MkAnd(new BoolExpr[] { ctx.MkAnd(rows_c), sudoku_c }); + sudoku_c = ctx.MkAnd(new BoolExpr[] { ctx.MkAnd(cols_c), sudoku_c }); + for (BoolExpr[] t : sq_c) + sudoku_c = ctx.MkAnd(new BoolExpr[] { ctx.MkAnd(t), sudoku_c }); + + // sudoku instance, we use '0' for empty cells + int[][] instance = { { 0, 0, 0, 0, 9, 4, 0, 3, 0 }, + { 0, 0, 0, 5, 1, 0, 0, 0, 7 }, { 0, 8, 9, 0, 0, 0, 0, 4, 0 }, + { 0, 0, 0, 0, 0, 0, 2, 0, 8 }, { 0, 6, 0, 2, 0, 1, 0, 5, 0 }, + { 1, 0, 2, 0, 0, 0, 0, 0, 0 }, { 0, 7, 0, 0, 0, 0, 5, 2, 0 }, + { 9, 0, 0, 0, 6, 5, 0, 0, 0 }, { 0, 4, 0, 9, 7, 0, 0, 0, 0 } }; + + BoolExpr instance_c = ctx.MkTrue(); + for (int i = 0; i < 9; i++) + for (int j = 0; j < 9; j++) + instance_c = ctx + .MkAnd(new BoolExpr[] { + instance_c, + (BoolExpr) ctx.MkITE( + ctx.MkEq(ctx.MkInt(instance[i][j]), + ctx.MkInt(0)), + ctx.MkTrue(), + ctx.MkEq(X[i][j], + ctx.MkInt(instance[i][j]))) }); + + Solver s = ctx.MkSolver(); + s.Assert(sudoku_c); + s.Assert(instance_c); + + if (s.Check() == Status.SATISFIABLE) + { + Model m = s.Model(); + Expr[][] R = new Expr[9][9]; + for (int i = 0; i < 9; i++) + for (int j = 0; j < 9; j++) + R[i][j] = m.Evaluate(X[i][j], false); + System.out.println("Sudoku solution:"); + for (int i = 0; i < 9; i++) + { + for (int j = 0; j < 9; j++) + System.out.print(" " + R[i][j]); + System.out.println(); + } + } else + { + System.out.println("Failed to solve sudoku"); + throw new TestFailedException(); + } + } + + // / A basic example of how to use quantifiers. + + void QuantifierExample1(Context ctx) throws Z3Exception + { + System.out.println("QuantifierExample"); + + Sort[] types = new Sort[3]; + IntExpr[] xs = new IntExpr[3]; + Symbol[] names = new Symbol[3]; + IntExpr[] vars = new IntExpr[3]; + + for (int j = 0; j < 3; j++) + { + types[j] = ctx.IntSort(); + names[j] = ctx.MkSymbol("x_" + Integer.toString(j)); + xs[j] = (IntExpr) ctx.MkConst(names[j], types[j]); + vars[j] = (IntExpr) ctx.MkBound(2 - j, types[j]); // <-- vars + // reversed! + } + + Expr body_vars = ctx + .MkAnd(new BoolExpr[] { + ctx.MkEq( + ctx.MkAdd(new ArithExpr[] { vars[0], + ctx.MkInt(1) }), ctx.MkInt(2)), + ctx.MkEq( + ctx.MkAdd(new ArithExpr[] { vars[1], + ctx.MkInt(2) }), + ctx.MkAdd(new ArithExpr[] { vars[2], + ctx.MkInt(3) })) }); + + Expr body_const = ctx.MkAnd(new BoolExpr[] { + ctx.MkEq(ctx.MkAdd(new ArithExpr[] { xs[0], ctx.MkInt(1) }), + ctx.MkInt(2)), + ctx.MkEq(ctx.MkAdd(new ArithExpr[] { xs[1], ctx.MkInt(2) }), + ctx.MkAdd(new ArithExpr[] { xs[2], ctx.MkInt(3) })) }); + + Expr x = ctx.MkForall(types, names, body_vars, 1, null, null, + ctx.MkSymbol("Q1"), ctx.MkSymbol("skid1")); + System.out.println("Quantifier X: " + x.toString()); + + Expr y = ctx.MkForall(xs, body_const, 1, null, null, + ctx.MkSymbol("Q2"), ctx.MkSymbol("skid2")); + System.out.println("Quantifier Y: " + y.toString()); + } + + void QuantifierExample2(Context ctx) throws Z3Exception + { + + System.out.println("QuantifierExample2"); + + Expr q1, q2; + FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort(), ctx.IntSort()); + FuncDecl g = ctx.MkFuncDecl("g", ctx.IntSort(), ctx.IntSort()); + + // Quantifier with Exprs as the bound variables. + { + Expr x = ctx.MkConst("x", ctx.IntSort()); + Expr y = ctx.MkConst("y", ctx.IntSort()); + Expr f_x = ctx.MkApp(f, new Expr[] { x }); + Expr f_y = ctx.MkApp(f, new Expr[] { y }); + Expr g_y = ctx.MkApp(g, new Expr[] { y }); + Pattern[] pats = new Pattern[] { ctx.MkPattern(new Expr[] { f_x, + g_y }) }; + Expr[] no_pats = new Expr[] { f_y }; + Expr[] bound = new Expr[] { x, y }; + Expr body = ctx.MkAnd(new BoolExpr[] { ctx.MkEq(f_x, f_y), + ctx.MkEq(f_y, g_y) }); + + q1 = ctx.MkForall(bound, body, 1, null, no_pats, ctx.MkSymbol("q"), + ctx.MkSymbol("sk")); + + System.out.println(q1); + } + + // Quantifier with de-Brujin indices. + { + Expr x = ctx.MkBound(1, ctx.IntSort()); + Expr y = ctx.MkBound(0, ctx.IntSort()); + Expr f_x = ctx.MkApp(f, new Expr[] { x }); + Expr f_y = ctx.MkApp(f, new Expr[] { y }); + Expr g_y = ctx.MkApp(g, new Expr[] { y }); + Pattern[] pats = new Pattern[] { ctx.MkPattern(new Expr[] { f_x, + g_y }) }; + Expr[] no_pats = new Expr[] { f_y }; + Symbol[] names = new Symbol[] { ctx.MkSymbol("x"), + ctx.MkSymbol("y") }; + Sort[] sorts = new Sort[] { ctx.IntSort(), ctx.IntSort() }; + Expr body = ctx.MkAnd(new BoolExpr[] { ctx.MkEq(f_x, f_y), + ctx.MkEq(f_y, g_y) }); + + q2 = ctx.MkForall(sorts, names, body, 1, null, // pats, + no_pats, ctx.MkSymbol("q"), ctx.MkSymbol("sk")); + System.out.println(q2); + } + + System.out.println(q1.Equals(q2)); + } + + // / Prove that f(x, y) = f(w, v) implies y = v when + // / f is injective in the second argument. + + public void QuantifierExample3() throws Z3Exception, TestFailedException + { + System.out.println("QuantifierExample3"); + + HashMap cfg = new HashMap(); + cfg.put("MBQI", "false"); + cfg.put("PROOF_MODE", "2"); + cfg.put("AUTO_CONFIG", "false"); + + /* + * If quantified formulas are asserted in a logical context, then the + * model produced by Z3 should be viewed as a potential model. + */ + + { + Context ctx = new Context(cfg); + + /* declare function f */ + Sort I = ctx.IntSort(); + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiom(ctx, f, 1); + + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); + Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); + + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); + + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, new BoolExpr[] { inj, p1 }); + + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, new BoolExpr[] { inj, p1 }); + } + } + + // / Prove that f(x, y) = f(w, v) implies y = v when + // / f is injective in the second argument. + + public void QuantifierExample4() throws Z3Exception, TestFailedException + { + System.out.println("QuantifierExample4"); + + HashMap cfg = new HashMap(); + cfg.put("MBQI", "false"); + cfg.put("PROOF_MODE", "2"); + cfg.put("AUTO_CONFIG", "false"); + + /* + * If quantified formulas are asserted in a logical context, then the + * model produced by Z3 should be viewed as a potential model. + */ + + { + Context ctx = new Context(cfg); + /* declare function f */ + Sort I = ctx.IntSort(); + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiomAbs(ctx, f, 1); + + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); + Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); + + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); + + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, new BoolExpr[] { inj, p1 }); + + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, new BoolExpr[] { inj, p1 }); + } + } + + // / Some basic tests. + + void BasicTests(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("BasicTests"); + + Symbol qi = ctx.MkSymbol(1); + Symbol fname = ctx.MkSymbol("f"); + Symbol x = ctx.MkSymbol("x"); + Symbol y = ctx.MkSymbol("y"); + + Sort bs = ctx.MkBoolSort(); + + Sort[] domain = { bs, bs }; + FuncDecl f = ctx.MkFuncDecl(fname, domain, bs); + Expr fapp = ctx.MkApp(f, + new Expr[] { ctx.MkConst(x, bs), ctx.MkConst(y, bs) }); + + Expr[] fargs2 = { ctx.MkFreshConst("cp", bs) }; + Sort[] domain2 = { bs }; + Expr fapp2 = ctx.MkApp(ctx.MkFreshFuncDecl("fp", domain2, bs), fargs2); + + BoolExpr trivial_eq = ctx.MkEq(fapp, fapp); + BoolExpr nontrivial_eq = ctx.MkEq(fapp, fapp2); + + Goal g = ctx.MkGoal(true, false, true); + g.Assert(trivial_eq); + g.Assert(nontrivial_eq); + System.out.println("Goal: " + g); + + Solver solver = ctx.MkSolver(); + + for (BoolExpr a : g.Formulas()) + solver.Assert(a); + + if (solver.Check() != Status.SATISFIABLE) + throw new TestFailedException(); + + ApplyResult ar = ApplyTactic(ctx, ctx.MkTactic("simplify"), g); + if (ar.NumSubgoals() == 1 + && (ar.Subgoals()[0].IsDecidedSat() || ar.Subgoals()[0] + .IsDecidedUnsat())) + throw new TestFailedException(); + + ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g); + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedSat()) + throw new TestFailedException(); + + g.Assert(ctx.MkEq(ctx.MkNumeral(1, ctx.MkBitVecSort(32)), + ctx.MkNumeral(2, ctx.MkBitVecSort(32)))); + ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g); + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedUnsat()) + throw new TestFailedException(); + + Goal g2 = ctx.MkGoal(true, true, false); + ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2); + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedSat()) + throw new TestFailedException(); + + g2 = ctx.MkGoal(true, true, false); + g2.Assert(ctx.MkFalse()); + ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2); + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedUnsat()) + throw new TestFailedException(); + + Goal g3 = ctx.MkGoal(true, true, false); + Expr xc = ctx.MkConst(ctx.MkSymbol("x"), ctx.IntSort()); + Expr yc = ctx.MkConst(ctx.MkSymbol("y"), ctx.IntSort()); + g3.Assert(ctx.MkEq(xc, ctx.MkNumeral(1, ctx.IntSort()))); + g3.Assert(ctx.MkEq(yc, ctx.MkNumeral(2, ctx.IntSort()))); + BoolExpr constr = ctx.MkEq(xc, yc); + g3.Assert(constr); + ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g3); + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedUnsat()) + throw new TestFailedException(); + + ModelConverterTest(ctx); + + // Real num/den test. + RatNum rn = ctx.MkReal(42, 43); + Expr inum = rn.Numerator(); + Expr iden = rn.Denominator(); + System.out.println("Numerator: " + inum + " Denominator: " + iden); + if (inum.toString() != "42" || iden.toString() != "43") + throw new TestFailedException(); + + if (rn.ToDecimalString(3) != "0.976?") + throw new TestFailedException(); + + BigIntCheck(ctx, ctx.MkReal("-1231231232/234234333")); + BigIntCheck(ctx, ctx.MkReal("-123123234234234234231232/234234333")); + BigIntCheck(ctx, ctx.MkReal("-234234333")); + BigIntCheck(ctx, ctx.MkReal("234234333/2")); + + String bn = "1234567890987654321"; + + if (ctx.MkInt(bn).BigInteger().toString() != bn) + throw new TestFailedException(); + + if (ctx.MkBV(bn, 128).BigInteger().toString() != bn) + throw new TestFailedException(); + + if (ctx.MkBV(bn, 32).BigInteger().toString() == bn) + throw new TestFailedException(); + + // Error handling test. + try + { + Expr plus_ri = ctx.MkAdd(new ArithExpr[] { ctx.MkInt(1), + ctx.MkReal(2) }); + throw new TestFailedException(); // unreachable + } catch (Z3Exception e) + { + } + } + + // / Some basic expression casting tests. + + void CastingTest(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("CastingTest"); + + Sort[] domain = { ctx.BoolSort(), ctx.BoolSort() }; + FuncDecl f = ctx.MkFuncDecl("f", domain, ctx.BoolSort()); + + AST upcast = ctx.MkFuncDecl(ctx.MkSymbol("q"), domain, ctx.BoolSort()); + + try + { + FuncDecl downcast = (FuncDecl) f; // OK + } catch (ClassCastException e) + { + throw new TestFailedException(); + } + + try + { + Expr uc = (Expr) upcast; + throw new TestFailedException(); // should not be reachable! + } catch (ClassCastException e) + { + } + + Symbol s = ctx.MkSymbol(42); + IntSymbol si = (s.getClass() == IntSymbol.class) ? (IntSymbol) s : null; + if (si == null) + throw new TestFailedException(); + try + { + IntSymbol si2 = (IntSymbol) s; + } catch (ClassCastException e) + { + throw new TestFailedException(); + } + + s = ctx.MkSymbol("abc"); + StringSymbol ss = (s.getClass() == StringSymbol.class) ? (StringSymbol) s + : null; + if (ss == null) + throw new TestFailedException(); + try + { + StringSymbol ss2 = (StringSymbol) s; + } catch (ClassCastException e) + { + throw new TestFailedException(); + } + try + { + IntSymbol si2 = (IntSymbol) s; + throw new TestFailedException(); // unreachable + } catch (Exception e) + { + } + + Sort srt = ctx.MkBitVecSort(32); + BitVecSort bvs = null; + try + { + bvs = (BitVecSort) srt; + } catch (ClassCastException e) + { + throw new TestFailedException(); + } + + if (bvs.Size() != 32) + throw new TestFailedException(); + + Expr q = ctx.MkAdd(new ArithExpr[] { ctx.MkInt(1), ctx.MkInt(2) }); + Expr q2 = q.Args()[1]; + Sort qs = q2.Sort(); + if (qs.getClass() != IntSort.class) + throw new TestFailedException(); + try + { + IntSort isrt = (IntSort) qs; + } catch (ClassCastException e) + { + throw new TestFailedException(); + } + + AST a = ctx.MkInt(42); + Expr ae = (a.getClass() == Expr.class) ? ((Expr) a) : null; + if (ae == null) + throw new TestFailedException(); + ArithExpr aae = (a.getClass() == ArithExpr.class) ? ((ArithExpr) a) + : null; + if (aae == null) + throw new TestFailedException(); + IntExpr aie = (a.getClass() == IntExpr.class) ? ((IntExpr) a) : null; + if (aie == null) + throw new TestFailedException(); + IntNum ain = (a.getClass() == IntNum.class) ? ((IntNum) a) : null; + if (ain == null) + throw new TestFailedException(); + + Expr[][] earr = new Expr[2][]; + earr[0] = new Expr[2]; + earr[1] = new Expr[2]; + earr[0][0] = ctx.MkTrue(); + earr[0][1] = ctx.MkTrue(); + earr[1][0] = ctx.MkFalse(); + earr[1][1] = ctx.MkFalse(); + for (Expr[] ea : earr) + for (Expr e : ea) + { + try + { + Expr ns = ctx.MkNot((BoolExpr) e); + BoolExpr ens = (BoolExpr) ns; + } catch (ClassCastException ex) + { + throw new TestFailedException(); + } + } + } + + // / Shows how to read an SMT1 file. + + void SMT1FileTest(String filename) throws Z3Exception + { + System.out.print("SMT File test "); + + { + HashMap cfg = new HashMap(); + Context ctx = new Context(cfg); + ctx.ParseSMTLIBFile(filename, null, null, null, null); + + BoolExpr a = ctx.MkAnd(ctx.SMTLIBFormulas()); + System.out.println("read formula: " + a); + } + } + + // / Shows how to read an SMT2 file. + + void SMT2FileTest(String filename) throws Z3Exception + { + Date before = new Date(); + + System.out.println("SMT2 File test "); + System.gc(); + + { + HashMap cfg = new HashMap(); + cfg.put("MODEL", "true"); + Context ctx = new Context(cfg); + Expr a = ctx.ParseSMTLIB2File(filename, null, null, null, null); + + long t_diff = ((new Date()).getTime() - before.getTime()) / 1000; + + System.out.println("SMT2 file read time: " + t_diff + " sec"); + + // Iterate over the formula. + + LinkedList q = new LinkedList(); + q.add(a); + int cnt = 0; + while (q.size() > 0) + { + AST cur = (AST) q.removeFirst(); + cnt++; + + if (cur.getClass() == Expr.class) + if (!(cur.IsVar())) + for (Expr c : ((Expr) cur).Args()) + q.add(c); + } + System.out.println(cnt + " ASTs"); + } + + long t_diff = ((new Date()).getTime() - before.getTime()) / 1000; + System.out.println("SMT2 file test took " + t_diff + " sec"); + } + + // / Shows how to use Solver(logic) + + // / + void LogicExample(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("LogicTest"); + + Context.ToggleWarningMessages(true); + + BitVecSort bvs = ctx.MkBitVecSort(32); + Expr x = ctx.MkConst("x", bvs); + Expr y = ctx.MkConst("y", bvs); + BoolExpr eq = ctx.MkEq(x, y); + + // Use a solver for QF_BV + Solver s = ctx.MkSolver("QF_BV"); + s.Assert(eq); + Status res = s.Check(); + System.out.println("solver result: " + res); + + // Or perhaps a tactic for QF_BV + Goal g = ctx.MkGoal(true, false, true); + g.Assert(eq); + + Tactic t = ctx.MkTactic("qfbv"); + ApplyResult ar = t.Apply(g); + System.out.println("tactic result: " + ar); + + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedSat()) + throw new TestFailedException(); + } + + // / Demonstrates how to use the ParOr tactic. + + void ParOrExample(Context ctx) throws Z3Exception, TestFailedException + { + System.out.println("ParOrExample"); + + BitVecSort bvs = ctx.MkBitVecSort(32); + Expr x = ctx.MkConst("x", bvs); + Expr y = ctx.MkConst("y", bvs); + BoolExpr q = ctx.MkEq(x, y); + + Goal g = ctx.MkGoal(true, false, true); + g.Assert(q); + + Tactic t1 = ctx.MkTactic("qfbv"); + Tactic t2 = ctx.MkTactic("qfbv"); + Tactic p = ctx.ParOr(new Tactic[] { t1, t2 }); + + ApplyResult ar = p.Apply(g); + + if (ar.NumSubgoals() != 1 || !ar.Subgoals()[0].IsDecidedSat()) + throw new TestFailedException(); + } + + void BigIntCheck(Context ctx, RatNum r) throws Z3Exception + { + System.out.println("Num: " + r.BigIntNumerator()); + System.out.println("Den: " + r.BigIntDenominator()); + } + + // / Find a model for x xor y. + + public void FindModelExample1(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("FindModelExample1"); + + BoolExpr x = ctx.MkBoolConst("x"); + BoolExpr y = ctx.MkBoolConst("y"); + BoolExpr x_xor_y = ctx.MkXor(x, y); + + Model model = Check(ctx, x_xor_y, Status.SATISFIABLE); + System.out.println("x = " + model.Evaluate(x, false) + ", y = " + + model.Evaluate(y, false)); + } + + // / Find a model for x < y + 1, x > 2. + // / Then, assert not(x = y), and find another model. + + public void FindModelExample2(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("find_model_example2"); + + IntExpr x = ctx.MkIntConst("x"); + IntExpr y = ctx.MkIntConst("y"); + IntExpr one = ctx.MkInt(1); + IntExpr two = ctx.MkInt(2); + + ArithExpr y_plus_one = ctx.MkAdd(new ArithExpr[] { y, one }); + + BoolExpr c1 = ctx.MkLt(x, y_plus_one); + BoolExpr c2 = ctx.MkGt(x, two); + + BoolExpr q = ctx.MkAnd(new BoolExpr[] { c1, c2 }); + + System.out.println("model for: x < y + 1, x > 2"); + Model model = Check(ctx, q, Status.SATISFIABLE); + System.out.println("x = " + model.Evaluate(x, false) + ", y =" + + model.Evaluate(y, false)); + + /* assert not(x = y) */ + BoolExpr x_eq_y = ctx.MkEq(x, y); + BoolExpr c3 = ctx.MkNot(x_eq_y); + + q = ctx.MkAnd(new BoolExpr[] { q, c3 }); + + System.out.println("model for: x < y + 1, x > 2, not(x = y)"); + model = Check(ctx, q, Status.SATISFIABLE); + System.out.println("x = " + model.Evaluate(x, false) + ", y = " + + model.Evaluate(y, false)); + } + + // / Prove x = y implies g(x) = g(y), and + // / disprove x = y implies g(g(x)) = g(y). + + // / This function demonstrates how to create uninterpreted + // / types and functions. + public void ProveExample1(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ProveExample1"); + + /* create uninterpreted type. */ + Sort U = ctx.MkUninterpretedSort(ctx.MkSymbol("U")); + + /* declare function g */ + FuncDecl g = ctx.MkFuncDecl("g", U, U); + + /* create x and y */ + Expr x = ctx.MkConst("x", U); + Expr y = ctx.MkConst("y", U); + /* create g(x), g(y) */ + Expr gx = g.Apply(x); + Expr gy = g.Apply(y); + + /* assert x = y */ + BoolExpr eq = ctx.MkEq(x, y); + + /* prove g(x) = g(y) */ + BoolExpr f = ctx.MkEq(gx, gy); + System.out.println("prove: x = y implies g(x) = g(y)"); + Prove(ctx, ctx.MkImplies(eq, f)); + + /* create g(g(x)) */ + Expr ggx = g.Apply(gx); + + /* disprove g(g(x)) = g(y) */ + f = ctx.MkEq(ggx, gy); + System.out.println("disprove: x = y implies g(g(x)) = g(y)"); + Disprove(ctx, ctx.MkImplies(eq, f)); + + /* Print the model using the custom model printer */ + Model m = Check(ctx, ctx.MkNot(f), Status.SATISFIABLE); + System.out.println(m); + } + + // / Prove not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0 + // . + // / Then, show that z < -1 is not implied. + + // / This example demonstrates how to combine uninterpreted + // functions + // / and arithmetic. + public void ProveExample2(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ProveExample2"); + + /* declare function g */ + Sort I = ctx.IntSort(); + + FuncDecl g = ctx.MkFuncDecl("g", I, I); + + /* create x, y, and z */ + IntExpr x = ctx.MkIntConst("x"); + IntExpr y = ctx.MkIntConst("y"); + IntExpr z = ctx.MkIntConst("z"); + + /* create gx, gy, gz */ + Expr gx = ctx.MkApp(g, x); + Expr gy = ctx.MkApp(g, y); + Expr gz = ctx.MkApp(g, z); + + /* create zero */ + IntExpr zero = ctx.MkInt(0); + + /* assert not(g(g(x) - g(y)) = g(z)) */ + ArithExpr gx_gy = ctx.MkSub(new ArithExpr[] { (IntExpr) gx, + (IntExpr) gy }); + Expr ggx_gy = ctx.MkApp(g, gx_gy); + BoolExpr eq = ctx.MkEq(ggx_gy, gz); + BoolExpr c1 = ctx.MkNot(eq); + + /* assert x + z <= y */ + ArithExpr x_plus_z = ctx.MkAdd(new ArithExpr[] { x, z }); + BoolExpr c2 = ctx.MkLe(x_plus_z, y); + + /* assert y <= x */ + BoolExpr c3 = ctx.MkLe(y, x); + + /* prove z < 0 */ + BoolExpr f = ctx.MkLt(z, zero); + System.out + .println("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); + Prove(ctx, f, new BoolExpr[] { c1, c2, c3 }); + + /* disprove z < -1 */ + IntExpr minus_one = ctx.MkInt(-1); + f = ctx.MkLt(z, minus_one); + System.out + .println("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); + Disprove(ctx, f, new BoolExpr[] { c1, c2, c3 }); + } + + // / Show how push & pop can be used to create "backtracking" points. + + // / This example also demonstrates how big numbers can be + // / created in ctx. + public void PushPopExample1(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("PushPopExample1"); + + /* create a big number */ + IntSort int_type = ctx.IntSort(); + IntExpr big_number = ctx + .MkInt("1000000000000000000000000000000000000000000000000000000"); + + /* create number 3 */ + IntExpr three = (IntExpr) ctx.MkNumeral("3", int_type); + + /* create x */ + IntExpr x = ctx.MkIntConst("x"); + + Solver solver = ctx.MkSolver(); + + /* assert x >= "big number" */ + BoolExpr c1 = ctx.MkGe(x, big_number); + System.out.println("assert: x >= 'big number'"); + solver.Assert(c1); + + /* create a backtracking point */ + System.out.println("push"); + solver.Push(); + + /* assert x <= 3 */ + BoolExpr c2 = ctx.MkLe(x, three); + System.out.println("assert: x <= 3"); + solver.Assert(c2); + + /* context is inconsistent at this point */ + if (solver.Check() != Status.UNSATISFIABLE) + throw new TestFailedException(); + + /* + * backtrack: the constraint x <= 3 will be removed, since it was + * asserted after the last ctx.Push. + */ + System.out.println("pop"); + solver.Pop(1); + + /* the context is consistent again. */ + if (solver.Check() != Status.SATISFIABLE) + throw new TestFailedException(); + + /* new constraints can be asserted... */ + + /* create y */ + IntExpr y = ctx.MkIntConst("y"); + + /* assert y > x */ + BoolExpr c3 = ctx.MkGt(y, x); + System.out.println("assert: y > x"); + solver.Assert(c3); + + /* the context is still consistent. */ + if (solver.Check() != Status.SATISFIABLE) + throw new TestFailedException(); + } + + // / Tuples. + + // / Check that the projection of a tuple + // / returns the corresponding element. + public void TupleExample(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("TupleExample"); + + Sort int_type = ctx.IntSort(); + TupleSort tuple = ctx.MkTupleSort(ctx.MkSymbol("mk_tuple"), // name of + // tuple + // constructor + new Symbol[] { ctx.MkSymbol("first"), ctx.MkSymbol("second") }, // names + // of + // projection + // operators + new Sort[] { int_type, int_type } // types of projection + // operators + ); + FuncDecl first = tuple.FieldDecls()[0]; // declarations are for + // projections + FuncDecl second = tuple.FieldDecls()[1]; + Expr x = ctx.MkConst("x", int_type); + Expr y = ctx.MkConst("y", int_type); + Expr n1 = tuple.MkDecl().Apply(new Expr[] { x, y }); + Expr n2 = first.Apply(n1); + BoolExpr n3 = ctx.MkEq(x, n2); + System.out.println("Tuple example: " + n3); + Prove(ctx, n3); + } + + // / Simple bit-vector example. + + // / + // / This example disproves that x - 10 <= 0 IFF x <= 10 for (32-bit) + // machine integers + // / + public void BitvectorExample1(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("BitvectorExample1"); + + Sort bv_type = ctx.MkBitVecSort(32); + BitVecExpr x = (BitVecExpr) ctx.MkConst("x", bv_type); + BitVecNum zero = (BitVecNum) ctx.MkNumeral("0", bv_type); + BitVecNum ten = ctx.MkBV(10, 32); + BitVecExpr x_minus_ten = ctx.MkBVSub(x, ten); + /* bvsle is signed less than or equal to */ + BoolExpr c1 = ctx.MkBVSLE(x, ten); + BoolExpr c2 = ctx.MkBVSLE(x_minus_ten, zero); + BoolExpr thm = ctx.MkIff(c1, c2); + System.out + .println("disprove: x - 10 <= 0 IFF x <= 10 for (32-bit) machine integers"); + Disprove(ctx, thm); + } + + // / Find x and y such that: x ^ y - 103 == x * y + + public void BitvectorExample2(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("BitvectorExample2"); + + /* construct x ^ y - 103 == x * y */ + Sort bv_type = ctx.MkBitVecSort(32); + BitVecExpr x = ctx.MkBVConst("x", 32); + BitVecExpr y = ctx.MkBVConst("y", 32); + BitVecExpr x_xor_y = ctx.MkBVXOR(x, y); + BitVecExpr c103 = (BitVecNum) ctx.MkNumeral("103", bv_type); + BitVecExpr lhs = ctx.MkBVSub(x_xor_y, c103); + BitVecExpr rhs = ctx.MkBVMul(x, y); + BoolExpr ctr = ctx.MkEq(lhs, rhs); + + System.out + .println("find values of x and y, such that x ^ y - 103 == x * y"); + + /* find a model (i.e., values for x an y that satisfy the constraint */ + Model m = Check(ctx, ctr, Status.SATISFIABLE); + System.out.println(m); + } + + // / Demonstrates how to use the SMTLIB parser. + + public void ParserExample1(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ParserExample1"); + + ctx.ParseSMTLIBString( + "(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))", + null, null, null, null); + for (BoolExpr f : ctx.SMTLIBFormulas()) + System.out.println("formula " + f); + + Model m = Check(ctx, ctx.MkAnd(ctx.SMTLIBFormulas()), + Status.SATISFIABLE); + } + + // / Demonstrates how to initialize the parser symbol table. + + public void ParserExample2(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ParserExample2"); + + Symbol[] declNames = { ctx.MkSymbol("a"), ctx.MkSymbol("b") }; + FuncDecl a = ctx.MkConstDecl(declNames[0], ctx.MkIntSort()); + FuncDecl b = ctx.MkConstDecl(declNames[1], ctx.MkIntSort()); + FuncDecl[] decls = new FuncDecl[] { a, b }; + + ctx.ParseSMTLIBString("(benchmark tst :formula (> a b))", null, null, + declNames, decls); + BoolExpr f = ctx.SMTLIBFormulas()[0]; + System.out.println("formula: " + f); + Check(ctx, f, Status.SATISFIABLE); + } + + // / Demonstrates how to initialize the parser symbol table. + + public void ParserExample3(Context ctx) throws Exception + { + System.out.println("ParserExample3"); + + /* declare function g */ + Sort I = ctx.MkIntSort(); + FuncDecl g = ctx.MkFuncDecl("g", new Sort[] { I, I }, I); + + BoolExpr ca = CommAxiom(ctx, g); + + ctx.ParseSMTLIBString( + "(benchmark tst :formula (forall (x Int) (y Int) (implies (= x y) (= (gg x 0) (gg 0 y)))))", + null, null, new Symbol[] { ctx.MkSymbol("gg") }, + new FuncDecl[] { g }); + + BoolExpr thm = ctx.SMTLIBFormulas()[0]; + System.out.println("formula: " + thm); + Prove(ctx, thm, ca); + } + + // / Display the declarations, assumptions and formulas in a SMT-LIB string. + + public void ParserExample4(Context ctx) throws Z3Exception + { + System.out.println("ParserExample4"); + + ctx.ParseSMTLIBString( + "(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))", + null, null, null, null); + for (FuncDecl decl : ctx.SMTLIBDecls()) + { + System.out.println("Declaration: " + decl); + } + for (BoolExpr f : ctx.SMTLIBAssumptions()) + { + System.out.println("Assumption: " + f); + } + for (BoolExpr f : ctx.SMTLIBFormulas()) + { + System.out.println("Formula: " + f); + } + } + + // / Demonstrates how to handle parser errors using Z3 error handling + // support. + + // / + public void ParserExample5(Context ctx) + { + System.out.println("ParserExample5"); + + try + { + ctx.ParseSMTLIBString( + /* + * the following string has a parsing error: missing + * parenthesis + */ + "(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))", + null, null, null, null); + } catch (Z3Exception e) + { + System.out.println("Z3 error: " + e); + } + } + + // / Create an ite-Expr (if-then-else Exprs). + + public void ITEExample(Context ctx) throws Z3Exception + { + System.out.println("ITEExample"); + + BoolExpr f = ctx.MkFalse(); + Expr one = ctx.MkInt(1); + Expr zero = ctx.MkInt(0); + Expr ite = ctx.MkITE(f, one, zero); + + System.out.println("Expr: " + ite); + } + + // / Create an enumeration data type. + + public void EnumExample(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("EnumExample"); + + Symbol name = ctx.MkSymbol("fruit"); + + EnumSort fruit = ctx.MkEnumSort(ctx.MkSymbol("fruit"), + new Symbol[] { ctx.MkSymbol("apple"), ctx.MkSymbol("banana"), + ctx.MkSymbol("orange") }); + + System.out.println((fruit.Consts()[0])); + System.out.println((fruit.Consts()[1])); + System.out.println((fruit.Consts()[2])); + + System.out.println((fruit.TesterDecls()[0])); + System.out.println((fruit.TesterDecls()[1])); + System.out.println((fruit.TesterDecls()[2])); + + Expr apple = fruit.Consts()[0]; + Expr banana = fruit.Consts()[1]; + Expr orange = fruit.Consts()[2]; + + /* Apples are different from oranges */ + Prove(ctx, ctx.MkNot(ctx.MkEq(apple, orange))); + + /* Apples pass the apple test */ + Prove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], apple)); + + /* Oranges fail the apple test */ + Disprove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], orange)); + Prove(ctx, (BoolExpr) ctx.MkNot((BoolExpr) ctx.MkApp( + fruit.TesterDecls()[0], orange))); + + Expr fruity = ctx.MkConst("fruity", fruit); + + /* If something is fruity, then it is an apple, banana, or orange */ + + Prove(ctx, + ctx.MkOr(new BoolExpr[] { ctx.MkEq(fruity, apple), + ctx.MkEq(fruity, banana), ctx.MkEq(fruity, orange) })); + } + + // / Create a list datatype. + + public void ListExample(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ListExample"); + + Sort int_ty; + ListSort int_list; + Expr nil, l1, l2, x, y, u, v; + BoolExpr fml, fml1; + + int_ty = ctx.MkIntSort(); + + int_list = ctx.MkListSort(ctx.MkSymbol("int_list"), int_ty); + + nil = ctx.MkConst(int_list.NilDecl()); + l1 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { ctx.MkInt(1), nil }); + l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { ctx.MkInt(2), nil }); + + /* nil != cons(1, nil) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1))); + + /* cons(2,nil) != cons(1, nil) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(l1, l2))); + + /* cons(x,nil) = cons(y, nil) => x = y */ + x = ctx.MkConst("x", int_ty); + y = ctx.MkConst("y", int_ty); + l1 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { x, nil }); + l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { y, nil }); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + + /* cons(x,u) = cons(x, v) => u = v */ + u = ctx.MkConst("u", int_list); + v = ctx.MkConst("v", int_list); + l1 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { x, u }); + l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { y, v }); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + + /* is_nil(u) or is_cons(u) */ + Prove(ctx, + ctx.MkOr(new BoolExpr[] { + (BoolExpr) ctx.MkApp(int_list.IsNilDecl(), + new Expr[] { u }), + (BoolExpr) ctx.MkApp(int_list.IsConsDecl(), + new Expr[] { u }) })); + + /* occurs check u != cons(x,u) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + + /* destructors: is_cons(u) => u = cons(head(u),tail(u)) */ + fml1 = ctx.MkEq(u, ctx.MkApp(int_list.ConsDecl(), + new Expr[] { ctx.MkApp(int_list.HeadDecl(), new Expr[] { u }), + ctx.MkApp(int_list.TailDecl(), new Expr[] { u }) })); + fml = ctx.MkImplies( + (BoolExpr) ctx.MkApp(int_list.IsConsDecl(), new Expr[] { u }), + fml1); + System.out.println("Formula " + fml); + + Prove(ctx, fml); + + Disprove(ctx, fml1); + } + + // / Create a binary tree datatype. + + public void TreeExample(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("TreeExample"); + + Sort cell; + FuncDecl nil_decl, is_nil_decl, cons_decl, is_cons_decl, car_decl, cdr_decl; + Expr nil, l1, l2, x, y, u, v; + BoolExpr fml, fml1; + String[] head_tail = new String[] { "car", "cdr" }; + Sort[] sorts = new Sort[] { null, null }; + int[] sort_refs = new int[] { 0, 0 }; + Constructor nil_con, cons_con; + + nil_con = ctx.MkConstructor("nil", "is_nil", null, null, null); + cons_con = ctx.MkConstructor("cons", "is_cons", head_tail, sorts, + sort_refs); + Constructor[] constructors = new Constructor[] { nil_con, cons_con }; + + cell = ctx.MkDatatypeSort("cell", constructors); + + nil_decl = nil_con.ConstructorDecl(); + is_nil_decl = nil_con.TesterDecl(); + cons_decl = cons_con.ConstructorDecl(); + is_cons_decl = cons_con.TesterDecl(); + FuncDecl[] cons_accessors = cons_con.AccessorDecls(); + car_decl = cons_accessors[0]; + cdr_decl = cons_accessors[1]; + + nil = ctx.MkConst(nil_decl); + l1 = ctx.MkApp(cons_decl, new Expr[] { nil, nil }); + l2 = ctx.MkApp(cons_decl, new Expr[] { l1, nil }); + + /* nil != cons(nil, nil) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1))); + + /* cons(x,u) = cons(x, v) => u = v */ + u = ctx.MkConst("u", cell); + v = ctx.MkConst("v", cell); + x = ctx.MkConst("x", cell); + y = ctx.MkConst("y", cell); + l1 = ctx.MkApp(cons_decl, new Expr[] { x, u }); + l2 = ctx.MkApp(cons_decl, new Expr[] { y, v }); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + + /* is_nil(u) or is_cons(u) */ + Prove(ctx, + ctx.MkOr(new BoolExpr[] { + (BoolExpr) ctx.MkApp(is_nil_decl, new Expr[] { u }), + (BoolExpr) ctx.MkApp(is_cons_decl, new Expr[] { u }) })); + + /* occurs check u != cons(x,u) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + + /* destructors: is_cons(u) => u = cons(car(u),cdr(u)) */ + fml1 = ctx.MkEq( + u, + ctx.MkApp( + cons_decl, + new Expr[] { ctx.MkApp(car_decl, u), + ctx.MkApp(cdr_decl, u) })); + fml = ctx.MkImplies((BoolExpr) ctx.MkApp(is_cons_decl, u), fml1); + System.out.println("Formula " + fml); + Prove(ctx, fml); + + Disprove(ctx, fml1); + } + + // / Create a forest of trees. + + // / + // / forest ::= nil | cons(tree, forest) + // / tree ::= nil | cons(forest, forest) + // / + public void ForestExample(Context ctx) throws Z3Exception, + TestFailedException + { + System.out.println("ForestExample"); + + Sort tree, forest; + FuncDecl nil1_decl, is_nil1_decl, cons1_decl, is_cons1_decl, car1_decl, cdr1_decl; + FuncDecl nil2_decl, is_nil2_decl, cons2_decl, is_cons2_decl, car2_decl, cdr2_decl; + Expr nil1, nil2, t1, t2, t3, t4, f1, f2, f3, l1, l2, x, y, u, v; + + // + // Declare the names of the accessors for cons. + // Then declare the sorts of the accessors. + // For this example, all sorts refer to the new types 'forest' and + // 'tree' + // being declared, so we pass in null for both sorts1 and sorts2. + // On the other hand, the sort_refs arrays contain the indices of the + // two new sorts being declared. The first element in sort1_refs + // points to 'tree', which has index 1, the second element in sort1_refs + // array + // points to 'forest', which has index 0. + // + Symbol[] head_tail1 = new Symbol[] { ctx.MkSymbol("head"), + ctx.MkSymbol("tail") }; + Sort[] sorts1 = new Sort[] { null, null }; + int[] sort1_refs = new int[] { 1, 0 }; // the first item points to a + // tree, the second to a forest + + Symbol[] head_tail2 = new Symbol[] { ctx.MkSymbol("car"), + ctx.MkSymbol("cdr") }; + Sort[] sorts2 = new Sort[] { null, null }; + int[] sort2_refs = new int[] { 0, 0 }; // both items point to the forest + // datatype. + Constructor nil1_con, cons1_con, nil2_con, cons2_con; + Constructor[] constructors1 = new Constructor[2], constructors2 = new Constructor[2]; + Symbol[] sort_names = { ctx.MkSymbol("forest"), ctx.MkSymbol("tree") }; + + /* build a forest */ + nil1_con = ctx.MkConstructor(ctx.MkSymbol("nil"), + ctx.MkSymbol("is_nil"), null, null, null); + cons1_con = ctx.MkConstructor(ctx.MkSymbol("cons1"), + ctx.MkSymbol("is_cons1"), head_tail1, sorts1, sort1_refs); + constructors1[0] = nil1_con; + constructors1[1] = cons1_con; + + /* build a tree */ + nil2_con = ctx.MkConstructor(ctx.MkSymbol("nil2"), + ctx.MkSymbol("is_nil2"), null, null, null); + cons2_con = ctx.MkConstructor(ctx.MkSymbol("cons2"), + ctx.MkSymbol("is_cons2"), head_tail2, sorts2, sort2_refs); + constructors2[0] = nil2_con; + constructors2[1] = cons2_con; + + Constructor[][] clists = new Constructor[][] { constructors1, + constructors2 }; + + Sort[] sorts = ctx.MkDatatypeSorts(sort_names, clists); + forest = sorts[0]; + tree = sorts[1]; + + // + // Now that the datatype has been created. + // Query the constructors for the constructor + // functions, testers, and field accessors. + // + nil1_decl = nil1_con.ConstructorDecl(); + is_nil1_decl = nil1_con.TesterDecl(); + cons1_decl = cons1_con.ConstructorDecl(); + is_cons1_decl = cons1_con.TesterDecl(); + FuncDecl[] cons1_accessors = cons1_con.AccessorDecls(); + car1_decl = cons1_accessors[0]; + cdr1_decl = cons1_accessors[1]; + + nil2_decl = nil2_con.ConstructorDecl(); + is_nil2_decl = nil2_con.TesterDecl(); + cons2_decl = cons2_con.ConstructorDecl(); + is_cons2_decl = cons2_con.TesterDecl(); + FuncDecl[] cons2_accessors = cons2_con.AccessorDecls(); + car2_decl = cons2_accessors[0]; + cdr2_decl = cons2_accessors[1]; + + nil1 = ctx.MkConst(nil1_decl); + nil2 = ctx.MkConst(nil2_decl); + f1 = ctx.MkApp(cons1_decl, new Expr[] { nil2, nil1 }); + t1 = ctx.MkApp(cons2_decl, new Expr[] { nil1, nil1 }); + t2 = ctx.MkApp(cons2_decl, new Expr[] { f1, nil1 }); + t3 = ctx.MkApp(cons2_decl, new Expr[] { f1, f1 }); + t4 = ctx.MkApp(cons2_decl, new Expr[] { nil1, f1 }); + f2 = ctx.MkApp(cons1_decl, new Expr[] { t1, nil1 }); + f3 = ctx.MkApp(cons1_decl, new Expr[] { t1, f1 }); + + /* nil != cons(nil,nil) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(nil1, f1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(nil2, t1))); + + /* cons(x,u) = cons(x, v) => u = v */ + u = ctx.MkConst("u", forest); + v = ctx.MkConst("v", forest); + x = ctx.MkConst("x", tree); + y = ctx.MkConst("y", tree); + l1 = ctx.MkApp(cons1_decl, new Expr[] { x, u }); + l2 = ctx.MkApp(cons1_decl, new Expr[] { y, v }); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + + /* is_nil(u) or is_cons(u) */ + Prove(ctx, ctx.MkOr(new BoolExpr[] { + (BoolExpr) ctx.MkApp(is_nil1_decl, new Expr[] { u }), + (BoolExpr) ctx.MkApp(is_cons1_decl, new Expr[] { u }) })); + + /* occurs check u != cons(x,u) */ + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + } + + // / Demonstrate how to use #Eval. + + public void EvalExample1(Context ctx) throws Z3Exception + { + System.out.println("EvalExample1"); + + IntExpr x = ctx.MkIntConst("x"); + IntExpr y = ctx.MkIntConst("y"); + IntExpr two = ctx.MkInt(2); + + Solver solver = ctx.MkSolver(); + + /* assert x < y */ + solver.Assert(ctx.MkLt(x, y)); + + /* assert x > 2 */ + solver.Assert(ctx.MkGt(x, two)); + + /* find model for the constraints above */ + Model model = null; + if (Status.SATISFIABLE == solver.Check()) + { + model = solver.Model(); + System.out.println(model); + System.out.println("\nevaluating x+y"); + Expr v = model.Evaluate(ctx.MkAdd(new ArithExpr[] { x, y }), false); + if (v != null) + { + System.out.println("result = " + (v)); + } else + { + System.out.println("Failed to evaluate: x+y"); + } + } else + { + System.out.println("BUG, the constraints are satisfiable."); + } + } + + // / Demonstrate how to use #Eval on tuples. + + public void EvalExample2(Context ctx) throws Z3Exception + { + System.out.println("EvalExample2"); + + Sort int_type = ctx.IntSort(); + TupleSort tuple = ctx.MkTupleSort(ctx.MkSymbol("mk_tuple"), // name of + // tuple + // constructor + new Symbol[] { ctx.MkSymbol("first"), ctx.MkSymbol("second") }, // names + // of + // projection + // operators + new Sort[] { int_type, int_type } // types of projection + // operators + ); + FuncDecl first = tuple.FieldDecls()[0]; // declarations are for + // projections + FuncDecl second = tuple.FieldDecls()[1]; + Expr tup1 = ctx.MkConst("t1", tuple); + Expr tup2 = ctx.MkConst("t2", tuple); + + Solver solver = ctx.MkSolver(); + + /* assert tup1 != tup2 */ + solver.Assert(ctx.MkNot(ctx.MkEq(tup1, tup2))); + /* assert first tup1 = first tup2 */ + solver.Assert(ctx.MkEq(ctx.MkApp(first, tup1), ctx.MkApp(first, tup2))); + + /* find model for the constraints above */ + Model model = null; + if (Status.SATISFIABLE == solver.Check()) + { + model = solver.Model(); + System.out.println(model); + System.out.println("evaluating tup1 " + + (model.Evaluate(tup1, false))); + System.out.println("evaluating tup2 " + + (model.Evaluate(tup2, false))); + System.out.println("evaluating second(tup2) " + + (model.Evaluate(ctx.MkApp(second, tup2), false))); + } else + { + System.out.println("BUG, the constraints are satisfiable."); + } + } + + // / Demonstrate how to use Pushand Popto + // / control the size of models. + + // / Note: this test is specialized to 32-bit bitvectors. + public void CheckSmall(Context ctx, Solver solver, BitVecExpr[] to_minimize) + throws Z3Exception + { + int num_Exprs = to_minimize.length; + int[] upper = new int[num_Exprs]; + int[] lower = new int[num_Exprs]; + for (int i = 0; i < upper.length; ++i) + { + upper[i] = Integer.MAX_VALUE; + lower[i] = 0; + } + boolean some_work = true; + int last_index = -1; + int last_upper = 0; + while (some_work) + { + solver.Push(); + + boolean check_is_sat = true; + while (check_is_sat && some_work) + { + // Assert all feasible bounds. + for (int i = 0; i < num_Exprs; ++i) + { + solver.Assert(ctx.MkBVULE(to_minimize[i], + ctx.MkBV(upper[i], 32))); + } + + check_is_sat = Status.SATISFIABLE == solver.Check(); + if (!check_is_sat) + { + if (last_index != -1) + { + lower[last_index] = last_upper + 1; + } + break; + } + System.out.println(solver.Model()); + + // narrow the bounds based on the current model. + for (int i = 0; i < num_Exprs; ++i) + { + Expr v = solver.Model().Evaluate(to_minimize[i], false); + int ui = ((BitVecNum) v).Int(); + if (ui < upper[i]) + { + upper[i] = (int) ui; + } + System.out.println(i + " " + lower[i] + " " + upper[i]); + } + + // find a new bound to add + some_work = false; + last_index = 0; + for (int i = 0; i < num_Exprs; ++i) + { + if (lower[i] < upper[i]) + { + last_upper = (upper[i] + lower[i]) / 2; + last_index = i; + solver.Assert(ctx.MkBVULE(to_minimize[i], + ctx.MkBV(last_upper, 32))); + some_work = true; + break; + } + } + } + solver.Pop(); + } + } + + // / Reduced-size model generation example. + + public void FindSmallModelExample(Context ctx) throws Z3Exception + { + System.out.println("FindSmallModelExample"); + + BitVecExpr x = ctx.MkBVConst("x", 32); + BitVecExpr y = ctx.MkBVConst("y", 32); + BitVecExpr z = ctx.MkBVConst("z", 32); + + Solver solver = ctx.MkSolver(); + + solver.Assert(ctx.MkBVULE(x, ctx.MkBVAdd(y, z))); + CheckSmall(ctx, solver, new BitVecExpr[] { x, y, z }); + } + + // / Simplifier example. + + public void SimplifierExample(Context ctx) throws Z3Exception + { + System.out.println("SimplifierExample"); + + IntExpr x = ctx.MkIntConst("x"); + IntExpr y = ctx.MkIntConst("y"); + IntExpr z = ctx.MkIntConst("z"); + IntExpr u = ctx.MkIntConst("u"); + + Expr t1 = ctx.MkAdd(new ArithExpr[] { + x, + ctx.MkSub(new ArithExpr[] { y, + ctx.MkAdd(new ArithExpr[] { x, z }) }) }); + Expr t2 = t1.Simplify(); + System.out.println((t1) + " -> " + (t2)); + } + + // / Extract unsatisfiable core example + + public void UnsatCoreAndProofExample() throws Z3Exception + { + System.out.println("UnsatCoreAndProofExample"); + + HashMap cfg = new HashMap(); + cfg.put("PROOF_MODE", "2"); + + { + Context ctx = new Context(cfg); + Solver solver = ctx.MkSolver(); + + BoolExpr pa = ctx.MkBoolConst("PredA"); + BoolExpr pb = ctx.MkBoolConst("PredB"); + BoolExpr pc = ctx.MkBoolConst("PredC"); + BoolExpr pd = ctx.MkBoolConst("PredD"); + BoolExpr p1 = ctx.MkBoolConst("P1"); + BoolExpr p2 = ctx.MkBoolConst("P2"); + BoolExpr p3 = ctx.MkBoolConst("P3"); + BoolExpr p4 = ctx.MkBoolConst("P4"); + BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), + ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; + BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); + BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); + BoolExpr f3 = ctx.MkOr(new BoolExpr[] { ctx.MkNot(pa), + ctx.MkNot(pc) }); + BoolExpr f4 = pd; + + solver.Assert(ctx.MkOr(new BoolExpr[] { f1, p1 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f2, p2 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f3, p3 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f4, p4 })); + Status result = solver.Check(assumptions); + + if (result == Status.UNSATISFIABLE) + { + System.out.println("unsat"); + System.out.println("proof: " + solver.Proof()); + System.out.println("core: "); + for (Expr c : solver.UnsatCore()) + { + System.out.println(c); + } + } + } + } + + public void FiniteDomainExample(Context ctx) throws Z3Exception + { + System.out.println("FiniteDomainExample"); + + FiniteDomainSort s = ctx.MkFiniteDomainSort("S", 10); + FiniteDomainSort t = ctx.MkFiniteDomainSort("T", 10); + Expr s1 = ctx.MkNumeral(1, s); + Expr t1 = ctx.MkNumeral(1, t); + System.out.println(s); + System.out.println(t); + System.out.println(s1); + System.out.println(ctx.MkNumeral(2, s)); + System.out.println(t1); + // But you cannot mix numerals of different sorts + // even if the size of their domains are the same: + // System.out.println(ctx.MkEq(s1, t1)); + } + + public static void main(String[] args) + { + JavaExample p = new JavaExample(); + try + { + Context.ToggleWarningMessages(true); + Log.Open("test.log"); + + System.out.print("Z3 Major Version: "); + System.out.println(Version.Major()); + System.out.print("Z3 Full Version: "); + System.out.println(Version.getString()); + + p.SimpleExample(); + + { + HashMap cfg = new HashMap<>(); + cfg.put("MODEL", "true"); + cfg.put("PROOF_MODE", "2"); + Context ctx = new Context(cfg); + p.BasicTests(ctx); + p.CastingTest(ctx); + p.SudokuExample(ctx); + p.QuantifierExample1(ctx); + p.QuantifierExample2(ctx); + p.LogicExample(ctx); + p.ParOrExample(ctx); + p.FindModelExample1(ctx); + p.FindModelExample2(ctx); + p.ProveExample1(ctx); + p.ProveExample2(ctx); + p.PushPopExample1(ctx); + p.ArrayExample1(ctx); + p.ArrayExample2(ctx); + p.ArrayExample3(ctx); + p.TupleExample(ctx); + p.BitvectorExample1(ctx); + p.BitvectorExample2(ctx); + p.ParserExample1(ctx); + p.ParserExample2(ctx); + p.ParserExample3(ctx); + p.ParserExample4(ctx); + p.ParserExample5(ctx); + p.ITEExample(ctx); + p.EnumExample(ctx); + p.ListExample(ctx); + p.TreeExample(ctx); + p.ForestExample(ctx); + p.EvalExample1(ctx); + p.EvalExample2(ctx); + p.FindSmallModelExample(ctx); + p.SimplifierExample(ctx); + p.FiniteDomainExample(ctx); + } + + p.QuantifierExample3(); + p.QuantifierExample4(); + p.UnsatCoreAndProofExample(); + + Log.Close(); + if (Log.isOpen()) + System.out.println("Log is still open!"); + } catch (Z3Exception ex) + { + System.out.println("Z3 Managed Exception: " + ex.getMessage()); + System.out.println("Stack trace: " + ex.getStackTrace()); + } catch (TestFailedException ex) + { + System.out.println("TEST CASE FAILED: " + ex.getMessage()); + } catch (Exception ex) + { + System.out.println("Unknown Exception: " + ex.getMessage()); + } + } +} diff --git a/examples/java/README b/examples/java/README new file mode 100644 index 000000000..9dc513c2a --- /dev/null +++ b/examples/java/README @@ -0,0 +1,10 @@ +### This is work-in-progress and does not work yet. + +Small example using the Z3 Java bindings. +To build the example execute + make examples +in the build directory. + +It will create JavaExample.class in the build directory, +which can be run via + java -cp com.microsoft.z3.jar;. JavaExample \ No newline at end of file diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 57d6ecac0..6fff2abba 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -79,6 +79,7 @@ def init_project_def(): add_c_example('c_example', 'c') add_c_example('maxsat') add_dotnet_example('dotnet_example', 'dotnet') + add_java_example('java_example', 'java') add_z3py_example('py_example', 'python') return API_files diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 6d2c1f0af..a0fed0696 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1070,7 +1070,7 @@ class DotNetExampleComponent(ExampleComponent): if DOTNET_ENABLED: dll_name = get_component(DOTNET_COMPONENT).dll_name dll = '%s.dll' % dll_name - exefile = '%s.exe' % self.name + exefile = '%s$(EXE_EXT)' % self.name out.write('%s: %s' % (exefile, dll)) for csfile in get_cs_files(self.ex_dir): out.write(' ') @@ -1089,6 +1089,28 @@ class DotNetExampleComponent(ExampleComponent): out.write('\n') out.write('_ex_%s: %s\n\n' % (self.name, exefile)) +class JavaExampleComponent(ExampleComponent): + def __init__(self, name, path): + ExampleComponent.__init__(self, name, path) + + def is_example(self): + return True + + def mk_makefile(self, out): + if JAVA_ENABLED: + pkg = get_component(JAVA_COMPONENT).package_name + '.jar' + out.write('_ex_%s: %s' % (self.name, pkg)) + # for javafile in get_java_files(self.ex_dir): + # out.write(' ') + # out.write('%s/%s' % (self.to_ex_dir, javafile)) + out.write('\n') + out.write('\t%s -cp %s ' % (JAVAC, pkg)) + win_ex_dir = self.to_ex_dir + for javafile in get_java_files(self.ex_dir): + out.write(' ') + out.write('%s/%s' % (win_ex_dir, javafile)) + out.write(' -d .\n\n') + class PythonExampleComponent(ExampleComponent): def __init__(self, name, path): ExampleComponent.__init__(self, name, path) @@ -1154,6 +1176,10 @@ def add_dotnet_example(name, path=None): c = DotNetExampleComponent(name, path) reg_component(name, c) +def add_java_example(name, path=None): + c = JavaExampleComponent(name, path) + reg_component(name, c) + def add_z3py_example(name, path=None): c = PythonExampleComponent(name, path) reg_component(name, c) diff --git a/src/api/java/Context.java b/src/api/java/Context.java index ef82eba35..d289d956f 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -525,7 +525,7 @@ public class Context extends IDisposable public Expr MkConst(FuncDecl f) throws Z3Exception { - return MkApp(f, null); + return MkApp(f, (Expr)null); } /** @@ -600,6 +600,17 @@ public class Context extends IDisposable return (BitVecExpr) MkConst(name, MkBitVecSort(size)); } + /** + * Create a new function application. + **/ + public Expr MkApp(FuncDecl f, Expr arg) throws Z3Exception + { + CheckContextMatch(f); + CheckContextMatch(arg); + Expr[] args = { arg }; + return Expr.Create(this, f, args); + } + /** * Create a new function application. **/ @@ -2773,6 +2784,17 @@ public class Context extends IDisposable 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() throws Z3Exception + { + return MkSolver((Symbol)null); + } + /** * Creates a new (incremental) solver. This solver also uses a set * of builtin tactics for handling the first check-sat command, and diff --git a/src/api/java/EnumSort.java b/src/api/java/EnumSort.java index 8c9eeb16a..f02301a5d 100644 --- a/src/api/java/EnumSort.java +++ b/src/api/java/EnumSort.java @@ -59,6 +59,6 @@ public class EnumSort extends Sort _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); + _consts[i] = ctx.MkApp(_constdecls[i], (Expr)null); } }; diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index 4bc7f6842..88e67d82e 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -16,9 +16,18 @@ import com.microsoft.z3.enumerations.*; public class Expr extends AST { /** - * Returns a simplified version of the expression. A set of - * parameters to configure the simplifier + * Returns a simplified version of the expression + **/ + public Expr Simplify() throws Z3Exception + { + return Simplify(null); + } + + /** + * Returns a simplified version of the expression + * A set of + * parameters to configure the simplifier + * **/ public Expr Simplify(Params p) throws Z3Exception { diff --git a/src/api/java/FuncDecl.java b/src/api/java/FuncDecl.java index d64ce3cf9..c001dc982 100644 --- a/src/api/java/FuncDecl.java +++ b/src/api/java/FuncDecl.java @@ -356,24 +356,36 @@ public class FuncDecl extends AST } /** - * Create expression that applies function to arguments. + * Create expression that applies function to arguments. + * * * @return **/ /* operator this[] not translated */ /** - * Create expression that applies function to arguments. + * Create expression that applies function to arguments. + * * * @return **/ public Expr Apply(Expr[] args) throws Z3Exception { - Context().CheckContextMatch(args); return Expr.Create(Context(), this, args); } + /** + * Create expression that applies function to one argument. + * + * + * @return + **/ + public Expr Apply(Expr arg) throws Z3Exception + { + Context().CheckContextMatch(arg); + Expr[] a = { arg }; + return Expr.Create(Context(), this, a); + } + } diff --git a/src/api/java/Goal.java b/src/api/java/Goal.java index d4b242a03..0add69fd5 100644 --- a/src/api/java/Goal.java +++ b/src/api/java/Goal.java @@ -69,13 +69,22 @@ public class Goal extends Z3Object 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()); } } + /** + * Adds a to the given goal. + * @throws Z3Exception + **/ + public void Assert(BoolExpr constraint) throws Z3Exception + { + Context().CheckContextMatch(constraint); + Native.goalAssert(Context().nCtx(), NativeObject(), + constraint.NativeObject()); + } + /** * Indicates whether the goal contains `false'. **/ diff --git a/src/api/java/Log.java b/src/api/java/Log.java index bd85d021c..cd62f82ac 100644 --- a/src/api/java/Log.java +++ b/src/api/java/Log.java @@ -13,7 +13,7 @@ package com.microsoft.z3; **/ public final class Log { - private boolean m_is_open = false; + private static boolean m_is_open = false; /** * Open an interaction log file. the name of the file @@ -21,7 +21,7 @@ public final class Log * * @return True if opening the log file succeeds, false otherwise. **/ - public boolean Open(String filename) + public static boolean Open(String filename) { m_is_open = true; return Native.openLog(filename) == 1; @@ -30,7 +30,7 @@ public final class Log /** * Closes the interaction log. **/ - public void Close() + public static void Close() { m_is_open = false; Native.closeLog(); @@ -41,7 +41,7 @@ public final class Log * log. * @throws Z3Exception **/ - public void Append(String s) throws Z3Exception + public static void Append(String s) throws Z3Exception { if (!m_is_open) throw new Z3Exception("Log cannot be closed."); @@ -53,7 +53,7 @@ public final class Log * * @return True if the interaction log is open, false otherwise. **/ - public boolean isOpen() + public static boolean isOpen() { return m_is_open; } diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java index 703f22be4..f3ec9c916 100644 --- a/src/api/java/Solver.java +++ b/src/api/java/Solver.java @@ -59,6 +59,14 @@ public class Solver extends Z3Object Native.solverPush(Context().nCtx(), NativeObject()); } + /** + * Backtracks one backtracking point. . + **/ + public void Pop() + { + Pop(1); + } + /** * Backtracks backtracking points. Note that * an exception is thrown if is not smaller than @@ -79,7 +87,7 @@ public class Solver extends Z3Object } /** - * Assert a constraint (or multiple) into the solver. + * Assert a multiple constraints into the solver. * @throws Z3Exception **/ public void Assert(BoolExpr[] constraints) throws Z3Exception @@ -92,6 +100,16 @@ public class Solver extends Z3Object } } + /** + * Assert one constraint into the solver. + * @throws Z3Exception + **/ + public void Assert(BoolExpr constraint) throws Z3Exception + { + Context().CheckContextMatch(constraint); + Native.solverAssert(Context().nCtx(), NativeObject(), constraint.NativeObject()); + } + /** * The number of assertions in the solver. * @throws Z3Exception @@ -144,6 +162,16 @@ public class Solver extends Z3Object } } + /** + * Checks whether the assertions in the solver are consistent or not. + * + **/ + public Status Check() + { + return Check(null); + } + /** * The model of the last Check. The result is * null if Check was not invoked before, if its diff --git a/src/api/java/Tactic.java b/src/api/java/Tactic.java index 90e728087..b9a0ba0c7 100644 --- a/src/api/java/Tactic.java +++ b/src/api/java/Tactic.java @@ -33,6 +33,15 @@ public class Tactic extends Z3Object .nCtx(), NativeObject())); } + /** + * Execute the tactic over the goal. + * @throws Z3Exception + **/ + public ApplyResult Apply(Goal g) throws Z3Exception + { + return Apply(g, null); + } + /** * Execute the tactic over the goal. * @throws Z3Exception diff --git a/src/api/java/Version.java b/src/api/java/Version.java index 51fad896c..af5da39de 100644 --- a/src/api/java/Version.java +++ b/src/api/java/Version.java @@ -9,16 +9,12 @@ package com.microsoft.z3; /** * Version information. Note that this class is static. **/ -public final class Version +public class Version { - Version() - { - } - /** * The major version **/ - public int Major() + public static 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); @@ -28,7 +24,7 @@ public final class Version /** * The minor version **/ - public int Minor() + public static 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); @@ -38,7 +34,7 @@ public final class Version /** * The build version **/ - public int Build() + public static 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); @@ -48,7 +44,7 @@ public final class Version /** * The revision **/ - public int Revision() + public static 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); @@ -58,7 +54,7 @@ public final class Version /** * A string representation of the version information. **/ - public String toString() + public static String getString() { Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr(); Native.getVersion(major, minor, build, revision); From e2198f6541a717b661c91d74ebe3e1912b94c85e Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 27 Nov 2012 23:18:47 +0000 Subject: [PATCH 030/133] Java API: build system bugfix. Signed-off-by: Christoph M. Wintersteiger --- scripts/update_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index da760fbea..8d5d5e712 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -507,8 +507,8 @@ def mk_java(): 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')) + if IS_WINDOWS: + java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) else: java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name for name, result, params in _dotnet_decls: From 1d9b09019665bef03a0b091a5529e0c6223678df Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 27 Nov 2012 15:34:02 -0800 Subject: [PATCH 031/133] quantifiers and a heuristic for disequalities Signed-off-by: Nikolaj Bjorner --- src/muz_qe/pdr_quantifiers.cpp | 61 +++++++++++++--------------------- src/muz_qe/pdr_util.cpp | 16 +++++++-- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 47a1622f3..b681b0121 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -106,11 +106,19 @@ 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_ref e(m); + var_subst vs(m, false); + inv_var_shifter invsh(m); + vs(q->get_expr(), binding.size(), binding.c_ptr(), e); + invsh(e, q->get_num_decls(), 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); + m_instantiated_rules.push_back(m_current_rule); + m_instantiations.push_back(to_app(e)); TRACE("pdr", tout << mk_pp(q, m) << "\n"; tout << "binding\n"; for (unsigned i = 0; i < binding.size(); ++i) { @@ -122,21 +130,8 @@ namespace pdr { tout << mk_pp(var_inst[i].get(), m) << " "; } tout << "\n"; + tout << mk_pp(e, m) << "\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); - invsh(e, q->get_num_decls(), 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)); } @@ -206,7 +201,6 @@ namespace pdr { 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()); fmls.append(m_Bs); @@ -259,18 +253,6 @@ namespace pdr { add_binding(q, new_binding); found_instance = true; } - if (collector.size() == 0) { - // Try to create dummy instances. - for (unsigned i = 0; i < m_Bs.size(); ++i) { - q = qs[i]; - expr_ref_vector binding(m); - for (unsigned j = 0; j < q->get_num_decls(); ++j) { - binding.push_back(m.mk_fresh_const("B", q->get_decl_sort(j))); - } - add_binding(q, binding); - } - found_instance = true; - } return found_instance; } @@ -300,7 +282,7 @@ namespace pdr { pred_transformer& pt = node.pt(); manager& pm = pt.get_pdr_manager(); expr_ref A(m), B(m), C(m), v(m); - expr_ref_vector As(m); + expr_ref_vector As(m), Bs(m); m_Bs.reset(); // // nodes from leaves that are repeated @@ -342,7 +324,6 @@ namespace pdr { for (unsigned j = 0; j < qis->size(); ++j) { 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"; @@ -359,7 +340,7 @@ namespace pdr { 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); + B = pt2.get_formulas(previous_level, false); TRACE("pdr", tout << "B:\n" << mk_pp(B, m) << "\n";); @@ -371,17 +352,23 @@ namespace pdr { rep->set_substitution(&sub); (*rep)(B); TRACE("pdr", tout << "B substituted:\n" << mk_pp(B, m) << "\n";); - - B = m.update_quantifier(q, B); - m_Bs.push_back(B); + datalog::flatten_and(B, Bs); + for (unsigned i = 0; i < Bs.size(); ++i) { + m_Bs.push_back(m.update_quantifier(q, Bs[i].get())); + } } } TRACE("pdr", tout << "A:\n" << mk_pp(m_A, m) << "\n"; + tout << "quantifier:\n"; + for (unsigned i = 0; i < qis->size(); ++i) { + tout << mk_pp((*qis)[i].get(), m) << " "; + } + tout << "\n"; tout << "B:\n"; 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"; + tout << mk_pp(m_Bs[i].get(), m) << "\n"; } ast_smt_pp pp(m); pp.add_assumption(m_A); diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 705b519a2..8a36e9089 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -219,11 +219,21 @@ namespace pdr { collect(formulas, tocollect); for (unsigned i = 0; i < tocollect.size(); ++i) { expr* e = tocollect[i]; + expr* e1, *e2; SASSERT(m.is_bool(e)); SASSERT(is_true(e) || is_false(e)); if (is_true(e)) { result.push_back(e); } + // hack to break disequalities for arithmetic variables. + else if (m.is_eq(e, e1, e2) && m_arith.is_int_real(e1)) { + if (get_number(e1) < get_number(e2)) { + result.push_back(m_arith.mk_lt(e1,e2)); + } + else { + result.push_back(m_arith.mk_lt(e2,e1)); + } + } else { result.push_back(m.mk_not(e)); } @@ -260,11 +270,11 @@ namespace pdr { SASSERT(v); // no-op } - else if (!m.is_bool(args[0])) { - tocollect.push_back(e); + else if (m.is_bool(args[0])) { + todo.append(sz, args); } else { - todo.append(sz, args); + tocollect.push_back(e); } break; case OP_DISTINCT: From aa4fe775b1f43d94a72635561d048dcbd3b0b9a4 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 27 Nov 2012 17:18:38 -0800 Subject: [PATCH 032/133] fixed bug reported by Herman Signed-off-by: Leonardo de Moura --- RELEASE_NOTES | 2 ++ src/solver/strategic_solver.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 55e873997..e6b63d62d 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -14,6 +14,8 @@ Version 4.3.2 - Removed 'autoconf' dependency. We do not need to execute 'autoconf' and './configure' anymore to build Z3. +- Fixed incorrect result returned by Z3_solver_get_num_scopes. (Thanks to Herman Venter). This bug was introduced in Z3 4.3.0 + Version 4.3.1 ============= diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index 616ec5342..b6eb98b42 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -308,7 +308,7 @@ void strategic_solver::pop(unsigned n) { unsigned strategic_solver::get_scope_level() const { if (m_ctx == 0) return 0; - return m_ctx->m_assertions.size(); + return m_ctx->m_scopes.size(); } struct aux_timeout_eh : public event_handler { From 29b896b0bfdd60323925fd0c4f47cef08f09a0e1 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 13:59:50 +0000 Subject: [PATCH 033/133] Java API: build fixes Signed-off-by: Christoph M. Wintersteiger --- scripts/mk_util.py | 5 ++++- scripts/update_api.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index a0fed0696..2b1eaec93 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -985,7 +985,10 @@ class JavaDLLComponent(Component): else: t = t.replace('PLATFORM', 'win32') out.write(t) - out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) Native$(OBJ_EXT) libz3$(LIB_EXT)\n') + if IS_WINDOWS: # On Windows, CL creates a .lib file to link against. + out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(LIB_EXT)\n') + else: + out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(SO_EXT)\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) diff --git a/scripts/update_api.py b/scripts/update_api.py index 8d5d5e712..9167beceb 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -537,8 +537,9 @@ def mk_java(): java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('extern "C" {\n') java_wrapper.write('#endif\n') + pkg_str = get_component('java').package_name.replace('.', '_') for name, result, params in _dotnet_decls: - java_wrapper.write('JNIEXPORT %s JNICALL Java_Z3Native_%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), java_method_name(name))) + java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) i = 0; for param in params: java_wrapper.write(', ') From 519d308b8645525dbe1822a25210bb509a9a1723 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 14:59:39 +0000 Subject: [PATCH 034/133] Java API: bugfixes Signed-off-by: Christoph M. Wintersteiger --- examples/java/JavaExample.java | 4 ++-- src/api/java/Context.java | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index a721c53d2..d0bdcf8d4 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -806,7 +806,6 @@ class JavaExample { System.out.println("BasicTests"); - Symbol qi = ctx.MkSymbol(1); Symbol fname = ctx.MkSymbol("f"); Symbol x = ctx.MkSymbol("x"); Symbol y = ctx.MkSymbol("y"); @@ -2207,7 +2206,8 @@ class JavaExample } catch (Z3Exception ex) { System.out.println("Z3 Managed Exception: " + ex.getMessage()); - System.out.println("Stack trace: " + ex.getStackTrace()); + System.out.println("Stack trace: "); + ex.printStackTrace(System.out); } catch (TestFailedException ex) { System.out.println("TEST CASE FAILED: " + ex.getMessage()); diff --git a/src/api/java/Context.java b/src/api/java/Context.java index d289d956f..3519900cd 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -2974,23 +2974,15 @@ public class Context extends IDisposable void CheckContextMatch(Z3Object other) throws Z3Exception { - - if (this == other.Context()) - throw new Z3Exception("Context mismatch"); + 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); - } - } + if (arr != null) + for (Z3Object a : arr) + CheckContextMatch(a); } private ASTDecRefQueue m_AST_DRQ = new ASTDecRefQueue(); From 830f6ada93499fabab3803bf8beeae8a4acc344b Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 17:35:07 +0000 Subject: [PATCH 035/133] Java API: bugfixes Signed-off-by: Christoph M. Wintersteiger --- src/api/java/Context.java | 5 +---- src/api/java/Z3Object.java | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 3519900cd..b903f71e0 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -3083,8 +3083,6 @@ public class Context extends IDisposable **/ protected void finalize() { - // Console.WriteLine("Context Finalizer from " + - // System.Threading.Thread.CurrentThread.ManagedThreadId); Dispose(); if (m_refCount == 0) @@ -3094,6 +3092,7 @@ public class Context extends IDisposable m_ctx = 0; } else /* re-queue the finalizer */ + /* BUG: DRQ's need to be taken over too! */ new Context(m_ctx, m_refCount, m_n_err_handler); } @@ -3102,8 +3101,6 @@ public class Context extends IDisposable **/ 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); diff --git a/src/api/java/Z3Object.java b/src/api/java/Z3Object.java index e5e4af3c2..877fead79 100644 --- a/src/api/java/Z3Object.java +++ b/src/api/java/Z3Object.java @@ -104,13 +104,12 @@ public class Z3Object extends IDisposable 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(); + an[i] = a[i].NativeObject(); return an; } static int ArrayLength(Z3Object[] a) { - return (a == null) ? 0 : (int) a.length; + return (a == null) ? 0 : a.length; } } From 27652d70ad4ce584245f97bab812a32c9aab7948 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 21:14:27 +0000 Subject: [PATCH 036/133] Java API: multi-platform fixes Signed-off-by: Christoph M. Wintersteiger --- scripts/update_api.py | 49 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 9167beceb..e55a3a356 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -468,18 +468,6 @@ def java_method_name(name): i = i + 1 return result -# Return the Java method name used to retrieve the elements of the given parameter -def java_get_array_elements(p): - if param_type(p) == INT or param_type(p) == UINT: - return 'GetIntArrayElements' - else: - return 'GetLongArrayElements' -# Return the Java method name used to release the elements of the given parameter -def java_release_array_elements(p): - if param_type(p) == INT or param_type(p) == UINT: - return 'ReleaseIntArrayElements' - else: - return 'ReleaseLongArrayElements' # Return the type of the java array elements def java_array_element_type(p): if param_type(p) == INT or param_type(p) == UINT: @@ -536,7 +524,24 @@ def mk_java(): java_wrapper.write('#include"z3.h"\n') java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('extern "C" {\n') - java_wrapper.write('#endif\n') + java_wrapper.write('#endif\n\n') + if VS_X64: + java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') + java_wrapper.write(' T * NEW = (T*) jenv->GetLongArrayElements(OLD, NULL); \n') + java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') + java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') + else: + java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') + java_wrapper.write(' T * NEW = 0; { \\\n') + java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') + java_wrapper.write(' unsigned int size = jenv->GetArrayLength(OLD); \\\n') + java_wrapper.write(' NEW = (T*) (new int[size]); \\\n') + java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n') + java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') + java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n') + java_wrapper.write(' } \n\n') + java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') + java_wrapper.write(' delete [] NEW; \n\n') pkg_str = get_component('java').package_name.replace('.', '_') for name, result, params in _dotnet_decls: java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) @@ -553,11 +558,10 @@ def mk_java(): if k == OUT or k == INOUT: java_wrapper.write(' %s _a%s;\n' % (type2str(param_type(param)), i)) elif k == IN_ARRAY or k == INOUT_ARRAY: - java_wrapper.write(' %s * _a%s = (%s *) jenv->%s(a%s, NULL);\n' % (type2str(param_type(param)), - i, - type2str(param_type(param)), - java_get_array_elements(param), - i)) + if param_type(param) == INT or param_type(param) == UINT: + java_wrapper.write(' %s * _a%s = (%s*) jenv->GetIntArrayElements(a%s, NULL);\n' % (type2str(param_type(param)), i, type2str(param_type(param)), i)) + else: + java_wrapper.write(' GETLONGAELEMS(%s, a%s, _a%s);\n' % (type2str(param_type(param)), i, i)) elif k == OUT_ARRAY: java_wrapper.write(' %s * _a%s = (%s *) malloc(((unsigned)a%s) * sizeof(%s));\n' % (type2str(param_type(param)), i, @@ -602,10 +606,11 @@ def mk_java(): i)) java_wrapper.write(' free(_a%s);\n' % i) elif k == IN_ARRAY or k == OUT_ARRAY: - java_wrapper.write(' jenv->%s(a%s, (%s *) _a%s, JNI_ABORT);\n' % (java_release_array_elements(param), - i, - java_array_element_type(param), - i)) + if param_type(param) == INT or param_type(param) == UINT: + java_wrapper.write(' jenv->ReleaseIntArrayElements(a%s, (jint*)_a%s, JNI_ABORT);\n' % (i, i)) + else: + java_wrapper.write(' RELEASELONGAELEMS(a%s, _a%s);\n' % (i, i)) + elif k == OUT or k == INOUT: if param_type(param) == INT or param_type(param) == UINT: java_wrapper.write(' {\n') From 00ebabcc6e1db8aae2ae7b74adff6224a837ff11 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 21:30:22 +0000 Subject: [PATCH 037/133] Ignoring more common build directories Signed-off-by: Christoph M. Wintersteiger --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d380fe06f..a26ee7565 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,8 @@ ncscope.out # Commonly used directories for code bld_dbg/* bld_rel/* +bld_dbg_x64/* +bld_rel_x64/* # Auto generated files. config.log config.status From 8ba77b38d46c33dfa9cf58181199a4c032fc2b6c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 28 Nov 2012 13:37:41 -0800 Subject: [PATCH 038/133] revert to prettier SMT2 printer as default Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index f11c9852d..ec78f8e92 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -994,7 +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)"); + p.insert(":print-low-level-smt2", CPK_BOOL, "(default false) 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, @@ -1651,7 +1651,7 @@ 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); + bool print_low_level = m_params.get_bool(":print-low-level-smt2", false); #define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); From 2b0be7668572359033fb8d0e68bc55490664f570 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 28 Nov 2012 13:43:58 -0800 Subject: [PATCH 039/133] track uses_level better as suggested by Arie Gurfinkel Signed-off-by: Nikolaj Bjorner --- src/muz_qe/pdr_context.cpp | 21 +++++++++++---------- src/muz_qe/pdr_context.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 798ee406d..2f43d518c 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -266,7 +266,7 @@ namespace pdr { } else if (is_invariant(tgt_level, curr, false, assumes_level)) { - add_property(curr, tgt_level); // assumes_level?tgt_level:infty_level + add_property(curr, assumes_level?tgt_level:infty_level); TRACE("pdr", tout << "is invariant: "<< tgt_level << " " << mk_pp(curr, m) << "\n";); src[i] = src.back(); src.pop_back(); @@ -293,9 +293,6 @@ namespace pdr { bool pred_transformer::add_property1(expr * lemma, unsigned lvl) { if (is_infty_level(lvl)) { - if (m.is_false(lemma)) { - return false; - } if (!m_invariants.contains(lemma)) { TRACE("pdr", tout << "property1: " << head()->get_name() << " " << mk_pp(lemma, m) << "\n";); m_invariants.push_back(lemma); @@ -410,7 +407,7 @@ namespace pdr { add_property(result, level); } - lbool pred_transformer::is_reachable(model_node& n, expr_ref_vector* core) { + lbool pred_transformer::is_reachable(model_node& n, expr_ref_vector* core, bool& uses_level) { TRACE("pdr", tout << "is-reachable: " << head()->get_name() << " level: " << n.level() << "\n"; tout << mk_pp(n.state(), m) << "\n";); @@ -427,6 +424,9 @@ namespace pdr { tout << mk_pp(n.state(), m) << "\n";); n.set_model(model); } + else if (is_sat == l_false) { + uses_level = m_solver.assumes_level(); + } return is_sat; } @@ -1640,7 +1640,8 @@ namespace pdr { close_node(n); } else { - switch (expand_state(n, cube)) { + bool uses_level = true; + switch (expand_state(n, cube, uses_level)) { case l_true: if (n.level() == 0) { TRACE("pdr", tout << "reachable\n";); @@ -1653,7 +1654,7 @@ namespace pdr { break; case l_false: { core_generalizer::cores cores; - cores.push_back(std::make_pair(cube, true)); + cores.push_back(std::make_pair(cube, uses_level)); for (unsigned i = 0; !cores.empty() && i < m_core_generalizers.size(); ++i) { core_generalizer::cores new_cores; @@ -1666,7 +1667,7 @@ namespace pdr { bool found_invariant = false; for (unsigned i = 0; i < cores.size(); ++i) { expr_ref_vector const& core = cores[i].first; - bool uses_level = cores[i].second; + uses_level = cores[i].second; found_invariant = !uses_level || found_invariant; expr_ref ncore(m_pm.mk_not_and(core), m); TRACE("pdr", tout << "invariant state: " << (uses_level?"":"(inductive) ") << mk_pp(ncore, m) << "\n";); @@ -1690,8 +1691,8 @@ namespace pdr { // return a property that blocks state and is implied by the // predicate transformer (or some unfolding of it). // - lbool context::expand_state(model_node& n, expr_ref_vector& result) { - return n.pt().is_reachable(n, &result); + lbool context::expand_state(model_node& n, expr_ref_vector& result, bool& uses_level) { + return n.pt().is_reachable(n, &result, uses_level); } void context::propagate(unsigned max_prop_lvl) { diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index c7f53752a..a201ac03b 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -140,7 +140,7 @@ namespace pdr { bool propagate_to_next_level(unsigned level); void add_property(expr * lemma, unsigned lvl); // add property 'p' to state at level. - lbool is_reachable(model_node& n, expr_ref_vector* core); + lbool is_reachable(model_node& n, expr_ref_vector* core, bool& uses_level); bool is_invariant(unsigned level, expr* co_state, bool inductive, bool& assumes_level, expr_ref_vector* core = 0); bool check_inductive(unsigned level, expr_ref_vector& state, bool& assumes_level); @@ -309,7 +309,7 @@ namespace pdr { void close_node(model_node& n); void check_pre_closed(model_node& n); void expand_node(model_node& n); - lbool expand_state(model_node& n, expr_ref_vector& cube); + lbool expand_state(model_node& n, expr_ref_vector& cube, bool& uses_level); void create_children(model_node& n); expr_ref mk_sat_answer() const; expr_ref mk_unsat_answer() const; From 1ed4e7c480f72ea17b5c6664c94e094acbd465c7 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 22:20:02 +0000 Subject: [PATCH 040/133] Managed API: bugfixes Signed-off-by: Christoph M. Wintersteiger --- examples/dotnet/Program.cs | 2 +- src/api/dotnet/Context.cs | 10 ++++++++-- src/api/dotnet/Expr.cs | 6 ++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index db3cd30b2..75393378b 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -839,7 +839,7 @@ namespace test_mapi // Error handling test. try { - Expr plus_ri = ctx.MkAdd(ctx.MkInt(1), ctx.MkReal(2)); + IntExpr i = ctx.MkInt("1/2"); throw new TestFailedException(); // unreachable } catch (Z3Exception) diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index 3e438d69d..ff36b4553 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -113,7 +113,6 @@ namespace Microsoft.Z3 get { Contract.Ensures(Contract.Result() != null); - if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort; } } @@ -134,7 +133,14 @@ namespace Microsoft.Z3 /// /// Retrieves the Real sort of the context. /// - public RealSort RealSort { get { Contract.Ensures(Contract.Result() != null); if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort; } } + public RealSort RealSort + { + get + { + Contract.Ensures(Contract.Result() != null); + if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort; + } + } /// /// Create a new Boolean sort. diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index dade77eb1..9f5c04f0b 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -1532,8 +1532,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"); + case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj); } } @@ -1544,8 +1543,7 @@ namespace Microsoft.Z3 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_sort_kind.Z3_UNKNOWN_SORT: throw new Z3Exception("Unknown Sort"); + case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj); } return new Expr(ctx, obj); From bbfd9dd19f03c62db5fc14b6e9db48af96842dfc Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 28 Nov 2012 22:20:36 +0000 Subject: [PATCH 041/133] Java API: bugfixes Signed-off-by: Christoph M. Wintersteiger --- examples/java/JavaExample.java | 18 +++++++++++------- src/api/java/Context.java | 6 +++--- src/api/java/Expr.java | 4 ---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index d0bdcf8d4..7e403fecd 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -882,10 +882,10 @@ class JavaExample Expr inum = rn.Numerator(); Expr iden = rn.Denominator(); System.out.println("Numerator: " + inum + " Denominator: " + iden); - if (inum.toString() != "42" || iden.toString() != "43") + if (!inum.toString().equals("42") || !iden.toString().equals("43")) throw new TestFailedException(); - if (rn.ToDecimalString(3) != "0.976?") + if (!rn.ToDecimalString(3).toString().equals("0.976?")) throw new TestFailedException(); BigIntCheck(ctx, ctx.MkReal("-1231231232/234234333")); @@ -895,23 +895,23 @@ class JavaExample String bn = "1234567890987654321"; - if (ctx.MkInt(bn).BigInteger().toString() != bn) + if (!ctx.MkInt(bn).BigInteger().toString().equals(bn)) throw new TestFailedException(); - if (ctx.MkBV(bn, 128).BigInteger().toString() != bn) + if (!ctx.MkBV(bn, 128).BigInteger().toString().equals(bn)) throw new TestFailedException(); - if (ctx.MkBV(bn, 32).BigInteger().toString() == bn) + if (ctx.MkBV(bn, 32).BigInteger().toString().equals(bn)) throw new TestFailedException(); // Error handling test. try { - Expr plus_ri = ctx.MkAdd(new ArithExpr[] { ctx.MkInt(1), - ctx.MkReal(2) }); + IntExpr i = ctx.MkInt("0.5"); throw new TestFailedException(); // unreachable } catch (Z3Exception e) { + System.out.println("GOT: " + e.getMessage()); } } @@ -2211,9 +2211,13 @@ class JavaExample } catch (TestFailedException ex) { System.out.println("TEST CASE FAILED: " + ex.getMessage()); + System.out.println("Stack trace: "); + ex.printStackTrace(System.out); } catch (Exception ex) { System.out.println("Unknown Exception: " + ex.getMessage()); + System.out.println("Stack trace: "); + ex.printStackTrace(System.out); } } } diff --git a/src/api/java/Context.java b/src/api/java/Context.java index b903f71e0..c3fbeab15 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -86,7 +86,6 @@ public class Context extends IDisposable **/ public BoolSort BoolSort() throws Z3Exception { - if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort; @@ -97,7 +96,6 @@ public class Context extends IDisposable **/ public IntSort IntSort() throws Z3Exception { - if (m_intSort == null) m_intSort = new IntSort(this); return m_intSort; @@ -106,8 +104,10 @@ public class Context extends IDisposable /** * Retrieves the Real sort of the context. **/ - public RealSort RealSort() + public RealSort RealSort() throws Z3Exception { + if (m_realSort== null) + m_realSort = new RealSort(this); return m_realSort; } diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index 88e67d82e..a67d94e7e 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -1786,8 +1786,6 @@ public class Expr extends AST return new RatNum(ctx, obj); case Z3_BV_SORT: return new BitVecNum(ctx, obj); - case Z3_UNKNOWN_SORT: - throw new Z3Exception("Unknown Sort"); default: ; } } @@ -1806,8 +1804,6 @@ public class Expr extends AST return new ArrayExpr(ctx, obj); case Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj); - case Z3_UNKNOWN_SORT: - throw new Z3Exception("Unknown Sort"); default: ; } From 3ca41c6202329cd5b5880789c3ca1159649e1f7f Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 28 Nov 2012 16:46:19 -0800 Subject: [PATCH 042/133] fixed recently introduced bug Signed-off-by: Leonardo de Moura --- src/smt/asserted_formulas.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index f86da835c..15b49ee32 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -287,6 +287,7 @@ void asserted_formulas::reduce() { INVOKE(m_params.m_quasi_macros && has_quantifiers(), apply_quasi_macros()); INVOKE(m_params.m_simplify_bit2int, apply_bit2int()); INVOKE(m_params.m_eliminate_bounds && has_quantifiers(), cheap_quant_fourier_motzkin()); + INVOKE(m_params.m_ematching && has_quantifiers(), infer_patterns()); INVOKE(m_params.m_max_bv_sharing && has_bv(), max_bv_sharing()); INVOKE(m_params.m_bb_quantifiers, elim_bvs_from_quantifiers()); // temporary HACK: make sure that arith & bv are list-assoc From 30905da58cc1de3825acbda8d1e4ba939bd5fdec Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 08:14:06 -0800 Subject: [PATCH 043/133] fixed: make examples Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 2b1eaec93..5edace6cb 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1097,7 +1097,7 @@ class JavaExampleComponent(ExampleComponent): ExampleComponent.__init__(self, name, path) def is_example(self): - return True + return JAVA_ENABLED def mk_makefile(self, out): if JAVA_ENABLED: From 001c8487e929db30d6d569acafe992a8b20a8c64 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 09:13:24 -0800 Subject: [PATCH 044/133] small change to be able to test java example on linux Signed-off-by: Leonardo de Moura --- examples/java/JavaExample.java | 2 +- examples/java/README | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 7e403fecd..d96553c19 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -2157,7 +2157,7 @@ class JavaExample p.SimpleExample(); { - HashMap cfg = new HashMap<>(); + HashMap cfg = new HashMap(); cfg.put("MODEL", "true"); cfg.put("PROOF_MODE", "2"); Context ctx = new Context(cfg); diff --git a/examples/java/README b/examples/java/README index 9dc513c2a..fa1f20a63 100644 --- a/examples/java/README +++ b/examples/java/README @@ -6,5 +6,10 @@ To build the example execute in the build directory. It will create JavaExample.class in the build directory, -which can be run via - java -cp com.microsoft.z3.jar;. JavaExample \ No newline at end of file +which can be run on Windows via + java -cp com.microsoft.z3.jar;. JavaExample + +On Linux and FreeBSD, we must use + LD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample + + \ No newline at end of file From 0733db382f4f6a4c804d2f4addce8ed8ad7be819 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 09:15:03 -0800 Subject: [PATCH 045/133] updated release notes Signed-off-by: Leonardo de Moura --- RELEASE_NOTES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e6b63d62d..8fab69938 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -16,6 +16,8 @@ Version 4.3.2 - Fixed incorrect result returned by Z3_solver_get_num_scopes. (Thanks to Herman Venter). This bug was introduced in Z3 4.3.0 +- Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java + Version 4.3.1 ============= From c6bd31e01d0de893a4b301a5134babcd5c442750 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 10:05:13 -0800 Subject: [PATCH 046/133] working on new global parameter setting framework Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 5edace6cb..4bbaa80a8 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1601,8 +1601,10 @@ def mk_mem_initializer_cpp(cnames, path): fullname = '%s/mem_initializer.cpp' % path fout = open(fullname, 'w') fout.write('// Automatically generated file.\n') - initializer_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\'\)') - finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') + initializer_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\'\)') + # ADD_INITIALIZER with priority + initializer_prio_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\',[ \t]*(-?[0-9]*)\)') + finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) @@ -1615,15 +1617,22 @@ def mk_mem_initializer_cpp(cnames, path): if not added_include: added_include = True fout.write('#include"%s"\n' % h_file) - initializer_cmds.append(m.group(1)) + initializer_cmds.append((m.group(1), 0)) + m = initializer_prio_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + initializer_cmds.append((m.group(1), int(m.group(2)))) m = finalizer_pat.match(line) if m: if not added_include: added_include = True fout.write('#include"%s"\n' % h_file) finalizer_cmds.append(m.group(1)) + initializer_cmds.sort(key=lambda tup: tup[1]) fout.write('void mem_initialize() {\n') - for cmd in initializer_cmds: + for (cmd, prio) in initializer_cmds: fout.write(cmd) fout.write('\n') fout.write('}\n') From c3055207ed7577199a39e1310f5319c8af30aca3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 10:30:16 -0800 Subject: [PATCH 047/133] updated release notes Signed-off-by: Leonardo de Moura --- RELEASE_NOTES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 8fab69938..617b44bd0 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -18,6 +18,8 @@ Version 4.3.2 - Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java +- Fixed crash when parsing incorrect formulas. The crash was introduced when support for "arithmetic coercions" was added in Z3 4.3.0. + Version 4.3.1 ============= From cefa2d765014b8a41074676d7e4c71a463a2f3cc Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 29 Nov 2012 13:11:34 -0800 Subject: [PATCH 048/133] add option to print with variable declarations Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index ec78f8e92..14de8550e 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -995,6 +995,7 @@ namespace datalog { 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 false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); + p.insert(":print-with-variable-declarations", CPK_BOOL, "(default true) use variable declarations when displaying rules (instead of attempting to use original names)"); PRIVATE_PARAMS( p.insert(":dbg-fpr-nonempty-relation-signature", CPK_BOOL, @@ -1652,6 +1653,7 @@ namespace datalog { 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", false); + bool do_declare_vars = m_params.get_bool(":print-with-variable-declarations", true); #define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); @@ -1708,7 +1710,7 @@ namespace datalog { out << "))\n"; } - if (use_fixedpoint_extensions) { + if (use_fixedpoint_extensions && do_declare_vars) { declare_vars(rules, fresh_names, out); } From 646ace6842d905c80e2e6242546b186ff0333709 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 29 Nov 2012 14:56:09 -0800 Subject: [PATCH 049/133] fix bugs uncovered from running non-Horn SDV samples Signed-off-by: Nikolaj Bjorner --- src/muz_qe/horn_tactic.cpp | 37 ++++++++++++++++++++------------- src/muz_qe/pdr_context.cpp | 6 ++---- src/muz_qe/pdr_util.cpp | 13 +++++++++--- src/smt/theory_diff_logic_def.h | 2 ++ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 59e9e6fec..930bd5483 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -90,21 +90,30 @@ class horn_tactic : public tactic { m_ctx.register_predicate(to_app(a)->get_decl(), true); } - void check_predicate(expr* a) { - expr* a1 = 0; - while (true) { + void check_predicate(ast_mark& mark, expr* a) { + ptr_vector todo; + todo.push_back(a); + while (!todo.empty()) { + a = todo.back(); + todo.pop_back(); + if (mark.is_marked(a)) { + continue; + } + mark.mark(a, true); if (is_quantifier(a)) { a = to_quantifier(a)->get_expr(); - continue; + todo.push_back(a); } - if (m.is_not(a, a1)) { - a = a1; - continue; + else if (m.is_not(a) || m.is_and(a) || m.is_or(a) || m.is_implies(a)) { + todo.append(to_app(a)->get_num_args(), to_app(a)->get_args()); } - if (is_predicate(a)) { + else if (m.is_ite(a)) { + todo.append(to_app(a)->get_arg(1)); + todo.append(to_app(a)->get_arg(2)); + } + else if (is_predicate(a)) { register_predicate(a); } - break; } } @@ -112,14 +121,15 @@ class horn_tactic : public tactic { formula_kind get_formula_kind(expr_ref& f) { normalize(f); + ast_mark mark; expr_ref_vector args(m), body(m); expr_ref head(m); expr* a = 0, *a1 = 0; datalog::flatten_or(f, args); for (unsigned i = 0; i < args.size(); ++i) { - a = args[i].get(); - check_predicate(a); - if (m.is_not(a, a1) && is_predicate(a1)) { + a = args[i].get(); + check_predicate(mark, a); + if (m.is_not(a, a1)) { body.push_back(a1); } else if (is_predicate(a)) { @@ -128,9 +138,6 @@ class horn_tactic : public tactic { } head = a; } - else if (m.is_not(a, a1)) { - body.push_back(a1); - } else { body.push_back(m.mk_not(a)); } diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 2f43d518c..e56c332a1 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1827,10 +1827,8 @@ namespace pdr { proof_ref pr(m); pr = m.mk_asserted(m.mk_true()); for (unsigned i = 0; i < vars.size(); ++i) { - if (smt::is_value_sort(m, vars[i].get())) { - tmp = mev.eval(M, vars[i].get()); - sub.insert(vars[i].get(), tmp, pr); - } + tmp = mev.eval(M, vars[i].get()); + 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 8a36e9089..db11b5b20 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -608,6 +608,7 @@ namespace pdr { best effort evaluator of extensional array equality. */ void model_evaluator::eval_array_eq(app* e, expr* arg1, expr* arg2) { + TRACE("pdr", tout << "array equality: " << mk_pp(e, m) << "\n";); expr_ref v1(m), v2(m); m_model->eval(arg1, v1); m_model->eval(arg2, v2); @@ -633,7 +634,10 @@ namespace pdr { if (else1 != else2) { if (m.is_value(else1) && m.is_value(else2)) { - set_bool(e, false); + TRACE("pdr", tout + << "defaults are different: " << mk_pp(e, m) << " " + << mk_pp(else1, m) << " " << mk_pp(else2, m) << "\n";); + set_false(e); } else { TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); @@ -659,7 +663,10 @@ namespace pdr { continue; } else if (m.is_value(w1) && m.is_value(w2)) { - set_bool(e, false); + TRACE("pdr", tout << "Equality evaluation: " << mk_pp(e, m) << "\n"; + tout << mk_pp(s1, m) << " |-> " << mk_pp(w1, m) << "\n"; + tout << mk_pp(s2, m) << " |-> " << mk_pp(w2, m) << "\n";); + set_false(e); return; } else { @@ -668,7 +675,7 @@ namespace pdr { return; } } - set_bool(e, true); + set_true(e); } void model_evaluator::eval_eq(app* e, expr* arg1, expr* arg2) { diff --git a/src/smt/theory_diff_logic_def.h b/src/smt/theory_diff_logic_def.h index f0c491f64..9f2c97a84 100644 --- a/src/smt/theory_diff_logic_def.h +++ b/src/smt/theory_diff_logic_def.h @@ -102,6 +102,7 @@ template bool theory_diff_logic::internalize_term(app * term) { bool result = null_theory_var != mk_term(term); CTRACE("arith", !result, tout << "Did not internalize " << mk_pp(term, get_manager()) << "\n";); + TRACE("non_diff_logic", tout << "Terms may not be internalized\n";); found_non_diff_logic_expr(term); return result; } @@ -831,6 +832,7 @@ theory_var theory_diff_logic::mk_var(app* n) { v = mk_var(e); } if (is_interpreted(n)) { + TRACE("non_diff_logic", tout << "Variable should not be interpreted\n";); found_non_diff_logic_expr(n); } TRACE("arith", tout << mk_pp(n, get_manager()) << " |-> " << v << "\n";); From cf28cbab0af8293fe5110ebbf5d8377b8ce40ec4 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 17:19:12 -0800 Subject: [PATCH 050/133] saved params work Signed-off-by: Leonardo de Moura --- .gitignore | 1 + RELEASE_NOTES | 2 +- scripts/mk_util.py | 53 +++- src/api/api_ast.cpp | 4 +- src/api/api_config_params.cpp | 7 +- src/api/api_datalog.cpp | 4 +- src/api/api_solver.cpp | 12 +- src/api/api_tactic.cpp | 4 +- src/ast/normal_forms/nnf.cpp | 26 +- src/ast/normal_forms/nnf.h | 3 + src/ast/pp.cpp | 18 ++ src/ast/pp.h | 6 + src/ast/rewriter/arith_rewriter.cpp | 48 ++-- src/ast/rewriter/array_rewriter.cpp | 8 +- .../bit_blaster/bit_blaster_rewriter.cpp | 12 +- src/ast/rewriter/bool_rewriter.cpp | 25 +- src/ast/rewriter/bv_rewriter.cpp | 32 +-- src/ast/rewriter/poly_rewriter_def.h | 18 +- src/ast/rewriter/th_rewriter.cpp | 22 +- src/ast/rewriter/th_rewriter.h | 4 +- src/cmd_context/basic_cmds.cpp | 51 +--- src/cmd_context/cmd_context.cpp | 22 +- src/cmd_context/cmd_context.h | 5 + src/cmd_context/eval_cmd.cpp | 2 +- src/cmd_context/extra_cmds/dbg_cmds.cpp | 24 +- src/cmd_context/extra_cmds/subpaving_cmds.cpp | 2 +- src/cmd_context/parametric_cmd.cpp | 9 +- src/cmd_context/simplify_cmd.cpp | 18 +- src/cmd_context/tactic_cmds.cpp | 42 +-- .../arith_simplifier_params.cpp | 4 +- src/front_end_params/bit_blaster_params.h | 4 +- src/front_end_params/bv_simplifier_params.h | 4 +- src/front_end_params/cnf_params.cpp | 4 +- src/front_end_params/dyn_ack_params.cpp | 12 +- src/front_end_params/front_end_params.cpp | 54 ++-- src/front_end_params/model_params.cpp | 10 +- src/front_end_params/nnf_params.cpp | 8 +- .../params2front_end_params.cpp | 58 ++-- src/front_end_params/parser_params.cpp | 4 +- .../pattern_inference_params.cpp | 20 +- src/front_end_params/preprocessor_params.h | 36 +-- src/front_end_params/qi_params.h | 42 +-- src/front_end_params/smt_params.cpp | 112 ++++---- src/front_end_params/theory_arith_params.cpp | 88 +++---- src/front_end_params/theory_array_params.h | 20 +- src/front_end_params/theory_bv_params.h | 12 +- src/front_end_params/theory_datatype_params.h | 2 +- src/math/polynomial/algebraic_numbers.cpp | 24 +- src/math/polynomial/algebraic_numbers.h | 3 + src/math/polynomial/polynomial.cpp | 12 +- src/math/polynomial/polynomial.h | 3 + src/math/subpaving/subpaving_t_def.h | 32 +-- .../subpaving/tactic/subpaving_tactic.cpp | 24 +- src/model/model_evaluator.cpp | 12 +- src/muz_qe/datalog_parser.cpp | 2 +- src/muz_qe/dl_bmc_engine.cpp | 2 +- src/muz_qe/dl_cmds.cpp | 14 +- src/muz_qe/dl_context.cpp | 70 ++--- src/muz_qe/dl_context.h | 36 +-- src/muz_qe/dl_mk_array_blast.cpp | 2 +- src/muz_qe/dl_mk_bit_blast.cpp | 6 +- src/muz_qe/dl_mk_rule_inliner.cpp | 6 +- src/muz_qe/dl_smt_relation.cpp | 2 +- src/muz_qe/horn_tactic.cpp | 4 +- src/muz_qe/pdr_context.cpp | 26 +- src/muz_qe/pdr_dl_interface.cpp | 52 ++-- src/muz_qe/pdr_interpolant_provider.cpp | 2 +- src/muz_qe/pdr_prop_solver.cpp | 2 +- src/muz_qe/pdr_reachable_cache.cpp | 2 +- src/muz_qe/pdr_smt_context_manager.cpp | 2 +- src/muz_qe/qe.cpp | 10 +- src/muz_qe/qe_cmd.cpp | 8 +- src/muz_qe/qe_lite.cpp | 14 +- src/muz_qe/qe_sat_tactic.cpp | 16 +- src/muz_qe/qe_tactic.cpp | 4 +- src/nlsat/nlsat_solver.cpp | 32 +-- src/nlsat/tactic/goal2nlsat.cpp | 6 +- src/nlsat/tactic/qfnra_nlsat_tactic.cpp | 8 +- src/sat/sat_asymm_branch.cpp | 12 +- src/sat/sat_config.cpp | 86 +++--- src/sat/sat_probing.cpp | 10 +- src/sat/sat_scc.cpp | 4 +- src/sat/sat_simplifier.cpp | 64 ++--- src/sat/sat_solver.cpp | 2 +- src/sat/tactic/goal2sat.cpp | 12 +- src/sat/tactic/sat_tactic.cpp | 2 +- src/shell/datalog_frontend.cpp | 12 +- src/shell/dimacs_frontend.cpp | 2 +- src/shell/main.cpp | 15 +- src/smt/arith_eq_solver.cpp | 4 +- src/smt/smt_implied_equalities.cpp | 6 +- src/smt/tactic/smt_tactic.cpp | 12 +- src/tactic/aig/aig_tactic.cpp | 8 +- src/tactic/arith/add_bounds_tactic.cpp | 8 +- src/tactic/arith/bound_propagator.cpp | 12 +- src/tactic/arith/bv2int_rewriter.cpp | 2 +- src/tactic/arith/diff_neq_tactic.cpp | 4 +- src/tactic/arith/factor_tactic.cpp | 4 +- src/tactic/arith/fm_tactic.cpp | 32 +-- src/tactic/arith/lia2pb_tactic.cpp | 12 +- src/tactic/arith/nla2bv_tactic.cpp | 12 +- src/tactic/arith/normalize_bounds_tactic.cpp | 4 +- src/tactic/arith/pb2bv_tactic.cpp | 10 +- src/tactic/arith/purify_arith_tactic.cpp | 16 +- src/tactic/arith/recover_01_tactic.cpp | 4 +- src/tactic/bv/bit_blaster_tactic.cpp | 10 +- src/tactic/bv/bv1_blaster_tactic.cpp | 6 +- src/tactic/bv/max_bv_sharing_tactic.cpp | 8 +- src/tactic/core/cofactor_elim_term_ite.cpp | 2 +- src/tactic/core/ctx_simplify_tactic.cpp | 10 +- src/tactic/core/elim_term_ite_tactic.cpp | 4 +- src/tactic/core/elim_uncnstr_tactic.cpp | 4 +- src/tactic/core/nnf_tactic.cpp | 2 +- src/tactic/core/propagate_values_tactic.cpp | 4 +- src/tactic/core/simplify_tactic.cpp | 2 +- src/tactic/core/solve_eqs_tactic.cpp | 12 +- src/tactic/core/split_clause_tactic.cpp | 4 +- src/tactic/core/tseitin_cnf_tactic.cpp | 26 +- src/tactic/fpa/fpa2bv_rewriter.h | 4 +- src/tactic/fpa/qffpa_tactic.cpp | 2 +- src/tactic/sls/sls_tactic.cpp | 48 ++-- src/tactic/smtlogics/qfnra_tactic.cpp | 2 +- src/tactic/smtlogics/quant_tactics.cpp | 2 +- src/tactic/ufbv/macro_finder_tactic.cpp | 4 +- src/test/dl_product_relation.cpp | 2 +- src/util/double_manager.h | 2 +- src/util/gparams.cpp | 249 ++++++++++++++++++ src/util/gparams.h | 122 +++++++++ src/util/params.cpp | 88 ++++++- src/util/params.h | 11 +- 130 files changed, 1469 insertions(+), 948 deletions(-) create mode 100644 src/util/gparams.cpp create mode 100644 src/util/gparams.h diff --git a/.gitignore b/.gitignore index a26ee7565..3fe56e9f3 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ config.status configure install_tactic.cpp mem_initializer.cpp +gparams_register_modules.cpp scripts/config-debug.mk scripts/config-release.mk src/api/api_commands.cpp diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 617b44bd0..4c74b41a5 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -16,7 +16,7 @@ Version 4.3.2 - Fixed incorrect result returned by Z3_solver_get_num_scopes. (Thanks to Herman Venter). This bug was introduced in Z3 4.3.0 -- Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java +- Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java` - Fixed crash when parsing incorrect formulas. The crash was introduced when support for "arithmetic coercions" was added in Z3 4.3.0. diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 4bbaa80a8..0c40d9a56 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1418,6 +1418,7 @@ def mk_auto_src(): mk_pat_db() mk_all_install_tactic_cpps() mk_all_mem_initializer_cpps() + mk_all_gparams_register_modules() # TODO: delete after src/ast/pattern/expr_pattern_match # database.smt ==> database.h @@ -1594,7 +1595,7 @@ def mk_all_install_tactic_cpps(): # This file implements the procedures # void mem_initialize() # void mem_finalize() -# This procedures are invoked by the Z3 memory_manager +# These procedures are invoked by the Z3 memory_manager def mk_mem_initializer_cpp(cnames, path): initializer_cmds = [] finalizer_cmds = [] @@ -1653,6 +1654,56 @@ def mk_all_mem_initializer_cpps(): cnames.append(c.name) mk_mem_initializer_cpp(cnames, c.src_dir) +# Generate an mem_initializer.cpp at path. +# This file implements the procedure +# void gparams_register_modules() +# This procedure is invoked by gparams::init() +def mk_gparams_register_modules(cnames, path): + cmds = [] + mod_cmds = [] + fullname = '%s/gparams_register_modules.cpp' % path + fout = open(fullname, 'w') + fout.write('// Automatically generated file.\n') + fout.write('#include"gparams.h"\n') + reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)') + reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') + for cname in cnames: + c = get_component(cname) + h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + for h_file in h_files: + added_include = False + fin = open("%s/%s" % (c.src_dir, h_file), 'r') + for line in fin: + m = reg_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + cmds.append((m.group(1))) + m = reg_mod_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + mod_cmds.append((m.group(1), m.group(2))) + fout.write('void gparams_register_modules() {\n') + for code in cmds: + fout.write('{ param_descrs d; %s(*d); gparams::register_global(d); }\n' % code) + for (mod, code) in mod_cmds: + fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) + fout.write('}\n') + if VERBOSE: + print "Generated '%s'" % fullname + +def mk_all_gparams_register_modules(): + if not ONLY_MAKEFILES: + for c in get_components(): + if c.require_mem_initializer(): + cnames = [] + cnames.extend(c.deps) + cnames.append(c.name) + mk_gparams_register_modules(cnames, c.src_dir) + # Generate a .def based on the files at c.export_files slot. def mk_def_file(c): pat1 = re.compile(".*Z3_API.*") diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index aeddf63c3..1503b387f 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -674,8 +674,8 @@ extern "C" { ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); params_ref p = to_param_ref(_p); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = p.get_bool(":ctrl-c", false); + unsigned timeout = p.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = p.get_bool("ctrl_c", false); th_rewriter m_rw(m, p); expr_ref result(m); cancel_eh eh(m_rw); diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 07e043726..550212cf9 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -21,6 +21,7 @@ Revision History: #include"pp.h" #include"api_log_macros.h" #include"api_util.h" +#include"cmd_context.h" #include"symbol.h" namespace api { @@ -41,8 +42,6 @@ namespace api { }; -extern std::string smt_keyword2opt_name(symbol const & opt); - extern "C" { Z3_config Z3_API Z3_mk_config() { LOG_Z3_mk_config(); @@ -62,7 +61,7 @@ extern "C" { api::config_params* p = reinterpret_cast(c); if (param_id != 0 && param_id[0] == ':') { // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt_keyword2opt_name(symbol(param_id)); + std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); p->m_ini.set_param_value(new_param_id.c_str(), param_value); } else { @@ -91,7 +90,7 @@ extern "C" { } if (param_id != 0 && param_id[0] == ':') { // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt_keyword2opt_name(symbol(param_id)); + std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); ini.set_param_value(new_param_id.c_str(), param_value); } else { diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 0200a4405..3c434600b 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -265,7 +265,7 @@ extern "C" { RESET_ERROR_CODE(); lbool r = l_undef; cancel_eh eh(*to_fixedpoint_ref(d)); - unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); api::context::set_interruptable(*(mk_c(c)), eh); { scoped_timer timer(timeout, &eh); @@ -289,7 +289,7 @@ extern "C" { LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations); RESET_ERROR_CODE(); lbool r = l_undef; - unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); cancel_eh eh(*to_fixedpoint_ref(d)); api::context::set_interruptable(*(mk_c(c)), eh); { diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 790ca8f59..a85e8d83a 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -37,8 +37,8 @@ extern "C" { ast_manager & m = mk_c(c)->m(); Z3_solver_ref * s = to_solver(_s); s->m_solver->set_produce_proofs(m.proofs_enabled()); - s->m_solver->set_produce_unsat_cores(s->m_params.get_bool(":unsat-core", false)); - s->m_solver->set_produce_models(s->m_params.get_bool(":model", true)); + s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); + s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); s->m_solver->set_front_end_params(mk_c(c)->fparams()); s->m_solver->updt_params(s->m_params); s->m_solver->init(m, s->m_logic); @@ -127,8 +127,8 @@ extern "C" { LOG_Z3_solver_set_params(c, s, p); RESET_ERROR_CODE(); if (to_solver(s)->m_initialized) { - bool old_model = to_solver(s)->m_params.get_bool(":model", true); - bool new_model = to_param_ref(p).get_bool(":model", true); + bool old_model = to_solver(s)->m_params.get_bool("model", true); + bool new_model = to_param_ref(p).get_bool("model", true); if (old_model != new_model) to_solver_ref(s)->set_produce_models(new_model); to_solver_ref(s)->updt_params(to_param_ref(p)); @@ -238,8 +238,8 @@ extern "C" { } } expr * const * _assumptions = to_exprs(assumptions); - unsigned timeout = to_solver(s)->m_params.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = to_solver(s)->m_params.get_bool(":ctrl-c", false); + unsigned timeout = to_solver(s)->m_params.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh eh(*to_solver_ref(s)); api::context::set_interruptable(*(mk_c(c)), eh); lbool result; diff --git a/src/api/api_tactic.cpp b/src/api/api_tactic.cpp index ff55923a4..5bce218e6 100644 --- a/src/api/api_tactic.cpp +++ b/src/api/api_tactic.cpp @@ -404,8 +404,8 @@ extern "C" { Z3_apply_result_ref * ref = alloc(Z3_apply_result_ref, mk_c(c)->m()); mk_c(c)->save_object(ref); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = p.get_bool(":ctrl-c", false); + unsigned timeout = p.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = p.get_bool("ctrl_c", false); cancel_eh eh(*to_tactic_ref(t)); to_tactic_ref(t)->updt_params(p); diff --git a/src/ast/normal_forms/nnf.cpp b/src/ast/normal_forms/nnf.cpp index 4d8849178..d525fa167 100644 --- a/src/ast/normal_forms/nnf.cpp +++ b/src/ast/normal_forms/nnf.cpp @@ -122,11 +122,11 @@ public: } void updt_params(params_ref const & p) { - m_sk_hack_enabled = p.get_bool(":nnf-sk-hack", false); + m_sk_hack_enabled = p.get_bool("sk_hack", false); } static void get_param_descrs(param_descrs & r) { - r.insert(":nnf-sk-hack", CPK_BOOL, "(default: false) hack for VCC"); + r.insert("sk_hack", CPK_BOOL, "(default: false) hack for VCC"); } ast_manager & m() const { return m_manager; } @@ -264,7 +264,7 @@ struct nnf::imp { } void updt_local_params(params_ref const & p) { - symbol mode_sym = p.get_sym(":nnf-mode", m_skolem); + symbol mode_sym = p.get_sym("mode", m_skolem); if (mode_sym == m_skolem) m_mode = NNF_SKOLEM; else if (mode_sym == "full") @@ -276,18 +276,18 @@ struct nnf::imp { TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << p << "\n";); - m_ignore_labels = p.get_bool(":nnf-ignore-labels", false); - m_skolemize = p.get_bool(":skolemize", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_ignore_labels = p.get_bool("ignore_labels", false); + m_skolemize = p.get_bool("skolemize", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } static void get_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":nnf-mode", CPK_SYMBOL, + r.insert("mode", CPK_SYMBOL, "(default: skolem) NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full"); - r.insert(":nnf-ignore-labels", CPK_BOOL, + r.insert("ignore_labels", CPK_BOOL, "(default: false) remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - r.insert(":skolemize", CPK_BOOL, + r.insert("skolemize", CPK_BOOL, "(default: true) skolemize (existential force) quantifiers"); skolemizer::get_param_descrs(r); } @@ -884,15 +884,15 @@ nnf::nnf(ast_manager & m, defined_names & n, params_ref const & p) { nnf::nnf(ast_manager & m, defined_names & n, nnf_params & np) { params_ref p; if (np.m_nnf_mode == NNF_FULL) - p.set_sym(":nnf-mode", symbol("full")); + p.set_sym("mode", symbol("full")); else if (np.m_nnf_mode == NNF_QUANT) - p.set_sym(":nnf-mode", symbol("quantifiers")); + p.set_sym("mode", symbol("quantifiers")); if (np.m_nnf_ignore_labels) - p.set_bool(":nnf-ignore-labels", true); + p.set_bool("ignore_labels", true); if (np.m_nnf_sk_hack) - p.set_bool(":nnf-sk-hack", true); + p.set_bool("sk_hack", true); m_imp = alloc(imp, m, n, p); } diff --git a/src/ast/normal_forms/nnf.h b/src/ast/normal_forms/nnf.h index 685083ff7..96807afc0 100644 --- a/src/ast/normal_forms/nnf.h +++ b/src/ast/normal_forms/nnf.h @@ -41,6 +41,9 @@ public: ); void updt_params(params_ref const & p); + /* + REG_MODULE_PARAMS('nnf', 'nnf::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); void cancel() { set_cancel(true); } diff --git a/src/ast/pp.cpp b/src/ast/pp.cpp index 43f19e166..d05776e78 100644 --- a/src/ast/pp.cpp +++ b/src/ast/pp.cpp @@ -19,6 +19,24 @@ Revision History: #include"pp.h" using namespace format_ns; +void pp_param_descrs(param_descrs & p) { + p.insert("max_indent", CPK_UINT, "max. indentation in pretty printer"); + p.insert("max_num_lines", CPK_UINT, "max. number of lines to be displayed in pretty printer"); + p.insert("max_width", CPK_UINT, "max. width in pretty printer"); + p.insert("max_ribbon", CPK_UINT, "max. ribbon (width - indentation) in pretty printer"); + p.insert("max_depth", CPK_UINT, "max. term depth (when pretty printing SMT2 terms/formulas)"); + p.insert("min_alias_size", CPK_UINT, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)"); + p.insert("decimal", CPK_BOOL, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise"); + p.insert("decimal_precision", CPK_BOOL, "maximum number of decimal places to be used when pp.decimal=true"); + p.insert("bv_literals", CPK_BOOL, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing"); + p.insert("bv_neg", CPK_BOOL, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1"); + p.insert("flat_assoc", CPK_BOOL, "flat associative operators (when pretty printing SMT2 terms/formulas)"); + p.insert("fixed_indent", CPK_BOOL, "use a fixed indentation for applications"); + p.insert("single_line", CPK_BOOL, "ignore line breaks when true"); + p.insert("bounded", CPK_BOOL, "ignore characters exceeding max widht"); + p.insert("simplify_implies", CPK_BOOL, "simplify nested implications for pretty printing"); +} + pp_params g_pp_params; void set_pp_default_params(pp_params const & p) { diff --git a/src/ast/pp.h b/src/ast/pp.h index 43c1de7b7..13afcb07c 100644 --- a/src/ast/pp.h +++ b/src/ast/pp.h @@ -21,6 +21,12 @@ Revision History: #include"format.h" #include"pp_params.h" +#include"params.h" + +/* + REG_MODULE_PARAMS('pp', 'pp_param_descrs') +*/ +void pp_param_descrs(param_descrs & d); void set_pp_default_params(pp_params const & p); void register_pp_params(ini_params & p); diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index 3efc14abe..f5fdcf8af 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -22,18 +22,18 @@ Notes: #include"ast_pp.h" void arith_rewriter::updt_local_params(params_ref const & p) { - m_arith_lhs = p.get_bool(":arith-lhs", false); - m_gcd_rounding = p.get_bool(":gcd-rounding", false); - m_eq2ineq = p.get_bool(":eq2ineq", false); - m_elim_to_real = p.get_bool(":elim-to-real", false); - m_push_to_real = p.get_bool(":push-to-real", true); - m_anum_simp = p.get_bool(":algebraic-number-evaluator", true); - m_max_degree = p.get_uint(":max-degree", 64); - m_expand_power = p.get_bool(":expand-power", false); - m_mul2power = p.get_bool(":mul-to-power", false); - m_elim_rem = p.get_bool(":elim-rem", false); - m_expand_tan = p.get_bool(":expand-tan", false); - set_sort_sums(p.get_bool(":sort-sums", false)); // set here to avoid collision with bvadd + m_arith_lhs = p.get_bool("arith_lhs", false); + m_gcd_rounding = p.get_bool("gcd_rounding", false); + m_eq2ineq = p.get_bool("eq2ineq", false); + m_elim_to_real = p.get_bool("elim_to_real", false); + m_push_to_real = p.get_bool("push_to_real", true); + m_anum_simp = p.get_bool("algebraic_number_evaluator", true); + m_max_degree = p.get_uint("max_degree", 64); + m_expand_power = p.get_bool("expand_power", false); + m_mul2power = p.get_bool("mul_to_power", false); + m_elim_rem = p.get_bool("elim_rem", false); + m_expand_tan = p.get_bool("expand_tan", false); + set_sort_sums(p.get_bool("sort_sums", false)); // set here to avoid collision with bvadd } void arith_rewriter::updt_params(params_ref const & p) { @@ -43,18 +43,18 @@ void arith_rewriter::updt_params(params_ref const & p) { void arith_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert(":algebraic-number-evaluator", CPK_BOOL, "(default: true) simplify/evaluate expressions containing (algebraic) irrational numbers."); - r.insert(":mul-to-power", CPK_BOOL, "(default: false) collpase (* t ... t) into (^ t k), it is ignored if :expand-power is true."); - r.insert(":expand-power", CPK_BOOL, "(default: false) expand (^ t k) into (* t ... t) if 1 < k <= :max-degree."); - r.insert(":expand-tan", CPK_BOOL, "(default: false) replace (tan x) with (/ (sin x) (cos x))."); - r.insert(":max-degree", CPK_UINT, "(default: 64) max degree of algebraic numbers (and power operators) processed by simplifier."); - r.insert(":eq2ineq", CPK_BOOL, "(default: false) split arithmetic equalities into two inequalities."); - r.insert(":sort-sums", CPK_BOOL, "(default: false) sort the arguments of + application."); - r.insert(":gcd-rounding", CPK_BOOL, "(default: false) use gcd rounding on integer arithmetic atoms."); - r.insert(":arith-lhs", CPK_BOOL, "(default: false) all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."); - r.insert(":elim-to-real", CPK_BOOL, "(default: false) eliminate to_real from arithmetic predicates that contain only integers."); - r.insert(":push-to-real", CPK_BOOL, "(default: true) distribute to_real over * and +."); - r.insert(":elim-rem", CPK_BOOL, "(default: false) replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."); + r.insert("algebraic_number_evaluator", CPK_BOOL, "(default: true) simplify/evaluate expressions containing (algebraic) irrational numbers."); + r.insert("mul_to_power", CPK_BOOL, "(default: false) collpase (* t ... t) into (^ t k), it is ignored if expand_power is true."); + r.insert("expand_power", CPK_BOOL, "(default: false) expand (^ t k) into (* t ... t) if 1 < k <= max_degree."); + r.insert("expand_tan", CPK_BOOL, "(default: false) replace (tan x) with (/ (sin x) (cos x))."); + r.insert("max_degree", CPK_UINT, "(default: 64) max degree of algebraic numbers (and power operators) processed by simplifier."); + r.insert("eq2ineq", CPK_BOOL, "(default: false) split arithmetic equalities into two inequalities."); + r.insert("sort_sums", CPK_BOOL, "(default: false) sort the arguments of + application."); + r.insert("gcd_rounding", CPK_BOOL, "(default: false) use gcd rounding on integer arithmetic atoms."); + r.insert("arith_lhs", CPK_BOOL, "(default: false) all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."); + r.insert("elim_to_real", CPK_BOOL, "(default: false) eliminate to_real from arithmetic predicates that contain only integers."); + r.insert("push_to_real", CPK_BOOL, "(default: true) distribute to_real over * and +."); + r.insert("elim_rem", CPK_BOOL, "(default: false) replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."); } br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/array_rewriter.cpp b/src/ast/rewriter/array_rewriter.cpp index 268f4dca0..ac93e0f87 100644 --- a/src/ast/rewriter/array_rewriter.cpp +++ b/src/ast/rewriter/array_rewriter.cpp @@ -21,13 +21,13 @@ Notes: #include"ast_pp.h" void array_rewriter::updt_params(params_ref const & p) { - m_sort_store = p.get_bool(":sort-store", false); - m_expand_select_store = p.get_bool(":expand-select-store", false); + m_sort_store = p.get_bool("sort_store", false); + m_expand_select_store = p.get_bool("expand_select_store", false); } void array_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":expand-select-store", CPK_BOOL, "(default: false) replace a (select (store ...) ...) term by an if-then-else term."); - r.insert(":sort-store", CPK_BOOL, "(default: false) sort nested stores when the indices are known to be different."); + r.insert("expand_select_store", CPK_BOOL, "(default: false) replace a (select (store ...) ...) term by an if-then-else term."); + r.insert("sort_store", CPK_BOOL, "(default: false) sort nested stores when the indices are known to be different."); } br_status array_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp index c64ea56d0..1fd83e91f 100644 --- a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp +++ b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp @@ -125,12 +125,12 @@ struct blaster_rewriter_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_blast_add = p.get_bool(":blast-add", true); - m_blast_mul = p.get_bool(":blast-mul", true); - m_blast_full = p.get_bool(":blast-full", false); - m_blast_quant = p.get_bool(":blast-quant", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_blast_add = p.get_bool("blast_add", true); + m_blast_mul = p.get_bool("blast_mul", true); + m_blast_full = p.get_bool("blast_full", false); + m_blast_quant = p.get_bool("blast_quant", false); m_blaster.set_max_memory(m_max_memory); } diff --git a/src/ast/rewriter/bool_rewriter.cpp b/src/ast/rewriter/bool_rewriter.cpp index b7fe296c4..b3f422fe5 100644 --- a/src/ast/rewriter/bool_rewriter.cpp +++ b/src/ast/rewriter/bool_rewriter.cpp @@ -20,21 +20,22 @@ Notes: #include"rewriter_def.h" void bool_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_elim_and = p.get_bool(":elim-and", false); - m_local_ctx = p.get_bool(":local-ctx", false); - m_local_ctx_limit = p.get_uint(":local-ctx-limit", UINT_MAX); - m_blast_distinct = p.get_bool(":blast-distinct", false); - m_ite_extra_rules = p.get_bool(":ite-extra-rules", false); + m_flat = p.get_bool("flat", true); + m_elim_and = p.get_bool("elim_and", false); + m_local_ctx = p.get_bool("local_ctx", false); + m_local_ctx_limit = p.get_uint("local_ctx_limit", UINT_MAX); + m_blast_distinct = p.get_bool("blast_distinct", false); + m_ite_extra_rules = p.get_bool("ite_extra_rules", false); } void bool_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":ite-extra-rules", CPK_BOOL, "(default: false) extra ite simplifications, these additional simplifications may reduce size locally but increase globally."); - r.insert(":flat", CPK_BOOL, "(default: true) create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor."); - r.insert(":elim-and", CPK_BOOL, "(default: false) conjunctions are rewritten using negation and disjunctions."); - r.insert(":local-ctx", CPK_BOOL, "(default: false) perform local (i.e., cheap) context simplifications."); - r.insert(":local-ctx-limit", CPK_UINT, "(default: inf) limit for applying local context simplifier."); - r.insert(":blast-distinct", CPK_BOOL, "(default: false) expand a distinct predicate into a quadratic number of disequalities."); + r.insert("ite_extra_rules", CPK_BOOL, + "(default: false) extra ite simplifications, these additional simplifications may reduce size locally but increase globally."); + r.insert("flat", CPK_BOOL, "(default: true) create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor."); + r.insert("elim_and", CPK_BOOL, "(default: false) conjunctions are rewritten using negation and disjunctions."); + r.insert("local_ctx", CPK_BOOL, "(default: false) perform local (i.e., cheap) context simplifications."); + r.insert("local_ctx_limit", CPK_UINT, "(default: inf) limit for applying local context simplifier."); + r.insert("blast_distinct", CPK_BOOL, "(default: false) expand a distinct predicate into a quadratic number of disequalities."); } br_status bool_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/bv_rewriter.cpp b/src/ast/rewriter/bv_rewriter.cpp index adef6a5b0..fbc1f7c11 100644 --- a/src/ast/rewriter/bv_rewriter.cpp +++ b/src/ast/rewriter/bv_rewriter.cpp @@ -54,14 +54,14 @@ app * mk_extract_proc::operator()(unsigned high, unsigned low, expr * arg) { } void bv_rewriter::updt_local_params(params_ref const & p) { - m_hi_div0 = p.get_bool(":hi-div0", true); - m_elim_sign_ext = p.get_bool(":elim-sign-ext", true); - m_mul2concat = p.get_bool(":mul2concat", false); - m_bit2bool = p.get_bool(":bit2bool", true); - m_blast_eq_value = p.get_bool(":blast-eq-value", false); - m_mkbv2num = p.get_bool(":mkbv2num", false); - m_split_concat_eq = p.get_bool(":split-concat-eq", false); - m_udiv2mul = p.get_bool(":udiv2mul", false); + m_hi_div0 = p.get_bool("hi_div0", true); + m_elim_sign_ext = p.get_bool("elim_sign_ext", true); + m_mul2concat = p.get_bool("mul2concat", false); + m_bit2bool = p.get_bool("bit2bool", true); + m_blast_eq_value = p.get_bool("blast_eq_value", false); + m_mkbv2num = p.get_bool("mkbv2num", false); + m_split_concat_eq = p.get_bool("split_concat_eq", false); + m_udiv2mul = p.get_bool("udiv2mul", false); } void bv_rewriter::updt_params(params_ref const & p) { @@ -71,15 +71,15 @@ void bv_rewriter::updt_params(params_ref const & p) { void bv_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert(":udiv2mul", CPK_BOOL, "(default: false) convert constant udiv to mul."); - r.insert(":split-concat-eq", CPK_BOOL, "(default: false) split equalities of the form (= (concat t1 t2) t3)."); - r.insert(":bit2bool", CPK_BOOL, "(default: true) try to convert bit-vector terms of size 1 into Boolean terms."); - r.insert(":blast-eq-value", CPK_BOOL, "(default: false) blast (some) Bit-vector equalities into bits."); - r.insert(":elim-sign-ext", CPK_BOOL, "(default: true) expand sign-ext operator using concat and extract."); - r.insert(":hi-div0", CPK_BOOL, "(default: true) use the 'hardware interpretation' for division by zero (for bit-vector terms)."); - r.insert(":mul2concat", CPK_BOOL, "(default: false) replace multiplication by a power of two into a concatenation."); + r.insert("udiv2mul", CPK_BOOL, "(default: false) convert constant udiv to mul."); + r.insert("split_concat_eq", CPK_BOOL, "(default: false) split equalities of the form (= (concat t1 t2) t3)."); + r.insert("bit2bool", CPK_BOOL, "(default: true) try to convert bit-vector terms of size 1 into Boolean terms."); + r.insert("blast_eq_value", CPK_BOOL, "(default: false) blast (some) Bit-vector equalities into bits."); + r.insert("elim_sign_ext", CPK_BOOL, "(default: true) expand sign-ext operator using concat and extract."); + r.insert("hi_div0", CPK_BOOL, "(default: true) use the 'hardware interpretation' for division by zero (for bit-vector terms)."); + r.insert("mul2concat", CPK_BOOL, "(default: false) replace multiplication by a power of two into a concatenation."); #ifndef _EXTERNAL_RELEASE - r.insert(":mkbv2num", CPK_BOOL, "(default: false) convert (mkbv [true/false]*) into a numeral"); + r.insert("mkbv2num", CPK_BOOL, "(default: false) convert (mkbv [true/false]*) into a numeral"); #endif } diff --git a/src/ast/rewriter/poly_rewriter_def.h b/src/ast/rewriter/poly_rewriter_def.h index e942b453a..e6c8a653c 100644 --- a/src/ast/rewriter/poly_rewriter_def.h +++ b/src/ast/rewriter/poly_rewriter_def.h @@ -27,19 +27,19 @@ char const * poly_rewriter::g_ste_blowup_msg = "sum of monomials blowup" template void poly_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_som = p.get_bool(":som", false); - m_hoist_mul = p.get_bool(":hoist-mul", false); - m_hoist_cmul = p.get_bool(":hoist-cmul", false); - m_som_blowup = p.get_uint(":som-blowup", UINT_MAX); + m_flat = p.get_bool("flat", true); + m_som = p.get_bool("som", false); + m_hoist_mul = p.get_bool("hoist_mul", false); + m_hoist_cmul = p.get_bool("hoist_cmul", false); + m_som_blowup = p.get_uint("som_blowup", UINT_MAX); } template void poly_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":som", CPK_BOOL, "(default: false) put polynomials in som-of-monomials form."); - r.insert(":som-blowup", CPK_UINT, "(default: infty) maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"); - r.insert(":hoist-mul", CPK_BOOL, "(default: false) hoist multiplication over summation to minimize number of multiplications"); - r.insert(":hoist-cmul", CPK_BOOL, "(default: false) hoist constant multiplication over summation to minimize number of multiplications"); + r.insert("som", CPK_BOOL, "(default: false) put polynomials in som-of-monomials form."); + r.insert("som_blowup", CPK_UINT, "(default: infty) maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"); + r.insert("hoist_mul", CPK_BOOL, "(default: false) hoist multiplication over summation to minimize number of multiplications"); + r.insert("hoist_cmul", CPK_BOOL, "(default: false) hoist constant multiplication over summation to minimize number of multiplications"); } template diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index ee55d53e7..da4dd3860 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -57,13 +57,13 @@ struct th_rewriter_cfg : public default_rewriter_cfg { ast_manager & m() const { return m_b_rw.m(); } void updt_local_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_pull_cheap_ite = p.get_bool(":pull-cheap-ite", false); - m_cache_all = p.get_bool(":cache-all", false); - m_push_ite_arith = p.get_bool(":push-ite-arith", false); - m_push_ite_bv = p.get_bool(":push-ite-bv", false); + m_flat = p.get_bool("flat", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_pull_cheap_ite = p.get_bool("pull_cheap_ite", false); + m_cache_all = p.get_bool("cache_all", false); + m_push_ite_arith = p.get_bool("push_ite_arith", false); + m_push_ite_bv = p.get_bool("push_ite_bv", false); } void updt_params(params_ref const & p) { @@ -695,10 +695,10 @@ void th_rewriter::get_param_descrs(param_descrs & r) { array_rewriter::get_param_descrs(r); insert_max_memory(r); insert_max_steps(r); - r.insert(":push-ite-arith", CPK_BOOL, "(default: false) push if-then-else over arithmetic terms."); - r.insert(":push-ite-bv", CPK_BOOL, "(default: false) push if-then-else over bit-vector terms."); - r.insert(":pull-cheap-ite", CPK_BOOL, "(default: false) pull if-then-else terms when cheap."); - r.insert(":cache-all", CPK_BOOL, "(default: false) cache all intermediate results."); + r.insert("push_ite_arith", CPK_BOOL, "(default: false) push if-then-else over arithmetic terms."); + r.insert("push_ite_bv", CPK_BOOL, "(default: false) push if-then-else over bit-vector terms."); + r.insert("pull_cheap_ite", CPK_BOOL, "(default: false) pull if-then-else terms when cheap."); + r.insert("cache_all", CPK_BOOL, "(default: false) cache all intermediate results."); } th_rewriter::~th_rewriter() { diff --git a/src/ast/rewriter/th_rewriter.h b/src/ast/rewriter/th_rewriter.h index 1b77c42c7..19a89d286 100644 --- a/src/ast/rewriter/th_rewriter.h +++ b/src/ast/rewriter/th_rewriter.h @@ -37,7 +37,9 @@ public: void updt_params(params_ref const & p); static void get_param_descrs(param_descrs & r); - + /* + REG_MODULE_PARAMS('simplify', 'th_rewriter::get_param_descrs') + */ unsigned get_cache_size() const; unsigned get_num_steps() const; diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 4c24b5ae6..1960cd22a 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -28,6 +28,7 @@ Notes: #include"simplify_cmd.h" #include"eval_cmd.h" #include"front_end_params.h" +#include"gparams.h" class help_cmd : public cmd { svector m_cmds; @@ -219,25 +220,6 @@ UNARY_CMD(pp_cmd, "display", "", "display the given term.", CPK_EXPR, expr UNARY_CMD(echo_cmd, "echo", "", "display the given string", CPK_STRING, char const *, ctx.regular_stream() << arg << std::endl;); -/** - \brief Convert a keyword into an internal Z3 option name -*/ -std::string smt_keyword2opt_name(symbol const & opt) { - std::string r; - SASSERT(opt.bare_str()[0] == ':'); - r = opt.bare_str() + 1; - unsigned sz = static_cast(r.size()); - for (unsigned i = 0; i < sz; i++) { - char curr = r[i]; - if ('a' <= curr && curr <= 'z') - r[i] = 'A' + (curr - 'a'); - else if (curr == '-') - r[i] = '_'; - } - TRACE("smt2_opt_name", tout << opt << " -> '" << r << "'\n";); - return r; -} - class set_get_option_cmd : public cmd { protected: symbol m_true; @@ -259,7 +241,6 @@ protected: symbol m_numeral_as_real; symbol m_error_behavior; symbol m_int_real_coercions; - ini_params m_ini; bool is_builtin_option(symbol const & s) const { return @@ -289,10 +270,7 @@ public: m_global_decls(":global-decls"), m_numeral_as_real(":numeral-as-real"), m_error_behavior(":error-behavior"), - m_int_real_coercions(":int-real-coercions"), - m_ini(false) { - params.register_params(m_ini); - register_pp_params(m_ini); + m_int_real_coercions(":int-real-coercions") { } virtual ~set_get_option_cmd() {} @@ -324,22 +302,11 @@ class set_option_cmd : public set_get_option_cmd { } void set_param(cmd_context & ctx, char const * value) { - m_ini.freeze(ctx.has_manager()); - std::string internal_opt = smt_keyword2opt_name(m_option); try { - std::string old_value; - if (!m_ini.get_param_value(internal_opt.c_str(), old_value)) { - m_unsupported = true; - return; - } - m_ini.set_param_value(internal_opt.c_str(), value); + gparams::set(m_option, value); } - catch (set_get_param_exception ex) { - std::string msg = "error setting '"; - msg += m_option.str(); - msg += "', "; - msg += ex.get_msg(); - throw cmd_exception(msg); + catch (gparams::exception ex) { + throw cmd_exception(ex.msg()); } } @@ -545,12 +512,10 @@ public: print_bool(ctx, ctx.m().int_real_coercions()); } else { - std::string iopt = smt_keyword2opt_name(opt); - std::string r; - if (m_ini.get_param_value(iopt.c_str(), r)) { - ctx.regular_stream() << r << std::endl; + try { + std::string val = gparams::get_value(opt); } - else { + catch (gparams::exception ex) { ctx.print_unsupported(opt); } } diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index afcac48ac..d14ce3076 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -39,6 +39,22 @@ Notes: #include"model_evaluator.h" #include"for_each_expr.h" +std::string smt2_keyword_to_param(symbol const & opt) { + std::string r; + SASSERT(opt.bare_str()[0] == ':'); + r = opt.bare_str() + 1; + unsigned sz = static_cast(r.size()); + for (unsigned i = 0; i < sz; i++) { + char curr = r[i]; + if ('A' <= curr && curr <= 'Z') + r[i] = curr - 'A' + 'a'; + else if (curr == '-') + r[i] = '_'; + } + TRACE("smt2_keyword_to_param", tout << opt << " -> '" << r << "'\n";); + return r; +} + func_decls::func_decls(ast_manager & m, func_decl * f): m_decls(TAG(func_decl*, f, 0)) { m.inc_ref(f); @@ -1400,9 +1416,9 @@ void cmd_context::validate_model() { get_check_sat_result()->get_model(md); SASSERT(md.get() != 0); params_ref p; - p.set_uint(":max-degree", UINT_MAX); // evaluate algebraic numbers of any degree. - p.set_uint(":sort-store", true); - p.set_bool(":model-completion", true); + p.set_uint("max_degree", UINT_MAX); // evaluate algebraic numbers of any degree. + p.set_uint("sort_store", true); + p.set_bool("model_completion", true); model_evaluator evaluator(*(md.get()), p); contains_array_op_proc contains_array(m()); { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 5f83e0224..6688f66d9 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -37,6 +37,11 @@ Notes: #include"progress_callback.h" #include"scoped_ptr_vector.h" +/** + \brief Auxiliary function for converting SMT2 keywords into Z3 internal parameter names. +*/ +std::string smt2_keyword_to_param(symbol const & k); + struct front_end_params; class func_decls { diff --git a/src/cmd_context/eval_cmd.cpp b/src/cmd_context/eval_cmd.cpp index fe9c738a2..7ebe2f54f 100644 --- a/src/cmd_context/eval_cmd.cpp +++ b/src/cmd_context/eval_cmd.cpp @@ -62,7 +62,7 @@ public: SASSERT(last_result); last_result->get_model(md); expr_ref r(ctx.m()); - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); model_evaluator ev(*(md.get()), m_params); cancel_eh eh(ev); { diff --git a/src/cmd_context/extra_cmds/dbg_cmds.cpp b/src/cmd_context/extra_cmds/dbg_cmds.cpp index b7b4f058d..509b5ff2e 100644 --- a/src/cmd_context/extra_cmds/dbg_cmds.cpp +++ b/src/cmd_context/extra_cmds/dbg_cmds.cpp @@ -141,8 +141,8 @@ public: UNARY_CMD(bool_rewriter_cmd, "dbg-bool-rewriter", "", "apply the Boolean rewriter to the given term", CPK_EXPR, expr *, { expr_ref t(ctx.m()); params_ref p; - p.set_bool(":flat", false); - SASSERT(p.get_bool(":flat", true) == false); + p.set_bool("flat", false); + SASSERT(p.get_bool("flat", true) == false); bool_rewriter_star r(ctx.m(), p); r(arg, t); ctx.display(ctx.regular_stream(), t); @@ -153,7 +153,7 @@ UNARY_CMD(bool_frewriter_cmd, "dbg-bool-flat-rewriter", "", "apply the Boo expr_ref t(ctx.m()); { params_ref p; - p.set_bool(":flat", true); + p.set_bool("flat", true); bool_rewriter_star r(ctx.m(), p); r(arg, t); } @@ -165,8 +165,8 @@ UNARY_CMD(elim_and_cmd, "dbg-elim-and", "", "apply the Boolean rewriter (e expr_ref t(ctx.m()); { params_ref p; - p.set_bool(":flat", true); - p.set_bool(":elim-and", true); + p.set_bool("flat", true); + p.set_bool("elim_and", true); bool_rewriter_star r(ctx.m(), p); r(arg, t); } @@ -208,15 +208,15 @@ UNARY_CMD(some_value_cmd, "dbg-some-value", "", "retrieve some value of th void tst_params(cmd_context & ctx) { params_ref p1; params_ref p2; - p1.set_uint(":val", 100); + p1.set_uint("val", 100); p2 = p1; - SASSERT(p2.get_uint(":val", 0) == 100); - p2.set_uint(":val", 200); - SASSERT(p2.get_uint(":val", 0) == 200); - SASSERT(p1.get_uint(":val", 0) == 100); + SASSERT(p2.get_uint("val", 0) == 100); + p2.set_uint("val", 200); + SASSERT(p2.get_uint("val", 0) == 200); + SASSERT(p1.get_uint("val", 0) == 100); p2 = p1; - SASSERT(p2.get_uint(":val", 0) == 100); - SASSERT(p1.get_uint(":val", 0) == 100); + SASSERT(p2.get_uint("val", 0) == 100); + SASSERT(p1.get_uint("val", 0) == 100); ctx.regular_stream() << "worked" << std::endl; } diff --git a/src/cmd_context/extra_cmds/subpaving_cmds.cpp b/src/cmd_context/extra_cmds/subpaving_cmds.cpp index 9b84ddf68..632f558dc 100644 --- a/src/cmd_context/extra_cmds/subpaving_cmds.cpp +++ b/src/cmd_context/extra_cmds/subpaving_cmds.cpp @@ -31,7 +31,7 @@ static void to_subpaving(cmd_context & ctx, expr * t) { expr2var e2v(m); expr2subpaving e2s(m, *s, &e2v); params_ref p; - p.set_bool(":mul-to-power", true); + p.set_bool("mul_to_power", true); th_rewriter simp(m, p); expr_ref t_s(m); simp(t, t_s); diff --git a/src/cmd_context/parametric_cmd.cpp b/src/cmd_context/parametric_cmd.cpp index bc06d3ee6..f028c3b9d 100644 --- a/src/cmd_context/parametric_cmd.cpp +++ b/src/cmd_context/parametric_cmd.cpp @@ -16,6 +16,7 @@ Notes: --*/ #include +#include"cmd_context.h" #include"parametric_cmd.h" char const * parametric_cmd::get_descr(cmd_context & ctx) const { @@ -37,13 +38,15 @@ cmd_arg_kind parametric_cmd::next_arg_kind(cmd_context & ctx) const { void parametric_cmd::set_next_arg(cmd_context & ctx, symbol const & s) { if (m_last == symbol::null) { - m_last = s; + m_last = symbol(smt2_keyword_to_param(s).c_str()); if (pdescrs(ctx).get_kind(m_last.bare_str()) == CPK_INVALID) throw cmd_exception("invalid keyword argument"); return; } - m_params.set_sym(m_last.bare_str(), s); - m_last = symbol::null; + else { + m_params.set_sym(m_last.bare_str(), s); + m_last = symbol::null; + } } param_descrs const & parametric_cmd::pdescrs(cmd_context & ctx) const { diff --git a/src/cmd_context/simplify_cmd.cpp b/src/cmd_context/simplify_cmd.cpp index 089eb353b..3a1828a51 100644 --- a/src/cmd_context/simplify_cmd.cpp +++ b/src/cmd_context/simplify_cmd.cpp @@ -40,9 +40,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { th_rewriter::get_param_descrs(p); insert_timeout(p); - p.insert(":print", CPK_BOOL, "(default: true) print the simplified term."); - p.insert(":print-proofs", CPK_BOOL, "(default: false) print a proof showing the original term is equal to the resultant one."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); + p.insert("print_proofs", CPK_BOOL, "(default: false) print a proof showing the original term is equal to the resultant one."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } virtual ~simplify_cmd() { @@ -67,12 +67,12 @@ public: throw cmd_exception("invalid simplify command, argument expected"); expr_ref r(ctx.m()); proof_ref pr(ctx.m()); - if (m_params.get_bool(":som", false)) - m_params.set_bool(":flat", true); + if (m_params.get_bool("som", false)) + m_params.set_bool("flat", true); th_rewriter s(ctx.m(), m_params); unsigned cache_sz; unsigned num_steps = 0; - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); bool failed = false; cancel_eh eh(s); { @@ -94,17 +94,17 @@ public: num_steps = s.get_num_steps(); s.cleanup(); } - if (m_params.get_bool(":print", true)) { + if (m_params.get_bool("print", true)) { ctx.display(ctx.regular_stream(), r); ctx.regular_stream() << std::endl; } - if (!failed && m_params.get_bool(":print-proofs", false)) { + if (!failed && m_params.get_bool("print_proofs", false)) { ast_smt_pp pp(ctx.m()); pp.set_logic(ctx.get_logic().str().c_str()); pp.display_expr_smt2(ctx.regular_stream(), pr.get()); ctx.regular_stream() << std::endl; } - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { shared_occs s1(ctx.m()); if (!failed) s1(r); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index 32adb5f47..b911e3634 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -153,7 +153,7 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { insert_timeout(p); insert_max_memory(p); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } void display_statistics(cmd_context & ctx, tactic * t) { @@ -180,9 +180,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { exec_given_tactic_cmd::init_pdescrs(ctx, p); - p.insert(":print-unsat-core", CPK_BOOL, "(default: false) print unsatisfiable core."); - p.insert(":print-proof", CPK_BOOL, "(default: false) print proof."); - p.insert(":print-model", CPK_BOOL, "(default: false) print model."); + p.insert("print_unsat_core", CPK_BOOL, "(default: false) print unsatisfiable core."); + p.insert("print_proof", CPK_BOOL, "(default: false) print proof."); + p.insert("print_model", CPK_BOOL, "(default: false) print model."); } virtual void execute(cmd_context & ctx) { @@ -192,7 +192,7 @@ public: tref->set_front_end_params(ctx.params()); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", UINT_MAX); goal_ref g = alloc(goal, m, ctx.produce_proofs(), ctx.produce_models(), ctx.produce_unsat_cores()); assert_exprs_from(ctx, *g); TRACE("check_sat_using", g->display(tout);); @@ -241,7 +241,7 @@ public: ptr_vector core_elems; m.linearize(core, core_elems); result->m_core.append(core_elems.size(), core_elems.c_ptr()); - if (p.get_bool(":print-unsat-core", false)) { + if (p.get_bool("print_unsat_core", false)) { ctx.regular_stream() << "(unsat-core"; ptr_vector::const_iterator it = core_elems.begin(); ptr_vector::const_iterator end = core_elems.end(); @@ -255,7 +255,7 @@ public: if (ctx.produce_models() && md) { result->m_model = md; - if (p.get_bool(":print-model", false)) { + if (p.get_bool("print_model", false)) { ctx.regular_stream() << "(model " << std::endl; model_smt2_pp(ctx.regular_stream(), ctx, *md, 2); ctx.regular_stream() << ")" << std::endl; @@ -266,12 +266,12 @@ public: if (ctx.produce_proofs() && pr) { result->m_proof = pr; - if (p.get_bool(":print-proof", false)) { + if (p.get_bool("print_proof", false)) { ctx.regular_stream() << mk_ismt2_pp(pr, m) << "\n"; } } - if (p.get_bool(":print-statistics", false)) + if (p.get_bool("print_statistics", false)) display_statistics(ctx, tref.get()); } }; @@ -285,14 +285,14 @@ public: virtual char const * get_main_descr() const { return "apply the given tactic to the current context, and print the resultant set of goals."; } virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { - p.insert(":print", CPK_BOOL, "(default: true) print resultant goals."); + p.insert("print", CPK_BOOL, "(default: true) print resultant goals."); #ifndef _EXTERNAL_RELEASE - p.insert(":print-proof", CPK_BOOL, "(default: false) print proof associated with each assertion."); + p.insert("print_proof", CPK_BOOL, "(default: false) print proof associated with each assertion."); #endif - p.insert(":print-model-converter", CPK_BOOL, "(default: false) print model converter."); - p.insert(":print-benchmark", CPK_BOOL, "(default: false) display resultant goals as a SMT2 benchmark."); + p.insert("print_model_converter", CPK_BOOL, "(default: false) print model converter."); + p.insert("print_benchmark", CPK_BOOL, "(default: false) display resultant goals as a SMT2 benchmark."); #ifndef _EXTERNAL_RELEASE - p.insert(":print-dependencies", CPK_BOOL, "(default: false) print dependencies when displaying the resultant set of goals."); + p.insert("print_dependencies", CPK_BOOL, "(default: false) print dependencies when displaying the resultant set of goals."); #endif exec_given_tactic_cmd::init_pdescrs(ctx, p); } @@ -307,7 +307,7 @@ public: goal_ref g = alloc(goal, m, ctx.produce_proofs(), ctx.produce_models(), ctx.produce_unsat_cores()); assert_exprs_from(ctx, *g); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", UINT_MAX); goal_ref_buffer result_goals; model_converter_ref mc; @@ -330,8 +330,8 @@ public: } } - if (!failed && p.get_bool(":print", true)) { - bool print_dependencies = p.get_bool(":print-dependencies", false); + if (!failed && p.get_bool("print", true)) { + bool print_dependencies = p.get_bool("print_dependencies", false); ctx.regular_stream() << "(goals\n"; unsigned sz = result_goals.size(); for (unsigned i = 0; i < sz; i++) { @@ -344,12 +344,12 @@ public: } #ifndef _EXTERNAL_RELEASE - if (!failed && ctx.produce_proofs() && p.get_bool(":print-proof", false)) { + if (!failed && ctx.produce_proofs() && p.get_bool("print_proof", false)) { // TODO } #endif - if (!failed && p.get_bool(":print-benchmark", false)) { + if (!failed && p.get_bool("print_benchmark", false)) { unsigned num_goals = result_goals.size(); SASSERT(num_goals > 0); if (num_goals == 1) { @@ -381,10 +381,10 @@ public: } } - if (!failed && mc && p.get_bool(":print-model-converter", false)) + if (!failed && mc && p.get_bool("print_model_converter", false)) mc->display(ctx.regular_stream()); - if (p.get_bool(":print-statistics", false)) + if (p.get_bool("print_statistics", false)) display_statistics(ctx, tref.get()); } } diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp index 0c2f5c710..21808bc1e 100644 --- a/src/front_end_params/arith_simplifier_params.cpp +++ b/src/front_end_params/arith_simplifier_params.cpp @@ -20,7 +20,7 @@ Revision History: #include"arith_simplifier_params.h" void arith_simplifier_params::register_params(ini_params & p) { - p.register_bool_param("ARITH_EXPAND_EQS", m_arith_expand_eqs); - p.register_bool_param("ARITH_PROCESS_ALL_EQS", m_arith_process_all_eqs); + p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); + p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); } diff --git a/src/front_end_params/bit_blaster_params.h b/src/front_end_params/bit_blaster_params.h index 8196774ca..ab183d7fc 100644 --- a/src/front_end_params/bit_blaster_params.h +++ b/src/front_end_params/bit_blaster_params.h @@ -29,8 +29,8 @@ struct bit_blaster_params { m_bb_quantifiers(false) { } void register_params(ini_params & p) { - p.register_bool_param("BB_EXT_GATES", m_bb_ext_gates, "use extended gates during bit-blasting"); - p.register_bool_param("BB_QUANTIFIERS", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); + p.register_bool_param("bb_ext_gates", m_bb_ext_gates, "use extended gates during bit-blasting"); + p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); } }; diff --git a/src/front_end_params/bv_simplifier_params.h b/src/front_end_params/bv_simplifier_params.h index a6ff749c4..50dedfd22 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/front_end_params/bv_simplifier_params.h @@ -30,8 +30,8 @@ struct bv_simplifier_params { m_bv2int_distribute(true) { } void register_params(ini_params & p) { - p.register_bool_param("HI_DIV0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); - p.register_bool_param("BV2INT_DISTRIBUTE", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); + p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); + p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); } }; diff --git a/src/front_end_params/cnf_params.cpp b/src/front_end_params/cnf_params.cpp index 57d02e8db..fffd698a6 100644 --- a/src/front_end_params/cnf_params.cpp +++ b/src/front_end_params/cnf_params.cpp @@ -20,7 +20,7 @@ Revision History: #include"cnf_params.h" void cnf_params::register_params(ini_params & p) { - p.register_unsigned_param("CNF_FACTOR", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); - p.register_int_param("CNF_MODE", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); + p.register_unsigned_param("cnf_factor", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); + p.register_int_param("cnf_mode", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); } diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/front_end_params/dyn_ack_params.cpp index b4d0546a9..90a0bb17b 100644 --- a/src/front_end_params/dyn_ack_params.cpp +++ b/src/front_end_params/dyn_ack_params.cpp @@ -19,13 +19,13 @@ Revision History: #include"dyn_ack_params.h" void dyn_ack_params::register_params(ini_params & p) { - p.register_int_param("DACK", 0, 2, reinterpret_cast(m_dack), + p.register_int_param("dack", 0, 2, reinterpret_cast(m_dack), "0 - disable dynamic ackermannization, 1 - expand Leibniz's axiom if a congruence is the root of a conflict, 2 - expand Leibniz's axiom if a congruence is used during conflict resolution."); - p.register_bool_param("DACK_EQ", m_dack_eq, "enable dynamic ackermannization for transtivity of equalities"); - p.register_unsigned_param("DACK_THRESHOLD", m_dack_threshold, "number of times the congruence rule must be used before Leibniz's axiom is expanded"); - p.register_double_param("DACK_FACTOR", m_dack_factor, "number of instance per conflict"); - p.register_unsigned_param("DACK_GC", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); - p.register_double_param("DACK_GC_INV_DECAY", m_dack_gc_inv_decay); + p.register_bool_param("dack_eq", m_dack_eq, "enable dynamic ackermannization for transtivity of equalities"); + p.register_unsigned_param("dack_threshold", m_dack_threshold, "number of times the congruence rule must be used before Leibniz's axiom is expanded"); + p.register_double_param("dack_factor", m_dack_factor, "number of instance per conflict"); + p.register_unsigned_param("dack_gc", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); + p.register_double_param("dack_gc_inv_decay", m_dack_gc_inv_decay); } diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 7aea7e7ee..9d05a3fc3 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -25,62 +25,62 @@ void front_end_params::register_params(ini_params & p) { parser_params::register_params(p); arith_simplifier_params::register_params(p); model_params::register_params(p); - p.register_bool_param("AT_LABELS_CEX", m_at_labels_cex, + p.register_bool_param("at_labels_cex", m_at_labels_cex, "only use labels that contain '@' when building multiple counterexamples"); - p.register_bool_param("CHECK_AT_LABELS", m_check_at_labels, + p.register_bool_param("check_at_labels", m_check_at_labels, "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("DEFAULT_QID", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); + p.register_bool_param("default_qid", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); - p.register_bool_param("TYPE_CHECK", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("WELL_SORTED_CHECK", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("INTERACTIVE", m_interactive, "enable interactive mode using Simplify input format"); - p.register_unsigned_param("SOFT_TIMEOUT", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); - p.register_double_param("INSTRUCTION_MAX", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - p.register_bool_param("AUTO_CONFIG", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); - p.register_int_param("PROOF_MODE", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); - p.register_bool_param("TRACE", m_trace, "enable tracing for the Axiom Profiler tool"); - p.register_string_param("TRACE_FILE_NAME", m_trace_file_name, "tracing file name"); - p.register_bool_param("ASYNC_COMMANDS", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); - p.register_bool_param("DISPLAY_CONFIG", m_display_config, "display configuration used by Z3"); + p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); + p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); + p.register_bool_param("interactive", m_interactive, "enable interactive mode using Simplify input format"); + p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); + p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); + p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); + p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); + p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); + p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); + p.register_bool_param("async_commands", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); + p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. - p.register_unsigned_param("MEMORY_HIGH_WATERMARK", m_memory_high_watermark, + p.register_unsigned_param("memory_high_watermark", m_memory_high_watermark, "set high watermark for memory consumption (in megabytes)"); - p.register_unsigned_param("MEMORY_MAX_SIZE", m_memory_max_size, + p.register_unsigned_param("memory_max_size", m_memory_max_size, "set hard upper limit for memory consumption (in megabytes)"); #endif #ifndef _EXTERNAL_RELEASE // external users should not have access to it. - p.register_bool_param("PREPROCESS", m_preprocess); + p.register_bool_param("preprocess", m_preprocess); #endif - p.register_bool_param("USER_THEORY_PREPROCESS_AXIOMS", + p.register_bool_param("user_theory_preprocess_axioms", m_user_theory_preprocess_axioms, "Apply full pre-processing to user theory axioms", true); - p.register_bool_param("USER_THEORY_PERSIST_AXIOMS", + p.register_bool_param("user_theory_persist_axioms", m_user_theory_persist_axioms, "Persist user axioms to the base level", true); - p.register_bool_param("SMTLIB2_COMPLIANT", m_smtlib2_compliant); + p.register_bool_param("smtlib2_compliant", m_smtlib2_compliant); - p.register_bool_param("IGNORE_BAD_PATTERNS", m_ignore_bad_patterns); + p.register_bool_param("ignore_bad_patterns", m_ignore_bad_patterns); PRIVATE_PARAMS({ - p.register_bool_param("IGNORE_CHECKSAT", m_ignore_checksat); - p.register_bool_param("DEBUG_REF_COUNT", m_debug_ref_count); - p.register_bool_param("IGNORE_USER_PATTERNS", m_ignore_user_patterns); - p.register_bool_param("INCREMENTAL_CORE_ASSERT", m_incremental_core_assert); - DEBUG_CODE(p.register_int_param("COPY_PARAMS", m_copy_params);); + p.register_bool_param("ignore_checksat", m_ignore_checksat); + p.register_bool_param("debug_ref_count", m_debug_ref_count); + p.register_bool_param("ignore_user_patterns", m_ignore_user_patterns); + p.register_bool_param("incremental_core_assert", m_incremental_core_assert); + DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); // temporary hack until strategic_solver is ported to new tactic framework PRIVATE_PARAMS({ - p.register_bool_param("NLSAT", m_nlsat); + p.register_bool_param("nlsat", m_nlsat); }); } diff --git a/src/front_end_params/model_params.cpp b/src/front_end_params/model_params.cpp index df6420b7a..a859684d8 100644 --- a/src/front_end_params/model_params.cpp +++ b/src/front_end_params/model_params.cpp @@ -20,14 +20,14 @@ Revision History: #include"model_params.h" void model_params::register_params(ini_params & p) { - p.register_bool_param("MODEL_PARTIAL", m_model_partial, "enable/disable partial function interpretations", true); - p.register_bool_param("MODEL_V1", m_model_v1_pp, + p.register_bool_param("model_partial", m_model_partial, "enable/disable partial function interpretations", true); + p.register_bool_param("model_v1", m_model_v1_pp, "use Z3 version 1.x pretty printer", true); - p.register_bool_param("MODEL_V2", m_model_v2_pp, + p.register_bool_param("model_v2", m_model_v2_pp, "use Z3 version 2.x (x <= 16) pretty printer", true); - p.register_bool_param("MODEL_COMPACT", m_model_compact, + p.register_bool_param("model_compact", m_model_compact, "try to compact function graph (i.e., function interpretations that are lookup tables", true); - p.register_bool_param("MODEL_COMPLETION", m_model_completion, + p.register_bool_param("model_completion", m_model_completion, "assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model", true); } diff --git a/src/front_end_params/nnf_params.cpp b/src/front_end_params/nnf_params.cpp index 044ca155e..351997f98 100644 --- a/src/front_end_params/nnf_params.cpp +++ b/src/front_end_params/nnf_params.cpp @@ -19,8 +19,8 @@ Revision History: #include"nnf_params.h" void nnf_params::register_params(ini_params & p) { - p.register_unsigned_param("NNF_FACTOR", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); - p.register_int_param("NNF_MODE", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); - p.register_bool_param("NNF_IGNORE_LABELS", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - p.register_bool_param("NNF_SK_HACK", m_nnf_sk_hack, "hack for VCC"); + p.register_unsigned_param("nnf_factor", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); + p.register_int_param("nnf_mode", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); + p.register_bool_param("nnf_ignore_labels", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); + p.register_bool_param("nnf_sk_hack", m_nnf_sk_hack, "hack for VCC"); } diff --git a/src/front_end_params/params2front_end_params.cpp b/src/front_end_params/params2front_end_params.cpp index a2bae371c..4c5866786 100644 --- a/src/front_end_params/params2front_end_params.cpp +++ b/src/front_end_params/params2front_end_params.cpp @@ -27,28 +27,28 @@ Revision History: the new strategy framework. */ void params2front_end_params(params_ref const & s, front_end_params & t) { - t.m_relevancy_lvl = s.get_uint(":relevancy", t.m_relevancy_lvl); + t.m_relevancy_lvl = s.get_uint("relevancy", t.m_relevancy_lvl); TRACE("qi_cost", s.display(tout); tout << "\n";); - t.m_qi_cost = s.get_str(":qi-cost", t.m_qi_cost.c_str()); - t.m_mbqi = s.get_bool(":mbqi", t.m_mbqi); - t.m_mbqi_max_iterations = s.get_uint(":mbqi-max-iterations", t.m_mbqi_max_iterations); - t.m_random_seed = s.get_uint(":random-seed", t.m_random_seed); - t.m_model = s.get_bool(":produce-models", t.m_model); - if (s.get_bool(":produce-proofs", false)) + t.m_qi_cost = s.get_str("qi_cost", t.m_qi_cost.c_str()); + t.m_mbqi = s.get_bool("mbqi", t.m_mbqi); + t.m_mbqi_max_iterations = s.get_uint("mbqi_max_iterations", t.m_mbqi_max_iterations); + t.m_random_seed = s.get_uint("random_seed", t.m_random_seed); + t.m_model = s.get_bool("produce_models", t.m_model); + if (s.get_bool("produce_proofs", false)) t.m_proof_mode = PGM_FINE; - t.m_well_sorted_check = s.get_bool(":check-sorts", t.m_well_sorted_check); - t.m_qi_eager_threshold = s.get_double(":qi-eager-threshold", t.m_qi_eager_threshold); - t.m_qi_lazy_threshold = s.get_double(":qi-lazy-threshold", t.m_qi_lazy_threshold); - t.m_preprocess = s.get_bool(":preprocess", t.m_preprocess); - t.m_hi_div0 = s.get_bool(":hi-div0", t.m_hi_div0); - t.m_auto_config = s.get_bool(":auto-config", t.m_auto_config); - t.m_array_simplify = s.get_bool(":array-old-simplifier", t.m_array_simplify); - t.m_arith_branch_cut_ratio = s.get_uint(":arith-branch-cut-ratio", t.m_arith_branch_cut_ratio); - t.m_arith_expand_eqs = s.get_bool(":arith-expand-eqs", t.m_arith_expand_eqs); + t.m_well_sorted_check = s.get_bool("check_sorts", t.m_well_sorted_check); + t.m_qi_eager_threshold = s.get_double("qi_eager_threshold", t.m_qi_eager_threshold); + t.m_qi_lazy_threshold = s.get_double("qi_lazy_threshold", t.m_qi_lazy_threshold); + t.m_preprocess = s.get_bool("preprocess", t.m_preprocess); + t.m_hi_div0 = s.get_bool("hi_div0", t.m_hi_div0); + t.m_auto_config = s.get_bool("auto_config", t.m_auto_config); + t.m_array_simplify = s.get_bool("array_old_simplifier", t.m_array_simplify); + t.m_arith_branch_cut_ratio = s.get_uint("arith_branch_cut_ratio", t.m_arith_branch_cut_ratio); + t.m_arith_expand_eqs = s.get_bool("arith_expand_eqs", t.m_arith_expand_eqs); - if (s.get_bool(":arith-greatest-error-pivot", false)) + if (s.get_bool("arith_greatest_error_pivot", false)) t.m_arith_pivot_strategy = ARITH_PIVOT_GREATEST_ERROR; - else if (s.get_bool(":arith-least-error-pivot", false)) + else if (s.get_bool("arith_least_error_pivot", false)) t.m_arith_pivot_strategy = ARITH_PIVOT_LEAST_ERROR; } @@ -59,22 +59,22 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { */ void front_end_params2params(front_end_params const & s, params_ref & t) { if (s.m_model) - t.set_bool(":produce-models", true); + t.set_bool("produce_models", true); if (!s.m_hi_div0) - t.set_bool(":hi-div0", false); + t.set_bool("hi_div0", false); } /** \brief Bridge for using params_ref with smt::context. */ void solver_front_end_params_descrs(param_descrs & r) { - r.insert(":hi-div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); - r.insert(":relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); - r.insert(":mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); - r.insert(":mbqi-max-iterations", CPK_UINT, "maximum number of rounds of MBQI"); - r.insert(":random-seed", CPK_UINT, "random seed for smt solver"); - r.insert(":qi-eager-threshold", CPK_DOUBLE, "threshold for eager quantifier instantiation"); - r.insert(":qi-lazy-threshold", CPK_DOUBLE, "threshold for lazy quantifier instantiation"); - r.insert(":auto_config", CPK_BOOL, "use heuristics to automatically configure smt solver"); - r.insert(":arith-branch-cut-ratio", CPK_UINT, "branch&bound / gomory cut ratio"); + r.insert("hi_div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); + r.insert("relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); + r.insert("mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); + r.insert("mbqi_max_iterations", CPK_UINT, "maximum number of rounds of MBQI"); + r.insert("random_seed", CPK_UINT, "random seed for smt solver"); + r.insert("qi_eager_threshold", CPK_DOUBLE, "threshold for eager quantifier instantiation"); + r.insert("qi_lazy_threshold", CPK_DOUBLE, "threshold for lazy quantifier instantiation"); + r.insert("auto_config", CPK_BOOL, "use heuristics to automatically configure smt solver"); + r.insert("arith_branch_cut_ratio", CPK_UINT, "branch&bound / gomory cut ratio"); } diff --git a/src/front_end_params/parser_params.cpp b/src/front_end_params/parser_params.cpp index 000885fa5..3edd03fb0 100644 --- a/src/front_end_params/parser_params.cpp +++ b/src/front_end_params/parser_params.cpp @@ -6,8 +6,8 @@ parser_params::parser_params() : } void parser_params::register_params(ini_params & p) { - p.register_bool_param("DUMP_GOAL_AS_SMT", m_dump_goal_as_smt, "write goal back to output in SMT format"); - p.register_bool_param("DISPLAY_ERROR_FOR_VISUAL_STUDIO", m_display_error_for_vs, "display error messages in Visual Studio format"); + p.register_bool_param("dump_goal_as_smt", m_dump_goal_as_smt, "write goal back to output in SMT format"); + p.register_bool_param("display_error_for_visual_studio", m_display_error_for_vs, "display error messages in Visual Studio format"); } diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp index 176fdd8c2..4b0d4c964 100644 --- a/src/front_end_params/pattern_inference_params.cpp +++ b/src/front_end_params/pattern_inference_params.cpp @@ -19,19 +19,19 @@ Revision History: #include"pattern_inference_params.h" void pattern_inference_params::register_params(ini_params & p) { - p.register_unsigned_param("PI_MAX_MULTI_PATTERNS", m_pi_max_multi_patterns, + p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); - p.register_bool_param("PI_BLOCK_LOOP_PATTERNS", m_pi_block_loop_patterns, + p.register_bool_param("pi_block_loop_patterns", m_pi_block_loop_patterns, "block looping patterns during pattern inference"); - p.register_int_param("PI_ARITH", 0, 2, reinterpret_cast(m_pi_arith), + p.register_int_param("pi_arith", 0, 2, reinterpret_cast(m_pi_arith), "0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms."); - p.register_bool_param("PI_USE_DATABASE", m_pi_use_database); - p.register_unsigned_param("PI_ARITH_WEIGHT", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); - p.register_unsigned_param("PI_NON_NESTED_ARITH_WEIGHT", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); - p.register_bool_param("PI_PULL_QUANTIFIERS", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); - p.register_int_param("PI_NOPAT_WEIGHT", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); - p.register_bool_param("PI_AVOID_SKOLEMS", m_pi_avoid_skolems); - p.register_bool_param("PI_WARNINGS", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); + p.register_bool_param("pi_use_database", m_pi_use_database); + p.register_unsigned_param("pi_arith_weight", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); + p.register_unsigned_param("pi_non_nested_arith_weight", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); + p.register_bool_param("pi_pull_quantifiers", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); + p.register_int_param("pi_nopat_weight", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); + p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); + p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); } diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 4b32feb60..89bd01b48 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -84,25 +84,25 @@ public: pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); - p.register_int_param("LIFT_ITE", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_int_param("NG_LIFT_ITE", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_bool_param("ELIM_TERM_ITE", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); - p.register_bool_param("ELIM_AND", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); - p.register_bool_param("MACRO_FINDER", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); - p.register_bool_param("PROPAGATE_VALUES", m_propagate_values, "propagate values during preprocessing step"); - p.register_bool_param("PROPAGATE_BOOLEANS", m_propagate_booleans, "propagate boolean values during preprocessing step"); - p.register_bool_param("PULL_CHEAP_ITE_TREES", m_pull_cheap_ite_trees); - p.register_bool_param("PULL_NESTED_QUANTIFIERS", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); - p.register_bool_param("REFINE_INJ_AXIOM", m_refine_inj_axiom); - p.register_bool_param("ELIM_BOUNDS", m_eliminate_bounds, "cheap Fourier-Motzkin"); + p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); + p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); + p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); + p.register_bool_param("elim_and", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); + p.register_bool_param("macro_finder", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); + p.register_bool_param("propagate_values", m_propagate_values, "propagate values during preprocessing step"); + p.register_bool_param("propagate_booleans", m_propagate_booleans, "propagate boolean values during preprocessing step"); + p.register_bool_param("pull_cheap_ite_trees", m_pull_cheap_ite_trees); + p.register_bool_param("pull_nested_quantifiers", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); + p.register_bool_param("refine_inj_axiom", m_refine_inj_axiom); + p.register_bool_param("elim_bounds", m_eliminate_bounds, "cheap Fourier-Motzkin"); - p.register_bool_param("BIT2INT", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); - p.register_bool_param("DISTRIBUTE_FORALL", m_distribute_forall); - p.register_bool_param("REDUCE_ARGS", m_reduce_args); - p.register_bool_param("QUASI_MACROS", m_quasi_macros); - p.register_bool_param("RESTRICTED_QUASI_MACROS", m_restricted_quasi_macros); - p.register_bool_param("BV_MAX_SHARING", m_max_bv_sharing); - p.register_bool_param("PRE_SIMPLIFIER", m_pre_simplifier); + p.register_bool_param("bit2int", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); + p.register_bool_param("distribute_forall", m_distribute_forall); + p.register_bool_param("reduce_args", m_reduce_args); + p.register_bool_param("quasi_macros", m_quasi_macros); + p.register_bool_param("restricted_quasi_macros", m_restricted_quasi_macros); + p.register_bool_param("bv_max_sharing", m_max_bv_sharing); + p.register_bool_param("pre_simplifier", m_pre_simplifier); } }; diff --git a/src/front_end_params/qi_params.h b/src/front_end_params/qi_params.h index bd41de12c..aee2c4d3d 100644 --- a/src/front_end_params/qi_params.h +++ b/src/front_end_params/qi_params.h @@ -107,31 +107,31 @@ struct qi_params { } void register_params(ini_params & p) { - p.register_unsigned_param("QI_MAX_EAGER_MULTI_PATTERNS", m_qi_max_eager_multipatterns, + p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); - p.register_unsigned_param("QI_MAX_LAZY_MULTI_PATTERN_MATCHING", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); - p.register_string_param("QI_COST", m_qi_cost, "The cost function for quantifier instantiation"); - p.register_string_param("QI_NEW_GEN", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); - p.register_double_param("QI_EAGER_THRESHOLD", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); - p.register_double_param("QI_LAZY_THRESHOLD", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); - p.register_bool_param("QI_PROFILE", m_qi_profile); - p.register_unsigned_param("QI_PROFILE_FREQ", m_qi_profile_freq); - p.register_int_param("QI_QUICK_CHECKER", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); - p.register_bool_param("QI_LAZY_QUICK_CHECKER", m_qi_lazy_quick_checker); - p.register_bool_param("QI_PROMOTE_UNSAT", m_qi_promote_unsat); - p.register_unsigned_param("QI_MAX_INSTANCES", m_qi_max_instances); - p.register_bool_param("QI_LAZY_INSTANTIATION", m_qi_lazy_instantiation); - p.register_bool_param("QI_CONSERVATIVE_FINAL_CHECK", m_qi_conservative_final_check); + p.register_unsigned_param("qi_max_lazy_multi_pattern_matching", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); + p.register_string_param("qi_cost", m_qi_cost, "The cost function for quantifier instantiation"); + p.register_string_param("qi_new_gen", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); + p.register_double_param("qi_eager_threshold", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); + p.register_double_param("qi_lazy_threshold", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); + p.register_bool_param("qi_profile", m_qi_profile); + p.register_unsigned_param("qi_profile_freq", m_qi_profile_freq); + p.register_int_param("qi_quick_checker", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); + p.register_bool_param("qi_lazy_quick_checker", m_qi_lazy_quick_checker); + p.register_bool_param("qi_promote_unsat", m_qi_promote_unsat); + p.register_unsigned_param("qi_max_instances", m_qi_max_instances); + p.register_bool_param("qi_lazy_instantiation", m_qi_lazy_instantiation); + p.register_bool_param("qi_conservative_final_check", m_qi_conservative_final_check); - p.register_bool_param("MBQI", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); - p.register_unsigned_param("MBQI_MAX_CEXS", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); - p.register_unsigned_param("MBQI_MAX_CEXS_INCR", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); - p.register_unsigned_param("MBQI_MAX_ITERATIONS", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); - p.register_bool_param("MBQI_TRACE", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); - p.register_unsigned_param("MBQI_FORCE_TEMPLATE", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); + p.register_bool_param("mbqi", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); + p.register_unsigned_param("mbqi_max_cexs", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); + p.register_unsigned_param("mbqi_max_cexs_incr", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); + p.register_unsigned_param("mbqi_max_iterations", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); + p.register_bool_param("mbqi_trace", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); + p.register_unsigned_param("mbqi_force_template", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); - p.register_bool_param("INST_GEN", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); + p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); } }; diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 0c4a0c844..14db6020a 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -27,82 +27,82 @@ void smt_params::register_params(ini_params & p) { theory_bv_params::register_params(p); theory_datatype_params::register_params(p); - p.register_bool_param("CHECK_PROOF", m_check_proof); - p.register_bool_param("DISPLAY_PROOF", m_display_proof); - p.register_bool_param("DISPLAY_DOT_PROOF", m_display_dot_proof); - p.register_bool_param("DISPLAY_UNSAT_CORE", m_display_unsat_core); - p.register_bool_param("INTERNALIZER_NNF", m_internalizer_nnf); - p.register_bool_param("EQ_PROPAGATION", m_eq_propagation); - p.register_bool_param("BIN_CLAUSES", m_binary_clause_opt); - p.register_unsigned_param("RELEVANCY", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); - p.register_bool_param("RELEVANCY_LEMMA", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); - p.register_unsigned_param("RANDOM_SEED", m_random_seed, "random seed for Z3"); - p.register_percentage_param("RANDOM_CASE_SPLIT_FREQ", m_random_var_freq, "frequency of random case splits"); - p.register_int_param("PHASE_SELECTION", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); - p.register_bool_param("MINIMIZE_LEMMAS", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); - p.register_unsigned_param("MAX_CONFLICTS", m_max_conflicts, "maximum number of conflicts"); + p.register_bool_param("check_proof", m_check_proof); + p.register_bool_param("display_proof", m_display_proof); + p.register_bool_param("display_dot_proof", m_display_dot_proof); + p.register_bool_param("display_unsat_core", m_display_unsat_core); + p.register_bool_param("internalizer_nnf", m_internalizer_nnf); + p.register_bool_param("eq_propagation", m_eq_propagation); + p.register_bool_param("bin_clauses", m_binary_clause_opt); + p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); + p.register_bool_param("relevancy_lemma", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); + p.register_unsigned_param("random_seed", m_random_seed, "random seed for Z3"); + p.register_percentage_param("random_case_split_freq", m_random_var_freq, "frequency of random case splits"); + p.register_int_param("phase_selection", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); + p.register_bool_param("minimize_lemmas", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); + p.register_unsigned_param("max_conflicts", m_max_conflicts, "maximum number of conflicts"); - p.register_unsigned_param("RECENT_LEMMA_THRESHOLD", m_recent_lemmas_size); - p.register_unsigned_param("TICK", m_tick); + p.register_unsigned_param("recent_lemma_threshold", m_recent_lemmas_size); + p.register_unsigned_param("tick", m_tick); PRIVATE_PARAMS({ - p.register_bool_param("THEORY_RESOLVE", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); + p.register_bool_param("theory_resolve", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); }); - p.register_int_param("RESTART_STRATEGY", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); - p.register_unsigned_param("RESTART_INITIAL", m_restart_initial, + p.register_int_param("restart_strategy", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); + p.register_unsigned_param("restart_initial", m_restart_initial, "inital restart frequency in number of conflicts, it is also the unit for the luby sequence"); - p.register_double_param("RESTART_FACTOR", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); - p.register_bool_param("RESTART_ADAPTIVE", m_restart_adaptive, "disable restarts based on the search 'agility'"); - p.register_percentage_param("RESTART_AGILITY_THRESHOLD", m_restart_agility_threshold); + p.register_double_param("restart_factor", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); + p.register_bool_param("restart_adaptive", m_restart_adaptive, "disable restarts based on the search 'agility'"); + p.register_percentage_param("restart_agility_threshold", m_restart_agility_threshold); - p.register_int_param("LEMMA_GC_STRATEGY", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); - p.register_bool_param("LEMMA_GC_HALF", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); - p.register_unsigned_param("LEMMA_GC_INITIAL", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); - p.register_double_param("LEMMA_GC_FACTOR", m_lemma_gc_factor, "used by geometric strategy"); - p.register_unsigned_param("LEMMA_GC_NEW_OLD_RATIO", m_new_old_ratio); - p.register_unsigned_param("LEMMA_GC_NEW_CLAUSE_ACTIVITY", m_new_clause_activity); - p.register_unsigned_param("LEMMA_GC_OLD_CLAUSE_ACTIVITY", m_old_clause_activity); - p.register_unsigned_param("LEMMA_GC_NEW_CLAUSE_RELEVANCY", m_new_clause_relevancy); - p.register_unsigned_param("LEMMA_GC_OLD_CLAUSE_RELEVANCY", m_old_clause_activity); + p.register_int_param("lemma_gc_strategy", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); + p.register_bool_param("lemma_gc_half", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); + p.register_unsigned_param("lemma_gc_initial", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); + p.register_double_param("lemma_gc_factor", m_lemma_gc_factor, "used by geometric strategy"); + p.register_unsigned_param("lemma_gc_new_old_ratio", m_new_old_ratio); + p.register_unsigned_param("lemma_gc_new_clause_activity", m_new_clause_activity); + p.register_unsigned_param("lemma_gc_old_clause_activity", m_old_clause_activity); + p.register_unsigned_param("lemma_gc_new_clause_relevancy", m_new_clause_relevancy); + p.register_unsigned_param("lemma_gc_old_clause_relevancy", m_old_clause_activity); - p.register_bool_param("SIMPLIFY_CLAUSES", m_simplify_clauses); + p.register_bool_param("simplify_clauses", m_simplify_clauses); - p.register_int_param("RANDOM_INITIAL_ACTIVITY", 0, 2, reinterpret_cast(m_random_initial_activity)); + p.register_int_param("random_initial_activity", 0, 2, reinterpret_cast(m_random_initial_activity)); PRIVATE_PARAMS({ - p.register_double_param("INV_DECAY", m_inv_decay); - p.register_unsigned_param("PHASE_CACHING_ON_DURATION", m_phase_caching_on); - p.register_unsigned_param("PHASE_CACHING_OFF_DURATION", m_phase_caching_off); + p.register_double_param("inv_decay", m_inv_decay); + p.register_unsigned_param("phase_caching_on_duration", m_phase_caching_on); + p.register_unsigned_param("phase_caching_off_duration", m_phase_caching_off); }); - p.register_bool_param("SMTLIB_DUMP_LEMMAS", m_smtlib_dump_lemmas); - p.register_string_param("SMTLIB_LOGIC", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); - p.register_bool_param("DISPLAY_FEATURES", m_display_features); + p.register_bool_param("smtlib_dump_lemmas", m_smtlib_dump_lemmas); + p.register_string_param("smtlib_logic", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); + p.register_bool_param("display_features", m_display_features); - p.register_bool_param("NEW_CORE2TH_EQ", m_new_core2th_eq); - p.register_bool_param("EMATCHING", m_ematching, "E-Matching based quantifier instantiation"); + p.register_bool_param("new_core2th_eq", m_new_core2th_eq); + p.register_bool_param("ematching", m_ematching, "E-Matching based quantifier instantiation"); - p.register_bool_param("PROFILE_RES_SUB", m_profile_res_sub); + p.register_bool_param("profile_res_sub", m_profile_res_sub); #ifndef _EXTERNAL_RELEASE - p.register_bool_param("DISPLAY_BOOL_VAR2EXPR", m_display_bool_var2expr); - p.register_bool_param("DISPLAY_LL_BOOL_VAR2EXPR", m_display_ll_bool_var2expr); - p.register_bool_param("ABORT_AFTER_PREPROC", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); - p.register_bool_param("DISPLAY_INSTALLED_THEORIES", m_display_installed_theories, "display theories installed at smt::context", true); + p.register_bool_param("display_bool_var2expr", m_display_bool_var2expr); + p.register_bool_param("display_ll_bool_var2expr", m_display_ll_bool_var2expr); + p.register_bool_param("abort_after_preproc", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); + p.register_bool_param("display_installed_theories", m_display_installed_theories, "display theories installed at smt::context", true); #endif - p.register_int_param("CASE_SPLIT", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); - p.register_unsigned_param("REL_CASE_SPLIT_ORDER", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); - p.register_bool_param("LOOKAHEAD_DISEQ", m_lookahead_diseq); + p.register_int_param("case_split", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); + p.register_unsigned_param("rel_case_split_order", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); + p.register_bool_param("lookahead_diseq", m_lookahead_diseq); - p.register_bool_param("DELAY_UNITS", m_delay_units); - p.register_unsigned_param("DELAY_UNITS_THRESHOLD", m_delay_units_threshold); + p.register_bool_param("delay_units", m_delay_units); + p.register_unsigned_param("delay_units_threshold", m_delay_units_threshold); - p.register_bool_param("MODEL", m_model, "enable/disable model construction", true); - p.register_bool_param("MODEL_VALIDATE", m_model_validate, "validate the model", true); - p.register_bool_param("MODEL_ON_TIMEOUT", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); - p.register_bool_param("MODEL_ON_FINAL_CHECK", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); + p.register_bool_param("model", m_model, "enable/disable model construction", true); + p.register_bool_param("model_validate", m_model_validate, "validate the model", true); + p.register_bool_param("model_on_timeout", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); + p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); - p.register_unsigned_param("PROGRESS_SAMPLING_FREQ", m_progress_sampling_freq, "frequency for progress output in miliseconds"); + p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); } diff --git a/src/front_end_params/theory_arith_params.cpp b/src/front_end_params/theory_arith_params.cpp index 2d77b6e73..49a654dbf 100644 --- a/src/front_end_params/theory_arith_params.cpp +++ b/src/front_end_params/theory_arith_params.cpp @@ -21,56 +21,56 @@ Revision History: void theory_arith_params::register_params(ini_params & p) { #ifdef _EXTERNAL_RELEASE - p.register_int_param("ARITH_SOLVER", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); + p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); #else - p.register_int_param("ARITH_SOLVER", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); + p.register_int_param("arith_solver", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); #endif - p.register_bool_param("ARITH_FORCE_SIMPLEX", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); - p.register_unsigned_param("ARITH_BLANDS_RULE_THRESHOLD", m_arith_blands_rule_threshold); - p.register_bool_param("ARITH_PROPAGATE_EQS", m_arith_propagate_eqs); - p.register_int_param("ARITH_PROPAGATION_MODE", 0, 2, reinterpret_cast(m_arith_bound_prop)); - p.register_bool_param("ARITH_STRONGER_LEMMAS", m_arith_stronger_lemmas); - p.register_bool_param("ARITH_SKIP_BIG_COEFFS", m_arith_skip_rows_with_big_coeffs); - p.register_unsigned_param("ARITH_MAX_LEMMA_SIZE", m_arith_max_lemma_size); - p.register_unsigned_param("ARITH_SMALL_LEMMA_SIZE", m_arith_small_lemma_size); - p.register_bool_param("ARITH_REFLECT", m_arith_reflect); - p.register_bool_param("ARITH_IGNORE_INT", m_arith_ignore_int); - p.register_unsigned_param("ARITH_LAZY_PIVOTING", m_arith_lazy_pivoting_lvl); - p.register_unsigned_param("ARITH_RANDOM_SEED", m_arith_random_seed); - p.register_bool_param("ARITH_RANDOM_INITIAL_VALUE", m_arith_random_initial_value); - p.register_int_param("ARITH_RANDOM_LOWER", m_arith_random_lower); - p.register_int_param("ARITH_RANDOM_UPPER", m_arith_random_upper); - p.register_bool_param("ARITH_ADAPTIVE", m_arith_adaptive); - p.register_double_param("ARITH_ADAPTIVE_ASSERTION_THRESHOLD", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); - p.register_double_param("ARITH_ADAPTIVE_PROPAGATION_THRESHOLD", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); - p.register_bool_param("ARITH_DUMP_LEMMAS", m_arith_dump_lemmas); - p.register_bool_param("ARITH_EAGER_EQ_AXIOMS", m_arith_eager_eq_axioms); - p.register_unsigned_param("ARITH_BRANCH_CUT_RATIO", m_arith_branch_cut_ratio); + p.register_bool_param("arith_force_simplex", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); + p.register_unsigned_param("arith_blands_rule_threshold", m_arith_blands_rule_threshold); + p.register_bool_param("arith_propagate_eqs", m_arith_propagate_eqs); + p.register_int_param("arith_propagation_mode", 0, 2, reinterpret_cast(m_arith_bound_prop)); + p.register_bool_param("arith_stronger_lemmas", m_arith_stronger_lemmas); + p.register_bool_param("arith_skip_big_coeffs", m_arith_skip_rows_with_big_coeffs); + p.register_unsigned_param("arith_max_lemma_size", m_arith_max_lemma_size); + p.register_unsigned_param("arith_small_lemma_size", m_arith_small_lemma_size); + p.register_bool_param("arith_reflect", m_arith_reflect); + p.register_bool_param("arith_ignore_int", m_arith_ignore_int); + p.register_unsigned_param("arith_lazy_pivoting", m_arith_lazy_pivoting_lvl); + p.register_unsigned_param("arith_random_seed", m_arith_random_seed); + p.register_bool_param("arith_random_initial_value", m_arith_random_initial_value); + p.register_int_param("arith_random_lower", m_arith_random_lower); + p.register_int_param("arith_random_upper", m_arith_random_upper); + p.register_bool_param("arith_adaptive", m_arith_adaptive); + p.register_double_param("arith_adaptive_assertion_threshold", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); + p.register_double_param("arith_adaptive_propagation_threshold", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); + p.register_bool_param("arith_dump_lemmas", m_arith_dump_lemmas); + p.register_bool_param("arith_eager_eq_axioms", m_arith_eager_eq_axioms); + p.register_unsigned_param("arith_branch_cut_ratio", m_arith_branch_cut_ratio); - p.register_bool_param("ARITH_ADD_BINARY_BOUNDS", m_arith_add_binary_bounds); - p.register_unsigned_param("ARITH_PROP_STRATEGY", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); + p.register_bool_param("arith_add_binary_bounds", m_arith_add_binary_bounds); + p.register_unsigned_param("arith_prop_strategy", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); - p.register_bool_param("ARITH_EQ_BOUNDS", m_arith_eq_bounds); - p.register_bool_param("ARITH_LAZY_ADAPTER", m_arith_lazy_adapter); - p.register_bool_param("ARITH_GCD_TEST", m_arith_gcd_test); - p.register_bool_param("ARITH_EAGER_GCD", m_arith_eager_gcd); - p.register_bool_param("ARITH_ADAPTIVE_GCD", m_arith_adaptive_gcd); - p.register_unsigned_param("ARITH_PROPAGATION_THRESHOLD", m_arith_propagation_threshold); + p.register_bool_param("arith_eq_bounds", m_arith_eq_bounds); + p.register_bool_param("arith_lazy_adapter", m_arith_lazy_adapter); + p.register_bool_param("arith_gcd_test", m_arith_gcd_test); + p.register_bool_param("arith_eager_gcd", m_arith_eager_gcd); + p.register_bool_param("arith_adaptive_gcd", m_arith_adaptive_gcd); + p.register_unsigned_param("arith_propagation_threshold", m_arith_propagation_threshold); - p.register_bool_param("NL_ARITH", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); - p.register_bool_param("NL_ARITH_GB", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); - p.register_bool_param("NL_ARITH_GB_EQS", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); - p.register_bool_param("NL_ARITH_GB_PERTURBATE", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); - p.register_unsigned_param("NL_ARITH_GB_THRESHOLD", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); - p.register_bool_param("NL_ARITH_BRANCHING", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); - p.register_unsigned_param("NL_ARITH_ROUNDS", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); - p.register_unsigned_param("NL_ARITH_MAX_DEGREE", m_nl_arith_max_degree, "max degree for internalizing new monomials."); + p.register_bool_param("nl_arith", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); + p.register_bool_param("nl_arith_gb", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); + p.register_bool_param("nl_arith_gb_eqs", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); + p.register_bool_param("nl_arith_gb_perturbate", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); + p.register_unsigned_param("nl_arith_gb_threshold", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); + p.register_bool_param("nl_arith_branching", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); + p.register_unsigned_param("nl_arith_rounds", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); + p.register_unsigned_param("nl_arith_max_degree", m_nl_arith_max_degree, "max degree for internalizing new monomials."); PRIVATE_PARAMS({ - p.register_bool_param("ARITH_FIXNUM", m_arith_fixnum); - p.register_bool_param("ARITH_INT_ONLY", m_arith_int_only); - p.register_bool_param("ARITH_ENUM_CONST_MOD", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); - p.register_bool_param("ARITH_INT_EQ_BRANCHING", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); + p.register_bool_param("arith_fixnum", m_arith_fixnum); + p.register_bool_param("arith_int_only", m_arith_int_only); + p.register_bool_param("arith_enum_const_mod", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); + p.register_bool_param("arith_int_eq_branching", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); }); - p.register_bool_param("ARITH_EUCLIDEAN_SOLVER", m_arith_euclidean_solver, ""); + p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); } diff --git a/src/front_end_params/theory_array_params.h b/src/front_end_params/theory_array_params.h index 9e93fefbe..3d45ebcf5 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/front_end_params/theory_array_params.h @@ -56,17 +56,17 @@ struct theory_array_params { } void register_params(ini_params & p) { - p.register_int_param("ARRAY_SOLVER", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); - p.register_bool_param("ARRAY_WEAK", m_array_weak); - p.register_bool_param("ARRAY_EXTENSIONAL", m_array_extensional); - p.register_unsigned_param("ARRAY_LAZINESS", m_array_laziness); - p.register_bool_param("ARRAY_DELAY_EXP_AXIOM", m_array_delay_exp_axiom); - p.register_bool_param("ARRAY_CG", m_array_cg); - p.register_bool_param("ARRAY_ALWAYS_PROP_UPWARD", m_array_always_prop_upward, + p.register_int_param("array_solver", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); + p.register_bool_param("array_weak", m_array_weak); + p.register_bool_param("array_extensional", m_array_extensional); + p.register_unsigned_param("array_laziness", m_array_laziness); + p.register_bool_param("array_delay_exp_axiom", m_array_delay_exp_axiom); + p.register_bool_param("array_cg", m_array_cg); + p.register_bool_param("array_always_prop_upward", m_array_always_prop_upward, "Disable the built-in filter upwards propagation"); - p.register_bool_param("ARRAY_LAZY_IEQ", m_array_lazy_ieq); - p.register_unsigned_param("ARRAY_LAZY_IEQ_DELAY", m_array_lazy_ieq_delay); - p.register_bool_param("ARRAY_CANONIZE", m_array_canonize_simplify, + p.register_bool_param("array_lazy_ieq", m_array_lazy_ieq); + p.register_unsigned_param("array_lazy_ieq_delay", m_array_lazy_ieq_delay); + p.register_bool_param("array_canonize", m_array_canonize_simplify, "Normalize arrays into normal form during simplification"); } }; diff --git a/src/front_end_params/theory_bv_params.h b/src/front_end_params/theory_bv_params.h index 38e1e263f..6bf5ac868 100644 --- a/src/front_end_params/theory_bv_params.h +++ b/src/front_end_params/theory_bv_params.h @@ -41,12 +41,12 @@ struct theory_bv_params { m_bv_blast_max_size(INT_MAX), m_bv_enable_int2bv2int(false) {} void register_params(ini_params & p) { - p.register_int_param("BV_SOLVER", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); - p.register_unsigned_param("BV_BLAST_MAX_SIZE", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); - p.register_bool_param("BV_REFLECT", m_bv_reflect); - p.register_bool_param("BV_LAZY_LE", m_bv_lazy_le); - p.register_bool_param("BV_CC", m_bv_cc, "enable congruence closure for BV operators"); - p.register_bool_param("BV_ENABLE_INT2BV_PROPAGATION", m_bv_enable_int2bv2int, + p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); + p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); + p.register_bool_param("bv_reflect", m_bv_reflect); + p.register_bool_param("bv_lazy_le", m_bv_lazy_le); + p.register_bool_param("bv_cc", m_bv_cc, "enable congruence closure for BV operators"); + p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, "enable full (potentially expensive) propagation for int2bv and bv2int"); } }; diff --git a/src/front_end_params/theory_datatype_params.h b/src/front_end_params/theory_datatype_params.h index 000c4da07..33b2c1814 100644 --- a/src/front_end_params/theory_datatype_params.h +++ b/src/front_end_params/theory_datatype_params.h @@ -29,7 +29,7 @@ struct theory_datatype_params { } void register_params(ini_params & p) { - p.register_unsigned_param("DT_LAZY_SPLITS", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); + p.register_unsigned_param("dt_lazy_splits", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); } }; diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index f7de4054c..c35e0d368 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -57,12 +57,12 @@ namespace algebraic_numbers { typedef upolynomial::factors factors; void manager::get_param_descrs(param_descrs & r) { - r.insert(":algebraic-zero-accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); - r.insert(":algebraic-min-mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); - r.insert(":algebraic-factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); - r.insert(":algebraic-factor-max-prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert(":algebraic-factor-num-primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); - r.insert(":algebraic-factor-search-size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + r.insert("zero_accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); + r.insert("min_mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); + r.insert("factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); + r.insert("factor_max_prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); + r.insert("factor_num_primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); + r.insert("factor_search_size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); } struct manager::imp { @@ -157,12 +157,12 @@ namespace algebraic_numbers { } void updt_params(params_ref const & p) { - m_min_magnitude = -static_cast(p.get_uint(":algebraic-min-mag", 16)); - m_factor = p.get_bool(":algebraic-factor", true); // use polynomial factorization - m_factor_params.m_max_p = p.get_uint(":algebraic-factor-max-prime", 31); - m_factor_params.m_p_trials = p.get_uint(":algebraic-factor-num-primes", 1); - m_factor_params.m_max_search_size = p.get_uint(":algebraic-factor-max-search-size", 5000); - m_zero_accuracy = -static_cast(p.get_uint(":algebraic-zero-accuracy", 0)); + m_min_magnitude = -static_cast(p.get_uint("min_mag", 16)); + m_factor = p.get_bool("factor", true); // use polynomial factorization + m_factor_params.m_max_p = p.get_uint("factor_max_prime", 31); + m_factor_params.m_p_trials = p.get_uint("factor_num_primes", 1); + m_factor_params.m_max_search_size = p.get_uint("factor_max_search_size", 5000); + m_zero_accuracy = -static_cast(p.get_uint("zero_accuracy", 0)); } unsynch_mpq_manager & qm() { diff --git a/src/math/polynomial/algebraic_numbers.h b/src/math/polynomial/algebraic_numbers.h index 4735a875b..0db3ee68c 100644 --- a/src/math/polynomial/algebraic_numbers.h +++ b/src/math/polynomial/algebraic_numbers.h @@ -60,6 +60,9 @@ namespace algebraic_numbers { manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); ~manager(); + /* + REG_MODULE_PARAMS('algebraic', 'algebraic_numbers::manager::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); } diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index 1b5c7965f..4e14c5661 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -50,15 +50,15 @@ namespace polynomial { } void factor_params::updt_params(params_ref const & p) { - m_max_p = p.get_uint(":factor-max-prime", UINT_MAX); - m_p_trials = p.get_uint(":factor-num-primes", 1); - m_max_search_size = p.get_uint(":factor-max-search-size", UINT_MAX); + m_max_p = p.get_uint("max_prime", UINT_MAX); + m_p_trials = p.get_uint("num_primes", 1); + m_max_search_size = p.get_uint("max_search_size", UINT_MAX); } void factor_params::get_param_descrs(param_descrs & r) { - r.insert(":factor-max-search-size", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); - r.insert(":factor-max-prime", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert(":factor-num-primes", CPK_UINT, "(default: 1) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); + r.insert("max_search_size", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + r.insert("max_prime", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); + r.insert("num_primes", CPK_UINT, "(default: 1) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); } typedef ptr_vector monomial_vector; diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index f6370e5fa..7cefe6f56 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -90,6 +90,9 @@ namespace polynomial { factor_params(); factor_params(unsigned max_p, unsigned p_trials, unsigned max_search_size); void updt_params(params_ref const & p); + /* + REG_MODULE_PARAMS('factor', polynomial::factor_params::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); }; diff --git a/src/math/subpaving/subpaving_t_def.h b/src/math/subpaving/subpaving_t_def.h index 7c80de75c..c215ddf98 100644 --- a/src/math/subpaving/subpaving_t_def.h +++ b/src/math/subpaving/subpaving_t_def.h @@ -474,7 +474,7 @@ void context_t::del(interval & a) { template void context_t::updt_params(params_ref const & p) { - unsigned epsilon = p.get_uint(":epsilon", 20); + unsigned epsilon = p.get_uint("epsilon", 20); if (epsilon != 0) { nm().set(m_epsilon, static_cast(epsilon)); nm().inv(m_epsilon); @@ -485,18 +485,18 @@ void context_t::updt_params(params_ref const & p) { m_zero_epsilon = true; } - unsigned max_power = p.get_uint(":max-bound", 10); + unsigned max_power = p.get_uint("max_bound", 10); nm().set(m_max_bound, 10); nm().power(m_max_bound, max_power, m_max_bound); nm().set(m_minus_max_bound, m_max_bound); nm().neg(m_minus_max_bound); - m_max_depth = p.get_uint(":max-depth", 128); - m_max_nodes = p.get_uint(":max-nodes", 8192); + m_max_depth = p.get_uint("max_depth", 128); + m_max_nodes = p.get_uint("max_nodes", 8192); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - unsigned prec = p.get_uint(":nth-root-precision", 8192); + unsigned prec = p.get_uint("nth_root_precision", 8192); if (prec == 0) prec = 1; nm().set(m_nth_root_prec, static_cast(prec)); @@ -505,20 +505,20 @@ void context_t::updt_params(params_ref const & p) { template void context_t::collect_param_descrs(param_descrs & d) { - d.insert(":max-nodes", CPK_UINT, "(default: 8192) maximum number of nodes in the subpaving tree."); - d.insert(":max-depth", CPK_UINT, "(default: 128) maximum depth of the subpaving tree."); - d.insert(":epsilon", CPK_UINT, "(default: 20) value k s.t. a new lower (upper) bound for x is propagated only new-lower(x) > lower(k) + 1/k * max(min(upper(x) - lower(x), |lower|), 1) (new-upper(x) < upper(x) - 1/k * max(min(upper(x) - lower(x), |lower|), 1)). If k = 0, then this restriction is ignored."); - d.insert(":max-bound", CPK_UINT, "(default 10) value k s.t. a new upper (lower) bound for x is propagated only if upper(x) > -10^k or lower(x) = -oo (lower(x) < 10^k or upper(x) = oo)"); - d.insert(":nth-root-precision", CPK_UINT, "(default 8192) value k s.t. 1/k is the precision for computing the nth root in the subpaving module."); + d.insert("max_nodes", CPK_UINT, "(default: 8192) maximum number of nodes in the subpaving tree."); + d.insert("max_depth", CPK_UINT, "(default: 128) maximum depth of the subpaving tree."); + d.insert("epsilon", CPK_UINT, "(default: 20) value k s.t. a new lower (upper) bound for x is propagated only new-lower(x) > lower(k) + 1/k * max(min(upper(x) - lower(x), |lower|), 1) (new-upper(x) < upper(x) - 1/k * max(min(upper(x) - lower(x), |lower|), 1)). If k = 0, then this restriction is ignored."); + d.insert("max_bound", CPK_UINT, "(default 10) value k s.t. a new upper (lower) bound for x is propagated only if upper(x) > -10^k or lower(x) = -oo (lower(x) < 10^k or upper(x) = oo)"); + d.insert("nth_root_precision", CPK_UINT, "(default 8192) value k s.t. 1/k is the precision for computing the nth root in the subpaving module."); } template void context_t::display_params(std::ostream & out) const { - out << ":max-nodes " << m_max_nodes << "\n"; - out << ":max-depth " << m_max_depth << "\n"; - out << ":epsilon " << nm().to_rational_string(m_epsilon) << "\n"; - out << ":max-bound " << nm().to_rational_string(m_max_bound) << "\n"; - out << ":max-memory " << m_max_memory << "\n"; + out << "max_nodes " << m_max_nodes << "\n"; + out << "max_depth " << m_max_depth << "\n"; + out << "epsilon " << nm().to_rational_string(m_epsilon) << "\n"; + out << "max_bound " << nm().to_rational_string(m_max_bound) << "\n"; + out << "max_memory " << m_max_memory << "\n"; } template diff --git a/src/math/subpaving/tactic/subpaving_tactic.cpp b/src/math/subpaving/tactic/subpaving_tactic.cpp index 7bbff4b0b..d03bacebb 100644 --- a/src/math/subpaving/tactic/subpaving_tactic.cpp +++ b/src/math/subpaving/tactic/subpaving_tactic.cpp @@ -81,14 +81,14 @@ class subpaving_tactic : public tactic { void collect_param_descrs(param_descrs & r) { m_ctx->collect_param_descrs(r); // #ifndef _EXTERNAL_RELEASE - r.insert(":numeral", CPK_SYMBOL, "(default: mpq) options: mpq, mpf, hwf, mpff, mpfx."); - r.insert(":print-nodes", CPK_BOOL, "(default: false) display subpaving tree leaves."); + r.insert("numeral", CPK_SYMBOL, "(default: mpq) options: mpq, mpf, hwf, mpff, mpfx."); + r.insert("print_nodes", CPK_BOOL, "(default: false) display subpaving tree leaves."); // #endif } void updt_params(params_ref const & p) { - m_display = p.get_bool(":print-nodes", false); - symbol engine = p.get_sym(":numeral", symbol("mpq")); + m_display = p.get_bool("print_nodes", false); + symbol engine = p.get_sym("numeral", symbol("mpq")); engine_kind new_kind; if (engine == "mpq") new_kind = MPQ; @@ -293,16 +293,16 @@ tactic * mk_subpaving_tactic_core(ast_manager & m, params_ref const & p) { tactic * mk_subpaving_tactic(ast_manager & m, params_ref const & p) { params_ref simp_p = p; - simp_p.set_bool(":arith-lhs", true); - simp_p.set_bool(":expand-power", true); - simp_p.set_uint(":max-power", UINT_MAX); - simp_p.set_bool(":som", true); - simp_p.set_bool(":eq2ineq", true); - simp_p.set_bool(":elim-and", true); - simp_p.set_bool(":blast-distinct", true); + simp_p.set_bool("arith_lhs", true); + simp_p.set_bool("expand_power", true); + simp_p.set_uint("max_power", UINT_MAX); + simp_p.set_bool("som", true); + simp_p.set_bool("eq2ineq", true); + simp_p.set_bool("elim_and", true); + simp_p.set_bool("blast_distinct", true); params_ref simp2_p = p; - simp2_p.set_bool(":mul-to-power", true); + simp2_p.set_bool("mul_to_power", true); return and_then(using_params(mk_simplify_tactic(m, p), simp_p), diff --git a/src/model/model_evaluator.cpp b/src/model/model_evaluator.cpp index 258590121..beed0061e 100644 --- a/src/model/model_evaluator.cpp +++ b/src/model/model_evaluator.cpp @@ -60,10 +60,10 @@ struct evaluator_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_model_completion = p.get_bool(":model-completion", false); - m_cache = p.get_bool(":cache", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_model_completion = p.get_bool("model_completion", false); + m_cache = p.get_bool("cache", true); } ast_manager & m() const { return m_model.get_manager(); } @@ -232,8 +232,8 @@ void model_evaluator::updt_params(params_ref const & p) { void model_evaluator::get_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":model-completion", CPK_BOOL, "(default: false) assigns an interpretation to symbols that are not intepreted by the model."); - r.insert(":cache", CPK_BOOL, "(default: true) cache intermediate results."); + r.insert("model_completion", CPK_BOOL, "(default: false) assigns an interpretation to symbols that are not intepreted by the model."); + r.insert("cache", CPK_BOOL, "(default: true) cache intermediate results."); } void model_evaluator::set_model_completion(bool f) { diff --git a/src/muz_qe/datalog_parser.cpp b/src/muz_qe/datalog_parser.cpp index f527bb25a..a1bfc629d 100644 --- a/src/muz_qe/datalog_parser.cpp +++ b/src/muz_qe/datalog_parser.cpp @@ -1162,7 +1162,7 @@ public: : dparser(ctx, ctx.get_manager()), m_bool_sort(ctx.get_manager()), m_short_sort(ctx.get_manager()), - m_use_map_names(ctx.get_params().get_bool(":use-map-names", true)) { + m_use_map_names(ctx.get_params().get_bool("use_map_names", true)) { } ~wpa_parser_impl() { reset_dealloc_values(m_sort_contents); diff --git a/src/muz_qe/dl_bmc_engine.cpp b/src/muz_qe/dl_bmc_engine.cpp index 02791bc6f..e88e04c5a 100644 --- a/src/muz_qe/dl_bmc_engine.cpp +++ b/src/muz_qe/dl_bmc_engine.cpp @@ -71,7 +71,7 @@ namespace datalog { m_ctx.set_output_predicate(m_query_pred); m_ctx.apply_default_transformation(mc, m_pc); - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index e19b9fef8..28e699c7c 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -210,7 +210,7 @@ public: datalog::context& dlctx = m_dl_ctx->dlctx(); set_background(ctx); dlctx.updt_params(m_params); - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); cancel_eh eh(dlctx); lbool status = l_undef; { @@ -266,9 +266,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { m_dl_ctx->dlctx().collect_params(p); insert_timeout(p); - p.insert(":print-answer", CPK_BOOL, "(default: false) print answer instance(s) to query."); - p.insert(":print-certificate", CPK_BOOL, "(default: false) print certificate for reachability or non-reachability."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print_answer", CPK_BOOL, "(default: false) print answer instance(s) to query."); + p.insert("print_certificate", CPK_BOOL, "(default: false) print certificate for reachability or non-reachability."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } @@ -283,7 +283,7 @@ private: } void print_answer(cmd_context& ctx) { - if (m_params.get_bool(":print-answer", false)) { + if (m_params.get_bool("print_answer", false)) { datalog::context& dlctx = m_dl_ctx->dlctx(); ast_manager& m = ctx.m(); expr_ref query_result(dlctx.get_answer_as_formula(), m); @@ -298,7 +298,7 @@ private: } void print_statistics(cmd_context& ctx) { - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { statistics st; datalog::context& dlctx = m_dl_ctx->dlctx(); unsigned long long max_mem = memory::get_max_used_memory(); @@ -312,7 +312,7 @@ private: } void print_certificate(cmd_context& ctx) { - if (m_params.get_bool(":print-certificate", false)) { + if (m_params.get_bool("print_certificate", false)) { datalog::context& dlctx = m_dl_ctx->dlctx(); if (!dlctx.display_certificate(ctx.regular_stream())) { throw cmd_exception("certificates are not supported for the selected engine"); diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index ec78f8e92..9fbc93248 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -960,55 +960,55 @@ namespace datalog { } void context::collect_params(param_descrs& p) { - p.insert(":engine", CPK_SYMBOL, "(default: automatically configured) select 'datalog', PDR 'pdr' engine."); - p.insert(":bit-blast", CPK_BOOL, "(default: false) bit-blast bit-vectors (for PDR engine)."); - p.insert(":default-table", CPK_SYMBOL, "default table implementation: 'sparse' (default), 'hashtable', 'bitvector', 'interval'"); - p.insert(":default-relation", CPK_SYMBOL, "default relation implementation: 'external_relation', 'pentagon'"); + p.insert("engine", CPK_SYMBOL, "(default: automatically configured) select 'datalog', PDR 'pdr' engine."); + p.insert("bit_blast", CPK_BOOL, "(default: false) bit-blast bit-vectors (for PDR engine)."); + p.insert("default_table", CPK_SYMBOL, "default table implementation: 'sparse' (default), 'hashtable', 'bitvector', 'interval'"); + p.insert("default_relation", CPK_SYMBOL, "default relation implementation: 'external_relation', 'pentagon'"); - p.insert(":generate-explanations", CPK_BOOL, "if true, signature of relations will be extended to contain explanations for facts"); - p.insert(":explanations-on-relation-level", CPK_BOOL, "if true, explanations are generated as history of each relation, " - "rather than per fact (:generate-explanations must be set to true for this option to have any effect)"); + p.insert("generate_explanations", CPK_BOOL, "if true, signature of relations will be extended to contain explanations for facts"); + p.insert("explanations_on_relation_level", CPK_BOOL, "if true, explanations are generated as history of each relation, " + "rather than per fact (generate_explanations must be set to true for this option to have any effect)"); - p.insert(":magic-sets-for-queries", CPK_BOOL, "magic set transformation will be used for queries"); - p.insert(":unbound-compressor", CPK_BOOL, "auxiliary relations will be introduced to avoid unbound variables in rule heads"); - p.insert(":similarity-compressor", CPK_BOOL, "rules that differ only in values of constants will be merged into a single rule"); - p.insert(":similarity-compressor-threshold", CPK_UINT, "if :dl-similiaryt-compressor is on, this value determines how many " + p.insert("magic_sets_for_queries", CPK_BOOL, "magic set transformation will be used for queries"); + p.insert("unbound_compressor", CPK_BOOL, "auxiliary relations will be introduced to avoid unbound variables in rule heads"); + p.insert("similarity_compressor", CPK_BOOL, "rules that differ only in values of constants will be merged into a single rule"); + p.insert("similarity_compressor_threshold", CPK_UINT, "if dl_similiaryt_compressor is on, this value determines how many " "similar rules there must be in order for them to be merged"); - p.insert(":all-or-nothing-deltas", CPK_BOOL, "compile rules so that it is enough for the delta relation in union and widening " + p.insert("all_or_nothing_deltas", CPK_BOOL, "compile rules so that it is enough for the delta relation in union and widening " "operations to determine only whether the updated relation was modified or not"); - p.insert(":compile-with-widening", CPK_BOOL, "widening will be used to compile recursive rules"); - p.insert(":eager-emptiness-checking", CPK_BOOL, "emptiness of affected relations will be checked after each instruction, " + p.insert("compile_with_widening", CPK_BOOL, "widening will be used to compile recursive rules"); + p.insert("eager_emptiness_checking", CPK_BOOL, "emptiness of affected relations will be checked after each instruction, " "so that we may ommit unnecessary instructions"); - p.insert(":default-table-checked", CPK_BOOL, - "if true, the detault table will be :default-table inside a wrapper that checks that " - "its results are the same as of :default-table-checker table"); + p.insert("default_table_checked", CPK_BOOL, + "if true, the detault table will be default_table inside a wrapper that checks that " + "its results are the same as of default_table_checker table"); - p.insert(":initial-restart-timeout", CPK_UINT, "length of saturation run before the first restart (in ms); zero means no restarts"); - p.insert(":restart-timeout-quotient", CPK_UINT, "restart timeout will be multiplied by this number after each restart"); - p.insert(":use-map-names", CPK_BOOL, "use names from map files when displaying tuples"); + p.insert("initial_restart_timeout", CPK_UINT, "length of saturation run before the first restart (in ms); zero means no restarts"); + p.insert("restart_timeout_quotient", CPK_UINT, "restart timeout will be multiplied by this number after each restart"); + p.insert("use_map_names", CPK_BOOL, "use names from map files when displaying tuples"); - p.insert(":output-profile", CPK_BOOL, "determines whether profile informations should be output when outputting Datalog rules or instructions"); - p.insert(":output-tuples", CPK_BOOL, "determines whether tuples for output predicates should be output"); - 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("output_profile", CPK_BOOL, "determines whether profile informations should be output when outputting Datalog rules or instructions"); + p.insert("output_tuples", CPK_BOOL, "determines whether tuples for output predicates should be output"); + 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 false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); + 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 false) 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, + p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " "by putting in half of the table columns, if it would have been empty otherwise"); - p.insert(":smt-relation-ground-recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); + p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); ); - p.insert(":fix-unbound-vars", CPK_BOOL, "fix unbound variables in tail"); - p.insert(":default-table-checker", CPK_SYMBOL, "see :default-table-checked"); - p.insert(":inline-linear", CPK_BOOL, "(default true) try linear inlining method"); - p.insert(":inline-eager", CPK_BOOL, "(default true) try eager inlining of rules"); - PRIVATE_PARAMS(p.insert(":inline-linear-branch", CPK_BOOL, "try linear inlining method with potential expansion");); + p.insert("fix_unbound_vars", CPK_BOOL, "fix unbound variables in tail"); + p.insert("default_table_checker", CPK_SYMBOL, "see default_table_checked"); + p.insert("inline_linear", CPK_BOOL, "(default true) try linear inlining method"); + p.insert("inline_eager", CPK_BOOL, "(default true) try eager inlining of rules"); + PRIVATE_PARAMS(p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion");); pdr::dl_interface::collect_params(p); bmc::collect_params(p); @@ -1189,7 +1189,7 @@ namespace datalog { }; void context::configure_engine() { - symbol e = m_params.get_sym(":engine", symbol()); + symbol e = m_params.get_sym("engine", symbol()); if (e == symbol("datalog")) { m_engine = DATALOG_ENGINE; @@ -1650,8 +1650,8 @@ namespace datalog { expr_ref fml(m); 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", false); + 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", false); #define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index 229bbc474..fe94dd3cc 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -156,25 +156,25 @@ namespace datalog { var_subst & get_var_subst() { return m_var_subst; } dl_decl_util & get_decl_util() { return m_decl_util; } - bool output_profile() const { return m_params.get_bool(":output-profile", false); } - bool fix_unbound_vars() const { return m_params.get_bool(":fix-unbound-vars", false); } - symbol default_table() const { return m_params.get_sym(":default-table", symbol("sparse")); } - symbol default_relation() const { return m_params.get_sym(":default-relation", external_relation_plugin::get_name()); } - symbol default_table_checker() const { return m_params.get_sym(":default-table-checker", symbol("sparse")); } - bool default_table_checked() const { return m_params.get_bool(":default-table-checked", false); } - bool dbg_fpr_nonempty_relation_signature() const { return m_params.get_bool(":dbg-fpr-nonempty-relation-signatures", false); } - unsigned dl_profile_milliseconds_threshold() const { return m_params.get_uint(":profile-milliseconds-threshold", 0); } - bool all_or_nothing_deltas() const { return m_params.get_bool(":all-or-nothing-deltas", false); } - bool compile_with_widening() const { return m_params.get_bool(":compile-with-widening", false); } - bool unbound_compressor() const { return m_params.get_bool(":unbound-compressor", true); } - bool similarity_compressor() const { return m_params.get_bool(":similarity-compressor", true); } - unsigned similarity_compressor_threshold() const { return m_params.get_uint(":similarity-compressor-threshold", 11); } + bool output_profile() const { return m_params.get_bool("output_profile", false); } + bool fix_unbound_vars() const { return m_params.get_bool("fix_unbound_vars", false); } + symbol default_table() const { return m_params.get_sym("default_table", symbol("sparse")); } + symbol default_relation() const { return m_params.get_sym("default_relation", external_relation_plugin::get_name()); } + symbol default_table_checker() const { return m_params.get_sym("default_table_checker", symbol("sparse")); } + bool default_table_checked() const { return m_params.get_bool("default_table_checked", false); } + bool dbg_fpr_nonempty_relation_signature() const { return m_params.get_bool("dbg_fpr_nonempty_relation_signatures", false); } + unsigned dl_profile_milliseconds_threshold() const { return m_params.get_uint("profile_milliseconds_threshold", 0); } + bool all_or_nothing_deltas() const { return m_params.get_bool("all_or_nothing_deltas", false); } + bool compile_with_widening() const { return m_params.get_bool("compile_with_widening", false); } + bool unbound_compressor() const { return m_params.get_bool("unbound_compressor", true); } + bool similarity_compressor() const { return m_params.get_bool("similarity_compressor", true); } + unsigned similarity_compressor_threshold() const { return m_params.get_uint("similarity_compressor_threshold", 11); } unsigned soft_timeout() const { return m_fparams.m_soft_timeout; } - unsigned initial_restart_timeout() const { return m_params.get_uint(":initial-restart-timeout", 0); } - bool generate_explanations() const { return m_params.get_bool(":generate-explanations", false); } - bool explanations_on_relation_level() const { return m_params.get_bool(":explanations-on-relation-level", false); } - bool magic_sets_for_queries() const { return m_params.get_bool(":magic-sets-for-queries", false); } - bool eager_emptiness_checking() const { return m_params.get_bool(":eager-emptiness-checking", true); } + unsigned initial_restart_timeout() const { return m_params.get_uint("initial_restart_timeout", 0); } + bool generate_explanations() const { return m_params.get_bool("generate_explanations", false); } + bool explanations_on_relation_level() const { return m_params.get_bool("explanations_on_relation_level", false); } + bool magic_sets_for_queries() const { return m_params.get_bool("magic_sets_for_queries", false); } + bool eager_emptiness_checking() const { return m_params.get_bool("eager_emptiness_checking", true); } void register_finite_sort(sort * s, sort_kind k); diff --git a/src/muz_qe/dl_mk_array_blast.cpp b/src/muz_qe/dl_mk_array_blast.cpp index d63528db3..a5259ba8a 100644 --- a/src/muz_qe/dl_mk_array_blast.cpp +++ b/src/muz_qe/dl_mk_array_blast.cpp @@ -30,7 +30,7 @@ namespace datalog { a(m), rm(ctx.get_rule_manager()), m_rewriter(m, m_params){ - m_params.set_bool(":expand-select-store",true); + m_params.set_bool("expand_select_store",true); m_rewriter.updt_params(m_params); } diff --git a/src/muz_qe/dl_mk_bit_blast.cpp b/src/muz_qe/dl_mk_bit_blast.cpp index 9c503360c..c523315d9 100644 --- a/src/muz_qe/dl_mk_bit_blast.cpp +++ b/src/muz_qe/dl_mk_bit_blast.cpp @@ -165,14 +165,14 @@ namespace datalog { m_rules(ctx.get_rule_manager()), m_blaster(ctx.get_manager(), m_params), m_rewriter(ctx.get_manager(), ctx, m_rules) { - m_params.set_bool(":blast-full", true); - m_params.set_bool(":blast-quant", true); + m_params.set_bool("blast_full", true); + m_params.set_bool("blast_quant", true); m_blaster.updt_params(m_params); } rule_set * operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc) { // TODO mc, pc - if (!m_context.get_params().get_bool(":bit-blast", false)) { + if (!m_context.get_params().get_bool("bit_blast", false)) { return 0; } if (m_context.get_engine() != PDR_ENGINE) { diff --git a/src/muz_qe/dl_mk_rule_inliner.cpp b/src/muz_qe/dl_mk_rule_inliner.cpp index 1d3d62020..cfe532fb6 100644 --- a/src/muz_qe/dl_mk_rule_inliner.cpp +++ b/src/muz_qe/dl_mk_rule_inliner.cpp @@ -751,7 +751,7 @@ namespace datalog { valid.resize(sz, true); params_ref const& params = m_context.get_params(); - bool allow_branching = params.get_bool(":inline-linear-branch", false); + bool allow_branching = params.get_bool("inline_linear_branch", false); for (unsigned i = 0; i < sz; ++i) { @@ -867,7 +867,7 @@ namespace datalog { scoped_ptr res = alloc(rule_set, m_context); - if (params.get_bool(":inline-eager", true)) { + if (params.get_bool("inline_eager", true)) { TRACE("dl", source.display(tout << "before eager inlining\n");); plan_inlining(source); something_done = transform_rules(source, *res); @@ -879,7 +879,7 @@ namespace datalog { TRACE("dl", res->display(tout << "after eager inlining\n");); } - if (params.get_bool(":inline-linear", true) && inline_linear(res)) { + if (params.get_bool("inline_linear", true) && inline_linear(res)) { something_done = true; } diff --git a/src/muz_qe/dl_smt_relation.cpp b/src/muz_qe/dl_smt_relation.cpp index 55d3f7199..348c63e1c 100644 --- a/src/muz_qe/dl_smt_relation.cpp +++ b/src/muz_qe/dl_smt_relation.cpp @@ -533,7 +533,7 @@ namespace datalog { IF_VERBOSE(10, verbose_stream() << "Computing delta...\n"; ); - if (params.get_bool(":smt-relation-ground-recursive", false)) { + if (params.get_bool("smt_relation_ground_recursive", false)) { // ensure R is ground. Simplify S using assumption not R if (!is_ground(rInst)) { proof_ref pr(m); diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 59e9e6fec..dd6a2c2d3 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -161,9 +161,9 @@ class horn_tactic : public tactic { bool produce_proofs = g->proofs_enabled(); if (produce_proofs) { - if (!m_ctx.get_params().get_bool(":generate-proof-trace", true)) { + if (!m_ctx.get_params().get_bool("generate_proof_trace", true)) { params_ref params = m_ctx.get_params(); - params.set_bool(":generate-proof-trace", true); + params.set_bool("generate_proof_trace", true); updt_params(params); } } diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 2f43d518c..3b3ee61a1 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1098,7 +1098,7 @@ namespace pdr { m_pm(m_fparams, m_params, m), m_query_pred(m), m_query(0), - m_search(m_params.get_bool(":bfs-model-search", true)), + m_search(m_params.get_bool("bfs_model_search", true)), m_last_result(l_undef), m_inductive_lvl(0), m_cancel(false) @@ -1323,7 +1323,7 @@ namespace pdr { }; void context::validate() { - if (!m_params.get_bool(":validate-result", false)) { + if (!m_params.get_bool("validate_result", false)) { return; } switch(m_last_result) { @@ -1414,12 +1414,12 @@ namespace pdr { void context::init_core_generalizers(datalog::rule_set& rules) { reset_core_generalizers(); classifier_proc classify(m, rules); - bool use_mc = m_params.get_bool(":use-multicore-generalizer", false); + bool use_mc = m_params.get_bool("use_multicore_generalizer", false); if (use_mc) { m_core_generalizers.push_back(alloc(core_multi_generalizer, *this, 0)); } - if (m_params.get_bool(":use-farkas", true) && !classify.is_bool()) { - if (m_params.get_bool(":inline-proof-mode", true)) { + if (m_params.get_bool("use_farkas", true) && !classify.is_bool()) { + if (m_params.get_bool("inline_proof_mode", true)) { m.toggle_proof_mode(PGM_FINE); m_fparams.m_proof_mode = PGM_FINE; m_fparams.m_arith_bound_prop = BP_NONE; @@ -1435,13 +1435,13 @@ namespace pdr { m_core_generalizers.push_back(alloc(core_farkas_generalizer, *this, m, m_fparams)); } } - if (!use_mc && m_params.get_bool(":use-inductive-generalizer", true)) { + if (!use_mc && m_params.get_bool("use_inductive_generalizer", true)) { m_core_generalizers.push_back(alloc(core_bool_inductive_generalizer, *this, 0)); } - if (m_params.get_bool(":use-interpolants", false)) { + if (m_params.get_bool("use_interpolants", false)) { m_core_generalizers.push_back(alloc(core_interpolant_generalizer, *this)); } - if (m_params.get_bool(":inductive-reachability-check", false)) { + if (m_params.get_bool("inductive_reachability_check", false)) { m_core_generalizers.push_back(alloc(core_induction_generalizer, *this)); } } @@ -1553,7 +1553,7 @@ namespace pdr { \brief Retrieve satisfying assignment with explanation. */ expr_ref context::mk_sat_answer() const { - if (m_params.get_bool(":generate-proof-trace", false)) { + if (m_params.get_bool("generate_proof_trace", false)) { proof_ref pr = get_proof(); return expr_ref(pr.get(), m); } @@ -1674,7 +1674,7 @@ namespace pdr { n.pt().add_property(ncore, uses_level?n.level():infty_level); } CASSERT("pdr",n.level() == 0 || check_invariant(n.level()-1)); - m_search.backtrack_level(!found_invariant && m_params.get_bool(":flexible-trace", false), n); + m_search.backtrack_level(!found_invariant && m_params.get_bool("flexible_trace", false), n); break; } case l_undef: { @@ -1696,7 +1696,7 @@ namespace pdr { } void context::propagate(unsigned max_prop_lvl) { - if (m_params.get_bool(":simplify-formulas-pre", false)) { + if (m_params.get_bool("simplify_formulas_pre", false)) { simplify_formulas(); } for (unsigned lvl = 0; lvl <= max_prop_lvl; lvl++) { @@ -1715,7 +1715,7 @@ namespace pdr { throw inductive_exception(); } } - if (m_params.get_bool(":simplify-formulas-post", false)) { + if (m_params.get_bool("simplify_formulas_post", false)) { simplify_formulas(); } } @@ -1763,7 +1763,7 @@ namespace pdr { */ void context::create_children(model_node& n) { SASSERT(n.level() > 0); - bool use_model_generalizer = m_params.get_bool(":use-model-generalizer", false); + bool use_model_generalizer = m_params.get_bool("use_model_generalizer", false); datalog::scoped_no_proof _sc(m); pred_transformer& pt = n.pt(); diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index b047aaae0..6cbc3b78d 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -108,13 +108,13 @@ lbool dl_interface::query(expr * query) { model_converter_ref mc = datalog::mk_skip_model_converter(); proof_converter_ref pc; - if (m_ctx.get_params().get_bool(":generate-proof-trace", false)) { + if (m_ctx.get_params().get_bool("generate_proof_trace", false)) { pc = datalog::mk_skip_proof_converter(); } m_ctx.set_output_predicate(query_pred); m_ctx.apply_default_transformation(mc, pc); - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); @@ -133,10 +133,10 @@ lbool dl_interface::query(expr * query) { } } - if (m_ctx.get_params().get_uint(":unfold-rules",0) > 0) { - unsigned num_unfolds = m_ctx.get_params().get_uint(":unfold-rules", 0); + if (m_ctx.get_params().get_uint("unfold_rules",0) > 0) { + unsigned num_unfolds = m_ctx.get_params().get_uint("unfold_rules", 0); datalog::rule_transformer transformer1(m_ctx), transformer2(m_ctx); - if (m_ctx.get_params().get_uint(":coalesce-rules", false)) { + if (m_ctx.get_params().get_uint("coalesce_rules", false)) { transformer1.register_plugin(alloc(datalog::mk_coalesce, m_ctx)); m_ctx.transform_rules(transformer1, mc, pc); } @@ -198,7 +198,7 @@ expr_ref dl_interface::get_cover_delta(int level, func_decl* pred_orig) { } void dl_interface::add_cover(int level, func_decl* pred, expr* property) { - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { throw default_exception("Covers are incompatible with slicing. Disable slicing before using covers"); } m_context->add_cover(level, pred, property); @@ -248,28 +248,28 @@ proof_ref dl_interface::get_proof() { } void dl_interface::collect_params(param_descrs& p) { - p.insert(":bfs-model-search", CPK_BOOL, "PDR: (default true) use BFS strategy for expanding model search"); - p.insert(":use-farkas", CPK_BOOL, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"); - p.insert(":generate-proof-trace", CPK_BOOL, "PDR: (default false) trace for 'sat' answer as proof object"); - p.insert(":inline-proofs", CPK_BOOL, "PDR: (default true) run PDR with proof mode turned on and extract " + p.insert("bfs_model_search", CPK_BOOL, "PDR: (default true) use BFS strategy for expanding model search"); + p.insert("use_farkas", CPK_BOOL, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"); + p.insert("generate_proof_trace", CPK_BOOL, "PDR: (default false) trace for 'sat' answer as proof object"); + p.insert("inline_proofs", CPK_BOOL, "PDR: (default true) run PDR with proof mode turned on and extract " "Farkas coefficients directly (instead of creating a separate proof object when extracting coefficients)"); - p.insert(":flexible-trace", CPK_BOOL, "PDR: (default false) allow PDR generate long counter-examples " + p.insert("flexible_trace", CPK_BOOL, "PDR: (default false) allow PDR generate long counter-examples " "by extending candidate trace within search area"); - p.insert(":unfold-rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); - p.insert(":use-model-generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); - p.insert(":validate-result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); - PRIVATE_PARAMS(p.insert(":use-multicore-generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); - PRIVATE_PARAMS(p.insert(":use-inductive-generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); - PRIVATE_PARAMS(p.insert(":use-interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); - PRIVATE_PARAMS(p.insert(":dump-interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); - PRIVATE_PARAMS(p.insert(":cache-mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); - PRIVATE_PARAMS(p.insert(":inductive-reachability-check", CPK_BOOL, + p.insert("unfold_rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); + p.insert("use_model_generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); + p.insert("validate_result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); + PRIVATE_PARAMS(p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); + PRIVATE_PARAMS(p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); + PRIVATE_PARAMS(p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); + PRIVATE_PARAMS(p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); + PRIVATE_PARAMS(p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); + PRIVATE_PARAMS(p.insert("inductive_reachability_check", CPK_BOOL, "PDR: (default false) assume negation of the cube on the previous level when " "checking for reachability (not only during cube weakening)");); - PRIVATE_PARAMS(p.insert(":max-num-contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); - PRIVATE_PARAMS(p.insert(":try-minimize-core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); - p.insert(":simplify-formulas-pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); - p.insert(":simplify-formulas-post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); - p.insert(":slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); - p.insert(":coalesce-rules", CPK_BOOL, "BMC: (default false) coalesce rules"); + PRIVATE_PARAMS(p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); + PRIVATE_PARAMS(p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); + p.insert("simplify_formulas_pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); + p.insert("simplify_formulas_post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); + p.insert("slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); + p.insert("coalesce_rules", CPK_BOOL, "BMC: (default false) coalesce rules"); } diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index 85655c737..bcea5cbc4 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -318,7 +318,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& throw default_exception("invalid interpolator output"); } res = *ait; - if (m_params.get_bool(":dump-interpolants", false)) { + if (m_params.get_bool("dump_interpolants", false)) { interpolant_provider::output_interpolant(m, f1, f2, res); } return l_true; diff --git a/src/muz_qe/pdr_prop_solver.cpp b/src/muz_qe/pdr_prop_solver.cpp index d70675d80..4fd036f48 100644 --- a/src/muz_qe/pdr_prop_solver.cpp +++ b/src/muz_qe/pdr_prop_solver.cpp @@ -212,7 +212,7 @@ namespace pdr { m(pm.get_manager()), m_pm(pm), m_name(name), - m_try_minimize_core(pm.get_params().get_bool(":try-minimize-core", false)), + m_try_minimize_core(pm.get_params().get_bool("try_minimize_core", false)), m_ctx(pm.mk_fresh()), m_pos_level_atoms(m), m_neg_level_atoms(m), diff --git a/src/muz_qe/pdr_reachable_cache.cpp b/src/muz_qe/pdr_reachable_cache.cpp index ed9926f85..f248f4d86 100644 --- a/src/muz_qe/pdr_reachable_cache.cpp +++ b/src/muz_qe/pdr_reachable_cache.cpp @@ -27,7 +27,7 @@ namespace pdr { m_ctx(0), m_ref_holder(m), m_disj_connector(m), - m_cache_mode((datalog::PDR_CACHE_MODE)params.get_uint(":cache-mode",0)) { + m_cache_mode((datalog::PDR_CACHE_MODE)params.get_uint("cache_mode",0)) { if (m_cache_mode == datalog::CONSTRAINT_CACHE) { m_ctx = pm.mk_fresh(); m_ctx->assert_expr(m_pm.get_background()); diff --git a/src/muz_qe/pdr_smt_context_manager.cpp b/src/muz_qe/pdr_smt_context_manager.cpp index d79192769..c9dcf7b4e 100644 --- a/src/muz_qe/pdr_smt_context_manager.cpp +++ b/src/muz_qe/pdr_smt_context_manager.cpp @@ -96,7 +96,7 @@ namespace pdr { smt_context_manager::smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m): m_fparams(fp), m(m), - m_max_num_contexts(p.get_uint(":max-num-contexts", 500)), + m_max_num_contexts(p.get_uint("max_num_contexts", 500)), m_num_contexts(0), m_predicate_list(m) { } diff --git a/src/muz_qe/qe.cpp b/src/muz_qe/qe.cpp index a01500fe3..3b854b250 100644 --- a/src/muz_qe/qe.cpp +++ b/src/muz_qe/qe.cpp @@ -1340,7 +1340,7 @@ namespace qe { m_nnf(m, get_is_relevant(), get_mk_atom()) { params_ref params; - params.set_bool(":gcd-rounding", true); + params.set_bool("gcd_rounding", true); m_rewriter.updt_params(params); } @@ -2010,7 +2010,7 @@ namespace qe { } void updt_params(params_ref const& p) { - m_eliminate_variables_as_block = p.get_bool(":eliminate-variables-as-block", m_eliminate_variables_as_block); + m_eliminate_variables_as_block = p.get_bool("eliminate_variables_as_block", m_eliminate_variables_as_block); } void eliminate(bool is_forall, unsigned num_vars, app* const* vars, expr_ref& fml) { @@ -2194,7 +2194,7 @@ namespace qe { } void expr_quant_elim::updt_params(params_ref const& p) { - bool r = p.get_bool(":use-neq-qe", m_use_new_qe); + bool r = p.get_bool("use_neq_qe", m_use_new_qe); if (r != m_use_new_qe) { dealloc(m_qe); m_qe = 0; @@ -2205,9 +2205,9 @@ namespace qe { } void expr_quant_elim::collect_param_descrs(param_descrs& r) { - r.insert(":eliminate-variables-as-block", CPK_BOOL, + r.insert("eliminate_variables_as_block", CPK_BOOL, "(default: true) eliminate variables as a block (true) or one at a time (false)"); - // r.insert(":use-new-qe", CPK_BOOL, "(default: true) invoke quantifier engine based on abstracted solver"); + // r.insert("use_new_qe", CPK_BOOL, "(default: true) invoke quantifier engine based on abstracted solver"); } void expr_quant_elim::init_qe() { diff --git a/src/muz_qe/qe_cmd.cpp b/src/muz_qe/qe_cmd.cpp index 218224c51..ef8d1c058 100644 --- a/src/muz_qe/qe_cmd.cpp +++ b/src/muz_qe/qe_cmd.cpp @@ -16,8 +16,8 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { insert_timeout(p); - p.insert(":print", CPK_BOOL, "(default: true) print the simplified term."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } virtual ~qe_cmd() { @@ -45,11 +45,11 @@ public: qe(m_target, result, pr); - if (m_params.get_bool(":print", true)) { + if (m_params.get_bool("print", true)) { ctx.display(ctx.regular_stream(), result); ctx.regular_stream() << std::endl; } - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { statistics st; qe.collect_statistics(st); st.display(ctx.regular_stream()); diff --git a/src/muz_qe/qe_lite.cpp b/src/muz_qe/qe_lite.cpp index 6baa7ad80..9c9f54830 100644 --- a/src/muz_qe/qe_lite.cpp +++ b/src/muz_qe/qe_lite.cpp @@ -1048,13 +1048,13 @@ namespace fm { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_fm_real_only = p.get_bool(":fm-real-only", true); - m_fm_limit = p.get_uint(":fm-limit", 5000000); - m_fm_cutoff1 = p.get_uint(":fm-cutoff1", 8); - m_fm_cutoff2 = p.get_uint(":fm-cutoff2", 256); - m_fm_extra = p.get_uint(":fm-extra", 0); - m_fm_occ = p.get_bool(":fm-occ", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_fm_real_only = p.get_bool("fm_real_only", true); + m_fm_limit = p.get_uint("fm_limit", 5000000); + m_fm_cutoff1 = p.get_uint("fm_cutoff1", 8); + m_fm_cutoff2 = p.get_uint("fm_cutoff2", 256); + m_fm_extra = p.get_uint("fm_extra", 0); + m_fm_occ = p.get_bool("fm_occ", false); } void set_cancel(bool f) { diff --git a/src/muz_qe/qe_sat_tactic.cpp b/src/muz_qe/qe_sat_tactic.cpp index 1480a8ca0..5f73e4a30 100644 --- a/src/muz_qe/qe_sat_tactic.cpp +++ b/src/muz_qe/qe_sat_tactic.cpp @@ -301,17 +301,17 @@ namespace qe { virtual void cleanup() {} virtual void updt_params(params_ref const & p) { - m_extrapolate_strategy_param = p.get_uint(":extrapolate-strategy", m_extrapolate_strategy_param); - m_projection_mode_param = p.get_bool(":projection-mode", m_projection_mode_param); - m_strong_context_simplify_param = p.get_bool(":strong-context-simplify", m_strong_context_simplify_param); - m_ctx_simplify_local_param = p.get_bool(":strong-context-simplify-local", m_ctx_simplify_local_param); + m_extrapolate_strategy_param = p.get_uint("extrapolate_strategy", m_extrapolate_strategy_param); + m_projection_mode_param = p.get_bool("projection_mode", m_projection_mode_param); + m_strong_context_simplify_param = p.get_bool("strong_context_simplify", m_strong_context_simplify_param); + m_ctx_simplify_local_param = p.get_bool("strong_context_simplify_local", m_ctx_simplify_local_param); } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":extrapolate-strategy",CPK_UINT, "(default: 0 trivial extrapolation) 1 - nnf strengthening 2 - smt-test 3 - nnf_weakening"); - r.insert(":projection-mode", CPK_BOOL, "(default: true - full) false - partial quantifier instantiation"); - r.insert(":strong-context-simplify", CPK_BOOL, "(default: true) use strong context simplifier on result of quantifier elimination"); - r.insert(":strong-context-simplify-local", CPK_BOOL, "(default: false) use strong context simplifier locally on the new formula only"); + r.insert("extrapolate_strategy",CPK_UINT, "(default: 0 trivial extrapolation) 1 - nnf strengthening 2 - smt-test 3 - nnf_weakening"); + r.insert("projection_mode", CPK_BOOL, "(default: true - full) false - partial quantifier instantiation"); + r.insert("strong_context_simplify", CPK_BOOL, "(default: true) use strong context simplifier on result of quantifier elimination"); + r.insert("strong_context_simplify_local", CPK_BOOL, "(default: false) use strong context simplifier locally on the new formula only"); } diff --git a/src/muz_qe/qe_tactic.cpp b/src/muz_qe/qe_tactic.cpp index f17d15d6a..971d677ea 100644 --- a/src/muz_qe/qe_tactic.cpp +++ b/src/muz_qe/qe_tactic.cpp @@ -36,7 +36,7 @@ class qe_tactic : public tactic { } void updt_params(params_ref const & p) { - m_fparams.m_nlquant_elim = p.get_bool(":qe-nonlinear", false); + m_fparams.m_nlquant_elim = p.get_bool("qe_nonlinear", false); m_qe.updt_params(p); } @@ -113,7 +113,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { - r.insert(":qe-nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution."); + r.insert("qe_nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution."); m_imp->collect_param_descrs(r); } diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 837e76ecd..d76d584f7 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -198,15 +198,15 @@ namespace nlsat { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_lazy = p.get_uint(":lazy", 0); - m_simplify_cores = p.get_bool(":simplify-conflicts", true); - bool min_cores = p.get_bool(":minimize-conflicts", false); - m_reorder = p.get_bool(":reorder", true); - m_randomize = p.get_bool(":randomize", true); - m_max_conflicts = p.get_uint(":max-conflicts", UINT_MAX); - m_random_order = p.get_bool(":shuffle-vars", false); - m_random_seed = p.get_uint(":seed", 0); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_lazy = p.get_uint("lazy", 0); + m_simplify_cores = p.get_bool("simplify_conflicts", true); + bool min_cores = p.get_bool("minimize_conflicts", false); + m_reorder = p.get_bool("reorder", true); + m_randomize = p.get_bool("randomize", true); + m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); + m_random_order = p.get_bool("shuffle_vars", false); + m_random_seed = p.get_uint("seed", 0); m_ism.set_seed(m_random_seed); m_explain.set_simplify_cores(m_simplify_cores); m_explain.set_minimize_cores(min_cores); @@ -2572,13 +2572,13 @@ namespace nlsat { void solver::collect_param_descrs(param_descrs & d) { insert_max_memory(d); algebraic_numbers::manager::collect_param_descrs(d); - d.insert(":max-conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - d.insert(":shuffle-vars", CPK_BOOL, "(default: false) use a variable order."); - d.insert(":seed", CPK_UINT, "(default: 0) random seed."); - d.insert(":randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); - d.insert(":reorder", CPK_BOOL, "(default: true) reorder variables."); - d.insert(":lazy", CPK_UINT, "(default: 0) how lazy the solver is."); - d.insert(":simplify-conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); + d.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); + d.insert("shuffle_vars", CPK_BOOL, "(default: false) use a variable order."); + d.insert("seed", CPK_UINT, "(default: 0) random seed."); + d.insert("randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); + d.insert("reorder", CPK_BOOL, "(default: true) reorder variables."); + d.insert("lazy", CPK_UINT, "(default: 0) how lazy the solver is."); + d.insert("simplify_conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); } unsynch_mpq_manager & solver::qm() { diff --git a/src/nlsat/tactic/goal2nlsat.cpp b/src/nlsat/tactic/goal2nlsat.cpp index 75e3c4a40..1af98c7e8 100644 --- a/src/nlsat/tactic/goal2nlsat.cpp +++ b/src/nlsat/tactic/goal2nlsat.cpp @@ -77,8 +77,8 @@ struct goal2nlsat::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_factor = p.get_bool(":factor", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_factor = p.get_bool("factor", true); m_fparams.updt_params(p); } @@ -293,7 +293,7 @@ goal2nlsat::~goal2nlsat() { void goal2nlsat::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":factor", CPK_BOOL, "(default: true) factor polynomials."); + r.insert("factor", CPK_BOOL, "(default: true) factor polynomials."); polynomial::factor_params::get_param_descrs(r); } diff --git a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp index 7bb6bd019..b05636541 100644 --- a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp +++ b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp @@ -31,13 +31,13 @@ Notes: tactic * mk_qfnra_nlsat_tactic(ast_manager & m, params_ref const & p) { params_ref main_p = p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":blast-distinct", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("blast_distinct", true); params_ref purify_p = p; - purify_p.set_bool(":complete", false); // temporary hack, solver does not support uninterpreted functions for encoding (div0 x) applications. So, we replace it application of this kind with an uninterpreted function symbol. + purify_p.set_bool("complete", false); // temporary hack, solver does not support uninterpreted functions for encoding (div0 x) applications. So, we replace it application of this kind with an uninterpreted function symbol. tactic * factor; - if (p.get_bool(":factor", true)) + if (p.get_bool("factor", true)) factor = mk_factor_tactic(m, p); else factor = mk_skip_tactic(); diff --git a/src/sat/sat_asymm_branch.cpp b/src/sat/sat_asymm_branch.cpp index bc2a7120d..a7209306a 100644 --- a/src/sat/sat_asymm_branch.cpp +++ b/src/sat/sat_asymm_branch.cpp @@ -194,17 +194,17 @@ namespace sat { } void asymm_branch::updt_params(params_ref const & p) { - m_asymm_branch = p.get_bool(":asymm-branch", true); - m_asymm_branch_rounds = p.get_uint(":asymm-branch-rounds", 32); - m_asymm_branch_limit = p.get_uint(":asymm-branch-limit", 100000000); + m_asymm_branch = p.get_bool("asymm_branch", true); + m_asymm_branch_rounds = p.get_uint("asymm_branch_rounds", 32); + m_asymm_branch_limit = p.get_uint("asymm_branch_limit", 100000000); if (m_asymm_branch_limit > INT_MAX) m_asymm_branch_limit = INT_MAX; } void asymm_branch::collect_param_descrs(param_descrs & d) { - d.insert(":asymm-branch", CPK_BOOL, "(default: true) asymmetric branching."); - d.insert(":asymm-branch-rounds", CPK_UINT, "(default: 32) maximum number of rounds of asymmetric branching."); - d.insert(":asymm-branch-limit", CPK_UINT, "approx. maximum number of literals visited during asymmetric branching."); + d.insert("asymm_branch", CPK_BOOL, "(default: true) asymmetric branching."); + d.insert("asymm_branch_rounds", CPK_UINT, "(default: 32) maximum number of rounds of asymmetric branching."); + d.insert("asymm_branch_limit", CPK_UINT, "approx. maximum number of literals visited during asymmetric branching."); } void asymm_branch::collect_statistics(statistics & st) { diff --git a/src/sat/sat_config.cpp b/src/sat/sat_config.cpp index 48aa270e4..e30569d89 100644 --- a/src/sat/sat_config.cpp +++ b/src/sat/sat_config.cpp @@ -22,24 +22,24 @@ Revision History: namespace sat { config::config(params_ref const & p): - m_always_true("always-true"), - m_always_false("always-false"), + m_always_true("always_true"), + m_always_false("always_false"), m_caching("caching"), m_random("random"), m_geometric("geometric"), m_luby("luby"), - m_dyn_psm("dyn-psm"), + m_dyn_psm("dyn_psm"), m_psm("psm"), m_glue("glue"), - m_glue_psm("glue-psm"), - m_psm_glue("psm-glue") { + m_glue_psm("glue_psm"), + m_psm_glue("psm_glue") { updt_params(p); } void config::updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - symbol s = p.get_sym(":restart", m_luby); + symbol s = p.get_sym("restart", m_luby); if (s == m_luby) m_restart = RS_LUBY; else if (s == m_geometric) @@ -47,7 +47,7 @@ namespace sat { else throw sat_param_exception("invalid restart strategy"); - s = p.get_sym(":phase", m_caching); + s = p.get_sym("phase", m_caching); if (s == m_always_false) m_phase = PS_ALWAYS_FALSE; else if (s == m_always_true) @@ -59,29 +59,29 @@ namespace sat { else throw sat_param_exception("invalid phase selection strategy"); - m_phase_caching_on = p.get_uint(":phase-caching-on", 400); - m_phase_caching_off = p.get_uint(":phase-caching-off", 100); + m_phase_caching_on = p.get_uint("phase_caching_on", 400); + m_phase_caching_off = p.get_uint("phase_caching_off", 100); - m_restart_initial = p.get_uint(":restart-initial", 100); - m_restart_factor = p.get_double(":restart-factor", 1.5); + m_restart_initial = p.get_uint("restart_initial", 100); + m_restart_factor = p.get_double("restart_factor", 1.5); - m_random_freq = p.get_double(":random-freq", 0.01); + m_random_freq = p.get_double("random_freq", 0.01); - m_burst_search = p.get_uint(":burst-search", 100); + m_burst_search = p.get_uint("burst_search", 100); - m_max_conflicts = p.get_uint(":max-conflicts", UINT_MAX); + m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); - m_simplify_mult1 = p.get_uint(":simplify-mult1", 300); - m_simplify_mult2 = p.get_double(":simplify-mult2", 1.5); - m_simplify_max = p.get_uint(":simplify-max", 500000); + m_simplify_mult1 = p.get_uint("simplify_mult1", 300); + m_simplify_mult2 = p.get_double("simplify_mult2", 1.5); + m_simplify_max = p.get_uint("simplify_max", 500000); - s = p.get_sym(":gc-strategy", m_glue_psm); + s = p.get_sym("gc_strategy", m_glue_psm); if (s == m_dyn_psm) { m_gc_strategy = GC_DYN_PSM; - m_gc_initial = p.get_uint(":gc-initial", 500); - m_gc_increment = p.get_uint(":gc-increment", 100); - m_gc_small_lbd = p.get_uint(":gc-small-lbd", 3); - m_gc_k = p.get_uint(":gc-k", 7); + m_gc_initial = p.get_uint("gc_initial", 500); + m_gc_increment = p.get_uint("gc_increment", 100); + m_gc_small_lbd = p.get_uint("gc_small_lbd", 3); + m_gc_k = p.get_uint("gc_k", 7); if (m_gc_k > 255) m_gc_k = 255; } @@ -96,31 +96,31 @@ namespace sat { m_gc_strategy = GC_PSM_GLUE; else throw sat_param_exception("invalid gc strategy"); - m_gc_initial = p.get_uint(":gc-initial", 20000); - m_gc_increment = p.get_uint(":gc-increment", 500); + m_gc_initial = p.get_uint("gc_initial", 20000); + m_gc_increment = p.get_uint("gc_increment", 500); } - m_minimize_lemmas = p.get_bool(":minimize-lemmas", true); - m_dyn_sub_res = p.get_bool(":dyn-sub-res", true); + m_minimize_lemmas = p.get_bool("minimize_lemmas", true); + m_dyn_sub_res = p.get_bool("dyn_sub_res", true); } void config::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":phase", CPK_SYMBOL, "(default: caching) phase selection strategy: always-false, always-true, caching, random."); - r.insert(":phase-caching-on", CPK_UINT, "(default: 400)"); - r.insert(":phase-caching-off", CPK_UINT, "(default: 100)"); - r.insert(":restart", CPK_SYMBOL, "(default: luby) restart strategy: luby or geometric."); - r.insert(":restart-initial", CPK_UINT, "(default: 100) initial restart (number of conflicts)."); - r.insert(":restart-factor", CPK_DOUBLE, "(default: 1.5) restart increment factor for geometric strategy."); - r.insert(":random-freq", CPK_DOUBLE, "(default: 0.01) frequency of random case splits."); - r.insert(":burst-search", CPK_UINT, "(default: 100) number of conflicts before first global simplification."); - r.insert(":max-conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - r.insert(":gc-strategy", CPK_SYMBOL, "(default: glue-psm) garbage collection strategy: psm, glue, glue-psm, dyn-psm."); - r.insert(":gc-initial", CPK_UINT, "(default: 20000) learned clauses garbage collection frequence."); - r.insert(":gc-increment", CPK_UINT, "(default: 500) increment to the garbage collection threshold."); - r.insert(":gc-small-lbd", CPK_UINT, "(default: 3) learned clauses with small LBD are never deleted (only used in dyn-psm)."); - r.insert(":gc-k", CPK_UINT, "(default: 7) learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn-psm)."); - r.insert(":minimize-lemmas", CPK_BOOL, "(default: true) minimize learned clauses."); - r.insert(":dyn-sub-res", CPK_BOOL, "(default: true) dynamic subsumption resolution for minimizing learned clauses."); + r.insert("phase", CPK_SYMBOL, "(default: caching) phase selection strategy: always_false, always_true, caching, random."); + r.insert("phase_caching_on", CPK_UINT, "(default: 400)"); + r.insert("phase_caching_off", CPK_UINT, "(default: 100)"); + r.insert("restart", CPK_SYMBOL, "(default: luby) restart strategy: luby or geometric."); + r.insert("restart_initial", CPK_UINT, "(default: 100) initial restart (number of conflicts)."); + r.insert("restart_factor", CPK_DOUBLE, "(default: 1.5) restart increment factor for geometric strategy."); + r.insert("random_freq", CPK_DOUBLE, "(default: 0.01) frequency of random case splits."); + r.insert("burst_search", CPK_UINT, "(default: 100) number of conflicts before first global simplification."); + r.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); + r.insert("gc_strategy", CPK_SYMBOL, "(default: glue_psm) garbage collection strategy: psm, glue, glue_psm, dyn_psm."); + r.insert("gc_initial", CPK_UINT, "(default: 20000) learned clauses garbage collection frequence."); + r.insert("gc_increment", CPK_UINT, "(default: 500) increment to the garbage collection threshold."); + r.insert("gc_small_lbd", CPK_UINT, "(default: 3) learned clauses with small LBD are never deleted (only used in dyn_psm)."); + r.insert("gc_k", CPK_UINT, "(default: 7) learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn_psm)."); + r.insert("minimize_lemmas", CPK_BOOL, "(default: true) minimize learned clauses."); + r.insert("dyn_sub_res", CPK_BOOL, "(default: true) dynamic subsumption resolution for minimizing learned clauses."); } }; diff --git a/src/sat/sat_probing.cpp b/src/sat/sat_probing.cpp index f51b16033..f9741cd7b 100644 --- a/src/sat/sat_probing.cpp +++ b/src/sat/sat_probing.cpp @@ -243,11 +243,11 @@ namespace sat { } void probing::updt_params(params_ref const & p) { - m_probing = p.get_bool(":probing", true); - m_probing_limit = p.get_uint(":probing-limit", 5000000); - m_probing_cache = p.get_bool(":probing-cache", true); - m_probing_binary = p.get_bool(":probing-binary", true); - m_probing_cache_limit = megabytes_to_bytes(p.get_uint(":probing-chache-limit", 1024)); + m_probing = p.get_bool("probing", true); + m_probing_limit = p.get_uint("probing_limit", 5000000); + m_probing_cache = p.get_bool("probing_cache", true); + m_probing_binary = p.get_bool("probing_binary", true); + m_probing_cache_limit = megabytes_to_bytes(p.get_uint("probing_chache_limit", 1024)); } void probing::collect_param_descrs(param_descrs & d) { diff --git a/src/sat/sat_scc.cpp b/src/sat/sat_scc.cpp index 5e351290f..f2598119f 100644 --- a/src/sat/sat_scc.cpp +++ b/src/sat/sat_scc.cpp @@ -231,11 +231,11 @@ namespace sat { } void scc::updt_params(params_ref const & p) { - m_scc = p.get_bool(":scc", true); + m_scc = p.get_bool("scc", true); } void scc::collect_param_descrs(param_descrs & d) { - d.insert(":scc", CPK_BOOL, "(default: true) eliminate Boolean variables by computing strongly connected components."); + d.insert("scc", CPK_BOOL, "(default: true) eliminate Boolean variables by computing strongly connected components."); } }; diff --git a/src/sat/sat_simplifier.cpp b/src/sat/sat_simplifier.cpp index 3f3015967..8a1713647 100644 --- a/src/sat/sat_simplifier.cpp +++ b/src/sat/sat_simplifier.cpp @@ -1431,44 +1431,44 @@ namespace sat { } void simplifier::updt_params(params_ref const & p) { - m_elim_blocked_clauses = p.get_bool(":elim-blocked-clauses", false); - m_elim_blocked_clauses_at = p.get_uint(":elim-blocked-clauses-at", 2); - m_blocked_clause_limit = p.get_uint(":blocked-clause-limit", 100000000); - m_resolution = p.get_bool(":resolution", true); - m_res_limit = p.get_uint(":resolution-limit", 500000000); - m_res_occ_cutoff = p.get_uint(":res-occ-cutoff", 10); - m_res_occ_cutoff1 = p.get_uint(":res-occ-cutoff-range1", 8); - m_res_occ_cutoff2 = p.get_uint(":res-occ-cutoff-range2", 5); - m_res_occ_cutoff3 = p.get_uint(":res-occ-cutoff-range3", 3); - m_res_lit_cutoff1 = p.get_uint(":res-lit-cutoff-range1", 700); - m_res_lit_cutoff2 = p.get_uint(":res-lit-cutoff-range2", 400); - m_res_lit_cutoff3 = p.get_uint(":res-lit-cutoff-range3", 300); - m_res_cls_cutoff1 = p.get_uint(":res-cls-cutoff1", 100000); - m_res_cls_cutoff2 = p.get_uint(":res-cls-cutoff2", 700000); - m_subsumption = p.get_bool(":subsumption", true); - m_subsumption_limit = p.get_uint(":subsumption-limit", 100000000); + m_elim_blocked_clauses = p.get_bool("elim_blocked_clauses", false); + m_elim_blocked_clauses_at = p.get_uint("elim_blocked_clauses_at", 2); + m_blocked_clause_limit = p.get_uint("blocked_clause_limit", 100000000); + m_resolution = p.get_bool("resolution", true); + m_res_limit = p.get_uint("resolution_limit", 500000000); + m_res_occ_cutoff = p.get_uint("res_occ_cutoff", 10); + m_res_occ_cutoff1 = p.get_uint("res_occ_cutoff_range1", 8); + m_res_occ_cutoff2 = p.get_uint("res_occ_cutoff_range2", 5); + m_res_occ_cutoff3 = p.get_uint("res_occ_cutoff_range3", 3); + m_res_lit_cutoff1 = p.get_uint("res_lit_cutoff_range1", 700); + m_res_lit_cutoff2 = p.get_uint("res_lit_cutoff_range2", 400); + m_res_lit_cutoff3 = p.get_uint("res_lit_cutoff_range3", 300); + m_res_cls_cutoff1 = p.get_uint("res_cls_cutoff1", 100000); + m_res_cls_cutoff2 = p.get_uint("res_cls_cutoff2", 700000); + m_subsumption = p.get_bool("subsumption", true); + m_subsumption_limit = p.get_uint("subsumption_limit", 100000000); } void simplifier::collect_param_descrs(param_descrs & r) { - r.insert(":elim-blocked-clauses", CPK_BOOL, "(default: false) eliminate blocked clauses."); - r.insert(":elim-blocked-clauses-at", CPK_UINT, "(default: 2) eliminate blocked clauses only once at the given simplification round."); - r.insert(":blocked-clause-limit", CPK_UINT, "(default: 100000000) maximum number of literals visited during blocked clause elimination."); - r.insert(":resolution", CPK_BOOL, "(default: true) eliminate boolean variables using resolution."); - r.insert(":resolution-limit", CPK_UINT, "(default: 500000000) approx. maximum number of literals visited during variable elimination."); - r.insert(":res-occ-cutoff", CPK_UINT, "(default: 10) first cutoff (on number of positive/negative occurrences) for Boolean variable elimination."); - r.insert(":res-occ-cutoff-range1", CPK_UINT, "(default: 8) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than :res-cls-cutoff1 clauses."); - r.insert(":res-occ-cutoff-range2", CPK_UINT, "(default: 5) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than :res-cls-cutoff1 and less than :res-cls-cutoff2."); - r.insert(":res-occ-cutoff-range3", CPK_UINT, "(default: 3) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than :res-cls-cutoff2."); + r.insert("elim_blocked_clauses", CPK_BOOL, "(default: false) eliminate blocked clauses."); + r.insert("elim_blocked_clauses_at", CPK_UINT, "(default: 2) eliminate blocked clauses only once at the given simplification round."); + r.insert("blocked_clause_limit", CPK_UINT, "(default: 100000000) maximum number of literals visited during blocked clause elimination."); + r.insert("resolution", CPK_BOOL, "(default: true) eliminate boolean variables using resolution."); + r.insert("resolution_limit", CPK_UINT, "(default: 500000000) approx. maximum number of literals visited during variable elimination."); + r.insert("res_occ_cutoff", CPK_UINT, "(default: 10) first cutoff (on number of positive/negative occurrences) for Boolean variable elimination."); + r.insert("res_occ_cutoff_range1", CPK_UINT, "(default: 8) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); + r.insert("res_occ_cutoff_range2", CPK_UINT, "(default: 5) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); + r.insert("res_occ_cutoff_range3", CPK_UINT, "(default: 3) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - r.insert(":res-lit-cutoff-range1", CPK_UINT, "(default: 700) second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than :res-cls-cutoff1 clauses."); - r.insert(":res-lit-cutoff-range2", CPK_UINT, "(default: 400) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than :res-cls-cutoff1 and less than :res-cls-cutoff2."); - r.insert(":res-lit-cutoff-range3", CPK_UINT, "(default: 300) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than :res-cls-cutoff2."); + r.insert("res_lit_cutoff_range1", CPK_UINT, "(default: 700) second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); + r.insert("res_lit_cutoff_range2", CPK_UINT, "(default: 400) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); + r.insert("res_lit_cutoff_range3", CPK_UINT, "(default: 300) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - r.insert(":res-cls-cutoff1", CPK_UINT, "(default: 100000000) limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - r.insert(":res-cls-cutoff2", CPK_UINT, "(default: 700000000) limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination."); + r.insert("res_cls_cutoff1", CPK_UINT, "(default: 100000000) limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination."); + r.insert("res_cls_cutoff2", CPK_UINT, "(default: 700000000) limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - r.insert(":subsumption", CPK_BOOL, "(default: true) eliminate subsumed clauses."); - r.insert(":subsumption-limit", CPK_UINT, "(default: 100000000) approx. maximum number of literals visited during subsumption (and subsumption resolution)."); + r.insert("subsumption", CPK_BOOL, "(default: true) eliminate subsumed clauses."); + r.insert("subsumption_limit", CPK_UINT, "(default: 100000000) approx. maximum number of literals visited during subsumption (and subsumption resolution)."); } void simplifier::collect_statistics(statistics & st) { diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 0322e80c5..399fb2c61 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -1909,7 +1909,7 @@ namespace sat { m_asymm_branch.updt_params(p); m_probing.updt_params(p); m_scc.updt_params(p); - m_rand.set_seed(p.get_uint(":random-seed", 0)); + m_rand.set_seed(p.get_uint("random_seed", 0)); } void solver::collect_param_descrs(param_descrs & d) { diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index b6c2e39cf..16184e2bc 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -67,8 +67,8 @@ struct goal2sat::imp { } void updt_params(params_ref const & p) { - m_ite_extra = p.get_bool(":ite-extra", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_ite_extra = p.get_bool("ite_extra", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void throw_op_not_handled() { @@ -420,7 +420,7 @@ goal2sat::goal2sat():m_imp(0) { void goal2sat::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":ite-extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); + r.insert("ite_extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); } struct goal2sat::scoped_set_imp { @@ -575,8 +575,8 @@ struct sat2goal::imp { } void updt_params(params_ref const & p) { - m_learned = p.get_bool(":learned", false); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_learned = p.get_bool("learned", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void checkpoint() { @@ -676,7 +676,7 @@ sat2goal::sat2goal():m_imp(0) { void sat2goal::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":learned", CPK_BOOL, "(default: false) collect also learned clauses."); + r.insert("learned", CPK_BOOL, "(default: false) collect also learned clauses."); } struct sat2goal::scoped_set_imp { diff --git a/src/sat/tactic/sat_tactic.cpp b/src/sat/tactic/sat_tactic.cpp index 015eb6c66..d48994861 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -210,7 +210,7 @@ tactic * mk_sat_tactic(ast_manager & m, params_ref const & p) { tactic * mk_sat_preprocessor_tactic(ast_manager & m, params_ref const & p) { params_ref p_aux; - p_aux.set_uint(":max-conflicts", 0); + p_aux.set_uint("max_conflicts", 0); tactic * t = clean(using_params(mk_sat_tactic(m, p), p_aux)); t->updt_params(p); return t; diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index 14dcc91c3..d422db708 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -72,8 +72,8 @@ static void display_statistics( code.process_all_costs(); { params_ref p(ctx.get_params()); - p.set_bool(":output-profile", true); - p.set_uint(":profile-milliseconds-threshold", 100); + p.set_bool("output_profile", true); + p.set_uint("profile_milliseconds_threshold", 100); ctx.updt_params(p); out << "--------------\n"; @@ -132,9 +132,9 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref params; - params.set_sym(":engine", symbol("datalog")); - params.set_sym(":default-table", dl_params.m_default_table); - params.set_bool(":default-table-checked", dl_params.m_default_table_checked); + params.set_sym("engine", symbol("datalog")); + params.set_sym("default_table", dl_params.m_default_table); + params.set_bool("default_table_checked", dl_params.m_default_table_checked); datalog::context ctx(m, front_end_params, params); size_t watermark = front_end_params.m_memory_high_watermark; @@ -252,7 +252,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ TRACE("dl_compiler", ctx.display(tout); rules_code.display(ctx, tout);); - if (ctx.get_params().get_bool(":output-tuples", true)) { + if (ctx.get_params().get_bool("output_tuples", true)) { ctx.display_output_facts(std::cout); } diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index cf64ed110..2dbb0adf8 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -69,7 +69,7 @@ unsigned read_dimacs(char const * file_name, front_end_params & front_end_params register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref p; - p.set_bool(":produce-models", front_end_params.m_model); + p.set_bool("produce_models", front_end_params.m_model); sat::solver solver(p, 0); g_solver = &solver; diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 6dc5a7ebe..d6e7b1bf1 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -32,6 +32,7 @@ Revision History: #include"timeout.h" #include"z3_exception.h" #include"error_codes.h" +#include"gparams.h" typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_Z3_LOG } input_kind; @@ -76,8 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "ini:file configuration file.\n"; - std::cout << " " << OPT << "ini? display all available INI file parameters.\n"; + std::cout << " " << OPT << "params display all available parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -285,13 +285,8 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); } - else if (strcmp(opt_name, "ini") == 0) { - if (!opt_arg) - error("option argument (/ini:file) is missing."); - read_ini_file(opt_arg); - } - else if (strcmp(opt_name, "ini?") == 0) { - display_ini_help(); + else if (strcmp(opt_name, "params") == 0) { + gparams::display(std::cout); exit(0); } else if (strcmp(opt_name, "geninidoc") == 0) { @@ -327,7 +322,7 @@ void parse_cmd_line_args(int argc, char ** argv) { char * key = argv[i]; *eq_pos = 0; char * value = eq_pos+1; - g_params->set_param_value(key, value); + gparams::set(key, value); } else { if (g_front_end_params->m_interactive) { diff --git a/src/smt/arith_eq_solver.cpp b/src/smt/arith_eq_solver.cpp index 417f8022b..41a61bf73 100644 --- a/src/smt/arith_eq_solver.cpp +++ b/src/smt/arith_eq_solver.cpp @@ -26,8 +26,8 @@ arith_eq_solver::arith_eq_solver(ast_manager & m, params_ref const& p): m_util(m), m_arith_rewriter(m) { - m_params.set_bool(":gcd-rounding", true); - // m_params.set_bool(":sum", true); + m_params.set_bool("gcd_rounding", true); + // m_params.set_bool("sum", true); m_arith_rewriter.updt_params(m_params); } diff --git a/src/smt/smt_implied_equalities.cpp b/src/smt/smt_implied_equalities.cpp index 91784f5f5..c6f28d4b2 100644 --- a/src/smt/smt_implied_equalities.cpp +++ b/src/smt/smt_implied_equalities.cpp @@ -197,7 +197,7 @@ namespace smt { s_stats_val_eq_timer.start(); params_ref p; - p.set_bool(":produce-models", false); + p.set_bool("produce_models", false); m_solver.updt_params(p); for (unsigned i = 0; i < terms.size(); ++i) { @@ -232,7 +232,7 @@ namespace smt { } m_stats_val_eq_timer.stop(); s_stats_val_eq_timer.stop(); - p.set_bool(":produce-models", true); + p.set_bool("produce_models", true); m_solver.updt_params(p); @@ -325,7 +325,7 @@ namespace smt { lbool operator()(unsigned num_terms, expr* const* terms, unsigned* class_ids) { params_ref p; - p.set_bool(":produce-models", true); + p.set_bool("produce_models", true); m_solver.updt_params(p); sort2term_ids termids; stopwatch timer; diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 84587b6c9..1551c765c 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -60,8 +60,8 @@ public: } void updt_params_core(params_ref const & p) { - m_candidate_models = p.get_bool(":candidate-models", false); - m_fail_if_inconclusive = p.get_bool(":fail-if-inconclusive", true); + m_candidate_models = p.get_bool("candidate_models", false); + m_fail_if_inconclusive = p.get_bool("fail_if_inconclusive", true); } virtual void updt_params(params_ref const & p) { @@ -69,12 +69,12 @@ public: updt_params_core(p); m_params_ref = p; params2front_end_params(m_params_ref, fparams()); - SASSERT(p.get_bool(":auto_config", fparams().m_auto_config) == fparams().m_auto_config); + SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":candidate-models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete."); - r.insert(":fail-if-inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal."); + r.insert("candidate_models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete."); + r.insert("fail_if_inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal."); solver_front_end_params_descrs(r); } @@ -315,7 +315,7 @@ tactic * mk_smt_tactic(params_ref const & p) { tactic * mk_smt_tactic_using(bool auto_config, params_ref const & _p) { params_ref p = _p; - p.set_bool(":auto-config", auto_config); + p.set_bool("auto_config", auto_config); tactic * r = mk_smt_tactic(p); TRACE("smt_tactic", tout << "auto_config: " << auto_config << "\nr: " << r << "\np: " << p << "\n";); return using_params(r, p); diff --git a/src/tactic/aig/aig_tactic.cpp b/src/tactic/aig/aig_tactic.cpp index 617db0b8c..dc577eb73 100644 --- a/src/tactic/aig/aig_tactic.cpp +++ b/src/tactic/aig/aig_tactic.cpp @@ -62,14 +62,14 @@ public: } virtual void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_aig_gate_encoding = p.get_bool(":aig-default-gate-encoding", true); - m_aig_per_assertion = p.get_bool(":aig-per-assertion", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_aig_gate_encoding = p.get_bool("aig_default_gate_encoding", true); + m_aig_per_assertion = p.get_bool("aig_per_assertion", true); } virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":aig-per-assertion", CPK_BOOL, "(default: true) process one assertion at a time."); + r.insert("aig_per_assertion", CPK_BOOL, "(default: true) process one assertion at a time."); } void operator()(goal_ref const & g) { diff --git a/src/tactic/arith/add_bounds_tactic.cpp b/src/tactic/arith/add_bounds_tactic.cpp index 81e9c26cf..d396359a3 100644 --- a/src/tactic/arith/add_bounds_tactic.cpp +++ b/src/tactic/arith/add_bounds_tactic.cpp @@ -70,8 +70,8 @@ class add_bounds_tactic : public tactic { } void updt_params(params_ref const & p) { - m_lower = p.get_rat(":add-bound-lower", rational(-2)); - m_upper = p.get_rat(":add-bound-upper", rational(2)); + m_lower = p.get_rat("add_bound_lower", rational(-2)); + m_upper = p.get_rat("add_bound_upper", rational(2)); } void set_cancel(bool f) { @@ -159,8 +159,8 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":add-bound-lower", CPK_NUMERAL, "(default: -2) lower bound to be added to unbounded variables."); - r.insert(":add-bound-upper", CPK_NUMERAL, "(default: 2) upper bound to be added to unbounded variables."); + r.insert("add_bound_lower", CPK_NUMERAL, "(default: -2) lower bound to be added to unbounded variables."); + r.insert("add_bound_upper", CPK_NUMERAL, "(default: 2) upper bound to be added to unbounded variables."); } virtual void operator()(goal_ref const & g, diff --git a/src/tactic/arith/bound_propagator.cpp b/src/tactic/arith/bound_propagator.cpp index 40c2ed49b..dbd7c5f69 100644 --- a/src/tactic/arith/bound_propagator.cpp +++ b/src/tactic/arith/bound_propagator.cpp @@ -116,15 +116,15 @@ void bound_propagator::del_constraint(constraint & c) { } void bound_propagator::updt_params(params_ref const & p) { - m_max_refinements = p.get_uint(":bound-max-refinements", 16); - m_threshold = p.get_double(":bound-threshold", 0.05); - m_small_interval = p.get_double(":bound-small-interval", 128); - m_strict2double = p.get_double(":strict2double", 0.00001); + m_max_refinements = p.get_uint("bound_max_refinements", 16); + m_threshold = p.get_double("bound_threshold", 0.05); + m_small_interval = p.get_double("bound_small_interval", 128); + m_strict2double = p.get_double("strict2double", 0.00001); } void bound_propagator::get_param_descrs(param_descrs & r) { - r.insert(":bound-max-refinements", CPK_UINT, "(default: 16) maximum number of bound refinements (per round) for unbounded variables."); - r.insert(":bound-threshold", CPK_DOUBLE, "(default: 0.05) bound propagation improvement threshold ratio."); + r.insert("bound_max_refinements", CPK_UINT, "(default: 16) maximum number of bound refinements (per round) for unbounded variables."); + r.insert("bound_threshold", CPK_DOUBLE, "(default: 0.05) bound propagation improvement threshold ratio."); } void bound_propagator::collect_statistics(statistics & st) const { diff --git a/src/tactic/arith/bv2int_rewriter.cpp b/src/tactic/arith/bv2int_rewriter.cpp index e8ddf18c9..0965f36f2 100644 --- a/src/tactic/arith/bv2int_rewriter.cpp +++ b/src/tactic/arith/bv2int_rewriter.cpp @@ -21,7 +21,7 @@ Notes: #include "ast_pp.h" void bv2int_rewriter_ctx::update_params(params_ref const& p) { - m_max_size = p.get_uint(":max-bv-size", UINT_MAX); + m_max_size = p.get_uint("max_bv_size", UINT_MAX); } struct lt_rational { diff --git a/src/tactic/arith/diff_neq_tactic.cpp b/src/tactic/arith/diff_neq_tactic.cpp index 93ac6912d..b534c8295 100644 --- a/src/tactic/arith/diff_neq_tactic.cpp +++ b/src/tactic/arith/diff_neq_tactic.cpp @@ -62,7 +62,7 @@ class diff_neq_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_k = rational(p.get_uint(":diff-neq-max-k", 1024)); + m_max_k = rational(p.get_uint("diff_neq_max_k", 1024)); m_max_neg_k = -m_max_k; if (m_max_k >= rational(INT_MAX/2)) m_max_k = rational(INT_MAX/2); @@ -374,7 +374,7 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":diff-neq-max-k", CPK_UINT, "(default: 1024) maximum variable upper bound for diff neq solver."); + r.insert("diff_neq_max_k", CPK_UINT, "(default: 1024) maximum variable upper bound for diff neq solver."); } virtual void collect_statistics(statistics & st) const { diff --git a/src/tactic/arith/factor_tactic.cpp b/src/tactic/arith/factor_tactic.cpp index 2cfbc9ef8..752f6681d 100644 --- a/src/tactic/arith/factor_tactic.cpp +++ b/src/tactic/arith/factor_tactic.cpp @@ -40,7 +40,7 @@ class factor_tactic : public tactic { } void updt_params(params_ref const & p) { - m_split_factors = p.get_bool(":split-factors", true); + m_split_factors = p.get_bool("split_factors", true); m_fparams.updt_params(p); } @@ -311,7 +311,7 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":split-factors", CPK_BOOL, + r.insert("split_factors", CPK_BOOL, "(default: true) apply simplifications such as (= (* p1 p2) 0) --> (or (= p1 0) (= p2 0))."); polynomial::factor_params::get_param_descrs(r); } diff --git a/src/tactic/arith/fm_tactic.cpp b/src/tactic/arith/fm_tactic.cpp index 4796e7f39..c4b7cbaf3 100644 --- a/src/tactic/arith/fm_tactic.cpp +++ b/src/tactic/arith/fm_tactic.cpp @@ -792,13 +792,13 @@ class fm_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_fm_real_only = p.get_bool(":fm-real-only", true); - m_fm_limit = p.get_uint(":fm-limit", 5000000); - m_fm_cutoff1 = p.get_uint(":fm-cutoff1", 8); - m_fm_cutoff2 = p.get_uint(":fm-cutoff2", 256); - m_fm_extra = p.get_uint(":fm-extra", 0); - m_fm_occ = p.get_bool(":fm-occ", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_fm_real_only = p.get_bool("fm_real_only", true); + m_fm_limit = p.get_uint("fm_limit", 5000000); + m_fm_cutoff1 = p.get_uint("fm_cutoff1", 8); + m_fm_cutoff2 = p.get_uint("fm_cutoff2", 256); + m_fm_extra = p.get_uint("fm_extra", 0); + m_fm_occ = p.get_bool("fm_occ", false); } void set_cancel(bool f) { @@ -1668,12 +1668,12 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_produce_models(r); insert_max_memory(r); - r.insert(":fm-real-only", CPK_BOOL, "(default: true) consider only real variables for fourier-motzkin elimination."); - r.insert(":fm-occ", CPK_BOOL, "(default: false) consider inequalities occurring in clauses for FM."); - r.insert(":fm-limit", CPK_UINT, "(default: 5000000) maximum number of constraints, monomials, clauses visited during FM."); - r.insert(":fm-cutoff1", CPK_UINT, "(default: 8) first cutoff for FM based on maximum number of lower/upper occurrences."); - r.insert(":fm-cutoff2", CPK_UINT, "(default: 256) second cutoff for FM based on num_lower * num_upper occurrences."); - r.insert(":fm-extra", CPK_UINT, "(default: 0) max. increase on the number of inequalities for each FM variable elimination step."); + r.insert("fm_real_only", CPK_BOOL, "(default: true) consider only real variables for fourier-motzkin elimination."); + r.insert("fm_occ", CPK_BOOL, "(default: false) consider inequalities occurring in clauses for FM."); + r.insert("fm_limit", CPK_UINT, "(default: 5000000) maximum number of constraints, monomials, clauses visited during FM."); + r.insert("fm_cutoff1", CPK_UINT, "(default: 8) first cutoff for FM based on maximum number of lower/upper occurrences."); + r.insert("fm_cutoff2", CPK_UINT, "(default: 256) second cutoff for FM based on num_lower * num_upper occurrences."); + r.insert("fm_extra", CPK_UINT, "(default: 0) max. increase on the number of inequalities for each FM variable elimination step."); } virtual void set_cancel(bool f) { @@ -1707,9 +1707,9 @@ public: tactic * mk_fm_tactic(ast_manager & m, params_ref const & p) { params_ref s_p = p; - s_p.set_bool(":arith-lhs", true); - s_p.set_bool(":elim-and", true); - s_p.set_bool(":som", true); + s_p.set_bool("arith_lhs", true); + s_p.set_bool("elim_and", true); + s_p.set_bool("som", true); return and_then(using_params(mk_simplify_tactic(m, s_p), s_p), clean(alloc(fm_tactic, m, p))); } diff --git a/src/tactic/arith/lia2pb_tactic.cpp b/src/tactic/arith/lia2pb_tactic.cpp index 871614c1b..6fee55e4b 100644 --- a/src/tactic/arith/lia2pb_tactic.cpp +++ b/src/tactic/arith/lia2pb_tactic.cpp @@ -50,9 +50,9 @@ class lia2pb_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_partial_lia2pb = p.get_bool(":lia2pb-partial", false); - m_max_bits = p.get_uint(":lia2pb-max-bits", 32); - m_total_bits = p.get_uint(":lia2pb-total-bits", 2048); + m_partial_lia2pb = p.get_bool("lia2pb_partial", false); + m_max_bits = p.get_uint("lia2pb_max_bits", 32); + m_total_bits = p.get_uint("lia2pb_total_bits", 2048); } void updt_params(params_ref const & p) { @@ -325,9 +325,9 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":lia2pb-partial", CPK_BOOL, "(default: false) partial lia2pb conversion."); - r.insert(":lia2pb-max-bits", CPK_UINT, "(default: 32) maximum number of bits to be used (per variable) in lia2pb."); - r.insert(":lia2pb-total-bits", CPK_UINT, "(default: 2048) total number of bits to be used (per problem) in lia2pb."); + r.insert("lia2pb_partial", CPK_BOOL, "(default: false) partial lia2pb conversion."); + r.insert("lia2pb_max_bits", CPK_UINT, "(default: 32) maximum number of bits to be used (per variable) in lia2pb."); + r.insert("lia2pb_total_bits", CPK_UINT, "(default: 2048) total number of bits to be used (per problem) in lia2pb."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/arith/nla2bv_tactic.cpp b/src/tactic/arith/nla2bv_tactic.cpp index a9033bcd3..188ea7d70 100644 --- a/src/tactic/arith/nla2bv_tactic.cpp +++ b/src/tactic/arith/nla2bv_tactic.cpp @@ -68,7 +68,7 @@ class nla2bv_tactic : public tactic { m_is_sat_preserving(true), m_arith(m), m_bv(m), - m_bv2real(m, rational(p.get_uint(":nla2bv-root",2)), rational(p.get_uint(":nla2bv-divisor",2)), p.get_uint(":nla2bv-max-bv-size", UINT_MAX)), + m_bv2real(m, rational(p.get_uint("nla2bv_root",2)), rational(p.get_uint("nla2bv_divisor",2)), p.get_uint("nla2bv_max_bv_size", UINT_MAX)), m_bv2int_ctx(m, p), m_bounds(m), m_subst(m), @@ -76,7 +76,7 @@ class nla2bv_tactic : public tactic { m_defs(m), m_trail(m), m_fmc(0) { - m_default_bv_size = m_num_bits = p.get_uint(":nla2bv-bv-size", 4); + m_default_bv_size = m_num_bits = p.get_uint("nla2bv_bv_size", 4); } ~imp() {} @@ -436,10 +436,10 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":nla2bv-max-bv-size", CPK_UINT, "(default: inf) maximum bit-vector size used by nla2bv tactic"); - r.insert(":nla2bv-bv-size", CPK_UINT, "(default: 4) default bit-vector size used by nla2bv tactic."); - r.insert(":nla2bv-root", CPK_UINT, "(default: 2) nla2bv tactic encodes reals into bit-vectors using expressions of the form a+b*sqrt(c), this parameter sets the value of c used in the encoding."); - r.insert(":nla2bv-divisor", CPK_UINT, "(default: 2) nla2bv tactic parameter."); + r.insert("nla2bv_max_bv_size", CPK_UINT, "(default: inf) maximum bit-vector size used by nla2bv tactic"); + r.insert("nla2bv_bv_size", CPK_UINT, "(default: 4) default bit-vector size used by nla2bv tactic."); + r.insert("nla2bv_root", CPK_UINT, "(default: 2) nla2bv tactic encodes reals into bit-vectors using expressions of the form a+b*sqrt(c), this parameter sets the value of c used in the encoding."); + r.insert("nla2bv_divisor", CPK_UINT, "(default: 2) nla2bv tactic parameter."); } /** diff --git a/src/tactic/arith/normalize_bounds_tactic.cpp b/src/tactic/arith/normalize_bounds_tactic.cpp index f7aa968ef..a62b311b5 100644 --- a/src/tactic/arith/normalize_bounds_tactic.cpp +++ b/src/tactic/arith/normalize_bounds_tactic.cpp @@ -44,7 +44,7 @@ class normalize_bounds_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_normalize_int_only = p.get_bool(":norm-int-only", true); + m_normalize_int_only = p.get_bool("norm_int_only", true); } void updt_params(params_ref const & p) { @@ -173,7 +173,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_produce_models(r); - r.insert(":norm-int-only", CPK_BOOL, "(default: true) normalize only the bounds of integer constants."); + r.insert("norm_int_only", CPK_BOOL, "(default: true) normalize only the bounds of integer constants."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/arith/pb2bv_tactic.cpp b/src/tactic/arith/pb2bv_tactic.cpp index 36cc801dc..8790ca5a7 100644 --- a/src/tactic/arith/pb2bv_tactic.cpp +++ b/src/tactic/arith/pb2bv_tactic.cpp @@ -863,15 +863,15 @@ private: } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_all_clauses_limit = p.get_uint(":pb2bv-all-clauses-limit", 8); - m_cardinality_limit = p.get_uint(":pb2bv-cardinality-limit", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_all_clauses_limit = p.get_uint("pb2bv_all_clauses_limit", 8); + m_cardinality_limit = p.get_uint("pb2bv_cardinality_limit", UINT_MAX); } void collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":pb2bv-all-clauses-limit", CPK_UINT, "(default: 8) maximum number of literals for using equivalent CNF encoding of PB constraint."); - r.insert(":pb2bv-cardinality-limit", CPK_UINT, "(default: inf) limit for using arc-consistent cardinality constraint encoding."); + r.insert("pb2bv_all_clauses_limit", CPK_UINT, "(default: 8) maximum number of literals for using equivalent CNF encoding of PB constraint."); + r.insert("pb2bv_cardinality_limit", CPK_UINT, "(default: inf) limit for using arc-consistent cardinality constraint encoding."); } void set_cancel(bool f) { diff --git a/src/tactic/arith/purify_arith_tactic.cpp b/src/tactic/arith/purify_arith_tactic.cpp index 4bea07269..d6ed86c08 100644 --- a/src/tactic/arith/purify_arith_tactic.cpp +++ b/src/tactic/arith/purify_arith_tactic.cpp @@ -856,11 +856,11 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":complete", CPK_BOOL, + r.insert("complete", CPK_BOOL, "(default: true) add constraints to make sure that any interpretation of a underspecified arithmetic operators is a functio. The result will include additional uninterpreted functions/constants: /0, div0, mod0, 0^0, neg-root"); - r.insert(":elim-root-objects", CPK_BOOL, + r.insert("elim_root_objects", CPK_BOOL, "(default: true) eliminate root objects."); - r.insert(":elim-inverses", CPK_BOOL, + r.insert("elim_inverses", CPK_BOOL, "(default: true) eliminate inverse trigonometric functions (asin, acos, atan)."); th_rewriter::get_param_descrs(r); } @@ -876,9 +876,9 @@ public: tactic_report report("purify-arith", *g); bool produce_proofs = g->proofs_enabled(); bool produce_models = g->models_enabled(); - bool elim_root_objs = m_params.get_bool(":elim-root-objects", true); - bool elim_inverses = m_params.get_bool(":elim-inverses", true); - bool complete = m_params.get_bool(":complete", true); + bool elim_root_objs = m_params.get_bool("elim_root_objects", true); + bool elim_inverses = m_params.get_bool("elim_inverses", true); + bool complete = m_params.get_bool("complete", true); purify_arith_proc proc(m_util, m_aux_decls, produce_proofs, elim_root_objs, elim_inverses, complete); proc(*(g.get()), mc, produce_models); @@ -902,10 +902,10 @@ public: tactic * mk_purify_arith_tactic(ast_manager & m, params_ref const & p) { params_ref elim_rem_p = p; - elim_rem_p.set_bool(":elim-rem", true); + elim_rem_p.set_bool("elim-rem", true); params_ref skolemize_p; - skolemize_p.set_bool(":skolemize", false); + skolemize_p.set_bool("skolemize", false); return and_then(using_params(mk_snf_tactic(m, skolemize_p), skolemize_p), using_params(mk_simplify_tactic(m, elim_rem_p), elim_rem_p), diff --git a/src/tactic/arith/recover_01_tactic.cpp b/src/tactic/arith/recover_01_tactic.cpp index a42bedc44..3b1a86345 100644 --- a/src/tactic/arith/recover_01_tactic.cpp +++ b/src/tactic/arith/recover_01_tactic.cpp @@ -58,7 +58,7 @@ class recover_01_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_cls_max_size = p.get_uint(":recover-01-max-bits", 10); + m_cls_max_size = p.get_uint("recover_01_max_bits", 10); } void updt_params(params_ref const & p) { @@ -408,7 +408,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { th_rewriter::get_param_descrs(r); - r.insert(":recover-01-max-bits", CPK_UINT, "(default: 10) maximum number of bits to consider in a clause."); + r.insert("recover_01_max_bits", CPK_UINT, "(default: 10) maximum number of bits to consider in a clause."); } void operator()(goal_ref const & g, diff --git a/src/tactic/bv/bit_blaster_tactic.cpp b/src/tactic/bv/bit_blaster_tactic.cpp index 63d534cbb..0330141cb 100644 --- a/src/tactic/bv/bit_blaster_tactic.cpp +++ b/src/tactic/bv/bit_blaster_tactic.cpp @@ -36,7 +36,7 @@ class bit_blaster_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_blast_quant = p.get_bool(":blast-quant", false); + m_blast_quant = p.get_bool("blast_quant", false); } void updt_params(params_ref const & p) { @@ -120,10 +120,10 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":blast-mul", CPK_BOOL, "(default: true) bit-blast multipliers (and dividers, remainders)."); - r.insert(":blast-add", CPK_BOOL, "(default: true) bit-blast adders."); - r.insert(":blast-quant", CPK_BOOL, "(default: false) bit-blast quantified variables."); - r.insert(":blast-full", CPK_BOOL, "(default: false) bit-blast any term with bit-vector sort, this option will make E-matching ineffective in any pattern containing bit-vector terms."); + r.insert("blast_mul", CPK_BOOL, "(default: true) bit-blast multipliers (and dividers, remainders)."); + r.insert("blast_add", CPK_BOOL, "(default: true) bit-blast adders."); + r.insert("blast_quant", CPK_BOOL, "(default: false) bit-blast quantified variables."); + r.insert("blast_full", CPK_BOOL, "(default: false) bit-blast any term with bit-vector sort, this option will make E-matching ineffective in any pattern containing bit-vector terms."); } virtual void operator()(goal_ref const & g, diff --git a/src/tactic/bv/bv1_blaster_tactic.cpp b/src/tactic/bv/bv1_blaster_tactic.cpp index 77ab1be31..8dcaf2112 100644 --- a/src/tactic/bv/bv1_blaster_tactic.cpp +++ b/src/tactic/bv/bv1_blaster_tactic.cpp @@ -63,9 +63,9 @@ class bv1_blaster_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_produce_models = p.get_bool(":produce-models", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_produce_models = p.get_bool("produce_models", false); } bool rewrite_patterns() const { UNREACHABLE(); return false; } diff --git a/src/tactic/bv/max_bv_sharing_tactic.cpp b/src/tactic/bv/max_bv_sharing_tactic.cpp index 462c9f3e2..251e2b754 100644 --- a/src/tactic/bv/max_bv_sharing_tactic.cpp +++ b/src/tactic/bv/max_bv_sharing_tactic.cpp @@ -55,9 +55,9 @@ class max_bv_sharing_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_max_args = p.get_uint(":max-args", 128); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_max_args = p.get_uint("max_args", 128); } bool max_steps_exceeded(unsigned num_steps) const { @@ -298,7 +298,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-args", CPK_UINT, + r.insert("max_args", CPK_UINT, "(default: 128) maximum number of arguments (per application) that will be considered by the greedy (quadratic) heuristic."); } diff --git a/src/tactic/core/cofactor_elim_term_ite.cpp b/src/tactic/core/cofactor_elim_term_ite.cpp index b39d82201..78d532357 100644 --- a/src/tactic/core/cofactor_elim_term_ite.cpp +++ b/src/tactic/core/cofactor_elim_term_ite.cpp @@ -304,7 +304,7 @@ struct cofactor_elim_term_ite::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void set_cancel(bool f) { diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 91334fd5c..cca21b90e 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -90,10 +90,10 @@ struct ctx_simplify_tactic::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_max_depth = p.get_uint(":max-depth", 1024); - m_bail_on_blowup = p.get_bool(":bail-on-blowup", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_max_depth = p.get_uint("max_depth", 1024); + m_bail_on_blowup = p.get_bool("bail_on_blowup", false); } void checkpoint() { @@ -519,7 +519,7 @@ void ctx_simplify_tactic::updt_params(params_ref const & p) { void ctx_simplify_tactic::get_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-depth", CPK_UINT, "(default: 1024) maximum term depth."); + r.insert("max_depth", CPK_UINT, "(default: 1024) maximum term depth."); } void ctx_simplify_tactic::operator()(goal_ref const & in, diff --git a/src/tactic/core/elim_term_ite_tactic.cpp b/src/tactic/core/elim_term_ite_tactic.cpp index 4f04859ac..456bad5e0 100644 --- a/src/tactic/core/elim_term_ite_tactic.cpp +++ b/src/tactic/core/elim_term_ite_tactic.cpp @@ -72,7 +72,7 @@ class elim_term_ite_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } }; @@ -160,7 +160,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-args", CPK_UINT, + r.insert("max_args", CPK_UINT, "(default: 128) maximum number of arguments (per application) that will be considered by the greedy (quadratic) heuristic."); } diff --git a/src/tactic/core/elim_uncnstr_tactic.cpp b/src/tactic/core/elim_uncnstr_tactic.cpp index 7d15bc7c0..d1dca296a 100644 --- a/src/tactic/core/elim_uncnstr_tactic.cpp +++ b/src/tactic/core/elim_uncnstr_tactic.cpp @@ -881,8 +881,8 @@ class elim_uncnstr_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); } ast_manager & m() { return m_manager; } diff --git a/src/tactic/core/nnf_tactic.cpp b/src/tactic/core/nnf_tactic.cpp index 157c7078e..fdaf03d55 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -120,7 +120,7 @@ tactic * mk_snf_tactic(ast_manager & m, params_ref const & p) { tactic * mk_nnf_tactic(ast_manager & m, params_ref const & p) { params_ref new_p(p); - new_p.set_sym(":nnf-mode", symbol("full")); + new_p.set_sym("nnf_mode", symbol("full")); TRACE("nnf", tout << "mk_nnf: " << new_p << "\n";); return using_params(mk_snf_tactic(m, p), new_p); } diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 9ab597dfa..6d9e6ccbd 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -44,7 +44,7 @@ class propagate_values_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_max_rounds = p.get_uint(":max-rounds", 4); + m_max_rounds = p.get_uint("max_rounds", 4); } void updt_params(params_ref const & p) { @@ -237,7 +237,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { th_rewriter::get_param_descrs(r); - r.insert(":max-rounds", CPK_UINT, "(default: 2) maximum number of rounds."); + r.insert("max_rounds", CPK_UINT, "(default: 2) maximum number of rounds."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/core/simplify_tactic.cpp b/src/tactic/core/simplify_tactic.cpp index 0408f8c8d..95db962a7 100644 --- a/src/tactic/core/simplify_tactic.cpp +++ b/src/tactic/core/simplify_tactic.cpp @@ -138,7 +138,7 @@ tactic * mk_simplify_tactic(ast_manager & m, params_ref const & p) { tactic * mk_elim_and_tactic(ast_manager & m, params_ref const & p) { params_ref xp = p; - xp.set_bool(":elim-and", true); + xp.set_bool("elim_and", true); return using_params(mk_simplify_tactic(m, xp), xp); } diff --git a/src/tactic/core/solve_eqs_tactic.cpp b/src/tactic/core/solve_eqs_tactic.cpp index aa8fb03c2..995940406 100644 --- a/src/tactic/core/solve_eqs_tactic.cpp +++ b/src/tactic/core/solve_eqs_tactic.cpp @@ -71,9 +71,9 @@ class solve_eqs_tactic : public tactic { ast_manager & m() const { return m_manager; } void updt_params(params_ref const & p) { - m_ite_solver = p.get_bool(":ite-solver", true); - m_theory_solver = p.get_bool(":theory-solver", true); - m_max_occs = p.get_uint(":solve-eqs-max-occs", UINT_MAX); + m_ite_solver = p.get_bool("ite_solver", true); + m_theory_solver = p.get_bool("theory_solver", true); + m_max_occs = p.get_uint("solve_eqs_max_occs", UINT_MAX); } void set_cancel(bool f) { @@ -732,9 +732,9 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":solve-eqs-max-occs", CPK_UINT, "(default: infty) maximum number of occurrences for considering a variable for gaussian eliminations."); - r.insert(":theory-solver", CPK_BOOL, "(default: true) use theory solvers."); - r.insert(":ite-solver", CPK_BOOL, "(default: true) use if-then-else solver."); + r.insert("solve_eqs_max_occs", CPK_UINT, "(default: infty) maximum number of occurrences for considering a variable for gaussian eliminations."); + r.insert("theory_solver", CPK_BOOL, "(default: true) use theory solvers."); + r.insert("ite_solver", CPK_BOOL, "(default: true) use if-then-else solver."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/core/split_clause_tactic.cpp b/src/tactic/core/split_clause_tactic.cpp index f259ca8ad..5699aa178 100644 --- a/src/tactic/core/split_clause_tactic.cpp +++ b/src/tactic/core/split_clause_tactic.cpp @@ -96,11 +96,11 @@ public: } virtual void updt_params(params_ref const & p) { - m_largest_clause = p.get_bool(":split-largest-clause", false); + m_largest_clause = p.get_bool("split_largest_clause", false); } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":split-largest-clause", CPK_BOOL, "(default: false) split the largest clause in the goal."); + r.insert("split_largest_clause", CPK_BOOL, "(default: false) split the largest clause in the goal."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/core/tseitin_cnf_tactic.cpp b/src/tactic/core/tseitin_cnf_tactic.cpp index 2a4f3df2e..b6c4b0655 100644 --- a/src/tactic/core/tseitin_cnf_tactic.cpp +++ b/src/tactic/core/tseitin_cnf_tactic.cpp @@ -122,12 +122,12 @@ class tseitin_cnf_tactic : public tactic { } void updt_params(params_ref const & p) { - m_common_patterns = p.get_bool(":common-patterns", true); - m_distributivity = p.get_bool(":distributivity", true); - m_distributivity_blowup = p.get_uint(":distributivity-blowup", 32); - m_ite_chains = p.get_bool(":ite-chains", true); - m_ite_extra = p.get_bool(":ite-extra", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_common_patterns = p.get_bool("common_patterns", true); + m_distributivity = p.get_bool("distributivity", true); + m_distributivity_blowup = p.get_uint("distributivity_blowup", 32); + m_ite_chains = p.get_bool("ite_chains", true); + m_ite_extra = p.get_bool("ite_extra", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void push_frame(app * n) { m_frame_stack.push_back(frame(n)); } @@ -881,11 +881,11 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":common-patterns", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing commonly used patterns"); - r.insert(":distributivity", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by applying distributivity over unshared subformulas"); - r.insert(":distributivity-blowup", CPK_UINT, "(default: 32) maximum overhead for applying distributivity during CNF encoding"); - r.insert("ite-chaing", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing if-then-else chains"); - r.insert(":ite-extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); + r.insert("common_patterns", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing commonly used patterns"); + r.insert("distributivity", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by applying distributivity over unshared subformulas"); + r.insert("distributivity_blowup", CPK_UINT, "(default: 32) maximum overhead for applying distributivity during CNF encoding"); + r.insert("ite_chaing", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing if-then-else chains"); + r.insert("ite_extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); } virtual void operator()(goal_ref const & in, @@ -934,8 +934,8 @@ tactic * mk_tseitin_cnf_core_tactic(ast_manager & m, params_ref const & p) { tactic * mk_tseitin_cnf_tactic(ast_manager & m, params_ref const & p) { params_ref simp_p = p; - simp_p.set_bool(":elim-and", true); - simp_p.set_bool(":blast-distinct", true); + simp_p.set_bool("elim_and", true); + simp_p.set_bool("blast_distinct", true); return or_else(mk_tseitin_cnf_core_tactic(m, p), and_then(using_params(mk_simplify_tactic(m, p), simp_p), mk_tseitin_cnf_core_tactic(m, p))); diff --git a/src/tactic/fpa/fpa2bv_rewriter.h b/src/tactic/fpa/fpa2bv_rewriter.h index 62c6f1a2d..02a667f18 100644 --- a/src/tactic/fpa/fpa2bv_rewriter.h +++ b/src/tactic/fpa/fpa2bv_rewriter.h @@ -54,8 +54,8 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); } bool max_steps_exceeded(unsigned num_steps) const { diff --git a/src/tactic/fpa/qffpa_tactic.cpp b/src/tactic/fpa/qffpa_tactic.cpp index d034000c4..f3c913ccc 100644 --- a/src/tactic/fpa/qffpa_tactic.cpp +++ b/src/tactic/fpa/qffpa_tactic.cpp @@ -26,7 +26,7 @@ Notes: tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p) { params_ref sat_simp_p = p; - sat_simp_p .set_bool(":elim-and", true); + sat_simp_p .set_bool("elim_and", true); return and_then(mk_simplify_tactic(m, p), mk_fpa2bv_tactic(m, p), diff --git a/src/tactic/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index 0ad845095..290a0ad35 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -1363,16 +1363,16 @@ class sls_tactic : public tactic { static void collect_param_descrs(param_descrs & r) { insert_produce_models(r); - r.insert(":sls-restarts", CPK_UINT, "(default: infty) # of SLS restarts."); - r.insert(":random-seed", CPK_UINT, "(default: 0) random seed."); - r.insert(":plateau-limit", CPK_UINT, "(default: 100) SLS plateau limit."); + r.insert("sls_restarts", CPK_UINT, "(default: infty) # of SLS restarts."); + r.insert("random_seed", CPK_UINT, "(default: 0) random seed."); + r.insert("plateau_limit", CPK_UINT, "(default: 100) SLS plateau limit."); } void updt_params(params_ref const & p) { - m_produce_models = p.get_bool(":produce-models", false); - m_max_restarts = p.get_uint(":sls-restarts", -1); - m_tracker.set_random_seed(p.get_uint(":random-seed", 0)); - m_plateau_limit = p.get_uint(":plateau-limit", 100); + m_produce_models = p.get_bool("produce_models", false); + m_max_restarts = p.get_uint("sls_restarts", -1); + m_tracker.set_random_seed(p.get_uint("random_seed", 0)); + m_plateau_limit = p.get_uint("plateau_limit", 100); } void checkpoint() { @@ -1854,28 +1854,28 @@ tactic * mk_sls_tactic(ast_manager & m, params_ref const & p) { tactic * mk_preamble(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - // main_p.set_bool(":pull-cheap-ite", true); - main_p.set_bool(":push-ite-bv", true); - main_p.set_bool(":blast-distinct", true); - // main_p.set_bool(":udiv2mul", true); - main_p.set_bool(":hi-div0", true); + main_p.set_bool("elim_and", true); + // main_p.set_bool("pull-cheap_ite", true); + main_p.set_bool("push_ite_bv", true); + main_p.set_bool("blast_distinct", true); + // main_p.set_bool("udiv2mul", true); + main_p.set_bool("hi_div0", true); params_ref simp2_p = p; - simp2_p.set_bool(":som", true); - simp2_p.set_bool(":pull-cheap-ite", true); - simp2_p.set_bool(":push-ite-bv", false); - simp2_p.set_bool(":local-ctx", true); - simp2_p.set_uint(":local-ctx-limit", 10000000); + simp2_p.set_bool("som", true); + simp2_p.set_bool("pull_cheap_ite", true); + simp2_p.set_bool("push_ite_bv", false); + simp2_p.set_bool("local_ctx", true); + simp2_p.set_uint("local_ctx_limit", 10000000); params_ref hoist_p; - hoist_p.set_bool(":hoist-mul", true); - // hoist_p.set_bool(":hoist-cmul", true); - hoist_p.set_bool(":som", false); + hoist_p.set_bool("hoist_mul", true); + // hoist_p.set_bool("hoist_cmul", true); + hoist_p.set_bool("som", false); params_ref gaussian_p; // conservative gaussian elimination. - gaussian_p.set_uint(":gaussian-max-occs", 2); + gaussian_p.set_uint("gaussian_max_occs", 2); return and_then(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -1890,8 +1890,8 @@ tactic * mk_preamble(ast_manager & m, params_ref const & p) { tactic * mk_qfbv_sls_tactic(ast_manager & m, params_ref const & p) { params_ref sls_p(p); - sls_p.set_uint(":sls-restarts", 10000); - sls_p.set_uint(":plateau-limit", 100); + sls_p.set_uint("sls_restarts", 10000); + sls_p.set_uint("plateau_limit", 100); tactic * t = and_then(mk_preamble(m, p), using_params(mk_sls_tactic(m, p), sls_p)); diff --git a/src/tactic/smtlogics/qfnra_tactic.cpp b/src/tactic/smtlogics/qfnra_tactic.cpp index d13d9e198..a2877eefa 100644 --- a/src/tactic/smtlogics/qfnra_tactic.cpp +++ b/src/tactic/smtlogics/qfnra_tactic.cpp @@ -25,7 +25,7 @@ Notes: static tactic * mk_qfnra_sat_solver(ast_manager& m, params_ref const& p, unsigned bv_size) { params_ref nra2sat_p = p; - nra2sat_p.set_uint(":nla2bv-max-bv-size", p.get_uint(":nla2bv-max-bv-size", bv_size)); + nra2sat_p.set_uint(":nla2bv-max-bv-size", p.get_uint("nla2bv_max_bv_size", bv_size)); return and_then(mk_nla2bv_tactic(m, nra2sat_p), mk_smt_tactic(), diff --git a/src/tactic/smtlogics/quant_tactics.cpp b/src/tactic/smtlogics/quant_tactics.cpp index 157202442..4bb896c74 100644 --- a/src/tactic/smtlogics/quant_tactics.cpp +++ b/src/tactic/smtlogics/quant_tactics.cpp @@ -72,7 +72,7 @@ tactic * mk_uflra_tactic(ast_manager & m, params_ref const & p) { tactic * mk_auflia_tactic(ast_manager & m, params_ref const & p) { params_ref qi_p; qi_p.set_str(":qi-cost", "0"); - TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str(":qi-cost", "") << "\n";); + TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str("qi_cost", "") << "\n";); tactic * st = and_then(mk_no_solve_eq_preprocessor(m), or_else(and_then(fail_if(mk_gt(mk_num_exprs_probe(), mk_const_probe(static_cast(128)))), using_params(mk_smt_tactic(), qi_p), diff --git a/src/tactic/ufbv/macro_finder_tactic.cpp b/src/tactic/ufbv/macro_finder_tactic.cpp index 3872a3a2e..14a42ec51 100644 --- a/src/tactic/ufbv/macro_finder_tactic.cpp +++ b/src/tactic/ufbv/macro_finder_tactic.cpp @@ -102,7 +102,7 @@ class macro_finder_tactic : public tactic { } void updt_params(params_ref const & p) { - m_elim_and = p.get_bool(":elim-and", false); + m_elim_and = p.get_bool("elim_and", false); } }; @@ -131,7 +131,7 @@ public: insert_max_memory(r); insert_produce_models(r); insert_produce_proofs(r); - r.insert(":elim-and", CPK_BOOL, "(default: false) eliminate conjunctions during (internal) calls to the simplifier."); + r.insert("elim_and", CPK_BOOL, "(default: false) eliminate conjunctions during (internal) calls to the simplifier."); } virtual void operator()(goal_ref const & in, diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index 2711f3e00..ac895dacf 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -128,7 +128,7 @@ namespace datalog { dl_decl_util dl_util(m); relation_manager & rmgr = ctx.get_rmanager(); - relation_plugin & rel_plugin = *ctx.get_rmanager().get_relation_plugin(params.get_sym(":default-relation", symbol("sparse"))); + relation_plugin & rel_plugin = *ctx.get_rmanager().get_relation_plugin(params.get_sym("default_relation", symbol("sparse"))); SASSERT(&rel_plugin); finite_product_relation_plugin plg(rel_plugin, rmgr); diff --git a/src/util/double_manager.h b/src/util/double_manager.h index a6a72cc6f..5334e60df 100644 --- a/src/util/double_manager.h +++ b/src/util/double_manager.h @@ -40,7 +40,7 @@ public: double_manager(params_ref const & p = params_ref()) { updt_params(p); } void updt_params(params_ref const & p) { - m_zero_tolerance = p.get_double(":zero-tolerance", 0.00000001); + m_zero_tolerance = p.get_double("zero_tolerance", 0.00000001); } static void reset(double & a) { a = 0.0; } diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp new file mode 100644 index 000000000..556e84734 --- /dev/null +++ b/src/util/gparams.cpp @@ -0,0 +1,249 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + gparams.cpp + +Abstract: + + Global parameter management. + +Author: + + Leonardo (leonardo) 2012-11-29 + +Notes: + +--*/ +#include"gparams.h" +#include"dictionary.h" + +extern void gparams_register_modules(); + +struct gparams::imp { + dictionary m_module_param_descrs; + param_descrs m_param_descrs; + dictionary m_module_params; + params_ref m_params; + params_ref m_empty; +public: + imp() { + } + + ~imp() { + { + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + dealloc(it->m_value); + } + } + { + dictionary::iterator it = m_module_params.begin(); + dictionary::iterator end = m_module_params.end(); + for (; it != end; ++it) { + dealloc(it->m_value); + } + } + } + + void register_global(param_descrs & d) { + m_param_descrs.copy(d); + } + + void register_module(char const * module_name, param_descrs * d) { + symbol s(module_name); + param_descrs * old_d; + if (m_module_param_descrs.find(s, old_d)) { + old_d->copy(*d); + dealloc(d); + } + else { + m_module_param_descrs.insert(s, d); + } + } + + void display(std::ostream & out, unsigned indent, bool smt2_style) { + m_param_descrs.display(out, indent, smt2_style); + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key << "\n"; + it->m_value->display(out, indent + 4, smt2_style); + } + } + + void normalize(char const * name, /* out */ symbol & mod_name, /* out */ symbol & param_name) { + if (*name == ':') + name++; + std::string tmp = name; + unsigned n = tmp.size(); + for (unsigned i = 0; i < n; i++) { + if (tmp[i] >= 'A' && tmp[i] <= 'Z') + tmp[i] = tmp[i] - 'A' + 'a'; + else if (tmp[i] == '-') + tmp[i] = '_'; + } + for (unsigned i = 0; i < n; i++) { + if (tmp[i] == '.') { + param_name = tmp.substr(i+1).c_str(); + tmp.resize(i); + mod_name = tmp.c_str(); + return; + } + } + param_name = tmp.c_str(); + mod_name = symbol::null; + } + + params_ref & get_params(symbol const & mod_name) { + if (mod_name == symbol::null) { + return m_params; + } + else { + params_ref * p; + if (m_module_params.find(mod_name, p)) { + return *p; + } + else { + p = alloc(params_ref); + m_module_params.insert(mod_name, p); + return *p; + } + } + } + + void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) { + param_kind k = d.get_kind(param_name); + params_ref & ps = get_params(mod_name); + if (k == CPK_INVALID) { + if (mod_name == symbol::null) + throw default_exception("unknown parameter '%s'", param_name.bare_str()); + else + throw default_exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + else if (k == CPK_UINT) { + long val = strtol(value, 0, 10); + ps.set_uint(param_name, static_cast(val)); + } + else if (k == CPK_BOOL) { + if (strcmp(value, "true") == 0) { + ps.set_bool(param_name, true); + } + else if (strcmp(value, "false") == 0) { + ps.set_bool(param_name, false); + } + else { + if (mod_name == symbol::null) + throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); + else + throw default_exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); + } + } + else if (k == CPK_SYMBOL) { + ps.set_sym(param_name, symbol(value)); + } + else if (k == CPK_STRING) { + ps.set_str(param_name, value); + } + else { + if (mod_name == symbol::null) + throw default_exception("unsupported parameter type '%s'", param_name.bare_str()); + else + throw default_exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + } + + void set(char const * name, char const * value) { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + set(m_param_descrs, p, value, m); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + set(*d, p, value, m); + } + else { + throw default_exception("invalid parameter, unknown module '%s'", m.bare_str()); + } + } + } + + std::string get_value(char const * name) { + + } + + + params_ref const & get_module(symbol const & module_name) { + params_ref * ps = 0; + if (m_module_params.find(module_name, ps)) { + return *ps; + } + else { + return m_empty; + } + } + + params_ref const & get() { + return m_params; + } + +}; + +gparams::imp * gparams::g_imp = 0; + +void gparams::set(char const * name, char const * value) { + SASSERT(g_imp != 0); + g_imp->set(name, value); +} + +std::string gparams::get_value(char const * name) { + SASSERT(g_imp != 0); + g_imp->get_value(name); +} + +void gparams::register_global(param_descrs & d) { + SASSERT(g_imp != 0); + g_imp->register_global(d); +} + +void gparams::register_module(char const * module_name, param_descrs * d) { + SASSERT(g_imp != 0); + g_imp->register_module(module_name, d); +} + +params_ref const & gparams::get_module(char const * module_name) { + return get_module(symbol(module_name)); +} + +params_ref const & gparams::get_module(symbol const & module_name) { + SASSERT(g_imp != 0); + return g_imp->get_module(module_name); +} + +params_ref const & gparams::get() { + SASSERT(g_imp != 0); + return g_imp->get(); +} + +void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) { + SASSERT(g_imp != 0); + g_imp->display(out, indent, smt2_style); +} + +void gparams::init() { + g_imp = alloc(imp); + gparams_register_modules(); +} + +void gparams::finalize() { + if (g_imp != 0) { + dealloc(g_imp); + g_imp = 0; + } +} + + diff --git a/src/util/gparams.h b/src/util/gparams.h new file mode 100644 index 000000000..e02a8daa8 --- /dev/null +++ b/src/util/gparams.h @@ -0,0 +1,122 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + gparams.h + +Abstract: + + Global parameter management. + +Author: + + Leonardo (leonardo) 2012-11-29 + +Notes: + +--*/ +#ifndef _GPARAMS_H_ +#define _GPARAMS_H_ + +#include"params.h" + +class gparams { + struct imp; + static imp * g_imp; + typedef z3_exception exception; +public: + /** + \brief Set a global parameter \c name with \c value. + + The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. + The character '.' is used a delimiter (more later). + + The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. + Thus, the following parameter names are considered equivalent: "auto-config" and "AUTO_CONFIG". + + This function can be used to set parameters for a specific Z3 module. + This can be done by using .. + For example: + set_global_param('pp.decimal', 'true') + will set the parameter "decimal" in the module "pp" to true. + + An exception is thrown if the the parameter name is unknown, or if the value is incorrect. + */ + static void set(char const * name, char const * value); + + /** + \brief Auxiliary method used to implement get-option in SMT 2.0 front-end. + + If the parameter is not set, then it just returns 'default'. + + An exception is thrown if the the parameter name is unknown. + */ + static std::string get_value(char const * name); + + /** + \brief Register additional global parameters + + This is an auxiliary function used by our automatic code generator. + Example: the directive REG_PARAMS('collect_param_descrs') + "tells" the automatic code generator how to register the additional global parameters. + */ + static void register_global(param_descrs & d); + + /** + \brief Register parameter descriptions for a Z3 module. + The parameters of a given Z3 module can only be set using #set_global_param if + they are registered in this module using this function. + + This is an auxiliary function used by our automatic code generator. + Each module will contain directives (in comments) such as + Example: the directive REG_MODULE_PARAMS('nlsat', 'nlsat::solver::collect_param_descrs') + "tells" the automatic code generator how to register the parameters for the given + module. + */ + static void register_module(char const * module_name, param_descrs * d); + + /** + \brief Retrieves the parameters associated with the given module. + + Example: + // The following command sets the parameter "decimal" in the module "pp" to true. + set_global_param("pp.decimal", "true"); + ... + // The following command will return the global parameters that were set for the module "pp". + // In this example "p" will contain "decimal" -> true after executing this function. + params_ref const & p = get_module_params("pp") + */ + static params_ref const & get_module(char const * module_name); + static params_ref const & get_module(symbol const & module_name); + + /** + \brief Return the global parameter set (i.e., parameters that are not associated with any particular module). + */ + static params_ref const & get(); + + /** + \brief Dump information about available parameters in the given output stream. + */ + static void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false); + + /** + \brief Initialize the global parameter management module. + + Remark: I set a priority in the initialization, because this module must be initialized + after the core modules such as symbol. + ADD_INITIALIZER('gparams::init();', 1) + */ + static void init(); + + /** + \brief Finalize the global parameter management module. + + ADD_FINALIZER('gparams::finalize();'); + */ + static void finalize(); +}; + + + +#endif diff --git a/src/util/params.cpp b/src/util/params.cpp index ae7f0c830..b143a82dd 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -60,7 +60,7 @@ struct param_descrs::imp { bool operator()(symbol const & s1, symbol const & s2) const { return strcmp(s1.bare_str(), s2.bare_str()) < 0; } }; - void display(std::ostream & out, unsigned indent) const { + void display(std::ostream & out, unsigned indent, bool smt2_style) const { svector names; dictionary::iterator it = m_info.begin(); dictionary::iterator end = m_info.end(); @@ -72,7 +72,20 @@ struct param_descrs::imp { svector::iterator end2 = names.end(); for (; it2 != end2; ++it2) { for (unsigned i = 0; i < indent; i++) out << " "; - out << *it2; + if (smt2_style) + out << ':'; + char const * s = it2->bare_str(); + unsigned n = strlen(s); + for (unsigned i = 0; i < n; i++) { + if (smt2_style && s[i] == '_') + out << '-'; + else if (!smt2_style && s[i] == '-') + out << '_'; + else if (s[i] >= 'A' && s[i] <= 'Z') + out << (s[i] - 'A' + 'a'); + else + out << s[i]; + } info d; d.second = 0; m_info.find(*it2, d); @@ -80,6 +93,15 @@ struct param_descrs::imp { out << " (" << d.first << ") " << d.second << "\n"; } } + + void copy(param_descrs & other) { + dictionary::iterator it = other.m_imp->m_info.begin(); + dictionary::iterator end = other.m_imp->m_info.end(); + for (; it != end; ++it) { + insert(it->m_key, it->m_value.first, it->m_value.second); + } + } + }; param_descrs::param_descrs() { @@ -90,6 +112,10 @@ param_descrs::~param_descrs() { dealloc(m_imp); } +void param_descrs::copy(param_descrs & other) { + m_imp->copy(other); +} + void param_descrs::insert(symbol const & name, param_kind k, char const * descr) { m_imp->insert(name, k, descr); } @@ -122,28 +148,28 @@ symbol param_descrs::get_param_name(unsigned i) const { return m_imp->get_param_name(i); } -void param_descrs::display(std::ostream & out, unsigned indent) const { - return m_imp->display(out, indent); +void param_descrs::display(std::ostream & out, unsigned indent, bool smt2_style) const { + return m_imp->display(out, indent, smt2_style); } void insert_max_memory(param_descrs & r) { - r.insert(":max-memory", CPK_UINT, "(default: infty) maximum amount of memory in megabytes."); + r.insert("max_memory", CPK_UINT, "(default: infty) maximum amount of memory in megabytes."); } void insert_max_steps(param_descrs & r) { - r.insert(":max-steps", CPK_UINT, "(default: infty) maximum number of steps."); + r.insert("max_steps", CPK_UINT, "(default: infty) maximum number of steps."); } void insert_produce_models(param_descrs & r) { - r.insert(":produce-models", CPK_BOOL, "(default: false) model generation."); + r.insert("produce_models", CPK_BOOL, "(default: false) model generation."); } void insert_produce_proofs(param_descrs & r) { - r.insert(":produce-proofs", CPK_BOOL, "(default: false) proof generation."); + r.insert("produce_proofs", CPK_BOOL, "(default: false) proof generation."); } void insert_timeout(param_descrs & r) { - r.insert(":timeout", CPK_UINT, "(default: infty) timeout in milliseconds."); + r.insert("timeout", CPK_UINT, "(default: infty) timeout in milliseconds."); } class params { @@ -255,6 +281,39 @@ public: } out << ")"; } + + void display(std::ostream & out, symbol const & k) const { + svector::const_iterator it = m_entries.begin(); + svector::const_iterator end = m_entries.end(); + for (; it != end; ++it) { + if (it->first != k) + continue; + switch (it->second.m_kind) { + case CPK_BOOL: + out << it->second.m_bool_value; + return; + case CPK_UINT: + out << it->second.m_uint_value; + return; + case CPK_DOUBLE: + out << it->second.m_double_value; + return; + case CPK_NUMERAL: + out << *(it->second.m_rat_value); + return; + case CPK_SYMBOL: + out << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value); + return; + case CPK_STRING: + out << it->second.m_str_value; + return; + default: + out << "internal"; + return; + } + } + out << "default"; + } }; params_ref::~params_ref() { @@ -274,6 +333,17 @@ void params_ref::display(std::ostream & out) const { out << "(params)"; } +void params_ref::display(std::ostream & out, char const * k) const { + display(out, symbol(k)); +} + +void params_ref::display(std::ostream & out, symbol const & k) const { + if (m_params) + m_params->display(out, k); + else + out << "default"; +} + void params_ref::validate(param_descrs const & p) const { if (m_params) m_params->validate(p); diff --git a/src/util/params.h b/src/util/params.h index 66c4e7c7a..f587ed862 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -79,6 +79,14 @@ public: void display(std::ostream & out) const; void validate(param_descrs const & p) const; + + /* + \brief Display the value of the given parameter. + + It displays 'default' if k is not in the parameter set. + */ + void display(std::ostream & out, char const * k); + void display(std::ostream & out, symbol const & k); }; inline std::ostream & operator<<(std::ostream & out, params_ref const & ref) { @@ -92,13 +100,14 @@ class param_descrs { public: param_descrs(); ~param_descrs(); + void copy(param_descrs & other); void insert(char const * name, param_kind k, char const * descr); void insert(symbol const & name, param_kind k, char const * descr); void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; param_kind get_kind(symbol const & name) const; - void display(std::ostream & out, unsigned indent = 0) const; + void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false) const; unsigned size() const; symbol get_param_name(unsigned idx) const; }; From 722cce0cff4b27ef7e4319fd5216a4715ac9bd56 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 17:52:07 -0800 Subject: [PATCH 051/133] checkpoint Signed-off-by: Leonardo de Moura --- src/util/gparams.cpp | 15 +++++++++++++-- src/util/gparams.h | 5 ++++- src/util/params.h | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 556e84734..27fdd828b 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -173,7 +173,8 @@ public: } std::string get_value(char const * name) { - + // TODO + return ""; } @@ -200,9 +201,19 @@ void gparams::set(char const * name, char const * value) { g_imp->set(name, value); } +void gparams::set(symbol const & name, char const * value) { + SASSERT(g_imp != 0); + g_imp->set(name.bare_str(), value); +} + std::string gparams::get_value(char const * name) { SASSERT(g_imp != 0); - g_imp->get_value(name); + return g_imp->get_value(name); +} + +std::string gparams::get_value(symbol const & name) { + SASSERT(g_imp != 0); + return g_imp->get_value(name.bare_str()); } void gparams::register_global(param_descrs & d) { diff --git a/src/util/gparams.h b/src/util/gparams.h index e02a8daa8..7112e67f9 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -24,8 +24,9 @@ Notes: class gparams { struct imp; static imp * g_imp; - typedef z3_exception exception; public: + typedef default_exception exception; + /** \brief Set a global parameter \c name with \c value. @@ -44,6 +45,7 @@ public: An exception is thrown if the the parameter name is unknown, or if the value is incorrect. */ static void set(char const * name, char const * value); + static void set(symbol const & name, char const * value); /** \brief Auxiliary method used to implement get-option in SMT 2.0 front-end. @@ -53,6 +55,7 @@ public: An exception is thrown if the the parameter name is unknown. */ static std::string get_value(char const * name); + static std::string get_value(symbol const & name); /** \brief Register additional global parameters diff --git a/src/util/params.h b/src/util/params.h index f587ed862..616f316bd 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -85,8 +85,8 @@ public: It displays 'default' if k is not in the parameter set. */ - void display(std::ostream & out, char const * k); - void display(std::ostream & out, symbol const & k); + void display(std::ostream & out, char const * k) const; + void display(std::ostream & out, symbol const & k) const; }; inline std::ostream & operator<<(std::ostream & out, params_ref const & ref) { From 654c02701c73c05ba8d7b561a9aed3013703a9ad Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 29 Nov 2012 19:17:01 -0800 Subject: [PATCH 052/133] pretty print rules with quoted symbols Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 26 ++++++++++++++++++++- src/muz_qe/dl_mk_interp_tail_simplifier.cpp | 5 ++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 14de8550e..3818b1955 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -1626,6 +1626,23 @@ namespace datalog { void context::get_rules_as_formulas(expr_ref_vector& rules, svector& names) { expr_ref fml(m); + datalog::rule_manager& rm = get_rule_manager(); + datalog::rule_ref_vector rule_refs(rm); + + // ensure that rules are all using bound variables. + for (unsigned i = 0; i < m_rule_fmls.size(); ++i) { + ptr_vector sorts; + get_free_vars(m_rule_fmls[i].get(), sorts); + if (!sorts.empty()) { + rm.mk_rule(m_rule_fmls[i].get(), rule_refs, m_rule_names[i]); + m_rule_fmls[i] = m_rule_fmls.back(); + m_rule_names[i] = m_rule_names.back(); + m_rule_fmls.pop_back(); + m_rule_names.pop_back(); + --i; + } + } + add_rules(rule_refs); rule_set::iterator it = m_rule_set.begin(), end = m_rule_set.end(); for (; it != end; ++it) { (*it)->to_formula(fml); @@ -1732,13 +1749,20 @@ namespace datalog { } PP(r); if (symbol::null != nm) { + out << " :named "; while (fresh_names.contains(nm)) { std::ostringstream s; s << nm << "!"; nm = symbol(s.str().c_str()); } fresh_names.add(nm); - out << " :named " << nm << ")"; + if (is_smt2_quoted_symbol(nm)) { + out << mk_smt2_quoted_symbol(nm); + } + else { + out << nm; + } + out << ")"; } out << ")\n"; } diff --git a/src/muz_qe/dl_mk_interp_tail_simplifier.cpp b/src/muz_qe/dl_mk_interp_tail_simplifier.cpp index 74ab001b4..aa11d1b36 100644 --- a/src/muz_qe/dl_mk_interp_tail_simplifier.cpp +++ b/src/muz_qe/dl_mk_interp_tail_simplifier.cpp @@ -461,6 +461,11 @@ namespace datalog { { rule_ref r(r0, m_context.get_rule_manager()); + if (r->has_quantifiers()) { + res = r; + return false; + } + start: unsigned u_len = r->get_uninterpreted_tail_size(); unsigned len = r->get_tail_size(); From 0c1f2a82818a29ea4f8d4f1605fa29e10a3ad89e Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 15:39:25 +0000 Subject: [PATCH 053/133] Java API: Added exception wrappers and build dependencies. Signed-off-by: Christoph M. Wintersteiger --- examples/java/JavaExample.java | 4 +- scripts/mk_util.py | 21 +- scripts/update_api.py | 55 +- src/api/java/AST.java | 390 +- src/api/java/ASTDecRefQueue.java | 28 +- src/api/java/ASTMap.java | 184 +- src/api/java/ASTVector.java | 163 +- src/api/java/ApplyResult.java | 115 +- src/api/java/ApplyResultDecRefQueue.java | 28 +- src/api/java/AstMapDecRefQueue.java | 28 +- src/api/java/AstVectorDecRefQueue.java | 28 +- src/api/java/BitVecNum.java | 90 +- src/api/java/BitVecSort.java | 2 +- src/api/java/Constructor.java | 2 +- src/api/java/ConstructorList.java | 2 +- src/api/java/Context.java | 6218 +++++++++--------- src/api/java/DatatypeSort.java | 2 +- src/api/java/FiniteDomainSort.java | 2 +- src/api/java/Fixedpoint.java | 550 +- src/api/java/FixedpointDecRefQueue.java | 28 +- src/api/java/FuncDecl.java | 666 +- src/api/java/FuncInterp.java | 6 +- src/api/java/FuncInterpDecRefQueue.java | 28 +- src/api/java/FuncInterpEntryDecRefQueue.java | 28 +- src/api/java/Goal.java | 371 +- src/api/java/GoalDecRefQueue.java | 28 +- src/api/java/IntNum.java | 82 +- src/api/java/Model.java | 39 +- src/api/java/ModelDecRefQueue.java | 16 +- src/api/java/ParamDescrs.java | 14 +- src/api/java/ParamDescrsDecRefQueue.java | 16 +- src/api/java/Params.java | 8 +- src/api/java/ParamsDecRefQueue.java | 16 +- src/api/java/Pattern.java | 10 +- src/api/java/ProbeDecRefQueue.java | 16 +- src/api/java/Quantifier.java | 12 +- src/api/java/RatNum.java | 9 +- src/api/java/RelationSort.java | 2 +- src/api/java/Solver.java | 64 +- src/api/java/SolverDecRefQueue.java | 16 +- src/api/java/Sort.java | 10 +- src/api/java/Statistics.java | 21 +- src/api/java/StatisticsDecRefQueue.java | 18 +- src/api/java/Symbol.java | 6 +- src/api/java/Tactic.java | 2 +- src/api/java/TacticDecRefQueue.java | 16 +- src/api/java/TupleSort.java | 2 +- 47 files changed, 4908 insertions(+), 4554 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index d96553c19..5d56a474b 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -159,7 +159,7 @@ class JavaExample Sort t = f.Range(); Sort[] dom = f.Domain(); - if (dom.length != 2 || !t.Equals(dom[0]) || !t.Equals(dom[1])) + if (dom.length != 2 || !t.equals(dom[0]) || !t.equals(dom[1])) { System.out.println(Integer.toString(dom.length) + " " + dom[0].toString() + " " + dom[1].toString() + " " @@ -700,7 +700,7 @@ class JavaExample System.out.println(q2); } - System.out.println(q1.Equals(q2)); + System.out.println(q1.equals(q2)); } // / Prove that f(x, y) = f(w, v) implies y = v when diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 5edace6cb..d96c4a0ec 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -990,10 +990,13 @@ class JavaDLLComponent(Component): else: out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(SO_EXT)\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) + deps = '' + for jfile in get_java_files(self.src_dir): + deps += ('%s/%s ' % (self.to_src_dir, jfile)) + for jfile in get_java_files((self.src_dir + "/enumerations")): + deps += ('%s/enumerations/%s ' % (self.to_src_dir, jfile)) + if IS_WINDOWS: deps = deps.replace('/', '\\') + out.write(deps) out.write('\n') t = ('\t%s %s/enumerations/*.java -d api/java/classes\n' % (JAVAC, self.to_src_dir)) if IS_WINDOWS: t = t.replace('/','\\') @@ -1103,10 +1106,12 @@ class JavaExampleComponent(ExampleComponent): if JAVA_ENABLED: pkg = get_component(JAVA_COMPONENT).package_name + '.jar' out.write('_ex_%s: %s' % (self.name, pkg)) - # for javafile in get_java_files(self.ex_dir): - # out.write(' ') - # out.write('%s/%s' % (self.to_ex_dir, javafile)) - out.write('\n') + deps = '' + for jfile in get_java_files(self.ex_dir): + out.write(' %s/%s' % (self.to_ex_dir, jfile)) + if IS_WINDOWS: + deps = deps.replace('/', '\\') + out.write('%s\n' % deps) out.write('\t%s -cp %s ' % (JAVAC, pkg)) win_ex_dir = self.to_ex_dir for javafile in get_java_files(self.ex_dir): diff --git a/scripts/update_api.py b/scripts/update_api.py index e55a3a356..354f5728f 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -489,18 +489,19 @@ def mk_java(): java_native = open(java_nativef, 'w') java_native.write('// Automatically generated file\n') java_native.write('package %s;\n' % get_component('java').package_name) + java_native.write('import %s.enumerations.*;\n' % get_component('java').package_name) java_native.write('public final class Native {\n') java_native.write(' public static class IntPtr { public int value; }\n') java_native.write(' public static class LongPtr { public long value; }\n') java_native.write(' public static class StringPtr { public String value; }\n') java_native.write(' public static class errorHandler { public long ptr; }\n') - if IS_WINDOWS: java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) else: java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name + java_native.write('\n\n') for name, result, params in _dotnet_decls: - java_native.write(' public static native %s %s(' % (type2java(result), java_method_name(name))) + java_native.write(' protected static native %s INTERNAL%s(' % (type2java(result), java_method_name(name))) first = True i = 0; for param in params: @@ -511,12 +512,46 @@ def mk_java(): java_native.write('%s a%d' % (param2java(param), i)) i = i + 1 java_native.write(');\n') - java_native.write(' public static void main(String[] args) {\n') - java_native.write(' IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr();\n') - java_native.write(' getVersion(major, minor, build, revision);\n') - java_native.write(' System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value);\n') - java_native.write(' }\n') - java_native.write('}\n'); + java_native.write('\n\n') + # Exception wrappers + for name, result, params in _dotnet_decls: + java_native.write(' public static %s %s(' % (type2java(result), java_method_name(name))) + first = True + i = 0; + for param in params: + if first: + first = False + else: + java_native.write(', ') + java_native.write('%s a%d' % (param2java(param), i)) + i = i + 1 + java_native.write(')') + if len(params) > 0 and param_type(params[0]) == CONTEXT: + java_native.write(' throws Z3Exception') + java_native.write('\n') + java_native.write(' {\n') + java_native.write(' ') + if result != VOID: + java_native.write('%s res = ' % type2java(result)) + java_native.write('INTERNAL%s(' % (java_method_name(name))) + first = True + i = 0; + for param in params: + if first: + first = False + else: + java_native.write(', ') + java_native.write('a%d' % i) + i = i + 1 + java_native.write(');\n') + if len(params) > 0 and param_type(params[0]) == CONTEXT: + java_native.write(' Z3_error_code err = Z3_error_code.fromInt(INTERNALgetErrorCode(a0));\n') + java_native.write(' if (err != Z3_error_code.Z3_OK)\n') + java_native.write(' throw new Z3Exception(INTERNALgetErrorMsgEx(a0, err.toInt()));\n') + if result != VOID: + java_native.write(' return res;\n') + java_native.write(' }\n\n') + java_native.write('}\n') java_wrapper = open(java_wrapperf, 'w') java_wrapper.write('// Automatically generated file\n') java_wrapper.write('#include\n') @@ -544,7 +579,7 @@ def mk_java(): java_wrapper.write(' delete [] NEW; \n\n') pkg_str = get_component('java').package_name.replace('.', '_') for name, result, params in _dotnet_decls: - java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) + java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) i = 0; for param in params: java_wrapper.write(', ') @@ -629,7 +664,7 @@ def mk_java(): if result == STRING: java_wrapper.write(' return jenv->NewStringUTF(result);\n') elif result != VOID: - java_wrapper.write(' return (%s) result;\n' % type2javaw(result)) + java_wrapper.write(' return (%s) result;\n' % type2javaw(result)) java_wrapper.write('}\n') java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('}\n') diff --git a/src/api/java/AST.java b/src/api/java/AST.java index f30e67673..fbefbf5e2 100644 --- a/src/api/java/AST.java +++ b/src/api/java/AST.java @@ -13,216 +13,222 @@ import com.microsoft.z3.enumerations.*; **/ 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 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. */ + /** + * 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. + **/ + 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; - } - } + /** + * 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()); - } + /** + * 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()); - } + /** + * 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 - { + /** + * 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())); - } + 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())); - } + /** + * The kind of the AST. + **/ + public Z3_ast_kind ASTKind() throws Z3Exception + { + 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 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 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 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 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; - } + /** + * 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. + **/ + public String toString() + { + try + { + return Native.astToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - /** - * A string representation of the AST in s-expression notation. - **/ - public String SExpr() throws Z3Exception - { - 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) + { + super(ctx); + } - AST(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + 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 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); - } + 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"); - } - } + 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 index 720e90a4c..f66c54006 100644 --- a/src/api/java/ASTDecRefQueue.java +++ b/src/api/java/ASTDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; public class ASTDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.incRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.incRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.decRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.decRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/ASTMap.java b/src/api/java/ASTMap.java index a2d334b0e..c40c4c6b8 100644 --- a/src/api/java/ASTMap.java +++ b/src/api/java/ASTMap.java @@ -11,106 +11,114 @@ package com.microsoft.z3; **/ 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) - { + /** + * 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) throws Z3Exception + { - return Native.astMapContains(Context().nCtx(), NativeObject(), - k.NativeObject()); - } + 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())); - } + /** + * 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) - { + /** + * Stores or replaces a new key/value pair in the map. The + * key AST The value AST + **/ + public void Insert(AST k, AST v) throws Z3Exception + { - Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), - v.NativeObject()); - } + Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), + v.NativeObject()); + } - /** - * Erases the key from the map. An - * AST - **/ - public void Erase(AST k) - { + /** + * Erases the key from the map. An + * AST + **/ + public void Erase(AST k) throws Z3Exception + { - Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject()); - } + Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject()); + } - /** - * Removes all keys from the map. - **/ - public void Reset() - { - Native.astMapReset(Context().nCtx(), NativeObject()); - } + /** + * Removes all keys from the map. + **/ + public void Reset() throws Z3Exception + { + Native.astMapReset(Context().nCtx(), NativeObject()); + } - /** - * The size of the map - **/ - public int Size() - { - return Native.astMapSize(Context().nCtx(), NativeObject()); - } + /** + * The size of the map + **/ + public int Size() throws Z3Exception + { + 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())); - } + /** + * 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()); - } + /** + * Retrieves a string representation of the map. + **/ + public String toString() + { + try + { + return Native.astMapToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - ASTMap(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + ASTMap(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } - ASTMap(Context ctx) throws Z3Exception - { - super(ctx, Native.mkAstMap(ctx.nCtx())); - } + 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 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); - } + 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 index b93c9f4bd..0e9cf1ae7 100644 --- a/src/api/java/ASTVector.java +++ b/src/api/java/ASTVector.java @@ -11,94 +11,99 @@ package com.microsoft.z3; **/ class ASTVector extends Z3Object { - /** - * The size of the vector - **/ - public int Size() - { - return Native.astVectorSize(Context().nCtx(), NativeObject()); - } + /** + * The size of the vector + **/ + public int Size() throws Z3Exception + { + 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)); - } + /** + * 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) - { + public void set(int i, AST value) throws Z3Exception + { - 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(int newSize) - { - Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); - } + /** + * Resize the vector to . The new size of the vector. + **/ + public void Resize(int newSize) throws Z3Exception + { + 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) - { + /** + * Add the AST to the back of the vector. The size is + * increased by 1. An AST + **/ + public void Push(AST a) throws Z3Exception + { + Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); + } - 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())); + } - /** - * 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() + { + try + { + return Native.astVectorToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - /** - * 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, long obj) throws Z3Exception - { - super(ctx, obj); - } + ASTVector(Context ctx) throws Z3Exception + { + super(ctx, Native.mkAstVector(ctx.nCtx())); + } - 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 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); - } + void DecRef(long o) throws Z3Exception + { + Context().ASTVector_DRQ().Add(o); + super.DecRef(o); + } } diff --git a/src/api/java/ApplyResult.java b/src/api/java/ApplyResult.java index feb8dc5ea..31267b536 100644 --- a/src/api/java/ApplyResult.java +++ b/src/api/java/ApplyResult.java @@ -12,64 +12,71 @@ package com.microsoft.z3; **/ public class ApplyResult extends Z3Object { - /** - * The number of Subgoals. - **/ - public int NumSubgoals() - { - return Native.applyResultGetNumSubgoals(Context().nCtx(), - NativeObject()); - } + /** + * The number of Subgoals. + **/ + public int NumSubgoals() throws Z3Exception + { + 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; - } + /** + * 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())); - } + /** + * 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()); - } + /** + * A string representation of the ApplyResult. + **/ + public String toString() + { + try + { + return Native.applyResultToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - ApplyResult(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + 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 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); - } + 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 index 96d18bef1..c459e85aa 100644 --- a/src/api/java/ApplyResultDecRefQueue.java +++ b/src/api/java/ApplyResultDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class ApplyResultDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.applyResultIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.applyResultIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.applyResultDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.applyResultDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/AstMapDecRefQueue.java b/src/api/java/AstMapDecRefQueue.java index 23cb3c6fd..d59074cdb 100644 --- a/src/api/java/AstMapDecRefQueue.java +++ b/src/api/java/AstMapDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class ASTMapDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.astMapIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.astMapIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.astMapDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.astMapDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/AstVectorDecRefQueue.java b/src/api/java/AstVectorDecRefQueue.java index 4496c092e..d4b508a54 100644 --- a/src/api/java/AstVectorDecRefQueue.java +++ b/src/api/java/AstVectorDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class ASTVectorDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.astVectorIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.astVectorIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.astVectorDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.astVectorDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/BitVecNum.java b/src/api/java/BitVecNum.java index 10dad6423..3560d5efa 100644 --- a/src/api/java/BitVecNum.java +++ b/src/api/java/BitVecNum.java @@ -13,50 +13,56 @@ import java.math.BigInteger; **/ 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 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 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()); - } + /** + * 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()); - } + /** + * Returns a string representation of the numeral. + **/ + public String toString() + { + try + { + return Native.getNumeralString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - BitVecNum(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + BitVecNum(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } } diff --git a/src/api/java/BitVecSort.java b/src/api/java/BitVecSort.java index e8cd0af27..58781302e 100644 --- a/src/api/java/BitVecSort.java +++ b/src/api/java/BitVecSort.java @@ -13,7 +13,7 @@ public class BitVecSort extends Sort /** * The size of the bit-vector sort. **/ - public int Size() + public int Size() throws Z3Exception { return Native.getBvSortSize(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/Constructor.java b/src/api/java/Constructor.java index 3ddb8664b..e267998a0 100644 --- a/src/api/java/Constructor.java +++ b/src/api/java/Constructor.java @@ -54,7 +54,7 @@ public class Constructor extends Z3Object /** * Destructor. **/ - protected void finalize() + protected void finalize() throws Z3Exception { Native.delConstructor(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/ConstructorList.java b/src/api/java/ConstructorList.java index 857ec3cf0..87b6bd4fd 100644 --- a/src/api/java/ConstructorList.java +++ b/src/api/java/ConstructorList.java @@ -14,7 +14,7 @@ public class ConstructorList extends Z3Object /** * Destructor. **/ - protected void finalize() + protected void finalize() throws Z3Exception { Native.delConstructorList(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/Context.java b/src/api/java/Context.java index c3fbeab15..1d2f800ba 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -14,3110 +14,3116 @@ import com.microsoft.z3.enumerations.*; **/ 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() throws Z3Exception - { - if (m_realSort== null) - m_realSort = new RealSort(this); - 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, (Expr)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 arg) throws Z3Exception - { - CheckContextMatch(f); - CheckContextMatch(arg); - Expr[] args = { arg }; - return Expr.Create(this, f, args); - } - - /** - * 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() throws Z3Exception - { - return MkSolver((Symbol)null); - } - - /** - * 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) - 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() - { - Dispose(); - - if (m_refCount == 0) - { - m_n_err_handler = null; - Native.delContext(m_ctx); - m_ctx = 0; - } else - /* re-queue the finalizer */ - /* BUG: DRQ's need to be taken over too! */ - new Context(m_ctx, m_refCount, m_n_err_handler); - } - - /** - * Disposes of the context. - **/ - public void Dispose() - { - 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; - } + /** + * 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() throws Z3Exception + { + if (m_realSort == null) + m_realSort = new RealSort(this); + 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, (Expr) 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 arg) throws Z3Exception + { + CheckContextMatch(f); + CheckContextMatch(arg); + Expr[] args = { arg }; + return Expr.Create(this, f, args); + } + + /** + * 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() throws Z3Exception + { + return MkSolver((Symbol) null); + } + + /** + * 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) + 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() + { + Dispose(); + + if (m_refCount == 0) + { + m_n_err_handler = null; + try + { + Native.delContext(m_ctx); + } catch (Z3Exception e) + { + // OK. + } + m_ctx = 0; + } else + /* re-queue the finalizer */ + /* BUG: DRQ's need to be taken over too! */ + new Context(m_ctx, m_refCount, m_n_err_handler); + } + + /** + * Disposes of the context. + **/ + public void Dispose() + { + 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/DatatypeSort.java b/src/api/java/DatatypeSort.java index 1ff123706..7e6d002aa 100644 --- a/src/api/java/DatatypeSort.java +++ b/src/api/java/DatatypeSort.java @@ -14,7 +14,7 @@ public class DatatypeSort extends Sort /** * The number of constructors of the datatype sort. **/ - public int NumConstructors() + public int NumConstructors() throws Z3Exception { return Native.getDatatypeSortNumConstructors(Context().nCtx(), NativeObject()); diff --git a/src/api/java/FiniteDomainSort.java b/src/api/java/FiniteDomainSort.java index 0183bec60..8c39320ad 100644 --- a/src/api/java/FiniteDomainSort.java +++ b/src/api/java/FiniteDomainSort.java @@ -14,7 +14,7 @@ public class FiniteDomainSort extends Sort /** * The size of the finite domain sort. **/ - public long Size() + public long Size() throws Z3Exception { Native.LongPtr res = new Native.LongPtr(); Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res); diff --git a/src/api/java/Fixedpoint.java b/src/api/java/Fixedpoint.java index 860629eec..375cb7b97 100644 --- a/src/api/java/Fixedpoint.java +++ b/src/api/java/Fixedpoint.java @@ -14,314 +14,320 @@ import com.microsoft.z3.enumerations.*; public class Fixedpoint extends Z3Object { - /** - * A string that describes all available fixedpoint solver parameters. - **/ - public String Help() - { + /** + * A string that describes all available fixedpoint solver parameters. + **/ + public String Help() throws Z3Exception + { + return Native.fixedpointGetHelp(Context().nCtx(), NativeObject()); + } - return Native.fixedpointGetHelp(Context().nCtx(), NativeObject()); - } + /** + * Sets the fixedpoint solver parameters. + * + * @throws Z3Exception + **/ + public void setParameters(Params value) throws Z3Exception + { - /** - * Sets the fixedpoint solver parameters. - * - * @throws Z3Exception - **/ - public void setParameters(Params value) throws Z3Exception - { + 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. + * + * @throws Z3Exception + **/ + public ParamDescrs ParameterDescriptions() throws Z3Exception + { + return new ParamDescrs(Context(), Native.fixedpointGetParamDescrs( + Context().nCtx(), 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()); + } + } - /** - * Assert a constraint (or multiple) into the fixedpoint solver. - * - * @throws Z3Exception - **/ - public void Assert(BoolExpr[] constraints) throws Z3Exception - { + /** + * Register predicate as recursive relation. + * + * @throws Z3Exception + **/ + public void RegisterRelation(FuncDecl f) throws Z3Exception + { - Context().CheckContextMatch(constraints); - for (BoolExpr a : constraints) - { - Native.fixedpointAssert(Context().nCtx(), NativeObject(), - a.NativeObject()); - } - } + Context().CheckContextMatch(f); + Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), + f.NativeObject()); + } - /** - * Register predicate as recursive relation. - * - * @throws Z3Exception - **/ - public void RegisterRelation(FuncDecl f) throws Z3Exception - { + /** + * Add rule into the fixedpoint solver. + * + * @throws Z3Exception + **/ + public void AddRule(BoolExpr rule, Symbol name) throws Z3Exception + { - Context().CheckContextMatch(f); - Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(), - f.NativeObject()); - } + Context().CheckContextMatch(rule); + Native.fixedpointAddRule(Context().nCtx(), NativeObject(), + rule.NativeObject(), AST.GetNativeObject(name)); + } - /** - * Add rule into the fixedpoint solver. - * - * @throws Z3Exception - **/ - public void AddRule(BoolExpr rule, Symbol name) throws Z3Exception - { + /** + * Add table fact to the fixedpoint solver. + * + * @throws Z3Exception + **/ + public void AddFact(FuncDecl pred, int[] args) throws Z3Exception + { - Context().CheckContextMatch(rule); - Native.fixedpointAddRule(Context().nCtx(), NativeObject(), - rule.NativeObject(), AST.GetNativeObject(name)); - } + Context().CheckContextMatch(pred); + Native.fixedpointAddFact(Context().nCtx(), NativeObject(), + pred.NativeObject(), (int) args.length, args); + } - /** - * Add table fact to the fixedpoint solver. - * - * @throws Z3Exception - **/ - public void AddFact(FuncDecl pred, int[] args) throws Z3Exception - { + /** + * 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(pred); - Native.fixedpointAddFact(Context().nCtx(), NativeObject(), - pred.NativeObject(), (int) args.length, args); - } + 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 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 - { + /** + * 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(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; - } - } + 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; + } + } - /** - * 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 - { + /** + * Creates a backtracking point. + **/ + public void Push() throws Z3Exception + { + Native.fixedpointPush(Context().nCtx(), NativeObject()); + } - 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; - } - } + /** + * Backtrack one backtracking point. Note that an exception is + * thrown if Pop is called without a corresponding Push + * + **/ + public void Pop() throws Z3Exception + { + Native.fixedpointPop(Context().nCtx(), NativeObject()); + } - /** - * Creates a backtracking point. - **/ - public void Push() - { - Native.fixedpointPush(Context().nCtx(), NativeObject()); - } + /** + * Update named rule into in the fixedpoint solver. + * + * @throws Z3Exception + **/ + public void UpdateRule(BoolExpr rule, Symbol name) throws Z3Exception + { - /** - * 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()); - } + Context().CheckContextMatch(rule); + Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(), + rule.NativeObject(), AST.GetNativeObject(name)); + } - /** - * Update named rule into in the fixedpoint solver. - * - * @throws Z3Exception - **/ - public void UpdateRule(BoolExpr rule, Symbol name) throws Z3Exception - { + /** + * 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); + } - Context().CheckContextMatch(rule); - Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(), - rule.NativeObject(), AST.GetNativeObject(name)); - } + /** + * Retrieve explanation why fixedpoint engine returned status Unknown. + **/ + public String GetReasonUnknown() throws Z3Exception + { - /** - * 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); - } + return Native.fixedpointGetReasonUnknown(Context().nCtx(), + NativeObject()); + } - /** - * Retrieve explanation why fixedpoint engine returned status Unknown. - **/ - public String GetReasonUnknown() - { + /** + * Retrieve the number of levels explored for a given predicate. + **/ + public int GetNumLevels(FuncDecl predicate) throws Z3Exception + { + return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), + predicate.NativeObject()); + } - return Native.fixedpointGetReasonUnknown(Context().nCtx(), - 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); + } - /** - * Retrieve the number of levels explored for a given predicate. - **/ - public int GetNumLevels(FuncDecl predicate) - { - return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), - predicate.NativeObject()); - } + /** + * Add property about the predicate. The property is added + * at level. + **/ + public void AddCover(int level, FuncDecl predicate, Expr property) + throws Z3Exception + { + Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, + predicate.NativeObject(), property.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); - } + /** + * Retrieve internal string representation of fixedpoint object. + **/ + public String toString() + { + try + { + return Native.fixedpointToString(Context().nCtx(), NativeObject(), + 0, null); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - /** - * 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()); - } + /** + * Instrument the Datalog engine on which table representation to use for + * recursive predicate. + **/ + public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception + { - /** - * Retrieve internal string representation of fixedpoint object. - **/ - public String toString() - { - return Native.fixedpointToString(Context().nCtx(), NativeObject(), 0, - null); - } + Native.fixedpointSetPredicateRepresentation(Context().nCtx(), + NativeObject(), f.NativeObject(), AST.ArrayLength(kinds), + Symbol.ArrayToNative(kinds)); - /** - * 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) throws Z3Exception + { - } + return Native.fixedpointToString(Context().nCtx(), NativeObject(), + AST.ArrayLength(queries), AST.ArrayToNative(queries)); + } - /** - * Convert benchmark given as set of axioms, rules and queries to a string. - **/ - public String toString(BoolExpr[] queries) - { + /** + * Retrieve set of rules added to fixedpoint context. + * + * @throws Z3Exception + **/ + public BoolExpr[] Rules() throws Z3Exception + { - return Native.fixedpointToString(Context().nCtx(), NativeObject(), - AST.ArrayLength(queries), AST.ArrayToNative(queries)); - } + 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 rules added to fixedpoint context. - * - * @throws Z3Exception - **/ - public BoolExpr[] Rules() throws Z3Exception - { + /** + * Retrieve set of assertions added to fixedpoint context. + * + * @throws Z3Exception + **/ + public BoolExpr[] Assertions() 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; - } + 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; + } - /** - * Retrieve set of assertions added to fixedpoint context. - * - * @throws Z3Exception - **/ - public BoolExpr[] Assertions() throws Z3Exception - { + Fixedpoint(Context ctx, long obj) throws Z3Exception + { + super(ctx, obj); + } - 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) throws Z3Exception + { + super(ctx, Native.mkFixedpoint(ctx.nCtx())); + } - Fixedpoint(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + void IncRef(long o) throws Z3Exception + { + Context().Fixedpoint_DRQ().IncAndClear(Context(), o); + super.IncRef(o); + } - 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); - } + 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 index 3d436eafb..677691db8 100644 --- a/src/api/java/FixedpointDecRefQueue.java +++ b/src/api/java/FixedpointDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class FixedpointDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.fixedpointIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.fixedpointIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.fixedpointDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.fixedpointDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/FuncDecl.java b/src/api/java/FuncDecl.java index c001dc982..a2bf28c5d 100644 --- a/src/api/java/FuncDecl.java +++ b/src/api/java/FuncDecl.java @@ -13,379 +13,385 @@ import com.microsoft.z3.enumerations.*; **/ 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 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. */ + /** + * 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; - } + /** + * 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 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()); - } + /** + * A string representations of the function declaration. + **/ + public String toString() + { + try + { + return Native.funcDeclToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - /** - * Returns a unique identifier for the function declaration. - **/ - public int Id() throws Z3Exception - { - return Native.getFuncDeclId(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 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 size of the domain of the function declaration + **/ + public int DomainSize() throws Z3Exception + { + return Native.getDomainSize(Context().nCtx(), NativeObject()); + } - /** - * The domain of the function declaration - **/ - public Sort[] Domain() throws Z3Exception - { + /** + * The domain of the function declaration + **/ + public Sort[] Domain() throws Z3Exception + { - int n = DomainSize(); + 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; - } + 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 - { + /** + * The range of the function declaration + **/ + public Sort Range() throws Z3Exception + { - 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() throws Z3Exception - { - return Z3_decl_kind.fromInt(Native.getDeclKind(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 - { + /** + * The name of the function declaration + **/ + public Symbol Name() throws Z3Exception + { - 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 int NumParameters() throws Z3Exception - { - return Native.getDeclNumParameters(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 - { + /** + * 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; - } + 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; + /** + * 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 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 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 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 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 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 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 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; - } + /** + * 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, 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, 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, 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, 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, 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, FuncDecl fd) + { + this.kind = k; + this.fd = fd; + } - Parameter(Z3_parameter_kind k, String r) - { - this.kind = k; - this.r = r; - } - } + 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, 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, 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())); + 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); - } + 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 + **/ + /* 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); - } + /** + * Create expression that applies function to arguments. + * + * @return + **/ + public Expr Apply(Expr[] args) throws Z3Exception + { + Context().CheckContextMatch(args); + return Expr.Create(Context(), this, args); + } - /** - * Create expression that applies function to one argument. - * - * - * @return - **/ - public Expr Apply(Expr arg) throws Z3Exception - { - Context().CheckContextMatch(arg); - Expr[] a = { arg }; - return Expr.Create(Context(), this, a); - } + /** + * Create expression that applies function to one argument. + * + * @return + **/ + public Expr Apply(Expr arg) throws Z3Exception + { + Context().CheckContextMatch(arg); + Expr[] a = { arg }; + return Expr.Create(Context(), this, a); + } } diff --git a/src/api/java/FuncInterp.java b/src/api/java/FuncInterp.java index 25d3fe1c8..261f433e7 100644 --- a/src/api/java/FuncInterp.java +++ b/src/api/java/FuncInterp.java @@ -33,7 +33,7 @@ public class FuncInterp extends Z3Object /** * The number of arguments of the entry. **/ - public int NumArgs() + public int NumArgs() throws Z3Exception { return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); } @@ -93,7 +93,7 @@ public class FuncInterp extends Z3Object /** * The number of entries in the function interpretation. **/ - public int NumEntries() + public int NumEntries() throws Z3Exception { return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); } @@ -127,7 +127,7 @@ public class FuncInterp extends Z3Object /** * The arity of the function interpretation **/ - public int Arity() + public int Arity() throws Z3Exception { return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/FuncInterpDecRefQueue.java b/src/api/java/FuncInterpDecRefQueue.java index e41551b66..d1b662cb2 100644 --- a/src/api/java/FuncInterpDecRefQueue.java +++ b/src/api/java/FuncInterpDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class FuncInterpDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.funcInterpIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.funcInterpIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.funcInterpDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.funcInterpDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/FuncInterpEntryDecRefQueue.java b/src/api/java/FuncInterpEntryDecRefQueue.java index 8d642217f..df2702020 100644 --- a/src/api/java/FuncInterpEntryDecRefQueue.java +++ b/src/api/java/FuncInterpEntryDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class FuncInterpEntryDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.funcEntryIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.funcEntryIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.funcEntryDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.funcEntryDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/Goal.java b/src/api/java/Goal.java index 0add69fd5..61ac96d30 100644 --- a/src/api/java/Goal.java +++ b/src/api/java/Goal.java @@ -14,207 +14,218 @@ import com.microsoft.z3.enumerations.*; **/ 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())); - } + /** + * 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() throws Z3Exception + { + 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 precise. + **/ + public boolean IsPrecise() throws Z3Exception + { + 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 under-approximation. + **/ + public boolean IsUnderApproximation() throws Z3Exception + { + 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 an over-approximation. + **/ + public boolean IsOverApproximation() throws Z3Exception + { + 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; - } + /** + * Indicates whether the goal is garbage (i.e., the product of over- and + * under-approximations). + **/ + public boolean IsGarbage() throws Z3Exception + { + 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) - { - Native.goalAssert(Context().nCtx(), NativeObject(), - c.NativeObject()); - } - } + /** + * Adds the to the given goal. + * + * @throws Z3Exception + **/ + public void Assert(BoolExpr[] constraints) throws Z3Exception + { + Context().CheckContextMatch(constraints); + for (BoolExpr c : constraints) + { + Native.goalAssert(Context().nCtx(), NativeObject(), + c.NativeObject()); + } + } - /** - * Adds a to the given goal. - * @throws Z3Exception - **/ - public void Assert(BoolExpr constraint) throws Z3Exception - { - Context().CheckContextMatch(constraint); - Native.goalAssert(Context().nCtx(), NativeObject(), - constraint.NativeObject()); - } + /** + * Adds a to the given goal. + * + * @throws Z3Exception + **/ + public void Assert(BoolExpr constraint) throws Z3Exception + { + Context().CheckContextMatch(constraint); + Native.goalAssert(Context().nCtx(), NativeObject(), + constraint.NativeObject()); + } - /** - * Indicates whether the goal contains `false'. - **/ - public boolean Inconsistent() - { - return Native.goalInconsistent(Context().nCtx(), NativeObject()); - } + /** + * Indicates whether the goal contains `false'. + **/ + public boolean Inconsistent() throws Z3Exception + { + 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()); - } + /** + * The depth of the goal. This tracks how many transformations + * were applied to it. + **/ + public int Depth() throws Z3Exception + { + return Native.goalDepth(Context().nCtx(), NativeObject()); + } - /** - * Erases all formulas from the given goal. - **/ - public void Reset() - { - Native.goalReset(Context().nCtx(), NativeObject()); - } + /** + * Erases all formulas from the given goal. + **/ + public void Reset() throws Z3Exception + { + Native.goalReset(Context().nCtx(), NativeObject()); + } - /** - * The number of formulas in the goal. - **/ - public int Size() - { - return Native.goalSize(Context().nCtx(), NativeObject()); - } + /** + * The number of formulas in the goal. + **/ + public int Size() throws Z3Exception + { + 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 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()); - } + /** + * The number of formulas, subformulas and terms in the goal. + **/ + public int NumExprs() throws Z3Exception + { + 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 is empty, and it is precise or the product of + * an under approximation. + **/ + public boolean IsDecidedSat() throws Z3Exception + { + 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()); - } + /** + * Indicates whether the goal contains `false', and it is precise or the + * product of an over approximation. + **/ + public boolean IsDecidedUnsat() throws Z3Exception + { + 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())); - } + /** + * 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); + /** + * 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]; - } + 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 to string conversion. + * + * @return A string representation of the Goal. + **/ + public String toString() + { + try + { + return Native.goalToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } - Goal(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + 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)); - } + 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 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); - } + 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 index 9bd2b79db..7dd52285f 100644 --- a/src/api/java/GoalDecRefQueue.java +++ b/src/api/java/GoalDecRefQueue.java @@ -7,13 +7,25 @@ package com.microsoft.z3; class GoalDecRefQueue extends IDecRefQueue { - public void IncRef(Context ctx, long obj) - { - Native.goalIncRef(ctx.nCtx(), obj); - } + public void IncRef(Context ctx, long obj) + { + try + { + Native.goalIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } - public void DecRef(Context ctx, long obj) - { - Native.goalDecRef(ctx.nCtx(), obj); - } + public void DecRef(Context ctx, long obj) + { + try + { + Native.goalDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } + } }; diff --git a/src/api/java/IntNum.java b/src/api/java/IntNum.java index aecf68ee7..1397616c6 100644 --- a/src/api/java/IntNum.java +++ b/src/api/java/IntNum.java @@ -14,46 +14,52 @@ import java.math.BigInteger; public class IntNum extends IntExpr { - IntNum(Context ctx, long obj) throws Z3Exception - { - super(ctx, obj); - } + 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 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 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()); - } + /** + * 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()); - } + /** + * Returns a string representation of the numeral. + **/ + public String toString() + { + try + { + return Native.getNumeralString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } + } } diff --git a/src/api/java/Model.java b/src/api/java/Model.java index 2616f26be..e38c260c4 100644 --- a/src/api/java/Model.java +++ b/src/api/java/Model.java @@ -19,7 +19,7 @@ public class Model extends Z3Object * * @return An expression if the constant has an interpretation in the model, * null otherwise. - * @throws Z3Exception + * @throws Z3Exception **/ public Expr ConstInterp(Expr a) throws Z3Exception { @@ -33,7 +33,7 @@ public class Model extends Z3Object * * @return An expression if the function has an interpretation in the model, * null otherwise. - * @throws Z3Exception + * @throws Z3Exception **/ public Expr ConstInterp(FuncDecl f) throws Z3Exception { @@ -60,7 +60,7 @@ public class Model extends Z3Object * * @return A FunctionInterpretation if the function has an interpretation in * the model, null otherwise. - * @throws Z3Exception + * @throws Z3Exception **/ public FuncInterp FuncInterp(FuncDecl f) throws Z3Exception { @@ -105,14 +105,15 @@ public class Model extends Z3Object /** * The number of constants that have an interpretation in the model. **/ - public int NumConsts() + public int NumConsts() throws Z3Exception { return Native.modelGetNumConsts(Context().nCtx(), NativeObject()); } /** * The function declarations of the constants in the model. - * @throws Z3Exception + * + * @throws Z3Exception **/ public FuncDecl[] ConstDecls() throws Z3Exception { @@ -127,14 +128,15 @@ public class Model extends Z3Object /** * The number of function interpretations in the model. **/ - public int NumFuncs() + public int NumFuncs() throws Z3Exception { return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); } /** * The function declarations of the function interpretations in the model. - * @throws Z3Exception + * + * @throws Z3Exception **/ public FuncDecl[] FuncDecls() throws Z3Exception { @@ -148,7 +150,8 @@ public class Model extends Z3Object /** * All symbols that have an interpretation in the model. - * @throws Z3Exception + * + * @throws Z3Exception **/ public FuncDecl[] Decls() throws Z3Exception { @@ -192,7 +195,7 @@ public class Model extends Z3Object * that does not have an interpretation in the model. * * @return The evaluation of in the model. - * @throws Z3Exception + * @throws Z3Exception **/ public Expr Eval(Expr t, boolean completion) throws Z3Exception { @@ -206,7 +209,8 @@ public class Model extends Z3Object /** * Alias for Eval. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Expr Evaluate(Expr t, boolean completion) throws Z3Exception { @@ -217,7 +221,7 @@ public class Model extends Z3Object * The number of uninterpreted sorts that the model has an interpretation * for. **/ - public int NumSorts() + public int NumSorts() throws Z3Exception { return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); } @@ -228,7 +232,8 @@ public class Model extends Z3Object * 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 + * + * @throws Z3Exception **/ public Sort[] Sorts() throws Z3Exception { @@ -248,7 +253,7 @@ public class Model extends Z3Object * * @return An array of expressions, where each is an element of the universe * of - * @throws Z3Exception + * @throws Z3Exception **/ public Expr[] SortUniverse(Sort s) throws Z3Exception { @@ -269,7 +274,13 @@ public class Model extends Z3Object **/ public String toString() { - return Native.modelToString(Context().nCtx(), NativeObject()); + try + { + return Native.modelToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } Model(Context ctx, long obj) throws Z3Exception diff --git a/src/api/java/ModelDecRefQueue.java b/src/api/java/ModelDecRefQueue.java index 89a0bbd78..71fb939cf 100644 --- a/src/api/java/ModelDecRefQueue.java +++ b/src/api/java/ModelDecRefQueue.java @@ -9,11 +9,23 @@ class ModelDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.modelIncRef(ctx.nCtx(), obj); + try + { + Native.modelIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.modelDecRef(ctx.nCtx(), obj); + try + { + Native.modelDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/ParamDescrs.java b/src/api/java/ParamDescrs.java index 11a8ee8b2..09b70f5c7 100644 --- a/src/api/java/ParamDescrs.java +++ b/src/api/java/ParamDescrs.java @@ -16,7 +16,7 @@ public class ParamDescrs extends Z3Object /** * validate a set of parameters. **/ - public void Validate(Params p) + public void Validate(Params p) throws Z3Exception { Native.paramsValidate(Context().nCtx(), p.NativeObject(), @@ -26,7 +26,7 @@ public class ParamDescrs extends Z3Object /** * Retrieve kind of parameter. **/ - public Z3_param_kind GetKind(Symbol name) + public Z3_param_kind GetKind(Symbol name) throws Z3Exception { return Z3_param_kind.fromInt(Native.paramDescrsGetKind( @@ -53,7 +53,7 @@ public class ParamDescrs extends Z3Object /** * The size of the ParamDescrs. **/ - public int Size() + public int Size() throws Z3Exception { return Native.paramDescrsSize(Context().nCtx(), NativeObject()); } @@ -63,7 +63,13 @@ public class ParamDescrs extends Z3Object **/ public String toString() { - return Native.paramDescrsToString(Context().nCtx(), NativeObject()); + try + { + return Native.paramDescrsToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } ParamDescrs(Context ctx, long obj) throws Z3Exception diff --git a/src/api/java/ParamDescrsDecRefQueue.java b/src/api/java/ParamDescrsDecRefQueue.java index f36d302ba..75e2a2c7e 100644 --- a/src/api/java/ParamDescrsDecRefQueue.java +++ b/src/api/java/ParamDescrsDecRefQueue.java @@ -9,11 +9,23 @@ class ParamDescrsDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.paramDescrsIncRef(ctx.nCtx(), obj); + try + { + Native.paramDescrsIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.paramDescrsDecRef(ctx.nCtx(), obj); + try + { + Native.paramDescrsDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/Params.java b/src/api/java/Params.java index 33ca34a23..3bc8b4574 100644 --- a/src/api/java/Params.java +++ b/src/api/java/Params.java @@ -80,7 +80,13 @@ public class Params extends Z3Object **/ public String toString() { - return Native.paramsToString(Context().nCtx(), NativeObject()); + try + { + return Native.paramsToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } Params(Context ctx) throws Z3Exception diff --git a/src/api/java/ParamsDecRefQueue.java b/src/api/java/ParamsDecRefQueue.java index 27fa3cadd..7c3ccbee8 100644 --- a/src/api/java/ParamsDecRefQueue.java +++ b/src/api/java/ParamsDecRefQueue.java @@ -9,11 +9,23 @@ class ParamsDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.paramsIncRef(ctx.nCtx(), obj); + try + { + Native.paramsIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.paramsDecRef(ctx.nCtx(), obj); + try + { + Native.paramsDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/Pattern.java b/src/api/java/Pattern.java index 47f4a7c6a..ed36ad0e7 100644 --- a/src/api/java/Pattern.java +++ b/src/api/java/Pattern.java @@ -15,7 +15,7 @@ public class Pattern extends AST /** * The number of terms in the pattern. **/ - public int NumTerms() + public int NumTerms() throws Z3Exception { return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); } @@ -41,7 +41,13 @@ public class Pattern extends AST **/ public String toString() { - return Native.patternToString(Context().nCtx(), NativeObject()); + try + { + return Native.patternToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } Pattern(Context ctx, long obj) throws Z3Exception diff --git a/src/api/java/ProbeDecRefQueue.java b/src/api/java/ProbeDecRefQueue.java index 01d2e3852..b368702df 100644 --- a/src/api/java/ProbeDecRefQueue.java +++ b/src/api/java/ProbeDecRefQueue.java @@ -9,11 +9,23 @@ class ProbeDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.probeIncRef(ctx.nCtx(), obj); + try + { + Native.probeIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.probeDecRef(ctx.nCtx(), obj); + try + { + Native.probeDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/Quantifier.java b/src/api/java/Quantifier.java index a0b5c9e6a..82e5a958b 100644 --- a/src/api/java/Quantifier.java +++ b/src/api/java/Quantifier.java @@ -16,7 +16,7 @@ public class Quantifier extends BoolExpr /** * Indicates whether the quantifier is universal. **/ - public boolean IsUniversal() + public boolean IsUniversal() throws Z3Exception { return Native.isQuantifierForall(Context().nCtx(), NativeObject()); } @@ -24,7 +24,7 @@ public class Quantifier extends BoolExpr /** * Indicates whether the quantifier is existential. **/ - public boolean IsExistential() + public boolean IsExistential() throws Z3Exception { return !IsUniversal(); } @@ -32,7 +32,7 @@ public class Quantifier extends BoolExpr /** * The weight of the quantifier. **/ - public int Weight() + public int Weight() throws Z3Exception { return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); } @@ -40,7 +40,7 @@ public class Quantifier extends BoolExpr /** * The number of patterns. **/ - public int NumPatterns() + public int NumPatterns() throws Z3Exception { return Native .getQuantifierNumPatterns(Context().nCtx(), NativeObject()); @@ -64,7 +64,7 @@ public class Quantifier extends BoolExpr /** * The number of no-patterns. **/ - public int NumNoPatterns() + public int NumNoPatterns() throws Z3Exception { return Native.getQuantifierNumNoPatterns(Context().nCtx(), NativeObject()); @@ -88,7 +88,7 @@ public class Quantifier extends BoolExpr /** * The number of bound variables. **/ - public int NumBound() + public int NumBound() throws Z3Exception { return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/RatNum.java b/src/api/java/RatNum.java index 045416973..bdc57fbdb 100644 --- a/src/api/java/RatNum.java +++ b/src/api/java/RatNum.java @@ -7,6 +7,7 @@ package com.microsoft.z3; import java.math.BigInteger; + /** * Rational Numerals **/ @@ -63,7 +64,13 @@ public class RatNum extends RealExpr **/ public String toString() { - return Native.getNumeralString(Context().nCtx(), NativeObject()); + try + { + return Native.getNumeralString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } RatNum(Context ctx, long obj) throws Z3Exception diff --git a/src/api/java/RelationSort.java b/src/api/java/RelationSort.java index 2880eadc9..820228e82 100644 --- a/src/api/java/RelationSort.java +++ b/src/api/java/RelationSort.java @@ -14,7 +14,7 @@ public class RelationSort extends Sort /** * The arity of the relation sort. **/ - public int Arity() + public int Arity() throws Z3Exception { return Native.getRelationArity(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java index f3ec9c916..278427d49 100644 --- a/src/api/java/Solver.java +++ b/src/api/java/Solver.java @@ -16,14 +16,15 @@ public class Solver extends Z3Object /** * A string that describes all available solver parameters. **/ - public String Help() + public String Help() throws Z3Exception { return Native.solverGetHelp(Context().nCtx(), NativeObject()); } /** * Sets the solver parameters. - * @throws Z3Exception + * + * @throws Z3Exception **/ public void setParameters(Params value) throws Z3Exception { @@ -34,7 +35,8 @@ public class Solver extends Z3Object /** * Retrieves parameter descriptions for solver. - * @throws Z3Exception + * + * @throws Z3Exception **/ public ParamDescrs ParameterDescriptions() throws Z3Exception { @@ -46,7 +48,7 @@ public class Solver extends Z3Object * The current number of backtracking points (scopes). * **/ - public int NumScopes() + public int NumScopes() throws Z3Exception { return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); } @@ -54,7 +56,7 @@ public class Solver extends Z3Object /** * Creates a backtracking point. **/ - public void Push() + public void Push() throws Z3Exception { Native.solverPush(Context().nCtx(), NativeObject()); } @@ -62,9 +64,9 @@ public class Solver extends Z3Object /** * Backtracks one backtracking point. . **/ - public void Pop() + public void Pop() throws Z3Exception { - Pop(1); + Pop(1); } /** @@ -72,7 +74,7 @@ public class Solver extends Z3Object * an exception is thrown if is not smaller than * NumScopes **/ - public void Pop(int n) + public void Pop(int n) throws Z3Exception { Native.solverPop(Context().nCtx(), NativeObject(), n); } @@ -81,14 +83,15 @@ public class Solver extends Z3Object * Resets the Solver. This removes all assertions from the * solver. **/ - public void Reset() + public void Reset() throws Z3Exception { Native.solverReset(Context().nCtx(), NativeObject()); } /** * Assert a multiple constraints into the solver. - * @throws Z3Exception + * + * @throws Z3Exception **/ public void Assert(BoolExpr[] constraints) throws Z3Exception { @@ -102,17 +105,20 @@ public class Solver extends Z3Object /** * Assert one constraint into the solver. - * @throws Z3Exception + * + * @throws Z3Exception **/ public void Assert(BoolExpr constraint) throws Z3Exception { Context().CheckContextMatch(constraint); - Native.solverAssert(Context().nCtx(), NativeObject(), constraint.NativeObject()); + Native.solverAssert(Context().nCtx(), NativeObject(), + constraint.NativeObject()); } /** * The number of assertions in the solver. - * @throws Z3Exception + * + * @throws Z3Exception **/ public int NumAssertions() throws Z3Exception { @@ -123,7 +129,8 @@ public class Solver extends Z3Object /** * The set of asserted formulas. - * @throws Z3Exception + * + * @throws Z3Exception **/ public BoolExpr[] Assertions() throws Z3Exception { @@ -141,7 +148,7 @@ public class Solver extends Z3Object * **/ - public Status Check(Expr[] assumptions) + public Status Check(Expr[] assumptions) throws Z3Exception { Z3_lbool r; if (assumptions == null) @@ -167,9 +174,9 @@ public class Solver extends Z3Object * **/ - public Status Check() + public Status Check() throws Z3Exception { - return Check(null); + return Check(null); } /** @@ -177,7 +184,8 @@ public class Solver extends Z3Object * null if Check was not invoked before, if its * results was not SATISFIABLE, or if model production is not * enabled. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Model Model() throws Z3Exception { @@ -193,7 +201,8 @@ public class Solver extends Z3Object * null if Check was not invoked before, if its * results was not UNSATISFIABLE, or if proof production is * disabled. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Expr Proof() throws Z3Exception { @@ -209,7 +218,8 @@ public class Solver extends Z3Object * 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 + * + * @throws Z3Exception **/ public Expr[] UnsatCore() throws Z3Exception { @@ -227,15 +237,15 @@ public class Solver extends Z3Object * A brief justification of why the last call to Check returned * UNKNOWN. **/ - public String ReasonUnknown() + public String ReasonUnknown() throws Z3Exception { - return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject()); } /** * Solver statistics. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Statistics Statistics() throws Z3Exception { @@ -248,7 +258,13 @@ public class Solver extends Z3Object **/ public String toString() { - return Native.solverToString(Context().nCtx(), NativeObject()); + try + { + return Native.solverToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } Solver(Context ctx, long obj) throws Z3Exception diff --git a/src/api/java/SolverDecRefQueue.java b/src/api/java/SolverDecRefQueue.java index 11a670732..2696f6ecc 100644 --- a/src/api/java/SolverDecRefQueue.java +++ b/src/api/java/SolverDecRefQueue.java @@ -9,11 +9,23 @@ class SolverDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.solverIncRef(ctx.nCtx(), obj); + try + { + Native.solverIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.solverDecRef(ctx.nCtx(), obj); + try + { + Native.solverDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/Sort.java b/src/api/java/Sort.java index 9a6f8aa9a..526329146 100644 --- a/src/api/java/Sort.java +++ b/src/api/java/Sort.java @@ -37,7 +37,7 @@ public class Sort extends AST * * @return **/ - public boolean Equals(Object o) + public boolean equals(Object o) { Sort casted = (Sort) o; if (casted == null) @@ -86,7 +86,13 @@ public class Sort extends AST **/ public String toString() { - return Native.sortToString(Context().nCtx(), NativeObject()); + try + { + return Native.sortToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } /** diff --git a/src/api/java/Statistics.java b/src/api/java/Statistics.java index 07a573940..3f6e31f96 100644 --- a/src/api/java/Statistics.java +++ b/src/api/java/Statistics.java @@ -56,7 +56,8 @@ public class Statistics extends Z3Object /** * The string representation of the the entry's value. - * @throws Z3Exception + * + * @throws Z3Exception **/ public String Value() throws Z3Exception { @@ -107,20 +108,27 @@ public class Statistics extends Z3Object **/ public String toString() { - return Native.statsToString(Context().nCtx(), NativeObject()); + try + { + return Native.statsToString(Context().nCtx(), NativeObject()); + } catch (Z3Exception e) + { + return "Z3Exception: " + e.getMessage(); + } } /** * The number of statistical data. **/ - public int Size() + public int Size() throws Z3Exception { return Native.statsSize(Context().nCtx(), NativeObject()); } /** * The data entries. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Entry[] Entries() throws Z3Exception { @@ -147,7 +155,7 @@ public class Statistics extends Z3Object /** * The statistical counters. **/ - public String[] Keys() + public String[] Keys() throws Z3Exception { int n = Size(); String[] res = new String[n]; @@ -159,7 +167,8 @@ public class Statistics extends Z3Object /** * The value of a particular statistical counter. Returns null if * the key is unknown. - * @throws Z3Exception + * + * @throws Z3Exception **/ public Entry get(String key) throws Z3Exception { diff --git a/src/api/java/StatisticsDecRefQueue.java b/src/api/java/StatisticsDecRefQueue.java index 0bbd7914a..907cf8760 100644 --- a/src/api/java/StatisticsDecRefQueue.java +++ b/src/api/java/StatisticsDecRefQueue.java @@ -9,11 +9,23 @@ class StatisticsDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.statsIncRef(ctx.nCtx(), obj); + try + { + Native.statsIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } - + public void DecRef(Context ctx, long obj) { - Native.statsDecRef(ctx.nCtx(), obj); + try + { + Native.statsDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/Symbol.java b/src/api/java/Symbol.java index 526960e88..cd987adf2 100644 --- a/src/api/java/Symbol.java +++ b/src/api/java/Symbol.java @@ -16,7 +16,7 @@ public class Symbol extends Z3Object /** * The kind of the symbol (int or string) **/ - protected Z3_symbol_kind Kind() + protected Z3_symbol_kind Kind() throws Z3Exception { return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(), NativeObject())); @@ -25,7 +25,7 @@ public class Symbol extends Z3Object /** * Indicates whether the symbol is of Int kind **/ - public boolean IsIntSymbol() + public boolean IsIntSymbol() throws Z3Exception { return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL; } @@ -33,7 +33,7 @@ public class Symbol extends Z3Object /** * Indicates whether the symbol is of string kind. **/ - public boolean IsStringSymbol() + public boolean IsStringSymbol() throws Z3Exception { return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL; } diff --git a/src/api/java/Tactic.java b/src/api/java/Tactic.java index b9a0ba0c7..124db0ef2 100644 --- a/src/api/java/Tactic.java +++ b/src/api/java/Tactic.java @@ -18,7 +18,7 @@ public class Tactic extends Z3Object /** * A string containing a description of parameters accepted by the tactic. **/ - public String Help() + public String Help() throws Z3Exception { return Native.tacticGetHelp(Context().nCtx(), NativeObject()); } diff --git a/src/api/java/TacticDecRefQueue.java b/src/api/java/TacticDecRefQueue.java index ff0e27b5c..c2ea2c079 100644 --- a/src/api/java/TacticDecRefQueue.java +++ b/src/api/java/TacticDecRefQueue.java @@ -9,11 +9,23 @@ class TacticDecRefQueue extends IDecRefQueue { public void IncRef(Context ctx, long obj) { - Native.tacticIncRef(ctx.nCtx(), obj); + try + { + Native.tacticIncRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } public void DecRef(Context ctx, long obj) { - Native.tacticDecRef(ctx.nCtx(), obj); + try + { + Native.tacticDecRef(ctx.nCtx(), obj); + } catch (Z3Exception e) + { + // OK. + } } }; diff --git a/src/api/java/TupleSort.java b/src/api/java/TupleSort.java index f05885f35..3eb28b88e 100644 --- a/src/api/java/TupleSort.java +++ b/src/api/java/TupleSort.java @@ -25,7 +25,7 @@ public class TupleSort extends Sort /** * The number of fields in the tuple. **/ - public int NumFields() + public int NumFields() throws Z3Exception { return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); } From 3544379f53c623df9cfff1091a832261881b471e Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 19:10:59 +0000 Subject: [PATCH 054/133] Java API: removed platform-dependency of Native.cpp Signed-off-by: Christoph M. Wintersteiger --- scripts/update_api.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 354f5728f..cdc1ba0f5 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -560,23 +560,24 @@ def mk_java(): java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('extern "C" {\n') java_wrapper.write('#endif\n\n') - if VS_X64: - java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') - java_wrapper.write(' T * NEW = (T*) jenv->GetLongArrayElements(OLD, NULL); \n') - java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') - java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') - else: - java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') - java_wrapper.write(' T * NEW = 0; { \\\n') - java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') - java_wrapper.write(' unsigned int size = jenv->GetArrayLength(OLD); \\\n') - java_wrapper.write(' NEW = (T*) (new int[size]); \\\n') - java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n') - java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') - java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n') - java_wrapper.write(' } \n\n') - java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') - java_wrapper.write(' delete [] NEW; \n\n') + java_wrapper.write('#ifdef _M_X64\n\n') + java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') + java_wrapper.write(' T * NEW = (T*) jenv->GetLongArrayElements(OLD, NULL); \n') + java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') + java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') + java_wrapper.write('#else\n') + java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') + java_wrapper.write(' T * NEW = 0; { \\\n') + java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') + java_wrapper.write(' unsigned int size = jenv->GetArrayLength(OLD); \\\n') + java_wrapper.write(' NEW = (T*) (new int[size]); \\\n') + java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n') + java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') + java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n') + java_wrapper.write(' } \n\n') + java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') + java_wrapper.write(' delete [] NEW; \n\n') + java_wrapper.write('#endif\n') pkg_str = get_component('java').package_name.replace('.', '_') for name, result, params in _dotnet_decls: java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) From e87e0991f3856d88be501b448e70b0947dbae4c8 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 19:17:05 +0000 Subject: [PATCH 055/133] Java API: multi-platform fixes --- scripts/update_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index cdc1ba0f5..60ec37220 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -560,12 +560,12 @@ def mk_java(): java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('extern "C" {\n') java_wrapper.write('#endif\n\n') - java_wrapper.write('#ifdef _M_X64\n\n') + java_wrapper.write('#if defined(_M_X64) || defined(_AMD64_)\n\n') java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') java_wrapper.write(' T * NEW = (T*) jenv->GetLongArrayElements(OLD, NULL); \n') java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') - java_wrapper.write('#else\n') + java_wrapper.write('#else\n\n') java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') java_wrapper.write(' T * NEW = 0; { \\\n') java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') @@ -577,7 +577,7 @@ def mk_java(): java_wrapper.write(' } \n\n') java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write(' delete [] NEW; \n\n') - java_wrapper.write('#endif\n') + java_wrapper.write('#endif\n\n') pkg_str = get_component('java').package_name.replace('.', '_') for name, result, params in _dotnet_decls: java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) From caf14b96d4aca73435440da7ed39cb67d2d99563 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 11:30:20 -0800 Subject: [PATCH 056/133] moving to gparams... Signed-off-by: Leonardo de Moura --- src/api/api_config_params.cpp | 66 ++++++++--------------------------- src/api/api_config_params.h | 2 -- 2 files changed, 14 insertions(+), 54 deletions(-) diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 550212cf9..7a0303234 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -23,21 +23,14 @@ Revision History: #include"api_util.h" #include"cmd_context.h" #include"symbol.h" +#include"gparams.h" namespace api { - config_params::config_params(): - m_ini(false /* do not abort on errors */) { - register_verbosity_level(m_ini); - register_warning(m_ini); - m_params.register_params(m_ini); - register_pp_params(m_ini); + config_params::config_params() { } config_params::config_params(front_end_params const & p):m_params(p) { - register_verbosity_level(m_ini); - register_warning(m_ini); - register_pp_params(m_ini); } }; @@ -56,66 +49,35 @@ extern "C" { } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { + // REMARK: we don't need Z3_config anymore try { LOG_Z3_set_param_value(c, param_id, param_value); - api::config_params* p = reinterpret_cast(c); - if (param_id != 0 && param_id[0] == ':') { - // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); - p->m_ini.set_param_value(new_param_id.c_str(), param_value); - } - else { - p->m_ini.set_param_value(param_id, param_value); - } + gparams::set(param_id, param_value); } - catch (set_get_param_exception & ex) { + catch (gparams::exception & ex) { // The error handler was not set yet. // Just throw a warning. std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.get_msg(); + buffer << "Error setting " << param_id << ", " << ex.msg(); warning_msg(buffer.str().c_str()); } } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { + Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - ini_params ini; - mk_c(c)->fparams().register_params(ini); - register_pp_params(ini); - register_verbosity_level(ini); - register_warning(ini); - if (mk_c(c)->has_solver()) { - ini.freeze(); - } - if (param_id != 0 && param_id[0] == ':') { - // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); - ini.set_param_value(new_param_id.c_str(), param_value); - } - else { - ini.set_param_value(param_id, param_value); - } - memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); - memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); + gparams::set(param_id, param_value); + // TODO: set memory limits + // memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); + // memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); + Z3_CATCH; } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); - ini_params ini; - mk_c(c)->fparams().register_params(ini); - register_verbosity_level(ini); - register_pp_params(ini); - register_warning(ini); - std::string param_value_s; - if (!ini.get_param_value(param_id, param_value_s)) { - if (param_value) *param_value = 0; - return false; - } - if (param_value) { - *param_value = mk_c(c)->mk_external_string(param_value_s); - } - return true; + // TODO: we don't really have support for that anymore. + return false; } }; diff --git a/src/api/api_config_params.h b/src/api/api_config_params.h index 22e713c50..99ded289d 100644 --- a/src/api/api_config_params.h +++ b/src/api/api_config_params.h @@ -18,14 +18,12 @@ Revision History: #ifndef _API_CONFIG_PARAMS_H_ #define _API_CONFIG_PARAMS_H_ -#include"ini_file.h" #include"front_end_params.h" namespace api { class config_params { public: - ini_params m_ini; front_end_params m_params; config_params(); config_params(front_end_params const & p); From d13d6fecbf6d8251fb2bf5ca1a1fadd30bd6c463 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 19:43:34 +0000 Subject: [PATCH 057/133] Java API: added correct error handling. Signed-off-by: Christoph M. Wintersteiger --- scripts/update_api.py | 17 ++++++++++++++--- src/api/java/Context.java | 33 +++------------------------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 60ec37220..abd347a74 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -494,12 +494,12 @@ 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') + java_native.write(' public static native void setInternalErrorHandler(long ctx);\n\n') if IS_WINDOWS: java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) else: java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name - java_native.write('\n\n') + java_native.write('\n') for name, result, params in _dotnet_decls: java_native.write(' protected static native %s INTERNAL%s(' % (type2java(result), java_method_name(name))) first = True @@ -553,6 +553,7 @@ def mk_java(): java_native.write(' }\n\n') java_native.write('}\n') java_wrapper = open(java_wrapperf, 'w') + pkg_str = get_component('java').package_name.replace('.', '_') java_wrapper.write('// Automatically generated file\n') java_wrapper.write('#include\n') java_wrapper.write('#include\n') @@ -578,7 +579,17 @@ def mk_java(): java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write(' delete [] NEW; \n\n') java_wrapper.write('#endif\n\n') - pkg_str = get_component('java').package_name.replace('.', '_') + java_wrapper.write('void Z3JavaErrorHandler(Z3_context c, Z3_error_code e)\n') + java_wrapper.write('{\n') + java_wrapper.write(' // Internal do-nothing error handler. This is required to avoid that Z3 calls exit()\n') + java_wrapper.write(' // upon errors, but the actual error handling is done by throwing exceptions in the\n') + java_wrapper.write(' // wrappers below.\n') + java_wrapper.write('}\n\n') + java_wrapper.write('JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, long a0)\n' % pkg_str) + java_wrapper.write('{\n') + java_wrapper.write(' Z3_set_error_handler((Z3_context)a0, Z3JavaErrorHandler);\n') + java_wrapper.write('}\n\n') + java_wrapper.write('') for name, result, params in _dotnet_decls: java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name))) i = 0; diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 1d2f800ba..f375ab525 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -38,12 +38,11 @@ public class Context extends IDisposable InitContext(); } - private Context(long ctx, long refCount, Native.errorHandler errh) + private Context(long ctx, long refCount) { super(); this.m_ctx = ctx; this.m_refCount = refCount; - this.m_n_err_handler = errh; } /** @@ -2908,21 +2907,6 @@ public class Context extends IDisposable 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: @@ -2950,26 +2934,16 @@ public class Context extends IDisposable } 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); + Native.setInternalErrorHandler(nCtx()); } void CheckContextMatch(Z3Object other) throws Z3Exception @@ -3087,7 +3061,6 @@ public class Context extends IDisposable if (m_refCount == 0) { - m_n_err_handler = null; try { Native.delContext(m_ctx); @@ -3099,7 +3072,7 @@ public class Context extends IDisposable } else /* re-queue the finalizer */ /* BUG: DRQ's need to be taken over too! */ - new Context(m_ctx, m_refCount, m_n_err_handler); + new Context(m_ctx, m_refCount); } /** From 9b2236361c98feaee24b2e4a3c10506dcd1b5d8b Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 19:50:57 +0000 Subject: [PATCH 058/133] Java API: bugfix Signed-off-by: Christoph M. Wintersteiger --- scripts/update_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index abd347a74..f89764299 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -585,7 +585,7 @@ def mk_java(): java_wrapper.write(' // upon errors, but the actual error handling is done by throwing exceptions in the\n') java_wrapper.write(' // wrappers below.\n') java_wrapper.write('}\n\n') - java_wrapper.write('JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, long a0)\n' % pkg_str) + java_wrapper.write('JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, jlong a0)\n' % pkg_str) java_wrapper.write('{\n') java_wrapper.write(' Z3_set_error_handler((Z3_context)a0, Z3JavaErrorHandler);\n') java_wrapper.write('}\n\n') From 9246a7a6733104f067478eb1c26a16c85426dce3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 13:14:42 -0800 Subject: [PATCH 059/133] checkpoint Signed-off-by: Leonardo de Moura --- src/util/params.cpp | 138 +++++++++++++++++++++++++++++++++++++++----- src/util/params.h | 18 ++++-- 2 files changed, 138 insertions(+), 18 deletions(-) diff --git a/src/util/params.cpp b/src/util/params.cpp index b143a82dd..264149e4b 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -22,18 +22,35 @@ Notes: #include"dictionary.h" struct param_descrs::imp { - typedef std::pair info; + struct info { + param_kind m_kind; + char const * m_descr; + char const * m_default; + + info(param_kind k, char const * descr, char const * def): + m_kind(k), + m_descr(descr), + m_default(def) { + } + + info(): + m_kind(CPK_INVALID), + m_descr(0), + m_default(0) { + } + }; + dictionary m_info; svector m_names; - void insert(symbol const & name, param_kind k, char const * descr) { + void insert(symbol const & name, param_kind k, char const * descr, char const * def) { SASSERT(!name.is_numerical()); info i; if (m_info.find(name, i)) { - SASSERT(i.first == k); + SASSERT(i.m_kind == k); return; } - m_info.insert(name, info(k, descr)); + m_info.insert(name, info(k, descr, def)); m_names.push_back(name); } @@ -44,10 +61,24 @@ struct param_descrs::imp { param_kind get_kind(symbol const & name) const { info i; if (m_info.find(name, i)) - return i.first; + return i.m_kind; return CPK_INVALID; } + char const * get_descr(symbol const & name) const { + info i; + if (m_info.find(name, i)) + return i.m_descr; + return 0; + } + + char const * get_default(symbol const & name) const { + info i; + if (m_info.find(name, i)) + return i.m_default; + return 0; + } + unsigned size() const { return m_names.size(); } @@ -87,10 +118,12 @@ struct param_descrs::imp { out << s[i]; } info d; - d.second = 0; m_info.find(*it2, d); - SASSERT(d.second); - out << " (" << d.first << ") " << d.second << "\n"; + SASSERT(d.m_descr); + out << " (" << d.m_kind << ") " << d.m_descr; + if (d.m_default != 0) + out << " (default: " << d.m_default << ")"; + out << "\n"; } } @@ -98,7 +131,7 @@ struct param_descrs::imp { dictionary::iterator it = other.m_imp->m_info.begin(); dictionary::iterator end = other.m_imp->m_info.end(); for (; it != end; ++it) { - insert(it->m_key, it->m_value.first, it->m_value.second); + insert(it->m_key, it->m_value.m_kind, it->m_value.m_descr, it->m_value.m_default); } } @@ -116,12 +149,28 @@ void param_descrs::copy(param_descrs & other) { m_imp->copy(other); } -void param_descrs::insert(symbol const & name, param_kind k, char const * descr) { - m_imp->insert(name, k, descr); +void param_descrs::insert(symbol const & name, param_kind k, char const * descr, char const * def) { + m_imp->insert(name, k, descr, def); } -void param_descrs::insert(char const * name, param_kind k, char const * descr) { - insert(symbol(name), k, descr); +void param_descrs::insert(char const * name, param_kind k, char const * descr, char const * def) { + insert(symbol(name), k, descr, def); +} + +char const * param_descrs::get_descr(char const * name) const { + return get_descr(symbol(name)); +} + +char const * param_descrs::get_descr(symbol const & name) const { + return m_imp->get_descr(name); +} + +char const * param_descrs::get_default(char const * name) const { + return get_default(symbol(name)); +} + +char const * param_descrs::get_default(symbol const & name) const { + return m_imp->get_default(name); } void param_descrs::erase(symbol const & name) { @@ -235,6 +284,12 @@ public: symbol get_sym(symbol const & k, symbol const & _default) const; symbol get_sym(char const * k, symbol const & _default) const; + bool get_bool(char const * k, params_ref const & fallback, bool _default) const; + unsigned get_uint(char const * k, params_ref const & fallback, unsigned _default) const; + double get_double(char const * k, params_ref const & fallback, double _default) const; + char const * get_str(char const * k, params_ref const & fallback, char const * _default) const; + symbol get_sym(char const * k, params_ref const & fallback, symbol const & _default) const; + // setters void set_bool(symbol const & k, bool v); void set_bool(char const * k, bool v); @@ -372,7 +427,7 @@ void params_ref::copy_core(params const * src) { return; svector::const_iterator it = src->m_entries.begin(); svector::const_iterator end = src->m_entries.end(); - for (; it != end; ++it) { + for (; it != end; ++it) { switch (it->second.m_kind) { case CPK_BOOL: m_params->set_bool(it->first, it->second.m_bool_value); @@ -440,6 +495,26 @@ symbol params_ref::get_sym(char const * k, symbol const & _default) const { return m_params ? m_params->get_sym(k, _default) : _default; } +bool params_ref::get_bool(char const * k, params_ref const & fallback, bool _default) const { + return m_params ? m_params->get_bool(k, fallback, _default) : fallback.get_bool(k, _default); +} + +unsigned params_ref::get_uint(char const * k, params_ref const & fallback, unsigned _default) const { + return m_params ? m_params->get_uint(k, fallback, _default) : fallback.get_uint(k, _default); +} + +double params_ref::get_double(char const * k, params_ref const & fallback, double _default) const { + return m_params ? m_params->get_double(k, fallback, _default) : fallback.get_double(k, _default); +} + +char const * params_ref::get_str(char const * k, params_ref const & fallback, char const * _default) const { + return m_params ? m_params->get_str(k, fallback, _default) : fallback.get_str(k, _default); +} + +symbol params_ref::get_sym(char const * k, params_ref const & fallback, symbol const & _default) const { + return m_params ? m_params->get_sym(k, fallback, _default) : fallback.get_sym(k, _default); +} + bool params_ref::empty() const { if (!m_params) return true; @@ -684,6 +759,41 @@ symbol params::get_sym(char const * k, symbol const & _default) const { GET_VALUE(return symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);, CPK_SYMBOL); } +#define GET_VALUE2(MATCH_CODE, KIND) { \ + if (!empty()) { \ + TRAVERSE_CONST_ENTRIES(if (it->first == k && it->second.m_kind == KIND) { \ + MATCH_CODE \ + }); \ + } \ +} + +#define GET_SIMPLE_VALUE2(FIELD_NAME, KIND) GET_VALUE2(return it->second.FIELD_NAME;, KIND) + +bool params::get_bool(char const * k, params_ref const & fallback, bool _default) const { + GET_SIMPLE_VALUE2(m_bool_value, CPK_BOOL); + return fallback.get_bool(k, _default); +} + +unsigned params::get_uint(char const * k, params_ref const & fallback, unsigned _default) const { + GET_SIMPLE_VALUE2(m_uint_value, CPK_UINT); + return fallback.get_uint(k, _default); +} + +double params::get_double(char const * k, params_ref const & fallback, double _default) const { + GET_SIMPLE_VALUE2(m_double_value, CPK_DOUBLE); + return fallback.get_double(k, _default); +} + +char const * params::get_str(char const * k, params_ref const & fallback, char const * _default) const { + GET_SIMPLE_VALUE2(m_str_value, CPK_STRING); + return fallback.get_str(k, _default); +} + +symbol params::get_sym(char const * k, params_ref const & fallback, symbol const & _default) const { + GET_VALUE2(return symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);, CPK_SYMBOL); + return fallback.get_sym(k, _default); +} + #define SET_VALUE(MATCH_CODE, ADD_CODE) { \ TRAVERSE_ENTRIES(if (it->first == k) { \ MATCH_CODE \ diff --git a/src/util/params.h b/src/util/params.h index 616f316bd..747b23e39 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -38,10 +38,10 @@ public: params_ref & operator=(params_ref const & p); - // copy params from p + // copy params from src void copy(params_ref const & src); void append(params_ref const & src) { copy(src); } - + bool get_bool(symbol const & k, bool _default) const; bool get_bool(char const * k, bool _default) const; unsigned get_uint(symbol const & k, unsigned _default) const; @@ -55,6 +55,12 @@ public: symbol get_sym(symbol const & k, symbol const & _default) const; symbol get_sym(char const * k, symbol const & _default) const; + bool get_bool(char const * k, params_ref const & fallback, bool _default) const; + unsigned get_uint(char const * k, params_ref const & fallback, unsigned _default) const; + double get_double(char const * k, params_ref const & fallback, double _default) const; + char const * get_str(char const * k, params_ref const & fallback, char const * _default) const; + symbol get_sym(char const * k, params_ref const & fallback, symbol const & _default) const; + bool empty() const; bool contains(symbol const & k) const; bool contains(char const * k) const; @@ -101,12 +107,16 @@ public: param_descrs(); ~param_descrs(); void copy(param_descrs & other); - void insert(char const * name, param_kind k, char const * descr); - void insert(symbol const & name, param_kind k, char const * descr); + void insert(char const * name, param_kind k, char const * descr, char const * def = 0); + void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0); void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; param_kind get_kind(symbol const & name) const; + char const * get_descr(char const * name) const; + char const * get_descr(symbol const & name) const; + char const * get_default(char const * name) const; + char const * get_default(symbol const & name) const; void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false) const; unsigned size() const; symbol get_param_name(unsigned idx) const; From 692593baaa391ab747a08f3781224c22d26aa575 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 30 Nov 2012 22:31:07 +0000 Subject: [PATCH 060/133] Java API: 32-bit issues and bugfixes. Signed-off-by: Christoph M. Wintersteiger --- examples/java/JavaExample.java | 50 +++++++++++++++++++--------- scripts/update_api.py | 60 ++++++++++++++++++++++------------ src/api/java/AST.java | 39 +++++++++++++--------- src/api/java/Context.java | 2 +- src/api/java/EnumSort.java | 9 ++--- src/api/java/Quantifier.java | 15 +++++---- src/api/java/Sort.java | 13 +++++--- src/api/java/Z3Object.java | 2 +- 8 files changed, 119 insertions(+), 71 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 5d56a474b..d06f72217 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -907,11 +907,10 @@ class JavaExample // Error handling test. try { - IntExpr i = ctx.MkInt("0.5"); + IntExpr i = ctx.MkInt("1/2"); throw new TestFailedException(); // unreachable } catch (Z3Exception e) - { - System.out.println("GOT: " + e.getMessage()); + { } } @@ -1001,19 +1000,38 @@ class JavaExample } AST a = ctx.MkInt(42); - Expr ae = (a.getClass() == Expr.class) ? ((Expr) a) : null; - if (ae == null) + + try + { + Expr.class.cast(a); + } catch (ClassCastException e) + { throw new TestFailedException(); - ArithExpr aae = (a.getClass() == ArithExpr.class) ? ((ArithExpr) a) - : null; - if (aae == null) + } + + try + { + ArithExpr.class.cast(a); + } catch (ClassCastException e) + { throw new TestFailedException(); - IntExpr aie = (a.getClass() == IntExpr.class) ? ((IntExpr) a) : null; - if (aie == null) + } + + try + { + IntExpr.class.cast(a); + } catch (ClassCastException e) + { throw new TestFailedException(); - IntNum ain = (a.getClass() == IntNum.class) ? ((IntNum) a) : null; - if (ain == null) + } + + try + { + IntNum.class.cast(a); + } catch (ClassCastException e) + { throw new TestFailedException(); + } Expr[][] earr = new Expr[2][]; earr[0] = new Expr[2]; @@ -1585,7 +1603,7 @@ class JavaExample Symbol name = ctx.MkSymbol("fruit"); - EnumSort fruit = ctx.MkEnumSort(ctx.MkSymbol("fruit"), + EnumSort fruit = ctx.MkEnumSort(name, new Symbol[] { ctx.MkSymbol("apple"), ctx.MkSymbol("banana"), ctx.MkSymbol("orange") }); @@ -1974,7 +1992,7 @@ class JavaExample { int num_Exprs = to_minimize.length; int[] upper = new int[num_Exprs]; - int[] lower = new int[num_Exprs]; + int[] lower = new int[num_Exprs]; for (int i = 0; i < upper.length; ++i) { upper[i] = Integer.MAX_VALUE; @@ -2207,12 +2225,12 @@ class JavaExample { System.out.println("Z3 Managed Exception: " + ex.getMessage()); System.out.println("Stack trace: "); - ex.printStackTrace(System.out); + ex.printStackTrace(System.out); } catch (TestFailedException ex) { System.out.println("TEST CASE FAILED: " + ex.getMessage()); System.out.println("Stack trace: "); - ex.printStackTrace(System.out); + ex.printStackTrace(System.out); } catch (Exception ex) { System.out.println("Unknown Exception: " + ex.getMessage()); diff --git a/scripts/update_api.py b/scripts/update_api.py index f89764299..d7dbb7bcf 100644 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -474,11 +474,6 @@ def java_array_element_type(p): return 'jint' else: return 'jlong' -def java_set_array_region(p): - if param_type(p) == INT or param_type(p) == UINT: - return 'SetIntArrayRegion' - else: - return 'SetLongArrayRegion' def mk_java(): if not is_java_enabled(): @@ -563,21 +558,43 @@ def mk_java(): java_wrapper.write('#endif\n\n') java_wrapper.write('#if defined(_M_X64) || defined(_AMD64_)\n\n') java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') - java_wrapper.write(' T * NEW = (T*) jenv->GetLongArrayElements(OLD, NULL); \n') + java_wrapper.write(' T * NEW = (OLD == 0) ? 0 : (T*) jenv->GetLongArrayElements(OLD, NULL);\n') java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') - java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') + java_wrapper.write(' if (OLD != 0) jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') + java_wrapper.write('#define GETLONGAREGION(T,OLD,Z,SZ,NEW) \\\n') + java_wrapper.write(' jenv->GetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)NEW); \n') + java_wrapper.write('#define SETLONGAREGION(OLD,Z,SZ,NEW) \\\n') + java_wrapper.write(' jenv->SetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)NEW) \n\n') java_wrapper.write('#else\n\n') java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') java_wrapper.write(' T * NEW = 0; { \\\n') - java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') - java_wrapper.write(' unsigned int size = jenv->GetArrayLength(OLD); \\\n') - java_wrapper.write(' NEW = (T*) (new int[size]); \\\n') - java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n') - java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') - java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n') - java_wrapper.write(' } \n\n') - java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') + java_wrapper.write(' jlong * temp = (OLD == 0) ? 0 : jenv->GetLongArrayElements(OLD, NULL); \\\n') + java_wrapper.write(' unsigned int size = (OLD == 0) ? 0 :jenv->GetArrayLength(OLD); \\\n') + java_wrapper.write(' if (OLD != 0) { \\\n') + java_wrapper.write(' NEW = (T*) (new int[size]); \\\n') + java_wrapper.write(' for (unsigned i=0; i < size; i++) \\\n') + java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') + java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, temp, JNI_ABORT); \\\n') + java_wrapper.write(' } \\\n') + java_wrapper.write(' } \n\n') + java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write(' delete [] NEW; \n\n') + java_wrapper.write('#define GETLONGAREGION(T,OLD,Z,SZ,NEW) \\\n') + java_wrapper.write(' { \\\n') + java_wrapper.write(' jlong * temp = new jlong[SZ]; \\\n') + java_wrapper.write(' jenv->GetLongArrayRegion(OLD,Z,(jsize)SZ,(jlong*)temp); \\\n') + java_wrapper.write(' for (int i = 0; i < (SZ); i++) \\\n') + java_wrapper.write(' NEW[i] = reinterpret_cast(temp[i]); \\\n') + java_wrapper.write(' delete [] temp; \\\n') + java_wrapper.write(' }\n\n') + java_wrapper.write('#define SETLONGAREGION(OLD,Z,SZ,NEW) \\\n') + java_wrapper.write(' { \\\n') + java_wrapper.write(' jlong * temp = new jlong[SZ]; \\\n') + java_wrapper.write(' for (int i = 0; i < (SZ); i++) \\\n') + java_wrapper.write(' temp[i] = reinterpret_cast(NEW[i]); \\\n') + java_wrapper.write(' jenv->SetLongArrayRegion(OLD,Z,(jsize)SZ,temp); \\\n') + java_wrapper.write(' delete [] temp; \\\n') + java_wrapper.write(' }\n\n') java_wrapper.write('#endif\n\n') java_wrapper.write('void Z3JavaErrorHandler(Z3_context c, Z3_error_code e)\n') java_wrapper.write('{\n') @@ -615,6 +632,10 @@ def mk_java(): type2str(param_type(param)), param_array_capacity_pos(param), type2str(param_type(param)))) + if param_type(param) == INT or param_type(param) == UINT: + java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i)) + else: + java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i)) elif k == IN and param_type(param) == STRING: java_wrapper.write(' Z3_string _a%s = (Z3_string) jenv->GetStringUTFChars(a%s, NULL);\n' % (i, i)) i = i + 1 @@ -646,11 +667,10 @@ def mk_java(): for param in params: k = param_kind(param) if k == OUT_ARRAY: - java_wrapper.write(' jenv->%s(a%s, 0, (jsize)a%s, (%s *) _a%s);\n' % (java_set_array_region(param), - i, - param_array_capacity_pos(param), - java_array_element_type(param), - i)) + if param_type(param) == INT or param_type(param) == UINT: + java_wrapper.write(' jenv->SetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i)) + else: + java_wrapper.write(' SETLONGAREGION(a%s, 0, a%s, _a%s);\n' % (i, param_array_capacity_pos(param), i)) java_wrapper.write(' free(_a%s);\n' % i) elif k == IN_ARRAY or k == OUT_ARRAY: if param_type(param) == INT or param_type(param) == UINT: diff --git a/src/api/java/AST.java b/src/api/java/AST.java index fbefbf5e2..418c43e9f 100644 --- a/src/api/java/AST.java +++ b/src/api/java/AST.java @@ -37,10 +37,15 @@ public class AST extends Z3Object **/ public boolean equals(Object o) { - AST casted = (AST) o; - if (casted == null) - return false; - return this == casted; + AST casted = null; + + try { + casted = AST.class.cast(o); + } catch (ClassCastException e) { + return false; + } + + return this.NativeObject() == casted.NativeObject(); } /** @@ -53,18 +58,20 @@ public class AST extends Z3Object { 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; - } + + AST oAST = null; + try { + AST.class.cast(other); + } catch (ClassCastException e) { + return 1; + } + + if (Id() < oAST.Id()) + return -1; + else if (Id() > oAST.Id()) + return +1; + else + return 0; } /** diff --git a/src/api/java/Context.java b/src/api/java/Context.java index f375ab525..d6076b5ee 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -524,7 +524,7 @@ public class Context extends IDisposable public Expr MkConst(FuncDecl f) throws Z3Exception { - return MkApp(f, (Expr) null); + return MkApp(f, (Expr[]) null); } /** diff --git a/src/api/java/EnumSort.java b/src/api/java/EnumSort.java index f02301a5d..10f0f9764 100644 --- a/src/api/java/EnumSort.java +++ b/src/api/java/EnumSort.java @@ -16,7 +16,6 @@ public class EnumSort extends Sort **/ public FuncDecl[] ConstDecls() { - return _constdecls; } @@ -25,7 +24,6 @@ public class EnumSort extends Sort **/ public Expr[] Consts() { - return _consts; } @@ -34,7 +32,6 @@ public class EnumSort extends Sort **/ public FuncDecl[] TesterDecls() { - return _testerdecls; } @@ -53,12 +50,12 @@ public class EnumSort extends Sort n_constdecls, n_testers)); _constdecls = new FuncDecl[n]; for (int i = 0; i < n; i++) - _constdecls[i] = new FuncDecl(ctx, n_constdecls[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]); + _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], (Expr)null); + _consts[i] = ctx.MkApp(_constdecls[i], (Expr[])null); } }; diff --git a/src/api/java/Quantifier.java b/src/api/java/Quantifier.java index 82e5a958b..6ee7e4412 100644 --- a/src/api/java/Quantifier.java +++ b/src/api/java/Quantifier.java @@ -159,13 +159,14 @@ public class Quantifier extends BoolExpr .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())); + 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())); } } diff --git a/src/api/java/Sort.java b/src/api/java/Sort.java index 526329146..fcf6b117a 100644 --- a/src/api/java/Sort.java +++ b/src/api/java/Sort.java @@ -39,10 +39,15 @@ public class Sort extends AST **/ public boolean equals(Object o) { - Sort casted = (Sort) o; - if (casted == null) - return false; - return this == casted; + Sort casted = null; + + try { + casted = Sort.class.cast(o); + } catch (ClassCastException e) { + return false; + } + + return this.NativeObject() == casted.NativeObject(); } /** diff --git a/src/api/java/Z3Object.java b/src/api/java/Z3Object.java index 877fead79..8aeb03ddf 100644 --- a/src/api/java/Z3Object.java +++ b/src/api/java/Z3Object.java @@ -104,7 +104,7 @@ public class Z3Object extends IDisposable return null; long[] an = new long[a.length]; for (int i = 0; i < a.length; i++) - an[i] = a[i].NativeObject(); + an[i] = (a[i] == null) ? 0 : a[i].NativeObject(); return an; } From 4f9442864a846d5b934157a6c6b38e696fc0c04d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 15:31:40 -0800 Subject: [PATCH 061/133] auto generation of parameter helper Signed-off-by: Leonardo de Moura --- .gitignore | 2 + scripts/mk_util.py | 97 ++++++++++++++++++++++++++++++++++++-- src/nlsat/nlsat_params.pyg | 13 +++++ src/nlsat/nlsat_solver.cpp | 33 ++++++------- 4 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 src/nlsat/nlsat_params.pyg diff --git a/.gitignore b/.gitignore index 3fe56e9f3..3d6e631f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *~ *.pyc +# .hpp files are automatically generated +*.hpp .z3-trace # OCaml generated files *.a diff --git a/scripts/mk_util.py b/scripts/mk_util.py index e449f9c0f..782990cd7 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1420,11 +1420,102 @@ def mk_makefile(): # Generate automatically generated source code def mk_auto_src(): if not ONLY_MAKEFILES: + exec_pyg_scripts() mk_pat_db() mk_all_install_tactic_cpps() mk_all_mem_initializer_cpps() mk_all_gparams_register_modules() +UINT = 0 +BOOL = 1 +DOUBLE = 2 +STRING = 3 +SYMBOL = 4 +UINT_MAX = 4294967295 +CURR_PYG = None + +def get_curr_pyg(): + return CURR_PYG + +TYPE2CPK = { UINT : 'CPK_UINT', BOOL : 'CPK_BOOL', DOUBLE : 'CPK_DOUBLE', STRING : 'CPK_STRING', SYMBOL : 'CPK_SYMBOL' } +TYPE2CTYPE = { UINT : 'unsigned', BOOL : 'bool', DOUBLE : 'double', STRING : 'char const *', SYMBOL : 'symbol' } +TYPE2GETTER = { UINT : 'get_uint', BOOL : 'get_bool', DOUBLE : 'get_double', STRING : 'get_str', SYMBOL : 'get_sym' } + +def pyg_default(p): + if p[1] == BOOL: + if p[2]: + return "true" + else: + return "false" + return p[2] + +def pyg_default_as_c_literal(p): + if p[1] == BOOL: + if p[2]: + return "true" + else: + return "false" + elif p[1] == STRING: + return '"%s"' % p[2] + elif p[1] == SYMBOL: + return 'symbol("%s")' % p[2] + return p[2] + +def def_module_params(module_name, export, params): + pyg = get_curr_pyg() + hpp = '%shpp' % pyg[:len(pyg)-3] + out = open(hpp, 'w') + out.write('// Automatically generated file\n') + out.write('#include"params.h"\n') + if export: + out.write('#include"gparams.h"\n') + out.write('struct %s_params {\n' % module_name) + out.write(' params_ref const & p;\n') + if export: + out.write(' params_ref const & g;\n') + out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) + out.write(' p(_p)') + if export: + out.write(', g(gparams::get_module("%s"))' % module_name) + out.write(' {}\n') + out.write(' static void collect_param_descrs(param_descrs & d) {\n') + for param in params: + out.write(' d.insert("%s", %s, "%s", "%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param))) + out.write(' }\n') + if export: + out.write(' /*\n') + out.write(" REG_MODULE_PARAMS('%s', '%s_params::collect_param_descrs')\n" % (module_name, module_name)) + out.write(' */\n') + # Generated accessors + for param in params: + if export: + out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' % + (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + else: + out.write(' %s %s() const { return p.%s("%s", %s); }\n' % + (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + out.write('};\n') + if is_verbose(): + print "Generated '%s'" % hpp + +def max_memory_param(): + return ('max_memory', UINT, UINT_MAX, 'maximum amount of memory in megabytes.') + +PYG_GLOBALS = { 'UINT' : UINT, 'BOOL' : BOOL, 'DOUBLE' : DOUBLE, 'STRING' : STRING, 'SYMBOL' : SYMBOL, + 'UINT_MAX' : UINT_MAX, + 'max_memory_param' : max_memory_param, + 'def_module_params' : def_module_params } + +# Execute python auxiliary scripts that generate extra code for Z3. +def exec_pyg_scripts(): + global CURR_PYG + for root, dirs, files in os.walk('src'): + for f in files: + if f.endswith('.pyg'): + script = os.path.join(root, f) + CURR_PYG = script + execfile(script, PYG_GLOBALS) + # TODO: delete after src/ast/pattern/expr_pattern_match # database.smt ==> database.h def mk_pat_db(): @@ -1548,7 +1639,7 @@ def mk_install_tactic_cpp(cnames, path): probe_pat = re.compile('[ \t]*ADD_PROBE\(.*\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') @@ -1613,7 +1704,7 @@ def mk_mem_initializer_cpp(cnames, path): finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') @@ -1674,7 +1765,7 @@ def mk_gparams_register_modules(cnames, path): reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') diff --git a/src/nlsat/nlsat_params.pyg b/src/nlsat/nlsat_params.pyg new file mode 100644 index 000000000..2728e1180 --- /dev/null +++ b/src/nlsat/nlsat_params.pyg @@ -0,0 +1,13 @@ + +def_module_params('nlsat', + export=True, + params=(max_memory_param(), + ('lazy', UINT, 0, "how lazy the solver is."), + ('reorder', BOOL, True, "reorder variables."), + ('simplify_conflicts', BOOL, True, "simplify conflicts using equalities before resolving them in nlsat solver."), + ('minimize_conflicts', BOOL, False, "minimize conflicts"), + ('randomize', BOOL, True, "randomize selection of a witness in nlsat."), + ('max_conflicts', UINT, UINT_MAX, "maximum number of conflicts."), + ('shuffle_vars', BOOL, False, "use a random variable order."), + ('seed', UINT, 0, "random seed."))) + diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index d76d584f7..341431556 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -31,6 +31,7 @@ Revision History: #include"dependency.h" #include"polynomial_cache.h" #include"permutation.h" +#include"nlsat_params.hpp" #define NLSAT_EXTRA_VERBOSE @@ -197,20 +198,21 @@ namespace nlsat { mk_clause(1, &true_lit, false, 0); } - void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - m_lazy = p.get_uint("lazy", 0); - m_simplify_cores = p.get_bool("simplify_conflicts", true); - bool min_cores = p.get_bool("minimize_conflicts", false); - m_reorder = p.get_bool("reorder", true); - m_randomize = p.get_bool("randomize", true); - m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); - m_random_order = p.get_bool("shuffle_vars", false); - m_random_seed = p.get_uint("seed", 0); + void updt_params(params_ref const & _p) { + nlsat_params p(_p); + m_max_memory = p.max_memory(); + m_lazy = p.lazy(); + m_simplify_cores = p.simplify_conflicts(); + bool min_cores = p.minimize_conflicts(); + m_reorder = p.reorder(); + m_randomize = p.randomize(); + m_max_conflicts = p.max_conflicts(); + m_random_order = p.shuffle_vars(); + m_random_seed = p.seed(); m_ism.set_seed(m_random_seed); m_explain.set_simplify_cores(m_simplify_cores); m_explain.set_minimize_cores(min_cores); - m_am.updt_params(p); + m_am.updt_params(p.p); } void set_cancel(bool f) { @@ -2570,15 +2572,8 @@ namespace nlsat { } void solver::collect_param_descrs(param_descrs & d) { - insert_max_memory(d); algebraic_numbers::manager::collect_param_descrs(d); - d.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - d.insert("shuffle_vars", CPK_BOOL, "(default: false) use a variable order."); - d.insert("seed", CPK_UINT, "(default: 0) random seed."); - d.insert("randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); - d.insert("reorder", CPK_BOOL, "(default: true) reorder variables."); - d.insert("lazy", CPK_UINT, "(default: 0) how lazy the solver is."); - d.insert("simplify_conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); + nlsat_params::collect_param_descrs(d); } unsynch_mpq_manager & solver::qm() { From 2d1a6bf270df9611453abfdc0822f40e3da1b25e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 30 Nov 2012 15:58:06 -0800 Subject: [PATCH 062/133] fix regression for simplifying tails with quantifiers, add some more handling for quantified tails Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 5 +- src/muz_qe/dl_context.cpp | 2 +- src/muz_qe/dl_mk_interp_tail_simplifier.cpp | 2 +- src/muz_qe/dl_util.h | 5 + src/muz_qe/expr_safe_replace.cpp | 102 +++ src/muz_qe/expr_safe_replace.h | 43 + src/muz_qe/pdr_quantifiers.cpp | 433 +++++----- src/muz_qe/pdr_quantifiers.h | 32 +- src/muz_qe/qe_lite.cpp | 889 ++++++++++---------- src/muz_qe/qe_lite.h | 2 +- 10 files changed, 888 insertions(+), 627 deletions(-) create mode 100644 src/muz_qe/expr_safe_replace.cpp create mode 100644 src/muz_qe/expr_safe_replace.h diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 3c98dca33..67f07e414 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -2637,12 +2637,13 @@ proof * ast_manager::mk_unit_resolution(unsigned num_proofs, proof * const * pro ptr_buffer args; args.append(num_proofs, (expr**) proofs); expr * fact; - expr const * f1 = get_fact(proofs[0]); - expr const * f2 = get_fact(proofs[1]); + expr * f1 = get_fact(proofs[0]); + expr * f2 = get_fact(proofs[1]); if (num_proofs == 2 && is_complement(f1, f2)) { fact = mk_false(); } else { + CTRACE("mk_unit_resolution_bug", !is_or(f1), tout << mk_pp(f1, *this) << " " << mk_pp(f2, *this) << "\n";); SASSERT(is_or(f1)); ptr_buffer new_lits; app const * cls = to_app(f1); diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 3818b1955..48242a7ed 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -1769,7 +1769,7 @@ namespace datalog { if (use_fixedpoint_extensions) { for (unsigned i = 0; i < num_queries; ++i) { out << "(query "; - PP(queries[i]); + PP(queries[i]); out << ")\n"; } } diff --git a/src/muz_qe/dl_mk_interp_tail_simplifier.cpp b/src/muz_qe/dl_mk_interp_tail_simplifier.cpp index aa11d1b36..9861c48ca 100644 --- a/src/muz_qe/dl_mk_interp_tail_simplifier.cpp +++ b/src/muz_qe/dl_mk_interp_tail_simplifier.cpp @@ -463,7 +463,7 @@ namespace datalog { if (r->has_quantifiers()) { res = r; - return false; + return true; } start: diff --git a/src/muz_qe/dl_util.h b/src/muz_qe/dl_util.h index f314b691d..12ed004ef 100644 --- a/src/muz_qe/dl_util.h +++ b/src/muz_qe/dl_util.h @@ -191,6 +191,11 @@ namespace datalog { scoped_coarse_proof(ast_manager& m): scoped_proof_mode(m, PGM_COARSE) {} }; + class scoped_fine_proof : public scoped_proof_mode { + public: + scoped_fine_proof(ast_manager& m): scoped_proof_mode(m, PGM_FINE) {} + }; + class scoped_no_proof : public scoped_proof_mode { public: scoped_no_proof(ast_manager& m): scoped_proof_mode(m, PGM_DISABLED) {} diff --git a/src/muz_qe/expr_safe_replace.cpp b/src/muz_qe/expr_safe_replace.cpp new file mode 100644 index 000000000..b3b4d5138 --- /dev/null +++ b/src/muz_qe/expr_safe_replace.cpp @@ -0,0 +1,102 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + expr_safe_replace.cpp + +Abstract: + + Version of expr_replace/expr_substitution that is safe for quantifiers. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-30 + +Revision History: + + +--*/ + +#include "expr_safe_replace.h" +#include "rewriter.h" + + +void expr_safe_replace::insert(expr* src, expr* dst) { + m_src.push_back(src); + m_dst.push_back(dst); + m_subst.insert(src, dst); +} + +void expr_safe_replace::operator()(expr* e, expr_ref& res) { + obj_map cache; + ptr_vector todo, args; + expr_ref_vector refs(m); + todo.push_back(e); + expr* a, *b, *d; + todo.push_back(e); + + while (!todo.empty()) { + a = todo.back(); + if (cache.contains(a)) { + todo.pop_back(); + } + else if (m_subst.find(a, b)) { + cache.insert(a, b); + todo.pop_back(); + } + else if (is_var(a)) { + cache.insert(a, a); + todo.pop_back(); + } + else if (is_app(a)) { + app* c = to_app(a); + unsigned n = c->get_num_args(); + args.reset(); + for (unsigned i = 0; i < n; ++i) { + if (cache.find(c->get_arg(i), d)) { + args.push_back(d); + } + else { + todo.push_back(c->get_arg(i)); + } + } + if (args.size() == n) { + b = m.mk_app(c->get_decl(), args.size(), args.c_ptr()); + refs.push_back(b); + cache.insert(a, b); + todo.pop_back(); + } + } + else { + SASSERT(is_quantifier(a)); + quantifier* q = to_quantifier(a); + expr_safe_replace replace(m); + var_shifter shift(m); + expr_ref new_body(m), src(m), dst(m), tmp(m); + expr_ref_vector pats(m), nopats(m); + unsigned num_decls = q->get_num_decls(); + for (unsigned i = 0; i < m_src.size(); ++i) { + shift(m_src[i].get(), num_decls, src); + shift(m_dst[i].get(), num_decls, dst); + replace.insert(src, dst); + } + unsigned np = q->get_num_patterns(); + for (unsigned i = 0; i < np; ++i) { + replace(q->get_pattern(i), tmp); + pats.push_back(tmp); + } + np = q->get_num_no_patterns(); + for (unsigned i = 0; i < np; ++i) { + replace(q->get_no_pattern(i), tmp); + nopats.push_back(tmp); + } + replace(q->get_expr(), new_body); + b = m.update_quantifier(q, pats.size(), pats.c_ptr(), nopats.size(), nopats.c_ptr(), new_body); + refs.push_back(b); + cache.insert(a, b); + todo.pop_back(); + } + } + res = cache.find(e); +} diff --git a/src/muz_qe/expr_safe_replace.h b/src/muz_qe/expr_safe_replace.h new file mode 100644 index 000000000..6af819596 --- /dev/null +++ b/src/muz_qe/expr_safe_replace.h @@ -0,0 +1,43 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + expr_safe_replace.h + +Abstract: + + Version of expr_replace/expr_substitution that is safe for quantifiers. + + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-30 + +Revision History: + + +--*/ + +#ifndef __EXPR_SAFE_REPLACE_H__ +#define __EXPR_SAFE_REPLACE_H__ + +#include "ast.h" + +class expr_safe_replace { + ast_manager& m; + expr_ref_vector m_src; + expr_ref_vector m_dst; + obj_map m_subst; + +public: + expr_safe_replace(ast_manager& m): m(m), m_src(m), m_dst(m) {} + + void insert(expr* src, expr* dst); + + void operator()(expr_ref& e) { (*this)(e.get(), e); } + + void operator()(expr* src, expr_ref& e); +}; + +#endif /* __EXPR_SAFE_REPLACE_H__ */ diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index b681b0121..7922b76c9 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -27,6 +27,9 @@ Revision History: #include "ast_smt_pp.h" #include "expr_abstract.h" #include "dl_mk_extract_quantifiers.h" +#include "qe_lite.h" +#include "well_sorted.h" +#include "expr_safe_replace.h" namespace pdr { @@ -49,6 +52,12 @@ namespace pdr { } } + quantifier_model_checker::~quantifier_model_checker() { + obj_map::iterator it = m_reachable.begin(), end = m_reachable.end(); + for (; it != end; ++it) { + m.dec_ref(it->m_value); + } + } void quantifier_model_checker::generalize_binding(expr_ref_vector const& binding, vector& bindings) { expr_ref_vector new_binding(m); @@ -193,13 +202,12 @@ namespace pdr { bool quantifier_model_checker::find_instantiations_proof_based(quantifier_ref_vector const& qs, unsigned level) { bool found_instance = false; - TRACE("pdr", tout << mk_pp(m_A,m) << "\n";); - datalog::scoped_coarse_proof _scp(m); + datalog::scoped_fine_proof _scp(m); expr_ref_vector fmls(m); front_end_params fparams; - fparams.m_proof_mode = PGM_COARSE; + fparams.m_proof_mode = PGM_FINE; fparams.m_mbqi = true; fmls.push_back(m_A.get()); @@ -209,15 +217,20 @@ namespace pdr { for (unsigned i = 0; i < fmls.size(); ++i) { tout << mk_pp(fmls[i].get(), m) << "\n"; }); + smt::kernel solver(m, fparams); for (unsigned i = 0; i < fmls.size(); ++i) { solver.assert_expr(fmls[i].get()); } lbool result = solver.check(); + + TRACE("pdr", tout << result << "\n";); + if (result != l_false) { - TRACE("pdr", tout << result << "\n";); - return found_instance; + return false; } + m_rules_model_check = false; + map qid_map; quantifier* q; for (unsigned i = 0; i < qs.size(); ++i) { @@ -234,8 +247,7 @@ namespace pdr { for (unsigned i = 0; i < collector.size(); ++i) { symbol qid = quants[i]->get_qid(); if (!qid_map.find(qid, q)) { - TRACE("pdr", tout << "Could not find quantifier " - << mk_pp(quants[i], m) << "\n";); + TRACE("pdr", tout << "Could not find quantifier " << mk_pp(quants[i], m) << "\n";); continue; } expr_ref_vector const& binding = collector.bindings()[i]; @@ -256,8 +268,43 @@ namespace pdr { return found_instance; } + /** - Given node: + For under-approximations: + + m_reachable: set of reachable states, per predicate + + rules: P(x) :- B[x,y] & Fa z . Q(y,z) + Q(y,z) :- C[y,z,u] & Fa w . R(u,w) + + qis: Fa z . Q(y,z) + + M: model satisfying P(x) & B[x,y] + + B'[x,y]: body with reachable states substituted for predicates. + + Q'[y,z]: reachable states substituted for Q. + + S'[x]: Ex y . B'[x,y] & Fa z . Q'[y, z] + + Method: + + 1. M |= Fa z . Q'[y, z] => done + + Weaker variant: + Check B[x,y] & Fa z . Q'[y, z] for consistency. + + 2. Otherwise, extract instantiations. + + 3. Update reachable (for next round): + + Q'[y,z] := Q'[y,z] \/ C'[y,z,u] & Fa w . R'(u,w) + + */ + + + /** + For over-approximations: - pt - predicate transformer for rule: P(x) :- Body1(x,y) || Body2(x,z) & (Fa u . Q(u,x,z)). @@ -267,22 +314,201 @@ namespace pdr { - 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::update_reachable(func_decl* f, expr* e) { + expr* e_old; + m.inc_ref(e); + if (m_reachable.find(f, e_old)) { + m.dec_ref(e_old); + } + m_reachable.insert(f, e); + } + + + expr_ref quantifier_model_checker::get_reachable(func_decl* p) { + expr* e = 0; + if (!m_reachable.find(p, e)) { + e = m_ctx.get_pred_transformer(p).initial_state(); + update_reachable(p, e); + } + return expr_ref(e, m); + } + + void quantifier_model_checker::add_over_approximations(quantifier_ref_vector& qis, model_node& n) { + add_approximations(qis, n, true); + } + + void quantifier_model_checker::add_under_approximations(quantifier_ref_vector& qis, model_node& n) { + add_approximations(qis, n, false); + } + + void quantifier_model_checker::add_approximations(quantifier_ref_vector& qis, model_node& n, bool is_over) { + pred_transformer& pt = n.pt(); + manager& pm = pt.get_pdr_manager(); + unsigned level = n.level(); + expr_ref_vector Bs(m); + expr_ref B(m), v(m); + quantifier_ref q(m); + datalog::scoped_no_proof _no_proof(m); + scoped_ptr rep = mk_default_expr_replacer(m); + for (unsigned j = 0; j < qis.size(); ++j) { + q = qis[j].get(); + app_ref_vector& inst = pt.get_inst(m_current_rule); + TRACE("pdr", + tout << "q:\n" << mk_pp(q, m) << "\n"; + tout << "level: " << level << "\n"; + model_smt2_pp(tout, m, n.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); + if (is_over) { + B = pt2.get_formulas(level - 1, false); + } + else { + B = get_reachable(f); + SASSERT(is_well_sorted(m, B)); + } + TRACE("pdr", tout << "B:\n" << mk_pp(B, m) << "\n";); + + expr_safe_replace sub(m); + for (unsigned i = 0; i < a->get_num_args(); ++i) { + v = m.mk_const(pm.o2n(pt2.sig(i),0)); + sub.insert(v, a->get_arg(i)); + } + sub(B); + TRACE("pdr", tout << "B substituted:\n" << mk_pp(B, m) << "\n";); + datalog::flatten_and(B, Bs); + for (unsigned i = 0; i < Bs.size(); ++i) { + m_Bs.push_back(m.update_quantifier(q, Bs[i].get())); + } + } + } + + /** + \brief compute strongest post-conditions for each predicate transformer. + (or at least something sufficient to change the set of current counter-examples) + */ + void quantifier_model_checker::weaken_under_approximation() { + + datalog::rule_set::decl2rules::iterator it = m_rules.begin_grouped_rules(), end = m_rules.end_grouped_rules(); + + for (; it != end; ++it) { + func_decl* p = it->m_key; + datalog::rule_vector& rules = *it->m_value; + expr_ref_vector bodies(m); + for (unsigned i = 0; i < rules.size(); ++i) { + bodies.push_back(strongest_post_condition(*rules[i])); + } + update_reachable(p, m.mk_or(bodies.size(), bodies.c_ptr())); + } + } + + expr_ref quantifier_model_checker::strongest_post_condition(datalog::rule& r) { + pred_transformer& pt = m_ctx.get_pred_transformer(r.get_decl()); + manager& pm = pt.get_pdr_manager(); + quantifier_ref_vector* qis = 0; + m_quantifiers.find(&r, qis); + expr_ref_vector body(m), inst(m); + expr_ref fml(m), v(m); + app* a; + func_decl* p; + svector names; + unsigned ut_size = r.get_uninterpreted_tail_size(); + unsigned t_size = r.get_tail_size(); + var_subst vs(m, false); + sort_ref_vector vars(m); + r.get_vars(vars); + if (qis) { + quantifier_ref_vector const& qi = *qis; + for (unsigned i = 0; i < qi.size(); ++i) { + fml = qi[i]->get_expr(); + a = to_app(fml); + p = a->get_decl(); + expr* p_reach = get_reachable(p); + pred_transformer& pt2 = m_ctx.get_pred_transformer(p); + expr_safe_replace sub(m); + for (unsigned j = 0; j < a->get_num_args(); ++j) { + v = m.mk_const(pm.o2n(pt2.sig(j),0)); + sub.insert(v, a->get_arg(j)); + } + sub(p_reach, fml); + body.push_back(m.update_quantifier(qi[i], fml)); + } + } + a = r.get_head(); + for (unsigned i = 0; i < a->get_num_args(); ++i) { + v = m.mk_var(vars.size()+i, m.get_sort(a->get_arg(i))); + body.push_back(m.mk_eq(v, a->get_arg(i))); + } + for (unsigned i = 0; i < ut_size; ++i) { + a = r.get_tail(i); + p = a->get_decl(); + pred_transformer& pt2 = m_ctx.get_pred_transformer(p); + expr* p_reach = get_reachable(p); + expr_safe_replace sub(m); + for (unsigned i = 0; i < a->get_num_args(); ++i) { + v = m.mk_const(pm.o2n(pt2.sig(i),0)); + sub.insert(v, a->get_arg(i)); + } + sub(p_reach, fml); + body.push_back(fml); + } + for (unsigned i = ut_size; i < t_size; ++i) { + body.push_back(r.get_tail(i)); + } + fml = m.mk_and(body.size(), body.c_ptr()); + vars.reverse(); + for (unsigned i = 0; i < vars.size(); ++i) { + names.push_back(symbol(i)); + } + if (!vars.empty()) { + fml = m.mk_exists(vars.size(), vars.c_ptr(), names.c_ptr(), fml); + SASSERT(is_well_sorted(m, fml)); + } + + for (unsigned i = 0; i < r.get_head()->get_num_args(); ++i) { + inst.push_back(m.mk_const(pm.o2n(pt.sig(i),0))); + } + vs(fml, inst.size(), inst.c_ptr(), fml); + SASSERT(is_well_sorted(m, fml)); + if (!vars.empty()) { + fml = to_quantifier(fml)->get_expr(); + uint_set empty_index_set; + qe_lite qe(m); + qe(empty_index_set, false, fml); + fml = m.mk_exists(vars.size(), vars.c_ptr(), names.c_ptr(), fml); + SASSERT(is_well_sorted(m, fml)); + m_ctx.get_context().get_rewriter()(fml); + } + SASSERT(is_well_sorted(m, fml)); + + IF_VERBOSE(0, verbose_stream() << "instantiate to\n:" << mk_pp(fml, m) << "\n";); + return fml; + } + 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), v(m); - expr_ref_vector As(m), Bs(m); + expr_ref A(m), C(m); + expr_ref_vector As(m); m_Bs.reset(); // // nodes from leaves that are repeated @@ -307,8 +533,6 @@ namespace pdr { 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()); @@ -316,48 +540,8 @@ namespace pdr { m_A = pm.mk_and(As); // Add quantifiers: - - { - 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) { - q = (*qis)[j].get(); - app_ref_vector& inst = pt.get_inst(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, false); - TRACE("pdr", tout << "B:\n" << mk_pp(B, m) << "\n";); - - - expr_substitution sub(m); - for (unsigned i = 0; i < a->get_num_args(); ++i) { - v = m.mk_const(pm.o2n(pt2.sig(i),0)); - sub.insert(v, a->get_arg(i)); - } - rep->set_substitution(&sub); - (*rep)(B); - TRACE("pdr", tout << "B substituted:\n" << mk_pp(B, m) << "\n";); - datalog::flatten_and(B, Bs); - for (unsigned i = 0; i < Bs.size(); ++i) { - m_Bs.push_back(m.update_quantifier(q, Bs[i].get())); - } - } - } + // add_over_approximations(*qis, node); + add_under_approximations(*qis, node); TRACE("pdr", tout << "A:\n" << mk_pp(m_A, m) << "\n"; @@ -384,13 +568,17 @@ namespace pdr { bool quantifier_model_checker::model_check(model_node& root) { m_instantiations.reset(); m_instantiated_rules.reset(); + m_rules_model_check = true; ptr_vector nodes; get_nodes(root, nodes); for (unsigned i = nodes.size(); i > 0; ) { --i; model_check_node(*nodes[i]); } - return m_instantiations.empty(); + if (!m_rules_model_check) { + weaken_under_approximation(); + } + return m_rules_model_check; } void quantifier_model_checker::refine() { @@ -446,136 +634,3 @@ namespace pdr { } }; - -#if 0 - // - // Build: - // - // A & forall x . B1 & forall y . B2 & ... - // = - // not exists x y . (!A or !B1 or !B2 or ...) - // - // Find an instance that satisfies formula. - // (or find all instances?) - // - bool quantifier_model_checker::find_instantiations_qe_based(quantifier_ref_vector const& qs, unsigned level) { - expr_ref_vector fmls(m), conjs(m), fresh_vars(m); - app_ref_vector all_vars(m); - expr_ref C(m); - qe::def_vector defs(m); - front_end_params fparams; - qe::expr_quant_elim qe(m, fparams); - for (unsigned i = 0; i < m_Bs.size(); ++i) { - quantifier* q = qs[i]; - unsigned num_decls = q->get_num_decls(); - unsigned offset = all_vars.size(); - for (unsigned j = 0; j < num_decls; ++j) { - all_vars.push_back(m.mk_fresh_const("V",q->get_decl_sort(j))); - } - var_subst varsubst(m, false); - varsubst(m_Bs[i].get(), num_decls, (expr**)(all_vars.c_ptr() + offset), C); - fmls.push_back(C); - } - conjs.push_back(m_A); - conjs.push_back(m.mk_not(m.mk_and(fmls.size(), fmls.c_ptr()))); - // add previous instances. - expr* r = m.mk_and(m_Bs.size(), m_Bs.c_ptr()); - m_trail.push_back(r); - expr* inst; - if (!m_bound.find(m_current_rule, r, inst)) { - TRACE("pdr", tout << "did not find: " << mk_pp(r, m) << "\n";); - m_trail.push_back(r);Newton Sanches - inst = m.mk_true(); - m_bound.insert(m_current_rule, r, inst); - } - else { - TRACE("pdr", tout << "blocking: " << mk_pp(inst, m) << "\n";); - conjs.push_back(inst); - } - C = m.mk_and(conjs.size(), conjs.c_ptr()); - lbool result = qe.first_elim(all_vars.size(), all_vars.c_ptr(), C, defs); - TRACE("pdr", tout << mk_pp(C.get(), m) << "\n" << result << "\n";); - if (result != l_true) { - return false; - } - inst = m.mk_and(inst, m.mk_not(C)); - m_trail.push_back(inst); - m_bound.insert(m_current_rule, r, inst); - TRACE("pdr", - tout << "Instantiating\n"; - for (unsigned i = 0; i < defs.size(); ++i) { - tout << defs.var(i)->get_name() << " " << mk_pp(defs.def(i), m) << "\n"; - } - ); - expr_substitution sub(m); - for (unsigned i = 0; i < defs.size(); ++i) { - sub.insert(m.mk_const(defs.var(i)), defs.def(i)); - } - scoped_ptr rep = mk_default_expr_replacer(m); - rep->set_substitution(&sub); - for (unsigned i = 0; i < all_vars.size(); ++i) { - expr_ref tmp(all_vars[i].get(), m); - (*rep)(tmp); - all_vars[i] = to_app(tmp); - } - unsigned offset = 0; - for (unsigned i = 0; i < m_Bs.size(); ++i) { - quantifier* q = qs[i]; - unsigned num_decls = q->get_num_decls(); - expr_ref_vector new_binding(m); - for (unsigned j = 0; j < num_decls; ++j) { - new_binding.push_back(all_vars[offset+j].get()); - } - offset += num_decls; - add_binding(q, new_binding); - } - return true; - } - - bool quantifier_model_checker::find_instantiations_model_based(quantifier_ref_vector const& qs, unsigned level) { - bool found_instance = false; - expr_ref C(m); - front_end_params fparams; - smt::kernel solver(m, fparams); - solver.assert_expr(m_A); - for (unsigned i = 0; i < m_Bs.size(); ++i) { - expr_ref_vector fresh_vars(m); - quantifier* q = qs[i]; - for (unsigned j = 0; j < q->get_num_decls(); ++j) { - fresh_vars.push_back(m.mk_fresh_const("V",q->get_decl_sort(j))); - } - var_subst varsubst(m, false); - varsubst(m_Bs[i].get(), fresh_vars.size(), fresh_vars.c_ptr(), C); - TRACE("pdr", tout << "updated propagation formula: " << mk_pp(C,m) << "\n";); - - solver.push(); - // TBD: what to do with the different tags when unfolding the same predicate twice? - solver.assert_expr(m.mk_not(C)); - lbool result = solver.check(); - if (result == l_true) { - found_instance = true; - model_ref mr; - solver.get_model(mr); - TRACE("pdr", model_smt2_pp(tout, m, *mr, 0);); - - expr_ref_vector insts(m); - for (unsigned j = 0; j < fresh_vars.size(); ++j) { - expr* interp = mr->get_const_interp(to_app(fresh_vars[j].get())->get_decl()); - if (interp) { - insts.push_back(interp); - } - else { - insts.push_back(fresh_vars[j].get()); - } - TRACE("pdr", tout << mk_pp(insts.back(), m) << "\n";); - } - add_binding(q, insts); - } - solver.pop(1); - } - return found_instance; - } - - -#endif - diff --git a/src/muz_qe/pdr_quantifiers.h b/src/muz_qe/pdr_quantifiers.h index bae323cf8..2a7dcaf2c 100644 --- a/src/muz_qe/pdr_quantifiers.h +++ b/src/muz_qe/pdr_quantifiers.h @@ -33,24 +33,27 @@ namespace pdr { class model_node; class pred_transformer; class context; - - + class quantifier_model_checker { context& m_ctx; ast_manager& m; obj_map& m_quantifiers; datalog::rule_set& m_rules; - expr_ref_vector m_trail; + + obj_map m_reachable; // set of reachable states expr_ref m_A; expr_ref_vector m_Bs; pred_transformer* m_current_pt; datalog::rule const* m_current_rule; model_node* m_current_node; + bool m_rules_model_check; app_ref_vector m_instantiations; ptr_vector m_instantiated_rules; void model_check_node(model_node& node); + void weaken_under_approximation(); + bool find_instantiations(quantifier_ref_vector const& qs, unsigned level); bool find_instantiations_model_based(quantifier_ref_vector const& qs, unsigned level); @@ -79,6 +82,18 @@ namespace pdr { bool model_check(model_node& root); + void add_over_approximations(quantifier_ref_vector& qis, model_node& n); + + void add_under_approximations(quantifier_ref_vector& qis, model_node& n); + + void add_approximations(quantifier_ref_vector& qis, model_node& n, bool is_over); + + expr_ref get_reachable(func_decl* f); + + void update_reachable(func_decl* f, expr* e); + + expr_ref strongest_post_condition(datalog::rule& r); + public: quantifier_model_checker( context& ctx, @@ -89,9 +104,14 @@ namespace pdr { m(m), m_quantifiers(quantifiers), m_rules(rules), - m_trail(m), m_A(m), m_Bs(m), - m_current_pt(0), m_current_rule(0), - m_current_node(0), m_instantiations(m) {} + m_A(m), + m_Bs(m), + m_current_pt(0), + m_current_rule(0), + m_current_node(0), + m_instantiations(m) {} + + ~quantifier_model_checker(); bool check(); }; diff --git a/src/muz_qe/qe_lite.cpp b/src/muz_qe/qe_lite.cpp index 6baa7ad80..43008a1d6 100644 --- a/src/muz_qe/qe_lite.cpp +++ b/src/muz_qe/qe_lite.cpp @@ -74,462 +74,489 @@ public: }; -class der2 { - ast_manager & m; - is_variable_proc* m_is_variable; - var_subst m_subst; - expr_ref_buffer m_new_exprs; - - ptr_vector m_map; - int_vector m_pos2var; - ptr_vector m_inx2var; - unsigned_vector m_order; - expr_ref_vector m_subst_map; - expr_ref_buffer m_new_args; - th_rewriter m_rewriter; - - void der_sort_vars(ptr_vector & vars, ptr_vector & definitions, unsigned_vector & order) { - order.reset(); +namespace eq { + class der { + ast_manager & m; + is_variable_proc* m_is_variable; + var_subst m_subst; + expr_ref_buffer m_new_exprs; - // eliminate self loops, and definitions containing quantifiers. - bool found = false; - for (unsigned i = 0; i < definitions.size(); i++) { - var * v = vars[i]; - expr * t = definitions[i]; - if (t == 0 || has_quantifiers(t) || occurs(v, t)) - definitions[i] = 0; - else - found = true; // found at least one candidate - } + ptr_vector m_map; + int_vector m_pos2var; + ptr_vector m_inx2var; + unsigned_vector m_order; + expr_ref_vector m_subst_map; + expr_ref_buffer m_new_args; + th_rewriter m_rewriter; - if (!found) - return; - - typedef std::pair frame; - svector todo; - - expr_fast_mark1 visiting; - expr_fast_mark2 done; - - unsigned vidx, num; - - for (unsigned i = 0; i < definitions.size(); i++) { - if (definitions[i] == 0) - continue; - var * v = vars[i]; - SASSERT(v->get_idx() == i); - SASSERT(todo.empty()); - todo.push_back(frame(v, 0)); - while (!todo.empty()) { - start: - frame & fr = todo.back(); - expr * t = fr.first; - if (t->get_ref_count() > 1 && done.is_marked(t)) { - todo.pop_back(); + void der_sort_vars(ptr_vector & vars, ptr_vector & definitions, unsigned_vector & order) { + order.reset(); + + // eliminate self loops, and definitions containing quantifiers. + bool found = false; + for (unsigned i = 0; i < definitions.size(); i++) { + var * v = vars[i]; + expr * t = definitions[i]; + if (t == 0 || has_quantifiers(t) || occurs(v, t)) + definitions[i] = 0; + else + found = true; // found at least one candidate + } + + if (!found) + return; + + typedef std::pair frame; + svector todo; + + expr_fast_mark1 visiting; + expr_fast_mark2 done; + + unsigned vidx, num; + + for (unsigned i = 0; i < definitions.size(); i++) { + if (definitions[i] == 0) continue; - } - switch (t->get_kind()) { - case AST_VAR: - vidx = to_var(t)->get_idx(); - if (fr.second == 0) { - CTRACE("der_bug", vidx >= definitions.size(), tout << "vidx: " << vidx << "\n";); - // Remark: The size of definitions may be smaller than the number of variables occuring in the quantified formula. - if (definitions.get(vidx, 0) != 0) { - if (visiting.is_marked(t)) { - // cycle detected: remove t - visiting.reset_mark(t); - definitions[vidx] = 0; - } - else { - visiting.mark(t); - fr.second = 1; - todo.push_back(frame(definitions[vidx], 0)); - goto start; - } - } + var * v = vars[i]; + SASSERT(v->get_idx() == i); + SASSERT(todo.empty()); + todo.push_back(frame(v, 0)); + while (!todo.empty()) { + start: + frame & fr = todo.back(); + expr * t = fr.first; + if (t->get_ref_count() > 1 && done.is_marked(t)) { + todo.pop_back(); + continue; } - else { - SASSERT(fr.second == 1); - if (definitions.get(vidx, 0) != 0) { - visiting.reset_mark(t); - order.push_back(vidx); + switch (t->get_kind()) { + case AST_VAR: + vidx = to_var(t)->get_idx(); + if (fr.second == 0) { + CTRACE("der_bug", vidx >= definitions.size(), tout << "vidx: " << vidx << "\n";); + // Remark: The size of definitions may be smaller than the number of variables occuring in the quantified formula. + if (definitions.get(vidx, 0) != 0) { + if (visiting.is_marked(t)) { + // cycle detected: remove t + visiting.reset_mark(t); + definitions[vidx] = 0; + } + else { + visiting.mark(t); + fr.second = 1; + todo.push_back(frame(definitions[vidx], 0)); + goto start; + } + } } else { - // var was removed from the list of candidate vars to elim cycle - // do nothing + SASSERT(fr.second == 1); + if (definitions.get(vidx, 0) != 0) { + visiting.reset_mark(t); + order.push_back(vidx); + } + else { + // var was removed from the list of candidate vars to elim cycle + // do nothing + } } + if (t->get_ref_count() > 1) + done.mark(t); + todo.pop_back(); + break; + case AST_QUANTIFIER: + UNREACHABLE(); + todo.pop_back(); + break; + case AST_APP: + num = to_app(t)->get_num_args(); + while (fr.second < num) { + expr * arg = to_app(t)->get_arg(fr.second); + fr.second++; + if (arg->get_ref_count() > 1 && done.is_marked(arg)) + continue; + todo.push_back(frame(arg, 0)); + goto start; + } + if (t->get_ref_count() > 1) + done.mark(t); + todo.pop_back(); + break; + default: + UNREACHABLE(); + todo.pop_back(); + break; } - if (t->get_ref_count() > 1) - done.mark(t); - todo.pop_back(); - break; - case AST_QUANTIFIER: - UNREACHABLE(); - todo.pop_back(); - break; - case AST_APP: - num = to_app(t)->get_num_args(); - while (fr.second < num) { - expr * arg = to_app(t)->get_arg(fr.second); - fr.second++; - if (arg->get_ref_count() > 1 && done.is_marked(arg)) - continue; - todo.push_back(frame(arg, 0)); - goto start; - } - if (t->get_ref_count() > 1) - done.mark(t); - todo.pop_back(); - break; - default: - UNREACHABLE(); - todo.pop_back(); - break; } } } - } - - bool is_variable(expr * e) const { - return (*m_is_variable)(e); - } - - bool is_neg_var(ast_manager & m, expr * e) { - expr* e1; - return m.is_not(e, e1) && is_variable(e1); - } - - - /** - \brief Return true if e can be viewed as a variable disequality. - Store the variable id in v and the definition in t. - For example: - - if e is (not (= (VAR 1) T)), then v assigned to 1, and t to T. - if e is (iff (VAR 2) T), then v is assigned to 2, and t to (not T). - (not T) is used because this formula is equivalent to (not (iff (VAR 2) (not T))), - and can be viewed as a disequality. - */ - bool is_var_diseq(expr * e, var * & v, expr_ref & t) { - expr* e1; - if (m.is_not(e, e1)) { - return is_var_eq(e, v, t); - } - else if (is_var_eq(e, v, t) && m.is_bool(v)) { - bool_rewriter(m).mk_not(t, t); - m_new_exprs.push_back(t); - return true; - } - else { - return false; - } - } - - - - /** - \brief Return true if e can be viewed as a variable equality. - */ - - bool is_var_eq(expr * e, var * & v, expr_ref & t) { - expr* lhs, *rhs; - // (= VAR t), (iff VAR t), (iff (not VAR) t), (iff t (not VAR)) cases - if (m.is_eq(e, lhs, rhs) || m.is_iff(e, lhs, rhs)) { - // (iff (not VAR) t) (iff t (not VAR)) cases - if (!is_variable(lhs) && !is_variable(rhs) && m.is_bool(lhs)) { - if (!is_neg_var(m, lhs)) { - std::swap(lhs, rhs); - } - if (!is_neg_var(m, lhs)) { - return false; - } - v = to_var(lhs); - t = m.mk_not(rhs); + bool is_variable(expr * e) const { + return (*m_is_variable)(e); + } + + bool is_neg_var(ast_manager & m, expr * e) { + expr* e1; + return m.is_not(e, e1) && is_variable(e1); + } + + + /** + \brief Return true if e can be viewed as a variable disequality. + Store the variable id in v and the definition in t. + For example: + + if e is (not (= (VAR 1) T)), then v assigned to 1, and t to T. + if e is (iff (VAR 2) T), then v is assigned to 2, and t to (not T). + (not T) is used because this formula is equivalent to (not (iff (VAR 2) (not T))), + and can be viewed as a disequality. + */ + bool is_var_diseq(expr * e, var * & v, expr_ref & t) { + expr* e1; + if (m.is_not(e, e1)) { + return is_var_eq(e, v, t); + } + else if (is_var_eq(e, v, t) && m.is_bool(v)) { + bool_rewriter(m).mk_not(t, t); m_new_exprs.push_back(t); + return true; + } + else { + return false; + } + } + + + + /** + \brief Return true if e can be viewed as a variable equality. + */ + + bool is_var_eq(expr * e, var * & v, expr_ref & t) { + expr* lhs, *rhs; + + // (= VAR t), (iff VAR t), (iff (not VAR) t), (iff t (not VAR)) cases + if (m.is_eq(e, lhs, rhs) || m.is_iff(e, lhs, rhs)) { + // (iff (not VAR) t) (iff t (not VAR)) cases + if (!is_variable(lhs) && !is_variable(rhs) && m.is_bool(lhs)) { + if (!is_neg_var(m, lhs)) { + std::swap(lhs, rhs); + } + if (!is_neg_var(m, lhs)) { + return false; + } + v = to_var(lhs); + t = m.mk_not(rhs); + m_new_exprs.push_back(t); + TRACE("der", tout << mk_pp(e, m) << "\n";); + return true; + } + if (!is_variable(lhs)) + std::swap(lhs, rhs); + if (!is_variable(lhs)) + return false; + v = to_var(lhs); + t = rhs; TRACE("der", tout << mk_pp(e, m) << "\n";); return true; } - if (!is_variable(lhs)) - std::swap(lhs, rhs); - if (!is_variable(lhs)) + + // (ite cond (= VAR t) (= VAR t2)) case + expr* cond, *e2, *e3; + if (m.is_ite(e, cond, e2, e3)) { + if (is_var_eq(e2, v, t)) { + expr_ref t2(m); + var* v2; + if (is_var_eq(e3, v2, t2) && v2 == v) { + t = m.mk_ite(cond, t, t2); + m_new_exprs.push_back(t); + return true; + } + } return false; - v = to_var(lhs); - t = rhs; - TRACE("der", tout << mk_pp(e, m) << "\n";); - return true; + } + + // VAR = true case + if (is_variable(e)) { + t = m.mk_true(); + v = to_var(e); + TRACE("der", tout << mk_pp(e, m) << "\n";); + return true; + } + + // VAR = false case + if (is_neg_var(m, e)) { + t = m.mk_false(); + v = to_var(to_app(e)->get_arg(0)); + TRACE("der", tout << mk_pp(e, m) << "\n";); + return true; + } + + return false; } - // (ite cond (= VAR t) (= VAR t2)) case - expr* cond, *e2, *e3; - if (m.is_ite(e, cond, e2, e3)) { - if (is_var_eq(e2, v, t)) { - expr_ref t2(m); - var* v2; - if (is_var_eq(e3, v2, t2) && v2 == v) { - t = m.mk_ite(cond, t, t2); - m_new_exprs.push_back(t); + + bool is_var_def(bool check_eq, expr* e, var*& v, expr_ref& t) { + if (check_eq) { + return is_var_eq(e, v, t); + } + else { + return is_var_diseq(e, v, t); + } + } + + void get_elimination_order() { + m_order.reset(); + + TRACE("top_sort", + tout << "DEFINITIONS: " << std::endl; + for(unsigned i = 0; i < m_map.size(); i++) + if(m_map[i]) tout << "VAR " << i << " = " << mk_pp(m_map[i], m) << std::endl; + ); + + der_sort_vars(m_inx2var, m_map, m_order); + + TRACE("der", + tout << "Elimination m_order:" << std::endl; + for(unsigned i=0; iget_expr(); + if ((q->is_forall() && m.is_or(e)) || + (q->is_exists() && m.is_and(e))) { + num_args = to_app(e)->get_num_args(); + args = to_app(e)->get_args(); + } + } + + void apply_substitution(quantifier * q, expr_ref & r) { + + expr * e = q->get_expr(); + unsigned num_args = 1; + expr* const* args = &e; + flatten_args(q, num_args, args); + bool_rewriter rw(m); + + // get a new expression + m_new_args.reset(); + for(unsigned i = 0; i < num_args; i++) { + int x = m_pos2var[i]; + if (x == -1 || m_map[x] == 0) { + m_new_args.push_back(args[i]); + } + } + + expr_ref t(m); + if (q->is_forall()) { + rw.mk_or(m_new_args.size(), m_new_args.c_ptr(), t); + } + else { + rw.mk_and(m_new_args.size(), m_new_args.c_ptr(), t); + } + expr_ref new_e(m); + m_subst(t, m_subst_map.size(), m_subst_map.c_ptr(), new_e); + + // don't forget to update the quantifier patterns + expr_ref_buffer new_patterns(m); + expr_ref_buffer new_no_patterns(m); + for (unsigned j = 0; j < q->get_num_patterns(); j++) { + expr_ref new_pat(m); + m_subst(q->get_pattern(j), m_subst_map.size(), m_subst_map.c_ptr(), new_pat); + new_patterns.push_back(new_pat); + } + + for (unsigned j = 0; j < q->get_num_no_patterns(); j++) { + expr_ref new_nopat(m); + m_subst(q->get_no_pattern(j), m_subst_map.size(), m_subst_map.c_ptr(), new_nopat); + new_no_patterns.push_back(new_nopat); + } + + r = m.update_quantifier(q, new_patterns.size(), new_patterns.c_ptr(), + new_no_patterns.size(), new_no_patterns.c_ptr(), new_e); + } + + void reduce_quantifier1(quantifier * q, expr_ref & r, proof_ref & pr) { + expr * e = q->get_expr(); + is_variable_test is_v(q->get_num_decls()); + set_is_variable_proc(is_v); + unsigned num_args = 1; + expr* const* args = &e; + flatten_args(q, num_args, args); + + unsigned def_count = 0; + unsigned largest_vinx = 0; + + find_definitions(num_args, args, q->is_exists(), def_count, largest_vinx); + + if (def_count > 0) { + get_elimination_order(); + SASSERT(m_order.size() <= def_count); // some might be missing because of cycles + + if (!m_order.empty()) { + create_substitution(largest_vinx + 1); + apply_substitution(q, r); + } + else { + r = q; + } + } + else { + TRACE("der_bug", tout << "Did not find any diseq\n" << mk_pp(q, m) << "\n";); + r = q; + } + + if (m.proofs_enabled()) { + pr = r == q ? 0 : m.mk_der(q, r); + } + } + + void elim_unused_vars(expr_ref& r, proof_ref &pr) { + if (is_quantifier(r)) { + quantifier * q = to_quantifier(r); + ::elim_unused_vars(m, q, r); + if (m.proofs_enabled()) { + proof * p1 = m.mk_elim_unused_vars(q, r); + pr = m.mk_transitivity(pr, p1); + } + } + } + + void find_definitions(unsigned num_args, expr* const* args, bool is_exists, unsigned& def_count, unsigned& largest_vinx) { + var * v = 0; + expr_ref t(m); + def_count = 0; + largest_vinx = 0; + m_map.reset(); + m_pos2var.reset(); + m_inx2var.reset(); + m_pos2var.reserve(num_args, -1); + + // Find all definitions + for (unsigned i = 0; i < num_args; i++) { + if (is_var_def(is_exists, args[i], v, t)) { + unsigned idx = v->get_idx(); + if(m_map.get(idx, 0) == 0) { + m_map.reserve(idx + 1, 0); + m_inx2var.reserve(idx + 1, 0); + m_map[idx] = t; + m_inx2var[idx] = v; + m_pos2var[i] = idx; + def_count++; + largest_vinx = std::max(idx, largest_vinx); + } + } + } + } + + bool reduce_var_set(expr_ref_vector& conjs) { + unsigned def_count = 0; + unsigned largest_vinx = 0; + + find_definitions(conjs.size(), conjs.c_ptr(), true, def_count, largest_vinx); + + if (def_count > 0) { + get_elimination_order(); + SASSERT(m_order.size() <= def_count); // some might be missing because of cycles + + if (!m_order.empty()) { + expr_ref r(m), new_r(m); + r = m.mk_and(conjs.size(), conjs.c_ptr()); + create_substitution(largest_vinx + 1); + m_subst(r, m_subst_map.size(), m_subst_map.c_ptr(), new_r); + m_rewriter(new_r); + conjs.reset(); + datalog::flatten_and(new_r, conjs); return true; } } return false; } - - // VAR = true case - if (is_variable(e)) { - t = m.mk_true(); - v = to_var(e); - TRACE("der", tout << mk_pp(e, m) << "\n";); - return true; - } - - // VAR = false case - if (is_neg_var(m, e)) { - t = m.mk_false(); - v = to_var(to_app(e)->get_arg(0)); - TRACE("der", tout << mk_pp(e, m) << "\n";); - return true; - } - - return false; - } - - bool is_var_def(bool check_eq, expr* e, var*& v, expr_ref& t) { - if (check_eq) { - return is_var_eq(e, v, t); - } - else { - return is_var_diseq(e, v, t); - } - } - - void get_elimination_order() { - m_order.reset(); - - TRACE("top_sort", - tout << "DEFINITIONS: " << std::endl; - for(unsigned i = 0; i < m_map.size(); i++) - if(m_map[i]) tout << "VAR " << i << " = " << mk_pp(m_map[i], m) << std::endl; - ); + public: + der(ast_manager & m): m(m), m_is_variable(0), m_subst(m), m_new_exprs(m), m_subst_map(m), m_new_args(m), m_rewriter(m) {} - der_sort_vars(m_inx2var, m_map, m_order); + void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} - TRACE("der", - tout << "Elimination m_order:" << std::endl; - for(unsigned i=0; iget_expr(); - if ((q->is_forall() && m.is_or(e)) || - (q->is_exists() && m.is_and(e))) { - num_args = to_app(e)->get_num_args(); - args = to_app(e)->get_args(); - } - } - - void apply_substitution(quantifier * q, expr_ref & r) { - - expr * e = q->get_expr(); - unsigned num_args = 1; - expr* const* args = &e; - flatten_args(q, num_args, args); - bool_rewriter rw(m); - - // get a new expression - m_new_args.reset(); - for(unsigned i = 0; i < num_args; i++) { - int x = m_pos2var[i]; - if (x == -1 || m_map[x] == 0) { - m_new_args.push_back(args[i]); + void operator()(quantifier * q, expr_ref & r, proof_ref & pr) { + TRACE("der", tout << mk_pp(q, m) << "\n";); + pr = 0; + r = q; + reduce_quantifier(q, r, pr); + if (r != q) { + elim_unused_vars(r, pr); } } - expr_ref t(m); - if (q->is_forall()) { - rw.mk_or(m_new_args.size(), m_new_args.c_ptr(), t); - } - else { - rw.mk_and(m_new_args.size(), m_new_args.c_ptr(), t); - } - expr_ref new_e(m); - m_subst(t, m_subst_map.size(), m_subst_map.c_ptr(), new_e); - - // don't forget to update the quantifier patterns - expr_ref_buffer new_patterns(m); - expr_ref_buffer new_no_patterns(m); - for (unsigned j = 0; j < q->get_num_patterns(); j++) { - expr_ref new_pat(m); - m_subst(q->get_pattern(j), m_subst_map.size(), m_subst_map.c_ptr(), new_pat); - new_patterns.push_back(new_pat); - } - - for (unsigned j = 0; j < q->get_num_no_patterns(); j++) { - expr_ref new_nopat(m); - m_subst(q->get_no_pattern(j), m_subst_map.size(), m_subst_map.c_ptr(), new_nopat); - new_no_patterns.push_back(new_nopat); - } - - r = m.update_quantifier(q, new_patterns.size(), new_patterns.c_ptr(), - new_no_patterns.size(), new_no_patterns.c_ptr(), new_e); - } - - void reduce_quantifier1(quantifier * q, expr_ref & r, proof_ref & pr) { - expr * e = q->get_expr(); - is_variable_test is_v(q->get_num_decls()); - set_is_variable_proc(is_v); - unsigned num_args = 1; - expr* const* args = &e; - flatten_args(q, num_args, args); - - unsigned def_count = 0; - unsigned largest_vinx = 0; - - find_definitions(num_args, args, q->is_exists(), def_count, largest_vinx); - - if (def_count > 0) { - get_elimination_order(); - SASSERT(m_order.size() <= def_count); // some might be missing because of cycles - - if (!m_order.empty()) { - create_substitution(largest_vinx + 1); - apply_substitution(q, r); - } - else { - r = q; - } - } - else { - TRACE("der_bug", tout << "Did not find any diseq\n" << mk_pp(q, m) << "\n";); + void reduce_quantifier(quantifier * q, expr_ref & r, proof_ref & pr) { r = q; - } - - if (m.proofs_enabled()) { - pr = r == q ? 0 : m.mk_der(q, r); - } - } - - void elim_unused_vars(expr_ref& r, proof_ref &pr) { - if (is_quantifier(r)) { - quantifier * q = to_quantifier(r); - ::elim_unused_vars(m, q, r); - if (m.proofs_enabled()) { - proof * p1 = m.mk_elim_unused_vars(q, r); - pr = m.mk_transitivity(pr, p1); - } - } - } - - void find_definitions(unsigned num_args, expr* const* args, bool is_exists, unsigned& def_count, unsigned& largest_vinx) { - var * v = 0; - expr_ref t(m); - def_count = 0; - largest_vinx = 0; - m_map.reset(); - m_pos2var.reset(); - m_inx2var.reset(); - m_pos2var.reserve(num_args, -1); - - // Find all definitions - for (unsigned i = 0; i < num_args; i++) { - if (is_var_def(is_exists, args[i], v, t)) { - unsigned idx = v->get_idx(); - if(m_map.get(idx, 0) == 0) { - m_map.reserve(idx + 1, 0); - m_inx2var.reserve(idx + 1, 0); - m_map[idx] = t; - m_inx2var[idx] = v; - m_pos2var[i] = idx; - def_count++; - largest_vinx = std::max(idx, largest_vinx); + // Keep applying reduce_quantifier1 until r doesn't change anymore + do { + proof_ref curr_pr(m); + q = to_quantifier(r); + reduce_quantifier1(q, r, curr_pr); + if (m.proofs_enabled()) { + pr = m.mk_transitivity(pr, curr_pr); } - } - } - } - - bool reduce_var_set(expr_ref_vector& conjs) { - unsigned def_count = 0; - unsigned largest_vinx = 0; - - find_definitions(conjs.size(), conjs.c_ptr(), true, def_count, largest_vinx); - - if (def_count > 0) { - get_elimination_order(); - SASSERT(m_order.size() <= def_count); // some might be missing because of cycles + } while (q != r && is_quantifier(r)); - if (!m_order.empty()) { - expr_ref r(m), new_r(m); - r = m.mk_and(conjs.size(), conjs.c_ptr()); - create_substitution(largest_vinx + 1); - m_subst(r, m_subst_map.size(), m_subst_map.c_ptr(), new_r); - m_rewriter(new_r); - conjs.reset(); - datalog::flatten_and(new_r, conjs); - return true; - } + m_new_exprs.reset(); } - return false; - } - - -public: - der2(ast_manager & m): m(m), m_is_variable(0), m_subst(m), m_new_exprs(m), m_subst_map(m), m_new_args(m), m_rewriter(m) {} - - void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} - - void operator()(quantifier * q, expr_ref & r, proof_ref & pr) { - TRACE("der", tout << mk_pp(q, m) << "\n";); - pr = 0; - r = q; - reduce_quantifier(q, r, pr); - if (r != q) { - elim_unused_vars(r, pr); - } - } - - void reduce_quantifier(quantifier * q, expr_ref & r, proof_ref & pr) { - r = q; - // Keep applying reduce_quantifier1 until r doesn't change anymore - do { - proof_ref curr_pr(m); - q = to_quantifier(r); - reduce_quantifier1(q, r, curr_pr); - if (m.proofs_enabled()) { - pr = m.mk_transitivity(pr, curr_pr); - } - } while (q != r && is_quantifier(r)); - m_new_exprs.reset(); - } + void operator()(expr_ref_vector& r) { + while (reduce_var_set(r)) ; + m_new_exprs.reset(); + } + + ast_manager& get_manager() const { return m; } + }; +}; // namespace eq - void operator()(expr_ref_vector& r) { - while (reduce_var_set(r)) ; - m_new_exprs.reset(); - } +// ------------------------------------------------------------ +// basic destructive equality (and disequality) resolution for arrays. + +namespace ar { + class der { + ast_manager& m; + is_variable_proc* m_is_variable; + + bool is_variable(expr * e) const { + return (*m_is_variable)(e); + } + + public: + + der(ast_manager& m): m(m), m_is_variable(0) {} + + void operator()(expr_ref_vector& fmls) { + IF_VERBOSE(1, verbose_stream() << "Todo: eliminate arrays\n";); + } + + void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} + + }; +}; // namespace ar - ast_manager& get_manager() const { return m; } -}; // ------------------------------------------------------------ // fm_tactic adapted to eliminate designated de-Brujin indices. @@ -1808,7 +1835,6 @@ namespace fm { void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} - void operator()(expr_ref_vector& fmls) { init(fmls); init_use_list(fmls); @@ -1873,12 +1899,13 @@ namespace fm { class qe_lite::impl { ast_manager& m; - der2 m_der; params_ref m_params; + eq::der m_der; fm::fm m_fm; + ar::der m_array_der; public: - impl(ast_manager& m): m(m), m_der(m), m_fm(m, m_params) {} + impl(ast_manager& m): m(m), m_der(m), m_fm(m, m_params), m_array_der(m) {} void operator()(app_ref_vector& vars, expr_ref& fml) { if (vars.empty()) { @@ -1928,10 +1955,16 @@ public: } void operator()(uint_set const& index_set, bool index_of_bound, expr_ref& fml) { - expr_ref_vector conjs(m); - conjs.push_back(fml); - (*this)(index_set, index_of_bound, conjs); - bool_rewriter(m).mk_and(conjs.size(), conjs.c_ptr(), fml); + expr_ref_vector disjs(m); + datalog::flatten_or(fml, disjs); + for (unsigned i = 0; i < disjs.size(); ++i) { + expr_ref_vector conjs(m); + conjs.push_back(disjs[i].get()); + (*this)(index_set, index_of_bound, conjs); + bool_rewriter(m).mk_and(conjs.size(), conjs.c_ptr(), fml); + disjs[i] = fml; + } + bool_rewriter(m).mk_or(disjs.size(), disjs.c_ptr(), fml); } @@ -1941,9 +1974,11 @@ public: TRACE("qe_lite", for (unsigned i = 0; i < fmls.size(); ++i) tout << mk_pp(fmls[i].get(), m) << "\n";); IF_VERBOSE(3, for (unsigned i = 0; i < fmls.size(); ++i) verbose_stream() << mk_pp(fmls[i].get(), m) << "\n";); m_der.set_is_variable_proc(is_var); - m_der(fmls); m_fm.set_is_variable_proc(is_var); + m_array_der.set_is_variable_proc(is_var); + m_der(fmls); m_fm(fmls); + m_array_der(fmls); TRACE("qe_lite", for (unsigned i = 0; i < fmls.size(); ++i) tout << mk_pp(fmls[i].get(), m) << "\n";); } diff --git a/src/muz_qe/qe_lite.h b/src/muz_qe/qe_lite.h index 3a23c7188..3ffbf8fad 100644 --- a/src/muz_qe/qe_lite.h +++ b/src/muz_qe/qe_lite.h @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2010 Microsoft Corporation +Copyright (c) 2012 Microsoft Corporation Module Name: From 3e6bddbad1d8e7886b13abaadfcabef416df7acc Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 17:20:45 -0800 Subject: [PATCH 063/133] converted pp_params Signed-off-by: Leonardo de Moura --- src/api/api_ast.cpp | 7 ++- src/ast/ast_pp.h | 2 +- src/ast/ast_printer.cpp | 8 +-- src/ast/ast_smt2_pp.cpp | 50 ++++++++++----- src/ast/ast_smt2_pp.h | 29 ++++----- src/ast/pp.cpp | 61 ++++++------------- src/ast/pp.h | 14 +---- src/ast/pp_params.cpp | 57 ----------------- src/ast/pp_params.h | 46 -------------- src/ast/pp_params.pyg | 17 ++++++ src/ast/substitution/substitution_tree.cpp | 4 +- src/cmd_context/cmd_context.cpp | 11 ++-- .../extra_cmds/polynomial_cmds.cpp | 8 ++- src/front_end_params/front_end_params.h | 1 - src/model/model_pp.cpp | 3 +- src/model/model_smt2_pp.cpp | 4 +- src/muz_qe/dl_context.cpp | 8 +-- src/muz_qe/pdr_manager.cpp | 4 +- src/shell/main.cpp | 1 - src/tactic/fpa/fpa2bv_converter.cpp | 2 +- 20 files changed, 114 insertions(+), 223 deletions(-) delete mode 100644 src/ast/pp_params.cpp delete mode 100644 src/ast/pp_params.h create mode 100644 src/ast/pp_params.pyg diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 1503b387f..45892bac3 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -36,6 +36,7 @@ Revision History: #include"scoped_ctrl_c.h" #include"cancel_eh.h" #include"scoped_timer.h" +#include"pp_params.hpp" extern "C" { @@ -833,7 +834,8 @@ extern "C" { break; case Z3_PRINT_SMTLIB_COMPLIANT: { ast_smt_pp pp(mk_c(c)->m()); - pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies); + pp_params params; + pp.set_simplify_implies(params.simplify_implies()); ast* a1 = to_ast(a); pp.set_logic(mk_c(c)->fparams().m_smtlib_logic.c_str()); if (!is_expr(a1)) { @@ -886,7 +888,8 @@ extern "C" { pp.set_logic(logic); pp.set_status(status); pp.add_attributes(attributes); - pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies); + pp_params params; + pp.set_simplify_implies(params.simplify_implies()); for (unsigned i = 0; i < num_assumptions; ++i) { pp.add_assumption(to_expr(assumptions[i])); } diff --git a/src/ast/ast_pp.h b/src/ast/ast_pp.h index d99fb7670..7e7bdfc4e 100644 --- a/src/ast/ast_pp.h +++ b/src/ast/ast_pp.h @@ -24,7 +24,7 @@ Revision History: #include"ast_smt2_pp.h" struct mk_pp : public mk_ismt2_pp { - mk_pp(ast * t, ast_manager & m, pp_params const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0): + mk_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0): mk_ismt2_pp(t, m, p, indent, num_vars, var_prefix) { } mk_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0): diff --git a/src/ast/ast_printer.cpp b/src/ast/ast_printer.cpp index 33ddcb709..8d6ed91f7 100644 --- a/src/ast/ast_printer.cpp +++ b/src/ast/ast_printer.cpp @@ -33,14 +33,14 @@ public: virtual void display(std::ostream & out, func_decl * f, unsigned indent = 0) const { out << f->get_name(); } - virtual void pp(sort * s, format_ns::format_ref & r) const { mk_smt2_format(s, env(), get_pp_default_params(), r); } - virtual void pp(func_decl * f, format_ns::format_ref & r) const { mk_smt2_format(f, env(), get_pp_default_params(), r); } + virtual void pp(sort * s, format_ns::format_ref & r) const { mk_smt2_format(s, env(), params_ref(), r); } + virtual void pp(func_decl * f, format_ns::format_ref & r) const { mk_smt2_format(f, env(), params_ref(), r); } virtual void pp(expr * n, format_ns::format_ref & r) const { sbuffer buf; - mk_smt2_format(n, env(), get_pp_default_params(), 0, 0, r, buf); + mk_smt2_format(n, env(), params_ref(), 0, 0, r, buf); } virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const { - mk_smt2_format(n, env(), get_pp_default_params(), num_vars, var_prefix, r, var_names); + mk_smt2_format(n, env(), params_ref(), num_vars, var_prefix, r, var_names); } virtual void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const { NOT_IMPLEMENTED_YET(); diff --git a/src/ast/ast_smt2_pp.cpp b/src/ast/ast_smt2_pp.cpp index dcc7a1a0d..afe301ddf 100644 --- a/src/ast/ast_smt2_pp.cpp +++ b/src/ast/ast_smt2_pp.cpp @@ -24,6 +24,7 @@ Revision History: #include"ast_ll_pp.h" #include"ast_pp.h" #include"algebraic_numbers.h" +#include"pp_params.hpp" using namespace format_ns; #define ALIAS_PREFIX "a" @@ -376,7 +377,6 @@ typedef app_ref_vector format_ref_vector; class smt2_printer { ast_manager & m_manager; - pp_params const & m_params; smt2_pp_environment & m_env; shared_occs m_soccs; @@ -421,6 +421,16 @@ class smt2_printer { string_buffer<> m_next_name_buffer; + // Config + bool m_pp_decimal; + unsigned m_pp_decimal_precision; + bool m_pp_bv_lits; + bool m_pp_bv_neg; + unsigned m_pp_max_depth; + unsigned m_pp_min_alias_size; + bool m_pp_flat_assoc; + + symbol next_name(char const * prefix, unsigned & idx) { while (true) { m_next_name_buffer.reset(); @@ -508,10 +518,10 @@ class smt2_printer { void pp_const(app * c) { format * f; if (m_env.get_autil().is_numeral(c) || m_env.get_autil().is_irrational_algebraic_numeral(c)) { - f = m_env.pp_arith_literal(c, m_params.m_pp_decimal, m_params.m_pp_decimal_precision); + f = m_env.pp_arith_literal(c, m_pp_decimal, m_pp_decimal_precision); } else if (m_env.get_bvutil().is_numeral(c)) { - f = m_env.pp_bv_literal(c, m_params.m_pp_bv_lits, m_params.m_pp_bv_neg); + f = m_env.pp_bv_literal(c, m_pp_bv_lits, m_pp_bv_neg); } else if (m_env.get_futil().is_value(c)) { f = m_env.pp_float_literal(c); @@ -584,8 +594,8 @@ class smt2_printer { m_format_stack.shrink(fr.m_spos); m_info_stack.shrink(fr.m_spos); if (fr.m_use_alias && m_root != t && - ((f_info.m_depth >= m_params.m_pp_max_depth) || - ((f_info.m_weight >= m_params.m_pp_min_alias_size || is_quantifier(t)) && m_soccs.is_shared(t)))) { + ((f_info.m_depth >= m_pp_max_depth) || + ((f_info.m_weight >= m_pp_min_alias_size || is_quantifier(t)) && m_soccs.is_shared(t)))) { symbol a = next_alias(); TRACE("smt2_pp", tout << "a: " << a << " depth: " << f_info.m_depth << ", weight: " << f_info.m_weight << ", lvl: " << f_info.m_lvl << " t: #" << t->get_id() << "\n" << mk_ll_pp(t, m()) @@ -602,7 +612,7 @@ class smt2_printer { } bool flat_assoc(app * t, frame const & fr) { - if (!m_params.m_pp_flat_assoc) + if (!m_pp_flat_assoc) return false; func_decl * f = t->get_decl(); if (f->is_associative() && m_frame_stack.size() >= 2 && !m_soccs.is_shared(t)) { @@ -943,9 +953,8 @@ class smt2_printer { } public: - smt2_printer(smt2_pp_environment & env, pp_params const & params): + smt2_printer(smt2_pp_environment & env, params_ref const & params): m_manager(env.get_manager()), - m_params(params), m_env(env), m_soccs(m_manager), m_root(0), @@ -953,6 +962,15 @@ public: m_next_alias_idx(1), m_format_stack(fm()) { init_expr2alias_stack(); + + pp_params p(params); + m_pp_decimal = p.decimal(); + m_pp_decimal_precision = p.decimal_precision(); + m_pp_bv_lits = p.bv_literals(); + m_pp_bv_neg = p.bv_neg(); + m_pp_max_depth = p.max_depth(); + m_pp_min_alias_size = p.min_alias_size(); + m_pp_flat_assoc = p.flat_assoc(); } ~smt2_printer() { @@ -1003,24 +1021,24 @@ public: }; -void mk_smt2_format(expr * n, smt2_pp_environment & env, pp_params const & p, +void mk_smt2_format(expr * n, smt2_pp_environment & env, params_ref const & p, unsigned num_vars, char const * var_prefix, format_ref & r, sbuffer & var_names) { smt2_printer pr(env, p); pr(n, num_vars, var_prefix, r, var_names); } -void mk_smt2_format(sort * s, smt2_pp_environment & env, pp_params const & p, format_ref & r) { +void mk_smt2_format(sort * s, smt2_pp_environment & env, params_ref const & p, format_ref & r) { smt2_printer pr(env, p); pr(s, r); } -void mk_smt2_format(func_decl * f, smt2_pp_environment & env, pp_params const & p, format_ref & r) { +void mk_smt2_format(func_decl * f, smt2_pp_environment & env, params_ref const & p, format_ref & r) { smt2_printer pr(env, p); pr(f, r); } -std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, pp_params const & p, unsigned indent, +std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, params_ref const & p, unsigned indent, unsigned num_vars, char const * var_prefix) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); @@ -1032,7 +1050,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & e return out; } -std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, pp_params const & p, unsigned indent) { +std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, params_ref const & p, unsigned indent) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); sbuffer var_names; @@ -1043,7 +1061,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & e return out; } -std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, pp_params const & p, unsigned indent) { +std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, params_ref const & p, unsigned indent) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); sbuffer var_names; @@ -1054,7 +1072,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environmen return out; } -mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned indent, unsigned num_vars, char const * var_prefix): +mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent, unsigned num_vars, char const * var_prefix): m_ast(t), m_manager(m), m_params(p), @@ -1066,7 +1084,7 @@ mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent, unsigned num_vars, char const * var_prefix): m_ast(t), m_manager(m), - m_params(get_pp_default_params()), + m_params(m_empty), m_indent(indent), m_num_vars(num_vars), m_var_prefix(var_prefix) { diff --git a/src/ast/ast_smt2_pp.h b/src/ast/ast_smt2_pp.h index 048dd8d67..aa84d6e03 100644 --- a/src/ast/ast_smt2_pp.h +++ b/src/ast/ast_smt2_pp.h @@ -23,7 +23,7 @@ Revision History: #define _AST_SMT2_PP_H_ #include"format.h" -#include"pp_params.h" +#include"params.h" #include"arith_decl_plugin.h" #include"bv_decl_plugin.h" #include"array_decl_plugin.h" @@ -82,28 +82,29 @@ public: virtual bool uses(symbol const & s) const { return false; } }; -void mk_smt2_format(expr * n, smt2_pp_environment & env, pp_params const & p, +void mk_smt2_format(expr * n, smt2_pp_environment & env, params_ref const & p, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names); -void mk_smt2_format(sort * s, smt2_pp_environment & env, pp_params const & p, format_ns::format_ref & r); -void mk_smt2_format(func_decl * f, smt2_pp_environment & env, pp_params const & p, format_ns::format_ref & r); +void mk_smt2_format(sort * s, smt2_pp_environment & env, params_ref const & p, format_ns::format_ref & r); +void mk_smt2_format(func_decl * f, smt2_pp_environment & env, params_ref const & p, format_ns::format_ref & r); -std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, pp_params const & p, unsigned indent = 0, +std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); -std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, pp_params const & p, unsigned indent = 0); -std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, pp_params const & p, unsigned indent = 0); +std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0); +std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0); /** \brief Internal wrapper (for debugging purposes only) */ struct mk_ismt2_pp { - ast * m_ast; - ast_manager & m_manager; - pp_params const & m_params; - unsigned m_indent; - unsigned m_num_vars; - char const * m_var_prefix; - mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); + ast * m_ast; + ast_manager & m_manager; + params_ref m_empty; + params_ref const & m_params; + unsigned m_indent; + unsigned m_num_vars; + char const * m_var_prefix; + mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); }; diff --git a/src/ast/pp.cpp b/src/ast/pp.cpp index d05776e78..13247127d 100644 --- a/src/ast/pp.cpp +++ b/src/ast/pp.cpp @@ -17,40 +17,9 @@ Revision History: --*/ #include"pp.h" +#include"pp_params.hpp" using namespace format_ns; -void pp_param_descrs(param_descrs & p) { - p.insert("max_indent", CPK_UINT, "max. indentation in pretty printer"); - p.insert("max_num_lines", CPK_UINT, "max. number of lines to be displayed in pretty printer"); - p.insert("max_width", CPK_UINT, "max. width in pretty printer"); - p.insert("max_ribbon", CPK_UINT, "max. ribbon (width - indentation) in pretty printer"); - p.insert("max_depth", CPK_UINT, "max. term depth (when pretty printing SMT2 terms/formulas)"); - p.insert("min_alias_size", CPK_UINT, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)"); - p.insert("decimal", CPK_BOOL, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise"); - p.insert("decimal_precision", CPK_BOOL, "maximum number of decimal places to be used when pp.decimal=true"); - p.insert("bv_literals", CPK_BOOL, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing"); - p.insert("bv_neg", CPK_BOOL, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1"); - p.insert("flat_assoc", CPK_BOOL, "flat associative operators (when pretty printing SMT2 terms/formulas)"); - p.insert("fixed_indent", CPK_BOOL, "use a fixed indentation for applications"); - p.insert("single_line", CPK_BOOL, "ignore line breaks when true"); - p.insert("bounded", CPK_BOOL, "ignore characters exceeding max widht"); - p.insert("simplify_implies", CPK_BOOL, "simplify nested implications for pretty printing"); -} - -pp_params g_pp_params; - -void set_pp_default_params(pp_params const & p) { - g_pp_params = p; -} - -void register_pp_params(ini_params & p) { - g_pp_params.register_params(p); -} - -pp_params const & get_pp_default_params() { - return g_pp_params; -} - static std::pair space_upto_line_break(ast_manager & m, format * f) { unsigned r; SASSERT(f->get_family_id() == fm(m).get_family_id("format")); @@ -87,7 +56,15 @@ inline bool fits(ast_manager & m, format * f, unsigned space_left) { return s <= space_left; } -void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { +void pp(std::ostream & out, format * f, ast_manager & m, params_ref const & _p) { + pp_params p(_p); + unsigned max_width = p.max_width(); + unsigned max_ribbon = p.max_ribbon(); + unsigned max_num_lines = p.max_num_lines(); + unsigned max_indent = p.max_indent(); + bool bounded = p.bounded(); + bool single_line = p.single_line(); + unsigned pos = 0; unsigned ribbon_pos = 0; unsigned line = 0; @@ -98,7 +75,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { todo.push_back(std::make_pair(f, 0)); app_ref space(mk_string(m, " "), fm(m)); while (!todo.empty()) { - if (line >= p.m_pp_max_num_lines) + if (line >= max_num_lines) return; std::pair pair = todo.back(); format * f = pair.first; @@ -107,10 +84,10 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { SASSERT(f->get_family_id() == fm(m).get_family_id("format")); switch (f->get_decl_kind()) { case OP_STRING: - if (p.m_pp_bounded && pos > p.m_pp_max_width) + if (bounded && pos > max_width) break; len = static_cast(strlen(f->get_decl()->get_parameter(0).get_symbol().bare_str())); - if (p.m_pp_bounded && pos + len > p.m_pp_max_width) { + if (bounded && pos + len > max_width) { out << "..."; break; } @@ -121,7 +98,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { case OP_INDENT: todo.push_back(std::make_pair(to_app(f->get_arg(0)), std::min(indent + f->get_decl()->get_parameter(0).get_int(), - p.m_pp_max_indent))); + max_indent))); break; case OP_COMPOSE: i = f->get_num_args(); @@ -131,7 +108,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { } break; case OP_CHOICE: - space_left = std::min(p.m_pp_max_width - pos, p.m_pp_max_ribbon - pos); + space_left = std::min(max_width - pos, max_ribbon - pos); if (space_left > 0 && fits(m, to_app(f->get_arg(0)), space_left)) todo.push_back(std::make_pair(to_app(f->get_arg(0)), indent)); else @@ -139,14 +116,14 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { break; case OP_LINE_BREAK: case OP_LINE_BREAK_EXT: - if (p.m_pp_single_line) { + if (single_line) { todo.push_back(std::make_pair(space, indent)); break; } pos = indent; ribbon_pos = 0; line++; - if (line < p.m_pp_max_num_lines) { + if (line < max_num_lines) { out << "\n"; for (unsigned i = 0; i < indent; i++) out << " "; @@ -160,7 +137,3 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { } } -void pp(std::ostream & out, format_ns::format * f, ast_manager & m) { - pp(out, f, m, g_pp_params); -} - diff --git a/src/ast/pp.h b/src/ast/pp.h index 13afcb07c..f567afa4a 100644 --- a/src/ast/pp.h +++ b/src/ast/pp.h @@ -20,21 +20,9 @@ Revision History: #define _PP_H_ #include"format.h" -#include"pp_params.h" #include"params.h" -/* - REG_MODULE_PARAMS('pp', 'pp_param_descrs') -*/ -void pp_param_descrs(param_descrs & d); - -void set_pp_default_params(pp_params const & p); -void register_pp_params(ini_params & p); - -pp_params const & get_pp_default_params(); - -void pp(std::ostream & out, format_ns::format * f, ast_manager & m, pp_params const & p); -void pp(std::ostream & out, format_ns::format * f, ast_manager & m); +void pp(std::ostream & out, format_ns::format * f, ast_manager & m, params_ref const & p = params_ref()); #endif /* _PP_H_ */ diff --git a/src/ast/pp_params.cpp b/src/ast/pp_params.cpp deleted file mode 100644 index 0cf3e455d..000000000 --- a/src/ast/pp_params.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pp_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-20. - -Revision History: - ---*/ - -#include"pp_params.h" - -pp_params::pp_params(): - m_pp_max_indent(UINT_MAX), - m_pp_max_num_lines(UINT_MAX), - m_pp_max_width(80), - m_pp_max_ribbon(80), - m_pp_max_depth(5), - m_pp_min_alias_size(10), - m_pp_decimal(false), - m_pp_decimal_precision(10), - m_pp_bv_lits(true), - m_pp_bv_neg(false), - m_pp_flat_assoc(true), - m_pp_fixed_indent(false), - m_pp_single_line(false), - m_pp_bounded(false), - m_pp_simplify_implies(false) { -} - -void pp_params::register_params(ini_params & p) { - p.register_unsigned_param("PP_MAX_INDENT", m_pp_max_indent, "max. indentation in pretty printer", true); - p.register_unsigned_param("PP_MAX_NUM_LINES", m_pp_max_num_lines, "max. number of lines to be displayed in pretty printer", true); - p.register_unsigned_param("PP_MAX_WIDTH", m_pp_max_width, "max. width in pretty printer", true); - p.register_unsigned_param("PP_MAX_RIBBON", m_pp_max_ribbon, "max. ribbon (width - indentation) in pretty printer", true); - p.register_unsigned_param("PP_MAX_DEPTH", m_pp_max_depth, "max. term depth (when pretty printing SMT2 terms/formulas)", true); - p.register_unsigned_param("PP_MIN_ALIAS_SIZE", m_pp_min_alias_size, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)", true); - p.register_bool_param("PP_DECIMAL", m_pp_decimal, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise", true); - p.register_unsigned_param("PP_DECIMAL_PRECISION", m_pp_decimal_precision, "maximum number of decimal places to be used when PP_DECIMAL=true", true); - p.register_bool_param("PP_BV_LITERALS", m_pp_bv_lits, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing", true); - p.register_bool_param("PP_BV_NEG", m_pp_bv_neg, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1", true); - p.register_bool_param("PP_FLAT_ASSOC", m_pp_flat_assoc, "flat associative operators (when pretty printing SMT2 terms/formulas)", true); - p.register_bool_param("PP_FIXED_INDENT", m_pp_fixed_indent, "use a fixed indentation for applications", true); - p.register_bool_param("PP_SINGLE_LINE", m_pp_single_line, "ignore line breaks when true", true); - p.register_bool_param("PP_BOUNDED", m_pp_bounded, "ignore characters exceeding max widht", true); - p.register_bool_param("PP_SIMPLIFY_IMPLIES", m_pp_simplify_implies, "simplify nested implications for pretty printing", true); -} - diff --git a/src/ast/pp_params.h b/src/ast/pp_params.h deleted file mode 100644 index 970f97968..000000000 --- a/src/ast/pp_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pp_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-20. - -Revision History: - ---*/ -#ifndef _PP_PARAMS_H_ -#define _PP_PARAMS_H_ - -#include"ini_file.h" - -struct pp_params { - unsigned m_pp_max_indent; // max. indentation - unsigned m_pp_max_num_lines; // max. num. lines - unsigned m_pp_max_width; // max. width - unsigned m_pp_max_ribbon; // max. ribbon: width - indentation - unsigned m_pp_max_depth; - unsigned m_pp_min_alias_size; - bool m_pp_decimal; // display reals using decimals - unsigned m_pp_decimal_precision; // max. number of decimal places - bool m_pp_bv_lits; - bool m_pp_bv_neg; // use bvneg to display bit-vector literals which the most significant bit is 1 - bool m_pp_flat_assoc; - bool m_pp_fixed_indent; - bool m_pp_single_line; // ignore line breaks if true - bool m_pp_bounded; // ignore characters exceeding max width. - bool m_pp_simplify_implies; // simplify nested implications during pretty printing - - pp_params(); - void register_params(ini_params & p); -}; - -#endif /* _PP_PARAMS_H_ */ - diff --git a/src/ast/pp_params.pyg b/src/ast/pp_params.pyg new file mode 100644 index 000000000..57d6e185d --- /dev/null +++ b/src/ast/pp_params.pyg @@ -0,0 +1,17 @@ +def_module_params('pp', + export=True, + params=(('max_indent', UINT, UINT_MAX, 'max. indentation in pretty printer'), + ('max_num_lines', UINT, UINT_MAX, 'max. number of lines to be displayed in pretty printer'), + ('max_width', UINT, 80, 'max. width in pretty printer'), + ('max_ribbon', UINT, 80, 'max. ribbon (width - indentation) in pretty printer'), + ('max_depth', UINT, 5, 'max. term depth (when pretty printing SMT2 terms/formulas)'), + ('min_alias_size', UINT, 10, 'min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)'), + ('decimal', BOOL, False, 'pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a ? if the value is not precise'), + ('decimal_precision', UINT, 10, 'maximum number of decimal places to be used when pp.decimal=true'), + ('bv_literals', BOOL, True, 'use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing'), + ('bv_neg', BOOL, False, 'use bvneg when displaying Bit-Vector literals where the most significant bit is 1'), + ('flat_assoc', BOOL, True, 'flat associative operators (when pretty printing SMT2 terms/formulas)'), + ('fixed_indent', BOOL, False, 'use a fixed indentation for applications'), + ('single_line', BOOL, False, 'ignore line breaks when true'), + ('bounded', BOOL, False, 'ignore characters exceeding max widht'), + ('simplify_implies', BOOL, True, 'simplify nested implications for pretty printing'))) diff --git a/src/ast/substitution/substitution_tree.cpp b/src/ast/substitution/substitution_tree.cpp index 81b2f7be6..037d51e32 100644 --- a/src/ast/substitution/substitution_tree.cpp +++ b/src/ast/substitution/substitution_tree.cpp @@ -607,8 +607,8 @@ void substitution_tree::display(std::ostream & out, node * n, unsigned delta) co out << " "; display(out, n->m_subst); if (n->m_leaf) { - pp_params p; - p.m_pp_single_line = true; + params_ref p; + p.set_bool("single_line", true); out << " ==> "; out << mk_pp(n->m_expr, m_manager, p); out << "\n"; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index d14ce3076..5dcc4268c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1536,8 +1536,7 @@ cmd_context::pp_env & cmd_context::get_pp_env() const { } void cmd_context::pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const { - mk_smt2_format(n, get_pp_env(), get_pp_default_params(), - num_vars, var_prefix, r, var_names); + mk_smt2_format(n, get_pp_env(), params_ref(), num_vars, var_prefix, r, var_names); } void cmd_context::pp(expr * n, format_ns::format_ref & r) const { @@ -1546,7 +1545,7 @@ void cmd_context::pp(expr * n, format_ns::format_ref & r) const { } void cmd_context::pp(func_decl * f, format_ns::format_ref & r) const { - mk_smt2_format(f, get_pp_env(), get_pp_default_params(), r); + mk_smt2_format(f, get_pp_env(), params_ref(), r); } void cmd_context::display(std::ostream & out, sort * s, unsigned indent) const { @@ -1554,7 +1553,7 @@ void cmd_context::display(std::ostream & out, sort * s, unsigned indent) const { f = pp(s); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const { @@ -1562,7 +1561,7 @@ void cmd_context::display(std::ostream & out, expr * n, unsigned indent, unsigne pp(n, num_vars, var_prefix, f, var_names); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::display(std::ostream & out, expr * n, unsigned indent) const { @@ -1575,7 +1574,7 @@ void cmd_context::display(std::ostream & out, func_decl * d, unsigned indent) co pp(d, f); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::dump_assertions(std::ostream & out) const { diff --git a/src/cmd_context/extra_cmds/polynomial_cmds.cpp b/src/cmd_context/extra_cmds/polynomial_cmds.cpp index 7b37b750e..e68789dac 100644 --- a/src/cmd_context/extra_cmds/polynomial_cmds.cpp +++ b/src/cmd_context/extra_cmds/polynomial_cmds.cpp @@ -26,10 +26,10 @@ Notes: #include"parametric_cmd.h" #include"mpq.h" #include"algebraic_numbers.h" -#include"pp.h" -#include"pp_params.h" #include"polynomial_var2value.h" #include"expr2var.h" +#include"pp.h" +#include"pp_params.hpp" static void to_poly(cmd_context & ctx, expr * t) { polynomial::numeral_manager nm; @@ -145,9 +145,11 @@ class poly_isolate_roots_cmd : public cmd { scoped_anum_vector rs(m_am); m_am.isolate_roots(m_p, m_x2v, rs); ctx.regular_stream() << "(roots"; + pp_params params; + bool pp_decimal = params.decimal(); for (unsigned i = 0; i < rs.size(); i++) { ctx.regular_stream() << std::endl; - if (!get_pp_default_params().m_pp_decimal) + if (!pp_decimal) m_am.display_root_smt2(ctx.regular_stream(), rs[i]); else m_am.display_decimal(ctx.regular_stream(), rs[i]); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index f9e62cd01..b87265c01 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -23,7 +23,6 @@ Revision History: #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" -#include"pp_params.h" #include"parser_params.h" #include"arith_simplifier_params.h" #include"model_params.h" diff --git a/src/model/model_pp.cpp b/src/model/model_pp.cpp index a8e8a0880..b968c7184 100644 --- a/src/model/model_pp.cpp +++ b/src/model/model_pp.cpp @@ -85,8 +85,7 @@ static void display_functions(std::ostream & out, model_core const & md) { if (fi->is_partial()) out << " #unspecified"; else { - pp_params const & params = get_pp_default_params(); - out << " " << mk_ismt2_pp(fi->get_else(), m, params, 5, arity, "x"); + out << " " << mk_ismt2_pp(fi->get_else(), m, params_ref(), 5, arity, "x"); } for (unsigned j = 0; j < num_entries; j++) out << ")"; diff --git a/src/model/model_smt2_pp.cpp b/src/model/model_smt2_pp.cpp index 1a639b5f1..929668638 100644 --- a/src/model/model_smt2_pp.cpp +++ b/src/model/model_smt2_pp.cpp @@ -128,7 +128,7 @@ static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, mod format_ref f_card(fm(m)); f_card = mk_indent(m, indent, mk_seq1(m, f_args, f_args+2, f2f(), "forall")); pp_indent(out, indent); - pp(out, f_card, m, get_pp_default_params()); + pp(out, f_card, m); out << "\n"; pp_indent(out, indent); out << ";; -----------\n"; @@ -284,7 +284,7 @@ static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core co body.get(), mk_string(m, ")"))))); pp_indent(out, indent); - pp(out, def.get(), m, get_pp_default_params()); + pp(out, def.get(), m); out << "\n"; } } diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 4a9bba27c..3a2844964 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -1672,12 +1672,11 @@ namespace datalog { bool print_low_level = m_params.get_bool("print_low_level_smt2", false); bool do_declare_vars = m_params.get_bool("print_with_variable_declarations", true); -#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); +#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env); get_rules_as_formulas(rules, names); smt2_pp_environment_dbg env(m); - pp_params params; mk_fresh_name fresh_names; collect_free_funcs(num_axioms, axioms, visited, visitor, fresh_names); collect_free_funcs(rules.size(), rules.c_ptr(), visited, visitor, fresh_names); @@ -1719,7 +1718,7 @@ namespace datalog { func_decl* f = *it; out << "(declare-rel " << f->get_name() << " ("; for (unsigned i = 0; i < f->get_arity(); ++i) { - ast_smt2_pp(out, f->get_domain(i), env, params); + ast_smt2_pp(out, f->get_domain(i), env); if (i + 1 < f->get_arity()) { out << " "; } @@ -1796,7 +1795,6 @@ namespace datalog { // smt2_pp_environment_dbg env(m); var_subst vsubst(m, false); - pp_params param; expr_ref_vector fresh_vars(m), subst(m); expr_ref res(m); @@ -1839,7 +1837,7 @@ namespace datalog { symbol name = fresh_names.next(); fresh_vars.push_back(m.mk_const(name, s)); out << "(declare-var " << name << " "; - ast_smt2_pp(out, s, env, param); + ast_smt2_pp(out, s, env); out << ")\n"; } subst.push_back(fresh_vars[vars[max_var]].get()); diff --git a/src/muz_qe/pdr_manager.cpp b/src/muz_qe/pdr_manager.cpp index ad53f45db..9536d8f36 100644 --- a/src/muz_qe/pdr_manager.cpp +++ b/src/muz_qe/pdr_manager.cpp @@ -29,7 +29,6 @@ Revision History: #include "model_smt2_pp.h" #include "model_converter.h" - namespace pdr { class collect_decls_proc { @@ -143,11 +142,10 @@ namespace pdr { } } smt2_pp_environment_dbg env(m); - pp_params params; func_decl_set::iterator it = aux_decls.begin(), end = aux_decls.end(); for (; it != end; ++it) { func_decl* f = *it; - ast_smt2_pp(out, f, env, params); + ast_smt2_pp(out, f, env); out << "\n"; } diff --git a/src/shell/main.cpp b/src/shell/main.cpp index d6e7b1bf1..56882a02b 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -127,7 +127,6 @@ void init_params() { g_extra_params = new extra_params(); register_verbosity_level(*g_params); register_warning(*g_params); - register_pp_params(*g_params); g_front_end_params->register_params(*g_params); g_extra_params->register_params(*g_params); g_params_initialized = true; diff --git a/src/tactic/fpa/fpa2bv_converter.cpp b/src/tactic/fpa/fpa2bv_converter.cpp index 77ff50e9b..62cc76266 100644 --- a/src/tactic/fpa/fpa2bv_converter.cpp +++ b/src/tactic/fpa/fpa2bv_converter.cpp @@ -105,7 +105,7 @@ void fpa2bv_converter::mk_value(func_decl * f, unsigned num, expr * const * args mk_triple(bv_sgn, bv_sig, biased_exp, result); TRACE("fpa2bv_dbg", tout << "value of [" << sign << " " << m_mpz_manager.to_string(sig) << " " << exp << "] is " - << mk_ismt2_pp(result, m) << std::endl;); + << mk_ismt2_pp(result, m) << std::endl;); } } From 6195ed7c662f2ff02f0975091ec3ec1f31f16ddd Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 18:16:02 -0800 Subject: [PATCH 064/133] checkpoint Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 2 +- src/ast/normal_forms/cnf.cpp | 19 ++-- src/ast/normal_forms/cnf.h | 26 +++++- src/ast/normal_forms/cnf_params.pyg | 4 + src/ast/normal_forms/nnf.cpp | 101 +++++++++++---------- src/ast/normal_forms/nnf.h | 2 - src/ast/normal_forms/nnf_params.pyg | 8 ++ src/front_end_params/cnf_params.cpp | 26 ------ src/front_end_params/cnf_params.h | 56 ------------ src/front_end_params/nnf_params.cpp | 26 ------ src/front_end_params/nnf_params.h | 74 --------------- src/front_end_params/preprocessor_params.h | 6 +- src/front_end_params/smt_params.cpp | 1 - src/front_end_params/smt_params.h | 2 - src/smt/asserted_formulas.cpp | 82 ++++------------- src/smt/smt_context.h | 4 - src/smt/smt_internalizer.cpp | 7 +- 17 files changed, 120 insertions(+), 326 deletions(-) create mode 100644 src/ast/normal_forms/cnf_params.pyg create mode 100644 src/ast/normal_forms/nnf_params.pyg delete mode 100644 src/front_end_params/cnf_params.cpp delete mode 100644 src/front_end_params/cnf_params.h delete mode 100644 src/front_end_params/nnf_params.cpp delete mode 100644 src/front_end_params/nnf_params.h diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 6fff2abba..27120c89d 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -18,6 +18,7 @@ def init_project_def(): add_lib('subpaving', ['interval'], 'math/subpaving') add_lib('ast', ['util', 'polynomial']) add_lib('rewriter', ['ast', 'polynomial'], 'ast/rewriter') + add_lib('normal_forms', ['rewriter'], 'ast/normal_forms') add_lib('model', ['rewriter']) add_lib('tactic', ['ast', 'model']) add_lib('substitution', ['ast'], 'ast/substitution') @@ -30,7 +31,6 @@ def init_project_def(): # Simplifier module will be deleted in the future. # It has been replaced with rewriter module. add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') - add_lib('normal_forms', ['rewriter', 'front_end_params'], 'ast/normal_forms') add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core') add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic') add_lib('arith_tactics', ['core_tactics', 'sat'], 'tactic/arith') diff --git a/src/ast/normal_forms/cnf.cpp b/src/ast/normal_forms/cnf.cpp index d454c7f00..2a58b16a6 100644 --- a/src/ast/normal_forms/cnf.cpp +++ b/src/ast/normal_forms/cnf.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"cnf.h" +#include"cnf_params.hpp" #include"var_subst.h" #include"ast_util.h" #include"ast_pp.h" @@ -159,7 +160,7 @@ inline bool cnf::is_too_expensive(approx_nat approx_result_size, ptr_buffer f_args; flat_args(n->get_decl(), new_args, f_args); TRACE("cnf_or", for (unsigned i = 0; i < f_args.size(); i++) tout << mk_pp(f_args[i], m_manager) << "\n";); approx_nat result_size = approx_result_size_for_disj(f_args); TRACE("cnf_or", tout << mk_pp(n, m_manager) << "\napprox. result: " << result_size << "\n";); - if (m_params.m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_params.m_cnf_factor) { + if (m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_cnf_factor) { expr_ref_buffer cheap_args(m_manager); proof_ref_buffer cheap_args_pr(m_manager); if (is_too_expensive(result_size, f_args)) { @@ -354,7 +355,7 @@ void cnf::reduce1_and(app * n, bool in_q) { get_args(n, in_q, new_args, new_arg_prs); app * r; proof * pr = 0; - if (in_q || m_params.m_cnf_mode == CNF_OPPORTUNISTIC || m_params.m_cnf_mode == CNF_FULL) { + if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { ptr_buffer f_args; flat_args(n->get_decl(), new_args, f_args); r = m_manager.mk_and(f_args.size(), f_args.c_ptr()); @@ -379,7 +380,7 @@ void cnf::reduce1_label(app * n, bool in_q) { expr * new_arg; proof * new_arg_pr; get_cached(n->get_arg(0), true, new_arg, new_arg_pr); - if (in_q || m_params.m_cnf_mode == CNF_FULL) { + if (in_q || m_cnf_mode == CNF_FULL) { // TODO: in the current implementation, labels are removed during CNF translation. // This is satisfactory for Boogie, since it does not use labels inside quantifiers, // and we only need CNF_QUANT for Superposition Calculus. @@ -439,8 +440,7 @@ void cnf::reduce1_quantifier(quantifier * q, bool in_q) { TRACE("cnf_quant", tout << mk_pp(q, m_manager) << "\n" << mk_pp(r, m_manager) << "\n";); } -cnf::cnf(ast_manager & m, defined_names & n, cnf_params & params): - m_params(params), +cnf::cnf(ast_manager & m, defined_names & n, params_ref const & params): m_manager(m), m_defined_names(n), m_pull(m), @@ -448,6 +448,9 @@ cnf::cnf(ast_manager & m, defined_names & n, cnf_params & params): m_todo_defs(m), m_todo_proofs(m), m_coarse_proofs(m) { + cnf_params p(params); + m_cnf_mode = static_cast(p.mode()); + m_cnf_factor = p.factor(); } cnf::~cnf() { @@ -488,7 +491,7 @@ void cnf::reduce(expr * n, expr_ref & r, proof_ref & pr) { } void cnf::operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & pr) { - if (m_params.m_cnf_mode == CNF_DISABLED) { + if (m_cnf_mode == CNF_DISABLED) { r = n; pr = m_manager.mk_reflexivity(n); return; diff --git a/src/ast/normal_forms/cnf.h b/src/ast/normal_forms/cnf.h index 60c2d2410..8aa390c48 100644 --- a/src/ast/normal_forms/cnf.h +++ b/src/ast/normal_forms/cnf.h @@ -19,11 +19,29 @@ Revision History: #ifndef _CNF_H_ #define _CNF_H_ -#include"cnf_params.h" #include"pull_quant.h" #include"nnf.h" #include"approx_nat.h" +/** + \brief CNF translation mode. The cheapest mode is CNF_QUANT, and + the most expensive is CNF_FULL. +*/ +enum cnf_mode { + CNF_DISABLED, /* CNF translator is disabled. + This mode is sufficient when using E-matching. + */ + CNF_QUANT, /* A subformula is put into CNF if it is inside of a + quantifier. + + This mode is sufficient when using Superposition + Calculus. + */ + CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ + CNF_FULL /* Everything is put into CNF, new names are introduced + if it is too expensive. */ +}; + /** \brief Entry into the todo list of the CNF translator. It is also used as the key in the CNF cache. */ @@ -71,7 +89,6 @@ public: */ class cnf { typedef std::pair expr_bool_pair; - cnf_params & m_params; ast_manager & m_manager; defined_names & m_defined_names; pull_quant m_pull; @@ -83,6 +100,9 @@ class cnf { ptr_vector m_result_def_proofs; proof_ref_vector m_coarse_proofs; + cnf_mode m_cnf_mode; + unsigned m_cnf_factor; + void cache_result(expr * e, bool in_q, expr * r, proof * pr); void get_cached(expr * n, bool in_q, expr * & r, proof * & pr) const { m_cache.get(cnf_entry(n, true, in_q), r, pr); } bool is_cached(expr * n, bool in_q) const { return m_cache.contains(cnf_entry(n, true, in_q)); } @@ -105,7 +125,7 @@ class cnf { void reduce(expr * n, expr_ref & r, proof_ref & pr); public: - cnf(ast_manager & m, defined_names & n, cnf_params & params); + cnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); ~cnf(); void operator()(expr * n, // [IN] expression that should be put into CNF expr_ref_vector & new_defs, // [OUT] new definitions diff --git a/src/ast/normal_forms/cnf_params.pyg b/src/ast/normal_forms/cnf_params.pyg new file mode 100644 index 000000000..3383f674a --- /dev/null +++ b/src/ast/normal_forms/cnf_params.pyg @@ -0,0 +1,4 @@ +def_module_params('cnf', + export=True, + params=(('mode', UINT, 0, 'CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - opportunistic, 3 - full'), + ('factor', UINT, 4, 'the maximum number of clauses that can be created when converting a subformula'))) diff --git a/src/ast/normal_forms/nnf.cpp b/src/ast/normal_forms/nnf.cpp index d525fa167..8e0065071 100644 --- a/src/ast/normal_forms/nnf.cpp +++ b/src/ast/normal_forms/nnf.cpp @@ -18,6 +18,7 @@ Notes: --*/ #include"nnf.h" +#include"nnf_params.hpp" #include"warning.h" #include"used_vars.h" #include"well_sorted.h" @@ -29,6 +30,40 @@ Notes: #include"ast_smt2_pp.h" +/** + \brief NNF translation mode. The cheapest mode is NNF_SKOLEM, and + the most expensive is NNF_FULL. +*/ +enum nnf_mode { + NNF_SKOLEM, /* A subformula is put into NNF only if it contains + quantifiers or labels. The result of the + transformation will be in skolem normal form. + If a formula is too expensive to be put into NNF, + then nested quantifiers and labels are renamed. + + This mode is sufficient when using E-matching. + */ + NNF_QUANT, /* A subformula is put into NNF if it contains + quantifiers, labels, or is in the scope of a + quantifier. The result of the transformation will be + in skolem normal form, and the body of quantifiers + will be in NNF. If a ground formula is too expensive to + be put into NNF, then nested quantifiers and labels + are renamed. + + This mode is sufficient when using Superposition + Calculus. + + Remark: If the problem does not contain quantifiers, + then NNF_QUANT is identical to NNF_SKOLEM. + */ + NNF_OPPORTUNISTIC, /* Similar to NNF_QUANT, but a subformula is + also put into NNF, if it is + cheap. Otherwise, the nested quantifiers and + labels are renamed. */ + NNF_FULL /* Everything is put into NNF. */ +}; + class skolemizer { typedef act_cache cache; @@ -113,20 +148,16 @@ class skolemizer { } public: - skolemizer(ast_manager & m, params_ref const & p): + skolemizer(ast_manager & m): m_manager(m), m_sk_hack("sk_hack"), + m_sk_hack_enabled(false), m_cache(m), m_cache_pr(m) { - updt_params(p); } - void updt_params(params_ref const & p) { - m_sk_hack_enabled = p.get_bool("sk_hack", false); - } - - static void get_param_descrs(param_descrs & r) { - r.insert("sk_hack", CPK_BOOL, "(default: false) hack for VCC"); + void set_sk_hack(bool f) { + m_sk_hack_enabled = f; } ast_manager & m() const { return m_manager; } @@ -220,8 +251,6 @@ struct nnf::imp { name_exprs * m_name_nested_formulas; name_exprs * m_name_quant; - symbol m_skolem; - volatile bool m_cancel; unsigned long long m_max_memory; // in bytes @@ -231,10 +260,9 @@ struct nnf::imp { m_todo_defs(m), m_todo_proofs(m), m_result_pr_stack(m), - m_skolemizer(m, p), - m_skolem("skolem"), + m_skolemizer(m), m_cancel(false) { - updt_local_params(p); + updt_params(p); for (unsigned i = 0; i < 4; i++) { m_cache[i] = alloc(act_cache, m); if (m.proofs_enabled()) @@ -258,14 +286,10 @@ struct nnf::imp { del_name_exprs(m_name_quant); } - void updt_params(params_ref const & p) { - updt_local_params(p); - m_skolemizer.updt_params(p); - } - - void updt_local_params(params_ref const & p) { - symbol mode_sym = p.get_sym("mode", m_skolem); - if (mode_sym == m_skolem) + void updt_params(params_ref const & _p) { + nnf_params p(_p); + symbol mode_sym = p.mode(); + if (mode_sym == "skolem") m_mode = NNF_SKOLEM; else if (mode_sym == "full") m_mode = NNF_FULL; @@ -273,23 +297,17 @@ struct nnf::imp { m_mode = NNF_QUANT; else throw nnf_params_exception("invalid NNF mode"); + + TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << _p << "\n";); - TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << p << "\n";); - - m_ignore_labels = p.get_bool("ignore_labels", false); - m_skolemize = p.get_bool("skolemize", true); - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_ignore_labels = p.ignore_labels(); + m_skolemize = p.skolemize(); + m_max_memory = megabytes_to_bytes(p.max_memory()); + m_skolemizer.set_sk_hack(p.sk_hack()); } static void get_param_descrs(param_descrs & r) { - insert_max_memory(r); - r.insert("mode", CPK_SYMBOL, - "(default: skolem) NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full"); - r.insert("ignore_labels", CPK_BOOL, - "(default: false) remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - r.insert("skolemize", CPK_BOOL, - "(default: true) skolemize (existential force) quantifiers"); - skolemizer::get_param_descrs(r); + nnf_params::collect_param_descrs(r); } void reset() { @@ -881,21 +899,6 @@ nnf::nnf(ast_manager & m, defined_names & n, params_ref const & p) { m_imp = alloc(imp, m, n, p); } -nnf::nnf(ast_manager & m, defined_names & n, nnf_params & np) { - params_ref p; - if (np.m_nnf_mode == NNF_FULL) - p.set_sym("mode", symbol("full")); - else if (np.m_nnf_mode == NNF_QUANT) - p.set_sym("mode", symbol("quantifiers")); - - if (np.m_nnf_ignore_labels) - p.set_bool("ignore_labels", true); - - if (np.m_nnf_sk_hack) - p.set_bool("sk_hack", true); - m_imp = alloc(imp, m, n, p); -} - nnf::~nnf() { dealloc(m_imp); } diff --git a/src/ast/normal_forms/nnf.h b/src/ast/normal_forms/nnf.h index 96807afc0..e8296e933 100644 --- a/src/ast/normal_forms/nnf.h +++ b/src/ast/normal_forms/nnf.h @@ -21,7 +21,6 @@ Notes: #define _NNF_H_ #include"ast.h" -#include"nnf_params.h" #include"params.h" #include"defined_names.h" @@ -30,7 +29,6 @@ class nnf { imp * m_imp; public: nnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); - nnf(ast_manager & m, defined_names & n, nnf_params & params); // for backward compatibility ~nnf(); void operator()(expr * n, // [IN] expression that should be put into NNF diff --git a/src/ast/normal_forms/nnf_params.pyg b/src/ast/normal_forms/nnf_params.pyg new file mode 100644 index 000000000..6fab28f11 --- /dev/null +++ b/src/ast/normal_forms/nnf_params.pyg @@ -0,0 +1,8 @@ +def_module_params('nnf', + export=True, + params=(max_memory_param(), + ('sk_hack', BOOL, False, 'hack for VCC'), + ('mode', SYMBOL, 'skolem', + 'NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full'), + ('ignore_labels', BOOL, False, 'remove/ignore labels in the input formula, this option is ignored if proofs are enabled'), + ('skolemize', BOOL, True, 'skolemize (existential force) quantifiers'))) diff --git a/src/front_end_params/cnf_params.cpp b/src/front_end_params/cnf_params.cpp deleted file mode 100644 index fffd698a6..000000000 --- a/src/front_end_params/cnf_params.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ - -#include"cnf_params.h" - -void cnf_params::register_params(ini_params & p) { - p.register_unsigned_param("cnf_factor", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); - p.register_int_param("cnf_mode", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); -} - diff --git a/src/front_end_params/cnf_params.h b/src/front_end_params/cnf_params.h deleted file mode 100644 index f694e1716..000000000 --- a/src/front_end_params/cnf_params.h +++ /dev/null @@ -1,56 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ -#ifndef _CNF_PARAMS_H_ -#define _CNF_PARAMS_H_ - -#include"ini_file.h" - -/** - \brief CNF translation mode. The cheapest mode is CNF_QUANT, and - the most expensive is CNF_FULL. -*/ -enum cnf_mode { - CNF_DISABLED, /* CNF translator is disabled. - This mode is sufficient when using E-matching. - */ - CNF_QUANT, /* A subformula is put into CNF if it is inside of a - quantifier. - - This mode is sufficient when using Superposition - Calculus. - */ - CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ - CNF_FULL /* Everything is put into CNF, new names are introduced - if it is too expensive. */ -}; - -struct cnf_params { - cnf_mode m_cnf_mode; - unsigned m_cnf_factor; - cnf_params(): - m_cnf_mode(CNF_DISABLED), - m_cnf_factor(4) { - } - - void register_params(ini_params & p); -}; - - -#endif /* _CNF_PARAMS_H_ */ - diff --git a/src/front_end_params/nnf_params.cpp b/src/front_end_params/nnf_params.cpp deleted file mode 100644 index 351997f98..000000000 --- a/src/front_end_params/nnf_params.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - nnf_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-14. - -Revision History: - ---*/ -#include"nnf_params.h" - -void nnf_params::register_params(ini_params & p) { - p.register_unsigned_param("nnf_factor", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); - p.register_int_param("nnf_mode", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); - p.register_bool_param("nnf_ignore_labels", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - p.register_bool_param("nnf_sk_hack", m_nnf_sk_hack, "hack for VCC"); -} diff --git a/src/front_end_params/nnf_params.h b/src/front_end_params/nnf_params.h deleted file mode 100644 index f759a93ac..000000000 --- a/src/front_end_params/nnf_params.h +++ /dev/null @@ -1,74 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - nnf_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-14. - -Revision History: - ---*/ -#ifndef _NNF_PARAMS_H_ -#define _NNF_PARAMS_H_ - -#include"ini_file.h" - -/** - \brief NNF translation mode. The cheapest mode is NNF_SKOLEM, and - the most expensive is NNF_FULL. -*/ -enum nnf_mode { - NNF_SKOLEM, /* A subformula is put into NNF only if it contains - quantifiers or labels. The result of the - transformation will be in skolem normal form. - If a formula is too expensive to be put into NNF, - then nested quantifiers and labels are renamed. - - This mode is sufficient when using E-matching. - */ - NNF_QUANT, /* A subformula is put into NNF if it contains - quantifiers, labels, or is in the scope of a - quantifier. The result of the transformation will be - in skolem normal form, and the body of quantifiers - will be in NNF. If a ground formula is too expensive to - be put into NNF, then nested quantifiers and labels - are renamed. - - This mode is sufficient when using Superposition - Calculus. - - Remark: If the problem does not contain quantifiers, - then NNF_QUANT is identical to NNF_SKOLEM. - */ - NNF_OPPORTUNISTIC, /* Similar to NNF_QUANT, but a subformula is - also put into NNF, if it is - cheap. Otherwise, the nested quantifiers and - labels are renamed. */ - NNF_FULL /* Everything is put into NNF. */ -}; - -struct nnf_params { - nnf_mode m_nnf_mode; - unsigned m_nnf_factor; - bool m_nnf_ignore_labels; - bool m_nnf_sk_hack; - nnf_params(): - m_nnf_mode(NNF_SKOLEM), - m_nnf_factor(4), - m_nnf_ignore_labels(false), - m_nnf_sk_hack(false) { - } - - void register_params(ini_params & p); -}; - -#endif /* _NNF_PARAMS_H_ */ - diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 89bd01b48..00466bc02 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _PREPROCESSOR_PARAMS_H_ #define _PREPROCESSOR_PARAMS_H_ -#include"nnf_params.h" -#include"cnf_params.h" #include"pattern_inference_params.h" #include"bit_blaster_params.h" #include"bv_simplifier_params.h" @@ -31,7 +29,7 @@ enum lift_ite_kind { LI_FULL }; -struct preprocessor_params : public nnf_params, public cnf_params, public pattern_inference_params, +struct preprocessor_params : public pattern_inference_params, public bit_blaster_params, public bv_simplifier_params { lift_ite_kind m_lift_ite; lift_ite_kind m_ng_lift_ite; // lift ite for non ground terms @@ -79,8 +77,6 @@ public: } void register_params(ini_params & p) { - nnf_params::register_params(p); - cnf_params::register_params(p); pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 14db6020a..74e279ff8 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -31,7 +31,6 @@ void smt_params::register_params(ini_params & p) { p.register_bool_param("display_proof", m_display_proof); p.register_bool_param("display_dot_proof", m_display_dot_proof); p.register_bool_param("display_unsat_core", m_display_unsat_core); - p.register_bool_param("internalizer_nnf", m_internalizer_nnf); p.register_bool_param("eq_propagation", m_eq_propagation); p.register_bool_param("bin_clauses", m_binary_clause_opt); p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 20a150c64..5c62c49e3 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -72,7 +72,6 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_display_dot_proof; bool m_display_unsat_core; bool m_check_proof; - bool m_internalizer_nnf; bool m_eq_propagation; bool m_binary_clause_opt; unsigned m_relevancy_lvl; @@ -193,7 +192,6 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_dot_proof(false), m_display_unsat_core(false), m_check_proof(false), - m_internalizer_nnf(false), m_eq_propagation(true), m_binary_clause_opt(true), m_relevancy_lvl(2), diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 15b49ee32..c548eca94 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -25,12 +25,12 @@ Revision History: #include"bv_simplifier_plugin.h" #include"for_each_expr.h" #include"well_sorted.h" +#include"pull_quant.h" #include"pull_ite_tree.h" #include"push_app_ite.h" #include"elim_term_ite.h" #include"pattern_inference.h" #include"nnf.h" -#include"cnf.h" #include"bv_elim.h" #include"inj_axiom.h" #include"der.h" @@ -86,22 +86,6 @@ void asserted_formulas::setup() { if (m_params.m_relevancy_lvl == 0) m_params.m_relevancy_lemma = false; - - switch (m_params.m_cnf_mode) { - case CNF_QUANT: - if (m_params.m_nnf_mode == NNF_SKOLEM) - m_params.m_nnf_mode = NNF_QUANT; - break; - case CNF_OPPORTUNISTIC: - if (m_params.m_nnf_mode == NNF_SKOLEM) - m_params.m_nnf_mode = NNF_QUANT; - break; - case CNF_FULL: - m_params.m_nnf_mode = NNF_FULL; - break; - default: - break; - } } void asserted_formulas::setup_simplifier_plugins(simplifier & s, basic_simplifier_plugin * & bsimp, arith_simplifier_plugin * & asimp, bv_simplifier_plugin * & bvsimp) { @@ -439,13 +423,10 @@ void asserted_formulas::apply_quasi_macros() { } void asserted_formulas::nnf_cnf() { - IF_IVERBOSE(10, verbose_stream() << "applying nnf&cnf...\n";); - nnf apply_nnf(m_manager, m_defined_names, m_params); - cnf apply_cnf(m_manager, m_defined_names, m_params); + IF_IVERBOSE(10, verbose_stream() << "applying nnf...\n";); + nnf apply_nnf(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); - expr_ref_vector cnf_todo(m_manager); - proof_ref_vector cnf_todo_prs(m_manager); expr_ref_vector push_todo(m_manager); proof_ref_vector push_todo_prs(m_manager); @@ -456,60 +437,33 @@ void asserted_formulas::nnf_cnf() { expr * n = m_asserted_formulas.get(i); TRACE("nnf_bug", tout << "processing:\n" << mk_pp(n, m_manager) << "\n";); proof * pr = m_asserted_formula_prs.get(i, 0); - cnf_todo.reset(); - cnf_todo_prs.reset(); expr_ref r1(m_manager); proof_ref pr1(m_manager); CASSERT("well_sorted",is_well_sorted(m_manager, n)); - apply_nnf(n, cnf_todo, cnf_todo_prs, r1, pr1); + apply_nnf(n, push_todo, push_todo_prs, r1, pr1); CASSERT("well_sorted",is_well_sorted(m_manager, r1)); pr = m_manager.mk_modus_ponens(pr, pr1); - cnf_todo.push_back(r1); - cnf_todo_prs.push_back(pr); + push_todo.push_back(r1); + push_todo_prs.push_back(pr); if (canceled()) { return; } - - unsigned sz1 = cnf_todo.size(); - for (unsigned j = 0; j < sz1; j++) { - push_todo.reset(); - push_todo_prs.reset(); - + unsigned sz2 = push_todo.size(); + for (unsigned k = 0; k < sz2; k++) { + expr * n = push_todo.get(k); + proof * pr = 0; + m_simplifier(n, r1, pr1); + CASSERT("well_sorted",is_well_sorted(m_manager, r1)); if (canceled()) { return; } - - expr * n = cnf_todo.get(j); - proof * pr = m_manager.proofs_enabled() ? cnf_todo_prs.get(j) : 0; - - CASSERT("well_sorted",is_well_sorted(m_manager, n)); - apply_cnf(n, push_todo, push_todo_prs, r1, pr1); - CASSERT("well_sorted",is_well_sorted(m_manager, r1)); - - push_todo.push_back(r1); - - if (m_manager.proofs_enabled()) { - pr = m_manager.mk_modus_ponens(pr, pr1); - push_todo_prs.push_back(pr); - } - - unsigned sz2 = push_todo.size(); - for (unsigned k = 0; k < sz2; k++) { - expr * n = push_todo.get(k); - proof * pr = 0; - m_simplifier(n, r1, pr1); - CASSERT("well_sorted",is_well_sorted(m_manager, r1)); - if (canceled()) { - return; - } - - if (m_manager.proofs_enabled()) - pr = m_manager.mk_modus_ponens(push_todo_prs.get(k), pr1); - else - pr = 0; - push_assertion(r1, pr, new_exprs, new_prs); - } + + if (m_manager.proofs_enabled()) + pr = m_manager.mk_modus_ponens(push_todo_prs.get(k), pr1); + else + pr = 0; + push_assertion(r1, pr, new_exprs, new_prs); } } swap_asserted_formulas(new_exprs, new_prs); diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index b44d42fc8..132718e9a 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -654,10 +654,6 @@ namespace smt { protected: unsigned m_generation; //!< temporary variable used during internalization - bool expand_pos_def_only() const { - return m_fparams.m_nnf_mode == NNF_FULL && m_fparams.m_internalizer_nnf; - } - public: bool binary_clause_opt_enabled() const { return !m_manager.proofs_enabled() && m_fparams.m_binary_clause_opt; diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 86b1641bc..0cfe5b1de 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -1566,9 +1566,7 @@ namespace smt { mk_gate_clause(~l, l_arg); buffer.push_back(~l_arg); } - if (!expand_pos_def_only()) { - mk_gate_clause(buffer.size(), buffer.c_ptr()); - } + mk_gate_clause(buffer.size(), buffer.c_ptr()); } void context::mk_or_cnstr(app * n) { @@ -1578,8 +1576,7 @@ namespace smt { unsigned num_args = n->get_num_args(); for (unsigned i = 0; i < num_args; i++) { literal l_arg = get_literal(n->get_arg(i)); - if (!expand_pos_def_only()) - mk_gate_clause(l, ~l_arg); + mk_gate_clause(l, ~l_arg); buffer.push_back(l_arg); } mk_gate_clause(buffer.size(), buffer.c_ptr()); From be5f93320123c198997e1a5567a1417d0f020e74 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 18:20:07 -0800 Subject: [PATCH 065/133] removed dead module Signed-off-by: Leonardo de Moura --- src/ast/normal_forms/cnf.cpp | 527 ---------------------------- src/ast/normal_forms/cnf.h | 141 -------- src/ast/normal_forms/cnf_params.pyg | 4 - 3 files changed, 672 deletions(-) delete mode 100644 src/ast/normal_forms/cnf.cpp delete mode 100644 src/ast/normal_forms/cnf.h delete mode 100644 src/ast/normal_forms/cnf_params.pyg diff --git a/src/ast/normal_forms/cnf.cpp b/src/ast/normal_forms/cnf.cpp deleted file mode 100644 index 2a58b16a6..000000000 --- a/src/ast/normal_forms/cnf.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ -#include"cnf.h" -#include"cnf_params.hpp" -#include"var_subst.h" -#include"ast_util.h" -#include"ast_pp.h" -#include"ast_ll_pp.h" - -unsigned cnf_entry::hash() const { - unsigned a = m_node->get_id(); - unsigned b = m_polarity; - unsigned c = m_in_q; - mix(a,b,c); - return c; -} - -bool cnf_entry::operator==(cnf_entry const & k) const { - return m_node == k.m_node && m_polarity == k.m_polarity && m_in_q == k.m_in_q; -} - -cnf_cache::cnf_cache(ast_manager & m): - m_manager(m) { -} - -void cnf_cache::insert(cnf_entry const & k, expr * r, proof * pr) { - SASSERT(!m_cache.contains(k)); - m_manager.inc_ref(r); - m_manager.inc_ref(pr); - m_cache.insert(k, expr_proof_pair(r, pr)); -} - -void cnf_cache::reset() { - cache::iterator it = m_cache.begin(); - cache::iterator end = m_cache.end(); - for (; it != end; ++it) { - expr_proof_pair & pair = (*it).m_value; - m_manager.dec_ref(pair.first); - m_manager.dec_ref(pair.second); - } - m_cache.reset(); -} - -void cnf::cache_result(expr * e, bool in_q, expr * r, proof * pr) { - SASSERT(r); - TRACE("cnf", tout << "caching result for: " << e->get_id() << " " << r->get_id() << "\n";); - m_cache.insert(cnf_entry(e, true, in_q), r, pr); -} - -void cnf::visit(expr * n, bool in_q, bool & visited) { - if (!is_cached(n, in_q)) { - m_todo.push_back(std::make_pair(n, in_q)); - visited = false; - } -} - -bool cnf::visit_children(expr * n, bool in_q) { - bool visited = true; - switch(n->get_kind()) { - case AST_APP: - if (m_manager.is_or(n) || m_manager.is_and(n) || m_manager.is_label(n)) { - unsigned j = to_app(n)->get_num_args(); - while (j > 0) { - --j; - visit(to_app(n)->get_arg(j), in_q, visited); - } - } - break; - case AST_QUANTIFIER: - visit(to_quantifier(n)->get_expr(), true, visited); - break; - default: - break; - } - return visited; -} - -void cnf::reduce1(expr * n, bool in_q) { - switch(n->get_kind()) { - case AST_APP: - if (m_manager.is_or(n)) - reduce1_or(to_app(n), in_q); - else if (m_manager.is_and(n)) - reduce1_and(to_app(n), in_q); - else if (m_manager.is_label(n)) - reduce1_label(to_app(n), in_q); - else - cache_result(n, in_q, n, 0); - break; - case AST_QUANTIFIER: - reduce1_quantifier(to_quantifier(n), in_q); - break; - default: - cache_result(n, in_q, n, 0); - break; - } -} - -void cnf::get_args(app * n, bool in_q, ptr_buffer & new_args, ptr_buffer & new_arg_prs) { - unsigned num = n->get_num_args(); - for (unsigned i = 0; i < num; i++) { - expr * new_arg = 0; - proof * new_arg_pr = 0; - get_cached(n->get_arg(i), in_q, new_arg, new_arg_pr); - SASSERT(new_arg); - new_args.push_back(new_arg); - if (new_arg_pr) - new_arg_prs.push_back(new_arg_pr); - } -} - -void cnf::flat_args(func_decl * d, ptr_buffer const & args, ptr_buffer & flat_args) { - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (is_app_of(arg, d)) - flat_args.append(to_app(arg)->get_num_args(), to_app(arg)->get_args()); - else - flat_args.push_back(arg); - } -} - -/** - \brief Return the approximated size of distributing OR over AND on - (OR args[0] .... args[sz-1]) -*/ -approx_nat cnf::approx_result_size_for_disj(ptr_buffer const & args) { - approx_nat r(1); - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (m_manager.is_and(arg)) - r *= to_app(arg)->get_num_args(); - } - return r; -} - -/** - \brief Return true if it is too expensive to process the disjunction of args -*/ -inline bool cnf::is_too_expensive(approx_nat approx_result_size, ptr_buffer const & args) { - // (OR A (AND B C)) is always considered cheap. - if (args.size() == 2 && (!m_manager.is_and(args[0]) || !m_manager.is_and(args[1]))) - return false; - return !(approx_result_size < m_cnf_factor); -} - -/** - \brief Create a (positive) name for the expressions of the form (AND ...) in args. - Store the result in new_args. -*/ -void cnf::name_args(ptr_buffer const & args, expr_ref_buffer & new_args, proof_ref_buffer & new_arg_prs) { - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (m_manager.is_and(arg)) { - expr_ref new_def(m_manager); - proof_ref new_def_pr(m_manager); - app_ref new_arg(m_manager); - proof_ref new_arg_pr(m_manager); - - if (m_defined_names.mk_pos_name(to_app(arg), new_def, new_def_pr, new_arg, new_arg_pr)) { - m_todo_defs.push_back(new_def); - if (m_manager.proofs_enabled()) - m_todo_proofs.push_back(new_def_pr); - } - new_args.push_back(new_arg); - - if (m_manager.fine_grain_proofs()) - new_arg_prs.push_back(new_arg_pr); - else - m_coarse_proofs.push_back(new_arg_pr); - } - else - new_args.push_back(arg); - } -} - -void cnf::distribute(app * n, app * & r, proof * & pr) { - SASSERT(m_manager.is_or(n)); - buffer sz; - buffer it; - ptr_buffer new_args; - unsigned num = n->get_num_args(); - for (unsigned i = 0; i < num; i++) { - expr * arg = n->get_arg(i); - it.push_back(0); - if (m_manager.is_and(arg)) - sz.push_back(to_app(arg)->get_num_args()); - else - sz.push_back(1); - } - - do { - ptr_buffer lits; - for (unsigned i = 0; i < num; i++) { - expr * arg = n->get_arg(i); - if (m_manager.is_and(arg)) { - SASSERT(it[i] < to_app(arg)->get_num_args()); - lits.push_back(to_app(arg)->get_arg(it[i])); - } - else { - SASSERT(it[i] == 0); - lits.push_back(arg); - } - } - app * n = m_manager.mk_or(lits.size(), lits.c_ptr()); - new_args.push_back(n); - } - while (product_iterator_next(sz.size(), sz.c_ptr(), it.c_ptr())); - SASSERT(!new_args.empty()); - if (new_args.size() == 1) - r = to_app(new_args[0]); - else - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - pr = 0; - if (m_manager.fine_grain_proofs() && r != n) - pr = m_manager.mk_iff_oeq(m_manager.mk_distributivity(n, r)); -} - -void cnf::push_quant(quantifier * q, expr * & r, proof * & pr) { - SASSERT(is_forall(q)); - expr * e = q->get_expr(); - pr = 0; - if (m_manager.is_and(e)) { - expr_ref_buffer new_args(m_manager); - unsigned num = to_app(e)->get_num_args(); - for (unsigned i = 0; i < num; i++) { - quantifier_ref aux(m_manager); - aux = m_manager.update_quantifier(q, 0, 0, 0, 0, to_app(e)->get_arg(i)); - expr_ref new_arg(m_manager); - elim_unused_vars(m_manager, aux, new_arg); - new_args.push_back(new_arg); - } - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs()) - pr = m_manager.mk_iff_oeq(m_manager.mk_push_quant(q, r)); - } - else { - r = q; - } -} - -void cnf::reduce1_or(app * n, bool in_q) { - ptr_buffer new_args; - ptr_buffer new_arg_prs; - get_args(n, in_q, new_args, new_arg_prs); - expr * r; - proof * pr = 0; - if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { - ptr_buffer f_args; - flat_args(n->get_decl(), new_args, f_args); - TRACE("cnf_or", for (unsigned i = 0; i < f_args.size(); i++) tout << mk_pp(f_args[i], m_manager) << "\n";); - approx_nat result_size = approx_result_size_for_disj(f_args); - TRACE("cnf_or", tout << mk_pp(n, m_manager) << "\napprox. result: " << result_size << "\n";); - if (m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_cnf_factor) { - expr_ref_buffer cheap_args(m_manager); - proof_ref_buffer cheap_args_pr(m_manager); - if (is_too_expensive(result_size, f_args)) { - name_args(f_args, cheap_args, cheap_args_pr); - } - else { - cheap_args.append(f_args.size(), f_args.c_ptr()); - } - - app_ref r1(m_manager); - r1 = m_manager.mk_or(cheap_args.size(), cheap_args.c_ptr()); - - // Proof gen support --------------------------- - // r1 is (OR cheap_args) it is only built if proofs are enabled. - // p1 is a proof for (= n r1) - proof * p1 = 0; - if (m_manager.fine_grain_proofs()) { - proof * prs[3]; - app * r[2]; - r[0] = m_manager.mk_or(new_args.size(), new_args.c_ptr()); - prs[0] = n == r[0] ? 0 : m_manager.mk_oeq_congruence(n, r[0], new_arg_prs.size(), new_arg_prs.c_ptr()); - r[1] = m_manager.mk_or(f_args.size(), f_args.c_ptr()); - prs[1] = r[0] == r[1] ? 0 : m_manager.mk_iff_oeq(m_manager.mk_rewrite(r[0], r[1])); - prs[2] = r[1] == r1 ? 0 : m_manager.mk_oeq_congruence(r[1], r1, cheap_args_pr.size(), cheap_args_pr.c_ptr()); - p1 = m_manager.mk_transitivity(3, prs); - } - // -------------------------------------------- - - expr_ref r2(m_manager); - proof_ref p2(m_manager); - m_pull.pull_quant2(r1, r2, p2); - - if (is_quantifier(r2)) { - expr * e = to_quantifier(r2)->get_expr(); - SASSERT(m_manager.is_or(e)); - app * d_r; - proof * d_pr; - distribute(to_app(e), d_r, d_pr); - quantifier_ref r3(m_manager); - r3 = m_manager.update_quantifier(to_quantifier(r2), d_r); - proof * push_pr; - push_quant(r3, r, push_pr); - if (m_manager.fine_grain_proofs()) { - // p1 is a proof of n == r1 - // p2 is a proof of r1 == r2 - p2 = p2 == 0 ? 0 : m_manager.mk_iff_oeq(p2); - proof * p3 = r2 == r3 ? 0 : m_manager.mk_oeq_quant_intro(to_quantifier(r2), r3, d_pr); - CTRACE("cnf_or", p1, tout << "p1:\n" << mk_pp(m_manager.get_fact(p1), m_manager) << "\n";); - CTRACE("cnf_or", p2, tout << "p2:\n" << mk_pp(m_manager.get_fact(p2), m_manager) << "\n";); - CTRACE("cnf_or", p3, tout << "p3:\n" << mk_pp(m_manager.get_fact(p3), m_manager) << "\n";); - TRACE("cnf_or", tout << "r2 == r3: " << (r2 == r3) << "\n" - << mk_pp(r2, m_manager) << "\n" << mk_pp(r3, m_manager) << "\n";); - pr = m_manager.mk_transitivity(p1, p2, p3, push_pr); - } - cache_result(n, in_q, r, pr); - } - else { - SASSERT(p2 == 0); - SASSERT(r1 == r2); - SASSERT(m_manager.is_or(r2)); - app * r3; - distribute(to_app(r2), r3, pr); - r = r3; - pr = m_manager.mk_transitivity(p1, pr); - cache_result(n, in_q, r, pr); - } - return; - } - } - - r = m_manager.mk_or(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, to_app(r), new_arg_prs.size(), new_arg_prs.c_ptr()); - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_and(app * n, bool in_q) { - ptr_buffer new_args; - ptr_buffer new_arg_prs; - get_args(n, in_q, new_args, new_arg_prs); - app * r; - proof * pr = 0; - if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { - ptr_buffer f_args; - flat_args(n->get_decl(), new_args, f_args); - r = m_manager.mk_and(f_args.size(), f_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) { - app * r0 = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - proof * p0 = r0 == n ? 0 : m_manager.mk_oeq_congruence(n, r0, new_arg_prs.size(), new_arg_prs.c_ptr()); - proof * p1 = r0 == r ? 0 : m_manager.mk_iff_oeq(m_manager.mk_rewrite(r0, r)); - pr = m_manager.mk_transitivity(p0, p1); - } - } - else { - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, r, new_arg_prs.size(), new_arg_prs.c_ptr()); - } - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_label(app * n, bool in_q) { - expr * r; - proof * pr = 0; - expr * new_arg; - proof * new_arg_pr; - get_cached(n->get_arg(0), true, new_arg, new_arg_pr); - if (in_q || m_cnf_mode == CNF_FULL) { - // TODO: in the current implementation, labels are removed during CNF translation. - // This is satisfactory for Boogie, since it does not use labels inside quantifiers, - // and we only need CNF_QUANT for Superposition Calculus. - r = new_arg; - if (m_manager.fine_grain_proofs()) { - proof * p0 = m_manager.mk_iff_oeq(m_manager.mk_rewrite(n, n->get_arg(0))); - pr = m_manager.mk_transitivity(p0, new_arg_pr); - } - } - else { - r = m_manager.mk_app(n->get_decl(), new_arg); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, to_app(r), 1, &new_arg_pr); - } - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_quantifier(quantifier * q, bool in_q) { - expr * new_expr; - proof * new_expr_pr; - get_cached(q->get_expr(), true, new_expr, new_expr_pr); - expr_ref r(m_manager); - proof_ref pr(m_manager); - if (m_manager.is_and(new_expr) && q->is_forall()) { - quantifier_ref q1(m_manager); - q1 = m_manager.update_quantifier(q, new_expr); - expr_ref q2(m_manager); - proof_ref p2(m_manager); - m_pull.pull_quant2(q1, q2, p2); - expr * q3; - proof * p3; - push_quant(to_quantifier(q2), q3, p3); - r = q3; - if (m_manager.fine_grain_proofs()) { - proof * p1 = q == q1 ? 0 : m_manager.mk_oeq_quant_intro(q, q1, new_expr_pr); - p2 = p2 == 0 ? 0 : m_manager.mk_iff_oeq(p2); - pr = m_manager.mk_transitivity(p1, p2, p3); - } - } - else if ((m_manager.is_or(new_expr) || is_forall(new_expr)) && q->is_forall()) { - quantifier_ref q1(m_manager); - q1 = m_manager.update_quantifier(q, new_expr); - m_pull.pull_quant2(q1, r, pr); - if (m_manager.fine_grain_proofs()) { - pr = pr == 0 ? 0 : m_manager.mk_iff_oeq(pr); - proof * p1 = q == q1 ? 0 : m_manager.mk_oeq_quant_intro(q, q1, new_expr_pr); - pr = m_manager.mk_transitivity(p1, pr); - } - } - else { - r = m_manager.update_quantifier(q, new_expr); - if (m_manager.fine_grain_proofs() && r != q) - pr = q == r ? 0 : m_manager.mk_oeq_quant_intro(q, to_quantifier(r), new_expr_pr); - } - - cache_result(q, in_q, r, pr); - TRACE("cnf_quant", tout << mk_pp(q, m_manager) << "\n" << mk_pp(r, m_manager) << "\n";); -} - -cnf::cnf(ast_manager & m, defined_names & n, params_ref const & params): - m_manager(m), - m_defined_names(n), - m_pull(m), - m_cache(m), - m_todo_defs(m), - m_todo_proofs(m), - m_coarse_proofs(m) { - cnf_params p(params); - m_cnf_mode = static_cast(p.mode()); - m_cnf_factor = p.factor(); -} - -cnf::~cnf() { -} - -void cnf::reduce(expr * n, expr_ref & r, proof_ref & pr) { - m_coarse_proofs.reset(); - m_todo.reset(); - m_todo.push_back(expr_bool_pair(n, false)); - while (!m_todo.empty()) { - expr_bool_pair pair = m_todo.back(); - expr * n = pair.first; - bool in_q = pair.second; - if (is_cached(n, in_q)) { - m_todo.pop_back(); - } - else if (visit_children(n, in_q)) { - m_todo.pop_back(); - reduce1(n, in_q); - } - } - expr * r2; - proof * pr2; - get_cached(n, false, r2, pr2); - r = r2; - switch (m_manager.proof_mode()) { - case PGM_DISABLED: - pr = m_manager.mk_undef_proof(); - break; - case PGM_COARSE: - remove_duplicates(m_coarse_proofs); - pr = n == r2 ? m_manager.mk_reflexivity(n) : m_manager.mk_cnf_star(n, r2, m_coarse_proofs.size(), m_coarse_proofs.c_ptr()); - break; - case PGM_FINE: - pr = pr2 == 0 ? m_manager.mk_reflexivity(n) : pr2; - break; - } -} - -void cnf::operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & pr) { - if (m_cnf_mode == CNF_DISABLED) { - r = n; - pr = m_manager.mk_reflexivity(n); - return; - } - - reset(); - reduce(n, r, pr); - for (unsigned i = 0; i < m_todo_defs.size(); i++) { - expr_ref dr(m_manager); - proof_ref dpr(m_manager); - reduce(m_todo_defs.get(i), dr, dpr); - m_result_defs.push_back(dr); - if (m_manager.proofs_enabled()) { - proof * new_pr = m_manager.mk_modus_ponens(m_todo_proofs.get(i), dpr); - m_result_def_proofs.push_back(new_pr); - } - else - m_result_def_proofs.push_back(m_manager.mk_undef_proof()); - } - std::reverse(m_result_defs.begin(), m_result_defs.end()); - new_defs.append(m_result_defs.size(), m_result_defs.c_ptr()); - std::reverse(m_result_def_proofs.begin(), m_result_def_proofs.end()); - new_def_proofs.append(m_result_def_proofs.size(), m_result_def_proofs.c_ptr()); -} - -void cnf::reset() { - m_cache.reset(); - m_todo.reset(); - m_todo_defs.reset(); - m_todo_proofs.reset(); - m_result_defs.reset(); - m_result_def_proofs.reset(); -} diff --git a/src/ast/normal_forms/cnf.h b/src/ast/normal_forms/cnf.h deleted file mode 100644 index 8aa390c48..000000000 --- a/src/ast/normal_forms/cnf.h +++ /dev/null @@ -1,141 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf.h - -Abstract: - - CNF translation - -Author: - - Leonardo de Moura (leonardo) 2008-01-17. - -Revision History: - ---*/ -#ifndef _CNF_H_ -#define _CNF_H_ - -#include"pull_quant.h" -#include"nnf.h" -#include"approx_nat.h" - -/** - \brief CNF translation mode. The cheapest mode is CNF_QUANT, and - the most expensive is CNF_FULL. -*/ -enum cnf_mode { - CNF_DISABLED, /* CNF translator is disabled. - This mode is sufficient when using E-matching. - */ - CNF_QUANT, /* A subformula is put into CNF if it is inside of a - quantifier. - - This mode is sufficient when using Superposition - Calculus. - */ - CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ - CNF_FULL /* Everything is put into CNF, new names are introduced - if it is too expensive. */ -}; - -/** - \brief Entry into the todo list of the CNF translator. It is also used as the key in the CNF cache. -*/ -struct cnf_entry { - expr * m_node; - bool m_polarity:1; - bool m_in_q:1; - cnf_entry():m_node(0), m_polarity(false), m_in_q(false) {} - cnf_entry(expr * n, bool p, bool in_q):m_node(n), m_polarity(p), m_in_q(in_q) {} - unsigned hash() const; - bool operator==(cnf_entry const & k) const; -}; - -/** - \brief Cache for CNF transformation. It is a mapping from (expr, polarity, in_q) -> (expr, proof) -*/ -class cnf_cache { -public: - typedef std::pair expr_proof_pair; - - typedef map, default_eq > cache; - - ast_manager & m_manager; - cache m_cache; - -public: - cnf_cache(ast_manager & m); - ~cnf_cache() { reset(); } - void insert(cnf_entry const & k, expr * r, proof * pr); - bool contains(cnf_entry const & k) const { return m_cache.contains(k); } - void get(cnf_entry const & k, expr * & r, proof * & pr) const { expr_proof_pair tmp; m_cache.find(k, tmp); r = tmp.first; pr = tmp.second; } - void reset(); -}; - -/** - \brief Functor for converting expressions into CNF. The functor can - optionally process subformulas nested in quantifiers. New names may be - introduced for subformulas that are too expensive to be put into CNF. - - NNF translation must be applied before converting to CNF. - - - To use CNF_QUANT, we must use at least NNF_QUANT - - To use CNF_OPPORTUNISTIC, we must use at least NNF_QUANT - - To use CNF_FULL, we must use NNF_FULL -*/ -class cnf { - typedef std::pair expr_bool_pair; - ast_manager & m_manager; - defined_names & m_defined_names; - pull_quant m_pull; - cnf_cache m_cache; - svector m_todo; - expr_ref_vector m_todo_defs; - proof_ref_vector m_todo_proofs; - ptr_vector m_result_defs; - ptr_vector m_result_def_proofs; - proof_ref_vector m_coarse_proofs; - - cnf_mode m_cnf_mode; - unsigned m_cnf_factor; - - void cache_result(expr * e, bool in_q, expr * r, proof * pr); - void get_cached(expr * n, bool in_q, expr * & r, proof * & pr) const { m_cache.get(cnf_entry(n, true, in_q), r, pr); } - bool is_cached(expr * n, bool in_q) const { return m_cache.contains(cnf_entry(n, true, in_q)); } - - void visit(expr * n, bool in_q, bool & visited); - bool visit_children(expr * n, bool in_q); - - void get_args(app * n, bool in_q, ptr_buffer & new_args, ptr_buffer & new_arg_prs); - void flat_args(func_decl * d, ptr_buffer const & args, ptr_buffer & flat_args); - approx_nat approx_result_size_for_disj(ptr_buffer const & args); - bool is_too_expensive(approx_nat approx_result_size, ptr_buffer const & args); - void name_args(ptr_buffer const & args, expr_ref_buffer & new_args, proof_ref_buffer & new_arg_prs); - void distribute(app * arg, app * & r, proof * & pr); - void push_quant(quantifier * q, expr * & r, proof * & pr); - void reduce1(expr * n, bool in_q); - void reduce1_or(app * n, bool in_q); - void reduce1_and(app * n, bool in_q); - void reduce1_label(app * n, bool in_q); - void reduce1_quantifier(quantifier * q, bool in_q); - - void reduce(expr * n, expr_ref & r, proof_ref & pr); -public: - cnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); - ~cnf(); - void operator()(expr * n, // [IN] expression that should be put into CNF - expr_ref_vector & new_defs, // [OUT] new definitions - proof_ref_vector & new_def_proofs, // [OUT] proofs of the new definitions - expr_ref & r, // [OUT] resultant expression - proof_ref & p // [OUT] proof for (~ n r) - ); - - void reset(); -}; - -#endif /* _CNF_H_ */ - diff --git a/src/ast/normal_forms/cnf_params.pyg b/src/ast/normal_forms/cnf_params.pyg deleted file mode 100644 index 3383f674a..000000000 --- a/src/ast/normal_forms/cnf_params.pyg +++ /dev/null @@ -1,4 +0,0 @@ -def_module_params('cnf', - export=True, - params=(('mode', UINT, 0, 'CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - opportunistic, 3 - full'), - ('factor', UINT, 4, 'the maximum number of clauses that can be created when converting a subformula'))) From f78e595b566cbb9d6f5d55311a046268dd97c98c Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 1 Dec 2012 15:51:33 +0000 Subject: [PATCH 066/133] Added QF_FPABV logic, default tactic, and the asIEEEBV conversion function. Signed-off-by: Christoph M. Wintersteiger --- src/ast/float_decl_plugin.cpp | 30 +++++++++++-- src/ast/float_decl_plugin.h | 9 +++- src/ast/rewriter/float_rewriter.cpp | 5 +++ src/ast/rewriter/float_rewriter.h | 2 + src/cmd_context/cmd_context.cpp | 6 ++- src/tactic/fpa/fpa2bv_converter.cpp | 45 +++++++++++++++++-- src/tactic/fpa/fpa2bv_converter.h | 1 + src/tactic/fpa/fpa2bv_rewriter.h | 1 + src/tactic/fpa/qffpa_tactic.h | 1 + src/tactic/portfolio/smt_strategic_solver.cpp | 1 + 10 files changed, 90 insertions(+), 11 deletions(-) diff --git a/src/ast/float_decl_plugin.cpp b/src/ast/float_decl_plugin.cpp index 7cf8f32bd..dbe7d5232 100644 --- a/src/ast/float_decl_plugin.cpp +++ b/src/ast/float_decl_plugin.cpp @@ -348,13 +348,13 @@ func_decl * float_decl_plugin::mk_to_float(decl_kind k, unsigned num_parameters, // When the bv_decl_plugin is installed, then we know how to convert 3 bit-vectors into a float! sort * fp = mk_float_sort(domain[2]->get_parameter(0).get_int(), domain[1]->get_parameter(0).get_int()+1); symbol name("asFloat"); - return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters)); - } + return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters)); + } else { // .. Otherwise we only know how to convert rationals/reals. if (!(num_parameters == 2 && parameters[0].is_int() && parameters[1].is_int())) m_manager->raise_exception("expecting two integer parameters to asFloat"); - if (arity != 2 && arity != 3) + if (arity != 2 && arity != 3) m_manager->raise_exception("invalid number of arguments to asFloat operator"); if (!is_rm_sort(domain[0]) || domain[1] != m_real_sort) m_manager->raise_exception("sort mismatch"); @@ -373,6 +373,23 @@ func_decl * float_decl_plugin::mk_to_float(decl_kind k, unsigned num_parameters, } } +func_decl * float_decl_plugin::mk_to_ieee_bv(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) { + if (!m_bv_plugin) + m_manager->raise_exception("asIEEEBV unsupported; use a logic with BV support"); + if (arity != 1) + m_manager->raise_exception("invalid number of arguments to asIEEEBV"); + if (!is_float_sort(domain[0])) + m_manager->raise_exception("sort mismatch"); + + // When the bv_decl_plugin is installed, then we know how to convert a float to an IEEE bit-vector. + unsigned float_sz = domain[0]->get_parameter(0).get_int() + domain[0]->get_parameter(1).get_int(); + parameter ps[] = { parameter(float_sz) }; + sort * bv_srt = m_bv_plugin->mk_sort(m_bv_fid, 1, ps); + symbol name("asIEEEBV"); + return m_manager->mk_func_decl(name, 1, domain, bv_srt, func_decl_info(m_family_id, k, num_parameters, parameters)); +} + func_decl * float_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range) { switch (k) { @@ -420,6 +437,8 @@ func_decl * float_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters return mk_rm_unary_decl(k, num_parameters, parameters, arity, domain, range); case OP_FLOAT_FUSED_MA: return mk_fused_ma(k, num_parameters, parameters, arity, domain, range); + case OP_TO_IEEE_BV: + return mk_to_ieee_bv(k, num_parameters, parameters, arity, domain, range); default: m_manager->raise_exception("unsupported floating point operator"); return 0; @@ -462,7 +481,10 @@ void float_decl_plugin::get_op_names(svector & op_names, symbol co op_names.push_back(builtin_name("min", OP_FLOAT_MIN)); op_names.push_back(builtin_name("max", OP_FLOAT_MAX)); - op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT)); + op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT)); + + if (m_bv_plugin) + op_names.push_back(builtin_name("asIEEEBV", OP_TO_IEEE_BV)); } void float_decl_plugin::get_sort_names(svector & sort_names, symbol const & logic) { diff --git a/src/ast/float_decl_plugin.h b/src/ast/float_decl_plugin.h index 416275306..c4503349b 100644 --- a/src/ast/float_decl_plugin.h +++ b/src/ast/float_decl_plugin.h @@ -67,6 +67,7 @@ enum float_op_kind { OP_FLOAT_IS_SIGN_MINUS, OP_TO_FLOAT, + OP_TO_IEEE_BV, LAST_FLOAT_OP }; @@ -118,6 +119,8 @@ class float_decl_plugin : public decl_plugin { unsigned arity, sort * const * domain, sort * range); func_decl * mk_to_float(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range); + func_decl * mk_to_ieee_bv(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range); virtual void set_manager(ast_manager * m, family_id id); unsigned mk_id(mpf const & v); @@ -159,7 +162,7 @@ class float_util { ast_manager & m_manager; float_decl_plugin * m_plugin; family_id m_fid; - arith_util m_a_util; + arith_util m_a_util; public: float_util(ast_manager & m); ~float_util(); @@ -209,7 +212,7 @@ public: bool is_to_float(expr * n) { return is_app_of(n, m_fid, OP_TO_FLOAT); } - app * mk_to_float(expr * arg1, expr * arg2) { return m().mk_app(m_fid, OP_TO_FLOAT, arg1, arg2); } + app * mk_to_float(expr * arg1, expr * arg2) { return m().mk_app(m_fid, OP_TO_FLOAT, arg1, arg2); } app * mk_add(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_ADD, arg1, arg2, arg3); } app * mk_mul(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_MUL, arg1, arg2, arg3); } app * mk_sub(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_SUB, arg1, arg2, arg3); } @@ -238,6 +241,8 @@ public: app * mk_is_sign_minus(expr * arg1) { return m().mk_app(m_fid, OP_FLOAT_IS_SIGN_MINUS, arg1); } bool is_uminus(expr * a) { return is_app_of(a, m_fid, OP_FLOAT_UMINUS); } + + app * mk_to_ieee_bv(expr * arg1) { return m().mk_app(m_fid, OP_TO_IEEE_BV, arg1); } }; #endif diff --git a/src/ast/rewriter/float_rewriter.cpp b/src/ast/rewriter/float_rewriter.cpp index ad0709423..9678af216 100644 --- a/src/ast/rewriter/float_rewriter.cpp +++ b/src/ast/rewriter/float_rewriter.cpp @@ -59,6 +59,7 @@ br_status float_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c case OP_FLOAT_IS_NZERO: SASSERT(num_args == 1); st = mk_is_nzero(args[0], result); break; case OP_FLOAT_IS_PZERO: SASSERT(num_args == 1); st = mk_is_pzero(args[0], result); break; case OP_FLOAT_IS_SIGN_MINUS: SASSERT(num_args == 1); st = mk_is_sign_minus(args[0], result); break; + case OP_TO_IEEE_BV: SASSERT(num_args == 1); st = mk_to_ieee_bv(args[0], result); break; } return st; } @@ -439,3 +440,7 @@ br_status float_rewriter::mk_eq_core(expr * arg1, expr * arg2, expr_ref & result return BR_FAILED; } + +br_status float_rewriter::mk_to_ieee_bv(expr * arg1, expr_ref & result) { + return BR_FAILED; +} \ No newline at end of file diff --git a/src/ast/rewriter/float_rewriter.h b/src/ast/rewriter/float_rewriter.h index e4258895d..7c86a5bc3 100644 --- a/src/ast/rewriter/float_rewriter.h +++ b/src/ast/rewriter/float_rewriter.h @@ -67,6 +67,8 @@ public: br_status mk_is_nzero(expr * arg1, expr_ref & result); br_status mk_is_pzero(expr * arg1, expr_ref & result); br_status mk_is_sign_minus(expr * arg1, expr_ref & result); + + br_status mk_to_ieee_bv(expr * arg1, expr_ref & result); }; #endif diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index afcac48ac..9ec11d085 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -460,6 +460,7 @@ bool cmd_context::logic_has_arith_core(symbol const & s) const { s == "LIA" || s == "LRA" || s == "QF_FPA" || + s == "QF_FPABV" || s == "HORN"; } @@ -478,6 +479,7 @@ bool cmd_context::logic_has_bv_core(symbol const & s) const { s == "QF_ABV" || s == "QF_AUFBV" || s == "QF_BVRE" || + s == "QF_FPABV" || s == "HORN"; } @@ -502,7 +504,7 @@ bool cmd_context::logic_has_seq() const { } bool cmd_context::logic_has_floats() const { - return !has_logic() || m_logic == "QF_FPA"; + return !has_logic() || m_logic == "QF_FPA" || m_logic == "QF_FPABV"; } bool cmd_context::logic_has_array_core(symbol const & s) const { @@ -599,7 +601,7 @@ bool cmd_context::supported_logic(symbol const & s) const { logic_has_arith_core(s) || logic_has_bv_core(s) || logic_has_array_core(s) || logic_has_seq_core(s) || logic_has_horn(s) || - s == "QF_FPA"; + s == "QF_FPA" || s == "QF_FPABV"; } void cmd_context::set_logic(symbol const & s) { diff --git a/src/tactic/fpa/fpa2bv_converter.cpp b/src/tactic/fpa/fpa2bv_converter.cpp index 77ff50e9b..21d5a2d23 100644 --- a/src/tactic/fpa/fpa2bv_converter.cpp +++ b/src/tactic/fpa/fpa2bv_converter.cpp @@ -1399,6 +1399,13 @@ void fpa2bv_converter::mk_to_float(func_decl * f, unsigned num, expr * const * a } } +void fpa2bv_converter::mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * args, expr_ref & result) { + SASSERT(num == 1); + expr * sgn, * s, * e; + split(args[0], sgn, s, e); + result = m_bv_util.mk_concat(m_bv_util.mk_concat(sgn, s), e); +} + void fpa2bv_converter::split(expr * e, expr * & sgn, expr * & sig, expr * & exp) const { SASSERT(is_app_of(e, m_plugin->get_family_id(), OP_TO_FLOAT)); SASSERT(to_app(e)->get_num_args() == 3); @@ -2035,7 +2042,8 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { tout << bv_mdl->get_constant(i)->get_name() << " --> " << mk_ismt2_pp(bv_mdl->get_const_interp(bv_mdl->get_constant(i)), m) << std::endl; ); - + + obj_hashtable seen; for (obj_map::iterator it = m_const2bv.begin(); it != m_const2bv.end(); @@ -2053,6 +2061,10 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { expr * sig = bv_mdl->get_const_interp(to_app(a->get_arg(1))->get_decl()); expr * exp = bv_mdl->get_const_interp(to_app(a->get_arg(2))->get_decl()); + seen.insert(to_app(a->get_arg(0))->get_decl()); + seen.insert(to_app(a->get_arg(1))->get_decl()); + seen.insert(to_app(a->get_arg(2))->get_decl()); + if (!sgn && !sig && !exp) continue; @@ -2080,7 +2092,7 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { fu.fm().set(fp_val, ebits, sbits, !mpqm.is_zero(sgn_q.to_mpq()), sig_z, exp_z); float_mdl->register_decl(var, fu.mk_value(fp_val)); - + mpzm.del(sig_z); } @@ -2104,9 +2116,36 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { case BV_RM_TO_POSITIVE: float_mdl->register_decl(var, fu.mk_round_toward_positive()); break; case BV_RM_TO_ZERO: default: float_mdl->register_decl(var, fu.mk_round_toward_zero()); - } + } + seen.insert(var); } } fu.fm().del(fp_val); + + // Keep all the non-float constants. + unsigned sz = bv_mdl->get_num_constants(); + for (unsigned i = 0; i < sz; i++) + { + func_decl * c = bv_mdl->get_constant(i); + if (seen.contains(c)) + continue; + float_mdl->register_decl(c, bv_mdl->get_const_interp(c)); + } + + // And keep everything else + sz = bv_mdl->get_num_functions(); + for (unsigned i = 0; i < sz; i++) + { + func_decl * c = bv_mdl->get_function(i); + float_mdl->register_decl(c, bv_mdl->get_const_interp(c)); + } + + sz = bv_mdl->get_num_uninterpreted_sorts(); + for (unsigned i = 0; i < sz; i++) + { + sort * s = bv_mdl->get_uninterpreted_sort(i); + ptr_vector u = bv_mdl->get_universe(s); + float_mdl->register_usort(s, u.size(), u.c_ptr()); + } } diff --git a/src/tactic/fpa/fpa2bv_converter.h b/src/tactic/fpa/fpa2bv_converter.h index 291120e92..1ee374941 100644 --- a/src/tactic/fpa/fpa2bv_converter.h +++ b/src/tactic/fpa/fpa2bv_converter.h @@ -100,6 +100,7 @@ public: void mk_is_sign_minus(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_float(func_decl * f, unsigned num, expr * const * args, expr_ref & result); + void mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * args, expr_ref & result); fpa2bv_model_converter * mk_model_converter(); diff --git a/src/tactic/fpa/fpa2bv_rewriter.h b/src/tactic/fpa/fpa2bv_rewriter.h index 62c6f1a2d..91682c6e1 100644 --- a/src/tactic/fpa/fpa2bv_rewriter.h +++ b/src/tactic/fpa/fpa2bv_rewriter.h @@ -129,6 +129,7 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg { case OP_FLOAT_IS_PZERO: m_conv.mk_is_pzero(f, num, args, result); return BR_DONE; case OP_FLOAT_IS_SIGN_MINUS: m_conv.mk_is_sign_minus(f, num, args, result); return BR_DONE; case OP_TO_FLOAT: m_conv.mk_to_float(f, num, args, result); return BR_DONE; + case OP_TO_IEEE_BV: m_conv.mk_to_ieee_bv(f, num, args, result); return BR_DONE; default: TRACE("fpa2bv", tout << "unsupported operator: " << f->get_name() << "\n"; for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m()) << std::endl;); diff --git a/src/tactic/fpa/qffpa_tactic.h b/src/tactic/fpa/qffpa_tactic.h index 660565463..8ca2183c1 100644 --- a/src/tactic/fpa/qffpa_tactic.h +++ b/src/tactic/fpa/qffpa_tactic.h @@ -27,6 +27,7 @@ class tactic; tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p = params_ref()); /* ADD_TACTIC("qffpa", "(try to) solve goal using the tactic for QF_FPA.", "mk_qffpa_tactic(m, p)") + ADD_TACTIC("qffpabv", "(try to) solve goal using the tactic for QF_FPABV (floats+bit-vectors).", "mk_qffpa_tactic(m, p)") */ #endif diff --git a/src/tactic/portfolio/smt_strategic_solver.cpp b/src/tactic/portfolio/smt_strategic_solver.cpp index 4cf530b1e..7a274a830 100644 --- a/src/tactic/portfolio/smt_strategic_solver.cpp +++ b/src/tactic/portfolio/smt_strategic_solver.cpp @@ -79,6 +79,7 @@ static void init(strategic_solver * s) { s->set_tactic_for(symbol("UFBV"), alloc(ufbv_fct)); s->set_tactic_for(symbol("BV"), alloc(ufbv_fct)); s->set_tactic_for(symbol("QF_FPA"), alloc(qffpa_fct)); + s->set_tactic_for(symbol("QF_FPABV"), alloc(qffpa_fct)); s->set_tactic_for(symbol("HORN"), alloc(horn_fct)); } From 589f096e6ea077df8a6dd938c15aa877c73d6ee6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 15:54:34 -0800 Subject: [PATCH 067/133] working on new parameter framework Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 2 +- src/api/api_config_params.cpp | 62 ++++--- src/api/api_datalog.cpp | 2 +- src/api/api_model.cpp | 7 +- src/api/api_parsers.cpp | 4 +- src/api/python/z3.py | 50 +++--- src/api/z3_api.h | 95 +++++++---- src/ast/pattern/expr_pattern_match.cpp | 3 +- src/cmd_context/basic_cmds.cpp | 6 +- src/cmd_context/cmd_context.cpp | 18 +- src/cmd_context/cmd_context.h | 8 +- src/front_end_params/README | 9 + src/front_end_params/front_end_params.cpp | 23 --- src/front_end_params/front_end_params.h | 35 +--- src/front_end_params/model_params.cpp | 35 ---- src/front_end_params/model_params.h | 43 ----- src/front_end_params/parser_params.cpp | 14 -- src/front_end_params/parser_params.h | 33 ---- src/front_end_params/smt_params.cpp | 12 ++ src/front_end_params/smt_params.h | 18 +- src/parsers/smt/smtlib_solver.cpp | 10 +- src/parsers/smt2/smt2parser.cpp | 26 ++- src/parsers/smt2/smt2parser.h | 2 +- src/parsers/smt2/smt2scanner.cpp | 9 +- src/parsers/smt2/smt2scanner.h | 4 +- src/parsers/util/parser_params.pyg | 6 + src/shell/main.cpp | 16 +- src/shell/smtlib_frontend.cpp | 2 +- src/smt/proto_model/proto_model.cpp | 8 +- src/smt/proto_model/proto_model.h | 9 +- src/smt/smt_model_generator.cpp | 3 +- src/util/gparams.cpp | 190 ++++++++++++++++------ src/util/gparams.h | 8 +- src/util/memory_manager.cpp | 25 ++- src/util/params.cpp | 14 +- src/util/params.h | 2 + 36 files changed, 436 insertions(+), 377 deletions(-) create mode 100644 src/front_end_params/README delete mode 100644 src/front_end_params/model_params.cpp delete mode 100644 src/front_end_params/model_params.h delete mode 100644 src/front_end_params/parser_params.cpp delete mode 100644 src/front_end_params/parser_params.h create mode 100644 src/parsers/util/parser_params.pyg diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 782990cd7..1df3c082e 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1472,7 +1472,7 @@ def def_module_params(module_name, export, params): out.write('struct %s_params {\n' % module_name) out.write(' params_ref const & p;\n') if export: - out.write(' params_ref const & g;\n') + out.write(' params_ref g;\n') out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) out.write(' p(_p)') if export: diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 7a0303234..6adcced44 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -36,9 +36,45 @@ namespace api { }; extern "C" { + void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) { + memory::initialize(UINT_MAX); + LOG_Z3_global_param_set(param_id, param_value); + try { + gparams::set(param_id, param_value); + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ", " << ex.msg(); + warning_msg(buffer.str().c_str()); + } + } + + std::string g_Z3_global_param_get_buffer; + + Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) { + memory::initialize(UINT_MAX); + LOG_Z3_global_param_get(param_id, param_value); + *param_value = 0; + try { + g_Z3_global_param_get_buffer = gparams::get_value(param_id); + *param_value = g_Z3_global_param_get_buffer.c_str(); + return Z3_TRUE; + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ", " << ex.msg(); + warning_msg(buffer.str().c_str()); + return Z3_FALSE; + } + } + Z3_config Z3_API Z3_mk_config() { + memory::initialize(UINT_MAX); LOG_Z3_mk_config(); - memory::initialize(0); Z3_config r = reinterpret_cast(alloc(api::config_params)); RETURN_Z3(r); } @@ -49,35 +85,19 @@ extern "C" { } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { - // REMARK: we don't need Z3_config anymore - try { - LOG_Z3_set_param_value(c, param_id, param_value); - gparams::set(param_id, param_value); - } - catch (gparams::exception & ex) { - // The error handler was not set yet. - // Just throw a warning. - std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.msg(); - warning_msg(buffer.str().c_str()); - } + LOG_Z3_set_param_value(c, param_id, param_value); + // PARAM-TODO save the parameter } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { - Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - gparams::set(param_id, param_value); - // TODO: set memory limits - // memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); - // memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); - Z3_CATCH; + // NOOP in the current version } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); - // TODO: we don't really have support for that anymore. - return false; + return Z3_FALSE; } }; diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 3c434600b..34ca9627a 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -344,7 +344,7 @@ extern "C" { std::istream& s) { ast_manager& m = mk_c(c)->m(); dl_collected_cmds coll(m); - cmd_context ctx(&mk_c(c)->fparams(), false, &m); + cmd_context ctx(false, &m); install_dl_collect_cmds(coll, ctx); ctx.set_ignore_check(true); if (!parse_smt2_commands(ctx, s)) { diff --git a/src/api/api_model.cpp b/src/api/api_model.cpp index a6ada4ae6..80577efee 100644 --- a/src/api/api_model.cpp +++ b/src/api/api_model.cpp @@ -25,6 +25,7 @@ Revision History: #include"model.h" #include"model_v2_pp.h" #include"model_smt2_pp.h" +#include"model_params.hpp" extern "C" { @@ -488,7 +489,8 @@ extern "C" { Z3_model m, Z3_ast t, Z3_ast * v) { - return Z3_model_eval(c, m, t, mk_c(c)->fparams().m_model_completion, v); + model_params p; + return Z3_model_eval(c, m, t, p.completion(), v); } Z3_bool Z3_API Z3_eval_func_decl(Z3_context c, @@ -660,7 +662,8 @@ extern "C" { result.resize(result.size()-1); } else { - model_v2_pp(buffer, *(to_model_ref(m)), mk_c(c)->fparams().m_model_partial); + model_params p; + model_v2_pp(buffer, *(to_model_ref(m)), p.partial()); result = buffer.str(); } return mk_c(c)->mk_external_string(result); diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index b6d18096f..69ca1fc81 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -296,7 +296,7 @@ extern "C" { Z3_symbol const decl_names[], Z3_func_decl const decls[]) { Z3_TRY; - cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m())); + cmd_context ctx(false, &(mk_c(c)->m())); ctx.set_ignore_check(true); if (exec) { ctx.set_solver(alloc(z3_context_solver, *mk_c(c))); @@ -362,7 +362,7 @@ extern "C" { Z3_symbol decl_names[], Z3_func_decl decls[]) { Z3_TRY; - cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m())); + cmd_context ctx(false, &(mk_c(c)->m())); std::string s(str); std::istringstream is(s); // No logging for this one, since it private. diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 94031cce6..b03cf1fd8 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -169,28 +169,6 @@ class Context: """ Z3_interrupt(self.ref()) - def set(self, *args, **kws): - """Set global configuration options. - - Z3 command line options can be set using this method. - The option names can be specified in different ways: - - >>> ctx = Context() - >>> ctx.set('WELL_SORTED_CHECK', True) - >>> ctx.set(':well-sorted-check', True) - >>> ctx.set(well_sorted_check=True) - """ - if __debug__: - _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.") - for key, value in kws.iteritems(): - Z3_update_param_value(self.ctx, str(key).upper(), _to_param_value(value)) - prev = None - for a in args: - if prev == None: - prev = a - else: - Z3_update_param_value(self.ctx, str(prev), _to_param_value(a)) - prev = None # Global Z3 context _main_ctx = None @@ -221,15 +199,37 @@ def _get_ctx(ctx): return ctx def set_option(*args, **kws): - """Update parameters of the global context `main_ctx()`, and global configuration options of Z3Py. See `Context.set()`. - + """Set Z3 global (or module) parameters. + >>> set_option(precision=10) """ + if __debug__: + _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.") new_kws = {} for k, v in kws.iteritems(): if not set_pp_option(k, v): new_kws[k] = v - main_ctx().set(*args, **new_kws) + for key, value in new_kws.iteritems(): + Z3_global_param_set(str(key).upper(), _to_param_value(value)) + prev = None + for a in args: + if prev == None: + prev = a + else: + Z3_global_param_set(str(prev), _to_param_value(a)) + prev = None + +def get_option(name): + """Return the value of a Z3 global (or module) parameter + + >>> get_option('nlsat.reorder') + true + """ + ptr = (ctypes.c_char_p * 1)() + if Z3_global_param_get(str(name), ptr): + r = str(ptr[0]) + return r + raise Z3Exception("failed to retrieve value for '%s'" % name) ######################################### # diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 9570af43b..a0c6434c2 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1233,25 +1233,82 @@ extern "C" { #endif // CAMLIDL #ifdef CorML3 + /** + @name Configuration + */ + + /*@{*/ + /** + \brief Set a global (or module) parameter. + This setting is shared by all Z3 contexts. + + When a Z3 module is initialized it will use the value of these parameters + when Z3_params objects are not provided. + + The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. + The character '.' is a delimiter (more later). + + The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. + Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION". + + This function can be used to set parameters for a specific Z3 module. + This can be done by using .. + For example: + Z3_global_param_set('pp.decimal', 'true') + will set the parameter "decimal" in the module "pp" to true. + + def_API('Z3_global_param_set', VOID, (_in(STRING), _in(STRING))) + */ + void Z3_API Z3_global_param_set(__in Z3_string param_id, __in Z3_string param_value); + + /** + \brief Get a global (or module) parameter. + + Returns \mlonly \c None \endmlonly \conly \c Z3_FALSE + if the parameter value does not exist. + + \sa Z3_global_param_set + + The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value. + + \remark This function cannot be invoked simultaneously from different threads without synchronization. + The result string stored in param_value is stored in shared location. + + def_API('Z3_global_param_get', BOOL, (_in(STRING), _out(STRING))) + */ + Z3_bool_opt Z3_API Z3_global_param_get(__in Z3_string param_id, __out_opt Z3_string_ptr param_value); + + /*@}*/ + /** @name Create configuration */ /*@{*/ /** - \brief Create a configuration. + \brief Create a configuration object for the Z3 context object. Configurations are created in order to assign parameters prior to creating - contexts for Z3 interaction. For example, if the users wishes to use model + contexts for Z3 interaction. For example, if the users wishes to use proof generation, then call: - \ccode{Z3_set_param_value(cfg\, "MODEL"\, "true")} + \ccode{Z3_set_param_value(cfg\, "proof"\, "true")} \mlonly \remark Consider using {!mk_context_x} instead of using explicit configuration objects. The function {!mk_context_x} receives an array of string pairs. This array represents the configuration options. \endmlonly + \remark In previous versions of Z3, the \c Z3_config was used to store + global and module configurations. Now, we should use \c Z3_global_param_set. + + The following parameters can be set: + + - proof (Boolean) Enable proof generation + - debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting + - trace (Boolean) Tracing support for VCC + - trace_file_name (String) Trace out file for VCC traces + \sa Z3_set_param_value \sa Z3_del_config @@ -1271,18 +1328,14 @@ extern "C" { /** \brief Set a configuration parameter. - The list of all configuration parameters can be obtained using the Z3 executable: - - \verbatim - z3.exe -ini? - \endverbatim + The following parameters can be set for \sa Z3_mk_config def_API('Z3_set_param_value', VOID, (_in(CONFIG), _in(STRING), _in(STRING))) */ void Z3_API Z3_set_param_value(__in Z3_config c, __in Z3_string param_id, __in Z3_string param_value); - + /*@}*/ #endif @@ -1367,33 +1420,19 @@ extern "C" { #endif /** - \brief Update a mutable configuration parameter. + \brief This is a deprecated function. This is a NOOP in the current version of Z3. - The list of all configuration parameters can be obtained using the Z3 executable: - - \verbatim - z3.exe -ini? - \endverbatim - - Only a few configuration parameters are mutable once the context is created. - The error handler is invoked when trying to modify an immutable parameter. - - \conly \sa Z3_set_param_value - \mlonly \sa Z3_mk_context \endmlonly + \deprecated Use #Z3_global_param_set. def_API('Z3_update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) */ void Z3_API Z3_update_param_value(__in Z3_context c, __in Z3_string param_id, __in Z3_string param_value); /** - \brief Get a configuration parameter. + \brief This is a deprecated function. This is a NOOP in the current version of Z3. + It always return Z3_FALSE. - Returns \mlonly \c None \endmlonly \conly \c Z3_FALSE - if the parameter value does not exist. - - \conly \sa Z3_mk_config - \conly \sa Z3_set_param_value - \mlonly \sa Z3_mk_context \endmlonly + \deprecated Use #Z3_global_param_get def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) */ diff --git a/src/ast/pattern/expr_pattern_match.cpp b/src/ast/pattern/expr_pattern_match.cpp index 25be8dbf0..a446ae538 100644 --- a/src/ast/pattern/expr_pattern_match.cpp +++ b/src/ast/pattern/expr_pattern_match.cpp @@ -388,8 +388,7 @@ expr_pattern_match::initialize(char const * spec_string) { m_instrs.push_back(instr(BACKTRACK)); std::istringstream is(spec_string); - front_end_params p; - cmd_context ctx(&p, true, &m_manager); + cmd_context ctx(true, &m_manager); VERIFY(parse_smt2_commands(ctx, is)); ptr_vector::const_iterator it = ctx.begin_assertions(); diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 1960cd22a..43507ed3f 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -29,6 +29,7 @@ Notes: #include"eval_cmd.h" #include"front_end_params.h" #include"gparams.h" +#include"model_params.hpp" class help_cmd : public cmd { svector m_cmds; @@ -104,9 +105,10 @@ ATOMIC_CMD(get_model_cmd, "get-model", "retrieve model for the last check-sat co throw cmd_exception("model is not available"); model_ref m; ctx.get_check_sat_result()->get_model(m); - if (ctx.params().m_model_v1_pp || ctx.params().m_model_v2_pp) { + model_params p; + if (p.v1() || p.v2()) { std::ostringstream buffer; - model_v2_pp(buffer, *m, ctx.params().m_model_partial); + model_v2_pp(buffer, *m, p.partial()); ctx.regular_stream() << "\"" << escaped(buffer.str().c_str(), true) << "\"" << std::endl; } else { ctx.regular_stream() << "(model " << std::endl; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 5dcc4268c..cd8c81387 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -316,10 +316,9 @@ public: } }; -cmd_context::cmd_context(front_end_params * params, bool main_ctx, ast_manager * m, symbol const & l): +cmd_context::cmd_context(bool main_ctx, ast_manager * m, symbol const & l): m_main_ctx(main_ctx), - m_params(params == 0 ? alloc(front_end_params) : params), - m_params_owner(params == 0), + m_fparams(alloc(front_end_params)), m_logic(l), m_interactive_mode(false), m_global_decls(false), // :global-decls is false by default. @@ -359,9 +358,7 @@ cmd_context::~cmd_context() { finalize_probes(); m_solver = 0; m_check_sat_result = 0; - if (m_params_owner) { - dealloc(m_params); - } + dealloc(m_fparams); } void cmd_context::set_produce_models(bool f) { @@ -382,10 +379,6 @@ void cmd_context::set_produce_proofs(bool f) { params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; } -bool cmd_context::is_smtlib2_compliant() const { - return params().m_smtlib2_compliant; -} - bool cmd_context::produce_models() const { return params().m_model; } @@ -599,8 +592,9 @@ void cmd_context::init_manager() { m_manager = alloc(ast_manager, params().m_proof_mode, params().m_trace_stream); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); - if (params().m_smtlib2_compliant) - m_manager->enable_int_real_coercions(false); + // PARAM-TODO + // if (params().m_smtlib2_compliant) + // m_manager->enable_int_real_coercions(false); } void cmd_context::init_external_manager() { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 6688f66d9..1b15c0b60 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -138,8 +138,7 @@ public: protected: bool m_main_ctx; - front_end_params * m_params; - bool m_params_owner; + front_end_params * m_fparams; symbol m_logic; bool m_interactive_mode; bool m_global_decls; @@ -251,9 +250,8 @@ protected: void print_unsupported_info(symbol const& s) { if (s != symbol::null) diagnostic_stream() << "; " << s << std::endl;} public: - cmd_context(front_end_params * params = 0, bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); + cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); ~cmd_context(); - bool is_smtlib2_compliant() const; void set_logic(symbol const & s); bool has_logic() const { return m_logic != symbol::null; } symbol const & get_logic() const { return m_logic; } @@ -290,7 +288,7 @@ public: virtual ast_manager & get_ast_manager() { return m(); } pdecl_manager & pm() const { if (!m_pmanager) const_cast(this)->init_manager(); return *m_pmanager; } sexpr_manager & sm() const { if (!m_sexpr_manager) const_cast(this)->m_sexpr_manager = alloc(sexpr_manager); return *m_sexpr_manager; } - front_end_params & params() const { return *m_params; } + front_end_params & params() const { return *m_fparams; } void set_solver(solver * s); solver * get_solver() const { return m_solver.get(); } diff --git a/src/front_end_params/README b/src/front_end_params/README new file mode 100644 index 000000000..1ab0a2463 --- /dev/null +++ b/src/front_end_params/README @@ -0,0 +1,9 @@ +This directory contains the "remains" of the old parameter setting +infrastructure used by Z3. Old code (mostly `smt::context`) is still +based on the front_end_params structure. However, we removed support +for the old INI file infrastructure. Instead, we have functions for +setting the fields of front_end_params using parameter sets +(params_ref). Moreover, many of the parameters in front_end_params +are now "hidden". That is, they can't be set from the command line or +using the command `set-option`. + diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 9d05a3fc3..d30ec825d 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -22,9 +22,7 @@ void front_end_params::register_params(ini_params & p) { p.register_param_vector(m_param_vector.get()); preprocessor_params::register_params(p); smt_params::register_params(p); - parser_params::register_params(p); arith_simplifier_params::register_params(p); - model_params::register_params(p); p.register_bool_param("at_labels_cex", m_at_labels_cex, "only use labels that contain '@' when building multiple counterexamples"); p.register_bool_param("check_at_labels", m_check_at_labels, @@ -33,14 +31,12 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("interactive", m_interactive, "enable interactive mode using Simplify input format"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); - p.register_bool_param("async_commands", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS @@ -51,29 +47,10 @@ void front_end_params::register_params(ini_params & p) { "set hard upper limit for memory consumption (in megabytes)"); #endif -#ifndef _EXTERNAL_RELEASE - // external users should not have access to it. - p.register_bool_param("preprocess", m_preprocess); -#endif - - p.register_bool_param("user_theory_preprocess_axioms", - m_user_theory_preprocess_axioms, - "Apply full pre-processing to user theory axioms", - true); - - p.register_bool_param("user_theory_persist_axioms", - m_user_theory_persist_axioms, - "Persist user axioms to the base level", - true); - - p.register_bool_param("smtlib2_compliant", m_smtlib2_compliant); - - p.register_bool_param("ignore_bad_patterns", m_ignore_bad_patterns); PRIVATE_PARAMS({ p.register_bool_param("ignore_checksat", m_ignore_checksat); p.register_bool_param("debug_ref_count", m_debug_ref_count); - p.register_bool_param("ignore_user_patterns", m_ignore_user_patterns); p.register_bool_param("incremental_core_assert", m_incremental_core_assert); DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index b87265c01..505052450 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -23,22 +23,15 @@ Revision History: #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" -#include"parser_params.h" #include"arith_simplifier_params.h" -#include"model_params.h" -struct front_end_params : public preprocessor_params, public smt_params, public parser_params, - public arith_simplifier_params, public model_params - { +struct front_end_params : public preprocessor_params, public smt_params, + public arith_simplifier_params { ref m_param_vector; - unsigned m_max_num_cex; // maximum number of counterexamples bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. bool m_default_qid; - bool m_interactive; bool m_well_sorted_check; - bool m_ignore_bad_patterns; - bool m_ignore_user_patterns; bool m_incremental_core_assert; // assert conditions to the core incrementally unsigned m_soft_timeout; double m_instr_out; @@ -46,32 +39,26 @@ struct front_end_params : public preprocessor_params, public smt_params, public unsigned m_memory_max_size; proof_gen_mode m_proof_mode; bool m_auto_config; - bool m_smtlib2_compliant; #ifdef Z3DEBUG int m_copy_params; // used for testing copy params... Invoke method copy_params(m_copy_params) in main.cpp when diff -1. #endif - bool m_preprocess; // temporary hack for disabling all preprocessing.. + bool m_ignore_checksat; // abort before checksat... for internal debugging bool m_debug_ref_count; bool m_trace; std::string m_trace_file_name; std::fstream* m_trace_stream; - bool m_async_commands; bool m_display_config; - bool m_user_theory_preprocess_axioms; - bool m_user_theory_persist_axioms; bool m_nlsat; // temporary hack until strategic_solver is ported to new tactic framework + bool m_dump_goal_as_smt; + front_end_params(): m_param_vector(alloc(param_vector, this)), - m_max_num_cex(1), m_at_labels_cex(false), m_check_at_labels(false), m_default_qid(false), - m_interactive(false), m_well_sorted_check(true), - m_ignore_bad_patterns(true), - m_ignore_user_patterns(false), m_incremental_core_assert(true), m_soft_timeout(0), m_instr_out(0.0), @@ -83,25 +70,17 @@ struct front_end_params : public preprocessor_params, public smt_params, public #else m_auto_config(false), #endif -#if 0 - m_smtlib2_compliant(true), -#else - m_smtlib2_compliant(false), -#endif #ifdef Z3DEBUG m_copy_params(-1), #endif - m_preprocess(true), // temporary hack for disabling all preprocessing.. m_ignore_checksat(false), m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), m_trace_stream(NULL), - m_async_commands(true), m_display_config(false), - m_user_theory_preprocess_axioms(false), - m_user_theory_persist_axioms(false), - m_nlsat(false) { + m_nlsat(false), + m_dump_goal_as_smt(false) { } void register_params(ini_params & p); diff --git a/src/front_end_params/model_params.cpp b/src/front_end_params/model_params.cpp deleted file mode 100644 index a859684d8..000000000 --- a/src/front_end_params/model_params.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - model_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-08-23. - -Revision History: - ---*/ - -#include"model_params.h" - -void model_params::register_params(ini_params & p) { - p.register_bool_param("model_partial", m_model_partial, "enable/disable partial function interpretations", true); - p.register_bool_param("model_v1", m_model_v1_pp, - "use Z3 version 1.x pretty printer", true); - p.register_bool_param("model_v2", m_model_v2_pp, - "use Z3 version 2.x (x <= 16) pretty printer", true); - p.register_bool_param("model_compact", m_model_compact, - "try to compact function graph (i.e., function interpretations that are lookup tables", true); - p.register_bool_param("model_completion", m_model_completion, - "assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model", true); - -} - - diff --git a/src/front_end_params/model_params.h b/src/front_end_params/model_params.h deleted file mode 100644 index 2718d4e5f..000000000 --- a/src/front_end_params/model_params.h +++ /dev/null @@ -1,43 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - model_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-08-23. - -Revision History: - ---*/ -#ifndef _MODEL_PARAMS_H_ -#define _MODEL_PARAMS_H_ - -#include"ini_file.h" - -struct model_params { - bool m_model_partial; - bool m_model_compact; - bool m_model_v1_pp; - bool m_model_v2_pp; - bool m_model_completion; - - model_params(): - m_model_partial(false), - m_model_compact(false), - m_model_v1_pp(false), - m_model_v2_pp(false), - m_model_completion(false) { - } - - void register_params(ini_params & p); -}; - -#endif /* _MODEL_PARAMS_H_ */ - diff --git a/src/front_end_params/parser_params.cpp b/src/front_end_params/parser_params.cpp deleted file mode 100644 index 3edd03fb0..000000000 --- a/src/front_end_params/parser_params.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "parser_params.h" - -parser_params::parser_params() : - m_dump_goal_as_smt(false), - m_display_error_for_vs(false) { -} - -void parser_params::register_params(ini_params & p) { - p.register_bool_param("dump_goal_as_smt", m_dump_goal_as_smt, "write goal back to output in SMT format"); - p.register_bool_param("display_error_for_visual_studio", m_display_error_for_vs, "display error messages in Visual Studio format"); -} - - - diff --git a/src/front_end_params/parser_params.h b/src/front_end_params/parser_params.h deleted file mode 100644 index eaab4fd81..000000000 --- a/src/front_end_params/parser_params.h +++ /dev/null @@ -1,33 +0,0 @@ -/*++ -Copyright (c) 2008 Microsoft Corporation - -Module Name: - - parser_params.h - -Abstract: - - - -Author: - - Nikolaj Bjorner (nbjorner) 2008-04-21. - -Revision History: - ---*/ -#ifndef _PARSER_PARAMS_H_ -#define _PARSER_PARAMS_H_ - -#include"ini_file.h" - -struct parser_params { - bool m_dump_goal_as_smt; // re-print goal as SMT benchmark. - bool m_display_error_for_vs; // print error in vs format. - - parser_params(); - void register_params(ini_params & p); -}; - -#endif /* _PARSER_PARAMS_H_ */ - diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 74e279ff8..737b369b4 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -103,5 +103,17 @@ void smt_params::register_params(ini_params & p) { p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); + + + p.register_bool_param("user_theory_preprocess_axioms", + m_user_theory_preprocess_axioms, + "Apply full pre-processing to user theory axioms", + true); + + p.register_bool_param("user_theory_persist_axioms", + m_user_theory_persist_axioms, + "Persist user axioms to the base level", + true); + } diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 5c62c49e3..c6b34a2d3 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -169,6 +169,7 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith // // ----------------------------------- bool m_model; + bool m_model_compact; bool m_model_validate; bool m_model_on_timeout; bool m_model_on_final_check; @@ -187,6 +188,15 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith // ----------------------------------- bool m_display_installed_theories; + // ----------------------------------- + // + // From front_end_params + // + // ----------------------------------- + bool m_preprocess; // temporary hack for disabling all preprocessing.. + bool m_user_theory_preprocess_axioms; + bool m_user_theory_persist_axioms; + smt_params(): m_display_proof(false), m_display_dot_proof(false), @@ -241,11 +251,17 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_ll_bool_var2expr(false), m_abort_after_preproc(false), m_model(true), + m_model_compact(false), m_model_validate(false), m_model_on_timeout(false), m_model_on_final_check(false), m_progress_sampling_freq(0), - m_display_installed_theories(false) { + m_display_installed_theories(false), + m_preprocess(true), // temporary hack for disabling all preprocessing.. + m_user_theory_preprocess_axioms(false), + m_user_theory_persist_axioms(false) + { + } void register_params(ini_params & p); diff --git a/src/parsers/smt/smtlib_solver.cpp b/src/parsers/smt/smtlib_solver.cpp index dd54de350..ddcdb56c8 100644 --- a/src/parsers/smt/smtlib_solver.cpp +++ b/src/parsers/smt/smtlib_solver.cpp @@ -28,6 +28,8 @@ Revision History: #include"solver.h" #include"smt_strategic_solver.h" #include"cmd_context.h" +#include"model_params.hpp" +#include"parser_params.hpp" namespace smtlib { @@ -35,8 +37,9 @@ namespace smtlib { m_ast_manager(params.m_proof_mode, params.m_trace_stream), m_params(params), m_ctx(0), - m_parser(parser::create(m_ast_manager, params.m_ignore_user_patterns)), m_error_code(0) { + parser_params ps; + m_parser = parser::create(m_ast_manager, ps.ignore_user_patterns()); m_parser->initialize_smtlib(); } @@ -82,7 +85,7 @@ namespace smtlib { // Hack: it seems SMT-LIB allow benchmarks without any :formula benchmark.add_formula(m_ast_manager.mk_true()); } - m_ctx = alloc(cmd_context, &m_params, true, &m_ast_manager, benchmark.get_logic()); + m_ctx = alloc(cmd_context, true, &m_ast_manager, benchmark.get_logic()); m_ctx->set_solver(mk_smt_strategic_solver(false)); theory::expr_iterator fit = benchmark.begin_formulas(); theory::expr_iterator fend = benchmark.end_formulas(); @@ -105,7 +108,8 @@ namespace smtlib { model_ref md; if (r->status() != l_false) r->get_model(md); if (md.get() != 0 && m_params.m_model) { - model_v2_pp(std::cout, *(md.get()), m_params.m_model_partial); + model_params p; + model_v2_pp(std::cout, *(md.get()), p.partial()); } } else { diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index f288c526e..c0c8d5bc5 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -28,7 +28,7 @@ Revision History: #include"rewriter.h" #include"has_free_vars.h" #include"ast_smt2_pp.h" -#include"front_end_params.h" +#include"parser_params.hpp" namespace smt2 { typedef cmd_exception parser_exception; @@ -106,9 +106,14 @@ namespace smt2 { ast_manager & m() const { return m_ctx.m(); } pdecl_manager & pm() const { return m_ctx.pm(); } sexpr_manager & sm() const { return m_ctx.sm(); } + + bool m_ignore_user_patterns; + bool m_ignore_bad_patterns; + bool m_display_error_for_vs; - bool ignore_user_patterns() const { return m_ctx.params().m_ignore_user_patterns; } - bool ignore_bad_patterns() const { return m_ctx.params().m_ignore_bad_patterns; } + bool ignore_user_patterns() const { return m_ignore_user_patterns; } + bool ignore_bad_patterns() const { return m_ignore_bad_patterns; } + bool use_vs_format() const { return m_display_error_for_vs; } struct psort_frame { psort_decl * m_decl; @@ -383,8 +388,6 @@ namespace smt2 { void check_int(char const * msg) { if (!curr_is_int()) throw parser_exception(msg); } void check_float(char const * msg) { if (!curr_is_float()) throw parser_exception(msg); } - bool use_vs_format() const { return m_ctx.params().m_display_error_for_vs; } - void error(unsigned line, unsigned pos, char const * msg) { if (use_vs_format()) { m_ctx.diagnostic_stream() << "Z3(" << line << ", " << pos << "): ERROR: " << msg; @@ -2354,9 +2357,9 @@ namespace smt2 { } public: - parser(cmd_context & ctx, std::istream & is, bool interactive): + parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & _p): m_ctx(ctx), - m_scanner(ctx, is, interactive), + m_scanner(ctx, is, interactive, _p), m_curr(scanner::NULL_TOKEN), m_curr_cmd(0), m_num_bindings(0), @@ -2393,6 +2396,11 @@ namespace smt2 { m_num_open_paren(0) { // the following assertion does not hold if ctx was already attached to an AST manager before the parser object is created. // SASSERT(!m_ctx.has_manager()); + + parser_params p(_p); + m_ignore_user_patterns = p.ignore_user_patterns(); + m_ignore_bad_patterns = p.ignore_bad_patterns(); + m_display_error_for_vs = p.error_for_visual_studio(); } ~parser() { @@ -2487,8 +2495,8 @@ namespace smt2 { }; }; -bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive) { - smt2::parser p(ctx, is, interactive); +bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & ps) { + smt2::parser p(ctx, is, interactive, ps); return p(); } diff --git a/src/parsers/smt2/smt2parser.h b/src/parsers/smt2/smt2parser.h index a7264ff63..d230e5ae0 100644 --- a/src/parsers/smt2/smt2parser.h +++ b/src/parsers/smt2/smt2parser.h @@ -21,6 +21,6 @@ Revision History: #include"cmd_context.h" -bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false); +bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false, params_ref const & p = params_ref()); #endif diff --git a/src/parsers/smt2/smt2scanner.cpp b/src/parsers/smt2/smt2scanner.cpp index b350796fc..e2b2030ac 100644 --- a/src/parsers/smt2/smt2scanner.cpp +++ b/src/parsers/smt2/smt2scanner.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"smt2scanner.h" +#include"parser_params.hpp" namespace smt2 { @@ -241,7 +242,7 @@ namespace smt2 { } } - scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive): + scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive, params_ref const & _p): m_ctx(ctx), m_interactive(interactive), m_spos(0), @@ -253,6 +254,10 @@ namespace smt2 { m_bend(0), m_stream(stream), m_cache_input(false) { + + parser_params p(_p); + m_smtlib2_compliant = p.smt2_compliant(); + for (int i = 0; i < 256; ++i) { m_normalized[i] = (char) i; } @@ -325,7 +330,7 @@ namespace smt2 { case '#': return read_bv_literal(); case '-': - if (m_ctx.is_smtlib2_compliant()) + if (m_smtlib2_compliant) return read_symbol(); else return read_signed_number(); diff --git a/src/parsers/smt2/smt2scanner.h b/src/parsers/smt2/smt2scanner.h index 015f05fa1..c63a09ff1 100644 --- a/src/parsers/smt2/smt2scanner.h +++ b/src/parsers/smt2/smt2scanner.h @@ -55,6 +55,8 @@ namespace smt2 { svector m_cache; svector m_cache_result; + bool m_smtlib2_compliant; + char curr() const { return m_curr; } void new_line() { m_line++; m_spos = 0; } void next(); @@ -74,7 +76,7 @@ namespace smt2 { EOF_TOKEN }; - scanner(cmd_context & ctx, std::istream& stream, bool interactive = false); + scanner(cmd_context & ctx, std::istream& stream, bool interactive = false, params_ref const & p = params_ref()); ~scanner() {} diff --git a/src/parsers/util/parser_params.pyg b/src/parsers/util/parser_params.pyg new file mode 100644 index 000000000..fa8f17a00 --- /dev/null +++ b/src/parsers/util/parser_params.pyg @@ -0,0 +1,6 @@ +def_module_params('parser', + export=True, + params=(('ignore_user_patterns', BOOL, False, 'ignore patterns provided by the user'), + ('ignore_bad_patterns', BOOL, True, 'ignore malformed patterns'), + ('error_for_visual_studio', BOOL, False, 'display error messages in Visual Studio format'), + ('smt2_compliant', BOOL, False, 'enable/disable SMT-LIB 2.0 compliance'))) diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 56882a02b..bc3953c1e 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -77,7 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "params display all available parameters.\n"; + std::cout << " " << OPT << "ps display all available parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -184,10 +184,7 @@ void parse_cmd_line_args(int argc, char ** argv) { if (i < argc - 1) g_aux_input_file += " "; } - if (g_front_end_params->m_interactive) { - warning_msg("ignoring input file in interactive mode."); - } - else if (g_input_file) { + if (g_input_file) { warning_msg("input file was already specified."); } else { @@ -284,7 +281,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); } - else if (strcmp(opt_name, "params") == 0) { + else if (strcmp(opt_name, "ps") == 0) { gparams::display(std::cout); exit(0); } @@ -324,10 +321,7 @@ void parse_cmd_line_args(int argc, char ** argv) { gparams::set(key, value); } else { - if (g_front_end_params->m_interactive) { - warning_msg("ignoring input file in interactive mode."); - } - else if (g_input_file) { + if (g_input_file) { warning_msg("input file was already specified."); } else { @@ -389,7 +383,7 @@ int main(int argc, char ** argv) { if (g_input_file && g_standard_input) { error("using standard input to read formula."); } - if (!g_input_file && !g_front_end_params->m_interactive && !g_standard_input) { + if (!g_input_file && !g_standard_input) { error("input file was not specified."); } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 08b070183..c9dcc3fa2 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -97,7 +97,7 @@ unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_en g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); - cmd_context ctx(&front_end_params); + cmd_context ctx; // temporary hack until strategic_solver is ported to new tactic framework if (front_end_params.m_nlsat) { diff --git a/src/smt/proto_model/proto_model.cpp b/src/smt/proto_model/proto_model.cpp index 4cedea228..34742e3a0 100644 --- a/src/smt/proto_model/proto_model.cpp +++ b/src/smt/proto_model/proto_model.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"proto_model.h" +#include"model_params.hpp" #include"ast_pp.h" #include"ast_ll_pp.h" #include"var_subst.h" @@ -26,15 +27,16 @@ Revision History: #include"model_v2_pp.h" #include"basic_simplifier_plugin.h" -proto_model::proto_model(ast_manager & m, simplifier & s, model_params const & p): +proto_model::proto_model(ast_manager & m, simplifier & s, params_ref const & p): model_core(m), - m_params(p), m_asts(m), m_simplifier(s), m_afid(m.get_family_id(symbol("array"))) { register_factory(alloc(basic_factory, m)); m_user_sort_factory = alloc(user_sort_factory, m); register_factory(m_user_sort_factory); + + m_model_partial = model_params(p).partial(); } void proto_model::reset_finterp() { @@ -620,7 +622,7 @@ void proto_model::complete_partial_func(func_decl * f) { \brief Set the (else) field of function interpretations... */ void proto_model::complete_partial_funcs() { - if (m_params.m_model_partial) + if (m_model_partial) return; // m_func_decls may be "expanded" when we invoke get_some_value. diff --git a/src/smt/proto_model/proto_model.h b/src/smt/proto_model/proto_model.h index bd5609f33..d16586698 100644 --- a/src/smt/proto_model/proto_model.h +++ b/src/smt/proto_model/proto_model.h @@ -29,16 +29,15 @@ Revision History: #define _PROTO_MODEL_H_ #include"model_core.h" -#include"model_params.h" #include"value_factory.h" #include"plugin_manager.h" #include"simplifier.h" #include"arith_decl_plugin.h" #include"func_decl_dependencies.h" #include"model.h" +#include"params.h" class proto_model : public model_core { - model_params const & m_params; ast_ref_vector m_asts; plugin_manager m_factories; user_sort_factory * m_user_sort_factory; @@ -47,6 +46,8 @@ class proto_model : public model_core { func_decl_set m_aux_decls; ptr_vector m_tmp; + bool m_model_partial; + void reset_finterp(); expr * mk_some_interp_for(func_decl * d); @@ -60,11 +61,9 @@ class proto_model : public model_core { public: - proto_model(ast_manager & m, simplifier & s, model_params const & p); + proto_model(ast_manager & m, simplifier & s, params_ref const & p = params_ref()); virtual ~proto_model(); - model_params const & get_model_params() const { return m_params; } - void register_factory(value_factory * f) { m_factories.register_plugin(f); } bool eval(expr * e, expr_ref & result, bool model_completion = false); diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index 1c441ad11..d14abc31a 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -48,7 +48,8 @@ namespace smt { void model_generator::init_model() { SASSERT(!m_model); - m_model = alloc(proto_model, m_manager, m_context->get_simplifier(), m_context->get_fparams()); + // PARAM-TODO + m_model = alloc(proto_model, m_manager, m_context->get_simplifier()); // , m_context->get_fparams()); ptr_vector::const_iterator it = m_context->begin_theories(); ptr_vector::const_iterator end = m_context->end_theories(); for (; it != end; ++it) { diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 27fdd828b..426789bb4 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -26,7 +26,6 @@ struct gparams::imp { param_descrs m_param_descrs; dictionary m_module_params; params_ref m_params; - params_ref m_empty; public: imp() { } @@ -49,28 +48,37 @@ public: } void register_global(param_descrs & d) { - m_param_descrs.copy(d); + #pragma omp critical (gparams) + { + m_param_descrs.copy(d); + } } void register_module(char const * module_name, param_descrs * d) { - symbol s(module_name); - param_descrs * old_d; - if (m_module_param_descrs.find(s, old_d)) { - old_d->copy(*d); - dealloc(d); - } - else { - m_module_param_descrs.insert(s, d); + #pragma omp critical (gparams) + { + symbol s(module_name); + param_descrs * old_d; + if (m_module_param_descrs.find(s, old_d)) { + old_d->copy(*d); + dealloc(d); + } + else { + m_module_param_descrs.insert(s, d); + } } } void display(std::ostream & out, unsigned indent, bool smt2_style) { - m_param_descrs.display(out, indent, smt2_style); - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); - for (; it != end; ++it) { - out << "[module] " << it->m_key << "\n"; - it->m_value->display(out, indent + 4, smt2_style); + #pragma omp critical (gparams) + { + m_param_descrs.display(out, indent, smt2_style); + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key << "\n"; + it->m_value->display(out, indent + 4, smt2_style); + } } } @@ -102,15 +110,13 @@ public: return m_params; } else { - params_ref * p; - if (m_module_params.find(mod_name, p)) { - return *p; - } - else { + params_ref * p = 0; + if (!m_module_params.find(mod_name, p)) { p = alloc(params_ref); m_module_params.insert(mod_name, p); - return *p; } + SASSERT(p != 0); + return *p; } } @@ -119,9 +125,9 @@ public: params_ref & ps = get_params(mod_name); if (k == CPK_INVALID) { if (mod_name == symbol::null) - throw default_exception("unknown parameter '%s'", param_name.bare_str()); + throw exception("unknown parameter '%s'", param_name.bare_str()); else - throw default_exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); } else if (k == CPK_UINT) { long val = strtol(value, 0, 10); @@ -136,9 +142,9 @@ public: } else { if (mod_name == symbol::null) - throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); + throw exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); else - throw default_exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); + throw exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); } } else if (k == CPK_SYMBOL) { @@ -149,47 +155,125 @@ public: } else { if (mod_name == symbol::null) - throw default_exception("unsupported parameter type '%s'", param_name.bare_str()); + throw exception("unsupported parameter type '%s'", param_name.bare_str()); else - throw default_exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); } } void set(char const * name, char const * value) { - symbol m, p; - normalize(name, m, p); - if (m == symbol::null) { - set(m_param_descrs, p, value, m); - } - else { - param_descrs * d; - if (m_module_param_descrs.find(m, d)) { - set(*d, p, value, m); + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + set(m_param_descrs, p, value, m); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + set(*d, p, value, m); + } + else { + throw exception("invalid parameter, unknown module '%s'", m.bare_str()); + } + } } - else { - throw default_exception("invalid parameter, unknown module '%s'", m.bare_str()); + catch (exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); } } + if (error) + throw exception(error_msg); + } + + std::string get_value(params_ref const & ps, symbol const & p) { + std::ostringstream buffer; + ps.display(buffer, p); + return buffer.str(); + } + + std::string get_default(param_descrs const & d, symbol const & p, symbol const & m) { + if (!d.contains(p)) { + if (m == symbol::null) + throw exception("unknown parameter '%s'", p.bare_str()); + else + throw exception("unknown parameter '%s' at module '%s'", p.bare_str(), m.bare_str()); + } + char const * r = d.get_default(p); + if (r == 0) + return "default"; + return r; } std::string get_value(char const * name) { - // TODO - return ""; + std::string r; + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + if (m_params.contains(p)) { + r = get_value(m_params, p); + } + else { + r = get_default(m_param_descrs, p, m); + } + } + else { + params_ref * ps = 0; + if (m_module_params.find(m, ps) && ps->contains(p)) { + r = get_value(*ps, p); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + r = get_default(*d, p, m); + } + else { + throw exception("unknown module '%s'", m.bare_str()); + } + } + } + } + catch (exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); + } + } + if (error) + throw exception(error_msg); + return r; } - - params_ref const & get_module(symbol const & module_name) { + params_ref get_module(symbol const & module_name) { + params_ref result; params_ref * ps = 0; - if (m_module_params.find(module_name, ps)) { - return *ps; - } - else { - return m_empty; + #pragma omp critical (gparams) + { + if (m_module_params.find(module_name, ps)) { + result = *ps; + } } + return result; } - params_ref const & get() { - return m_params; + params_ref get() { + params_ref result; + #pragma omp critical (gparams) + { + result = m_params; + } + return result; } }; @@ -226,16 +310,16 @@ void gparams::register_module(char const * module_name, param_descrs * d) { g_imp->register_module(module_name, d); } -params_ref const & gparams::get_module(char const * module_name) { +params_ref gparams::get_module(char const * module_name) { return get_module(symbol(module_name)); } -params_ref const & gparams::get_module(symbol const & module_name) { +params_ref gparams::get_module(symbol const & module_name) { SASSERT(g_imp != 0); return g_imp->get_module(module_name); } -params_ref const & gparams::get() { +params_ref gparams::get() { SASSERT(g_imp != 0); return g_imp->get(); } diff --git a/src/util/gparams.h b/src/util/gparams.h index 7112e67f9..04e1f6051 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -31,7 +31,7 @@ public: \brief Set a global parameter \c name with \c value. The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. - The character '.' is used a delimiter (more later). + The character '.' is a delimiter (more later). The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. Thus, the following parameter names are considered equivalent: "auto-config" and "AUTO_CONFIG". @@ -90,13 +90,13 @@ public: // In this example "p" will contain "decimal" -> true after executing this function. params_ref const & p = get_module_params("pp") */ - static params_ref const & get_module(char const * module_name); - static params_ref const & get_module(symbol const & module_name); + static params_ref get_module(char const * module_name); + static params_ref get_module(symbol const & module_name); /** \brief Return the global parameter set (i.e., parameters that are not associated with any particular module). */ - static params_ref const & get(); + static params_ref get(); /** \brief Dump information about available parameters in the given output stream. diff --git a/src/util/memory_manager.cpp b/src/util/memory_manager.cpp index b6eb648d9..be08fe50f 100644 --- a/src/util/memory_manager.cpp +++ b/src/util/memory_manager.cpp @@ -1,9 +1,9 @@ #include #include +#include #include"trace.h" #include"memory_manager.h" #include"error_codes.h" - // The following two function are automatically generated by the mk_make.py script. // The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files. // For example, rational.h contains @@ -27,6 +27,7 @@ out_of_memory_error::out_of_memory_error():z3_error(ERR_MEMOUT) { } volatile bool g_memory_out_of_memory = false; +bool g_memory_initialized = false; long long g_memory_alloc_size = 0; long long g_memory_max_size = 0; long long g_memory_max_used_size = 0; @@ -70,8 +71,20 @@ mem_usage_report g_info; #endif void memory::initialize(size_t max_size) { + bool initialize = false; + #pragma omp critical (z3_memory_manager) + { + // only update the maximum size if max_size != UINT_MAX + if (max_size != UINT_MAX) + g_memory_max_size = max_size; + if (!g_memory_initialized) { + g_memory_initialized = true; + initialize = true; + } + } + if (!initialize) + return; g_memory_out_of_memory = false; - g_memory_max_size = max_size; mem_initialize(); } @@ -108,8 +121,12 @@ void memory::set_max_size(size_t max_size) { static bool g_finalizing = false; void memory::finalize() { - g_finalizing = true; - mem_finalize(); + if (g_memory_initialized) { + g_finalizing = true; + mem_finalize(); + g_memory_initialized = false; + g_finalizing = false; + } } unsigned long long memory::get_allocation_size() { diff --git a/src/util/params.cpp b/src/util/params.cpp index 264149e4b..4f2a73e99 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -57,6 +57,10 @@ struct param_descrs::imp { void erase(symbol const & name) { m_info.erase(name); } + + bool contains(symbol const & name) const { + return m_info.contains(name); + } param_kind get_kind(symbol const & name) const { info i; @@ -157,6 +161,14 @@ void param_descrs::insert(char const * name, param_kind k, char const * descr, c insert(symbol(name), k, descr, def); } +bool param_descrs::contains(char const * name) const { + return contains(symbol(name)); +} + +bool param_descrs::contains(symbol const & name) const { + return m_imp->contains(name); +} + char const * param_descrs::get_descr(char const * name) const { return get_descr(symbol(name)); } @@ -345,7 +357,7 @@ public: continue; switch (it->second.m_kind) { case CPK_BOOL: - out << it->second.m_bool_value; + out << (it->second.m_bool_value?"true":"false"); return; case CPK_UINT: out << it->second.m_uint_value; diff --git a/src/util/params.h b/src/util/params.h index 747b23e39..68f4c967b 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -109,6 +109,8 @@ public: void copy(param_descrs & other); void insert(char const * name, param_kind k, char const * descr, char const * def = 0); void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0); + bool contains(char const * name) const; + bool contains(symbol const & name) const; void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; From 823dd6ca47e8ed64aa9d828ab55845718bb5e86c Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 15:54:53 -0800 Subject: [PATCH 068/133] missing file Signed-off-by: Leonardo de Moura --- src/model/model_params.pyg | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/model/model_params.pyg diff --git a/src/model/model_params.pyg b/src/model/model_params.pyg new file mode 100644 index 000000000..689519e6c --- /dev/null +++ b/src/model/model_params.pyg @@ -0,0 +1,9 @@ +def_module_params('model', + export=True, + params=(('validate', BOOL, False, 'validate models produced by Z3'), + ('partial', BOOL, False, 'enable/disable partial function interpretations'), + ('v1', BOOL, False, 'use Z3 version 1.x pretty printer'), + ('v2', BOOL, False, 'use Z3 version 2.x (x <= 16) pretty printer'), + ('compact', BOOL, False, 'try to compact function graph (i.e., function interpretations that are lookup tables)'), + ('completion', BOOL, False, 'assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model'))) + From 9374a4e20ae1bcabcaacbd1408a2ab728886f462 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 16:30:39 -0800 Subject: [PATCH 069/133] removed ini_file Signed-off-by: Leonardo de Moura --- src/cmd_context/cmd_context.cpp | 5 - .../arith_simplifier_params.cpp | 3 +- .../arith_simplifier_params.h | 4 - src/front_end_params/bit_blaster_params.h | 4 +- src/front_end_params/bv_simplifier_params.h | 4 +- src/front_end_params/dyn_ack_params.cpp | 3 +- src/front_end_params/dyn_ack_params.h | 3 - src/front_end_params/front_end_params.cpp | 10 +- src/front_end_params/front_end_params.h | 25 - .../pattern_inference_params.cpp | 3 +- .../pattern_inference_params.h | 4 - src/front_end_params/preprocessor_params.h | 3 + src/front_end_params/qi_params.h | 7 +- src/front_end_params/smt_params.cpp | 2 + src/front_end_params/smt_params.h | 7 +- src/front_end_params/theory_arith_params.cpp | 2 + src/front_end_params/theory_arith_params.h | 4 +- src/front_end_params/theory_array_params.h | 5 +- src/front_end_params/theory_bv_params.h | 4 +- src/front_end_params/theory_datatype_params.h | 4 +- src/muz_qe/dl_cmds.cpp | 6 +- src/muz_qe/dl_context.cpp | 16 +- src/muz_qe/pdr_dl_interface.cpp | 22 +- src/shell/datalog_frontend.cpp | 8 +- src/shell/datalog_frontend.h | 2 +- src/shell/main.cpp | 55 +- src/shell/smtlib_frontend.cpp | 1 - src/smt/smt_context.cpp | 6 - src/smt/smt_context.h | 2 - src/smt/smt_setup.cpp | 1 - src/test/ini_file.cpp | 50 - src/test/main.cpp | 1 - src/util/ini_file.cpp | 1564 ----------------- src/util/ini_file.h | 117 -- src/util/instruction_count.cpp | 41 - src/util/instruction_count.h | 43 - src/util/util.cpp | 6 +- src/util/warning.cpp | 6 +- 38 files changed, 82 insertions(+), 1971 deletions(-) delete mode 100644 src/test/ini_file.cpp delete mode 100644 src/util/ini_file.cpp delete mode 100644 src/util/ini_file.h delete mode 100644 src/util/instruction_count.cpp delete mode 100644 src/util/instruction_count.h diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index cd8c81387..984e5db0c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1295,11 +1295,6 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions return; IF_VERBOSE(100, verbose_stream() << "check-sat..." << std::endl;); TRACE("before_check_sat", dump_assertions(tout);); - if (params().m_ignore_checksat) { - m_check_sat_result = 0; - regular_stream() << "unknown" << std::endl; - return; - } if (!has_manager()) init_manager(); if (m_solver) { diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp index 21808bc1e..8cf07b915 100644 --- a/src/front_end_params/arith_simplifier_params.cpp +++ b/src/front_end_params/arith_simplifier_params.cpp @@ -19,8 +19,9 @@ Revision History: #include"arith_simplifier_params.h" +#if 0 void arith_simplifier_params::register_params(ini_params & p) { p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); } - +#endif diff --git a/src/front_end_params/arith_simplifier_params.h b/src/front_end_params/arith_simplifier_params.h index 3e44b5a6e..f1b22b09a 100644 --- a/src/front_end_params/arith_simplifier_params.h +++ b/src/front_end_params/arith_simplifier_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -#include"ini_file.h" - struct arith_simplifier_params { bool m_arith_expand_eqs; bool m_arith_process_all_eqs; @@ -29,8 +27,6 @@ struct arith_simplifier_params { m_arith_expand_eqs(false), m_arith_process_all_eqs(false) { } - - void register_params(ini_params & p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/bit_blaster_params.h b/src/front_end_params/bit_blaster_params.h index ab183d7fc..653c8fc74 100644 --- a/src/front_end_params/bit_blaster_params.h +++ b/src/front_end_params/bit_blaster_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _BIT_BLASTER_PARAMS_H_ #define _BIT_BLASTER_PARAMS_H_ -#include"ini_file.h" - struct bit_blaster_params { bool m_bb_ext_gates; bool m_bb_quantifiers; @@ -28,10 +26,12 @@ struct bit_blaster_params { m_bb_ext_gates(false), m_bb_quantifiers(false) { } +#if 0 void register_params(ini_params & p) { p.register_bool_param("bb_ext_gates", m_bb_ext_gates, "use extended gates during bit-blasting"); p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); } +#endif }; #endif /* _BIT_BLASTER_PARAMS_H_ */ diff --git a/src/front_end_params/bv_simplifier_params.h b/src/front_end_params/bv_simplifier_params.h index 50dedfd22..887940e36 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/front_end_params/bv_simplifier_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ -#include"ini_file.h" - struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. bool m_bv2int_distribute; //!< if true allows downward propagation of bv2int. @@ -29,10 +27,12 @@ struct bv_simplifier_params { m_hi_div0(true), m_bv2int_distribute(true) { } +#if 0 void register_params(ini_params & p) { p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); } +#endif }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/front_end_params/dyn_ack_params.cpp index 90a0bb17b..2e94c376d 100644 --- a/src/front_end_params/dyn_ack_params.cpp +++ b/src/front_end_params/dyn_ack_params.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include"dyn_ack_params.h" +#if 0 void dyn_ack_params::register_params(ini_params & p) { p.register_int_param("dack", 0, 2, reinterpret_cast(m_dack), "0 - disable dynamic ackermannization, 1 - expand Leibniz's axiom if a congruence is the root of a conflict, 2 - expand Leibniz's axiom if a congruence is used during conflict resolution."); @@ -27,5 +28,5 @@ void dyn_ack_params::register_params(ini_params & p) { p.register_unsigned_param("dack_gc", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); p.register_double_param("dack_gc_inv_decay", m_dack_gc_inv_decay); } - +#endif diff --git a/src/front_end_params/dyn_ack_params.h b/src/front_end_params/dyn_ack_params.h index c5325195e..9f7ce578c 100644 --- a/src/front_end_params/dyn_ack_params.h +++ b/src/front_end_params/dyn_ack_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _DYN_ACK_PARAMS_H_ #define _DYN_ACK_PARAMS_H_ -#include"ini_file.h" - enum dyn_ack_strategy { DACK_DISABLED, DACK_ROOT, // congruence is the root of the conflict @@ -45,7 +43,6 @@ public: m_dack_gc_inv_decay(0.8) { } - void register_params(ini_params & p); }; diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index d30ec825d..49c3f042e 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -18,8 +18,9 @@ Revision History: --*/ #include"front_end_params.h" +#if 0 + void front_end_params::register_params(ini_params & p) { - p.register_param_vector(m_param_vector.get()); preprocessor_params::register_params(p); smt_params::register_params(p); arith_simplifier_params::register_params(p); @@ -27,8 +28,6 @@ void front_end_params::register_params(ini_params & p) { "only use labels that contain '@' when building multiple counterexamples"); p.register_bool_param("check_at_labels", m_check_at_labels, "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("default_qid", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); - p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); @@ -49,10 +48,7 @@ void front_end_params::register_params(ini_params & p) { PRIVATE_PARAMS({ - p.register_bool_param("ignore_checksat", m_ignore_checksat); p.register_bool_param("debug_ref_count", m_debug_ref_count); - p.register_bool_param("incremental_core_assert", m_incremental_core_assert); - DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); // temporary hack until strategic_solver is ported to new tactic framework @@ -61,6 +57,8 @@ void front_end_params::register_params(ini_params & p) { }); } +#endif + void front_end_params::open_trace_file() { if (m_trace) { m_trace_stream = alloc(std::fstream, m_trace_file_name.c_str(), std::ios_base::out); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 505052450..d033ba911 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -19,7 +19,6 @@ Revision History: #ifndef _FRONT_END_PARAMS_H_ #define _FRONT_END_PARAMS_H_ -#include"ini_file.h" #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" @@ -27,23 +26,14 @@ Revision History: struct front_end_params : public preprocessor_params, public smt_params, public arith_simplifier_params { - ref m_param_vector; bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. - bool m_default_qid; bool m_well_sorted_check; - bool m_incremental_core_assert; // assert conditions to the core incrementally - unsigned m_soft_timeout; - double m_instr_out; unsigned m_memory_high_watermark; unsigned m_memory_max_size; proof_gen_mode m_proof_mode; bool m_auto_config; -#ifdef Z3DEBUG - int m_copy_params; // used for testing copy params... Invoke method copy_params(m_copy_params) in main.cpp when diff -1. -#endif - bool m_ignore_checksat; // abort before checksat... for internal debugging bool m_debug_ref_count; bool m_trace; std::string m_trace_file_name; @@ -54,14 +44,9 @@ struct front_end_params : public preprocessor_params, public smt_params, bool m_dump_goal_as_smt; front_end_params(): - m_param_vector(alloc(param_vector, this)), m_at_labels_cex(false), m_check_at_labels(false), - m_default_qid(false), m_well_sorted_check(true), - m_incremental_core_assert(true), - m_soft_timeout(0), - m_instr_out(0.0), m_memory_high_watermark(0), m_memory_max_size(0), m_proof_mode(PGM_DISABLED), @@ -70,10 +55,6 @@ struct front_end_params : public preprocessor_params, public smt_params, #else m_auto_config(false), #endif -#ifdef Z3DEBUG - m_copy_params(-1), -#endif - m_ignore_checksat(false), m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), @@ -83,16 +64,10 @@ struct front_end_params : public preprocessor_params, public smt_params, m_dump_goal_as_smt(false) { } - void register_params(ini_params & p); - void open_trace_file(); void close_trace_file(); - void copy_params(unsigned idx) { - m_param_vector->copy_params(this, idx); - } - bool has_auto_config(unsigned idx) { return m_auto_config; } private: diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp index 4b0d4c964..cfc0df4f1 100644 --- a/src/front_end_params/pattern_inference_params.cpp +++ b/src/front_end_params/pattern_inference_params.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include"pattern_inference_params.h" +#if 0 void pattern_inference_params::register_params(ini_params & p) { p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); @@ -33,5 +34,5 @@ void pattern_inference_params::register_params(ini_params & p) { p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); } - +#endif diff --git a/src/front_end_params/pattern_inference_params.h b/src/front_end_params/pattern_inference_params.h index 79d7b4d87..7108e5589 100644 --- a/src/front_end_params/pattern_inference_params.h +++ b/src/front_end_params/pattern_inference_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ -#include"ini_file.h" - enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms AP_CONSERVATIVE, // only infer patterns with arithmetic terms if there is no other option @@ -51,8 +49,6 @@ struct pattern_inference_params { m_pi_avoid_skolems(true), m_pi_warnings(false) { } - - void register_params(ini_params & p); }; #endif /* _PATTERN_INFERENCE_PARAMS_H_ */ diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 00466bc02..b84aebe1a 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -76,6 +76,7 @@ public: m_nlquant_elim(false) { } +#if 0 void register_params(ini_params & p) { pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); @@ -100,6 +101,8 @@ public: p.register_bool_param("bv_max_sharing", m_max_bv_sharing); p.register_bool_param("pre_simplifier", m_pre_simplifier); } +#endif + }; #endif /* _PREPROCESSOR_PARAMS_H_ */ diff --git a/src/front_end_params/qi_params.h b/src/front_end_params/qi_params.h index aee2c4d3d..1a8edb3a8 100644 --- a/src/front_end_params/qi_params.h +++ b/src/front_end_params/qi_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _QI_PARAMS_H_ #define _QI_PARAMS_H_ -#include"ini_file.h" +#include"util.h" enum quick_checker_mode { MC_NO, // do not use (cheap) model checking based instantiation @@ -105,7 +105,8 @@ struct qi_params { m_mbqi_force_template(10), m_instgen(false) { } - + +#if 0 void register_params(ini_params & p) { p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); @@ -133,6 +134,8 @@ struct qi_params { p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); } +#endif + }; #endif /* _QI_PARAMS_H_ */ diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 737b369b4..77d3660e6 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -19,6 +19,7 @@ Revision History: #include"smt_params.h" #include"trace.h" +#if 0 void smt_params::register_params(ini_params & p) { dyn_ack_params::register_params(p); qi_params::register_params(p); @@ -117,3 +118,4 @@ void smt_params::register_params(ini_params & p) { } +#endif diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index c6b34a2d3..804049315 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -19,7 +19,6 @@ Revision History: #ifndef _SMT_PARAMS_H_ #define _SMT_PARAMS_H_ -#include"ini_file.h" #include"dyn_ack_params.h" #include"qi_params.h" #include"theory_arith_params.h" @@ -196,6 +195,7 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_preprocess; // temporary hack for disabling all preprocessing.. bool m_user_theory_preprocess_axioms; bool m_user_theory_persist_axioms; + unsigned m_soft_timeout; smt_params(): m_display_proof(false), @@ -259,12 +259,11 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_installed_theories(false), m_preprocess(true), // temporary hack for disabling all preprocessing.. m_user_theory_preprocess_axioms(false), - m_user_theory_persist_axioms(false) + m_user_theory_persist_axioms(false), + m_soft_timeout(0) { } - - void register_params(ini_params & p); }; #endif /* _SMT_PARAMS_H_ */ diff --git a/src/front_end_params/theory_arith_params.cpp b/src/front_end_params/theory_arith_params.cpp index 49a654dbf..8dde26e94 100644 --- a/src/front_end_params/theory_arith_params.cpp +++ b/src/front_end_params/theory_arith_params.cpp @@ -19,6 +19,7 @@ Revision History: #include"theory_arith_params.h" +#if 0 void theory_arith_params::register_params(ini_params & p) { #ifdef _EXTERNAL_RELEASE p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); @@ -74,3 +75,4 @@ void theory_arith_params::register_params(ini_params & p) { p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); } +#endif diff --git a/src/front_end_params/theory_arith_params.h b/src/front_end_params/theory_arith_params.h index 290049037..01163dd0a 100644 --- a/src/front_end_params/theory_arith_params.h +++ b/src/front_end_params/theory_arith_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _THEORY_ARITH_PARAMS_H_ #define _THEORY_ARITH_PARAMS_H_ -#include"ini_file.h" +#include enum arith_solver_id { AS_NO_ARITH, @@ -150,8 +150,6 @@ struct theory_arith_params { m_nl_arith_rounds(1024), m_arith_euclidean_solver(false) { } - - void register_params(ini_params & p); }; #endif /* _THEORY_ARITH_PARAMS_H_ */ diff --git a/src/front_end_params/theory_array_params.h b/src/front_end_params/theory_array_params.h index 3d45ebcf5..e33bc2566 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/front_end_params/theory_array_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_ARRAY_PARAMS_H_ #define _THEORY_ARRAY_PARAMS_H_ -#include"ini_file.h" - enum array_solver_id { AR_NO_ARRAY, AR_SIMPLE, @@ -55,6 +53,7 @@ struct theory_array_params { m_array_simplify(true) { } +#if 0 void register_params(ini_params & p) { p.register_int_param("array_solver", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); p.register_bool_param("array_weak", m_array_weak); @@ -69,6 +68,8 @@ struct theory_array_params { p.register_bool_param("array_canonize", m_array_canonize_simplify, "Normalize arrays into normal form during simplification"); } +#endif + }; diff --git a/src/front_end_params/theory_bv_params.h b/src/front_end_params/theory_bv_params.h index 6bf5ac868..18a3bac77 100644 --- a/src/front_end_params/theory_bv_params.h +++ b/src/front_end_params/theory_bv_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_BV_PARAMS_H_ #define _THEORY_BV_PARAMS_H_ -#include"ini_file.h" - enum bv_solver_id { BS_NO_BV, BS_BLASTER @@ -40,6 +38,7 @@ struct theory_bv_params { m_bv_cc(false), m_bv_blast_max_size(INT_MAX), m_bv_enable_int2bv2int(false) {} +#if 0 void register_params(ini_params & p) { p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); @@ -49,6 +48,7 @@ struct theory_bv_params { p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, "enable full (potentially expensive) propagation for int2bv and bv2int"); } +#endif }; #endif /* _THEORY_BV_PARAMS_H_ */ diff --git a/src/front_end_params/theory_datatype_params.h b/src/front_end_params/theory_datatype_params.h index 33b2c1814..8f914ac7b 100644 --- a/src/front_end_params/theory_datatype_params.h +++ b/src/front_end_params/theory_datatype_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_DATATYPE_PARAMS_H_ #define _THEORY_DATATYPE_PARAMS_H_ -#include"ini_file.h" - struct theory_datatype_params { unsigned m_dt_lazy_splits; @@ -28,9 +26,11 @@ struct theory_datatype_params { m_dt_lazy_splits(1) { } +#if 0 void register_params(ini_params & p) { p.register_unsigned_param("dt_lazy_splits", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); } +#endif }; diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index 28e699c7c..d89b8d80d 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -472,8 +472,10 @@ static void install_dl_cmds_aux(cmd_context& ctx, dl_collected_cmds* collected_c ctx.insert(alloc(dl_query_cmd, dl_ctx)); ctx.insert(alloc(dl_declare_rel_cmd, dl_ctx)); ctx.insert(alloc(dl_declare_var_cmd, dl_ctx)); - PRIVATE_PARAMS(ctx.insert(alloc(dl_push_cmd, dl_ctx));); // not exposed to keep command-extensions simple. - PRIVATE_PARAMS(ctx.insert(alloc(dl_pop_cmd, dl_ctx));); +#ifndef _EXTERNAL_RELEASE + ctx.insert(alloc(dl_push_cmd, dl_ctx)); // not exposed to keep command-extensions simple. + ctx.insert(alloc(dl_pop_cmd, dl_ctx)); +#endif } void install_dl_cmds(cmd_context & ctx) { diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 3a2844964..631e1266c 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -997,19 +997,19 @@ namespace datalog { p.insert("print_low_level_smt2", CPK_BOOL, "(default false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); p.insert("print_with_variable_declarations", CPK_BOOL, "(default true) use variable declarations when displaying rules (instead of attempting to use original names)"); - PRIVATE_PARAMS( - p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, - "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " - "by putting in half of the table columns, if it would have been empty otherwise"); - - p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); - ); +#ifndef _EXTERNAL_RELEASE + p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, + "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " + "by putting in half of the table columns, if it would have been empty otherwise"); + p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); + p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion"); +#endif p.insert("fix_unbound_vars", CPK_BOOL, "fix unbound variables in tail"); p.insert("default_table_checker", CPK_SYMBOL, "see default_table_checked"); p.insert("inline_linear", CPK_BOOL, "(default true) try linear inlining method"); p.insert("inline_eager", CPK_BOOL, "(default true) try eager inlining of rules"); - PRIVATE_PARAMS(p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion");); + pdr::dl_interface::collect_params(p); bmc::collect_params(p); diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index 6cbc3b78d..cee6cf747 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -258,16 +258,18 @@ void dl_interface::collect_params(param_descrs& p) { p.insert("unfold_rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); p.insert("use_model_generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); p.insert("validate_result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); - PRIVATE_PARAMS(p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); - PRIVATE_PARAMS(p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); - PRIVATE_PARAMS(p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); - PRIVATE_PARAMS(p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); - PRIVATE_PARAMS(p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); - PRIVATE_PARAMS(p.insert("inductive_reachability_check", CPK_BOOL, - "PDR: (default false) assume negation of the cube on the previous level when " - "checking for reachability (not only during cube weakening)");); - PRIVATE_PARAMS(p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); - PRIVATE_PARAMS(p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); +#ifndef _EXTERNAL_RELEASE + p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states"); + p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening"); + p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation"); + p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants"); + p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search"); + p.insert("inductive_reachability_check", CPK_BOOL, + "PDR: (default false) assume negation of the cube on the previous level when " + "checking for reachability (not only during cube weakening)"); + p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create"); + p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)"); +#endif p.insert("simplify_formulas_pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); p.insert("simplify_formulas_post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); p.insert("slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index d422db708..4bfe2a545 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -50,10 +50,10 @@ datalog_params::datalog_params(): m_default_table_checked(false) {} -void datalog_params::register_params(ini_params& p) { - p.register_symbol_param("DEFAULT_TABLE", m_default_table, "Datalog engine: default table (sparse)"); - p.register_bool_param("DEFAULT_TABLE_CHECKED", m_default_table_checked, "Wrap default table with a sanity checker"); -} +// void datalog_params::register_params(ini_params& p) { +// p.register_symbol_param("DEFAULT_TABLE", m_default_table, "Datalog engine: default table (sparse)"); +// p.register_bool_param("DEFAULT_TABLE_CHECKED", m_default_table_checked, "Wrap default table with a sanity checker"); +// } static void display_statistics( std::ostream& out, diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index 898a7fd97..7e08fce0e 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -23,7 +23,7 @@ struct datalog_params { symbol m_default_table; bool m_default_table_checked; datalog_params(); - virtual void register_params(ini_params& p); + // virtual void register_params(ini_params& p); }; unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index bc3953c1e..5434206cc 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -109,13 +109,13 @@ public: virtual ~extra_params() {} - virtual void register_params(ini_params & p) { - datalog_params::register_params(p); - p.register_bool_param("STATISTICS", m_statistics, "display statistics"); - } + // PARAM-TODO + // virtual void register_params(ini_params & p) { + // datalog_params::register_params(p); + // p.register_bool_param("STATISTICS", m_statistics, "display statistics"); + // } }; -ini_params* g_params = 0; extra_params* g_extra_params = 0; bool g_params_initialized = false; @@ -123,12 +123,12 @@ void init_params() { if (!g_params_initialized) { z3_bound_num_procs(); g_front_end_params = new front_end_params(); - g_params = new ini_params(); + // g_params = new ini_params(); g_extra_params = new extra_params(); - register_verbosity_level(*g_params); - register_warning(*g_params); - g_front_end_params->register_params(*g_params); - g_extra_params->register_params(*g_params); + // register_verbosity_level(*g_params); + // register_warning(*g_params); + // g_front_end_params->register_params(*g_params); + // g_extra_params->register_params(*g_params); g_params_initialized = true; } } @@ -137,37 +137,11 @@ void del_params() { if (g_front_end_params != NULL) g_front_end_params->close_trace_file(); delete g_extra_params; - delete g_params; delete g_front_end_params; g_extra_params = 0; - g_params = 0; g_front_end_params = 0; } - -void read_ini_file(const char * file_name) { - std::ifstream in(file_name); - if (in.bad() || in.fail()) { - std::cerr << "Error: failed to open init file \"" << file_name << "\".\n"; - exit(ERR_INI_FILE); - } - g_params->read_ini_file(in); -} - -void display_ini_help() { - g_params->display_params(std::cout); -} - -void display_config() { - if (g_front_end_params->m_display_config) { - display_ini_help(); - } -} - -void display_ini_doc() { - g_params->display_params_documentation(std::cout); -} - void parse_cmd_line_args(int argc, char ** argv) { int i = 1; char * eq_pos = 0; @@ -285,10 +259,6 @@ void parse_cmd_line_args(int argc, char ** argv) { gparams::display(std::cout); exit(0); } - else if (strcmp(opt_name, "geninidoc") == 0) { - display_ini_doc(); - exit(0); - } #ifdef _TRACE else if (strcmp(opt_name, "tr") == 0) { if (!opt_arg) @@ -375,11 +345,6 @@ int main(int argc, char ** argv) { memory::set_high_watermark(static_cast(g_front_end_params->m_memory_high_watermark) * 1024 * 1024); memory::set_max_size(static_cast(g_front_end_params->m_memory_max_size) * 1024 * 1024); g_front_end_params->open_trace_file(); - DEBUG_CODE( - if (g_front_end_params->m_copy_params != -1) { - g_front_end_params->copy_params(g_front_end_params->m_copy_params); - TRACE("copy_params", g_params->display_params(tout);); - }); if (g_input_file && g_standard_input) { error("using standard input to read formula."); } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index c9dcc3fa2..759f5cee2 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -40,7 +40,6 @@ static smtlib::solver* g_solver = 0; static cmd_context * g_cmd_context = 0; static void display_statistics() { - display_config(); clock_t end_time = clock(); if ((g_solver || g_cmd_context) && g_display_statistics) { std::cout.flush(); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 9ab21ccc5..c51a1ebc1 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -3103,7 +3103,6 @@ namespace smt { m_next_progress_sample = 0; TRACE("literal_occ", display_literal_num_occs(tout);); m_timer.start(); - m_instr.start(); } void context::end_search() { @@ -3359,11 +3358,6 @@ namespace smt { return true; } - if (m_instr.is_instruction_maxed(m_fparams.m_instr_out)) { - m_last_search_failure = TIMEOUT; - return true; - } - if (m_progress_callback) { m_progress_callback->fast_progress_sample(); if (m_fparams.m_progress_sampling_freq > 0 && m_timer.ms_timeout(m_next_progress_sample + 1)) { diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 132718e9a..204a56827 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -47,7 +47,6 @@ Revision History: #include"proto_model.h" #include"model.h" #include"timer.h" -#include"instruction_count.h" #include"statistics.h" #include"progress_callback.h" @@ -77,7 +76,6 @@ namespace smt { setup m_setup; volatile bool m_cancel_flag; timer m_timer; - instruction_count m_instr; asserted_formulas m_asserted_formulas; scoped_ptr m_qmanager; scoped_ptr m_model_generator; diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index bd9196056..67c94808e 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -55,7 +55,6 @@ namespace smt { case CFG_LOGIC: setup_default(); break; case CFG_AUTO: setup_auto_config(); break; } - TRACE("setup", ini_params p; m_params.register_params(p); p.display_params(tout);); } void setup::setup_default() { diff --git a/src/test/ini_file.cpp b/src/test/ini_file.cpp deleted file mode 100644 index d3114c037..000000000 --- a/src/test/ini_file.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include -#include"ini_file.h" -#include"debug.h" - -static void tst1() { - ini_params p; - int p1; - p.register_int_param("ipar1", 0, 100, p1); - int p2; - p.register_int_param("ipar2", -100, 100, p2); - bool p3; - p.register_bool_param("bpar1", p3); - bool p4; - p.register_bool_param("bpar2", p4); - unsigned p5; - p.register_unsigned_param("upar1", 0, 100, p5); - double p6; - p.register_percentage_param("ppar1", p6); - std::istringstream in("ipar1 = 100 ipar2=-30 bpar1 = true ;; COMMENT\n bpar2 = false upar1=30 ppar1 = 10"); - p.read_ini_file(in); - SASSERT(p1 == 100); - SASSERT(p2 == -30); - SASSERT(p3); - SASSERT(!p4); - SASSERT(p5 == 30); - SASSERT(p6 == 0.1); -} - -void tst_ini_file() { - tst1(); -} - diff --git a/src/test/main.cpp b/src/test/main.cpp index acbea0761..bee889ea2 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -140,7 +140,6 @@ int main(int argc, char ** argv) { TST(diff_logic); TST(uint_set); TST_ARGV(expr_rand); - TST(ini_file); TST(list); TST(small_object_allocator); TST(timeout); diff --git a/src/util/ini_file.cpp b/src/util/ini_file.cpp deleted file mode 100644 index 48279a2ea..000000000 --- a/src/util/ini_file.cpp +++ /dev/null @@ -1,1564 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.cpp - -Abstract: - - Configuration file support. - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include"ini_file.h" -#include"util.h" -#include"trace.h" -#include"str_hashtable.h" -#include"map.h" -#include"string_buffer.h" -#include"symbol_table.h" -#include"error_codes.h" -#include - -template -class value_vector_map { - void * m_owner; - map *, ptr_hash, ptr_eq > m_mapping; - ptr_vector m_domain; - ptr_vector > m_range; - unsigned m_max_size; -public: - value_vector_map(void * owner):m_owner(owner), m_max_size(0) {} - - ~value_vector_map() { - std::for_each(m_range.begin(), m_range.end(), delete_proc >()); - } - - void insert(T * ptr, T const & value) { - SASSERT(reinterpret_cast(ptr) >= reinterpret_cast(m_owner)); - vector * vect; - if (m_mapping.find(ptr, vect)) { - vect->push_back(value); - if (vect->size() > m_max_size) - m_max_size = vect->size(); - return; - } - vect = alloc(vector); - m_range.push_back(vect); - m_domain.push_back(ptr); - vect->push_back(value); - if (m_max_size == 0) - m_max_size = 1; - m_mapping.insert(ptr, vect); - } - - void copy_params(void * curr_owner, unsigned idx) { - typename ptr_vector::iterator it = m_domain.begin(); - typename ptr_vector::iterator end = m_domain.end(); - for (; it != end; ++it) { - T * ptr = *it; - vector * vect = 0; - m_mapping.find(ptr, vect); - SASSERT(vect != 0); - if (idx < vect->size()) { - // BIG HACK - SASSERT(reinterpret_cast(ptr) >= reinterpret_cast(m_owner)); - size_t offset = reinterpret_cast(ptr) - reinterpret_cast(m_owner); - T * curr_ptr = reinterpret_cast(reinterpret_cast(curr_owner) + offset); - *curr_ptr = vect->operator[](idx); - } - } - } - - unsigned size(void) const { return m_max_size; } -}; - -struct param_vector_imp { - value_vector_map m_bool_params; - value_vector_map m_unsigned_params; - value_vector_map m_int_params; - value_vector_map m_double_params; - value_vector_map m_string_params; - value_vector_map m_symbol_params; - value_vector_map > m_symbol_list_params; - value_vector_map > m_symbol_nat_list_params; - - param_vector_imp(void * owner): - m_bool_params(owner), - m_unsigned_params(owner), - m_int_params(owner), - m_double_params(owner), - m_string_params(owner), - m_symbol_params(owner), - m_symbol_list_params(owner), - m_symbol_nat_list_params(owner) { - } - - void insert_bool_param(bool * value_ptr, bool value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_bool_params.insert(value_ptr, value); - } - - void insert_unsigned_param(unsigned * value_ptr, unsigned value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_unsigned_params.insert(value_ptr, value); - } - - void insert_int_param(int * value_ptr, int value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_int_params.insert(value_ptr, value); - } - - void insert_double_param(double * value_ptr, double value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_double_params.insert(value_ptr, value); - } - - void insert_string_param(std::string * value_ptr, std::string const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_string_params.insert(value_ptr, value); - } - - void insert_symbol_param(symbol * value_ptr, symbol const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_symbol_params.insert(value_ptr, value); - } - - void insert_symbol_list_param(svector * value_ptr, svector const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> "; display(tout, value.begin(), value.end()); tout << "\n";); - m_symbol_list_params.insert(value_ptr, value); - } - - void insert_symbol_nat_list_param(svector * value_ptr, svector const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> "; display(tout, value.begin(), value.end()); tout << "\n";); - m_symbol_nat_list_params.insert(value_ptr, value); - } - - void copy_params(void * curr_owner, unsigned idx) { - m_bool_params.copy_params(curr_owner, idx); - m_unsigned_params.copy_params(curr_owner, idx); - m_int_params.copy_params(curr_owner, idx); - m_double_params.copy_params(curr_owner, idx); - m_string_params.copy_params(curr_owner, idx); - m_symbol_params.copy_params(curr_owner, idx); - m_symbol_list_params.copy_params(curr_owner, idx); - m_symbol_nat_list_params.copy_params(curr_owner, idx); - } - - unsigned size(void) const { - unsigned ret = 0; - ret = std::max(ret, m_bool_params.size()); - ret = std::max(ret, m_unsigned_params.size()); - ret = std::max(ret, m_int_params.size()); - ret = std::max(ret, m_double_params.size()); - ret = std::max(ret, m_string_params.size()); - ret = std::max(ret, m_symbol_params.size()); - ret = std::max(ret, m_symbol_list_params.size()); - ret = std::max(ret, m_symbol_nat_list_params.size()); - return ret; - } -}; - - -param_vector::param_vector(void * owner): - m_ref_count(0) { - m_imp = alloc(param_vector_imp, owner); -} - -param_vector::~param_vector() { - dealloc(m_imp); -} - -void param_vector::inc_ref() { - m_ref_count++; -} - -void param_vector::dec_ref() { - SASSERT(m_ref_count > 0); - m_ref_count--; - if (m_ref_count == 0) - dealloc(this); -} - -void param_vector::copy_params(void * curr_owner, unsigned idx) { - m_imp->copy_params(curr_owner, idx); -} - -unsigned param_vector::size(void) const -{ - return m_imp->size(); -} - -enum itoken { - ITK_NULL, ITK_ID, ITK_NUM, ITK_DOUBLE, ITK_STRING, ITK_BAD_STRING, ITK_TRUE, ITK_FALSE, ITK_COMMA, ITK_LP, ITK_RP, ITK_LCB, ITK_RCB, ITK_CLN, ITK_EQ, ITK_BAD_ID, ITK_EOS, ITK_LAST -}; - -class ini_reserved_symbols { - typedef map str2token; - str2token m_str2token; - -public: - ini_reserved_symbols() { - m_str2token.insert("true", ITK_TRUE); - m_str2token.insert("false", ITK_FALSE); - } - - itoken string2itoken(char const * str) { - str2token::entry * e = m_str2token.find_core(const_cast(str)); - if (e) - return e->get_data().m_value; - else - return ITK_ID; - } -}; - -static char const * g_itoken2string[] = { - "", - "", - "", - "", - "", - "", - "true", - "false", - ",", - "(", - ")", - "{", - "}", - ":", - "=", - "", - "" -}; - -COMPILE_TIME_ASSERT(sizeof(g_itoken2string)/sizeof(char const*) == ITK_LAST); - -inline static const char * itoken2string(itoken t) { - return g_itoken2string[t]; -} - -inline itoken string2itoken(ini_reserved_symbols& reserved, char const * str) { - itoken r = reserved.string2itoken(str); - TRACE("token", tout << str << " -> " << itoken2string(r) << "\n";); - return r; -} - -class ini_lexer { - std::istream & m_input; - char m_curr_char; - int m_line; - int m_pos; - int m_tok_pos; - string_buffer<> m_buffer; - ini_reserved_symbols m_ini_reserved; -public: - bool eos() const { - return m_curr_char == EOF; - } - - void next() { - m_curr_char = m_input.get(); - m_pos++; - } - - void save_and_next() { - m_buffer << m_curr_char; - next(); - } - - ini_lexer(std::istream & input): - m_input(input), - m_line(1), - m_pos(0), - m_tok_pos(0), - m_ini_reserved() { - next(); - } - - itoken read_num() { - while (isdigit(m_curr_char)) { - save_and_next(); - } - if (m_curr_char == '.') { - save_and_next(); - while (isdigit(m_curr_char)) { - save_and_next(); - } - if (m_curr_char == 'e' || m_curr_char == 'E' || m_curr_char == 'd' || m_curr_char == 'D') { - save_and_next(); - if (m_curr_char == '-') { - save_and_next(); - } - while (isdigit(m_curr_char)) { - save_and_next(); - } - } - return ITK_DOUBLE; - } - return ITK_NUM; - } - - itoken read_id() { - while (!eos() && (isalpha(m_curr_char) || isdigit(m_curr_char) || m_curr_char == '_')) { - save_and_next(); - } - return string2itoken(m_ini_reserved, m_buffer.c_str()); - } - - itoken read_string() { - m_tok_pos = m_pos; - next(); - while (m_curr_char != '"' && m_curr_char != '\'') { - if (m_input.eof()) { - return ITK_BAD_STRING; - } - if (m_curr_char == '\n') { - return ITK_BAD_STRING; - } - if (m_curr_char == '\\') { - next(); // do not save the '\' - switch (m_curr_char) { - case 't': - m_buffer << '\t'; - next(); - break; - case 'n': - m_buffer << '\n'; - next(); - break; - case '\n': - m_buffer << '\n'; - next(); - break; - default: - if (!isdigit(m_curr_char)) { - save_and_next(); /* handles \\, \", \', and \? */ - } - else { /* \xxx */ - int c = 0; - int i = 0; - do { - c = 10*c + (m_curr_char-'0'); - next(); - } - while (++i<3 && isdigit(m_curr_char)); - if (c > UCHAR_MAX) { - return ITK_BAD_STRING; - } - m_buffer << static_cast(c); - } - } - } - else { - save_and_next(); - } - } - next(); - return ITK_STRING; - } - - itoken next_token() { - for(;;) { - if (eos()) { - return ITK_EOS; - } - - m_buffer.reset(); - switch (m_curr_char) { - case ';': // comment - while (m_curr_char != '\n' && !eos()) { - next(); - } - break; - case '\n': - next(); - m_line++; - break; - case '=': - m_tok_pos = m_pos; - next(); - return ITK_EQ; - case '\'': - case '\"': - return read_string(); - case '{': - m_tok_pos = m_pos; - next(); - return ITK_LCB; - case '}': - m_tok_pos = m_pos; - next(); - return ITK_RCB; - case '(': - m_tok_pos = m_pos; - next(); - return ITK_LP; - case ')': - m_tok_pos = m_pos; - next(); - return ITK_RP; - case ',': - m_tok_pos = m_pos; - next(); - return ITK_COMMA; - case ':': - m_tok_pos = m_pos; - next(); - return ITK_CLN; - default: - if (isspace(m_curr_char)) { - next(); - break; - } - else if (isdigit(m_curr_char)) { - m_tok_pos = m_pos; - save_and_next(); - return read_num(); - } - else { - char old = m_curr_char; - m_tok_pos = m_pos; - save_and_next(); - TRACE("ini_lexer", tout << "old: " << static_cast(old) << " " << old << "\n";); - if (old == '-' && isdigit(m_curr_char)) { - return read_num(); - } - else if (old == '_' || isalpha(old)) { - return read_id(); - } - else { - return ITK_BAD_ID; - } - } - } - } - } - - char const * get_token_data() const { - return m_buffer.c_str(); - } - - unsigned get_token_pos() const { - return m_tok_pos; - } -}; - - -enum ini_param_kind { - IPK_BOOL, - IPK_INT, - IPK_UNSIGNED, - IPK_DOUBLE, - IPK_PERCENTAGE, - IPK_STRING, - IPK_SYMBOL, - IPK_SYMBOL_LIST, - IPK_SYMBOL_NAT_LIST -}; - - -struct ini_param_info { - ini_param_kind m_kind; - bool m_is_mutable; - - char const * m_description; - union { - struct { - int m_int_min; - int m_int_max; - int * m_int_val; - }; - struct { - unsigned m_uint_min; - unsigned m_uint_max; - unsigned * m_uint_val; - }; - bool * m_bool_val; - double * m_double_val; - double * m_perc_val; - symbol * m_sym_val; - std::string * m_str_val; - svector * m_sym_list_val; - svector * m_sym_nat_list_val; - }; - - ini_param_info(char const * descr = 0): - m_kind(IPK_BOOL), - m_is_mutable(false), - m_description(descr), - m_bool_val(0) { - } - - ini_param_info(int min, int max, int * val, char const * descr, bool is_mutable): - m_kind(IPK_INT), - m_is_mutable(is_mutable), - m_description(descr), - m_int_min(min), - m_int_max(max), - m_int_val(val) { - } - - ini_param_info(unsigned min, unsigned max, unsigned * val, char const * descr, bool is_mutable): - m_kind(IPK_UNSIGNED), - m_is_mutable(is_mutable), - m_description(descr), - m_uint_min(min), - m_uint_max(max), - m_uint_val(val) { - } - - ini_param_info(bool * val, char const * descr, bool is_mutable): - m_kind(IPK_BOOL), - m_is_mutable(is_mutable), - m_description(descr), - m_bool_val(val) { - } - - ini_param_info(bool perc, double * val, char const * descr, bool is_mutable): - m_kind(perc ? IPK_PERCENTAGE : IPK_DOUBLE), - m_is_mutable(is_mutable), - m_description(descr), - m_perc_val(val) { - } - - ini_param_info(svector * val, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL_LIST), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_list_val(val) { - } - - ini_param_info(svector * val, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL_NAT_LIST), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_nat_list_val(val) { - } - - ini_param_info(symbol * s, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_val(s) { - } - - ini_param_info(std::string * str, char const * descr, bool is_mutable): - m_kind(IPK_STRING), - m_is_mutable(is_mutable), - m_description(descr), - m_str_val(str) { - } - -}; - -struct ini_params_imp { - bool m_abort_on_error; - ini_reserved_symbols m_ini_reserved; - ref m_param_vector; - symbol_table m_param_info; - bool m_is_frozen; - - ini_params_imp(bool abort_on_error): m_abort_on_error(abort_on_error), m_is_frozen(false) {} - - void freeze(bool f) { m_is_frozen = f; } - - void register_param_vector(param_vector * pv) { - m_param_vector = pv; - } - - void register_bool_param(symbol param_name, bool & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_unsigned_param(symbol param_name, unsigned min, unsigned max, unsigned & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(min, max, &value, descr, is_mutable)); - } - - void register_int_param(symbol param_name, int min, int max, int & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(min, max, &value, descr, is_mutable)); - } - - void register_percentage_param(symbol param_name, double & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(true, &value, descr, is_mutable)); - } - - void register_double_param(symbol param_name, double & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(false, &value, descr, is_mutable)); - } - - void register_string_param(symbol param_name, std::string & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_param(symbol param_name, symbol & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_list_param(symbol param_name, svector & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_nat_list_param(symbol param_name, svector & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - struct symbol_lt_proc { - bool operator()(const symbol & s1, const symbol & s2) const { - return strcmp(s1.bare_str(), s2.bare_str()) < 0; - } - }; - - void display_param_help(char const* param_id, std::ostream& out) const { - ini_param_info info; - if (m_param_info.find(symbol(param_id), info)) { - display_param_info(out, info); - } - else { - out << "option " << param_id << " does not exist"; - } - } - - void display_param_info(std::ostream& out, ini_param_info& info) const { - switch (info.m_kind) { - case IPK_BOOL: - out << " boolean"; - out << ", default: " << (*info.m_bool_val ? "true" : "false"); - break; - case IPK_INT: - out << " integer"; - if (info.m_int_min > INT_MIN) { - out << ", min: " << info.m_int_min; - } - if (info.m_int_max < INT_MAX) { - out << ", max: " << info.m_int_max; - } - out << ", default: " << *info.m_int_val; - break; - case IPK_UNSIGNED: - out << " unsigned integer"; - if (info.m_uint_min > 0) { - out << ", min: " << info.m_uint_min; - } - if (info.m_uint_max < INT_MAX) { - out << ", max: " << info.m_uint_max; - } - out << ", default: " << *info.m_uint_val; - break; - case IPK_DOUBLE: - out << " double"; - out << ", default: " << *info.m_double_val; - break; - case IPK_PERCENTAGE: - out << " percentage"; - out << ", default: " << *info.m_perc_val; - break; - case IPK_SYMBOL: - out << " symbol"; - out << ", default: " << *info.m_sym_val; - break; - case IPK_STRING: - out << " string"; - out << ", default: " << *info.m_str_val; - break; - case IPK_SYMBOL_LIST: - out << " list of symbols (strings)"; - break; - case IPK_SYMBOL_NAT_LIST: - out << " list of pairs: symbols(strings) x unsigned"; - break; - } - if (info.m_description) { - out << ", " << info.m_description << "."; - } - out << "\n"; - } - - void display_params(std::ostream & out) const { - svector params; - m_param_info.get_dom(params); - std::sort(params.begin(), params.end(), symbol_lt_proc()); - svector::iterator it = params.begin(); - svector::iterator end = params.end(); - for (; it != end; ++it) { - out << *it << ":"; - ini_param_info info; - m_param_info.find(*it, info); - display_param_info(out, info); - } - } - - void display_params_documentation(std::ostream & out) const { - out << "// AUTOMATICALLY GENERATED FILE - DO NOT EDIT\n\n" - << "/**\n" - << " \\page config INI parameters\n\n"; - svector params; - m_param_info.get_dom(params); - std::sort(params.begin(), params.end(), symbol_lt_proc()); - svector::iterator it = params.begin(); - svector::iterator end = params.end(); - for (; it != end; ++it) { - out << "- \\c " << *it << ":"; - ini_param_info info; - m_param_info.find(*it, info); - switch (info.m_kind) { - case IPK_BOOL: - out << " \\em boolean"; - out << ", default: " << (*info.m_bool_val ? "\\c true" : "\\c false"); - break; - case IPK_INT: - out << " \\em integer"; - if (info.m_int_min > INT_MIN) { - out << ", min: \\c " << info.m_int_min; - } - if (info.m_int_max < INT_MAX) { - out << ", max: \\c " << info.m_int_max; - } - out << ", default: \\c " << *info.m_int_val; - break; - case IPK_UNSIGNED: - out << " \\em unsigned \\em integer"; - if (info.m_uint_min > 0) { - out << ", min: \\c " << info.m_uint_min; - } - if (info.m_uint_max < INT_MAX) { - out << ", max: \\c " << info.m_uint_max; - } - out << ", default: \\c " << *info.m_uint_val; - break; - case IPK_DOUBLE: - out << " \\em double"; - out << ", default: \\c " << *info.m_double_val; - break; - case IPK_PERCENTAGE: - out << " \\em percentage"; - out << ", default: \\c " << *info.m_perc_val; - break; - case IPK_STRING: - out << " \\em string"; - out << ", default: " << *info.m_str_val; - break; - case IPK_SYMBOL: - out << " \\em symbol"; - out << ", default: " << *info.m_sym_val; - break; - case IPK_SYMBOL_LIST: - out << " \\em list \\em of \\em symbols \\em (strings)"; - break; - case IPK_SYMBOL_NAT_LIST: - out << " \\em list \\em of \\em pairs: \\em symbols(strings) \\em x \\em unsigned"; - break; - } - if (info.m_description) { - out << ", " << info.m_description << "."; - } - out << "\n\n"; - } - out << "*/\n"; - } - - void error(char const * param_id, char const * msg) { - if (m_abort_on_error) { - verbose_stream() << "Error setting '" << param_id << "', reason: " << msg << "\n"; - throw z3_error(ERR_INI_FILE); - } - else { - throw set_get_param_exception(param_id, msg); - } - } - - symbol trim(char const * param_id) { - string_buffer<> m_buffer; - while (*param_id != 0 && !isspace(*param_id)) { - m_buffer.append(*param_id); - param_id++; - } - return symbol(m_buffer.c_str()); - } - - void set_param_value(char const * param_id, char const * param_value) { - TRACE("param_value", tout << param_id << " " << param_value << "\n";); - if (param_value == 0) { - error(param_id, "invalid (null) option"); - } - symbol s(param_id); - ini_param_info info; - if (!m_param_info.find(s, info)) { - s = trim(param_id); - if (!m_param_info.find(s, info)) - error(param_id, "unknown option."); - } - if (!info.m_is_mutable && m_is_frozen) { - error(param_id, "option value cannot be modified after initialization"); - } - switch (info.m_kind) { - case IPK_BOOL: - parse_bool_param(param_id, info, param_value); - break; - case IPK_INT: - parse_int_param(param_id, info, param_value); - break; - case IPK_UNSIGNED: - parse_uint_param(param_id, info, param_value); - break; - case IPK_DOUBLE: - parse_double_param(param_id, info, param_value); - break; - case IPK_PERCENTAGE: - parse_perc_param(param_id, info, param_value); - break; - case IPK_STRING: - parse_string_param(param_id, info, param_value); - break; - case IPK_SYMBOL: - // TODO: not used so far - *info.m_sym_val = param_value; - break; - case IPK_SYMBOL_LIST: - error(param_id, "this option can only be set in an INI file"); - break; - case IPK_SYMBOL_NAT_LIST: - error(param_id, "this option can only be set in an INI file"); - break; - default: - UNREACHABLE(); - } - } - - - bool get_param_value(char const * param_id, std::string& param_value) { - TRACE("param_value", tout << param_id << "\n";); - std::ostringstream buffer; - symbol s(param_id); - ini_param_info info; - if (!m_param_info.find(s, info)) { - s = trim(param_id); - if (!m_param_info.find(s, info)) { - return false; - } - } - switch (info.m_kind) { - case IPK_BOOL: - buffer << ((*info.m_bool_val)?"true":"false"); - break; - case IPK_INT: - buffer << (*info.m_int_val); - break; - case IPK_UNSIGNED: - buffer << (*info.m_uint_val); - break; - case IPK_DOUBLE: - buffer << (*info.m_double_val); - break; - case IPK_PERCENTAGE: - buffer << (*info.m_perc_val); - break; - case IPK_STRING: - buffer << (*info.m_str_val); - break; - case IPK_SYMBOL: - buffer << (info.m_sym_val->str()); - break; - case IPK_SYMBOL_LIST: - error(param_id, "this option cannot be retrieved"); - break; - case IPK_SYMBOL_NAT_LIST: - error(param_id, "this option cannot be retrieved"); - break; - default: - UNREACHABLE(); - } - param_value = buffer.str(); - return true; - } - - string_buffer<> m_buffer; - - char const * get_token_data() const { - return m_buffer.c_str(); - } - - void save_and_next(char const * & in) { - m_buffer.append(*in); - ++in; - } - - itoken read_num(char const * & in) { - while (isdigit(*in)) { - save_and_next(in); - } - TRACE("read_num", tout << "1. read_num: " << m_buffer.c_str() << ", *in: " << *in << "\n";); - if (*in == '.') { - save_and_next(in); - while (isdigit(*in)) { - save_and_next(in); - } - TRACE("read_num", tout << "2. read_num: " << m_buffer.c_str() << ", *in: " << *in << "\n";); - if (*in == 'e' || *in == 'E' || *in == 'd' || *in == 'D') { - save_and_next(in); - if (*in == '-') { - save_and_next(in); - } - while (isdigit(*in)) { - save_and_next(in); - } - } - return ITK_DOUBLE; - } - return ITK_NUM; - } - - itoken read_id(char const * & in) { - while (!*in == 0 && (isalpha(*in) || isdigit(*in) || *in == '_')) { - save_and_next(in); - } - return string2itoken(m_ini_reserved, m_buffer.c_str()); - } - - itoken read_string(char const * & in) { - ++in; - while (*in != '"' && *in != '\'') { - TRACE("read_string", tout << *in << "\n";); - if (*in == 0) - return ITK_BAD_STRING; - if (*in == '\n') - return ITK_BAD_STRING; - if (*in == '\\') { - ++in; - switch (*in) { - case 't': - m_buffer << '\t'; - ++in; - break; - case 'n': - m_buffer << '\n'; - ++in; - break; - case '\n': - m_buffer << '\n'; - ++in; - break; - default: - if (!isdigit(*in)) { - save_and_next(in); /* handles \\, \", \', and \? */ - } - else { /* \xxx */ - int c = 0; - int i = 0; - do { - c = 10*c + (*in-'0'); - ++in; - } - while (++i<3 && isdigit(*in)); - if (c > UCHAR_MAX) - return ITK_BAD_STRING; - m_buffer << static_cast(c); - } - } - } - else { - save_and_next(in); - } - } - ++in; - return ITK_STRING; - } - - itoken next_token(char const * & in) { - for(;;) { - if (*in == 0) - return ITK_EOS; - m_buffer.reset(); - switch (*in) { - case '{': - in++; - return ITK_LCB; - case '}': - in++; - return ITK_RCB; - case ',': - in++; - return ITK_COMMA; - case '"': - case '\'': - TRACE("read_string", tout << "found \"\n";); - return read_string(in); - default: - if (isspace(*in)) { - in++; - break; - } - else if (isdigit(*in)) { - TRACE("read_num", tout << "found is_digit\n";); - return read_num(in); - } - else { - char old = *in; - save_and_next(in); - if (old == '-' && isdigit(*in)) { - return read_num(in); - } - else if (old == '_' || isalpha(old)) { - return read_id(in); - } - else { - return ITK_BAD_ID; - } - } - } - } - } - - bool end_of_list(char const * param_id, char const * & param_value) { - switch (next_token(param_value)) { - case ITK_COMMA: - return false; - case ITK_RCB: - return true; - default: - error(param_id, "boolean value (true/false) expected"); - } - return false; - } - - void parse_bool_param(char const * param_id, ini_param_info & info, char const * param_value) { - switch (next_token(param_value)) { - case ITK_TRUE: - *info.m_bool_val = true; - break; - case ITK_FALSE: - *info.m_bool_val = false; - break; - default: - error(param_id, "boolean value (true/false) expected"); - } - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - switch (next_token(param_value)) { - case ITK_TRUE: - m_param_vector->m_imp->insert_bool_param(info.m_bool_val, true); - break; - case ITK_FALSE: - m_param_vector->m_imp->insert_bool_param(info.m_bool_val, false); - break; - default: - error(param_id, "boolean value (true/false) expected"); - } - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_int_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error(param_id, "integer out of bounds"); - *info.m_int_val = val; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error(param_id, "integer out of bounds"); - m_param_vector->m_imp->insert_int_param(info.m_int_val, val); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_uint_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - unsigned val = static_cast(strtol(get_token_data(), 0, 10)); - - if (val < info.m_uint_min || val > info.m_uint_max) - error(param_id, "unsigned out of bounds"); - *info.m_uint_val = val; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - unsigned val = static_cast(strtol(get_token_data(), 0, 10)); - if (val < info.m_uint_min || val > info.m_uint_max) - error(param_id, "unsigned out of bounds"); - m_param_vector->m_imp->insert_unsigned_param(info.m_uint_val, val); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_double_param(char const * param_id, ini_param_info & info, char const * param_value) { - itoken k = next_token(param_value); - if (k != ITK_NUM && k != ITK_DOUBLE) - error(param_id, "float expected"); - char * aux; - *info.m_double_val = strtod(get_token_data(), &aux); - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - k = next_token(param_value); - if (k != ITK_NUM && k != ITK_DOUBLE) - error(param_id, "float expected"); - m_param_vector->m_imp->insert_double_param(info.m_double_val, strtod(get_token_data(), &aux)); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_perc_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error(param_id, "integer between 0 and 100 expected"); - *info.m_perc_val = static_cast(val)/100.0; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error(param_id, "integer between 0 and 100 expected"); - m_param_vector->m_imp->insert_double_param(info.m_perc_val, static_cast(val)/100.0); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_string_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_STRING) - error(param_id, "string expected"); - *info.m_str_val = get_token_data(); - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_STRING) - error(param_id, "string expected"); - m_param_vector->m_imp->insert_string_param(info.m_str_val, get_token_data()); - if (end_of_list(param_id, param_value)) - return; - } - } - } -}; - -class ini_parser { - ini_lexer m_lexer; - ini_params_imp * m_params; - itoken m_curr_token; - - void error(unsigned pos, char const * msg) { - if (m_params->m_abort_on_error) { - verbose_stream() << "Error INI file [position: " << pos << "]: " << msg << "\n"; - throw z3_error(ERR_INI_FILE); - } - else { - throw ini_parser_exception(pos, msg); - } - } - - void error(char const * msg) { - error(m_lexer.get_token_pos(), msg); - } - - itoken get_curr_token() { - if (m_curr_token == ITK_NULL) { - m_curr_token = m_lexer.next_token(); - } - SASSERT(m_curr_token != ITK_NULL); - return m_curr_token; - } - - void next() { - if (m_curr_token == ITK_NULL) { - m_lexer.next_token(); - } - else { - m_curr_token = ITK_NULL; - } - } - - char const * get_token_data() { - if (m_curr_token == ITK_NULL) { - get_curr_token(); - } - SASSERT(m_curr_token != ITK_NULL); - return m_lexer.get_token_data(); - } - - bool test_next(itoken expected) { - if (get_curr_token() == expected) { - next(); - return true; - } - else { - return false; - } - } - - void check(itoken expected) { - if (!test_next(expected)) { - string_buffer<> msg; - msg << "unexpected token '" << itoken2string(get_curr_token()) - << "', '" << itoken2string(expected) << "' expected."; - error(msg.c_str()); - } - } - -public: - ini_parser(std::istream & in, ini_params_imp * p): - m_lexer(in), - m_params(p), - m_curr_token(ITK_NULL) { - } - - void parse_param() { - symbol s(get_token_data()); - check(ITK_ID); - ini_param_info info; - if (!m_params->m_param_info.find(s, info)) { - error("unknown option."); - } - check(ITK_EQ); - switch (info.m_kind) { - case IPK_BOOL: - parse_bool_param(info); - break; - case IPK_INT: - parse_int_param(info); - break; - case IPK_UNSIGNED: - parse_uint_param(info); - break; - case IPK_DOUBLE: - parse_double_param(info); - break; - case IPK_PERCENTAGE: - parse_perc_param(info); - break; - case IPK_STRING: - parse_string_param(info); - break; - case IPK_SYMBOL: - // TODO: add support for VAL{VAL,...,VAL} - *info.m_sym_val = get_token_data(); - check(ITK_STRING); - break; - case IPK_SYMBOL_NAT_LIST: - parse_symbol_nat_list(info); - break; - case IPK_SYMBOL_LIST: - parse_symbol_list(info); - break; - default: - UNREACHABLE(); - } - } - - bool end_of_list() { - switch (get_curr_token()) { - case ITK_COMMA: - next(); - return false; - case ITK_RCB: - next(); - return true; - default: - error("boolean value expected"); - } - return false; - } - - void parse_bool_param(ini_param_info & info) { - if (get_curr_token() != ITK_TRUE && get_curr_token() != ITK_FALSE) - error("boolean value expected"); - *info.m_bool_val = get_curr_token() == ITK_TRUE; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_TRUE && get_curr_token() != ITK_FALSE) - error("boolean value expected"); - m_params->m_param_vector->m_imp->insert_bool_param(info.m_bool_val, get_curr_token() == ITK_TRUE); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_int_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error("integer out of bounds"); - *info.m_int_val = val; - next(); - TRACE("int_param", tout << "val: " << val << "\n";); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error("integer out of bounds"); - m_params->m_param_vector->m_imp->insert_int_param(info.m_int_val, val); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_uint_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - long val = strtol(get_token_data(), 0, 10); - if (val < static_cast(info.m_uint_min) || val > static_cast(info.m_uint_max)) - error("integer out of bounds"); - *info.m_uint_val = val; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - long val = strtol(get_token_data(), 0, 10); - if (val < static_cast(info.m_uint_min) || val > static_cast(info.m_uint_max)) - error("integer out of bounds"); - m_params->m_param_vector->m_imp->insert_unsigned_param(info.m_uint_val, val); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_double_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM && get_curr_token() != ITK_DOUBLE) - error("float expected"); - char * aux; - *info.m_double_val = strtod(get_token_data(), &aux); - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM && get_curr_token() != ITK_DOUBLE) - error("float expected"); - m_params->m_param_vector->m_imp->insert_double_param(info.m_double_val, strtod(get_token_data(), &aux)); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_perc_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error("integer between 0 and 100 expected"); - *info.m_perc_val = static_cast(val)/100.0; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error("integer between 0 and 100 expected"); - m_params->m_param_vector->m_imp->insert_double_param(info.m_perc_val, static_cast(val)/100.0); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_string_param(ini_param_info & info) { - if (get_curr_token() != ITK_STRING) - error("string expected"); - *info.m_str_val = get_token_data(); - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_STRING) - error("string expected"); - m_params->m_param_vector->m_imp->insert_string_param(info.m_str_val, get_token_data()); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_s_list(svector & result) { - check(ITK_LP); - for (;;) { - symbol s(get_token_data()); - result.push_back(s); - check(ITK_ID); - if (!test_next(ITK_COMMA)) { - check(ITK_RP); - return; - } - } - } - - void parse_symbol_list(ini_param_info & info) { - parse_s_list(*(info.m_sym_list_val)); - if (m_params->m_param_vector.get() && test_next(ITK_LCB)) { - for (;;) { - svector lst; - parse_s_list(lst); - m_params->m_param_vector->m_imp->insert_symbol_list_param(info.m_sym_list_val, lst); - if (!test_next(ITK_COMMA)) { - check(ITK_RCB); - return; - } - } - } - } - - void parse_sn_list(svector & result) { - check(ITK_LP); - for (;;) { - symbol s(get_token_data()); - check(ITK_ID); - check(ITK_CLN); - unsigned val = strtol(get_token_data(), 0, 10); - check(ITK_NUM); - result.push_back(std::make_pair(s, val)); - if (!test_next(ITK_COMMA)) { - check(ITK_RP); - return; - } - } - } - - void parse_symbol_nat_list(ini_param_info & info) { - parse_sn_list(*(info.m_sym_nat_list_val)); - if (m_params->m_param_vector.get() && test_next(ITK_LCB)) { - for (;;) { - svector lst; - parse_sn_list(lst); - m_params->m_param_vector->m_imp->insert_symbol_nat_list_param(info.m_sym_nat_list_val, lst); - if (!test_next(ITK_COMMA)) { - check(ITK_RCB); - return; - } - } - } - } - - void parse() { - while (get_curr_token() != ITK_EOS) { - parse_param(); - } - } -}; - -ini_params::ini_params(bool abort_on_error) { - m_imp = alloc(ini_params_imp, abort_on_error); -} - -ini_params::~ini_params() { - dealloc(m_imp); -} - -void ini_params::register_bool_param(char const * param_name, bool & value, char const * descr, bool is_mutable) { - m_imp->register_bool_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_unsigned_param(char const * param_name, unsigned min, unsigned max, unsigned & value, char const * descr, bool is_mutable) { - m_imp->register_unsigned_param(symbol(param_name), min, max, value, descr, is_mutable); -} - -void ini_params::register_int_param(char const * param_name, int min, int max, int & value, char const * descr, bool is_mutable) { - m_imp->register_int_param(symbol(param_name), min, max, value, descr, is_mutable); -} - -void ini_params::register_double_param(char const * param_name, double & value, char const * descr, bool is_mutable) { - m_imp->register_double_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_percentage_param(char const * param_name, double & value, char const * descr, bool is_mutable) { - m_imp->register_percentage_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_string_param(char const * param_name, std::string & value, char const * descr, bool is_mutable) { - m_imp->register_string_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_param(char const * param_name, symbol & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_list_param(char const * param_name, svector & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_list_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_nat_list_param(char const * param_name, svector & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_nat_list_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_param_vector(param_vector * pv) { - m_imp->register_param_vector(pv); -} - -void ini_params::read_ini_file(std::istream & in) { - ini_parser p(in, m_imp); - p.parse(); -} - -void ini_params::display_params(std::ostream & out) const { - m_imp->display_params(out); -} - -void ini_params::display_parameter_help(char const* param_id, std::ostream & out) const { - m_imp->display_param_help(param_id, out); -} - -void ini_params::display_params_documentation(std::ostream & out) const { - m_imp->display_params_documentation(out); -} - -void ini_params::set_param_value(char const * param_id, char const * param_value) { - m_imp->set_param_value(param_id, param_value); -} -bool ini_params::get_param_value(char const * param_id, std::string& param_value) { - return m_imp->get_param_value(param_id, param_value); -} - -void ini_params::freeze(bool f) { - m_imp->freeze(f); -} - - - diff --git a/src/util/ini_file.h b/src/util/ini_file.h deleted file mode 100644 index cb884b916..000000000 --- a/src/util/ini_file.h +++ /dev/null @@ -1,117 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.h - -Abstract: - - Configuration file support. - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#ifndef _INI_FILE_H_ -#define _INI_FILE_H_ - -#include -#include -#include - -#include"symbol.h" -#include"vector.h" -#include"ref.h" - -#ifdef _EXTERNAL_RELEASE -#define PRIVATE_PARAMS(CODE) ((void) 0) -#else -#define PRIVATE_PARAMS(CODE) { CODE } -#endif - -struct param_vector_imp; -struct ini_params_imp; -class ini_parser; - -typedef std::pair symbol_nat_pair; - -inline std::ostream & operator<<(std::ostream & out, symbol_nat_pair const & p) { - out << p.first << ":" << p.second; - return out; -} - -/** - \brief Support for multiple values for a parameter. The values are used to configure - different cores. -*/ -class param_vector { - unsigned m_ref_count; - param_vector_imp * m_imp; - friend struct ini_params_imp; - friend class ini_parser; -public: - // TODO: onwer is a big hack - param_vector(void * owner); - ~param_vector(); - void inc_ref(); - void dec_ref(); - void copy_params(void * curr_owner, unsigned idx); - unsigned size(void) const; -}; - -class set_get_param_exception { - std::string m_id; - std::string m_msg; -public: - set_get_param_exception(char const * id, char const * msg):m_id(id), m_msg(msg) {} - char const * get_param_id() const { return m_id.c_str(); } - char const * get_msg() const { return m_msg.c_str(); } -}; - -class ini_parser_exception { - unsigned m_pos; - std::string m_msg; -public: - ini_parser_exception(unsigned pos, char const * msg):m_pos(pos), m_msg(msg) {} - unsigned get_pos() const { return m_pos; } - char const * get_msg() const { return m_msg.c_str(); } -}; - -class ini_params { - ini_params_imp * m_imp; -public: - ini_params(bool abort_on_error = true); - ~ini_params(); - void freeze(bool f = true); - void register_bool_param(char const * param_name, bool & value, char const * descr = 0, bool is_mutable = false); - void register_unsigned_param(char const * param_name, unsigned min, unsigned max, unsigned & value, char const * descr = 0, bool is_mutable = false); - void register_unsigned_param(char const * param_name, unsigned & value, char const * descr = 0, bool is_mutable = false) { - register_unsigned_param(param_name, 0, INT_MAX, value, descr, is_mutable); - } - void register_int_param(char const * param_name, int min, int max, int & value, char const * descr = 0, bool is_mutable = false); - void register_int_param(char const * param_name, int & value, char const * descr = 0, bool is_mutable = false) { - register_int_param(param_name, INT_MIN, INT_MAX, value, descr, is_mutable); - } - void register_double_param(char const * param_name, double & value, char const * descr = 0,bool is_mutable = false); - void register_percentage_param(char const * param_name, double & value, char const * descr = 0, bool is_mutable = false); - void register_string_param(char const * param_name, std::string & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_param(char const * param_name, symbol & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_list_param(char const * param_name, svector & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_nat_list_param(char const * param_name, svector & value, char const * descr = 0, bool is_mutable = false); - void register_param_vector(param_vector * pv); - - void read_ini_file(std::istream & in); - void display_params(std::ostream & out) const; - void display_parameter_help(char const* param_id, std::ostream & out) const; - void set_param_value(char const * param_id, char const * param_value); - void set_param_mutable(char const * param_id); - bool get_param_value(char const * param_id, std::string& param_value); - void display_params_documentation(std::ostream & out) const; -}; - -#endif /* _INI_FILE_H_ */ - diff --git a/src/util/instruction_count.cpp b/src/util/instruction_count.cpp deleted file mode 100644 index 6dd5bcb85..000000000 --- a/src/util/instruction_count.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifdef _WINDOWS -#include -#endif -#include "instruction_count.h" - -#ifdef _WINDOWS -typedef BOOL (WINAPI *QTCP)(HANDLE, PULONG64); -static QTCP QTCP_proc; -BOOL WINAPI dummy_qtcp(HANDLE h, PULONG64 u) -{ - *u = 0; - return 0; -} - -inline void check_handler() -{ - if (!QTCP_proc) { - QTCP_proc = (QTCP) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "QueryThreadCycleTime"); - if (!QTCP_proc) - QTCP_proc = &dummy_qtcp; - } -} -#endif - -void instruction_count::start() { - m_count = 0; -#ifdef _WINDOWS - check_handler(); - QTCP_proc(GetCurrentThread(), &m_count); -#endif -} - -double instruction_count::get_num_instructions() { - unsigned long long current = 0; -#ifdef _WINDOWS - check_handler(); - QTCP_proc(GetCurrentThread(), ¤t); -#endif - return static_cast(current - m_count); -} - diff --git a/src/util/instruction_count.h b/src/util/instruction_count.h deleted file mode 100644 index 29fa0c45b..000000000 --- a/src/util/instruction_count.h +++ /dev/null @@ -1,43 +0,0 @@ -/*++ -Copyright (c) 2009 Microsoft Corporation - -Module Name: - - instruction_count.h - -Abstract: - - - -Author: - - Nikolaj Bjorner (nbjorner) 2009-03-04. - -Revision History: - ---*/ -#ifndef _INSTRUCTION_COUNT_H_ -#define _INSTRUCTION_COUNT_H_ - - -/** - \brief Wrapper for an instruction counter. -*/ -class instruction_count { - unsigned long long m_count; -public: - instruction_count() : m_count(0) {} - - ~instruction_count() {} - - void start(); - - double get_num_instructions(); - - bool is_instruction_maxed(double max_instr) { - return max_instr > 0.0 && get_num_instructions() > max_instr; - } -}; - -#endif /* _INSTRUcTION_COUNT_H_ */ - diff --git a/src/util/util.cpp b/src/util/util.cpp index c2795b637..3e5ced813 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -18,7 +18,6 @@ Revision History: --*/ #include"util.h" -#include"ini_file.h" unsigned g_verbosity_level = 0; @@ -30,8 +29,9 @@ unsigned get_verbosity_level() { return g_verbosity_level; } -void register_verbosity_level(ini_params & p) { - p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); +void register_verbosity_level() { + // PARAM-TODO + // p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); } static std::ostream* g_verbose_stream = &std::cerr; diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 4ab54f203..19c0dac90 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -23,7 +23,6 @@ Revision History: #include "util.h" #include "buffer.h" #include "vector.h" -#include "ini_file.h" #ifdef _WINDOWS #define PRF sprintf_s @@ -83,8 +82,9 @@ void set_warning_stream(std::ostream* strm) { g_warning_stream = strm; } -void register_warning(ini_params & p) { - p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); +void register_warning() { + // PARAM-TODO + // p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); } void disable_error_msg_prefix() { From 29cf179364d59e75f15a9a5947c7bbfb7a2f89d2 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 17:03:14 -0800 Subject: [PATCH 070/133] more reorg Signed-off-by: Leonardo de Moura --- src/api/api_solver.cpp | 1 - src/ast/pattern/expr_pattern_match.cpp | 1 - src/ast/pattern/expr_pattern_match.h | 1 - src/cmd_context/cmd_context.cpp | 2 -- src/cmd_context/tactic_cmds.cpp | 1 - src/front_end_params/front_end_params.cpp | 4 ---- src/front_end_params/front_end_params.h | 12 +----------- src/front_end_params/preprocessor_params.h | 6 +++++- src/front_end_params/smt_params.h | 16 +++++++++++++--- src/shell/smtlib_frontend.cpp | 13 +++---------- src/smt/smt_model_generator.cpp | 2 +- src/smt/smt_solver.cpp | 15 +++++---------- src/smt/tactic/smt_tactic.cpp | 17 +++-------------- src/solver/solver.h | 9 --------- src/solver/strategic_solver.cpp | 2 -- src/solver/strategic_solver.h | 2 -- src/solver/tactic2solver.cpp | 2 -- src/solver/tactic2solver.h | 2 -- src/tactic/tactic.h | 1 - src/tactic/tactical.cpp | 13 ------------- 20 files changed, 31 insertions(+), 91 deletions(-) diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index a85e8d83a..31901d360 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -39,7 +39,6 @@ extern "C" { s->m_solver->set_produce_proofs(m.proofs_enabled()); s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); - s->m_solver->set_front_end_params(mk_c(c)->fparams()); s->m_solver->updt_params(s->m_params); s->m_solver->init(m, s->m_logic); s->m_initialized = true; diff --git a/src/ast/pattern/expr_pattern_match.cpp b/src/ast/pattern/expr_pattern_match.cpp index a446ae538..86cad58f8 100644 --- a/src/ast/pattern/expr_pattern_match.cpp +++ b/src/ast/pattern/expr_pattern_match.cpp @@ -36,7 +36,6 @@ Notes: #include"ast_pp.h" #include"cmd_context.h" #include"smt2parser.h" -#include"front_end_params.h" expr_pattern_match::expr_pattern_match(ast_manager & manager): m_manager(manager), m_precompiled(manager) { diff --git a/src/ast/pattern/expr_pattern_match.h b/src/ast/pattern/expr_pattern_match.h index 45295e627..555d6a67e 100644 --- a/src/ast/pattern/expr_pattern_match.h +++ b/src/ast/pattern/expr_pattern_match.h @@ -22,7 +22,6 @@ Notes: #include"ast.h" #include"map.h" -#include"front_end_params.h" class expr_pattern_match { diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 3fd52f9d0..42abd2b2c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1301,7 +1301,6 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions init_manager(); if (m_solver) { m_check_sat_result = m_solver.get(); // solver itself stores the result. - m_solver->set_front_end_params(params()); m_solver->set_progress_callback(this); scoped_watch sw(*this); cancel_eh eh(*m_solver); @@ -1445,7 +1444,6 @@ void cmd_context::validate_model() { void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; - m_solver->set_front_end_params(params()); if (has_manager() && s != 0) { m_solver->set_produce_unsat_cores(m_produce_unsat_cores); m_solver->set_produce_models(params().m_model); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index b911e3634..d44ef196d 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -189,7 +189,6 @@ public: params_ref p = ps(); front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); - tref->set_front_end_params(ctx.params()); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); unsigned timeout = p.get_uint("timeout", UINT_MAX); diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 49c3f042e..0d51d94fb 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -51,10 +51,6 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("debug_ref_count", m_debug_ref_count); }); - // temporary hack until strategic_solver is ported to new tactic framework - PRIVATE_PARAMS({ - p.register_bool_param("nlsat", m_nlsat); - }); } #endif diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index d033ba911..626f51a19 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -20,14 +20,9 @@ Revision History: #define _FRONT_END_PARAMS_H_ #include"ast.h" -#include"preprocessor_params.h" #include"smt_params.h" -#include"arith_simplifier_params.h" -struct front_end_params : public preprocessor_params, public smt_params, - public arith_simplifier_params { - bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. - bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. +struct front_end_params : public smt_params { bool m_well_sorted_check; unsigned m_memory_high_watermark; unsigned m_memory_max_size; @@ -39,13 +34,9 @@ struct front_end_params : public preprocessor_params, public smt_params, std::string m_trace_file_name; std::fstream* m_trace_stream; bool m_display_config; - bool m_nlsat; // temporary hack until strategic_solver is ported to new tactic framework - bool m_dump_goal_as_smt; front_end_params(): - m_at_labels_cex(false), - m_check_at_labels(false), m_well_sorted_check(true), m_memory_high_watermark(0), m_memory_max_size(0), @@ -60,7 +51,6 @@ struct front_end_params : public preprocessor_params, public smt_params, m_trace_file_name("z3.log"), m_trace_stream(NULL), m_display_config(false), - m_nlsat(false), m_dump_goal_as_smt(false) { } diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index b84aebe1a..e4b20b87a 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -22,6 +22,7 @@ Revision History: #include"pattern_inference_params.h" #include"bit_blaster_params.h" #include"bv_simplifier_params.h" +#include"arith_simplifier_params.h" enum lift_ite_kind { LI_NONE, @@ -30,7 +31,9 @@ enum lift_ite_kind { }; struct preprocessor_params : public pattern_inference_params, - public bit_blaster_params, public bv_simplifier_params { + public bit_blaster_params, + public bv_simplifier_params, + public arith_simplifier_params { lift_ite_kind m_lift_ite; lift_ite_kind m_ng_lift_ite; // lift ite for non ground terms bool m_pull_cheap_ite_trees; @@ -81,6 +84,7 @@ public: pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); + arith_simplifier_params::register_params(p); p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 804049315..6e7755458 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -25,6 +25,7 @@ Revision History: #include"theory_array_params.h" #include"theory_bv_params.h" #include"theory_datatype_params.h" +#include"preprocessor_params.h" enum phase_selection { PS_ALWAYS_FALSE, @@ -65,7 +66,12 @@ enum case_split_strategy { CS_RELEVANCY_GOAL, // based on relevancy and the current goal }; -struct smt_params : public dyn_ack_params, public qi_params, public theory_arith_params, public theory_array_params, public theory_bv_params, +struct smt_params : public preprocessor_params, + public dyn_ack_params, + public qi_params, + public theory_arith_params, + public theory_array_params, + public theory_bv_params, public theory_datatype_params { bool m_display_proof; bool m_display_dot_proof; @@ -196,7 +202,9 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_user_theory_preprocess_axioms; bool m_user_theory_persist_axioms; unsigned m_soft_timeout; - + bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. + bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. + smt_params(): m_display_proof(false), m_display_dot_proof(false), @@ -260,7 +268,9 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_preprocess(true), // temporary hack for disabling all preprocessing.. m_user_theory_preprocess_axioms(false), m_user_theory_persist_axioms(false), - m_soft_timeout(0) + m_soft_timeout(0), + m_at_labels_cex(false), + m_check_at_labels(false) { } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 759f5cee2..c95b90098 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -98,16 +98,9 @@ unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_en signal(SIGINT, on_ctrl_c); cmd_context ctx; - // temporary hack until strategic_solver is ported to new tactic framework - if (front_end_params.m_nlsat) { - tactic_factory2solver * s = alloc(tactic_factory2solver); - s->set_tactic(alloc(qfnra_nlsat_fct)); - ctx.set_solver(s); - } - else { - solver * s = mk_smt_strategic_solver(false); - ctx.set_solver(s); - } + solver * s = mk_smt_strategic_solver(false); + ctx.set_solver(s); + install_dl_cmds(ctx); install_dbg_cmds(ctx); install_polynomial_cmds(ctx); diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index d14abc31a..cf22c3e3a 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -48,7 +48,7 @@ namespace smt { void model_generator::init_model() { SASSERT(!m_model); - // PARAM-TODO + // PARAM-TODO smt_params ---> params_ref m_model = alloc(proto_model, m_manager, m_context->get_simplifier()); // , m_context->get_fparams()); ptr_vector::const_iterator it = m_context->begin_theories(); ptr_vector::const_iterator end = m_context->end_theories(); diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 888e1b34c..8807e1e2b 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -24,22 +24,19 @@ Notes: namespace smt { class solver : public solver_na2as { - front_end_params * m_params; + front_end_params m_params; smt::kernel * m_context; progress_callback * m_callback; public: - solver():m_params(0), m_context(0), m_callback(0) {} + solver():m_context(0), m_callback(0) {} virtual ~solver() { if (m_context != 0) dealloc(m_context); } - virtual void set_front_end_params(front_end_params & p) { - m_params = &p; - } - virtual void updt_params(params_ref const & p) { + // PARAM-TODO copy p --> m_params if (m_context == 0) return; m_context->updt_params(p); @@ -49,8 +46,7 @@ namespace smt { if (m_context == 0) { ast_manager m; reg_decl_plugins(m); - front_end_params p; - smt::kernel s(m, p); + smt::kernel s(m, m_params); s.collect_param_descrs(r); } else { @@ -59,11 +55,10 @@ namespace smt { } virtual void init_core(ast_manager & m, symbol const & logic) { - SASSERT(m_params); reset(); #pragma omp critical (solver) { - m_context = alloc(smt::kernel, m, *m_params); + m_context = alloc(smt::kernel, m, m_params); if (m_callback) m_context->set_progress_callback(m_callback); } diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 1551c765c..c75e0d56b 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -24,7 +24,7 @@ Notes: #include"rewriter_types.h" class smt_tactic : public tactic { - scoped_ptr m_params; + front_end_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -52,11 +52,7 @@ public: } front_end_params & fparams() { - if (!m_params) { - m_params = alloc(front_end_params); - params2front_end_params(m_params_ref, fparams()); - } - return *m_params; + return m_params; } void updt_params_core(params_ref const & p) { @@ -68,6 +64,7 @@ public: TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); m_params_ref = p; + // PARAM-TODO update params2front_end_params p ---> m_params params2front_end_params(m_params_ref, fparams()); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } @@ -97,14 +94,6 @@ public: m_stats.reset(); } - // for backward compatibility - virtual void set_front_end_params(front_end_params & p) { - m_params = alloc(front_end_params, p); - SASSERT(m_params.get() == &fparams()); - // must propagate the params_ref to fparams - params2front_end_params(m_params_ref, fparams()); - } - virtual void set_logic(symbol const & l) { m_logic = l; } diff --git a/src/solver/solver.h b/src/solver/solver.h index 6f9887c1a..f26a5c5f4 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -41,15 +41,6 @@ struct front_end_params; class solver : public check_sat_result { public: virtual ~solver() {} - - /** - \brief This method is invoked to allow the solver to access the front_end_params (environment parameters). - - \warning This method is used for backward compatibility. The first solver implemented in Z3 used - front_end_params to store its configuration parameters. - */ - virtual void set_front_end_params(front_end_params & p) {} - /** \brief Update the solver internal settings. */ diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index b6eb98b42..8968f862a 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -191,7 +191,6 @@ void strategic_solver::init_inc_solver() { m_inc_solver->set_produce_proofs(m_produce_proofs); m_inc_solver->set_produce_models(m_produce_models); m_inc_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_inc_solver->set_front_end_params(*m_fparams); m_inc_solver->init(m(), m_logic); unsigned sz = get_num_assertions(); if (m_produce_unsat_cores) { @@ -329,7 +328,6 @@ struct strategic_solver::mk_tactic { params_ref p; front_end_params2params(*s->m_fparams, p); tactic * tct = (*f)(m, p); - tct->set_front_end_params(*s->m_fparams); tct->set_logic(s->m_logic); if (s->m_callback) tct->set_progress_callback(s->m_callback); diff --git a/src/solver/strategic_solver.h b/src/solver/strategic_solver.h index e903e9bd0..7cdda80d5 100644 --- a/src/solver/strategic_solver.h +++ b/src/solver/strategic_solver.h @@ -118,8 +118,6 @@ public: void set_inc_unknown_behavior(inc_unknown_behavior b) { m_inc_unknown_behavior = b; } void force_tactic(bool f) { m_force_tactic = f; } - virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; } - virtual void updt_params(params_ref const & p); virtual void collect_param_descrs(param_descrs & r); diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index 63308bd27..0dd55a26b 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -107,8 +107,6 @@ lbool tactic2solver_core::check_sat_core(unsigned num_assumptions, expr * const return l_undef; tactic & t = *(m_ctx->m_tactic); simple_check_sat_result & result = *(m_ctx->m_result); - if (m_fparams) - t.set_front_end_params(*m_fparams); goal_ref g = alloc(goal, m, m_produce_proofs, m_produce_models, m_produce_unsat_cores); t.set_logic(m_ctx->m_logic); unsigned sz = m_ctx->m_assertions.size(); diff --git a/src/solver/tactic2solver.h b/src/solver/tactic2solver.h index 8cf3551b4..854956d80 100644 --- a/src/solver/tactic2solver.h +++ b/src/solver/tactic2solver.h @@ -54,8 +54,6 @@ public: virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0; - virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; } - virtual void updt_params(params_ref const & p); virtual void collect_param_descrs(param_descrs & r); diff --git a/src/tactic/tactic.h b/src/tactic/tactic.h index cb2c3f515..015b5fe0a 100644 --- a/src/tactic/tactic.h +++ b/src/tactic/tactic.h @@ -92,7 +92,6 @@ public: virtual void reset() { cleanup(); } // for backward compatibility - virtual void set_front_end_params(front_end_params & p) {} virtual void set_logic(symbol const & l) {} virtual void set_progress_callback(progress_callback * callback) {} diff --git a/src/tactic/tactical.cpp b/src/tactic/tactical.cpp index 30e05bd26..0d61f0916 100644 --- a/src/tactic/tactical.cpp +++ b/src/tactic/tactical.cpp @@ -87,11 +87,6 @@ public: m_t2->reset(); } - virtual void set_front_end_params(front_end_params & p) { - m_t1->set_front_end_params(p); - m_t2->set_front_end_params(p); - } - virtual void set_logic(symbol const & l) { m_t1->set_logic(l); m_t2->set_logic(l); @@ -380,13 +375,6 @@ public: (*it)->reset(); } - virtual void set_front_end_params(front_end_params & p) { - ptr_vector::iterator it = m_ts.begin(); - ptr_vector::iterator end = m_ts.end(); - for (; it != end; ++it) - (*it)->set_front_end_params(p); - } - virtual void set_logic(symbol const & l) { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); @@ -992,7 +980,6 @@ public: virtual void cleanup(void) { m_t->cleanup(); } virtual void collect_statistics(statistics & st) const { m_t->collect_statistics(st); } virtual void reset_statistics() { m_t->reset_statistics(); } - virtual void set_front_end_params(front_end_params & p) { m_t->set_front_end_params(p); } virtual void updt_params(params_ref const & p) { m_t->updt_params(p); } virtual void collect_param_descrs(param_descrs & r) { m_t->collect_param_descrs(r); } virtual void reset() { m_t->reset(); } From 92acd6d4ee5d5ac62414e8f012f3e27582f4db6e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:19:02 -0800 Subject: [PATCH 071/133] removed front_end_params from cmd_context Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 14 ++++---- src/cmd_context/basic_cmds.cpp | 21 ++++++------ src/cmd_context/cmd_context.cpp | 60 ++++++++++++++++++++------------- src/cmd_context/cmd_context.h | 6 ++-- src/cmd_context/tactic_cmds.cpp | 3 -- src/muz_qe/dl_cmds.cpp | 4 ++- src/solver/strategic_solver.cpp | 19 +++++------ src/solver/strategic_solver.h | 5 +-- src/solver/tactic2solver.cpp | 3 -- src/solver/tactic2solver.h | 3 +- 10 files changed, 71 insertions(+), 67 deletions(-) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 27120c89d..ac6f44a83 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -25,22 +25,22 @@ def init_project_def(): add_lib('parser_util', ['ast'], 'parsers/util') add_lib('grobner', ['ast'], 'math/grobner') add_lib('euclid', ['util'], 'math/euclid') - # Front-end-params module still contain a lot of parameters for smt solver component. - # This should be fixed - add_lib('front_end_params', ['ast']) - # Simplifier module will be deleted in the future. - # It has been replaced with rewriter module. - add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core') add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic') add_lib('arith_tactics', ['core_tactics', 'sat'], 'tactic/arith') add_lib('nlsat_tactic', ['nlsat', 'sat_tactic', 'arith_tactics'], 'nlsat/tactic') add_lib('subpaving_tactic', ['core_tactics', 'subpaving'], 'math/subpaving/tactic') add_lib('aig_tactic', ['tactic'], 'tactic/aig') - add_lib('solver', ['model', 'tactic', 'front_end_params']) + add_lib('solver', ['model', 'tactic']) add_lib('cmd_context', ['solver', 'rewriter']) add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds') add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2') + # Front-end-params module still contain a lot of parameters for smt solver component. + # This should be fixed + add_lib('front_end_params', ['ast']) + # Simplifier module will be deleted in the future. + # It has been replaced with rewriter module. + add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern') add_lib('macros', ['simplifier', 'front_end_params'], 'ast/macros') add_lib('proof_checker', ['rewriter', 'front_end_params'], 'ast/proof_checker') diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 43507ed3f..d3861257b 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -27,7 +27,6 @@ Notes: #include"cmd_util.h" #include"simplify_cmd.h" #include"eval_cmd.h" -#include"front_end_params.h" #include"gparams.h" #include"model_params.hpp" @@ -159,7 +158,7 @@ public: }; ATOMIC_CMD(get_proof_cmd, "get-proof", "retrieve proof", { - if (ctx.params().m_proof_mode == PGM_DISABLED) + if (!ctx.produce_proofs()) throw cmd_exception("proof construction is not enabled, use command (set-option :produce-proofs true)"); if (!ctx.has_manager() || ctx.cs_state() != cmd_context::css_unsat) @@ -253,7 +252,7 @@ protected: } public: - set_get_option_cmd(char const * name, front_end_params & params): + set_get_option_cmd(char const * name): cmd(name), m_true("true"), m_false("false"), @@ -375,8 +374,8 @@ class set_option_cmd : public set_get_option_cmd { } public: - set_option_cmd(front_end_params & params): - set_get_option_cmd("set-option", params), + set_option_cmd(): + set_get_option_cmd("set-option"), m_unsupported(false) { } @@ -454,8 +453,8 @@ class get_option_cmd : public set_get_option_cmd { } public: - get_option_cmd(front_end_params & params): - set_get_option_cmd("get-option", params) { + get_option_cmd(): + set_get_option_cmd("get-option") { } virtual char const * get_usage() const { return ""; } virtual char const * get_descr(cmd_context & ctx) const { return "get configuration option."; } @@ -476,13 +475,13 @@ public: print_bool(ctx, ctx.interactive_mode()); } else if (opt == m_produce_proofs) { - print_bool(ctx, ctx.params().m_proof_mode != PGM_DISABLED); + print_bool(ctx, ctx.produce_proofs()); } else if (opt == m_produce_unsat_cores) { print_bool(ctx, ctx.produce_unsat_cores()); } else if (opt == m_produce_models) { - print_bool(ctx, ctx.params().m_model); + print_bool(ctx, ctx.produce_models()); } else if (opt == m_produce_assignments) { print_bool(ctx, ctx.produce_assignments()); @@ -711,8 +710,8 @@ void install_basic_cmds(cmd_context & ctx) { ctx.insert(alloc(get_assertions_cmd)); ctx.insert(alloc(get_proof_cmd)); ctx.insert(alloc(get_unsat_core_cmd)); - ctx.insert(alloc(set_option_cmd, ctx.params())); - ctx.insert(alloc(get_option_cmd, ctx.params())); + ctx.insert(alloc(set_option_cmd)); + ctx.insert(alloc(get_option_cmd)); ctx.insert(alloc(get_info_cmd)); ctx.insert(alloc(set_info_cmd)); ctx.insert(alloc(builtin_cmd, "assert", "", "assert term.")); diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 42abd2b2c..7a06f30bf 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -16,7 +16,6 @@ Notes: --*/ #include -#include"front_end_params.h" #include"tptr.h" #include"cmd_context.h" #include"func_decl_dependencies.h" @@ -318,7 +317,6 @@ public: cmd_context::cmd_context(bool main_ctx, ast_manager * m, symbol const & l): m_main_ctx(main_ctx), - m_fparams(alloc(front_end_params)), m_logic(l), m_interactive_mode(false), m_global_decls(false), // :global-decls is false by default. @@ -358,11 +356,11 @@ cmd_context::~cmd_context() { finalize_probes(); m_solver = 0; m_check_sat_result = 0; - dealloc(m_fparams); } void cmd_context::set_produce_models(bool f) { - params().m_model = f; + // PARAM-TODO + // params().m_model = f; if (m_solver) m_solver->set_produce_models(f); } @@ -374,19 +372,35 @@ void cmd_context::set_produce_unsat_cores(bool f) { } void cmd_context::set_produce_proofs(bool f) { + // PARAM-TODO // can only be set before initialization SASSERT(!has_manager()); - params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; + // params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; } bool cmd_context::produce_models() const { - return params().m_model; + // PARAM-TODO + // return params().m_model; + return true; } bool cmd_context::produce_proofs() const { - return params().m_proof_mode != PGM_DISABLED; + // PARAM-TODO + // return params().m_proof_mode != PGM_DISABLED; + return false; } +bool cmd_context::well_sorted_check_enabled() const { + // PARAM-TODO + return true; +} + +bool cmd_context::validate_model_enabled() const { + // PARAM-TODO + return false; +} + + cmd_context::check_sat_state cmd_context::cs_state() const { if (m_check_sat_result.get() == 0) return css_clear; @@ -579,9 +593,9 @@ void cmd_context::init_manager_core(bool new_manager) { insert(pm().mk_plist_decl()); } if (m_solver) { - m_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_solver->set_produce_models(params().m_model); - m_solver->set_produce_proofs(params().m_proof_mode == PGM_FINE); + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); m_solver->init(m(), m_logic); } m_check_logic.set_logic(m(), m_logic); @@ -591,7 +605,7 @@ void cmd_context::init_manager() { SASSERT(m_manager == 0); SASSERT(m_pmanager == 0); m_check_sat_result = 0; - m_manager = alloc(ast_manager, params().m_proof_mode, params().m_trace_stream); + m_manager = alloc(ast_manager, produce_proofs() ? PGM_FINE : PGM_DISABLED); // PARAM-TODO , params().m_trace_stream); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); // PARAM-TODO @@ -855,7 +869,7 @@ object_ref * cmd_context::find_object_ref(symbol const & s) const { return r; } -#define CHECK_SORT(T) if (params().m_well_sorted_check) m().check_sorts_core(T) +#define CHECK_SORT(T) if (well_sorted_check_enabled()) m().check_sorts_core(T) void cmd_context::mk_const(symbol const & s, expr_ref & result) const { mk_app(s, 0, 0, 0, 0, 0, result); @@ -895,13 +909,13 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg return; } SASSERT(num_args > 0); - TRACE("macro_bug", tout << "m_well_sorted_check: " << params().m_well_sorted_check << "\n"; + TRACE("macro_bug", tout << "well_sorted_check_enabled(): " << well_sorted_check_enabled() << "\n"; tout << "s: " << s << "\n"; tout << "body:\n" << mk_ismt2_pp(_m.second, m()) << "\n"; tout << "args:\n"; for (unsigned i = 0; i < num_args; i++) tout << mk_ismt2_pp(args[i], m()) << "\n" << mk_pp(m().get_sort(args[i]), m()) << "\n";); var_subst subst(m()); subst(_m.second, num_args, args, result); - if (params().m_well_sorted_check && !is_well_sorted(m(), result)) + if (well_sorted_check_enabled() && !is_well_sorted(m(), result)) throw cmd_exception("invalid macro application, sort mismatch ", s); return; } @@ -930,7 +944,7 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg func_decl * f = fs.find(m(), num_args, args, range); if (f == 0) throw cmd_exception("unknown constant ", s); - if (params().m_well_sorted_check) + if (well_sorted_check_enabled()) m().check_sort(f, num_args, args); result = m().mk_app(f, num_args, args); return; @@ -1151,7 +1165,7 @@ void cmd_context::assert_expr(expr * t) { m_check_sat_result = 0; m().inc_ref(t); m_assertions.push_back(t); - if (m_produce_unsat_cores) + if (produce_unsat_cores()) m_assertion_names.push_back(0); if (m_solver) m_solver->assert_expr(t); @@ -1160,7 +1174,7 @@ void cmd_context::assert_expr(expr * t) { void cmd_context::assert_expr(symbol const & name, expr * t) { if (!m_check_logic(t)) throw cmd_exception(m_check_logic.get_last_error()); - if (!m_produce_unsat_cores || name == symbol::null) { + if (!produce_unsat_cores() || name == symbol::null) { assert_expr(t); return; } @@ -1266,7 +1280,7 @@ void cmd_context::restore_assertions(unsigned old_sz) { SASSERT(old_sz <= m_assertions.size()); SASSERT(!m_interactive_mode || m_assertions.size() == m_assertion_strings.size()); restore(m(), m_assertions, old_sz); - if (m_produce_unsat_cores) + if (produce_unsat_cores()) restore(m(), m_assertion_names, old_sz); if (m_interactive_mode) m_assertion_strings.shrink(old_sz); @@ -1398,7 +1412,7 @@ struct contains_array_op_proc { \brief Check if the current model satisfies the quantifier free formulas. */ void cmd_context::validate_model() { - if (!params().m_model_validate) + if (!validate_model_enabled()) return; if (!is_model_available()) return; @@ -1445,9 +1459,9 @@ void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; if (has_manager() && s != 0) { - m_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_solver->set_produce_models(params().m_model); - m_solver->set_produce_proofs(params().m_proof_mode == PGM_FINE); + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); m_solver->init(m(), m_logic); // assert formulas and create scopes in the new solver. unsigned lim = 0; @@ -1502,7 +1516,7 @@ void cmd_context::display_assertions() { } bool cmd_context::is_model_available() const { - if (params().m_model && + if (produce_models() && has_manager() && (cs_state() == css_sat || cs_state() == css_unknown)) { model_ref md; diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 1b15c0b60..c2acba0dc 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -42,8 +42,6 @@ Notes: */ std::string smt2_keyword_to_param(symbol const & k); -struct front_end_params; - class func_decls { func_decl * m_decls; public: @@ -138,7 +136,6 @@ public: protected: bool m_main_ctx; - front_end_params * m_fparams; symbol m_logic; bool m_interactive_mode; bool m_global_decls; @@ -274,6 +271,8 @@ public: bool produce_models() const; bool produce_proofs() const; bool produce_unsat_cores() const { return m_produce_unsat_cores; } + bool well_sorted_check_enabled() const; + bool validate_model_enabled() const; void set_produce_models(bool flag); void set_produce_unsat_cores(bool flag); void set_produce_proofs(bool flag); @@ -288,7 +287,6 @@ public: virtual ast_manager & get_ast_manager() { return m(); } pdecl_manager & pm() const { if (!m_pmanager) const_cast(this)->init_manager(); return *m_pmanager; } sexpr_manager & sm() const { if (!m_sexpr_manager) const_cast(this)->m_sexpr_manager = alloc(sexpr_manager); return *m_sexpr_manager; } - front_end_params & params() const { return *m_fparams; } void set_solver(solver * s); solver * get_solver() const { return m_solver.get(); } diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index d44ef196d..ba1193b20 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -24,7 +24,6 @@ Notes: #include"scoped_ctrl_c.h" #include"cancel_eh.h" #include"model_smt2_pp.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" #include"tactic.h" #include"tactical.h" @@ -187,7 +186,6 @@ public: virtual void execute(cmd_context & ctx) { params_ref p = ps(); - front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); @@ -298,7 +296,6 @@ public: virtual void execute(cmd_context & ctx) { params_ref p = ps(); - front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); { tactic & t = *(tref.get()); diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index d89b8d80d..deb4dc7ec 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -33,6 +33,8 @@ Notes: class dl_context { + // PARAM-TODO temp HACK: added m_params field because cmd_context does not have front_end_params anymore + front_end_params m_params; cmd_context & m_cmd; dl_collected_cmds* m_collected_cmds; unsigned m_ref_count; @@ -62,7 +64,7 @@ public: void init() { ast_manager& m = m_cmd.m(); if (!m_context) { - m_context = alloc(datalog::context, m, m_cmd.params()); + m_context = alloc(datalog::context, m, m_params); } if (!m_decl_plugin) { symbol name("datalog_relation"); diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index 8968f862a..8ce098c51 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -18,8 +18,6 @@ Notes: --*/ #include"strategic_solver.h" #include"scoped_timer.h" -#include"front_end_params.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" // minimum verbosity level for portfolio verbose messages @@ -33,7 +31,6 @@ strategic_solver::ctx::ctx(ast_manager & m): strategic_solver::strategic_solver(): m_manager(0), - m_fparams(0), m_force_tactic(false), m_inc_mode(false), m_check_sat_executed(false), @@ -50,6 +47,7 @@ strategic_solver::strategic_solver(): m_produce_proofs = false; m_produce_models = false; m_produce_unsat_cores = false; + m_auto_config = true; } strategic_solver::~strategic_solver() { @@ -99,11 +97,12 @@ void strategic_solver::set_inc_solver(solver * s) { void strategic_solver::updt_params(params_ref const & p) { if (m_inc_solver) m_inc_solver->updt_params(p); - if (m_fparams) - params2front_end_params(p, *m_fparams); + m_params = p; + m_auto_config = p.get_bool("auto_config", true); + // PARAM-TODO + // PROOFS, MODELS, UNSATCORES } - void strategic_solver::collect_param_descrs(param_descrs & r) { if (m_inc_solver) m_inc_solver->collect_param_descrs(r); @@ -323,10 +322,8 @@ struct aux_timeout_eh : public event_handler { struct strategic_solver::mk_tactic { strategic_solver * m_solver; - mk_tactic(strategic_solver * s, tactic_factory * f):m_solver(s) { + mk_tactic(strategic_solver * s, tactic_factory * f, params_ref const & p):m_solver(s) { ast_manager & m = s->m(); - params_ref p; - front_end_params2params(*s->m_fparams, p); tactic * tct = (*f)(m, p); tct->set_logic(s->m_logic); if (s->m_callback) @@ -374,7 +371,7 @@ lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assum reset_results(); m_check_sat_executed = true; if (num_assumptions > 0 || // assumptions were provided - (!m_fparams->m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off + (!m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off ) { // must use incremental solver return check_sat_with_assumptions(num_assumptions, assumptions); @@ -438,7 +435,7 @@ lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assum TRACE("strategic_solver", tout << "using goal...\n"; g->display_with_dependencies(tout);); - mk_tactic tct_maker(this, factory); + mk_tactic tct_maker(this, factory, m_params); SASSERT(m_curr_tactic); proof_ref pr(m()); diff --git a/src/solver/strategic_solver.h b/src/solver/strategic_solver.h index 7cdda80d5..1883a88cd 100644 --- a/src/solver/strategic_solver.h +++ b/src/solver/strategic_solver.h @@ -23,7 +23,6 @@ Notes: #include"tactic.h" class progress_callback; -struct front_end_params; /** \brief Implementation of the solver API that supports: @@ -57,7 +56,7 @@ public: private: ast_manager * m_manager; - front_end_params * m_fparams; + params_ref m_params; symbol m_logic; bool m_force_tactic; // use tactics even when auto_config = false bool m_inc_mode; @@ -93,6 +92,8 @@ private: bool m_produce_models; bool m_produce_unsat_cores; + bool m_auto_config; + progress_callback * m_callback; void reset_results(); diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index 0dd55a26b..e630f9c78 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -20,7 +20,6 @@ Notes: --*/ #include"tactic2solver.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" tactic2solver_core::ctx::ctx(ast_manager & m, symbol const & logic): @@ -94,8 +93,6 @@ lbool tactic2solver_core::check_sat_core(unsigned num_assumptions, expr * const SASSERT(m_ctx); ast_manager & m = m_ctx->m(); params_ref p = m_params; - if (m_fparams) - front_end_params2params(*m_fparams, p); #pragma omp critical (tactic2solver_core) { m_ctx->m_tactic = get_tactic(m, p); diff --git a/src/solver/tactic2solver.h b/src/solver/tactic2solver.h index 854956d80..0a057b04b 100644 --- a/src/solver/tactic2solver.h +++ b/src/solver/tactic2solver.h @@ -43,13 +43,12 @@ class tactic2solver_core : public solver_na2as { ast_manager & m() const { return m_assertions.m(); } }; scoped_ptr m_ctx; - front_end_params * m_fparams; params_ref m_params; bool m_produce_models; bool m_produce_proofs; bool m_produce_unsat_cores; public: - tactic2solver_core():m_ctx(0), m_fparams(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {} + tactic2solver_core():m_ctx(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {} virtual ~tactic2solver_core(); virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0; From 29ec68284b554cb6bc507322d7e8b3a3ef0976e6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:34:53 -0800 Subject: [PATCH 072/133] Added better error message when old parameter name is used Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 1 - src/api/api_context.h | 1 - src/front_end_params/front_end_params.h | 4 --- src/util/gparams.cpp | 38 +++++++++++++++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index ba8d2ae64..11fb28a02 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -90,7 +90,6 @@ namespace api { context::context(config_params * p, bool user_ref_count): m_params(p ? p->m_params : front_end_params()), - m_param_ini(m_params), m_user_ref_count(user_ref_count), m_manager(m_params.m_proof_mode, m_params.m_trace_stream), m_plugins(m_manager), diff --git a/src/api/api_context.h b/src/api/api_context.h index 3da506b54..76c601d60 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -53,7 +53,6 @@ namespace api { struct add_plugins { add_plugins(ast_manager & m); }; front_end_params m_params; - param_ini m_param_ini; bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters. ast_manager m_manager; add_plugins m_plugins; diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 626f51a19..c3fa9fa95 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -41,11 +41,7 @@ struct front_end_params : public smt_params { m_memory_high_watermark(0), m_memory_max_size(0), m_proof_mode(PGM_DISABLED), -#if defined(SMTCOMP) || defined(_EXTERNAL_RELEASE) m_auto_config(true), -#else - m_auto_config(false), -#endif m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 426789bb4..e7b2a52eb 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -21,6 +21,19 @@ Notes: extern void gparams_register_modules(); +char const * g_old_params_names[] = { + "arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", 0 }; + +bool is_old_param_name(symbol const & name) { + char const * const * it = g_old_params_names; + while (*it) { + if (name == *it) + return true; + it++; + } + return false; +} + struct gparams::imp { dictionary m_module_param_descrs; param_descrs m_param_descrs; @@ -120,14 +133,26 @@ public: } } + void throw_unknown_parameter(symbol const & param_name, symbol const & mod_name) { + if (mod_name == symbol::null) { + if (is_old_param_name(param_name)) { + throw exception("unknown parameter '%s', this is an old parameter name, invoke 'z3 -ps' to obtain the new parameter list", + param_name.bare_str()); + } + else { + throw exception("unknown parameter '%s'", param_name.bare_str()); + } + } + else { + throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + } + void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) { param_kind k = d.get_kind(param_name); params_ref & ps = get_params(mod_name); if (k == CPK_INVALID) { - if (mod_name == symbol::null) - throw exception("unknown parameter '%s'", param_name.bare_str()); - else - throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw_unknown_parameter(param_name, mod_name); } else if (k == CPK_UINT) { long val = strtol(value, 0, 10); @@ -200,10 +225,7 @@ public: std::string get_default(param_descrs const & d, symbol const & p, symbol const & m) { if (!d.contains(p)) { - if (m == symbol::null) - throw exception("unknown parameter '%s'", p.bare_str()); - else - throw exception("unknown parameter '%s' at module '%s'", p.bare_str(), m.bare_str()); + throw_unknown_parameter(p, m); } char const * r = d.get_default(p); if (r == 0) From 9bd4fd969ac859c4bcfb48727d96a37359950596 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:50:26 -0800 Subject: [PATCH 073/133] cleanning Signed-off-by: Leonardo de Moura --- src/front_end_params/front_end_params.cpp | 1 - src/front_end_params/front_end_params.h | 6 +----- src/front_end_params/smt_params.h | 6 +++--- src/shell/dimacs_frontend.cpp | 8 +++----- src/shell/dimacs_frontend.h | 2 +- src/shell/main.cpp | 20 ++------------------ 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 0d51d94fb..32692180f 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -36,7 +36,6 @@ void front_end_params::register_params(ini_params & p) { p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); - p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index c3fa9fa95..2c7dbfa2e 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -33,8 +33,6 @@ struct front_end_params : public smt_params { bool m_trace; std::string m_trace_file_name; std::fstream* m_trace_stream; - bool m_display_config; - bool m_dump_goal_as_smt; front_end_params(): m_well_sorted_check(true), @@ -45,9 +43,7 @@ struct front_end_params : public smt_params { m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), - m_trace_stream(NULL), - m_display_config(false), - m_dump_goal_as_smt(false) { + m_trace_stream(NULL) { } void open_trace_file(); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 6e7755458..24479de16 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -204,6 +204,7 @@ struct smt_params : public preprocessor_params, unsigned m_soft_timeout; bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. + bool m_dump_goal_as_smt; smt_params(): m_display_proof(false), @@ -270,9 +271,8 @@ struct smt_params : public preprocessor_params, m_user_theory_persist_axioms(false), m_soft_timeout(0), m_at_labels_cex(false), - m_check_at_labels(false) - { - + m_check_at_labels(false), + m_dump_goal_as_smt(false) { } }; diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index 2dbb0adf8..0acd222dd 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -22,7 +22,6 @@ Revision History: #include"timeout.h" #include"dimacs.h" #include"sat_solver.h" -#include"front_end_params.h" extern bool g_display_statistics; static sat::solver * g_solver = 0; @@ -64,12 +63,12 @@ static void display_model(sat::solver const & s) { std::cout << "\n"; } -unsigned read_dimacs(char const * file_name, front_end_params & front_end_params) { +unsigned read_dimacs(char const * file_name) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref p; - p.set_bool("produce_models", front_end_params.m_model); + p.set_bool("produce_models", true); sat::solver solver(p, 0); g_solver = &solver; @@ -90,8 +89,7 @@ unsigned read_dimacs(char const * file_name, front_end_params & front_end_params switch (r) { case l_true: std::cout << "sat\n"; - if (front_end_params.m_model) - display_model(solver); + display_model(solver); break; case l_undef: std::cout << "unknown\n"; diff --git a/src/shell/dimacs_frontend.h b/src/shell/dimacs_frontend.h index 22ab63529..9521c8256 100644 --- a/src/shell/dimacs_frontend.h +++ b/src/shell/dimacs_frontend.h @@ -19,7 +19,7 @@ Revision History: #ifndef _DIMACS_FRONTEND_H_ #define _DIMACS_FRONTEND_H_ -unsigned read_dimacs(char const * benchmark_file, front_end_params & front_end_params); +unsigned read_dimacs(char const * benchmark_file); #endif /* _DATALOG_FRONTEND_H_ */ diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 5434206cc..b08d02812 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -77,7 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "ps display all available parameters.\n"; + std::cout << " " << OPT << "ps display Z3 global (and module) parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -87,8 +87,6 @@ void display_usage() { // std::cout << "\nOutput:\n"; std::cout << " " << OPT << "st display statistics.\n"; - std::cout << "\nSearch heuristics:\n"; - std::cout << " " << OPT << "rs:num random seed.\n"; #if defined(Z3DEBUG) || defined(_TRACE) std::cout << "\nDebugging support:\n"; #endif @@ -226,20 +224,6 @@ void parse_cmd_line_args(int argc, char ** argv) { } g_front_end_params->m_relevancy_lvl = strtol(opt_arg, 0, 10); } - else if (strcmp(opt_name, "rd") == 0) { - if (!opt_arg) { - error("optional argument (/rd:num) is missing."); - } - g_front_end_params->m_random_var_freq = static_cast(strtol(opt_arg, 0, 10)) / 100.0; - } - else if (strcmp(opt_name, "rs") == 0) { - if (!opt_arg) { - error("optional argument (/rs:num) is missing."); - } - long seed = strtol(opt_arg, 0, 10); - g_front_end_params->m_random_seed = seed; - g_front_end_params->m_arith_random_seed = seed; - } else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) error("option argument (/T:timeout) is missing."); @@ -382,7 +366,7 @@ int main(int argc, char ** argv) { return_value = read_smtlib2_commands(g_input_file, *g_front_end_params); break; case IN_DIMACS: - return_value = read_dimacs(g_input_file, *g_front_end_params); + return_value = read_dimacs(g_input_file); break; case IN_DATALOG: read_datalog(g_input_file, *g_extra_params, *g_front_end_params); From 02e763bb6bbd5796670eba9603490f16a9164673 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 20:56:40 -0800 Subject: [PATCH 074/133] env params Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 2 +- src/api/api_config_params.cpp | 2 ++ src/cmd_context/cmd_context.cpp | 2 +- src/shell/main.cpp | 16 ++--------- src/smt/asserted_formulas.cpp | 49 ++++++++++++++++----------------- src/smt/smt_context.cpp | 45 +++++++++++++++--------------- src/smt/smt_quantifier.cpp | 2 +- src/smt/smt_setup.cpp | 4 +-- src/util/env_params.cpp | 36 ++++++++++++++++++++++++ src/util/env_params.h | 32 +++++++++++++++++++++ src/util/gparams.cpp | 6 ++++ src/util/timeit.cpp | 6 ++-- src/util/util.cpp | 5 ---- src/util/util.h | 2 -- src/util/warning.h | 4 --- 15 files changed, 133 insertions(+), 80 deletions(-) create mode 100644 src/util/env_params.cpp create mode 100644 src/util/env_params.h diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 1df3c082e..277a7e702 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1784,7 +1784,7 @@ def mk_gparams_register_modules(cnames, path): mod_cmds.append((m.group(1), m.group(2))) fout.write('void gparams_register_modules() {\n') for code in cmds: - fout.write('{ param_descrs d; %s(*d); gparams::register_global(d); }\n' % code) + fout.write('{ param_descrs d; %s(d); gparams::register_global(d); }\n' % code) for (mod, code) in mod_cmds: fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) fout.write('}\n') diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 6adcced44..c14e68919 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -24,6 +24,7 @@ Revision History: #include"cmd_context.h" #include"symbol.h" #include"gparams.h" +#include"env_params.h" namespace api { @@ -41,6 +42,7 @@ extern "C" { LOG_Z3_global_param_set(param_id, param_value); try { gparams::set(param_id, param_value); + env_params::updt_params(); } catch (z3_exception & ex) { // The error handler is only available for contexts diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 7a06f30bf..984a535c7 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1309,7 +1309,7 @@ void cmd_context::pop(unsigned n) { void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions) { if (m_ignore_check) return; - IF_VERBOSE(100, verbose_stream() << "check-sat..." << std::endl;); + IF_VERBOSE(100, verbose_stream() << "(started \"check-sat\")" << std::endl;); TRACE("before_check_sat", dump_assertions(tout);); if (!has_manager()) init_manager(); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index b08d02812..90473c21f 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -33,6 +33,7 @@ Revision History: #include"z3_exception.h" #include"error_codes.h" #include"gparams.h" +#include"env_params.h" typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_Z3_LOG } input_kind; @@ -106,12 +107,6 @@ public: } virtual ~extra_params() {} - - // PARAM-TODO - // virtual void register_params(ini_params & p) { - // datalog_params::register_params(p); - // p.register_bool_param("STATISTICS", m_statistics, "display statistics"); - // } }; extra_params* g_extra_params = 0; @@ -123,8 +118,6 @@ void init_params() { g_front_end_params = new front_end_params(); // g_params = new ini_params(); g_extra_params = new extra_params(); - // register_verbosity_level(*g_params); - // register_warning(*g_params); // g_front_end_params->register_params(*g_params); // g_extra_params->register_params(*g_params); g_params_initialized = true; @@ -304,9 +297,6 @@ class global_state_initialiser { public: global_state_initialiser() { memory::initialize(0); -#if defined(_WINDOWS) && defined(_Z3_BUILD_PARALLEL_SMT) - memory::mem->set_threaded_mode(true); -#endif init_params(); } @@ -326,8 +316,8 @@ int main(int argc, char ** argv) { global_state_initialiser global_state; memory::exit_when_out_of_memory(true, "ERROR: out of memory"); parse_cmd_line_args(argc, argv); - memory::set_high_watermark(static_cast(g_front_end_params->m_memory_high_watermark) * 1024 * 1024); - memory::set_max_size(static_cast(g_front_end_params->m_memory_max_size) * 1024 * 1024); + env_params::updt_params(); + g_front_end_params->open_trace_file(); if (g_input_file && g_standard_input) { error("using standard input to read formula."); diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index c548eca94..513aa7634 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -248,7 +248,6 @@ void asserted_formulas::reduce() { if (m_macro_manager.has_macros()) expand_macros(); TRACE("before_reduce", display(tout);); - IF_VERBOSE(10000, verbose_stream() << "total size: " << get_total_size() << "\n";); CASSERT("well_sorted", check_well_sorted()); #define INVOKE(COND, FUNC) if (COND) { FUNC; IF_VERBOSE(10000, verbose_stream() << "total size: " << get_total_size() << "\n";); } TRACE("reduce_step_ll", ast_mark visited; display_ll(tout, visited);); TRACE("reduce_step", display(tout << #FUNC << " ");); CASSERT("well_sorted",check_well_sorted()); if (inconsistent() || canceled()) { TRACE("after_reduce", display(tout);); TRACE("after_reduce_ll", ast_mark visited; display_ll(tout, visited);); return; } @@ -280,7 +279,7 @@ void asserted_formulas::reduce() { CASSERT("well_sorted",check_well_sorted()); - IF_VERBOSE(10, verbose_stream() << "simplifier done.\n";); + IF_VERBOSE(10, verbose_stream() << "(smt.simplifier-done)\n";); TRACE("after_reduce", display(tout);); TRACE("after_reduce_ll", ast_mark visited; display_ll(tout, visited);); TRACE("macros", m_macro_manager.display(tout);); @@ -288,7 +287,7 @@ void asserted_formulas::reduce() { } void asserted_formulas::eliminate_and() { - IF_IVERBOSE(10, verbose_stream() << "eliminating and...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.eliminating-and)\n";); set_eliminate_and(true); reduce_asserted_formulas(); TRACE("after_elim_and", display(tout);); @@ -393,19 +392,19 @@ void asserted_formulas::find_macros_core() { } void asserted_formulas::find_macros() { - IF_IVERBOSE(10, verbose_stream() << "trying to find macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.find-macros)\n";); TRACE("before_find_macros", display(tout);); find_macros_core(); TRACE("after_find_macros", display(tout);); } void asserted_formulas::expand_macros() { - IF_IVERBOSE(10, verbose_stream() << "expanding macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.expand-macros)\n";); find_macros_core(); } void asserted_formulas::apply_quasi_macros() { - IF_IVERBOSE(10, verbose_stream() << "finding quasi macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.find-quasi-macros)\n";); TRACE("before_quasi_macros", display(tout);); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); @@ -423,7 +422,7 @@ void asserted_formulas::apply_quasi_macros() { } void asserted_formulas::nnf_cnf() { - IF_IVERBOSE(10, verbose_stream() << "applying nnf...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.nnf)\n";); nnf apply_nnf(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); @@ -471,7 +470,7 @@ void asserted_formulas::nnf_cnf() { #define MK_SIMPLE_SIMPLIFIER(NAME, FUNCTOR_DEF, LABEL, MSG) \ void asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG << "...\n";); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE(LABEL, tout << "before:\n"; display(tout);); \ FUNCTOR_DEF; \ expr_ref_vector new_exprs(m_manager); \ @@ -503,16 +502,16 @@ void asserted_formulas::NAME() { TRACE(LABEL, display(tout);); \ } -MK_SIMPLE_SIMPLIFIER(apply_distribute_forall, distribute_forall functor(m_manager, *m_bsimp), "distribute_forall", "distribute forall"); +MK_SIMPLE_SIMPLIFIER(apply_distribute_forall, distribute_forall functor(m_manager, *m_bsimp), "distribute_forall", "distribute-forall"); void asserted_formulas::reduce_and_solve() { - IF_IVERBOSE(10, verbose_stream() << "reducing...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.reducing)\n";); flush_cache(); // collect garbage reduce_asserted_formulas(); } void asserted_formulas::infer_patterns() { - IF_IVERBOSE(10, verbose_stream() << "pattern inference...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.pattern-inference)\n";); TRACE("before_pattern_inference", display(tout);); pattern_inference infer(m_manager, m_params); expr_ref_vector new_exprs(m_manager); @@ -546,7 +545,7 @@ void asserted_formulas::commit() { } void asserted_formulas::eliminate_term_ite() { - IF_IVERBOSE(10, verbose_stream() << "eliminating ite term...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.eliminating-ite-term)\n";); TRACE("before_elim_term_ite", display(tout);); elim_term_ite elim(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); @@ -583,7 +582,7 @@ void asserted_formulas::eliminate_term_ite() { } void asserted_formulas::propagate_values() { - IF_IVERBOSE(10, verbose_stream() << "constant propagation...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.constant-propagation)\n";); TRACE("propagate_values", tout << "before:\n"; display(tout);); flush_cache(); bool found = false; @@ -661,7 +660,7 @@ void asserted_formulas::propagate_booleans() { flush_cache(); while (cont) { TRACE("propagate_booleans", tout << "before:\n"; display(tout);); - IF_IVERBOSE(10, verbose_stream() << "boolean propagation...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.propagate-booleans)\n";); cont = false; unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); @@ -704,7 +703,7 @@ void asserted_formulas::propagate_booleans() { #define MK_SIMPLIFIER(NAME, FUNCTOR, TAG, MSG, REDUCE) \ bool asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG << "...\n";); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE(TAG, ast_mark visited; display_ll(tout, visited);); \ FUNCTOR; \ bool changed = false; \ @@ -741,9 +740,9 @@ bool asserted_formulas::NAME() { \ return changed; \ } -MK_SIMPLIFIER(pull_cheap_ite_trees, pull_cheap_ite_tree_star functor(m_manager, m_simplifier), "pull_cheap_ite_trees", "pull cheap ite trees", false); +MK_SIMPLIFIER(pull_cheap_ite_trees, pull_cheap_ite_tree_star functor(m_manager, m_simplifier), "pull_cheap_ite_trees", "pull-cheap-ite-trees", false); -MK_SIMPLIFIER(pull_nested_quantifiers, pull_nested_quant functor(m_manager), "pull_nested_quantifiers", "pull nested quantifiers", false); +MK_SIMPLIFIER(pull_nested_quantifiers, pull_nested_quant functor(m_manager), "pull_nested_quantifiers", "pull-nested-quantifiers", false); proof * asserted_formulas::get_inconsistency_proof() const { if (!inconsistent()) @@ -761,7 +760,7 @@ proof * asserted_formulas::get_inconsistency_proof() const { } void asserted_formulas::refine_inj_axiom() { - IF_IVERBOSE(10, verbose_stream() << "refining injectivity...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.refine-injectivity)\n";); TRACE("inj_axiom", display(tout);); unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); @@ -783,9 +782,9 @@ void asserted_formulas::refine_inj_axiom() { TRACE("inj_axiom", display(tout);); } -MK_SIMPLIFIER(apply_bit2int, bit2int& functor = m_bit2int, "bit2int", "propagate bit-vector over integers", true); +MK_SIMPLIFIER(apply_bit2int, bit2int& functor = m_bit2int, "bit2int", "propagate-bit-vector-over-integers", true); -MK_SIMPLIFIER(cheap_quant_fourier_motzkin, elim_bounds_star functor(m_manager), "elim_bounds", "cheap fourier-motzkin", true); +MK_SIMPLIFIER(cheap_quant_fourier_motzkin, elim_bounds_star functor(m_manager), "elim_bounds", "cheap-fourier-motzkin", true); // MK_SIMPLIFIER(quant_elim, qe::expr_quant_elim_star1 &functor = m_quant_elim, // "quantifiers", "quantifier elimination procedures", true); @@ -795,11 +794,11 @@ bool asserted_formulas::quant_elim() { return false; } -MK_SIMPLIFIER(elim_bvs_from_quantifiers, bv_elim_star functor(m_manager), "bv_elim", "eliminate bit-vectors from quantifiers", true); +MK_SIMPLIFIER(elim_bvs_from_quantifiers, bv_elim_star functor(m_manager), "bv_elim", "eliminate-bit-vectors-from-quantifiers", true); #define LIFT_ITE(NAME, FUNCTOR, MSG) \ void asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG;); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE("lift_ite", display(tout);); \ FUNCTOR; \ unsigned i = m_asserted_qhead; \ @@ -822,8 +821,8 @@ void asserted_formulas::NAME() { reduce_and_solve(); \ } -LIFT_ITE(lift_ite, push_app_ite functor(m_simplifier, m_params.m_lift_ite == LI_CONSERVATIVE), "lifting ite...\n"); -LIFT_ITE(ng_lift_ite, ng_push_app_ite functor(m_simplifier, m_params.m_ng_lift_ite == LI_CONSERVATIVE), "lifting ng ite...\n"); +LIFT_ITE(lift_ite, push_app_ite functor(m_simplifier, m_params.m_lift_ite == LI_CONSERVATIVE), "lifting ite"); +LIFT_ITE(ng_lift_ite, ng_push_app_ite functor(m_simplifier, m_params.m_ng_lift_ite == LI_CONSERVATIVE), "lifting ng ite"); unsigned asserted_formulas::get_total_size() const { expr_mark visited; @@ -835,7 +834,7 @@ unsigned asserted_formulas::get_total_size() const { } void asserted_formulas::max_bv_sharing() { - IF_IVERBOSE(10, verbose_stream() << "maximizing bv sharing...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.maximizing-bv-sharing)\n";); TRACE("bv_sharing", display(tout);); unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index c51a1ebc1..1aae1c62a 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -2488,7 +2488,7 @@ namespace smt { SASSERT(check_clauses(m_lemmas)); SASSERT(check_clauses(m_aux_clauses)); - IF_VERBOSE(2, verbose_stream() << "simplifying clause set... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.simplifying-clause-set"; verbose_stream().flush();); // m_simp_counter is used to balance the cost of simplify_clause. // @@ -2503,8 +2503,7 @@ namespace smt { // the field m_simp_qhead is used to check whether there are // new assigned literals at the base level. m_simp_qhead = m_assigned_literals.size(); - - unsigned num_clauses = m_aux_clauses.size() + m_lemmas.size(); + unsigned num_del_clauses = 0; SASSERT(m_scope_lvl == m_base_lvl); @@ -2519,7 +2518,7 @@ namespace smt { num_del_clauses += simplify_clauses(m_lemmas, bs.m_lemmas_lim); } TRACE("simp_counter", tout << "simp_counter: " << m_simp_counter << " scope_lvl: " << m_scope_lvl << "\n";); - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_clauses << " (out of " << num_clauses << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_clauses << ")" << std::endl;); TRACE("simplify_clauses_detail", tout << "after:\n"; display_clauses(tout, m_lemmas);); SASSERT(check_clauses(m_lemmas) && check_clauses(m_aux_clauses)); } @@ -2551,7 +2550,7 @@ namespace smt { SASSERT(start_at <= sz); if (start_at + m_fparams.m_recent_lemmas_size >= sz) return; - IF_VERBOSE(2, verbose_stream() << "deleting inactive lemmas... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.delete-inactive-lemmas"; verbose_stream().flush();); SASSERT (m_fparams.m_recent_lemmas_size < sz); unsigned end_at = sz - m_fparams.m_recent_lemmas_size; SASSERT(start_at < end_at); @@ -2595,7 +2594,7 @@ namespace smt { cls->set_activity(cls->get_activity() / m_fparams.m_clause_decay); } } - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_cls << " (out of " << sz << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_cls << ")" << std::endl;); } /** @@ -2606,7 +2605,7 @@ namespace smt { depends on which group the clauses is in. */ void context::del_inactive_lemmas2() { - IF_VERBOSE(2, verbose_stream() << "deleting inactive clauses... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.delete-inactive-clauses "; verbose_stream().flush();); unsigned sz = m_lemmas.size(); unsigned start_at = m_base_lvl == 0 ? 0 : m_base_scopes[m_base_lvl - 1].m_lemmas_lim; SASSERT(start_at <= sz); @@ -2645,7 +2644,7 @@ namespace smt { } SASSERT(j <= sz); m_lemmas.shrink(j); - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_cls << " (out of " << sz << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_cls << ")" << std::endl;); } /** @@ -2786,7 +2785,7 @@ namespace smt { } void context::assert_expr(expr * e, proof * pr) { - timeit tt(get_verbosity_level() >= 100, "simplifying"); + timeit tt(get_verbosity_level() >= 100, "smt.simplifying"); assert_expr_core(e, pr); } @@ -2800,7 +2799,7 @@ namespace smt { void context::internalize_assertions() { TRACE("internalize_assertions", tout << "internalize_assertions()...\n";); - timeit tt(get_verbosity_level() >= 100, "preprocessing"); + timeit tt(get_verbosity_level() >= 100, "smt.preprocessing"); reduce_assertions(); if (!m_asserted_formulas.inconsistent()) { unsigned sz = m_asserted_formulas.get_num_formulas(); @@ -3158,7 +3157,7 @@ namespace smt { exit(1); } #endif - timeit tt(get_verbosity_level() >= 100, "searching"); + timeit tt(get_verbosity_level() >= 100, "smt.stats"); scoped_mk_model smk(*this); SASSERT(at_search_level()); TRACE("search", display(tout); display_enodes_lbls(tout);); @@ -3166,7 +3165,7 @@ namespace smt { init_search(); flet l(m_searching, true); TRACE("after_init_search", display(tout);); - IF_VERBOSE(2, verbose_stream() << "searching...\n";); + IF_VERBOSE(2, verbose_stream() << "(smt.searching)\n";); TRACE("search_lite", tout << "searching...\n";); lbool status = l_undef; unsigned curr_lvl = m_scope_lvl; @@ -3215,16 +3214,16 @@ namespace smt { inc_limits(); if (force_restart || !m_fparams.m_restart_adaptive || m_agility < m_fparams.m_restart_agility_threshold) { SASSERT(!inconsistent()); - IF_VERBOSE(1, verbose_stream() << "restarting... propagations: " << m_stats.m_num_propagations - << ", decisions: " << m_stats.m_num_decisions - << ", conflicts: " << m_stats.m_num_conflicts << ", restart: " << m_restart_threshold; + IF_VERBOSE(1, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations + << " :decisions " << m_stats.m_num_decisions + << " :conflicts " << m_stats.m_num_conflicts << " :restart " << m_restart_threshold; if (m_fparams.m_restart_strategy == RS_IN_OUT_GEOMETRIC) { - verbose_stream() << ", restart-outer: " << m_restart_outer_threshold; + verbose_stream() << " :restart-outer " << m_restart_outer_threshold; } if (m_fparams.m_restart_adaptive) { - verbose_stream() << ", agility: " << m_agility; + verbose_stream() << " :agility " << m_agility; } - verbose_stream() << std::endl; verbose_stream().flush();); + verbose_stream() << ")" << std::endl; verbose_stream().flush();); // execute the restart m_stats.m_num_restarts++; if (m_scope_lvl > curr_lvl) { @@ -3259,12 +3258,12 @@ namespace smt { void context::tick(unsigned & counter) const { counter++; if (counter > m_fparams.m_tick) { - IF_VERBOSE(3, verbose_stream() << "working..."; - verbose_stream() << " num. conflicts: " << m_num_conflicts; + IF_VERBOSE(3, verbose_stream() << "(smt.working"; + verbose_stream() << " :conflicts " << m_num_conflicts; // verbose_stream() << " lemma avg. activity: " << get_lemma_avg_activity(); if (m_fparams.m_restart_adaptive) - verbose_stream() << " agility: " << m_agility; - verbose_stream() << std::endl; verbose_stream().flush();); + verbose_stream() << " :agility " << m_agility; + verbose_stream() << ")" << std::endl; verbose_stream().flush();); TRACE("assigned_literals_per_lvl", display_num_assigned_literals_per_lvl(tout); tout << "\n";); counter = 0; } @@ -3410,7 +3409,7 @@ namespace smt { final_check_status ok; if (m_final_check_idx < num_th) { theory * th = m_theory_set[m_final_check_idx]; - IF_VERBOSE(100, verbose_stream() << "final check '" << th->get_name() << "' ...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.final-check \"" << th->get_name() << "\")\n";); ok = th->final_check_eh(); TRACE("final_check_step", tout << "final check '" << th->get_name() << " ok: " << ok << " inconsistent " << inconsistent() << "\n";); if (ok == FC_GIVEUP) { diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index c11f226ed..e6d81d3d2 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -211,7 +211,7 @@ namespace smt { final_check_status final_check_eh(bool full) { if (full) { - IF_VERBOSE(100, verbose_stream() << "final check 'quantifiers'...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.final-check \"quantifiers\")\n";); final_check_status result = m_qi_queue.final_check_eh() ? FC_DONE : FC_CONTINUE; final_check_status presult = m_plugin->final_check_eh(full); if (presult != FC_DONE) diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index 67c94808e..ac080ccaa 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -118,7 +118,7 @@ namespace smt { void setup::setup_auto_config() { static_features st(m_manager); - IF_VERBOSE(100, verbose_stream() << "configuring...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.configuring)\n";); TRACE("setup", tout << "setup, logic: " << m_logic << "\n";); // HACK: do not collect features for QF_BV and QF_AUFBV... since they do not use them... if (m_logic == "QF_BV") { @@ -128,7 +128,7 @@ namespace smt { setup_QF_AUFBV(); } else { - IF_VERBOSE(100, verbose_stream() << "collecting features...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.collecting-features)\n";); st.collect(m_context.get_num_asserted_formulas(), m_context.get_asserted_formulas()); IF_VERBOSE(1000, st.display_primitive(verbose_stream());); if (m_logic == "QF_UF") diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp new file mode 100644 index 000000000..cf1d31b85 --- /dev/null +++ b/src/util/env_params.cpp @@ -0,0 +1,36 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + env_params.cpp + +Abstract: + + Goodies for updating environment parameters. + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#include"env_params.h" +#include"params.h" +#include"gparams.h" +#include"util.h" +#include"memory_manager.h" + +void env_params::updt_params() { + params_ref p = gparams::get(); + set_verbosity_level(p.get_uint("verbose", 0)); + enable_warning_messages(p.get_bool("warning", true)); + memory::set_max_size(p.get_uint("memory_max_size", 0)); +} + +void env_params::collect_param_descrs(param_descrs & d) { + d.insert("verbose", CPK_UINT, "be verbose, where the value is the verbosity level", "0"); + d.insert("warning", CPK_BOOL, "enable/disable warning messages", "true"); + d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no bound.", "0"); +} diff --git a/src/util/env_params.h b/src/util/env_params.h new file mode 100644 index 000000000..8b5fa7005 --- /dev/null +++ b/src/util/env_params.h @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + env_params.h + +Abstract: + + Goodies for updating environment parameters. + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#ifndef _ENV_PARAMS_H_ +#define _ENV_PARAMS_H_ + +class param_descrs; + +struct env_params { + static void updt_params(); + static void collect_param_descrs(param_descrs & p); + /* + REG_PARAMS('env_params::collect_param_descrs') + */ +}; + +#endif diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index e7b2a52eb..29377eb8d 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -18,6 +18,7 @@ Notes: --*/ #include"gparams.h" #include"dictionary.h" +#include"trace.h" extern void gparams_register_modules(); @@ -291,6 +292,7 @@ public: params_ref get() { params_ref result; + TRACE("gparams", tout << "get() m_params: " << m_params << "\n";); #pragma omp critical (gparams) { result = m_params; @@ -303,6 +305,7 @@ public: gparams::imp * gparams::g_imp = 0; void gparams::set(char const * name, char const * value) { + TRACE("gparams", tout << "setting [" << name << "] <- '" << value << "'\n";); SASSERT(g_imp != 0); g_imp->set(name, value); } @@ -342,6 +345,7 @@ params_ref gparams::get_module(symbol const & module_name) { } params_ref gparams::get() { + TRACE("gparams", tout << "gparams::get()\n";); SASSERT(g_imp != 0); return g_imp->get(); } @@ -352,11 +356,13 @@ void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) { } void gparams::init() { + TRACE("gparams", tout << "gparams::init()\n";); g_imp = alloc(imp); gparams_register_modules(); } void gparams::finalize() { + TRACE("gparams", tout << "gparams::finalize()\n";); if (g_imp != 0) { dealloc(g_imp); g_imp = 0; diff --git a/src/util/timeit.cpp b/src/util/timeit.cpp index 975dd3127..5246beced 100644 --- a/src/util/timeit.cpp +++ b/src/util/timeit.cpp @@ -38,9 +38,9 @@ struct timeit::imp { ~imp() { m_watch.stop(); double end_memory = static_cast(memory::get_allocation_size())/static_cast(1024*1024); - m_out << m_msg << ", time: " << std::fixed << std::setprecision(2) << m_watch.get_seconds() - << " secs, memory: (before " << std::fixed << std::setprecision(2) << m_start_memory - << ", after " << std::fixed << std::setprecision(2) << end_memory << ")" + m_out << "(" << m_msg << " :time " << std::fixed << std::setprecision(2) << m_watch.get_seconds() + << " :before-memory " << std::fixed << std::setprecision(2) << m_start_memory + << " :after-memory " << std::fixed << std::setprecision(2) << end_memory << ")" << std::endl; } }; diff --git a/src/util/util.cpp b/src/util/util.cpp index 3e5ced813..eb9acb385 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -29,11 +29,6 @@ unsigned get_verbosity_level() { return g_verbosity_level; } -void register_verbosity_level() { - // PARAM-TODO - // p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); -} - static std::ostream* g_verbose_stream = &std::cerr; void set_verbose_stream(std::ostream& str) { diff --git a/src/util/util.h b/src/util/util.h index 5e51d8ef1..945d259f9 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -157,8 +157,6 @@ struct delete_proc { void set_verbosity_level(unsigned lvl); unsigned get_verbosity_level(); -class ini_params; -void register_verbosity_level(ini_params & p); std::ostream& verbose_stream(); void set_verbose_stream(std::ostream& str); diff --git a/src/util/warning.h b/src/util/warning.h index 6800c1f95..a556bfb60 100644 --- a/src/util/warning.h +++ b/src/util/warning.h @@ -21,8 +21,6 @@ Revision History: #include #include -class ini_params; - void send_warnings_to_stdout(bool flag); void enable_warning_messages(bool flag); @@ -33,8 +31,6 @@ void set_warning_stream(std::ostream* strm); void warning_msg(const char * msg, ...); -void register_warning(ini_params & p); - void disable_error_msg_prefix(); void format2ostream(std::ostream& out, char const* fmt, va_list args); From f15de18c4a6041d8f752f0606f2c30f903a00db7 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 22:53:55 -0800 Subject: [PATCH 075/133] context params Signed-off-by: Leonardo de Moura --- src/cmd_context/basic_cmds.cpp | 3 + src/cmd_context/cmd_context.cpp | 49 +++++----- src/cmd_context/cmd_context.h | 7 +- src/cmd_context/context_params.cpp | 114 ++++++++++++++++++++++ src/cmd_context/context_params.h | 52 ++++++++++ src/front_end_params/front_end_params.cpp | 5 - src/shell/datalog_frontend.h | 1 - src/shell/main.cpp | 3 - src/solver/strategic_solver.cpp | 2 - src/util/env_params.cpp | 2 +- src/util/gparams.cpp | 4 +- 11 files changed, 204 insertions(+), 38 deletions(-) create mode 100644 src/cmd_context/context_params.cpp create mode 100644 src/cmd_context/context_params.h diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index d3861257b..df9efc4dd 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -29,6 +29,7 @@ Notes: #include"eval_cmd.h" #include"gparams.h" #include"model_params.hpp" +#include"env_params.h" class help_cmd : public cmd { svector m_cmds; @@ -305,6 +306,8 @@ class set_option_cmd : public set_get_option_cmd { void set_param(cmd_context & ctx, char const * value) { try { gparams::set(m_option, value); + env_params::updt_params(); + ctx.params().updt_params(); } catch (gparams::exception ex) { throw cmd_exception(ex.msg()); diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 984a535c7..1a018a41d 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -359,48 +359,43 @@ cmd_context::~cmd_context() { } void cmd_context::set_produce_models(bool f) { - // PARAM-TODO - // params().m_model = f; if (m_solver) m_solver->set_produce_models(f); + m_params.m_model = f; } void cmd_context::set_produce_unsat_cores(bool f) { // can only be set before initialization SASSERT(!has_manager()); - m_produce_unsat_cores = f; + m_params.m_unsat_core = f; } void cmd_context::set_produce_proofs(bool f) { - // PARAM-TODO // can only be set before initialization SASSERT(!has_manager()); - // params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; + m_params.m_proof = f; } bool cmd_context::produce_models() const { - // PARAM-TODO - // return params().m_model; - return true; + return m_params.m_model; } bool cmd_context::produce_proofs() const { - // PARAM-TODO - // return params().m_proof_mode != PGM_DISABLED; - return false; + return m_params.m_proof; +} + +bool cmd_context::produce_unsat_cores() const { + return m_params.m_unsat_core; } bool cmd_context::well_sorted_check_enabled() const { - // PARAM-TODO - return true; + return m_params.m_well_sorted_check; } bool cmd_context::validate_model_enabled() const { - // PARAM-TODO - return false; + return m_params.m_validate_model; } - cmd_context::check_sat_state cmd_context::cs_state() const { if (m_check_sat_result.get() == 0) return css_clear; @@ -593,10 +588,7 @@ void cmd_context::init_manager_core(bool new_manager) { insert(pm().mk_plist_decl()); } if (m_solver) { - m_solver->set_produce_unsat_cores(produce_unsat_cores()); - m_solver->set_produce_models(produce_models()); - m_solver->set_produce_proofs(produce_proofs()); - m_solver->init(m(), m_logic); + init_solver_options(m_solver.get()); } m_check_logic.set_logic(m(), m_logic); } @@ -1455,14 +1447,23 @@ void cmd_context::validate_model() { } } +void cmd_context::init_solver_options(solver * s) { + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); + m_solver->init(m(), m_logic); + if (!m_params.m_auto_config) { + params_ref p; + p.set_bool("auto_config", false); + m_solver->updt_params(p); + } +} + void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; if (has_manager() && s != 0) { - m_solver->set_produce_unsat_cores(produce_unsat_cores()); - m_solver->set_produce_models(produce_models()); - m_solver->set_produce_proofs(produce_proofs()); - m_solver->init(m(), m_logic); + init_solver_options(s); // assert formulas and create scopes in the new solver. unsigned lim = 0; svector::iterator it = m_scopes.begin(); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index c2acba0dc..ae517b0c2 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -36,6 +36,7 @@ Notes: #include"check_logic.h" #include"progress_callback.h" #include"scoped_ptr_vector.h" +#include"context_params.h" /** \brief Auxiliary function for converting SMT2 keywords into Z3 internal parameter names. @@ -135,6 +136,7 @@ public: }; protected: + context_params m_params; bool m_main_ctx; symbol m_logic; bool m_interactive_mode; @@ -246,9 +248,12 @@ protected: void print_unsupported_msg() { regular_stream() << "unsupported" << std::endl; } void print_unsupported_info(symbol const& s) { if (s != symbol::null) diagnostic_stream() << "; " << s << std::endl;} + void init_solver_options(solver * s); + public: cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); ~cmd_context(); + context_params & params() { return m_params; } void set_logic(symbol const & s); bool has_logic() const { return m_logic != symbol::null; } symbol const & get_logic() const { return m_logic; } @@ -270,7 +275,7 @@ public: void set_random_seed(unsigned s) { m_random_seed = s; } bool produce_models() const; bool produce_proofs() const; - bool produce_unsat_cores() const { return m_produce_unsat_cores; } + bool produce_unsat_cores() const; bool well_sorted_check_enabled() const; bool validate_model_enabled() const; void set_produce_models(bool flag); diff --git a/src/cmd_context/context_params.cpp b/src/cmd_context/context_params.cpp new file mode 100644 index 000000000..c7efa0d8d --- /dev/null +++ b/src/cmd_context/context_params.cpp @@ -0,0 +1,114 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + context_params.cpp + +Abstract: + + Goodies for managing context parameters in the cmd_context and + api_context + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#include"context_params.h" +#include"gparams.h" +#include"params.h" + +context_params::context_params() { + updt_params(); +} + +void context_params::set_bool(bool & opt, char const * param, char const * value) { + if (strcmp(value, "true") == 0) { + opt = true; + } + else if (strcmp(value, "false") == 0) { + opt = false; + } + else { + throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param); + } +} + +void context_params::set(char const * param, char const * value) { + std::string p = param; + unsigned n = p.size(); + for (unsigned i = 0; i < n; i++) { + if (p[i] >= 'A' && p[i] <= 'Z') + p[i] = p[i] - 'A' + 'a'; + else if (p[i] == '-') + p[i] = '_'; + } + if (p == "timeout") { + long val = strtol(value, 0, 10); + m_timeout = static_cast(val); + } + else if (p == "type_check" || p == "well_sorted_check") { + set_bool(m_well_sorted_check, param, value); + } + else if (p == "auto_config") { + set_bool(m_auto_config, param, value); + } + else if (p == "proof") { + set_bool(m_proof, param, value); + } + else if (p == "model") { + set_bool(m_model, param, value); + } + else if (p == "validate_model") { + set_bool(m_validate_model, param, value); + } + else if (p == "trace") { + set_bool(m_trace, param, value); + } + else if (p == "trace_file_name") { + m_trace_file_name = value; + } + else if (p == "unsat_core") { + set_bool(m_unsat_core, param, value); + } + else if (p == "debug_ref_count") { + set_bool(m_debug_ref_count, param, value); + } + else { + throw default_exception("unknown parameter '%s'", p.c_str()); + } +} + +void context_params::updt_params() { + updt_params(gparams::get()); +} + +void context_params::updt_params(params_ref const & p) { + m_timeout = p.get_uint("timeout", UINT_MAX); + m_well_sorted_check = p.get_bool("type_check", p.get_bool("well_sorted_check", true)); + m_auto_config = p.get_bool("auto_config", true); + m_proof = p.get_bool("proof", false); + m_model = p.get_bool("model", true); + m_validate_model = p.get_bool("validate_model", false); + m_trace = p.get_bool("trace", false); + m_trace_file_name = p.get_str("trace_file_name", "z3.log"); + m_unsat_core = p.get_bool("unsat_core", false); + m_debug_ref_count = p.get_bool("debug_ref_count", false); +} + +void context_params::collect_param_descrs(param_descrs & d) { + d.insert("timeout", CPK_UINT, "default timeout (in milliseconds) used for solvers", "4294967295"); + d.insert("well_sorted_check", CPK_BOOL, "type checker", "true"); + d.insert("type_check", CPK_BOOL, "type checker (alias for well_sorted_check)", "true"); + d.insert("auto_config", CPK_BOOL, "use heuristics to automatically select solver and configure it", "true"); + d.insert("proof", CPK_BOOL, "proof generation, it must be enabled when the Z3 context is created", "false"); + d.insert("model", CPK_BOOL, "model generation for solvers, this parameter can be overwritten when creating a solver", "true"); + d.insert("validate_model", CPK_BOOL, "validate models produced by solvers", "false"); + d.insert("trace", CPK_BOOL, "trace generation for VCC", "false"); + d.insert("trace_file_name", CPK_STRING, "trace out file name (see option 'trace')", "z3.log"); + d.insert("unsat_core", CPK_BOOL, "unsat-core generation for solvers, this parameter can be overwritten when creating a solver, not every solver in Z3 supports unsat core generation", "false"); + d.insert("debug_ref_count", CPK_BOOL, "debug support for AST reference counting", "false"); +} diff --git a/src/cmd_context/context_params.h b/src/cmd_context/context_params.h new file mode 100644 index 000000000..556c3bd3f --- /dev/null +++ b/src/cmd_context/context_params.h @@ -0,0 +1,52 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + context_params.h + +Abstract: + + Goodies for managing context parameters in the cmd_context and + api_context + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#ifndef _CONTEXT_PARAMS_H_ +#define _CONTEXT_PARAMS_H_ + +#include"params.h" + +class context_params { + void set_bool(bool & opt, char const * param, char const * value); + +public: + bool m_auto_config; + bool m_proof; + bool m_debug_ref_count; + bool m_trace; + std::string m_trace_file_name; + bool m_well_sorted_check; + bool m_model; + bool m_validate_model; + bool m_unsat_core; + unsigned m_timeout; + bool m_statistics; + + context_params(); + void set(char const * param, char const * value); + void updt_params(); + void updt_params(params_ref const & p); + static void collect_param_descrs(param_descrs & d); + /* + REG_PARAMS('context_params::collect_param_descrs') + */ +}; + + +#endif diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 32692180f..f00c21d56 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -32,10 +32,6 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); - p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); - p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); - p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. @@ -47,7 +43,6 @@ void front_end_params::register_params(ini_params & p) { PRIVATE_PARAMS({ - p.register_bool_param("debug_ref_count", m_debug_ref_count); }); } diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index 7e08fce0e..bf4194ef4 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -23,7 +23,6 @@ struct datalog_params { symbol m_default_table; bool m_default_table_checked; datalog_params(); - // virtual void register_params(ini_params& p); }; unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 90473c21f..9cef54628 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -116,10 +116,7 @@ void init_params() { if (!g_params_initialized) { z3_bound_num_procs(); g_front_end_params = new front_end_params(); - // g_params = new ini_params(); g_extra_params = new extra_params(); - // g_front_end_params->register_params(*g_params); - // g_extra_params->register_params(*g_params); g_params_initialized = true; } } diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index 8ce098c51..40d77066e 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -99,8 +99,6 @@ void strategic_solver::updt_params(params_ref const & p) { m_inc_solver->updt_params(p); m_params = p; m_auto_config = p.get_bool("auto_config", true); - // PARAM-TODO - // PROOFS, MODELS, UNSATCORES } void strategic_solver::collect_param_descrs(param_descrs & r) { diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp index cf1d31b85..a76c2308b 100644 --- a/src/util/env_params.cpp +++ b/src/util/env_params.cpp @@ -24,7 +24,7 @@ Notes: void env_params::updt_params() { params_ref p = gparams::get(); - set_verbosity_level(p.get_uint("verbose", 0)); + set_verbosity_level(p.get_uint("verbose", get_verbosity_level())); enable_warning_messages(p.get_bool("warning", true)); memory::set_max_size(p.get_uint("memory_max_size", 0)); } diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 29377eb8d..85b648a55 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -86,7 +86,9 @@ public: void display(std::ostream & out, unsigned indent, bool smt2_style) { #pragma omp critical (gparams) { - m_param_descrs.display(out, indent, smt2_style); + out << "Global parameters\n"; + m_param_descrs.display(out, indent + 4, smt2_style); + out << "\n"; dictionary::iterator it = m_module_param_descrs.begin(); dictionary::iterator end = m_module_param_descrs.end(); for (; it != end; ++it) { From 1c15e078a40c3b47016959cde4998c02366ec35d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 23:00:06 -0800 Subject: [PATCH 076/133] cleanup Signed-off-by: Leonardo de Moura --- src/util/warning.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 19c0dac90..0a1ac9bbc 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -82,11 +82,6 @@ void set_warning_stream(std::ostream* strm) { g_warning_stream = strm; } -void register_warning() { - // PARAM-TODO - // p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); -} - void disable_error_msg_prefix() { g_show_error_msg_prefix = false; } From 80405dbd627b7fb14c15343301359c238dd7cbba Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 08:12:15 -0800 Subject: [PATCH 077/133] added context_params to API Signed-off-by: Leonardo de Moura --- src/api/api_ast.cpp | 2 +- src/api/api_config_params.cpp | 35 +++++++++++++++++++---------------- src/api/api_config_params.h | 34 ---------------------------------- src/api/api_context.cpp | 35 +++++++++-------------------------- src/api/api_context.h | 32 ++++++++++++++++---------------- src/api/api_datalog.cpp | 4 ++-- src/api/api_solver.cpp | 17 ++++++++++++----- src/api/z3_api.h | 15 ++++++++++----- 8 files changed, 69 insertions(+), 105 deletions(-) delete mode 100644 src/api/api_config_params.h diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 45892bac3..c604927fd 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -675,7 +675,7 @@ extern "C" { ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); params_ref p = to_param_ref(_p); - unsigned timeout = p.get_uint("timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", mk_c(c)->get_timeout()); bool use_ctrl_c = p.get_bool("ctrl_c", false); th_rewriter m_rw(m, p); expr_ref result(m); diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index c14e68919..908900043 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -17,7 +17,6 @@ Revision History: --*/ #include"z3.h" #include"api_context.h" -#include"api_config_params.h" #include"pp.h" #include"api_log_macros.h" #include"api_util.h" @@ -25,16 +24,7 @@ Revision History: #include"symbol.h" #include"gparams.h" #include"env_params.h" - -namespace api { - - config_params::config_params() { - } - - config_params::config_params(front_end_params const & p):m_params(p) { - } - -}; +#include"context_params.h" extern "C" { void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) { @@ -68,7 +58,7 @@ extern "C" { // The error handler is only available for contexts // Just throw a warning. std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.msg(); + buffer << "Error setting " << param_id << ": " << ex.msg(); warning_msg(buffer.str().c_str()); return Z3_FALSE; } @@ -77,28 +67,41 @@ extern "C" { Z3_config Z3_API Z3_mk_config() { memory::initialize(UINT_MAX); LOG_Z3_mk_config(); - Z3_config r = reinterpret_cast(alloc(api::config_params)); + Z3_config r = reinterpret_cast(alloc(context_params)); RETURN_Z3(r); } void Z3_API Z3_del_config(Z3_config c) { LOG_Z3_del_config(c); - dealloc((reinterpret_cast(c))); + dealloc((reinterpret_cast(c))); } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { LOG_Z3_set_param_value(c, param_id, param_value); - // PARAM-TODO save the parameter + try { + context_params * p = reinterpret_cast(c); + p->set(param_id, param_value); + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ": " << ex.msg(); + warning_msg(buffer.str().c_str()); + } } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { + Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - // NOOP in the current version + mk_c(c)->params().set(param_id, param_value); + Z3_CATCH; } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); + // TODO return Z3_FALSE; } diff --git a/src/api/api_config_params.h b/src/api/api_config_params.h deleted file mode 100644 index 99ded289d..000000000 --- a/src/api/api_config_params.h +++ /dev/null @@ -1,34 +0,0 @@ -/*++ -Copyright (c) 2012 Microsoft Corporation - -Module Name: - - api_config_params.h - -Abstract: - Configuration parameters - -Author: - - Leonardo de Moura (leonardo) 2012-02-29. - -Revision History: - ---*/ -#ifndef _API_CONFIG_PARAMS_H_ -#define _API_CONFIG_PARAMS_H_ - -#include"front_end_params.h" - -namespace api { - - class config_params { - public: - front_end_params m_params; - config_params(); - config_params(front_end_params const & p); - }; - -}; - -#endif diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 11fb28a02..02069e06d 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -18,7 +18,6 @@ Revision History: --*/ #include"api_context.h" -#include"api_config_params.h" #include"smtparser.h" #include"version.h" #include"ast_pp.h" @@ -54,14 +53,6 @@ namespace api { return static_cast(f); } - context::param_ini::param_ini(front_end_params & p) : m_params(p) { - p.open_trace_file(); - } - - context::param_ini::~param_ini() { - m_params.close_trace_file(); - } - context::add_plugins::add_plugins(ast_manager & m) { reg_decl_plugins(m); } @@ -88,10 +79,10 @@ namespace api { } } - context::context(config_params * p, bool user_ref_count): - m_params(p ? p->m_params : front_end_params()), + context::context(context_params * p, bool user_ref_count): + m_params(*p), m_user_ref_count(user_ref_count), - m_manager(m_params.m_proof_mode, m_params.m_trace_stream), + m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED), // PARAM-TODO , _fparams.m_proof_mode, m_fparams.m_trace_stream), m_plugins(m_manager), m_arith_util(m_manager), m_bv_util(m_manager), @@ -114,8 +105,6 @@ namespace api { // // Configuration parameter settings. // - memory::set_high_watermark(static_cast(m_params.m_memory_high_watermark)*1024*1024); - memory::set_max_size(static_cast(m_params.m_memory_max_size)*1024*1024); if (m_params.m_debug_ref_count) { m_manager.debug_ref_count(); } @@ -334,7 +323,8 @@ namespace api { smt::kernel & context::get_smt_kernel() { if (!m_solver) { - m_solver = alloc(smt::kernel, m_manager, m_params); + // PARAM-TODO: copy config_params -> fparams + m_solver = alloc(smt::kernel, m_manager, m_fparams); } return *m_solver; } @@ -419,15 +409,15 @@ extern "C" { Z3_context Z3_API Z3_mk_context(Z3_config c) { LOG_Z3_mk_context(c); - memory::initialize(0); - Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), false)); + memory::initialize(UINT_MAX); + Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), false)); RETURN_Z3(r); } Z3_context Z3_API Z3_mk_context_rc(Z3_config c) { LOG_Z3_mk_context_rc(c); - memory::initialize(0); - Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), true)); + memory::initialize(UINT_MAX); + Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), true)); RETURN_Z3(r); } @@ -573,11 +563,4 @@ ast_manager & Z3_API Z3_get_manager(__in Z3_context c) { return mk_c(c)->m(); } -front_end_params& Z3_API Z3_get_parameters(__in Z3_context c) { - return mk_c(c)->fparams(); -} -Z3_context Z3_mk_context_from_params(front_end_params const& p) { - api::config_params cp(p); - return reinterpret_cast(alloc(api::context, &cp)); -} diff --git a/src/api/api_context.h b/src/api/api_context.h index 76c601d60..df0f488af 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -31,28 +31,19 @@ Revision History: #include"front_end_params.h" #include"event_handler.h" #include"tactic_manager.h" +#include"context_params.h" namespace smtlib { class parser; }; namespace api { - class config_params; - Z3_search_failure mk_Z3_search_failure(smt::failure f); class context : public tactic_manager { - class param_ini { - front_end_params & m_params; - public: - param_ini(front_end_params & p); - ~param_ini(); - }; - struct add_plugins { add_plugins(ast_manager & m); }; - - front_end_params m_params; + context_params m_params; bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters. ast_manager m_manager; add_plugins m_plugins; @@ -61,8 +52,11 @@ namespace api { bv_util m_bv_util; datalog::dl_decl_util m_datalog_util; + // Support for old solver API + front_end_params m_fparams; smt::kernel * m_solver; // General purpose solver for backward compatibility - + // ------------------------------- + ast_ref_vector m_last_result; //!< used when m_user_ref_count == true ast_ref_vector m_ast_trail; //!< used when m_user_ref_count == false unsigned_vector m_ast_lim; @@ -102,11 +96,16 @@ namespace api { // // ------------------------ - context(config_params * p, bool user_ref_count = false); + context(context_params * p, bool user_ref_count = false); ~context(); - - front_end_params & fparams() { return m_params; } ast_manager & m() { return m_manager; } + + context_params & params() { return m_params; } + bool produce_proofs() const { return m_manager.proofs_enabled(); } + bool produce_models() const { return m_params.m_model; } + bool produce_unsat_cores() const { return m_params.m_unsat_core; } + bool use_auto_config() const { return m_params.m_auto_config; } + unsigned get_timeout() const { return m_params.m_timeout; } arith_util & autil() { return m_arith_util; } bv_util & bvutil() { return m_bv_util; } datalog::dl_decl_util & datalog_util() { return m_datalog_util; } @@ -167,12 +166,13 @@ namespace api { static void out_of_memory_handler(void * _ctx); void check_sorts(ast * n); + // ------------------------ // // Solver interface for backward compatibility // // ------------------------ - + front_end_params & fparams() { return m_fparams; } bool has_solver() const { return m_solver != 0; } smt::kernel & get_smt_kernel(); void assert_cnstr(expr * a); diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 34ca9627a..4c54a4332 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -265,7 +265,7 @@ extern "C" { RESET_ERROR_CODE(); lbool r = l_undef; cancel_eh eh(*to_fixedpoint_ref(d)); - unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); api::context::set_interruptable(*(mk_c(c)), eh); { scoped_timer timer(timeout, &eh); @@ -289,7 +289,7 @@ extern "C" { LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations); RESET_ERROR_CODE(); lbool r = l_undef; - unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); cancel_eh eh(*to_fixedpoint_ref(d)); api::context::set_interruptable(*(mk_c(c)), eh); { diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 31901d360..67d083704 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -36,10 +36,17 @@ extern "C" { static void init_solver_core(Z3_context c, Z3_solver _s) { ast_manager & m = mk_c(c)->m(); Z3_solver_ref * s = to_solver(_s); - s->m_solver->set_produce_proofs(m.proofs_enabled()); - s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); - s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); - s->m_solver->updt_params(s->m_params); + s->m_solver->set_produce_proofs(mk_c(c)->produce_proofs()); + s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", mk_c(c)->produce_unsat_cores())); + s->m_solver->set_produce_models(s->m_params.get_bool("model", mk_c(c)->produce_models())); + if (!mk_c(c)->use_auto_config()) { + params_ref p = s->m_params; + p.set_bool("auto_config", false); + s->m_solver->updt_params(p); + } + else { + s->m_solver->updt_params(s->m_params); + } s->m_solver->init(m, s->m_logic); s->m_initialized = true; } @@ -237,7 +244,7 @@ extern "C" { } } expr * const * _assumptions = to_exprs(assumptions); - unsigned timeout = to_solver(s)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh eh(*to_solver_ref(s)); api::context::set_interruptable(*(mk_c(c)), eh); diff --git a/src/api/z3_api.h b/src/api/z3_api.h index a0c6434c2..16bf9193c 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1308,6 +1308,12 @@ extern "C" { - debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting - trace (Boolean) Tracing support for VCC - trace_file_name (String) Trace out file for VCC traces + - timeout (unsigned) default timeout (in milliseconds) used for solvers + - well_sorted_check type checker + - auto_config use heuristics to automatically select solver and configure it + - model model generation for solvers, this parameter can be overwritten when creating a solver + - validate_model validate models produced by solvers + - unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver \sa Z3_set_param_value \sa Z3_del_config @@ -1420,19 +1426,18 @@ extern "C" { #endif /** - \brief This is a deprecated function. This is a NOOP in the current version of Z3. + \brief Set a value of a context parameter. - \deprecated Use #Z3_global_param_set. + \sa Use #Z3_global_param_set. def_API('Z3_update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) */ void Z3_API Z3_update_param_value(__in Z3_context c, __in Z3_string param_id, __in Z3_string param_value); /** - \brief This is a deprecated function. This is a NOOP in the current version of Z3. - It always return Z3_FALSE. + \brief Return the value of a context parameter. - \deprecated Use #Z3_global_param_get + \sa Use #Z3_global_param_get def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) */ From 288a96610f446aa01da0ba8aa72b070b6d26eba8 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 09:08:47 -0800 Subject: [PATCH 078/133] ported VCC trace streams Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 2 +- src/ast/ast.cpp | 51 ++++++++++++++++++----- src/ast/ast.h | 9 +++- src/cmd_context/cmd_context.cpp | 4 +- src/front_end_params/front_end_params.cpp | 16 ------- src/front_end_params/front_end_params.h | 12 +----- src/parsers/smt/smtlib_solver.cpp | 8 ++-- src/parsers/smt/smtlib_solver.h | 6 +-- src/shell/main.cpp | 7 +--- src/shell/smtlib_frontend.cpp | 6 +-- src/shell/smtlib_frontend.h | 10 +---- src/smt/mam.cpp | 33 +++++++-------- src/smt/mam.h | 8 ++-- src/smt/qi_queue.cpp | 35 +++++++--------- src/smt/qi_queue.h | 3 +- src/smt/smt_case_split_queue.cpp | 13 ++---- src/smt/smt_conflict_resolution.cpp | 23 +++++----- src/smt/smt_context.cpp | 39 ++++++++--------- src/smt/smt_context_pp.cpp | 3 +- src/smt/smt_internalizer.cpp | 8 ++-- src/smt/smt_quantifier.cpp | 13 +++--- 21 files changed, 149 insertions(+), 160 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 02069e06d..2d242f9b0 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -82,7 +82,7 @@ namespace api { context::context(context_params * p, bool user_ref_count): m_params(*p), m_user_ref_count(user_ref_count), - m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED), // PARAM-TODO , _fparams.m_proof_mode, m_fparams.m_trace_stream), + m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), m_plugins(m_manager), m_arith_util(m_manager), m_bv_util(m_manager), diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 67f07e414..ae82dcadf 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1196,13 +1196,36 @@ decl_plugin * user_sort_plugin::mk_fresh() { // // ----------------------------------- -ast_manager::ast_manager(proof_gen_mode m, std::ostream *trace_stream, bool is_format_manager): +ast_manager::ast_manager(proof_gen_mode m, char const * trace_file, bool is_format_manager): m_alloc("ast_manager"), m_expr_array_manager(*this, m_alloc), m_expr_dependency_manager(*this, m_alloc), m_expr_dependency_array_manager(*this, m_alloc), m_proof_mode(m), - m_trace_stream(trace_stream) { + m_trace_stream(0), + m_trace_stream_owner(false) { + + if (trace_file) { + m_trace_stream = alloc(std::fstream, trace_file, std::ios_base::out); + m_trace_stream_owner = true; + } + + if (!is_format_manager) + m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true); + else + m_format_manager = 0; + init(); +} + +ast_manager::ast_manager(proof_gen_mode m, std::fstream * trace_stream, bool is_format_manager): + m_alloc("ast_manager"), + m_expr_array_manager(*this, m_alloc), + m_expr_dependency_manager(*this, m_alloc), + m_expr_dependency_array_manager(*this, m_alloc), + m_proof_mode(m), + m_trace_stream(trace_stream), + m_trace_stream_owner(false) { + if (!is_format_manager) m_format_manager = alloc(ast_manager, PGM_DISABLED, trace_stream, true); else @@ -1216,9 +1239,10 @@ ast_manager::ast_manager(ast_manager const & src, bool disable_proofs): m_expr_dependency_manager(*this, m_alloc), m_expr_dependency_array_manager(*this, m_alloc), m_proof_mode(disable_proofs ? PGM_DISABLED : src.m_proof_mode), - m_trace_stream(src.m_trace_stream) { + m_trace_stream(src.m_trace_stream), + m_trace_stream_owner(false) { SASSERT(!src.is_format_manager()); - m_format_manager = 0; + m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true); init(); copy_families_plugins(src); } @@ -1256,6 +1280,7 @@ void ast_manager::init() { ast_manager::~ast_manager() { SASSERT(is_format_manager() || !m_family_manager.has_family(symbol("format"))); + dec_ref(m_bool_sort); dec_ref(m_proof_sort); dec_ref(m_true); @@ -1294,6 +1319,13 @@ ast_manager::~ast_manager() { #endif if (m_format_manager != 0) dealloc(m_format_manager); + if (m_trace_stream_owner) { + std::fstream & tmp = * m_trace_stream; + tmp << "[eof]\n"; + tmp.close(); + dealloc(m_trace_stream); + m_trace_stream = 0; + } } void ast_manager::compact_memory() { @@ -1873,8 +1905,8 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const new_node = new (mem) app(decl, num_args, args); r = register_node(new_node); } -#ifndef SMTCOMP - if (m_trace_stream != NULL && r == new_node) { + + if (m_trace_stream && r == new_node) { *m_trace_stream << "[mk-app] #" << r->get_id() << " "; if (r->get_num_args() == 0 && r->get_decl()->get_name() == "int") { ast_ll_pp(*m_trace_stream, *this, r); @@ -1887,7 +1919,7 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const *m_trace_stream << "\n"; } } -#endif + return r; } @@ -2064,8 +2096,7 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort * num_no_patterns, no_patterns); quantifier * r = register_node(new_node); -#ifndef SMTCOMP - if (m_trace_stream != NULL && r == new_node) { + if (m_trace_stream && r == new_node) { *m_trace_stream << "[mk-quant] #" << r->get_id() << " " << qid; for (unsigned i = 0; i < num_patterns; ++i) { *m_trace_stream << " #" << patterns[i]->get_id(); @@ -2073,7 +2104,7 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort * *m_trace_stream << " #" << body->get_id() << "\n"; } -#endif + return r; } diff --git a/src/ast/ast.h b/src/ast/ast.h index 8453598f2..2a0872721 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1350,7 +1350,8 @@ protected: unsigned m_fresh_id; bool m_debug_ref_count; u_map m_debug_free_indices; - std::ostream* m_trace_stream; + std::fstream* m_trace_stream; + bool m_trace_stream_owner; #ifdef Z3DEBUG bool slow_not_contains(ast const * n); #endif @@ -1361,10 +1362,14 @@ protected: bool coercion_needed(func_decl * decl, unsigned num_args, expr * const * args); public: - ast_manager(proof_gen_mode = PGM_DISABLED, std::ostream * trace_stream = NULL, bool is_format_manager = false); + ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = 0, bool is_format_manager = false); + ast_manager(proof_gen_mode, std::fstream * trace_stream, bool is_format_manager = false); ast_manager(ast_manager const & src, bool disable_proofs = false); ~ast_manager(); + bool has_trace_stream() const { return m_trace_stream != 0; } + std::ostream & trace_stream() { SASSERT(has_trace_stream()); return *m_trace_stream; } + void enable_int_real_coercions(bool f) { m_int_real_coercions = f; } bool int_real_coercions() const { return m_int_real_coercions; } diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 1a018a41d..19fbdcd3c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -597,7 +597,9 @@ void cmd_context::init_manager() { SASSERT(m_manager == 0); SASSERT(m_pmanager == 0); m_check_sat_result = 0; - m_manager = alloc(ast_manager, produce_proofs() ? PGM_FINE : PGM_DISABLED); // PARAM-TODO , params().m_trace_stream); + m_manager = alloc(ast_manager, + produce_proofs() ? PGM_FINE : PGM_DISABLED, + m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); // PARAM-TODO diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index f00c21d56..367c983c3 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -49,19 +49,3 @@ void front_end_params::register_params(ini_params & p) { #endif -void front_end_params::open_trace_file() { - if (m_trace) { - m_trace_stream = alloc(std::fstream, m_trace_file_name.c_str(), std::ios_base::out); - } -} - -void front_end_params::close_trace_file() { - if (m_trace_stream != NULL) { - std::fstream &tmp = *m_trace_stream; - m_trace_stream = NULL; - tmp << "[eof]\n"; - tmp.close(); - // do not delete it, this might be called from a Ctrl-C signal handler - // and there might be someone writing to it - } -} diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 2c7dbfa2e..9bf5dd69c 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -30,9 +30,6 @@ struct front_end_params : public smt_params { bool m_auto_config; bool m_debug_ref_count; - bool m_trace; - std::string m_trace_file_name; - std::fstream* m_trace_stream; front_end_params(): m_well_sorted_check(true), @@ -40,16 +37,9 @@ struct front_end_params : public smt_params { m_memory_max_size(0), m_proof_mode(PGM_DISABLED), m_auto_config(true), - m_debug_ref_count(false), - m_trace(false), - m_trace_file_name("z3.log"), - m_trace_stream(NULL) { + m_debug_ref_count(false) { } - void open_trace_file(); - - void close_trace_file(); - bool has_auto_config(unsigned idx) { return m_auto_config; } private: diff --git a/src/parsers/smt/smtlib_solver.cpp b/src/parsers/smt/smtlib_solver.cpp index ddcdb56c8..ef28216bf 100644 --- a/src/parsers/smt/smtlib_solver.cpp +++ b/src/parsers/smt/smtlib_solver.cpp @@ -33,9 +33,9 @@ Revision History: namespace smtlib { - solver::solver(front_end_params & params): - m_ast_manager(params.m_proof_mode, params.m_trace_stream), - m_params(params), + solver::solver(): + m_ast_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, + m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), m_ctx(0), m_error_code(0) { parser_params ps; @@ -103,7 +103,7 @@ namespace smtlib { check_sat_result * r = m_ctx->get_check_sat_result(); if (r != 0) { proof * pr = r->get_proof(); - if (pr != 0 && m_params.m_display_proof) + if (pr != 0 && m_params.m_proof) std::cout << mk_ll_pp(pr, m_ast_manager, false, false); model_ref md; if (r->status() != l_false) r->get_model(md); diff --git a/src/parsers/smt/smtlib_solver.h b/src/parsers/smt/smtlib_solver.h index a84f2c98f..4e9815d38 100644 --- a/src/parsers/smt/smtlib_solver.h +++ b/src/parsers/smt/smtlib_solver.h @@ -20,20 +20,20 @@ Revision History: #define _SMTLIB_SOLVER_H_ #include"smtparser.h" -#include"front_end_params.h" +#include"context_params.h" #include"lbool.h" class cmd_context; namespace smtlib { class solver { + context_params m_params; ast_manager m_ast_manager; - front_end_params & m_params; cmd_context * m_ctx; scoped_ptr m_parser; unsigned m_error_code; public: - solver(front_end_params & params); + solver(); ~solver(); bool solve_smt(char const * benchmark_file); bool solve_smt_string(char const * benchmark_string); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 9cef54628..ecbaf8887 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -122,8 +122,6 @@ void init_params() { } void del_params() { - if (g_front_end_params != NULL) - g_front_end_params->close_trace_file(); delete g_extra_params; delete g_front_end_params; g_extra_params = 0; @@ -315,7 +313,6 @@ int main(int argc, char ** argv) { parse_cmd_line_args(argc, argv); env_params::updt_params(); - g_front_end_params->open_trace_file(); if (g_input_file && g_standard_input) { error("using standard input to read formula."); } @@ -346,11 +343,11 @@ int main(int argc, char ** argv) { } switch (g_input_kind) { case IN_SMTLIB: - return_value = read_smtlib_file(g_input_file, *g_front_end_params); + return_value = read_smtlib_file(g_input_file); break; case IN_SMTLIB_2: memory::exit_when_out_of_memory(true, "(error \"out of memory\")"); - return_value = read_smtlib2_commands(g_input_file, *g_front_end_params); + return_value = read_smtlib2_commands(g_input_file); break; case IN_DIMACS: return_value = read_dimacs(g_input_file); diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index c95b90098..1551329c6 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -67,11 +67,11 @@ static void on_ctrl_c(int) { raise(SIGINT); } -unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_end_params) { +unsigned read_smtlib_file(char const * benchmark_file) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); - smtlib::solver solver(front_end_params); + smtlib::solver solver; g_solver = &solver; bool ok = true; @@ -92,7 +92,7 @@ unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_ return solver.get_error_code(); } -unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_end_params) { +unsigned read_smtlib2_commands(char const * file_name) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); diff --git a/src/shell/smtlib_frontend.h b/src/shell/smtlib_frontend.h index 0db1571e4..d83944119 100644 --- a/src/shell/smtlib_frontend.h +++ b/src/shell/smtlib_frontend.h @@ -21,14 +21,8 @@ Revision History: #include"front_end_params.h" -unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_end_params); - -unsigned read_smtlib_commands(char const* command_file, front_end_params& front_end_params); -unsigned read_smtlib2_commands(char const* command_file, front_end_params& front_end_params); - -#ifdef _Z3_BUILD_PARALLEL_MPI -unsigned start_mpi_subordinate(front_end_params& front_end_params); -#endif +unsigned read_smtlib_file(char const * benchmark_file); +unsigned read_smtlib2_commands(char const * command_file); #endif /* _SMTLIB_FRONTEND_H_ */ diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index ba97d8939..24b8e2e7c 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -1824,7 +1824,6 @@ namespace smt { backtrack_stack m_backtrack_stack; unsigned m_top; const instruction * m_pc; - std::ostream* m_trace_stream; // auxiliary temporary variables unsigned m_max_generation; // the maximum generation of an app enode processed. @@ -1855,10 +1854,9 @@ namespace smt { void update_max_generation(enode * n) { m_max_generation = std::max(m_max_generation, n->get_generation()); -#ifndef SMTCOMP - if (m_trace_stream != NULL) + + if (m_ast_manager.has_trace_stream()) m_used_enodes.push_back(n); -#endif } // We have to provide the number of expected arguments because we have flat-assoc applications such as +. @@ -1965,12 +1963,11 @@ namespace smt { #define INIT_ARGS_SIZE 16 public: - interpreter(context & ctx, mam & m, bool use_filters, std::ostream *trace_stream): + interpreter(context & ctx, mam & m, bool use_filters): m_context(ctx), m_ast_manager(ctx.get_manager()), m_mam(m), - m_use_filters(use_filters), - m_trace_stream(trace_stream) { + m_use_filters(use_filters) { m_args.resize(INIT_ARGS_SIZE, 0); } @@ -2266,12 +2263,12 @@ namespace smt { m_pattern_instances.reset(); m_pattern_instances.push_back(n); m_max_generation = n->get_generation(); -#ifndef SMTCOMP - if (m_trace_stream != NULL) { + + if (m_ast_manager.has_trace_stream()) { m_used_enodes.reset(); m_used_enodes.push_back(n); } -#endif + m_pc = t->get_root(); m_registers[0] = n; m_top = 0; @@ -2638,10 +2635,10 @@ namespace smt { } backtrack_point & bp = m_backtrack_stack[m_top - 1]; m_max_generation = bp.m_old_max_generation; -#ifndef SMTCOMP - if (m_trace_stream != NULL) + + if (m_ast_manager.has_trace_stream()) m_used_enodes.shrink(bp.m_old_used_enodes_size); -#endif + TRACE("mam_int", tout << "backtrack top: " << bp.m_instr << " " << *(bp.m_instr) << "\n";); #ifdef _PROFILE_MAM if (bp.m_instr->m_opcode != CHOOSE) // CHOOSE has a different status. It is a control flow backtracking. @@ -3759,14 +3756,14 @@ namespace smt { } public: - mam_impl(context & ctx, bool use_filters, std::ostream *trace): - mam(ctx, trace), + mam_impl(context & ctx, bool use_filters): + mam(ctx), m_ast_manager(ctx.get_manager()), m_use_filters(use_filters), m_trail_stack(*this), m_ct_manager(m_lbl_hasher, m_trail_stack), m_compiler(ctx, m_ct_manager, m_lbl_hasher, use_filters), - m_interpreter(ctx, *this, use_filters, trace), + m_interpreter(ctx, *this, use_filters), m_trees(m_ast_manager, m_compiler, m_trail_stack), m_region(m_trail_stack.get_region()), m_r1(0), @@ -3980,8 +3977,8 @@ namespace smt { } }; - mam * mk_mam(context & ctx, std::ostream *trace) { - return alloc(mam_impl, ctx, true, trace); + mam * mk_mam(context & ctx) { + return alloc(mam_impl, ctx, true); } }; diff --git a/src/smt/mam.h b/src/smt/mam.h index cee6f6e2f..c9f813150 100644 --- a/src/smt/mam.h +++ b/src/smt/mam.h @@ -29,11 +29,9 @@ namespace smt { class mam { protected: context & m_context; - std::ostream * m_trace_stream; public: - mam(context & ctx, std::ostream *trace): - m_context(ctx), - m_trace_stream(trace) { + mam(context & ctx): + m_context(ctx) { } virtual ~mam() { @@ -68,7 +66,7 @@ namespace smt { #endif }; - mam * mk_mam(context & ctx, std::ostream *trace); + mam * mk_mam(context & ctx); }; #endif /* _MAM_H_ */ diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index a2a2cc9de..9394dae34 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -26,7 +26,7 @@ Revision History: namespace smt { - qi_queue::qi_queue(quantifier_manager & qm, context & ctx, qi_params & params, std::ostream *trace_stream): + qi_queue::qi_queue(quantifier_manager & qm, context & ctx, qi_params & params): m_qm(qm), m_context(ctx), m_manager(m_context.get_manager()), @@ -37,7 +37,6 @@ namespace smt { m_parser(m_manager), m_evaluator(m_manager), m_subst(m_manager), - m_trace_stream(trace_stream), m_instances(m_manager) { init_parser_vars(); m_vals.resize(15, 0.0f); @@ -173,25 +172,23 @@ namespace smt { } void qi_queue::display_instance_profile(fingerprint * f, quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned proof_id, unsigned generation) { -#ifndef SMTCOMP - if (m_trace_stream != NULL) { - *m_trace_stream << "[instance] "; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[instance] "; #if 1 - *m_trace_stream << static_cast(f); + m_manager.trace_stream() << static_cast(f); #else for (unsigned i = 0; i < num_bindings; i++) { // I don't want to use mk_pp because it creates expressions for pretty printing. // This nasty side-effect may change the behavior of Z3. - *m_trace_stream << " #" << bindings[i]->get_owner_id(); + m_manager.trace_stream() << " #" << bindings[i]->get_owner_id(); } #endif if (m_manager.proofs_enabled()) - *m_trace_stream << " #" << proof_id; - *m_trace_stream << " ; " << generation; - *m_trace_stream << "\n"; + m_manager.trace_stream() << " #" << proof_id; + m_manager.trace_stream() << " ; " << generation; + m_manager.trace_stream() << "\n"; } -#endif } void qi_queue::instantiate(entry & ent) { @@ -224,10 +221,10 @@ namespace smt { TRACE("qi_queue_bug", tout << "new instance after simplification:\n" << mk_pp(s_instance, m_manager) << "\n";); if (m_manager.is_true(s_instance)) { TRACE("checker", tout << "reduced to true, before:\n" << mk_ll_pp(instance, m_manager);); -#ifndef SMTCOMP - if (m_trace_stream != NULL) - *m_trace_stream << "[end-of-instance]\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[end-of-instance]\n"; + return; } quantifier_stat * stat = m_qm.get_stat(q); @@ -308,10 +305,10 @@ namespace smt { } } }); -#ifndef SMTCOMP - if (m_trace_stream != NULL) - *m_trace_stream << "[end-of-instance]\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[end-of-instance]\n"; + } void qi_queue::push_scope() { diff --git a/src/smt/qi_queue.h b/src/smt/qi_queue.h index 43d57d84f..1060f083b 100644 --- a/src/smt/qi_queue.h +++ b/src/smt/qi_queue.h @@ -53,7 +53,6 @@ namespace smt { cached_var_subst m_subst; svector m_vals; double m_eager_cost_threshold; - std::ostream * m_trace_stream; struct entry { fingerprint * m_qb; float m_cost; @@ -81,7 +80,7 @@ namespace smt { void display_instance_profile(fingerprint * f, quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned proof_id, unsigned generation); public: - qi_queue(quantifier_manager & qm, context & ctx, qi_params & params, std::ostream *trace); + qi_queue(quantifier_manager & qm, context & ctx, qi_params & params); ~qi_queue(); void setup(); /** diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 66d08e9fc..808284224 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -395,8 +395,8 @@ namespace smt { if ((is_or && val == l_true) || (is_and && val == l_false)) { expr * undef_child = 0; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; } TRACE("case_split", tout << "found AND/OR candidate: #" << curr->get_id() << " #" << undef_child->get_id() << "\n";); literal l = m_context.get_literal(undef_child); @@ -851,8 +851,8 @@ namespace smt { if ((is_or && val == l_true) || (is_and && val == l_false)) { expr * undef_child = 0; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; } TRACE("case_split", tout << "found AND/OR candidate: #" << curr->get_id() << " #" << undef_child->get_id() << "\n";); literal l = m_context.get_literal(undef_child); @@ -900,11 +900,6 @@ namespace smt { // does the push after calling us m_priority_queue2.insert(idx); e.m_last_decided = -1; - /* - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[generation] #" << e.m_expr->get_id() << " " << e.m_generation << "\n"; - } - */ return; } } diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 2bc32e217..071275dd4 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -304,13 +304,13 @@ namespace smt { if (th) th->conflict_resolution_eh(to_app(n), var); } -#ifndef SMTCOMP - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[resolve-lit] " << m_conflict_lvl - lvl << " "; - m_ctx.display_literal(*m_params.m_trace_stream, ~antecedent); - *m_params.m_trace_stream << "\n"; + + if (get_manager().has_trace_stream()) { + get_manager().trace_stream() << "[resolve-lit] " << m_conflict_lvl - lvl << " "; + m_ctx.display_literal(get_manager().trace_stream(), ~antecedent); + get_manager().trace_stream() << "\n"; } -#endif + if (lvl == m_conflict_lvl) { num_marks++; } @@ -478,13 +478,12 @@ namespace smt { } do { -#ifndef SMTCOMP - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[resolve-process] "; - m_ctx.display_literal(*m_params.m_trace_stream, ~consequent); - *m_params.m_trace_stream << "\n"; + + if (get_manager().has_trace_stream()) { + get_manager().trace_stream() << "[resolve-process] "; + m_ctx.display_literal(get_manager().trace_stream(), ~consequent); + get_manager().trace_stream() << "\n"; } -#endif TRACE("conflict", tout << "processing consequent: "; m_ctx.display_literal(tout, consequent); tout << "\n"; tout << "num_marks: " << num_marks << ", js kind: " << js.get_kind() << "\n";); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 1aae1c62a..3fb8398b4 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -190,11 +190,10 @@ namespace smt { TRACE("phase_selection", tout << "saving phase, is_pos: " << d.m_phase << " l: " << l << "\n";); if (d.is_atom() && (m_fparams.m_relevancy_lvl == 0 || (m_fparams.m_relevancy_lvl == 1 && !d.is_quantifier()) || is_relevant_core(bool_var2expr(l.var())))) m_atom_propagation_queue.push_back(l); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) + + if (m_manager.has_trace_stream()) trace_assign(l, j, decision); m_case_split_queue->assign_lit_eh(l); -#endif } bool context::bcp() { @@ -1789,10 +1788,10 @@ namespace smt { \brief Create an internal backtracking point */ void context::push_scope() { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[push] " << m_scope_lvl << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[push] " << m_scope_lvl << "\n"; + m_scope_lvl++; m_region.push_scope(); m_scopes.push_back(scope()); @@ -2237,10 +2236,10 @@ namespace smt { \warning This method will not invoke reset_cache_generation. */ unsigned context::pop_scope_core(unsigned num_scopes) { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[pop] " << num_scopes << " " << m_scope_lvl << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[pop] " << num_scopes << " " << m_scope_lvl << "\n"; + TRACE("context", tout << "backtracking: " << num_scopes << "\n";); TRACE("pop_scope_detail", display(tout);); SASSERT(num_scopes > 0); @@ -2927,10 +2926,8 @@ namespace smt { Return true if succeeded. */ bool context::check_preamble(bool reset_cancel) { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[begin-check] " << m_scope_lvl << "\n"; -#endif + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[begin-check] " << m_scope_lvl << "\n"; if (reset_cancel) { m_cancel_flag = false; @@ -3534,13 +3531,13 @@ namespace smt { tout << ", ilvl: " << get_intern_level(l.var()) << "\n" << mk_pp(bool_var2expr(l.var()), m_manager) << "\n"; }); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) { - *m_fparams.m_trace_stream << "[conflict] "; - display_literals(*m_fparams.m_trace_stream, num_lits, lits); - *m_fparams.m_trace_stream << "\n"; + + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[conflict] "; + display_literals(m_manager.trace_stream(), num_lits, lits); + m_manager.trace_stream() << "\n"; } -#endif + #ifdef Z3DEBUG expr_ref_vector expr_lits(m_manager); svector expr_signs; diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index 4bc5dfd74..9ce684440 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -583,7 +583,8 @@ namespace smt { } void context::trace_assign(literal l, b_justification j, bool decision) const { - std::ostream & out = *m_fparams.m_trace_stream; + SASSERT(m_manager.has_trace_stream()); + std::ostream & out = m_manager.trace_stream(); out << "[assign] "; display_literal(out, l); if (decision) diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 0cfe5b1de..556222c33 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -952,10 +952,10 @@ namespace smt { tout << "is_true_eq: " << e->is_true_eq() << " in cg_table: " << m_cg_table.contains_ptr(e) << " is_cgr: " << e->is_cgr() << "\n"; }); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[attach-enode] #" << n->get_id() << " " << m_generation << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[attach-enode] #" << n->get_id() << " " << m_generation << "\n"; + return e; } diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index e6d81d3d2..14e63b982 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -45,13 +45,16 @@ namespace smt { m_wrapper(wrapper), m_context(ctx), m_params(p), - m_qi_queue(m_wrapper, ctx, p, p.m_trace_stream), + m_qi_queue(m_wrapper, ctx, p), m_qstat_gen(ctx.get_manager(), ctx.get_region()), m_plugin(plugin) { m_num_instances = 0; m_qi_queue.setup(); } + bool has_trace_stream() const { return m_context.get_manager().has_trace_stream(); } + std::ostream & trace_stream() { return m_context.get_manager().trace_stream(); } + quantifier_stat * get_stat(quantifier * q) const { return m_quantifier_stat.find(q); } @@ -112,8 +115,8 @@ namespace smt { get_stat(q)->update_max_generation(max_generation); fingerprint * f = m_context.add_fingerprint(q, q->get_id(), num_bindings, bindings); if (f) { - if (m_params.m_trace_stream != NULL) { - std::ostream & out = *m_params.m_trace_stream; + if (has_trace_stream()) { + std::ostream & out = trace_stream(); out << "[new-match] " << static_cast(f) << " #" << q->get_id(); for (unsigned i = 0; i < num_bindings; i++) { // I don't want to use mk_pp because it creates expressions for pretty printing. @@ -418,8 +421,8 @@ namespace smt { m_fparams = &(m_context->get_fparams()); ast_manager & m = m_context->get_manager(); - m_mam = mk_mam(*m_context, m_fparams->m_trace_stream); - m_lazy_mam = mk_mam(*m_context, m_fparams->m_trace_stream); + m_mam = mk_mam(*m_context); + m_lazy_mam = mk_mam(*m_context); m_model_finder = alloc(model_finder, m, m_context->get_simplifier()); m_model_checker = alloc(model_checker, m, *m_fparams, *(m_model_finder.get())); From ffb7e26c75eef09d871b3e43600e7ba00ff87637 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 10:05:29 -0800 Subject: [PATCH 079/133] removed front-end-params Signed-off-by: Leonardo de Moura --- src/api/api_context.h | 6 +- src/api/api_datalog.cpp | 2 +- src/api/api_datalog.h | 4 +- src/ast/proof_checker/proof_checker.cpp | 2 +- src/cmd_context/context_params.h | 1 - src/front_end_params/front_end_params.cpp | 51 -------------- src/front_end_params/front_end_params.h | 51 -------------- .../params2front_end_params.h | 31 --------- ...t_end_params.cpp => params2smt_params.cpp} | 13 ++-- src/front_end_params/params2smt_params.h | 31 +++++++++ src/front_end_params/smt_params.h | 23 ++++++- src/muz_qe/dl_bmc_engine.h | 2 +- src/muz_qe/dl_cmds.cpp | 4 +- src/muz_qe/dl_context.cpp | 2 +- src/muz_qe/dl_context.h | 8 +-- src/muz_qe/dl_smt_relation.cpp | 12 ++-- src/muz_qe/dl_smt_relation.h | 4 +- src/muz_qe/horn_tactic.cpp | 2 +- src/muz_qe/nlarith_util.cpp | 2 +- src/muz_qe/pdr_context.cpp | 2 +- src/muz_qe/pdr_context.h | 6 +- src/muz_qe/pdr_farkas_learner.cpp | 10 +-- src/muz_qe/pdr_farkas_learner.h | 8 +-- src/muz_qe/pdr_generalizers.cpp | 2 +- src/muz_qe/pdr_generalizers.h | 2 +- src/muz_qe/pdr_interpolant_provider.cpp | 2 +- src/muz_qe/pdr_manager.cpp | 2 +- src/muz_qe/pdr_manager.h | 6 +- src/muz_qe/pdr_prop_solver.cpp | 2 +- src/muz_qe/pdr_prop_solver.h | 2 +- src/muz_qe/pdr_quantifiers.cpp | 2 +- src/muz_qe/pdr_smt_context_manager.cpp | 4 +- src/muz_qe/pdr_smt_context_manager.h | 4 +- src/muz_qe/pdr_util.cpp | 2 +- src/muz_qe/qe.cpp | 16 ++--- src/muz_qe/qe.h | 10 +-- src/muz_qe/qe_arith_plugin.cpp | 6 +- src/muz_qe/qe_cmd.cpp | 2 +- src/muz_qe/qe_sat_tactic.cpp | 2 +- src/muz_qe/qe_tactic.cpp | 2 +- src/muz_qe/unit_subsumption_tactic.cpp | 2 +- src/muz_qe/vsubst_tactic.cpp | 6 +- src/parsers/smt/smtparser.cpp | 1 - src/shell/datalog_frontend.cpp | 22 +++--- src/shell/datalog_frontend.h | 2 +- src/shell/main.cpp | 68 ++----------------- src/shell/smtlib_frontend.h | 2 - src/smt/asserted_formulas.cpp | 2 +- src/smt/asserted_formulas.h | 6 +- src/smt/expr_context_simplifier.cpp | 2 +- src/smt/expr_context_simplifier.h | 6 +- src/smt/smt_case_split_queue.cpp | 14 ++-- src/smt/smt_case_split_queue.h | 2 +- src/smt/smt_conflict_resolution.cpp | 4 +- src/smt/smt_conflict_resolution.h | 8 +-- src/smt/smt_context.cpp | 4 +- src/smt/smt_context.h | 8 +-- src/smt/smt_kernel.cpp | 14 ++-- src/smt/smt_kernel.h | 4 +- src/smt/smt_model_checker.cpp | 2 +- src/smt/smt_model_checker.h | 6 +- src/smt/smt_quantifier.cpp | 10 +-- src/smt/smt_quantifier.h | 4 +- src/smt/smt_setup.cpp | 2 +- src/smt/smt_setup.h | 6 +- src/smt/smt_solver.cpp | 4 +- src/smt/tactic/ctx_solver_simplify_tactic.cpp | 4 +- src/smt/tactic/smt_tactic.cpp | 14 ++-- src/smt/theory_diff_logic.h | 6 +- src/smt/theory_instgen.cpp | 10 +-- src/smt/theory_instgen.h | 4 +- src/smt/user_plugin/user_smt_theory.cpp | 2 +- src/smt/user_plugin/user_smt_theory.h | 4 +- src/solver/solver.h | 2 - src/tactic/tactic.h | 1 - src/test/arith_simplifier_plugin.cpp | 4 +- src/test/check_assumptions.cpp | 4 +- src/test/datalog_parser.cpp | 6 +- src/test/dl_context.cpp | 6 +- src/test/dl_product_relation.cpp | 6 +- src/test/dl_query.cpp | 8 +-- src/test/dl_relation.cpp | 4 +- src/test/dl_smt_relation.cpp | 2 +- src/test/dl_table.cpp | 2 +- src/test/model_retrieval.cpp | 4 +- src/test/quant_elim.cpp | 4 +- src/test/quant_solve.cpp | 11 ++- src/test/smt_context.cpp | 2 +- src/test/substitution.cpp | 4 +- src/test/theory_dl.cpp | 2 +- src/util/env_params.cpp | 4 +- 91 files changed, 264 insertions(+), 412 deletions(-) delete mode 100644 src/front_end_params/front_end_params.cpp delete mode 100644 src/front_end_params/front_end_params.h delete mode 100644 src/front_end_params/params2front_end_params.h rename src/front_end_params/{params2front_end_params.cpp => params2smt_params.cpp} (89%) create mode 100644 src/front_end_params/params2smt_params.h diff --git a/src/api/api_context.h b/src/api/api_context.h index df0f488af..a126f0790 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -28,7 +28,7 @@ Revision History: #include"datatype_decl_plugin.h" #include"dl_decl_plugin.h" #include"smt_kernel.h" -#include"front_end_params.h" +#include"smt_params.h" #include"event_handler.h" #include"tactic_manager.h" #include"context_params.h" @@ -53,7 +53,7 @@ namespace api { datalog::dl_decl_util m_datalog_util; // Support for old solver API - front_end_params m_fparams; + smt_params m_fparams; smt::kernel * m_solver; // General purpose solver for backward compatibility // ------------------------------- @@ -172,7 +172,7 @@ namespace api { // Solver interface for backward compatibility // // ------------------------ - front_end_params & fparams() { return m_fparams; } + smt_params & fparams() { return m_fparams; } bool has_solver() const { return m_solver != 0; } smt::kernel & get_smt_kernel(); void assert_cnstr(expr * a); diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 4c54a4332..9b7093d1e 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -32,7 +32,7 @@ Revision History: namespace api { - fixedpoint_context::fixedpoint_context(ast_manager& m, front_end_params& p) : + fixedpoint_context::fixedpoint_context(ast_manager& m, smt_params& p) : m_state(0), m_reduce_app(0), m_reduce_assign(0), diff --git a/src/api/api_datalog.h b/src/api/api_datalog.h index 97bedfc9b..1dc0a9cbd 100644 --- a/src/api/api_datalog.h +++ b/src/api/api_datalog.h @@ -21,7 +21,7 @@ Revision History: #include"z3.h" #include"ast.h" -#include"front_end_params.h" +#include"smt_params.h" #include"dl_external_relation.h" #include"dl_decl_plugin.h" #include"smt_kernel.h" @@ -40,7 +40,7 @@ namespace api { datalog::context m_context; ast_ref_vector m_trail; public: - fixedpoint_context(ast_manager& m, front_end_params& p); + fixedpoint_context(ast_manager& m, smt_params& p); virtual ~fixedpoint_context() {} family_id get_family_id() const { return const_cast(m_context).get_decl_util().get_family_id(); } void set_state(void* state); diff --git a/src/ast/proof_checker/proof_checker.cpp b/src/ast/proof_checker/proof_checker.cpp index 8a064a315..bef0fea9c 100644 --- a/src/ast/proof_checker/proof_checker.cpp +++ b/src/ast/proof_checker/proof_checker.cpp @@ -4,7 +4,7 @@ // include "spc_decl_plugin.h" #include "ast_smt_pp.h" #include "arith_decl_plugin.h" -#include "front_end_params.h" +#include "smt_params.h" #include "th_rewriter.h" #include "var_subst.h" diff --git a/src/cmd_context/context_params.h b/src/cmd_context/context_params.h index 556c3bd3f..0fe4da93e 100644 --- a/src/cmd_context/context_params.h +++ b/src/cmd_context/context_params.h @@ -36,7 +36,6 @@ public: bool m_validate_model; bool m_unsat_core; unsigned m_timeout; - bool m_statistics; context_params(); void set(char const * param, char const * value); diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp deleted file mode 100644 index 367c983c3..000000000 --- a/src/front_end_params/front_end_params.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - front_end_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include"front_end_params.h" - -#if 0 - -void front_end_params::register_params(ini_params & p) { - preprocessor_params::register_params(p); - smt_params::register_params(p); - arith_simplifier_params::register_params(p); - p.register_bool_param("at_labels_cex", m_at_labels_cex, - "only use labels that contain '@' when building multiple counterexamples"); - p.register_bool_param("check_at_labels", m_check_at_labels, - "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); - p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); - p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - -#ifdef _WINDOWS - // The non-windows memory manager does not have access to memory sizes. - p.register_unsigned_param("memory_high_watermark", m_memory_high_watermark, - "set high watermark for memory consumption (in megabytes)"); - p.register_unsigned_param("memory_max_size", m_memory_max_size, - "set hard upper limit for memory consumption (in megabytes)"); -#endif - - - PRIVATE_PARAMS({ - }); - -} - -#endif - diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h deleted file mode 100644 index 9bf5dd69c..000000000 --- a/src/front_end_params/front_end_params.h +++ /dev/null @@ -1,51 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - front_end_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#ifndef _FRONT_END_PARAMS_H_ -#define _FRONT_END_PARAMS_H_ - -#include"ast.h" -#include"smt_params.h" - -struct front_end_params : public smt_params { - bool m_well_sorted_check; - unsigned m_memory_high_watermark; - unsigned m_memory_max_size; - proof_gen_mode m_proof_mode; - bool m_auto_config; - - bool m_debug_ref_count; - - front_end_params(): - m_well_sorted_check(true), - m_memory_high_watermark(0), - m_memory_max_size(0), - m_proof_mode(PGM_DISABLED), - m_auto_config(true), - m_debug_ref_count(false) { - } - - bool has_auto_config(unsigned idx) { return m_auto_config; } - -private: - - front_end_params& operator=(front_end_params const& other); -}; - -#endif /* _FRONT_END_PARAMS_H_ */ - diff --git a/src/front_end_params/params2front_end_params.h b/src/front_end_params/params2front_end_params.h deleted file mode 100644 index 936928d4a..000000000 --- a/src/front_end_params/params2front_end_params.h +++ /dev/null @@ -1,31 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - params2front_end_params.h - -Abstract: - - Backward compatibility utilities for parameter setting - -Author: - - Leonardo de Moura (leonardo) 2011-05-19. - -Revision History: - ---*/ -#ifndef _PARAMS2FRONT_END_PARAMS_H_ -#define _PARAMS2FRONT_END_PARAMS_H_ - -class params_ref; -struct front_end_params; - -void params2front_end_params(params_ref const & s, front_end_params & t); - -void front_end_params2params(front_end_params const & s, params_ref & t); - -void solver_front_end_params_descrs(param_descrs & r); - -#endif diff --git a/src/front_end_params/params2front_end_params.cpp b/src/front_end_params/params2smt_params.cpp similarity index 89% rename from src/front_end_params/params2front_end_params.cpp rename to src/front_end_params/params2smt_params.cpp index 4c5866786..b01d9478a 100644 --- a/src/front_end_params/params2front_end_params.cpp +++ b/src/front_end_params/params2smt_params.cpp @@ -3,7 +3,7 @@ Copyright (c) 2011 Microsoft Corporation Module Name: - params2front_end_params.h + params2smt_params.h Abstract: @@ -16,17 +16,17 @@ Author: Revision History: --*/ -#include"front_end_params.h" +#include"smt_params.h" #include"params.h" /** - Update front_end_params using s. + Update smt_params using s. Only the most frequently used options are updated. This function is mainly used to allow smt::context to be used in the new strategy framework. */ -void params2front_end_params(params_ref const & s, front_end_params & t) { +void params2smt_params(params_ref const & s, smt_params & t) { t.m_relevancy_lvl = s.get_uint("relevancy", t.m_relevancy_lvl); TRACE("qi_cost", s.display(tout); tout << "\n";); t.m_qi_cost = s.get_str("qi_cost", t.m_qi_cost.c_str()); @@ -36,7 +36,6 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { t.m_model = s.get_bool("produce_models", t.m_model); if (s.get_bool("produce_proofs", false)) t.m_proof_mode = PGM_FINE; - t.m_well_sorted_check = s.get_bool("check_sorts", t.m_well_sorted_check); t.m_qi_eager_threshold = s.get_double("qi_eager_threshold", t.m_qi_eager_threshold); t.m_qi_lazy_threshold = s.get_double("qi_lazy_threshold", t.m_qi_lazy_threshold); t.m_preprocess = s.get_bool("preprocess", t.m_preprocess); @@ -57,7 +56,7 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { It also copies the model construction parameter. Thus, model construction can be enabled at the command line. */ -void front_end_params2params(front_end_params const & s, params_ref & t) { +void smt_params2params(smt_params const & s, params_ref & t) { if (s.m_model) t.set_bool("produce_models", true); if (!s.m_hi_div0) @@ -67,7 +66,7 @@ void front_end_params2params(front_end_params const & s, params_ref & t) { /** \brief Bridge for using params_ref with smt::context. */ -void solver_front_end_params_descrs(param_descrs & r) { +void solver_smt_params_descrs(param_descrs & r) { r.insert("hi_div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); r.insert("relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); r.insert("mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); diff --git a/src/front_end_params/params2smt_params.h b/src/front_end_params/params2smt_params.h new file mode 100644 index 000000000..d4f60cb64 --- /dev/null +++ b/src/front_end_params/params2smt_params.h @@ -0,0 +1,31 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + params2smt_params.h + +Abstract: + + Backward compatibility utilities for parameter setting + +Author: + + Leonardo de Moura (leonardo) 2011-05-19. + +Revision History: + +--*/ +#ifndef _PARAMS2SMT_PARAMS_H_ +#define _PARAMS2SMT_PARAMS_H_ + +class params_ref; +struct smt_params; + +void params2smt_params(params_ref const & s, smt_params & t); + +void smt_params2params(smt_params const & s, params_ref & t); + +void solver_smt_params_descrs(param_descrs & r); + +#endif diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 24479de16..68e5a596d 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -19,6 +19,7 @@ Revision History: #ifndef _SMT_PARAMS_H_ #define _SMT_PARAMS_H_ +#include"ast.h" #include"dyn_ack_params.h" #include"qi_params.h" #include"theory_arith_params.h" @@ -205,6 +206,24 @@ struct smt_params : public preprocessor_params, bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. bool m_dump_goal_as_smt; + proof_gen_mode m_proof_mode; + bool m_auto_config; + +#if 0 + unsigned m_memory_high_watermark; + unsigned m_memory_max_size; + + bool m_auto_config; + + bool m_debug_ref_count; + + m_well_sorted_check(true), + m_memory_high_watermark(0), + m_memory_max_size(0), + + m_auto_config(true), + m_debug_ref_count(false) { +#endif smt_params(): m_display_proof(false), @@ -272,7 +291,9 @@ struct smt_params : public preprocessor_params, m_soft_timeout(0), m_at_labels_cex(false), m_check_at_labels(false), - m_dump_goal_as_smt(false) { + m_dump_goal_as_smt(false), + m_proof_mode(PGM_DISABLED), + m_auto_config(true) { } }; diff --git a/src/muz_qe/dl_bmc_engine.h b/src/muz_qe/dl_bmc_engine.h index 5de54f843..bd330fa22 100644 --- a/src/muz_qe/dl_bmc_engine.h +++ b/src/muz_qe/dl_bmc_engine.h @@ -32,7 +32,7 @@ namespace datalog { class bmc { context& m_ctx; ast_manager& m; - front_end_params m_fparams; + smt_params m_fparams; smt::kernel m_solver; obj_map m_pred2sort; obj_map m_sort2pred; diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index deb4dc7ec..f45165709 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -33,8 +33,8 @@ Notes: class dl_context { - // PARAM-TODO temp HACK: added m_params field because cmd_context does not have front_end_params anymore - front_end_params m_params; + // PARAM-TODO temp HACK: added m_params field because cmd_context does not have smt_params anymore + smt_params m_params; cmd_context & m_cmd; dl_collected_cmds* m_collected_cmds; unsigned m_ref_count; diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 1e139813b..3b7ad6ffc 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -226,7 +226,7 @@ namespace datalog { // // ----------------------------------- - context::context(ast_manager & m, front_end_params& fp, params_ref const& pa): + context::context(ast_manager & m, smt_params& fp, params_ref const& pa): m(m), m_fparams(fp), m_params(pa), diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index fe94dd3cc..9078bc693 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -24,7 +24,7 @@ Revision History: #undef max #endif #include"arith_decl_plugin.h" -#include"front_end_params.h" +#include"smt_params.h" #include"map.h" #include"th_rewriter.h" #include"str_hashtable.h" @@ -78,7 +78,7 @@ namespace datalog { typedef vector > fact_vector; ast_manager & m; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref m_params; dl_decl_util m_decl_util; th_rewriter m_rewriter; @@ -122,7 +122,7 @@ namespace datalog { public: - context(ast_manager & m, front_end_params& params, params_ref const& p = params_ref()); + context(ast_manager & m, smt_params& params, params_ref const& p = params_ref()); ~context(); void reset(); @@ -149,7 +149,7 @@ namespace datalog { relation_manager & get_rmanager() { return m_rmanager; } const relation_manager & get_rmanager() const { return m_rmanager; } rule_manager & get_rule_manager() { return m_rule_manager; } - front_end_params & get_fparams() const { return m_fparams; } + smt_params & get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } DL_ENGINE get_engine() { configure_engine(); return m_engine; } th_rewriter& get_rewriter() { return m_rewriter; } diff --git a/src/muz_qe/dl_smt_relation.cpp b/src/muz_qe/dl_smt_relation.cpp index 348c63e1c..ee465a7d8 100644 --- a/src/muz_qe/dl_smt_relation.cpp +++ b/src/muz_qe/dl_smt_relation.cpp @@ -129,7 +129,7 @@ namespace datalog { } IF_VERBOSE(10, verbose_stream() << "Checking emptiness...\n"; ); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); // [Leo]: asserted_formulas do not have support for der. // We should use the tactics der. // flet flet2(params.m_der, true); @@ -182,7 +182,7 @@ namespace datalog { expr_ref fml_free(m), fml_inst(m); fml_free = m.mk_and(facts, m.mk_not(get_relation())); instantiate(fml_free, fml_inst); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); // [Leo]: asserted_formulas do not have support for qe nor der. // We should use the tactics qe and der. // BTW, qe at asserted_formulas was disabled when we moved to codeplex, but the field m_quant_elim was not deleted. @@ -239,7 +239,7 @@ namespace datalog { void smt_relation::display_finite(std::ostream & out) const { ast_manager& m = get_manager(); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); expr* r = get_relation(); expr_ref tmp(m); expr_ref_vector values(m), eqs(m); @@ -524,7 +524,7 @@ namespace datalog { expr_ref rInst(m), srcInst(m), tmp(m), tmp1(m); expr_ref notR(m), srcGround(m); - front_end_params& fparams = get(r).get_plugin().get_fparams(); + smt_params& fparams = get(r).get_plugin().get_fparams(); params_ref const& params = get(r).get_plugin().get_params(); get(r).instantiate(get(r).get_relation(), rInst); @@ -730,8 +730,8 @@ namespace datalog { return symbol(m_counter++); } - front_end_params& smt_relation_plugin::get_fparams() { - return const_cast(get_manager().get_context().get_fparams()); + smt_params& smt_relation_plugin::get_fparams() { + return const_cast(get_manager().get_context().get_fparams()); } params_ref const& smt_relation_plugin::get_params() { diff --git a/src/muz_qe/dl_smt_relation.h b/src/muz_qe/dl_smt_relation.h index 99de2ad83..a1bab918f 100644 --- a/src/muz_qe/dl_smt_relation.h +++ b/src/muz_qe/dl_smt_relation.h @@ -20,7 +20,7 @@ Revision History: #define _DL_SMT_RELATION_H_ #include "dl_base.h" -#include "front_end_params.h" +#include "smt_params.h" #include "params.h" namespace datalog { @@ -70,7 +70,7 @@ namespace datalog { symbol fresh_name(); - front_end_params& get_fparams(); + smt_params& get_fparams(); params_ref const& get_params(); diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 8632f333b..1dec1b4fe 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -26,7 +26,7 @@ class horn_tactic : public tactic { struct imp { ast_manager& m; datalog::context m_ctx; - front_end_params m_fparams; + smt_params m_fparams; imp(ast_manager & m, params_ref const & p): m(m), diff --git a/src/muz_qe/nlarith_util.cpp b/src/muz_qe/nlarith_util.cpp index 039b57acf..5f8a24e99 100644 --- a/src/muz_qe/nlarith_util.cpp +++ b/src/muz_qe/nlarith_util.cpp @@ -72,7 +72,7 @@ namespace nlarith { bool m_enable_linear; app_ref m_zero; app_ref m_one; - front_end_params m_params; + smt_params m_params; basic_simplifier_plugin m_bs; arith_simplifier_plugin m_rw; arith_rewriter m_rw1; diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index cb00dbeab..bb3d0f6be 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1087,7 +1087,7 @@ namespace pdr { // context context::context( - front_end_params& fparams, + smt_params& fparams, params_ref const& params, ast_manager& m ) diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index a201ac03b..77c3f48a9 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -285,7 +285,7 @@ namespace pdr { void reset() { memset(this, 0, sizeof(*this)); } }; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref const& m_params; ast_manager& m; datalog::context* m_context; @@ -343,13 +343,13 @@ namespace pdr { We check whether there is some reachable state of the relation checked_relation. */ context( - front_end_params& fparams, + smt_params& fparams, params_ref const& params, ast_manager& m); ~context(); - front_end_params& get_fparams() const { return m_fparams; } + smt_params& get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } ast_manager& get_manager() const { return m; } manager& get_pdr_manager() { return m_pm; } diff --git a/src/muz_qe/pdr_farkas_learner.cpp b/src/muz_qe/pdr_farkas_learner.cpp index 3206c64da..46de8f212 100644 --- a/src/muz_qe/pdr_farkas_learner.cpp +++ b/src/muz_qe/pdr_farkas_learner.cpp @@ -244,7 +244,7 @@ namespace pdr { } }; - farkas_learner::farkas_learner(front_end_params& params, ast_manager& outer_mgr) + farkas_learner::farkas_learner(smt_params& params, ast_manager& outer_mgr) : m_proof_params(get_proof_params(params)), m_pr(PROOF_MODE), p2o(m_pr, outer_mgr), @@ -254,8 +254,8 @@ namespace pdr { m_ctx = alloc(smt::kernel, m_pr, m_proof_params); } - front_end_params farkas_learner::get_proof_params(front_end_params& orig_params) { - front_end_params res(orig_params); + smt_params farkas_learner::get_proof_params(smt_params& orig_params) { + smt_params res(orig_params); res.m_proof_mode = PROOF_MODE; res.m_arith_bound_prop = BP_NONE; // temp hack to fix the build @@ -796,7 +796,7 @@ namespace pdr { void farkas_learner::test() { - front_end_params params; + smt_params params; enable_trace("farkas_learner"); bool res; @@ -883,7 +883,7 @@ namespace pdr { end = p->get_benchmark()->end_formulas(); B = m.mk_and(static_cast(end-it), it); - front_end_params params; + smt_params params; pdr::farkas_learner fl(params, m); expr_ref_vector lemmas(m); bool res = fl.get_lemma_guesses(A, B, lemmas); diff --git a/src/muz_qe/pdr_farkas_learner.h b/src/muz_qe/pdr_farkas_learner.h index 56cb3640c..809f4cd7e 100644 --- a/src/muz_qe/pdr_farkas_learner.h +++ b/src/muz_qe/pdr_farkas_learner.h @@ -26,7 +26,7 @@ Revision History: #include "smt_kernel.h" #include "bool_rewriter.h" #include "pdr_util.h" -#include "front_end_params.h" +#include "smt_params.h" #include "tactic.h" namespace pdr { @@ -39,12 +39,12 @@ class farkas_learner { typedef obj_hashtable expr_set; - front_end_params m_proof_params; + smt_params m_proof_params; ast_manager m_pr; scoped_ptr m_ctx; - static front_end_params get_proof_params(front_end_params& orig_params); + static smt_params get_proof_params(smt_params& orig_params); // // all ast objects passed to private functions have m_proof_mgs as their ast_manager @@ -72,7 +72,7 @@ class farkas_learner { static void test(); public: - farkas_learner(front_end_params& params, ast_manager& m); + farkas_learner(smt_params& params, ast_manager& m); /** All ast objects have the ast_manager which was passed as diff --git a/src/muz_qe/pdr_generalizers.cpp b/src/muz_qe/pdr_generalizers.cpp index 3105485e0..31bb132c4 100644 --- a/src/muz_qe/pdr_generalizers.cpp +++ b/src/muz_qe/pdr_generalizers.cpp @@ -103,7 +103,7 @@ namespace pdr { // weaken predecessor. // - core_farkas_generalizer::core_farkas_generalizer(context& ctx, ast_manager& m, front_end_params& p): + core_farkas_generalizer::core_farkas_generalizer(context& ctx, ast_manager& m, smt_params& p): core_generalizer(ctx), m_farkas_learner(p, m) {} diff --git a/src/muz_qe/pdr_generalizers.h b/src/muz_qe/pdr_generalizers.h index 3b9851ca5..543e6d985 100644 --- a/src/muz_qe/pdr_generalizers.h +++ b/src/muz_qe/pdr_generalizers.h @@ -36,7 +36,7 @@ namespace pdr { class core_farkas_generalizer : public core_generalizer { farkas_learner m_farkas_learner; public: - core_farkas_generalizer(context& ctx, ast_manager& m, front_end_params& p); + core_farkas_generalizer(context& ctx, ast_manager& m, smt_params& p); virtual ~core_farkas_generalizer() {} virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); virtual void collect_statistics(statistics& st) const; diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index bcea5cbc4..de1c62d79 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -306,7 +306,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& return l_undef; } - front_end_params dummy_params; + smt_params dummy_params; cmd_context cctx(&dummy_params, false, &m); for_each_expr(used_symbol_inserter(cctx), f1); diff --git a/src/muz_qe/pdr_manager.cpp b/src/muz_qe/pdr_manager.cpp index 9536d8f36..598d8c850 100644 --- a/src/muz_qe/pdr_manager.cpp +++ b/src/muz_qe/pdr_manager.cpp @@ -166,7 +166,7 @@ namespace pdr { return res; } - manager::manager(front_end_params& fparams, params_ref const& params, ast_manager& manager) : + manager::manager(smt_params& fparams, params_ref const& params, ast_manager& manager) : m(manager), m_fparams(fparams), m_params(params), diff --git a/src/muz_qe/pdr_manager.h b/src/muz_qe/pdr_manager.h index 85f2116e9..58b4ffc53 100644 --- a/src/muz_qe/pdr_manager.h +++ b/src/muz_qe/pdr_manager.h @@ -78,7 +78,7 @@ namespace pdr { class manager { ast_manager& m; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref const& m_params; mutable bool_rewriter m_brwr; @@ -110,11 +110,11 @@ namespace pdr { void add_new_state(func_decl * s); public: - manager(front_end_params& fparams, params_ref const& params, + manager(smt_params& fparams, params_ref const& params, ast_manager & manager); ast_manager& get_manager() const { return m; } - front_end_params& get_fparams() const { return m_fparams; } + smt_params& get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } bool_rewriter& get_brwr() const { return m_brwr; } diff --git a/src/muz_qe/pdr_prop_solver.cpp b/src/muz_qe/pdr_prop_solver.cpp index 4fd036f48..5d0bd4e28 100644 --- a/src/muz_qe/pdr_prop_solver.cpp +++ b/src/muz_qe/pdr_prop_solver.cpp @@ -24,7 +24,7 @@ Revision History: #include "ast_smt2_pp.h" #include "dl_util.h" #include "model_pp.h" -#include "front_end_params.h" +#include "smt_params.h" #include "datatype_decl_plugin.h" #include "bv_decl_plugin.h" #include "pdr_farkas_learner.h" diff --git a/src/muz_qe/pdr_prop_solver.h b/src/muz_qe/pdr_prop_solver.h index fcbfbd536..165a37845 100644 --- a/src/muz_qe/pdr_prop_solver.h +++ b/src/muz_qe/pdr_prop_solver.h @@ -35,7 +35,7 @@ namespace pdr { class prop_solver { private: - front_end_params& m_fparams; + smt_params& m_fparams; ast_manager& m; manager& m_pm; symbol m_name; diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 7922b76c9..1cb4a5c95 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -206,7 +206,7 @@ namespace pdr { datalog::scoped_fine_proof _scp(m); expr_ref_vector fmls(m); - front_end_params fparams; + smt_params fparams; fparams.m_proof_mode = PGM_FINE; fparams.m_mbqi = true; diff --git a/src/muz_qe/pdr_smt_context_manager.cpp b/src/muz_qe/pdr_smt_context_manager.cpp index c9dcf7b4e..704967686 100644 --- a/src/muz_qe/pdr_smt_context_manager.cpp +++ b/src/muz_qe/pdr_smt_context_manager.cpp @@ -21,7 +21,7 @@ Revision History: #include "has_free_vars.h" #include "ast_pp.h" #include -#include "front_end_params.h" +#include "smt_params.h" namespace pdr { @@ -93,7 +93,7 @@ namespace pdr { return m_context.get_proof(); } - smt_context_manager::smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m): + smt_context_manager::smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m): m_fparams(fp), m(m), m_max_num_contexts(p.get_uint("max_num_contexts", 500)), diff --git a/src/muz_qe/pdr_smt_context_manager.h b/src/muz_qe/pdr_smt_context_manager.h index 31fb8ccb3..342100ed0 100644 --- a/src/muz_qe/pdr_smt_context_manager.h +++ b/src/muz_qe/pdr_smt_context_manager.h @@ -88,7 +88,7 @@ namespace pdr { }; class smt_context_manager { - front_end_params& m_fparams; + smt_params& m_fparams; ast_manager& m; unsigned m_max_num_contexts; ptr_vector m_contexts; @@ -96,7 +96,7 @@ namespace pdr { app_ref_vector m_predicate_list; func_decl_set m_predicate_set; public: - smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m); + smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m); ~smt_context_manager(); smt_context* mk_fresh(); void collect_statistics(statistics& st) const; diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index db11b5b20..934a038d2 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -30,7 +30,7 @@ Notes: #include "bool_rewriter.h" #include "dl_util.h" #include "for_each_expr.h" -#include "front_end_params.h" +#include "smt_params.h" #include "model.h" #include "model_v2_pp.h" #include "ref_vector.h" diff --git a/src/muz_qe/qe.cpp b/src/muz_qe/qe.cpp index 3b854b250..bb65f8bf8 100644 --- a/src/muz_qe/qe.cpp +++ b/src/muz_qe/qe.cpp @@ -1319,7 +1319,7 @@ namespace qe { public: - quant_elim_plugin(ast_manager& m, quant_elim& qe, front_end_params& p): + quant_elim_plugin(ast_manager& m, quant_elim& qe, smt_params& p): m(m), m_qe(qe), m_rewriter(m), @@ -1959,7 +1959,7 @@ namespace qe { class quant_elim_new : public quant_elim { ast_manager& m; - front_end_params& m_fparams; + smt_params& m_fparams; expr_ref m_assumption; bool m_produce_models; ptr_vector m_plugins; @@ -1968,7 +1968,7 @@ namespace qe { bool m_eliminate_variables_as_block; public: - quant_elim_new(ast_manager& m, front_end_params& p) : + quant_elim_new(ast_manager& m, smt_params& p) : m(m), m_fparams(p), m_assumption(m), @@ -2165,7 +2165,7 @@ namespace qe { // ------------------------------------------------ // expr_quant_elim - expr_quant_elim::expr_quant_elim(ast_manager& m, front_end_params const& fp, params_ref const& p): + expr_quant_elim::expr_quant_elim(ast_manager& m, smt_params const& fp, params_ref const& p): m(m), m_fparams(fp), m_params(p), @@ -2212,7 +2212,7 @@ namespace qe { void expr_quant_elim::init_qe() { if (!m_qe) { - m_qe = alloc(quant_elim_new, m, const_cast(m_fparams)); + m_qe = alloc(quant_elim_new, m, const_cast(m_fparams)); } } @@ -2399,7 +2399,7 @@ namespace qe { cache_result(q, r, pr); } - expr_quant_elim_star1::expr_quant_elim_star1(ast_manager& m, front_end_params const& p): + expr_quant_elim_star1::expr_quant_elim_star1(ast_manager& m, smt_params const& p): simplifier(m), m_quant_elim(m, p), m_assumption(m.mk_true()) { } @@ -2437,7 +2437,7 @@ namespace qe { class simplify_solver_context : public i_solver_context { ast_manager& m; - front_end_params m_fparams; + smt_params m_fparams; app_ref_vector* m_vars; expr_ref* m_fml; ptr_vector m_contains; @@ -2612,7 +2612,7 @@ namespace qe { } void simplify_exists(app_ref_vector& vars, expr_ref& fml) { - front_end_params params; + smt_params params; ast_manager& m = fml.get_manager(); simplify_solver_context ctx(m); ctx.solve(fml, vars); diff --git a/src/muz_qe/qe.h b/src/muz_qe/qe.h index 4ca098f73..1697a5cbd 100644 --- a/src/muz_qe/qe.h +++ b/src/muz_qe/qe.h @@ -22,7 +22,7 @@ Revision History: #define __QE_H__ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "statistics.h" #include "lbool.h" #include "expr_functors.h" @@ -221,7 +221,7 @@ namespace qe { qe_solver_plugin* mk_array_plugin(i_solver_context& ctx); - qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, front_end_params& p); + qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, smt_params& p); class def_vector { func_decl_ref_vector m_vars; @@ -275,7 +275,7 @@ namespace qe { class expr_quant_elim { ast_manager& m; - front_end_params const& m_fparams; + smt_params const& m_fparams; params_ref m_params; expr_ref_vector m_trail; obj_map m_visited; @@ -283,7 +283,7 @@ namespace qe { expr* m_assumption; bool m_use_new_qe; public: - expr_quant_elim(ast_manager& m, front_end_params const& fp, params_ref const& p = params_ref()); + expr_quant_elim(ast_manager& m, smt_params const& fp, params_ref const& p = params_ref()); ~expr_quant_elim(); void operator()(expr* assumption, expr* fml, expr_ref& result); @@ -331,7 +331,7 @@ namespace qe { virtual void reduce1_quantifier(quantifier * q); virtual bool is_target(quantifier * q) const { return q->get_num_patterns() == 0 && q->get_num_no_patterns() == 0; } public: - expr_quant_elim_star1(ast_manager & m, front_end_params const& p); + expr_quant_elim_star1(ast_manager & m, smt_params const& p); virtual ~expr_quant_elim_star1() {} void collect_statistics(statistics & st) const { diff --git a/src/muz_qe/qe_arith_plugin.cpp b/src/muz_qe/qe_arith_plugin.cpp index 14cb5ee53..69c036639 100644 --- a/src/muz_qe/qe_arith_plugin.cpp +++ b/src/muz_qe/qe_arith_plugin.cpp @@ -98,7 +98,7 @@ namespace qe { bool_rewriter m_bool_rewriter; arith_rewriter m_arith_rewriter; - arith_qe_util(ast_manager& m, front_end_params& p, i_solver_context& ctx) : + arith_qe_util(ast_manager& m, smt_params& p, i_solver_context& ctx) : m(m), m_ctx(ctx), m_arith(m), @@ -1511,7 +1511,7 @@ public: subst_cache m_subst; public: - arith_plugin(i_solver_context& ctx, ast_manager& m, front_end_params& p): + arith_plugin(i_solver_context& ctx, ast_manager& m, smt_params& p): qe_solver_plugin(m, m.get_family_id("arith"), ctx), m_util(m, p, ctx), m_trail(m) @@ -2562,7 +2562,7 @@ public: }; - qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, front_end_params& p) { + qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, smt_params& p) { if (p.m_nlquant_elim) { return alloc(nlarith_plugin, ctx, ctx.get_manager(), produce_models); } diff --git a/src/muz_qe/qe_cmd.cpp b/src/muz_qe/qe_cmd.cpp index ef8d1c058..6f001c9da 100644 --- a/src/muz_qe/qe_cmd.cpp +++ b/src/muz_qe/qe_cmd.cpp @@ -38,7 +38,7 @@ public: } virtual void execute(cmd_context & ctx) { - front_end_params par; + smt_params par; proof_ref pr(ctx.m()); qe::expr_quant_elim_star1 qe(ctx.m(), par); expr_ref result(ctx.m()); diff --git a/src/muz_qe/qe_sat_tactic.cpp b/src/muz_qe/qe_sat_tactic.cpp index 5f73e4a30..f33de6382 100644 --- a/src/muz_qe/qe_sat_tactic.cpp +++ b/src/muz_qe/qe_sat_tactic.cpp @@ -59,7 +59,7 @@ namespace qe { ast_manager& m; expr_ref m_false; volatile bool m_cancel; - front_end_params m_fparams; + smt_params m_fparams; params_ref m_params; unsigned m_extrapolate_strategy_param; bool m_projection_mode_param; diff --git a/src/muz_qe/qe_tactic.cpp b/src/muz_qe/qe_tactic.cpp index 971d677ea..5b522e041 100644 --- a/src/muz_qe/qe_tactic.cpp +++ b/src/muz_qe/qe_tactic.cpp @@ -24,7 +24,7 @@ Revision History: class qe_tactic : public tactic { struct imp { ast_manager & m; - front_end_params m_fparams; + smt_params m_fparams; volatile bool m_cancel; qe::expr_quant_elim m_qe; diff --git a/src/muz_qe/unit_subsumption_tactic.cpp b/src/muz_qe/unit_subsumption_tactic.cpp index cd43e73e3..1fb71490d 100644 --- a/src/muz_qe/unit_subsumption_tactic.cpp +++ b/src/muz_qe/unit_subsumption_tactic.cpp @@ -21,7 +21,7 @@ Author: struct unit_subsumption_tactic : public tactic { ast_manager& m; params_ref m_params; - front_end_params m_fparams; + smt_params m_fparams; volatile bool m_cancel; smt::context m_context; expr_ref_vector m_clauses; diff --git a/src/muz_qe/vsubst_tactic.cpp b/src/muz_qe/vsubst_tactic.cpp index 83e1c448b..b84202ee9 100644 --- a/src/muz_qe/vsubst_tactic.cpp +++ b/src/muz_qe/vsubst_tactic.cpp @@ -45,7 +45,7 @@ Notes: #include"arith_decl_plugin.h" #include"for_each_expr.h" #include"extension_model_converter.h" -#include"params2front_end_params.h" +#include"params2smt_params.h" #include"ast_smt2_pp.h" class vsubst_tactic : public tactic { @@ -93,8 +93,8 @@ class vsubst_tactic : public tactic { throw tactic_exception("there are no real variables"); } - front_end_params params; - params2front_end_params(p, params); + smt_params params; + params2smt_params(p, params); params.m_model = false; flet fl1(params.m_nlquant_elim, true); flet fl2(params.m_nl_arith_gb, false); diff --git a/src/parsers/smt/smtparser.cpp b/src/parsers/smt/smtparser.cpp index 53dffb28c..d3b2feeb7 100644 --- a/src/parsers/smt/smtparser.cpp +++ b/src/parsers/smt/smtparser.cpp @@ -37,7 +37,6 @@ Revision History: #include"var_subst.h" #include"well_sorted.h" #include"str_hashtable.h" -#include"front_end_params.h" #include"stopwatch.h" class id_param_info { diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index 4bfe2a545..c4aab9111 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -25,7 +25,7 @@ Revision History: #undef min #undef max #endif -#include"front_end_params.h" +#include"smt_params.h" #include"datalog_parser.h" #include"arith_decl_plugin.h" #include"dl_compiler.h" @@ -43,7 +43,7 @@ static datalog::context * g_ctx = 0; static datalog::rule_set * g_orig_rules; static datalog::instruction_block * g_code; static datalog::execution_context * g_ectx; -static front_end_params * g_params; +static smt_params * g_params; datalog_params::datalog_params(): m_default_table("sparse"), @@ -61,7 +61,7 @@ static void display_statistics( datalog::rule_set& orig_rules, datalog::instruction_block& code, datalog::execution_context& ex_ctx, - front_end_params& params, + smt_params& params, bool verbose ) { @@ -125,8 +125,10 @@ static void on_ctrl_c(int) { } -unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params) { +unsigned read_datalog(char const * file) { IF_VERBOSE(1, verbose_stream() << "Z3 Datalog Engine\n";); + datalog_params dl_params; + smt_params s_params; ast_manager m; g_overall_time.start(); register_on_timeout_proc(on_timeout); @@ -136,11 +138,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ params.set_sym("default_table", dl_params.m_default_table); params.set_bool("default_table_checked", dl_params.m_default_table_checked); - datalog::context ctx(m, front_end_params, params); - size_t watermark = front_end_params.m_memory_high_watermark; - if (watermark == 0) { - memory::set_high_watermark(static_cast(UINT_MAX)); - } + datalog::context ctx(m, s_params, params); datalog::relation_manager & rmgr = ctx.get_rmanager(); datalog::relation_plugin & inner_plg = *rmgr.get_relation_plugin(symbol("tr_hashtable")); SASSERT(&inner_plg); @@ -190,7 +188,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ g_orig_rules = &original_rules; g_code = &rules_code; g_ectx = &ex_ctx; - g_params = &front_end_params; + g_params = &s_params; try { g_piece_timer.reset(); @@ -262,7 +260,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ original_rules, rules_code, ex_ctx, - front_end_params, + s_params, false); } @@ -274,7 +272,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ original_rules, rules_code, ex_ctx, - front_end_params, + s_params, true); return ERR_MEMOUT; } diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index bf4194ef4..e53e35c89 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -25,7 +25,7 @@ struct datalog_params { datalog_params(); }; -unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); +unsigned read_datalog(char const * file); #endif /* _DATALOG_FRONTEND_H_ */ diff --git a/src/shell/main.cpp b/src/shell/main.cpp index ecbaf8887..fb205c872 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -41,7 +41,6 @@ std::string g_aux_input_file; char const * g_input_file = 0; bool g_standard_input = false; input_kind g_input_kind = IN_UNSPECIFIED; -front_end_params * g_front_end_params = 0; bool g_display_statistics = false; bool g_display_istatistics = false; @@ -98,36 +97,7 @@ void display_usage() { std::cout << " " << OPT << "dbg:tag enable assertions tagged with .\n"; #endif } - -class extra_params : public datalog_params { - bool & m_statistics; -public: - extra_params(): - m_statistics(g_display_statistics) { - } - - virtual ~extra_params() {} -}; - -extra_params* g_extra_params = 0; -bool g_params_initialized = false; - -void init_params() { - if (!g_params_initialized) { - z3_bound_num_procs(); - g_front_end_params = new front_end_params(); - g_extra_params = new extra_params(); - g_params_initialized = true; - } -} - -void del_params() { - delete g_extra_params; - delete g_front_end_params; - g_extra_params = 0; - g_front_end_params = 0; -} - + void parse_cmd_line_args(int argc, char ** argv) { int i = 1; char * eq_pos = 0; @@ -200,18 +170,9 @@ void parse_cmd_line_args(int argc, char ** argv) { long lvl = strtol(opt_arg, 0, 10); set_verbosity_level(lvl); } - else if (strcmp(opt_name, "vldt") == 0) { - g_front_end_params->m_model_validate = true; - } else if (strcmp(opt_name, "file") == 0) { g_input_file = opt_arg; } - else if (strcmp(opt_name, "r") == 0) { - if (!opt_arg) { - error("optional argument (/r:level) is missing."); - } - g_front_end_params->m_relevancy_lvl = strtol(opt_arg, 0, 10); - } else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) error("option argument (/T:timeout) is missing."); @@ -221,8 +182,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "t") == 0) { if (!opt_arg) error("option argument (/t:timeout) is missing."); - long tm = strtol(opt_arg, 0, 10); - g_front_end_params->m_soft_timeout = tm*1000; + gparams::set("timeout", opt_arg); } else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); @@ -248,7 +208,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "memory") == 0) { if (!opt_arg) error("option argument (/memory:val) is missing."); - g_front_end_params->m_memory_high_watermark = strtoul(opt_arg, 0, 10); + gparams::set("memory_max_size", opt_arg); } else { std::cerr << "Error: invalid command line option: " << arg << "\n"; @@ -288,27 +248,10 @@ char const * get_extension(char const * file_name) { } } -class global_state_initialiser { -public: - global_state_initialiser() { - memory::initialize(0); - init_params(); - } - - void reset() { - del_params(); - memory::finalize(); - } - - ~global_state_initialiser() { - reset(); - } -}; - int main(int argc, char ** argv) { try{ unsigned return_value = 0; - global_state_initialiser global_state; + memory::initialize(0); memory::exit_when_out_of_memory(true, "ERROR: out of memory"); parse_cmd_line_args(argc, argv); env_params::updt_params(); @@ -353,7 +296,7 @@ int main(int argc, char ** argv) { return_value = read_dimacs(g_input_file); break; case IN_DATALOG: - read_datalog(g_input_file, *g_extra_params, *g_front_end_params); + read_datalog(g_input_file); break; case IN_Z3_LOG: replay_z3_log(g_input_file); @@ -361,7 +304,6 @@ int main(int argc, char ** argv) { default: UNREACHABLE(); } - global_state.reset(); #ifdef _WINDOWS _CrtDumpMemoryLeaks(); #endif diff --git a/src/shell/smtlib_frontend.h b/src/shell/smtlib_frontend.h index d83944119..2c5eed70c 100644 --- a/src/shell/smtlib_frontend.h +++ b/src/shell/smtlib_frontend.h @@ -19,8 +19,6 @@ Revision History: #ifndef _SMTLIB_FRONTEND_H_ #define _SMTLIB_FRONTEND_H_ -#include"front_end_params.h" - unsigned read_smtlib_file(char const * benchmark_file); unsigned read_smtlib2_commands(char const * command_file); diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 513aa7634..6da2c15f5 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -40,7 +40,7 @@ Revision History: #include"distribute_forall.h" #include"quasi_macros.h" -asserted_formulas::asserted_formulas(ast_manager & m, front_end_params & p): +asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p): m_manager(m), m_params(p), m_pre_simplifier(m), diff --git a/src/smt/asserted_formulas.h b/src/smt/asserted_formulas.h index 23be4ae7c..e888a974e 100644 --- a/src/smt/asserted_formulas.h +++ b/src/smt/asserted_formulas.h @@ -19,7 +19,7 @@ Revision History: #ifndef _ASSERTED_FORMULAS_H_ #define _ASSERTED_FORMULAS_H_ -#include"front_end_params.h" +#include"smt_params.h" #include"simplifier.h" #include"basic_simplifier_plugin.h" #include"static_features.h" @@ -36,7 +36,7 @@ class bv_simplifier_plugin; class asserted_formulas { ast_manager & m_manager; - front_end_params & m_params; + smt_params & m_params; simplifier m_pre_simplifier; simplifier m_simplifier; basic_simplifier_plugin * m_bsimp; @@ -100,7 +100,7 @@ class asserted_formulas { bool canceled() { return m_cancel_flag; } public: - asserted_formulas(ast_manager & m, front_end_params & p); + asserted_formulas(ast_manager & m, smt_params & p); ~asserted_formulas(); void setup(); diff --git a/src/smt/expr_context_simplifier.cpp b/src/smt/expr_context_simplifier.cpp index 8fd5b41bb..b23bb3bdc 100644 --- a/src/smt/expr_context_simplifier.cpp +++ b/src/smt/expr_context_simplifier.cpp @@ -310,7 +310,7 @@ bool expr_context_simplifier::is_false(expr* e) const { // it occurs in the context (on the path) where it was inserted. // -expr_strong_context_simplifier::expr_strong_context_simplifier(front_end_params& p, ast_manager& m): +expr_strong_context_simplifier::expr_strong_context_simplifier(smt_params& p, ast_manager& m): m_manager(m), m_params(p), m_arith(m), m_id(0), m_fn(0,m), m_solver(m, p) { sort* i_sort = m_arith.mk_int(); m_fn = m.mk_func_decl(symbol(0xbeef101), i_sort, m.mk_bool_sort()); diff --git a/src/smt/expr_context_simplifier.h b/src/smt/expr_context_simplifier.h index 6e13dcf43..2c1f32ddc 100644 --- a/src/smt/expr_context_simplifier.h +++ b/src/smt/expr_context_simplifier.h @@ -22,7 +22,7 @@ Revision History: #include "ast.h" #include "obj_hashtable.h" #include "basic_simplifier_plugin.h" -#include "front_end_params.h" +#include "smt_params.h" #include "smt_kernel.h" #include "arith_decl_plugin.h" @@ -57,7 +57,7 @@ private: class expr_strong_context_simplifier { ast_manager& m_manager; - front_end_params & m_params; + smt_params & m_params; arith_util m_arith; unsigned m_id; func_decl_ref m_fn; @@ -70,7 +70,7 @@ class expr_strong_context_simplifier { bool is_forced(expr* e, expr* v); public: - expr_strong_context_simplifier(front_end_params& p, ast_manager& m); + expr_strong_context_simplifier(smt_params& p, ast_manager& m); void operator()(expr* e, expr_ref& result) { simplify(e, result); } void operator()(expr_ref& result) { simplify(result.get(), result); } void push() { m_solver.push(); } diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 808284224..7a03224cf 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -278,7 +278,7 @@ namespace smt { }; typedef int_hashtable > bool_var_set; context & m_context; - front_end_params &m_params; + smt_params &m_params; ast_manager & m_manager; ptr_vector m_queue; unsigned m_head; @@ -287,7 +287,7 @@ namespace smt { unsigned m_head2; svector m_scopes; public: - rel_case_split_queue(context & ctx, front_end_params & p): + rel_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_params(p), m_manager(ctx.get_manager()), @@ -465,14 +465,14 @@ namespace smt { typedef int_hashtable > bool_var_set; context & m_context; ast_manager & m_manager; - front_end_params &m_params; + smt_params &m_params; ptr_vector m_queue; unsigned m_head; int m_bs_num_bool_vars; //!< Number of boolean variable before starting to search. bool_var_act_queue m_delayed_queue; svector m_scopes; public: - rel_act_case_split_queue(context & ctx, front_end_params & p): + rel_act_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_manager(ctx.get_manager()), m_params(p), @@ -694,7 +694,7 @@ namespace smt { typedef int_hashtable > bool_var_set; context & m_context; - front_end_params & m_params; + smt_params & m_params; ast_manager & m_manager; ptr_vector m_queue; unsigned m_head; @@ -714,7 +714,7 @@ namespace smt { public: - rel_goal_case_split_queue(context & ctx, front_end_params & p): + rel_goal_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_params(p), m_manager(ctx.get_manager()), @@ -1088,7 +1088,7 @@ namespace smt { }; - case_split_queue * mk_case_split_queue(context & ctx, front_end_params & p) { + case_split_queue * mk_case_split_queue(context & ctx, smt_params & p) { if (p.m_relevancy_lvl < 2 && (p.m_case_split_strategy == CS_RELEVANCY || p.m_case_split_strategy == CS_RELEVANCY_ACTIVITY || p.m_case_split_strategy == CS_RELEVANCY_GOAL)) { warning_msg("relevacy must be enabled to use option CASE_SPLIT=3, 4 or 5"); diff --git a/src/smt/smt_case_split_queue.h b/src/smt/smt_case_split_queue.h index 106b97e38..d78739df1 100644 --- a/src/smt/smt_case_split_queue.h +++ b/src/smt/smt_case_split_queue.h @@ -48,7 +48,7 @@ namespace smt { virtual ~case_split_queue() {} }; - case_split_queue * mk_case_split_queue(context & ctx, front_end_params & p); + case_split_queue * mk_case_split_queue(context & ctx, smt_params & p); }; #endif /* _SMT_CASE_SPLIT_QUEUE_H_ */ diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 071275dd4..d34aa2ec8 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -32,7 +32,7 @@ namespace smt { conflict_resolution::conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dyn_ack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ): @@ -1419,7 +1419,7 @@ namespace smt { conflict_resolution * mk_conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches) { return alloc(conflict_resolution, m, ctx, dack_manager, params, assigned_literals, watches); diff --git a/src/smt/smt_conflict_resolution.h b/src/smt/smt_conflict_resolution.h index 5287b4e26..a55b331dc 100644 --- a/src/smt/smt_conflict_resolution.h +++ b/src/smt/smt_conflict_resolution.h @@ -25,7 +25,7 @@ Revision History: #include"smt_enode.h" #include"dyn_ack.h" #include"obj_pair_hashtable.h" -#include"front_end_params.h" +#include"smt_params.h" #include"obj_pair_hashtable.h" #include"map.h" #include"watch_list.h" @@ -46,7 +46,7 @@ namespace smt { typedef obj_pair_set enode_pair_set; ast_manager & m_manager; - front_end_params const & m_params; + smt_params const & m_params; context & m_ctx; dyn_ack_manager & m_dyn_ack_manager; literal_vector const & m_assigned_literals; @@ -204,7 +204,7 @@ namespace smt { conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ); @@ -266,7 +266,7 @@ namespace smt { conflict_resolution * mk_conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 3fb8398b4..a7623832f 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -39,7 +39,7 @@ Revision History: namespace smt { - context::context(ast_manager & m, front_end_params & p, params_ref const & _p): + context::context(ast_manager & m, smt_params & p, params_ref const & _p): m_manager(m), m_fparams(p), m_params(_p), @@ -102,7 +102,7 @@ namespace smt { flush(); } - context * context::mk_fresh(symbol const * l, front_end_params * p) { + context * context::mk_fresh(symbol const * l, smt_params * p) { context * new_ctx = alloc(context, m_manager, p == 0 ? m_fparams : *p); new_ctx->set_logic(l == 0 ? m_setup.get_logic() : *l); // copy missing simplifier_plugins diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 204a56827..7940b17be 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -71,7 +71,7 @@ namespace smt { protected: ast_manager & m_manager; - front_end_params & m_fparams; + smt_params & m_fparams; params_ref m_params; setup m_setup; volatile bool m_cancel_flag; @@ -220,7 +220,7 @@ namespace smt { return m_asserted_formulas.get_simplifier(); } - front_end_params & get_fparams() { + smt_params & get_fparams() { return m_fparams; } @@ -1314,7 +1314,7 @@ namespace smt { void assert_expr_core(expr * e, proof * pr); public: - context(ast_manager & m, front_end_params & fp, params_ref const & p = params_ref()); + context(ast_manager & m, smt_params & fp, params_ref const & p = params_ref()); virtual ~context(); @@ -1325,7 +1325,7 @@ namespace smt { If l == 0, then the logic of this context is used in the new context. If p == 0, then this->m_params is used */ - context * mk_fresh(symbol const * l = 0, front_end_params * p = 0); + context * mk_fresh(symbol const * l = 0, smt_params * p = 0); app * mk_eq_atom(expr * lhs, expr * rhs); diff --git a/src/smt/smt_kernel.cpp b/src/smt/smt_kernel.cpp index 9d87b1363..977f0ee4a 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -19,7 +19,7 @@ Revision History: #include"smt_kernel.h" #include"smt_context.h" #include"ast_smt2_pp.h" -#include"params2front_end_params.h" +#include"params2smt_params.h" namespace smt { @@ -27,12 +27,12 @@ namespace smt { smt::context m_kernel; params_ref m_params; - imp(ast_manager & m, front_end_params & fp, params_ref const & p): + imp(ast_manager & m, smt_params & fp, params_ref const & p): m_kernel(m, fp, p), m_params(p) { } - front_end_params & fparams() { + smt_params & fparams() { return m_kernel.get_fparams(); } @@ -179,11 +179,11 @@ namespace smt { } void updt_params(params_ref const & p) { - params2front_end_params(p, fparams()); + params2smt_params(p, fparams()); } }; - kernel::kernel(ast_manager & m, front_end_params & fp, params_ref const & p) { + kernel::kernel(ast_manager & m, smt_params & fp, params_ref const & p) { m_imp = alloc(imp, m, fp, p); } @@ -237,7 +237,7 @@ namespace smt { void kernel::reset() { ast_manager & _m = m(); - front_end_params & fps = m_imp->fparams(); + smt_params & fps = m_imp->fparams(); params_ref ps = m_imp->params(); #pragma omp critical (smt_kernel) { @@ -343,7 +343,7 @@ namespace smt { } void kernel::collect_param_descrs(param_descrs & d) { - solver_front_end_params_descrs(d); + solver_smt_params_descrs(d); } context & kernel::get_context() { diff --git a/src/smt/smt_kernel.h b/src/smt/smt_kernel.h index 4c381e113..37b044af1 100644 --- a/src/smt/smt_kernel.h +++ b/src/smt/smt_kernel.h @@ -34,7 +34,7 @@ Revision History: #include"statistics.h" #include"smt_failure.h" -struct front_end_params; +struct smt_params; class progress_callback; namespace smt { @@ -46,7 +46,7 @@ namespace smt { struct imp; imp * m_imp; public: - kernel(ast_manager & m, front_end_params & fp, params_ref const & p = params_ref()); + kernel(ast_manager & m, smt_params & fp, params_ref const & p = params_ref()); ~kernel(); diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index 58921bb35..704c272ee 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -281,7 +281,7 @@ namespace smt { void model_checker::init_aux_context() { if (!m_fparams) { - m_fparams = alloc(front_end_params, m_context->get_fparams()); + m_fparams = alloc(smt_params, m_context->get_fparams()); m_fparams->m_relevancy_lvl = 0; // no relevancy since the model checking problems are quantifier free } if (!m_aux_context) { diff --git a/src/smt/smt_model_checker.h b/src/smt/smt_model_checker.h index fca576090..5af7859ce 100644 --- a/src/smt/smt_model_checker.h +++ b/src/smt/smt_model_checker.h @@ -24,7 +24,7 @@ Revision History: #include"ast.h" #include"obj_hashtable.h" #include"qi_params.h" -#include"front_end_params.h" +#include"smt_params.h" #include"region.h" class proto_model; @@ -39,9 +39,9 @@ namespace smt { class model_checker { ast_manager & m_manager; qi_params const & m_params; - // copy of front_end_params for auxiliary context. + // copy of smt_params for auxiliary context. // the idea is to use a different configuration for the aux context (e.g., disable relevancy) - scoped_ptr m_fparams; + scoped_ptr m_fparams; quantifier_manager * m_qm; context * m_context; // owner of the model checker obj_map const * m_root2value; // temp field to store mapping received in the check method. diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 14e63b982..799dd3c49 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -33,7 +33,7 @@ namespace smt { struct quantifier_manager::imp { quantifier_manager & m_wrapper; context & m_context; - front_end_params & m_params; + smt_params & m_params; qi_queue m_qi_queue; obj_map m_quantifier_stat; quantifier_stat_gen m_qstat_gen; @@ -41,7 +41,7 @@ namespace smt { scoped_ptr m_plugin; unsigned m_num_instances; - imp(quantifier_manager & wrapper, context & ctx, front_end_params & p, quantifier_manager_plugin * plugin): + imp(quantifier_manager & wrapper, context & ctx, smt_params & p, quantifier_manager_plugin * plugin): m_wrapper(wrapper), m_context(ctx), m_params(p), @@ -242,7 +242,7 @@ namespace smt { }; - quantifier_manager::quantifier_manager(context & ctx, front_end_params & fp, params_ref const & p) { + quantifier_manager::quantifier_manager(context & ctx, smt_params & fp, params_ref const & p) { m_imp = alloc(imp, *this, ctx, fp, mk_default_plugin()); m_imp->m_plugin->set_manager(*this); } @@ -355,7 +355,7 @@ namespace smt { #pragma omp critical (quantifier_manager) { context & ctx = m_imp->m_context; - front_end_params & p = m_imp->m_params; + smt_params & p = m_imp->m_params; quantifier_manager_plugin * plugin = m_imp->m_plugin->mk_fresh(); dealloc(m_imp); m_imp = alloc(imp, *this, ctx, p, plugin); @@ -395,7 +395,7 @@ namespace smt { // The default plugin uses E-matching, MBQI and quick-checker class default_qm_plugin : public quantifier_manager_plugin { quantifier_manager * m_qm; - front_end_params * m_fparams; + smt_params * m_fparams; context * m_context; scoped_ptr m_mam; scoped_ptr m_lazy_mam; diff --git a/src/smt/smt_quantifier.h b/src/smt/smt_quantifier.h index 3873c9737..19113229c 100644 --- a/src/smt/smt_quantifier.h +++ b/src/smt/smt_quantifier.h @@ -25,7 +25,7 @@ Revision History: #include"smt_types.h" class proto_model; -struct front_end_params; +struct smt_params; namespace smt { class quantifier_manager_plugin; @@ -35,7 +35,7 @@ namespace smt { struct imp; imp * m_imp; public: - quantifier_manager(context & ctx, front_end_params & fp, params_ref const & p); + quantifier_manager(context & ctx, smt_params & fp, params_ref const & p); ~quantifier_manager(); context & get_context() const; diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index ac080ccaa..f088870a4 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -33,7 +33,7 @@ Revision History: namespace smt { - setup::setup(context & c, front_end_params & params): + setup::setup(context & c, smt_params & params): m_context(c), m_manager(c.get_manager()), m_params(params), diff --git a/src/smt/smt_setup.h b/src/smt/smt_setup.h index 5c017a498..e0188537e 100644 --- a/src/smt/smt_setup.h +++ b/src/smt/smt_setup.h @@ -20,7 +20,7 @@ Revision History: #define _SMT_SETUP_H_ #include"ast.h" -#include"front_end_params.h" +#include"smt_params.h" struct static_features; namespace smt { @@ -42,7 +42,7 @@ namespace smt { class setup { context & m_context; ast_manager & m_manager; - front_end_params & m_params; + smt_params & m_params; symbol m_logic; bool m_already_configured; void setup_auto_config(); @@ -96,7 +96,7 @@ namespace smt { void setup_i_arith(); void setup_mi_arith(); public: - setup(context & c, front_end_params & params); + setup(context & c, smt_params & params); void mark_already_configured() { m_already_configured = true; } bool already_configured() const { return m_already_configured; } bool set_logic(symbol logic) { diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 8807e1e2b..ad653a968 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -19,12 +19,12 @@ Notes: #include"solver_na2as.h" #include"smt_kernel.h" #include"reg_decl_plugins.h" -#include"front_end_params.h" +#include"smt_params.h" namespace smt { class solver : public solver_na2as { - front_end_params m_params; + smt_params m_params; smt::kernel * m_context; progress_callback * m_callback; public: diff --git a/src/smt/tactic/ctx_solver_simplify_tactic.cpp b/src/smt/tactic/ctx_solver_simplify_tactic.cpp index e5b625661..25c41c2a2 100644 --- a/src/smt/tactic/ctx_solver_simplify_tactic.cpp +++ b/src/smt/tactic/ctx_solver_simplify_tactic.cpp @@ -19,7 +19,7 @@ Notes: #include"ctx_solver_simplify_tactic.h" #include"arith_decl_plugin.h" -#include"front_end_params.h" +#include"smt_params.h" #include"smt_kernel.h" #include"ast_pp.h" #include"mk_simplified_app.h" @@ -28,7 +28,7 @@ Notes: class ctx_solver_simplify_tactic : public tactic { ast_manager& m; params_ref m_params; - front_end_params m_front_p; + smt_params m_front_p; smt::kernel m_solver; arith_util m_arith; mk_simplified_app m_mk_app; diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index c75e0d56b..a8694363c 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -19,12 +19,12 @@ Notes: #include"tactic.h" #include"tactical.h" #include"smt_kernel.h" -#include"front_end_params.h" -#include"params2front_end_params.h" +#include"smt_params.h" +#include"params2smt_params.h" #include"rewriter_types.h" class smt_tactic : public tactic { - front_end_params m_params; + smt_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -51,7 +51,7 @@ public: SASSERT(m_ctx == 0); } - front_end_params & fparams() { + smt_params & fparams() { return m_params; } @@ -64,15 +64,15 @@ public: TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); m_params_ref = p; - // PARAM-TODO update params2front_end_params p ---> m_params - params2front_end_params(m_params_ref, fparams()); + // PARAM-TODO update params2smt_params p ---> m_params + params2smt_params(m_params_ref, fparams()); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } virtual void collect_param_descrs(param_descrs & r) { r.insert("candidate_models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete."); r.insert("fail_if_inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal."); - solver_front_end_params_descrs(r); + solver_smt_params_descrs(r); } virtual void set_cancel(bool f) { diff --git a/src/smt/theory_diff_logic.h b/src/smt/theory_diff_logic.h index 80d729001..264ab9b2d 100644 --- a/src/smt/theory_diff_logic.h +++ b/src/smt/theory_diff_logic.h @@ -32,7 +32,7 @@ Revision History: #include"arith_decl_plugin.h" #include"smt_justification.h" #include"map.h" -#include"front_end_params.h" +#include"smt_params.h" #include"arith_eq_adapter.h" #include"smt_model_generator.h" #include"numeral_factory.h" @@ -251,7 +251,7 @@ namespace smt { } }; - front_end_params & m_params; + smt_params & m_params; arith_util m_util; arith_eq_adapter m_arith_eq_adapter; theory_diff_logic_statistics m_stats; @@ -305,7 +305,7 @@ namespace smt { void del_clause_eh(clause* cls); public: - theory_diff_logic(ast_manager& m, front_end_params & params): + theory_diff_logic(ast_manager& m, smt_params & params): theory(m.get_family_id("arith")), m_params(params), m_util(m), diff --git a/src/smt/theory_instgen.cpp b/src/smt/theory_instgen.cpp index f631fd04c..68e04aab0 100644 --- a/src/smt/theory_instgen.cpp +++ b/src/smt/theory_instgen.cpp @@ -230,12 +230,12 @@ namespace smt { class clause_subsumption { ast_manager& m; grounder m_grounder; - front_end_params m_params; + smt_params m_params; context m_ctx; quantifier_ref_vector m_assumptions; unsigned_vector m_limit; public: - clause_subsumption(ast_manager& m, front_end_params& p): + clause_subsumption(ast_manager& m, smt_params& p): m(m), m_grounder(m), m_params(p), m_ctx(m,m_params), m_assumptions(m) { m_params.m_instgen = false; } @@ -1131,7 +1131,7 @@ namespace smt { }; ast_manager& m_manager; - front_end_params& m_params; + smt_params& m_params; fo_clause_internalizer m_internalizer; instantiator m_instantiator; clause_subsumption m_subsumer; @@ -1184,7 +1184,7 @@ namespace smt { public: - theory_instgen_impl(ast_manager& m, front_end_params& p): + theory_instgen_impl(ast_manager& m, smt_params& p): theory_instgen(m.get_family_id("inst_gen")), m_manager(m), m_params(p), @@ -1277,7 +1277,7 @@ namespace smt { }; - theory_instgen* mk_theory_instgen(ast_manager& m, front_end_params& p) { + theory_instgen* mk_theory_instgen(ast_manager& m, smt_params& p) { return alloc(theory_instgen_impl, m, p); } diff --git a/src/smt/theory_instgen.h b/src/smt/theory_instgen.h index 076dad748..c32636e9b 100644 --- a/src/smt/theory_instgen.h +++ b/src/smt/theory_instgen.h @@ -25,7 +25,7 @@ Revision History: #define _THEORY_INST_GEN_H_ #include "smt_theory.h" -#include "front_end_params.h" +#include "smt_params.h" namespace smt { @@ -37,7 +37,7 @@ namespace smt { virtual char const * get_name() const { return "instgen"; } }; - theory_instgen* mk_theory_instgen(ast_manager& m, front_end_params& p); + theory_instgen* mk_theory_instgen(ast_manager& m, smt_params& p); }; diff --git a/src/smt/user_plugin/user_smt_theory.cpp b/src/smt/user_plugin/user_smt_theory.cpp index d95346469..ab4cc62c4 100644 --- a/src/smt/user_plugin/user_smt_theory.cpp +++ b/src/smt/user_plugin/user_smt_theory.cpp @@ -44,7 +44,7 @@ namespace smt { {} }; - user_theory::user_theory(ast_manager & m, front_end_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp): + user_theory::user_theory(ast_manager & m, smt_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp): theory(fid), m_params(p), m_ext_context(ext_context), diff --git a/src/smt/user_plugin/user_smt_theory.h b/src/smt/user_plugin/user_smt_theory.h index 3dd664738..56851b768 100644 --- a/src/smt/user_plugin/user_smt_theory.h +++ b/src/smt/user_plugin/user_smt_theory.h @@ -43,7 +43,7 @@ namespace smt { typedef union_find th_union_find; typedef std::pair var_pair; - front_end_params const& m_params; + smt_params const& m_params; void * m_ext_context; void * m_ext_data; std::string m_name; @@ -134,7 +134,7 @@ namespace smt { void assert_axiom_core(app* axiom); public: - user_theory(ast_manager & m, front_end_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp); + user_theory(ast_manager & m, smt_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp); virtual ~user_theory(); virtual theory * mk_fresh(context * new_ctx); diff --git a/src/solver/solver.h b/src/solver/solver.h index f26a5c5f4..5cd3da52b 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -23,8 +23,6 @@ Notes: #include"progress_callback.h" #include"params.h" -struct front_end_params; - /** \brief Abstract interface for making solvers available in the Z3 API and front-ends such as SMT 2.0 and (legacy) SMT 1.0. diff --git a/src/tactic/tactic.h b/src/tactic/tactic.h index 015b5fe0a..80de1bcd0 100644 --- a/src/tactic/tactic.h +++ b/src/tactic/tactic.h @@ -29,7 +29,6 @@ Notes: #include"tactic_exception.h" #include"lbool.h" -struct front_end_params; class progress_callback; typedef ptr_buffer goal_buffer; diff --git a/src/test/arith_simplifier_plugin.cpp b/src/test/arith_simplifier_plugin.cpp index 0ea1c2675..59f4996ce 100644 --- a/src/test/arith_simplifier_plugin.cpp +++ b/src/test/arith_simplifier_plugin.cpp @@ -1,5 +1,5 @@ #include "arith_eq_solver.h" -#include "front_end_params.h" +#include "smt_params.h" typedef rational numeral; typedef vector row; @@ -24,7 +24,7 @@ static void test_solve_integer_equations( } void tst_arith_simplifier_plugin() { - front_end_params params; + smt_params params; ast_manager m; arith_eq_solver asimp(m); diff --git a/src/test/check_assumptions.cpp b/src/test/check_assumptions.cpp index e6a5433e9..872af714c 100644 --- a/src/test/check_assumptions.cpp +++ b/src/test/check_assumptions.cpp @@ -1,5 +1,5 @@ #include "memory_manager.h" -#include "front_end_params.h" +#include "smt_params.h" #include "ast.h" #include "arith_decl_plugin.h" #include "bv_decl_plugin.h" @@ -9,7 +9,7 @@ void tst_check_assumptions() { memory::initialize(0); - front_end_params params; + smt_params params; ast_manager mgr; reg_decl_plugins(mgr); diff --git a/src/test/datalog_parser.cpp b/src/test/datalog_parser.cpp index 2d8a04225..64ee4201e 100644 --- a/src/test/datalog_parser.cpp +++ b/src/test/datalog_parser.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "arith_decl_plugin.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" #include "reg_decl_plugins.h" using namespace datalog; @@ -10,7 +10,7 @@ using namespace datalog; static void dparse_string(char const* str) { ast_manager m; - front_end_params params; + smt_params params; reg_decl_plugins(m); context ctx(m, params); @@ -37,7 +37,7 @@ static void dparse_string(char const* str) { static void dparse_file(char const* file) { ast_manager m; - front_end_params params; + smt_params params; reg_decl_plugins(m); context ctx(m, params); diff --git a/src/test/dl_context.cpp b/src/test/dl_context.cpp index b2530b9da..c004c531f 100644 --- a/src/test/dl_context.cpp +++ b/src/test/dl_context.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "arith_decl_plugin.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" using namespace datalog; @@ -27,7 +27,7 @@ static void dl_context_simple_query_test(params_ref & params) { ast_manager m; dl_decl_util decl_util(m); - front_end_params fparams; + smt_params fparams; context ctx(m, fparams); ctx.updt_params(params); @@ -49,7 +49,7 @@ static void dl_context_simple_query_test(params_ref & params) { void dl_context_saturate_file(params_ref & params, const char * f) { ast_manager m; dl_decl_util decl_util(m); - front_end_params fparams; + smt_params fparams; context ctx(m, fparams); ctx.updt_params(params); diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index ac895dacf..4b67b32af 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -19,7 +19,7 @@ namespace datalog { }; - void test_functional_columns(front_end_params fparams, params_ref& params) { + void test_functional_columns(smt_params fparams, params_ref& params) { ast_manager m; context ctx(m, fparams); ctx.updt_params(params); @@ -121,7 +121,7 @@ namespace datalog { } } - void test_finite_product_relation(front_end_params fparams, params_ref& params) { + void test_finite_product_relation(smt_params fparams, params_ref& params) { ast_manager m; context ctx(m, fparams); ctx.updt_params(params); @@ -338,7 +338,7 @@ namespace datalog { using namespace datalog; void tst_dl_product_relation() { - front_end_params fparams; + smt_params fparams; params_ref params; test_functional_columns(fparams, params); diff --git a/src/test/dl_query.cpp b/src/test/dl_query.cpp index 2cca7cce6..712ae386a 100644 --- a/src/test/dl_query.cpp +++ b/src/test/dl_query.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "dl_table_relation.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" #include "stopwatch.h" #include "reg_decl_plugins.h" @@ -43,7 +43,7 @@ void dl_query_ask_for_last_arg(context & ctx, func_decl * pred, relation_fact & } } -void dl_query_test(ast_manager & m, front_end_params & fparams, params_ref& params, +void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, context & ctx_b, char const* problem_file, unsigned test_count, bool use_magic_sets) { @@ -124,7 +124,7 @@ void dl_query_test(ast_manager & m, front_end_params & fparams, params_ref& para } } -void dl_query_test_wpa(front_end_params & fparams, params_ref& params) { +void dl_query_test_wpa(smt_params & fparams, params_ref& params) { params.set_bool(":magic-sets-for-queries", true); ast_manager m; reg_decl_plugins(m); @@ -183,7 +183,7 @@ void dl_query_test_wpa(front_end_params & fparams, params_ref& params) { } void tst_dl_query() { - front_end_params fparams; + smt_params fparams; params_ref params; params.set_sym(":default-table", symbol("sparse")); params.set_sym(":default-relation", symbol("tr_sparse")); diff --git a/src/test/dl_relation.cpp b/src/test/dl_relation.cpp index 095751cb6..fe8ba1730 100644 --- a/src/test/dl_relation.cpp +++ b/src/test/dl_relation.cpp @@ -8,7 +8,7 @@ namespace datalog { static void test_interval_relation() { - front_end_params params; + smt_params params; ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); @@ -111,7 +111,7 @@ namespace datalog { std::cout << "bound relation\n"; - front_end_params params; + smt_params params; ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); diff --git a/src/test/dl_smt_relation.cpp b/src/test/dl_smt_relation.cpp index fa66a89c9..bae1784b0 100644 --- a/src/test/dl_smt_relation.cpp +++ b/src/test/dl_smt_relation.cpp @@ -14,7 +14,7 @@ namespace datalog { arith_util a(m); sort* int_sort = a.mk_int(); sort* real_sort = a.mk_real(); - front_end_params params; + smt_params params; context ctx(m, params); relation_manager & rm = ctx.get_rmanager(); relation_signature sig1; diff --git a/src/test/dl_table.cpp b/src/test/dl_table.cpp index a29ef48d8..6383dc1ab 100644 --- a/src/test/dl_table.cpp +++ b/src/test/dl_table.cpp @@ -24,7 +24,7 @@ static void test_table(mk_table_fn mk_table) { sig.push_back(4); sig.push_back(8); sig.push_back(4); - front_end_params params; + smt_params params; ast_manager ast_m; datalog::context ctx(ast_m, params); datalog::relation_manager & m = ctx.get_rmanager(); diff --git a/src/test/model_retrieval.cpp b/src/test/model_retrieval.cpp index 0a0b8a0dc..da6c3ddd0 100644 --- a/src/test/model_retrieval.cpp +++ b/src/test/model_retrieval.cpp @@ -1,6 +1,6 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "smt_context.h" #include "arith_decl_plugin.h" #include "bv_decl_plugin.h" @@ -11,7 +11,7 @@ void tst_model_retrieval() { memory::initialize(0); - front_end_params params; + smt_params params; params.m_model = true; diff --git a/src/test/quant_elim.cpp b/src/test/quant_elim.cpp index 0f1ddfabd..4e750c34e 100644 --- a/src/test/quant_elim.cpp +++ b/src/test/quant_elim.cpp @@ -1,5 +1,5 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "simplifier.h" #include "qe.h" #include "basic_simplifier_plugin.h" @@ -33,7 +33,7 @@ static void test_qe(ast_manager& m, lbool expected_outcome, expr* fml, char cons // enable_trace("bv_bit_prop"); simplifier simp(m); - front_end_params params; + smt_params params; // params.m_quant_elim = true; std::cout << mk_pp(fml, m) << "\n"; diff --git a/src/test/quant_solve.cpp b/src/test/quant_solve.cpp index bae63f129..36b354b44 100644 --- a/src/test/quant_solve.cpp +++ b/src/test/quant_solve.cpp @@ -1,5 +1,5 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "qe.h" #include "arith_decl_plugin.h" #include "ast_pp.h" @@ -28,7 +28,7 @@ static void validate_quant_solution(ast_manager& m, expr* fml, expr* guard, qe:: (*rep)(fml1); expr_ref tmp(m); tmp = m.mk_not(m.mk_implies(guard, fml1)); - front_end_params fp; + smt_params fp; smt::kernel solver(m, fp); solver.assert_expr(tmp); lbool res = solver.check(); @@ -63,7 +63,7 @@ static void validate_quant_solutions(app* x, expr* fml, expr_ref_vector& guards) std::cout << mk_pp(fml2, m) << "\n"; tmp = m.mk_not(m.mk_iff(fml2, tmp)); std::cout << mk_pp(tmp, m) << "\n"; - front_end_params fp; + smt_params fp; smt::kernel solver(m, fp); solver.assert_expr(tmp); lbool res = solver.check(); @@ -78,7 +78,7 @@ static void validate_quant_solutions(app* x, expr* fml, expr_ref_vector& guards) static void test_quant_solver(ast_manager& m, unsigned sz, app*const* xs, expr* fml, bool validate) { - front_end_params params; + smt_params params; qe::expr_quant_elim qe(m, params); qe::guarded_defs defs(m); bool success = qe.solve_for_vars(sz, xs, fml, defs); @@ -98,8 +98,7 @@ static void test_quant_solver(ast_manager& m, unsigned sz, app*const* xs, expr* static expr_ref parse_fml(ast_manager& m, char const* str) { expr_ref result(m); - front_end_params fp; - cmd_context ctx(&fp, false, &m); + cmd_context ctx(false, &m); ctx.set_ignore_check(true); std::ostringstream buffer; buffer << "(declare-const x Int)\n" diff --git a/src/test/smt_context.cpp b/src/test/smt_context.cpp index 853bde068..49ada8ebd 100644 --- a/src/test/smt_context.cpp +++ b/src/test/smt_context.cpp @@ -3,7 +3,7 @@ void tst_smt_context() { - front_end_params params; + smt_params params; ast_manager m; reg_decl_plugins(m); diff --git a/src/test/substitution.cpp b/src/test/substitution.cpp index 38f85bb11..889666972 100644 --- a/src/test/substitution.cpp +++ b/src/test/substitution.cpp @@ -1,5 +1,5 @@ #include "expr_substitution.h" -#include "front_end_params.h" +#include "smt_params.h" #include "substitution.h" #include "unifier.h" #include "bv_decl_plugin.h" @@ -10,7 +10,7 @@ void tst_substitution() { memory::initialize(0); - front_end_params params; + smt_params params; params.m_model = true; enable_trace("subst_bug"); diff --git a/src/test/theory_dl.cpp b/src/test/theory_dl.cpp index d07ec34af..9521a8932 100644 --- a/src/test/theory_dl.cpp +++ b/src/test/theory_dl.cpp @@ -6,7 +6,7 @@ void tst_theory_dl() { ast_manager m; - front_end_params params; + smt_params params; params.m_model = true; datalog::dl_decl_util u(m); smt::context ctx(m, params); diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp index a76c2308b..28d80d92d 100644 --- a/src/util/env_params.cpp +++ b/src/util/env_params.cpp @@ -27,10 +27,12 @@ void env_params::updt_params() { set_verbosity_level(p.get_uint("verbose", get_verbosity_level())); enable_warning_messages(p.get_bool("warning", true)); memory::set_max_size(p.get_uint("memory_max_size", 0)); + memory::set_high_watermark(p.get_uint("memory_high_watermark", 0)); } void env_params::collect_param_descrs(param_descrs & d) { d.insert("verbose", CPK_UINT, "be verbose, where the value is the verbosity level", "0"); d.insert("warning", CPK_BOOL, "enable/disable warning messages", "true"); - d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no bound.", "0"); + d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no limit", "0"); + d.insert("memory_high_watermark", CPK_UINT, "set high watermark for memory consumption (in megabytes), if 0 then there is no limit", "0"); } From 6107e8d9ce0ac487740e92546a155370c028f164 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 10:47:04 -0800 Subject: [PATCH 080/133] moved old params files Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 14 +++---- .../pattern}/pattern_inference_params.h | 0 src/ast/proof_checker/proof_checker.cpp | 1 - .../bit_blaster}/bit_blaster_params.h | 0 .../simplifier}/arith_simplifier_params.h | 0 src/ast/simplifier/array_simplifier_params.h | 33 ++++++++++++++++ .../simplifier/array_simplifier_plugin.cpp | 2 +- src/ast/simplifier/array_simplifier_plugin.h | 6 +-- .../simplifier}/bv_simplifier_params.h | 6 --- .../arith_simplifier_params.cpp | 27 ------------- .../pattern_inference_params.cpp | 38 ------------------- src/{front_end_params => smt/params}/README | 0 .../params}/dyn_ack_params.cpp | 0 .../params}/dyn_ack_params.h | 0 .../params}/params2smt_params.cpp | 0 .../params}/params2smt_params.h | 0 .../params}/preprocessor_params.h | 0 .../params}/qi_params.h | 0 .../params}/smt_params.cpp | 0 .../params}/smt_params.h | 0 .../params}/theory_arith_params.cpp | 0 .../params}/theory_arith_params.h | 0 .../params}/theory_array_params.h | 10 ++--- .../params}/theory_bv_params.h | 0 .../params}/theory_datatype_params.h | 0 25 files changed, 47 insertions(+), 90 deletions(-) rename src/{front_end_params => ast/pattern}/pattern_inference_params.h (100%) rename src/{front_end_params => ast/rewriter/bit_blaster}/bit_blaster_params.h (100%) rename src/{front_end_params => ast/simplifier}/arith_simplifier_params.h (100%) create mode 100644 src/ast/simplifier/array_simplifier_params.h rename src/{front_end_params => ast/simplifier}/bv_simplifier_params.h (61%) delete mode 100644 src/front_end_params/arith_simplifier_params.cpp delete mode 100644 src/front_end_params/pattern_inference_params.cpp rename src/{front_end_params => smt/params}/README (100%) rename src/{front_end_params => smt/params}/dyn_ack_params.cpp (100%) rename src/{front_end_params => smt/params}/dyn_ack_params.h (100%) rename src/{front_end_params => smt/params}/params2smt_params.cpp (100%) rename src/{front_end_params => smt/params}/params2smt_params.h (100%) rename src/{front_end_params => smt/params}/preprocessor_params.h (100%) rename src/{front_end_params => smt/params}/qi_params.h (100%) rename src/{front_end_params => smt/params}/smt_params.cpp (100%) rename src/{front_end_params => smt/params}/smt_params.h (100%) rename src/{front_end_params => smt/params}/theory_arith_params.cpp (100%) rename src/{front_end_params => smt/params}/theory_arith_params.h (100%) rename src/{front_end_params => smt/params}/theory_array_params.h (88%) rename src/{front_end_params => smt/params}/theory_bv_params.h (100%) rename src/{front_end_params => smt/params}/theory_datatype_params.h (100%) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index ac6f44a83..707d067e2 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -35,17 +35,15 @@ def init_project_def(): add_lib('cmd_context', ['solver', 'rewriter']) add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds') add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2') - # Front-end-params module still contain a lot of parameters for smt solver component. - # This should be fixed - add_lib('front_end_params', ['ast']) + add_lib('proof_checker', ['rewriter'], 'ast/proof_checker') # Simplifier module will be deleted in the future. # It has been replaced with rewriter module. - add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') + add_lib('simplifier', ['rewriter'], 'ast/simplifier') + add_lib('macros', ['simplifier'], 'ast/macros') add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern') - add_lib('macros', ['simplifier', 'front_end_params'], 'ast/macros') - add_lib('proof_checker', ['rewriter', 'front_end_params'], 'ast/proof_checker') - add_lib('bit_blaster', ['rewriter', 'simplifier', 'front_end_params'], 'ast/rewriter/bit_blaster') - add_lib('proto_model', ['model', 'simplifier', 'front_end_params'], 'smt/proto_model') + add_lib('bit_blaster', ['rewriter', 'simplifier'], 'ast/rewriter/bit_blaster') + add_lib('smt_params', ['ast', 'simplifier', 'pattern', 'bit_blaster'], 'smt/params') + add_lib('proto_model', ['model', 'simplifier', 'smt_params'], 'smt/proto_model') add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model', 'substitution', 'grobner', 'euclid', 'proof_checker', 'pattern', 'parser_util']) add_lib('user_plugin', ['smt'], 'smt/user_plugin') diff --git a/src/front_end_params/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h similarity index 100% rename from src/front_end_params/pattern_inference_params.h rename to src/ast/pattern/pattern_inference_params.h diff --git a/src/ast/proof_checker/proof_checker.cpp b/src/ast/proof_checker/proof_checker.cpp index bef0fea9c..240504048 100644 --- a/src/ast/proof_checker/proof_checker.cpp +++ b/src/ast/proof_checker/proof_checker.cpp @@ -4,7 +4,6 @@ // include "spc_decl_plugin.h" #include "ast_smt_pp.h" #include "arith_decl_plugin.h" -#include "smt_params.h" #include "th_rewriter.h" #include "var_subst.h" diff --git a/src/front_end_params/bit_blaster_params.h b/src/ast/rewriter/bit_blaster/bit_blaster_params.h similarity index 100% rename from src/front_end_params/bit_blaster_params.h rename to src/ast/rewriter/bit_blaster/bit_blaster_params.h diff --git a/src/front_end_params/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h similarity index 100% rename from src/front_end_params/arith_simplifier_params.h rename to src/ast/simplifier/arith_simplifier_params.h diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h new file mode 100644 index 000000000..8b9f3e37e --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params.h @@ -0,0 +1,33 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + array_simplifier_params.h + +Abstract: + + This file was created during code reorg. + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ +#define _ARRAY_SIMPLIFIER_PARAMS_H_ + +struct array_simplifier_params { + bool m_array_canonize_simplify; + bool m_array_simplify; // temporary hack for disabling array simplifier plugin. + + array_simplifier_params(): + m_array_canonize_simplify(false), + m_array_simplify(true) { + } +}; + +#endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ + diff --git a/src/ast/simplifier/array_simplifier_plugin.cpp b/src/ast/simplifier/array_simplifier_plugin.cpp index 8654db275..75c3cdbce 100644 --- a/src/ast/simplifier/array_simplifier_plugin.cpp +++ b/src/ast/simplifier/array_simplifier_plugin.cpp @@ -33,7 +33,7 @@ array_simplifier_plugin::array_simplifier_plugin( ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, - theory_array_params const& p) : + array_simplifier_params const& p) : simplifier_plugin(symbol("array"),m), m_util(m), m_simp(s), diff --git a/src/ast/simplifier/array_simplifier_plugin.h b/src/ast/simplifier/array_simplifier_plugin.h index fffa18c3f..572da9a17 100644 --- a/src/ast/simplifier/array_simplifier_plugin.h +++ b/src/ast/simplifier/array_simplifier_plugin.h @@ -24,7 +24,7 @@ Revision History: #include"array_decl_plugin.h" #include"simplifier_plugin.h" #include"basic_simplifier_plugin.h" -#include"theory_array_params.h" +#include"array_simplifier_params.h" #include"simplifier.h" #include"obj_hashtable.h" #include"lbool.h" @@ -71,7 +71,7 @@ class array_simplifier_plugin : public simplifier_plugin { array_util m_util; basic_simplifier_plugin& m_simp; simplifier& m_simplifier; - theory_array_params const& m_params; + array_simplifier_params const& m_params; select_cache m_select_cache; ptr_vector m_tmp; ptr_vector m_tmp2; @@ -100,7 +100,7 @@ class array_simplifier_plugin : public simplifier_plugin { public: - array_simplifier_plugin(ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, theory_array_params const& p); + array_simplifier_plugin(ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, array_simplifier_params const& p); virtual ~array_simplifier_plugin(); virtual bool reduce(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result); diff --git a/src/front_end_params/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h similarity index 61% rename from src/front_end_params/bv_simplifier_params.h rename to src/ast/simplifier/bv_simplifier_params.h index 887940e36..4bec70285 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -27,12 +27,6 @@ struct bv_simplifier_params { m_hi_div0(true), m_bv2int_distribute(true) { } -#if 0 - void register_params(ini_params & p) { - p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); - p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); - } -#endif }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp deleted file mode 100644 index 8cf07b915..000000000 --- a/src/front_end_params/arith_simplifier_params.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - arith_simplifier_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-05-09. - -Revision History: - ---*/ - -#include"arith_simplifier_params.h" - -#if 0 -void arith_simplifier_params::register_params(ini_params & p) { - p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); - p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); -} -#endif diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp deleted file mode 100644 index cfc0df4f1..000000000 --- a/src/front_end_params/pattern_inference_params.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pattern_inference_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-03-24. - -Revision History: - ---*/ -#include"pattern_inference_params.h" - -#if 0 -void pattern_inference_params::register_params(ini_params & p) { - p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, - "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); - p.register_bool_param("pi_block_loop_patterns", m_pi_block_loop_patterns, - "block looping patterns during pattern inference"); - p.register_int_param("pi_arith", 0, 2, reinterpret_cast(m_pi_arith), - "0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms."); - p.register_bool_param("pi_use_database", m_pi_use_database); - p.register_unsigned_param("pi_arith_weight", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); - p.register_unsigned_param("pi_non_nested_arith_weight", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); - p.register_bool_param("pi_pull_quantifiers", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); - p.register_int_param("pi_nopat_weight", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); - p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); - p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); -} -#endif - diff --git a/src/front_end_params/README b/src/smt/params/README similarity index 100% rename from src/front_end_params/README rename to src/smt/params/README diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/smt/params/dyn_ack_params.cpp similarity index 100% rename from src/front_end_params/dyn_ack_params.cpp rename to src/smt/params/dyn_ack_params.cpp diff --git a/src/front_end_params/dyn_ack_params.h b/src/smt/params/dyn_ack_params.h similarity index 100% rename from src/front_end_params/dyn_ack_params.h rename to src/smt/params/dyn_ack_params.h diff --git a/src/front_end_params/params2smt_params.cpp b/src/smt/params/params2smt_params.cpp similarity index 100% rename from src/front_end_params/params2smt_params.cpp rename to src/smt/params/params2smt_params.cpp diff --git a/src/front_end_params/params2smt_params.h b/src/smt/params/params2smt_params.h similarity index 100% rename from src/front_end_params/params2smt_params.h rename to src/smt/params/params2smt_params.h diff --git a/src/front_end_params/preprocessor_params.h b/src/smt/params/preprocessor_params.h similarity index 100% rename from src/front_end_params/preprocessor_params.h rename to src/smt/params/preprocessor_params.h diff --git a/src/front_end_params/qi_params.h b/src/smt/params/qi_params.h similarity index 100% rename from src/front_end_params/qi_params.h rename to src/smt/params/qi_params.h diff --git a/src/front_end_params/smt_params.cpp b/src/smt/params/smt_params.cpp similarity index 100% rename from src/front_end_params/smt_params.cpp rename to src/smt/params/smt_params.cpp diff --git a/src/front_end_params/smt_params.h b/src/smt/params/smt_params.h similarity index 100% rename from src/front_end_params/smt_params.h rename to src/smt/params/smt_params.h diff --git a/src/front_end_params/theory_arith_params.cpp b/src/smt/params/theory_arith_params.cpp similarity index 100% rename from src/front_end_params/theory_arith_params.cpp rename to src/smt/params/theory_arith_params.cpp diff --git a/src/front_end_params/theory_arith_params.h b/src/smt/params/theory_arith_params.h similarity index 100% rename from src/front_end_params/theory_arith_params.h rename to src/smt/params/theory_arith_params.h diff --git a/src/front_end_params/theory_array_params.h b/src/smt/params/theory_array_params.h similarity index 88% rename from src/front_end_params/theory_array_params.h rename to src/smt/params/theory_array_params.h index e33bc2566..c1ae8ce32 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/smt/params/theory_array_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _THEORY_ARRAY_PARAMS_H_ #define _THEORY_ARRAY_PARAMS_H_ +#include"array_simplifier_params.h" + enum array_solver_id { AR_NO_ARRAY, AR_SIMPLE, @@ -26,7 +28,7 @@ enum array_solver_id { AR_FULL }; -struct theory_array_params { +struct theory_array_params : public array_simplifier_params { array_solver_id m_array_mode; bool m_array_weak; bool m_array_extensional; @@ -36,8 +38,6 @@ struct theory_array_params { bool m_array_always_prop_upward; bool m_array_lazy_ieq; unsigned m_array_lazy_ieq_delay; - bool m_array_canonize_simplify; - bool m_array_simplify; // temporary hack for disabling array simplifier plugin. theory_array_params(): m_array_mode(AR_FULL), @@ -48,9 +48,7 @@ struct theory_array_params { m_array_cg(false), m_array_always_prop_upward(true), // UPWARDs filter is broken... TODO: fix it m_array_lazy_ieq(false), - m_array_lazy_ieq_delay(10), - m_array_canonize_simplify(false), - m_array_simplify(true) { + m_array_lazy_ieq_delay(10) { } #if 0 diff --git a/src/front_end_params/theory_bv_params.h b/src/smt/params/theory_bv_params.h similarity index 100% rename from src/front_end_params/theory_bv_params.h rename to src/smt/params/theory_bv_params.h diff --git a/src/front_end_params/theory_datatype_params.h b/src/smt/params/theory_datatype_params.h similarity index 100% rename from src/front_end_params/theory_datatype_params.h rename to src/smt/params/theory_datatype_params.h From 6a220c8b58929c6d3461774cbef17edc55ae9afb Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 11:27:39 -0800 Subject: [PATCH 081/133] moved old params files Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 277a7e702..c2cbb3f33 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1461,19 +1461,22 @@ def pyg_default_as_c_literal(p): return 'symbol("%s")' % p[2] return p[2] -def def_module_params(module_name, export, params): +def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() + print os.path.split(get_curr_pyg) hpp = '%shpp' % pyg[:len(pyg)-3] out = open(hpp, 'w') + if class_name == None: + class_name = '%s_params' % module_name out.write('// Automatically generated file\n') out.write('#include"params.h"\n') if export: out.write('#include"gparams.h"\n') - out.write('struct %s_params {\n' % module_name) + out.write('struct %s {\n' % class_name) out.write(' params_ref const & p;\n') if export: out.write(' params_ref g;\n') - out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) + out.write(' %s(params_ref const & _p = params_ref()):\n' % class_name) out.write(' p(_p)') if export: out.write(', g(gparams::get_module("%s"))' % module_name) @@ -1484,7 +1487,7 @@ def def_module_params(module_name, export, params): out.write(' }\n') if export: out.write(' /*\n') - out.write(" REG_MODULE_PARAMS('%s', '%s_params::collect_param_descrs')\n" % (module_name, module_name)) + out.write(" REG_MODULE_PARAMS('%s', '%s::collect_param_descrs')\n" % (module_name, class_name)) out.write(' */\n') # Generated accessors for param in params: From 8d62c95a5476067b36d80cf7102d2c776dad9a2e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 11:31:38 -0800 Subject: [PATCH 082/133] fixed mk_make Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index c2cbb3f33..452a915d1 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1463,11 +1463,11 @@ def pyg_default_as_c_literal(p): def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() - print os.path.split(get_curr_pyg) - hpp = '%shpp' % pyg[:len(pyg)-3] - out = open(hpp, 'w') + dirname = os.path.split(get_curr_pyg())[0] if class_name == None: class_name = '%s_params' % module_name + hpp = os.path.join(dirname, '%s.hpp' % class_name) + out = open(hpp, 'w') out.write('// Automatically generated file\n') out.write('#include"params.h"\n') if export: From c82b8174d8d1894c3b0f412234aab2fb63368b20 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:08:58 -0800 Subject: [PATCH 083/133] fixed win compilation bug Signed-off-by: Leonardo de Moura --- src/muz_qe/pdr_interpolant_provider.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index de1c62d79..7c9afd74a 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -306,8 +306,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& return l_undef; } - smt_params dummy_params; - cmd_context cctx(&dummy_params, false, &m); + cmd_context cctx(false, &m); for_each_expr(used_symbol_inserter(cctx), f1); parse_smt2_commands(cctx, std::istringstream(res_text), false); From 32854c677c3270f3b83c2bb64ca39ca195dd40bf Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:10:06 -0800 Subject: [PATCH 084/133] exposed old simplifier parameters Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 7 +++++-- src/ast/simplifier/arith_simplifier_params.h | 15 +++++++++++---- .../simplifier/arith_simplifier_params_helper.pyg | 6 ++++++ src/ast/simplifier/array_simplifier_params.h | 13 ++++++++++--- .../simplifier/array_simplifier_params_helper.pyg | 6 ++++++ src/ast/simplifier/bv_simplifier_params.h | 13 ++++++++++--- .../simplifier/bv_simplifier_params_helper.pyg | 6 ++++++ 7 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 src/ast/simplifier/arith_simplifier_params_helper.pyg create mode 100644 src/ast/simplifier/array_simplifier_params_helper.pyg create mode 100644 src/ast/simplifier/bv_simplifier_params_helper.pyg diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 452a915d1..4ce41040b 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1461,6 +1461,9 @@ def pyg_default_as_c_literal(p): return 'symbol("%s")' % p[2] return p[2] +def to_c_method(s): + return s.replace('.', '_') + def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() dirname = os.path.split(get_curr_pyg())[0] @@ -1493,10 +1496,10 @@ def def_module_params(module_name, export, params, class_name=None): for param in params: if export: out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' % - (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) else: out.write(' %s %s() const { return p.%s("%s", %s); }\n' % - (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) out.write('};\n') if is_verbose(): print "Generated '%s'" % hpp diff --git a/src/ast/simplifier/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h index f1b22b09a..5a00f6337 100644 --- a/src/ast/simplifier/arith_simplifier_params.h +++ b/src/ast/simplifier/arith_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -struct arith_simplifier_params { +#include"arith_simplifier_params_helper.hpp" + +struct arith_simplifier_params { bool m_arith_expand_eqs; bool m_arith_process_all_eqs; - arith_simplifier_params(): - m_arith_expand_eqs(false), - m_arith_process_all_eqs(false) { + arith_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + arith_simplifier_params_helper p(_p); + m_arith_expand_eqs = p.arith_expand_eqs(); + m_arith_process_all_eqs = p.arith_process_all_eqs(); } }; diff --git a/src/ast/simplifier/arith_simplifier_params_helper.pyg b/src/ast/simplifier/arith_simplifier_params_helper.pyg new file mode 100644 index 000000000..9cd79bebc --- /dev/null +++ b/src/ast/simplifier/arith_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='arith_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('arith.expand_eqs', BOOL, False, 'expand equalities into two inequalities'), + ('arith.process_all_eqs', BOOL, False, 'put all equations in the form (= t c), where c is a numeral'))) diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h index 8b9f3e37e..6c203ed63 100644 --- a/src/ast/simplifier/array_simplifier_params.h +++ b/src/ast/simplifier/array_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ #define _ARRAY_SIMPLIFIER_PARAMS_H_ +#include"array_simplifier_params_helper.hpp" + struct array_simplifier_params { bool m_array_canonize_simplify; bool m_array_simplify; // temporary hack for disabling array simplifier plugin. - array_simplifier_params(): - m_array_canonize_simplify(false), - m_array_simplify(true) { + array_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + array_simplifier_params_helper p(_p); + m_array_canonize_simplify = p.array_canonize(); + m_array_simplify = p.array_simplify(); } }; diff --git a/src/ast/simplifier/array_simplifier_params_helper.pyg b/src/ast/simplifier/array_simplifier_params_helper.pyg new file mode 100644 index 000000000..93c184c23 --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='array_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('array.canonize', BOOL, False, 'normalize array terms into normal form during simplification'), + ('array.simplify', BOOL, True, 'enable/disable array simplifications'))) diff --git a/src/ast/simplifier/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h index 4bec70285..85d969d48 100644 --- a/src/ast/simplifier/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ +#include"bv_simplifier_params_helper.hpp" + struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. bool m_bv2int_distribute; //!< if true allows downward propagation of bv2int. - bv_simplifier_params(): - m_hi_div0(true), - m_bv2int_distribute(true) { + bv_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + bv_simplifier_params_helper p(_p); + m_hi_div0 = p.bv_hi_div0(); + m_bv2int_distribute = p.bv_bv2int_distribute(); } }; diff --git a/src/ast/simplifier/bv_simplifier_params_helper.pyg b/src/ast/simplifier/bv_simplifier_params_helper.pyg new file mode 100644 index 000000000..24bc86150 --- /dev/null +++ b/src/ast/simplifier/bv_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='bv_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('bv.hi_div0', BOOL, True, 'if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero; otherwise, these operations are considered uninterpreted'), + ('bv.bv2int_distribute', BOOL, True, 'if true, then int2bv is distributed over arithmetical operators'))) From 624115ea6deddb2c0dc6f800dbe7f8fa0bd1b95b Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:24:27 -0800 Subject: [PATCH 085/133] exposed pattern inference params Signed-off-by: Leonardo de Moura --- src/ast/pattern/pattern_inference_params.h | 27 ++++++++++++------- .../pattern_inference_params_helper.pyg | 11 ++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 src/ast/pattern/pattern_inference_params_helper.pyg diff --git a/src/ast/pattern/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h index 7108e5589..59faa150f 100644 --- a/src/ast/pattern/pattern_inference_params.h +++ b/src/ast/pattern/pattern_inference_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ +#include"pattern_inference_params_helper.hpp" + enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms AP_CONSERVATIVE, // only infer patterns with arithmetic terms if there is no other option @@ -37,17 +39,22 @@ struct pattern_inference_params { bool m_pi_avoid_skolems; bool m_pi_warnings; - pattern_inference_params(): - m_pi_max_multi_patterns(0), - m_pi_block_loop_patterns(true), - m_pi_arith(AP_CONSERVATIVE), - m_pi_use_database(false), - m_pi_arith_weight(5), - m_pi_non_nested_arith_weight(10), - m_pi_pull_quantifiers(true), + pattern_inference_params(params_ref const & p = params_ref()): m_pi_nopat_weight(-1), - m_pi_avoid_skolems(true), - m_pi_warnings(false) { + m_pi_avoid_skolems(true) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + pattern_inference_params_helper p(_p); + m_pi_max_multi_patterns = p.max_multi_patterns(); + m_pi_block_loop_patterns = p.block_loop_patterns(); + m_pi_arith = static_cast(p.arith()); + m_pi_use_database = p.use_database(); + m_pi_arith_weight = p.arith_weight(); + m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); + m_pi_pull_quantifiers = p.pull_quantifiers(); + m_pi_warnings = p.warnings(); } }; diff --git a/src/ast/pattern/pattern_inference_params_helper.pyg b/src/ast/pattern/pattern_inference_params_helper.pyg new file mode 100644 index 000000000..cc9699b01 --- /dev/null +++ b/src/ast/pattern/pattern_inference_params_helper.pyg @@ -0,0 +1,11 @@ +def_module_params(class_name='pattern_inference_params_helper', + module_name='pi', + export=True, + params=(('max_multi_patterns', UINT, 0, 'when patterns are not provided, the prover uses a heuristic to infer them, this option sets the threshold on the number of extra multi-patterns that can be created; by default, the prover creates at most one multi-pattern when there is no unary pattern'), + ('block_loop_patterns', BOOL, True, 'block looping patterns during pattern inference'), + ('arith', UINT, 1, '0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms'), + ('use_database', BOOL, True, 'use pattern database'), + ('arith_weight', UINT, 5, 'default weight for quantifiers where the only available pattern has nested arithmetic terms'), + ('non_nested_arith_weight', UINT, 10, 'default weight for quantifiers where the only available pattern has non nested arithmetic terms'), + ('pull_quantifiers', BOOL, True, 'pull nested quantifiers, if no pattern was found'), + ('warnings', BOOL, False, 'enable/disable warning messages in the pattern inference module'))) From 1871bef6e1bff67405e85dd9d944e10fd3e847f3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:47:20 -0800 Subject: [PATCH 086/133] cleaned algebraic params Signed-off-by: Leonardo de Moura --- src/math/polynomial/algebraic.pyg | 9 +++++++++ src/math/polynomial/algebraic_numbers.cpp | 23 ++++++++++------------- src/math/polynomial/algebraic_numbers.h | 3 --- src/model/model_params.pyg | 3 +-- 4 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 src/math/polynomial/algebraic.pyg diff --git a/src/math/polynomial/algebraic.pyg b/src/math/polynomial/algebraic.pyg new file mode 100644 index 000000000..5e6c288f8 --- /dev/null +++ b/src/math/polynomial/algebraic.pyg @@ -0,0 +1,9 @@ +def_module_params('algebraic', + export=True, + params=(('zero_accuracy', UINT, 0, 'one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)'), + ('min_mag', UINT, 16, 'Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16'), + ('factor', BOOL, True, 'use polynomial factorization to simplify polynomials representing algebraic numbers'), + ('factor_max_prime', UINT, 31, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step'), + ('factor_num_primes', UINT, 1, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)\'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching'), + ('factor_search_size', UINT, 5000, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space'))) + diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index c35e0d368..90ad6ea9d 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -25,6 +25,7 @@ Notes: #include"scoped_ptr_vector.h" #include"mpbqi.h" #include"timeit.h" +#include"algebraic_params.hpp" namespace algebraic_numbers { @@ -57,12 +58,7 @@ namespace algebraic_numbers { typedef upolynomial::factors factors; void manager::get_param_descrs(param_descrs & r) { - r.insert("zero_accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); - r.insert("min_mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); - r.insert("factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); - r.insert("factor_max_prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert("factor_num_primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); - r.insert("factor_search_size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + algebraic_params::collect_param_descrs(r); } struct manager::imp { @@ -156,13 +152,14 @@ namespace algebraic_numbers { #endif } - void updt_params(params_ref const & p) { - m_min_magnitude = -static_cast(p.get_uint("min_mag", 16)); - m_factor = p.get_bool("factor", true); // use polynomial factorization - m_factor_params.m_max_p = p.get_uint("factor_max_prime", 31); - m_factor_params.m_p_trials = p.get_uint("factor_num_primes", 1); - m_factor_params.m_max_search_size = p.get_uint("factor_max_search_size", 5000); - m_zero_accuracy = -static_cast(p.get_uint("zero_accuracy", 0)); + void updt_params(params_ref const & _p) { + algebraic_params p(_p); + m_min_magnitude = -static_cast(p.min_mag()); + m_factor = p.factor(); + m_factor_params.m_max_p = p.factor_max_prime(); + m_factor_params.m_p_trials = p.factor_num_primes(); + m_factor_params.m_max_search_size = p.factor_search_size(); + m_zero_accuracy = -static_cast(p.zero_accuracy()); } unsynch_mpq_manager & qm() { diff --git a/src/math/polynomial/algebraic_numbers.h b/src/math/polynomial/algebraic_numbers.h index 0db3ee68c..4735a875b 100644 --- a/src/math/polynomial/algebraic_numbers.h +++ b/src/math/polynomial/algebraic_numbers.h @@ -60,9 +60,6 @@ namespace algebraic_numbers { manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); ~manager(); - /* - REG_MODULE_PARAMS('algebraic', 'algebraic_numbers::manager::get_param_descrs') - */ static void get_param_descrs(param_descrs & r); static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); } diff --git a/src/model/model_params.pyg b/src/model/model_params.pyg index 689519e6c..977538163 100644 --- a/src/model/model_params.pyg +++ b/src/model/model_params.pyg @@ -1,7 +1,6 @@ def_module_params('model', export=True, - params=(('validate', BOOL, False, 'validate models produced by Z3'), - ('partial', BOOL, False, 'enable/disable partial function interpretations'), + params=(('partial', BOOL, False, 'enable/disable partial function interpretations'), ('v1', BOOL, False, 'use Z3 version 1.x pretty printer'), ('v2', BOOL, False, 'use Z3 version 2.x (x <= 16) pretty printer'), ('compact', BOOL, False, 'try to compact function graph (i.e., function interpretations that are lookup tables)'), From fa53b1eb92f4ca9d822c9fd119b94fab88c49b18 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 13:15:56 -0800 Subject: [PATCH 087/133] added module descriptions Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 11 ++++++- src/ast/normal_forms/nnf_params.pyg | 1 + src/ast/pattern/pattern_inference_params.cpp | 32 +++++++++++++++++++ src/ast/pattern/pattern_inference_params.h | 14 ++------ .../pattern_inference_params_helper.pyg | 1 + src/ast/pp_params.pyg | 1 + .../simplifier/arith_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/arith_simplifier_params.h | 8 ++--- .../arith_simplifier_params_helper.pyg | 1 + .../simplifier/array_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/array_simplifier_params.h | 10 ++---- src/ast/simplifier/bv_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/bv_simplifier_params.h | 8 ++--- src/math/polynomial/algebraic.pyg | 1 + src/nlsat/nlsat_params.pyg | 1 + src/util/gparams.cpp | 20 +++++++++++- src/util/gparams.h | 5 +++ 17 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 src/ast/pattern/pattern_inference_params.cpp create mode 100644 src/ast/simplifier/arith_simplifier_params.cpp create mode 100644 src/ast/simplifier/array_simplifier_params.cpp create mode 100644 src/ast/simplifier/bv_simplifier_params.cpp diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 4ce41040b..2906b11fe 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1464,7 +1464,7 @@ def pyg_default_as_c_literal(p): def to_c_method(s): return s.replace('.', '_') -def def_module_params(module_name, export, params, class_name=None): +def def_module_params(module_name, export, params, class_name=None, description=None): pyg = get_curr_pyg() dirname = os.path.split(get_curr_pyg())[0] if class_name == None: @@ -1491,6 +1491,8 @@ def def_module_params(module_name, export, params, class_name=None): if export: out.write(' /*\n') out.write(" REG_MODULE_PARAMS('%s', '%s::collect_param_descrs')\n" % (module_name, class_name)) + if description != None: + out.write(" REG_MODULE_DESCRIPTION('%s', '%s')\n" % (module_name, description)) out.write(' */\n') # Generated accessors for param in params: @@ -1763,12 +1765,14 @@ def mk_all_mem_initializer_cpps(): def mk_gparams_register_modules(cnames, path): cmds = [] mod_cmds = [] + mod_descrs = [] fullname = '%s/gparams_register_modules.cpp' % path fout = open(fullname, 'w') fout.write('// Automatically generated file.\n') fout.write('#include"gparams.h"\n') reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)') reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') + reg_mod_descr_pat = re.compile('[ \t]*REG_MODULE_DESCRIPTION\(\'([^\']*)\', *\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) @@ -1788,11 +1792,16 @@ def mk_gparams_register_modules(cnames, path): added_include = True fout.write('#include"%s"\n' % h_file) mod_cmds.append((m.group(1), m.group(2))) + m = reg_mod_descr_pat.match(line) + if m: + mod_descrs.append((m.group(1), m.group(2))) fout.write('void gparams_register_modules() {\n') for code in cmds: fout.write('{ param_descrs d; %s(d); gparams::register_global(d); }\n' % code) for (mod, code) in mod_cmds: fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) + for (mod, descr) in mod_descrs: + fout.write('gparams::register_module_descr("%s", "%s");\n' % (mod, descr)) fout.write('}\n') if VERBOSE: print "Generated '%s'" % fullname diff --git a/src/ast/normal_forms/nnf_params.pyg b/src/ast/normal_forms/nnf_params.pyg index 6fab28f11..aac8fbb86 100644 --- a/src/ast/normal_forms/nnf_params.pyg +++ b/src/ast/normal_forms/nnf_params.pyg @@ -1,4 +1,5 @@ def_module_params('nnf', + description='negation normal form', export=True, params=(max_memory_param(), ('sk_hack', BOOL, False, 'hack for VCC'), diff --git a/src/ast/pattern/pattern_inference_params.cpp b/src/ast/pattern/pattern_inference_params.cpp new file mode 100644 index 000000000..8adbdb9f1 --- /dev/null +++ b/src/ast/pattern/pattern_inference_params.cpp @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + pattern_inference_params.h + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"pattern_inference_params.h" +#include"pattern_inference_params_helper.hpp" + +void pattern_inference_params::updt_params(params_ref const & _p) { + pattern_inference_params_helper p(_p); + m_pi_max_multi_patterns = p.max_multi_patterns(); + m_pi_block_loop_patterns = p.block_loop_patterns(); + m_pi_arith = static_cast(p.arith()); + m_pi_use_database = p.use_database(); + m_pi_arith_weight = p.arith_weight(); + m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); + m_pi_pull_quantifiers = p.pull_quantifiers(); + m_pi_warnings = p.warnings(); +} diff --git a/src/ast/pattern/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h index 59faa150f..dc9f0cb9b 100644 --- a/src/ast/pattern/pattern_inference_params.h +++ b/src/ast/pattern/pattern_inference_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ -#include"pattern_inference_params_helper.hpp" +#include"params.h" enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms @@ -45,17 +45,7 @@ struct pattern_inference_params { updt_params(p); } - void updt_params(params_ref const & _p) { - pattern_inference_params_helper p(_p); - m_pi_max_multi_patterns = p.max_multi_patterns(); - m_pi_block_loop_patterns = p.block_loop_patterns(); - m_pi_arith = static_cast(p.arith()); - m_pi_use_database = p.use_database(); - m_pi_arith_weight = p.arith_weight(); - m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); - m_pi_pull_quantifiers = p.pull_quantifiers(); - m_pi_warnings = p.warnings(); - } + void updt_params(params_ref const & _p); }; #endif /* _PATTERN_INFERENCE_PARAMS_H_ */ diff --git a/src/ast/pattern/pattern_inference_params_helper.pyg b/src/ast/pattern/pattern_inference_params_helper.pyg index cc9699b01..5d64e8e52 100644 --- a/src/ast/pattern/pattern_inference_params_helper.pyg +++ b/src/ast/pattern/pattern_inference_params_helper.pyg @@ -1,5 +1,6 @@ def_module_params(class_name='pattern_inference_params_helper', module_name='pi', + description='pattern inference (heuristics) for universal formulas (without annotation)', export=True, params=(('max_multi_patterns', UINT, 0, 'when patterns are not provided, the prover uses a heuristic to infer them, this option sets the threshold on the number of extra multi-patterns that can be created; by default, the prover creates at most one multi-pattern when there is no unary pattern'), ('block_loop_patterns', BOOL, True, 'block looping patterns during pattern inference'), diff --git a/src/ast/pp_params.pyg b/src/ast/pp_params.pyg index 57d6e185d..75b2baddd 100644 --- a/src/ast/pp_params.pyg +++ b/src/ast/pp_params.pyg @@ -1,5 +1,6 @@ def_module_params('pp', export=True, + description='pretty printer', params=(('max_indent', UINT, UINT_MAX, 'max. indentation in pretty printer'), ('max_num_lines', UINT, UINT_MAX, 'max. number of lines to be displayed in pretty printer'), ('max_width', UINT, 80, 'max. width in pretty printer'), diff --git a/src/ast/simplifier/arith_simplifier_params.cpp b/src/ast/simplifier/arith_simplifier_params.cpp new file mode 100644 index 000000000..a3fabe02f --- /dev/null +++ b/src/ast/simplifier/arith_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + arith_simplifier_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"arith_simplifier_params.h" +#include"arith_simplifier_params_helper.hpp" + +void arith_simplifier_params::updt_params(params_ref const & _p) { + arith_simplifier_params_helper p(_p); + m_arith_expand_eqs = p.arith_expand_eqs(); + m_arith_process_all_eqs = p.arith_process_all_eqs(); +} diff --git a/src/ast/simplifier/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h index 5a00f6337..109f73307 100644 --- a/src/ast/simplifier/arith_simplifier_params.h +++ b/src/ast/simplifier/arith_simplifier_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -#include"arith_simplifier_params_helper.hpp" +#include"params.h" struct arith_simplifier_params { bool m_arith_expand_eqs; @@ -29,11 +29,7 @@ struct arith_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - arith_simplifier_params_helper p(_p); - m_arith_expand_eqs = p.arith_expand_eqs(); - m_arith_process_all_eqs = p.arith_process_all_eqs(); - } + void updt_params(params_ref const & _p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/ast/simplifier/arith_simplifier_params_helper.pyg b/src/ast/simplifier/arith_simplifier_params_helper.pyg index 9cd79bebc..49a7cf3d2 100644 --- a/src/ast/simplifier/arith_simplifier_params_helper.pyg +++ b/src/ast/simplifier/arith_simplifier_params_helper.pyg @@ -1,5 +1,6 @@ def_module_params(class_name='arith_simplifier_params_helper', module_name="old_simplify", # Parameters will be in the old_simplify module + description="old simplification (stack) still used in the smt module", export=True, params=( ('arith.expand_eqs', BOOL, False, 'expand equalities into two inequalities'), diff --git a/src/ast/simplifier/array_simplifier_params.cpp b/src/ast/simplifier/array_simplifier_params.cpp new file mode 100644 index 000000000..bffff44d9 --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + array_simplifier_params.cpp + +Abstract: + + This file was created during code reorg. + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"array_simplifier_params.h" +#include"array_simplifier_params_helper.hpp" + +void array_simplifier_params::updt_params(params_ref const & _p) { + array_simplifier_params_helper p(_p); + m_array_canonize_simplify = p.array_canonize(); + m_array_simplify = p.array_simplify(); +} diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h index 6c203ed63..2f6fa720b 100644 --- a/src/ast/simplifier/array_simplifier_params.h +++ b/src/ast/simplifier/array_simplifier_params.h @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2006 Microsoft Corporation +Copyright (c) 2012 Microsoft Corporation Module Name: @@ -19,7 +19,7 @@ Revision History: #ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ #define _ARRAY_SIMPLIFIER_PARAMS_H_ -#include"array_simplifier_params_helper.hpp" +#include"params.h" struct array_simplifier_params { bool m_array_canonize_simplify; @@ -29,11 +29,7 @@ struct array_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - array_simplifier_params_helper p(_p); - m_array_canonize_simplify = p.array_canonize(); - m_array_simplify = p.array_simplify(); - } + void updt_params(params_ref const & _p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/ast/simplifier/bv_simplifier_params.cpp b/src/ast/simplifier/bv_simplifier_params.cpp new file mode 100644 index 000000000..aa9dcfc2d --- /dev/null +++ b/src/ast/simplifier/bv_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + bv_simplifier_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"bv_simplifier_params.h" +#include"bv_simplifier_params_helper.hpp" + +void bv_simplifier_params::updt_params(params_ref const & _p) { + bv_simplifier_params_helper p(_p); + m_hi_div0 = p.bv_hi_div0(); + m_bv2int_distribute = p.bv_bv2int_distribute(); +} diff --git a/src/ast/simplifier/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h index 85d969d48..5f5832235 100644 --- a/src/ast/simplifier/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ -#include"bv_simplifier_params_helper.hpp" +#include"params.h" struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. @@ -29,11 +29,7 @@ struct bv_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - bv_simplifier_params_helper p(_p); - m_hi_div0 = p.bv_hi_div0(); - m_bv2int_distribute = p.bv_bv2int_distribute(); - } + void updt_params(params_ref const & _p); }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/math/polynomial/algebraic.pyg b/src/math/polynomial/algebraic.pyg index 5e6c288f8..92a2f10df 100644 --- a/src/math/polynomial/algebraic.pyg +++ b/src/math/polynomial/algebraic.pyg @@ -1,4 +1,5 @@ def_module_params('algebraic', + description='real algebraic number package', export=True, params=(('zero_accuracy', UINT, 0, 'one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)'), ('min_mag', UINT, 16, 'Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16'), diff --git a/src/nlsat/nlsat_params.pyg b/src/nlsat/nlsat_params.pyg index 2728e1180..4faad3379 100644 --- a/src/nlsat/nlsat_params.pyg +++ b/src/nlsat/nlsat_params.pyg @@ -1,5 +1,6 @@ def_module_params('nlsat', + description='nonlinear solver', export=True, params=(max_memory_param(), ('lazy', UINT, 0, "how lazy the solver is."), diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 85b648a55..8a5532ee0 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -37,6 +37,7 @@ bool is_old_param_name(symbol const & name) { struct gparams::imp { dictionary m_module_param_descrs; + dictionary m_module_descrs; param_descrs m_param_descrs; dictionary m_module_params; params_ref m_params; @@ -83,6 +84,13 @@ public: } } + void register_module_descr(char const * module_name, char const * descr) { + #pragma omp critical (gparams) + { + m_module_descrs.insert(symbol(module_name), descr); + } + } + void display(std::ostream & out, unsigned indent, bool smt2_style) { #pragma omp critical (gparams) { @@ -92,7 +100,12 @@ public: dictionary::iterator it = m_module_param_descrs.begin(); dictionary::iterator end = m_module_param_descrs.end(); for (; it != end; ++it) { - out << "[module] " << it->m_key << "\n"; + out << "[module] " << it->m_key; + char const * descr = 0; + if (m_module_descrs.find(it->m_key, descr)) { + out << ", description: " << descr; + } + out << "\n"; it->m_value->display(out, indent + 4, smt2_style); } } @@ -337,6 +350,11 @@ void gparams::register_module(char const * module_name, param_descrs * d) { g_imp->register_module(module_name, d); } +void gparams::register_module_descr(char const * module_name, char const * descr) { + SASSERT(g_imp != 0); + g_imp->register_module_descr(module_name, descr); +} + params_ref gparams::get_module(char const * module_name) { return get_module(symbol(module_name)); } diff --git a/src/util/gparams.h b/src/util/gparams.h index 04e1f6051..2a784a239 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -79,6 +79,11 @@ public: */ static void register_module(char const * module_name, param_descrs * d); + /** + \brief Add a (small) description to the given module. + */ + static void register_module_descr(char const * module_name, char const * descr); + /** \brief Retrieves the parameters associated with the given module. From 5057257e403effd753da5197d8dac0a6cc6f8bf3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 13:18:33 -0800 Subject: [PATCH 088/133] removed unnecessary README Signed-off-by: Leonardo de Moura --- src/smt/params/README | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/smt/params/README diff --git a/src/smt/params/README b/src/smt/params/README deleted file mode 100644 index 1ab0a2463..000000000 --- a/src/smt/params/README +++ /dev/null @@ -1,9 +0,0 @@ -This directory contains the "remains" of the old parameter setting -infrastructure used by Z3. Old code (mostly `smt::context`) is still -based on the front_end_params structure. However, we removed support -for the old INI file infrastructure. Instead, we have functions for -setting the fields of front_end_params using parameter sets -(params_ref). Moreover, many of the parameters in front_end_params -are now "hidden". That is, they can't be set from the command line or -using the command `set-option`. - From 773f82a44cabd15b064da23b23690c8e3c007dd6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 14:47:34 -0800 Subject: [PATCH 089/133] connected smt_params with new parameter infrastructure Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 2 +- src/smt/params/preprocessor_params.cpp | 32 +++++++ src/smt/params/preprocessor_params.h | 32 +------ src/smt/params/qi_params.cpp | 37 ++++++++ src/smt/params/qi_params.h | 39 +------- src/smt/params/smt_params.cpp | 126 ++++++------------------- src/smt/params/smt_params.h | 26 ++--- src/smt/params/smt_params_helper.pyg | 38 ++++++++ src/smt/params/theory_arith_params.cpp | 71 +++----------- src/smt/params/theory_arith_params.h | 6 +- src/smt/params/theory_bv_params.cpp | 25 +++++ src/smt/params/theory_bv_params.h | 21 ++--- src/smt/smt_kernel.cpp | 4 +- src/smt/smt_solver.cpp | 2 +- src/smt/tactic/smt_tactic.cpp | 6 +- 15 files changed, 211 insertions(+), 256 deletions(-) create mode 100644 src/smt/params/preprocessor_params.cpp create mode 100644 src/smt/params/qi_params.cpp create mode 100644 src/smt/params/smt_params_helper.pyg create mode 100644 src/smt/params/theory_bv_params.cpp diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 2d242f9b0..f197e8ad8 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -323,7 +323,7 @@ namespace api { smt::kernel & context::get_smt_kernel() { if (!m_solver) { - // PARAM-TODO: copy config_params -> fparams + m_fparams.updt_params(m_params); m_solver = alloc(smt::kernel, m_manager, m_fparams); } return *m_solver; diff --git a/src/smt/params/preprocessor_params.cpp b/src/smt/params/preprocessor_params.cpp new file mode 100644 index 000000000..375fef787 --- /dev/null +++ b/src/smt/params/preprocessor_params.cpp @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + preprocessor_params.h + +Abstract: + + Preprocess AST before adding them to the logical context + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"preprocessor_params.h" +#include"smt_params_helper.hpp" + +void preprocessor_params::updt_local_params(params_ref const & _p) { + smt_params_helper p(_p); + m_macro_finder = p.macro_finder(); +} + +void preprocessor_params::updt_params(params_ref const & p) { + pattern_inference_params::updt_params(p); + bv_simplifier_params::updt_params(p); + arith_simplifier_params::updt_params(p); + updt_local_params(p); +} diff --git a/src/smt/params/preprocessor_params.h b/src/smt/params/preprocessor_params.h index e4b20b87a..d53f26318 100644 --- a/src/smt/params/preprocessor_params.h +++ b/src/smt/params/preprocessor_params.h @@ -56,7 +56,7 @@ struct preprocessor_params : public pattern_inference_params, bool m_nlquant_elim; public: - preprocessor_params(): + preprocessor_params(params_ref const & p = params_ref()): m_lift_ite(LI_NONE), m_ng_lift_ite(LI_NONE), m_pull_cheap_ite_trees(false), @@ -77,36 +77,12 @@ public: m_max_bv_sharing(true), m_pre_simplifier(true), m_nlquant_elim(false) { + updt_local_params(p); } -#if 0 - void register_params(ini_params & p) { - pattern_inference_params::register_params(p); - bit_blaster_params::register_params(p); - bv_simplifier_params::register_params(p); - arith_simplifier_params::register_params(p); - p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); - p.register_bool_param("elim_and", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); - p.register_bool_param("macro_finder", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); - p.register_bool_param("propagate_values", m_propagate_values, "propagate values during preprocessing step"); - p.register_bool_param("propagate_booleans", m_propagate_booleans, "propagate boolean values during preprocessing step"); - p.register_bool_param("pull_cheap_ite_trees", m_pull_cheap_ite_trees); - p.register_bool_param("pull_nested_quantifiers", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); - p.register_bool_param("refine_inj_axiom", m_refine_inj_axiom); - p.register_bool_param("elim_bounds", m_eliminate_bounds, "cheap Fourier-Motzkin"); - - p.register_bool_param("bit2int", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); - p.register_bool_param("distribute_forall", m_distribute_forall); - p.register_bool_param("reduce_args", m_reduce_args); - p.register_bool_param("quasi_macros", m_quasi_macros); - p.register_bool_param("restricted_quasi_macros", m_restricted_quasi_macros); - p.register_bool_param("bv_max_sharing", m_max_bv_sharing); - p.register_bool_param("pre_simplifier", m_pre_simplifier); - } -#endif + void updt_local_params(params_ref const & p); + void updt_params(params_ref const & p); }; #endif /* _PREPROCESSOR_PARAMS_H_ */ diff --git a/src/smt/params/qi_params.cpp b/src/smt/params/qi_params.cpp new file mode 100644 index 000000000..f5506d35b --- /dev/null +++ b/src/smt/params/qi_params.cpp @@ -0,0 +1,37 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + qi_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"qi_params.h" +#include"smt_params_helper.hpp" + +void qi_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_mbqi = p.mbqi(); + m_mbqi_max_cexs = p.mbqi_max_cexs(); + m_mbqi_max_cexs_incr = p.mbqi_max_cexs_incr(); + m_mbqi_max_iterations = p.mbqi_max_iterations(); + m_mbqi_trace = p.mbqi_trace(); + m_mbqi_force_template = p.mbqi_force_template(); + m_qi_profile = p.qi_profile(); + m_qi_profile_freq = p.qi_profile_freq(); + m_qi_max_instances = p.qi_max_instances(); + m_qi_eager_threshold = p.qi_eager_threshold(); + m_qi_lazy_threshold = p.qi_lazy_threshold(); + m_qi_cost = p.qi_cost(); + m_qi_max_eager_multipatterns = p.qi_max_multi_patterns(); +} diff --git a/src/smt/params/qi_params.h b/src/smt/params/qi_params.h index 1a8edb3a8..b0a21e75b 100644 --- a/src/smt/params/qi_params.h +++ b/src/smt/params/qi_params.h @@ -20,6 +20,7 @@ Revision History: #define _QI_PARAMS_H_ #include"util.h" +#include"params.h" enum quick_checker_mode { MC_NO, // do not use (cheap) model checking based instantiation @@ -53,7 +54,7 @@ struct qi_params { bool m_instgen; - qi_params(): + qi_params(params_ref const & p = params_ref()): /* The "weight 0" performance bug ------------------------------ @@ -93,49 +94,17 @@ struct qi_params { m_qi_max_instances(UINT_MAX), m_qi_lazy_instantiation(false), m_qi_conservative_final_check(false), -#ifdef _EXTERNAL_RELEASE m_mbqi(true), // enabled by default -#else - m_mbqi(false), // to avoid Rustan whining that the models are not partial anymore. -#endif m_mbqi_max_cexs(1), m_mbqi_max_cexs_incr(1), m_mbqi_max_iterations(1000), m_mbqi_trace(false), m_mbqi_force_template(10), m_instgen(false) { + updt_params(p); } -#if 0 - void register_params(ini_params & p) { - p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, - "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); - p.register_unsigned_param("qi_max_lazy_multi_pattern_matching", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); - p.register_string_param("qi_cost", m_qi_cost, "The cost function for quantifier instantiation"); - p.register_string_param("qi_new_gen", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); - p.register_double_param("qi_eager_threshold", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); - p.register_double_param("qi_lazy_threshold", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); - p.register_bool_param("qi_profile", m_qi_profile); - p.register_unsigned_param("qi_profile_freq", m_qi_profile_freq); - p.register_int_param("qi_quick_checker", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); - p.register_bool_param("qi_lazy_quick_checker", m_qi_lazy_quick_checker); - p.register_bool_param("qi_promote_unsat", m_qi_promote_unsat); - p.register_unsigned_param("qi_max_instances", m_qi_max_instances); - p.register_bool_param("qi_lazy_instantiation", m_qi_lazy_instantiation); - p.register_bool_param("qi_conservative_final_check", m_qi_conservative_final_check); - - - p.register_bool_param("mbqi", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); - p.register_unsigned_param("mbqi_max_cexs", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); - p.register_unsigned_param("mbqi_max_cexs_incr", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); - p.register_unsigned_param("mbqi_max_iterations", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); - p.register_bool_param("mbqi_trace", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); - p.register_unsigned_param("mbqi_force_template", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); - - p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); - } -#endif - + void updt_params(params_ref const & p); }; #endif /* _QI_PARAMS_H_ */ diff --git a/src/smt/params/smt_params.cpp b/src/smt/params/smt_params.cpp index 77d3660e6..70f0ad811 100644 --- a/src/smt/params/smt_params.cpp +++ b/src/smt/params/smt_params.cpp @@ -17,105 +17,33 @@ Revision History: --*/ #include"smt_params.h" -#include"trace.h" - -#if 0 -void smt_params::register_params(ini_params & p) { - dyn_ack_params::register_params(p); - qi_params::register_params(p); - theory_arith_params::register_params(p); - theory_array_params::register_params(p); - theory_bv_params::register_params(p); - theory_datatype_params::register_params(p); - - p.register_bool_param("check_proof", m_check_proof); - p.register_bool_param("display_proof", m_display_proof); - p.register_bool_param("display_dot_proof", m_display_dot_proof); - p.register_bool_param("display_unsat_core", m_display_unsat_core); - p.register_bool_param("eq_propagation", m_eq_propagation); - p.register_bool_param("bin_clauses", m_binary_clause_opt); - p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); - p.register_bool_param("relevancy_lemma", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); - p.register_unsigned_param("random_seed", m_random_seed, "random seed for Z3"); - p.register_percentage_param("random_case_split_freq", m_random_var_freq, "frequency of random case splits"); - p.register_int_param("phase_selection", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); - p.register_bool_param("minimize_lemmas", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); - p.register_unsigned_param("max_conflicts", m_max_conflicts, "maximum number of conflicts"); - - p.register_unsigned_param("recent_lemma_threshold", m_recent_lemmas_size); - p.register_unsigned_param("tick", m_tick); - - PRIVATE_PARAMS({ - p.register_bool_param("theory_resolve", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); - }); - - p.register_int_param("restart_strategy", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); - p.register_unsigned_param("restart_initial", m_restart_initial, - "inital restart frequency in number of conflicts, it is also the unit for the luby sequence"); - p.register_double_param("restart_factor", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); - p.register_bool_param("restart_adaptive", m_restart_adaptive, "disable restarts based on the search 'agility'"); - p.register_percentage_param("restart_agility_threshold", m_restart_agility_threshold); - - p.register_int_param("lemma_gc_strategy", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); - p.register_bool_param("lemma_gc_half", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); - p.register_unsigned_param("lemma_gc_initial", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); - p.register_double_param("lemma_gc_factor", m_lemma_gc_factor, "used by geometric strategy"); - p.register_unsigned_param("lemma_gc_new_old_ratio", m_new_old_ratio); - p.register_unsigned_param("lemma_gc_new_clause_activity", m_new_clause_activity); - p.register_unsigned_param("lemma_gc_old_clause_activity", m_old_clause_activity); - p.register_unsigned_param("lemma_gc_new_clause_relevancy", m_new_clause_relevancy); - p.register_unsigned_param("lemma_gc_old_clause_relevancy", m_old_clause_activity); - - p.register_bool_param("simplify_clauses", m_simplify_clauses); - - p.register_int_param("random_initial_activity", 0, 2, reinterpret_cast(m_random_initial_activity)); - - PRIVATE_PARAMS({ - - p.register_double_param("inv_decay", m_inv_decay); - p.register_unsigned_param("phase_caching_on_duration", m_phase_caching_on); - p.register_unsigned_param("phase_caching_off_duration", m_phase_caching_off); - }); - - p.register_bool_param("smtlib_dump_lemmas", m_smtlib_dump_lemmas); - p.register_string_param("smtlib_logic", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); - p.register_bool_param("display_features", m_display_features); - - p.register_bool_param("new_core2th_eq", m_new_core2th_eq); - p.register_bool_param("ematching", m_ematching, "E-Matching based quantifier instantiation"); - - p.register_bool_param("profile_res_sub", m_profile_res_sub); -#ifndef _EXTERNAL_RELEASE - p.register_bool_param("display_bool_var2expr", m_display_bool_var2expr); - p.register_bool_param("display_ll_bool_var2expr", m_display_ll_bool_var2expr); - p.register_bool_param("abort_after_preproc", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); - p.register_bool_param("display_installed_theories", m_display_installed_theories, "display theories installed at smt::context", true); -#endif - p.register_int_param("case_split", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); - p.register_unsigned_param("rel_case_split_order", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); - p.register_bool_param("lookahead_diseq", m_lookahead_diseq); - - p.register_bool_param("delay_units", m_delay_units); - p.register_unsigned_param("delay_units_threshold", m_delay_units_threshold); - - p.register_bool_param("model", m_model, "enable/disable model construction", true); - p.register_bool_param("model_validate", m_model_validate, "validate the model", true); - p.register_bool_param("model_on_timeout", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); - p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); - - p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); - - - p.register_bool_param("user_theory_preprocess_axioms", - m_user_theory_preprocess_axioms, - "Apply full pre-processing to user theory axioms", - true); - - p.register_bool_param("user_theory_persist_axioms", - m_user_theory_persist_axioms, - "Persist user axioms to the base level", - true); +#include"smt_params_helper.hpp" +void smt_params::updt_local_params(params_ref const & _p) { + smt_params_helper p(_p); + m_auto_config = p.auto_config(); + m_ematching = p.ematching(); + m_phase_selection = static_cast(p.phase_selection()); + m_restart_strategy = static_cast(p.restart_strategy()); + m_restart_factor = p.restart_factor(); + m_case_split_strategy = static_cast(p.case_split()); + m_delay_units = p.delay_units(); + m_delay_units_threshold = p.delay_units_threshold(); +} + +void smt_params::updt_params(params_ref const & p) { + preprocessor_params::updt_params(p); + qi_params::updt_params(p); + theory_arith_params::updt_params(p); + theory_bv_params::updt_params(p); + updt_local_params(p); +} + +void smt_params::updt_params(context_params const & p) { + m_auto_config = p.m_auto_config; + m_soft_timeout = p.m_timeout; + m_model = p.m_model; + m_model_validate = p.m_validate_model; + m_proof_mode = p.m_proof ? PGM_FINE : PGM_DISABLED; } -#endif diff --git a/src/smt/params/smt_params.h b/src/smt/params/smt_params.h index 68e5a596d..ec057239a 100644 --- a/src/smt/params/smt_params.h +++ b/src/smt/params/smt_params.h @@ -27,6 +27,7 @@ Revision History: #include"theory_bv_params.h" #include"theory_datatype_params.h" #include"preprocessor_params.h" +#include"context_params.h" enum phase_selection { PS_ALWAYS_FALSE, @@ -209,23 +210,7 @@ struct smt_params : public preprocessor_params, proof_gen_mode m_proof_mode; bool m_auto_config; -#if 0 - unsigned m_memory_high_watermark; - unsigned m_memory_max_size; - - bool m_auto_config; - - bool m_debug_ref_count; - - m_well_sorted_check(true), - m_memory_high_watermark(0), - m_memory_max_size(0), - - m_auto_config(true), - m_debug_ref_count(false) { -#endif - - smt_params(): + smt_params(params_ref const & p = params_ref()): m_display_proof(false), m_display_dot_proof(false), m_display_unsat_core(false), @@ -294,7 +279,14 @@ struct smt_params : public preprocessor_params, m_dump_goal_as_smt(false), m_proof_mode(PGM_DISABLED), m_auto_config(true) { + updt_local_params(p); } + + void updt_local_params(params_ref const & p); + + void updt_params(params_ref const & p); + + void updt_params(context_params const & p); }; #endif /* _SMT_PARAMS_H_ */ diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg new file mode 100644 index 000000000..8db95a581 --- /dev/null +++ b/src/smt/params/smt_params_helper.pyg @@ -0,0 +1,38 @@ +def_module_params(module_name='smt', + class_name='smt_params_helper', + description='smt solver based on lazy smt', + export=True, + params=(('auto_config', BOOL, True, 'automatically configure solver'), + ('macro_finder', BOOL, False, 'try to find universally quantified formulas that can be viewed as macros'), + ('ematching', BOOL, True, 'E-Matching based quantifier instantiation'), + ('phase_selection', UINT, 4, 'phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences'), + ('restart_strategy', UINT, 1, '0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic'), + ('restart_factor', DOUBLE, 1.1, 'when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold'), + ('case_split', UINT, 1, '0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal'), + ('delay_units', BOOL, False, 'if true then z3 will not restart when a unit clause is learned'), + ('delay_units_threshold', UINT, 32, 'maximum number of learned unit clauses before restarting, ingored if delay_units is false'), + ('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'), + ('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'), + ('mbqi.max_cexs_incr', UINT, 0, 'increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI'), + ('mbqi.max_iterations', UINT, 1000, 'maximum number of rounds of MBQI'), + ('mbqi.trace', BOOL, False, 'generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied'), + ('mbqi.force_template', UINT, 10, 'some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= mbqi.force_template are forced to be used as a template'), + ('qi.profile', BOOL, False, 'profile quantifier instantiation'), + ('qi.profile_freq', UINT, UINT_MAX, 'how frequent results are reported by qi.profile'), + ('qi.max_instances', UINT, UINT_MAX, 'maximum number of quantifier instantiations'), + ('qi.eager_threshold', DOUBLE, 10.0, 'threshold for eager quantifier instantiation'), + ('qi.lazy_threshold', DOUBLE, 20.0, 'threshold for lazy quantifier instantiation'), + ('qi.cost', STRING, '(+ weight generation)', 'expression specifying what is the cost of a given quantifier instantiation'), + ('qi.max_multi_patterns', UINT, 0, 'specify the number of extra multi patterns'), + ('bv.reflect', BOOL, True, 'create enode for every bit-vector term'), + ('arith.random_initial_value', BOOL, False, 'use random initial values in the simplex-based procedure for linear arithmetic'), + ('arith.solver', UINT, 2, 'arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination'), + ('arith.nl', BOOL, True, '(incomplete) nonlinear arithmetic support based on Groebner basis and interval propagation'), + ('arith.nl.gb', BOOL, True, 'groebner Basis computation, this option is ignored when arith.nl=false'), + ('arith.nl.branching', BOOL, True, 'branching on integer variables in non linear clusters'), + ('arith.nl.rounds', UINT, 1024, 'threshold for number of (nested) final checks for non linear arithmetic'), + ('arith.euclidean_solver', BOOL, False, 'eucliean solver for linear integer arithmetic'), + ('arith.propagate_eqs', BOOL, True, 'propagate (cheap) equalities'), + ('arith.branch_cut_ratio', UINT, 2, 'branch/cut ratio for linear integer arithmetic'), + ('arith.int_eq_branch', BOOL, False, 'branching using derived integer equations'), + ('arith.ignore_int', BOOL, False, 'treat integer variables as real'))) diff --git a/src/smt/params/theory_arith_params.cpp b/src/smt/params/theory_arith_params.cpp index 8dde26e94..5a1101524 100644 --- a/src/smt/params/theory_arith_params.cpp +++ b/src/smt/params/theory_arith_params.cpp @@ -16,63 +16,22 @@ Author: Revision History: --*/ - #include"theory_arith_params.h" +#include"smt_params_helper.hpp" -#if 0 -void theory_arith_params::register_params(ini_params & p) { -#ifdef _EXTERNAL_RELEASE - p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); -#else - p.register_int_param("arith_solver", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); -#endif - p.register_bool_param("arith_force_simplex", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); - p.register_unsigned_param("arith_blands_rule_threshold", m_arith_blands_rule_threshold); - p.register_bool_param("arith_propagate_eqs", m_arith_propagate_eqs); - p.register_int_param("arith_propagation_mode", 0, 2, reinterpret_cast(m_arith_bound_prop)); - p.register_bool_param("arith_stronger_lemmas", m_arith_stronger_lemmas); - p.register_bool_param("arith_skip_big_coeffs", m_arith_skip_rows_with_big_coeffs); - p.register_unsigned_param("arith_max_lemma_size", m_arith_max_lemma_size); - p.register_unsigned_param("arith_small_lemma_size", m_arith_small_lemma_size); - p.register_bool_param("arith_reflect", m_arith_reflect); - p.register_bool_param("arith_ignore_int", m_arith_ignore_int); - p.register_unsigned_param("arith_lazy_pivoting", m_arith_lazy_pivoting_lvl); - p.register_unsigned_param("arith_random_seed", m_arith_random_seed); - p.register_bool_param("arith_random_initial_value", m_arith_random_initial_value); - p.register_int_param("arith_random_lower", m_arith_random_lower); - p.register_int_param("arith_random_upper", m_arith_random_upper); - p.register_bool_param("arith_adaptive", m_arith_adaptive); - p.register_double_param("arith_adaptive_assertion_threshold", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); - p.register_double_param("arith_adaptive_propagation_threshold", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); - p.register_bool_param("arith_dump_lemmas", m_arith_dump_lemmas); - p.register_bool_param("arith_eager_eq_axioms", m_arith_eager_eq_axioms); - p.register_unsigned_param("arith_branch_cut_ratio", m_arith_branch_cut_ratio); - - p.register_bool_param("arith_add_binary_bounds", m_arith_add_binary_bounds); - p.register_unsigned_param("arith_prop_strategy", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); - - p.register_bool_param("arith_eq_bounds", m_arith_eq_bounds); - p.register_bool_param("arith_lazy_adapter", m_arith_lazy_adapter); - p.register_bool_param("arith_gcd_test", m_arith_gcd_test); - p.register_bool_param("arith_eager_gcd", m_arith_eager_gcd); - p.register_bool_param("arith_adaptive_gcd", m_arith_adaptive_gcd); - p.register_unsigned_param("arith_propagation_threshold", m_arith_propagation_threshold); - - p.register_bool_param("nl_arith", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); - p.register_bool_param("nl_arith_gb", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); - p.register_bool_param("nl_arith_gb_eqs", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); - p.register_bool_param("nl_arith_gb_perturbate", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); - p.register_unsigned_param("nl_arith_gb_threshold", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); - p.register_bool_param("nl_arith_branching", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); - p.register_unsigned_param("nl_arith_rounds", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); - p.register_unsigned_param("nl_arith_max_degree", m_nl_arith_max_degree, "max degree for internalizing new monomials."); - PRIVATE_PARAMS({ - p.register_bool_param("arith_fixnum", m_arith_fixnum); - p.register_bool_param("arith_int_only", m_arith_int_only); - p.register_bool_param("arith_enum_const_mod", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); - p.register_bool_param("arith_int_eq_branching", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); - }); - p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); +void theory_arith_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_arith_random_initial_value = p.arith_random_initial_value(); + m_arith_mode = static_cast(p.arith_solver()); + m_nl_arith = p.arith_nl(); + m_nl_arith_gb = p.arith_nl_gb(); + m_nl_arith_branching = p.arith_nl_branching(); + m_nl_arith_rounds = p.arith_nl_rounds(); + m_arith_euclidean_solver = p.arith_euclidean_solver(); + m_arith_propagate_eqs = p.arith_propagate_eqs(); + m_arith_branch_cut_ratio = p.arith_branch_cut_ratio(); + m_arith_int_eq_branching = p.arith_int_eq_branch(); + m_arith_ignore_int = p.arith_ignore_int(); } -#endif + diff --git a/src/smt/params/theory_arith_params.h b/src/smt/params/theory_arith_params.h index 01163dd0a..52fef8ca4 100644 --- a/src/smt/params/theory_arith_params.h +++ b/src/smt/params/theory_arith_params.h @@ -20,6 +20,7 @@ Revision History: #define _THEORY_ARITH_PARAMS_H_ #include +#include"params.h" enum arith_solver_id { AS_NO_ARITH, @@ -104,7 +105,7 @@ struct theory_arith_params { bool m_arith_euclidean_solver; - theory_arith_params(): + theory_arith_params(params_ref const & p = params_ref()): m_arith_mode(AS_ARITH), m_arith_auto_config_simplex(false), m_arith_blands_rule_threshold(1000), @@ -149,7 +150,10 @@ struct theory_arith_params { m_nl_arith_branching(true), m_nl_arith_rounds(1024), m_arith_euclidean_solver(false) { + updt_params(p); } + + void updt_params(params_ref const & p); }; #endif /* _THEORY_ARITH_PARAMS_H_ */ diff --git a/src/smt/params/theory_bv_params.cpp b/src/smt/params/theory_bv_params.cpp new file mode 100644 index 000000000..c2a31c59d --- /dev/null +++ b/src/smt/params/theory_bv_params.cpp @@ -0,0 +1,25 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + theory_bv_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"theory_bv_params.h" +#include"smt_params_helper.hpp" + +void theory_bv_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_bv_reflect = p.bv_reflect(); +} diff --git a/src/smt/params/theory_bv_params.h b/src/smt/params/theory_bv_params.h index 18a3bac77..a3052b4e9 100644 --- a/src/smt/params/theory_bv_params.h +++ b/src/smt/params/theory_bv_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _THEORY_BV_PARAMS_H_ #define _THEORY_BV_PARAMS_H_ +#include"params.h" + enum bv_solver_id { BS_NO_BV, BS_BLASTER @@ -31,24 +33,17 @@ struct theory_bv_params { bool m_bv_cc; unsigned m_bv_blast_max_size; bool m_bv_enable_int2bv2int; - theory_bv_params(): + theory_bv_params(params_ref const & p = params_ref()): m_bv_mode(BS_BLASTER), m_bv_reflect(true), m_bv_lazy_le(false), m_bv_cc(false), m_bv_blast_max_size(INT_MAX), - m_bv_enable_int2bv2int(false) {} -#if 0 - void register_params(ini_params & p) { - p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); - p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); - p.register_bool_param("bv_reflect", m_bv_reflect); - p.register_bool_param("bv_lazy_le", m_bv_lazy_le); - p.register_bool_param("bv_cc", m_bv_cc, "enable congruence closure for BV operators"); - p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, - "enable full (potentially expensive) propagation for int2bv and bv2int"); - } -#endif + m_bv_enable_int2bv2int(false) { + updt_params(p); + } + + void updt_params(params_ref const & p); }; #endif /* _THEORY_BV_PARAMS_H_ */ diff --git a/src/smt/smt_kernel.cpp b/src/smt/smt_kernel.cpp index 977f0ee4a..23687af8c 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -179,7 +179,9 @@ namespace smt { } void updt_params(params_ref const & p) { - params2smt_params(p, fparams()); + // We don't need params2smt_params anymore. smt_params has support for reading params_ref. + // The update is performed at smt_kernel "users". + // params2smt_params(p, fparams()); } }; diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index ad653a968..2aa4ee28f 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -36,7 +36,7 @@ namespace smt { } virtual void updt_params(params_ref const & p) { - // PARAM-TODO copy p --> m_params + m_params.updt_params(p); if (m_context == 0) return; m_context->updt_params(p); diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index a8694363c..20b6585e1 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -24,7 +24,7 @@ Notes: #include"rewriter_types.h" class smt_tactic : public tactic { - smt_params m_params; + smt_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -63,9 +63,7 @@ public: virtual void updt_params(params_ref const & p) { TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); - m_params_ref = p; - // PARAM-TODO update params2smt_params p ---> m_params - params2smt_params(m_params_ref, fparams()); + fparams().updt_params(p); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } From a813c384a6ae1dcce168431ff9019a9f942a16ed Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 2 Dec 2012 15:33:18 -0800 Subject: [PATCH 090/133] fix bug in proof generation for PDR, add more features for handling quantifiers Signed-off-by: Nikolaj Bjorner --- src/muz_qe/equiv_proof_converter.cpp | 33 ++++ src/muz_qe/equiv_proof_converter.h | 8 +- src/muz_qe/pdr_context.cpp | 47 +++++- src/muz_qe/pdr_context.h | 9 +- src/muz_qe/pdr_quantifiers.cpp | 35 +++- src/muz_qe/pdr_util.cpp | 21 ++- src/muz_qe/pdr_util.h | 2 + src/muz_qe/qe_lite.cpp | 241 +++++++++++++++++++++++++-- 8 files changed, 356 insertions(+), 40 deletions(-) create mode 100644 src/muz_qe/equiv_proof_converter.cpp diff --git a/src/muz_qe/equiv_proof_converter.cpp b/src/muz_qe/equiv_proof_converter.cpp new file mode 100644 index 000000000..8b821227b --- /dev/null +++ b/src/muz_qe/equiv_proof_converter.cpp @@ -0,0 +1,33 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + equiv_proof_converter.cpp + +Abstract: + + Proof converter that applies equivalence rule to leaves. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-11-23 + +Revision History: + +--*/ + +#include "equiv_proof_converter.h" +#include "ast_pp.h" +#include "dl_util.h" + +void equiv_proof_converter::insert(expr* fml1, expr* fml2) { + datalog::scoped_fine_proof _sp(m); + 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); + TRACE("proof_converter", tout << mk_pp(p3.get(), m) << "\n";); + SASSERT(m.has_fact(p3)); + m_replace.insert(p3); +} diff --git a/src/muz_qe/equiv_proof_converter.h b/src/muz_qe/equiv_proof_converter.h index 94d6f4e04..01dd0a238 100644 --- a/src/muz_qe/equiv_proof_converter.h +++ b/src/muz_qe/equiv_proof_converter.h @@ -43,13 +43,7 @@ public: 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); - } + void insert(expr* fml1, expr* fml2); ast_manager& get_manager() { return m; } diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index e56c332a1..bc49769c8 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -162,9 +162,6 @@ namespace pdr { } } - void pred_transformer::find_predecessors(model_core const& model, ptr_vector& preds) const { - find_predecessors(find_rule(model), preds); - } void pred_transformer::remove_predecessors(expr_ref_vector& literals) { // remove tags @@ -740,6 +737,44 @@ namespace pdr { return expr_ref(m.mk_app(f, args.size(), args.c_ptr()), m); } + static bool is_ini(datalog::rule const& r) { + return r.get_uninterpreted_tail_size() == 0; + } + + datalog::rule* model_node::get_rule() { + if (m_rule) { + return const_cast(m_rule); + } + // only initial states are not set by the PDR search. + datalog::rule const& rl1 = pt().find_rule(*m_model); + if (is_ini(rl1)) { + set_rule(&rl1); + return const_cast(m_rule); + } + ast_manager& m = pt().get_manager(); + // otherwise, the initial state is reachable. + ptr_vector const& rules = pt().rules(); + ptr_vector ini_rules; + expr_ref_vector tags(m); + expr_ref ini_tags(m), ini_state(m); + for (unsigned i = 0; i < rules.size(); ++i) { + datalog::rule* rl = rules[i]; + if (is_ini(*rl)) { + tags.push_back(pt().rule2tag(rl)); + } + } + SASSERT(!tags.empty()); + ini_tags = m.mk_or(tags.size(), tags.c_ptr()); + ini_state = m.mk_and(ini_tags, pt().initial_state(), state()); + model_ref mdl; + pt().get_solver().set_model(&mdl); + VERIFY(l_true == pt().get_solver().check_conjunction_as_assumptions(ini_state)); + datalog::rule const& rl2 = pt().find_rule(*mdl); + SASSERT(is_ini(rl2)); + set_rule(&rl2); + return const_cast(m_rule); + } + void model_node::mk_instantiate(datalog::rule_ref& r0, datalog::rule_ref& r1, expr_ref_vector& binding) { ast_manager& m = pt().get_manager(); @@ -763,7 +798,7 @@ namespace pdr { model.insert(e, m.mk_true()); } } - r0 = const_cast(&pt().find_rule(*m_model.get())); + r0 = get_rule(); app_ref_vector& inst = pt().get_inst(r0); TRACE("pdr", tout << mk_pp(state(), m) << " instance: " << inst.size() << "\n";); for (unsigned i = 0; i < inst.size(); ++i) { @@ -1644,7 +1679,7 @@ namespace pdr { switch (expand_state(n, cube, uses_level)) { case l_true: if (n.level() == 0) { - TRACE("pdr", tout << "reachable\n";); + TRACE("pdr", tout << "reachable at level 0\n";); close_node(n); } else { @@ -1772,6 +1807,8 @@ namespace pdr { expr* T = pt.get_transition(r); expr* phi = n.state(); + n.set_rule(&r); + IF_VERBOSE(3, verbose_stream() << "Model:\n"; model_smt2_pp(verbose_stream(), m, *M, 0); verbose_stream() << "\n"; diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index a201ac03b..c52412db5 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -132,7 +132,6 @@ namespace pdr { bool is_reachable(expr* state); void remove_predecessors(expr_ref_vector& literals); void find_predecessors(datalog::rule const& r, ptr_vector& predicates) const; - void find_predecessors(model_core const& model, ptr_vector& preds) const; datalog::rule const& find_rule(model_core const& model) const; expr* get_transition(datalog::rule const& r) { return m_rule2transition.find(&r); } ptr_vector& get_aux_vars(datalog::rule const& r) { return m_rule2vars.find(&r); } @@ -163,6 +162,8 @@ namespace pdr { void ground_free_vars(expr* e, app_ref_vector& vars, ptr_vector& aux_vars); + prop_solver& get_solver() { return m_solver; } + }; @@ -177,10 +178,11 @@ namespace pdr { unsigned m_orig_level; unsigned m_depth; bool m_closed; + datalog::rule const* m_rule; public: model_node(model_node* parent, expr_ref& state, pred_transformer& pt, unsigned level): m_parent(parent), m_pt(pt), m_state(state), m_model(0), - m_level(level), m_orig_level(level), m_depth(0), m_closed(false) { + m_level(level), m_orig_level(level), m_depth(0), m_closed(false), m_rule(0) { if (m_parent) { m_parent->m_children.push_back(this); SASSERT(m_parent->m_level == level+1); @@ -217,6 +219,9 @@ namespace pdr { void set_pre_closed() { m_closed = true; } void reset() { m_children.reset(); } + void set_rule(datalog::rule const* r) { m_rule = r; } + datalog::rule* get_rule(); + expr_ref get_trace() const; void mk_instantiate(datalog::rule_ref& r0, datalog::rule_ref& r1, expr_ref_vector& binding); diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 7922b76c9..455795adc 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -105,7 +105,11 @@ namespace pdr { } - void quantifier_model_checker::add_binding(quantifier* q, expr_ref_vector& binding) { + void quantifier_model_checker::add_binding(quantifier* q, expr_ref_vector& binding) { + if (binding.size() != q->get_num_decls()) { + // not a full binding. It may happen that the quantifier got simplified. + return; + } apply_binding(q, binding); vector bindings; generalize_binding(binding, bindings); @@ -126,15 +130,18 @@ namespace pdr { inst.append(var_inst.size(), (expr*const*)var_inst.c_ptr()); inst.reverse(); expr_abstract(m, 0, inst.size(), inst.c_ptr(), e, e); + if (m_instantiations.contains(to_app(e))) { + return; + } m_instantiated_rules.push_back(m_current_rule); m_instantiations.push_back(to_app(e)); TRACE("pdr", tout << mk_pp(q, m) << "\n"; - tout << "binding\n"; + tout << "binding: "; for (unsigned i = 0; i < binding.size(); ++i) { tout << mk_pp(binding[i].get(), m) << " "; } tout << "\n"; - tout << "inst\n"; + tout << "inst: "; for (unsigned i = 0; i < var_inst.size(); ++i) { tout << mk_pp(var_inst[i].get(), m) << " "; } @@ -361,6 +368,7 @@ namespace pdr { scoped_ptr rep = mk_default_expr_replacer(m); for (unsigned j = 0; j < qis.size(); ++j) { q = qis[j].get(); + SASSERT(is_forall(q)); app_ref_vector& inst = pt.get_inst(m_current_rule); TRACE("pdr", tout << "q:\n" << mk_pp(q, m) << "\n"; @@ -433,11 +441,16 @@ namespace pdr { unsigned t_size = r.get_tail_size(); var_subst vs(m, false); sort_ref_vector vars(m); + uint_set empty_index_set; + qe_lite qe(m); + r.get_vars(vars); +#if 1 if (qis) { quantifier_ref_vector const& qi = *qis; for (unsigned i = 0; i < qi.size(); ++i) { - fml = qi[i]->get_expr(); + quantifier* q = qi[i]; + fml = q->get_expr(); a = to_app(fml); p = a->get_decl(); expr* p_reach = get_reachable(p); @@ -448,9 +461,17 @@ namespace pdr { sub.insert(v, a->get_arg(j)); } sub(p_reach, fml); - body.push_back(m.update_quantifier(qi[i], fml)); + uint_set is; + for (unsigned j = 0; j < q->get_num_decls(); ++j) { + is.insert(j); + } + fml = m.mk_not(fml); + qe(is, true, fml); + fml = m.mk_not(fml); + body.push_back(m.update_quantifier(q, fml)); } } +#endif a = r.get_head(); for (unsigned i = 0; i < a->get_num_args(); ++i) { v = m.mk_var(vars.size()+i, m.get_sort(a->get_arg(i))); @@ -489,8 +510,6 @@ namespace pdr { SASSERT(is_well_sorted(m, fml)); if (!vars.empty()) { fml = to_quantifier(fml)->get_expr(); - uint_set empty_index_set; - qe_lite qe(m); qe(empty_index_set, false, fml); fml = m.mk_exists(vars.size(), vars.c_ptr(), names.c_ptr(), fml); SASSERT(is_well_sorted(m, fml)); @@ -498,7 +517,7 @@ namespace pdr { } SASSERT(is_well_sorted(m, fml)); - IF_VERBOSE(0, verbose_stream() << "instantiate to\n:" << mk_pp(fml, m) << "\n";); + IF_VERBOSE(0, verbose_stream() << "instantiate to:\n" << mk_pp(fml, m) << "\n";); return fml; } diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index db11b5b20..ed8445b1e 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -386,13 +386,12 @@ namespace pdr { for_each_expr(*this, m_visited, tocollect[i]); } unsigned sz = m_model->get_num_constants(); - expr_ref e(m), eq(m); + expr_ref e(m), eq(m), val(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); + e = m.mk_const(m_model->get_constant(i)); if (m_visited.is_marked(e)) { + val = eval(m_model, e); eq = m.mk_eq(e, val); model.push_back(eq); } @@ -923,6 +922,20 @@ namespace pdr { return !has_x; } + expr_ref model_evaluator::eval(model_ref& model, func_decl* d) { + SASSERT(d->get_arity() == 0); + expr_ref result(m); + if (m_array.is_array(d->get_range())) { + expr_ref e(m); + e = m.mk_const(d); + result = eval(model, e); + } + else { + result = model->get_const_interp(d); + } + return result; + } + expr_ref model_evaluator::eval(model_ref& model, expr* e) { expr_ref result(m); m_model = model; diff --git a/src/muz_qe/pdr_util.h b/src/muz_qe/pdr_util.h index 89598d347..220e56b3c 100644 --- a/src/muz_qe/pdr_util.h +++ b/src/muz_qe/pdr_util.h @@ -129,6 +129,8 @@ namespace pdr { void operator()(expr* e) {} expr_ref eval(model_ref& mdl, expr* e); + + expr_ref eval(model_ref& mdl, func_decl* d); }; /** diff --git a/src/muz_qe/qe_lite.cpp b/src/muz_qe/qe_lite.cpp index 43008a1d6..68eadb5f5 100644 --- a/src/muz_qe/qe_lite.cpp +++ b/src/muz_qe/qe_lite.cpp @@ -33,6 +33,8 @@ Revision History: #include "dl_util.h" #include "th_rewriter.h" #include "dl_util.h" +#include "for_each_expr.h" +#include "expr_safe_replace.h" class is_variable_proc { @@ -77,9 +79,10 @@ public: namespace eq { class der { ast_manager & m; + arith_util a; is_variable_proc* m_is_variable; var_subst m_subst; - expr_ref_buffer m_new_exprs; + expr_ref_vector m_new_exprs; ptr_vector m_map; int_vector m_pos2var; @@ -225,7 +228,81 @@ namespace eq { return false; } } + + bool solve_arith_core(app * lhs, expr * rhs, expr * eq, var* & var, expr_ref & def) { + SASSERT(a.is_add(lhs)); + bool is_int = a.is_int(lhs); + expr * a1; + expr * v; + rational a_val; + unsigned num = lhs->get_num_args(); + unsigned i; + for (i = 0; i < num; i++) { + expr * arg = lhs->get_arg(i); + if (is_variable(arg)) { + a_val = rational(1); + v = arg; + break; + } + else if (a.is_mul(arg, a1, v) && + is_variable(v) && + a.is_numeral(a1, a_val) && + !a_val.is_zero() && + (!is_int || a_val.is_minus_one())) { + break; + } + } + if (i == num) + return false; + var = to_var(v); + expr_ref inv_a(m); + if (!a_val.is_one()) { + inv_a = a.mk_numeral(rational(1)/a_val, is_int); + rhs = a.mk_mul(inv_a, rhs); + } + + ptr_buffer other_args; + for (unsigned j = 0; j < num; j++) { + if (i != j) { + if (inv_a) + other_args.push_back(a.mk_mul(inv_a, lhs->get_arg(j))); + else + other_args.push_back(lhs->get_arg(j)); + } + } + switch (other_args.size()) { + case 0: + def = rhs; + break; + case 1: + def = a.mk_sub(rhs, other_args[0]); + break; + default: + def = a.mk_sub(rhs, a.mk_add(other_args.size(), other_args.c_ptr())); + break; + } + m_new_exprs.push_back(def); + return true; + } + bool arith_solve(expr * lhs, expr * rhs, expr * eq, var* & var, expr_ref & t) { + return + (a.is_add(lhs) && solve_arith_core(to_app(lhs), rhs, eq, var, t)) || + (a.is_add(rhs) && solve_arith_core(to_app(rhs), lhs, eq, var, t)); + } + + bool trival_solve(expr* lhs, expr* rhs, expr* eq, var* & v, expr_ref& t) { + if (!is_variable(lhs)) { + std::swap(lhs, rhs); + } + if (!is_variable(lhs)) { + return false; + } + v = to_var(lhs); + t = rhs; + TRACE("der", tout << mk_pp(eq, m) << "\n";); + return true; + } /** @@ -251,14 +328,13 @@ namespace eq { TRACE("der", tout << mk_pp(e, m) << "\n";); return true; } - if (!is_variable(lhs)) - std::swap(lhs, rhs); - if (!is_variable(lhs)) - return false; - v = to_var(lhs); - t = rhs; - TRACE("der", tout << mk_pp(e, m) << "\n";); - return true; + if (trival_solve(lhs, rhs, e, v, t)) { + return true; + } + if (arith_solve(lhs, rhs, e, v, t)) { + return true; + } + return false; } // (ite cond (= VAR t) (= VAR t2)) case @@ -494,7 +570,7 @@ namespace eq { } public: - der(ast_manager & m): m(m), m_is_variable(0), m_subst(m), m_new_exprs(m), m_subst_map(m), m_new_args(m), m_rewriter(m) {} + der(ast_manager & m): m(m), a(m), m_is_variable(0), m_subst(m), m_new_exprs(m), m_subst_map(m), m_new_args(m), m_rewriter(m) {} void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} @@ -538,20 +614,129 @@ namespace eq { namespace ar { class der { ast_manager& m; + array_util a; is_variable_proc* m_is_variable; + ptr_vector m_todo; + expr_mark m_visited; bool is_variable(expr * e) const { return (*m_is_variable)(e); } + void mark_all(expr* e) { + for_each_expr(*this, m_visited, e); + } + + void mark_all(expr_ref_vector const& fmls, unsigned j) { + for (unsigned i = 0; i < fmls.size(); ++i) { + if (i != j) { + mark_all(fmls[i]); + } + } + } + + /** + Ex A. A[x] = t & Phi where x \not\in A, t. + => + Ex A. Phi[store(A,x,t)] + */ + + bool solve_select(expr_ref_vector& conjs, unsigned i, expr* e1, expr* e2) { + if (a.is_select(e1)) { + app* a1 = to_app(e1); + expr* A = a1->get_arg(0); + if (!is_variable(A)) { + return false; + } + m_visited.reset(); + for (unsigned j = 1; j < a1->get_num_args(); ++j) { + mark_all(a1->get_arg(j)); + } + mark_all(e2); + if (m_visited.is_marked(A)) { + return false; + } + ptr_vector args; + args.push_back(A); + args.append(a1->get_num_args()-1, a1->get_args()+1); + args.push_back(e2); + expr* B = a.mk_store(args.size(), args.c_ptr()); + expr_safe_replace rep(m); + rep.insert(A, B); + expr_ref tmp(m); + for (unsigned j = 0; j < conjs.size(); ++j) { + if (i == j) { + conjs[j] = m.mk_true(); + } + else { + rep(conjs[j].get(), tmp); + conjs[j] = tmp; + } + } + return true; + } + return false; + } + + bool solve_select(expr_ref_vector& conjs, unsigned i, expr* e) { + expr* e1, *e2; + return + m.is_eq(e, e1, e2) && + (solve_select(conjs, i, e1, e2) || + solve_select(conjs, i, e2, e1)); + } + + /** + Ex x. A[x] != B[x] & Phi where x \not\in A, B, Phi + => + A != B & Phi + */ + bool solve_neq_select(expr_ref_vector& conjs, unsigned i, expr* e) { + expr* e1, *a1, *a2; + if (m.is_not(e, e1) && m.is_eq(e1, a1, a2)) { + if (a.is_select(a1) && + a.is_select(a2) && + to_app(a1)->get_num_args() == to_app(a2)->get_num_args()) { + expr* e1 = to_app(a1)->get_arg(0); + expr* e2 = to_app(a2)->get_arg(0); + m_visited.reset(); + mark_all(conjs, i); + mark_all(e1); + mark_all(e2); + for (unsigned j = 1; j < to_app(a1)->get_num_args(); ++j) { + expr* x = to_app(a1)->get_arg(j); + expr* y = to_app(a2)->get_arg(j); + if (!is_variable(x)) { + return false; + } + if (x != y) { + return false; + } + if (m_visited.is_marked(x)) { + return false; + } + } + conjs[i] = m.mk_not(m.mk_eq(e1, e2)); + return true; + } + } + return false; + } + + public: - der(ast_manager& m): m(m), m_is_variable(0) {} + der(ast_manager& m): m(m), a(m), m_is_variable(0) {} void operator()(expr_ref_vector& fmls) { - IF_VERBOSE(1, verbose_stream() << "Todo: eliminate arrays\n";); + for (unsigned i = 0; i < fmls.size(); ++i) { + solve_select(fmls, i, fmls[i].get()); + solve_neq_select(fmls, i, fmls[i].get()); + } } + void operator()(expr* e) {} + void set_is_variable_proc(is_variable_proc& proc) { m_is_variable = &proc;} }; @@ -1904,6 +2089,22 @@ class qe_lite::impl { fm::fm m_fm; ar::der m_array_der; + bool has_unique_non_ground(expr_ref_vector const& fmls, unsigned& index) { + index = fmls.size(); + if (index <= 1) { + return false; + } + for (unsigned i = 0; i < fmls.size(); ++i) { + if (!is_ground(fmls[i])) { + if (index != fmls.size()) { + return false; + } + index = i; + } + } + return index < fmls.size(); + } + public: impl(ast_manager& m): m(m), m_der(m), m_fm(m, m_params), m_array_der(m) {} @@ -1970,9 +2171,21 @@ public: void operator()(uint_set const& index_set, bool index_of_bound, expr_ref_vector& fmls) { datalog::flatten_and(fmls); + unsigned index; + if (has_unique_non_ground(fmls, index)) { + expr_ref fml(m); + fml = fmls[index].get(); + (*this)(index_set, index_of_bound, fml); + fmls[index] = fml; + return; + } + TRACE("qe_lite", for (unsigned i = 0; i < fmls.size(); ++i) { + tout << mk_pp(fmls[i].get(), m) << "\n"; + }); + IF_VERBOSE(3, for (unsigned i = 0; i < fmls.size(); ++i) { + verbose_stream() << mk_pp(fmls[i].get(), m) << "\n"; + }); is_variable_test is_var(index_set, index_of_bound); - TRACE("qe_lite", for (unsigned i = 0; i < fmls.size(); ++i) tout << mk_pp(fmls[i].get(), m) << "\n";); - IF_VERBOSE(3, for (unsigned i = 0; i < fmls.size(); ++i) verbose_stream() << mk_pp(fmls[i].get(), m) << "\n";); m_der.set_is_variable_proc(is_var); m_fm.set_is_variable_proc(is_var); m_array_der.set_is_variable_proc(is_var); From 0934cb06d8d75b36babc7eb0fda67b4610acee93 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 16:38:33 -0800 Subject: [PATCH 091/133] exposed sat params Signed-off-by: Leonardo de Moura --- src/sat/sat_asymm_branch.cpp | 14 +++--- src/sat/sat_asymm_branch_params.pyg | 6 +++ src/sat/sat_config.cpp | 70 ++++++++++++----------------- src/sat/sat_params.pyg | 20 +++++++++ src/sat/sat_scc.cpp | 8 ++-- src/sat/sat_scc_params.pyg | 5 +++ src/sat/sat_simplifier.cpp | 56 +++++++++-------------- src/sat/sat_simplifier_params.pyg | 19 ++++++++ 8 files changed, 111 insertions(+), 87 deletions(-) create mode 100644 src/sat/sat_asymm_branch_params.pyg create mode 100644 src/sat/sat_params.pyg create mode 100644 src/sat/sat_scc_params.pyg create mode 100644 src/sat/sat_simplifier_params.pyg diff --git a/src/sat/sat_asymm_branch.cpp b/src/sat/sat_asymm_branch.cpp index a7209306a..81d631e4e 100644 --- a/src/sat/sat_asymm_branch.cpp +++ b/src/sat/sat_asymm_branch.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"sat_asymm_branch.h" +#include"sat_asymm_branch_params.hpp" #include"sat_solver.h" #include"stopwatch.h" #include"trace.h" @@ -193,18 +194,17 @@ namespace sat { } } - void asymm_branch::updt_params(params_ref const & p) { - m_asymm_branch = p.get_bool("asymm_branch", true); - m_asymm_branch_rounds = p.get_uint("asymm_branch_rounds", 32); - m_asymm_branch_limit = p.get_uint("asymm_branch_limit", 100000000); + void asymm_branch::updt_params(params_ref const & _p) { + sat_asymm_branch_params p(_p); + m_asymm_branch = p.asymm_branch(); + m_asymm_branch_rounds = p.asymm_branch_rounds(); + m_asymm_branch_limit = p.asymm_branch_limit(); if (m_asymm_branch_limit > INT_MAX) m_asymm_branch_limit = INT_MAX; } void asymm_branch::collect_param_descrs(param_descrs & d) { - d.insert("asymm_branch", CPK_BOOL, "(default: true) asymmetric branching."); - d.insert("asymm_branch_rounds", CPK_UINT, "(default: 32) maximum number of rounds of asymmetric branching."); - d.insert("asymm_branch_limit", CPK_UINT, "approx. maximum number of literals visited during asymmetric branching."); + sat_asymm_branch_params::collect_param_descrs(d); } void asymm_branch::collect_statistics(statistics & st) { diff --git a/src/sat/sat_asymm_branch_params.pyg b/src/sat/sat_asymm_branch_params.pyg new file mode 100644 index 000000000..8940c64a6 --- /dev/null +++ b/src/sat/sat_asymm_branch_params.pyg @@ -0,0 +1,6 @@ +def_module_params(module_name='sat', + class_name='sat_asymm_branch_params', + export=True, + params=(('asymm_branch', BOOL, True, 'asymmetric branching'), + ('asymm_branch.rounds', UINT, 32, 'maximum number of rounds of asymmetric branching'), + ('asymm_branch.limit', UINT, 100000000, 'approx. maximum number of literals visited during asymmetric branching'))) diff --git a/src/sat/sat_config.cpp b/src/sat/sat_config.cpp index e30569d89..cc0f97ff0 100644 --- a/src/sat/sat_config.cpp +++ b/src/sat/sat_config.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include"sat_config.h" #include"sat_types.h" +#include"sat_params.hpp" namespace sat { @@ -36,10 +37,11 @@ namespace sat { updt_params(p); } - void config::updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + void config::updt_params(params_ref const & _p) { + sat_params p(_p); + m_max_memory = megabytes_to_bytes(p.max_memory()); - symbol s = p.get_sym("restart", m_luby); + symbol s = p.restart(); if (s == m_luby) m_restart = RS_LUBY; else if (s == m_geometric) @@ -47,7 +49,7 @@ namespace sat { else throw sat_param_exception("invalid restart strategy"); - s = p.get_sym("phase", m_caching); + s = p.phase(); if (s == m_always_false) m_phase = PS_ALWAYS_FALSE; else if (s == m_always_true) @@ -59,29 +61,31 @@ namespace sat { else throw sat_param_exception("invalid phase selection strategy"); - m_phase_caching_on = p.get_uint("phase_caching_on", 400); - m_phase_caching_off = p.get_uint("phase_caching_off", 100); + m_phase_caching_on = p.phase_caching_on(); + m_phase_caching_off = p.phase_caching_off(); - m_restart_initial = p.get_uint("restart_initial", 100); - m_restart_factor = p.get_double("restart_factor", 1.5); + m_restart_initial = p.restart_initial(); + m_restart_factor = p.restart_factor(); - m_random_freq = p.get_double("random_freq", 0.01); + m_random_freq = p.random_freq(); - m_burst_search = p.get_uint("burst_search", 100); + m_burst_search = p.burst_search(); - m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); + m_max_conflicts = p.max_conflicts(); + + // These parameters are not exposed + m_simplify_mult1 = _p.get_uint("simplify_mult1", 300); + m_simplify_mult2 = _p.get_double("simplify_mult2", 1.5); + m_simplify_max = _p.get_uint("simplify_max", 500000); + // -------------------------------- - m_simplify_mult1 = p.get_uint("simplify_mult1", 300); - m_simplify_mult2 = p.get_double("simplify_mult2", 1.5); - m_simplify_max = p.get_uint("simplify_max", 500000); - - s = p.get_sym("gc_strategy", m_glue_psm); + s = p.gc(); if (s == m_dyn_psm) { m_gc_strategy = GC_DYN_PSM; - m_gc_initial = p.get_uint("gc_initial", 500); - m_gc_increment = p.get_uint("gc_increment", 100); - m_gc_small_lbd = p.get_uint("gc_small_lbd", 3); - m_gc_k = p.get_uint("gc_k", 7); + m_gc_initial = p.gc_initial(); + m_gc_increment = p.gc_increment(); + m_gc_small_lbd = p.gc_small_lbd(); + m_gc_k = p.gc_k(); if (m_gc_k > 255) m_gc_k = 255; } @@ -96,31 +100,15 @@ namespace sat { m_gc_strategy = GC_PSM_GLUE; else throw sat_param_exception("invalid gc strategy"); - m_gc_initial = p.get_uint("gc_initial", 20000); - m_gc_increment = p.get_uint("gc_increment", 500); + m_gc_initial = p.gc_initial(); + m_gc_increment = p.gc_increment(); } - m_minimize_lemmas = p.get_bool("minimize_lemmas", true); - m_dyn_sub_res = p.get_bool("dyn_sub_res", true); + m_minimize_lemmas = p.minimize_lemmas(); + m_dyn_sub_res = p.dyn_sub_res(); } void config::collect_param_descrs(param_descrs & r) { - insert_max_memory(r); - r.insert("phase", CPK_SYMBOL, "(default: caching) phase selection strategy: always_false, always_true, caching, random."); - r.insert("phase_caching_on", CPK_UINT, "(default: 400)"); - r.insert("phase_caching_off", CPK_UINT, "(default: 100)"); - r.insert("restart", CPK_SYMBOL, "(default: luby) restart strategy: luby or geometric."); - r.insert("restart_initial", CPK_UINT, "(default: 100) initial restart (number of conflicts)."); - r.insert("restart_factor", CPK_DOUBLE, "(default: 1.5) restart increment factor for geometric strategy."); - r.insert("random_freq", CPK_DOUBLE, "(default: 0.01) frequency of random case splits."); - r.insert("burst_search", CPK_UINT, "(default: 100) number of conflicts before first global simplification."); - r.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - r.insert("gc_strategy", CPK_SYMBOL, "(default: glue_psm) garbage collection strategy: psm, glue, glue_psm, dyn_psm."); - r.insert("gc_initial", CPK_UINT, "(default: 20000) learned clauses garbage collection frequence."); - r.insert("gc_increment", CPK_UINT, "(default: 500) increment to the garbage collection threshold."); - r.insert("gc_small_lbd", CPK_UINT, "(default: 3) learned clauses with small LBD are never deleted (only used in dyn_psm)."); - r.insert("gc_k", CPK_UINT, "(default: 7) learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn_psm)."); - r.insert("minimize_lemmas", CPK_BOOL, "(default: true) minimize learned clauses."); - r.insert("dyn_sub_res", CPK_BOOL, "(default: true) dynamic subsumption resolution for minimizing learned clauses."); + sat_params::collect_param_descrs(r); } }; diff --git a/src/sat/sat_params.pyg b/src/sat/sat_params.pyg new file mode 100644 index 000000000..71579b86a --- /dev/null +++ b/src/sat/sat_params.pyg @@ -0,0 +1,20 @@ +def_module_params('sat', + export=True, + description='propositional SAT solver', + params=(max_memory_param(), + ('phase', SYMBOL, 'caching', 'phase selection strategy: always_false, always_true, caching, random'), + ('phase.caching.on', UINT, 400, 'phase caching on period (in number of conflicts)'), + ('phase.caching.off', UINT, 100, 'phase caching off period (in number of conflicts)'), + ('restart', SYMBOL, 'luby', 'restart strategy: luby or geometric'), + ('restart.initial', UINT, 100, 'initial restart (number of conflicts)'), + ('restart.factor', DOUBLE, 1.5, 'restart increment factor for geometric strategy'), + ('random_freq', DOUBLE, 0.01, 'frequency of random case splits'), + ('burst_search', UINT, 100, 'number of conflicts before first global simplification'), + ('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts'), + ('gc', SYMBOL, 'glue_psm', 'garbage collection strategy: psm, glue, glue_psm, dyn_psm'), + ('gc.initial', UINT, 20000, 'learned clauses garbage collection frequence'), + ('gc.increment', UINT, 500, 'increment to the garbage collection threshold'), + ('gc.small_lbd', UINT, 3, 'learned clauses with small LBD are never deleted (only used in dyn_psm)'), + ('gc.k', UINT, 7, 'learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn_psm)'), + ('minimize_lemmas', BOOL, True, 'minimize learned clauses'), + ('dyn_sub_res', BOOL, True, 'dynamic subsumption resolution for minimizing learned clauses'))) diff --git a/src/sat/sat_scc.cpp b/src/sat/sat_scc.cpp index f2598119f..29f3f006f 100644 --- a/src/sat/sat_scc.cpp +++ b/src/sat/sat_scc.cpp @@ -21,6 +21,7 @@ Revision History: #include"sat_elim_eqs.h" #include"stopwatch.h" #include"trace.h" +#include"sat_scc_params.hpp" namespace sat { @@ -230,12 +231,13 @@ namespace sat { m_num_elim = 0; } - void scc::updt_params(params_ref const & p) { - m_scc = p.get_bool("scc", true); + void scc::updt_params(params_ref const & _p) { + sat_scc_params p(_p); + m_scc = p.scc(); } void scc::collect_param_descrs(param_descrs & d) { - d.insert("scc", CPK_BOOL, "(default: true) eliminate Boolean variables by computing strongly connected components."); + sat_scc_params::collect_param_descrs(d); } }; diff --git a/src/sat/sat_scc_params.pyg b/src/sat/sat_scc_params.pyg new file mode 100644 index 000000000..b88de4de8 --- /dev/null +++ b/src/sat/sat_scc_params.pyg @@ -0,0 +1,5 @@ +def_module_params(module_name='sat', + class_name='sat_scc_params', + export=True, + params=(('scc', BOOL, True, 'eliminate Boolean variables by computing strongly connected components'),)) + diff --git a/src/sat/sat_simplifier.cpp b/src/sat/sat_simplifier.cpp index 8a1713647..623c73758 100644 --- a/src/sat/sat_simplifier.cpp +++ b/src/sat/sat_simplifier.cpp @@ -19,6 +19,7 @@ Revision History: --*/ #include"sat_simplifier.h" +#include"sat_simplifier_params.hpp" #include"sat_solver.h" #include"stopwatch.h" #include"trace.h" @@ -1430,45 +1431,28 @@ namespace sat { m_new_cls.finalize(); } - void simplifier::updt_params(params_ref const & p) { - m_elim_blocked_clauses = p.get_bool("elim_blocked_clauses", false); - m_elim_blocked_clauses_at = p.get_uint("elim_blocked_clauses_at", 2); - m_blocked_clause_limit = p.get_uint("blocked_clause_limit", 100000000); - m_resolution = p.get_bool("resolution", true); - m_res_limit = p.get_uint("resolution_limit", 500000000); - m_res_occ_cutoff = p.get_uint("res_occ_cutoff", 10); - m_res_occ_cutoff1 = p.get_uint("res_occ_cutoff_range1", 8); - m_res_occ_cutoff2 = p.get_uint("res_occ_cutoff_range2", 5); - m_res_occ_cutoff3 = p.get_uint("res_occ_cutoff_range3", 3); - m_res_lit_cutoff1 = p.get_uint("res_lit_cutoff_range1", 700); - m_res_lit_cutoff2 = p.get_uint("res_lit_cutoff_range2", 400); - m_res_lit_cutoff3 = p.get_uint("res_lit_cutoff_range3", 300); - m_res_cls_cutoff1 = p.get_uint("res_cls_cutoff1", 100000); - m_res_cls_cutoff2 = p.get_uint("res_cls_cutoff2", 700000); - m_subsumption = p.get_bool("subsumption", true); - m_subsumption_limit = p.get_uint("subsumption_limit", 100000000); + void simplifier::updt_params(params_ref const & _p) { + sat_simplifier_params p(_p); + m_elim_blocked_clauses = p.elim_blocked_clauses(); + m_elim_blocked_clauses_at = p.elim_blocked_clauses_at(); + m_blocked_clause_limit = p.blocked_clause_limit(); + m_resolution = p.resolution(); + m_res_limit = p.resolution_limit(); + m_res_occ_cutoff = p.resolution_occ_cutoff(); + m_res_occ_cutoff1 = p.resolution_occ_cutoff_range1(); + m_res_occ_cutoff2 = p.resolution_occ_cutoff_range2(); + m_res_occ_cutoff3 = p.resolution_occ_cutoff_range3(); + m_res_lit_cutoff1 = p.resolution_lit_cutoff_range1(); + m_res_lit_cutoff2 = p.resolution_lit_cutoff_range2(); + m_res_lit_cutoff3 = p.resolution_lit_cutoff_range3(); + m_res_cls_cutoff1 = p.resolution_cls_cutoff1(); + m_res_cls_cutoff2 = p.resolution_cls_cutoff2(); + m_subsumption = p.subsumption(); + m_subsumption_limit = p.subsumption_limit(); } void simplifier::collect_param_descrs(param_descrs & r) { - r.insert("elim_blocked_clauses", CPK_BOOL, "(default: false) eliminate blocked clauses."); - r.insert("elim_blocked_clauses_at", CPK_UINT, "(default: 2) eliminate blocked clauses only once at the given simplification round."); - r.insert("blocked_clause_limit", CPK_UINT, "(default: 100000000) maximum number of literals visited during blocked clause elimination."); - r.insert("resolution", CPK_BOOL, "(default: true) eliminate boolean variables using resolution."); - r.insert("resolution_limit", CPK_UINT, "(default: 500000000) approx. maximum number of literals visited during variable elimination."); - r.insert("res_occ_cutoff", CPK_UINT, "(default: 10) first cutoff (on number of positive/negative occurrences) for Boolean variable elimination."); - r.insert("res_occ_cutoff_range1", CPK_UINT, "(default: 8) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); - r.insert("res_occ_cutoff_range2", CPK_UINT, "(default: 5) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); - r.insert("res_occ_cutoff_range3", CPK_UINT, "(default: 3) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - - r.insert("res_lit_cutoff_range1", CPK_UINT, "(default: 700) second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); - r.insert("res_lit_cutoff_range2", CPK_UINT, "(default: 400) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); - r.insert("res_lit_cutoff_range3", CPK_UINT, "(default: 300) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - - r.insert("res_cls_cutoff1", CPK_UINT, "(default: 100000000) limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - r.insert("res_cls_cutoff2", CPK_UINT, "(default: 700000000) limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - - r.insert("subsumption", CPK_BOOL, "(default: true) eliminate subsumed clauses."); - r.insert("subsumption_limit", CPK_UINT, "(default: 100000000) approx. maximum number of literals visited during subsumption (and subsumption resolution)."); + sat_simplifier_params::collect_param_descrs(r); } void simplifier::collect_statistics(statistics & st) { diff --git a/src/sat/sat_simplifier_params.pyg b/src/sat/sat_simplifier_params.pyg new file mode 100644 index 000000000..6165e7e62 --- /dev/null +++ b/src/sat/sat_simplifier_params.pyg @@ -0,0 +1,19 @@ +def_module_params(module_name='sat', + class_name='sat_simplifier_params', + export=True, + params=(('elim_blocked_clauses', BOOL, False, 'eliminate blocked clauses'), + ('elim_blocked_clauses_at', UINT, 2, 'eliminate blocked clauses only once at the given simplification round'), + ('blocked_clause_limit', UINT, 100000000, 'maximum number of literals visited during blocked clause elimination'), + ('resolution', BOOL, True, 'eliminate boolean variables using resolution'), + ('resolution.limit', UINT, 500000000, 'approx. maximum number of literals visited during variable elimination'), + ('resolution.occ_cutoff', UINT, 10, 'first cutoff (on number of positive/negative occurrences) for Boolean variable elimination'), + ('resolution.occ_cutoff_range1', UINT, 8, 'second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses'), + ('resolution.occ_cutoff_range2', UINT, 5, 'second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2'), + ('resolution.occ_cutoff_range3', UINT, 3, 'second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff2'), + ('resolution.lit_cutoff_range1', UINT, 700, 'second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses'), + ('resolution.lit_cutoff_range2', UINT, 400, 'second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2'), + ('resolution.lit_cutoff_range3', UINT, 300, 'second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff2'), + ('resolution.cls_cutoff1', UINT, 100000000, 'limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination'), + ('resolution.cls_cutoff2', UINT, 700000000, 'limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination'), + ('subsumption', BOOL, True, 'eliminate subsumed clauses'), + ('subsumption.limit', UINT, 100000000, 'approx. maximum number of literals visited during subsumption (and subsumption resolution)'))) From 91096b638aa347e7507a57c27376babd6330ab81 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 17:18:25 -0800 Subject: [PATCH 092/133] better help Signed-off-by: Leonardo de Moura --- src/shell/main.cpp | 39 +++++++++++---- src/util/gparams.cpp | 113 ++++++++++++++++++++++++++++++++++--------- src/util/gparams.h | 7 ++- src/util/params.cpp | 10 ++-- src/util/params.h | 2 +- 5 files changed, 133 insertions(+), 38 deletions(-) diff --git a/src/shell/main.cpp b/src/shell/main.cpp index fb205c872..6dd4aa2e8 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -77,8 +77,11 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "ps display Z3 global (and module) parameters.\n"; - std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; + std::cout << " " << OPT << "p display Z3 global (and module) parameters.\n"; + std::cout << " " << OPT << "pd display Z3 global (and module) parameter descriptions.\n"; + std::cout << " " << OPT << "pm:name display Z3 module ('name') parameters.\n"; + std::cout << " " << OPT << "pp:name display Z3 parameter description.\n"; + std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. std::cout << " " << OPT << "T:timeout set the timeout (in seconds).\n"; @@ -166,7 +169,7 @@ void parse_cmd_line_args(int argc, char ** argv) { } else if (strcmp(opt_name, "v") == 0) { if (!opt_arg) - error("option argument (/v:level) is missing."); + error("option argument (-v:level) is missing."); long lvl = strtol(opt_arg, 0, 10); set_verbosity_level(lvl); } @@ -175,39 +178,55 @@ void parse_cmd_line_args(int argc, char ** argv) { } else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) - error("option argument (/T:timeout) is missing."); + error("option argument (-T:timeout) is missing."); long tm = strtol(opt_arg, 0, 10); set_timeout(tm * 1000); } else if (strcmp(opt_name, "t") == 0) { if (!opt_arg) - error("option argument (/t:timeout) is missing."); + error("option argument (-t:timeout) is missing."); gparams::set("timeout", opt_arg); } else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); } - else if (strcmp(opt_name, "ps") == 0) { - gparams::display(std::cout); + else if (strcmp(opt_name, "p") == 0) { + gparams::display(std::cout, 0, false, false); + exit(0); + } + else if (strcmp(opt_name, "pd") == 0) { + gparams::display(std::cout, 0, false, true); + exit(0); + } + else if (strcmp(opt_name, "pm") == 0) { + if (!opt_arg) + error("option argument (-pm:name) is missing."); + gparams::display_module(std::cout, opt_arg); + exit(0); + } + else if (strcmp(opt_name, "pp") == 0) { + if (!opt_arg) + error("option argument (-pp:name) is missing."); + gparams::display_parameter(std::cout, opt_arg); exit(0); } #ifdef _TRACE else if (strcmp(opt_name, "tr") == 0) { if (!opt_arg) - error("option argument (/tr:tag) is missing."); + error("option argument (-tr:tag) is missing."); enable_trace(opt_arg); } #endif #ifdef Z3DEBUG else if (strcmp(opt_name, "dbg") == 0) { if (!opt_arg) - error("option argument (/dbg:tag) is missing."); + error("option argument (-dbg:tag) is missing."); enable_debug(opt_arg); } #endif else if (strcmp(opt_name, "memory") == 0) { if (!opt_arg) - error("option argument (/memory:val) is missing."); + error("option argument (-memory:val) is missing."); gparams::set("memory_max_size", opt_arg); } else { diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 8a5532ee0..314049727 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -91,26 +91,6 @@ public: } } - void display(std::ostream & out, unsigned indent, bool smt2_style) { - #pragma omp critical (gparams) - { - out << "Global parameters\n"; - m_param_descrs.display(out, indent + 4, smt2_style); - out << "\n"; - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); - for (; it != end; ++it) { - out << "[module] " << it->m_key; - char const * descr = 0; - if (m_module_descrs.find(it->m_key, descr)) { - out << ", description: " << descr; - } - out << "\n"; - it->m_value->display(out, indent + 4, smt2_style); - } - } - } - void normalize(char const * name, /* out */ symbol & mod_name, /* out */ symbol & param_name) { if (*name == ':') name++; @@ -315,6 +295,80 @@ public: return result; } + void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) { + #pragma omp critical (gparams) + { + out << "Global parameters\n"; + m_param_descrs.display(out, indent + 4, smt2_style, include_descr); + out << "\n"; + if (!smt2_style) { + out << "To set a module parameter, use .=value\n"; + out << "Example: pp.decimal=true\n"; + out << "\n"; + } + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key; + char const * descr = 0; + if (m_module_descrs.find(it->m_key, descr)) { + out << ", description: " << descr; + } + out << "\n"; + it->m_value->display(out, indent + 4, smt2_style, include_descr); + } + } + } + + void display_modules(std::ostream & out) { + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key; + char const * descr = 0; + if (m_module_descrs.find(it->m_key, descr)) { + out << ", description: " << descr; + } + out << "\n"; + } + } + + void display_module(std::ostream & out, symbol const & module_name) { + param_descrs * d = 0; + if (!m_module_param_descrs.find(module_name, d)) + throw exception("unknown module '%s'", module_name.bare_str()); + out << "[module] " << module_name; + char const * descr = 0; + if (m_module_descrs.find(module_name, descr)) { + out << ", description: " << descr; + } + out << "\n"; + d->display(out, 4, false); + } + + void display_parameter(std::ostream & out, char const * name) { + symbol m, p; + normalize(name, m, p); + std::cout << name << " " << m << " " << p << "\n"; + param_descrs * d; + if (m == symbol::null) { + d = &m_param_descrs; + } + else { + if (!m_module_param_descrs.find(m, d)) + throw exception("unknown module '%s'", m.bare_str()); + } + if (!d->contains(p)) + throw_unknown_parameter(p, m); + out << " name: " << p << "\n"; + if (m != symbol::null) { + out << " module: " << m << "\n"; + out << " qualified name: " << m << "." << p << "\n"; + } + out << " type: " << d->get_kind(p) << "\n"; + out << " description: " << d->get_descr(p) << "\n"; + out << " default value: " << d->get_default(p) << "\n"; + } }; gparams::imp * gparams::g_imp = 0; @@ -370,9 +424,24 @@ params_ref gparams::get() { return g_imp->get(); } -void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) { +void gparams::display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) { SASSERT(g_imp != 0); - g_imp->display(out, indent, smt2_style); + g_imp->display(out, indent, smt2_style, include_descr); +} + +void gparams::display_modules(std::ostream & out) { + SASSERT(g_imp != 0); + g_imp->display_modules(out); +} + +void gparams::display_module(std::ostream & out, char const * module_name) { + SASSERT(g_imp != 0); + g_imp->display_module(out, symbol(module_name)); +} + +void gparams::display_parameter(std::ostream & out, char const * name) { + SASSERT(g_imp != 0); + g_imp->display_parameter(out, name); } void gparams::init() { diff --git a/src/util/gparams.h b/src/util/gparams.h index 2a784a239..a41044c84 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -106,8 +106,13 @@ public: /** \brief Dump information about available parameters in the given output stream. */ - static void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false); + static void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false, bool include_descr=true); + // Auxiliary APIs for better command line support + static void display_modules(std::ostream & out); + static void display_module(std::ostream & out, char const * module_name); + static void display_parameter(std::ostream & out, char const * name); + /** \brief Initialize the global parameter management module. diff --git a/src/util/params.cpp b/src/util/params.cpp index 4f2a73e99..c0b8653ae 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -95,7 +95,7 @@ struct param_descrs::imp { bool operator()(symbol const & s1, symbol const & s2) const { return strcmp(s1.bare_str(), s2.bare_str()) < 0; } }; - void display(std::ostream & out, unsigned indent, bool smt2_style) const { + void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) const { svector names; dictionary::iterator it = m_info.begin(); dictionary::iterator end = m_info.end(); @@ -124,7 +124,9 @@ struct param_descrs::imp { info d; m_info.find(*it2, d); SASSERT(d.m_descr); - out << " (" << d.m_kind << ") " << d.m_descr; + out << " (" << d.m_kind << ")"; + if (include_descr) + out << " " << d.m_descr; if (d.m_default != 0) out << " (default: " << d.m_default << ")"; out << "\n"; @@ -209,8 +211,8 @@ symbol param_descrs::get_param_name(unsigned i) const { return m_imp->get_param_name(i); } -void param_descrs::display(std::ostream & out, unsigned indent, bool smt2_style) const { - return m_imp->display(out, indent, smt2_style); +void param_descrs::display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) const { + return m_imp->display(out, indent, smt2_style, include_descr); } void insert_max_memory(param_descrs & r) { diff --git a/src/util/params.h b/src/util/params.h index 68f4c967b..164de9ab3 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -119,7 +119,7 @@ public: char const * get_descr(symbol const & name) const; char const * get_default(char const * name) const; char const * get_default(symbol const & name) const; - void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false) const; + void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false, bool include_descr=true) const; unsigned size() const; symbol get_param_name(unsigned idx) const; }; From a99b8fe797d8a26d358f6013a1a06c444b2ca5ad Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 22:03:30 -0800 Subject: [PATCH 093/133] exposed rewriter parameters Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 6 +- src/ast/rewriter/arith_rewriter.cpp | 41 ++--- src/ast/rewriter/arith_rewriter_params.pyg | 15 ++ src/ast/rewriter/array_rewriter.cpp | 11 +- src/ast/rewriter/array_rewriter_params.pyg | 5 + src/ast/rewriter/bool_rewriter.cpp | 24 ++- src/ast/rewriter/bool_rewriter_params.pyg | 9 + src/ast/rewriter/bv_rewriter.cpp | 28 ++- src/ast/rewriter/bv_rewriter_params.pyg | 10 ++ src/ast/rewriter/poly_rewriter_def.h | 19 +- src/ast/rewriter/poly_rewriter_params.pyg | 8 + src/ast/rewriter/rewriter_params.pyg | 11 ++ src/ast/rewriter/th_rewriter.cpp | 25 ++- src/ast/rewriter/th_rewriter.h | 3 - src/shell/main.cpp | 14 +- src/util/gparams.cpp | 198 ++++++++++++++------- 16 files changed, 265 insertions(+), 162 deletions(-) create mode 100644 src/ast/rewriter/arith_rewriter_params.pyg create mode 100644 src/ast/rewriter/array_rewriter_params.pyg create mode 100644 src/ast/rewriter/bool_rewriter_params.pyg create mode 100644 src/ast/rewriter/bv_rewriter_params.pyg create mode 100644 src/ast/rewriter/poly_rewriter_params.pyg create mode 100644 src/ast/rewriter/rewriter_params.pyg diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 2906b11fe..98fae665a 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1507,11 +1507,15 @@ def def_module_params(module_name, export, params, class_name=None, description= print "Generated '%s'" % hpp def max_memory_param(): - return ('max_memory', UINT, UINT_MAX, 'maximum amount of memory in megabytes.') + return ('max_memory', UINT, UINT_MAX, 'maximum amount of memory in megabytes') + +def max_steps_param(): + return ('max_steps', UINT, UINT_MAX, 'maximum number of steps') PYG_GLOBALS = { 'UINT' : UINT, 'BOOL' : BOOL, 'DOUBLE' : DOUBLE, 'STRING' : STRING, 'SYMBOL' : SYMBOL, 'UINT_MAX' : UINT_MAX, 'max_memory_param' : max_memory_param, + 'max_steps_param' : max_steps_param, 'def_module_params' : def_module_params } # Execute python auxiliary scripts that generate extra code for Z3. diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index f5fdcf8af..a5dfda6e7 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -17,23 +17,25 @@ Notes: --*/ #include"arith_rewriter.h" +#include"arith_rewriter_params.hpp" #include"poly_rewriter_def.h" #include"algebraic_numbers.h" #include"ast_pp.h" -void arith_rewriter::updt_local_params(params_ref const & p) { - m_arith_lhs = p.get_bool("arith_lhs", false); - m_gcd_rounding = p.get_bool("gcd_rounding", false); - m_eq2ineq = p.get_bool("eq2ineq", false); - m_elim_to_real = p.get_bool("elim_to_real", false); - m_push_to_real = p.get_bool("push_to_real", true); - m_anum_simp = p.get_bool("algebraic_number_evaluator", true); - m_max_degree = p.get_uint("max_degree", 64); - m_expand_power = p.get_bool("expand_power", false); - m_mul2power = p.get_bool("mul_to_power", false); - m_elim_rem = p.get_bool("elim_rem", false); - m_expand_tan = p.get_bool("expand_tan", false); - set_sort_sums(p.get_bool("sort_sums", false)); // set here to avoid collision with bvadd +void arith_rewriter::updt_local_params(params_ref const & _p) { + arith_rewriter_params p(_p); + m_arith_lhs = p.arith_lhs(); + m_gcd_rounding = p.gcd_rounding(); + m_eq2ineq = p.eq2ineq(); + m_elim_to_real = p.elim_to_real(); + m_push_to_real = p.push_to_real(); + m_anum_simp = p.algebraic_number_evaluator(); + m_max_degree = p.max_degree(); + m_expand_power = p.expand_power(); + m_mul2power = p.mul_to_power(); + m_elim_rem = p.elim_rem(); + m_expand_tan = p.expand_tan(); + set_sort_sums(p.sort_sums()); } void arith_rewriter::updt_params(params_ref const & p) { @@ -43,18 +45,7 @@ void arith_rewriter::updt_params(params_ref const & p) { void arith_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert("algebraic_number_evaluator", CPK_BOOL, "(default: true) simplify/evaluate expressions containing (algebraic) irrational numbers."); - r.insert("mul_to_power", CPK_BOOL, "(default: false) collpase (* t ... t) into (^ t k), it is ignored if expand_power is true."); - r.insert("expand_power", CPK_BOOL, "(default: false) expand (^ t k) into (* t ... t) if 1 < k <= max_degree."); - r.insert("expand_tan", CPK_BOOL, "(default: false) replace (tan x) with (/ (sin x) (cos x))."); - r.insert("max_degree", CPK_UINT, "(default: 64) max degree of algebraic numbers (and power operators) processed by simplifier."); - r.insert("eq2ineq", CPK_BOOL, "(default: false) split arithmetic equalities into two inequalities."); - r.insert("sort_sums", CPK_BOOL, "(default: false) sort the arguments of + application."); - r.insert("gcd_rounding", CPK_BOOL, "(default: false) use gcd rounding on integer arithmetic atoms."); - r.insert("arith_lhs", CPK_BOOL, "(default: false) all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."); - r.insert("elim_to_real", CPK_BOOL, "(default: false) eliminate to_real from arithmetic predicates that contain only integers."); - r.insert("push_to_real", CPK_BOOL, "(default: true) distribute to_real over * and +."); - r.insert("elim_rem", CPK_BOOL, "(default: false) replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."); + arith_rewriter_params::collect_param_descrs(r); } br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/arith_rewriter_params.pyg b/src/ast/rewriter/arith_rewriter_params.pyg new file mode 100644 index 000000000..8a41d838d --- /dev/null +++ b/src/ast/rewriter/arith_rewriter_params.pyg @@ -0,0 +1,15 @@ +def_module_params(module_name='rewriter', + class_name='arith_rewriter_params', + export=True, + params=(("algebraic_number_evaluator", BOOL, True, "simplify/evaluate expressions containing (algebraic) irrational numbers."), + ("mul_to_power", BOOL, False, "collpase (* t ... t) into (^ t k), it is ignored if expand_power is true."), + ("expand_power", BOOL, False, "expand (^ t k) into (* t ... t) if 1 < k <= max_degree."), + ("expand_tan", BOOL, False, "replace (tan x) with (/ (sin x) (cos x))."), + ("max_degree", UINT, 64, "max degree of algebraic numbers (and power operators) processed by simplifier."), + ("eq2ineq", BOOL, False, "split arithmetic equalities into two inequalities."), + ("sort_sums", BOOL, False, "sort the arguments of + application."), + ("gcd_rounding", BOOL, False, "use gcd rounding on integer arithmetic atoms."), + ("arith_lhs", BOOL, False, "all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."), + ("elim_to_real", BOOL, False, "eliminate to_real from arithmetic predicates that contain only integers."), + ("push_to_real", BOOL, True, "distribute to_real over * and +."), + ("elim_rem", BOOL, False, "replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."))) diff --git a/src/ast/rewriter/array_rewriter.cpp b/src/ast/rewriter/array_rewriter.cpp index ac93e0f87..9dbbeb231 100644 --- a/src/ast/rewriter/array_rewriter.cpp +++ b/src/ast/rewriter/array_rewriter.cpp @@ -17,17 +17,18 @@ Notes: --*/ #include"array_rewriter.h" +#include"array_rewriter_params.hpp" #include"ast_lt.h" #include"ast_pp.h" -void array_rewriter::updt_params(params_ref const & p) { - m_sort_store = p.get_bool("sort_store", false); - m_expand_select_store = p.get_bool("expand_select_store", false); +void array_rewriter::updt_params(params_ref const & _p) { + array_rewriter_params p(_p); + m_sort_store = p.sort_store(); + m_expand_select_store = p.expand_select_store(); } void array_rewriter::get_param_descrs(param_descrs & r) { - r.insert("expand_select_store", CPK_BOOL, "(default: false) replace a (select (store ...) ...) term by an if-then-else term."); - r.insert("sort_store", CPK_BOOL, "(default: false) sort nested stores when the indices are known to be different."); + array_rewriter_params::collect_param_descrs(r); } br_status array_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/array_rewriter_params.pyg b/src/ast/rewriter/array_rewriter_params.pyg new file mode 100644 index 000000000..2e3ae9f6a --- /dev/null +++ b/src/ast/rewriter/array_rewriter_params.pyg @@ -0,0 +1,5 @@ +def_module_params(module_name='rewriter', + class_name='array_rewriter_params', + export=True, + params=(("expand_select_store", BOOL, False, "replace a (select (store ...) ...) term by an if-then-else term"), + ("sort_store", BOOL, False, "sort nested stores when the indices are known to be different"))) diff --git a/src/ast/rewriter/bool_rewriter.cpp b/src/ast/rewriter/bool_rewriter.cpp index b3f422fe5..4fcaf02fe 100644 --- a/src/ast/rewriter/bool_rewriter.cpp +++ b/src/ast/rewriter/bool_rewriter.cpp @@ -17,25 +17,21 @@ Notes: --*/ #include"bool_rewriter.h" +#include"bool_rewriter_params.hpp" #include"rewriter_def.h" -void bool_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool("flat", true); - m_elim_and = p.get_bool("elim_and", false); - m_local_ctx = p.get_bool("local_ctx", false); - m_local_ctx_limit = p.get_uint("local_ctx_limit", UINT_MAX); - m_blast_distinct = p.get_bool("blast_distinct", false); - m_ite_extra_rules = p.get_bool("ite_extra_rules", false); +void bool_rewriter::updt_params(params_ref const & _p) { + bool_rewriter_params p(_p); + m_flat = p.flat(); + m_elim_and = p.elim_and(); + m_local_ctx = p.local_ctx(); + m_local_ctx_limit = p.local_ctx_limit(); + m_blast_distinct = p.blast_distinct(); + m_ite_extra_rules = p.ite_extra_rules(); } void bool_rewriter::get_param_descrs(param_descrs & r) { - r.insert("ite_extra_rules", CPK_BOOL, - "(default: false) extra ite simplifications, these additional simplifications may reduce size locally but increase globally."); - r.insert("flat", CPK_BOOL, "(default: true) create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor."); - r.insert("elim_and", CPK_BOOL, "(default: false) conjunctions are rewritten using negation and disjunctions."); - r.insert("local_ctx", CPK_BOOL, "(default: false) perform local (i.e., cheap) context simplifications."); - r.insert("local_ctx_limit", CPK_UINT, "(default: inf) limit for applying local context simplifier."); - r.insert("blast_distinct", CPK_BOOL, "(default: false) expand a distinct predicate into a quadratic number of disequalities."); + bool_rewriter_params::collect_param_descrs(r); } br_status bool_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/bool_rewriter_params.pyg b/src/ast/rewriter/bool_rewriter_params.pyg new file mode 100644 index 000000000..a5bcf6f5d --- /dev/null +++ b/src/ast/rewriter/bool_rewriter_params.pyg @@ -0,0 +1,9 @@ +def_module_params(module_name='rewriter', + class_name='bool_rewriter_params', + export=True, + params=(("ite_extra_rules", BOOL, False, "extra ite simplifications, these additional simplifications may reduce size locally but increase globally"), + ("flat", BOOL, True, "create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor"), + ("elim_and", BOOL, False, "conjunctions are rewritten using negation and disjunctions"), + ("local_ctx", BOOL, False, "perform local (i.e., cheap) context simplifications"), + ("local_ctx_limit", UINT, UINT_MAX, "limit for applying local context simplifier"), + ("blast_distinct", BOOL, False, "expand a distinct predicate into a quadratic number of disequalities"))) diff --git a/src/ast/rewriter/bv_rewriter.cpp b/src/ast/rewriter/bv_rewriter.cpp index fbc1f7c11..5fd562676 100644 --- a/src/ast/rewriter/bv_rewriter.cpp +++ b/src/ast/rewriter/bv_rewriter.cpp @@ -17,6 +17,7 @@ Notes: --*/ #include"bv_rewriter.h" +#include"bv_rewriter_params.hpp" #include"poly_rewriter_def.h" #include"ast_smt2_pp.h" @@ -53,15 +54,16 @@ app * mk_extract_proc::operator()(unsigned high, unsigned low, expr * arg) { return r; } -void bv_rewriter::updt_local_params(params_ref const & p) { - m_hi_div0 = p.get_bool("hi_div0", true); - m_elim_sign_ext = p.get_bool("elim_sign_ext", true); - m_mul2concat = p.get_bool("mul2concat", false); - m_bit2bool = p.get_bool("bit2bool", true); - m_blast_eq_value = p.get_bool("blast_eq_value", false); - m_mkbv2num = p.get_bool("mkbv2num", false); - m_split_concat_eq = p.get_bool("split_concat_eq", false); - m_udiv2mul = p.get_bool("udiv2mul", false); +void bv_rewriter::updt_local_params(params_ref const & _p) { + bv_rewriter_params p(_p); + m_hi_div0 = p.hi_div0(); + m_elim_sign_ext = p.elim_sign_ext(); + m_mul2concat = p.mul2concat(); + m_bit2bool = p.bit2bool(); + m_blast_eq_value = p.blast_eq_value(); + m_split_concat_eq = p.split_concat_eq(); + m_udiv2mul = p.udiv2mul(); + m_mkbv2num = _p.get_bool("mkbv2num", false); } void bv_rewriter::updt_params(params_ref const & p) { @@ -71,13 +73,7 @@ void bv_rewriter::updt_params(params_ref const & p) { void bv_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert("udiv2mul", CPK_BOOL, "(default: false) convert constant udiv to mul."); - r.insert("split_concat_eq", CPK_BOOL, "(default: false) split equalities of the form (= (concat t1 t2) t3)."); - r.insert("bit2bool", CPK_BOOL, "(default: true) try to convert bit-vector terms of size 1 into Boolean terms."); - r.insert("blast_eq_value", CPK_BOOL, "(default: false) blast (some) Bit-vector equalities into bits."); - r.insert("elim_sign_ext", CPK_BOOL, "(default: true) expand sign-ext operator using concat and extract."); - r.insert("hi_div0", CPK_BOOL, "(default: true) use the 'hardware interpretation' for division by zero (for bit-vector terms)."); - r.insert("mul2concat", CPK_BOOL, "(default: false) replace multiplication by a power of two into a concatenation."); + bv_rewriter_params::collect_param_descrs(r); #ifndef _EXTERNAL_RELEASE r.insert("mkbv2num", CPK_BOOL, "(default: false) convert (mkbv [true/false]*) into a numeral"); #endif diff --git a/src/ast/rewriter/bv_rewriter_params.pyg b/src/ast/rewriter/bv_rewriter_params.pyg new file mode 100644 index 000000000..780d8e724 --- /dev/null +++ b/src/ast/rewriter/bv_rewriter_params.pyg @@ -0,0 +1,10 @@ +def_module_params(module_name='rewriter', + class_name='bv_rewriter_params', + export=True, + params=(("udiv2mul", BOOL, False, "convert constant udiv to mul"), + ("split_concat_eq", BOOL, False, "split equalities of the form (= (concat t1 t2) t3)"), + ("bit2bool", BOOL, True, "try to convert bit-vector terms of size 1 into Boolean terms"), + ("blast_eq_value", BOOL, False, "blast (some) Bit-vector equalities into bits"), + ("elim_sign_ext", BOOL, True, "expand sign-ext operator using concat and extract"), + ("hi_div0", BOOL, True, "use the 'hardware interpretation' for division by zero (for bit-vector terms)"), + ("mul2concat", BOOL, False, "replace multiplication by a power of two into a concatenation"))) diff --git a/src/ast/rewriter/poly_rewriter_def.h b/src/ast/rewriter/poly_rewriter_def.h index e6c8a653c..290144c75 100644 --- a/src/ast/rewriter/poly_rewriter_def.h +++ b/src/ast/rewriter/poly_rewriter_def.h @@ -17,6 +17,7 @@ Notes: --*/ #include"poly_rewriter.h" +#include"poly_rewriter_params.hpp" #include"ast_lt.h" #include"ast_ll_pp.h" #include"ast_smt2_pp.h" @@ -26,20 +27,18 @@ char const * poly_rewriter::g_ste_blowup_msg = "sum of monomials blowup" template -void poly_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool("flat", true); - m_som = p.get_bool("som", false); - m_hoist_mul = p.get_bool("hoist_mul", false); - m_hoist_cmul = p.get_bool("hoist_cmul", false); - m_som_blowup = p.get_uint("som_blowup", UINT_MAX); +void poly_rewriter::updt_params(params_ref const & _p) { + poly_rewriter_params p(_p); + m_flat = p.flat(); + m_som = p.som(); + m_hoist_mul = p.hoist_mul(); + m_hoist_cmul = p.hoist_cmul(); + m_som_blowup = p.som_blowup(); } template void poly_rewriter::get_param_descrs(param_descrs & r) { - r.insert("som", CPK_BOOL, "(default: false) put polynomials in som-of-monomials form."); - r.insert("som_blowup", CPK_UINT, "(default: infty) maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"); - r.insert("hoist_mul", CPK_BOOL, "(default: false) hoist multiplication over summation to minimize number of multiplications"); - r.insert("hoist_cmul", CPK_BOOL, "(default: false) hoist constant multiplication over summation to minimize number of multiplications"); + poly_rewriter_params::collect_param_descrs(r); } template diff --git a/src/ast/rewriter/poly_rewriter_params.pyg b/src/ast/rewriter/poly_rewriter_params.pyg new file mode 100644 index 000000000..18d1e1dba --- /dev/null +++ b/src/ast/rewriter/poly_rewriter_params.pyg @@ -0,0 +1,8 @@ +def_module_params(module_name='rewriter', + class_name='poly_rewriter_params', + export=True, + params=(("som", BOOL, False, "put polynomials in som-of-monomials form"), + ("som_blowup", UINT, UINT_MAX, "maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"), + ("hoist_mul", BOOL, False, "hoist multiplication over summation to minimize number of multiplications"), + ("hoist_cmul", BOOL, False, "hoist constant multiplication over summation to minimize number of multiplications"), + ("flat", BOOL, True, "create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor"))) diff --git a/src/ast/rewriter/rewriter_params.pyg b/src/ast/rewriter/rewriter_params.pyg new file mode 100644 index 000000000..3a8ed5d5e --- /dev/null +++ b/src/ast/rewriter/rewriter_params.pyg @@ -0,0 +1,11 @@ +def_module_params('rewriter', + description='new formula simplification module used in the tactic framework, and new solvers', + export=True, + params=(max_memory_param(), + max_steps_param(), + ("flat", BOOL, True, "create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor"), + ("push_ite_arith", BOOL, False, "push if-then-else over arithmetic terms."), + ("push_ite_bv", BOOL, False, "push if-then-else over bit-vector terms."), + ("pull_cheap_ite", BOOL, False, "pull if-then-else terms when cheap."), + ("cache_all", BOOL, False, "cache all intermediate results."))) + diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index da4dd3860..07ee7698d 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -17,6 +17,7 @@ Notes: --*/ #include"th_rewriter.h" +#include"rewriter_params.hpp" #include"bool_rewriter.h" #include"arith_rewriter.h" #include"bv_rewriter.h" @@ -56,14 +57,15 @@ struct th_rewriter_cfg : public default_rewriter_cfg { ast_manager & m() const { return m_b_rw.m(); } - void updt_local_params(params_ref const & p) { - m_flat = p.get_bool("flat", true); - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - m_max_steps = p.get_uint("max_steps", UINT_MAX); - m_pull_cheap_ite = p.get_bool("pull_cheap_ite", false); - m_cache_all = p.get_bool("cache_all", false); - m_push_ite_arith = p.get_bool("push_ite_arith", false); - m_push_ite_bv = p.get_bool("push_ite_bv", false); + void updt_local_params(params_ref const & _p) { + rewriter_params p(_p); + m_flat = p.flat(); + m_max_memory = megabytes_to_bytes(p.max_memory()); + m_max_steps = p.max_steps(); + m_pull_cheap_ite = p.pull_cheap_ite(); + m_cache_all = p.cache_all(); + m_push_ite_arith = p.push_ite_arith(); + m_push_ite_bv = p.push_ite_bv(); } void updt_params(params_ref const & p) { @@ -693,12 +695,7 @@ void th_rewriter::get_param_descrs(param_descrs & r) { arith_rewriter::get_param_descrs(r); bv_rewriter::get_param_descrs(r); array_rewriter::get_param_descrs(r); - insert_max_memory(r); - insert_max_steps(r); - r.insert("push_ite_arith", CPK_BOOL, "(default: false) push if-then-else over arithmetic terms."); - r.insert("push_ite_bv", CPK_BOOL, "(default: false) push if-then-else over bit-vector terms."); - r.insert("pull_cheap_ite", CPK_BOOL, "(default: false) pull if-then-else terms when cheap."); - r.insert("cache_all", CPK_BOOL, "(default: false) cache all intermediate results."); + rewriter_params::collect_param_descrs(r); } th_rewriter::~th_rewriter() { diff --git a/src/ast/rewriter/th_rewriter.h b/src/ast/rewriter/th_rewriter.h index 19a89d286..b25558dd9 100644 --- a/src/ast/rewriter/th_rewriter.h +++ b/src/ast/rewriter/th_rewriter.h @@ -37,9 +37,6 @@ public: void updt_params(params_ref const & p); static void get_param_descrs(param_descrs & r); - /* - REG_MODULE_PARAMS('simplify', 'th_rewriter::get_param_descrs') - */ unsigned get_cache_size() const; unsigned get_num_steps() const; diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 6dd4aa2e8..21ee8b71c 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -80,8 +80,8 @@ void display_usage() { std::cout << " " << OPT << "p display Z3 global (and module) parameters.\n"; std::cout << " " << OPT << "pd display Z3 global (and module) parameter descriptions.\n"; std::cout << " " << OPT << "pm:name display Z3 module ('name') parameters.\n"; - std::cout << " " << OPT << "pp:name display Z3 parameter description.\n"; - std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; + std::cout << " " << OPT << "pp:name display Z3 parameter description, if 'name' is not provided, then all module names are listed.\n"; + std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. std::cout << " " << OPT << "T:timeout set the timeout (in seconds).\n"; @@ -199,9 +199,13 @@ void parse_cmd_line_args(int argc, char ** argv) { exit(0); } else if (strcmp(opt_name, "pm") == 0) { - if (!opt_arg) - error("option argument (-pm:name) is missing."); - gparams::display_module(std::cout, opt_arg); + if (opt_arg) { + gparams::display_module(std::cout, opt_arg); + } + else { + gparams::display_modules(std::cout); + std::cout << "\nUse -pm:name to display all parameters available at module 'name'\n"; + } exit(0); } else if (strcmp(opt_name, "pp") == 0) { diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 314049727..4aecd0c05 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -36,13 +36,27 @@ bool is_old_param_name(symbol const & name) { } struct gparams::imp { + bool m_modules_registered; dictionary m_module_param_descrs; dictionary m_module_descrs; param_descrs m_param_descrs; dictionary m_module_params; params_ref m_params; + + void check_registered() { + if (m_modules_registered) + return; + m_modules_registered = true; + gparams_register_modules(); + } + + dictionary & get_module_param_descrs() { check_registered(); return m_module_param_descrs; } + dictionary & get_module_descrs() { check_registered(); return m_module_descrs; } + param_descrs & get_param_descrs() { check_registered(); return m_param_descrs; } + public: - imp() { + imp(): + m_modules_registered(false) { } ~imp() { @@ -62,35 +76,45 @@ public: } } + // ----------------------------------------------- + // + // Module registration routines. + // They are invoked when descriptions are initialized + // + // ----------------------------------------------- + void register_global(param_descrs & d) { - #pragma omp critical (gparams) - { - m_param_descrs.copy(d); - } + // Don't need synchronization here, this method + // is invoked from check_registered that is already protected. + m_param_descrs.copy(d); } void register_module(char const * module_name, param_descrs * d) { - #pragma omp critical (gparams) - { - symbol s(module_name); - param_descrs * old_d; - if (m_module_param_descrs.find(s, old_d)) { - old_d->copy(*d); - dealloc(d); - } - else { - m_module_param_descrs.insert(s, d); - } + // Don't need synchronization here, this method + // is invoked from check_registered that is already protected. + symbol s(module_name); + param_descrs * old_d; + if (m_module_param_descrs.find(s, old_d)) { + old_d->copy(*d); + dealloc(d); + } + else { + m_module_param_descrs.insert(s, d); } } void register_module_descr(char const * module_name, char const * descr) { - #pragma omp critical (gparams) - { - m_module_descrs.insert(symbol(module_name), descr); - } + // Don't need synchronization here, this method + // is invoked from check_registered that is already protected. + m_module_descrs.insert(symbol(module_name), descr); } + // ----------------------------------------------- + // + // Parameter setting & retrieval + // + // ----------------------------------------------- + void normalize(char const * name, /* out */ symbol & mod_name, /* out */ symbol & param_name) { if (*name == ':') name++; @@ -132,7 +156,7 @@ public: void throw_unknown_parameter(symbol const & param_name, symbol const & mod_name) { if (mod_name == symbol::null) { if (is_old_param_name(param_name)) { - throw exception("unknown parameter '%s', this is an old parameter name, invoke 'z3 -ps' to obtain the new parameter list", + throw exception("unknown parameter '%s', this is an old parameter name, invoke 'z3 -p' to obtain the new parameter list", param_name.bare_str()); } else { @@ -191,11 +215,11 @@ public: symbol m, p; normalize(name, m, p); if (m == symbol::null) { - set(m_param_descrs, p, value, m); + set(get_param_descrs(), p, value, m); } else { param_descrs * d; - if (m_module_param_descrs.find(m, d)) { + if (get_module_param_descrs().find(m, d)) { set(*d, p, value, m); } else { @@ -203,7 +227,7 @@ public: } } } - catch (exception & ex) { + catch (z3_exception & ex) { // Exception cannot cross critical section boundaries. error = true; error_msg = ex.msg(); @@ -243,7 +267,7 @@ public: r = get_value(m_params, p); } else { - r = get_default(m_param_descrs, p, m); + r = get_default(get_param_descrs(), p, m); } } else { @@ -253,7 +277,7 @@ public: } else { param_descrs * d; - if (m_module_param_descrs.find(m, d)) { + if (get_module_param_descrs().find(m, d)) { r = get_default(*d, p, m); } else { @@ -262,7 +286,7 @@ public: } } } - catch (exception & ex) { + catch (z3_exception & ex) { // Exception cannot cross critical section boundaries. error = true; error_msg = ex.msg(); @@ -295,23 +319,29 @@ public: return result; } + // ----------------------------------------------- + // + // Pretty printing + // + // ----------------------------------------------- + void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) { #pragma omp critical (gparams) { out << "Global parameters\n"; - m_param_descrs.display(out, indent + 4, smt2_style, include_descr); + get_param_descrs().display(out, indent + 4, smt2_style, include_descr); out << "\n"; if (!smt2_style) { out << "To set a module parameter, use .=value\n"; out << "Example: pp.decimal=true\n"; out << "\n"; } - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); + dictionary::iterator it = get_module_param_descrs().begin(); + dictionary::iterator end = get_module_param_descrs().end(); for (; it != end; ++it) { out << "[module] " << it->m_key; char const * descr = 0; - if (m_module_descrs.find(it->m_key, descr)) { + if (get_module_descrs().find(it->m_key, descr)) { out << ", description: " << descr; } out << "\n"; @@ -321,53 +351,84 @@ public: } void display_modules(std::ostream & out) { - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); - for (; it != end; ++it) { - out << "[module] " << it->m_key; - char const * descr = 0; - if (m_module_descrs.find(it->m_key, descr)) { - out << ", description: " << descr; + #pragma omp critical (gparams) + { + dictionary::iterator it = get_module_param_descrs().begin(); + dictionary::iterator end = get_module_param_descrs().end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key; + char const * descr = 0; + if (get_module_descrs().find(it->m_key, descr)) { + out << ", description: " << descr; + } + out << "\n"; } - out << "\n"; } } void display_module(std::ostream & out, symbol const & module_name) { - param_descrs * d = 0; - if (!m_module_param_descrs.find(module_name, d)) - throw exception("unknown module '%s'", module_name.bare_str()); - out << "[module] " << module_name; - char const * descr = 0; - if (m_module_descrs.find(module_name, descr)) { - out << ", description: " << descr; + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + param_descrs * d = 0; + if (!get_module_param_descrs().find(module_name, d)) + throw exception("unknown module '%s'", module_name.bare_str()); + out << "[module] " << module_name; + char const * descr = 0; + if (get_module_descrs().find(module_name, descr)) { + out << ", description: " << descr; + } + out << "\n"; + d->display(out, 4, false); + } + catch (z3_exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); + } } - out << "\n"; - d->display(out, 4, false); + if (error) + throw exception(error_msg); } void display_parameter(std::ostream & out, char const * name) { - symbol m, p; - normalize(name, m, p); - std::cout << name << " " << m << " " << p << "\n"; - param_descrs * d; - if (m == symbol::null) { - d = &m_param_descrs; + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + symbol m, p; + normalize(name, m, p); + std::cout << name << " " << m << " " << p << "\n"; + param_descrs * d; + if (m == symbol::null) { + d = &get_param_descrs(); + } + else { + if (!get_module_param_descrs().find(m, d)) + throw exception("unknown module '%s'", m.bare_str()); + } + if (!d->contains(p)) + throw_unknown_parameter(p, m); + out << " name: " << p << "\n"; + if (m != symbol::null) { + out << " module: " << m << "\n"; + out << " qualified name: " << m << "." << p << "\n"; + } + out << " type: " << d->get_kind(p) << "\n"; + out << " description: " << d->get_descr(p) << "\n"; + out << " default value: " << d->get_default(p) << "\n"; + } + catch (z3_exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); + } } - else { - if (!m_module_param_descrs.find(m, d)) - throw exception("unknown module '%s'", m.bare_str()); - } - if (!d->contains(p)) - throw_unknown_parameter(p, m); - out << " name: " << p << "\n"; - if (m != symbol::null) { - out << " module: " << m << "\n"; - out << " qualified name: " << m << "." << p << "\n"; - } - out << " type: " << d->get_kind(p) << "\n"; - out << " description: " << d->get_descr(p) << "\n"; - out << " default value: " << d->get_default(p) << "\n"; + if (error) + throw exception(error_msg); } }; @@ -447,7 +508,6 @@ void gparams::display_parameter(std::ostream & out, char const * name) { void gparams::init() { TRACE("gparams", tout << "gparams::init()\n";); g_imp = alloc(imp); - gparams_register_modules(); } void gparams::finalize() { From 42f06b10126469eb407519e3bdc17621fe917d57 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 3 Dec 2012 15:13:11 +0000 Subject: [PATCH 094/133] FPA bugfix Signed-off-by: Christoph M. Wintersteiger --- src/tactic/fpa/fpa2bv_converter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tactic/fpa/fpa2bv_converter.cpp b/src/tactic/fpa/fpa2bv_converter.cpp index f45400a55..8a4b31612 100644 --- a/src/tactic/fpa/fpa2bv_converter.cpp +++ b/src/tactic/fpa/fpa2bv_converter.cpp @@ -1403,7 +1403,7 @@ void fpa2bv_converter::mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * SASSERT(num == 1); expr * sgn, * s, * e; split(args[0], sgn, s, e); - result = m_bv_util.mk_concat(m_bv_util.mk_concat(sgn, s), e); + result = m_bv_util.mk_concat(m_bv_util.mk_concat(sgn, e), s); } void fpa2bv_converter::split(expr * e, expr * & sgn, expr * & sig, expr * & exp) const { From 67485b8af7d820b6ace358a51f143c07b0862941 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 3 Dec 2012 08:29:28 -0800 Subject: [PATCH 095/133] fixing handling of arrays Signed-off-by: Nikolaj Bjorner --- src/muz_qe/pdr_context.cpp | 31 +++++++++++++++++-------------- src/muz_qe/pdr_quantifiers.cpp | 2 +- src/muz_qe/pdr_util.cpp | 2 ++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index ab4ff3a2c..76b609720 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1809,11 +1809,12 @@ namespace pdr { n.set_rule(&r); - IF_VERBOSE(3, verbose_stream() << "Model:\n"; - model_smt2_pp(verbose_stream(), m, *M, 0); - verbose_stream() << "\n"; - verbose_stream() << "Transition:\n" << mk_pp(T, m) << "\n"; - verbose_stream() << "Phi:\n" << mk_pp(phi, m) << "\n";); + TRACE("pdr", + tout << "Model:\n"; + model_smt2_pp(tout, m, *M, 0); + tout << "\n"; + tout << "Transition:\n" << mk_pp(T, m) << "\n"; + tout << "Phi:\n" << mk_pp(phi, m) << "\n";); model_evaluator mev(m); expr_ref_vector mdl(m), forms(m), Phi(m); @@ -1843,19 +1844,21 @@ namespace pdr { qe_lite qe(m); expr_ref phi1 = m_pm.mk_and(Phi); qe(vars, phi1); + TRACE("pdr", tout << "Eliminated\n" << mk_pp(phi1, m) << "\n";); if (!use_model_generalizer) { reduce_disequalities(*M, 3, phi1); + TRACE("pdr", tout << "Reduced-eq\n" << mk_pp(phi1, m) << "\n";); } get_context().get_rewriter()(phi1); - IF_VERBOSE(2, - verbose_stream() << "Vars:\n"; - for (unsigned i = 0; i < vars.size(); ++i) { - verbose_stream() << mk_pp(vars[i].get(), m) << "\n"; - } - verbose_stream() << "Literals\n"; - verbose_stream() << mk_pp(m_pm.mk_and(Phi), m) << "\n"; - verbose_stream() << "Reduced\n" << mk_pp(phi1, m) << "\n";); + TRACE("pdr", + tout << "Vars:\n"; + for (unsigned i = 0; i < vars.size(); ++i) { + tout << mk_pp(vars[i].get(), m) << "\n"; + } + tout << "Literals\n"; + tout << mk_pp(m_pm.mk_and(Phi), m) << "\n"; + tout << "Reduced\n" << mk_pp(phi1, m) << "\n";); if (!vars.empty()) { // also fresh names for auxiliary variables in body? @@ -1870,7 +1873,7 @@ namespace pdr { if (!rep) rep = mk_expr_simp_replacer(m); rep->set_substitution(&sub); (*rep)(phi1); - IF_VERBOSE(2, verbose_stream() << "Projected:\n" << mk_pp(phi1, m) << "\n";); + TRACE("pdr", tout << "Projected:\n" << mk_pp(phi1, m) << "\n";); } Phi.reset(); datalog::flatten_and(phi1, Phi); diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index c041f0671..51a86e38c 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -536,7 +536,7 @@ namespace pdr { if (!node.get_model_ptr()) { return; } - m_current_rule = &pt.find_rule(node.get_model()); + m_current_rule = node.get_rule(); m_current_pt = &pt; m_current_node = &node; if (!m_current_rule) { diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index c0b1859bb..515f61338 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -238,11 +238,13 @@ namespace pdr { result.push_back(m.mk_not(e)); } } +#if 0 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; } +#endif reset(); TRACE("pdr", tout << "minimized model:\n"; From b219b875b1afe087a09c5ff5424f3cc7bedbb9ae Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 09:37:15 -0800 Subject: [PATCH 096/133] fixed bug in using-params combinator in the SMT 2.0 front-end Signed-off-by: Leonardo de Moura --- src/cmd_context/tactic_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index ba1193b20..8a7449a88 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -497,7 +497,7 @@ static tactic * mk_using_params(cmd_context & ctx, sexpr * n) { throw cmd_exception("invalid using-params combinator, keyword expected", c->get_line(), c->get_pos()); if (i == num_children) throw cmd_exception("invalid using-params combinator, parameter value expected", c->get_line(), c->get_pos()); - symbol param_name = c->get_symbol(); + symbol param_name = symbol(smt2_keyword_to_param(c->get_symbol()).c_str()); c = n->get_child(i); i++; switch (descrs.get_kind(param_name)) { From eb3fa254d84c48bbaa65c3d0802c90dac98d7eb1 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 3 Dec 2012 17:56:42 +0000 Subject: [PATCH 097/133] Java API: bugfix Signed-off-by: Christoph M. Wintersteiger --- src/api/java/AST.java | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/api/java/AST.java b/src/api/java/AST.java index 418c43e9f..b7d048a1e 100644 --- a/src/api/java/AST.java +++ b/src/api/java/AST.java @@ -37,13 +37,15 @@ public class AST extends Z3Object **/ public boolean equals(Object o) { - AST casted = null; + AST casted = null; - try { - casted = AST.class.cast(o); - } catch (ClassCastException e) { - return false; - } + try + { + casted = AST.class.cast(o); + } catch (ClassCastException e) + { + return false; + } return this.NativeObject() == casted.NativeObject(); } @@ -60,18 +62,20 @@ public class AST extends Z3Object return 1; AST oAST = null; - try { - AST.class.cast(other); - } catch (ClassCastException e) { - return 1; - } + try + { + oAST = AST.class.cast(other); + } catch (ClassCastException e) + { + return 1; + } - if (Id() < oAST.Id()) - return -1; - else if (Id() > oAST.Id()) - return +1; - else - return 0; + if (Id() < oAST.Id()) + return -1; + else if (Id() > oAST.Id()) + return +1; + else + return 0; } /** From 5c11f394cd69f1502ffd496aa104c3b8d1dc1f6b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 3 Dec 2012 11:01:33 -0800 Subject: [PATCH 098/133] port to new parameter infrastructure Signed-off-by: Nikolaj Bjorner --- src/muz_qe/datalog_parser.cpp | 6 +- src/muz_qe/dl_bmc_engine.cpp | 5 +- src/muz_qe/dl_bmc_engine.h | 3 +- src/muz_qe/dl_cmds.cpp | 24 +- src/muz_qe/dl_context.cpp | 72 +-- src/muz_qe/dl_context.h | 47 +- src/muz_qe/dl_mk_bit_blast.cpp | 4 +- src/muz_qe/dl_mk_rule_inliner.cpp | 8 +- src/muz_qe/dl_smt_relation.cpp | 766 ------------------------ src/muz_qe/dl_smt_relation.h | 141 ----- src/muz_qe/dl_util.h | 1 + src/muz_qe/fixedpoint_params.pyg | 62 ++ src/muz_qe/horn_tactic.cpp | 4 +- src/muz_qe/pdr_context.cpp | 52 +- src/muz_qe/pdr_context.h | 7 +- src/muz_qe/pdr_dl_interface.cpp | 41 +- src/muz_qe/pdr_dl_interface.h | 2 - src/muz_qe/pdr_farkas_learner.cpp | 1 - src/muz_qe/pdr_generalizers.cpp | 74 +-- src/muz_qe/pdr_generalizers.h | 7 - src/muz_qe/pdr_interpolant_provider.cpp | 381 ------------ src/muz_qe/pdr_interpolant_provider.h | 54 -- src/muz_qe/pdr_manager.cpp | 15 +- src/muz_qe/pdr_manager.h | 18 +- src/muz_qe/pdr_prop_solver.cpp | 2 +- src/muz_qe/pdr_reachable_cache.cpp | 4 +- src/muz_qe/pdr_reachable_cache.h | 11 +- src/muz_qe/pdr_smt_context_manager.cpp | 4 +- src/muz_qe/pdr_smt_context_manager.h | 3 +- src/shell/datalog_frontend.cpp | 8 +- src/test/dl_smt_relation.cpp | 234 -------- src/test/main.cpp | 1 - 32 files changed, 174 insertions(+), 1888 deletions(-) delete mode 100644 src/muz_qe/dl_smt_relation.cpp delete mode 100644 src/muz_qe/dl_smt_relation.h create mode 100644 src/muz_qe/fixedpoint_params.pyg delete mode 100644 src/muz_qe/pdr_interpolant_provider.cpp delete mode 100644 src/muz_qe/pdr_interpolant_provider.h delete mode 100644 src/test/dl_smt_relation.cpp diff --git a/src/muz_qe/datalog_parser.cpp b/src/muz_qe/datalog_parser.cpp index a1bfc629d..afda12858 100644 --- a/src/muz_qe/datalog_parser.cpp +++ b/src/muz_qe/datalog_parser.cpp @@ -1160,9 +1160,9 @@ class wpa_parser_impl : public wpa_parser, dparser { public: wpa_parser_impl(context & ctx) : dparser(ctx, ctx.get_manager()), - m_bool_sort(ctx.get_manager()), - m_short_sort(ctx.get_manager()), - m_use_map_names(ctx.get_params().get_bool("use_map_names", true)) { + m_bool_sort(ctx.get_manager()), + m_short_sort(ctx.get_manager()), + m_use_map_names(ctx.get_params().use_map_names()) { } ~wpa_parser_impl() { reset_dealloc_values(m_sort_contents); diff --git a/src/muz_qe/dl_bmc_engine.cpp b/src/muz_qe/dl_bmc_engine.cpp index e88e04c5a..dd35cc870 100644 --- a/src/muz_qe/dl_bmc_engine.cpp +++ b/src/muz_qe/dl_bmc_engine.cpp @@ -71,7 +71,7 @@ namespace datalog { m_ctx.set_output_predicate(m_query_pred); m_ctx.apply_default_transformation(mc, m_pc); - if (m_ctx.get_params().get_bool("slice", true)) { + if (m_ctx.get_params().slice()) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); @@ -1100,9 +1100,6 @@ namespace datalog { m_solver.reset_statistics(); } - void bmc::collect_params(param_descrs& p) { - } - expr_ref bmc::get_answer() { return m_answer; } diff --git a/src/muz_qe/dl_bmc_engine.h b/src/muz_qe/dl_bmc_engine.h index bd330fa22..5b6e433cd 100644 --- a/src/muz_qe/dl_bmc_engine.h +++ b/src/muz_qe/dl_bmc_engine.h @@ -24,6 +24,7 @@ Revision History: #include "statistics.h" #include "smt_kernel.h" #include "bv_decl_plugin.h" +#include "smt_params.h" namespace datalog { @@ -130,8 +131,6 @@ namespace datalog { void reset_statistics(); expr_ref get_answer(); - - static void collect_params(param_descrs& p); }; }; diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index f45165709..735df8d80 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -28,13 +28,15 @@ Notes: #include"cancel_eh.h" #include"scoped_ctrl_c.h" #include"scoped_timer.h" +#include"params2smt_params.h" #include"trail.h" #include -class dl_context { - // PARAM-TODO temp HACK: added m_params field because cmd_context does not have smt_params anymore - smt_params m_params; +struct dl_context { + smt_params m_fparams; + params_ref m_params_ref; + fixedpoint_params m_params; cmd_context & m_cmd; dl_collected_cmds* m_collected_cmds; unsigned m_ref_count; @@ -42,8 +44,8 @@ class dl_context { scoped_ptr m_context; trail_stack m_trail; -public: dl_context(cmd_context & ctx, dl_collected_cmds* collected_cmds): + m_params(m_params_ref), m_cmd(ctx), m_collected_cmds(collected_cmds), m_ref_count(0), @@ -64,7 +66,7 @@ public: void init() { ast_manager& m = m_cmd.m(); if (!m_context) { - m_context = alloc(datalog::context, m, m_params); + m_context = alloc(datalog::context, m, m_fparams, m_params_ref); } if (!m_decl_plugin) { symbol name("datalog_relation"); @@ -212,7 +214,7 @@ public: datalog::context& dlctx = m_dl_ctx->dlctx(); set_background(ctx); dlctx.updt_params(m_params); - unsigned timeout = m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = m_dl_ctx->m_params.timeout(); cancel_eh eh(dlctx); lbool status = l_undef; { @@ -267,10 +269,6 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { m_dl_ctx->dlctx().collect_params(p); - insert_timeout(p); - p.insert("print_answer", CPK_BOOL, "(default: false) print answer instance(s) to query."); - p.insert("print_certificate", CPK_BOOL, "(default: false) print certificate for reachability or non-reachability."); - p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } @@ -285,7 +283,7 @@ private: } void print_answer(cmd_context& ctx) { - if (m_params.get_bool("print_answer", false)) { + if (m_dl_ctx->m_params.print_answer()) { datalog::context& dlctx = m_dl_ctx->dlctx(); ast_manager& m = ctx.m(); expr_ref query_result(dlctx.get_answer_as_formula(), m); @@ -300,7 +298,7 @@ private: } void print_statistics(cmd_context& ctx) { - if (m_params.get_bool("print_statistics", false)) { + if (m_dl_ctx->m_params.print_statistics()) { statistics st; datalog::context& dlctx = m_dl_ctx->dlctx(); unsigned long long max_mem = memory::get_max_used_memory(); @@ -314,7 +312,7 @@ private: } void print_certificate(cmd_context& ctx) { - if (m_params.get_bool("print_certificate", false)) { + if (m_dl_ctx->m_params.print_certificate()) { datalog::context& dlctx = m_dl_ctx->dlctx(); if (!dlctx.display_certificate(ctx.regular_stream())) { throw cmd_exception("certificates are not supported for the selected engine"); diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 3b7ad6ffc..228dbc572 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -44,7 +44,6 @@ Revision History: #include"dl_compiler.h" #include"dl_instruction.h" #include"dl_context.h" -#include"dl_smt_relation.h" #ifndef _EXTERNAL_RELEASE #include"dl_skip_table.h" #endif @@ -229,7 +228,8 @@ namespace datalog { context::context(ast_manager & m, smt_params& fp, params_ref const& pa): m(m), m_fparams(fp), - m_params(pa), + m_params_ref(pa), + m_params(m_params_ref), m_decl_util(m), m_rewriter(m), m_var_subst(m), @@ -259,7 +259,6 @@ namespace datalog { #endif //register plugins for builtin relations - get_rmanager().register_plugin(alloc(smt_relation_plugin, get_rmanager())); get_rmanager().register_plugin(alloc(bound_relation_plugin, get_rmanager())); get_rmanager().register_plugin(alloc(interval_relation_plugin, get_rmanager())); @@ -960,66 +959,13 @@ namespace datalog { } void context::collect_params(param_descrs& p) { - p.insert("engine", CPK_SYMBOL, "(default: automatically configured) select 'datalog', PDR 'pdr' engine."); - p.insert("bit_blast", CPK_BOOL, "(default: false) bit-blast bit-vectors (for PDR engine)."); - p.insert("default_table", CPK_SYMBOL, "default table implementation: 'sparse' (default), 'hashtable', 'bitvector', 'interval'"); - p.insert("default_relation", CPK_SYMBOL, "default relation implementation: 'external_relation', 'pentagon'"); - - p.insert("generate_explanations", CPK_BOOL, "if true, signature of relations will be extended to contain explanations for facts"); - p.insert("explanations_on_relation_level", CPK_BOOL, "if true, explanations are generated as history of each relation, " - "rather than per fact (generate_explanations must be set to true for this option to have any effect)"); - - p.insert("magic_sets_for_queries", CPK_BOOL, "magic set transformation will be used for queries"); - p.insert("unbound_compressor", CPK_BOOL, "auxiliary relations will be introduced to avoid unbound variables in rule heads"); - p.insert("similarity_compressor", CPK_BOOL, "rules that differ only in values of constants will be merged into a single rule"); - p.insert("similarity_compressor_threshold", CPK_UINT, "if dl_similiaryt_compressor is on, this value determines how many " - "similar rules there must be in order for them to be merged"); - - p.insert("all_or_nothing_deltas", CPK_BOOL, "compile rules so that it is enough for the delta relation in union and widening " - "operations to determine only whether the updated relation was modified or not"); - p.insert("compile_with_widening", CPK_BOOL, "widening will be used to compile recursive rules"); - p.insert("eager_emptiness_checking", CPK_BOOL, "emptiness of affected relations will be checked after each instruction, " - "so that we may ommit unnecessary instructions"); - p.insert("default_table_checked", CPK_BOOL, - "if true, the detault table will be default_table inside a wrapper that checks that " - "its results are the same as of default_table_checker table"); - - - p.insert("initial_restart_timeout", CPK_UINT, "length of saturation run before the first restart (in ms); zero means no restarts"); - p.insert("restart_timeout_quotient", CPK_UINT, "restart timeout will be multiplied by this number after each restart"); - p.insert("use_map_names", CPK_BOOL, "use names from map files when displaying tuples"); - - p.insert("output_profile", CPK_BOOL, "determines whether profile informations should be output when outputting Datalog rules or instructions"); - p.insert("output_tuples", CPK_BOOL, "determines whether tuples for output predicates should be output"); - 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 false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); - p.insert("print_with_variable_declarations", CPK_BOOL, "(default true) use variable declarations when displaying rules (instead of attempting to use original names)"); - -#ifndef _EXTERNAL_RELEASE - p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, - "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " - "by putting in half of the table columns, if it would have been empty otherwise"); - - p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); - p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion"); -#endif - p.insert("fix_unbound_vars", CPK_BOOL, "fix unbound variables in tail"); - p.insert("default_table_checker", CPK_SYMBOL, "see default_table_checked"); - p.insert("inline_linear", CPK_BOOL, "(default true) try linear inlining method"); - p.insert("inline_eager", CPK_BOOL, "(default true) try eager inlining of rules"); - - - pdr::dl_interface::collect_params(p); - bmc::collect_params(p); + fixedpoint_params::collect_param_descrs(p); insert_timeout(p); } void context::updt_params(params_ref const& p) { - m_params.copy(p); - if (m_pdr.get()) m_pdr->updt_params(); - + m_params_ref.copy(p); + if (m_pdr.get()) m_pdr->updt_params(); } void context::collect_predicates(decl_set & res) { @@ -1190,7 +1136,7 @@ namespace datalog { }; void context::configure_engine() { - symbol e = m_params.get_sym("engine", symbol()); + symbol e = m_params.engine(); if (e == symbol("datalog")) { m_engine = DATALOG_ENGINE; @@ -1668,9 +1614,9 @@ namespace datalog { expr_ref fml(m); 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", false); - bool do_declare_vars = m_params.get_bool("print_with_variable_declarations", true); + bool use_fixedpoint_extensions = m_params.print_with_fixedpoint_extensions(); + bool print_low_level = m_params.print_low_level_smt2(); + bool do_declare_vars = m_params.print_with_variable_declarations(); #define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env); diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index 9078bc693..5dcb3e1fa 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -24,7 +24,6 @@ Revision History: #undef max #endif #include"arith_decl_plugin.h" -#include"smt_params.h" #include"map.h" #include"th_rewriter.h" #include"str_hashtable.h" @@ -44,6 +43,7 @@ Revision History: #include"model_converter.h" #include"proof_converter.h" #include"model2expr.h" +#include"smt_params.h" namespace datalog { @@ -78,8 +78,9 @@ namespace datalog { typedef vector > fact_vector; ast_manager & m; - smt_params& m_fparams; - params_ref m_params; + smt_params & m_fparams; + params_ref m_params_ref; + fixedpoint_params m_params; dl_decl_util m_decl_util; th_rewriter m_rewriter; var_subst m_var_subst; @@ -122,7 +123,7 @@ namespace datalog { public: - context(ast_manager & m, smt_params& params, params_ref const& p = params_ref()); + context(ast_manager & m, smt_params& fp, params_ref const& p = params_ref()); ~context(); void reset(); @@ -150,31 +151,31 @@ namespace datalog { const relation_manager & get_rmanager() const { return m_rmanager; } rule_manager & get_rule_manager() { return m_rule_manager; } smt_params & get_fparams() const { return m_fparams; } - params_ref const& get_params() const { return m_params; } + fixedpoint_params const& get_params() const { return m_params; } DL_ENGINE get_engine() { configure_engine(); return m_engine; } th_rewriter& get_rewriter() { return m_rewriter; } var_subst & get_var_subst() { return m_var_subst; } dl_decl_util & get_decl_util() { return m_decl_util; } - bool output_profile() const { return m_params.get_bool("output_profile", false); } - bool fix_unbound_vars() const { return m_params.get_bool("fix_unbound_vars", false); } - symbol default_table() const { return m_params.get_sym("default_table", symbol("sparse")); } - symbol default_relation() const { return m_params.get_sym("default_relation", external_relation_plugin::get_name()); } - symbol default_table_checker() const { return m_params.get_sym("default_table_checker", symbol("sparse")); } - bool default_table_checked() const { return m_params.get_bool("default_table_checked", false); } - bool dbg_fpr_nonempty_relation_signature() const { return m_params.get_bool("dbg_fpr_nonempty_relation_signatures", false); } - unsigned dl_profile_milliseconds_threshold() const { return m_params.get_uint("profile_milliseconds_threshold", 0); } - bool all_or_nothing_deltas() const { return m_params.get_bool("all_or_nothing_deltas", false); } - bool compile_with_widening() const { return m_params.get_bool("compile_with_widening", false); } - bool unbound_compressor() const { return m_params.get_bool("unbound_compressor", true); } - bool similarity_compressor() const { return m_params.get_bool("similarity_compressor", true); } - unsigned similarity_compressor_threshold() const { return m_params.get_uint("similarity_compressor_threshold", 11); } + bool output_profile() const { return m_params.output_profile(); } + bool fix_unbound_vars() const { return m_params.fix_unbound_vars(); } + symbol default_table() const { return m_params.default_table(); } + symbol default_relation() const { return m_params.default_relation(); } // external_relation_plugin::get_name()); + symbol default_table_checker() const { return m_params.default_table_checker(); } + bool default_table_checked() const { return m_params.default_table_checked(); } + bool dbg_fpr_nonempty_relation_signature() const { return m_params.dbg_fpr_nonempty_relation_signature(); } + unsigned dl_profile_milliseconds_threshold() const { return m_params.profile_timeout_milliseconds(); } + bool all_or_nothing_deltas() const { return m_params.all_or_nothing_deltas(); } + bool compile_with_widening() const { return m_params.compile_with_widening(); } + bool unbound_compressor() const { return m_params.unbound_compressor(); } + bool similarity_compressor() const { return m_params.similarity_compressor(); } + unsigned similarity_compressor_threshold() const { return m_params.similarity_compressor_threshold(); } unsigned soft_timeout() const { return m_fparams.m_soft_timeout; } - unsigned initial_restart_timeout() const { return m_params.get_uint("initial_restart_timeout", 0); } - bool generate_explanations() const { return m_params.get_bool("generate_explanations", false); } - bool explanations_on_relation_level() const { return m_params.get_bool("explanations_on_relation_level", false); } - bool magic_sets_for_queries() const { return m_params.get_bool("magic_sets_for_queries", false); } - bool eager_emptiness_checking() const { return m_params.get_bool("eager_emptiness_checking", true); } + unsigned initial_restart_timeout() const { return m_params.initial_restart_timeout(); } + bool generate_explanations() const { return m_params.generate_explanations(); } + bool explanations_on_relation_level() const { return m_params.explanations_on_relation_level(); } + bool magic_sets_for_queries() const { return m_params.magic_sets_for_queries(); } + bool eager_emptiness_checking() const { return m_params.eager_emptiness_checking(); } void register_finite_sort(sort * s, sort_kind k); diff --git a/src/muz_qe/dl_mk_bit_blast.cpp b/src/muz_qe/dl_mk_bit_blast.cpp index c523315d9..1fa93a0ca 100644 --- a/src/muz_qe/dl_mk_bit_blast.cpp +++ b/src/muz_qe/dl_mk_bit_blast.cpp @@ -161,7 +161,7 @@ namespace datalog { impl(context& ctx): m_context(ctx), m(ctx.get_manager()), - m_params(ctx.get_params()), + m_params(ctx.get_params().p), m_rules(ctx.get_rule_manager()), m_blaster(ctx.get_manager(), m_params), m_rewriter(ctx.get_manager(), ctx, m_rules) { @@ -172,7 +172,7 @@ namespace datalog { rule_set * operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc) { // TODO mc, pc - if (!m_context.get_params().get_bool("bit_blast", false)) { + if (!m_context.get_params().bit_blast()) { return 0; } if (m_context.get_engine() != PDR_ENGINE) { diff --git a/src/muz_qe/dl_mk_rule_inliner.cpp b/src/muz_qe/dl_mk_rule_inliner.cpp index cfe532fb6..9c9bf7abb 100644 --- a/src/muz_qe/dl_mk_rule_inliner.cpp +++ b/src/muz_qe/dl_mk_rule_inliner.cpp @@ -750,8 +750,7 @@ namespace datalog { valid.reset(); valid.resize(sz, true); - params_ref const& params = m_context.get_params(); - bool allow_branching = params.get_bool("inline_linear_branch", false); + bool allow_branching = m_context.get_params().inline_linear_branch(); for (unsigned i = 0; i < sz; ++i) { @@ -842,7 +841,6 @@ namespace datalog { bool something_done = false; ref hsmc; ref hpc; - params_ref const& params = m_context.get_params(); if (source.get_num_rules() == 0) { return 0; @@ -867,7 +865,7 @@ namespace datalog { scoped_ptr res = alloc(rule_set, m_context); - if (params.get_bool("inline_eager", true)) { + if (m_context.get_params().inline_eager()) { TRACE("dl", source.display(tout << "before eager inlining\n");); plan_inlining(source); something_done = transform_rules(source, *res); @@ -879,7 +877,7 @@ namespace datalog { TRACE("dl", res->display(tout << "after eager inlining\n");); } - if (params.get_bool("inline_linear", true) && inline_linear(res)) { + if (m_context.get_params().inline_linear() && inline_linear(res)) { something_done = true; } diff --git a/src/muz_qe/dl_smt_relation.cpp b/src/muz_qe/dl_smt_relation.cpp deleted file mode 100644 index ee465a7d8..000000000 --- a/src/muz_qe/dl_smt_relation.cpp +++ /dev/null @@ -1,766 +0,0 @@ -/*++ -Copyright (c) 2010 Microsoft Corporation - -Module Name: - - dl_smt_relation.cpp - -Abstract: - - Relation based on SMT signature. - - -Author: - - Nikolaj Bjorner (nbjorner) 2010-10-10 - -Revision History: - ---*/ -#include -#include "debug.h" -#include "ast_pp.h" -#include "dl_context.h" -#include "dl_smt_relation.h" -#include "expr_abstract.h" -#include "smt_kernel.h" -#include "th_rewriter.h" -#include "qe.h" -#include "datatype_decl_plugin.h" -#include "bv_decl_plugin.h" -#include "ast_ll_pp.h" -#include "expr_context_simplifier.h" -#include "has_free_vars.h" -#include "ast_smt_pp.h" - -namespace datalog { - - - smt_relation::smt_relation(smt_relation_plugin & p, const relation_signature & s, expr* r) - : relation_base(p, s), - m_rel(r, p.get_ast_manager()), - m_bound_vars(p.get_ast_manager()) - { - ast_manager& m = p.get_ast_manager(); - for (unsigned i = 0; m_bound_vars.size() < s.size(); ++i) { - unsigned j = s.size() - i - 1; - m_bound_vars.push_back(m.mk_const(symbol(j), s[j])); - } - SASSERT(is_well_formed()); - } - - smt_relation::~smt_relation() { - } - - bool smt_relation::is_well_formed() const { - ast_manager& m = get_manager(); - ptr_vector bound_sorts; - for (unsigned i = 0; i < m_bound_vars.size(); ++i) { - bound_sorts.push_back(m.get_sort(m_bound_vars[i])); - } - return is_well_formed_vars(bound_sorts, get_relation()); - } - - void smt_relation::instantiate(expr* r, expr_ref& result) const { - ast_manager& m = get_manager(); - var_subst subst(m); - ptr_vector bound_sorts; - for (unsigned i = 0; i < m_bound_vars.size(); ++i) { - bound_sorts.push_back(m.get_sort(m_bound_vars[i])); - } - TRACE("smt_relation", - tout << mk_ll_pp(r, m) << "\n"; - for (unsigned i = 0; i < bound_sorts.size(); ++i) { - tout << mk_pp(bound_sorts[i], m) << " "; - } - tout << "\n"; - ); - SASSERT(is_well_formed_vars(bound_sorts, r)); - - subst(r, m_bound_vars.size(), m_bound_vars.c_ptr(), result); - } - - void smt_relation::mk_abstract(expr* r, expr_ref& result) const { - ast_manager& m = get_manager(); - TRACE("smt_relation", tout << mk_ll_pp(r, m) << "\n";); - expr_abstract(m, 0, m_bound_vars.size(), m_bound_vars.c_ptr(), r, result); - TRACE("smt_relation", tout << mk_ll_pp(result, m) << "\n";); - ptr_vector bound_sorts; - for (unsigned i = 0; i < m_bound_vars.size(); ++i) { - bound_sorts.push_back(m.get_sort(m_bound_vars[i])); - } - SASSERT(is_well_formed_vars(bound_sorts, r)); - } - - void smt_relation::set_relation(expr* r) { - m_rel = r; - is_well_formed(); - } - - void smt_relation::add_relation(expr* s) { - ast_manager& m = get_manager(); - m_rel = m.mk_or(m_rel, s); - is_well_formed(); - } - - void smt_relation::filter_relation(expr* s) { - ast_manager& m = get_manager(); - m_rel = m.mk_and(m_rel, s); - is_well_formed(); - } - - expr* smt_relation::get_relation() const { - return m_rel.get(); - } - - void smt_relation::simplify(expr_ref& fml) const { - th_rewriter rw(get_manager()); - rw(fml); - } - - bool smt_relation::empty() const { - ast_manager& m = get_manager(); - expr* r = get_relation(); - if (m.is_true(r)) { - return false; - } - if (m.is_false(r)) { - return true; - } - IF_VERBOSE(10, verbose_stream() << "Checking emptiness...\n"; ); - - smt_params& params = get_plugin().get_fparams(); - // [Leo]: asserted_formulas do not have support for der. - // We should use the tactics der. - // flet flet2(params.m_der, true); - smt::kernel ctx(m, params); - expr_ref tmp(m); - instantiate(r, tmp); - ctx.assert_expr(tmp); - if (get_plugin().get_fparams().m_dump_goal_as_smt) { - static unsigned n = 0; - std::ostringstream strm; - strm << "File" << n << ".smt2"; - std::ofstream out(strm.str().c_str()); - ast_smt_pp pp(m); - pp.display_smt2(out, tmp); - ++n; - } - return l_false == ctx.check(); - } - - void smt_relation::add_fact(const relation_fact & f) { - SASSERT(f.size() == size()); - ast_manager& m = get_manager(); - expr_ref_vector eqs(m); - for (unsigned i = 0; i < f.size(); ++i) { - eqs.push_back(m.mk_eq(m.mk_var(i,m.get_sort(f[i])), f[i])); - } - expr_ref e1(m.mk_and(eqs.size(), eqs.c_ptr()), m); - add_relation(e1); - } - - - bool smt_relation::contains_fact(const relation_fact & f) const { - ast_manager& m = get_manager(); - expr_ref_vector eqs(m); - expr_ref cond(m); - for (unsigned i = 0; i < f.size(); ++i) { - eqs.push_back(m.mk_eq(m.mk_var(i,m.get_sort(f[i])), f[i])); - } - cond = m.mk_and(eqs.size(), eqs.c_ptr()); - return const_cast(this)->contains(cond); - } - - // - // facts in Rel iff - // facts => Rel iff - // facts & not Rel is unsat - // - bool smt_relation::contains(expr* facts) { - ast_manager& m = get_manager(); - expr_ref fml_free(m), fml_inst(m); - fml_free = m.mk_and(facts, m.mk_not(get_relation())); - instantiate(fml_free, fml_inst); - smt_params& params = get_plugin().get_fparams(); - // [Leo]: asserted_formulas do not have support for qe nor der. - // We should use the tactics qe and der. - // BTW, qe at asserted_formulas was disabled when we moved to codeplex, but the field m_quant_elim was not deleted. - // - // flet flet0(params.m_quant_elim, true); - flet flet1(params.m_nnf_cnf, false); - // flet flet2(params.m_der, true); - smt::kernel ctx(m, params); - ctx.assert_expr(fml_inst); - lbool result = ctx.check(); - TRACE("smt_relation", - display(tout); - tout << mk_pp(facts, m) << "\n"; - tout << ((result == l_false)?"true":"false") << "\n";); - return result == l_false; - } - - smt_relation * smt_relation::clone() const { - return alloc(smt_relation, get_plugin(), get_signature(), get_relation()); - } - - smt_relation * smt_relation::complement(func_decl* p) const { - ast_manager& m = get_manager(); - smt_relation* result = alloc(smt_relation, get_plugin(), get_signature(), m.mk_not(get_relation())); - TRACE("smt_relation", - display(tout<<"src:\n"); - result->display(tout<<"complement:\n");); - return result; - } - - void smt_relation::display(std::ostream & out) const { - if (is_finite_domain()) { - display_finite(out); - } - else { - out << mk_ll_pp(get_relation(), get_manager()) << "\n"; - } - } - - smt_relation_plugin & smt_relation::get_plugin() const { - return static_cast(relation_base::get_plugin()); - } - - bool smt_relation::is_finite_domain() const { - relation_signature const& sig = get_signature(); - for (unsigned i = 0; i < sig.size(); ++i) { - if (!get_plugin().is_finite_domain(sig[i])) { - return false; - } - } - return true; - } - - - void smt_relation::display_finite(std::ostream & out) const { - ast_manager& m = get_manager(); - smt_params& params = get_plugin().get_fparams(); - expr* r = get_relation(); - expr_ref tmp(m); - expr_ref_vector values(m), eqs(m); - unsigned num_vars = m_bound_vars.size(); - values.resize(num_vars); - eqs.resize(num_vars); - instantiate(r, tmp); - flet flet4(params.m_model, true); - smt::kernel ctx(m, params); - ctx.assert_expr(tmp); - - while (true) { - lbool is_sat = ctx.check(); - if (is_sat == l_false) { - break; - } - model_ref mod; - ctx.get_model(mod); - for (unsigned i = 0; i < num_vars; ++i) { - mod->eval(m_bound_vars[i], tmp, true); - values[i] = tmp; - eqs[i] = m.mk_eq(values[i].get(), m_bound_vars[i]); - - } - out << " ("; - for (unsigned i = 0; i < num_vars; ++i) { - unsigned j = num_vars - 1 - i; - out << mk_pp(values[j].get(), m); - if (i + 1 < num_vars) { - out << " "; - } - } - out << ")\n"; - tmp = m.mk_not(m.mk_and(num_vars, eqs.c_ptr())); - ctx.assert_expr(tmp); - } - } - - // ----------------------------------- - // - // smt_relation_plugin - // - // ----------------------------------- - - - smt_relation_plugin::smt_relation_plugin(relation_manager & m) - : relation_plugin(smt_relation_plugin::get_name(), m), m_counter(0) {} - - - relation_base * smt_relation_plugin::mk_empty(const relation_signature & s) { - return alloc(smt_relation, *this, s, get_ast_manager().mk_false()); - } - - - class smt_relation_plugin::join_fn : public convenient_relation_join_fn { - smt_relation_plugin& m_plugin; - expr_ref_vector m_conjs; - public: - join_fn(smt_relation_plugin& p, const relation_signature & o1_sig, const relation_signature & o2_sig, unsigned col_cnt, - const unsigned * cols1, const unsigned * cols2) - : convenient_relation_join_fn(o1_sig, o2_sig, col_cnt, cols1, cols2), - m_plugin(p), - m_conjs(p.get_ast_manager()) { - ast_manager& m = p.get_ast_manager(); - unsigned sz = m_cols1.size(); - for (unsigned i = 0; i < sz; ++i) { - unsigned col1 = m_cols1[i]; - unsigned col2 = m_cols2[i]; - var* v1 = m.mk_var(col1, o1_sig[col1]); - var* v2 = m.mk_var(col2 + o1_sig.size(), o2_sig[col2]); - m_conjs.push_back(m.mk_eq(v1, v2)); - } - } - - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { - ast_manager& m = m_plugin.get_ast_manager(); - expr_ref e2(m), res(m); - shift_vars sh(m); - sh(get(r2).get_relation(), r1.get_signature().size(), e2); - m_conjs.push_back(get(r1).get_relation()); - m_conjs.push_back(e2); - res = m.mk_and(m_conjs.size(), m_conjs.c_ptr()); - m_conjs.pop_back(); - m_conjs.pop_back(); - smt_relation* result = alloc(smt_relation, m_plugin, get_result_signature(), res); - TRACE("smt_relation", - get(r1).display(tout << "src1:\n"); - get(r2).display(tout << "src2:\n"); - for (unsigned i = 0; i < m_conjs.size(); ++i) { - tout << m_cols1[i] << " = " << m_cols2[i] << " -- "; - tout << mk_pp(m_conjs[i].get(), m) << "\n"; - } - result->display(tout << "dst:\n"); - ); - return result; - } - }; - - relation_join_fn * smt_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { - if (!check_kind(r1) || !check_kind(r2)) { - return 0; - } - return alloc(join_fn, *this, r1.get_signature(), r2.get_signature(), col_cnt, cols1, cols2); - } - - class smt_relation_plugin::project_fn : public convenient_relation_project_fn { - smt_relation_plugin& m_plugin; - expr_ref_vector m_subst; - sort_ref_vector m_sorts; - svector m_names; - public: - project_fn(smt_relation_plugin& p, - const relation_signature & orig_sig, unsigned removed_col_cnt, const unsigned * removed_cols) - : convenient_relation_project_fn(orig_sig, removed_col_cnt, removed_cols), - m_plugin(p), - m_subst(p.get_ast_manager()), - m_sorts(p.get_ast_manager()) { - ast_manager& m = p.get_ast_manager(); - unsigned_vector const& cols = m_removed_cols; - unsigned num_cols = cols.size(); - - unsigned lo = 0, hi = num_cols; - for (unsigned i = 0, c = 0; i < orig_sig.size(); ++i) { - SASSERT(c <= num_cols); - if (c == num_cols) { - SASSERT(lo == num_cols); - m_subst.push_back(m.mk_var(hi, orig_sig[i])); - ++hi; - continue; - } - SASSERT(c < num_cols); - unsigned col = cols[c]; - SASSERT(i <= col); - if (i == col) { - m_names.push_back(symbol(p.fresh_name())); - m_sorts.push_back(orig_sig[col]); - m_subst.push_back(m.mk_var(lo, orig_sig[i])); - ++lo; - ++c; - continue; - } - m_subst.push_back(m.mk_var(hi, orig_sig[i])); - ++hi; - } - m_subst.reverse(); - m_sorts.reverse(); - m_names.reverse(); - } - - virtual relation_base * operator()(const relation_base & r) { - ast_manager& m = m_plugin.get_ast_manager(); - expr_ref tmp1(m), tmp2(m); - var_subst subst(m); - smt_relation* result = 0; - tmp1 = get(r).get_relation(); - subst(tmp1, m_subst.size(), m_subst.c_ptr(), tmp2); - tmp2 = m.mk_exists(m_sorts.size(), m_sorts.c_ptr(), m_names.c_ptr(), tmp2); - result = alloc(smt_relation, m_plugin, get_result_signature(), tmp2); - TRACE("smt_relation", - tout << "Signature: "; - for (unsigned i = 0; i < r.get_signature().size(); ++i) { - tout << mk_pp(r.get_signature()[i], m) << " "; - } - tout << "Remove: "; - for (unsigned i = 0; i < m_removed_cols.size(); ++i) { - tout << m_removed_cols[i] << " "; - } - tout << "\n"; - tout << "Subst: "; - for (unsigned i = 0; i < m_subst.size(); ++i) { - tout << mk_pp(m_subst[i].get(), m) << " "; - } - tout << "\n"; - get(r).display(tout); - tout << " --> \n"; - result->display(tout);); - return result; - } - }; - - relation_transformer_fn * smt_relation_plugin::mk_project_fn(const relation_base & r, - unsigned col_cnt, const unsigned * removed_cols) { - return alloc(project_fn, *this, r.get_signature(), col_cnt, removed_cols); - } - - - class smt_relation_plugin::rename_fn : public convenient_relation_rename_fn { - smt_relation_plugin& m_plugin; - expr_ref_vector m_subst; - public: - rename_fn(smt_relation_plugin& p, const relation_signature & orig_sig, unsigned cycle_len, const unsigned * cycle) - : convenient_relation_rename_fn(orig_sig, cycle_len, cycle), - m_plugin(p), - m_subst(p.get_ast_manager()) { - - ast_manager& m = p.get_ast_manager(); - for (unsigned i = 0; i < orig_sig.size(); ++i) { - m_subst.push_back(m.mk_var(i, orig_sig[i])); - } - unsigned col1, col2; - for (unsigned i = 0; i +1 < cycle_len; ++i) { - col1 = cycle[i]; - col2 = cycle[i+1]; - m_subst[col2] = m.mk_var(col1, orig_sig[col2]); - } - col1 = cycle[cycle_len-1]; - col2 = cycle[0]; - m_subst[col2] = m.mk_var(col1, orig_sig[col2]); - m_subst.reverse(); - } - - virtual relation_base * operator()(const relation_base & r) { - ast_manager& m = m_plugin.get_ast_manager(); - expr_ref res(m); - var_subst subst(m); - subst(get(r).get_relation(), m_subst.size(), m_subst.c_ptr(), res); - TRACE("smt_relation3", - tout << "cycle: "; - for (unsigned i = 0; i < m_cycle.size(); ++i) { - tout << m_cycle[i] << " "; - } - tout << "\n"; - tout << "old_sig: "; - for (unsigned i = 0; i < r.get_signature().size(); ++i) { - tout << mk_pp(r.get_signature()[i], m) << " "; - } - tout << "\n"; - tout << "new_sig: "; - for (unsigned i = 0; i < get_result_signature().size(); ++i) { - tout << mk_pp(get_result_signature()[i], m) << " "; - } - tout << "\n"; - tout << "subst: "; - for (unsigned i = 0; i < m_subst.size(); ++i) { - tout << mk_pp(m_subst[i].get(), m) << " "; - } - tout << "\n"; - get(r).display(tout << "src:\n"); - tout << "dst:\n" << mk_ll_pp(res, m) << "\n"; - ); - smt_relation* result = alloc(smt_relation, m_plugin, get_result_signature(), res); - - return result; - } - }; - - relation_transformer_fn * smt_relation_plugin::mk_rename_fn(const relation_base & r, - unsigned cycle_len, const unsigned * permutation_cycle) { - if(!check_kind(r)) { - return 0; - } - return alloc(rename_fn, *this, r.get_signature(), cycle_len, permutation_cycle); - } - - - class smt_relation_plugin::union_fn : public relation_union_fn { - smt_relation_plugin& m_plugin; - - public: - union_fn(smt_relation_plugin& p) : - m_plugin(p) { - } - - virtual void operator()(relation_base & r, const relation_base & src, relation_base * delta) { - ast_manager& m = m_plugin.get_ast_manager(); - expr* srcE = get(src).get_relation(); - TRACE("smt_relation", - tout << "dst:\n"; - get(r).display(tout); - tout << "src:\n"; - get(src).display(tout);); - - SASSERT(get(src).is_well_formed()); - SASSERT(get(r).is_well_formed()); - - if (delta) { - // - // delta(a) <- - // exists x . srcE(a, x) & not rE(a, y) - - - expr_ref rInst(m), srcInst(m), tmp(m), tmp1(m); - expr_ref notR(m), srcGround(m); - smt_params& fparams = get(r).get_plugin().get_fparams(); - params_ref const& params = get(r).get_plugin().get_params(); - - get(r).instantiate(get(r).get_relation(), rInst); - get(src).instantiate(get(src).get_relation(), srcInst); - qe::expr_quant_elim_star1 qe(m, fparams); - - IF_VERBOSE(10, verbose_stream() << "Computing delta...\n"; ); - - if (params.get_bool("smt_relation_ground_recursive", false)) { - // ensure R is ground. Simplify S using assumption not R - if (!is_ground(rInst)) { - proof_ref pr(m); - qe(rInst, tmp, pr); - rInst = tmp; - get(r).set_relation(rInst); - } - SASSERT(is_ground(rInst)); - notR = m.mk_not(rInst); - qe.reduce_with_assumption(notR, srcInst, tmp); - SASSERT(is_ground(tmp)); - } - else { - // Simplify not R usng assumption Exists x . S. - expr_ref srcGround(srcInst, m); - app_ref_vector srcVars(m); - qe::hoist_exists(srcGround, srcVars); - SASSERT(is_ground(srcGround)); - notR = m.mk_not(rInst); - qe.reduce_with_assumption(srcGround, notR, tmp1); - tmp = m.mk_and(srcInst, tmp1); - SASSERT(!has_free_vars(tmp)); - TRACE("smt_relation", - tout << "elim_exists result:\n" << mk_ll_pp(tmp, m) << "\n";); - } - - SASSERT(!has_free_vars(tmp)); - get(r).simplify(tmp); - - get(src).mk_abstract(tmp, tmp1); - TRACE("smt_relation", tout << "abstracted:\n"; tout << mk_ll_pp(tmp1, m) << "\n";); - get(*delta).set_relation(tmp1); - get(r).add_relation(tmp1); - } - else { - get(r).add_relation(srcE); - } - TRACE("smt_relation", get(r).display(tout << "dst':\n");); - } - }; - - relation_union_fn * smt_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta) { - if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; - } - return alloc(union_fn, *this); - } - - relation_union_fn * smt_relation_plugin::mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta) { - if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; - } - return alloc(union_fn, *this); - } - - class smt_relation_plugin::filter_interpreted_fn : public relation_mutator_fn { - smt_relation_plugin& m_plugin; - app_ref m_condition; - public: - filter_interpreted_fn(smt_relation_plugin& p, app * condition) - : m_plugin(p), - m_condition(condition, p.get_ast_manager()) { - } - - virtual void operator()(relation_base & r) { - SASSERT(m_plugin.check_kind(r)); - get(r).filter_relation(m_condition); - TRACE("smt_relation", - tout << mk_pp(m_condition, m_plugin.get_ast_manager()) << "\n"; - get(r).display(tout); - ); - } - }; - - relation_mutator_fn * smt_relation_plugin::mk_filter_interpreted_fn(const relation_base & r, app * condition) { - if(!check_kind(r)) { - return 0; - } - return alloc(filter_interpreted_fn, *this, condition); - } - - relation_mutator_fn * smt_relation_plugin::mk_filter_equal_fn(const relation_base & r, - const relation_element & value, unsigned col) { - if(!check_kind(r)) { - return 0; - } - ast_manager& m = get_ast_manager(); - app_ref condition(m); - expr_ref var(m.mk_var(col, r.get_signature()[col]), m); - condition = m.mk_eq(var, value); - return mk_filter_interpreted_fn(r, condition); - } - - class smt_relation_plugin::filter_identical_fn : public relation_mutator_fn { - smt_relation_plugin& m_plugin; - expr_ref m_condition; - public: - filter_identical_fn(smt_relation_plugin& p, const relation_signature & sig, unsigned col_cnt, const unsigned * identical_cols) - : m_plugin(p), - m_condition(p.get_ast_manager()) { - if (col_cnt <= 1) { - return; - } - ast_manager& m = p.get_ast_manager(); - unsigned col = identical_cols[0]; - expr_ref v0(m.mk_var(col, sig[col]), m); - expr_ref_vector eqs(m); - for (unsigned i = 1; i < col_cnt; ++i) { - col = identical_cols[i]; - eqs.push_back(m.mk_eq(v0, m.mk_var(col, sig[col]))); - } - m_condition = m.mk_and(eqs.size(), eqs.c_ptr()); - } - - virtual void operator()(relation_base & r) { - get(r).filter_relation(m_condition); - TRACE("smt_relation", - tout << mk_pp(m_condition, m_plugin.get_ast_manager()) << "\n"; - get(r).display(tout); - ); - } - }; - - relation_mutator_fn * smt_relation_plugin::mk_filter_identical_fn(const relation_base & r, - unsigned col_cnt, const unsigned * identical_cols) { - if (!check_kind(r)) { - return 0; - } - return alloc(filter_identical_fn, *this, r.get_signature(), col_cnt, identical_cols); - } - - - class smt_relation_plugin::negation_filter_fn : public convenient_relation_negation_filter_fn { - smt_relation_plugin& m_plugin; - expr_ref_vector m_conjs; - public: - negation_filter_fn(smt_relation_plugin& p, - const relation_base & tgt, const relation_base & neg_t, - unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * negated_cols) : - convenient_negation_filter_fn(tgt, neg_t, joined_col_cnt, t_cols, negated_cols), - m_plugin(p), - m_conjs(p.get_ast_manager()) { - ast_manager& m = p.get_ast_manager(); - unsigned sz = m_cols1.size(); - for (unsigned i = 0; i < sz; ++i) { - unsigned col1 = m_cols1[i]; - unsigned col2 = m_cols2[i]; - var* v1 = m.mk_var(col1, tgt.get_signature()[col1]); - var* v2 = m.mk_var(col2, neg_t.get_signature()[col2]); - m_conjs.push_back(m.mk_eq(v1, v2)); - } - } - - void operator()(relation_base & t, const relation_base & negated_obj) { - // TBD: fixme. - NOT_IMPLEMENTED_YET(); - ast_manager& m = m_plugin.get_ast_manager(); - expr_ref res(m), e2(m); - shift_vars sh(m); - sh(get(negated_obj).get_relation(), t.get_signature().size(), e2); - m_conjs.push_back(get(t).get_relation()); - m_conjs.push_back(m.mk_not(e2)); - res = m.mk_and(m_conjs.size(), m_conjs.c_ptr()); - m_conjs.pop_back(); - m_conjs.pop_back(); - // TBD: free variables in negation? - } - }; - - relation_intersection_filter_fn * smt_relation_plugin::mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols) { - if (!check_kind(t) || !check_kind(negated_obj)) { - return 0; - } - return alloc(negation_filter_fn, *this, t, negated_obj, joined_col_cnt, t_cols, negated_cols); - } - - - smt_relation& smt_relation_plugin::get(relation_base& r) { return dynamic_cast(r); } - - smt_relation const & smt_relation_plugin::get(relation_base const& r) { return dynamic_cast(r); } - - bool smt_relation_plugin::can_handle_signature(relation_signature const& sig) { - // TBD: refine according to theories handled by quantifier elimination - return get_manager().is_non_explanation(sig); - } - - // TBD: when relations are finite domain, they also support table iterators. - - symbol smt_relation_plugin::fresh_name() { - return symbol(m_counter++); - } - - smt_params& smt_relation_plugin::get_fparams() { - return const_cast(get_manager().get_context().get_fparams()); - } - - params_ref const& smt_relation_plugin::get_params() { - return get_manager().get_context().get_params(); - } - - bool smt_relation_plugin::is_finite_domain(sort *s) const { - ast_manager& m = get_ast_manager(); - if (m.is_bool(s)) { - return true; - } - bv_util bv(m); - if (bv.is_bv_sort(s)) { - return true; - } - datatype_util dt(m); - if (dt.is_datatype(s) && !dt.is_recursive(s)) { - ptr_vector const& constrs = *dt.get_datatype_constructors(s); - for (unsigned i = 0; i < constrs.size(); ++i) { - func_decl* f = constrs[i]; - for (unsigned j = 0; j < f->get_arity(); ++j) { - if (!is_finite_domain(f->get_domain(j))) { - return false; - } - } - } - return true; - } - return false; - } -}; - diff --git a/src/muz_qe/dl_smt_relation.h b/src/muz_qe/dl_smt_relation.h deleted file mode 100644 index a1bab918f..000000000 --- a/src/muz_qe/dl_smt_relation.h +++ /dev/null @@ -1,141 +0,0 @@ -/*++ -Copyright (c) 2010 Microsoft Corporation - -Module Name: - - dl_smt_relation.h - -Abstract: - - Relation signature represented by signatures that have quantifier elimination. - -Author: - - Nikolaj Bjorner (nbjorner) 2010-10-10 - -Revision History: - ---*/ -#ifndef _DL_SMT_RELATION_H_ -#define _DL_SMT_RELATION_H_ - -#include "dl_base.h" -#include "smt_params.h" -#include "params.h" - -namespace datalog { - - class smt_relation; - - class smt_relation_plugin : public relation_plugin { - - unsigned m_counter; - - friend class smt_relation; - class join_fn; - class project_fn; - class rename_fn; - class union_fn; - class filter_identical_fn; - class filter_interpreted_fn; - class negation_filter_fn; - - public: - smt_relation_plugin(relation_manager & m); - - virtual bool can_handle_signature(const relation_signature & s); - - static symbol get_name() { return symbol("smt_relation"); } - - virtual relation_base * mk_empty(const relation_signature & s); - - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); - - symbol fresh_name(); - - smt_params& get_fparams(); - - params_ref const& get_params(); - - bool is_finite_domain(sort* s) const; - - private: - static smt_relation& get(relation_base& r); - - static smt_relation const & get(relation_base const& r); - }; - - class smt_relation : public relation_base { - friend class smt_relation_plugin; - friend class smt_relation_plugin::join_fn; - friend class smt_relation_plugin::project_fn; - friend class smt_relation_plugin::rename_fn; - friend class smt_relation_plugin::union_fn; - friend class smt_relation_plugin::filter_identical_fn; - friend class smt_relation_plugin::filter_interpreted_fn; - friend class smt_relation_plugin::negation_filter_fn; - - expr_ref m_rel; // relation. - expr_ref_vector m_bound_vars; - - unsigned size() const { return get_signature().size(); } - - ast_manager& get_manager() const { return get_plugin().get_ast_manager(); } - - smt_relation(smt_relation_plugin & p, const relation_signature & s, expr* r); - - virtual ~smt_relation(); - - void instantiate(expr* e, expr_ref& result) const; - - void mk_abstract(expr* e, expr_ref& result) const; - - bool contains(expr* facts); - - bool is_finite_domain() const; - - bool is_well_formed() const; - - void display_finite(std::ostream & out) const; - - void simplify(expr_ref& e) const; - - public: - - virtual bool empty() const; - - virtual void add_fact(const relation_fact & f); - - virtual bool contains_fact(const relation_fact & f) const; - virtual smt_relation * clone() const; - virtual smt_relation * complement(func_decl*) const; - virtual void display(std::ostream & out) const; - virtual void to_formula(expr_ref& fml) const { fml = get_relation(); simplify(fml); } - - expr* get_relation() const; - void set_relation(expr* r); - void add_relation(expr* s); // add s to relation. - void filter_relation(expr* s); // restrict relation with s - smt_relation_plugin& get_plugin() const; - - }; -}; - -#endif diff --git a/src/muz_qe/dl_util.h b/src/muz_qe/dl_util.h index 12ed004ef..d9e437ccc 100644 --- a/src/muz_qe/dl_util.h +++ b/src/muz_qe/dl_util.h @@ -26,6 +26,7 @@ Revision History: #include"horn_subsume_model_converter.h" #include"replace_proof_converter.h" #include"substitution.h" +#include"fixedpoint_params.hpp" namespace datalog { diff --git a/src/muz_qe/fixedpoint_params.pyg b/src/muz_qe/fixedpoint_params.pyg new file mode 100644 index 000000000..aa78dad3d --- /dev/null +++ b/src/muz_qe/fixedpoint_params.pyg @@ -0,0 +1,62 @@ +def_module_params('fixedpoint', + description='fixedpoint parameters', + export=True, + params=(('timeout', UINT, UINT_MAX, 'set timeout'), + ('engine', SYMBOL, 'auto-config', 'Select: auto-config, datalog, pdr, bmc'), + ('default_table', SYMBOL, 'sparse', 'default table implementation: sparse, hashtable, bitvector, interval'), + ('default_relation', SYMBOL, 'pentagon', 'default relation implementation: external_relation, pentagon'), + ('generate_explanations', BOOL, False, '(DATALOG) produce explanations for produced facts when using the datalog engine'), + ('use_map_names', BOOL, True, "(DATALOG) use names from map files when displaying tuples"), + ('bit_blast', BOOL, False, '(PDR) bit-blast bit-vectors'), + ('explanations_on_relation_level', BOOL, False, '(DATALOG) if true, explanations are generated as history of each relation, rather than per fact (generate_explanations must be set to true for this option to have any effect)'), + ('magic_sets_for_queries', BOOL, False, "(DATALOG) magic set transformation will be used for queries"), + ('unbound_compressor', BOOL, True, "auxiliary relations will be introduced to avoid unbound variables in rule heads"), + ('similarity_compressor', BOOL, True, "(DATALOG) rules that differ only in values of constants will be merged into a single rule"), + ('similarity_compressor_threshold', UINT, 11, "(DATALOG) if similarity_compressor is on, this value determines how many similar rules there must be in order for them to be merged"), + ('all_or_nothing_deltas', BOOL, False, "(DATALOG) compile rules so that it is enough for the delta relation in union and widening operations to determine only whether the updated relation was modified or not"), + ('compile_with_widening', BOOL, False, "(DATALOG) widening will be used to compile recursive rules"), + ('eager_emptiness_checking', BOOL, True, "(DATALOG) emptiness of affected relations will be checked after each instruction, so that we may ommit unnecessary instructions"), + ('default_table_checked', BOOL, False, "if true, the detault table will be default_table inside a wrapper that checks that its results are the same as of default_table_checker table"), + ('default_table_checker', SYMBOL, 'null', "see default_table_checked"), + + + ('initial_restart_timeout', UINT, 0, "length of saturation run before the first restart (in ms), zero means no restarts"), + ('output_profile', BOOL, False, "determines whether profile informations should be output when outputting Datalog rules or instructions"), + ('inline_linear', BOOL, True, "try linear inlining method"), + ('inline_eager', BOOL, True, "try eager inlining of rules"), + ('inline_linear_branch', BOOL, False, "try linear inlining method with potential expansion"), + ('fix_unbound_vars', BOOL, False, "fix unbound variables in tail"), + ('output_tuples', BOOL, True, "determines whether tuples for output predicates should be output"), + ('print_with_fixedpoint_extensions', BOOL, True, "use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, when printing rules"), + ('print_low_level_smt2', BOOL, False, "use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"), + ('print_with_variable_declarations', BOOL, True, "use variable declarations when displaying rules (instead of attempting to use original names)"), + ('bfs_model_search', BOOL, True, "PDR: (default true) use BFS strategy for expanding model search"), + ('use_farkas', BOOL, True, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"), + ('generate_proof_trace', BOOL, False, "PDR: (default false) trace for 'sat' answer as proof object"), + ('flexible_trace', BOOL, False, "PDR: (default false) allow PDR generate long counter-examples " + "by extending candidate trace within search area"), + ('unfold_rules', UINT, 0, "PDR: (default 0) unfold rules statically using iterative squarring"), + ('use_model_generalizer', BOOL, False, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"), + ('validate_result', BOOL, False, "PDR (default false) validate result (by proof checking or model checking)"), + ('simplify_formulas_pre', BOOL, False, "PDR: (default false) simplify derived formulas before inductive propagation"), + ('simplify_formulas_post', BOOL, False, "PDR: (default false) simplify derived formulas after inductive propagation"), + ('slice', BOOL, True, "PDR: (default true) simplify clause set using slicing"), + ('coalesce_rules', BOOL, False, "BMC: (default false) coalesce rules"), + ('use_multicore_generalizer', BOOL, False, "PDR: (default false) extract multiple cores for blocking states"), + ('use_inductive_generalizer', BOOL, True, "PDR: (default true) generalize lemmas using induction strengthening"), + ('cache_mode', UINT, 0, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search"), + ('inductive_reachability_check', BOOL, False, "PDR: (default false) assume negation of the cube on the previous level when " + "checking for reachability (not only during cube weakening)"), + ('max_num_contexts', UINT, 500, "PDR: (default 500) maximal number of contexts to create"), + ('try_minimize_core', BOOL, False, "PDR: (default false) try to reduce core size (before inductive minimization)"), + ('profile_timeout_milliseconds', UINT, 0, "instructions and rules that took less than the threshold will not be printed when printed the instruction/rule list"), + ('dbg_fpr_nonempty_relation_signature', BOOL, False, + "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " + "by putting in half of the table columns, if it would have been empty otherwise"), + ('print_answer', BOOL, False, 'print answer instance(s) to query'), + ('print_certificate', BOOL, False, 'print certificate for reacahbility or non-reachability'), + ('print_statistics', BOOL, False, 'print statistics'), + )) + + + diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 1dec1b4fe..98b6130b8 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -168,8 +168,8 @@ class horn_tactic : public tactic { bool produce_proofs = g->proofs_enabled(); if (produce_proofs) { - if (!m_ctx.get_params().get_bool("generate_proof_trace", true)) { - params_ref params = m_ctx.get_params(); + if (!m_ctx.get_params().generate_proof_trace()) { + params_ref params = m_ctx.get_params().p; params.set_bool("generate_proof_trace", true); updt_params(params); } diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 76b609720..974c9251e 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1123,17 +1123,17 @@ namespace pdr { context::context( smt_params& fparams, - params_ref const& params, + fixedpoint_params const& params, ast_manager& m ) : m_fparams(fparams), m_params(params), m(m), m_context(0), - m_pm(m_fparams, m_params, m), + m_pm(m_fparams, params, m), m_query_pred(m), m_query(0), - m_search(m_params.get_bool("bfs_model_search", true)), + m_search(m_params.bfs_model_search()), m_last_result(l_undef), m_inductive_lvl(0), m_cancel(false) @@ -1358,7 +1358,7 @@ namespace pdr { }; void context::validate() { - if (!m_params.get_bool("validate_result", false)) { + if (!m_params.validate_result()) { return; } switch(m_last_result) { @@ -1449,34 +1449,26 @@ namespace pdr { void context::init_core_generalizers(datalog::rule_set& rules) { reset_core_generalizers(); classifier_proc classify(m, rules); - bool use_mc = m_params.get_bool("use_multicore_generalizer", false); + bool use_mc = m_params.use_multicore_generalizer(); if (use_mc) { m_core_generalizers.push_back(alloc(core_multi_generalizer, *this, 0)); } - if (m_params.get_bool("use_farkas", true) && !classify.is_bool()) { - if (m_params.get_bool("inline_proof_mode", true)) { - m.toggle_proof_mode(PGM_FINE); - m_fparams.m_proof_mode = PGM_FINE; - m_fparams.m_arith_bound_prop = BP_NONE; - m_fparams.m_arith_auto_config_simplex = true; - m_fparams.m_arith_propagate_eqs = false; - m_fparams.m_arith_eager_eq_axioms = false; - if (classify.is_dl()) { - m_fparams.m_arith_mode = AS_DIFF_LOGIC; - m_fparams.m_arith_expand_eqs = true; - } - } - else { - m_core_generalizers.push_back(alloc(core_farkas_generalizer, *this, m, m_fparams)); + if (m_params.use_farkas() && !classify.is_bool()) { + m.toggle_proof_mode(PGM_FINE); + m_fparams.m_proof_mode = PGM_FINE; + m_fparams.m_arith_bound_prop = BP_NONE; + m_fparams.m_arith_auto_config_simplex = true; + m_fparams.m_arith_propagate_eqs = false; + m_fparams.m_arith_eager_eq_axioms = false; + if (classify.is_dl()) { + m_fparams.m_arith_mode = AS_DIFF_LOGIC; + m_fparams.m_arith_expand_eqs = true; } } - if (!use_mc && m_params.get_bool("use_inductive_generalizer", true)) { + if (!use_mc && m_params.use_inductive_generalizer()) { m_core_generalizers.push_back(alloc(core_bool_inductive_generalizer, *this, 0)); } - if (m_params.get_bool("use_interpolants", false)) { - m_core_generalizers.push_back(alloc(core_interpolant_generalizer, *this)); - } - if (m_params.get_bool("inductive_reachability_check", false)) { + if (m_params.inductive_reachability_check()) { m_core_generalizers.push_back(alloc(core_induction_generalizer, *this)); } } @@ -1588,7 +1580,7 @@ namespace pdr { \brief Retrieve satisfying assignment with explanation. */ expr_ref context::mk_sat_answer() const { - if (m_params.get_bool("generate_proof_trace", false)) { + if (m_params.generate_proof_trace()) { proof_ref pr = get_proof(); return expr_ref(pr.get(), m); } @@ -1709,7 +1701,7 @@ namespace pdr { n.pt().add_property(ncore, uses_level?n.level():infty_level); } CASSERT("pdr",n.level() == 0 || check_invariant(n.level()-1)); - m_search.backtrack_level(!found_invariant && m_params.get_bool("flexible_trace", false), n); + m_search.backtrack_level(!found_invariant && m_params.flexible_trace(), n); break; } case l_undef: { @@ -1731,7 +1723,7 @@ namespace pdr { } void context::propagate(unsigned max_prop_lvl) { - if (m_params.get_bool("simplify_formulas_pre", false)) { + if (m_params.simplify_formulas_pre()) { simplify_formulas(); } for (unsigned lvl = 0; lvl <= max_prop_lvl; lvl++) { @@ -1750,7 +1742,7 @@ namespace pdr { throw inductive_exception(); } } - if (m_params.get_bool("simplify_formulas_post", false)) { + if (m_params.simplify_formulas_post()) { simplify_formulas(); } } @@ -1798,7 +1790,7 @@ namespace pdr { */ void context::create_children(model_node& n) { SASSERT(n.level() > 0); - bool use_model_generalizer = m_params.get_bool("use_model_generalizer", false); + bool use_model_generalizer = m_params.use_model_generalizer(); datalog::scoped_no_proof _sc(m); pred_transformer& pt = n.pt(); diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index f3dd6807e..7491327dd 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -30,6 +30,7 @@ Revision History: #include "pdr_prop_solver.h" #include "pdr_reachable_cache.h" + namespace datalog { class rule_set; class context; @@ -291,7 +292,7 @@ namespace pdr { }; smt_params& m_fparams; - params_ref const& m_params; + fixedpoint_params const& m_params; ast_manager& m; datalog::context* m_context; manager m_pm; @@ -349,13 +350,13 @@ namespace pdr { */ context( smt_params& fparams, - params_ref const& params, + fixedpoint_params const& params, ast_manager& m); ~context(); smt_params& get_fparams() const { return m_fparams; } - params_ref const& get_params() const { return m_params; } + fixedpoint_params const& get_params() const { return m_params; } ast_manager& get_manager() const { return m; } manager& get_pdr_manager() { return m_pm; } decl2rel const& get_pred_transformers() const { return m_rels; } diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index cee6cf747..663f634c4 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -108,13 +108,13 @@ lbool dl_interface::query(expr * query) { model_converter_ref mc = datalog::mk_skip_model_converter(); proof_converter_ref pc; - if (m_ctx.get_params().get_bool("generate_proof_trace", false)) { + if (m_ctx.get_params().generate_proof_trace()) { pc = datalog::mk_skip_proof_converter(); } m_ctx.set_output_predicate(query_pred); m_ctx.apply_default_transformation(mc, pc); - if (m_ctx.get_params().get_bool("slice", true)) { + if (m_ctx.get_params().slice()) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); @@ -133,10 +133,10 @@ lbool dl_interface::query(expr * query) { } } - if (m_ctx.get_params().get_uint("unfold_rules",0) > 0) { - unsigned num_unfolds = m_ctx.get_params().get_uint("unfold_rules", 0); + if (m_ctx.get_params().unfold_rules() > 0) { + unsigned num_unfolds = m_ctx.get_params().unfold_rules(); datalog::rule_transformer transformer1(m_ctx), transformer2(m_ctx); - if (m_ctx.get_params().get_uint("coalesce_rules", false)) { + if (m_ctx.get_params().coalesce_rules()) { transformer1.register_plugin(alloc(datalog::mk_coalesce, m_ctx)); m_ctx.transform_rules(transformer1, mc, pc); } @@ -198,7 +198,7 @@ expr_ref dl_interface::get_cover_delta(int level, func_decl* pred_orig) { } void dl_interface::add_cover(int level, func_decl* pred, expr* property) { - if (m_ctx.get_params().get_bool("slice", true)) { + if (m_ctx.get_params().slice()) { throw default_exception("Covers are incompatible with slicing. Disable slicing before using covers"); } m_context->add_cover(level, pred, property); @@ -246,32 +246,3 @@ model_ref dl_interface::get_model() { proof_ref dl_interface::get_proof() { return m_context->get_proof(); } - -void dl_interface::collect_params(param_descrs& p) { - p.insert("bfs_model_search", CPK_BOOL, "PDR: (default true) use BFS strategy for expanding model search"); - p.insert("use_farkas", CPK_BOOL, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"); - p.insert("generate_proof_trace", CPK_BOOL, "PDR: (default false) trace for 'sat' answer as proof object"); - p.insert("inline_proofs", CPK_BOOL, "PDR: (default true) run PDR with proof mode turned on and extract " - "Farkas coefficients directly (instead of creating a separate proof object when extracting coefficients)"); - p.insert("flexible_trace", CPK_BOOL, "PDR: (default false) allow PDR generate long counter-examples " - "by extending candidate trace within search area"); - p.insert("unfold_rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); - p.insert("use_model_generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); - p.insert("validate_result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); -#ifndef _EXTERNAL_RELEASE - p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states"); - p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening"); - p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation"); - p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants"); - p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search"); - p.insert("inductive_reachability_check", CPK_BOOL, - "PDR: (default false) assume negation of the cube on the previous level when " - "checking for reachability (not only during cube weakening)"); - p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create"); - p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)"); -#endif - p.insert("simplify_formulas_pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); - p.insert("simplify_formulas_post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); - p.insert("slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); - p.insert("coalesce_rules", CPK_BOOL, "BMC: (default false) coalesce rules"); -} diff --git a/src/muz_qe/pdr_dl_interface.h b/src/muz_qe/pdr_dl_interface.h index 61f56282e..c4844f892 100644 --- a/src/muz_qe/pdr_dl_interface.h +++ b/src/muz_qe/pdr_dl_interface.h @@ -66,8 +66,6 @@ namespace pdr { expr_ref get_cover_delta(int level, func_decl* pred); void add_cover(int level, func_decl* pred, expr* property); - - static void collect_params(param_descrs& p); void updt_params(); diff --git a/src/muz_qe/pdr_farkas_learner.cpp b/src/muz_qe/pdr_farkas_learner.cpp index 46de8f212..b3d0b4fd0 100644 --- a/src/muz_qe/pdr_farkas_learner.cpp +++ b/src/muz_qe/pdr_farkas_learner.cpp @@ -29,7 +29,6 @@ Revision History: #include "pdr_util.h" #include "pdr_farkas_learner.h" #include "th_rewriter.h" -#include "pdr_interpolant_provider.h" #include "ast_ll_pp.h" #include "arith_bounds_tactic.h" #include "proof_utils.h" diff --git a/src/muz_qe/pdr_generalizers.cpp b/src/muz_qe/pdr_generalizers.cpp index 31bb132c4..5a6ab4240 100644 --- a/src/muz_qe/pdr_generalizers.cpp +++ b/src/muz_qe/pdr_generalizers.cpp @@ -20,7 +20,6 @@ Revision History: #include "pdr_context.h" #include "pdr_farkas_learner.h" -#include "pdr_interpolant_provider.h" #include "pdr_generalizers.h" #include "expr_abstract.h" #include "var_subst.h" @@ -143,77 +142,6 @@ namespace pdr { } - /** - < F, phi, i + 1 > - / \ - < G, psi, i > < H, theta, i > - core - - Given: - 1. psi => core - 2. Gi => not core - 3. phi & psi & theta => F_{i+1} - - Then, by weakening 2: - Gi => (F_{i+1} => not (phi & core & theta)) - - Find interpolant I, such that - - Gi => I, I => (F_{i+1} => not (phi & core' & theta')) - - where core => core', theta => theta' - - This implementation checks if - - Gi => (F_{i+1} => not (phi & theta)) - - */ - void core_interpolant_generalizer::operator()(model_node& n, expr_ref_vector& core, bool& uses_level) { - if (!n.parent()) { - return; - } - manager& pm = n.pt().get_pdr_manager(); - ast_manager& m = n.pt().get_manager(); - model_node& p = *n.parent(); - - // find index of node into parent. - unsigned index = 0; - for (; index < p.children().size() && (&n != p.children()[index]); ++index); - SASSERT(index < p.children().size()); - - expr_ref G(m), F(m), r(m), B(m), I(m), cube(m); - expr_ref_vector fmls(m); - - F = p.pt().get_formulas(p.level(), true); - G = n.pt().get_formulas(n.level(), true); - pm.formula_n2o(index, false, G); - - // get formulas from siblings. - for (unsigned i = 0; i < p.children().size(); ++i) { - if (i != index) { - pm.formula_n2o(p.children()[i]->state(), r, i, true); - fmls.push_back(r); - } - } - fmls.push_back(F); - fmls.push_back(p.state()); - B = pm.mk_and(fmls); - - // when G & B is unsat, find I such that G => I, I => not B - lbool res = pm.get_interpolator().get_interpolant(G, B, I); - - TRACE("pdr", - tout << "Interpolating:\n" << mk_pp(G, m) << "\n" << mk_pp(B, m) << "\n"; - if (res == l_true) tout << mk_pp(I, m) << "\n"; else tout << "failed\n";); - - if(res == l_true) { - pm.formula_o2n(I, cube, index, true); - TRACE("pdr", tout << "After renaming: " << mk_pp(cube, m) << "\n";); - core.reset(); - datalog::flatten_and(cube, core); - uses_level = true; - } - } // @@ -463,7 +391,7 @@ namespace pdr { imp imp(m_ctx); ast_manager& m = core.get_manager(); expr_ref goal = imp.mk_induction_goal(p->pt(), p->level(), depth); - smt::kernel ctx(m, m_ctx.get_fparams(), m_ctx.get_params()); + smt::kernel ctx(m, m_ctx.get_fparams(), m_ctx.get_params().p); ctx.assert_expr(goal); lbool r = ctx.check(); TRACE("pdr", tout << r << "\n"; diff --git a/src/muz_qe/pdr_generalizers.h b/src/muz_qe/pdr_generalizers.h index 543e6d985..5f3393682 100644 --- a/src/muz_qe/pdr_generalizers.h +++ b/src/muz_qe/pdr_generalizers.h @@ -51,13 +51,6 @@ namespace pdr { virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores); }; - class core_interpolant_generalizer : public core_generalizer { - public: - core_interpolant_generalizer(context& ctx): core_generalizer(ctx) {} - virtual ~core_interpolant_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); - }; - class core_induction_generalizer : public core_generalizer { class imp; public: diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp deleted file mode 100644 index 7c9afd74a..000000000 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - pdr_interpolant_provider.cpp - -Abstract: - - Interface for obtaining interpolants. - - This file is Windows specific. - -Author: - - Krystof Hoder (t-khoder) 2011-10-19. - -Revision History: - ---*/ - -//disables the warning on deprecation of fgets function -- didn't really find by what it should be replaced -#ifdef _WINDOWS -#pragma warning(disable: 4995) -#endif - -#include -#include "ast_smt_pp.h" -#include "cmd_context.h" -#include "for_each_expr.h" -#include "obj_hashtable.h" -#include "smt2parser.h" -#include "rewriter.h" -#include "rewriter_def.h" -#include "pdr_util.h" -#include "pdr_interpolant_provider.h" -#include "expr_context_simplifier.h" - -#ifdef _WINDOWS -#include -#include -#include -#include - -/** -Requirements for the use of this object: - -The directory where the expcutable is must contain also executable -PdrInterpolator.exe. - -This executable takes one argument with a file name that contains -two SMTLIB problem instances, each terminated by string "\n##next##\n". - -The output of the executable is given to the standard output and -is also terminated by the "\n##next##\n" string. - -If formulas in the two input problems are unsatisfiable, they problem -is printed at the output in the format -(assert FORM) - -If the formulas are satisfiable, "0" is output and if the result cannot -be determined, the output is "?". (Both are still followed by "\n##next##\n"). - -*/ -class interpolant_provider_impl : public interpolant_provider -{ - static std::string s_terminator_str; - static std::string s_satisfiable_str; - static std::string s_unknown_str; - - std::string m_exec_name; - params_ref const & m_params; - - /** - If non-empty, contains name of a temporary file that is used for passing the - interpolation problem to the interpolating engine. - */ - std::string m_tmp_file_name; - - simplifier m_simpl; - - PROCESS_INFORMATION m_pi; - STARTUPINFOA m_si; - HANDLE m_in_rd; - HANDLE m_out_rd; - HANDLE m_in_wr; - HANDLE m_out_wr; - - - class used_symbol_inserter { - typedef obj_hashtable func_decl_set; - typedef obj_hashtable sort_set; - - ast_manager& m; - cmd_context& m_cctx; - - func_decl_set m_funcs; - sort_set m_sorts; - - void handle_sort(sort * s) { - if(s->get_family_id()!=null_family_id || m_sorts.contains(s)) { - return; - } - m_sorts.insert(s); - NOT_IMPLEMENTED_YET(); - //we should insert it into the context somehow, but now not sure how and - //we don't deal with user defined sorts (yet)... - //m_cctx.insert(s); - } - void handle_func_decl(func_decl * fn) { - if(fn->get_family_id()!=null_family_id || m_funcs.contains(fn)) { - return; - } - m_funcs.insert(fn); - m_cctx.insert(fn); - } - - public: - - used_symbol_inserter(cmd_context& cctx) : m(cctx.m()), m_cctx(cctx) {} - - void operator()(var * n) { - handle_sort(n->get_sort()); - } - void operator()(app * n) { - if (is_uninterp(n)) { - handle_func_decl(n->get_decl()); - } - handle_sort(n->get_decl()->get_range()); - } - void operator()(quantifier * n) { - unsigned sz = n->get_num_decls(); - for(unsigned i=0; iget_decl_sort(i)); - } - } - }; - - class form_fixer_cfg : public default_rewriter_cfg - { - ast_manager& m; - public: - form_fixer_cfg(ast_manager& m) : m(m) {} - - br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, - proof_ref & result_pr) - { - if(m.is_or(f) && num==0) { - result = m.mk_false(); - return BR_DONE; - } - return BR_FAILED; - } - }; - - - std::string get_tmp_file_name(); - - std::string execute_interpolator(std::string input); - - void simplify_expr(expr* f, expr_ref& result); - void output_interpolant_problem(std::ostream& out, expr * f1, expr * f2); - -public: - - interpolant_provider_impl(ast_manager& m, params_ref const& params, std::string exec_name) - : interpolant_provider(m), - m_params(params), - m_exec_name(exec_name), - m_simpl(m) { - memset(&m_si, 0, sizeof(m_si)); - memset(&m_pi, 0, sizeof(m_pi)); - } - - ~interpolant_provider_impl(); - - - /** - If (f1 /\ f2) is unsatisfiable, return true and into res assign a formula - I such that f1 --> I, I --> ~f2, and the language if I is in the intersection - of languages of f1 and f2. - - If (f1 /\ f2) is satisfiable, return false. - */ - virtual lbool get_interpolant(expr * f1, expr * f2, expr_ref& res); -}; - -std::string interpolant_provider_impl::s_terminator_str = ";##next##"; -std::string interpolant_provider_impl::s_satisfiable_str = ";#sat#"; -std::string interpolant_provider_impl::s_unknown_str = ";#unknown#"; - -interpolant_provider_impl::~interpolant_provider_impl() { - if(m_tmp_file_name.size()!=0) { - DeleteFileA(m_tmp_file_name.c_str()); - } - CloseHandle(m_pi.hProcess); - CloseHandle(m_pi.hThread); - CloseHandle(m_in_rd); - CloseHandle(m_in_wr); - CloseHandle(m_out_rd); - CloseHandle(m_out_wr); -} - -void interpolant_provider_impl::simplify_expr(expr* f, expr_ref& result) { - expr_ref rwr_f(m); - form_fixer_cfg fixer(m); - rewriter_tpl rwr(m, false, fixer); - rwr(f, rwr_f); - proof_ref pr(m); - m_simpl(rwr_f, result, pr); -} - - -std::string interpolant_provider_impl::get_tmp_file_name() { - //return "c:\\test.txt"; - if(m_tmp_file_name.length()!=0) { - return m_tmp_file_name; - } - char path[MAX_PATH]; - if(GetTempPathA(256, path)==0) { - throw default_exception("cannot get temp directory"); - } - - std::stringstream name_prefix_builder; - - name_prefix_builder<<"pdr"<(input.size()), &wr, 0)) { - throw default_exception("Cold not write to pipe"); - } - - std::string result; - char line[256]; - while (true) { - memset(line, 0, sizeof(line)); - if (!ReadFile(m_out_rd, line, sizeof(line)-1, &rd, 0)) { - throw default_exception("Cold not write to pipe"); - } - result += line; - if (strstr(result.c_str(), s_terminator_str.c_str())) { - return result; - } - } -} - -lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& res) { - std::ostringstream prb; - output_interpolant_problem(prb, f1, f2); - std::string res_text = execute_interpolator(prb.str()); - if(strstr(res_text.c_str(), s_satisfiable_str.c_str())) { - return l_false; - } - if(strstr(res_text.c_str(), s_unknown_str.c_str())) { - return l_undef; - } - - cmd_context cctx(false, &m); - for_each_expr(used_symbol_inserter(cctx), f1); - - parse_smt2_commands(cctx, std::istringstream(res_text), false); - - ptr_vector::const_iterator ait = cctx.begin_assertions(); - ptr_vector::const_iterator aend = cctx.end_assertions(); - if(ait+1!=aend) { - throw default_exception("invalid interpolator output"); - } - res = *ait; - if (m_params.get_bool("dump_interpolants", false)) { - interpolant_provider::output_interpolant(m, f1, f2, res); - } - return l_true; -} - -interpolant_provider * interpolant_provider::mk(ast_manager& m, params_ref const& p) -{ - char self_name[MAX_PATH]; - GetModuleFileNameA(NULL, self_name, MAX_PATH); - char * last_backslash = strrchr(self_name,'\\'); - if(last_backslash==NULL) { - throw default_exception("GetModuleFileNameA did not return full path to the executable"); - } - //we cut the string at the last backslash - *last_backslash = 0; - - std::string exec_name = self_name + std::string(".\\PdrInterpolator.exe"); - - return alloc(interpolant_provider_impl, m, p, exec_name); -} - -#else - -interpolant_provider * -interpolant_provider::mk(ast_manager& m, params_ref const& p) { - // interpolations are windows specific and private. - return 0; -} - - -#endif - - -void interpolant_provider::output_interpolant(ast_manager& m, expr* A, expr* B, expr* I) { - static unsigned file_num = 0; - - std::ostringstream filename; - filename << "interpolation_" << file_num++ << ".smt"; - std::ofstream out(filename.str().c_str()); - - ast_smt_pp pp(m); - pp.add_assumption(A); - pp.display(out, B); - std::ostringstream strm; - strm << ";" << mk_pp(I, m) << "\n"; - - buffer buff; - std::string s = strm.str(); - char const* i_str = s.c_str(); - while (*i_str) { - buff.push_back(*i_str); - if (*i_str == '\n') { - buff.push_back(';'); - } - ++i_str; - } - buff.push_back(0); - out << buff.c_ptr(); - out << "##next##\n"; - out.close(); -} diff --git a/src/muz_qe/pdr_interpolant_provider.h b/src/muz_qe/pdr_interpolant_provider.h deleted file mode 100644 index 84197a265..000000000 --- a/src/muz_qe/pdr_interpolant_provider.h +++ /dev/null @@ -1,54 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - interpolant_provider.h - -Abstract: - - Interface for obtaining interpolants. - -Author: - - Krystof Hoder (t-khoder) 2011-10-19. - -Revision History: - ---*/ - -#include "ast.h" -#include "lbool.h" -#include "model.h" -#include "params.h" - -#ifndef _PDR_INTERPOLANT_PROVIDER_H_ -#define _PDR_INTERPOLANT_PROVIDER_H_ - -class interpolant_provider -{ -protected: - ast_manager & m; - - interpolant_provider(ast_manager& m) : m(m) {} - -public: - - virtual ~interpolant_provider() {} - - /** - If (f1 /\ f2) is unsatisfiable, return true and into res assign a formula - I such that f1 --> I, I --> ~f2, and the language if I is in the intersection - of languages of f1 and f2. - - If (f1 /\ f2) is satisfiable, return false. - */ - virtual lbool get_interpolant(expr * f1, expr * f2, expr_ref& res) = 0; - - static interpolant_provider * mk(ast_manager& m, params_ref const& p); - - static void output_interpolant(ast_manager& m, expr* A, expr* B, expr* I); -}; - - -#endif diff --git a/src/muz_qe/pdr_manager.cpp b/src/muz_qe/pdr_manager.cpp index 598d8c850..04facc776 100644 --- a/src/muz_qe/pdr_manager.cpp +++ b/src/muz_qe/pdr_manager.cpp @@ -166,7 +166,7 @@ namespace pdr { return res; } - manager::manager(smt_params& fparams, params_ref const& params, ast_manager& manager) : + manager::manager(smt_params& fparams, fixedpoint_params const& params, ast_manager& manager) : m(manager), m_fparams(fparams), m_params(params), @@ -311,17 +311,8 @@ namespace pdr { else { return false; } - } - - - interpolant_provider& manager::get_interpolator() { - if(!m_interpolator) { - m_interpolator = interpolant_provider::mk(m, get_params()); - } - return *m_interpolator; - } - - + } + bool manager::implication_surely_holds(expr * lhs, expr * rhs, expr * bg) { smt::kernel sctx(m, get_fparams()); if(bg) { diff --git a/src/muz_qe/pdr_manager.h b/src/muz_qe/pdr_manager.h index 58b4ffc53..cb2c9b253 100644 --- a/src/muz_qe/pdr_manager.h +++ b/src/muz_qe/pdr_manager.h @@ -32,7 +32,6 @@ Revision History: #include "pdr_util.h" #include "pdr_sym_mux.h" #include "pdr_farkas_learner.h" -#include "pdr_interpolant_provider.h" #include "pdr_smt_context_manager.h" #include "dl_rule.h" @@ -79,7 +78,7 @@ namespace pdr { { ast_manager& m; smt_params& m_fparams; - params_ref const& m_params; + fixedpoint_params const& m_params; mutable bool_rewriter m_brwr; @@ -91,16 +90,6 @@ namespace pdr { /** whenever we need an unique number, we get this one and increase */ unsigned m_next_unique_num; - /** - It would make more sense to have interpolantor inside the prop_solver, - however we have one prop_solver instance in each relation. - Each instance of interpolant_provider creates a temporary file and - interpolant_provider can be shared, so it makes more sence to have - it in pdr_manager which is created only once. - */ - - scoped_ptr m_interpolator; - static vector get_state_suffixes(); @@ -110,12 +99,12 @@ namespace pdr { void add_new_state(func_decl * s); public: - manager(smt_params& fparams, params_ref const& params, + manager(smt_params& fparams, fixedpoint_params const& params, ast_manager & manager); ast_manager& get_manager() const { return m; } smt_params& get_fparams() const { return m_fparams; } - params_ref const& get_params() const { return m_params; } + fixedpoint_params const& get_params() const { return m_params; } bool_rewriter& get_brwr() const { return m_brwr; } expr_ref mk_and(unsigned sz, expr* const* exprs); @@ -298,7 +287,6 @@ namespace pdr { expr* get_background() const { return m_background; } - interpolant_provider& get_interpolator(); /** Return true if we can show that lhs => rhs. The function can have false negatives diff --git a/src/muz_qe/pdr_prop_solver.cpp b/src/muz_qe/pdr_prop_solver.cpp index 5d0bd4e28..43d75b7bf 100644 --- a/src/muz_qe/pdr_prop_solver.cpp +++ b/src/muz_qe/pdr_prop_solver.cpp @@ -212,7 +212,7 @@ namespace pdr { m(pm.get_manager()), m_pm(pm), m_name(name), - m_try_minimize_core(pm.get_params().get_bool("try_minimize_core", false)), + m_try_minimize_core(pm.get_params().try_minimize_core()), m_ctx(pm.mk_fresh()), m_pos_level_atoms(m), m_neg_level_atoms(m), diff --git a/src/muz_qe/pdr_reachable_cache.cpp b/src/muz_qe/pdr_reachable_cache.cpp index f248f4d86..4f4f620de 100644 --- a/src/muz_qe/pdr_reachable_cache.cpp +++ b/src/muz_qe/pdr_reachable_cache.cpp @@ -21,13 +21,13 @@ Revision History: namespace pdr { - reachable_cache::reachable_cache(pdr::manager & pm, params_ref const& params) + reachable_cache::reachable_cache(pdr::manager & pm, fixedpoint_params const& params) : m(pm.get_manager()), m_pm(pm), m_ctx(0), m_ref_holder(m), m_disj_connector(m), - m_cache_mode((datalog::PDR_CACHE_MODE)params.get_uint("cache_mode",0)) { + m_cache_mode((datalog::PDR_CACHE_MODE)params.cache_mode()) { if (m_cache_mode == datalog::CONSTRAINT_CACHE) { m_ctx = pm.mk_fresh(); m_ctx->assert_expr(m_pm.get_background()); diff --git a/src/muz_qe/pdr_reachable_cache.h b/src/muz_qe/pdr_reachable_cache.h index d8096f15c..48caa22a5 100644 --- a/src/muz_qe/pdr_reachable_cache.h +++ b/src/muz_qe/pdr_reachable_cache.h @@ -17,14 +17,13 @@ Revision History: --*/ -#include "ast.h" -#include "params.h" -#include "ref_vector.h" -#include "pdr_manager.h" -#include "pdr_smt_context_manager.h" #ifndef _REACHABLE_CACHE_H_ #define _REACHABLE_CACHE_H_ +#include "ast.h" +#include "ref_vector.h" +#include "pdr_manager.h" +#include "pdr_smt_context_manager.h" namespace pdr { class reachable_cache { @@ -48,7 +47,7 @@ namespace pdr { void add_disjuncted_formula(expr * f); public: - reachable_cache(pdr::manager & pm, params_ref const& params); + reachable_cache(pdr::manager & pm, fixedpoint_params const& params); void add_init(app * f) { add_disjuncted_formula(f); } diff --git a/src/muz_qe/pdr_smt_context_manager.cpp b/src/muz_qe/pdr_smt_context_manager.cpp index 704967686..ca308954c 100644 --- a/src/muz_qe/pdr_smt_context_manager.cpp +++ b/src/muz_qe/pdr_smt_context_manager.cpp @@ -93,10 +93,10 @@ namespace pdr { return m_context.get_proof(); } - smt_context_manager::smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m): + smt_context_manager::smt_context_manager(smt_params& fp, fixedpoint_params const& p, ast_manager& m): m_fparams(fp), m(m), - m_max_num_contexts(p.get_uint("max_num_contexts", 500)), + m_max_num_contexts(p.max_num_contexts()), m_num_contexts(0), m_predicate_list(m) { } diff --git a/src/muz_qe/pdr_smt_context_manager.h b/src/muz_qe/pdr_smt_context_manager.h index 342100ed0..7d6eebfbd 100644 --- a/src/muz_qe/pdr_smt_context_manager.h +++ b/src/muz_qe/pdr_smt_context_manager.h @@ -23,6 +23,7 @@ Revision History: #include "smt_kernel.h" #include "sat_solver.h" #include "func_decl_dependencies.h" +#include "dl_util.h" namespace pdr { @@ -96,7 +97,7 @@ namespace pdr { app_ref_vector m_predicate_list; func_decl_set m_predicate_set; public: - smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m); + smt_context_manager(smt_params& fp, fixedpoint_params const& p, ast_manager& m); ~smt_context_manager(); smt_context* mk_fresh(); void collect_statistics(statistics& st) const; diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index c4aab9111..1d001c349 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -26,12 +26,12 @@ Revision History: #undef max #endif #include"smt_params.h" -#include"datalog_parser.h" #include"arith_decl_plugin.h" #include"dl_compiler.h" -#include"dl_context.h" #include"dl_mk_filter_rules.h" #include"dl_finite_product_relation.h" +#include"dl_context.h" +#include"datalog_parser.h" #include"datalog_frontend.h" #include"timeout.h" @@ -71,7 +71,7 @@ static void display_statistics( code.process_all_costs(); { - params_ref p(ctx.get_params()); + params_ref p; p.set_bool("output_profile", true); p.set_uint("profile_milliseconds_threshold", 100); ctx.updt_params(p); @@ -250,7 +250,7 @@ unsigned read_datalog(char const * file) { TRACE("dl_compiler", ctx.display(tout); rules_code.display(ctx, tout);); - if (ctx.get_params().get_bool("output_tuples", true)) { + if (ctx.get_params().output_tuples()) { ctx.display_output_facts(std::cout); } diff --git a/src/test/dl_smt_relation.cpp b/src/test/dl_smt_relation.cpp deleted file mode 100644 index bae1784b0..000000000 --- a/src/test/dl_smt_relation.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "dl_smt_relation.h" -#include "arith_decl_plugin.h" -#include "dl_context.h" -#include "z3.h" -#include "z3_private.h" -#include "reg_decl_plugins.h" - - -namespace datalog { - - void test_smt_relation_unit() { - ast_manager m; - reg_decl_plugins(m); - arith_util a(m); - sort* int_sort = a.mk_int(); - sort* real_sort = a.mk_real(); - smt_params params; - context ctx(m, params); - relation_manager & rm = ctx.get_rmanager(); - relation_signature sig1; - sig1.push_back(int_sort); - sig1.push_back(int_sort); - sig1.push_back(real_sort); - - smt_relation_plugin plugin(rm); - - scoped_rel r1 = plugin.mk_empty(sig1); - - // add_fact - relation_fact fact1(m); - fact1.push_back(a.mk_numeral(rational(1), true)); - fact1.push_back(a.mk_numeral(rational(2), true)); - fact1.push_back(a.mk_numeral(rational(3), false)); - - relation_fact fact2(m); - fact2.push_back(a.mk_numeral(rational(2), true)); - fact2.push_back(a.mk_numeral(rational(2), true)); - fact2.push_back(a.mk_numeral(rational(3), false)); - - r1->add_fact(fact1); - r1->display(std::cout << "r1: "); - - - // contains_fact - SASSERT(r1->contains_fact(fact1)); - SASSERT(!r1->contains_fact(fact2)); - - // empty - scoped_rel r2 = plugin.mk_empty(sig1); - SASSERT(!r1->empty()); - SASSERT(r2->empty()); - - // clone - scoped_rel r3 = r1->clone(); - - // complement? - r2->add_fact(fact2); - scoped_rel r4 = dynamic_cast(*r2).complement(0); - r4->display(std::cout << "complement r4: " ); - - // join - unsigned col_cnt = 2; - unsigned cols1[2] = {1, 2}; - unsigned cols2[2] = {0, 2}; - scoped_ptr joinfn = plugin.mk_join_fn(*r1, *r4, col_cnt, cols1, cols2); - scoped_rel r5 = (*joinfn)(*r1, *r4); - r5->display(std::cout<< "join r5: "); - - relation_fact fact3(m); - fact3.push_back(a.mk_numeral(rational(1), true)); - fact3.push_back(a.mk_numeral(rational(2), true)); - fact3.push_back(a.mk_numeral(rational(3), false)); - fact3.push_back(a.mk_numeral(rational(2), true)); - fact3.push_back(a.mk_numeral(rational(2), true)); - fact3.push_back(a.mk_numeral(rational(3), false)); - SASSERT(!r5->contains_fact(fact3)); - fact3[5] = a.mk_numeral(rational(4), false); - SASSERT(!r5->contains_fact(fact3)); - fact3[5] = a.mk_numeral(rational(3), false); - fact3[4] = a.mk_numeral(rational(3), true); - SASSERT(r5->contains_fact(fact3)); - - // project - unsigned removed_cols[2] = { 1, 4 }; - scoped_ptr projfn = plugin.mk_project_fn(*r5, col_cnt, removed_cols); - scoped_rel r6 = (*projfn)(*r5); - r6->display(std::cout<< "project r6: "); - - // rename - unsigned cycle[3] = { 0, 2, 4 }; - unsigned cycle_len = 3; - scoped_rel renamefn = plugin.mk_rename_fn(*r5, cycle_len, cycle); - scoped_rel r7 = (*renamefn)(*r5); - r7->display(std::cout << "rename r7: "); - - // union - // widen - relation_base* delta = 0; - scoped_ptr widenfn = plugin.mk_widen_fn(*r1, *r2, delta); - scoped_ptr unionfn = plugin.mk_union_fn(*r1, *r2, delta); - scoped_rel r8 = r1->clone(); - (*unionfn)(*r8,*r2,0); - r8->display(std::cout << "union r8: "); - - // filter_identical - unsigned identical_cols[2] = { 1, 3 }; - scoped_ptr filti = plugin.mk_filter_identical_fn(*r5, col_cnt, identical_cols); - scoped_rel r9 = r1->clone(); - (*filti)(*r9); - r9->display(std::cout << "filter identical r9: "); - - // filter_equal - app_ref value(m); - value = m.mk_const(symbol("x"), int_sort); - scoped_rel eqn = plugin.mk_filter_equal_fn(*r5, value.get(), 3); - scoped_rel r10 = r1->clone(); - (*eqn)(*r10); - r10->display(std::cout << "filter equal r10: "); - - - // filter_interpreted - app_ref cond(m); - cond = a.mk_lt(m.mk_var(3, int_sort), m.mk_var(4, int_sort)); - scoped_rel filtint = plugin.mk_filter_interpreted_fn(*r5, cond); - scoped_rel r11 = r5->clone(); - (*filtint)(*r11); - r11->display(std::cout << "filter interpreted r11: "); - - } - - void test_smt_relation_api() { - - enable_trace("smt_relation"); - enable_trace("smt_relation2"); - enable_trace("quant_elim"); - Z3_config cfg = Z3_mk_config(); - Z3_set_param_value(cfg, "DL_DEFAULT_RELATION", "smt_relation2"); - Z3_context ctx = Z3_mk_context(cfg); - Z3_fixedpoint dl = Z3_mk_fixedpoint(ctx); - Z3_fixedpoint_inc_ref(ctx,dl); - Z3_del_config(cfg); - - Z3_sort int_sort = Z3_mk_int_sort(ctx); - Z3_sort bool_sort = Z3_mk_bool_sort(ctx); - Z3_func_decl nil_decl, is_nil_decl; - Z3_func_decl cons_decl, is_cons_decl, head_decl, tail_decl; - - Z3_sort list = Z3_mk_list_sort( - ctx, - Z3_mk_string_symbol(ctx, "list"), - int_sort, - &nil_decl, - &is_nil_decl, - &cons_decl, - &is_cons_decl, - &head_decl, - &tail_decl); - - Z3_sort listint[2] = { list, int_sort }; - Z3_symbol p_sym = Z3_mk_string_symbol(ctx, "p"); - Z3_symbol q_sym = Z3_mk_string_symbol(ctx, "q"); - - - Z3_func_decl p = Z3_mk_func_decl(ctx, p_sym, 2, listint, bool_sort); - Z3_func_decl q = Z3_mk_func_decl(ctx, q_sym, 2, listint, bool_sort); - Z3_fixedpoint_register_relation(ctx, dl, p); - Z3_fixedpoint_register_relation(ctx, dl, q); - - - Z3_ast zero = Z3_mk_numeral(ctx, "0", int_sort); - Z3_ast one = Z3_mk_numeral(ctx, "1", int_sort); - Z3_ast two = Z3_mk_numeral(ctx, "2", int_sort); - Z3_ast x = Z3_mk_bound(ctx, 0, list); - Z3_ast y = Z3_mk_bound(ctx, 1, int_sort); - Z3_ast z = Z3_mk_bound(ctx, 2, list); - Z3_ast zero_x[2] = { zero, x }; - Z3_ast fx = Z3_mk_app(ctx, cons_decl, 2, zero_x); - Z3_ast zero_fx[2] = { zero, fx }; - Z3_ast ffx = Z3_mk_app(ctx, cons_decl, 2, zero_fx); - Z3_ast xy[2] = { x, y }; - Z3_ast zy[2] = { z, y }; - // Z3_ast ffxy[2] = { ffx, y }; - // Z3_ast fxy[2] = { fx, y }; - Z3_ast zero_nil[2] = { zero, Z3_mk_app(ctx, nil_decl, 0, 0) }; - Z3_ast f0 = Z3_mk_app(ctx, cons_decl, 2, zero_nil); - Z3_ast zero_f0[2] = { zero, f0 }; - Z3_ast f1 = Z3_mk_app(ctx, cons_decl, 2, zero_f0); - Z3_ast zero_f1[2] = { zero, f1 }; - Z3_ast f2 = Z3_mk_app(ctx, cons_decl, 2, zero_f1); - Z3_ast zero_f2[2] = { zero, f2 }; - Z3_ast f3 = Z3_mk_app(ctx, cons_decl, 2, zero_f2); - Z3_ast zero_f3[2] = { zero, f3 }; - Z3_ast f4 = Z3_mk_app(ctx, cons_decl, 2, zero_f3); - Z3_ast zero_f4[2] = { zero, f4 }; - Z3_ast f5 = Z3_mk_app(ctx, cons_decl, 2, zero_f4); - Z3_ast zero_z[2] = { zero, z }; - Z3_ast fz = Z3_mk_app(ctx, cons_decl, 2, zero_z); - - Z3_ast pxy = Z3_mk_app(ctx, p, 2, xy); - Z3_ast pzy = Z3_mk_app(ctx, p, 2, zy); - Z3_ast qxy = Z3_mk_app(ctx, q, 2, xy); - Z3_ast qzy = Z3_mk_app(ctx, q, 2, zy); - Z3_ast even_y = Z3_mk_eq(ctx, zero, Z3_mk_mod(ctx, y, two)); - Z3_ast odd_y = Z3_mk_eq(ctx, one, Z3_mk_mod(ctx, y, two)); - - - // p(x, y) :- odd(y), p(z,y), f(z) = x . // dead rule. - // q(x, y) :- p(f(f(x)), y). - // p(x, y) :- q(f(x), y) // x decreases - // p(x, y) :- even y, x = f^5(0) // initial condition. - - Z3_ast body1[3] = { pzy, Z3_mk_eq(ctx, fz, x), odd_y }; - Z3_ast body2[2] = { pzy, Z3_mk_eq(ctx, ffx, z) }; - Z3_ast body3[2] = { qzy, Z3_mk_eq(ctx, fx, z) }; - Z3_ast body4[2] = { even_y, Z3_mk_eq(ctx, x, f5) }; - Z3_fixedpoint_add_rule(ctx, dl, Z3_mk_implies(ctx, Z3_mk_and(ctx, 3, body1), pxy), 0); - Z3_fixedpoint_add_rule(ctx, dl, Z3_mk_implies(ctx, Z3_mk_and(ctx, 2, body2), qxy), 0); - Z3_fixedpoint_add_rule(ctx, dl, Z3_mk_implies(ctx, Z3_mk_and(ctx, 2, body3), pxy), 0); - Z3_fixedpoint_add_rule(ctx, dl, Z3_mk_implies(ctx, Z3_mk_and(ctx, 2, body4), pxy), 0); - - Z3_lbool r = Z3_fixedpoint_query(ctx, dl, pxy); - if (r != Z3_L_UNDEF) { - std::cout << Z3_ast_to_string(ctx, Z3_fixedpoint_get_answer(ctx, dl)) << "\n"; - } - - Z3_del_context(ctx); - - } -}; - -void tst_dl_smt_relation() { - datalog::test_smt_relation_api(); - datalog::test_smt_relation_unit(); -} diff --git a/src/test/main.cpp b/src/test/main.cpp index bee889ea2..13ade7714 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -166,7 +166,6 @@ int main(int argc, char ** argv) { TST(total_order); TST(dl_table); TST(dl_context); - TST(dl_smt_relation); TST(dl_query); TST(dl_util); TST(dl_product_relation); From 847c5f96910578bbd7775751f7045c067377edd6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 11:55:24 -0800 Subject: [PATCH 099/133] fixing problems Signed-off-by: Leonardo de Moura --- examples/java/JavaExample.java | 20 ++++++++--------- src/api/api_context.cpp | 2 +- src/parsers/util/simple_parser.cpp | 2 +- src/smt/qi_queue.cpp | 19 ++++++++++++---- src/smt/smt_solver.cpp | 36 ++++++++++++++++++++---------- src/util/gparams.cpp | 16 ++++++++++++- 6 files changed, 66 insertions(+), 29 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index d06f72217..4d9b6dc1f 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -712,9 +712,9 @@ class JavaExample System.out.println("QuantifierExample3"); HashMap cfg = new HashMap(); - cfg.put("MBQI", "false"); - cfg.put("PROOF_MODE", "2"); - cfg.put("AUTO_CONFIG", "false"); + cfg.put("smt.mbqi", "false"); + cfg.put("proof", "true"); + cfg.put("auto_config", "false"); /* * If quantified formulas are asserted in a logical context, then the @@ -761,9 +761,9 @@ class JavaExample System.out.println("QuantifierExample4"); HashMap cfg = new HashMap(); - cfg.put("MBQI", "false"); - cfg.put("PROOF_MODE", "2"); - cfg.put("AUTO_CONFIG", "false"); + cfg.put("smt.mbqi", "false"); + cfg.put("proof", "true"); + cfg.put("auto_config", "false"); /* * If quantified formulas are asserted in a logical context, then the @@ -1081,7 +1081,7 @@ class JavaExample { HashMap cfg = new HashMap(); - cfg.put("MODEL", "true"); + cfg.put("model", "true"); Context ctx = new Context(cfg); Expr a = ctx.ParseSMTLIB2File(filename, null, null, null, null); @@ -2100,7 +2100,7 @@ class JavaExample System.out.println("UnsatCoreAndProofExample"); HashMap cfg = new HashMap(); - cfg.put("PROOF_MODE", "2"); + cfg.put("proof", "true"); { Context ctx = new Context(cfg); @@ -2176,8 +2176,8 @@ class JavaExample { HashMap cfg = new HashMap(); - cfg.put("MODEL", "true"); - cfg.put("PROOF_MODE", "2"); + cfg.put("model", "true"); + cfg.put("proof", "true"); Context ctx = new Context(cfg); p.BasicTests(ctx); p.CastingTest(ctx); diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index f197e8ad8..69b7ea999 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -80,7 +80,7 @@ namespace api { } context::context(context_params * p, bool user_ref_count): - m_params(*p), + m_params(p != 0 ? *p : context_params()), m_user_ref_count(user_ref_count), m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), m_plugins(m_manager), diff --git a/src/parsers/util/simple_parser.cpp b/src/parsers/util/simple_parser.cpp index 65f75e870..045a45b24 100644 --- a/src/parsers/util/simple_parser.cpp +++ b/src/parsers/util/simple_parser.cpp @@ -112,7 +112,7 @@ expr * simple_parser::parse_expr(scanner & s) { } bool simple_parser::parse(std::istream & in, expr_ref & result) { - scanner s(in, std::cerr, false); + scanner s(in, std::cerr, false); try { result = parse_expr(s); if (!result) diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index 9394dae34..35dd19087 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -47,10 +47,21 @@ namespace smt { void qi_queue::setup() { TRACE("qi_cost", tout << "qi_cost: " << m_params.m_qi_cost << "\n";); - if (!m_parser.parse_string(m_params.m_qi_cost.c_str(), m_cost_function)) - throw default_exception("invalid cost function %s", m_params.m_qi_cost.c_str()); - if (!m_parser.parse_string(m_params.m_qi_new_gen.c_str(), m_new_gen_function)) - throw default_exception("invalid new-gen function %s", m_params.m_qi_new_gen.c_str()); + if (!m_parser.parse_string(m_params.m_qi_cost.c_str(), m_cost_function)) { + // it is not reasonable to abort here during the creation of smt::context just because an invalid option was provided. + // throw default_exception("invalid cost function %s", m_params.m_qi_cost.c_str()); + + // using warning message instead + warning_msg("invalid cost function '%s', switching to default one", m_params.m_qi_cost.c_str()); + // Trying again with default function + VERIFY(m_parser.parse_string("(+ weight generation)", m_cost_function)); + } + if (!m_parser.parse_string(m_params.m_qi_new_gen.c_str(), m_new_gen_function)) { + // See comment above + // throw default_exception("invalid new-gen function %s", m_params.m_qi_new_gen.c_str()); + warning_msg("invalid new_gen function '%s', switching to default one", m_params.m_qi_new_gen.c_str()); + VERIFY(m_parser.parse_string("cost", m_new_gen_function)); + } m_eager_cost_threshold = m_params.m_qi_eager_threshold; } diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 2aa4ee28f..e8c1c6698 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -56,9 +56,13 @@ namespace smt { virtual void init_core(ast_manager & m, symbol const & logic) { reset(); -#pragma omp critical (solver) + // We can throw exceptions when creating a smt::kernel object + // So, we should create the smt::kernel outside of the criticial section + // block. OMP does not allow exceptions to cross critical section boundaries. + smt::kernel * new_kernel = alloc(smt::kernel, m, m_params); + #pragma omp critical (solver) { - m_context = alloc(smt::kernel, m, m_params); + m_context = new_kernel; if (m_callback) m_context->set_progress_callback(m_callback); } @@ -77,59 +81,67 @@ namespace smt { virtual void reset_core() { if (m_context != 0) { -#pragma omp critical (solver) + #pragma omp critical (solver) { dealloc(m_context); m_context = 0; } } } + + // An exception may be thrown when creating a smt::kernel. + // So, there is no guarantee that m_context != 0 when + // using smt_solver from the SMT 2.0 command line frontend. + void check_context() const { + if (m_context == 0) + throw default_exception("Z3 failed to create solver, check previous error messages"); + } virtual void assert_expr(expr * t) { - SASSERT(m_context); + check_context(); m_context->assert_expr(t); } virtual void push_core() { - SASSERT(m_context); + check_context(); m_context->push(); } virtual void pop_core(unsigned n) { - SASSERT(m_context); + check_context(); m_context->pop(n); } virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { - SASSERT(m_context); + check_context(); TRACE("solver_na2as", tout << "smt_solver::check_sat_core: " << num_assumptions << "\n";); return m_context->check(num_assumptions, assumptions); } virtual void get_unsat_core(ptr_vector & r) { - SASSERT(m_context); + check_context(); unsigned sz = m_context->get_unsat_core_size(); for (unsigned i = 0; i < sz; i++) r.push_back(m_context->get_unsat_core_expr(i)); } virtual void get_model(model_ref & m) { - SASSERT(m_context); + check_context(); m_context->get_model(m); } virtual proof * get_proof() { - SASSERT(m_context); + check_context(); return m_context->get_proof(); } virtual std::string reason_unknown() const { - SASSERT(m_context); + check_context(); return m_context->last_failure_as_string(); } virtual void get_labels(svector & r) { - SASSERT(m_context); + check_context(); buffer tmp; m_context->get_relevant_labels(0, tmp); r.append(tmp.size(), tmp.c_ptr()); diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 4aecd0c05..183678c59 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -178,6 +178,11 @@ public: long val = strtol(value, 0, 10); ps.set_uint(param_name, static_cast(val)); } + else if (k == CPK_DOUBLE) { + char * aux; + double val = strtod(value, &aux); + ps.set_double(param_name, val); + } else if (k == CPK_BOOL) { if (strcmp(value, "true") == 0) { ps.set_bool(param_name, true); @@ -196,7 +201,16 @@ public: ps.set_sym(param_name, symbol(value)); } else if (k == CPK_STRING) { - ps.set_str(param_name, value); + // There is no guarantee that (external) callers will not delete value after invoking gparams::set. + // I see two solutions: + // 1) Modify params_ref to create a copy of set_str parameters. + // This solution is not nice since we create copies and move the params_ref around. + // We would have to keep copying the strings. + // Moreover, when we use params_ref internally, the value is usually a static value. + // So, we would be paying this price for nothing. + // 2) "Copy" value by transforming it into a symbol. + // I'm using this solution for now. + ps.set_str(param_name, symbol(value).bare_str()); } else { if (mod_name == symbol::null) From d634c945bfb85d876ee3d48c9b85bde90e4d5a3d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 13:44:39 -0800 Subject: [PATCH 100/133] renamed validate_model --> model_validate Signed-off-by: Leonardo de Moura --- src/api/z3_api.h | 2 +- src/cmd_context/cmd_context.cpp | 2 +- src/cmd_context/context_params.cpp | 8 ++++---- src/cmd_context/context_params.h | 2 +- src/smt/params/smt_params.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 16bf9193c..07748e0e1 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1312,7 +1312,7 @@ extern "C" { - well_sorted_check type checker - auto_config use heuristics to automatically select solver and configure it - model model generation for solvers, this parameter can be overwritten when creating a solver - - validate_model validate models produced by solvers + - model_validate validate models produced by solvers - unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver \sa Z3_set_param_value diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 19fbdcd3c..c6bfeb663 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -393,7 +393,7 @@ bool cmd_context::well_sorted_check_enabled() const { } bool cmd_context::validate_model_enabled() const { - return m_params.m_validate_model; + return m_params.m_model_validate; } cmd_context::check_sat_state cmd_context::cs_state() const { diff --git a/src/cmd_context/context_params.cpp b/src/cmd_context/context_params.cpp index c7efa0d8d..495f73b75 100644 --- a/src/cmd_context/context_params.cpp +++ b/src/cmd_context/context_params.cpp @@ -62,8 +62,8 @@ void context_params::set(char const * param, char const * value) { else if (p == "model") { set_bool(m_model, param, value); } - else if (p == "validate_model") { - set_bool(m_validate_model, param, value); + else if (p == "model_validate") { + set_bool(m_model_validate, param, value); } else if (p == "trace") { set_bool(m_trace, param, value); @@ -92,7 +92,7 @@ void context_params::updt_params(params_ref const & p) { m_auto_config = p.get_bool("auto_config", true); m_proof = p.get_bool("proof", false); m_model = p.get_bool("model", true); - m_validate_model = p.get_bool("validate_model", false); + m_model_validate = p.get_bool("model_validate", false); m_trace = p.get_bool("trace", false); m_trace_file_name = p.get_str("trace_file_name", "z3.log"); m_unsat_core = p.get_bool("unsat_core", false); @@ -106,7 +106,7 @@ void context_params::collect_param_descrs(param_descrs & d) { d.insert("auto_config", CPK_BOOL, "use heuristics to automatically select solver and configure it", "true"); d.insert("proof", CPK_BOOL, "proof generation, it must be enabled when the Z3 context is created", "false"); d.insert("model", CPK_BOOL, "model generation for solvers, this parameter can be overwritten when creating a solver", "true"); - d.insert("validate_model", CPK_BOOL, "validate models produced by solvers", "false"); + d.insert("model_validate", CPK_BOOL, "validate models produced by solvers", "false"); d.insert("trace", CPK_BOOL, "trace generation for VCC", "false"); d.insert("trace_file_name", CPK_STRING, "trace out file name (see option 'trace')", "z3.log"); d.insert("unsat_core", CPK_BOOL, "unsat-core generation for solvers, this parameter can be overwritten when creating a solver, not every solver in Z3 supports unsat core generation", "false"); diff --git a/src/cmd_context/context_params.h b/src/cmd_context/context_params.h index 0fe4da93e..6b42b5b50 100644 --- a/src/cmd_context/context_params.h +++ b/src/cmd_context/context_params.h @@ -33,7 +33,7 @@ public: std::string m_trace_file_name; bool m_well_sorted_check; bool m_model; - bool m_validate_model; + bool m_model_validate; bool m_unsat_core; unsigned m_timeout; diff --git a/src/smt/params/smt_params.cpp b/src/smt/params/smt_params.cpp index 70f0ad811..fb5ada715 100644 --- a/src/smt/params/smt_params.cpp +++ b/src/smt/params/smt_params.cpp @@ -43,7 +43,7 @@ void smt_params::updt_params(context_params const & p) { m_auto_config = p.m_auto_config; m_soft_timeout = p.m_timeout; m_model = p.m_model; - m_model_validate = p.m_validate_model; + m_model_validate = p.m_model_validate; m_proof_mode = p.m_proof ? PGM_FINE : PGM_DISABLED; } From 6d7d205e13f0ee1562f4ea2c458cef002ba7e6ca Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 15:02:34 -0800 Subject: [PATCH 101/133] fixed more problems in the new param framework Signed-off-by: Leonardo de Moura --- src/api/api_params.cpp | 8 ++-- src/api/python/z3.py | 7 ++- src/cmd_context/cmd_context.cpp | 16 ------- src/cmd_context/cmd_context.h | 5 --- src/cmd_context/parametric_cmd.cpp | 2 +- src/cmd_context/tactic_cmds.cpp | 2 +- src/smt/params/smt_params.cpp | 7 +++ src/smt/params/smt_params_helper.pyg | 2 + src/tactic/arith/degree_shift_tactic.cpp | 2 +- src/tactic/arith/purify_arith_tactic.cpp | 2 +- src/tactic/sls/sls_tactic.cpp | 2 +- src/tactic/smtlogics/nra_tactic.cpp | 8 ++-- src/tactic/smtlogics/qfaufbv_tactic.cpp | 20 ++++----- src/tactic/smtlogics/qfauflia_tactic.cpp | 12 ++--- src/tactic/smtlogics/qfbv_tactic.cpp | 36 +++++++-------- src/tactic/smtlogics/qfidl_tactic.cpp | 26 +++++------ src/tactic/smtlogics/qflia_tactic.cpp | 56 ++++++++++++------------ src/tactic/smtlogics/qflra_tactic.cpp | 18 ++++---- src/tactic/smtlogics/qfnia_tactic.cpp | 28 ++++++------ src/tactic/smtlogics/qfnra_tactic.cpp | 10 ++--- src/tactic/smtlogics/qfuf_tactic.cpp | 6 +-- src/tactic/smtlogics/qfufbv_tactic.cpp | 4 +- src/tactic/smtlogics/quant_tactics.cpp | 14 +++--- src/tactic/ufbv/ufbv_tactic.cpp | 10 ++--- src/test/dl_context.cpp | 4 +- src/test/dl_product_relation.cpp | 2 +- src/test/dl_query.cpp | 12 ++--- src/util/debug.cpp | 6 ++- src/util/params.cpp | 23 ++++++++++ src/util/params.h | 3 ++ 30 files changed, 185 insertions(+), 168 deletions(-) diff --git a/src/api/api_params.cpp b/src/api/api_params.cpp index 74899bc44..19634af32 100644 --- a/src/api/api_params.cpp +++ b/src/api/api_params.cpp @@ -66,7 +66,7 @@ extern "C" { Z3_TRY; LOG_Z3_params_set_bool(c, p, k, v); RESET_ERROR_CODE(); - to_params(p)->m_params.set_bool(to_symbol(k), v != 0); + to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v != 0); Z3_CATCH; } @@ -77,7 +77,7 @@ extern "C" { Z3_TRY; LOG_Z3_params_set_uint(c, p, k, v); RESET_ERROR_CODE(); - to_params(p)->m_params.set_uint(to_symbol(k), v); + to_params(p)->m_params.set_uint(norm_param_name(to_symbol(k)).c_str(), v); Z3_CATCH; } @@ -88,7 +88,7 @@ extern "C" { Z3_TRY; LOG_Z3_params_set_double(c, p, k, v); RESET_ERROR_CODE(); - to_params(p)->m_params.set_double(to_symbol(k), v); + to_params(p)->m_params.set_double(norm_param_name(to_symbol(k)).c_str(), v); Z3_CATCH; } @@ -99,7 +99,7 @@ extern "C" { Z3_TRY; LOG_Z3_params_set_symbol(c, p, k, v); RESET_ERROR_CODE(); - to_params(p)->m_params.set_sym(to_symbol(k), to_symbol(v)); + to_params(p)->m_params.set_sym(norm_param_name(to_symbol(k)).c_str(), to_symbol(v)); Z3_CATCH; } diff --git a/src/api/python/z3.py b/src/api/python/z3.py index b03cf1fd8..71fd9a732 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -223,7 +223,7 @@ def get_option(name): """Return the value of a Z3 global (or module) parameter >>> get_option('nlsat.reorder') - true + 'true' """ ptr = (ctypes.c_char_p * 1)() if Z3_global_param_get(str(name), ptr): @@ -4384,8 +4384,8 @@ def args2params(arguments, keywords, ctx=None): """Convert python arguments into a Z3_params object. A ':' is added to the keywords, and '_' is replaced with '-' - >>> args2params([':model', True, ':relevancy', 2], {'elim_and' : True}) - (params :model 1 :relevancy 2 :elim-and 1) + >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True}) + (params model 1 relevancy 2 elim_and 1) """ if __debug__: _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.") @@ -4398,7 +4398,6 @@ def args2params(arguments, keywords, ctx=None): r.set(prev, a) prev = None for k, v in keywords.iteritems(): - k = ':' + k.replace('_', '-') r.set(k, v) return r diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index c6bfeb663..b27e1e177 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -38,22 +38,6 @@ Notes: #include"model_evaluator.h" #include"for_each_expr.h" -std::string smt2_keyword_to_param(symbol const & opt) { - std::string r; - SASSERT(opt.bare_str()[0] == ':'); - r = opt.bare_str() + 1; - unsigned sz = static_cast(r.size()); - for (unsigned i = 0; i < sz; i++) { - char curr = r[i]; - if ('A' <= curr && curr <= 'Z') - r[i] = curr - 'A' + 'a'; - else if (curr == '-') - r[i] = '_'; - } - TRACE("smt2_keyword_to_param", tout << opt << " -> '" << r << "'\n";); - return r; -} - func_decls::func_decls(ast_manager & m, func_decl * f): m_decls(TAG(func_decl*, f, 0)) { m.inc_ref(f); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index ae517b0c2..ca3ada7cf 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -38,11 +38,6 @@ Notes: #include"scoped_ptr_vector.h" #include"context_params.h" -/** - \brief Auxiliary function for converting SMT2 keywords into Z3 internal parameter names. -*/ -std::string smt2_keyword_to_param(symbol const & k); - class func_decls { func_decl * m_decls; public: diff --git a/src/cmd_context/parametric_cmd.cpp b/src/cmd_context/parametric_cmd.cpp index f028c3b9d..c229bc29c 100644 --- a/src/cmd_context/parametric_cmd.cpp +++ b/src/cmd_context/parametric_cmd.cpp @@ -38,7 +38,7 @@ cmd_arg_kind parametric_cmd::next_arg_kind(cmd_context & ctx) const { void parametric_cmd::set_next_arg(cmd_context & ctx, symbol const & s) { if (m_last == symbol::null) { - m_last = symbol(smt2_keyword_to_param(s).c_str()); + m_last = symbol(norm_param_name(s).c_str()); if (pdescrs(ctx).get_kind(m_last.bare_str()) == CPK_INVALID) throw cmd_exception("invalid keyword argument"); return; diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index 8a7449a88..ca87406c7 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -497,7 +497,7 @@ static tactic * mk_using_params(cmd_context & ctx, sexpr * n) { throw cmd_exception("invalid using-params combinator, keyword expected", c->get_line(), c->get_pos()); if (i == num_children) throw cmd_exception("invalid using-params combinator, parameter value expected", c->get_line(), c->get_pos()); - symbol param_name = symbol(smt2_keyword_to_param(c->get_symbol()).c_str()); + symbol param_name = symbol(norm_param_name(c->get_symbol()).c_str()); c = n->get_child(i); i++; switch (descrs.get_kind(param_name)) { diff --git a/src/smt/params/smt_params.cpp b/src/smt/params/smt_params.cpp index fb5ada715..113a2bead 100644 --- a/src/smt/params/smt_params.cpp +++ b/src/smt/params/smt_params.cpp @@ -22,6 +22,8 @@ Revision History: void smt_params::updt_local_params(params_ref const & _p) { smt_params_helper p(_p); m_auto_config = p.auto_config(); + m_random_seed = p.random_seed(); + m_relevancy_lvl = p.relevancy(); m_ematching = p.ematching(); m_phase_selection = static_cast(p.phase_selection()); m_restart_strategy = static_cast(p.restart_strategy()); @@ -29,6 +31,11 @@ void smt_params::updt_local_params(params_ref const & _p) { m_case_split_strategy = static_cast(p.case_split()); m_delay_units = p.delay_units(); m_delay_units_threshold = p.delay_units_threshold(); + m_preprocess = _p.get_bool("preprocess", true); // hidden parameter + if (_p.get_bool("arith.greatest_error_pivot", false)) + m_arith_pivot_strategy = ARITH_PIVOT_GREATEST_ERROR; + else if (_p.get_bool("arith.least_error_pivot", false)) + m_arith_pivot_strategy = ARITH_PIVOT_LEAST_ERROR; } void smt_params::updt_params(params_ref const & p) { diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg index 8db95a581..bcdf78b73 100644 --- a/src/smt/params/smt_params_helper.pyg +++ b/src/smt/params/smt_params_helper.pyg @@ -3,6 +3,8 @@ def_module_params(module_name='smt', description='smt solver based on lazy smt', export=True, params=(('auto_config', BOOL, True, 'automatically configure solver'), + ('random_seed', UINT, 0, 'random seed for the smt solver'), + ('relevancy', UINT, 2, 'relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant'), ('macro_finder', BOOL, False, 'try to find universally quantified formulas that can be viewed as macros'), ('ematching', BOOL, True, 'E-Matching based quantifier instantiation'), ('phase_selection', UINT, 4, 'phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences'), diff --git a/src/tactic/arith/degree_shift_tactic.cpp b/src/tactic/arith/degree_shift_tactic.cpp index 8e2c6d7cb..a1aa0bdc8 100644 --- a/src/tactic/arith/degree_shift_tactic.cpp +++ b/src/tactic/arith/degree_shift_tactic.cpp @@ -342,7 +342,7 @@ protected: tactic * mk_degree_shift_tactic(ast_manager & m, params_ref const & p) { params_ref mul2power_p; - mul2power_p.set_bool(":mul-to-power", true); + mul2power_p.set_bool("mul_to_power", true); return and_then(using_params(mk_simplify_tactic(m), mul2power_p), clean(alloc(degree_shift_tactic, m))); } diff --git a/src/tactic/arith/purify_arith_tactic.cpp b/src/tactic/arith/purify_arith_tactic.cpp index d6ed86c08..d2292ede9 100644 --- a/src/tactic/arith/purify_arith_tactic.cpp +++ b/src/tactic/arith/purify_arith_tactic.cpp @@ -902,7 +902,7 @@ public: tactic * mk_purify_arith_tactic(ast_manager & m, params_ref const & p) { params_ref elim_rem_p = p; - elim_rem_p.set_bool("elim-rem", true); + elim_rem_p.set_bool("elim_rem", true); params_ref skolemize_p; skolemize_p.set_bool("skolemize", false); diff --git a/src/tactic/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index 290a0ad35..f49ce8422 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -1855,7 +1855,7 @@ tactic * mk_sls_tactic(ast_manager & m, params_ref const & p) { tactic * mk_preamble(ast_manager & m, params_ref const & p) { params_ref main_p; main_p.set_bool("elim_and", true); - // main_p.set_bool("pull-cheap_ite", true); + // main_p.set_bool("pull_cheap_ite", true); main_p.set_bool("push_ite_bv", true); main_p.set_bool("blast_distinct", true); // main_p.set_bool("udiv2mul", true); diff --git a/src/tactic/smtlogics/nra_tactic.cpp b/src/tactic/smtlogics/nra_tactic.cpp index 623b7e55e..845b6bfec 100644 --- a/src/tactic/smtlogics/nra_tactic.cpp +++ b/src/tactic/smtlogics/nra_tactic.cpp @@ -27,11 +27,11 @@ Notes: tactic * mk_nra_tactic(ast_manager & m, params_ref const& p) { params_ref p1 = p; - p1.set_uint(":seed", 11); - p1.set_bool(":factor", false); + p1.set_uint("seed", 11); + p1.set_bool("factor", false); params_ref p2 = p; - p2.set_uint(":seed", 13); - p2.set_bool(":factor", false); + p2.set_uint("seed", 13); + p2.set_bool("factor", false); return and_then(mk_simplify_tactic(m, p), mk_nnf_tactic(m, p), diff --git a/src/tactic/smtlogics/qfaufbv_tactic.cpp b/src/tactic/smtlogics/qfaufbv_tactic.cpp index 5f371da0c..cb14fa778 100644 --- a/src/tactic/smtlogics/qfaufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfaufbv_tactic.cpp @@ -29,22 +29,22 @@ Notes: tactic * mk_qfaufbv_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":sort-store", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("sort_store", true); params_ref simp2_p = p; - simp2_p.set_bool(":som", true); - simp2_p.set_bool(":pull-cheap-ite", true); - simp2_p.set_bool(":push-ite-bv", false); - simp2_p.set_bool(":local-ctx", true); - simp2_p.set_uint(":local-ctx-limit", 10000000); + simp2_p.set_bool("som", true); + simp2_p.set_bool("pull_cheap_ite", true); + simp2_p.set_bool("push_ite_bv", false); + simp2_p.set_bool("local_ctx", true); + simp2_p.set_uint("local_ctx_limit", 10000000); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 32); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 32); + ctx_simp_p.set_uint("max_steps", 5000000); params_ref solver_p; - solver_p.set_bool(":array-old-simplifier", false); + solver_p.set_bool("array.simplify", false); // disable array simplifications at old_simplify module tactic * preamble_st = and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), diff --git a/src/tactic/smtlogics/qfauflia_tactic.cpp b/src/tactic/smtlogics/qfauflia_tactic.cpp index 422be13d5..89f96d354 100644 --- a/src/tactic/smtlogics/qfauflia_tactic.cpp +++ b/src/tactic/smtlogics/qfauflia_tactic.cpp @@ -26,16 +26,16 @@ Notes: tactic * mk_qfauflia_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":som", true); - main_p.set_bool(":sort-store", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("som", true); + main_p.set_bool("sort_store", true); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 30); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 30); + ctx_simp_p.set_uint("max_steps", 5000000); params_ref solver_p; - solver_p.set_bool(":array-old-simplifier", false); + solver_p.set_bool("array.simplify", false); // disable array simplifications at old_simplify module tactic * preamble_st = and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), diff --git a/src/tactic/smtlogics/qfbv_tactic.cpp b/src/tactic/smtlogics/qfbv_tactic.cpp index 5924c5bdf..51b040332 100644 --- a/src/tactic/smtlogics/qfbv_tactic.cpp +++ b/src/tactic/smtlogics/qfbv_tactic.cpp @@ -33,40 +33,40 @@ Notes: tactic * mk_qfbv_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":push-ite-bv", true); - main_p.set_bool(":blast-distinct", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("push_ite_bv", true); + main_p.set_bool("blast_distinct", true); params_ref simp2_p = p; - simp2_p.set_bool(":som", true); - simp2_p.set_bool(":pull-cheap-ite", true); - simp2_p.set_bool(":push-ite-bv", false); - simp2_p.set_bool(":local-ctx", true); - simp2_p.set_uint(":local-ctx-limit", 10000000); + simp2_p.set_bool("som", true); + simp2_p.set_bool("pull_cheap_ite", true); + simp2_p.set_bool("push_ite_bv", false); + simp2_p.set_bool("local_ctx", true); + simp2_p.set_uint("local_ctx_limit", 10000000); params_ref local_ctx_p = p; - local_ctx_p.set_bool(":local-ctx", true); + local_ctx_p.set_bool("local_ctx", true); params_ref solver_p; - solver_p.set_bool(":preprocess", false); // preprocessor of smt::context is not needed. + solver_p.set_bool("preprocess", false); // preprocessor of smt::context is not needed. params_ref no_flat_p; - no_flat_p.set_bool(":flat", false); + no_flat_p.set_bool("flat", false); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 32); - ctx_simp_p.set_uint(":max-steps", 50000000); + ctx_simp_p.set_uint("max_depth", 32); + ctx_simp_p.set_uint("max_steps", 50000000); params_ref hoist_p; - hoist_p.set_bool(":hoist-mul", true); - hoist_p.set_bool(":som", false); + hoist_p.set_bool("hoist_mul", true); + hoist_p.set_bool("som", false); params_ref solve_eq_p; // conservative guassian elimination. - solve_eq_p.set_uint(":solve-eqs-max-occs", 2); + solve_eq_p.set_uint("solve_eqs_max_occs", 2); params_ref big_aig_p; - big_aig_p.set_bool(":aig-per-assertion", false); + big_aig_p.set_bool("aig_per_assertion", false); tactic * preamble_st = and_then(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -74,7 +74,7 @@ tactic * mk_qfbv_tactic(ast_manager & m, params_ref const & p) { mk_elim_uncnstr_tactic(m), if_no_proofs(if_no_unsat_cores(mk_bv_size_reduction_tactic(m))), using_params(mk_simplify_tactic(m), simp2_p)), - // Z3 can solve a couple of extra benchmarks by using :hoist-mul + // Z3 can solve a couple of extra benchmarks by using hoist_mul // but the timeout in SMT-COMP is too small. // Moreover, it impacted negatively some easy benchmarks. // We should decide later, if we keep it or not. diff --git a/src/tactic/smtlogics/qfidl_tactic.cpp b/src/tactic/smtlogics/qfidl_tactic.cpp index 57aef4991..de05797e8 100644 --- a/src/tactic/smtlogics/qfidl_tactic.cpp +++ b/src/tactic/smtlogics/qfidl_tactic.cpp @@ -37,23 +37,23 @@ Notes: tactic * mk_qfidl_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":blast-distinct", true); - main_p.set_bool(":som", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("blast_distinct", true); + main_p.set_bool("som", true); params_ref lhs_p; - lhs_p.set_bool(":arith-lhs", true); + lhs_p.set_bool("arith_lhs", true); params_ref lia2pb_p; - lia2pb_p.set_uint(":lia2pb-max-bits", 4); + lia2pb_p.set_uint("lia2pb_max_bits", 4); params_ref pb2bv_p; - pb2bv_p.set_uint(":pb2bv-all-clauses-limit", 8); + pb2bv_p.set_uint("pb2bv_all_clauses_limit", 8); params_ref pull_ite_p; - pull_ite_p.set_bool(":pull-cheap-ite", true); - pull_ite_p.set_bool(":local-ctx", true); - pull_ite_p.set_uint(":local-ctx-limit", 10000000); + pull_ite_p.set_bool("pull_cheap_ite", true); + pull_ite_p.set_bool("local_ctx", true); + pull_ite_p.set_uint("local_ctx_limit", 10000000); tactic * preamble_st = and_then(and_then(mk_simplify_tactic(m), mk_fix_dl_var_tactic(m), @@ -71,10 +71,10 @@ tactic * mk_qfidl_tactic(ast_manager & m, params_ref const & p) { params_ref bv_solver_p; // The cardinality constraint encoding generates a lot of shared if-then-else's that can be flattened. // Several of them are simplified to and/or. If we flat them, we increase a lot the memory consumption. - bv_solver_p.set_bool(":flat", false); - bv_solver_p.set_bool(":som", false); + bv_solver_p.set_bool("flat", false); + bv_solver_p.set_bool("som", false); // dynamic psm seems to work well. - bv_solver_p.set_sym(":gc-strategy", symbol("dyn-psm")); + bv_solver_p.set_sym("gc", symbol("dyn_psm")); tactic * bv_solver = using_params(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -93,7 +93,7 @@ tactic * mk_qfidl_tactic(ast_manager & m, params_ref const & p) { bv_solver); params_ref diff_neq_p; - diff_neq_p.set_uint(":diff-neq-max-k", 25); + diff_neq_p.set_uint("diff_neq_max_k", 25); tactic * st = cond(mk_and(mk_lt(mk_num_consts_probe(), mk_const_probe(static_cast(BIG_PROBLEM))), mk_and(mk_not(mk_produce_proofs_probe()), diff --git a/src/tactic/smtlogics/qflia_tactic.cpp b/src/tactic/smtlogics/qflia_tactic.cpp index 1fb30faae..6b05cff96 100644 --- a/src/tactic/smtlogics/qflia_tactic.cpp +++ b/src/tactic/smtlogics/qflia_tactic.cpp @@ -64,17 +64,17 @@ probe * mk_quasi_pb_probe() { // Create SMT solver that does not use cuts static tactic * mk_no_cut_smt_tactic(unsigned rs) { params_ref solver_p; - solver_p.set_uint(":arith-branch-cut-ratio", 10000000); - solver_p.set_uint(":random-seed", rs); + solver_p.set_uint("arith.branch_cut_ratio", 10000000); + solver_p.set_uint("random_seed", rs); return using_params(mk_smt_tactic_using(false), solver_p); } // Create SMT solver that does not use cuts static tactic * mk_no_cut_no_relevancy_smt_tactic(unsigned rs) { params_ref solver_p; - solver_p.set_uint(":arith-branch-cut-ratio", 10000000); - solver_p.set_uint(":random-seed", rs); - solver_p.set_uint(":relevancy", 0); + solver_p.set_uint("arith.branch_cut_ratio", 10000000); + solver_p.set_uint("random_seed", rs); + solver_p.set_uint("relevancy", 0); return using_params(mk_smt_tactic_using(false), solver_p); } @@ -82,10 +82,10 @@ static tactic * mk_bv2sat_tactic(ast_manager & m) { params_ref solver_p; // The cardinality constraint encoding generates a lot of shared if-then-else's that can be flattened. // Several of them are simplified to and/or. If we flat them, we increase a lot the memory consumption. - solver_p.set_bool(":flat", false); - solver_p.set_bool(":som", false); + solver_p.set_bool("flat", false); + solver_p.set_bool("som", false); // dynamic psm seems to work well. - solver_p.set_sym(":gc-strategy", symbol("dyn-psm")); + solver_p.set_sym("gc", symbol("dyn_psm")); return using_params(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -101,8 +101,8 @@ static tactic * mk_bv2sat_tactic(ast_manager & m) { static tactic * mk_pb_tactic(ast_manager & m) { params_ref pb2bv_p; - pb2bv_p.set_bool(":ite-extra", true); - pb2bv_p.set_uint(":pb2bv-all-clauses-limit", 8); + pb2bv_p.set_bool("ite_extra", true); + pb2bv_p.set_uint("pb2bv_all_clauses_limit", 8); return and_then(fail_if_not(mk_is_pb_probe()), fail_if(mk_produce_proofs_probe()), @@ -119,8 +119,8 @@ static tactic * mk_pb_tactic(ast_manager & m) { static tactic * mk_lia2sat_tactic(ast_manager & m) { params_ref pb2bv_p; - pb2bv_p.set_bool(":ite-extra", true); - pb2bv_p.set_uint(":pb2bv-all-clauses-limit", 8); + pb2bv_p.set_bool("ite_extra", true); + pb2bv_p.set_uint("pb2bv_all_clauses_limit", 8); return and_then(fail_if(mk_is_unbounded_probe()), fail_if(mk_produce_proofs_probe()), @@ -137,11 +137,11 @@ static tactic * mk_lia2sat_tactic(ast_manager & m) { // Fails if the problem is no ILP. static tactic * mk_ilp_model_finder_tactic(ast_manager & m) { params_ref add_bounds_p1; - add_bounds_p1.set_rat(":add-bound-lower", rational(-16)); - add_bounds_p1.set_rat(":add-bound-upper", rational(15)); + add_bounds_p1.set_rat("add_bound_lower", rational(-16)); + add_bounds_p1.set_rat("add_bound_upper", rational(15)); params_ref add_bounds_p2; - add_bounds_p2.set_rat(":add-bound-lower", rational(-32)); - add_bounds_p2.set_rat(":add-bound-upper", rational(31)); + add_bounds_p2.set_rat("add_bound_lower", rational(-32)); + add_bounds_p2.set_rat("add_bound_upper", rational(31)); return and_then(fail_if_not(mk_and(mk_is_ilp_probe(), mk_is_unbounded_probe())), fail_if(mk_produce_proofs_probe()), @@ -170,22 +170,22 @@ static tactic * mk_bounded_tactic(ast_manager & m) { tactic * mk_qflia_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":som", true); - // main_p.set_bool(":push-ite-arith", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("som", true); + // main_p.set_bool("push_ite_arith", true); params_ref pull_ite_p; - pull_ite_p.set_bool(":pull-cheap-ite", true); - pull_ite_p.set_bool(":push-ite-arith", false); - pull_ite_p.set_bool(":local-ctx", true); - pull_ite_p.set_uint(":local-ctx-limit", 10000000); + pull_ite_p.set_bool("pull_cheap_ite", true); + pull_ite_p.set_bool("push_ite_arith", false); + pull_ite_p.set_bool("local_ctx", true); + pull_ite_p.set_uint("local_ctx_limit", 10000000); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 30); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 30); + ctx_simp_p.set_uint("max_steps", 5000000); params_ref lhs_p; - lhs_p.set_bool(":arith-lhs", true); + lhs_p.set_bool("arith_lhs", true); tactic * preamble_st = and_then(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -197,10 +197,10 @@ tactic * mk_qflia_tactic(ast_manager & m, params_ref const & p) { ); params_ref quasi_pb_p; - quasi_pb_p.set_uint(":lia2pb-max-bits", 64); + quasi_pb_p.set_uint("lia2pb_max_bits", 64); params_ref no_cut_p; - no_cut_p.set_uint(":arith-branch-cut-ratio", 10000000); + no_cut_p.set_uint("arith.branch_cut_ratio", 10000000); tactic * st = using_params(and_then(preamble_st, diff --git a/src/tactic/smtlogics/qflra_tactic.cpp b/src/tactic/smtlogics/qflra_tactic.cpp index 42aaa96b7..41f0e16f3 100644 --- a/src/tactic/smtlogics/qflra_tactic.cpp +++ b/src/tactic/smtlogics/qflra_tactic.cpp @@ -29,23 +29,23 @@ Notes: tactic * mk_qflra_tactic(ast_manager & m, params_ref const & p) { params_ref pivot_p; - pivot_p.set_bool(":arith-greatest-error-pivot", true); + pivot_p.set_bool("arith.greatest_error_pivot", true); params_ref main_p = p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":som", true); - main_p.set_bool(":blast-distinct", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("som", true); + main_p.set_bool("blast_distinct", true); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 30); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 30); + ctx_simp_p.set_uint("max_steps", 5000000); params_ref lhs_p; - lhs_p.set_bool(":arith-lhs", true); - lhs_p.set_bool(":eq2ineq", true); + lhs_p.set_bool("arith_lhs", true); + lhs_p.set_bool("eq2ineq", true); params_ref elim_to_real_p; - elim_to_real_p.set_bool(":elim-to-real", true); + elim_to_real_p.set_bool("elim_to_real", true); #if 0 diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index e87d36503..950291221 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -31,14 +31,14 @@ Notes: tactic * mk_qfnia_bv_solver(ast_manager & m, params_ref const & p_ref) { params_ref p = p_ref; - p.set_bool(":flat", false); - p.set_bool(":hi-div0", true); - p.set_bool(":elim-and", true); - p.set_bool(":blast-distinct", true); + p.set_bool("flat", false); + p.set_bool("hi_div0", true); + p.set_bool("elim_and", true); + p.set_bool("blast_distinct", true); params_ref simp2_p = p; - simp2_p.set_bool(":local-ctx", true); - simp2_p.set_uint(":local-ctx-limit", 10000000); + simp2_p.set_bool("local_ctx", true); + simp2_p.set_uint("local_ctx_limit", 10000000); tactic * r = using_params(and_then(mk_simplify_tactic(m), @@ -53,19 +53,19 @@ tactic * mk_qfnia_bv_solver(ast_manager & m, params_ref const & p_ref) { tactic * mk_qfnia_premable(ast_manager & m, params_ref const & p_ref) { params_ref pull_ite_p = p_ref; - pull_ite_p.set_bool(":pull-cheap-ite", true); - pull_ite_p.set_bool(":local-ctx", true); - pull_ite_p.set_uint(":local-ctx-limit", 10000000); + pull_ite_p.set_bool("pull_cheap_ite", true); + pull_ite_p.set_bool("local_ctx", true); + pull_ite_p.set_uint("local_ctx_limit", 10000000); params_ref ctx_simp_p = p_ref; - ctx_simp_p.set_uint(":max-depth", 30); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 30); + ctx_simp_p.set_uint("max_steps", 5000000); params_ref simp_p = p_ref; - simp_p.set_bool(":hoist-mul", true); + simp_p.set_bool("hoist_mul", true); params_ref elim_p = p_ref; - elim_p.set_uint(":max-memory",20); + elim_p.set_uint("max_memory",20); return and_then(mk_simplify_tactic(m), @@ -79,7 +79,7 @@ tactic * mk_qfnia_premable(ast_manager & m, params_ref const & p_ref) { tactic * mk_qfnia_sat_solver(ast_manager & m, params_ref const & p) { params_ref nia2sat_p = p; - nia2sat_p.set_uint(":nla2bv-max-bv-size", 64); + nia2sat_p.set_uint("nla2bv_max_bv_size", 64); return and_then(mk_nla2bv_tactic(m, nia2sat_p), mk_qfnia_bv_solver(m, p), diff --git a/src/tactic/smtlogics/qfnra_tactic.cpp b/src/tactic/smtlogics/qfnra_tactic.cpp index a2877eefa..716b4868b 100644 --- a/src/tactic/smtlogics/qfnra_tactic.cpp +++ b/src/tactic/smtlogics/qfnra_tactic.cpp @@ -25,7 +25,7 @@ Notes: static tactic * mk_qfnra_sat_solver(ast_manager& m, params_ref const& p, unsigned bv_size) { params_ref nra2sat_p = p; - nra2sat_p.set_uint(":nla2bv-max-bv-size", p.get_uint("nla2bv_max_bv_size", bv_size)); + nra2sat_p.set_uint("nla2bv_max_bv_size", p.get_uint("nla2bv_max_bv_size", bv_size)); return and_then(mk_nla2bv_tactic(m, nra2sat_p), mk_smt_tactic(), @@ -34,11 +34,11 @@ static tactic * mk_qfnra_sat_solver(ast_manager& m, params_ref const& p, unsigne tactic * mk_qfnra_tactic(ast_manager & m, params_ref const& p) { params_ref p1 = p; - p1.set_uint(":seed", 11); - p1.set_bool(":factor", false); + p1.set_uint("seed", 11); + p1.set_bool("factor", false); params_ref p2 = p; - p2.set_uint(":seed", 13); - p2.set_bool(":factor", false); + p2.set_uint("seed", 13); + p2.set_bool("factor", false); return and_then(mk_simplify_tactic(m, p), mk_propagate_values_tactic(m, p), diff --git a/src/tactic/smtlogics/qfuf_tactic.cpp b/src/tactic/smtlogics/qfuf_tactic.cpp index 3acfb8d98..567325f6a 100644 --- a/src/tactic/smtlogics/qfuf_tactic.cpp +++ b/src/tactic/smtlogics/qfuf_tactic.cpp @@ -26,9 +26,9 @@ Notes: tactic * mk_qfuf_tactic(ast_manager & m, params_ref const & p) { params_ref s2_p; - s2_p.set_bool(":pull-cheap-ite", true); - s2_p.set_bool(":local-ctx", true); - s2_p.set_uint(":local-ctx-limit", 10000000); + s2_p.set_bool("pull_cheap_ite", true); + s2_p.set_bool("local_ctx", true); + s2_p.set_uint("local_ctx_limit", 10000000); return and_then(mk_simplify_tactic(m, p), mk_propagate_values_tactic(m, p), mk_solve_eqs_tactic(m, p), diff --git a/src/tactic/smtlogics/qfufbv_tactic.cpp b/src/tactic/smtlogics/qfufbv_tactic.cpp index 400ff9891..d10b7c1b4 100644 --- a/src/tactic/smtlogics/qfufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfufbv_tactic.cpp @@ -28,8 +28,8 @@ Notes: tactic * mk_qfufbv_tactic(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":blast-distinct", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("blast_distinct", true); tactic * preamble_st = and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), diff --git a/src/tactic/smtlogics/quant_tactics.cpp b/src/tactic/smtlogics/quant_tactics.cpp index 4bb896c74..6b5ede813 100644 --- a/src/tactic/smtlogics/quant_tactics.cpp +++ b/src/tactic/smtlogics/quant_tactics.cpp @@ -27,13 +27,13 @@ Revision History: static tactic * mk_quant_preprocessor(ast_manager & m, bool disable_gaussian = false) { params_ref pull_ite_p; - pull_ite_p.set_bool(":pull-cheap-ite", true); - pull_ite_p.set_bool(":local-ctx", true); - pull_ite_p.set_uint(":local-ctx-limit", 10000000); + pull_ite_p.set_bool("pull_cheap_ite", true); + pull_ite_p.set_bool("local_ctx", true); + pull_ite_p.set_uint("local_ctx_limit", 10000000); params_ref ctx_simp_p; - ctx_simp_p.set_uint(":max-depth", 30); - ctx_simp_p.set_uint(":max-steps", 5000000); + ctx_simp_p.set_uint("max_depth", 30); + ctx_simp_p.set_uint("max_steps", 5000000); tactic * solve_eqs; if (disable_gaussian) @@ -71,8 +71,8 @@ tactic * mk_uflra_tactic(ast_manager & m, params_ref const & p) { tactic * mk_auflia_tactic(ast_manager & m, params_ref const & p) { params_ref qi_p; - qi_p.set_str(":qi-cost", "0"); - TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str("qi_cost", "") << "\n";); + qi_p.set_str("qi.cost", "0"); + TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str("qi.cost", "") << "\n";); tactic * st = and_then(mk_no_solve_eq_preprocessor(m), or_else(and_then(fail_if(mk_gt(mk_num_exprs_probe(), mk_const_probe(static_cast(128)))), using_params(mk_smt_tactic(), qi_p), diff --git a/src/tactic/ufbv/ufbv_tactic.cpp b/src/tactic/ufbv/ufbv_tactic.cpp index 85ec506aa..80d403b67 100644 --- a/src/tactic/ufbv/ufbv_tactic.cpp +++ b/src/tactic/ufbv/ufbv_tactic.cpp @@ -37,7 +37,7 @@ tactic * mk_der_fp_tactic(ast_manager & m, params_ref const & p) { tactic * mk_ufbv_preprocessor_tactic(ast_manager & m, params_ref const & p) { params_ref no_elim_and(p); - no_elim_and.set_bool(":elim-and", false); + no_elim_and.set_bool("elim_and", false); return and_then( mk_trace_tactic("ufbv_pre"), @@ -61,10 +61,10 @@ tactic * mk_ufbv_preprocessor_tactic(ast_manager & m, params_ref const & p) { tactic * mk_ufbv_tactic(ast_manager & m, params_ref const & p) { params_ref main_p(p); - main_p.set_bool(":mbqi", true); - main_p.set_uint(":mbqi-max-iterations", -1); - main_p.set_bool(":elim-and", true); - main_p.set_bool(":solver", true); + main_p.set_bool("mbqi", true); + main_p.set_uint("mbqi_max_iterations", -1); + main_p.set_bool("elim_and", true); + main_p.set_bool("solver", true); tactic * t = and_then(repeat(mk_ufbv_preprocessor_tactic(m, main_p), 2), mk_smt_tactic_using(false, main_p)); diff --git a/src/test/dl_context.cpp b/src/test/dl_context.cpp index c004c531f..ff7548abc 100644 --- a/src/test/dl_context.cpp +++ b/src/test/dl_context.cpp @@ -72,9 +72,9 @@ void tst_dl_context() { params_ref params; for(unsigned rel_index=0; rel_index=0; eager_checking--) { - params.set_bool(":eager-emptiness-checking", eager_checking!=0); + params.set_bool("eager_emptiness_checking", eager_checking!=0); std::cerr << "Testing " << relations[rel_index] << "\n"; std::cerr << "Eager emptiness checking " << (eager_checking!=0 ? "on" : "off") << "\n"; diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index 4b67b32af..e58634ec8 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -343,7 +343,7 @@ void tst_dl_product_relation() { test_functional_columns(fparams, params); - params.set_sym(":default-relation", symbol("tr_sparse")); + params.set_sym("default_relation", symbol("tr_sparse")); test_finite_product_relation(fparams, params); } diff --git a/src/test/dl_query.cpp b/src/test/dl_query.cpp index 712ae386a..ad21247af 100644 --- a/src/test/dl_query.cpp +++ b/src/test/dl_query.cpp @@ -50,7 +50,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, dl_decl_util decl_util(m); context ctx_q(m, fparams); - params.set_bool(":magic-sets-for-queries", use_magic_sets); + params.set_bool("magic_sets_for_queries", use_magic_sets); ctx_q.updt_params(params); { parser* p = parser::create(ctx_q,m); @@ -125,7 +125,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, } void dl_query_test_wpa(smt_params & fparams, params_ref& params) { - params.set_bool(":magic-sets-for-queries", true); + params.set_bool("magic_sets_for_queries", true); ast_manager m; reg_decl_plugins(m); arith_util arith(m); @@ -185,8 +185,8 @@ void dl_query_test_wpa(smt_params & fparams, params_ref& params) { void tst_dl_query() { smt_params fparams; params_ref params; - params.set_sym(":default-table", symbol("sparse")); - params.set_sym(":default-relation", symbol("tr_sparse")); + params.set_sym("default_table", symbol("sparse")); + params.set_sym("default_relation", symbol("tr_sparse")); //params.m_dl_default_table = symbol("hashtable"); //params.m_dl_default_relation = symbol("tr_hashtable"); @@ -212,9 +212,9 @@ void tst_dl_query() { ctx_base.dl_saturate(); for(unsigned use_restarts=0; use_restarts<=1; use_restarts++) { - params.set_uint(":initial-restart-timeout", use_restarts ? 100 : 0); + params.set_uint("initial_restart_timeout", use_restarts ? 100 : 0); for(unsigned use_similar=0; use_similar<=1; use_similar++) { - params.set_uint(":similarity-compressor", use_similar != 0); + params.set_uint("similarity_compressor", use_similar != 0); for(unsigned use_magic_sets=0; use_magic_sets<=1; use_magic_sets++) { stopwatch watch; diff --git a/src/util/debug.cpp b/src/util/debug.cpp index 41e0a48fc..75ea8586a 100644 --- a/src/util/debug.cpp +++ b/src/util/debug.cpp @@ -22,6 +22,7 @@ Revision History: #endif #include #include"str_hashtable.h" +#include"z3_exception.h" volatile bool g_enable_assertions = true; @@ -73,7 +74,7 @@ void invoke_gdb() { char buffer[1024]; int * x = 0; for (;;) { - std::cerr << "(C)ontinue, (A)bort, (S)top, Invoke (G)DB\n"; + std::cerr << "(C)ontinue, (A)bort, (S)top, (T)hrow exception, Invoke (G)DB\n"; char result; std::cin >> result; switch(result) { @@ -88,6 +89,9 @@ void invoke_gdb() { // force seg fault... *x = 0; return; + case 't': + case 'T': + throw default_exception("assertion violation"); case 'G': case 'g': sprintf(buffer, "gdb -nw /proc/%d/exe %d", getpid(), getpid()); diff --git a/src/util/params.cpp b/src/util/params.cpp index c0b8653ae..f302f7721 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -21,6 +21,29 @@ Notes: #include"symbol.h" #include"dictionary.h" +std::string norm_param_name(char const * n) { + if (n == 0) + return "_"; + if (*n == ':') + n++; + std::string r = n; + unsigned sz = r.size(); + if (sz == 0) + return "_"; + for (unsigned i = 0; i < sz; i++) { + char curr = r[i]; + if ('A' <= curr && curr <= 'Z') + r[i] = curr - 'A' + 'a'; + else if (curr == '-' || curr == ':') + r[i] = '_'; + } + return r; +} + +std::string norm_param_name(symbol const & n) { + return norm_param_name(n.bare_str()); +} + struct param_descrs::imp { struct info { param_kind m_kind; diff --git a/src/util/params.h b/src/util/params.h index 164de9ab3..13850758c 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -22,6 +22,9 @@ Notes: #include"cmd_context_types.h" #include"vector.h" +std::string norm_param_name(char const * n); +std::string norm_param_name(symbol const & n); + typedef cmd_arg_kind param_kind; class params; From 67183ea08a5694751d006c13f3d7bc2a70e9a385 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 3 Dec 2012 15:05:43 -0800 Subject: [PATCH 102/133] factor out relation context for datalog Signed-off-by: Nikolaj Bjorner --- src/api/api_datalog.cpp | 4 +- src/muz_qe/datalog_parser.cpp | 3 - src/muz_qe/dl_bmc_engine.cpp | 1 - src/muz_qe/dl_compiler.cpp | 8 +- src/muz_qe/dl_context.cpp | 482 +++---------------- src/muz_qe/dl_context.h | 66 +-- src/muz_qe/dl_costs.cpp | 2 +- src/muz_qe/dl_costs.h | 2 +- src/muz_qe/dl_instruction.cpp | 74 +-- src/muz_qe/dl_instruction.h | 18 +- src/muz_qe/dl_mk_explanations.cpp | 6 +- src/muz_qe/dl_mk_magic_sets.cpp | 2 +- src/muz_qe/dl_mk_partial_equiv.cpp | 2 +- src/muz_qe/dl_mk_rule_inliner.cpp | 2 +- src/muz_qe/dl_mk_similarity_compressor.cpp | 2 +- src/muz_qe/dl_mk_simple_joins.cpp | 9 +- src/muz_qe/dl_mk_subsumption_checker.cpp | 2 +- src/muz_qe/dl_mk_unbound_compressor.cpp | 2 +- src/muz_qe/dl_rule.cpp | 2 +- src/muz_qe/fixedpoint_params.pyg | 34 +- src/muz_qe/pdr_dl_interface.cpp | 1 - src/muz_qe/rel_context.cpp | 517 +++++++++++++++++++++ src/muz_qe/rel_context.h | 115 +++++ src/shell/datalog_frontend.cpp | 12 +- 24 files changed, 799 insertions(+), 569 deletions(-) create mode 100644 src/muz_qe/rel_context.cpp create mode 100644 src/muz_qe/rel_context.h diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 9b7093d1e..28fe3ed33 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -48,7 +48,7 @@ namespace api { if (!m.has_plugin(name)) { m.register_plugin(name, alloc(datalog::dl_decl_plugin)); } - datalog::relation_manager& r = m_context.get_rmanager(); + datalog::relation_manager& r = m_context.get_rel_context().get_rmanager(); r.register_plugin(alloc(datalog::external_relation_plugin, *this, r)); } @@ -295,7 +295,7 @@ extern "C" { { scoped_timer timer(timeout, &eh); try { - r = to_fixedpoint_ref(d)->ctx().dl_query(num_relations, to_func_decls(relations)); + r = to_fixedpoint_ref(d)->ctx().rel_query(num_relations, to_func_decls(relations)); } catch (z3_exception& ex) { mk_c(c)->handle_exception(ex); diff --git a/src/muz_qe/datalog_parser.cpp b/src/muz_qe/datalog_parser.cpp index afda12858..cfe283410 100644 --- a/src/muz_qe/datalog_parser.cpp +++ b/src/muz_qe/datalog_parser.cpp @@ -1326,9 +1326,6 @@ private: throw default_exception("tuple file %s for undeclared predicate %s", m_current_file.c_str(), predicate_name.bare_str()); } - if(!m_context.can_add_table_fact(pred)) { - NOT_IMPLEMENTED_YET(); - } unsigned pred_arity = pred->get_arity(); sort * const * arg_sorts = pred->get_domain(); diff --git a/src/muz_qe/dl_bmc_engine.cpp b/src/muz_qe/dl_bmc_engine.cpp index dd35cc870..27161320e 100644 --- a/src/muz_qe/dl_bmc_engine.cpp +++ b/src/muz_qe/dl_bmc_engine.cpp @@ -57,7 +57,6 @@ namespace datalog { m_ctx.ensure_opened(); m_rules.reset(); - m_ctx.get_rmanager().reset_relations(); datalog::rule_manager& rule_manager = m_ctx.get_rule_manager(); datalog::rule_set old_rules(m_ctx.get_rules()); datalog::rule_ref_vector query_rules(rule_manager); diff --git a/src/muz_qe/dl_compiler.cpp b/src/muz_qe/dl_compiler.cpp index 99c7b86f5..d403b5b5c 100644 --- a/src/muz_qe/dl_compiler.cpp +++ b/src/muz_qe/dl_compiler.cpp @@ -42,7 +42,7 @@ namespace datalog { return; } relation_signature sig; - m_context.get_rmanager().from_predicate(pred, sig); + m_context.get_rel_context().get_rmanager().from_predicate(pred, sig); reg_idx reg = get_fresh_register(sig); e->get_data().m_value=reg; @@ -563,7 +563,7 @@ namespace datalog { } SASSERT(is_app(e)); relation_sort arg_sort; - m_context.get_rmanager().from_predicate(neg_pred, i, arg_sort); + m_context.get_rel_context().get_rmanager().from_predicate(neg_pred, i, arg_sort); reg_idx new_reg; make_add_constant_column(head_pred, filtered_res, arg_sort, to_app(e), new_reg, acc); @@ -1096,7 +1096,7 @@ namespace datalog { func_decl_set::iterator fdit = preds.begin(); func_decl_set::iterator fdend = preds.end(); for(; fdit!=fdend; ++fdit) { - if(!m_context.get_rmanager().is_saturated(*fdit)) { + if(!m_context.get_rel_context().get_rmanager().is_saturated(*fdit)) { return false; } } @@ -1181,7 +1181,7 @@ namespace datalog { acc.set_observer(0); - TRACE("dl", execution_code.display(m_context, tout);); + TRACE("dl", execution_code.display(m_context.get_rel_context(), tout);); } diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 228dbc572..0f9f1d520 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -24,18 +24,12 @@ Revision History: #include"arith_decl_plugin.h" #include"bv_decl_plugin.h" #include"dl_table.h" -#include"dl_sparse_table.h" #include"dl_table_relation.h" -#include"dl_bound_relation.h" -#include"dl_interval_relation.h" -#include"dl_finite_product_relation.h" -#include"dl_product_relation.h" #include"dl_rule_transformer.h" #include"dl_mk_coi_filter.h" #include"dl_mk_explanations.h" #include"dl_mk_filter_rules.h" #include"dl_mk_interp_tail_simplifier.h" -#include"dl_mk_magic_sets.h" #include"dl_mk_rule_inliner.h" #include"dl_mk_simple_joins.h" #include"dl_mk_similarity_compressor.h" @@ -44,9 +38,6 @@ Revision History: #include"dl_compiler.h" #include"dl_instruction.h" #include"dl_context.h" -#ifndef _EXTERNAL_RELEASE -#include"dl_skip_table.h" -#endif #include"for_each_expr.h" #include"ast_smt_pp.h" #include"ast_smt2_pp.h" @@ -189,7 +180,6 @@ namespace datalog { virtual ~restore_rules() {} virtual void undo(context& ctx) { - ctx.reset_tables(); ctx.replace_rules(*m_old_rules); reset(); } @@ -209,7 +199,6 @@ namespace datalog { m_trail.push_scope(); m_trail.push(restore_rules(m_rule_set)); m_trail.push(restore_vec_size_trail(m_background)); - m_trail.push(restore_vec_size_trail(m_table_facts)); } void context::pop() { @@ -233,7 +222,6 @@ namespace datalog { m_decl_util(m), m_rewriter(m), m_var_subst(m), - m_rmanager(*this), m_rule_manager(*this), m_trail(*this), m_pinned(m), @@ -243,25 +231,11 @@ namespace datalog { m_background(m), m_closed(false), m_saturation_was_run(false), - m_last_result_relation(0), m_last_answer(m), m_engine(LAST_ENGINE), m_cancel(false) { //register plugins for builtin tables - get_rmanager().register_plugin(alloc(sparse_table_plugin, get_rmanager())); - get_rmanager().register_plugin(alloc(hashtable_table_plugin, get_rmanager())); - get_rmanager().register_plugin(alloc(bitvector_table_plugin, get_rmanager())); - get_rmanager().register_plugin(alloc(equivalence_table_plugin, get_rmanager())); - -#ifndef _EXTERNAL_RELEASE - get_rmanager().register_plugin(alloc(skip_table_plugin, get_rmanager())); -#endif - - //register plugins for builtin relations - - get_rmanager().register_plugin(alloc(bound_relation_plugin, get_rmanager())); - get_rmanager().register_plugin(alloc(interval_relation_plugin, get_rmanager())); } context::~context() { @@ -272,14 +246,12 @@ namespace datalog { m_trail.reset(); m_rule_set.reset(); m_argument_var_names.reset(); - m_output_preds.reset(); m_preds.reset(); m_preds_by_name.reset(); reset_dealloc_values(m_sorts); - if (m_last_result_relation) { - m_last_result_relation->deallocate(); - m_last_result_relation = 0; - } + m_pdr = 0; + m_bmc = 0; + m_rel = 0; } bool context::is_fact(app * head) const { @@ -455,59 +427,13 @@ namespace datalog { return e->get_data().m_value[arg_index]; } - relation_plugin & context::get_ordinary_relation_plugin(symbol relation_name) { - relation_plugin * plugin = get_rmanager().get_relation_plugin(relation_name); - if (!plugin) { - std::stringstream sstm; - sstm << "relation plugin " << relation_name << " does not exist"; - throw default_exception(sstm.str()); - } - if (plugin->is_product_relation()) { - throw default_exception("cannot request product relation directly"); - } - if (plugin->is_sieve_relation()) { - throw default_exception("cannot request sieve relation directly"); - } - if (plugin->is_finite_product_relation()) { - throw default_exception("cannot request finite product relation directly"); - } - return *plugin; - } void context::set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, symbol const * relation_names) { - relation_manager & rmgr = get_rmanager(); - - family_id target_kind = null_family_id; - switch (relation_name_cnt) { - case 0: - return; - case 1: - target_kind = get_ordinary_relation_plugin(relation_names[0]).get_kind(); - break; - default: { - svector rel_kinds; // kinds of plugins that are not table plugins - family_id rel_kind; // the aggregate kind of non-table plugins - for (unsigned i = 0; i < relation_name_cnt; i++) { - relation_plugin & p = get_ordinary_relation_plugin(relation_names[i]); - rel_kinds.push_back(p.get_kind()); - } - if (rel_kinds.size() == 1) { - rel_kind = rel_kinds[0]; - } - else { - relation_signature rel_sig; - //rmgr.from_predicate(pred, rel_sig); - product_relation_plugin & prod_plugin = product_relation_plugin::get_plugin(rmgr); - rel_kind = prod_plugin.get_relation_kind(rel_sig, rel_kinds); - } - target_kind = rel_kind; - break; - } + if (relation_name_cnt > 0) { + ensure_rel(); + m_rel->set_predicate_representation(pred, relation_name_cnt, relation_names); } - - SASSERT(target_kind != null_family_id); - get_rmanager().set_predicate_kind(pred, target_kind); } func_decl * context::mk_fresh_head_predicate(symbol const & prefix, symbol const & suffix, @@ -517,19 +443,25 @@ namespace datalog { register_predicate(new_pred); - if (orig_pred) { - family_id target_kind = get_rmanager().get_requested_predicate_kind(orig_pred); - if (target_kind != null_family_id) { - get_rmanager().set_predicate_kind(new_pred, target_kind); - } + if (m_rel.get()) { + m_rel->inherit_predicate_kind(new_pred, orig_pred); } return new_pred; } void context::set_output_predicate(func_decl * pred) { - if (!m_output_preds.contains(pred)) { - m_output_preds.insert(pred); - } + ensure_rel(); + m_rel->set_output_predicate(pred); + } + + bool context::is_output_predicate(func_decl * pred) { + ensure_rel(); + return m_rel->is_output_predicate(pred); + } + + const decl_set & context::get_output_predicates() { + ensure_rel(); + return m_rel->get_output_predicates(); } void context::add_rule(expr* rl, symbol const& name) { @@ -562,7 +494,6 @@ namespace datalog { throw default_exception(strm.str()); } rule_ref r(rules[0].get(), rm); - get_rmanager().reset_saturated_marks(); rule_ref_vector const& rls = m_rule_set.get_rules(); rule* old_rule = 0; for (unsigned i = 0; i < rls.size(); ++i) { @@ -795,7 +726,6 @@ namespace datalog { } void context::add_rule(rule_ref& r) { - get_rmanager().reset_saturated_marks(); m_rule_set.add_rule(r); } @@ -809,12 +739,10 @@ namespace datalog { void context::add_fact(func_decl * pred, const relation_fact & fact) { if (get_engine() == DATALOG_ENGINE) { - get_rmanager().reset_saturated_marks(); - get_relation(pred).add_fact(fact); - m_table_facts.push_back(std::make_pair(pred, fact)); + ensure_rel(); + m_rel->add_fact(pred, fact); } else { - ast_manager& m = get_manager(); expr_ref rule(m.mk_app(pred, fact.size(), (expr*const*)fact.c_ptr()), m); add_rule(rule, symbol::null); } @@ -832,26 +760,18 @@ namespace datalog { add_fact(head->get_decl(), fact); } - bool context::can_add_table_fact(func_decl * pred) { - return get_relation(pred).from_table(); - } - void context::add_table_fact(func_decl * pred, const table_fact & fact) { - relation_base & rel0 = get_relation(pred); - if (get_engine() != DATALOG_ENGINE || - !can_add_table_fact(pred) || - !rel0.from_table()) { + if (get_engine() == DATALOG_ENGINE) { + ensure_rel(); + m_rel->add_fact(pred, fact); + } + else { relation_fact rfact(m); for (unsigned i = 0; i < fact.size(); ++i) { rfact.push_back(m_decl_util.mk_numeral(fact[i], pred->get_domain()[i])); } add_fact(pred, rfact); } - else { - get_rmanager().reset_saturated_marks(); - table_relation & rel = static_cast(rel0); - rel.add_table_fact(fact); - } } void context::add_table_fact(func_decl * pred, unsigned num_args, unsigned args[]) { @@ -968,117 +888,14 @@ namespace datalog { if (m_pdr.get()) m_pdr->updt_params(); } - void context::collect_predicates(decl_set & res) { - unsigned rule_cnt = m_rule_set.get_num_rules(); - for (unsigned rindex=0; rindexget_head()->get_decl()); - unsigned tail_len = r->get_uninterpreted_tail_size(); - for (unsigned tindex=0; tindexget_tail(tindex)->get_decl()); - } - } - decl_set::iterator oit = m_output_preds.begin(); - decl_set::iterator oend = m_output_preds.end(); - for (; oit!=oend; ++oit) { - res.insert(*oit); - } - get_rmanager().collect_predicates(res); + void context::collect_predicates(decl_set& res) { + ensure_rel(); + m_rel->collect_predicates(res); } - - void context::restrict_predicates( const decl_set & res ) { - set_intersection(m_output_preds, res); - get_rmanager().restrict_predicates(res); - } - - lbool context::dl_saturate() { - if (!m_closed) { - close(); - } - bool time_limit = soft_timeout()!=0; - unsigned remaining_time_limit = soft_timeout(); - unsigned restart_time = initial_restart_timeout(); - - rule_set original_rules(get_rules()); - decl_set original_predicates; - collect_predicates(original_predicates); - - instruction_block rules_code; - instruction_block termination_code; - execution_context ex_ctx(*this); - lbool result; - - TRACE("dl", display(tout);); - - while (true) { - model_converter_ref mc; // Ignored in Datalog mode - proof_converter_ref pc; // Ignored in Datalog mode - transform_rules(mc, pc); - compiler::compile(*this, get_rules(), rules_code, termination_code); - - TRACE("dl", rules_code.display(*this, tout); ); - - bool timeout_after_this_round = time_limit && (restart_time==0 || remaining_time_limit<=restart_time); - - if (time_limit || restart_time!=0) { - unsigned timeout = time_limit ? (restart_time!=0) ? - std::min(remaining_time_limit, restart_time) - : remaining_time_limit : restart_time; - ex_ctx.set_timelimit(timeout); - } - - bool early_termination = !rules_code.perform(ex_ctx); - ex_ctx.reset_timelimit(); - VERIFY( termination_code.perform(ex_ctx) ); - - rules_code.process_all_costs(); - - IF_VERBOSE(10, ex_ctx.report_big_relations(1000, verbose_stream());); - - if (!early_termination) { - m_last_status = OK; - result = l_true; - break; - } - - if (memory::above_high_watermark()) { - m_last_status = MEMOUT; - result = l_undef; - break; - } - if (timeout_after_this_round || m_cancel) { - m_last_status = TIMEOUT; - result = l_undef; - break; - } - SASSERT(restart_time!=0); - if (time_limit) { - SASSERT(remaining_time_limit>restart_time); - remaining_time_limit-=restart_time; - } - uint64 new_restart_time = static_cast(restart_time)*initial_restart_timeout(); - if (new_restart_time>UINT_MAX) { - restart_time=UINT_MAX; - } - else { - restart_time=static_cast(new_restart_time); - } - - rules_code.reset(); - termination_code.reset(); - ex_ctx.reset(); - reopen(); - restrict_predicates(original_predicates); - replace_rules(original_rules); - close(); - } - reopen(); - restrict_predicates(original_predicates); - replace_rules(original_rules); - close(); - TRACE("dl", ex_ctx.report_big_relations(100, tout);); - return result; + void context::restrict_predicates(decl_set const& res) { + ensure_rel(); + m_rel->restrict_predicates(res); } expr_ref context::get_background_assertion() { @@ -1101,6 +918,7 @@ namespace datalog { m_cancel = true; if (m_pdr.get()) m_pdr->cancel(); if (m_bmc.get()) m_bmc->cancel(); + if (m_rel.get()) m_rel->cancel(); } void context::cleanup() { @@ -1180,7 +998,7 @@ namespace datalog { switch(get_engine()) { case DATALOG_ENGINE: - return dl_query(query); + return rel_query(query); case PDR_ENGINE: case QPDR_ENGINE: return pdr_query(query); @@ -1189,18 +1007,14 @@ namespace datalog { return bmc_query(query); default: UNREACHABLE(); - return dl_query(query); + return rel_query(query); } } void context::new_query() { flush_add_rules(); - if (m_last_result_relation) { - m_last_result_relation->deallocate(); - m_last_result_relation = 0; - } m_last_status = OK; - m_last_answer = get_manager().mk_true(); + m_last_answer = 0; } model_ref context::get_model() { @@ -1233,7 +1047,6 @@ namespace datalog { lbool context::pdr_query(expr* query) { ensure_pdr(); - m_last_answer = 0; return m_pdr->query(query); } @@ -1245,218 +1058,25 @@ namespace datalog { lbool context::bmc_query(expr* query) { ensure_bmc(); - m_last_answer = 0; return m_bmc->query(query); } -#define BEGIN_QUERY() \ - rule_set original_rules(get_rules()); \ - decl_set original_preds; \ - collect_predicates(original_preds); \ - bool was_closed = m_closed; \ - if (m_closed) { \ - reopen(); \ - } \ - -#define END_QUERY() \ - reopen(); \ - replace_rules(original_rules); \ - restrict_predicates(original_preds); \ - \ - if (was_closed) { \ - close(); \ - } \ - - lbool context::dl_query(unsigned num_rels, func_decl * const* rels) { - BEGIN_QUERY(); - for (unsigned i = 0; i < num_rels; ++i) { - set_output_predicate(rels[i]); + void context::ensure_rel() { + if (!m_rel.get()) { + m_rel = alloc(rel_context, *this); } - close(); - reset_negated_tables(); - lbool res = dl_saturate(); + } - switch(res) { - case l_true: { - expr_ref_vector ans(m); - expr_ref e(m); - bool some_non_empty = num_rels == 0; - for (unsigned i = 0; i < num_rels; ++i) { - relation_base& rel = get_relation(rels[i]); - if (!rel.empty()) { - some_non_empty = true; - } - rel.to_formula(e); - ans.push_back(e); - } - SASSERT(!m_last_result_relation); - if (some_non_empty) { - m_last_answer = m.mk_and(ans.size(), ans.c_ptr()); - } - else { - m_last_answer = m.mk_false(); - res = l_false; - } - break; - } - case l_false: - m_last_answer = m.mk_false(); - break; - case l_undef: - break; - } - END_QUERY(); - return res; + lbool context::rel_query(unsigned num_rels, func_decl * const* rels) { + ensure_rel(); + return m_rel->query(num_rels, rels); } - lbool context::dl_query(expr* query) { - BEGIN_QUERY(); - rule_manager& rm = get_rule_manager(); - rule_ref qrule(rm); - rule_ref_vector qrules(rm); - func_decl_ref query_pred(get_manager()); - try { - rm.mk_query(query, query_pred, qrules, qrule); - } - catch(default_exception& exn) { - close(); - m_last_status = INPUT_ERROR; - throw exn; - } - try { - add_rules(qrules); - } - catch (default_exception& exn) { - close(); - m_last_status = INPUT_ERROR; - throw exn; - } - - set_output_predicate(qrule->get_head()->get_decl()); - close(); - reset_negated_tables(); - - if (generate_explanations()) { - model_converter_ref mc; // ignored in Datalog mode - proof_converter_ref pc; // ignored in Datalog mode - rule_transformer transformer(*this); - //expl_plugin is deallocated when transformer goes out of scope - mk_explanations * expl_plugin = - alloc(mk_explanations, *this, explanations_on_relation_level()); - transformer.register_plugin(expl_plugin); - transform_rules(transformer, mc, pc); - - //we will retrieve the predicate with explanations instead of the original query predicate - query_pred = expl_plugin->get_e_decl(query_pred); - const rule_vector & query_rules = get_rules().get_predicate_rules(query_pred); - SASSERT(query_rules.size()==1); - qrule = query_rules.back(); - } - - if (magic_sets_for_queries()) { - model_converter_ref mc; // Ignored in Datalog mode - proof_converter_ref pc; // Ignored in Datalog mode - rule_transformer transformer(*this); - transformer.register_plugin(alloc(mk_magic_sets, *this, qrule.get())); - transform_rules(transformer, mc, pc); - } - - lbool res = dl_saturate(); - - if (res != l_undef) { - m_last_result_relation = get_relation(query_pred).clone(); - if (m_last_result_relation->empty()) { - res = l_false; - m_last_answer = m.mk_false(); - } - else { - m_last_result_relation->to_formula(m_last_answer); - } - } - - END_QUERY(); - return res; + lbool context::rel_query(expr* query) { + ensure_rel(); + return m_rel->query(query); } - void context::reset_tables() { - get_rmanager().reset_saturated_marks(); - rule_set::decl2rules::iterator it = m_rule_set.begin_grouped_rules(); - rule_set::decl2rules::iterator end = m_rule_set.end_grouped_rules(); - for (; it != end; ++it) { - func_decl* p = it->m_key; - relation_base & rel = get_relation(p); - rel.reset(); - } - for (unsigned i = 0; i < m_table_facts.size(); ++i) { - func_decl* pred = m_table_facts[i].first; - relation_fact const& fact = m_table_facts[i].second; - get_relation(pred).add_fact(fact); - } - } - - void context::reset_negated_tables() { - rule_set::pred_set_vector const & pred_sets = m_rule_set.get_strats(); - bool non_empty = false; - for (unsigned i = 1; i < pred_sets.size(); ++i) { - func_decl_set::iterator it = pred_sets[i]->begin(), end = pred_sets[i]->end(); - for (; it != end; ++it) { - func_decl* pred = *it; - relation_base & rel = get_relation(pred); - if (!rel.empty()) { - non_empty = true; - break; - } - } - } - if (!non_empty) { - return; - } - // collect predicates that depend on negation. - func_decl_set depends_on_negation; - for (unsigned i = 1; i < pred_sets.size(); ++i) { - bool change = true; - while (change) { - change = false; - func_decl_set::iterator it = pred_sets[i]->begin(), end = pred_sets[i]->end(); - for (; it != end; ++it) { - func_decl* pred = *it; - if (depends_on_negation.contains(pred)) { - continue; - } - rule_vector const& rules = m_rule_set.get_predicate_rules(pred); - bool inserted = false; - for (unsigned j = 0; !inserted && j < rules.size(); ++j) { - rule* r = rules[j]; - unsigned psz = r->get_positive_tail_size(); - unsigned tsz = r->get_uninterpreted_tail_size(); - if (psz < tsz) { - depends_on_negation.insert(pred); - change = true; - inserted = true; - } - for (unsigned k = 0; !inserted && k < tsz; ++k) { - func_decl* tail_decl = r->get_tail(k)->get_decl(); - if (depends_on_negation.contains(tail_decl)) { - depends_on_negation.insert(pred); - change = true; - inserted = true; - } - } - } - } - } - } - func_decl_set::iterator it = depends_on_negation.begin(), end = depends_on_negation.end(); - for (; it != end; ++it) { - func_decl* pred = *it; - relation_base & rel = get_relation(pred); - - if (!rel.empty()) { - TRACE("dl", tout << "Resetting: " << mk_ismt2_pp(pred, m) << "\n";); - rel.reset(); - } - } - } expr* context::get_answer_as_formula() { if (m_last_answer) { @@ -1473,6 +1093,10 @@ namespace datalog { ensure_bmc(); m_last_answer = m_bmc->get_answer(); return m_last_answer.get(); + case DATALOG_ENGINE: + ensure_rel(); + m_last_answer = m_rel->get_last_answer(); + return m_last_answer.get(); default: UNREACHABLE(); } @@ -1533,8 +1157,8 @@ namespace datalog { execution_result context::get_status() { return m_last_status; } bool context::result_contains_fact(relation_fact const& f) { - SASSERT(m_last_result_relation); - return m_last_result_relation->contains_fact(f); + ensure_rel(); + return m_rel->result_contains_fact(f); } // TBD: algebraic data-types declarations will not be printed. diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index 5dcb3e1fa..89446ce3b 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -35,11 +35,11 @@ Revision History: #include"dl_rule_set.h" #include"pdr_dl_interface.h" #include"dl_bmc_engine.h" +#include"rel_context.h" #include"lbool.h" #include"statistics.h" #include"params.h" #include"trail.h" -#include"dl_external_relation.h" #include"model_converter.h" #include"proof_converter.h" #include"model2expr.h" @@ -75,7 +75,6 @@ namespace datalog { typedef map sym2decl; typedef obj_map > pred2syms; typedef obj_map sort_domain_map; - typedef vector > fact_vector; ast_manager & m; smt_params & m_fparams; @@ -84,7 +83,6 @@ namespace datalog { dl_decl_util m_decl_util; th_rewriter m_rewriter; var_subst m_var_subst; - relation_manager m_rmanager; rule_manager m_rule_manager; trail_stack m_trail; @@ -94,7 +92,6 @@ namespace datalog { func_decl_set m_preds; sym2decl m_preds_by_name; pred2syms m_argument_var_names; - decl_set m_output_preds; rule_set m_rule_set; expr_ref_vector m_rule_fmls; svector m_rule_names; @@ -102,23 +99,20 @@ namespace datalog { scoped_ptr m_pdr; scoped_ptr m_bmc; + scoped_ptr m_rel; bool m_closed; bool m_saturation_was_run; execution_result m_last_status; - relation_base * m_last_result_relation; expr_ref m_last_answer; DL_ENGINE m_engine; volatile bool m_cancel; - fact_vector m_table_facts; bool is_fact(app * head) const; bool has_sort_domain(relation_sort s) const; sort_domain & get_sort_domain(relation_sort s); const sort_domain & get_sort_domain(relation_sort s) const; - relation_plugin & get_ordinary_relation_plugin(symbol relation_name); - class engine_type_proc; @@ -130,25 +124,12 @@ namespace datalog { void push(); void pop(); - relation_base & get_relation(func_decl * pred) { return get_rmanager().get_relation(pred); } - relation_base * try_get_relation(func_decl * pred) const { return get_rmanager().try_get_relation(pred); } - bool saturation_was_run() const { return m_saturation_was_run; } void notify_saturation_was_run() { m_saturation_was_run = true; } - /** - \brief Store the relation \c rel under the predicate \c pred. The \c context object - takes over the ownership of the relation object. - */ - void store_relation(func_decl * pred, relation_base * rel) { - get_rmanager().store_relation(pred, rel); - } - void configure_engine(); ast_manager & get_manager() const { return m; } - relation_manager & get_rmanager() { return m_rmanager; } - const relation_manager & get_rmanager() const { return m_rmanager; } rule_manager & get_rule_manager() { return m_rule_manager; } smt_params & get_fparams() const { return m_fparams; } fixedpoint_params const& get_params() const { return m_params; } @@ -247,8 +228,8 @@ namespace datalog { symbol const * relation_names); void set_output_predicate(func_decl * pred); - bool is_output_predicate(func_decl * pred) { return m_output_preds.contains(pred); } - const decl_set & get_output_predicates() const { return m_output_preds; } + bool is_output_predicate(func_decl * pred); + const decl_set & get_output_predicates(); rule_set const & get_rules() { flush_add_rules(); return m_rule_set; } @@ -314,7 +295,6 @@ namespace datalog { and there is no transformation of relation values before they are put into the table. */ - bool can_add_table_fact(func_decl * pred); void add_table_fact(func_decl * pred, const table_fact & fact); void add_table_fact(func_decl * pred, unsigned num_args, unsigned args[]); @@ -323,6 +303,7 @@ namespace datalog { */ void close(); void ensure_closed(); + bool is_closed() { return m_closed; } /** \brief Undo the effect of the \c close operation. @@ -351,13 +332,10 @@ namespace datalog { void display_rules(std::ostream & out) const { m_rule_set.display(out); } - void display_facts(std::ostream & out) const { - m_rmanager.display(out); - } void display(std::ostream & out) const { display_rules(out); - display_facts(out); + if (m_rel) m_rel->display_facts(out); } void display_smt2(unsigned num_queries, expr* const* queries, std::ostream& out); @@ -407,23 +385,16 @@ namespace datalog { /** Query multiple output relations. */ - lbool dl_query(unsigned num_rels, func_decl * const* rels); + lbool rel_query(unsigned num_rels, func_decl * const* rels); - /** - Reset tables that are under negation. - */ - void reset_negated_tables(); - - /** - Just reset all tables. - */ - void reset_tables(); /** \brief retrieve last proof status. */ execution_result get_status(); + void set_status(execution_result r) { m_last_status = r; } + /** \brief retrieve formula corresponding to query that returns l_true. The formula describes one or more instances of the existential variables @@ -446,29 +417,36 @@ namespace datalog { */ bool result_contains_fact(relation_fact const& f); +#if 0 /** \brief display facts generated for query. */ void display_output_facts(std::ostream & out) const { - m_rmanager.display_output_tables(out); + get_rel_context().get_rmanager().display_output_tables(out); } +#endif - /** - \brief expose datalog saturation for test. - */ - lbool dl_saturate(); + rel_context& get_rel_context() { ensure_rel(); return *m_rel; } private: + /** + Just reset all tables. + */ + void reset_tables(); + + void flush_add_rules(); void ensure_pdr(); void ensure_bmc(); + void ensure_rel(); + void new_query(); - lbool dl_query(expr* query); + lbool rel_query(expr* query); lbool pdr_query(expr* query); diff --git a/src/muz_qe/dl_costs.cpp b/src/muz_qe/dl_costs.cpp index 0b7641093..fe085d7f7 100644 --- a/src/muz_qe/dl_costs.cpp +++ b/src/muz_qe/dl_costs.cpp @@ -115,7 +115,7 @@ namespace datalog { } - void accounted_object::output_profile(context & ctx, std::ostream & out) const { + void accounted_object::output_profile(std::ostream & out) const { costs c; get_total_cost(c); c.output(out); diff --git a/src/muz_qe/dl_costs.h b/src/muz_qe/dl_costs.h index 0fc60451d..16cfc16b1 100644 --- a/src/muz_qe/dl_costs.h +++ b/src/muz_qe/dl_costs.h @@ -79,7 +79,7 @@ namespace datalog { void process_costs(); bool passes_output_thresholds(context & ctx) const; - void output_profile(context & ctx, std::ostream & out) const; + void output_profile(std::ostream & out) const; private: //private and undefined copy constructor and operator= to avoid the default ones diff --git a/src/muz_qe/dl_instruction.cpp b/src/muz_qe/dl_instruction.cpp index 9d6e9036f..503ffec3b 100644 --- a/src/muz_qe/dl_instruction.cpp +++ b/src/muz_qe/dl_instruction.cpp @@ -33,11 +33,11 @@ namespace datalog { // // ----------------------------------- - execution_context::execution_context(context & datalog_context) - : m_datalog_context(datalog_context), + execution_context::execution_context(context & context) + : m_context(context), m_stopwatch(0), m_timelimit_ms(0), - m_eager_emptiness_checking(datalog_context.eager_emptiness_checking()) {} + m_eager_emptiness_checking(context.eager_emptiness_checking()) {} execution_context::~execution_context() { reset(); @@ -135,12 +135,12 @@ namespace datalog { process_costs(); } - void instruction::display_indented(context & ctx, std::ostream & out, std::string indentation) const { + void instruction::display_indented(rel_context & ctx, std::ostream & out, std::string indentation) const { out << indentation; display_head_impl(ctx, out); if (ctx.output_profile()) { out << " {"; - output_profile(ctx, out); + output_profile(out); out << '}'; } out << "\n"; @@ -157,10 +157,10 @@ namespace datalog { virtual bool perform(execution_context & ctx) { if (m_store) { if (ctx.reg(m_reg)) { - ctx.get_datalog_context().store_relation(m_pred, ctx.release_reg(m_reg)); + ctx.get_rel_context().store_relation(m_pred, ctx.release_reg(m_reg)); } else { - context & dctx = ctx.get_datalog_context(); + rel_context & dctx = ctx.get_rel_context(); relation_base * empty_rel; //the object referenced by sig is valid only until we call dctx.store_relation() const relation_signature & sig = dctx.get_relation(m_pred).get_signature(); @@ -169,7 +169,7 @@ namespace datalog { } } else { - relation_base& rel = ctx.get_datalog_context().get_relation(m_pred); + relation_base& rel = ctx.get_rel_context().get_relation(m_pred); if ((!ctx.eager_emptiness_checking() || !rel.empty())) { ctx.set_reg(m_reg, rel.clone()); } @@ -182,7 +182,7 @@ namespace datalog { virtual void make_annotations(execution_context & ctx) { ctx.set_register_annotation(m_reg, m_pred->get_name().bare_str()); } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { const char * rel_name = m_pred->get_name().bare_str(); if (m_store) { out << "store " << m_reg << " into " << rel_name; @@ -213,7 +213,7 @@ namespace datalog { virtual void make_annotations(execution_context & ctx) { ctx.set_register_annotation(m_reg, "alloc"); } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "dealloc " << m_reg; } }; @@ -248,7 +248,7 @@ namespace datalog { ctx.set_register_annotation(m_src, str); } } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << (m_clone ? "clone " : "move ") << m_src << " into " << m_tgt; } }; @@ -304,11 +304,11 @@ namespace datalog { virtual void make_annotations(execution_context & ctx) { m_body->make_annotations(ctx); } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "while"; print_container(m_controls, out); } - virtual void display_body_impl(context & ctx, std::ostream & out, std::string indentation) const { + virtual void display_body_impl(rel_context & ctx, std::ostream & out, std::string indentation) const { m_body->display_indented(ctx, out, indentation+" "); } }; @@ -349,9 +349,9 @@ namespace datalog { } TRACE("dl", - r1.get_signature().output(ctx.get_datalog_context().get_manager(), tout); + r1.get_signature().output(ctx.get_rel_context().get_manager(), tout); tout<<":"<\n";); try { @@ -371,7 +371,7 @@ namespace datalog { } TRACE("dl", - ctx.reg(m_res)->get_signature().output(ctx.get_datalog_context().get_manager(), tout); + ctx.reg(m_res)->get_signature().output(ctx.get_rel_context().get_manager(), tout); tout<<":"<get_size_estimate_rows()<<"\n";); if (ctx.eager_emptiness_checking() && ctx.reg(m_res)->empty()) { @@ -385,7 +385,7 @@ namespace datalog { ctx.get_register_annotation(m_rel1, a1); ctx.set_register_annotation(m_res, "join " + a1 + " " + a2); } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "join " << m_rel1; print_container(m_cols1, out); out << " and " << m_rel2; @@ -431,10 +431,10 @@ namespace datalog { } virtual void make_annotations(execution_context & ctx) { std::stringstream a; - a << "filter_equal " << m_col << " val: " << ctx.get_datalog_context().get_rmanager().to_nice_string(m_value); + a << "filter_equal " << m_col << " val: " << ctx.get_rel_context().get_rmanager().to_nice_string(m_value); ctx.set_register_annotation(m_reg, a.str()); } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "filter_equal " << m_reg << " col: " << m_col << " val: " << ctx.get_rmanager().to_nice_string(m_value); } @@ -476,7 +476,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "filter_identical " << m_reg << " "; print_container(m_cols, out); } @@ -519,7 +519,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "filter_interpreted " << m_reg << " using " << mk_pp(m_cond, m_cond.get_manager()); } @@ -624,7 +624,7 @@ namespace datalog { ctx.set_register_annotation(m_delta, "delta of "+str); } } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << (m_widen ? "widen " : "union ") << m_src << " into " << m_tgt; if (m_delta!=execution_context::void_register) { out << " with delta " << m_delta; @@ -678,7 +678,7 @@ namespace datalog { return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << (m_projection ? "project " : "rename ") << m_src << " into " << m_tgt; out << (m_projection ? " deleting columns " : " with cycle "); print_container(m_cols, out); @@ -739,7 +739,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "join_project " << m_rel1; print_container(m_cols1, out); out << " and " << m_rel2; @@ -800,7 +800,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "select_equal_and_project " << m_src <<" into " << m_result << " col: " << m_col << " val: " << ctx.get_rmanager().to_nice_string(m_value); } @@ -809,7 +809,7 @@ namespace datalog { std::string s1 = "src"; ctx.get_register_annotation(m_src, s1); s << "select equal project col " << m_col << " val: " - << ctx.get_datalog_context().get_rmanager().to_nice_string(m_value) << " " << s1; + << ctx.get_rel_context().get_rmanager().to_nice_string(m_value) << " " << s1; ctx.set_register_annotation(m_result, s.str()); } }; @@ -854,7 +854,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "filter_by_negation on " << m_tgt; print_container(m_cols1, out); out << " with " << m_neg_rel; @@ -887,12 +887,12 @@ namespace datalog { } virtual bool perform(execution_context & ctx) { ctx.make_empty(m_tgt); - relation_base * rel = ctx.get_datalog_context().get_rmanager().mk_empty_relation(m_sig, m_pred); + relation_base * rel = ctx.get_rel_context().get_rmanager().mk_empty_relation(m_sig, m_pred); rel->add_fact(m_fact); ctx.set_reg(m_tgt, rel); return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "mk_unary_singleton into " << m_tgt << " sort:" << ctx.get_rmanager().to_nice_string(m_sig[0]) << " val:" << ctx.get_rmanager().to_nice_string(m_sig[0], m_fact[0]); @@ -919,10 +919,10 @@ namespace datalog { instr_mk_total(const relation_signature & sig, func_decl* p, reg_idx tgt) : m_sig(sig), m_pred(p), m_tgt(tgt) {} virtual bool perform(execution_context & ctx) { ctx.make_empty(m_tgt); - ctx.set_reg(m_tgt, ctx.get_datalog_context().get_rmanager().mk_full_relation(m_sig, m_pred)); + ctx.set_reg(m_tgt, ctx.get_rel_context().get_rmanager().mk_full_relation(m_sig, m_pred)); return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "mk_total into " << m_tgt << " sort:" << ctx.get_rmanager().to_nice_string(m_sig); } @@ -944,10 +944,10 @@ namespace datalog { instr_mark_saturated(ast_manager & m, func_decl * pred) : m_pred(pred, m) {} virtual bool perform(execution_context & ctx) { - ctx.get_datalog_context().get_rmanager().mark_saturated(m_pred); + ctx.get_rel_context().get_rmanager().mark_saturated(m_pred); return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "mark_saturated " << m_pred->get_name().bare_str(); } virtual void make_annotations(execution_context & ctx) { @@ -970,7 +970,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << "instr_assert_signature of " << m_tgt << " signature:"; print_container(m_sig, out); } @@ -1019,7 +1019,7 @@ namespace datalog { TRACE("dl", tout <<"% "; - instr->display_head_impl(ctx.get_datalog_context(), tout); + instr->display_head_impl(ctx.get_rel_context(), tout); tout <<"\n";); success = !ctx.should_terminate() && instr->perform(ctx); } @@ -1042,12 +1042,12 @@ namespace datalog { } } - void instruction_block::display_indented(context & ctx, std::ostream & out, std::string indentation) const { + void instruction_block::display_indented(rel_context & ctx, std::ostream & out, std::string indentation) const { instr_seq_type::const_iterator it = m_data.begin(); instr_seq_type::const_iterator end = m_data.end(); for(; it!=end; ++it) { instruction * i = (*it); - if (i->passes_output_thresholds(ctx) || i->being_recorded()) { + if (i->passes_output_thresholds(ctx.get_context()) || i->being_recorded()) { i->display_indented(ctx, out, indentation); } } diff --git a/src/muz_qe/dl_instruction.h b/src/muz_qe/dl_instruction.h index c44c860a0..89f95c860 100644 --- a/src/muz_qe/dl_instruction.h +++ b/src/muz_qe/dl_instruction.h @@ -58,7 +58,7 @@ namespace datalog { private: typedef u_map reg_annotations; - context & m_datalog_context; + context & m_context; reg_vector m_registers; reg_annotations m_reg_annotation; @@ -73,12 +73,12 @@ namespace datalog { */ bool m_eager_emptiness_checking; public: - execution_context(context & datalog_context); + execution_context(context & context); ~execution_context(); void reset(); - context & get_datalog_context() { return m_datalog_context; }; + rel_context & get_rel_context() { return m_context.get_rel_context(); }; void set_timelimit(unsigned time_in_ms); void reset_timelimit(); @@ -208,7 +208,7 @@ namespace datalog { The newline character at the end should not be printed. */ - virtual void display_head_impl(context & ctx, std::ostream & out) const { + virtual void display_head_impl(rel_context & ctx, std::ostream & out) const { out << ""; } /** @@ -216,7 +216,7 @@ namespace datalog { Each line must be prepended by \c indentation and ended by a newline character. */ - virtual void display_body_impl(context & ctx, std::ostream & out, std::string indentation) const {} + virtual void display_body_impl(rel_context & ctx, std::ostream & out, std::string indentation) const {} public: typedef execution_context::reg_type reg_type; typedef execution_context::reg_idx reg_idx; @@ -227,10 +227,10 @@ namespace datalog { virtual void make_annotations(execution_context & ctx) = 0; - void display(context & ctx, std::ostream & out) const { + void display(rel_context & ctx, std::ostream & out) const { display_indented(ctx, out, ""); } - void display_indented(context & ctx, std::ostream & out, std::string indentation) const; + void display_indented(rel_context & ctx, std::ostream & out, std::string indentation) const; static instruction * mk_load(ast_manager & m, func_decl * pred, reg_idx tgt); /** @@ -329,10 +329,10 @@ namespace datalog { void make_annotations(execution_context & ctx); - void display(context & ctx, std::ostream & out) const { + void display(rel_context & ctx, std::ostream & out) const { display_indented(ctx, out, ""); } - void display_indented(context & ctx, std::ostream & out, std::string indentation) const; + void display_indented(rel_context & ctx, std::ostream & out, std::string indentation) const; }; diff --git a/src/muz_qe/dl_mk_explanations.cpp b/src/muz_qe/dl_mk_explanations.cpp index 425d3fb60..b4683bdbe 100644 --- a/src/muz_qe/dl_mk_explanations.cpp +++ b/src/muz_qe/dl_mk_explanations.cpp @@ -607,7 +607,7 @@ namespace datalog { m_e_sort = m_decl_util.mk_rule_sort(); m_pinned.push_back(m_e_sort); - relation_manager & rmgr = ctx.get_rmanager(); + relation_manager & rmgr = ctx.get_rel_context().get_rmanager(); symbol er_symbol = explanation_relation_plugin::get_name(relation_level); m_er_plugin = static_cast(rmgr.get_relation_plugin(er_symbol)); if(!m_er_plugin) { @@ -640,7 +640,7 @@ namespace datalog { void mk_explanations::assign_rel_level_kind(func_decl * e_decl, func_decl * orig) { SASSERT(m_relation_level); - relation_manager & rmgr = m_context.get_rmanager(); + relation_manager & rmgr = m_context.get_rel_context().get_rmanager(); unsigned sz = e_decl->get_arity(); relation_signature sig; rmgr.from_predicate(e_decl, sig); @@ -884,7 +884,7 @@ namespace datalog { m_context.collect_predicates(m_original_preds); rule_set * res = alloc(rule_set, m_context); - transform_facts(m_context.get_rmanager()); + transform_facts(m_context.get_rel_context().get_rmanager()); transform_rules(source, *res); return res; } diff --git a/src/muz_qe/dl_mk_magic_sets.cpp b/src/muz_qe/dl_mk_magic_sets.cpp index 668cbf939..373a90969 100644 --- a/src/muz_qe/dl_mk_magic_sets.cpp +++ b/src/muz_qe/dl_mk_magic_sets.cpp @@ -365,7 +365,7 @@ namespace datalog { rule * r = *it; transform_rule(task.m_adornment, r); } - if(!m_context.get_relation(task.m_pred).empty()) { + if(!m_context.get_rel_context().get_relation(task.m_pred).empty()) { //we need a rule to copy facts that are already in a relation into the adorned //relation (since out intentional predicates can have facts, not only rules) create_transfer_rule(task); diff --git a/src/muz_qe/dl_mk_partial_equiv.cpp b/src/muz_qe/dl_mk_partial_equiv.cpp index 68f333b1b..367a15743 100644 --- a/src/muz_qe/dl_mk_partial_equiv.cpp +++ b/src/muz_qe/dl_mk_partial_equiv.cpp @@ -97,7 +97,7 @@ namespace datalog { return 0; } - relation_manager & rm = m_context.get_rmanager(); + relation_manager & rm = m_context.get_rel_context().get_rmanager(); rule_set::decl2rules::iterator it = source.begin_grouped_rules(); rule_set::decl2rules::iterator end = source.end_grouped_rules(); diff --git a/src/muz_qe/dl_mk_rule_inliner.cpp b/src/muz_qe/dl_mk_rule_inliner.cpp index 9c9bf7abb..fa532ee6c 100644 --- a/src/muz_qe/dl_mk_rule_inliner.cpp +++ b/src/muz_qe/dl_mk_rule_inliner.cpp @@ -205,7 +205,7 @@ namespace datalog { void mk_rule_inliner::count_pred_occurrences(rule_set const & orig) { - m_context.get_rmanager().collect_non_empty_predicates(m_preds_with_facts); + m_context.get_rel_context().get_rmanager().collect_non_empty_predicates(m_preds_with_facts); rule_set::iterator rend = orig.end(); for (rule_set::iterator rit = orig.begin(); rit!=rend; ++rit) { diff --git a/src/muz_qe/dl_mk_similarity_compressor.cpp b/src/muz_qe/dl_mk_similarity_compressor.cpp index 8225aa315..42a5ba367 100644 --- a/src/muz_qe/dl_mk_similarity_compressor.cpp +++ b/src/muz_qe/dl_mk_similarity_compressor.cpp @@ -361,7 +361,7 @@ namespace datalog { collect_orphan_consts(*it, const_infos, val_fact); m_context.add_fact(aux_pred, val_fact); } - m_context.get_rmanager().mark_saturated(aux_pred); + m_context.get_rel_context().get_rmanager().mark_saturated(aux_pred); app * new_head = r->get_head(); ptr_vector new_tail; diff --git a/src/muz_qe/dl_mk_simple_joins.cpp b/src/muz_qe/dl_mk_simple_joins.cpp index da1f80a53..363a4f0f7 100644 --- a/src/muz_qe/dl_mk_simple_joins.cpp +++ b/src/muz_qe/dl_mk_simple_joins.cpp @@ -569,10 +569,11 @@ namespace datalog { cost estimate_size(app * t) const { func_decl * pred = t->get_decl(); unsigned n=pred->get_arity(); - if( (m_context.saturation_was_run() && m_context.get_rmanager().try_get_relation(pred)) - || m_context.get_rmanager().is_saturated(pred)) { - SASSERT(m_context.get_rmanager().try_get_relation(pred)); //if it is saturated, it should exist - unsigned rel_size_int = m_context.get_relation(pred).get_size_estimate_rows(); + relation_manager& rm = m_context.get_rel_context().get_rmanager(); + if( (m_context.saturation_was_run() && rm.try_get_relation(pred)) + || rm.is_saturated(pred)) { + SASSERT(rm.try_get_relation(pred)); //if it is saturated, it should exist + unsigned rel_size_int = m_context.get_rel_context().get_relation(pred).get_size_estimate_rows(); if(rel_size_int!=0) { cost rel_size = static_cast(rel_size_int); cost curr_size = rel_size; diff --git a/src/muz_qe/dl_mk_subsumption_checker.cpp b/src/muz_qe/dl_mk_subsumption_checker.cpp index d20ad5055..19c28c036 100644 --- a/src/muz_qe/dl_mk_subsumption_checker.cpp +++ b/src/muz_qe/dl_mk_subsumption_checker.cpp @@ -250,7 +250,7 @@ namespace datalog { } void mk_subsumption_checker::scan_for_relations_total_due_to_facts() { - relation_manager& rm = m_context.get_rmanager(); + relation_manager& rm = m_context.get_rel_context().get_rmanager(); decl_set candidate_preds; m_context.collect_predicates(candidate_preds); diff --git a/src/muz_qe/dl_mk_unbound_compressor.cpp b/src/muz_qe/dl_mk_unbound_compressor.cpp index 000a70b22..e3db82759 100644 --- a/src/muz_qe/dl_mk_unbound_compressor.cpp +++ b/src/muz_qe/dl_mk_unbound_compressor.cpp @@ -337,7 +337,7 @@ namespace datalog { // TODO mc, pc m_modified = false; - m_context.get_rmanager().collect_non_empty_predicates(m_non_empty_rels); + m_context.get_rel_context().get_rmanager().collect_non_empty_predicates(m_non_empty_rels); unsigned init_rule_cnt = source.get_num_rules(); SASSERT(m_rules.empty()); diff --git a/src/muz_qe/dl_rule.cpp b/src/muz_qe/dl_rule.cpp index 9b0af2554..dedd37a78 100644 --- a/src/muz_qe/dl_rule.cpp +++ b/src/muz_qe/dl_rule.cpp @@ -1014,7 +1014,7 @@ namespace datalog { out << '.'; if (ctx.output_profile()) { out << " {"; - output_profile(ctx, out); + output_profile(out); out << '}'; } out << '\n'; diff --git a/src/muz_qe/fixedpoint_params.pyg b/src/muz_qe/fixedpoint_params.pyg index aa78dad3d..61f993c0a 100644 --- a/src/muz_qe/fixedpoint_params.pyg +++ b/src/muz_qe/fixedpoint_params.pyg @@ -30,25 +30,25 @@ def_module_params('fixedpoint', ('print_with_fixedpoint_extensions', BOOL, True, "use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, when printing rules"), ('print_low_level_smt2', BOOL, False, "use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"), ('print_with_variable_declarations', BOOL, True, "use variable declarations when displaying rules (instead of attempting to use original names)"), - ('bfs_model_search', BOOL, True, "PDR: (default true) use BFS strategy for expanding model search"), - ('use_farkas', BOOL, True, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"), - ('generate_proof_trace', BOOL, False, "PDR: (default false) trace for 'sat' answer as proof object"), - ('flexible_trace', BOOL, False, "PDR: (default false) allow PDR generate long counter-examples " + ('bfs_model_search', BOOL, True, "PDR: use BFS strategy for expanding model search"), + ('use_farkas', BOOL, True, "PDR: use lemma generator based on Farkas (for linear real arithmetic)"), + ('generate_proof_trace', BOOL, False, "PDR: trace for 'sat' answer as proof object"), + ('flexible_trace', BOOL, False, "PDR: allow PDR generate long counter-examples " "by extending candidate trace within search area"), - ('unfold_rules', UINT, 0, "PDR: (default 0) unfold rules statically using iterative squarring"), - ('use_model_generalizer', BOOL, False, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"), - ('validate_result', BOOL, False, "PDR (default false) validate result (by proof checking or model checking)"), - ('simplify_formulas_pre', BOOL, False, "PDR: (default false) simplify derived formulas before inductive propagation"), - ('simplify_formulas_post', BOOL, False, "PDR: (default false) simplify derived formulas after inductive propagation"), - ('slice', BOOL, True, "PDR: (default true) simplify clause set using slicing"), - ('coalesce_rules', BOOL, False, "BMC: (default false) coalesce rules"), - ('use_multicore_generalizer', BOOL, False, "PDR: (default false) extract multiple cores for blocking states"), - ('use_inductive_generalizer', BOOL, True, "PDR: (default true) generalize lemmas using induction strengthening"), - ('cache_mode', UINT, 0, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search"), - ('inductive_reachability_check', BOOL, False, "PDR: (default false) assume negation of the cube on the previous level when " + ('unfold_rules', UINT, 0, "PDR: unfold rules statically using iterative squarring"), + ('use_model_generalizer', BOOL, False, "PDR: use model for backwards propagation (instead of symbolic simulation)"), + ('validate_result', BOOL, False, "PDR validate result (by proof checking or model checking)"), + ('simplify_formulas_pre', BOOL, False, "PDR: simplify derived formulas before inductive propagation"), + ('simplify_formulas_post', BOOL, False, "PDR: simplify derived formulas after inductive propagation"), + ('slice', BOOL, True, "PDR: simplify clause set using slicing"), + ('coalesce_rules', BOOL, False, "BMC: coalesce rules"), + ('use_multicore_generalizer', BOOL, False, "PDR: extract multiple cores for blocking states"), + ('use_inductive_generalizer', BOOL, True, "PDR: generalize lemmas using induction strengthening"), + ('cache_mode', UINT, 0, "PDR: use no (0), symbolic (1) or explicit cache (2) for model search"), + ('inductive_reachability_check', BOOL, False, "PDR: assume negation of the cube on the previous level when " "checking for reachability (not only during cube weakening)"), - ('max_num_contexts', UINT, 500, "PDR: (default 500) maximal number of contexts to create"), - ('try_minimize_core', BOOL, False, "PDR: (default false) try to reduce core size (before inductive minimization)"), + ('max_num_contexts', UINT, 500, "PDR: maximal number of contexts to create"), + ('try_minimize_core', BOOL, False, "PDR: try to reduce core size (before inductive minimization)"), ('profile_timeout_milliseconds', UINT, 0, "instructions and rules that took less than the threshold will not be printed when printed the instruction/rule list"), ('dbg_fpr_nonempty_relation_signature', BOOL, False, "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index 663f634c4..0482ece05 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -83,7 +83,6 @@ lbool dl_interface::query(expr * query) { m_pdr_rules.reset(); m_refs.reset(); m_pred2slice.reset(); - m_ctx.get_rmanager().reset_relations(); ast_manager& m = m_ctx.get_manager(); datalog::rule_manager& rule_manager = m_ctx.get_rule_manager(); datalog::rule_set old_rules(m_ctx.get_rules()); diff --git a/src/muz_qe/rel_context.cpp b/src/muz_qe/rel_context.cpp new file mode 100644 index 000000000..1b4042ab9 --- /dev/null +++ b/src/muz_qe/rel_context.cpp @@ -0,0 +1,517 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + rel_context.cpp + +Abstract: + + context for relational datalog engine. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-12-3. + +Revision History: + + Extracted from dl_context + +--*/ +#include"rel_context.h" +#include"dl_context.h" +#include"dl_compiler.h" +#include"dl_instruction.h" +#include"dl_mk_explanations.h" +#include"dl_mk_magic_sets.h" +#include"dl_product_relation.h" +#include"dl_bound_relation.h" +#include"dl_interval_relation.h" +#include"dl_finite_product_relation.h" +#include"dl_sparse_table.h" +#include"dl_table.h" +#include"dl_table_relation.h" +#ifndef _EXTERNAL_RELEASE +#include"dl_skip_table.h" +#endif + +namespace datalog { + + rel_context::rel_context(context& ctx) + : m_context(ctx), + m(ctx.get_manager()), + m_rmanager(ctx), + m_answer(m), + m_cancel(false), + m_last_result_relation(0) { + get_rmanager().register_plugin(alloc(sparse_table_plugin, get_rmanager())); + get_rmanager().register_plugin(alloc(hashtable_table_plugin, get_rmanager())); + get_rmanager().register_plugin(alloc(bitvector_table_plugin, get_rmanager())); + get_rmanager().register_plugin(alloc(equivalence_table_plugin, get_rmanager())); + +#ifndef _EXTERNAL_RELEASE + get_rmanager().register_plugin(alloc(skip_table_plugin, get_rmanager())); +#endif + + //register plugins for builtin relations + + get_rmanager().register_plugin(alloc(bound_relation_plugin, get_rmanager())); + get_rmanager().register_plugin(alloc(interval_relation_plugin, get_rmanager())); + +} + + rel_context::~rel_context() { + if (m_last_result_relation) { + m_last_result_relation->deallocate(); + m_last_result_relation = 0; + } + } + + void rel_context::collect_predicates(decl_set & res) { + unsigned rule_cnt = m_context.get_rules().get_num_rules(); + for (unsigned rindex=0; rindexget_head()->get_decl()); + unsigned tail_len = r->get_uninterpreted_tail_size(); + for (unsigned tindex=0; tindexget_tail(tindex)->get_decl()); + } + } + decl_set::iterator oit = m_output_preds.begin(); + decl_set::iterator oend = m_output_preds.end(); + for (; oit!=oend; ++oit) { + res.insert(*oit); + } + get_rmanager().collect_predicates(res); + } + + + lbool rel_context::saturate() { + m_context.ensure_closed(); + + bool time_limit = m_context.soft_timeout()!=0; + unsigned remaining_time_limit = m_context.soft_timeout(); + unsigned restart_time = m_context.initial_restart_timeout(); + + rule_set original_rules(m_context.get_rules()); + decl_set original_predicates; + m_context.collect_predicates(original_predicates); + + instruction_block rules_code; + instruction_block termination_code; + execution_context ex_ctx(m_context); + + lbool result; + + TRACE("dl", m_context.display(tout);); + + while (true) { + model_converter_ref mc; // Ignored in Datalog mode + proof_converter_ref pc; // Ignored in Datalog mode + m_context.transform_rules(mc, pc); + compiler::compile(m_context, m_context.get_rules(), rules_code, termination_code); + + TRACE("dl", rules_code.display(*this, tout); ); + + bool timeout_after_this_round = time_limit && (restart_time==0 || remaining_time_limit<=restart_time); + + if (time_limit || restart_time!=0) { + unsigned timeout = time_limit ? (restart_time!=0) ? + std::min(remaining_time_limit, restart_time) + : remaining_time_limit : restart_time; + ex_ctx.set_timelimit(timeout); + } + + bool early_termination = !rules_code.perform(ex_ctx); + ex_ctx.reset_timelimit(); + VERIFY( termination_code.perform(ex_ctx) ); + + rules_code.process_all_costs(); + + IF_VERBOSE(10, ex_ctx.report_big_relations(1000, verbose_stream());); + + if (!early_termination) { + m_context.set_status(OK); + result = l_true; + break; + } + + if (memory::above_high_watermark()) { + m_context.set_status(MEMOUT); + result = l_undef; + break; + } + if (timeout_after_this_round || m_cancel) { + m_context.set_status(TIMEOUT); + result = l_undef; + break; + } + SASSERT(restart_time != 0); + if (time_limit) { + SASSERT(remaining_time_limit>restart_time); + remaining_time_limit -= restart_time; + } + uint64 new_restart_time = static_cast(restart_time)*m_context.initial_restart_timeout(); + if (new_restart_time > UINT_MAX) { + restart_time = UINT_MAX; + } + else { + restart_time = static_cast(new_restart_time); + } + + rules_code.reset(); + termination_code.reset(); + ex_ctx.reset(); + m_context.reopen(); + restrict_predicates(original_predicates); + m_context.replace_rules(original_rules); + m_context.close(); + } + m_context.reopen(); + restrict_predicates(original_predicates); + m_context.replace_rules(original_rules); + m_context.close(); + TRACE("dl", ex_ctx.report_big_relations(100, tout);); + m_cancel = false; + return result; + } + +#define BEGIN_QUERY() \ + rule_set original_rules(m_context.get_rules()); \ + decl_set original_preds; \ + m_context.collect_predicates(original_preds); \ + bool was_closed = m_context.is_closed(); \ + if (was_closed) { \ + m_context.reopen(); \ + } \ + +#define END_QUERY() \ + m_context.reopen(); \ + m_context.replace_rules(original_rules); \ + restrict_predicates(original_preds); \ + \ + if (was_closed) { \ + m_context.close(); \ + } \ + + lbool rel_context::query(unsigned num_rels, func_decl * const* rels) { + get_rmanager().reset_saturated_marks(); + BEGIN_QUERY(); + for (unsigned i = 0; i < num_rels; ++i) { + set_output_predicate(rels[i]); + } + m_context.close(); + reset_negated_tables(); + lbool res = saturate(); + + switch(res) { + case l_true: { + expr_ref_vector ans(m); + expr_ref e(m); + bool some_non_empty = num_rels == 0; + for (unsigned i = 0; i < num_rels; ++i) { + relation_base& rel = get_relation(rels[i]); + if (!rel.empty()) { + some_non_empty = true; + } + rel.to_formula(e); + ans.push_back(e); + } + SASSERT(!m_last_result_relation); + if (some_non_empty) { + m_answer = m.mk_and(ans.size(), ans.c_ptr()); + } + else { + m_answer = m.mk_false(); + res = l_false; + } + break; + } + case l_false: + m_answer = m.mk_false(); + break; + case l_undef: + break; + } + END_QUERY(); + return res; + } + + lbool rel_context::query(expr* query) { + get_rmanager().reset_saturated_marks(); + BEGIN_QUERY(); + rule_manager& rm = m_context.get_rule_manager(); + rule_ref qrule(rm); + rule_ref_vector qrules(rm); + func_decl_ref query_pred(m); + try { + rm.mk_query(query, query_pred, qrules, qrule); + } + catch(default_exception& exn) { + m_context.close(); + m_context.set_status(INPUT_ERROR); + throw exn; + } + try { + m_context.add_rules(qrules); + } + catch (default_exception& exn) { + m_context.close(); + m_context.set_status(INPUT_ERROR); + throw exn; + } + + set_output_predicate(qrule->get_head()->get_decl()); + m_context.close(); + reset_negated_tables(); + + if (m_context.generate_explanations()) { + model_converter_ref mc; // ignored in Datalog mode + proof_converter_ref pc; // ignored in Datalog mode + rule_transformer transformer(m_context); + //expl_plugin is deallocated when transformer goes out of scope + mk_explanations * expl_plugin = + alloc(mk_explanations, m_context, m_context.explanations_on_relation_level()); + transformer.register_plugin(expl_plugin); + m_context.transform_rules(transformer, mc, pc); + + //we will retrieve the predicate with explanations instead of the original query predicate + query_pred = expl_plugin->get_e_decl(query_pred); + const rule_vector & query_rules = m_context.get_rules().get_predicate_rules(query_pred); + SASSERT(query_rules.size()==1); + qrule = query_rules.back(); + } + + if (m_context.magic_sets_for_queries()) { + model_converter_ref mc; // Ignored in Datalog mode + proof_converter_ref pc; // Ignored in Datalog mode + rule_transformer transformer(m_context); + transformer.register_plugin(alloc(mk_magic_sets, m_context, qrule.get())); + m_context.transform_rules(transformer, mc, pc); + } + + lbool res = saturate(); + + if (res != l_undef) { + m_last_result_relation = get_relation(query_pred).clone(); + if (m_last_result_relation->empty()) { + res = l_false; + m_answer = m.mk_false(); + } + else { + m_last_result_relation->to_formula(m_answer); + } + } + + END_QUERY(); + return res; + } + + void rel_context::reset_negated_tables() { + rule_set::pred_set_vector const & pred_sets = m_context.get_rules().get_strats(); + bool non_empty = false; + for (unsigned i = 1; i < pred_sets.size(); ++i) { + func_decl_set::iterator it = pred_sets[i]->begin(), end = pred_sets[i]->end(); + for (; it != end; ++it) { + func_decl* pred = *it; + relation_base & rel = get_relation(pred); + if (!rel.empty()) { + non_empty = true; + break; + } + } + } + if (!non_empty) { + return; + } + // collect predicates that depend on negation. + func_decl_set depends_on_negation; + for (unsigned i = 1; i < pred_sets.size(); ++i) { + bool change = true; + while (change) { + change = false; + func_decl_set::iterator it = pred_sets[i]->begin(), end = pred_sets[i]->end(); + for (; it != end; ++it) { + func_decl* pred = *it; + if (depends_on_negation.contains(pred)) { + continue; + } + rule_vector const& rules = m_context.get_rules().get_predicate_rules(pred); + bool inserted = false; + for (unsigned j = 0; !inserted && j < rules.size(); ++j) { + rule* r = rules[j]; + unsigned psz = r->get_positive_tail_size(); + unsigned tsz = r->get_uninterpreted_tail_size(); + if (psz < tsz) { + depends_on_negation.insert(pred); + change = true; + inserted = true; + } + for (unsigned k = 0; !inserted && k < tsz; ++k) { + func_decl* tail_decl = r->get_tail(k)->get_decl(); + if (depends_on_negation.contains(tail_decl)) { + depends_on_negation.insert(pred); + change = true; + inserted = true; + } + } + } + } + } + } + func_decl_set::iterator it = depends_on_negation.begin(), end = depends_on_negation.end(); + for (; it != end; ++it) { + func_decl* pred = *it; + relation_base & rel = get_relation(pred); + + if (!rel.empty()) { + TRACE("dl", tout << "Resetting: " << mk_ismt2_pp(pred, m) << "\n";); + rel.reset(); + } + } + } + + void rel_context::set_output_predicate(func_decl * pred) { + if (!m_output_preds.contains(pred)) { + m_output_preds.insert(pred); + } + } + + void rel_context::restrict_predicates( const decl_set & res ) { + set_intersection(m_output_preds, res); + get_rmanager().restrict_predicates(res); + } + + relation_base & rel_context::get_relation(func_decl * pred) { return get_rmanager().get_relation(pred); } + relation_base * rel_context::try_get_relation(func_decl * pred) const { return get_rmanager().try_get_relation(pred); } + + relation_manager & rel_context::get_rmanager() { return m_rmanager; } + + const relation_manager & rel_context::get_rmanager() const { return m_rmanager; } + + bool rel_context::output_profile() const { return m_context.output_profile(); } + + + void rel_context::set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, + symbol const * relation_names) { + + relation_manager & rmgr = get_rmanager(); + + family_id target_kind = null_family_id; + switch (relation_name_cnt) { + case 0: + return; + case 1: + target_kind = get_ordinary_relation_plugin(relation_names[0]).get_kind(); + break; + default: { + svector rel_kinds; // kinds of plugins that are not table plugins + family_id rel_kind; // the aggregate kind of non-table plugins + for (unsigned i = 0; i < relation_name_cnt; i++) { + relation_plugin & p = get_ordinary_relation_plugin(relation_names[i]); + rel_kinds.push_back(p.get_kind()); + } + if (rel_kinds.size() == 1) { + rel_kind = rel_kinds[0]; + } + else { + relation_signature rel_sig; + //rmgr.from_predicate(pred, rel_sig); + product_relation_plugin & prod_plugin = product_relation_plugin::get_plugin(rmgr); + rel_kind = prod_plugin.get_relation_kind(rel_sig, rel_kinds); + } + target_kind = rel_kind; + break; + } + } + + SASSERT(target_kind != null_family_id); + get_rmanager().set_predicate_kind(pred, target_kind); + } + + relation_plugin & rel_context::get_ordinary_relation_plugin(symbol relation_name) { + relation_plugin * plugin = get_rmanager().get_relation_plugin(relation_name); + if (!plugin) { + std::stringstream sstm; + sstm << "relation plugin " << relation_name << " does not exist"; + throw default_exception(sstm.str()); + } + if (plugin->is_product_relation()) { + throw default_exception("cannot request product relation directly"); + } + if (plugin->is_sieve_relation()) { + throw default_exception("cannot request sieve relation directly"); + } + if (plugin->is_finite_product_relation()) { + throw default_exception("cannot request finite product relation directly"); + } + return *plugin; + } + + bool rel_context::result_contains_fact(relation_fact const& f) { + SASSERT(m_last_result_relation); + return m_last_result_relation->contains_fact(f); + } + + void rel_context::reset_tables() { + get_rmanager().reset_saturated_marks(); + rule_set::decl2rules::iterator it = m_context.get_rules().begin_grouped_rules(); + rule_set::decl2rules::iterator end = m_context.get_rules().end_grouped_rules(); + for (; it != end; ++it) { + func_decl* p = it->m_key; + relation_base & rel = get_relation(p); + rel.reset(); + } + for (unsigned i = 0; i < m_table_facts.size(); ++i) { + func_decl* pred = m_table_facts[i].first; + relation_fact const& fact = m_table_facts[i].second; + get_relation(pred).add_fact(fact); + } + } + + void rel_context::add_fact(func_decl* pred, relation_fact const& fact) { + get_rmanager().reset_saturated_marks(); + get_relation(pred).add_fact(fact); + m_table_facts.push_back(std::make_pair(pred, fact)); + } + + void rel_context::add_fact(func_decl* pred, table_fact const& fact) { + get_rmanager().reset_saturated_marks(); + relation_base & rel0 = get_relation(pred); + if (rel0.from_table()) { + table_relation & rel = static_cast(rel0); + rel.add_table_fact(fact); + // TODO: table facts? + } + else { + relation_fact rfact(m); + for (unsigned i = 0; i < fact.size(); ++i) { + rfact.push_back(m_context.get_decl_util().mk_numeral(fact[i], pred->get_domain()[i])); + } + add_fact(pred, rfact); + } + } + + void rel_context::store_relation(func_decl * pred, relation_base * rel) { + get_rmanager().store_relation(pred, rel); + } + + void rel_context::inherit_predicate_kind(func_decl* new_pred, func_decl* orig_pred) { + if (orig_pred) { + family_id target_kind = get_rmanager().get_requested_predicate_kind(orig_pred); + if (target_kind != null_family_id) { + get_rmanager().set_predicate_kind(new_pred, target_kind); + } + } + } + + void rel_context::display_output_facts(std::ostream & out) const { + get_rmanager().display_output_tables(out); + } + + void rel_context::display_facts(std::ostream& out) const { + get_rmanager().display(out); + } + + +}; diff --git a/src/muz_qe/rel_context.h b/src/muz_qe/rel_context.h new file mode 100644 index 000000000..8e0ea4a16 --- /dev/null +++ b/src/muz_qe/rel_context.h @@ -0,0 +1,115 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + rel_context.h + +Abstract: + + context for relational datalog engine. + +Author: + + Nikolaj Bjorner (nbjorner) 2012-12-3. + +Revision History: + + Extracted from dl_context + +--*/ +#ifndef _REL_CONTEXT_H_ +#define _REL_CONTEXT_H_ +#include "ast.h" +#include "dl_relation_manager.h" +#include "lbool.h" + +namespace datalog { + + class context; + + class rel_context { + typedef vector > fact_vector; + + context& m_context; + ast_manager& m; + relation_manager m_rmanager; + expr_ref m_answer; + volatile bool m_cancel; + relation_base * m_last_result_relation; + decl_set m_output_preds; + fact_vector m_table_facts; + + void reset_negated_tables(); + + lbool saturate(); + + relation_plugin & get_ordinary_relation_plugin(symbol relation_name); + + void reset_tables(); + + public: + rel_context(context& ctx); + + ~rel_context(); + + relation_manager & get_rmanager(); + const relation_manager & get_rmanager() const; + ast_manager& get_manager() { return m; } + context& get_context() { return m_context; } + relation_base & get_relation(func_decl * pred); + relation_base * try_get_relation(func_decl * pred) const; + expr_ref get_last_answer() { return m_answer; } + + bool output_profile() const; + + + lbool query(expr* q); + lbool query(unsigned num_rels, func_decl * const* rels); + + void set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, + symbol const * relation_names); + + void inherit_predicate_kind(func_decl* new_pred, func_decl* orig_pred); + + void cancel() { m_cancel = true; } + + + + /** + \brief Restrict the set of used predicates to \c res. + + The function deallocates unsused relations, it does not deal with rules. + */ + void restrict_predicates(const decl_set & res); + + void collect_predicates(decl_set & res); + + void set_output_predicate(func_decl * pred); + bool is_output_predicate(func_decl * pred) { return m_output_preds.contains(pred); } + const decl_set & get_output_predicates() const { return m_output_preds; } + + + /** + \brief query result if it contains fact. + */ + bool result_contains_fact(relation_fact const& f); + + void add_fact(func_decl* pred, relation_fact const& fact); + + void add_fact(func_decl* pred, table_fact const& fact); + + /** + \brief Store the relation \c rel under the predicate \c pred. The \c context object + takes over the ownership of the relation object. + */ + void store_relation(func_decl * pred, relation_base * rel); + + void display_output_facts(std::ostream & out) const; + void display_facts(std::ostream & out) const; + + + }; +}; + +#endif /* _REL_CONTEXT_H_ */ diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index 1d001c349..44a9d9b66 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -86,7 +86,7 @@ static void display_statistics( out << "--------------\n"; out << "instructions \n"; - code.display(ctx, out); + code.display(ctx.get_rel_context(), out); out << "--------------\n"; out << "big relations \n"; @@ -94,7 +94,7 @@ static void display_statistics( } out << "--------------\n"; out << "relation sizes\n"; - ctx.get_rmanager().display_relation_sizes(out); + ctx.get_rel_context().get_rmanager().display_relation_sizes(out); if (verbose) { out << "--------------\n"; @@ -139,7 +139,7 @@ unsigned read_datalog(char const * file) { params.set_bool("default_table_checked", dl_params.m_default_table_checked); datalog::context ctx(m, s_params, params); - datalog::relation_manager & rmgr = ctx.get_rmanager(); + datalog::relation_manager & rmgr = ctx.get_rel_context().get_rmanager(); datalog::relation_plugin & inner_plg = *rmgr.get_relation_plugin(symbol("tr_hashtable")); SASSERT(&inner_plg); rmgr.register_plugin(alloc(datalog::finite_product_relation_plugin, inner_plg, rmgr)); @@ -206,7 +206,7 @@ unsigned read_datalog(char const * file) { datalog::compiler::compile(ctx, ctx.get_rules(), rules_code, termination_code); - TRACE("dl_compiler", rules_code.display(ctx, tout);); + TRACE("dl_compiler", rules_code.display(ctx.get_rel_context(), tout);); rules_code.make_annotations(ex_ctx); @@ -248,10 +248,10 @@ unsigned read_datalog(char const * file) { TRACE("dl_compiler", ctx.display(tout); - rules_code.display(ctx, tout);); + rules_code.display(ctx.get_rel_context(), tout);); if (ctx.get_params().output_tuples()) { - ctx.display_output_facts(std::cout); + ctx.get_rel_context().display_output_facts(std::cout); } display_statistics( From 72e09759ee7ff96123834177746d9805d8b6d237 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 3 Dec 2012 15:13:45 -0800 Subject: [PATCH 103/133] factor out relation context for datalog Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_cmds.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index 735df8d80..8c4e26db7 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -44,6 +44,11 @@ struct dl_context { scoped_ptr m_context; trail_stack m_trail; + fixedpoint_params const& get_params() { + init(); + return m_context->get_params(); + } + dl_context(cmd_context & ctx, dl_collected_cmds* collected_cmds): m_params(m_params_ref), m_cmd(ctx), @@ -214,7 +219,7 @@ public: datalog::context& dlctx = m_dl_ctx->dlctx(); set_background(ctx); dlctx.updt_params(m_params); - unsigned timeout = m_dl_ctx->m_params.timeout(); + unsigned timeout = m_dl_ctx->get_params().timeout(); cancel_eh eh(dlctx); lbool status = l_undef; { @@ -283,7 +288,7 @@ private: } void print_answer(cmd_context& ctx) { - if (m_dl_ctx->m_params.print_answer()) { + if (m_dl_ctx->get_params().print_answer()) { datalog::context& dlctx = m_dl_ctx->dlctx(); ast_manager& m = ctx.m(); expr_ref query_result(dlctx.get_answer_as_formula(), m); @@ -298,7 +303,7 @@ private: } void print_statistics(cmd_context& ctx) { - if (m_dl_ctx->m_params.print_statistics()) { + if (m_dl_ctx->get_params().print_statistics()) { statistics st; datalog::context& dlctx = m_dl_ctx->dlctx(); unsigned long long max_mem = memory::get_max_used_memory(); @@ -312,7 +317,7 @@ private: } void print_certificate(cmd_context& ctx) { - if (m_dl_ctx->m_params.print_certificate()) { + if (m_dl_ctx->get_params().print_certificate()) { datalog::context& dlctx = m_dl_ctx->dlctx(); if (!dlctx.display_certificate(ctx.regular_stream())) { throw cmd_exception("certificates are not supported for the selected engine"); From 0ec6e2f218a65a2f1c029773aee072459d1c47d7 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 15:19:47 -0800 Subject: [PATCH 104/133] adjusting examples Signed-off-by: Leonardo de Moura --- examples/c++/example.cpp | 17 +++++++++-------- src/api/c++/z3++.h | 4 ++++ src/api/python/z3.py | 13 +++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/examples/c++/example.cpp b/examples/c++/example.cpp index 180117a96..ab6e67ab9 100644 --- a/examples/c++/example.cpp +++ b/examples/c++/example.cpp @@ -143,7 +143,7 @@ void prove_example2() { void nonlinear_example1() { std::cout << "nonlinear example 1\n"; config cfg; - cfg.set(":auto-config", true); + cfg.set("auto_config", true); context c(cfg); expr x = c.real_const("x"); @@ -158,12 +158,13 @@ void nonlinear_example1() { std::cout << s.check() << "\n"; model m = s.get_model(); std::cout << m << "\n"; - c.set(":pp-decimal", true); // set decimal notation + set_param("pp.decimal", true); // set decimal notation std::cout << "model in decimal notation\n"; std::cout << m << "\n"; - c.set(":pp-decimal-precision", 50); // increase number of decimal places to 50. + set_param("pp.decimal-precision", 50); // increase number of decimal places to 50. std::cout << "model using 50 decimal places\n"; std::cout << m << "\n"; + set_param("pp.decimal", false); // disable decimal notation } /** @@ -352,7 +353,7 @@ void quantifier_example() { // making sure model based quantifier instantiation is enabled. params p(c); - p.set(":mbqi", true); + p.set("mbqi", true); s.set(p); s.add(forall(x, y, f(x, y) >= 0)); @@ -468,7 +469,7 @@ void unsat_core_example3() { // enabling unsat core tracking params p(c); - p.set(":unsat-core", true); + p.set("unsat_core", true); s.set(p); // The following assertion will not be tracked. @@ -585,7 +586,7 @@ void tactic_example4() { std::cout << "tactic example 4\n"; context c; params p(c); - p.set(":mul2concat", true); + p.set("mul2concat", true); tactic t = with(tactic(c, "simplify"), p) & tactic(c, "solve-eqs") & @@ -628,8 +629,8 @@ void tactic_example6() { std::cout << "tactic example 6\n"; context c; params p(c); - p.set(":arith-lhs", true); - p.set(":som", true); // sum-of-monomials normal form + p.set("arith_lhs", true); + p.set("som", true); // sum-of-monomials normal form solver s = (with(tactic(c, "simplify"), p) & tactic(c, "normalize-bounds") & diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 7fc36575a..bdb462df0 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -64,6 +64,10 @@ namespace z3 { class apply_result; class fixedpoint; + inline void set_param(char const * param, char const * value) { Z3_global_param_set(param, value); } + inline void set_param(char const * param, bool value) { Z3_global_param_set(param, value ? "true" : "false"); } + inline void set_param(char const * param, int value) { std::ostringstream oss; oss << value; Z3_global_param_set(param, oss.str().c_str()); } + /** \brief Exception used to sign API usage errors. */ diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 71fd9a732..301267ce1 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -198,10 +198,10 @@ def _get_ctx(ctx): else: return ctx -def set_option(*args, **kws): +def set_param(*args, **kws): """Set Z3 global (or module) parameters. - >>> set_option(precision=10) + >>> set_param(precision=10) """ if __debug__: _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.") @@ -219,10 +219,15 @@ def set_option(*args, **kws): Z3_global_param_set(str(prev), _to_param_value(a)) prev = None -def get_option(name): +def set_option(*args, **kws): + """Alias for 'set_param' for backward compatibility. + """ + return set_param(*args, **kws) + +def get_param(name): """Return the value of a Z3 global (or module) parameter - >>> get_option('nlsat.reorder') + >>> get_param('nlsat.reorder') 'true' """ ptr = (ctypes.c_char_p * 1)() From 1cd1a42618a62f321b58cfe3e2cb8d208508c7cd Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 3 Dec 2012 16:02:04 -0800 Subject: [PATCH 105/133] cleanup, fix repeated use of fmls in validator Signed-off-by: Nikolaj Bjorner --- src/muz_qe/dl_context.cpp | 7 +++--- src/muz_qe/dl_context.h | 9 ------- src/muz_qe/pdr_context.cpp | 3 ++- src/muz_qe/pdr_util.cpp | 50 -------------------------------------- src/muz_qe/rel_context.h | 3 ++- 5 files changed, 8 insertions(+), 64 deletions(-) diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 0f9f1d520..7a46228ce 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -925,13 +925,14 @@ namespace datalog { m_cancel = false; if (m_pdr.get()) m_pdr->cleanup(); if (m_bmc.get()) m_bmc->cleanup(); + if (m_rel.get()) m_rel->cleanup(); } class context::engine_type_proc { - ast_manager& m; - arith_util a; + ast_manager& m; + arith_util a; datatype_util dt; - DL_ENGINE m_engine; + DL_ENGINE m_engine; public: engine_type_proc(ast_manager& m): m(m), a(m), dt(m), m_engine(DATALOG_ENGINE) {} diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index 89446ce3b..f84050e68 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -417,15 +417,6 @@ namespace datalog { */ bool result_contains_fact(relation_fact const& f); -#if 0 - /** - \brief display facts generated for query. - */ - void display_output_facts(std::ostream & out) const { - get_rel_context().get_rmanager().display_output_tables(out); - } -#endif - rel_context& get_rel_context() { ensure_rel(); return *m_rel; } private: diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 974c9251e..9faee3ab0 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1387,7 +1387,7 @@ namespace pdr { break; } case l_false: { - expr_ref_vector refs(m), fmls(m); + expr_ref_vector refs(m); expr_ref tmp(m); model_ref model; vector rs; @@ -1402,6 +1402,7 @@ namespace pdr { for (unsigned i = 0; i < rules.size(); ++i) { datalog::rule& r = *rules[i]; model->eval(r.get_head(), tmp); + expr_ref_vector fmls(m); fmls.push_back(m.mk_not(tmp)); unsigned utsz = r.get_uninterpreted_tail_size(); unsigned tsz = r.get_tail_size(); diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index 515f61338..fd08b1aad 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -86,48 +86,6 @@ namespace pdr { return res.str(); } - ///////////////////////// - // select elimination rewriter - // - - 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) {} - }; - - - 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) {} - }; - ///////////////////////// @@ -238,13 +196,6 @@ namespace pdr { result.push_back(m.mk_not(e)); } } -#if 0 - 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; - } -#endif reset(); TRACE("pdr", tout << "minimized model:\n"; @@ -1266,6 +1217,5 @@ namespace pdr { template class rewriter_tpl; -template class rewriter_tpl; diff --git a/src/muz_qe/rel_context.h b/src/muz_qe/rel_context.h index 8e0ea4a16..5fa2486b4 100644 --- a/src/muz_qe/rel_context.h +++ b/src/muz_qe/rel_context.h @@ -73,7 +73,8 @@ namespace datalog { void inherit_predicate_kind(func_decl* new_pred, func_decl* orig_pred); void cancel() { m_cancel = true; } - + + void cleanup() { m_cancel = false; } /** From 54e452a1afd9676177da8a699b58c8363d2cfded Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 16:58:44 -0800 Subject: [PATCH 106/133] chasing bug in the Java bindings Signed-off-by: Leonardo de Moura --- examples/java/JavaExample.java | 42 +++++++++++++++++++++++++++++++--- src/api/z3_replayer.cpp | 10 ++++++-- src/smt/smt_setup.cpp | 14 ++++++------ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 4d9b6dc1f..0d5f01fc3 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -182,6 +182,7 @@ class JavaExample public void SimpleExample() throws Z3Exception { System.out.println("SimpleExample"); + Log.Append("SimpleExample"); { Context ctx = new Context(); @@ -367,6 +368,7 @@ class JavaExample void ArrayExample1(Context ctx) throws Z3Exception, TestFailedException { System.out.println("ArrayExample1"); + Log.Append("ArrayExample1"); Goal g = ctx.MkGoal(true, false, false); ArraySort asort = ctx.MkArraySort(ctx.IntSort(), ctx.MkBitVecSort(32)); @@ -416,6 +418,7 @@ class JavaExample TestFailedException { System.out.println("ArrayExample2"); + Log.Append("ArrayExample2"); Sort int_type = ctx.IntSort(); Sort array_type = ctx.MkArraySort(int_type, int_type); @@ -465,6 +468,7 @@ class JavaExample TestFailedException { System.out.println("ArrayExample3"); + Log.Append("ArrayExample2"); for (int n = 2; n <= 5; n++) { @@ -503,6 +507,7 @@ class JavaExample void SudokuExample(Context ctx) throws Z3Exception, TestFailedException { System.out.println("SudokuExample"); + Log.Append("SudokuExample"); // 9x9 matrix of integer variables IntExpr[][] X = new IntExpr[9][]; @@ -609,6 +614,7 @@ class JavaExample void QuantifierExample1(Context ctx) throws Z3Exception { System.out.println("QuantifierExample"); + Log.Append("QuantifierExample"); Sort[] types = new Sort[3]; IntExpr[] xs = new IntExpr[3]; @@ -654,6 +660,7 @@ class JavaExample { System.out.println("QuantifierExample2"); + Log.Append("QuantifierExample2"); Expr q1, q2; FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort(), ctx.IntSort()); @@ -710,9 +717,11 @@ class JavaExample public void QuantifierExample3() throws Z3Exception, TestFailedException { System.out.println("QuantifierExample3"); + Log.Append("QuantifierExample3"); HashMap cfg = new HashMap(); - cfg.put("smt.mbqi", "false"); + // We must set a global or provide an argument to Prove + // cfg.put("mbqi", "false"); cfg.put("proof", "true"); cfg.put("auto_config", "false"); @@ -759,9 +768,11 @@ class JavaExample public void QuantifierExample4() throws Z3Exception, TestFailedException { System.out.println("QuantifierExample4"); + Log.Append("QuantifierExample4"); HashMap cfg = new HashMap(); - cfg.put("smt.mbqi", "false"); + // We must set a global or provide an argument to Prove + // cfg.put("mbqi", "false"); cfg.put("proof", "true"); cfg.put("auto_config", "false"); @@ -1117,6 +1128,7 @@ class JavaExample void LogicExample(Context ctx) throws Z3Exception, TestFailedException { System.out.println("LogicTest"); + Log.Append("LogicTest"); Context.ToggleWarningMessages(true); @@ -1148,6 +1160,7 @@ class JavaExample void ParOrExample(Context ctx) throws Z3Exception, TestFailedException { System.out.println("ParOrExample"); + Log.Append("ParOrExample"); BitVecSort bvs = ctx.MkBitVecSort(32); Expr x = ctx.MkConst("x", bvs); @@ -1179,6 +1192,7 @@ class JavaExample TestFailedException { System.out.println("FindModelExample1"); + Log.Append("FindModelExample1"); BoolExpr x = ctx.MkBoolConst("x"); BoolExpr y = ctx.MkBoolConst("y"); @@ -1195,7 +1209,8 @@ class JavaExample public void FindModelExample2(Context ctx) throws Z3Exception, TestFailedException { - System.out.println("find_model_example2"); + System.out.println("FindModelExample2"); + Log.Append("FindModelExample2"); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); @@ -1235,6 +1250,7 @@ class JavaExample TestFailedException { System.out.println("ProveExample1"); + Log.Append("ProveExample1"); /* create uninterpreted type. */ Sort U = ctx.MkUninterpretedSort(ctx.MkSymbol("U")); @@ -1281,6 +1297,7 @@ class JavaExample TestFailedException { System.out.println("ProveExample2"); + Log.Append("ProveExample2"); /* declare function g */ Sort I = ctx.IntSort(); @@ -1336,6 +1353,7 @@ class JavaExample TestFailedException { System.out.println("PushPopExample1"); + Log.Append("PushPopExample1"); /* create a big number */ IntSort int_type = ctx.IntSort(); @@ -1402,6 +1420,7 @@ class JavaExample TestFailedException { System.out.println("TupleExample"); + Log.Append("TupleExample"); Sort int_type = ctx.IntSort(); TupleSort tuple = ctx.MkTupleSort(ctx.MkSymbol("mk_tuple"), // name of @@ -1436,6 +1455,7 @@ class JavaExample TestFailedException { System.out.println("BitvectorExample1"); + Log.Append("BitvectorExample1"); Sort bv_type = ctx.MkBitVecSort(32); BitVecExpr x = (BitVecExpr) ctx.MkConst("x", bv_type); @@ -1457,6 +1477,7 @@ class JavaExample TestFailedException { System.out.println("BitvectorExample2"); + Log.Append("BitvectorExample2"); /* construct x ^ y - 103 == x * y */ Sort bv_type = ctx.MkBitVecSort(32); @@ -1482,6 +1503,7 @@ class JavaExample TestFailedException { System.out.println("ParserExample1"); + Log.Append("ParserExample1"); ctx.ParseSMTLIBString( "(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))", @@ -1499,6 +1521,7 @@ class JavaExample TestFailedException { System.out.println("ParserExample2"); + Log.Append("ParserExample2"); Symbol[] declNames = { ctx.MkSymbol("a"), ctx.MkSymbol("b") }; FuncDecl a = ctx.MkConstDecl(declNames[0], ctx.MkIntSort()); @@ -1517,6 +1540,7 @@ class JavaExample public void ParserExample3(Context ctx) throws Exception { System.out.println("ParserExample3"); + Log.Append("ParserExample3"); /* declare function g */ Sort I = ctx.MkIntSort(); @@ -1539,6 +1563,7 @@ class JavaExample public void ParserExample4(Context ctx) throws Z3Exception { System.out.println("ParserExample4"); + Log.Append("ParserExample4"); ctx.ParseSMTLIBString( "(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))", @@ -1585,6 +1610,7 @@ class JavaExample public void ITEExample(Context ctx) throws Z3Exception { System.out.println("ITEExample"); + Log.Append("ITEExample"); BoolExpr f = ctx.MkFalse(); Expr one = ctx.MkInt(1); @@ -1600,6 +1626,7 @@ class JavaExample TestFailedException { System.out.println("EnumExample"); + Log.Append("EnumExample"); Symbol name = ctx.MkSymbol("fruit"); @@ -1645,6 +1672,7 @@ class JavaExample TestFailedException { System.out.println("ListExample"); + Log.Append("ListExample"); Sort int_ty; ListSort int_list; @@ -1711,6 +1739,7 @@ class JavaExample TestFailedException { System.out.println("TreeExample"); + Log.Append("TreeExample"); Sort cell; FuncDecl nil_decl, is_nil_decl, cons_decl, is_cons_decl, car_decl, cdr_decl; @@ -1786,6 +1815,7 @@ class JavaExample TestFailedException { System.out.println("ForestExample"); + Log.Append("ForestExample"); Sort tree, forest; FuncDecl nil1_decl, is_nil1_decl, cons1_decl, is_cons1_decl, car1_decl, cdr1_decl; @@ -1901,6 +1931,7 @@ class JavaExample public void EvalExample1(Context ctx) throws Z3Exception { System.out.println("EvalExample1"); + Log.Append("EvalExample1"); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); @@ -1940,6 +1971,7 @@ class JavaExample public void EvalExample2(Context ctx) throws Z3Exception { System.out.println("EvalExample2"); + Log.Append("EvalExample2"); Sort int_type = ctx.IntSort(); TupleSort tuple = ctx.MkTupleSort(ctx.MkSymbol("mk_tuple"), // name of @@ -2063,6 +2095,7 @@ class JavaExample public void FindSmallModelExample(Context ctx) throws Z3Exception { System.out.println("FindSmallModelExample"); + Log.Append("FindSmallModelExample"); BitVecExpr x = ctx.MkBVConst("x", 32); BitVecExpr y = ctx.MkBVConst("y", 32); @@ -2079,6 +2112,7 @@ class JavaExample public void SimplifierExample(Context ctx) throws Z3Exception { System.out.println("SimplifierExample"); + Log.Append("SimplifierExample"); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); @@ -2098,6 +2132,7 @@ class JavaExample public void UnsatCoreAndProofExample() throws Z3Exception { System.out.println("UnsatCoreAndProofExample"); + Log.Append("UnsatCoreAndProofExample"); HashMap cfg = new HashMap(); cfg.put("proof", "true"); @@ -2144,6 +2179,7 @@ class JavaExample public void FiniteDomainExample(Context ctx) throws Z3Exception { System.out.println("FiniteDomainExample"); + Log.Append("FiniteDomainExample"); FiniteDomainSort s = ctx.MkFiniteDomainSort("S", 10); FiniteDomainSort t = ctx.MkFiniteDomainSort("T", 10); diff --git a/src/api/z3_replayer.cpp b/src/api/z3_replayer.cpp index b41ef876c..079516145 100644 --- a/src/api/z3_replayer.cpp +++ b/src/api/z3_replayer.cpp @@ -232,8 +232,11 @@ struct z3_replayer::imp { } void read_ptr() { - if (!(('0' <= curr() && curr() <= '9') || ('A' <= curr() && curr() <= 'F') || ('a' <= curr() && curr() <= 'f'))) + if (!(('0' <= curr() && curr() <= '9') || ('A' <= curr() && curr() <= 'F') || ('a' <= curr() && curr() <= 'f'))) { + TRACE("invalid_ptr", tout << "curr: " << curr() << "\n";); throw z3_replayer_exception("invalid ptr"); + } + unsigned pos = 0; m_ptr = 0; while (true) { char c = curr(); @@ -246,10 +249,13 @@ struct z3_replayer::imp { else if ('A' <= c && c <= 'F') { m_ptr = m_ptr * 16 + 10 + (c - 'A'); } + else if (pos == 1 && (c == 'x' || c == 'X')) { + // support for 0x.... notation + } else { return; } - next(); + next(); pos++; } } diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index f088870a4..77c1be886 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -266,7 +266,7 @@ namespace smt { // Moreover, if model construction is enabled, then rational numbers may be needed // to compute the actual value of epsilon even if the input does not have rational numbers. // Example: (x < 1) and (x > 0) - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } else if (!m_params.m_arith_auto_config_simplex && is_dense(st)) { @@ -343,7 +343,7 @@ namespace smt { tout << "RELEVANCY: " << m_params.m_relevancy_lvl << "\n"; tout << "ARITH_EQ_BOUNDS: " << m_params.m_arith_eq_bounds << "\n";); - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } else if (!m_params.m_arith_auto_config_simplex && is_dense(st)) { @@ -394,7 +394,7 @@ namespace smt { m_params.m_lemma_gc_half = true; m_params.m_restart_strategy = RS_GEOMETRIC; - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } else if (st.m_arith_k_sum < rational(INT_MAX / 8)) @@ -409,7 +409,7 @@ namespace smt { m_params.m_restart_strategy = RS_GEOMETRIC; m_params.m_restart_factor = 1.5; m_params.m_restart_adaptive = false; - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } // else if (st.m_arith_k_sum < rational(INT_MAX / 8)) @@ -683,7 +683,7 @@ namespace smt { } void setup::setup_i_arith() { - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } else { @@ -692,7 +692,7 @@ namespace smt { } void setup::setup_mi_arith() { - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } else { @@ -734,7 +734,7 @@ namespace smt { } break; default: - if (m_params.m_proof_mode != PGM_DISABLED) { + if (m_manager.proof_mode() != PGM_DISABLED) { m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); } // else if (m_params.m_arith_fixnum) { From 8191cc1951cb14c16b4af357d3b98a076092d114 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 3 Dec 2012 18:44:27 -0800 Subject: [PATCH 107/133] fixed problems with logger and invalid assertion Signed-off-by: Leonardo de Moura --- src/api/api_model.cpp | 2 +- src/smt/dyn_ack.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/api_model.cpp b/src/api/api_model.cpp index 80577efee..f26ffeeba 100644 --- a/src/api/api_model.cpp +++ b/src/api/api_model.cpp @@ -201,7 +201,7 @@ extern "C" { LOG_Z3_get_as_array_func_decl(c, a); RESET_ERROR_CODE(); if (is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) { - return of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast())); + RETURN_Z3(of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast()))); } else { SET_ERROR_CODE(Z3_INVALID_ARG); diff --git a/src/smt/dyn_ack.cpp b/src/smt/dyn_ack.cpp index fc9b8939f..533d143c3 100644 --- a/src/smt/dyn_ack.cpp +++ b/src/smt/dyn_ack.cpp @@ -58,7 +58,7 @@ namespace smt { \remark if negate == true, then the hypothesis is actually (not (= lhs rhs)) */ proof * mk_hypothesis(ast_manager & m, app * eq, bool negate, expr * lhs, expr * rhs) { - SASSERT(m.is_eq(eq)); + SASSERT(m.is_eq(eq) || m.is_iff(eq)); SASSERT((eq->get_arg(0) == lhs && eq->get_arg(1) == rhs) || (eq->get_arg(0) == rhs && eq->get_arg(1) == lhs)); app * h = negate ? m.mk_not(eq) : eq; From f7528456da2c20c68d6c00a997f6ef12a8486d8f Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 4 Dec 2012 03:40:21 +0000 Subject: [PATCH 108/133] Fix slight inconsistencies in use of \sa --- src/api/z3_api.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 07748e0e1..5ef92b931 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1428,7 +1428,7 @@ extern "C" { /** \brief Set a value of a context parameter. - \sa Use #Z3_global_param_set. + \sa Z3_global_param_set def_API('Z3_update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) */ @@ -1437,7 +1437,7 @@ extern "C" { /** \brief Return the value of a context parameter. - \sa Use #Z3_global_param_get + \sa Z3_global_param_get def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) */ @@ -1707,7 +1707,7 @@ extern "C" { use the APIs for creating numerals and pass a numeric constant together with the sort returned by this call. - \sa Z3_get_finite_domain_sort_size. + \sa Z3_get_finite_domain_sort_size def_API('Z3_mk_finite_domain_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT64))) */ From 9754ccf8a14750eded85360c96414e1736846fe0 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 11:16:42 -0800 Subject: [PATCH 109/133] fixing problems with the new parameter framework Signed-off-by: Leonardo de Moura --- src/cmd_context/basic_cmds.cpp | 4 ++-- src/cmd_context/cmd_context.cpp | 10 ++++++++++ src/cmd_context/cmd_context.h | 1 + src/parsers/smt2/smt2parser.cpp | 22 ++++++++++++++++------ src/smt/params/smt_params_helper.pyg | 1 + src/smt/params/theory_arith_params.cpp | 1 + src/tactic/core/nnf_tactic.cpp | 2 +- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index df9efc4dd..8f65485ae 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -307,7 +307,7 @@ class set_option_cmd : public set_get_option_cmd { try { gparams::set(m_option, value); env_params::updt_params(); - ctx.params().updt_params(); + ctx.global_params_updated(); } catch (gparams::exception ex) { throw cmd_exception(ex.msg()); @@ -517,7 +517,7 @@ public: } else { try { - std::string val = gparams::get_value(opt); + ctx.regular_stream() << gparams::get_value(opt) << std::endl; } catch (gparams::exception ex) { ctx.print_unsupported(opt); diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index b27e1e177..0380e91ea 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -342,6 +342,16 @@ cmd_context::~cmd_context() { m_check_sat_result = 0; } +void cmd_context::global_params_updated() { + m_params.updt_params(); + if (m_solver) { + params_ref p; + if (!m_params.m_auto_config) + p.set_bool("auto_config", false); + m_solver->updt_params(p); + } +} + void cmd_context::set_produce_models(bool f) { if (m_solver) m_solver->set_produce_models(f); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index ca3ada7cf..2edc87ca6 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -249,6 +249,7 @@ public: cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); ~cmd_context(); context_params & params() { return m_params; } + void global_params_updated(); // this method should be invoked when global (and module) params are updated. void set_logic(symbol const & s); bool has_logic() const { return m_logic != symbol::null; } symbol const & get_logic() const { return m_logic; } diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index c0c8d5bc5..ee93dca2f 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -35,6 +35,7 @@ namespace smt2 { class parser { cmd_context & m_ctx; + params_ref m_params; scanner m_scanner; scanner::token m_curr; cmd * m_curr_cmd; @@ -2285,6 +2286,10 @@ namespace smt2 { shrink(m_sexpr_stack, sexpr_spos); m_symbol_stack.shrink(sym_spos); m_num_bindings = 0; + // HACK for propagating the update of parser parameters + if (norm_param_name(s) == "set_option") { + updt_params(); + } return; } else { @@ -2357,9 +2362,10 @@ namespace smt2 { } public: - parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & _p): + parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & p): m_ctx(ctx), - m_scanner(ctx, is, interactive, _p), + m_params(p), + m_scanner(ctx, is, interactive, p), m_curr(scanner::NULL_TOKEN), m_curr_cmd(0), m_num_bindings(0), @@ -2397,15 +2403,19 @@ namespace smt2 { // the following assertion does not hold if ctx was already attached to an AST manager before the parser object is created. // SASSERT(!m_ctx.has_manager()); - parser_params p(_p); - m_ignore_user_patterns = p.ignore_user_patterns(); - m_ignore_bad_patterns = p.ignore_bad_patterns(); - m_display_error_for_vs = p.error_for_visual_studio(); + updt_params(); } ~parser() { reset_stack(); } + + void updt_params() { + parser_params p(m_params); + m_ignore_user_patterns = p.ignore_user_patterns(); + m_ignore_bad_patterns = p.ignore_bad_patterns(); + m_display_error_for_vs = p.error_for_visual_studio(); + } void reset() { reset_stack(); diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg index bcdf78b73..ee583ff85 100644 --- a/src/smt/params/smt_params_helper.pyg +++ b/src/smt/params/smt_params_helper.pyg @@ -35,6 +35,7 @@ def_module_params(module_name='smt', ('arith.nl.rounds', UINT, 1024, 'threshold for number of (nested) final checks for non linear arithmetic'), ('arith.euclidean_solver', BOOL, False, 'eucliean solver for linear integer arithmetic'), ('arith.propagate_eqs', BOOL, True, 'propagate (cheap) equalities'), + ('arith.propagation_mode', UINT, 2, '0 - no propagation, 1 - propagate existing literals, 2 - refine bounds'), ('arith.branch_cut_ratio', UINT, 2, 'branch/cut ratio for linear integer arithmetic'), ('arith.int_eq_branch', BOOL, False, 'branching using derived integer equations'), ('arith.ignore_int', BOOL, False, 'treat integer variables as real'))) diff --git a/src/smt/params/theory_arith_params.cpp b/src/smt/params/theory_arith_params.cpp index 5a1101524..7281a5daa 100644 --- a/src/smt/params/theory_arith_params.cpp +++ b/src/smt/params/theory_arith_params.cpp @@ -32,6 +32,7 @@ void theory_arith_params::updt_params(params_ref const & _p) { m_arith_branch_cut_ratio = p.arith_branch_cut_ratio(); m_arith_int_eq_branching = p.arith_int_eq_branch(); m_arith_ignore_int = p.arith_ignore_int(); + m_arith_bound_prop = static_cast(p.arith_propagation_mode()); } diff --git a/src/tactic/core/nnf_tactic.cpp b/src/tactic/core/nnf_tactic.cpp index fdaf03d55..a79a4ed06 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -120,7 +120,7 @@ tactic * mk_snf_tactic(ast_manager & m, params_ref const & p) { tactic * mk_nnf_tactic(ast_manager & m, params_ref const & p) { params_ref new_p(p); - new_p.set_sym("nnf_mode", symbol("full")); + new_p.set_sym("mode", symbol("full")); TRACE("nnf", tout << "mk_nnf: " << new_p << "\n";); return using_params(mk_snf_tactic(m, p), new_p); } From ff999773b2a75fa8c9f362d00c31d38ea116447e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 11:17:24 -0800 Subject: [PATCH 110/133] adjusting verbose msgs Signed-off-by: Leonardo de Moura --- src/smt/smt_model_checker.cpp | 15 +++++++-------- src/smt/smt_quantifier.cpp | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index 704c272ee..53f3af961 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -312,7 +312,7 @@ namespace smt { TRACE("model_checker", tout << "MODEL_CHECKER INVOKED\n"; tout << "model:\n"; model_pp(tout, *m_curr_model);); if (m_params.m_mbqi_trace) { - verbose_stream() << "[mbqi] started\n"; + verbose_stream() << "(smt.mbqi \"started\")\n"; } init_aux_context(); @@ -324,13 +324,12 @@ namespace smt { quantifier * q = *it; if (m_context->is_relevant(q) && m_context->get_assignment(q) == l_true) { if (m_params.m_mbqi_trace && q->get_qid() != symbol::null) { - verbose_stream() << "[mbqi] checking: " << q->get_qid() << "\n"; + verbose_stream() << "(smt.mbqi :checking " << q->get_qid() << ")\n"; } found_relevant = true; if (!check(q)) { - IF_VERBOSE(5, verbose_stream() << "current model does not satisfy: " << q->get_qid() << "\n";); - if (m_params.m_mbqi_trace) { - verbose_stream() << "[mbqi] failed " << q->get_qid() << "\n"; + if (m_params.m_mbqi_trace || get_verbosity_level() >= 5) { + verbose_stream() << "(smt.mbqi :failed " << q->get_qid() << ")\n"; } num_failures++; } @@ -347,9 +346,9 @@ namespace smt { m_curr_model->cleanup(); if (m_params.m_mbqi_trace) { if (num_failures == 0) - verbose_stream() << "[mbqi] succeeded\n"; + verbose_stream() << "(smt.mbqi :succeeded true)\n"; else - verbose_stream() << "[mbqi] num failures " << num_failures << "\n"; + verbose_stream() << "(smt.mbqi :num-failures " << num_failures << ")\n"; } return num_failures == 0; } @@ -360,7 +359,7 @@ namespace smt { } void model_checker::restart_eh() { - IF_VERBOSE(100, verbose_stream() << "instantiating new instances...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.mbqi \"instantiating new instances...\")\n";); assert_new_instances(); reset_new_instances(); } diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 799dd3c49..d56fe0cff 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -562,7 +562,7 @@ namespace smt { virtual quantifier_manager::check_model_result check_model(proto_model * m, obj_map const & root2value) { if (m_fparams->m_mbqi) { - IF_VERBOSE(10, verbose_stream() << "model based quantifier instantiation...\n";); + IF_VERBOSE(10, verbose_stream() << "(smt.mbqi)\n";); if (m_model_checker->check(m, root2value)) { return quantifier_manager::SAT; } @@ -594,7 +594,6 @@ namespace smt { final_check_status final_check_quant() { if (use_ematching()) { if (m_lazy_matching_idx < m_fparams->m_qi_max_lazy_multipattern_matching) { - IF_VERBOSE(100, verbose_stream() << "matching delayed multi-patterns... \n";); m_lazy_mam->rematch(); m_context->push_trail(value_trail(m_lazy_matching_idx)); m_lazy_matching_idx++; From 4d1d784a1c3de895d1ddd46b92fb3c8fc070ca6a Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 4 Dec 2012 19:32:20 +0000 Subject: [PATCH 111/133] Java+.Net Examples: refactoring Signed-off-by: Christoph M. Wintersteiger --- examples/dotnet/Program.cs | 238 ++++++++++++------------ examples/java/JavaExample.java | 321 ++++++++++++++++----------------- 2 files changed, 274 insertions(+), 285 deletions(-) diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index 75393378b..2085de296 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -248,10 +248,13 @@ namespace test_mapi return res; } - static void Prove(Context ctx, BoolExpr f, params BoolExpr[] assumptions) + static void Prove(Context ctx, BoolExpr f, bool useMBQI = false, params BoolExpr[] assumptions) { Console.WriteLine("Proving: " + f); Solver s = ctx.MkSolver(); + Params p = ctx.MkParams(); + p.Add("mbqi", useMBQI); + s.Parameters = p; foreach (BoolExpr a in assumptions) s.Assert(a); s.Assert(ctx.MkNot(f)); @@ -270,10 +273,13 @@ namespace test_mapi } } - static void Disprove(Context ctx, BoolExpr f, params BoolExpr[] assumptions) + static void Disprove(Context ctx, BoolExpr f, bool useMBQI = false, params BoolExpr[] assumptions) { Console.WriteLine("Disproving: " + f); Solver s = ctx.MkSolver(); + Params p = ctx.MkParams(); + p.Add("mbqi", useMBQI); + s.Parameters = p; foreach (BoolExpr a in assumptions) s.Assert(a); s.Assert(ctx.MkNot(f)); @@ -298,7 +304,7 @@ namespace test_mapi ArithExpr xr = (ArithExpr)ctx.MkConst(ctx.MkSymbol("x"), ctx.MkRealSort()); ArithExpr yr = (ArithExpr)ctx.MkConst(ctx.MkSymbol("y"), ctx.MkRealSort()); - Goal g4 = ctx.MkGoal(true, false, true); + Goal g4 = ctx.MkGoal(true); g4.Assert(ctx.MkGt(xr, ctx.MkReal(10, 1))); g4.Assert(ctx.MkEq(yr, ctx.MkAdd(xr, ctx.MkReal(1, 1)))); g4.Assert(ctx.MkGt(yr, ctx.MkReal(1, 1))); @@ -330,7 +336,7 @@ namespace test_mapi { Console.WriteLine("ArrayExample1"); - Goal g = ctx.MkGoal(true, false, false); + Goal g = ctx.MkGoal(true); ArraySort asort = ctx.MkArraySort(ctx.IntSort, ctx.MkBitVecSort(32)); ArrayExpr aex = (ArrayExpr)ctx.MkConst(ctx.MkSymbol("MyArray"), asort); Expr sel = ctx.MkSelect(aex, ctx.MkInt(0)); @@ -640,95 +646,76 @@ namespace test_mapi /// Prove that f(x, y) = f(w, v) implies y = v when /// f is injective in the second argument. /// - public static void QuantifierExample3() + public static void QuantifierExample3(Context ctx) { Console.WriteLine("QuantifierExample3"); - - Dictionary cfg = new Dictionary() { - { "MBQI", "false" }, - { "PROOF_MODE", "2" }, - { "AUTO_CONFIG", "false" } - }; - /* If quantified formulas are asserted in a logical context, then the model produced by Z3 should be viewed as a potential model. */ - using (Context ctx = new Context(cfg)) - { - /* declare function f */ - Sort I = ctx.IntSort; - FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + /* declare function f */ + Sort I = ctx.IntSort; + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); - /* f is injective in the second argument. */ - BoolExpr inj = InjAxiom(ctx, f, 1); + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiom(ctx, f, 1); - /* create x, y, v, w, fxy, fwv */ - Expr x = ctx.MkIntConst("x"); - Expr y = ctx.MkIntConst("y"); - Expr v = ctx.MkIntConst("v"); - Expr w = ctx.MkIntConst("w"); - Expr fxy = ctx.MkApp(f, x, y); - Expr fwv = ctx.MkApp(f, w, v); + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, x, y); + Expr fwv = ctx.MkApp(f, w, v); - /* f(x, y) = f(w, v) */ - BoolExpr p1 = ctx.MkEq(fxy, fwv); + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); - /* prove f(x, y) = f(w, v) implies y = v */ - BoolExpr p2 = ctx.MkEq(y, v); - Prove(ctx, p2, inj, p1); + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, false, inj, p1); - /* disprove f(x, y) = f(w, v) implies x = w */ - BoolExpr p3 = ctx.MkEq(x, w); - Disprove(ctx, p3, inj, p1); - } + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, false, inj, p1); } /// /// Prove that f(x, y) = f(w, v) implies y = v when /// f is injective in the second argument. /// - public static void QuantifierExample4() + public static void QuantifierExample4(Context ctx) { Console.WriteLine("QuantifierExample4"); - Dictionary cfg = new Dictionary() { - { "MBQI", "false" }, - { "PROOF_MODE", "2" }, - { "AUTO_CONFIG","false" }}; - - /* If quantified formulas are asserted in a logical context, then the model produced by Z3 should be viewed as a potential model. */ - using (Context ctx = new Context(cfg)) - { - /* declare function f */ - Sort I = ctx.IntSort; - FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + /* declare function f */ + Sort I = ctx.IntSort; + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); - /* f is injective in the second argument. */ - BoolExpr inj = InjAxiomAbs(ctx, f, 1); + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiomAbs(ctx, f, 1); - /* create x, y, v, w, fxy, fwv */ - Expr x = ctx.MkIntConst("x"); - Expr y = ctx.MkIntConst("y"); - Expr v = ctx.MkIntConst("v"); - Expr w = ctx.MkIntConst("w"); - Expr fxy = ctx.MkApp(f, x, y); - Expr fwv = ctx.MkApp(f, w, v); + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, x, y); + Expr fwv = ctx.MkApp(f, w, v); - /* f(x, y) = f(w, v) */ - BoolExpr p1 = ctx.MkEq(fxy, fwv); + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); - /* prove f(x, y) = f(w, v) implies y = v */ - BoolExpr p2 = ctx.MkEq(y, v); - Prove(ctx, p2, inj, p1); + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, false, inj, p1); - /* disprove f(x, y) = f(w, v) implies x = w */ - BoolExpr p3 = ctx.MkEq(x, w); - Disprove(ctx, p3, inj, p1); - } + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, false, inj, p1); } /// @@ -756,7 +743,7 @@ namespace test_mapi BoolExpr trivial_eq = ctx.MkEq(fapp, fapp); BoolExpr nontrivial_eq = ctx.MkEq(fapp, fapp2); - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true); g.Assert(trivial_eq); g.Assert(nontrivial_eq); Console.WriteLine("Goal: " + g); @@ -784,18 +771,18 @@ namespace test_mapi throw new TestFailedException(); - Goal g2 = ctx.MkGoal(true, true, false); + Goal g2 = ctx.MkGoal(true, true); ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2); if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedSat) throw new TestFailedException(); - g2 = ctx.MkGoal(true, true, false); + g2 = ctx.MkGoal(true, true); g2.Assert(ctx.MkFalse()); ar = ApplyTactic(ctx, ctx.MkTactic("smt"), g2); if (ar.NumSubgoals != 1 || !ar.Subgoals[0].IsDecidedUnsat) throw new TestFailedException(); - Goal g3 = ctx.MkGoal(true, true, false); + Goal g3 = ctx.MkGoal(true, true); Expr xc = ctx.MkConst(ctx.MkSymbol("x"), ctx.IntSort); Expr yc = ctx.MkConst(ctx.MkSymbol("y"), ctx.IntSort); g3.Assert(ctx.MkEq(xc, ctx.MkNumeral(1, ctx.IntSort))); @@ -1063,7 +1050,7 @@ namespace test_mapi // Or perhaps a tactic for QF_BV - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true); g.Assert(eq); Tactic t = ctx.MkTactic("qfbv"); @@ -1086,7 +1073,7 @@ namespace test_mapi Expr y = ctx.MkConst("y", bvs); BoolExpr q = ctx.MkEq(x, y); - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true); g.Assert(q); Tactic t1 = ctx.MkTactic("qfbv"); @@ -1128,7 +1115,7 @@ namespace test_mapi /// public static void FindModelExample2(Context ctx) { - Console.WriteLine("find_model_example2"); + Console.WriteLine("FindModelExample2"); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); @@ -1250,13 +1237,13 @@ namespace test_mapi /* prove z < 0 */ BoolExpr f = ctx.MkLt(z, zero); Console.WriteLine("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); - Prove(ctx, f, c1, c2, c3); + Prove(ctx, f, false, c1, c2, c3); /* disprove z < -1 */ IntExpr minus_one = ctx.MkInt(-1); f = ctx.MkLt(z, minus_one); Console.WriteLine("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); - Disprove(ctx, f, c1, c2, c3); + Disprove(ctx, f, false, c1, c2, c3); } /// @@ -1448,7 +1435,7 @@ namespace test_mapi BoolExpr thm = ctx.SMTLIBFormulas[0]; Console.WriteLine("formula: {0}", thm); - Prove(ctx, thm, ca); + Prove(ctx, thm, false, ca); } /// @@ -1979,45 +1966,40 @@ namespace test_mapi /// /// Extract unsatisfiable core example /// - public static void UnsatCoreAndProofExample() + public static void UnsatCoreAndProofExample(Context ctx) { Console.WriteLine("UnsatCoreAndProofExample"); - Dictionary cfg = new Dictionary() { { "PROOF_MODE", "2" } }; + Solver solver = ctx.MkSolver(); - using (Context ctx = new Context(cfg)) + BoolExpr pa = ctx.MkBoolConst("PredA"); + BoolExpr pb = ctx.MkBoolConst("PredB"); + BoolExpr pc = ctx.MkBoolConst("PredC"); + BoolExpr pd = ctx.MkBoolConst("PredD"); + BoolExpr p1 = ctx.MkBoolConst("P1"); + BoolExpr p2 = ctx.MkBoolConst("P2"); + BoolExpr p3 = ctx.MkBoolConst("P3"); + BoolExpr p4 = ctx.MkBoolConst("P4"); + BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; + BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); + BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); + BoolExpr f3 = ctx.MkOr(ctx.MkNot(pa), ctx.MkNot(pc)); + BoolExpr f4 = pd; + + solver.Assert(ctx.MkOr(f1, p1)); + solver.Assert(ctx.MkOr(f2, p2)); + solver.Assert(ctx.MkOr(f3, p3)); + solver.Assert(ctx.MkOr(f4, p4)); + Status result = solver.Check(assumptions); + + if (result == Status.UNSATISFIABLE) { - Solver solver = ctx.MkSolver(); - - BoolExpr pa = ctx.MkBoolConst("PredA"); - BoolExpr pb = ctx.MkBoolConst("PredB"); - BoolExpr pc = ctx.MkBoolConst("PredC"); - BoolExpr pd = ctx.MkBoolConst("PredD"); - BoolExpr p1 = ctx.MkBoolConst("P1"); - BoolExpr p2 = ctx.MkBoolConst("P2"); - BoolExpr p3 = ctx.MkBoolConst("P3"); - BoolExpr p4 = ctx.MkBoolConst("P4"); - BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; - BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); - BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); - BoolExpr f3 = ctx.MkOr(ctx.MkNot(pa), ctx.MkNot(pc)); - BoolExpr f4 = pd; - - solver.Assert(ctx.MkOr(f1, p1)); - solver.Assert(ctx.MkOr(f2, p2)); - solver.Assert(ctx.MkOr(f3, p3)); - solver.Assert(ctx.MkOr(f4, p4)); - Status result = solver.Check(assumptions); - - if (result == Status.UNSATISFIABLE) + Console.WriteLine("unsat"); + Console.WriteLine("proof: {0}", solver.Proof); + Console.WriteLine("core: "); + foreach (Expr c in solver.UnsatCore) { - Console.WriteLine("unsat"); - Console.WriteLine("proof: {0}", solver.Proof); - Console.WriteLine("core: "); - foreach (Expr c in solver.UnsatCore) - { - Console.WriteLine("{0}", c); - } + Console.WriteLine("{0}", c); } } } @@ -2054,9 +2036,8 @@ namespace test_mapi SimpleExample(); - using (Context ctx = new Context(new Dictionary() - { { "MODEL", "true"}, - { "PROOF_MODE", "2"} })) + // These examples need model generation turned on. + using (Context ctx = new Context(new Dictionary() { { "model", "true" } })) { BasicTests(ctx); CastingTest(ctx); @@ -2067,25 +2048,16 @@ namespace test_mapi ParOrExample(ctx); FindModelExample1(ctx); FindModelExample2(ctx); - ProveExample1(ctx); - ProveExample2(ctx); PushPopExample1(ctx); ArrayExample1(ctx); - ArrayExample2(ctx); ArrayExample3(ctx); - TupleExample(ctx); BitvectorExample1(ctx); BitvectorExample2(ctx); ParserExample1(ctx); ParserExample2(ctx); - ParserExample3(ctx); ParserExample4(ctx); ParserExample5(ctx); ITEExample(ctx); - EnumExample(ctx); - ListExample(ctx); - TreeExample(ctx); - ForestExample(ctx); EvalExample1(ctx); EvalExample2(ctx); FindSmallModelExample(ctx); @@ -2093,9 +2065,29 @@ namespace test_mapi FiniteDomainExample(ctx); } - QuantifierExample3(); - QuantifierExample4(); - UnsatCoreAndProofExample(); + // These examples need proof generation turned on. + using (Context ctx = new Context(new Dictionary() { { "proof", "true" } })) + { + ProveExample1(ctx); + ProveExample2(ctx); + ArrayExample2(ctx); + TupleExample(ctx); + ParserExample3(ctx); + EnumExample(ctx); + ListExample(ctx); + TreeExample(ctx); + ForestExample(ctx); + UnsatCoreAndProofExample(ctx); + } + + // These examples need proof generation turned on and auto-config set to false. + using (Context ctx = new Context(new Dictionary() + { {"proof", "true" }, + {"auto-config", "false" } })) + { + QuantifierExample3(ctx); + QuantifierExample4(ctx); + } Log.Close(); if (Log.isOpen()) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 0d5f01fc3..b3cb939ac 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -250,24 +250,28 @@ class JavaExample return res; } - void Prove(Context ctx, BoolExpr f) throws Z3Exception, TestFailedException + void Prove(Context ctx, BoolExpr f, boolean useMBQI) throws Z3Exception, + TestFailedException { BoolExpr[] assumptions = new BoolExpr[0]; - Prove(ctx, f, assumptions); + Prove(ctx, f, useMBQI, assumptions); } - void Prove(Context ctx, BoolExpr f, BoolExpr assumption) + void Prove(Context ctx, BoolExpr f, boolean useMBQI, BoolExpr assumption) throws Z3Exception, TestFailedException { BoolExpr[] assumptions = { assumption }; - Prove(ctx, f, assumptions); + Prove(ctx, f, useMBQI, assumptions); } - void Prove(Context ctx, BoolExpr f, BoolExpr[] assumptions) + void Prove(Context ctx, BoolExpr f, boolean useMBQI, BoolExpr[] assumptions) throws Z3Exception, TestFailedException { System.out.println("Proving: " + f); Solver s = ctx.MkSolver(); + Params p = ctx.MkParams(); + p.Add("mbqi", useMBQI); + s.setParameters(p); for (BoolExpr a : assumptions) s.Assert(a); s.Assert(ctx.MkNot(f)); @@ -286,25 +290,28 @@ class JavaExample } } - void Disprove(Context ctx, BoolExpr f) throws Z3Exception, + void Disprove(Context ctx, BoolExpr f, boolean useMBQI) throws Z3Exception, TestFailedException { BoolExpr[] a = {}; - Disprove(ctx, f, a); + Disprove(ctx, f, useMBQI, a); } - void Disprove(Context ctx, BoolExpr f, BoolExpr assumption) + void Disprove(Context ctx, BoolExpr f, boolean useMBQI, BoolExpr assumption) throws Z3Exception, TestFailedException { BoolExpr[] a = { assumption }; - Disprove(ctx, f, a); + Disprove(ctx, f, useMBQI, a); } - void Disprove(Context ctx, BoolExpr f, BoolExpr[] assumptions) - throws Z3Exception, TestFailedException + void Disprove(Context ctx, BoolExpr f, boolean useMBQI, + BoolExpr[] assumptions) throws Z3Exception, TestFailedException { System.out.println("Disproving: " + f); Solver s = ctx.MkSolver(); + Params p = ctx.MkParams(); + p.Add("mbqi", useMBQI); + s.setParameters(p); for (BoolExpr a : assumptions) s.Assert(a); s.Assert(ctx.MkNot(f)); @@ -332,7 +339,7 @@ class JavaExample ctx.MkRealSort()); ArithExpr yr = (ArithExpr) ctx.MkConst(ctx.MkSymbol("y"), ctx.MkRealSort()); - Goal g4 = ctx.MkGoal(true, false, true); + Goal g4 = ctx.MkGoal(true, false, false); g4.Assert(ctx.MkGt(xr, ctx.MkReal(10, 1))); g4.Assert(ctx.MkEq(yr, ctx.MkAdd(new ArithExpr[] { xr, ctx.MkReal(1, 1) }))); @@ -455,7 +462,7 @@ class JavaExample System.out .println("prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))"); System.out.println(thm); - Prove(ctx, thm); + Prove(ctx, thm, false); } // / Show that distinct(a_0, ... , a_n) is @@ -714,101 +721,83 @@ class JavaExample // / f is injective in the second argument. - public void QuantifierExample3() throws Z3Exception, TestFailedException + public void QuantifierExample3(Context ctx) throws Z3Exception, + TestFailedException { System.out.println("QuantifierExample3"); Log.Append("QuantifierExample3"); - HashMap cfg = new HashMap(); - // We must set a global or provide an argument to Prove - // cfg.put("mbqi", "false"); - cfg.put("proof", "true"); - cfg.put("auto_config", "false"); - /* * If quantified formulas are asserted in a logical context, then the * model produced by Z3 should be viewed as a potential model. */ - { - Context ctx = new Context(cfg); + /* declare function f */ + Sort I = ctx.IntSort(); + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); - /* declare function f */ - Sort I = ctx.IntSort(); - FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiom(ctx, f, 1); - /* f is injective in the second argument. */ - BoolExpr inj = InjAxiom(ctx, f, 1); + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); + Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); - /* create x, y, v, w, fxy, fwv */ - Expr x = ctx.MkIntConst("x"); - Expr y = ctx.MkIntConst("y"); - Expr v = ctx.MkIntConst("v"); - Expr w = ctx.MkIntConst("w"); - Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); - Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); - /* f(x, y) = f(w, v) */ - BoolExpr p1 = ctx.MkEq(fxy, fwv); + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, false, new BoolExpr[] { inj, p1 }); - /* prove f(x, y) = f(w, v) implies y = v */ - BoolExpr p2 = ctx.MkEq(y, v); - Prove(ctx, p2, new BoolExpr[] { inj, p1 }); - - /* disprove f(x, y) = f(w, v) implies x = w */ - BoolExpr p3 = ctx.MkEq(x, w); - Disprove(ctx, p3, new BoolExpr[] { inj, p1 }); - } + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, false, new BoolExpr[] { inj, p1 }); } // / Prove that f(x, y) = f(w, v) implies y = v when // / f is injective in the second argument. - public void QuantifierExample4() throws Z3Exception, TestFailedException + public void QuantifierExample4(Context ctx) throws Z3Exception, TestFailedException { System.out.println("QuantifierExample4"); Log.Append("QuantifierExample4"); - HashMap cfg = new HashMap(); - // We must set a global or provide an argument to Prove - // cfg.put("mbqi", "false"); - cfg.put("proof", "true"); - cfg.put("auto_config", "false"); - /* * If quantified formulas are asserted in a logical context, then the * model produced by Z3 should be viewed as a potential model. */ - { - Context ctx = new Context(cfg); - /* declare function f */ - Sort I = ctx.IntSort(); - FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); + /* declare function f */ + Sort I = ctx.IntSort(); + FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { I, I }, I); - /* f is injective in the second argument. */ - BoolExpr inj = InjAxiomAbs(ctx, f, 1); + /* f is injective in the second argument. */ + BoolExpr inj = InjAxiomAbs(ctx, f, 1); - /* create x, y, v, w, fxy, fwv */ - Expr x = ctx.MkIntConst("x"); - Expr y = ctx.MkIntConst("y"); - Expr v = ctx.MkIntConst("v"); - Expr w = ctx.MkIntConst("w"); - Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); - Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); + /* create x, y, v, w, fxy, fwv */ + Expr x = ctx.MkIntConst("x"); + Expr y = ctx.MkIntConst("y"); + Expr v = ctx.MkIntConst("v"); + Expr w = ctx.MkIntConst("w"); + Expr fxy = ctx.MkApp(f, new Expr[] { x, y }); + Expr fwv = ctx.MkApp(f, new Expr[] { w, v }); - /* f(x, y) = f(w, v) */ - BoolExpr p1 = ctx.MkEq(fxy, fwv); + /* f(x, y) = f(w, v) */ + BoolExpr p1 = ctx.MkEq(fxy, fwv); - /* prove f(x, y) = f(w, v) implies y = v */ - BoolExpr p2 = ctx.MkEq(y, v); - Prove(ctx, p2, new BoolExpr[] { inj, p1 }); + /* prove f(x, y) = f(w, v) implies y = v */ + BoolExpr p2 = ctx.MkEq(y, v); + Prove(ctx, p2, false, new BoolExpr[] { inj, p1 }); - /* disprove f(x, y) = f(w, v) implies x = w */ - BoolExpr p3 = ctx.MkEq(x, w); - Disprove(ctx, p3, new BoolExpr[] { inj, p1 }); - } + /* disprove f(x, y) = f(w, v) implies x = w */ + BoolExpr p3 = ctx.MkEq(x, w); + Disprove(ctx, p3, false, new BoolExpr[] { inj, p1 }); } // / Some basic tests. @@ -835,7 +824,7 @@ class JavaExample BoolExpr trivial_eq = ctx.MkEq(fapp, fapp); BoolExpr nontrivial_eq = ctx.MkEq(fapp, fapp2); - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true, false, false); g.Assert(trivial_eq); g.Assert(nontrivial_eq); System.out.println("Goal: " + g); @@ -921,7 +910,7 @@ class JavaExample IntExpr i = ctx.MkInt("1/2"); throw new TestFailedException(); // unreachable } catch (Z3Exception e) - { + { } } @@ -1144,7 +1133,7 @@ class JavaExample System.out.println("solver result: " + res); // Or perhaps a tactic for QF_BV - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true, false, false); g.Assert(eq); Tactic t = ctx.MkTactic("qfbv"); @@ -1167,7 +1156,7 @@ class JavaExample Expr y = ctx.MkConst("y", bvs); BoolExpr q = ctx.MkEq(x, y); - Goal g = ctx.MkGoal(true, false, true); + Goal g = ctx.MkGoal(true, false, false); g.Assert(q); Tactic t1 = ctx.MkTactic("qfbv"); @@ -1271,7 +1260,7 @@ class JavaExample /* prove g(x) = g(y) */ BoolExpr f = ctx.MkEq(gx, gy); System.out.println("prove: x = y implies g(x) = g(y)"); - Prove(ctx, ctx.MkImplies(eq, f)); + Prove(ctx, ctx.MkImplies(eq, f), false); /* create g(g(x)) */ Expr ggx = g.Apply(gx); @@ -1279,7 +1268,7 @@ class JavaExample /* disprove g(g(x)) = g(y) */ f = ctx.MkEq(ggx, gy); System.out.println("disprove: x = y implies g(g(x)) = g(y)"); - Disprove(ctx, ctx.MkImplies(eq, f)); + Disprove(ctx, ctx.MkImplies(eq, f), false); /* Print the model using the custom model printer */ Model m = Check(ctx, ctx.MkNot(f), Status.SATISFIABLE); @@ -1335,14 +1324,14 @@ class JavaExample BoolExpr f = ctx.MkLt(z, zero); System.out .println("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); - Prove(ctx, f, new BoolExpr[] { c1, c2, c3 }); + Prove(ctx, f, false, new BoolExpr[] { c1, c2, c3 }); /* disprove z < -1 */ IntExpr minus_one = ctx.MkInt(-1); f = ctx.MkLt(z, minus_one); System.out .println("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); - Disprove(ctx, f, new BoolExpr[] { c1, c2, c3 }); + Disprove(ctx, f, false, new BoolExpr[] { c1, c2, c3 }); } // / Show how push & pop can be used to create "backtracking" points. @@ -1442,7 +1431,7 @@ class JavaExample Expr n2 = first.Apply(n1); BoolExpr n3 = ctx.MkEq(x, n2); System.out.println("Tuple example: " + n3); - Prove(ctx, n3); + Prove(ctx, n3, false); } // / Simple bit-vector example. @@ -1468,7 +1457,7 @@ class JavaExample BoolExpr thm = ctx.MkIff(c1, c2); System.out .println("disprove: x - 10 <= 0 IFF x <= 10 for (32-bit) machine integers"); - Disprove(ctx, thm); + Disprove(ctx, thm, false); } // / Find x and y such that: x ^ y - 103 == x * y @@ -1555,7 +1544,7 @@ class JavaExample BoolExpr thm = ctx.SMTLIBFormulas()[0]; System.out.println("formula: " + thm); - Prove(ctx, thm, ca); + Prove(ctx, thm, false, ca); } // / Display the declarations, assumptions and formulas in a SMT-LIB string. @@ -1647,15 +1636,16 @@ class JavaExample Expr orange = fruit.Consts()[2]; /* Apples are different from oranges */ - Prove(ctx, ctx.MkNot(ctx.MkEq(apple, orange))); + Prove(ctx, ctx.MkNot(ctx.MkEq(apple, orange)), false); /* Apples pass the apple test */ - Prove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], apple)); + Prove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], apple), false); /* Oranges fail the apple test */ - Disprove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], orange)); + Disprove(ctx, (BoolExpr) ctx.MkApp(fruit.TesterDecls()[0], orange), + false); Prove(ctx, (BoolExpr) ctx.MkNot((BoolExpr) ctx.MkApp( - fruit.TesterDecls()[0], orange))); + fruit.TesterDecls()[0], orange)), false); Expr fruity = ctx.MkConst("fruity", fruit); @@ -1663,7 +1653,8 @@ class JavaExample Prove(ctx, ctx.MkOr(new BoolExpr[] { ctx.MkEq(fruity, apple), - ctx.MkEq(fruity, banana), ctx.MkEq(fruity, orange) })); + ctx.MkEq(fruity, banana), ctx.MkEq(fruity, orange) }), + false); } // / Create a list datatype. @@ -1688,25 +1679,25 @@ class JavaExample l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { ctx.MkInt(2), nil }); /* nil != cons(1, nil) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1)), false); /* cons(2,nil) != cons(1, nil) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(l1, l2))); + Prove(ctx, ctx.MkNot(ctx.MkEq(l1, l2)), false); /* cons(x,nil) = cons(y, nil) => x = y */ x = ctx.MkConst("x", int_ty); y = ctx.MkConst("y", int_ty); l1 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { x, nil }); l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { y, nil }); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y)), false); /* cons(x,u) = cons(x, v) => u = v */ u = ctx.MkConst("u", int_list); v = ctx.MkConst("v", int_list); l1 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { x, u }); l2 = ctx.MkApp(int_list.ConsDecl(), new Expr[] { y, v }); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v)), false); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y)), false); /* is_nil(u) or is_cons(u) */ Prove(ctx, @@ -1714,10 +1705,10 @@ class JavaExample (BoolExpr) ctx.MkApp(int_list.IsNilDecl(), new Expr[] { u }), (BoolExpr) ctx.MkApp(int_list.IsConsDecl(), - new Expr[] { u }) })); + new Expr[] { u }) }), false); /* occurs check u != cons(x,u) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1)), false); /* destructors: is_cons(u) => u = cons(head(u),tail(u)) */ fml1 = ctx.MkEq(u, ctx.MkApp(int_list.ConsDecl(), @@ -1728,9 +1719,9 @@ class JavaExample fml1); System.out.println("Formula " + fml); - Prove(ctx, fml); + Prove(ctx, fml, false); - Disprove(ctx, fml1); + Disprove(ctx, fml1, false); } // / Create a binary tree datatype. @@ -1770,7 +1761,7 @@ class JavaExample l2 = ctx.MkApp(cons_decl, new Expr[] { l1, nil }); /* nil != cons(nil, nil) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(nil, l1)), false); /* cons(x,u) = cons(x, v) => u = v */ u = ctx.MkConst("u", cell); @@ -1779,17 +1770,18 @@ class JavaExample y = ctx.MkConst("y", cell); l1 = ctx.MkApp(cons_decl, new Expr[] { x, u }); l2 = ctx.MkApp(cons_decl, new Expr[] { y, v }); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v)), false); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y)), false); /* is_nil(u) or is_cons(u) */ Prove(ctx, ctx.MkOr(new BoolExpr[] { (BoolExpr) ctx.MkApp(is_nil_decl, new Expr[] { u }), - (BoolExpr) ctx.MkApp(is_cons_decl, new Expr[] { u }) })); + (BoolExpr) ctx.MkApp(is_cons_decl, new Expr[] { u }) }), + false); /* occurs check u != cons(x,u) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1)), false); /* destructors: is_cons(u) => u = cons(car(u),cdr(u)) */ fml1 = ctx.MkEq( @@ -1800,9 +1792,9 @@ class JavaExample ctx.MkApp(cdr_decl, u) })); fml = ctx.MkImplies((BoolExpr) ctx.MkApp(is_cons_decl, u), fml1); System.out.println("Formula " + fml); - Prove(ctx, fml); + Prove(ctx, fml, false); - Disprove(ctx, fml1); + Disprove(ctx, fml1, false); } // / Create a forest of trees. @@ -1904,8 +1896,8 @@ class JavaExample f3 = ctx.MkApp(cons1_decl, new Expr[] { t1, f1 }); /* nil != cons(nil,nil) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(nil1, f1))); - Prove(ctx, ctx.MkNot(ctx.MkEq(nil2, t1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(nil1, f1)), false); + Prove(ctx, ctx.MkNot(ctx.MkEq(nil2, t1)), false); /* cons(x,u) = cons(x, v) => u = v */ u = ctx.MkConst("u", forest); @@ -1914,16 +1906,16 @@ class JavaExample y = ctx.MkConst("y", tree); l1 = ctx.MkApp(cons1_decl, new Expr[] { x, u }); l2 = ctx.MkApp(cons1_decl, new Expr[] { y, v }); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v))); - Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y))); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(u, v)), false); + Prove(ctx, ctx.MkImplies(ctx.MkEq(l1, l2), ctx.MkEq(x, y)), false); /* is_nil(u) or is_cons(u) */ Prove(ctx, ctx.MkOr(new BoolExpr[] { (BoolExpr) ctx.MkApp(is_nil1_decl, new Expr[] { u }), - (BoolExpr) ctx.MkApp(is_cons1_decl, new Expr[] { u }) })); + (BoolExpr) ctx.MkApp(is_cons1_decl, new Expr[] { u }) }), false); /* occurs check u != cons(x,u) */ - Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1))); + Prove(ctx, ctx.MkNot(ctx.MkEq(u, l1)), false); } // / Demonstrate how to use #Eval. @@ -2129,49 +2121,42 @@ class JavaExample // / Extract unsatisfiable core example - public void UnsatCoreAndProofExample() throws Z3Exception + public void UnsatCoreAndProofExample(Context ctx) throws Z3Exception { System.out.println("UnsatCoreAndProofExample"); Log.Append("UnsatCoreAndProofExample"); - HashMap cfg = new HashMap(); - cfg.put("proof", "true"); + Solver solver = ctx.MkSolver(); + BoolExpr pa = ctx.MkBoolConst("PredA"); + BoolExpr pb = ctx.MkBoolConst("PredB"); + BoolExpr pc = ctx.MkBoolConst("PredC"); + BoolExpr pd = ctx.MkBoolConst("PredD"); + BoolExpr p1 = ctx.MkBoolConst("P1"); + BoolExpr p2 = ctx.MkBoolConst("P2"); + BoolExpr p3 = ctx.MkBoolConst("P3"); + BoolExpr p4 = ctx.MkBoolConst("P4"); + BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), ctx.MkNot(p2), + ctx.MkNot(p3), ctx.MkNot(p4) }; + BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); + BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); + BoolExpr f3 = ctx.MkOr(new BoolExpr[] { ctx.MkNot(pa), ctx.MkNot(pc) }); + BoolExpr f4 = pd; + + solver.Assert(ctx.MkOr(new BoolExpr[] { f1, p1 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f2, p2 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f3, p3 })); + solver.Assert(ctx.MkOr(new BoolExpr[] { f4, p4 })); + Status result = solver.Check(assumptions); + + if (result == Status.UNSATISFIABLE) { - Context ctx = new Context(cfg); - Solver solver = ctx.MkSolver(); - - BoolExpr pa = ctx.MkBoolConst("PredA"); - BoolExpr pb = ctx.MkBoolConst("PredB"); - BoolExpr pc = ctx.MkBoolConst("PredC"); - BoolExpr pd = ctx.MkBoolConst("PredD"); - BoolExpr p1 = ctx.MkBoolConst("P1"); - BoolExpr p2 = ctx.MkBoolConst("P2"); - BoolExpr p3 = ctx.MkBoolConst("P3"); - BoolExpr p4 = ctx.MkBoolConst("P4"); - BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), - ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; - BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); - BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); - BoolExpr f3 = ctx.MkOr(new BoolExpr[] { ctx.MkNot(pa), - ctx.MkNot(pc) }); - BoolExpr f4 = pd; - - solver.Assert(ctx.MkOr(new BoolExpr[] { f1, p1 })); - solver.Assert(ctx.MkOr(new BoolExpr[] { f2, p2 })); - solver.Assert(ctx.MkOr(new BoolExpr[] { f3, p3 })); - solver.Assert(ctx.MkOr(new BoolExpr[] { f4, p4 })); - Status result = solver.Check(assumptions); - - if (result == Status.UNSATISFIABLE) + System.out.println("unsat"); + System.out.println("proof: " + solver.Proof()); + System.out.println("core: "); + for (Expr c : solver.UnsatCore()) { - System.out.println("unsat"); - System.out.println("proof: " + solver.Proof()); - System.out.println("core: "); - for (Expr c : solver.UnsatCore()) - { - System.out.println(c); - } + System.out.println(c); } } } @@ -2210,10 +2195,9 @@ class JavaExample p.SimpleExample(); - { + { // These examples need model generation turned on. HashMap cfg = new HashMap(); cfg.put("model", "true"); - cfg.put("proof", "true"); Context ctx = new Context(cfg); p.BasicTests(ctx); p.CastingTest(ctx); @@ -2224,25 +2208,16 @@ class JavaExample p.ParOrExample(ctx); p.FindModelExample1(ctx); p.FindModelExample2(ctx); - p.ProveExample1(ctx); - p.ProveExample2(ctx); p.PushPopExample1(ctx); p.ArrayExample1(ctx); - p.ArrayExample2(ctx); p.ArrayExample3(ctx); - p.TupleExample(ctx); p.BitvectorExample1(ctx); p.BitvectorExample2(ctx); p.ParserExample1(ctx); p.ParserExample2(ctx); - p.ParserExample3(ctx); p.ParserExample4(ctx); p.ParserExample5(ctx); p.ITEExample(ctx); - p.EnumExample(ctx); - p.ListExample(ctx); - p.TreeExample(ctx); - p.ForestExample(ctx); p.EvalExample1(ctx); p.EvalExample2(ctx); p.FindSmallModelExample(ctx); @@ -2250,9 +2225,31 @@ class JavaExample p.FiniteDomainExample(ctx); } - p.QuantifierExample3(); - p.QuantifierExample4(); - p.UnsatCoreAndProofExample(); + { // These examples need proof generation turned on. + HashMap cfg = new HashMap(); + cfg.put("proof", "true"); + Context ctx = new Context(cfg); + p.ProveExample1(ctx); + p.ProveExample2(ctx); + p.ArrayExample2(ctx); + p.TupleExample(ctx); + p.ParserExample3(ctx); + p.EnumExample(ctx); + p.ListExample(ctx); + p.TreeExample(ctx); + p.ForestExample(ctx); + p.UnsatCoreAndProofExample(ctx); + } + + { // These examples need proof generation turned on and auto-config + // set to false. + HashMap cfg = new HashMap(); + cfg.put("proof", "true"); + cfg.put("auto-config", "false"); + Context ctx = new Context(cfg); + p.QuantifierExample3(ctx); + p.QuantifierExample4(ctx); + } Log.Close(); if (Log.isOpen()) From acd251e554a8da107ca93c7d65643068a7bf5bf6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 4 Dec 2012 19:32:46 +0000 Subject: [PATCH 112/133] .NET API: bugfix. Signed-off-by: Christoph M. Wintersteiger --- src/api/dotnet/Context.cs | 1 + src/api/dotnet/IDecRefQueue.cs | 4 +- src/api/dotnet/Microsoft.Z3.csproj | 65 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index ff36b4553..aee60c43f 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -3657,6 +3657,7 @@ namespace Microsoft.Z3 Goal_DRQ.Clear(this); Model_DRQ.Clear(this); Params_DRQ.Clear(this); + ParamDescrs_DRQ.Clear(this); Probe_DRQ.Clear(this); Solver_DRQ.Clear(this); Statistics_DRQ.Clear(this); diff --git a/src/api/dotnet/IDecRefQueue.cs b/src/api/dotnet/IDecRefQueue.cs index e6276c4f4..d741a8f05 100644 --- a/src/api/dotnet/IDecRefQueue.cs +++ b/src/api/dotnet/IDecRefQueue.cs @@ -24,7 +24,7 @@ using System.Threading; using System.Diagnostics.Contracts; namespace Microsoft.Z3 -{ +{ [ContractClass(typeof(DecRefQueueContracts))] internal abstract class IDecRefQueue { @@ -35,7 +35,7 @@ namespace Microsoft.Z3 { Contract.Invariant(this.m_queue != null); } - + #endregion readonly internal protected Object m_lock = new Object(); diff --git a/src/api/dotnet/Microsoft.Z3.csproj b/src/api/dotnet/Microsoft.Z3.csproj index 762b83b28..a1bb868eb 100644 --- a/src/api/dotnet/Microsoft.Z3.csproj +++ b/src/api/dotnet/Microsoft.Z3.csproj @@ -252,6 +252,71 @@ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true + + true + bin\x86\Debug\ + DEBUG;TRACE + true + full + x86 + ..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + bin\x86\Release\ + true + ..\external\Microsoft.Z3.xml + true + pdbonly + x86 + ..\external\Microsoft.Z3.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + bin\x86\external\ + true + ..\external\Microsoft.Z3.xml + true + pdbonly + x86 + bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + true + ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + + + bin\x86\Release_delaysign\ + DELAYSIGN + true + ..\Release_delaysign\Microsoft.Z3.xml + true + pdbonly + x86 + ..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + true + ;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + From 334ec57ea442aa6304a528881a00dd1df5a415eb Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 4 Dec 2012 19:33:01 +0000 Subject: [PATCH 113/133] Java API: refactoring Signed-off-by: Christoph M. Wintersteiger --- src/api/java/Params.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/java/Params.java b/src/api/java/Params.java index 3bc8b4574..c954c50e5 100644 --- a/src/api/java/Params.java +++ b/src/api/java/Params.java @@ -44,8 +44,8 @@ public class Params extends Z3Object **/ public void Add(String name, boolean value) throws Z3Exception { - Native.paramsSetBool(Context().nCtx(), NativeObject(), Context() - .MkSymbol(name).NativeObject(), (value) ? true : false); + Native.paramsSetBool(Context().nCtx(), NativeObject(), + Context().MkSymbol(name).NativeObject(), value); } /** From 92a29b1e43c97bbefe092dc116ca8c8568ab7241 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 11:55:12 -0800 Subject: [PATCH 114/133] added Z3_global_param_reset_all API Signed-off-by: Leonardo de Moura --- examples/c/test_capi.c | 67 +++++------------------------------ src/api/api_config_params.cpp | 7 ++++ src/api/c++/z3++.h | 1 + src/api/python/z3.py | 5 +++ src/api/z3_api.h | 11 ++++++ src/util/gparams.cpp | 31 +++++++++------- src/util/gparams.h | 5 +++ 7 files changed, 56 insertions(+), 71 deletions(-) diff --git a/examples/c/test_capi.c b/examples/c/test_capi.c index 70cdc2852..27bf6de2c 100644 --- a/examples/c/test_capi.c +++ b/examples/c/test_capi.c @@ -70,7 +70,7 @@ Z3_context mk_context_custom(Z3_config cfg, Z3_error_handler err) { Z3_context ctx; - Z3_set_param_value(cfg, "MODEL", "true"); + Z3_set_param_value(cfg, "model", "true"); ctx = Z3_mk_context(cfg); Z3_set_error_handler(ctx, err); @@ -105,7 +105,7 @@ Z3_context mk_context() Z3_context mk_proof_context() { Z3_config cfg = Z3_mk_config(); Z3_context ctx; - Z3_set_param_value(cfg, "PROOF_MODE", "2"); + Z3_set_param_value(cfg, "proof", "true"); ctx = mk_context_custom(cfg, throw_z3_error); Z3_del_config(cfg); return ctx; @@ -1038,12 +1038,12 @@ void quantifier_example1() /* If quantified formulas are asserted in a logical context, then Z3 may return L_UNDEF. In this case, the model produced by Z3 should be viewed as a potential/candidate model. */ - Z3_set_param_value(cfg, "MODEL", "true"); + /* The current model finder for quantified formulas cannot handle injectivity. So, we are limiting the number of iterations to avoid a long "wait". */ - Z3_set_param_value(cfg, "MBQI_MAX_ITERATIONS", "10"); + Z3_global_param_set("smt.mbqi.max_iterations", "10"); ctx = mk_context_custom(cfg, error_handler); Z3_del_config(cfg); @@ -1087,8 +1087,9 @@ void quantifier_example1() if (Z3_get_search_failure(ctx) != Z3_QUANTIFIERS) { exitf("unexpected result"); } - Z3_del_context(ctx); + /* reset global parameters set by this function */ + Z3_global_param_reset_all(); } /** @@ -1646,7 +1647,7 @@ void parser_example3() cfg = Z3_mk_config(); /* See quantifer_example1 */ - Z3_set_param_value(cfg, "MODEL", "true"); + Z3_set_param_value(cfg, "model", "true"); ctx = mk_context_custom(cfg, error_handler); Z3_del_config(cfg); @@ -2249,57 +2250,6 @@ void unsat_core_and_proof_example() { Z3_del_context(ctx); } -/** - \brief Extract classes of implied equalities. - - This example illustrates the use of #Z3_get_implied_equalities. -*/ -void get_implied_equalities_example() { - Z3_config cfg = Z3_mk_config(); - Z3_context ctx; - - printf("\nget_implied_equalities example\n"); - LOG_MSG("get_implied_equalities example"); - - Z3_set_param_value(cfg, "ARITH_PROCESS_ALL_EQS", "true"); - Z3_set_param_value(cfg, "ARITH_EQ_BOUNDS", "true"); - ctx = Z3_mk_context(cfg); - Z3_del_config(cfg); - { - Z3_sort int_ty = Z3_mk_int_sort(ctx); - Z3_ast a = mk_int_var(ctx,"a"); - Z3_ast b = mk_int_var(ctx,"b"); - Z3_ast c = mk_int_var(ctx,"c"); - Z3_ast d = mk_int_var(ctx,"d"); - Z3_func_decl f = Z3_mk_func_decl(ctx, Z3_mk_string_symbol(ctx,"f"), 1, &int_ty, int_ty); - Z3_ast fa = Z3_mk_app(ctx, f, 1, &a); - Z3_ast fb = Z3_mk_app(ctx, f, 1, &b); - Z3_ast fc = Z3_mk_app(ctx, f, 1, &c); - unsigned const num_terms = 7; - unsigned i; - Z3_ast terms[7] = { a, b, c, d, fa, fb, fc }; - unsigned class_ids[7] = { 0, 0, 0, 0, 0, 0, 0 }; - - Z3_assert_cnstr(ctx, Z3_mk_eq(ctx, a, b)); - Z3_assert_cnstr(ctx, Z3_mk_eq(ctx, b, c)); - Z3_assert_cnstr(ctx, Z3_mk_le(ctx, fc, b)); - Z3_assert_cnstr(ctx, Z3_mk_le(ctx, b, fa)); - - Z3_get_implied_equalities(ctx, num_terms, terms, class_ids); - for (i = 0; i < num_terms; ++i) { - printf("Class %s |-> %d\n", Z3_ast_to_string(ctx, terms[i]), class_ids[i]); - } - printf("asserting f(a) <= b\n"); - Z3_assert_cnstr(ctx, Z3_mk_le(ctx, fa, b)); - Z3_get_implied_equalities(ctx, num_terms, terms, class_ids); - for (i = 0; i < num_terms; ++i) { - printf("Class %s |-> %d\n", Z3_ast_to_string(ctx, terms[i]), class_ids[i]); - } - } - /* delete logical context */ - Z3_del_context(ctx); -} - #define MAX_RETRACTABLE_ASSERTIONS 1024 /** @@ -2504,7 +2454,7 @@ void reference_counter_example() { LOG_MSG("reference_counter_example"); cfg = Z3_mk_config(); - Z3_set_param_value(cfg, "MODEL", "true"); + Z3_set_param_value(cfg, "model", "true"); // Create a Z3 context where the user is reponsible for managing // Z3_ast reference counters. ctx = Z3_mk_context_rc(cfg); @@ -2685,7 +2635,6 @@ int main() { binary_tree_example(); enum_example(); unsat_core_and_proof_example(); - get_implied_equalities_example(); incremental_example1(); reference_counter_example(); smt2parser_example(); diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 908900043..aaaabb7b2 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -43,6 +43,13 @@ extern "C" { } } + void Z3_API Z3_global_param_reset_all() { + memory::initialize(UINT_MAX); + LOG_Z3_global_param_reset_all(); + gparams::reset(); + env_params::updt_params(); + } + std::string g_Z3_global_param_get_buffer; Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) { diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index bdb462df0..fca009cea 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -67,6 +67,7 @@ namespace z3 { inline void set_param(char const * param, char const * value) { Z3_global_param_set(param, value); } inline void set_param(char const * param, bool value) { Z3_global_param_set(param, value ? "true" : "false"); } inline void set_param(char const * param, int value) { std::ostringstream oss; oss << value; Z3_global_param_set(param, oss.str().c_str()); } + inline void reset_params() { Z3_global_param_reset_all(); } /** \brief Exception used to sign API usage errors. diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 301267ce1..033626747 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -219,6 +219,11 @@ def set_param(*args, **kws): Z3_global_param_set(str(prev), _to_param_value(a)) prev = None +def reset_params(): + """Reset all global (or module) parameters. + """ + Z3_global_param_reset_all() + def set_option(*args, **kws): """Alias for 'set_param' for backward compatibility. """ diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 5ef92b931..49d59e125 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1260,6 +1260,17 @@ extern "C" { def_API('Z3_global_param_set', VOID, (_in(STRING), _in(STRING))) */ void Z3_API Z3_global_param_set(__in Z3_string param_id, __in Z3_string param_value); + + + /** + \brief Restore the value of all global (and module) parameters. + This command will not affect already created objects (such as tactics and solvers). + + \sa Z3_global_param_set + + def_API('Z3_global_param_reset_all', VOID, ()) + */ + void Z3_API Z3_global_param_reset_all(); /** \brief Get a global (or module) parameter. diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 183678c59..976393e46 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -60,20 +60,22 @@ public: } ~imp() { - { - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); - for (; it != end; ++it) { - dealloc(it->m_value); - } + reset(); + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + dealloc(it->m_value); } - { - dictionary::iterator it = m_module_params.begin(); - dictionary::iterator end = m_module_params.end(); - for (; it != end; ++it) { - dealloc(it->m_value); - } + } + + void reset() { + m_params.reset(); + dictionary::iterator it = m_module_params.begin(); + dictionary::iterator end = m_module_params.end(); + for (; it != end; ++it) { + dealloc(it->m_value); } + m_module_params.reset(); } // ----------------------------------------------- @@ -448,6 +450,11 @@ public: gparams::imp * gparams::g_imp = 0; +void gparams::reset() { + SASSERT(g_imp != 0); + g_imp->reset(); +} + void gparams::set(char const * name, char const * value) { TRACE("gparams", tout << "setting [" << name << "] <- '" << value << "'\n";); SASSERT(g_imp != 0); diff --git a/src/util/gparams.h b/src/util/gparams.h index a41044c84..a55761830 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -27,6 +27,11 @@ class gparams { public: typedef default_exception exception; + /** + \brief Reset all global and module parameters. + */ + static void reset(); + /** \brief Set a global parameter \c name with \c value. From 2eef4cc1e788c7b61361bcc19b0f80d9948d4c33 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 11:59:46 -0800 Subject: [PATCH 115/133] forgot synch Signed-off-by: Leonardo de Moura --- src/util/gparams.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 976393e46..7fdc3821a 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -69,13 +69,16 @@ public: } void reset() { - m_params.reset(); - dictionary::iterator it = m_module_params.begin(); - dictionary::iterator end = m_module_params.end(); - for (; it != end; ++it) { - dealloc(it->m_value); + #pragma omp critical (gparams) + { + m_params.reset(); + dictionary::iterator it = m_module_params.begin(); + dictionary::iterator end = m_module_params.end(); + for (; it != end; ++it) { + dealloc(it->m_value); + } + m_module_params.reset(); } - m_module_params.reset(); } // ----------------------------------------------- From 6f5f1b290e32dc674794cb6d885aa1c8e93d6a5f Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 15:33:21 -0800 Subject: [PATCH 116/133] better error message for renamed parameter names Signed-off-by: Leonardo de Moura --- src/util/gparams.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 7fdc3821a..b81531798 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -35,6 +35,47 @@ bool is_old_param_name(symbol const & name) { return false; } +char const * g_params_renames[] = { + "proof_mode", "proof", + "soft_timeout", "timeout", + "mbqi", "smt.mbqi", + "relevancy", "smt.relevancy", + "ematching", "smt.ematching", + "macro_finder", "smt.macro_finder", + "delay_units", "smt.delay_units", + "case_split", "smt.case_split", + "phase_selection", "smt.phase_selection", + "restart_strategy", "smt.restart_strategy", + "restart_factor", "smt.restart_factor", + "arith_random_initial_value", "smt.arith.random_initial_value", + "bv_reflect", "smt.bv.reflect", + "qi_cost", "smt.qi.cost", + "qi_eager_threshold", "smt.qi.eager_threshold", + "nl_arith", "smt.arith.nl", + "nnf_sk_hack", "nnf.sk_hack", + "model_v2", "model.v2", + "pi_non_nested_arith_weight", "pi.non_nested_arith_weight", + "pi_warnings", "pi.warnings", + "pp_decimal", "pp.decimal", + "pp_decimal", "pp.decimal_precision", + "pp_bv_literals", "pp.bv_literals", + "pp_bv_neg", "pp.bv_neg", + "pp_max_depth", "pp.max_depth", + "pp_min_alias_size", "pp.min_alias_size", + 0 }; + +char const * get_new_param_name(symbol const & p) { + char const * const * it = g_params_renames; + while (*it) { + if (p == *it) { + it++; + return *it; + } + it += 2; + } + return 0; +} + struct gparams::imp { bool m_modules_registered; dictionary m_module_param_descrs; @@ -160,7 +201,12 @@ public: void throw_unknown_parameter(symbol const & param_name, symbol const & mod_name) { if (mod_name == symbol::null) { - if (is_old_param_name(param_name)) { + char const * new_name = get_new_param_name(param_name); + if (new_name) { + throw exception("the parameter '%s' was renamed to '%s', invoke 'z3 -p' to obtain the new parameter list, and 'z3 -pp:%s' for the full description of the parameter", + param_name.bare_str(), new_name, new_name); + } + else if (is_old_param_name(param_name)) { throw exception("unknown parameter '%s', this is an old parameter name, invoke 'z3 -p' to obtain the new parameter list", param_name.bare_str()); } From 89385b4e9a84c3804320b1eea37baf74242737d2 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 15:37:43 -0800 Subject: [PATCH 117/133] no need for / options --- src/shell/main.cpp | 52 ++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 21ee8b71c..ffa132355 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -44,15 +44,9 @@ input_kind g_input_kind = IN_UNSPECIFIED; bool g_display_statistics = false; bool g_display_istatistics = false; -#ifdef _WINDOWS -#define OPT "/" -#else -#define OPT "-" -#endif - void error(const char * msg) { std::cerr << "Error: " << msg << "\n"; - std::cerr << "For usage information: z3 " << OPT << "h\n"; + std::cerr << "For usage information: z3 -h\n"; exit(ERR_CMD_LINE); } @@ -64,40 +58,40 @@ void display_usage() { std::cout << "32"; #endif std::cout << " bit]. (C) Copyright 2006 Microsoft Corp.\n"; - std::cout << "Usage: z3 [options] [" << OPT << "file:]file\n"; + std::cout << "Usage: z3 [options] [-file:]file\n"; std::cout << "\nInput format:\n"; - std::cout << " " << OPT << "smt use parser for SMT input format.\n"; - std::cout << " " << OPT << "smt2 use parser for SMT 2 input format.\n"; - std::cout << " " << OPT << "dl use parser for Datalog input format.\n"; - std::cout << " " << OPT << "dimacs use parser for DIMACS input format.\n"; - std::cout << " " << OPT << "log use parser for Z3 log input format.\n"; - std::cout << " " << OPT << "in read formula from standard input.\n"; + std::cout << " -smt use parser for SMT input format.\n"; + std::cout << " -smt2 use parser for SMT 2 input format.\n"; + std::cout << " -dl use parser for Datalog input format.\n"; + std::cout << " -dimacs use parser for DIMACS input format.\n"; + std::cout << " -log use parser for Z3 log input format.\n"; + std::cout << " -in read formula from standard input.\n"; std::cout << "\nMiscellaneous:\n"; - std::cout << " " << OPT << "h, " << OPT << "? prints this message.\n"; - std::cout << " " << OPT << "version prints version number of Z3.\n"; - std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; - std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "p display Z3 global (and module) parameters.\n"; - std::cout << " " << OPT << "pd display Z3 global (and module) parameter descriptions.\n"; - std::cout << " " << OPT << "pm:name display Z3 module ('name') parameters.\n"; - std::cout << " " << OPT << "pp:name display Z3 parameter description, if 'name' is not provided, then all module names are listed.\n"; + std::cout << " -h, -? prints this message.\n"; + std::cout << " -version prints version number of Z3.\n"; + std::cout << " -v:level be verbose, where is the verbosity level.\n"; + std::cout << " -nw disable warning messages.\n"; + std::cout << " -p display Z3 global (and module) parameters.\n"; + std::cout << " -pd display Z3 global (and module) parameter descriptions.\n"; + std::cout << " -pm:name display Z3 module ('name') parameters.\n"; + std::cout << " -pp:name display Z3 parameter description, if 'name' is not provided, then all module names are listed.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. - std::cout << " " << OPT << "T:timeout set the timeout (in seconds).\n"; - std::cout << " " << OPT << "t:timeout set the soft timeout (in seconds). It only kills the current query.\n"; - std::cout << " " << OPT << "memory:Megabytes set a limit for virtual memory consumption.\n"; + std::cout << " -T:timeout set the timeout (in seconds).\n"; + std::cout << " -t:timeout set the soft timeout (in seconds). It only kills the current query.\n"; + std::cout << " -memory:Megabytes set a limit for virtual memory consumption.\n"; // std::cout << "\nOutput:\n"; - std::cout << " " << OPT << "st display statistics.\n"; + std::cout << " -st display statistics.\n"; #if defined(Z3DEBUG) || defined(_TRACE) std::cout << "\nDebugging support:\n"; #endif #ifdef _TRACE - std::cout << " " << OPT << "tr:tag enable trace messages tagged with .\n"; + std::cout << " -tr:tag enable trace messages tagged with .\n"; #endif #ifdef Z3DEBUG - std::cout << " " << OPT << "dbg:tag enable assertions tagged with .\n"; + std::cout << " -dbg:tag enable assertions tagged with .\n"; #endif } @@ -235,7 +229,7 @@ void parse_cmd_line_args(int argc, char ** argv) { } else { std::cerr << "Error: invalid command line option: " << arg << "\n"; - std::cerr << "For usage information: z3 " << OPT << "h\n"; + std::cerr << "For usage information: z3 -h\n"; exit(ERR_CMD_LINE); } } From f6a3ec58e5d35c66f36c49a43ead2cde314ddd08 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Tue, 4 Dec 2012 15:48:28 -0800 Subject: [PATCH 118/133] allow --help, --version, etc as valid parameter names Signed-off-by: Leonardo de Moura --- src/shell/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/shell/main.cpp b/src/shell/main.cpp index ffa132355..d91038b39 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -93,6 +93,11 @@ void display_usage() { #ifdef Z3DEBUG std::cout << " -dbg:tag enable assertions tagged with .\n"; #endif + std::cout << "\nParameter setting:\n"; + std::cout << "Global and module parameters can be set in the command line.\n"; + std::cout << " param_name=value for setting global parameters.\n"; + std::cout << " module_name.param_name=value for setting module parameters.\n"; + std::cout << "Use 'z3 -p' for the complete list of global and module parameters.\n"; } void parse_cmd_line_args(int argc, char ** argv) { @@ -126,6 +131,9 @@ void parse_cmd_line_args(int argc, char ** argv) { #endif ) { char * opt_name = arg + 1; + // allow names such as --help + if (*opt_name == '-') + opt_name++; char * opt_arg = 0; char * colon = strchr(arg, ':'); if (colon) { From 5379130c8cb5bfd9fb3e6b9919e8e9fe401a74f5 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 08:35:03 -0800 Subject: [PATCH 119/133] eliminated m_proof_mode from smt_params, ast_manager has this information Signed-off-by: Leonardo de Moura --- src/muz_qe/dl_cmds.cpp | 1 - src/muz_qe/pdr_context.cpp | 1 - src/muz_qe/pdr_farkas_learner.cpp | 1 - src/muz_qe/pdr_quantifiers.cpp | 2 +- src/muz_qe/unit_subsumption_tactic.cpp | 1 - src/muz_qe/vsubst_tactic.cpp | 3 +- src/smt/params/params2smt_params.cpp | 79 -------------------------- src/smt/params/params2smt_params.h | 31 ---------- src/smt/params/smt_params.cpp | 1 - src/smt/params/smt_params.h | 2 - src/smt/smt_kernel.cpp | 4 +- src/smt/tactic/smt_tactic.cpp | 4 +- 12 files changed, 6 insertions(+), 124 deletions(-) delete mode 100644 src/smt/params/params2smt_params.cpp delete mode 100644 src/smt/params/params2smt_params.h diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index 8c4e26db7..bf9c24203 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -28,7 +28,6 @@ Notes: #include"cancel_eh.h" #include"scoped_ctrl_c.h" #include"scoped_timer.h" -#include"params2smt_params.h" #include"trail.h" #include diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 9faee3ab0..c8c1e3b2a 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1456,7 +1456,6 @@ namespace pdr { } if (m_params.use_farkas() && !classify.is_bool()) { m.toggle_proof_mode(PGM_FINE); - m_fparams.m_proof_mode = PGM_FINE; m_fparams.m_arith_bound_prop = BP_NONE; m_fparams.m_arith_auto_config_simplex = true; m_fparams.m_arith_propagate_eqs = false; diff --git a/src/muz_qe/pdr_farkas_learner.cpp b/src/muz_qe/pdr_farkas_learner.cpp index b3d0b4fd0..06b8f5eeb 100644 --- a/src/muz_qe/pdr_farkas_learner.cpp +++ b/src/muz_qe/pdr_farkas_learner.cpp @@ -255,7 +255,6 @@ namespace pdr { smt_params farkas_learner::get_proof_params(smt_params& orig_params) { smt_params res(orig_params); - res.m_proof_mode = PROOF_MODE; res.m_arith_bound_prop = BP_NONE; // temp hack to fix the build // res.m_conflict_resolution_strategy = CR_ALL_DECIDED; diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 51a86e38c..2816a58d4 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -214,7 +214,7 @@ namespace pdr { expr_ref_vector fmls(m); smt_params fparams; - fparams.m_proof_mode = PGM_FINE; + SASSERT(m.proofs_enabled()); fparams.m_mbqi = true; fmls.push_back(m_A.get()); diff --git a/src/muz_qe/unit_subsumption_tactic.cpp b/src/muz_qe/unit_subsumption_tactic.cpp index 1fb71490d..afc81723a 100644 --- a/src/muz_qe/unit_subsumption_tactic.cpp +++ b/src/muz_qe/unit_subsumption_tactic.cpp @@ -37,7 +37,6 @@ struct unit_subsumption_tactic : public tactic { m_cancel(false), m_context(m, m_fparams, p), m_clauses(m) { - m_fparams.m_proof_mode = m.proof_mode(); } void set_cancel(bool f) { diff --git a/src/muz_qe/vsubst_tactic.cpp b/src/muz_qe/vsubst_tactic.cpp index b84202ee9..c389d9a66 100644 --- a/src/muz_qe/vsubst_tactic.cpp +++ b/src/muz_qe/vsubst_tactic.cpp @@ -45,7 +45,6 @@ Notes: #include"arith_decl_plugin.h" #include"for_each_expr.h" #include"extension_model_converter.h" -#include"params2smt_params.h" #include"ast_smt2_pp.h" class vsubst_tactic : public tactic { @@ -94,7 +93,7 @@ class vsubst_tactic : public tactic { } smt_params params; - params2smt_params(p, params); + params.updt_params(p); params.m_model = false; flet fl1(params.m_nlquant_elim, true); flet fl2(params.m_nl_arith_gb, false); diff --git a/src/smt/params/params2smt_params.cpp b/src/smt/params/params2smt_params.cpp deleted file mode 100644 index b01d9478a..000000000 --- a/src/smt/params/params2smt_params.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - params2smt_params.h - -Abstract: - - Backward compatibility utilities for parameter setting - -Author: - - Leonardo de Moura (leonardo) 2011-05-19. - -Revision History: - ---*/ -#include"smt_params.h" -#include"params.h" - -/** - Update smt_params using s. - Only the most frequently used options are updated. - - This function is mainly used to allow smt::context to be used in - the new strategy framework. -*/ -void params2smt_params(params_ref const & s, smt_params & t) { - t.m_relevancy_lvl = s.get_uint("relevancy", t.m_relevancy_lvl); - TRACE("qi_cost", s.display(tout); tout << "\n";); - t.m_qi_cost = s.get_str("qi_cost", t.m_qi_cost.c_str()); - t.m_mbqi = s.get_bool("mbqi", t.m_mbqi); - t.m_mbqi_max_iterations = s.get_uint("mbqi_max_iterations", t.m_mbqi_max_iterations); - t.m_random_seed = s.get_uint("random_seed", t.m_random_seed); - t.m_model = s.get_bool("produce_models", t.m_model); - if (s.get_bool("produce_proofs", false)) - t.m_proof_mode = PGM_FINE; - t.m_qi_eager_threshold = s.get_double("qi_eager_threshold", t.m_qi_eager_threshold); - t.m_qi_lazy_threshold = s.get_double("qi_lazy_threshold", t.m_qi_lazy_threshold); - t.m_preprocess = s.get_bool("preprocess", t.m_preprocess); - t.m_hi_div0 = s.get_bool("hi_div0", t.m_hi_div0); - t.m_auto_config = s.get_bool("auto_config", t.m_auto_config); - t.m_array_simplify = s.get_bool("array_old_simplifier", t.m_array_simplify); - t.m_arith_branch_cut_ratio = s.get_uint("arith_branch_cut_ratio", t.m_arith_branch_cut_ratio); - t.m_arith_expand_eqs = s.get_bool("arith_expand_eqs", t.m_arith_expand_eqs); - - if (s.get_bool("arith_greatest_error_pivot", false)) - t.m_arith_pivot_strategy = ARITH_PIVOT_GREATEST_ERROR; - else if (s.get_bool("arith_least_error_pivot", false)) - t.m_arith_pivot_strategy = ARITH_PIVOT_LEAST_ERROR; -} - -/** - \brief Copy parameters (from s) that affect the semantics of Z3 (e.g., HI_DIV0). - It also copies the model construction parameter. Thus, model construction - can be enabled at the command line. -*/ -void smt_params2params(smt_params const & s, params_ref & t) { - if (s.m_model) - t.set_bool("produce_models", true); - if (!s.m_hi_div0) - t.set_bool("hi_div0", false); -} - -/** - \brief Bridge for using params_ref with smt::context. -*/ -void solver_smt_params_descrs(param_descrs & r) { - r.insert("hi_div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); - r.insert("relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); - r.insert("mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); - r.insert("mbqi_max_iterations", CPK_UINT, "maximum number of rounds of MBQI"); - r.insert("random_seed", CPK_UINT, "random seed for smt solver"); - r.insert("qi_eager_threshold", CPK_DOUBLE, "threshold for eager quantifier instantiation"); - r.insert("qi_lazy_threshold", CPK_DOUBLE, "threshold for lazy quantifier instantiation"); - r.insert("auto_config", CPK_BOOL, "use heuristics to automatically configure smt solver"); - r.insert("arith_branch_cut_ratio", CPK_UINT, "branch&bound / gomory cut ratio"); -} diff --git a/src/smt/params/params2smt_params.h b/src/smt/params/params2smt_params.h deleted file mode 100644 index d4f60cb64..000000000 --- a/src/smt/params/params2smt_params.h +++ /dev/null @@ -1,31 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - params2smt_params.h - -Abstract: - - Backward compatibility utilities for parameter setting - -Author: - - Leonardo de Moura (leonardo) 2011-05-19. - -Revision History: - ---*/ -#ifndef _PARAMS2SMT_PARAMS_H_ -#define _PARAMS2SMT_PARAMS_H_ - -class params_ref; -struct smt_params; - -void params2smt_params(params_ref const & s, smt_params & t); - -void smt_params2params(smt_params const & s, params_ref & t); - -void solver_smt_params_descrs(param_descrs & r); - -#endif diff --git a/src/smt/params/smt_params.cpp b/src/smt/params/smt_params.cpp index 113a2bead..22122cd83 100644 --- a/src/smt/params/smt_params.cpp +++ b/src/smt/params/smt_params.cpp @@ -51,6 +51,5 @@ void smt_params::updt_params(context_params const & p) { m_soft_timeout = p.m_timeout; m_model = p.m_model; m_model_validate = p.m_model_validate; - m_proof_mode = p.m_proof ? PGM_FINE : PGM_DISABLED; } diff --git a/src/smt/params/smt_params.h b/src/smt/params/smt_params.h index ec057239a..3d823cb51 100644 --- a/src/smt/params/smt_params.h +++ b/src/smt/params/smt_params.h @@ -207,7 +207,6 @@ struct smt_params : public preprocessor_params, bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. bool m_dump_goal_as_smt; - proof_gen_mode m_proof_mode; bool m_auto_config; smt_params(params_ref const & p = params_ref()): @@ -277,7 +276,6 @@ struct smt_params : public preprocessor_params, m_at_labels_cex(false), m_check_at_labels(false), m_dump_goal_as_smt(false), - m_proof_mode(PGM_DISABLED), m_auto_config(true) { updt_local_params(p); } diff --git a/src/smt/smt_kernel.cpp b/src/smt/smt_kernel.cpp index 23687af8c..779c68625 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -19,7 +19,7 @@ Revision History: #include"smt_kernel.h" #include"smt_context.h" #include"ast_smt2_pp.h" -#include"params2smt_params.h" +#include"smt_params_helper.hpp" namespace smt { @@ -345,7 +345,7 @@ namespace smt { } void kernel::collect_param_descrs(param_descrs & d) { - solver_smt_params_descrs(d); + smt_params_helper::collect_param_descrs(d); } context & kernel::get_context() { diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 20b6585e1..2c7d58b1a 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -20,7 +20,7 @@ Notes: #include"tactical.h" #include"smt_kernel.h" #include"smt_params.h" -#include"params2smt_params.h" +#include"smt_params_helper.hpp" #include"rewriter_types.h" class smt_tactic : public tactic { @@ -70,7 +70,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { r.insert("candidate_models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete."); r.insert("fail_if_inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal."); - solver_smt_params_descrs(r); + smt_params_helper::collect_param_descrs(r); } virtual void set_cancel(bool f) { From 3736c5ea3b97521dad85cdc6262151fae2875ec5 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 08:56:19 -0800 Subject: [PATCH 120/133] removed template specialization overkill Signed-off-by: Leonardo de Moura --- src/smt/smt_setup.cpp | 49 +++++++++++-------------------------- src/smt/theory_arith.cpp | 1 - src/smt/theory_arith.h | 43 +++++++------------------------- src/smt/theory_arith_aux.h | 22 ++++++++--------- src/smt/theory_arith_core.h | 8 +++--- 5 files changed, 38 insertions(+), 85 deletions(-) diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index 77c1be886..ac31eb1a9 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -266,8 +266,8 @@ namespace smt { // Moreover, if model construction is enabled, then rational numbers may be needed // to compute the actual value of epsilon even if the input does not have rational numbers. // Example: (x < 1) and (x > 0) - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); + if (m_manager.proofs_enabled()) { + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); } else if (!m_params.m_arith_auto_config_simplex && is_dense(st)) { if (!st.m_has_rational && !m_params.m_model && st.m_arith_k_sum < rational(INT_MAX / 8)) @@ -343,8 +343,8 @@ namespace smt { tout << "RELEVANCY: " << m_params.m_relevancy_lvl << "\n"; tout << "ARITH_EQ_BOUNDS: " << m_params.m_arith_eq_bounds << "\n";); - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); + if (m_manager.proofs_enabled()) { + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); } else if (!m_params.m_arith_auto_config_simplex && is_dense(st)) { TRACE("setup", tout << "using dense diff logic...\n";); @@ -394,8 +394,8 @@ namespace smt { m_params.m_lemma_gc_half = true; m_params.m_restart_strategy = RS_GEOMETRIC; - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); + if (m_manager.proofs_enabled()) { + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); } else if (st.m_arith_k_sum < rational(INT_MAX / 8)) m_context.register_plugin(alloc(smt::theory_dense_si, m_manager, m_params)); @@ -409,8 +409,8 @@ namespace smt { m_params.m_restart_strategy = RS_GEOMETRIC; m_params.m_restart_factor = 1.5; m_params.m_restart_adaptive = false; - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); + if (m_manager.proofs_enabled()) { + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); } // else if (st.m_arith_k_sum < rational(INT_MAX / 8)) // m_context.register_plugin(alloc(smt::theory_si_arith, m_manager, m_params)); @@ -683,21 +683,11 @@ namespace smt { } void setup::setup_i_arith() { - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); - } - else { - m_context.register_plugin(alloc(smt::theory_i_arith, m_manager, m_params)); - } + m_context.register_plugin(alloc(smt::theory_i_arith, m_manager, m_params)); } void setup::setup_mi_arith() { - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); - } - else { - m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); - } + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); } void setup::setup_arith() { @@ -734,21 +724,10 @@ namespace smt { } break; default: - if (m_manager.proof_mode() != PGM_DISABLED) { - m_context.register_plugin(alloc(smt::theory_mi_arith_w_proofs, m_manager, m_params)); - } - // else if (m_params.m_arith_fixnum) { - // if (m_params.m_arith_int_only) - // m_context.register_plugin(alloc(smt::theory_si_arith, m_manager, m_params)); - // else - // m_context.register_plugin(alloc(smt::theory_smi_arith, m_manager, m_params)); - // } - else { - if (m_params.m_arith_int_only) - m_context.register_plugin(alloc(smt::theory_i_arith, m_manager, m_params)); - else - m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); - } + if (m_params.m_arith_int_only) + m_context.register_plugin(alloc(smt::theory_i_arith, m_manager, m_params)); + else + m_context.register_plugin(alloc(smt::theory_mi_arith, m_manager, m_params)); break; } } diff --git a/src/smt/theory_arith.cpp b/src/smt/theory_arith.cpp index d57812b7a..0bb356b95 100644 --- a/src/smt/theory_arith.cpp +++ b/src/smt/theory_arith.cpp @@ -21,7 +21,6 @@ Revision History: namespace smt { - template class theory_arith; template class theory_arith; template class theory_arith; // template class theory_arith; diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index c125558f7..9435a49cd 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -87,8 +87,8 @@ namespace smt { typedef vector numeral_vector; static const int dead_row_id = -1; - static const bool proofs_enabled = Ext::proofs_enabled; protected: + bool proofs_enabled() const { return get_manager().proofs_enabled(); } struct linear_monomial { numeral m_coeff; @@ -233,8 +233,8 @@ namespace smt { void reset(); literal_vector& lits() { return m_lits; } eq_vector& eqs() { return m_eqs; } - void push_lit(literal l, numeral const& r); - void push_eq(enode_pair const& p, numeral const& r); + void push_lit(literal l, numeral const& r, bool proofs_enabled); + void push_eq(enode_pair const& p, numeral const& r, bool proofs_enabled); unsigned num_params() const { return empty()?0:m_eq_coeffs.size() + m_lit_coeffs.size() + 1; } numeral const* lit_coeffs() const { return m_lit_coeffs.c_ptr(); } numeral const* eq_coeffs() const { return m_eq_coeffs.c_ptr(); } @@ -284,8 +284,8 @@ namespace smt { bool is_true() const { return m_is_true; } void assign_eh(bool is_true, inf_numeral const & epsilon); virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff) { - a.push_lit(literal(get_bool_var(), !m_is_true), coeff); + virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { + a.push_lit(literal(get_bool_var(), !m_is_true), coeff, proofs_enabled); } }; @@ -301,9 +301,9 @@ namespace smt { } virtual ~eq_bound() {} virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff) { + virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { SASSERT(m_lhs->get_root() == m_rhs->get_root()); - a.push_eq(enode_pair(m_lhs, m_rhs), coeff); + a.push_eq(enode_pair(m_lhs, m_rhs), coeff, proofs_enabled); } }; @@ -316,7 +316,7 @@ namespace smt { derived_bound(theory_var v, inf_numeral const & val, bound_kind k):bound(v, val, k, false) {} virtual ~derived_bound() {} virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff); + virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled); virtual void push_lit(literal l, numeral const&) { m_lits.push_back(l); } virtual void push_eq(enode_pair const& p, numeral const&) { m_eqs.push_back(p); } }; @@ -329,7 +329,7 @@ namespace smt { justified_derived_bound(theory_var v, inf_numeral const & val, bound_kind k):derived_bound(v, val, k) {} virtual ~justified_derived_bound() {} virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff); + virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled); virtual void push_lit(literal l, numeral const& coeff); virtual void push_eq(enode_pair const& p, numeral const& coeff); @@ -1053,30 +1053,9 @@ namespace smt { static inf_numeral mk_inf_numeral(numeral const & n, numeral const & r) { return inf_numeral(n, r); } - static const bool proofs_enabled = false; mi_ext() : m_int_epsilon(rational(1)), m_real_epsilon(rational(0), true) {} }; - class mi_ext_with_proofs { - public: - typedef rational numeral; - typedef inf_rational inf_numeral; - inf_numeral m_int_epsilon; - inf_numeral m_real_epsilon; - numeral fractional_part(inf_numeral const& n) { - SASSERT(n.is_rational()); - return n.get_rational() - floor(n); - } - static numeral fractional_part(numeral const & n) { - return n - floor(n); - } - static inf_numeral mk_inf_numeral(numeral const & n, numeral const & r) { - return inf_numeral(n, r); - } - static const bool proofs_enabled = true; - mi_ext_with_proofs() : m_int_epsilon(rational(1)), m_real_epsilon(rational(0), true) {} - }; - class i_ext { public: typedef rational numeral; @@ -1090,7 +1069,6 @@ namespace smt { UNREACHABLE(); return inf_numeral(n); } - static const bool proofs_enabled = false; i_ext() : m_int_epsilon(1), m_real_epsilon(1) {} }; @@ -1107,7 +1085,6 @@ namespace smt { UNREACHABLE(); return inf_numeral(n); } - static const bool proofs_enabled = false; si_ext(): m_int_epsilon(s_integer(1)), m_real_epsilon(s_integer(1)) {} }; @@ -1128,12 +1105,10 @@ namespace smt { static inf_numeral mk_inf_numeral(numeral const& n, numeral const& i) { return inf_numeral(n, i); } - static const bool proofs_enabled = false; smi_ext() : m_int_epsilon(s_integer(1)), m_real_epsilon(s_integer(0), true) {} }; typedef theory_arith theory_mi_arith; - typedef theory_arith theory_mi_arith_w_proofs; typedef theory_arith theory_i_arith; // typedef theory_arith theory_si_arith; // typedef theory_arith theory_smi_arith; diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index 4d22287ed..1e15365a4 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -336,7 +336,7 @@ namespace smt { } template - void theory_arith::antecedents::push_lit(literal l, numeral const& r) { + void theory_arith::antecedents::push_lit(literal l, numeral const& r, bool proofs_enabled) { m_lits.push_back(l); if (proofs_enabled) { m_lit_coeffs.push_back(r); @@ -344,7 +344,7 @@ namespace smt { } template - void theory_arith::antecedents::push_eq(enode_pair const& p, numeral const& r) { + void theory_arith::antecedents::push_eq(enode_pair const& p, numeral const& r, bool proofs_enabled) { m_eqs.push_back(p); if (proofs_enabled) { m_eq_coeffs.push_back(r); @@ -690,14 +690,14 @@ namespace smt { // ----------------------------------- template - void theory_arith::derived_bound::push_justification(antecedents& a, numeral const& coeff) { + void theory_arith::derived_bound::push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { if (proofs_enabled) { for (unsigned i = 0; i < m_lits.size(); ++i) { - a.push_lit(m_lits[i], coeff); + a.push_lit(m_lits[i], coeff, proofs_enabled); } for (unsigned i = 0; i < m_eqs.size(); ++i) { - a.push_eq(m_eqs[i], coeff); + a.push_eq(m_eqs[i], coeff, proofs_enabled); } } else { @@ -708,12 +708,12 @@ namespace smt { template - void theory_arith::justified_derived_bound::push_justification(antecedents& a, numeral const& coeff) { + void theory_arith::justified_derived_bound::push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { for (unsigned i = 0; i < this->m_lits.size(); ++i) { - a.push_lit(this->m_lits[i], coeff*m_lit_coeffs[i]); + a.push_lit(this->m_lits[i], coeff*m_lit_coeffs[i], proofs_enabled); } for (unsigned i = 0; i < this->m_eqs.size(); ++i) { - a.push_eq(this->m_eqs[i], coeff*m_eq_coeffs[i]); + a.push_eq(this->m_eqs[i], coeff*m_eq_coeffs[i], proofs_enabled); } } @@ -755,7 +755,7 @@ namespace smt { literal l = ante.lits()[i]; if (lits.contains(l.index())) continue; - if (proofs_enabled) { + if (proofs_enabled()) { new_bound.push_lit(l, ante.lit_coeffs()[i]); } else { @@ -768,7 +768,7 @@ namespace smt { enode_pair const & p = ante.eqs()[i]; if (eqs.contains(p)) continue; - if (proofs_enabled) { + if (proofs_enabled()) { new_bound.push_eq(p, ante.eq_coeffs()[i]); } else { @@ -796,7 +796,7 @@ namespace smt { template void theory_arith::mk_bound_from_row(theory_var v, inf_numeral const & k, bound_kind kind, row const & r) { inf_numeral k_norm = normalize_bound(v, k, kind); - derived_bound * new_bound = proofs_enabled?alloc(justified_derived_bound, v, k_norm, kind):alloc(derived_bound, v, k_norm, kind); + derived_bound * new_bound = proofs_enabled()?alloc(justified_derived_bound, v, k_norm, kind):alloc(derived_bound, v, k_norm, kind); m_bounds_to_delete.push_back(new_bound); m_asserted_bounds.push_back(new_bound); m_tmp_lit_set.reset(); diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index a691096ec..0f3ed1d13 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -2456,7 +2456,7 @@ namespace smt { delta -= coeff*(k_2 - k_1); } TRACE("propagate_bounds", tout << "delta (after replace): " << delta << "\n";); - new_atom->push_justification(ante, coeff); + new_atom->push_justification(ante, coeff, proofs_enabled()); SASSERT(delta >= inf_numeral::zero()); } } @@ -2569,7 +2569,7 @@ namespace smt { for (; it != end; ++it) lits.push_back(~(*it)); justification * js = 0; - if (proofs_enabled) { + if (proofs_enabled()) { js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr(), ante.num_params(), ante.params("assign-bounds")); } @@ -2656,13 +2656,13 @@ namespace smt { for (unsigned i = 0; i < num_literals; i++) { ctx.display_detailed_literal(tout, lits[i]); tout << " "; - if (proofs_enabled) { + if (proofs_enabled()) { tout << "bound: " << bounds.lit_coeffs()[i] << "\n"; } } for (unsigned i = 0; i < num_eqs; i++) { tout << "#" << eqs[i].first->get_owner_id() << "=#" << eqs[i].second->get_owner_id() << " "; - if (proofs_enabled) { + if (proofs_enabled()) { tout << "bound: " << bounds.eq_coeffs()[i] << "\n"; } } From 5e4d1151ebd90c4c9556a79e38af025682292df9 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 15:20:16 -0800 Subject: [PATCH 121/133] fixing clang compilation problems Signed-off-by: Leonardo de Moura --- src/muz_qe/qe_sat_tactic.cpp | 4 ++-- src/smt/expr_context_simplifier.h | 2 +- src/util/cooperate.cpp | 2 +- src/util/memory_manager.cpp | 1 + src/util/scoped_timer.cpp | 1 + src/util/timeout.cpp | 1 + 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/muz_qe/qe_sat_tactic.cpp b/src/muz_qe/qe_sat_tactic.cpp index f33de6382..854e15493 100644 --- a/src/muz_qe/qe_sat_tactic.cpp +++ b/src/muz_qe/qe_sat_tactic.cpp @@ -629,7 +629,7 @@ namespace qe { expr_ref fml(_fml, m); if (m_strong_context_simplify_param && m_ctx_simplify_local_param) { m_ctx_rewriter.push(); - m_ctx_rewriter.assert(M(idx)); + m_ctx_rewriter.assert_expr(M(idx)); m_ctx_rewriter(fml); m_ctx_rewriter.pop(); TRACE("qe", tout << mk_pp(_fml, m) << "\n-- context simplify -->\n" << mk_pp(fml, m) << "\n";); @@ -650,7 +650,7 @@ namespace qe { m_rewriter(not_fml); if (m_strong_context_simplify_param && !m_ctx_simplify_local_param) { m_ctx_rewriter.push(); - m_ctx_rewriter.assert(M(idx)); + m_ctx_rewriter.assert_expr(M(idx)); m_ctx_rewriter(not_fml); m_ctx_rewriter.pop(); } diff --git a/src/smt/expr_context_simplifier.h b/src/smt/expr_context_simplifier.h index 2c1f32ddc..982b65878 100644 --- a/src/smt/expr_context_simplifier.h +++ b/src/smt/expr_context_simplifier.h @@ -75,7 +75,7 @@ public: void operator()(expr_ref& result) { simplify(result.get(), result); } void push() { m_solver.push(); } void pop() { m_solver.pop(1); } - void assert(expr* e) { m_solver.assert_expr(e); } + void assert_expr(expr* e) { m_solver.assert_expr(e); } void collect_statistics(statistics & st) const { m_solver.collect_statistics(st); } void reset_statistics() { m_solver.reset_statistics(); } diff --git a/src/util/cooperate.cpp b/src/util/cooperate.cpp index c941b18e5..cdd91bfdd 100644 --- a/src/util/cooperate.cpp +++ b/src/util/cooperate.cpp @@ -16,10 +16,10 @@ Author: Notes: --*/ -#include"z3_omp.h" #include"cooperate.h" #include"trace.h" #include"debug.h" +#include"z3_omp.h" struct cooperation_lock { omp_nest_lock_t m_lock; diff --git a/src/util/memory_manager.cpp b/src/util/memory_manager.cpp index be08fe50f..de4e760d7 100644 --- a/src/util/memory_manager.cpp +++ b/src/util/memory_manager.cpp @@ -4,6 +4,7 @@ #include"trace.h" #include"memory_manager.h" #include"error_codes.h" +#include"z3_omp.h" // The following two function are automatically generated by the mk_make.py script. // The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files. // For example, rational.h contains diff --git a/src/util/scoped_timer.cpp b/src/util/scoped_timer.cpp index 5f9d554f9..4b191505f 100644 --- a/src/util/scoped_timer.cpp +++ b/src/util/scoped_timer.cpp @@ -58,6 +58,7 @@ Revision History: #endif #include"util.h" #include +#include"z3_omp.h" struct scoped_timer::imp { event_handler * m_eh; diff --git a/src/util/timeout.cpp b/src/util/timeout.cpp index b0b914b5c..75621995c 100644 --- a/src/util/timeout.cpp +++ b/src/util/timeout.cpp @@ -19,6 +19,7 @@ Revision History: --*/ #include +#include"z3_omp.h" #include"util.h" #include"timeout.h" #include"error_codes.h" From 2b66b50c758f06981683b5398cc3c1ee743971cf Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 16:21:38 -0800 Subject: [PATCH 122/133] making tests deterministic Signed-off-by: Leonardo de Moura --- src/api/python/z3.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 033626747..e690a9bff 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -23,8 +23,11 @@ Small example: >>> s.add(y == x + 1) >>> s.check() sat ->>> s.model() -[y = 2, x = 1] +>>> m = s.model() +>>> m[x] +1 +>>> m[y] +2 Z3 exceptions: @@ -1728,10 +1731,11 @@ def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]): >>> q = Exists([x, y], f(x, y) >= x, skid="foo") >>> q Exists([x, y], f(x, y) >= x) - >>> Tactic('nnf')(q) - [[f(x!foo!1, y!foo!0) >= x!foo!1]] - >>> Tactic('nnf')(q).as_expr() - f(x!foo!3, y!foo!2) >= x!foo!3 + >>> is_quantifier(q) + True + >>> r = Tactic('nnf')(q).as_expr() + >>> is_quantifier(r) + False """ return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns) From 1a11196211b29e06dedbcaaf3688e5b9048955e1 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 16:21:53 -0800 Subject: [PATCH 123/133] fixing bug introduced today Signed-off-by: Leonardo de Moura --- src/smt/theory_arith.h | 2 +- src/smt/theory_arith_aux.h | 2 +- src/smt/theory_arith_core.h | 14 +++++++------- src/smt/theory_arith_eq.h | 12 ++++++------ src/smt/theory_arith_int.h | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 9435a49cd..e7037f31a 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -260,7 +260,7 @@ namespace smt { bool is_atom() const { return m_atom; } inf_numeral const & get_value() const { return m_value; } virtual bool has_justification() const { return false; } - virtual void push_justification(antecedents& antecedents, numeral const& coeff) {} + virtual void push_justification(antecedents& antecedents, numeral const& coeff, bool proofs_enabled) {} }; diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index 1e15365a4..9f77934e5 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -749,7 +749,7 @@ namespace smt { void theory_arith::accumulate_justification(bound & b, derived_bound& new_bound, numeral const& coeff, literal_idx_set & lits, eq_set & eqs) { antecedents& ante = m_tmp_antecedents; ante.reset(); - b.push_justification(ante, coeff); + b.push_justification(ante, coeff, proofs_enabled()); unsigned num_lits = ante.lits().size(); for (unsigned i = 0; i < num_lits; ++i) { literal l = ante.lits()[i]; diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index 0f3ed1d13..b774fb3d9 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -1979,7 +1979,7 @@ namespace smt { tout << "is_below_lower: " << below_lower(x_i) << ", is_above_upper: " << above_upper(x_i) << "\n";); antecedents& ante = get_antecedents(); explain_bound(r, idx, !is_below, delta, ante); - b->push_justification(ante, numeral(1)); + b->push_justification(ante, numeral(1), proofs_enabled()); set_conflict(ante.lits().size(), ante.lits().c_ptr(), @@ -2122,8 +2122,8 @@ namespace smt { void theory_arith::sign_bound_conflict(bound * b1, bound * b2) { SASSERT(b1->get_var() == b2->get_var()); antecedents& ante = get_antecedents(); - b1->push_justification(ante, numeral(1)); - b2->push_justification(ante, numeral(1)); + b1->push_justification(ante, numeral(1), proofs_enabled()); + b2->push_justification(ante, numeral(1), proofs_enabled()); set_conflict(ante.lits().size(), ante.lits().c_ptr(), ante.eqs().size(), ante.eqs().c_ptr(), ante, is_int(b1->get_var()), "farkas"); TRACE("arith_conflict", tout << "bound conflict\n";); @@ -2382,7 +2382,7 @@ namespace smt { if (!b->has_justification()) continue; if (!relax_bounds() || delta.is_zero()) { - b->push_justification(ante, it->m_coeff); + b->push_justification(ante, it->m_coeff, proofs_enabled()); continue; } numeral coeff = it->m_coeff; @@ -2442,7 +2442,7 @@ namespace smt { SASSERT(!is_b_lower || k_2 <= k_1); SASSERT(is_b_lower || k_2 >= k_1); if (new_atom == 0) { - b->push_justification(ante, coeff); + b->push_justification(ante, coeff, proofs_enabled()); continue; } SASSERT(!is_b_lower || k_2 < k_1); @@ -2686,8 +2686,8 @@ namespace smt { typename vector::const_iterator end = r.end_entries(); for (; it != end; ++it) { if (!it->is_dead() && is_fixed(it->m_var)) { - lower(it->m_var)->push_justification(antecedents, it->m_coeff); - upper(it->m_var)->push_justification(antecedents, it->m_coeff); + lower(it->m_var)->push_justification(antecedents, it->m_coeff, proofs_enabled()); + upper(it->m_var)->push_justification(antecedents, it->m_coeff, proofs_enabled()); } } } diff --git a/src/smt/theory_arith_eq.h b/src/smt/theory_arith_eq.h index e6130acfe..04e16e778 100644 --- a/src/smt/theory_arith_eq.h +++ b/src/smt/theory_arith_eq.h @@ -59,10 +59,10 @@ namespace smt { // v >= k >= v2 => v >= v2 // - lower(v)->push_justification(ante, numeral::zero()); - upper(v2)->push_justification(ante, numeral::zero()); - lower(v2)->push_justification(ante, numeral::zero()); - upper(v)->push_justification(ante, numeral::zero()); + lower(v)->push_justification(ante, numeral::zero(), proofs_enabled()); + upper(v2)->push_justification(ante, numeral::zero(), proofs_enabled()); + lower(v2)->push_justification(ante, numeral::zero(), proofs_enabled()); + upper(v)->push_justification(ante, numeral::zero(), proofs_enabled()); TRACE("arith_fixed_propagate_eq", tout << "propagate eq: v" << v << " = v" << v2 << "\n"; display_var(tout, v); @@ -247,8 +247,8 @@ namespace smt { // // x1 <= k1 x1 >= k1, x2 <= x1 + k2 x2 >= x1 + k2 // - lower(x2)->push_justification(ante, numeral::zero()); - upper(x2)->push_justification(ante, numeral::zero()); + lower(x2)->push_justification(ante, numeral::zero(), proofs_enabled()); + upper(x2)->push_justification(ante, numeral::zero(), proofs_enabled()); m_stats.m_fixed_eqs++; propagate_eq_to_core(x, x2, ante); } diff --git a/src/smt/theory_arith_int.h b/src/smt/theory_arith_int.h index 2a3bff804..e0ecc087a 100644 --- a/src/smt/theory_arith_int.h +++ b/src/smt/theory_arith_int.h @@ -525,7 +525,7 @@ namespace smt { } // k += new_a_ij * lower_bound(x_j).get_rational(); k.addmul(new_a_ij, lower_bound(x_j).get_rational()); - lower(x_j)->push_justification(ante, numeral::zero()); + lower(x_j)->push_justification(ante, numeral::zero(), proofs_enabled()); } else { SASSERT(at_upper(x_j)); @@ -541,7 +541,7 @@ namespace smt { } // k += new_a_ij * upper_bound(x_j).get_rational(); k.addmul(new_a_ij, upper_bound(x_j).get_rational()); - upper(x_j)->push_justification(ante, numeral::zero()); + upper(x_j)->push_justification(ante, numeral::zero(), proofs_enabled()); } pol.push_back(row_entry(new_a_ij, x_j)); } @@ -566,7 +566,7 @@ namespace smt { } // k += new_a_ij * lower_bound(x_j).get_rational(); k.addmul(new_a_ij, lower_bound(x_j).get_rational()); - lower(x_j)->push_justification(ante, numeral::zero()); + lower(x_j)->push_justification(ante, numeral::zero(), proofs_enabled()); } else { SASSERT(at_upper(x_j)); @@ -579,7 +579,7 @@ namespace smt { new_a_ij.neg(); // the upper terms are inverted // k += new_a_ij * upper_bound(x_j).get_rational(); k.addmul(new_a_ij, upper_bound(x_j).get_rational()); - upper(x_j)->push_justification(ante, numeral::zero()); + upper(x_j)->push_justification(ante, numeral::zero(), proofs_enabled()); } TRACE("gomory_cut_detail", tout << "new_a_ij: " << new_a_ij << "\n";); pol.push_back(row_entry(new_a_ij, x_j)); @@ -772,8 +772,8 @@ namespace smt { // u += ncoeff * lower_bound(v).get_rational(); u.addmul(ncoeff, lower_bound(v).get_rational()); } - lower(v)->push_justification(ante, numeral::zero()); - upper(v)->push_justification(ante, numeral::zero()); + lower(v)->push_justification(ante, numeral::zero(), proofs_enabled()); + upper(v)->push_justification(ante, numeral::zero(), proofs_enabled()); } else if (gcds.is_zero()) { gcds = abs_ncoeff; From 4ec4151e8210aee2af21ef21d5bb9332d36a20ab Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Mon, 3 Dec 2012 03:50:28 +0000 Subject: [PATCH 124/133] Change treatment of unsigned to avoid depending on unspecified behavior of recursive macros --- src/api/ml/build.sed | 6 +++--- src/api/ml/z3.idl | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/api/ml/build.sed b/src/api/ml/build.sed index e4434a5a1..d53a13713 100644 --- a/src/api/ml/build.sed +++ b/src/api/ml/build.sed @@ -1,7 +1,7 @@ # attempt to clean up the mess with 'unsigned' -s/__in unsigned __/__in __/g -s/__out unsigned __/__out __/g -s/__out_opt unsigned __/__out_opt __/g +s/ unsigned/ unsigned int/g +s/unsigned int long/unsigned long/g +s/unsigned int __/unsigned __/g # '@name ' -> 'Section: ' diff --git a/src/api/ml/z3.idl b/src/api/ml/z3.idl index 2450e387d..555835c88 100644 --- a/src/api/ml/z3.idl +++ b/src/api/ml/z3.idl @@ -91,11 +91,6 @@ quote(c,"#define xstr(s) str(s)"); quote(c,"#define str(s) #s"); -// CamlIDL (1.05) has a bug where it does not accept [unsigned] as a type, -// only as a specifier, so unsigned is defined to be unsigned int. -#define unsigned unsigned int - - // Suppress "warning C4090: 'function' : different 'const' qualifiers" as // CamlIDL does not seem to get this right. quote(c,"#pragma warning(disable:4090)"); From ae5f96895dfd7454d1a3cb8770d0a180b956acda Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Mon, 3 Dec 2012 03:51:04 +0000 Subject: [PATCH 125/133] Change to avoid relying on sed supporting disjunction or escaped control characters --- src/api/ml/add_error_checking.V3.sed | 2 +- src/api/ml/add_error_checking.sed | 81 ++++++++++++++++++---------- src/api/ml/build.sed | 2 +- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/api/ml/add_error_checking.V3.sed b/src/api/ml/add_error_checking.V3.sed index 170ca2d6b..7ec725b77 100644 --- a/src/api/ml/add_error_checking.V3.sed +++ b/src/api/ml/add_error_checking.V3.sed @@ -1,2 +1,2 @@ # Customize error handling for contexts created in ML: -s/Z3_API Z3_mk_context\(_rc\|\)(\(.*\))/Z3_API Z3_mk_context\1(\2) quote(dealloc,\"Z3_set_error_handler(_res, caml_z3_error_handler);\")/g +s/Z3_API Z3_mk_context(\(.*\))/Z3_API Z3_mk_context(\1) quote(dealloc,\"Z3_set_error_handler(_res, caml_z3_error_handler);\")/g diff --git a/src/api/ml/add_error_checking.sed b/src/api/ml/add_error_checking.sed index ede3275e1..71c06b9e4 100644 --- a/src/api/ml/add_error_checking.sed +++ b/src/api/ml/add_error_checking.sed @@ -3,14 +3,19 @@ # Add error checking epilogue for all Z3_API functions that accept two Z3_contexts :begincc -# add epilogue for two Z3_context parameters -s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\")\7/g - -# if a match was found, done with all Z3_contexts and Z3_theorys +# add epilogue for two Z3_context parameters and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3);\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3);\")/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3);\")/g t endt # if complete prototype, done with two Z3_contexts -/Z3_API .*(.*)\(;\|\)[ ]*$/b endcc +/Z3_API .*(.*);[ ]*$/b endcc +/Z3_API .*(.*)[ ]*$/b endcc # if incomplete prototype /Z3_API .*(.*/{ @@ -18,10 +23,14 @@ t endt # read another line N - # add epilogue for two Z3_context parameters - s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")\7/g - - # if a match was found, done with all Z3_contexts and Z3_theorys + # add epilogue for two Z3_context parameters and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5\6) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3\4Z3_context \5) quote(dealloc,\"check_error_code(\3); check_error_code(\5);\")/g t endt # else keep looking for two Z3_contexts @@ -31,14 +40,19 @@ t endt # Add error checking epilogue for all Z3_API functions that accept one Z3_context :beginc -# add epilogue for one Z3_context parameter -s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g - -# if a match was found, done with all Z3_contexts and Z3_theorys +# add epilogue for one Z3_context parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\")/g t endt # if complete prototype, done with all Z3_contexts -/Z3_API .*(.*)\(;\|\)[ ]*$/b endc +/Z3_API .*(.*);[ ]*$/b endc +/Z3_API .*(.*)[ ]*$/b endc # if incomplete prototype /Z3_API .*(.*/{ @@ -46,10 +60,14 @@ t endt # read another line N - # add epilogue for one Z3_context parameter - s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")\5/g - - # if a match was found, done with all Z3_contexts and Z3_theorys + # add epilogue for one Z3_context parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_context \3\4) quote(dealloc,\"check_error_code(\3);\")/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_context \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_context \3) quote(dealloc,\"check_error_code(\3);\")/g t endt # else keep looking for one Z3_context @@ -60,24 +78,33 @@ t endt # Add error checking epilogue for all Z3_API functions that accept a Z3_theory :begint -# add epilogue for one Z3_theory parameter -s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g - -# if a match was found, done with all Z3_contexts and Z3_theorys +# add epilogue for one Z3_theory parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt +s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g +t endt +s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g t endt # if complete prototype, done with all Z3_theorys -/Z3_API .*(.*)\(;\|\)[ ]*$/b endt +/Z3_API .*(.*);[ ]*$/b endt +/Z3_API .*(.*)[ ]*$/b endt /Z3_API .*(.*/{ # read another line N - # add epilogue for one Z3_theory parameter - s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\|\))\(;\|\)[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")\5/g - - # if a match was found, done with all Z3_theorys + # add epilogue for one Z3_theory parameter and if a match was found, done with all Z3_contexts and Z3_theorys so jump to endt + s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\));[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\));[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\");/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\)\([^a-zA-Z].*\))[ ]*$/Z3_API \1(\2Z3_theory \3\4) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g + t endt + s/Z3_API \(.*\)(\(.*\)Z3_theory \([a-zA-Z]*\))[ ]*$/Z3_API \1(\2Z3_theory \3) quote(dealloc,\"check_error_code(Z3_theory_get_context(\3));\")/g t endt # else keep looking for one Z3_theory diff --git a/src/api/ml/build.sed b/src/api/ml/build.sed index d53a13713..c7d1fc804 100644 --- a/src/api/ml/build.sed +++ b/src/api/ml/build.sed @@ -43,7 +43,7 @@ s/\\ / /g s/\\c \([^ .,:]*\)/[\1]/g # '#Z3_' -> 'Z3.' -s/#Z3_\([^ \n\.\t,)]*\)/{!Z3.\1}/g +s/#Z3_\([^ \.,) ]*\)/{!Z3.\1}/g # '/*@}*/' -> '' s/\/\*@{\*\///g From 949317ccfcb7f43d2449c72448b31b2a172797a2 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 4 Dec 2012 03:23:10 +0000 Subject: [PATCH 126/133] Fixes for error handling in ml api --- src/api/ml/add_error_checking.V3.sed | 2 +- src/api/ml/error_handling.idl | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/api/ml/add_error_checking.V3.sed b/src/api/ml/add_error_checking.V3.sed index 7ec725b77..7df291520 100644 --- a/src/api/ml/add_error_checking.V3.sed +++ b/src/api/ml/add_error_checking.V3.sed @@ -1,2 +1,2 @@ # Customize error handling for contexts created in ML: -s/Z3_API Z3_mk_context(\(.*\))/Z3_API Z3_mk_context(\1) quote(dealloc,\"Z3_set_error_handler(_res, caml_z3_error_handler);\")/g +s/Z3_API Z3_mk_context(\(.*\))/Z3_API Z3_mk_context(\1) quote(dealloc,\"Z3_set_error_handler(_res, (void*)caml_z3_error_handler);\")/g diff --git a/src/api/ml/error_handling.idl b/src/api/ml/error_handling.idl index cc49a91e4..5a2ec9915 100644 --- a/src/api/ml/error_handling.idl +++ b/src/api/ml/error_handling.idl @@ -53,6 +53,12 @@ Author: #endif +// The V3 API uses a single handler irregardless of UNSAFE_ERRORS +quote(c," +/* All contexts share the same handler */ +static value caml_z3_error_handler = 0; +"); + #ifdef SAFE_ERRORS quote(mlmli," @@ -64,7 +70,7 @@ quote(mlmli," exception Error of context * error_code "); quote(ml," -/* Register dynamically-generated exception tag for use from C */ +(* Register dynamically-generated exception tag for use from C *) let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK)) "); @@ -108,7 +114,7 @@ quote(mlmli," exception Error of context * error_code "); quote(ml," -/* Register dynamically-generated exception tag for use from C */ +(* Register dynamically-generated exception tag for use from C *) let _ = Callback.register_exception \"Z3.Error\" (Error (Obj.magic None, OK)) "); @@ -116,9 +122,6 @@ quote(c," /* Error checking routine that does nothing */ void check_error_code(Z3_context c) {} -/* All contexts share the same handler */ -static value caml_error_handler = 0; - static void error_handler_static (Z3_context c, Z3_error_code e) { static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; @@ -126,8 +129,8 @@ static void error_handler_static (Z3_context c, Z3_error_code e) value ctx_err[2]; ctx_err[0] = c2ml_Z3_context(&c); ctx_err[1] = camlidl_c2ml_z3_Z3_error_code(&e, &_ctxs); - if (caml_error_handler) { - caml_callback2(caml_error_handler, ctx_err[0], ctx_err[1]); + if (caml_z3_error_handler) { + caml_callback2(caml_z3_error_handler, ctx_err[0], ctx_err[1]); } else { /* if no handler set, raise OCaml Error exception */ exn_tag = caml_named_value(\"Z3.Error\"); @@ -141,7 +144,7 @@ static void error_handler_static (Z3_context c, Z3_error_code e) void ml2c_Z3_error_handler (value ml_handler, void* c_handler) { - caml_error_handler = ml_handler; + caml_z3_error_handler = ml_handler; c_handler = (void*)error_handler_static; } From 6fad07e6e1f16c0c662092132e2141f690176d34 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 4 Dec 2012 03:31:08 +0000 Subject: [PATCH 127/133] Update build system for ml api --- src/api/ml/Makefile | 14 +++++ src/api/ml/Makefile.build | 69 ++++++++++++++++++++++++ src/api/ml/generate_mlapi.sh | 53 ++++++++++++++++++ src/api/ml/postprocess.sed | 8 +++ src/api/ml/{build.sed => preprocess.sed} | 0 src/api/ml/reverse.sed | 3 ++ src/api/ml/{z3.idl => z3.0.idl} | 5 -- 7 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 src/api/ml/Makefile create mode 100644 src/api/ml/Makefile.build create mode 100755 src/api/ml/generate_mlapi.sh create mode 100644 src/api/ml/postprocess.sed rename src/api/ml/{build.sed => preprocess.sed} (100%) create mode 100644 src/api/ml/reverse.sed rename src/api/ml/{z3.idl => z3.0.idl} (98%) diff --git a/src/api/ml/Makefile b/src/api/ml/Makefile new file mode 100644 index 000000000..55f89fe1c --- /dev/null +++ b/src/api/ml/Makefile @@ -0,0 +1,14 @@ +# to set ARGS, invoke as e.g.: $ make ARGS='-DUNSAFE_ERRORS -DLEAK_CONTEXTS' +ARGS= + + +default: z3.ml z3.mli z3_stubs.c + + +%.ml %.mli %_stubs.c: ../%_api.h %.0.idl x3.ml x3V3.ml x3V3.mli \ + error_handling.idl mlx_get_app_args.idl mlx_get_array_sort.idl mlx_get_datatype_sort.idl mlx_get_domains.idl mlx_get_error_msg.idl mlx_get_pattern_terms.idl mlx_get_tuple_sort.idl mlx_mk_context_x.idl mlx_mk_datatypes.idl mlx_mk_numeral.idl mlx_mk_sort.idl mlx_mk_symbol.idl mlx_model.idl mlx_numeral_refine.idl mlx_parse_smtlib.idl mlx_sort_refine.idl mlx_statistics.idl mlx_symbol_refine.idl mlx_term_refine.idl \ + generate_mlapi.sh add_error_checking.V3.sed add_error_checking.sed preprocess.sed postprocess.sed reverse.sed + ./generate_mlapi.sh $(ARGS) + +clean: + rm -f z3.ml z3.mli z3_stubs.c diff --git a/src/api/ml/Makefile.build b/src/api/ml/Makefile.build new file mode 100644 index 000000000..27c798bbf --- /dev/null +++ b/src/api/ml/Makefile.build @@ -0,0 +1,69 @@ +# Makefile to compile OCaml interface to Z3 +# +# Parameters: ARGS and DEPS environment variables +# ARGS is passed through to the Makefile that generates the OCaml interface +# DEPS is a sequence of files that are deleted when the OCaml interface changes + +SRC_ML=../../../src/api/ml +ifeq (${OS}, Windows_NT) +# the BLD_ML path ends up stored in z3.cm{,x}a, so it must be in windows format +BLD_ML=$(shell cygpath -m $(CURDIR)) +CFLAGS=-ccopt -wd4090 -ccopt -I$(SRC_ML)/.. +XCDBG=-g $(CFLAGS) +XCOPT=-ccopt -Ox -ccopt -Oy- $(CFLAGS) +# ole32 is needed by camlidl (COM support) +XLIB=-cclib ole32.lib +AR=lib /nologo /LIBPATH:../../build ../../z3.lib /out: +O=obj +A=lib +else +BLD_ML=$(CURDIR) +CFLAGS=-ccopt -Wno-discard-qual -ccopt -Wno-unused-variable -ccopt -I$(SRC_ML)/.. +XCDBG=-g -ccopt -g $(CFLAGS) +XCOPT=-ccopt -O3 -ccopt -fomit-frame-pointer $(CFLAGS) +XLIB= +AR=ar rcs # note trailing space is significant +O=o +A=a +endif + + +all: z3.cma z3.cmxa ocamlz3 + + +# keep these files to avoid repeatedly rebuilding them +.PRECIOUS: $(SRC_ML)/z3.ml $(SRC_ML)/z3.mli $(SRC_ML)/z3_stubs.c z3.ml z3.mli z3_stubs.c z3_theory_stubs.c + +# regenerate OCaml API if needed +$(SRC_ML)/%.mli $(SRC_ML)/%.ml $(SRC_ML)/%_stubs.c: $(SRC_ML)/Makefile + make -C $(SRC_ML) z3.mli z3.ml z3_stubs.c + +# copy OCaml API from src to build directories +%.mli %.ml %_stubs.c %_theory_stubs.c: $(SRC_ML)/%.mli $(SRC_ML)/%.ml $(SRC_ML)/%_stubs.c Makefile + cp $(SRC_ML)/z3.mli $(SRC_ML)/z3.ml $(SRC_ML)/z3_stubs.c $(SRC_ML)/z3_theory_stubs.c . + +# OCaml library module for native code clients +%.cmxa %.cmi lib%stubs.a %.a: %.mli %.ml %_stubs.c %_theory_stubs.c Makefile + rm -f $(DEPS) + ocamlopt.opt -c $(XCOPT) z3.mli z3.ml z3_stubs.c z3_theory_stubs.c + $(AR)libz3stubs.$(A) z3.$(O) z3_stubs.$(O) z3_theory_stubs.$(O) + ocamlopt.opt -a -cclib -L$(BLD_ML)/../.. $(XLIB) -cclib -lcamlidl -cclib -lz3 -cclib -lz3stubs z3.cmx -o z3.cmxa + rm -f z3_theory_stubs.$(O) z3_stubs.$(O) z3.$(O) z3.cmx + +# OCaml library module for byte code clients +%.cma %.cmi lib%stubs_dbg.a: %.mli %.ml %_stubs.c %_theory_stubs.c Makefile + rm -f $(DEPS) + ocamlc.opt -c $(XCDBG) z3.mli z3.ml z3_stubs.c z3_theory_stubs.c + $(AR)libz3stubs_dbg.$(A) z3_stubs.$(O) z3_theory_stubs.$(O) + ocamlc.opt -custom -a $(CXDBG) -cclib -L$(BLD_ML)/../.. $(XLIB) -cclib -lcamlidl -cclib -lz3 -cclib -lz3stubs_dbg z3.cmo -o z3.cma + rm -f z3_theory_stubs.$(O) z3_stubs.$(O) z3.cmo + + +# OCaml custom toplevel system pre-linked with Z3 +ocamlz3: z3.cma Makefile + ocamlmktop -o ocamlz3 z3.cma -cclib -L. + + +clean: Makefile + make -C $(SRC_ML) clean + rm -rf Makefile libz3stubs.$(A) libz3stubs_dbg.$(A) ocamlz3 ocamlz3.dSYM z3.$(O) z3.$(A) z3.cma z3.cmi z3.cmo z3.cmx z3.cmxa z3.ml z3.mli z3_stubs.$(O) z3_stubs.c z3_theory_stubs.$(O) z3_theory_stubs.c diff --git a/src/api/ml/generate_mlapi.sh b/src/api/ml/generate_mlapi.sh new file mode 100755 index 000000000..dd8692833 --- /dev/null +++ b/src/api/ml/generate_mlapi.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Script to generate the Z3 OCaml API +# +# Assumes that environment variables are set to provide access to the following commands: camlidl, gcc, grep, sed +# +# This script uses 'gcc -E' as the C preprocessor, other C preprocessors may work but have not been tested. +# +# Invoke with "-DUNSAFE_ERRORS" to build version that does not support recoverable errors, but avoids some error-checking overhead. +# Invoke with "-DLEAK_CONTEXTS" to build version that leaks Z3_context objects, but avoids some garbage-collection overhead. + + +# add calls to error checking routine +# convert from doxygen to ocamldoc markup and other syntactic munging +# ../z3_api.h -> z3V3_api.idl +sed -f add_error_checking.V3.sed -f preprocess.sed ../z3_api.h > z3V3_api.idl + +# z3.idl (z3V3_api.idl x3V3.mli x3V3.ml) -> z3V3_stubs.c, z3V3.mli, z3V3.ml +gcc -E -w -P -CC -xc -DCAMLIDL -DMLAPIV3 $@ z3.0.idl > z3V3.idl +camlidl -nocpp z3V3.idl + +# reverse.sed to reverse order of substitution of enums to avoid matching prefixes such as enum_1 of enum_10 +grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_]*$" z3V3.mli | sed -e "s|and z3_\([a-zA-Z0-9_]*\) = \([a-zA-Z0-9_]*\)|s/\2/\1/g|g" -f reverse.sed > /tmp/renameV3.sed +grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_ ]* option$" z3V3.mli | sed -e "s|and \(z3_[a-zA-Z0-9_]*\) = \([a-zA-Z0-9_ ]*\)|s/\1/\2/g|g" >> /tmp/renameV3.sed + +# rename.sed to substitute out type equations for enums and options, then postprocess +cp -f z3V3.mli z3V3.ml /tmp +sed -f /tmp/renameV3.sed -f postprocess.sed /tmp/z3V3.mli > z3V3.mli +sed -f /tmp/renameV3.sed -f postprocess.sed /tmp/z3V3.ml > z3V3.ml + +# ../z3_api.h -> z3_api.idl +sed -f add_error_checking.sed -f preprocess.sed ../z3_api.h > z3_api.idl + +# z3.idl (z3_api.idl x3.ml) -> z3_stubs.c, z3.mli, z3.ml +gcc -E -w -P -CC -xc -I. -DCAMLIDL $@ z3.0.idl > z3.idl +camlidl -nocpp z3.idl + +# reverse.sed to reverse order of substitution of enums to avoid matching prefixes such as enum_1 of enum_10 +grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_]*$" z3.mli | sed -e "s|and z3_\([a-zA-Z0-9_]*\) = \([a-zA-Z0-9_]*\)|s/\2/\1/g|g" -f reverse.sed > /tmp/rename.sed +grep "^and z3_[a-zA-Z0-9_]* = [a-z][a-zA-Z0-9_ ]* option$" z3.mli | sed -e "s|and \(z3_[a-zA-Z0-9_]*\) = \([a-zA-Z0-9_ ]*\)|s/\1/\2/g|g" >> /tmp/rename.sed + +# rename.sed to substitute out type equations for enums and options, then postprocess +cp z3.mli z3.ml /tmp +sed -f /tmp/rename.sed -f postprocess.sed /tmp/z3.mli > z3.mli +sed -f /tmp/rename.sed -f postprocess.sed /tmp/z3.ml > z3.ml + + +# append Z3.V3 module onto Z3 module +cat z3V3.mli >> z3.mli +cat z3V3.ml >> z3.ml +sed "1,22d" z3V3_stubs.c >> z3_stubs.c + +rm -f z3V3_api.idl z3V3.idl z3V3.ml z3V3.mli z3V3_stubs.c z3_api.idl z3.idl diff --git a/src/api/ml/postprocess.sed b/src/api/ml/postprocess.sed new file mode 100644 index 000000000..f25f70cb7 --- /dev/null +++ b/src/api/ml/postprocess.sed @@ -0,0 +1,8 @@ +# remove 'z3_' and 'Z3_' prefixes on names + +s/{\!Z3\./{\!/g +s/\([^_]\)[zZ]3_/\1/g + +# remove cyclic definitions introduced by substituting type equations + +s/^and \([a-z][a-zA-Z_ ]*\) = \1$//g diff --git a/src/api/ml/build.sed b/src/api/ml/preprocess.sed similarity index 100% rename from src/api/ml/build.sed rename to src/api/ml/preprocess.sed diff --git a/src/api/ml/reverse.sed b/src/api/ml/reverse.sed new file mode 100644 index 000000000..31ac563d2 --- /dev/null +++ b/src/api/ml/reverse.sed @@ -0,0 +1,3 @@ +# output lines of input in reverse order + +1!G;h;$!d diff --git a/src/api/ml/z3.idl b/src/api/ml/z3.0.idl similarity index 98% rename from src/api/ml/z3.idl rename to src/api/ml/z3.0.idl index 555835c88..3773a28e3 100644 --- a/src/api/ml/z3.idl +++ b/src/api/ml/z3.0.idl @@ -91,11 +91,6 @@ quote(c,"#define xstr(s) str(s)"); quote(c,"#define str(s) #s"); -// Suppress "warning C4090: 'function' : different 'const' qualifiers" as -// CamlIDL does not seem to get this right. -quote(c,"#pragma warning(disable:4090)"); - - #ifndef MLAPIV3 #define DEFINE_TYPE(T) typedef [abstract] void* T From 2f3daf14b51f993f5e8ed88f51b678c5d8e8c98d Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 6 Dec 2012 00:42:30 +0000 Subject: [PATCH 128/133] Regenerate ml api --- src/api/ml/z3.ml | 404 ++--- src/api/ml/z3.mli | 3498 ++++++++++------------------------------- src/api/ml/z3_stubs.c | 401 +++-- 3 files changed, 1196 insertions(+), 3107 deletions(-) diff --git a/src/api/ml/z3.ml b/src/api/ml/z3.ml index 76536ef43..4d391c06f 100644 --- a/src/api/ml/z3.ml +++ b/src/api/ml/z3.ml @@ -293,13 +293,12 @@ let reset_memory () = () (** Exceptions raised by Z3. It is safe to continue interacting with Z3 after catching [Error] exceptions. - - {b See also}: {!get_error_msg} *) exception Error of context * error_code - +(* Register dynamically-generated exception tag for use from C *) let _ = Callback.register_exception "Z3.Error" (Error (Obj.magic None, OK)) external mk_context: (string * string) list -> context = "caml_z3_mk_context" @@ -349,7 +348,6 @@ external param_descrs_to_string : context -> param_descrs -> string (** Refined view of a {!symbol}. - - {b See also}: {!mk_symbol} - {b See also}: {!symbol_refine} *) @@ -368,33 +366,28 @@ external mk_string_symbol : context -> string -> symbol A datatype constructor descriptor. *) type datatype_constructor_desc = { - constructor_desc : symbol; (** name of the constructor function *) - recognizer_desc : symbol; (** name of the recognizer function *) - accessor_descs : (symbol * sort) array; (** names and sorts of the fields *) + constructor_desc : symbol; (** name of the constructor function *) + recognizer_desc : symbol; (** name of the recognizer function *) + accessor_descs : (symbol * sort) array; (** names and sorts of the fields *) } - (** A datatype is described by a name and constructor descriptors. *) type datatype_desc = symbol * datatype_constructor_desc array - (** A datatype constructor representation. *) type datatype_constructor = { - constructor : func_decl; (** constructor function *) - recognizer : func_decl; (** recognizer function *) - accessors : func_decl array; (** field accessor functions *) + constructor : func_decl; (** constructor function *) + recognizer : func_decl; (** recognizer function *) + accessors : func_decl array; (** field accessor functions *) } - (** A datatype is represented by a sort and constructors. *) type datatype = sort * datatype_constructor array - (** Refined view of a {!sort}. - - {b See also}: {!mk_sort} - {b See also}: {!sort_refine} *) @@ -751,9 +744,9 @@ external mk_set_subset : context -> ast -> ast -> ast Summary: \[ [ numeral_refined ] \] is the refined view of a numeral . *) type numeral_refined = - | Numeral_int of int * sort - | Numeral_int64 of int64 * sort - | Numeral_large of string * sort + | Numeral_int of int * sort + | Numeral_int64 of int64 * sort + | Numeral_large of string * sort | Numeral_rational of numeral_refined * numeral_refined external mk_numeral : context -> string -> sort -> ast @@ -930,21 +923,18 @@ external get_app_arg : context -> app -> int -> ast (** Summary: \[ [ binder_type ] \] is a universal or existential quantifier. - - {b See also}: {!term_refined} *) type binder_type = Forall | Exists - (** Summary: \[ [ term_refined ] \] is the refinement of a {!ast} . - - {b See also}: {!term_refine} *) type term_refined = - | Term_numeral of numeral_refined - | Term_app of decl_kind * func_decl * ast array + | Term_numeral of numeral_refined + | Term_app of decl_kind * func_decl * ast array | Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast - | Term_var of int * sort + | Term_var of int * sort external is_eq_ast : context -> ast -> ast -> bool = "camlidl_z3_Z3_is_eq_ast" @@ -1220,12 +1210,6 @@ external get_smtlib_sort : context -> int -> sort external get_smtlib_error : context -> string = "camlidl_z3_Z3_get_smtlib_error" -external parse_z3_string : context -> string -> ast - = "camlidl_z3_Z3_parse_z3_string" - -external parse_z3_file : context -> string -> ast - = "camlidl_z3_Z3_parse_z3_file" - external set_error : context -> error_code -> unit = "camlidl_z3_Z3_set_error" @@ -1235,6 +1219,12 @@ external get_error_msg_ex : context -> error_code -> string external get_version : unit -> int * int * int * int = "camlidl_z3_Z3_get_version" +external enable_trace : string -> unit + = "camlidl_z3_Z3_enable_trace" + +external disable_trace : string -> unit + = "camlidl_z3_Z3_disable_trace" + external mk_fixedpoint : context -> fixedpoint = "camlidl_z3_Z3_mk_fixedpoint" @@ -1280,8 +1270,11 @@ external fixedpoint_register_relation : context -> fixedpoint -> func_decl -> un external fixedpoint_set_predicate_representation : context -> fixedpoint -> func_decl -> symbol array -> unit = "camlidl_z3_Z3_fixedpoint_set_predicate_representation" -external fixedpoint_simplify_rules : context -> fixedpoint -> ast array -> func_decl array -> ast_vector - = "camlidl_z3_Z3_fixedpoint_simplify_rules" +external fixedpoint_get_rules : context -> fixedpoint -> ast_vector + = "camlidl_z3_Z3_fixedpoint_get_rules" + +external fixedpoint_get_assertions : context -> fixedpoint -> ast_vector + = "camlidl_z3_Z3_fixedpoint_get_assertions" external fixedpoint_set_params : context -> fixedpoint -> params -> unit = "camlidl_z3_Z3_fixedpoint_set_params" @@ -1295,6 +1288,12 @@ external fixedpoint_get_param_descrs : context -> fixedpoint -> param_descrs external fixedpoint_to_string : context -> fixedpoint -> ast array -> string = "camlidl_z3_Z3_fixedpoint_to_string" +external fixedpoint_from_string : context -> fixedpoint -> string -> ast_vector + = "camlidl_z3_Z3_fixedpoint_from_string" + +external fixedpoint_from_file : context -> fixedpoint -> string -> ast_vector + = "camlidl_z3_Z3_fixedpoint_from_file" + external fixedpoint_push : context -> fixedpoint -> unit = "camlidl_z3_Z3_fixedpoint_push" @@ -1544,6 +1543,9 @@ external solver_get_num_scopes : context -> solver -> int external solver_assert : context -> solver -> ast -> unit = "camlidl_z3_Z3_solver_assert" +external solver_assert_and_track : context -> solver -> ast -> ast -> unit + = "camlidl_z3_Z3_solver_assert_and_track" + external solver_get_assertions : context -> solver -> ast_vector = "camlidl_z3_Z3_solver_get_assertions" @@ -1597,18 +1599,15 @@ external stats_get_double_value : context -> stats -> int -> float = "camlidl_z3_Z3_stats_get_double_value" - (* Internal auxiliary functions: *) (* (* Transform a pair of arrays into an array of pairs *) let array_combine a b = if Array.length a <> Array.length b then raise (Invalid_argument "array_combine"); Array.init (Array.length a) (fun i -> (a.(i), b.(i))) - (* [a |> b] is the pipeline operator for [b(a)] *) let ( |> ) x f = f x *) - (* Find the index of an element in an array, raises Not_found is missing *) let find equal x a = let len = Array.length a in @@ -1622,24 +1621,17 @@ let find equal x a = find_ (i+1) in find_ 0 - - (* Symbols *) - let symbol_refine c s = match get_symbol_kind c s with | INT_SYMBOL -> Symbol_int (get_symbol_int c s) | STRING_SYMBOL -> Symbol_string (get_symbol_string c s) - let mk_symbol c = function | Symbol_int(i) -> mk_int_symbol c i | Symbol_string(s) -> mk_string_symbol c s - - (* Sorts *) - -let get_datatype_sort c s = - Array.init (get_datatype_sort_num_constructors c s) (fun i -> +let get_datatype_sort c s = + Array.init (get_datatype_sort_num_constructors c s) (fun i -> let constructor = get_datatype_sort_constructor c s i in let recognizer = get_datatype_sort_recognizer c s i in let accessors = @@ -1648,7 +1640,6 @@ let get_datatype_sort c s = ) in {constructor; recognizer; accessors} ) - let sort_refine c s = match get_sort_kind c s with | UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c s) @@ -1665,7 +1656,6 @@ let sort_refine c s = | DATATYPE_SORT -> Sort_datatype (get_datatype_sort c s) | RELATION_SORT -> Sort_relation (Array.init (get_relation_arity c s) (fun i -> get_relation_column c s i)) | UNKNOWN_SORT -> Sort_unknown - let mk_sort c = function | Sort_uninterpreted(s) -> mk_uninterpreted_sort c s | Sort_bool -> mk_bool_sort c @@ -1677,10 +1667,7 @@ let mk_sort c = function | Sort_datatype(constructors) -> get_range c constructors.(0).constructor | Sort_relation(_) -> invalid_arg "Z3.mk_sort: cannot construct relation sorts" | Sort_unknown(_) -> invalid_arg "Z3.mk_sort: cannot construct unknown sorts" - - (* Replacement datatypes creation API *) - let mk_datatypes ctx generator = let usort0 = mk_uninterpreted_sort ctx (mk_int_symbol ctx 0) in @@ -1749,19 +1736,16 @@ let mk_datatypes ctx generator = ) ctorss ; datatypes - - (* Numerals *) - let rec numeral_refine c t = assert( get_ast_kind c t = NUMERAL_AST ); let sort = get_sort c t in let is_int, i = get_numeral_int c t in - if is_int then + if is_int then Numeral_int (i, sort) else let is_int64, i = get_numeral_int64 c t in - if is_int64 then + if is_int64 then Numeral_int64 (i, sort) else if get_sort_kind c sort <> REAL_SORT then @@ -1770,14 +1754,11 @@ let rec numeral_refine c t = let n = numeral_refine c (get_numerator c t) in let d = numeral_refine c (get_denominator c t) in Numeral_rational (n, d) - - let to_real c x = if get_sort_kind c (get_sort c x) = REAL_SORT then x else mk_int2real c x - let rec embed_numeral c = function | Numeral_int (i, s) -> mk_int c i s | Numeral_int64 (i, s) -> mk_int64 c i s @@ -1790,21 +1771,14 @@ let rec embed_numeral c = function let d_str = get_numeral_string c (embed_numeral c d) in mk_numeral c (n_str ^ " / " ^ d_str) (mk_real_sort c) *) - (* Terms *) - let get_app_args c a = Array.init (get_app_num_args c a) (get_app_arg c a);; - let get_domains c d = Array.init (get_domain_size c d) (get_domain c d);; - - -let get_pattern_terms c p = +let get_pattern_terms c p = Array.init (get_pattern_num_terms c p) (get_pattern c p) - - -let term_refine c t = +let term_refine c t = match get_ast_kind c t with | NUMERAL_AST -> Term_numeral (numeral_refine c t) @@ -1815,35 +1789,29 @@ let term_refine c t = let args = Array.init num_args (get_app_arg c t') in let k = get_decl_kind c f in Term_app (k, f, args) - | QUANTIFIER_AST -> + | QUANTIFIER_AST -> let bt = if is_quantifier_forall c t then Forall else Exists in - let w = get_quantifier_weight c t in - let np = get_quantifier_num_patterns c t in - let pats = Array.init np (get_quantifier_pattern_ast c t) in - let pats = Array.map (get_pattern_terms c) pats in - let nb = get_quantifier_num_bound c t in + let w = get_quantifier_weight c t in + let np = get_quantifier_num_patterns c t in + let pats = Array.init np (get_quantifier_pattern_ast c t) in + let pats = Array.map (get_pattern_terms c) pats in + let nb = get_quantifier_num_bound c t in let bound = Array.init nb (fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i) ) in let body = get_quantifier_body c t in Term_quantifier (bt, w, pats, bound, body) - | VAR_AST -> + | VAR_AST -> Term_var (get_index_value c t, get_sort c t) | _ -> assert false - - (* let mk_term c = function *) -(* | Term_numeral (numeral, sort) -> mk_numeral c numeral sort *) -(* | Term_app (kind, decl, args) -> *) -(* | Term_quantifier (strength, weight, pats, bound, body) -> *) -(* | Term_var (index, sort) -> *) - - - +(* | Term_numeral (numeral, sort) -> mk_numeral c numeral sort *) +(* | Term_app (kind, decl, args) -> *) +(* | Term_quantifier (strength, weight, pats, bound, body) -> *) +(* | Term_var (index, sort) -> *) (* Refined model API *) - let model_refine c m = let num_sorts = model_get_num_sorts c m in let sorts = Hashtbl.create num_sorts in @@ -1903,49 +1871,33 @@ let model_refine c m = () done; {sorts; consts; arrays; funcs} - - (* Extended parser API *) - -let get_smtlib_formulas c = +let get_smtlib_formulas c = Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c) - -let get_smtlib_assumptions c = +let get_smtlib_assumptions c = Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c) - let get_smtlib_decls c = Array.init (get_smtlib_num_decls c) (get_smtlib_decl c) - let get_smtlib_parse_results c = (get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c) - -let parse_smtlib_string_x c a1 a2 a3 a4 a5 = +let parse_smtlib_string_x c a1 a2 a3 a4 a5 = parse_smtlib_string c a1 a2 a3 a4 a5 ; get_smtlib_parse_results c - -let parse_smtlib_file_x c a1 a2 a3 a4 a5 = +let parse_smtlib_file_x c a1 a2 a3 a4 a5 = parse_smtlib_file c a1 a2 a3 a4 a5 ; get_smtlib_parse_results c - -let parse_smtlib_string_formula c a1 a2 a3 a4 a5 = +let parse_smtlib_string_formula c a1 a2 a3 a4 a5 = parse_smtlib_string c a1 a2 a3 a4 a5 ; match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_string_formula" - -let parse_smtlib_file_formula c a1 a2 a3 a4 a5 = +let parse_smtlib_file_formula c a1 a2 a3 a4 a5 = parse_smtlib_file c a1 a2 a3 a4 a5 ; match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_file_formula" - - (* Error handling *) - let get_error_msg c e = match e with | PARSER_ERROR -> (get_error_msg_ex c e) ^ ": " ^ (get_smtlib_error c) | _ -> get_error_msg_ex c e - - (* Refined stats API *) - let stats_refine c s = let num_stats = stats_size c s in let tbl = Hashtbl.create num_stats in @@ -1970,7 +1922,7 @@ let _ = module V3 = struct -(* File generated from z3.idl *) +(* File generated from z3V3.idl *) type symbol and literals @@ -2205,6 +2157,15 @@ and ast_print_mode = | PRINT_SMTLIB2_COMPLIANT +external global_param_set : string -> string -> unit + = "camlidl_z3V3_Z3_global_param_set" + +external global_param_reset_all : unit -> unit + = "camlidl_z3V3_Z3_global_param_reset_all" + +external global_param_get : string -> string option + = "camlidl_z3V3_Z3_global_param_get" + external mk_config : unit -> config = "camlidl_z3V3_Z3_mk_config" @@ -2263,7 +2224,7 @@ external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_dec = "camlidl_z3V3_Z3_mk_list_sort" external mk_constructor : context -> symbol -> symbol -> symbol array -> sort array -> int array -> constructor - = "camlidl_z3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor" + = "camlidl_z3V3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor" external del_constructor : context -> constructor -> unit = "camlidl_z3V3_Z3_del_constructor" @@ -2587,16 +2548,16 @@ external mk_bound : context -> int -> sort -> ast = "camlidl_z3V3_Z3_mk_bound" external mk_forall : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall" + = "camlidl_z3V3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall" external mk_exists : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists" + = "camlidl_z3V3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists" external mk_quantifier : context -> bool -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier" + = "camlidl_z3V3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier" external mk_quantifier_ex : context -> bool -> int -> symbol -> symbol -> pattern array -> ast array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex" + = "camlidl_z3V3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex" external mk_forall_const : context -> int -> app array -> pattern array -> ast -> ast = "camlidl_z3V3_Z3_mk_forall_const" @@ -2605,10 +2566,10 @@ external mk_exists_const : context -> int -> app array -> pattern array -> ast - = "camlidl_z3V3_Z3_mk_exists_const" external mk_quantifier_const : context -> bool -> int -> app array -> pattern array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const" + = "camlidl_z3V3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const" external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> app array -> pattern array -> ast array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex" + = "camlidl_z3V3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex" external get_symbol_kind : context -> symbol -> symbol_kind = "camlidl_z3V3_Z3_get_symbol_kind" @@ -2890,19 +2851,19 @@ external model_to_string : context -> model -> string = "camlidl_z3V3_Z3_model_to_string" external benchmark_to_smtlib_string : context -> string -> string -> string -> string -> ast array -> ast -> string - = "camlidl_z3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string" + = "camlidl_z3V3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string" external parse_smtlib2_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - = "camlidl_z3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string" + = "camlidl_z3V3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string" external parse_smtlib2_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - = "camlidl_z3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file" + = "camlidl_z3V3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file" external parse_smtlib_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit - = "camlidl_z3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string" + = "camlidl_z3V3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string" external parse_smtlib_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit - = "camlidl_z3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file" + = "camlidl_z3V3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file" external get_smtlib_num_formulas : context -> int = "camlidl_z3V3_Z3_get_smtlib_num_formulas" @@ -2931,15 +2892,15 @@ external get_smtlib_sort : context -> int -> sort external get_smtlib_error : context -> string = "camlidl_z3V3_Z3_get_smtlib_error" -external parse_z3_string : context -> string -> ast - = "camlidl_z3_Z3_parse_z3V3_string" - -external parse_z3_file : context -> string -> ast - = "camlidl_z3_Z3_parse_z3V3_file" - external get_version : unit -> int * int * int * int = "camlidl_z3V3_Z3_get_version" +external enable_trace : string -> unit + = "camlidl_z3V3_Z3_enable_trace" + +external disable_trace : string -> unit + = "camlidl_z3V3_Z3_disable_trace" + external reset_memory : unit -> unit = "camlidl_z3V3_Z3_reset_memory" @@ -3121,114 +3082,85 @@ external get_context_assignment : context -> ast = "camlidl_z3V3_Z3_get_context_assignment" - - (* Internal auxillary functions: *) - (* Transform a pair of arrays into an array of pairs *) let array_combine a b = if Array.length a <> Array.length b then raise (Invalid_argument "array_combine"); Array.init (Array.length a) (fun i->(a.(i),b.(i)));; - (* [a |> b] is the pipeline operator for [b(a)] *) let ( |> ) x f = f x;; - - (* Extensions, except for refinement: *) -let mk_context_x configs = +let mk_context_x configs = let config = mk_config() in let f(param_id,param_value) = set_param_value config param_id param_value in Array.iter f configs; let context = mk_context config in del_config config; context;; - let get_app_args c a = Array.init (get_app_num_args c a) (get_app_arg c a);; - let get_domains c d = Array.init (get_domain_size c d) (get_domain c d);; - let get_array_sort c t = (get_array_sort_domain c t, get_array_sort_range c t);; - -let get_tuple_sort c ty = +let get_tuple_sort c ty = (get_tuple_sort_mk_decl c ty, Array.init (get_tuple_sort_num_fields c ty) (get_tuple_sort_field_decl c ty));; - -type datatype_constructor_refined = { - constructor : func_decl; - recognizer : func_decl; - accessors : func_decl array +type datatype_constructor_refined = { + constructor : func_decl; + recognizer : func_decl; + accessors : func_decl array } - -let get_datatype_sort c ty = +let get_datatype_sort c ty = Array.init (get_datatype_sort_num_constructors c ty) - (fun idx_c -> + (fun idx_c -> let constr = get_datatype_sort_constructor c ty idx_c in - let recog = get_datatype_sort_recognizer c ty idx_c in + let recog = get_datatype_sort_recognizer c ty idx_c in let num_acc = get_domain_size c constr in { constructor = constr; recognizer = recog; accessors = Array.init num_acc (get_datatype_sort_constructor_accessor c ty idx_c); }) - let get_model_constants c m = Array.init (get_model_num_constants c m) (get_model_constant c m);; - - let get_model_func_entry c m i j = (Array.init (get_model_func_entry_num_args c m i j) (get_model_func_entry_arg c m i j), get_model_func_entry_value c m i j);; - let get_model_func_entries c m i = Array.init (get_model_func_num_entries c m i) (get_model_func_entry c m i);; - let get_model_funcs c m = Array.init (get_model_num_funcs c m) (fun i->(get_model_func_decl c m i |> get_decl_name c, get_model_func_entries c m i, get_model_func_else c m i));; - -let get_smtlib_formulas c = +let get_smtlib_formulas c = Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c);; - -let get_smtlib_assumptions c = +let get_smtlib_assumptions c = Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c);; - let get_smtlib_decls c = Array.init (get_smtlib_num_decls c) (get_smtlib_decl c);; - let get_smtlib_parse_results c = (get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c);; - -let parse_smtlib_string_formula c a1 a2 a3 a4 a5 = +let parse_smtlib_string_formula c a1 a2 a3 a4 a5 = (parse_smtlib_string c a1 a2 a3 a4 a5; match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_string_formula");; - -let parse_smtlib_file_formula c a1 a2 a3 a4 a5 = +let parse_smtlib_file_formula c a1 a2 a3 a4 a5 = (parse_smtlib_file c a1 a2 a3 a4 a5; match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_file_formula");; - -let parse_smtlib_string_x c a1 a2 a3 a4 a5 = +let parse_smtlib_string_x c a1 a2 a3 a4 a5 = (parse_smtlib_string c a1 a2 a3 a4 a5; get_smtlib_parse_results c);; - -let parse_smtlib_file_x c a1 a2 a3 a4 a5 = +let parse_smtlib_file_x c a1 a2 a3 a4 a5 = (parse_smtlib_file c a1 a2 a3 a4 a5; get_smtlib_parse_results c);; - (* Refinement: *) - type symbol_refined = | Symbol_int of int | Symbol_string of string | Symbol_unknown;; - let symbol_refine c s = match get_symbol_kind c s with | INT_SYMBOL -> Symbol_int (get_symbol_int c s) | STRING_SYMBOL -> Symbol_string (get_symbol_string c s);; - type sort_refined = | Sort_uninterpreted of symbol | Sort_bool @@ -3240,7 +3172,6 @@ type sort_refined = | Sort_relation | Sort_finite_domain | Sort_unknown of symbol;; - let sort_refine c ty = match get_sort_kind c ty with | UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c ty) @@ -3250,56 +3181,50 @@ let sort_refine c ty = | BV_SORT -> Sort_bv (get_bv_sort_size c ty) | ARRAY_SORT -> Sort_array (get_array_sort_domain c ty, get_array_sort_range c ty) | DATATYPE_SORT -> Sort_datatype (get_datatype_sort c ty) - | RELATION_SORT -> Sort_relation + | RELATION_SORT -> Sort_relation | FINITE_DOMAIN_SORT -> Sort_finite_domain | UNKNOWN_SORT -> Sort_unknown (get_sort_name c ty);; - -let get_pattern_terms c p = +let get_pattern_terms c p = Array.init (get_pattern_num_terms c p) (get_pattern c p) - -type binder_type = | Forall | Exists - -type numeral_refined = - | Numeral_small of int64 * int64 - | Numeral_large of string - -type term_refined = - | Term_app of decl_kind * func_decl * ast array +type binder_type = | Forall | Exists +type numeral_refined = + | Numeral_small of int64 * int64 + | Numeral_large of string +type term_refined = + | Term_app of decl_kind * func_decl * ast array | Term_quantifier of binder_type * int * ast array array * (symbol *sort) array * ast - | Term_numeral of numeral_refined * sort - | Term_var of int * sort - -let term_refine c t = + | Term_numeral of numeral_refined * sort + | Term_var of int * sort +let term_refine c t = match get_ast_kind c t with - | NUMERAL_AST -> + | NUMERAL_AST -> let (is_small, n, d) = get_numeral_small c t in - if is_small then - Term_numeral(Numeral_small(n,d), get_sort c t) + if is_small then + Term_numeral(Numeral_small(n,d), get_sort c t) else - Term_numeral(Numeral_large(get_numeral_string c t), get_sort c t) - | APP_AST -> + Term_numeral(Numeral_large(get_numeral_string c t), get_sort c t) + | APP_AST -> let t' = to_app c t in - let f = get_app_decl c t' in + let f = get_app_decl c t' in let num_args = get_app_num_args c t' in let args = Array.init num_args (get_app_arg c t') in let k = get_decl_kind c f in Term_app (k, f, args) - | QUANTIFIER_AST -> + | QUANTIFIER_AST -> let bt = if is_quantifier_forall c t then Forall else Exists in - let w = get_quantifier_weight c t in - let np = get_quantifier_num_patterns c t in - let pats = Array.init np (get_quantifier_pattern_ast c t) in - let pats = Array.map (get_pattern_terms c) pats in - let nb = get_quantifier_num_bound c t in - let bound = Array.init nb - (fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)) in + let w = get_quantifier_weight c t in + let np = get_quantifier_num_patterns c t in + let pats = Array.init np (get_quantifier_pattern_ast c t) in + let pats = Array.map (get_pattern_terms c) pats in + let nb = get_quantifier_num_bound c t in + let bound = Array.init nb + (fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)) in let body = get_quantifier_body c t in Term_quantifier(bt, w, pats, bound, body) - | VAR_AST -> + | VAR_AST -> Term_var(get_index_value c t, get_sort c t) | _ -> assert false - -type theory_callbacks = +type theory_callbacks = { mutable delete_theory : unit -> unit; mutable reduce_eq : ast -> ast -> ast option; @@ -3318,8 +3243,7 @@ type theory_callbacks = mutable new_assignment: ast -> bool -> unit; mutable new_relevant : ast -> unit; } - -let mk_theory_callbacks() = +let mk_theory_callbacks() = { delete_theory = (fun () -> ()); reduce_eq = (fun _ _ -> None); @@ -3338,8 +3262,6 @@ let mk_theory_callbacks() = new_assignment = (fun _ _ -> ()); new_relevant = (fun _ -> ()); } - - external get_theory_callbacks : theory -> theory_callbacks = "get_theory_callbacks" external mk_theory_register : context -> string -> theory_callbacks -> theory = "mk_theory_register" external set_delete_callback_register : theory -> unit = "set_delete_callback_register" @@ -3358,146 +3280,116 @@ external set_new_eq_callback_register : theory -> unit = "set_new_eq_callback_re external set_new_diseq_callback_register : theory -> unit = "set_new_diseq_callback_register" external set_new_assignment_callback_register : theory -> unit = "set_new_assignment_callback_register" external set_new_relevant_callback_register : theory -> unit = "set_new_relevant_callback_register" - -let is_some opt = +let is_some opt = match opt with | Some v -> true - | None -> false - -let get_some opt = + | None -> false +let get_some opt = match opt with | Some v -> v - | None -> failwith "None unexpected" - - - - + | None -> failwith "None unexpected" let apply_delete (th:theory_callbacks) = th.delete_theory () -let set_delete_callback th cb = +let set_delete_callback th cb = let cbs = get_theory_callbacks th in cbs.delete_theory <- cb; set_delete_callback_register th - -let mk_theory context name = +let mk_theory context name = Callback.register "is_some" is_some; Callback.register "get_some" get_some; Callback.register "apply_delete" apply_delete; let cbs = mk_theory_callbacks() in mk_theory_register context name cbs - - let apply_reduce_app (th:theory_callbacks) f args = th.reduce_app f args -let set_reduce_app_callback th cb = +let set_reduce_app_callback th cb = Callback.register "apply_reduce_app" apply_reduce_app; let cbs = get_theory_callbacks th in cbs.reduce_app <- cb; set_reduce_app_callback_register th - let apply_reduce_eq (th:theory_callbacks) a b = th.reduce_eq a b -let set_reduce_eq_callback th cb = +let set_reduce_eq_callback th cb = Callback.register "apply_reduce_eq" apply_reduce_eq; let cbs = get_theory_callbacks th in cbs.reduce_eq <- cb; set_reduce_eq_callback_register th - let apply_reduce_distinct (th:theory_callbacks) args = th.reduce_distinct args -let set_reduce_distinct_callback th cb = +let set_reduce_distinct_callback th cb = Callback.register "apply_reduce_distinct" apply_reduce_distinct; let cbs = get_theory_callbacks th in cbs.reduce_distinct <- cb; set_reduce_distinct_callback_register th - - let apply_new_app (th:theory_callbacks) a = th.new_app a -let set_new_app_callback th cb = +let set_new_app_callback th cb = Callback.register "apply_new_app" apply_new_app; let cbs = get_theory_callbacks th in cbs.new_app <- cb; set_new_app_callback_register th - let apply_new_elem (th:theory_callbacks) a = th.new_elem a -let set_new_elem_callback th cb = +let set_new_elem_callback th cb = Callback.register "apply_new_elem" apply_new_elem; let cbs = get_theory_callbacks th in cbs.new_elem <- cb; set_new_elem_callback_register th - - let apply_init_search (th:theory_callbacks) = th.init_search() -let set_init_search_callback th cb = +let set_init_search_callback th cb = Callback.register "apply_init_search" apply_init_search; let cbs = get_theory_callbacks th in cbs.init_search <- cb; set_init_search_callback_register th - - let apply_push (th:theory_callbacks) = th.push() -let set_push_callback th cb = +let set_push_callback th cb = Callback.register "apply_push" apply_push; let cbs = get_theory_callbacks th in cbs.push <- cb; set_push_callback_register th - let apply_pop (th:theory_callbacks) = th.pop() -let set_pop_callback th cb = +let set_pop_callback th cb = Callback.register "apply_pop" apply_pop; let cbs = get_theory_callbacks th in cbs.pop <- cb; set_pop_callback_register th - - let apply_restart (th:theory_callbacks) = th.restart() -let set_restart_callback th cb = +let set_restart_callback th cb = Callback.register "apply_restart" apply_restart; let cbs = get_theory_callbacks th in cbs.restart <- cb; set_restart_callback_register th - - let apply_reset (th:theory_callbacks) = th.reset() -let set_reset_callback th cb = +let set_reset_callback th cb = Callback.register "apply_reset" apply_reset; let cbs = get_theory_callbacks th in cbs.reset <- cb; set_reset_callback_register th - let apply_final_check (th:theory_callbacks) = th.final_check() -let set_final_check_callback th cb = +let set_final_check_callback th cb = Callback.register "apply_final_check" apply_final_check; let cbs = get_theory_callbacks th in cbs.final_check <- cb; set_final_check_callback_register th - let apply_new_eq (th:theory_callbacks) a b = th.new_eq a b -let set_new_eq_callback th cb = +let set_new_eq_callback th cb = Callback.register "apply_new_eq" apply_new_eq; let cbs = get_theory_callbacks th in cbs.new_eq <- cb; set_new_eq_callback_register th - - let apply_new_diseq (th:theory_callbacks) a b = th.new_diseq a b -let set_new_diseq_callback th cb = +let set_new_diseq_callback th cb = Callback.register "apply_new_diseq" apply_new_diseq; let cbs = get_theory_callbacks th in cbs.new_diseq <- cb; set_new_diseq_callback_register th - let apply_new_assignment (th:theory_callbacks) a b = th.new_assignment a b -let set_new_assignment_callback th cb = +let set_new_assignment_callback th cb = Callback.register "apply_new_assignment" apply_new_assignment; let cbs = get_theory_callbacks th in cbs.new_assignment <- cb; set_new_assignment_callback_register th - let apply_new_relevant (th:theory_callbacks) a = th.new_relevant a -let set_new_relevant_callback th cb = +let set_new_relevant_callback th cb = Callback.register "apply_new_relevant" apply_new_relevant; let cbs = get_theory_callbacks th in cbs.new_relevant <- cb; set_new_relevant_callback_register th - end diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index b0935f03c..4dd3d5b14 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -268,24 +268,17 @@ and goal_prec = (** - - *) (** {2 {L Types}} - - - Most of the types in the API are abstract. - - + Most of the types in the API are abstract. - [context]: manager of all other Z3 objects, global configuration options, etc. - - [symbol]: Lisp-like symbol used to name types, constants, and functions. A symbol can be created using string or integers. + - [symbol]: Lisp-like symbol used to name types, constants, and functions. A symbol can be created using string or integers. - [ast]: abstract syntax tree node. That is, the data-structure used in Z3 to represent terms, formulas and types. - [sort]: kind of AST used to represent types. - [func_decl]: kind of AST used to represent function symbols. - [app]: kind of AST used to represent function applications. - [pattern]: kind of AST used to represent pattern and multi-patterns used to guide quantifier instantiation. - - [params]: parameter set used to configure many components such as: simplifiers, tactics, solvers, etc. - [model]: model for the constraints asserted into the logical context. - [func_interp]: interpretation of a function in a model. @@ -301,23 +294,21 @@ and goal_prec = - [stats]: statistical data for a solver. *) (** - {!lbool} + {!lbool} Lifted Boolean type: [false], [undefined], [true]. *) (** - {!symbol_kind} + {!symbol_kind} The different kinds of symbol. In Z3, a symbol can be represented using integers and strings (See {!get_symbol_kind}). - - {b See also}: {!mk_int_symbol} - {b See also}: {!mk_string_symbol} *) (** - {!parameter_kind} + {!parameter_kind} The different kinds of parameters that can be associated with function symbols. - {b See also}: {!get_decl_num_parameters} - {b See also}: {!get_decl_parameter_kind} - - PARAMETER_INT is used for integer parameters. - PARAMETER_DOUBLE is used for double parameters. - PARAMETER_RATIONAL is used for parameters that are rational numbers. @@ -327,229 +318,131 @@ and goal_prec = - PARAMETER_FUNC_DECL is used for function declaration parameters. *) (** - {!sort_kind} + {!sort_kind} The different kinds of Z3 types (See {!get_sort_kind}). *) (** - {!ast_kind} + {!ast_kind} The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types. - - - APP_AST: constant and applications - - NUMERAL_AST: numeral constants - - VAR_AST: bound variables - - QUANTIFIER_AST: quantifiers - - SORT_AST: sort - - FUNC_DECL_AST: function declaration - - UNKNOWN_AST: internal + - APP_AST: constant and applications + - NUMERAL_AST: numeral constants + - VAR_AST: bound variables + - QUANTIFIER_AST: quantifiers + - SORT_AST: sort + - FUNC_DECL_AST: function declaration + - UNKNOWN_AST: internal *) (** - {!decl_kind} + {!decl_kind} The different kinds of interpreted function kinds. - - OP_TRUE The constant true. - - OP_FALSE The constant false. - - OP_EQ The equality predicate. - - OP_DISTINCT The n-ary distinct predicate (every argument is mutually distinct). - - OP_ITE The ternary if-then-else term. - - OP_AND n-ary conjunction. - - OP_OR n-ary disjunction. - - OP_IFF equivalence (binary). - - OP_XOR Exclusive or. - - OP_NOT Negation. - - OP_IMPLIES Implication. - - OP_OEQ Binary equivalence modulo namings. This binary predicate is used in proof terms. It captures equisatisfiability and equivalence modulo renamings. - - OP_ANUM Arithmetic numeral. - - OP_AGNUM Arithmetic algebraic numeral. Algebraic numbers are used to represent irrational numbers in Z3. - - OP_LE <=. - - OP_GE >=. - - OP_LT <. - - OP_GT >. - - OP_ADD Addition - Binary. - - OP_SUB Binary subtraction. - - OP_UMINUS Unary minus. - - OP_MUL Multiplication - Binary. - - OP_DIV Division - Binary. - - OP_IDIV Integer division - Binary. - - OP_REM Remainder - Binary. - - OP_MOD Modulus - Binary. - - OP_TO_REAL Coercion of integer to real - Unary. - - OP_TO_INT Coercion of real to integer - Unary. - - OP_IS_INT Check if real is also an integer - Unary. - - OP_POWER Power operator x^y. - - OP_STORE 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. - - - OP_SELECT Array select. - + Array store takes at least 3 arguments. + - OP_SELECT Array select. - OP_CONST_ARRAY The constant array. For example, select(const(v),i) = v holds for every v and i. The function is unary. - - OP_ARRAY_DEFAULT Default value of arrays. For example default(const(v)) = v. The function is unary. - - OP_ARRAY_MAP Array map operator. It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i. - - OP_SET_UNION Set union between two Booelan arrays (two arrays whose range type is Boolean). The function is binary. - - OP_SET_INTERSECT Set intersection between two Boolean arrays. The function is binary. - - OP_SET_DIFFERENCE Set difference between two Boolean arrays. The function is binary. - - OP_SET_COMPLEMENT Set complement of a Boolean array. The function is unary. - - OP_SET_SUBSET Subset predicate between two Boolean arrays. The relation is binary. - - OP_AS_ARRAY An array value that behaves as the function graph of the function passed as parameter. - - OP_BNUM Bit-vector numeral. - - OP_BIT1 One bit bit-vector. - - OP_BIT0 Zero bit bit-vector. - - OP_BNEG Unary minus. - - OP_BADD Binary addition. - - OP_BSUB Binary subtraction. - - OP_BMUL Binary multiplication. - - OP_BSDIV Binary signed division. - - OP_BUDIV Binary unsigned int division. - - OP_BSREM Binary signed remainder. - - OP_BUREM Binary unsigned int remainder. - - OP_BSMOD Binary signed modulus. - - OP_BSDIV0 Unary function. bsdiv(x,0) is congruent to bsdiv0(x). - - OP_BUDIV0 Unary function. budiv(x,0) is congruent to budiv0(x). - - OP_BSREM0 Unary function. bsrem(x,0) is congruent to bsrem0(x). - - OP_BUREM0 Unary function. burem(x,0) is congruent to burem0(x). - - OP_BSMOD0 Unary function. bsmod(x,0) is congruent to bsmod0(x). - - OP_ULEQ Unsigned bit-vector <= - Binary relation. - - - OP_SLEQ Signed bit-vector <= - Binary relation. - - - OP_UGEQ Unsigned bit-vector >= - Binary relation. - - - OP_SGEQ Signed bit-vector >= - Binary relation. - - - OP_ULT Unsigned bit-vector < - Binary relation. - + - OP_SLEQ Signed bit-vector <= - Binary relation. + - OP_UGEQ Unsigned bit-vector >= - Binary relation. + - OP_SGEQ Signed bit-vector >= - Binary relation. + - OP_ULT Unsigned bit-vector < - Binary relation. - OP_SLT Signed bit-vector < - Binary relation. - - OP_UGT Unsigned bit-vector > - Binary relation. - - OP_SGT Signed bit-vector > - Binary relation. - - OP_BAND Bit-wise and - Binary. - - OP_BOR Bit-wise or - Binary. - - OP_BNOT Bit-wise not - Unary. - - OP_BXOR Bit-wise xor - Binary. - - OP_BNAND Bit-wise nand - Binary. - - OP_BNOR Bit-wise nor - Binary. - - OP_BXNOR Bit-wise xnor - Binary. - - OP_CONCAT Bit-vector concatenation - Binary. - - OP_SIGN_EXT Bit-vector sign extension. - - OP_ZERO_EXT Bit-vector zero extension. - - OP_EXTRACT Bit-vector extraction. - - OP_REPEAT Repeat bit-vector n times. - - OP_BREDOR Bit-vector reduce or - Unary. - - OP_BREDAND Bit-vector reduce and - Unary. - - OP_BCOMP . - - OP_BSHL Shift left. - - OP_BLSHR Logical shift right. - - OP_BASHR Arithmetical shift right. - - OP_ROTATE_LEFT Left rotation. - - OP_ROTATE_RIGHT Right rotation. - - OP_EXT_ROTATE_LEFT (extended) Left rotation. Similar to OP_ROTATE_LEFT, but it is a binary operator instead of a parametric one. - - OP_EXT_ROTATE_RIGHT (extended) Right rotation. Similar to OP_ROTATE_RIGHT, but it is a binary operator instead of a parametric one. - - OP_INT2BV Coerce integer to bit-vector. NB. This function is not supported by the decision procedures. Only the most rudimentary simplification rules are applied to this function. - - OP_BV2INT Coerce bit-vector to integer. NB. This function is not supported by the decision procedures. Only the most rudimentary simplification rules are applied to this function. - - - OP_CARRY Compute the carry bit in a full-adder. + - OP_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))) - - OP_XOR3 Compute ternary XOR. The meaning is given by the equivalence (xor3 l1 l2 l3) <=> (xor (xor l1 l2) l3) - - OP_PR_UNDEF: Undef/Null proof object. - - OP_PR_TRUE: Proof for the expression 'true'. - - OP_PR_ASSERTED: Proof for a fact asserted by the user. - - OP_PR_GOAL: Proof for a fact (tagged as goal) asserted by the user. - - OP_PR_MODUS_PONENS: Given a proof for p and a proof for (implies p q), produces a proof for q. {e T1: p @@ -557,19 +450,16 @@ and goal_prec = [mp T1 T2]: q } The second antecedents may also be a proof for (iff p q). - - OP_PR_REFLEXIVITY: 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 + The only reflexive relations that are used are equivalence modulo namings, equality and equivalence. That is, R is either '~', '=' or 'iff'. - - OP_PR_SYMMETRY: Given an symmetric relation R and a proof for (R t s), produces a proof for (R s t). {e T1: (R t s) [symmetry T1]: (R s t) } T1 is the antecedent of this proof object. - - OP_PR_TRANSITIVITY: Given a transitive relation R, and proofs for (R t s) and (R s u), produces a proof for (R t u). {e @@ -577,10 +467,8 @@ and goal_prec = T2: (R s u) [trans T1 T2]: (R t u) } - - OP_PR_TRANSITIVITY_STAR: Condensed transitivity proof. This proof object is only used if the parameter PROOF_MODE is 1. - It combines several symmetry and transitivity proofs. - + It combines several symmetry and transitivity proofs. Example: {e T1: (R a b) @@ -589,13 +477,11 @@ and goal_prec = [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, + 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. - - OP_PR_MONOTONICITY: Monotonicity proof object. {e T1: (R t_1 s_1) @@ -605,58 +491,42 @@ and goal_prec = } Remark: if t_i == s_i, then the antecedent Ti is suppressed. That is, reflexivity proofs are supressed to save space. - - OP_PR_QUANT_INTRO: 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)) - - - OP_PR_DISTRIBUTIVITY: Distributivity proof object. + - OP_PR_DISTRIBUTIVITY: 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 + Remark. This rule is used by the CNF conversion pass and instantiated by f = or, and g = and. - - OP_PR_AND_ELIM: Given a proof for (and l_1 ... l_n), produces a proof for l_i - {e T1: (and l_1 ... l_n) [and-elim T1]: l_i } - OP_PR_NOT_OR_ELIM: Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). - {e T1: (not (or l_1 ... l_n)) [not-or-elim T1]: (not l_i) } - - OP_PR_REWRITE: 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), + 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: {e (= (+ x 0) x) (= (+ x 1 2) (+ 3 x)) (iff (or x false) x) } - - OP_PR_REWRITE_STAR: 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. @@ -666,44 +536,31 @@ and goal_prec = - 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) - - OP_PR_PULL_QUANT: A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. - - OP_PR_PULL_QUANT_STAR: 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 is only used if the parameter PROOF_MODE is 1. This proof object has no antecedents. - - OP_PR_PUSH_QUANT: A proof for: - {e (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. - - - OP_PR_ELIM_UNUSED_VARS: + - OP_PR_ELIM_UNUSED_VARS: 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])) - + (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. - - OP_PR_DER: 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. - - OP_PR_QUANT_INST: A proof of (or (not (forall (x) (P x))) (P a)) - - OP_PR_HYPOTHESIS: Mark a hypothesis in a natural deduction style proof. - - - OP_PR_LEMMA: - + - OP_PR_LEMMA: {e T1: false [lemma T1]: (or (not l_1) ... (not l_n)) @@ -711,22 +568,19 @@ and goal_prec = 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. - - - OP_PR_UNIT_RESOLUTION: + - OP_PR_UNIT_RESOLUTION: {e - T1: (or l_1 ... l_n l_1' ... l_m') - T2: (not l_1) + T1: (or l_1 ... l_n l_1' ... l_m') + T2: (not l_1) ... - T(n+1): (not l_n) + T(n+1): (not l_n) [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m') } - - - OP_PR_IFF_TRUE: + - OP_PR_IFF_TRUE: {e T1: p [iff-true T1]: (iff p true) } - - OP_PR_IFF_FALSE: {e T1: (not p) @@ -736,14 +590,14 @@ and goal_prec = - OP_PR_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. - + - OP_PR_DEF_AXIOM: Proof object used to justify Tseitin's like axioms: - + {e (or (not (and p q)) p) (or (not (and p q)) q) @@ -772,7 +626,7 @@ and goal_prec = You can recover the propositional tautologies by unfolding the Boolean connectives in the axioms a small bounded number of steps (=3). - + - OP_PR_DEF_INTRO: 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: @@ -788,17 +642,17 @@ and goal_prec = [def-intro]: (and (or (not cond) (= n th)) (or cond (= n el))) Otherwise: - [def-intro]: (= n e) + [def-intro]: (= n e) - - OP_PR_APPLY_DEF: + - OP_PR_APPLY_DEF: [apply-def T1]: F ~ n F is 'equivalent' to n, given that T1 is a proof that n is a name for F. - + - OP_PR_IFF_OEQ: T1: (iff p q) [iff~ T1]: (~ p q) - + - OP_PR_NNF_POS: Proof for a (positive) NNF step. Example: {e T1: (not s_1) ~ r_1 @@ -813,7 +667,7 @@ and goal_prec = The quantifier is retained (unless the bound variables are eliminated). Example {e - T1: q ~ q_new + 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 @@ -822,7 +676,7 @@ and goal_prec = NNF_NEG furthermore handles the case where negation is pushed over Boolean connectives 'and' and 'or'. - + - OP_PR_NFF_NEG: Proof for a (negative) NNF step. Examples: {e T1: (not s_1) ~ r_1 @@ -843,24 +697,24 @@ and goal_prec = (and (or r_1 r_2) (or r_1' r_2'))) } - OP_PR_NNF_STAR: 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 is only used if the parameter PROOF_MODE is 1. + This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - OP_PR_CNF_STAR: 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. + 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. + + - OP_PR_SKOLEMIZE: Proof for: - - OP_PR_SKOLEMIZE: Proof for: - {e [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. - + - OP_PR_MODUS_PONENS_OEQ: Modus ponens style rule for equi-satisfiability. {e T1: p @@ -873,9 +727,9 @@ and goal_prec = 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. + 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. @@ -906,7 +760,7 @@ and goal_prec = {e (=> (and ln+1 ln+2 .. ln+m) (or l0 l1 .. ln-1)) } - In other words we use the following (Prolog style) convention for Horn + In other words we use the following (Prolog style) convention for Horn implications: The head of a Horn implication is position 0, the first conjunct in the body of an implication is position 1 @@ -929,16 +783,16 @@ and goal_prec = - OP_RA_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 + 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. - - OP_RA_EMPTY: Creates the empty relation. - + - OP_RA_EMPTY: Creates the empty relation. + - OP_RA_IS_EMPTY: Tests if the relation is empty. - OP_RA_JOIN: Create the relational join. - - OP_RA_UNION: Create the union or convex hull of two relations. + - OP_RA_UNION: Create the union or convex hull of two relations. The function takes two arguments. - OP_RA_WIDEN: Widen two relations. @@ -948,7 +802,7 @@ and goal_prec = The function takes one argument. - OP_RA_FILTER: Filter (restrict) a relation with respect to a predicate. - The first argument is a relation. + 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. @@ -963,23 +817,23 @@ and goal_prec = 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. - - - OP_RA_RENAME: rename columns in the relation. + + - OP_RA_RENAME: rename columns in the relation. The function takes one argument. The parameters contain the renaming as a cycle. - + - OP_RA_COMPLEMENT: Complement the relation. - OP_RA_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. - - OP_RA_CLONE: Create a fresh copy (clone) of a relation. + - OP_RA_CLONE: Create a fresh copy (clone) of a relation. The function is logically the identity, but in the context of a register machine allows - for [OP_RA_UNION] + for [OP_RA_UNION] to perform destructive updates to the first argument. - + - OP_FD_LT: A less than predicate over the finite domain FINITE_DOMAIN_SORT. @@ -999,10 +853,10 @@ and goal_prec = - OP_UNINTERPRETED: kind used for uninterpreted symbols. *) (** - {!param_kind} + {!param_kind} The different kinds of parameters that can be associated with parameter sets. - (see {!mk_params}). + (see {!mk_params}). - PK_UINT integer parameters. - PK_BOOL boolean parameters. @@ -1013,140 +867,113 @@ and goal_prec = - PK_INVALID invalid parameter. *) (** - {!search_failure} + {!search_failure} The different kinds of search failure types. - - NO_FAILURE: The last search was successful - - UNKNOWN: Undocumented failure reason - - TIMEOUT: Timeout - - MEMOUT_WATERMAK: Search hit a memory high-watermak limit - - CANCELED: External cancel flag was set - - NUM_CONFLICTS: Maximum number of conflicts was reached - - THEORY: Theory is incomplete - - QUANTIFIERS: Logical context contains universal quantifiers + - NO_FAILURE: The last search was successful + - UNKNOWN: Undocumented failure reason + - TIMEOUT: Timeout + - MEMOUT_WATERMAK: Search hit a memory high-watermak limit + - CANCELED: External cancel flag was set + - NUM_CONFLICTS: Maximum number of conflicts was reached + - THEORY: Theory is incomplete + - QUANTIFIERS: Logical context contains universal quantifiers *) (** - {!ast_print_mode} + {!ast_print_mode} Z3 pretty printing modes (See {!set_ast_print_mode}). - - PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format. - - PRINT_LOW_LEVEL: Print AST nodes using a low-level format. + - PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format. + - PRINT_LOW_LEVEL: Print AST nodes using a low-level format. - PRINT_SMTLIB_COMPLIANT: Print AST nodes in SMTLIB 1.x compliant format. - PRINT_SMTLIB2_COMPLIANT: Print AST nodes in SMTLIB 2.x compliant format. *) (** - {!error_code} - Z3 error codes - - - OK: No error. - - SORT_ERROR: User tried to build an invalid (type incorrect) AST. - - IOB: Index out of bounds. - - INVALID_ARG: Invalid argument was provided. - - PARSER_ERROR: An error occurred when parsing a string or file. - - NO_PARSER: Parser output is not available, that is, user didn't invoke {!parse_smtlib_string} or {!parse_smtlib_file}. + {!error_code} + Z3 error codes + + - OK: No error. + - SORT_ERROR: User tried to build an invalid (type incorrect) AST. + - IOB: Index out of bounds. + - INVALID_ARG: Invalid argument was provided. + - PARSER_ERROR: An error occurred when parsing a string or file. + - NO_PARSER: Parser output is not available, that is, user didn't invoke {!parse_smtlib_string} or {!parse_smtlib_file}. - INVALID_PATTERN: Invalid pattern was used to build a quantifier. - - MEMOUT_FAIL: A memory allocation failure was encountered. + - MEMOUT_FAIL: A memory allocation failure was encountered. - FILE_ACCESS_ERRROR: A file could not be accessed. - - INVALID_USAGE: API call is invalid in the current state. + - INVALID_USAGE: API call is invalid in the current state. - INTERNAL_FATAL: An error internal to Z3 occurred. - DEC_REF_ERROR: Trying to decrement the reference counter of an AST that was deleted or the reference counter was not initialized. - - EXCEPTION: Internal Z3 exception. Additional details can be retrieved using {!get_error_msg}. + - EXCEPTION: Internal Z3 exception. Additional details can be retrieved using {!get_error_msg}. *) (** Definitions for update_api.py - - def_Type('CONFIG', 'config', 'Config') - def_Type('CONTEXT', 'context', 'ContextObj') - def_Type('AST', 'ast', 'Ast') - def_Type('APP', 'app', 'Ast') - def_Type('SORT', 'sort', 'Sort') - def_Type('FUNC_DECL', 'func_decl', 'FuncDecl') - def_Type('PATTERN', 'pattern', 'Pattern') - def_Type('MODEL', 'model', 'Model') - def_Type('LITERALS', 'literals', 'Literals') - def_Type('CONSTRUCTOR', 'constructor', 'Constructor') + + def_Type('CONFIG', 'config', 'Config') + def_Type('CONTEXT', 'context', 'ContextObj') + def_Type('AST', 'ast', 'Ast') + def_Type('APP', 'app', 'Ast') + def_Type('SORT', 'sort', 'Sort') + def_Type('FUNC_DECL', 'func_decl', 'FuncDecl') + def_Type('PATTERN', 'pattern', 'Pattern') + def_Type('MODEL', 'model', 'Model') + def_Type('LITERALS', 'literals', 'Literals') + def_Type('CONSTRUCTOR', 'constructor', 'Constructor') def_Type('CONSTRUCTOR_LIST', 'constructor_list', 'ConstructorList') - def_Type('THEORY', 'theory', 'ctypes.c_void_p') - def_Type('THEORY_DATA', 'theory_data', 'ctypes.c_void_p') - def_Type('SOLVER', 'solver', 'SolverObj') - def_Type('GOAL', 'goal', 'GoalObj') - def_Type('TACTIC', 'tactic', 'TacticObj') - def_Type('PARAMS', 'params', 'Params') - def_Type('PROBE', 'probe', 'ProbeObj') - def_Type('STATS', 'stats', 'StatsObj') - def_Type('AST_VECTOR', 'ast_vector', 'AstVectorObj') - def_Type('AST_MAP', 'ast_map', 'AstMapObj') - def_Type('APPLY_RESULT', 'apply_result', 'ApplyResultObj') - def_Type('FUNC_INTERP', 'func_interp', 'FuncInterpObj') - def_Type('FUNC_ENTRY', 'func_entry', 'FuncEntryObj') - def_Type('FIXEDPOINT', 'fixedpoint', 'FixedpointObj') - def_Type('PARAM_DESCRS', 'param_descrs', 'ParamDescrs') + def_Type('THEORY', 'theory', 'ctypes.c_void_p') + def_Type('THEORY_DATA', 'theory_data', 'ctypes.c_void_p') + def_Type('SOLVER', 'solver', 'SolverObj') + def_Type('GOAL', 'goal', 'GoalObj') + def_Type('TACTIC', 'tactic', 'TacticObj') + def_Type('PARAMS', 'params', 'Params') + def_Type('PROBE', 'probe', 'ProbeObj') + def_Type('STATS', 'stats', 'StatsObj') + def_Type('AST_VECTOR', 'ast_vector', 'AstVectorObj') + def_Type('AST_MAP', 'ast_map', 'AstMapObj') + def_Type('APPLY_RESULT', 'apply_result', 'ApplyResultObj') + def_Type('FUNC_INTERP', 'func_interp', 'FuncInterpObj') + def_Type('FUNC_ENTRY', 'func_entry', 'FuncEntryObj') + def_Type('FIXEDPOINT', 'fixedpoint', 'FixedpointObj') + def_Type('PARAM_DESCRS', 'param_descrs', 'ParamDescrs') *) (** Exceptions raised by Z3. It is safe to continue interacting with Z3 after catching [Error] exceptions. - - {b See also}: {!get_error_msg} *) exception Error of context * error_code (** - {!goal_prec} + {!goal_prec} A Goal is essentially a set of formulas. Z3 provide APIs for building strategies/tactics for solving and transforming Goals. Some of these transformations apply under/over approximations. - - - GOAL_PRECISE: Approximations/Relaxations were not applied on the goal (sat and unsat answers were preserved). - - GOAL_UNDER: Goal is the product of a under-approximation (sat answers are preserved). - - GOAL_OVER: Goal is the product of an over-approximation (unsat answers are preserved). + - GOAL_PRECISE: Approximations/Relaxations were not applied on the goal (sat and unsat answers were preserved). + - GOAL_UNDER: Goal is the product of a under-approximation (sat answers are preserved). + - GOAL_OVER: Goal is the product of an over-approximation (unsat answers are preserved). - GOAL_UNDER_OVER: Goal is garbage (it is the product of over- and under-approximations, sat and unsat answers are not preserved). *) (** {2 {L Create context}} *) (** - Summary: Create a context using the given configuration. - + Summary: Create a context using the given configuration. After a context is created, the configuration cannot be changed, although some parameters can be changed using {!update_param_value}. All main interaction with Z3 happens in the context of a [context]. - - - - - def_API('mk_context', CONTEXT, (_in(CONFIG),)) *) external mk_context: (string * string) list -> context = "caml_z3_mk_context" (** - Summary: Update a mutable configuration parameter. - - The list of all configuration parameters can be obtained using the Z3 executable: - - {v - z3.exe -ini? - v} - - Only a few configuration parameters are mutable once the context is created. - The error handler is invoked when trying to modify an immutable parameter. - - - - {b See also}: {!mk_context } - + Summary: Set a value of a context parameter. + - {b See also}: {!global_param_set} def_API('update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) *) external update_param_value : context -> string -> string -> unit = "camlidl_z3_Z3_update_param_value" (** - Summary: Get a configuration parameter. - - Returns [None] - if the parameter value does not exist. - - - - - {b See also}: {!mk_context } - + Summary: Return the value of a context parameter. + - {b See also}: {!global_param_get} def_API('get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) *) external get_param_value : context -> string -> string option @@ -1155,7 +982,6 @@ external get_param_value : context -> string -> string option (** Summary: Interrupt the execution of a Z3 procedure. This procedure can be used to interrupt: solvers, simplifiers and tactics. - def_API('interrupt', VOID, (_in(CONTEXT),)) *) external interrupt : context -> unit @@ -1168,10 +994,6 @@ external interrupt : context -> unit Summary: Create a Z3 (empty) parameter set. Starting at Z3 4.0, parameter sets are used to configure many components such as: simplifiers, tactics, solvers, etc. - - - - def_API('mk_params', PARAMS, (_in(CONTEXT),)) *) external mk_params : context -> params @@ -1179,7 +1001,6 @@ external mk_params : context -> params (** Summary: Add a Boolean parameter [k] with value [v] to the parameter set [p]. - def_API('params_set_bool', VOID, (_in(CONTEXT), _in(PARAMS), _in(SYMBOL), _in(BOOL))) *) external params_set_bool : context -> params -> symbol -> bool -> unit @@ -1187,7 +1008,6 @@ external params_set_bool : context -> params -> symbol -> bool -> unit (** Summary: Add a unsigned int parameter [k] with value [v] to the parameter set [p]. - def_API('params_set_uint', VOID, (_in(CONTEXT), _in(PARAMS), _in(SYMBOL), _in(UINT))) *) external params_set_uint : context -> params -> symbol -> int -> unit @@ -1195,7 +1015,6 @@ external params_set_uint : context -> params -> symbol -> int -> unit (** Summary: Add a double parameter [k] with value [v] to the parameter set [p]. - def_API('params_set_double', VOID, (_in(CONTEXT), _in(PARAMS), _in(SYMBOL), _in(DOUBLE))) *) external params_set_double : context -> params -> symbol -> float -> unit @@ -1203,7 +1022,6 @@ external params_set_double : context -> params -> symbol -> float -> unit (** Summary: Add a symbol parameter [k] with value [v] to the parameter set [p]. - def_API('params_set_symbol', VOID, (_in(CONTEXT), _in(PARAMS), _in(SYMBOL), _in(SYMBOL))) *) external params_set_symbol : context -> params -> symbol -> symbol -> unit @@ -1212,7 +1030,6 @@ external params_set_symbol : context -> params -> symbol -> symbol -> unit (** Summary: Convert a parameter set into a string. This function is mainly used for printing the contents of a parameter set. - def_API('params_to_string', STRING, (_in(CONTEXT), _in(PARAMS))) *) external params_to_string : context -> params -> string @@ -1220,9 +1037,7 @@ external params_to_string : context -> params -> string (** Summary: Validate the parameter set [p] against the parameter description set [d]. - The procedure invokes the error handler if [p] is invalid. - def_API('params_validate', VOID, (_in(CONTEXT), _in(PARAMS), _in(PARAM_DESCRS))) *) external params_validate : context -> params -> param_descrs -> unit @@ -1233,7 +1048,6 @@ external params_validate : context -> params -> param_descrs -> unit *) (** Summary: Return the kind associated with the given parameter name [n]. - def_API('param_descrs_get_kind', UINT, (_in(CONTEXT), _in(PARAM_DESCRS), _in(SYMBOL))) *) external param_descrs_get_kind : context -> param_descrs -> symbol -> param_kind @@ -1241,7 +1055,6 @@ external param_descrs_get_kind : context -> param_descrs -> symbol -> param_kind (** Summary: Return the number of parameters in the given parameter description set. - def_API('param_descrs_size', UINT, (_in(CONTEXT), _in(PARAM_DESCRS))) *) external param_descrs_size : context -> param_descrs -> int @@ -1249,9 +1062,7 @@ external param_descrs_size : context -> param_descrs -> int (** Summary: Return the number of parameters in the given parameter description set. - - {b Precondition}: i < param_descrs_size c p - def_API('param_descrs_get_name', SYMBOL, (_in(CONTEXT), _in(PARAM_DESCRS), _in(UINT))) *) external param_descrs_get_name : context -> param_descrs -> int -> symbol @@ -1260,7 +1071,6 @@ external param_descrs_get_name : context -> param_descrs -> int -> symbol (** Summary: Convert a parameter description set into a string. This function is mainly used for printing the contents of a parameter description set. - def_API('param_descrs_to_string', STRING, (_in(CONTEXT), _in(PARAM_DESCRS))) *) external param_descrs_to_string : context -> param_descrs -> string @@ -1272,7 +1082,6 @@ external param_descrs_to_string : context -> param_descrs -> string (** Refined view of a {!symbol}. - - {b See also}: {!mk_symbol} - {b See also}: {!symbol_refine} *) @@ -1283,24 +1092,19 @@ type symbol_refined = (** Summary: \[ [ mk_symbol c sr ] \] constructs the symbol described by [sr]. - - {b See also}: {!symbol_refine} *) val mk_symbol: context -> symbol_refined -> symbol (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Create a Z3 symbol using an integer. - Symbols are used to name several term and type constructors. - NB. Not all integers can be passed to this function. The legal range of unsigned int integers is 0 to 2^30-1. - - {b See also}: {!mk_string_symbol} - def_API('mk_int_symbol', SYMBOL, (_in(CONTEXT), _in(INT))) *) external mk_int_symbol : context -> int -> symbol @@ -1308,11 +1112,8 @@ external mk_int_symbol : context -> int -> symbol (** Summary: Create a Z3 symbol using a C string. - Symbols are used to name several term and type constructors. - - {b See also}: {!mk_int_symbol} - def_API('mk_string_symbol', SYMBOL, (_in(CONTEXT), _in(STRING))) *) external mk_string_symbol : context -> string -> symbol @@ -1326,33 +1127,28 @@ external mk_string_symbol : context -> string -> symbol A datatype constructor descriptor. *) type datatype_constructor_desc = { - constructor_desc : symbol; (** name of the constructor function *) - recognizer_desc : symbol; (** name of the recognizer function *) - accessor_descs : (symbol * sort) array; (** names and sorts of the fields *) + constructor_desc : symbol; (** name of the constructor function *) + recognizer_desc : symbol; (** name of the recognizer function *) + accessor_descs : (symbol * sort) array; (** names and sorts of the fields *) } - (** A datatype is described by a name and constructor descriptors. *) type datatype_desc = symbol * datatype_constructor_desc array - (** A datatype constructor representation. *) type datatype_constructor = { - constructor : func_decl; (** constructor function *) - recognizer : func_decl; (** recognizer function *) - accessors : func_decl array; (** field accessor functions *) + constructor : func_decl; (** constructor function *) + recognizer : func_decl; (** recognizer function *) + accessors : func_decl array; (** field accessor functions *) } - (** A datatype is represented by a sort and constructors. *) type datatype = sort * datatype_constructor array - (** Refined view of a {!sort}. - - {b See also}: {!mk_sort} - {b See also}: {!sort_refine} *) @@ -1371,40 +1167,33 @@ type sort_refined = (** Summary: \[ [ mk_sort c sr ] \] constructs the sort described by [sr]. - - {b Precondition}: [sr] is not of form [Sort_relation] or [Sort_unknown], which cannot be directly constructed - {b See also}: {!mk_datatypes} - {b See also}: {!sort_refine} *) val mk_sort: context -> sort_refined -> sort - (** \[ [mk_datatypes ctx sorts_to_descriptors] \] creates mutually recursive datatypes described by [sorts_to_descriptors], which is a function from the sorts of the datatypes to be created to descriptors of the datatypes' constructors. - - {b See also}: {!Test_mlapi.forest_example} *) val mk_datatypes: context -> (sort array -> (datatype_desc array) option) -> datatype array (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Create a free (uninterpreted) type using the given name (symbol). - Two free types are considered the same iff the have the same name. - def_API('mk_uninterpreted_sort', SORT, (_in(CONTEXT), _in(SYMBOL))) *) external mk_uninterpreted_sort : context -> symbol -> sort = "camlidl_z3_Z3_mk_uninterpreted_sort" (** - Summary: Create the Boolean type. - + Summary: Create the Boolean type. This type is used to create propositional variables and predicates. - def_API('mk_bool_sort', SORT, (_in(CONTEXT), )) *) external mk_bool_sort : context -> sort @@ -1412,24 +1201,19 @@ external mk_bool_sort : context -> sort (** Summary: Create the integer type. - This type is not the int type found in programming languages. A machine integer can be represented using bit-vectors. The function {!mk_bv_sort} creates a bit-vector type. - - {b See also}: {!mk_bv_sort} - def_API('mk_int_sort', SORT, (_in(CONTEXT), )) *) external mk_int_sort : context -> sort = "camlidl_z3_Z3_mk_int_sort" (** - Summary: Create the real type. - + Summary: Create the real type. This type is not a floating point number. Z3 does not have support for floating point numbers yet. - def_API('mk_real_sort', SORT, (_in(CONTEXT), )) *) external mk_real_sort : context -> sort @@ -1437,11 +1221,8 @@ external mk_real_sort : context -> sort (** Summary: Create a bit-vector type of the given size. - This type can also be seen as a machine integer. - - {b Remarks}: The size of the bitvector type must be greater than zero. - def_API('mk_bv_sort', SORT, (_in(CONTEXT), _in(UINT))) *) external mk_bv_sort : context -> int -> sort @@ -1449,27 +1230,21 @@ external mk_bv_sort : context -> int -> sort (** Summary: Create a named finite domain sort. - - To create constants that belong to the finite domain, + To create constants that belong to the finite domain, use the APIs for creating numerals and pass a numeric constant together with the sort returned by this call. - - - {b See also}: {!get_finite_domain_sort_size.} - + - {b See also}: {!get_finite_domain_sort_size} def_API('mk_finite_domain_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT64))) *) external mk_finite_domain_sort : context -> symbol -> int64 -> sort = "camlidl_z3_Z3_mk_finite_domain_sort" (** - Summary: Create an array type. - + Summary: Create an array type. We usually represent the array type as: {e [domain -> range] }. Arrays are usually used to model the heap/memory in software verification. - - {b See also}: {!mk_select} - {b See also}: {!mk_store} - def_API('mk_array_sort', SORT, (_in(CONTEXT), _in(SORT), _in(SORT))) *) external mk_array_sort : context -> sort -> sort -> sort @@ -1477,14 +1252,8 @@ external mk_array_sort : context -> sort -> sort -> sort (** Summary: Create a tuple type. - [mk_tuple_sort c name field_names field_sorts] creates a tuple with a constructor named [name], a [n] fields, where [n] is the size of the arrays [field_names] and [field_sorts]. - - - - - @param c logical context @param mk_tuple_name name of the constructor function associated with the tuple type. @param num_fields number of fields in the tuple type. @@ -1492,7 +1261,6 @@ external mk_array_sort : context -> sort -> sort -> sort @param field_sorts type of the tuple fields. @param mk_tuple_decl output parameter that will contain the constructor declaration. @param proj_decl output parameter that will contain the projection function declarations. This field must be a buffer of size [num_fields] allocated by the user. - def_API('mk_tuple_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _out(FUNC_DECL), _out_array(2, FUNC_DECL))) *) external mk_tuple_sort : context -> symbol -> symbol array -> sort array -> sort * func_decl * func_decl array @@ -1500,28 +1268,20 @@ external mk_tuple_sort : context -> symbol -> symbol array -> sort array -> sort (** Summary: Create a enumeration sort. - - [mk_enumeration_sort c enums] creates an enumeration sort with enumeration names [enums], + [mk_enumeration_sort c enums] creates an enumeration sort with enumeration names [enums], it also returns [n] predicates, where [n] is the number of [enums] corresponding to testing whether an element is one of the enumerants. - - - - - @param c logical context @param name name of the enumeration sort. @param n number of elemenets in enumeration sort. @param enum_names names of the enumerated elements. @param enum_consts constants corresponding to the enumerated elements. @param enum_testers predicates testing if terms of the enumeration sort correspond to an enumeration. - - For example, if this function is called with three symbols A, B, C and the name S, then - [s] is a sort whose name is S, and the function returns three terms corresponding to A, B, C in + For example, if this function is called with three symbols A, B, C and the name S, then + [s] is a sort whose name is S, and the function returns three terms corresponding to A, B, C in [enum_consts]. The array [enum_testers] has three predicates of type {e (s -> Bool) }. The first predicate (corresponding to A) is true when applied to A, and false otherwise. Similarly for the other predicates. - def_API('mk_enumeration_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SYMBOL), _out_array(2, FUNC_DECL), _out_array(2, FUNC_DECL))) *) external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_decl array * func_decl array @@ -1529,13 +1289,7 @@ external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_ (** Summary: Create a list sort - [mk_list_sort c name elem_sort] creates a list sort of [name], over elements of sort [elem_sort]. - - - - - @param c logical context @param name name of the list sort. @param elem_sort sort of list elements. @@ -1545,7 +1299,6 @@ external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_ @param is_cons_decl cons cell test. @param head_decl list head. @param tail_decl list tail. - def_API('mk_list_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(SORT), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL))) *) external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_decl * func_decl * func_decl * func_decl * func_decl @@ -1554,19 +1307,17 @@ external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_dec (* (** Summary: Create a constructor. - @param c logical context. @param name constructor name. @param recognizer name of recognizer function. @param num_fields number of fields in constructor. @param field_names names of the constructor fields. - @param sorts field sorts, [None] + @param sorts field sorts, [None] if the field sort refers to a recursive sort. @param sort_refs reference to datatype sort that is an argument to the constructor; if the corresponding - sort reference is [None], - then the value in sort_refs should be an index referring to - one of the recursive datatypes that is declared. - + sort reference is [None], + then the value in sort_refs should be an index referring to + one of the recursive datatypes that is declared. def_API('mk_constructor', CONSTRUCTOR, (_in(CONTEXT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(3, SYMBOL), _in_array(3, SORT), _in_array(3, UINT))) *) external mk_constructor : context -> symbol -> symbol -> symbol array -> sort option array -> int array -> constructor @@ -1574,24 +1325,20 @@ external mk_constructor : context -> symbol -> symbol -> symbol array -> sort op (** Summary: Reclaim memory allocated to constructor. - @param c logical context. @param constr constructor. - def_API('del_constructor', VOID, (_in(CONTEXT), _in(CONSTRUCTOR))) *) external del_constructor : context -> constructor -> unit = "camlidl_z3_Z3_del_constructor" (** - Summary: Create datatype, such as lists, trees, records, enumerations or unions of records. + Summary: Create datatype, such as lists, trees, records, enumerations or unions of records. The datatype may be recursive. Return the datatype sort. - @param c logical context. - @param name name of datatype. + @param name name of datatype. @param num_constructors number of constructors passed in. @param constructors array of constructor containers. - def_API('mk_datatype', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _inout_array(2, CONSTRUCTOR))) *) external mk_datatype : context -> symbol -> constructor array -> sort * constructor array @@ -1599,11 +1346,9 @@ external mk_datatype : context -> symbol -> constructor array -> sort * construc (** Summary: Create list of constructors. - @param c logical context. @param num_constructors number of constructors in list. @param constructors list of constructors. - def_API('mk_constructor_list', CONSTRUCTOR_LIST, (_in(CONTEXT), _in(UINT), _in_array(1, CONSTRUCTOR))) *) external mk_constructor_list : context -> constructor array -> constructor_list @@ -1611,12 +1356,9 @@ external mk_constructor_list : context -> constructor array -> constructor_list (** Summary: Reclaim memory allocated for constructor list. - Each constructor inside the constructor list must be independently reclaimed using {!del_constructor}. - @param c logical context. @param clist constructor list container. - def_API('del_constructor_list', VOID, (_in(CONTEXT), _in(CONSTRUCTOR_LIST))) *) external del_constructor_list : context -> constructor_list -> unit @@ -1624,28 +1366,24 @@ external del_constructor_list : context -> constructor_list -> unit (** Summary: Create mutually recursive datatypes. - @param c logical context. @param num_sorts number of datatype sorts. @param sort_names names of datatype sorts. - @param sorts array of datattype sorts. + @param sorts array of datatype sorts. @param constructor_lists list of constructors, one list per sort. - def_API('mk_datatypes', VOID, (_in(CONTEXT), _in(UINT), _in_array(1, SYMBOL), _out_array(1, SORT), _inout_array(1, CONSTRUCTOR_LIST))) *) external mk_datatypes : context -> symbol array -> constructor_list array -> sort array * constructor_list array = "camlidl_z3_Z3_mk_datatypes" (** - Summary: Query constructor for declared functions. - + Summary: Query constructor for declared functions. @param c logical context. @param constr constructor container. The container must have been passed in to a {!mk_datatype} call. @param num_fields number of accessor fields in the constructor. @param constructor constructor function declaration. @param tester constructor test function declaration. @param accessors array of accessor function declarations. - def_API('query_constructor', VOID, (_in(CONTEXT), _in(CONSTRUCTOR), _in(UINT), _out(FUNC_DECL), _out(FUNC_DECL), _out_array(2, FUNC_DECL))) *) external query_constructor : context -> constructor -> int -> func_decl * func_decl * func_decl array @@ -1657,22 +1395,17 @@ external query_constructor : context -> constructor -> int -> func_decl * func_d *) (** Summary: Declare a constant or function. - [mk_func_decl c n d r] creates a function with name [n], domain [d], and range [r]. - The arity of the function is the size of the array [d]. - + The arity of the function is the size of the array [d]. @param c logical context. @param s name of the constant or function. @param domain_size number of arguments. It is 0 when declaring a constant. @param domain array containing the sort of each argument. The array must contain domain_size elements. It is 0 when declaring a constant. @param range sort of the constant or the return sort of the function. - After declaring a constant or function, the function {!mk_app} can be used to create a constant or function application. - - {b See also}: {!mk_app} - def_API('mk_func_decl', FUNC_DECL, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SORT), _in(SORT))) *) external mk_func_decl : context -> symbol -> sort array -> sort -> func_decl @@ -1680,9 +1413,7 @@ external mk_func_decl : context -> symbol -> sort array -> sort -> func_decl (** Summary: Create a constant or function application. - - {b See also}: {!mk_func_decl} - def_API('mk_app', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT), _in_array(2, AST))) *) external mk_app : context -> func_decl -> ast array -> ast @@ -1690,18 +1421,9 @@ external mk_app : context -> func_decl -> ast array -> ast (** Summary: Declare and create a constant. - - - - - - - - [mk_const c s t] is a shorthand for [mk_app c (mk_func_decl c s [||] t) [||]] - + [mk_const c s t] is a shorthand for [mk_app c (mk_func_decl c s [||] t) [||]] - {b See also}: {!mk_func_decl} - {b See also}: {!mk_app} - def_API('mk_const', AST, (_in(CONTEXT), _in(SYMBOL), _in(SORT))) *) external mk_const : context -> symbol -> sort -> ast @@ -1709,14 +1431,8 @@ external mk_const : context -> symbol -> sort -> ast (** Summary: Declare a fresh constant or function. - Z3 will generate an unique name for this function declaration. - - - - - {b See also}: {!mk_func_decl} - def_API('mk_fresh_func_decl', FUNC_DECL, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SORT), _in(SORT))) *) external mk_fresh_func_decl : context -> string -> sort array -> sort -> func_decl @@ -1724,17 +1440,9 @@ external mk_fresh_func_decl : context -> string -> sort array -> sort -> func_de (** Summary: Declare and create a fresh constant. - - - - - [mk_fresh_const c p t] is a shorthand for [mk_app c (mk_fresh_func_decl c p [||] t) [||]]. - - - + [mk_fresh_const c p t] is a shorthand for [mk_app c (mk_fresh_func_decl c p [||] t) [||]]. - {b See also}: {!mk_func_decl} - {b See also}: {!mk_app} - def_API('mk_fresh_const', AST, (_in(CONTEXT), _in(STRING), _in(SORT))) *) external mk_fresh_const : context -> string -> sort -> ast @@ -1745,7 +1453,6 @@ external mk_fresh_const : context -> string -> sort -> ast *) (** Summary: Create an AST node representing [true]. - def_API('mk_true', AST, (_in(CONTEXT), )) *) external mk_true : context -> ast @@ -1753,7 +1460,6 @@ external mk_true : context -> ast (** Summary: Create an AST node representing [false]. - def_API('mk_false', AST, (_in(CONTEXT), )) *) external mk_false : context -> ast @@ -1762,51 +1468,40 @@ external mk_false : context -> ast (** Summary: \[ [ mk_eq c l r ] \] Create an AST node representing {e l = r }. - - The nodes [l] and [r] must have the same type. - + The nodes [l] and [r] must have the same type. def_API('mk_eq', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_eq : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_eq" (** - Summary: \[ [mk_distinct c [| t_1; ...; t_n |]] \] Create an AST node represeting a distinct construct. It is used for declaring - the arguments t_i pairwise distinct. - + the arguments t_i pairwise distinct. The [distinct] construct is used for declaring the arguments pairwise distinct. That is, {e Forall 0 <= i < j < num_args. not args[i] = args[j] }. - All arguments must have the same sort. - - {b Remarks}: The number of arguments of a distinct construct must be greater than one. - def_API('mk_distinct', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_distinct : context -> ast array -> ast = "camlidl_z3_Z3_mk_distinct" (** - Summary: \[ [ mk_not c a ] \] + Summary: \[ [ mk_not c a ] \] Create an AST node representing {e not(a) }. - The node [a] must have Boolean sort. - def_API('mk_not', AST, (_in(CONTEXT), _in(AST))) *) external mk_not : context -> ast -> ast = "camlidl_z3_Z3_mk_not" (** - Summary: \[ [ mk_ite c t1 t2 t2 ] \] + Summary: \[ [ mk_ite c t1 t2 t2 ] \] Create an AST node representing an if-then-else: {e ite(t1, t2, t3) }. - The node [t1] must have Boolean sort, [t2] and [t3] must have the same sort. The sort of the new node is equal to the sort of [t2] and [t3]. - def_API('mk_ite', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(AST))) *) external mk_ite : context -> ast -> ast -> ast -> ast @@ -1815,9 +1510,7 @@ external mk_ite : context -> ast -> ast -> ast -> ast (** Summary: \[ [ mk_iff c t1 t2 ] \] Create an AST node representing {e t1 iff t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_iff', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_iff : context -> ast -> ast -> ast @@ -1826,9 +1519,7 @@ external mk_iff : context -> ast -> ast -> ast (** Summary: \[ [ mk_implies c t1 t2 ] \] Create an AST node representing {e t1 implies t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_implies', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_implies : context -> ast -> ast -> ast @@ -1837,37 +1528,25 @@ external mk_implies : context -> ast -> ast -> ast (** Summary: \[ [ mk_xor c t1 t2 ] \] Create an AST node representing {e t1 xor t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_xor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_xor : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_xor" (** - - Summary: \[ [mk_and c [| t_1; ...; t_n |]] \] Create the conjunction: {e t_1 and ... and t_n}. - - + Summary: \[ [mk_and c [| t_1; ...; t_n |]] \] Create the conjunction: {e t_1 and ... and t_n}. All arguments must have Boolean sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_and', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_and : context -> ast array -> ast = "camlidl_z3_Z3_mk_and" (** - - Summary: \[ [mk_or c [| t_1; ...; t_n |]] \] Create the disjunction: {e t_1 or ... or t_n}. - - + Summary: \[ [mk_or c [| t_1; ...; t_n |]] \] Create the disjunction: {e t_1 or ... or t_n}. All arguments must have Boolean sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_or', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_or : context -> ast array -> ast @@ -1877,110 +1556,78 @@ external mk_or : context -> ast array -> ast {2 {L Arithmetic: Integers and Reals}} *) (** - - Summary: \[ [mk_add c [| t_1; ...; t_n |]] \] Create the term: {e t_1 + ... + t_n}. - - + Summary: \[ [mk_add c [| t_1; ...; t_n |]] \] Create the term: {e t_1 + ... + t_n}. All arguments must have int or real sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_add', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_add : context -> ast array -> ast = "camlidl_z3_Z3_mk_add" (** - - Summary: \[ [mk_mul c [| t_1; ...; t_n |]] \] Create the term: {e t_1 * ... * t_n}. - - + Summary: \[ [mk_mul c [| t_1; ...; t_n |]] \] Create the term: {e t_1 * ... * t_n}. All arguments must have int or real sort. - - {b Remarks}: Z3 has limited support for non-linear arithmetic. - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_mul', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_mul : context -> ast array -> ast = "camlidl_z3_Z3_mk_mul" (** - - Summary: \[ [mk_sub c [| t_1; ...; t_n |]] \] Create the term: {e t_1 - ... - t_n}. - - + Summary: \[ [mk_sub c [| t_1; ...; t_n |]] \] Create the term: {e t_1 - ... - t_n}. All arguments must have int or real sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_sub', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_sub : context -> ast array -> ast = "camlidl_z3_Z3_mk_sub" (** - - Summary: \[ [mk_unary_minus c arg] \] Create the term: {e - arg}. - + Summary: \[ [mk_unary_minus c arg] \] Create the term: {e - arg}. The arguments must have int or real type. - def_API('mk_unary_minus', AST, (_in(CONTEXT), _in(AST))) *) external mk_unary_minus : context -> ast -> ast = "camlidl_z3_Z3_mk_unary_minus" (** - - Summary: \[ [mk_div c t_1 t_2] \] Create the term: {e t_1 div t_2}. - + Summary: \[ [mk_div c t_1 t_2] \] Create the term: {e t_1 div t_2}. The arguments must either both have int type or both have real type. If the arguments have int type, then the result type is an int type, otherwise the the result type is real. - def_API('mk_div', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_div : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_div" (** - - Summary: \[ [mk_mod c t_1 t_2] \] Create the term: {e t_1 mod t_2}. - + Summary: \[ [mk_mod c t_1 t_2] \] Create the term: {e t_1 mod t_2}. The arguments must have int type. - def_API('mk_mod', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_mod : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_mod" (** - - Summary: \[ [mk_rem c t_1 t_2] \] Create the term: {e t_1 rem t_2}. - + Summary: \[ [mk_rem c t_1 t_2] \] Create the term: {e t_1 rem t_2}. The arguments must have int type. - def_API('mk_rem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_rem : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_rem" (** - - The arguments must have int or real type. - def_API('mk_power', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_power : context -> ast -> ast -> ast = "camlidl_z3_Z3_mk_power" (** - Summary: \[ [ mk_lt c t1 t2 ] \] + Summary: \[ [ mk_lt c t1 t2 ] \] Create less than. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_lt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_lt : context -> ast -> ast -> ast @@ -1989,9 +1636,7 @@ external mk_lt : context -> ast -> ast -> ast (** Summary: \[ [ mk_le c t1 t2 ] \] Create less than or equal to. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_le', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_le : context -> ast -> ast -> ast @@ -2000,9 +1645,7 @@ external mk_le : context -> ast -> ast -> ast (** Summary: \[ [ mk_gt c t1 t2 ] \] Create greater than. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_gt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_gt : context -> ast -> ast -> ast @@ -2011,9 +1654,7 @@ external mk_gt : context -> ast -> ast -> ast (** Summary: \[ [ mk_ge c t1 t2 ] \] Create greater than or equal to. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_ge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ge : context -> ast -> ast -> ast @@ -2022,19 +1663,14 @@ external mk_ge : context -> ast -> ast -> ast (** Summary: \[ [ mk_int2real c t1 ] \] 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 + You can take the floor of a real by creating an auxiliary integer constant [k] and - and asserting {e mk_int2real(k) <= t1 < mk_int2real(k)+1 }. - + and asserting {e mk_int2real(k) <= t1 < mk_int2real(k)+1 }. The node [t1] must have sort integer. - - {b See also}: {!mk_real2int} - {b See also}: {!mk_is_int} - def_API('mk_int2real', AST, (_in(CONTEXT), _in(AST))) *) external mk_int2real : context -> ast -> ast @@ -2043,13 +1679,10 @@ external mk_int2real : context -> ast -> ast (** Summary: \[ [ mk_real2int c t1 ] \] Coerce a real to an integer. - The semantics of this function follows the SMT-LIB standard for the function to_int - - {b See also}: {!mk_int2real} - {b See also}: {!mk_is_int} - def_API('mk_real2int', AST, (_in(CONTEXT), _in(AST))) *) external mk_real2int : context -> ast -> ast @@ -2058,10 +1691,8 @@ external mk_real2int : context -> ast -> ast (** Summary: \[ [ mk_is_int c t1 ] \] Check if a real number is an integer. - - {b See also}: {!mk_int2real} - {b See also}: {!mk_real2int} - def_API('mk_is_int', AST, (_in(CONTEXT), _in(AST))) *) external mk_is_int : context -> ast -> ast @@ -2073,9 +1704,7 @@ external mk_is_int : context -> ast -> ast (** Summary: \[ [ mk_bvnot c t1 ] \] Bitwise negation. - The node [t1] must have a bit-vector sort. - def_API('mk_bvnot', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvnot : context -> ast -> ast @@ -2084,9 +1713,7 @@ external mk_bvnot : context -> ast -> ast (** Summary: \[ [ mk_bvredand c t1 ] \] Take conjunction of bits in vector, return vector of length 1. - The node [t1] must have a bit-vector sort. - def_API('mk_bvredand', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvredand : context -> ast -> ast @@ -2095,9 +1722,7 @@ external mk_bvredand : context -> ast -> ast (** Summary: \[ [ mk_bvredor c t1 ] \] Take disjunction of bits in vector, return vector of length 1. - The node [t1] must have a bit-vector sort. - def_API('mk_bvredor', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvredor : context -> ast -> ast @@ -2106,9 +1731,7 @@ external mk_bvredor : context -> ast -> ast (** Summary: \[ [ mk_bvand c t1 t2 ] \] Bitwise and. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvand', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvand : context -> ast -> ast -> ast @@ -2117,9 +1740,7 @@ external mk_bvand : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvor c t1 t2 ] \] Bitwise or. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvor : context -> ast -> ast -> ast @@ -2128,9 +1749,7 @@ external mk_bvor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvxor c t1 t2 ] \] Bitwise exclusive-or. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvxor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvxor : context -> ast -> ast -> ast @@ -2138,10 +1757,8 @@ external mk_bvxor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvnand c t1 t2 ] \] - Bitwise nand. - + Bitwise nand. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvnand', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvnand : context -> ast -> ast -> ast @@ -2149,10 +1766,8 @@ external mk_bvnand : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvnor c t1 t2 ] \] - Bitwise nor. - + Bitwise nor. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvnor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvnor : context -> ast -> ast -> ast @@ -2160,10 +1775,8 @@ external mk_bvnor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvxnor c t1 t2 ] \] - Bitwise xnor. - + Bitwise xnor. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvxnor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvxnor : context -> ast -> ast -> ast @@ -2172,9 +1785,7 @@ external mk_bvxnor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvneg c t1 ] \] Standard two's complement unary minus. - The node [t1] must have bit-vector sort. - def_API('mk_bvneg', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvneg : context -> ast -> ast @@ -2183,9 +1794,7 @@ external mk_bvneg : context -> ast -> ast (** Summary: \[ [ mk_bvadd c t1 t2 ] \] Standard two's complement addition. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvadd : context -> ast -> ast -> ast @@ -2194,9 +1803,7 @@ external mk_bvadd : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsub c t1 t2 ] \] Standard two's complement subtraction. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsub : context -> ast -> ast -> ast @@ -2205,9 +1812,7 @@ external mk_bvsub : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvmul c t1 t2 ] \] Standard two's complement multiplication. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvmul : context -> ast -> ast -> ast @@ -2215,14 +1820,11 @@ external mk_bvmul : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvudiv c t1 t2 ] \] - Unsigned division. - + Unsigned division. It is defined as the [floor] of {e t1/t2 } if [t2] is different from zero. If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvudiv', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvudiv : context -> ast -> ast -> ast @@ -2231,17 +1833,11 @@ external mk_bvudiv : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsdiv c t1 t2 ] \] Two's complement signed division. - It is defined in the following way: - - The [floor] of {e t1/t2 } if [t2] is different from zero, and {e t1*t2 >= 0 }. - - The [ceiling] of {e t1/t2 } if [t2] is different from zero, and {e t1*t2 < 0 }. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsdiv', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsdiv : context -> ast -> ast -> ast @@ -2250,13 +1846,9 @@ external mk_bvsdiv : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvurem c t1 t2 ] \] Unsigned remainder. - It is defined as {e t1 - (t1 /u t2) * t2 }, where {e /u } represents unsigned int division. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvurem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvurem : context -> ast -> ast -> ast @@ -2265,16 +1857,11 @@ external mk_bvurem : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsrem c t1 t2 ] \] Two's complement signed remainder (sign follows dividend). - It is defined as {e t1 - (t1 /s t2) * t2 }, where {e /s } represents signed division. The most significant bit (sign) of the result is equal to the most significant bit of [t1]. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - - {b See also}: {!mk_bvsmod} - def_API('mk_bvsrem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsrem : context -> ast -> ast -> ast @@ -2283,13 +1870,9 @@ external mk_bvsrem : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsmod c t1 t2 ] \] Two's complement signed remainder (sign follows divisor). - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - - {b See also}: {!mk_bvsrem} - def_API('mk_bvsmod', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsmod : context -> ast -> ast -> ast @@ -2298,9 +1881,7 @@ external mk_bvsmod : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvult c t1 t2 ] \] Unsigned less than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvult', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvult : context -> ast -> ast -> ast @@ -2309,17 +1890,14 @@ external mk_bvult : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvslt c t1 t2 ] \] Two's complement signed less than. - It abbreviates: - {v + {v (or (and (= (extract[|m-1|:|m-1|] t1) bit1) (= (extract[|m-1|:|m-1|] t2) bit0)) (and (= (extract[|m-1|:|m-1|] t1) (extract[|m-1|:|m-1|] t2)) (bvult t1 t2))) v} - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvslt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvslt : context -> ast -> ast -> ast @@ -2328,9 +1906,7 @@ external mk_bvslt : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvule c t1 t2 ] \] Unsigned less than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvule', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvule : context -> ast -> ast -> ast @@ -2339,9 +1915,7 @@ external mk_bvule : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsle c t1 t2 ] \] Two's complement signed less than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsle', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsle : context -> ast -> ast -> ast @@ -2350,9 +1924,7 @@ external mk_bvsle : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvuge c t1 t2 ] \] Unsigned greater than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvuge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvuge : context -> ast -> ast -> ast @@ -2361,9 +1933,7 @@ external mk_bvuge : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsge c t1 t2 ] \] Two's complement signed greater than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsge : context -> ast -> ast -> ast @@ -2372,9 +1942,7 @@ external mk_bvsge : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvugt c t1 t2 ] \] Unsigned greater than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvugt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvugt : context -> ast -> ast -> ast @@ -2383,9 +1951,7 @@ external mk_bvugt : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsgt c t1 t2 ] \] Two's complement signed greater than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsgt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsgt : context -> ast -> ast -> ast @@ -2394,12 +1960,9 @@ external mk_bvsgt : context -> ast -> ast -> ast (** Summary: \[ [ mk_concat c t1 t2 ] \] Concatenate the given bit-vectors. - The nodes [t1] and [t2] must have (possibly different) bit-vector sorts - The result is a bit-vector of size {e n1+n2 }, where [n1] ([n2)] is the size of [t1] ([t2)]. - def_API('mk_concat', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_concat : context -> ast -> ast -> ast @@ -2410,9 +1973,7 @@ external mk_concat : context -> ast -> ast -> ast Extract the bits [high] down to [low] from a bitvector of size [m] to yield a new bitvector of size [n], where {e n = high - low + 1 }. - The node [t1] must have a bit-vector sort. - def_API('mk_extract', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in(AST))) *) external mk_extract : context -> int -> int -> ast -> ast @@ -2423,9 +1984,7 @@ external mk_extract : context -> int -> int -> ast -> ast Sign-extend of the given bit-vector to the (signed) equivalent bitvector of size {e m+i }, where [m] is the size of the given bit-vector. - The node [t1] must have a bit-vector sort. - def_API('mk_sign_ext', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_sign_ext : context -> int -> ast -> ast @@ -2433,12 +1992,10 @@ external mk_sign_ext : context -> int -> ast -> ast (** Summary: \[ [ mk_zero_ext c i t1 ] \] - Extend the given bit-vector with zeros to the (unsigned int) equivalent + Extend the given bit-vector with zeros to the (unsigned) equivalent bitvector of size {e m+i }, where [m] is the size of the given bit-vector. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_zero_ext', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_zero_ext : context -> int -> ast -> ast @@ -2447,9 +2004,7 @@ external mk_zero_ext : context -> int -> ast -> ast (** Summary: \[ [ mk_repeat c i t1 ] \] Repeat the given bit-vector up length {e i }. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_repeat', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_repeat : context -> int -> ast -> ast @@ -2458,16 +2013,12 @@ external mk_repeat : context -> int -> ast -> ast (** Summary: \[ [ mk_bvshl c t1 t2 ] \] Shift left. - It is equivalent to multiplication by {e 2^x } where [x] is the value of the third argument. - - NB. The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvshl', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvshl : context -> ast -> ast -> ast @@ -2476,16 +2027,12 @@ external mk_bvshl : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvlshr c t1 t2 ] \] Logical shift right. - It is equivalent to unsigned int division by {e 2^x } where [x] is the value of the third argument. - - NB. The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvlshr', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvlshr : context -> ast -> ast -> ast @@ -2494,17 +2041,13 @@ external mk_bvlshr : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvashr c t1 t2 ] \] 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. - - The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvashr', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvashr : context -> ast -> ast -> ast @@ -2513,9 +2056,7 @@ external mk_bvashr : context -> ast -> ast -> ast (** Summary: \[ [ mk_rotate_left c i t1 ] \] Rotate bits of [t1] to the left [i] times. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_rotate_left', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_rotate_left : context -> int -> ast -> ast @@ -2524,9 +2065,7 @@ external mk_rotate_left : context -> int -> ast -> ast (** Summary: \[ [ mk_rotate_right c i t1 ] \] Rotate bits of [t1] to the right [i] times. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_rotate_right', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_rotate_right : context -> int -> ast -> ast @@ -2535,9 +2074,7 @@ external mk_rotate_right : context -> int -> ast -> ast (** Summary: \[ [ mk_ext_rotate_left c t1 t2 ] \] Rotate bits of [t1] to the left [t2] times. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_ext_rotate_left', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ext_rotate_left : context -> ast -> ast -> ast @@ -2546,9 +2083,7 @@ external mk_ext_rotate_left : context -> ast -> ast -> ast (** Summary: \[ [ mk_ext_rotate_right c t1 t2 ] \] Rotate bits of [t1] to the right [t2] times. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_ext_rotate_right', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ext_rotate_right : context -> ast -> ast -> ast @@ -2557,13 +2092,10 @@ external mk_ext_rotate_right : context -> ast -> ast -> ast (** Summary: \[ [ mk_int2bv c n t1 ] \] Create an [n] bit bit-vector from the integer argument [t1]. - - NB. This function is essentially treated as uninterpreted. + 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 node [t1] must have integer sort. - + The node [t1] must have integer sort. def_API('mk_int2bv', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_int2bv : context -> int -> ast -> ast @@ -2572,17 +2104,14 @@ external mk_int2bv : context -> int -> ast -> ast (** Summary: \[ [ mk_bv2int c t1 is_signed ] \] Create an integer from the bit-vector argument [t1]. - If [is_signed] is false, then the bit-vector [t1] is treated as unsigned int. + If [is_signed] is false, then the bit-vector [t1] is treated as unsigned int. So the result is non-negative and in the range {e [0..2^N-1] }, where N are the number of bits in [t1]. If [is_signed] is true, [t1] is treated as a signed bit-vector. - - This function is essentially treated as uninterpreted. + 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 node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_bv2int', AST, (_in(CONTEXT), _in(AST), _in(BOOL))) *) external mk_bv2int : context -> ast -> bool -> ast @@ -2592,9 +2121,7 @@ external mk_bv2int : context -> ast -> bool -> ast Summary: \[ [ mk_bvadd_no_overflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise addition of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvadd_no_overflow : context -> ast -> ast -> bool -> ast @@ -2604,9 +2131,7 @@ external mk_bvadd_no_overflow : context -> ast -> ast -> bool -> ast Summary: \[ [ mk_bvadd_no_underflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed addition of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvadd_no_underflow : context -> ast -> ast -> ast @@ -2616,9 +2141,7 @@ external mk_bvadd_no_underflow : context -> ast -> ast -> ast Summary: \[ [ mk_bvsub_no_overflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed subtraction of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsub_no_overflow : context -> ast -> ast -> ast @@ -2628,9 +2151,7 @@ external mk_bvsub_no_overflow : context -> ast -> ast -> ast Summary: \[ [ mk_bvsub_no_underflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise subtraction of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvsub_no_underflow : context -> ast -> ast -> bool -> ast @@ -2638,11 +2159,9 @@ external mk_bvsub_no_underflow : context -> ast -> ast -> bool -> ast (** Summary: \[ [ mk_bvsdiv_no_overflow c t1 t2 ] \] - Create a predicate that checks that the bit-wise signed division + Create a predicate that checks that the bit-wise signed division of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsdiv_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsdiv_no_overflow : context -> ast -> ast -> ast @@ -2650,11 +2169,9 @@ external mk_bvsdiv_no_overflow : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvneg_no_overflow c t1 ] \] - Check that bit-wise negation does not overflow when + Check that bit-wise negation does not overflow when [t1] is interpreted as a signed bit-vector. - The node [t1] must have bit-vector sort. - def_API('mk_bvneg_no_overflow', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvneg_no_overflow : context -> ast -> ast @@ -2664,9 +2181,7 @@ external mk_bvneg_no_overflow : context -> ast -> ast Summary: \[ [ mk_bvmul_no_overflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise multiplication of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvmul_no_overflow : context -> ast -> ast -> bool -> ast @@ -2676,9 +2191,7 @@ external mk_bvmul_no_overflow : context -> ast -> ast -> bool -> ast Summary: \[ [ mk_bvmul_no_underflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed multiplication of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvmul_no_underflow : context -> ast -> ast -> ast @@ -2690,15 +2203,12 @@ external mk_bvmul_no_underflow : context -> ast -> ast -> ast (** Summary: \[ [ mk_select c a i ] \] 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 {e [domain -> range] }, + 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 {e [domain -> range] }, and [i] must have the sort [domain]. The sort of the result is [range]. - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_store} - def_API('mk_select', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_select : context -> ast -> ast -> ast @@ -2707,18 +2217,15 @@ external mk_select : context -> ast -> ast -> ast (** Summary: \[ [ mk_store c a i v ] \] Array update. - The node [a] must have an array sort {e [domain -> range] }, [i] must have sort [domain], [v] must have sort range. The sort of the result is {e [domain -> range] }. The semantics of this function is given by the theory of arrays described in the SMT-LIB - standard. See http: + 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 + 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). - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_select} - def_API('mk_store', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(AST))) *) external mk_store : context -> ast -> ast -> ast -> ast @@ -2726,14 +2233,11 @@ external mk_store : context -> ast -> ast -> ast -> ast (** Summary: Create the constant array. - - The resulting term is an array, such that a [select] on an arbitrary index + The resulting term is an array, such that a [select] on an arbitrary index produces the value [v]. - @param c logical context. @param domain domain sort for the array. @param v value that the array maps to. - def_API('mk_const_array', AST, (_in(CONTEXT), _in(SORT), _in(AST))) *) external mk_const_array : context -> sort -> ast -> ast @@ -2742,15 +2246,12 @@ external mk_const_array : context -> sort -> ast -> ast (** Summary: \[ [ mk_map f n args ] \] map f on the the argument arrays. - The [n] nodes [args] must be of array sorts {e [domain_i -> range_i] }. - The function declaration [f] must have type {e range_1 .. range_n -> range }. + The function declaration [f] must have type {e range_1 .. range_n -> range }. [v] must have sort range. The sort of the result is {e [domain_i -> range] }. - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_store} - {b See also}: {!mk_select} - def_API('mk_map', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT), _in_array(2, AST))) *) external mk_map : context -> func_decl -> int -> ast -> ast @@ -2758,12 +2259,10 @@ external mk_map : context -> func_decl -> int -> ast -> ast (** Summary: Access the array default value. - Produces the default range value, for arrays that can be represented as + Produces the default range value, for arrays that can be represented as finite maps with a default range value. - @param c logical context. @param array array value whose default range value is accessed. - def_API('mk_array_default', AST, (_in(CONTEXT), _in(AST))) *) external mk_array_default : context -> ast -> ast @@ -2774,7 +2273,6 @@ external mk_array_default : context -> ast -> ast *) (** Summary: Create Set type. - def_API('mk_set_sort', SORT, (_in(CONTEXT), _in(SORT))) *) external mk_set_sort : context -> sort -> sort @@ -2782,7 +2280,6 @@ external mk_set_sort : context -> sort -> sort (** Summary: Create the empty set. - def_API('mk_empty_set', AST, (_in(CONTEXT), _in(SORT))) *) external mk_empty_set : context -> sort -> ast @@ -2790,7 +2287,6 @@ external mk_empty_set : context -> sort -> ast (** Summary: Create the full set. - def_API('mk_full_set', AST, (_in(CONTEXT), _in(SORT))) *) external mk_full_set : context -> sort -> ast @@ -2798,9 +2294,7 @@ external mk_full_set : context -> sort -> ast (** Summary: Add an element to a set. - The first argument must be a set, the second an element. - def_API('mk_set_add', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_add : context -> ast -> ast -> ast @@ -2808,9 +2302,7 @@ external mk_set_add : context -> ast -> ast -> ast (** Summary: Remove an element to a set. - The first argument must be a set, the second an element. - def_API('mk_set_del', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_del : context -> ast -> ast -> ast @@ -2818,7 +2310,6 @@ external mk_set_del : context -> ast -> ast -> ast (** Summary: Take the union of a list of sets. - def_API('mk_set_union', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_set_union : context -> ast array -> ast @@ -2826,7 +2317,6 @@ external mk_set_union : context -> ast array -> ast (** Summary: Take the intersection of a list of sets. - def_API('mk_set_intersect', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_set_intersect : context -> ast array -> ast @@ -2834,7 +2324,6 @@ external mk_set_intersect : context -> ast array -> ast (** Summary: Take the set difference between two sets. - def_API('mk_set_difference', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_difference : context -> ast -> ast -> ast @@ -2842,7 +2331,6 @@ external mk_set_difference : context -> ast -> ast -> ast (** Summary: Take the complement of a set. - def_API('mk_set_complement', AST, (_in(CONTEXT), _in(AST))) *) external mk_set_complement : context -> ast -> ast @@ -2850,9 +2338,7 @@ external mk_set_complement : context -> ast -> ast (** Summary: Check for set membership. - The first argument should be an element type of the set. - def_API('mk_set_member', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_member : context -> ast -> ast -> ast @@ -2860,7 +2346,6 @@ external mk_set_member : context -> ast -> ast -> ast (** Summary: Check for subsetness of sets. - def_API('mk_set_subset', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_subset : context -> ast -> ast -> ast @@ -2874,32 +2359,27 @@ external mk_set_subset : context -> ast -> ast -> ast Summary: \[ [ numeral_refined ] \] is the refined view of a numeral . *) type numeral_refined = - | Numeral_int of int * sort - | Numeral_int64 of int64 * sort - | Numeral_large of string * sort + | Numeral_int of int * sort + | Numeral_int64 of int64 * sort + | Numeral_large of string * sort | Numeral_rational of numeral_refined * numeral_refined (** Summary: \[ [ embed_numeral c nr ] \] constructs the numeral described by [nr]. - - {b See also}: {!numeral_refine} *) val embed_numeral: context -> numeral_refined -> ast (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** - Summary: Create a numeral of a given sort. - + Summary: Create a numeral of a given sort. @param c logical context. @param numeral A string representing the numeral value in decimal notation. If the given sort is a real, then the numeral can be a rational, that is, a string of the form {e [num]* / [num]* }. - @param ty The sort of the numeral. In the current implementation, the given sort can be an int, real, finite-domain, or bit-vectors of arbitrary size. - + @param ty The sort of the numeral. In the current implementation, the given sort can be an int, real, finite-domain, or bit-vectors of arbitrary size. - {b See also}: {!mk_int} - - def_API('mk_numeral', AST, (_in(CONTEXT), _in(STRING), _in(SORT))) *) external mk_numeral : context -> string -> sort -> ast @@ -2907,43 +2387,32 @@ external mk_numeral : context -> string -> sort -> ast (** Summary: Create a real from a fraction. - @param c logical context. @param num numerator of rational. @param den denomerator of rational. - - {b Precondition}: den != 0 - - {b See also}: {!mk_numeral} - {b See also}: {!mk_int} - - def_API('mk_real', AST, (_in(CONTEXT), _in(INT), _in(INT))) *) external mk_real : context -> int -> int -> ast = "camlidl_z3_Z3_mk_real" (** - Summary: Create a numeral of an int, bit-vector, or finite-domain sort. - + Summary: Create a numeral of an int, bit-vector, or finite-domain sort. This function can be use to create numerals that fit in a machine integer. It is slightly faster than {!mk_numeral} since it is not necessary to parse a string. - - {b See also}: {!mk_numeral} - def_API('mk_int', AST, (_in(CONTEXT), _in(INT), _in(SORT))) *) external mk_int : context -> int -> sort -> ast = "camlidl_z3_Z3_mk_int" (** - Summary: Create a numeral of a int, bit-vector, or finite-domain sort. - + Summary: Create a numeral of a int, bit-vector, or finite-domain sort. This function can be use to create numerals that fit in a machine long long integer. It is slightly faster than {!mk_numeral} since it is not necessary to parse a string. - - {b See also}: {!mk_numeral} - def_API('mk_int64', AST, (_in(CONTEXT), _in(INT64), _in(SORT))) *) external mk_int64 : context -> int64 -> sort -> ast @@ -2954,22 +2423,17 @@ external mk_int64 : context -> int64 -> sort -> ast *) (** Summary: Create a pattern for quantifier instantiation. - Z3 uses pattern matching to instantiate quantifiers. If a pattern is not provided for a quantifier, then Z3 will automatically compute a set of patterns for it. However, for optimal performance, the user should provide the patterns. - Patterns comprise a list of terms. The list should be - non-empty. If the list comprises of more than one term, it is + non-empty. If the list comprises of more than one term, it is a called a multi-pattern. - In general, one can pass in a list of (multi-)patterns in the quantifier constructor. - - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_pattern', PATTERN, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_pattern : context -> ast array -> pattern @@ -2977,12 +2441,10 @@ external mk_pattern : context -> ast array -> pattern (** Summary: Create 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. - - {v + {v 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 @@ -2990,18 +2452,14 @@ external mk_pattern : context -> ast array -> pattern 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)) v} - 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. - @param c logical context @param index de-Bruijn index @param ty sort of the bound variable - - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_bound', AST, (_in(CONTEXT), _in(UINT), _in(SORT))) *) external mk_bound : context -> int -> sort -> ast @@ -3010,21 +2468,17 @@ external mk_bound : context -> int -> sort -> ast (** Summary: Create a forall formula. It takes an expression [body] that contains bound variables of the same sorts as the sorts listed in the array [sorts]. The bound variables are de-Bruijn indices created - using {!mk_bound}. The array [decl_names] contains the names that the quantified formula uses for the + using {!mk_bound}. The array [decl_names] contains the names that the quantified formula uses for the bound variables. Z3 applies the convention that the last element in the [decl_names] and [sorts] array refers to the variable with index 0, the second to last element of [decl_names] and [sorts] refers to the variable with index 1, etc. - - [mk_forall c w p t n b] creates a forall formula, where [w] is the weight, [p] is an array of patterns, [t] is an array with the sorts of the bound variables, [n] is an array with the 'names' of the bound variables, and [b] is the body of the quantifier. Quantifiers are associated with weights indicating the importance of using the quantifier during - instantiation. - - + instantiation. @param c logical context. @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_patterns number of patterns. @@ -3033,11 +2487,9 @@ external mk_bound : context -> int -> sort -> ast @param sorts the sorts of the bound variables. @param decl_names names of the bound variables @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_exists} - def_API('mk_forall', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, PATTERN), _in(UINT), _in_array(4, SORT), _in_array(4, SYMBOL), _in(AST))) *) external mk_forall : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast @@ -3045,21 +2497,18 @@ external mk_forall : context -> int -> pattern array -> sort array -> symbol arr (** Summary: Create an exists formula. Similar to {!mk_forall}. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_quantifier} - def_API('mk_exists', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, PATTERN), _in(UINT), _in_array(4, SORT), _in_array(4, SYMBOL), _in(AST))) *) external mk_exists : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast = "camlidl_z3_Z3_mk_exists_bytecode" "camlidl_z3_Z3_mk_exists" (** - Summary: Create a quantifier - universal or existential, with pattern hints. + Summary: Create a quantifier - universal or existential, with pattern hints. See the documentation for {!mk_forall} for an explanation of the parameters. - @param c logical context. @param is_forall flag to indicate if this is a universal or existential quantifier. @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @@ -3069,12 +2518,10 @@ external mk_exists : context -> int -> pattern array -> sort array -> symbol arr @param sorts array of sorts of the bound variables. @param decl_names names of the bound variables. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_quantifier', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(UINT), _in_array(3, PATTERN), _in(UINT), _in_array(5, SORT), _in_array(5, SYMBOL), _in(AST))) *) external mk_quantifier : context -> bool -> int -> pattern array -> sort array -> symbol array -> ast -> ast @@ -3082,7 +2529,6 @@ external mk_quantifier : context -> bool -> int -> pattern array -> sort array - (** Summary: Create a quantifier - universal or existential, with pattern hints, no patterns, and attributes - @param c logical context. @param is_forall flag to indicate if this is a universal or existential quantifier. @param quantifier_id identifier to identify quantifier @@ -3096,12 +2542,10 @@ external mk_quantifier : context -> bool -> int -> pattern array -> sort array - @param sorts array of sorts of the bound variables. @param decl_names names of the bound variables. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_quantifier_ex', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(5, PATTERN), _in(UINT), _in_array(7, AST), _in(UINT), _in_array(9, SORT), _in_array(9, SYMBOL), _in(AST))) *) external mk_quantifier_ex : context -> bool -> int -> symbol -> symbol -> pattern array -> ast array -> sort array -> symbol array -> ast -> ast @@ -3110,19 +2554,16 @@ external mk_quantifier_ex : context -> bool -> int -> symbol -> symbol -> patter (** Summary: Create a universal quantifier using a list of constants that will form the set of bound variables. - @param c logical context. - @param weight quantifiers are associated with weights indicating the importance of using + @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_bound number of constants to be abstracted into bound variables. @param bound array of constants to be abstracted into bound variables. @param num_patterns number of patterns. @param patterns array containing the patterns created using {!mk_pattern}. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_exists_const} - def_API('mk_forall_const', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, APP), _in(UINT), _in_array(4, PATTERN), _in(AST))) *) external mk_forall_const : context -> int -> app array -> pattern array -> ast -> ast @@ -3130,42 +2571,36 @@ external mk_forall_const : context -> int -> app array -> pattern array -> ast - (** Summary: Similar to {!mk_forall_const}. - Summary: Create an existential quantifier using a list of constants that will form the set of bound variables. - @param c logical context. - @param weight quantifiers are associated with weights indicating the importance of using + @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_bound number of constants to be abstracted into bound variables. @param bound array of constants to be abstracted into bound variables. @param num_patterns number of patterns. @param patterns array containing the patterns created using {!mk_pattern}. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_forall_const} - def_API('mk_exists_const', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, APP), _in(UINT), _in_array(4, PATTERN), _in(AST))) *) external mk_exists_const : context -> int -> app array -> pattern array -> ast -> ast = "camlidl_z3_Z3_mk_exists_const" (** - Summary: Create a universal or existential + Summary: Create a universal or existential quantifier using a list of constants that will form the set of bound variables. - def_API('mk_quantifier_const', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(UINT), _in_array(3, APP), _in(UINT), _in_array(5, PATTERN), _in(AST))) *) external mk_quantifier_const : context -> bool -> int -> app array -> pattern array -> ast -> ast = "camlidl_z3_Z3_mk_quantifier_const_bytecode" "camlidl_z3_Z3_mk_quantifier_const" (** - Summary: Create a universal or existential + Summary: Create a universal or existential quantifier using a list of constants that will form the set of bound variables. - def_API('mk_quantifier_const_ex', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(5, APP), _in(UINT), _in_array(7, PATTERN), _in(UINT), _in_array(9, AST), _in(AST))) *) external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> app array -> pattern array -> ast array -> ast -> ast @@ -3175,7 +2610,7 @@ external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> {2 {L Accessors}} *) (** - {3 {L Symbols}} + {3 {L Symbols}} *) (** @@ -3184,13 +2619,12 @@ external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> val symbol_refine: context -> symbol -> symbol_refined (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Return [INT_SYMBOL] if the symbol was constructed using {!mk_int_symbol}, and [STRING_SYMBOL] if the symbol was constructed using {!mk_string_symbol}. - def_API('get_symbol_kind', UINT, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_kind : context -> symbol -> symbol_kind @@ -3198,12 +2632,9 @@ external get_symbol_kind : context -> symbol -> symbol_kind (** Summary: \[ [ get_symbol_int c s ] \] - Return the symbol int value. - + Return the symbol int value. - {b Precondition}: get_symbol_kind s == INT_SYMBOL - - {b See also}: {!mk_int_symbol} - def_API('get_symbol_int', INT, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_int : context -> symbol -> int @@ -3211,23 +2642,16 @@ external get_symbol_int : context -> symbol -> int (** Summary: \[ [ get_symbol_string c s ] \] - Return the symbol name. - + Return the symbol name. - {b Precondition}: get_symbol_string s == STRING_SYMBOL - - - - - - {b See also}: {!mk_string_symbol} - def_API('get_symbol_string', STRING, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_string : context -> symbol -> string = "camlidl_z3_Z3_get_symbol_string" (** - {3 {L Sorts}} + {3 {L Sorts}} *) (** @@ -3236,8 +2660,7 @@ external get_symbol_string : context -> symbol -> string val sort_refine: context -> sort -> sort_refined (** - Summary: Return the sort name as a symbol. - + Summary: Return the sort name as a symbol. def_API('get_sort_name', SYMBOL, (_in(CONTEXT), _in(SORT))) *) external get_sort_name : context -> sort -> symbol @@ -3245,20 +2668,18 @@ external get_sort_name : context -> sort -> symbol (** Summary: Return a unique identifier for [s]. - - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. - + - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. def_API('get_sort_id', UINT, (_in(CONTEXT), _in(SORT))) *) external get_sort_id : context -> sort -> int = "camlidl_z3_Z3_get_sort_id" (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** - Summary: Convert a [sort] into [ast]. - - {b Remarks}: [sort_to_ast c s] can be replaced by [(s :> ast)]. - + Summary: Convert a [sort] into [ast]. + - {b Remarks}: [sort_to_ast c s] can be replaced by [(s :> ast)]. def_API('sort_to_ast', AST, (_in(CONTEXT), _in(SORT))) *) external sort_to_ast : context -> sort -> ast @@ -3266,8 +2687,7 @@ external sort_to_ast : context -> sort -> ast (** Summary: compare sorts. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_sort', BOOL, (_in(CONTEXT), _in(SORT), _in(SORT))) *) external is_eq_sort : context -> sort -> sort -> bool @@ -3275,9 +2695,7 @@ external is_eq_sort : context -> sort -> sort -> bool (** Summary: Return the sort kind (e.g., array, tuple, int, bool, etc). - - {b See also}: {!sort_kind} - def_API('get_sort_kind', UINT, (_in(CONTEXT), _in(SORT))) *) external get_sort_kind : context -> sort -> sort_kind @@ -3285,23 +2703,18 @@ external get_sort_kind : context -> sort -> sort_kind (** Summary: \[ [ get_bv_sort_size c t ] \] - Return the size of the given bit-vector sort. - + Return the size of the given bit-vector sort. - {b Precondition}: get_sort_kind c t == BV_SORT - - {b See also}: {!mk_bv_sort} - {b See also}: {!get_sort_kind} - def_API('get_bv_sort_size', UINT, (_in(CONTEXT), _in(SORT))) *) external get_bv_sort_size : context -> sort -> int = "camlidl_z3_Z3_get_bv_sort_size" (** - - Summary: Return the size of the sort in [r]. Return [None] if the call failed. + Summary: Return the size of the sort in [r]. Return [None] if the call failed. That is, get_sort_kind(s) == FINITE_DOMAIN_SORT - def_API('get_finite_domain_sort_size', BOOL, (_in(CONTEXT), _in(SORT), _out(UINT64))) *) external get_finite_domain_sort_size : context -> sort -> int64 option @@ -3310,26 +2723,20 @@ external get_finite_domain_sort_size : context -> sort -> int64 option (** Summary: \[ [ get_array_sort_domain c t ] \] Return the domain of the given array sort. - - {b Precondition}: get_sort_kind c t == ARRAY_SORT - - {b See also}: {!mk_array_sort} - {b See also}: {!get_sort_kind} - def_API('get_array_sort_domain', SORT, (_in(CONTEXT), _in(SORT))) *) external get_array_sort_domain : context -> sort -> sort = "camlidl_z3_Z3_get_array_sort_domain" (** - Summary: \[ [ get_array_sort_range c t ] \] - Return the range of the given array sort. - + Summary: \[ [ get_array_sort_range c t ] \] + Return the range of the given array sort. - {b Precondition}: get_sort_kind c t == ARRAY_SORT - - {b See also}: {!mk_array_sort} - {b See also}: {!get_sort_kind} - def_API('get_array_sort_range', SORT, (_in(CONTEXT), _in(SORT))) *) external get_array_sort_range : context -> sort -> sort @@ -3338,13 +2745,10 @@ external get_array_sort_range : context -> sort -> sort (** Summary: \[ [ get_tuple_sort_mk_decl c t ] \] Return the constructor declaration of the given tuple - sort. - + sort. - {b Precondition}: get_sort_kind c t == DATATYPE_SORT - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_mk_decl', FUNC_DECL, (_in(CONTEXT), _in(SORT))) *) external get_tuple_sort_mk_decl : context -> sort -> func_decl @@ -3352,13 +2756,10 @@ external get_tuple_sort_mk_decl : context -> sort -> func_decl (** Summary: \[ [ get_tuple_sort_num_fields c t ] \] - Return the number of fields of the given tuple sort. - + Return the number of fields of the given tuple sort. - {b Precondition}: get_sort_kind c t == DATATYPE_SORT - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_num_fields', UINT, (_in(CONTEXT), _in(SORT))) *) external get_tuple_sort_num_fields : context -> sort -> int @@ -3367,14 +2768,11 @@ external get_tuple_sort_num_fields : context -> sort -> int (** Summary: \[ [ get_tuple_sort_field_decl c t i ] \] Return the i-th field declaration (i.e., projection function declaration) - of the given tuple sort. - + of the given tuple sort. - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: i < get_tuple_sort_num_fields c t - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_field_decl', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_tuple_sort_field_decl : context -> sort -> int -> func_decl @@ -3382,13 +2780,10 @@ external get_tuple_sort_field_decl : context -> sort -> int -> func_decl (** Summary: Return number of constructors for datatype. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_recognizer} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_num_constructors', UINT, (_in(CONTEXT), _in(SORT))) *) external get_datatype_sort_num_constructors : context -> sort -> int @@ -3396,14 +2791,11 @@ external get_datatype_sort_num_constructors : context -> sort -> int (** Summary: Return idx'th constructor. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx < get_datatype_sort_num_constructors c t - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_recognizer} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_constructor', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_datatype_sort_constructor : context -> sort -> int -> func_decl @@ -3411,14 +2803,11 @@ external get_datatype_sort_constructor : context -> sort -> int -> func_decl (** Summary: Return idx'th recognizer. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx < get_datatype_sort_num_constructors c t - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_recognizer', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_datatype_sort_recognizer : context -> sort -> int -> func_decl @@ -3426,15 +2815,12 @@ external get_datatype_sort_recognizer : context -> sort -> int -> func_decl (** Summary: Return idx_a'th accessor for the idx_c'th constructor. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx_c < get_datatype_sort_num_constructors c t - {b Precondition}: idx_a < get_domain_size c get_datatype_sort_constructor c idx_c - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_recognizer} - def_API('get_datatype_sort_constructor_accessor', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT), _in(UINT))) *) external get_datatype_sort_constructor_accessor : context -> sort -> int -> int -> func_decl @@ -3442,11 +2828,8 @@ external get_datatype_sort_constructor_accessor : context -> sort -> int -> int (** Summary: Return arity of relation. - - {b Precondition}: get_sort_kind s == RELATION_SORT - - {b See also}: {!get_relation_column} - def_API('get_relation_arity', UINT, (_in(CONTEXT), _in(SORT))) *) external get_relation_arity : context -> sort -> int @@ -3454,24 +2837,20 @@ external get_relation_arity : context -> sort -> int (** Summary: Return sort at i'th column of relation sort. - - {b Precondition}: get_sort_kind c s == RELATION_SORT - {b Precondition}: col < get_relation_arity c s - - {b See also}: {!get_relation_arity} - def_API('get_relation_column', SORT, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_relation_column : context -> sort -> int -> sort = "camlidl_z3_Z3_get_relation_column" (** - {3 {L Function Declarations}} + {3 {L Function Declarations}} *) (** - Summary: Convert a [func_decl] into [ast]. - - {b Remarks}: [func_decl_to_ast c f] can be replaced by [(f :> ast)]. - + Summary: Convert a [func_decl] into [ast]. + - {b Remarks}: [func_decl_to_ast c f] can be replaced by [(f :> ast)]. def_API('func_decl_to_ast', AST, (_in(CONTEXT), _in(FUNC_DECL))) *) external func_decl_to_ast : context -> func_decl -> ast @@ -3479,8 +2858,7 @@ external func_decl_to_ast : context -> func_decl -> ast (** Summary: compare terms. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_func_decl', BOOL, (_in(CONTEXT), _in(FUNC_DECL), _in(FUNC_DECL))) *) external is_eq_func_decl : context -> func_decl -> func_decl -> bool @@ -3488,16 +2866,14 @@ external is_eq_func_decl : context -> func_decl -> func_decl -> bool (** Summary: Return a unique identifier for [f]. - - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. - + - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. def_API('get_func_decl_id', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_func_decl_id : context -> func_decl -> int = "camlidl_z3_Z3_get_func_decl_id" (** - Summary: Return the constant declaration name as a symbol. - + Summary: Return the constant declaration name as a symbol. def_API('get_decl_name', SYMBOL, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_name : context -> func_decl -> symbol @@ -3505,7 +2881,6 @@ external get_decl_name : context -> func_decl -> symbol (** Summary: Return declaration kind corresponding to declaration. - def_API('get_decl_kind', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_kind : context -> func_decl -> decl_kind @@ -3513,9 +2888,7 @@ external get_decl_kind : context -> func_decl -> decl_kind (** Summary: Return the number of parameters of the given declaration. - - {b See also}: {!get_arity} - def_API('get_domain_size', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_domain_size : context -> func_decl -> int @@ -3523,9 +2896,7 @@ external get_domain_size : context -> func_decl -> int (** Summary: Alias for [get_domain_size]. - - {b See also}: {!get_domain_size} - def_API('get_arity', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_arity : context -> func_decl -> int @@ -3534,11 +2905,8 @@ external get_arity : context -> func_decl -> int (** Summary: \[ [ get_domain c d i ] \] Return the sort of the i-th parameter of the given function declaration. - - {b Precondition}: i < get_domain_size d - - {b See also}: {!get_domain_size} - def_API('get_domain', SORT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_domain : context -> func_decl -> int -> sort @@ -3547,7 +2915,6 @@ external get_domain : context -> func_decl -> int -> sort (** Summary: \[ [ get_domains c d ] \] is the array of parameters of [d]. - - {b See also}: {!get_domain_size} - {b See also}: {!get_domain} *) @@ -3555,11 +2922,9 @@ val get_domains: context -> func_decl -> sort array (** Summary: \[ [ get_range c d ] \] - Return the range of the given declaration. - + Return the range of the given declaration. If [d] is a constant (i.e., has zero arguments), then this function returns the sort of the constant. - def_API('get_range', SORT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_range : context -> func_decl -> sort @@ -3567,7 +2932,6 @@ external get_range : context -> func_decl -> sort (** Summary: Return the number of parameters associated with a declaration. - def_API('get_decl_num_parameters', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_num_parameters : context -> func_decl -> int @@ -3575,11 +2939,9 @@ external get_decl_num_parameters : context -> func_decl -> int (** Summary: Return the parameter type associated with a declaration. - @param c the context @param d the function declaration @param idx is the index of the named parameter it should be between 0 and the number of parameters. - def_API('get_decl_parameter_kind', UINT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_parameter_kind : context -> func_decl -> int -> parameter_kind @@ -3587,9 +2949,7 @@ external get_decl_parameter_kind : context -> func_decl -> int -> parameter_kind (** Summary: Return the integer value associated with an integer parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_INT - def_API('get_decl_int_parameter', INT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_int_parameter : context -> func_decl -> int -> int @@ -3597,9 +2957,7 @@ external get_decl_int_parameter : context -> func_decl -> int -> int (** Summary: Return the double value associated with an double parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_DOUBLE - def_API('get_decl_double_parameter', DOUBLE, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_double_parameter : context -> func_decl -> int -> float @@ -3607,9 +2965,7 @@ external get_decl_double_parameter : context -> func_decl -> int -> float (** Summary: Return the double value associated with an double parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_SYMBOL - def_API('get_decl_symbol_parameter', SYMBOL, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_symbol_parameter : context -> func_decl -> int -> symbol @@ -3617,9 +2973,7 @@ external get_decl_symbol_parameter : context -> func_decl -> int -> symbol (** Summary: Return the sort value associated with a sort parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_SORT - def_API('get_decl_sort_parameter', SORT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_sort_parameter : context -> func_decl -> int -> sort @@ -3627,9 +2981,7 @@ external get_decl_sort_parameter : context -> func_decl -> int -> sort (** Summary: Return the expresson value associated with an expression parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_AST - def_API('get_decl_ast_parameter', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_ast_parameter : context -> func_decl -> int -> ast @@ -3637,9 +2989,7 @@ external get_decl_ast_parameter : context -> func_decl -> int -> ast (** Summary: Return the expresson value associated with an expression parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_FUNC_DECL - def_API('get_decl_func_decl_parameter', FUNC_DECL, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_func_decl_parameter : context -> func_decl -> int -> func_decl @@ -3647,21 +2997,18 @@ external get_decl_func_decl_parameter : context -> func_decl -> int -> func_decl (** Summary: Return the rational value, as a string, associated with a rational parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_RATIONAL - def_API('get_decl_rational_parameter', STRING, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_rational_parameter : context -> func_decl -> int -> string = "camlidl_z3_Z3_get_decl_rational_parameter" (** - {3 {L Applications}} + {3 {L Applications}} *) (** - Summary: Convert a [app] into [ast]. - - {b Remarks}: [app_to_ast c a] can be replaced by [(a :> ast)]. - + Summary: Convert a [app] into [ast]. + - {b Remarks}: [app_to_ast c a] can be replaced by [(a :> ast)]. def_API('app_to_ast', AST, (_in(CONTEXT), _in(APP))) *) external app_to_ast : context -> app -> ast @@ -3669,7 +3016,6 @@ external app_to_ast : context -> app -> ast (** Summary: Return the declaration of a constant or function application. - def_API('get_app_decl', FUNC_DECL, (_in(CONTEXT), _in(APP))) *) external get_app_decl : context -> app -> func_decl @@ -3679,7 +3025,6 @@ external get_app_decl : context -> app -> func_decl Summary: \[ [ get_app_num_args c a ] \] Return the number of argument of an application. If [t] is an constant, then the number of arguments is 0. - def_API('get_app_num_args', UINT, (_in(CONTEXT), _in(APP))) *) external get_app_num_args : context -> app -> int @@ -3688,9 +3033,7 @@ external get_app_num_args : context -> app -> int (** Summary: \[ [ get_app_arg c a i ] \] Return the i-th argument of the given application. - - {b Precondition}: i < get_num_args c a - def_API('get_app_arg', AST, (_in(CONTEXT), _in(APP), _in(UINT))) *) external get_app_arg : context -> app -> int -> ast @@ -3699,44 +3042,37 @@ external get_app_arg : context -> app -> int -> ast (** Summary: \[ [ get_app_args c a ] \] is the array of arguments of an application. If [t] is a constant, then the array is empty. - - {b See also}: {!get_app_num_args} - {b See also}: {!get_app_arg} *) val get_app_args: context -> app -> ast array (** - {3 {L Terms}} + {3 {L Terms}} *) (** Summary: \[ [ binder_type ] \] is a universal or existential quantifier. - - {b See also}: {!term_refined} *) type binder_type = Forall | Exists - (** Summary: \[ [ term_refined ] \] is the refinement of a {!ast} . - - {b See also}: {!term_refine} *) type term_refined = - | Term_numeral of numeral_refined - | Term_app of decl_kind * func_decl * ast array + | Term_numeral of numeral_refined + | Term_app of decl_kind * func_decl * ast array | Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast - | Term_var of int * sort + | Term_var of int * sort (** Summary: \[ [ mk_term c tr ] \] constructs the term described by [tr]. - - {b Precondition}: [tr] is not of form - {b See also}: {!term_refine} *) (* val mk_term: context -> term_refined -> ast *) - - (** Summary: \[ [ term_refine c a ] \] is the refined view of [a]. *) @@ -3744,8 +3080,7 @@ val term_refine : context -> ast -> term_refined (** Summary: compare terms. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_ast', BOOL, (_in(CONTEXT), _in(AST), _in(AST))) *) external is_eq_ast : context -> ast -> ast -> bool @@ -3753,8 +3088,7 @@ external is_eq_ast : context -> ast -> ast -> bool (** Summary: Return a unique identifier for [t]. - - {b Remarks}: Implicitly used by [Pervasives.compare] for values of type [ast], [app], [sort], [func_decl], and [pattern]. - + - {b Remarks}: Implicitly used by [Pervasives.compare] for values of type [ast], [app], [sort], [func_decl], and [pattern]. def_API('get_ast_id', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_id : context -> ast -> int @@ -3762,8 +3096,7 @@ external get_ast_id : context -> ast -> int (** Summary: Return a hash code for the given AST. - - {b Remarks}: Implicitly used by [Hashtbl.hash] for values of type [ast], [app], [sort], [func_decl], and [pattern]. - + - {b Remarks}: Implicitly used by [Hashtbl.hash] for values of type [ast], [app], [sort], [func_decl], and [pattern]. def_API('get_ast_hash', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_hash : context -> ast -> int @@ -3771,9 +3104,7 @@ external get_ast_hash : context -> ast -> int (** Summary: Return the sort of an AST node. - The AST node must be a constant, application, numeral, bound variable, or quantifier. - def_API('get_sort', SORT, (_in(CONTEXT), _in(AST))) *) external get_sort : context -> ast -> sort @@ -3781,7 +3112,6 @@ external get_sort : context -> ast -> sort (** Summary: Return true if the given expression [t] is well sorted. - def_API('is_well_sorted', BOOL, (_in(CONTEXT), _in(AST))) *) external is_well_sorted : context -> ast -> bool @@ -3789,7 +3119,6 @@ external is_well_sorted : context -> ast -> bool (** Summary: Return L_TRUE if [a] is true, L_FALSE if it is false, and L_UNDEF otherwise. - def_API('get_bool_value', UINT, (_in(CONTEXT), _in(AST))) *) external get_bool_value : context -> ast -> lbool @@ -3797,14 +3126,13 @@ external get_bool_value : context -> ast -> lbool (** Summary: Return the kind of the given AST. - def_API('get_ast_kind', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_kind : context -> ast -> ast_kind = "camlidl_z3_Z3_get_ast_kind" (** - def_API('is_app', BOOL, (_in(CONTEXT), _in(AST))) + def_API('is_app', BOOL, (_in(CONTEXT), _in(AST))) *) external is_app : context -> ast -> bool = "camlidl_z3_Z3_is_app" @@ -3817,17 +3145,14 @@ external is_numeral_ast : context -> ast -> bool (** Summary: Return true if the give AST is a real algebraic number. - def_API('is_algebraic_number', BOOL, (_in(CONTEXT), _in(AST))) *) external is_algebraic_number : context -> ast -> bool = "camlidl_z3_Z3_is_algebraic_number" (** - Summary: Convert an [ast] into an [APP_AST]. - - - {b Precondition}: {v get_ast_kind c a == [APP_AST] v} - + Summary: Convert an [ast] into an [APP_AST]. + - {b Precondition}: {v get_ast_kind c a == [APP_AST] v} def_API('to_app', APP, (_in(CONTEXT), _in(AST))) *) external to_app : context -> ast -> app @@ -3835,33 +3160,28 @@ external to_app : context -> ast -> app (** Summary: Convert an AST into a FUNC_DECL_AST. This is just type casting. - - - {b Precondition}: {v get_ast_kind c a == FUNC_DECL_AST v} - + - {b Precondition}: {v get_ast_kind c a == FUNC_DECL_AST v} def_API('to_func_decl', FUNC_DECL, (_in(CONTEXT), _in(AST))) *) external to_func_decl : context -> ast -> func_decl = "camlidl_z3_Z3_to_func_decl" (** - {4 {L Numerals}} + {4 {L Numerals}} *) (** Summary: \[ [ numeral_refine c a ] \] is the refined view of [a]. - - {b Precondition}: [get_ast_kind c a = NUMERAL_AST] *) val numeral_refine : context -> ast -> numeral_refined (** - {5 {L Low-level API}} + {5 {L Low-level API}} *) (** Summary: Return numeral value, as a string of a numeric constant term - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_numeral_string', STRING, (_in(CONTEXT), _in(AST))) *) external get_numeral_string : context -> ast -> string @@ -3870,19 +3190,15 @@ external get_numeral_string : context -> ast -> string (** Summary: Return numeral as a string in decimal notation. The result has at most [precision] decimal places. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST || is_algebraic_number c a - - def_API('get_numeral_decimal_string', STRING, (_in(CONTEXT), _in(AST), _in(UINT))) + def_API('get_numeral_decimal_string', STRING, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_numeral_decimal_string : context -> ast -> int -> string = "camlidl_z3_Z3_get_numeral_decimal_string" (** Summary: Return the numerator (as a numeral AST) of a numeral AST of sort Real. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_numerator', AST, (_in(CONTEXT), _in(AST))) *) external get_numerator : context -> ast -> ast @@ -3890,9 +3206,7 @@ external get_numerator : context -> ast -> ast (** Summary: Return the denominator (as a numeral AST) of a numeral AST of sort Real. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_denominator', AST, (_in(CONTEXT), _in(AST))) *) external get_denominator : context -> ast -> ast @@ -3900,16 +3214,12 @@ external get_denominator : context -> ast -> ast (** Summary: Return numeral value, as a pair of 64 bit numbers if the representation fits. - @param c logical context. @param a term. @param num numerator. @param den denominator. - Return [TRUE] if the numeral value fits in 64 bit numerals, [FALSE] otherwise. - - {b Precondition}: get_ast_kind a == NUMERAL_AST - def_API('get_numeral_small', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) *) external get_numeral_small : context -> ast -> bool * int64 * int64 @@ -3919,11 +3229,8 @@ external get_numeral_small : context -> ast -> bool * int64 * int64 Summary: \[ [ get_numeral_int c v ] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit in a machine int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_int', BOOL, (_in(CONTEXT), _in(AST), _out(INT))) *) external get_numeral_int : context -> ast -> bool * int @@ -3933,11 +3240,8 @@ external get_numeral_int : context -> ast -> bool * int Summary: \[ [ get_numeral_int64 c v ] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit in a machine long long int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64))) *) external get_numeral_int64 : context -> ast -> bool * int64 @@ -3947,47 +3251,39 @@ external get_numeral_int64 : context -> ast -> bool * int64 Summary: \[ [ get_numeral_rational_int64 c x y] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit as a rational number as machine long long int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_rational_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) *) external get_numeral_rational_int64 : context -> ast -> bool * int64 * int64 = "camlidl_z3_Z3_get_numeral_rational_int64" (** - Summary: Return a lower bound for the given real algebraic number. + Summary: Return a lower bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real. - - {b Precondition}: is_algebraic_number c a - def_API('get_algebraic_number_lower', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_algebraic_number_lower : context -> ast -> int -> ast = "camlidl_z3_Z3_get_algebraic_number_lower" (** - Summary: Return a upper bound for the given real algebraic number. + Summary: Return a upper bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real. - - {b Precondition}: is_algebraic_number c a - def_API('get_algebraic_number_upper', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_algebraic_number_upper : context -> ast -> int -> ast = "camlidl_z3_Z3_get_algebraic_number_upper" (** - {4 {L Patterns}} + {4 {L Patterns}} *) (** - Summary: Convert a pattern into ast. - - {b Remarks}: [pattern_to_ast c p] can be replaced by [(p :> ast)]. - + Summary: Convert a pattern into ast. + - {b Remarks}: [pattern_to_ast c p] can be replaced by [(p :> ast)]. def_API('pattern_to_ast', AST, (_in(CONTEXT), _in(PATTERN))) *) external pattern_to_ast : context -> pattern -> ast @@ -3996,7 +3292,6 @@ external pattern_to_ast : context -> pattern -> ast (** Summary: \[ [ get_pattern_terms c p ] \] is the ast's in pattern. - - {b See also}: {!get_pattern_num_terms} - {b See also}: {!get_pattern} *) @@ -4004,7 +3299,6 @@ val get_pattern_terms: context -> pattern -> ast array;; (** Summary: Return number of terms in pattern. - def_API('get_pattern_num_terms', UINT, (_in(CONTEXT), _in(PATTERN))) *) external get_pattern_num_terms : context -> pattern -> int @@ -4012,20 +3306,17 @@ external get_pattern_num_terms : context -> pattern -> int (** Summary: Return i'th ast in pattern. - def_API('get_pattern', AST, (_in(CONTEXT), _in(PATTERN), _in(UINT))) *) external get_pattern : context -> pattern -> int -> ast = "camlidl_z3_Z3_get_pattern" (** - {4 {L Quantifiers}} + {4 {L Quantifiers}} *) (** Summary: Return index of de-Brujin bound variable. - - {b Precondition}: get_ast_kind a == VAR_AST - def_API('get_index_value', UINT, (_in(CONTEXT), _in(AST))) *) external get_index_value : context -> ast -> int @@ -4033,29 +3324,23 @@ external get_index_value : context -> ast -> int (** Summary: Determine if quantifier is universal. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - - def_API('is_quantifier_forall', BOOL, (_in(CONTEXT), _in(AST))) + def_API('is_quantifier_forall', BOOL, (_in(CONTEXT), _in(AST))) *) external is_quantifier_forall : context -> ast -> bool = "camlidl_z3_Z3_is_quantifier_forall" (** Summary: Obtain weight of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - - def_API('get_quantifier_weight', UINT, (_in(CONTEXT), _in(AST))) + def_API('get_quantifier_weight', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_weight : context -> ast -> int = "camlidl_z3_Z3_get_quantifier_weight" (** Summary: Return number of patterns used in quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_patterns', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_patterns : context -> ast -> int @@ -4063,9 +3348,7 @@ external get_quantifier_num_patterns : context -> ast -> int (** Summary: Return i'th pattern. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_pattern_ast', PATTERN, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_pattern_ast : context -> ast -> int -> pattern @@ -4073,9 +3356,7 @@ external get_quantifier_pattern_ast : context -> ast -> int -> pattern (** Summary: Return number of no_patterns used in quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_no_patterns', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_no_patterns : context -> ast -> int @@ -4083,9 +3364,7 @@ external get_quantifier_num_no_patterns : context -> ast -> int (** Summary: Return i'th no_pattern. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_no_pattern_ast', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_no_pattern_ast : context -> ast -> int -> ast @@ -4093,9 +3372,7 @@ external get_quantifier_no_pattern_ast : context -> ast -> int -> ast (** Summary: Return number of bound variables of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_bound', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_bound : context -> ast -> int @@ -4103,9 +3380,7 @@ external get_quantifier_num_bound : context -> ast -> int (** Summary: Return symbol of the i'th bound variable. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_bound_name', SYMBOL, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_bound_name : context -> ast -> int -> symbol @@ -4113,9 +3388,7 @@ external get_quantifier_bound_name : context -> ast -> int -> symbol (** Summary: Return sort of the i'th bound variable. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_bound_sort', SORT, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_bound_sort : context -> ast -> int -> sort @@ -4123,22 +3396,18 @@ external get_quantifier_bound_sort : context -> ast -> int -> sort (** Summary: Return body of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_body', AST, (_in(CONTEXT), _in(AST))) *) external get_quantifier_body : context -> ast -> ast = "camlidl_z3_Z3_get_quantifier_body" (** - {3 {L Simplification}} + {3 {L Simplification}} *) (** Summary: Interface to simplifier. - Provides an interface to the AST simplifier used by Z3. - def_API('simplify', AST, (_in(CONTEXT), _in(AST))) *) external simplify : context -> ast -> ast @@ -4146,11 +3415,9 @@ external simplify : context -> ast -> ast (** Summary: Interface to simplifier. - Provides an interface to the AST simplifier used by Z3. - This procedure is similar to {!simplify}, but the behavior of the simplifier + This procedure is similar to {!simplify}, but the behavior of the simplifier can be configured using the given parameter set. - def_API('simplify_ex', AST, (_in(CONTEXT), _in(AST), _in(PARAMS))) *) external simplify_ex : context -> ast -> params -> ast @@ -4158,7 +3425,6 @@ external simplify_ex : context -> ast -> params -> ast (** Summary: Return a string describing all available parameters. - def_API('simplify_get_help', STRING, (_in(CONTEXT),)) *) external simplify_get_help : context -> string @@ -4166,7 +3432,6 @@ external simplify_get_help : context -> string (** Summary: Return the parameter description set for the simplify procedure. - def_API('simplify_get_param_descrs', PARAM_DESCRS, (_in(CONTEXT),)) *) external simplify_get_param_descrs : context -> param_descrs @@ -4177,10 +3442,9 @@ external simplify_get_param_descrs : context -> param_descrs *) (** Summary: Update the arguments of term [a] using the arguments [args]. - The number of arguments [num_args] should coincide + The number of arguments [num_args] should coincide with the number of arguments to [a]. If [a] is a quantifier, then num_args has to be 1. - def_API('update_term', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST))) *) external update_term : context -> ast -> ast array -> ast @@ -4190,7 +3454,6 @@ external update_term : context -> ast -> ast array -> ast Summary: Substitute every occurrence of {e from[i] } in [a] with {e to[i] }, for [i] smaller than [num_exprs]. The result is the new AST. The arrays [from] and [to] must have size [num_exprs]. For every [i] smaller than [num_exprs], we must have that sort of {e from[i] } must be equal to sort of {e to[i] }. - def_API('substitute', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST), _in_array(2, AST))) *) external substitute : context -> ast -> ast array -> ast array -> ast @@ -4199,7 +3462,6 @@ external substitute : context -> ast -> ast array -> ast array -> ast (** Summary: Substitute the free variables in [a] with the expressions in [to]. For every [i] smaller than [num_exprs], the variable with de-Bruijn index [i] is replaced with term {e to[i] }. - def_API('substitute_vars', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST))) *) external substitute_vars : context -> ast -> ast array -> ast @@ -4209,7 +3471,6 @@ external substitute_vars : context -> ast -> ast array -> ast Summary: Translate/Copy the AST [a] from context [source] to context [target]. AST [a] must have been created using context [source]. - {b Precondition}: source != target - def_API('translate', AST, (_in(CONTEXT), _in(AST), _in(CONTEXT))) *) external translate : context -> ast -> context -> ast @@ -4232,45 +3493,36 @@ type model_refined = { } -(** +(** Summary: [model_refine c m] is the refined model of [m]. *) val model_refine : context -> model -> model_refined (** Summary: \[ [ model_eval c m t ] \] - Evaluate the AST node [t] in the given model. - - Return [None] if the term was not successfully evaluated. - + Evaluate the AST node [t] in the given model. + Return [None] if the term was not successfully evaluated. If [model_completion] is TRUE, then Z3 will assign an interpretation for any constant or function that does not have an interpretation in [m]. These constants and functions were essentially don't cares. - The evaluation may fail for the following reasons: - - [t] contains a quantifier. - - the model [m] is partial, that is, it doesn't have a complete interpretation for uninterpreted functions. That is, the option {e MODEL_PARTIAL=true } was used. - - [t] is type incorrect. - def_API('model_eval', BOOL, (_in(CONTEXT), _in(MODEL), _in(AST), _in(BOOL), _out(AST))) *) external model_eval : context -> model -> ast -> bool -> ast option = "camlidl_z3_Z3_model_eval" (** - {4 {L Low-level API}} + {4 {L Low-level API}} *) (** Summary: Return the interpretation (i.e., assignment) of constant [a] in the model [m]. - Return [None], - if the model does not assign an interpretation for [a]. + Return [None], + if the model does not assign an interpretation for [a]. That should be interpreted as: the value of [a] does not matter. - - {b Precondition}: get_arity c a == 0 - def_API('model_get_const_interp', AST, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL))) *) external model_get_const_interp : context -> model -> func_decl -> ast option @@ -4278,15 +3530,10 @@ external model_get_const_interp : context -> model -> func_decl -> ast option (** Summary: Return the interpretation of the function [f] in the model [m]. - Return [None], - if the model does not assign an interpretation for [f]. + Return [None], + if the model does not assign an interpretation for [f]. That should be interpreted as: the [f] does not matter. - - {b Precondition}: get_arity c f > 0 - - - - def_API('model_get_func_interp', FUNC_INTERP, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL))) *) external model_get_func_interp : context -> model -> func_decl -> func_interp option @@ -4294,9 +3541,7 @@ external model_get_func_interp : context -> model -> func_decl -> func_interp op (** Summary: Return the number of constants assigned by the given model. - - {b See also}: {!model_get_const_decl} - def_API('model_get_num_consts', UINT, (_in(CONTEXT), _in(MODEL))) *) external model_get_num_consts : context -> model -> int @@ -4304,12 +3549,9 @@ external model_get_num_consts : context -> model -> int (** Summary: \[ [ model_get_const_decl c m i ] \] - Return the i-th constant in the given model. - + Return the i-th constant in the given model. - {b Precondition}: i < model_get_num_consts c m - - {b See also}: {!model_eval} - def_API('model_get_const_decl', FUNC_DECL, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external model_get_const_decl : context -> model -> int -> func_decl @@ -4317,10 +3559,8 @@ external model_get_const_decl : context -> model -> int -> func_decl (** Summary: Return the number of function interpretations in the given model. - 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. - def_API('model_get_num_funcs', UINT, (_in(CONTEXT), _in(MODEL))) *) external model_get_num_funcs : context -> model -> int @@ -4329,11 +3569,8 @@ external model_get_num_funcs : context -> model -> int (** Summary: \[ [ model_get_func_decl c m i ] \] Return the declaration of the i-th function in the given model. - - {b Precondition}: i < model_get_num_funcs c m - - {b See also}: {!model_get_num_funcs} - def_API('model_get_func_decl', FUNC_DECL, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external model_get_func_decl : context -> model -> int -> func_decl @@ -4341,14 +3578,11 @@ external model_get_func_decl : context -> model -> int -> func_decl (** Summary: Return the number of uninterpreted sorts that [m] assigs an interpretation to. - Z3 also provides an intepretation for uninterpreted sorts used in a formua. The interpretation for a sort [s] is a finite set of distinct values. We say this finite set is the "universe" of [s]. - - {b See also}: {!model_get_sort} - {b See also}: {!model_get_sort_universe} - def_API('model_get_num_sorts', UINT, (_in(CONTEXT), _in(MODEL))) *) external model_get_num_sorts : context -> model -> int @@ -4356,12 +3590,9 @@ external model_get_num_sorts : context -> model -> int (** Summary: Return a uninterpreted sort that [m] assigns an interpretation. - - {b Precondition}: i < model_get_num_sorts c m - - {b See also}: {!model_get_num_sorts} - {b See also}: {!model_get_sort_universe} - def_API('model_get_sort', SORT, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external model_get_sort : context -> model -> int -> sort @@ -4369,10 +3600,8 @@ external model_get_sort : context -> model -> int -> sort (** Summary: Return the finite set of distinct values that represent the interpretation for sort [s]. - - {b See also}: {!model_get_num_sorts} - {b See also}: {!model_get_sort} - def_API('model_get_sort_universe', AST_VECTOR, (_in(CONTEXT), _in(MODEL), _in(SORT))) *) external model_get_sort_universe : context -> model -> sort -> ast_vector @@ -4382,11 +3611,8 @@ external model_get_sort_universe : context -> model -> sort -> ast_vector Summary: The {e (_ as-array f) } AST node is a construct for assigning interpretations for arrays in Z3. It is the array such that forall indices [i] we have that {e (select (_ as-array f) i) } is equal to {e (f i) }. This procedure returns TRUE if the [a] is an [as-array] AST node. - - Z3 current solvers have minimal support for [as_array] nodes. - + Z3 current solvers have minimal support for [as_array] nodes. - {b See also}: {!get_as_array_func_decl} - def_API('is_as_array', BOOL, (_in(CONTEXT), _in(AST))) *) external is_as_array : context -> ast -> bool @@ -4394,9 +3620,7 @@ external is_as_array : context -> ast -> bool (** Summary: Return the function declaration [f] associated with a {e (_ as_array f) } node. - - {b See also}: {!is_as_array} - def_API('get_as_array_func_decl', FUNC_DECL, (_in(CONTEXT), _in(AST))) *) external get_as_array_func_decl : context -> ast -> func_decl @@ -4404,11 +3628,9 @@ external get_as_array_func_decl : context -> ast -> func_decl (** Summary: Return the number of entries in the given function interpretation. - 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. This procedure return the number of element in the finite map of [f]. - def_API('func_interp_get_num_entries', UINT, (_in(CONTEXT), _in(FUNC_INTERP))) *) external func_interp_get_num_entries : context -> func_interp -> int @@ -4417,11 +3639,8 @@ external func_interp_get_num_entries : context -> func_interp -> int (** Summary: Return a "point" of the given function intepretation. It represents the value of [f] in a particular point. - - {b Precondition}: i < func_interp_get_num_entries c f - - {b See also}: {!func_interp_get_num_entries} - def_API('func_interp_get_entry', FUNC_ENTRY, (_in(CONTEXT), _in(FUNC_INTERP), _in(UINT))) *) external func_interp_get_entry : context -> func_interp -> int -> func_entry @@ -4429,10 +3648,8 @@ external func_interp_get_entry : context -> func_interp -> int -> func_entry (** Summary: Return the 'else' value of the given function interpretation. - A function interpretation is represented as a finite map and an 'else' value. This procedure returns the 'else' value. - def_API('func_interp_get_else', AST, (_in(CONTEXT), _in(FUNC_INTERP))) *) external func_interp_get_else : context -> func_interp -> ast @@ -4440,20 +3657,16 @@ external func_interp_get_else : context -> func_interp -> ast (** Summary: Return the arity (number of arguments) of the given function interpretation. - def_API('func_interp_get_arity', UINT, (_in(CONTEXT), _in(FUNC_INTERP))) *) external func_interp_get_arity : context -> func_interp -> int = "camlidl_z3_Z3_func_interp_get_arity" (** - Summary: Return the value of this point. - + Summary: Return the value of this point. A func_entry object represents an element in the finite map used to encode a function interpretation. - - {b See also}: {!func_interp_get_entry} - def_API('func_entry_get_value', AST, (_in(CONTEXT), _in(FUNC_ENTRY))) *) external func_entry_get_value : context -> func_entry -> ast @@ -4461,9 +3674,7 @@ external func_entry_get_value : context -> func_entry -> ast (** Summary: Return the number of arguments in a func_entry object. - - {b See also}: {!func_interp_get_entry} - def_API('func_entry_get_num_args', UINT, (_in(CONTEXT), _in(FUNC_ENTRY))) *) external func_entry_get_num_args : context -> func_entry -> int @@ -4471,11 +3682,8 @@ external func_entry_get_num_args : context -> func_entry -> int (** Summary: Return an argument of a func_entry object. - - {b Precondition}: i < func_entry_get_num_args c e - - {b See also}: {!func_interp_get_entry} - def_API('func_entry_get_arg', AST, (_in(CONTEXT), _in(FUNC_ENTRY), _in(UINT))) *) external func_entry_get_arg : context -> func_entry -> int -> ast @@ -4486,7 +3694,6 @@ external func_entry_get_arg : context -> func_entry -> int -> ast *) (** Summary: Log interaction to a file. - extra_API('open_log', INT, (_in(STRING),)) *) external open_log : string -> bool @@ -4494,11 +3701,9 @@ external open_log : string -> bool (** Summary: Append user-defined string to interaction log. - The interaction log is opened using open_log. It contains the formulas that are checked using Z3. You can use this command to append comments, for instance. - extra_API('append_log', VOID, (_in(STRING),)) *) external append_log : string -> unit @@ -4506,7 +3711,6 @@ external append_log : string -> unit (** Summary: Close interaction log. - extra_API('close_log', VOID, ()) *) external close_log : unit -> unit @@ -4514,10 +3718,8 @@ external close_log : unit -> unit (** Summary: Enable/disable printing warning messages to the console. - Warnings are printed after passing [true], warning messages are - suppressed after calling this method with [false]. - + suppressed after calling this method with [false]. def_API('toggle_warning_messages', VOID, (_in(BOOL),)) *) external toggle_warning_messages : bool -> unit @@ -4528,19 +3730,16 @@ external toggle_warning_messages : bool -> unit *) (** Summary: Select mode for the format used for pretty-printing AST nodes. - The default mode for pretty printing AST nodes is to produce - SMT-LIB style output where common subexpressions are printed + SMT-LIB style output where common subexpressions are printed at each occurrence. The mode is called PRINT_SMTLIB_FULL. - To print shared common subexpressions only once, + To print shared common subexpressions only once, use the PRINT_LOW_LEVEL mode. To print in way that conforms to SMT-LIB standards and uses let expressions to share common sub-expressions use PRINT_SMTLIB_COMPLIANT. - - {b See also}: {!ast_to_string} - {b See also}: {!pattern_to_string} - {b See also}: {!func_decl_to_string} - def_API('set_ast_print_mode', VOID, (_in(CONTEXT), _in(PRINT_MODE))) *) external set_ast_print_mode : context -> ast_print_mode -> unit @@ -4548,13 +3747,8 @@ external set_ast_print_mode : context -> ast_print_mode -> unit (** Summary: Convert the given AST node into a string. - - - - - {b See also}: {!pattern_to_string} - {b See also}: {!sort_to_string} - def_API('ast_to_string', STRING, (_in(CONTEXT), _in(AST))) *) external ast_to_string : context -> ast -> string @@ -4580,11 +3774,6 @@ external func_decl_to_string : context -> func_decl -> string (** Summary: Convert the given model into a string. - - - - - def_API('model_to_string', STRING, (_in(CONTEXT), _in(MODEL))) *) external model_to_string : context -> model -> string @@ -4592,20 +3781,14 @@ external model_to_string : context -> model -> string (** Summary: Convert the given benchmark into SMT-LIB formatted string. - - - - - @param c - context. @param name - name of benchmark. The argument is optional. - @param logic - the benchmark logic. + @param logic - the benchmark logic. @param status - the status string (sat, unsat, or unknown) @param attributes - other attributes, such as source, difficulty or category. @param num_assumptions - number of assumptions. @param assumptions - auxiliary assumptions. @param formula - formula to be checked for consistency in conjunction with assumptions. - def_API('benchmark_to_smtlib_string', STRING, (_in(CONTEXT), _in(STRING), _in(STRING), _in(STRING), _in(STRING), _in(UINT), _in_array(5, AST), _in(AST))) *) external benchmark_to_smtlib_string : context -> string -> string -> string -> string -> ast array -> ast -> string @@ -4616,11 +3799,9 @@ external benchmark_to_smtlib_string : context -> string -> string -> string -> s *) (** Summary: \[ [ parse_smtlib2_string c str ] \] - Parse the given string using the SMT-LIB2 parser. - + Parse the given string using the SMT-LIB2 parser. It returns a formula comprising of the conjunction of assertions in the scope (up to push/pop) at the end of the string. - def_API('parse_smtlib2_string', AST, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib2_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast @@ -4628,7 +3809,6 @@ external parse_smtlib2_string : context -> string -> symbol array -> sort array (** Summary: Similar to {!parse_smtlib2_string}, but reads the benchmark from a file. - def_API('parse_smtlib2_file', AST, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib2_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast @@ -4637,57 +3817,45 @@ external parse_smtlib2_file : context -> string -> symbol array -> sort array -> (** Summary: \[ [ parse_smtlib_string_x c str sort_names sorts decl_names decls ] \] - - Parse the given string using the SMT-LIB parser. - - The symbol table of the parser can be initialized using the given sorts and declarations. + Parse the given string using the SMT-LIB parser. + The symbol table of the parser can be initialized using the given sorts and declarations. The symbols in the arrays [sort_names] and [decl_names] don't need to match the names of the sorts and declarations in the arrays [sorts] and [decls]. This is an useful feature since we can use arbitrary names to reference sorts and declarations defined using the API. - - {b See also}: {!parse_smtlib_file_x} *) val parse_smtlib_string_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array) - (** Summary: Similar to {!parse_smtlib_string_x}, but reads the benchmark from a file. - - {b See also}: {!parse_smtlib_string_x} *) val parse_smtlib_file_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array) - (** Summary: \[ [ parse_smtlib_string_formula c ... ] \] calls [(parse_smtlib_string c ...)] and returns the single formula produced. - - {b See also}: {!parse_smtlib_file_formula} - {b See also}: {!parse_smtlib_string_x} *) val parse_smtlib_string_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - (** Summary: \[ [ parse_smtlib_file_formula c ... ] \] calls [(parse_smtlib_file c ...)] and returns the single formula produced. - - {b See also}: {!parse_smtlib_string_formula} - {b See also}: {!parse_smtlib_file_x} *) val parse_smtlib_file_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast (** - {4 {L Low-level API}} + {4 {L Low-level API}} *) (** Summary: \[ [ parse_smtlib_string c str sort_names sorts decl_names decls ] \] - Parse the given string using the SMT-LIB parser. - - The symbol table of the parser can be initialized using the given sorts and declarations. + Parse the given string using the SMT-LIB parser. + The symbol table of the parser can be initialized using the given sorts and declarations. The symbols in the arrays [sort_names] and [decl_names] don't need to match the names of the sorts and declarations in the arrays [sorts] and [decls]. This is an useful feature since we can use arbitrary names to reference sorts and declarations defined using the C API. - The formulas, assumptions and declarations defined in [str] can be extracted using the functions: - {!get_smtlib_num_formulas}, {!get_smtlib_formula}, {!get_smtlib_num_assumptions}, {!get_smtlib_assumption}, + {!get_smtlib_num_formulas}, {!get_smtlib_formula}, {!get_smtlib_num_assumptions}, {!get_smtlib_assumption}, {!get_smtlib_num_decls}, and {!get_smtlib_decl}. - def_API('parse_smtlib_string', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit @@ -4695,7 +3863,6 @@ external parse_smtlib_string : context -> string -> symbol array -> sort array - (** Summary: Similar to {!parse_smtlib_string}, but reads the benchmark from a file. - def_API('parse_smtlib_file', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit @@ -4703,7 +3870,6 @@ external parse_smtlib_file : context -> string -> symbol array -> sort array -> (** Summary: Return the number of SMTLIB formulas parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_formulas', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_formulas : context -> int @@ -4712,9 +3878,7 @@ external get_smtlib_num_formulas : context -> int (** Summary: \[ [ get_smtlib_formula c i ] \] Return the i-th formula parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_formulas c - def_API('get_smtlib_formula', AST, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_formula : context -> int -> ast @@ -4722,7 +3886,6 @@ external get_smtlib_formula : context -> int -> ast (** Summary: Return the number of SMTLIB assumptions parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_assumptions', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_assumptions : context -> int @@ -4731,9 +3894,7 @@ external get_smtlib_num_assumptions : context -> int (** Summary: \[ [ get_smtlib_assumption c i ] \] Return the i-th assumption parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_assumptions c - def_API('get_smtlib_assumption', AST, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_assumption : context -> int -> ast @@ -4741,7 +3902,6 @@ external get_smtlib_assumption : context -> int -> ast (** Summary: Return the number of declarations parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_decls', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_decls : context -> int @@ -4750,9 +3910,7 @@ external get_smtlib_num_decls : context -> int (** Summary: \[ [ get_smtlib_decl c i ] \] Return the i-th declaration parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_decls c - def_API('get_smtlib_decl', FUNC_DECL, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_decl : context -> int -> func_decl @@ -4760,7 +3918,6 @@ external get_smtlib_decl : context -> int -> func_decl (** Summary: Return the number of sorts parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_sorts', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_sorts : context -> int @@ -4769,9 +3926,7 @@ external get_smtlib_num_sorts : context -> int (** Summary: \[ [ get_smtlib_sort c i ] \] Return the i-th sort parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_sorts c - def_API('get_smtlib_sort', SORT, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_sort : context -> int -> sort @@ -4781,38 +3936,17 @@ external get_smtlib_sort : context -> int -> sort (** Summary: \[ [ get_smtlib_error c ] \] Retrieve that last error message information generated from parsing. - def_API('get_smtlib_error', STRING, (_in(CONTEXT), )) *) external get_smtlib_error : context -> string = "camlidl_z3_Z3_get_smtlib_error" *) -(** - Summary: \[ [ parse_z3_string c str ] \] - Parse the given string using the Z3 native parser. - - Return the conjunction of asserts made in the input. - - def_API('parse_z3_string', AST, (_in(CONTEXT), _in(STRING))) -*) -external parse_z3_string : context -> string -> ast - = "camlidl_z3_Z3_parse_z3_string" - -(** - Summary: Similar to {!parse_z3_string}, but reads the benchmark from a file. - - def_API('parse_z3_file', AST, (_in(CONTEXT), _in(STRING))) -*) -external parse_z3_file : context -> string -> ast - = "camlidl_z3_Z3_parse_z3_file" - (** {2 {L Error Handling}} *) (** Summary: Set an error. - def_API('set_error', VOID, (_in(CONTEXT), _in(ERROR_CODE))) *) external set_error : context -> error_code -> unit @@ -4821,7 +3955,6 @@ external set_error : context -> error_code -> unit (* (** Summary: Return a string describing the given error code. - def_API('get_error_msg_ex', STRING, (_in(CONTEXT), _in(ERROR_CODE))) *) external get_error_msg_ex : context -> error_code -> string @@ -4831,7 +3964,7 @@ external get_error_msg_ex : context -> error_code -> string (** Summary: Return a string describing the given error code. -*) +*) val get_error_msg: context -> error_code -> string (** @@ -4839,21 +3972,32 @@ val get_error_msg: context -> error_code -> string *) (** Summary: Return Z3 version number information. - def_API('get_version', VOID, (_out(UINT), _out(UINT), _out(UINT), _out(UINT))) *) external get_version : unit -> int * int * int * int = "camlidl_z3_Z3_get_version" +(** + Summary: Enable tracing messages tagged as [tag] when Z3 is compiled in debug mode. + It is a NOOP otherwise + def_API('enable_trace', VOID, (_in(STRING),)) +*) +external enable_trace : string -> unit + = "camlidl_z3_Z3_enable_trace" + +(** + Summary: Disable tracing messages tagged as [tag] when Z3 is compiled in debug mode. + It is a NOOP otherwise + def_API('disable_trace', VOID, (_in(STRING),)) +*) +external disable_trace : string -> unit + = "camlidl_z3_Z3_disable_trace" + (** {2 {L Fixedpoint facilities}} *) (** - Summary: Create a new fixedpoint context. - - - - + Summary: Create a new fixedpoint context. def_API('mk_fixedpoint', FIXEDPOINT, (_in(CONTEXT), )) *) external mk_fixedpoint : context -> fixedpoint @@ -4862,33 +4006,27 @@ external mk_fixedpoint : context -> fixedpoint (** Summary: Add a universal Horn clause as a named rule. The [horn_rule] should be of the form: - - {v + {v horn_rule ::= (forall (bound-vars) horn_rule) - | (=> atoms horn_rule) - | atom + | (=> atoms horn_rule) + | atom v} - def_API('fixedpoint_add_rule', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST), _in(SYMBOL))) *) external fixedpoint_add_rule : context -> fixedpoint -> ast -> symbol -> unit = "camlidl_z3_Z3_fixedpoint_add_rule" (** - Summary: Add a Database fact. - + Summary: Add a Database fact. @param c - context @param d - fixed point context @param r - relation signature for the row. - @param num_args - number of columns for the given row. + @param num_args - number of columns for the given row. @param args - array of the row elements. - - The number of arguments [num_args] should be equal to the number + The number of arguments [num_args] should be equal to the number of sorts in the domain of [r]. Each sort in the domain should be an integral (bit-vector, Boolean or or finite domain sort). - - The call has the same effect as adding a rule where is applied to the arguments. - + The call has the same effect as adding a rule where [r] is applied to the arguments. def_API('fixedpoint_add_fact', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL), _in(UINT), _in_array(3, UINT))) *) external fixedpoint_add_fact : context -> fixedpoint -> func_decl -> int array -> unit @@ -4896,10 +4034,8 @@ external fixedpoint_add_fact : context -> fixedpoint -> func_decl -> int array - (** Summary: Assert a constraint to the fixedpoint context. - The constraints are used as background axioms when the fixedpoint engine uses the PDR mode. They are ignored for standard Datalog mode. - def_API('fixedpoint_assert', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST))) *) external fixedpoint_assert : context -> fixedpoint -> ast -> unit @@ -4907,17 +4043,14 @@ external fixedpoint_assert : context -> fixedpoint -> ast -> unit (** Summary: Pose a query against the asserted rules. - - {v + {v query ::= (exists (bound-vars) query) - | literals + | literals v} - - query returns + query returns - L_FALSE if the query is unsatisfiable. - L_TRUE if the query is satisfiable. Obtain the answer by calling {!fixedpoint_get_answer}. - L_UNDEF if the query was interrupted, timed out or otherwise failed. - def_API('fixedpoint_query', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST))) *) external fixedpoint_query : context -> fixedpoint -> ast -> lbool @@ -4925,14 +4058,11 @@ external fixedpoint_query : context -> fixedpoint -> ast -> lbool (** Summary: Pose multiple queries against the asserted rules. - The queries are encoded as relations (function declarations). - - query returns + query returns - L_FALSE if the query is unsatisfiable. - L_TRUE if the query is satisfiable. Obtain the answer by calling {!fixedpoint_get_answer}. - L_UNDEF if the query was interrupted, timed out or otherwise failed. - def_API('fixedpoint_query_relations', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(UINT), _in_array(2, FUNC_DECL))) *) external fixedpoint_query_relations : context -> fixedpoint -> func_decl array -> lbool @@ -4940,14 +4070,10 @@ external fixedpoint_query_relations : context -> fixedpoint -> func_decl array - (** Summary: Retrieve a formula that encodes satisfying answers to the query. - - When used in Datalog mode, the returned answer is a disjunction of conjuncts. Each conjunct encodes values of the bound variables of the query that are satisfied. In PDR mode, the returned answer is a single conjunction. - The previous call to fixedpoint_query must have returned L_TRUE. - def_API('fixedpoint_get_answer', AST, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_get_answer : context -> fixedpoint -> ast @@ -4955,18 +4081,15 @@ external fixedpoint_get_answer : context -> fixedpoint -> ast (** Summary: Retrieve a string that describes the last status returned by {!fixedpoint_query}. - Use this method when {!fixedpoint_query} returns L_UNDEF. - def_API('fixedpoint_get_reason_unknown', STRING, (_in(CONTEXT), _in(FIXEDPOINT) )) *) external fixedpoint_get_reason_unknown : context -> fixedpoint -> string = "camlidl_z3_Z3_fixedpoint_get_reason_unknown" (** - Summary: Update a named rule. + Summary: Update a named rule. A rule with the same name must have been previously created. - def_API('fixedpoint_update_rule', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST), _in(SYMBOL))) *) external fixedpoint_update_rule : context -> fixedpoint -> ast -> symbol -> unit @@ -4974,11 +4097,9 @@ external fixedpoint_update_rule : context -> fixedpoint -> ast -> symbol -> unit (** Summary: Query the PDR engine for the maximal levels properties are known about predicate. - - This call retrieves the maximal number of relevant unfoldings + This call retrieves the maximal number of relevant unfoldings of [pred] with respect to the current exploration state. Note: this functionality is PDR specific. - def_API('fixedpoint_get_num_levels', UINT, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL))) *) external fixedpoint_get_num_levels : context -> fixedpoint -> func_decl -> int @@ -4989,9 +4110,7 @@ external fixedpoint_get_num_levels : context -> fixedpoint -> func_decl -> int Return just the delta that is known at [level]. To obtain the full set of properties of [pred] one should query at [level+1] , [level+2] etc, and include [level=-1]. - Note: this functionality is PDR specific. - def_API('fixedpoint_get_cover_delta', AST, (_in(CONTEXT), _in(FIXEDPOINT), _in(INT), _in(FUNC_DECL))) *) external fixedpoint_get_cover_delta : context -> fixedpoint -> int -> func_decl -> ast @@ -4999,14 +4118,11 @@ external fixedpoint_get_cover_delta : context -> fixedpoint -> int -> func_decl (** Summary: Add property about the predicate [pred]. - Add a property of predicate [pred] at [level]. + Add a property of predicate [pred] at [level]. It gets pushed forward when possible. - Note: level = -1 is treated as the fixedpoint. So passing -1 for the [level] means that the property is true of the fixed-point unfolding with respect to [pred]. - Note: this functionality is PDR specific. - def_API('fixedpoint_add_cover', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(INT), _in(FUNC_DECL), _in(AST))) *) external fixedpoint_add_cover : context -> fixedpoint -> int -> func_decl -> ast -> unit @@ -5014,7 +4130,6 @@ external fixedpoint_add_cover : context -> fixedpoint -> int -> func_decl -> ast (** Summary: Retrieve statistics information from the last call to {!fixedpoint_query}. - def_API('fixedpoint_get_statistics', STATS, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_get_statistics : context -> fixedpoint -> stats @@ -5025,7 +4140,6 @@ external fixedpoint_get_statistics : context -> fixedpoint -> stats Fixedpoint defined relations have least-fixedpoint semantics. For example, the relation is empty if it does not occur in a head or a fact. - def_API('fixedpoint_register_relation', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL))) *) external fixedpoint_register_relation : context -> fixedpoint -> func_decl -> unit @@ -5033,29 +4147,30 @@ external fixedpoint_register_relation : context -> fixedpoint -> func_decl -> un (** Summary: Configure the predicate representation. - It sets the predicate to use a set of domains given by the list of symbols. The domains given by the list of symbols must belong to a set of built-in domains. - def_API('fixedpoint_set_predicate_representation', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL), _in(UINT), _in_array(3, SYMBOL))) *) external fixedpoint_set_predicate_representation : context -> fixedpoint -> func_decl -> symbol array -> unit = "camlidl_z3_Z3_fixedpoint_set_predicate_representation" (** - Summary: Simplify rules into a set of new rules that are returned. - The simplification routines apply inlining, quantifier elimination, and other - algebraic simplifications. - - def_API('fixedpoint_simplify_rules', AST_VECTOR, (_in(CONTEXT), _in(FIXEDPOINT), _in(UINT), _in_array(2,AST), _in(UINT), _in_array(4,FUNC_DECL))) + Summary: Retrieve set of rules from fixedpoint context. + def_API('fixedpoint_get_rules', AST_VECTOR, (_in(CONTEXT),_in(FIXEDPOINT))) *) -external fixedpoint_simplify_rules : context -> fixedpoint -> ast array -> func_decl array -> ast_vector - = "camlidl_z3_Z3_fixedpoint_simplify_rules" +external fixedpoint_get_rules : context -> fixedpoint -> ast_vector + = "camlidl_z3_Z3_fixedpoint_get_rules" (** - Summary: Set parameters on fixedpoint context. + Summary: Retrieve set of background assertions from fixedpoint context. + def_API('fixedpoint_get_assertions', AST_VECTOR, (_in(CONTEXT),_in(FIXEDPOINT))) +*) +external fixedpoint_get_assertions : context -> fixedpoint -> ast_vector + = "camlidl_z3_Z3_fixedpoint_get_assertions" +(** + Summary: Set parameters on fixedpoint context. def_API('fixedpoint_set_params', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(PARAMS))) *) external fixedpoint_set_params : context -> fixedpoint -> params -> unit @@ -5063,7 +4178,6 @@ external fixedpoint_set_params : context -> fixedpoint -> params -> unit (** Summary: Return a string describing all fixedpoint available parameters. - def_API('fixedpoint_get_help', STRING, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_get_help : context -> fixedpoint -> string @@ -5071,7 +4185,6 @@ external fixedpoint_get_help : context -> fixedpoint -> string (** Summary: Return the parameter description set for the given fixedpoint object. - def_API('fixedpoint_get_param_descrs', PARAM_DESCRS, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_get_param_descrs : context -> fixedpoint -> param_descrs @@ -5083,20 +4196,40 @@ external fixedpoint_get_param_descrs : context -> fixedpoint -> param_descrs @param f - fixedpoint context. @param num_queries - number of additional queries to print. @param queries - additional queries. - def_API('fixedpoint_to_string', STRING, (_in(CONTEXT), _in(FIXEDPOINT), _in(UINT), _in_array(2, AST))) *) external fixedpoint_to_string : context -> fixedpoint -> ast array -> string = "camlidl_z3_Z3_fixedpoint_to_string" +(** + Summary: Parse an SMT-LIB2 string with fixedpoint rules. + Add the rules to the current fixedpoint context. + Return the set of queries in the file. + @param c - context. + @param f - fixedpoint context. + @param s - string containing SMT2 specification. + def_API('fixedpoint_from_string', AST_VECTOR, (_in(CONTEXT), _in(FIXEDPOINT), _in(STRING))) +*) +external fixedpoint_from_string : context -> fixedpoint -> string -> ast_vector + = "camlidl_z3_Z3_fixedpoint_from_string" + +(** + Summary: Parse an SMT-LIB2 file with fixedpoint rules. + Add the rules to the current fixedpoint context. + Return the set of queries in the file. + @param c - context. + @param f - fixedpoint context. + @param s - string containing SMT2 specification. + def_API('fixedpoint_from_file', AST_VECTOR, (_in(CONTEXT), _in(FIXEDPOINT), _in(STRING))) +*) +external fixedpoint_from_file : context -> fixedpoint -> string -> ast_vector + = "camlidl_z3_Z3_fixedpoint_from_file" + (** Summary: Create a backtracking point. - The fixedpoint solver contains a set of rules, added facts and assertions. The set of rules, facts and assertions are restored upon calling {!fixedpoint_pop}. - - {b See also}: {!fixedpoint_pop} - def_API('fixedpoint_push', VOID, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_push : context -> fixedpoint -> unit @@ -5104,11 +4237,8 @@ external fixedpoint_push : context -> fixedpoint -> unit (** Summary: Backtrack one backtracking point. - - {b See also}: {!fixedpoint_push} - - {b Precondition}: The number of calls to pop cannot exceed calls to push. - def_API('fixedpoint_pop', VOID, (_in(CONTEXT), _in(FIXEDPOINT))) *) external fixedpoint_pop : context -> fixedpoint -> unit @@ -5119,10 +4249,6 @@ external fixedpoint_pop : context -> fixedpoint -> unit *) (** Summary: Return an empty AST vector. - - - - def_API('mk_ast_vector', AST_VECTOR, (_in(CONTEXT),)) *) external mk_ast_vector : context -> ast_vector @@ -5130,7 +4256,6 @@ external mk_ast_vector : context -> ast_vector (** Summary: Return the size of the given AST vector. - def_API('ast_vector_size', UINT, (_in(CONTEXT), _in(AST_VECTOR))) *) external ast_vector_size : context -> ast_vector -> int @@ -5138,27 +4263,22 @@ external ast_vector_size : context -> ast_vector -> int (** Summary: Return the AST at position [i] in the AST vector [v]. - - {b Precondition}: i < ast_vector_size c v - def_API('ast_vector_get', AST, (_in(CONTEXT), _in(AST_VECTOR), _in(UINT))) *) external ast_vector_get : context -> ast_vector -> int -> ast = "camlidl_z3_Z3_ast_vector_get" (** - Summary: Update position [i] of the AST vector [v] with the AST [a]. - + Summary: Update position [i] of the AST vector [v] with the AST [a]. - {b Precondition}: i < ast_vector_size c v - def_API('ast_vector_set', VOID, (_in(CONTEXT), _in(AST_VECTOR), _in(UINT), _in(AST))) *) external ast_vector_set : context -> ast_vector -> int -> ast -> unit = "camlidl_z3_Z3_ast_vector_set" (** - Summary: Resize the AST vector [v]. - + Summary: Resize the AST vector [v]. def_API('ast_vector_resize', VOID, (_in(CONTEXT), _in(AST_VECTOR), _in(UINT))) *) external ast_vector_resize : context -> ast_vector -> int -> unit @@ -5166,7 +4286,6 @@ external ast_vector_resize : context -> ast_vector -> int -> unit (** Summary: Add the AST [a] in the end of the AST vector [v]. The size of [v] is increased by one. - def_API('ast_vector_push', VOID, (_in(CONTEXT), _in(AST_VECTOR), _in(AST))) *) external ast_vector_push : context -> ast_vector -> ast -> unit @@ -5174,7 +4293,6 @@ external ast_vector_push : context -> ast_vector -> ast -> unit (** Summary: Translate the AST vector [v] from context [s] into an AST vector in context [t]. - def_API('ast_vector_translate', AST_VECTOR, (_in(CONTEXT), _in(AST_VECTOR), _in(CONTEXT))) *) external ast_vector_translate : context -> ast_vector -> context -> ast_vector @@ -5182,7 +4300,6 @@ external ast_vector_translate : context -> ast_vector -> context -> ast_vector (** Summary: Convert AST vector into a string. - def_API('ast_vector_to_string', STRING, (_in(CONTEXT), _in(AST_VECTOR))) *) external ast_vector_to_string : context -> ast_vector -> string @@ -5193,10 +4310,6 @@ external ast_vector_to_string : context -> ast_vector -> string *) (** Summary: Return an empty mapping from AST to AST - - - - def_API('mk_ast_map', AST_MAP, (_in(CONTEXT),) ) *) external mk_ast_map : context -> ast_map @@ -5204,7 +4317,6 @@ external mk_ast_map : context -> ast_map (** Summary: Return true if the map [m] contains the AST key [k]. - def_API('ast_map_contains', BOOL, (_in(CONTEXT), _in(AST_MAP), _in(AST))) *) external ast_map_contains : context -> ast_map -> ast -> bool @@ -5212,9 +4324,7 @@ external ast_map_contains : context -> ast_map -> ast -> bool (** Summary: Return the value associated with the key [k]. - The procedure invokes the error handler if [k] is not in the map. - def_API('ast_map_find', AST, (_in(CONTEXT), _in(AST_MAP), _in(AST))) *) external ast_map_find : context -> ast_map -> ast -> ast @@ -5222,7 +4332,6 @@ external ast_map_find : context -> ast_map -> ast -> ast (** Summary: Store/Replace a new key, value pair in the given map. - def_API('ast_map_insert', VOID, (_in(CONTEXT), _in(AST_MAP), _in(AST), _in(AST))) *) external ast_map_insert : context -> ast_map -> ast -> ast -> unit @@ -5230,7 +4339,6 @@ external ast_map_insert : context -> ast_map -> ast -> ast -> unit (** Summary: Erase a key from the map. - def_API('ast_map_erase', VOID, (_in(CONTEXT), _in(AST_MAP), _in(AST))) *) external ast_map_erase : context -> ast_map -> ast -> unit @@ -5238,7 +4346,6 @@ external ast_map_erase : context -> ast_map -> ast -> unit (** Summary: Remove all keys from the given map. - def_API('ast_map_reset', VOID, (_in(CONTEXT), _in(AST_MAP))) *) external ast_map_reset : context -> ast_map -> unit @@ -5246,7 +4353,6 @@ external ast_map_reset : context -> ast_map -> unit (** Summary: Return the size of the given map. - def_API('ast_map_size', UINT, (_in(CONTEXT), _in(AST_MAP))) *) external ast_map_size : context -> ast_map -> int @@ -5254,7 +4360,6 @@ external ast_map_size : context -> ast_map -> int (** Summary: Return the keys stored in the given map. - def_API('ast_map_keys', AST_VECTOR, (_in(CONTEXT), _in(AST_MAP))) *) external ast_map_keys : context -> ast_map -> ast_vector @@ -5262,7 +4367,6 @@ external ast_map_keys : context -> ast_map -> ast_vector (** Summary: Convert the given map into a string. - def_API('ast_map_to_string', STRING, (_in(CONTEXT), _in(AST_MAP))) *) external ast_map_to_string : context -> ast_map -> string @@ -5275,17 +4379,10 @@ external ast_map_to_string : context -> ast_map -> string Summary: Create a goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or transformed using tactics and solvers. - If models == true, then model generation is enabled for the new goal. - If unsat_cores == true, then unsat core generation is enabled for the new goal. - - If proofs == true, then proof generation is enabled for the new goal. Remark, the + If proofs == true, then proof generation is enabled for the new goal. Remark, the Z3 context c must have been created with proof generation support. - - - - def_API('mk_goal', GOAL, (_in(CONTEXT), _in(BOOL), _in(BOOL), _in(BOOL))) *) external mk_goal : context -> bool -> bool -> bool -> goal @@ -5295,15 +4392,13 @@ external mk_goal : context -> bool -> bool -> bool -> goal Summary: Return the "precision" of the given goal. Goals can be transformed using over and under approximations. A 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. - def_API('goal_precision', UINT, (_in(CONTEXT), _in(GOAL))) *) external goal_precision : context -> goal -> goal_prec = "camlidl_z3_Z3_goal_precision" (** - Summary: Add a new formula [a] to the given goal. - + Summary: Add a new formula [a] to the given goal. def_API('goal_assert', VOID, (_in(CONTEXT), _in(GOAL), _in(AST))) *) external goal_assert : context -> goal -> ast -> unit @@ -5311,7 +4406,6 @@ external goal_assert : context -> goal -> ast -> unit (** Summary: Return true if the given goal contains the formula [false]. - def_API('goal_inconsistent', BOOL, (_in(CONTEXT), _in(GOAL))) *) external goal_inconsistent : context -> goal -> bool @@ -5319,7 +4413,6 @@ external goal_inconsistent : context -> goal -> bool (** Summary: Return the depth of the given goal. It tracks how many transformations were applied to it. - def_API('goal_depth', UINT, (_in(CONTEXT), _in(GOAL))) *) external goal_depth : context -> goal -> int @@ -5327,7 +4420,6 @@ external goal_depth : context -> goal -> int (** Summary: Erase all formulas from the given goal. - def_API('goal_reset', VOID, (_in(CONTEXT), _in(GOAL))) *) external goal_reset : context -> goal -> unit @@ -5335,7 +4427,6 @@ external goal_reset : context -> goal -> unit (** Summary: Return the number of formulas in the given goal. - def_API('goal_size', UINT, (_in(CONTEXT), _in(GOAL))) *) external goal_size : context -> goal -> int @@ -5343,9 +4434,7 @@ external goal_size : context -> goal -> int (** Summary: Return a formula from the given goal. - - {b Precondition}: idx < goal_size c g - def_API('goal_formula', AST, (_in(CONTEXT), _in(GOAL), _in(UINT))) *) external goal_formula : context -> goal -> int -> ast @@ -5353,7 +4442,6 @@ external goal_formula : context -> goal -> int -> ast (** Summary: Return the number of formulas, subformulas and terms in the given goal. - def_API('goal_num_exprs', UINT, (_in(CONTEXT), _in(GOAL))) *) external goal_num_exprs : context -> goal -> int @@ -5361,7 +4449,6 @@ external goal_num_exprs : context -> goal -> int (** Summary: Return true if the goal is empty, and it is precise or the product of a under approximation. - def_API('goal_is_decided_sat', BOOL, (_in(CONTEXT), _in(GOAL))) *) external goal_is_decided_sat : context -> goal -> bool @@ -5369,7 +4456,6 @@ external goal_is_decided_sat : context -> goal -> bool (** Summary: Return true if the goal contains false, and it is precise or the product of an over approximation. - def_API('goal_is_decided_unsat', BOOL, (_in(CONTEXT), _in(GOAL))) *) external goal_is_decided_unsat : context -> goal -> bool @@ -5377,7 +4463,6 @@ external goal_is_decided_unsat : context -> goal -> bool (** Summary: Copy a goal [g] from the context [source] to a the context [target]. - def_API('goal_translate', GOAL, (_in(CONTEXT), _in(GOAL), _in(CONTEXT))) *) external goal_translate : context -> goal -> context -> goal @@ -5385,7 +4470,6 @@ external goal_translate : context -> goal -> context -> goal (** Summary: Convert a goal into a string. - def_API('goal_to_string', STRING, (_in(CONTEXT), _in(GOAL))) *) external goal_to_string : context -> goal -> string @@ -5398,9 +4482,7 @@ external goal_to_string : context -> goal -> string Summary: Return a tactic associated with the given name. The complete list of tactics may be obtained using the procedures {!get_num_tactics} and {!get_tactic_name}. It may also be obtained using the command {e (help-tactics) } in the SMT 2.0 front-end. - Tactics are the basic building block for creating custom solvers for specific problem domains. - def_API('mk_tactic', TACTIC, (_in(CONTEXT), _in(STRING))) *) external mk_tactic : context -> string -> tactic @@ -5410,10 +4492,8 @@ external mk_tactic : context -> string -> tactic Summary: Return a probe associated with the given name. The complete list of probes may be obtained using the procedures {!get_num_probes} and {!get_probe_name}. It may also be obtained using the command {e (help-tactics) } in the SMT 2.0 front-end. - 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. - def_API('mk_probe', PROBE, (_in(CONTEXT), _in(STRING))) *) external mk_probe : context -> string -> probe @@ -5422,7 +4502,6 @@ external mk_probe : context -> string -> probe (** Summary: Return a tactic that applies [t1] to a given goal and [t2] to every subgoal produced by t1. - def_API('tactic_and_then', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(TACTIC))) *) external tactic_and_then : context -> tactic -> tactic -> tactic @@ -5431,7 +4510,6 @@ external tactic_and_then : context -> tactic -> tactic -> tactic (** Summary: Return a tactic that first applies [t1] to a given goal, if it fails then returns the result of [t2] applied to the given goal. - def_API('tactic_or_else', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(TACTIC))) *) external tactic_or_else : context -> tactic -> tactic -> tactic @@ -5439,7 +4517,6 @@ external tactic_or_else : context -> tactic -> tactic -> tactic (** Summary: Return a tactic that applies the given tactics in parallel. - def_API('tactic_par_or', TACTIC, (_in(CONTEXT), _in(UINT), _in_array(1, TACTIC))) *) external tactic_par_or : context -> tactic array -> tactic @@ -5448,7 +4525,6 @@ external tactic_par_or : context -> tactic array -> tactic (** Summary: Return a tactic that applies [t1] to a given goal and then [t2] to every subgoal produced by t1. The subgoals are processed in parallel. - def_API('tactic_par_and_then', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(TACTIC))) *) external tactic_par_and_then : context -> tactic -> tactic -> tactic @@ -5457,7 +4533,6 @@ external tactic_par_and_then : context -> tactic -> tactic -> tactic (** Summary: Return a tactic that applies [t] to a given goal for [ms] milliseconds. If [t] does not terminate in [ms] milliseconds, then it fails. - def_API('tactic_try_for', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(UINT))) *) external tactic_try_for : context -> tactic -> int -> tactic @@ -5466,7 +4541,6 @@ external tactic_try_for : context -> tactic -> int -> tactic (** Summary: Return a tactic that applies [t] to a given goal is the probe [p] evaluates to true. If [p] evaluates to false, then the new tactic behaves like the skip tactic. - def_API('tactic_when', TACTIC, (_in(CONTEXT), _in(PROBE), _in(TACTIC))) *) external tactic_when : context -> probe -> tactic -> tactic @@ -5475,7 +4549,6 @@ external tactic_when : context -> probe -> tactic -> tactic (** Summary: Return a tactic that applies [t1] to a given goal if the probe [p] evaluates to true, and [t2] if [p] evaluates to false. - def_API('tactic_cond', TACTIC, (_in(CONTEXT), _in(PROBE), _in(TACTIC), _in(TACTIC))) *) external tactic_cond : context -> probe -> tactic -> tactic -> tactic @@ -5484,7 +4557,6 @@ external tactic_cond : context -> probe -> tactic -> tactic -> tactic (** Summary: Return a tactic that keeps applying [t] until the goal is not modified anymore or the maximum number of iterations [max] is reached. - def_API('tactic_repeat', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(UINT))) *) external tactic_repeat : context -> tactic -> int -> tactic @@ -5492,7 +4564,6 @@ external tactic_repeat : context -> tactic -> int -> tactic (** Summary: Return a tactic that just return the given goal. - def_API('tactic_skip', TACTIC, (_in(CONTEXT),)) *) external tactic_skip : context -> tactic @@ -5500,7 +4571,6 @@ external tactic_skip : context -> tactic (** Summary: Return a tactic that always fails. - def_API('tactic_fail', TACTIC, (_in(CONTEXT),)) *) external tactic_fail : context -> tactic @@ -5508,7 +4578,6 @@ external tactic_fail : context -> tactic (** Summary: Return a tactic that fails if the probe [p] evaluates to false. - def_API('tactic_fail_if', TACTIC, (_in(CONTEXT), _in(PROBE))) *) external tactic_fail_if : context -> probe -> tactic @@ -5517,7 +4586,6 @@ external tactic_fail_if : context -> probe -> tactic (** Summary: Return a tactic that fails if the goal is not trivially satisfiable (i.e., empty) or trivially unsatisfiable (i.e., contains false). - def_API('tactic_fail_if_not_decided', TACTIC, (_in(CONTEXT),)) *) external tactic_fail_if_not_decided : context -> tactic @@ -5525,7 +4593,6 @@ external tactic_fail_if_not_decided : context -> tactic (** Summary: Return a tactic that applies [t] using the given set of parameters. - def_API('tactic_using_params', TACTIC, (_in(CONTEXT), _in(TACTIC), _in(PARAMS))) *) external tactic_using_params : context -> tactic -> params -> tactic @@ -5533,7 +4600,6 @@ external tactic_using_params : context -> tactic -> params -> tactic (** Summary: Return a probe that always evaluates to val. - def_API('probe_const', PROBE, (_in(CONTEXT), _in(DOUBLE))) *) external probe_const : context -> float -> probe @@ -5541,9 +4607,7 @@ external probe_const : context -> float -> probe (** Summary: Return a probe that evaluates to "true" when the value returned by [p1] is less than the value returned by [p2]. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_lt', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_lt : context -> probe -> probe -> probe @@ -5551,9 +4615,7 @@ external probe_lt : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when the value returned by [p1] is greater than the value returned by [p2]. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_gt', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_gt : context -> probe -> probe -> probe @@ -5561,9 +4623,7 @@ external probe_gt : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when the value returned by [p1] is less than or equal to the value returned by [p2]. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_le', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_le : context -> probe -> probe -> probe @@ -5571,19 +4631,15 @@ external probe_le : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when the value returned by [p1] is greater than or equal to the value returned by [p2]. - - {b Remarks}: For probes, "true" is any value different from 0.0. - - def_API('probe_ge', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) + def_API('probe_ge', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_ge : context -> probe -> probe -> probe = "camlidl_z3_Z3_probe_ge" (** Summary: Return a probe that evaluates to "true" when the value returned by [p1] is equal to the value returned by [p2]. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_eq', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_eq : context -> probe -> probe -> probe @@ -5591,9 +4647,7 @@ external probe_eq : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when [p1] and [p2] evaluates to true. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_and', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_and : context -> probe -> probe -> probe @@ -5601,9 +4655,7 @@ external probe_and : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when [p1] or [p2] evaluates to true. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_or', PROBE, (_in(CONTEXT), _in(PROBE), _in(PROBE))) *) external probe_or : context -> probe -> probe -> probe @@ -5611,9 +4663,7 @@ external probe_or : context -> probe -> probe -> probe (** Summary: Return a probe that evaluates to "true" when [p] does not evaluate to true. - - {b Remarks}: For probes, "true" is any value different from 0.0. - def_API('probe_not', PROBE, (_in(CONTEXT), _in(PROBE))) *) external probe_not : context -> probe -> probe @@ -5621,7 +4671,6 @@ external probe_not : context -> probe -> probe (** Summary: Return the number of builtin tactics available in Z3. - def_API('get_num_tactics', UINT, (_in(CONTEXT),)) *) external get_num_tactics : context -> int @@ -5629,9 +4678,7 @@ external get_num_tactics : context -> int (** Summary: Return the name of the idx tactic. - - {b Precondition}: i < get_num_tactics c - def_API('get_tactic_name', STRING, (_in(CONTEXT), _in(UINT))) *) external get_tactic_name : context -> int -> string @@ -5639,7 +4686,6 @@ external get_tactic_name : context -> int -> string (** Summary: Return the number of builtin probes available in Z3. - def_API('get_num_probes', UINT, (_in(CONTEXT),)) *) external get_num_probes : context -> int @@ -5647,9 +4693,7 @@ external get_num_probes : context -> int (** Summary: Return the name of the i probe. - - {b Precondition}: i < get_num_probes c - def_API('get_probe_name', STRING, (_in(CONTEXT), _in(UINT))) *) external get_probe_name : context -> int -> string @@ -5657,7 +4701,6 @@ external get_probe_name : context -> int -> string (** Summary: Return a string containing a description of parameters accepted by the given tactic. - def_API('tactic_get_help', STRING, (_in(CONTEXT), _in(TACTIC))) *) external tactic_get_help : context -> tactic -> string @@ -5665,7 +4708,6 @@ external tactic_get_help : context -> tactic -> string (** Summary: Return the parameter description set for the given tactic object. - def_API('tactic_get_param_descrs', PARAM_DESCRS, (_in(CONTEXT), _in(TACTIC))) *) external tactic_get_param_descrs : context -> tactic -> param_descrs @@ -5673,7 +4715,6 @@ external tactic_get_param_descrs : context -> tactic -> param_descrs (** Summary: Return a string containing a description of the tactic with the given name. - def_API('tactic_get_descr', STRING, (_in(CONTEXT), _in(STRING))) *) external tactic_get_descr : context -> string -> string @@ -5681,7 +4722,6 @@ external tactic_get_descr : context -> string -> string (** Summary: Return a string containing a description of the probe with the given name. - def_API('probe_get_descr', STRING, (_in(CONTEXT), _in(STRING))) *) external probe_get_descr : context -> string -> string @@ -5690,7 +4730,6 @@ external probe_get_descr : context -> string -> string (** Summary: Execute the probe over the goal. The probe always produce a double value. "Boolean" probes return 0.0 for false, and a value different from 0.0 for true. - def_API('probe_apply', DOUBLE, (_in(CONTEXT), _in(PROBE), _in(GOAL))) *) external probe_apply : context -> probe -> goal -> float @@ -5698,7 +4737,6 @@ external probe_apply : context -> probe -> goal -> float (** Summary: Apply tactic [t] to the goal [g]. - def_API('tactic_apply', APPLY_RESULT, (_in(CONTEXT), _in(TACTIC), _in(GOAL))) *) external tactic_apply : context -> tactic -> goal -> apply_result @@ -5706,7 +4744,6 @@ external tactic_apply : context -> tactic -> goal -> apply_result (** Summary: Apply tactic [t] to the goal [g] using the parameter set [p]. - def_API('tactic_apply_ex', APPLY_RESULT, (_in(CONTEXT), _in(TACTIC), _in(GOAL), _in(PARAMS))) *) external tactic_apply_ex : context -> tactic -> goal -> params -> apply_result @@ -5714,7 +4751,6 @@ external tactic_apply_ex : context -> tactic -> goal -> params -> apply_result (** Summary: Convert the [apply_result] object returned by {!tactic_apply} into a string. - def_API('apply_result_to_string', STRING, (_in(CONTEXT), _in(APPLY_RESULT))) *) external apply_result_to_string : context -> apply_result -> string @@ -5722,7 +4758,6 @@ external apply_result_to_string : context -> apply_result -> string (** Summary: Return the number of subgoals in the [apply_result] object returned by {!tactic_apply}. - def_API('apply_result_get_num_subgoals', UINT, (_in(CONTEXT), _in(APPLY_RESULT))) *) external apply_result_get_num_subgoals : context -> apply_result -> int @@ -5730,9 +4765,7 @@ external apply_result_get_num_subgoals : context -> apply_result -> int (** Summary: Return one of the subgoals in the [apply_result] object returned by {!tactic_apply}. - - {b Precondition}: i < apply_result_get_num_subgoals c r - def_API('apply_result_get_subgoal', GOAL, (_in(CONTEXT), _in(APPLY_RESULT), _in(UINT))) *) external apply_result_get_subgoal : context -> apply_result -> int -> goal @@ -5741,7 +4774,6 @@ external apply_result_get_subgoal : context -> apply_result -> int -> goal (** Summary: Convert a model for the subgoal [apply_result_get_subgoal(c], r, i) into a model for the original goal [g]. Where [g] is the goal used to create [r] using [tactic_apply(c], t, g). - def_API('apply_result_convert_model', MODEL, (_in(CONTEXT), _in(APPLY_RESULT), _in(UINT), _in(MODEL))) *) external apply_result_convert_model : context -> apply_result -> int -> model -> model @@ -5753,11 +4785,7 @@ external apply_result_convert_model : context -> apply_result -> int -> model -> (** Summary: Create 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. - - - - + check-sat commands that take more than a given number of milliseconds to be solved. def_API('mk_solver', SOLVER, (_in(CONTEXT),)) *) external mk_solver : context -> solver @@ -5765,7 +4793,6 @@ external mk_solver : context -> solver (** Summary: Create a new (incremental) solver. - def_API('mk_simple_solver', SOLVER, (_in(CONTEXT),)) *) external mk_simple_solver : context -> solver @@ -5774,10 +4801,6 @@ external mk_simple_solver : context -> solver (** Summary: Create a new solver customized for the given logic. It behaves like {!mk_solver} if the logic is unknown or unsupported. - - - - def_API('mk_solver_for_logic', SOLVER, (_in(CONTEXT), _in(SYMBOL))) *) external mk_solver_for_logic : context -> symbol -> solver @@ -5787,7 +4810,6 @@ external mk_solver_for_logic : context -> symbol -> solver Summary: Create a new solver that is implemented using the given tactic. The solver supports the commands {!solver_push} and {!solver_pop}, but it will always solve each {!solver_check} from scratch. - def_API('mk_solver_from_tactic', SOLVER, (_in(CONTEXT), _in(TACTIC))) *) external mk_solver_from_tactic : context -> tactic -> solver @@ -5795,7 +4817,6 @@ external mk_solver_from_tactic : context -> tactic -> solver (** Summary: Return a string describing all solver available parameters. - def_API('solver_get_help', STRING, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_help : context -> solver -> string @@ -5803,7 +4824,6 @@ external solver_get_help : context -> solver -> string (** Summary: Return the parameter description set for the given solver object. - def_API('solver_get_param_descrs', PARAM_DESCRS, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_param_descrs : context -> solver -> param_descrs @@ -5811,7 +4831,6 @@ external solver_get_param_descrs : context -> solver -> param_descrs (** Summary: Set the given solver using the given parameters. - def_API('solver_set_params', VOID, (_in(CONTEXT), _in(SOLVER), _in(PARAMS))) *) external solver_set_params : context -> solver -> params -> unit @@ -5819,11 +4838,8 @@ external solver_set_params : context -> solver -> params -> unit (** Summary: Create a backtracking point. - - The solver contains a stack of assertions. - + The solver contains a stack of assertions. - {b See also}: {!solver_pop} - def_API('solver_push', VOID, (_in(CONTEXT), _in(SOLVER))) *) external solver_push : context -> solver -> unit @@ -5831,11 +4847,8 @@ external solver_push : context -> solver -> unit (** Summary: Backtrack [n] backtracking points. - - {b See also}: {!solver_push} - - {b Precondition}: n <= solver_get_num_scopes c s - def_API('solver_pop', VOID, (_in(CONTEXT), _in(SOLVER), _in(UINT))) *) external solver_pop : context -> solver -> int -> unit @@ -5843,7 +4856,6 @@ external solver_pop : context -> solver -> int -> unit (** Summary: Remove all assertions from the solver. - def_API('solver_reset', VOID, (_in(CONTEXT), _in(SOLVER))) *) external solver_reset : context -> solver -> unit @@ -5851,10 +4863,8 @@ external solver_reset : context -> solver -> unit (** Summary: Return the number of backtracking points. - - {b See also}: {!solver_push} - {b See also}: {!solver_pop} - def_API('solver_get_num_scopes', UINT, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_num_scopes : context -> solver -> int @@ -5862,34 +4872,42 @@ external solver_get_num_scopes : context -> solver -> int (** Summary: Assert a constraint into the solver. - The functions {!solver_check} and {!solver_check_assumptions} should be used to check whether the logical context is consistent or not. - def_API('solver_assert', VOID, (_in(CONTEXT), _in(SOLVER), _in(AST))) *) external solver_assert : context -> solver -> ast -> unit = "camlidl_z3_Z3_solver_assert" +(** + Summary: Assert a constraint [a] into the solver, and track it (in the unsat) core using + the Boolean constant [p]. + This API is an alternative to {!solver_check_assumptions} for extracting unsat cores. + Both APIs can be used in the same solver. The unsat core will contain a combination + of the Boolean variables provided using solver_assert_and_track and the Boolean literals + provided using {!solver_check_assumptions}. + - {b Precondition}: [a] must be a Boolean expression + - {b Precondition}: [p] must be a Boolean constant aka variable. + def_API('solver_assert_and_track', VOID, (_in(CONTEXT), _in(SOLVER), _in(AST), _in(AST))) +*) +external solver_assert_and_track : context -> solver -> ast -> ast -> unit + = "camlidl_z3_Z3_solver_assert_and_track" + (** Summary: Return the set of asserted formulas as a goal object. - - def_API('solver_get_assertions', AST_VECTOR, (_in(CONTEXT), _in(SOLVER))) + def_API('solver_get_assertions', AST_VECTOR, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_assertions : context -> solver -> ast_vector = "camlidl_z3_Z3_solver_get_assertions" (** Summary: Check whether the assertions in a given solver are consistent or not. - The function {!solver_get_model} retrieves a model if the assertions are not unsatisfiable (i.e., the result is not \c L_FALSE) and model construction is enabled. - The function {!solver_get_proof} retrieves a proof if proof - generation was enabled when the context was created, and the + generation was enabled when the context was created, and the assertions are unsatisfiable (i.e., the result is [L_FALSE)]. - def_API('solver_check', INT, (_in(CONTEXT), _in(SOLVER))) *) external solver_check : context -> solver -> lbool @@ -5898,12 +4916,9 @@ external solver_check : context -> solver -> lbool (** Summary: Check whether the assertions in the given solver and optional assumptions are consistent or not. - - The function {!solver_get_unsat_core} retrieves the subset of the + The function {!solver_get_unsat_core} retrieves the subset of the assumptions used in the unsatisfiability proof produced by Z3. - - {b See also}: {!solver_check} - def_API('solver_check_assumptions', INT, (_in(CONTEXT), _in(SOLVER), _in(UINT), _in_array(2, AST))) *) external solver_check_assumptions : context -> solver -> ast array -> lbool @@ -5911,10 +4926,8 @@ external solver_check_assumptions : context -> solver -> ast array -> lbool (** Summary: Retrieve the model for the last {!solver_check} or {!solver_check_assumptions} - - The error handler is invoked if a model is not available because + The error handler is invoked if a model is not available because the commands above were not invoked for the given solver, or if the result was [L_FALSE]. - def_API('solver_get_model', MODEL, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_model : context -> solver -> model @@ -5922,11 +4935,9 @@ external solver_get_model : context -> solver -> model (** Summary: Retrieve the proof for the last {!solver_check} or {!solver_check_assumptions} - The error handler is invoked if proof generation is not enabled, or if the commands above were not invoked for the given solver, or if the result was different from [L_FALSE]. - def_API('solver_get_proof', AST, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_proof : context -> solver -> ast @@ -5935,7 +4946,6 @@ external solver_get_proof : context -> solver -> ast (** Summary: Retrieve the unsat core for the last {!solver_check_assumptions} The unsat core is a subset of the assumptions [a]. - def_API('solver_get_unsat_core', AST_VECTOR, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_unsat_core : context -> solver -> ast_vector @@ -5944,7 +4954,6 @@ external solver_get_unsat_core : context -> solver -> ast_vector (** Summary: Return a brief justification for an "unknown" result (i.e., L_UNDEF) for the commands {!solver_check} and {!solver_check_assumptions} - def_API('solver_get_reason_unknown', STRING, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_reason_unknown : context -> solver -> string @@ -5952,9 +4961,6 @@ external solver_get_reason_unknown : context -> solver -> string (** Summary: Return statistics for the given solver. - - - def_API('solver_get_statistics', STATS, (_in(CONTEXT), _in(SOLVER))) *) external solver_get_statistics : context -> solver -> stats @@ -5962,7 +4968,6 @@ external solver_get_statistics : context -> solver -> stats (** Summary: Convert a solver into a string. - def_API('solver_to_string', STRING, (_in(CONTEXT), _in(SOLVER))) *) external solver_to_string : context -> solver -> string @@ -5976,25 +4981,23 @@ type stat_datum = Stat_int of int | Stat_float of float type stats_refined = (string, stat_datum) Hashtbl.t -(** +(** Summary: [stats_refine c s] is the refined stats of [s]. *) val stats_refine : context -> stats -> stats_refined (** Summary: Convert a statistics into a string. - def_API('stats_to_string', STRING, (_in(CONTEXT), _in(STATS))) *) external stats_to_string : context -> stats -> string = "camlidl_z3_Z3_stats_to_string" (** - {4 {L Low-level API}} + {4 {L Low-level API}} *) (** Summary: Return the number of statistical data in [s]. - def_API('stats_size', UINT, (_in(CONTEXT), _in(STATS))) *) external stats_size : context -> stats -> int @@ -6002,9 +5005,7 @@ external stats_size : context -> stats -> int (** Summary: Return the key (a string) for a particular statistical data. - - {b Precondition}: idx < stats_size c s - def_API('stats_get_key', STRING, (_in(CONTEXT), _in(STATS), _in(UINT))) *) external stats_get_key : context -> stats -> int -> string @@ -6012,9 +5013,7 @@ external stats_get_key : context -> stats -> int -> string (** Summary: Return TRUE if the given statistical data is a unsigned int integer. - - {b Precondition}: idx < stats_size c s - def_API('stats_is_uint', BOOL, (_in(CONTEXT), _in(STATS), _in(UINT))) *) external stats_is_uint : context -> stats -> int -> bool @@ -6022,9 +5021,7 @@ external stats_is_uint : context -> stats -> int -> bool (** Summary: Return TRUE if the given statistical data is a double. - - {b Precondition}: idx < stats_size c s - def_API('stats_is_double', BOOL, (_in(CONTEXT), _in(STATS), _in(UINT))) *) external stats_is_double : context -> stats -> int -> bool @@ -6032,9 +5029,7 @@ external stats_is_double : context -> stats -> int -> bool (** Summary: Return the unsigned int value of the given statistical data. - - {b Precondition}: idx < stats_size c s && stats_is_uint c s - def_API('stats_get_uint_value', UINT, (_in(CONTEXT), _in(STATS), _in(UINT))) *) external stats_get_uint_value : context -> stats -> int -> int @@ -6042,25 +5037,22 @@ external stats_get_uint_value : context -> stats -> int -> int (** Summary: Return the double value of the given statistical data. - - {b Precondition}: idx < stats_size c s && stats_is_double c s - def_API('stats_get_double_value', DOUBLE, (_in(CONTEXT), _in(STATS), _in(UINT))) *) external stats_get_double_value : context -> stats -> int -> float = "camlidl_z3_Z3_stats_get_double_value" -(** - {2 {L Legacy V3 API}} -*) - +(** + {2 {L Legacy V3 API}} +*) module V3 : sig -(** - {2 {L Legacy V3 API}} -*) +(** + {2 {L Legacy V3 API}} +*) -(* File generated from z3.idl *) +(* File generated from z3V3.idl *) type symbol and literals @@ -6296,24 +5288,17 @@ and ast_print_mode = (** - - *) (** {2 {L Types}} - - - Most of the types in the API are abstract. - - + Most of the types in the API are abstract. - [context]: manager of all other Z3 objects, global configuration options, etc. - - [symbol]: Lisp-like symbol used to name types, constants, and functions. A symbol can be created using string or integers. + - [symbol]: Lisp-like symbol used to name types, constants, and functions. A symbol can be created using string or integers. - [ast]: abstract syntax tree node. That is, the data-structure used in Z3 to represent terms, formulas and types. - [sort]: kind of AST used to represent types. - [func_decl]: kind of AST used to represent function symbols. - [app]: kind of AST used to represent function applications. - [pattern]: kind of AST used to represent pattern and multi-patterns used to guide quantifier instantiation. - - [params]: parameter set used to configure many components such as: simplifiers, tactics, solvers, etc. - [model]: model for the constraints asserted into the logical context. - [func_interp]: interpretation of a function in a model. @@ -6329,23 +5314,21 @@ and ast_print_mode = - [stats]: statistical data for a solver. *) (** - {!lbool} + {!lbool} Lifted Boolean type: [false], [undefined], [true]. *) (** - {!symbol_kind} + {!symbol_kind} The different kinds of symbol. In Z3, a symbol can be represented using integers and strings (See {!get_symbol_kind}). - - {b See also}: {!mk_int_symbol} - {b See also}: {!mk_string_symbol} *) (** - {!parameter_kind} + {!parameter_kind} The different kinds of parameters that can be associated with function symbols. - {b See also}: {!get_decl_num_parameters} - {b See also}: {!get_decl_parameter_kind} - - PARAMETER_INT is used for integer parameters. - PARAMETER_DOUBLE is used for double parameters. - PARAMETER_RATIONAL is used for parameters that are rational numbers. @@ -6355,23 +5338,23 @@ and ast_print_mode = - PARAMETER_FUNC_DECL is used for function declaration parameters. *) (** - {!sort_kind} + {!sort_kind} The different kinds of Z3 types (See {!get_sort_kind}). *) (** - {!ast_kind} + {!ast_kind} The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types. - - APP_AST: constant and applications - - NUMERAL_AST: numeral constants - - VAR_AST: bound variables - - QUANTIFIER_AST: quantifiers - - SORT_AST: sort - - FUNC_DECL_AST: function declaration - - UNKNOWN_AST: internal + - APP_AST: constant and applications + - NUMERAL_AST: numeral constants + - VAR_AST: bound variables + - QUANTIFIER_AST: quantifiers + - SORT_AST: sort + - FUNC_DECL_AST: function declaration + - UNKNOWN_AST: internal *) (** - {!decl_kind} + {!decl_kind} The different kinds of interpreted function kinds. - OP_TRUE The constant true. @@ -6436,9 +5419,9 @@ and ast_print_mode = - OP_POWER Power operator x^y. - OP_STORE 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. + Array store takes at least 3 arguments. - - OP_SELECT Array select. + - OP_SELECT Array select. - OP_CONST_ARRAY The constant array. For example, select(const(v),i) = v holds for every v and i. The function is unary. @@ -6473,7 +5456,7 @@ and ast_print_mode = - OP_BSUB Binary subtraction. - OP_BMUL Binary multiplication. - + - OP_BSDIV Binary signed division. - OP_BUDIV Binary unsigned int division. @@ -6493,16 +5476,16 @@ and ast_print_mode = - OP_BUREM0 Unary function. burem(x,0) is congruent to burem0(x). - OP_BSMOD0 Unary function. bsmod(x,0) is congruent to bsmod0(x). - + - OP_ULEQ Unsigned bit-vector <= - Binary relation. - - OP_SLEQ Signed bit-vector <= - Binary relation. + - OP_SLEQ Signed bit-vector <= - Binary relation. - - OP_UGEQ Unsigned bit-vector >= - Binary relation. + - OP_UGEQ Unsigned bit-vector >= - Binary relation. - - OP_SGEQ Signed bit-vector >= - Binary relation. + - OP_SGEQ Signed bit-vector >= - Binary relation. - - OP_ULT Unsigned bit-vector < - Binary relation. + - OP_ULT Unsigned bit-vector < - Binary relation. - OP_SLT Signed bit-vector < - Binary relation. @@ -6562,7 +5545,7 @@ and ast_print_mode = is not supported by the decision procedures. Only the most rudimentary simplification rules are applied to this function. - - OP_CARRY Compute the carry bit in a full-adder. + - OP_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))) @@ -6575,7 +5558,7 @@ and ast_print_mode = - OP_PR_TRUE: Proof for the expression 'true'. - OP_PR_ASSERTED: Proof for a fact asserted by the user. - + - OP_PR_GOAL: Proof for a fact (tagged as goal) asserted by the user. - OP_PR_MODUS_PONENS: Given a proof for p and a proof for (implies p q), produces a proof for q. @@ -6587,7 +5570,7 @@ and ast_print_mode = The second antecedents may also be a proof for (iff p q). - OP_PR_REFLEXIVITY: 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 + The only reflexive relations that are used are equivalence modulo namings, equality and equivalence. That is, R is either '~', '=' or 'iff'. @@ -6607,7 +5590,7 @@ and ast_print_mode = } - OP_PR_TRANSITIVITY_STAR: Condensed transitivity proof. This proof object is only used if the parameter PROOF_MODE is 1. - It combines several symmetry and transitivity proofs. + It combines several symmetry and transitivity proofs. Example: {e @@ -6620,7 +5603,7 @@ and ast_print_mode = 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, + 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. @@ -6638,8 +5621,8 @@ and ast_print_mode = T1: (~ p q) [quant-intro T1]: (~ (forall (x) p) (forall (x) q)) - - - OP_PR_DISTRIBUTIVITY: Distributivity proof object. + + - OP_PR_DISTRIBUTIVITY: Distributivity proof object. Given that f (= or) distributes over g (= and), produces a proof for (= (f a (g c d)) @@ -6653,11 +5636,11 @@ and ast_print_mode = 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 + Remark. This rule is used by the CNF conversion pass and instantiated by f = or, and g = and. - + - OP_PR_AND_ELIM: Given a proof for (and l_1 ... l_n), produces a proof for l_i - + {e T1: (and l_1 ... l_n) [and-elim T1]: l_i @@ -6673,10 +5656,10 @@ and ast_print_mode = 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), + 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: {e @@ -6698,22 +5681,22 @@ and ast_print_mode = - OP_PR_PULL_QUANT: A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. - OP_PR_PULL_QUANT_STAR: 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 is only used if the parameter PROOF_MODE is 1. This proof object has no antecedents. - + - OP_PR_PUSH_QUANT: A proof for: {e (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. - - OP_PR_ELIM_UNUSED_VARS: + - OP_PR_ELIM_UNUSED_VARS: 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])) + (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. @@ -6723,14 +5706,14 @@ and ast_print_mode = if x does not occur in t. This proof object has no antecedents. - + Several variables can be eliminated simultaneously. - OP_PR_QUANT_INST: A proof of (or (not (forall (x) (P x))) (P a)) - OP_PR_HYPOTHESIS: Mark a hypothesis in a natural deduction style proof. - - OP_PR_LEMMA: + - OP_PR_LEMMA: {e T1: false @@ -6740,16 +5723,16 @@ and ast_print_mode = It converts the proof in a proof for (or (not l_1) ... (not l_n)), when T1 contains the hypotheses: l_1, ..., l_n. - - OP_PR_UNIT_RESOLUTION: + - OP_PR_UNIT_RESOLUTION: {e - T1: (or l_1 ... l_n l_1' ... l_m') - T2: (not l_1) + T1: (or l_1 ... l_n l_1' ... l_m') + T2: (not l_1) ... - T(n+1): (not l_n) + T(n+1): (not l_n) [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m') } - - OP_PR_IFF_TRUE: + - OP_PR_IFF_TRUE: {e T1: p [iff-true T1]: (iff p true) @@ -6764,14 +5747,14 @@ and ast_print_mode = - OP_PR_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. - + - OP_PR_DEF_AXIOM: Proof object used to justify Tseitin's like axioms: - + {e (or (not (and p q)) p) (or (not (and p q)) q) @@ -6800,7 +5783,7 @@ and ast_print_mode = You can recover the propositional tautologies by unfolding the Boolean connectives in the axioms a small bounded number of steps (=3). - + - OP_PR_DEF_INTRO: 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: @@ -6816,17 +5799,17 @@ and ast_print_mode = [def-intro]: (and (or (not cond) (= n th)) (or cond (= n el))) Otherwise: - [def-intro]: (= n e) + [def-intro]: (= n e) - - OP_PR_APPLY_DEF: + - OP_PR_APPLY_DEF: [apply-def T1]: F ~ n F is 'equivalent' to n, given that T1 is a proof that n is a name for F. - + - OP_PR_IFF_OEQ: T1: (iff p q) [iff~ T1]: (~ p q) - + - OP_PR_NNF_POS: Proof for a (positive) NNF step. Example: {e T1: (not s_1) ~ r_1 @@ -6841,7 +5824,7 @@ and ast_print_mode = The quantifier is retained (unless the bound variables are eliminated). Example {e - T1: q ~ q_new + 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 @@ -6850,7 +5833,7 @@ and ast_print_mode = NNF_NEG furthermore handles the case where negation is pushed over Boolean connectives 'and' and 'or'. - + - OP_PR_NFF_NEG: Proof for a (negative) NNF step. Examples: {e T1: (not s_1) ~ r_1 @@ -6871,24 +5854,24 @@ and ast_print_mode = (and (or r_1 r_2) (or r_1' r_2'))) } - OP_PR_NNF_STAR: 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 is only used if the parameter PROOF_MODE is 1. + This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - OP_PR_CNF_STAR: 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. + 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. + + - OP_PR_SKOLEMIZE: Proof for: - - OP_PR_SKOLEMIZE: Proof for: - {e [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. - + - OP_PR_MODUS_PONENS_OEQ: Modus ponens style rule for equi-satisfiability. {e T1: p @@ -6901,9 +5884,9 @@ and ast_print_mode = 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. + 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. @@ -6934,7 +5917,7 @@ and ast_print_mode = {e (=> (and ln+1 ln+2 .. ln+m) (or l0 l1 .. ln-1)) } - In other words we use the following (Prolog style) convention for Horn + In other words we use the following (Prolog style) convention for Horn implications: The head of a Horn implication is position 0, the first conjunct in the body of an implication is position 1 @@ -6957,16 +5940,16 @@ and ast_print_mode = - OP_RA_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 + 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. - - OP_RA_EMPTY: Creates the empty relation. - + - OP_RA_EMPTY: Creates the empty relation. + - OP_RA_IS_EMPTY: Tests if the relation is empty. - OP_RA_JOIN: Create the relational join. - - OP_RA_UNION: Create the union or convex hull of two relations. + - OP_RA_UNION: Create the union or convex hull of two relations. The function takes two arguments. - OP_RA_WIDEN: Widen two relations. @@ -6976,7 +5959,7 @@ and ast_print_mode = The function takes one argument. - OP_RA_FILTER: Filter (restrict) a relation with respect to a predicate. - The first argument is a relation. + 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. @@ -6991,23 +5974,23 @@ and ast_print_mode = 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. - - - OP_RA_RENAME: rename columns in the relation. + + - OP_RA_RENAME: rename columns in the relation. The function takes one argument. The parameters contain the renaming as a cycle. - + - OP_RA_COMPLEMENT: Complement the relation. - OP_RA_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. - - OP_RA_CLONE: Create a fresh copy (clone) of a relation. + - OP_RA_CLONE: Create a fresh copy (clone) of a relation. The function is logically the identity, but in the context of a register machine allows - for [OP_RA_UNION] + for [OP_RA_UNION] to perform destructive updates to the first argument. - + - OP_FD_LT: A less than predicate over the finite domain FINITE_DOMAIN_SORT. @@ -7027,10 +6010,10 @@ and ast_print_mode = - OP_UNINTERPRETED: kind used for uninterpreted symbols. *) (** - {!param_kind} + {!param_kind} The different kinds of parameters that can be associated with parameter sets. - (see {!mk_params}). + (see {!mk_params}). - PK_UINT integer parameters. - PK_BOOL boolean parameters. @@ -7041,77 +6024,128 @@ and ast_print_mode = - PK_INVALID invalid parameter. *) (** - {!search_failure} + {!search_failure} The different kinds of search failure types. - - NO_FAILURE: The last search was successful - - UNKNOWN: Undocumented failure reason - - TIMEOUT: Timeout - - MEMOUT_WATERMAK: Search hit a memory high-watermak limit - - CANCELED: External cancel flag was set - - NUM_CONFLICTS: Maximum number of conflicts was reached - - THEORY: Theory is incomplete - - QUANTIFIERS: Logical context contains universal quantifiers + - NO_FAILURE: The last search was successful + - UNKNOWN: Undocumented failure reason + - TIMEOUT: Timeout + - MEMOUT_WATERMAK: Search hit a memory high-watermak limit + - CANCELED: External cancel flag was set + - NUM_CONFLICTS: Maximum number of conflicts was reached + - THEORY: Theory is incomplete + - QUANTIFIERS: Logical context contains universal quantifiers *) (** - {!ast_print_mode} + {!ast_print_mode} Z3 pretty printing modes (See {!set_ast_print_mode}). - - PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format. - - PRINT_LOW_LEVEL: Print AST nodes using a low-level format. + - PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format. + - PRINT_LOW_LEVEL: Print AST nodes using a low-level format. - PRINT_SMTLIB_COMPLIANT: Print AST nodes in SMTLIB 1.x compliant format. - PRINT_SMTLIB2_COMPLIANT: Print AST nodes in SMTLIB 2.x compliant format. *) (** Definitions for update_api.py - - def_Type('CONFIG', 'config', 'Config') - def_Type('CONTEXT', 'context', 'ContextObj') - def_Type('AST', 'ast', 'Ast') - def_Type('APP', 'app', 'Ast') - def_Type('SORT', 'sort', 'Sort') - def_Type('FUNC_DECL', 'func_decl', 'FuncDecl') - def_Type('PATTERN', 'pattern', 'Pattern') - def_Type('MODEL', 'model', 'Model') - def_Type('LITERALS', 'literals', 'Literals') - def_Type('CONSTRUCTOR', 'constructor', 'Constructor') + def_Type('CONFIG', 'config', 'Config') + def_Type('CONTEXT', 'context', 'ContextObj') + def_Type('AST', 'ast', 'Ast') + def_Type('APP', 'app', 'Ast') + def_Type('SORT', 'sort', 'Sort') + def_Type('FUNC_DECL', 'func_decl', 'FuncDecl') + def_Type('PATTERN', 'pattern', 'Pattern') + def_Type('MODEL', 'model', 'Model') + def_Type('LITERALS', 'literals', 'Literals') + def_Type('CONSTRUCTOR', 'constructor', 'Constructor') def_Type('CONSTRUCTOR_LIST', 'constructor_list', 'ConstructorList') - def_Type('THEORY', 'theory', 'ctypes.c_void_p') - def_Type('THEORY_DATA', 'theory_data', 'ctypes.c_void_p') - def_Type('SOLVER', 'solver', 'SolverObj') - def_Type('GOAL', 'goal', 'GoalObj') - def_Type('TACTIC', 'tactic', 'TacticObj') - def_Type('PARAMS', 'params', 'Params') - def_Type('PROBE', 'probe', 'ProbeObj') - def_Type('STATS', 'stats', 'StatsObj') - def_Type('AST_VECTOR', 'ast_vector', 'AstVectorObj') - def_Type('AST_MAP', 'ast_map', 'AstMapObj') - def_Type('APPLY_RESULT', 'apply_result', 'ApplyResultObj') - def_Type('FUNC_INTERP', 'func_interp', 'FuncInterpObj') - def_Type('FUNC_ENTRY', 'func_entry', 'FuncEntryObj') - def_Type('FIXEDPOINT', 'fixedpoint', 'FixedpointObj') - def_Type('PARAM_DESCRS', 'param_descrs', 'ParamDescrs') + def_Type('THEORY', 'theory', 'ctypes.c_void_p') + def_Type('THEORY_DATA', 'theory_data', 'ctypes.c_void_p') + def_Type('SOLVER', 'solver', 'SolverObj') + def_Type('GOAL', 'goal', 'GoalObj') + def_Type('TACTIC', 'tactic', 'TacticObj') + def_Type('PARAMS', 'params', 'Params') + def_Type('PROBE', 'probe', 'ProbeObj') + def_Type('STATS', 'stats', 'StatsObj') + def_Type('AST_VECTOR', 'ast_vector', 'AstVectorObj') + def_Type('AST_MAP', 'ast_map', 'AstMapObj') + def_Type('APPLY_RESULT', 'apply_result', 'ApplyResultObj') + def_Type('FUNC_INTERP', 'func_interp', 'FuncInterpObj') + def_Type('FUNC_ENTRY', 'func_entry', 'FuncEntryObj') + def_Type('FIXEDPOINT', 'fixedpoint', 'FixedpointObj') + def_Type('PARAM_DESCRS', 'param_descrs', 'ParamDescrs') *) +(** + {2 {L Configuration}} +*) +(** + Summary: Set a global (or module) parameter. + This setting is shared by all Z3 contexts. + When a Z3 module is initialized it will use the value of these parameters + when params objects are not provided. + The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. + The character '.' is a delimiter (more later). + The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. + Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION". + This function can be used to set parameters for a specific Z3 module. + This can be done by using .. + For example: + global_param_set('pp.decimal', 'true') + will set the parameter "decimal" in the module "pp" to true. + def_API('global_param_set', VOID, (_in(STRING), _in(STRING))) +*) +external global_param_set : string -> string -> unit + = "camlidl_z3V3_Z3_global_param_set" + +(** + Summary: Restore the value of all global (and module) parameters. + This command will not affect already created objects (such as tactics and solvers). + - {b See also}: {!global_param_set} + def_API('global_param_reset_all', VOID, ()) +*) +external global_param_reset_all : unit -> unit + = "camlidl_z3V3_Z3_global_param_reset_all" + +(** + Summary: Get a global (or module) parameter. + Returns [None] + if the parameter value does not exist. + - {b See also}: {!global_param_set} + The caller must invoke {!global_param_del_value} to delete the value returned at [param_value]. + - {b Remarks}: This function cannot be invoked simultaneously from different threads without synchronization. + The result string stored in param_value is stored in shared location. + def_API('global_param_get', BOOL, (_in(STRING), _out(STRING))) +*) +external global_param_get : string -> string option + = "camlidl_z3V3_Z3_global_param_get" + (** {2 {L Create configuration}} *) (** - Summary: Create a configuration. - - Configurations are created in order to assign parameters prior to creating - contexts for Z3 interaction. For example, if the users wishes to use model + Summary: Create a configuration object for the Z3 context object. + Configurations are created in order to assign parameters prior to creating + contexts for Z3 interaction. For example, if the users wishes to use proof generation, then call: - - [set_param_value cfg "MODEL" "true"] - + [set_param_value cfg "proof" "true"] - {b Remarks}: Consider using {!mk_context_x} instead of using explicit configuration objects. The function {!mk_context_x} receives an array of string pairs. This array represents the - configuration options. - + configuration options. + - {b Remarks}: In previous versions of Z3, the [config] was used to store + global and module configurations. Now, we should use [global_param_set]. + The following parameters can be set: + - proof (Boolean) Enable proof generation + - debug_ref_count (Boolean) Enable debug support for ast reference counting + - trace (Boolean) Tracing support for VCC + - trace_file_name (String) Trace out file for VCC traces + - timeout (unsigned) default timeout (in milliseconds) used for solvers + - well_sorted_check type checker + - auto_config use heuristics to automatically select solver and configure it + - model model generation for solvers, this parameter can be overwritten when creating a solver + - model_validate validate models produced by solvers + - unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver - {b See also}: {!set_param_value} - {b See also}: {!del_config} - def_API('mk_config', CONFIG, ()) *) external mk_config : unit -> config @@ -7119,9 +6153,7 @@ external mk_config : unit -> config (** Summary: Delete the given configuration object. - - {b See also}: {!mk_config} - def_API('del_config', VOID, (_in(CONFIG),)) *) external del_config : config -> unit @@ -7129,15 +6161,8 @@ external del_config : config -> unit (** Summary: Set a configuration parameter. - - The list of all configuration parameters can be obtained using the Z3 executable: - - {v - z3.exe -ini? - v} - + The following parameters can be set for - {b See also}: {!mk_config} - def_API('set_param_value', VOID, (_in(CONFIG), _in(STRING), _in(STRING))) *) external set_param_value : config -> string -> string -> unit @@ -7147,16 +6172,10 @@ external set_param_value : config -> string -> string -> unit {2 {L Create context}} *) (** - Summary: Create a context using the given configuration. - + Summary: Create a context using the given configuration. After a context is created, the configuration cannot be changed, although some parameters can be changed using {!update_param_value}. All main interaction with Z3 happens in the context of a [context]. - - - - - def_API('mk_context', CONTEXT, (_in(CONFIG),)) *) external mk_context : config -> context @@ -7164,44 +6183,23 @@ external mk_context : config -> context (** Summary: Delete the given logical context. - - {b See also}: {!mk_context} - def_API('del_context', VOID, (_in(CONTEXT),)) *) external del_context : context -> unit = "camlidl_z3V3_Z3_del_context" (** - Summary: Update a mutable configuration parameter. - - The list of all configuration parameters can be obtained using the Z3 executable: - - {v - z3.exe -ini? - v} - - Only a few configuration parameters are mutable once the context is created. - The error handler is invoked when trying to modify an immutable parameter. - - - - {b See also}: {!mk_context } - + Summary: Set a value of a context parameter. + - {b See also}: {!global_param_set} def_API('update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) *) external update_param_value : context -> string -> string -> unit = "camlidl_z3V3_Z3_update_param_value" (** - Summary: Get a configuration parameter. - - Returns [None] - if the parameter value does not exist. - - - - - {b See also}: {!mk_context } - + Summary: Return the value of a context parameter. + - {b See also}: {!global_param_get} def_API('get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) *) external get_param_value : context -> string -> string option @@ -7211,18 +6209,14 @@ external get_param_value : context -> string -> string option {2 {L Symbols}} *) (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Create a Z3 symbol using an integer. - Symbols are used to name several term and type constructors. - NB. Not all integers can be passed to this function. The legal range of unsigned int integers is 0 to 2^30-1. - - {b See also}: {!mk_string_symbol} - def_API('mk_int_symbol', SYMBOL, (_in(CONTEXT), _in(INT))) *) external mk_int_symbol : context -> int -> symbol @@ -7230,11 +6224,8 @@ external mk_int_symbol : context -> int -> symbol (** Summary: Create a Z3 symbol using a C string. - Symbols are used to name several term and type constructors. - - {b See also}: {!mk_int_symbol} - def_API('mk_string_symbol', SYMBOL, (_in(CONTEXT), _in(STRING))) *) external mk_string_symbol : context -> string -> symbol @@ -7244,23 +6235,19 @@ external mk_string_symbol : context -> string -> symbol {2 {L Sorts}} *) (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Create a free (uninterpreted) type using the given name (symbol). - Two free types are considered the same iff the have the same name. - def_API('mk_uninterpreted_sort', SORT, (_in(CONTEXT), _in(SYMBOL))) *) external mk_uninterpreted_sort : context -> symbol -> sort = "camlidl_z3V3_Z3_mk_uninterpreted_sort" (** - Summary: Create the Boolean type. - + Summary: Create the Boolean type. This type is used to create propositional variables and predicates. - def_API('mk_bool_sort', SORT, (_in(CONTEXT), )) *) external mk_bool_sort : context -> sort @@ -7268,24 +6255,19 @@ external mk_bool_sort : context -> sort (** Summary: Create the integer type. - This type is not the int type found in programming languages. A machine integer can be represented using bit-vectors. The function {!mk_bv_sort} creates a bit-vector type. - - {b See also}: {!mk_bv_sort} - def_API('mk_int_sort', SORT, (_in(CONTEXT), )) *) external mk_int_sort : context -> sort = "camlidl_z3V3_Z3_mk_int_sort" (** - Summary: Create the real type. - + Summary: Create the real type. This type is not a floating point number. Z3 does not have support for floating point numbers yet. - def_API('mk_real_sort', SORT, (_in(CONTEXT), )) *) external mk_real_sort : context -> sort @@ -7293,11 +6275,8 @@ external mk_real_sort : context -> sort (** Summary: Create a bit-vector type of the given size. - This type can also be seen as a machine integer. - - {b Remarks}: The size of the bitvector type must be greater than zero. - def_API('mk_bv_sort', SORT, (_in(CONTEXT), _in(UINT))) *) external mk_bv_sort : context -> int -> sort @@ -7305,27 +6284,21 @@ external mk_bv_sort : context -> int -> sort (** Summary: Create a named finite domain sort. - - To create constants that belong to the finite domain, + To create constants that belong to the finite domain, use the APIs for creating numerals and pass a numeric constant together with the sort returned by this call. - - - {b See also}: {!get_finite_domain_sort_size.} - + - {b See also}: {!get_finite_domain_sort_size} def_API('mk_finite_domain_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT64))) *) external mk_finite_domain_sort : context -> symbol -> int64 -> sort = "camlidl_z3V3_Z3_mk_finite_domain_sort" (** - Summary: Create an array type. - + Summary: Create an array type. We usually represent the array type as: {e [domain -> range] }. Arrays are usually used to model the heap/memory in software verification. - - {b See also}: {!mk_select} - {b See also}: {!mk_store} - def_API('mk_array_sort', SORT, (_in(CONTEXT), _in(SORT), _in(SORT))) *) external mk_array_sort : context -> sort -> sort -> sort @@ -7333,14 +6306,8 @@ external mk_array_sort : context -> sort -> sort -> sort (** Summary: Create a tuple type. - [mk_tuple_sort c name field_names field_sorts] creates a tuple with a constructor named [name], a [n] fields, where [n] is the size of the arrays [field_names] and [field_sorts]. - - - - - @param c logical context @param mk_tuple_name name of the constructor function associated with the tuple type. @param num_fields number of fields in the tuple type. @@ -7348,7 +6315,6 @@ external mk_array_sort : context -> sort -> sort -> sort @param field_sorts type of the tuple fields. @param mk_tuple_decl output parameter that will contain the constructor declaration. @param proj_decl output parameter that will contain the projection function declarations. This field must be a buffer of size [num_fields] allocated by the user. - def_API('mk_tuple_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _out(FUNC_DECL), _out_array(2, FUNC_DECL))) *) external mk_tuple_sort : context -> symbol -> symbol array -> sort array -> sort * func_decl * func_decl array @@ -7356,28 +6322,20 @@ external mk_tuple_sort : context -> symbol -> symbol array -> sort array -> sort (** Summary: Create a enumeration sort. - - [mk_enumeration_sort c enums] creates an enumeration sort with enumeration names [enums], + [mk_enumeration_sort c enums] creates an enumeration sort with enumeration names [enums], it also returns [n] predicates, where [n] is the number of [enums] corresponding to testing whether an element is one of the enumerants. - - - - - @param c logical context @param name name of the enumeration sort. @param n number of elemenets in enumeration sort. @param enum_names names of the enumerated elements. @param enum_consts constants corresponding to the enumerated elements. @param enum_testers predicates testing if terms of the enumeration sort correspond to an enumeration. - - For example, if this function is called with three symbols A, B, C and the name S, then - [s] is a sort whose name is S, and the function returns three terms corresponding to A, B, C in + For example, if this function is called with three symbols A, B, C and the name S, then + [s] is a sort whose name is S, and the function returns three terms corresponding to A, B, C in [enum_consts]. The array [enum_testers] has three predicates of type {e (s -> Bool) }. The first predicate (corresponding to A) is true when applied to A, and false otherwise. Similarly for the other predicates. - def_API('mk_enumeration_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SYMBOL), _out_array(2, FUNC_DECL), _out_array(2, FUNC_DECL))) *) external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_decl array * func_decl array @@ -7385,13 +6343,7 @@ external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_ (** Summary: Create a list sort - [mk_list_sort c name elem_sort] creates a list sort of [name], over elements of sort [elem_sort]. - - - - - @param c logical context @param name name of the list sort. @param elem_sort sort of list elements. @@ -7401,7 +6353,6 @@ external mk_enumeration_sort : context -> symbol -> symbol array -> sort * func_ @param is_cons_decl cons cell test. @param head_decl list head. @param tail_decl list tail. - def_API('mk_list_sort', SORT, (_in(CONTEXT), _in(SYMBOL), _in(SORT), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL), _out(FUNC_DECL))) *) external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_decl * func_decl * func_decl * func_decl * func_decl @@ -7409,44 +6360,38 @@ external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_dec (** Summary: Create a constructor. - @param c logical context. @param name constructor name. @param recognizer name of recognizer function. @param num_fields number of fields in constructor. @param field_names names of the constructor fields. - @param sorts field sorts, [None] + @param sorts field sorts, [None] if the field sort refers to a recursive sort. @param sort_refs reference to datatype sort that is an argument to the constructor; if the corresponding - sort reference is [None], - then the value in sort_refs should be an index referring to - one of the recursive datatypes that is declared. - + sort reference is [None], + then the value in sort_refs should be an index referring to + one of the recursive datatypes that is declared. def_API('mk_constructor', CONSTRUCTOR, (_in(CONTEXT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(3, SYMBOL), _in_array(3, SORT), _in_array(3, UINT))) *) external mk_constructor : context -> symbol -> symbol -> symbol array -> sort array -> int array -> constructor - = "camlidl_z3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor" + = "camlidl_z3V3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor" (** Summary: Reclaim memory allocated to constructor. - @param c logical context. @param constr constructor. - def_API('del_constructor', VOID, (_in(CONTEXT), _in(CONSTRUCTOR))) *) external del_constructor : context -> constructor -> unit = "camlidl_z3V3_Z3_del_constructor" (** - Summary: Create datatype, such as lists, trees, records, enumerations or unions of records. + Summary: Create datatype, such as lists, trees, records, enumerations or unions of records. The datatype may be recursive. Return the datatype sort. - @param c logical context. - @param name name of datatype. + @param name name of datatype. @param num_constructors number of constructors passed in. @param constructors array of constructor containers. - def_API('mk_datatype', SORT, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _inout_array(2, CONSTRUCTOR))) *) external mk_datatype : context -> symbol -> constructor array -> sort * constructor array @@ -7454,11 +6399,9 @@ external mk_datatype : context -> symbol -> constructor array -> sort * construc (** Summary: Create list of constructors. - @param c logical context. @param num_constructors number of constructors in list. @param constructors list of constructors. - def_API('mk_constructor_list', CONSTRUCTOR_LIST, (_in(CONTEXT), _in(UINT), _in_array(1, CONSTRUCTOR))) *) external mk_constructor_list : context -> constructor array -> constructor_list @@ -7466,12 +6409,9 @@ external mk_constructor_list : context -> constructor array -> constructor_list (** Summary: Reclaim memory allocated for constructor list. - Each constructor inside the constructor list must be independently reclaimed using {!del_constructor}. - @param c logical context. @param clist constructor list container. - def_API('del_constructor_list', VOID, (_in(CONTEXT), _in(CONSTRUCTOR_LIST))) *) external del_constructor_list : context -> constructor_list -> unit @@ -7479,28 +6419,24 @@ external del_constructor_list : context -> constructor_list -> unit (** Summary: Create mutually recursive datatypes. - @param c logical context. @param num_sorts number of datatype sorts. @param sort_names names of datatype sorts. - @param sorts array of datattype sorts. + @param sorts array of datatype sorts. @param constructor_lists list of constructors, one list per sort. - def_API('mk_datatypes', VOID, (_in(CONTEXT), _in(UINT), _in_array(1, SYMBOL), _out_array(1, SORT), _inout_array(1, CONSTRUCTOR_LIST))) *) external mk_datatypes : context -> symbol array -> constructor_list array -> sort array * constructor_list array = "camlidl_z3V3_Z3_mk_datatypes" (** - Summary: Query constructor for declared functions. - + Summary: Query constructor for declared functions. @param c logical context. @param constr constructor container. The container must have been passed in to a {!mk_datatype} call. @param num_fields number of accessor fields in the constructor. @param constructor constructor function declaration. @param tester constructor test function declaration. @param accessors array of accessor function declarations. - def_API('query_constructor', VOID, (_in(CONTEXT), _in(CONSTRUCTOR), _in(UINT), _out(FUNC_DECL), _out(FUNC_DECL), _out_array(2, FUNC_DECL))) *) external query_constructor : context -> constructor -> int -> func_decl * func_decl * func_decl array @@ -7511,22 +6447,17 @@ external query_constructor : context -> constructor -> int -> func_decl * func_d *) (** Summary: Declare a constant or function. - [mk_func_decl c n d r] creates a function with name [n], domain [d], and range [r]. - The arity of the function is the size of the array [d]. - + The arity of the function is the size of the array [d]. @param c logical context. @param s name of the constant or function. @param domain_size number of arguments. It is 0 when declaring a constant. @param domain array containing the sort of each argument. The array must contain domain_size elements. It is 0 when declaring a constant. @param range sort of the constant or the return sort of the function. - After declaring a constant or function, the function {!mk_app} can be used to create a constant or function application. - - {b See also}: {!mk_app} - def_API('mk_func_decl', FUNC_DECL, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SORT), _in(SORT))) *) external mk_func_decl : context -> symbol -> sort array -> sort -> func_decl @@ -7534,9 +6465,7 @@ external mk_func_decl : context -> symbol -> sort array -> sort -> func_decl (** Summary: Create a constant or function application. - - {b See also}: {!mk_func_decl} - def_API('mk_app', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT), _in_array(2, AST))) *) external mk_app : context -> func_decl -> ast array -> ast @@ -7544,18 +6473,9 @@ external mk_app : context -> func_decl -> ast array -> ast (** Summary: Declare and create a constant. - - - - - - - - [mk_const c s t] is a shorthand for [mk_app c (mk_func_decl c s [||] t) [||]] - + [mk_const c s t] is a shorthand for [mk_app c (mk_func_decl c s [||] t) [||]] - {b See also}: {!mk_func_decl} - {b See also}: {!mk_app} - def_API('mk_const', AST, (_in(CONTEXT), _in(SYMBOL), _in(SORT))) *) external mk_const : context -> symbol -> sort -> ast @@ -7563,14 +6483,8 @@ external mk_const : context -> symbol -> sort -> ast (** Summary: Declare a fresh constant or function. - Z3 will generate an unique name for this function declaration. - - - - - {b See also}: {!mk_func_decl} - def_API('mk_fresh_func_decl', FUNC_DECL, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SORT), _in(SORT))) *) external mk_fresh_func_decl : context -> string -> sort array -> sort -> func_decl @@ -7578,17 +6492,9 @@ external mk_fresh_func_decl : context -> string -> sort array -> sort -> func_de (** Summary: Declare and create a fresh constant. - - - - - [mk_fresh_const c p t] is a shorthand for [mk_app c (mk_fresh_func_decl c p [||] t) [||]]. - - - + [mk_fresh_const c p t] is a shorthand for [mk_app c (mk_fresh_func_decl c p [||] t) [||]]. - {b See also}: {!mk_func_decl} - {b See also}: {!mk_app} - def_API('mk_fresh_const', AST, (_in(CONTEXT), _in(STRING), _in(SORT))) *) external mk_fresh_const : context -> string -> sort -> ast @@ -7599,7 +6505,6 @@ external mk_fresh_const : context -> string -> sort -> ast *) (** Summary: Create an AST node representing [true]. - def_API('mk_true', AST, (_in(CONTEXT), )) *) external mk_true : context -> ast @@ -7607,7 +6512,6 @@ external mk_true : context -> ast (** Summary: Create an AST node representing [false]. - def_API('mk_false', AST, (_in(CONTEXT), )) *) external mk_false : context -> ast @@ -7616,51 +6520,40 @@ external mk_false : context -> ast (** Summary: \[ [ mk_eq c l r ] \] Create an AST node representing {e l = r }. - - The nodes [l] and [r] must have the same type. - + The nodes [l] and [r] must have the same type. def_API('mk_eq', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_eq : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_eq" (** - Summary: \[ [mk_distinct c [| t_1; ...; t_n |]] \] Create an AST node represeting a distinct construct. It is used for declaring - the arguments t_i pairwise distinct. - + the arguments t_i pairwise distinct. The [distinct] construct is used for declaring the arguments pairwise distinct. That is, {e Forall 0 <= i < j < num_args. not args[i] = args[j] }. - All arguments must have the same sort. - - {b Remarks}: The number of arguments of a distinct construct must be greater than one. - def_API('mk_distinct', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_distinct : context -> ast array -> ast = "camlidl_z3V3_Z3_mk_distinct" (** - Summary: \[ [ mk_not c a ] \] + Summary: \[ [ mk_not c a ] \] Create an AST node representing {e not(a) }. - The node [a] must have Boolean sort. - def_API('mk_not', AST, (_in(CONTEXT), _in(AST))) *) external mk_not : context -> ast -> ast = "camlidl_z3V3_Z3_mk_not" (** - Summary: \[ [ mk_ite c t1 t2 t2 ] \] + Summary: \[ [ mk_ite c t1 t2 t2 ] \] Create an AST node representing an if-then-else: {e ite(t1, t2, t3) }. - The node [t1] must have Boolean sort, [t2] and [t3] must have the same sort. The sort of the new node is equal to the sort of [t2] and [t3]. - def_API('mk_ite', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(AST))) *) external mk_ite : context -> ast -> ast -> ast -> ast @@ -7669,9 +6562,7 @@ external mk_ite : context -> ast -> ast -> ast -> ast (** Summary: \[ [ mk_iff c t1 t2 ] \] Create an AST node representing {e t1 iff t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_iff', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_iff : context -> ast -> ast -> ast @@ -7680,9 +6571,7 @@ external mk_iff : context -> ast -> ast -> ast (** Summary: \[ [ mk_implies c t1 t2 ] \] Create an AST node representing {e t1 implies t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_implies', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_implies : context -> ast -> ast -> ast @@ -7691,37 +6580,25 @@ external mk_implies : context -> ast -> ast -> ast (** Summary: \[ [ mk_xor c t1 t2 ] \] Create an AST node representing {e t1 xor t2 }. - The nodes [t1] and [t2] must have Boolean sort. - def_API('mk_xor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_xor : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_xor" (** - - Summary: \[ [mk_and c [| t_1; ...; t_n |]] \] Create the conjunction: {e t_1 and ... and t_n}. - - + Summary: \[ [mk_and c [| t_1; ...; t_n |]] \] Create the conjunction: {e t_1 and ... and t_n}. All arguments must have Boolean sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_and', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_and : context -> ast array -> ast = "camlidl_z3V3_Z3_mk_and" (** - - Summary: \[ [mk_or c [| t_1; ...; t_n |]] \] Create the disjunction: {e t_1 or ... or t_n}. - - + Summary: \[ [mk_or c [| t_1; ...; t_n |]] \] Create the disjunction: {e t_1 or ... or t_n}. All arguments must have Boolean sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_or', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_or : context -> ast array -> ast @@ -7731,110 +6608,78 @@ external mk_or : context -> ast array -> ast {2 {L Arithmetic: Integers and Reals}} *) (** - - Summary: \[ [mk_add c [| t_1; ...; t_n |]] \] Create the term: {e t_1 + ... + t_n}. - - + Summary: \[ [mk_add c [| t_1; ...; t_n |]] \] Create the term: {e t_1 + ... + t_n}. All arguments must have int or real sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_add', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_add : context -> ast array -> ast = "camlidl_z3V3_Z3_mk_add" (** - - Summary: \[ [mk_mul c [| t_1; ...; t_n |]] \] Create the term: {e t_1 * ... * t_n}. - - + Summary: \[ [mk_mul c [| t_1; ...; t_n |]] \] Create the term: {e t_1 * ... * t_n}. All arguments must have int or real sort. - - {b Remarks}: Z3 has limited support for non-linear arithmetic. - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_mul', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_mul : context -> ast array -> ast = "camlidl_z3V3_Z3_mk_mul" (** - - Summary: \[ [mk_sub c [| t_1; ...; t_n |]] \] Create the term: {e t_1 - ... - t_n}. - - + Summary: \[ [mk_sub c [| t_1; ...; t_n |]] \] Create the term: {e t_1 - ... - t_n}. All arguments must have int or real sort. - - {b Remarks}: The number of arguments must be greater than zero. - def_API('mk_sub', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_sub : context -> ast array -> ast = "camlidl_z3V3_Z3_mk_sub" (** - - Summary: \[ [mk_unary_minus c arg] \] Create the term: {e - arg}. - + Summary: \[ [mk_unary_minus c arg] \] Create the term: {e - arg}. The arguments must have int or real type. - def_API('mk_unary_minus', AST, (_in(CONTEXT), _in(AST))) *) external mk_unary_minus : context -> ast -> ast = "camlidl_z3V3_Z3_mk_unary_minus" (** - - Summary: \[ [mk_div c t_1 t_2] \] Create the term: {e t_1 div t_2}. - + Summary: \[ [mk_div c t_1 t_2] \] Create the term: {e t_1 div t_2}. The arguments must either both have int type or both have real type. If the arguments have int type, then the result type is an int type, otherwise the the result type is real. - def_API('mk_div', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_div : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_div" (** - - Summary: \[ [mk_mod c t_1 t_2] \] Create the term: {e t_1 mod t_2}. - + Summary: \[ [mk_mod c t_1 t_2] \] Create the term: {e t_1 mod t_2}. The arguments must have int type. - def_API('mk_mod', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_mod : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_mod" (** - - Summary: \[ [mk_rem c t_1 t_2] \] Create the term: {e t_1 rem t_2}. - + Summary: \[ [mk_rem c t_1 t_2] \] Create the term: {e t_1 rem t_2}. The arguments must have int type. - def_API('mk_rem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_rem : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_rem" (** - - The arguments must have int or real type. - def_API('mk_power', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_power : context -> ast -> ast -> ast = "camlidl_z3V3_Z3_mk_power" (** - Summary: \[ [ mk_lt c t1 t2 ] \] + Summary: \[ [ mk_lt c t1 t2 ] \] Create less than. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_lt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_lt : context -> ast -> ast -> ast @@ -7843,9 +6688,7 @@ external mk_lt : context -> ast -> ast -> ast (** Summary: \[ [ mk_le c t1 t2 ] \] Create less than or equal to. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_le', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_le : context -> ast -> ast -> ast @@ -7854,9 +6697,7 @@ external mk_le : context -> ast -> ast -> ast (** Summary: \[ [ mk_gt c t1 t2 ] \] Create greater than. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_gt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_gt : context -> ast -> ast -> ast @@ -7865,9 +6706,7 @@ external mk_gt : context -> ast -> ast -> ast (** Summary: \[ [ mk_ge c t1 t2 ] \] Create greater than or equal to. - The nodes [t1] and [t2] must have the same sort, and must be int or real. - def_API('mk_ge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ge : context -> ast -> ast -> ast @@ -7876,19 +6715,14 @@ external mk_ge : context -> ast -> ast -> ast (** Summary: \[ [ mk_int2real c t1 ] \] 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 + You can take the floor of a real by creating an auxiliary integer constant [k] and - and asserting {e mk_int2real(k) <= t1 < mk_int2real(k)+1 }. - + and asserting {e mk_int2real(k) <= t1 < mk_int2real(k)+1 }. The node [t1] must have sort integer. - - {b See also}: {!mk_real2int} - {b See also}: {!mk_is_int} - def_API('mk_int2real', AST, (_in(CONTEXT), _in(AST))) *) external mk_int2real : context -> ast -> ast @@ -7897,13 +6731,10 @@ external mk_int2real : context -> ast -> ast (** Summary: \[ [ mk_real2int c t1 ] \] Coerce a real to an integer. - The semantics of this function follows the SMT-LIB standard for the function to_int - - {b See also}: {!mk_int2real} - {b See also}: {!mk_is_int} - def_API('mk_real2int', AST, (_in(CONTEXT), _in(AST))) *) external mk_real2int : context -> ast -> ast @@ -7912,10 +6743,8 @@ external mk_real2int : context -> ast -> ast (** Summary: \[ [ mk_is_int c t1 ] \] Check if a real number is an integer. - - {b See also}: {!mk_int2real} - {b See also}: {!mk_real2int} - def_API('mk_is_int', AST, (_in(CONTEXT), _in(AST))) *) external mk_is_int : context -> ast -> ast @@ -7927,9 +6756,7 @@ external mk_is_int : context -> ast -> ast (** Summary: \[ [ mk_bvnot c t1 ] \] Bitwise negation. - The node [t1] must have a bit-vector sort. - def_API('mk_bvnot', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvnot : context -> ast -> ast @@ -7938,9 +6765,7 @@ external mk_bvnot : context -> ast -> ast (** Summary: \[ [ mk_bvredand c t1 ] \] Take conjunction of bits in vector, return vector of length 1. - The node [t1] must have a bit-vector sort. - def_API('mk_bvredand', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvredand : context -> ast -> ast @@ -7949,9 +6774,7 @@ external mk_bvredand : context -> ast -> ast (** Summary: \[ [ mk_bvredor c t1 ] \] Take disjunction of bits in vector, return vector of length 1. - The node [t1] must have a bit-vector sort. - def_API('mk_bvredor', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvredor : context -> ast -> ast @@ -7960,9 +6783,7 @@ external mk_bvredor : context -> ast -> ast (** Summary: \[ [ mk_bvand c t1 t2 ] \] Bitwise and. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvand', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvand : context -> ast -> ast -> ast @@ -7971,9 +6792,7 @@ external mk_bvand : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvor c t1 t2 ] \] Bitwise or. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvor : context -> ast -> ast -> ast @@ -7982,9 +6801,7 @@ external mk_bvor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvxor c t1 t2 ] \] Bitwise exclusive-or. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvxor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvxor : context -> ast -> ast -> ast @@ -7992,10 +6809,8 @@ external mk_bvxor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvnand c t1 t2 ] \] - Bitwise nand. - + Bitwise nand. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvnand', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvnand : context -> ast -> ast -> ast @@ -8003,10 +6818,8 @@ external mk_bvnand : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvnor c t1 t2 ] \] - Bitwise nor. - + Bitwise nor. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvnor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvnor : context -> ast -> ast -> ast @@ -8014,10 +6827,8 @@ external mk_bvnor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvxnor c t1 t2 ] \] - Bitwise xnor. - + Bitwise xnor. The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvxnor', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvxnor : context -> ast -> ast -> ast @@ -8026,9 +6837,7 @@ external mk_bvxnor : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvneg c t1 ] \] Standard two's complement unary minus. - The node [t1] must have bit-vector sort. - def_API('mk_bvneg', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvneg : context -> ast -> ast @@ -8037,9 +6846,7 @@ external mk_bvneg : context -> ast -> ast (** Summary: \[ [ mk_bvadd c t1 t2 ] \] Standard two's complement addition. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvadd : context -> ast -> ast -> ast @@ -8048,9 +6855,7 @@ external mk_bvadd : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsub c t1 t2 ] \] Standard two's complement subtraction. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsub : context -> ast -> ast -> ast @@ -8059,9 +6864,7 @@ external mk_bvsub : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvmul c t1 t2 ] \] Standard two's complement multiplication. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvmul : context -> ast -> ast -> ast @@ -8069,14 +6872,11 @@ external mk_bvmul : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvudiv c t1 t2 ] \] - Unsigned division. - + Unsigned division. It is defined as the [floor] of {e t1/t2 } if [t2] is different from zero. If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvudiv', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvudiv : context -> ast -> ast -> ast @@ -8085,17 +6885,11 @@ external mk_bvudiv : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsdiv c t1 t2 ] \] Two's complement signed division. - It is defined in the following way: - - The [floor] of {e t1/t2 } if [t2] is different from zero, and {e t1*t2 >= 0 }. - - The [ceiling] of {e t1/t2 } if [t2] is different from zero, and {e t1*t2 < 0 }. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsdiv', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsdiv : context -> ast -> ast -> ast @@ -8104,13 +6898,9 @@ external mk_bvsdiv : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvurem c t1 t2 ] \] Unsigned remainder. - It is defined as {e t1 - (t1 /u t2) * t2 }, where {e /u } represents unsigned int division. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvurem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvurem : context -> ast -> ast -> ast @@ -8119,16 +6909,11 @@ external mk_bvurem : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsrem c t1 t2 ] \] Two's complement signed remainder (sign follows dividend). - It is defined as {e t1 - (t1 /s t2) * t2 }, where {e /s } represents signed division. The most significant bit (sign) of the result is equal to the most significant bit of [t1]. - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - - {b See also}: {!mk_bvsmod} - def_API('mk_bvsrem', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsrem : context -> ast -> ast -> ast @@ -8137,13 +6922,9 @@ external mk_bvsrem : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsmod c t1 t2 ] \] Two's complement signed remainder (sign follows divisor). - If {e t2 } is zero, then the result is undefined. - The nodes [t1] and [t2] must have the same bit-vector sort. - - {b See also}: {!mk_bvsrem} - def_API('mk_bvsmod', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsmod : context -> ast -> ast -> ast @@ -8152,9 +6933,7 @@ external mk_bvsmod : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvult c t1 t2 ] \] Unsigned less than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvult', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvult : context -> ast -> ast -> ast @@ -8163,17 +6942,14 @@ external mk_bvult : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvslt c t1 t2 ] \] Two's complement signed less than. - It abbreviates: - {v + {v (or (and (= (extract[|m-1|:|m-1|] t1) bit1) (= (extract[|m-1|:|m-1|] t2) bit0)) (and (= (extract[|m-1|:|m-1|] t1) (extract[|m-1|:|m-1|] t2)) (bvult t1 t2))) v} - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvslt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvslt : context -> ast -> ast -> ast @@ -8182,9 +6958,7 @@ external mk_bvslt : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvule c t1 t2 ] \] Unsigned less than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvule', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvule : context -> ast -> ast -> ast @@ -8193,9 +6967,7 @@ external mk_bvule : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsle c t1 t2 ] \] Two's complement signed less than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsle', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsle : context -> ast -> ast -> ast @@ -8204,9 +6976,7 @@ external mk_bvsle : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvuge c t1 t2 ] \] Unsigned greater than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvuge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvuge : context -> ast -> ast -> ast @@ -8215,9 +6985,7 @@ external mk_bvuge : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsge c t1 t2 ] \] Two's complement signed greater than or equal to. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsge', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsge : context -> ast -> ast -> ast @@ -8226,9 +6994,7 @@ external mk_bvsge : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvugt c t1 t2 ] \] Unsigned greater than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvugt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvugt : context -> ast -> ast -> ast @@ -8237,9 +7003,7 @@ external mk_bvugt : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvsgt c t1 t2 ] \] Two's complement signed greater than. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsgt', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsgt : context -> ast -> ast -> ast @@ -8248,12 +7012,9 @@ external mk_bvsgt : context -> ast -> ast -> ast (** Summary: \[ [ mk_concat c t1 t2 ] \] Concatenate the given bit-vectors. - The nodes [t1] and [t2] must have (possibly different) bit-vector sorts - The result is a bit-vector of size {e n1+n2 }, where [n1] ([n2)] is the size of [t1] ([t2)]. - def_API('mk_concat', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_concat : context -> ast -> ast -> ast @@ -8264,9 +7025,7 @@ external mk_concat : context -> ast -> ast -> ast Extract the bits [high] down to [low] from a bitvector of size [m] to yield a new bitvector of size [n], where {e n = high - low + 1 }. - The node [t1] must have a bit-vector sort. - def_API('mk_extract', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in(AST))) *) external mk_extract : context -> int -> int -> ast -> ast @@ -8277,9 +7036,7 @@ external mk_extract : context -> int -> int -> ast -> ast Sign-extend of the given bit-vector to the (signed) equivalent bitvector of size {e m+i }, where [m] is the size of the given bit-vector. - The node [t1] must have a bit-vector sort. - def_API('mk_sign_ext', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_sign_ext : context -> int -> ast -> ast @@ -8287,12 +7044,10 @@ external mk_sign_ext : context -> int -> ast -> ast (** Summary: \[ [ mk_zero_ext c i t1 ] \] - Extend the given bit-vector with zeros to the (unsigned int) equivalent + Extend the given bit-vector with zeros to the (unsigned) equivalent bitvector of size {e m+i }, where [m] is the size of the given bit-vector. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_zero_ext', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_zero_ext : context -> int -> ast -> ast @@ -8301,9 +7056,7 @@ external mk_zero_ext : context -> int -> ast -> ast (** Summary: \[ [ mk_repeat c i t1 ] \] Repeat the given bit-vector up length {e i }. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_repeat', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_repeat : context -> int -> ast -> ast @@ -8312,16 +7065,12 @@ external mk_repeat : context -> int -> ast -> ast (** Summary: \[ [ mk_bvshl c t1 t2 ] \] Shift left. - It is equivalent to multiplication by {e 2^x } where [x] is the value of the third argument. - - NB. The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvshl', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvshl : context -> ast -> ast -> ast @@ -8330,16 +7079,12 @@ external mk_bvshl : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvlshr c t1 t2 ] \] Logical shift right. - It is equivalent to unsigned int division by {e 2^x } where [x] is the value of the third argument. - - NB. The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvlshr', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvlshr : context -> ast -> ast -> ast @@ -8348,17 +7093,13 @@ external mk_bvlshr : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvashr c t1 t2 ] \] 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. - - The semantics of shift operations varies between environments. This - definition does not necessarily capture directly the semantics of the + 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 nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvashr', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvashr : context -> ast -> ast -> ast @@ -8367,9 +7108,7 @@ external mk_bvashr : context -> ast -> ast -> ast (** Summary: \[ [ mk_rotate_left c i t1 ] \] Rotate bits of [t1] to the left [i] times. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_rotate_left', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_rotate_left : context -> int -> ast -> ast @@ -8378,9 +7117,7 @@ external mk_rotate_left : context -> int -> ast -> ast (** Summary: \[ [ mk_rotate_right c i t1 ] \] Rotate bits of [t1] to the right [i] times. - - The node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_rotate_right', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_rotate_right : context -> int -> ast -> ast @@ -8389,9 +7126,7 @@ external mk_rotate_right : context -> int -> ast -> ast (** Summary: \[ [ mk_ext_rotate_left c t1 t2 ] \] Rotate bits of [t1] to the left [t2] times. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_ext_rotate_left', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ext_rotate_left : context -> ast -> ast -> ast @@ -8400,9 +7135,7 @@ external mk_ext_rotate_left : context -> ast -> ast -> ast (** Summary: \[ [ mk_ext_rotate_right c t1 t2 ] \] Rotate bits of [t1] to the right [t2] times. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_ext_rotate_right', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_ext_rotate_right : context -> ast -> ast -> ast @@ -8411,13 +7144,10 @@ external mk_ext_rotate_right : context -> ast -> ast -> ast (** Summary: \[ [ mk_int2bv c n t1 ] \] Create an [n] bit bit-vector from the integer argument [t1]. - - NB. This function is essentially treated as uninterpreted. + 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 node [t1] must have integer sort. - + The node [t1] must have integer sort. def_API('mk_int2bv', AST, (_in(CONTEXT), _in(UINT), _in(AST))) *) external mk_int2bv : context -> int -> ast -> ast @@ -8426,17 +7156,14 @@ external mk_int2bv : context -> int -> ast -> ast (** Summary: \[ [ mk_bv2int c t1 is_signed ] \] Create an integer from the bit-vector argument [t1]. - If [is_signed] is false, then the bit-vector [t1] is treated as unsigned int. + If [is_signed] is false, then the bit-vector [t1] is treated as unsigned int. So the result is non-negative and in the range {e [0..2^N-1] }, where N are the number of bits in [t1]. If [is_signed] is true, [t1] is treated as a signed bit-vector. - - This function is essentially treated as uninterpreted. + 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 node [t1] must have a bit-vector sort. - + The node [t1] must have a bit-vector sort. def_API('mk_bv2int', AST, (_in(CONTEXT), _in(AST), _in(BOOL))) *) external mk_bv2int : context -> ast -> bool -> ast @@ -8446,9 +7173,7 @@ external mk_bv2int : context -> ast -> bool -> ast Summary: \[ [ mk_bvadd_no_overflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise addition of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvadd_no_overflow : context -> ast -> ast -> bool -> ast @@ -8458,9 +7183,7 @@ external mk_bvadd_no_overflow : context -> ast -> ast -> bool -> ast Summary: \[ [ mk_bvadd_no_underflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed addition of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvadd_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvadd_no_underflow : context -> ast -> ast -> ast @@ -8470,9 +7193,7 @@ external mk_bvadd_no_underflow : context -> ast -> ast -> ast Summary: \[ [ mk_bvsub_no_overflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed subtraction of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsub_no_overflow : context -> ast -> ast -> ast @@ -8482,9 +7203,7 @@ external mk_bvsub_no_overflow : context -> ast -> ast -> ast Summary: \[ [ mk_bvsub_no_underflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise subtraction of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsub_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvsub_no_underflow : context -> ast -> ast -> bool -> ast @@ -8492,11 +7211,9 @@ external mk_bvsub_no_underflow : context -> ast -> ast -> bool -> ast (** Summary: \[ [ mk_bvsdiv_no_overflow c t1 t2 ] \] - Create a predicate that checks that the bit-wise signed division + Create a predicate that checks that the bit-wise signed division of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvsdiv_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvsdiv_no_overflow : context -> ast -> ast -> ast @@ -8504,11 +7221,9 @@ external mk_bvsdiv_no_overflow : context -> ast -> ast -> ast (** Summary: \[ [ mk_bvneg_no_overflow c t1 ] \] - Check that bit-wise negation does not overflow when + Check that bit-wise negation does not overflow when [t1] is interpreted as a signed bit-vector. - The node [t1] must have bit-vector sort. - def_API('mk_bvneg_no_overflow', AST, (_in(CONTEXT), _in(AST))) *) external mk_bvneg_no_overflow : context -> ast -> ast @@ -8518,9 +7233,7 @@ external mk_bvneg_no_overflow : context -> ast -> ast Summary: \[ [ mk_bvmul_no_overflow c t1 t2 is_signed ] \] Create a predicate that checks that the bit-wise multiplication of [t1] and [t2] does not overflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul_no_overflow', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(BOOL))) *) external mk_bvmul_no_overflow : context -> ast -> ast -> bool -> ast @@ -8530,9 +7243,7 @@ external mk_bvmul_no_overflow : context -> ast -> ast -> bool -> ast Summary: \[ [ mk_bvmul_no_underflow c t1 t2 ] \] Create a predicate that checks that the bit-wise signed multiplication of [t1] and [t2] does not underflow. - The nodes [t1] and [t2] must have the same bit-vector sort. - def_API('mk_bvmul_no_underflow', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_bvmul_no_underflow : context -> ast -> ast -> ast @@ -8544,15 +7255,12 @@ external mk_bvmul_no_underflow : context -> ast -> ast -> ast (** Summary: \[ [ mk_select c a i ] \] 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 {e [domain -> range] }, + 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 {e [domain -> range] }, and [i] must have the sort [domain]. The sort of the result is [range]. - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_store} - def_API('mk_select', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_select : context -> ast -> ast -> ast @@ -8561,18 +7269,15 @@ external mk_select : context -> ast -> ast -> ast (** Summary: \[ [ mk_store c a i v ] \] Array update. - The node [a] must have an array sort {e [domain -> range] }, [i] must have sort [domain], [v] must have sort range. The sort of the result is {e [domain -> range] }. The semantics of this function is given by the theory of arrays described in the SMT-LIB - standard. See http: + 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 + 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). - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_select} - def_API('mk_store', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(AST))) *) external mk_store : context -> ast -> ast -> ast -> ast @@ -8580,14 +7285,11 @@ external mk_store : context -> ast -> ast -> ast -> ast (** Summary: Create the constant array. - - The resulting term is an array, such that a [select] on an arbitrary index + The resulting term is an array, such that a [select] on an arbitrary index produces the value [v]. - @param c logical context. @param domain domain sort for the array. @param v value that the array maps to. - def_API('mk_const_array', AST, (_in(CONTEXT), _in(SORT), _in(AST))) *) external mk_const_array : context -> sort -> ast -> ast @@ -8596,15 +7298,12 @@ external mk_const_array : context -> sort -> ast -> ast (** Summary: \[ [ mk_map f n args ] \] map f on the the argument arrays. - The [n] nodes [args] must be of array sorts {e [domain_i -> range_i] }. - The function declaration [f] must have type {e range_1 .. range_n -> range }. + The function declaration [f] must have type {e range_1 .. range_n -> range }. [v] must have sort range. The sort of the result is {e [domain_i -> range] }. - - {b See also}: {!mk_array_sort} - {b See also}: {!mk_store} - {b See also}: {!mk_select} - def_API('mk_map', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT), _in_array(2, AST))) *) external mk_map : context -> func_decl -> int -> ast -> ast @@ -8612,12 +7311,10 @@ external mk_map : context -> func_decl -> int -> ast -> ast (** Summary: Access the array default value. - Produces the default range value, for arrays that can be represented as + Produces the default range value, for arrays that can be represented as finite maps with a default range value. - @param c logical context. @param array array value whose default range value is accessed. - def_API('mk_array_default', AST, (_in(CONTEXT), _in(AST))) *) external mk_array_default : context -> ast -> ast @@ -8628,7 +7325,6 @@ external mk_array_default : context -> ast -> ast *) (** Summary: Create Set type. - def_API('mk_set_sort', SORT, (_in(CONTEXT), _in(SORT))) *) external mk_set_sort : context -> sort -> sort @@ -8636,7 +7332,6 @@ external mk_set_sort : context -> sort -> sort (** Summary: Create the empty set. - def_API('mk_empty_set', AST, (_in(CONTEXT), _in(SORT))) *) external mk_empty_set : context -> sort -> ast @@ -8644,7 +7339,6 @@ external mk_empty_set : context -> sort -> ast (** Summary: Create the full set. - def_API('mk_full_set', AST, (_in(CONTEXT), _in(SORT))) *) external mk_full_set : context -> sort -> ast @@ -8652,9 +7346,7 @@ external mk_full_set : context -> sort -> ast (** Summary: Add an element to a set. - The first argument must be a set, the second an element. - def_API('mk_set_add', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_add : context -> ast -> ast -> ast @@ -8662,9 +7354,7 @@ external mk_set_add : context -> ast -> ast -> ast (** Summary: Remove an element to a set. - The first argument must be a set, the second an element. - def_API('mk_set_del', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_del : context -> ast -> ast -> ast @@ -8672,7 +7362,6 @@ external mk_set_del : context -> ast -> ast -> ast (** Summary: Take the union of a list of sets. - def_API('mk_set_union', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_set_union : context -> ast array -> ast @@ -8680,7 +7369,6 @@ external mk_set_union : context -> ast array -> ast (** Summary: Take the intersection of a list of sets. - def_API('mk_set_intersect', AST, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_set_intersect : context -> ast array -> ast @@ -8688,7 +7376,6 @@ external mk_set_intersect : context -> ast array -> ast (** Summary: Take the set difference between two sets. - def_API('mk_set_difference', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_difference : context -> ast -> ast -> ast @@ -8696,7 +7383,6 @@ external mk_set_difference : context -> ast -> ast -> ast (** Summary: Take the complement of a set. - def_API('mk_set_complement', AST, (_in(CONTEXT), _in(AST))) *) external mk_set_complement : context -> ast -> ast @@ -8704,9 +7390,7 @@ external mk_set_complement : context -> ast -> ast (** Summary: Check for set membership. - The first argument should be an element type of the set. - def_API('mk_set_member', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_member : context -> ast -> ast -> ast @@ -8714,7 +7398,6 @@ external mk_set_member : context -> ast -> ast -> ast (** Summary: Check for subsetness of sets. - def_API('mk_set_subset', AST, (_in(CONTEXT), _in(AST), _in(AST))) *) external mk_set_subset : context -> ast -> ast -> ast @@ -8724,18 +7407,14 @@ external mk_set_subset : context -> ast -> ast -> ast {2 {L Numerals}} *) (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** - Summary: Create a numeral of a given sort. - + Summary: Create a numeral of a given sort. @param c logical context. @param numeral A string representing the numeral value in decimal notation. If the given sort is a real, then the numeral can be a rational, that is, a string of the form {e [num]* / [num]* }. - @param ty The sort of the numeral. In the current implementation, the given sort can be an int, real, finite-domain, or bit-vectors of arbitrary size. - + @param ty The sort of the numeral. In the current implementation, the given sort can be an int, real, finite-domain, or bit-vectors of arbitrary size. - {b See also}: {!mk_int} - - def_API('mk_numeral', AST, (_in(CONTEXT), _in(STRING), _in(SORT))) *) external mk_numeral : context -> string -> sort -> ast @@ -8743,43 +7422,32 @@ external mk_numeral : context -> string -> sort -> ast (** Summary: Create a real from a fraction. - @param c logical context. @param num numerator of rational. @param den denomerator of rational. - - {b Precondition}: den != 0 - - {b See also}: {!mk_numeral} - {b See also}: {!mk_int} - - def_API('mk_real', AST, (_in(CONTEXT), _in(INT), _in(INT))) *) external mk_real : context -> int -> int -> ast = "camlidl_z3V3_Z3_mk_real" (** - Summary: Create a numeral of an int, bit-vector, or finite-domain sort. - + Summary: Create a numeral of an int, bit-vector, or finite-domain sort. This function can be use to create numerals that fit in a machine integer. It is slightly faster than {!mk_numeral} since it is not necessary to parse a string. - - {b See also}: {!mk_numeral} - def_API('mk_int', AST, (_in(CONTEXT), _in(INT), _in(SORT))) *) external mk_int : context -> int -> sort -> ast = "camlidl_z3V3_Z3_mk_int" (** - Summary: Create a numeral of a int, bit-vector, or finite-domain sort. - + Summary: Create a numeral of a int, bit-vector, or finite-domain sort. This function can be use to create numerals that fit in a machine long long integer. It is slightly faster than {!mk_numeral} since it is not necessary to parse a string. - - {b See also}: {!mk_numeral} - def_API('mk_int64', AST, (_in(CONTEXT), _in(INT64), _in(SORT))) *) external mk_int64 : context -> int64 -> sort -> ast @@ -8790,22 +7458,17 @@ external mk_int64 : context -> int64 -> sort -> ast *) (** Summary: Create a pattern for quantifier instantiation. - Z3 uses pattern matching to instantiate quantifiers. If a pattern is not provided for a quantifier, then Z3 will automatically compute a set of patterns for it. However, for optimal performance, the user should provide the patterns. - Patterns comprise a list of terms. The list should be - non-empty. If the list comprises of more than one term, it is + non-empty. If the list comprises of more than one term, it is a called a multi-pattern. - In general, one can pass in a list of (multi-)patterns in the quantifier constructor. - - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_pattern', PATTERN, (_in(CONTEXT), _in(UINT), _in_array(1, AST))) *) external mk_pattern : context -> ast array -> pattern @@ -8813,12 +7476,10 @@ external mk_pattern : context -> ast array -> pattern (** Summary: Create 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. - - {v + {v 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 @@ -8826,18 +7487,14 @@ external mk_pattern : context -> ast array -> pattern 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)) v} - 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. - @param c logical context @param index de-Bruijn index @param ty sort of the bound variable - - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_bound', AST, (_in(CONTEXT), _in(UINT), _in(SORT))) *) external mk_bound : context -> int -> sort -> ast @@ -8846,21 +7503,17 @@ external mk_bound : context -> int -> sort -> ast (** Summary: Create a forall formula. It takes an expression [body] that contains bound variables of the same sorts as the sorts listed in the array [sorts]. The bound variables are de-Bruijn indices created - using {!mk_bound}. The array [decl_names] contains the names that the quantified formula uses for the + using {!mk_bound}. The array [decl_names] contains the names that the quantified formula uses for the bound variables. Z3 applies the convention that the last element in the [decl_names] and [sorts] array refers to the variable with index 0, the second to last element of [decl_names] and [sorts] refers to the variable with index 1, etc. - - [mk_forall c w p t n b] creates a forall formula, where [w] is the weight, [p] is an array of patterns, [t] is an array with the sorts of the bound variables, [n] is an array with the 'names' of the bound variables, and [b] is the body of the quantifier. Quantifiers are associated with weights indicating the importance of using the quantifier during - instantiation. - - + instantiation. @param c logical context. @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_patterns number of patterns. @@ -8869,33 +7522,28 @@ external mk_bound : context -> int -> sort -> ast @param sorts the sorts of the bound variables. @param decl_names names of the bound variables @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_exists} - def_API('mk_forall', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, PATTERN), _in(UINT), _in_array(4, SORT), _in_array(4, SYMBOL), _in(AST))) *) external mk_forall : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall" + = "camlidl_z3V3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall" (** Summary: Create an exists formula. Similar to {!mk_forall}. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_quantifier} - def_API('mk_exists', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, PATTERN), _in(UINT), _in_array(4, SORT), _in_array(4, SYMBOL), _in(AST))) *) external mk_exists : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists" + = "camlidl_z3V3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists" (** - Summary: Create a quantifier - universal or existential, with pattern hints. + Summary: Create a quantifier - universal or existential, with pattern hints. See the documentation for {!mk_forall} for an explanation of the parameters. - @param c logical context. @param is_forall flag to indicate if this is a universal or existential quantifier. @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @@ -8905,20 +7553,17 @@ external mk_exists : context -> int -> pattern array -> sort array -> symbol arr @param sorts array of sorts of the bound variables. @param decl_names names of the bound variables. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_quantifier', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(UINT), _in_array(3, PATTERN), _in(UINT), _in_array(5, SORT), _in_array(5, SYMBOL), _in(AST))) *) external mk_quantifier : context -> bool -> int -> pattern array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier" + = "camlidl_z3V3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier" (** Summary: Create a quantifier - universal or existential, with pattern hints, no patterns, and attributes - @param c logical context. @param is_forall flag to indicate if this is a universal or existential quantifier. @param quantifier_id identifier to identify quantifier @@ -8932,33 +7577,28 @@ external mk_quantifier : context -> bool -> int -> pattern array -> sort array - @param sorts array of sorts of the bound variables. @param decl_names names of the bound variables. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_bound} - {b See also}: {!mk_forall} - {b See also}: {!mk_exists} - def_API('mk_quantifier_ex', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(5, PATTERN), _in(UINT), _in_array(7, AST), _in(UINT), _in_array(9, SORT), _in_array(9, SYMBOL), _in(AST))) *) external mk_quantifier_ex : context -> bool -> int -> symbol -> symbol -> pattern array -> ast array -> sort array -> symbol array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex" + = "camlidl_z3V3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex" (** Summary: Create a universal quantifier using a list of constants that will form the set of bound variables. - @param c logical context. - @param weight quantifiers are associated with weights indicating the importance of using + @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_bound number of constants to be abstracted into bound variables. @param bound array of constants to be abstracted into bound variables. @param num_patterns number of patterns. @param patterns array containing the patterns created using {!mk_pattern}. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_exists_const} - def_API('mk_forall_const', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, APP), _in(UINT), _in_array(4, PATTERN), _in(AST))) *) external mk_forall_const : context -> int -> app array -> pattern array -> ast -> ast @@ -8966,61 +7606,54 @@ external mk_forall_const : context -> int -> app array -> pattern array -> ast - (** Summary: Similar to {!mk_forall_const}. - Summary: Create an existential quantifier using a list of constants that will form the set of bound variables. - @param c logical context. - @param weight quantifiers are associated with weights indicating the importance of using + @param weight quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0. @param num_bound number of constants to be abstracted into bound variables. @param bound array of constants to be abstracted into bound variables. @param num_patterns number of patterns. @param patterns array containing the patterns created using {!mk_pattern}. @param body the body of the quantifier. - - {b See also}: {!mk_pattern} - {b See also}: {!mk_forall_const} - def_API('mk_exists_const', AST, (_in(CONTEXT), _in(UINT), _in(UINT), _in_array(2, APP), _in(UINT), _in_array(4, PATTERN), _in(AST))) *) external mk_exists_const : context -> int -> app array -> pattern array -> ast -> ast = "camlidl_z3V3_Z3_mk_exists_const" (** - Summary: Create a universal or existential + Summary: Create a universal or existential quantifier using a list of constants that will form the set of bound variables. - def_API('mk_quantifier_const', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(UINT), _in_array(3, APP), _in(UINT), _in_array(5, PATTERN), _in(AST))) *) external mk_quantifier_const : context -> bool -> int -> app array -> pattern array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const" + = "camlidl_z3V3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const" (** - Summary: Create a universal or existential + Summary: Create a universal or existential quantifier using a list of constants that will form the set of bound variables. - def_API('mk_quantifier_const_ex', AST, (_in(CONTEXT), _in(BOOL), _in(UINT), _in(SYMBOL), _in(SYMBOL), _in(UINT), _in_array(5, APP), _in(UINT), _in_array(7, PATTERN), _in(UINT), _in_array(9, AST), _in(AST))) *) external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> app array -> pattern array -> ast array -> ast -> ast - = "camlidl_z3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex" + = "camlidl_z3V3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex" (** {2 {L Accessors}} *) (** - {3 {L Symbols}} + {3 {L Symbols}} *) (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** Summary: Return [INT_SYMBOL] if the symbol was constructed using {!mk_int_symbol}, and [STRING_SYMBOL] if the symbol was constructed using {!mk_string_symbol}. - def_API('get_symbol_kind', UINT, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_kind : context -> symbol -> symbol_kind @@ -9028,12 +7661,9 @@ external get_symbol_kind : context -> symbol -> symbol_kind (** Summary: \[ [ get_symbol_int c s ] \] - Return the symbol int value. - + Return the symbol int value. - {b Precondition}: get_symbol_kind s == INT_SYMBOL - - {b See also}: {!mk_int_symbol} - def_API('get_symbol_int', INT, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_int : context -> symbol -> int @@ -9041,27 +7671,19 @@ external get_symbol_int : context -> symbol -> int (** Summary: \[ [ get_symbol_string c s ] \] - Return the symbol name. - + Return the symbol name. - {b Precondition}: get_symbol_string s == STRING_SYMBOL - - - - - - {b See also}: {!mk_string_symbol} - def_API('get_symbol_string', STRING, (_in(CONTEXT), _in(SYMBOL))) *) external get_symbol_string : context -> symbol -> string = "camlidl_z3V3_Z3_get_symbol_string" (** - {3 {L Sorts}} + {3 {L Sorts}} *) (** - Summary: Return the sort name as a symbol. - + Summary: Return the sort name as a symbol. def_API('get_sort_name', SYMBOL, (_in(CONTEXT), _in(SORT))) *) external get_sort_name : context -> sort -> symbol @@ -9069,20 +7691,18 @@ external get_sort_name : context -> sort -> symbol (** Summary: Return a unique identifier for [s]. - - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. - + - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. def_API('get_sort_id', UINT, (_in(CONTEXT), _in(SORT))) *) external get_sort_id : context -> sort -> int = "camlidl_z3V3_Z3_get_sort_id" (** - {4 {L Redundant low-level API}} + {4 {L Redundant low-level API}} *) (** - Summary: Convert a [sort] into [ast]. - - {b Remarks}: [sort_to_ast c s] can be replaced by [(s :> ast)]. - + Summary: Convert a [sort] into [ast]. + - {b Remarks}: [sort_to_ast c s] can be replaced by [(s :> ast)]. def_API('sort_to_ast', AST, (_in(CONTEXT), _in(SORT))) *) external sort_to_ast : context -> sort -> ast @@ -9090,8 +7710,7 @@ external sort_to_ast : context -> sort -> ast (** Summary: compare sorts. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_sort', BOOL, (_in(CONTEXT), _in(SORT), _in(SORT))) *) external is_eq_sort : context -> sort -> sort -> bool @@ -9099,9 +7718,7 @@ external is_eq_sort : context -> sort -> sort -> bool (** Summary: Return the sort kind (e.g., array, tuple, int, bool, etc). - - {b See also}: {!sort_kind} - def_API('get_sort_kind', UINT, (_in(CONTEXT), _in(SORT))) *) external get_sort_kind : context -> sort -> sort_kind @@ -9109,23 +7726,18 @@ external get_sort_kind : context -> sort -> sort_kind (** Summary: \[ [ get_bv_sort_size c t ] \] - Return the size of the given bit-vector sort. - + Return the size of the given bit-vector sort. - {b Precondition}: get_sort_kind c t == BV_SORT - - {b See also}: {!mk_bv_sort} - {b See also}: {!get_sort_kind} - def_API('get_bv_sort_size', UINT, (_in(CONTEXT), _in(SORT))) *) external get_bv_sort_size : context -> sort -> int = "camlidl_z3V3_Z3_get_bv_sort_size" (** - - Summary: Return the size of the sort in [r]. Return [None] if the call failed. + Summary: Return the size of the sort in [r]. Return [None] if the call failed. That is, get_sort_kind(s) == FINITE_DOMAIN_SORT - def_API('get_finite_domain_sort_size', BOOL, (_in(CONTEXT), _in(SORT), _out(UINT64))) *) external get_finite_domain_sort_size : context -> sort -> int64 option @@ -9134,26 +7746,20 @@ external get_finite_domain_sort_size : context -> sort -> int64 option (** Summary: \[ [ get_array_sort_domain c t ] \] Return the domain of the given array sort. - - {b Precondition}: get_sort_kind c t == ARRAY_SORT - - {b See also}: {!mk_array_sort} - {b See also}: {!get_sort_kind} - def_API('get_array_sort_domain', SORT, (_in(CONTEXT), _in(SORT))) *) external get_array_sort_domain : context -> sort -> sort = "camlidl_z3V3_Z3_get_array_sort_domain" (** - Summary: \[ [ get_array_sort_range c t ] \] - Return the range of the given array sort. - + Summary: \[ [ get_array_sort_range c t ] \] + Return the range of the given array sort. - {b Precondition}: get_sort_kind c t == ARRAY_SORT - - {b See also}: {!mk_array_sort} - {b See also}: {!get_sort_kind} - def_API('get_array_sort_range', SORT, (_in(CONTEXT), _in(SORT))) *) external get_array_sort_range : context -> sort -> sort @@ -9162,13 +7768,10 @@ external get_array_sort_range : context -> sort -> sort (** Summary: \[ [ get_tuple_sort_mk_decl c t ] \] Return the constructor declaration of the given tuple - sort. - + sort. - {b Precondition}: get_sort_kind c t == DATATYPE_SORT - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_mk_decl', FUNC_DECL, (_in(CONTEXT), _in(SORT))) *) external get_tuple_sort_mk_decl : context -> sort -> func_decl @@ -9176,13 +7779,10 @@ external get_tuple_sort_mk_decl : context -> sort -> func_decl (** Summary: \[ [ get_tuple_sort_num_fields c t ] \] - Return the number of fields of the given tuple sort. - + Return the number of fields of the given tuple sort. - {b Precondition}: get_sort_kind c t == DATATYPE_SORT - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_num_fields', UINT, (_in(CONTEXT), _in(SORT))) *) external get_tuple_sort_num_fields : context -> sort -> int @@ -9191,14 +7791,11 @@ external get_tuple_sort_num_fields : context -> sort -> int (** Summary: \[ [ get_tuple_sort_field_decl c t i ] \] Return the i-th field declaration (i.e., projection function declaration) - of the given tuple sort. - + of the given tuple sort. - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: i < get_tuple_sort_num_fields c t - - {b See also}: {!mk_tuple_sort} - {b See also}: {!get_sort_kind} - def_API('get_tuple_sort_field_decl', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_tuple_sort_field_decl : context -> sort -> int -> func_decl @@ -9206,13 +7803,10 @@ external get_tuple_sort_field_decl : context -> sort -> int -> func_decl (** Summary: Return number of constructors for datatype. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_recognizer} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_num_constructors', UINT, (_in(CONTEXT), _in(SORT))) *) external get_datatype_sort_num_constructors : context -> sort -> int @@ -9220,14 +7814,11 @@ external get_datatype_sort_num_constructors : context -> sort -> int (** Summary: Return idx'th constructor. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx < get_datatype_sort_num_constructors c t - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_recognizer} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_constructor', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_datatype_sort_constructor : context -> sort -> int -> func_decl @@ -9235,14 +7826,11 @@ external get_datatype_sort_constructor : context -> sort -> int -> func_decl (** Summary: Return idx'th recognizer. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx < get_datatype_sort_num_constructors c t - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_constructor_accessor} - def_API('get_datatype_sort_recognizer', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_datatype_sort_recognizer : context -> sort -> int -> func_decl @@ -9250,15 +7838,12 @@ external get_datatype_sort_recognizer : context -> sort -> int -> func_decl (** Summary: Return idx_a'th accessor for the idx_c'th constructor. - - {b Precondition}: get_sort_kind t == DATATYPE_SORT - {b Precondition}: idx_c < get_datatype_sort_num_constructors c t - {b Precondition}: idx_a < get_domain_size c get_datatype_sort_constructor c idx_c - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_recognizer} - def_API('get_datatype_sort_constructor_accessor', FUNC_DECL, (_in(CONTEXT), _in(SORT), _in(UINT), _in(UINT))) *) external get_datatype_sort_constructor_accessor : context -> sort -> int -> int -> func_decl @@ -9266,11 +7851,8 @@ external get_datatype_sort_constructor_accessor : context -> sort -> int -> int (** Summary: Return arity of relation. - - {b Precondition}: get_sort_kind s == RELATION_SORT - - {b See also}: {!get_relation_column} - def_API('get_relation_arity', UINT, (_in(CONTEXT), _in(SORT))) *) external get_relation_arity : context -> sort -> int @@ -9278,24 +7860,20 @@ external get_relation_arity : context -> sort -> int (** Summary: Return sort at i'th column of relation sort. - - {b Precondition}: get_sort_kind c s == RELATION_SORT - {b Precondition}: col < get_relation_arity c s - - {b See also}: {!get_relation_arity} - def_API('get_relation_column', SORT, (_in(CONTEXT), _in(SORT), _in(UINT))) *) external get_relation_column : context -> sort -> int -> sort = "camlidl_z3V3_Z3_get_relation_column" (** - {3 {L Function Declarations}} + {3 {L Function Declarations}} *) (** - Summary: Convert a [func_decl] into [ast]. - - {b Remarks}: [func_decl_to_ast c f] can be replaced by [(f :> ast)]. - + Summary: Convert a [func_decl] into [ast]. + - {b Remarks}: [func_decl_to_ast c f] can be replaced by [(f :> ast)]. def_API('func_decl_to_ast', AST, (_in(CONTEXT), _in(FUNC_DECL))) *) external func_decl_to_ast : context -> func_decl -> ast @@ -9303,8 +7881,7 @@ external func_decl_to_ast : context -> func_decl -> ast (** Summary: compare terms. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_func_decl', BOOL, (_in(CONTEXT), _in(FUNC_DECL), _in(FUNC_DECL))) *) external is_eq_func_decl : context -> func_decl -> func_decl -> bool @@ -9312,16 +7889,14 @@ external is_eq_func_decl : context -> func_decl -> func_decl -> bool (** Summary: Return a unique identifier for [f]. - - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. - + - {b Remarks}: Implicitly used by [Pervasives.( = )] and [Pervasives.compare]. def_API('get_func_decl_id', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_func_decl_id : context -> func_decl -> int = "camlidl_z3V3_Z3_get_func_decl_id" (** - Summary: Return the constant declaration name as a symbol. - + Summary: Return the constant declaration name as a symbol. def_API('get_decl_name', SYMBOL, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_name : context -> func_decl -> symbol @@ -9329,7 +7904,6 @@ external get_decl_name : context -> func_decl -> symbol (** Summary: Return declaration kind corresponding to declaration. - def_API('get_decl_kind', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_kind : context -> func_decl -> decl_kind @@ -9337,9 +7911,7 @@ external get_decl_kind : context -> func_decl -> decl_kind (** Summary: Return the number of parameters of the given declaration. - - {b See also}: {!get_arity} - def_API('get_domain_size', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_domain_size : context -> func_decl -> int @@ -9347,9 +7919,7 @@ external get_domain_size : context -> func_decl -> int (** Summary: Alias for [get_domain_size]. - - {b See also}: {!get_domain_size} - def_API('get_arity', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_arity : context -> func_decl -> int @@ -9358,11 +7928,8 @@ external get_arity : context -> func_decl -> int (** Summary: \[ [ get_domain c d i ] \] Return the sort of the i-th parameter of the given function declaration. - - {b Precondition}: i < get_domain_size d - - {b See also}: {!get_domain_size} - def_API('get_domain', SORT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_domain : context -> func_decl -> int -> sort @@ -9370,11 +7937,9 @@ external get_domain : context -> func_decl -> int -> sort (** Summary: \[ [ get_range c d ] \] - Return the range of the given declaration. - + Return the range of the given declaration. If [d] is a constant (i.e., has zero arguments), then this function returns the sort of the constant. - def_API('get_range', SORT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_range : context -> func_decl -> sort @@ -9382,7 +7947,6 @@ external get_range : context -> func_decl -> sort (** Summary: Return the number of parameters associated with a declaration. - def_API('get_decl_num_parameters', UINT, (_in(CONTEXT), _in(FUNC_DECL))) *) external get_decl_num_parameters : context -> func_decl -> int @@ -9390,11 +7954,9 @@ external get_decl_num_parameters : context -> func_decl -> int (** Summary: Return the parameter type associated with a declaration. - @param c the context @param d the function declaration @param idx is the index of the named parameter it should be between 0 and the number of parameters. - def_API('get_decl_parameter_kind', UINT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_parameter_kind : context -> func_decl -> int -> parameter_kind @@ -9402,9 +7964,7 @@ external get_decl_parameter_kind : context -> func_decl -> int -> parameter_kind (** Summary: Return the integer value associated with an integer parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_INT - def_API('get_decl_int_parameter', INT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_int_parameter : context -> func_decl -> int -> int @@ -9412,9 +7972,7 @@ external get_decl_int_parameter : context -> func_decl -> int -> int (** Summary: Return the double value associated with an double parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_DOUBLE - def_API('get_decl_double_parameter', DOUBLE, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_double_parameter : context -> func_decl -> int -> float @@ -9422,9 +7980,7 @@ external get_decl_double_parameter : context -> func_decl -> int -> float (** Summary: Return the double value associated with an double parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_SYMBOL - def_API('get_decl_symbol_parameter', SYMBOL, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_symbol_parameter : context -> func_decl -> int -> symbol @@ -9432,9 +7988,7 @@ external get_decl_symbol_parameter : context -> func_decl -> int -> symbol (** Summary: Return the sort value associated with a sort parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_SORT - def_API('get_decl_sort_parameter', SORT, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_sort_parameter : context -> func_decl -> int -> sort @@ -9442,9 +7996,7 @@ external get_decl_sort_parameter : context -> func_decl -> int -> sort (** Summary: Return the expresson value associated with an expression parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_AST - def_API('get_decl_ast_parameter', AST, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_ast_parameter : context -> func_decl -> int -> ast @@ -9452,9 +8004,7 @@ external get_decl_ast_parameter : context -> func_decl -> int -> ast (** Summary: Return the expresson value associated with an expression parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_FUNC_DECL - def_API('get_decl_func_decl_parameter', FUNC_DECL, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_func_decl_parameter : context -> func_decl -> int -> func_decl @@ -9462,21 +8012,18 @@ external get_decl_func_decl_parameter : context -> func_decl -> int -> func_decl (** Summary: Return the rational value, as a string, associated with a rational parameter. - - {b Precondition}: get_decl_parameter_kind c d idx == PARAMETER_RATIONAL - def_API('get_decl_rational_parameter', STRING, (_in(CONTEXT), _in(FUNC_DECL), _in(UINT))) *) external get_decl_rational_parameter : context -> func_decl -> int -> string = "camlidl_z3V3_Z3_get_decl_rational_parameter" (** - {3 {L Applications}} + {3 {L Applications}} *) (** - Summary: Convert a [app] into [ast]. - - {b Remarks}: [app_to_ast c a] can be replaced by [(a :> ast)]. - + Summary: Convert a [app] into [ast]. + - {b Remarks}: [app_to_ast c a] can be replaced by [(a :> ast)]. def_API('app_to_ast', AST, (_in(CONTEXT), _in(APP))) *) external app_to_ast : context -> app -> ast @@ -9484,7 +8031,6 @@ external app_to_ast : context -> app -> ast (** Summary: Return the declaration of a constant or function application. - def_API('get_app_decl', FUNC_DECL, (_in(CONTEXT), _in(APP))) *) external get_app_decl : context -> app -> func_decl @@ -9494,7 +8040,6 @@ external get_app_decl : context -> app -> func_decl Summary: \[ [ get_app_num_args c a ] \] Return the number of argument of an application. If [t] is an constant, then the number of arguments is 0. - def_API('get_app_num_args', UINT, (_in(CONTEXT), _in(APP))) *) external get_app_num_args : context -> app -> int @@ -9503,21 +8048,18 @@ external get_app_num_args : context -> app -> int (** Summary: \[ [ get_app_arg c a i ] \] Return the i-th argument of the given application. - - {b Precondition}: i < get_num_args c a - def_API('get_app_arg', AST, (_in(CONTEXT), _in(APP), _in(UINT))) *) external get_app_arg : context -> app -> int -> ast = "camlidl_z3V3_Z3_get_app_arg" (** - {3 {L Terms}} + {3 {L Terms}} *) (** Summary: compare terms. - - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. - + - {b Remarks}: [Pervasives.( = )] or [Pervasives.compare] can also be used. def_API('is_eq_ast', BOOL, (_in(CONTEXT), _in(AST), _in(AST))) *) external is_eq_ast : context -> ast -> ast -> bool @@ -9525,8 +8067,7 @@ external is_eq_ast : context -> ast -> ast -> bool (** Summary: Return a unique identifier for [t]. - - {b Remarks}: Implicitly used by [Pervasives.compare] for values of type [ast], [app], [sort], [func_decl], and [pattern]. - + - {b Remarks}: Implicitly used by [Pervasives.compare] for values of type [ast], [app], [sort], [func_decl], and [pattern]. def_API('get_ast_id', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_id : context -> ast -> int @@ -9534,8 +8075,7 @@ external get_ast_id : context -> ast -> int (** Summary: Return a hash code for the given AST. - - {b Remarks}: Implicitly used by [Hashtbl.hash] for values of type [ast], [app], [sort], [func_decl], and [pattern]. - + - {b Remarks}: Implicitly used by [Hashtbl.hash] for values of type [ast], [app], [sort], [func_decl], and [pattern]. def_API('get_ast_hash', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_hash : context -> ast -> int @@ -9543,9 +8083,7 @@ external get_ast_hash : context -> ast -> int (** Summary: Return the sort of an AST node. - The AST node must be a constant, application, numeral, bound variable, or quantifier. - def_API('get_sort', SORT, (_in(CONTEXT), _in(AST))) *) external get_sort : context -> ast -> sort @@ -9553,7 +8091,6 @@ external get_sort : context -> ast -> sort (** Summary: Return true if the given expression [t] is well sorted. - def_API('is_well_sorted', BOOL, (_in(CONTEXT), _in(AST))) *) external is_well_sorted : context -> ast -> bool @@ -9561,7 +8098,6 @@ external is_well_sorted : context -> ast -> bool (** Summary: Return L_TRUE if [a] is true, L_FALSE if it is false, and L_UNDEF otherwise. - def_API('get_bool_value', UINT, (_in(CONTEXT), _in(AST))) *) external get_bool_value : context -> ast -> lbool @@ -9569,14 +8105,13 @@ external get_bool_value : context -> ast -> lbool (** Summary: Return the kind of the given AST. - def_API('get_ast_kind', UINT, (_in(CONTEXT), _in(AST))) *) external get_ast_kind : context -> ast -> ast_kind = "camlidl_z3V3_Z3_get_ast_kind" (** - def_API('is_app', BOOL, (_in(CONTEXT), _in(AST))) + def_API('is_app', BOOL, (_in(CONTEXT), _in(AST))) *) external is_app : context -> ast -> bool = "camlidl_z3V3_Z3_is_app" @@ -9589,17 +8124,14 @@ external is_numeral_ast : context -> ast -> bool (** Summary: Return true if the give AST is a real algebraic number. - def_API('is_algebraic_number', BOOL, (_in(CONTEXT), _in(AST))) *) external is_algebraic_number : context -> ast -> bool = "camlidl_z3V3_Z3_is_algebraic_number" (** - Summary: Convert an [ast] into an [APP_AST]. - - - {b Precondition}: {v get_ast_kind c a == [APP_AST] v} - + Summary: Convert an [ast] into an [APP_AST]. + - {b Precondition}: {v get_ast_kind c a == [APP_AST] v} def_API('to_app', APP, (_in(CONTEXT), _in(AST))) *) external to_app : context -> ast -> app @@ -9607,25 +8139,21 @@ external to_app : context -> ast -> app (** Summary: Convert an AST into a FUNC_DECL_AST. This is just type casting. - - - {b Precondition}: {v get_ast_kind c a == FUNC_DECL_AST v} - + - {b Precondition}: {v get_ast_kind c a == FUNC_DECL_AST v} def_API('to_func_decl', FUNC_DECL, (_in(CONTEXT), _in(AST))) *) external to_func_decl : context -> ast -> func_decl = "camlidl_z3V3_Z3_to_func_decl" (** - {4 {L Numerals}} + {4 {L Numerals}} *) (** - {5 {L Low-level API}} + {5 {L Low-level API}} *) (** Summary: Return numeral value, as a string of a numeric constant term - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_numeral_string', STRING, (_in(CONTEXT), _in(AST))) *) external get_numeral_string : context -> ast -> string @@ -9634,19 +8162,15 @@ external get_numeral_string : context -> ast -> string (** Summary: Return numeral as a string in decimal notation. The result has at most [precision] decimal places. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST || is_algebraic_number c a - - def_API('get_numeral_decimal_string', STRING, (_in(CONTEXT), _in(AST), _in(UINT))) + def_API('get_numeral_decimal_string', STRING, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_numeral_decimal_string : context -> ast -> int -> string = "camlidl_z3V3_Z3_get_numeral_decimal_string" (** Summary: Return the numerator (as a numeral AST) of a numeral AST of sort Real. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_numerator', AST, (_in(CONTEXT), _in(AST))) *) external get_numerator : context -> ast -> ast @@ -9654,9 +8178,7 @@ external get_numerator : context -> ast -> ast (** Summary: Return the denominator (as a numeral AST) of a numeral AST of sort Real. - - {b Precondition}: get_ast_kind c a == NUMERAL_AST - def_API('get_denominator', AST, (_in(CONTEXT), _in(AST))) *) external get_denominator : context -> ast -> ast @@ -9664,16 +8186,12 @@ external get_denominator : context -> ast -> ast (** Summary: Return numeral value, as a pair of 64 bit numbers if the representation fits. - @param c logical context. @param a term. @param num numerator. @param den denominator. - Return [TRUE] if the numeral value fits in 64 bit numerals, [FALSE] otherwise. - - {b Precondition}: get_ast_kind a == NUMERAL_AST - def_API('get_numeral_small', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) *) external get_numeral_small : context -> ast -> bool * int64 * int64 @@ -9683,11 +8201,8 @@ external get_numeral_small : context -> ast -> bool * int64 * int64 Summary: \[ [ get_numeral_int c v ] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit in a machine int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_int', BOOL, (_in(CONTEXT), _in(AST), _out(INT))) *) external get_numeral_int : context -> ast -> bool * int @@ -9697,11 +8212,8 @@ external get_numeral_int : context -> ast -> bool * int Summary: \[ [ get_numeral_int64 c v ] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit in a machine long long int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64))) *) external get_numeral_int64 : context -> ast -> bool * int64 @@ -9711,47 +8223,39 @@ external get_numeral_int64 : context -> ast -> bool * int64 Summary: \[ [ get_numeral_rational_int64 c x y] \] Similar to {!get_numeral_string}, but only succeeds if the value can fit as a rational number as machine long long int. Return TRUE if the call succeeded. - - {b Precondition}: get_ast_kind c v == NUMERAL_AST - - {b See also}: {!get_numeral_string} - def_API('get_numeral_rational_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64), _out(INT64))) *) external get_numeral_rational_int64 : context -> ast -> bool * int64 * int64 = "camlidl_z3V3_Z3_get_numeral_rational_int64" (** - Summary: Return a lower bound for the given real algebraic number. + Summary: Return a lower bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real. - - {b Precondition}: is_algebraic_number c a - def_API('get_algebraic_number_lower', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_algebraic_number_lower : context -> ast -> int -> ast = "camlidl_z3V3_Z3_get_algebraic_number_lower" (** - Summary: Return a upper bound for the given real algebraic number. + Summary: Return a upper bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real. - - {b Precondition}: is_algebraic_number c a - def_API('get_algebraic_number_upper', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_algebraic_number_upper : context -> ast -> int -> ast = "camlidl_z3V3_Z3_get_algebraic_number_upper" (** - {4 {L Patterns}} + {4 {L Patterns}} *) (** - Summary: Convert a pattern into ast. - - {b Remarks}: [pattern_to_ast c p] can be replaced by [(p :> ast)]. - + Summary: Convert a pattern into ast. + - {b Remarks}: [pattern_to_ast c p] can be replaced by [(p :> ast)]. def_API('pattern_to_ast', AST, (_in(CONTEXT), _in(PATTERN))) *) external pattern_to_ast : context -> pattern -> ast @@ -9759,7 +8263,6 @@ external pattern_to_ast : context -> pattern -> ast (** Summary: Return number of terms in pattern. - def_API('get_pattern_num_terms', UINT, (_in(CONTEXT), _in(PATTERN))) *) external get_pattern_num_terms : context -> pattern -> int @@ -9767,20 +8270,17 @@ external get_pattern_num_terms : context -> pattern -> int (** Summary: Return i'th ast in pattern. - def_API('get_pattern', AST, (_in(CONTEXT), _in(PATTERN), _in(UINT))) *) external get_pattern : context -> pattern -> int -> ast = "camlidl_z3V3_Z3_get_pattern" (** - {4 {L Quantifiers}} + {4 {L Quantifiers}} *) (** Summary: Return index of de-Brujin bound variable. - - {b Precondition}: get_ast_kind a == VAR_AST - def_API('get_index_value', UINT, (_in(CONTEXT), _in(AST))) *) external get_index_value : context -> ast -> int @@ -9788,29 +8288,23 @@ external get_index_value : context -> ast -> int (** Summary: Determine if quantifier is universal. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - - def_API('is_quantifier_forall', BOOL, (_in(CONTEXT), _in(AST))) + def_API('is_quantifier_forall', BOOL, (_in(CONTEXT), _in(AST))) *) external is_quantifier_forall : context -> ast -> bool = "camlidl_z3V3_Z3_is_quantifier_forall" (** Summary: Obtain weight of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - - def_API('get_quantifier_weight', UINT, (_in(CONTEXT), _in(AST))) + def_API('get_quantifier_weight', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_weight : context -> ast -> int = "camlidl_z3V3_Z3_get_quantifier_weight" (** Summary: Return number of patterns used in quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_patterns', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_patterns : context -> ast -> int @@ -9818,9 +8312,7 @@ external get_quantifier_num_patterns : context -> ast -> int (** Summary: Return i'th pattern. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_pattern_ast', PATTERN, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_pattern_ast : context -> ast -> int -> pattern @@ -9828,9 +8320,7 @@ external get_quantifier_pattern_ast : context -> ast -> int -> pattern (** Summary: Return number of no_patterns used in quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_no_patterns', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_no_patterns : context -> ast -> int @@ -9838,9 +8328,7 @@ external get_quantifier_num_no_patterns : context -> ast -> int (** Summary: Return i'th no_pattern. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_no_pattern_ast', AST, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_no_pattern_ast : context -> ast -> int -> ast @@ -9848,9 +8336,7 @@ external get_quantifier_no_pattern_ast : context -> ast -> int -> ast (** Summary: Return number of bound variables of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_num_bound', UINT, (_in(CONTEXT), _in(AST))) *) external get_quantifier_num_bound : context -> ast -> int @@ -9858,9 +8344,7 @@ external get_quantifier_num_bound : context -> ast -> int (** Summary: Return symbol of the i'th bound variable. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_bound_name', SYMBOL, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_bound_name : context -> ast -> int -> symbol @@ -9868,9 +8352,7 @@ external get_quantifier_bound_name : context -> ast -> int -> symbol (** Summary: Return sort of the i'th bound variable. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_bound_sort', SORT, (_in(CONTEXT), _in(AST), _in(UINT))) *) external get_quantifier_bound_sort : context -> ast -> int -> sort @@ -9878,22 +8360,18 @@ external get_quantifier_bound_sort : context -> ast -> int -> sort (** Summary: Return body of quantifier. - - {b Precondition}: get_ast_kind a == QUANTIFIER_AST - def_API('get_quantifier_body', AST, (_in(CONTEXT), _in(AST))) *) external get_quantifier_body : context -> ast -> ast = "camlidl_z3V3_Z3_get_quantifier_body" (** - {3 {L Simplification}} + {3 {L Simplification}} *) (** Summary: Interface to simplifier. - Provides an interface to the AST simplifier used by Z3. - def_API('simplify', AST, (_in(CONTEXT), _in(AST))) *) external simplify : context -> ast -> ast @@ -9904,10 +8382,9 @@ external simplify : context -> ast -> ast *) (** Summary: Update the arguments of term [a] using the arguments [args]. - The number of arguments [num_args] should coincide + The number of arguments [num_args] should coincide with the number of arguments to [a]. If [a] is a quantifier, then num_args has to be 1. - def_API('update_term', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST))) *) external update_term : context -> ast -> ast array -> ast @@ -9917,7 +8394,6 @@ external update_term : context -> ast -> ast array -> ast Summary: Substitute every occurrence of {e from[i] } in [a] with {e to[i] }, for [i] smaller than [num_exprs]. The result is the new AST. The arrays [from] and [to] must have size [num_exprs]. For every [i] smaller than [num_exprs], we must have that sort of {e from[i] } must be equal to sort of {e to[i] }. - def_API('substitute', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST), _in_array(2, AST))) *) external substitute : context -> ast -> ast array -> ast array -> ast @@ -9926,7 +8402,6 @@ external substitute : context -> ast -> ast array -> ast array -> ast (** Summary: Substitute the free variables in [a] with the expressions in [to]. For every [i] smaller than [num_exprs], the variable with de-Bruijn index [i] is replaced with term {e to[i] }. - def_API('substitute_vars', AST, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST))) *) external substitute_vars : context -> ast -> ast array -> ast @@ -9937,7 +8412,6 @@ external substitute_vars : context -> ast -> ast array -> ast *) (** Summary: Log interaction to a file. - extra_API('open_log', INT, (_in(STRING),)) *) external open_log : string -> bool @@ -9945,11 +8419,9 @@ external open_log : string -> bool (** Summary: Append user-defined string to interaction log. - The interaction log is opened using open_log. It contains the formulas that are checked using Z3. You can use this command to append comments, for instance. - extra_API('append_log', VOID, (_in(STRING),)) *) external append_log : string -> unit @@ -9957,7 +8429,6 @@ external append_log : string -> unit (** Summary: Close interaction log. - extra_API('close_log', VOID, ()) *) external close_log : unit -> unit @@ -9965,10 +8436,8 @@ external close_log : unit -> unit (** Summary: Enable/disable printing warning messages to the console. - Warnings are printed after passing [true], warning messages are - suppressed after calling this method with [false]. - + suppressed after calling this method with [false]. def_API('toggle_warning_messages', VOID, (_in(BOOL),)) *) external toggle_warning_messages : bool -> unit @@ -9979,19 +8448,16 @@ external toggle_warning_messages : bool -> unit *) (** Summary: Select mode for the format used for pretty-printing AST nodes. - The default mode for pretty printing AST nodes is to produce - SMT-LIB style output where common subexpressions are printed + SMT-LIB style output where common subexpressions are printed at each occurrence. The mode is called PRINT_SMTLIB_FULL. - To print shared common subexpressions only once, + To print shared common subexpressions only once, use the PRINT_LOW_LEVEL mode. To print in way that conforms to SMT-LIB standards and uses let expressions to share common sub-expressions use PRINT_SMTLIB_COMPLIANT. - - {b See also}: {!ast_to_string} - {b See also}: {!pattern_to_string} - {b See also}: {!func_decl_to_string} - def_API('set_ast_print_mode', VOID, (_in(CONTEXT), _in(PRINT_MODE))) *) external set_ast_print_mode : context -> ast_print_mode -> unit @@ -9999,13 +8465,8 @@ external set_ast_print_mode : context -> ast_print_mode -> unit (** Summary: Convert the given AST node into a string. - - - - - {b See also}: {!pattern_to_string} - {b See also}: {!sort_to_string} - def_API('ast_to_string', STRING, (_in(CONTEXT), _in(AST))) *) external ast_to_string : context -> ast -> string @@ -10031,11 +8492,6 @@ external func_decl_to_string : context -> func_decl -> string (** Summary: Convert the given model into a string. - - - - - def_API('model_to_string', STRING, (_in(CONTEXT), _in(MODEL))) *) external model_to_string : context -> model -> string @@ -10043,80 +8499,66 @@ external model_to_string : context -> model -> string (** Summary: Convert the given benchmark into SMT-LIB formatted string. - - - - - @param c - context. @param name - name of benchmark. The argument is optional. - @param logic - the benchmark logic. + @param logic - the benchmark logic. @param status - the status string (sat, unsat, or unknown) @param attributes - other attributes, such as source, difficulty or category. @param num_assumptions - number of assumptions. @param assumptions - auxiliary assumptions. @param formula - formula to be checked for consistency in conjunction with assumptions. - def_API('benchmark_to_smtlib_string', STRING, (_in(CONTEXT), _in(STRING), _in(STRING), _in(STRING), _in(STRING), _in(UINT), _in_array(5, AST), _in(AST))) *) external benchmark_to_smtlib_string : context -> string -> string -> string -> string -> ast array -> ast -> string - = "camlidl_z3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string" + = "camlidl_z3V3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string" (** {2 {L Parser interface}} *) (** Summary: \[ [ parse_smtlib2_string c str ] \] - Parse the given string using the SMT-LIB2 parser. - + Parse the given string using the SMT-LIB2 parser. It returns a formula comprising of the conjunction of assertions in the scope (up to push/pop) at the end of the string. - def_API('parse_smtlib2_string', AST, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib2_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - = "camlidl_z3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string" + = "camlidl_z3V3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string" (** Summary: Similar to {!parse_smtlib2_string}, but reads the benchmark from a file. - def_API('parse_smtlib2_file', AST, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib2_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - = "camlidl_z3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file" + = "camlidl_z3V3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file" (** - {4 {L Low-level API}} + {4 {L Low-level API}} *) (** Summary: \[ [ parse_smtlib_string c str sort_names sorts decl_names decls ] \] - Parse the given string using the SMT-LIB parser. - - The symbol table of the parser can be initialized using the given sorts and declarations. + Parse the given string using the SMT-LIB parser. + The symbol table of the parser can be initialized using the given sorts and declarations. The symbols in the arrays [sort_names] and [decl_names] don't need to match the names of the sorts and declarations in the arrays [sorts] and [decls]. This is an useful feature since we can use arbitrary names to reference sorts and declarations defined using the C API. - The formulas, assumptions and declarations defined in [str] can be extracted using the functions: - {!get_smtlib_num_formulas}, {!get_smtlib_formula}, {!get_smtlib_num_assumptions}, {!get_smtlib_assumption}, + {!get_smtlib_num_formulas}, {!get_smtlib_formula}, {!get_smtlib_num_assumptions}, {!get_smtlib_assumption}, {!get_smtlib_num_decls}, and {!get_smtlib_decl}. - def_API('parse_smtlib_string', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit - = "camlidl_z3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string" + = "camlidl_z3V3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string" (** Summary: Similar to {!parse_smtlib_string}, but reads the benchmark from a file. - def_API('parse_smtlib_file', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) *) external parse_smtlib_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit - = "camlidl_z3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file" + = "camlidl_z3V3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file" (** Summary: Return the number of SMTLIB formulas parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_formulas', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_formulas : context -> int @@ -10125,9 +8567,7 @@ external get_smtlib_num_formulas : context -> int (** Summary: \[ [ get_smtlib_formula c i ] \] Return the i-th formula parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_formulas c - def_API('get_smtlib_formula', AST, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_formula : context -> int -> ast @@ -10135,7 +8575,6 @@ external get_smtlib_formula : context -> int -> ast (** Summary: Return the number of SMTLIB assumptions parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_assumptions', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_assumptions : context -> int @@ -10144,9 +8583,7 @@ external get_smtlib_num_assumptions : context -> int (** Summary: \[ [ get_smtlib_assumption c i ] \] Return the i-th assumption parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_assumptions c - def_API('get_smtlib_assumption', AST, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_assumption : context -> int -> ast @@ -10154,7 +8591,6 @@ external get_smtlib_assumption : context -> int -> ast (** Summary: Return the number of declarations parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_decls', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_decls : context -> int @@ -10163,9 +8599,7 @@ external get_smtlib_num_decls : context -> int (** Summary: \[ [ get_smtlib_decl c i ] \] Return the i-th declaration parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_decls c - def_API('get_smtlib_decl', FUNC_DECL, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_decl : context -> int -> func_decl @@ -10173,7 +8607,6 @@ external get_smtlib_decl : context -> int -> func_decl (** Summary: Return the number of sorts parsed by {!parse_smtlib_string} or {!parse_smtlib_file}. - def_API('get_smtlib_num_sorts', UINT, (_in(CONTEXT), )) *) external get_smtlib_num_sorts : context -> int @@ -10182,9 +8615,7 @@ external get_smtlib_num_sorts : context -> int (** Summary: \[ [ get_smtlib_sort c i ] \] Return the i-th sort parsed by the last call to {!parse_smtlib_string} or {!parse_smtlib_file}. - - {b Precondition}: i < get_smtlib_num_sorts c - def_API('get_smtlib_sort', SORT, (_in(CONTEXT), _in(UINT))) *) external get_smtlib_sort : context -> int -> sort @@ -10193,50 +8624,43 @@ external get_smtlib_sort : context -> int -> sort (** Summary: \[ [ get_smtlib_error c ] \] Retrieve that last error message information generated from parsing. - def_API('get_smtlib_error', STRING, (_in(CONTEXT), )) *) external get_smtlib_error : context -> string = "camlidl_z3V3_Z3_get_smtlib_error" -(** - Summary: \[ [ parse_z3_string c str ] \] - Parse the given string using the Z3 native parser. - - Return the conjunction of asserts made in the input. - - def_API('parse_z3_string', AST, (_in(CONTEXT), _in(STRING))) -*) -external parse_z3_string : context -> string -> ast - = "camlidl_z3_Z3_parse_z3V3_string" - -(** - Summary: Similar to {!parse_z3_string}, but reads the benchmark from a file. - - def_API('parse_z3_file', AST, (_in(CONTEXT), _in(STRING))) -*) -external parse_z3_file : context -> string -> ast - = "camlidl_z3_Z3_parse_z3V3_file" - (** {2 {L Miscellaneous}} *) (** Summary: Return Z3 version number information. - def_API('get_version', VOID, (_out(UINT), _out(UINT), _out(UINT), _out(UINT))) *) external get_version : unit -> int * int * int * int = "camlidl_z3V3_Z3_get_version" (** - Summary: Reset all allocated resources. + Summary: Enable tracing messages tagged as [tag] when Z3 is compiled in debug mode. + It is a NOOP otherwise + def_API('enable_trace', VOID, (_in(STRING),)) +*) +external enable_trace : string -> unit + = "camlidl_z3V3_Z3_enable_trace" - Use this facility on out-of memory errors. +(** + Summary: Disable tracing messages tagged as [tag] when Z3 is compiled in debug mode. + It is a NOOP otherwise + def_API('disable_trace', VOID, (_in(STRING),)) +*) +external disable_trace : string -> unit + = "camlidl_z3V3_Z3_disable_trace" + +(** + Summary: Reset all allocated resources. + Use this facility on out-of memory errors. It allows discharging the previous state and resuming afresh. Any pointers previously returned by the API become invalid. - def_API('reset_memory', VOID, ()) *) external reset_memory : unit -> unit @@ -10277,15 +8701,12 @@ external theory_get_context : theory -> context (** Summary: Assert a theory axiom/lemmas during the search. - - An axiom added at search level [n] will remain in the logical context until - level [n] is backtracked. - + An axiom added at search level [n] will remain in the logical context until + level [n] is backtracked. The callbacks for push ({!set_push_callback}) and pop ({!set_pop_callback}) can be used to track when the search level is increased (i.e., new case-split) and decreased (i.e., case-split is backtracked). - Z3 tracks the theory axioms asserted. So, multiple assertions of the same axiom are ignored. *) @@ -10296,7 +8717,6 @@ external theory_assert_axiom : theory -> ast -> unit Summary: Inform to the logical context that [lhs] and [rhs] have the same interpretation in the model being built by theory [t]. If lhs = rhs is inconsistent with other theories, then the logical context will backtrack. - For more information, see the paper "Model-Based Theory Combination" in the Z3 website. *) external theory_assume_eq : theory -> ast -> ast -> unit @@ -10304,7 +8724,7 @@ external theory_assume_eq : theory -> ast -> ast -> unit (** Summary: Enable/disable the simplification of theory axioms asserted using {!theory_assert_axiom}. - By default, the simplification of theory specific operators is disabled. + By default, the simplification of theory specific operators is disabled. That is, the reduce theory callbacks are not invoked for theory axioms. The default behavior is useful when asserting axioms stating properties of theory operators. *) @@ -10319,12 +8739,11 @@ external theory_get_eqc_root : theory -> ast -> ast (** Summary: Return the next element in the equivalence class containing [n]. - The elements in an equivalence class are organized in a circular list. - You can traverse the list by calling this function multiple times + You can traverse the list by calling this function multiple times using the result from the previous call. This is illustrated in the code snippet below. - {v + {v ast curr = n; do curr = theory_get_eqc_next(theory, curr); @@ -10335,14 +8754,14 @@ external theory_get_eqc_next : theory -> ast -> ast = "camlidl_z3V3_Z3_theory_get_eqc_next" (** - Summary: Return the number of parents of [n] that are operators of the given theory. + Summary: Return the number of parents of [n] that are operators of the given theory. *) external theory_get_num_parents : theory -> ast -> int = "camlidl_z3V3_Z3_theory_get_num_parents" (** - Summary: Return the i-th parent of [n]. - See {!theory_get_num_parents}. + Summary: Return the i-th parent of [n]. + See {!theory_get_num_parents}. *) external theory_get_parent : theory -> ast -> int -> ast = "camlidl_z3V3_Z3_theory_get_parent" @@ -10369,7 +8788,6 @@ external theory_get_num_elems : theory -> int (** Summary: Return the i-th elem of the given theory in the logical context. - - {b See}: {!theory_get_num_elems} *) external theory_get_elem : theory -> int -> ast @@ -10385,7 +8803,6 @@ external theory_get_num_apps : theory -> int (** Summary: Return the i-th application of the given theory in the logical context. - - {b See}: {!theory_get_num_apps} *) external theory_get_app : theory -> int -> ast @@ -10396,11 +8813,9 @@ external theory_get_app : theory -> int -> ast *) (** Summary: Create injective function declaration - @deprecated This method just asserts a (universally quantified) formula that asserts that the new function is injective. It is compatible with the old interface for solving: {!assert_cnstr}, {!check_assumptions}, etc. - def_API('mk_injective_function', FUNC_DECL, (_in(CONTEXT), _in(SYMBOL), _in(UINT), _in_array(2, SORT), _in(SORT))) *) external mk_injective_function : context -> symbol -> sort array -> sort -> func_decl @@ -10414,9 +8829,7 @@ external mk_injective_function : context -> symbol -> sort array -> sort -> func It is incorrect to invoke this function after invoking {!check}, {!check_and_get_model}, {!check_assumptions} and {!push}. Return [TRUE] if the logic was changed successfully, and [FALSE] otherwise. - @deprecated Subsumed by {!mk_solver_for_logic} - def_API('set_logic', VOID, (_in(CONTEXT), _in(STRING))) *) external set_logic : context -> string -> bool @@ -10424,15 +8837,11 @@ external set_logic : context -> string -> bool (** Summary: Create a backtracking point. - - The logical context can be viewed as a stack of contexts. The + The logical context can be viewed as a stack of contexts. The scope level is the number of elements on this stack. The stack of contexts is simulated using trail (undo) stacks. - - {b See also}: {!pop} - @deprecated Subsumed by {!solver_push} - def_API('push', VOID, (_in(CONTEXT),)) *) external push : context -> unit @@ -10440,17 +8849,13 @@ external push : context -> unit (** Summary: Backtrack. - Restores the context from the top of the stack, and pops it off the - stack. Any changes to the logical context (by {!assert_cnstr} or + stack. Any changes to the logical context (by {!assert_cnstr} or other functions) between the matching {!push} and [pop] operators are flushed, and the context is completely restored to what it was right before the {!push}. - - {b See also}: {!push} - @deprecated Subsumed by {!solver_pop} - def_API('pop', VOID, (_in(CONTEXT), _in(UINT))) *) external pop : context -> int -> unit @@ -10458,38 +8863,17 @@ external pop : context -> int -> unit (** Summary: Retrieve the current scope level. - It retrieves the number of scopes that have been pushed, but not yet popped. - - {b See also}: {!push} - {b See also}: {!pop} - @deprecated Subsumed by {!solver_get_num_scopes}. - def_API('get_num_scopes', UINT, (_in(CONTEXT),)) *) external get_num_scopes : context -> int = "camlidl_z3V3_Z3_get_num_scopes" (** - - - - - - - - - - - - - - - - - @deprecated This function has no effect. - + @deprecated This function has no effect. def_API('persist_ast', VOID, (_in(CONTEXT), _in(AST), _in(UINT))) *) external persist_ast : context -> ast -> int -> unit @@ -10497,18 +8881,13 @@ external persist_ast : context -> ast -> int -> unit (** Summary: Assert a constraint into the logical context. - After one assertion, the logical context may become - inconsistent. - + inconsistent. The functions {!check} or {!check_and_get_model} should be used to check whether the logical context is consistent or not. - - {b See also}: {!check} - {b See also}: {!check_and_get_model} - @deprecated Subsumed by {!solver_assert} - def_API('assert_cnstr', VOID, (_in(CONTEXT), _in(AST))) *) external assert_cnstr : context -> ast -> unit @@ -10516,25 +8895,13 @@ external assert_cnstr : context -> ast -> unit (** Summary: Check whether the given logical context is consistent or not. - If the logical context is not unsatisfiable (i.e., the return value is different from [L_FALSE)] and model construction is enabled (see {!mk_config}), - - then a valid model is returned. Otherwise, it is unsafe to use the returned model. - - - - - - + then a valid model is returned. Otherwise, it is unsafe to use the returned model. - {b Remarks}: Model construction must be enabled using configuration parameters (See, {!mk_config}). - - {b See also}: {!check} - - @deprecated Subsumed by {!solver_check} - def_API('check_and_get_model', INT, (_in(CONTEXT), _out(MODEL))) *) external check_and_get_model : context -> lbool * model @@ -10542,13 +8909,9 @@ external check_and_get_model : context -> lbool * model (** Summary: Check whether the given logical context is consistent or not. - The function {!check_and_get_model} should be used when models are needed. - - {b See also}: {!check_and_get_model} - @deprecated Subsumed by {!solver_check} - def_API('check', INT, (_in(CONTEXT),)) *) external check : context -> lbool @@ -10556,40 +8919,23 @@ external check : context -> lbool (** Summary: Check whether the given logical context and optional assumptions is consistent or not. - If the logical context is not unsatisfiable (i.e., the return value is different from [L_FALSE)], - and model construction is enabled (see {!mk_config}), - - then a valid model is returned. Otherwise, it is unsafe to use the returned model. - - - - - + then a valid model is returned. Otherwise, it is unsafe to use the returned model. @param c logical context. @param num_assumptions number of auxiliary assumptions. @param assumptions array of auxiliary assumptions @param m optional pointer to a model. @param proof optional pointer to a proof term. - @param core_size size of unsatisfiable core. - @param core pointer to an array receiving unsatisfiable core. + @param core_size size of unsatisfiable core. + @param core pointer to an array receiving unsatisfiable core. The unsatisfiable core is a subset of the assumptions, so the array has the same size as the assumptions. The [core] array is not populated if [core_size] is set to 0. - - {b Precondition}: assumptions comprises of propositional literals. - In other words, you cannot use compound formulas for assumptions, + In other words, you cannot use compound formulas for assumptions, but should use propositional variables or negations of propositional variables. - - - - - - {b See also}: {!check} - - @deprecated Subsumed by {!solver_check_assumptions} - def_API('check_assumptions', INT, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _out(MODEL), _out(AST), _out(UINT), _out_array2(1, 5, AST))) *) external check_assumptions : context -> ast array -> int -> ast array -> lbool * model * ast * int * ast array @@ -10597,25 +8943,20 @@ external check_assumptions : context -> ast array -> int -> ast array -> lbool * (** Summary: Retrieve congruence class representatives for terms. - The function can be used for relying on Z3 to identify equal terms under the current set of assumptions. The array of terms and array of class identifiers should have the same length. The class identifiers are numerals that are assigned to the same value for their corresponding terms if the current context forces the terms to be - equal. You cannot deduce that terms corresponding to different numerals must be all different, + equal. You cannot deduce that terms corresponding to different numerals must be all different, (especially when using non-convex theories). All implied equalities are returned by this call. This means that two terms map to the same class identifier if and only if the current context implies that they are equal. - A side-effect of the function is a satisfiability check. The function return L_FALSE if the current assertions are not satisfiable. - - {b See also}: {!check_and_get_model} - {b See also}: {!check} - @deprecated Subsumed by solver API - def_API('get_implied_equalities', UINT, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _out_array(1, UINT))) *) external get_implied_equalities : context -> ast array -> lbool * int array @@ -10623,11 +8964,8 @@ external get_implied_equalities : context -> ast array -> lbool * int array (** Summary: Delete a model object. - - {b See also}: {!check_and_get_model} - @deprecated Subsumed by solver API - def_API('del_model', VOID, (_in(CONTEXT), _in(MODEL))) *) external del_model : context -> model -> unit @@ -10638,13 +8976,10 @@ external del_model : context -> model -> unit *) (** Summary: Cancel an ongoing check. - Notifies the current check to abort and return. This method should be called from a different thread than the one performing the check. - @deprecated Use {!interrupt} instead. - def_API('soft_check_cancel', VOID, (_in(CONTEXT), )) *) external soft_check_cancel : context -> unit @@ -10652,12 +8987,9 @@ external soft_check_cancel : context -> unit (** Summary: Retrieve reason for search failure. - - If a call to {!check} or {!check_and_get_model} returns L_UNDEF, + If a call to {!check} or {!check_and_get_model} returns L_UNDEF, use this facility to determine the more detailed cause of search failure. - @deprecated Subsumed by {!solver_get_reason_unknown} - def_API('get_search_failure', UINT, (_in(CONTEXT), )) *) external get_search_failure : context -> search_failure @@ -10668,20 +9000,16 @@ external get_search_failure : context -> search_failure *) (** Summary: Create a labeled formula. - @param c logical context. @param s name of the label. @param is_pos label polarity. @param f formula being labeled. - - A label behaves as an identity function, so the truth value of the - labeled formula is unchanged. Labels are used for identifying + A label behaves as an identity function, so the truth value of the + labeled formula is unchanged. Labels are used for identifying useful sub-formulas when generating counter-examples. - @deprecated Labels are only supported by the old Solver API. This feature is not essential (it can be simulated using auxiliary Boolean variables). It is only available for backward compatibility. - def_API('mk_label', AST, (_in(CONTEXT), _in(SYMBOL), _in(BOOL), _in(AST))) *) external mk_label : context -> symbol -> bool -> ast -> ast @@ -10690,14 +9018,11 @@ external mk_label : context -> symbol -> bool -> ast -> ast (** Summary: Retrieve the set of labels that were relevant in the context of the current satisfied context. - - {b See also}: {!del_literals} - {b See also}: {!get_num_literals} - {b See also}: {!get_label_symbol} - {b See also}: {!get_literal} - @deprecated This procedure is based on the old Solver API. - def_API('get_relevant_labels', LITERALS, (_in(CONTEXT), )) *) external get_relevant_labels : context -> literals @@ -10705,30 +9030,24 @@ external get_relevant_labels : context -> literals (** Summary: Retrieve the set of literals that satisfy the current context. - - {b See also}: {!del_literals} - {b See also}: {!get_num_literals} - {b See also}: {!get_label_symbol} - {b See also}: {!get_literal} - @deprecated This procedure is based on the old Solver API. - def_API('get_relevant_literals', LITERALS, (_in(CONTEXT), )) *) external get_relevant_literals : context -> literals = "camlidl_z3V3_Z3_get_relevant_literals" (** - Summary: Retrieve the set of literals that whose assignment were + Summary: Retrieve the set of literals that whose assignment were guess, but not propagated during the search. - - {b See also}: {!del_literals} - {b See also}: {!get_num_literals} - {b See also}: {!get_label_symbol} - {b See also}: {!get_literal} - @deprecated This procedure is based on the old Solver API. - def_API('get_guessed_literals', LITERALS, (_in(CONTEXT), )) *) external get_guessed_literals : context -> literals @@ -10736,11 +9055,8 @@ external get_guessed_literals : context -> literals (** Summary: Delete a labels context. - - {b See also}: {!get_relevant_labels} - @deprecated This procedure is based on the old Solver API. - def_API('del_literals', VOID, (_in(CONTEXT), _in(LITERALS))) *) external del_literals : context -> literals -> unit @@ -10748,11 +9064,8 @@ external del_literals : context -> literals -> unit (** Summary: Retrieve the number of label symbols that were returned. - - {b See also}: {!get_relevant_labels} - @deprecated This procedure is based on the old Solver API. - def_API('get_num_literals', UINT, (_in(CONTEXT), _in(LITERALS))) *) external get_num_literals : context -> literals -> int @@ -10760,9 +9073,7 @@ external get_num_literals : context -> literals -> int (** Summary: Retrieve label symbol at idx. - @deprecated This procedure is based on the old Solver API. - def_API('get_label_symbol', SYMBOL, (_in(CONTEXT), _in(LITERALS), _in(UINT))) *) external get_label_symbol : context -> literals -> int -> symbol @@ -10770,9 +9081,7 @@ external get_label_symbol : context -> literals -> int -> symbol (** Summary: Retrieve literal expression at idx. - @deprecated This procedure is based on the old Solver API. - def_API('get_literal', AST, (_in(CONTEXT), _in(LITERALS), _in(UINT))) *) external get_literal : context -> literals -> int -> ast @@ -10780,13 +9089,9 @@ external get_literal : context -> literals -> int -> ast (** Summary: Disable label. - The disabled label is not going to be used when blocking the subsequent search. - - {b See also}: {!block_literals} - @deprecated This procedure is based on the old Solver API. - def_API('disable_literal', VOID, (_in(CONTEXT), _in(LITERALS), _in(UINT))) *) external disable_literal : context -> literals -> int -> unit @@ -10794,9 +9099,7 @@ external disable_literal : context -> literals -> int -> unit (** Summary: Block subsequent checks using the remaining enabled labels. - @deprecated This procedure is based on the old Solver API. - def_API('block_literals', VOID, (_in(CONTEXT), _in(LITERALS))) *) external block_literals : context -> literals -> unit @@ -10807,13 +9110,9 @@ external block_literals : context -> literals -> unit *) (** Summary: Return the number of constants assigned by the given model. - - - {b Remarks}: Consider using {!get_model_constants}. - + - {b Remarks}: Consider using {!get_model_constants}. - {b See also}: {!get_model_constant} - @deprecated use {!model_get_num_consts} - def_API('get_model_num_constants', UINT, (_in(CONTEXT), _in(MODEL))) *) external get_model_num_constants : context -> model -> int @@ -10821,14 +9120,10 @@ external get_model_num_constants : context -> model -> int (** Summary: \[ [ get_model_constant c m i ] \] - Return the i-th constant in the given model. - - - {b Remarks}: Consider using {!get_model_constants}. - + Return the i-th constant in the given model. + - {b Remarks}: Consider using {!get_model_constants}. - {b Precondition}: i < get_model_num_constants c m - @deprecated use {!model_get_const_decl} - def_API('get_model_constant', FUNC_DECL, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external get_model_constant : context -> model -> int -> func_decl @@ -10836,12 +9131,9 @@ external get_model_constant : context -> model -> int -> func_decl (** Summary: Return the number of function interpretations in the given model. - 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. - @deprecated use {!model_get_num_funcs} - def_API('get_model_num_funcs', UINT, (_in(CONTEXT), _in(MODEL))) *) external get_model_num_funcs : context -> model -> int @@ -10850,24 +9142,18 @@ external get_model_num_funcs : context -> model -> int (** Summary: \[ [ get_model_func_decl c m i ] \] Return the declaration of the i-th function in the given model. - - {b Precondition}: i < get_model_num_funcs c m - - {b See also}: {!get_model_num_funcs} - @deprecated use {!model_get_func_decl} - def_API('get_model_func_decl', FUNC_DECL, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external get_model_func_decl : context -> model -> int -> func_decl = "camlidl_z3V3_Z3_get_model_func_decl" (** - Summary: Return the value of the given constant or function + Summary: Return the value of the given constant or function in the given model. - @deprecated Consider using {!model_eval} or {!model_get_func_interp} - def_API('eval_func_decl', BOOL, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL), _out(AST))) *) external eval_func_decl : context -> model -> func_decl -> bool * ast @@ -10875,17 +9161,14 @@ external eval_func_decl : context -> model -> func_decl -> bool * ast (** Summary: \[ [ is_array_value c v ] \] - Determine whether the term encodes an array value. - A term encodes an array value if it is a nested sequence of + Determine whether the term encodes an array value. + A term encodes an array value if it is a nested sequence of applications of store on top of a constant array. The indices to the stores have to be values (for example, integer constants) so that equality between the indices can be evaluated. Array values are useful for representing interpretations for arrays. - Return the number of entries mapping to non-default values of the array. - @deprecated Use {!is_as_array} - def_API('is_array_value', BOOL, (_in(CONTEXT), _in(MODEL), _in(AST), _out(UINT))) *) external is_array_value : context -> model -> ast -> bool * int @@ -10895,11 +9178,8 @@ external is_array_value : context -> model -> ast -> bool * int Summary: \[ [ get_array_value c v ] \] An array values is represented as a dictionary plus a default (else) value. This function returns the array graph. - - - {b Precondition}: TRUE == is_array_value c v &num_entries - + - {b Precondition}: TRUE == is_array_value c v &num_entries @deprecated Use func_interp objects and {!get_as_array_func_decl} - def_API('get_array_value', VOID, (_in(CONTEXT), _in(MODEL), _in(AST), _in(UINT), _out_array(3, AST), _out_array(3, AST), _out (AST))) *) external get_array_value : context -> model -> ast -> ast array -> ast array -> ast array * ast array * ast @@ -10908,20 +9188,14 @@ external get_array_value : context -> model -> ast -> ast array -> ast array -> (** Summary: \[ [ get_model_func_else c m i ] \] Return the 'else' value of the i-th function interpretation in the given model. - A function interpretation is represented as a finite map and an 'else' value. - - - {b Remarks}: Consider using {!get_model_funcs}. - + - {b Remarks}: Consider using {!get_model_funcs}. - {b Precondition}: i < get_model_num_funcs c m - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_num_entries} - {b See also}: {!get_model_func_entry_num_args} - {b See also}: {!get_model_func_entry_arg} - @deprecated Use func_interp objects - def_API('get_model_func_else', AST, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external get_model_func_else : context -> model -> int -> ast @@ -10930,20 +9204,14 @@ external get_model_func_else : context -> model -> int -> ast (** Summary: \[ [ get_model_func_num_entries c m i ] \] Return the number of entries of the i-th function interpretation in the given model. - A function interpretation is represented as a finite map and an 'else' value. - - - {b Remarks}: Consider using {!get_model_funcs}. - + - {b Remarks}: Consider using {!get_model_funcs}. - {b Precondition}: i < get_model_num_funcs c m - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_else} - {b See also}: {!get_model_func_entry_num_args} - {b See also}: {!get_model_func_entry_arg} - @deprecated Use func_interp objects - def_API('get_model_func_num_entries', UINT, (_in(CONTEXT), _in(MODEL), _in(UINT))) *) external get_model_func_num_entries : context -> model -> int -> int @@ -10953,24 +9221,16 @@ external get_model_func_num_entries : context -> model -> int -> int Summary: \[ [ get_model_func_entry_num_args c m i j ] \] Return the number of arguments of the j-th entry of the i-th function interpretation in the given model. - A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map. - An entry represents the value of a function given a set of arguments. - - - - {b Remarks}: Consider using {!get_model_funcs}. - + - {b Remarks}: Consider using {!get_model_funcs}. - {b Precondition}: i < get_model_num_funcs c m - {b Precondition}: j < get_model_func_num_entries c m i - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_num_entries } - {b See also}: {!get_model_func_entry_arg} - @deprecated Use func_interp objects - def_API('get_model_func_entry_num_args', UINT, (_in(CONTEXT), _in(MODEL), _in(UINT), _in(UINT))) *) external get_model_func_entry_num_args : context -> model -> int -> int -> int @@ -10980,25 +9240,17 @@ external get_model_func_entry_num_args : context -> model -> int -> int -> int Summary: \[ [ get_model_func_entry_arg c m i j k ] \] Return the k-th argument of the j-th entry of the i-th function interpretation in the given model. - A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map. - An entry represents the value of a function given a set of arguments. - - - - {b Remarks}: Consider using {!get_model_funcs}. - + - {b Remarks}: Consider using {!get_model_funcs}. - {b Precondition}: i < get_model_num_funcs c m - {b Precondition}: j < get_model_func_num_entries c m i - {b Precondition}: k < get_model_func_entry_num_args c m i j - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_num_entries } - {b See also}: {!get_model_func_entry_num_args} - @deprecated Use func_interp objects - def_API('get_model_func_entry_arg', AST, (_in(CONTEXT), _in(MODEL), _in(UINT), _in(UINT), _in(UINT))) *) external get_model_func_entry_arg : context -> model -> int -> int -> int -> ast @@ -11008,23 +9260,15 @@ external get_model_func_entry_arg : context -> model -> int -> int -> int -> ast Summary: \[ [ get_model_func_entry_value c m i j ] \] Return the return value of the j-th entry of the i-th function interpretation in the given model. - A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map. - An entry represents the value of a function given a set of arguments. - - - - {b Remarks}: Consider using {!get_model_funcs}. - + - {b Remarks}: Consider using {!get_model_funcs}. - {b Precondition}: i < get_model_num_funcs c m - {b Precondition}: j < get_model_func_num_entries c m i - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_num_entries } - @deprecated Use func_interp objects - def_API('get_model_func_entry_value', AST, (_in(CONTEXT), _in(MODEL), _in(UINT), _in(UINT))) *) external get_model_func_entry_value : context -> model -> int -> int -> ast @@ -11032,21 +9276,14 @@ external get_model_func_entry_value : context -> model -> int -> int -> ast (** Summary: \[ [ eval c m t ] \] - Evaluate the AST node [t] in the given model. - - Return a pair: Boolean and value. The Boolean is true if the term was successfully evaluated. - + Evaluate the AST node [t] in the given model. + Return a pair: Boolean and value. The Boolean is true if the term was successfully evaluated. The evaluation may fail for the following reasons: - - [t] contains a quantifier. - - the model [m] is partial, that is, it doesn't have a complete interpretation for uninterpreted functions. That is, the option {e MODEL_PARTIAL=true } was used. - - [t] is type incorrect. - @deprecated Use {!model_eval} - def_API('eval', BOOL, (_in(CONTEXT), _in(MODEL), _in(AST), _out(AST))) *) external eval : context -> model -> ast -> bool * ast @@ -11054,12 +9291,9 @@ external eval : context -> model -> ast -> bool * ast (** Summary: Evaluate declaration given values. - Provides direct way to evaluate declarations without going over terms. - @deprecated Consider using {!model_eval} and {!substitute_vars} - def_API('eval_decl', BOOL, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL), _in(UINT), _in_array(3, AST), _out(AST))) *) external eval_decl : context -> model -> func_decl -> ast array -> bool * ast @@ -11070,17 +9304,10 @@ external eval_decl : context -> model -> func_decl -> ast array -> bool * ast *) (** Summary: Convert the given logical context into a string. - This function is mainly used for debugging purposes. It displays the internal structure of a logical context. - - - - - - @deprecated This method is obsolete. It just displays the internal representation of + @deprecated This method is obsolete. It just displays the internal representation of the global solver available for backward compatibility reasons. - def_API('context_to_string', STRING, (_in(CONTEXT),)) *) external context_to_string : context -> string @@ -11088,17 +9315,10 @@ external context_to_string : context -> string (** Summary: Return runtime statistics as a string. - This function is mainly used for debugging purposes. It displays statistics of the search activity. - - - - - - @deprecated This method is based on the old solver API. + @deprecated This method is based on the old solver API. Use {!stats_to_string} when using the new solver API. - def_API('statistics_to_string', STRING, (_in(CONTEXT),)) *) external statistics_to_string : context -> string @@ -11106,129 +9326,98 @@ external statistics_to_string : context -> string (** Summary: Extract satisfying assignment from context as a conjunction. - This function can be used for debugging purposes. It returns a conjunction of formulas that are assigned to true in the current context. This conjunction will contain not only the assertions that are set to true under the current assignment, but will also include additional literals - if there has been a call to {!check} or {!check_and_get_model}. - + if there has been a call to {!check} or {!check_and_get_model}. @deprecated This method is based on the old solver API. - def_API('get_context_assignment', AST, (_in(CONTEXT),)) *) external get_context_assignment : context -> ast = "camlidl_z3V3_Z3_get_context_assignment" - (** {2 {L ML Extensions}} *) - (** \[ [ mk_context_x configs] \] is a shorthand for the context with configurations in [configs]. *) val mk_context_x: (string * string) array -> context;; - (** \[ [ get_app_args c a ] \] is the array of arguments of an application. If [t] is a constant, then the array is empty. - - {b See also}: {!get_app_num_args} - {b See also}: {!get_app_arg} *) -val get_app_args: context -> app -> ast array - +val get_app_args: context -> app -> ast array (** \[ [ get_app_args c d ] \] is the array of parameters of [d]. - - {b See also}: {!get_domain_size} - {b See also}: {!get_domain} *) val get_domains: context -> func_decl -> sort array - (** \[ [ get_array_sort c t ] \] is the domain and the range of [t]. - - {b See also}: {!get_array_sort_domain} - {b See also}: {!get_array_sort_range} *) val get_array_sort: context -> sort -> sort * sort - (** \[ [ get_tuple_sort c ty ] \] is the pair [(mk_decl, fields)] where [mk_decl] is the constructor declaration of [ty], and [fields] is the array of fields in [ty]. - - {b See also}: {!get_tuple_sort_mk_decl} - {b See also}: {!get_tuple_sort_num_fields} - {b See also}: {!get_tuple_sort_field_decl} *) val get_tuple_sort: context -> sort -> (func_decl * func_decl array) - (** \[ [ datatype_constructor_refined ] \] is the refinement of a datatype constructor. - It contains the constructor declaration, recognizer, and list of accessor functions. *) -type datatype_constructor_refined = { - constructor : func_decl; - recognizer : func_decl; - accessors : func_decl array +type datatype_constructor_refined = { + constructor : func_decl; + recognizer : func_decl; + accessors : func_decl array } - (** \[ [ get_datatype_sort c ty ] \] is the array of triples [(constructor, recognizer, fields)] where [constructor] is the constructor declaration of [ty], [recognizer] is the recognizer for the [constructor], and [fields] is the array of fields in [ty]. - - {b See also}: {!get_datatype_sort_num_constructors} - {b See also}: {!get_datatype_sort_constructor} - {b See also}: {!get_datatype_sort_recognizer} - {b See also}: {!get_datatype_sort_constructor_accessor} *) - - val get_datatype_sort: context -> sort -> datatype_constructor_refined array - (** \[ [ get_model_constants c m ] \] is the array of constants in the model [m]. - - {b See also}: {!get_model_num_constants} - {b See also}: {!get_model_constant} *) val get_model_constants: context -> model -> func_decl array - - (** \[ [ get_model_func_entry c m i j ] \] is the [j]'th entry in the [i]'th function in the model [m]. - - {b See also}: {!get_model_func_entry_num_args} - {b See also}: {!get_model_func_entry_arg} - {b See also}: {!get_model_func_entry_value} *) val get_model_func_entry: context -> model -> int -> int -> (ast array * ast);; - (** \[ [ get_model_func_entries c m i ] \] is the array of entries in the [i]'th function in the model [m]. - - {b See also}: {!get_model_func_num_entries} - {b See also}: {!get_model_func_entry} *) val get_model_func_entries: context -> model -> int -> (ast array * ast) array;; - (** \[ [ get_model_funcs c m ] \] is the array of functions in the model [m]. Each function is represented by the triple [(decl, entries, else)], where [decl] is the declaration name for the function, [entries] is the array of entries in the function, and [else] is the default (else) value for the function. - - {b See also}: {!get_model_num_funcs} - {b See also}: {!get_model_func_decl} - {b See also}: {!get_model_func_entries} - {b See also}: {!get_model_func_else} *) -val get_model_funcs: context -> model -> +val get_model_funcs: context -> model -> (symbol * - (ast array * ast) array * + (ast array * ast) array * ast) array - (** \[ [ get_smtlib_formulas c ] \] is the array of formulas created by a preceding call to {!parse_smtlib_string} or {!parse_smtlib_file}. - Recommend use {!parse_smtlib_string_x} or {!parse_smtlib_file_x} for functional style interface to the SMT-LIB parser. - - {b See also}: {!parse_smtlib_string_x} - {b See also}: {!parse_smtlib_file_x} - {b See also}: {!parse_smtlib_string} @@ -11237,13 +9426,9 @@ val get_model_funcs: context -> model -> - {b See also}: {!get_smtlib_formula} *) val get_smtlib_formulas: context -> ast array - (** \[ [get_smtlib_assumptions c] \] is the array of assumptions created by a preceding call to {!parse_smtlib_string} or {!parse_smtlib_file}. - Recommend use {!parse_smtlib_string_x} or {!parse_smtlib_file_x} for functional style interface to the SMT-LIB parser. - - - {b See also}: {!parse_smtlib_string_x} - {b See also}: {!parse_smtlib_file_x} - {b See also}: {!parse_smtlib_string} @@ -11252,13 +9437,9 @@ val get_smtlib_formulas: context -> ast array - {b See also}: {!get_smtlib_assumption} *) val get_smtlib_assumptions: context -> ast array - (** \[ [ get_smtlib_decls c ] \] is the array of declarations created by a preceding call to {!parse_smtlib_string} or {!parse_smtlib_file}. - Recommend use {!parse_smtlib_string_x} or {!parse_smtlib_file_x} for functional style interface to the SMT-LIB parser. - - - {b See also}: {!parse_smtlib_string_x} - {b See also}: {!parse_smtlib_file_x} - {b See also}: {!parse_smtlib_string} @@ -11267,13 +9448,9 @@ val get_smtlib_assumptions: context -> ast array - {b See also}: {!get_smtlib_decl} *) val get_smtlib_decls: context -> func_decl array - (** \[ [ get_smtlib_parse_results c ] \] is the triple [(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c)]. - Recommend use {!parse_smtlib_string_x} or {!parse_smtlib_file_x} for functional style interface to the SMT-LIB parser. - - - {b See also}: {!parse_smtlib_string_x} - {b See also}: {!parse_smtlib_file_x} - {b See also}: {!parse_smtlib_string} @@ -11283,52 +9460,38 @@ val get_smtlib_decls: context -> func_decl array - {b See also}: {!get_smtlib_decls} *) val get_smtlib_parse_results: context -> (ast array * ast array * func_decl array) - (** - \[ [ parse_smtlib_string_formula c ... ] \] calls [(parse_smtlib_string c ...)] and returns the single formula produced. - + \[ [ parse_smtlib_string_formula c ... ] \] calls [(parse_smtlib_string c ...)] and returns the single formula produced. Recommended for functional style interface to the SMT-LIB parser. - - {b See also}: {!parse_smtlib_file_formula} - {b See also}: {!parse_smtlib_string_x} *) val parse_smtlib_string_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - (** - \[ [ parse_smtlib_file_formula c ... ] \] calls [(parse_smtlib_file c ...)] and returns the single formula produced. - + \[ [ parse_smtlib_file_formula c ... ] \] calls [(parse_smtlib_file c ...)] and returns the single formula produced. Recommended for functional style interface to the SMT-LIB parser. - - {b See also}: {!parse_smtlib_file_formula} - {b See also}: {!parse_smtlib_file_x} *) val parse_smtlib_file_formula: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast - (** \[ [ parse_smtlib_string_x c ... ] \] is [(parse_smtlib_string c ...; get_smtlib_parse_results c)] - Recommended for functional style interface to the SMT-LIB parser. - - {b See also}: {!parse_smtlib_file_x} - {b See also}: {!parse_smtlib_string} - {b See also}: {!get_smtlib_parse_results} *) val parse_smtlib_string_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array) - (** \[ [ parse_smtlib_file_x c ... ] \] is [(parse_smtlib_file c ...; get_smtlib_parse_results c)] - Recommended for functional style interface to the SMT-LIB parser. - - {b See also}: {!parse_smtlib_string_x} - {b See also}: {!parse_smtlib_file} - {b See also}: {!get_smtlib_parse_results} *) val parse_smtlib_file_x: context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> (ast array * ast array * func_decl array) - (** \[ [ symbol_refined ] \] is the refinement of a {!symbol} . - - {b See also}: {!symbol_refine} - {b See also}: {!get_symbol_kind} *) @@ -11336,23 +9499,17 @@ type symbol_refined = | Symbol_int of int | Symbol_string of string | Symbol_unknown;; - (** \[ [ symbol_refine c s ] \] is the refined symbol of [s]. - - - {b See also}: {!symbol_refined} + - {b See also}: {!symbol_refined} - {b See also}: {!get_symbol_kind} *) val symbol_refine: context -> symbol -> symbol_refined;; - (** \[ [ sort_refined ] \] is the refinement of a {!sort} . - - {b See also}: {!sort_refine} - {b See also}: {!get_sort_kind} *) - - type sort_refined = | Sort_uninterpreted of symbol | Sort_bool @@ -11364,122 +9521,91 @@ type sort_refined = | Sort_relation | Sort_finite_domain | Sort_unknown of symbol - (** \[ [ sort_refine c t ] \] is the refined sort of [t]. - - - {b See also}: {!sort_refined} + - {b See also}: {!sort_refined} - {b See also}: {!get_sort_kind} *) val sort_refine: context -> sort -> sort_refined;; - (** \[ [ binder_type ] \] is a universal or existential quantifier. - - {b See also}: {!term_refined} *) -type binder_type = | Forall | Exists - +type binder_type = | Forall | Exists (** \[ [ numeral_refined ] \] is the refinement of a numeral . - Numerals whose fractional representation can be fit with 64 bit integers are treated as small. - *) -type numeral_refined = - | Numeral_small of int64 * int64 - | Numeral_large of string - +type numeral_refined = + | Numeral_small of int64 * int64 + | Numeral_large of string (** \[ [ term_refined ] \] is the refinement of a {!ast} . - - {b See also}: {!term_refine} *) -type term_refined = - | Term_app of decl_kind * func_decl * ast array +type term_refined = + | Term_app of decl_kind * func_decl * ast array | Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast - | Term_numeral of numeral_refined * sort - | Term_var of int * sort - + | Term_numeral of numeral_refined * sort + | Term_var of int * sort (** \[ [ term_refine c a ] \] is the refined term of [a]. - - - {b See also}: {!term_refined} + - {b See also}: {!term_refined} *) val term_refine : context -> ast -> term_refined - -(** +(** \[ [mk_theory c name ] \] create a custom theory. - *) val mk_theory : context -> string -> theory - (** \[ [set_delete_callback th cb] \] set callback when theory gets deleted. *) val set_delete_callback : theory -> (unit -> unit) -> unit - (** \[ [set_reduce_app_callback th cb] \] set callback for simplifying theory terms. *) val set_reduce_app_callback : theory -> (func_decl -> ast array -> ast option) -> unit - (** \[ [set_reduce_eq_callback th cb] \] set callback for simplifying equalities over theory terms. *) val set_reduce_eq_callback : theory -> (ast -> ast -> ast option) -> unit - (** \[ [set_reduce_distinct_callback th cb] \] set callback for simplifying disequalities over theory terms. *) val set_reduce_distinct_callback : theory -> (ast array -> ast option) -> unit - (** \[ [set_new_app_callback th cb] \] set callback for registering new application. *) val set_new_app_callback : theory -> (ast -> unit) -> unit - (** \[ [set_new_elem_callback th cb] \] set callback for registering new element. - - - {b See also}: the help for the corresponding C API function. + - {b See also}: the help for the corresponding C API function. *) val set_new_elem_callback : theory -> (ast -> unit) -> unit - (** \[ [set_init_search_callback th cb] \] set callback when Z3 starts searching for a satisfying assignment. *) val set_init_search_callback : theory -> (unit -> unit) -> unit - (** \[ [set_push_callback th cb] \] set callback for a logical context push. *) val set_push_callback : theory -> (unit -> unit) -> unit - (** \[ [set_pop_callback th cb] \] set callback for a logical context pop. *) val set_pop_callback : theory -> (unit -> unit) -> unit - (** \[ [set_restart_callback th cb] \] set callback for search restart. *) val set_restart_callback : theory -> (unit -> unit) -> unit - val set_reset_callback : theory -> (unit -> unit) -> unit - val set_final_check_callback : theory -> (unit -> bool) -> unit - val set_new_eq_callback : theory -> (ast -> ast -> unit) -> unit - val set_new_diseq_callback : theory -> (ast -> ast -> unit) -> unit - val set_new_assignment_callback : theory -> (ast -> bool -> unit) -> unit - val set_new_relevant_callback : theory -> (ast -> unit) -> unit - end diff --git a/src/api/ml/z3_stubs.c b/src/api/ml/z3_stubs.c index 0f32cb20e..0cf20fb2e 100644 --- a/src/api/ml/z3_stubs.c +++ b/src/api/ml/z3_stubs.c @@ -18,16 +18,13 @@ #define xstr(s) str(s) #define str(s) #s -#pragma warning(disable:4090) void check_error_code (Z3_context c); - Z3_context last_ctx; - + // caml_final_register is the implementation of Gc.finalize value caml_final_register (value f, value v); - void register_finalizer(value** closure, char* name, Z3_context ctx, value v) { if (*closure == NULL) { @@ -39,7 +36,6 @@ Z3_context last_ctx; } caml_final_register(**closure, v); } - value c2ml_Z3_context (Z3_context* c) { static value* finalize_Z3_context_closure = NULL; @@ -50,13 +46,11 @@ Z3_context last_ctx; (Z3_context) *c, v); return v; } - void ml2c_Z3_context (value v, Z3_context* c) { *c = (Z3_context) Field(v, 0); last_ctx = *c; } - value finalize_Z3_context (value v) { Z3_context c; @@ -87,17 +81,15 @@ typedef struct _Z3_ast_context { Z3_ast ast; Z3_context ctx; } Z3_ast_context; - void ml2c_Z3_ast (value v, Z3_ast* c) { *c = ((Z3_ast_context*) Data_custom_val(v))->ast; } - static int compare_Z3_ast (value v1, value v2) { Z3_ast_context* ac1; Z3_ast_context* ac2; - unsigned int id1, id2; + unsigned id1, id2; ac1 = Data_custom_val(v1); ac2 = Data_custom_val(v2); id1 = Z3_get_ast_id(ac1->ctx, ac1->ast); @@ -106,11 +98,10 @@ static int compare_Z3_ast (value v1, value v2) check_error_code(ac2->ctx); return id2 - id1; } - static intnat hash_Z3_ast (value v) { Z3_ast_context* ac; - unsigned int hash; + unsigned hash; ac = Data_custom_val(v); hash = Z3_get_ast_hash(ac->ctx, ac->ast); check_error_code(ac->ctx); @@ -126,7 +117,6 @@ static intnat hash_Z3_ast (value v) check_error_code(ac->ctx); return Val_unit; } - static struct custom_operations cops_Z3_ast = { NULL, custom_finalize_default, @@ -135,7 +125,6 @@ static intnat hash_Z3_ast (value v) custom_serialize_default, custom_deserialize_default }; - value c2ml_Z3_ast (Z3_ast* c) { static value* finalize_Z3_ast_closure = NULL; @@ -156,7 +145,7 @@ static intnat hash_Z3_ast (value v) #define camlidl_c2ml_z3_Z3_ast(c,ctx) c2ml_Z3_ast(c) -#define DEFINE_SUBAST_OPS(T) void ml2c_ ## T (value v, T * a) { ml2c_Z3_ast(v, (Z3_ast*) a); } value c2ml_ ## T (T * a) { return c2ml_Z3_ast((Z3_ast*) a); } +#define DEFINE_SUBAST_OPS(T) void ml2c_ ## T (value v, T * a) { ml2c_Z3_ast(v, (Z3_ast*) a); } value c2ml_ ## T (T * a) { return c2ml_Z3_ast((Z3_ast*) a); } DEFINE_SUBAST_OPS(Z3_sort) #define camlidl_ml2c_z3_Z3_sort(v,c,ctx) ml2c_Z3_sort(v,c) @@ -177,7 +166,7 @@ DEFINE_SUBAST_OPS(Z3_pattern) #define camlidl_c2ml_z3_Z3_pattern(c,ctx) c2ml_Z3_pattern(c) -#define DEFINE_RC_OPS(T) value c2ml_ ## T (T * c) { static value* finalize_ ## T ## _closure = NULL; value v; check_error_code(last_ctx); v = caml_alloc_small(2, Abstract_tag); Field(v, 0) = (value) *c; Field(v, 1) = (value) last_ctx; register_finalizer(&finalize_ ## T ## _closure, xstr(finalize_ ## T), (Z3_context) *c, v); T ## _inc_ref(last_ctx, *c); return v; } void ml2c_ ## T (value v, T * c) { *c = (T) Field(v, 0); } value finalize_ ## T (value v) { Z3_context c; c = (Z3_context) Field(v, 1); T ## _dec_ref(c, (T) Field(v, 0)); check_error_code(c); return Val_unit; } + #define DEFINE_RC_OPS(T) value c2ml_ ## T (T * c) { static value* finalize_ ## T ## _closure = NULL; value v; check_error_code(last_ctx); v = caml_alloc_small(2, Abstract_tag); Field(v, 0) = (value) *c; Field(v, 1) = (value) last_ctx; register_finalizer(&finalize_ ## T ## _closure, xstr(finalize_ ## T), (Z3_context) *c, v); T ## _inc_ref(last_ctx, *c); return v; } void ml2c_ ## T (value v, T * c) { *c = (T) Field(v, 0); } value finalize_ ## T (value v) { Z3_context c; c = (Z3_context) Field(v, 1); T ## _dec_ref(c, (T) Field(v, 0)); check_error_code(c); return Val_unit; } DEFINE_RC_OPS(Z3_params) #define camlidl_ml2c_z3_Z3_params(v,c,ctx) ml2c_Z3_params(v,c) @@ -248,7 +237,7 @@ DEFINE_RC_OPS(Z3_stats) #define camlidl_c2ml_z3_Z3_stats(c,ctx) c2ml_Z3_stats(c) -#define DEFINE_OPT_OPS(T) void ml2c_ ## T ## _opt (value v, T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; if (v != Val_int(0)) { camlidl_ml2c_z3_ ## T(Field(v, 0), c, _ctx); } else { *c = NULL; } } value c2ml_ ## T ## _opt (T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; value v; value a; if (*c) { a = camlidl_c2ml_z3_ ## T(c, _ctx); Begin_root(a) v = caml_alloc_small(1, 0); Field(v, 0) = a; End_roots(); } else { v = Val_int(0); } return v; } +#define DEFINE_OPT_OPS(T) void ml2c_ ## T ## _opt (value v, T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; if (v != Val_int(0)) { camlidl_ml2c_z3_ ## T(Field(v, 0), c, _ctx); } else { *c = NULL; } } value c2ml_ ## T ## _opt (T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; value v; value a; if (*c) { a = camlidl_c2ml_z3_ ## T(c, _ctx); Begin_root(a) v = caml_alloc_small(1, 0); Field(v, 0) = a; End_roots(); } else { v = Val_int(0); } return v; } DEFINE_OPT_OPS(Z3_ast) #define camlidl_ml2c_z3_Z3_ast_opt(v,c,ctx) ml2c_Z3_ast_opt(v,c) @@ -682,9 +671,12 @@ value _v1; } +/* All contexts share the same handler */ +static value caml_z3_error_handler = 0; + + value camlidl_c2ml_z3_Z3_error_code(Z3_error_code * _c2, camlidl_ctx _ctx); - - +/* Error checking routine that raises OCaml Error exceptions */ void check_error_code (Z3_context c) { static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; @@ -703,8 +695,7 @@ void check_error_code (Z3_context c) caml_raise_with_args(*exn_tag, 2, ctx_err); } } - - +/* Disable default error handler, all error checking is done by check_error_code */ void* error_handler_static = NULL; int camlidl_transl_table_z3_enum_11[4] = { @@ -743,9 +734,7 @@ value caml_z3_mk_context(value key_val_list) Z3_context _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - cfg = Z3_mk_config(); - while (key_val_list != Val_emptylist) { item = Field(key_val_list, 0); @@ -756,7 +745,6 @@ value caml_z3_mk_context(value key_val_list) Z3_set_param_value(cfg, ckey, cval); key_val_list = Field(key_val_list, 1); } - _res = Z3_mk_context_rc(cfg); Z3_del_config(cfg); _vres = camlidl_c2ml_z3_Z3_context(&_res, _ctx); @@ -1238,7 +1226,7 @@ value camlidl_z3_Z3_mk_finite_domain_sort( { Z3_context c; /*in*/ Z3_symbol name; /*in*/ - __int64 size; /*in*/ + unsigned long long size; /*in*/ Z3_sort _res; value _vres; @@ -4286,7 +4274,7 @@ value camlidl_z3_Z3_mk_int64( value _v_ty) { Z3_context c; /*in*/ - __int64 v; /*in*/ + long long v; /*in*/ Z3_sort ty; /*in*/ Z3_ast _res; value _vres; @@ -5105,8 +5093,8 @@ value camlidl_z3_Z3_get_finite_domain_sort_size( { Z3_context c; /*in*/ Z3_sort s; /*in*/ - __int64 *r; /*out*/ - __int64 _c1; + unsigned long long *r; /*out*/ + unsigned long long _c1; value _v2; value _vres; @@ -6273,13 +6261,13 @@ value camlidl_z3_Z3_get_numeral_small( { Z3_context c; /*in*/ Z3_ast a; /*in*/ - __int64 *num; /*out*/ - __int64 *den; /*out*/ + long long *num; /*out*/ + long long *den; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; - __int64 _c2; + long long _c1; + long long _c2; value _vresult; value _vres[3] = { 0, 0, 0, }; @@ -6342,11 +6330,11 @@ value camlidl_z3_Z3_get_numeral_int64( { Z3_context c; /*in*/ Z3_ast v; /*in*/ - __int64 *i; /*out*/ + long long *i; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; + long long _c1; value _vresult; value _vres[2] = { 0, 0, }; @@ -6374,13 +6362,13 @@ value camlidl_z3_Z3_get_numeral_rational_int64( { Z3_context c; /*in*/ Z3_ast v; /*in*/ - __int64 *num; /*out*/ - __int64 *den; /*out*/ + long long *num; /*out*/ + long long *den; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; - __int64 _c2; + long long _c1; + long long _c2; value _vresult; value _vres[3] = { 0, 0, 0, }; @@ -8170,50 +8158,6 @@ check_error_code(c); return _vres; } -value camlidl_z3_Z3_parse_z3_string( - value _v_c, - value _v_str) -{ - Z3_context c; /*in*/ - Z3_string str; /*in*/ - Z3_ast _res; - value _vres; - - struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; - camlidl_ctx _ctx = &_ctxs; - camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); - camlidl_ml2c_z3_Z3_string(_v_str, &str, _ctx); - _res = Z3_parse_z3_string(c, str); - _vres = camlidl_c2ml_z3_Z3_ast(&_res, _ctx); - camlidl_free(_ctx); - /* begin user-supplied deallocation sequence */ -check_error_code(c); - /* end user-supplied deallocation sequence */ - return _vres; -} - -value camlidl_z3_Z3_parse_z3_file( - value _v_c, - value _v_file_name) -{ - Z3_context c; /*in*/ - Z3_string file_name; /*in*/ - Z3_ast _res; - value _vres; - - struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; - camlidl_ctx _ctx = &_ctxs; - camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); - camlidl_ml2c_z3_Z3_string(_v_file_name, &file_name, _ctx); - _res = Z3_parse_z3_file(c, file_name); - _vres = camlidl_c2ml_z3_Z3_ast(&_res, _ctx); - camlidl_free(_ctx); - /* begin user-supplied deallocation sequence */ -check_error_code(c); - /* end user-supplied deallocation sequence */ - return _vres; -} - value camlidl_z3_Z3_set_error( value _v_c, value _v_e) @@ -8286,6 +8230,30 @@ value camlidl_z3_Z3_get_version(value _unit) return _vresult; } +value camlidl_z3_Z3_enable_trace( + value _v_tag) +{ + Z3_string tag; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_string(_v_tag, &tag, _ctx); + Z3_enable_trace(tag); + camlidl_free(_ctx); + return Val_unit; +} + +value camlidl_z3_Z3_disable_trace( + value _v_tag) +{ + Z3_string tag; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_string(_v_tag, &tag, _ctx); + Z3_disable_trace(tag); + camlidl_free(_ctx); + return Val_unit; +} + value camlidl_z3_Z3_mk_fixedpoint( value _v_c) { @@ -8669,46 +8637,42 @@ check_error_code(c); return Val_unit; } -value camlidl_z3_Z3_fixedpoint_simplify_rules( +value camlidl_z3_Z3_fixedpoint_get_rules( value _v_c, - value _v_f, - value _v_rules, - value _v_outputs) + value _v_f) { Z3_context c; /*in*/ Z3_fixedpoint f; /*in*/ - unsigned int num_rules; /*in*/ - Z3_ast *rules; /*in*/ - unsigned int num_outputs; /*in*/ - Z3_func_decl *outputs; /*in*/ Z3_ast_vector _res; - mlsize_t _c1; - mlsize_t _c2; - value _v3; - mlsize_t _c4; - mlsize_t _c5; - value _v6; value _vres; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx); - _c1 = Wosize_val(_v_rules); - rules = camlidl_malloc(_c1 * sizeof(Z3_ast ), _ctx); - for (_c2 = 0; _c2 < _c1; _c2++) { - _v3 = Field(_v_rules, _c2); - camlidl_ml2c_z3_Z3_ast(_v3, &rules[_c2], _ctx); - } - num_rules = _c1; - _c4 = Wosize_val(_v_outputs); - outputs = camlidl_malloc(_c4 * sizeof(Z3_func_decl ), _ctx); - for (_c5 = 0; _c5 < _c4; _c5++) { - _v6 = Field(_v_outputs, _c5); - camlidl_ml2c_z3_Z3_func_decl(_v6, &outputs[_c5], _ctx); - } - num_outputs = _c4; - _res = Z3_fixedpoint_simplify_rules(c, f, num_rules, rules, num_outputs, outputs); + _res = Z3_fixedpoint_get_rules(c, f); + _vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx); + camlidl_free(_ctx); + /* begin user-supplied deallocation sequence */ +check_error_code(c); + /* end user-supplied deallocation sequence */ + return _vres; +} + +value camlidl_z3_Z3_fixedpoint_get_assertions( + value _v_c, + value _v_f) +{ + Z3_context c; /*in*/ + Z3_fixedpoint f; /*in*/ + Z3_ast_vector _res; + value _vres; + + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); + camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx); + _res = Z3_fixedpoint_get_assertions(c, f); _vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx); camlidl_free(_ctx); /* begin user-supplied deallocation sequence */ @@ -8817,6 +8781,56 @@ check_error_code(c); return _vres; } +value camlidl_z3_Z3_fixedpoint_from_string( + value _v_c, + value _v_f, + value _v_s) +{ + Z3_context c; /*in*/ + Z3_fixedpoint f; /*in*/ + Z3_string s; /*in*/ + Z3_ast_vector _res; + value _vres; + + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); + camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx); + camlidl_ml2c_z3_Z3_string(_v_s, &s, _ctx); + _res = Z3_fixedpoint_from_string(c, f, s); + _vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx); + camlidl_free(_ctx); + /* begin user-supplied deallocation sequence */ +check_error_code(c); + /* end user-supplied deallocation sequence */ + return _vres; +} + +value camlidl_z3_Z3_fixedpoint_from_file( + value _v_c, + value _v_f, + value _v_s) +{ + Z3_context c; /*in*/ + Z3_fixedpoint f; /*in*/ + Z3_string s; /*in*/ + Z3_ast_vector _res; + value _vres; + + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); + camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx); + camlidl_ml2c_z3_Z3_string(_v_s, &s, _ctx); + _res = Z3_fixedpoint_from_file(c, f, s); + _vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx); + camlidl_free(_ctx); + /* begin user-supplied deallocation sequence */ +check_error_code(c); + /* end user-supplied deallocation sequence */ + return _vres; +} + value camlidl_z3_Z3_fixedpoint_push( value _v_c, value _v_d) @@ -10692,6 +10706,30 @@ check_error_code(c); return Val_unit; } +value camlidl_z3_Z3_solver_assert_and_track( + value _v_c, + value _v_s, + value _v_a, + value _v_p) +{ + Z3_context c; /*in*/ + Z3_solver s; /*in*/ + Z3_ast a; /*in*/ + Z3_ast p; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx); + camlidl_ml2c_z3_Z3_solver(_v_s, &s, _ctx); + camlidl_ml2c_z3_Z3_ast(_v_a, &a, _ctx); + camlidl_ml2c_z3_Z3_ast(_v_p, &p, _ctx); + Z3_solver_assert_and_track(c, s, a, p); + camlidl_free(_ctx); + /* begin user-supplied deallocation sequence */ +check_error_code(c); + /* end user-supplied deallocation sequence */ + return Val_unit; +} + value camlidl_z3_Z3_solver_get_assertions( value _v_c, value _v_s) @@ -11072,7 +11110,6 @@ check_error_code(c); return _vres; } -void caml_z3_error_handler(Z3_context c, Z3_error_code e) { static char buffer[128]; char * msg = Z3_get_error_msg_ex(c, e); if (strlen(msg) > 100) { failwith("Z3: error message is too big to fit in buffer"); } else { sprintf(buffer, "Z3: %s", msg); failwith(buffer); } } void camlidl_ml2c_z3V3_Z3_symbol(value _v1, Z3_symbol * _c2, camlidl_ctx _ctx) { *_c2 = *((Z3_symbol *) Bp_val(_v1)); @@ -11604,6 +11641,54 @@ value _v1; return _v1; } +value camlidl_z3V3_Z3_global_param_set( + value _v_param_id, + value _v_param_value) +{ + Z3_string param_id; /*in*/ + Z3_string param_value; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3V3_Z3_string(_v_param_id, ¶m_id, _ctx); + camlidl_ml2c_z3V3_Z3_string(_v_param_value, ¶m_value, _ctx); + Z3_global_param_set(param_id, param_value); + camlidl_free(_ctx); + return Val_unit; +} + +value camlidl_z3V3_Z3_global_param_reset_all(value _unit) +{ + Z3_global_param_reset_all(); + return Val_unit; +} + +value camlidl_z3V3_Z3_global_param_get( + value _v_param_id) +{ + Z3_string param_id; /*in*/ + Z3_string *param_value; /*out*/ + Z3_string _c1; + value _v2; + value _vres; + + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3V3_Z3_string(_v_param_id, ¶m_id, _ctx); + param_value = &_c1; + Z3_global_param_get(param_id, param_value); + if (param_value == NULL) { + _vres = Val_int(0); + } else { + _v2 = camlidl_c2ml_z3V3_Z3_string(&*param_value, _ctx); + Begin_root(_v2) + _vres = camlidl_alloc_small(1, 0); + Field(_vres, 0) = _v2; + End_roots(); + } + camlidl_free(_ctx); + return _vres; +} + value camlidl_z3V3_Z3_mk_config(value _unit) { Z3_config _res; @@ -11661,7 +11746,7 @@ value camlidl_z3V3_Z3_mk_context( _vres = camlidl_c2ml_z3V3_Z3_context(&_res, _ctx); camlidl_free(_ctx); /* begin user-supplied deallocation sequence */ -Z3_set_error_handler(_res, caml_z3_error_handler); +Z3_set_error_handler(_res, (void*)caml_z3_error_handler); /* end user-supplied deallocation sequence */ return _vres; } @@ -11857,7 +11942,7 @@ value camlidl_z3V3_Z3_mk_finite_domain_sort( { Z3_context c; /*in*/ Z3_symbol name; /*in*/ - __int64 size; /*in*/ + unsigned long long size; /*in*/ Z3_sort _res; value _vres; @@ -14575,7 +14660,7 @@ value camlidl_z3V3_Z3_mk_int64( value _v_ty) { Z3_context c; /*in*/ - __int64 v; /*in*/ + long long v; /*in*/ Z3_sort ty; /*in*/ Z3_ast _res; value _vres; @@ -15334,8 +15419,8 @@ value camlidl_z3V3_Z3_get_finite_domain_sort_size( { Z3_context c; /*in*/ Z3_sort s; /*in*/ - __int64 *r; /*out*/ - __int64 _c1; + unsigned long long *r; /*out*/ + unsigned long long _c1; value _v2; value _vres; @@ -16352,13 +16437,13 @@ value camlidl_z3V3_Z3_get_numeral_small( { Z3_context c; /*in*/ Z3_ast a; /*in*/ - __int64 *num; /*out*/ - __int64 *den; /*out*/ + long long *num; /*out*/ + long long *den; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; - __int64 _c2; + long long _c1; + long long _c2; value _vresult; value _vres[3] = { 0, 0, 0, }; @@ -16415,11 +16500,11 @@ value camlidl_z3V3_Z3_get_numeral_int64( { Z3_context c; /*in*/ Z3_ast v; /*in*/ - __int64 *i; /*out*/ + long long *i; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; + long long _c1; value _vresult; value _vres[2] = { 0, 0, }; @@ -16444,13 +16529,13 @@ value camlidl_z3V3_Z3_get_numeral_rational_int64( { Z3_context c; /*in*/ Z3_ast v; /*in*/ - __int64 *num; /*out*/ - __int64 *den; /*out*/ + long long *num; /*out*/ + long long *den; /*out*/ int _res; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; - __int64 _c1; - __int64 _c2; + long long _c1; + long long _c2; value _vresult; value _vres[3] = { 0, 0, 0, }; @@ -17570,44 +17655,6 @@ value camlidl_z3V3_Z3_get_smtlib_error( return _vres; } -value camlidl_z3_Z3_parse_z3V3_string( - value _v_c, - value _v_str) -{ - Z3_context c; /*in*/ - Z3_string str; /*in*/ - Z3_ast _res; - value _vres; - - struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; - camlidl_ctx _ctx = &_ctxs; - camlidl_ml2c_z3V3_Z3_context(_v_c, &c, _ctx); - camlidl_ml2c_z3V3_Z3_string(_v_str, &str, _ctx); - _res = Z3_parse_z3_string(c, str); - _vres = camlidl_c2ml_z3V3_Z3_ast(&_res, _ctx); - camlidl_free(_ctx); - return _vres; -} - -value camlidl_z3_Z3_parse_z3V3_file( - value _v_c, - value _v_file_name) -{ - Z3_context c; /*in*/ - Z3_string file_name; /*in*/ - Z3_ast _res; - value _vres; - - struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; - camlidl_ctx _ctx = &_ctxs; - camlidl_ml2c_z3V3_Z3_context(_v_c, &c, _ctx); - camlidl_ml2c_z3V3_Z3_string(_v_file_name, &file_name, _ctx); - _res = Z3_parse_z3_file(c, file_name); - _vres = camlidl_c2ml_z3V3_Z3_ast(&_res, _ctx); - camlidl_free(_ctx); - return _vres; -} - value camlidl_z3V3_Z3_get_version(value _unit) { unsigned int *major; /*out*/ @@ -17640,6 +17687,30 @@ value camlidl_z3V3_Z3_get_version(value _unit) return _vresult; } +value camlidl_z3V3_Z3_enable_trace( + value _v_tag) +{ + Z3_string tag; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3V3_Z3_string(_v_tag, &tag, _ctx); + Z3_enable_trace(tag); + camlidl_free(_ctx); + return Val_unit; +} + +value camlidl_z3V3_Z3_disable_trace( + value _v_tag) +{ + Z3_string tag; /*in*/ + struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; + camlidl_ctx _ctx = &_ctxs; + camlidl_ml2c_z3V3_Z3_string(_v_tag, &tag, _ctx); + Z3_disable_trace(tag); + camlidl_free(_ctx); + return Val_unit; +} + value camlidl_z3V3_Z3_reset_memory(value _unit) { Z3_reset_memory(); From 3cefa0a1f76a4ce1cfe53fe5782aa8d061691535 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 5 Dec 2012 16:53:54 -0800 Subject: [PATCH 129/133] making tests deterministic Signed-off-by: Leonardo de Moura --- src/api/python/z3.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/api/python/z3.py b/src/api/python/z3.py index e690a9bff..6517de221 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -5787,8 +5787,15 @@ class Solver(Z3PPObject): >>> s.assert_and_track(x < 0, p3) >>> print s.check() unsat - >>> print s.unsat_core() - [p3, p1] + >>> c = s.unsat_core() + >>> len(c) + 2 + >>> Bool('p1') in c + True + >>> Bool('p2') in c + False + >>> p3 in c + True """ if isinstance(p, str): p = Bool(p, self.ctx) @@ -6985,9 +6992,9 @@ def solve(*args, **keywords): configure it using the options in `keywords`, adds the constraints in `args`, and invokes check. - >>> a, b = Ints('a b') - >>> solve(a + b == 3, Or(a == 0, a == 1), a != 0) - [b = 2, a = 1] + >>> a = Int('a') + >>> solve(a > 0, a < 2) + [a = 1] """ s = Solver() s.set(**keywords) From 6bdde9047aae6b0b12ea85b19f6c6218a0e8f5e6 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 5 Dec 2012 12:01:03 -0800 Subject: [PATCH 130/133] fixing unit tests Signed-off-by: Nikolaj Bjorner --- src/muz_qe/rel_context.h | 3 +-- src/smt/smt_model_checker.cpp | 1 + src/test/dl_context.cpp | 2 +- src/test/dl_product_relation.cpp | 9 +++++---- src/test/dl_query.cpp | 8 ++++---- src/test/dl_relation.cpp | 4 ++-- src/test/dl_table.cpp | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/muz_qe/rel_context.h b/src/muz_qe/rel_context.h index 5fa2486b4..b05532d14 100644 --- a/src/muz_qe/rel_context.h +++ b/src/muz_qe/rel_context.h @@ -41,8 +41,6 @@ namespace datalog { fact_vector m_table_facts; void reset_negated_tables(); - - lbool saturate(); relation_plugin & get_ordinary_relation_plugin(symbol relation_name); @@ -109,6 +107,7 @@ namespace datalog { void display_output_facts(std::ostream & out) const; void display_facts(std::ostream & out) const; + lbool saturate(); }; }; diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index 53f3af961..cefdacef5 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -283,6 +283,7 @@ namespace smt { if (!m_fparams) { m_fparams = alloc(smt_params, m_context->get_fparams()); m_fparams->m_relevancy_lvl = 0; // no relevancy since the model checking problems are quantifier free + m_fparams->m_proof_mode = m_manager.proof_mode(); } if (!m_aux_context) { symbol logic; diff --git a/src/test/dl_context.cpp b/src/test/dl_context.cpp index ff7548abc..d5fcddb71 100644 --- a/src/test/dl_context.cpp +++ b/src/test/dl_context.cpp @@ -60,7 +60,7 @@ void dl_context_saturate_file(params_ref & params, const char * f) { } dealloc(parser); std::cerr << "Saturating...\n"; - ctx.dl_saturate(); + ctx.get_rel_context().saturate(); std::cerr << "Done\n"; } diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index e58634ec8..ef43258ad 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -22,11 +22,12 @@ namespace datalog { void test_functional_columns(smt_params fparams, params_ref& params) { ast_manager m; context ctx(m, fparams); + rel_context& rctx = ctx.get_rel_context(); ctx.updt_params(params); - relation_manager & rmgr(ctx.get_rmanager()); + relation_manager & rmgr(rctx.get_rmanager()); sparse_table_plugin & plugin = - static_cast(*ctx.get_rmanager().get_table_plugin(symbol("sparse"))); + static_cast(*rctx.get_rmanager().get_table_plugin(symbol("sparse"))); SASSERT(&plugin); table_signature sig2; sig2.push_back(2); @@ -126,9 +127,9 @@ namespace datalog { context ctx(m, fparams); ctx.updt_params(params); dl_decl_util dl_util(m); - relation_manager & rmgr = ctx.get_rmanager(); + relation_manager & rmgr = ctx.get_rel_context().get_rmanager(); - relation_plugin & rel_plugin = *ctx.get_rmanager().get_relation_plugin(params.get_sym("default_relation", symbol("sparse"))); + relation_plugin & rel_plugin = *rmgr.get_relation_plugin(params.get_sym("default_relation", symbol("sparse"))); SASSERT(&rel_plugin); finite_product_relation_plugin plg(rel_plugin, rmgr); diff --git a/src/test/dl_query.cpp b/src/test/dl_query.cpp index ad21247af..4dc770056 100644 --- a/src/test/dl_query.cpp +++ b/src/test/dl_query.cpp @@ -57,7 +57,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, TRUSTME( p->parse_file(problem_file) ); dealloc(p); } - relation_manager & rel_mgr_q = ctx_b.get_rmanager(); + relation_manager & rel_mgr_q = ctx_b.get_rel_context().get_rmanager(); decl_set out_preds = ctx_b.get_output_predicates(); decl_set::iterator it = out_preds.begin(); @@ -68,10 +68,10 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, func_decl * pred_q = ctx_q.try_get_predicate_decl(symbol(pred_b->get_name().bare_str())); SASSERT(pred_q); - relation_base & rel_b = ctx_b.get_relation(pred_b); + relation_base & rel_b = ctx_b.get_rel_context().get_relation(pred_b); relation_signature sig_b = rel_b.get_signature(); - relation_signature sig_q = ctx_q.get_relation(pred_q).get_signature(); + relation_signature sig_q = ctx_q.get_rel_context().get_relation(pred_q).get_signature(); SASSERT(sig_b.size()==sig_q.size()); std::cerr << "Queries on random facts...\n"; @@ -209,7 +209,7 @@ void tst_dl_query() { TRUSTME( p->parse_file(problem_file) ); dealloc(p); } - ctx_base.dl_saturate(); + ctx_base.get_rel_context().saturate(); for(unsigned use_restarts=0; use_restarts<=1; use_restarts++) { params.set_uint("initial_restart_timeout", use_restarts ? 100 : 0); diff --git a/src/test/dl_relation.cpp b/src/test/dl_relation.cpp index fe8ba1730..5daf3dc9b 100644 --- a/src/test/dl_relation.cpp +++ b/src/test/dl_relation.cpp @@ -12,7 +12,7 @@ namespace datalog { ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); - relation_manager & m = ctx.get_rmanager(); + relation_manager & m = ctx.get_rel_context().get_rmanager(); m.register_plugin(alloc(interval_relation_plugin, m)); interval_relation_plugin& ip = dynamic_cast(*m.get_relation_plugin(symbol("interval_relation"))); SASSERT(&ip); @@ -115,7 +115,7 @@ namespace datalog { ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); - relation_manager & m = ctx.get_rmanager(); + relation_manager & m = ctx.get_rel_context().get_rmanager(); m.register_plugin(alloc(bound_relation_plugin, m)); bound_relation_plugin& br = dynamic_cast(*m.get_relation_plugin(symbol("bound_relation"))); SASSERT(&br); diff --git a/src/test/dl_table.cpp b/src/test/dl_table.cpp index 6383dc1ab..0c8afcdc2 100644 --- a/src/test/dl_table.cpp +++ b/src/test/dl_table.cpp @@ -27,9 +27,9 @@ static void test_table(mk_table_fn mk_table) { smt_params params; ast_manager ast_m; datalog::context ctx(ast_m, params); - datalog::relation_manager & m = ctx.get_rmanager(); + datalog::relation_manager & m = ctx.get_rel_context().get_rmanager(); - ctx.get_rmanager().register_plugin(alloc(datalog::bitvector_table_plugin, ctx.get_rmanager())); + m.register_plugin(alloc(datalog::bitvector_table_plugin, m)); datalog::table_base* _tbl = mk_table(m, sig); datalog::table_base& table = *_tbl; From dbde71c2905db352dbb83d8b5e177aa68e6762ea Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 5 Dec 2012 12:05:07 -0800 Subject: [PATCH 131/133] fixing unit tests Signed-off-by: Nikolaj Bjorner --- src/smt/smt_model_checker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index cefdacef5..53f3af961 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -283,7 +283,6 @@ namespace smt { if (!m_fparams) { m_fparams = alloc(smt_params, m_context->get_fparams()); m_fparams->m_relevancy_lvl = 0; // no relevancy since the model checking problems are quantifier free - m_fparams->m_proof_mode = m_manager.proof_mode(); } if (!m_aux_context) { symbol logic; From 75739fdf7b35e79f6403c5c28c28340c7019ff7f Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 6 Dec 2012 08:19:42 -0800 Subject: [PATCH 132/133] fixed memory smash Signed-off-by: Leonardo de Moura --- src/ast/rewriter/th_rewriter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index 07ee7698d..29034d396 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -483,10 +483,13 @@ struct th_rewriter_cfg : public default_rewriter_cfg { f = to_app(t1)->get_decl(); return unify_core(to_app(t1), t2, new_t1, new_t2, c, first); } - else { + else if (is_arith_bv_app(t2)) { f = to_app(t2)->get_decl(); return unify_core(to_app(t2), t1, new_t2, new_t1, c, first); } + else { + return false; + } } // Apply transformations of the form From 68b97024e2638317d3980308c1eb65d3299ad2cd Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 6 Dec 2012 08:54:00 -0800 Subject: [PATCH 133/133] added missing option Signed-off-by: Leonardo de Moura --- src/smt/params/preprocessor_params.cpp | 3 ++- src/smt/params/smt_params_helper.pyg | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/smt/params/preprocessor_params.cpp b/src/smt/params/preprocessor_params.cpp index 375fef787..4799b8b9f 100644 --- a/src/smt/params/preprocessor_params.cpp +++ b/src/smt/params/preprocessor_params.cpp @@ -21,7 +21,8 @@ Revision History: void preprocessor_params::updt_local_params(params_ref const & _p) { smt_params_helper p(_p); - m_macro_finder = p.macro_finder(); + m_macro_finder = p.macro_finder(); + m_pull_nested_quantifiers = p.pull_nested_quantifiers(); } void preprocessor_params::updt_params(params_ref const & p) { diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg index ee583ff85..071d843a3 100644 --- a/src/smt/params/smt_params_helper.pyg +++ b/src/smt/params/smt_params_helper.pyg @@ -13,6 +13,7 @@ def_module_params(module_name='smt', ('case_split', UINT, 1, '0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal'), ('delay_units', BOOL, False, 'if true then z3 will not restart when a unit clause is learned'), ('delay_units_threshold', UINT, 32, 'maximum number of learned unit clauses before restarting, ingored if delay_units is false'), + ('pull_nested_quantifiers', BOOL, False, 'pull nested quantifiers'), ('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'), ('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'), ('mbqi.max_cexs_incr', UINT, 0, 'increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI'),