3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-14 01:46:15 +00:00

merge with unstable

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-04-30 10:40:03 -07:00
commit 9377779e58
54 changed files with 20581 additions and 20354 deletions

View file

@ -1,11 +1,52 @@
import os import os
import shutil import shutil
import re import re
import getopt
import pydoc import pydoc
import sys import sys
import subprocess import subprocess
import shutil import shutil
ML_ENABLED=False
BUILD_DIR='../build'
def norm_path(p):
# We use '/' on mk_project for convenience
return os.path.join(*(p.split('/')))
def display_help(exit_code):
print("mk_api_doc.py: Z3 documentation generator\n")
print("\nOptions:")
print(" -h, --help display this message.")
print(" -b <subdir>, --build=<subdir> subdirectory where Z3 is built (default: ../build).")
print(" --ml include ML/OCaml API documentation.")
def parse_options():
global ML_ENABLED, BUILD_DIR
try:
options, remainder = getopt.gnu_getopt(sys.argv[1:],
'b:h',
['build=', 'help', 'ml'])
except:
print("ERROR: Invalid command line option")
display_help(1)
for opt, arg in options:
if opt in ('-b', '--build'):
BUILD_DIR = norm_path(arg)
elif opt in ('h', '--help'):
display_help()
exit(1)
elif opt in ('--ml'):
ML_ENABLED=True
else:
print("ERROR: Invalid command line option: %s" % opt)
display_help(1)
def mk_dir(d): def mk_dir(d):
if not os.path.exists(d): if not os.path.exists(d):
os.makedirs(d) os.makedirs(d)
@ -22,9 +63,23 @@ def cleanup_API(inf, outf):
_outf.write(line) _outf.write(line)
try: try:
parse_options()
fi = open('website.dox', 'r')
fo = open('website-adj.dox', 'w')
for line in fi:
if (line != '[ML]\n'):
fo.write(line)
elif (ML_ENABLED):
fo.write(' - <a class="el" href="ml/index.html">ML/OCaml API</a>\n')
fi.close()
fo.close()
mk_dir('api/html') mk_dir('api/html')
mk_dir('tmp') mk_dir('tmp')
shutil.copyfile('website.dox', 'tmp/website.dox') shutil.copyfile('website-adj.dox', 'tmp/website.dox')
os.remove('website-adj.dox')
shutil.copyfile('../src/api/python/z3.py', 'tmp/z3py.py') shutil.copyfile('../src/api/python/z3.py', 'tmp/z3py.py')
cleanup_API('../src/api/z3_api.h', 'tmp/z3_api.h') cleanup_API('../src/api/z3_api.h', 'tmp/z3_api.h')
cleanup_API('../src/api/z3_algebraic.h', 'tmp/z3_algebraic.h') cleanup_API('../src/api/z3_algebraic.h', 'tmp/z3_algebraic.h')
@ -59,6 +114,14 @@ try:
pydoc.writedoc('z3') pydoc.writedoc('z3')
shutil.move('z3.html', 'api/html/z3.html') shutil.move('z3.html', 'api/html/z3.html')
print "Generated Python documentation." print "Generated Python documentation."
if ML_ENABLED:
mk_dir('api/html/ml')
if subprocess.call(['ocamldoc', '-html', '-d', 'api\html\ml', '-sort', '-hide', 'Z3', '-I', '%s/api/ml' % BUILD_DIR, '../src/api/ml/z3enums.mli', '../src/api/ml/z3.mli']) != 0:
print "ERROR: ocamldoc failed."
exit(1)
print "Generated ML/OCaml documentation."
print "Documentation was successfully generated at subdirectory './api/html'." print "Documentation was successfully generated at subdirectory './api/html'."
except: except:
print "ERROR: failed to generate documentation" print "ERROR: failed to generate documentation"

View file

@ -4,9 +4,9 @@
Z3 is a high-performance theorem prover being developed at <a class="el" Z3 is a high-performance theorem prover being developed at <a class="el"
href="http://research.microsoft.com">Microsoft Research</a>. href="http://research.microsoft.com">Microsoft Research</a>.
<b>The Z3 website moved to <a class="el" href="http://z3.codeplex.com">z3.codeplex.com</a>.</b> <b>The Z3 website moved to <a class="el" href="http://github.com/z3prover">http://github.com/z3prover.</a>.</b>
The old Z3 website can be found <a class="el" href="http://research.microsoft.com/en-us/um/redmond/projects/z3/old/index.html">here</a>. The old Z3 websites can be found <a class="el" href="http://research.microsoft.com/en-us/um/redmond/projects/z3/old/index.html">here</a> and <a href="http://z3.codeplex.com">here</a>.
This website hosts the automatically generated documentation for the Z3 APIs. This website hosts the automatically generated documentation for the Z3 APIs.
@ -14,6 +14,7 @@
- \ref cppapi - \ref cppapi
- <a class="el" href="class_microsoft_1_1_z3_1_1_context.html">.NET API</a> - <a class="el" href="class_microsoft_1_1_z3_1_1_context.html">.NET API</a>
- <a class="el" href="namespacecom_1_1microsoft_1_1z3.html">Java API</a> - <a class="el" href="namespacecom_1_1microsoft_1_1z3.html">Java API</a>
- <a class="el" href="namespacez3py.html">Python API</a> (also available in <a class="el" href="z3.html">pydoc format</a>). - <a class="el" href="namespacez3py.html">Python API</a> (also available in <a class="el" href="z3.html">pydoc format</a>)
[ML]
- Try Z3 online at <a href="http://rise4fun.com/z3">RiSE4Fun</a>. - Try Z3 online at <a href="http://rise4fun.com/z3">RiSE4Fun</a>.
*/ */

View file

@ -47,16 +47,16 @@ def set_build_dir(path):
mk_dir(BUILD_X64_DIR) mk_dir(BUILD_X64_DIR)
def display_help(): def display_help():
print "mk_win_dist.py: Z3 Windows distribution generator\n" print("mk_win_dist.py: Z3 Windows distribution generator\n")
print "This script generates the zip files containing executables, dlls, header files for Windows." print("This script generates the zip files containing executables, dlls, header files for Windows.")
print "It must be executed from the Z3 root directory." print("It must be executed from the Z3 root directory.")
print "\nOptions:" print("\nOptions:")
print " -h, --help display this message." print(" -h, --help display this message.")
print " -s, --silent do not print verbose messages." print(" -s, --silent do not print verbose messages.")
print " -b <sudir>, --build=<subdir> subdirectory where x86 and x64 Z3 versions will be built (default: build-dist)." print(" -b <sudir>, --build=<subdir> subdirectory where x86 and x64 Z3 versions will be built (default: build-dist).")
print " -f, --force force script to regenerate Makefiles." print(" -f, --force force script to regenerate Makefiles.")
print " --nojava do not include Java bindings in the binary distribution files." print(" --nojava do not include Java bindings in the binary distribution files.")
print " --githash include git hash in the Zip file." print(" --githash include git hash in the Zip file.")
exit(0) exit(0)
# Parse configuration option for mk_make script # Parse configuration option for mk_make script
@ -180,7 +180,7 @@ def mk_dist_dir_core(x64):
mk_util.JAVA_ENABLED = JAVA_ENABLED mk_util.JAVA_ENABLED = JAVA_ENABLED
mk_win_dist(build_path, dist_path) mk_win_dist(build_path, dist_path)
if is_verbose(): if is_verbose():
print "Generated %s distribution folder at '%s'" % (platform, dist_path) print("Generated %s distribution folder at '%s'") % (platform, dist_path)
def mk_dist_dir(): def mk_dist_dir():
mk_dist_dir_core(False) mk_dist_dir_core(False)
@ -208,7 +208,7 @@ def mk_zip_core(x64):
ZIPOUT = zipfile.ZipFile(zfname, 'w', zipfile.ZIP_DEFLATED) ZIPOUT = zipfile.ZipFile(zfname, 'w', zipfile.ZIP_DEFLATED)
os.path.walk(dist_path, mk_zip_visitor, '*') os.path.walk(dist_path, mk_zip_visitor, '*')
if is_verbose(): if is_verbose():
print "Generated '%s'" % zfname print("Generated '%s'") % zfname
except: except:
pass pass
ZIPOUT = None ZIPOUT = None
@ -253,7 +253,7 @@ def cp_vs_runtime_core(x64):
for f in VS_RUNTIME_FILES: for f in VS_RUNTIME_FILES:
shutil.copy(f, bin_dist_path) shutil.copy(f, bin_dist_path)
if is_verbose(): if is_verbose():
print "Copied '%s' to '%s'" % (f, bin_dist_path) print("Copied '%s' to '%s'") % (f, bin_dist_path)
def cp_vs_runtime(): def cp_vs_runtime():
cp_vs_runtime_core(True) cp_vs_runtime_core(True)

View file

@ -1,20 +1,20 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
api_interp.cpp api_interp.cpp
Abstract: Abstract:
API for interpolation API for interpolation
Author: Author:
Ken McMillan Ken McMillan
Revision History: Revision History:
--*/ --*/
#include<iostream> #include<iostream>
#include<sstream> #include<sstream>
#include<vector> #include<vector>
@ -643,69 +643,69 @@ extern "C" {
#define IZ3_ROOT SHRT_MAX #define IZ3_ROOT SHRT_MAX
/** This function uses Z3 to determine satisfiability of a set of /** This function uses Z3 to determine satisfiability of a set of
constraints. If UNSAT, an interpolant is returned, based on the constraints. If UNSAT, an interpolant is returned, based on the
refutation generated by Z3. If SAT, a model is returned. refutation generated by Z3. If SAT, a model is returned.
If "parents" is non-null, computes a tree interpolant. The tree is If "parents" is non-null, computes a tree interpolant. The tree is
defined by the array "parents". This array maps each formula in defined by the array "parents". This array maps each formula in
the tree to its parent, where formulas are indicated by their the tree to its parent, where formulas are indicated by their
integer index in "cnsts". The parent of formula n must have index integer index in "cnsts". The parent of formula n must have index
greater than n. The last formula is the root of the tree. Its greater than n. The last formula is the root of the tree. Its
parent entry should be the constant IZ3_ROOT. parent entry should be the constant IZ3_ROOT.
If "parents" is null, computes a sequence interpolant. If "parents" is null, computes a sequence interpolant.
\param ctx The Z3 context. Must be generated by iz3_mk_context \param ctx The Z3 context. Must be generated by iz3_mk_context
\param num The number of constraints in the sequence \param num The number of constraints in the sequence
\param cnsts Array of constraints (AST's in context ctx) \param cnsts Array of constraints (AST's in context ctx)
\param parents The parents vector defining the tree structure \param parents The parents vector defining the tree structure
\param options Interpolation options (may be NULL) \param options Interpolation options (may be NULL)
\param interps Array to return interpolants (size at least num-1, may be NULL) \param interps Array to return interpolants (size at least num-1, may be NULL)
\param model Returns a Z3 model if constraints SAT (may be NULL) \param model Returns a Z3 model if constraints SAT (may be NULL)
\param labels Returns relevant labels if SAT (may be NULL) \param labels Returns relevant labels if SAT (may be NULL)
\param incremental \param incremental
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3 VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
context ctx. The model and interpolants returned are also context ctx. The model and interpolants returned are also
in this context. in this context.
The return code is as in Z3_check_assumptions, that is, The return code is as in Z3_check_assumptions, that is,
Z3_L_FALSE = constraints UNSAT (interpolants returned) Z3_L_FALSE = constraints UNSAT (interpolants returned)
Z3_L_TRUE = constraints SAT (model returned) Z3_L_TRUE = constraints SAT (model returned)
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
Currently, this function supports integer and boolean variables, Currently, this function supports integer and boolean variables,
as well as arrays over these types, with linear arithmetic, as well as arrays over these types, with linear arithmetic,
uninterpreted functions and quantifiers over integers (that is uninterpreted functions and quantifiers over integers (that is
AUFLIA). Interpolants are produced in AULIA. However, some AUFLIA). Interpolants are produced in AULIA. However, some
uses of array operations may cause quantifiers to appear in the uses of array operations may cause quantifiers to appear in the
interpolants even when there are no quantifiers in the input formulas. interpolants even when there are no quantifiers in the input formulas.
Although quantifiers may appear in the input formulas, Z3 may give up in Although quantifiers may appear in the input formulas, Z3 may give up in
this case, returning Z3_L_UNDEF. this case, returning Z3_L_UNDEF.
If "incremental" is true, cnsts must contain exactly the set of If "incremental" is true, cnsts must contain exactly the set of
formulas that are currently asserted in the context. If false, formulas that are currently asserted in the context. If false,
there must be no formulas currently asserted in the context. there must be no formulas currently asserted in the context.
Setting "incremental" to true makes it posisble to incrementally Setting "incremental" to true makes it posisble to incrementally
add and remove constraints from the context until the context add and remove constraints from the context until the context
becomes UNSAT, at which point an interpolant is computed. Caution becomes UNSAT, at which point an interpolant is computed. Caution
must be used, however. Before popping the context, if you wish to must be used, however. Before popping the context, if you wish to
keep the interolant formulas, you *must* preserve them by using keep the interolant formulas, you *must* preserve them by using
Z3_persist_ast. Also, if you want to simplify the interpolant Z3_persist_ast. Also, if you want to simplify the interpolant
formulas using Z3_simplify, you must first pop all of the formulas using Z3_simplify, you must first pop all of the
assertions in the context (or use a different context). Otherwise, assertions in the context (or use a different context). Otherwise,
the formulas will be simplified *relative* to these constraints, the formulas will be simplified *relative* to these constraints,
which is almost certainly not what you want. which is almost certainly not what you want.
Current limitations on tree interpolants. In a tree interpolation Current limitations on tree interpolants. In a tree interpolation
problem, each constant (0-ary function symbol) must occur only problem, each constant (0-ary function symbol) must occur only
along one path from root to leaf. Function symbols (of arity > 0) along one path from root to leaf. Function symbols (of arity > 0)
are considered to have global scope (i.e., may appear in any are considered to have global scope (i.e., may appear in any
interpolant formula). interpolant formula).
def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST))) def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST)))
*/ */
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx, Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,

View file

@ -2559,7 +2559,7 @@ namespace Microsoft.Z3
/// Create a bit-vector numeral. /// Create a bit-vector numeral.
/// </summary> /// </summary>
/// <param name="v">value of the numeral.</param> /// <param name="v">value of the numeral.</param>
/// /// <param name="size">the size of the bit-vector</param> /// <param name="size">the size of the bit-vector</param>
public BitVecNum MkBV(long v, uint size) public BitVecNum MkBV(long v, uint size)
{ {
Contract.Ensures(Contract.Result<BitVecNum>() != null); Contract.Ensures(Contract.Result<BitVecNum>() != null);

View file

@ -3212,7 +3212,7 @@ public class Context extends IDisposable
* @param rm rounding mode term * @param rm rounding mode term
* @param t1 floating-point term * @param t1 floating-point term
* @param t2 floating-point term * @param t2 floating-point term
* @param t3">floating-point term * @param t3 floating-point term
* Remarks: * Remarks:
* The result is round((t1 * t2) + t3) * The result is round((t1 * t2) + t3)
* @throws Z3Exception * @throws Z3Exception
@ -3247,7 +3247,7 @@ public class Context extends IDisposable
/** /**
* Floating-point roundToIntegral. Rounds a floating-point number to * Floating-point roundToIntegral. Rounds a floating-point number to
* the closest integer, again represented as a floating-point number. * the closest integer, again represented as a floating-point number.
* @param rm">term of RoundingMode sort * @param rm term of RoundingMode sort
* @param t floating-point term * @param t floating-point term
* @throws Z3Exception * @throws Z3Exception
**/ **/
@ -3425,7 +3425,7 @@ public class Context extends IDisposable
/** /**
* Conversion of a single IEEE 754-2008 bit-vector into a floating-point number. * Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
* @param bv">bit-vector value (of size m). * @param bv bit-vector value (of size m).
* @param s FloatingPoint sort (ebits+sbits == m) * @param s FloatingPoint sort (ebits+sbits == m)
* Remarks: * Remarks:
* Produces a term that represents the conversion of a bit-vector term bv to a * Produces a term that represents the conversion of a bit-vector term bv to a

View file

@ -8580,29 +8580,83 @@ def fpToFPUnsigned(rm, x, s):
return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx) return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx)
def fpToSBV(rm, x, s): def fpToSBV(rm, x, s):
"""Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.""" """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
>>> x = FP('x', FPSort(8, 24))
>>> y = fpToSBV(RTZ(), x, BitVecSort(32))
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False
"""
if __debug__: if __debug__:
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression") _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
_z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression") _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
_z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort") _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
return FPRef(Z3_mk_fpa_to_sbv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx) return BitVecRef(Z3_mk_fpa_to_sbv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
def fpToUBV(rm, x, s): def fpToUBV(rm, x, s):
"""Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.""" """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
>>> x = FP('x', FPSort(8, 24))
>>> y = fpToUBV(RTZ(), x, BitVecSort(32))
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False
"""
if __debug__: if __debug__:
_z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression") _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
_z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression") _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
_z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort") _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
return FPRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx) return BitVecRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
def fpToReal(x): def fpToReal(x):
"""Create a Z3 floating-point conversion expression, from floating-point expression to real.""" """Create a Z3 floating-point conversion expression, from floating-point expression to real.
>>> x = FP('x', FPSort(8, 24))
>>> y = fpToReal(x)
>>> print is_fp(x)
True
>>> print is_real(y)
True
>>> print is_fp(y)
False
>>> print is_real(x)
False
"""
if __debug__: if __debug__:
_z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression") _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
return FPRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx) return ArithRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx)
def fpToIEEEBV(x): def fpToIEEEBV(x):
"""Create a Z3 floating-point conversion expression, from floating-point expression to IEEE bit-vector.""" """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
The size of the resulting bit-vector is automatically determined.
Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
knows only one NaN and it will always produce the same bit-vector represenatation of
that NaN.
>>> x = FP('x', FPSort(8, 24))
>>> y = fpToIEEEBV(x)
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False
"""
if __debug__: if __debug__:
_z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression") _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
return FPRef(Z3_mk_fpa_to_ieee_bv(x.ctx_ref(), x.ast), x.ctx) return BitVecRef(Z3_mk_fpa_to_ieee_bv(x.ctx_ref(), x.ast), x.ctx)

View file

@ -1043,6 +1043,13 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters
case OP_DISTINCT: { case OP_DISTINCT: {
func_decl_info info(m_family_id, OP_DISTINCT); func_decl_info info(m_family_id, OP_DISTINCT);
info.set_pairwise(); info.set_pairwise();
for (unsigned i = 1; i < arity; i++) {
if (domain[i] != domain[0]) {
std::ostringstream buffer;
buffer << "Sort mismatch between first argument and argument " << (i+1);
throw ast_exception(buffer.str().c_str());
}
}
return m_manager->mk_func_decl(symbol("distinct"), arity, domain, m_bool_sort, info); return m_manager->mk_func_decl(symbol("distinct"), arity, domain, m_bool_sort, info);
} }
default: default:
@ -2340,6 +2347,10 @@ quantifier * ast_manager::update_quantifier(quantifier * q, bool is_forall, unsi
num_patterns == 0 ? q->get_no_patterns() : 0); num_patterns == 0 ? q->get_no_patterns() : 0);
} }
app * ast_manager::mk_distinct(unsigned num_args, expr * const * args) {
return mk_app(m_basic_family_id, OP_DISTINCT, num_args, args);
}
app * ast_manager::mk_distinct_expanded(unsigned num_args, expr * const * args) { app * ast_manager::mk_distinct_expanded(unsigned num_args, expr * const * args) {
if (num_args < 2) if (num_args < 2)
return mk_true(); return mk_true();

View file

@ -2000,7 +2000,7 @@ public:
app * mk_and(expr * arg1, expr * arg2, expr * arg3) { return mk_app(m_basic_family_id, OP_AND, arg1, arg2, arg3); } app * mk_and(expr * arg1, expr * arg2, expr * arg3) { return mk_app(m_basic_family_id, OP_AND, arg1, arg2, arg3); }
app * mk_implies(expr * arg1, expr * arg2) { return mk_app(m_basic_family_id, OP_IMPLIES, arg1, arg2); } app * mk_implies(expr * arg1, expr * arg2) { return mk_app(m_basic_family_id, OP_IMPLIES, arg1, arg2); }
app * mk_not(expr * n) { return mk_app(m_basic_family_id, OP_NOT, n); } app * mk_not(expr * n) { return mk_app(m_basic_family_id, OP_NOT, n); }
app * mk_distinct(unsigned num_args, expr * const * args) { return mk_app(m_basic_family_id, OP_DISTINCT, num_args, args); } app * mk_distinct(unsigned num_args, expr * const * args);
app * mk_distinct_expanded(unsigned num_args, expr * const * args); app * mk_distinct_expanded(unsigned num_args, expr * const * args);
app * mk_true() { return m_true; } app * mk_true() { return m_true; }
app * mk_false() { return m_false; } app * mk_false() { return m_false; }

View file

@ -2096,9 +2096,14 @@ void fpa2bv_converter::mk_to_fp_real(func_decl * f, sort * s, expr * rm, expr *
bool is_int; bool is_int;
m_util.au().is_numeral(x, q, is_int); m_util.au().is_numeral(x, q, is_int);
if (q.is_zero())
return mk_pzero(f, result);
else {
scoped_mpf v(m_mpf_manager); scoped_mpf v(m_mpf_manager);
m_util.fm().set(v, ebits, sbits, rm, q.to_mpq()); m_util.fm().set(v, ebits, sbits, rm, q.to_mpq());
expr_ref sgn(m), s(m), e(m), unbiased_exp(m); expr_ref sgn(m), s(m), e(m), unbiased_exp(m);
sgn = m_bv_util.mk_numeral((m_util.fm().sgn(v)) ? 1 : 0, 1); sgn = m_bv_util.mk_numeral((m_util.fm().sgn(v)) ? 1 : 0, 1);
s = m_bv_util.mk_numeral(m_util.fm().sig(v), sbits - 1); s = m_bv_util.mk_numeral(m_util.fm().sig(v), sbits - 1);
@ -2107,11 +2112,15 @@ void fpa2bv_converter::mk_to_fp_real(func_decl * f, sort * s, expr * rm, expr *
mk_fp(sgn, e, s, result); mk_fp(sgn, e, s, result);
} }
}
else if (m_util.au().is_numeral(x)) { else if (m_util.au().is_numeral(x)) {
rational q; rational q;
bool is_int; bool is_int;
m_util.au().is_numeral(x, q, is_int); m_util.au().is_numeral(x, q, is_int);
if (m_util.au().is_zero(x))
mk_pzero(f, result);
else {
expr_ref rm_nta(m), rm_nte(m), rm_tp(m), rm_tn(m), rm_tz(m); expr_ref rm_nta(m), rm_nte(m), rm_tp(m), rm_tn(m), rm_tz(m);
mk_is_rm(rm, BV_RM_TIES_TO_AWAY, rm_nta); mk_is_rm(rm, BV_RM_TIES_TO_AWAY, rm_nta);
mk_is_rm(rm, BV_RM_TIES_TO_EVEN, rm_nte); mk_is_rm(rm, BV_RM_TIES_TO_EVEN, rm_nte);
@ -2165,6 +2174,7 @@ void fpa2bv_converter::mk_to_fp_real(func_decl * f, sort * s, expr * rm, expr *
mk_ite(rm_nte, v2, result, result); mk_ite(rm_nte, v2, result, result);
mk_ite(rm_nta, v1, result, result); mk_ite(rm_nta, v1, result, result);
} }
}
else { else {
bv_util & bu = m_bv_util; bv_util & bu = m_bv_util;
arith_util & au = m_arith_util; arith_util & au = m_arith_util;
@ -2183,6 +2193,10 @@ void fpa2bv_converter::mk_to_fp_real(func_decl * f, sort * s, expr * rm, expr *
expr_ref rme(rm, m); expr_ref rme(rm, m);
round(s, rme, sgn, sig, exp, result); round(s, rme, sgn, sig, exp, result);
expr_ref c0(m);
mk_is_zero(x, c0);
mk_ite(c0, x, result, result);
expr * e = m.mk_eq(m_util.mk_to_real(result), x); expr * e = m.mk_eq(m_util.mk_to_real(result), x);
m_extra_assertions.push_back(e); m_extra_assertions.push_back(e);
} }
@ -2209,6 +2223,9 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con
SASSERT(e.is_int64()); SASSERT(e.is_int64());
SASSERT(m_mpz_manager.eq(e.to_mpq().denominator(), 1)); SASSERT(m_mpz_manager.eq(e.to_mpq().denominator(), 1));
if (q.is_zero())
return mk_pzero(f, result);
else {
scoped_mpf nte(m_mpf_manager), nta(m_mpf_manager), tp(m_mpf_manager), tn(m_mpf_manager), tz(m_mpf_manager); scoped_mpf nte(m_mpf_manager), nta(m_mpf_manager), tp(m_mpf_manager), tn(m_mpf_manager), tz(m_mpf_manager);
m_mpf_manager.set(nte, ebits, sbits, MPF_ROUND_NEAREST_TEVEN, q.to_mpq(), e.to_mpq().numerator()); m_mpf_manager.set(nte, ebits, sbits, MPF_ROUND_NEAREST_TEVEN, q.to_mpq(), e.to_mpq().numerator());
m_mpf_manager.set(nta, ebits, sbits, MPF_ROUND_NEAREST_TAWAY, q.to_mpq(), e.to_mpq().numerator()); m_mpf_manager.set(nta, ebits, sbits, MPF_ROUND_NEAREST_TAWAY, q.to_mpq(), e.to_mpq().numerator());
@ -2240,7 +2257,9 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con
mk_ite(c2, bv_tp, result, result); mk_ite(c2, bv_tp, result, result);
mk_ite(c3, bv_nta, result, result); mk_ite(c3, bv_nta, result, result);
mk_ite(c4, bv_nte, result, result); mk_ite(c4, bv_nte, result, result);
}
} }
void fpa2bv_converter::mk_to_real(func_decl * f, unsigned num, expr * const * args, expr_ref & result) { void fpa2bv_converter::mk_to_real(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE("fpa2bv_to_real", for (unsigned i = 0; i < num; i++) TRACE("fpa2bv_to_real", for (unsigned i = 0; i < num; i++)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;); tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
@ -2367,10 +2386,9 @@ void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const
mk_pinf(f, pinf); mk_pinf(f, pinf);
// Special case: x == 0 -> p/n zero // Special case: x == 0 -> p/n zero
expr_ref c1(m), v1(m), rm_is_to_neg(m); expr_ref c1(m), v1(m);
c1 = is_zero; c1 = is_zero;
mk_is_rm(rm, BV_RM_TO_NEGATIVE, rm_is_to_neg); v1 = pzero;
mk_ite(rm_is_to_neg, nzero, pzero, v1);
// Special case: x != 0 // Special case: x != 0
expr_ref is_neg_bit(m), exp_too_large(m), sig_4(m), exp_2(m); expr_ref is_neg_bit(m), exp_too_large(m), sig_4(m), exp_2(m);
@ -2508,10 +2526,9 @@ void fpa2bv_converter::mk_to_fp_unsigned(func_decl * f, unsigned num, expr * con
mk_pinf(f, pinf); mk_pinf(f, pinf);
// Special case: x == 0 -> p/n zero // Special case: x == 0 -> p/n zero
expr_ref c1(m), v1(m), rm_is_to_neg(m); expr_ref c1(m), v1(m);
c1 = is_zero; c1 = is_zero;
mk_is_rm(rm, BV_RM_TO_NEGATIVE, rm_is_to_neg); v1 = pzero;
mk_ite(rm_is_to_neg, nzero, pzero, v1);
// Special case: x != 0 // Special case: x != 0
expr_ref exp_too_large(m), sig_4(m), exp_2(m); expr_ref exp_too_large(m), sig_4(m), exp_2(m);

View file

@ -879,12 +879,20 @@ void fpa_decl_plugin::get_sort_names(svector<builtin_name> & sort_names, symbol
} }
expr * fpa_decl_plugin::get_some_value(sort * s) { expr * fpa_decl_plugin::get_some_value(sort * s) {
SASSERT(s->is_sort_of(m_family_id, FLOATING_POINT_SORT)); if (s->is_sort_of(m_family_id, FLOATING_POINT_SORT)) {
mpf tmp; mpf tmp;
m_fm.mk_nan(s->get_parameter(0).get_int(), s->get_parameter(1).get_int(), tmp); m_fm.mk_nan(s->get_parameter(0).get_int(), s->get_parameter(1).get_int(), tmp);
expr * res = this->mk_numeral(tmp); expr * res = mk_numeral(tmp);
m_fm.del(tmp); m_fm.del(tmp);
return res; return res;
}
else if (s->is_sort_of(m_family_id, ROUNDING_MODE_SORT)) {
func_decl * f = mk_rm_const_decl(OP_FPA_RM_TOWARD_ZERO, 0, 0, 0, 0, s);
return m_manager->mk_const(f);
}
UNREACHABLE();
return 0;
} }
bool fpa_decl_plugin::is_value(app * e) const { bool fpa_decl_plugin::is_value(app * e) const {

View file

@ -902,6 +902,7 @@ template<typename Cfg>
void bit_blaster_tpl<Cfg>::mk_shl(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) { void bit_blaster_tpl<Cfg>::mk_shl(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) {
numeral k; numeral k;
if (is_numeral(sz, b_bits, k)) { if (is_numeral(sz, b_bits, k)) {
if (k > numeral(sz)) k = numeral(sz);
unsigned n = static_cast<unsigned>(k.get_int64()); unsigned n = static_cast<unsigned>(k.get_int64());
if (n >= sz) n = sz; if (n >= sz) n = sz;
unsigned pos; unsigned pos;
@ -947,6 +948,7 @@ template<typename Cfg>
void bit_blaster_tpl<Cfg>::mk_lshr(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) { void bit_blaster_tpl<Cfg>::mk_lshr(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) {
numeral k; numeral k;
if (is_numeral(sz, b_bits, k)) { if (is_numeral(sz, b_bits, k)) {
if (k > numeral(sz)) k = numeral(sz);
unsigned n = static_cast<unsigned>(k.get_int64()); unsigned n = static_cast<unsigned>(k.get_int64());
unsigned pos = 0; unsigned pos = 0;
for (unsigned i = n; i < sz; pos++, i++) for (unsigned i = n; i < sz; pos++, i++)
@ -989,6 +991,7 @@ template<typename Cfg>
void bit_blaster_tpl<Cfg>::mk_ashr(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) { void bit_blaster_tpl<Cfg>::mk_ashr(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits) {
numeral k; numeral k;
if (is_numeral(sz, b_bits, k)) { if (is_numeral(sz, b_bits, k)) {
if (k > numeral(sz)) k = numeral(sz);
unsigned n = static_cast<unsigned>(k.get_int64()); unsigned n = static_cast<unsigned>(k.get_int64());
unsigned pos = 0; unsigned pos = 0;
for (unsigned i = n; i < sz; pos++, i++) for (unsigned i = n; i < sz; pos++, i++)

View file

@ -1,20 +1,20 @@
/*++ /*++
Copyright (c) 2013 Microsoft Corporation Copyright (c) 2013 Microsoft Corporation
Module Name: Module Name:
interpolant_cmds.cpp interpolant_cmds.cpp
Abstract: Abstract:
Commands for interpolation. Commands for interpolation.
Author: Author:
Leonardo (leonardo) 2011-12-23 Leonardo (leonardo) 2011-12-23
Notes: Notes:
--*/ --*/
#include<sstream> #include<sstream>
#include"cmd_context.h" #include"cmd_context.h"
#include"cmd_util.h" #include"cmd_util.h"

View file

@ -1,20 +1,20 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
interpolant_cmds.h interpolant_cmds.h
Abstract: Abstract:
Commands for interpolation. Commands for interpolation.
Author: Author:
Leonardo (leonardo) 2011-12-23 Leonardo (leonardo) 2011-12-23
Notes: Notes:
--*/ --*/
#ifndef _INTERPOLANT_CMDS_H_ #ifndef _INTERPOLANT_CMDS_H_
#define _INTERPOLANT_CMDS_H_ #define _INTERPOLANT_CMDS_H_

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012 Microsoft Corporation
Module Name: Module Name:
duality.h duality.h
Abstract: Abstract:
main header for duality main header for duality
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#pragma once #pragma once
@ -109,7 +109,7 @@ namespace Duality {
Term ExtractStores(hash_map<ast, Term> &memo, const Term &t, std::vector<expr> &cnstrs, hash_map<ast,expr> &renaming); Term ExtractStores(hash_map<ast, Term> &memo, const Term &t, std::vector<expr> &cnstrs, hash_map<ast,expr> &renaming);
protected: protected:
void SummarizeRec(hash_set<ast> &memo, std::vector<expr> &lits, int &ops, const Term &t); void SummarizeRec(hash_set<ast> &memo, std::vector<expr> &lits, int &ops, const Term &t);
int CountOperatorsRec(hash_set<ast> &memo, const Term &t); int CountOperatorsRec(hash_set<ast> &memo, const Term &t);
@ -126,7 +126,7 @@ protected:
Term DeleteBoundRec(hash_map<int,hash_map<ast,Term> > &memo, int level, int num, const Term &t); Term DeleteBoundRec(hash_map<int,hash_map<ast,Term> > &memo, int level, int num, const Term &t);
Term DeleteBound(int level, int num, const Term &t); Term DeleteBound(int level, int num, const Term &t);
}; };
/** This class represents a relation post-fixed point (RPFP) problem as /** This class represents a relation post-fixed point (RPFP) problem as
* a "problem graph". The graph consists of Nodes and hyper-edges. * a "problem graph". The graph consists of Nodes and hyper-edges.

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
duality_profiling.cpp duality_profiling.cpp
Abstract: Abstract:
collection performance information for duality collection performance information for duality
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#include <map> #include <map>

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
duality_profiling.h duality_profiling.h
Abstract: Abstract:
collection performance information for duality collection performance information for duality
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef DUALITYPROFILING_H #ifndef DUALITYPROFILING_H
#define DUALITYPROFILING_H #define DUALITYPROFILING_H

View file

@ -1,23 +1,23 @@
/*++ /*++
Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012 Microsoft Corporation
Module Name: Module Name:
duality_rpfp.h duality_rpfp.h
Abstract: Abstract:
implements relational post-fixedpoint problem implements relational post-fixedpoint problem
(RPFP) data structure. (RPFP) data structure.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
@ -40,7 +40,7 @@ Revision History:
#ifdef Z3OPS #ifdef Z3OPS
class Z3_subterm_truth { class Z3_subterm_truth {
public: public:
virtual bool eval(Z3_ast f) = 0; virtual bool eval(Z3_ast f) = 0;
~Z3_subterm_truth(){} ~Z3_subterm_truth(){}
}; };
@ -1642,7 +1642,7 @@ namespace Duality {
else else
res = 2; res = 2;
} }
done: done:
memo[f] = res; memo[f] = res;
return res; return res;
} }
@ -1729,7 +1729,7 @@ done:
else else
res = 2; res = 2;
} }
done: done:
memo[labpos][f] = res; memo[labpos][f] = res;
return res; return res;
} }
@ -1873,7 +1873,7 @@ done:
lits.push_back(bv); lits.push_back(bv);
} }
} }
done: done:
done[truth].insert(f); done[truth].insert(f);
} }
@ -1907,7 +1907,7 @@ done:
lits.push_back(bv); lits.push_back(bv);
} }
} }
done: done:
done.insert(f); done.insert(f);
} }
@ -2009,9 +2009,9 @@ done:
RPFP::Term RPFP::UnderapproxFormula(const Term &f, hash_set<ast> &dont_cares){ RPFP::Term RPFP::UnderapproxFormula(const Term &f, hash_set<ast> &dont_cares){
/* first compute truth values of subterms */ /* first compute truth values of subterms */
hash_map<ast,int> memo; hash_map<ast,int> memo;
#ifdef Z3OPS #ifdef Z3OPS
stt = Z3_mk_subterm_truth(ctx,dualModel); stt = Z3_mk_subterm_truth(ctx,dualModel);
#endif #endif
// SubtermTruth(memo,f); // SubtermTruth(memo,f);
/* now compute an implicant */ /* now compute an implicant */
std::vector<Term> lits; std::vector<Term> lits;
@ -3117,6 +3117,7 @@ done:
} }
if(node->Annotation.IsEmpty() || eq(node->Annotation.Formula,prev_annot) || (repeated_case_count > 0 && !axioms_added) || (repeated_case_count >= 10)){ if(node->Annotation.IsEmpty() || eq(node->Annotation.Formula,prev_annot) || (repeated_case_count > 0 && !axioms_added) || (repeated_case_count >= 10)){
//looks_bad:
if(!axioms_added){ if(!axioms_added){
// add the axioms in the off chance they are useful // add the axioms in the off chance they are useful
const std::vector<expr> &theory = ls->get_axioms(); const std::vector<expr> &theory = ls->get_axioms();
@ -4275,7 +4276,7 @@ done:
return false; return false;
} }
RPFP::~RPFP(){ RPFP::~RPFP(){
ClearProofCore(); ClearProofCore();
for(unsigned i = 0; i < nodes.size(); i++) for(unsigned i = 0; i < nodes.size(); i++)
delete nodes[i]; delete nodes[i];

View file

@ -1,23 +1,23 @@
/*++ /*++
Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012 Microsoft Corporation
Module Name: Module Name:
duality_solver.h duality_solver.h
Abstract: Abstract:
implements relational post-fixedpoint problem implements relational post-fixedpoint problem
(RPFP) solver (RPFP) solver
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012 Microsoft Corporation
Module Name: Module Name:
wrapper.cpp wrapper.cpp
Abstract: Abstract:
wrap various objects in the style expected by duality wrap various objects in the style expected by duality
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)
@ -57,12 +57,12 @@ namespace Duality {
m_mode = m().proof_mode(); m_mode = m().proof_mode();
} }
expr context::constant(const std::string &name, const sort &ty){ expr context::constant(const std::string &name, const sort &ty){
symbol s = str_symbol(name.c_str()); symbol s = str_symbol(name.c_str());
return cook(m().mk_const(m().mk_const_decl(s, ty))); return cook(m().mk_const(m().mk_const_decl(s, ty)));
} }
expr context::make(decl_kind op, int n, ::expr **args){ expr context::make(decl_kind op, int n, ::expr **args){
switch(op) { switch(op) {
case True: return mki(m_basic_fid,OP_TRUE,n,args); case True: return mki(m_basic_fid,OP_TRUE,n,args);
case False: return mki(m_basic_fid,OP_FALSE,n,args); case False: return mki(m_basic_fid,OP_FALSE,n,args);
@ -108,46 +108,46 @@ expr context::make(decl_kind op, int n, ::expr **args){
assert(0); assert(0);
return expr(*this); return expr(*this);
} }
} }
expr context::mki(family_id fid, ::decl_kind dk, int n, ::expr **args){ expr context::mki(family_id fid, ::decl_kind dk, int n, ::expr **args){
return cook(m().mk_app(fid, dk, 0, 0, n, (::expr **)args)); return cook(m().mk_app(fid, dk, 0, 0, n, (::expr **)args));
} }
expr context::make(decl_kind op, const std::vector<expr> &args){ expr context::make(decl_kind op, const std::vector<expr> &args){
static std::vector< ::expr*> a(10); static std::vector< ::expr*> a(10);
if(a.size() < args.size()) if(a.size() < args.size())
a.resize(args.size()); a.resize(args.size());
for(unsigned i = 0; i < args.size(); i++) for(unsigned i = 0; i < args.size(); i++)
a[i] = to_expr(args[i].raw()); a[i] = to_expr(args[i].raw());
return make(op,args.size(), args.size() ? &a[0] : 0); return make(op,args.size(), args.size() ? &a[0] : 0);
} }
expr context::make(decl_kind op){ expr context::make(decl_kind op){
return make(op,0,0); return make(op,0,0);
} }
expr context::make(decl_kind op, const expr &arg0){ expr context::make(decl_kind op, const expr &arg0){
::expr *a = to_expr(arg0.raw()); ::expr *a = to_expr(arg0.raw());
return make(op,1,&a); return make(op,1,&a);
} }
expr context::make(decl_kind op, const expr &arg0, const expr &arg1){ expr context::make(decl_kind op, const expr &arg0, const expr &arg1){
::expr *args[2]; ::expr *args[2];
args[0] = to_expr(arg0.raw()); args[0] = to_expr(arg0.raw());
args[1] = to_expr(arg1.raw()); args[1] = to_expr(arg1.raw());
return make(op,2,args); return make(op,2,args);
} }
expr context::make(decl_kind op, const expr &arg0, const expr &arg1, const expr &arg2){ expr context::make(decl_kind op, const expr &arg0, const expr &arg1, const expr &arg2){
::expr *args[3]; ::expr *args[3];
args[0] = to_expr(arg0.raw()); args[0] = to_expr(arg0.raw());
args[1] = to_expr(arg1.raw()); args[1] = to_expr(arg1.raw());
args[2] = to_expr(arg2.raw()); args[2] = to_expr(arg2.raw());
return make(op,3,args); return make(op,3,args);
} }
expr context::make_quant(decl_kind op, const std::vector<expr> &bvs, const expr &body){ expr context::make_quant(decl_kind op, const std::vector<expr> &bvs, const expr &body){
if(bvs.size() == 0) return body; if(bvs.size() == 0) return body;
std::vector< ::expr *> foo(bvs.size()); std::vector< ::expr *> foo(bvs.size());
@ -177,9 +177,9 @@ expr context::make_quant(decl_kind op, const std::vector<expr> &bvs, const expr
0, 0 0, 0
); );
return cook(result.get()); return cook(result.get());
} }
expr context::make_quant(decl_kind op, const std::vector<sort> &_sorts, const std::vector<symbol> &_names, const expr &body){ expr context::make_quant(decl_kind op, const std::vector<sort> &_sorts, const std::vector<symbol> &_names, const expr &body){
if(_sorts.size() == 0) return body; if(_sorts.size() == 0) return body;
@ -203,7 +203,7 @@ expr context::make_quant(decl_kind op, const std::vector<sort> &_sorts, const st
0, 0 0, 0
); );
return cook(result.get()); return cook(result.get());
} }
decl_kind func_decl::get_decl_kind() const { decl_kind func_decl::get_decl_kind() const {

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012 Microsoft Corporation
Module Name: Module Name:
duality_wrapper.h duality_wrapper.h
Abstract: Abstract:
wrap various Z3 classes in the style expected by duality wrap various Z3 classes in the style expected by duality
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef __DUALITY_WRAPPER_H_ #ifndef __DUALITY_WRAPPER_H_
#define __DUALITY_WRAPPER_H_ #define __DUALITY_WRAPPER_H_

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
foci2.h foci2.h
Abstract: Abstract:
An interface class for foci2. An interface class for foci2.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef FOCI2_H #ifndef FOCI2_H
#define FOCI2_H #define FOCI2_H

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3base.cpp iz3base.cpp
Abstract: Abstract:
Base class for interpolators. Includes an AST manager and a scoping Base class for interpolators. Includes an AST manager and a scoping
object as bases. object as bases.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3base.h iz3base.h
Abstract: Abstract:
Base class for interpolators. Includes an AST manager and a scoping Base class for interpolators. Includes an AST manager and a scoping
object as bases. object as bases.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3BASE_H #ifndef IZ3BASE_H
#define IZ3BASE_H #define IZ3BASE_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3checker.cpp iz3checker.cpp
Abstract: Abstract:
check correctness of interpolant check correctness of interpolant
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3checker.h iz3checker.h
Abstract: Abstract:
check correctness of an interpolant check correctness of an interpolant
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3_CHECKER_H #ifndef IZ3_CHECKER_H
#define IZ3_CHECKER_H #define IZ3_CHECKER_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3foci.cpp iz3foci.cpp
Abstract: Abstract:
Implements a secondary solver using foci2. Implements a secondary solver using foci2.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3foci.h iz3foci.h
Abstract: Abstract:
Implements a secondary solver using foci2. Implements a secondary solver using foci2.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3FOCI_H #ifndef IZ3FOCI_H
#define IZ3FOCI_H #define IZ3FOCI_H

View file

@ -1,11 +1,11 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3hash.h iz3hash.h
Abstract: Abstract:
Simple implementation of bucket-list hash tables conforming to SGI Simple implementation of bucket-list hash tables conforming to SGI
hash_map and hash_set interfaces. Just enough members are hash_map and hash_set interfaces. Just enough members are
@ -18,13 +18,13 @@ Abstract:
This package lives in namespace hash_space. Specializations of This package lives in namespace hash_space. Specializations of
class "hash" should be made in this namespace. class "hash" should be made in this namespace.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3_HASH_H #ifndef IZ3_HASH_H
#define IZ3_HASH_H #define IZ3_HASH_H
@ -44,6 +44,7 @@ namespace hash_space {
template <typename T> class hash {}; template <typename T> class hash {};
template <> template <>
class hash<int> { class hash<int> {
public: public:
@ -56,7 +57,7 @@ namespace hash_space {
class hash<std::string> { class hash<std::string> {
public: public:
size_t operator()(const std::string &s) const { size_t operator()(const std::string &s) const {
return string_hash(s.c_str(), static_cast<unsigned>(s.size()), 0); return string_hash(s.c_str(), s.size(), 0);
} }
}; };
@ -111,7 +112,7 @@ namespace hash_space {
4294967291ul 4294967291ul
}; };
inline size_t next_prime(size_t n) { inline unsigned long next_prime(unsigned long n) {
const unsigned long* to = primes + (int)num_primes; const unsigned long* to = primes + (int)num_primes;
for(const unsigned long* p = primes; p < to; p++) for(const unsigned long* p = primes; p < to; p++)
if(*p >= n) return *p; if(*p >= n) return *p;
@ -378,7 +379,7 @@ namespace hash_space {
void resize(size_t new_size) { void resize(size_t new_size) {
const size_t old_n = buckets.size(); const size_t old_n = buckets.size();
if (new_size <= old_n) return; if (new_size <= old_n) return;
const size_t n = next_prime(static_cast<unsigned>(new_size)); const size_t n = next_prime(new_size);
if (n <= old_n) return; if (n <= old_n) return;
Table tmp(n, (Entry*)(0)); Table tmp(n, (Entry*)(0));
for (size_t i = 0; i < old_n; ++i) { for (size_t i = 0; i < old_n; ++i) {

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3interp.cpp iz3interp.cpp
Abstract: Abstract:
Interpolation based on proof translation. Interpolation based on proof translation.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
/* Copyright 2011 Microsoft Research. */ /* Copyright 2011 Microsoft Research. */
@ -398,10 +398,27 @@ public:
s.assert_expr(to_expr(cnsts[i].raw())); s.assert_expr(to_expr(cnsts[i].raw()));
} }
void get_proof_assumptions(z3pf proof, std::vector<ast> &cnsts, hash_set<ast> &memo){
if(memo.find(proof) != memo.end())return;
memo.insert(proof);
pfrule dk = pr(proof);
if(dk == PR_ASSERTED)
cnsts.push_back(conc(proof));
else {
unsigned nprems = num_prems(proof);
for(unsigned i = 0; i < nprems; i++){
z3pf arg = prem(proof,i);
get_proof_assumptions(arg,cnsts,memo);
}
}
}
iz3interp(ast_manager &_m_manager) iz3interp(ast_manager &_m_manager)
: iz3base(_m_manager) {} : iz3base(_m_manager) {}
}; };
void iz3interpolate(ast_manager &_m_manager, void iz3interpolate(ast_manager &_m_manager,
ast *proof, ast *proof,
const ptr_vector<ast> &cnsts, const ptr_vector<ast> &cnsts,
@ -475,6 +492,13 @@ void iz3interpolate(ast_manager &_m_manager,
_cnsts[i] = itp.cook(cnsts[i]); _cnsts[i] = itp.cook(cnsts[i]);
iz3mgr::ast _proof = itp.cook(proof); iz3mgr::ast _proof = itp.cook(proof);
iz3mgr::ast _tree = itp.cook(tree); iz3mgr::ast _tree = itp.cook(tree);
// if consts isn't provided, we can reconstruct it
if(_cnsts.empty()){
hash_set<iz3mgr::ast> memo;
itp.get_proof_assumptions(_proof,_cnsts,memo);
}
itp.proof_to_interpolant(_proof,_cnsts,_tree,_interps,options); itp.proof_to_interpolant(_proof,_cnsts,_tree,_interps,options);
interps.resize(_interps.size()); interps.resize(_interps.size());
for(unsigned i = 0; i < interps.size(); i++) for(unsigned i = 0; i < interps.size(); i++)

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3interp.h iz3interp.h
Abstract: Abstract:
Interpolation based on proof translation. Interpolation based on proof translation.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3_INTERP_H #ifndef IZ3_INTERP_H
#define IZ3_INTERP_H #define IZ3_INTERP_H
@ -67,7 +67,11 @@ void iz3interpolate(ast_manager &_m_manager,
interpolation_options_struct * options = 0); interpolation_options_struct * options = 0);
/* Compute an interpolant from a proof. This version uses the ast /* Compute an interpolant from a proof. This version uses the ast
representation, for compatibility with the new API. */ representation, for compatibility with the new API. Here, cnsts is
a vector of all the assertions in the proof. This can be
over-approximated by the set of all assertions in the
solver. However, if it is empty it will be reconstructed from the
proof, so it can be considered a hint. */
void iz3interpolate(ast_manager &_m_manager, void iz3interpolate(ast_manager &_m_manager,
ast *proof, ast *proof,

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3mgr.cpp iz3mgr.cpp
Abstract: Abstract:
A wrapper around an ast manager, providing convenience methods. A wrapper around an ast manager, providing convenience methods.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
@ -648,7 +648,7 @@ void iz3mgr::get_assign_bounds_rule_coeffs(const ast &proof, std::vector<rationa
extract_lcd(rats); extract_lcd(rats);
} }
/** Set P to P + cQ, where P and Q are linear inequalities. Assumes P is 0 <= y or 0 < y. */ /** Set P to P + cQ, where P and Q are linear inequalities. Assumes P is 0 <= y or 0 < y. */
void iz3mgr::linear_comb(ast &P, const ast &c, const ast &Q, bool round_off){ void iz3mgr::linear_comb(ast &P, const ast &c, const ast &Q, bool round_off){
ast Qrhs; ast Qrhs;
@ -825,7 +825,7 @@ iz3mgr::ast iz3mgr::cont_eq(stl_ext::hash_set<ast> &cont_eq_memo, bool truth, as
return ast(); return ast();
} }
// substitute a term t for unbound occurrences of variable v in e // substitute a term t for unbound occurrences of variable v in e
iz3mgr::ast iz3mgr::subst(stl_ext::hash_map<ast,ast> &subst_memo, ast var, ast t, ast e){ iz3mgr::ast iz3mgr::subst(stl_ext::hash_map<ast,ast> &subst_memo, ast var, ast t, ast e){
if(e == var) return t; if(e == var) return t;
@ -865,9 +865,9 @@ iz3mgr::ast iz3mgr::subst(stl_ext::hash_map<ast,ast> &subst_memo,ast e){
return res; return res;
} }
// apply a quantifier to a formula, with some optimizations // apply a quantifier to a formula, with some optimizations
// 1) bound variable does not occur -> no quantifier // 1) bound variable does not occur -> no quantifier
// 2) bound variable must be equal to some term -> substitute // 2) bound variable must be equal to some term -> substitute
iz3mgr::ast iz3mgr::apply_quant(opr quantifier, ast var, ast e){ iz3mgr::ast iz3mgr::apply_quant(opr quantifier, ast var, ast e){
if((quantifier == Forall && op(e) == And) if((quantifier == Forall && op(e) == And)
@ -896,5 +896,5 @@ void iz3mgr::get_bound_substitutes(stl_ext::hash_map<ast,bool> &memo, const ast
if(op(e) == if(op(e) ==
} }
} }
#endif #endif

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3mgr.h iz3mgr.h
Abstract: Abstract:
A wrapper around an ast manager, providing convenience methods. A wrapper around an ast manager, providing convenience methods.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3MGR_H #ifndef IZ3MGR_H
#define IZ3MGR_H #define IZ3MGR_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2013 Microsoft Corporation Copyright (c) 2013 Microsoft Corporation
Module Name: Module Name:
iz3pp.cpp iz3pp.cpp
Abstract: Abstract:
Pretty-print interpolation problems Pretty-print interpolation problems
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
/* Copyright 2011 Microsoft Research. */ /* Copyright 2011 Microsoft Research. */
#include <assert.h> #include <assert.h>

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2013 Microsoft Corporation Copyright (c) 2013 Microsoft Corporation
Module Name: Module Name:
iz3pp.cpp iz3pp.cpp
Abstract: Abstract:
Pretty-print interpolation problems Pretty-print interpolation problems
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3_PP_H #ifndef IZ3_PP_H
#define IZ3_PP_H #define IZ3_PP_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3profiling.h iz3profiling.h
Abstract: Abstract:
Some routines for measuring performance. Some routines for measuring performance.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3profiling.h iz3profiling.h
Abstract: Abstract:
Some routines for measuring performance. Some routines for measuring performance.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3PROFILING_H #ifndef IZ3PROFILING_H
#define IZ3PROFILING_H #define IZ3PROFILING_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3proof.cpp iz3proof.cpp
Abstract: Abstract:
This class defines a simple interpolating proof system. This class defines a simple interpolating proof system.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
@ -436,12 +436,12 @@ void iz3proof::interpolate_lemma(node_struct &n){
pv->interpolate_clause(n.conclusion,interps[n.frame]); pv->interpolate_clause(n.conclusion,interps[n.frame]);
} }
iz3proof::ast iz3proof::interpolate(const prover::range &_rng, bool _weak iz3proof::ast iz3proof::interpolate(const prover::range &_rng, bool _weak
#ifdef CHECK_PROOFS #ifdef CHECK_PROOFS
, ast assump , ast assump
, std::vector<int> *parents , std::vector<int> *parents
#endif #endif
){ ){
// std::cout << "proof size: " << nodes.size() << "\n"; // std::cout << "proof size: " << nodes.size() << "\n";
rng = _rng; rng = _rng;
weak = _weak; weak = _weak;

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3proof.h iz3proof.h
Abstract: Abstract:
This class defines a simple interpolating proof system. This class defines a simple interpolating proof system.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3PROOF_H #ifndef IZ3PROOF_H
#define IZ3PROOF_H #define IZ3PROOF_H
@ -40,7 +40,7 @@ Revision History:
rules Resolution, Assumption, Contra and Lemma, and that all rules Resolution, Assumption, Contra and Lemma, and that all
clauses are strict (i.e., each literal in each clause is local). clauses are strict (i.e., each literal in each clause is local).
*/ */
class iz3proof { class iz3proof {
public: public:

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3proof.cpp iz3proof.cpp
Abstract: Abstract:
This class defines a simple interpolating proof system. This class defines a simple interpolating proof system.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3proof.h iz3proof.h
Abstract: Abstract:
This class defines a simple interpolating proof system. This class defines a simple interpolating proof system.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3PROOF_ITP_H #ifndef IZ3PROOF_ITP_H
#define IZ3PROOF_ITP_H #define IZ3PROOF_ITP_H
@ -32,7 +32,7 @@ Revision History:
As opposed to iz3proof, this class directly computes interpolants, As opposed to iz3proof, this class directly computes interpolants,
so the proof representation is just the interpolant itself. so the proof representation is just the interpolant itself.
*/ */
class iz3proof_itp : public iz3mgr { class iz3proof_itp : public iz3mgr {
public: public:

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3scopes.cpp iz3scopes.cpp
Abstract: Abstract:
Calculations with scopes, for both sequence and tree interpolation. Calculations with scopes, for both sequence and tree interpolation.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#include <assert.h> #include <assert.h>
@ -85,7 +85,7 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
#else #else
namespace std { namespace std {
template <> template <>
class hash<scopes::range_lo > { class hash<scopes::range_lo > {
public: public:
@ -93,16 +93,16 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
return p.lo + (size_t)p.next; return p.lo + (size_t)p.next;
} }
}; };
} }
template <> inline template <> inline
size_t stdext::hash_value<scopes::range_lo >(const scopes::range_lo& p) size_t stdext::hash_value<scopes::range_lo >(const scopes::range_lo& p)
{ {
std::hash<scopes::range_lo> h; std::hash<scopes::range_lo> h;
return h(p); return h(p);
} }
namespace std { namespace std {
template <> template <>
class less<scopes::range_lo > { class less<scopes::range_lo > {
public: public:
@ -110,18 +110,18 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
return x.lo < y.lo || x.lo == y.lo && (size_t)x.next < (size_t)y.next; return x.lo < y.lo || x.lo == y.lo && (size_t)x.next < (size_t)y.next;
} }
}; };
} }
struct range_op { struct range_op {
scopes::range_lo *x, *y; scopes::range_lo *x, *y;
int hi; int hi;
range_op(scopes::range_lo *_x, scopes::range_lo *_y, int _hi){ range_op(scopes::range_lo *_x, scopes::range_lo *_y, int _hi){
x = _x; y = _y; hi = _hi; x = _x; y = _y; hi = _hi;
} }
}; };
namespace std { namespace std {
template <> template <>
class hash<range_op > { class hash<range_op > {
public: public:
@ -129,16 +129,16 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
return (size_t) p.x + (size_t)p.y + p.hi; return (size_t) p.x + (size_t)p.y + p.hi;
} }
}; };
} }
template <> inline template <> inline
size_t stdext::hash_value<range_op >(const range_op& p) size_t stdext::hash_value<range_op >(const range_op& p)
{ {
std::hash<range_op> h; std::hash<range_op> h;
return h(p); return h(p);
} }
namespace std { namespace std {
template <> template <>
class less<range_op > { class less<range_op > {
public: public:
@ -147,16 +147,16 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
((size_t)x.y < (size_t)y.y || x.y == y.y && x.hi < y.hi); ((size_t)x.y < (size_t)y.y || x.y == y.y && x.hi < y.hi);
} }
}; };
} }
struct range_tables { struct range_tables {
hash_map<scopes::range_lo, scopes::range_lo *> unique; hash_map<scopes::range_lo, scopes::range_lo *> unique;
hash_map<range_op,scopes::range_lo *> lub; hash_map<range_op,scopes::range_lo *> lub;
hash_map<range_op,scopes::range_lo *> glb; hash_map<range_op,scopes::range_lo *> glb;
}; };
scopes::range_lo *scopes::find_range_lo(int lo, range_lo *next){ scopes::range_lo *scopes::find_range_lo(int lo, range_lo *next){
range_lo foo(lo,next); range_lo foo(lo,next);
std::pair<range_lo,range_lo *> baz(foo,(range_lo *)0); std::pair<range_lo,range_lo *> baz(foo,(range_lo *)0);
std::pair<hash_map<range_lo,scopes::range_lo *>::iterator,bool> bar = rt->unique.insert(baz); std::pair<hash_map<range_lo,scopes::range_lo *>::iterator,bool> bar = rt->unique.insert(baz);
@ -166,9 +166,9 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
//std::pair<hash_set<scopes::range_lo>::iterator,bool> bar = rt->unique.insert(foo); //std::pair<hash_set<scopes::range_lo>::iterator,bool> bar = rt->unique.insert(foo);
// const range_lo *baz = &*(bar.first); // const range_lo *baz = &*(bar.first);
// return (range_lo *)baz; // coerce const // return (range_lo *)baz; // coerce const
} }
scopes::range_lo *scopes::range_lub_lo(range_lo *rng1, range_lo *rng2){ scopes::range_lo *scopes::range_lub_lo(range_lo *rng1, range_lo *rng2){
if(!rng1) return rng2; if(!rng1) return rng2;
if(!rng2) return rng1; if(!rng2) return rng1;
if(rng1->lo > rng2->lo) if(rng1->lo > rng2->lo)
@ -185,10 +185,10 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
range_lo *baz = range_lub_lo(rng1->next,rng2); range_lo *baz = range_lub_lo(rng1->next,rng2);
res = find_range_lo(rng1->lo,baz); res = find_range_lo(rng1->lo,baz);
return res; return res;
} }
scopes::range_lo *scopes::range_glb_lo(range_lo *rng1, range_lo *rng2, int hi){ scopes::range_lo *scopes::range_glb_lo(range_lo *rng1, range_lo *rng2, int hi){
if(!rng1) return rng1; if(!rng1) return rng1;
if(!rng2) return rng2; if(!rng2) return rng2;
if(rng1->lo > rng2->lo) if(rng1->lo > rng2->lo)
@ -216,55 +216,55 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
else foo = range_glb_lo(rng1->next,rng2,hi); else foo = range_glb_lo(rng1->next,rng2,hi);
res = foo; res = foo;
return res; return res;
} }
/** computes the lub (smallest containing subtree) of two ranges */ /** computes the lub (smallest containing subtree) of two ranges */
scopes::range scopes::range_lub(const range &rng1, const range &rng2){ scopes::range scopes::range_lub(const range &rng1, const range &rng2){
int hi = tree_lca(rng1.hi,rng2.hi); int hi = tree_lca(rng1.hi,rng2.hi);
if(hi == SHRT_MAX) return range_full(); if(hi == SHRT_MAX) return range_full();
range_lo *lo = range_lub_lo(rng1.lo,rng2.lo); range_lo *lo = range_lub_lo(rng1.lo,rng2.lo);
return range(hi,lo); return range(hi,lo);
} }
/** computes the glb (intersection) of two ranges */ /** computes the glb (intersection) of two ranges */
scopes::range scopes::range_glb(const range &rng1, const range &rng2){ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
if(rng1.hi == SHRT_MAX) return rng2; if(rng1.hi == SHRT_MAX) return rng2;
if(rng2.hi == SHRT_MAX) return rng1; if(rng2.hi == SHRT_MAX) return rng1;
int hi = tree_gcd(rng1.hi,rng2.hi); int hi = tree_gcd(rng1.hi,rng2.hi);
range_lo *lo = hi == SHRT_MIN ? 0 : range_glb_lo(rng1.lo,rng2.lo,hi); range_lo *lo = hi == SHRT_MIN ? 0 : range_glb_lo(rng1.lo,rng2.lo,hi);
if(!lo) hi = SHRT_MIN; if(!lo) hi = SHRT_MIN;
return range(hi,lo); return range(hi,lo);
} }
/** is this range empty? */ /** is this range empty? */
bool scopes::range_is_empty(const range &rng){ bool scopes::range_is_empty(const range &rng){
return rng.hi == SHRT_MIN; return rng.hi == SHRT_MIN;
} }
/** return an empty range */ /** return an empty range */
scopes::range scopes::range_empty(){ scopes::range scopes::range_empty(){
return range(SHRT_MIN,0); return range(SHRT_MIN,0);
} }
/** return a full range */ /** return a full range */
scopes::range scopes::range_full(){ scopes::range scopes::range_full(){
return range(SHRT_MAX,0); return range(SHRT_MAX,0);
} }
/** return the maximal element of a range */ /** return the maximal element of a range */
int scopes::range_max(const range &rng){ int scopes::range_max(const range &rng){
return rng.hi; return rng.hi;
} }
/** return a minimal (not necessarily unique) element of a range */ /** return a minimal (not necessarily unique) element of a range */
int scopes::range_min(const range &rng){ int scopes::range_min(const range &rng){
if(rng.hi == SHRT_MAX) return SHRT_MIN; if(rng.hi == SHRT_MAX) return SHRT_MIN;
return rng.lo ? rng.lo->lo : SHRT_MAX; return rng.lo ? rng.lo->lo : SHRT_MAX;
} }
/** return range consisting of downward closure of a point */ /** return range consisting of downward closure of a point */
scopes::range scopes::range_downward(int _hi){ scopes::range scopes::range_downward(int _hi){
std::vector<bool> descendants(parents.size()); std::vector<bool> descendants(parents.size());
for(int i = descendants.size() - 1; i >= 0 ; i--) for(int i = descendants.size() - 1; i >= 0 ; i--)
descendants[i] = i == _hi || parents[i] < parents.size() && descendants[parents[i]]; descendants[i] = i == _hi || parents[i] < parents.size() && descendants[parents[i]];
@ -275,16 +275,16 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
for(int i = descendants.size() - 1; i >= 0; --i) for(int i = descendants.size() - 1; i >= 0; --i)
if(descendants[i]) foo = find_range_lo(i,foo); if(descendants[i]) foo = find_range_lo(i,foo);
return range(_hi,foo); return range(_hi,foo);
} }
/** add an element to a range */ /** add an element to a range */
void scopes::range_add(int i, range &n){ void scopes::range_add(int i, range &n){
range foo = range(i, find_range_lo(i,0)); range foo = range(i, find_range_lo(i,0));
n = range_lub(foo,n); n = range_lub(foo,n);
} }
/** Choose an element of rng1 that is near to rng2 */ /** Choose an element of rng1 that is near to rng2 */
int scopes::range_near(const range &rng1, const range &rng2){ int scopes::range_near(const range &rng1, const range &rng2){
int frame; int frame;
int thing = tree_lca(rng1.hi,rng2.hi); int thing = tree_lca(rng1.hi,rng2.hi);
@ -292,28 +292,28 @@ scopes::range scopes::range_glb(const range &rng1, const range &rng2){
range line = range(rng1.hi,find_range_lo(rng2.hi,(range_lo *)0)); range line = range(rng1.hi,find_range_lo(rng2.hi,(range_lo *)0));
line = range_glb(line,rng1); line = range_glb(line,rng1);
return range_min(line); return range_min(line);
} }
/** test whether a tree node is contained in a range */ /** test whether a tree node is contained in a range */
bool scopes::in_range(int n, const range &rng){ bool scopes::in_range(int n, const range &rng){
range r = range_empty(); range r = range_empty();
range_add(n,r); range_add(n,r);
r = range_glb(rng,r); r = range_glb(rng,r);
return !range_is_empty(r); return !range_is_empty(r);
} }
/** test whether two ranges of tree nodes intersect */ /** test whether two ranges of tree nodes intersect */
bool scopes::ranges_intersect(const range &rng1, const range &rng2){ bool scopes::ranges_intersect(const range &rng1, const range &rng2){
range r = range_glb(rng1,rng2); range r = range_glb(rng1,rng2);
return !range_is_empty(r); return !range_is_empty(r);
} }
bool scopes::range_contained(const range &rng1, const range &rng2){ bool scopes::range_contained(const range &rng1, const range &rng2){
range r = range_glb(rng1,rng2); range r = range_glb(rng1,rng2);
return r.hi == rng1.hi && r.lo == rng1.lo; return r.hi == rng1.hi && r.lo == rng1.lo;
} }
#endif #endif

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3scopes.h iz3scopes.h
Abstract: Abstract:
Calculations with scopes, for both sequence and tree interpolation. Calculations with scopes, for both sequence and tree interpolation.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3SOPES_H #ifndef IZ3SOPES_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3secondary iz3secondary
Abstract: Abstract:
Interface for secondary provers. Interface for secondary provers.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3SECONDARY_H #ifndef IZ3SECONDARY_H

View file

@ -1,21 +1,21 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3translate.cpp iz3translate.cpp
Abstract: Abstract:
Translate a Z3 proof to in interpolated proof. Translate a Z3 proof to in interpolated proof.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
#pragma warning(disable:4996) #pragma warning(disable:4996)
@ -99,7 +99,7 @@ public:
symb commute; symb commute;
public: public:
#define from_ast(x) (x) #define from_ast(x) (x)

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3translate.h iz3translate.h
Abstract: Abstract:
Interface for proof translations from Z3 proofs to interpolatable Interface for proof translations from Z3 proofs to interpolatable
proofs. proofs.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifndef IZ3TRANSLATION_H #ifndef IZ3TRANSLATION_H
@ -29,7 +29,7 @@ Revision History:
// an interpolatable proof // an interpolatable proof
class iz3translation : public iz3base { class iz3translation : public iz3base {
public: public:
virtual iz3proof::node translate(ast, iz3proof &) = 0; virtual iz3proof::node translate(ast, iz3proof &) = 0;
virtual ast quantify(ast e, const range &rng){return e;} virtual ast quantify(ast e, const range &rng){return e;}
virtual ~iz3translation(){} virtual ~iz3translation(){}

View file

@ -1,23 +1,23 @@
/*++ /*++
Copyright (c) 2011 Microsoft Corporation Copyright (c) 2011 Microsoft Corporation
Module Name: Module Name:
iz3translate_direct.cpp iz3translate_direct.cpp
Abstract: Abstract:
Translate a Z3 proof into the interpolating proof calculus. Translate a Z3 proof into the interpolating proof calculus.
Translation is direct, without transformations on the target proof Translation is direct, without transformations on the target proof
representaiton. representaiton.
Author: Author:
Ken McMillan (kenmcmil) Ken McMillan (kenmcmil)
Revision History: Revision History:
--*/ --*/
#ifdef _WINDOWS #ifdef _WINDOWS
@ -47,7 +47,7 @@ using namespace stl_ext;
/* This can introduce an address dependency if the range type of hash_map has /* This can introduce an address dependency if the range type of hash_map has
a destructor. Since the code in this file is not used and only here for a destructor. Since the code in this file is not used and only here for
historical comparisons, we allow this non-determinism. historical comparisons, we allow this non-determinism.
*/ */
namespace stl_ext { namespace stl_ext {
template <class T> template <class T>
class hash<T *> { class hash<T *> {
@ -196,7 +196,7 @@ public:
// Translation memo for case of non-local resolutions // Translation memo for case of non-local resolutions
hash_map<non_local_lits *, AstToIpf> non_local_translation; hash_map<non_local_lits *, AstToIpf> non_local_translation;
public: public:
#define from_ast(x) (x) #define from_ast(x) (x)
@ -1639,71 +1639,71 @@ public:
++it) ++it)
delete it->second; delete it->second;
} }
}; };
#ifdef IZ3_TRANSLATE_DIRECT #ifdef IZ3_TRANSLATE_DIRECT
iz3translation *iz3translation::create(iz3mgr &mgr, iz3translation *iz3translation::create(iz3mgr &mgr,
iz3secondary *secondary, iz3secondary *secondary,
const std::vector<std::vector<ast> > &cnsts, const std::vector<std::vector<ast> > &cnsts,
const std::vector<int> &parents, const std::vector<int> &parents,
const std::vector<ast> &theory){ const std::vector<ast> &theory){
return new iz3translation_direct(mgr,secondary,cnsts,parents,theory); return new iz3translation_direct(mgr,secondary,cnsts,parents,theory);
} }
#if 1 #if 1
void iz3translation_direct_trace_lit(iz3translation_direct *p, iz3mgr::ast lit, iz3mgr::ast proof){ void iz3translation_direct_trace_lit(iz3translation_direct *p, iz3mgr::ast lit, iz3mgr::ast proof){
p->trace_lit(lit, proof); p->trace_lit(lit, proof);
} }
void iz3translation_direct_show_step(iz3translation_direct *p, iz3mgr::ast proof){ void iz3translation_direct_show_step(iz3translation_direct *p, iz3mgr::ast proof){
p->show_step(proof); p->show_step(proof);
} }
void iz3translation_direct_show_marked(iz3translation_direct *p, iz3mgr::ast proof){ void iz3translation_direct_show_marked(iz3translation_direct *p, iz3mgr::ast proof){
p->show_marked(proof); p->show_marked(proof);
} }
void iz3translation_direct_show_lit(iz3translation_direct *p, iz3mgr::ast lit){ void iz3translation_direct_show_lit(iz3translation_direct *p, iz3mgr::ast lit){
p->show_lit(lit); p->show_lit(lit);
} }
void iz3translation_direct_show_z3_lit(iz3translation_direct *p, iz3mgr::ast a){ void iz3translation_direct_show_z3_lit(iz3translation_direct *p, iz3mgr::ast a){
p->show_z3_lit(a); p->show_z3_lit(a);
} }
void iz3translation_direct_pfgoto(iz3translation_direct *p, iz3mgr::ast proof){ void iz3translation_direct_pfgoto(iz3translation_direct *p, iz3mgr::ast proof){
p->pfgoto(proof); p->pfgoto(proof);
} }
void iz3translation_direct_show_nll(iz3translation_direct *p, non_local_lits *nll){ void iz3translation_direct_show_nll(iz3translation_direct *p, non_local_lits *nll){
p->show_nll(nll); p->show_nll(nll);
} }
void iz3translation_direct_pfback(iz3translation_direct *p ){ void iz3translation_direct_pfback(iz3translation_direct *p ){
p->pfback(); p->pfback();
} }
void iz3translation_direct_pffwd(iz3translation_direct *p ){ void iz3translation_direct_pffwd(iz3translation_direct *p ){
p->pffwd(); p->pffwd();
} }
void iz3translation_direct_pfprem(iz3translation_direct *p, int i){ void iz3translation_direct_pfprem(iz3translation_direct *p, int i){
p->pfprem(i); p->pfprem(i);
} }
struct stdio_fixer { struct stdio_fixer {
stdio_fixer(){ stdio_fixer(){
std::cout.rdbuf()->pubsetbuf(0,0); std::cout.rdbuf()->pubsetbuf(0,0);
} }
} my_stdio_fixer; } my_stdio_fixer;
#endif #endif

View file

@ -4761,6 +4761,25 @@ namespace polynomial {
} }
} }
// muladd may throw if the cancel flag is set.
// So we wrap the degree2pos set and reset
// in a scoped class to ensure the state is clean
// on exit.
struct scoped_degree2pos {
imp& pm;
polynomial const* p;
scoped_degree2pos(imp& pm, polynomial const* p):
pm(pm),
p(p)
{
pm.save_degree2pos(p);
}
~scoped_degree2pos() {
pm.reset_degree2pos(p);
}
};
/** /**
\brief Given an univariate polynomial p(x) and a polynomial q(y_1, ..., y_n), \brief Given an univariate polynomial p(x) and a polynomial q(y_1, ..., y_n),
return a polynomial r(y_1, ..., y_n) = p(q(y_1, ..., y_n)). return a polynomial r(y_1, ..., y_n) = p(q(y_1, ..., y_n)).
@ -4773,7 +4792,7 @@ namespace polynomial {
} }
var x = max_var(p); var x = max_var(p);
unsigned d = degree(p, x); unsigned d = degree(p, x);
save_degree2pos(p); scoped_degree2pos _sd2pos(*this, p);
scoped_numeral a(m()); scoped_numeral a(m());
m_manager.set(a, p->a(m_degree2pos[d])); m_manager.set(a, p->a(m_degree2pos[d]));
r = mk_const(a); r = mk_const(a);
@ -4785,7 +4804,6 @@ namespace polynomial {
m_manager.reset(a); m_manager.reset(a);
r = muladd(q, r, a); r = muladd(q, r, a);
} }
reset_degree2pos(p);
} }
polynomial * mk_x_minus_y(var x, var y) { polynomial * mk_x_minus_y(var x, var y) {

View file

@ -63,7 +63,7 @@ def_module_params('fixedpoint',
('duality.recursion_bound', UINT, UINT_MAX, ('duality.recursion_bound', UINT, UINT_MAX,
'Recursion bound for stratified inlining'), 'Recursion bound for stratified inlining'),
('duality.profile', BOOL, False, 'profile run time'), ('duality.profile', BOOL, False, 'profile run time'),
('duality.mbqi', BOOL, True, 'use model-based quantifier instantion'), ('duality.mbqi', BOOL, True, 'use model-based quantifier instantiation'),
('duality.batch_expand', BOOL, False, 'use batch expansion'), ('duality.batch_expand', BOOL, False, 'use batch expansion'),
('duality.conjecture_file', STRING, '', 'save conjectures to file'), ('duality.conjecture_file', STRING, '', 'save conjectures to file'),
('pdr.bfs_model_search', BOOL, True, ('pdr.bfs_model_search', BOOL, True,

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2013 Microsoft Corporation Copyright (c) 2013 Microsoft Corporation
Module Name: Module Name:
duality_dl_interface.cpp duality_dl_interface.cpp
Abstract: Abstract:
SMT2 interface for Duality SMT2 interface for Duality
Author: Author:
Krystof Hoder (t-khoder) 2011-9-22. Krystof Hoder (t-khoder) 2011-9-22.
Modified by Ken McMIllan (kenmcmil) 2013-4-18. Modified by Ken McMIllan (kenmcmil) 2013-4-18.
Revision History: Revision History:
--*/ --*/
#include "dl_context.h" #include "dl_context.h"
#include "dl_mk_coi_filter.h" #include "dl_mk_coi_filter.h"
@ -87,28 +87,28 @@ namespace Duality {
}; };
dl_interface::dl_interface(datalog::context& dl_ctx) : dl_interface::dl_interface(datalog::context& dl_ctx) :
engine_base(dl_ctx.get_manager(), "duality"), engine_base(dl_ctx.get_manager(), "duality"),
m_ctx(dl_ctx) m_ctx(dl_ctx)
{ {
_d = 0; _d = 0;
// dl_ctx.get_manager().toggle_proof_mode(PGM_FINE); // dl_ctx.get_manager().toggle_proof_mode(PGM_FINE);
} }
dl_interface::~dl_interface() { dl_interface::~dl_interface() {
if(_d) if(_d)
dealloc(_d); dealloc(_d);
} }
// //
// Check if the new rules are weaker so that we can // Check if the new rules are weaker so that we can
// re-use existing context. // re-use existing context.
// //
#if 0 #if 0
void dl_interface::check_reset() { void dl_interface::check_reset() {
// TODO // TODO
datalog::rule_ref_vector const& new_rules = m_ctx.get_rules().get_rules(); datalog::rule_ref_vector const& new_rules = m_ctx.get_rules().get_rules();
datalog::rule_ref_vector const& old_rules = m_old_rules.get_rules(); datalog::rule_ref_vector const& old_rules = m_old_rules.get_rules();
@ -127,11 +127,11 @@ void dl_interface::check_reset() {
} }
m_old_rules.reset(); m_old_rules.reset();
m_old_rules.add_rules(new_rules.size(), new_rules.c_ptr()); m_old_rules.add_rules(new_rules.size(), new_rules.c_ptr());
} }
#endif #endif
lbool dl_interface::query(::expr * query) { lbool dl_interface::query(::expr * query) {
// we restore the initial state in the datalog context // we restore the initial state in the datalog context
m_ctx.ensure_opened(); m_ctx.ensure_opened();
@ -364,29 +364,29 @@ lbool dl_interface::query(::expr * query) {
return l_false; return l_false;
} }
return l_true; return l_true;
} }
expr_ref dl_interface::get_cover_delta(int level, ::func_decl* pred_orig) { expr_ref dl_interface::get_cover_delta(int level, ::func_decl* pred_orig) {
SASSERT(false); SASSERT(false);
return expr_ref(m_ctx.get_manager()); return expr_ref(m_ctx.get_manager());
} }
void dl_interface::add_cover(int level, ::func_decl* pred, ::expr* property) { void dl_interface::add_cover(int level, ::func_decl* pred, ::expr* property) {
SASSERT(false); SASSERT(false);
} }
unsigned dl_interface::get_num_levels(::func_decl* pred) { unsigned dl_interface::get_num_levels(::func_decl* pred) {
SASSERT(false); SASSERT(false);
return 0; return 0;
} }
void dl_interface::collect_statistics(::statistics& st) const { void dl_interface::collect_statistics(::statistics& st) const {
} }
void dl_interface::reset_statistics() { void dl_interface::reset_statistics() {
} }
static hash_set<func_decl> *local_func_decls; static hash_set<func_decl> *local_func_decls;
static void print_proof(dl_interface *d, std::ostream& out, RPFP *tree, RPFP::Node *root) { static void print_proof(dl_interface *d, std::ostream& out, RPFP *tree, RPFP::Node *root) {
context &ctx = d->dd()->ctx; context &ctx = d->dd()->ctx;
@ -456,14 +456,14 @@ static hash_set<func_decl> *local_func_decls;
} }
out << " )"; out << " )";
out << ")\n"; out << ")\n";
} }
void dl_interface::display_certificate(std::ostream& out) const { void dl_interface::display_certificate(std::ostream& out) const {
((dl_interface *)this)->display_certificate_non_const(out); ((dl_interface *)this)->display_certificate_non_const(out);
} }
void dl_interface::display_certificate_non_const(std::ostream& out) { void dl_interface::display_certificate_non_const(std::ostream& out) {
if(_d->status == StatusModel){ if(_d->status == StatusModel){
ast_manager &m = m_ctx.get_manager(); ast_manager &m = m_ctx.get_manager();
model_ref md = get_model(); model_ref md = get_model();
@ -499,14 +499,14 @@ void dl_interface::display_certificate_non_const(std::ostream& out) {
model_v2_pp(out,mod); model_v2_pp(out,mod);
out << "\")\n"; out << "\")\n";
} }
} }
expr_ref dl_interface::get_answer() { expr_ref dl_interface::get_answer() {
SASSERT(false); SASSERT(false);
return expr_ref(m_ctx.get_manager()); return expr_ref(m_ctx.get_manager());
} }
void dl_interface::cancel() { void dl_interface::cancel() {
#if 0 #if 0
if(_d && _d->ls) if(_d && _d->ls)
_d->ls->cancel(); _d->ls->cancel();
@ -515,15 +515,15 @@ void dl_interface::cancel() {
std::cout << "(error \"duality canceled\")\nunknown\n"; std::cout << "(error \"duality canceled\")\nunknown\n";
abort(); abort();
#endif #endif
} }
void dl_interface::cleanup() { void dl_interface::cleanup() {
} }
void dl_interface::updt_params() { void dl_interface::updt_params() {
} }
model_ref dl_interface::get_model() { model_ref dl_interface::get_model() {
ast_manager &m = m_ctx.get_manager(); ast_manager &m = m_ctx.get_manager();
model_ref md(alloc(::model, m)); model_ref md(alloc(::model, m));
std::vector<RPFP::Node *> &nodes = _d->rpfp->nodes; std::vector<RPFP::Node *> &nodes = _d->rpfp->nodes;
@ -549,7 +549,7 @@ model_ref dl_interface::get_model() {
} }
} }
return md; return md;
} }
static proof_ref extract_proof(dl_interface *d, RPFP *tree, RPFP::Node *root) { static proof_ref extract_proof(dl_interface *d, RPFP *tree, RPFP::Node *root) {
context &ctx = d->dd()->ctx; context &ctx = d->dd()->ctx;
@ -608,9 +608,9 @@ model_ref dl_interface::get_model() {
proof_ref res(mgr.mk_hyper_resolve(pprems.size(),&pprems[0], ctx.uncook(conc), pos, substs),mgr); proof_ref res(mgr.mk_hyper_resolve(pprems.size(),&pprems[0], ctx.uncook(conc), pos, substs),mgr);
return res; return res;
} }
proof_ref dl_interface::get_proof() { proof_ref dl_interface::get_proof() {
if(_d->status == StatusRefutation){ if(_d->status == StatusRefutation){
hash_set<func_decl> locals; hash_set<func_decl> locals;
local_func_decls = &locals; local_func_decls = &locals;
@ -618,5 +618,5 @@ proof_ref dl_interface::get_proof() {
} }
else else
return proof_ref(m_ctx.get_manager()); return proof_ref(m_ctx.get_manager());
} }
} }

View file

@ -1,22 +1,22 @@
/*++ /*++
Copyright (c) 2013 Microsoft Corporation Copyright (c) 2013 Microsoft Corporation
Module Name: Module Name:
duality_dl_interface.h duality_dl_interface.h
Abstract: Abstract:
SMT2 interface for Duality SMT2 interface for Duality
Author: Author:
Krystof Hoder (t-khoder) 2011-9-22. Krystof Hoder (t-khoder) 2011-9-22.
Modified by Ken McMIllan (kenmcmil) 2013-4-18. Modified by Ken McMIllan (kenmcmil) 2013-4-18.
Revision History: Revision History:
--*/ --*/
#ifndef _DUALITY_DL_INTERFACE_H_ #ifndef _DUALITY_DL_INTERFACE_H_
#define _DUALITY_DL_INTERFACE_H_ #define _DUALITY_DL_INTERFACE_H_

View file

@ -282,7 +282,7 @@ class fix_dl_var_tactic : public tactic {
expr_ref new_curr(m); expr_ref new_curr(m);
proof_ref new_pr(m); proof_ref new_pr(m);
unsigned size = g->size(); unsigned size = g->size();
for (unsigned idx = 0; idx < size; idx++) { for (unsigned idx = 0; !g->inconsistent() && idx < size; idx++) {
expr * curr = g->form(idx); expr * curr = g->form(idx);
m_rw(curr, new_curr, new_pr); m_rw(curr, new_curr, new_pr);
if (produce_proofs) { if (produce_proofs) {

View file

@ -447,9 +447,28 @@ void test_bvneg() {
Z3_del_context(ctx); Z3_del_context(ctx);
} }
static bool cb_called = false;
static void my_cb(Z3_context, Z3_error_code) {
cb_called = true;
}
static void test_mk_distinct() {
Z3_config cfg = Z3_mk_config();
Z3_context ctx = Z3_mk_context(cfg);
Z3_set_error_handler(ctx, my_cb);
Z3_sort bv8 = Z3_mk_bv_sort(ctx, 8);
Z3_sort bv32 = Z3_mk_bv_sort(ctx, 32);
Z3_ast args[] = { Z3_mk_int64(ctx, 0, bv8), Z3_mk_int64(ctx, 0, bv32) };
Z3_ast d = Z3_mk_distinct(ctx, 2, args);
SASSERT(cb_called);
}
void tst_api() { void tst_api() {
test_apps(); test_apps();
test_bvneg(); test_bvneg();
test_mk_distinct();
// bv_invariant(); // bv_invariant();
} }
#else #else

View file

@ -1475,6 +1475,9 @@ void mpf_manager::mk_ninf(unsigned ebits, unsigned sbits, mpf & o) {
void mpf_manager::unpack(mpf & o, bool normalize) { void mpf_manager::unpack(mpf & o, bool normalize) {
// Insert the hidden bit or adjust the exponent of denormal numbers. // Insert the hidden bit or adjust the exponent of denormal numbers.
if (is_zero(o))
return;
if (is_normal(o)) if (is_normal(o))
m_mpz_manager.add(o.significand, m_powers2(o.sbits-1), o.significand); m_mpz_manager.add(o.significand, m_powers2(o.sbits-1), o.significand);
else { else {