3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 05:18:44 +00:00

merged changes from unstable

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-11-21 12:41:52 -08:00
commit 6679fc4c0b
46 changed files with 3598 additions and 655 deletions

51
.gitignore vendored Normal file
View file

@ -0,0 +1,51 @@
*~
*.pyc
.z3-trace
# OCaml generated files
*.a
*.cma
*.cmi
*.cmxa
ocamlz3
# Emacs temp files
\#*\#
# Directories with generated code and documentation
build/*
build-dist/*
dist/*
doc/html/*
# GTAGS generated files
src/GPATH
src/GRTAGS
src/GSYMS
src/GTAGS
src/HTML/*
# CSCOPE files
src/cscope.in.out
src/cscope.out
src/cscope.po.out
ncscope.out
# CEDET files
.cproject
.project
# Commonly used directories for code
bld_dbg/*
bld_rel/*
# Auto generated files.
config.log
config.status
configure
install_tactic.cpp
mem_initializer.cpp
scripts/config-debug.mk
scripts/config-release.mk
src/api/api_commands.cpp
src/api/api_log_macros.h
src/api/api_log_macros.cpp
src/api/dll/api_dll.def
src/api/dotnet/Enumerations.cs
src/api/dotnet/Native.cs
src/api/python/z3consts.py
src/api/python/z3core.py
src/ast/pattern/database.h
src/util/version.h

12
README
View file

@ -12,8 +12,6 @@ Z3 can be built using Visual Studio Command Prompt and make/g++.
2) Building Z3 using make/g++ and Python
Execute:
autoconf
./configure
python scripts/mk_make.py
cd build
make
@ -24,9 +22,7 @@ You can change the installation p
Use the following commands to install in a different prefix (e.g., /home/leo).
autoconf
./configure --prefix=/home/leo
python scripts/mk_make.py
python scripts/mk_make.py --prefix=/home/leo
cd build
make
sudo make install
@ -35,11 +31,9 @@ To uninstall Z3, use
sudo make uninstall
3) Building Z3 using clang++ on Linux/OSX
3) Building Z3 using clang and clang++ on Linux/OSX
Remark: clang does not support OpenMP yet.
autoconf
./configure CXX=clang++
python scripts/mk_make.py
CXX=clang++ CC=clang python scripts/mk_make.py
cd build
make

View file

@ -5,6 +5,15 @@ Version 4.3.2
- Added get_version() and get_version_string() to Z3Py
- Added support for FreeBSD. Z3 can be compiled on FreeBSD using g++.
- Reverted to `(set-option :global-decls false)` as the default. In Z3 4.3.0 and Z3 4.3.1, this option was set to true.
Thanks to Julien Henry for reporting this problem.
- Added `doc` directory and scripts for automatically generating the API documentation.
- Removed 'autoconf' dependency. We do not need to execute 'autoconf' and './configure' anymore to build Z3.
Version 4.3.1
=============

View file

@ -1,214 +0,0 @@
AC_INIT([z3], [4.2])
AC_CONFIG_SRCDIR(src/util/util.cpp)
AC_PREFIX_DEFAULT(/usr)
###################
#
# Testing python
#
###################
AC_ARG_WITH(python,
[AS_HELP_STRING([--with-python=PYTHON_PATH],
[specify the location of the python 2.x executable.])])
PYTHON="python"
if test "x$with_python" != x; then
PYTHON="$with_python"
fi
AC_SUBST(PYTHON)
cat > tst_python.py <<EOF
from sys import version
if version >= "3":
exit(1)
exit(0)
EOF
if $PYTHON tst_python.py; then
HAS_PYTHON="1"
HAS_PYTHON_MSG="yes"
cat > get_py_dir.py << EOF
import distutils.sysconfig
print distutils.sysconfig.get_python_lib()
EOF
if $PYTHON get_py_dir.py > dir.txt; then
PYTHON_PACKAGE_DIR=`cat dir.txt`
else
HAS_PYTHON="0"
HAS_PYTHON_MSG="no"
fi
rm -f dir.txt
rm -f get_py_dir.py
else
HAS_PYTHON="0"
HAS_PYTHON_MSG="no"
fi
rm -f tst_python.py
if test "$HAS_PYTHON" = "0"; then
AC_MSG_ERROR([You need Python 2.x to generate the Z3 Makefiles.\nPlease download python at http://python.org])
fi
AC_SUBST(PYTHON_PACKAGE_DIR)
###################
#
# Configuring bignum package
#
###################
# Select big num package
ARITH="internal"
AC_ARG_WITH([gmp], [AS_HELP_STRING([--with-gmp], [Use GMP for multi-precision naturals (default=no)])], [use_gmp=yes], [use_gmp=no])
AS_IF([test "$use_gmp" = "yes"],[
ARITH="gmp"
CPPFLAGS="$CPPFLAGS -D_MP_GMP"
],[
CPPFLAGS="$CPPFLAGS -D_MP_INTERNAL"
])
AC_SUBST(EXTRA_LIB_SRCS)
if test "$ARITH" = "gmp"; then
AC_CHECK_LIB(gmp, __gmpz_init, ,
[AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
AC_CHECK_HEADER([gmp.h], GMP='gmp', AC_MSG_ERROR([GMP include file not found]))
AC_SUBST(LIBS)
echo $CPPFLAGS
fi
###################
#
# Basic configuration
#
###################
# Sets CXX
AC_LANG([C++])
AC_PROG_CXX(g++ clang++ false)
AC_PROG_CC
if test $CXX = "false"; then
AC_MSG_ERROR([C++ compiler was not found])
fi
AC_PROG_MAKE_SET
AC_LANG_CPLUSPLUS
# Sets GREP
AC_PROG_GREP
# Sets SED
AC_PROG_SED
AS_IF([test "$CXX" = "g++"], [
# Enable OpenMP
CXXFLAGS+=" -fopenmp"
LDFLAGS+=" -fopenmp"
SLIBEXTRAFLAGS+=" -fopenmp"
# Use -mfpmath=sse
CXXFLAGS+=" -mfpmath=sse"
],
[test "$CXX" = "clang++"], [
# OpenMP is not supported in clang++
CXXFLAGS+=" -D _NO_OMP_"
],
[
AC_MSG_ERROR([Unsupported compiler: $CXX])
])
AR=ar
AC_SUBST(AR)
###################
#
# Platform characteristics
#
###################
host_os=`uname -s`
AS_IF([test "$host_os" = "Darwin"], [
PLATFORM=osx
SO_EXT=.dylib
SLIBFLAGS+="-dynamiclib"
COMP_VERSIONS="-compatibility_version \$(Z3_VERSION) -current_version \$(Z3_VERSION)"
STATIC_FLAGS=
], [test "$host_os" = "Linux"], [
PLATFORM=linux
SO_EXT=.so
LDFLAGS+=" -lrt"
SLIBFLAGS+=" -shared"
COMP_VERSIONS=
STATIC_FLAGS=-static
CXXFLAGS+=" -fno-strict-aliasing"
if test "$CXX" = "clang++"; then
# More flags for clang++ for Linux
CXXFLAGS+=" -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value"
fi
SLIBEXTRAFLAGS+=" -lrt"
], [test "${host_os:0:6}" = "CYGWIN"], [
PLATFORM=win
SO_EXT=.dll
SLIBFLAGS+="-shared"
COMP_VERSIONS=
CXXFLAGS+=" -D_CYGWIN -fno-strict-aliasing"
],
[
AC_MSG_ERROR([Unknown host platform: $host_os])
])
AC_SUBST(SLIBFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(SLIBEXTRAFLAGS)
AC_SUBST(SO_EXT)
###################
#
# Checking if 32 or 64 bits
#
###################
AC_CHECK_SIZEOF(int *)
if test $ac_cv_sizeof_int_p -eq 8; then
dnl In 64-bit systems we have to compile using -fPIC
CXXFLAGS+=" -fPIC"
CPPFLAGS+=" -D_AMD64_"
dnl Only enable use of thread local storage for 64-bit Linux. It is disabled for OSX and 32-bit Linux
if test $PLATFORM = "linux"; then
CPPFLAGS+=" -D_USE_THREAD_LOCAL"
fi
IS_X64="yes"
else
IS_X64="no"
fi
###################
#
# Generating configuration
#
###################
AC_OUTPUT(scripts/config-debug.mk scripts/config-release.mk)
###################
#
# Checking how to build Z3
#
###################
# Python is available, give user the option to generate the make files wherever they want
cat <<EOF
Z3 was configured with success.
Host platform: $PLATFORM
Compiler: $CXX
Arithmetic: $ARITH
Python: $PYTHON
Prefix: $prefix
64-bit: $IS_X64
To build and install Z3, execute:
python scripts/mk_make.py
cd build
make
sudo make install
EOF

11
doc/README Normal file
View file

@ -0,0 +1,11 @@
API documentation
-----------------
To generate the API documentation for the C, .NET and Python APIs, we must execute
python mk_doc.py
We must have doxygen installed in our system.
The documentation will be stored in the subdirectory './html'.
The main file is './html/index.html'

4
doc/footer.html Normal file
View file

@ -0,0 +1,4 @@
<div id="nav">
</div>
</body>
</html>

23
doc/header.html Normal file
View file

@ -0,0 +1,23 @@
<HTML>
<HEAD>
<meta name="author" content="Leonardo de Moura" />
<meta name="author" content="Nikolaj Bjorner" />
<meta name="author" content="Christoph Wintersteiger" />
<meta name="description" content="Z3: theorem prover" />
<meta name="keywords" content="decision procedure, theorem prover, SMT-LIB, SMTLIB, SMT LIB, SMT Solver, SMTCOMP, SMT-COMP, SAT solver, formal methods, constraint solver, software verification, hardware verification" />
<TITLE>Z3: Theorem Prover</TITLE>
<LINK HREF="z3.css" REL="stylesheet" TYPE="text/css">
<LINK href="tabs.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table>
<tr>
<th style="width:120px"><a style="border=0px" class="el" href="http://z3.codeplex.com"><img border="0" src="z3.png" alt="Z3" /></a></th>
<th style="width:100%">
<div id="nav">
</div>
</th>
</tr>
</table>

47
doc/mk_doc.py Normal file
View file

@ -0,0 +1,47 @@
import os
import shutil
import re
import pydoc
import sys
import subprocess
def mk_dir(d):
if not os.path.exists(d):
os.makedirs(d)
# Eliminate def_API and extra_API directives from file 'inf'.
# The result is stored in 'outf'.
def cleanup_API(inf, outf):
pat1 = re.compile(".*def_API.*")
pat2 = re.compile(".*extra_API.*")
_inf = open(inf, 'r')
_outf = open(outf, 'w')
for line in _inf:
if not pat1.match(line) and not pat2.match(line):
_outf.write(line)
try:
mk_dir('html')
cleanup_API('../src/api/z3_api.h', 'z3_api.h')
print "Removed annotations from z3_api.h."
DEVNULL = open(os.devnull, 'wb')
try:
subprocess.call(['doxygen', 'z3.dox'], stdout=DEVNULL, stderr=DEVNULL)
except:
print "ERROR: failed to execute 'doxygen', make sure doxygen (http://www.doxygen.org) is available in your system."
exit(1)
print "Generated C and .NET API documentation."
os.remove('z3_api.h')
print "Removed temporary file z3_api.h."
shutil.copy('z3.css', 'html/z3.css')
print "Copied z3.css."
shutil.copy('z3.png', 'html/z3.png')
print "Copied z3.png."
sys.path.append('../src/api/python')
pydoc.writedoc('z3')
shutil.move('z3.html', 'html/z3.html')
print "Generated Python documentation."
print "Documentation was successfully generated at subdirectory './html'."
except:
print "ERROR: failed to generate documentation"
exit(1)

4
doc/update_website.cmd Normal file
View file

@ -0,0 +1,4 @@
REM Script for updating the website containing the Z3 API documentation.
REM You must be inside the Microsoft network to execute this script, and
REM robocopy must be in your PATH.
robocopy /S html \\research\root\web\external\en-us\UM\redmond\projects\z3

17
doc/website.dox Normal file
View file

@ -0,0 +1,17 @@
/**
\mainpage An Efficient Theorem Prover
Z3 is a high-performance theorem prover being developed at <a class="el"
href="http://research.microsoft.com">Microsoft Research</a>.
<b>The Z3 website moved to <a class="el" href="http://z3.codeplex.com">z3.codeplex.com</a>.</b>
The old Z3 website can be found <a class="el" href="http://research.microsoft.com/en-us/um/redmond/projects/z3/old/index.html">here</a>.
This website hosts the automatically generated documentation for the Z3 APIs.
- \ref capi
- <a class="el" href="class_microsoft_1_1_z3_1_1_context.html">.NET API</a>
- <a class="el" href="z3.html">Python API</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>.
*/

934
doc/z3.css Normal file
View file

@ -0,0 +1,934 @@
/* Section Start for new text handling */
.PSubText
{
FONT-SIZE: 8pt;
COLOR: #555555;
}
.LeftJustifyBullet
{
FONT-SIZE: 10pt;
margin-left:-24px;
}
/* Section End for new text handling */
/* Section Start for text handling based on Rob Gruen's layout for the Download Details page */
A:hover
{
TEXT-DECORATION: underline
}
A
{
TEXT-DECORATION: none;
COLOR: #333399;
}
LI
{
FONT-SIZE: 10pt;
COLOR: #555555;
margin-bottom:10px;
margin-left: -3px;
}
LI LI
{
FONT-SIZE: 10pt;
COLOR: #555555;
margin-bottom:10px;
margin-left: -3px;
}
BODY
{
margin-right: 20px;
margin-left: 20px;
COLOR: #555555;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 10pt;
}
P
{
FONT-SIZE: 10pt;
COLOR: #555555;
}
.Z3Title
{
FONT-SIZE: 18pt;
COLOR: #1A41A8;
margin-bottom:-10px;
}
.PageTitle
{
FONT-SIZE: 12pt;
COLOR: #333333;
margin-bottom:-10px;
}
.BlobTitle
{
FONT-SIZE: 12pt;
COLOR: #333333;
LINE-HEIGHT: 100%;
margin-bottom:-10px;
}
.Heading1
{
FONT-SIZE: 10pt;
COLOR: #2A51B8;
margin-bottom:-10px;
}
.Heading2
{
FONT-WEIGHT: bold;
FONT-SIZE: 10pt;
COLOR: #555555;
margin-bottom:-10px;
}
.Heading3
{
FONT-SIZE: 10pt;
COLOR: #2A51B8;
margin-bottom:-10px;
}
.title
{
font-size: 18pt;
color: #1A41A8;
margin-bottom:-10px;
line-height: 35pt
}
.quote
{
FONT-FAMILY: Georgia, Times, Times New Roman, serif;
FONT-STYLE: italic;
FONT-SIZE: 20pt;
COLOR: #2A51B8;
}
.attribution
{
FONT-SIZE: 8pt;
COLOR: #555555;
}
.quickinfo
{
FONT-WEIGHT: bold;
FONT-SIZE: 13pt;
MARGIN-LEFT: 12px;
COLOR: #2A51B8;
}
.quickinfo_header
{
font-weight: bold;
color: #555555;
margin-left: 25px;
}
hr
{
width: 100%;
margin-top: 10px;
margin-bottom: 10px;
color: #cccccc;
}
.RHPSectionHeader
{
font-size: 10pt;
margin-left: 20px;
color: #2A51B8;
display: block;
}
.RHPNav
{
FONT-SIZE: 10pt;
MARGIN-TOP: 6px;
COLOR: #333333;
}
.author
{
FONT-SIZE: 8pt;
COLOR: #555555;
}
.lastupdated
{
FONT-SIZE: 8pt;
COLOR: #555555;
}
/* Section End for text handling based on Rob Gruen's layout for the Download Details page */
/* Section Start for text handling based on rmcstyle.css */
.title_2ndLvl
{
font-family: tahoma;
font-size: 120%;
color: #FFFFFF;
padding-left: 5px;
}
.VR
{
background-color: #cccccc;
width: 1px;
margin-top: -24;
}
.link1
{
font-size:70%;
font-family: verdana;
}
.link2
{
font-size: 70%;
font-family:Verdana;
font-style:italic;
}
.link3
{
font-style: italic;
font-family: Verdana;
color: #000000;
font-weight: bold;
}
.link4
{
font: italic 70% Verdana;
color: #000000;
text-decoration: none;
}
.link5
{
font: 70% Verdana;
color: #003399;
text-decoration: none;
}
.link6
{
font: 70% verdana;
color: #003399;
}
.ReadMore
{
text-decoration:none;
}
/* .text1
{
font: 70% Verdana;
} */
.text2
{
padding-bottom: 10px;
font: 70% Verdana;
}
.text3
{
font-size: 120%;
font-family:Verdana;
color: #000000;
}
.text3_w_padding
{
font: 120% Verdana;
color: #000000;
padding-left:20px;
}
.text4
{
font-weight: bold;
font-size: 70%;
font-family: Verdana;
color: #000000;
}
.text5
{
padding-left: 5px;
font-weight: bold;
font-size: 70%;
font-family: Verdana;
color: #ffffff;
}
.text6
{
font: 70%;
font-family: verdana;
}
.newsTitle
{
font-family: tahoma;
font-size: 120%;
color: #CCCCCC;
}
.areaTitle
{
font-family: tahoma;
font-size: 120%;
color: #FFFFFF;
}
.newsContentTitle
{
font-family: tahoma;
font-size: 120%;
color: #FFFFFF;
}
.areaContentTitle
{
font-family: verdana;
font-size: 140%;
color: #000000;
}
.areaContentTitle_w_pad
{
font-family: verdana;
font-size: 140%;
color: #000000;
padding-left: 20px;
padding-top: 20px;
}
.newsArchiveTitle
{
font-family: verdana;
font-size: 150%;
color: #000000;
}
.FeatureStoryTitle
{
font-family: verdana;
font-size: 18 pt;
COLOR: #2A51B8;
margin-bottom:-15px;
}
.FeatureStoryDate
{
font-family: Verdana;
font-size: 8 pt;
color: #555555;
}
.FeatureStoryByLine
{
font-family: verdana;
font-size: 10 pt;
color: #555555;
margin-bottom:-15px;
font-weight: bold;
}
.SideBarLink
{
font-family: verdana;
font-size: 80%;
color: #000000;
}
.newsArchiveSubTitle
{
font-family: verdana;
font-size: 118%;
color: #666666;
}
.newsArchiveYear
{
font: bold 80% Verdana;
color: #000000;
border-bottom: #cccccc 1px solid;
border-top: #cccccc 1px solid;
}
.newsHeadlineTitle
{
font-family: verdana;
font-size: 140%;
color: #000000;
}
.newsPublicationDate
{
font-family: Verdana;
font-size: 60%;
color: #000000;
font-weight: bold;
}
.newsPublicationSource
{
font-family: Verdana;
font-size: 60%;
color: #000000;
font-weight: bold;
}
h1 {font-size: 16pt; color: #2A51B8; margin: 30px 0px; font-weight: normal;}
.anchor { color: #2A51B8; }
h2 {font-size: 14pt; color: #2A51B8; margin: 10px 0px; font-weight: normal;}
h3 {font-size: 12pt; color: #2A51B8; margin: 10px 0px; font-weight: normal;}
h4
{
color: #808080;
font-family: Tahoma;
font-size: 90%;
margin-bottom: -10px
}
.TitleHeader {font-family: tahoma; font-weight: bold; font-size: 110%; color: #000000;}
P P
{
font-size: 100%;
}
.groupheading
{
padding-left: 20px;
padding-top: 40px;
padding-bottom: 10px;
font-size: 1.4em;
color: #0065CF;
font-family:verdana;
}
.GroupTitle
{
padding-left: 20px;
padding-top: 20px;
padding-bottom: 10px;
font-size: 1.4em;
color: #0065CF;
}
LI LI
{
font-size: 100%;
}
LI A
{
font-size: 100%;
}
/* Section End for text handling based on rmcstyle.css */
/* Section Start for text handling based on new_style.css */
.O
{
color:white;
font-size:149%;
}
ul
{
color: #808080;
list-style-type:square
}
/* Section End for text handling based on new_style.css */
/* Section Start for page layout based on Rob Gruen's downloads Page */
.bodymargin
{
margin-left: 20px;
position: relative;
}
/* Section Start for page layout based on Rob Gruen's downloads Page */
/* Section Start for page layout based on Rob Gruen's downloads Page */
.quickinfo_tbl
{
color: #555555;
BORDER-RIGHT: black 1px solid;
BORDER-TOP: black 1px solid;
BORDER-LEFT: black 1px solid;
WIDTH: 560px;
BORDER-BOTTOM: black 1px solid;
HEIGHT: 164px;
}
/* Section Start for page layout based on Rob Gruen's downloads Page */
/* Section Start for page layout based on rmcstyle.css */
.linkbox
{
margin-left: 20px;
margin-right: 30px;
margin-bottom: 20px;
padding-bottom: 10px;
width: 175px;
float: right;
background: #ffffff;
border-bottom: #CCCCCC 1px solid;
}
.outlineDivTitle
{
border-top: #CCCCCC 1px solid;
background-color: #FFFFFF;
color: #CCCCCC;
padding-left: 15px;
padding-bottom: 12px;
padding-top: 12px;
font: bold 70% Verdana;
color: #2A51B8;
}
.outlineDiv
{
padding-left: 20px;
background-image: URL(/images/orangesquare.gif);
background-repeat: no-repeat;
background-position: 6 8;
font: 70% verdana;
color: #555555;
line-height: 200%;
}
/* Section End for page layout based on rmcstyle.css */
/* Section Start for page layout based on new_style.css */
.QL_border
{
border-right: #555555 1px solid;
background: #ffffff;
border-left: #555555 1px solid;
border-bottom: #555555 1px solid;
}
/* Section End for page layout based on new_style.css */
/* Begin Versal-specific styles */
.imageAlignLeft
{
background-color: #ffffff;
margin: 0px 10px 10px 10px;
color: #666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 70%;
font-weight:normal;
text-align: left;
}
.imageAlignRight
{
background-color: #ffffff;
margin: 0px 10px 10px 10px;
color: #666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 70%;
font-weight:normal;
text-align: left;
}
.imageFloatLeft
{
float: left;
background-color: #ffffff;
margin: 0px 10px 10px 0px;
color: #666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 70%;
font-weight:normal;
text-align: left;
}
.imageFloatRight
{
float: right;
background-color: #ffffff;
margin: 0px 10px 10px 10px;
color: #666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 70%;
font-weight:normal;
text-align: left;
}
.imageCaptionText
{
color:#666666;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:xx-small;
font-weight:normal;
}
.tableBorder
{
border-top: solid 1px #C0C0C0;
border-left: solid 1px #C0C0C0;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
margin-top: 1em;
}
.tableNoBorder
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
margin-top: 1em;
}
.tableBorderLabel
{
border-top: solid 1px #C0C0C0;
border-left: solid 1px #C0C0C0;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
background: #999999;
color: #FFFFFF;
}
.tableNoBorderLabel
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
background: #999999;
color: #FFFFFF;
}
.tableBorderHeader
{
background: #CCCCCC;
color: #000000;
}
.tableBorderHeader td
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
border-top: solid 1px #CCCCCC;
border-left: solid 1px #CCCCCC;
}
.tableNoBorderHeader
{
background: #CCCCCC;
color: #000000;
}
.tableNoBorderHeader td
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
}
.tableBorderSection
{
background: #DDDDDD;
}
.tableBorderSection td
{
border-top: solid 1px #CCCCCC;
border-left: solid 1px #CCCCCC;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
}
.tableNoBorderSection
{
background: #DDDDDD;
}
.tableNoBorderSection td
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 100%;
font-weight: bold;
}
.tableBorderRecord td
{
border-bottom: solid 1px #CCCCCC;
border-right: solid 1px #CCCCCC;
}
.tableBorderRecord td td
{
border-width: 0px;
}
.tableNoBorderRecord td
{
}
.tableNoBorderRecord td td
{
}
.tableFootnotes
{
margin-top: 7px;
margin-left: 5px;
}
.dataTableBottomMargin
{
height: 1px;
overflow: hidden;
margin-bottom: 18px;
}
.footnote
{
font: 70% Arial;
position: relative;
top: -0.2em;
}
.footnoteText
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 65%;
}
.footnotes
{
margin-top: 11px;
margin-bottom: 36px;
}
pre.codeSample
{
background: #DDDDDD;
font-family: Lucida Console, Courier New;
font-size: 70%;
padding: 10px 15px 10px 25px;
margin-bottom: 1em;
}
span.codeSample
{
font-family: Lucida Console, Courier New;
}
/* End Versal-specific styles */
/* Section Start for MNP styles */
.mnpSearchButton {width:22px;}
table.centered-small {
background-color: #eef3f5;
border: 1px solid;
border-color: #dedeee;
width: 100%;
border-style: solid; border-width: thin;
font-size: 10pt; text-decoration: none;
}
table.centered-small a:link { text-decoration: none; }
table.centered-small a:visited { text-decoration: none; }
table.centered-small a:active { text-decoration: none; }
address { font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif; }
.fragment {
font-family: monospace, fixed;
font-size: 10ptr;
}
PRE.fragment {
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
margin-top: 4px;
margin-bottom: 4px;
margin-left: 2px;
margin-right: 8px;
padding-left: 6px;
padding-right: 6px;
padding-top: 4px;
padding-bottom: 4px;
}
/* Style for detailed member documentation */
.memtemplate {
font-size: 80%;
color: #606060;
font-weight: normal;
}
.memnav {
background-color: #e8eef2;
border: 1px solid #84b0c7;
text-align: center;
margin: 2px;
margin-right: 15px;
padding: 2px;
}
.memitem {
padding: 4px;
background-color: #eef3f5;
border-width: 1px;
border-style: solid;
border-color: #dedeee;
-moz-border-radius: 8px 8px 8px 8px;
}
.memname {
white-space: nowrap;
font-weight: normal;
font-size: 10pt;
}
.memdoc{
padding-left: 10px;
}
.memproto {
background-color: #d5e1e8;
width: 100%;
border-width: 1px;
border-style: solid;
border-color: #84b0c7;
font-weight: bold;
-moz-border-radius: 8px 8px 8px 8px;
}
.paramkey {
text-align: right;
}
.paramtype {
white-space: nowrap;
}
.paramname {
color: #602020;
font-style: italic;
white-space: nowrap;
}
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
DIV.groupHeader {
margin-left: 16px;
margin-top: 12px;
margin-bottom: 6px;
font-weight: bold;
}
DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% }
TD.indexkey {
background-color: #e8eef2;
font-weight: bold;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TD.indexvalue {
background-color: #e8eef2;
font-style: italic;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px;
border: 1px solid #CCCCCC;
}
TR.memlist {
background-color: #f0f0f0;
}
P.formulaDsp { text-align: center; }
IMG.formulaDsp { }
IMG.formulaInl { vertical-align: middle; }
SPAN.keyword { color: #008000 }
SPAN.keywordtype { color: #604020 }
SPAN.keywordflow { color: #e08000 }
SPAN.comment { color: #800000 }
SPAN.preprocessor { color: #806020 }
SPAN.stringliteral { color: #002080 }
SPAN.charliteral { color: #008080 }
.mdescLeft {
padding: 0px 8px 4px 8px;
font-size: 80%;
font-style: italic;
background-color: #FAFAFA;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.mdescRight {
padding: 0px 8px 4px 8px;
font-size: 80%;
font-style: italic;
background-color: #FAFAFA;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.memItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memItemRight {
padding: 1px 8px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplItemRight {
padding: 1px 8px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-size: 80%;
}
.memTemplParams {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-top-style: solid;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
color: #606060;
background-color: #FAFAFA;
font-size: 80%;
}
dl { font-size: 10pt; }
td { font-size: 10pt; }
th { font-weight: normal; }
#nav {font-family: Verdana, Arial, sans-serif; margin:0 0 0 10px;border-bottom:3px solid #DDE4EC; height:35px; min-width:500px;}
#nav ul { list-style: none; margin-top:15px; padding: 0; font-size:150%; float:left; }
#nav ul li, div.sitemenu ul li a, div.sitemenu ul li a:visited {color: #4E688E;display: block;padding: 0 5px;text-decoration: none;white-space: nowrap;float:left;}
#nav ul li a:hover {color: #000;text-decoration: none;}
#nav ul li a:active {color: #cfdbe6;text-decoration: none;}

1610
doc/z3.dox Normal file

File diff suppressed because it is too large Load diff

BIN
doc/z3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -1,20 +0,0 @@
CC=@CC@
PREFIX=@prefix@
CXX=@CXX@
CXXFLAGS=@CPPFLAGS@ @CXXFLAGS@ -DZ3DEBUG -D_TRACE -c -g -Wall -msse -msse2
CXX_OUT_FLAG=-o
OBJ_EXT=.o
LIB_EXT=.a
AR=@AR@
AR_FLAGS=rcs
AR_OUTFLAG=
EXE_EXT=
LINK=@CXX@
LINK_FLAGS=
LINK_OUT_FLAG=-o
LINK_EXTRA_FLAGS=-lpthread @LDFLAGS@
SO_EXT=@SO_EXT@
SLINK=@CXX@
SLINK_FLAGS=@SLIBFLAGS@
SLINK_EXTRA_FLAGS=@SLIBEXTRAFLAGS@
SLINK_OUT_FLAG=-o

View file

@ -1,20 +0,0 @@
CC=@CC@
PREFIX=@prefix@
CXX=@CXX@
CXXFLAGS=@CPPFLAGS@ @CXXFLAGS@ -c -O3 -D _EXTERNAL_RELEASE -fomit-frame-pointer -msse -msse2
CXX_OUT_FLAG=-o
OBJ_EXT=.o
LIB_EXT=.a
AR=@AR@
AR_FLAGS=rcs
AR_OUTFLAG=
EXE_EXT=
LINK=@CXX@
LINK_FLAGS=
LINK_OUT_FLAG=-o
LINK_EXTRA_FLAGS=-lpthread @LDFLAGS@
SO_EXT=@SO_EXT@
SLINK=@CXX@
SLINK_FLAGS=@SLIBFLAGS@
SLINK_EXTRA_FLAGS=@SLIBEXTRAFLAGS@
SLINK_OUT_FLAG=-o

View file

@ -1,21 +0,0 @@
CC=cl
CXX=cl
CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _AMD64_ /D _DEBUG /D Z3DEBUG /D _CONSOLE /D _TRACE /D _WINDOWS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze-
CXX_OUT_FLAG=/Fo
OBJ_EXT=.obj
LIB_EXT=.lib
AR=lib
AR_FLAGS=/nologo
AR_OUTFLAG=/OUT:
EXE_EXT=.exe
LINK=cl
LINK_FLAGS=/nologo /MDd
LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT
LINK_OUT_FLAG=/Fe
SO_EXT=.dll
SLINK=cl
SLINK_FLAGS=/nologo /LDd
SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO
SLINK_OUT_FLAG=/Fe

View file

@ -1,21 +0,0 @@
CC=cl
CXX=cl
CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D Z3DEBUG /D _CONSOLE /D _TRACE /D _WINDOWS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2
CXX_OUT_FLAG=/Fo
OBJ_EXT=.obj
LIB_EXT=.lib
AR=lib
AR_FLAGS=/nologo
AR_OUTFLAG=/OUT:
EXE_EXT=.exe
LINK=cl
LINK_FLAGS=/nologo /MDd
LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT
LINK_OUT_FLAG=/Fe
SO_EXT=.dll
SLINK=cl
SLINK_FLAGS=/nologo /LDd
SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO
SLINK_OUT_FLAG=/Fe

View file

@ -1,21 +0,0 @@
CC=cl
CXX=cl
CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /O2 /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG /D _LIB /D _WINDOWS /D _AMD64_ /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP
CXX_OUT_FLAG=/Fo
OBJ_EXT=.obj
LIB_EXT=.lib
AR=lib
AR_FLAGS=/nologo
AR_OUTFLAG=/OUT:
EXE_EXT=.exe
LINK=cl
LINK_FLAGS=/nologo /MD
LINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608
LINK_OUT_FLAG=/Fe
SO_EXT=.dll
SLINK=cl
SLINK_FLAGS=/nologo /LD
SLINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608
SLINK_OUT_FLAG=/Fe

View file

@ -1,23 +0,0 @@
CC=cl
CXX=cl
CXXFLAGS=/nologo /c /Zi /openmp /W3 /WX- /O2 /Oy- /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG /D _CONSOLE /D _WINDOWS /D ASYNC_COMMANDS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2
CXX_OUT_FLAG=/Fo
OBJ_EXT=.obj
LIB_EXT=.lib
AR=lib
AR_FLAGS=/nologo
AR_OUTFLAG=/OUT:
EXE_EXT=.exe
LINK=cl
LINK_FLAGS=/nologo /MD
LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT
LINK_OUT_FLAG=/Fe
SO_EXT=.dll
SLINK=cl
SLINK_FLAGS=/nologo /LD
SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO
SLINK_OUT_FLAG=/Fe

View file

@ -71,6 +71,7 @@ def init_project_def():
static=build_static_lib(),
export_files=API_files)
add_dot_net_dll('dotnet', ['api_dll'], 'api/dotnet', dll_name='Microsoft.Z3', assembly_info_dir='Properties')
add_java_dll('java', ['api_dll'], 'api/java', dll_name='libz3j')
add_hlib('cpp', 'api/c++', includes2install=['z3++.h'])
set_z3py_dir('api/python')
# Examples

View file

@ -6,17 +6,40 @@
#
# Author: Leonardo de Moura (leonardo)
############################################
import sys
if sys.version >= "3":
print "ERROR: python 2.x required."
exit(1)
import os
import glob
import re
import getopt
import sys
import shutil
from mk_exception import *
from fnmatch import fnmatch
import distutils.sysconfig
import compileall
import subprocess
def getenv(name, default):
try:
return os.environ[name]
except:
return default
CXX=getenv("CXX", None)
CC=getenv("CC", None)
CPPFLAGS=getenv("CPPFLAGS", "")
CXXFLAGS=getenv("CXXFLAGS", "")
LDFLAGS=getenv("LDFLAGS", "")
JAVA=getenv("JAVA", "java")
JAVAC=getenv("JAVAC", "javac")
JAVAH=getenv("JAVAH", "javah")
CXX_COMPILERS=['g++', 'clang++']
C_COMPILERS=['gcc', 'clang']
PYTHON_PACKAGE_DIR=distutils.sysconfig.get_python_lib()
BUILD_DIR='build'
REV_BUILD_DIR='..'
@ -40,12 +63,168 @@ Z3PY_SRC_DIR=None
VS_PROJ = False
TRACE = False
DOTNET_ENABLED=False
JAVA_ENABLED=False
STATIC_LIB=False
VER_MAJOR=None
VER_MINOR=None
VER_BUILD=None
VER_REVISION=None
PREFIX='/usr'
GMP=False
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in getenv("PATH", "").split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
class TempFile:
def __init__(self, name):
try:
self.name = name
self.fname = open(name, 'w')
except:
raise MKException("Failed to create temporary file '%s'" % self.name)
def add(self, s):
self.fname.write(s)
def commit(self):
self.fname.close()
def __del__(self):
self.fname.close()
try:
os.remove(self.name)
except:
raise MKException("Failed to eliminate temporary file '%s'" % self.name)
def exec_cmd(cmd):
if isinstance(cmd, str):
cmd = cmd.split(' ')
new_cmd = []
for e in cmd:
e = e.strip(' ')
if e != "":
se = e.split(' ')
if len(se) > 1:
new_cmd.extend(se)
else:
new_cmd.append(e)
cmd = new_cmd
null = open(os.devnull, 'wb')
try:
return subprocess.call(cmd, stdout=null, stderr=null)
except:
# Failed to create process
return 1
# rm -f fname
def rmf(fname):
if os.path.exists(fname):
os.remove(fname)
def exec_compiler_cmd(cmd):
r = exec_cmd(cmd)
rmf('a.out')
return r
def test_cxx_compiler(cc):
if is_verbose():
print "Testing %s..." % cc
t = TempFile('tst.cpp')
t.add('#include<iostream>\nint main() { return 0; }\n')
t.commit()
return exec_compiler_cmd([cc, CPPFLAGS, CXXFLAGS, 'tst.cpp', LDFLAGS]) == 0
def test_c_compiler(cc):
if is_verbose():
print "Testing %s..." % cc
t = TempFile('tst.c')
t.add('#include<stdio.h>\nint main() { return 0; }\n')
t.commit()
return exec_compiler_cmd([cc, CPPFLAGS, 'tst.c', LDFLAGS]) == 0
def test_gmp(cc):
if is_verbose():
print "Testing GMP..."
t = TempFile('tst.cpp')
t.add('#include<gmp.h>\nint main() { mpz_t t; mpz_init(t); mpz_clear(t); return 0; }\n')
t.commit()
return exec_compiler_cmd([cc, CPPFLAGS, CXXFLAGS, 'tst.cpp', LDFLAGS, '-lgmp']) == 0
def check_java():
t = TempFile('Hello.java')
t.add('public class Hello { public static void main(String[] args) { System.out.println("Hello, World"); }}\n')
t.commit()
if is_verbose():
print "Testing %s..." % JAVAC
r = exec_cmd([JAVAC, 'Hello.java'])
if r != 0:
raise MKException('Failed testing Java compiler. Set environment variable JAVAC with the path to the Java compiler')
if is_verbose():
print "Testing %s..." % JAVA
r = exec_cmd([JAVA, 'Hello'])
rmf('Hello.class')
if r != 0:
raise MKException('Failed testing Java program. Set environment variable JAVA with the path to the Java virtual machine')
t2 = TempFile('Z3Native.java')
t2.add('public final class Z3Native { public static native long mkConfig(); }\n')
t2.commit()
if is_verbose():
print "Testing %s (for JNI)..." % JAVAC
r = exec_cmd([JAVAC, 'Z3Native.java'])
if r != 0:
raise MKException('Failed testing Java compiler (for source containing JNI bindings). Set environment variable JAVAC with the path to the Java compiler')
if is_verbose():
print "Testing %s..." % JAVAH
r = exec_cmd([JAVAH, 'Z3Native'])
if not os.path.exists('Z3Native.h'):
r = 1
rmf('Z3Native.h')
rmf('Z3Native.class')
if r != 0:
raise MKException('Failed testing Java JNI Header file generator. Set environment variable JAVAH with the path to the Java JNI header file generator')
def is64():
return sys.maxsize >= 2**32
def check_ar():
if is_verbose():
print "Testing ar..."
if which('ar')== None:
raise MKException('ar (archive tool) was not found')
def find_cxx_compiler():
global CXX, CXX_COMPILERS
if CXX != None:
if test_cxx_compiler(CXX):
return CXX
for cxx in CXX_COMPILERS:
if test_cxx_compiler(cxx):
CXX = 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.')
def find_c_compiler():
global CC, C_COMPILERS
if CC != None:
if test_c_compiler(CC):
return CC
for c in C_COMPILERS:
if test_c_compiler(c):
CC = c
return CC
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):
global VER_MAJOR, VER_MINOR, VER_BUILD, VER_REVISION
@ -109,69 +288,91 @@ if os.name == 'nt':
# Enable .Net bindings by default on windows
DOTNET_ENABLED=True
def display_help():
def display_help(exit_code):
print "mk_make.py: Z3 Makefile generator\n"
print "This script generates the Makefile for the Z3 theorem prover."
print "It must be executed from the Z3 root directory."
print "\nOptions:"
print " -h, --help display this message."
print " -s, --silent do not print verbose messages."
if not IS_WINDOWS:
print " -p <dir>, --prefix=<dir> installation prefix (default: %s)." % PREFIX
print " -b <sudir>, --build=<subdir> subdirectory where Z3 will be built (default: build)."
print " -d, --debug compile Z3 in debug mode."
print " -x, --x64 create 64 binary when using Visual Studio."
print " -m, --makefiles generate only makefiles."
print " -c, --showcpp display file .cpp file names before invoking compiler."
print " -v, --vsproj generate Visual Studio Project Files."
print " -t, --trace enable tracing in release mode."
print " -n, --nodotnet do not generate Microsoft.Z3.dll make rules."
if IS_WINDOWS:
print " -x, --x64 create 64 binary when using Visual Studio."
print " -m, --makefiles generate only makefiles."
if IS_WINDOWS:
print " -v, --vsproj generate Visual Studio Project Files."
if IS_WINDOWS:
print " -n, --nodotnet do not generate Microsoft.Z3.dll make rules."
print " -j, --java generate Java bindinds."
print " --staticlib build Z3 static library."
exit(0)
if not IS_WINDOWS:
print " -g, --gmp use GMP."
if not IS_WINDOWS:
print ""
print "Some influential environment variables:"
print " CXX C++ compiler"
print " CC C compiler (only used for compiling examples)"
print " LDFLAGS Linker flags, e.g., -L<lib dir> if you have libraries in a non-standard directory"
print " CPPFLAGS Preprocessor flags, e.g., -I<include dir> if you have header files in a non-standard directory"
print " CXXFLAGS C++ compiler flags"
print " JAVA Java virtual machine (only relevant if -j or --java option is provided)"
print " JAVAC Java compiler (only relevant if -j or --java option is provided)"
print " JAVAH Java H file generator for JNI bindinds (only relevant if -j or --java option is provided)"
exit(exit_code)
# Parse configuration option for mk_make script
def parse_options():
global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE, DOTNET_ENABLED, STATIC_LIB
options, remainder = getopt.gnu_getopt(sys.argv[1:], 'b:dsxhmcvtn', ['build=',
'debug',
'silent',
'x64',
'help',
'makefiles',
'showcpp',
'vsproj',
'trace',
'nodotnet',
'staticlib'
])
for opt, arg in options:
if opt in ('-b', '--build'):
if arg == 'src':
raise MKException('The src directory should not be used to host the Makefile')
set_build_dir(arg)
elif opt in ('-s', '--silent'):
VERBOSE = False
elif opt in ('-d', '--debug'):
DEBUG_MODE = True
elif opt in ('-x', '--x64'):
if not IS_WINDOWS:
raise MKException('x64 compilation mode can only be specified when using Visual Studio')
VS_X64 = True
elif opt in ('-h', '--help'):
display_help()
elif opt in ('-m', '--onlymakefiles'):
ONLY_MAKEFILES = True
elif opt in ('-c', '--showcpp'):
SHOW_CPPS = True
elif opt in ('-v', '--vsproj'):
VS_PROJ = True
elif opt in ('-t', '--trace'):
TRACE = True
elif opt in ('-n', '--nodotnet'):
DOTNET_ENABLED = False
elif opt in ('--staticlib'):
STATIC_LIB = True
else:
raise MKException("Invalid command line option '%s'" % opt)
global VERBOSE, DEBUG_MODE, IS_WINDOWS, VS_X64, ONLY_MAKEFILES, SHOW_CPPS, VS_PROJ, TRACE
global DOTNET_ENABLED, JAVA_ENABLED, STATIC_LIB, PREFIX, GMP
try:
options, remainder = getopt.gnu_getopt(sys.argv[1:],
'b:dsxhmcvtnp:gj',
['build=', 'debug', 'silent', 'x64', 'help', 'makefiles', 'showcpp', 'vsproj',
'trace', 'nodotnet', 'staticlib', 'prefix=', 'gmp', 'java'])
for opt, arg in options:
if opt in ('-b', '--build'):
if arg == 'src':
raise MKException('The src directory should not be used to host the Makefile')
set_build_dir(arg)
elif opt in ('-s', '--silent'):
VERBOSE = False
elif opt in ('-d', '--debug'):
DEBUG_MODE = True
elif opt in ('-x', '--x64'):
if not IS_WINDOWS:
raise MKException('x64 compilation mode can only be specified when using Visual Studio')
VS_X64 = True
elif opt in ('-h', '--help'):
display_help(0)
elif opt in ('-m', '--onlymakefiles'):
ONLY_MAKEFILES = True
elif opt in ('-c', '--showcpp'):
SHOW_CPPS = True
elif opt in ('-v', '--vsproj'):
VS_PROJ = True
elif opt in ('-t', '--trace'):
TRACE = True
elif opt in ('-n', '--nodotnet'):
DOTNET_ENABLED = False
elif opt in ('--staticlib'):
STATIC_LIB = True
elif opt in ('-p', '--prefix'):
PREFIX = arg
elif opt in ('-g', '--gmp'):
GMP = True
elif opt in ('-j', '--java'):
JAVA_ENABLED = True
else:
print "ERROR: Invalid command line option '%s'" % opt
display_help(1)
except:
print "ERROR: Invalid command line option"
display_help(1)
# Return a list containing a file names included using '#include' in
# the given C/C++ file named fname.
def extract_c_includes(fname):
@ -250,6 +451,9 @@ def get_z3py_dir():
def is_verbose():
return VERBOSE
def is_java_enabled():
return JAVA_ENABLED
def get_cpp_files(path):
return filter(lambda f: f.endswith('.cpp'), os.listdir(path))
@ -343,14 +547,7 @@ class Component:
out.write('\n')
if SHOW_CPPS:
out.write('\t@echo %s/%s\n' % (self.src_dir, cppfile))
# TRACE is enabled in debug mode by default
extra_opt = ''
if TRACE and not DEBUG_MODE:
if IS_WINDOWS:
extra_opt = '/D _TRACE'
else:
extra_opt = '-D _TRACE'
out.write('\t@$(CXX) $(CXXFLAGS) %s $(%s) $(CXX_OUT_FLAG)%s %s\n' % (extra_opt, include_defs, objfile, srcfile))
out.write('\t@$(CXX) $(CXXFLAGS) $(%s) $(CXX_OUT_FLAG)%s %s\n' % (include_defs, objfile, srcfile))
def mk_makefile(self, out):
include_defs = mk_fresh_name('includes')
@ -693,6 +890,21 @@ class DotNetDLLComponent(Component):
shutil.copy('%s/%s.dll' % (build_path, self.dll_name),
'%s/bin/%s.dll' % (dist_path, self.dll_name))
class JavaDLLComponent(Component):
def __init__(self, name, dll_name, path, deps):
Component.__init__(self, name, path, deps)
if dll_name == None:
dll_name = name
self.dll_name = dll_name
def mk_makefile(self, out):
return
def main_component(self):
return JAVA_ENABLED
class ExampleComponent(Component):
def __init__(self, name, path):
Component.__init__(self, name, path, [])
@ -826,6 +1038,10 @@ def add_dot_net_dll(name, deps=[], path=None, dll_name=None, assembly_info_dir=N
c = DotNetDLLComponent(name, dll_name, path, deps, assembly_info_dir)
reg_component(name, c)
def add_java_dll(name, deps=[], path=None, dll_name=None):
c = JavaDLLComponent(name, dll_name, path, deps)
reg_component(name, c)
def add_cpp_example(name, path=None):
c = CppExampleComponent(name, path)
reg_component(name, c)
@ -842,24 +1058,153 @@ def add_z3py_example(name, path=None):
c = PythonExampleComponent(name, path)
reg_component(name, c)
# Copy configuration correct file to BUILD_DIR
def cp_config_mk():
def mk_config():
if ONLY_MAKEFILES:
return
config = open('%s/config.mk' % BUILD_DIR, 'w')
if IS_WINDOWS:
if VS_X64:
if DEBUG_MODE:
shutil.copyfile('scripts/config-vs-debug-x64.mk', '%s/config.mk' % BUILD_DIR)
else:
shutil.copyfile('scripts/config-vs-release-x64.mk', '%s/config.mk' % BUILD_DIR)
else:
if DEBUG_MODE:
shutil.copyfile('scripts/config-vs-debug.mk', '%s/config.mk' % BUILD_DIR)
else:
shutil.copyfile('scripts/config-vs-release.mk', '%s/config.mk' % BUILD_DIR)
else:
config.write(
'CC=cl\n'
'CXX=cl\n'
'CXX_OUT_FLAG=/Fo\n'
'OBJ_EXT=.obj\n'
'LIB_EXT=.lib\n'
'AR=lib\n'
'AR_FLAGS=/nologo\n'
'AR_OUTFLAG=/OUT:\n'
'EXE_EXT=.exe\n'
'LINK=cl\n'
'LINK_OUT_FLAG=/Fe\n'
'SO_EXT=.dll\n'
'SLINK=cl\n'
'SLINK_OUT_FLAG=/Fe\n')
if DEBUG_MODE:
shutil.copyfile('scripts/config-debug.mk', '%s/config.mk' % BUILD_DIR)
config.write(
'LINK_FLAGS=/nologo /MDd\n'
'SLINK_FLAGS=/nologo /LDd\n')
if not VS_X64:
config.write(
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D Z3DEBUG /D _CONSOLE /D _TRACE /D _WINDOWS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n'
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
else:
config.write(
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /Od /Oy- /D WIN32 /D _AMD64_ /D _DEBUG /D Z3DEBUG /D _CONSOLE /D _TRACE /D _WINDOWS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze-\n'
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
else:
shutil.copyfile('scripts/config-release.mk', '%s/config.mk' % BUILD_DIR)
# Windows Release mode
config.write(
'LINK_FLAGS=/nologo /MD\n'
'SLINK_FLAGS=/nologo /LD\n')
extra_opt = ''
if TRACE:
extra_opt = '/D _TRACE'
if not VS_X64:
config.write(
'CXXFLAGS=/nologo /c /Zi /openmp /W3 /WX- /O2 /Oy- /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _CONSOLE /D _WINDOWS /D ASYNC_COMMANDS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /analyze- /arch:SSE2\n' % extra_opt)
config.write(
'LINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT\n'
'SLINK_EXTRA_FLAGS=/link /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE:NO\n')
else:
config.write(
'CXXFLAGS=/c /Zi /nologo /openmp /W3 /WX- /O2 /D _EXTERNAL_RELEASE /D WIN32 /D NDEBUG %s /D _LIB /D _WINDOWS /D _AMD64_ /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP\n' % extra_opt)
config.write(
'LINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608\n'
'SLINK_EXTRA_FLAGS=/link /MACHINE:X64 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608\n')
# End of Windows VS config.mk
else:
global CXX, CC, GMP, CPPFLAGS, CXXFLAGS, LDFLAGS
ARITH = "internal"
check_ar()
CXX = find_cxx_compiler()
CC = find_c_compiler()
if GMP:
test_gmp(CXX)
ARITH = "gmp"
CPPFLAGS = '%s -D_MP_GMP' % CPPFLAGS
LDFLAGS = '%s -lgmp' % LDFLAGS
else:
CPPFLAGS = '%s -D_MP_INTERNAL' % CPPFLAGS
CXXFLAGS = '%s -c' % CXXFLAGS
if CXX == 'g++':
CXXFLAGS = '%s -fopenmp -mfpmath=sse' % CXXFLAGS
LDFLAGS = '%s -fopenmp' % LDFLAGS
SLIBEXTRAFLAGS = '-fopenmp'
else:
# CLang does not support OMP
CXXFLAGS = '%s -D_NO_OMP_' % CXXFLAGS
SLIBEXTRAFLAGS = ''
sysname = os.uname()[0]
if sysname == 'Darwin':
SO_EXT = '.dylib'
SLIBFLAGS = '-dynamiclib'
elif sysname == 'Linux':
CXXFLAGS = '%s -fno-strict-aliasing -D_LINUX_' % CXXFLAGS
if CXX == 'clang++':
CXXFLAGS = '%s -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value' % CXXFLAGS
SO_EXT = '.so'
LDFLAGS = '%s -lrt' % LDFLAGS
SLIBFLAGS = '-shared'
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
elif sysname == 'FreeBSD':
CXXFLAGS = '%s -fno-strict-aliasing -D_FREEBSD_' % CXXFLAGS
SO_EXT = '.so'
LDFLAGS = '%s -lrt' % LDFLAGS
SLIBFLAGS = '-shared'
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
elif sysname[:6] == 'CYGWIN':
CXXFLAGS = '%s -D_CYGWIN -fno-strict-aliasing' % CXXFLAGS
SO_EXT = '.dll'
SLIBFLAGS = '-shared'
else:
raise MKException('Unsupported platform: %s' % sysname)
if is64():
CXXFLAGS = '%s -fPIC' % CXXFLAGS
CPPFLAGS = '%s -D_AMD64_' % CPPFLAGS
if sysname == 'Linux':
CPPFLAGS = '%s -D_USE_THREAD_LOCAL' % CPPFLAGS
if DEBUG_MODE:
CPPFLAGS = '%s -DZ3DEBUG' % CPPFLAGS
if TRACE or DEBUG_MODE:
CPPFLAGS = '%s -D_TRACE' % CPPFLAGS
if DEBUG_MODE:
CXXFLAGS = '%s -g -Wall' % CXXFLAGS
else:
CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE -fomit-frame-pointer' % CXXFLAGS
CXXFLAGS = '%s -msse -msse2' % CXXFLAGS
config.write('PREFIX=%s\n' % PREFIX)
config.write('CC=%s\n' % CC)
config.write('CXX=%s\n' % CXX)
config.write('CXXFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS))
config.write('CXX_OUT_FLAG=-o \n')
config.write('OBJ_EXT=.o\n')
config.write('LIB_EXT=.a\n')
config.write('AR=ar\n')
config.write('AR_FLAGS=rcs\n')
config.write('AR_OUTFLAG=\n')
config.write('EXE_EXT=\n')
config.write('LINK=%s\n' % CXX)
config.write('LINK_FLAGS=\n')
config.write('LINK_OUT_FLAG=-o \n')
config.write('LINK_EXTRA_FLAGS=-lpthread %s\n' % LDFLAGS)
config.write('SO_EXT=%s\n' % SO_EXT)
config.write('SLINK=%s\n' % CXX)
config.write('SLINK_FLAGS=%s\n' % SLIBFLAGS)
config.write('SLINK_EXTRA_FLAGS=%s\n' % SLIBEXTRAFLAGS)
config.write('SLINK_OUT_FLAG=-o \n')
if is_verbose():
print 'Host platform: %s' % sysname
print 'C++ Compiler: %s' % CXX
print 'C Compiler : %s' % CC
print 'Arithmetic: %s' % ARITH
print 'Prefix: %s' % PREFIX
print '64-bit: %s' % is64()
if is_java_enabled():
print 'Java Compiler: %s' % JAVAC
print 'Java VM: %s' % JAVA
print 'Java H gen.: %s' % JAVAH
def mk_install(out):
out.write('install:\n')
@ -883,7 +1228,7 @@ def mk_uninstall(out):
# Generate the Z3 makefile
def mk_makefile():
mk_dir(BUILD_DIR)
cp_config_mk()
mk_config()
if VERBOSE:
print "Writing %s/Makefile" % BUILD_DIR
out = open('%s/Makefile' % BUILD_DIR, 'w')
@ -1219,6 +1564,8 @@ def mk_bindings(api_files):
new_api_files.append('%s/%s' % (api_file_path.src_dir, api_file))
g = {}
g["API_FILES"] = new_api_files
if is_java_enabled():
check_java()
execfile('scripts/update_api.py', g) # HACK
cp_z3pyc_to_build()

View file

@ -132,6 +132,11 @@ Type2Dotnet = { VOID : 'void', VOID_PTR : 'IntPtr', INT : 'int', UINT : 'uint',
STRING : 'string', STRING_PTR : 'byte**', BOOL : 'int', SYMBOL : 'IntPtr',
PRINT_MODE : 'uint', ERROR_CODE : 'uint' }
# Mapping to Java types
Type2Java = { VOID : 'void', VOID_PTR : 'long', INT : 'int', UINT : 'int', INT64 : 'long', UINT64 : 'long', DOUBLE : 'double',
STRING : 'String', STRING_PTR : 'StringPtr',
BOOL : 'boolean', SYMBOL : 'long', PRINT_MODE : 'int', ERROR_CODE : 'int' }
next_type_id = FIRST_OBJ_ID
def def_Type(var, c_type, py_type):
@ -165,6 +170,13 @@ def type2dotnet(ty):
global Type2Dotnet
return Type2Dotnet[ty]
def type2java(ty):
global Type2Java
if (ty >= FIRST_OBJ_ID):
return 'long'
else:
return Type2Java[ty]
def _in(ty):
return (IN, ty);
@ -224,6 +236,20 @@ def param2dotnet(p):
else:
return type2dotnet(param_type(p))
def param2java(p):
k = param_kind(p)
if k == OUT:
if param_type(p) == INT or param_type(p) == UINT:
return "IntPtr"
elif param_type(p) == INT64 or param_type(p) == UINT64:
return "LongPtr"
else:
return "long" # ?
if k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY:
return "%s[]" % type2java(param_type(p))
else:
return type2java(param_type(p))
def param2pystr(p):
if param_kind(p) == IN_ARRAY or param_kind(p) == OUT_ARRAY or param_kind(p) == IN_ARRAY or param_kind(p) == INOUT_ARRAY or param_kind(p) == OUT:
return "ctypes.POINTER(%s)" % type2pystr(param_type(p))
@ -399,6 +425,48 @@ def mk_dotnet_wrappers():
dotnet.write(" }\n\n")
dotnet.write("}\n\n")
def java_method_name(name):
result = ''
name = name[3:] # Remove Z3_
n = len(name)
i = 0
while i < n:
if name[i] == '_':
i = i + 1
if i < n:
result += name[i].upper()
else:
result += name[i]
i = i + 1
return result
def mk_java():
if not is_java_enabled():
return
java_dir = get_component('java').src_dir
java_nativef = '%s/Z3Native.java' % java_dir
java_wrapperf = '%s/Z3Native.c' % java_dir
java_native = open(java_nativef, 'w')
java_native.write('public final class Z3Native {\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 StringPtr { public String value; }\n')
for name, result, params in _dotnet_decls:
java_native.write(' public static native %s %s(' % (type2java(result), java_method_name(name)))
first = True
i = 0;
for param in params:
if first:
first = False
else:
java_native.write(', ')
java_native.write('%s a%d' % (param2java(param), i))
i = i + 1
java_native.write(');\n')
java_native.write('}\n');
if is_verbose():
print "Generated '%s'" % java_nativef
def mk_log_header(file, name, params):
file.write("void log_%s(" % name)
i = 0
@ -668,6 +736,7 @@ mk_bindings()
mk_py_wrappers()
mk_dotnet()
mk_dotnet_wrappers()
mk_java()
log_h.close()
log_c.close()

View file

@ -449,6 +449,23 @@ extern "C" {
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
}
Z3_ast_vector Z3_API Z3_fixedpoint_get_assertions(
Z3_context c,
Z3_fixedpoint d)
{
Z3_TRY;
LOG_Z3_fixedpoint_get_assertions(c, d);
ast_manager& m = mk_c(c)->m();
Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, m);
mk_c(c)->save_object(v);
unsigned num_asserts = to_fixedpoint_ref(d)->ctx().get_num_assertions();
for (unsigned i = 0; i < num_asserts; ++i) {
v->m_ast_vector.push_back(to_fixedpoint_ref(d)->ctx().get_assertion(i));
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
}
void Z3_API Z3_fixedpoint_set_reduce_assign_callback(
Z3_context c, Z3_fixedpoint d, Z3_fixedpoint_reduce_assign_callback_fptr f) {

View file

@ -278,6 +278,23 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Retrieve set of assertions added to fixedpoint context.
/// </summary>
public BoolExpr[] Assertions {
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector v = 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;
}
}
#region Internal
internal Fixedpoint(Context ctx, IntPtr obj)

View file

@ -6145,7 +6145,11 @@ class Fixedpoint(Z3PPObject):
def get_rules(self):
"""retrieve rules that have been added to fixedpoint context"""
return AstVector(Z3_fixedpoint_get_rules(self.ctx.ref(), self.fixedpoint), self.ctx)
def get_assertions(self):
"""retrieve assertions that have been added to fixedpoint context"""
return AstVector(Z3_fixedpoint_get_assertions(self.ctx.ref(), self.fixedpoint), self.ctx)
def __repr__(self):
"""Return a formatted string with all added rules and constraints."""
return self.sexpr()

View file

@ -5535,7 +5535,7 @@ END_MLAPI_EXCLUDE
of sorts in the domain of \c r. Each sort in the domain should be an integral
(bit-vector, Boolean or or finite domain sort).
The call has the same effect as adding a rule where \r is applied to the arguments.
The call has the same effect as adding a rule where \c r is applied to the arguments.
def_API('Z3_fixedpoint_add_fact', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL), _in(UINT), _in_array(3, UINT)))
*/
@ -5696,6 +5696,15 @@ END_MLAPI_EXCLUDE
__in Z3_context c,
__in Z3_fixedpoint f);
/**
\brief Retrieve set of background assertions from fixedpoint context.
def_API('Z3_fixedpoint_get_assertions', AST_VECTOR, (_in(CONTEXT),_in(FIXEDPOINT)))
*/
Z3_ast_vector Z3_API Z3_fixedpoint_get_assertions(
__in Z3_context c,
__in Z3_fixedpoint f);
/**
\brief Set parameters on fixedpoint context.

View file

@ -29,6 +29,7 @@ Revision History:
#include"vector.h"
#include"for_each_ast.h"
#include"decl_collector.h"
#include"smt2_util.h"
// ---------------------------------------
// smt_renaming
@ -67,32 +68,10 @@ symbol smt_renaming::fix_symbol(symbol s, int k) {
return symbol(buffer.str().c_str());
}
buffer << "|";
if (*data == '|') {
while (*data) {
if (*data == '|') {
if (!data[1]) {
break;
}
buffer << "\\";
}
buffer << *data;
++data;
}
}
else {
while (*data) {
if (*data == '|') {
buffer << "\\";
}
buffer << *data;
++data;
}
}
buffer << mk_smt2_quoted_symbol(s);
if (k > 0) {
buffer << k;
}
buffer << "|";
return symbol(buffer.str().c_str());
}

View file

@ -306,7 +306,7 @@ cmd_context::cmd_context(front_end_params * params, bool main_ctx, ast_manager *
m_params_owner(params == 0),
m_logic(l),
m_interactive_mode(false),
m_global_decls(!this->params().m_smtlib2_compliant), // SMTLIB 2.0 uses scoped decls.
m_global_decls(false), // :global-decls is false by default.
m_print_success(false), // params.m_smtlib2_compliant),
m_random_seed(0),
m_produce_unsat_cores(false),
@ -477,7 +477,8 @@ bool cmd_context::logic_has_bv_core(symbol const & s) const {
s == "QF_UFBV" ||
s == "QF_ABV" ||
s == "QF_AUFBV" ||
s == "QF_BVRE";
s == "QF_BVRE" ||
s == "HORN";
}
bool cmd_context::logic_has_horn(symbol const& s) const {
@ -518,7 +519,8 @@ bool cmd_context::logic_has_array_core(symbol const & s) const {
s == "AUFBV" ||
s == "ABV" ||
s == "QF_ABV" ||
s == "QF_AUFBV";
s == "QF_AUFBV" ||
s == "HORN";
}
bool cmd_context::logic_has_array() const {

View file

@ -315,7 +315,7 @@ private:
if (m_params.get_bool(":print-certificate", false)) {
datalog::context& dlctx = m_dl_ctx->dlctx();
if (!dlctx.display_certificate(ctx.regular_stream())) {
throw cmd_exception("certificates are not supported for selected DL_ENGINE");
throw cmd_exception("certificates are not supported for the selected engine");
}
ctx.regular_stream() << "\n";
}

View file

@ -238,6 +238,7 @@ namespace datalog {
m_pinned(m),
m_vars(m),
m_rule_set(*this),
m_rule_fmls(m),
m_background(m),
m_closed(false),
m_saturation_was_run(false),
@ -521,10 +522,19 @@ namespace datalog {
}
void context::add_rule(expr* rl, symbol const& name) {
m_rule_fmls.push_back(rl);
m_rule_names.push_back(name);
}
void context::flush_add_rules() {
datalog::rule_manager& rm = get_rule_manager();
datalog::rule_ref_vector rules(rm);
rm.mk_rule(rl, rules, name);
for (unsigned i = 0; i < m_rule_fmls.size(); ++i) {
rm.mk_rule(m_rule_fmls[i].get(), rules, m_rule_names[i]);
}
add_rules(rules);
m_rule_fmls.reset();
m_rule_names.reset();
}
//
@ -1223,6 +1233,7 @@ namespace datalog {
}
void context::new_query() {
flush_add_rules();
if (m_last_result_relation) {
m_last_result_relation->deallocate();
m_last_result_relation = 0;
@ -1512,7 +1523,7 @@ namespace datalog {
switch(get_engine()) {
case DATALOG_ENGINE:
return false;
case PDR_ENGINE:
case QPDR_ENGINE:
ensure_pdr();
m_pdr->display_certificate(out);
return true;
@ -1618,6 +1629,10 @@ namespace datalog {
names.push_back((*it)->name());
}
}
for (unsigned i = 0; i < m_rule_fmls.size(); ++i) {
rules.push_back(m_rule_fmls[i].get());
names.push_back(m_rule_names[i]);
}
smt2_pp_environment_dbg env(m);
pp_params params;
@ -1674,8 +1689,11 @@ namespace datalog {
declare_vars(rules, fresh_names, out);
}
if (num_axioms > 0 && !use_fixedpoint_extensions) {
throw default_exception("Background axioms cannot be used with SMT-LIB2 HORN format");
}
for (unsigned i = 0; i < num_axioms; ++i) {
SASSERT(use_fixedpoint_extensions);
out << "(assert ";
ast_smt2_pp(out, axioms[i], env, params);
out << ")\n";
@ -1683,7 +1701,8 @@ namespace datalog {
for (unsigned i = 0; i < rules.size(); ++i) {
out << (use_fixedpoint_extensions?"(rule ":"(assert ");
expr* r = rules[i].get();
if (symbol::null != names[i]) {
symbol nm = names[i];
if (symbol::null != nm) {
out << "(! ";
}
if (use_fixedpoint_extensions) {
@ -1692,8 +1711,14 @@ namespace datalog {
else {
out << mk_smt_pp(r, m);
}
if (symbol::null != names[i]) {
out << " :named " << names[i] << ")";
if (symbol::null != nm) {
while (fresh_names.contains(nm)) {
std::ostringstream s;
s << nm << "!";
nm = symbol(s.str().c_str());
}
fresh_names.add(nm);
out << " :named " << nm << ")";
}
out << ")\n";
}

View file

@ -96,6 +96,8 @@ namespace datalog {
pred2syms m_argument_var_names;
decl_set m_output_preds;
rule_set m_rule_set;
expr_ref_vector m_rule_fmls;
svector<symbol> m_rule_names;
expr_ref_vector m_background;
scoped_ptr<pdr::dl_interface> m_pdr;
@ -259,6 +261,8 @@ namespace datalog {
void assert_expr(expr* e);
expr_ref get_background_assertion();
unsigned get_num_assertions() { return m_background.size(); }
expr* get_assertion(unsigned i) const { return m_background[i]; }
/**
Method exposed from API for adding rules.
@ -454,6 +458,8 @@ namespace datalog {
private:
void flush_add_rules();
void ensure_pdr();
void ensure_bmc();

View file

@ -194,6 +194,7 @@ namespace datalog {
}
}
// TBD: replace by r.has_quantifiers() and test
bool mk_rule_inliner::has_quantifier(rule const& r) const {
unsigned utsz = r.get_uninterpreted_tail_size();
for (unsigned i = utsz; i < r.get_tail_size(); ++i) {

View file

@ -818,6 +818,11 @@ namespace datalog {
}
rule_set * mk_slice::operator()(rule_set const & src, model_converter_ref& mc, proof_converter_ref& pc) {
for (unsigned i = 0; i < src.get_num_rules(); ++i) {
if (src.get_rule(i)->has_quantifiers()) {
return 0;
}
}
ref<slice_proof_converter> spc;
ref<slice_model_converter> smc;
if (pc) {

View file

@ -3,11 +3,11 @@ Copyright (c) 2012 Microsoft Corporation
Module Name:
pdr_tactic.h
horn_tactic.h
Abstract:
PDR as a tactic to solve Horn clauses.
HORN as a tactic to solve Horn clauses.
Author:
@ -19,10 +19,10 @@ Revision History:
#include"tactical.h"
#include"model_converter.h"
#include"proof_converter.h"
#include"pdr_tactic.h"
#include"horn_tactic.h"
#include"dl_context.h"
class pdr_tactic : public tactic {
class horn_tactic : public tactic {
struct imp {
ast_manager& m;
datalog::context m_ctx;
@ -90,6 +90,24 @@ class pdr_tactic : public tactic {
m_ctx.register_predicate(to_app(a)->get_decl(), true);
}
void check_predicate(expr* a) {
expr* a1 = 0;
while (true) {
if (is_quantifier(a)) {
a = to_quantifier(a)->get_expr();
continue;
}
if (m.is_not(a, a1)) {
a = a1;
continue;
}
if (is_predicate(a)) {
register_predicate(a);
}
break;
}
}
enum formula_kind { IS_RULE, IS_QUERY, IS_NONE };
formula_kind get_formula_kind(expr_ref& f) {
@ -99,13 +117,12 @@ class pdr_tactic : public tactic {
expr* a = 0, *a1 = 0;
datalog::flatten_or(f, args);
for (unsigned i = 0; i < args.size(); ++i) {
a = args[i].get();
a = args[i].get();
check_predicate(a);
if (m.is_not(a, a1) && is_predicate(a1)) {
register_predicate(a1);
body.push_back(a1);
}
else if (is_predicate(a)) {
register_predicate(a);
if (head) {
return IS_NONE;
}
@ -139,7 +156,7 @@ class pdr_tactic : public tactic {
expr_dependency_ref & core) {
SASSERT(g->is_well_sorted());
mc = 0; pc = 0; core = 0;
tactic_report report("pdr", *g);
tactic_report report("horn", *g);
bool produce_models = g->models_enabled();
bool produce_proofs = g->proofs_enabled();
@ -174,6 +191,7 @@ class pdr_tactic : public tactic {
if (queries.size() != 1) {
q = m.mk_fresh_const("query", m.mk_bool_sort());
register_predicate(q);
for (unsigned i = 0; i < queries.size(); ++i) {
f = mk_rule(queries[i].get(), q);
m_ctx.add_rule(f, symbol::null);
@ -209,7 +227,7 @@ class pdr_tactic : public tactic {
// subgoal is unchanged.
break;
}
TRACE("pdr", g->display(tout););
TRACE("horn", g->display(tout););
SASSERT(g->is_well_sorted());
}
};
@ -217,16 +235,16 @@ class pdr_tactic : public tactic {
params_ref m_params;
imp * m_imp;
public:
pdr_tactic(ast_manager & m, params_ref const & p):
horn_tactic(ast_manager & m, params_ref const & p):
m_params(p) {
m_imp = alloc(imp, m, p);
}
virtual tactic * translate(ast_manager & m) {
return alloc(pdr_tactic, m, m_params);
return alloc(horn_tactic, m, m_params);
}
virtual ~pdr_tactic() {
virtual ~horn_tactic() {
dealloc(m_imp);
}
@ -280,7 +298,7 @@ protected:
}
};
tactic * mk_pdr_tactic(ast_manager & m, params_ref const & p) {
return clean(alloc(pdr_tactic, m, p));
tactic * mk_horn_tactic(ast_manager & m, params_ref const & p) {
return clean(alloc(horn_tactic, m, p));
}

View file

@ -3,7 +3,7 @@ Copyright (c) 2012 Microsoft Corporation
Module Name:
pdr_tactic.h
horn_tactic.h
Abstract:
@ -16,15 +16,15 @@ Author:
Revision History:
--*/
#ifndef _PDR_TACTIC_H_
#define _PDR_TACTIC_H_
#ifndef _HORN_TACTIC_H_
#define _HORN_TACTIC_H_
#include"params.h"
class ast_manager;
class tactic;
tactic * mk_pdr_tactic(ast_manager & m, params_ref const & p = params_ref());
tactic * mk_horn_tactic(ast_manager & m, params_ref const & p = params_ref());
/*
ADD_TACTIC("pdr", "apply pdr for horn clauses.", "mk_pdr_tactic(m, p)")
ADD_TACTIC("horn", "apply tactic for horn clauses.", "mk_horn_tactic(m, p)")
*/
#endif

View file

@ -35,7 +35,9 @@ class mk_fresh_name {
public:
mk_fresh_name(): m_char('A'), m_num(0) {}
void add(ast* a);
void add(symbol const& s) { m_symbols.insert(s); }
symbol next();
bool contains(symbol const& s) const { return m_symbols.contains(s); }
};

View file

@ -26,6 +26,7 @@ Revision History:
#include "model_pp.h"
#include "front_end_params.h"
#include "datatype_decl_plugin.h"
#include "bv_decl_plugin.h"
#include "pdr_farkas_learner.h"
#include "ast_smt2_pp.h"
#include "expr_replacer.h"
@ -94,9 +95,12 @@ namespace pdr {
void expand_literals(expr_ref_vector& conjs) {
arith_util arith(m);
datatype_util dt(m);
bv_util bv(m);
expr* e1, *e2, *c, *val;
for (unsigned i = 0; i < conjs.size(); ++i) {
rational r;
unsigned bv_size;
for (unsigned i = 0; i < conjs.size(); ++i) {
expr* e = conjs[i].get();
if (m.is_eq(e, e1, e2) && arith.is_int_real(e1)) {
conjs[i] = arith.mk_le(e1,e2);
@ -109,7 +113,8 @@ namespace pdr {
}
++i;
}
else if (m.is_eq(e, c, val) && is_app(val) && dt.is_constructor(to_app(val))) {
else if ((m.is_eq(e, c, val) && is_app(val) && dt.is_constructor(to_app(val))) ||
(m.is_eq(e, val, c) && is_app(val) && dt.is_constructor(to_app(val)))){
func_decl* f = to_app(val)->get_decl();
func_decl* r = dt.get_constructor_recognizer(f);
conjs[i] = m.mk_app(r,c);
@ -118,6 +123,24 @@ namespace pdr {
conjs.push_back(m.mk_eq(m.mk_app(acc[i], c), to_app(val)->get_arg(i)));
}
}
else if ((m.is_eq(e, c, val) && bv.is_numeral(val, r, bv_size)) ||
(m.is_eq(e, val, c) && bv.is_numeral(val, r, bv_size))) {
rational two(2);
for (unsigned j = 0; j < bv_size; ++j) {
parameter p(j);
expr* e = m.mk_app(bv.get_family_id(), OP_BIT2BOOL, 1, &p, 1, &c);
if ((r % two).is_zero()) {
e = m.mk_not(e);
}
r = div(r, two);
if (j == 0) {
conjs[i] = e;
}
else {
conjs.push_back(e);
}
}
}
}
}
@ -341,7 +364,7 @@ namespace pdr {
}
fl.get_lemmas(pr, bs, lemmas);
safe.elim_proxies(lemmas);
fl.simplify_lemmas(lemmas); // redundant
fl.simplify_lemmas(lemmas); // redundant?
if (m_fparams.m_arith_mode == AS_DIFF_LOGIC &&
!is_difference_logic(m, lemmas.size(), lemmas.c_ptr())) {
IF_VERBOSE(1,

View file

@ -340,19 +340,32 @@ class der2 {
}
}
void apply_substitution(quantifier * q, expr_ref & r) {
void flatten_args(quantifier* q, unsigned& num_args, expr*const*& args) {
expr * e = q->get_expr();
unsigned num_args = to_app(e)->get_num_args();
num_args = 1;
args = &e;
if ((q->is_forall() && m.is_or(e)) ||
(q->is_exists() && m.is_and(e))) {
num_args = to_app(e)->get_num_args();
args = to_app(e)->get_args();
}
}
void apply_substitution(quantifier * q, expr_ref & r) {
expr * e = q->get_expr();
unsigned num_args = 1;
expr* const* args = &e;
flatten_args(q, num_args, args);
bool_rewriter rw(m);
// get a new expression
m_new_args.reset();
for(unsigned i = 0; i < num_args; i++) {
int x = m_pos2var[i];
if (x != -1 && m_map[x] != 0)
continue; // this is a disequality/equality with definition (vanishes)
m_new_args.push_back(to_app(e)->get_arg(i));
if (x == -1 || m_map[x] == 0) {
m_new_args.push_back(args[i]);
}
}
expr_ref t(m);
@ -390,11 +403,7 @@ class der2 {
set_is_variable_proc(is_v);
unsigned num_args = 1;
expr* const* args = &e;
if ((q->is_forall() && m.is_or(e)) ||
(q->is_exists() && m.is_and(e))) {
num_args = to_app(e)->get_num_args();
args = to_app(e)->get_args();
}
flatten_args(q, num_args, args);
unsigned def_count = 0;
unsigned largest_vinx = 0;

View file

@ -197,4 +197,4 @@ protected:
void convert(model * bv_mdl, model * float_mdl);
};
#endif
#endif

View file

@ -0,0 +1,166 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
fpa2bv_rewriter.h
Abstract:
Rewriter for converting FPA to BV
Author:
Christoph (cwinter) 2012-02-09
Notes:
--*/
#ifndef _FPA2BV_REWRITER_H_
#define _FPA2BV_REWRITER_H_
#include"cooperate.h"
#include"rewriter_def.h"
#include"bv_decl_plugin.h"
#include"fpa2bv_converter.h"
struct fpa2bv_rewriter_cfg : public default_rewriter_cfg {
ast_manager & m_manager;
expr_ref_vector m_out;
fpa2bv_converter & m_conv;
unsigned long long m_max_memory;
unsigned m_max_steps;
ast_manager & m() const { return m_manager; }
fpa2bv_rewriter_cfg(ast_manager & m, fpa2bv_converter & c, params_ref const & p):
m_manager(m),
m_out(m),
m_conv(c) {
updt_params(p);
// We need to make sure that the mananger has the BV plugin loaded.
symbol s_bv("bv");
if (!m_manager.has_plugin(s_bv))
m_manager.register_plugin(s_bv, alloc(bv_decl_plugin));
}
~fpa2bv_rewriter_cfg() {
}
void cleanup_buffers() {
m_out.finalize();
}
void updt_params(params_ref const & p) {
m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX));
m_max_steps = p.get_uint(":max-steps", UINT_MAX);
}
bool max_steps_exceeded(unsigned num_steps) const {
cooperate("fpa2bv");
if (memory::get_allocation_size() > m_max_memory)
throw tactic_exception(TACTIC_MAX_MEMORY_MSG);
return num_steps > m_max_steps;
}
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
TRACE("fpa2bv_rw", tout << "APP: " << f->get_name() << std::endl; );
if (num == 0 && f->get_family_id() == null_family_id && m_conv.is_float(f->get_range())) {
m_conv.mk_const(f, result);
return BR_DONE;
}
if (num == 0 && f->get_family_id() == null_family_id && m_conv.is_rm_sort(f->get_range())) {
m_conv.mk_rm_const(f, result);
return BR_DONE;
}
if (m().is_eq(f)) {
SASSERT(num == 2);
if (m_conv.is_float(args[0])) {
m_conv.mk_eq(args[0], args[1], result);
return BR_DONE;
}
return BR_FAILED;
}
if (m().is_ite(f)) {
SASSERT(num == 3);
if (m_conv.is_float(args[1])) {
m_conv.mk_ite(args[0], args[1], args[2], result);
return BR_DONE;
}
return BR_FAILED;
}
if (m_conv.is_float_family(f)) {
switch (f->get_decl_kind()) {
case OP_RM_NEAREST_TIES_TO_AWAY:
case OP_RM_NEAREST_TIES_TO_EVEN:
case OP_RM_TOWARD_NEGATIVE:
case OP_RM_TOWARD_POSITIVE:
case OP_RM_TOWARD_ZERO: m_conv.mk_rounding_mode(f, result); return BR_DONE;
case OP_FLOAT_VALUE: m_conv.mk_value(f, num, args, result); return BR_DONE;
case OP_FLOAT_PLUS_INF: m_conv.mk_plus_inf(f, result); return BR_DONE;
case OP_FLOAT_MINUS_INF: m_conv.mk_minus_inf(f, result); return BR_DONE;
case OP_FLOAT_NAN: m_conv.mk_nan(f, result); return BR_DONE;
case OP_FLOAT_ADD: m_conv.mk_add(f, num, args, result); return BR_DONE;
case OP_FLOAT_SUB: m_conv.mk_sub(f, num, args, result); return BR_DONE;
case OP_FLOAT_UMINUS: m_conv.mk_uminus(f, num, args, result); return BR_DONE;
case OP_FLOAT_MUL: m_conv.mk_mul(f, num, args, result); return BR_DONE;
case OP_FLOAT_DIV: m_conv.mk_div(f, num, args, result); return BR_DONE;
case OP_FLOAT_REM: m_conv.mk_remainder(f, num, args, result); return BR_DONE;
case OP_FLOAT_ABS: m_conv.mk_abs(f, num, args, result); return BR_DONE;
case OP_FLOAT_MIN: m_conv.mk_min(f, num, args, result); return BR_DONE;
case OP_FLOAT_MAX: m_conv.mk_max(f, num, args, result); return BR_DONE;
case OP_FLOAT_FUSED_MA: m_conv.mk_fusedma(f, num, args, result); return BR_DONE;
case OP_FLOAT_SQRT: m_conv.mk_sqrt(f, num, args, result); return BR_DONE;
case OP_FLOAT_ROUND_TO_INTEGRAL: m_conv.mk_round_to_integral(f, num, args, result); return BR_DONE;
case OP_FLOAT_EQ: m_conv.mk_float_eq(f, num, args, result); return BR_DONE;
case OP_FLOAT_LT: m_conv.mk_float_lt(f, num, args, result); return BR_DONE;
case OP_FLOAT_GT: m_conv.mk_float_gt(f, num, args, result); return BR_DONE;
case OP_FLOAT_LE: m_conv.mk_float_le(f, num, args, result); return BR_DONE;
case OP_FLOAT_GE: m_conv.mk_float_ge(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_ZERO: m_conv.mk_is_zero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_NZERO: m_conv.mk_is_nzero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_PZERO: m_conv.mk_is_pzero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_SIGN_MINUS: m_conv.mk_is_sign_minus(f, num, args, result); return BR_DONE;
case OP_TO_FLOAT: m_conv.mk_to_float(f, num, args, result); return BR_DONE;
default:
TRACE("fpa2bv", tout << "unsupported operator: " << f->get_name() << "\n";
for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m()) << std::endl;);
throw tactic_exception("NYI");
}
}
return BR_FAILED;
}
bool reduce_quantifier(quantifier * old_q,
expr * new_body,
expr * const * new_patterns,
expr * const * new_no_patterns,
expr_ref & result,
proof_ref & result_pr) {
return false;
}
bool reduce_var(var * t, expr_ref & result, proof_ref & result_pr) {
return false;
}
};
template class rewriter_tpl<fpa2bv_rewriter_cfg>;
struct fpa2bv_rewriter : public rewriter_tpl<fpa2bv_rewriter_cfg> {
fpa2bv_rewriter_cfg m_cfg;
fpa2bv_rewriter(ast_manager & m, fpa2bv_converter & c, params_ref const & p):
rewriter_tpl<fpa2bv_rewriter_cfg>(m, m.proofs_enabled(), m_cfg),
m_cfg(m, c, p) {
}
};
#endif

View file

@ -17,156 +17,10 @@ Notes:
--*/
#include"tactical.h"
#include"rewriter_def.h"
#include"cooperate.h"
#include"ref_util.h"
#include"bv_decl_plugin.h"
#include"float_decl_plugin.h"
#include"fpa2bv_converter.h"
#include"tactical.h"
#include"fpa2bv_rewriter.h"
#include"simplify_tactic.h"
#include"fpa2bv_tactic.h"
struct fpa2bv_rewriter_cfg : public default_rewriter_cfg {
ast_manager & m_manager;
expr_ref_vector m_out;
fpa2bv_converter & m_conv;
unsigned long long m_max_memory;
unsigned m_max_steps;
ast_manager & m() const { return m_manager; }
fpa2bv_rewriter_cfg(ast_manager & m, fpa2bv_converter & c, params_ref const & p):
m_manager(m),
m_out(m),
m_conv(c) {
updt_params(p);
// We need to make sure that the mananger has the BV plugin loaded.
symbol s_bv("bv");
if (!m_manager.has_plugin(s_bv))
m_manager.register_plugin(s_bv, alloc(bv_decl_plugin));
}
~fpa2bv_rewriter_cfg() {
}
void cleanup_buffers() {
m_out.finalize();
}
void updt_params(params_ref const & p) {
m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX));
m_max_steps = p.get_uint(":max-steps", UINT_MAX);
}
bool max_steps_exceeded(unsigned num_steps) const {
cooperate("fpa2bv");
if (memory::get_allocation_size() > m_max_memory)
throw tactic_exception(TACTIC_MAX_MEMORY_MSG);
return num_steps > m_max_steps;
}
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
TRACE("fpa2bv_rw", tout << "APP: " << f->get_name() << std::endl; );
if (num == 0 && f->get_family_id() == null_family_id && m_conv.is_float(f->get_range())) {
m_conv.mk_const(f, result);
return BR_DONE;
}
if (num == 0 && f->get_family_id() == null_family_id && m_conv.is_rm_sort(f->get_range())) {
m_conv.mk_rm_const(f, result);
return BR_DONE;
}
if (m().is_eq(f)) {
SASSERT(num == 2);
if (m_conv.is_float(args[0])) {
m_conv.mk_eq(args[0], args[1], result);
return BR_DONE;
}
return BR_FAILED;
}
if (m().is_ite(f)) {
SASSERT(num == 3);
if (m_conv.is_float(args[1])) {
m_conv.mk_ite(args[0], args[1], args[2], result);
return BR_DONE;
}
return BR_FAILED;
}
if (m_conv.is_float_family(f)) {
switch (f->get_decl_kind()) {
case OP_RM_NEAREST_TIES_TO_AWAY:
case OP_RM_NEAREST_TIES_TO_EVEN:
case OP_RM_TOWARD_NEGATIVE:
case OP_RM_TOWARD_POSITIVE:
case OP_RM_TOWARD_ZERO: m_conv.mk_rounding_mode(f, result); return BR_DONE;
case OP_FLOAT_VALUE: m_conv.mk_value(f, num, args, result); return BR_DONE;
case OP_FLOAT_PLUS_INF: m_conv.mk_plus_inf(f, result); return BR_DONE;
case OP_FLOAT_MINUS_INF: m_conv.mk_minus_inf(f, result); return BR_DONE;
case OP_FLOAT_NAN: m_conv.mk_nan(f, result); return BR_DONE;
case OP_FLOAT_ADD: m_conv.mk_add(f, num, args, result); return BR_DONE;
case OP_FLOAT_SUB: m_conv.mk_sub(f, num, args, result); return BR_DONE;
case OP_FLOAT_UMINUS: m_conv.mk_uminus(f, num, args, result); return BR_DONE;
case OP_FLOAT_MUL: m_conv.mk_mul(f, num, args, result); return BR_DONE;
case OP_FLOAT_DIV: m_conv.mk_div(f, num, args, result); return BR_DONE;
case OP_FLOAT_REM: m_conv.mk_remainder(f, num, args, result); return BR_DONE;
case OP_FLOAT_ABS: m_conv.mk_abs(f, num, args, result); return BR_DONE;
case OP_FLOAT_MIN: m_conv.mk_min(f, num, args, result); return BR_DONE;
case OP_FLOAT_MAX: m_conv.mk_max(f, num, args, result); return BR_DONE;
case OP_FLOAT_FUSED_MA: m_conv.mk_fusedma(f, num, args, result); return BR_DONE;
case OP_FLOAT_SQRT: m_conv.mk_sqrt(f, num, args, result); return BR_DONE;
case OP_FLOAT_ROUND_TO_INTEGRAL: m_conv.mk_round_to_integral(f, num, args, result); return BR_DONE;
case OP_FLOAT_EQ: m_conv.mk_float_eq(f, num, args, result); return BR_DONE;
case OP_FLOAT_LT: m_conv.mk_float_lt(f, num, args, result); return BR_DONE;
case OP_FLOAT_GT: m_conv.mk_float_gt(f, num, args, result); return BR_DONE;
case OP_FLOAT_LE: m_conv.mk_float_le(f, num, args, result); return BR_DONE;
case OP_FLOAT_GE: m_conv.mk_float_ge(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_ZERO: m_conv.mk_is_zero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_NZERO: m_conv.mk_is_nzero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_PZERO: m_conv.mk_is_pzero(f, num, args, result); return BR_DONE;
case OP_FLOAT_IS_SIGN_MINUS: m_conv.mk_is_sign_minus(f, num, args, result); return BR_DONE;
case OP_TO_FLOAT: m_conv.mk_to_float(f, num, args, result); return BR_DONE;
default:
TRACE("fpa2bv", tout << "unsupported operator: " << f->get_name() << "\n";
for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m()) << std::endl;);
throw tactic_exception("NYI");
}
}
return BR_FAILED;
}
bool reduce_quantifier(quantifier * old_q,
expr * new_body,
expr * const * new_patterns,
expr * const * new_no_patterns,
expr_ref & result,
proof_ref & result_pr) {
return false;
}
bool reduce_var(var * t, expr_ref & result, proof_ref & result_pr) {
return false;
}
};
template class rewriter_tpl<fpa2bv_rewriter_cfg>;
struct fpa2bv_rewriter : public rewriter_tpl<fpa2bv_rewriter_cfg> {
fpa2bv_rewriter_cfg m_cfg;
fpa2bv_rewriter(ast_manager & m, fpa2bv_converter & c, params_ref const & p):
rewriter_tpl<fpa2bv_rewriter_cfg>(m, m.proofs_enabled(), m_cfg),
m_cfg(m, c, p) {
}
};
class fpa2bv_tactic : public tactic {
struct imp {
ast_manager & m;

View file

@ -35,4 +35,4 @@ tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p) {
using_params(mk_simplify_tactic(m, p), sat_simp_p),
mk_sat_tactic(m, p),
mk_fail_if_undecided_tactic());
}
}

View file

@ -33,7 +33,7 @@ Notes:
#include"default_tactic.h"
#include"ufbv_tactic.h"
#include"qffpa_tactic.h"
#include"pdr_tactic.h"
#include"horn_tactic.h"
#include"smt_solver.h"
MK_SIMPLE_TACTIC_FACTORY(qfuf_fct, mk_qfuf_tactic(m, p));
@ -55,7 +55,7 @@ MK_SIMPLE_TACTIC_FACTORY(qfnia_fct, mk_qfnia_tactic(m, p));
MK_SIMPLE_TACTIC_FACTORY(qfnra_fct, mk_qfnra_tactic(m, p));
MK_SIMPLE_TACTIC_FACTORY(qffpa_fct, mk_qffpa_tactic(m, p));
MK_SIMPLE_TACTIC_FACTORY(ufbv_fct, mk_ufbv_tactic(m, p));
MK_SIMPLE_TACTIC_FACTORY(horn_fct, mk_pdr_tactic(m, p));
MK_SIMPLE_TACTIC_FACTORY(horn_fct, mk_horn_tactic(m, p));
static void init(strategic_solver * s) {
s->set_default_tactic(alloc(default_fct));

View file

@ -25,4 +25,8 @@ class tactic;
tactic * mk_macro_finder_tactic(ast_manager & m, params_ref const & p = params_ref());
/*
ADD_TACTIC("macro-finder", "Identifies and applies macros.", "mk_macro_finder_tactic(m, p)")
*/
#endif

View file

@ -25,4 +25,8 @@ class tactic;
tactic * mk_quasi_macros_tactic(ast_manager & m, params_ref const & p = params_ref());
/*
ADD_TACTIC("quasi-macros", "Identifies and applies quasi-macros.", "mk_quasi_macros_tactic(m, p)")
*/
#endif

View file

@ -33,15 +33,22 @@ Revision History:
#include<sys/time.h>
#include<sys/errno.h>
#include<pthread.h>
#else
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux
#include<csignal>
#include<ctime>
#include<memory.h>
#include"warning.h"
#define CLOCKID CLOCK_PROCESS_CPUTIME_ID
#ifdef _LINUX_
#define CLOCKID CLOCK_PROCESS_CPUTIME_ID
#else
// FreeBSD does not support CLOCK_PROCESS_CPUTIME_ID
#define CLOCKID CLOCK_PROF
#endif
#define SIG SIGRTMIN
// ---------
#else
// Other platforms
#endif
#include"scoped_timer.h"
@ -63,12 +70,14 @@ struct scoped_timer::imp {
pthread_attr_t m_attributes;
unsigned m_interval;
pthread_cond_t m_condition_var;
#else
// Linux
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
static void * g_timer;
void (*m_old_handler)(int);
void * m_old_timer;
timer_t m_timerid;
#else
// Other
#endif
#if defined(_WINDOWS) || defined(_CYGWIN)
@ -117,10 +126,12 @@ struct scoped_timer::imp {
throw default_exception("failed to destroy pthread condition variable");
return st;
}
#else
#elif defined(_LINUX_) || defined(_FREEBSD_)
static void sig_handler(int) {
static_cast<imp*>(g_timer)->m_eh->operator()();
}
#else
// Other
#endif
@ -142,8 +153,8 @@ struct scoped_timer::imp {
throw default_exception("failed to initialize timer thread attributes");
if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0)
throw default_exception("failed to start timer thread");
#else
// Linux version
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
if (omp_in_parallel()) {
// It doesn't work in with more than one thread.
// SIGEV_SIGNAL: the event is handled by the process not by the thread that installed the handler.
@ -172,6 +183,8 @@ struct scoped_timer::imp {
its.it_interval.tv_nsec = 0;
if (timer_settime(m_timerid, 0, &its, NULL) == -1)
throw default_exception("failed to set timer");
#else
// Other platforms
#endif
}
@ -187,14 +200,16 @@ struct scoped_timer::imp {
throw default_exception("failed to join thread");
if (pthread_attr_destroy(&m_attributes) != 0)
throw default_exception("failed to destroy pthread attributes object");
#else
// Linux version
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
if (omp_in_parallel())
return; // see comments in the constructor.
timer_delete(m_timerid);
if (m_old_handler != SIG_ERR)
signal(SIG, m_old_handler);
g_timer = m_old_timer;
#else
// Other Platforms
#endif
}
@ -203,9 +218,11 @@ struct scoped_timer::imp {
#if defined(_WINDOWS) || defined(_CYGWIN)
#elif defined(__APPLE__) && defined(__MACH__)
// Mac OS X
#else
// Linux
#elif defined(_LINUX_) || defined(_FREEBSD_)
// Linux & FreeBSD
void * scoped_timer::imp::g_timer = 0;
#else
// Other platforms
#endif
scoped_timer::scoped_timer(unsigned ms, event_handler * eh) {