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

Merge branch 'pure' of https://git01.codeplex.com/z3 into contrib

This commit is contained in:
Christoph M. Wintersteiger 2014-10-24 21:17:57 +01:00
commit 6a496a1bfb
560 changed files with 52025 additions and 9358 deletions

3
.gitattributes vendored
View file

@ -1 +1,4 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
src/api/dotnet/Properties/AssemblyInfo.cs text eol=crlf src/api/dotnet/Properties/AssemblyInfo.cs text eol=crlf

5
.gitignore vendored
View file

@ -55,6 +55,8 @@ src/api/api_log_macros.cpp
src/api/dll/api_dll.def src/api/dll/api_dll.def
src/api/dotnet/Enumerations.cs src/api/dotnet/Enumerations.cs
src/api/dotnet/Native.cs src/api/dotnet/Native.cs
src/api/dotnet/Properties/AssemblyInfo.cs
src/api/dotnet/Microsoft.Z3.xml
src/api/python/z3consts.py src/api/python/z3consts.py
src/api/python/z3core.py src/api/python/z3core.py
src/ast/pattern/database.h src/ast/pattern/database.h
@ -62,3 +64,6 @@ src/util/version.h
src/api/java/Native.cpp src/api/java/Native.cpp
src/api/java/Native.java src/api/java/Native.java
src/api/java/enumerations/*.java src/api/java/enumerations/*.java
*.bak
doc/api
doc/code

View file

@ -3,6 +3,15 @@ RELEASE NOTES
Version 4.3.2 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.
- 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
as well as the following Codeplex users that either reported bugs or took part in discussions:
xor88, parno, gario, Bauna, GManNickG, hanwentao, dinu09, fhowar, Cici, chinissai, barak_cohen, tvalentyn, krikunts, sukyoung, daramos, snedunuri, rajtendulkar, sonertari, nick8325, dvitek, amdragon, Beatgodes, dmonniaux, nickolai, DameNingen, mangpo, ttsiodras, blurium, sbrickey, pcodemod, indranilsaha, apanda, hougaardj, yoff, EfForEffort, Ansotegui, scottgw, viorelpreoteasa, idudka, c2855337, gario, jnfoster, omarmrivas, switicus, vosandi, foens, yzwwf, Heizmann, znajem, ilyagri, hougaardj, cliguda, rgrig, 92c849c1ccc707173, edmcman, cipher1024, MichaelvW, hellok, n00b42, ic3guy, Adorf, tvcsantos, zilongwang, Elarnon, immspw, jbridge99, danliew, zverlov, petross, jmh93, dradorf, fniksic, Heyji, cxcfan, henningg, wxlfrank, rvprasad, MovGP0, jackie1015, cowang, ffaghih, sanpra1989, gzchenyin, baitman, xjtulixiangyang, andreis, trucnguyenlam, erizzi, hanhchi, qsp, windypan, vadave, gradanne, SamWot, gsingh93, manjeetdahiya, zverlov, RaLa, and regehr.
- New parameter setting infrastructure. Now, it is possible to set parameter for Z3 internal modules. Several parameter names changed. Execute `z3 -p` for the new parameter list. - New parameter setting infrastructure. Now, it is possible to set parameter for Z3 internal modules. Several parameter names changed. Execute `z3 -p` for the new parameter list.
- Added get_version() and get_version_string() to Z3Py - Added get_version() and get_version_string() to Z3Py

View file

@ -27,6 +27,10 @@ try:
shutil.copyfile('website.dox', 'tmp/website.dox') shutil.copyfile('website.dox', 'tmp/website.dox')
shutil.copyfile('../src/api/python/z3.py', 'tmp/z3py.py') shutil.copyfile('../src/api/python/z3.py', 'tmp/z3py.py')
cleanup_API('../src/api/z3_api.h', 'tmp/z3_api.h') cleanup_API('../src/api/z3_api.h', 'tmp/z3_api.h')
cleanup_API('../src/api/z3_algebraic.h', 'tmp/z3_algebraic.h')
cleanup_API('../src/api/z3_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')
print "Removed annotations from z3_api.h." print "Removed annotations from z3_api.h."
try: try:
@ -38,6 +42,10 @@ try:
exit(1) exit(1)
print "Generated C and .NET API documentation." print "Generated C and .NET API documentation."
os.remove('tmp/z3_api.h') os.remove('tmp/z3_api.h')
os.remove('tmp/z3_algebraic.h')
os.remove('tmp/z3_polynomial.h')
os.remove('tmp/z3_rcf.h')
os.remove('tmp/z3_interp.h')
print "Removed temporary file z3_api.h." print "Removed temporary file z3_api.h."
os.remove('tmp/website.dox') os.remove('tmp/website.dox')
print "Removed temporary file website.dox" print "Removed temporary file website.dox"

View file

@ -15,5 +15,5 @@
- <a class="el" href="class_microsoft_1_1_z3_1_1_context.html">.NET API</a> - <a class="el" href="class_microsoft_1_1_z3_1_1_context.html">.NET API</a>
- <a class="el" href="namespacecom_1_1microsoft_1_1z3.html">Java API</a> - <a class="el" href="namespacecom_1_1microsoft_1_1z3.html">Java API</a>
- <a class="el" href="namespacez3py.html">Python API</a> (also available in <a class="el" href="z3.html">pydoc format</a>). - <a class="el" href="namespacez3py.html">Python API</a> (also available in <a class="el" href="z3.html">pydoc format</a>).
- Try Z3 online at <a href="http://rise4fun.com/z3py">RiSE4Fun</a> using <a href="http://rise4fun.com/z3py">Python</a> or <a href="http://rise4fun.com/z3">SMT 2.0</a>. - Try Z3 online at <a href="http://rise4fun.com/z3">RiSE4Fun</a>.
*/ */

View file

@ -363,7 +363,7 @@ TYPEDEF_HIDES_STRUCT = NO
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols. # corresponding to a cache size of 2^16 = 65536 symbols.
SYMBOL_CACHE_SIZE = 0 # SYMBOL_CACHE_SIZE = 0
# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
@ -708,7 +708,11 @@ INPUT_ENCODING = UTF-8
# *.f90 *.f *.for *.vhd *.vhdl # *.f90 *.f *.for *.vhd *.vhdl
FILE_PATTERNS = website.dox \ FILE_PATTERNS = website.dox \
z3_api.h \ z3_api.h \
z3_algebraic.h \
z3_polynomial.h \
z3_rcf.h \
z3_interp.h \
z3++.h \ z3++.h \
z3py.py \ z3py.py \
ApplyResult.cs \ ApplyResult.cs \
@ -1477,13 +1481,13 @@ XML_OUTPUT = xml
# which can be used by a validating XML parser to check the # which can be used by a validating XML parser to check the
# syntax of the XML files. # syntax of the XML files.
XML_SCHEMA = # XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD, # The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the # which can be used by a validating XML parser to check the
# syntax of the XML files. # syntax of the XML files.
XML_DTD = # XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will # If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting # dump the program listings (including syntax highlighting
@ -1699,7 +1703,7 @@ DOT_NUM_THREADS = 0
# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
# directory containing the font. # directory containing the font.
DOT_FONTNAME = FreeSans # DOT_FONTNAME = FreeSans
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt. # The default size is 10pt.

View file

@ -1,5 +1,7 @@
#include<vector> #include<vector>
#include"z3++.h" #include"z3++.h"
using namespace z3; using namespace z3;
/** /**

View file

@ -474,7 +474,7 @@ namespace test_mapi
cells_c[i] = new BoolExpr[9]; cells_c[i] = new BoolExpr[9];
for (uint j = 0; j < 9; j++) for (uint j = 0; j < 9; j++)
cells_c[i][j] = ctx.MkAnd(ctx.MkLe(ctx.MkInt(1), X[i][j]), cells_c[i][j] = ctx.MkAnd(ctx.MkLe(ctx.MkInt(1), X[i][j]),
ctx.MkLe(X[i][j], ctx.MkInt(9))); ctx.MkLe(X[i][j], ctx.MkInt(9)));
} }
// each row contains a digit at most once // each row contains a digit at most once
@ -485,7 +485,13 @@ namespace test_mapi
// each column contains a digit at most once // each column contains a digit at most once
BoolExpr[] cols_c = new BoolExpr[9]; BoolExpr[] cols_c = new BoolExpr[9];
for (uint j = 0; j < 9; j++) for (uint j = 0; j < 9; j++)
cols_c[j] = ctx.MkDistinct(X[j]); {
IntExpr[] column = new IntExpr[9];
for (uint i = 0; i < 9; i++)
column[i] = X[i][j];
cols_c[j] = ctx.MkDistinct(column);
}
// each 3x3 square contains a digit at most once // each 3x3 square contains a digit at most once
BoolExpr[][] sq_c = new BoolExpr[3][]; BoolExpr[][] sq_c = new BoolExpr[3][];
@ -2087,7 +2093,7 @@ namespace test_mapi
{ {
QuantifierExample3(ctx); QuantifierExample3(ctx);
QuantifierExample4(ctx); QuantifierExample4(ctx);
} }
Log.Close(); Log.Close();
if (Log.isOpen()) if (Log.isOpen())

452
examples/interp/iz3.cpp Executable file
View file

@ -0,0 +1,452 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include "z3.h"
int usage(const char **argv){
std::cerr << "usage: " << argv[0] << " [options] file.smt" << std::endl;
std::cerr << std::endl;
std::cerr << "options:" << std::endl;
std::cerr << " -t,--tree tree interpolation" << std::endl;
std::cerr << " -c,--check check result" << std::endl;
std::cerr << " -p,--profile profile execution" << std::endl;
std::cerr << " -w,--weak weak interpolants" << std::endl;
std::cerr << " -f,--flat ouput flat formulas" << std::endl;
std::cerr << " -o <file> ouput to SMT-LIB file" << std::endl;
std::cerr << " -a,--anon anonymize" << std::endl;
std::cerr << " -s,--simple simple proof mode" << std::endl;
std::cerr << std::endl;
return 1;
}
int main(int argc, const char **argv) {
bool tree_mode = false;
bool check_mode = false;
bool profile_mode = false;
bool incremental_mode = false;
std::string output_file;
bool flat_mode = false;
bool anonymize = false;
bool write = false;
Z3_config cfg = Z3_mk_config();
// Z3_interpolation_options options = Z3_mk_interpolation_options();
Z3_params options = 0;
/* Parse the command line */
int argn = 1;
while(argn < argc-1){
std::string flag = argv[argn];
if(flag[0] == '-'){
if(flag == "-t" || flag == "--tree")
tree_mode = true;
else if(flag == "-c" || flag == "--check")
check_mode = true;
else if(flag == "-p" || flag == "--profile")
profile_mode = true;
#if 0
else if(flag == "-w" || flag == "--weak")
Z3_set_interpolation_option(options,"weak","1");
else if(flag == "--secondary")
Z3_set_interpolation_option(options,"secondary","1");
#endif
else if(flag == "-i" || flag == "--incremental")
incremental_mode = true;
else if(flag == "-o"){
argn++;
if(argn >= argc) return usage(argv);
output_file = argv[argn];
}
else if(flag == "-f" || flag == "--flat")
flat_mode = true;
else if(flag == "-a" || flag == "--anon")
anonymize = true;
else if(flag == "-w" || flag == "--write")
write = true;
else if(flag == "-s" || flag == "--simple")
Z3_set_param_value(cfg,"PREPROCESS","false");
else
return usage(argv);
}
argn++;
}
if(argn != argc-1)
return usage(argv);
const char *filename = argv[argn];
/* Create a Z3 context to contain formulas */
Z3_context ctx = Z3_mk_interpolation_context(cfg);
if(write || anonymize)
Z3_set_ast_print_mode(ctx,Z3_PRINT_SMTLIB2_COMPLIANT);
else if(!flat_mode)
Z3_set_ast_print_mode(ctx,Z3_PRINT_SMTLIB_COMPLIANT);
/* Read an interpolation problem */
unsigned num;
Z3_ast *constraints;
unsigned *parents = 0;
const char *error;
bool ok;
unsigned num_theory;
Z3_ast *theory;
ok = Z3_read_interpolation_problem(ctx, &num, &constraints, tree_mode ? &parents : 0, filename, &error, &num_theory, &theory);
/* If parse failed, print the error message */
if(!ok){
std::cerr << error << "\n";
return 1;
}
/* if we get only one formula, and it is a conjunction, split it into conjuncts. */
if(!tree_mode && num == 1){
Z3_app app = Z3_to_app(ctx,constraints[0]);
Z3_func_decl func = Z3_get_app_decl(ctx,app);
Z3_decl_kind dk = Z3_get_decl_kind(ctx,func);
if(dk == Z3_OP_AND){
int nconjs = Z3_get_app_num_args(ctx,app);
if(nconjs > 1){
std::cout << "Splitting formula into " << nconjs << " conjuncts...\n";
num = nconjs;
constraints = new Z3_ast[num];
for(int k = 0; k < num; k++)
constraints[k] = Z3_get_app_arg(ctx,app,k);
}
}
}
/* Write out anonymized version. */
if(write || anonymize){
#if 0
Z3_anonymize_ast_vector(ctx,num,constraints);
#endif
std::string ofn = output_file.empty() ? "iz3out.smt2" : output_file;
Z3_write_interpolation_problem(ctx, num, constraints, parents, ofn.c_str(), num_theory, theory);
std::cout << "anonymized problem written to " << ofn << "\n";
exit(0);
}
/* Compute an interpolant, or get a model. */
Z3_ast *interpolants = (Z3_ast *)malloc((num-1) * sizeof(Z3_ast));
Z3_model model = 0;
Z3_lbool result;
if(!incremental_mode){
/* In non-incremental mode, we just pass the constraints. */
result = Z3_L_UNDEF; // FIXME: Z3_interpolate(ctx, num, constraints, parents, options, interpolants, &model, 0, false, num_theory, theory);
}
else {
/* This is a somewhat useless demonstration of incremental mode.
Here, we assert the constraints in the context, then pass them to
iZ3 in an array, so iZ3 knows the sequence. Note it's safe to pass
"true", even though we haven't techically asserted if. */
Z3_push(ctx);
std::vector<Z3_ast> asserted(num);
/* We start with nothing asserted. */
for(int i = 0; i < num; i++)
asserted[i] = Z3_mk_true(ctx);
/* Now we assert the constrints one at a time until UNSAT. */
for(int i = 0; i < num; i++){
asserted[i] = constraints[i];
Z3_assert_cnstr(ctx,constraints[i]); // assert one constraint
result = Z3_L_UNDEF; // FIXME: Z3_interpolate(ctx, num, &asserted[0], parents, options, interpolants, &model, 0, true, 0, 0);
if(result == Z3_L_FALSE){
for(unsigned j = 0; j < num-1; j++)
/* Since we want the interpolant formulas to survive a "pop", we
"persist" them here. */
Z3_persist_ast(ctx,interpolants[j],1);
break;
}
}
Z3_pop(ctx,1);
}
switch (result) {
/* If UNSAT, print the interpolants */
case Z3_L_FALSE:
printf("unsat\n");
if(output_file.empty()){
printf("interpolant:\n");
for(int i = 0; i < num-1; i++)
printf("%s\n", Z3_ast_to_string(ctx, interpolants[i]));
}
else {
#if 0
Z3_write_interpolation_problem(ctx,num-1,interpolants,0,output_file.c_str());
printf("interpolant written to %s\n",output_file.c_str());
#endif
}
#if 1
if(check_mode){
std::cout << "Checking interpolant...\n";
bool chk;
chk = Z3_check_interpolant(ctx,num,constraints,parents,interpolants,&error,num_theory,theory);
if(chk)
std::cout << "Interpolant is correct\n";
else {
std::cout << "Interpolant is incorrect\n";
std::cout << error;
return 1;
}
}
#endif
break;
case Z3_L_UNDEF:
printf("fail\n");
break;
case Z3_L_TRUE:
printf("sat\n");
printf("model:\n%s\n", Z3_model_to_string(ctx, model));
break;
}
if(profile_mode)
std::cout << Z3_interpolation_profile(ctx);
/* Delete the model if there is one */
if (model)
Z3_del_model(ctx, model);
/* Delete logical context. */
Z3_del_context(ctx);
free(interpolants);
return 0;
}
#if 0
int test(){
int i;
/* Create a Z3 context to contain formulas */
Z3_config cfg = Z3_mk_config();
Z3_context ctx = iz3_mk_context(cfg);
int num = 2;
Z3_ast *constraints = (Z3_ast *)malloc(num * sizeof(Z3_ast));
#if 1
Z3_sort arr = Z3_mk_array_sort(ctx,Z3_mk_int_sort(ctx),Z3_mk_bool_sort(ctx));
Z3_symbol as = Z3_mk_string_symbol(ctx, "a");
Z3_symbol bs = Z3_mk_string_symbol(ctx, "b");
Z3_symbol xs = Z3_mk_string_symbol(ctx, "x");
Z3_ast a = Z3_mk_const(ctx,as,arr);
Z3_ast b = Z3_mk_const(ctx,bs,arr);
Z3_ast x = Z3_mk_const(ctx,xs,Z3_mk_int_sort(ctx));
Z3_ast c1 = Z3_mk_eq(ctx,a,Z3_mk_store(ctx,b,x,Z3_mk_true(ctx)));
Z3_ast c2 = Z3_mk_not(ctx,Z3_mk_select(ctx,a,x));
#else
Z3_symbol xs = Z3_mk_string_symbol(ctx, "x");
Z3_ast x = Z3_mk_const(ctx,xs,Z3_mk_bool_sort(ctx));
Z3_ast c1 = Z3_mk_eq(ctx,x,Z3_mk_true(ctx));
Z3_ast c2 = Z3_mk_eq(ctx,x,Z3_mk_false(ctx));
#endif
constraints[0] = c1;
constraints[1] = c2;
/* print out the result for grins. */
// Z3_string smtout = Z3_benchmark_to_smtlib_string (ctx, "foo", "QFLIA", "sat", "", num, constraints, Z3_mk_true(ctx));
// Z3_string smtout = Z3_ast_to_string(ctx,constraints[0]);
// Z3_string smtout = Z3_context_to_string(ctx);
// puts(smtout);
iz3_print(ctx,num,constraints,"iZ3temp.smt");
/* Make room for interpolants. */
Z3_ast *interpolants = (Z3_ast *)malloc((num-1) * sizeof(Z3_ast));
/* Make room for the model. */
Z3_model model = 0;
/* Call the prover */
Z3_lbool result = iz3_interpolate(ctx, num, constraints, interpolants, &model);
switch (result) {
/* If UNSAT, print the interpolants */
case Z3_L_FALSE:
printf("unsat, interpolants:\n");
for(i = 0; i < num-1; i++)
printf("%s\n", Z3_ast_to_string(ctx, interpolants[i]));
break;
case Z3_L_UNDEF:
printf("fail\n");
break;
case Z3_L_TRUE:
printf("sat\n");
printf("model:\n%s\n", Z3_model_to_string(ctx, model));
break;
}
/* Delete the model if there is one */
if (model)
Z3_del_model(ctx, model);
/* Delete logical context (note, we call iz3_del_context, not
Z3_del_context */
iz3_del_context(ctx);
return 1;
}
struct z3_error {
Z3_error_code c;
z3_error(Z3_error_code _c) : c(_c) {}
};
extern "C" {
static void throw_z3_error(Z3_error_code c){
throw z3_error(c);
}
}
int main(int argc, const char **argv) {
/* Create a Z3 context to contain formulas */
Z3_config cfg = Z3_mk_config();
Z3_context ctx = iz3_mk_context(cfg);
Z3_set_error_handler(ctx, throw_z3_error);
/* Make some constraints, by parsing an smtlib formatted file given as arg 1 */
try {
Z3_parse_smtlib_file(ctx, argv[1], 0, 0, 0, 0, 0, 0);
}
catch(const z3_error &err){
std::cerr << "Z3 error: " << Z3_get_error_msg(err.c) << "\n";
std::cerr << Z3_get_smtlib_error(ctx) << "\n";
return(1);
}
/* Get the constraints from the parser. */
int num = Z3_get_smtlib_num_formulas(ctx);
if(num == 0){
std::cerr << "iZ3 error: File contains no formulas.\n";
return 1;
}
Z3_ast *constraints = (Z3_ast *)malloc(num * sizeof(Z3_ast));
int i;
for (i = 0; i < num; i++)
constraints[i] = Z3_get_smtlib_formula(ctx, i);
/* if we get only one formula, and it is a conjunction, split it into conjuncts. */
if(num == 1){
Z3_app app = Z3_to_app(ctx,constraints[0]);
Z3_func_decl func = Z3_get_app_decl(ctx,app);
Z3_decl_kind dk = Z3_get_decl_kind(ctx,func);
if(dk == Z3_OP_AND){
int nconjs = Z3_get_app_num_args(ctx,app);
if(nconjs > 1){
std::cout << "Splitting formula into " << nconjs << " conjuncts...\n";
num = nconjs;
constraints = new Z3_ast[num];
for(int k = 0; k < num; k++)
constraints[k] = Z3_get_app_arg(ctx,app,k);
}
}
}
/* print out the result for grins. */
// Z3_string smtout = Z3_benchmark_to_smtlib_string (ctx, "foo", "QFLIA", "sat", "", num, constraints, Z3_mk_true(ctx));
// Z3_string smtout = Z3_ast_to_string(ctx,constraints[0]);
// Z3_string smtout = Z3_context_to_string(ctx);
// puts(smtout);
// iz3_print(ctx,num,constraints,"iZ3temp.smt");
/* Make room for interpolants. */
Z3_ast *interpolants = (Z3_ast *)malloc((num-1) * sizeof(Z3_ast));
/* Make room for the model. */
Z3_model model = 0;
/* Call the prover */
Z3_lbool result = iz3_interpolate(ctx, num, constraints, interpolants, &model);
switch (result) {
/* If UNSAT, print the interpolants */
case Z3_L_FALSE:
printf("unsat, interpolants:\n");
for(i = 0; i < num-1; i++)
printf("%s\n", Z3_ast_to_string(ctx, interpolants[i]));
std::cout << "Checking interpolants...\n";
const char *error;
if(iZ3_check_interpolant(ctx, num, constraints, 0, interpolants, &error))
std::cout << "Interpolant is correct\n";
else {
std::cout << "Interpolant is incorrect\n";
std::cout << error << "\n";
}
break;
case Z3_L_UNDEF:
printf("fail\n");
break;
case Z3_L_TRUE:
printf("sat\n");
printf("model:\n%s\n", Z3_model_to_string(ctx, model));
break;
}
/* Delete the model if there is one */
if (model)
Z3_del_model(ctx, model);
/* Delete logical context (note, we call iz3_del_context, not
Z3_del_context */
iz3_del_context(ctx);
return 0;
}
#endif

View file

@ -1,7 +1,6 @@
### This is work-in-progress and does not work yet. A small example using the Z3 Java bindings.
Small example using the Z3 Java bindings. To build the example, configure Z3 with the --java option to scripts/mk_make.py, build via
To build the example execute
make examples make examples
in the build directory. in the build directory.
@ -11,5 +10,5 @@ which can be run on Windows via
On Linux and FreeBSD, we must use On Linux and FreeBSD, we must use
LD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample LD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample
On OSX, the corresponding option is DYLD_LIBRARY_PATH:
DYLD_LIBRARY_PATH=. java -cp com.microsoft.z3.jar:. JavaExample

18
examples/tptp/README Normal file
View file

@ -0,0 +1,18 @@
TPTP front-end and utilities as a sample using the C++ bindings.
To build the example execute
make examples
in the build directory.
This command will create the executable tptp.
On Windows, you can just execute it.
On OSX and Linux, you must install z3 first using
sudo make install
OR update LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (OSX)
with the build directory. You need that to be able to
find the Z3 shared library.
The sample illustrates using Z3 from the TPTP language.
The TPTP language is documented on http://tptp.org
It also exposes utilities for converting between SMT-LIB
and TPTP format.

2478
examples/tptp/tptp5.cpp Normal file

File diff suppressed because it is too large Load diff

38
examples/tptp/tptp5.h Normal file
View file

@ -0,0 +1,38 @@
#ifndef TPTP5_H_
#define TPTP5_H_
class TreeNode;
#if 0
class named_formulas {
expr_ref_vector m_fmls;
svector<symbol> m_names;
bool m_has_conjecture;
unsigned m_conjecture_index;
public:
named_formulas(ast_manager& m) :
m_fmls(m),
m_has_conjecture(false),
m_conjecture_index(0)
{}
void push_back(expr* fml, char const* name) {
m_fmls.push_back(fml);
m_names.push_back(symbol(name));
}
unsigned size() const { return m_fmls.size(); }
expr*const* c_ptr() const { return m_fmls.c_ptr(); }
expr* operator[](unsigned i) { return m_fmls[i].get(); }
symbol const& name(unsigned i) { return m_names[i]; }
void set_has_conjecture() {
m_has_conjecture = true;
m_conjecture_index = m_fmls.size();
}
bool has_conjecture() const { return m_has_conjecture; }
unsigned conjecture_index() const { return m_conjecture_index; }
};
bool tptp5_parse(ast_manager& m, char const* filename, named_formulas& fmls);
#endif
#endif

2672
examples/tptp/tptp5.lex.cpp Normal file

File diff suppressed because it is too large Load diff

4475
examples/tptp/tptp5.tab.c Normal file

File diff suppressed because it is too large Load diff

138
examples/tptp/tptp5.tab.h Normal file
View file

@ -0,0 +1,138 @@
/* A Bison parser, made by GNU Bison 2.4.2. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
AMPERSAND = 258,
AT_SIGN = 259,
AT_SIGN_MINUS = 260,
AT_SIGN_PLUS = 261,
CARET = 262,
COLON = 263,
COLON_EQUALS = 264,
COMMA = 265,
EQUALS = 266,
EQUALS_GREATER = 267,
EXCLAMATION = 268,
EXCLAMATION_EQUALS = 269,
EXCLAMATION_EXCLAMATION = 270,
EXCLAMATION_GREATER = 271,
LBRKT = 272,
LESS_EQUALS = 273,
LESS_EQUALS_GREATER = 274,
LESS_TILDE_GREATER = 275,
LPAREN = 276,
MINUS = 277,
MINUS_MINUS_GREATER = 278,
PERIOD = 279,
QUESTION = 280,
QUESTION_QUESTION = 281,
QUESTION_STAR = 282,
RBRKT = 283,
RPAREN = 284,
STAR = 285,
TILDE = 286,
TILDE_AMPERSAND = 287,
TILDE_VLINE = 288,
VLINE = 289,
_DLR_cnf = 290,
_DLR_fof = 291,
_DLR_fot = 292,
_DLR_itef = 293,
_DLR_itetf = 294,
_DLR_itett = 295,
_DLR_tff = 296,
_DLR_thf = 297,
_LIT_cnf = 298,
_LIT_fof = 299,
_LIT_include = 300,
_LIT_tff = 301,
_LIT_thf = 302,
arrow = 303,
comment = 304,
comment_line = 305,
decimal = 306,
decimal_exponent = 307,
decimal_fraction = 308,
distinct_object = 309,
dollar_dollar_word = 310,
dollar_word = 311,
dot_decimal = 312,
integer = 313,
less_sign = 314,
lower_word = 315,
plus = 316,
positive_decimal = 317,
rational = 318,
real = 319,
signed_integer = 320,
signed_rational = 321,
signed_real = 322,
single_quoted = 323,
star = 324,
unrecognized = 325,
unsigned_integer = 326,
unsigned_rational = 327,
unsigned_real = 328,
upper_word = 329,
vline = 330
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1685 of yacc.c */
#line 148 "tptp5.y"
int ival; double dval; char* sval; TreeNode* pval;
/* Line 1685 of yacc.c */
#line 130 "tptp5.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;

View file

@ -14,6 +14,7 @@ def init_project_def():
add_lib('polynomial', ['util'], 'math/polynomial') add_lib('polynomial', ['util'], 'math/polynomial')
add_lib('sat', ['util']) add_lib('sat', ['util'])
add_lib('nlsat', ['polynomial', 'sat']) add_lib('nlsat', ['polynomial', 'sat'])
add_lib('hilbert', ['util'], 'math/hilbert')
add_lib('interval', ['util'], 'math/interval') add_lib('interval', ['util'], 'math/interval')
add_lib('realclosure', ['interval'], 'math/realclosure') add_lib('realclosure', ['interval'], 'math/realclosure')
add_lib('subpaving', ['interval'], 'math/subpaving') add_lib('subpaving', ['interval'], 'math/subpaving')
@ -33,34 +34,49 @@ def init_project_def():
add_lib('subpaving_tactic', ['core_tactics', 'subpaving'], 'math/subpaving/tactic') add_lib('subpaving_tactic', ['core_tactics', 'subpaving'], 'math/subpaving/tactic')
add_lib('aig_tactic', ['tactic'], 'tactic/aig') add_lib('aig_tactic', ['tactic'], 'tactic/aig')
add_lib('solver', ['model', 'tactic']) add_lib('solver', ['model', 'tactic'])
add_lib('cmd_context', ['solver', 'rewriter']) add_lib('interp', ['solver'])
add_lib('cmd_context', ['solver', 'rewriter', 'interp'])
add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds') add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds')
add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2') add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2')
add_lib('proof_checker', ['rewriter'], 'ast/proof_checker') add_lib('proof_checker', ['rewriter'], 'ast/proof_checker')
# Simplifier module will be deleted in the future. # Simplifier module will be deleted in the future.
# It has been replaced with rewriter module. # It has been replaced with rewriter module.
add_lib('simplifier', ['rewriter'], 'ast/simplifier') add_lib('simplifier', ['rewriter'], 'ast/simplifier')
add_lib('fpa', ['ast', 'util', 'simplifier'], 'ast/fpa')
add_lib('macros', ['simplifier'], 'ast/macros') add_lib('macros', ['simplifier'], 'ast/macros')
add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern') add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern')
add_lib('bit_blaster', ['rewriter', 'simplifier'], 'ast/rewriter/bit_blaster') add_lib('bit_blaster', ['rewriter', 'simplifier'], 'ast/rewriter/bit_blaster')
add_lib('smt_params', ['ast', 'simplifier', 'pattern', 'bit_blaster'], 'smt/params') add_lib('smt_params', ['ast', 'simplifier', 'pattern', 'bit_blaster'], 'smt/params')
add_lib('proto_model', ['model', 'simplifier', 'smt_params'], 'smt/proto_model') add_lib('proto_model', ['model', 'simplifier', 'smt_params'], 'smt/proto_model')
add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model', add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model',
'substitution', 'grobner', 'euclid', 'proof_checker', 'pattern', 'parser_util']) 'substitution', 'grobner', 'euclid', 'proof_checker', 'pattern', 'parser_util', 'fpa'])
add_lib('user_plugin', ['smt'], 'smt/user_plugin') add_lib('user_plugin', ['smt'], 'smt/user_plugin')
add_lib('bv_tactics', ['tactic', 'bit_blaster'], 'tactic/bv') add_lib('bv_tactics', ['tactic', 'bit_blaster'], 'tactic/bv')
add_lib('fuzzing', ['ast'], 'test/fuzzing') add_lib('fuzzing', ['ast'], 'test/fuzzing')
add_lib('fpa', ['core_tactics', 'bv_tactics', 'sat_tactic'], 'tactic/fpa') add_lib('fpa_tactics', ['fpa', 'core_tactics', 'bv_tactics', 'sat_tactic'], 'tactic/fpa')
add_lib('smt_tactic', ['smt'], 'smt/tactic') add_lib('smt_tactic', ['smt'], 'smt/tactic')
add_lib('sls_tactic', ['tactic', 'normal_forms', 'core_tactics', 'bv_tactics'], 'tactic/sls') add_lib('sls_tactic', ['tactic', 'normal_forms', 'core_tactics', 'bv_tactics'], 'tactic/sls')
# TODO: split muz_qe into muz, qe. Perhaps, we should also consider breaking muz into muz and pdr. add_lib('qe', ['smt','sat'], 'qe')
add_lib('muz_qe', ['smt', 'sat', 'smt2parser', 'aig_tactic']) add_lib('duality', ['smt', 'interp', 'qe'])
add_lib('smtlogic_tactics', ['arith_tactics', 'bv_tactics', 'nlsat_tactic', 'smt_tactic', 'aig_tactic', 'muz_qe'], 'tactic/smtlogics') add_lib('muz', ['smt', 'sat', 'smt2parser', 'aig_tactic', 'qe'], 'muz/base')
add_lib('transforms', ['muz', 'hilbert'], 'muz/transforms')
add_lib('rel', ['muz', 'transforms'], 'muz/rel')
add_lib('pdr', ['muz', 'transforms', 'arith_tactics', 'smt_tactic'], 'muz/pdr')
add_lib('clp', ['muz', 'transforms'], 'muz/clp')
add_lib('tab', ['muz', 'transforms'], 'muz/tab')
add_lib('bmc', ['muz', 'transforms'], 'muz/bmc')
add_lib('duality_intf', ['muz', 'transforms', 'duality'], 'muz/duality')
add_lib('fp', ['muz', 'pdr', 'clp', 'tab', 'rel', 'bmc', 'duality_intf'], 'muz/fp')
add_lib('smtlogic_tactics', ['arith_tactics', 'bv_tactics', 'nlsat_tactic', 'smt_tactic', 'aig_tactic', 'fp', 'muz','qe'], 'tactic/smtlogics')
add_lib('ufbv_tactic', ['normal_forms', 'core_tactics', 'macros', 'smt_tactic', 'rewriter'], 'tactic/ufbv') add_lib('ufbv_tactic', ['normal_forms', 'core_tactics', 'macros', 'smt_tactic', 'rewriter'], 'tactic/ufbv')
add_lib('portfolio', ['smtlogic_tactics', 'ufbv_tactic', 'fpa', 'aig_tactic', 'muz_qe', 'sls_tactic', 'subpaving_tactic'], 'tactic/portfolio') add_lib('portfolio', ['smtlogic_tactics', 'ufbv_tactic', 'fpa_tactics', 'aig_tactic', 'fp', 'qe','sls_tactic', 'subpaving_tactic'], 'tactic/portfolio')
add_lib('smtparser', ['portfolio'], 'parsers/smt') add_lib('smtparser', ['portfolio'], 'parsers/smt')
API_files = ['z3_api.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h'] # add_dll('foci2', ['util'], 'interp/foci2stub',
add_lib('api', ['portfolio', 'user_plugin', 'smtparser', 'realclosure'], # 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']
add_lib('api', ['portfolio', 'user_plugin', 'smtparser', 'realclosure', 'interp'],
includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files) includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files)
add_exe('shell', ['api', 'sat', 'extra_cmds'], exe_name='z3') add_exe('shell', ['api', 'sat', 'extra_cmds'], exe_name='z3')
add_exe('test', ['api', 'fuzzing'], exe_name='test-z3', install=False) add_exe('test', ['api', 'fuzzing'], exe_name='test-z3', install=False)
@ -75,6 +91,8 @@ def init_project_def():
set_z3py_dir('api/python') set_z3py_dir('api/python')
# Examples # Examples
add_cpp_example('cpp_example', 'c++') add_cpp_example('cpp_example', 'c++')
add_cpp_example('iz3', 'interp')
add_cpp_example('z3_tptp', 'tptp')
add_c_example('c_example', 'c') add_c_example('c_example', 'c')
add_c_example('maxsat') add_c_example('maxsat')
add_dotnet_example('dotnet_example', 'dotnet') add_dotnet_example('dotnet_example', 'dotnet')

View file

@ -1,7 +1,7 @@
############################################ ############################################
# Copyright (c) 2012 Microsoft Corporation # Copyright (c) 2012 Microsoft Corporation
# #
# Auxiliary scripts for generating Makefiles # Auxiliary scripts for generating Makefiles
# and Visual Studio project files. # and Visual Studio project files.
# #
# Author: Leonardo de Moura (leonardo) # Author: Leonardo de Moura (leonardo)
@ -29,6 +29,7 @@ CXX=getenv("CXX", None)
CC=getenv("CC", None) CC=getenv("CC", None)
CPPFLAGS=getenv("CPPFLAGS", "") CPPFLAGS=getenv("CPPFLAGS", "")
CXXFLAGS=getenv("CXXFLAGS", "") CXXFLAGS=getenv("CXXFLAGS", "")
EXAMP_DEBUG_FLAG=''
LDFLAGS=getenv("LDFLAGS", "") LDFLAGS=getenv("LDFLAGS", "")
JNI_HOME=getenv("JNI_HOME", None) JNI_HOME=getenv("JNI_HOME", None)
@ -41,7 +42,7 @@ BUILD_DIR='build'
REV_BUILD_DIR='..' REV_BUILD_DIR='..'
SRC_DIR='src' SRC_DIR='src'
EXAMPLE_DIR='examples' EXAMPLE_DIR='examples'
# Required Components # Required Components
Z3_DLL_COMPONENT='api_dll' Z3_DLL_COMPONENT='api_dll'
PATTERN_COMPONENT='pattern' PATTERN_COMPONENT='pattern'
UTIL_COMPONENT='util' UTIL_COMPONENT='util'
@ -53,6 +54,7 @@ CPP_COMPONENT='cpp'
IS_WINDOWS=False IS_WINDOWS=False
IS_LINUX=False IS_LINUX=False
IS_OSX=False IS_OSX=False
IS_FREEBSD=False
VERBOSE=True VERBOSE=True
DEBUG_MODE=False DEBUG_MODE=False
SHOW_CPPS = True SHOW_CPPS = True
@ -70,13 +72,15 @@ VER_BUILD=None
VER_REVISION=None VER_REVISION=None
PREFIX=os.path.split(os.path.split(os.path.split(PYTHON_PACKAGE_DIR)[0])[0])[0] PREFIX=os.path.split(os.path.split(os.path.split(PYTHON_PACKAGE_DIR)[0])[0])[0]
GMP=False GMP=False
FOCI2=False
FOCI2LIB=''
VS_PAR=False VS_PAR=False
VS_PAR_NUM=8 VS_PAR_NUM=8
GPROF=False GPROF=False
GIT_HASH=False GIT_HASH=False
def check_output(cmd): def check_output(cmd):
return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].rstrip('\r\n') return str(subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]).rstrip('\r\n')
def git_hash(): def git_hash():
try: try:
@ -95,6 +99,9 @@ def is_windows():
def is_linux(): def is_linux():
return IS_LINUX return IS_LINUX
def is_freebsd():
return IS_FREEBSD
def is_osx(): def is_osx():
return IS_OSX return IS_OSX
@ -198,6 +205,14 @@ def test_gmp(cc):
t.commit() t.commit()
return exec_compiler_cmd([cc, CPPFLAGS, 'tstgmp.cpp', LDFLAGS, '-lgmp']) == 0 return exec_compiler_cmd([cc, CPPFLAGS, 'tstgmp.cpp', LDFLAGS, '-lgmp']) == 0
def test_foci2(cc,foci2lib):
if is_verbose():
print("Testing FOCI2...")
t = TempFile('tstfoci2.cpp')
t.add('#include<foci2.h>\nint main() { foci2 *f = foci2::create("lia"); return 0; }\n')
t.commit()
return exec_compiler_cmd([cc, CPPFLAGS, '-Isrc/interp', 'tstfoci2.cpp', LDFLAGS, foci2lib]) == 0
def test_openmp(cc): def test_openmp(cc):
if is_verbose(): if is_verbose():
print("Testing OpenMP...") print("Testing OpenMP...")
@ -207,7 +222,7 @@ def test_openmp(cc):
return exec_compiler_cmd([cc, CPPFLAGS, 'tstomp.cpp', LDFLAGS, '-fopenmp']) == 0 return exec_compiler_cmd([cc, CPPFLAGS, 'tstomp.cpp', LDFLAGS, '-fopenmp']) == 0
def find_jni_h(path): def find_jni_h(path):
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for f in files: for f in files:
if f == 'jni.h': if f == 'jni.h':
return root return root
@ -219,7 +234,7 @@ def check_java():
global JAR global JAR
JDK_HOME = getenv('JDK_HOME', None) # we only need to check this locally. JDK_HOME = getenv('JDK_HOME', None) # we only need to check this locally.
if is_verbose(): if is_verbose():
print("Finding javac ...") print("Finding javac ...")
@ -268,7 +283,7 @@ def check_java():
oo = TempFile('output') oo = TempFile('output')
eo = TempFile('errout') eo = TempFile('errout')
try: try:
subprocess.call([JAVAC, 'Hello.java', '-verbose'], stdout=oo.fname, stderr=eo.fname) subprocess.call([JAVAC, 'Hello.java', '-verbose'], stdout=oo.fname, stderr=eo.fname)
oo.commit() oo.commit()
eo.commit() eo.commit()
@ -283,7 +298,7 @@ def check_java():
if JNI_HOME != None: if JNI_HOME != None:
if not os.path.exists(os.path.join(JNI_HOME, 'jni.h')): if not os.path.exists(os.path.join(JNI_HOME, 'jni.h')):
raise MKException("Failed to detect jni.h '%s'; the environment variable JNI_HOME is probably set to the wrong path." % os.path.join(JNI_HOME)) raise MKException("Failed to detect jni.h '%s'; the environment variable JNI_HOME is probably set to the wrong path." % os.path.join(JNI_HOME))
else: else:
# Search for jni.h in the library directories... # Search for jni.h in the library directories...
t = open('errout', 'r') t = open('errout', 'r')
open_pat = re.compile("\[search path for class files: (.*)\]") open_pat = re.compile("\[search path for class files: (.*)\]")
@ -299,22 +314,22 @@ def check_java():
# ... plus some heuristic ones. # ... plus some heuristic ones.
extra_dirs = [] extra_dirs = []
# For the libraries, even the JDK usually uses a JRE that comes with it. To find the # For the libraries, even the JDK usually uses a JRE that comes with it. To find the
# headers we have to go a little bit higher up. # headers we have to go a little bit higher up.
for dir in cdirs: for dir in cdirs:
extra_dirs.append(os.path.abspath(os.path.join(dir, '..'))) extra_dirs.append(os.path.abspath(os.path.join(dir, '..')))
if IS_OSX: # Apparently Apple knows best where to put stuff... if IS_OSX: # Apparently Apple knows best where to put stuff...
extra_dirs.append('/System/Library/Frameworks/JavaVM.framework/Headers/') extra_dirs.append('/System/Library/Frameworks/JavaVM.framework/Headers/')
cdirs[len(cdirs):] = extra_dirs cdirs[len(cdirs):] = extra_dirs
for dir in cdirs: for dir in cdirs:
q = find_jni_h(dir) q = find_jni_h(dir)
if q != False: if q != False:
JNI_HOME = q JNI_HOME = q
if JNI_HOME == None: if JNI_HOME == None:
raise MKException("Failed to detect jni.h. Possible solution: set JNI_HOME with the path to JDK.") raise MKException("Failed to detect jni.h. Possible solution: set JNI_HOME with the path to JDK.")
@ -336,7 +351,7 @@ def find_cxx_compiler():
if test_cxx_compiler(cxx): if test_cxx_compiler(cxx):
CXX = cxx CXX = cxx
return CXX return CXX
raise MKException('C++ compiler was not found. Try to set the environment variable CXX with the C++ compiler available in your system.') raise MKException('C++ compiler was not found. Try to set the environment variable CXX with the C++ compiler available in your system.')
def find_c_compiler(): def find_c_compiler():
global CC, C_COMPILERS global CC, C_COMPILERS
@ -347,7 +362,7 @@ def find_c_compiler():
if test_c_compiler(c): if test_c_compiler(c):
CC = c CC = c
return CC return CC
raise MKException('C compiler was not found. Try to set the environment variable CC with the C compiler available in your system.') raise MKException('C compiler was not found. Try to set the environment variable CC with the C compiler available in your system.')
def set_version(major, minor, build, revision): def set_version(major, minor, build, revision):
global VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION global VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION
@ -415,6 +430,8 @@ elif os.name == 'posix':
IS_OSX=True IS_OSX=True
elif os.uname()[0] == 'Linux': elif os.uname()[0] == 'Linux':
IS_LINUX=True IS_LINUX=True
elif os.uname()[0] == 'FreeBSD':
IS_FREEBSD=True
def display_help(exit_code): def display_help(exit_code):
print("mk_make.py: Z3 Makefile generator\n") print("mk_make.py: Z3 Makefile generator\n")
@ -438,11 +455,12 @@ def display_help(exit_code):
print(" -v, --vsproj generate Visual Studio Project Files.") print(" -v, --vsproj generate Visual Studio Project Files.")
if IS_WINDOWS: if IS_WINDOWS:
print(" -n, --nodotnet do not generate Microsoft.Z3.dll make rules.") print(" -n, --nodotnet do not generate Microsoft.Z3.dll make rules.")
print(" -j, --java generate Java bindinds.") print(" -j, --java generate Java bindings.")
print(" --staticlib build Z3 static library.") print(" --staticlib build Z3 static library.")
if not IS_WINDOWS: if not IS_WINDOWS:
print(" -g, --gmp use GMP.") print(" -g, --gmp use GMP.")
print(" --gprof enable gprof") print(" --gprof enable gprof")
print(" -f <path> --foci2=<path> use foci2 library at path")
print("") print("")
print("Some influential environment variables:") print("Some influential environment variables:")
if not IS_WINDOWS: if not IS_WINDOWS:
@ -458,18 +476,19 @@ def display_help(exit_code):
# Parse configuration option for mk_make script # Parse configuration option for mk_make script
def parse_options(): def parse_options():
global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE, VS_PAR, VS_PAR_NUM 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, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH global DOTNET_ENABLED, JAVA_ENABLED, STATIC_LIB, PREFIX, GMP, FOCI2, FOCI2LIB, PYTHON_PACKAGE_DIR, GPROF, GIT_HASH
try: try:
options, remainder = getopt.gnu_getopt(sys.argv[1:], options, remainder = getopt.gnu_getopt(sys.argv[1:],
'b:dsxhmcvtnp:gj', 'b:df:sxhmcvtnp:gj',
['build=', 'debug', 'silent', 'x64', 'help', 'makefiles', 'showcpp', 'vsproj', ['build=', 'debug', 'silent', 'x64', 'help', 'makefiles', 'showcpp', 'vsproj',
'trace', 'nodotnet', 'staticlib', 'prefix=', 'gmp', 'java', 'parallel=', 'gprof', 'trace', 'nodotnet', 'staticlib', 'prefix=', 'gmp', 'foci2=', 'java', 'parallel=', 'gprof',
'githash=']) 'githash='])
except: except:
print("ERROR: Invalid command line option") print("ERROR: Invalid command line option")
display_help(1) display_help(1)
for opt, arg in options: for opt, arg in options:
print('opt = %s, arg = %s' % (opt, arg))
if opt in ('-b', '--build'): if opt in ('-b', '--build'):
if arg == 'src': if arg == 'src':
raise MKException('The src directory should not be used to host the Makefile') raise MKException('The src directory should not be used to host the Makefile')
@ -507,12 +526,15 @@ def parse_options():
VS_PAR_NUM = int(arg) VS_PAR_NUM = int(arg)
elif opt in ('-g', '--gmp'): elif opt in ('-g', '--gmp'):
GMP = True GMP = True
elif opt in ('-f', '--foci2'):
FOCI2 = True
FOCI2LIB = arg
elif opt in ('-j', '--java'): elif opt in ('-j', '--java'):
JAVA_ENABLED = True JAVA_ENABLED = True
elif opt == '--gprof': elif opt == '--gprof':
GPROF = True GPROF = True
elif opt == '--githash': elif opt == '--githash':
GIT_HASH=arg GIT_HASH=arg
else: else:
print("ERROR: Invalid command line option '%s'" % opt) print("ERROR: Invalid command line option '%s'" % opt)
display_help(1) display_help(1)
@ -526,7 +548,7 @@ def extract_c_includes(fname):
system_inc_pat = re.compile("[ \t]*#include[ \t]*\<.*\>[ \t]*") system_inc_pat = re.compile("[ \t]*#include[ \t]*\<.*\>[ \t]*")
# We should generate and error for any occurrence of #include that does not match the previous pattern. # We should generate and error for any occurrence of #include that does not match the previous pattern.
non_std_inc_pat = re.compile(".*#include.*") non_std_inc_pat = re.compile(".*#include.*")
f = open(fname, 'r') f = open(fname, 'r')
linenum = 1 linenum = 1
for line in f: for line in f:
@ -565,7 +587,7 @@ def set_z3py_dir(p):
raise MKException("Python bindings directory '%s' does not exist" % full) raise MKException("Python bindings directory '%s' does not exist" % full)
Z3PY_SRC_DIR = full Z3PY_SRC_DIR = full
if VERBOSE: if VERBOSE:
print("Python bindinds directory was detected.") print("Python bindings directory was detected.")
_UNIQ_ID = 0 _UNIQ_ID = 0
@ -600,7 +622,7 @@ def is_java_enabled():
return JAVA_ENABLED return JAVA_ENABLED
def is_compiler(given, expected): def is_compiler(given, expected):
""" """
Return True if the 'given' compiler is the expected one. Return True if the 'given' compiler is the expected one.
>>> is_compiler('g++', 'g++') >>> is_compiler('g++', 'g++')
True True
@ -622,7 +644,13 @@ def is_compiler(given, expected):
def is_CXX_gpp(): def is_CXX_gpp():
return is_compiler(CXX, 'g++') return is_compiler(CXX, 'g++')
def is_clang_in_gpp_form(cc):
version_string = check_output([cc, '--version'])
return str(version_string).find('clang') != -1
def is_CXX_clangpp(): def is_CXX_clangpp():
if is_compiler(CXX, 'g++'):
return is_clang_in_gpp_form(CXX)
return is_compiler(CXX, 'clang++') return is_compiler(CXX, 'clang++')
def get_cpp_files(path): def get_cpp_files(path):
@ -665,6 +693,10 @@ class Component:
self.src_dir = os.path.join(SRC_DIR, path) self.src_dir = os.path.join(SRC_DIR, path)
self.to_src_dir = os.path.join(REV_BUILD_DIR, self.src_dir) self.to_src_dir = os.path.join(REV_BUILD_DIR, self.src_dir)
def get_link_name(self):
return os.path.join(self.build_dir, self.name) + '$(LIB_EXT)'
# Find fname in the include paths for the given component. # Find fname in the include paths for the given component.
# ownerfile is only used for creating error messages. # ownerfile is only used for creating error messages.
# That is, we were looking for fname when processing ownerfile # That is, we were looking for fname when processing ownerfile
@ -709,7 +741,7 @@ class Component:
self.add_rule_for_each_include(out, include) self.add_rule_for_each_include(out, include)
include_node = '%s.node' % os.path.join(self.build_dir, include) include_node = '%s.node' % os.path.join(self.build_dir, include)
out.write('%s: ' % include_node) out.write('%s: ' % include_node)
self.add_cpp_h_deps(out, include) self.add_cpp_h_deps(out, include)
out.write('\n') out.write('\n')
out.write('\t@echo done > %s\n' % include_node) out.write('\t@echo done > %s\n' % include_node)
@ -732,7 +764,7 @@ class Component:
out.write('\n') out.write('\n')
mk_dir(os.path.join(BUILD_DIR, self.build_dir)) mk_dir(os.path.join(BUILD_DIR, self.build_dir))
if VS_PAR and IS_WINDOWS: if VS_PAR and IS_WINDOWS:
cppfiles = get_cpp_files(self.src_dir) cppfiles = list(get_cpp_files(self.src_dir))
dependencies = set() dependencies = set()
for cppfile in cppfiles: for cppfile in cppfiles:
dependencies.add(os.path.join(self.to_src_dir, cppfile)) dependencies.add(os.path.join(self.to_src_dir, cppfile))
@ -769,7 +801,7 @@ class Component:
# Return true if the component needs builder to generate an install_tactics.cpp file # Return true if the component needs builder to generate an install_tactics.cpp file
def require_install_tactics(self): def require_install_tactics(self):
return False return False
# Return true if the component needs a def file # Return true if the component needs a def file
def require_def_file(self): def require_def_file(self):
return False return False
@ -778,6 +810,9 @@ class Component:
def require_mem_initializer(self): def require_mem_initializer(self):
return False return False
def mk_install_deps(self, out):
return
def mk_install(self, out): def mk_install(self, out):
return return
@ -786,7 +821,7 @@ class Component:
def is_example(self): def is_example(self):
return False return False
# Invoked when creating a (windows) distribution package using components at build_path, and # Invoked when creating a (windows) distribution package using components at build_path, and
# storing them at dist_path # storing them at dist_path
def mk_win_dist(self, build_path, dist_path): def mk_win_dist(self, build_path, dist_path):
@ -821,10 +856,13 @@ class LibComponent(Component):
out.write('\n') out.write('\n')
out.write('%s: %s\n\n' % (self.name, libfile)) out.write('%s: %s\n\n' % (self.name, libfile))
def mk_install_dep(self, out):
out.write('%s' % libfile)
def mk_install(self, out): def mk_install(self, out):
for include in self.includes2install: for include in self.includes2install:
out.write('\t@cp %s %s\n' % (os.path.join(self.to_src_dir, include), os.path.join('$(PREFIX)', 'include', include))) out.write('\t@cp %s %s\n' % (os.path.join(self.to_src_dir, include), os.path.join('$(PREFIX)', 'include', include)))
def mk_uninstall(self, out): def mk_uninstall(self, out):
for include in self.includes2install: for include in self.includes2install:
out.write('\t@rm -f %s\n' % os.path.join('$(PREFIX)', 'include', include)) out.write('\t@rm -f %s\n' % os.path.join('$(PREFIX)', 'include', include))
@ -833,7 +871,7 @@ class LibComponent(Component):
mk_dir(os.path.join(dist_path, 'include')) mk_dir(os.path.join(dist_path, 'include'))
for include in self.includes2install: for include in self.includes2install:
shutil.copy(os.path.join(self.src_dir, include), shutil.copy(os.path.join(self.src_dir, include),
os.path.join(dist_path, 'include', include)) os.path.join(dist_path, 'include', include))
def mk_unix_dist(self, build_path, dist_path): def mk_unix_dist(self, build_path, dist_path):
self.mk_win_dist(build_path, dist_path) self.mk_win_dist(build_path, dist_path)
@ -880,7 +918,7 @@ class ExeComponent(Component):
out.write(obj) out.write(obj)
for dep in deps: for dep in deps:
c_dep = get_component(dep) c_dep = get_component(dep)
out.write(' %s$(LIB_EXT)' % os.path.join(c_dep.build_dir, c_dep.name)) out.write(' ' + c_dep.get_link_name())
out.write('\n') out.write('\n')
out.write('\t$(LINK) $(LINK_OUT_FLAG)%s $(LINK_FLAGS)' % exefile) out.write('\t$(LINK) $(LINK_OUT_FLAG)%s $(LINK_FLAGS)' % exefile)
for obj in objs: for obj in objs:
@ -888,7 +926,8 @@ class ExeComponent(Component):
out.write(obj) out.write(obj)
for dep in deps: for dep in deps:
c_dep = get_component(dep) c_dep = get_component(dep)
out.write(' %s$(LIB_EXT)' % os.path.join(c_dep.build_dir, c_dep.name)) out.write(' ' + c_dep.get_link_name())
out.write(' ' + FOCI2LIB)
out.write(' $(LINK_EXTRA_FLAGS)\n') out.write(' $(LINK_EXTRA_FLAGS)\n')
out.write('%s: %s\n\n' % (self.name, exefile)) out.write('%s: %s\n\n' % (self.name, exefile))
@ -902,11 +941,14 @@ class ExeComponent(Component):
def main_component(self): def main_component(self):
return self.install return self.install
def mk_install_dep(self, out):
out.write('%s' % exefile)
def mk_install(self, out): def mk_install(self, out):
if self.install: if self.install:
exefile = '%s$(EXE_EXT)' % self.exe_name exefile = '%s$(EXE_EXT)' % self.exe_name
out.write('\t@cp %s %s\n' % (exefile, os.path.join('$(PREFIX)', 'bin', exefile))) out.write('\t@cp %s %s\n' % (exefile, os.path.join('$(PREFIX)', 'bin', exefile)))
def mk_uninstall(self, out): def mk_uninstall(self, out):
exefile = '%s$(EXE_EXT)' % self.exe_name exefile = '%s$(EXE_EXT)' % self.exe_name
out.write('\t@rm -f %s\n' % os.path.join('$(PREFIX)', 'bin', exefile)) out.write('\t@rm -f %s\n' % os.path.join('$(PREFIX)', 'bin', exefile))
@ -931,6 +973,9 @@ class ExtraExeComponent(ExeComponent):
def main_component(self): def main_component(self):
return False return False
def require_mem_initializer(self):
return False
def get_so_ext(): def get_so_ext():
sysname = os.uname()[0] sysname = os.uname()[0]
if sysname == 'Darwin': if sysname == 'Darwin':
@ -954,6 +999,12 @@ class DLLComponent(Component):
self.install = install self.install = install
self.static = static self.static = static
def get_link_name(self):
if self.static:
return os.path.join(self.build_dir, self.name) + '$(LIB_EXT)'
else:
return self.name + '$(SO_EXT)'
def mk_makefile(self, out): def mk_makefile(self, out):
Component.mk_makefile(self, out) Component.mk_makefile(self, out)
# generate rule for (SO_EXT) # generate rule for (SO_EXT)
@ -976,7 +1027,7 @@ class DLLComponent(Component):
for dep in deps: for dep in deps:
if not dep in self.reexports: if not dep in self.reexports:
c_dep = get_component(dep) c_dep = get_component(dep)
out.write(' %s$(LIB_EXT)' % os.path.join(c_dep.build_dir, c_dep.name)) out.write(' ' + c_dep.get_link_name())
out.write('\n') out.write('\n')
out.write('\t$(LINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS)' % dllfile) out.write('\t$(LINK) $(SLINK_OUT_FLAG)%s $(SLINK_FLAGS)' % dllfile)
for obj in objs: for obj in objs:
@ -985,7 +1036,8 @@ class DLLComponent(Component):
for dep in deps: for dep in deps:
if not dep in self.reexports: if not dep in self.reexports:
c_dep = get_component(dep) c_dep = get_component(dep)
out.write(' %s$(LIB_EXT)' % os.path.join(c_dep.build_dir, c_dep.name)) out.write(' ' + c_dep.get_link_name())
out.write(' ' + FOCI2LIB)
out.write(' $(SLINK_EXTRA_FLAGS)') out.write(' $(SLINK_EXTRA_FLAGS)')
if IS_WINDOWS: if IS_WINDOWS:
out.write(' /DEF:%s.def' % os.path.join(self.to_src_dir, self.name)) out.write(' /DEF:%s.def' % os.path.join(self.to_src_dir, self.name))
@ -1020,7 +1072,7 @@ class DLLComponent(Component):
out.write(' ') out.write(' ')
out.write(obj) out.write(obj)
out.write('\n') out.write('\n')
def main_component(self): def main_component(self):
return self.install return self.install
@ -1033,6 +1085,11 @@ class DLLComponent(Component):
def require_def_file(self): def require_def_file(self):
return IS_WINDOWS and self.export_files return IS_WINDOWS and self.export_files
def mk_install_dep(self, out):
out.write('%s$(SO_EXT)' % self.dll_name)
if self.static:
out.write(' %s$(LIB_EXT)' % self.dll_name)
def mk_install(self, out): def mk_install(self, out):
if self.install: if self.install:
dllfile = '%s$(SO_EXT)' % self.dll_name dllfile = '%s$(SO_EXT)' % self.dll_name
@ -1041,7 +1098,7 @@ class DLLComponent(Component):
if self.static: if self.static:
libfile = '%s$(LIB_EXT)' % self.dll_name libfile = '%s$(LIB_EXT)' % self.dll_name
out.write('\t@cp %s %s\n' % (libfile, os.path.join('$(PREFIX)', 'lib', libfile))) out.write('\t@cp %s %s\n' % (libfile, os.path.join('$(PREFIX)', 'lib', libfile)))
def mk_uninstall(self, out): def mk_uninstall(self, out):
dllfile = '%s$(SO_EXT)' % self.dll_name dllfile = '%s$(SO_EXT)' % self.dll_name
@ -1075,7 +1132,7 @@ class DotNetDLLComponent(Component):
if assembly_info_dir == None: if assembly_info_dir == None:
assembly_info_dir = "." assembly_info_dir = "."
self.dll_name = dll_name self.dll_name = dll_name
self.assembly_info_dir = assembly_info_dir self.assembly_info_dir = assembly_info_dir
def mk_makefile(self, out): def mk_makefile(self, out):
if DOTNET_ENABLED: if DOTNET_ENABLED:
@ -1089,23 +1146,26 @@ class DotNetDLLComponent(Component):
cs_fp_files.append(os.path.join(self.to_src_dir, self.assembly_info_dir, cs_file)) cs_fp_files.append(os.path.join(self.to_src_dir, self.assembly_info_dir, cs_file))
cs_files.append(os.path.join(self.assembly_info_dir, cs_file)) cs_files.append(os.path.join(self.assembly_info_dir, cs_file))
dllfile = '%s.dll' % self.dll_name dllfile = '%s.dll' % self.dll_name
out.write('%s:' % dllfile) out.write('%s: %s$(SO_EXT)' % (dllfile, get_component(Z3_DLL_COMPONENT).dll_name))
for cs_file in cs_fp_files: for cs_file in cs_fp_files:
out.write(' ') out.write(' ')
out.write(cs_file) out.write(cs_file)
out.write('\n') out.write('\n')
out.write(' cd %s && csc /noconfig /unsafe+ /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:mscorlib.dll /reference:System.Core.dll /reference:System.dll /reference:System.Numerics.dll /debug+ /debug:full /filealign:512 /optimize- /out:%s.dll /target:library' % (self.to_src_dir, self.dll_name)) out.write(' csc /noconfig /unsafe+ /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /reference:mscorlib.dll /reference:System.Core.dll /reference:System.dll /reference:System.Numerics.dll /filealign:512 /linkresource:%s.dll /out:%s.dll /target:library /doc:%s.xml' % (get_component(Z3_DLL_COMPONENT).dll_name, self.dll_name, self.dll_name))
if DEBUG_MODE:
out.write(' /define:DEBUG;TRACE /debug+ /debug:full /optimize-')
else:
out.write(' /optimize+')
if VS_X64:
out.write(' /platform:x64')
else:
out.write(' /platform:x86')
for cs_file in cs_files: for cs_file in cs_files:
out.write(' ') out.write(' %s' % os.path.join(self.to_src_dir, cs_file))
out.write(cs_file)
out.write('\n') out.write('\n')
# HACK
win_to_src_dir = self.to_src_dir.replace('/', '\\')
out.write(' move %s\n' % os.path.join(win_to_src_dir, dllfile))
out.write(' move %s.pdb\n' % os.path.join(win_to_src_dir, self.dll_name))
out.write('%s: %s\n\n' % (self.name, dllfile)) out.write('%s: %s\n\n' % (self.name, dllfile))
return return
def main_component(self): def main_component(self):
return DOTNET_ENABLED return DOTNET_ENABLED
@ -1118,6 +1178,13 @@ class DotNetDLLComponent(Component):
mk_dir(os.path.join(dist_path, 'bin')) mk_dir(os.path.join(dist_path, 'bin'))
shutil.copy('%s.dll' % os.path.join(build_path, self.dll_name), shutil.copy('%s.dll' % os.path.join(build_path, self.dll_name),
'%s.dll' % os.path.join(dist_path, 'bin', self.dll_name)) '%s.dll' % os.path.join(dist_path, 'bin', self.dll_name))
shutil.copy('%s.xml' % os.path.join(build_path, self.dll_name),
'%s.xml' % os.path.join(dist_path, 'bin', self.dll_name))
if DEBUG_MODE:
shutil.copy('%s.pdb' % os.path.join(build_path, self.dll_name),
'%s.pdb' % os.path.join(dist_path, 'bin', self.dll_name))
def mk_unix_dist(self, build_path, dist_path): def mk_unix_dist(self, build_path, dist_path):
# Do nothing # Do nothing
@ -1138,13 +1205,15 @@ class JavaDLLComponent(Component):
if is_java_enabled(): if is_java_enabled():
mk_dir(os.path.join(BUILD_DIR, 'api', 'java', 'classes')) mk_dir(os.path.join(BUILD_DIR, 'api', 'java', 'classes'))
dllfile = '%s$(SO_EXT)' % self.dll_name dllfile = '%s$(SO_EXT)' % self.dll_name
out.write('libz3java$(SO_EXT): libz3$(SO_EXT) %s\n' % os.path.join(self.to_src_dir, 'Native.cpp')) out.write('libz3java$(SO_EXT): libz3$(SO_EXT) %s\n' % os.path.join(self.to_src_dir, 'Native.cpp'))
t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)api/java/Native$(OBJ_EXT) -I"%s" -I"%s/PLATFORM" -I%s %s/Native.cpp\n' % (JNI_HOME, JNI_HOME, get_component('api').to_src_dir, self.to_src_dir) t = '\t$(CXX) $(CXXFLAGS) $(CXX_OUT_FLAG)api/java/Native$(OBJ_EXT) -I"%s" -I"%s/PLATFORM" -I%s %s/Native.cpp\n' % (JNI_HOME, JNI_HOME, get_component('api').to_src_dir, self.to_src_dir)
if IS_OSX: if IS_OSX:
t = t.replace('PLATFORM', 'darwin') t = t.replace('PLATFORM', 'darwin')
elif IS_LINUX: elif IS_LINUX:
t = t.replace('PLATFORM', 'linux') t = t.replace('PLATFORM', 'linux')
elif IS_FREEBSD:
t = t.replace('PLATFORM', 'freebsd')
else: else:
t = t.replace('PLATFORM', 'win32') t = t.replace('PLATFORM', 'win32')
out.write(t) out.write(t)
@ -1162,21 +1231,21 @@ class JavaDLLComponent(Component):
deps += '%s ' % os.path.join(self.to_src_dir, 'enumerations', jfile) deps += '%s ' % os.path.join(self.to_src_dir, 'enumerations', jfile)
out.write(deps) out.write(deps)
out.write('\n') out.write('\n')
if IS_WINDOWS: #if IS_WINDOWS:
JAVAC = '"%s"' % JAVAC JAVAC = '"%s"' % JAVAC
JAR = '"%s"' % JAR JAR = '"%s"' % JAR
t = ('\t%s %s.java -d %s\n' % (JAVAC, os.path.join(self.to_src_dir, 'enumerations', '*'), os.path.join('api', 'java', 'classes'))) t = ('\t%s %s.java -d %s\n' % (JAVAC, os.path.join(self.to_src_dir, 'enumerations', '*'), os.path.join('api', 'java', 'classes')))
out.write(t) out.write(t)
t = ('\t%s -cp %s %s.java -d %s\n' % (JAVAC, t = ('\t%s -cp %s %s.java -d %s\n' % (JAVAC,
os.path.join('api', 'java', 'classes'), os.path.join('api', 'java', 'classes'),
os.path.join(self.to_src_dir, '*'), os.path.join(self.to_src_dir, '*'),
os.path.join('api', 'java', 'classes'))) os.path.join('api', 'java', 'classes')))
out.write(t) out.write(t)
out.write('\t%s cfm %s.jar %s -C %s .\n' % (JAR, self.package_name, out.write('\t%s cfm %s.jar %s -C %s .\n' % (JAR, self.package_name,
os.path.join(self.to_src_dir, 'manifest'), os.path.join(self.to_src_dir, 'manifest'),
os.path.join('api', 'java', 'classes'))) os.path.join('api', 'java', 'classes')))
out.write('java: %s.jar\n\n' % self.package_name) out.write('java: %s.jar\n\n' % self.package_name)
def main_component(self): def main_component(self):
return is_java_enabled() return is_java_enabled()
@ -1185,7 +1254,7 @@ class JavaDLLComponent(Component):
mk_dir(os.path.join(dist_path, 'bin')) mk_dir(os.path.join(dist_path, 'bin'))
shutil.copy('%s.jar' % os.path.join(build_path, self.package_name), shutil.copy('%s.jar' % os.path.join(build_path, self.package_name),
'%s.jar' % os.path.join(dist_path, 'bin', self.package_name)) '%s.jar' % os.path.join(dist_path, 'bin', self.package_name))
shutil.copy(os.path.join(build_path, 'libz3java.dll'), shutil.copy(os.path.join(build_path, 'libz3java.dll'),
os.path.join(dist_path, 'bin', 'libz3java.dll')) os.path.join(dist_path, 'bin', 'libz3java.dll'))
shutil.copy(os.path.join(build_path, 'libz3java.lib'), shutil.copy(os.path.join(build_path, 'libz3java.lib'),
os.path.join(dist_path, 'bin', 'libz3java.lib')) os.path.join(dist_path, 'bin', 'libz3java.lib'))
@ -1196,7 +1265,7 @@ class JavaDLLComponent(Component):
shutil.copy('%s.jar' % os.path.join(build_path, self.package_name), shutil.copy('%s.jar' % os.path.join(build_path, self.package_name),
'%s.jar' % os.path.join(dist_path, 'bin', self.package_name)) '%s.jar' % os.path.join(dist_path, 'bin', self.package_name))
so = get_so_ext() so = get_so_ext()
shutil.copy(os.path.join(build_path, 'libz3java.%s' % so), shutil.copy(os.path.join(build_path, 'libz3java.%s' % so),
os.path.join(dist_path, 'bin', 'libz3java.%s' % so)) os.path.join(dist_path, 'bin', 'libz3java.%s' % so))
class ExampleComponent(Component): class ExampleComponent(Component):
@ -1228,7 +1297,7 @@ class CppExampleComponent(ExampleComponent):
out.write(' ') out.write(' ')
out.write(os.path.join(self.to_ex_dir, cppfile)) out.write(os.path.join(self.to_ex_dir, cppfile))
out.write('\n') out.write('\n')
out.write('\t%s $(LINK_OUT_FLAG)%s $(LINK_FLAGS)' % (self.compiler(), exefile)) out.write('\t%s $(OS_DEFINES) $(EXAMP_DEBUG_FLAG) $(LINK_OUT_FLAG)%s $(LINK_FLAGS)' % (self.compiler(), exefile))
# Add include dir components # Add include dir components
out.write(' -I%s' % get_component(API_COMPONENT).to_src_dir) out.write(' -I%s' % get_component(API_COMPONENT).to_src_dir)
out.write(' -I%s' % get_component(CPP_COMPONENT).to_src_dir) out.write(' -I%s' % get_component(CPP_COMPONENT).to_src_dir)
@ -1252,7 +1321,7 @@ class CExampleComponent(CppExampleComponent):
def src_files(self): def src_files(self):
return get_c_files(self.ex_dir) return get_c_files(self.ex_dir)
class DotNetExampleComponent(ExampleComponent): class DotNetExampleComponent(ExampleComponent):
def __init__(self, name, path): def __init__(self, name, path):
ExampleComponent.__init__(self, name, path) ExampleComponent.__init__(self, name, path)
@ -1400,7 +1469,8 @@ def mk_config():
'LINK_OUT_FLAG=/Fe\n' 'LINK_OUT_FLAG=/Fe\n'
'SO_EXT=.dll\n' 'SO_EXT=.dll\n'
'SLINK=cl\n' 'SLINK=cl\n'
'SLINK_OUT_FLAG=/Fe\n') 'SLINK_OUT_FLAG=/Fe\n'
'OS_DEFINES=/D _WINDOWS\n')
extra_opt = '' extra_opt = ''
if GIT_HASH: if GIT_HASH:
extra_opt = '%s /D Z3GITHASH=%s' % (extra_opt, GIT_HASH) extra_opt = '%s /D Z3GITHASH=%s' % (extra_opt, GIT_HASH)
@ -1447,7 +1517,8 @@ def mk_config():
print('JNI Bindings: %s' % JNI_HOME) print('JNI Bindings: %s' % JNI_HOME)
print('Java Compiler: %s' % JAVAC) print('Java Compiler: %s' % JAVAC)
else: else:
global CXX, CC, GMP, CPPFLAGS, CXXFLAGS, LDFLAGS global CXX, CC, GMP, FOCI2, CPPFLAGS, CXXFLAGS, LDFLAGS, EXAMP_DEBUG_FLAG
OS_DEFINES = ""
ARITH = "internal" ARITH = "internal"
check_ar() check_ar()
CXX = find_cxx_compiler() CXX = find_cxx_compiler()
@ -1464,6 +1535,14 @@ def mk_config():
SLIBEXTRAFLAGS = '%s -lgmp' % SLIBEXTRAFLAGS SLIBEXTRAFLAGS = '%s -lgmp' % SLIBEXTRAFLAGS
else: else:
CPPFLAGS = '%s -D_MP_INTERNAL' % CPPFLAGS CPPFLAGS = '%s -D_MP_INTERNAL' % CPPFLAGS
if FOCI2:
if test_foci2(CXX,FOCI2LIB):
LDFLAGS = '%s %s' % (LDFLAGS,FOCI2LIB)
SLIBEXTRAFLAGS = '%s %s' % (SLIBEXTRAFLAGS,FOCI2LIB)
CPPFLAGS = '%s -D_FOCI2' % CPPFLAGS
else:
print("FAILED\n")
FOCI2 = False
if GIT_HASH: if GIT_HASH:
CPPFLAGS = '%s -DZ3GITHASH=%s' % (CPPFLAGS, GIT_HASH) CPPFLAGS = '%s -DZ3GITHASH=%s' % (CPPFLAGS, GIT_HASH)
CXXFLAGS = '%s -c' % CXXFLAGS CXXFLAGS = '%s -c' % CXXFLAGS
@ -1476,6 +1555,7 @@ def mk_config():
CXXFLAGS = '%s -D_NO_OMP_' % CXXFLAGS CXXFLAGS = '%s -D_NO_OMP_' % CXXFLAGS
if DEBUG_MODE: if DEBUG_MODE:
CXXFLAGS = '%s -g -Wall' % CXXFLAGS CXXFLAGS = '%s -g -Wall' % CXXFLAGS
EXAMP_DEBUG_FLAG = '-g'
else: else:
if GPROF: if GPROF:
CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE' % CXXFLAGS CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE' % CXXFLAGS
@ -1489,18 +1569,21 @@ def mk_config():
SLIBFLAGS = '-dynamiclib' SLIBFLAGS = '-dynamiclib'
elif sysname == 'Linux': elif sysname == 'Linux':
CXXFLAGS = '%s -fno-strict-aliasing -D_LINUX_' % CXXFLAGS CXXFLAGS = '%s -fno-strict-aliasing -D_LINUX_' % CXXFLAGS
OS_DEFINES = '-D_LINUX'
SO_EXT = '.so' SO_EXT = '.so'
LDFLAGS = '%s -lrt' % LDFLAGS LDFLAGS = '%s -lrt' % LDFLAGS
SLIBFLAGS = '-shared' SLIBFLAGS = '-shared'
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
elif sysname == 'FreeBSD': elif sysname == 'FreeBSD':
CXXFLAGS = '%s -fno-strict-aliasing -D_FREEBSD_' % CXXFLAGS CXXFLAGS = '%s -fno-strict-aliasing -D_FREEBSD_' % CXXFLAGS
OS_DEFINES = '-D_FREEBSD_'
SO_EXT = '.so' SO_EXT = '.so'
LDFLAGS = '%s -lrt' % LDFLAGS LDFLAGS = '%s -lrt' % LDFLAGS
SLIBFLAGS = '-shared' SLIBFLAGS = '-shared'
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
elif sysname[:6] == 'CYGWIN': elif sysname[:6] == 'CYGWIN':
CXXFLAGS = '%s -D_CYGWIN -fno-strict-aliasing' % CXXFLAGS CXXFLAGS = '%s -D_CYGWIN -fno-strict-aliasing' % CXXFLAGS
OS_DEFINES = '-D_CYGWIN'
SO_EXT = '.dll' SO_EXT = '.dll'
SLIBFLAGS = '-shared' SLIBFLAGS = '-shared'
else: else:
@ -1519,6 +1602,7 @@ def mk_config():
config.write('CC=%s\n' % CC) config.write('CC=%s\n' % CC)
config.write('CXX=%s\n' % CXX) config.write('CXX=%s\n' % CXX)
config.write('CXXFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS)) config.write('CXXFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS))
config.write('EXAMP_DEBUG_FLAG=%s\n' % EXAMP_DEBUG_FLAG)
config.write('CXX_OUT_FLAG=-o \n') config.write('CXX_OUT_FLAG=-o \n')
config.write('OBJ_EXT=.o\n') config.write('OBJ_EXT=.o\n')
config.write('LIB_EXT=.a\n') config.write('LIB_EXT=.a\n')
@ -1535,6 +1619,7 @@ def mk_config():
config.write('SLINK_FLAGS=%s\n' % SLIBFLAGS) config.write('SLINK_FLAGS=%s\n' % SLIBFLAGS)
config.write('SLINK_EXTRA_FLAGS=%s\n' % SLIBEXTRAFLAGS) config.write('SLINK_EXTRA_FLAGS=%s\n' % SLIBEXTRAFLAGS)
config.write('SLINK_OUT_FLAG=-o \n') config.write('SLINK_OUT_FLAG=-o \n')
config.write('OS_DEFINES=%s\n' % OS_DEFINES)
if is_verbose(): if is_verbose():
print('Host platform: %s' % sysname) print('Host platform: %s' % sysname)
print('C++ Compiler: %s' % CXX) print('C++ Compiler: %s' % CXX)
@ -1551,7 +1636,11 @@ def mk_config():
print('Java Compiler: %s' % JAVAC) print('Java Compiler: %s' % JAVAC)
def mk_install(out): def mk_install(out):
out.write('install:\n') out.write('install: ')
for c in get_components():
c.mk_install_deps(out)
out.write(' ')
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)', 'bin'))
out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'include')) out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'include'))
out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'lib')) out.write('\t@mkdir -p %s\n' % os.path.join('$(PREFIX)', 'lib'))
@ -1572,7 +1661,7 @@ def mk_install(out):
out.write('\t@echo Z3 shared libraries were installed at \'%s\', make sure this directory is in your %s environment variable.\n' % out.write('\t@echo Z3 shared libraries were installed at \'%s\', make sure this directory is in your %s environment variable.\n' %
(os.path.join(PREFIX, 'lib'), LD_LIBRARY_PATH)) (os.path.join(PREFIX, 'lib'), LD_LIBRARY_PATH))
out.write('\t@echo Z3Py was installed at \'%s\', make sure this directory is in your PYTHONPATH environment variable.' % PYTHON_PACKAGE_DIR) out.write('\t@echo Z3Py was installed at \'%s\', make sure this directory is in your PYTHONPATH environment variable.' % PYTHON_PACKAGE_DIR)
out.write('\n') out.write('\n')
def mk_uninstall(out): def mk_uninstall(out):
out.write('uninstall:\n') out.write('uninstall:\n')
@ -1582,7 +1671,7 @@ def mk_uninstall(out):
out.write('\t@rm -f %s*.pyc\n' % os.path.join(PYTHON_PACKAGE_DIR, 'z3')) out.write('\t@rm -f %s*.pyc\n' % os.path.join(PYTHON_PACKAGE_DIR, 'z3'))
out.write('\t@rm -f %s*.pyc\n' % os.path.join(PYTHON_PACKAGE_DIR, '__pycache__', 'z3')) out.write('\t@rm -f %s*.pyc\n' % os.path.join(PYTHON_PACKAGE_DIR, '__pycache__', 'z3'))
out.write('\t@echo Z3 was successfully uninstalled.\n') out.write('\t@echo Z3 was successfully uninstalled.\n')
out.write('\n') out.write('\n')
# Generate the Z3 makefile # Generate the Z3 makefile
def mk_makefile(): def mk_makefile():
@ -1637,7 +1726,7 @@ def mk_makefile():
print('Remark: to open a Visual Studio Command Prompt, go to: "Start > All Programs > Visual Studio > Visual Studio Tools"') print('Remark: to open a Visual Studio Command Prompt, go to: "Start > All Programs > Visual Studio > Visual Studio Tools"')
else: else:
print("Type 'cd %s; make' to build Z3" % BUILD_DIR) print("Type 'cd %s; make' to build Z3" % BUILD_DIR)
# Generate automatically generated source code # Generate automatically generated source code
def mk_auto_src(): def mk_auto_src():
if not ONLY_MAKEFILES: if not ONLY_MAKEFILES:
@ -1712,7 +1801,7 @@ def def_module_params(module_name, export, params, class_name=None, description=
out.write(' {}\n') out.write(' {}\n')
out.write(' static void collect_param_descrs(param_descrs & d) {\n') out.write(' static void collect_param_descrs(param_descrs & d) {\n')
for param in params: for param in params:
out.write(' d.insert("%s", %s, "%s", "%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param))) out.write(' d.insert("%s", %s, "%s", "%s","%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param), module_name))
out.write(' }\n') out.write(' }\n')
if export: if export:
out.write(' /*\n') out.write(' /*\n')
@ -1723,10 +1812,10 @@ def def_module_params(module_name, export, params, class_name=None, description=
# Generated accessors # Generated accessors
for param in params: for param in params:
if export: if export:
out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' % out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' %
(TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param)))
else: else:
out.write(' %s %s() const { return p.%s("%s", %s); }\n' % out.write(' %s %s() const { return p.%s("%s", %s); }\n' %
(TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param)))
out.write('};\n') out.write('};\n')
out.write('#endif\n') out.write('#endif\n')
@ -1739,8 +1828,8 @@ def max_memory_param():
def max_steps_param(): def max_steps_param():
return ('max_steps', UINT, UINT_MAX, 'maximum number of steps') return ('max_steps', UINT, UINT_MAX, 'maximum number of steps')
PYG_GLOBALS = { 'UINT' : UINT, 'BOOL' : BOOL, 'DOUBLE' : DOUBLE, 'STRING' : STRING, 'SYMBOL' : SYMBOL, PYG_GLOBALS = { 'UINT' : UINT, 'BOOL' : BOOL, 'DOUBLE' : DOUBLE, 'STRING' : STRING, 'SYMBOL' : SYMBOL,
'UINT_MAX' : UINT_MAX, 'UINT_MAX' : UINT_MAX,
'max_memory_param' : max_memory_param, 'max_memory_param' : max_memory_param,
'max_steps_param' : max_steps_param, 'max_steps_param' : max_steps_param,
'def_module_params' : def_module_params } 'def_module_params' : def_module_params }
@ -1755,7 +1844,7 @@ def _execfile(file, globals=globals(), locals=locals()):
# Execute python auxiliary scripts that generate extra code for Z3. # Execute python auxiliary scripts that generate extra code for Z3.
def exec_pyg_scripts(): def exec_pyg_scripts():
global CURR_PYG global CURR_PYG
for root, dirs, files in os.walk('src'): for root, dirs, files in os.walk('src'):
for f in files: for f in files:
if f.endswith('.pyg'): if f.endswith('.pyg'):
script = os.path.join(root, f) script = os.path.join(root, f)
@ -1771,7 +1860,7 @@ def mk_pat_db():
fout.write('char const * g_pattern_database =\n') fout.write('char const * g_pattern_database =\n')
for line in fin: for line in fin:
fout.write('"%s\\n"\n' % line.strip('\n')) fout.write('"%s\\n"\n' % line.strip('\n'))
fout.write(';\n') fout.write(';\n')
if VERBOSE: if VERBOSE:
print("Generated '%s'" % os.path.join(c.src_dir, 'database.h')) print("Generated '%s'" % os.path.join(c.src_dir, 'database.h'))
@ -1785,9 +1874,9 @@ def update_version():
raise MKException("set_version(major, minor, build, revision) must be used before invoking update_version()") raise MKException("set_version(major, minor, build, revision) must be used before invoking update_version()")
if not ONLY_MAKEFILES: if not ONLY_MAKEFILES:
mk_version_dot_h(major, minor, build, revision) mk_version_dot_h(major, minor, build, revision)
update_all_assembly_infos(major, minor, build, revision) mk_all_assembly_infos(major, minor, build, revision)
mk_def_files() mk_def_files()
# Update files with the version number # Update files with the version number
def mk_version_dot_h(major, minor, build, revision): def mk_version_dot_h(major, minor, build, revision):
c = get_component(UTIL_COMPONENT) c = get_component(UTIL_COMPONENT)
@ -1800,49 +1889,32 @@ def mk_version_dot_h(major, minor, build, revision):
if VERBOSE: if VERBOSE:
print("Generated '%s'" % os.path.join(c.src_dir, 'version.h')) print("Generated '%s'" % os.path.join(c.src_dir, 'version.h'))
# Update version number in AssemblyInfo.cs files # Generate AssemblyInfo.cs files with the right version numbers by using AssemblyInfo files as a template
def update_all_assembly_infos(major, minor, build, revision): def mk_all_assembly_infos(major, minor, build, revision):
for c in get_components(): for c in get_components():
if c.has_assembly_info(): if c.has_assembly_info():
assembly = os.path.join(c.src_dir, c.assembly_info_dir, 'AssemblyInfo.cs') assembly = os.path.join(c.src_dir, c.assembly_info_dir, 'AssemblyInfo')
if os.path.exists(assembly): if os.path.exists(assembly):
# It is a CS file # It is a CS file
update_assembly_info_version(assembly, mk_assembly_info_version(assembly, major, minor, build, revision)
major, minor, build, revision, False)
else: else:
assembly = os.path.join(c.src_dir, c.assembly_info_dir, 'AssemblyInfo.cs') raise MKException("Failed to find assembly info file 'AssemblyInfo' at '%s'" % os.path.join(c.src_dir, c.assembly_info_dir))
if os.path.exists(assembly):
# It is a cpp file
update_assembly_info_version(assembly, # Generate version number in the given 'AssemblyInfo.cs' file using 'AssemblyInfo' as a template.
major, minor, build, revision, True) def mk_assembly_info_version(assemblyinfo, major, minor, build, revision):
else: ver_pat = re.compile('[assembly: AssemblyVersion\("[\.\d]*"\) *')
raise MKException("Failed to find assembly info file at '%s'" % os.path.join(c.src_dir, c.assembly_info_dir)) fver_pat = re.compile('[assembly: AssemblyFileVersion\("[\.\d]*"\) *')
# Update version number in the given AssemblyInfo.cs files
def update_assembly_info_version(assemblyinfo, major, minor, build, revision, is_cpp=False):
if is_cpp:
ver_pat = re.compile('[assembly:AssemblyVersionAttribute\("[\.\d]*"\) *')
fver_pat = re.compile('[assembly:AssemblyFileVersionAttribute\("[\.\d]*"\) *')
else:
ver_pat = re.compile('[assembly: AssemblyVersion\("[\.\d]*"\) *')
fver_pat = re.compile('[assembly: AssemblyFileVersion\("[\.\d]*"\) *')
fin = open(assemblyinfo, 'r') fin = open(assemblyinfo, 'r')
tmp = '%s.new' % assemblyinfo tmp = '%s.cs' % assemblyinfo
fout = open(tmp, 'w') fout = open(tmp, 'w')
num_updates = 0 num_updates = 0
for line in fin: for line in fin:
if ver_pat.match(line): if ver_pat.match(line):
if is_cpp: fout.write('[assembly: AssemblyVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
fout.write('[assembly:AssemblyVersionAttribute("%s.%s.%s.%s")];\n' % (major, minor, build, revision))
else:
fout.write('[assembly: AssemblyVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
num_updates = num_updates + 1 num_updates = num_updates + 1
elif fver_pat.match(line): elif fver_pat.match(line):
if is_cpp: fout.write('[assembly: AssemblyFileVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
fout.write('[assembly:AssemblyFileVersionAttribute("%s.%s.%s.%s")];\n' % (major, minor, build, revision))
else:
fout.write('[assembly: AssemblyFileVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
num_updates = num_updates + 1 num_updates = num_updates + 1
else: else:
fout.write(line) fout.write(line)
@ -1851,7 +1923,6 @@ def update_assembly_info_version(assemblyinfo, major, minor, build, revision, is
assert num_updates == 2, "unexpected number of version number updates" assert num_updates == 2, "unexpected number of version number updates"
fin.close() fin.close()
fout.close() fout.close()
shutil.move(tmp, assemblyinfo)
if VERBOSE: if VERBOSE:
print("Updated '%s'" % assemblyinfo) print("Updated '%s'" % assemblyinfo)
@ -1894,7 +1965,7 @@ def mk_install_tactic_cpp(cnames, path):
if not added_include: if not added_include:
added_include = True added_include = True
fout.write('#include"%s"\n' % h_file) fout.write('#include"%s"\n' % h_file)
try: try:
exec(line.strip('\n '), globals()) exec(line.strip('\n '), globals())
except: except:
raise MKException("Failed processing ADD_TACTIC command at '%s'\n%s" % (fullname, line)) raise MKException("Failed processing ADD_TACTIC command at '%s'\n%s" % (fullname, line))
@ -1902,7 +1973,7 @@ def mk_install_tactic_cpp(cnames, path):
if not added_include: if not added_include:
added_include = True added_include = True
fout.write('#include"%s"\n' % h_file) fout.write('#include"%s"\n' % h_file)
try: try:
exec(line.strip('\n '), globals()) exec(line.strip('\n '), globals())
except: except:
raise MKException("Failed processing ADD_PROBE command at '%s'\n%s" % (fullname, line)) raise MKException("Failed processing ADD_PROBE command at '%s'\n%s" % (fullname, line))
@ -2086,7 +2157,7 @@ def mk_def_files():
def cp_z3py_to_build(): def cp_z3py_to_build():
mk_dir(BUILD_DIR) mk_dir(BUILD_DIR)
# Erase existing .pyc files # Erase existing .pyc files
for root, dirs, files in os.walk(Z3PY_SRC_DIR): for root, dirs, files in os.walk(Z3PY_SRC_DIR):
for f in files: for f in files:
if f.endswith('.pyc'): if f.endswith('.pyc'):
rmf(os.path.join(root, f)) rmf(os.path.join(root, f))
@ -2129,7 +2200,7 @@ def mk_bindings(api_files):
mk_z3consts_java(api_files) mk_z3consts_java(api_files)
_execfile(os.path.join('scripts', 'update_api.py'), g) # HACK _execfile(os.path.join('scripts', 'update_api.py'), g) # HACK
cp_z3py_to_build() cp_z3py_to_build()
# Extract enumeration types from API files, and add python definitions. # Extract enumeration types from API files, and add python definitions.
def mk_z3consts_py(api_files): def mk_z3consts_py(api_files):
if Z3PY_SRC_DIR == None: if Z3PY_SRC_DIR == None:
@ -2166,7 +2237,7 @@ def mk_z3consts_py(api_files):
m2 = comment_pat.match(line) m2 = comment_pat.match(line)
if m1 or m2: if m1 or m2:
# skip blank lines and comments # skip blank lines and comments
linenum = linenum + 1 linenum = linenum + 1
elif mode == SEARCHING: elif mode == SEARCHING:
m = typedef_pat.match(line) m = typedef_pat.match(line)
if m: if m:
@ -2207,7 +2278,7 @@ def mk_z3consts_py(api_files):
linenum = linenum + 1 linenum = linenum + 1
if VERBOSE: if VERBOSE:
print("Generated '%s'" % os.path.join(Z3PY_SRC_DIR, 'z3consts.py')) print("Generated '%s'" % os.path.join(Z3PY_SRC_DIR, 'z3consts.py'))
# Extract enumeration types from z3_api.h, and add .Net definitions # Extract enumeration types from z3_api.h, and add .Net definitions
def mk_z3consts_dotnet(api_files): def mk_z3consts_dotnet(api_files):
@ -2248,7 +2319,7 @@ def mk_z3consts_dotnet(api_files):
m2 = comment_pat.match(line) m2 = comment_pat.match(line)
if m1 or m2: if m1 or m2:
# skip blank lines and comments # skip blank lines and comments
linenum = linenum + 1 linenum = linenum + 1
elif mode == SEARCHING: elif mode == SEARCHING:
m = typedef_pat.match(line) m = typedef_pat.match(line)
if m: if m:
@ -2331,7 +2402,7 @@ def mk_z3consts_java(api_files):
m2 = comment_pat.match(line) m2 = comment_pat.match(line)
if m1 or m2: if m1 or m2:
# skip blank lines and comments # skip blank lines and comments
linenum = linenum + 1 linenum = linenum + 1
elif mode == SEARCHING: elif mode == SEARCHING:
m = typedef_pat.match(line) m = typedef_pat.match(line)
if m: if m:
@ -2369,7 +2440,7 @@ def mk_z3consts_java(api_files):
for k in decls: for k in decls:
i = decls[k] i = decls[k]
if first: if first:
first = False first = False
else: else:
efile.write(',\n') efile.write(',\n')
efile.write(' %s (%s)' % (k, i)) efile.write(' %s (%s)' % (k, i))
@ -2380,7 +2451,7 @@ def mk_z3consts_java(api_files):
efile.write(' }\n\n') efile.write(' }\n\n')
efile.write(' public static final %s fromInt(int v) {\n' % name) efile.write(' public static final %s fromInt(int v) {\n' % name)
efile.write(' for (%s k: values()) \n' % name) efile.write(' for (%s k: values()) \n' % name)
efile.write(' if (k.intValue == v) return k;\n') efile.write(' if (k.intValue == v) return k;\n')
efile.write(' return values()[0];\n') efile.write(' return values()[0];\n')
efile.write(' }\n\n') efile.write(' }\n\n')
efile.write(' public final int toInt() { return this.intValue; }\n') efile.write(' public final int toInt() { return this.intValue; }\n')
@ -2451,7 +2522,11 @@ def mk_vs_proj(name, components):
f.write(' <ClCompile>\n') f.write(' <ClCompile>\n')
f.write(' <Optimization>Disabled</Optimization>\n') f.write(' <Optimization>Disabled</Optimization>\n')
f.write(' <PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_TRACE;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n') f.write(' <PreprocessorDefinitions>WIN32;_DEBUG;Z3DEBUG;_TRACE;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
f.write(' <MinimalRebuild>true</MinimalRebuild>\n') if VS_PAR:
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
else:
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n') f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
f.write(' <WarningLevel>Level3</WarningLevel>\n') f.write(' <WarningLevel>Level3</WarningLevel>\n')
f.write(' <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n') f.write(' <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n')
@ -2485,7 +2560,11 @@ def mk_vs_proj(name, components):
f.write(' <ClCompile>\n') f.write(' <ClCompile>\n')
f.write(' <Optimization>Disabled</Optimization>\n') f.write(' <Optimization>Disabled</Optimization>\n')
f.write(' <PreprocessorDefinitions>WIN32;_NDEBUG;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n') f.write(' <PreprocessorDefinitions>WIN32;_NDEBUG;_MP_INTERNAL;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n')
f.write(' <MinimalRebuild>true</MinimalRebuild>\n') if VS_PAR:
f.write(' <MinimalRebuild>false</MinimalRebuild>\n')
f.write(' <MultiProcessorCompilation>true</MultiProcessorCompilation>\n')
else:
f.write(' <MinimalRebuild>true</MinimalRebuild>\n')
f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n') f.write(' <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\n')
f.write(' <WarningLevel>Level3</WarningLevel>\n') f.write(' <WarningLevel>Level3</WarningLevel>\n')
f.write(' <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n') f.write(' <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\n')
@ -2531,16 +2610,17 @@ def mk_vs_proj(name, components):
def mk_win_dist(build_path, dist_path): def mk_win_dist(build_path, dist_path):
for c in get_components(): for c in get_components():
c.mk_win_dist(build_path, dist_path) c.mk_win_dist(build_path, dist_path)
# Add Z3Py to lib directory # Add Z3Py to bin directory
for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(build_path)): print("Adding to %s\n" % dist_path)
for pyc in filter(lambda f: f.endswith('.pyc') or f.endswith('.py'), os.listdir(build_path)):
shutil.copy(os.path.join(build_path, pyc), shutil.copy(os.path.join(build_path, pyc),
os.path.join(dist_path, 'bin', pyc)) os.path.join(dist_path, 'bin', pyc))
def mk_unix_dist(build_path, dist_path): def mk_unix_dist(build_path, dist_path):
for c in get_components(): for c in get_components():
c.mk_unix_dist(build_path, dist_path) c.mk_unix_dist(build_path, dist_path)
# Add Z3Py to lib directory # Add Z3Py to bin directory
for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(build_path)): for pyc in filter(lambda f: f.endswith('.pyc') or f.endswith('.py'), os.listdir(build_path)):
shutil.copy(os.path.join(build_path, pyc), shutil.copy(os.path.join(build_path, pyc),
os.path.join(dist_path, 'bin', pyc)) os.path.join(dist_path, 'bin', pyc))

View file

@ -144,7 +144,7 @@ def mk_z3_core(x64):
cmds.append('call "%VCINSTALLDIR%vcvarsall.bat" amd64') cmds.append('call "%VCINSTALLDIR%vcvarsall.bat" amd64')
cmds.append('cd %s' % BUILD_X64_DIR) cmds.append('cd %s' % BUILD_X64_DIR)
else: else:
cmds.append('"call %VCINSTALLDIR%vcvarsall.bat" x86') cmds.append('call "%VCINSTALLDIR%vcvarsall.bat" x86')
cmds.append('cd %s' % BUILD_X86_DIR) cmds.append('cd %s' % BUILD_X86_DIR)
cmds.append('nmake') cmds.append('nmake')
if exec_cmds(cmds) != 0: if exec_cmds(cmds) != 0:

View file

@ -108,6 +108,7 @@ INOUT = 2
IN_ARRAY = 3 IN_ARRAY = 3
OUT_ARRAY = 4 OUT_ARRAY = 4
INOUT_ARRAY = 5 INOUT_ARRAY = 5
OUT_MANAGED_ARRAY = 6
# Primitive Types # Primitive Types
VOID = 0 VOID = 0
@ -131,13 +132,13 @@ def is_obj(ty):
Type2Str = { VOID : 'void', VOID_PTR : 'void*', INT : 'int', UINT : 'unsigned', INT64 : '__int64', UINT64 : '__uint64', DOUBLE : 'double', 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', 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', 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', 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',
STRING : 'ctypes.c_char_p', STRING_PTR : 'ctypes.POINTER(ctypes.c_char_p)', BOOL : 'ctypes.c_bool', SYMBOL : 'Symbol', 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', PRINT_MODE : 'ctypes.c_uint', ERROR_CODE : 'ctypes.c_uint'
} }
# Mapping to .NET types # Mapping to .NET types
@ -148,11 +149,11 @@ Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint',
# Mapping to Java types # Mapping to Java types
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double', Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
STRING : 'String', STRING_PTR : 'StringPtr', STRING : 'String', STRING_PTR : 'StringPtr',
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int' } 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', Type2JavaW = { VOID : 'void', VOID_PTR : 'jlong', INT : 'jint', UINT : 'jint', INT64 : 'jlong', UINT64 : 'jlong', DOUBLE : 'jdouble',
STRING : 'jstring', STRING_PTR : 'jobject', STRING : 'jstring', STRING_PTR : 'jobject',
BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint' } BOOL : 'jboolean', SYMBOL : 'jlong', PRINT_MODE : 'jint', ERROR_CODE : 'jint'}
next_type_id = FIRST_OBJ_ID next_type_id = FIRST_OBJ_ID
@ -224,6 +225,10 @@ def _out_array2(cap, sz, ty):
def _inout_array(sz, ty): def _inout_array(sz, ty):
return (INOUT_ARRAY, ty, sz, sz); return (INOUT_ARRAY, ty, sz, sz);
def _out_managed_array(sz,ty):
return (OUT_MANAGED_ARRAY, ty, 0, sz)
def param_kind(p): def param_kind(p):
return p[0] return p[0]
@ -254,12 +259,14 @@ def param2dotnet(p):
return "out IntPtr" return "out IntPtr"
else: else:
return "[In, Out] ref %s" % type2dotnet(param_type(p)) return "[In, Out] ref %s" % type2dotnet(param_type(p))
if k == IN_ARRAY: elif k == IN_ARRAY:
return "[In] %s[]" % type2dotnet(param_type(p)) return "[In] %s[]" % type2dotnet(param_type(p))
if k == INOUT_ARRAY: elif k == INOUT_ARRAY:
return "[In, Out] %s[]" % type2dotnet(param_type(p)) return "[In, Out] %s[]" % type2dotnet(param_type(p))
if k == OUT_ARRAY: elif k == OUT_ARRAY:
return "[Out] %s[]" % type2dotnet(param_type(p)) return "[Out] %s[]" % type2dotnet(param_type(p))
elif k == OUT_MANAGED_ARRAY:
return "[Out] out %s[]" % type2dotnet(param_type(p))
else: else:
return type2dotnet(param_type(p)) return type2dotnet(param_type(p))
@ -268,7 +275,7 @@ def param2java(p):
if k == OUT: if k == OUT:
if param_type(p) == INT or param_type(p) == UINT: if param_type(p) == INT or param_type(p) == UINT:
return "IntPtr" return "IntPtr"
elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) >= FIRST_OBJ_ID: elif param_type(p) == INT64 or param_type(p) == UINT64 or param_type(p) == VOID_PTR or param_type(p) >= FIRST_OBJ_ID:
return "LongPtr" return "LongPtr"
elif param_type(p) == STRING: elif param_type(p) == STRING:
return "StringPtr" return "StringPtr"
@ -276,8 +283,13 @@ def param2java(p):
print("ERROR: unreachable code") print("ERROR: unreachable code")
assert(False) assert(False)
exit(1) exit(1)
if k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY: elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
return "%s[]" % type2java(param_type(p)) return "%s[]" % type2java(param_type(p))
elif k == OUT_MANAGED_ARRAY:
if param_type(p) == UINT:
return "UIntArrayPtr"
else:
return "ObjArrayPtr"
else: else:
return type2java(param_type(p)) return type2java(param_type(p))
@ -285,11 +297,13 @@ def param2javaw(p):
k = param_kind(p) k = param_kind(p)
if k == OUT: if k == OUT:
return "jobject" return "jobject"
if k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY: elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
if param_type(p) == INT or param_type(p) == UINT: if param_type(p) == INT or param_type(p) == UINT:
return "jintArray" return "jintArray"
else: else:
return "jlongArray" return "jlongArray"
elif k == OUT_MANAGED_ARRAY:
return "jlong";
else: else:
return type2javaw(param_type(p)) return type2javaw(param_type(p))
@ -420,7 +434,7 @@ def mk_dotnet():
NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc' ] NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc' ]
Unwrapped = [ 'Z3_del_context' ] Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ]
def mk_dotnet_wrappers(): def mk_dotnet_wrappers():
global Type2Str global Type2Str
@ -466,6 +480,8 @@ def mk_dotnet_wrappers():
dotnet.write('out '); dotnet.write('out ');
else: else:
dotnet.write('ref ') dotnet.write('ref ')
elif param_kind(param) == OUT_MANAGED_ARRAY:
dotnet.write('out ');
dotnet.write('a%d' % i) dotnet.write('a%d' % i)
i = i + 1 i = i + 1
dotnet.write(');\n'); dotnet.write(');\n');
@ -522,8 +538,10 @@ def mk_java():
java_native.write(' public static class IntPtr { public int value; }\n') java_native.write(' public static class IntPtr { public int value; }\n')
java_native.write(' public static class LongPtr { public long value; }\n') java_native.write(' public static class LongPtr { public long value; }\n')
java_native.write(' public static class StringPtr { public String value; }\n') java_native.write(' public static class StringPtr { public String value; }\n')
java_native.write(' public static class ObjArrayPtr { public long[] value; }\n')
java_native.write(' public static class UIntArrayPtr { public int[] value; }\n')
java_native.write(' public static native void setInternalErrorHandler(long ctx);\n\n') java_native.write(' public static native void setInternalErrorHandler(long ctx);\n\n')
if IS_WINDOWS: if IS_WINDOWS or os.uname()[0]=="CYGWIN":
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name) java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name)
else: else:
java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name java_native.write(' static { System.loadLibrary("%s"); }\n' % get_component('java').dll_name[3:]) # We need 3: to extract the prexi 'lib' form the dll_name
@ -588,6 +606,9 @@ def mk_java():
java_wrapper = open(java_wrapperf, 'w') java_wrapper = open(java_wrapperf, 'w')
pkg_str = get_component('java').package_name.replace('.', '_') pkg_str = get_component('java').package_name.replace('.', '_')
java_wrapper.write('// Automatically generated file\n') java_wrapper.write('// Automatically generated file\n')
java_wrapper.write('#ifdef _CYGWIN\n')
java_wrapper.write('typedef long long __int64;\n')
java_wrapper.write('#endif\n')
java_wrapper.write('#include<jni.h>\n') java_wrapper.write('#include<jni.h>\n')
java_wrapper.write('#include<stdlib.h>\n') java_wrapper.write('#include<stdlib.h>\n')
java_wrapper.write('#include"z3.h"\n') java_wrapper.write('#include"z3.h"\n')
@ -673,9 +694,11 @@ def mk_java():
if param_type(param) == INT or param_type(param) == UINT: if param_type(param) == INT or param_type(param) == UINT:
java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i)) java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i))
else: else:
java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i)) java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i))
elif k == IN and param_type(param) == STRING: elif k == IN and param_type(param) == STRING:
java_wrapper.write(' Z3_string _a%s = (Z3_string) jenv->GetStringUTFChars(a%s, NULL);\n' % (i, i)) java_wrapper.write(' Z3_string _a%s = (Z3_string) jenv->GetStringUTFChars(a%s, NULL);\n' % (i, i))
elif k == OUT_MANAGED_ARRAY:
java_wrapper.write(' %s * _a%s = 0;\n' % (type2str(param_type(param)), i))
i = i + 1 i = i + 1
# invoke procedure # invoke procedure
java_wrapper.write(' ') java_wrapper.write(' ')
@ -694,6 +717,8 @@ def mk_java():
java_wrapper.write('&_a%s' % i) java_wrapper.write('&_a%s' % i)
elif k == OUT_ARRAY or k == IN_ARRAY or k == INOUT_ARRAY: elif k == OUT_ARRAY or k == IN_ARRAY or k == INOUT_ARRAY:
java_wrapper.write('_a%s' % i) java_wrapper.write('_a%s' % i)
elif k == OUT_MANAGED_ARRAY:
java_wrapper.write('&_a%s' % i)
elif k == IN and param_type(param) == STRING: elif k == IN and param_type(param) == STRING:
java_wrapper.write('_a%s' % i) java_wrapper.write('_a%s' % i)
else: else:
@ -729,6 +754,8 @@ def mk_java():
java_wrapper.write(' jfieldID fid = jenv->GetFieldID(mc, "value", "J");\n') java_wrapper.write(' jfieldID fid = jenv->GetFieldID(mc, "value", "J");\n')
java_wrapper.write(' jenv->SetLongField(a%s, fid, (jlong) _a%s);\n' % (i, i)) java_wrapper.write(' jenv->SetLongField(a%s, fid, (jlong) _a%s);\n' % (i, i))
java_wrapper.write(' }\n') java_wrapper.write(' }\n')
elif k == OUT_MANAGED_ARRAY:
java_wrapper.write(' *(jlong**)a%s = (jlong*)_a%s;\n' % (i, i))
i = i + 1 i = i + 1
# return # return
if result == STRING: if result == STRING:
@ -929,6 +956,9 @@ def def_API(name, result, params):
elif ty == INT64: elif ty == INT64:
log_c.write(" I(0);\n") log_c.write(" I(0);\n")
exe_c.write("in.get_int64_addr(%s)" % i) exe_c.write("in.get_int64_addr(%s)" % i)
elif ty == VOID_PTR:
log_c.write(" P(0);\n")
exe_c.write("in.get_obj_addr(%s)" % i)
else: else:
error("unsupported parameter for %s, %s" % (name, p)) error("unsupported parameter for %s, %s" % (name, p))
elif kind == IN_ARRAY or kind == INOUT_ARRAY: elif kind == IN_ARRAY or kind == INOUT_ARRAY:
@ -950,22 +980,43 @@ def def_API(name, result, params):
log_c.write(" Au(a%s);\n" % sz) log_c.write(" Au(a%s);\n" % sz)
exe_c.write("in.get_uint_array(%s)" % i) exe_c.write("in.get_uint_array(%s)" % i)
else: else:
error ("unsupported parameter for %s, %s" % (name, p)) error ("unsupported parameter for %s, %s" % (ty, name, p))
elif kind == OUT_ARRAY: elif kind == OUT_ARRAY:
sz = param_array_capacity_pos(p) sz = param_array_capacity_pos(p)
log_c.write(" for (unsigned i = 0; i < a%s; i++) { " % sz) sz_p = params[sz]
sz_p_k = param_kind(sz_p)
tstr = type2str(ty)
if sz_p_k == OUT or sz_p_k == INOUT:
sz_e = ("(*a%s)" % sz)
else:
sz_e = ("a%s" % sz)
log_c.write(" for (unsigned i = 0; i < %s; i++) { " % sz_e)
if is_obj(ty): if is_obj(ty):
log_c.write("P(0);") log_c.write("P(0);")
log_c.write(" }\n") log_c.write(" }\n")
log_c.write(" Ap(a%s);\n" % sz) log_c.write(" Ap(%s);\n" % sz_e)
exe_c.write("reinterpret_cast<%s*>(in.get_obj_array(%s))" % (type2str(ty), i)) exe_c.write("reinterpret_cast<%s*>(in.get_obj_array(%s))" % (tstr, i))
elif ty == UINT: elif ty == UINT:
log_c.write("U(0);") log_c.write("U(0);")
log_c.write(" }\n") log_c.write(" }\n")
log_c.write(" Au(a%s);\n" % sz) log_c.write(" Au(%s);\n" % sz_e)
exe_c.write("in.get_uint_array(%s)" % i) exe_c.write("in.get_uint_array(%s)" % i)
else: else:
error ("unsupported parameter for %s, %s" % (name, p)) error ("unsupported parameter for %s, %s" % (name, p))
elif kind == OUT_MANAGED_ARRAY:
sz = param_array_size_pos(p)
sz_p = params[sz]
sz_p_k = param_kind(sz_p)
tstr = type2str(ty)
if sz_p_k == OUT or sz_p_k == INOUT:
sz_e = ("(*a%s)" % sz)
else:
sz_e = ("a%s" % sz)
log_c.write(" for (unsigned i = 0; i < %s; i++) { " % sz_e)
log_c.write("P(0);")
log_c.write(" }\n")
log_c.write(" Ap(%s);\n" % sz_e)
exe_c.write("reinterpret_cast<%s**>(in.get_obj_array(%s))" % (tstr, i))
else: else:
error ("unsupported parameter for %s, %s" % (name, p)) error ("unsupported parameter for %s, %s" % (name, p))
i = i + 1 i = i + 1

View file

@ -31,7 +31,7 @@ Revision History:
#include"ast_smt2_pp.h" #include"ast_smt2_pp.h"
#include"th_rewriter.h" #include"th_rewriter.h"
#include"var_subst.h" #include"var_subst.h"
#include"expr_substitution.h" #include"expr_safe_replace.h"
#include"pp.h" #include"pp.h"
#include"scoped_ctrl_c.h" #include"scoped_ctrl_c.h"
#include"cancel_eh.h" #include"cancel_eh.h"
@ -208,6 +208,7 @@ extern "C" {
MK_BINARY(Z3_mk_xor, mk_c(c)->get_basic_fid(), OP_XOR, SKIP); MK_BINARY(Z3_mk_xor, mk_c(c)->get_basic_fid(), OP_XOR, SKIP);
MK_NARY(Z3_mk_and, mk_c(c)->get_basic_fid(), OP_AND, SKIP); MK_NARY(Z3_mk_and, mk_c(c)->get_basic_fid(), OP_AND, SKIP);
MK_NARY(Z3_mk_or, mk_c(c)->get_basic_fid(), OP_OR, SKIP); MK_NARY(Z3_mk_or, mk_c(c)->get_basic_fid(), OP_OR, SKIP);
MK_UNARY(Z3_mk_interpolant, mk_c(c)->get_basic_fid(), OP_INTERP, SKIP);
Z3_ast mk_ite_core(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3) { Z3_ast mk_ite_core(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3) {
expr * result = mk_c(c)->m().mk_ite(to_expr(t1), to_expr(t2), to_expr(t3)); expr * result = mk_c(c)->m().mk_ite(to_expr(t1), to_expr(t2), to_expr(t3));
@ -786,17 +787,12 @@ extern "C" {
RETURN_Z3(of_expr(0)); RETURN_Z3(of_expr(0));
} }
} }
expr_safe_replace subst(m);
expr_substitution subst(m);
for (unsigned i = 0; i < num_exprs; i++) { for (unsigned i = 0; i < num_exprs; i++) {
subst.insert(from[i], to[i]); subst.insert(from[i], to[i]);
} }
th_rewriter m_rw(m);
m_rw.set_substitution(&subst);
expr_ref new_a(m); expr_ref new_a(m);
proof_ref pr(m); subst(a, new_a);
m_rw(a, new_a, pr);
mk_c(c)->save_ast_trail(new_a); mk_c(c)->save_ast_trail(new_a);
r = new_a.get(); r = new_a.get();
RETURN_Z3(of_expr(r)); RETURN_Z3(of_expr(r));
@ -927,6 +923,7 @@ extern "C" {
case OP_NOT: return Z3_OP_NOT; case OP_NOT: return Z3_OP_NOT;
case OP_IMPLIES: return Z3_OP_IMPLIES; case OP_IMPLIES: return Z3_OP_IMPLIES;
case OP_OEQ: return Z3_OP_OEQ; case OP_OEQ: return Z3_OP_OEQ;
case OP_INTERP: return Z3_OP_INTERP;
case PR_UNDEF: return Z3_OP_PR_UNDEF; case PR_UNDEF: return Z3_OP_PR_UNDEF;
case PR_TRUE: return Z3_OP_PR_TRUE; case PR_TRUE: return Z3_OP_PR_TRUE;
@ -1073,6 +1070,12 @@ extern "C" {
case OP_BSMUL_NO_OVFL: case OP_BSMUL_NO_OVFL:
case OP_BUMUL_NO_OVFL: case OP_BUMUL_NO_OVFL:
case OP_BSMUL_NO_UDFL: case OP_BSMUL_NO_UDFL:
case OP_BSDIV_I:
case OP_BUDIV_I:
case OP_BSREM_I:
case OP_BUREM_I:
case OP_BSMOD_I:
return Z3_OP_UNINTERPRETED; return Z3_OP_UNINTERPRETED;
default: default:
UNREACHABLE(); UNREACHABLE();

View file

@ -117,6 +117,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_sort int_s = Z3_mk_int_sort(c); Z3_sort int_s = Z3_mk_int_sort(c);
if (is_signed) { if (is_signed) {
Z3_ast r = Z3_mk_bv2int(c, n, false); Z3_ast r = Z3_mk_bv2int(c, n, false);
Z3_inc_ref(c, r);
Z3_sort s = Z3_get_sort(c, n); Z3_sort s = Z3_get_sort(c, n);
unsigned sz = Z3_get_bv_sort_size(c, s); unsigned sz = Z3_get_bv_sort_size(c, s);
rational max_bound = power(rational(2), sz); rational max_bound = power(rational(2), sz);
@ -135,6 +136,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_dec_ref(c, pred); Z3_dec_ref(c, pred);
Z3_dec_ref(c, sub); Z3_dec_ref(c, sub);
Z3_dec_ref(c, zero); Z3_dec_ref(c, zero);
Z3_dec_ref(c, r);
RETURN_Z3(res); RETURN_Z3(res);
} }
else { else {

View file

@ -106,10 +106,4 @@ extern "C" {
Z3_CATCH; Z3_CATCH;
} }
Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) {
LOG_Z3_get_param_value(c, param_id, param_value);
// TODO
return Z3_FALSE;
}
}; };

View file

@ -128,6 +128,7 @@ namespace api {
for (unsigned i = 0; i < m_replay_stack.size(); ++i) { for (unsigned i = 0; i < m_replay_stack.size(); ++i) {
dealloc(m_replay_stack[i]); dealloc(m_replay_stack[i]);
} }
m_ast_trail.reset();
} }
reset_parser(); reset_parser();
dealloc(m_solver); dealloc(m_solver);
@ -139,7 +140,7 @@ namespace api {
if (m_interruptable) if (m_interruptable)
(*m_interruptable)(); (*m_interruptable)();
m().set_cancel(true); m().set_cancel(true);
if (m_rcf_manager.get() == 0) if (m_rcf_manager.get() != 0)
m_rcf_manager->set_cancel(true); m_rcf_manager->set_cancel(true);
} }
} }
@ -342,24 +343,21 @@ namespace api {
void context::push() { void context::push() {
get_smt_kernel().push(); get_smt_kernel().push();
if (!m_user_ref_count) { m_ast_lim.push_back(m_ast_trail.size());
m_ast_lim.push_back(m_ast_trail.size()); m_replay_stack.push_back(0);
m_replay_stack.push_back(0);
}
} }
void context::pop(unsigned num_scopes) { void context::pop(unsigned num_scopes) {
for (unsigned i = 0; i < num_scopes; ++i) { for (unsigned i = 0; i < num_scopes; ++i) {
if (!m_user_ref_count) { unsigned sz = m_ast_lim.back();
unsigned sz = m_ast_lim.back(); m_ast_lim.pop_back();
m_ast_lim.pop_back(); dealloc(m_replay_stack.back());
dealloc(m_replay_stack.back()); m_replay_stack.pop_back();
m_replay_stack.pop_back(); while (m_ast_trail.size() > sz) {
while (m_ast_trail.size() > sz) { m_ast_trail.pop_back();
m_ast_trail.pop_back();
}
} }
} }
SASSERT(num_scopes <= get_smt_kernel().get_scope_level());
get_smt_kernel().pop(num_scopes); get_smt_kernel().pop(num_scopes);
} }

View file

@ -18,7 +18,6 @@ Revision History:
#include"api_datalog.h" #include"api_datalog.h"
#include"api_context.h" #include"api_context.h"
#include"api_util.h" #include"api_util.h"
#include"dl_context.h"
#include"ast_pp.h" #include"ast_pp.h"
#include"api_ast_vector.h" #include"api_ast_vector.h"
#include"api_log_macros.h" #include"api_log_macros.h"
@ -29,104 +28,126 @@ Revision History:
#include"dl_cmds.h" #include"dl_cmds.h"
#include"cmd_context.h" #include"cmd_context.h"
#include"smt2parser.h" #include"smt2parser.h"
#include"dl_context.h"
#include"dl_register_engine.h"
#include"dl_external_relation.h"
#include"dl_decl_plugin.h"
#include"rel_context.h"
namespace api { namespace api {
fixedpoint_context::fixedpoint_context(ast_manager& m, smt_params& p) : class fixedpoint_context : public datalog::external_relation_context {
m_state(0), void * m_state;
m_reduce_app(0), reduce_app_callback_fptr m_reduce_app;
m_reduce_assign(0), reduce_assign_callback_fptr m_reduce_assign;
m_context(m, p), datalog::register_engine m_register_engine;
m_trail(m) {} datalog::context m_context;
ast_ref_vector m_trail;
public:
void fixedpoint_context::set_state(void* state) { fixedpoint_context(ast_manager& m, smt_params& p):
SASSERT(!m_state); m_state(0),
m_state = state; m_reduce_app(0),
symbol name("datalog_relation"); m_reduce_assign(0),
ast_manager& m = m_context.get_manager(); m_context(m, m_register_engine, p),
if (!m.has_plugin(name)) { m_trail(m) {}
m.register_plugin(name, alloc(datalog::dl_decl_plugin));
} virtual ~fixedpoint_context() {}
datalog::relation_manager& r = m_context.get_rel_context().get_rmanager(); family_id get_family_id() const { return const_cast<datalog::context&>(m_context).get_decl_util().get_family_id(); }
r.register_plugin(alloc(datalog::external_relation_plugin, *this, r)); void set_state(void* state) {
} SASSERT(!m_state);
m_state = state;
void fixedpoint_context::reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) { symbol name("datalog_relation");
expr* r = 0;
if (m_reduce_app) {
m_reduce_app(m_state, f, num_args, args, &r);
result = r;
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_trail.push_back(r);
}
// allow fallthrough.
if (r == 0) {
ast_manager& m = m_context.get_manager(); ast_manager& m = m_context.get_manager();
result = m.mk_app(f, num_args, args); if (!m.has_plugin(name)) {
} m.register_plugin(name, alloc(datalog::dl_decl_plugin));
} }
datalog::rel_context_base* rel = m_context.get_rel_context();
// overwrite terms passed in outs vector with values computed by function. if (rel) {
void fixedpoint_context::reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) { datalog::relation_manager& r = rel->get_rmanager();
if (m_reduce_assign) { r.register_plugin(alloc(datalog::external_relation_plugin, *this, r));
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
} }
m_reduce_assign(m_state, f, num_args, args, num_out, outs);
} }
} void set_reduce_app(reduce_app_callback_fptr f) {
m_reduce_app = f;
void fixedpoint_context::add_rule(expr* rule, symbol const& name) {
m_context.add_rule(rule, name);
}
void fixedpoint_context::update_rule(expr* rule, symbol const& name) {
m_context.update_rule(rule, name);
}
void fixedpoint_context::add_table_fact(func_decl* r, unsigned num_args, unsigned args[]) {
m_context.add_table_fact(r, num_args, args);
}
unsigned fixedpoint_context::get_num_levels(func_decl* pred) {
return m_context.get_num_levels(pred);
}
expr_ref fixedpoint_context::get_cover_delta(int level, func_decl* pred) {
return m_context.get_cover_delta(level, pred);
}
void fixedpoint_context::add_cover(int level, func_decl* pred, expr* predicate) {
m_context.add_cover(level, pred, predicate);
}
std::string fixedpoint_context::get_last_status() {
datalog::execution_result status = m_context.get_status();
switch(status) {
case datalog::INPUT_ERROR:
return "input error";
case datalog::OK:
return "ok";
case datalog::TIMEOUT:
return "timeout";
default:
UNREACHABLE();
return "unknown";
} }
} void set_reduce_assign(reduce_assign_callback_fptr f) {
m_reduce_assign = f;
std::string fixedpoint_context::to_string(unsigned num_queries, expr*const* queries) { }
std::stringstream str; virtual void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) {
m_context.display_smt2(num_queries, queries, str); expr* r = 0;
return str.str(); if (m_reduce_app) {
} m_reduce_app(m_state, f, num_args, args, &r);
result = r;
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_trail.push_back(r);
}
// allow fallthrough.
if (r == 0) {
ast_manager& m = m_context.get_manager();
result = m.mk_app(f, num_args, args);
}
}
virtual void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) {
if (m_reduce_assign) {
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_reduce_assign(m_state, f, num_args, args, num_out, outs);
}
}
datalog::context& ctx() { return m_context; }
void add_rule(expr* rule, symbol const& name) {
m_context.add_rule(rule, name);
}
void update_rule(expr* rule, symbol const& name) {
m_context.update_rule(rule, name);
}
void add_table_fact(func_decl* r, unsigned num_args, unsigned args[]) {
m_context.add_table_fact(r, num_args, args);
}
std::string get_last_status() {
datalog::execution_result status = m_context.get_status();
switch(status) {
case datalog::INPUT_ERROR:
return "input error";
case datalog::OK:
return "ok";
case datalog::TIMEOUT:
return "timeout";
case datalog::APPROX:
return "approximated";
default:
UNREACHABLE();
return "unknown";
}
}
std::string to_string(unsigned num_queries, expr*const* queries) {
std::stringstream str;
m_context.display_smt2(num_queries, queries, str);
return str.str();
}
void cancel() {
m_context.cancel();
}
void reset_cancel() {
m_context.reset_cancel();
}
unsigned get_num_levels(func_decl* pred) {
return m_context.get_num_levels(pred);
}
expr_ref get_cover_delta(int level, func_decl* pred) {
return m_context.get_cover_delta(level, pred);
}
void add_cover(int level, func_decl* pred, expr* predicate) {
m_context.add_cover(level, pred, predicate);
}
void collect_param_descrs(param_descrs & p) { m_context.collect_params(p); }
void updt_params(params_ref const& p) { m_context.updt_params(p); }
};
}; };
extern "C" { extern "C" {

View file

@ -22,48 +22,14 @@ Revision History:
#include"z3.h" #include"z3.h"
#include"ast.h" #include"ast.h"
#include"smt_params.h" #include"smt_params.h"
#include"dl_external_relation.h"
#include"dl_decl_plugin.h"
#include"smt_kernel.h" #include"smt_kernel.h"
#include"api_util.h" #include"api_util.h"
#include"dl_context.h"
typedef void (*reduce_app_callback_fptr)(void*, func_decl*, unsigned, expr*const*, expr**); typedef void (*reduce_app_callback_fptr)(void*, func_decl*, unsigned, expr*const*, expr**);
typedef void (*reduce_assign_callback_fptr)(void*, func_decl*, unsigned, expr*const*, unsigned, expr*const*); typedef void (*reduce_assign_callback_fptr)(void*, func_decl*, unsigned, expr*const*, unsigned, expr*const*);
namespace api { namespace api {
class fixedpoint_context;
class fixedpoint_context : public datalog::external_relation_context {
void * m_state;
reduce_app_callback_fptr m_reduce_app;
reduce_assign_callback_fptr m_reduce_assign;
datalog::context m_context;
ast_ref_vector m_trail;
public:
fixedpoint_context(ast_manager& m, smt_params& p);
virtual ~fixedpoint_context() {}
family_id get_family_id() const { return const_cast<datalog::context&>(m_context).get_decl_util().get_family_id(); }
void set_state(void* state);
void set_reduce_app(reduce_app_callback_fptr f) { m_reduce_app = f; }
void set_reduce_assign(reduce_assign_callback_fptr f) { m_reduce_assign = f; }
virtual void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result);
virtual void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs);
datalog::context& ctx() { return m_context; }
void add_rule(expr* rule, symbol const& name);
void update_rule(expr* rule, symbol const& name);
void add_table_fact(func_decl* r, unsigned num_args, unsigned args[]);
std::string get_last_status();
std::string to_string(unsigned num_queries, expr*const* queries);
void cancel() { m_context.cancel(); }
void reset_cancel() { m_context.reset_cancel(); }
unsigned get_num_levels(func_decl* pred);
expr_ref get_cover_delta(int level, func_decl* pred);
void add_cover(int level, func_decl* pred, expr* predicate);
void collect_param_descrs(param_descrs & p) { m_context.collect_params(p); }
void updt_params(params_ref const& p) { m_context.updt_params(p); }
};
}; };

723
src/api/api_interp.cpp Normal file
View file

@ -0,0 +1,723 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
api_interp.cpp
Abstract:
API for interpolation
Author:
Ken McMillan
Revision History:
--*/
#include<iostream>
#include<sstream>
#include<vector>
#include"z3.h"
#include"api_log_macros.h"
#include"api_context.h"
#include"api_tactic.h"
#include"api_solver.h"
#include"api_model.h"
#include"api_stats.h"
#include"api_ast_vector.h"
#include"tactic2solver.h"
#include"scoped_ctrl_c.h"
#include"cancel_eh.h"
#include"scoped_timer.h"
#include"smt_strategic_solver.h"
#include"smt_solver.h"
#include"smt_implied_equalities.h"
#include"iz3interp.h"
#include"iz3profiling.h"
#include"iz3hash.h"
#include"iz3pp.h"
#include"iz3checker.h"
#include"scoped_proof.h"
using namespace stl_ext;
// WARNING: don't make a hash_map with this if the range type
// has a destructor: you'll get an address dependency!!!
namespace stl_ext {
template <>
class hash < Z3_ast > {
public:
size_t operator()(const Z3_ast p) const {
return (size_t)p;
}
};
}
typedef interpolation_options_struct *Z3_interpolation_options;
extern "C" {
Z3_context Z3_mk_interpolation_context(Z3_config cfg){
if (!cfg) cfg = Z3_mk_config();
Z3_set_param_value(cfg, "PROOF", "true");
Z3_set_param_value(cfg, "MODEL", "true");
// Z3_set_param_value(cfg, "PRE_SIMPLIFIER","false");
// Z3_set_param_value(cfg, "SIMPLIFY_CLAUSES","false");
Z3_context ctx = Z3_mk_context(cfg);
Z3_del_config(cfg);
return ctx;
}
void Z3_interpolate_proof(Z3_context ctx,
Z3_ast proof,
int num,
Z3_ast *cnsts,
unsigned *parents,
Z3_params options,
Z3_ast *interps,
int num_theory,
Z3_ast *theory)
{
if (num > 1){ // if we have interpolants to compute
ptr_vector<ast> pre_cnsts_vec(num); // get constraints in a vector
for (int i = 0; i < num; i++){
ast *a = to_ast(cnsts[i]);
pre_cnsts_vec[i] = a;
}
::vector<int> pre_parents_vec; // get parents in a vector
if (parents){
pre_parents_vec.resize(num);
for (int i = 0; i < num; i++)
pre_parents_vec[i] = parents[i];
}
ptr_vector<ast> theory_vec; // get background theory in a vector
if (theory){
theory_vec.resize(num_theory);
for (int i = 0; i < num_theory; i++)
theory_vec[i] = to_ast(theory[i]);
}
ptr_vector<ast> interpolants(num - 1); // make space for result
ast_manager &_m = mk_c(ctx)->m();
iz3interpolate(_m,
to_ast(proof),
pre_cnsts_vec,
pre_parents_vec,
interpolants,
theory_vec,
0); // ignore params for now FIXME
// copy result back
for (unsigned i = 0; i < interpolants.size(); i++){
mk_c(ctx)->save_ast_trail(interpolants[i]);
interps[i] = of_ast(interpolants[i]);
_m.dec_ref(interpolants[i]);
}
}
}
static std::ostringstream itp_err;
int Z3_check_interpolant(Z3_context ctx,
unsigned num,
Z3_ast *cnsts,
unsigned *parents,
Z3_ast *itp,
Z3_string *error,
unsigned num_theory,
Z3_ast *theory){
ast_manager &_m = mk_c(ctx)->m();
itp_err.clear();
// need a solver -- make one here, but how?
params_ref p = params_ref::get_empty(); //FIXME
scoped_ptr<solver_factory> sf(mk_smt_solver_factory());
scoped_ptr<solver> sp((*(sf))(_m, p, false, true, false, symbol("AUFLIA")));
ptr_vector<ast> cnsts_vec(num); // get constraints in a vector
for (unsigned i = 0; i < num; i++){
ast *a = to_ast(cnsts[i]);
cnsts_vec[i] = a;
}
ptr_vector<ast> itp_vec(num); // get interpolants in a vector
for (unsigned i = 0; i < num - 1; i++){
ast *a = to_ast(itp[i]);
itp_vec[i] = a;
}
::vector<int> parents_vec; // get parents in a vector
if (parents){
parents_vec.resize(num);
for (unsigned i = 0; i < num; i++)
parents_vec[i] = parents[i];
}
ptr_vector<ast> theory_vec; // get background theory in a vector
if (theory){
theory_vec.resize(num_theory);
for (unsigned i = 0; i < num_theory; i++)
theory_vec[i] = to_ast(theory[i]);
}
bool res = iz3check(_m,
sp.get(),
itp_err,
cnsts_vec,
parents_vec,
itp_vec,
theory_vec);
*error = res ? 0 : itp_err.str().c_str();
return res;
}
static std::string Z3_profile_string;
Z3_string Z3_interpolation_profile(Z3_context ctx){
std::ostringstream f;
profiling::print(f);
Z3_profile_string = f.str();
return Z3_profile_string.c_str();
}
Z3_interpolation_options
Z3_mk_interpolation_options(){
return (Z3_interpolation_options) new interpolation_options_struct;
}
void
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){
opts->map[name] = value;
}
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p){
Z3_TRY;
LOG_Z3_get_interpolant(c, pf, pat, p);
RESET_ERROR_CODE();
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, mk_c(c)->m());
mk_c(c)->save_object(v);
ast *_pf = to_ast(pf);
ast *_pat = to_ast(pat);
ptr_vector<ast> interp;
ptr_vector<ast> cnsts; // to throw away
ast_manager &_m = mk_c(c)->m();
iz3interpolate(_m,
_pf,
cnsts,
_pat,
interp,
(interpolation_options_struct *)0 // ignore params for now
);
// copy result back
for (unsigned i = 0; i < interp.size(); i++){
v->m_ast_vector.push_back(interp[i]);
_m.dec_ref(interp[i]);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
}
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c, __in Z3_ast pat, __in Z3_params p, __out Z3_ast_vector *out_interp, __out Z3_model *model){
Z3_TRY;
LOG_Z3_compute_interpolant(c, pat, p, out_interp, model);
RESET_ERROR_CODE();
// params_ref &_p = to_params(p)->m_params;
params_ref _p;
_p.set_bool("proof", true); // this is currently useless
scoped_proof_mode spm(mk_c(c)->m(), PGM_FINE);
scoped_ptr<solver_factory> sf = mk_smt_solver_factory();
scoped_ptr<solver> m_solver((*sf)(mk_c(c)->m(), _p, true, true, true, ::symbol::null));
m_solver.get()->updt_params(_p); // why do we have to do this?
ast *_pat = to_ast(pat);
ptr_vector<ast> interp;
ptr_vector<ast> cnsts; // to throw away
ast_manager &_m = mk_c(c)->m();
model_ref m;
lbool _status = iz3interpolate(_m,
*(m_solver.get()),
_pat,
cnsts,
interp,
m,
0 // ignore params for now
);
for (unsigned i = 0; i < cnsts.size(); i++)
_m.dec_ref(cnsts[i]);
Z3_lbool status = of_lbool(_status);
Z3_ast_vector_ref *v = 0;
*model = 0;
if (_status == l_false){
// copy result back
v = alloc(Z3_ast_vector_ref, mk_c(c)->m());
mk_c(c)->save_object(v);
for (unsigned i = 0; i < interp.size(); i++){
v->m_ast_vector.push_back(interp[i]);
_m.dec_ref(interp[i]);
}
}
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);
}
*out_interp = of_ast_vector(v);
return status;
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
};
static void tokenize(const std::string &str, std::vector<std::string> &tokens){
for (unsigned i = 0; i < str.size();){
if (str[i] == ' '){ i++; continue; }
unsigned beg = i;
while (i < str.size() && str[i] != ' ')i++;
if (i > beg)
tokens.push_back(str.substr(beg, i - beg));
}
}
static void get_file_params(const char *filename, hash_map<std::string, std::string> &params){
std::ifstream f(filename);
if (f){
std::string first_line;
std::getline(f, first_line);
// std::cout << "first line: '" << first_line << "'" << std::endl;
if (first_line.size() >= 2 && first_line[0] == ';' && first_line[1] == '!'){
std::vector<std::string> tokens;
tokenize(first_line.substr(2, first_line.size() - 2), tokens);
for (unsigned i = 0; i < tokens.size(); i++){
std::string &tok = tokens[i];
size_t eqpos = tok.find('=');
if (eqpos != std::string::npos){
std::string left = tok.substr(0, eqpos);
std::string right = tok.substr(eqpos + 1, tok.size() - eqpos - 1);
params[left] = right;
}
}
}
f.close();
}
}
extern "C" {
#if 0
static void iZ3_write_seq(Z3_context ctx, int num, Z3_ast *cnsts, const char *filename, int num_theory, Z3_ast *theory){
int num_fmlas = num+num_theory;
std::vector<Z3_ast> fmlas(num_fmlas);
if(num_theory)
std::copy(theory,theory+num_theory,fmlas.begin());
for(int i = 0; i < num_theory; i++)
fmlas[i] = Z3_mk_implies(ctx,Z3_mk_true(ctx),fmlas[i]);
std::copy(cnsts,cnsts+num,fmlas.begin()+num_theory);
Z3_string smt = Z3_benchmark_to_smtlib_string(ctx,"none","AUFLIA","unknown","",num_fmlas-1,&fmlas[0],fmlas[num_fmlas-1]);
std::ofstream f(filename);
if(num_theory)
f << ";! THEORY=" << num_theory << "\n";
f << smt;
f.close();
}
void Z3_write_interpolation_problem(Z3_context ctx, int num, Z3_ast *cnsts, unsigned *parents, const char *filename, int num_theory, Z3_ast *theory){
if(!parents){
iZ3_write_seq(ctx,num,cnsts,filename,num_theory,theory);
return;
}
std::vector<Z3_ast> tcnsts(num);
hash_map<int,Z3_ast> syms;
for(int j = 0; j < num - 1; j++){
std::ostringstream oss;
oss << "$P" << j;
std::string name = oss.str();
Z3_symbol s = Z3_mk_string_symbol(ctx, name.c_str());
Z3_ast symbol = Z3_mk_const(ctx, s, Z3_mk_bool_sort(ctx));
syms[j] = symbol;
tcnsts[j] = Z3_mk_implies(ctx,cnsts[j],symbol);
}
tcnsts[num-1] = Z3_mk_implies(ctx,cnsts[num-1],Z3_mk_false(ctx));
for(int j = num-2; j >= 0; j--){
int parent = parents[j];
// assert(parent >= 0 && parent < num);
tcnsts[parent] = Z3_mk_implies(ctx,syms[j],tcnsts[parent]);
}
iZ3_write_seq(ctx,num,&tcnsts[0],filename,num_theory,theory);
}
#else
static Z3_ast and_vec(Z3_context ctx, svector<Z3_ast> &c){
return (c.size() > 1) ? Z3_mk_and(ctx, c.size(), &c[0]) : c[0];
}
static Z3_ast parents_vector_to_tree(Z3_context ctx, int num, Z3_ast *cnsts, unsigned *parents){
Z3_ast res;
if (!parents){
res = Z3_mk_interpolant(ctx, cnsts[0]);
for (int i = 1; i < num - 1; i++){
Z3_ast bar[2] = { res, cnsts[i] };
res = Z3_mk_interpolant(ctx, Z3_mk_and(ctx, 2, bar));
}
if (num > 1){
Z3_ast bar[2] = { res, cnsts[num - 1] };
res = Z3_mk_and(ctx, 2, bar);
}
}
else {
std::vector<svector<Z3_ast> > chs(num);
for (int i = 0; i < num - 1; i++){
svector<Z3_ast> &c = chs[i];
c.push_back(cnsts[i]);
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);
}
}
Z3_inc_ref(ctx, res);
return res;
}
void Z3_write_interpolation_problem(Z3_context ctx, unsigned num, Z3_ast *cnsts, unsigned *parents, const char *filename, unsigned num_theory, Z3_ast *theory){
std::ofstream f(filename);
if (num > 0){
#if 0
// Suggested shorthand:
ptr_vector<expr> cnsts_vec;
cnsts_vec.append(num, to_exprs(cnsts));
cnsts_vec.append(num_theory, to_exprs(theory));
#endif
ptr_vector<expr> cnsts_vec(num); // get constraints in a vector
for (unsigned i = 0; i < num; i++){
expr *a = to_expr(cnsts[i]);
cnsts_vec[i] = a;
}
for (unsigned i = 0; i < num_theory; i++){
expr *a = to_expr(theory[i]);
cnsts_vec.push_back(a);
}
Z3_ast tree = parents_vector_to_tree(ctx, num, cnsts, parents);
iz3pp(mk_c(ctx)->m(), cnsts_vec, to_expr(tree), f);
Z3_dec_ref(ctx, tree);
}
f.close();
#if 0
if(!parents){
iZ3_write_seq(ctx,num,cnsts,filename,num_theory,theory);
return;
}
std::vector<Z3_ast> tcnsts(num);
hash_map<int,Z3_ast> syms;
for(int j = 0; j < num - 1; j++){
std::ostringstream oss;
oss << "$P" << j;
std::string name = oss.str();
Z3_symbol s = Z3_mk_string_symbol(ctx, name.c_str());
Z3_ast symbol = Z3_mk_const(ctx, s, Z3_mk_bool_sort(ctx));
syms[j] = symbol;
tcnsts[j] = Z3_mk_implies(ctx,cnsts[j],symbol);
}
tcnsts[num-1] = Z3_mk_implies(ctx,cnsts[num-1],Z3_mk_false(ctx));
for(int j = num-2; j >= 0; j--){
int parent = parents[j];
// assert(parent >= 0 && parent < num);
tcnsts[parent] = Z3_mk_implies(ctx,syms[j],tcnsts[parent]);
}
iZ3_write_seq(ctx,num,&tcnsts[0],filename,num_theory,theory);
#endif
}
#endif
static std::vector<Z3_ast> read_cnsts;
static std::vector<unsigned> read_parents;
static std::ostringstream read_error;
static std::string read_msg;
static std::vector<Z3_ast> read_theory;
static bool iZ3_parse(Z3_context ctx, const char *filename, const char **error, svector<Z3_ast> &assertions){
read_error.clear();
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);
int nconjs = Z3_get_app_num_args(ctx, app);
assertions.resize(nconjs);
for (int k = 0; k < nconjs; k++)
assertions[k] = Z3_get_app_arg(ctx, app, k);
}
else {
Z3_parse_smtlib_file(ctx, filename, 0, 0, 0, 0, 0, 0);
int numa = Z3_get_smtlib_num_assumptions(ctx);
int numf = Z3_get_smtlib_num_formulas(ctx);
int num = numa + numf;
assertions.resize(num);
for (int j = 0; j < num; j++){
if (j < numa)
assertions[j] = Z3_get_smtlib_assumption(ctx, j);
else
assertions[j] = Z3_get_smtlib_formula(ctx, j - numa);
}
}
}
catch (...) {
read_error << "SMTLIB parse error: " << Z3_get_smtlib_error(ctx);
read_msg = read_error.str();
*error = read_msg.c_str();
return false;
}
Z3_set_error_handler(ctx, 0);
return true;
}
int Z3_read_interpolation_problem(Z3_context ctx, unsigned *_num, Z3_ast *cnsts[], unsigned *parents[], const char *filename, Z3_string_ptr error, unsigned *ret_num_theory, Z3_ast *theory[]){
hash_map<std::string, std::string> file_params;
get_file_params(filename, file_params);
unsigned num_theory = 0;
if (file_params.find("THEORY") != file_params.end())
num_theory = atoi(file_params["THEORY"].c_str());
svector<Z3_ast> assertions;
if (!iZ3_parse(ctx, filename, error, assertions))
return false;
if (num_theory > assertions.size())
num_theory = assertions.size();
unsigned num = assertions.size() - num_theory;
read_cnsts.resize(num);
read_parents.resize(num);
read_theory.resize(num_theory);
for (unsigned j = 0; j < num_theory; j++)
read_theory[j] = assertions[j];
for (unsigned j = 0; j < num; j++)
read_cnsts[j] = assertions[j + num_theory];
if (ret_num_theory)
*ret_num_theory = num_theory;
if (theory)
*theory = &read_theory[0];
if (!parents){
*_num = num;
*cnsts = &read_cnsts[0];
return true;
}
for (unsigned j = 0; j < num; j++)
read_parents[j] = SHRT_MAX;
hash_map<Z3_ast, int> pred_map;
for (unsigned j = 0; j < num; j++){
Z3_ast lhs = 0, rhs = read_cnsts[j];
if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, rhs))) == Z3_OP_IMPLIES){
Z3_app app1 = Z3_to_app(ctx, rhs);
Z3_ast lhs1 = Z3_get_app_arg(ctx, app1, 0);
Z3_ast rhs1 = Z3_get_app_arg(ctx, app1, 1);
if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, lhs1))) == Z3_OP_AND){
Z3_app app2 = Z3_to_app(ctx, lhs1);
int nconjs = Z3_get_app_num_args(ctx, app2);
for (int k = nconjs - 1; k >= 0; --k)
rhs1 = Z3_mk_implies(ctx, Z3_get_app_arg(ctx, app2, k), rhs1);
rhs = rhs1;
}
}
while (1){
Z3_app app = Z3_to_app(ctx, rhs);
Z3_func_decl func = Z3_get_app_decl(ctx, app);
Z3_decl_kind dk = Z3_get_decl_kind(ctx, func);
if (dk == Z3_OP_IMPLIES){
if (lhs){
Z3_ast child = lhs;
if (pred_map.find(child) == pred_map.end()){
read_error << "formula " << j + 1 << ": unknown: " << Z3_ast_to_string(ctx, child);
goto fail;
}
int child_num = pred_map[child];
if (read_parents[child_num] != SHRT_MAX){
read_error << "formula " << j + 1 << ": multiple reference: " << Z3_ast_to_string(ctx, child);
goto fail;
}
read_parents[child_num] = j;
}
lhs = Z3_get_app_arg(ctx, app, 0);
rhs = Z3_get_app_arg(ctx, app, 1);
}
else {
if (!lhs){
read_error << "formula " << j + 1 << ": should be (implies {children} fmla parent)";
goto fail;
}
read_cnsts[j] = lhs;
Z3_ast name = rhs;
if (pred_map.find(name) != pred_map.end()){
read_error << "formula " << j + 1 << ": duplicate symbol";
goto fail;
}
pred_map[name] = j;
break;
}
}
}
for (unsigned j = 0; j < num - 1; j++)
if (read_parents[j] == SHRT_MAX){
read_error << "formula " << j + 1 << ": unreferenced";
goto fail;
}
*_num = num;
*cnsts = &read_cnsts[0];
*parents = &read_parents[0];
return true;
fail:
read_msg = read_error.str();
*error = read_msg.c_str();
return false;
}
}
#if 0
/** Constant reprepresenting a root of a formula tree for tree interpolation */
#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.
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.
\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.
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
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.
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)))
*/
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,
__in unsigned num,
__in_ecount(num) Z3_ast *cnsts,
__in_ecount(num) unsigned *parents,
__in Z3_params options,
__out_ecount(num - 1) Z3_ast *interps,
__out Z3_model *model,
__out Z3_literals *labels,
__in unsigned incremental,
__in unsigned num_theory,
__in_ecount(num_theory) Z3_ast *theory);
#endif

View file

@ -60,6 +60,7 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG); SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0); RETURN_Z3(0);
} }
mk_c(c)->save_ast_trail(r);
RETURN_Z3(of_expr(r)); RETURN_Z3(of_expr(r));
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);
} }
@ -275,6 +276,7 @@ extern "C" {
RESET_ERROR_CODE(); RESET_ERROR_CODE();
CHECK_NON_NULL(f, 0); CHECK_NON_NULL(f, 0);
expr * e = to_func_interp_ref(f)->get_else(); expr * e = to_func_interp_ref(f)->get_else();
mk_c(c)->save_ast_trail(e);
RETURN_Z3(of_expr(e)); RETURN_Z3(of_expr(e));
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);
} }
@ -313,6 +315,7 @@ extern "C" {
LOG_Z3_func_entry_get_value(c, e); LOG_Z3_func_entry_get_value(c, e);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
expr * v = to_func_entry_ref(e)->get_result(); expr * v = to_func_entry_ref(e)->get_result();
mk_c(c)->save_ast_trail(v);
RETURN_Z3(of_expr(v)); RETURN_Z3(of_expr(v));
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);
} }

View file

@ -165,7 +165,10 @@ extern "C" {
} }
for (unsigned i = 0; i < num_bound; ++i) { for (unsigned i = 0; i < num_bound; ++i) {
app* a = to_app(bound[i]); app* a = to_app(bound[i]);
SASSERT(a->get_kind() == AST_APP); if (a->get_kind() != AST_APP) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
symbol s(to_app(a)->get_decl()->get_name()); symbol s(to_app(a)->get_decl()->get_name());
names.push_back(of_symbol(s)); names.push_back(of_symbol(s));
types.push_back(of_sort(mk_c(c)->m().get_sort(a))); types.push_back(of_sort(mk_c(c)->m().get_sort(a)));

View file

@ -40,6 +40,12 @@ extern "C" {
params_ref p = s->m_params; params_ref p = s->m_params;
mk_c(c)->params().get_solver_params(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled); mk_c(c)->params().get_solver_params(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled);
s->m_solver = (*(s->m_solver_factory))(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled, s->m_logic); s->m_solver = (*(s->m_solver_factory))(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled, s->m_logic);
param_descrs r;
s->m_solver->collect_param_descrs(r);
context_params::collect_solver_param_descrs(r);
p.validate(r);
s->m_solver->updt_params(p);
} }
static void init_solver(Z3_context c, Z3_solver s) { static void init_solver(Z3_context c, Z3_solver s) {
@ -101,6 +107,7 @@ extern "C" {
if (!initialized) if (!initialized)
init_solver(c, s); init_solver(c, s);
to_solver_ref(s)->collect_param_descrs(descrs); to_solver_ref(s)->collect_param_descrs(descrs);
context_params::collect_solver_param_descrs(descrs);
if (!initialized) if (!initialized)
to_solver(s)->m_solver = 0; to_solver(s)->m_solver = 0;
descrs.display(buffer); descrs.display(buffer);
@ -118,6 +125,7 @@ extern "C" {
if (!initialized) if (!initialized)
init_solver(c, s); init_solver(c, s);
to_solver_ref(s)->collect_param_descrs(d->m_descrs); to_solver_ref(s)->collect_param_descrs(d->m_descrs);
context_params::collect_solver_param_descrs(d->m_descrs);
if (!initialized) if (!initialized)
to_solver(s)->m_solver = 0; to_solver(s)->m_solver = 0;
Z3_param_descrs r = of_param_descrs(d); Z3_param_descrs r = of_param_descrs(d);
@ -129,14 +137,19 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_solver_set_params(c, s, p); LOG_Z3_solver_set_params(c, s, p);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
if (to_solver(s)->m_solver) { if (to_solver(s)->m_solver) {
bool old_model = to_solver(s)->m_params.get_bool("model", true); bool old_model = to_solver(s)->m_params.get_bool("model", true);
bool new_model = to_param_ref(p).get_bool("model", true); bool new_model = to_param_ref(p).get_bool("model", true);
if (old_model != new_model) if (old_model != new_model)
to_solver_ref(s)->set_produce_models(new_model); to_solver_ref(s)->set_produce_models(new_model);
param_descrs r;
to_solver_ref(s)->collect_param_descrs(r);
context_params::collect_solver_param_descrs(r);
to_param_ref(p).validate(r);
to_solver_ref(s)->updt_params(to_param_ref(p)); to_solver_ref(s)->updt_params(to_param_ref(p));
} }
to_solver(s)->m_params = to_param_ref(p); to_solver(s)->m_params.append(to_param_ref(p));
Z3_CATCH; Z3_CATCH;
} }

View file

@ -40,7 +40,7 @@ extern "C" {
LOG_Z3_pop(c, num_scopes); LOG_Z3_pop(c, num_scopes);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
CHECK_SEARCHING(c); CHECK_SEARCHING(c);
if (num_scopes > mk_c(c)->get_smt_kernel().get_scope_level()) { if (num_scopes > mk_c(c)->get_num_scopes()) {
SET_ERROR_CODE(Z3_IOB); SET_ERROR_CODE(Z3_IOB);
return; return;
} }

View file

@ -222,6 +222,9 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_tactic_using_params(c, t, p); LOG_Z3_tactic_using_params(c, t, p);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
param_descrs r;
to_tactic_ref(t)->collect_param_descrs(r);
to_param_ref(p).validate(r);
tactic * new_t = using_params(to_tactic_ref(t), to_param_ref(p)); tactic * new_t = using_params(to_tactic_ref(t), to_param_ref(p));
RETURN_TACTIC(new_t); RETURN_TACTIC(new_t);
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);
@ -447,6 +450,9 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_tactic_apply_ex(c, t, g, p); LOG_Z3_tactic_apply_ex(c, t, g, p);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
param_descrs pd;
to_tactic_ref(t)->collect_param_descrs(pd);
to_param_ref(p).validate(pd);
Z3_apply_result r = _tactic_apply(c, t, g, to_param_ref(p)); Z3_apply_result r = _tactic_apply(c, t, g, to_param_ref(p));
RETURN_Z3(r); RETURN_Z3(r);
Z3_CATCH_RETURN(0); Z3_CATCH_RETURN(0);

View file

@ -85,6 +85,8 @@ namespace z3 {
friend std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; } friend std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; }
}; };
/** /**
\brief Z3 global configuration object. \brief Z3 global configuration object.
*/ */
@ -204,6 +206,8 @@ namespace z3 {
func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range); func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range); func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
func_decl function(symbol const& name, sort_vector const& domain, sort const& range);
func_decl function(char const * name, sort_vector const& domain, sort const& range);
func_decl function(char const * name, sort const & domain, sort const & range); func_decl function(char const * name, sort const & domain, sort const & range);
func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range); func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range);
func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range); func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range);
@ -267,8 +271,9 @@ namespace z3 {
object(object const & s):m_ctx(s.m_ctx) {} object(object const & s):m_ctx(s.m_ctx) {}
context & ctx() const { return *m_ctx; } context & ctx() const { return *m_ctx; }
void check_error() const { m_ctx->check_error(); } void check_error() const { m_ctx->check_error(); }
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); } friend void check_context(object const & a, object const & b);
}; };
inline void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
class symbol : public object { class symbol : public object {
Z3_symbol m_sym; Z3_symbol m_sym;
@ -280,7 +285,7 @@ namespace z3 {
Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); } Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); }
std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); } std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); }
int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); } int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); }
friend std::ostream & operator<<(std::ostream & out, symbol const & s) { friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
if (s.kind() == Z3_INT_SYMBOL) if (s.kind() == Z3_INT_SYMBOL)
out << "k!" << s.to_int(); out << "k!" << s.to_int();
else else
@ -289,6 +294,7 @@ namespace z3 {
} }
}; };
class params : public object { class params : public object {
Z3_params m_params; Z3_params m_params;
public: public:
@ -307,7 +313,9 @@ namespace z3 {
void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); } void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); }
void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); } void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); }
void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); } void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); }
friend std::ostream & operator<<(std::ostream & out, params const & p) { out << Z3_params_to_string(p.ctx(), p); return out; } friend std::ostream & operator<<(std::ostream & out, params const & p) {
out << Z3_params_to_string(p.ctx(), p); return out;
}
}; };
class ast : public object { class ast : public object {
@ -323,14 +331,19 @@ namespace z3 {
ast & operator=(ast const & s) { Z3_inc_ref(s.ctx(), s.m_ast); if (m_ast) Z3_dec_ref(ctx(), m_ast); m_ctx = s.m_ctx; m_ast = s.m_ast; return *this; } ast & operator=(ast const & s) { Z3_inc_ref(s.ctx(), s.m_ast); if (m_ast) Z3_dec_ref(ctx(), m_ast); m_ctx = s.m_ctx; m_ast = s.m_ast; return *this; }
Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; } Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; }
unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; } unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; }
friend std::ostream & operator<<(std::ostream & out, ast const & n) { out << Z3_ast_to_string(n.ctx(), n.m_ast); return out; } friend std::ostream & operator<<(std::ostream & out, ast const & n) {
out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
}
/** /**
\brief Return true if the ASTs are structurally identical. \brief Return true if the ASTs are structurally identical.
*/ */
friend bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; } friend bool eq(ast const & a, ast const & b);
}; };
inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
/** /**
\brief A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort. \brief A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort.
*/ */
@ -429,6 +442,7 @@ namespace z3 {
expr operator()() const; expr operator()() const;
expr operator()(unsigned n, expr const * args) const; expr operator()(unsigned n, expr const * args) const;
expr operator()(expr_vector const& v) const;
expr operator()(expr const & a) const; expr operator()(expr const & a) const;
expr operator()(int a) const; expr operator()(int a) const;
expr operator()(expr const & a1, expr const & a2) const; expr operator()(expr const & a1, expr const & a2) const;
@ -567,6 +581,7 @@ namespace z3 {
return expr(a.ctx(), r); return expr(a.ctx(), r);
} }
/** /**
\brief Return an expression representing <tt>a and b</tt>. \brief Return an expression representing <tt>a and b</tt>.
@ -582,6 +597,7 @@ namespace z3 {
return expr(a.ctx(), r); return expr(a.ctx(), r);
} }
/** /**
\brief Return an expression representing <tt>a and b</tt>. \brief Return an expression representing <tt>a and b</tt>.
The C++ Boolean value \c b is automatically converted into a Z3 Boolean constant. The C++ Boolean value \c b is automatically converted into a Z3 Boolean constant.
@ -633,21 +649,12 @@ namespace z3 {
a.check_error(); a.check_error();
return expr(a.ctx(), r); return expr(a.ctx(), r);
} }
friend expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); } friend expr implies(expr const & a, bool b);
friend expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); } friend expr implies(bool a, expr const & b);
/** friend expr ite(expr const & c, expr const & t, expr const & e);
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
friend expr distinct(expr_vector const& args);
\pre c.is_bool()
*/
friend expr ite(expr const & c, expr const & t, expr const & e) {
check_context(c, t); check_context(c, e);
assert(c.is_bool());
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
c.check_error();
return expr(c.ctx(), r);
}
friend expr operator==(expr const & a, expr const & b) { friend expr operator==(expr const & a, expr const & b) {
check_context(a, b); check_context(a, b);
@ -711,15 +718,9 @@ namespace z3 {
/** /**
\brief Power operator \brief Power operator
*/ */
friend expr pw(expr const & a, expr const & b) { friend expr pw(expr const & a, expr const & b);
assert(a.is_arith() && b.is_arith()); friend expr pw(expr const & a, int b);
check_context(a, b); friend expr pw(int a, expr const & b);
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
a.check_error();
return expr(a.ctx(), r);
}
friend expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
friend expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
friend expr operator/(expr const & a, expr const & b) { friend expr operator/(expr const & a, expr const & b) {
check_context(a, b); check_context(a, b);
@ -886,6 +887,38 @@ namespace z3 {
expr substitute(expr_vector const& dst); expr substitute(expr_vector const& dst);
}; };
inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
inline expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
inline expr pw(expr const & a, expr const & b) {
assert(a.is_arith() && b.is_arith());
check_context(a, b);
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
a.check_error();
return expr(a.ctx(), r);
}
inline expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
inline expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
/**
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
\pre c.is_bool()
*/
inline expr ite(expr const & c, expr const & t, expr const & e) {
check_context(c, t); check_context(c, e);
assert(c.is_bool());
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
c.check_error();
return expr(c.ctx(), r);
}
/** /**
\brief Wraps a Z3_ast as an expr object. It also checks for errors. \brief Wraps a Z3_ast as an expr object. It also checks for errors.
@ -1062,6 +1095,16 @@ namespace z3 {
array<Z3_app> vars(xs); array<Z3_app> vars(xs);
Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r); Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);
} }
inline expr distinct(expr_vector const& args) {
assert(args.size() > 0);
context& ctx = args[0].ctx();
array<Z3_ast> _args(args);
Z3_ast r = Z3_mk_distinct(ctx, _args.size(), _args.ptr());
ctx.check_error();
return expr(ctx, r);
}
class func_entry : public object { class func_entry : public object {
Z3_func_entry m_entry; Z3_func_entry m_entry;
@ -1305,7 +1348,7 @@ namespace z3 {
expr as_expr() const { expr as_expr() const {
unsigned n = size(); unsigned n = size();
if (n == 0) if (n == 0)
return ctx().bool_val(false); return ctx().bool_val(true);
else if (n == 1) else if (n == 1)
return operator[](0); return operator[](0);
else { else {
@ -1389,22 +1432,28 @@ namespace z3 {
t1.check_error(); t1.check_error();
return tactic(t1.ctx(), r); return tactic(t1.ctx(), r);
} }
friend tactic repeat(tactic const & t, unsigned max=UINT_MAX) { friend tactic repeat(tactic const & t, unsigned max);
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max); friend tactic with(tactic const & t, params const & p);
t.check_error(); friend tactic try_for(tactic const & t, unsigned ms);
return tactic(t.ctx(), r);
}
friend tactic with(tactic const & t, params const & p) {
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
t.check_error();
return tactic(t.ctx(), r);
}
friend tactic try_for(tactic const & t, unsigned ms) {
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
t.check_error();
return tactic(t.ctx(), r);
}
}; };
inline tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
t.check_error();
return tactic(t.ctx(), r);
}
inline tactic with(tactic const & t, params const & p) {
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
t.check_error();
return tactic(t.ctx(), r);
}
inline tactic try_for(tactic const & t, unsigned ms) {
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
t.check_error();
return tactic(t.ctx(), r);
}
class probe : public object { class probe : public object {
Z3_probe m_probe; Z3_probe m_probe;
@ -1516,6 +1565,22 @@ namespace z3 {
inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) { inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
return function(range.ctx().str_symbol(name), arity, domain, range); return function(range.ctx().str_symbol(name), arity, domain, range);
} }
inline func_decl context::function(symbol const& name, sort_vector const& domain, sort const& range) {
array<Z3_sort> args(domain.size());
for (unsigned i = 0; i < domain.size(); i++) {
check_context(domain[i], range);
args[i] = domain[i];
}
Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, domain.size(), args.ptr(), range);
check_error();
return func_decl(*this, f);
}
inline func_decl context::function(char const * name, sort_vector const& domain, sort const& range) {
return function(range.ctx().str_symbol(name), domain, range);
}
inline func_decl context::function(char const * name, sort const & domain, sort const & range) { inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
check_context(domain, range); check_context(domain, range);
@ -1602,6 +1667,16 @@ namespace z3 {
return expr(ctx(), r); return expr(ctx(), r);
} }
inline expr func_decl::operator()(expr_vector const& args) const {
array<Z3_ast> _args(args.size());
for (unsigned i = 0; i < args.size(); i++) {
check_context(*this, args[i]);
_args[i] = args[i];
}
Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
check_error();
return expr(ctx(), r);
}
inline expr func_decl::operator()() const { inline expr func_decl::operator()() const {
Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0); Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
ctx().check_error(); ctx().check_error();

View file

@ -302,8 +302,11 @@ namespace Microsoft.Z3
} }
/// <summary> /// <summary>
/// Create a new finite domain sort. /// Create a new finite domain sort.
/// <returns>The result is a sort</returns>
/// </summary> /// </summary>
/// <param name="name">The name used to identify the sort</param>
/// <param name="size">The size of the sort</param>
public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size) public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size)
{ {
Contract.Requires(name != null); Contract.Requires(name != null);
@ -314,8 +317,13 @@ namespace Microsoft.Z3
} }
/// <summary> /// <summary>
/// Create a new finite domain sort. /// Create a new finite domain sort.
/// <returns>The result is a sort</returns>
/// Elements of the sort are created using <seealso cref="MkNumeral(ulong, Sort)"/>,
/// and the elements range from 0 to <tt>size-1</tt>.
/// </summary> /// </summary>
/// <param name="name">The name used to identify the sort</param>
/// <param name="size">The size of the sort</param>
public FiniteDomainSort MkFiniteDomainSort(string name, ulong size) public FiniteDomainSort MkFiniteDomainSort(string name, ulong size)
{ {
Contract.Ensures(Contract.Result<FiniteDomainSort>() != null); Contract.Ensures(Contract.Result<FiniteDomainSort>() != null);
@ -908,6 +916,8 @@ namespace Microsoft.Z3
CheckContextMatch(t); CheckContextMatch(t);
return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Length, AST.ArrayToNative(t))); return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
} }
#endregion #endregion
#region Arithmetic #region Arithmetic
@ -3513,32 +3523,15 @@ namespace Microsoft.Z3
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The list of all configuration parameters can be obtained using the Z3 executable: /// The list of all configuration parameters can be obtained using the Z3 executable:
/// <c>z3.exe -ini?</c> /// <c>z3.exe -p</c>
/// Only a few configuration parameters are mutable once the context is created. /// Only a few configuration parameters are mutable once the context is created.
/// An exception is thrown when trying to modify an immutable parameter. /// An exception is thrown when trying to modify an immutable parameter.
/// </remarks> /// </remarks>
/// <seealso cref="GetParamValue"/>
public void UpdateParamValue(string id, string value) public void UpdateParamValue(string id, string value)
{ {
Native.Z3_update_param_value(nCtx, id, value); Native.Z3_update_param_value(nCtx, id, value);
} }
/// <summary>
/// Get a configuration parameter.
/// </summary>
/// <remarks>
/// Returns null if the parameter value does not exist.
/// </remarks>
/// <seealso cref="UpdateParamValue"/>
public string GetParamValue(string id)
{
IntPtr res = IntPtr.Zero;
if (Native.Z3_get_param_value(nCtx, id, out res) == 0)
return null;
else
return Marshal.PtrToStringAnsi(res);
}
#endregion #endregion
#region Internal #region Internal
@ -3636,7 +3629,7 @@ namespace Microsoft.Z3
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } } internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal uint refCount = 0; internal long refCount = 0;
/// <summary> /// <summary>
/// Finalizer. /// Finalizer.

View file

@ -99,7 +99,7 @@ namespace Microsoft.Z3
Contract.Requires(Contract.ForAll(args, a => a != null)); Contract.Requires(Contract.ForAll(args, a => a != null));
Context.CheckContextMatch(args); Context.CheckContextMatch(args);
if (args.Length != NumArgs) if (IsApp && args.Length != NumArgs)
throw new Z3Exception("Number of arguments does not match"); throw new Z3Exception("Number of arguments does not match");
NativeObject = Native.Z3_update_term(Context.nCtx, NativeObject, (uint)args.Length, Expr.ArrayToNative(args)); NativeObject = Native.Z3_update_term(Context.nCtx, NativeObject, (uint)args.Length, Expr.ArrayToNative(args));
} }
@ -269,57 +269,66 @@ namespace Microsoft.Z3
/// <summary> /// <summary>
/// Indicates whether the term is the constant true. /// Indicates whether the term is the constant true.
/// </summary> /// </summary>
public bool IsTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TRUE; } } public bool IsTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TRUE; } }
/// <summary> /// <summary>
/// Indicates whether the term is the constant false. /// Indicates whether the term is the constant false.
/// </summary> /// </summary>
public bool IsFalse { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FALSE; } } public bool IsFalse { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FALSE; } }
/// <summary> /// <summary>
/// Indicates whether the term is an equality predicate. /// Indicates whether the term is an equality predicate.
/// </summary> /// </summary>
public bool IsEq { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EQ; } } public bool IsEq { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is an n-ary distinct predicate (every argument is mutually distinct). /// Indicates whether the term is an n-ary distinct predicate (every argument is mutually distinct).
/// </summary> /// </summary>
public bool IsDistinct { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DISTINCT; } } public bool IsDistinct { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DISTINCT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a ternary if-then-else term /// Indicates whether the term is a ternary if-then-else term
/// </summary> /// </summary>
public bool IsITE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ITE; } } public bool IsITE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ITE; } }
/// <summary> /// <summary>
/// Indicates whether the term is an n-ary conjunction /// Indicates whether the term is an n-ary conjunction
/// </summary> /// </summary>
public bool IsAnd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AND; } } public bool IsAnd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AND; } }
/// <summary> /// <summary>
/// Indicates whether the term is an n-ary disjunction /// Indicates whether the term is an n-ary disjunction
/// </summary> /// </summary>
public bool IsOr { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OR; } } public bool IsOr { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OR; } }
/// <summary> /// <summary>
/// Indicates whether the term is an if-and-only-if (Boolean equivalence, binary) /// Indicates whether the term is an if-and-only-if (Boolean equivalence, binary)
/// </summary> /// </summary>
public bool IsIff { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IFF; } } public bool IsIff { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IFF; } }
/// <summary> /// <summary>
/// Indicates whether the term is an exclusive or /// Indicates whether the term is an exclusive or
/// </summary> /// </summary>
public bool IsXor { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR; } } public bool IsXor { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a negation /// Indicates whether the term is a negation
/// </summary> /// </summary>
public bool IsNot { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_NOT; } } public bool IsNot { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_NOT; } }
/// <summary> /// <summary>
/// Indicates whether the term is an implication /// Indicates whether the term is an implication
/// </summary> /// </summary>
public bool IsImplies { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IMPLIES; } } public bool IsImplies { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IMPLIES; } }
#endregion
#region Interpolation
/// <summary>
/// Indicates whether the term is marked for interpolation.
/// </summary>
/// <remarks></remarks>
public bool IsInterpolant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INTERP; } }
#endregion #endregion
#region Arithmetic Terms #region Arithmetic Terms
@ -346,82 +355,82 @@ namespace Microsoft.Z3
/// <summary> /// <summary>
/// Indicates whether the term is an arithmetic numeral. /// Indicates whether the term is an arithmetic numeral.
/// </summary> /// </summary>
public bool IsArithmeticNumeral { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ANUM; } } public bool IsArithmeticNumeral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ANUM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a less-than-or-equal /// Indicates whether the term is a less-than-or-equal
/// </summary> /// </summary>
public bool IsLE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LE; } } public bool IsLE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a greater-than-or-equal /// Indicates whether the term is a greater-than-or-equal
/// </summary> /// </summary>
public bool IsGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GE; } } public bool IsGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a less-than /// Indicates whether the term is a less-than
/// </summary> /// </summary>
public bool IsLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LT; } } public bool IsLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a greater-than /// Indicates whether the term is a greater-than
/// </summary> /// </summary>
public bool IsGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GT; } } public bool IsGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GT; } }
/// <summary> /// <summary>
/// Indicates whether the term is addition (binary) /// Indicates whether the term is addition (binary)
/// </summary> /// </summary>
public bool IsAdd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD; } } public bool IsAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD; } }
/// <summary> /// <summary>
/// Indicates whether the term is subtraction (binary) /// Indicates whether the term is subtraction (binary)
/// </summary> /// </summary>
public bool IsSub { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB; } } public bool IsSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB; } }
/// <summary> /// <summary>
/// Indicates whether the term is a unary minus /// Indicates whether the term is a unary minus
/// </summary> /// </summary>
public bool IsUMinus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UMINUS; } } public bool IsUMinus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UMINUS; } }
/// <summary> /// <summary>
/// Indicates whether the term is multiplication (binary) /// Indicates whether the term is multiplication (binary)
/// </summary> /// </summary>
public bool IsMul { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MUL; } } public bool IsMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MUL; } }
/// <summary> /// <summary>
/// Indicates whether the term is division (binary) /// Indicates whether the term is division (binary)
/// </summary> /// </summary>
public bool IsDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DIV; } } public bool IsDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DIV; } }
/// <summary> /// <summary>
/// Indicates whether the term is integer division (binary) /// Indicates whether the term is integer division (binary)
/// </summary> /// </summary>
public bool IsIDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IDIV; } } public bool IsIDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IDIV; } }
/// <summary> /// <summary>
/// Indicates whether the term is remainder (binary) /// Indicates whether the term is remainder (binary)
/// </summary> /// </summary>
public bool IsRemainder { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REM; } } public bool IsRemainder { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REM; } }
/// <summary> /// <summary>
/// Indicates whether the term is modulus (binary) /// Indicates whether the term is modulus (binary)
/// </summary> /// </summary>
public bool IsModulus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MOD; } } public bool IsModulus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MOD; } }
/// <summary> /// <summary>
/// Indicates whether the term is a coercion of integer to real (unary) /// Indicates whether the term is a coercion of integer to real (unary)
/// </summary> /// </summary>
public bool IsIntToReal { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_REAL; } } public bool IsIntToReal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_REAL; } }
/// <summary> /// <summary>
/// Indicates whether the term is a coercion of real to integer (unary) /// Indicates whether the term is a coercion of real to integer (unary)
/// </summary> /// </summary>
public bool IsRealToInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_INT; } } public bool IsRealToInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_INT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a check that tests whether a real is integral (unary) /// Indicates whether the term is a check that tests whether a real is integral (unary)
/// </summary> /// </summary>
public bool IsRealIsInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IS_INT; } } public bool IsRealIsInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IS_INT; } }
#endregion #endregion
#region Array Terms #region Array Terms
@ -443,64 +452,64 @@ namespace Microsoft.Z3
/// </summary> /// </summary>
/// <remarks>It satisfies select(store(a,i,v),j) = if i = j then v else select(a,j). /// <remarks>It satisfies select(store(a,i,v),j) = if i = j then v else select(a,j).
/// Array store takes at least 3 arguments. </remarks> /// Array store takes at least 3 arguments. </remarks>
public bool IsStore { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_STORE; } } public bool IsStore { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_STORE; } }
/// <summary> /// <summary>
/// Indicates whether the term is an array select. /// Indicates whether the term is an array select.
/// </summary> /// </summary>
public bool IsSelect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SELECT; } } public bool IsSelect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SELECT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a constant array. /// Indicates whether the term is a constant array.
/// </summary> /// </summary>
/// <remarks>For example, select(const(v),i) = v holds for every v and i. The function is unary.</remarks> /// <remarks>For example, select(const(v),i) = v holds for every v and i. The function is unary.</remarks>
public bool IsConstantArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONST_ARRAY; } } public bool IsConstantArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONST_ARRAY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a default array. /// Indicates whether the term is a default array.
/// </summary> /// </summary>
/// <remarks>For example default(const(v)) = v. The function is unary.</remarks> /// <remarks>For example default(const(v)) = v. The function is unary.</remarks>
public bool IsDefaultArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; } } public bool IsDefaultArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; } }
/// <summary> /// <summary>
/// Indicates whether the term is an array map. /// Indicates whether the term is an array map.
/// </summary> /// </summary>
/// <remarks>It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i.</remarks> /// <remarks>It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i.</remarks>
public bool IsArrayMap { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_MAP; } } public bool IsArrayMap { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_MAP; } }
/// <summary> /// <summary>
/// Indicates whether the term is an as-array term. /// Indicates whether the term is an as-array term.
/// </summary> /// </summary>
/// <remarks>An as-array term is n array value that behaves as the function graph of the /// <remarks>An as-array term is n array value that behaves as the function graph of the
/// function passed as parameter.</remarks> /// function passed as parameter.</remarks>
public bool IsAsArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AS_ARRAY; } } public bool IsAsArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AS_ARRAY; } }
#endregion #endregion
#region Set Terms #region Set Terms
/// <summary> /// <summary>
/// Indicates whether the term is set union /// Indicates whether the term is set union
/// </summary> /// </summary>
public bool IsSetUnion { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_UNION; } } public bool IsSetUnion { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_UNION; } }
/// <summary> /// <summary>
/// Indicates whether the term is set intersection /// Indicates whether the term is set intersection
/// </summary> /// </summary>
public bool IsSetIntersect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_INTERSECT; } } public bool IsSetIntersect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_INTERSECT; } }
/// <summary> /// <summary>
/// Indicates whether the term is set difference /// Indicates whether the term is set difference
/// </summary> /// </summary>
public bool IsSetDifference { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; } } public bool IsSetDifference { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; } }
/// <summary> /// <summary>
/// Indicates whether the term is set complement /// Indicates whether the term is set complement
/// </summary> /// </summary>
public bool IsSetComplement { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; } } public bool IsSetComplement { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; } }
/// <summary> /// <summary>
/// Indicates whether the term is set subset /// Indicates whether the term is set subset
/// </summary> /// </summary>
public bool IsSetSubset { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_SUBSET; } } public bool IsSetSubset { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_SUBSET; } }
#endregion #endregion
#region Bit-vector terms #region Bit-vector terms
@ -515,266 +524,266 @@ namespace Microsoft.Z3
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector numeral /// Indicates whether the term is a bit-vector numeral
/// </summary> /// </summary>
public bool IsBVNumeral { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNUM; } } public bool IsBVNumeral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNUM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a one-bit bit-vector with value one /// Indicates whether the term is a one-bit bit-vector with value one
/// </summary> /// </summary>
public bool IsBVBitOne { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT1; } } public bool IsBVBitOne { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT1; } }
/// <summary> /// <summary>
/// Indicates whether the term is a one-bit bit-vector with value zero /// Indicates whether the term is a one-bit bit-vector with value zero
/// </summary> /// </summary>
public bool IsBVBitZero { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT0; } } public bool IsBVBitZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT0; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector unary minus /// Indicates whether the term is a bit-vector unary minus
/// </summary> /// </summary>
public bool IsBVUMinus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNEG; } } public bool IsBVUMinus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNEG; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector addition (binary) /// Indicates whether the term is a bit-vector addition (binary)
/// </summary> /// </summary>
public bool IsBVAdd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BADD; } } public bool IsBVAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BADD; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector subtraction (binary) /// Indicates whether the term is a bit-vector subtraction (binary)
/// </summary> /// </summary>
public bool IsBVSub { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSUB; } } public bool IsBVSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSUB; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector multiplication (binary) /// Indicates whether the term is a bit-vector multiplication (binary)
/// </summary> /// </summary>
public bool IsBVMul { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BMUL; } } public bool IsBVMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BMUL; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed division (binary) /// Indicates whether the term is a bit-vector signed division (binary)
/// </summary> /// </summary>
public bool IsBVSDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV; } } public bool IsBVSDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector unsigned division (binary) /// Indicates whether the term is a bit-vector unsigned division (binary)
/// </summary> /// </summary>
public bool IsBVUDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV; } } public bool IsBVUDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed remainder (binary) /// Indicates whether the term is a bit-vector signed remainder (binary)
/// </summary> /// </summary>
public bool IsBVSRem { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM; } } public bool IsBVSRem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector unsigned remainder (binary) /// Indicates whether the term is a bit-vector unsigned remainder (binary)
/// </summary> /// </summary>
public bool IsBVURem { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM; } } public bool IsBVURem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed modulus /// Indicates whether the term is a bit-vector signed modulus
/// </summary> /// </summary>
public bool IsBVSMod { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD; } } public bool IsBVSMod { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed division by zero /// Indicates whether the term is a bit-vector signed division by zero
/// </summary> /// </summary>
internal bool IsBVSDiv0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV0; } } internal bool IsBVSDiv0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV0; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector unsigned division by zero /// Indicates whether the term is a bit-vector unsigned division by zero
/// </summary> /// </summary>
internal bool IsBVUDiv0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV0; } } internal bool IsBVUDiv0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV0; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed remainder by zero /// Indicates whether the term is a bit-vector signed remainder by zero
/// </summary> /// </summary>
internal bool IsBVSRem0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM0; } } internal bool IsBVSRem0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM0; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector unsigned remainder by zero /// Indicates whether the term is a bit-vector unsigned remainder by zero
/// </summary> /// </summary>
internal bool IsBVURem0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM0; } } internal bool IsBVURem0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM0; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector signed modulus by zero /// Indicates whether the term is a bit-vector signed modulus by zero
/// </summary> /// </summary>
internal bool IsBVSMod0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD0; } } internal bool IsBVSMod0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD0; } }
/// <summary> /// <summary>
/// Indicates whether the term is an unsigned bit-vector less-than-or-equal /// Indicates whether the term is an unsigned bit-vector less-than-or-equal
/// </summary> /// </summary>
public bool IsBVULE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULEQ; } } public bool IsBVULE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is a signed bit-vector less-than-or-equal /// Indicates whether the term is a signed bit-vector less-than-or-equal
/// </summary> /// </summary>
public bool IsBVSLE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLEQ; } } public bool IsBVSLE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is an unsigned bit-vector greater-than-or-equal /// Indicates whether the term is an unsigned bit-vector greater-than-or-equal
/// </summary> /// </summary>
public bool IsBVUGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGEQ; } } public bool IsBVUGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is a signed bit-vector greater-than-or-equal /// Indicates whether the term is a signed bit-vector greater-than-or-equal
/// </summary> /// </summary>
public bool IsBVSGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGEQ; } } public bool IsBVSGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is an unsigned bit-vector less-than /// Indicates whether the term is an unsigned bit-vector less-than
/// </summary> /// </summary>
public bool IsBVULT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULT; } } public bool IsBVULT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a signed bit-vector less-than /// Indicates whether the term is a signed bit-vector less-than
/// </summary> /// </summary>
public bool IsBVSLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLT; } } public bool IsBVSLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLT; } }
/// <summary> /// <summary>
/// Indicates whether the term is an unsigned bit-vector greater-than /// Indicates whether the term is an unsigned bit-vector greater-than
/// </summary> /// </summary>
public bool IsBVUGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGT; } } public bool IsBVUGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a signed bit-vector greater-than /// Indicates whether the term is a signed bit-vector greater-than
/// </summary> /// </summary>
public bool IsBVSGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGT; } } public bool IsBVSGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise AND /// Indicates whether the term is a bit-wise AND
/// </summary> /// </summary>
public bool IsBVAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BAND; } } public bool IsBVAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BAND; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise OR /// Indicates whether the term is a bit-wise OR
/// </summary> /// </summary>
public bool IsBVOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BOR; } } public bool IsBVOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise NOT /// Indicates whether the term is a bit-wise NOT
/// </summary> /// </summary>
public bool IsBVNOT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOT; } } public bool IsBVNOT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise XOR /// Indicates whether the term is a bit-wise XOR
/// </summary> /// </summary>
public bool IsBVXOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXOR; } } public bool IsBVXOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise NAND /// Indicates whether the term is a bit-wise NAND
/// </summary> /// </summary>
public bool IsBVNAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNAND; } } public bool IsBVNAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNAND; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise NOR /// Indicates whether the term is a bit-wise NOR
/// </summary> /// </summary>
public bool IsBVNOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOR; } } public bool IsBVNOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-wise XNOR /// Indicates whether the term is a bit-wise XNOR
/// </summary> /// </summary>
public bool IsBVXNOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXNOR; } } public bool IsBVXNOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXNOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector concatenation (binary) /// Indicates whether the term is a bit-vector concatenation (binary)
/// </summary> /// </summary>
public bool IsBVConcat { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONCAT; } } public bool IsBVConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONCAT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector sign extension /// Indicates whether the term is a bit-vector sign extension
/// </summary> /// </summary>
public bool IsBVSignExtension { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SIGN_EXT; } } public bool IsBVSignExtension { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SIGN_EXT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector zero extension /// Indicates whether the term is a bit-vector zero extension
/// </summary> /// </summary>
public bool IsBVZeroExtension { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ZERO_EXT; } } public bool IsBVZeroExtension { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ZERO_EXT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector extraction /// Indicates whether the term is a bit-vector extraction
/// </summary> /// </summary>
public bool IsBVExtract { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXTRACT; } } public bool IsBVExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXTRACT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector repetition /// Indicates whether the term is a bit-vector repetition
/// </summary> /// </summary>
public bool IsBVRepeat { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REPEAT; } } public bool IsBVRepeat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REPEAT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector reduce OR /// Indicates whether the term is a bit-vector reduce OR
/// </summary> /// </summary>
public bool IsBVReduceOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDOR; } } public bool IsBVReduceOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDOR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector reduce AND /// Indicates whether the term is a bit-vector reduce AND
/// </summary> /// </summary>
public bool IsBVReduceAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDAND; } } public bool IsBVReduceAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDAND; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector comparison /// Indicates whether the term is a bit-vector comparison
/// </summary> /// </summary>
public bool IsBVComp { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BCOMP; } } public bool IsBVComp { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BCOMP; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector shift left /// Indicates whether the term is a bit-vector shift left
/// </summary> /// </summary>
public bool IsBVShiftLeft { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSHL; } } public bool IsBVShiftLeft { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSHL; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector logical shift right /// Indicates whether the term is a bit-vector logical shift right
/// </summary> /// </summary>
public bool IsBVShiftRightLogical { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BLSHR; } } public bool IsBVShiftRightLogical { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BLSHR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector arithmetic shift left /// Indicates whether the term is a bit-vector arithmetic shift left
/// </summary> /// </summary>
public bool IsBVShiftRightArithmetic { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BASHR; } } public bool IsBVShiftRightArithmetic { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BASHR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector rotate left /// Indicates whether the term is a bit-vector rotate left
/// </summary> /// </summary>
public bool IsBVRotateLeft { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_LEFT; } } public bool IsBVRotateLeft { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_LEFT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector rotate right /// Indicates whether the term is a bit-vector rotate right
/// </summary> /// </summary>
public bool IsBVRotateRight { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; } } public bool IsBVRotateRight { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector rotate left (extended) /// Indicates whether the term is a bit-vector rotate left (extended)
/// </summary> /// </summary>
/// <remarks>Similar to Z3_OP_ROTATE_LEFT, but it is a binary operator instead of a parametric one.</remarks> /// <remarks>Similar to Z3_OP_ROTATE_LEFT, but it is a binary operator instead of a parametric one.</remarks>
public bool IsBVRotateLeftExtended { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; } } public bool IsBVRotateLeftExtended { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector rotate right (extended) /// Indicates whether the term is a bit-vector rotate right (extended)
/// </summary> /// </summary>
/// <remarks>Similar to Z3_OP_ROTATE_RIGHT, but it is a binary operator instead of a parametric one.</remarks> /// <remarks>Similar to Z3_OP_ROTATE_RIGHT, but it is a binary operator instead of a parametric one.</remarks>
public bool IsBVRotateRightExtended { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; } } public bool IsBVRotateRightExtended { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a coercion from integer to bit-vector /// Indicates whether the term is a coercion from integer to bit-vector
/// </summary> /// </summary>
/// <remarks>This function is not supported by the decision procedures. Only the most /// <remarks>This function is not supported by the decision procedures. Only the most
/// rudimentary simplification rules are applied to this function.</remarks> /// rudimentary simplification rules are applied to this function.</remarks>
public bool IsIntToBV { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INT2BV; } } public bool IsIntToBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INT2BV; } }
/// <summary> /// <summary>
/// Indicates whether the term is a coercion from bit-vector to integer /// Indicates whether the term is a coercion from bit-vector to integer
/// </summary> /// </summary>
/// <remarks>This function is not supported by the decision procedures. Only the most /// <remarks>This function is not supported by the decision procedures. Only the most
/// rudimentary simplification rules are applied to this function.</remarks> /// rudimentary simplification rules are applied to this function.</remarks>
public bool IsBVToInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BV2INT; } } public bool IsBVToInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BV2INT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector carry /// Indicates whether the term is a bit-vector carry
/// </summary> /// </summary>
/// <remarks>Compute the carry bit in a full-adder. The meaning is given by the /// <remarks>Compute the carry bit in a full-adder. The meaning is given by the
/// equivalence (carry l1 l2 l3) &lt;=&gt; (or (and l1 l2) (and l1 l3) (and l2 l3)))</remarks> /// equivalence (carry l1 l2 l3) &lt;=&gt; (or (and l1 l2) (and l1 l3) (and l2 l3)))</remarks>
public bool IsBVCarry { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CARRY; } } public bool IsBVCarry { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CARRY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a bit-vector ternary XOR /// Indicates whether the term is a bit-vector ternary XOR
/// </summary> /// </summary>
/// <remarks>The meaning is given by the equivalence (xor3 l1 l2 l3) &lt;=&gt; (xor (xor l1 l2) l3)</remarks> /// <remarks>The meaning is given by the equivalence (xor3 l1 l2 l3) &lt;=&gt; (xor (xor l1 l2) l3)</remarks>
public bool IsBVXOR3 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR3; } } public bool IsBVXOR3 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR3; } }
#endregion #endregion
@ -783,14 +792,14 @@ namespace Microsoft.Z3
/// Indicates whether the term is a label (used by the Boogie Verification condition generator). /// Indicates whether the term is a label (used by the Boogie Verification condition generator).
/// </summary> /// </summary>
/// <remarks>The label has two parameters, a string and a Boolean polarity. It takes one argument, a formula.</remarks> /// <remarks>The label has two parameters, a string and a Boolean polarity. It takes one argument, a formula.</remarks>
public bool IsLabel { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL; } } public bool IsLabel { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL; } }
/// <summary> /// <summary>
/// Indicates whether the term is a label literal (used by the Boogie Verification condition generator). /// Indicates whether the term is a label literal (used by the Boogie Verification condition generator).
/// </summary> /// </summary>
/// <remarks>A label literal has a set of string parameters. It takes no arguments.</remarks> /// <remarks>A label literal has a set of string parameters. It takes no arguments.</remarks>
public bool IsLabelLit { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL_LIT; } } public bool IsLabelLit { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL_LIT; } }
#endregion #endregion
#region Proof Terms #region Proof Terms
/// <summary> /// <summary>
@ -798,22 +807,22 @@ namespace Microsoft.Z3
/// </summary> /// </summary>
/// <remarks>This binary predicate is used in proof terms. /// <remarks>This binary predicate is used in proof terms.
/// It captures equisatisfiability and equivalence modulo renamings.</remarks> /// It captures equisatisfiability and equivalence modulo renamings.</remarks>
public bool IsOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OEQ; } } public bool IsOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is a Proof for the expression 'true'. /// Indicates whether the term is a Proof for the expression 'true'.
/// </summary> /// </summary>
public bool IsProofTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRUE; } } public bool IsProofTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRUE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for a fact asserted by the user. /// Indicates whether the term is a proof for a fact asserted by the user.
/// </summary> /// </summary>
public bool IsProofAsserted { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ASSERTED; } } public bool IsProofAsserted { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ASSERTED; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for a fact (tagged as goal) asserted by the user. /// Indicates whether the term is a proof for a fact (tagged as goal) asserted by the user.
/// </summary> /// </summary>
public bool IsProofGoal { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_GOAL; } } public bool IsProofGoal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_GOAL; } }
/// <summary> /// <summary>
/// Indicates whether the term is proof via modus ponens /// Indicates whether the term is proof via modus ponens
@ -824,7 +833,7 @@ namespace Microsoft.Z3
/// T2: (implies p q) /// T2: (implies p q)
/// [mp T1 T2]: q /// [mp T1 T2]: q
/// The second antecedents may also be a proof for (iff p q).</remarks> /// The second antecedents may also be a proof for (iff p q).</remarks>
public bool IsProofModusPonens { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; } } public bool IsProofModusPonens { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for (R t t), where R is a reflexive relation. /// Indicates whether the term is a proof for (R t t), where R is a reflexive relation.
@ -833,7 +842,7 @@ namespace Microsoft.Z3
/// The only reflexive relations that are used are /// The only reflexive relations that are used are
/// equivalence modulo namings, equality and equivalence. /// equivalence modulo namings, equality and equivalence.
/// That is, R is either '~', '=' or 'iff'.</remarks> /// That is, R is either '~', '=' or 'iff'.</remarks>
public bool IsProofReflexivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } } public bool IsProofReflexivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } }
/// <summary> /// <summary>
/// Indicates whether the term is proof by symmetricity of a relation /// Indicates whether the term is proof by symmetricity of a relation
@ -844,7 +853,7 @@ namespace Microsoft.Z3
/// [symmetry T1]: (R s t) /// [symmetry T1]: (R s t)
/// T1 is the antecedent of this proof object. /// T1 is the antecedent of this proof object.
/// </remarks> /// </remarks>
public bool IsProofSymmetry { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } } public bool IsProofSymmetry { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by transitivity of a relation /// Indicates whether the term is a proof by transitivity of a relation
@ -856,7 +865,7 @@ namespace Microsoft.Z3
/// T2: (R s u) /// T2: (R s u)
/// [trans T1 T2]: (R t u) /// [trans T1 T2]: (R t u)
/// </remarks> /// </remarks>
public bool IsProofTransitivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } } public bool IsProofTransitivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by condensed transitivity of a relation /// Indicates whether the term is a proof by condensed transitivity of a relation
@ -877,7 +886,7 @@ namespace Microsoft.Z3
/// if there is a path from s to t, if we view every /// if there is a path from s to t, if we view every
/// antecedent (R a b) as an edge between a and b. /// antecedent (R a b) as an edge between a and b.
/// </remarks> /// </remarks>
public bool IsProofTransitivityStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } } public bool IsProofTransitivityStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } }
/// <summary> /// <summary>
@ -891,7 +900,7 @@ namespace Microsoft.Z3
/// Remark: if t_i == s_i, then the antecedent Ti is suppressed. /// Remark: if t_i == s_i, then the antecedent Ti is suppressed.
/// That is, reflexivity proofs are supressed to save space. /// That is, reflexivity proofs are supressed to save space.
/// </remarks> /// </remarks>
public bool IsProofMonotonicity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } } public bool IsProofMonotonicity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a quant-intro proof /// Indicates whether the term is a quant-intro proof
@ -901,7 +910,7 @@ namespace Microsoft.Z3
/// T1: (~ p q) /// T1: (~ p q)
/// [quant-intro T1]: (~ (forall (x) p) (forall (x) q)) /// [quant-intro T1]: (~ (forall (x) p) (forall (x) q))
/// </remarks> /// </remarks>
public bool IsProofQuantIntro { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } } public bool IsProofQuantIntro { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } }
/// <summary> /// <summary>
/// Indicates whether the term is a distributivity proof object. /// Indicates whether the term is a distributivity proof object.
@ -919,7 +928,7 @@ namespace Microsoft.Z3
/// Remark. This rule is used by the CNF conversion pass and /// Remark. This rule is used by the CNF conversion pass and
/// instantiated by f = or, and g = and. /// instantiated by f = or, and g = and.
/// </remarks> /// </remarks>
public bool IsProofDistributivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } } public bool IsProofDistributivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by elimination of AND /// Indicates whether the term is a proof by elimination of AND
@ -929,7 +938,7 @@ namespace Microsoft.Z3
/// T1: (and l_1 ... l_n) /// T1: (and l_1 ... l_n)
/// [and-elim T1]: l_i /// [and-elim T1]: l_i
/// </remarks> /// </remarks>
public bool IsProofAndElimination { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } } public bool IsProofAndElimination { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by eliminiation of not-or /// Indicates whether the term is a proof by eliminiation of not-or
@ -939,7 +948,7 @@ namespace Microsoft.Z3
/// T1: (not (or l_1 ... l_n)) /// T1: (not (or l_1 ... l_n))
/// [not-or-elim T1]: (not l_i) /// [not-or-elim T1]: (not l_i)
/// </remarks> /// </remarks>
public bool IsProofOrElimination { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } } public bool IsProofOrElimination { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by rewriting /// Indicates whether the term is a proof by rewriting
@ -958,7 +967,7 @@ namespace Microsoft.Z3
/// (= (+ x 1 2) (+ 3 x)) /// (= (+ x 1 2) (+ 3 x))
/// (iff (or x false) x) /// (iff (or x false) x)
/// </remarks> /// </remarks>
public bool IsProofRewrite { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE; } } public bool IsProofRewrite { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by rewriting /// Indicates whether the term is a proof by rewriting
@ -974,7 +983,7 @@ namespace Microsoft.Z3
/// - When converting bit-vectors to Booleans (BIT2BOOL=true) /// - When converting bit-vectors to Booleans (BIT2BOOL=true)
/// - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true) /// - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true)
/// </remarks> /// </remarks>
public bool IsProofRewriteStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } } public bool IsProofRewriteStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for pulling quantifiers out. /// Indicates whether the term is a proof for pulling quantifiers out.
@ -982,7 +991,7 @@ namespace Microsoft.Z3
/// <remarks> /// <remarks>
/// A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. /// A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents.
/// </remarks> /// </remarks>
public bool IsProofPullQuant { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } } public bool IsProofPullQuant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for pulling quantifiers out. /// Indicates whether the term is a proof for pulling quantifiers out.
@ -992,7 +1001,7 @@ namespace Microsoft.Z3
/// This proof object is only used if the parameter PROOF_MODE is 1. /// This proof object is only used if the parameter PROOF_MODE is 1.
/// This proof object has no antecedents /// This proof object has no antecedents
/// </remarks> /// </remarks>
public bool IsProofPullQuantStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } } public bool IsProofPullQuantStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for pushing quantifiers in. /// Indicates whether the term is a proof for pushing quantifiers in.
@ -1005,7 +1014,7 @@ namespace Microsoft.Z3
/// (forall (x_1 ... x_m) p_n[x_1 ... x_m]))) /// (forall (x_1 ... x_m) p_n[x_1 ... x_m])))
/// This proof object has no antecedents /// This proof object has no antecedents
/// </remarks> /// </remarks>
public bool IsProofPushQuant { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } } public bool IsProofPushQuant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for elimination of unused variables. /// Indicates whether the term is a proof for elimination of unused variables.
@ -1017,7 +1026,7 @@ namespace Microsoft.Z3
/// It is used to justify the elimination of unused variables. /// It is used to justify the elimination of unused variables.
/// This proof object has no antecedents. /// This proof object has no antecedents.
/// </remarks> /// </remarks>
public bool IsProofElimUnusedVars { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } } public bool IsProofElimUnusedVars { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for destructive equality resolution /// Indicates whether the term is a proof for destructive equality resolution
@ -1031,7 +1040,7 @@ namespace Microsoft.Z3
/// ///
/// Several variables can be eliminated simultaneously. /// Several variables can be eliminated simultaneously.
/// </remarks> /// </remarks>
public bool IsProofDER { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DER; } } public bool IsProofDER { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DER; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for quantifier instantiation /// Indicates whether the term is a proof for quantifier instantiation
@ -1039,13 +1048,13 @@ namespace Microsoft.Z3
/// <remarks> /// <remarks>
/// A proof of (or (not (forall (x) (P x))) (P a)) /// A proof of (or (not (forall (x) (P x))) (P a))
/// </remarks> /// </remarks>
public bool IsProofQuantInst { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } } public bool IsProofQuantInst { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } }
/// <summary> /// <summary>
/// Indicates whether the term is a hypthesis marker. /// Indicates whether the term is a hypthesis marker.
/// </summary> /// </summary>
/// <remarks>Mark a hypothesis in a natural deduction style proof.</remarks> /// <remarks>Mark a hypothesis in a natural deduction style proof.</remarks>
public bool IsProofHypothesis { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } } public bool IsProofHypothesis { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by lemma /// Indicates whether the term is a proof by lemma
@ -1058,7 +1067,7 @@ namespace Microsoft.Z3
/// It converts the proof in a proof for (or (not l_1) ... (not l_n)), /// It converts the proof in a proof for (or (not l_1) ... (not l_n)),
/// when T1 contains the hypotheses: l_1, ..., l_n. /// when T1 contains the hypotheses: l_1, ..., l_n.
/// </remarks> /// </remarks>
public bool IsProofLemma { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_LEMMA; } } public bool IsProofLemma { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_LEMMA; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by unit resolution /// Indicates whether the term is a proof by unit resolution
@ -1070,7 +1079,7 @@ namespace Microsoft.Z3
/// T(n+1): (not l_n) /// T(n+1): (not l_n)
/// [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m') /// [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m')
/// </remarks> /// </remarks>
public bool IsProofUnitResolution { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } } public bool IsProofUnitResolution { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by iff-true /// Indicates whether the term is a proof by iff-true
@ -1079,7 +1088,7 @@ namespace Microsoft.Z3
/// T1: p /// T1: p
/// [iff-true T1]: (iff p true) /// [iff-true T1]: (iff p true)
/// </remarks> /// </remarks>
public bool IsProofIFFTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; } } public bool IsProofIFFTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by iff-false /// Indicates whether the term is a proof by iff-false
@ -1088,7 +1097,7 @@ namespace Microsoft.Z3
/// T1: (not p) /// T1: (not p)
/// [iff-false T1]: (iff p false) /// [iff-false T1]: (iff p false)
/// </remarks> /// </remarks>
public bool IsProofIFFFalse { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } } public bool IsProofIFFFalse { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by commutativity /// Indicates whether the term is a proof by commutativity
@ -1101,7 +1110,7 @@ namespace Microsoft.Z3
/// This proof object has no antecedents. /// This proof object has no antecedents.
/// Remark: if f is bool, then = is iff. /// Remark: if f is bool, then = is iff.
/// </remarks> /// </remarks>
public bool IsProofCommutativity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } } public bool IsProofCommutativity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for Tseitin-like axioms /// Indicates whether the term is a proof for Tseitin-like axioms
@ -1137,7 +1146,7 @@ namespace Microsoft.Z3
/// unfolding the Boolean connectives in the axioms a small /// unfolding the Boolean connectives in the axioms a small
/// bounded number of steps (=3). /// bounded number of steps (=3).
/// </remarks> /// </remarks>
public bool IsProofDefAxiom { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } } public bool IsProofDefAxiom { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for introduction of a name /// Indicates whether the term is a proof for introduction of a name
@ -1160,7 +1169,7 @@ namespace Microsoft.Z3
/// Otherwise: /// Otherwise:
/// [def-intro]: (= n e) /// [def-intro]: (= n e)
/// </remarks> /// </remarks>
public bool IsProofDefIntro { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } } public bool IsProofDefIntro { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for application of a definition /// Indicates whether the term is a proof for application of a definition
@ -1170,7 +1179,7 @@ namespace Microsoft.Z3
/// F is 'equivalent' to n, given that T1 is a proof that /// F is 'equivalent' to n, given that T1 is a proof that
/// n is a name for F. /// n is a name for F.
/// </remarks> /// </remarks>
public bool IsProofApplyDef { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } } public bool IsProofApplyDef { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof iff-oeq /// Indicates whether the term is a proof iff-oeq
@ -1179,7 +1188,7 @@ namespace Microsoft.Z3
/// T1: (iff p q) /// T1: (iff p q)
/// [iff~ T1]: (~ p q) /// [iff~ T1]: (~ p q)
/// </remarks> /// </remarks>
public bool IsProofIFFOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } } public bool IsProofIFFOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for a positive NNF step /// Indicates whether the term is a proof for a positive NNF step
@ -1207,7 +1216,7 @@ namespace Microsoft.Z3
/// NNF_NEG furthermore handles the case where negation is pushed /// NNF_NEG furthermore handles the case where negation is pushed
/// over Boolean connectives 'and' and 'or'. /// over Boolean connectives 'and' and 'or'.
/// </remarks> /// </remarks>
public bool IsProofNNFPos { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_POS; } } public bool IsProofNNFPos { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_POS; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for a negative NNF step /// Indicates whether the term is a proof for a negative NNF step
@ -1232,7 +1241,7 @@ namespace Microsoft.Z3
/// [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2)) /// [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2))
/// (and (or r_1 r_2) (or r_1' r_2'))) /// (and (or r_1 r_2) (or r_1' r_2')))
/// </remarks> /// </remarks>
public bool IsProofNNFNeg { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } } public bool IsProofNNFNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form. /// Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form.
@ -1244,7 +1253,7 @@ namespace Microsoft.Z3
/// ///
/// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. /// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO.
/// </remarks> /// </remarks>
public bool IsProofNNFStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } } public bool IsProofNNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form. /// Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form.
@ -1254,7 +1263,7 @@ namespace Microsoft.Z3
/// This proof object is only used if the parameter PROOF_MODE is 1. /// This proof object is only used if the parameter PROOF_MODE is 1.
/// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. /// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO.
/// </remarks> /// </remarks>
public bool IsProofCNFStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } } public bool IsProofCNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for a Skolemization step /// Indicates whether the term is a proof for a Skolemization step
@ -1267,7 +1276,7 @@ namespace Microsoft.Z3
/// ///
/// This proof object has no antecedents. /// This proof object has no antecedents.
/// </remarks> /// </remarks>
public bool IsProofSkolemize { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } } public bool IsProofSkolemize { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof by modus ponens for equi-satisfiability. /// Indicates whether the term is a proof by modus ponens for equi-satisfiability.
@ -1278,7 +1287,7 @@ namespace Microsoft.Z3
/// T2: (~ p q) /// T2: (~ p q)
/// [mp~ T1 T2]: q /// [mp~ T1 T2]: q
/// </remarks> /// </remarks>
public bool IsProofModusPonensOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } } public bool IsProofModusPonensOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } }
/// <summary> /// <summary>
/// Indicates whether the term is a proof for theory lemma /// Indicates whether the term is a proof for theory lemma
@ -1297,7 +1306,7 @@ namespace Microsoft.Z3
/// (iff (= t1 t2) (and (&lt;= t1 t2) (&lt;= t2 t1))) /// (iff (= t1 t2) (and (&lt;= t1 t2) (&lt;= t2 t1)))
/// - gcd-test - Indicates an integer linear arithmetic lemma that uses a gcd test. /// - gcd-test - Indicates an integer linear arithmetic lemma that uses a gcd test.
/// </remarks> /// </remarks>
public bool IsProofTheoryLemma { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; } } public bool IsProofTheoryLemma { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; } }
#endregion #endregion
#region Relational Terms #region Relational Terms
@ -1322,40 +1331,40 @@ namespace Microsoft.Z3
/// The function takes <c>n+1</c> arguments, where the first argument is the relation and the remaining <c>n</c> elements /// The function takes <c>n+1</c> arguments, where the first argument is the relation and the remaining <c>n</c> elements
/// correspond to the <c>n</c> columns of the relation. /// correspond to the <c>n</c> columns of the relation.
/// </remarks> /// </remarks>
public bool IsRelationStore { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_STORE; } } public bool IsRelationStore { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_STORE; } }
/// <summary> /// <summary>
/// Indicates whether the term is an empty relation /// Indicates whether the term is an empty relation
/// </summary> /// </summary>
public bool IsEmptyRelation { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_EMPTY; } } public bool IsEmptyRelation { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_EMPTY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a test for the emptiness of a relation /// Indicates whether the term is a test for the emptiness of a relation
/// </summary> /// </summary>
public bool IsIsEmptyRelation { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; } } public bool IsIsEmptyRelation { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; } }
/// <summary> /// <summary>
/// Indicates whether the term is a relational join /// Indicates whether the term is a relational join
/// </summary> /// </summary>
public bool IsRelationalJoin { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_JOIN; } } public bool IsRelationalJoin { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_JOIN; } }
/// <summary> /// <summary>
/// Indicates whether the term is the union or convex hull of two relations. /// Indicates whether the term is the union or convex hull of two relations.
/// </summary> /// </summary>
/// <remarks>The function takes two arguments.</remarks> /// <remarks>The function takes two arguments.</remarks>
public bool IsRelationUnion { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_UNION; } } public bool IsRelationUnion { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_UNION; } }
/// <summary> /// <summary>
/// Indicates whether the term is the widening of two relations /// Indicates whether the term is the widening of two relations
/// </summary> /// </summary>
/// <remarks>The function takes two arguments.</remarks> /// <remarks>The function takes two arguments.</remarks>
public bool IsRelationWiden { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_WIDEN; } } public bool IsRelationWiden { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_WIDEN; } }
/// <summary> /// <summary>
/// Indicates whether the term is a projection of columns (provided as numbers in the parameters). /// Indicates whether the term is a projection of columns (provided as numbers in the parameters).
/// </summary> /// </summary>
/// <remarks>The function takes one argument.</remarks> /// <remarks>The function takes one argument.</remarks>
public bool IsRelationProject { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_PROJECT; } } public bool IsRelationProject { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_PROJECT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a relation filter /// Indicates whether the term is a relation filter
@ -1367,7 +1376,7 @@ namespace Microsoft.Z3
/// corresponding to the columns of the relation. /// corresponding to the columns of the relation.
/// So the first column in the relation has index 0. /// So the first column in the relation has index 0.
/// </remarks> /// </remarks>
public bool IsRelationFilter { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_FILTER; } } public bool IsRelationFilter { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_FILTER; } }
/// <summary> /// <summary>
/// Indicates whether the term is an intersection of a relation with the negation of another. /// Indicates whether the term is an intersection of a relation with the negation of another.
@ -1383,7 +1392,7 @@ namespace Microsoft.Z3
/// target are elements in x in pos, such that there is no y in neg that agrees with /// target are elements in x in pos, such that there is no y in neg that agrees with
/// x on the columns c1, d1, .., cN, dN. /// x on the columns c1, d1, .., cN, dN.
/// </remarks> /// </remarks>
public bool IsRelationNegationFilter { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } } public bool IsRelationNegationFilter { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } }
/// <summary> /// <summary>
/// Indicates whether the term is the renaming of a column in a relation /// Indicates whether the term is the renaming of a column in a relation
@ -1392,12 +1401,12 @@ namespace Microsoft.Z3
/// The function takes one argument. /// The function takes one argument.
/// The parameters contain the renaming as a cycle. /// The parameters contain the renaming as a cycle.
/// </remarks> /// </remarks>
public bool IsRelationRename { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_RENAME; } } public bool IsRelationRename { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_RENAME; } }
/// <summary> /// <summary>
/// Indicates whether the term is the complement of a relation /// Indicates whether the term is the complement of a relation
/// </summary> /// </summary>
public bool IsRelationComplement { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } } public bool IsRelationComplement { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a relational select /// Indicates whether the term is a relational select
@ -1407,7 +1416,7 @@ namespace Microsoft.Z3
/// The function takes <c>n+1</c> arguments, where the first argument is a relation, /// The function takes <c>n+1</c> arguments, where the first argument is a relation,
/// and the remaining <c>n</c> arguments correspond to a record. /// and the remaining <c>n</c> arguments correspond to a record.
/// </remarks> /// </remarks>
public bool IsRelationSelect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_SELECT; } } public bool IsRelationSelect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_SELECT; } }
/// <summary> /// <summary>
/// Indicates whether the term is a relational clone (copy) /// Indicates whether the term is a relational clone (copy)
@ -1419,7 +1428,7 @@ namespace Microsoft.Z3
/// for terms of kind <seealso cref="IsRelationUnion"/> /// for terms of kind <seealso cref="IsRelationUnion"/>
/// to perform destructive updates to the first argument. /// to perform destructive updates to the first argument.
/// </remarks> /// </remarks>
public bool IsRelationClone { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_CLONE; } } public bool IsRelationClone { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_CLONE; } }
#endregion #endregion
#region Finite domain terms #region Finite domain terms
@ -1438,7 +1447,7 @@ namespace Microsoft.Z3
/// <summary> /// <summary>
/// Indicates whether the term is a less than predicate over a finite domain. /// Indicates whether the term is a less than predicate over a finite domain.
/// </summary> /// </summary>
public bool IsFiniteDomainLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } } public bool IsFiniteDomainLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
#endregion #endregion
#endregion #endregion

View file

@ -269,6 +269,14 @@ namespace Microsoft.Z3
AST.ArrayLength(queries), AST.ArrayToNative(queries)); AST.ArrayLength(queries), AST.ArrayToNative(queries));
} }
BoolExpr[] ToBoolExprs(ASTVector v) {
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
}
/// <summary> /// <summary>
/// Retrieve set of rules added to fixedpoint context. /// Retrieve set of rules added to fixedpoint context.
/// </summary> /// </summary>
@ -278,12 +286,7 @@ namespace Microsoft.Z3
{ {
Contract.Ensures(Contract.Result<BoolExpr[]>() != null); Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector v = new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject)); return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject)));
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
} }
} }
@ -296,15 +299,27 @@ namespace Microsoft.Z3
{ {
Contract.Ensures(Contract.Result<BoolExpr[]>() != null); Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector v = new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject)); return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject)));
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
} }
} }
/// <summary>
/// Parse an SMT-LIB2 file with fixedpoint rules.
/// Add the rules to the current fixedpoint context.
/// Return the set of queries in the file.
/// </summary>
public BoolExpr[] ParseFile(string file) {
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file)));
}
/// <summary>
/// Similar to ParseFile. Instead it takes as argument a string.
/// </summary>
public BoolExpr[] ParseString(string s) {
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s)));
}
#region Internal #region Internal
internal Fixedpoint(Context ctx, IntPtr obj) internal Fixedpoint(Context ctx, IntPtr obj)

View file

@ -43,7 +43,7 @@ namespace Microsoft.Z3
/// The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. /// The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'.
/// Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION". /// Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION".
/// This function can be used to set parameters for a specific Z3 module. /// This function can be used to set parameters for a specific Z3 module.
/// This can be done by using <module-name>.<parameter-name>. /// This can be done by using [module-name].[parameter-name].
/// For example: /// For example:
/// Z3_global_param_set('pp.decimal', 'true') /// Z3_global_param_set('pp.decimal', 'true')
/// will set the parameter "decimal" in the module "pp" to true. /// will set the parameter "decimal" in the module "pp" to true.

View file

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
namespace Microsoft.Z3
{
/// <summary>
/// The InterpolationContext is suitable for generation of interpolants.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the C/C++ API, which is well documented.</remarks>
[ContractVerification(true)]
class InterpolationContext : Context
{
/// <summary>
/// Constructor.
/// </summary>
public InterpolationContext() : base() { }
/// <summary>
/// Constructor.
/// </summary>
/// <remarks><seealso cref="Context.Context(Dictionary&lt;string, string&gt;)"/></remarks>
public InterpolationContext(Dictionary<string, string> settings) : base(settings) { }
#region Terms
/// <summary>
/// Create an expression that marks a formula position for interpolation.
/// </summary>
public BoolExpr MkInterpolant(BoolExpr a)
{
Contract.Requires(a != null);
Contract.Ensures(Contract.Result<BoolExpr>() != null);
CheckContextMatch(a);
return new BoolExpr(this, Native.Z3_mk_interpolant(nCtx, a.NativeObject));
}
#endregion
/// <summary>
/// Computes an interpolant.
/// </summary>
/// <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)
{
Contract.Requires(pf != null);
Contract.Requires(pat != null);
Contract.Requires(p != null);
Contract.Ensures(Contract.Result<Expr>() != null);
CheckContextMatch(pf);
CheckContextMatch(pat);
CheckContextMatch(p);
ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
uint n = seq.Size;
Expr[] res = new Expr[n];
for (uint i = 0; i < n; i++)
res[i] = Expr.Create(this, seq[i].NativeObject);
return res;
}
/// <summary>
/// Computes an interpolant.
/// </summary>
/// <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)
{
Contract.Requires(pat != null);
Contract.Requires(p != null);
Contract.Ensures(Contract.ValueAtReturn(out interp) != null);
Contract.Ensures(Contract.ValueAtReturn(out model) != null);
CheckContextMatch(pat);
CheckContextMatch(p);
IntPtr i = IntPtr.Zero, m = IntPtr.Zero;
int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m);
interp = new ASTVector(this, i);
model = new Model(this, m);
return (Z3_lbool)r;
}
/// <summary>
/// Return a string summarizing cumulative time used for interpolation.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_interpolation_profile in the C/C++ API, which is
/// well documented.</remarks>
public string InterpolationProfile()
{
return Native.Z3_interpolation_profile(nCtx);
}
/// <summary>
/// Checks the correctness of an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_check_interpolant in the C/C++ API, which is
/// well documented.</remarks>
public int CheckInterpolant(Expr[] cnsts, uint[] parents, Expr[] interps, out string error, Expr[] theory)
{
Contract.Requires(cnsts.Length == parents.Length);
Contract.Requires(cnsts.Length == interps.Length + 1);
IntPtr n_err_str;
int r = Native.Z3_check_interpolant(nCtx,
(uint)cnsts.Length,
Expr.ArrayToNative(cnsts),
parents,
Expr.ArrayToNative(interps),
out n_err_str,
(uint)theory.Length,
Expr.ArrayToNative(theory));
error = Marshal.PtrToStringAnsi(n_err_str);
return r;
}
/// <summary>
/// Reads an interpolation problem from a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public int ReadInterpolationProblem(string filename, out Expr[] cnsts, out uint[] parents, out string error, out Expr[] theory)
{
uint num = 0, num_theory = 0;
IntPtr[] n_cnsts;
IntPtr[] n_theory;
IntPtr n_err_str;
int r = Native.Z3_read_interpolation_problem(nCtx, ref num, out n_cnsts, out parents, filename, out n_err_str, ref num_theory, out n_theory);
error = Marshal.PtrToStringAnsi(n_err_str);
cnsts = new Expr[num];
parents = new uint[num];
theory = new Expr[num_theory];
for (int i = 0; i < num; i++)
cnsts[i] = Expr.Create(this, n_cnsts[i]);
for (int i = 0; i < num_theory; i++)
theory[i] = Expr.Create(this, n_theory[i]);
return r;
}
/// <summary>
/// Writes an interpolation problem to a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public void WriteInterpolationProblem(string filename, Expr[] cnsts, uint[] parents, Expr[] theory)
{
Contract.Requires(cnsts.Length == parents.Length);
Native.Z3_write_interpolation_problem(nCtx, (uint)cnsts.Length, Expr.ArrayToNative(cnsts), parents, filename, (uint)theory.Length, Expr.ArrayToNative(theory));
}
}
}

View file

@ -19,13 +19,12 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\Debug\</OutputPath> <OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile> <DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
</DocumentationFile>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking> <CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface> <CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure> <CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
@ -140,6 +139,7 @@
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel> <CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly> <CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel> <CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
<DocumentationFile>..\x64\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\x64\external_64\</OutputPath> <OutputPath>..\x64\external_64\</OutputPath>
@ -193,7 +193,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'">
<OutputPath>..\x64\external\</OutputPath> <OutputPath>..\x64\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>..\x64\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@ -220,7 +220,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'">
<OutputPath>..\Release_delaysign\</OutputPath> <OutputPath>..\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>..\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -238,7 +238,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'">
<OutputPath>bin\x64\Release_delaysign\</OutputPath> <OutputPath>bin\x64\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>bin\x64\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
@ -254,7 +254,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath> <OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType> <DebugType>full</DebugType>
@ -266,11 +266,12 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> <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> <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>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>bin\x86\Release\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -285,7 +286,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x86'">
<OutputPath>bin\x86\external\</OutputPath> <OutputPath>bin\x86\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>bin\x86\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -303,7 +304,7 @@
<OutputPath>bin\x86\Release_delaysign\</OutputPath> <OutputPath>bin\x86\Release_delaysign\</OutputPath>
<DefineConstants>DELAYSIGN</DefineConstants> <DefineConstants>DELAYSIGN</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile> <DocumentationFile>bin\x86\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -351,6 +352,7 @@
<Compile Include="FuncDecl.cs" /> <Compile Include="FuncDecl.cs" />
<Compile Include="FuncInterp.cs" /> <Compile Include="FuncInterp.cs" />
<Compile Include="Goal.cs" /> <Compile Include="Goal.cs" />
<Compile Include="InterpolationContext.cs" />
<Compile Include="IntExpr.cs" /> <Compile Include="IntExpr.cs" />
<Compile Include="IntNum.cs" /> <Compile Include="IntNum.cs" />
<Compile Include="IntSort.cs" /> <Compile Include="IntSort.cs" />
@ -399,4 +401,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View file

@ -58,6 +58,16 @@ namespace Microsoft.Z3
Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value); Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
} }
/// <summary>
/// Adds a parameter setting.
/// </summary>
public void Add(Symbol name, string value)
{
Contract.Requires(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject);
}
/// <summary> /// <summary>
/// Adds a parameter setting. /// Adds a parameter setting.
/// </summary> /// </summary>
@ -103,6 +113,16 @@ namespace Microsoft.Z3
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
} }
/// <summary>
/// Adds a parameter setting.
/// </summary>
public void Add(string name, string value)
{
Contract.Requires(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
}
/// <summary> /// <summary>
/// A string representation of the parameter set. /// A string representation of the parameter set.
/// </summary> /// </summary>

View file

@ -12,7 +12,7 @@ using System.Security.Permissions;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Z3")] [assembly: AssemblyProduct("Z3")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2006")] [assembly: AssemblyCopyright("Copyright (C) 2006-2014 Microsoft Corporation")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -36,4 +36,3 @@ using System.Security.Permissions;
// [assembly: AssemblyVersion("4.2.0.0")] // [assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.3.2.0")] [assembly: AssemblyVersion("4.3.2.0")]
[assembly: AssemblyFileVersion("4.3.2.0")] [assembly: AssemblyFileVersion("4.3.2.0")]

View file

@ -132,7 +132,8 @@ namespace Microsoft.Z3
/// <remarks> /// <remarks>
/// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores. /// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores.
/// Both APIs can be used in the same solver. The unsat core will contain a combination /// Both APIs can be used in the same solver. The unsat core will contain a combination
/// of the Boolean variables provided using <see cref="AssertAndTrack"/> and the Boolean literals /// of the Boolean variables provided using <see cref="AssertAndTrack(BoolExpr[],BoolExpr[])"/>
/// and the Boolean literals
/// provided using <see cref="Check"/> with assumptions. /// provided using <see cref="Check"/> with assumptions.
/// </remarks> /// </remarks>
public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps) public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
@ -156,7 +157,8 @@ namespace Microsoft.Z3
/// <remarks> /// <remarks>
/// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores. /// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores.
/// Both APIs can be used in the same solver. The unsat core will contain a combination /// Both APIs can be used in the same solver. The unsat core will contain a combination
/// of the Boolean variables provided using <see cref="AssertAndTrack"/> and the Boolean literals /// of the Boolean variables provided using <see cref="AssertAndTrack(BoolExpr[],BoolExpr[])"/>
/// and the Boolean literals
/// provided using <see cref="Check"/> with assumptions. /// provided using <see cref="Check"/> with assumptions.
/// </remarks> /// </remarks>
public void AssertAndTrack(BoolExpr constraint, BoolExpr p) public void AssertAndTrack(BoolExpr constraint, BoolExpr p)
@ -210,7 +212,7 @@ namespace Microsoft.Z3
public Status Check(params Expr[] assumptions) public Status Check(params Expr[] assumptions)
{ {
Z3_lbool r; Z3_lbool r;
if (assumptions == null) if (assumptions == null || assumptions.Length == 0)
r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject); r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject);
else else
r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)assumptions.Length, AST.ArrayToNative(assumptions)); r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)assumptions.Length, AST.ArrayToNative(assumptions));

View file

@ -74,9 +74,10 @@ namespace Microsoft.Z3
Contract.Requires(name != null); Contract.Requires(name != null);
IntPtr t = IntPtr.Zero; IntPtr t = IntPtr.Zero;
IntPtr[] f = new IntPtr[numFields];
NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields, NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts), Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
ref t, new IntPtr[numFields]); ref t, f);
} }
#endregion #endregion
}; };

View file

@ -19,6 +19,7 @@ Notes:
using System; using System;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Threading;
namespace Microsoft.Z3 namespace Microsoft.Z3
{ {
@ -50,8 +51,7 @@ namespace Microsoft.Z3
if (m_ctx != null) if (m_ctx != null)
{ {
m_ctx.refCount--; if (Interlocked.Decrement(ref m_ctx.refCount) == 0)
if (m_ctx.refCount == 0)
GC.ReRegisterForFinalize(m_ctx); GC.ReRegisterForFinalize(m_ctx);
m_ctx = null; m_ctx = null;
} }
@ -77,7 +77,7 @@ namespace Microsoft.Z3
{ {
Contract.Requires(ctx != null); Contract.Requires(ctx != null);
ctx.refCount++; Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx; m_ctx = ctx;
} }
@ -85,7 +85,7 @@ namespace Microsoft.Z3
{ {
Contract.Requires(ctx != null); Contract.Requires(ctx != null);
ctx.refCount++; Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx; m_ctx = ctx;
IncRef(obj); IncRef(obj);
m_n_obj = obj; m_n_obj = obj;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from AST.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
AST.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
@ -13,28 +24,12 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
**/ **/
public class AST extends Z3Object public class AST extends Z3Object
{ {
/**
* Comparison operator. <param name="a">An AST</param> <param name="b">An
* AST</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
* the same context and represent the same sort; false otherwise.
**/
/* Overloaded operators are not translated. */
/**
* Comparison operator. <param name="a">An AST</param> <param name="b">An
* AST</param>
*
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
* from the same context or represent different sorts; false
* otherwise.
**/
/* Overloaded operators are not translated. */ /* Overloaded operators are not translated. */
/** /**
* Object comparison. * Object comparison.
**/ * <param name="o">another AST</param>
**/
public boolean equals(Object o) public boolean equals(Object o)
{ {
AST casted = null; AST casted = null;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ASTDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ASTMap.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ASTMap.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ASTVector.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ASTVector.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from AlgebraicNum.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
AlgebraicNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ApplyResult.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ApplyResult.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ApplyResultDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ArithExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
* **/
ArithExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ArithSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ArithSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ArrayExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ArrayExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ArraySort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ArraySort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
AstMapDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
AstVectorDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from BitVecExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
BitVecExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from BitVecNum.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
BitVecNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
@ -35,7 +46,7 @@ public class BitVecNum extends BitVecExpr
{ {
Native.LongPtr res = new Native.LongPtr(); Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true) if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int64"); throw new Z3Exception("Numeral is not a long");
return res.value; return res.value;
} }

View file

@ -1,8 +1,20 @@
/** /**
* This file was automatically generated from BitVecSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
BitVecSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
/** /**

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from BoolExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
BoolExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from BoolSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
BoolSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Constructor.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Constructor.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ConstructorList.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ConstructorList.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Context.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Context.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
@ -2904,27 +2915,13 @@ public class Context extends IDisposable
* configuration parameters can be obtained using the Z3 executable: * configuration parameters can be obtained using the Z3 executable:
* <code>z3.exe -ini?</code> Only a few configuration parameters are mutable * <code>z3.exe -ini?</code> Only a few configuration parameters are mutable
* once the context is created. An exception is thrown when trying to modify * once the context is created. An exception is thrown when trying to modify
* an immutable parameter. </remarks> <seealso cref="GetParamValue"/> * an immutable parameter. </remarks>
**/ **/
public void updateParamValue(String id, String value) throws Z3Exception public void updateParamValue(String id, String value) throws Z3Exception
{ {
Native.updateParamValue(nCtx(), id, value); Native.updateParamValue(nCtx(), id, value);
} }
/**
* Get a configuration parameter. <remarks> Returns null if the parameter
* value does not exist. </remarks> <seealso cref="UpdateParamValue"/>
**/
public String getParamValue(String id) throws Z3Exception
{
Native.StringPtr res = new Native.StringPtr();
boolean r = Native.getParamValue(nCtx(), id, res);
if (!r)
return null;
else
return res.value;
}
long m_ctx = 0; long m_ctx = 0;
long nCtx() long nCtx()

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from DatatypeExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
DatatypeExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from DatatypeSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
DatatypeSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from EnumSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
EnumSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from FiniteDomainSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
FiniteDomainSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Fixedpoint.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Fixedpoint.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
FixedpointDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from FuncDecl.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
FuncDecl.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from FuncInterp.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
FuncInterp.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
FuncInterpDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
FuncInterpEntryDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Global.java Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
Global.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
@ -38,8 +50,7 @@ public final class Global
/** /**
* Get a global (or module) parameter. * Get a global (or module) parameter.
* <remarks> * <remarks>
* Returns null if the parameter <param name="id"/> does not exist. * Returns null if the parameter <param name="id">parameter id</param> does not exist.
* The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
* This function cannot be invoked simultaneously from different threads without synchronization. * This function cannot be invoked simultaneously from different threads without synchronization.
* The result string stored in param_value is stored in a shared location. * The result string stored in param_value is stored in a shared location.
* </remarks> * </remarks>
@ -58,7 +69,7 @@ public final class Global
* <remarks> * <remarks>
* This command will not affect already created objects (such as tactics and solvers) * This command will not affect already created objects (such as tactics and solvers)
* </remarks> * </remarks>
* @seealso SetParameter * <seealso cref="SetParameter"/>
**/ **/
public static void resetParameters() public static void resetParameters()
{ {

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Goal.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Goal.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
GoalDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from IDecRefQueue.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
IDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from IntExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
IntExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from IntNum.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
IntNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from IntSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
IntSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from IntSymbol.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
IntSymbol.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -0,0 +1,183 @@
/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
InterpolationContext.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
import java.util.Map;
import java.lang.String;
import com.microsoft.z3.Native.IntPtr;
import com.microsoft.z3.Native.UIntArrayPtr;
import com.microsoft.z3.enumerations.Z3_lbool;
/** <summary>
* The InterpolationContext is suitable for generation of interpolants.
* </summary>
* <remarks>For more information on interpolation please refer
* too the C/C++ API, which is well documented.</remarks>
**/
public class InterpolationContext extends Context
{
/**
* Constructor.
**/
public InterpolationContext() throws Z3Exception
{
m_ctx = Native.mkInterpolationContext(0);
initContext();
}
/**
* Constructor.
*
* <remarks><seealso cref="Context.Context(Dictionary&lt;string, string&gt;)"/></remarks>
**/
public InterpolationContext(Map<String, String> settings) throws Z3Exception
{
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet())
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
m_ctx = Native.mkInterpolationContext(cfg);
Native.delConfig(cfg);
initContext();
}
/**
* Create an expression that marks a formula position for interpolation.
* @throws Z3Exception
**/
public BoolExpr MkInterpolant(BoolExpr a) throws Z3Exception
{
checkContextMatch(a);
return new BoolExpr(this, Native.mkInterpolant(nCtx(), a.getNativeObject()));
}
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* too the function Z3_get_interpolant in the C/C++ API, which is
* well documented.</remarks>
* @throws Z3Exception
**/
Expr[] GetInterpolant(Expr pf, Expr pat, Params p) throws Z3Exception
{
checkContextMatch(pf);
checkContextMatch(pat);
checkContextMatch(p);
ASTVector seq = new ASTVector(this, Native.getInterpolant(nCtx(), pf.getNativeObject(), pat.getNativeObject(), p.getNativeObject()));
int n = seq.size();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(this, seq.get(i).getNativeObject());
return res;
}
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* too the function Z3_compute_interpolant in the C/C++ API, which is
* well documented.</remarks>
* @throws Z3Exception
**/
Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model) throws Z3Exception
{
checkContextMatch(pat);
checkContextMatch(p);
Native.LongPtr n_i = new Native.LongPtr();
Native.LongPtr n_m = new Native.LongPtr();
int r = Native.computeInterpolant(nCtx(), pat.getNativeObject(), p.getNativeObject(), n_i, n_m);
interp = new ASTVector(this, n_i.value);
model = new Model(this, n_m.value);
return Z3_lbool.fromInt(r);
}
/// <summary>
/// Return a string summarizing cumulative time used for interpolation.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_interpolation_profile in the C/C++ API, which is
/// well documented.</remarks>
public String InterpolationProfile() throws Z3Exception
{
return Native.interpolationProfile(nCtx());
}
/// <summary>
/// Checks the correctness of an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_check_interpolant in the C/C++ API, which is
/// well documented.</remarks>
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory) throws Z3Exception
{
Native.StringPtr n_err_str = new Native.StringPtr();
int r = Native.checkInterpolant(nCtx(),
cnsts.length,
Expr.arrayToNative(cnsts),
parents,
Expr.arrayToNative(interps),
n_err_str,
theory.length,
Expr.arrayToNative(theory));
error = n_err_str.value;
return r;
}
/// <summary>
/// Reads an interpolation problem from a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
{
Native.IntPtr n_num = new Native.IntPtr();
Native.IntPtr n_num_theory = new Native.IntPtr();
Native.ObjArrayPtr n_cnsts = new Native.ObjArrayPtr();
Native.UIntArrayPtr n_parents = new Native.UIntArrayPtr();
Native.ObjArrayPtr n_theory = new Native.ObjArrayPtr();
Native.StringPtr n_err_str = new Native.StringPtr();
int r = Native.readInterpolationProblem(nCtx(), n_num, n_cnsts, n_parents, filename, n_err_str, n_num_theory, n_theory);
int num = n_num.value;
int num_theory = n_num_theory.value;
error = n_err_str.value;
cnsts = new Expr[num];
parents = new int[num];
theory = new Expr[num_theory];
for (int i = 0; i < num; i++)
{
cnsts[i] = Expr.create(this, n_cnsts.value[i]);
parents[i] = n_parents.value[i];
}
for (int i = 0; i < num_theory; i++)
theory[i] = Expr.create(this, n_theory.value[i]);
return r;
}
/// <summary>
/// Writes an interpolation problem to a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public void WriteInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
{
Native.writeInterpolationProblem(nCtx(), cnsts.length, Expr.arrayToNative(cnsts), parents, filename, theory.length, Expr.arrayToNative(theory));
}
}

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ListSort.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ListSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Log.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Log.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Model.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Model.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ModelDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from ParamDescrs.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
ParamDescrs.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ParamDescrsDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,20 @@
/** /**
* This file was automatically generated from Params.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Params.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;
@ -28,6 +40,17 @@ public class Params extends Z3Object
Native.paramsSetDouble(getContext().nCtx(), getNativeObject(), Native.paramsSetDouble(getContext().nCtx(), getNativeObject(),
name.getNativeObject(), value); name.getNativeObject(), value);
} }
/**
* Adds a parameter setting.
**/
public void add(Symbol name, String value) throws Z3Exception
{
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
name.getNativeObject(),
getContext().mkSymbol(value).getNativeObject());
}
/** /**
* Adds a parameter setting. * Adds a parameter setting.
@ -75,6 +98,17 @@ public class Params extends Z3Object
.mkSymbol(name).getNativeObject(), value.getNativeObject()); .mkSymbol(name).getNativeObject(), value.getNativeObject());
} }
/**
* Adds a parameter setting.
**/
public void add(String name, String value) throws Z3Exception
{
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
getContext().mkSymbol(name).getNativeObject(),
getContext().mkSymbol(value).getNativeObject());
}
/** /**
* A string representation of the parameter set. * A string representation of the parameter set.
**/ **/

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ParamDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Pattern.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Pattern.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Probe.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Probe.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/** /**
* Copyright (c) 2012 Microsoft Corporation Copyright (c) 2012-2014 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/ Module Name:
ProbeDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from Quantifier.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
Quantifier.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,3 +1,6 @@
Java bindings Java bindings
------------- -------------
The Java bindings will be included in the Z3 build if it is configured with
the option --java to python scripts/mk_make.py. This will produce the
com.microsoft.z3.jar package in the build directory.

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from RatNum.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
RatNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/** /**
* This file was automatically generated from RealExpr.cs Copyright (c) 2012-2014 Microsoft Corporation
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter) Module Name:
**/
RealExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3; package com.microsoft.z3;

Some files were not shown because too many files have changed in this diff Show more