3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-19 20:33:38 +00:00
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-11-30 13:17:41 -08:00
commit 124c0339c1
53 changed files with 4995 additions and 4595 deletions

View file

@ -159,7 +159,7 @@ class JavaExample
Sort t = f.Range(); Sort t = f.Range();
Sort[] dom = f.Domain(); 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) + " " System.out.println(Integer.toString(dom.length) + " "
+ dom[0].toString() + " " + dom[1].toString() + " " + dom[0].toString() + " " + dom[1].toString() + " "
@ -700,7 +700,7 @@ class JavaExample
System.out.println(q2); System.out.println(q2);
} }
System.out.println(q1.Equals(q2)); System.out.println(q1.equals(q2));
} }
// / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when // / Prove that <tt>f(x, y) = f(w, v) implies y = v</tt> when

View file

@ -990,10 +990,13 @@ class JavaDLLComponent(Component):
else: else:
out.write('\t$(SLINK) $(SLINK_OUT_FLAG)libz3java$(SO_EXT) $(SLINK_FLAGS) api/java/Native$(OBJ_EXT) libz3$(SO_EXT)\n') 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) out.write('%s.jar: libz3java$(SO_EXT) ' % self.package_name)
# for java_file in get_java_files(self.src_dir): deps = ''
# out.write('%s ' % java_file) for jfile in get_java_files(self.src_dir):
# for java_file in get_java_files((self.src_dir + "/%s/enumerations") % subdir): deps += ('%s/%s ' % (self.to_src_dir, jfile))
# out.write('%s ' % java_file) 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') out.write('\n')
t = ('\t%s %s/enumerations/*.java -d api/java/classes\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('/','\\') if IS_WINDOWS: t = t.replace('/','\\')
@ -1103,10 +1106,12 @@ class JavaExampleComponent(ExampleComponent):
if JAVA_ENABLED: if JAVA_ENABLED:
pkg = get_component(JAVA_COMPONENT).package_name + '.jar' pkg = get_component(JAVA_COMPONENT).package_name + '.jar'
out.write('_ex_%s: %s' % (self.name, pkg)) out.write('_ex_%s: %s' % (self.name, pkg))
# for javafile in get_java_files(self.ex_dir): deps = ''
# out.write(' ') for jfile in get_java_files(self.ex_dir):
# out.write('%s/%s' % (self.to_ex_dir, javafile)) out.write(' %s/%s' % (self.to_ex_dir, jfile))
out.write('\n') if IS_WINDOWS:
deps = deps.replace('/', '\\')
out.write('%s\n' % deps)
out.write('\t%s -cp %s ' % (JAVAC, pkg)) out.write('\t%s -cp %s ' % (JAVAC, pkg))
win_ex_dir = self.to_ex_dir win_ex_dir = self.to_ex_dir
for javafile in get_java_files(self.ex_dir): for javafile in get_java_files(self.ex_dir):

View file

@ -489,18 +489,19 @@ def mk_java():
java_native = open(java_nativef, 'w') java_native = open(java_nativef, 'w')
java_native.write('// Automatically generated file\n') java_native.write('// Automatically generated file\n')
java_native.write('package %s;\n' % get_component('java').package_name) 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 final class Native {\n')
java_native.write(' public static class IntPtr { public int value; }\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 LongPtr { public long value; }\n')
java_native.write(' public static class StringPtr { public String 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 class errorHandler { public long ptr; }\n')
if IS_WINDOWS: if IS_WINDOWS:
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name)
else: 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(' 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: 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 first = True
i = 0; i = 0;
for param in params: for param in params:
@ -511,12 +512,46 @@ def mk_java():
java_native.write('%s a%d' % (param2java(param), i)) java_native.write('%s a%d' % (param2java(param), i))
i = i + 1 i = i + 1
java_native.write(');\n') java_native.write(');\n')
java_native.write(' public static void main(String[] args) {\n') java_native.write('\n\n')
java_native.write(' IntPtr major = new IntPtr(), minor = new IntPtr(), build = new IntPtr(), revision = new IntPtr();\n') # Exception wrappers
java_native.write(' getVersion(major, minor, build, revision);\n') for name, result, params in _dotnet_decls:
java_native.write(' System.out.format("Z3 (for Java) %d.%d.%d%n", major.value, minor.value, build.value);\n') 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_native.write('}\n')
java_native.write('}\n');
java_wrapper = open(java_wrapperf, 'w') java_wrapper = open(java_wrapperf, 'w')
java_wrapper.write('// Automatically generated file\n') java_wrapper.write('// Automatically generated file\n')
java_wrapper.write('#include<jni.h>\n') java_wrapper.write('#include<jni.h>\n')
@ -525,12 +560,12 @@ def mk_java():
java_wrapper.write('#ifdef __cplusplus\n') java_wrapper.write('#ifdef __cplusplus\n')
java_wrapper.write('extern "C" {\n') java_wrapper.write('extern "C" {\n')
java_wrapper.write('#endif\n\n') java_wrapper.write('#endif\n\n')
if VS_X64: java_wrapper.write('#if defined(_M_X64) || defined(_AMD64_)\n\n')
java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\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 = (T*) jenv->GetLongArrayElements(OLD, NULL); \n')
java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n')
java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n') java_wrapper.write(' jenv->ReleaseLongArrayElements(OLD, (jlong *) NEW, JNI_ABORT); \n\n')
else: java_wrapper.write('#else\n\n')
java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n') java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n')
java_wrapper.write(' T * NEW = 0; { \\\n') java_wrapper.write(' T * NEW = 0; { \\\n')
java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n') java_wrapper.write(' jlong * temp = jenv->GetLongArrayElements(OLD, NULL); \\\n')
@ -542,9 +577,10 @@ def mk_java():
java_wrapper.write(' } \n\n') java_wrapper.write(' } \n\n')
java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n') java_wrapper.write('#define RELEASELONGAELEMS(OLD,NEW) \\\n')
java_wrapper.write(' delete [] NEW; \n\n') java_wrapper.write(' delete [] NEW; \n\n')
java_wrapper.write('#endif\n\n')
pkg_str = get_component('java').package_name.replace('.', '_') pkg_str = get_component('java').package_name.replace('.', '_')
for name, result, params in _dotnet_decls: 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; i = 0;
for param in params: for param in params:
java_wrapper.write(', ') java_wrapper.write(', ')

View file

@ -35,7 +35,7 @@ public class AST extends Z3Object
/** /**
* Object comparison. * Object comparison.
**/ **/
public boolean Equals(Object o) public boolean equals(Object o)
{ {
AST casted = (AST) o; AST casted = (AST) o;
if (casted == null) if (casted == null)
@ -49,7 +49,7 @@ public class AST extends Z3Object
* @return Negative if the object should be sorted before <paramref * @return Negative if the object should be sorted before <paramref
* name="other"/>, positive if after else zero. * name="other"/>, positive if after else zero.
**/ **/
public int CompareTo(Object other) throws Z3Exception public int compareTo(Object other) throws Z3Exception
{ {
if (other == null) if (other == null)
return 1; return 1;
@ -104,7 +104,7 @@ public class AST extends Z3Object
/** /**
* The kind of the AST. * The kind of the AST.
**/ **/
public Z3_ast_kind ASTKind() public Z3_ast_kind ASTKind() throws Z3Exception
{ {
return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(), return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(),
NativeObject())); NativeObject()));
@ -163,8 +163,14 @@ public class AST extends Z3Object
* A string representation of the AST. * A string representation of the AST.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astToString(Context().nCtx(), NativeObject()); return Native.astToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
public class ASTDecRefQueue extends IDecRefQueue public class ASTDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.incRef(ctx.nCtx(), obj); Native.incRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.decRef(ctx.nCtx(), obj); Native.decRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -18,7 +18,7 @@ class ASTMap extends Z3Object
* @return True if <paramref name="k"/> is a key in the map, false * @return True if <paramref name="k"/> is a key in the map, false
* otherwise. * otherwise.
**/ **/
public boolean Contains(AST k) public boolean Contains(AST k) throws Z3Exception
{ {
return Native.astMapContains(Context().nCtx(), NativeObject(), return Native.astMapContains(Context().nCtx(), NativeObject(),
@ -29,6 +29,7 @@ class ASTMap extends Z3Object
* Finds the value associated with the key <paramref name="k"/>. <remarks> * Finds the value associated with the key <paramref name="k"/>. <remarks>
* This function signs an error when <paramref name="k"/> is not a key in * This function signs an error when <paramref name="k"/> is not a key in
* the map. </remarks> <param name="k">An AST</param> * the map. </remarks> <param name="k">An AST</param>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public AST Find(AST k) throws Z3Exception public AST Find(AST k) throws Z3Exception
@ -41,7 +42,7 @@ class ASTMap extends Z3Object
* Stores or replaces a new key/value pair in the map. <param name="k">The * Stores or replaces a new key/value pair in the map. <param name="k">The
* key AST</param> <param name="v">The value AST</param> * key AST</param> <param name="v">The value AST</param>
**/ **/
public void Insert(AST k, AST v) public void Insert(AST k, AST v) throws Z3Exception
{ {
Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(), Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(),
@ -52,7 +53,7 @@ class ASTMap extends Z3Object
* Erases the key <paramref name="k"/> from the map. <param name="k">An * Erases the key <paramref name="k"/> from the map. <param name="k">An
* AST</param> * AST</param>
**/ **/
public void Erase(AST k) public void Erase(AST k) throws Z3Exception
{ {
Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject()); Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject());
@ -61,7 +62,7 @@ class ASTMap extends Z3Object
/** /**
* Removes all keys from the map. * Removes all keys from the map.
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.astMapReset(Context().nCtx(), NativeObject()); Native.astMapReset(Context().nCtx(), NativeObject());
} }
@ -69,13 +70,14 @@ class ASTMap extends Z3Object
/** /**
* The size of the map * The size of the map
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.astMapSize(Context().nCtx(), NativeObject()); return Native.astMapSize(Context().nCtx(), NativeObject());
} }
/** /**
* The keys stored in the map. * The keys stored in the map.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ASTVector Keys() throws Z3Exception public ASTVector Keys() throws Z3Exception
@ -88,8 +90,14 @@ class ASTMap extends Z3Object
* Retrieves a string representation of the map. * Retrieves a string representation of the map.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astMapToString(Context().nCtx(), NativeObject()); return Native.astMapToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ASTMap(Context ctx, long obj) throws Z3Exception ASTMap(Context ctx, long obj) throws Z3Exception

View file

@ -14,7 +14,7 @@ class ASTVector extends Z3Object
/** /**
* The size of the vector * The size of the vector
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.astVectorSize(Context().nCtx(), NativeObject()); return Native.astVectorSize(Context().nCtx(), NativeObject());
} }
@ -33,7 +33,7 @@ class ASTVector extends Z3Object
NativeObject(), i)); NativeObject(), i));
} }
public void set(int i, AST value) public void set(int i, AST value) throws Z3Exception
{ {
Native.astVectorSet(Context().nCtx(), NativeObject(), i, Native.astVectorSet(Context().nCtx(), NativeObject(), i,
@ -44,7 +44,7 @@ class ASTVector extends Z3Object
* Resize the vector to <paramref name="newSize"/>. <param * Resize the vector to <paramref name="newSize"/>. <param
* name="newSize">The new size of the vector.</param> * name="newSize">The new size of the vector.</param>
**/ **/
public void Resize(int newSize) public void Resize(int newSize) throws Z3Exception
{ {
Native.astVectorResize(Context().nCtx(), NativeObject(), newSize); Native.astVectorResize(Context().nCtx(), NativeObject(), newSize);
} }
@ -53,9 +53,8 @@ class ASTVector extends Z3Object
* Add the AST <paramref name="a"/> to the back of the vector. The size is * Add the AST <paramref name="a"/> to the back of the vector. The size is
* increased by 1. <param name="a">An AST</param> * increased by 1. <param name="a">An AST</param>
**/ **/
public void Push(AST a) public void Push(AST a) throws Z3Exception
{ {
Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject()); Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject());
} }
@ -76,8 +75,14 @@ class ASTVector extends Z3Object
* Retrieves a string representation of the vector. * Retrieves a string representation of the vector.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.astVectorToString(Context().nCtx(), NativeObject()); return Native.astVectorToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ASTVector(Context ctx, long obj) throws Z3Exception ASTVector(Context ctx, long obj) throws Z3Exception

View file

@ -15,7 +15,7 @@ public class ApplyResult extends Z3Object
/** /**
* The number of Subgoals. * The number of Subgoals.
**/ **/
public int NumSubgoals() public int NumSubgoals() throws Z3Exception
{ {
return Native.applyResultGetNumSubgoals(Context().nCtx(), return Native.applyResultGetNumSubgoals(Context().nCtx(),
NativeObject()); NativeObject());
@ -23,6 +23,7 @@ public class ApplyResult extends Z3Object
/** /**
* Retrieves the subgoals from the ApplyResult. * Retrieves the subgoals from the ApplyResult.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Goal[] Subgoals() throws Z3Exception public Goal[] Subgoals() throws Z3Exception
@ -52,8 +53,14 @@ public class ApplyResult extends Z3Object
* A string representation of the ApplyResult. * A string representation of the ApplyResult.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.applyResultToString(Context().nCtx(), NativeObject()); return Native.applyResultToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ApplyResult(Context ctx, long obj) throws Z3Exception ApplyResult(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ApplyResultDecRefQueue extends IDecRefQueue class ApplyResultDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.applyResultIncRef(ctx.nCtx(), obj); Native.applyResultIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.applyResultDecRef(ctx.nCtx(), obj); Native.applyResultDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ASTMapDecRefQueue extends IDecRefQueue class ASTMapDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.astMapIncRef(ctx.nCtx(), obj); Native.astMapIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.astMapDecRef(ctx.nCtx(), obj); Native.astMapDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ASTVectorDecRefQueue extends IDecRefQueue class ASTVectorDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.astVectorIncRef(ctx.nCtx(), obj); Native.astVectorIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.astVectorDecRef(ctx.nCtx(), obj); Native.astVectorDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -51,8 +51,14 @@ public class BitVecNum extends BitVecExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
BitVecNum(Context ctx, long obj) throws Z3Exception BitVecNum(Context ctx, long obj) throws Z3Exception

View file

@ -13,7 +13,7 @@ public class BitVecSort extends Sort
/** /**
* The size of the bit-vector sort. * The size of the bit-vector sort.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.getBvSortSize(Context().nCtx(), NativeObject()); return Native.getBvSortSize(Context().nCtx(), NativeObject());
} }

View file

@ -54,7 +54,7 @@ public class Constructor extends Z3Object
/** /**
* Destructor. * Destructor.
**/ **/
protected void finalize() protected void finalize() throws Z3Exception
{ {
Native.delConstructor(Context().nCtx(), NativeObject()); Native.delConstructor(Context().nCtx(), NativeObject());
} }

View file

@ -14,7 +14,7 @@ public class ConstructorList extends Z3Object
/** /**
* Destructor. * Destructor.
**/ **/
protected void finalize() protected void finalize() throws Z3Exception
{ {
Native.delConstructorList(Context().nCtx(), NativeObject()); Native.delConstructorList(Context().nCtx(), NativeObject());
} }

View file

@ -3088,7 +3088,13 @@ public class Context extends IDisposable
if (m_refCount == 0) if (m_refCount == 0)
{ {
m_n_err_handler = null; m_n_err_handler = null;
try
{
Native.delContext(m_ctx); Native.delContext(m_ctx);
} catch (Z3Exception e)
{
// OK.
}
m_ctx = 0; m_ctx = 0;
} else } else
/* re-queue the finalizer */ /* re-queue the finalizer */

View file

@ -14,7 +14,7 @@ public class DatatypeSort extends Sort
/** /**
* The number of constructors of the datatype sort. * The number of constructors of the datatype sort.
**/ **/
public int NumConstructors() public int NumConstructors() throws Z3Exception
{ {
return Native.getDatatypeSortNumConstructors(Context().nCtx(), return Native.getDatatypeSortNumConstructors(Context().nCtx(),
NativeObject()); NativeObject());

View file

@ -14,7 +14,7 @@ public class FiniteDomainSort extends Sort
/** /**
* The size of the finite domain sort. * The size of the finite domain sort.
**/ **/
public long Size() public long Size() throws Z3Exception
{ {
Native.LongPtr res = new Native.LongPtr(); Native.LongPtr res = new Native.LongPtr();
Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res); Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res);

View file

@ -17,9 +17,8 @@ public class Fixedpoint extends Z3Object
/** /**
* A string that describes all available fixedpoint solver parameters. * A string that describes all available fixedpoint solver parameters.
**/ **/
public String Help() public String Help() throws Z3Exception
{ {
return Native.fixedpointGetHelp(Context().nCtx(), NativeObject()); return Native.fixedpointGetHelp(Context().nCtx(), NativeObject());
} }
@ -38,6 +37,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieves parameter descriptions for Fixedpoint solver. * Retrieves parameter descriptions for Fixedpoint solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ParamDescrs ParameterDescriptions() throws Z3Exception public ParamDescrs ParameterDescriptions() throws Z3Exception
@ -53,7 +53,6 @@ public class Fixedpoint extends Z3Object
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
{ {
Context().CheckContextMatch(constraints); Context().CheckContextMatch(constraints);
for (BoolExpr a : constraints) for (BoolExpr a : constraints)
{ {
@ -156,7 +155,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Creates a backtracking point. <seealso cref="Pop"/> * Creates a backtracking point. <seealso cref="Pop"/>
**/ **/
public void Push() public void Push() throws Z3Exception
{ {
Native.fixedpointPush(Context().nCtx(), NativeObject()); Native.fixedpointPush(Context().nCtx(), NativeObject());
} }
@ -166,7 +165,7 @@ public class Fixedpoint extends Z3Object
* thrown if Pop is called without a corresponding <code>Push</code> * thrown if Pop is called without a corresponding <code>Push</code>
* </remarks> <seealso cref="Push"/> * </remarks> <seealso cref="Push"/>
**/ **/
public void Pop() public void Pop() throws Z3Exception
{ {
Native.fixedpointPop(Context().nCtx(), NativeObject()); Native.fixedpointPop(Context().nCtx(), NativeObject());
} }
@ -199,7 +198,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieve explanation why fixedpoint engine returned status Unknown. * Retrieve explanation why fixedpoint engine returned status Unknown.
**/ **/
public String GetReasonUnknown() public String GetReasonUnknown() throws Z3Exception
{ {
return Native.fixedpointGetReasonUnknown(Context().nCtx(), return Native.fixedpointGetReasonUnknown(Context().nCtx(),
@ -209,7 +208,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Retrieve the number of levels explored for a given predicate. * Retrieve the number of levels explored for a given predicate.
**/ **/
public int GetNumLevels(FuncDecl predicate) public int GetNumLevels(FuncDecl predicate) throws Z3Exception
{ {
return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(), return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(),
predicate.NativeObject()); predicate.NativeObject());
@ -232,6 +231,7 @@ public class Fixedpoint extends Z3Object
* at <tt>level</tt>. * at <tt>level</tt>.
**/ **/
public void AddCover(int level, FuncDecl predicate, Expr property) public void AddCover(int level, FuncDecl predicate, Expr property)
throws Z3Exception
{ {
Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level, Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level,
predicate.NativeObject(), property.NativeObject()); predicate.NativeObject(), property.NativeObject());
@ -242,15 +242,21 @@ public class Fixedpoint extends Z3Object
**/ **/
public String toString() public String toString()
{ {
return Native.fixedpointToString(Context().nCtx(), NativeObject(), 0, try
null); {
return Native.fixedpointToString(Context().nCtx(), NativeObject(),
0, null);
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
* Instrument the Datalog engine on which table representation to use for * Instrument the Datalog engine on which table representation to use for
* recursive predicate. * recursive predicate.
**/ **/
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception
{ {
Native.fixedpointSetPredicateRepresentation(Context().nCtx(), Native.fixedpointSetPredicateRepresentation(Context().nCtx(),
@ -262,7 +268,7 @@ public class Fixedpoint extends Z3Object
/** /**
* Convert benchmark given as set of axioms, rules and queries to a string. * Convert benchmark given as set of axioms, rules and queries to a string.
**/ **/
public String toString(BoolExpr[] queries) public String toString(BoolExpr[] queries) throws Z3Exception
{ {
return Native.fixedpointToString(Context().nCtx(), NativeObject(), return Native.fixedpointToString(Context().nCtx(), NativeObject(),

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FixedpointDecRefQueue extends IDecRefQueue class FixedpointDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.fixedpointIncRef(ctx.nCtx(), obj); Native.fixedpointIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.fixedpointDecRef(ctx.nCtx(), obj); Native.fixedpointDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -52,8 +52,14 @@ public class FuncDecl extends AST
* A string representations of the function declaration. * A string representations of the function declaration.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.funcDeclToString(Context().nCtx(), NativeObject()); return Native.funcDeclToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
@ -76,7 +82,7 @@ public class FuncDecl extends AST
* The size of the domain of the function declaration <seealso * The size of the domain of the function declaration <seealso
* cref="Arity"/> * cref="Arity"/>
**/ **/
public int DomainSize() public int DomainSize() throws Z3Exception
{ {
return Native.getDomainSize(Context().nCtx(), NativeObject()); return Native.getDomainSize(Context().nCtx(), NativeObject());
} }
@ -356,16 +362,16 @@ public class FuncDecl extends AST
} }
/** /**
* Create expression that applies function to arguments. * Create expression that applies function to arguments. <param
* <param name="args"></param> * name="args"></param>
* *
* @return * @return
**/ **/
/* operator this[] not translated */ /* operator this[] not translated */
/** /**
* Create expression that applies function to arguments. * Create expression that applies function to arguments. <param
* <param name="args"></param> * name="args"></param>
* *
* @return * @return
**/ **/
@ -376,8 +382,8 @@ public class FuncDecl extends AST
} }
/** /**
* Create expression that applies function to one argument. * Create expression that applies function to one argument. <param
* <param name="arg"></param> * name="arg"></param>
* *
* @return * @return
**/ **/

View file

@ -33,7 +33,7 @@ public class FuncInterp extends Z3Object
/** /**
* The number of arguments of the entry. * The number of arguments of the entry.
**/ **/
public int NumArgs() public int NumArgs() throws Z3Exception
{ {
return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject()); return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject());
} }
@ -93,7 +93,7 @@ public class FuncInterp extends Z3Object
/** /**
* The number of entries in the function interpretation. * The number of entries in the function interpretation.
**/ **/
public int NumEntries() public int NumEntries() throws Z3Exception
{ {
return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject()); return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject());
} }
@ -127,7 +127,7 @@ public class FuncInterp extends Z3Object
/** /**
* The arity of the function interpretation * The arity of the function interpretation
**/ **/
public int Arity() public int Arity() throws Z3Exception
{ {
return Native.funcInterpGetArity(Context().nCtx(), NativeObject()); return Native.funcInterpGetArity(Context().nCtx(), NativeObject());
} }

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FuncInterpDecRefQueue extends IDecRefQueue class FuncInterpDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.funcInterpIncRef(ctx.nCtx(), obj); Native.funcInterpIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.funcInterpDecRef(ctx.nCtx(), obj); Native.funcInterpDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class FuncInterpEntryDecRefQueue extends IDecRefQueue class FuncInterpEntryDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.funcEntryIncRef(ctx.nCtx(), obj); Native.funcEntryIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.funcEntryDecRef(ctx.nCtx(), obj); Native.funcEntryDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -21,7 +21,7 @@ public class Goal extends Z3Object
* applied when the objective is to find a proof for a given goal. * applied when the objective is to find a proof for a given goal.
* </remarks> * </remarks>
**/ **/
public Z3_goal_prec Precision() public Z3_goal_prec Precision() throws Z3Exception
{ {
return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(), return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(),
NativeObject())); NativeObject()));
@ -30,7 +30,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is precise. * Indicates whether the goal is precise.
**/ **/
public boolean IsPrecise() public boolean IsPrecise() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE; return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE;
} }
@ -38,7 +38,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is an under-approximation. * Indicates whether the goal is an under-approximation.
**/ **/
public boolean IsUnderApproximation() public boolean IsUnderApproximation() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER; return Precision() == Z3_goal_prec.Z3_GOAL_UNDER;
} }
@ -46,7 +46,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal is an over-approximation. * Indicates whether the goal is an over-approximation.
**/ **/
public boolean IsOverApproximation() public boolean IsOverApproximation() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_OVER; return Precision() == Z3_goal_prec.Z3_GOAL_OVER;
} }
@ -55,13 +55,14 @@ public class Goal extends Z3Object
* Indicates whether the goal is garbage (i.e., the product of over- and * Indicates whether the goal is garbage (i.e., the product of over- and
* under-approximations). * under-approximations).
**/ **/
public boolean IsGarbage() public boolean IsGarbage() throws Z3Exception
{ {
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER; return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
} }
/** /**
* Adds the <paramref name="constraints"/> to the given goal. * Adds the <paramref name="constraints"/> to the given goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
@ -76,6 +77,7 @@ public class Goal extends Z3Object
/** /**
* Adds a <paramref name="constraint"/> to the given goal. * Adds a <paramref name="constraint"/> to the given goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr constraint) throws Z3Exception public void Assert(BoolExpr constraint) throws Z3Exception
@ -88,7 +90,7 @@ public class Goal extends Z3Object
/** /**
* Indicates whether the goal contains `false'. * Indicates whether the goal contains `false'.
**/ **/
public boolean Inconsistent() public boolean Inconsistent() throws Z3Exception
{ {
return Native.goalInconsistent(Context().nCtx(), NativeObject()); return Native.goalInconsistent(Context().nCtx(), NativeObject());
} }
@ -97,7 +99,7 @@ public class Goal extends Z3Object
* The depth of the goal. <remarks> This tracks how many transformations * The depth of the goal. <remarks> This tracks how many transformations
* were applied to it. </remarks> * were applied to it. </remarks>
**/ **/
public int Depth() public int Depth() throws Z3Exception
{ {
return Native.goalDepth(Context().nCtx(), NativeObject()); return Native.goalDepth(Context().nCtx(), NativeObject());
} }
@ -105,7 +107,7 @@ public class Goal extends Z3Object
/** /**
* Erases all formulas from the given goal. * Erases all formulas from the given goal.
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.goalReset(Context().nCtx(), NativeObject()); Native.goalReset(Context().nCtx(), NativeObject());
} }
@ -113,13 +115,14 @@ public class Goal extends Z3Object
/** /**
* The number of formulas in the goal. * The number of formulas in the goal.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.goalSize(Context().nCtx(), NativeObject()); return Native.goalSize(Context().nCtx(), NativeObject());
} }
/** /**
* The formulas in the goal. * The formulas in the goal.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public BoolExpr[] Formulas() throws Z3Exception public BoolExpr[] Formulas() throws Z3Exception
@ -135,7 +138,7 @@ public class Goal extends Z3Object
/** /**
* The number of formulas, subformulas and terms in the goal. * The number of formulas, subformulas and terms in the goal.
**/ **/
public int NumExprs() public int NumExprs() throws Z3Exception
{ {
return Native.goalNumExprs(Context().nCtx(), NativeObject()); return Native.goalNumExprs(Context().nCtx(), NativeObject());
} }
@ -144,7 +147,7 @@ public class Goal extends Z3Object
* Indicates whether the goal is empty, and it is precise or the product of * Indicates whether the goal is empty, and it is precise or the product of
* an under approximation. * an under approximation.
**/ **/
public boolean IsDecidedSat() public boolean IsDecidedSat() throws Z3Exception
{ {
return Native.goalIsDecidedSat(Context().nCtx(), NativeObject()); return Native.goalIsDecidedSat(Context().nCtx(), NativeObject());
} }
@ -153,7 +156,7 @@ public class Goal extends Z3Object
* Indicates whether the goal contains `false', and it is precise or the * Indicates whether the goal contains `false', and it is precise or the
* product of an over approximation. * product of an over approximation.
**/ **/
public boolean IsDecidedUnsat() public boolean IsDecidedUnsat() throws Z3Exception
{ {
return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject()); return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject());
} }
@ -161,6 +164,7 @@ public class Goal extends Z3Object
/** /**
* Translates (copies) the Goal to the target Context <paramref * Translates (copies) the Goal to the target Context <paramref
* name="ctx"/>. * name="ctx"/>.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Goal Translate(Context ctx) throws Z3Exception public Goal Translate(Context ctx) throws Z3Exception
@ -190,8 +194,14 @@ public class Goal extends Z3Object
* @return A string representation of the Goal. * @return A string representation of the Goal.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.goalToString(Context().nCtx(), NativeObject()); return Native.goalToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Goal(Context ctx, long obj) throws Z3Exception Goal(Context ctx, long obj) throws Z3Exception
@ -199,7 +209,8 @@ public class Goal extends Z3Object
super(ctx, obj); super(ctx, obj);
} }
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) throws Z3Exception Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs)
throws Z3Exception
{ {
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false, super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
(unsatCores) ? true : false, (proofs) ? true : false)); (unsatCores) ? true : false, (proofs) ? true : false));

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class GoalDecRefQueue extends IDecRefQueue class GoalDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.goalIncRef(ctx.nCtx(), obj); Native.goalIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.goalDecRef(ctx.nCtx(), obj); Native.goalDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -53,7 +53,13 @@ public class IntNum extends IntExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
} }

View file

@ -105,13 +105,14 @@ public class Model extends Z3Object
/** /**
* The number of constants that have an interpretation in the model. * 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()); return Native.modelGetNumConsts(Context().nCtx(), NativeObject());
} }
/** /**
* The function declarations of the constants in the model. * The function declarations of the constants in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] ConstDecls() throws Z3Exception public FuncDecl[] ConstDecls() throws Z3Exception
@ -127,13 +128,14 @@ public class Model extends Z3Object
/** /**
* The number of function interpretations in the model. * The number of function interpretations in the model.
**/ **/
public int NumFuncs() public int NumFuncs() throws Z3Exception
{ {
return Native.modelGetNumFuncs(Context().nCtx(), NativeObject()); return Native.modelGetNumFuncs(Context().nCtx(), NativeObject());
} }
/** /**
* The function declarations of the function interpretations in the model. * The function declarations of the function interpretations in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] FuncDecls() throws Z3Exception public FuncDecl[] FuncDecls() throws Z3Exception
@ -148,6 +150,7 @@ public class Model extends Z3Object
/** /**
* All symbols that have an interpretation in the model. * All symbols that have an interpretation in the model.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public FuncDecl[] Decls() throws Z3Exception public FuncDecl[] Decls() throws Z3Exception
@ -206,6 +209,7 @@ public class Model extends Z3Object
/** /**
* Alias for <code>Eval</code>. * Alias for <code>Eval</code>.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr Evaluate(Expr t, boolean completion) 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 * The number of uninterpreted sorts that the model has an interpretation
* for. * for.
**/ **/
public int NumSorts() public int NumSorts() throws Z3Exception
{ {
return Native.modelGetNumSorts(Context().nCtx(), NativeObject()); return Native.modelGetNumSorts(Context().nCtx(), NativeObject());
} }
@ -228,6 +232,7 @@ public class Model extends Z3Object
* in a formula. The interpretation for a sort is a finite set of distinct * in a formula. The interpretation for a sort is a finite set of distinct
* values. We say this finite set is the "universe" of the sort. </remarks> * values. We say this finite set is the "universe" of the sort. </remarks>
* <seealso cref="NumSorts"/> <seealso cref="SortUniverse"/> * <seealso cref="NumSorts"/> <seealso cref="SortUniverse"/>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Sort[] Sorts() throws Z3Exception public Sort[] Sorts() throws Z3Exception
@ -268,8 +273,14 @@ public class Model extends Z3Object
* @return A string representation of the model. * @return A string representation of the model.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.modelToString(Context().nCtx(), NativeObject()); return Native.modelToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Model(Context ctx, long obj) throws Z3Exception Model(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ModelDecRefQueue extends IDecRefQueue class ModelDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.modelIncRef(ctx.nCtx(), obj); Native.modelIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.modelDecRef(ctx.nCtx(), obj); Native.modelDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class ParamDescrs extends Z3Object
/** /**
* validate a set of parameters. * validate a set of parameters.
**/ **/
public void Validate(Params p) public void Validate(Params p) throws Z3Exception
{ {
Native.paramsValidate(Context().nCtx(), p.NativeObject(), Native.paramsValidate(Context().nCtx(), p.NativeObject(),
@ -26,7 +26,7 @@ public class ParamDescrs extends Z3Object
/** /**
* Retrieve kind of parameter. * 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( return Z3_param_kind.fromInt(Native.paramDescrsGetKind(
@ -53,7 +53,7 @@ public class ParamDescrs extends Z3Object
/** /**
* The size of the ParamDescrs. * The size of the ParamDescrs.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.paramDescrsSize(Context().nCtx(), NativeObject()); return Native.paramDescrsSize(Context().nCtx(), NativeObject());
} }
@ -62,8 +62,14 @@ public class ParamDescrs extends Z3Object
* Retrieves a string representation of the ParamDescrs. * Retrieves a string representation of the ParamDescrs.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.paramDescrsToString(Context().nCtx(), NativeObject()); return Native.paramDescrsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
ParamDescrs(Context ctx, long obj) throws Z3Exception ParamDescrs(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ParamDescrsDecRefQueue extends IDecRefQueue class ParamDescrsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.paramDescrsIncRef(ctx.nCtx(), obj); Native.paramDescrsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.paramDescrsDecRef(ctx.nCtx(), obj); Native.paramDescrsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -79,8 +79,14 @@ public class Params extends Z3Object
* A string representation of the parameter set. * A string representation of the parameter set.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.paramsToString(Context().nCtx(), NativeObject()); return Native.paramsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Params(Context ctx) throws Z3Exception Params(Context ctx) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ParamsDecRefQueue extends IDecRefQueue class ParamsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.paramsIncRef(ctx.nCtx(), obj); Native.paramsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.paramsDecRef(ctx.nCtx(), obj); Native.paramsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -15,7 +15,7 @@ public class Pattern extends AST
/** /**
* The number of terms in the pattern. * The number of terms in the pattern.
**/ **/
public int NumTerms() public int NumTerms() throws Z3Exception
{ {
return Native.getPatternNumTerms(Context().nCtx(), NativeObject()); return Native.getPatternNumTerms(Context().nCtx(), NativeObject());
} }
@ -40,8 +40,14 @@ public class Pattern extends AST
* A string representation of the pattern. * A string representation of the pattern.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.patternToString(Context().nCtx(), NativeObject()); return Native.patternToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Pattern(Context ctx, long obj) throws Z3Exception Pattern(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class ProbeDecRefQueue extends IDecRefQueue class ProbeDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.probeIncRef(ctx.nCtx(), obj); Native.probeIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.probeDecRef(ctx.nCtx(), obj); Native.probeDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class Quantifier extends BoolExpr
/** /**
* Indicates whether the quantifier is universal. * Indicates whether the quantifier is universal.
**/ **/
public boolean IsUniversal() public boolean IsUniversal() throws Z3Exception
{ {
return Native.isQuantifierForall(Context().nCtx(), NativeObject()); return Native.isQuantifierForall(Context().nCtx(), NativeObject());
} }
@ -24,7 +24,7 @@ public class Quantifier extends BoolExpr
/** /**
* Indicates whether the quantifier is existential. * Indicates whether the quantifier is existential.
**/ **/
public boolean IsExistential() public boolean IsExistential() throws Z3Exception
{ {
return !IsUniversal(); return !IsUniversal();
} }
@ -32,7 +32,7 @@ public class Quantifier extends BoolExpr
/** /**
* The weight of the quantifier. * The weight of the quantifier.
**/ **/
public int Weight() public int Weight() throws Z3Exception
{ {
return Native.getQuantifierWeight(Context().nCtx(), NativeObject()); return Native.getQuantifierWeight(Context().nCtx(), NativeObject());
} }
@ -40,7 +40,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of patterns. * The number of patterns.
**/ **/
public int NumPatterns() public int NumPatterns() throws Z3Exception
{ {
return Native return Native
.getQuantifierNumPatterns(Context().nCtx(), NativeObject()); .getQuantifierNumPatterns(Context().nCtx(), NativeObject());
@ -64,7 +64,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of no-patterns. * The number of no-patterns.
**/ **/
public int NumNoPatterns() public int NumNoPatterns() throws Z3Exception
{ {
return Native.getQuantifierNumNoPatterns(Context().nCtx(), return Native.getQuantifierNumNoPatterns(Context().nCtx(),
NativeObject()); NativeObject());
@ -88,7 +88,7 @@ public class Quantifier extends BoolExpr
/** /**
* The number of bound variables. * The number of bound variables.
**/ **/
public int NumBound() public int NumBound() throws Z3Exception
{ {
return Native.getQuantifierNumBound(Context().nCtx(), NativeObject()); return Native.getQuantifierNumBound(Context().nCtx(), NativeObject());
} }

View file

@ -7,6 +7,7 @@
package com.microsoft.z3; package com.microsoft.z3;
import java.math.BigInteger; import java.math.BigInteger;
/** /**
* Rational Numerals * Rational Numerals
**/ **/
@ -62,8 +63,14 @@ public class RatNum extends RealExpr
* Returns a string representation of the numeral. * Returns a string representation of the numeral.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.getNumeralString(Context().nCtx(), NativeObject()); return Native.getNumeralString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
RatNum(Context ctx, long obj) throws Z3Exception RatNum(Context ctx, long obj) throws Z3Exception

View file

@ -14,7 +14,7 @@ public class RelationSort extends Sort
/** /**
* The arity of the relation sort. * The arity of the relation sort.
**/ **/
public int Arity() public int Arity() throws Z3Exception
{ {
return Native.getRelationArity(Context().nCtx(), NativeObject()); return Native.getRelationArity(Context().nCtx(), NativeObject());
} }

View file

@ -16,13 +16,14 @@ public class Solver extends Z3Object
/** /**
* A string that describes all available solver parameters. * A string that describes all available solver parameters.
**/ **/
public String Help() public String Help() throws Z3Exception
{ {
return Native.solverGetHelp(Context().nCtx(), NativeObject()); return Native.solverGetHelp(Context().nCtx(), NativeObject());
} }
/** /**
* Sets the solver parameters. * Sets the solver parameters.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void setParameters(Params value) throws Z3Exception public void setParameters(Params value) throws Z3Exception
@ -34,6 +35,7 @@ public class Solver extends Z3Object
/** /**
* Retrieves parameter descriptions for solver. * Retrieves parameter descriptions for solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public ParamDescrs ParameterDescriptions() throws Z3Exception public ParamDescrs ParameterDescriptions() throws Z3Exception
@ -46,7 +48,7 @@ public class Solver extends Z3Object
* The current number of backtracking points (scopes). <seealso cref="Pop"/> * The current number of backtracking points (scopes). <seealso cref="Pop"/>
* <seealso cref="Push"/> * <seealso cref="Push"/>
**/ **/
public int NumScopes() public int NumScopes() throws Z3Exception
{ {
return Native.solverGetNumScopes(Context().nCtx(), NativeObject()); return Native.solverGetNumScopes(Context().nCtx(), NativeObject());
} }
@ -54,7 +56,7 @@ public class Solver extends Z3Object
/** /**
* Creates a backtracking point. <seealso cref="Pop"/> * Creates a backtracking point. <seealso cref="Pop"/>
**/ **/
public void Push() public void Push() throws Z3Exception
{ {
Native.solverPush(Context().nCtx(), NativeObject()); Native.solverPush(Context().nCtx(), NativeObject());
} }
@ -62,7 +64,7 @@ public class Solver extends Z3Object
/** /**
* Backtracks one backtracking point. <remarks>. * Backtracks one backtracking point. <remarks>.
**/ **/
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 <paramref name="n"/> is not smaller than * an exception is thrown if <paramref name="n"/> is not smaller than
* <code>NumScopes</code></remarks> <seealso cref="Push"/> * <code>NumScopes</code></remarks> <seealso cref="Push"/>
**/ **/
public void Pop(int n) public void Pop(int n) throws Z3Exception
{ {
Native.solverPop(Context().nCtx(), NativeObject(), n); Native.solverPop(Context().nCtx(), NativeObject(), n);
} }
@ -81,13 +83,14 @@ public class Solver extends Z3Object
* Resets the Solver. <remarks>This removes all assertions from the * Resets the Solver. <remarks>This removes all assertions from the
* solver.</remarks> * solver.</remarks>
**/ **/
public void Reset() public void Reset() throws Z3Exception
{ {
Native.solverReset(Context().nCtx(), NativeObject()); Native.solverReset(Context().nCtx(), NativeObject());
} }
/** /**
* Assert a multiple constraints into the solver. * Assert a multiple constraints into the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr[] constraints) throws Z3Exception public void Assert(BoolExpr[] constraints) throws Z3Exception
@ -102,16 +105,19 @@ public class Solver extends Z3Object
/** /**
* Assert one constraint into the solver. * Assert one constraint into the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public void Assert(BoolExpr constraint) throws Z3Exception public void Assert(BoolExpr constraint) throws Z3Exception
{ {
Context().CheckContextMatch(constraint); Context().CheckContextMatch(constraint);
Native.solverAssert(Context().nCtx(), NativeObject(), constraint.NativeObject()); Native.solverAssert(Context().nCtx(), NativeObject(),
constraint.NativeObject());
} }
/** /**
* The number of assertions in the solver. * The number of assertions in the solver.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public int NumAssertions() throws Z3Exception public int NumAssertions() throws Z3Exception
@ -123,6 +129,7 @@ public class Solver extends Z3Object
/** /**
* The set of asserted formulas. * The set of asserted formulas.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public BoolExpr[] Assertions() throws Z3Exception public BoolExpr[] Assertions() throws Z3Exception
@ -141,7 +148,7 @@ public class Solver extends Z3Object
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso * <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
* cref="Proof"/> </remarks> * cref="Proof"/> </remarks>
**/ **/
public Status Check(Expr[] assumptions) public Status Check(Expr[] assumptions) throws Z3Exception
{ {
Z3_lbool r; Z3_lbool r;
if (assumptions == null) if (assumptions == null)
@ -167,7 +174,7 @@ public class Solver extends Z3Object
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso * <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
* cref="Proof"/> </remarks> * cref="Proof"/> </remarks>
**/ **/
public Status Check() public Status Check() throws Z3Exception
{ {
return Check(null); return Check(null);
} }
@ -177,6 +184,7 @@ public class Solver extends Z3Object
* <code>null</code> if <code>Check</code> was not invoked before, if its * <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>SATISFIABLE</code>, or if model production is not * results was not <code>SATISFIABLE</code>, or if model production is not
* enabled. </remarks> * enabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Model Model() throws Z3Exception public Model Model() throws Z3Exception
@ -193,6 +201,7 @@ public class Solver extends Z3Object
* <code>null</code> if <code>Check</code> was not invoked before, if its * <code>null</code> if <code>Check</code> was not invoked before, if its
* results was not <code>UNSATISFIABLE</code>, or if proof production is * results was not <code>UNSATISFIABLE</code>, or if proof production is
* disabled. </remarks> * disabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr Proof() throws Z3Exception public Expr Proof() throws Z3Exception
@ -209,6 +218,7 @@ public class Solver extends Z3Object
* is a subset of <code>Assertions</code> The result is empty if * is a subset of <code>Assertions</code> The result is empty if
* <code>Check</code> was not invoked before, if its results was not * <code>Check</code> was not invoked before, if its results was not
* <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks> * <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Expr[] UnsatCore() throws Z3Exception public Expr[] UnsatCore() throws Z3Exception
@ -227,14 +237,14 @@ public class Solver extends Z3Object
* A brief justification of why the last call to <code>Check</code> returned * A brief justification of why the last call to <code>Check</code> returned
* <code>UNKNOWN</code>. * <code>UNKNOWN</code>.
**/ **/
public String ReasonUnknown() public String ReasonUnknown() throws Z3Exception
{ {
return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject()); return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject());
} }
/** /**
* Solver statistics. * Solver statistics.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Statistics Statistics() throws Z3Exception public Statistics Statistics() throws Z3Exception
@ -247,8 +257,14 @@ public class Solver extends Z3Object
* A string representation of the solver. * A string representation of the solver.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.solverToString(Context().nCtx(), NativeObject()); return Native.solverToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
Solver(Context ctx, long obj) throws Z3Exception Solver(Context ctx, long obj) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class SolverDecRefQueue extends IDecRefQueue class SolverDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.solverIncRef(ctx.nCtx(), obj); Native.solverIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.solverDecRef(ctx.nCtx(), obj); Native.solverDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -37,7 +37,7 @@ public class Sort extends AST
* *
* @return * @return
**/ **/
public boolean Equals(Object o) public boolean equals(Object o)
{ {
Sort casted = (Sort) o; Sort casted = (Sort) o;
if (casted == null) if (casted == null)
@ -85,8 +85,14 @@ public class Sort extends AST
* A string representation of the sort. * A string representation of the sort.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.sortToString(Context().nCtx(), NativeObject()); return Native.sortToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**

View file

@ -56,6 +56,7 @@ public class Statistics extends Z3Object
/** /**
* The string representation of the the entry's value. * The string representation of the the entry's value.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public String Value() throws Z3Exception public String Value() throws Z3Exception
@ -106,20 +107,27 @@ public class Statistics extends Z3Object
* A string representation of the statistical data. * A string representation of the statistical data.
**/ **/
public String toString() public String toString()
{
try
{ {
return Native.statsToString(Context().nCtx(), NativeObject()); return Native.statsToString(Context().nCtx(), NativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
} }
/** /**
* The number of statistical data. * The number of statistical data.
**/ **/
public int Size() public int Size() throws Z3Exception
{ {
return Native.statsSize(Context().nCtx(), NativeObject()); return Native.statsSize(Context().nCtx(), NativeObject());
} }
/** /**
* The data entries. * The data entries.
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Entry[] Entries() throws Z3Exception public Entry[] Entries() throws Z3Exception
@ -147,7 +155,7 @@ public class Statistics extends Z3Object
/** /**
* The statistical counters. * The statistical counters.
**/ **/
public String[] Keys() public String[] Keys() throws Z3Exception
{ {
int n = Size(); int n = Size();
String[] res = new String[n]; String[] res = new String[n];
@ -159,6 +167,7 @@ public class Statistics extends Z3Object
/** /**
* The value of a particular statistical counter. <remarks>Returns null if * The value of a particular statistical counter. <remarks>Returns null if
* the key is unknown.</remarks> * the key is unknown.</remarks>
*
* @throws Z3Exception * @throws Z3Exception
**/ **/
public Entry get(String key) throws Z3Exception public Entry get(String key) throws Z3Exception

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class StatisticsDecRefQueue extends IDecRefQueue class StatisticsDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.statsIncRef(ctx.nCtx(), obj); Native.statsIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.statsDecRef(ctx.nCtx(), obj); Native.statsDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -16,7 +16,7 @@ public class Symbol extends Z3Object
/** /**
* The kind of the symbol (int or string) * 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(), return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(),
NativeObject())); NativeObject()));
@ -25,7 +25,7 @@ public class Symbol extends Z3Object
/** /**
* Indicates whether the symbol is of Int kind * Indicates whether the symbol is of Int kind
**/ **/
public boolean IsIntSymbol() public boolean IsIntSymbol() throws Z3Exception
{ {
return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL; 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. * Indicates whether the symbol is of string kind.
**/ **/
public boolean IsStringSymbol() public boolean IsStringSymbol() throws Z3Exception
{ {
return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL; return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
} }

View file

@ -18,7 +18,7 @@ public class Tactic extends Z3Object
/** /**
* A string containing a description of parameters accepted by the tactic. * 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()); return Native.tacticGetHelp(Context().nCtx(), NativeObject());
} }

View file

@ -8,12 +8,24 @@ package com.microsoft.z3;
class TacticDecRefQueue extends IDecRefQueue class TacticDecRefQueue extends IDecRefQueue
{ {
public void IncRef(Context ctx, long obj) public void IncRef(Context ctx, long obj)
{
try
{ {
Native.tacticIncRef(ctx.nCtx(), obj); Native.tacticIncRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
public void DecRef(Context ctx, long obj) public void DecRef(Context ctx, long obj)
{
try
{ {
Native.tacticDecRef(ctx.nCtx(), obj); Native.tacticDecRef(ctx.nCtx(), obj);
} catch (Z3Exception e)
{
// OK.
}
} }
}; };

View file

@ -25,7 +25,7 @@ public class TupleSort extends Sort
/** /**
* The number of fields in the tuple. * The number of fields in the tuple.
**/ **/
public int NumFields() public int NumFields() throws Z3Exception
{ {
return Native.getTupleSortNumFields(Context().nCtx(), NativeObject()); return Native.getTupleSortNumFields(Context().nCtx(), NativeObject());
} }

View file

@ -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_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_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( PRIVATE_PARAMS(
p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL,
@ -1625,6 +1626,23 @@ namespace datalog {
void context::get_rules_as_formulas(expr_ref_vector& rules, svector<symbol>& names) { void context::get_rules_as_formulas(expr_ref_vector& rules, svector<symbol>& names) {
expr_ref fml(m); 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<sort> 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(); rule_set::iterator it = m_rule_set.begin(), end = m_rule_set.end();
for (; it != end; ++it) { for (; it != end; ++it) {
(*it)->to_formula(fml); (*it)->to_formula(fml);
@ -1652,6 +1670,7 @@ namespace datalog {
svector<symbol> names; svector<symbol> names;
bool use_fixedpoint_extensions = m_params.get_bool("print_with_fixedpoint_extensions", true); 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 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, params);
@ -1708,7 +1727,7 @@ namespace datalog {
out << "))\n"; out << "))\n";
} }
if (use_fixedpoint_extensions) { if (use_fixedpoint_extensions && do_declare_vars) {
declare_vars(rules, fresh_names, out); declare_vars(rules, fresh_names, out);
} }
@ -1730,13 +1749,20 @@ namespace datalog {
} }
PP(r); PP(r);
if (symbol::null != nm) { if (symbol::null != nm) {
out << " :named ";
while (fresh_names.contains(nm)) { while (fresh_names.contains(nm)) {
std::ostringstream s; std::ostringstream s;
s << nm << "!"; s << nm << "!";
nm = symbol(s.str().c_str()); nm = symbol(s.str().c_str());
} }
fresh_names.add(nm); 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"; out << ")\n";
} }

View file

@ -461,6 +461,11 @@ namespace datalog {
{ {
rule_ref r(r0, m_context.get_rule_manager()); rule_ref r(r0, m_context.get_rule_manager());
if (r->has_quantifiers()) {
res = r;
return false;
}
start: start:
unsigned u_len = r->get_uninterpreted_tail_size(); unsigned u_len = r->get_uninterpreted_tail_size();
unsigned len = r->get_tail_size(); unsigned len = r->get_tail_size();

View file

@ -90,21 +90,30 @@ class horn_tactic : public tactic {
m_ctx.register_predicate(to_app(a)->get_decl(), true); m_ctx.register_predicate(to_app(a)->get_decl(), true);
} }
void check_predicate(expr* a) { void check_predicate(ast_mark& mark, expr* a) {
expr* a1 = 0; ptr_vector<expr> todo;
while (true) { 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)) { if (is_quantifier(a)) {
a = to_quantifier(a)->get_expr(); a = to_quantifier(a)->get_expr();
continue; todo.push_back(a);
} }
if (m.is_not(a, a1)) { else if (m.is_not(a) || m.is_and(a) || m.is_or(a) || m.is_implies(a)) {
a = a1; todo.append(to_app(a)->get_num_args(), to_app(a)->get_args());
continue;
} }
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); register_predicate(a);
} }
break;
} }
} }
@ -112,14 +121,15 @@ class horn_tactic : public tactic {
formula_kind get_formula_kind(expr_ref& f) { formula_kind get_formula_kind(expr_ref& f) {
normalize(f); normalize(f);
ast_mark mark;
expr_ref_vector args(m), body(m); expr_ref_vector args(m), body(m);
expr_ref head(m); expr_ref head(m);
expr* a = 0, *a1 = 0; expr* a = 0, *a1 = 0;
datalog::flatten_or(f, args); datalog::flatten_or(f, args);
for (unsigned i = 0; i < args.size(); ++i) { for (unsigned i = 0; i < args.size(); ++i) {
a = args[i].get(); a = args[i].get();
check_predicate(a); check_predicate(mark, a);
if (m.is_not(a, a1) && is_predicate(a1)) { if (m.is_not(a, a1)) {
body.push_back(a1); body.push_back(a1);
} }
else if (is_predicate(a)) { else if (is_predicate(a)) {
@ -128,9 +138,6 @@ class horn_tactic : public tactic {
} }
head = a; head = a;
} }
else if (m.is_not(a, a1)) {
body.push_back(a1);
}
else { else {
body.push_back(m.mk_not(a)); body.push_back(m.mk_not(a));
} }

View file

@ -1827,11 +1827,9 @@ namespace pdr {
proof_ref pr(m); proof_ref pr(m);
pr = m.mk_asserted(m.mk_true()); pr = m.mk_asserted(m.mk_true());
for (unsigned i = 0; i < vars.size(); ++i) { for (unsigned i = 0; i < vars.size(); ++i) {
if (smt::is_value_sort(m, vars[i].get())) {
tmp = mev.eval(M, vars[i].get()); tmp = mev.eval(M, vars[i].get());
sub.insert(vars[i].get(), tmp, pr); sub.insert(vars[i].get(), tmp, pr);
} }
}
if (!rep) rep = mk_expr_simp_replacer(m); if (!rep) rep = mk_expr_simp_replacer(m);
rep->set_substitution(&sub); rep->set_substitution(&sub);
(*rep)(phi1); (*rep)(phi1);

View file

@ -608,6 +608,7 @@ namespace pdr {
best effort evaluator of extensional array equality. best effort evaluator of extensional array equality.
*/ */
void model_evaluator::eval_array_eq(app* e, expr* arg1, expr* arg2) { 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); expr_ref v1(m), v2(m);
m_model->eval(arg1, v1); m_model->eval(arg1, v1);
m_model->eval(arg2, v2); m_model->eval(arg2, v2);
@ -633,7 +634,10 @@ namespace pdr {
if (else1 != else2) { if (else1 != else2) {
if (m.is_value(else1) && m.is_value(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 { else {
TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";); TRACE("pdr", tout << "equality is unknown: " << mk_pp(e, m) << "\n";);
@ -659,7 +663,10 @@ namespace pdr {
continue; continue;
} }
else if (m.is_value(w1) && m.is_value(w2)) { 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; return;
} }
else { else {
@ -668,7 +675,7 @@ namespace pdr {
return; return;
} }
} }
set_bool(e, true); set_true(e);
} }
void model_evaluator::eval_eq(app* e, expr* arg1, expr* arg2) { void model_evaluator::eval_eq(app* e, expr* arg1, expr* arg2) {

View file

@ -102,6 +102,7 @@ template<typename Ext>
bool theory_diff_logic<Ext>::internalize_term(app * term) { bool theory_diff_logic<Ext>::internalize_term(app * term) {
bool result = null_theory_var != mk_term(term); bool result = null_theory_var != mk_term(term);
CTRACE("arith", !result, tout << "Did not internalize " << mk_pp(term, get_manager()) << "\n";); 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); found_non_diff_logic_expr(term);
return result; return result;
} }
@ -831,6 +832,7 @@ theory_var theory_diff_logic<Ext>::mk_var(app* n) {
v = mk_var(e); v = mk_var(e);
} }
if (is_interpreted(n)) { if (is_interpreted(n)) {
TRACE("non_diff_logic", tout << "Variable should not be interpreted\n";);
found_non_diff_logic_expr(n); found_non_diff_logic_expr(n);
} }
TRACE("arith", tout << mk_pp(n, get_manager()) << " |-> " << v << "\n";); TRACE("arith", tout << mk_pp(n, get_manager()) << " |-> " << v << "\n";);