mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
Add basic MARCO example
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
67ea78a4a5
|
@ -304,7 +304,10 @@ endif()
|
||||||
# library. If not building a shared library ``-fPIC`` isn't needed and would add
|
# library. If not building a shared library ``-fPIC`` isn't needed and would add
|
||||||
# unnecessary overhead.
|
# unnecessary overhead.
|
||||||
if (BUILD_LIBZ3_SHARED)
|
if (BUILD_LIBZ3_SHARED)
|
||||||
if (NOT MSVC)
|
# Avoid adding -fPIC compiler switch if we compile with MSVC (which does not
|
||||||
|
# support the flag) or if we target Windows, which generally does not use
|
||||||
|
# position independent code for native code shared libraries (DLLs).
|
||||||
|
if (NOT (MSVC OR MINGW OR WIN32))
|
||||||
z3_add_cxx_flag("-fPIC" REQUIRED)
|
z3_add_cxx_flag("-fPIC" REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -387,4 +390,3 @@ option(ENABLE_EXAMPLE_TARGETS "Build Z3 api examples" ON)
|
||||||
if (ENABLE_EXAMPLE_TARGETS)
|
if (ENABLE_EXAMPLE_TARGETS)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
10
README.md
10
README.md
|
@ -56,6 +56,16 @@ CXX=clang++ CC=clang python scripts/mk_make.py
|
||||||
|
|
||||||
Note that Clang < 3.7 does not support OpenMP.
|
Note that Clang < 3.7 does not support OpenMP.
|
||||||
|
|
||||||
|
You can also build Z3 for Windows using Cygwin and the Mingw-w64 cross-compiler.
|
||||||
|
To configure that case correctly, make sure to use Cygwin's own python and not
|
||||||
|
some Windows installation of Python.
|
||||||
|
|
||||||
|
For a 64 bit build (from Cygwin64), configure Z3's sources with
|
||||||
|
```bash
|
||||||
|
CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar python scripts/mk_make.py
|
||||||
|
```
|
||||||
|
A 32 bit build should work similarly (but is untested); the same is true for 32/64 bit builds from within Cygwin32.
|
||||||
|
|
||||||
By default, it will install z3 executable at ``PREFIX/bin``, libraries at
|
By default, it will install z3 executable at ``PREFIX/bin``, libraries at
|
||||||
``PREFIX/lib``, and include files at ``PREFIX/include``, where ``PREFIX``
|
``PREFIX/lib``, and include files at ``PREFIX/include``, where ``PREFIX``
|
||||||
installation prefix if inferred by the ``mk_make.py`` script. It is usually
|
installation prefix if inferred by the ``mk_make.py`` script. It is usually
|
||||||
|
|
|
@ -188,7 +188,7 @@ class JavaExample
|
||||||
/* do something with the context */
|
/* do something with the context */
|
||||||
|
|
||||||
/* be kind to dispose manually and not wait for the GC. */
|
/* be kind to dispose manually and not wait for the GC. */
|
||||||
ctx.dispose();
|
ctx.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
185
examples/python/mus/marco.py
Normal file
185
examples/python/mus/marco.py
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
############################################
|
||||||
|
# Copyright (c) 2016 Microsoft Corporation
|
||||||
|
#
|
||||||
|
# Basic core and correction set enumeration.
|
||||||
|
#
|
||||||
|
# Author: Nikolaj Bjorner (nbjorner)
|
||||||
|
############################################
|
||||||
|
|
||||||
|
"""
|
||||||
|
Enumeration of Minimal Unsatisfiable Cores and Maximal Satisfying Subsets
|
||||||
|
This tutorial illustrates how to use Z3 for extracting all minimal unsatisfiable
|
||||||
|
cores together with all maximal satisfying subsets.
|
||||||
|
|
||||||
|
Origin
|
||||||
|
The algorithm that we describe next represents the essence of the core extraction
|
||||||
|
procedure by Liffiton and Malik and independently by Previti and Marques-Silva:
|
||||||
|
Enumerating Infeasibility: Finding Multiple MUSes Quickly
|
||||||
|
Mark H. Liffiton and Ammar Malik
|
||||||
|
in Proc. 10th International Conference on Integration of Artificial Intelligence (AI)
|
||||||
|
and Operations Research (OR) techniques in Constraint Programming (CPAIOR-2013), 160-175, May 2013.
|
||||||
|
|
||||||
|
Partial MUS Enumeration
|
||||||
|
Alessandro Previti, Joao Marques-Silva in Proc. AAAI-2013 July 2013
|
||||||
|
|
||||||
|
Z3py Features
|
||||||
|
|
||||||
|
This implementation contains no tuning. It was contributed by Mark Liffiton and it is
|
||||||
|
a simplification of one of the versions available from his Marco Polo Web site.
|
||||||
|
It illustrates the following features of Z3's Python-based API:
|
||||||
|
1. Using assumptions to track unsatisfiable cores.
|
||||||
|
2. Using multiple solvers and passing constraints between them.
|
||||||
|
3. Calling the C-based API from Python. Not all API functions are supported over the
|
||||||
|
Python wrappers. This example shows how to get a unique integer identifier of an AST,
|
||||||
|
which can be used as a key in a hash-table.
|
||||||
|
|
||||||
|
Idea of the Algorithm
|
||||||
|
The main idea of the algorithm is to maintain two logical contexts and exchange information
|
||||||
|
between them:
|
||||||
|
|
||||||
|
1. The MapSolver is used to enumerate sets of clauses that are not already
|
||||||
|
supersets of an existing unsatisfiable core and not already a subset of a maximal satisfying
|
||||||
|
assignment. The MapSolver uses one unique atomic predicate per soft clause, so it enumerates
|
||||||
|
sets of atomic predicates. For each minimal unsatisfiable core, say, represented by predicates
|
||||||
|
p1, p2, p5, the MapSolver contains the clause !p1 | !p2 | !p5. For each maximal satisfiable
|
||||||
|
subset, say, represented by predicats p2, p3, p5, the MapSolver contains a clause corresponding
|
||||||
|
to the disjunction of all literals not in the maximal satisfiable subset, p1 | p4 | p6.
|
||||||
|
2. The SubsetSolver contains a set of soft clauses (clauses with the unique indicator atom occurring negated).
|
||||||
|
The MapSolver feeds it a set of clauses (the indicator atoms). Recall that these are not already a superset
|
||||||
|
of an existing minimal unsatisfiable core, or a subset of a maximal satisfying assignment. If asserting
|
||||||
|
these atoms makes the SubsetSolver context infeasible, then it finds a minimal unsatisfiable subset
|
||||||
|
corresponding to these atoms. If asserting the atoms is consistent with the SubsetSolver, then it
|
||||||
|
extends this set of atoms maximally to a satisfying set.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from z3 import *
|
||||||
|
|
||||||
|
def main():
|
||||||
|
x, y = Reals('x y')
|
||||||
|
constraints = [x > 2, x < 1, x < 0, Or(x + y > 0, y < 0), Or(y >= 0, x >= 0), Or(y < 0, x < 0), Or(y > 0, x < 0)]
|
||||||
|
csolver = SubsetSolver(constraints)
|
||||||
|
msolver = MapSolver(n=csolver.n)
|
||||||
|
for orig, lits in enumerate_sets(csolver, msolver):
|
||||||
|
output = "%s %s" % (orig, lits)
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
def get_id(x):
|
||||||
|
return Z3_get_ast_id(x.ctx.ref(),x.as_ast())
|
||||||
|
|
||||||
|
|
||||||
|
class SubsetSolver:
|
||||||
|
constraints = []
|
||||||
|
n = 0
|
||||||
|
s = Solver()
|
||||||
|
varcache = {}
|
||||||
|
idcache = {}
|
||||||
|
|
||||||
|
def __init__(self, constraints):
|
||||||
|
self.constraints = constraints
|
||||||
|
self.n = len(constraints)
|
||||||
|
for i in range(self.n):
|
||||||
|
self.s.add(Implies(self.c_var(i), constraints[i]))
|
||||||
|
|
||||||
|
def c_var(self, i):
|
||||||
|
if i not in self.varcache:
|
||||||
|
v = Bool(str(self.constraints[abs(i)]))
|
||||||
|
self.idcache[get_id(v)] = abs(i)
|
||||||
|
if i >= 0:
|
||||||
|
self.varcache[i] = v
|
||||||
|
else:
|
||||||
|
self.varcache[i] = Not(v)
|
||||||
|
return self.varcache[i]
|
||||||
|
|
||||||
|
def check_subset(self, seed):
|
||||||
|
assumptions = self.to_c_lits(seed)
|
||||||
|
return (self.s.check(assumptions) == sat)
|
||||||
|
|
||||||
|
def to_c_lits(self, seed):
|
||||||
|
return [self.c_var(i) for i in seed]
|
||||||
|
|
||||||
|
def complement(self, aset):
|
||||||
|
return set(range(self.n)).difference(aset)
|
||||||
|
|
||||||
|
def seed_from_core(self):
|
||||||
|
core = self.s.unsat_core()
|
||||||
|
return [self.idcache[get_id(x)] for x in core]
|
||||||
|
|
||||||
|
def shrink(self, seed):
|
||||||
|
current = set(seed)
|
||||||
|
for i in seed:
|
||||||
|
if i not in current:
|
||||||
|
continue
|
||||||
|
current.remove(i)
|
||||||
|
if not self.check_subset(current):
|
||||||
|
current = set(self.seed_from_core())
|
||||||
|
else:
|
||||||
|
current.add(i)
|
||||||
|
return current
|
||||||
|
|
||||||
|
def grow(self, seed):
|
||||||
|
current = seed
|
||||||
|
for i in self.complement(current):
|
||||||
|
current.append(i)
|
||||||
|
if not self.check_subset(current):
|
||||||
|
current.pop()
|
||||||
|
return current
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MapSolver:
|
||||||
|
def __init__(self, n):
|
||||||
|
"""Initialization.
|
||||||
|
Args:
|
||||||
|
n: The number of constraints to map.
|
||||||
|
"""
|
||||||
|
self.solver = Solver()
|
||||||
|
self.n = n
|
||||||
|
self.all_n = set(range(n)) # used in complement fairly frequently
|
||||||
|
|
||||||
|
def next_seed(self):
|
||||||
|
"""Get the seed from the current model, if there is one.
|
||||||
|
Returns:
|
||||||
|
A seed as an array of 0-based constraint indexes.
|
||||||
|
"""
|
||||||
|
if self.solver.check() == unsat:
|
||||||
|
return None
|
||||||
|
seed = self.all_n.copy() # default to all True for "high bias"
|
||||||
|
model = self.solver.model()
|
||||||
|
for x in model:
|
||||||
|
if is_false(model[x]):
|
||||||
|
seed.remove(int(x.name()))
|
||||||
|
return list(seed)
|
||||||
|
|
||||||
|
def complement(self, aset):
|
||||||
|
"""Return the complement of a given set w.r.t. the set of mapped constraints."""
|
||||||
|
return self.all_n.difference(aset)
|
||||||
|
|
||||||
|
def block_down(self, frompoint):
|
||||||
|
"""Block down from a given set."""
|
||||||
|
comp = self.complement(frompoint)
|
||||||
|
self.solver.add( Or( [Bool(str(i)) for i in comp] ) )
|
||||||
|
|
||||||
|
def block_up(self, frompoint):
|
||||||
|
"""Block up from a given set."""
|
||||||
|
self.solver.add( Or( [Not(Bool(str(i))) for i in frompoint] ) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def enumerate_sets(csolver, map):
|
||||||
|
"""Basic MUS/MCS enumeration, as a simple example."""
|
||||||
|
while True:
|
||||||
|
seed = map.next_seed()
|
||||||
|
if seed is None:
|
||||||
|
return
|
||||||
|
if csolver.check_subset(seed):
|
||||||
|
MSS = csolver.grow(seed)
|
||||||
|
yield ("MSS", csolver.to_c_lits(MSS))
|
||||||
|
map.block_down(MSS)
|
||||||
|
else:
|
||||||
|
MUS = csolver.shrink(seed)
|
||||||
|
yield ("MUS", csolver.to_c_lits(MUS))
|
||||||
|
map.block_up(MUS)
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
|
@ -70,6 +70,7 @@ IS_OSX=False
|
||||||
IS_FREEBSD=False
|
IS_FREEBSD=False
|
||||||
IS_OPENBSD=False
|
IS_OPENBSD=False
|
||||||
IS_CYGWIN=False
|
IS_CYGWIN=False
|
||||||
|
IS_CYGWIN_MINGW=False
|
||||||
VERBOSE=True
|
VERBOSE=True
|
||||||
DEBUG_MODE=False
|
DEBUG_MODE=False
|
||||||
SHOW_CPPS = True
|
SHOW_CPPS = True
|
||||||
|
@ -143,6 +144,9 @@ def is_osx():
|
||||||
def is_cygwin():
|
def is_cygwin():
|
||||||
return IS_CYGWIN
|
return IS_CYGWIN
|
||||||
|
|
||||||
|
def is_cygwin_mingw():
|
||||||
|
return IS_CYGWIN_MINGW
|
||||||
|
|
||||||
def norm_path(p):
|
def norm_path(p):
|
||||||
# We use '/' on mk_project for convenience
|
# We use '/' on mk_project for convenience
|
||||||
return os.path.join(*(p.split('/')))
|
return os.path.join(*(p.split('/')))
|
||||||
|
@ -219,7 +223,10 @@ def rmf(fname):
|
||||||
|
|
||||||
def exec_compiler_cmd(cmd):
|
def exec_compiler_cmd(cmd):
|
||||||
r = exec_cmd(cmd)
|
r = exec_cmd(cmd)
|
||||||
rmf('a.out')
|
if is_windows() or is_cygwin_mingw():
|
||||||
|
rmf('a.exe')
|
||||||
|
else:
|
||||||
|
rmf('a.out')
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def test_cxx_compiler(cc):
|
def test_cxx_compiler(cc):
|
||||||
|
@ -597,6 +604,8 @@ elif os.name == 'posix':
|
||||||
IS_OPENBSD=True
|
IS_OPENBSD=True
|
||||||
elif os.uname()[0][:6] == 'CYGWIN':
|
elif os.uname()[0][:6] == 'CYGWIN':
|
||||||
IS_CYGWIN=True
|
IS_CYGWIN=True
|
||||||
|
if (CC != None and "mingw" in CC):
|
||||||
|
IS_CYGWIN_MINGW=True
|
||||||
|
|
||||||
def display_help(exit_code):
|
def display_help(exit_code):
|
||||||
print("mk_make.py: Z3 Makefile generator\n")
|
print("mk_make.py: Z3 Makefile generator\n")
|
||||||
|
@ -1875,12 +1884,15 @@ class MLComponent(Component):
|
||||||
|
|
||||||
|
|
||||||
OCAMLMKLIB = 'ocamlmklib'
|
OCAMLMKLIB = 'ocamlmklib'
|
||||||
|
|
||||||
LIBZ3 = '-L. -lz3'
|
LIBZ3 = '-L. -lz3'
|
||||||
if is_cygwin():
|
if is_cygwin() and not(is_cygwin_mingw()):
|
||||||
# Some ocamlmklib's don't like -g; observed on cygwin, but may be others as well.
|
|
||||||
LIBZ3 = 'libz3.dll'
|
LIBZ3 = 'libz3.dll'
|
||||||
elif DEBUG_MODE:
|
|
||||||
|
if DEBUG_MODE and not(is_cygwin()):
|
||||||
|
# Some ocamlmklib's don't like -g; observed on cygwin, but may be others as well.
|
||||||
OCAMLMKLIB += ' -g'
|
OCAMLMKLIB += ' -g'
|
||||||
|
|
||||||
z3mls = os.path.join(self.sub_dir, 'z3ml')
|
z3mls = os.path.join(self.sub_dir, 'z3ml')
|
||||||
out.write('%s.cma: %s %s %s\n' % (z3mls, cmos, stubso, z3dllso))
|
out.write('%s.cma: %s %s %s\n' % (z3mls, cmos, stubso, z3dllso))
|
||||||
out.write('\t%s -o %s -I %s %s %s %s\n' % (OCAMLMKLIB, z3mls, self.sub_dir, stubso, cmos, LIBZ3))
|
out.write('\t%s -o %s -I %s %s %s %s\n' % (OCAMLMKLIB, z3mls, self.sub_dir, stubso, cmos, LIBZ3))
|
||||||
|
@ -1943,7 +1955,7 @@ class MLComponent(Component):
|
||||||
out.write(' %s' % ((os.path.join(self.sub_dir, 'z3ml.cmxa'))))
|
out.write(' %s' % ((os.path.join(self.sub_dir, 'z3ml.cmxa'))))
|
||||||
out.write(' %s' % ((os.path.join(self.sub_dir, 'z3ml.cmxs'))))
|
out.write(' %s' % ((os.path.join(self.sub_dir, 'z3ml.cmxs'))))
|
||||||
out.write(' %s' % ((os.path.join(self.sub_dir, 'dllz3ml'))))
|
out.write(' %s' % ((os.path.join(self.sub_dir, 'dllz3ml'))))
|
||||||
if IS_WINDOWS:
|
if is_windows() or is_cygwin_mingw():
|
||||||
out.write('.dll')
|
out.write('.dll')
|
||||||
else:
|
else:
|
||||||
out.write('.so') # .so also on OSX!
|
out.write('.so') # .so also on OSX!
|
||||||
|
@ -2382,6 +2394,12 @@ def mk_config():
|
||||||
CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS
|
CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS
|
||||||
if TRACE or DEBUG_MODE:
|
if TRACE or DEBUG_MODE:
|
||||||
CPPFLAGS = '%s -D_TRACE' % CPPFLAGS
|
CPPFLAGS = '%s -D_TRACE' % CPPFLAGS
|
||||||
|
if is_cygwin_mingw():
|
||||||
|
# when cross-compiling with MinGW, we need to statically link its standard libraries
|
||||||
|
# and to make it create an import library.
|
||||||
|
SLIBEXTRAFLAGS = '%s -static-libgcc -static-libstdc++ -Wl,--out-implib,libz3.dll.a' % SLIBEXTRAFLAGS
|
||||||
|
LDFLAGS = '%s -static-libgcc -static-libstdc++' % LDFLAGS
|
||||||
|
|
||||||
config.write('PREFIX=%s\n' % PREFIX)
|
config.write('PREFIX=%s\n' % PREFIX)
|
||||||
config.write('CC=%s\n' % CC)
|
config.write('CC=%s\n' % CC)
|
||||||
config.write('CXX=%s\n' % CXX)
|
config.write('CXX=%s\n' % CXX)
|
||||||
|
@ -2411,6 +2429,8 @@ def mk_config():
|
||||||
print('Host platform: %s' % sysname)
|
print('Host platform: %s' % sysname)
|
||||||
print('C++ Compiler: %s' % CXX)
|
print('C++ Compiler: %s' % CXX)
|
||||||
print('C Compiler : %s' % CC)
|
print('C Compiler : %s' % CC)
|
||||||
|
if is_cygwin_mingw():
|
||||||
|
print('MinGW32 cross: %s' % (is_cygwin_mingw()))
|
||||||
print('Archive Tool: %s' % AR)
|
print('Archive Tool: %s' % AR)
|
||||||
print('Arithmetic: %s' % ARITH)
|
print('Arithmetic: %s' % ARITH)
|
||||||
print('OpenMP: %s' % HAS_OMP)
|
print('OpenMP: %s' % HAS_OMP)
|
||||||
|
|
|
@ -1324,36 +1324,80 @@ def mk_z3native_stubs_c(ml_dir): # C interface
|
||||||
if len(ap) > 0:
|
if len(ap) > 0:
|
||||||
ml_wrapper.write(' unsigned _i;\n')
|
ml_wrapper.write(' unsigned _i;\n')
|
||||||
|
|
||||||
# declare locals, preprocess arrays, strings, in/out arguments
|
# determine if the function has a context as parameter.
|
||||||
have_context = False
|
have_context = (len(params) > 0) and (param_type(params[0]) == CONTEXT)
|
||||||
|
|
||||||
|
if have_context and name not in Unwrapped:
|
||||||
|
ml_wrapper.write(' Z3_error_code ec;\n')
|
||||||
|
|
||||||
|
if result != VOID:
|
||||||
|
ts = type2str(result)
|
||||||
|
if ml_has_plus_type(ts):
|
||||||
|
pts = ml_plus_type(ts)
|
||||||
|
ml_wrapper.write(' %s z3rv_m;\n' % ts)
|
||||||
|
ml_wrapper.write(' %s z3rv;\n' % pts)
|
||||||
|
else:
|
||||||
|
ml_wrapper.write(' %s z3rv;\n' % ts)
|
||||||
|
|
||||||
|
# declare all required local variables
|
||||||
|
# To comply with C89, we need to first declare the variables and initialize them
|
||||||
|
# only afterwards.
|
||||||
i = 0
|
i = 0
|
||||||
for param in params:
|
for param in params:
|
||||||
if param_type(param) == CONTEXT and i == 0:
|
if param_type(param) == CONTEXT and i == 0:
|
||||||
ml_wrapper.write(' Z3_context_plus ctx_p = *(Z3_context_plus*) Data_custom_val(a' + str(i) + ');\n')
|
ml_wrapper.write(' Z3_context_plus ctx_p;\n')
|
||||||
ml_wrapper.write(' Z3_context _a0 = ctx_p->ctx;\n')
|
ml_wrapper.write(' Z3_context _a0;\n')
|
||||||
have_context = True
|
|
||||||
else:
|
else:
|
||||||
k = param_kind(param)
|
k = param_kind(param)
|
||||||
if k == OUT_ARRAY:
|
if k == OUT_ARRAY:
|
||||||
ml_wrapper.write(' %s * _a%s = (%s*) malloc(sizeof(%s) * (_a%s));\n' % (
|
ml_wrapper.write(' %s * _a%s;\n' % (type2str(param_type(param)), i))
|
||||||
type2str(param_type(param)),
|
elif k == OUT_MANAGED_ARRAY:
|
||||||
|
ml_wrapper.write(' %s * _a%s;\n' % (type2str(param_type(param)), i))
|
||||||
|
elif k == IN_ARRAY or k == INOUT_ARRAY:
|
||||||
|
t = param_type(param)
|
||||||
|
ts = type2str(t)
|
||||||
|
ml_wrapper.write(' %s * _a%s;\n' % (ts, i))
|
||||||
|
elif k == IN:
|
||||||
|
t = param_type(param)
|
||||||
|
ml_wrapper.write(' %s _a%s;\n' % (type2str(t), i))
|
||||||
|
elif k == OUT or k == INOUT:
|
||||||
|
t = param_type(param)
|
||||||
|
ml_wrapper.write(' %s _a%s;\n' % (type2str(t), i))
|
||||||
|
ts = type2str(t)
|
||||||
|
if ml_has_plus_type(ts):
|
||||||
|
pts = ml_plus_type(ts)
|
||||||
|
ml_wrapper.write(' %s _a%dp;\n' % (pts, i))
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
|
||||||
|
# End of variable declarations in outermost block:
|
||||||
|
# To comply with C89, no variable declarations may occur in the outermost block
|
||||||
|
# from that point onwards (breaks builds with at least VC 2012 and prior)
|
||||||
|
ml_wrapper.write('\n')
|
||||||
|
|
||||||
|
# Declare locals, preprocess arrays, strings, in/out arguments
|
||||||
|
i = 0
|
||||||
|
for param in params:
|
||||||
|
if param_type(param) == CONTEXT and i == 0:
|
||||||
|
ml_wrapper.write(' ctx_p = *(Z3_context_plus*) Data_custom_val(a' + str(i) + ');\n')
|
||||||
|
ml_wrapper.write(' _a0 = ctx_p->ctx;\n')
|
||||||
|
else:
|
||||||
|
k = param_kind(param)
|
||||||
|
if k == OUT_ARRAY:
|
||||||
|
ml_wrapper.write(' _a%s = (%s*) malloc(sizeof(%s) * (_a%s));\n' % (
|
||||||
i,
|
i,
|
||||||
type2str(param_type(param)),
|
type2str(param_type(param)),
|
||||||
type2str(param_type(param)),
|
type2str(param_type(param)),
|
||||||
param_array_capacity_pos(param)))
|
param_array_capacity_pos(param)))
|
||||||
elif k == OUT_MANAGED_ARRAY:
|
elif k == OUT_MANAGED_ARRAY:
|
||||||
ml_wrapper.write(' %s * _a%s = 0;\n' % (type2str(param_type(param)), i))
|
ml_wrapper.write(' _a%s = 0;\n' % i)
|
||||||
elif k == IN_ARRAY or k == INOUT_ARRAY:
|
elif k == IN_ARRAY or k == INOUT_ARRAY:
|
||||||
t = param_type(param)
|
t = param_type(param)
|
||||||
ts = type2str(t)
|
ts = type2str(t)
|
||||||
ml_wrapper.write(' %s * _a%s = (%s*) malloc(sizeof(%s) * _a%s);\n' % (ts, i, ts, ts, param_array_capacity_pos(param)))
|
ml_wrapper.write(' _a%s = (%s*) malloc(sizeof(%s) * _a%s);\n' % (i, ts, ts, param_array_capacity_pos(param)))
|
||||||
elif k == IN:
|
elif k == IN:
|
||||||
t = param_type(param)
|
t = param_type(param)
|
||||||
ml_wrapper.write(' %s _a%s = %s;\n' % (type2str(t), i, ml_unwrap(t, type2str(t), 'a' + str(i))))
|
ml_wrapper.write(' _a%s = %s;\n' % (i, ml_unwrap(t, type2str(t), 'a' + str(i))))
|
||||||
elif k == OUT:
|
|
||||||
ml_wrapper.write(' %s _a%s;\n' % (type2str(param_type(param)), i))
|
|
||||||
elif k == INOUT:
|
|
||||||
ml_wrapper.write(' %s _a%s = a%s;\n' % (type2str(param_type(param)), i, i))
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -1375,9 +1419,9 @@ def mk_z3native_stubs_c(ml_dir): # C interface
|
||||||
if result != VOID:
|
if result != VOID:
|
||||||
ts = type2str(result)
|
ts = type2str(result)
|
||||||
if ml_has_plus_type(ts):
|
if ml_has_plus_type(ts):
|
||||||
ml_wrapper.write('%s z3rv_m = ' % ts)
|
ml_wrapper.write('z3rv_m = ')
|
||||||
else:
|
else:
|
||||||
ml_wrapper.write('%s z3rv = ' % ts)
|
ml_wrapper.write('z3rv = ')
|
||||||
|
|
||||||
# invoke procedure
|
# invoke procedure
|
||||||
ml_wrapper.write('%s(' % name)
|
ml_wrapper.write('%s(' % name)
|
||||||
|
@ -1397,8 +1441,8 @@ def mk_z3native_stubs_c(ml_dir): # C interface
|
||||||
ml_wrapper.write(');\n')
|
ml_wrapper.write(');\n')
|
||||||
|
|
||||||
if have_context and name not in Unwrapped:
|
if have_context and name not in Unwrapped:
|
||||||
ml_wrapper.write(' int ec = Z3_get_error_code(ctx_p->ctx);\n')
|
ml_wrapper.write(' ec = Z3_get_error_code(ctx_p->ctx);\n')
|
||||||
ml_wrapper.write(' if (ec != 0) {\n')
|
ml_wrapper.write(' if (ec != Z3_OK) {\n')
|
||||||
ml_wrapper.write(' const char * msg = Z3_get_error_msg(ctx_p->ctx, ec);\n')
|
ml_wrapper.write(' const char * msg = Z3_get_error_msg(ctx_p->ctx, ec);\n')
|
||||||
ml_wrapper.write(' caml_raise_with_string(*caml_named_value("Z3EXCEPTION"), msg);\n')
|
ml_wrapper.write(' caml_raise_with_string(*caml_named_value("Z3EXCEPTION"), msg);\n')
|
||||||
ml_wrapper.write(' }\n')
|
ml_wrapper.write(' }\n')
|
||||||
|
@ -1408,9 +1452,9 @@ def mk_z3native_stubs_c(ml_dir): # C interface
|
||||||
if ml_has_plus_type(ts):
|
if ml_has_plus_type(ts):
|
||||||
pts = ml_plus_type(ts)
|
pts = ml_plus_type(ts)
|
||||||
if name in NULLWrapped:
|
if name in NULLWrapped:
|
||||||
ml_wrapper.write(' %s z3rv = %s_mk(z3rv_m);\n' % (pts, pts))
|
ml_wrapper.write(' z3rv = %s_mk(z3rv_m);\n' % pts)
|
||||||
else:
|
else:
|
||||||
ml_wrapper.write(' %s z3rv = %s_mk(ctx_p, (%s) z3rv_m);\n' % (pts, pts, ml_minus_type(ts)))
|
ml_wrapper.write(' z3rv = %s_mk(ctx_p, (%s) z3rv_m);\n' % (pts, ml_minus_type(ts)))
|
||||||
|
|
||||||
# convert output params
|
# convert output params
|
||||||
if len(op) > 0:
|
if len(op) > 0:
|
||||||
|
@ -1450,7 +1494,7 @@ def mk_z3native_stubs_c(ml_dir): # C interface
|
||||||
elif is_out_param(p):
|
elif is_out_param(p):
|
||||||
if ml_has_plus_type(ts):
|
if ml_has_plus_type(ts):
|
||||||
pts = ml_plus_type(ts)
|
pts = ml_plus_type(ts)
|
||||||
ml_wrapper.write(' %s _a%dp = %s_mk(ctx_p, (%s) _a%d);\n' % (pts, i, pts, ml_minus_type(ts), i))
|
ml_wrapper.write(' _a%dp = %s_mk(ctx_p, (%s) _a%d);\n' % (i, pts, ml_minus_type(ts), i))
|
||||||
ml_wrapper.write(' %s\n' % ml_alloc_and_store(pt, '_a%d_val' % i, '_a%dp' % i))
|
ml_wrapper.write(' %s\n' % ml_alloc_and_store(pt, '_a%d_val' % i, '_a%dp' % i))
|
||||||
else:
|
else:
|
||||||
ml_wrapper.write(' %s\n' % ml_alloc_and_store(pt, '_a%d_val' % i, '_a%d' % i))
|
ml_wrapper.write(' %s\n' % ml_alloc_and_store(pt, '_a%d_val' % i, '_a%d' % i))
|
||||||
|
|
|
@ -175,15 +175,8 @@ public class AST extends Z3Object implements Comparable<AST>
|
||||||
* A string representation of the AST.
|
* A string representation of the AST.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.astToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.astToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,34 +187,18 @@ public class AST extends Z3Object implements Comparable<AST>
|
||||||
return Native.astToString(getContext().nCtx(), getNativeObject());
|
return Native.astToString(getContext().nCtx(), getNativeObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
AST(Context ctx)
|
AST(Context ctx, long obj) {
|
||||||
{
|
|
||||||
super(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
AST(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.incRef(getContext().nCtx(), getNativeObject());
|
||||||
// Console.WriteLine("AST IncRef()");
|
|
||||||
if (getContext() == null || o == 0)
|
|
||||||
return;
|
|
||||||
getContext().getASTDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getASTDRQ().storeReference(getContext(), this);
|
||||||
// Console.WriteLine("AST DecRef()");
|
|
||||||
if (getContext() == null || o == 0)
|
|
||||||
return;
|
|
||||||
getContext().getASTDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static AST create(Context ctx, long obj)
|
static AST create(Context ctx, long obj)
|
||||||
|
|
|
@ -17,39 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ASTDecRefQueue extends IDecRefQueue
|
class ASTDecRefQueue extends IDecRefQueue<AST>
|
||||||
{
|
{
|
||||||
public ASTDecRefQueue()
|
public ASTDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.decRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.incRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.decRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,8 +20,7 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Map from AST to AST
|
* Map from AST to AST
|
||||||
**/
|
**/
|
||||||
class ASTMap extends Z3Object
|
class ASTMap extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the map contains the key {@code k}.
|
* Checks whether the map contains the key {@code k}.
|
||||||
* @param k An AST
|
* @param k An AST
|
||||||
|
@ -104,13 +103,7 @@ class ASTMap extends Z3Object
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.astMapToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.astMapToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTMap(Context ctx, long obj)
|
ASTMap(Context ctx, long obj)
|
||||||
|
@ -124,16 +117,12 @@ class ASTMap extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.astMapIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getASTMapDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getASTMapDRQ().storeReference(getContext(), this);
|
||||||
getContext().getASTMapDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Vectors of ASTs.
|
* Vectors of ASTs.
|
||||||
**/
|
**/
|
||||||
public class ASTVector extends Z3Object
|
public class ASTVector extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* The size of the vector
|
* The size of the vector
|
||||||
**/
|
**/
|
||||||
|
@ -88,15 +87,8 @@ public class ASTVector extends Z3Object
|
||||||
* Retrieves a string representation of the vector.
|
* Retrieves a string representation of the vector.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.astVectorToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.astVectorToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTVector(Context ctx, long obj)
|
ASTVector(Context ctx, long obj)
|
||||||
|
@ -110,17 +102,13 @@ public class ASTVector extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.astVectorIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getASTVectorDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getASTVectorDRQ().storeReference(getContext(), this);
|
||||||
getContext().getASTVectorDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,8 +21,7 @@ package com.microsoft.z3;
|
||||||
* ApplyResult objects represent the result of an application of a tactic to a
|
* ApplyResult objects represent the result of an application of a tactic to a
|
||||||
* goal. It contains the subgoals that were produced.
|
* goal. It contains the subgoals that were produced.
|
||||||
**/
|
**/
|
||||||
public class ApplyResult extends Z3Object
|
public class ApplyResult extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* The number of Subgoals.
|
* The number of Subgoals.
|
||||||
**/
|
**/
|
||||||
|
@ -64,15 +63,8 @@ public class ApplyResult extends Z3Object
|
||||||
* A string representation of the ApplyResult.
|
* A string representation of the ApplyResult.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.applyResultToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.applyResultToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyResult(Context ctx, long obj)
|
ApplyResult(Context ctx, long obj)
|
||||||
|
@ -81,16 +73,12 @@ public class ApplyResult extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.applyResultIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getApplyResultDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getApplyResultDRQ().storeReference(getContext(), this);
|
||||||
getContext().getApplyResultDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ApplyResultDecRefQueue extends IDecRefQueue
|
class ApplyResultDecRefQueue extends IDecRefQueue<ApplyResult>
|
||||||
{
|
{
|
||||||
public ApplyResultDecRefQueue()
|
public ApplyResultDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplyResultDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.applyResultDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.applyResultIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.applyResultDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ASTMapDecRefQueue extends IDecRefQueue
|
class ASTMapDecRefQueue extends IDecRefQueue<ASTMap> {
|
||||||
{
|
|
||||||
public ASTMapDecRefQueue()
|
public ASTMapDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTMapDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.astMapDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.astMapIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.astMapDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ASTVectorDecRefQueue extends IDecRefQueue
|
class ASTVectorDecRefQueue extends IDecRefQueue<ASTVector> {
|
||||||
{
|
|
||||||
public ASTVectorDecRefQueue()
|
public ASTVectorDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTVectorDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.astVectorDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.astVectorIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.astVectorDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -66,13 +66,7 @@ public class BitVecNum extends BitVecExpr
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitVecNum(Context ctx, long obj)
|
BitVecNum(Context ctx, long obj)
|
||||||
|
|
|
@ -20,15 +20,7 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Boolean expressions
|
* Boolean expressions
|
||||||
**/
|
**/
|
||||||
public class BoolExpr extends Expr
|
public class BoolExpr extends Expr {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Constructor for BoolExpr
|
|
||||||
**/
|
|
||||||
protected BoolExpr(Context ctx)
|
|
||||||
{
|
|
||||||
super(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for BoolExpr
|
* Constructor for BoolExpr
|
||||||
|
|
|
@ -20,8 +20,14 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Constructors are used for datatype sorts.
|
* Constructors are used for datatype sorts.
|
||||||
**/
|
**/
|
||||||
public class Constructor extends Z3Object
|
public class Constructor extends Z3Object {
|
||||||
{
|
private final int n;
|
||||||
|
|
||||||
|
Constructor(Context ctx, int n, long nativeObj) {
|
||||||
|
super(ctx, nativeObj);
|
||||||
|
this.n = n;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of fields of the constructor.
|
* The number of fields of the constructor.
|
||||||
* @throws Z3Exception
|
* @throws Z3Exception
|
||||||
|
@ -78,29 +84,19 @@ public class Constructor extends Z3Object
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Destructor.
|
void incRef() {
|
||||||
* @throws Throwable
|
// Datatype constructors are not reference counted.
|
||||||
* @throws Z3Exception on error
|
|
||||||
**/
|
|
||||||
protected void finalize() throws Throwable
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
Native.delConstructor(getContext().nCtx(), getNativeObject());
|
|
||||||
} finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int n = 0;
|
@Override
|
||||||
|
void addToReferenceQueue() {
|
||||||
|
getContext().getConstructorDRQ().storeReference(getContext(), this);
|
||||||
|
}
|
||||||
|
|
||||||
Constructor(Context ctx, Symbol name, Symbol recognizer,
|
static Constructor of(Context ctx, Symbol name, Symbol recognizer,
|
||||||
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs) {
|
||||||
|
int n = AST.arrayLength(fieldNames);
|
||||||
{
|
|
||||||
super(ctx);
|
|
||||||
|
|
||||||
n = AST.arrayLength(fieldNames);
|
|
||||||
|
|
||||||
if (n != AST.arrayLength(sorts))
|
if (n != AST.arrayLength(sorts))
|
||||||
throw new Z3Exception(
|
throw new Z3Exception(
|
||||||
|
@ -112,9 +108,10 @@ public class Constructor extends Z3Object
|
||||||
if (sortRefs == null)
|
if (sortRefs == null)
|
||||||
sortRefs = new int[n];
|
sortRefs = new int[n];
|
||||||
|
|
||||||
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
|
long nativeObj = Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
|
||||||
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
|
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
|
||||||
Sort.arrayToNative(sorts), sortRefs));
|
Sort.arrayToNative(sorts), sortRefs);
|
||||||
|
return new Constructor(ctx, n, nativeObj);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/api/java/ConstructorDecRefQueue.java
Normal file
12
src/api/java/ConstructorDecRefQueue.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package com.microsoft.z3;
|
||||||
|
|
||||||
|
public class ConstructorDecRefQueue extends IDecRefQueue<Constructor> {
|
||||||
|
public ConstructorDecRefQueue() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void decRef(Context ctx, long obj) {
|
||||||
|
Native.delConstructor(ctx.nCtx(), obj);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,32 +20,26 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Lists of constructors
|
* Lists of constructors
|
||||||
**/
|
**/
|
||||||
public class ConstructorList extends Z3Object
|
public class ConstructorList extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Destructor.
|
|
||||||
* @throws Throwable
|
|
||||||
* @throws Z3Exception on error
|
|
||||||
**/
|
|
||||||
protected void finalize() throws Throwable
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
Native.delConstructorList(getContext().nCtx(), getNativeObject());
|
|
||||||
} finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstructorList(Context ctx, long obj)
|
ConstructorList(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void incRef() {
|
||||||
|
// Constructor lists are not reference counted.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void addToReferenceQueue() {
|
||||||
|
getContext().getConstructorListDRQ().storeReference(getContext(), this);
|
||||||
|
}
|
||||||
|
|
||||||
ConstructorList(Context ctx, Constructor[] constructors)
|
ConstructorList(Context ctx, Constructor[] constructors)
|
||||||
{
|
{
|
||||||
super(ctx);
|
super(ctx, Native.mkConstructorList(ctx.nCtx(),
|
||||||
|
|
||||||
setNativeObject(Native.mkConstructorList(getContext().nCtx(),
|
|
||||||
constructors.length,
|
constructors.length,
|
||||||
Constructor.arrayToNative(constructors)));
|
Constructor.arrayToNative(constructors)));
|
||||||
}
|
}
|
||||||
|
|
12
src/api/java/ConstructorListDecRefQueue.java
Normal file
12
src/api/java/ConstructorListDecRefQueue.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package com.microsoft.z3;
|
||||||
|
|
||||||
|
public class ConstructorListDecRefQueue extends IDecRefQueue<ConstructorList> {
|
||||||
|
public ConstructorListDecRefQueue() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void decRef(Context ctx, long obj) {
|
||||||
|
Native.delConstructorList(ctx.nCtx(), obj);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,28 +17,30 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
import java.util.Map;
|
import static com.microsoft.z3.Constructor.of;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import com.microsoft.z3.enumerations.Z3_ast_print_mode;
|
import com.microsoft.z3.enumerations.Z3_ast_print_mode;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main interaction with Z3 happens via the Context.
|
* The main interaction with Z3 happens via the Context.
|
||||||
**/
|
**/
|
||||||
public class Context extends IDisposable
|
public class Context implements AutoCloseable {
|
||||||
{
|
private final long m_ctx;
|
||||||
/**
|
static final Object creation_lock = new Object();
|
||||||
* Constructor.
|
|
||||||
**/
|
public Context () {
|
||||||
public Context()
|
m_ctx = Native.mkContextRc(0);
|
||||||
{
|
init();
|
||||||
super();
|
|
||||||
synchronized (creation_lock) {
|
|
||||||
m_ctx = Native.mkContextRc(0);
|
|
||||||
initContext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Context (long m_ctx) {
|
||||||
|
this.m_ctx = m_ctx;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* Remarks:
|
* Remarks:
|
||||||
|
@ -56,17 +58,19 @@ public class Context extends IDisposable
|
||||||
* Note that in previous versions of Z3, this constructor was also used to set global and
|
* Note that in previous versions of Z3, this constructor was also used to set global and
|
||||||
* module parameters. For this purpose we should now use {@code Global.setParameter}
|
* module parameters. For this purpose we should now use {@code Global.setParameter}
|
||||||
**/
|
**/
|
||||||
public Context(Map<String, String> settings)
|
public Context(Map<String, String> settings) {
|
||||||
{
|
long cfg = Native.mkConfig();
|
||||||
super();
|
for (Map.Entry<String, String> kv : settings.entrySet()) {
|
||||||
synchronized (creation_lock) {
|
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
|
||||||
long cfg = Native.mkConfig();
|
|
||||||
for (Map.Entry<String, String> kv : settings.entrySet())
|
|
||||||
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
|
|
||||||
m_ctx = Native.mkContextRc(cfg);
|
|
||||||
Native.delConfig(cfg);
|
|
||||||
initContext();
|
|
||||||
}
|
}
|
||||||
|
m_ctx = Native.mkContextRc(cfg);
|
||||||
|
Native.delConfig(cfg);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT);
|
||||||
|
Native.setInternalErrorHandler(m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,7 +246,7 @@ public class Context extends IDisposable
|
||||||
checkContextMatch(name);
|
checkContextMatch(name);
|
||||||
checkContextMatch(fieldNames);
|
checkContextMatch(fieldNames);
|
||||||
checkContextMatch(fieldSorts);
|
checkContextMatch(fieldSorts);
|
||||||
return new TupleSort(this, name, (int) fieldNames.length, fieldNames,
|
return new TupleSort(this, name, fieldNames.length, fieldNames,
|
||||||
fieldSorts);
|
fieldSorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,8 +323,7 @@ public class Context extends IDisposable
|
||||||
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
return of(this, name, recognizer, fieldNames, sorts,
|
||||||
return new Constructor(this, name, recognizer, fieldNames, sorts,
|
|
||||||
sortRefs);
|
sortRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,10 +332,8 @@ public class Context extends IDisposable
|
||||||
**/
|
**/
|
||||||
public Constructor mkConstructor(String name, String recognizer,
|
public Constructor mkConstructor(String name, String recognizer,
|
||||||
String[] fieldNames, Sort[] sorts, int[] sortRefs)
|
String[] fieldNames, Sort[] sorts, int[] sortRefs)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
return of(this, mkSymbol(name), mkSymbol(recognizer),
|
||||||
return new Constructor(this, mkSymbol(name), mkSymbol(recognizer),
|
|
||||||
mkSymbols(fieldNames), sorts, sortRefs);
|
mkSymbols(fieldNames), sorts, sortRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +526,7 @@ public class Context extends IDisposable
|
||||||
throw new Z3Exception("Cannot create a pattern from zero terms");
|
throw new Z3Exception("Cannot create a pattern from zero terms");
|
||||||
|
|
||||||
long[] termsNative = AST.arrayToNative(terms);
|
long[] termsNative = AST.arrayToNative(terms);
|
||||||
return new Pattern(this, Native.mkPattern(nCtx(), (int) terms.length,
|
return new Pattern(this, Native.mkPattern(nCtx(), terms.length,
|
||||||
termsNative));
|
termsNative));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +689,7 @@ public class Context extends IDisposable
|
||||||
public BoolExpr mkDistinct(Expr... args)
|
public BoolExpr mkDistinct(Expr... args)
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return new BoolExpr(this, Native.mkDistinct(nCtx(), (int) args.length,
|
return new BoolExpr(this, Native.mkDistinct(nCtx(), args.length,
|
||||||
AST.arrayToNative(args)));
|
AST.arrayToNative(args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +757,7 @@ public class Context extends IDisposable
|
||||||
public BoolExpr mkAnd(BoolExpr... t)
|
public BoolExpr mkAnd(BoolExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return new BoolExpr(this, Native.mkAnd(nCtx(), (int) t.length,
|
return new BoolExpr(this, Native.mkAnd(nCtx(), t.length,
|
||||||
AST.arrayToNative(t)));
|
AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,7 +767,7 @@ public class Context extends IDisposable
|
||||||
public BoolExpr mkOr(BoolExpr... t)
|
public BoolExpr mkOr(BoolExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return new BoolExpr(this, Native.mkOr(nCtx(), (int) t.length,
|
return new BoolExpr(this, Native.mkOr(nCtx(), t.length,
|
||||||
AST.arrayToNative(t)));
|
AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,7 +778,7 @@ public class Context extends IDisposable
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ArithExpr) Expr.create(this,
|
return (ArithExpr) Expr.create(this,
|
||||||
Native.mkAdd(nCtx(), (int) t.length, AST.arrayToNative(t)));
|
Native.mkAdd(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -787,7 +788,7 @@ public class Context extends IDisposable
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ArithExpr) Expr.create(this,
|
return (ArithExpr) Expr.create(this,
|
||||||
Native.mkMul(nCtx(), (int) t.length, AST.arrayToNative(t)));
|
Native.mkMul(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -797,7 +798,7 @@ public class Context extends IDisposable
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return (ArithExpr) Expr.create(this,
|
return (ArithExpr) Expr.create(this,
|
||||||
Native.mkSub(nCtx(), (int) t.length, AST.arrayToNative(t)));
|
Native.mkSub(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1814,7 +1815,7 @@ public class Context extends IDisposable
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (ArrayExpr)Expr.create(this,
|
return (ArrayExpr)Expr.create(this,
|
||||||
Native.mkSetUnion(nCtx(), (int) args.length,
|
Native.mkSetUnion(nCtx(), args.length,
|
||||||
AST.arrayToNative(args)));
|
AST.arrayToNative(args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,7 +1826,7 @@ public class Context extends IDisposable
|
||||||
{
|
{
|
||||||
checkContextMatch(args);
|
checkContextMatch(args);
|
||||||
return (ArrayExpr)Expr.create(this,
|
return (ArrayExpr)Expr.create(this,
|
||||||
Native.mkSetIntersect(nCtx(), (int) args.length,
|
Native.mkSetIntersect(nCtx(), args.length,
|
||||||
AST.arrayToNative(args)));
|
AST.arrayToNative(args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1912,7 +1913,7 @@ public class Context extends IDisposable
|
||||||
public SeqExpr MkConcat(SeqExpr... t)
|
public SeqExpr MkConcat(SeqExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return new SeqExpr(this, Native.mkSeqConcat(nCtx(), (int)t.length, AST.arrayToNative(t)));
|
return new SeqExpr(this, Native.mkSeqConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2040,7 +2041,7 @@ public class Context extends IDisposable
|
||||||
public ReExpr MkConcat(ReExpr... t)
|
public ReExpr MkConcat(ReExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return new ReExpr(this, Native.mkReConcat(nCtx(), (int)t.length, AST.arrayToNative(t)));
|
return new ReExpr(this, Native.mkReConcat(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2049,7 +2050,7 @@ public class Context extends IDisposable
|
||||||
public ReExpr MkUnion(ReExpr... t)
|
public ReExpr MkUnion(ReExpr... t)
|
||||||
{
|
{
|
||||||
checkContextMatch(t);
|
checkContextMatch(t);
|
||||||
return new ReExpr(this, Native.mkReUnion(nCtx(), (int)t.length, AST.arrayToNative(t)));
|
return new ReExpr(this, Native.mkReUnion(nCtx(), t.length, AST.arrayToNative(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2258,7 +2259,7 @@ public class Context extends IDisposable
|
||||||
Symbol quantifierID, Symbol skolemID)
|
Symbol quantifierID, Symbol skolemID)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Quantifier(this, true, sorts, names, body, weight, patterns,
|
return Quantifier.of(this, true, sorts, names, body, weight, patterns,
|
||||||
noPatterns, quantifierID, skolemID);
|
noPatterns, quantifierID, skolemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2271,7 +2272,7 @@ public class Context extends IDisposable
|
||||||
Symbol skolemID)
|
Symbol skolemID)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Quantifier(this, true, boundConstants, body, weight,
|
return Quantifier.of(this, true, boundConstants, body, weight,
|
||||||
patterns, noPatterns, quantifierID, skolemID);
|
patterns, noPatterns, quantifierID, skolemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2284,7 +2285,7 @@ public class Context extends IDisposable
|
||||||
Symbol quantifierID, Symbol skolemID)
|
Symbol quantifierID, Symbol skolemID)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Quantifier(this, false, sorts, names, body, weight,
|
return Quantifier.of(this, false, sorts, names, body, weight,
|
||||||
patterns, noPatterns, quantifierID, skolemID);
|
patterns, noPatterns, quantifierID, skolemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2297,7 +2298,7 @@ public class Context extends IDisposable
|
||||||
Symbol skolemID)
|
Symbol skolemID)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Quantifier(this, false, boundConstants, body, weight,
|
return Quantifier.of(this, false, boundConstants, body, weight,
|
||||||
patterns, noPatterns, quantifierID, skolemID);
|
patterns, noPatterns, quantifierID, skolemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3814,7 +3815,7 @@ public class Context extends IDisposable
|
||||||
* must be a native object obtained from Z3 (e.g., through
|
* must be a native object obtained from Z3 (e.g., through
|
||||||
* {@code UnwrapAST}) and that it must have a correct reference count.
|
* {@code UnwrapAST}) and that it must have a correct reference count.
|
||||||
* @see Native#incRef
|
* @see Native#incRef
|
||||||
* @see unwrapAST
|
* @see #unwrapAST
|
||||||
* @param nativeObject The native pointer to wrap.
|
* @param nativeObject The native pointer to wrap.
|
||||||
**/
|
**/
|
||||||
public AST wrapAST(long nativeObject)
|
public AST wrapAST(long nativeObject)
|
||||||
|
@ -3869,19 +3870,12 @@ public class Context extends IDisposable
|
||||||
Native.updateParamValue(nCtx(), id, value);
|
Native.updateParamValue(nCtx(), id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long m_ctx = 0;
|
|
||||||
protected static final Object creation_lock = new Object();
|
|
||||||
|
|
||||||
long nCtx()
|
long nCtx()
|
||||||
{
|
{
|
||||||
return m_ctx;
|
return m_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initContext()
|
|
||||||
{
|
|
||||||
setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT);
|
|
||||||
Native.setInternalErrorHandler(nCtx());
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkContextMatch(Z3Object other)
|
void checkContextMatch(Z3Object other)
|
||||||
{
|
{
|
||||||
|
@ -3910,125 +3904,118 @@ public class Context extends IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
private ASTDecRefQueue m_AST_DRQ = new ASTDecRefQueue();
|
private ASTDecRefQueue m_AST_DRQ = new ASTDecRefQueue();
|
||||||
private ASTMapDecRefQueue m_ASTMap_DRQ = new ASTMapDecRefQueue(10);
|
private ASTMapDecRefQueue m_ASTMap_DRQ = new ASTMapDecRefQueue();
|
||||||
private ASTVectorDecRefQueue m_ASTVector_DRQ = new ASTVectorDecRefQueue(10);
|
private ASTVectorDecRefQueue m_ASTVector_DRQ = new ASTVectorDecRefQueue();
|
||||||
private ApplyResultDecRefQueue m_ApplyResult_DRQ = new ApplyResultDecRefQueue(10);
|
private ApplyResultDecRefQueue m_ApplyResult_DRQ = new ApplyResultDecRefQueue();
|
||||||
private FuncInterpEntryDecRefQueue m_FuncEntry_DRQ = new FuncInterpEntryDecRefQueue(10);
|
private FuncInterpEntryDecRefQueue m_FuncEntry_DRQ = new FuncInterpEntryDecRefQueue();
|
||||||
private FuncInterpDecRefQueue m_FuncInterp_DRQ = new FuncInterpDecRefQueue(10);
|
private FuncInterpDecRefQueue m_FuncInterp_DRQ = new FuncInterpDecRefQueue();
|
||||||
private GoalDecRefQueue m_Goal_DRQ = new GoalDecRefQueue(10);
|
private GoalDecRefQueue m_Goal_DRQ = new GoalDecRefQueue();
|
||||||
private ModelDecRefQueue m_Model_DRQ = new ModelDecRefQueue(10);
|
private ModelDecRefQueue m_Model_DRQ = new ModelDecRefQueue();
|
||||||
private ParamsDecRefQueue m_Params_DRQ = new ParamsDecRefQueue(10);
|
private ParamsDecRefQueue m_Params_DRQ = new ParamsDecRefQueue();
|
||||||
private ParamDescrsDecRefQueue m_ParamDescrs_DRQ = new ParamDescrsDecRefQueue(10);
|
private ParamDescrsDecRefQueue m_ParamDescrs_DRQ = new ParamDescrsDecRefQueue();
|
||||||
private ProbeDecRefQueue m_Probe_DRQ = new ProbeDecRefQueue(10);
|
private ProbeDecRefQueue m_Probe_DRQ = new ProbeDecRefQueue();
|
||||||
private SolverDecRefQueue m_Solver_DRQ = new SolverDecRefQueue(10);
|
private SolverDecRefQueue m_Solver_DRQ = new SolverDecRefQueue();
|
||||||
private StatisticsDecRefQueue m_Statistics_DRQ = new StatisticsDecRefQueue(10);
|
private StatisticsDecRefQueue m_Statistics_DRQ = new StatisticsDecRefQueue();
|
||||||
private TacticDecRefQueue m_Tactic_DRQ = new TacticDecRefQueue(10);
|
private TacticDecRefQueue m_Tactic_DRQ = new TacticDecRefQueue();
|
||||||
private FixedpointDecRefQueue m_Fixedpoint_DRQ = new FixedpointDecRefQueue(10);
|
private FixedpointDecRefQueue m_Fixedpoint_DRQ = new FixedpointDecRefQueue();
|
||||||
private OptimizeDecRefQueue m_Optimize_DRQ = new OptimizeDecRefQueue(10);
|
private OptimizeDecRefQueue m_Optimize_DRQ = new OptimizeDecRefQueue();
|
||||||
|
private ConstructorDecRefQueue m_Constructor_DRQ = new ConstructorDecRefQueue();
|
||||||
|
private ConstructorListDecRefQueue m_ConstructorList_DRQ =
|
||||||
|
new ConstructorListDecRefQueue();
|
||||||
|
|
||||||
public IDecRefQueue getASTDRQ()
|
public IDecRefQueue<Constructor> getConstructorDRQ() {
|
||||||
|
return m_Constructor_DRQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDecRefQueue<ConstructorList> getConstructorListDRQ() {
|
||||||
|
return m_ConstructorList_DRQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDecRefQueue<AST> getASTDRQ()
|
||||||
{
|
{
|
||||||
return m_AST_DRQ;
|
return m_AST_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getASTMapDRQ()
|
public IDecRefQueue<ASTMap> getASTMapDRQ()
|
||||||
{
|
{
|
||||||
return m_ASTMap_DRQ;
|
return m_ASTMap_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getASTVectorDRQ()
|
public IDecRefQueue<ASTVector> getASTVectorDRQ()
|
||||||
{
|
{
|
||||||
return m_ASTVector_DRQ;
|
return m_ASTVector_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getApplyResultDRQ()
|
public IDecRefQueue<ApplyResult> getApplyResultDRQ()
|
||||||
{
|
{
|
||||||
return m_ApplyResult_DRQ;
|
return m_ApplyResult_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getFuncEntryDRQ()
|
public IDecRefQueue<FuncInterp.Entry> getFuncEntryDRQ()
|
||||||
{
|
{
|
||||||
return m_FuncEntry_DRQ;
|
return m_FuncEntry_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getFuncInterpDRQ()
|
public IDecRefQueue<FuncInterp> getFuncInterpDRQ()
|
||||||
{
|
{
|
||||||
return m_FuncInterp_DRQ;
|
return m_FuncInterp_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getGoalDRQ()
|
public IDecRefQueue<Goal> getGoalDRQ()
|
||||||
{
|
{
|
||||||
return m_Goal_DRQ;
|
return m_Goal_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getModelDRQ()
|
public IDecRefQueue<Model> getModelDRQ()
|
||||||
{
|
{
|
||||||
return m_Model_DRQ;
|
return m_Model_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getParamsDRQ()
|
public IDecRefQueue<Params> getParamsDRQ()
|
||||||
{
|
{
|
||||||
return m_Params_DRQ;
|
return m_Params_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getParamDescrsDRQ()
|
public IDecRefQueue<ParamDescrs> getParamDescrsDRQ()
|
||||||
{
|
{
|
||||||
return m_ParamDescrs_DRQ;
|
return m_ParamDescrs_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getProbeDRQ()
|
public IDecRefQueue<Probe> getProbeDRQ()
|
||||||
{
|
{
|
||||||
return m_Probe_DRQ;
|
return m_Probe_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getSolverDRQ()
|
public IDecRefQueue<Solver> getSolverDRQ()
|
||||||
{
|
{
|
||||||
return m_Solver_DRQ;
|
return m_Solver_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getStatisticsDRQ()
|
public IDecRefQueue<Statistics> getStatisticsDRQ()
|
||||||
{
|
{
|
||||||
return m_Statistics_DRQ;
|
return m_Statistics_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getTacticDRQ()
|
public IDecRefQueue<Tactic> getTacticDRQ()
|
||||||
{
|
{
|
||||||
return m_Tactic_DRQ;
|
return m_Tactic_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getFixedpointDRQ()
|
public IDecRefQueue<Fixedpoint> getFixedpointDRQ()
|
||||||
{
|
{
|
||||||
return m_Fixedpoint_DRQ;
|
return m_Fixedpoint_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDecRefQueue getOptimizeDRQ()
|
public IDecRefQueue<Optimize> getOptimizeDRQ()
|
||||||
{
|
{
|
||||||
return m_Optimize_DRQ;
|
return m_Optimize_DRQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AtomicInteger m_refCount = new AtomicInteger(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalizer.
|
|
||||||
* @throws Throwable
|
|
||||||
**/
|
|
||||||
protected void finalize() throws Throwable
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
catch (Throwable t) {
|
|
||||||
throw t;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposes of the context.
|
* Disposes of the context.
|
||||||
**/
|
**/
|
||||||
public void dispose()
|
@Override
|
||||||
|
public void close()
|
||||||
{
|
{
|
||||||
m_AST_DRQ.clear(this);
|
m_AST_DRQ.clear(this);
|
||||||
m_ASTMap_DRQ.clear(this);
|
m_ASTMap_DRQ.clear(this);
|
||||||
|
@ -4051,16 +4038,6 @@ public class Context extends IDisposable
|
||||||
m_realSort = null;
|
m_realSort = null;
|
||||||
m_stringSort = null;
|
m_stringSort = null;
|
||||||
|
|
||||||
synchronized (creation_lock) {
|
Native.delContext(m_ctx);
|
||||||
if (m_refCount.get() == 0 && m_ctx != 0) {
|
|
||||||
try {
|
|
||||||
Native.delContext(m_ctx);
|
|
||||||
} catch (Z3Exception e) {
|
|
||||||
// OK?
|
|
||||||
System.out.println("Context deletion failed; memory leak possible.");
|
|
||||||
}
|
|
||||||
m_ctx = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,13 +92,9 @@ public class EnumSort extends Sort
|
||||||
|
|
||||||
EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
||||||
{
|
{
|
||||||
super(ctx, 0);
|
super(ctx, Native.mkEnumerationSort(ctx.nCtx(),
|
||||||
|
name.getNativeObject(), enumNames.length,
|
||||||
int n = enumNames.length;
|
Symbol.arrayToNative(enumNames),
|
||||||
long[] n_constdecls = new long[n];
|
new long[enumNames.length], new long[enumNames.length]));
|
||||||
long[] n_testers = new long[n];
|
|
||||||
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
|
|
||||||
name.getNativeObject(), n, Symbol.arrayToNative(enumNames),
|
|
||||||
n_constdecls, n_testers));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,13 +120,13 @@ public class Expr extends AST
|
||||||
* @param args arguments
|
* @param args arguments
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public void update(Expr[] args)
|
public Expr update(Expr[] args)
|
||||||
{
|
{
|
||||||
getContext().checkContextMatch(args);
|
getContext().checkContextMatch(args);
|
||||||
if (isApp() && args.length != getNumArgs()) {
|
if (isApp() && args.length != getNumArgs()) {
|
||||||
throw new Z3Exception("Number of arguments does not match");
|
throw new Z3Exception("Number of arguments does not match");
|
||||||
}
|
}
|
||||||
setNativeObject(Native.updateTerm(getContext().nCtx(), getNativeObject(),
|
return new Expr(getContext(), Native.updateTerm(getContext().nCtx(), getNativeObject(),
|
||||||
args.length, Expr.arrayToNative(args)));
|
args.length, Expr.arrayToNative(args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2091,36 +2091,23 @@ public class Expr extends AST
|
||||||
**/
|
**/
|
||||||
public int getIndex()
|
public int getIndex()
|
||||||
{
|
{
|
||||||
if (!isVar())
|
if (!isVar()) {
|
||||||
throw new Z3Exception("Term is not a bound variable.");
|
throw new Z3Exception("Term is not a bound variable.");
|
||||||
|
}
|
||||||
|
|
||||||
return Native.getIndexValue(getContext().nCtx(), getNativeObject());
|
return Native.getIndexValue(getContext().nCtx(), getNativeObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for Expr
|
|
||||||
**/
|
|
||||||
protected Expr(Context ctx)
|
|
||||||
{
|
|
||||||
super(ctx);
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Expr
|
* Constructor for Expr
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
protected Expr(Context ctx, long obj)
|
protected Expr(Context ctx, long obj) {
|
||||||
{
|
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void checkNativeObject(long obj)
|
void checkNativeObject(long obj) {
|
||||||
{
|
|
||||||
if (!Native.isApp(getContext().nCtx(), obj) &&
|
if (!Native.isApp(getContext().nCtx(), obj) &&
|
||||||
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() &&
|
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_VAR_AST.toInt() &&
|
||||||
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) {
|
Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST.toInt()) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class FPNum extends FPExpr
|
||||||
*/
|
*/
|
||||||
public boolean getSign() {
|
public boolean getSign() {
|
||||||
Native.IntPtr res = new Native.IntPtr();
|
Native.IntPtr res = new Native.IntPtr();
|
||||||
if (Native.fpaGetNumeralSign(getContext().nCtx(), getNativeObject(), res) ^ true)
|
if (!Native.fpaGetNumeralSign(getContext().nCtx(), getNativeObject(), res))
|
||||||
throw new Z3Exception("Sign is not a Boolean value");
|
throw new Z3Exception("Sign is not a Boolean value");
|
||||||
return res.value != 0;
|
return res.value != 0;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class FPNum extends FPExpr
|
||||||
public long getSignificandUInt64()
|
public long getSignificandUInt64()
|
||||||
{
|
{
|
||||||
Native.LongPtr res = new Native.LongPtr();
|
Native.LongPtr res = new Native.LongPtr();
|
||||||
if (Native.fpaGetNumeralSignificandUint64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
if (!Native.fpaGetNumeralSignificandUint64(getContext().nCtx(), getNativeObject(), res))
|
||||||
throw new Z3Exception("Significand is not a 64 bit unsigned integer");
|
throw new Z3Exception("Significand is not a 64 bit unsigned integer");
|
||||||
return res.value;
|
return res.value;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class FPNum extends FPExpr
|
||||||
*/
|
*/
|
||||||
public long getExponentInt64() {
|
public long getExponentInt64() {
|
||||||
Native.LongPtr res = new Native.LongPtr();
|
Native.LongPtr res = new Native.LongPtr();
|
||||||
if (Native.fpaGetNumeralExponentInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
if (!Native.fpaGetNumeralExponentInt64(getContext().nCtx(), getNativeObject(), res))
|
||||||
throw new Z3Exception("Exponent is not a 64 bit integer");
|
throw new Z3Exception("Exponent is not a 64 bit integer");
|
||||||
return res.value;
|
return res.value;
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,7 @@ public class FPNum extends FPExpr
|
||||||
*/
|
*/
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,6 @@ public class FiniteDomainNum extends FiniteDomainExpr
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,14 +255,8 @@ public class Fixedpoint extends Z3Object
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
|
||||||
{
|
|
||||||
return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
|
|
||||||
0, null);
|
0, null);
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -355,16 +349,15 @@ public class Fixedpoint extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.fixedpointIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getFixedpointDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getFixedpointDRQ().storeReference(getContext(), this);
|
||||||
getContext().getFixedpointDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void checkNativeObject(long obj) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class FixedpointDecRefQueue extends IDecRefQueue
|
class FixedpointDecRefQueue extends IDecRefQueue<Fixedpoint> {
|
||||||
{
|
|
||||||
public FixedpointDecRefQueue()
|
public FixedpointDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedpointDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void incRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.fixedpointIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
try
|
Native.fixedpointDecRef(ctx.nCtx(), obj);
|
||||||
{
|
|
||||||
Native.fixedpointDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,13 +47,7 @@ public class FuncDecl extends AST
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.funcDeclToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.funcDeclToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,20 +22,20 @@ package com.microsoft.z3;
|
||||||
* Each entry in the finite map represents the value of a function given a set
|
* Each entry in the finite map represents the value of a function given a set
|
||||||
* of arguments.
|
* of arguments.
|
||||||
**/
|
**/
|
||||||
public class FuncInterp extends Z3Object
|
public class FuncInterp extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* An Entry object represents an element in the finite map used to encode a
|
* An Entry object represents an element in the finite map used to encode a
|
||||||
* function interpretation.
|
* function interpretation.
|
||||||
**/
|
**/
|
||||||
public class Entry extends Z3Object
|
public static class Entry extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Return the (symbolic) value of this entry.
|
* Return the (symbolic) value of this entry.
|
||||||
*
|
*
|
||||||
* @throws Z3Exception
|
* @throws Z3Exception
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public Expr getValue()
|
public Expr getValue()
|
||||||
{
|
{
|
||||||
return Expr.create(getContext(),
|
return Expr.create(getContext(),
|
||||||
|
@ -45,7 +45,7 @@ public class FuncInterp extends Z3Object
|
||||||
/**
|
/**
|
||||||
* The number of arguments of the entry.
|
* The number of arguments of the entry.
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public int getNumArgs()
|
public int getNumArgs()
|
||||||
{
|
{
|
||||||
return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
|
return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
|
||||||
|
@ -56,7 +56,7 @@ public class FuncInterp extends Z3Object
|
||||||
*
|
*
|
||||||
* @throws Z3Exception
|
* @throws Z3Exception
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
**/
|
**/
|
||||||
public Expr[] getArgs()
|
public Expr[] getArgs()
|
||||||
{
|
{
|
||||||
int n = getNumArgs();
|
int n = getNumArgs();
|
||||||
|
@ -73,37 +73,26 @@ public class FuncInterp extends Z3Object
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
int n = getNumArgs();
|
||||||
{
|
String res = "[";
|
||||||
int n = getNumArgs();
|
Expr[] args = getArgs();
|
||||||
String res = "[";
|
for (int i = 0; i < n; i++)
|
||||||
Expr[] args = getArgs();
|
res += args[i] + ", ";
|
||||||
for (int i = 0; i < n; i++)
|
return res + getValue() + "]";
|
||||||
res += args[i] + ", ";
|
|
||||||
return res + getValue() + "]";
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry(Context ctx, long obj)
|
Entry(Context ctx, long obj) {
|
||||||
{
|
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.funcEntryIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getFuncEntryDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getFuncEntryDRQ().storeReference(getContext(), this);
|
||||||
getContext().getFuncEntryDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,33 +150,27 @@ public class FuncInterp extends Z3Object
|
||||||
**/
|
**/
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
String res = "";
|
||||||
|
res += "[";
|
||||||
|
for (Entry e : getEntries())
|
||||||
{
|
{
|
||||||
String res = "";
|
int n = e.getNumArgs();
|
||||||
res += "[";
|
if (n > 1)
|
||||||
for (Entry e : getEntries())
|
res += "[";
|
||||||
|
Expr[] args = e.getArgs();
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
int n = e.getNumArgs();
|
if (i != 0)
|
||||||
if (n > 1)
|
res += ", ";
|
||||||
res += "[";
|
res += args[i];
|
||||||
Expr[] args = e.getArgs();
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
if (i != 0)
|
|
||||||
res += ", ";
|
|
||||||
res += args[i];
|
|
||||||
}
|
|
||||||
if (n > 1)
|
|
||||||
res += "]";
|
|
||||||
res += " -> " + e.getValue() + ", ";
|
|
||||||
}
|
}
|
||||||
res += "else -> " + getElse();
|
if (n > 1)
|
||||||
res += "]";
|
res += "]";
|
||||||
return res;
|
res += " -> " + e.getValue() + ", ";
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
}
|
||||||
|
res += "else -> " + getElse();
|
||||||
|
res += "]";
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncInterp(Context ctx, long obj)
|
FuncInterp(Context ctx, long obj)
|
||||||
|
@ -196,16 +179,12 @@ public class FuncInterp extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.funcInterpIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getFuncInterpDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getFuncInterpDRQ().storeReference(getContext(), this);
|
||||||
getContext().getFuncInterpDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class FuncInterpDecRefQueue extends IDecRefQueue
|
class FuncInterpDecRefQueue extends IDecRefQueue<FuncInterp>
|
||||||
{
|
{
|
||||||
public FuncInterpDecRefQueue()
|
public FuncInterpDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FuncInterpDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.funcInterpDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.funcInterpIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.funcInterpDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class FuncInterpEntryDecRefQueue extends IDecRefQueue
|
class FuncInterpEntryDecRefQueue extends IDecRefQueue<FuncInterp.Entry> {
|
||||||
{
|
|
||||||
public FuncInterpEntryDecRefQueue()
|
public FuncInterpEntryDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FuncInterpEntryDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.funcEntryDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.funcEntryIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.funcEntryDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -23,8 +23,7 @@ import com.microsoft.z3.enumerations.Z3_goal_prec;
|
||||||
* A goal (aka problem). A goal is essentially a set of formulas, that can be
|
* A goal (aka problem). A goal is essentially a set of formulas, that can be
|
||||||
* solved and/or transformed using tactics and solvers.
|
* solved and/or transformed using tactics and solvers.
|
||||||
**/
|
**/
|
||||||
public class Goal extends Z3Object
|
public class Goal extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* The precision of the goal.
|
* The precision of the goal.
|
||||||
* Remarks: Goals can be transformed using over
|
* Remarks: Goals can be transformed using over
|
||||||
|
@ -211,15 +210,8 @@ 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() {
|
||||||
{
|
return Native.goalToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.goalToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,11 +221,11 @@ public class Goal extends Z3Object
|
||||||
**/
|
**/
|
||||||
public BoolExpr AsBoolExpr() {
|
public BoolExpr AsBoolExpr() {
|
||||||
int n = size();
|
int n = size();
|
||||||
if (n == 0)
|
if (n == 0) {
|
||||||
return getContext().mkTrue();
|
return getContext().mkTrue();
|
||||||
else if (n == 1)
|
} else if (n == 1) {
|
||||||
return getFormulas()[0];
|
return getFormulas()[0];
|
||||||
else {
|
} else {
|
||||||
return getContext().mkAnd(getFormulas());
|
return getContext().mkAnd(getFormulas());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,23 +235,18 @@ public class Goal extends Z3Object
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs)
|
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) {
|
||||||
|
|
||||||
{
|
|
||||||
super(ctx, Native.mkGoal(ctx.nCtx(), (models),
|
super(ctx, Native.mkGoal(ctx.nCtx(), (models),
|
||||||
(unsatCores), (proofs)));
|
(unsatCores), (proofs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void incRef(long o)
|
@Override
|
||||||
{
|
void incRef() {
|
||||||
getContext().getGoalDRQ().incAndClear(getContext(), o);
|
Native.goalIncRef(getContext().nCtx(), getNativeObject());
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decRef(long o)
|
@Override
|
||||||
{
|
void addToReferenceQueue() {
|
||||||
getContext().getGoalDRQ().add(o);
|
getContext().getGoalDRQ().storeReference(getContext(), this);
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class GoalDecRefQueue extends IDecRefQueue
|
class GoalDecRefQueue extends IDecRefQueue<Goal> {
|
||||||
{
|
|
||||||
public GoalDecRefQueue()
|
public GoalDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoalDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.goalIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.goalDecRef(ctx.nCtx(), obj);
|
Native.goalDecRef(ctx.nCtx(), obj);
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -17,55 +17,54 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.lang.ref.PhantomReference;
|
||||||
|
import java.lang.ref.Reference;
|
||||||
|
import java.lang.ref.ReferenceQueue;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class IDecRefQueue
|
/**
|
||||||
{
|
* A queue to handle management of native memory.
|
||||||
protected final Object m_lock = new Object();
|
*
|
||||||
protected LinkedList<Long> m_queue = new LinkedList<Long>();
|
* <p><b>Mechanics: </b>once an object is created, a metadata is stored for it in
|
||||||
protected int m_move_limit;
|
* {@code referenceMap}, and a {@link PhantomReference} is created with a
|
||||||
|
* reference to {@code referenceQueue}.
|
||||||
|
* Once the object becomes strongly unreachable, the phantom reference gets
|
||||||
|
* added by JVM to the {@code referenceQueue}.
|
||||||
|
* After each object creation, we iterate through the available objects in
|
||||||
|
* {@code referenceQueue} and decrement references for them.
|
||||||
|
*
|
||||||
|
* @param <T> Type of object stored in queue.
|
||||||
|
*/
|
||||||
|
public abstract class IDecRefQueue<T extends Z3Object> {
|
||||||
|
private final ReferenceQueue<T> referenceQueue = new ReferenceQueue<>();
|
||||||
|
private final Map<PhantomReference<T>, Long> referenceMap =
|
||||||
|
new IdentityHashMap<>();
|
||||||
|
|
||||||
protected IDecRefQueue()
|
protected IDecRefQueue() {}
|
||||||
{
|
|
||||||
m_move_limit = 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
m_move_limit = move_limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLimit(int l) { m_move_limit = l; }
|
|
||||||
|
|
||||||
protected abstract void incRef(Context ctx, long obj);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of this method should decrement the reference on a
|
||||||
|
* given native object.
|
||||||
|
* This function should always be called on the {@code ctx} thread.
|
||||||
|
*
|
||||||
|
* @param ctx Z3 context.
|
||||||
|
* @param obj Pointer to a Z3 object.
|
||||||
|
*/
|
||||||
protected abstract void decRef(Context ctx, long obj);
|
protected abstract void decRef(Context ctx, long obj);
|
||||||
|
|
||||||
protected void incAndClear(Context ctx, long o)
|
public void storeReference(Context ctx, T obj) {
|
||||||
{
|
PhantomReference<T> ref = new PhantomReference<>(obj, referenceQueue);
|
||||||
incRef(ctx, o);
|
referenceMap.put(ref, obj.getNativeObject());
|
||||||
if (m_queue.size() >= m_move_limit)
|
clear(ctx);
|
||||||
clear(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void add(long o)
|
|
||||||
{
|
|
||||||
if (o == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
synchronized (m_lock)
|
|
||||||
{
|
|
||||||
m_queue.add(o);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clear(Context ctx)
|
protected void clear(Context ctx)
|
||||||
{
|
{
|
||||||
synchronized (m_lock)
|
Reference<? extends T> ref;
|
||||||
{
|
while ((ref = referenceQueue.poll()) != null) {
|
||||||
for (Long o : m_queue)
|
long z3ast = referenceMap.remove(ref);
|
||||||
decRef(ctx, o);
|
decRef(ctx, z3ast);
|
||||||
m_queue.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*++
|
|
||||||
Copyright (c) 2012 Microsoft Corporation
|
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
IDisposable.java
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
Compatability interface (C# -> Java)
|
|
||||||
|
|
||||||
Author:
|
|
||||||
|
|
||||||
Christoph Wintersteiger (cwinter) 2012-03-16
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
package com.microsoft.z3;
|
|
||||||
|
|
||||||
public abstract class IDisposable
|
|
||||||
{
|
|
||||||
public abstract void dispose();
|
|
||||||
}
|
|
|
@ -63,14 +63,7 @@ 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() {
|
||||||
{
|
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,10 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.lang.String;
|
|
||||||
|
|
||||||
import com.microsoft.z3.enumerations.Z3_lbool;
|
import com.microsoft.z3.enumerations.Z3_lbool;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The InterpolationContext is suitable for generation of interpolants.
|
* The InterpolationContext is suitable for generation of interpolants.
|
||||||
*
|
*
|
||||||
|
@ -33,13 +32,13 @@ public class InterpolationContext extends Context
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
**/
|
**/
|
||||||
public InterpolationContext()
|
public static InterpolationContext mkContext()
|
||||||
{
|
{
|
||||||
super();
|
long m_ctx;
|
||||||
synchronized(creation_lock) {
|
synchronized(creation_lock) {
|
||||||
m_ctx = Native.mkInterpolationContext(0);
|
m_ctx = Native.mkInterpolationContext(0);
|
||||||
initContext();
|
|
||||||
}
|
}
|
||||||
|
return new InterpolationContext(m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,17 +48,21 @@ public class InterpolationContext extends Context
|
||||||
* Remarks:
|
* Remarks:
|
||||||
* @see Context#Context
|
* @see Context#Context
|
||||||
**/
|
**/
|
||||||
public InterpolationContext(Map<String, String> settings)
|
public static InterpolationContext mkContext(Map<String, String> settings)
|
||||||
{
|
{
|
||||||
super();
|
long m_ctx;
|
||||||
synchronized(creation_lock) {
|
synchronized(creation_lock) {
|
||||||
long cfg = Native.mkConfig();
|
long cfg = Native.mkConfig();
|
||||||
for (Map.Entry<String, String> kv : settings.entrySet())
|
for (Map.Entry<String, String> kv : settings.entrySet())
|
||||||
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
|
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
|
||||||
m_ctx = Native.mkInterpolationContext(cfg);
|
m_ctx = Native.mkInterpolationContext(cfg);
|
||||||
Native.delConfig(cfg);
|
Native.delConfig(cfg);
|
||||||
initContext();
|
|
||||||
}
|
}
|
||||||
|
return new InterpolationContext(m_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InterpolationContext(long m_ctx) {
|
||||||
|
super(m_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,8 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
|
import com.microsoft.z3.Native.LongPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List sorts.
|
* List sorts.
|
||||||
**/
|
**/
|
||||||
|
@ -88,14 +90,9 @@ public class ListSort extends Sort
|
||||||
|
|
||||||
ListSort(Context ctx, Symbol name, Sort elemSort)
|
ListSort(Context ctx, Symbol name, Sort elemSort)
|
||||||
{
|
{
|
||||||
super(ctx, 0);
|
super(ctx, Native.mkListSort(ctx.nCtx(), name.getNativeObject(),
|
||||||
|
elemSort.getNativeObject(),
|
||||||
Native.LongPtr inil = new Native.LongPtr(), iisnil = new Native.LongPtr();
|
new LongPtr(), new Native.LongPtr(), new LongPtr(),
|
||||||
Native.LongPtr icons = new Native.LongPtr(), iiscons = new Native.LongPtr();
|
new LongPtr(), new LongPtr(), new LongPtr()));
|
||||||
Native.LongPtr ihead = new Native.LongPtr(), itail = new Native.LongPtr();
|
|
||||||
|
|
||||||
setNativeObject(Native.mkListSort(ctx.nCtx(), name.getNativeObject(),
|
|
||||||
elemSort.getNativeObject(), inil, iisnil, icons, iiscons, ihead,
|
|
||||||
itail));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,7 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
|
||||||
/**
|
/**
|
||||||
* A Model contains interpretations (assignments) of constants and functions.
|
* A Model contains interpretations (assignments) of constants and functions.
|
||||||
**/
|
**/
|
||||||
public class Model extends Z3Object
|
public class Model extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the interpretation (the assignment) of {@code a} in
|
* Retrieves the interpretation (the assignment) of {@code a} in
|
||||||
* the model.
|
* the model.
|
||||||
|
@ -283,15 +282,8 @@ public class Model extends Z3Object
|
||||||
* @return A string representation of the model.
|
* @return A string representation of the model.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.modelToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.modelToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Model(Context ctx, long obj)
|
Model(Context ctx, long obj)
|
||||||
|
@ -300,16 +292,12 @@ public class Model extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.modelIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getModelDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getModelDRQ().storeReference(getContext(), this);
|
||||||
getContext().getModelDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ModelDecRefQueue extends IDecRefQueue
|
class ModelDecRefQueue extends IDecRefQueue<Model> {
|
||||||
{
|
|
||||||
public ModelDecRefQueue()
|
public ModelDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.modelDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.modelIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.modelDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -266,17 +266,12 @@ public class Optimize extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.optimizeIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getOptimizeDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getOptimizeDRQ().storeReference(getContext(), this);
|
||||||
getContext().getOptimizeDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class OptimizeDecRefQueue extends IDecRefQueue
|
class OptimizeDecRefQueue extends IDecRefQueue<Optimize> {
|
||||||
{
|
|
||||||
public OptimizeDecRefQueue()
|
public OptimizeDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OptimizeDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.optimizeDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.fixedpointIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.fixedpointDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,8 +22,7 @@ import com.microsoft.z3.enumerations.Z3_param_kind;
|
||||||
/**
|
/**
|
||||||
* A ParamDescrs describes a set of parameters.
|
* A ParamDescrs describes a set of parameters.
|
||||||
**/
|
**/
|
||||||
public class ParamDescrs extends Z3Object
|
public class ParamDescrs extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* validate a set of parameters.
|
* validate a set of parameters.
|
||||||
**/
|
**/
|
||||||
|
@ -82,15 +81,8 @@ public class ParamDescrs extends Z3Object
|
||||||
* Retrieves a string representation of the ParamDescrs.
|
* Retrieves a string representation of the ParamDescrs.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.paramDescrsToString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.paramDescrsToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamDescrs(Context ctx, long obj)
|
ParamDescrs(Context ctx, long obj)
|
||||||
|
@ -99,16 +91,12 @@ public class ParamDescrs extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.paramDescrsIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getParamDescrsDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getParamDescrsDRQ().storeReference(getContext(), this);
|
||||||
getContext().getParamDescrsDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ParamDescrsDecRefQueue extends IDecRefQueue
|
class ParamDescrsDecRefQueue extends IDecRefQueue<ParamDescrs> {
|
||||||
{
|
|
||||||
public ParamDescrsDecRefQueue()
|
public ParamDescrsDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParamDescrsDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void incRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.paramDescrsIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
try
|
Native.paramDescrsDecRef(ctx.nCtx(), obj);
|
||||||
{
|
|
||||||
Native.paramDescrsDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -21,8 +21,7 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
* A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
||||||
**/
|
**/
|
||||||
public class Params extends Z3Object
|
public class Params extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Adds a parameter setting.
|
* Adds a parameter setting.
|
||||||
**/
|
**/
|
||||||
|
@ -115,13 +114,7 @@ public class Params extends Z3Object
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.paramsToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.paramsToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Params(Context ctx)
|
Params(Context ctx)
|
||||||
|
@ -129,17 +122,14 @@ public class Params extends Z3Object
|
||||||
super(ctx, Native.mkParams(ctx.nCtx()));
|
super(ctx, Native.mkParams(ctx.nCtx()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.paramsIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getParamsDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getParamsDRQ().storeReference(getContext(), this);
|
||||||
getContext().getParamsDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ParamsDecRefQueue extends IDecRefQueue
|
class ParamsDecRefQueue extends IDecRefQueue<Params> {
|
||||||
{
|
|
||||||
public ParamsDecRefQueue()
|
public ParamsDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParamsDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.paramsDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.paramsIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.paramsDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -53,13 +53,7 @@ public class Pattern extends AST
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.patternToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.patternToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern(Context ctx, long obj)
|
Pattern(Context ctx, long obj)
|
||||||
|
|
|
@ -25,8 +25,7 @@ package com.microsoft.z3;
|
||||||
* also be obtained using the command {@code (help-tactic)} in the SMT 2.0
|
* also be obtained using the command {@code (help-tactic)} in the SMT 2.0
|
||||||
* front-end.
|
* front-end.
|
||||||
**/
|
**/
|
||||||
public class Probe extends Z3Object
|
public class Probe extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Execute the probe over the goal.
|
* Execute the probe over the goal.
|
||||||
*
|
*
|
||||||
|
@ -46,22 +45,17 @@ public class Probe extends Z3Object
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Probe(Context ctx, String name)
|
Probe(Context ctx, String name) {
|
||||||
{
|
|
||||||
super(ctx, Native.mkProbe(ctx.nCtx(), name));
|
super(ctx, Native.mkProbe(ctx.nCtx(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.probeIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getProbeDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getProbeDRQ().storeReference(getContext(), this);
|
||||||
getContext().getProbeDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,39 +17,16 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class ProbeDecRefQueue extends IDecRefQueue
|
class ProbeDecRefQueue extends IDecRefQueue<Probe>
|
||||||
{
|
{
|
||||||
public ProbeDecRefQueue()
|
public ProbeDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProbeDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void incRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.probeIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
try
|
Native.probeDecRef(ctx.nCtx(), obj);
|
||||||
{
|
|
||||||
Native.probeDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,68 +145,67 @@ public class Quantifier extends BoolExpr
|
||||||
.nCtx(), getNativeObject()));
|
.nCtx(), getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names,
|
public static Quantifier of(
|
||||||
|
Context ctx, boolean isForall, Sort[] sorts, Symbol[] names,
|
||||||
Expr body, int weight, Pattern[] patterns, Expr[] noPatterns,
|
Expr body, int weight, Pattern[] patterns, Expr[] noPatterns,
|
||||||
Symbol quantifierID, Symbol skolemID)
|
Symbol quantifierID, Symbol skolemID
|
||||||
{
|
) {
|
||||||
super(ctx, 0);
|
ctx.checkContextMatch(patterns);
|
||||||
|
ctx.checkContextMatch(noPatterns);
|
||||||
getContext().checkContextMatch(patterns);
|
ctx.checkContextMatch(sorts);
|
||||||
getContext().checkContextMatch(noPatterns);
|
ctx.checkContextMatch(names);
|
||||||
getContext().checkContextMatch(sorts);
|
ctx.checkContextMatch(body);
|
||||||
getContext().checkContextMatch(names);
|
|
||||||
getContext().checkContextMatch(body);
|
|
||||||
|
|
||||||
if (sorts.length != names.length)
|
if (sorts.length != names.length)
|
||||||
throw new Z3Exception(
|
throw new Z3Exception(
|
||||||
"Number of sorts does not match number of names");
|
"Number of sorts does not match number of names");
|
||||||
|
|
||||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
long nativeObj;
|
||||||
{
|
if (noPatterns == null && quantifierID == null && skolemID == null) {
|
||||||
setNativeObject(Native.mkQuantifier(ctx.nCtx(), (isForall), weight, AST.arrayLength(patterns), AST
|
nativeObj = Native.mkQuantifier(ctx.nCtx(), (isForall), weight, AST.arrayLength(patterns), AST
|
||||||
.arrayToNative(patterns), AST.arrayLength(sorts), AST
|
.arrayToNative(patterns), AST.arrayLength(sorts), AST
|
||||||
.arrayToNative(sorts), Symbol.arrayToNative(names), body
|
.arrayToNative(sorts), Symbol.arrayToNative(names), body
|
||||||
.getNativeObject()));
|
.getNativeObject());
|
||||||
} else
|
} else {
|
||||||
{
|
nativeObj = Native.mkQuantifierEx(ctx.nCtx(),
|
||||||
setNativeObject(Native.mkQuantifierEx(ctx.nCtx(),
|
(isForall), weight, AST.getNativeObject(quantifierID),
|
||||||
(isForall), weight, AST.getNativeObject(quantifierID),
|
AST.getNativeObject(skolemID),
|
||||||
AST.getNativeObject(skolemID),
|
AST.arrayLength(patterns), AST.arrayToNative(patterns),
|
||||||
AST.arrayLength(patterns), AST.arrayToNative(patterns),
|
AST.arrayLength(noPatterns), AST.arrayToNative(noPatterns),
|
||||||
AST.arrayLength(noPatterns), AST.arrayToNative(noPatterns),
|
AST.arrayLength(sorts), AST.arrayToNative(sorts),
|
||||||
AST.arrayLength(sorts), AST.arrayToNative(sorts),
|
Symbol.arrayToNative(names),
|
||||||
Symbol.arrayToNative(names),
|
body.getNativeObject());
|
||||||
body.getNativeObject()));
|
|
||||||
}
|
}
|
||||||
|
return new Quantifier(ctx, nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body,
|
|
||||||
|
public static Quantifier of(Context ctx, boolean isForall, Expr[] bound, Expr body,
|
||||||
int weight, Pattern[] patterns, Expr[] noPatterns,
|
int weight, Pattern[] patterns, Expr[] noPatterns,
|
||||||
Symbol quantifierID, Symbol skolemID)
|
Symbol quantifierID, Symbol skolemID)
|
||||||
{
|
{
|
||||||
super(ctx, 0);
|
ctx.checkContextMatch(noPatterns);
|
||||||
|
ctx.checkContextMatch(patterns);
|
||||||
getContext().checkContextMatch(noPatterns);
|
// ctx.CheckContextMatch(bound);
|
||||||
getContext().checkContextMatch(patterns);
|
ctx.checkContextMatch(body);
|
||||||
// Context().CheckContextMatch(bound);
|
|
||||||
getContext().checkContextMatch(body);
|
|
||||||
|
|
||||||
|
long nativeObj;
|
||||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||||
{
|
{
|
||||||
setNativeObject(Native.mkQuantifierConst(ctx.nCtx(),
|
nativeObj = Native.mkQuantifierConst(ctx.nCtx(),
|
||||||
isForall, weight, AST.arrayLength(bound),
|
isForall, weight, AST.arrayLength(bound),
|
||||||
AST.arrayToNative(bound), AST.arrayLength(patterns),
|
AST.arrayToNative(bound), AST.arrayLength(patterns),
|
||||||
AST.arrayToNative(patterns), body.getNativeObject()));
|
AST.arrayToNative(patterns), body.getNativeObject());
|
||||||
} else
|
} else {
|
||||||
{
|
nativeObj = Native.mkQuantifierConstEx(ctx.nCtx(),
|
||||||
setNativeObject(Native.mkQuantifierConstEx(ctx.nCtx(),
|
|
||||||
isForall, weight,
|
isForall, weight,
|
||||||
AST.getNativeObject(quantifierID),
|
AST.getNativeObject(quantifierID),
|
||||||
AST.getNativeObject(skolemID), AST.arrayLength(bound),
|
AST.getNativeObject(skolemID), AST.arrayLength(bound),
|
||||||
AST.arrayToNative(bound), AST.arrayLength(patterns),
|
AST.arrayToNative(bound), AST.arrayLength(patterns),
|
||||||
AST.arrayToNative(patterns), AST.arrayLength(noPatterns),
|
AST.arrayToNative(patterns), AST.arrayLength(noPatterns),
|
||||||
AST.arrayToNative(noPatterns), body.getNativeObject()));
|
AST.arrayToNative(noPatterns), body.getNativeObject());
|
||||||
}
|
}
|
||||||
|
return new Quantifier(ctx, nativeObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quantifier(Context ctx, long obj)
|
Quantifier(Context ctx, long obj)
|
||||||
|
|
|
@ -75,15 +75,8 @@ public class RatNum extends RealExpr
|
||||||
* Returns a string representation of the numeral.
|
* Returns a string representation of the numeral.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||||
try
|
|
||||||
{
|
|
||||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RatNum(Context ctx, long obj)
|
RatNum(Context ctx, long obj)
|
||||||
|
|
|
@ -22,8 +22,7 @@ import com.microsoft.z3.enumerations.Z3_lbool;
|
||||||
/**
|
/**
|
||||||
* Solvers.
|
* Solvers.
|
||||||
**/
|
**/
|
||||||
public class Solver extends Z3Object
|
public class Solver extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* A string that describes all available solver parameters.
|
* A string that describes all available solver parameters.
|
||||||
**/
|
**/
|
||||||
|
@ -127,13 +126,13 @@ public class Solver extends Z3Object
|
||||||
* using the Boolean constants in ps.
|
* using the Boolean constants in ps.
|
||||||
*
|
*
|
||||||
* Remarks:
|
* Remarks:
|
||||||
* This API is an alternative to {@link check} with assumptions for
|
* This API is an alternative to {@link #check()} with assumptions for
|
||||||
* extracting unsat cores.
|
* extracting unsat cores.
|
||||||
* Both APIs can be used in the same solver. The unsat core will contain a
|
* Both APIs can be used in the same solver. The unsat core will contain a
|
||||||
* combination
|
* combination
|
||||||
* of the Boolean variables provided using {@link assertAndTrack}
|
* of the Boolean variables provided using {@code #assertAndTrack}
|
||||||
* and the Boolean literals
|
* and the Boolean literals
|
||||||
* provided using {@link check} with assumptions.
|
* provided using {@link #check()} with assumptions.
|
||||||
**/
|
**/
|
||||||
public void assertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
|
public void assertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
|
||||||
{
|
{
|
||||||
|
@ -154,13 +153,13 @@ public class Solver extends Z3Object
|
||||||
* using the Boolean constant p.
|
* using the Boolean constant p.
|
||||||
*
|
*
|
||||||
* Remarks:
|
* Remarks:
|
||||||
* This API is an alternative to {@link check} with assumptions for
|
* This API is an alternative to {@link #check} with assumptions for
|
||||||
* extracting unsat cores.
|
* extracting unsat cores.
|
||||||
* Both APIs can be used in the same solver. The unsat core will contain a
|
* Both APIs can be used in the same solver. The unsat core will contain a
|
||||||
* combination
|
* combination
|
||||||
* of the Boolean variables provided using {@link assertAndTrack}
|
* of the Boolean variables provided using {@link #assertAndTrack}
|
||||||
* and the Boolean literals
|
* and the Boolean literals
|
||||||
* provided using {@link check} with assumptions.
|
* provided using {@link #check} with assumptions.
|
||||||
*/
|
*/
|
||||||
public void assertAndTrack(BoolExpr constraint, BoolExpr p)
|
public void assertAndTrack(BoolExpr constraint, BoolExpr p)
|
||||||
{
|
{
|
||||||
|
@ -323,14 +322,8 @@ public class Solver extends Z3Object
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native
|
||||||
{
|
.solverToString(getContext().nCtx(), getNativeObject());
|
||||||
return Native
|
|
||||||
.solverToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Solver(Context ctx, long obj)
|
Solver(Context ctx, long obj)
|
||||||
|
@ -339,16 +332,12 @@ public class Solver extends Z3Object
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void incRef(long o)
|
void incRef() {
|
||||||
{
|
Native.solverIncRef(getContext().nCtx(), getNativeObject());
|
||||||
getContext().getSolverDRQ().incAndClear(getContext(), o);
|
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void decRef(long o)
|
void addToReferenceQueue() {
|
||||||
{
|
getContext().getSolverDRQ().storeReference(getContext(), this);
|
||||||
getContext().getSolverDRQ().add(o);
|
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,36 +17,11 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class SolverDecRefQueue extends IDecRefQueue
|
class SolverDecRefQueue extends IDecRefQueue<Solver> {
|
||||||
{
|
|
||||||
public SolverDecRefQueue() { super(); }
|
public SolverDecRefQueue() { super(); }
|
||||||
|
|
||||||
public SolverDecRefQueue(int move_limit)
|
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void incRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj) {
|
||||||
{
|
Native.solverDecRef(ctx.nCtx(), obj);
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.solverIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.solverDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -82,15 +82,9 @@ public class Sort extends AST
|
||||||
/**
|
/**
|
||||||
* A string representation of the sort.
|
* A string representation of the sort.
|
||||||
**/
|
**/
|
||||||
public String toString()
|
@Override
|
||||||
{
|
public String toString() {
|
||||||
try
|
return Native.sortToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.sortToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,6 +95,7 @@ public class Sort extends AST
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
void checkNativeObject(long obj)
|
void checkNativeObject(long obj)
|
||||||
{
|
{
|
||||||
if (Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_SORT_AST
|
if (Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_SORT_AST
|
||||||
|
|
|
@ -20,8 +20,7 @@ package com.microsoft.z3;
|
||||||
/**
|
/**
|
||||||
* Objects of this class track statistical information about solvers.
|
* Objects of this class track statistical information about solvers.
|
||||||
**/
|
**/
|
||||||
public class Statistics extends Z3Object
|
public class Statistics extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Statistical data is organized into pairs of [Key, Entry], where every
|
* Statistical data is organized into pairs of [Key, Entry], where every
|
||||||
* Entry is either a {@code DoubleEntry} or a {@code UIntEntry}
|
* Entry is either a {@code DoubleEntry} or a {@code UIntEntry}
|
||||||
|
@ -84,15 +83,9 @@ public class Statistics extends Z3Object
|
||||||
/**
|
/**
|
||||||
* The string representation of the Entry.
|
* The string representation of the Entry.
|
||||||
**/
|
**/
|
||||||
public String toString()
|
@Override
|
||||||
{
|
public String toString() {
|
||||||
try
|
return Key + ": " + getValueString();
|
||||||
{
|
|
||||||
return Key + ": " + getValueString();
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean m_is_int = false;
|
private boolean m_is_int = false;
|
||||||
|
@ -118,15 +111,10 @@ public class Statistics extends Z3Object
|
||||||
/**
|
/**
|
||||||
* A string representation of the statistical data.
|
* A string representation of the statistical data.
|
||||||
**/
|
**/
|
||||||
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try
|
return Native.statsToString(getContext().nCtx(), getNativeObject());
|
||||||
{
|
|
||||||
return Native.statsToString(getContext().nCtx(), getNativeObject());
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,15 +189,13 @@ public class Statistics extends Z3Object
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void incRef(long o)
|
@Override
|
||||||
{
|
void incRef() {
|
||||||
getContext().getStatisticsDRQ().incAndClear(getContext(), o);
|
getContext().getStatisticsDRQ().storeReference(getContext(), this);
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decRef(long o)
|
@Override
|
||||||
{
|
void addToReferenceQueue() {
|
||||||
getContext().getStatisticsDRQ().add(o);
|
Native.statsIncRef(getContext().nCtx(), getNativeObject());
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,37 +17,14 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class StatisticsDecRefQueue extends IDecRefQueue
|
class StatisticsDecRefQueue extends IDecRefQueue<Statistics> {
|
||||||
{
|
|
||||||
public StatisticsDecRefQueue()
|
public StatisticsDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatisticsDecRefQueue(int move_limit)
|
@Override
|
||||||
{
|
protected void decRef(Context ctx, long obj) {
|
||||||
super(move_limit);
|
Native.statsDecRef(ctx.nCtx(), obj);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
protected void incRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.statsIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void decRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.statsDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ public class StringSymbol extends Symbol
|
||||||
void checkNativeObject(long obj)
|
void checkNativeObject(long obj)
|
||||||
{
|
{
|
||||||
if (Native.getSymbolKind(getContext().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL
|
if (Native.getSymbolKind(getContext().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL
|
||||||
.toInt())
|
.toInt()) {
|
||||||
throw new Z3Exception("Symbol is not of String kind");
|
throw new Z3Exception("Symbol is not of String kind");
|
||||||
|
}
|
||||||
super.checkNativeObject(obj);
|
super.checkNativeObject(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ import com.microsoft.z3.enumerations.Z3_symbol_kind;
|
||||||
/**
|
/**
|
||||||
* Symbols are used to name several term and type constructors.
|
* Symbols are used to name several term and type constructors.
|
||||||
**/
|
**/
|
||||||
public class Symbol extends Z3Object
|
public class Symbol extends Z3Object {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* The kind of the symbol (int or string)
|
* The kind of the symbol (int or string)
|
||||||
**/
|
**/
|
||||||
|
@ -62,19 +61,13 @@ public class Symbol extends Z3Object
|
||||||
* A string representation of the symbol.
|
* A string representation of the symbol.
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
if (isIntSymbol()) {
|
||||||
try
|
return Integer.toString(((IntSymbol) this).getInt());
|
||||||
{
|
} else if (isStringSymbol()) {
|
||||||
if (isIntSymbol())
|
return ((StringSymbol) this).getString();
|
||||||
return Integer.toString(((IntSymbol) this).getInt());
|
} else {
|
||||||
else if (isStringSymbol())
|
return "Z3Exception: Unknown symbol kind encountered.";
|
||||||
return ((StringSymbol) this).getString();
|
|
||||||
else
|
|
||||||
return "Z3Exception: Unknown symbol kind encountered.";
|
|
||||||
} catch (Z3Exception ex)
|
|
||||||
{
|
|
||||||
return "Z3Exception: " + ex.getMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +79,17 @@ public class Symbol extends Z3Object
|
||||||
super(ctx, obj);
|
super(ctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void incRef() {
|
||||||
|
// Symbol does not require tracking.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void addToReferenceQueue() {
|
||||||
|
|
||||||
|
// Symbol does not require tracking.
|
||||||
|
}
|
||||||
|
|
||||||
static Symbol create(Context ctx, long obj)
|
static Symbol create(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj)))
|
switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj)))
|
||||||
|
|
|
@ -24,8 +24,7 @@ package com.microsoft.z3;
|
||||||
* also be obtained using the command {@code (help-tactic)} in the SMT 2.0
|
* also be obtained using the command {@code (help-tactic)} in the SMT 2.0
|
||||||
* front-end.
|
* front-end.
|
||||||
**/
|
**/
|
||||||
public class Tactic extends Z3Object
|
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.
|
||||||
**/
|
**/
|
||||||
|
@ -92,15 +91,13 @@ public class Tactic extends Z3Object
|
||||||
super(ctx, Native.mkTactic(ctx.nCtx(), name));
|
super(ctx, Native.mkTactic(ctx.nCtx(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void incRef(long o)
|
@Override
|
||||||
{
|
void incRef() {
|
||||||
getContext().getTacticDRQ().incAndClear(getContext(), o);
|
Native.tacticIncRef(getContext().nCtx(), getNativeObject());
|
||||||
super.incRef(o);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decRef(long o)
|
@Override
|
||||||
{
|
void addToReferenceQueue() {
|
||||||
getContext().getTacticDRQ().add(o);
|
getContext().getTacticDRQ().storeReference(getContext(), this);
|
||||||
super.decRef(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,37 +17,15 @@ Notes:
|
||||||
|
|
||||||
package com.microsoft.z3;
|
package com.microsoft.z3;
|
||||||
|
|
||||||
class TacticDecRefQueue extends IDecRefQueue
|
class TacticDecRefQueue extends IDecRefQueue<Tactic> {
|
||||||
{
|
|
||||||
public TacticDecRefQueue()
|
public TacticDecRefQueue()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TacticDecRefQueue(int move_limit)
|
@Override
|
||||||
{
|
|
||||||
super(move_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void incRef(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Native.tacticIncRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void decRef(Context ctx, long obj)
|
protected void decRef(Context ctx, long obj)
|
||||||
{
|
{
|
||||||
try
|
Native.tacticDecRef(ctx.nCtx(), obj);
|
||||||
{
|
|
||||||
Native.tacticDecRef(ctx.nCtx(), obj);
|
|
||||||
} catch (Z3Exception e)
|
|
||||||
{
|
|
||||||
// OK.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -59,11 +59,9 @@ public class TupleSort extends Sort
|
||||||
TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames,
|
TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames,
|
||||||
Sort[] fieldSorts)
|
Sort[] fieldSorts)
|
||||||
{
|
{
|
||||||
super(ctx, 0);
|
super(ctx, Native.mkTupleSort(ctx.nCtx(), name.getNativeObject(),
|
||||||
|
|
||||||
Native.LongPtr t = new Native.LongPtr();
|
|
||||||
setNativeObject(Native.mkTupleSort(ctx.nCtx(), name.getNativeObject(),
|
|
||||||
numFields, Symbol.arrayToNative(fieldNames),
|
numFields, Symbol.arrayToNative(fieldNames),
|
||||||
AST.arrayToNative(fieldSorts), t, new long[numFields]));
|
AST.arrayToNative(fieldSorts), new Native.LongPtr(),
|
||||||
|
new long[numFields]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,88 +21,43 @@ package com.microsoft.z3;
|
||||||
* Internal base class for interfacing with native Z3 objects. Should not be
|
* Internal base class for interfacing with native Z3 objects. Should not be
|
||||||
* used externally.
|
* used externally.
|
||||||
**/
|
**/
|
||||||
public class Z3Object extends IDisposable
|
public abstract class Z3Object {
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Finalizer.
|
|
||||||
* @throws Throwable
|
|
||||||
**/
|
|
||||||
protected void finalize() throws Throwable
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
dispose();
|
|
||||||
} finally {
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private final Context m_ctx;
|
||||||
* Disposes of the underlying native Z3 object.
|
private final long m_n_obj;
|
||||||
**/
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
if (m_n_obj != 0)
|
|
||||||
{
|
|
||||||
decRef(m_n_obj);
|
|
||||||
m_n_obj = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ctx != null)
|
Z3Object(Context ctx, long obj) {
|
||||||
{
|
|
||||||
if (m_ctx.m_refCount.decrementAndGet() == 0)
|
|
||||||
m_ctx.dispose();
|
|
||||||
m_ctx = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Context m_ctx = null;
|
|
||||||
private long m_n_obj = 0;
|
|
||||||
|
|
||||||
Z3Object(Context ctx)
|
|
||||||
{
|
|
||||||
ctx.m_refCount.incrementAndGet();
|
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
}
|
checkNativeObject(obj);
|
||||||
|
|
||||||
Z3Object(Context ctx, long obj)
|
|
||||||
{
|
|
||||||
ctx.m_refCount.incrementAndGet();
|
|
||||||
m_ctx = ctx;
|
|
||||||
incRef(obj);
|
|
||||||
m_n_obj = obj;
|
m_n_obj = obj;
|
||||||
|
incRef();
|
||||||
|
addToReferenceQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void incRef(long o)
|
/**
|
||||||
{
|
* Add to ReferenceQueue for tracking reachability on the object and
|
||||||
}
|
* decreasing the reference count when the object is no longer reachable.
|
||||||
|
*/
|
||||||
|
abstract void addToReferenceQueue();
|
||||||
|
|
||||||
void decRef(long o)
|
/**
|
||||||
{
|
* Increment reference count on {@code this}.
|
||||||
}
|
*/
|
||||||
|
abstract void incRef();
|
||||||
|
|
||||||
void checkNativeObject(long obj)
|
/**
|
||||||
{
|
* This function is provided for overriding, and a child class
|
||||||
}
|
* can insert consistency checks on {@code obj}.
|
||||||
|
*
|
||||||
|
* @param obj Z3 native object.
|
||||||
|
*/
|
||||||
|
void checkNativeObject(long obj) {}
|
||||||
|
|
||||||
long getNativeObject()
|
long getNativeObject()
|
||||||
{
|
{
|
||||||
return m_n_obj;
|
return m_n_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNativeObject(long value)
|
|
||||||
{
|
|
||||||
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)
|
static long getNativeObject(Z3Object s)
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
|
@ -121,7 +76,7 @@ public class Z3Object extends IDisposable
|
||||||
return null;
|
return null;
|
||||||
long[] an = new long[a.length];
|
long[] an = new long[a.length];
|
||||||
for (int i = 0; i < a.length; i++)
|
for (int i = 0; i < a.length; i++)
|
||||||
an[i] = (a[i] == null) ? 0 : a[i].getNativeObject();
|
an[i] = (a[i] == null) ? 0 : a[i].getNativeObject();
|
||||||
return an;
|
return an;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,6 +227,7 @@ void Z3_ast_finalize(value v) {
|
||||||
int Z3_ast_compare(value v1, value v2) {
|
int Z3_ast_compare(value v1, value v2) {
|
||||||
Z3_ast_plus * a1 = (Z3_ast_plus*)Data_custom_val(v1);
|
Z3_ast_plus * a1 = (Z3_ast_plus*)Data_custom_val(v1);
|
||||||
Z3_ast_plus * a2 = (Z3_ast_plus*)Data_custom_val(v2);
|
Z3_ast_plus * a2 = (Z3_ast_plus*)Data_custom_val(v2);
|
||||||
|
unsigned id1, id2;
|
||||||
|
|
||||||
/* if the two ASTs belong to different contexts, we take
|
/* if the two ASTs belong to different contexts, we take
|
||||||
their contexts' addresses to order them (arbitrarily, but fixed) */
|
their contexts' addresses to order them (arbitrarily, but fixed) */
|
||||||
|
@ -242,8 +243,8 @@ int Z3_ast_compare(value v1, value v2) {
|
||||||
return +1;
|
return +1;
|
||||||
|
|
||||||
/* Comparison according to AST ids. */
|
/* Comparison according to AST ids. */
|
||||||
unsigned id1 = Z3_get_ast_id(a1->cp->ctx, a1->p);
|
id1 = Z3_get_ast_id(a1->cp->ctx, a1->p);
|
||||||
unsigned id2 = Z3_get_ast_id(a2->cp->ctx, a2->p);
|
id2 = Z3_get_ast_id(a2->cp->ctx, a2->p);
|
||||||
if (id1 == id2)
|
if (id1 == id2)
|
||||||
return 0;
|
return 0;
|
||||||
else if (id1 < id2)
|
else if (id1 < id2)
|
||||||
|
@ -255,7 +256,7 @@ int Z3_ast_compare(value v1, value v2) {
|
||||||
int Z3_ast_compare_ext(value v1, value v2) {
|
int Z3_ast_compare_ext(value v1, value v2) {
|
||||||
Z3_ast_plus * a1 = (Z3_ast_plus*)Data_custom_val(v1);
|
Z3_ast_plus * a1 = (Z3_ast_plus*)Data_custom_val(v1);
|
||||||
unsigned id1;
|
unsigned id1;
|
||||||
int id2 = Val_int(v2);
|
unsigned id2 = (unsigned)Val_int(v2);
|
||||||
if (a1->p == NULL && id2 == 0)
|
if (a1->p == NULL && id2 == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (a1->p == NULL)
|
if (a1->p == NULL)
|
||||||
|
|
|
@ -30,3 +30,18 @@ void pattern_inference_params::updt_params(params_ref const & _p) {
|
||||||
m_pi_pull_quantifiers = p.pull_quantifiers();
|
m_pi_pull_quantifiers = p.pull_quantifiers();
|
||||||
m_pi_warnings = p.warnings();
|
m_pi_warnings = p.warnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void pattern_inference_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_pi_max_multi_patterns);
|
||||||
|
DISPLAY_PARAM(m_pi_block_loop_patterns);
|
||||||
|
DISPLAY_PARAM(m_pi_arith);
|
||||||
|
DISPLAY_PARAM(m_pi_use_database);
|
||||||
|
DISPLAY_PARAM(m_pi_arith_weight);
|
||||||
|
DISPLAY_PARAM(m_pi_non_nested_arith_weight);
|
||||||
|
DISPLAY_PARAM(m_pi_pull_quantifiers);
|
||||||
|
DISPLAY_PARAM(m_pi_nopat_weight);
|
||||||
|
DISPLAY_PARAM(m_pi_avoid_skolems);
|
||||||
|
DISPLAY_PARAM(m_pi_warnings);
|
||||||
|
}
|
|
@ -46,6 +46,8 @@ struct pattern_inference_params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & _p);
|
void updt_params(params_ref const & _p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PATTERN_INFERENCE_PARAMS_H_ */
|
#endif /* PATTERN_INFERENCE_PARAMS_H_ */
|
||||||
|
|
|
@ -22,7 +22,7 @@ Revision History:
|
||||||
struct bit_blaster_params {
|
struct bit_blaster_params {
|
||||||
bool m_bb_ext_gates;
|
bool m_bb_ext_gates;
|
||||||
bool m_bb_quantifiers;
|
bool m_bb_quantifiers;
|
||||||
bit_blaster_params():
|
bit_blaster_params() :
|
||||||
m_bb_ext_gates(false),
|
m_bb_ext_gates(false),
|
||||||
m_bb_quantifiers(false) {
|
m_bb_quantifiers(false) {
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,11 @@ struct bit_blaster_params {
|
||||||
p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers");
|
p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void display(std::ostream & out) const {
|
||||||
|
out << "m_bb_ext_gates=" << m_bb_ext_gates << std::endl;
|
||||||
|
out << "m_bb_quantifiers=" << m_bb_quantifiers << std::endl;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BIT_BLASTER_PARAMS_H_ */
|
#endif /* BIT_BLASTER_PARAMS_H_ */
|
||||||
|
|
|
@ -24,3 +24,10 @@ void arith_simplifier_params::updt_params(params_ref const & _p) {
|
||||||
m_arith_expand_eqs = p.arith_expand_eqs();
|
m_arith_expand_eqs = p.arith_expand_eqs();
|
||||||
m_arith_process_all_eqs = p.arith_process_all_eqs();
|
m_arith_process_all_eqs = p.arith_process_all_eqs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void arith_simplifier_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_arith_expand_eqs);
|
||||||
|
DISPLAY_PARAM(m_arith_process_all_eqs);
|
||||||
|
}
|
|
@ -30,6 +30,8 @@ struct arith_simplifier_params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & _p);
|
void updt_params(params_ref const & _p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ARITH_SIMPLIFIER_PARAMS_H_ */
|
#endif /* ARITH_SIMPLIFIER_PARAMS_H_ */
|
||||||
|
|
|
@ -27,3 +27,10 @@ void bv_simplifier_params::updt_params(params_ref const & _p) {
|
||||||
m_bv2int_distribute = p.bv_bv2int_distribute();
|
m_bv2int_distribute = p.bv_bv2int_distribute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void bv_simplifier_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_hi_div0);
|
||||||
|
DISPLAY_PARAM(m_bv2int_distribute);
|
||||||
|
}
|
|
@ -30,6 +30,8 @@ struct bv_simplifier_params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & _p);
|
void updt_params(params_ref const & _p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BV_SIMPLIFIER_PARAMS_H_ */
|
#endif /* BV_SIMPLIFIER_PARAMS_H_ */
|
||||||
|
|
|
@ -544,18 +544,11 @@ public:
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
m_mus.reset();
|
m_mus.reset();
|
||||||
for (unsigned i = 0; i < core.size(); ++i) {
|
m_mus.add_soft(core.size(), core.c_ptr());
|
||||||
VERIFY(i == m_mus.add_soft(core[i]));
|
lbool is_sat = m_mus.get_mus(m_new_core);
|
||||||
}
|
|
||||||
unsigned_vector mus_idx;
|
|
||||||
lbool is_sat = m_mus.get_mus(mus_idx);
|
|
||||||
if (is_sat != l_true) {
|
if (is_sat != l_true) {
|
||||||
return is_sat;
|
return is_sat;
|
||||||
}
|
}
|
||||||
m_new_core.reset();
|
|
||||||
for (unsigned i = 0; i < mus_idx.size(); ++i) {
|
|
||||||
m_new_core.push_back(core[mus_idx[i]]);
|
|
||||||
}
|
|
||||||
core.reset();
|
core.reset();
|
||||||
core.append(m_new_core);
|
core.append(m_new_core);
|
||||||
return l_true;
|
return l_true;
|
||||||
|
|
|
@ -811,14 +811,10 @@ namespace qe {
|
||||||
}
|
}
|
||||||
TRACE("qe", tout << core1.size() << " " << core2.size() << "\n";);
|
TRACE("qe", tout << core1.size() << " " << core2.size() << "\n";);
|
||||||
if (core1.size() > 8) {
|
if (core1.size() > 8) {
|
||||||
unsigned_vector core_idxs;
|
if (l_true != mus.get_mus(core2)) {
|
||||||
if (l_true != mus.get_mus(core_idxs)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TRACE("qe", tout << core1.size() << " -> " << core_idxs.size() << "\n";);
|
TRACE("qe", tout << core1.size() << " -> " << core2.size() << "\n";);
|
||||||
for (unsigned i = 0; i < core_idxs.size(); ++i) {
|
|
||||||
core2.push_back(core1[core_idxs[i]].get());
|
|
||||||
}
|
|
||||||
core.reset();
|
core.reset();
|
||||||
core.append(core2);
|
core.append(core2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,3 +28,14 @@ void dyn_ack_params::updt_params(params_ref const & _p) {
|
||||||
m_dack_gc = p.dack_gc();
|
m_dack_gc = p.dack_gc();
|
||||||
m_dack_gc_inv_decay = p.dack_gc_inv_decay();
|
m_dack_gc_inv_decay = p.dack_gc_inv_decay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void dyn_ack_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_dack);
|
||||||
|
DISPLAY_PARAM(m_dack_eq);
|
||||||
|
DISPLAY_PARAM(m_dack_factor);
|
||||||
|
DISPLAY_PARAM(m_dack_threshold);
|
||||||
|
DISPLAY_PARAM(m_dack_gc);
|
||||||
|
DISPLAY_PARAM(m_dack_gc_inv_decay);
|
||||||
|
}
|
|
@ -47,6 +47,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & _p);
|
void updt_params(params_ref const & _p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,33 @@ void preprocessor_params::updt_params(params_ref const & p) {
|
||||||
arith_simplifier_params::updt_params(p);
|
arith_simplifier_params::updt_params(p);
|
||||||
updt_local_params(p);
|
updt_local_params(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void preprocessor_params::display(std::ostream & out) const {
|
||||||
|
pattern_inference_params::display(out);
|
||||||
|
bit_blaster_params::display(out);
|
||||||
|
bv_simplifier_params::display(out);
|
||||||
|
arith_simplifier_params::display(out);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_lift_ite);
|
||||||
|
DISPLAY_PARAM(m_ng_lift_ite);
|
||||||
|
DISPLAY_PARAM(m_pull_cheap_ite_trees);
|
||||||
|
DISPLAY_PARAM(m_pull_nested_quantifiers);
|
||||||
|
DISPLAY_PARAM(m_eliminate_term_ite);
|
||||||
|
DISPLAY_PARAM(m_eliminate_and);
|
||||||
|
DISPLAY_PARAM(m_macro_finder);
|
||||||
|
DISPLAY_PARAM(m_propagate_values);
|
||||||
|
DISPLAY_PARAM(m_propagate_booleans);
|
||||||
|
DISPLAY_PARAM(m_refine_inj_axiom);
|
||||||
|
DISPLAY_PARAM(m_eliminate_bounds);
|
||||||
|
DISPLAY_PARAM(m_simplify_bit2int);
|
||||||
|
DISPLAY_PARAM(m_nnf_cnf);
|
||||||
|
DISPLAY_PARAM(m_distribute_forall);
|
||||||
|
DISPLAY_PARAM(m_reduce_args);
|
||||||
|
DISPLAY_PARAM(m_quasi_macros);
|
||||||
|
DISPLAY_PARAM(m_restricted_quasi_macros);
|
||||||
|
DISPLAY_PARAM(m_max_bv_sharing);
|
||||||
|
DISPLAY_PARAM(m_pre_simplifier);
|
||||||
|
DISPLAY_PARAM(m_nlquant_elim);
|
||||||
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ public:
|
||||||
void updt_local_params(params_ref const & p);
|
void updt_local_params(params_ref const & p);
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PREPROCESSOR_PARAMS_H_ */
|
#endif /* PREPROCESSOR_PARAMS_H_ */
|
||||||
|
|
|
@ -36,3 +36,30 @@ void qi_params::updt_params(params_ref const & _p) {
|
||||||
m_qi_cost = p.qi_cost();
|
m_qi_cost = p.qi_cost();
|
||||||
m_qi_max_eager_multipatterns = p.qi_max_multi_patterns();
|
m_qi_max_eager_multipatterns = p.qi_max_multi_patterns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void qi_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_qi_ematching);
|
||||||
|
DISPLAY_PARAM(m_qi_cost);
|
||||||
|
DISPLAY_PARAM(m_qi_new_gen);
|
||||||
|
DISPLAY_PARAM(m_qi_eager_threshold);
|
||||||
|
DISPLAY_PARAM(m_qi_lazy_threshold);
|
||||||
|
DISPLAY_PARAM(m_qi_max_eager_multipatterns);
|
||||||
|
DISPLAY_PARAM(m_qi_max_lazy_multipattern_matching);
|
||||||
|
DISPLAY_PARAM(m_qi_profile);
|
||||||
|
DISPLAY_PARAM(m_qi_profile_freq);
|
||||||
|
DISPLAY_PARAM(m_qi_quick_checker);
|
||||||
|
DISPLAY_PARAM(m_qi_lazy_quick_checker);
|
||||||
|
DISPLAY_PARAM(m_qi_promote_unsat);
|
||||||
|
DISPLAY_PARAM(m_qi_max_instances);
|
||||||
|
DISPLAY_PARAM(m_qi_lazy_instantiation);
|
||||||
|
DISPLAY_PARAM(m_qi_conservative_final_check);
|
||||||
|
DISPLAY_PARAM(m_mbqi);
|
||||||
|
DISPLAY_PARAM(m_mbqi_max_cexs);
|
||||||
|
DISPLAY_PARAM(m_mbqi_max_cexs_incr);
|
||||||
|
DISPLAY_PARAM(m_mbqi_max_iterations);
|
||||||
|
DISPLAY_PARAM(m_mbqi_trace);
|
||||||
|
DISPLAY_PARAM(m_mbqi_force_template);
|
||||||
|
DISPLAY_PARAM(m_mbqi_id);
|
||||||
|
}
|
|
@ -98,13 +98,15 @@ struct qi_params {
|
||||||
m_mbqi_max_cexs_incr(1),
|
m_mbqi_max_cexs_incr(1),
|
||||||
m_mbqi_max_iterations(1000),
|
m_mbqi_max_iterations(1000),
|
||||||
m_mbqi_trace(false),
|
m_mbqi_trace(false),
|
||||||
m_mbqi_force_template(10),
|
m_mbqi_force_template(10),
|
||||||
m_mbqi_id(0)
|
m_mbqi_id(0)
|
||||||
{
|
{
|
||||||
updt_params(p);
|
updt_params(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* QI_PARAMS_H_ */
|
#endif /* QI_PARAMS_H_ */
|
||||||
|
|
|
@ -63,3 +63,96 @@ void smt_params::updt_params(context_params const & p) {
|
||||||
m_auto_config = p.m_auto_config;
|
m_auto_config = p.m_auto_config;
|
||||||
m_model = p.m_model;
|
m_model = p.m_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void smt_params::display(std::ostream & out) const {
|
||||||
|
preprocessor_params::display(out);
|
||||||
|
dyn_ack_params::display(out);
|
||||||
|
qi_params::display(out);
|
||||||
|
theory_arith_params::display(out);
|
||||||
|
theory_array_params::display(out);
|
||||||
|
theory_bv_params::display(out);
|
||||||
|
theory_pb_params::display(out);
|
||||||
|
theory_datatype_params::display(out);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_display_proof);
|
||||||
|
DISPLAY_PARAM(m_display_dot_proof);
|
||||||
|
DISPLAY_PARAM(m_display_unsat_core);
|
||||||
|
DISPLAY_PARAM(m_check_proof);
|
||||||
|
DISPLAY_PARAM(m_eq_propagation);
|
||||||
|
DISPLAY_PARAM(m_binary_clause_opt);
|
||||||
|
DISPLAY_PARAM(m_relevancy_lvl);
|
||||||
|
DISPLAY_PARAM(m_relevancy_lemma);
|
||||||
|
DISPLAY_PARAM(m_random_seed);
|
||||||
|
DISPLAY_PARAM(m_random_var_freq);
|
||||||
|
DISPLAY_PARAM(m_inv_decay);
|
||||||
|
DISPLAY_PARAM(m_clause_decay);
|
||||||
|
DISPLAY_PARAM(m_random_initial_activity);
|
||||||
|
DISPLAY_PARAM(m_phase_selection);
|
||||||
|
DISPLAY_PARAM(m_phase_caching_on);
|
||||||
|
DISPLAY_PARAM(m_phase_caching_off);
|
||||||
|
DISPLAY_PARAM(m_minimize_lemmas);
|
||||||
|
DISPLAY_PARAM(m_max_conflicts);
|
||||||
|
DISPLAY_PARAM(m_simplify_clauses);
|
||||||
|
DISPLAY_PARAM(m_tick);
|
||||||
|
DISPLAY_PARAM(m_display_features);
|
||||||
|
DISPLAY_PARAM(m_new_core2th_eq);
|
||||||
|
DISPLAY_PARAM(m_ematching);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_case_split_strategy);
|
||||||
|
DISPLAY_PARAM(m_rel_case_split_order);
|
||||||
|
DISPLAY_PARAM(m_lookahead_diseq);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_delay_units);
|
||||||
|
DISPLAY_PARAM(m_delay_units_threshold);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_theory_resolve);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_restart_strategy);
|
||||||
|
DISPLAY_PARAM(m_restart_initial);
|
||||||
|
DISPLAY_PARAM(m_restart_factor);
|
||||||
|
DISPLAY_PARAM(m_restart_adaptive);
|
||||||
|
DISPLAY_PARAM(m_agility_factor);
|
||||||
|
DISPLAY_PARAM(m_restart_agility_threshold);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_lemma_gc_strategy);
|
||||||
|
DISPLAY_PARAM(m_lemma_gc_half);
|
||||||
|
DISPLAY_PARAM(m_recent_lemmas_size);
|
||||||
|
DISPLAY_PARAM(m_lemma_gc_initial);
|
||||||
|
DISPLAY_PARAM(m_lemma_gc_factor);
|
||||||
|
DISPLAY_PARAM(m_new_old_ratio);
|
||||||
|
DISPLAY_PARAM(m_new_clause_activity);
|
||||||
|
DISPLAY_PARAM(m_old_clause_activity);
|
||||||
|
DISPLAY_PARAM(m_new_clause_relevancy);
|
||||||
|
DISPLAY_PARAM(m_old_clause_relevancy);
|
||||||
|
DISPLAY_PARAM(m_inv_clause_decay);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_smtlib_dump_lemmas);
|
||||||
|
DISPLAY_PARAM(m_logic);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_profile_res_sub);
|
||||||
|
DISPLAY_PARAM(m_display_bool_var2expr);
|
||||||
|
DISPLAY_PARAM(m_display_ll_bool_var2expr);
|
||||||
|
DISPLAY_PARAM(m_abort_after_preproc);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_model);
|
||||||
|
DISPLAY_PARAM(m_model_compact);
|
||||||
|
DISPLAY_PARAM(m_model_on_timeout);
|
||||||
|
DISPLAY_PARAM(m_model_on_final_check);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_progress_sampling_freq);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_display_installed_theories);
|
||||||
|
DISPLAY_PARAM(m_core_validate);
|
||||||
|
|
||||||
|
DISPLAY_PARAM(m_preprocess);
|
||||||
|
DISPLAY_PARAM(m_user_theory_preprocess_axioms);
|
||||||
|
DISPLAY_PARAM(m_user_theory_persist_axioms);
|
||||||
|
DISPLAY_PARAM(m_timeout);
|
||||||
|
DISPLAY_PARAM(m_rlimit);
|
||||||
|
DISPLAY_PARAM(m_at_labels_cex);
|
||||||
|
DISPLAY_PARAM(m_check_at_labels);
|
||||||
|
DISPLAY_PARAM(m_dump_goal_as_smt);
|
||||||
|
DISPLAY_PARAM(m_auto_config);
|
||||||
|
}
|
|
@ -289,6 +289,8 @@ struct smt_params : public preprocessor_params,
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
void updt_params(context_params const & p);
|
void updt_params(context_params const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SMT_PARAMS_H_ */
|
#endif /* SMT_PARAMS_H_ */
|
||||||
|
|
|
@ -38,3 +38,51 @@ void theory_arith_params::updt_params(params_ref const & _p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void theory_arith_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_arith_mode);
|
||||||
|
DISPLAY_PARAM(m_arith_auto_config_simplex); //!< force simplex solver in auto_config
|
||||||
|
DISPLAY_PARAM(m_arith_blands_rule_threshold);
|
||||||
|
DISPLAY_PARAM(m_arith_propagate_eqs);
|
||||||
|
DISPLAY_PARAM(m_arith_bound_prop);
|
||||||
|
DISPLAY_PARAM(m_arith_stronger_lemmas);
|
||||||
|
DISPLAY_PARAM(m_arith_skip_rows_with_big_coeffs);
|
||||||
|
DISPLAY_PARAM(m_arith_max_lemma_size);
|
||||||
|
DISPLAY_PARAM(m_arith_small_lemma_size);
|
||||||
|
DISPLAY_PARAM(m_arith_reflect);
|
||||||
|
DISPLAY_PARAM(m_arith_ignore_int);
|
||||||
|
DISPLAY_PARAM(m_arith_lazy_pivoting_lvl);
|
||||||
|
DISPLAY_PARAM(m_arith_random_seed);
|
||||||
|
DISPLAY_PARAM(m_arith_random_initial_value);
|
||||||
|
DISPLAY_PARAM(m_arith_random_lower);
|
||||||
|
DISPLAY_PARAM(m_arith_random_upper);
|
||||||
|
DISPLAY_PARAM(m_arith_adaptive);
|
||||||
|
DISPLAY_PARAM(m_arith_adaptive_assertion_threshold);
|
||||||
|
DISPLAY_PARAM(m_arith_adaptive_propagation_threshold);
|
||||||
|
DISPLAY_PARAM(m_arith_dump_lemmas);
|
||||||
|
DISPLAY_PARAM(m_arith_eager_eq_axioms);
|
||||||
|
DISPLAY_PARAM(m_arith_branch_cut_ratio);
|
||||||
|
DISPLAY_PARAM(m_arith_int_eq_branching);
|
||||||
|
DISPLAY_PARAM(m_arith_enum_const_mod);
|
||||||
|
DISPLAY_PARAM(m_arith_gcd_test);
|
||||||
|
DISPLAY_PARAM(m_arith_eager_gcd);
|
||||||
|
DISPLAY_PARAM(m_arith_adaptive_gcd);
|
||||||
|
DISPLAY_PARAM(m_arith_propagation_threshold);
|
||||||
|
DISPLAY_PARAM(m_arith_pivot_strategy);
|
||||||
|
DISPLAY_PARAM(m_arith_add_binary_bounds);
|
||||||
|
DISPLAY_PARAM(m_arith_propagation_strategy);
|
||||||
|
DISPLAY_PARAM(m_arith_eq_bounds);
|
||||||
|
DISPLAY_PARAM(m_arith_lazy_adapter);
|
||||||
|
DISPLAY_PARAM(m_arith_fixnum);
|
||||||
|
DISPLAY_PARAM(m_arith_int_only);
|
||||||
|
DISPLAY_PARAM(m_nl_arith);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_gb);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_gb_threshold);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_gb_eqs);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_gb_perturbate);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_max_degree);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_branching);
|
||||||
|
DISPLAY_PARAM(m_nl_arith_rounds);
|
||||||
|
DISPLAY_PARAM(m_arith_euclidean_solver);
|
||||||
|
}
|
|
@ -156,6 +156,8 @@ struct theory_arith_params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* THEORY_ARITH_PARAMS_H_ */
|
#endif /* THEORY_ARITH_PARAMS_H_ */
|
||||||
|
|
|
@ -25,4 +25,16 @@ void theory_array_params::updt_params(params_ref const & _p) {
|
||||||
m_array_extensional = p.array_extensional();
|
m_array_extensional = p.array_extensional();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void theory_array_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_array_mode);
|
||||||
|
DISPLAY_PARAM(m_array_weak);
|
||||||
|
DISPLAY_PARAM(m_array_extensional);
|
||||||
|
DISPLAY_PARAM(m_array_laziness);
|
||||||
|
DISPLAY_PARAM(m_array_delay_exp_axiom);
|
||||||
|
DISPLAY_PARAM(m_array_cg);
|
||||||
|
DISPLAY_PARAM(m_array_always_prop_upward);
|
||||||
|
DISPLAY_PARAM(m_array_lazy_ieq);
|
||||||
|
DISPLAY_PARAM(m_array_lazy_ieq_delay);
|
||||||
|
}
|
|
@ -71,6 +71,7 @@ struct theory_array_params : public array_simplifier_params {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,14 @@ void theory_bv_params::updt_params(params_ref const & _p) {
|
||||||
m_bv_reflect = p.bv_reflect();
|
m_bv_reflect = p.bv_reflect();
|
||||||
m_bv_enable_int2bv2int = p.bv_enable_int2bv();
|
m_bv_enable_int2bv2int = p.bv_enable_int2bv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void theory_bv_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_bv_mode);
|
||||||
|
DISPLAY_PARAM(m_bv_reflect);
|
||||||
|
DISPLAY_PARAM(m_bv_lazy_le);
|
||||||
|
DISPLAY_PARAM(m_bv_cc);
|
||||||
|
DISPLAY_PARAM(m_bv_blast_max_size);
|
||||||
|
DISPLAY_PARAM(m_bv_enable_int2bv2int);
|
||||||
|
}
|
|
@ -44,6 +44,8 @@ struct theory_bv_params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* THEORY_BV_PARAMS_H_ */
|
#endif /* THEORY_BV_PARAMS_H_ */
|
||||||
|
|
|
@ -31,6 +31,8 @@ struct theory_datatype_params {
|
||||||
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");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void display(std::ostream & out) const { out << "m_dt_lazy_splits=" << m_dt_lazy_splits << std::endl; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,3 +26,12 @@ void theory_pb_params::updt_params(params_ref const & _p) {
|
||||||
m_pb_enable_compilation = p.pb_enable_compilation();
|
m_pb_enable_compilation = p.pb_enable_compilation();
|
||||||
m_pb_enable_simplex = p.pb_enable_simplex();
|
m_pb_enable_simplex = p.pb_enable_simplex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
|
||||||
|
|
||||||
|
void theory_pb_params::display(std::ostream & out) const {
|
||||||
|
DISPLAY_PARAM(m_pb_conflict_frequency);
|
||||||
|
DISPLAY_PARAM(m_pb_learn_complements);
|
||||||
|
DISPLAY_PARAM(m_pb_enable_compilation);
|
||||||
|
DISPLAY_PARAM(m_pb_enable_simplex);
|
||||||
|
}
|
|
@ -35,6 +35,8 @@ struct theory_pb_params {
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void updt_params(params_ref const & p);
|
void updt_params(params_ref const & p);
|
||||||
|
|
||||||
|
void display(std::ostream & out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* THEORY_PB_PARAMS_H_ */
|
#endif /* THEORY_PB_PARAMS_H_ */
|
||||||
|
|
|
@ -109,10 +109,7 @@ namespace smt {
|
||||||
}
|
}
|
||||||
scoped_minimize_core scm(*this);
|
scoped_minimize_core scm(*this);
|
||||||
mus mus(*this);
|
mus mus(*this);
|
||||||
|
mus.add_soft(r.size(), r.c_ptr());
|
||||||
for (unsigned i = 0; i < r.size(); ++i) {
|
|
||||||
VERIFY(i == mus.add_soft(r[i]));
|
|
||||||
}
|
|
||||||
ptr_vector<expr> r2;
|
ptr_vector<expr> r2;
|
||||||
if (l_true == mus.get_mus(r2)) {
|
if (l_true == mus.get_mus(r2)) {
|
||||||
r.reset();
|
r.reset();
|
||||||
|
|
|
@ -22,7 +22,7 @@ Notes:
|
||||||
#include "mus.h"
|
#include "mus.h"
|
||||||
#include "ast_pp.h"
|
#include "ast_pp.h"
|
||||||
#include "ast_util.h"
|
#include "ast_util.h"
|
||||||
#include "uint_set.h"
|
#include "model_evaluator.h"
|
||||||
|
|
||||||
|
|
||||||
struct mus::imp {
|
struct mus::imp {
|
||||||
|
@ -59,7 +59,7 @@ struct mus::imp {
|
||||||
unsigned idx = m_lit2expr.size();
|
unsigned idx = m_lit2expr.size();
|
||||||
m_expr2lit.insert(lit, idx);
|
m_expr2lit.insert(lit, idx);
|
||||||
m_lit2expr.push_back(lit);
|
m_lit2expr.push_back(lit);
|
||||||
TRACE("opt", tout << idx << ": " << mk_pp(lit, m) << "\n" << m_lit2expr << "\n";);
|
TRACE("mus", tout << idx << ": " << mk_pp(lit, m) << "\n" << m_lit2expr << "\n";);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,42 +68,30 @@ struct mus::imp {
|
||||||
m_assumptions.push_back(lit);
|
m_assumptions.push_back(lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool get_mus(ptr_vector<expr>& mus) {
|
lbool get_mus(expr_ref_vector& mus) {
|
||||||
unsigned_vector result;
|
|
||||||
lbool r = get_mus(result);
|
|
||||||
ids2exprs(mus, result);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
lbool get_mus(unsigned_vector& mus_ids) {
|
|
||||||
// SASSERT: mus_ids does not have duplicates.
|
|
||||||
m_model.reset();
|
m_model.reset();
|
||||||
mus_ids.reset();
|
mus.reset();
|
||||||
|
|
||||||
if (m_lit2expr.size() == 1) {
|
if (m_lit2expr.size() == 1) {
|
||||||
mus_ids.push_back(0);
|
mus.push_back(m_lit2expr.back());
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
|
return get_mus1(mus);
|
||||||
return get_mus1(mus_ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool get_mus1(unsigned_vector& mus_ids) {
|
lbool get_mus(ptr_vector<expr>& mus) {
|
||||||
expr_ref_vector mus(m);
|
mus.reset();
|
||||||
lbool result = get_mus1(mus);
|
expr_ref_vector result(m);
|
||||||
for (unsigned i = 0; i < mus.size(); ++i) {
|
lbool r = get_mus(result);
|
||||||
mus_ids.push_back(m_expr2lit.find(mus[i].get()));
|
mus.append(result.size(), result.c_ptr());
|
||||||
}
|
return r;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lbool get_mus1(expr_ref_vector& mus) {
|
lbool get_mus1(expr_ref_vector& mus) {
|
||||||
ptr_vector<expr> unknown(m_lit2expr.size(), m_lit2expr.c_ptr());
|
ptr_vector<expr> unknown(m_lit2expr.size(), m_lit2expr.c_ptr());
|
||||||
ptr_vector<expr> core_exprs;
|
ptr_vector<expr> core_exprs;
|
||||||
while (!unknown.empty()) {
|
while (!unknown.empty()) {
|
||||||
IF_VERBOSE(12, verbose_stream() << "(opt.mus reducing core: " << unknown.size() << " new core: " << mus.size() << ")\n";);
|
IF_VERBOSE(12, verbose_stream() << "(mus reducing core: " << unknown.size() << " new core: " << mus.size() << ")\n";);
|
||||||
TRACE("opt", display_vec(tout << "core: ", unknown); display_vec(tout << "mus: ", mus););
|
TRACE("mus", display_vec(tout << "core: ", unknown); display_vec(tout << "mus: ", mus););
|
||||||
expr* lit = unknown.back();
|
expr* lit = unknown.back();
|
||||||
unknown.pop_back();
|
unknown.pop_back();
|
||||||
expr_ref not_lit(mk_not(m, lit), m);
|
expr_ref not_lit(mk_not(m, lit), m);
|
||||||
|
@ -132,7 +120,7 @@ struct mus::imp {
|
||||||
unknown.push_back(core_exprs[i]);
|
unknown.push_back(core_exprs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("opt", display_vec(tout << "core exprs:", core_exprs);
|
TRACE("mus", display_vec(tout << "core exprs:", core_exprs);
|
||||||
display_vec(tout << "core:", unknown);
|
display_vec(tout << "core:", unknown);
|
||||||
display_vec(tout << "mus:", mus);
|
display_vec(tout << "mus:", mus);
|
||||||
);
|
);
|
||||||
|
@ -147,42 +135,51 @@ struct mus::imp {
|
||||||
|
|
||||||
// use correction sets
|
// use correction sets
|
||||||
lbool get_mus2(expr_ref_vector& mus) {
|
lbool get_mus2(expr_ref_vector& mus) {
|
||||||
scoped_append _sa1(*this, mus, m_assumptions);
|
expr* lit = 0;
|
||||||
|
lbool is_sat;
|
||||||
ptr_vector<expr> unknown(m_lit2expr.size(), m_lit2expr.c_ptr());
|
ptr_vector<expr> unknown(m_lit2expr.size(), m_lit2expr.c_ptr());
|
||||||
while (!unknown.empty()) {
|
while (!unknown.empty()) {
|
||||||
expr* lit;
|
IF_VERBOSE(12, verbose_stream() << "(mus reducing core: " << unknown.size() << " new core: " << mus.size() << ")\n";);
|
||||||
lbool is_sat = get_next_mcs(mus, unknown, lit);
|
{
|
||||||
switch (is_sat) {
|
scoped_append _sa1(*this, mus, m_assumptions);
|
||||||
case l_undef:
|
is_sat = get_next_mcs(mus, unknown, lit);
|
||||||
return is_sat;
|
}
|
||||||
case l_false:
|
if (l_false == is_sat) {
|
||||||
mus.push_back(lit);
|
mus.push_back(lit);
|
||||||
break;
|
}
|
||||||
case l_true:
|
else {
|
||||||
break;
|
return is_sat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SASSERT(is_core(mus));
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the next literal to be a member of a core.
|
// find the next literal to be a member of a core.
|
||||||
lbool get_next_mcs(expr_ref_vector& mus, ptr_vector<expr>& unknown, expr*& core_literal) {
|
lbool get_next_mcs(expr_ref_vector& mus, ptr_vector<expr>& unknown, expr*& core_literal) {
|
||||||
ptr_vector<expr> mss, core, min_core;
|
ptr_vector<expr> mss;
|
||||||
|
expr_ref_vector nmcs(m);
|
||||||
|
expr_set core, min_core, nmcs_set;
|
||||||
bool min_core_valid = false;
|
bool min_core_valid = false;
|
||||||
expr* min_lit = 0;
|
expr* min_lit = 0;
|
||||||
while (!unknown.empty()) {
|
while (!unknown.empty()) {
|
||||||
expr* lit = unknown.back();
|
expr* lit = unknown.back();
|
||||||
unknown.pop_back();
|
unknown.pop_back();
|
||||||
model_ref mdl;
|
model_ref mdl;
|
||||||
scoped_append assume_mss(*this, mus, mss);
|
scoped_append assume_mss(*this, mus, mss); // current satisfied literals
|
||||||
scoped_append assume_lit(*this, mus, lit);
|
scoped_append assume_nmcs(*this, mus, nmcs); // current non-satisfied literals
|
||||||
|
scoped_append assume_lit(*this, mus, lit); // current unknown literal
|
||||||
switch (m_solver.check_sat(mus)) {
|
switch (m_solver.check_sat(mus)) {
|
||||||
case l_true:
|
case l_true: {
|
||||||
|
TRACE("mus", tout << "literal can be satisfied: " << mk_pp(lit, m) << "\n";);
|
||||||
mss.push_back(lit);
|
mss.push_back(lit);
|
||||||
m_solver.get_model(mdl);
|
m_solver.get_model(mdl);
|
||||||
|
model_evaluator eval(*mdl.get());
|
||||||
for (unsigned i = 0; i < unknown.size(); ) {
|
for (unsigned i = 0; i < unknown.size(); ) {
|
||||||
expr_ref tmp(m);
|
expr_ref tmp(m);
|
||||||
if (mdl->eval(unknown[i], tmp) && m.is_true(tmp)) {
|
eval(unknown[i], tmp);
|
||||||
|
if (m.is_true(tmp)) {
|
||||||
mss.push_back(unknown[i]);
|
mss.push_back(unknown[i]);
|
||||||
unknown[i] = unknown.back();
|
unknown[i] = unknown.back();
|
||||||
unknown.pop_back();
|
unknown.pop_back();
|
||||||
|
@ -192,16 +189,27 @@ struct mus::imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case l_false:
|
case l_false:
|
||||||
core.reset();
|
TRACE("mus", tout << "literal is in a core: " << mk_pp(lit, m) << "\n";);
|
||||||
m_solver.get_unsat_core(core);
|
nmcs.push_back(mk_not(m, lit));
|
||||||
// ???
|
nmcs_set.insert(nmcs.back());
|
||||||
|
get_core(core);
|
||||||
if (!core.contains(lit)) {
|
if (!core.contains(lit)) {
|
||||||
return l_false;
|
// The current mus is already a core.
|
||||||
|
unknown.reset();
|
||||||
|
return l_true;
|
||||||
|
}
|
||||||
|
if (have_intersection(nmcs_set, core)) {
|
||||||
|
// can't use this core directly. Hypothetically, we
|
||||||
|
// could try to combine min_core with core and
|
||||||
|
// see if the combination produces a better minimal core.
|
||||||
|
SASSERT(min_core_valid);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!min_core_valid || core.size() < min_core.size()) {
|
if (!min_core_valid || core.size() < min_core.size()) {
|
||||||
min_core.reset();
|
// The current core is smallest so far, so we get fewer unknowns from it.
|
||||||
min_core.append(core);
|
min_core = core;
|
||||||
min_core_valid = true;
|
min_core_valid = true;
|
||||||
min_lit = lit;
|
min_lit = lit;
|
||||||
}
|
}
|
||||||
|
@ -210,66 +218,57 @@ struct mus::imp {
|
||||||
return l_undef;
|
return l_undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SASSERT(min_core_valid);
|
||||||
if (!min_core_valid) {
|
if (!min_core_valid) {
|
||||||
// ???
|
// all unknown soft constraints were satisfiable
|
||||||
UNREACHABLE();
|
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (unsigned i = 0; i < min_core.size(); ++i) {
|
expr_set mss_set;
|
||||||
if (mss.contains(min_core[i]) && min_lit != min_core[i]) {
|
for (unsigned i = 0; i < mss.size(); ++i) {
|
||||||
unknown.push_back(min_core[i]);
|
mss_set.insert(mss[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
core_literal = min_lit;
|
|
||||||
}
|
}
|
||||||
|
expr_set::iterator it = min_core.begin(), end = min_core.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
if (mss_set.contains(*it) && min_lit != *it) {
|
||||||
|
unknown.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
core_literal = min_lit;
|
||||||
|
|
||||||
return l_false;
|
return l_false;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr* lit2expr(unsigned lit_id) const {
|
bool have_intersection(expr_set const& A, expr_set const& B) {
|
||||||
return m_lit2expr[lit_id];
|
if (A.size() < B.size()) {
|
||||||
}
|
expr_set::iterator it = A.begin(), end = A.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
void ids2exprs(ptr_vector<expr>& dst, unsigned_vector const& ids) const {
|
if (B.contains(*it)) return true;
|
||||||
for (unsigned i = 0; i < ids.size(); ++i) {
|
|
||||||
dst.push_back(lit2expr(ids[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_core(unsigned_vector const& mus_ids) {
|
|
||||||
ptr_vector<expr> mus_exprs;
|
|
||||||
ids2exprs(mus_exprs, mus_ids);
|
|
||||||
return l_false == m_solver.check_sat(mus_exprs.size(), mus_exprs.c_ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
// dst := A \ B
|
|
||||||
void set_difference(unsigned_vector& dst, ptr_vector<expr> const& A, unsigned_vector const& B) {
|
|
||||||
dst.reset();
|
|
||||||
for (unsigned i = 0; i < A.size(); ++i) {
|
|
||||||
unsigned lit_id;
|
|
||||||
if (m_expr2lit.find(A[i], lit_id) && !B.contains(lit_id)) {
|
|
||||||
dst.push_back(lit_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expr_set::iterator it = B.begin(), end = B.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
if (A.contains(*it)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_core(expr_ref_vector const& mus) {
|
||||||
|
return l_false == m_solver.check_sat(mus);
|
||||||
}
|
}
|
||||||
|
|
||||||
class scoped_append {
|
class scoped_append {
|
||||||
expr_ref_vector& m_fmls;
|
expr_ref_vector& m_fmls;
|
||||||
unsigned m_size;
|
unsigned m_size;
|
||||||
public:
|
public:
|
||||||
scoped_append(imp& imp, expr_ref_vector& fmls1, unsigned_vector const& fmls2):
|
scoped_append(imp& imp, expr_ref_vector& fmls1, expr_set const& fmls2):
|
||||||
m_fmls(fmls1),
|
m_fmls(fmls1),
|
||||||
m_size(fmls1.size()) {
|
m_size(fmls1.size()) {
|
||||||
for (unsigned i = 0; i < fmls2.size(); ++i) {
|
expr_set::iterator it = fmls2.begin(), end = fmls2.end();
|
||||||
fmls1.push_back(imp.lit2expr(fmls2[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scoped_append(imp& imp, expr_ref_vector& fmls1, uint_set const& fmls2):
|
|
||||||
m_fmls(fmls1),
|
|
||||||
m_size(fmls1.size()) {
|
|
||||||
uint_set::iterator it = fmls2.begin(), end = fmls2.end();
|
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
fmls1.push_back(imp.lit2expr(*it));
|
fmls1.push_back(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scoped_append(imp& imp, expr_ref_vector& fmls1, expr_ref_vector const& fmls2):
|
scoped_append(imp& imp, expr_ref_vector& fmls1, expr_ref_vector const& fmls2):
|
||||||
|
@ -292,12 +291,6 @@ struct mus::imp {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void add_core(unsigned_vector const& core, expr_ref_vector& assumptions) {
|
|
||||||
for (unsigned i = 0; i < core.size(); ++i) {
|
|
||||||
assumptions.push_back(lit2expr(core[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void display_vec(std::ostream& out, T const& v) const {
|
void display_vec(std::ostream& out, T const& v) const {
|
||||||
for (unsigned i = 0; i < v.size(); ++i) {
|
for (unsigned i = 0; i < v.size(); ++i) {
|
||||||
|
@ -353,14 +346,14 @@ struct mus::imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lbool qx(unsigned_vector& mus) {
|
lbool qx(expr_ref_vector& mus) {
|
||||||
uint_set core, support;
|
expr_set core, support;
|
||||||
for (unsigned i = 0; i < m_lit2expr.size(); ++i) {
|
for (unsigned i = 0; i < m_lit2expr.size(); ++i) {
|
||||||
core.insert(i);
|
core.insert(m_lit2expr[i].get());
|
||||||
}
|
}
|
||||||
lbool is_sat = qx(core, support, false);
|
lbool is_sat = qx(core, support, false);
|
||||||
if (is_sat == l_true) {
|
if (is_sat == l_true) {
|
||||||
uint_set::iterator it = core.begin(), end = core.end();
|
expr_set::iterator it = core.begin(), end = core.end();
|
||||||
mus.reset();
|
mus.reset();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
mus.push_back(*it);
|
mus.push_back(*it);
|
||||||
|
@ -369,7 +362,7 @@ struct mus::imp {
|
||||||
return is_sat;
|
return is_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool qx(uint_set& assignment, uint_set& support, bool has_support) {
|
lbool qx(expr_set& assignment, expr_set& support, bool has_support) {
|
||||||
lbool is_sat = l_true;
|
lbool is_sat = l_true;
|
||||||
#if 0
|
#if 0
|
||||||
if (s.m_config.m_minimize_core_partial && s.m_stats.m_restart - m_restart > m_max_restarts) {
|
if (s.m_config.m_minimize_core_partial && s.m_stats.m_restart - m_restart > m_max_restarts) {
|
||||||
|
@ -384,7 +377,7 @@ struct mus::imp {
|
||||||
is_sat = m_solver.check_sat(asms);
|
is_sat = m_solver.check_sat(asms);
|
||||||
switch (is_sat) {
|
switch (is_sat) {
|
||||||
case l_false: {
|
case l_false: {
|
||||||
uint_set core;
|
expr_set core;
|
||||||
get_core(core);
|
get_core(core);
|
||||||
support &= core;
|
support &= core;
|
||||||
assignment.reset();
|
assignment.reset();
|
||||||
|
@ -399,10 +392,10 @@ struct mus::imp {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (assignment.num_elems() == 1) {
|
if (assignment.size() == 1) {
|
||||||
return l_true;
|
return l_true;
|
||||||
}
|
}
|
||||||
uint_set assign2;
|
expr_set assign2;
|
||||||
split(assignment, assign2);
|
split(assignment, assign2);
|
||||||
support |= assignment;
|
support |= assignment;
|
||||||
is_sat = qx(assign2, support, !assignment.empty());
|
is_sat = qx(assign2, support, !assignment.empty());
|
||||||
|
@ -415,20 +408,20 @@ struct mus::imp {
|
||||||
return is_sat;
|
return is_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_core(uint_set& core) {
|
void get_core(expr_set& core) {
|
||||||
|
core.reset();
|
||||||
ptr_vector<expr> core_exprs;
|
ptr_vector<expr> core_exprs;
|
||||||
unsigned lit_id;
|
|
||||||
m_solver.get_unsat_core(core_exprs);
|
m_solver.get_unsat_core(core_exprs);
|
||||||
for (unsigned i = 0; i < core_exprs.size(); ++i) {
|
for (unsigned i = 0; i < core_exprs.size(); ++i) {
|
||||||
if (m_expr2lit.find(core_exprs[i], lit_id)) {
|
if (m_expr2lit.contains(core_exprs[i])) {
|
||||||
core.insert(lit_id);
|
core.insert(core_exprs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unsplit(uint_set& A, uint_set& B) {
|
void unsplit(expr_set& A, expr_set& B) {
|
||||||
uint_set A1, B1;
|
expr_set A1, B1;
|
||||||
uint_set::iterator it = A.begin(), end = A.end();
|
expr_set::iterator it = A.begin(), end = A.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (B.contains(*it)) {
|
if (B.contains(*it)) {
|
||||||
B1.insert(*it);
|
B1.insert(*it);
|
||||||
|
@ -441,10 +434,10 @@ struct mus::imp {
|
||||||
B = B1;
|
B = B1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void split(uint_set& lits1, uint_set& lits2) {
|
void split(expr_set& lits1, expr_set& lits2) {
|
||||||
unsigned half = lits1.num_elems()/2;
|
unsigned half = lits1.size()/2;
|
||||||
uint_set lits3;
|
expr_set lits3;
|
||||||
uint_set::iterator it = lits1.begin(), end = lits1.end();
|
expr_set::iterator it = lits1.begin(), end = lits1.end();
|
||||||
for (unsigned i = 0; it != end; ++it, ++i) {
|
for (unsigned i = 0; it != end; ++it, ++i) {
|
||||||
if (i < half) {
|
if (i < half) {
|
||||||
lits3.insert(*it);
|
lits3.insert(*it);
|
||||||
|
@ -474,7 +467,11 @@ void mus::add_assumption(expr* lit) {
|
||||||
return m_imp->add_assumption(lit);
|
return m_imp->add_assumption(lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbool mus::get_mus(unsigned_vector& mus) {
|
lbool mus::get_mus(ptr_vector<expr>& mus) {
|
||||||
|
return m_imp->get_mus(mus);
|
||||||
|
}
|
||||||
|
|
||||||
|
lbool mus::get_mus(expr_ref_vector& mus) {
|
||||||
return m_imp->get_mus(mus);
|
return m_imp->get_mus(mus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ class mus {
|
||||||
*/
|
*/
|
||||||
unsigned add_soft(expr* cls);
|
unsigned add_soft(expr* cls);
|
||||||
|
|
||||||
|
void add_soft(unsigned sz, expr* const* clss) {
|
||||||
|
for (unsigned i = 0; i < sz; ++i) add_soft(clss[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Additional assumption for solver to be used along with solver context,
|
Additional assumption for solver to be used along with solver context,
|
||||||
but not used in core computation. This facility is useful when querying
|
but not used in core computation. This facility is useful when querying
|
||||||
|
@ -43,8 +47,6 @@ class mus {
|
||||||
*/
|
*/
|
||||||
void add_assumption(expr* lit);
|
void add_assumption(expr* lit);
|
||||||
|
|
||||||
lbool get_mus(unsigned_vector& mus);
|
|
||||||
|
|
||||||
lbool get_mus(ptr_vector<expr>& mus);
|
lbool get_mus(ptr_vector<expr>& mus);
|
||||||
|
|
||||||
lbool get_mus(expr_ref_vector& mus);
|
lbool get_mus(expr_ref_vector& mus);
|
||||||
|
|
|
@ -556,6 +556,38 @@ public:
|
||||||
out << "]";
|
out << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core_hashtable& operator|=(core_hashtable const& other) {
|
||||||
|
if (this == &other) return *this;
|
||||||
|
iterator i = begin(), e = end();
|
||||||
|
for (; i != e; ++i) {
|
||||||
|
insert(*i);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
core_hashtable& operator&=(core_hashtable const& other) {
|
||||||
|
if (this == &other) return *this;
|
||||||
|
core_hashtable copy(*this);
|
||||||
|
iterator i = copy.begin(), e = copy.end();
|
||||||
|
for (; i != e; ++i) {
|
||||||
|
if (!other.contains(*i)) {
|
||||||
|
remove(*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
core_hashtable& operator=(core_hashtable const& other) {
|
||||||
|
if (this == &other) return *this;
|
||||||
|
reset();
|
||||||
|
core_hashtable::iterator i = other.begin(), e = other.end();
|
||||||
|
for (; i != e; ++i) {
|
||||||
|
insert(*i);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Z3DEBUG
|
#ifdef Z3DEBUG
|
||||||
bool check_invariant() {
|
bool check_invariant() {
|
||||||
entry * curr = m_table;
|
entry * curr = m_table;
|
||||||
|
@ -582,9 +614,6 @@ public:
|
||||||
unsigned long long get_num_collision() const { return 0; }
|
unsigned long long get_num_collision() const { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
core_hashtable& operator=(core_hashtable const&);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -640,4 +669,5 @@ public:
|
||||||
core_hashtable<int_hash_entry<INT_MIN, INT_MIN + 1>, HashProc, EqProc>(initial_capacity, h, e) {}
|
core_hashtable<int_hash_entry<INT_MIN, INT_MIN + 1>, HashProc, EqProc>(initial_capacity, h, e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* HASHTABLE_H_ */
|
#endif /* HASHTABLE_H_ */
|
||||||
|
|
|
@ -51,6 +51,7 @@ class obj_hashtable : public core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>,
|
||||||
public:
|
public:
|
||||||
obj_hashtable(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY):
|
obj_hashtable(unsigned initial_capacity = DEFAULT_HASHTABLE_INITIAL_CAPACITY):
|
||||||
core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>, ptr_eq<T> >(initial_capacity) {}
|
core_hashtable<obj_hash_entry<T>, obj_ptr_hash<T>, ptr_eq<T> >(initial_capacity) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Key, typename Value>
|
template<typename Key, typename Value>
|
||||||
|
|
Loading…
Reference in a new issue