mirror of
https://github.com/Z3Prover/z3
synced 2025-04-08 10:25:18 +00:00
Merge branch 'master' of https://github.com/Z3Prover/z3
This commit is contained in:
commit
9cc4fc919d
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -9,6 +9,7 @@ callgrind.out.*
|
|||
# OCaml generated files
|
||||
*.a
|
||||
*.cma
|
||||
*.cmo
|
||||
*.cmi
|
||||
*.cmxa
|
||||
ocamlz3
|
||||
|
@ -64,6 +65,12 @@ src/util/version.h
|
|||
src/api/java/Native.cpp
|
||||
src/api/java/Native.java
|
||||
src/api/java/enumerations/*.java
|
||||
src/api/ml/z3native_stubs.c
|
||||
src/api/ml/z3native.ml
|
||||
src/api/ml/z3enums.ml
|
||||
src/api/ml/z3native.mli
|
||||
src/api/ml/z3enums.mli
|
||||
src/api/ml/z3.mllib
|
||||
*.bak
|
||||
doc/api
|
||||
doc/code
|
||||
|
|
3
README
3
README
|
@ -39,3 +39,6 @@ Remark: clang does not support OpenMP yet.
|
|||
CXX=clang++ CC=clang python scripts/mk_make.py
|
||||
cd build
|
||||
make
|
||||
|
||||
|
||||
To clean Z3 you can delete the build directory and run the mk_make.py script again.
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
RELEASE NOTES
|
||||
|
||||
Version 4.4.0
|
||||
=============
|
||||
|
||||
- New feature: Support for the theory of floating-point numbers. This comes in the form of logics (QF_FP and QF_FPBV), tactics (qffp and qffpbv), as well as a theory plugin that allows theory combinations. Z3 supports the official SMT theory definition of FP (see http://smtlib.cs.uiowa.edu/theories/FloatingPoint.smt2) in SMT2 files, as well as all APIs.
|
||||
|
||||
- New feature: Stochastic local search engine for bit-vector formulas (see the qfbv-sls tactic).
|
||||
See also: Froehlich, Biere, Wintersteiger, Hamadi: Stochastic Local Search
|
||||
for Satisfiability Modulo Theories, AAAI 2015.
|
||||
|
||||
- Upgrade: This release includes a brand new OCaml/ML API that is much better integrated with the build system, and hopefully also easier to use than the previous one.
|
||||
|
||||
- Fixed various bugs reported by Marc Brockschmidt, Venkatesh-Prasad Ranganath, Enric Carbonell, Morgan Deters, Tom Ball, Malte Schwerhoff, Amir Ebrahimi, Codeplex users rsas, clockish, Heizmann, susmitj, steimann, and Stackoverflow users user297886.
|
||||
|
||||
|
||||
Version 4.3.2
|
||||
=============
|
||||
|
||||
- Added preliminary support for the theory of floating point numbers (tactics qffpa, qffpabv, and logics QF_FPA, QF_FPABV).
|
||||
|
||||
- Added the interpolation features of iZ3, which are now integrated into the Z3.
|
||||
- Added the interpolation features of iZ3, which are now integrated into Z3.
|
||||
|
||||
- Fixed a multitude of bugs and inconsistencies that were reported to us either in person, by email, or on Codeplex. Of those that we do have records of, we would like to express our gratitude to:
|
||||
Vladimir Klebanov, Konrad Jamrozik, Nuno Lopes, Carsten Ruetz, Esteban Pavese, Tomer Weiss, Ilya Mironov, Gabriele Paganelli, Levent Erkok, Fabian Emmes, David Cok, Etienne Kneuss, Arlen Cox, Matt Lewis, Carsten Otto, Paul Jackson, David Monniaux, Markus Rabe, Martin Pluecker, Jasmin Blanchette, Jules Villard, Andrew Gacek, George Karpenkov, Joerg Pfaehler, and Pablo Aledo
|
||||
|
|
|
@ -1,11 +1,52 @@
|
|||
import os
|
||||
import shutil
|
||||
import re
|
||||
import getopt
|
||||
import pydoc
|
||||
import sys
|
||||
import subprocess
|
||||
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):
|
||||
if not os.path.exists(d):
|
||||
os.makedirs(d)
|
||||
|
@ -22,15 +63,30 @@ def cleanup_API(inf, outf):
|
|||
_outf.write(line)
|
||||
|
||||
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('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')
|
||||
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_polynomial.h', 'tmp/z3_polynomial.h')
|
||||
cleanup_API('../src/api/z3_rcf.h', 'tmp/z3_rcf.h')
|
||||
cleanup_API('../src/api/z3_interp.h', 'tmp/z3_interp.h')
|
||||
cleanup_API('../src/api/z3_fpa.h', 'tmp/z3_fpa.h')
|
||||
|
||||
print "Removed annotations from z3_api.h."
|
||||
try:
|
||||
|
@ -46,6 +102,7 @@ try:
|
|||
os.remove('tmp/z3_polynomial.h')
|
||||
os.remove('tmp/z3_rcf.h')
|
||||
os.remove('tmp/z3_interp.h')
|
||||
os.remove('tmp/z3_fpa.h')
|
||||
print "Removed temporary file z3_api.h."
|
||||
os.remove('tmp/website.dox')
|
||||
print "Removed temporary file website.dox"
|
||||
|
@ -57,6 +114,14 @@ try:
|
|||
pydoc.writedoc('z3')
|
||||
shutil.move('z3.html', 'api/html/z3.html')
|
||||
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'."
|
||||
except:
|
||||
print "ERROR: failed to generate documentation"
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
Z3 is a high-performance theorem prover being developed at <a class="el"
|
||||
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.
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
|||
- \ref cppapi
|
||||
- <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="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>.
|
||||
*/
|
||||
|
|
|
@ -713,39 +713,10 @@ FILE_PATTERNS = website.dox \
|
|||
z3_polynomial.h \
|
||||
z3_rcf.h \
|
||||
z3_interp.h \
|
||||
z3_fpa.h \
|
||||
z3++.h \
|
||||
z3py.py \
|
||||
ApplyResult.cs \
|
||||
AST.cs \
|
||||
ASTMap.cs \
|
||||
ASTVector.cs \
|
||||
Config.cs \
|
||||
Constructor.cs \
|
||||
Context.cs \
|
||||
DecRefQUeue.cs \
|
||||
Enumerations.cs \
|
||||
Expr.cs \
|
||||
FuncDecl.cs \
|
||||
FuncInterp.cs \
|
||||
Goal.cs \
|
||||
Log.cs \
|
||||
Model.cs \
|
||||
Native.cs \
|
||||
Numeral.cs \
|
||||
Params.cs \
|
||||
Pattern.cs \
|
||||
Probe.cs \
|
||||
Quantifier.cs \
|
||||
Solver.cs \
|
||||
Sort.cs \
|
||||
Statistics.cs \
|
||||
Status.cs \
|
||||
Symbol.cs \
|
||||
Tactic.cs \
|
||||
Util.cs \
|
||||
Version.cs \
|
||||
Z3Exception.cs \
|
||||
Z3Object.cs \
|
||||
*.cs \
|
||||
*.java
|
||||
|
||||
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include<vector>
|
||||
#include"z3++.h"
|
||||
|
||||
|
||||
using namespace z3;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Demonstration of how Z3 can be used to prove validity of
|
||||
De Morgan's Duality Law: {e not(x and y) <-> (not x) or ( not y) }
|
||||
|
@ -21,6 +23,7 @@ void demorgan() {
|
|||
// adding the negation of the conjecture as a constraint.
|
||||
s.add(!conjecture);
|
||||
std::cout << s << "\n";
|
||||
std::cout << s.to_smt2() << "\n";
|
||||
switch (s.check()) {
|
||||
case unsat: std::cout << "de-Morgan is valid\n"; break;
|
||||
case sat: std::cout << "de-Morgan is not valid\n"; break;
|
||||
|
@ -974,7 +977,17 @@ void substitute_example() {
|
|||
std::cout << new_f << std::endl;
|
||||
}
|
||||
|
||||
void extract_example() {
|
||||
std::cout << "extract example\n";
|
||||
context c;
|
||||
expr x(c);
|
||||
x = c.constant("x", c.bv_sort(32));
|
||||
expr y = x.extract(21, 10);
|
||||
std::cout << y << " " << y.hi() << " " << y.lo() << "\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
try {
|
||||
demorgan(); std::cout << "\n";
|
||||
find_model_example1(); std::cout << "\n";
|
||||
|
@ -1012,6 +1025,7 @@ int main() {
|
|||
expr_vector_example(); std::cout << "\n";
|
||||
exists_expr_vector_example(); std::cout << "\n";
|
||||
substitute_example(); std::cout << "\n";
|
||||
extract_example(); std::cout << "\n";
|
||||
std::cout << "done\n";
|
||||
}
|
||||
catch (exception & ex) {
|
||||
|
|
|
@ -2595,6 +2595,97 @@ void substitute_vars_example() {
|
|||
Z3_del_context(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Demonstrates some basic features of the FloatingPoint theory.
|
||||
*/
|
||||
|
||||
void fpa_example() {
|
||||
Z3_config cfg;
|
||||
Z3_context ctx;
|
||||
Z3_sort double_sort, rm_sort;
|
||||
Z3_symbol s_rm, s_x, s_y, s_x_plus_y;
|
||||
Z3_ast rm, x, y, n, x_plus_y, c1, c2, c3, c4, c5, c6;
|
||||
Z3_ast args[2], args2[2], and_args[3], args3[3];
|
||||
|
||||
printf("\nFPA-example\n");
|
||||
LOG_MSG("FPA-example");
|
||||
|
||||
cfg = Z3_mk_config();
|
||||
ctx = Z3_mk_context(cfg);
|
||||
Z3_del_config(cfg);
|
||||
|
||||
double_sort = Z3_mk_fpa_sort(ctx, 11, 53);
|
||||
rm_sort = Z3_mk_fpa_rounding_mode_sort(ctx);
|
||||
|
||||
// Show that there are x, y s.t. (x + y) = 42.0 (with rounding mode).
|
||||
s_rm = Z3_mk_string_symbol(ctx, "rm");
|
||||
rm = Z3_mk_const(ctx, s_rm, rm_sort);
|
||||
s_x = Z3_mk_string_symbol(ctx, "x");
|
||||
s_y = Z3_mk_string_symbol(ctx, "y");
|
||||
x = Z3_mk_const(ctx, s_x, double_sort);
|
||||
y = Z3_mk_const(ctx, s_y, double_sort);
|
||||
n = Z3_mk_fpa_numeral_double(ctx, 42.0, double_sort);
|
||||
|
||||
s_x_plus_y = Z3_mk_string_symbol(ctx, "x_plus_y");
|
||||
x_plus_y = Z3_mk_const(ctx, s_x_plus_y, double_sort);
|
||||
c1 = Z3_mk_eq(ctx, x_plus_y, Z3_mk_fpa_add(ctx, rm, x, y));
|
||||
|
||||
args[0] = c1;
|
||||
args[1] = Z3_mk_eq(ctx, x_plus_y, n);
|
||||
c2 = Z3_mk_and(ctx, 2, (Z3_ast*)&args);
|
||||
|
||||
args2[0] = c2;
|
||||
args2[1] = Z3_mk_not(ctx, Z3_mk_eq(ctx, rm, Z3_mk_fpa_rtz(ctx)));
|
||||
c3 = Z3_mk_and(ctx, 2, (Z3_ast*)&args2);
|
||||
|
||||
and_args[0] = Z3_mk_not(ctx, Z3_mk_fpa_is_zero(ctx, y));
|
||||
and_args[1] = Z3_mk_not(ctx, Z3_mk_fpa_is_nan(ctx, y));
|
||||
and_args[2] = Z3_mk_not(ctx, Z3_mk_fpa_is_infinite(ctx, y));
|
||||
args3[0] = c3;
|
||||
args3[1] = Z3_mk_and(ctx, 3, and_args);
|
||||
c4 = Z3_mk_and(ctx, 2, (Z3_ast*)&args3);
|
||||
|
||||
printf("c4: %s\n", Z3_ast_to_string(ctx, c4));
|
||||
Z3_push(ctx);
|
||||
Z3_assert_cnstr(ctx, c4);
|
||||
check(ctx, Z3_L_TRUE);
|
||||
Z3_pop(ctx, 1);
|
||||
|
||||
// Show that the following are equal:
|
||||
// (fp #b0 #b10000000001 #xc000000000000)
|
||||
// ((_ to_fp 11 53) #x401c000000000000))
|
||||
// ((_ to_fp 11 53) RTZ 1.75 2)))
|
||||
// ((_ to_fp 11 53) RTZ 7.0)))
|
||||
|
||||
Z3_push(ctx);
|
||||
c1 = Z3_mk_fpa_fp(ctx,
|
||||
Z3_mk_numeral(ctx, "0", Z3_mk_bv_sort(ctx, 1)),
|
||||
Z3_mk_numeral(ctx, "3377699720527872", Z3_mk_bv_sort(ctx, 52)),
|
||||
Z3_mk_numeral(ctx, "1025", Z3_mk_bv_sort(ctx, 11)));
|
||||
c2 = Z3_mk_fpa_to_fp_bv(ctx,
|
||||
Z3_mk_numeral(ctx, "4619567317775286272", Z3_mk_bv_sort(ctx, 64)),
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
c3 = Z3_mk_fpa_to_fp_int_real(ctx,
|
||||
Z3_mk_fpa_rtz(ctx),
|
||||
Z3_mk_numeral(ctx, "2", Z3_mk_int_sort(ctx)),
|
||||
Z3_mk_numeral(ctx, "1.75", Z3_mk_real_sort(ctx)),
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
c4 = Z3_mk_fpa_to_fp_real(ctx,
|
||||
Z3_mk_fpa_rtz(ctx),
|
||||
Z3_mk_numeral(ctx, "7.0", Z3_mk_real_sort(ctx)),
|
||||
Z3_mk_fpa_sort(ctx, 11, 53));
|
||||
args3[0] = Z3_mk_eq(ctx, c1, c2);
|
||||
args3[1] = Z3_mk_eq(ctx, c1, c3);
|
||||
args3[2] = Z3_mk_eq(ctx, c1, c4);
|
||||
c5 = Z3_mk_and(ctx, 3, args3);
|
||||
|
||||
printf("c5: %s\n", Z3_ast_to_string(ctx, c5));
|
||||
Z3_assert_cnstr(ctx, c5);
|
||||
check(ctx, Z3_L_TRUE);
|
||||
Z3_pop(ctx, 1);
|
||||
|
||||
Z3_del_context(ctx);
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
@ -2640,5 +2731,6 @@ int main() {
|
|||
smt2parser_example();
|
||||
substitute_example();
|
||||
substitute_vars_example();
|
||||
fpa_example();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1041,7 +1041,7 @@ namespace test_mapi
|
|||
{
|
||||
Console.WriteLine("LogicTest");
|
||||
|
||||
Context.ToggleWarningMessages(true);
|
||||
Microsoft.Z3.Global.ToggleWarningMessages(true);
|
||||
|
||||
BitVecSort bvs = ctx.MkBitVecSort(32);
|
||||
Expr x = ctx.MkConst("x", bvs);
|
||||
|
@ -2010,6 +2010,47 @@ namespace test_mapi
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract unsatisfiable core example with AssertAndTrack
|
||||
/// </summary>
|
||||
public static void UnsatCoreAndProofExample2(Context ctx)
|
||||
{
|
||||
Console.WriteLine("UnsatCoreAndProofExample2");
|
||||
|
||||
Solver solver = ctx.MkSolver();
|
||||
|
||||
BoolExpr pa = ctx.MkBoolConst("PredA");
|
||||
BoolExpr pb = ctx.MkBoolConst("PredB");
|
||||
BoolExpr pc = ctx.MkBoolConst("PredC");
|
||||
BoolExpr pd = ctx.MkBoolConst("PredD");
|
||||
|
||||
BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc });
|
||||
BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc });
|
||||
BoolExpr f3 = ctx.MkOr(ctx.MkNot(pa), ctx.MkNot(pc));
|
||||
BoolExpr f4 = pd;
|
||||
|
||||
BoolExpr p1 = ctx.MkBoolConst("P1");
|
||||
BoolExpr p2 = ctx.MkBoolConst("P2");
|
||||
BoolExpr p3 = ctx.MkBoolConst("P3");
|
||||
BoolExpr p4 = ctx.MkBoolConst("P4");
|
||||
|
||||
solver.AssertAndTrack(f1, p1);
|
||||
solver.AssertAndTrack(f2, p2);
|
||||
solver.AssertAndTrack(f3, p3);
|
||||
solver.AssertAndTrack(f4, p4);
|
||||
Status result = solver.Check();
|
||||
|
||||
if (result == Status.UNSATISFIABLE)
|
||||
{
|
||||
Console.WriteLine("unsat");
|
||||
Console.WriteLine("core: ");
|
||||
foreach (Expr c in solver.UnsatCore)
|
||||
{
|
||||
Console.WriteLine("{0}", c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void FiniteDomainExample(Context ctx)
|
||||
{
|
||||
Console.WriteLine("FiniteDomainExample");
|
||||
|
@ -2028,11 +2069,89 @@ namespace test_mapi
|
|||
// Console.WriteLine("{0}", ctx.MkEq(s1, t1));
|
||||
}
|
||||
|
||||
public static void FloatingPointExample1(Context ctx)
|
||||
{
|
||||
Console.WriteLine("FloatingPointExample1");
|
||||
|
||||
FPSort s = ctx.MkFPSort(11, 53);
|
||||
Console.WriteLine("Sort: {0}", s);
|
||||
|
||||
FPNum x = (FPNum)ctx.MkNumeral("-1e1", s); /* -1 * 10^1 = -10 */
|
||||
FPNum y = (FPNum)ctx.MkNumeral("-10", s); /* -10 */
|
||||
FPNum z = (FPNum)ctx.MkNumeral("-1.25p3", s); /* -1.25 * 2^3 = -1.25 * 8 = -10 */
|
||||
Console.WriteLine("x={0}; y={1}; z={2}", x.ToString(), y.ToString(), z.ToString());
|
||||
|
||||
BoolExpr a = ctx.MkAnd(ctx.MkFPEq(x, y), ctx.MkFPEq(y, z));
|
||||
Check(ctx, ctx.MkNot(a), Status.UNSATISFIABLE);
|
||||
|
||||
/* nothing is equal to NaN according to floating-point
|
||||
* equality, so NaN == k should be unsatisfiable. */
|
||||
FPExpr k = (FPExpr)ctx.MkConst("x", s);
|
||||
FPExpr nan = ctx.MkFPNaN(s);
|
||||
|
||||
/* solver that runs the default tactic for QF_FP. */
|
||||
Solver slvr = ctx.MkSolver("QF_FP");
|
||||
slvr.Add(ctx.MkFPEq(nan, k));
|
||||
if (slvr.Check() != Status.UNSATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
Console.WriteLine("OK, unsat:" + Environment.NewLine + slvr);
|
||||
|
||||
/* NaN is equal to NaN according to normal equality. */
|
||||
slvr = ctx.MkSolver("QF_FP");
|
||||
slvr.Add(ctx.MkEq(nan, nan));
|
||||
if (slvr.Check() != Status.SATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
Console.WriteLine("OK, sat:" + Environment.NewLine + slvr);
|
||||
|
||||
/* Let's prove -1e1 * -1.25e3 == +100 */
|
||||
x = (FPNum)ctx.MkNumeral("-1e1", s);
|
||||
y = (FPNum)ctx.MkNumeral("-1.25p3", s);
|
||||
FPExpr x_plus_y = (FPExpr)ctx.MkConst("x_plus_y", s);
|
||||
FPNum r = (FPNum)ctx.MkNumeral("100", s);
|
||||
slvr = ctx.MkSolver("QF_FP");
|
||||
|
||||
slvr.Add(ctx.MkEq(x_plus_y, ctx.MkFPMul(ctx.MkFPRoundNearestTiesToAway(), x, y)));
|
||||
slvr.Add(ctx.MkNot(ctx.MkFPEq(x_plus_y, r)));
|
||||
if (slvr.Check() != Status.UNSATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
Console.WriteLine("OK, unsat:" + Environment.NewLine + slvr);
|
||||
}
|
||||
|
||||
public static void FloatingPointExample2(Context ctx)
|
||||
{
|
||||
Console.WriteLine("FloatingPointExample2");
|
||||
FPSort double_sort = ctx.MkFPSort(11, 53);
|
||||
FPRMSort rm_sort = ctx.MkFPRoundingModeSort();
|
||||
|
||||
FPRMExpr rm = (FPRMExpr)ctx.MkConst(ctx.MkSymbol("rm"), rm_sort);
|
||||
BitVecExpr x = (BitVecExpr)ctx.MkConst(ctx.MkSymbol("x"), ctx.MkBitVecSort(64));
|
||||
FPExpr y = (FPExpr)ctx.MkConst(ctx.MkSymbol("y"), double_sort);
|
||||
FPExpr fp_val = ctx.MkFP(42, double_sort);
|
||||
|
||||
BoolExpr c1 = ctx.MkEq(y, fp_val);
|
||||
BoolExpr c2 = ctx.MkEq(x, ctx.MkFPToBV(rm, y, 64, false));
|
||||
BoolExpr c3 = ctx.MkEq(x, ctx.MkBV(42, 64));
|
||||
BoolExpr c4 = ctx.MkEq(ctx.MkNumeral(42, ctx.RealSort), ctx.MkFPToReal(fp_val));
|
||||
BoolExpr c5 = ctx.MkAnd(c1, c2, c3, c4);
|
||||
Console.WriteLine("c5 = " + c5);
|
||||
|
||||
/* Generic solver */
|
||||
Solver s = ctx.MkSolver();
|
||||
s.Assert(c5);
|
||||
|
||||
Console.WriteLine(s);
|
||||
|
||||
if (s.Check() != Status.SATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
|
||||
Console.WriteLine("OK, model: {0}", s.Model.ToString());
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.ToggleWarningMessages(true);
|
||||
Microsoft.Z3.Global.ToggleWarningMessages(true);
|
||||
Log.Open("test.log");
|
||||
|
||||
Console.Write("Z3 Major Version: ");
|
||||
|
@ -2069,6 +2188,8 @@ namespace test_mapi
|
|||
FindSmallModelExample(ctx);
|
||||
SimplifierExample(ctx);
|
||||
FiniteDomainExample(ctx);
|
||||
FloatingPointExample1(ctx);
|
||||
FloatingPointExample2(ctx);
|
||||
}
|
||||
|
||||
// These examples need proof generation turned on.
|
||||
|
@ -2084,6 +2205,7 @@ namespace test_mapi
|
|||
TreeExample(ctx);
|
||||
ForestExample(ctx);
|
||||
UnsatCoreAndProofExample(ctx);
|
||||
UnsatCoreAndProofExample2(ctx);
|
||||
}
|
||||
|
||||
// These examples need proof generation turned on and auto-config set to false.
|
||||
|
|
|
@ -41,7 +41,7 @@ class JavaExample
|
|||
// / </code>
|
||||
// / Where, <code>finv</code>is a fresh function declaration.
|
||||
|
||||
public BoolExpr injAxiom(Context ctx, FuncDecl f, int i) throws Z3Exception
|
||||
public BoolExpr injAxiom(Context ctx, FuncDecl f, int i)
|
||||
{
|
||||
Sort[] domain = f.getDomain();
|
||||
int sz = f.getDomainSize();
|
||||
|
@ -102,7 +102,6 @@ class JavaExample
|
|||
// / Where, <code>finv</code>is a fresh function declaration.
|
||||
|
||||
public BoolExpr injAxiomAbs(Context ctx, FuncDecl f, int i)
|
||||
throws Z3Exception
|
||||
{
|
||||
Sort[] domain = f.getDomain();
|
||||
int sz = f.getDomainSize();
|
||||
|
@ -179,7 +178,7 @@ class JavaExample
|
|||
|
||||
// / "Hello world" example: create a Z3 logical context, and delete it.
|
||||
|
||||
public void simpleExample() throws Z3Exception
|
||||
public void simpleExample()
|
||||
{
|
||||
System.out.println("SimpleExample");
|
||||
Log.append("SimpleExample");
|
||||
|
@ -193,8 +192,7 @@ class JavaExample
|
|||
}
|
||||
}
|
||||
|
||||
Model check(Context ctx, BoolExpr f, Status sat) throws Z3Exception,
|
||||
TestFailedException
|
||||
Model check(Context ctx, BoolExpr f, Status sat) throws TestFailedException
|
||||
{
|
||||
Solver s = ctx.mkSolver();
|
||||
s.add(f);
|
||||
|
@ -207,7 +205,7 @@ class JavaExample
|
|||
}
|
||||
|
||||
void solveTactical(Context ctx, Tactic t, Goal g, Status sat)
|
||||
throws Z3Exception, TestFailedException
|
||||
throws TestFailedException
|
||||
{
|
||||
Solver s = ctx.mkSolver(t);
|
||||
System.out.println("\nTactical solver: " + s);
|
||||
|
@ -220,7 +218,7 @@ class JavaExample
|
|||
throw new TestFailedException();
|
||||
}
|
||||
|
||||
ApplyResult applyTactic(Context ctx, Tactic t, Goal g) throws Z3Exception
|
||||
ApplyResult applyTactic(Context ctx, Tactic t, Goal g)
|
||||
{
|
||||
System.out.println("\nGoal: " + g);
|
||||
|
||||
|
@ -250,15 +248,14 @@ class JavaExample
|
|||
return res;
|
||||
}
|
||||
|
||||
void prove(Context ctx, BoolExpr f, boolean useMBQI) throws Z3Exception,
|
||||
TestFailedException
|
||||
void prove(Context ctx, BoolExpr f, boolean useMBQI) throws TestFailedException
|
||||
{
|
||||
BoolExpr[] assumptions = new BoolExpr[0];
|
||||
prove(ctx, f, useMBQI, assumptions);
|
||||
}
|
||||
|
||||
void prove(Context ctx, BoolExpr f, boolean useMBQI,
|
||||
BoolExpr... assumptions) throws Z3Exception, TestFailedException
|
||||
BoolExpr... assumptions) throws TestFailedException
|
||||
{
|
||||
System.out.println("Proving: " + f);
|
||||
Solver s = ctx.mkSolver();
|
||||
|
@ -283,15 +280,15 @@ class JavaExample
|
|||
}
|
||||
}
|
||||
|
||||
void disprove(Context ctx, BoolExpr f, boolean useMBQI) throws Z3Exception,
|
||||
TestFailedException
|
||||
void disprove(Context ctx, BoolExpr f, boolean useMBQI)
|
||||
throws TestFailedException
|
||||
{
|
||||
BoolExpr[] a = {};
|
||||
disprove(ctx, f, useMBQI, a);
|
||||
}
|
||||
|
||||
void disprove(Context ctx, BoolExpr f, boolean useMBQI,
|
||||
BoolExpr... assumptions) throws Z3Exception, TestFailedException
|
||||
BoolExpr... assumptions) throws TestFailedException
|
||||
{
|
||||
System.out.println("Disproving: " + f);
|
||||
Solver s = ctx.mkSolver();
|
||||
|
@ -316,8 +313,7 @@ class JavaExample
|
|||
}
|
||||
}
|
||||
|
||||
void modelConverterTest(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
void modelConverterTest(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ModelConverterTest");
|
||||
|
||||
|
@ -357,7 +353,7 @@ class JavaExample
|
|||
|
||||
// / A simple array example.
|
||||
|
||||
void arrayExample1(Context ctx) throws Z3Exception, TestFailedException
|
||||
void arrayExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ArrayExample1");
|
||||
Log.append("ArrayExample1");
|
||||
|
@ -407,8 +403,7 @@ class JavaExample
|
|||
|
||||
// / <remarks>This example demonstrates how to use the array
|
||||
// theory.</remarks>
|
||||
public void arrayExample2(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void arrayExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ArrayExample2");
|
||||
Log.append("ArrayExample2");
|
||||
|
@ -457,8 +452,7 @@ class JavaExample
|
|||
|
||||
// / <remarks>This example also shows how to use the <code>distinct</code>
|
||||
// construct.</remarks>
|
||||
public void arrayExample3(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void arrayExample3(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ArrayExample3");
|
||||
Log.append("ArrayExample2");
|
||||
|
@ -497,7 +491,7 @@ class JavaExample
|
|||
|
||||
// / Sudoku solving example.
|
||||
|
||||
void sudokuExample(Context ctx) throws Z3Exception, TestFailedException
|
||||
void sudokuExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("SudokuExample");
|
||||
Log.append("SudokuExample");
|
||||
|
@ -600,7 +594,7 @@ class JavaExample
|
|||
|
||||
// / A basic example of how to use quantifiers.
|
||||
|
||||
void quantifierExample1(Context ctx) throws Z3Exception
|
||||
void quantifierExample1(Context ctx)
|
||||
{
|
||||
System.out.println("QuantifierExample");
|
||||
Log.append("QuantifierExample");
|
||||
|
@ -638,7 +632,7 @@ class JavaExample
|
|||
System.out.println("Quantifier Y: " + y.toString());
|
||||
}
|
||||
|
||||
void quantifierExample2(Context ctx) throws Z3Exception
|
||||
void quantifierExample2(Context ctx)
|
||||
{
|
||||
|
||||
System.out.println("QuantifierExample2");
|
||||
|
@ -694,8 +688,7 @@ class JavaExample
|
|||
// / <code>f</code> is injective in the second argument. <seealso
|
||||
// cref="inj_axiom"/>
|
||||
|
||||
public void quantifierExample3(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void quantifierExample3(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("QuantifierExample3");
|
||||
Log.append("QuantifierExample3");
|
||||
|
@ -736,8 +729,7 @@ class JavaExample
|
|||
// / <code>f</code> is injective in the second argument. <seealso
|
||||
// cref="inj_axiom"/>
|
||||
|
||||
public void quantifierExample4(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void quantifierExample4(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("QuantifierExample4");
|
||||
Log.append("QuantifierExample4");
|
||||
|
@ -776,7 +768,7 @@ class JavaExample
|
|||
|
||||
// / Some basic tests.
|
||||
|
||||
void basicTests(Context ctx) throws Z3Exception, TestFailedException
|
||||
void basicTests(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("BasicTests");
|
||||
|
||||
|
@ -890,7 +882,7 @@ class JavaExample
|
|||
|
||||
// / Some basic expression casting tests.
|
||||
|
||||
void castingTest(Context ctx) throws Z3Exception, TestFailedException
|
||||
void castingTest(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("CastingTest");
|
||||
|
||||
|
@ -1038,7 +1030,7 @@ class JavaExample
|
|||
|
||||
// / Shows how to read an SMT1 file.
|
||||
|
||||
void smt1FileTest(String filename) throws Z3Exception
|
||||
void smt1FileTest(String filename)
|
||||
{
|
||||
System.out.print("SMT File test ");
|
||||
|
||||
|
@ -1054,7 +1046,7 @@ class JavaExample
|
|||
|
||||
// / Shows how to read an SMT2 file.
|
||||
|
||||
void smt2FileTest(String filename) throws Z3Exception
|
||||
void smt2FileTest(String filename)
|
||||
{
|
||||
Date before = new Date();
|
||||
|
||||
|
@ -1095,13 +1087,13 @@ class JavaExample
|
|||
|
||||
// / Shows how to use Solver(logic)
|
||||
|
||||
// / <param name="ctx"></param>
|
||||
void logicExample(Context ctx) throws Z3Exception, TestFailedException
|
||||
// / @param ctx
|
||||
void logicExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("LogicTest");
|
||||
Log.append("LogicTest");
|
||||
|
||||
Context.ToggleWarningMessages(true);
|
||||
com.microsoft.z3.Global.ToggleWarningMessages(true);
|
||||
|
||||
BitVecSort bvs = ctx.mkBitVecSort(32);
|
||||
Expr x = ctx.mkConst("x", bvs);
|
||||
|
@ -1128,7 +1120,7 @@ class JavaExample
|
|||
|
||||
// / Demonstrates how to use the ParOr tactic.
|
||||
|
||||
void parOrExample(Context ctx) throws Z3Exception, TestFailedException
|
||||
void parOrExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ParOrExample");
|
||||
Log.append("ParOrExample");
|
||||
|
@ -1151,7 +1143,7 @@ class JavaExample
|
|||
throw new TestFailedException();
|
||||
}
|
||||
|
||||
void bigIntCheck(Context ctx, RatNum r) throws Z3Exception
|
||||
void bigIntCheck(Context ctx, RatNum r)
|
||||
{
|
||||
System.out.println("Num: " + r.getBigIntNumerator());
|
||||
System.out.println("Den: " + r.getBigIntDenominator());
|
||||
|
@ -1159,8 +1151,7 @@ class JavaExample
|
|||
|
||||
// / Find a model for <code>x xor y</code>.
|
||||
|
||||
public void findModelExample1(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void findModelExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("FindModelExample1");
|
||||
Log.append("FindModelExample1");
|
||||
|
@ -1177,8 +1168,7 @@ class JavaExample
|
|||
// / Find a model for <tt>x < y + 1, x > 2</tt>.
|
||||
// / Then, assert <tt>not(x = y)</tt>, and find another model.
|
||||
|
||||
public void findModelExample2(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void findModelExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("FindModelExample2");
|
||||
Log.append("FindModelExample2");
|
||||
|
@ -1217,8 +1207,7 @@ class JavaExample
|
|||
|
||||
// / <remarks>This function demonstrates how to create uninterpreted
|
||||
// / types and functions.</remarks>
|
||||
public void proveExample1(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void proveExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ProveExample1");
|
||||
Log.append("ProveExample1");
|
||||
|
@ -1264,8 +1253,7 @@ class JavaExample
|
|||
// / <remarks>This example demonstrates how to combine uninterpreted
|
||||
// functions
|
||||
// / and arithmetic.</remarks>
|
||||
public void proveExample2(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void proveExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ProveExample2");
|
||||
Log.append("ProveExample2");
|
||||
|
@ -1319,8 +1307,7 @@ class JavaExample
|
|||
|
||||
// / <remarks>This example also demonstrates how big numbers can be
|
||||
// / created in ctx.</remarks>
|
||||
public void pushPopExample1(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void pushPopExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("PushPopExample1");
|
||||
Log.append("PushPopExample1");
|
||||
|
@ -1386,8 +1373,7 @@ class JavaExample
|
|||
|
||||
// / <remarks>Check that the projection of a tuple
|
||||
// / returns the corresponding element.</remarks>
|
||||
public void tupleExample(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void tupleExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("TupleExample");
|
||||
Log.append("TupleExample");
|
||||
|
@ -1422,8 +1408,7 @@ class JavaExample
|
|||
// / This example disproves that x - 10 <= 0 IFF x <= 10 for (32-bit)
|
||||
// machine integers
|
||||
// / </remarks>
|
||||
public void bitvectorExample1(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void bitvectorExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("BitvectorExample1");
|
||||
Log.append("BitvectorExample1");
|
||||
|
@ -1444,8 +1429,7 @@ class JavaExample
|
|||
|
||||
// / Find x and y such that: x ^ y - 103 == x * y
|
||||
|
||||
public void bitvectorExample2(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void bitvectorExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("BitvectorExample2");
|
||||
Log.append("BitvectorExample2");
|
||||
|
@ -1470,8 +1454,7 @@ class JavaExample
|
|||
|
||||
// / Demonstrates how to use the SMTLIB parser.
|
||||
|
||||
public void parserExample1(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void parserExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ParserExample1");
|
||||
Log.append("ParserExample1");
|
||||
|
@ -1489,8 +1472,7 @@ class JavaExample
|
|||
|
||||
// / Demonstrates how to initialize the parser symbol table.
|
||||
|
||||
public void parserExample2(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void parserExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ParserExample2");
|
||||
Log.append("ParserExample2");
|
||||
|
@ -1532,7 +1514,7 @@ class JavaExample
|
|||
|
||||
// / Display the declarations, assumptions and formulas in a SMT-LIB string.
|
||||
|
||||
public void parserExample4(Context ctx) throws Z3Exception
|
||||
public void parserExample4(Context ctx)
|
||||
{
|
||||
System.out.println("ParserExample4");
|
||||
Log.append("ParserExample4");
|
||||
|
@ -1579,7 +1561,7 @@ class JavaExample
|
|||
|
||||
// / Create an ite-Expr (if-then-else Exprs).
|
||||
|
||||
public void iteExample(Context ctx) throws Z3Exception
|
||||
public void iteExample(Context ctx)
|
||||
{
|
||||
System.out.println("ITEExample");
|
||||
Log.append("ITEExample");
|
||||
|
@ -1594,8 +1576,7 @@ class JavaExample
|
|||
|
||||
// / Create an enumeration data type.
|
||||
|
||||
public void enumExample(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void enumExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("EnumExample");
|
||||
Log.append("EnumExample");
|
||||
|
@ -1642,8 +1623,7 @@ class JavaExample
|
|||
|
||||
// / Create a list datatype.
|
||||
|
||||
public void listExample(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void listExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ListExample");
|
||||
Log.append("ListExample");
|
||||
|
@ -1706,8 +1686,7 @@ class JavaExample
|
|||
|
||||
// / Create a binary tree datatype.
|
||||
|
||||
public void treeExample(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void treeExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("TreeExample");
|
||||
Log.append("TreeExample");
|
||||
|
@ -1779,8 +1758,7 @@ class JavaExample
|
|||
// / forest ::= nil | cons(tree, forest)
|
||||
// / tree ::= nil | cons(forest, forest)
|
||||
// / </remarks>
|
||||
public void forestExample(Context ctx) throws Z3Exception,
|
||||
TestFailedException
|
||||
public void forestExample(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("ForestExample");
|
||||
Log.append("ForestExample");
|
||||
|
@ -1899,7 +1877,7 @@ class JavaExample
|
|||
|
||||
// / Demonstrate how to use #Eval.
|
||||
|
||||
public void evalExample1(Context ctx) throws Z3Exception
|
||||
public void evalExample1(Context ctx)
|
||||
{
|
||||
System.out.println("EvalExample1");
|
||||
Log.append("EvalExample1");
|
||||
|
@ -1939,7 +1917,7 @@ class JavaExample
|
|||
|
||||
// / Demonstrate how to use #Eval on tuples.
|
||||
|
||||
public void evalExample2(Context ctx) throws Z3Exception
|
||||
public void evalExample2(Context ctx)
|
||||
{
|
||||
System.out.println("EvalExample2");
|
||||
Log.append("EvalExample2");
|
||||
|
@ -1990,8 +1968,7 @@ class JavaExample
|
|||
// / control the size of models.
|
||||
|
||||
// / <remarks>Note: this test is specialized to 32-bit bitvectors.</remarks>
|
||||
public void checkSmall(Context ctx, Solver solver,
|
||||
BitVecExpr... to_minimize) throws Z3Exception
|
||||
public void checkSmall(Context ctx, Solver solver, BitVecExpr... to_minimize)
|
||||
{
|
||||
int num_Exprs = to_minimize.length;
|
||||
int[] upper = new int[num_Exprs];
|
||||
|
@ -2063,7 +2040,7 @@ class JavaExample
|
|||
|
||||
// / Reduced-size model generation example.
|
||||
|
||||
public void findSmallModelExample(Context ctx) throws Z3Exception
|
||||
public void findSmallModelExample(Context ctx)
|
||||
{
|
||||
System.out.println("FindSmallModelExample");
|
||||
Log.append("FindSmallModelExample");
|
||||
|
@ -2080,7 +2057,7 @@ class JavaExample
|
|||
|
||||
// / Simplifier example.
|
||||
|
||||
public void simplifierExample(Context ctx) throws Z3Exception
|
||||
public void simplifierExample(Context ctx)
|
||||
{
|
||||
System.out.println("SimplifierExample");
|
||||
Log.append("SimplifierExample");
|
||||
|
@ -2098,7 +2075,7 @@ class JavaExample
|
|||
|
||||
// / Extract unsatisfiable core example
|
||||
|
||||
public void unsatCoreAndProofExample(Context ctx) throws Z3Exception
|
||||
public void unsatCoreAndProofExample(Context ctx)
|
||||
{
|
||||
System.out.println("UnsatCoreAndProofExample");
|
||||
Log.append("UnsatCoreAndProofExample");
|
||||
|
@ -2137,8 +2114,49 @@ class JavaExample
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract unsatisfiable core example with AssertAndTrack
|
||||
|
||||
public void unsatCoreAndProofExample2(Context ctx)
|
||||
{
|
||||
System.out.println("UnsatCoreAndProofExample2");
|
||||
Log.append("UnsatCoreAndProofExample2");
|
||||
|
||||
public void finiteDomainExample(Context ctx) throws Z3Exception
|
||||
Solver solver = ctx.mkSolver();
|
||||
|
||||
BoolExpr pa = ctx.mkBoolConst("PredA");
|
||||
BoolExpr pb = ctx.mkBoolConst("PredB");
|
||||
BoolExpr pc = ctx.mkBoolConst("PredC");
|
||||
BoolExpr pd = ctx.mkBoolConst("PredD");
|
||||
|
||||
BoolExpr f1 = ctx.mkAnd(new BoolExpr[] { pa, pb, pc });
|
||||
BoolExpr f2 = ctx.mkAnd(new BoolExpr[] { pa, ctx.mkNot(pb), pc });
|
||||
BoolExpr f3 = ctx.mkOr(ctx.mkNot(pa), ctx.mkNot(pc));
|
||||
BoolExpr f4 = pd;
|
||||
|
||||
BoolExpr p1 = ctx.mkBoolConst("P1");
|
||||
BoolExpr p2 = ctx.mkBoolConst("P2");
|
||||
BoolExpr p3 = ctx.mkBoolConst("P3");
|
||||
BoolExpr p4 = ctx.mkBoolConst("P4");
|
||||
|
||||
solver.assertAndTrack(f1, p1);
|
||||
solver.assertAndTrack(f2, p2);
|
||||
solver.assertAndTrack(f3, p3);
|
||||
solver.assertAndTrack(f4, p4);
|
||||
Status result = solver.check();
|
||||
|
||||
if (result == Status.UNSATISFIABLE)
|
||||
{
|
||||
System.out.println("unsat");
|
||||
System.out.println("core: ");
|
||||
for (Expr c : solver.getUnsatCore())
|
||||
{
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void finiteDomainExample(Context ctx)
|
||||
{
|
||||
System.out.println("FiniteDomainExample");
|
||||
Log.append("FiniteDomainExample");
|
||||
|
@ -2157,12 +2175,92 @@ class JavaExample
|
|||
// System.out.println(ctx.mkEq(s1, t1));
|
||||
}
|
||||
|
||||
public void floatingPointExample1(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("FloatingPointExample1");
|
||||
Log.append("FloatingPointExample1");
|
||||
|
||||
FPSort s = ctx.mkFPSort(11, 53);
|
||||
System.out.println("Sort: " + s);
|
||||
|
||||
FPNum x = (FPNum)ctx.mkNumeral("-1e1", s); /* -1 * 10^1 = -10 */
|
||||
FPNum y = (FPNum)ctx.mkNumeral("-10", s); /* -10 */
|
||||
FPNum z = (FPNum)ctx.mkNumeral("-1.25p3", s); /* -1.25 * 2^3 = -1.25 * 8 = -10 */
|
||||
System.out.println("x=" + x.toString() +
|
||||
"; y=" + y.toString() +
|
||||
"; z=" + z.toString());
|
||||
|
||||
BoolExpr a = ctx.mkAnd(ctx.mkFPEq(x, y), ctx.mkFPEq(y, z));
|
||||
check(ctx, ctx.mkNot(a), Status.UNSATISFIABLE);
|
||||
|
||||
/* nothing is equal to NaN according to floating-point
|
||||
* equality, so NaN == k should be unsatisfiable. */
|
||||
FPExpr k = (FPExpr)ctx.mkConst("x", s);
|
||||
FPExpr nan = ctx.mkFPNaN(s);
|
||||
|
||||
/* solver that runs the default tactic for QF_FP. */
|
||||
Solver slvr = ctx.mkSolver("QF_FP");
|
||||
slvr.add(ctx.mkFPEq(nan, k));
|
||||
if (slvr.check() != Status.UNSATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
System.out.println("OK, unsat:" + System.getProperty("line.separator") + slvr);
|
||||
|
||||
/* NaN is equal to NaN according to normal equality. */
|
||||
slvr = ctx.mkSolver("QF_FP");
|
||||
slvr.add(ctx.mkEq(nan, nan));
|
||||
if (slvr.check() != Status.SATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
System.out.println("OK, sat:" + System.getProperty("line.separator") + slvr);
|
||||
|
||||
/* Let's prove -1e1 * -1.25e3 == +100 */
|
||||
x = (FPNum)ctx.mkNumeral("-1e1", s);
|
||||
y = (FPNum)ctx.mkNumeral("-1.25p3", s);
|
||||
FPExpr x_plus_y = (FPExpr)ctx.mkConst("x_plus_y", s);
|
||||
FPNum r = (FPNum)ctx.mkNumeral("100", s);
|
||||
slvr = ctx.mkSolver("QF_FP");
|
||||
|
||||
slvr.add(ctx.mkEq(x_plus_y, ctx.mkFPMul(ctx.mkFPRoundNearestTiesToAway(), x, y)));
|
||||
slvr.add(ctx.mkNot(ctx.mkFPEq(x_plus_y, r)));
|
||||
if (slvr.check() != Status.UNSATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
System.out.println("OK, unsat:" + System.getProperty("line.separator") + slvr);
|
||||
}
|
||||
|
||||
public void floatingPointExample2(Context ctx) throws TestFailedException
|
||||
{
|
||||
System.out.println("FloatingPointExample2");
|
||||
Log.append("FloatingPointExample2");
|
||||
FPSort double_sort = ctx.mkFPSort(11, 53);
|
||||
FPRMSort rm_sort = ctx.mkFPRoundingModeSort();
|
||||
|
||||
FPRMExpr rm = (FPRMExpr)ctx.mkConst(ctx.mkSymbol("rm"), rm_sort);
|
||||
BitVecExpr x = (BitVecExpr)ctx.mkConst(ctx.mkSymbol("x"), ctx.mkBitVecSort(64));
|
||||
FPExpr y = (FPExpr)ctx.mkConst(ctx.mkSymbol("y"), double_sort);
|
||||
FPExpr fp_val = ctx.mkFP(42, double_sort);
|
||||
|
||||
BoolExpr c1 = ctx.mkEq(y, fp_val);
|
||||
BoolExpr c2 = ctx.mkEq(x, ctx.mkFPToBV(rm, y, 64, false));
|
||||
BoolExpr c3 = ctx.mkEq(x, ctx.mkBV(42, 64));
|
||||
BoolExpr c4 = ctx.mkEq(ctx.mkNumeral(42, ctx.getRealSort()), ctx.mkFPToReal(fp_val));
|
||||
BoolExpr c5 = ctx.mkAnd(c1, c2, c3, c4);
|
||||
System.out.println("c5 = " + c5);
|
||||
|
||||
/* Generic solver */
|
||||
Solver s = ctx.mkSolver();
|
||||
s.add(c5);
|
||||
|
||||
if (s.check() != Status.SATISFIABLE)
|
||||
throw new TestFailedException();
|
||||
|
||||
System.out.println("OK, model: " + s.getModel().toString());
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JavaExample p = new JavaExample();
|
||||
try
|
||||
{
|
||||
Context.ToggleWarningMessages(true);
|
||||
com.microsoft.z3.Global.ToggleWarningMessages(true);
|
||||
Log.open("test.log");
|
||||
|
||||
System.out.print("Z3 Major Version: ");
|
||||
|
@ -2200,6 +2298,8 @@ class JavaExample
|
|||
p.findSmallModelExample(ctx);
|
||||
p.simplifierExample(ctx);
|
||||
p.finiteDomainExample(ctx);
|
||||
p.floatingPointExample1(ctx);
|
||||
p.floatingPointExample2(ctx);
|
||||
}
|
||||
|
||||
{ // These examples need proof generation turned on.
|
||||
|
@ -2216,6 +2316,7 @@ class JavaExample
|
|||
p.treeExample(ctx);
|
||||
p.forestExample(ctx);
|
||||
p.unsatCoreAndProofExample(ctx);
|
||||
p.unsatCoreAndProofExample2(ctx);
|
||||
}
|
||||
|
||||
{ // These examples need proof generation turned on and auto-config
|
||||
|
|
22
examples/ml/README
Normal file
22
examples/ml/README
Normal file
|
@ -0,0 +1,22 @@
|
|||
Small example using the Z3 ML bindings.
|
||||
To build the example execute
|
||||
make examples
|
||||
in the build directory.
|
||||
|
||||
It will create ml_example in the build directory,
|
||||
which can be run in the build directory via
|
||||
LD_LIBRARY_PATH=. ./ml_example
|
||||
or
|
||||
LD_LIBRARY_PATH=. ./ml_example.byte
|
||||
for the byte-code version.
|
||||
|
||||
If Z3 was installed into the ocamlfind package repository (see src/api/ml/README),
|
||||
then we can compile this example as follows:
|
||||
|
||||
ocamlfind ocamlc -o ml_example.byte -package Z3 -linkpkg ml_example.ml
|
||||
ocamlfind ocamlopt -o ml_example -package Z3 -linkpkg ml_example.ml
|
||||
|
||||
Note that the resulting binaries depend on the shared z3 library, which needs to be
|
||||
in the PATH (Windows), LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (OSX). If Z3 was
|
||||
installed into ocamlfind, the path that should be added is
|
||||
`ocamlfind printconf destdir`/Z3
|
350
examples/ml/ml_example.ml
Normal file
350
examples/ml/ml_example.ml
Normal file
|
@ -0,0 +1,350 @@
|
|||
(*
|
||||
Copyright (C) 2012 Microsoft Corporation
|
||||
Author: CM Wintersteiger (cwinter) 2012-12-17
|
||||
*)
|
||||
|
||||
open Z3
|
||||
open Z3.Symbol
|
||||
open Z3.Sort
|
||||
open Z3.Expr
|
||||
open Z3.Boolean
|
||||
open Z3.FuncDecl
|
||||
open Z3.Goal
|
||||
open Z3.Tactic
|
||||
open Z3.Tactic.ApplyResult
|
||||
open Z3.Probe
|
||||
open Z3.Solver
|
||||
open Z3.Arithmetic
|
||||
open Z3.Arithmetic.Integer
|
||||
open Z3.Arithmetic.Real
|
||||
open Z3.BitVector
|
||||
|
||||
|
||||
exception TestFailedException of string
|
||||
|
||||
(**
|
||||
Model Converter test
|
||||
*)
|
||||
let model_converter_test ( ctx : context ) =
|
||||
Printf.printf "ModelConverterTest\n";
|
||||
let xr = (Expr.mk_const ctx (Symbol.mk_string ctx "x") (Real.mk_sort ctx)) in
|
||||
let yr = (Expr.mk_const ctx (Symbol.mk_string ctx "y") (Real.mk_sort ctx)) in
|
||||
let g4 = (mk_goal ctx true false false ) in
|
||||
(Goal.add g4 [ (mk_gt ctx xr (Real.mk_numeral_nd ctx 10 1)) ]) ;
|
||||
(Goal.add g4 [ (mk_eq ctx
|
||||
yr
|
||||
(Arithmetic.mk_add ctx [ xr; (Real.mk_numeral_nd ctx 1 1) ])) ]) ;
|
||||
(Goal.add g4 [ (mk_gt ctx yr (Real.mk_numeral_nd ctx 1 1)) ]) ;
|
||||
(
|
||||
let ar = (Tactic.apply (mk_tactic ctx "simplify") g4 None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
((is_decided_sat (get_subgoal ar 0)) ||
|
||||
(is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let ar = (Tactic.apply (and_then ctx (mk_tactic ctx ("simplify")) (mk_tactic ctx "solve-eqs") []) g4 None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
((is_decided_sat (get_subgoal ar 0)) ||
|
||||
(is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
;
|
||||
let solver = (mk_solver ctx None) in
|
||||
let f e = (Solver.add solver [ e ]) in
|
||||
ignore (List.map f (get_formulas (get_subgoal ar 0))) ;
|
||||
let q = (check solver []) in
|
||||
if q != SATISFIABLE then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
let m = (get_model solver) in
|
||||
match m with
|
||||
| None -> raise (TestFailedException "")
|
||||
| Some (m) ->
|
||||
Printf.printf "Solver says: %s\n" (string_of_status q) ;
|
||||
Printf.printf "Model: \n%s\n" (Model.to_string m) ;
|
||||
Printf.printf "Converted Model: \n%s\n" (Model.to_string (convert_model ar 0 m))
|
||||
)
|
||||
|
||||
(**
|
||||
Some basic tests.
|
||||
*)
|
||||
let basic_tests ( ctx : context ) =
|
||||
Printf.printf "BasicTests\n" ;
|
||||
let fname = (mk_string ctx "f") in
|
||||
let x = (mk_string ctx "x") in
|
||||
let y = (mk_string ctx "y") in
|
||||
let bs = (Boolean.mk_sort ctx) in
|
||||
let domain = [ bs; bs ] in
|
||||
let f = (FuncDecl.mk_func_decl ctx fname domain bs) in
|
||||
let fapp = (mk_app ctx f
|
||||
[ (Expr.mk_const ctx x bs); (Expr.mk_const ctx y bs) ]) in
|
||||
let fargs2 = [ (mk_fresh_const ctx "cp" bs) ] in
|
||||
let domain2 = [ bs ] in
|
||||
let fapp2 = (mk_app ctx (mk_fresh_func_decl ctx "fp" domain2 bs) fargs2) in
|
||||
let trivial_eq = (mk_eq ctx fapp fapp) in
|
||||
let nontrivial_eq = (mk_eq ctx fapp fapp2) in
|
||||
let g = (mk_goal ctx true false false) in
|
||||
(Goal.add g [ trivial_eq ]) ;
|
||||
(Goal.add g [ nontrivial_eq ]) ;
|
||||
Printf.printf "%s\n" ("Goal: " ^ (Goal.to_string g)) ;
|
||||
(
|
||||
let solver = (mk_solver ctx None) in
|
||||
(List.iter (fun a -> (Solver.add solver [ a ])) (get_formulas g)) ;
|
||||
if (check solver []) != SATISFIABLE then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let ar = (Tactic.apply (mk_tactic ctx "simplify") g None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
((is_decided_sat (get_subgoal ar 0)) ||
|
||||
(is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let ar = (Tactic.apply (mk_tactic ctx "smt") g None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
(not (is_decided_sat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(Goal.add g [ (mk_eq ctx
|
||||
(mk_numeral_int ctx 1 (BitVector.mk_sort ctx 32))
|
||||
(mk_numeral_int ctx 2 (BitVector.mk_sort ctx 32))) ] )
|
||||
;
|
||||
(
|
||||
let ar = (Tactic.apply (mk_tactic ctx "smt") g None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
(not (is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let g2 = (mk_goal ctx true true false) in
|
||||
let ar = (Tactic.apply (mk_tactic ctx "smt") g2 None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
(not (is_decided_sat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let g2 = (mk_goal ctx true true false) in
|
||||
(Goal.add g2 [ (Boolean.mk_false ctx) ]) ;
|
||||
let ar = (Tactic.apply (mk_tactic ctx "smt") g2 None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
(not (is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
(
|
||||
let g3 = (mk_goal ctx true true false) in
|
||||
let xc = (Expr.mk_const ctx (Symbol.mk_string ctx "x") (Integer.mk_sort ctx)) in
|
||||
let yc = (Expr.mk_const ctx (Symbol.mk_string ctx "y") (Integer.mk_sort ctx)) in
|
||||
(Goal.add g3 [ (mk_eq ctx xc (mk_numeral_int ctx 1 (Integer.mk_sort ctx))) ]) ;
|
||||
(Goal.add g3 [ (mk_eq ctx yc (mk_numeral_int ctx 2 (Integer.mk_sort ctx))) ]) ;
|
||||
let constr = (mk_eq ctx xc yc) in
|
||||
(Goal.add g3 [ constr ] ) ;
|
||||
let ar = (Tactic.apply (mk_tactic ctx "smt") g3 None) in
|
||||
if ((get_num_subgoals ar) == 1 &&
|
||||
(not (is_decided_unsat (get_subgoal ar 0)))) then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
) ;
|
||||
model_converter_test ctx ;
|
||||
(* Real num/den test. *)
|
||||
let rn = Real.mk_numeral_nd ctx 42 43 in
|
||||
let inum = (get_numerator rn) in
|
||||
let iden = get_denominator rn in
|
||||
Printf.printf "Numerator: %s Denominator: %s\n" (Real.numeral_to_string inum) (Real.numeral_to_string iden) ;
|
||||
if ((Real.numeral_to_string inum) <> "42" || (Real.numeral_to_string iden) <> "43") then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
;
|
||||
if ((to_decimal_string rn 3) <> "0.976?") then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
;
|
||||
if (to_decimal_string (Real.mk_numeral_s ctx "-1231231232/234234333") 5 <> "-5.25640?") then
|
||||
raise (TestFailedException "")
|
||||
else if (to_decimal_string (Real.mk_numeral_s ctx "-123123234234234234231232/234234333") 5 <> "-525641278361333.28170?") then
|
||||
raise (TestFailedException "")
|
||||
else if (to_decimal_string (Real.mk_numeral_s ctx "-234234333") 5 <> "-234234333") then
|
||||
raise (TestFailedException "")
|
||||
else if (to_decimal_string (Real.mk_numeral_s ctx "234234333/2") 5 <> "117117166.5") then
|
||||
raise (TestFailedException "")
|
||||
;
|
||||
(* Error handling test. *)
|
||||
try (
|
||||
let i = Integer.mk_numeral_s ctx "1/2" in
|
||||
raise (TestFailedException (numeral_to_string i)) (* unreachable *)
|
||||
)
|
||||
with Z3native.Exception(_) -> (
|
||||
Printf.printf "Exception caught, OK.\n"
|
||||
)
|
||||
|
||||
(**
|
||||
A basic example of how to use quantifiers.
|
||||
**)
|
||||
let quantifier_example1 ( ctx : context ) =
|
||||
Printf.printf "QuantifierExample\n" ;
|
||||
let is = (Integer.mk_sort ctx) in
|
||||
let types = [ is; is; is ] in
|
||||
let names = [ (Symbol.mk_string ctx "x_0");
|
||||
(Symbol.mk_string ctx "x_1");
|
||||
(Symbol.mk_string ctx "x_2") ] in
|
||||
let vars = [ (Quantifier.mk_bound ctx 2 (List.nth types 0));
|
||||
(Quantifier.mk_bound ctx 2 (List.nth types 1));
|
||||
(Quantifier.mk_bound ctx 2 (List.nth types 2)) ] in
|
||||
let xs = [ (Integer.mk_const ctx (List.nth names 0));
|
||||
(Integer.mk_const ctx (List.nth names 1));
|
||||
(Integer.mk_const ctx (List.nth names 2)) ] in
|
||||
|
||||
let body_vars = (Boolean.mk_and ctx
|
||||
[ (mk_eq ctx
|
||||
(Arithmetic.mk_add ctx [ (List.nth vars 0) ; (Integer.mk_numeral_i ctx 1)])
|
||||
(Integer.mk_numeral_i ctx 2)) ;
|
||||
(mk_eq ctx
|
||||
(Arithmetic.mk_add ctx [ (List.nth vars 1); (Integer.mk_numeral_i ctx 2)])
|
||||
(Arithmetic.mk_add ctx [ (List.nth vars 2); (Integer.mk_numeral_i ctx 3)])) ]) in
|
||||
let body_const = (Boolean.mk_and ctx
|
||||
[ (mk_eq ctx
|
||||
(Arithmetic.mk_add ctx [ (List.nth xs 0); (Integer.mk_numeral_i ctx 1)])
|
||||
(Integer.mk_numeral_i ctx 2)) ;
|
||||
(mk_eq ctx
|
||||
(Arithmetic.mk_add ctx [ (List.nth xs 1); (Integer.mk_numeral_i ctx 2)])
|
||||
(Arithmetic.mk_add ctx [ (List.nth xs 2); (Integer.mk_numeral_i ctx 3)])) ]) in
|
||||
|
||||
let x = (Quantifier.mk_forall ctx types names body_vars (Some 1) [] [] (Some (Symbol.mk_string ctx "Q1")) (Some (Symbol.mk_string ctx "skid1"))) in
|
||||
Printf.printf "Quantifier X: %s\n" (Quantifier.to_string x) ;
|
||||
let y = (Quantifier.mk_forall_const ctx xs body_const (Some 1) [] [] (Some (Symbol.mk_string ctx "Q2")) (Some (Symbol.mk_string ctx "skid2"))) in
|
||||
Printf.printf "Quantifier Y: %s\n" (Quantifier.to_string y) ;
|
||||
if (is_true (Quantifier.expr_of_quantifier x)) then
|
||||
raise (TestFailedException "") (* unreachable *)
|
||||
else if (is_false (Quantifier.expr_of_quantifier x)) then
|
||||
raise (TestFailedException "") (* unreachable *)
|
||||
else if (is_const (Quantifier.expr_of_quantifier x)) then
|
||||
raise (TestFailedException "") (* unreachable *)
|
||||
|
||||
|
||||
open Z3.FloatingPoint
|
||||
|
||||
(**
|
||||
A basic example of floating point arithmetic
|
||||
**)
|
||||
let fpa_example ( ctx : context ) =
|
||||
Printf.printf "FPAExample\n" ;
|
||||
(* let str = ref "" in *)
|
||||
(* (read_line ()) ; *)
|
||||
let double_sort = (FloatingPoint.mk_sort_double ctx) in
|
||||
let rm_sort = (FloatingPoint.RoundingMode.mk_sort ctx) in
|
||||
|
||||
(** Show that there are x, y s.t. (x + y) = 42.0 (with rounding mode). *)
|
||||
let s_rm = (mk_string ctx "rm") in
|
||||
let rm = (mk_const ctx s_rm rm_sort) in
|
||||
let s_x = (mk_string ctx "x") in
|
||||
let s_y = (mk_string ctx "y") in
|
||||
let x = (mk_const ctx s_x double_sort) in
|
||||
let y = (mk_const ctx s_y double_sort)in
|
||||
let n = (FloatingPoint.mk_numeral_f ctx 42.0 double_sort) in
|
||||
let s_x_plus_y = (mk_string ctx "x_plus_y") in
|
||||
let x_plus_y = (mk_const ctx s_x_plus_y double_sort) in
|
||||
let c1 = (mk_eq ctx x_plus_y (mk_add ctx rm x y)) in
|
||||
let args = [ c1 ; (mk_eq ctx x_plus_y n) ] in
|
||||
let c2 = (Boolean.mk_and ctx args) in
|
||||
let args2 = [ c2 ; (Boolean.mk_not ctx (Boolean.mk_eq ctx rm (RoundingMode.mk_rtz ctx))) ] in
|
||||
let c3 = (Boolean.mk_and ctx args2) in
|
||||
let and_args = [ (Boolean.mk_not ctx (mk_is_zero ctx y)) ;
|
||||
(Boolean.mk_not ctx (mk_is_nan ctx y)) ;
|
||||
(Boolean.mk_not ctx (mk_is_infinite ctx y)) ] in
|
||||
let args3 = [ c3 ; (Boolean.mk_and ctx and_args) ] in
|
||||
let c4 = (Boolean.mk_and ctx args3) in
|
||||
(Printf.printf "c4: %s\n" (Expr.to_string c4)) ;
|
||||
(
|
||||
let solver = (mk_solver ctx None) in
|
||||
(Solver.add solver [ c4 ]) ;
|
||||
if (check solver []) != SATISFIABLE then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
);
|
||||
|
||||
(* Show that the following are equal: *)
|
||||
(* (fp #b0 #b10000000001 #xc000000000000) *)
|
||||
(* ((_ to_fp 11 53) #x401c000000000000)) *)
|
||||
(* ((_ to_fp 11 53) RTZ 1.75 2))) *)
|
||||
(* ((_ to_fp 11 53) RTZ 7.0))) *)
|
||||
let c1 = (mk_fp ctx
|
||||
(mk_numeral_string ctx "0" (BitVector.mk_sort ctx 1))
|
||||
(mk_numeral_string ctx "3377699720527872" (BitVector.mk_sort ctx 52))
|
||||
(mk_numeral_string ctx "1025" (BitVector.mk_sort ctx 11))) in
|
||||
let c2 = (mk_to_fp_bv ctx
|
||||
(mk_numeral_string ctx "4619567317775286272" (BitVector.mk_sort ctx 64))
|
||||
(mk_sort ctx 11 53)) in
|
||||
let c3 = (mk_to_fp_int_real ctx
|
||||
(RoundingMode.mk_rtz ctx)
|
||||
(mk_numeral_string ctx "2" (Integer.mk_sort ctx))
|
||||
(mk_numeral_string ctx "1.75" (Real.mk_sort ctx))
|
||||
(FloatingPoint.mk_sort ctx 11 53)) in
|
||||
let c4 = (mk_to_fp_real ctx (RoundingMode.mk_rtz ctx)
|
||||
(mk_numeral_string ctx "7.0" (Real.mk_sort ctx))
|
||||
(FloatingPoint.mk_sort ctx 11 53)) in
|
||||
let args3 = [ (mk_eq ctx c1 c2) ;
|
||||
(mk_eq ctx c1 c3) ;
|
||||
(mk_eq ctx c1 c4) ] in
|
||||
let c5 = (Boolean.mk_and ctx args3) in
|
||||
(Printf.printf "c5: %s\n" (Expr.to_string c5)) ;
|
||||
(
|
||||
let solver = (mk_solver ctx None) in
|
||||
(Solver.add solver [ c5 ]) ;
|
||||
if (check solver []) != SATISFIABLE then
|
||||
raise (TestFailedException "")
|
||||
else
|
||||
Printf.printf "Test passed.\n"
|
||||
)
|
||||
|
||||
let _ =
|
||||
try (
|
||||
if not (Log.open_ "z3.log") then
|
||||
raise (TestFailedException "Log couldn't be opened.")
|
||||
else
|
||||
(
|
||||
Printf.printf "Running Z3 version %s\n" Version.to_string ;
|
||||
let cfg = [("model", "true"); ("proof", "false")] in
|
||||
let ctx = (mk_context cfg) in
|
||||
let is = (Symbol.mk_int ctx 42) in
|
||||
let ss = (Symbol.mk_string ctx "mySymbol") in
|
||||
let bs = (Boolean.mk_sort ctx) in
|
||||
let ints = (Integer.mk_sort ctx) in
|
||||
let rs = (Real.mk_sort ctx) in
|
||||
Printf.printf "int symbol: %s\n" (Symbol.to_string is);
|
||||
Printf.printf "string symbol: %s\n" (Symbol.to_string ss);
|
||||
Printf.printf "bool sort: %s\n" (Sort.to_string bs);
|
||||
Printf.printf "int sort: %s\n" (Sort.to_string ints);
|
||||
Printf.printf "real sort: %s\n" (Sort.to_string rs);
|
||||
basic_tests ctx ;
|
||||
quantifier_example1 ctx ;
|
||||
fpa_example ctx ;
|
||||
Printf.printf "Disposing...\n";
|
||||
Gc.full_major ()
|
||||
);
|
||||
Printf.printf "Exiting.\n" ;
|
||||
exit 0
|
||||
) with Z3native.Exception(msg) -> (
|
||||
Printf.printf "Z3 EXCEPTION: %s\n" msg ;
|
||||
exit 1
|
||||
)
|
||||
;;
|
|
@ -46,6 +46,15 @@ class ComplexExpr:
|
|||
other = _to_complex(other)
|
||||
return ComplexExpr(other.r*self.r - other.i*self.i, other.i*self.r + other.r*self.i)
|
||||
|
||||
def __pow__(self, k):
|
||||
if k == 0:
|
||||
return ComplexExpr(1, 0)
|
||||
if k == 1:
|
||||
return self
|
||||
if k < 0:
|
||||
return (self ** (-k)).inv()
|
||||
return reduce(lambda x, y: x * y, [self for _ in xrange(k)], ComplexExpr(1, 0))
|
||||
|
||||
def inv(self):
|
||||
den = self.r*self.r + self.i*self.i
|
||||
return ComplexExpr(self.r/den, -self.i/den)
|
||||
|
@ -65,9 +74,6 @@ class ComplexExpr:
|
|||
def __neq__(self, other):
|
||||
return Not(self.__eq__(other))
|
||||
|
||||
def __pow__(self, k):
|
||||
|
||||
|
||||
def simplify(self):
|
||||
return ComplexExpr(simplify(self.r), simplify(self.i))
|
||||
|
||||
|
@ -107,4 +113,5 @@ print(s.model())
|
|||
s.add(x.i != 1)
|
||||
print(s.check())
|
||||
# print(s.model())
|
||||
print (3 + I)^2/(5 - I)
|
||||
print ((3 + I) ** 2)/(5 - I)
|
||||
print ((3 + I) ** -3)/(5 - I)
|
||||
|
|
|
@ -9,7 +9,7 @@ from mk_util import *
|
|||
|
||||
# Z3 Project definition
|
||||
def init_project_def():
|
||||
set_version(4, 3, 2, 0)
|
||||
set_version(4, 4, 0, 0)
|
||||
add_lib('util', [])
|
||||
add_lib('polynomial', ['util'], 'math/polynomial')
|
||||
add_lib('sat', ['util'])
|
||||
|
@ -53,8 +53,8 @@ def init_project_def():
|
|||
add_lib('user_plugin', ['smt'], 'smt/user_plugin')
|
||||
add_lib('bv_tactics', ['tactic', 'bit_blaster'], 'tactic/bv')
|
||||
add_lib('fuzzing', ['ast'], 'test/fuzzing')
|
||||
add_lib('fpa_tactics', ['fpa', 'core_tactics', 'bv_tactics', 'sat_tactic'], 'tactic/fpa')
|
||||
add_lib('smt_tactic', ['smt'], 'smt/tactic')
|
||||
add_lib('fpa_tactics', ['fpa', 'core_tactics', 'bv_tactics', 'sat_tactic', 'smt_tactic'], 'tactic/fpa')
|
||||
add_lib('sls_tactic', ['tactic', 'normal_forms', 'core_tactics', 'bv_tactics'], 'tactic/sls')
|
||||
add_lib('qe', ['smt','sat'], 'qe')
|
||||
add_lib('duality', ['smt', 'interp', 'qe'])
|
||||
|
@ -75,7 +75,7 @@ def init_project_def():
|
|||
# dll_name='foci2',
|
||||
# export_files=['foci2stub.cpp'])
|
||||
# add_lib('interp', ['solver','foci2'])
|
||||
API_files = ['z3_api.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_interp.h']
|
||||
API_files = ['z3_api.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_interp.h', 'z3_fpa.h']
|
||||
add_lib('api', ['portfolio', 'user_plugin', 'smtparser', 'realclosure', 'interp'],
|
||||
includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files)
|
||||
add_exe('shell', ['api', 'sat', 'extra_cmds'], exe_name='z3')
|
||||
|
@ -87,6 +87,7 @@ def init_project_def():
|
|||
export_files=API_files)
|
||||
add_dot_net_dll('dotnet', ['api_dll'], 'api/dotnet', dll_name='Microsoft.Z3', assembly_info_dir='Properties')
|
||||
add_java_dll('java', ['api_dll'], 'api/java', dll_name='libz3java', package_name="com.microsoft.z3", manifest_file='manifest')
|
||||
add_ml_lib('ml', ['api_dll'], 'api/ml', lib_name='libz3ml')
|
||||
add_hlib('cpp', 'api/c++', includes2install=['z3++.h'])
|
||||
set_z3py_dir('api/python')
|
||||
# Examples
|
||||
|
@ -97,6 +98,7 @@ def init_project_def():
|
|||
add_c_example('maxsat')
|
||||
add_dotnet_example('dotnet_example', 'dotnet')
|
||||
add_java_example('java_example', 'java')
|
||||
add_ml_example('ml_example', 'ml')
|
||||
add_z3py_example('py_example', 'python')
|
||||
return API_files
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ CXXFLAGS=getenv("CXXFLAGS", "")
|
|||
EXAMP_DEBUG_FLAG=''
|
||||
LDFLAGS=getenv("LDFLAGS", "")
|
||||
JNI_HOME=getenv("JNI_HOME", None)
|
||||
OCAMLC=getenv("OCAMLC", "ocamlc")
|
||||
OCAMLOPT=getenv("OCAMLOPT", "ocamlopt")
|
||||
OCAML_LIB=getenv("OCAML_LIB", None)
|
||||
OCAMLFIND=getenv("OCAMLFIND", "ocamlfind")
|
||||
|
||||
CXX_COMPILERS=['g++', 'clang++']
|
||||
C_COMPILERS=['gcc', 'clang']
|
||||
|
@ -49,6 +53,7 @@ UTIL_COMPONENT='util'
|
|||
API_COMPONENT='api'
|
||||
DOTNET_COMPONENT='dotnet'
|
||||
JAVA_COMPONENT='java'
|
||||
ML_COMPONENT='ml'
|
||||
CPP_COMPONENT='cpp'
|
||||
#####################
|
||||
IS_WINDOWS=False
|
||||
|
@ -59,12 +64,14 @@ VERBOSE=True
|
|||
DEBUG_MODE=False
|
||||
SHOW_CPPS = True
|
||||
VS_X64 = False
|
||||
LINUX_X64 = True
|
||||
ONLY_MAKEFILES = False
|
||||
Z3PY_SRC_DIR=None
|
||||
VS_PROJ = False
|
||||
TRACE = False
|
||||
DOTNET_ENABLED=False
|
||||
JAVA_ENABLED=False
|
||||
ML_ENABLED=False
|
||||
STATIC_LIB=False
|
||||
VER_MAJOR=None
|
||||
VER_MINOR=None
|
||||
|
@ -219,7 +226,16 @@ def test_openmp(cc):
|
|||
t = TempFile('tstomp.cpp')
|
||||
t.add('#include<omp.h>\nint main() { return omp_in_parallel() ? 1 : 0; }\n')
|
||||
t.commit()
|
||||
return exec_compiler_cmd([cc, CPPFLAGS, 'tstomp.cpp', LDFLAGS, '-fopenmp']) == 0
|
||||
if IS_WINDOWS:
|
||||
r = exec_compiler_cmd([cc, CPPFLAGS, 'tstomp.cpp', LDFLAGS, '/openmp']) == 0
|
||||
try:
|
||||
rmf('tstomp.obj')
|
||||
rmf('tstomp.exe')
|
||||
except:
|
||||
pass
|
||||
return r
|
||||
else:
|
||||
return exec_compiler_cmd([cc, CPPFLAGS, 'tstomp.cpp', LDFLAGS, '-fopenmp']) == 0
|
||||
|
||||
def find_jni_h(path):
|
||||
for root, dirs, files in os.walk(path):
|
||||
|
@ -333,8 +349,62 @@ def check_java():
|
|||
if JNI_HOME == None:
|
||||
raise MKException("Failed to detect jni.h. Possible solution: set JNI_HOME with the path to JDK.")
|
||||
|
||||
def check_ml():
|
||||
t = TempFile('hello.ml')
|
||||
t.add('print_string "Hello world!\n";;')
|
||||
t.commit()
|
||||
if is_verbose():
|
||||
print ('Testing %s...' % OCAMLC)
|
||||
r = exec_cmd([OCAMLC, '-o', 'a.out', 'hello.ml'])
|
||||
if r != 0:
|
||||
raise MKException('Failed testing ocamlc compiler. Set environment variable OCAMLC with the path to the Ocaml compiler')
|
||||
if is_verbose():
|
||||
print ('Testing %s...' % OCAMLOPT)
|
||||
r = exec_cmd([OCAMLOPT, '-o', 'a.out', 'hello.ml'])
|
||||
if r != 0:
|
||||
raise MKException('Failed testing ocamlopt compiler. Set environment variable OCAMLOPT with the path to the Ocaml native compiler. Note that ocamlopt may require flexlink to be in your path.')
|
||||
try:
|
||||
rmf('hello.cmi')
|
||||
rmf('hello.cmo')
|
||||
rmf('hello.cmx')
|
||||
rmf('a.out')
|
||||
rmf('hello.o')
|
||||
except:
|
||||
pass
|
||||
find_ml_lib()
|
||||
find_ocaml_find()
|
||||
|
||||
def find_ocaml_find():
|
||||
global OCAMLFIND
|
||||
if is_verbose():
|
||||
print ("Testing %s..." % OCAMLFIND)
|
||||
r = exec_cmd([OCAMLFIND, 'printconf'])
|
||||
if r != 0:
|
||||
OCAMLFIND=''
|
||||
|
||||
def find_ml_lib():
|
||||
global OCAML_LIB
|
||||
if is_verbose():
|
||||
print ('Finding OCAML_LIB...')
|
||||
t = TempFile('output')
|
||||
null = open(os.devnull, 'wb')
|
||||
try:
|
||||
subprocess.call([OCAMLC, '-where'], stdout=t.fname, stderr=null)
|
||||
t.commit()
|
||||
except:
|
||||
raise MKException('Failed to find Ocaml library; please set OCAML_LIB')
|
||||
t = open('output', 'r')
|
||||
for line in t:
|
||||
OCAML_LIB = line[:-1]
|
||||
if is_verbose():
|
||||
print ('OCAML_LIB=%s' % OCAML_LIB)
|
||||
t.close()
|
||||
rmf('output')
|
||||
return
|
||||
|
||||
def is64():
|
||||
return sys.maxsize >= 2**32
|
||||
global LINUX_X64
|
||||
return LINUX_X64 and sys.maxsize >= 2**32
|
||||
|
||||
def check_ar():
|
||||
if is_verbose():
|
||||
|
@ -450,13 +520,16 @@ def display_help(exit_code):
|
|||
print(" -t, --trace enable tracing in release mode.")
|
||||
if IS_WINDOWS:
|
||||
print(" -x, --x64 create 64 binary when using Visual Studio.")
|
||||
else:
|
||||
print(" --x86 force 32-bit x86 build on x64 systems.")
|
||||
print(" -m, --makefiles generate only makefiles.")
|
||||
if IS_WINDOWS:
|
||||
print(" -v, --vsproj generate Visual Studio Project Files.")
|
||||
if IS_WINDOWS:
|
||||
print(" -n, --nodotnet do not generate Microsoft.Z3.dll make rules.")
|
||||
print(" -j, --java generate Java bindings.")
|
||||
print(" --staticlib build Z3 static library.")
|
||||
print(" --ml generate OCaml bindings.")
|
||||
print(" --staticlib build Z3 static library.")
|
||||
if not IS_WINDOWS:
|
||||
print(" -g, --gmp use GMP.")
|
||||
print(" --gprof enable gprof")
|
||||
|
@ -471,18 +544,22 @@ def display_help(exit_code):
|
|||
print(" CXXFLAGS C++ compiler flags")
|
||||
print(" JDK_HOME JDK installation directory (only relevant if -j or --java option is provided)")
|
||||
print(" JNI_HOME JNI bindings directory (only relevant if -j or --java option is provided)")
|
||||
print(" OCAMLC Ocaml byte-code compiler (only relevant with --ml)")
|
||||
print(" OCAMLOPT Ocaml native compiler (only relevant with --ml)")
|
||||
print(" OCAML_LIB Ocaml library directory (only relevant with --ml)")
|
||||
exit(exit_code)
|
||||
|
||||
# Parse configuration option for mk_make script
|
||||
def parse_options():
|
||||
global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE, VS_PAR, VS_PAR_NUM
|
||||
global DOTNET_ENABLED, JAVA_ENABLED, STATIC_LIB, PREFIX, GMP, FOCI2, FOCI2LIB, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH
|
||||
global DOTNET_ENABLED, JAVA_ENABLED, ML_ENABLED, STATIC_LIB, PREFIX, GMP, FOCI2, FOCI2LIB, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH
|
||||
global LINUX_X64
|
||||
try:
|
||||
options, remainder = getopt.gnu_getopt(sys.argv[1:],
|
||||
'b:df:sxhmcvtnp:gj',
|
||||
['build=', 'debug', 'silent', 'x64', 'help', 'makefiles', 'showcpp', 'vsproj',
|
||||
'trace', 'nodotnet', 'staticlib', 'prefix=', 'gmp', 'foci2=', 'java', 'parallel=', 'gprof',
|
||||
'githash='])
|
||||
'githash=', 'x86', 'ml'])
|
||||
except:
|
||||
print("ERROR: Invalid command line option")
|
||||
display_help(1)
|
||||
|
@ -501,9 +578,11 @@ def parse_options():
|
|||
if not IS_WINDOWS:
|
||||
raise MKException('x64 compilation mode can only be specified when using Visual Studio')
|
||||
VS_X64 = True
|
||||
elif opt in ('--x86'):
|
||||
LINUX_X64=False
|
||||
elif opt in ('-h', '--help'):
|
||||
display_help(0)
|
||||
elif opt in ('-m', '--onlymakefiles'):
|
||||
elif opt in ('-m', '--makefiles'):
|
||||
ONLY_MAKEFILES = True
|
||||
elif opt in ('-c', '--showcpp'):
|
||||
SHOW_CPPS = True
|
||||
|
@ -535,6 +614,8 @@ def parse_options():
|
|||
GPROF = True
|
||||
elif opt == '--githash':
|
||||
GIT_HASH=arg
|
||||
elif opt in ('', '--ml'):
|
||||
ML_ENABLED = True
|
||||
else:
|
||||
print("ERROR: Invalid command line option '%s'" % opt)
|
||||
display_help(1)
|
||||
|
@ -621,6 +702,9 @@ def is_verbose():
|
|||
def is_java_enabled():
|
||||
return JAVA_ENABLED
|
||||
|
||||
def is_ml_enabled():
|
||||
return ML_ENABLED
|
||||
|
||||
def is_compiler(given, expected):
|
||||
"""
|
||||
Return True if the 'given' compiler is the expected one.
|
||||
|
@ -665,6 +749,9 @@ def get_cs_files(path):
|
|||
def get_java_files(path):
|
||||
return filter(lambda f: f.endswith('.java'), os.listdir(path))
|
||||
|
||||
def get_ml_files(path):
|
||||
return filter(lambda f: f.endswith('.ml'), os.listdir(path))
|
||||
|
||||
def find_all_deps(name, deps):
|
||||
new_deps = []
|
||||
for dep in deps:
|
||||
|
@ -1198,6 +1285,7 @@ class JavaDLLComponent(Component):
|
|||
self.dll_name = dll_name
|
||||
self.package_name = package_name
|
||||
self.manifest_file = manifest_file
|
||||
self.install = not is_windows()
|
||||
|
||||
def mk_makefile(self, out):
|
||||
global JAVAC
|
||||
|
@ -1268,6 +1356,137 @@ class JavaDLLComponent(Component):
|
|||
shutil.copy(os.path.join(build_path, 'libz3java.%s' % so),
|
||||
os.path.join(dist_path, 'bin', 'libz3java.%s' % so))
|
||||
|
||||
def mk_install(self, out):
|
||||
if is_java_enabled() and self.install:
|
||||
dllfile = '%s$(SO_EXT)' % self.dll_name
|
||||
out.write('\t@cp %s %s\n' % (dllfile, os.path.join('$(PREFIX)', 'lib', dllfile)))
|
||||
out.write('\t@cp %s.jar %s.jar\n' % (self.package_name, os.path.join('$(PREFIX)', 'lib', self.package_name)))
|
||||
|
||||
def mk_uninstall(self, out):
|
||||
if is_java_enabled() and self.install:
|
||||
dllfile = '%s$(SO_EXT)' % self.dll_name
|
||||
out.write('\t@rm %s\n' % (os.path.join('$(PREFIX)', 'lib', dllfile)))
|
||||
out.write('\t@rm %s.jar\n' % (os.path.join('$(PREFIX)', 'lib', self.package_name)))
|
||||
|
||||
class MLComponent(Component):
|
||||
def __init__(self, name, lib_name, path, deps):
|
||||
Component.__init__(self, name, path, deps)
|
||||
if lib_name == None:
|
||||
lib_name = name
|
||||
self.lib_name = lib_name
|
||||
|
||||
def mk_ml_meta(self, ml_meta_in, ml_meta_out, major, minor, build, revision):
|
||||
ver_pat = re.compile('version = "VERSION"*')
|
||||
fin = open(ml_meta_in, 'r')
|
||||
fout = open(ml_meta_out, 'w')
|
||||
num_updates = 0
|
||||
for line in fin:
|
||||
if ver_pat.match(line):
|
||||
fout.write('version = "%s.%s.%s.%s"\n' % (major, minor, build, revision))
|
||||
num_updates = num_updates + 1
|
||||
else:
|
||||
fout.write(line)
|
||||
assert num_updates == 1, "unexpected number of version number updates"
|
||||
fin.close()
|
||||
fout.close()
|
||||
if VERBOSE:
|
||||
print("Updated '%s'" % ml_meta_out)
|
||||
|
||||
|
||||
def mk_makefile(self, out):
|
||||
if is_ml_enabled():
|
||||
CP_CMD = "cp"
|
||||
if IS_WINDOWS:
|
||||
CP_CMD = "copy"
|
||||
src_dir = self.to_src_dir
|
||||
sub_dir = os.path.join('api', 'ml')
|
||||
mk_dir(os.path.join(BUILD_DIR, sub_dir))
|
||||
api_src = get_component(API_COMPONENT).to_src_dir
|
||||
out.write('CXXFLAGS_OCAML=$(CXXFLAGS:/GL=)\n') # remove /GL; the ocaml tools don't like it.
|
||||
for f in filter(lambda f: f.endswith('.ml'), os.listdir(self.src_dir)):
|
||||
out.write('%s: %s\n' % (os.path.join(sub_dir,f),os.path.join(src_dir,f)))
|
||||
str = '\t%s %s %s\n' % (CP_CMD,os.path.join(src_dir,f),os.path.join(sub_dir,f))
|
||||
out.write(str)
|
||||
for f in filter(lambda f: f.endswith('.mli'), os.listdir(self.src_dir)):
|
||||
out.write('%s: %s\n' % (os.path.join(sub_dir,f),os.path.join(src_dir,f)))
|
||||
str = '\t%s %s %s\n' % (CP_CMD,os.path.join(src_dir,f),os.path.join(sub_dir,f))
|
||||
out.write(str)
|
||||
for f in filter(lambda f: f.endswith('.c'), os.listdir(self.src_dir)):
|
||||
out.write('%s: %s\n' % (os.path.join(sub_dir,f),os.path.join(src_dir,f)))
|
||||
str = '\t%s %s %s\n' % (CP_CMD,os.path.join(src_dir,f),os.path.join(sub_dir,f))
|
||||
out.write(str)
|
||||
modules = ["z3enums", "z3native", "z3"] # dependencies in this order!
|
||||
mls = ''
|
||||
mlis = ''
|
||||
cmis = ''
|
||||
archives = ''
|
||||
|
||||
for m in modules:
|
||||
fn = os.path.join(self.src_dir, ('%s.mli' % m))
|
||||
if not os.path.exists(fn):
|
||||
out.write('%s.mli: %s.ml%s\n' % (os.path.join(sub_dir,m),os.path.join(sub_dir,m),mlis))
|
||||
out.write('\t%s -I %s -i -c %s.ml > %s.mli\n' % (OCAMLC,sub_dir,os.path.join(sub_dir, m),os.path.join(sub_dir, m)))
|
||||
out.write('%s.cmi: %s.mli%s\n' % (os.path.join(sub_dir,m),os.path.join(sub_dir,m), cmis))
|
||||
out.write('\t%s -I %s -c %s.mli\n' % (OCAMLC,sub_dir,os.path.join(sub_dir,m)))
|
||||
out.write('%s.cma: %s.ml %s.cmi%s\n' % (os.path.join(sub_dir,m),os.path.join(sub_dir,m),os.path.join(sub_dir,m), archives))
|
||||
out.write('\t%s -a -o %s.ml -o %s.cma\n' % (OCAMLC,os.path.join(sub_dir,m), os.path.join(sub_dir,m)))
|
||||
mlis = mlis + ' ' + os.path.join(sub_dir, m) + '.mli'
|
||||
cmis = cmis + ' ' + os.path.join(sub_dir,m) + '.cmi'
|
||||
archives = archives + ' ' + os.path.join(sub_dir,m) + '.cma'
|
||||
mls = mls + ' ' + os.path.join(sub_dir, m) + '.ml'
|
||||
|
||||
out.write('%s: %s %s\n' %
|
||||
(os.path.join(sub_dir, 'z3native_stubs$(OBJ_EXT)'),
|
||||
os.path.join(sub_dir, 'z3native_stubs.c'),
|
||||
get_component(Z3_DLL_COMPONENT).dll_name+'$(SO_EXT)'));
|
||||
out.write('\t$(CC) $(CXXFLAGS_OCAML) -I %s -I %s %s $(CXX_OUT_FLAG)%s$(OBJ_EXT)\n' %
|
||||
(OCAML_LIB, api_src, os.path.join(sub_dir, 'z3native_stubs.c'), os.path.join(sub_dir, 'z3native_stubs')))
|
||||
|
||||
out.write('%s: %s %s %s$(SO_EXT)' % (
|
||||
os.path.join(sub_dir, "z3ml.cmxa"),
|
||||
cmis,
|
||||
archives,
|
||||
get_component(Z3_DLL_COMPONENT).dll_name))
|
||||
out.write(' %s\n' % (os.path.join(sub_dir, 'z3native_stubs$(OBJ_EXT)')))
|
||||
out.write('\tocamlmklib -o %s -I %s -ldopt \"-L. -lz3\" ' % (os.path.join(sub_dir, 'z3ml'), sub_dir))
|
||||
for m in modules:
|
||||
out.write(' %s' % (os.path.join(sub_dir, m+'.ml')))
|
||||
out.write(' %s\n' % (os.path.join(sub_dir, 'z3native_stubs$(OBJ_EXT)')))
|
||||
out.write('ml: %s\n' % (os.path.join(sub_dir, 'z3ml.cmxa')))
|
||||
self.mk_ml_meta(os.path.join('src/api/ml/META'), os.path.join(BUILD_DIR, sub_dir, 'META'), VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION)
|
||||
if OCAMLFIND != '':
|
||||
out.write('\nocamlfind_install: %s %s %s\n' % (
|
||||
get_component(Z3_DLL_COMPONENT).dll_name + '$(SO_EXT)',
|
||||
os.path.join(sub_dir, 'z3ml.cmxa'),
|
||||
os.path.join(sub_dir, 'META')))
|
||||
out.write('\t%s remove Z3\n' % (OCAMLFIND))
|
||||
out.write('\t%s install Z3 %s' % (OCAMLFIND, (os.path.join(sub_dir, 'META'))))
|
||||
for m in modules:
|
||||
out.write(' %s.cma' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s.cmx' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s.cmi' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s.cmo' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s.ml' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s.mli' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s$(OBJ_EXT)' % (os.path.join(sub_dir, m)))
|
||||
out.write(' %s' % ((os.path.join(sub_dir, 'z3ml$(LIB_EXT)'))))
|
||||
out.write(' %s' % ((os.path.join(sub_dir, 'z3ml.cma'))))
|
||||
out.write(' %s' % ((os.path.join(sub_dir, 'z3ml.cmxa'))))
|
||||
out.write(' %s' % ((os.path.join(sub_dir, 'libz3ml$(LIB_EXT)'))))
|
||||
out.write(' %s' % ((os.path.join(sub_dir, 'dllz3ml'))))
|
||||
if IS_WINDOWS:
|
||||
out.write('.dll')
|
||||
else:
|
||||
out.write('.so') # .so also on OSX!
|
||||
out.write(' ' + get_component(Z3_DLL_COMPONENT).dll_name + '$(SO_EXT)')
|
||||
if IS_WINDOWS:
|
||||
out.write(' ' + get_component(Z3_DLL_COMPONENT).dll_name + '$(LIB_EXT)')
|
||||
out.write('\n\n')
|
||||
|
||||
|
||||
def main_component(self):
|
||||
return is_ml_enabled()
|
||||
|
||||
class ExampleComponent(Component):
|
||||
def __init__(self, name, path):
|
||||
Component.__init__(self, name, path, [])
|
||||
|
@ -1377,6 +1596,39 @@ class JavaExampleComponent(ExampleComponent):
|
|||
out.write(' -d .\n')
|
||||
out.write('_ex_%s: JavaExample.class\n\n' % (self.name))
|
||||
|
||||
class MLExampleComponent(ExampleComponent):
|
||||
def __init__(self, name, path):
|
||||
ExampleComponent.__init__(self, name, path)
|
||||
|
||||
def is_example(self):
|
||||
return ML_ENABLED
|
||||
|
||||
def mk_makefile(self, out):
|
||||
if ML_ENABLED:
|
||||
out.write('ml_example.byte: api/ml/z3ml.cmxa ')
|
||||
for mlfile in get_ml_files(self.ex_dir):
|
||||
out.write(' %s' % os.path.join(self.to_ex_dir, mlfile))
|
||||
out.write('\n')
|
||||
out.write('\t%s ' % OCAMLC)
|
||||
if DEBUG_MODE:
|
||||
out.write('-g ')
|
||||
out.write('-custom -o ml_example.byte -I api/ml -cclib "-L. -lz3" nums.cma z3ml.cma')
|
||||
for mlfile in get_ml_files(self.ex_dir):
|
||||
out.write(' %s/%s' % (self.to_ex_dir, mlfile))
|
||||
out.write('\n')
|
||||
out.write('ml_example$(EXE_EXT): api/ml/z3ml.cmxa ml_example.byte')
|
||||
for mlfile in get_ml_files(self.ex_dir):
|
||||
out.write(' %s' % os.path.join(self.to_ex_dir, mlfile))
|
||||
out.write('\n')
|
||||
out.write('\t%s ' % OCAMLOPT)
|
||||
if DEBUG_MODE:
|
||||
out.write('-g ')
|
||||
out.write('-o ml_example$(EXE_EXT) -I api/ml -cclib "-L. -lz3" nums.cmxa z3ml.cmxa')
|
||||
for mlfile in get_ml_files(self.ex_dir):
|
||||
out.write(' %s/%s' % (self.to_ex_dir, mlfile))
|
||||
out.write('\n')
|
||||
out.write('_ex_%s: ml_example.byte ml_example$(EXE_EXT)\n\n' % self.name)
|
||||
|
||||
class PythonExampleComponent(ExampleComponent):
|
||||
def __init__(self, name, path):
|
||||
ExampleComponent.__init__(self, name, path)
|
||||
|
@ -1430,6 +1682,10 @@ def add_java_dll(name, deps=[], path=None, dll_name=None, package_name=None, man
|
|||
c = JavaDLLComponent(name, dll_name, package_name, manifest_file, path, deps)
|
||||
reg_component(name, c)
|
||||
|
||||
def add_ml_lib(name, deps=[], path=None, lib_name=None):
|
||||
c = MLComponent(name, lib_name, path, deps)
|
||||
reg_component(name, c)
|
||||
|
||||
def add_cpp_example(name, path=None):
|
||||
c = CppExampleComponent(name, path)
|
||||
reg_component(name, c)
|
||||
|
@ -1446,6 +1702,10 @@ def add_java_example(name, path=None):
|
|||
c = JavaExampleComponent(name, path)
|
||||
reg_component(name, c)
|
||||
|
||||
def add_ml_example(name, path=None):
|
||||
c = MLExampleComponent(name, path)
|
||||
reg_component(name, c)
|
||||
|
||||
def add_z3py_example(name, path=None):
|
||||
c = PythonExampleComponent(name, path)
|
||||
reg_component(name, c)
|
||||
|
@ -1462,7 +1722,7 @@ def mk_config():
|
|||
'OBJ_EXT=.obj\n'
|
||||
'LIB_EXT=.lib\n'
|
||||
'AR=lib\n'
|
||||
'AR_FLAGS=/nologo\n'
|
||||
'AR_FLAGS=/nologo /LTCG\n'
|
||||
'AR_OUTFLAG=/OUT:\n'
|
||||
'EXE_EXT=.exe\n'
|
||||
'LINK=cl\n'
|
||||
|
@ -1472,50 +1732,60 @@ def mk_config():
|
|||
'SLINK_OUT_FLAG=/Fe\n'
|
||||
'OS_DEFINES=/D _WINDOWS\n')
|
||||
extra_opt = ''
|
||||
HAS_OMP = test_openmp('cl')
|
||||
if HAS_OMP:
|
||||
extra_opt = ' /openmp'
|
||||
else:
|
||||
extra_opt = ' -D_NO_OMP_'
|
||||
if GIT_HASH:
|
||||
extra_opt = '%s /D Z3GITHASH=%s' % (extra_opt, GIT_HASH)
|
||||
extra_opt = ' %s /D Z3GITHASH=%s' % (extra_opt, GIT_HASH)
|
||||
if DEBUG_MODE:
|
||||
config.write(
|
||||
'LINK_FLAGS=/nologo /MDd\n'
|
||||
'SLINK_FLAGS=/nologo /LDd\n')
|
||||
if not VS_X64:
|
||||
config.write(
|
||||
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D Z3DEBUG %s /D _CONSOLE /D _TRACE /D _WINDOWS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n' % extra_opt)
|
||||
'CXXFLAGS=/c /GL /Zi /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D Z3DEBUG %s /D _CONSOLE /D _TRACE /D _WINDOWS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n' % extra_opt)
|
||||
config.write(
|
||||
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
'LINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
else:
|
||||
config.write(
|
||||
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _AMD64_ /D _DEBUG /D Z3DEBUG %s /D _CONSOLE /D _TRACE /D _WINDOWS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze-\n' % extra_opt)
|
||||
'CXXFLAGS=/c /GL /Zi /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _AMD64_ /D _DEBUG /D Z3DEBUG %s /D _CONSOLE /D _TRACE /D _WINDOWS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze-\n' % extra_opt)
|
||||
config.write(
|
||||
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
'LINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
else:
|
||||
# Windows Release mode
|
||||
config.write(
|
||||
'LINK_FLAGS=/nologo /MD\n'
|
||||
'SLINK_FLAGS=/nologo /LD\n')
|
||||
if TRACE:
|
||||
extra_opt = '%s /D _TRACE' % extra_opt
|
||||
extra_opt = '%s /D _TRACE ' % extra_opt
|
||||
if not VS_X64:
|
||||
config.write(
|
||||
'CXXFLAGS=/nologo /c /Zi /openmp /W3 /WX- /O2 /Oy- /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _CONSOLE /D _WINDOWS /D ASYNC_COMMANDS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n' % extra_opt)
|
||||
'CXXFLAGS=/nologo /c /GL /Zi /W3 /WX- /O2 /Oy- /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _CONSOLE /D _WINDOWS /D ASYNC_COMMANDS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n' % extra_opt)
|
||||
config.write(
|
||||
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
'LINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /LTCG /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
|
||||
else:
|
||||
config.write(
|
||||
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /O2 /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _LIB /D _WINDOWS /D _AMD64_ /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP\n' % extra_opt)
|
||||
'CXXFLAGS=/c /GL /Zi /nologo /W3 /WX- /O2 /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _LIB /D _WINDOWS /D _AMD64_ /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP\n' % extra_opt)
|
||||
config.write(
|
||||
'LINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608\n')
|
||||
'LINK_EXTRA_FLAGS=/link /LTCG /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608\n'
|
||||
'SLINK_EXTRA_FLAGS=/link /LTCG /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608\n')
|
||||
|
||||
# End of Windows VS config.mk
|
||||
if is_verbose():
|
||||
print('64-bit: %s' % is64())
|
||||
if is_java_enabled():
|
||||
print('OpenMP: %s' % HAS_OMP)
|
||||
if is_java_enabled():
|
||||
print('JNI Bindings: %s' % JNI_HOME)
|
||||
print('Java Compiler: %s' % JAVAC)
|
||||
if is_ml_enabled():
|
||||
print('OCaml Compiler: %s' % OCAMLC)
|
||||
print('OCaml Native: %s' % OCAMLOPT)
|
||||
print('OCaml Library: %s' % OCAML_LIB)
|
||||
else:
|
||||
global CXX, CC, GMP, FOCI2, CPPFLAGS, CXXFLAGS, LDFLAGS, EXAMP_DEBUG_FLAG
|
||||
OS_DEFINES = ""
|
||||
|
@ -1545,7 +1815,7 @@ def mk_config():
|
|||
FOCI2 = False
|
||||
if GIT_HASH:
|
||||
CPPFLAGS = '%s -DZ3GITHASH=%s' % (CPPFLAGS, GIT_HASH)
|
||||
CXXFLAGS = '%s -c' % CXXFLAGS
|
||||
CXXFLAGS = '%s -fvisibility=hidden -c' % CXXFLAGS
|
||||
HAS_OMP = test_openmp(CXX)
|
||||
if HAS_OMP:
|
||||
CXXFLAGS = '%s -fopenmp -mfpmath=sse' % CXXFLAGS
|
||||
|
@ -1598,6 +1868,10 @@ def mk_config():
|
|||
CPPFLAGS = '%s -D_AMD64_' % CPPFLAGS
|
||||
if sysname == 'Linux':
|
||||
CPPFLAGS = '%s -D_USE_THREAD_LOCAL' % CPPFLAGS
|
||||
elif not LINUX_X64:
|
||||
CXXFLAGS = '%s -m32' % CXXFLAGS
|
||||
LDFLAGS = '%s -m32' % LDFLAGS
|
||||
SLIBFLAGS = '%s -m32' % SLIBFLAGS
|
||||
if DEBUG_MODE:
|
||||
CPPFLAGS = '%s -DZ3DEBUG' % CPPFLAGS
|
||||
if TRACE or DEBUG_MODE:
|
||||
|
@ -1635,16 +1909,22 @@ def mk_config():
|
|||
print('64-bit: %s' % is64())
|
||||
if GPROF:
|
||||
print('gprof: enabled')
|
||||
print('Python version: %s' % distutils.sysconfig.get_python_version())
|
||||
print('Python version: %s' % distutils.sysconfig.get_python_version())
|
||||
if is_java_enabled():
|
||||
print('JNI Bindings: %s' % JNI_HOME)
|
||||
print('Java Compiler: %s' % JAVAC)
|
||||
if is_ml_enabled():
|
||||
print('OCaml Compiler: %s' % OCAMLC)
|
||||
print('OCaml Native: %s' % OCAMLOPT)
|
||||
print('OCaml Library: %s' % OCAML_LIB)
|
||||
|
||||
def mk_install(out):
|
||||
out.write('install: ')
|
||||
for c in get_components():
|
||||
c.mk_install_deps(out)
|
||||
out.write(' ')
|
||||
if is_ml_enabled() and OCAMLFIND != '':
|
||||
out.write('ocamlfind_install')
|
||||
out.write('\n')
|
||||
out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'bin'))
|
||||
out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'include'))
|
||||
|
@ -1862,7 +2142,7 @@ def mk_pat_db():
|
|||
c = get_component(PATTERN_COMPONENT)
|
||||
fin = open(os.path.join(c.src_dir, 'database.smt2'), 'r')
|
||||
fout = open(os.path.join(c.src_dir, 'database.h'), 'w')
|
||||
fout.write('char const * g_pattern_database =\n')
|
||||
fout.write('static char const g_pattern_database[] =\n')
|
||||
for line in fin:
|
||||
fout.write('"%s\\n"\n' % line.strip('\n'))
|
||||
fout.write(';\n')
|
||||
|
@ -2205,6 +2485,9 @@ def mk_bindings(api_files):
|
|||
mk_z3consts_java(api_files)
|
||||
_execfile(os.path.join('scripts', 'update_api.py'), g) # HACK
|
||||
cp_z3py_to_build()
|
||||
if is_ml_enabled():
|
||||
check_ml()
|
||||
mk_z3consts_ml(api_files)
|
||||
|
||||
# Extract enumeration types from API files, and add python definitions.
|
||||
def mk_z3consts_py(api_files):
|
||||
|
@ -2476,6 +2759,171 @@ def mk_z3consts_java(api_files):
|
|||
if VERBOSE:
|
||||
print("Generated '%s'" % ('%s' % gendir))
|
||||
|
||||
# Extract enumeration types from z3_api.h, and add ML definitions
|
||||
def mk_z3consts_ml(api_files):
|
||||
blank_pat = re.compile("^ *$")
|
||||
comment_pat = re.compile("^ *//.*$")
|
||||
typedef_pat = re.compile("typedef enum *")
|
||||
typedef2_pat = re.compile("typedef enum { *")
|
||||
openbrace_pat = re.compile("{ *")
|
||||
closebrace_pat = re.compile("}.*;")
|
||||
|
||||
ml = get_component(ML_COMPONENT)
|
||||
|
||||
DeprecatedEnums = [ 'Z3_search_failure' ]
|
||||
gendir = ml.src_dir
|
||||
if not os.path.exists(gendir):
|
||||
os.mkdir(gendir)
|
||||
|
||||
efile = open('%s.ml' % os.path.join(gendir, "z3enums"), 'w')
|
||||
efile.write('(* Automatically generated file *)\n\n')
|
||||
efile.write('(** The enumeration types of Z3. *)\n\n')
|
||||
for api_file in api_files:
|
||||
api_file_c = ml.find_file(api_file, ml.name)
|
||||
api_file = os.path.join(api_file_c.src_dir, api_file)
|
||||
|
||||
api = open(api_file, 'r')
|
||||
|
||||
SEARCHING = 0
|
||||
FOUND_ENUM = 1
|
||||
IN_ENUM = 2
|
||||
|
||||
mode = SEARCHING
|
||||
decls = {}
|
||||
idx = 0
|
||||
|
||||
linenum = 1
|
||||
for line in api:
|
||||
m1 = blank_pat.match(line)
|
||||
m2 = comment_pat.match(line)
|
||||
if m1 or m2:
|
||||
# skip blank lines and comments
|
||||
linenum = linenum + 1
|
||||
elif mode == SEARCHING:
|
||||
m = typedef_pat.match(line)
|
||||
if m:
|
||||
mode = FOUND_ENUM
|
||||
m = typedef2_pat.match(line)
|
||||
if m:
|
||||
mode = IN_ENUM
|
||||
decls = {}
|
||||
idx = 0
|
||||
elif mode == FOUND_ENUM:
|
||||
m = openbrace_pat.match(line)
|
||||
if m:
|
||||
mode = IN_ENUM
|
||||
decls = {}
|
||||
idx = 0
|
||||
else:
|
||||
assert False, "Invalid %s, line: %s" % (api_file, linenum)
|
||||
else:
|
||||
assert mode == IN_ENUM
|
||||
words = re.split('[^\-a-zA-Z0-9_]+', line)
|
||||
m = closebrace_pat.match(line)
|
||||
if m:
|
||||
name = words[1]
|
||||
if name not in DeprecatedEnums:
|
||||
efile.write('(** %s *)\n' % name[3:])
|
||||
efile.write('type %s =\n' % name[3:]) # strip Z3_
|
||||
for k, i in decls.items():
|
||||
efile.write(' | %s \n' % k[3:]) # strip Z3_
|
||||
efile.write('\n')
|
||||
efile.write('(** Convert %s to int*)\n' % name[3:])
|
||||
efile.write('let int_of_%s x : int =\n' % (name[3:])) # strip Z3_
|
||||
efile.write(' match x with\n')
|
||||
for k, i in decls.items():
|
||||
efile.write(' | %s -> %d\n' % (k[3:], i))
|
||||
efile.write('\n')
|
||||
efile.write('(** Convert int to %s*)\n' % name[3:])
|
||||
efile.write('let %s_of_int x : %s =\n' % (name[3:],name[3:])) # strip Z3_
|
||||
efile.write(' match x with\n')
|
||||
for k, i in decls.items():
|
||||
efile.write(' | %d -> %s\n' % (i, k[3:]))
|
||||
# use Z3.Exception?
|
||||
efile.write(' | _ -> raise (Failure "undefined enum value")\n\n')
|
||||
mode = SEARCHING
|
||||
else:
|
||||
if words[2] != '':
|
||||
if len(words[2]) > 1 and words[2][1] == 'x':
|
||||
idx = int(words[2], 16)
|
||||
else:
|
||||
idx = int(words[2])
|
||||
decls[words[1]] = idx
|
||||
idx = idx + 1
|
||||
linenum = linenum + 1
|
||||
if VERBOSE:
|
||||
print ('Generated "%s/z3enums.ml"' % ('%s' % gendir))
|
||||
efile = open('%s.mli' % os.path.join(gendir, "z3enums"), 'w')
|
||||
efile.write('(* Automatically generated file *)\n\n')
|
||||
efile.write('(** The enumeration types of Z3. *)\n\n')
|
||||
for api_file in api_files:
|
||||
api_file_c = ml.find_file(api_file, ml.name)
|
||||
api_file = os.path.join(api_file_c.src_dir, api_file)
|
||||
|
||||
api = open(api_file, 'r')
|
||||
|
||||
SEARCHING = 0
|
||||
FOUND_ENUM = 1
|
||||
IN_ENUM = 2
|
||||
|
||||
mode = SEARCHING
|
||||
decls = {}
|
||||
idx = 0
|
||||
|
||||
linenum = 1
|
||||
for line in api:
|
||||
m1 = blank_pat.match(line)
|
||||
m2 = comment_pat.match(line)
|
||||
if m1 or m2:
|
||||
# skip blank lines and comments
|
||||
linenum = linenum + 1
|
||||
elif mode == SEARCHING:
|
||||
m = typedef_pat.match(line)
|
||||
if m:
|
||||
mode = FOUND_ENUM
|
||||
m = typedef2_pat.match(line)
|
||||
if m:
|
||||
mode = IN_ENUM
|
||||
decls = {}
|
||||
idx = 0
|
||||
elif mode == FOUND_ENUM:
|
||||
m = openbrace_pat.match(line)
|
||||
if m:
|
||||
mode = IN_ENUM
|
||||
decls = {}
|
||||
idx = 0
|
||||
else:
|
||||
assert False, "Invalid %s, line: %s" % (api_file, linenum)
|
||||
else:
|
||||
assert mode == IN_ENUM
|
||||
words = re.split('[^\-a-zA-Z0-9_]+', line)
|
||||
m = closebrace_pat.match(line)
|
||||
if m:
|
||||
name = words[1]
|
||||
if name not in DeprecatedEnums:
|
||||
efile.write('(** %s *)\n' % name[3:])
|
||||
efile.write('type %s =\n' % name[3:]) # strip Z3_
|
||||
for k, i in decls.items():
|
||||
efile.write(' | %s \n' % k[3:]) # strip Z3_
|
||||
efile.write('\n')
|
||||
efile.write('(** Convert %s to int*)\n' % name[3:])
|
||||
efile.write('val int_of_%s : %s -> int\n' % (name[3:], name[3:])) # strip Z3_
|
||||
efile.write('(** Convert int to %s*)\n' % name[3:])
|
||||
efile.write('val %s_of_int : int -> %s\n' % (name[3:],name[3:])) # strip Z3_
|
||||
efile.write('\n')
|
||||
mode = SEARCHING
|
||||
else:
|
||||
if words[2] != '':
|
||||
if len(words[2]) > 1 and words[2][1] == 'x':
|
||||
idx = int(words[2], 16)
|
||||
else:
|
||||
idx = int(words[2])
|
||||
decls[words[1]] = idx
|
||||
idx = idx + 1
|
||||
linenum = linenum + 1
|
||||
if VERBOSE:
|
||||
print ('Generated "%s/z3enums.mli"' % ('%s' % gendir))
|
||||
|
||||
def mk_gui_str(id):
|
||||
return '4D2F40D8-E5F9-473B-B548-%012d' % id
|
||||
|
||||
|
@ -2633,3 +3081,5 @@ def mk_unix_dist(build_path, dist_path):
|
|||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ def mk_dir(d):
|
|||
os.makedirs(d)
|
||||
|
||||
def set_build_dir(path):
|
||||
global BUILD_DIR
|
||||
global BUILD_DIR, BUILD_X86_DIR, BUILD_X64_DIR
|
||||
BUILD_DIR = path
|
||||
BUILD_X86_DIR = os.path.join(path, 'x86')
|
||||
BUILD_X64_DIR = os.path.join(path, 'x64')
|
||||
|
@ -47,16 +47,16 @@ def set_build_dir(path):
|
|||
mk_dir(BUILD_X64_DIR)
|
||||
|
||||
def display_help():
|
||||
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 "It must be executed from the Z3 root directory."
|
||||
print "\nOptions:"
|
||||
print " -h, --help display this message."
|
||||
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 " -f, --force force script to regenerate Makefiles."
|
||||
print " --nojava do not include Java bindings in the binary distribution files."
|
||||
print " --githash include git hash in the Zip file."
|
||||
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("It must be executed from the Z3 root directory.")
|
||||
print("\nOptions:")
|
||||
print(" -h, --help display this message.")
|
||||
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(" -f, --force force script to regenerate Makefiles.")
|
||||
print(" --nojava do not include Java bindings in the binary distribution files.")
|
||||
print(" --githash include git hash in the Zip file.")
|
||||
exit(0)
|
||||
|
||||
# Parse configuration option for mk_make script
|
||||
|
@ -180,7 +180,7 @@ def mk_dist_dir_core(x64):
|
|||
mk_util.JAVA_ENABLED = JAVA_ENABLED
|
||||
mk_win_dist(build_path, dist_path)
|
||||
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():
|
||||
mk_dist_dir_core(False)
|
||||
|
@ -208,7 +208,7 @@ def mk_zip_core(x64):
|
|||
ZIPOUT = zipfile.ZipFile(zfname, 'w', zipfile.ZIP_DEFLATED)
|
||||
os.path.walk(dist_path, mk_zip_visitor, '*')
|
||||
if is_verbose():
|
||||
print "Generated '%s'" % zfname
|
||||
print("Generated '%s'") % zfname
|
||||
except:
|
||||
pass
|
||||
ZIPOUT = None
|
||||
|
@ -253,7 +253,7 @@ def cp_vs_runtime_core(x64):
|
|||
for f in VS_RUNTIME_FILES:
|
||||
shutil.copy(f, bin_dist_path)
|
||||
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():
|
||||
cp_vs_runtime_core(True)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
############################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
|
@ -124,6 +125,7 @@ SYMBOL = 9
|
|||
PRINT_MODE = 10
|
||||
ERROR_CODE = 11
|
||||
DOUBLE = 12
|
||||
FLOAT = 13
|
||||
|
||||
FIRST_OBJ_ID = 100
|
||||
|
||||
|
@ -131,30 +133,34 @@ def is_obj(ty):
|
|||
return ty >= FIRST_OBJ_ID
|
||||
|
||||
Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : '__int64', UINT64 : '__uint64', DOUBLE : 'double',
|
||||
STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'Z3_bool', SYMBOL : 'Z3_symbol',
|
||||
FLOAT : 'float', STRING : 'Z3_string', STRING_PTR : 'Z3_string_ptr', BOOL : 'Z3_bool', SYMBOL : 'Z3_symbol',
|
||||
PRINT_MODE : 'Z3_ast_print_mode', ERROR_CODE : 'Z3_error_code'
|
||||
}
|
||||
|
||||
Type2PyStr = { VOID_PTR : 'ctypes.c_void_p', INT : 'ctypes.c_int', UINT : 'ctypes.c_uint', INT64 : 'ctypes.c_longlong',
|
||||
UINT64 : 'ctypes.c_ulonglong', DOUBLE : 'ctypes.c_double',
|
||||
UINT64 : 'ctypes.c_ulonglong', DOUBLE : 'ctypes.c_double', FLOAT : 'ctypes.c_float',
|
||||
STRING : 'ctypes.c_char_p', STRING_PTR : 'ctypes.POINTER(ctypes.c_char_p)', BOOL : 'ctypes.c_bool', SYMBOL : 'Symbol',
|
||||
PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint'
|
||||
}
|
||||
|
||||
# Mapping to .NET types
|
||||
Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint', INT64 : 'Int64', UINT64 : 'UInt64', DOUBLE : 'double',
|
||||
STRING : 'string', STRING_PTR : 'byte**', BOOL : 'int', SYMBOL : 'IntPtr',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'byte**', BOOL : 'int', SYMBOL : 'IntPtr',
|
||||
PRINT_MODE : 'uint', ERROR_CODE : 'uint' }
|
||||
|
||||
# Mapping to Java types
|
||||
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
|
||||
STRING : 'String', STRING_PTR : 'StringPtr',
|
||||
FLOAT : 'float', STRING : 'String', STRING_PTR : 'StringPtr',
|
||||
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int'}
|
||||
|
||||
Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', INT64 : 'jlong', UINT64 : 'jlong', DOUBLE : 'jdouble',
|
||||
STRING : 'jstring', STRING_PTR : 'jobject',
|
||||
FLOAT : 'jfloat', STRING : 'jstring', STRING_PTR : 'jobject',
|
||||
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint'}
|
||||
|
||||
# Mapping to ML types
|
||||
Type2ML = { VOID : 'unit', VOID_PTR : 'VOIDP', INT : 'int', UINT : 'int', INT64 : 'int', UINT64 : 'int', DOUBLE : 'float',
|
||||
FLOAT : 'float', STRING : 'string', STRING_PTR : 'char**',
|
||||
BOOL : 'bool', SYMBOL : 'z3_symbol', PRINT_MODE : 'int', ERROR_CODE : 'int' }
|
||||
|
||||
next_type_id = FIRST_OBJ_ID
|
||||
|
||||
|
@ -178,6 +184,7 @@ def def_Types():
|
|||
v = Type2Str[k]
|
||||
if is_obj(k):
|
||||
Type2Dotnet[k] = v
|
||||
Type2ML[k] = v.lower()
|
||||
|
||||
def type2str(ty):
|
||||
global Type2Str
|
||||
|
@ -205,6 +212,10 @@ def type2javaw(ty):
|
|||
else:
|
||||
return Type2JavaW[ty]
|
||||
|
||||
def type2ml(ty):
|
||||
global Type2ML
|
||||
return Type2ML[ty]
|
||||
|
||||
def _in(ty):
|
||||
return (IN, ty);
|
||||
|
||||
|
@ -266,7 +277,7 @@ def param2dotnet(p):
|
|||
elif k == OUT_ARRAY:
|
||||
return "[Out] %s[]" % type2dotnet(param_type(p))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
return "[Out] out %s[]" % type2dotnet(param_type(p))
|
||||
return "[Out] out %s[]" % type2dotnet(param_type(p))
|
||||
else:
|
||||
return type2dotnet(param_type(p))
|
||||
|
||||
|
@ -313,6 +324,22 @@ def param2pystr(p):
|
|||
else:
|
||||
return type2pystr(param_type(p))
|
||||
|
||||
def param2ml(p):
|
||||
k = param_kind(p)
|
||||
if k == OUT:
|
||||
if param_type(p) == INT or param_type(p) == UINT or param_type(p) == INT64 or param_type(p) == UINT64:
|
||||
return "int"
|
||||
elif param_type(p) == STRING:
|
||||
return "string"
|
||||
else:
|
||||
return "ptr"
|
||||
elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
|
||||
return "%s array" % type2ml(param_type(p))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
return "%s array" % type2ml(param_type(p));
|
||||
else:
|
||||
return type2ml(param_type(p))
|
||||
|
||||
# Save name, result, params to generate wrapper
|
||||
_API2PY = []
|
||||
|
||||
|
@ -615,6 +642,7 @@ def mk_java():
|
|||
java_wrapper.write('#ifdef __cplusplus\n')
|
||||
java_wrapper.write('extern "C" {\n')
|
||||
java_wrapper.write('#endif\n\n')
|
||||
java_wrapper.write('#ifdef __GNUC__\n#if __GNUC__ >= 4\n#define DLL_VIS __attribute__ ((visibility ("default")))\n#else\n#define DLL_VIS\n#endif\n#else\n#define DLL_VIS\n#endif\n\n')
|
||||
java_wrapper.write('#if defined(_M_X64) || defined(_AMD64_)\n\n')
|
||||
java_wrapper.write('#define GETLONGAELEMS(T,OLD,NEW) \\\n')
|
||||
java_wrapper.write(' T * NEW = (OLD == 0) ? 0 : (T*) jenv->GetLongArrayElements(OLD, NULL);\n')
|
||||
|
@ -661,13 +689,13 @@ def mk_java():
|
|||
java_wrapper.write(' // upon errors, but the actual error handling is done by throwing exceptions in the\n')
|
||||
java_wrapper.write(' // wrappers below.\n')
|
||||
java_wrapper.write('}\n\n')
|
||||
java_wrapper.write('JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, jlong a0)\n' % pkg_str)
|
||||
java_wrapper.write('DLL_VIS JNIEXPORT void JNICALL Java_%s_Native_setInternalErrorHandler(JNIEnv * jenv, jclass cls, jlong a0)\n' % pkg_str)
|
||||
java_wrapper.write('{\n')
|
||||
java_wrapper.write(' Z3_set_error_handler((Z3_context)a0, Z3JavaErrorHandler);\n')
|
||||
java_wrapper.write('}\n\n')
|
||||
java_wrapper.write('')
|
||||
for name, result, params in _dotnet_decls:
|
||||
java_wrapper.write('JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name)))
|
||||
java_wrapper.write('DLL_VIS JNIEXPORT %s JNICALL Java_%s_Native_INTERNAL%s(JNIEnv * jenv, jclass cls' % (type2javaw(result), pkg_str, java_method_name(name)))
|
||||
i = 0;
|
||||
for param in params:
|
||||
java_wrapper.write(', ')
|
||||
|
@ -927,6 +955,9 @@ def def_API(name, result, params):
|
|||
elif ty == DOUBLE:
|
||||
log_c.write(" D(a%s);\n" % i)
|
||||
exe_c.write("in.get_double(%s)" % i)
|
||||
elif ty == FLOAT:
|
||||
log_c.write(" D(a%s);\n" % i)
|
||||
exe_c.write("in.get_float(%s)" % i)
|
||||
elif ty == BOOL:
|
||||
log_c.write(" I(a%s);\n" % i)
|
||||
exe_c.write("in.get_bool(%s)" % i)
|
||||
|
@ -1039,6 +1070,460 @@ def mk_bindings():
|
|||
exe_c.write(" in.register_cmd(%s, exec_%s);\n" % (key, val))
|
||||
exe_c.write("}\n")
|
||||
|
||||
def ml_method_name(name):
|
||||
return name[3:] # Remove Z3_
|
||||
|
||||
def is_out_param(p):
|
||||
if param_kind(p) == OUT or param_kind(p) == INOUT or param_kind(p) == OUT_ARRAY or param_kind(p) == INOUT_ARRAY or param_kind(p) == OUT_MANAGED_ARRAY:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def outparams(params):
|
||||
op = []
|
||||
for param in params:
|
||||
if is_out_param(param):
|
||||
op.append(param)
|
||||
return op
|
||||
|
||||
def is_in_param(p):
|
||||
if param_kind(p) == IN or param_kind(p) == INOUT or param_kind(p) == IN_ARRAY or param_kind(p) == INOUT_ARRAY:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def inparams(params):
|
||||
ip = []
|
||||
for param in params:
|
||||
if is_in_param(param):
|
||||
ip.append(param)
|
||||
return ip
|
||||
|
||||
def is_array_param(p):
|
||||
if param_kind(p) == IN_ARRAY or param_kind(p) == INOUT_ARRAY or param_kind(p) == OUT_ARRAY:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def arrayparams(params):
|
||||
op = []
|
||||
for param in params:
|
||||
if is_array_param(param):
|
||||
op.append(param)
|
||||
return op
|
||||
|
||||
|
||||
def ml_unwrap(t, ts, s):
|
||||
if t == STRING:
|
||||
return '(' + ts + ') String_val(' + s + ')'
|
||||
elif t == BOOL:
|
||||
return '(' + ts + ') Bool_val(' + s + ')'
|
||||
elif t == INT or t == PRINT_MODE or t == ERROR_CODE:
|
||||
return '(' + ts + ') Int_val(' + s + ')'
|
||||
elif t == UINT:
|
||||
return '(' + ts + ') Unsigned_int_val(' + s + ')'
|
||||
elif t == INT64:
|
||||
return '(' + ts + ') Long_val(' + s + ')'
|
||||
elif t == UINT64:
|
||||
return '(' + ts + ') Unsigned_long_val(' + s + ')'
|
||||
elif t == DOUBLE:
|
||||
return '(' + ts + ') Double_val(' + s + ')'
|
||||
else:
|
||||
return '* (' + ts + '*) Data_custom_val(' + s + ')'
|
||||
|
||||
def ml_set_wrap(t, d, n):
|
||||
if t == VOID:
|
||||
return d + ' = Val_unit;'
|
||||
elif t == BOOL:
|
||||
return d + ' = Val_bool(' + n + ');'
|
||||
elif t == INT or t == UINT or t == PRINT_MODE or t == ERROR_CODE:
|
||||
return d + ' = Val_int(' + n + ');'
|
||||
elif t == INT64 or t == UINT64:
|
||||
return d + ' = Val_long(' + n + ');'
|
||||
elif t == DOUBLE:
|
||||
return 'Store_double_val(' + d + ', ' + n + ');'
|
||||
elif t == STRING:
|
||||
return d + ' = caml_copy_string((const char*) ' + n + ');'
|
||||
else:
|
||||
ts = type2str(t)
|
||||
return d + ' = caml_alloc_custom(&default_custom_ops, sizeof(' + ts + '), 0, 1); memcpy( Data_custom_val(' + d + '), &' + n + ', sizeof(' + ts + '));'
|
||||
|
||||
def mk_ml():
|
||||
global Type2Str
|
||||
if not is_ml_enabled():
|
||||
return
|
||||
ml_dir = get_component('ml').src_dir
|
||||
ml_nativef = os.path.join(ml_dir, 'z3native.ml')
|
||||
ml_nativefi = os.path.join(ml_dir, 'z3native.mli')
|
||||
ml_wrapperf = os.path.join(ml_dir, 'z3native_stubs.c')
|
||||
ml_native = open(ml_nativef, 'w')
|
||||
ml_i = open(ml_nativefi, 'w')
|
||||
ml_native.write('(* Automatically generated file *)\n\n')
|
||||
ml_native.write('(** The native (raw) interface to the dynamic Z3 library. *)\n\n')
|
||||
ml_i.write('(* Automatically generated file *)\n\n')
|
||||
ml_i.write('(** The native (raw) interface to the dynamic Z3 library. *)\n\n')
|
||||
ml_i.write('(**/**)\n\n');
|
||||
ml_native.write('open Z3enums\n\n')
|
||||
ml_native.write('(**/**)\n')
|
||||
ml_native.write('type ptr\n')
|
||||
ml_i.write('type ptr\n')
|
||||
ml_native.write('and z3_symbol = ptr\n')
|
||||
ml_i.write('and z3_symbol = ptr\n')
|
||||
for k, v in Type2Str.items():
|
||||
if is_obj(k):
|
||||
ml_native.write('and %s = ptr\n' % v.lower())
|
||||
ml_i.write('and %s = ptr\n' % v.lower())
|
||||
ml_native.write('\n')
|
||||
ml_i.write('\n')
|
||||
ml_native.write('external is_null : ptr -> bool\n = "n_is_null"\n\n')
|
||||
ml_native.write('external mk_null : unit -> ptr\n = "n_mk_null"\n\n')
|
||||
ml_native.write('external set_internal_error_handler : ptr -> unit\n = "n_set_internal_error_handler"\n\n')
|
||||
ml_native.write('exception Exception of string\n\n')
|
||||
ml_i.write('val is_null : ptr -> bool\n')
|
||||
ml_i.write('val mk_null : unit -> ptr\n')
|
||||
ml_i.write('val set_internal_error_handler : ptr -> unit\n\n')
|
||||
ml_i.write('exception Exception of string\n\n')
|
||||
|
||||
# ML declarations
|
||||
ml_native.write('module ML2C = struct\n\n')
|
||||
for name, result, params in _dotnet_decls:
|
||||
ml_native.write(' external n_%s : ' % ml_method_name(name))
|
||||
ml_i.write('val %s : ' % ml_method_name(name))
|
||||
ip = inparams(params)
|
||||
op = outparams(params)
|
||||
if len(ip) == 0:
|
||||
ml_native.write(' unit -> ')
|
||||
ml_i.write(' unit -> ')
|
||||
for p in ip:
|
||||
ml_native.write('%s -> ' % param2ml(p))
|
||||
ml_i.write('%s -> ' % param2ml(p))
|
||||
if len(op) > 0:
|
||||
ml_native.write('(')
|
||||
ml_i.write('(')
|
||||
first = True
|
||||
if result != VOID or len(op) == 0:
|
||||
ml_native.write('%s' % type2ml(result))
|
||||
ml_i.write('%s' % type2ml(result))
|
||||
first = False
|
||||
for p in op:
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
ml_native.write(' * ')
|
||||
ml_i.write(' * ')
|
||||
ml_native.write('%s' % param2ml(p))
|
||||
ml_i.write('%s' % param2ml(p))
|
||||
if len(op) > 0:
|
||||
ml_native.write(')')
|
||||
ml_i.write(')')
|
||||
ml_native.write('\n')
|
||||
ml_i.write('\n')
|
||||
if len(ip) > 5:
|
||||
ml_native.write(' = "n_%s_bytecode"\n' % ml_method_name(name))
|
||||
ml_native.write(' "n_%s"\n' % ml_method_name(name))
|
||||
else:
|
||||
ml_native.write(' = "n_%s"\n' % ml_method_name(name))
|
||||
ml_native.write('\n')
|
||||
ml_native.write(' end\n\n')
|
||||
ml_i.write('\n(**/**)\n');
|
||||
|
||||
# Exception wrappers
|
||||
for name, result, params in _dotnet_decls:
|
||||
ip = inparams(params)
|
||||
op = outparams(params)
|
||||
ml_native.write(' let %s ' % ml_method_name(name))
|
||||
|
||||
first = True
|
||||
i = 0;
|
||||
for p in params:
|
||||
if is_in_param(p):
|
||||
if first:
|
||||
first = False;
|
||||
else:
|
||||
ml_native.write(' ')
|
||||
ml_native.write('a%d' % i)
|
||||
i = i + 1
|
||||
if len(ip) == 0:
|
||||
ml_native.write('()')
|
||||
ml_native.write(' = \n')
|
||||
ml_native.write(' ')
|
||||
if result == VOID and len(op) == 0:
|
||||
ml_native.write('let _ = ')
|
||||
else:
|
||||
ml_native.write('let res = ')
|
||||
ml_native.write('(ML2C.n_%s' % (ml_method_name(name)))
|
||||
if len(ip) == 0:
|
||||
ml_native.write(' ()')
|
||||
first = True
|
||||
i = 0;
|
||||
for p in params:
|
||||
if is_in_param(p):
|
||||
ml_native.write(' a%d' % i)
|
||||
i = i + 1
|
||||
ml_native.write(') in\n')
|
||||
if name not in Unwrapped and len(params) > 0 and param_type(params[0]) == CONTEXT:
|
||||
ml_native.write(' let err = (error_code_of_int (ML2C.n_get_error_code a0)) in \n')
|
||||
ml_native.write(' if err <> OK then\n')
|
||||
ml_native.write(' raise (Exception (ML2C.n_get_error_msg_ex a0 (int_of_error_code err)))\n')
|
||||
ml_native.write(' else\n')
|
||||
if result == VOID and len(op) == 0:
|
||||
ml_native.write(' ()\n')
|
||||
else:
|
||||
ml_native.write(' res\n')
|
||||
ml_native.write('\n')
|
||||
ml_native.write('(**/**)\n')
|
||||
|
||||
# C interface
|
||||
ml_wrapper = open(ml_wrapperf, 'w')
|
||||
ml_wrapper.write('// Automatically generated file\n\n')
|
||||
ml_wrapper.write('#include <stddef.h>\n')
|
||||
ml_wrapper.write('#include <string.h>\n\n')
|
||||
ml_wrapper.write('#ifdef __cplusplus\n')
|
||||
ml_wrapper.write('extern "C" {\n')
|
||||
ml_wrapper.write('#endif\n')
|
||||
ml_wrapper.write('#include <caml/mlvalues.h>\n')
|
||||
ml_wrapper.write('#include <caml/memory.h>\n')
|
||||
ml_wrapper.write('#include <caml/alloc.h>\n')
|
||||
ml_wrapper.write('#include <caml/fail.h>\n')
|
||||
ml_wrapper.write('#include <caml/callback.h>\n')
|
||||
ml_wrapper.write('#ifdef Custom_tag\n')
|
||||
ml_wrapper.write('#include <caml/custom.h>\n')
|
||||
ml_wrapper.write('#include <caml/bigarray.h>\n')
|
||||
ml_wrapper.write('#endif\n')
|
||||
ml_wrapper.write('#ifdef __cplusplus\n')
|
||||
ml_wrapper.write('}\n')
|
||||
ml_wrapper.write('#endif\n\n')
|
||||
ml_wrapper.write('#include <z3.h>\n\n')
|
||||
ml_wrapper.write('#define CAMLlocal6(X1,X2,X3,X4,X5,X6) \\\n')
|
||||
ml_wrapper.write(' CAMLlocal5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLlocal1(X6) \n')
|
||||
ml_wrapper.write('#define CAMLlocal7(X1,X2,X3,X4,X5,X6,X7) \\\n')
|
||||
ml_wrapper.write(' CAMLlocal5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLlocal2(X6,X7) \n')
|
||||
ml_wrapper.write('#define CAMLlocal8(X1,X2,X3,X4,X5,X6,X7,X8) \\\n')
|
||||
ml_wrapper.write(' CAMLlocal5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLlocal3(X6,X7,X8) \n')
|
||||
ml_wrapper.write('\n')
|
||||
ml_wrapper.write('#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7) \\\n')
|
||||
ml_wrapper.write(' CAMLparam5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam2(X6,X7) \n')
|
||||
ml_wrapper.write('#define CAMLparam8(X1,X2,X3,X4,X5,X6,X7,X8) \\\n')
|
||||
ml_wrapper.write(' CAMLparam5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam3(X6,X7,X8) \n')
|
||||
ml_wrapper.write('#define CAMLparam9(X1,X2,X3,X4,X5,X6,X7,X8,X9) \\\n')
|
||||
ml_wrapper.write(' CAMLparam5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam4(X6,X7,X8,X9) \n')
|
||||
ml_wrapper.write('#define CAMLparam12(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12) \\\n')
|
||||
ml_wrapper.write(' CAMLparam5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam5(X6,X7,X8,X9,X10); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam2(X11,X12) \n')
|
||||
ml_wrapper.write('#define CAMLparam13(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13) \\\n')
|
||||
ml_wrapper.write(' CAMLparam5(X1,X2,X3,X4,X5); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam5(X6,X7,X8,X9,X10); \\\n')
|
||||
ml_wrapper.write(' CAMLxparam3(X11,X12,X13) \n')
|
||||
ml_wrapper.write('\n\n')
|
||||
ml_wrapper.write('static struct custom_operations default_custom_ops = {\n')
|
||||
ml_wrapper.write(' (char*) "default handling",\n')
|
||||
ml_wrapper.write(' custom_finalize_default,\n')
|
||||
ml_wrapper.write(' custom_compare_default,\n')
|
||||
ml_wrapper.write(' custom_hash_default,\n')
|
||||
ml_wrapper.write(' custom_serialize_default,\n')
|
||||
ml_wrapper.write(' custom_deserialize_default\n')
|
||||
ml_wrapper.write('};\n\n')
|
||||
ml_wrapper.write('#ifdef __cplusplus\n')
|
||||
ml_wrapper.write('extern "C" {\n')
|
||||
ml_wrapper.write('#endif\n\n')
|
||||
ml_wrapper.write('CAMLprim value n_is_null(value p) {\n')
|
||||
ml_wrapper.write(' void * t = * (void**) Data_custom_val(p);\n')
|
||||
ml_wrapper.write(' return Val_bool(t == 0);\n')
|
||||
ml_wrapper.write('}\n\n')
|
||||
ml_wrapper.write('CAMLprim value n_mk_null( void ) {\n')
|
||||
ml_wrapper.write(' CAMLparam0();\n')
|
||||
ml_wrapper.write(' CAMLlocal1(result);\n')
|
||||
ml_wrapper.write(' void * z3_result = 0;\n')
|
||||
ml_wrapper.write(' result = caml_alloc_custom(&default_custom_ops, sizeof(void*), 0, 1);\n')
|
||||
ml_wrapper.write(' memcpy( Data_custom_val(result), &z3_result, sizeof(void*));\n')
|
||||
ml_wrapper.write(' CAMLreturn (result);\n')
|
||||
ml_wrapper.write('}\n\n')
|
||||
ml_wrapper.write('void MLErrorHandler(Z3_context c, Z3_error_code e)\n')
|
||||
ml_wrapper.write('{\n')
|
||||
ml_wrapper.write(' // Internal do-nothing error handler. This is required to avoid that Z3 calls exit()\n')
|
||||
ml_wrapper.write(' // upon errors, but the actual error handling is done by throwing exceptions in the\n')
|
||||
ml_wrapper.write(' // wrappers below.\n')
|
||||
ml_wrapper.write('}\n\n')
|
||||
ml_wrapper.write('void n_set_internal_error_handler(value a0)\n')
|
||||
ml_wrapper.write('{\n')
|
||||
ml_wrapper.write(' Z3_context _a0 = * (Z3_context*) Data_custom_val(a0);\n')
|
||||
ml_wrapper.write(' Z3_set_error_handler(_a0, MLErrorHandler);\n')
|
||||
ml_wrapper.write('}\n\n')
|
||||
for name, result, params in _dotnet_decls:
|
||||
ip = inparams(params)
|
||||
op = outparams(params)
|
||||
ap = arrayparams(params)
|
||||
ret_size = len(op)
|
||||
if result != VOID:
|
||||
ret_size = ret_size + 1
|
||||
|
||||
# Setup frame
|
||||
ml_wrapper.write('CAMLprim value n_%s(' % ml_method_name(name))
|
||||
first = True
|
||||
i = 0
|
||||
for p in params:
|
||||
if is_in_param(p):
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
ml_wrapper.write(', ')
|
||||
ml_wrapper.write('value a%d' % i)
|
||||
i = i + 1
|
||||
ml_wrapper.write(') {\n')
|
||||
ml_wrapper.write(' CAMLparam%d(' % len(ip))
|
||||
i = 0
|
||||
first = True
|
||||
for p in params:
|
||||
if is_in_param(p):
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
ml_wrapper.write(', ')
|
||||
ml_wrapper.write('a%d' % i)
|
||||
i = i + 1
|
||||
ml_wrapper.write(');\n')
|
||||
i = 0
|
||||
if len(op) + len(ap) == 0:
|
||||
ml_wrapper.write(' CAMLlocal1(result);\n')
|
||||
else:
|
||||
c = 0
|
||||
for p in params:
|
||||
if is_out_param(p) or is_array_param(p):
|
||||
c = c + 1
|
||||
ml_wrapper.write(' CAMLlocal%s(result, res_val' % (c+2))
|
||||
for p in params:
|
||||
if is_out_param(p) or is_array_param(p):
|
||||
ml_wrapper.write(', _a%s_val' % i)
|
||||
i = i + 1
|
||||
ml_wrapper.write(');\n')
|
||||
|
||||
if len(ap) != 0:
|
||||
ml_wrapper.write(' unsigned _i;\n')
|
||||
|
||||
# declare locals, preprocess arrays, strings, in/out arguments
|
||||
i = 0
|
||||
for param in params:
|
||||
k = param_kind(param)
|
||||
if k == OUT_ARRAY:
|
||||
ml_wrapper.write(' %s * _a%s = (%s*) malloc(sizeof(%s) * (_a%s));\n' % (
|
||||
type2str(param_type(param)),
|
||||
i,
|
||||
type2str(param_type(param)),
|
||||
type2str(param_type(param)),
|
||||
param_array_capacity_pos(param)))
|
||||
elif k == OUT_MANAGED_ARRAY:
|
||||
ml_wrapper.write(' %s * _a%s = 0;\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 = (%s*) malloc(sizeof(%s) * _a%s);\n' % (ts, i, ts, ts, param_array_capacity_pos(param)))
|
||||
elif k == IN:
|
||||
t = param_type(param)
|
||||
ml_wrapper.write(' %s _a%s = %s;\n' % (type2str(t), 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
|
||||
|
||||
if result != VOID:
|
||||
ml_wrapper.write(' %s z3_result;\n' % type2str(result))
|
||||
|
||||
i = 0
|
||||
for param in params:
|
||||
k = param_kind(param)
|
||||
if k == IN_ARRAY or k == INOUT_ARRAY:
|
||||
t = param_type(param)
|
||||
ts = type2str(t)
|
||||
ml_wrapper.write(' for (_i = 0; _i < _a%s; _i++) { _a%s[_i] = %s; }\n' % (param_array_capacity_pos(param), i, ml_unwrap(t, ts, 'Field(a' + str(i) + ', _i)')))
|
||||
i = i + 1
|
||||
|
||||
# invoke procedure
|
||||
ml_wrapper.write(' ')
|
||||
if result != VOID:
|
||||
ml_wrapper.write('z3_result = ')
|
||||
ml_wrapper.write('%s(' % name)
|
||||
i = 0
|
||||
first = True
|
||||
for param in params:
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
ml_wrapper.write(', ')
|
||||
k = param_kind(param)
|
||||
if k == OUT or k == INOUT or k == OUT_MANAGED_ARRAY:
|
||||
ml_wrapper.write('&_a%s' % i)
|
||||
else:
|
||||
ml_wrapper.write('_a%i' % i)
|
||||
i = i + 1
|
||||
ml_wrapper.write(');\n')
|
||||
|
||||
# convert output params
|
||||
if len(op) > 0:
|
||||
if result != VOID:
|
||||
ml_wrapper.write(' %s\n' % ml_set_wrap(result, "res_val", "z3_result"))
|
||||
i = 0;
|
||||
for p in params:
|
||||
if param_kind(p) == OUT_ARRAY or param_kind(p) == INOUT_ARRAY:
|
||||
ml_wrapper.write(' _a%s_val = caml_alloc(_a%s, 0);\n' % (i, param_array_capacity_pos(p)))
|
||||
ml_wrapper.write(' for (_i = 0; _i < _a%s; _i++) { value t; %s Store_field(_a%s_val, _i, t); }\n' % (param_array_capacity_pos(p), ml_set_wrap(param_type(p), 't', '_a' + str(i) + '[_i]'), i))
|
||||
elif param_kind(p) == OUT_MANAGED_ARRAY:
|
||||
ml_wrapper.write(' %s\n' % ml_set_wrap(param_type(p), "_a" + str(i) + "_val", "_a" + str(i) ))
|
||||
elif is_out_param(p):
|
||||
ml_wrapper.write(' %s\n' % ml_set_wrap(param_type(p), "_a" + str(i) + "_val", "_a" + str(i) ))
|
||||
i = i + 1
|
||||
|
||||
# return tuples
|
||||
if len(op) == 0:
|
||||
ml_wrapper.write(' %s\n' % ml_set_wrap(result, "result", "z3_result"))
|
||||
else:
|
||||
ml_wrapper.write(' result = caml_alloc(%s, 0);\n' % ret_size)
|
||||
i = j = 0
|
||||
if result != VOID:
|
||||
ml_wrapper.write(' Store_field(result, 0, res_val);\n')
|
||||
j = j + 1
|
||||
for p in params:
|
||||
if is_out_param(p):
|
||||
ml_wrapper.write(' Store_field(result, %s, _a%s_val);\n' % (j, i))
|
||||
j = j + 1;
|
||||
i = i + 1
|
||||
|
||||
# local array cleanup
|
||||
i = 0
|
||||
for p in params:
|
||||
k = param_kind(p)
|
||||
if k == OUT_ARRAY or k == IN_ARRAY or k == INOUT_ARRAY:
|
||||
ml_wrapper.write(' free(_a%s);\n' % i)
|
||||
i = i + 1
|
||||
|
||||
# return
|
||||
ml_wrapper.write(' CAMLreturn(result);\n')
|
||||
ml_wrapper.write('}\n\n')
|
||||
if len(ip) > 5:
|
||||
ml_wrapper.write('CAMLprim value n_%s_bytecode(value * argv, int argn) {\n' % ml_method_name(name))
|
||||
ml_wrapper.write(' return n_%s(' % ml_method_name(name))
|
||||
i = 0
|
||||
while i < len(ip):
|
||||
if i == 0:
|
||||
ml_wrapper.write('argv[0]')
|
||||
else:
|
||||
ml_wrapper.write(', argv[%s]' % i)
|
||||
i = i + 1
|
||||
ml_wrapper.write(');\n}\n')
|
||||
ml_wrapper.write('\n\n')
|
||||
ml_wrapper.write('#ifdef __cplusplus\n')
|
||||
ml_wrapper.write('}\n')
|
||||
ml_wrapper.write('#endif\n')
|
||||
if is_verbose():
|
||||
print ('Generated "%s"' % ml_nativef)
|
||||
|
||||
# Collect API(...) commands from
|
||||
def def_APIs():
|
||||
pat1 = re.compile(" *def_API.*")
|
||||
|
@ -1063,6 +1548,7 @@ mk_py_wrappers()
|
|||
mk_dotnet()
|
||||
mk_dotnet_wrappers()
|
||||
mk_java()
|
||||
mk_ml()
|
||||
|
||||
log_h.close()
|
||||
log_c.close()
|
||||
|
|
|
@ -300,7 +300,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(-1);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_get_symbol_string(Z3_context c, Z3_symbol s) {
|
||||
Z3_API char const * Z3_get_symbol_string(Z3_context c, Z3_symbol s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_get_symbol_string(c, s);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -648,6 +648,12 @@ extern "C" {
|
|||
else if (fid == mk_c(c)->get_datalog_fid() && k == datalog::DL_FINITE_SORT) {
|
||||
return Z3_FINITE_DOMAIN_SORT;
|
||||
}
|
||||
else if (fid == mk_c(c)->get_fpa_fid() && k == FLOATING_POINT_SORT) {
|
||||
return Z3_FLOATING_POINT_SORT;
|
||||
}
|
||||
else if (fid == mk_c(c)->get_fpa_fid() && k == ROUNDING_MODE_SORT) {
|
||||
return Z3_ROUNDING_MODE_SORT;
|
||||
}
|
||||
else {
|
||||
return Z3_UNKNOWN_SORT;
|
||||
}
|
||||
|
@ -817,7 +823,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a) {
|
||||
Z3_API char const * Z3_ast_to_string(Z3_context c, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_ast_to_string(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -860,11 +866,11 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_sort_to_string(Z3_context c, Z3_sort s) {
|
||||
Z3_API char const * Z3_sort_to_string(Z3_context c, Z3_sort s) {
|
||||
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(s));
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_func_decl_to_string(Z3_context c, Z3_func_decl f) {
|
||||
Z3_API char const * Z3_func_decl_to_string(Z3_context c, Z3_func_decl f) {
|
||||
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(f));
|
||||
}
|
||||
|
||||
|
@ -1113,6 +1119,62 @@ extern "C" {
|
|||
return Z3_OP_UNINTERPRETED;
|
||||
}
|
||||
}
|
||||
|
||||
if (mk_c(c)->get_fpa_fid() == _d->get_family_id()) {
|
||||
switch (_d->get_decl_kind()) {
|
||||
case OP_FPA_RM_NEAREST_TIES_TO_EVEN: return Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN;
|
||||
case OP_FPA_RM_NEAREST_TIES_TO_AWAY: return Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY;
|
||||
case OP_FPA_RM_TOWARD_POSITIVE: return Z3_OP_FPA_RM_TOWARD_POSITIVE;
|
||||
case OP_FPA_RM_TOWARD_NEGATIVE: return Z3_OP_FPA_RM_TOWARD_NEGATIVE;
|
||||
case OP_FPA_RM_TOWARD_ZERO: return Z3_OP_FPA_RM_TOWARD_ZERO;
|
||||
case OP_FPA_NUM: return Z3_OP_FPA_NUM;
|
||||
case OP_FPA_PLUS_INF: return Z3_OP_FPA_PLUS_INF;
|
||||
case OP_FPA_MINUS_INF: return Z3_OP_FPA_MINUS_INF;
|
||||
case OP_FPA_NAN: return Z3_OP_FPA_NAN;
|
||||
case OP_FPA_MINUS_ZERO: return Z3_OP_FPA_MINUS_ZERO;
|
||||
case OP_FPA_PLUS_ZERO: return Z3_OP_FPA_PLUS_ZERO;
|
||||
case OP_FPA_ADD: return Z3_OP_FPA_ADD;
|
||||
case OP_FPA_SUB: return Z3_OP_FPA_SUB;
|
||||
case OP_FPA_NEG: return Z3_OP_FPA_NEG;
|
||||
case OP_FPA_MUL: return Z3_OP_FPA_MUL;
|
||||
case OP_FPA_DIV: return Z3_OP_FPA_DIV;
|
||||
case OP_FPA_REM: return Z3_OP_FPA_REM;
|
||||
case OP_FPA_ABS: return Z3_OP_FPA_ABS;
|
||||
case OP_FPA_MIN: return Z3_OP_FPA_MIN;
|
||||
case OP_FPA_MAX: return Z3_OP_FPA_MAX;
|
||||
case OP_FPA_FMA: return Z3_OP_FPA_FMA;
|
||||
case OP_FPA_SQRT: return Z3_OP_FPA_SQRT;
|
||||
case OP_FPA_EQ: return Z3_OP_FPA_EQ;
|
||||
case OP_FPA_ROUND_TO_INTEGRAL: return Z3_OP_FPA_ROUND_TO_INTEGRAL;
|
||||
case OP_FPA_LT: return Z3_OP_FPA_LT;
|
||||
case OP_FPA_GT: return Z3_OP_FPA_GT;
|
||||
case OP_FPA_LE: return Z3_OP_FPA_LE;
|
||||
case OP_FPA_GE: return Z3_OP_FPA_GE;
|
||||
case OP_FPA_IS_NAN: return Z3_OP_FPA_IS_NAN;
|
||||
case OP_FPA_IS_INF: return Z3_OP_FPA_IS_INF;
|
||||
case OP_FPA_IS_ZERO: return Z3_OP_FPA_IS_ZERO;
|
||||
case OP_FPA_IS_NORMAL: return Z3_OP_FPA_IS_NORMAL;
|
||||
case OP_FPA_IS_SUBNORMAL: return Z3_OP_FPA_IS_SUBNORMAL;
|
||||
case OP_FPA_IS_NEGATIVE: return Z3_OP_FPA_IS_NEGATIVE;
|
||||
case OP_FPA_IS_POSITIVE: return Z3_OP_FPA_IS_POSITIVE;
|
||||
case OP_FPA_FP: return Z3_OP_FPA_FP;
|
||||
case OP_FPA_TO_FP: return Z3_OP_FPA_TO_FP;
|
||||
case OP_FPA_TO_FP_UNSIGNED: return Z3_OP_FPA_TO_FP_UNSIGNED;
|
||||
case OP_FPA_TO_UBV: return Z3_OP_FPA_TO_UBV;
|
||||
case OP_FPA_TO_SBV: return Z3_OP_FPA_TO_SBV;
|
||||
case OP_FPA_TO_REAL: return Z3_OP_FPA_TO_REAL;
|
||||
case OP_FPA_TO_IEEE_BV: return Z3_OP_FPA_TO_IEEE_BV;
|
||||
case OP_FPA_INTERNAL_BVWRAP:
|
||||
case OP_FPA_INTERNAL_BVUNWRAP:
|
||||
case OP_FPA_INTERNAL_TO_UBV_UNSPECIFIED:
|
||||
case OP_FPA_INTERNAL_TO_SBV_UNSPECIFIED:
|
||||
case OP_FPA_INTERNAL_TO_REAL_UNSPECIFIED:
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
}
|
||||
}
|
||||
|
||||
if (mk_c(c)->m().get_label_family_id() == _d->get_family_id()) {
|
||||
switch(_d->get_decl_kind()) {
|
||||
|
|
|
@ -88,6 +88,8 @@ namespace api {
|
|||
m_arith_util(m()),
|
||||
m_bv_util(m()),
|
||||
m_datalog_util(m()),
|
||||
m_fpa_util(m()),
|
||||
m_dtutil(m()),
|
||||
m_last_result(m()),
|
||||
m_ast_trail(m()),
|
||||
m_replay_stack() {
|
||||
|
@ -112,6 +114,7 @@ namespace api {
|
|||
m_array_fid = m().mk_family_id("array");
|
||||
m_dt_fid = m().mk_family_id("datatype");
|
||||
m_datalog_fid = m().mk_family_id("datalog_relation");
|
||||
m_fpa_fid = m().mk_family_id("fpa");
|
||||
m_dt_plugin = static_cast<datatype_decl_plugin*>(m().get_plugin(m_dt_fid));
|
||||
|
||||
if (!m_user_ref_count) {
|
||||
|
@ -546,12 +549,12 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_get_error_msg(Z3_error_code err) {
|
||||
Z3_API char const * Z3_get_error_msg(Z3_error_code err) {
|
||||
LOG_Z3_get_error_msg(err);
|
||||
return _get_error_msg_ex(0, err);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_get_error_msg_ex(Z3_context c, Z3_error_code err) {
|
||||
Z3_API char const * Z3_get_error_msg_ex(Z3_context c, Z3_error_code err) {
|
||||
LOG_Z3_get_error_msg_ex(c, err);
|
||||
return _get_error_msg_ex(c, err);
|
||||
}
|
||||
|
@ -575,7 +578,7 @@ extern "C" {
|
|||
|
||||
};
|
||||
|
||||
ast_manager & Z3_API Z3_get_manager(__in Z3_context c) {
|
||||
Z3_API ast_manager& Z3_get_manager(__in Z3_context c) {
|
||||
return mk_c(c)->m();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ Revision History:
|
|||
#include"bv_decl_plugin.h"
|
||||
#include"datatype_decl_plugin.h"
|
||||
#include"dl_decl_plugin.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
#include"smt_kernel.h"
|
||||
#include"smt_params.h"
|
||||
#include"event_handler.h"
|
||||
|
@ -56,6 +57,8 @@ namespace api {
|
|||
arith_util m_arith_util;
|
||||
bv_util m_bv_util;
|
||||
datalog::dl_decl_util m_datalog_util;
|
||||
fpa_util m_fpa_util;
|
||||
datatype_util m_dtutil;
|
||||
|
||||
// Support for old solver API
|
||||
smt_params m_fparams;
|
||||
|
@ -75,6 +78,7 @@ namespace api {
|
|||
family_id m_bv_fid;
|
||||
family_id m_dt_fid;
|
||||
family_id m_datalog_fid;
|
||||
family_id m_fpa_fid;
|
||||
datatype_decl_plugin * m_dt_plugin;
|
||||
|
||||
std::string m_string_buffer; // temporary buffer used to cache strings sent to the "external" world.
|
||||
|
@ -115,12 +119,15 @@ namespace api {
|
|||
arith_util & autil() { return m_arith_util; }
|
||||
bv_util & bvutil() { return m_bv_util; }
|
||||
datalog::dl_decl_util & datalog_util() { return m_datalog_util; }
|
||||
fpa_util & fpautil() { return m_fpa_util; }
|
||||
datatype_util& dtutil() { return m_dtutil; }
|
||||
family_id get_basic_fid() const { return m_basic_fid; }
|
||||
family_id get_array_fid() const { return m_array_fid; }
|
||||
family_id get_arith_fid() const { return m_arith_fid; }
|
||||
family_id get_bv_fid() const { return m_bv_fid; }
|
||||
family_id get_dt_fid() const { return m_dt_fid; }
|
||||
family_id get_datalog_fid() const { return m_datalog_fid; }
|
||||
family_id get_fpa_fid() const { return m_fpa_fid; }
|
||||
datatype_decl_plugin * get_dt_plugin() const { return m_dt_plugin; }
|
||||
|
||||
Z3_error_code get_error_code() const { return m_error_code; }
|
||||
|
|
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
mk_c(c)->reset_last_result();
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
datatype_util dt_util(m);
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
|
||||
sort_ref_vector tuples(m);
|
||||
sort* tuple;
|
||||
|
@ -102,7 +102,7 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
mk_c(c)->reset_last_result();
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
datatype_util dt_util(m);
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
|
||||
sort_ref_vector sorts(m);
|
||||
sort* e;
|
||||
|
@ -451,7 +451,7 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
CHECK_VALID_AST(t, 0);
|
||||
sort * _t = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
|
||||
if (!dt_util.is_datatype(_t)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
|
@ -470,13 +470,13 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
CHECK_VALID_AST(t, 0);
|
||||
sort * _t = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
if (!dt_util.is_datatype(_t)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx >= decls->size()) {
|
||||
if (idx >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
|
@ -499,16 +499,16 @@ extern "C" {
|
|||
LOG_Z3_get_datatype_sort_recognizer(c, t, idx);
|
||||
RESET_ERROR_CODE();
|
||||
sort * _t = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
|
||||
if (!dt_util.is_datatype(_t)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx >= decls->size()) {
|
||||
if (idx >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
return 0;
|
||||
}
|
||||
func_decl* decl = (*decls)[idx];
|
||||
decl = dt_util.get_constructor_recognizer(decl);
|
||||
|
@ -522,16 +522,16 @@ extern "C" {
|
|||
LOG_Z3_get_datatype_sort_constructor_accessor(c, t, idx_c, idx_a);
|
||||
RESET_ERROR_CODE();
|
||||
sort * _t = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
|
||||
if (!dt_util.is_datatype(_t)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx_c >= decls->size()) {
|
||||
if (idx_c >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
return 0;
|
||||
}
|
||||
func_decl* decl = (*decls)[idx_c];
|
||||
if (decl->get_arity() <= idx_a) {
|
||||
|
@ -555,7 +555,7 @@ extern "C" {
|
|||
LOG_Z3_get_tuple_sort_mk_decl(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
sort * tuple = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
|
@ -570,7 +570,7 @@ extern "C" {
|
|||
LOG_Z3_get_tuple_sort_num_fields(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
sort * tuple = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
|
@ -593,7 +593,7 @@ extern "C" {
|
|||
LOG_Z3_get_tuple_sort_field_decl(c, t, i);
|
||||
RESET_ERROR_CODE();
|
||||
sort * tuple = to_sort(t);
|
||||
datatype_util dt_util(mk_c(c)->m());
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
|
|
842
src/api/api_fpa.cpp
Normal file
842
src/api/api_fpa.cpp
Normal file
|
@ -0,0 +1,842 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
api_fpa.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Additional APIs for floating-point arithmetic (FP).
|
||||
|
||||
Author:
|
||||
|
||||
Christoph M. Wintersteiger (cwinter) 2013-06-05
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rounding_mode_sort(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
sort * s = ctx->fpautil().mk_rm_sort();
|
||||
mk_c(c)->save_ast_trail(s);
|
||||
RETURN_Z3(of_sort(s));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_nearest_ties_to_even(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_nearest_ties_to_even();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rne(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_nearest_ties_to_even();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_nearest_ties_to_away(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_nearest_ties_to_away();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rna(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_nearest_ties_to_away();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_toward_positive(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_positive();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtp(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rtp(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_positive();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_toward_negative(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_negative();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rtn(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_negative();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_toward_zero(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_zero();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rtz(c);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_toward_zero();
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_sort(c, ebits, sbits);
|
||||
RESET_ERROR_CODE();
|
||||
if (ebits < 2 || sbits < 3) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
}
|
||||
api::context * ctx = mk_c(c);
|
||||
sort * s = ctx->fpautil().mk_float_sort(ebits, sbits);
|
||||
ctx->save_ast_trail(s);
|
||||
RETURN_Z3(of_sort(s));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 5, 11);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 5, 11);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 8, 24);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 8, 24);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_double(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 11, 53);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 11, 53);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 15, 113);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c) {
|
||||
return Z3_mk_fpa_sort(c, 15, 113);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_nan(c, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_nan(to_sort(s));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_inf(c, s, negative);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = negative != 0 ? ctx->fpautil().mk_ninf(to_sort(s)) :
|
||||
ctx->fpautil().mk_pinf(to_sort(s));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_inf(c, s, negative);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = negative != 0 ? ctx->fpautil().mk_nzero(to_sort(s)) :
|
||||
ctx->fpautil().mk_pzero(to_sort(s));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_fp(c, sgn, sig, exp);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_fp(to_expr(sgn), to_expr(sig), to_expr(exp));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_numeral_float(c, v, ty);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
scoped_mpf tmp(ctx->fpautil().fm());
|
||||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
v);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_double(Z3_context c, double v, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_numeral_double(c, v, ty);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
scoped_mpf tmp(ctx->fpautil().fm());
|
||||
ctx->fpautil().fm().set(tmp, ctx->fpautil().get_ebits(to_sort(ty)), ctx->fpautil().get_sbits(to_sort(ty)), v);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int(Z3_context c, signed v, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_numeral_int(c, v, ty);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
scoped_mpf tmp(ctx->fpautil().fm());
|
||||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
v);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, Z3_bool sgn, signed exp, unsigned sig, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
scoped_mpf tmp(ctx->fpautil().fm());
|
||||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
sgn != 0, sig, exp);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
scoped_mpf tmp(ctx->fpautil().fm());
|
||||
ctx->fpautil().fm().set(tmp,
|
||||
ctx->fpautil().get_ebits(to_sort(ty)),
|
||||
ctx->fpautil().get_sbits(to_sort(ty)),
|
||||
sgn != 0, sig, exp);
|
||||
expr * a = ctx->fpautil().mk_value(tmp);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_abs(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_abs(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_neg(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_neg(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_add(to_expr(rm), to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_sub(to_expr(rm), to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_mul(to_expr(rm), to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_div(to_expr(rm), to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_fma(c, rm, t1, t2, t3);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_fma(to_expr(rm), to_expr(t1), to_expr(t2), to_expr(t3));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_sqrt(c, rm, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_sqrt(to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_rem(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_rem(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_round_to_integral(c, rm, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_round_to_integral(to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_min(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_min(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_max(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
Z3_ast r = of_ast(ctx->fpautil().mk_max(to_expr(t1), to_expr(t2)));
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_leq(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_le(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_lt(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_lt(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_geq(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_ge(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_gt(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_gt(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_eq(c, t1, t2);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_float_eq(to_expr(t1), to_expr(t2));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_normal(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_normal(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_subnormal(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_subnormal(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_zero(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_zero(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_infinite(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_inf(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_nan(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_nan(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_negative(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_negative(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_negative(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_is_positive(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_is_positive(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_bv(c, bv, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!ctx->bvutil().is_bv(to_expr(bv)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(bv));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_float(c, rm, t, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!fu.is_float(to_expr(t)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_real(c, rm, t, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!ctx->autil().is_real(to_expr(t)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_signed(c, rm, t, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!ctx->bvutil().is_bv(to_expr(t)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_unsigned(c, rm, t, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!ctx->bvutil().is_bv(to_expr(t)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp_unsigned(to_sort(s), to_expr(rm), to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_ubv(c, rm, t, sz);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_to_ubv(to_expr(rm), to_expr(t), sz);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_sbv(c, rm, t, sz);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_to_sbv(to_expr(rm), to_expr(t), sz);
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_real(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
expr * a = ctx->fpautil().mk_to_real(to_expr(t));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_fpa_get_ebits(Z3_context c, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_ebits(c, s);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_NON_NULL(s, 0);
|
||||
return mk_c(c)->fpautil().get_ebits(to_sort(s));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_ebits(c, s);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_NON_NULL(s, 0);
|
||||
return mk_c(c)->fpautil().get_sbits(to_sort(s));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_sign(c, t, sgn);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
|
||||
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
|
||||
scoped_mpf val(mpfm);
|
||||
bool r = plugin->is_numeral(to_expr(t), val);
|
||||
if (!r || mpfm.is_nan(val)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
*sgn = (mpfm.is_nan(val)) ? 0 : mpfm.sgn(val);
|
||||
return r;
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(__in Z3_context c, __in Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_significand_string(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
|
||||
unsynch_mpz_manager & mpzm = mpfm.mpz_manager();
|
||||
unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
|
||||
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
|
||||
scoped_mpf val(mpfm);
|
||||
if (!plugin->is_numeral(to_expr(t), val)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return "";
|
||||
}
|
||||
else if (!mpfm.is_regular(val)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG)
|
||||
return "";
|
||||
}
|
||||
unsigned sbits = val.get().get_sbits();
|
||||
scoped_mpq q(mpqm);
|
||||
scoped_mpz sn(mpzm);
|
||||
mpfm.sig_normalized(val, sn);
|
||||
mpqm.set(q, sn);
|
||||
mpqm.div(q, mpfm.m_powers2(sbits - 1), q);
|
||||
std::stringstream ss;
|
||||
mpqm.display_decimal(ss, q, sbits);
|
||||
return mk_c(c)->mk_external_string(ss.str());
|
||||
Z3_CATCH_RETURN("");
|
||||
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(__in Z3_context c, __in Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
|
||||
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
|
||||
scoped_mpf val(mpfm);
|
||||
bool r = plugin->is_numeral(to_expr(t), val);
|
||||
if (!r) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return "";
|
||||
}
|
||||
else if (!mpfm.is_normal(val) && !mpfm.is_denormal(val)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG)
|
||||
return "";
|
||||
}
|
||||
mpf_exp_t exp = mpfm.exp_normalized(val);
|
||||
std::stringstream ss;
|
||||
ss << exp;
|
||||
return mk_c(c)->mk_external_string(ss.str());
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(__in Z3_context c, __in Z3_ast t, __out __int64 * n) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
|
||||
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
|
||||
scoped_mpf val(mpfm);
|
||||
bool r = plugin->is_numeral(to_expr(t), val);
|
||||
if (!r) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
*n = mpfm.exp(val);
|
||||
return 1;
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_ieee_bv(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
Z3_ast r = of_ast(ctx->fpautil().mk_float_to_ieee_bv(to_expr(t)));
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_int_real(Z3_context c, Z3_ast rm, Z3_ast exp, Z3_ast sig, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_fpa_to_fp_int_real(c, rm, sig, exp, s);
|
||||
RESET_ERROR_CODE();
|
||||
api::context * ctx = mk_c(c);
|
||||
fpa_util & fu = ctx->fpautil();
|
||||
if (!fu.is_rm(to_expr(rm)) ||
|
||||
!ctx->autil().is_real(to_expr(sig)) ||
|
||||
!ctx->autil().is_int(to_expr(exp)) ||
|
||||
!fu.is_float(to_sort(s))) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(sig), to_expr(exp));
|
||||
ctx->save_ast_trail(a);
|
||||
RETURN_Z3(of_expr(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
};
|
|
@ -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:
|
||||
API for interpolation
|
||||
Abstract:
|
||||
API for interpolation
|
||||
|
||||
Author:
|
||||
Author:
|
||||
|
||||
Ken McMillan
|
||||
Ken McMillan
|
||||
|
||||
Revision History:
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include<sstream>
|
||||
#include<vector>
|
||||
|
@ -66,7 +66,6 @@ extern "C" {
|
|||
// Z3_set_param_value(cfg, "SIMPLIFY_CLAUSES","false");
|
||||
|
||||
Z3_context ctx = Z3_mk_context(cfg);
|
||||
Z3_del_config(cfg);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
@ -192,19 +191,19 @@ extern "C" {
|
|||
|
||||
|
||||
Z3_interpolation_options
|
||||
Z3_mk_interpolation_options(){
|
||||
Z3_mk_interpolation_options(){
|
||||
return (Z3_interpolation_options) new interpolation_options_struct;
|
||||
}
|
||||
|
||||
void
|
||||
Z3_del_interpolation_options(Z3_interpolation_options opts){
|
||||
Z3_del_interpolation_options(Z3_interpolation_options opts){
|
||||
delete opts;
|
||||
}
|
||||
|
||||
void
|
||||
Z3_set_interpolation_option(Z3_interpolation_options opts,
|
||||
Z3_string name,
|
||||
Z3_string value){
|
||||
Z3_set_interpolation_option(Z3_interpolation_options opts,
|
||||
Z3_string name,
|
||||
Z3_string value){
|
||||
opts->map[name] = value;
|
||||
}
|
||||
|
||||
|
@ -293,10 +292,10 @@ extern "C" {
|
|||
else {
|
||||
model_ref _m;
|
||||
m_solver.get()->get_model(_m);
|
||||
Z3_model_ref *crap = alloc(Z3_model_ref);
|
||||
crap->m_model = _m.get();
|
||||
mk_c(c)->save_object(crap);
|
||||
*model = of_model(crap);
|
||||
Z3_model_ref *tmp_val = alloc(Z3_model_ref);
|
||||
tmp_val->m_model = _m.get();
|
||||
mk_c(c)->save_object(tmp_val);
|
||||
*model = of_model(tmp_val);
|
||||
}
|
||||
|
||||
*out_interp = of_ast_vector(v);
|
||||
|
@ -413,11 +412,11 @@ extern "C" {
|
|||
Z3_ast foo = Z3_mk_interpolant(ctx, and_vec(ctx, c));
|
||||
chs[parents[i]].push_back(foo);
|
||||
}
|
||||
{
|
||||
svector<Z3_ast> &c = chs[num - 1];
|
||||
c.push_back(cnsts[num - 1]);
|
||||
res = and_vec(ctx, c);
|
||||
}
|
||||
{
|
||||
svector<Z3_ast> &c = chs[num - 1];
|
||||
c.push_back(cnsts[num - 1]);
|
||||
res = and_vec(ctx, c);
|
||||
}
|
||||
}
|
||||
Z3_inc_ref(ctx, res);
|
||||
return res;
|
||||
|
@ -490,8 +489,8 @@ extern "C" {
|
|||
try {
|
||||
std::string foo(filename);
|
||||
if (foo.size() >= 5 && foo.substr(foo.size() - 5) == ".smt2"){
|
||||
Z3_ast ass = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
|
||||
Z3_app app = Z3_to_app(ctx, ass);
|
||||
Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
|
||||
Z3_app app = Z3_to_app(ctx, assrts);
|
||||
int nconjs = Z3_get_app_num_args(ctx, app);
|
||||
assertions.resize(nconjs);
|
||||
for (int k = 0; k < nconjs; k++)
|
||||
|
@ -621,8 +620,8 @@ extern "C" {
|
|||
|
||||
for (unsigned j = 0; j < num - 1; j++)
|
||||
if (read_parents[j] == SHRT_MAX){
|
||||
read_error << "formula " << j + 1 << ": unreferenced";
|
||||
goto fail;
|
||||
read_error << "formula " << j + 1 << ": unreferenced";
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*_num = num;
|
||||
|
@ -644,69 +643,69 @@ extern "C" {
|
|||
#define IZ3_ROOT SHRT_MAX
|
||||
|
||||
/** This function uses Z3 to determine satisfiability of a set of
|
||||
constraints. If UNSAT, an interpolant is returned, based on the
|
||||
refutation generated by Z3. If SAT, a model is returned.
|
||||
constraints. If UNSAT, an interpolant is returned, based on the
|
||||
refutation generated by Z3. If SAT, a model is returned.
|
||||
|
||||
If "parents" is non-null, computes a tree interpolant. The tree is
|
||||
defined by the array "parents". This array maps each formula in
|
||||
the tree to its parent, where formulas are indicated by their
|
||||
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
|
||||
parent entry should be the constant IZ3_ROOT.
|
||||
If "parents" is non-null, computes a tree interpolant. The tree is
|
||||
defined by the array "parents". This array maps each formula in
|
||||
the tree to its parent, where formulas are indicated by their
|
||||
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
|
||||
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 num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints (AST's in context ctx)
|
||||
\param parents The parents vector defining the tree structure
|
||||
\param options Interpolation options (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 labels Returns relevant labels if SAT (may be NULL)
|
||||
\param incremental
|
||||
\param ctx The Z3 context. Must be generated by iz3_mk_context
|
||||
\param num The number of constraints in the sequence
|
||||
\param cnsts Array of constraints (AST's in context ctx)
|
||||
\param parents The parents vector defining the tree structure
|
||||
\param options Interpolation options (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 labels Returns relevant labels if SAT (may be NULL)
|
||||
\param incremental
|
||||
|
||||
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
|
||||
context ctx. The model and interpolants returned are also
|
||||
in this context.
|
||||
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
|
||||
context ctx. The model and interpolants returned are also
|
||||
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_TRUE = constraints SAT (model returned)
|
||||
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
|
||||
Z3_L_FALSE = constraints UNSAT (interpolants returned)
|
||||
Z3_L_TRUE = constraints SAT (model returned)
|
||||
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
|
||||
|
||||
Currently, this function supports integer and boolean variables,
|
||||
as well as arrays over these types, with linear arithmetic,
|
||||
uninterpreted functions and quantifiers over integers (that is
|
||||
AUFLIA). Interpolants are produced in AULIA. However, some
|
||||
uses of array operations may cause quantifiers to appear in the
|
||||
interpolants even when there are no quantifiers in the input formulas.
|
||||
Although quantifiers may appear in the input formulas, Z3 may give up in
|
||||
this case, returning Z3_L_UNDEF.
|
||||
Currently, this function supports integer and boolean variables,
|
||||
as well as arrays over these types, with linear arithmetic,
|
||||
uninterpreted functions and quantifiers over integers (that is
|
||||
AUFLIA). Interpolants are produced in AULIA. However, some
|
||||
uses of array operations may cause quantifiers to appear in the
|
||||
interpolants even when there are no quantifiers in the input formulas.
|
||||
Although quantifiers may appear in the input formulas, Z3 may give up in
|
||||
this case, returning Z3_L_UNDEF.
|
||||
|
||||
If "incremental" is true, cnsts must contain exactly the set of
|
||||
formulas that are currently asserted in the context. If false,
|
||||
there must be no formulas currently asserted in the context.
|
||||
Setting "incremental" to true makes it posisble to incrementally
|
||||
add and remove constraints from the context until the context
|
||||
becomes UNSAT, at which point an interpolant is computed. Caution
|
||||
must be used, however. Before popping the context, if you wish to
|
||||
keep the interolant formulas, you *must* preserve them by using
|
||||
Z3_persist_ast. Also, if you want to simplify the interpolant
|
||||
formulas using Z3_simplify, you must first pop all of the
|
||||
assertions in the context (or use a different context). Otherwise,
|
||||
the formulas will be simplified *relative* to these constraints,
|
||||
which is almost certainly not what you want.
|
||||
If "incremental" is true, cnsts must contain exactly the set of
|
||||
formulas that are currently asserted in the context. If false,
|
||||
there must be no formulas currently asserted in the context.
|
||||
Setting "incremental" to true makes it posisble to incrementally
|
||||
add and remove constraints from the context until the context
|
||||
becomes UNSAT, at which point an interpolant is computed. Caution
|
||||
must be used, however. Before popping the context, if you wish to
|
||||
keep the interolant formulas, you *must* preserve them by using
|
||||
Z3_persist_ast. Also, if you want to simplify the interpolant
|
||||
formulas using Z3_simplify, you must first pop all of the
|
||||
assertions in the context (or use a different context). Otherwise,
|
||||
the formulas will be simplified *relative* to these constraints,
|
||||
which is almost certainly not what you want.
|
||||
|
||||
|
||||
Current limitations on tree interpolants. In a tree interpolation
|
||||
problem, each constant (0-ary function symbol) must occur only
|
||||
along one path from root to leaf. Function symbols (of arity > 0)
|
||||
are considered to have global scope (i.e., may appear in any
|
||||
interpolant formula).
|
||||
Current limitations on tree interpolants. In a tree interpolation
|
||||
problem, each constant (0-ary function symbol) must occur only
|
||||
along one path from root to leaf. Function symbols (of arity > 0)
|
||||
are considered to have global scope (i.e., may appear in any
|
||||
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,
|
||||
|
|
|
@ -663,7 +663,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(Z3_FALSE);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_model_to_string(Z3_context c, Z3_model m) {
|
||||
Z3_API char const * Z3_model_to_string(Z3_context c, Z3_model m) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_model_to_string(c, m);
|
||||
RESET_ERROR_CODE();
|
||||
|
|
|
@ -23,13 +23,15 @@ Revision History:
|
|||
#include"arith_decl_plugin.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include"algebraic_numbers.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
|
||||
bool is_numeral_sort(Z3_context c, Z3_sort ty) {
|
||||
sort * _ty = to_sort(ty);
|
||||
family_id fid = _ty->get_family_id();
|
||||
if (fid != mk_c(c)->get_arith_fid() &&
|
||||
fid != mk_c(c)->get_bv_fid() &&
|
||||
fid != mk_c(c)->get_datalog_fid()) {
|
||||
fid != mk_c(c)->get_datalog_fid() &&
|
||||
fid != mk_c(c)->get_fpa_fid()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -48,7 +50,7 @@ extern "C" {
|
|||
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, const char* n, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_numeral(c, n, ty);
|
||||
RESET_ERROR_CODE();
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
@ -56,40 +58,42 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
sort * _ty = to_sort(ty);
|
||||
bool is_float = mk_c(c)->fpautil().is_float(_ty);
|
||||
std::string fixed_num;
|
||||
char const* m = n;
|
||||
while (*m) {
|
||||
if (!(('0' <= *m && *m <= '9') ||
|
||||
('/' == *m) || ('-' == *m) ||
|
||||
(' ' == *m) || ('\n' == *m) ||
|
||||
('.' == *m) || ('e' == *m) ||
|
||||
('E' == *m))) {
|
||||
('/' == *m) || ('-' == *m) ||
|
||||
(' ' == *m) || ('\n' == *m) ||
|
||||
('.' == *m) || ('e' == *m) ||
|
||||
('E' == *m) ||
|
||||
('p' == *m && is_float) ||
|
||||
('P' == *m && is_float))) {
|
||||
SET_ERROR_CODE(Z3_PARSER_ERROR);
|
||||
return 0;
|
||||
}
|
||||
++m;
|
||||
}
|
||||
ast * a = mk_c(c)->mk_numeral_core(rational(n), to_sort(ty));
|
||||
ast * a = 0;
|
||||
if (_ty->get_family_id() == mk_c(c)->get_fpa_fid()) {
|
||||
// avoid expanding floats into huge rationals.
|
||||
fpa_util & fu = mk_c(c)->fpautil();
|
||||
scoped_mpf t(fu.fm());
|
||||
fu.fm().set(t, fu.get_ebits(_ty), fu.get_sbits(_ty), MPF_ROUND_TOWARD_ZERO, n);
|
||||
a = fu.mk_value(t);
|
||||
mk_c(c)->save_ast_trail(a);
|
||||
}
|
||||
else
|
||||
a = mk_c(c)->mk_numeral_core(rational(n), _ty);
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_ast Z3_API Z3_mk_int(Z3_context c, int value, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_int(c, value, ty);
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty));
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned value, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_unsigned_int(c, value, ty);
|
||||
RESET_ERROR_CODE();
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
@ -97,11 +101,23 @@ extern "C" {
|
|||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned value, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_unsigned_int(c, value, ty);
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty));
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_int64(Z3_context c, long long value, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_int64(c, value, ty);
|
||||
RESET_ERROR_CODE();
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
@ -110,11 +126,11 @@ extern "C" {
|
|||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, unsigned long long value, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_unsigned_int64(c, value, ty);
|
||||
RESET_ERROR_CODE();
|
||||
RESET_ERROR_CODE();
|
||||
if (!check_numeral_sort(c, ty)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
@ -129,9 +145,11 @@ extern "C" {
|
|||
LOG_Z3_is_numeral_ast(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
expr* e = to_expr(a);
|
||||
return
|
||||
return
|
||||
mk_c(c)->autil().is_numeral(e) ||
|
||||
mk_c(c)->bvutil().is_numeral(e);
|
||||
mk_c(c)->bvutil().is_numeral(e) ||
|
||||
mk_c(c)->fpautil().is_numeral(e) ||
|
||||
mk_c(c)->fpautil().is_rm_numeral(e);
|
||||
Z3_CATCH_RETURN(Z3_FALSE);
|
||||
}
|
||||
|
||||
|
@ -172,8 +190,37 @@ extern "C" {
|
|||
return mk_c(c)->mk_external_string(r.to_string());
|
||||
}
|
||||
else {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return "";
|
||||
// floats are separated from all others to avoid huge rationals.
|
||||
fpa_util & fu = mk_c(c)->fpautil();
|
||||
scoped_mpf tmp(fu.fm());
|
||||
mpf_rounding_mode rm;
|
||||
if (mk_c(c)->fpautil().is_rm_numeral(to_expr(a), rm)) {
|
||||
switch (rm) {
|
||||
case OP_FPA_RM_NEAREST_TIES_TO_EVEN:
|
||||
return mk_c(c)->mk_external_string("roundNearestTiesToEven");
|
||||
break;
|
||||
case OP_FPA_RM_NEAREST_TIES_TO_AWAY:
|
||||
return mk_c(c)->mk_external_string("roundNearestTiesToAway");
|
||||
break;
|
||||
case OP_FPA_RM_TOWARD_POSITIVE:
|
||||
return mk_c(c)->mk_external_string("roundTowardPositive");
|
||||
break;
|
||||
case OP_FPA_RM_TOWARD_NEGATIVE:
|
||||
return mk_c(c)->mk_external_string("roundTowardNegative");
|
||||
break;
|
||||
case OP_FPA_RM_TOWARD_ZERO:
|
||||
default:
|
||||
return mk_c(c)->mk_external_string("roundTowardZero");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (mk_c(c)->fpautil().is_numeral(to_expr(a), tmp)) {
|
||||
return mk_c(c)->mk_external_string(fu.fm().to_string(tmp));
|
||||
}
|
||||
else {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
|
|
@ -507,7 +507,7 @@ extern "C" {
|
|||
return (Z3_ast)(p);
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_pattern_to_string(Z3_context c, Z3_pattern p) {
|
||||
Z3_API char const * Z3_pattern_to_string(Z3_context c, Z3_pattern p) {
|
||||
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(p));
|
||||
}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ extern "C" {
|
|||
Z3_CATCH;
|
||||
}
|
||||
|
||||
char const * Z3_API Z3_context_to_string(Z3_context c) {
|
||||
Z3_API char const * Z3_context_to_string(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_context_to_string(c);
|
||||
RESET_ERROR_CODE();
|
||||
|
|
|
@ -866,6 +866,9 @@ namespace z3 {
|
|||
friend expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; }
|
||||
|
||||
friend expr operator~(expr const & a) { Z3_ast r = Z3_mk_bvnot(a.ctx(), a); return expr(a.ctx(), r); }
|
||||
expr extract(unsigned hi, unsigned lo) const { Z3_ast r = Z3_mk_extract(ctx(), hi, lo, *this); return expr(ctx(), r); }
|
||||
unsigned lo() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 1)); }
|
||||
unsigned hi() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 0)); }
|
||||
|
||||
/**
|
||||
\brief Return a simplified version of this expression.
|
||||
|
@ -1314,6 +1317,26 @@ namespace z3 {
|
|||
expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
|
||||
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
|
||||
friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
|
||||
|
||||
std::string to_smt2(char const* status = "unknown") {
|
||||
array<Z3_ast> es(assertions());
|
||||
Z3_ast const* fmls = es.ptr();
|
||||
Z3_ast fml = 0;
|
||||
unsigned sz = es.size();
|
||||
if (sz > 0) {
|
||||
--sz;
|
||||
fml = fmls[sz];
|
||||
}
|
||||
else {
|
||||
fml = ctx().bool_val(true);
|
||||
}
|
||||
return std::string(Z3_benchmark_to_smtlib_string(
|
||||
ctx(),
|
||||
"", "", status, "",
|
||||
sz,
|
||||
fmls,
|
||||
fml));
|
||||
}
|
||||
};
|
||||
|
||||
class goal : public object {
|
||||
|
|
|
@ -213,12 +213,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
@ -227,10 +229,8 @@ namespace Microsoft.Z3
|
|||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST IncRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("inc() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("inc() called on null AST");
|
||||
if (Context == null || o == IntPtr.Zero)
|
||||
return;
|
||||
Context.AST_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
@ -238,10 +238,8 @@ namespace Microsoft.Z3
|
|||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST DecRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("dec() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("dec() called on null AST");
|
||||
if (Context == null || o == IntPtr.Zero)
|
||||
return;
|
||||
Context.AST_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
|
|
|
@ -128,12 +128,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_map_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_map_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Vectors of ASTs.
|
||||
/// </summary>
|
||||
internal class ASTVector : Z3Object
|
||||
public class ASTVector : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the vector
|
||||
|
@ -105,12 +105,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_vector_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_ast_vector_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -85,12 +85,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_apply_result_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_apply_result_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -32,11 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for ArithExpr </summary>
|
||||
internal protected ArithExpr(Context ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal ArithExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
|
|
|
@ -32,11 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for ArrayExpr </summary>
|
||||
internal protected ArrayExpr(Context ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal ArrayExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace Microsoft.Z3
|
|||
|
||||
#region Internal
|
||||
/// <summary> Constructor for BitVecExpr </summary>
|
||||
internal protected BitVecExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for BoolExpr </summary>
|
||||
internal protected BoolExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
/// <summary> Constructor for BoolExpr </summary>
|
||||
internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -2516,7 +2516,7 @@ namespace Microsoft.Z3
|
|||
/// Create a bit-vector numeral.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecNum>() != null);
|
||||
|
@ -3438,6 +3438,805 @@ namespace Microsoft.Z3
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Floating-Point Arithmetic
|
||||
|
||||
#region Rounding Modes
|
||||
#region RoundingMode Sort
|
||||
/// <summary>
|
||||
/// Create the floating-point RoundingMode sort.
|
||||
/// </summary>
|
||||
public FPRMSort MkFPRoundingModeSort()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMSort>() != null);
|
||||
return new FPRMSort(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Numerals
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
|
||||
/// </summary>
|
||||
public FPRMExpr MkFPRoundNearestTiesToEven()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMExpr(this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRNE()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_rne(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRoundNearestTiesToAway()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRNA()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_rna(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRoundTowardPositive()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRTP()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_rtp(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRoundTowardNegative()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRTN()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_rtn(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRoundTowardZero()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
|
||||
/// </summary>
|
||||
public FPRMNum MkFPRTZ()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPRMNum(this, Native.Z3_mk_fpa_rtz(nCtx));
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region FloatingPoint Sorts
|
||||
/// <summary>
|
||||
/// Create a FloatingPoint sort.
|
||||
/// </summary>
|
||||
/// <param name="ebits">exponent bits in the FloatingPoint sort.</param>
|
||||
/// <param name="sbits">significand bits in the FloatingPoint sort.</param>
|
||||
public FPSort MkFPSort(uint ebits, uint sbits)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, ebits, sbits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the half-precision (16-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSortHalf()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_half(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the half-precision (16-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSort16()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_16(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the single-precision (32-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSortSingle()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_single(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the single-precision (32-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSort32()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_32(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the double-precision (64-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSortDouble()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_double(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the double-precision (64-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSort64()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_64(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSortQuadruple()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
|
||||
/// </summary>
|
||||
public FPSort MkFPSort128()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPSort>() != null);
|
||||
return new FPSort(this, Native.Z3_mk_fpa_sort_128(nCtx));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Numerals
|
||||
/// <summary>
|
||||
/// Create a NaN of sort s.
|
||||
/// </summary>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNaN(FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a floating-point infinity of sort s.
|
||||
/// </summary>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
/// <param name="negative">indicates whether the result should be negative.</param>
|
||||
public FPNum MkFPInf(FPSort s, bool negative)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, negative ? 1 : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a floating-point zero of sort s.
|
||||
/// </summary>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
/// <param name="negative">indicates whether the result should be negative.</param>
|
||||
public FPNum MkFPZero(FPSort s, bool negative)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, negative ? 1 : 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a float.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(float v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a float.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(double v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from an int.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(int v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
|
||||
/// </summary>
|
||||
/// <param name="sgn">the sign.</param>
|
||||
/// <param name="sig">the significand.</param>
|
||||
/// <param name="exp">the exponent.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
|
||||
/// </summary>
|
||||
/// <param name="sgn">the sign.</param>
|
||||
/// <param name="sig">the significand.</param>
|
||||
/// <param name="exp">the exponent.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a float.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFP(float v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return MkFPNumeral(v, s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a float.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFP(double v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return MkFPNumeral(v, s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from an int.
|
||||
/// </summary>
|
||||
/// <param name="v">numeral value.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFP(int v, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return MkFPNumeral(v, s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
|
||||
/// </summary>
|
||||
/// <param name="sgn">the sign.</param>
|
||||
/// <param name="exp">the exponent.</param>
|
||||
/// <param name="sig">the significand.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return MkFPNumeral(sgn, exp, sig, s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
|
||||
/// </summary>
|
||||
/// <param name="sgn">the sign.</param>
|
||||
/// <param name="exp">the exponent.</param>
|
||||
/// <param name="sig">the significand.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
|
||||
return MkFPNumeral(sgn, exp, sig, s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
/// <summary>
|
||||
/// Floating-point absolute value
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public FPExpr MkFPAbs(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_abs(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point negation
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public FPExpr MkFPNeg(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_neg(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point addition
|
||||
/// </summary>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_add(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point subtraction
|
||||
/// </summary>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_sub(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point multiplication
|
||||
/// </summary>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_mul(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point division
|
||||
/// </summary>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_div(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point fused multiply-add
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The result is round((t1 * t2) + t3)
|
||||
/// </remarks>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
/// <param name="t3">floating-point term</param>
|
||||
public FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_fma(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point square root
|
||||
/// </summary>
|
||||
/// <param name="rm">rounding mode term</param>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_sqrt(this.nCtx, rm.NativeObject, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point remainder
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPRem(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_rem(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point roundToIntegral. Rounds a floating-point number to
|
||||
/// the closest integer, again represented as a floating-point number.
|
||||
/// </summary>
|
||||
/// <param name="rm">term of RoundingMode sort</param>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_round_to_integral(this.nCtx, rm.NativeObject, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum of floating-point numbers.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPMin(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_min(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum of floating-point numbers.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public FPExpr MkFPMax(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPNum>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_max(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point less than or equal.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public BoolExpr MkFPLEq(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_leq(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point less than.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public BoolExpr MkFPLt(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_lt(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point greater than or equal.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public BoolExpr MkFPGEq(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_geq(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point greater than.
|
||||
/// </summary>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public BoolExpr MkFPGt(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_gt(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point equality.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that this is IEEE 754 equality (as opposed to standard =).
|
||||
/// </remarks>
|
||||
/// <param name="t1">floating-point term</param>
|
||||
/// <param name="t2">floating-point term</param>
|
||||
public BoolExpr MkFPEq(FPExpr t1, FPExpr t2)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_eq(this.nCtx, t1.NativeObject, t2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a normal floating-point number.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsNormal(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_normal(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a subnormal floating-point number.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsSubnormal(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_subnormal(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a floating-point number with zero value, i.e., +0 or -0.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsZero(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_zero(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a floating-point number representing +oo or -oo.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsInfinite(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_infinite(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a NaN.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsNaN(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_nan(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a negative floating-point number.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsNegative(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_negative(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicate indicating whether t is a positive floating-point number.
|
||||
/// </summary>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public BoolExpr MkFPIsPositive(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr>() != null);
|
||||
return new BoolExpr(this, Native.Z3_mk_fpa_is_positive(this.nCtx, t.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Conversions to FloatingPoint terms
|
||||
/// <summary>
|
||||
/// Create an expression of FloatingPoint sort from three bit-vector expressions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is the operator named `fp' in the SMT FP theory definition.
|
||||
/// Note that sgn is required to be a bit-vector of size 1. Significand and exponent
|
||||
/// are required to be greater than 1 and 2 respectively. The FloatingPoint sort
|
||||
/// of the resulting expression is automatically determined from the bit-vector sizes
|
||||
/// of the arguments.
|
||||
/// </remarks>
|
||||
/// <param name="sgn">bit-vector term (of size 1) representing the sign.</param>
|
||||
/// <param name="sig">bit-vector term representing the significand.</param>
|
||||
/// <param name="exp">bit-vector term representing the exponent.</param>
|
||||
public FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_fp(this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of a bit-vector term bv to a
|
||||
/// floating-point term of sort s. The bit-vector size of bv (m) must be equal
|
||||
/// to ebits+sbits of s. The format of the bit-vector is as defined by the
|
||||
/// IEEE 754-2008 interchange format.
|
||||
/// </remarks>
|
||||
/// <param name="bv">bit-vector value (of size m).</param>
|
||||
/// <param name="s">FloatingPoint sort (ebits+sbits == m)</param>
|
||||
public FPExpr MkFPToFP(BitVecExpr bv, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_bv(this.nCtx, bv.NativeObject, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of a floating-point term t to a
|
||||
/// floating-point term of sort s. If necessary, the result will be rounded according
|
||||
/// to rounding mode rm.
|
||||
/// </remarks>
|
||||
/// <param name="rm">RoundingMode term.</param>
|
||||
/// <param name="t">FloatingPoint term.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a term of real sort into a term of FloatingPoint sort.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of term t of real sort into a
|
||||
/// floating-point term of sort s. If necessary, the result will be rounded according
|
||||
/// to rounding mode rm.
|
||||
/// </remarks>
|
||||
/// <param name="rm">RoundingMode term.</param>
|
||||
/// <param name="t">term of Real sort.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_real(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of the bit-vector term t into a
|
||||
/// floating-point term of sort s. The bit-vector t is taken to be in signed
|
||||
/// 2's complement format (when signed==true, otherwise unsigned). If necessary, the
|
||||
/// result will be rounded according to rounding mode rm.
|
||||
/// </remarks>
|
||||
/// <param name="rm">RoundingMode term.</param>
|
||||
/// <param name="t">term of bit-vector sort.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
/// <param name="signed">flag indicating whether t is interpreted as signed or unsigned bit-vector.</param>
|
||||
public FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
if (signed)
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_signed(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
|
||||
else
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_unsigned(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a floating-point number to another FloatingPoint sort s.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of a floating-point term t to a different
|
||||
/// FloatingPoint sort s. If necessary, rounding according to rm is applied.
|
||||
/// </remarks>
|
||||
/// <param name="s">FloatingPoint sort</param>
|
||||
/// <param name="rm">floating-point rounding mode term</param>
|
||||
/// <param name="t">floating-point term</param>
|
||||
public FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<FPExpr>() != null);
|
||||
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Conversions from FloatingPoint terms
|
||||
/// <summary>
|
||||
/// Conversion of a floating-point term into a bit-vector.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of the floating-poiunt term t into a
|
||||
/// bit-vector term of size sz in 2's complement format (signed when signed==true). If necessary,
|
||||
/// the result will be rounded according to rounding mode rm.
|
||||
/// </remarks>
|
||||
/// <param name="rm">RoundingMode term.</param>
|
||||
/// <param name="t">FloatingPoint term</param>
|
||||
/// <param name="sz">Size of the resulting bit-vector.</param>
|
||||
/// <param name="signed">Indicates whether the result is a signed or unsigned bit-vector.</param>
|
||||
public BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool signed)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
|
||||
if (signed)
|
||||
return new BitVecExpr(this, Native.Z3_mk_fpa_to_sbv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
|
||||
else
|
||||
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ubv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a floating-point term into a real-numbered term.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of the floating-poiunt term t into a
|
||||
/// real number. Note that this type of conversion will often result in non-linear
|
||||
/// constraints over real terms.
|
||||
/// </remarks>
|
||||
/// <param name="t">FloatingPoint term</param>
|
||||
public RealExpr MkFPToReal(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<RealExpr>() != null);
|
||||
return new RealExpr(this, Native.Z3_mk_fpa_to_real(this.nCtx, t.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Z3-specific extensions
|
||||
/// <summary>
|
||||
/// Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
/// <param name="t">FloatingPoint term.</param>
|
||||
public BitVecExpr MkFPToIEEEBV(FPExpr t)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
|
||||
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ieee_bv(this.nCtx, t.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Produces a term that represents the conversion of sig * 2^exp into a
|
||||
/// floating-point term of sort s. If necessary, the result will be rounded
|
||||
/// according to rounding mode rm.
|
||||
/// </remarks>
|
||||
/// <param name="rm">RoundingMode term.</param>
|
||||
/// <param name="exp">Exponent term of Int sort.</param>
|
||||
/// <param name="sig">Significand term of Real sort.</param>
|
||||
/// <param name="s">FloatingPoint sort.</param>
|
||||
public BitVecExpr MkFPToFP(FPRMExpr rm, IntExpr exp, RealExpr sig, FPSort s)
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
|
||||
return new BitVecExpr(this, Native.Z3_mk_fpa_to_fp_int_real(this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
#endregion // Floating-point Arithmetic
|
||||
|
||||
#region Miscellaneous
|
||||
/// <summary>
|
||||
|
@ -3488,17 +4287,7 @@ namespace Microsoft.Z3
|
|||
public ParamDescrs SimplifyParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(this, Native.Z3_simplify_get_param_descrs(nCtx)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable/disable printing of warning messages to the console.
|
||||
/// </summary>
|
||||
/// <remarks>Note that this function is static and effects the behaviour of
|
||||
/// all contexts globally.</remarks>
|
||||
public static void ToggleWarningMessages(bool enabled)
|
||||
{
|
||||
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Error Handling
|
||||
|
@ -3597,36 +4386,95 @@ namespace Microsoft.Z3
|
|||
}
|
||||
|
||||
readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
|
||||
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue();
|
||||
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue();
|
||||
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue();
|
||||
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue();
|
||||
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue();
|
||||
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue();
|
||||
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue();
|
||||
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue();
|
||||
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue();
|
||||
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue();
|
||||
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue();
|
||||
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue();
|
||||
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue();
|
||||
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue();
|
||||
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue(10);
|
||||
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue(10);
|
||||
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue(10);
|
||||
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue(10);
|
||||
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue(10);
|
||||
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue(10);
|
||||
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue(10);
|
||||
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue(10);
|
||||
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue(10);
|
||||
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue(10);
|
||||
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue(10);
|
||||
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue(10);
|
||||
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(10);
|
||||
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(10);
|
||||
|
||||
internal AST.DecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
|
||||
internal ASTMap.DecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
|
||||
internal ASTVector.DecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
|
||||
internal ApplyResult.DecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
|
||||
internal FuncInterp.Entry.DecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
|
||||
internal FuncInterp.DecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
|
||||
internal Goal.DecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
|
||||
internal Model.DecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
|
||||
internal Params.DecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
|
||||
internal ParamDescrs.DecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
|
||||
internal Probe.DecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
|
||||
internal Solver.DecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
|
||||
internal Statistics.DecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
|
||||
internal Tactic.DecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
|
||||
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
||||
/// <summary>
|
||||
/// AST DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// ASTMap DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// ASTVector DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// ApplyResult DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// FuncEntry DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// FuncInterp DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Goal DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Model DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Params DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// ParamDescrs DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Probe DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Solver DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Statistics DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Tactic DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// FixedPoint DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
||||
|
||||
|
||||
internal long refCount = 0;
|
||||
|
|
|
@ -32,11 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for DatatypeExpr </summary>
|
||||
internal protected DatatypeExpr(Context ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal DatatypeExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,16 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the inx'th constant declaration in the enumeration.
|
||||
/// </summary>
|
||||
/// <param name="inx"></param>
|
||||
/// <returns></returns>
|
||||
public FuncDecl ConstDecl(uint inx)
|
||||
{
|
||||
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, inx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constants in the enumeration.
|
||||
/// </summary>
|
||||
|
@ -61,7 +71,17 @@ namespace Microsoft.Z3
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test predicates for the constants in the enumeration.
|
||||
/// Retrieves the inx'th constant in the enumeration.
|
||||
/// </summary>
|
||||
/// <param name="inx"></param>
|
||||
/// <returns></returns>
|
||||
public Expr Const(uint inx)
|
||||
{
|
||||
return Context.MkApp(ConstDecl(inx));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The test predicates (recognizers) for the constants in the enumeration.
|
||||
/// </summary>
|
||||
public FuncDecl[] TesterDecls
|
||||
{
|
||||
|
@ -76,9 +96,19 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the inx'th tester/recognizer declaration in the enumeration.
|
||||
/// </summary>
|
||||
/// <param name="inx"></param>
|
||||
/// <returns></returns>
|
||||
public FuncDecl TesterDecl(uint inx)
|
||||
{
|
||||
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, inx));
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
||||
: base(ctx)
|
||||
: base(ctx, IntPtr.Zero)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
|
|
|
@ -1311,7 +1311,7 @@ namespace Microsoft.Z3
|
|||
|
||||
#region Relational Terms
|
||||
/// <summary>
|
||||
/// Indicates whether the term is of an array sort.
|
||||
/// Indicates whether the term is of relation sort.
|
||||
/// </summary>
|
||||
public bool IsRelation
|
||||
{
|
||||
|
@ -1448,6 +1448,281 @@ namespace Microsoft.Z3
|
|||
/// Indicates whether the term is a less than predicate over a finite domain.
|
||||
/// </summary>
|
||||
public bool IsFiniteDomainLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
|
||||
#endregion
|
||||
|
||||
#region Floating-point terms
|
||||
/// <summary>
|
||||
/// Indicates whether the terms is of floating-point sort.
|
||||
/// </summary>
|
||||
public bool IsFP
|
||||
{
|
||||
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FLOATING_POINT_SORT; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the terms is of floating-point rounding mode sort.
|
||||
/// </summary>
|
||||
public bool IsFPRM
|
||||
{
|
||||
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_ROUNDING_MODE_SORT; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point numeral
|
||||
/// </summary>
|
||||
public bool IsFPNumeral { get { return IsFP && IsNumeral; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point rounding mode numeral
|
||||
/// </summary>
|
||||
public bool IsFPRMNumeral { get { return IsFPRM && IsNumeral; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
/// </summary>
|
||||
public bool IsFPRMRoundNearestTiesToEven{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
/// </summary>
|
||||
public bool IsFPRMRoundNearestTiesToAway{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
/// </summary>
|
||||
public bool IsFPRMRoundTowardNegative{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
/// </summary>
|
||||
public bool IsFPRMRoundTowardPositive{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
/// </summary>
|
||||
public bool IsFPRMRoundTowardZero{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
/// </summary>
|
||||
public bool IsFPRMExprRNE{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
/// </summary>
|
||||
public bool IsFPRMExprRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
/// </summary>
|
||||
public bool IsFPRMExprRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
/// </summary>
|
||||
public bool IsFPRMExprRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
/// </summary>
|
||||
public bool IsFPRMExprRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point rounding mode numeral
|
||||
/// </summary>
|
||||
public bool IsFPRMExpr {
|
||||
get {
|
||||
return IsApp &&
|
||||
(FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY||
|
||||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN ||
|
||||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE ||
|
||||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE ||
|
||||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point +oo
|
||||
/// </summary>
|
||||
public bool IsFPPlusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_INF; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point -oo
|
||||
/// </summary>
|
||||
public bool IsFPMinusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_INF; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point NaN
|
||||
/// </summary>
|
||||
public bool IsFPNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NAN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point +zero
|
||||
/// </summary>
|
||||
public bool IsFPPlusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point -zero
|
||||
/// </summary>
|
||||
public bool IsFPMinusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point addition term
|
||||
/// </summary>
|
||||
public bool IsFPAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ADD; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point subtraction term
|
||||
/// </summary>
|
||||
public bool IsFPSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SUB; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point negation term
|
||||
/// </summary>
|
||||
public bool IsFPNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NEG; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point multiplication term
|
||||
/// </summary>
|
||||
public bool IsFPMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MUL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point divison term
|
||||
/// </summary>
|
||||
public bool IsFPDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_DIV; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point remainder term
|
||||
/// </summary>
|
||||
public bool IsFPRem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_REM; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point term absolute value term
|
||||
/// </summary>
|
||||
public bool IsFPAbs { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ABS; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point minimum term
|
||||
/// </summary>
|
||||
public bool IsFPMin { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MIN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point maximum term
|
||||
/// </summary>
|
||||
public bool IsFPMax { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MAX; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point fused multiply-add term
|
||||
/// </summary>
|
||||
public bool IsFPFMA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FMA; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point square root term
|
||||
/// </summary>
|
||||
public bool IsFPSqrt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SQRT; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point roundToIntegral term
|
||||
/// </summary>
|
||||
public bool IsFPRoundToIntegral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ROUND_TO_INTEGRAL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point equality term
|
||||
/// </summary>
|
||||
public bool IsFPEq { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_EQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point less-than term
|
||||
/// </summary>
|
||||
public bool IsFPLt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LT; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point greater-than term
|
||||
/// </summary>
|
||||
public bool IsFPGt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GT; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point less-than or equal term
|
||||
/// </summary>
|
||||
public bool IsFPLe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point greater-than or erqual term
|
||||
/// </summary>
|
||||
public bool IsFPGe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isNaN predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NAN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isInf predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisInf { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_INF; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isZero predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isNormal term
|
||||
/// </summary>
|
||||
public bool IsFPisNormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NORMAL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isSubnormal predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisSubnormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_SUBNORMAL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isNegative predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NEGATIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point isPositive predicate term
|
||||
/// </summary>
|
||||
public bool IsFPisPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_POSITIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point constructor term
|
||||
/// </summary>
|
||||
public bool IsFPFP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FP; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion term
|
||||
/// </summary>
|
||||
public bool IsFPToFp { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion from unsigned bit-vector term
|
||||
/// </summary>
|
||||
public bool IsFPToFpUnsigned { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP_UNSIGNED; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion to unsigned bit-vector term
|
||||
/// </summary>
|
||||
public bool IsFPToUBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_UBV; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion to signed bit-vector term
|
||||
/// </summary>
|
||||
public bool IsFPToSBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_SBV; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion to real term
|
||||
/// </summary>
|
||||
public bool IsFPToReal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_REAL; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is a floating-point conversion to IEEE-754 bit-vector term
|
||||
/// </summary>
|
||||
public bool IsFPToIEEEBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_IEEE_BV; } }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
@ -1489,10 +1764,6 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Constructor for Expr
|
||||
/// </summary>
|
||||
internal protected Expr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
/// <summary>
|
||||
/// Constructor for Expr
|
||||
/// </summary>
|
||||
internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
#if DEBUG
|
||||
|
@ -1541,7 +1812,9 @@ namespace Microsoft.Z3
|
|||
{
|
||||
case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMNum(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1552,7 +1825,9 @@ namespace Microsoft.Z3
|
|||
case Z3_sort_kind.Z3_REAL_SORT: return new RealExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMExpr(ctx, obj);
|
||||
}
|
||||
|
||||
return new Expr(ctx, obj);
|
||||
|
|
52
src/api/dotnet/FPExpr.cs
Normal file
52
src/api/dotnet/FPExpr.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPExpr.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Floating Point Expressions
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// FloatingPoint Expressions
|
||||
/// </summary>
|
||||
public class FPExpr : Expr
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of exponent bits.
|
||||
/// </summary>
|
||||
public uint EBits { get { return ((FPSort)Sort).EBits; } }
|
||||
|
||||
/// <summary>
|
||||
/// The number of significand bits.
|
||||
/// </summary>
|
||||
public uint SBits { get { return ((FPSort)Sort).EBits; } }
|
||||
|
||||
#region Internal
|
||||
/// <summary> Constructor for FPExpr </summary>
|
||||
internal FPExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
103
src/api/dotnet/FPNum.cs
Normal file
103
src/api/dotnet/FPNum.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPNum.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Floating Point Numerals
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// FloatiungPoint Numerals
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class FPNum : FPExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the sign of a floating-point literal
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Remarks: returns true if the numeral is negative
|
||||
/// </remarks>
|
||||
public bool Sign
|
||||
{
|
||||
get
|
||||
{
|
||||
int res = 0;
|
||||
if (Native.Z3_fpa_get_numeral_sign(Context.nCtx, NativeObject, ref res) == 0)
|
||||
throw new Z3Exception("Sign is not a Boolean value");
|
||||
return res != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The significand value of a floating-point numeral as a string
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The significand s is always 0 < s < 2.0; the resulting string is long
|
||||
/// enough to represent the real significand precisely.
|
||||
/// </remarks>
|
||||
public string Significand
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.Z3_fpa_get_numeral_significand_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the exponent value of a floating-point numeral as a string
|
||||
/// </summary>
|
||||
public string Exponent
|
||||
{
|
||||
get
|
||||
{
|
||||
return Native.Z3_fpa_get_numeral_exponent_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the exponent value of a floating-point numeral as a signed 64-bit integer
|
||||
/// </summary>
|
||||
public Int64 ExponentInt64
|
||||
{
|
||||
get
|
||||
{
|
||||
Int64 result = 0;
|
||||
if (Native.Z3_fpa_get_numeral_exponent_int64(Context.nCtx, NativeObject, ref result) == 0)
|
||||
throw new Z3Exception("Exponent is not a 64 bit integer");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal FPNum(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
}
|
42
src/api/dotnet/FPRMExpr.cs
Normal file
42
src/api/dotnet/FPRMExpr.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMExpr.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Floating Point Expressions over Rounding Modes
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// FloatingPoint RoundingMode Expressions
|
||||
/// </summary>
|
||||
public class FPRMExpr : Expr
|
||||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for FPRMExpr </summary>
|
||||
internal FPRMExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
100
src/api/dotnet/FPRMNum.cs
Normal file
100
src/api/dotnet/FPRMNum.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMExpr.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Floating Point Rounding Mode Numerals
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Floating-point rounding mode numerals
|
||||
/// </summary>
|
||||
public class FPRMNum : FPRMExpr
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
/// </summary>
|
||||
public bool isRoundNearestTiesToEven { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
/// </summary>
|
||||
public bool isRNE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
/// </summary>
|
||||
public bool isRoundNearestTiesToAway { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
/// </summary>
|
||||
public bool isRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
/// </summary>
|
||||
public bool isRoundTowardPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
/// </summary>
|
||||
public bool isRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
/// </summary>
|
||||
public bool isRoundTowardNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
/// </summary>
|
||||
public bool isRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
/// </summary>
|
||||
public bool isRoundTowardZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
/// </summary>
|
||||
public bool isRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the numeral.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
#region Internal
|
||||
/// <summary> Constructor for FPRMNum </summary>
|
||||
internal FPRMNum(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
43
src/api/dotnet/FPRMSort.cs
Normal file
43
src/api/dotnet/FPRMSort.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMSort.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Rounding Mode Sort
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The FloatingPoint RoundingMode sort
|
||||
/// </summary>
|
||||
public class FPRMSort : Sort
|
||||
{
|
||||
#region Internal
|
||||
internal FPRMSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal FPRMSort(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_fpa_rounding_mode_sort(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
52
src/api/dotnet/FPSort.cs
Normal file
52
src/api/dotnet/FPSort.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPSort.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Floating Point Sorts
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// FloatingPoint sort
|
||||
/// </summary>
|
||||
public class FPSort : Sort
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of exponent bits.
|
||||
/// </summary>
|
||||
public uint EBits { get { return Native.Z3_fpa_get_ebits(Context.nCtx, NativeObject); } }
|
||||
|
||||
/// <summary>
|
||||
/// The number of significand bits.
|
||||
/// </summary>
|
||||
public uint SBits { get { return Native.Z3_fpa_get_sbits(Context.nCtx, NativeObject); } }
|
||||
|
||||
#region Internal
|
||||
internal FPSort(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal FPSort(Context ctx, uint ebits, uint sbits)
|
||||
: base(ctx, Native.Z3_mk_fpa_sort(ctx.nCtx, ebits, sbits))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -335,12 +335,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_fixedpoint_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_fixedpoint_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -91,12 +91,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_entry_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_entry_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
@ -197,12 +199,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_interp_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_func_interp_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,40 @@ namespace Microsoft.Z3
|
|||
public static void ResetParameters()
|
||||
{
|
||||
Native.Z3_global_param_reset_all();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable/disable printing of warning messages to the console.
|
||||
/// </summary>
|
||||
/// <remarks>Note that this function is static and effects the behaviour of
|
||||
/// all contexts globally.</remarks>
|
||||
public static void ToggleWarningMessages(bool enabled)
|
||||
{
|
||||
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It is a NOOP otherwise.
|
||||
/// </remarks>
|
||||
/// <param name="tag">trace tag</param>
|
||||
public static void EnableTrace(string tag)
|
||||
{
|
||||
Native.Z3_enable_trace(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It is a NOOP otherwise.
|
||||
/// </remarks>
|
||||
/// <param name="tag">trace tag</param>
|
||||
public static void DisableTrace(string tag)
|
||||
{
|
||||
Native.Z3_disable_trace(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,12 +219,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_goal_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_goal_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,11 @@ using System.Diagnostics.Contracts;
|
|||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// DecRefQueue interface
|
||||
/// </summary>
|
||||
[ContractClass(typeof(DecRefQueueContracts))]
|
||||
internal abstract class IDecRefQueue
|
||||
public abstract class IDecRefQueue
|
||||
{
|
||||
#region Object invariant
|
||||
|
||||
|
@ -38,14 +41,25 @@ namespace Microsoft.Z3
|
|||
|
||||
#endregion
|
||||
|
||||
readonly internal protected Object m_lock = new Object();
|
||||
readonly internal protected List<IntPtr> m_queue = new List<IntPtr>();
|
||||
internal const uint m_move_limit = 1024;
|
||||
readonly private Object m_lock = new Object();
|
||||
readonly private List<IntPtr> m_queue = new List<IntPtr>();
|
||||
private uint m_move_limit;
|
||||
|
||||
public abstract void IncRef(Context ctx, IntPtr obj);
|
||||
public abstract void DecRef(Context ctx, IntPtr obj);
|
||||
internal IDecRefQueue(uint move_limit = 1024)
|
||||
{
|
||||
m_move_limit = move_limit;
|
||||
}
|
||||
|
||||
public void IncAndClear(Context ctx, IntPtr o)
|
||||
/// <summary>
|
||||
/// Sets the limit on numbers of objects that are kept back at GC collection.
|
||||
/// </summary>
|
||||
/// <param name="l"></param>
|
||||
public void SetLimit(uint l) { m_move_limit = l; }
|
||||
|
||||
internal abstract void IncRef(Context ctx, IntPtr obj);
|
||||
internal abstract void DecRef(Context ctx, IntPtr obj);
|
||||
|
||||
internal void IncAndClear(Context ctx, IntPtr o)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
|
@ -53,7 +67,7 @@ namespace Microsoft.Z3
|
|||
if (m_queue.Count >= m_move_limit) Clear(ctx);
|
||||
}
|
||||
|
||||
public void Add(IntPtr o)
|
||||
internal void Add(IntPtr o)
|
||||
{
|
||||
if (o == IntPtr.Zero) return;
|
||||
|
||||
|
@ -63,7 +77,7 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
public void Clear(Context ctx)
|
||||
internal void Clear(Context ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
|
||||
|
@ -79,12 +93,12 @@ namespace Microsoft.Z3
|
|||
[ContractClassFor(typeof(IDecRefQueue))]
|
||||
abstract class DecRefQueueContracts : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*++
|
||||
Copyright (<c>) 2012 Microsoft Corporation
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
|
@ -32,11 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for IntExpr </summary>
|
||||
internal protected IntExpr(Context ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal IntExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.Z3
|
|||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the C/C++ API, which is well documented.</remarks>
|
||||
[ContractVerification(true)]
|
||||
class InterpolationContext : Context
|
||||
public class InterpolationContext : Context
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
@ -47,7 +47,7 @@ namespace Microsoft.Z3
|
|||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_get_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
public Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
{
|
||||
Contract.Requires(pf != null);
|
||||
Contract.Requires(pat != null);
|
||||
|
@ -72,7 +72,7 @@ namespace Microsoft.Z3
|
|||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_compute_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
|
||||
public Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
|
||||
{
|
||||
Contract.Requires(pat != null);
|
||||
Contract.Requires(p != null);
|
||||
|
|
|
@ -113,9 +113,9 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
#region Internal
|
||||
internal ListSort(Context ctx, Symbol name, Sort elemSort)
|
||||
: base(ctx)
|
||||
: base(ctx, IntPtr.Zero)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<OutputPath>..\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>..\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
|
||||
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
|
||||
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
|
||||
|
@ -254,7 +254,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
|
||||
<OutputPath>..\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
|
@ -266,7 +266,7 @@
|
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
<DocumentationFile>..\x86\Debug\Microsoft.Z3.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
|
@ -342,6 +342,12 @@
|
|||
<Compile Include="ConstructorList.cs" />
|
||||
<Compile Include="DatatypeExpr.cs" />
|
||||
<Compile Include="DatatypeSort.cs" />
|
||||
<Compile Include="FPExpr.cs" />
|
||||
<Compile Include="FPNum.cs" />
|
||||
<Compile Include="FPRMExpr.cs" />
|
||||
<Compile Include="FPRMNum.cs" />
|
||||
<Compile Include="FPRMSort.cs" />
|
||||
<Compile Include="FPSort.cs" />
|
||||
<Compile Include="Global.cs" />
|
||||
<Compile Include="IDecRefQueue.cs" />
|
||||
<Compile Include="Enumerations.cs" />
|
||||
|
|
|
@ -291,12 +291,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_model_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_model_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -87,12 +87,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ using System.Diagnostics.Contracts;
|
|||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
||||
/// A Params objects represents a configuration in the form of Symbol/value pairs.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Params : Z3Object
|
||||
|
@ -140,12 +140,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_params_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_params_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -73,12 +73,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_probe_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_probe_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace Microsoft.Z3
|
|||
#region Internal
|
||||
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
|
||||
internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
|
||||
: base(ctx)
|
||||
: base(ctx, IntPtr.Zero)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(sorts != null);
|
||||
|
@ -203,7 +203,7 @@ namespace Microsoft.Z3
|
|||
|
||||
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
|
||||
internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
|
||||
: base(ctx)
|
||||
: base(ctx, IntPtr.Zero)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(body != null);
|
||||
|
|
9
src/api/dotnet/Readme.NET35
Normal file
9
src/api/dotnet/Readme.NET35
Normal file
|
@ -0,0 +1,9 @@
|
|||
The default Z3 bindings for .NET are built for the .NET framework version 4.
|
||||
Should the need arise, it is also possible to build them for .NET 3.5; the
|
||||
instructions are as follows:
|
||||
|
||||
In the project properties of Microsoft.Z3.csproj:
|
||||
- Under 'Application': Change Target framework to .NET Framework 3.5
|
||||
- Under 'Build': Add FRAMEWORK_LT_4 to the condidional compilation symbols
|
||||
- Remove the reference to System.Numerics
|
||||
- Install the NuGet Package "Microsoft Code Contracts for Net3.5"
|
|
@ -32,11 +32,6 @@ namespace Microsoft.Z3
|
|||
{
|
||||
#region Internal
|
||||
/// <summary> Constructor for RealExpr </summary>
|
||||
internal protected RealExpr(Context ctx)
|
||||
: base(ctx)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal RealExpr(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
|
|
|
@ -328,12 +328,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_solver_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -116,8 +116,7 @@ namespace Microsoft.Z3
|
|||
#region Internal
|
||||
/// <summary>
|
||||
/// Sort constructor
|
||||
/// </summary>
|
||||
internal protected Sort(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
|
||||
/// </summary>
|
||||
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
#if DEBUG
|
||||
|
@ -146,6 +145,8 @@ namespace Microsoft.Z3
|
|||
case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPSort(ctx, obj);
|
||||
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMSort(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown sort kind");
|
||||
}
|
||||
|
|
|
@ -189,12 +189,14 @@ namespace Microsoft.Z3
|
|||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_stats_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_stats_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -112,14 +112,19 @@ namespace Microsoft.Z3
|
|||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DecRefQueue
|
||||
/// </summary>
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public override void IncRef(Context ctx, IntPtr obj)
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_tactic_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public override void DecRef(Context ctx, IntPtr obj)
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_tactic_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Microsoft.Z3
|
|||
|
||||
#region Internal
|
||||
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
|
||||
: base(ctx)
|
||||
: base(ctx, IntPtr.Zero)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
Contract.Requires(name != null);
|
||||
|
|
|
@ -28,7 +28,8 @@ public class AST extends Z3Object
|
|||
|
||||
/**
|
||||
* Object comparison.
|
||||
* <param name="o">another AST</param>
|
||||
*
|
||||
* @param o another AST
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
@ -46,12 +47,14 @@ public class AST extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Object Comparison. <param name="other">Another AST</param>
|
||||
* Object Comparison.
|
||||
* @param other Another AST
|
||||
*
|
||||
* @return Negative if the object should be sorted before <paramref
|
||||
* name="other"/>, positive if after else zero.
|
||||
* @return Negative if the object should be sorted before {@code other},
|
||||
* positive if after else zero.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public int compareTo(Object other) throws Z3Exception
|
||||
public int compareTo(Object other)
|
||||
{
|
||||
if (other == null)
|
||||
return 1;
|
||||
|
@ -90,19 +93,21 @@ public class AST extends Z3Object
|
|||
|
||||
/**
|
||||
* A unique identifier for the AST (unique among all ASTs).
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public int getId() throws Z3Exception
|
||||
public int getId()
|
||||
{
|
||||
return Native.getAstId(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates (copies) the AST to the Context <paramref name="ctx"/>. <param
|
||||
* name="ctx">A context</param>
|
||||
* Translates (copies) the AST to the Context {@code ctx}.
|
||||
* @param ctx A context
|
||||
*
|
||||
* @return A copy of the AST which is associated with <paramref name="ctx"/>
|
||||
* @return A copy of the AST which is associated with {@code ctx}
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public AST translate(Context ctx) throws Z3Exception
|
||||
public AST translate(Context ctx)
|
||||
{
|
||||
|
||||
if (getContext() == ctx)
|
||||
|
@ -114,8 +119,9 @@ public class AST extends Z3Object
|
|||
|
||||
/**
|
||||
* The kind of the AST.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public Z3_ast_kind getASTKind() throws Z3Exception
|
||||
public Z3_ast_kind getASTKind()
|
||||
{
|
||||
return Z3_ast_kind.fromInt(Native.getAstKind(getContext().nCtx(),
|
||||
getNativeObject()));
|
||||
|
@ -123,8 +129,10 @@ public class AST extends Z3Object
|
|||
|
||||
/**
|
||||
* Indicates whether the AST is an Expr
|
||||
* @throws Z3Exception on error
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public boolean isExpr() throws Z3Exception
|
||||
public boolean isExpr()
|
||||
{
|
||||
switch (getASTKind())
|
||||
{
|
||||
|
@ -140,24 +148,30 @@ public class AST extends Z3Object
|
|||
|
||||
/**
|
||||
* Indicates whether the AST is an application
|
||||
* @return a boolean
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public boolean isApp() throws Z3Exception
|
||||
public boolean isApp()
|
||||
{
|
||||
return this.getASTKind() == Z3_ast_kind.Z3_APP_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a BoundVariable
|
||||
* Indicates whether the AST is a BoundVariable.
|
||||
* @return a boolean
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public boolean isVar() throws Z3Exception
|
||||
public boolean isVar()
|
||||
{
|
||||
return this.getASTKind() == Z3_ast_kind.Z3_VAR_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a Quantifier
|
||||
* @return a boolean
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public boolean isQuantifier() throws Z3Exception
|
||||
public boolean isQuantifier()
|
||||
{
|
||||
return this.getASTKind() == Z3_ast_kind.Z3_QUANTIFIER_AST;
|
||||
}
|
||||
|
@ -165,7 +179,7 @@ public class AST extends Z3Object
|
|||
/**
|
||||
* Indicates whether the AST is a Sort
|
||||
**/
|
||||
public boolean isSort() throws Z3Exception
|
||||
public boolean isSort()
|
||||
{
|
||||
return this.getASTKind() == Z3_ast_kind.Z3_SORT_AST;
|
||||
}
|
||||
|
@ -173,7 +187,7 @@ public class AST extends Z3Object
|
|||
/**
|
||||
* Indicates whether the AST is a FunctionDeclaration
|
||||
**/
|
||||
public boolean isFuncDecl() throws Z3Exception
|
||||
public boolean isFuncDecl()
|
||||
{
|
||||
return this.getASTKind() == Z3_ast_kind.Z3_FUNC_DECL_AST;
|
||||
}
|
||||
|
@ -195,7 +209,7 @@ public class AST extends Z3Object
|
|||
/**
|
||||
* A string representation of the AST in s-expression notation.
|
||||
**/
|
||||
public String getSExpr() throws Z3Exception
|
||||
public String getSExpr()
|
||||
{
|
||||
return Native.astToString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
@ -205,34 +219,30 @@ public class AST extends Z3Object
|
|||
super(ctx);
|
||||
}
|
||||
|
||||
AST(Context ctx, long obj) throws Z3Exception
|
||||
AST(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void incRef(long o) throws Z3Exception
|
||||
void incRef(long o)
|
||||
{
|
||||
// Console.WriteLine("AST IncRef()");
|
||||
if (getContext() == null)
|
||||
throw new Z3Exception("inc() called on null context");
|
||||
if (o == 0)
|
||||
throw new Z3Exception("inc() called on null AST");
|
||||
getContext().ast_DRQ().incAndClear(getContext(), o);
|
||||
if (getContext() == null || o == 0)
|
||||
return;
|
||||
getContext().getASTDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o) throws Z3Exception
|
||||
void decRef(long o)
|
||||
{
|
||||
// Console.WriteLine("AST DecRef()");
|
||||
if (getContext() == null)
|
||||
throw new Z3Exception("dec() called on null context");
|
||||
if (o == 0)
|
||||
throw new Z3Exception("dec() called on null AST");
|
||||
getContext().ast_DRQ().add(o);
|
||||
if (getContext() == null || o == 0)
|
||||
return;
|
||||
getContext().getASTDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
|
||||
static AST create(Context ctx, long obj) throws Z3Exception
|
||||
static AST create(Context ctx, long obj)
|
||||
{
|
||||
switch (Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)))
|
||||
{
|
||||
|
|
|
@ -19,6 +19,16 @@ package com.microsoft.z3;
|
|||
|
||||
class ASTDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public ASTDecRefQueue()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ASTDecRefQueue(int move_limit)
|
||||
{
|
||||
super(move_limit);
|
||||
}
|
||||
|
||||
protected void incRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -23,13 +23,13 @@ package com.microsoft.z3;
|
|||
class ASTMap extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Checks whether the map contains the key <paramref name="k"/>. <param
|
||||
* name="k">An AST</param>
|
||||
* Checks whether the map contains the key {@code k}.
|
||||
* @param k An AST
|
||||
*
|
||||
* @return True if <paramref name="k"/> is a key in the map, false
|
||||
* @return True if {@code k} is a key in the map, false
|
||||
* otherwise.
|
||||
**/
|
||||
public boolean contains(AST k) throws Z3Exception
|
||||
public boolean contains(AST k)
|
||||
{
|
||||
|
||||
return Native.astMapContains(getContext().nCtx(), getNativeObject(),
|
||||
|
@ -37,23 +37,25 @@ class ASTMap extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds the value associated with the key <paramref name="k"/>. <remarks>
|
||||
* This function signs an error when <paramref name="k"/> is not a key in
|
||||
* the map. </remarks> <param name="k">An AST</param>
|
||||
* Finds the value associated with the key {@code k}.
|
||||
* Remarks: This function signs an error when {@code k} is not a key in
|
||||
* the map.
|
||||
* @param k An AST
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public AST find(AST k) throws Z3Exception
|
||||
public AST find(AST k)
|
||||
{
|
||||
return new AST(getContext(), Native.astMapFind(getContext().nCtx(),
|
||||
getNativeObject(), k.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores or replaces a new key/value pair in the map. <param name="k">The
|
||||
* key AST</param> <param name="v">The value AST</param>
|
||||
* Stores or replaces a new key/value pair in the map.
|
||||
* @param k The key AST
|
||||
* @param v The value AST
|
||||
**/
|
||||
public void insert(AST k, AST v) throws Z3Exception
|
||||
public void insert(AST k, AST v)
|
||||
{
|
||||
|
||||
Native.astMapInsert(getContext().nCtx(), getNativeObject(), k.getNativeObject(),
|
||||
|
@ -61,19 +63,18 @@ class ASTMap extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Erases the key <paramref name="k"/> from the map. <param name="k">An
|
||||
* AST</param>
|
||||
* Erases the key {@code k} from the map.
|
||||
* @param k An AST
|
||||
**/
|
||||
public void erase(AST k) throws Z3Exception
|
||||
public void erase(AST k)
|
||||
{
|
||||
|
||||
Native.astMapErase(getContext().nCtx(), getNativeObject(), k.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all keys from the map.
|
||||
**/
|
||||
public void reset() throws Z3Exception
|
||||
public void reset()
|
||||
{
|
||||
Native.astMapReset(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ class ASTMap extends Z3Object
|
|||
/**
|
||||
* The size of the map
|
||||
**/
|
||||
public int size() throws Z3Exception
|
||||
public int size()
|
||||
{
|
||||
return Native.astMapSize(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
@ -91,7 +92,7 @@ class ASTMap extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ASTVector getKeys() throws Z3Exception
|
||||
public ASTVector getKeys()
|
||||
{
|
||||
return new ASTVector(getContext(), Native.astMapKeys(getContext().nCtx(),
|
||||
getNativeObject()));
|
||||
|
@ -111,25 +112,25 @@ class ASTMap extends Z3Object
|
|||
}
|
||||
}
|
||||
|
||||
ASTMap(Context ctx, long obj) throws Z3Exception
|
||||
ASTMap(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ASTMap(Context ctx) throws Z3Exception
|
||||
ASTMap(Context ctx)
|
||||
{
|
||||
super(ctx, Native.mkAstMap(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void incRef(long o) throws Z3Exception
|
||||
void incRef(long o)
|
||||
{
|
||||
getContext().astmap_DRQ().incAndClear(getContext(), o);
|
||||
getContext().getASTMapDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o) throws Z3Exception
|
||||
void decRef(long o)
|
||||
{
|
||||
getContext().astmap_DRQ().add(o);
|
||||
getContext().getASTMapDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,31 +20,32 @@ package com.microsoft.z3;
|
|||
/**
|
||||
* Vectors of ASTs.
|
||||
**/
|
||||
class ASTVector extends Z3Object
|
||||
public class ASTVector extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The size of the vector
|
||||
**/
|
||||
public int size() throws Z3Exception
|
||||
public int size()
|
||||
{
|
||||
return Native.astVectorSize(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the i-th object in the vector. <remarks>May throw an
|
||||
* IndexOutOfBoundsException when <paramref name="i"/> is out of
|
||||
* range.</remarks> <param name="i">Index</param>
|
||||
* Retrieves the i-th object in the vector.
|
||||
* Remarks: May throw an {@code IndexOutOfBoundsException} when
|
||||
* {@code i} is out of range.
|
||||
* @param i Index
|
||||
*
|
||||
* @return An AST
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public AST get(int i) throws Z3Exception
|
||||
public AST get(int i)
|
||||
{
|
||||
return new AST(getContext(), Native.astVectorGet(getContext().nCtx(),
|
||||
getNativeObject(), i));
|
||||
}
|
||||
|
||||
public void set(int i, AST value) throws Z3Exception
|
||||
public void set(int i, AST value)
|
||||
{
|
||||
|
||||
Native.astVectorSet(getContext().nCtx(), getNativeObject(), i,
|
||||
|
@ -52,31 +53,32 @@ class ASTVector extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Resize the vector to <paramref name="newSize"/>. <param
|
||||
* name="newSize">The new size of the vector.</param>
|
||||
* Resize the vector to {@code newSize}.
|
||||
* @param newSize The new size of the vector.
|
||||
**/
|
||||
public void resize(int newSize) throws Z3Exception
|
||||
public void resize(int newSize)
|
||||
{
|
||||
Native.astVectorResize(getContext().nCtx(), getNativeObject(), newSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the AST <paramref name="a"/> to the back of the vector. The size is
|
||||
* increased by 1. <param name="a">An AST</param>
|
||||
* Add the AST {@code a} to the back of the vector. The size is
|
||||
* increased by 1.
|
||||
* @param a An AST
|
||||
**/
|
||||
public void push(AST a) throws Z3Exception
|
||||
public void push(AST a)
|
||||
{
|
||||
Native.astVectorPush(getContext().nCtx(), getNativeObject(), a.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all ASTs in the vector to <paramref name="ctx"/>. <param
|
||||
* name="ctx">A context</param>
|
||||
* Translates all ASTs in the vector to {@code ctx}.
|
||||
* @param ctx A context
|
||||
*
|
||||
* @return A new ASTVector
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ASTVector translate(Context ctx) throws Z3Exception
|
||||
public ASTVector translate(Context ctx)
|
||||
{
|
||||
return new ASTVector(getContext(), Native.astVectorTranslate(getContext()
|
||||
.nCtx(), getNativeObject(), ctx.nCtx()));
|
||||
|
@ -96,25 +98,25 @@ class ASTVector extends Z3Object
|
|||
}
|
||||
}
|
||||
|
||||
ASTVector(Context ctx, long obj) throws Z3Exception
|
||||
ASTVector(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ASTVector(Context ctx) throws Z3Exception
|
||||
ASTVector(Context ctx)
|
||||
{
|
||||
super(ctx, Native.mkAstVector(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void incRef(long o) throws Z3Exception
|
||||
void incRef(long o)
|
||||
{
|
||||
getContext().astvector_DRQ().incAndClear(getContext(), o);
|
||||
getContext().getASTVectorDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o) throws Z3Exception
|
||||
void decRef(long o)
|
||||
{
|
||||
getContext().astvector_DRQ().add(o);
|
||||
getContext().getASTVectorDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,15 @@ public class AlgebraicNum extends ArithExpr
|
|||
{
|
||||
/**
|
||||
* Return a upper bound for a given real algebraic number. The interval
|
||||
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision">the
|
||||
* precision of the result</param>
|
||||
* isolating the number is smaller than 1/10^{@code precision}.
|
||||
*
|
||||
* @see Expr#isAlgebraicNumber
|
||||
* @param precision the precision of the result
|
||||
*
|
||||
* @return A numeral Expr of sort Real
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public RatNum toUpper(int precision) throws Z3Exception
|
||||
public RatNum toUpper(int precision)
|
||||
{
|
||||
|
||||
return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
|
||||
|
@ -39,12 +41,15 @@ public class AlgebraicNum extends ArithExpr
|
|||
|
||||
/**
|
||||
* Return a lower bound for the given real algebraic number. The interval
|
||||
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision"></param>
|
||||
* isolating the number is smaller than 1/10^{@code precision}.
|
||||
*
|
||||
* @see Expr#isAlgebraicNumber
|
||||
* @param precision precision
|
||||
*
|
||||
* @return A numeral Expr of sort Real
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public RatNum toLower(int precision) throws Z3Exception
|
||||
public RatNum toLower(int precision)
|
||||
{
|
||||
|
||||
return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
|
||||
|
@ -52,17 +57,20 @@ public class AlgebraicNum extends ArithExpr
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation in decimal notation. <remarks>The result
|
||||
* has at most <paramref name="precision"/> decimal places.</remarks>
|
||||
* Returns a string representation in decimal notation.
|
||||
* Remarks: The result has at most {@code precision} decimal places.
|
||||
* @param precision precision
|
||||
* @return String
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public String toDecimal(int precision) throws Z3Exception
|
||||
public String toDecimal(int precision)
|
||||
{
|
||||
|
||||
return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
|
||||
precision);
|
||||
}
|
||||
|
||||
AlgebraicNum(Context ctx, long obj) throws Z3Exception
|
||||
AlgebraicNum(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ApplyResult extends Z3Object
|
|||
/**
|
||||
* The number of Subgoals.
|
||||
**/
|
||||
public int getNumSubgoals() throws Z3Exception
|
||||
public int getNumSubgoals()
|
||||
{
|
||||
return Native.applyResultGetNumSubgoals(getContext().nCtx(),
|
||||
getNativeObject());
|
||||
|
@ -37,7 +37,7 @@ public class ApplyResult extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Goal[] getSubgoals() throws Z3Exception
|
||||
public Goal[] getSubgoals()
|
||||
{
|
||||
int n = getNumSubgoals();
|
||||
Goal[] res = new Goal[n];
|
||||
|
@ -48,13 +48,13 @@ public class ApplyResult extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a model for the subgoal <paramref name="i"/> into a model for the
|
||||
* original goal <code>g</code>, that the ApplyResult was obtained from.
|
||||
* Convert a model for the subgoal {@code i} into a model for the
|
||||
* original goal {@code g}, that the ApplyResult was obtained from.
|
||||
*
|
||||
* @return A model for <code>g</code>
|
||||
* @return A model for {@code g}
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Model convertModel(int i, Model m) throws Z3Exception
|
||||
public Model convertModel(int i, Model m)
|
||||
{
|
||||
return new Model(getContext(),
|
||||
Native.applyResultConvertModel(getContext().nCtx(), getNativeObject(), i, m.getNativeObject()));
|
||||
|
@ -74,20 +74,20 @@ public class ApplyResult extends Z3Object
|
|||
}
|
||||
}
|
||||
|
||||
ApplyResult(Context ctx, long obj) throws Z3Exception
|
||||
ApplyResult(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void incRef(long o) throws Z3Exception
|
||||
void incRef(long o)
|
||||
{
|
||||
getContext().applyResult_DRQ().incAndClear(getContext(), o);
|
||||
getContext().getApplyResultDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o) throws Z3Exception
|
||||
void decRef(long o)
|
||||
{
|
||||
getContext().applyResult_DRQ().add(o);
|
||||
getContext().getApplyResultDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,16 @@ package com.microsoft.z3;
|
|||
|
||||
class ApplyResultDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public ApplyResultDecRefQueue()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ApplyResultDecRefQueue(int move_limit)
|
||||
{
|
||||
super(move_limit);
|
||||
}
|
||||
|
||||
protected void incRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -22,16 +22,11 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class ArithExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for ArithExpr </summary>
|
||||
**/
|
||||
protected ArithExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
ArithExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
/**
|
||||
* Constructor for ArithExpr
|
||||
**/
|
||||
ArithExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class ArithSort extends Sort
|
||||
{
|
||||
ArithSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
ArithSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,16 +23,11 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class ArrayExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for ArrayExpr </summary>
|
||||
**/
|
||||
protected ArrayExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
ArrayExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
/**
|
||||
* Constructor for ArrayExpr
|
||||
**/
|
||||
ArrayExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,34 +22,38 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class ArraySort extends Sort
|
||||
{
|
||||
/**
|
||||
* The domain of the array sort.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort getDomain() throws Z3Exception
|
||||
{
|
||||
return Sort.create(getContext(),
|
||||
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
/**
|
||||
* The domain of the array sort.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
* @return a sort
|
||||
**/
|
||||
public Sort getDomain()
|
||||
{
|
||||
return Sort.create(getContext(),
|
||||
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of the array sort.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort getRange() throws Z3Exception
|
||||
{
|
||||
return Sort.create(getContext(),
|
||||
Native.getArraySortRange(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
/**
|
||||
* The range of the array sort.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
* @return a sort
|
||||
**/
|
||||
public Sort getRange()
|
||||
{
|
||||
return Sort.create(getContext(),
|
||||
Native.getArraySortRange(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
ArraySort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
ArraySort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ArraySort(Context ctx, Sort domain, Sort range) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.getNativeObject(),
|
||||
range.getNativeObject()));
|
||||
}
|
||||
ArraySort(Context ctx, Sort domain, Sort range)
|
||||
{
|
||||
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.getNativeObject(),
|
||||
range.getNativeObject()));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,6 +19,16 @@ package com.microsoft.z3;
|
|||
|
||||
class ASTMapDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public ASTMapDecRefQueue()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ASTMapDecRefQueue(int move_limit)
|
||||
{
|
||||
super(move_limit);
|
||||
}
|
||||
|
||||
protected void incRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -19,6 +19,16 @@ package com.microsoft.z3;
|
|||
|
||||
class ASTVectorDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public ASTVectorDecRefQueue()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ASTVectorDecRefQueue(int move_limit)
|
||||
{
|
||||
super(move_limit);
|
||||
}
|
||||
|
||||
protected void incRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -23,25 +23,22 @@ package com.microsoft.z3;
|
|||
public class BitVecExpr extends Expr
|
||||
{
|
||||
|
||||
/**
|
||||
* The size of the sort of a bit-vector term.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int getSortSize() throws Z3Exception
|
||||
{
|
||||
return ((BitVecSort) getSort()).getSize();
|
||||
}
|
||||
/**
|
||||
* The size of the sort of a bit-vector term.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
* @return an int
|
||||
**/
|
||||
public int getSortSize()
|
||||
{
|
||||
return ((BitVecSort) getSort()).getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for BitVecExpr </summary>
|
||||
**/
|
||||
BitVecExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
BitVecExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
/**
|
||||
* Constructor for BitVecExpr
|
||||
**/
|
||||
BitVecExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class BitVecNum extends BitVecExpr
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int getInt() throws Z3Exception
|
||||
public int getInt()
|
||||
{
|
||||
Native.IntPtr res = new Native.IntPtr();
|
||||
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
|
@ -42,7 +42,7 @@ public class BitVecNum extends BitVecExpr
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public long getLong() throws Z3Exception
|
||||
public long getLong()
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
|
@ -72,7 +72,7 @@ public class BitVecNum extends BitVecExpr
|
|||
}
|
||||
}
|
||||
|
||||
BitVecNum(Context ctx, long obj) throws Z3Exception
|
||||
BitVecNum(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
|
|
@ -22,16 +22,18 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class BitVecSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The size of the bit-vector sort.
|
||||
**/
|
||||
public int getSize() throws Z3Exception
|
||||
{
|
||||
return Native.getBvSortSize(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
/**
|
||||
* The size of the bit-vector sort.
|
||||
* @throws Z3Exception on error
|
||||
* @return an int
|
||||
**/
|
||||
public int getSize()
|
||||
{
|
||||
return Native.getBvSortSize(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
BitVecSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
BitVecSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,20 +22,21 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class BoolExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for BoolExpr </summary>
|
||||
**/
|
||||
protected BoolExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
/**
|
||||
* Constructor for BoolExpr
|
||||
**/
|
||||
protected BoolExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for BoolExpr </summary>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
BoolExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
/**
|
||||
* Constructor for BoolExpr
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
BoolExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class BoolSort extends Sort
|
||||
{
|
||||
BoolSort(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }}
|
||||
BoolSort(Context ctx) throws Z3Exception { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
|
||||
BoolSort(Context ctx, long obj) { super(ctx, obj); { }}
|
||||
BoolSort(Context ctx) { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
|
||||
};
|
||||
|
|
|
@ -22,48 +22,53 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class Constructor extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The number of fields of the constructor.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int getNumFields() throws Z3Exception
|
||||
{
|
||||
return n;
|
||||
}
|
||||
/**
|
||||
* The number of fields of the constructor.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
* @return an int
|
||||
**/
|
||||
public int getNumFields()
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the constructor.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl ConstructorDecl() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
Native.LongPtr tester = new Native.LongPtr();
|
||||
long[] accessors = new long[n];
|
||||
/**
|
||||
* The function declaration of the constructor.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl ConstructorDecl()
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
Native.LongPtr tester = new Native.LongPtr();
|
||||
long[] accessors = new long[n];
|
||||
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
|
||||
return new FuncDecl(getContext(), constructor.value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the tester.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl getTesterDecl() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
/**
|
||||
* The function declaration of the tester.
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl getTesterDecl()
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
Native.LongPtr tester = new Native.LongPtr();
|
||||
long[] accessors = new long[n];
|
||||
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
|
||||
return new FuncDecl(getContext(), tester.value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations of the accessors
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] getAccessorDecls() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
/**
|
||||
* The function declarations of the accessors
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[] getAccessorDecls()
|
||||
{
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
Native.LongPtr tester = new Native.LongPtr();
|
||||
long[] accessors = new long[n];
|
||||
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
|
||||
|
@ -71,39 +76,40 @@ public class Constructor extends Z3Object
|
|||
for (int i = 0; i < n; i++)
|
||||
t[i] = new FuncDecl(getContext(), accessors[i]);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize() throws Z3Exception
|
||||
{
|
||||
Native.delConstructor(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
/**
|
||||
* Destructor.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
protected void finalize()
|
||||
{
|
||||
Native.delConstructor(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
private int n = 0;
|
||||
private int n = 0;
|
||||
|
||||
Constructor(Context ctx, Symbol name, Symbol recognizer,
|
||||
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
Constructor(Context ctx, Symbol name, Symbol recognizer,
|
||||
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
||||
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
n = AST.arrayLength(fieldNames);
|
||||
n = AST.arrayLength(fieldNames);
|
||||
|
||||
if (n != AST.arrayLength(sorts))
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sorts");
|
||||
if (sortRefs != null && sortRefs.length != n)
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sort refs");
|
||||
if (n != AST.arrayLength(sorts))
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sorts");
|
||||
if (sortRefs != null && sortRefs.length != n)
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sort refs");
|
||||
|
||||
if (sortRefs == null)
|
||||
sortRefs = new int[n];
|
||||
if (sortRefs == null)
|
||||
sortRefs = new int[n];
|
||||
|
||||
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
|
||||
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
|
||||
Sort.arrayToNative(sorts), sortRefs));
|
||||
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
|
||||
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
|
||||
Sort.arrayToNative(sorts), sortRefs));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,25 +22,26 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class ConstructorList extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize() throws Z3Exception
|
||||
{
|
||||
Native.delConstructorList(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
/**
|
||||
* Destructor.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
protected void finalize()
|
||||
{
|
||||
Native.delConstructorList(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
ConstructorList(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, Constructor[] constructors) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
ConstructorList(Context ctx, Constructor[] constructors)
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
setNativeObject(Native.mkConstructorList(getContext().nCtx(),
|
||||
(int) constructors.length,
|
||||
Constructor.arrayToNative(constructors)));
|
||||
}
|
||||
setNativeObject(Native.mkConstructorList(getContext().nCtx(),
|
||||
(int) constructors.length,
|
||||
Constructor.arrayToNative(constructors)));
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,16 +22,11 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class DatatypeExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for DatatypeExpr </summary>
|
||||
**/
|
||||
protected DatatypeExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
DatatypeExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
/**
|
||||
* Constructor for DatatypeExpr
|
||||
**/
|
||||
DatatypeExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,81 +22,86 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class DatatypeSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The number of constructors of the datatype sort.
|
||||
**/
|
||||
public int getNumConstructors() throws Z3Exception
|
||||
{
|
||||
return Native.getDatatypeSortNumConstructors(getContext().nCtx(),
|
||||
getNativeObject());
|
||||
}
|
||||
/**
|
||||
* The number of constructors of the datatype sort.
|
||||
* @throws Z3Exception on error
|
||||
* @return an int
|
||||
**/
|
||||
public int getNumConstructors()
|
||||
{
|
||||
return Native.getDatatypeSortNumConstructors(getContext().nCtx(),
|
||||
getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] getConstructors() throws Z3Exception
|
||||
{
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(
|
||||
getContext().nCtx(), getNativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* The constructors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[] getConstructors()
|
||||
{
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(
|
||||
getContext().nCtx(), getNativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The recognizers.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] getRecognizers() throws Z3Exception
|
||||
{
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(
|
||||
getContext().nCtx(), getNativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* The recognizers.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[] getRecognizers()
|
||||
{
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(
|
||||
getContext().nCtx(), getNativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor accessors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[][] getAccessors() throws Z3Exception
|
||||
{
|
||||
/**
|
||||
* The constructor accessors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[][] getAccessors()
|
||||
{
|
||||
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[][] res = new FuncDecl[n][];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
FuncDecl fd = new FuncDecl(getContext(),
|
||||
Native.getDatatypeSortConstructor(getContext().nCtx(),
|
||||
getNativeObject(), i));
|
||||
int ds = fd.getDomainSize();
|
||||
FuncDecl[] tmp = new FuncDecl[ds];
|
||||
for (int j = 0; j < ds; j++)
|
||||
tmp[j] = new FuncDecl(getContext(),
|
||||
Native.getDatatypeSortConstructorAccessor(getContext()
|
||||
.nCtx(), getNativeObject(), i, j));
|
||||
res[i] = tmp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
int n = getNumConstructors();
|
||||
FuncDecl[][] res = new FuncDecl[n][];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
FuncDecl fd = new FuncDecl(getContext(),
|
||||
Native.getDatatypeSortConstructor(getContext().nCtx(),
|
||||
getNativeObject(), i));
|
||||
int ds = fd.getDomainSize();
|
||||
FuncDecl[] tmp = new FuncDecl[ds];
|
||||
for (int j = 0; j < ds; j++)
|
||||
tmp[j] = new FuncDecl(getContext(),
|
||||
Native.getDatatypeSortConstructorAccessor(getContext()
|
||||
.nCtx(), getNativeObject(), i, j));
|
||||
res[i] = tmp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
DatatypeSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
DatatypeSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkDatatype(ctx.nCtx(), name.getNativeObject(),
|
||||
(int) constructors.length, arrayToNative(constructors)));
|
||||
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
|
||||
|
||||
{
|
||||
super(ctx, Native.mkDatatype(ctx.nCtx(), name.getNativeObject(),
|
||||
(int) constructors.length, arrayToNative(constructors)));
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,51 +22,83 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class EnumSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The function declarations of the constants in the enumeration.
|
||||
**/
|
||||
public FuncDecl[] getConstDecls() throws Z3Exception
|
||||
{
|
||||
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
|
||||
/**
|
||||
* The function declarations of the constants in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[] getConstDecls()
|
||||
{
|
||||
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
|
||||
FuncDecl[] t = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), i));
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the inx'th constant declaration in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl getConstDecl(int inx)
|
||||
{
|
||||
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), inx));
|
||||
}
|
||||
|
||||
/**
|
||||
* The constants in the enumeration.
|
||||
**/
|
||||
public Expr[] getConsts() throws Z3Exception
|
||||
{
|
||||
FuncDecl[] cds = getConstDecls();
|
||||
/**
|
||||
* The constants in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
* @return an Expr[]
|
||||
**/
|
||||
public Expr[] getConsts()
|
||||
{
|
||||
FuncDecl[] cds = getConstDecls();
|
||||
Expr[] t = new Expr[cds.length];
|
||||
for (int i = 0; i < t.length; i++)
|
||||
t[i] = getContext().mkApp(cds[i]);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the inx'th constant in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
* @return an Expr
|
||||
**/
|
||||
public Expr getConst(int inx)
|
||||
{
|
||||
return getContext().mkApp(getConstDecl(inx));
|
||||
}
|
||||
|
||||
/**
|
||||
* The test predicates for the constants in the enumeration.
|
||||
**/
|
||||
public FuncDecl[] getTesterDecls() throws Z3Exception
|
||||
{
|
||||
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
|
||||
/**
|
||||
* The test predicates for the constants in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl[] getTesterDecls()
|
||||
{
|
||||
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
|
||||
FuncDecl[] t = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), i));
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the inx'th tester/recognizer declaration in the enumeration.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public FuncDecl getTesterDecl(int inx)
|
||||
{
|
||||
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), inx));
|
||||
}
|
||||
|
||||
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
||||
{
|
||||
super(ctx, 0);
|
||||
|
||||
int n = enumNames.length;
|
||||
long[] n_constdecls = new long[n];
|
||||
long[] n_testers = new long[n];
|
||||
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
|
||||
name.getNativeObject(), (int) n, Symbol.arrayToNative(enumNames),
|
||||
n_constdecls, n_testers));
|
||||
}
|
||||
int n = enumNames.length;
|
||||
long[] n_constdecls = new long[n];
|
||||
long[] n_testers = new long[n];
|
||||
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
|
||||
name.getNativeObject(), (int) n, Symbol.arrayToNative(enumNames),
|
||||
n_constdecls, n_testers));
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
41
src/api/java/FPExpr.java
Normal file
41
src/api/java/FPExpr.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* FloatingPoint Expressions
|
||||
*/
|
||||
public class FPExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* The number of exponent bits.
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public int getEBits() { return ((FPSort)getSort()).getEBits(); }
|
||||
|
||||
/**
|
||||
* The number of significand bits.
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public int getSBits() { return ((FPSort)getSort()).getSBits(); }
|
||||
|
||||
public FPExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
}
|
84
src/api/java/FPNum.java
Normal file
84
src/api/java/FPNum.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* FloatingPoint Numerals
|
||||
*/
|
||||
public class FPNum extends FPExpr
|
||||
{
|
||||
/**
|
||||
* Retrieves the sign of a floating-point literal
|
||||
* Remarks: returns true if the numeral is negative
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean getSign() {
|
||||
Native.IntPtr res = new Native.IntPtr();
|
||||
if (Native.fpaGetNumeralSign(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Sign is not a Boolean value");
|
||||
return res.value != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The significand value of a floating-point numeral as a string
|
||||
* Remarks: The significand s is always 0 < s < 2.0; the resulting string is long
|
||||
* enough to represent the real significand precisely.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public String getSignificand() {
|
||||
return Native.fpaGetNumeralSignificandString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exponent value of a floating-point numeral as a string
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public String getExponent() {
|
||||
return Native.fpaGetNumeralExponentString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exponent value of a floating-point numeral as a signed 64-bit integer
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public long getExponentInt64() {
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.fpaGetNumeralExponentInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Exponent is not a 64 bit integer");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
public FPNum(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the numeral.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
29
src/api/java/FPRMExpr.java
Normal file
29
src/api/java/FPRMExpr.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* FloatingPoint RoundingMode Expressions
|
||||
*/
|
||||
public class FPRMExpr extends Expr
|
||||
{
|
||||
public FPRMExpr(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
}
|
90
src/api/java/FPRMNum.java
Normal file
90
src/api/java/FPRMNum.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMNum.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.Z3_decl_kind;
|
||||
|
||||
/**
|
||||
* FloatingPoint RoundingMode Numerals
|
||||
*/
|
||||
public class FPRMNum extends FPRMExpr {
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
* @throws Z3Exception
|
||||
* **/
|
||||
public boolean isRoundNearestTiesToEven() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRNE() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRoundNearestTiesToAway() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRNA() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRoundTowardPositive() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardPositive
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRTP() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRoundTowardNegative() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardNegative
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRTN() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRoundTowardZero() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; }
|
||||
|
||||
/**
|
||||
* Indicates whether the term is the floating-point rounding numeral roundTowardZero
|
||||
* @throws Z3Exception
|
||||
*/
|
||||
public boolean isRTZ() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; }
|
||||
|
||||
public FPRMNum(Context ctx, long obj) {
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
}
|
35
src/api/java/FPRMSort.java
Normal file
35
src/api/java/FPRMSort.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPRMExpr.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* The FloatingPoint RoundingMode sort
|
||||
**/
|
||||
public class FPRMSort extends Sort
|
||||
{
|
||||
|
||||
public FPRMSort(Context ctx)
|
||||
{
|
||||
super(ctx, Native.mkFpaRoundingModeSort(ctx.nCtx()));
|
||||
}
|
||||
|
||||
public FPRMSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
}
|
49
src/api/java/FPSort.java
Normal file
49
src/api/java/FPSort.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FPSort.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2013-06-10
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* A FloatingPoint sort
|
||||
**/
|
||||
public class FPSort extends Sort
|
||||
{
|
||||
|
||||
public FPSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
public FPSort(Context ctx, int ebits, int sbits)
|
||||
{
|
||||
super(ctx, Native.mkFpaSort(ctx.nCtx(), ebits, sbits));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of exponent bits.
|
||||
*/
|
||||
public int getEBits() {
|
||||
return Native.fpaGetEbits(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of significand bits.
|
||||
*/
|
||||
public int getSBits() {
|
||||
return Native.fpaGetEbits(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
}
|
|
@ -22,24 +22,25 @@ package com.microsoft.z3;
|
|||
**/
|
||||
public class FiniteDomainSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The size of the finite domain sort.
|
||||
**/
|
||||
public long getSize() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
Native.getFiniteDomainSortSize(getContext().nCtx(), getNativeObject(), res);
|
||||
return res.value;
|
||||
}
|
||||
/**
|
||||
* The size of the finite domain sort.
|
||||
* @throws Z3Exception on error
|
||||
**/
|
||||
public long getSize()
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
Native.getFiniteDomainSortSize(getContext().nCtx(), getNativeObject(), res);
|
||||
return res.value;
|
||||
}
|
||||
|
||||
FiniteDomainSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
FiniteDomainSort(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
FiniteDomainSort(Context ctx, Symbol name, long size) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.getNativeObject(),
|
||||
size));
|
||||
}
|
||||
FiniteDomainSort(Context ctx, Symbol name, long size)
|
||||
{
|
||||
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.getNativeObject(),
|
||||
size));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class Fixedpoint extends Z3Object
|
|||
/**
|
||||
* A string that describes all available fixedpoint solver parameters.
|
||||
**/
|
||||
public String getHelp() throws Z3Exception
|
||||
public String getHelp()
|
||||
{
|
||||
return Native.fixedpointGetHelp(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void setParameters(Params value) throws Z3Exception
|
||||
public void setParameters(Params value)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(value);
|
||||
|
@ -51,7 +51,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ParamDescrs getParameterDescriptions() throws Z3Exception
|
||||
public ParamDescrs getParameterDescriptions()
|
||||
{
|
||||
return new ParamDescrs(getContext(), Native.fixedpointGetParamDescrs(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
|
@ -62,7 +62,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void add(BoolExpr ... constraints) throws Z3Exception
|
||||
public void add(BoolExpr ... constraints)
|
||||
{
|
||||
getContext().checkContextMatch(constraints);
|
||||
for (BoolExpr a : constraints)
|
||||
|
@ -77,7 +77,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void registerRelation(FuncDecl f) throws Z3Exception
|
||||
public void registerRelation(FuncDecl f)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(f);
|
||||
|
@ -90,7 +90,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void addRule(BoolExpr rule, Symbol name) throws Z3Exception
|
||||
public void addRule(BoolExpr rule, Symbol name)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(rule);
|
||||
|
@ -103,7 +103,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void addFact(FuncDecl pred, int ... args) throws Z3Exception
|
||||
public void addFact(FuncDecl pred, int ... args)
|
||||
{
|
||||
getContext().checkContextMatch(pred);
|
||||
Native.fixedpointAddFact(getContext().nCtx(), getNativeObject(),
|
||||
|
@ -119,7 +119,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Status query(BoolExpr query) throws Z3Exception
|
||||
public Status query(BoolExpr query)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(query);
|
||||
|
@ -144,7 +144,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Status query(FuncDecl[] relations) throws Z3Exception
|
||||
public Status query(FuncDecl[] relations)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(relations);
|
||||
|
@ -163,19 +163,22 @@ public class Fixedpoint extends Z3Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a backtracking point. <seealso cref="Pop"/>
|
||||
* Creates a backtracking point.
|
||||
* @see pop
|
||||
**/
|
||||
public void push() throws Z3Exception
|
||||
public void push()
|
||||
{
|
||||
Native.fixedpointPush(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Backtrack one backtracking point. <remarks>Note that an exception is
|
||||
* thrown if Pop is called without a corresponding <code>Push</code>
|
||||
* </remarks> <seealso cref="Push"/>
|
||||
* Backtrack one backtracking point.
|
||||
* Remarks: Note that an exception is thrown if {@code pop}
|
||||
* is called without a corresponding {@code push}
|
||||
*
|
||||
* @see push
|
||||
**/
|
||||
public void pop() throws Z3Exception
|
||||
public void pop()
|
||||
{
|
||||
Native.fixedpointPop(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
@ -185,7 +188,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void updateRule(BoolExpr rule, Symbol name) throws Z3Exception
|
||||
public void updateRule(BoolExpr rule, Symbol name)
|
||||
{
|
||||
|
||||
getContext().checkContextMatch(rule);
|
||||
|
@ -199,7 +202,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr getAnswer() throws Z3Exception
|
||||
public Expr getAnswer()
|
||||
{
|
||||
long ans = Native.fixedpointGetAnswer(getContext().nCtx(), getNativeObject());
|
||||
return (ans == 0) ? null : Expr.create(getContext(), ans);
|
||||
|
@ -208,7 +211,7 @@ public class Fixedpoint extends Z3Object
|
|||
/**
|
||||
* Retrieve explanation why fixedpoint engine returned status Unknown.
|
||||
**/
|
||||
public String getReasonUnknown() throws Z3Exception
|
||||
public String getReasonUnknown()
|
||||
{
|
||||
|
||||
return Native.fixedpointGetReasonUnknown(getContext().nCtx(),
|
||||
|
@ -218,7 +221,7 @@ public class Fixedpoint extends Z3Object
|
|||
/**
|
||||
* Retrieve the number of levels explored for a given predicate.
|
||||
**/
|
||||
public int getNumLevels(FuncDecl predicate) throws Z3Exception
|
||||
public int getNumLevels(FuncDecl predicate)
|
||||
{
|
||||
return Native.fixedpointGetNumLevels(getContext().nCtx(), getNativeObject(),
|
||||
predicate.getNativeObject());
|
||||
|
@ -229,7 +232,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr getCoverDelta(int level, FuncDecl predicate) throws Z3Exception
|
||||
public Expr getCoverDelta(int level, FuncDecl predicate)
|
||||
{
|
||||
long res = Native.fixedpointGetCoverDelta(getContext().nCtx(),
|
||||
getNativeObject(), level, predicate.getNativeObject());
|
||||
|
@ -241,7 +244,7 @@ public class Fixedpoint extends Z3Object
|
|||
* at <tt>level</tt>.
|
||||
**/
|
||||
public void addCover(int level, FuncDecl predicate, Expr property)
|
||||
throws Z3Exception
|
||||
|
||||
{
|
||||
Native.fixedpointAddCover(getContext().nCtx(), getNativeObject(), level,
|
||||
predicate.getNativeObject(), property.getNativeObject());
|
||||
|
@ -266,7 +269,7 @@ public class Fixedpoint extends Z3Object
|
|||
* Instrument the Datalog engine on which table representation to use for
|
||||
* recursive predicate.
|
||||
**/
|
||||
public void setPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception
|
||||
public void setPredicateRepresentation(FuncDecl f, Symbol[] kinds)
|
||||
{
|
||||
|
||||
Native.fixedpointSetPredicateRepresentation(getContext().nCtx(),
|
||||
|
@ -278,7 +281,7 @@ public class Fixedpoint extends Z3Object
|
|||
/**
|
||||
* Convert benchmark given as set of axioms, rules and queries to a string.
|
||||
**/
|
||||
public String toString(BoolExpr[] queries) throws Z3Exception
|
||||
public String toString(BoolExpr[] queries)
|
||||
{
|
||||
|
||||
return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
|
||||
|
@ -290,7 +293,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] getRules() throws Z3Exception
|
||||
public BoolExpr[] getRules()
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(
|
||||
|
@ -307,7 +310,7 @@ public class Fixedpoint extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] getAssertions() throws Z3Exception
|
||||
public BoolExpr[] getAssertions()
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(
|
||||
|
@ -319,25 +322,25 @@ public class Fixedpoint extends Z3Object
|
|||
return res;
|
||||
}
|
||||
|
||||
Fixedpoint(Context ctx, long obj) throws Z3Exception
|
||||
Fixedpoint(Context ctx, long obj)
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Fixedpoint(Context ctx) throws Z3Exception
|
||||
Fixedpoint(Context ctx)
|
||||
{
|
||||
super(ctx, Native.mkFixedpoint(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void incRef(long o) throws Z3Exception
|
||||
void incRef(long o)
|
||||
{
|
||||
getContext().fixedpoint_DRQ().incAndClear(getContext(), o);
|
||||
getContext().getFixedpointDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o) throws Z3Exception
|
||||
void decRef(long o)
|
||||
{
|
||||
getContext().fixedpoint_DRQ().add(o);
|
||||
getContext().getFixedpointDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue