mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
merge with master branch
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
651587ce01
1602 changed files with 40496 additions and 27837 deletions
26
.travis.yml
26
.travis.yml
|
@ -59,10 +59,24 @@ env:
|
|||
# 64-bit GCC 4.8 Debug
|
||||
- LINUX_BASE=ubuntu_14.04 C_COMPILER=/usr/bin/gcc-4.8 CXX_COMPILER=/usr/bin/g++-4.8 TARGET_ARCH=x86_64 Z3_BUILD_TYPE=Debug
|
||||
|
||||
# TODO: OSX support
|
||||
#matrix:
|
||||
# include:
|
||||
# - os: osx
|
||||
# osx_image: xcode 8.2
|
||||
# macOS (a.k.a OSX) support
|
||||
# FIXME: macOS support is temporarily disabled due to @wintersteiger 's concerns.
|
||||
# See https://github.com/Z3Prover/z3/pull/1207#issuecomment-322200998
|
||||
# matrix:
|
||||
# include:
|
||||
# # For now just test a single configuration. macOS builds on TravisCI are
|
||||
# # very slow so we should keep the number of configurations we test on this
|
||||
# # OS to a minimum.
|
||||
# - os: osx
|
||||
# osx_image: xcode8.3
|
||||
# # Note: Apple Clang does not support OpenMP
|
||||
# env: Z3_BUILD_TYPE=RelWithDebInfo USE_OPENMP=0
|
||||
script:
|
||||
- contrib/ci/scripts/travis_ci_entry_point.sh
|
||||
# Use `travis_wait` when doing LTO builds because this configuration will
|
||||
# have long link times during which it will not show any output which
|
||||
# TravisCI might kill due to perceived inactivity.
|
||||
- if [ "X${USE_LTO}" = "X1" ]; then
|
||||
travis_wait 45 contrib/ci/scripts/travis_ci_entry_point.sh || exit 1;
|
||||
else
|
||||
contrib/ci/scripts/travis_ci_entry_point.sh || exit 1;
|
||||
fi
|
||||
|
|
|
@ -235,22 +235,18 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
|||
if ("${TARGET_ARCHITECTURE}" STREQUAL "x86_64")
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_USE_THREAD_LOCAL")
|
||||
endif()
|
||||
z3_add_cxx_flag("-fno-strict-aliasing" REQUIRED)
|
||||
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
# Does OSX really not need any special flags?
|
||||
message(STATUS "Platform: Darwin")
|
||||
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
|
||||
message(STATUS "Platform: FreeBSD")
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_FREEBSD_")
|
||||
z3_add_cxx_flag("-fno-strict-aliasing" REQUIRED)
|
||||
elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
|
||||
message(STATUS "Platform: OpenBSD")
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_OPENBSD_")
|
||||
z3_add_cxx_flag("-fno-strict-aliasing" REQUIRED)
|
||||
elseif (CYGWIN)
|
||||
message(STATUS "Platform: Cygwin")
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_CYGWIN")
|
||||
z3_add_cxx_flag("-fno-strict-aliasing" REQUIRED)
|
||||
elseif (WIN32)
|
||||
message(STATUS "Platform: Windows")
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_WINDOWS")
|
||||
|
@ -258,8 +254,10 @@ else()
|
|||
message(FATAL_ERROR "Platform \"${CMAKE_SYSTEM_NAME}\" not recognised")
|
||||
endif()
|
||||
|
||||
list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src")
|
||||
|
||||
list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS
|
||||
"${CMAKE_BINARY_DIR}/src"
|
||||
"${CMAKE_SOURCE_DIR}/src"
|
||||
)
|
||||
################################################################################
|
||||
# GNU multiple precision library support
|
||||
################################################################################
|
||||
|
@ -280,33 +278,37 @@ endif()
|
|||
################################################################################
|
||||
# OpenMP support
|
||||
################################################################################
|
||||
option(USE_OPENMP "Use OpenMP" ON)
|
||||
set(OPENMP_FOUND FALSE)
|
||||
if (USE_OPENMP)
|
||||
# Because this is on by default we make the configure succeed with a warning
|
||||
# if OpenMP support is not detected.
|
||||
find_package(OpenMP)
|
||||
if (NOT OPENMP_FOUND)
|
||||
message(WARNING "OpenMP support was requested but your compiler doesn't support it")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
list(APPEND Z3_COMPONENT_CXX_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
# GCC and Clang need to have additional flags passed to the linker.
|
||||
# We can't do ``target_link_libraries(libz3 INTERFACE ${OpenMP_CXX_FLAGS})``
|
||||
# because ``/openmp`` is interpreted as file name rather than a linker
|
||||
# flag by MSVC and breaks the build
|
||||
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") OR
|
||||
("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
|
||||
list(APPEND Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
endif()
|
||||
unset(CMAKE_REQUIRED_FLAGS)
|
||||
message(STATUS "Using OpenMP")
|
||||
set(USE_OPENMP_DEFAULT ON)
|
||||
else()
|
||||
set(USE_OPENMP_DEFAULT OFF)
|
||||
endif()
|
||||
# By setting `USE_OPENMP` this way configuration will fail during the first
|
||||
# configure if the user explicitly passes `-DUSE_OPENMP=ON` and the compiler
|
||||
# does not support OpenMP. However if the option is not set explicitly during
|
||||
# the first configure OpenMP support will be automatically enabled/disabled
|
||||
# depending on whether OpenMP is available.
|
||||
option(USE_OPENMP "Use OpenMP" ${USE_OPENMP_DEFAULT})
|
||||
|
||||
if (USE_OPENMP)
|
||||
if (NOT OPENMP_FOUND)
|
||||
message(FATAL_ERROR "USE_OPENMP is ON but your compiler does not support OpenMP")
|
||||
endif()
|
||||
|
||||
list(APPEND Z3_COMPONENT_CXX_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
# GCC and Clang need to have additional flags passed to the linker.
|
||||
# We can't do ``target_link_libraries(libz3 INTERFACE ${OpenMP_CXX_FLAGS})``
|
||||
# because ``/openmp`` is interpreted as file name rather than a linker
|
||||
# flag by MSVC and breaks the build
|
||||
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") OR
|
||||
("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))
|
||||
list(APPEND Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
endif()
|
||||
message(STATUS "Using OpenMP")
|
||||
else()
|
||||
list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_NO_OMP_")
|
||||
message(STATUS "Not using OpenMP")
|
||||
set(USE_OPENMP OFF CACHE BOOL "Use OpenMP" FORCE)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -4,23 +4,55 @@
|
|||
# of the git directory changes CMake will be forced to re-run. This useful
|
||||
# for fetching the current git hash and including it in the build.
|
||||
#
|
||||
# `GIT_DIR` is the path to the git directory (i.e. the `.git` directory)
|
||||
# `GIT_DOT_FILE` is the path to the git directory (i.e. the `.git` directory) or
|
||||
# `.git` file used by a git worktree.
|
||||
# `SUCCESS_VAR` is the name of the variable to set. It will be set to TRUE
|
||||
# if the dependency was successfully added and FALSE otherwise.
|
||||
function(add_git_dir_dependency GIT_DIR SUCCESS_VAR)
|
||||
function(add_git_dir_dependency GIT_DOT_FILE SUCCESS_VAR)
|
||||
if (NOT "${ARGC}" EQUAL 2)
|
||||
message(FATAL_ERROR "Invalid number (${ARGC}) of arguments")
|
||||
endif()
|
||||
|
||||
if (NOT IS_ABSOLUTE "${GIT_DIR}")
|
||||
message(FATAL_ERROR "GIT_DIR (\"${GIT_DIR}\") is not an absolute path")
|
||||
if (NOT IS_ABSOLUTE "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR "GIT_DOT_FILE (\"${GIT_DOT_FILE}\") is not an absolute path")
|
||||
endif()
|
||||
|
||||
if (NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
message(FATAL_ERROR "GIT_DIR (\"${GIT_DIR}\") is not a directory")
|
||||
if (NOT EXISTS "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR "GIT_DOT_FILE (\"${GIT_DOT_FILE}\") does not exist")
|
||||
endif()
|
||||
|
||||
set(GIT_HEAD_FILE "${GIT_DIR}/HEAD")
|
||||
if (NOT IS_DIRECTORY "${GIT_DOT_FILE}")
|
||||
# Might be a git worktree. In this case we need parse out the worktree
|
||||
# git directory
|
||||
file(READ "${GIT_DOT_FILE}" GIT_DOT_FILE_DATA LIMIT 512)
|
||||
string(STRIP "${GIT_DOT_FILE_DATA}" GIT_DOT_FILE_DATA_STRIPPED)
|
||||
if ("${GIT_DOT_FILE_DATA_STRIPPED}" MATCHES "^gitdir:[ ]*(.+)$")
|
||||
# Git worktree
|
||||
message(STATUS "Found git worktree")
|
||||
set(GIT_WORKTREE_DIR "${CMAKE_MATCH_1}")
|
||||
set(GIT_HEAD_FILE "${GIT_WORKTREE_DIR}/HEAD")
|
||||
# Figure out where real git directory lives
|
||||
set(GIT_COMMON_DIR_FILE "${GIT_WORKTREE_DIR}/commondir")
|
||||
if (NOT EXISTS "${GIT_COMMON_DIR_FILE}")
|
||||
message(FATAL_ERROR "Found git worktree dir but could not find \"${GIT_COMMON_DIR_FILE}\"")
|
||||
endif()
|
||||
file(READ "${GIT_COMMON_DIR_FILE}" GIT_COMMON_DIR_FILE_DATA LIMIT 512)
|
||||
string(STRIP "${GIT_COMMON_DIR_FILE_DATA}" GIT_COMMON_DIR_FILE_DATA_STRIPPED)
|
||||
get_filename_component(GIT_DIR "${GIT_WORKTREE_DIR}/${GIT_COMMON_DIR_FILE_DATA_STRIPPED}" ABSOLUTE)
|
||||
if (NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
message(FATAL_ERROR "Failed to compute path to git directory from git worktree")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "GIT_DOT_FILE (\"${GIT_DOT_FILE}\") is not a directory or a pointer to git worktree directory")
|
||||
endif()
|
||||
else()
|
||||
# Just a normal `.git` directory
|
||||
message(STATUS "Found simple git working directory")
|
||||
set(GIT_HEAD_FILE "${GIT_DOT_FILE}/HEAD")
|
||||
set(GIT_DIR "${GIT_DOT_FILE}")
|
||||
endif()
|
||||
message(STATUS "Found git directory \"${GIT_DIR}\"")
|
||||
|
||||
if (NOT EXISTS "${GIT_HEAD_FILE}")
|
||||
message(AUTHOR_WARNING "Git head file \"${GIT_HEAD_FILE}\" cannot be found")
|
||||
set(${SUCCESS_VAR} FALSE PARENT_SCOPE)
|
||||
|
@ -79,24 +111,25 @@ function(add_git_dir_dependency GIT_DIR SUCCESS_VAR)
|
|||
set(${SUCCESS_VAR} TRUE PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# get_git_head_hash(GIT_DIR OUTPUT_VAR)
|
||||
# get_git_head_hash(GIT_DOT_FILE OUTPUT_VAR)
|
||||
#
|
||||
# Retrieve the current commit hash for a git working directory where `GIT_DIR`
|
||||
# is the `.git` directory in the root of the git working directory.
|
||||
# Retrieve the current commit hash for a git working directory where
|
||||
# `GIT_DOT_FILE` is the `.git` directory or `.git` pointer file in a git
|
||||
# worktree in the root of the git working directory.
|
||||
#
|
||||
# `OUTPUT_VAR` should be the name of the variable to put the result in. If this
|
||||
# function fails then either a fatal error will be raised or `OUTPUT_VAR` will
|
||||
# contain a string with the suffix `NOTFOUND` which can be used in CMake `if()`
|
||||
# commands.
|
||||
function(get_git_head_hash GIT_DIR OUTPUT_VAR)
|
||||
function(get_git_head_hash GIT_DOT_FILE OUTPUT_VAR)
|
||||
if (NOT "${ARGC}" EQUAL 2)
|
||||
message(FATAL_ERROR "Invalid number of arguments")
|
||||
endif()
|
||||
if (NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
message(FATAL_ERROR "\"${GIT_DIR}\" is not a directory")
|
||||
if (NOT EXISTS "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR "\"${GIT_DOT_FILE}\" does not exist")
|
||||
endif()
|
||||
if (NOT IS_ABSOLUTE "${GIT_DIR}")
|
||||
message(FATAL_ERROR \""${GIT_DIR}\" is not an absolute path")
|
||||
if (NOT IS_ABSOLUTE "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR \""${GIT_DOT_FILE}\" is not an absolute path")
|
||||
endif()
|
||||
find_package(Git)
|
||||
# NOTE: Use `GIT_FOUND` rather than `Git_FOUND` which was only
|
||||
|
@ -105,7 +138,7 @@ function(get_git_head_hash GIT_DIR OUTPUT_VAR)
|
|||
set(${OUTPUT_VAR} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
get_filename_component(GIT_WORKING_DIR "${GIT_DIR}" DIRECTORY)
|
||||
get_filename_component(GIT_WORKING_DIR "${GIT_DOT_FILE}" DIRECTORY)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
|
@ -128,24 +161,25 @@ function(get_git_head_hash GIT_DIR OUTPUT_VAR)
|
|||
set(${OUTPUT_VAR} "${Z3_GIT_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# get_git_head_describe(GIT_DIR OUTPUT_VAR)
|
||||
# get_git_head_describe(GIT_DOT_FILE OUTPUT_VAR)
|
||||
#
|
||||
# Retrieve the output of `git describe` for a git working directory where
|
||||
# `GIT_DIR` is the `.git` directory in the root of the git working directory.
|
||||
# `GIT_DOT_FILE` is the `.git` directory or `.git` pointer file in a git
|
||||
# worktree in the root of the git working directory.
|
||||
#
|
||||
# `OUTPUT_VAR` should be the name of the variable to put the result in. If this
|
||||
# function fails then either a fatal error will be raised or `OUTPUT_VAR` will
|
||||
# contain a string with the suffix `NOTFOUND` which can be used in CMake `if()`
|
||||
# commands.
|
||||
function(get_git_head_describe GIT_DIR OUTPUT_VAR)
|
||||
function(get_git_head_describe GIT_DOT_FILE OUTPUT_VAR)
|
||||
if (NOT "${ARGC}" EQUAL 2)
|
||||
message(FATAL_ERROR "Invalid number of arguments")
|
||||
endif()
|
||||
if (NOT IS_DIRECTORY "${GIT_DIR}")
|
||||
message(FATAL_ERROR "\"${GIT_DIR}\" is not a directory")
|
||||
if (NOT EXISTS "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR "\"${GIT_DOT_FILE}\" does not exist")
|
||||
endif()
|
||||
if (NOT IS_ABSOLUTE "${GIT_DIR}")
|
||||
message(FATAL_ERROR \""${GIT_DIR}\" is not an absolute path")
|
||||
if (NOT IS_ABSOLUTE "${GIT_DOT_FILE}")
|
||||
message(FATAL_ERROR \""${GIT_DOT_FILE}\" is not an absolute path")
|
||||
endif()
|
||||
find_package(Git)
|
||||
# NOTE: Use `GIT_FOUND` rather than `Git_FOUND` which was only
|
||||
|
@ -154,7 +188,7 @@ function(get_git_head_describe GIT_DIR OUTPUT_VAR)
|
|||
set(${OUTPUT_VAR} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
get_filename_component(GIT_WORKING_DIR "${GIT_DIR}" DIRECTORY)
|
||||
get_filename_component(GIT_WORKING_DIR "${GIT_DOT_FILE}" DIRECTORY)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
|
|
|
@ -36,15 +36,8 @@ function(z3_add_component_dependencies_to_target target_name)
|
|||
# Remaing args should be component names
|
||||
set(_expanded_deps ${ARGN})
|
||||
foreach (dependency ${_expanded_deps})
|
||||
# FIXME: Adding these include paths wouldn't be necessary if the sources
|
||||
# used include paths rooted in the ``src`` directory.
|
||||
get_property(_dep_include_dirs GLOBAL PROPERTY Z3_${dependency}_INCLUDES)
|
||||
foreach (inc_dir ${_dep_include_dirs})
|
||||
target_include_directories(${target_name} PRIVATE "${inc_dir}")
|
||||
endforeach()
|
||||
unset(_dep_include_dirs)
|
||||
# Ensure this component's dependencies are built before this component.
|
||||
# This important because we might need the generated header files in
|
||||
# This is important because we might need the generated header files in
|
||||
# other components.
|
||||
add_dependencies(${target_name} ${dependency})
|
||||
endforeach()
|
||||
|
@ -214,18 +207,14 @@ macro(z3_add_component component_name)
|
|||
target_compile_options(${component_name} PRIVATE ${flag})
|
||||
endforeach()
|
||||
|
||||
# It's unfortunate that we have to manage the include directories and dependencies ourselves.
|
||||
# It's unfortunate that we have to manage dependencies ourselves.
|
||||
#
|
||||
# If we weren't building "object" libraries we could use
|
||||
# ```
|
||||
# target_include_directories(${component_name} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
# target_link_libraries(${component_name} INTERFACE ${Z3_MOD_COMPONENT_DEPENDENCIES})
|
||||
# ```
|
||||
# but we can't do that with "object" libraries.
|
||||
|
||||
# Record this component's include directories
|
||||
set_property(GLOBAL PROPERTY Z3_${component_name}_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(GLOBAL APPEND PROPERTY Z3_${component_name}_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set_property(GLOBAL PROPERTY Z3_${component_name}_DEPS "")
|
||||
# Record this component's dependencies
|
||||
foreach (dependency ${Z3_MOD_COMPONENT_DEPENDENCIES})
|
||||
|
@ -243,12 +232,6 @@ macro(z3_add_component component_name)
|
|||
endif()
|
||||
#message(STATUS "Component \"${component_name}\" has the following dependencies ${_expanded_deps}")
|
||||
|
||||
# For any generated header files for this component
|
||||
target_include_directories(${component_name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
# So that any generated header files can refer to source files in the component's
|
||||
# source tree
|
||||
target_include_directories(${component_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Add any extra include directories
|
||||
foreach (extra_include ${Z3_COMPONENT_EXTRA_INCLUDE_DIRS})
|
||||
target_include_directories(${component_name} PRIVATE "${extra_include}")
|
||||
|
@ -283,7 +266,6 @@ macro(z3_add_install_tactic_rule)
|
|||
endforeach()
|
||||
unset(_component_tactic_header_files)
|
||||
|
||||
list(APPEND _search_paths "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_custom_command(OUTPUT "install_tactic.cpp"
|
||||
COMMAND "${PYTHON_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/mk_install_tactic_cpp.py"
|
||||
|
@ -311,13 +293,6 @@ macro(z3_add_memory_initializer_rule)
|
|||
)
|
||||
endif()
|
||||
z3_expand_dependencies(_expanded_components ${ARGN})
|
||||
# Get paths to search
|
||||
set(_search_paths "")
|
||||
foreach (dependency ${_expanded_components})
|
||||
get_property(_dep_include_dirs GLOBAL PROPERTY Z3_${dependency}_INCLUDES)
|
||||
list(APPEND _search_paths ${_dep_include_dirs})
|
||||
endforeach()
|
||||
list(APPEND _search_paths "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# Get header files that declare initializers and finalizers
|
||||
set(_mem_init_finalize_headers "")
|
||||
|
|
47
contrib/ci/scripts/install_deps_osx.sh
Executable file
47
contrib/ci/scripts/install_deps_osx.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
. ${SCRIPT_DIR}/run_quiet.sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
run_quiet brew update
|
||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
|
||||
function brew_install_or_upgrade() {
|
||||
if brew ls --versions "$1" > /dev/null 2>&1 ; then
|
||||
brew upgrade "$1"
|
||||
else
|
||||
brew install "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# FIXME: We should fix the versions of dependencies used
|
||||
# so that we have reproducible builds.
|
||||
|
||||
# HACK: Just use CMake version in TravisCI for now
|
||||
if [ "X${MACOS_UPDATE_CMAKE}" = "X1" ]; then
|
||||
brew_install_or_upgrade cmake
|
||||
fi
|
||||
|
||||
if [ "X${Z3_CMAKE_GENERATOR}" = "XNinja" ]; then
|
||||
brew_install_or_upgrade ninja
|
||||
fi
|
||||
|
||||
if [ "X${USE_LIBGMP}" = "X1" ]; then
|
||||
brew_install_or_upgrade gmp
|
||||
fi
|
||||
|
||||
if [ "X${BUILD_DOCS}" = "X1" ]; then
|
||||
brew_install_or_upgrade doxygen
|
||||
fi
|
||||
|
||||
if [ "X${DOTNET_BINDINGS}" = "X1" ]; then
|
||||
brew_install_or_upgrade mono
|
||||
fi
|
||||
|
||||
if [ "X${JAVA_BINDINGS}" = "X1" ]; then
|
||||
brew cask install java
|
||||
fi
|
|
@ -6,5 +6,67 @@ set -x
|
|||
set -e
|
||||
set -o pipefail
|
||||
|
||||
echo "Not implemented"
|
||||
exit 1
|
||||
# Set defaults
|
||||
# FIXME: Refactor this so we don't need to stay in sync with
|
||||
# `z3_build.Dockerfile`.
|
||||
export ASAN_BUILD="${ASAN_BUILD:-0}"
|
||||
export BUILD_DOCS="${BUILD_DOCS:-0}"
|
||||
export C_COMPILER="${C_COMPILER:-clang}"
|
||||
export CXX_COMPILER="${CXX_COMPILER:-clang++}"
|
||||
export DOTNET_BINDINGS="${DOTNET_BINDINGS:-1}"
|
||||
export JAVA_BINDINGS="${JAVA_BINDINGS:-1}"
|
||||
export NO_SUPPRESS_OUTPUT="${NO_SUPPRESS_OUTPUT:-0}"
|
||||
export PYTHON_BINDINGS="${PYTHON_BINDINGS:-1}"
|
||||
export PYTHON_EXECUTABLE="$(which python)"
|
||||
export RUN_SYSTEM_TESTS="${RUN_SYSTEM_TESTS:-1}"
|
||||
export RUN_UNIT_TESTS="${RUN_UNIT_TESTS:-1}"
|
||||
export TARGET_ARCH="${TARGET_ARCH:-x86_64}"
|
||||
export TEST_INSTALL="${TEST_INSTALL:-1}"
|
||||
export UBSAN_BUILD="${UBSAN_BUILD:-0}"
|
||||
export USE_LIBGMP="${USE_LIBGMP:-0}"
|
||||
export USE_LTO="${USE_LTO:-0}"
|
||||
export USE_OPENMP="${USE_OPENMP:-1}"
|
||||
|
||||
if [ -z "${TRAVIS_BUILD_DIR}" ]; then
|
||||
echo "TRAVIS_BUILD_DIR must be set to root of Z3 repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${TRAVIS_BUILD_DIR}" ]; then
|
||||
echo "TRAVIS_BUILD_DIR must be a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export Z3_SRC_DIR="${TRAVIS_BUILD_DIR}"
|
||||
export Z3_BUILD_DIR="${Z3_SRC_DIR}/build"
|
||||
export Z3_BUILD_TYPE="${Z3_BUILD_TYPE:-RelWithDebInfo}"
|
||||
export Z3_CMAKE_GENERATOR="${Z3_CMAKE_GENERATOR:-Ninja}"
|
||||
export Z3_INSTALL_PREFIX="${Z3_INSTALL_PREFIX:-/usr/local}"
|
||||
export Z3_STATIC_BUILD="${Z3_STATIC_BUILD:-0}"
|
||||
export Z3_SYSTEM_TEST_DIR="${Z3_SRC_DIR}/z3_system_test"
|
||||
export Z3_WARNINGS_AS_ERRORS="${Z3_WARNINGS_AS_ERRORS:-SERIOUS_ONLY}"
|
||||
export Z3_VERBOSE_BUILD_OUTPUT="${Z3_VERBOSE_BUILD_OUTPUT:-0}"
|
||||
|
||||
# Overwrite whatever what set in TravisCI
|
||||
export CC="${C_COMPILER}"
|
||||
export CXX="${CXX_COMPILER}"
|
||||
|
||||
if [ "X${MACOS_SKIP_DEPS_UPDATE}" = "X1" ]; then
|
||||
# This is just for local testing to avoid updating
|
||||
echo "Skipping dependency update"
|
||||
else
|
||||
"${SCRIPT_DIR}/install_deps_osx.sh"
|
||||
fi
|
||||
|
||||
# Build Z3
|
||||
"${SCRIPT_DIR}/build_z3_cmake.sh"
|
||||
# Test building docs
|
||||
"${SCRIPT_DIR}/test_z3_docs.sh"
|
||||
# Test examples
|
||||
"${SCRIPT_DIR}/test_z3_examples_cmake.sh"
|
||||
# Run unit tests
|
||||
"${SCRIPT_DIR}/test_z3_unit_tests_cmake.sh"
|
||||
# Run system tests
|
||||
"${SCRIPT_DIR}/test_z3_system_tests.sh"
|
||||
# Test install
|
||||
"${SCRIPT_DIR}/test_z3_install_cmake.sh"
|
||||
|
|
|
@ -587,6 +587,14 @@ def mk_def_file_internal(defname, dll_name, export_header_files):
|
|||
###############################################################################
|
||||
# Functions for generating ``gparams_register_modules.cpp``
|
||||
###############################################################################
|
||||
|
||||
def path_after_src(h_file):
|
||||
h_file = h_file.replace("\\","/")
|
||||
idx = h_file.rfind("src/")
|
||||
if idx == -1:
|
||||
return h_file
|
||||
return h_file[idx + 4:]
|
||||
|
||||
def mk_gparams_register_modules_internal(h_files_full_path, path):
|
||||
"""
|
||||
Generate a ``gparams_register_modules.cpp`` file in the directory ``path``.
|
||||
|
@ -608,7 +616,7 @@ def mk_gparams_register_modules_internal(h_files_full_path, path):
|
|||
fullname = os.path.join(path, 'gparams_register_modules.cpp')
|
||||
fout = open(fullname, 'w')
|
||||
fout.write('// Automatically generated file.\n')
|
||||
fout.write('#include"gparams.h"\n')
|
||||
fout.write('#include "util/gparams.h"\n')
|
||||
reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)')
|
||||
reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)')
|
||||
reg_mod_descr_pat = re.compile('[ \t]*REG_MODULE_DESCRIPTION\(\'([^\']*)\', *\'([^\']*)\'\)')
|
||||
|
@ -620,13 +628,13 @@ def mk_gparams_register_modules_internal(h_files_full_path, path):
|
|||
if m:
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
cmds.append((m.group(1)))
|
||||
m = reg_mod_pat.match(line)
|
||||
if m:
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
mod_cmds.append((m.group(1), m.group(2)))
|
||||
m = reg_mod_descr_pat.match(line)
|
||||
if m:
|
||||
|
@ -680,9 +688,9 @@ def mk_install_tactic_cpp_internal(h_files_full_path, path):
|
|||
fullname = os.path.join(path, 'install_tactic.cpp')
|
||||
fout = open(fullname, 'w')
|
||||
fout.write('// Automatically generated file.\n')
|
||||
fout.write('#include"tactic.h"\n')
|
||||
fout.write('#include"tactic_cmds.h"\n')
|
||||
fout.write('#include"cmd_context.h"\n')
|
||||
fout.write('#include "tactic/tactic.h"\n')
|
||||
fout.write('#include "cmd_context/tactic_cmds.h"\n')
|
||||
fout.write('#include "cmd_context/cmd_context.h"\n')
|
||||
tactic_pat = re.compile('[ \t]*ADD_TACTIC\(.*\)')
|
||||
probe_pat = re.compile('[ \t]*ADD_PROBE\(.*\)')
|
||||
for h_file in sorted_headers_by_component(h_files_full_path):
|
||||
|
@ -691,8 +699,8 @@ def mk_install_tactic_cpp_internal(h_files_full_path, path):
|
|||
for line in fin:
|
||||
if tactic_pat.match(line):
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
added_include = True
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
try:
|
||||
eval(line.strip('\n '), eval_globals, None)
|
||||
except Exception as e:
|
||||
|
@ -702,7 +710,7 @@ def mk_install_tactic_cpp_internal(h_files_full_path, path):
|
|||
if probe_pat.match(line):
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
try:
|
||||
eval(line.strip('\n '), eval_globals, None)
|
||||
except Exception as e:
|
||||
|
@ -764,19 +772,19 @@ def mk_mem_initializer_cpp_internal(h_files_full_path, path):
|
|||
if m:
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
initializer_cmds.append((m.group(1), 0))
|
||||
m = initializer_prio_pat.match(line)
|
||||
if m:
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
initializer_cmds.append((m.group(1), int(m.group(2))))
|
||||
m = finalizer_pat.match(line)
|
||||
if m:
|
||||
if not added_include:
|
||||
added_include = True
|
||||
fout.write('#include"%s"\n' % os.path.basename(h_file))
|
||||
fout.write('#include "%s"\n' % path_after_src(h_file))
|
||||
finalizer_cmds.append(m.group(1))
|
||||
initializer_cmds.sort(key=lambda tup: tup[1])
|
||||
fout.write('void mem_initialize() {\n')
|
||||
|
@ -881,9 +889,9 @@ def mk_hpp_from_pyg(pyg_file, output_dir):
|
|||
out.write('// Automatically generated file\n')
|
||||
out.write('#ifndef __%s_HPP_\n' % class_name.upper())
|
||||
out.write('#define __%s_HPP_\n' % class_name.upper())
|
||||
out.write('#include"params.h"\n')
|
||||
out.write('#include "util/params.h"\n')
|
||||
if export:
|
||||
out.write('#include"gparams.h"\n')
|
||||
out.write('#include "util/gparams.h"\n')
|
||||
out.write('struct %s {\n' % class_name)
|
||||
out.write(' params_ref const & p;\n')
|
||||
if export:
|
||||
|
|
|
@ -23,6 +23,7 @@ def init_project_def():
|
|||
add_lib('subpaving', ['interval'], 'math/subpaving')
|
||||
add_lib('ast', ['util', 'polynomial'])
|
||||
add_lib('rewriter', ['ast', 'polynomial', 'automata'], 'ast/rewriter')
|
||||
add_lib('macros', ['rewriter'], 'ast/macros')
|
||||
add_lib('normal_forms', ['rewriter'], 'ast/normal_forms')
|
||||
add_lib('model', ['rewriter'])
|
||||
add_lib('tactic', ['ast', 'model'])
|
||||
|
@ -30,7 +31,7 @@ def init_project_def():
|
|||
add_lib('parser_util', ['ast'], 'parsers/util')
|
||||
add_lib('grobner', ['ast'], 'math/grobner')
|
||||
add_lib('euclid', ['util'], 'math/euclid')
|
||||
add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core')
|
||||
add_lib('core_tactics', ['tactic', 'macros', 'normal_forms', 'rewriter'], 'tactic/core')
|
||||
add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic')
|
||||
add_lib('arith_tactics', ['core_tactics', 'sat'], 'tactic/arith')
|
||||
add_lib('nlsat_tactic', ['nlsat', 'sat_tactic', 'arith_tactics'], 'nlsat/tactic')
|
||||
|
@ -43,15 +44,11 @@ def init_project_def():
|
|||
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('proof_checker', ['rewriter'], 'ast/proof_checker')
|
||||
# Simplifier module will be deleted in the future.
|
||||
# It has been replaced with rewriter module.
|
||||
add_lib('simplifier', ['rewriter'], 'ast/simplifier')
|
||||
add_lib('fpa', ['ast', 'util', 'simplifier', 'model'], 'ast/fpa')
|
||||
add_lib('macros', ['simplifier'], 'ast/macros')
|
||||
add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern')
|
||||
add_lib('bit_blaster', ['rewriter', 'simplifier'], 'ast/rewriter/bit_blaster')
|
||||
add_lib('smt_params', ['ast', 'simplifier', 'pattern', 'bit_blaster'], 'smt/params')
|
||||
add_lib('proto_model', ['model', 'simplifier', 'smt_params'], 'smt/proto_model')
|
||||
add_lib('fpa', ['ast', 'util', 'rewriter', 'model'], 'ast/fpa')
|
||||
add_lib('pattern', ['normal_forms', 'smt2parser', 'rewriter'], 'ast/pattern')
|
||||
add_lib('bit_blaster', ['rewriter', 'rewriter'], 'ast/rewriter/bit_blaster')
|
||||
add_lib('smt_params', ['ast', 'rewriter', 'pattern', 'bit_blaster'], 'smt/params')
|
||||
add_lib('proto_model', ['model', 'rewriter', 'smt_params'], 'smt/proto_model')
|
||||
add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model',
|
||||
'substitution', 'grobner', 'euclid', 'simplex', 'proof_checker', 'pattern', 'parser_util', 'fpa', 'lp'])
|
||||
add_lib('bv_tactics', ['tactic', 'bit_blaster', 'core_tactics'], 'tactic/bv')
|
||||
|
@ -65,12 +62,13 @@ def init_project_def():
|
|||
add_lib('transforms', ['muz', 'hilbert', 'dataflow'], 'muz/transforms')
|
||||
add_lib('rel', ['muz', 'transforms'], 'muz/rel')
|
||||
add_lib('pdr', ['muz', 'transforms', 'arith_tactics', 'core_tactics', 'smt_tactic'], 'muz/pdr')
|
||||
add_lib('spacer', ['muz', 'transforms', 'arith_tactics', 'smt_tactic'], 'muz/spacer')
|
||||
add_lib('clp', ['muz', 'transforms'], 'muz/clp')
|
||||
add_lib('tab', ['muz', 'transforms'], 'muz/tab')
|
||||
add_lib('bmc', ['muz', 'transforms'], 'muz/bmc')
|
||||
add_lib('ddnf', ['muz', 'transforms', 'rel'], 'muz/ddnf')
|
||||
add_lib('duality_intf', ['muz', 'transforms', 'duality'], 'muz/duality')
|
||||
add_lib('fp', ['muz', 'pdr', 'clp', 'tab', 'rel', 'bmc', 'duality_intf', 'ddnf'], 'muz/fp')
|
||||
add_lib('fp', ['muz', 'pdr', 'clp', 'tab', 'rel', 'bmc', 'duality_intf', 'ddnf', 'spacer'], 'muz/fp')
|
||||
add_lib('nlsat_smt_tactic', ['nlsat_tactic', 'smt_tactic'], 'tactic/nlsat_smt')
|
||||
add_lib('ufbv_tactic', ['normal_forms', 'core_tactics', 'macros', 'smt_tactic', 'rewriter'], 'tactic/ufbv')
|
||||
add_lib('sat_solver', ['solver', 'core_tactics', 'aig_tactic', 'bv_tactics', 'arith_tactics', 'sat_tactic'], 'sat/sat_solver')
|
||||
|
@ -79,7 +77,7 @@ def init_project_def():
|
|||
add_lib('portfolio', ['smtlogic_tactics', 'sat_solver', 'ufbv_tactic', 'fpa_tactics', 'aig_tactic', 'fp', 'qe','sls_tactic', 'subpaving_tactic'], 'tactic/portfolio')
|
||||
add_lib('smtparser', ['portfolio'], 'parsers/smt')
|
||||
add_lib('opt', ['smt', 'smtlogic_tactics', 'sls_tactic', 'sat_solver'], 'opt')
|
||||
API_files = ['z3_api.h', 'z3_ast_containers.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_fixedpoint.h', 'z3_optimization.h', 'z3_interp.h', 'z3_fpa.h']
|
||||
API_files = ['z3_api.h', 'z3_ast_containers.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_fixedpoint.h', 'z3_optimization.h', 'z3_interp.h', 'z3_fpa.h', 'z3_spacer.h']
|
||||
add_lib('api', ['portfolio', 'smtparser', 'realclosure', 'interp', 'opt'],
|
||||
includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files)
|
||||
add_exe('shell', ['api', 'sat', 'extra_cmds','opt'], exe_name='z3')
|
||||
|
|
|
@ -2443,26 +2443,26 @@ def mk_config():
|
|||
SO_EXT = '.dylib'
|
||||
SLIBFLAGS = '-dynamiclib'
|
||||
elif sysname == 'Linux':
|
||||
CXXFLAGS = '%s -fno-strict-aliasing -D_LINUX_' % CXXFLAGS
|
||||
CXXFLAGS = '%s -D_LINUX_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_LINUX_'
|
||||
SO_EXT = '.so'
|
||||
LDFLAGS = '%s -lrt' % LDFLAGS
|
||||
SLIBFLAGS = '-shared'
|
||||
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
|
||||
elif sysname == 'FreeBSD':
|
||||
CXXFLAGS = '%s -fno-strict-aliasing -D_FREEBSD_' % CXXFLAGS
|
||||
CXXFLAGS = '%s -D_FREEBSD_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_FREEBSD_'
|
||||
SO_EXT = '.so'
|
||||
LDFLAGS = '%s -lrt' % LDFLAGS
|
||||
SLIBFLAGS = '-shared'
|
||||
SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS
|
||||
elif sysname == 'OpenBSD':
|
||||
CXXFLAGS = '%s -fno-strict-aliasing -D_OPENBSD_' % CXXFLAGS
|
||||
CXXFLAGS = '%s -D_OPENBSD_' % CXXFLAGS
|
||||
OS_DEFINES = '-D_OPENBSD_'
|
||||
SO_EXT = '.so'
|
||||
SLIBFLAGS = '-shared'
|
||||
elif sysname[:6] == 'CYGWIN':
|
||||
CXXFLAGS = '%s -D_CYGWIN -fno-strict-aliasing' % CXXFLAGS
|
||||
CXXFLAGS = '%s -D_CYGWIN' % CXXFLAGS
|
||||
OS_DEFINES = '-D_CYGWIN'
|
||||
SO_EXT = '.dll'
|
||||
SLIBFLAGS = '-shared'
|
||||
|
@ -3046,6 +3046,7 @@ def mk_vs_proj_cl_compile(f, name, components, debug):
|
|||
else:
|
||||
f.write(';')
|
||||
f.write(get_component(dep).to_src_dir)
|
||||
f.write(';%s\n' % os.path.join(REV_BUILD_DIR, SRC_DIR))
|
||||
f.write('</AdditionalIncludeDirectories>\n')
|
||||
f.write(' </ClCompile>\n')
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ def mk_py_wrappers():
|
|||
display_args(num)
|
||||
core_py.write("):\n")
|
||||
core_py.write(" _lib = lib()\n")
|
||||
core_py.write(" if _lib.%s is None:\n" % name)
|
||||
core_py.write(" if _lib is None or _lib.%s is None:\n" % name)
|
||||
core_py.write(" return\n")
|
||||
if result != VOID:
|
||||
core_py.write(" r = _lib.%s(" % name)
|
||||
|
@ -768,12 +768,12 @@ def mk_log_macro(file, name, params):
|
|||
cap = param_array_capacity_pos(p)
|
||||
if cap not in auxs:
|
||||
auxs.add(cap)
|
||||
file.write("unsigned _Z3_UNUSED Z3ARG%s; " % cap)
|
||||
file.write("unsigned _Z3_UNUSED Z3ARG%s = 0; " % cap)
|
||||
sz = param_array_size_pos(p)
|
||||
if sz not in auxs:
|
||||
auxs.add(sz)
|
||||
file.write("unsigned * _Z3_UNUSED Z3ARG%s; " % sz)
|
||||
file.write("%s _Z3_UNUSED Z3ARG%s; " % (param2str(p), i))
|
||||
file.write("unsigned * _Z3_UNUSED Z3ARG%s = 0; " % sz)
|
||||
file.write("%s _Z3_UNUSED Z3ARG%s = 0; " % (param2str(p), i))
|
||||
i = i + 1
|
||||
file.write("if (_LOG_CTX.enabled()) { log_%s(" % name)
|
||||
i = 0
|
||||
|
@ -1573,7 +1573,7 @@ def def_APIs(api_files):
|
|||
|
||||
def write_log_h_preamble(log_h):
|
||||
log_h.write('// Automatically generated file\n')
|
||||
log_h.write('#include\"z3.h\"\n')
|
||||
log_h.write('#include\"api/z3.h\"\n')
|
||||
log_h.write('#ifdef __GNUC__\n')
|
||||
log_h.write('#define _Z3_UNUSED __attribute__((unused))\n')
|
||||
log_h.write('#else\n')
|
||||
|
@ -1592,14 +1592,14 @@ def write_log_h_preamble(log_h):
|
|||
def write_log_c_preamble(log_c):
|
||||
log_c.write('// Automatically generated file\n')
|
||||
log_c.write('#include<iostream>\n')
|
||||
log_c.write('#include\"z3.h\"\n')
|
||||
log_c.write('#include\"api_log_macros.h\"\n')
|
||||
log_c.write('#include\"z3_logger.h\"\n')
|
||||
log_c.write('#include\"api/z3.h\"\n')
|
||||
log_c.write('#include\"api/api_log_macros.h\"\n')
|
||||
log_c.write('#include\"api/z3_logger.h\"\n')
|
||||
|
||||
def write_exe_c_preamble(exe_c):
|
||||
exe_c.write('// Automatically generated file\n')
|
||||
exe_c.write('#include\"z3.h\"\n')
|
||||
exe_c.write('#include\"z3_replayer.h\"\n')
|
||||
exe_c.write('#include\"api/z3.h\"\n')
|
||||
exe_c.write('#include\"api/z3_replayer.h\"\n')
|
||||
#
|
||||
exe_c.write('void Z3_replayer_error_handler(Z3_context ctx, Z3_error_code c) { printf("[REPLAYER ERROR HANDLER]: %s\\n", Z3_get_error_msg(ctx, c)); }\n')
|
||||
|
||||
|
|
69
scripts/update_include.py
Normal file
69
scripts/update_include.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Copyright (c) 2017 Microsoft Corporation
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
is_include = re.compile("#include \"(.*)\"")
|
||||
is_include2 = re.compile("#include\"(.*)\"")
|
||||
|
||||
|
||||
def fix_include(file, paths):
|
||||
tmp = "%s.tmp" % file
|
||||
ins = open(file)
|
||||
ous = open(tmp,'w')
|
||||
line = ins.readline()
|
||||
found = False
|
||||
while line:
|
||||
m = is_include.search(line)
|
||||
if m and m.group(1) in paths:
|
||||
ous.write("#include \"")
|
||||
ous.write(paths[m.group(1)])
|
||||
ous.write("\"\n")
|
||||
found = True
|
||||
line = ins.readline()
|
||||
continue
|
||||
m = is_include2.search(line)
|
||||
if m and m.group(1) in paths:
|
||||
ous.write("#include \"")
|
||||
ous.write(paths[m.group(1)])
|
||||
ous.write("\"\n")
|
||||
found = True
|
||||
line = ins.readline()
|
||||
continue
|
||||
ous.write(line)
|
||||
line = ins.readline()
|
||||
ins.close()
|
||||
ous.close()
|
||||
if found:
|
||||
print(file)
|
||||
os.system("move %s %s" % (tmp, file))
|
||||
else:
|
||||
os.system("del %s" % tmp)
|
||||
|
||||
def find_paths(dir):
|
||||
paths = {}
|
||||
for root, dirs, files in os.walk(dir):
|
||||
root1 = root.replace("\\","/")[4:]
|
||||
for f in files:
|
||||
if f.endswith('.h') or f.endswith('.hpp') or f.endswith('.cpp'):
|
||||
path = "%s/%s" % (root1, f)
|
||||
paths[f] = path
|
||||
if f.endswith('.pyg'):
|
||||
f = f.replace("pyg","hpp")
|
||||
path = "%s/%s" % (root1, f)
|
||||
paths[f] = path
|
||||
return paths
|
||||
|
||||
paths = find_paths('src')
|
||||
|
||||
def fixup(dir):
|
||||
for root, dirs, files in os.walk(dir):
|
||||
for f in files:
|
||||
if f == "z3.h":
|
||||
continue
|
||||
if f.endswith('.h') or f.endswith('.cpp'):
|
||||
path = "%s\\%s" % (root, f)
|
||||
fix_include(path, paths)
|
||||
|
||||
|
||||
fixup('src')
|
|
@ -14,6 +14,7 @@ set(Z3_API_HEADER_FILES_TO_SCAN
|
|||
z3_optimization.h
|
||||
z3_interp.h
|
||||
z3_fpa.h
|
||||
z3_spacer.h
|
||||
)
|
||||
set(Z3_FULL_PATH_API_HEADER_FILES_TO_SCAN "")
|
||||
foreach (header_file ${Z3_API_HEADER_FILES_TO_SCAN})
|
||||
|
@ -67,9 +68,6 @@ add_subdirectory(cmd_context)
|
|||
add_subdirectory(cmd_context/extra_cmds)
|
||||
add_subdirectory(parsers/smt2)
|
||||
add_subdirectory(ast/proof_checker)
|
||||
## Simplifier module will be deleted in the future.
|
||||
## It has been replaced with rewriter component.
|
||||
add_subdirectory(ast/simplifier)
|
||||
add_subdirectory(ast/fpa)
|
||||
add_subdirectory(ast/macros)
|
||||
add_subdirectory(ast/pattern)
|
||||
|
@ -92,6 +90,7 @@ add_subdirectory(muz/tab)
|
|||
add_subdirectory(muz/bmc)
|
||||
add_subdirectory(muz/ddnf)
|
||||
add_subdirectory(muz/duality)
|
||||
add_subdirectory(muz/spacer)
|
||||
add_subdirectory(muz/fp)
|
||||
add_subdirectory(tactic/nlsat_smt)
|
||||
add_subdirectory(tactic/ufbv)
|
||||
|
@ -168,6 +167,7 @@ set (libz3_public_headers
|
|||
z3_polynomial.h
|
||||
z3_rcf.h
|
||||
z3_v1.h
|
||||
z3_spacer.h
|
||||
)
|
||||
foreach (header ${libz3_public_headers})
|
||||
set_property(TARGET libz3 APPEND PROPERTY
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"ackr_model_converter.h"
|
||||
#include"ackermannize_bv_model_converter.h"
|
||||
#include "ackermannization/ackr_model_converter.h"
|
||||
#include "ackermannization/ackermannize_bv_model_converter.h"
|
||||
|
||||
model_converter * mk_ackermannize_bv_model_converter(ast_manager & m, const ackr_info_ref& info) {
|
||||
return mk_ackr_model_converter(m, info);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#ifndef ACKERMANNIZE_BV_MODEL_CONVERTER_H_
|
||||
#define ACKERMANNIZE_BV_MODEL_CONVERTER_H_
|
||||
|
||||
#include"model_converter.h"
|
||||
#include"ackr_info.h"
|
||||
#include "tactic/model_converter.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
|
||||
model_converter * mk_ackermannize_bv_model_converter(ast_manager & m, const ackr_info_ref& info);
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ Mikolas Janota
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"ackermannize_bv_tactic.h"
|
||||
#include"tactical.h"
|
||||
#include"lackr.h"
|
||||
#include"model_smt2_pp.h"
|
||||
#include"ackermannize_bv_tactic_params.hpp"
|
||||
#include"ackermannize_bv_model_converter.h"
|
||||
#include "ackermannization/ackermannize_bv_tactic.h"
|
||||
#include "tactic/tactical.h"
|
||||
#include "ackermannization/lackr.h"
|
||||
#include "model/model_smt2_pp.h"
|
||||
#include "ackermannization/ackermannize_bv_tactic_params.hpp"
|
||||
#include "ackermannization/ackermannize_bv_model_converter.h"
|
||||
|
||||
|
||||
class ackermannize_bv_tactic : public tactic {
|
||||
|
|
|
@ -16,7 +16,7 @@ Revision History:
|
|||
|
||||
#ifndef _ACKERMANNIZE_TACTIC_H_
|
||||
#define _ACKERMANNIZE_TACTIC_H_
|
||||
#include"tactical.h"
|
||||
#include "tactic/tactical.h"
|
||||
|
||||
tactic * mk_ackermannize_bv_tactic(ast_manager & m, params_ref const & p);
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"ackr_helper.h"
|
||||
#include"ackr_bound_probe.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include "ackermannization/ackr_helper.h"
|
||||
#include "ackermannization/ackr_bound_probe.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
|
||||
/*
|
||||
For each function f, calculate the number of its occurrences o_f and compute "o_f choose 2".
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef ACKR_BOUND_PROBE_H_
|
||||
#define ACKR_BOUND_PROBE_H_
|
||||
|
||||
#include"probe.h"
|
||||
#include "tactic/probe.h"
|
||||
|
||||
probe * mk_ackr_bound_probe();
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"ackr_helper.h"
|
||||
#include "ackermannization/ackr_helper.h"
|
||||
|
||||
double ackr_helper::calculate_lemma_bound(ackr_helper::fun2terms_map& occurrences) {
|
||||
fun2terms_map::iterator it = occurrences.begin();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef ACKR_HELPER_H_
|
||||
#define ACKR_HELPER_H_
|
||||
|
||||
#include"bv_decl_plugin.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
|
||||
class ackr_helper {
|
||||
public:
|
||||
|
|
|
@ -16,11 +16,11 @@ Revision History:
|
|||
#ifndef ACKR_INFO_H_
|
||||
#define ACKR_INFO_H_
|
||||
|
||||
#include"obj_hashtable.h"
|
||||
#include"ast.h"
|
||||
#include"ref.h"
|
||||
#include"expr_replacer.h"
|
||||
#include"ast_translation.h"
|
||||
#include "util/obj_hashtable.h"
|
||||
#include "ast/ast.h"
|
||||
#include "util/ref.h"
|
||||
#include "ast/rewriter/expr_replacer.h"
|
||||
#include "ast/ast_translation.h"
|
||||
|
||||
/** \brief
|
||||
Information about how a formula is being converted into
|
||||
|
|
|
@ -13,10 +13,10 @@ Mikolas Janota
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"ackr_model_converter.h"
|
||||
#include"model_evaluator.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include"ackr_info.h"
|
||||
#include "ackermannization/ackr_model_converter.h"
|
||||
#include "model/model_evaluator.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
|
||||
|
||||
class ackr_model_converter : public model_converter {
|
||||
|
|
|
@ -16,8 +16,8 @@ Revision History:
|
|||
#ifndef ACKR_MODEL_CONVERTER_H_
|
||||
#define ACKR_MODEL_CONVERTER_H_
|
||||
|
||||
#include"model_converter.h"
|
||||
#include"ackr_info.h"
|
||||
#include "tactic/model_converter.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
|
||||
model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref& info, model_ref& abstr_model);
|
||||
model_converter * mk_ackr_model_converter(ast_manager & m, const ackr_info_ref& info);
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
Revision History:
|
||||
--*/
|
||||
|
||||
#include"lackr.h"
|
||||
#include"ackermannization_params.hpp"
|
||||
#include"tactic.h"
|
||||
#include"lackr_model_constructor.h"
|
||||
#include"ackr_info.h"
|
||||
#include"for_each_expr.h"
|
||||
#include"model_smt2_pp.h"
|
||||
#include "ackermannization/lackr.h"
|
||||
#include "ackermannization/ackermannization_params.hpp"
|
||||
#include "tactic/tactic.h"
|
||||
#include "ackermannization/lackr_model_constructor.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
#include "ast/for_each_expr.h"
|
||||
#include "model/model_smt2_pp.h"
|
||||
|
||||
lackr::lackr(ast_manager& m, params_ref p, lackr_stats& st, expr_ref_vector& formulas,
|
||||
solver * uffree_solver)
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
#ifndef LACKR_H_
|
||||
#define LACKR_H_
|
||||
|
||||
#include"ackr_info.h"
|
||||
#include"ackr_helper.h"
|
||||
#include"th_rewriter.h"
|
||||
#include"cooperate.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include"lbool.h"
|
||||
#include"model.h"
|
||||
#include"solver.h"
|
||||
#include"util.h"
|
||||
#include"tactic_exception.h"
|
||||
#include"goal.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
#include "ackermannization/ackr_helper.h"
|
||||
#include "ast/rewriter/th_rewriter.h"
|
||||
#include "util/cooperate.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
#include "util/lbool.h"
|
||||
#include "model/model.h"
|
||||
#include "solver/solver.h"
|
||||
#include "util/util.h"
|
||||
#include "tactic/tactic_exception.h"
|
||||
#include "tactic/goal.h"
|
||||
|
||||
struct lackr_stats {
|
||||
lackr_stats() : m_it(0), m_ackrs_sz(0) {}
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"lackr_model_constructor.h"
|
||||
#include"model_evaluator.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include"ackr_info.h"
|
||||
#include"for_each_expr.h"
|
||||
#include"bv_rewriter.h"
|
||||
#include"bool_rewriter.h"
|
||||
#include "ackermannization/lackr_model_constructor.h"
|
||||
#include "model/model_evaluator.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
#include "ast/for_each_expr.h"
|
||||
#include "ast/rewriter/bv_rewriter.h"
|
||||
#include "ast/rewriter/bool_rewriter.h"
|
||||
|
||||
struct lackr_model_constructor::imp {
|
||||
public:
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#ifndef LACKR_MODEL_CONSTRUCTOR_H_
|
||||
#define LACKR_MODEL_CONSTRUCTOR_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"ackr_info.h"
|
||||
#include"ackr_helper.h"
|
||||
#include"model.h"
|
||||
#include "ast/ast.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
#include "ackermannization/ackr_helper.h"
|
||||
#include "model/model.h"
|
||||
|
||||
class lackr_model_constructor {
|
||||
public:
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
Revision History:
|
||||
--*/
|
||||
#include"lackr_model_converter_lazy.h"
|
||||
#include"model_evaluator.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include"ackr_info.h"
|
||||
#include"lackr_model_constructor.h"
|
||||
#include "ackermannization/lackr_model_converter_lazy.h"
|
||||
#include "model/model_evaluator.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
#include "ackermannization/lackr_model_constructor.h"
|
||||
|
||||
class lackr_model_converter_lazy : public model_converter {
|
||||
public:
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#ifndef LACKR_MODEL_CONVERTER_LAZY_H_
|
||||
#define LACKR_MODEL_CONVERTER_LAZY_H_
|
||||
|
||||
#include"model_converter.h"
|
||||
#include"ackr_info.h"
|
||||
#include "tactic/model_converter.h"
|
||||
#include "ackermannization/ackr_info.h"
|
||||
|
||||
model_converter * mk_lackr_model_converter_lazy(ast_manager & m, const ackr_info_ref& info, model_ref& abstr_model);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ z3_add_component(api
|
|||
api_parsers.cpp
|
||||
api_pb.cpp
|
||||
api_polynomial.cpp
|
||||
api_qe.cpp
|
||||
api_quant.cpp
|
||||
api_rcf.cpp
|
||||
api_seq.cpp
|
||||
|
|
|
@ -17,14 +17,14 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"algebraic_numbers.h"
|
||||
#include"expr2polynomial.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "math/polynomial/algebraic_numbers.h"
|
||||
#include "ast/expr2polynomial.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
|
||||
|
||||
#define CHECK_IS_ALGEBRAIC(ARG, RET) { \
|
||||
|
|
|
@ -15,12 +15,12 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"arith_decl_plugin.h"
|
||||
#include"algebraic_numbers.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "math/polynomial/algebraic_numbers.h"
|
||||
|
||||
#define MK_ARITH_OP(NAME, OP) MK_NARY(NAME, mk_c(c)->get_arith_fid(), OP, SKIP)
|
||||
#define MK_BINARY_ARITH_OP(NAME, OP) MK_BINARY(NAME, mk_c(c)->get_arith_fid(), OP, SKIP)
|
||||
|
|
|
@ -15,11 +15,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"array_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/array_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -16,28 +16,28 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"well_sorted.h"
|
||||
#include"arith_decl_plugin.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include"datatype_decl_plugin.h"
|
||||
#include"array_decl_plugin.h"
|
||||
#include"pb_decl_plugin.h"
|
||||
#include"ast_translation.h"
|
||||
#include"ast_pp.h"
|
||||
#include"ast_ll_pp.h"
|
||||
#include"ast_smt_pp.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include"th_rewriter.h"
|
||||
#include"var_subst.h"
|
||||
#include"expr_safe_replace.h"
|
||||
#include"pp.h"
|
||||
#include"scoped_ctrl_c.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"pp_params.hpp"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/well_sorted.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
#include "ast/datatype_decl_plugin.h"
|
||||
#include "ast/array_decl_plugin.h"
|
||||
#include "ast/pb_decl_plugin.h"
|
||||
#include "ast/ast_translation.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
#include "ast/ast_smt_pp.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ast/rewriter/th_rewriter.h"
|
||||
#include "ast/rewriter/var_subst.h"
|
||||
#include "ast/rewriter/expr_safe_replace.h"
|
||||
#include "ast/pp.h"
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "ast/pp_params.hpp"
|
||||
|
||||
extern bool is_numeral_sort(Z3_context c, Z3_sort ty);
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_ast_map.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include"dec_ref_util.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_ast_map.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "util/dec_ref_util.h"
|
||||
|
||||
Z3_ast_map_ref::~Z3_ast_map_ref() {
|
||||
dec_ref_key_values(m, m_map);
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_AST_MAP_H_
|
||||
#define API_AST_MAP_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"obj_hashtable.h"
|
||||
#include "api/api_util.h"
|
||||
#include "util/obj_hashtable.h"
|
||||
|
||||
struct Z3_ast_map_ref : public api::object {
|
||||
ast_manager & m;
|
||||
|
|
|
@ -16,12 +16,12 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"ast_translation.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "ast/ast_translation.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ Revision History:
|
|||
#ifndef API_AST_VECTOR_H_
|
||||
#define API_AST_VECTOR_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include "api/api_util.h"
|
||||
|
||||
namespace api {
|
||||
class context;
|
||||
|
|
|
@ -15,11 +15,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_context.h"
|
||||
#include"pp.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_util.h"
|
||||
#include"cmd_context.h"
|
||||
#include"symbol.h"
|
||||
#include"gparams.h"
|
||||
#include"env_params.h"
|
||||
#include"context_params.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_context.h"
|
||||
#include "ast/pp.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_util.h"
|
||||
#include "cmd_context/cmd_context.h"
|
||||
#include "util/symbol.h"
|
||||
#include "util/gparams.h"
|
||||
#include "util/env_params.h"
|
||||
#include "cmd_context/context_params.h"
|
||||
|
||||
extern "C" {
|
||||
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) {
|
||||
|
|
|
@ -18,15 +18,15 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<typeinfo>
|
||||
#include"api_context.h"
|
||||
#include"smtparser.h"
|
||||
#include"version.h"
|
||||
#include"ast_pp.h"
|
||||
#include"ast_ll_pp.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_util.h"
|
||||
#include"reg_decl_plugins.h"
|
||||
#include"realclosure.h"
|
||||
#include "api/api_context.h"
|
||||
#include "parsers/smt/smtparser.h"
|
||||
#include "util/version.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/reg_decl_plugins.h"
|
||||
#include "math/realclosure/realclosure.h"
|
||||
|
||||
// The install_tactics procedure is automatically generated
|
||||
void install_tactics(tactic_manager & ctx);
|
||||
|
@ -142,7 +142,7 @@ namespace api {
|
|||
#pragma omp critical (set_interruptable)
|
||||
{
|
||||
if (m_interruptable)
|
||||
(*m_interruptable)();
|
||||
(*m_interruptable)(API_INTERRUPT_EH_CALLER);
|
||||
m_limit.cancel();
|
||||
m().limit().cancel();
|
||||
}
|
||||
|
@ -150,8 +150,9 @@ namespace api {
|
|||
|
||||
void context::set_error_code(Z3_error_code err) {
|
||||
m_error_code = err;
|
||||
if (err != Z3_OK)
|
||||
if (err != Z3_OK) {
|
||||
invoke_error_handler(err);
|
||||
}
|
||||
}
|
||||
|
||||
void context::check_searching() {
|
||||
|
|
|
@ -20,22 +20,22 @@ Revision History:
|
|||
#ifndef API_CONTEXT_H_
|
||||
#define API_CONTEXT_H_
|
||||
|
||||
#include"z3.h"
|
||||
#include"ast.h"
|
||||
#include"api_util.h"
|
||||
#include"arith_decl_plugin.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include"seq_decl_plugin.h"
|
||||
#include"datatype_decl_plugin.h"
|
||||
#include"dl_decl_plugin.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
#include"smt_kernel.h"
|
||||
#include"smt_params.h"
|
||||
#include"event_handler.h"
|
||||
#include"tactic_manager.h"
|
||||
#include"context_params.h"
|
||||
#include"api_polynomial.h"
|
||||
#include"hashtable.h"
|
||||
#include "api/z3.h"
|
||||
#include "ast/ast.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
#include "ast/seq_decl_plugin.h"
|
||||
#include "ast/datatype_decl_plugin.h"
|
||||
#include "ast/dl_decl_plugin.h"
|
||||
#include "ast/fpa_decl_plugin.h"
|
||||
#include "smt/smt_kernel.h"
|
||||
#include "smt/params/smt_params.h"
|
||||
#include "util/event_handler.h"
|
||||
#include "cmd_context/tactic_manager.h"
|
||||
#include "cmd_context/context_params.h"
|
||||
#include "api/api_polynomial.h"
|
||||
#include "util/hashtable.h"
|
||||
|
||||
namespace smtlib {
|
||||
class parser;
|
||||
|
|
|
@ -15,24 +15,24 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"api_datalog.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"ast_pp.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_stats.h"
|
||||
#include"datalog_parser.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"dl_cmds.h"
|
||||
#include"cmd_context.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"
|
||||
#include "api/api_datalog.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_stats.h"
|
||||
#include "muz/fp/datalog_parser.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "muz/fp/dl_cmds.h"
|
||||
#include "cmd_context/cmd_context.h"
|
||||
#include "parsers/smt2/smt2parser.h"
|
||||
#include "muz/base/dl_context.h"
|
||||
#include "muz/fp/dl_register_engine.h"
|
||||
#include "muz/rel/dl_external_relation.h"
|
||||
#include "ast/dl_decl_plugin.h"
|
||||
#include "muz/rel/rel_context.h"
|
||||
|
||||
namespace api {
|
||||
|
||||
|
@ -605,5 +605,6 @@ extern "C" {
|
|||
|
||||
}
|
||||
|
||||
#include "api_datalog_spacer.inc"
|
||||
|
||||
};
|
||||
|
|
|
@ -19,11 +19,11 @@ Revision History:
|
|||
#ifndef API_DATALOG_H_
|
||||
#define API_DATALOG_H_
|
||||
|
||||
#include"z3.h"
|
||||
#include"ast.h"
|
||||
#include"smt_params.h"
|
||||
#include"smt_kernel.h"
|
||||
#include"api_util.h"
|
||||
#include "api/z3.h"
|
||||
#include "ast/ast.h"
|
||||
#include "smt/params/smt_params.h"
|
||||
#include "smt/smt_kernel.h"
|
||||
#include "api/api_util.h"
|
||||
|
||||
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*);
|
||||
|
|
113
src/api/api_datalog_spacer.inc
Normal file
113
src/api/api_datalog_spacer.inc
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*++
|
||||
Copyright (c) 2017 Arie Gurfinkel
|
||||
|
||||
Module Name:
|
||||
|
||||
api_datalog_spacer.inc
|
||||
|
||||
Abstract:
|
||||
|
||||
Spacer-specific datalog API
|
||||
|
||||
Author:
|
||||
|
||||
Arie Gurfinkel (arie)
|
||||
|
||||
Notes:
|
||||
this file is included at the bottom of api_datalog.cpp
|
||||
|
||||
--*/
|
||||
Z3_lbool Z3_API Z3_fixedpoint_query_from_lvl (Z3_context c, Z3_fixedpoint d, Z3_ast q, unsigned lvl) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_query_from_lvl (c, d, q, lvl);
|
||||
RESET_ERROR_CODE();
|
||||
lbool r = l_undef;
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
unsigned rlimit = to_fixedpoint(d)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
|
||||
{
|
||||
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
|
||||
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
|
||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||
scoped_timer timer(timeout, &eh);
|
||||
try {
|
||||
r = to_fixedpoint_ref(d)->ctx().query_from_lvl (to_expr(q), lvl);
|
||||
}
|
||||
catch (z3_exception& ex) {
|
||||
mk_c(c)->handle_exception(ex);
|
||||
r = l_undef;
|
||||
}
|
||||
to_fixedpoint_ref(d)->ctx().cleanup();
|
||||
}
|
||||
return of_lbool(r);
|
||||
Z3_CATCH_RETURN(Z3_L_UNDEF);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_fixedpoint_get_ground_sat_answer(Z3_context c, Z3_fixedpoint d) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_get_ground_sat_answer(c, d);
|
||||
RESET_ERROR_CODE();
|
||||
expr* e = to_fixedpoint_ref(d)->ctx().get_ground_sat_answer();
|
||||
mk_c(c)->save_ast_trail(e);
|
||||
RETURN_Z3(of_expr(e));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast_vector Z3_API Z3_fixedpoint_get_rules_along_trace(
|
||||
Z3_context c,
|
||||
Z3_fixedpoint d)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_get_rules_along_trace(c, d);
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, *mk_c(c), m);
|
||||
mk_c(c)->save_object(v);
|
||||
expr_ref_vector rules(m);
|
||||
svector<symbol> names;
|
||||
|
||||
to_fixedpoint_ref(d)->ctx().get_rules_along_trace_as_formulas(rules, names);
|
||||
for (unsigned i = 0; i < rules.size(); ++i) {
|
||||
v->m_ast_vector.push_back(rules[i].get());
|
||||
}
|
||||
RETURN_Z3(of_ast_vector(v));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_symbol Z3_API Z3_fixedpoint_get_rule_names_along_trace(
|
||||
Z3_context c,
|
||||
Z3_fixedpoint d)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_get_rule_names_along_trace(c, d);
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, *mk_c(c), m);
|
||||
mk_c(c)->save_object(v);
|
||||
expr_ref_vector rules(m);
|
||||
svector<symbol> names;
|
||||
std::stringstream ss;
|
||||
|
||||
to_fixedpoint_ref(d)->ctx().get_rules_along_trace_as_formulas(rules, names);
|
||||
for (unsigned i = 0; i < names.size(); ++i) {
|
||||
ss << ";" << names[i].str();
|
||||
}
|
||||
RETURN_Z3(of_symbol(symbol(ss.str().substr(1).c_str())));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_fixedpoint_add_invariant(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred, Z3_ast property) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_add_invariant(c, d, pred, property);
|
||||
RESET_ERROR_CODE();
|
||||
to_fixedpoint_ref(d)->ctx ().add_invariant(to_func_decl(pred), to_expr(property));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_fixedpoint_get_reachable(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_get_reachable(c, d, pred);
|
||||
RESET_ERROR_CODE();
|
||||
expr_ref r = to_fixedpoint_ref(d)->ctx().get_reachable(to_func_decl(pred));
|
||||
mk_c(c)->save_ast_trail(r);
|
||||
RETURN_Z3(of_expr(r.get()));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
|
@ -15,11 +15,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"datatype_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/datatype_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -45,13 +45,13 @@ extern "C" {
|
|||
|
||||
ptr_vector<accessor_decl> acc;
|
||||
for (unsigned i = 0; i < num_fields; ++i) {
|
||||
acc.push_back(mk_accessor_decl(to_symbol(field_names[i]), type_ref(to_sort(field_sorts[i]))));
|
||||
acc.push_back(mk_accessor_decl(m, to_symbol(field_names[i]), type_ref(to_sort(field_sorts[i]))));
|
||||
}
|
||||
|
||||
constructor_decl* constrs[1] = { mk_constructor_decl(to_symbol(name), recognizer, acc.size(), acc.c_ptr()) };
|
||||
|
||||
{
|
||||
datatype_decl * dt = mk_datatype_decl(to_symbol(name), 1, constrs);
|
||||
datatype_decl * dt = mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, 1, constrs);
|
||||
bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, 0, tuples);
|
||||
del_datatype_decl(dt);
|
||||
|
||||
|
@ -69,18 +69,13 @@ extern "C" {
|
|||
// create constructor
|
||||
SASSERT(dt_util.is_datatype(tuple));
|
||||
SASSERT(!dt_util.is_recursive(tuple));
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(tuple);
|
||||
func_decl* decl = (*decls)[0];
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(tuple);
|
||||
func_decl* decl = (decls)[0];
|
||||
mk_c(c)->save_multiple_ast_trail(decl);
|
||||
*mk_tuple_decl = of_func_decl(decl);
|
||||
|
||||
// Create projections
|
||||
ptr_vector<func_decl> const * accs = dt_util.get_constructor_accessors(decl);
|
||||
if (!accs) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const & _accs = *accs;
|
||||
ptr_vector<func_decl> const & _accs = *dt_util.get_constructor_accessors(decl);
|
||||
SASSERT(_accs.size() == num_fields);
|
||||
for (unsigned i = 0; i < _accs.size(); i++) {
|
||||
mk_c(c)->save_multiple_ast_trail(_accs[i]);
|
||||
|
@ -118,7 +113,7 @@ extern "C" {
|
|||
|
||||
|
||||
{
|
||||
datatype_decl * dt = mk_datatype_decl(to_symbol(name), n, constrs.c_ptr());
|
||||
datatype_decl * dt = mk_datatype_decl(dt_util, to_symbol(name), 0, 0, n, constrs.c_ptr());
|
||||
bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, 0, sorts);
|
||||
del_datatype_decl(dt);
|
||||
|
||||
|
@ -136,10 +131,10 @@ extern "C" {
|
|||
// create constructor
|
||||
SASSERT(dt_util.is_datatype(e));
|
||||
SASSERT(!dt_util.is_recursive(e));
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(e);
|
||||
SASSERT(decls && decls->size() == n);
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(e);
|
||||
SASSERT(decls.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
func_decl* decl = (*decls)[i];
|
||||
func_decl* decl = (decls)[i];
|
||||
mk_c(c)->save_multiple_ast_trail(decl);
|
||||
enum_consts[i] = of_func_decl(decl);
|
||||
decl = dt_util.get_constructor_recognizer(decl);
|
||||
|
@ -165,11 +160,12 @@ extern "C" {
|
|||
LOG_Z3_mk_list_sort(c, name, elem_sort, nil_decl, is_nil_decl, cons_decl, is_cons_decl, head_decl, tail_decl);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
mk_c(c)->reset_last_result();
|
||||
datatype_util data_util(m);
|
||||
accessor_decl* head_tail[2] = {
|
||||
mk_accessor_decl(symbol("head"), type_ref(to_sort(elem_sort))),
|
||||
mk_accessor_decl(symbol("tail"), type_ref(0))
|
||||
mk_accessor_decl(m, symbol("head"), type_ref(to_sort(elem_sort))),
|
||||
mk_accessor_decl(m, symbol("tail"), type_ref(0))
|
||||
};
|
||||
constructor_decl* constrs[2] = {
|
||||
mk_constructor_decl(symbol("nil"), symbol("is_nil"), 0, 0),
|
||||
|
@ -179,7 +175,7 @@ extern "C" {
|
|||
|
||||
sort_ref_vector sorts(m);
|
||||
{
|
||||
datatype_decl * decl = mk_datatype_decl(to_symbol(name), 2, constrs);
|
||||
datatype_decl * decl = mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, 2, constrs);
|
||||
bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &decl, 0, 0, sorts);
|
||||
del_datatype_decl(decl);
|
||||
|
||||
|
@ -215,18 +211,16 @@ extern "C" {
|
|||
*is_cons_decl = of_func_decl(f);
|
||||
}
|
||||
if (head_decl) {
|
||||
ptr_vector<func_decl> const* acc = data_util.get_constructor_accessors(cnstrs[1]);
|
||||
SASSERT(acc);
|
||||
SASSERT(acc->size() == 2);
|
||||
f = (*acc)[0];
|
||||
ptr_vector<func_decl> const& acc = *data_util.get_constructor_accessors(cnstrs[1]);
|
||||
SASSERT(acc.size() == 2);
|
||||
f = (acc)[0];
|
||||
mk_c(c)->save_multiple_ast_trail(f);
|
||||
*head_decl = of_func_decl(f);
|
||||
}
|
||||
if (tail_decl) {
|
||||
ptr_vector<func_decl> const* acc = data_util.get_constructor_accessors(cnstrs[1]);
|
||||
SASSERT(acc);
|
||||
SASSERT(acc->size() == 2);
|
||||
f = (*acc)[1];
|
||||
ptr_vector<func_decl> const& acc = *data_util.get_constructor_accessors(cnstrs[1]);
|
||||
SASSERT(acc.size() == 2);
|
||||
f = (acc)[1];
|
||||
mk_c(c)->save_multiple_ast_trail(f);
|
||||
*tail_decl = of_func_decl(f);
|
||||
}
|
||||
|
@ -301,13 +295,9 @@ extern "C" {
|
|||
*tester = of_func_decl(f2);
|
||||
}
|
||||
|
||||
ptr_vector<func_decl> const* accs = data_util.get_constructor_accessors(f);
|
||||
if (!accs && num_fields > 0) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return;
|
||||
}
|
||||
ptr_vector<func_decl> const& accs = *data_util.get_constructor_accessors(f);
|
||||
for (unsigned i = 0; i < num_fields; ++i) {
|
||||
func_decl* f2 = (*accs)[i];
|
||||
func_decl* f2 = (accs)[i];
|
||||
mk_c(c)->save_multiple_ast_trail(f2);
|
||||
accessors[i] = of_func_decl(f2);
|
||||
}
|
||||
|
@ -327,21 +317,23 @@ extern "C" {
|
|||
Z3_symbol name,
|
||||
unsigned num_constructors,
|
||||
Z3_constructor constructors[]) {
|
||||
datatype_util& dt_util = mk_c(c)->dtutil();
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
ptr_vector<constructor_decl> constrs;
|
||||
for (unsigned i = 0; i < num_constructors; ++i) {
|
||||
constructor* cn = reinterpret_cast<constructor*>(constructors[i]);
|
||||
ptr_vector<accessor_decl> acc;
|
||||
for (unsigned j = 0; j < cn->m_sorts.size(); ++j) {
|
||||
if (cn->m_sorts[j].get()) {
|
||||
acc.push_back(mk_accessor_decl(cn->m_field_names[j], type_ref(cn->m_sorts[j].get())));
|
||||
acc.push_back(mk_accessor_decl(m, cn->m_field_names[j], type_ref(cn->m_sorts[j].get())));
|
||||
}
|
||||
else {
|
||||
acc.push_back(mk_accessor_decl(cn->m_field_names[j], type_ref(cn->m_sort_refs[j])));
|
||||
acc.push_back(mk_accessor_decl(m, cn->m_field_names[j], type_ref(cn->m_sort_refs[j])));
|
||||
}
|
||||
}
|
||||
constrs.push_back(mk_constructor_decl(cn->m_name, cn->m_tester, acc.size(), acc.c_ptr()));
|
||||
}
|
||||
return mk_datatype_decl(to_symbol(name), num_constructors, constrs.c_ptr());
|
||||
return mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, num_constructors, constrs.c_ptr());
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_datatype(Z3_context c,
|
||||
|
@ -368,11 +360,11 @@ extern "C" {
|
|||
sort * s = sorts.get(0);
|
||||
|
||||
mk_c(c)->save_ast_trail(s);
|
||||
ptr_vector<func_decl> const* cnstrs = data_util.get_datatype_constructors(s);
|
||||
ptr_vector<func_decl> const& cnstrs = *data_util.get_datatype_constructors(s);
|
||||
|
||||
for (unsigned i = 0; i < num_constructors; ++i) {
|
||||
constructor* cn = reinterpret_cast<constructor*>(constructors[i]);
|
||||
cn->m_constructor = (*cnstrs)[i];
|
||||
cn->m_constructor = cnstrs[i];
|
||||
}
|
||||
RETURN_Z3_mk_datatype(of_sort(s));
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
@ -417,7 +409,7 @@ extern "C" {
|
|||
ptr_vector<datatype_decl> datas;
|
||||
for (unsigned i = 0; i < num_sorts; ++i) {
|
||||
constructor_list* cl = reinterpret_cast<constructor_list*>(constructor_lists[i]);
|
||||
datas.push_back(mk_datatype_decl(c,sort_names[i], cl->size(), reinterpret_cast<Z3_constructor*>(cl->c_ptr())));
|
||||
datas.push_back(mk_datatype_decl(c, sort_names[i], cl->size(), reinterpret_cast<Z3_constructor*>(cl->c_ptr())));
|
||||
}
|
||||
sort_ref_vector _sorts(m);
|
||||
bool ok = mk_c(c)->get_dt_plugin()->mk_datatypes(datas.size(), datas.c_ptr(), 0, 0, _sorts);
|
||||
|
@ -434,10 +426,10 @@ extern "C" {
|
|||
mk_c(c)->save_multiple_ast_trail(s);
|
||||
sorts[i] = of_sort(s);
|
||||
constructor_list* cl = reinterpret_cast<constructor_list*>(constructor_lists[i]);
|
||||
ptr_vector<func_decl> const* cnstrs = data_util.get_datatype_constructors(s);
|
||||
ptr_vector<func_decl> const& cnstrs = *data_util.get_datatype_constructors(s);
|
||||
for (unsigned j = 0; j < cl->size(); ++j) {
|
||||
constructor* cn = (*cl)[j];
|
||||
cn->m_constructor = (*cnstrs)[j];
|
||||
cn->m_constructor = cnstrs[j];
|
||||
}
|
||||
}
|
||||
RETURN_Z3_mk_datatypes;
|
||||
|
@ -456,12 +448,7 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
return decls->size();
|
||||
return dt_util.get_datatype_constructors(_t)->size();
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -474,12 +461,12 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx >= decls->size()) {
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(_t);
|
||||
if (idx >= decls.size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
func_decl* decl = (*decls)[idx];
|
||||
func_decl* decl = (decls)[idx];
|
||||
mk_c(c)->save_ast_trail(decl);
|
||||
return of_func_decl(decl);
|
||||
}
|
||||
|
@ -504,12 +491,12 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx >= decls->size()) {
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(_t);
|
||||
if (idx >= decls.size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
func_decl* decl = (*decls)[idx];
|
||||
func_decl* decl = (decls)[idx];
|
||||
decl = dt_util.get_constructor_recognizer(decl);
|
||||
mk_c(c)->save_ast_trail(decl);
|
||||
RETURN_Z3(of_func_decl(decl));
|
||||
|
@ -527,23 +514,23 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (!decls || idx_c >= decls->size()) {
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(_t);
|
||||
if (idx_c >= decls.size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
func_decl* decl = (*decls)[idx_c];
|
||||
func_decl* decl = (decls)[idx_c];
|
||||
if (decl->get_arity() <= idx_a) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * accs = dt_util.get_constructor_accessors(decl);
|
||||
SASSERT(accs && accs->size() == decl->get_arity());
|
||||
if (!accs || accs->size() <= idx_a) {
|
||||
ptr_vector<func_decl> const & accs = *dt_util.get_constructor_accessors(decl);
|
||||
SASSERT(accs.size() == decl->get_arity());
|
||||
if (accs.size() <= idx_a) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
decl = (*accs)[idx_a];
|
||||
decl = (accs)[idx_a];
|
||||
mk_c(c)->save_ast_trail(decl);
|
||||
RETURN_Z3(of_func_decl(decl));
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
@ -574,16 +561,13 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(tuple);
|
||||
if (!decls || decls->size() != 1) {
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(tuple);
|
||||
if (decls.size() != 1) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * accs = dt_util.get_constructor_accessors((*decls)[0]);
|
||||
if (!accs) {
|
||||
return 0;
|
||||
}
|
||||
return accs->size();
|
||||
ptr_vector<func_decl> const & accs = *dt_util.get_constructor_accessors(decls[0]);
|
||||
return accs.size();
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -597,21 +581,17 @@ extern "C" {
|
|||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(tuple);
|
||||
if (!decls || decls->size() != 1) {
|
||||
ptr_vector<func_decl> const & decls = *dt_util.get_datatype_constructors(tuple);
|
||||
if (decls.size() != 1) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * accs = dt_util.get_constructor_accessors((*decls)[0]);
|
||||
if (!accs) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
if (accs->size() <= i) {
|
||||
ptr_vector<func_decl> const & accs = *dt_util.get_constructor_accessors((decls)[0]);
|
||||
if (accs.size() <= i) {
|
||||
SET_ERROR_CODE(Z3_IOB);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
func_decl* acc = (*accs)[i];
|
||||
func_decl* acc = (accs)[i];
|
||||
mk_c(c)->save_ast_trail(acc);
|
||||
RETURN_Z3(of_func_decl(acc));
|
||||
Z3_CATCH_RETURN(0);
|
||||
|
|
|
@ -17,10 +17,10 @@ Notes:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "ast/fpa_decl_plugin.h"
|
||||
|
||||
bool is_fp_sort(Z3_context c, Z3_sort s) {
|
||||
return mk_c(c)->fpautil().is_float(to_sort(s));
|
||||
|
|
|
@ -16,11 +16,11 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_goal.h"
|
||||
#include"ast_translation.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_goal.h"
|
||||
#include "ast/ast_translation.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_GOAL_H_
|
||||
#define API_GOAL_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"goal.h"
|
||||
#include "api/api_util.h"
|
||||
#include "tactic/goal.h"
|
||||
|
||||
struct Z3_goal_ref : public api::object {
|
||||
goal_ref m_goal;
|
||||
|
|
|
@ -17,27 +17,27 @@
|
|||
--*/
|
||||
#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"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_tactic.h"
|
||||
#include "api/api_solver.h"
|
||||
#include "api/api_model.h"
|
||||
#include "api/api_stats.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "solver/tactic2solver.h"
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "tactic/portfolio/smt_strategic_solver.h"
|
||||
#include "smt/smt_solver.h"
|
||||
#include "smt/smt_implied_equalities.h"
|
||||
#include "interp/iz3interp.h"
|
||||
#include "interp/iz3profiling.h"
|
||||
#include "interp/iz3hash.h"
|
||||
#include "interp/iz3pp.h"
|
||||
#include "interp/iz3checker.h"
|
||||
#include "ast/scoped_proof.h"
|
||||
|
||||
using namespace stl_ext;
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<fstream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"util.h"
|
||||
#include"version.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "util/util.h"
|
||||
#include "util/version.h"
|
||||
|
||||
std::ostream * g_z3_log = 0;
|
||||
bool g_z3_log_enabled = false;
|
||||
|
|
|
@ -16,20 +16,31 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_model.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"array_decl_plugin.h"
|
||||
#include"model.h"
|
||||
#include"model_v2_pp.h"
|
||||
#include"model_smt2_pp.h"
|
||||
#include"model_params.hpp"
|
||||
#include"model_evaluator_params.hpp"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_model.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "ast/array_decl_plugin.h"
|
||||
#include "model/model.h"
|
||||
#include "model/model_v2_pp.h"
|
||||
#include "model/model_smt2_pp.h"
|
||||
#include "model/model_params.hpp"
|
||||
#include "model/model_evaluator_params.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
Z3_model Z3_API Z3_mk_model(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_model(c);
|
||||
RESET_ERROR_CODE();
|
||||
Z3_model_ref * m_ref = alloc(Z3_model_ref, *mk_c(c));
|
||||
m_ref->m_model = alloc(model, mk_c(c)->m());
|
||||
mk_c(c)->save_object(m_ref);
|
||||
RETURN_Z3(of_model(m_ref));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_model_inc_ref(c, m);
|
||||
|
@ -224,6 +235,31 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast else_val) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_add_func_interp(c, m, f, else_val);
|
||||
RESET_ERROR_CODE();
|
||||
func_decl* d = to_func_decl(f);
|
||||
model* mdl = to_model_ref(m);
|
||||
Z3_func_interp_ref * f_ref = alloc(Z3_func_interp_ref, *mk_c(c), mdl);
|
||||
f_ref->m_func_interp = alloc(func_interp, mk_c(c)->m(), d->get_arity());
|
||||
mk_c(c)->save_object(f_ref);
|
||||
mdl->register_decl(d, f_ref->m_func_interp);
|
||||
f_ref->m_func_interp->set_else(to_expr(else_val));
|
||||
RETURN_Z3(of_func_interp(f_ref));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_add_const_interp(c, m, f, a);
|
||||
RESET_ERROR_CODE();
|
||||
func_decl* d = to_func_decl(f);
|
||||
model* mdl = to_model_ref(m);
|
||||
mdl->register_decl(d, to_expr(a));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_interp_inc_ref(Z3_context c, Z3_func_interp f) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_interp_inc_ref(c, f);
|
||||
|
@ -283,6 +319,15 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_interp_set_else(Z3_context c, Z3_func_interp f, Z3_ast else_value) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_interp_set_else(c, f, else_value);
|
||||
RESET_ERROR_CODE();
|
||||
// CHECK_NON_NULL(f, 0);
|
||||
to_func_interp_ref(f)->set_else(to_expr(else_value));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_func_interp_get_arity(Z3_context c, Z3_func_interp f) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_interp_get_arity(c, f);
|
||||
|
@ -292,6 +337,24 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_interp_add_entry(Z3_context c, Z3_func_interp fi, Z3_ast_vector args, Z3_ast value) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_interp_add_entry(c, fi, args, value);
|
||||
//CHECK_NON_NULL(fi, void);
|
||||
//CHECK_NON_NULL(args, void);
|
||||
//CHECK_NON_NULL(value, void);
|
||||
func_interp* _fi = to_func_interp_ref(fi);
|
||||
expr* _value = to_expr(value);
|
||||
if (to_ast_vector_ref(args).size() != _fi->get_arity()) {
|
||||
SET_ERROR_CODE(Z3_IOB);
|
||||
return;
|
||||
}
|
||||
// check sorts of value
|
||||
expr* const* _args = (expr* const*) to_ast_vector_ref(args).c_ptr();
|
||||
_fi->insert_entry(_args, _value);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_entry_inc_ref(Z3_context c, Z3_func_entry e) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_entry_inc_ref(c, e);
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_MODEL_H_
|
||||
#define API_MODEL_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"model.h"
|
||||
#include "api/api_util.h"
|
||||
#include "model/model.h"
|
||||
|
||||
struct Z3_model_ref : public api::object {
|
||||
model_ref m_model;
|
||||
|
|
|
@ -16,14 +16,14 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"arith_decl_plugin.h"
|
||||
#include"bv_decl_plugin.h"
|
||||
#include"algebraic_numbers.h"
|
||||
#include"fpa_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "ast/bv_decl_plugin.h"
|
||||
#include "math/polynomial/algebraic_numbers.h"
|
||||
#include "ast/fpa_decl_plugin.h"
|
||||
|
||||
bool is_numeral_sort(Z3_context c, Z3_sort ty) {
|
||||
sort * _ty = to_sort(ty);
|
||||
|
|
|
@ -16,18 +16,18 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_stats.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"api_model.h"
|
||||
#include"opt_context.h"
|
||||
#include"opt_cmds.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"smt2parser.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_stats.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "api/api_model.h"
|
||||
#include "opt/opt_context.h"
|
||||
#include "opt/opt_cmds.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "parsers/smt2/smt2parser.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"params.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "util/params.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"cmd_context.h"
|
||||
#include"smt2parser.h"
|
||||
#include"smtparser.h"
|
||||
#include"solver_na2as.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "cmd_context/cmd_context.h"
|
||||
#include "parsers/smt2/smt2parser.h"
|
||||
#include "parsers/smt/smtparser.h"
|
||||
#include "solver/solver_na2as.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"pb_decl_plugin.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/pb_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_polynomial.h"
|
||||
#include"api_ast_vector.h"
|
||||
#include"expr2polynomial.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"expr2var.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_polynomial.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "ast/expr2polynomial.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "ast/expr2var.h"
|
||||
|
||||
namespace api {
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ Notes:
|
|||
#ifndef API_POLYNOMIAL_H_
|
||||
#define API_POLYNOMIAL_H_
|
||||
|
||||
#include"polynomial.h"
|
||||
#include "math/polynomial/polynomial.h"
|
||||
|
||||
namespace api {
|
||||
|
||||
|
|
173
src/api/api_qe.cpp
Normal file
173
src/api/api_qe.cpp
Normal file
|
@ -0,0 +1,173 @@
|
|||
/*++
|
||||
Copyright (c) 2017 Arie Gurfinkel
|
||||
|
||||
Module Name:
|
||||
|
||||
api_qe.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Model-based Projection (MBP) and Quantifier Elimination (QE) API
|
||||
|
||||
Author:
|
||||
|
||||
Arie Gurfinkel (arie)
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
#include <iostream>
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "api/api_model.h"
|
||||
#include "api/api_ast_map.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "qe/qe_vartest.h"
|
||||
#include "qe/qe_lite.h"
|
||||
#include "muz/spacer/spacer_util.h"
|
||||
#include "ast/expr_map.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
static bool to_apps(unsigned n, Z3_app const es[], app_ref_vector& result) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
if (!is_app(to_app(es[i]))) {
|
||||
return false;
|
||||
}
|
||||
result.push_back (to_app (es [i]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_qe_model_project (Z3_context c,
|
||||
Z3_model m,
|
||||
unsigned num_bounds,
|
||||
Z3_app const bound[],
|
||||
Z3_ast body)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_qe_model_project (c, m, num_bounds, bound, body);
|
||||
RESET_ERROR_CODE();
|
||||
|
||||
app_ref_vector vars(mk_c(c)->m ());
|
||||
if (!to_apps(num_bounds, bound, vars)) {
|
||||
SET_ERROR_CODE (Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
||||
expr_ref result (mk_c(c)->m ());
|
||||
result = to_expr (body);
|
||||
model_ref model (to_model_ref (m));
|
||||
spacer::qe_project (mk_c(c)->m (), vars, result, model);
|
||||
mk_c(c)->save_ast_trail (result.get ());
|
||||
|
||||
return of_expr (result.get ());
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_qe_model_project_skolem (Z3_context c,
|
||||
Z3_model m,
|
||||
unsigned num_bounds,
|
||||
Z3_app const bound[],
|
||||
Z3_ast body,
|
||||
Z3_ast_map map)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_qe_model_project_skolem (c, m, num_bounds, bound, body, map);
|
||||
RESET_ERROR_CODE();
|
||||
|
||||
ast_manager& man = mk_c(c)->m ();
|
||||
app_ref_vector vars(man);
|
||||
if (!to_apps(num_bounds, bound, vars)) {
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
|
||||
expr_ref result (mk_c(c)->m ());
|
||||
result = to_expr (body);
|
||||
model_ref model (to_model_ref (m));
|
||||
expr_map emap (man);
|
||||
|
||||
spacer::qe_project (mk_c(c)->m (), vars, result, model, emap);
|
||||
mk_c(c)->save_ast_trail (result.get ());
|
||||
|
||||
obj_map<ast, ast*> &map_z3 = to_ast_map_ref(map);
|
||||
|
||||
for (expr_map::iterator it = emap.begin(), end = emap.end(); it != end; ++it){
|
||||
man.inc_ref(&(it->get_key()));
|
||||
man.inc_ref(it->get_value());
|
||||
map_z3.insert(&(it->get_key()), it->get_value());
|
||||
}
|
||||
|
||||
return of_expr (result.get ());
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_model_extrapolate (Z3_context c,
|
||||
Z3_model m,
|
||||
Z3_ast fml)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_model_extrapolate (c, m, fml);
|
||||
RESET_ERROR_CODE();
|
||||
|
||||
model_ref model (to_model_ref (m));
|
||||
expr_ref_vector facts (mk_c(c)->m ());
|
||||
facts.push_back (to_expr (fml));
|
||||
flatten_and (facts);
|
||||
|
||||
spacer::model_evaluator_util mev (mk_c(c)->m());
|
||||
mev.set_model (*model);
|
||||
|
||||
expr_ref_vector lits (mk_c(c)->m());
|
||||
spacer::compute_implicant_literals (mev, facts, lits);
|
||||
|
||||
expr_ref result (mk_c(c)->m ());
|
||||
result = mk_and (lits);
|
||||
mk_c(c)->save_ast_trail (result.get ());
|
||||
|
||||
return of_expr (result.get ());
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_qe_lite (Z3_context c, Z3_ast_vector vars, Z3_ast body)
|
||||
{
|
||||
Z3_TRY;
|
||||
LOG_Z3_qe_lite (c, vars, body);
|
||||
RESET_ERROR_CODE();
|
||||
ast_ref_vector &vVars = to_ast_vector_ref (vars);
|
||||
|
||||
app_ref_vector vApps (mk_c(c)->m());
|
||||
for (unsigned i = 0; i < vVars.size (); ++i) {
|
||||
app *a = to_app (vVars.get (i));
|
||||
if (a->get_kind () != AST_APP) {
|
||||
SET_ERROR_CODE (Z3_INVALID_ARG);
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
vApps.push_back (a);
|
||||
}
|
||||
|
||||
expr_ref result (mk_c(c)->m ());
|
||||
result = to_expr (body);
|
||||
|
||||
params_ref p;
|
||||
qe_lite qe (mk_c(c)->m (), p);
|
||||
qe (vApps, result);
|
||||
|
||||
// -- copy back variables that were not eliminated
|
||||
if (vApps.size () < vVars.size ()) {
|
||||
vVars.reset ();
|
||||
for (app* v : vApps) {
|
||||
vVars.push_back (v);
|
||||
}
|
||||
}
|
||||
|
||||
mk_c(c)->save_ast_trail (result.get ());
|
||||
return of_expr (result);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,12 +15,12 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"pattern_validation.h"
|
||||
#include"expr_abstract.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "parsers/util/pattern_validation.h"
|
||||
#include "ast/expr_abstract.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ Notes:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"realclosure.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "math/realclosure/realclosure.h"
|
||||
|
||||
static rcmanager & rcfm(Z3_context c) {
|
||||
return mk_c(c)->rcfm();
|
||||
|
|
|
@ -16,11 +16,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"ast_pp.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_util.h"
|
||||
#include "ast/ast_pp.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -17,22 +17,22 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#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"smt_logics.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_tactic.h"
|
||||
#include "api/api_solver.h"
|
||||
#include "api/api_model.h"
|
||||
#include "api/api_stats.h"
|
||||
#include "api/api_ast_vector.h"
|
||||
#include "solver/tactic2solver.h"
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
#include "tactic/portfolio/smt_strategic_solver.h"
|
||||
#include "smt/smt_solver.h"
|
||||
#include "smt/smt_implied_equalities.h"
|
||||
#include "solver/smt_logics.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -306,10 +306,14 @@ extern "C" {
|
|||
result = to_solver_ref(s)->check_sat(num_assumptions, _assumptions);
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
to_solver_ref(s)->set_reason_unknown(eh);
|
||||
mk_c(c)->handle_exception(ex);
|
||||
return Z3_L_UNDEF;
|
||||
}
|
||||
}
|
||||
if (result == l_undef) {
|
||||
to_solver_ref(s)->set_reason_unknown(eh);
|
||||
}
|
||||
return static_cast<Z3_lbool>(result);
|
||||
}
|
||||
|
||||
|
@ -476,10 +480,14 @@ extern "C" {
|
|||
result = to_solver_ref(s)->get_consequences(_assumptions, _variables, _consequences);
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
to_solver_ref(s)->set_reason_unknown(eh);
|
||||
mk_c(c)->handle_exception(ex);
|
||||
return Z3_L_UNDEF;
|
||||
}
|
||||
}
|
||||
if (result == l_undef) {
|
||||
to_solver_ref(s)->set_reason_unknown(eh);
|
||||
}
|
||||
for (unsigned i = 0; i < _consequences.size(); ++i) {
|
||||
to_ast_vector_ref(consequences).push_back(_consequences[i].get());
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_SOLVER_H_
|
||||
#define API_SOLVER_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"solver.h"
|
||||
#include "api/api_util.h"
|
||||
#include "solver/solver.h"
|
||||
|
||||
struct Z3_solver_ref : public api::object {
|
||||
scoped_ptr<solver_factory> m_solver_factory;
|
||||
|
|
|
@ -16,10 +16,10 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_stats.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_stats.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_STATS_H_
|
||||
#define API_STATS_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"statistics.h"
|
||||
#include "api/api_util.h"
|
||||
#include "util/statistics.h"
|
||||
|
||||
struct Z3_stats_ref : public api::object {
|
||||
statistics m_stats;
|
||||
|
|
|
@ -16,14 +16,14 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_tactic.h"
|
||||
#include"api_model.h"
|
||||
#include"scoped_ctrl_c.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include "api/z3.h"
|
||||
#include "api/api_log_macros.h"
|
||||
#include "api/api_context.h"
|
||||
#include "api/api_tactic.h"
|
||||
#include "api/api_model.h"
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
#include "util/cancel_eh.h"
|
||||
#include "util/scoped_timer.h"
|
||||
|
||||
Z3_apply_result_ref::Z3_apply_result_ref(api::context& c, ast_manager & m): api::object(c), m_core(m) {
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
#ifndef API_TACTIC_H_
|
||||
#define API_TACTIC_H_
|
||||
|
||||
#include"api_goal.h"
|
||||
#include"tactical.h"
|
||||
#include "api/api_goal.h"
|
||||
#include "tactic/tactical.h"
|
||||
|
||||
namespace api {
|
||||
class context;
|
||||
|
|
|
@ -18,9 +18,9 @@ Revision History:
|
|||
#ifndef API_UTIL_H_
|
||||
#define API_UTIL_H_
|
||||
|
||||
#include"params.h"
|
||||
#include"lbool.h"
|
||||
#include"ast.h"
|
||||
#include "util/params.h"
|
||||
#include "util/lbool.h"
|
||||
#include "ast/ast.h"
|
||||
|
||||
#define Z3_TRY try {
|
||||
#define Z3_CATCH_CORE(CODE) } catch (z3_exception & ex) { mk_c(c)->handle_exception(ex); CODE }
|
||||
|
|
|
@ -1731,6 +1731,14 @@ namespace z3 {
|
|||
expr else_value() const { Z3_ast r = Z3_func_interp_get_else(ctx(), m_interp); check_error(); return expr(ctx(), r); }
|
||||
unsigned num_entries() const { unsigned r = Z3_func_interp_get_num_entries(ctx(), m_interp); check_error(); return r; }
|
||||
func_entry entry(unsigned i) const { Z3_func_entry e = Z3_func_interp_get_entry(ctx(), m_interp, i); check_error(); return func_entry(ctx(), e); }
|
||||
void add_entry(expr_vector const& args, expr& value) {
|
||||
Z3_func_interp_add_entry(ctx(), m_interp, args, value);
|
||||
check_error();
|
||||
}
|
||||
void set_else(expr& value) {
|
||||
Z3_func_interp_set_else(ctx(), m_interp, value);
|
||||
check_error();
|
||||
}
|
||||
};
|
||||
|
||||
class model : public object {
|
||||
|
@ -1740,6 +1748,7 @@ namespace z3 {
|
|||
Z3_model_inc_ref(ctx(), m);
|
||||
}
|
||||
public:
|
||||
model(context & c):object(c) { init(Z3_mk_model(c)); }
|
||||
model(context & c, Z3_model m):object(c) { init(m); }
|
||||
model(model const & s):object(s) { init(s.m_model); }
|
||||
~model() { Z3_model_dec_ref(ctx(), m_model); }
|
||||
|
@ -1795,6 +1804,17 @@ namespace z3 {
|
|||
return 0 != Z3_model_has_interp(ctx(), m_model, f);
|
||||
}
|
||||
|
||||
func_interp add_func_interp(func_decl& f, expr& else_val) {
|
||||
Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);
|
||||
check_error();
|
||||
return func_interp(ctx(), r);
|
||||
}
|
||||
|
||||
void add_const_interp(func_decl& f, expr& value) {
|
||||
Z3_add_const_interp(ctx(), m_model, f, value);
|
||||
check_error();
|
||||
}
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & out, model const & m);
|
||||
};
|
||||
inline std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }
|
||||
|
|
|
@ -298,6 +298,24 @@ public class Optimize extends Z3Object {
|
|||
return Native.optimizeToString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an SMT-LIB2 file with optimization objectives and constraints.
|
||||
* The parsed constraints and objectives are added to the optimization context.
|
||||
*/
|
||||
public void fromFile(String file)
|
||||
{
|
||||
Native.optimizeFromFile(getContext().nCtx(), getNativeObject(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to FromFile. Instead it takes as argument a string.
|
||||
*/
|
||||
public void fromString(String s)
|
||||
{
|
||||
Native.optimizeFromString(getContext().nCtx(), getNativeObject(), s);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Optimize statistics.
|
||||
**/
|
||||
|
|
|
@ -1215,6 +1215,44 @@ struct
|
|||
let mk_numeral ctx v size = Z3native.mk_numeral ctx v (mk_sort ctx size)
|
||||
end
|
||||
|
||||
module Seq =
|
||||
struct
|
||||
let mk_seq_sort = Z3native.mk_seq_sort
|
||||
let is_seq_sort = Z3native.is_seq_sort
|
||||
let mk_re_sort = Z3native.mk_re_sort
|
||||
let is_re_sort = Z3native.is_re_sort
|
||||
let mk_string_sort = Z3native.mk_string_sort
|
||||
let is_string_sort = Z3native.is_string_sort
|
||||
let mk_string = Z3native.mk_string
|
||||
let is_string = Z3native.is_string
|
||||
let get_string = Z3native.get_string
|
||||
let mk_seq_empty = Z3native.mk_seq_empty
|
||||
let mk_seq_unit = Z3native.mk_seq_unit
|
||||
let mk_seq_concat ctx args = Z3native.mk_seq_concat ctx (List.length args) args
|
||||
let mk_seq_prefix = Z3native.mk_seq_prefix
|
||||
let mk_seq_suffix = Z3native.mk_seq_suffix
|
||||
let mk_seq_contains = Z3native.mk_seq_contains
|
||||
let mk_seq_extract = Z3native.mk_seq_extract
|
||||
let mk_seq_replace = Z3native.mk_seq_replace
|
||||
let mk_seq_at = Z3native.mk_seq_at
|
||||
let mk_seq_length = Z3native.mk_seq_length
|
||||
let mk_seq_index = Z3native.mk_seq_index
|
||||
let mk_str_to_int = Z3native.mk_str_to_int
|
||||
let mk_int_to_str = Z3native.mk_int_to_str
|
||||
let mk_seq_to_re = Z3native.mk_seq_to_re
|
||||
let mk_seq_in_re = Z3native.mk_seq_in_re
|
||||
let mk_re_plus = Z3native.mk_re_plus
|
||||
let mk_re_star = Z3native.mk_re_star
|
||||
let mk_re_option = Z3native.mk_re_option
|
||||
let mk_re_union ctx args = Z3native.mk_re_union ctx (List.length args) args
|
||||
let mk_re_concat ctx args = Z3native.mk_re_concat ctx (List.length args) args
|
||||
let mk_re_range = Z3native.mk_re_range
|
||||
let mk_re_loop = Z3native.mk_re_loop
|
||||
let mk_re_intersect = Z3native.mk_re_intersect
|
||||
let mk_re_complement = Z3native.mk_re_complement
|
||||
let mk_re_empty = Z3native.mk_re_empty
|
||||
let mk_re_full = Z3native.mk_re_full
|
||||
end
|
||||
|
||||
module FloatingPoint =
|
||||
struct
|
||||
|
@ -1926,7 +1964,7 @@ struct
|
|||
let from_file (x:optimize) (s:string) = Z3native.optimize_from_file (gc x) x s
|
||||
let from_string (x:optimize) (s:string) = Z3native.optimize_from_string (gc x) x s
|
||||
let get_assertions (x:optimize) = AST.ASTVector.to_expr_list (Z3native.optimize_get_assertions (gc x) x)
|
||||
let get_objectives (x:optimize) = AST.ASTVector.to_expr_list (Z3native.optimize_get_statistics (gc x) x)
|
||||
let get_objectives (x:optimize) = AST.ASTVector.to_expr_list (Z3native.optimize_get_objectives (gc x) x)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1825,6 +1825,116 @@ sig
|
|||
val mk_numeral : context -> string -> int -> Expr.expr
|
||||
end
|
||||
|
||||
(** Sequences, Strings and Regular Expressions **)
|
||||
module Seq :
|
||||
sig
|
||||
(* create a sequence sort *)
|
||||
val mk_seq_sort : context -> Sort.sort -> Sort.sort
|
||||
|
||||
(* test if sort is a sequence sort *)
|
||||
val is_seq_sort : context -> Sort.sort -> bool
|
||||
|
||||
(* create regular expression sorts over sequences of the argument sort *)
|
||||
val mk_re_sort : context -> Sort.sort -> Sort.sort
|
||||
|
||||
(* test if sort is a regular expression sort *)
|
||||
val is_re_sort : context -> Sort.sort -> bool
|
||||
|
||||
(* create string sort *)
|
||||
val mk_string_sort : context -> Sort.sort
|
||||
|
||||
(* test if sort is a string sort (a sequence of 8-bit bit-vectors) *)
|
||||
val is_string_sort : context -> Sort.sort -> bool
|
||||
|
||||
(* create a string literal *)
|
||||
val mk_string : context -> string -> Expr.expr
|
||||
|
||||
(* test if expression is a string *)
|
||||
val is_string : context -> Expr.expr -> bool
|
||||
|
||||
(* retrieve string from string Expr.expr *)
|
||||
val get_string : context -> Expr.expr -> string
|
||||
|
||||
(* the empty sequence over base sort *)
|
||||
val mk_seq_empty : context -> Sort.sort -> Expr.expr
|
||||
|
||||
(* a unit sequence *)
|
||||
val mk_seq_unit : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* sequence concatenation *)
|
||||
val mk_seq_concat : context -> Expr.expr list -> Expr.expr
|
||||
|
||||
(* predicate if the first argument is a prefix of the second *)
|
||||
val mk_seq_prefix : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* predicate if the first argument is a suffix of the second *)
|
||||
val mk_seq_suffix : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* predicate if the first argument contains the second *)
|
||||
val mk_seq_contains : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* extract sub-sequence starting at index given by second argument and of length provided by third argument *)
|
||||
val mk_seq_extract : context -> Expr.expr -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* replace first occurrence of second argument by third *)
|
||||
val mk_seq_replace : context -> Expr.expr -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* a unit sequence at index provided by second argument *)
|
||||
val mk_seq_at : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* length of a sequence *)
|
||||
val mk_seq_length : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* index of the first occurrence of the second argument in the first *)
|
||||
val mk_seq_index : context -> Expr.expr -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* retrieve integer expression encoded in string *)
|
||||
val mk_str_to_int : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* convert an integer expression to a string *)
|
||||
val mk_int_to_str : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* create regular expression that accepts the argument sequence *)
|
||||
val mk_seq_to_re : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* regular expression membership predicate *)
|
||||
val mk_seq_in_re : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* regular expression plus *)
|
||||
val mk_re_plus : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* regular expression star *)
|
||||
val mk_re_star : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* optional regular expression *)
|
||||
val mk_re_option : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* union of regular expressions *)
|
||||
val mk_re_union : context -> Expr.expr list -> Expr.expr
|
||||
|
||||
(* concatenation of regular expressions *)
|
||||
val mk_re_concat : context -> Expr.expr list -> Expr.expr
|
||||
|
||||
(* regular expression for the range between two characters *)
|
||||
val mk_re_range : context -> Expr.expr -> Expr.expr -> Expr.expr
|
||||
|
||||
(* bounded loop regular expression *)
|
||||
val mk_re_loop : context -> Expr.expr -> int -> int -> Expr.expr
|
||||
|
||||
(* intersection of regular expressions *)
|
||||
val mk_re_intersect : context -> int -> Expr.expr list -> Expr.expr
|
||||
|
||||
(* the regular expression complement *)
|
||||
val mk_re_complement : context -> Expr.expr -> Expr.expr
|
||||
|
||||
(* the regular expression that accepts no sequences *)
|
||||
val mk_re_empty : context -> Sort.sort -> Expr.expr
|
||||
|
||||
(* the regular expression that accepts all sequences *)
|
||||
val mk_re_full : context -> Sort.sort -> Expr.expr
|
||||
|
||||
end
|
||||
|
||||
(** Floating-Point Arithmetic *)
|
||||
module FloatingPoint :
|
||||
sig
|
||||
|
|
|
@ -34,6 +34,9 @@ extern "C" {
|
|||
CAMLlocal5(X1,X2,X3,X4,X5); \
|
||||
CAMLlocal3(X6,X7,X8)
|
||||
|
||||
#define CAMLparam6(X1,X2,X3,X4,X5,X6) \
|
||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||
CAMLxparam1(X6)
|
||||
#define CAMLparam7(X1,X2,X3,X4,X5,X6,X7) \
|
||||
CAMLparam5(X1,X2,X3,X4,X5); \
|
||||
CAMLxparam2(X6,X7)
|
||||
|
|
|
@ -6551,6 +6551,22 @@ class Fixedpoint(Z3PPObject):
|
|||
r = Z3_fixedpoint_query(self.ctx.ref(), self.fixedpoint, query.as_ast())
|
||||
return CheckSatResult(r)
|
||||
|
||||
def query_from_lvl (self, lvl, *query):
|
||||
"""Query the fixedpoint engine whether formula is derivable starting at the given query level.
|
||||
"""
|
||||
query = _get_args(query)
|
||||
sz = len(query)
|
||||
if sz >= 1 and isinstance(query[0], FuncDecl):
|
||||
_z3_assert (False, "unsupported")
|
||||
else:
|
||||
if sz == 1:
|
||||
query = query[0]
|
||||
else:
|
||||
query = And(query)
|
||||
query = self.abstract(query, False)
|
||||
r = Z3_fixedpoint_query_from_lvl (self.ctx.ref(), self.fixedpoint, query.as_ast(), lvl)
|
||||
return CheckSatResult(r)
|
||||
|
||||
def push(self):
|
||||
"""create a backtracking point for added rules, facts and assertions"""
|
||||
Z3_fixedpoint_push(self.ctx.ref(), self.fixedpoint)
|
||||
|
@ -6573,6 +6589,23 @@ class Fixedpoint(Z3PPObject):
|
|||
r = Z3_fixedpoint_get_answer(self.ctx.ref(), self.fixedpoint)
|
||||
return _to_expr_ref(r, self.ctx)
|
||||
|
||||
def get_ground_sat_answer(self):
|
||||
"""Retrieve a ground cex from last query call."""
|
||||
r = Z3_fixedpoint_get_ground_sat_answer(self.ctx.ref(), self.fixedpoint)
|
||||
return _to_expr_ref(r, self.ctx)
|
||||
|
||||
def get_rules_along_trace(self):
|
||||
"""retrieve rules along the counterexample trace"""
|
||||
return AstVector(Z3_fixedpoint_get_rules_along_trace(self.ctx.ref(), self.fixedpoint), self.ctx)
|
||||
|
||||
def get_rule_names_along_trace(self):
|
||||
"""retrieve rule names along the counterexample trace"""
|
||||
# this is a hack as I don't know how to return a list of symbols from C++;
|
||||
# obtain names as a single string separated by semicolons
|
||||
names = _symbol2py (self.ctx, Z3_fixedpoint_get_rule_names_along_trace(self.ctx.ref(), self.fixedpoint))
|
||||
# split into individual names
|
||||
return names.split (';')
|
||||
|
||||
def get_num_levels(self, predicate):
|
||||
"""Retrieve number of levels used for predicate in PDR engine"""
|
||||
return Z3_fixedpoint_get_num_levels(self.ctx.ref(), self.fixedpoint, predicate.ast)
|
||||
|
@ -8167,9 +8200,9 @@ def sequence_interpolant(v,p=None,ctx=None):
|
|||
If parameters p are supplied, these are used in creating the
|
||||
solver that determines satisfiability.
|
||||
|
||||
>>> x = Int('x')
|
||||
>>> y = Int('y')
|
||||
>>> print(sequence_interpolant([x < 0, y == x , y > 2]))
|
||||
x = Int('x')
|
||||
y = Int('y')
|
||||
print(sequence_interpolant([x < 0, y == x , y > 2]))
|
||||
[Not(x >= 0), Not(y >= 0)]
|
||||
"""
|
||||
f = v[0]
|
||||
|
|
22
src/api/z3.h
22
src/api/z3.h
|
@ -22,16 +22,16 @@ Notes:
|
|||
#define Z3_H_
|
||||
|
||||
#include<stdio.h>
|
||||
#include"z3_macros.h"
|
||||
#include"z3_api.h"
|
||||
#include"z3_ast_containers.h"
|
||||
#include"z3_algebraic.h"
|
||||
#include"z3_polynomial.h"
|
||||
#include"z3_rcf.h"
|
||||
#include"z3_fixedpoint.h"
|
||||
#include"z3_optimization.h"
|
||||
#include"z3_interp.h"
|
||||
#include"z3_fpa.h"
|
||||
|
||||
#include "z3_macros.h"
|
||||
#include "z3_api.h"
|
||||
#include "z3_ast_containers.h"
|
||||
#include "z3_algebraic.h"
|
||||
#include "z3_polynomial.h"
|
||||
#include "z3_rcf.h"
|
||||
#include "z3_fixedpoint.h"
|
||||
#include "z3_optimization.h"
|
||||
#include "z3_interp.h"
|
||||
#include "z3_fpa.h"
|
||||
#include "z3_spacer.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1530,7 +1530,7 @@ extern "C" {
|
|||
In contrast to #Z3_mk_context_rc, the life time of Z3_ast objects
|
||||
are determined by the scope level of #Z3_solver_push and #Z3_solver_pop.
|
||||
In other words, a Z3_ast object remains valid until there is a
|
||||
call to Z3_pop that takes the current scope below the level where
|
||||
call to Z3_solver_pop that takes the current scope below the level where
|
||||
the object was created.
|
||||
|
||||
Note that all other reference counted objects, including Z3_model,
|
||||
|
@ -4680,6 +4680,14 @@ extern "C" {
|
|||
|
||||
/** @name Models */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
\brief Create a fresh model object. It has reference count 0.
|
||||
|
||||
def_API('Z3_mk_model', MODEL, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_model Z3_API Z3_mk_model(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Increment the reference counter of the given model.
|
||||
|
||||
|
@ -4850,6 +4858,26 @@ extern "C" {
|
|||
*/
|
||||
Z3_func_decl Z3_API Z3_get_as_array_func_decl(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Create a fresh func_interp object, add it to a model for a specified function.
|
||||
It has reference count 0.
|
||||
|
||||
\param c context
|
||||
\param m model
|
||||
\param f function declaration
|
||||
\param default_value default value for function interpretation
|
||||
|
||||
def_API('Z3_add_func_interp', FUNC_INTERP, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL), _in(AST)))
|
||||
*/
|
||||
Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast default_value);
|
||||
|
||||
/**
|
||||
\brief Add a constant interpretation.
|
||||
|
||||
def_API('Z3_add_const_interp', VOID, (_in(CONTEXT), _in(MODEL), _in(FUNC_DECL), _in(AST)))
|
||||
*/
|
||||
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Increment the reference counter of the given Z3_func_interp object.
|
||||
|
||||
|
@ -4897,6 +4925,16 @@ extern "C" {
|
|||
*/
|
||||
Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f);
|
||||
|
||||
/**
|
||||
\brief Return the 'else' value of the given function interpretation.
|
||||
|
||||
A function interpretation is represented as a finite map and an 'else' value.
|
||||
This procedure can be used to update the 'else' value.
|
||||
|
||||
def_API('Z3_func_interp_set_else', VOID, (_in(CONTEXT), _in(FUNC_INTERP), _in(AST)))
|
||||
*/
|
||||
void Z3_API Z3_func_interp_set_else(Z3_context c, Z3_func_interp f, Z3_ast else_value);
|
||||
|
||||
/**
|
||||
\brief Return the arity (number of arguments) of the given function interpretation.
|
||||
|
||||
|
@ -4904,6 +4942,22 @@ extern "C" {
|
|||
*/
|
||||
unsigned Z3_API Z3_func_interp_get_arity(Z3_context c, Z3_func_interp f);
|
||||
|
||||
/**
|
||||
\brief add a function entry to a function interpretation.
|
||||
|
||||
\param c logical context
|
||||
\param fi a function interpregation to be updated.
|
||||
\param args list of arguments. They should be constant values (such as integers) and be of the same types as the domain of the function.
|
||||
\param value value of the function when the parameters match args.
|
||||
|
||||
It is assumed that entries added to a function cover disjoint arguments.
|
||||
If an two entries are added with the same arguments, only the second insertion survives and the
|
||||
first inserted entry is removed.
|
||||
|
||||
def_API('Z3_func_interp_add_entry', VOID, (_in(CONTEXT), _in(FUNC_INTERP), _in(AST_VECTOR), _in(AST)))
|
||||
*/
|
||||
void Z3_API Z3_func_interp_add_entry(Z3_context c, Z3_func_interp fi, Z3_ast_vector args, Z3_ast value);
|
||||
|
||||
/**
|
||||
\brief Increment the reference counter of the given Z3_func_entry object.
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Notes:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"symbol.h"
|
||||
#include "util/symbol.h"
|
||||
struct ll_escaped { char const * m_str; ll_escaped(char const * str):m_str(str) {} };
|
||||
static std::ostream & operator<<(std::ostream & out, ll_escaped const & d);
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ Notes:
|
|||
--*/
|
||||
|
||||
#include<iostream>
|
||||
#include"rational.h"
|
||||
#include"z3_macros.h"
|
||||
#include "util/rational.h"
|
||||
#include "api/z3_macros.h"
|
||||
|
||||
#ifndef Z3_PRIVATE_H_
|
||||
#define Z3_PRIVATE_H_
|
||||
|
|
|
@ -16,12 +16,12 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include"vector.h"
|
||||
#include"map.h"
|
||||
#include"z3_replayer.h"
|
||||
#include"stream_buffer.h"
|
||||
#include"symbol.h"
|
||||
#include"trace.h"
|
||||
#include "util/vector.h"
|
||||
#include "util/map.h"
|
||||
#include "api/z3_replayer.h"
|
||||
#include "util/stream_buffer.h"
|
||||
#include "util/symbol.h"
|
||||
#include "util/trace.h"
|
||||
#include<sstream>
|
||||
#include<vector>
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ Notes:
|
|||
#define Z3_REPLAYER_H_
|
||||
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"z3_exception.h"
|
||||
#include "api/z3.h"
|
||||
#include "util/z3_exception.h"
|
||||
|
||||
class z3_replayer;
|
||||
|
||||
|
|
143
src/api/z3_spacer.h
Normal file
143
src/api/z3_spacer.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*++
|
||||
Copyright (c) 2017 Arie Gurfinkel
|
||||
|
||||
Module Name:
|
||||
|
||||
z3_spacer.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Spacer API
|
||||
|
||||
Author:
|
||||
|
||||
Arie Gurfinkel (arie)
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef Z3_SPACER_H_
|
||||
#define Z3_SPACER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/** \defgroup capi C API */
|
||||
/*@{*/
|
||||
|
||||
/** @name Spacer facilities */
|
||||
/*@{*/
|
||||
/**
|
||||
\brief Pose a query against the asserted rules at the given level.
|
||||
|
||||
\code
|
||||
query ::= (exists (bound-vars) query)
|
||||
| literals
|
||||
\endcode
|
||||
|
||||
query returns
|
||||
- Z3_L_FALSE if the query is unsatisfiable.
|
||||
- Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
|
||||
- Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
|
||||
|
||||
def_API('Z3_fixedpoint_query_from_lvl', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST), _in(UINT)))
|
||||
*/
|
||||
Z3_lbool Z3_API Z3_fixedpoint_query_from_lvl (Z3_context c,Z3_fixedpoint d, Z3_ast query, unsigned lvl);
|
||||
|
||||
/**
|
||||
\brief Retrieve a bottom-up (from query) sequence of ground facts
|
||||
|
||||
The previous call to Z3_fixedpoint_query must have returned Z3_L_TRUE.
|
||||
|
||||
def_API('Z3_fixedpoint_get_ground_sat_answer', AST, (_in(CONTEXT), _in(FIXEDPOINT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_fixedpoint_get_ground_sat_answer(Z3_context c,Z3_fixedpoint d);
|
||||
|
||||
/**
|
||||
\brief Obtain the list of rules along the counterexample trace.
|
||||
|
||||
def_API('Z3_fixedpoint_get_rules_along_trace', AST_VECTOR, (_in(CONTEXT), _in(FIXEDPOINT)))
|
||||
*/
|
||||
Z3_ast_vector Z3_API Z3_fixedpoint_get_rules_along_trace(Z3_context c,Z3_fixedpoint d);
|
||||
|
||||
/**
|
||||
\brief Obtain the list of rules along the counterexample trace.
|
||||
|
||||
def_API('Z3_fixedpoint_get_rule_names_along_trace', SYMBOL, (_in(CONTEXT), _in(FIXEDPOINT)))
|
||||
*/
|
||||
Z3_symbol Z3_API Z3_fixedpoint_get_rule_names_along_trace(Z3_context c,Z3_fixedpoint d);
|
||||
|
||||
/**
|
||||
\brief Add an invariant for the predicate \c pred.
|
||||
Add an assumed invariant of predicate \c pred.
|
||||
|
||||
Note: this functionality is Spacer specific.
|
||||
|
||||
def_API('Z3_fixedpoint_add_invariant', VOID, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL), _in(AST)))
|
||||
*/
|
||||
void Z3_API Z3_fixedpoint_add_invariant(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred, Z3_ast property);
|
||||
|
||||
|
||||
/**
|
||||
Retrieve reachable states of a predicate.
|
||||
Note: this functionality is Spacer specific.
|
||||
|
||||
def_API('Z3_fixedpoint_get_reachable', AST, (_in(CONTEXT), _in(FIXEDPOINT), _in(FUNC_DECL)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_fixedpoint_get_reachable(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred);
|
||||
|
||||
/**
|
||||
\brief Project variables given a model
|
||||
|
||||
def_API('Z3_qe_model_project', AST, (_in(CONTEXT), _in(MODEL), _in(UINT), _in_array(2, APP), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_qe_model_project
|
||||
(Z3_context c,
|
||||
Z3_model m,
|
||||
unsigned num_bounds,
|
||||
Z3_app const bound[],
|
||||
Z3_ast body);
|
||||
|
||||
|
||||
/**
|
||||
\brief Project variables given a model
|
||||
|
||||
def_API('Z3_qe_model_project_skolem', AST, (_in(CONTEXT), _in(MODEL), _in(UINT), _in_array(2, APP), _in(AST), _in(AST_MAP)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_qe_model_project_skolem
|
||||
(Z3_context c,
|
||||
Z3_model m,
|
||||
unsigned num_bounds,
|
||||
Z3_app const bound[],
|
||||
Z3_ast body,
|
||||
Z3_ast_map map);
|
||||
|
||||
/**
|
||||
\brief Extrapolates a model of a formula
|
||||
|
||||
def_API('Z3_model_extrapolate', AST, (_in(CONTEXT), _in(MODEL), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_model_extrapolate
|
||||
(Z3_context c,
|
||||
Z3_model m,
|
||||
Z3_ast fml);
|
||||
|
||||
/**
|
||||
\brief Best-effort quantifier elimination
|
||||
|
||||
def_API ('Z3_qe_lite', AST, (_in(CONTEXT), _in(AST_VECTOR), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_qe_lite
|
||||
(Z3_context c,
|
||||
Z3_ast_vector vars,
|
||||
Z3_ast body);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
|
@ -21,7 +21,7 @@ Notes:
|
|||
#ifndef Z3_V1_H_
|
||||
#define Z3_V1_H_
|
||||
|
||||
#include"z3.h"
|
||||
#include "api/z3.h"
|
||||
|
||||
// Backwards compatibility
|
||||
#define Z3_type_ast Z3_sort
|
||||
|
|
|
@ -23,6 +23,7 @@ z3_add_component(ast
|
|||
expr_map.cpp
|
||||
expr_stat.cpp
|
||||
expr_substitution.cpp
|
||||
factor_equivs.cpp
|
||||
for_each_ast.cpp
|
||||
for_each_expr.cpp
|
||||
format.cpp
|
||||
|
|
|
@ -17,7 +17,7 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#include"act_cache.h"
|
||||
#include "ast/act_cache.h"
|
||||
|
||||
#define MIN_MAX_UNUSED 1024
|
||||
#define INITIAL_CAPACITY 128
|
||||
|
|
|
@ -20,9 +20,9 @@ Notes:
|
|||
#ifndef ACT_CACHE_H_
|
||||
#define ACT_CACHE_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"obj_hashtable.h"
|
||||
#include"chashtable.h"
|
||||
#include "ast/ast.h"
|
||||
#include "util/obj_hashtable.h"
|
||||
#include "util/chashtable.h"
|
||||
|
||||
class act_cache {
|
||||
ast_manager & m_manager;
|
||||
|
|
|
@ -16,11 +16,11 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"arith_decl_plugin.h"
|
||||
#include"warning.h"
|
||||
#include"algebraic_numbers.h"
|
||||
#include"id_gen.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
#include "util/warning.h"
|
||||
#include "math/polynomial/algebraic_numbers.h"
|
||||
#include "util/id_gen.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
|
||||
struct arith_decl_plugin::algebraic_numbers_wrapper {
|
||||
unsynch_mpq_manager m_qmanager;
|
||||
|
@ -81,8 +81,9 @@ app * arith_decl_plugin::mk_numeral(algebraic_numbers::anum const & val, bool is
|
|||
return mk_numeral(rval, is_int);
|
||||
}
|
||||
else {
|
||||
if (is_int)
|
||||
if (is_int) {
|
||||
m_manager->raise_exception("invalid irrational value passed as an integer");
|
||||
}
|
||||
unsigned idx = aw().mk_id(val);
|
||||
parameter p(idx, true);
|
||||
SASSERT(p.is_external());
|
||||
|
@ -214,18 +215,8 @@ void arith_decl_plugin::set_manager(ast_manager * m, family_id id) {
|
|||
m_e = m->mk_const(e_decl);
|
||||
m->inc_ref(m_e);
|
||||
|
||||
func_decl * z_pw_z_int = m->mk_const_decl(symbol("0^0-int"), i, func_decl_info(id, OP_0_PW_0_INT));
|
||||
m_0_pw_0_int = m->mk_const(z_pw_z_int);
|
||||
m->inc_ref(m_0_pw_0_int);
|
||||
|
||||
func_decl * z_pw_z_real = m->mk_const_decl(symbol("0^0-real"), r, func_decl_info(id, OP_0_PW_0_REAL));
|
||||
m_0_pw_0_real = m->mk_const(z_pw_z_real);
|
||||
m->inc_ref(m_0_pw_0_real);
|
||||
|
||||
MK_OP(m_neg_root_decl, "neg-root", OP_NEG_ROOT, r);
|
||||
MK_UNARY(m_div_0_decl, "/0", OP_DIV_0, r);
|
||||
MK_UNARY(m_idiv_0_decl, "div0", OP_IDIV_0, i);
|
||||
MK_UNARY(m_mod_0_decl, "mod0", OP_MOD_0, i);
|
||||
MK_UNARY(m_u_asin_decl, "asin-u", OP_U_ASIN, r);
|
||||
MK_UNARY(m_u_acos_decl, "acos-u", OP_U_ACOS, r);
|
||||
}
|
||||
|
@ -278,12 +269,7 @@ arith_decl_plugin::arith_decl_plugin():
|
|||
m_atanh_decl(0),
|
||||
m_pi(0),
|
||||
m_e(0),
|
||||
m_0_pw_0_int(0),
|
||||
m_0_pw_0_real(0),
|
||||
m_neg_root_decl(0),
|
||||
m_div_0_decl(0),
|
||||
m_idiv_0_decl(0),
|
||||
m_mod_0_decl(0),
|
||||
m_u_asin_decl(0),
|
||||
m_u_acos_decl(0),
|
||||
m_convert_int_numerals_to_real(false) {
|
||||
|
@ -338,12 +324,7 @@ void arith_decl_plugin::finalize() {
|
|||
DEC_REF(m_atanh_decl);
|
||||
DEC_REF(m_pi);
|
||||
DEC_REF(m_e);
|
||||
DEC_REF(m_0_pw_0_int);
|
||||
DEC_REF(m_0_pw_0_real);
|
||||
DEC_REF(m_neg_root_decl);
|
||||
DEC_REF(m_div_0_decl);
|
||||
DEC_REF(m_idiv_0_decl);
|
||||
DEC_REF(m_mod_0_decl);
|
||||
DEC_REF(m_u_asin_decl);
|
||||
DEC_REF(m_u_acos_decl);
|
||||
m_manager->dec_array_ref(m_small_ints.size(), m_small_ints.c_ptr());
|
||||
|
@ -391,18 +372,24 @@ inline func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, bool is_real) {
|
|||
case OP_ATANH: return m_atanh_decl;
|
||||
case OP_PI: return m_pi->get_decl();
|
||||
case OP_E: return m_e->get_decl();
|
||||
case OP_0_PW_0_INT: return m_0_pw_0_int->get_decl();
|
||||
case OP_0_PW_0_REAL: return m_0_pw_0_real->get_decl();
|
||||
//case OP_0_PW_0_INT: return m_0_pw_0_int->get_decl();
|
||||
//case OP_0_PW_0_REAL: return m_0_pw_0_real->get_decl();
|
||||
case OP_NEG_ROOT: return m_neg_root_decl;
|
||||
case OP_DIV_0: return m_div_0_decl;
|
||||
case OP_IDIV_0: return m_idiv_0_decl;
|
||||
case OP_MOD_0: return m_mod_0_decl;
|
||||
//case OP_DIV_0: return m_div_0_decl;
|
||||
//case OP_IDIV_0: return m_idiv_0_decl;
|
||||
//case OP_MOD_0: return m_mod_0_decl;
|
||||
case OP_U_ASIN: return m_u_asin_decl;
|
||||
case OP_U_ACOS: return m_u_acos_decl;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void arith_decl_plugin::check_arity(unsigned arity, unsigned expected_arity) {
|
||||
if (arity != expected_arity) {
|
||||
m_manager->raise_exception("invalid number of arguments passed to function");
|
||||
}
|
||||
}
|
||||
|
||||
inline decl_kind arith_decl_plugin::fix_kind(decl_kind k, unsigned arity) {
|
||||
if (k == OP_SUB && arity == 1) {
|
||||
return OP_UMINUS;
|
||||
|
@ -482,9 +469,9 @@ static bool has_real_arg(ast_manager * m, unsigned num_args, expr * const * args
|
|||
static bool is_const_op(decl_kind k) {
|
||||
return
|
||||
k == OP_PI ||
|
||||
k == OP_E ||
|
||||
k == OP_0_PW_0_INT ||
|
||||
k == OP_0_PW_0_REAL;
|
||||
k == OP_E;
|
||||
//k == OP_0_PW_0_INT ||
|
||||
//k == OP_0_PW_0_REAL;
|
||||
}
|
||||
|
||||
func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
|
|
|
@ -19,7 +19,7 @@ Revision History:
|
|||
#ifndef ARITH_DECL_PLUGIN_H_
|
||||
#define ARITH_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include "ast/ast.h"
|
||||
class sexpr;
|
||||
|
||||
namespace algebraic_numbers {
|
||||
|
@ -70,12 +70,7 @@ enum arith_op_kind {
|
|||
OP_PI,
|
||||
OP_E,
|
||||
// under-specified symbols
|
||||
OP_0_PW_0_INT, // 0^0 for integers
|
||||
OP_0_PW_0_REAL, // 0^0 for reals
|
||||
OP_NEG_ROOT, // x^n when n is even and x is negative
|
||||
OP_DIV_0, // x/0
|
||||
OP_IDIV_0, // x div 0
|
||||
OP_MOD_0, // x mod 0
|
||||
OP_U_ASIN, // asin(x) for x < -1 or x > 1
|
||||
OP_U_ACOS, // acos(x) for x < -1 or x > 1
|
||||
LAST_ARITH_OP
|
||||
|
@ -141,12 +136,7 @@ protected:
|
|||
app * m_pi;
|
||||
app * m_e;
|
||||
|
||||
app * m_0_pw_0_int;
|
||||
app * m_0_pw_0_real;
|
||||
func_decl * m_neg_root_decl;
|
||||
func_decl * m_div_0_decl;
|
||||
func_decl * m_idiv_0_decl;
|
||||
func_decl * m_mod_0_decl;
|
||||
func_decl * m_u_asin_decl;
|
||||
func_decl * m_u_acos_decl;
|
||||
ptr_vector<app> m_small_ints;
|
||||
|
@ -157,6 +147,7 @@ protected:
|
|||
func_decl * mk_func_decl(decl_kind k, bool is_real);
|
||||
virtual void set_manager(ast_manager * m, family_id id);
|
||||
decl_kind fix_kind(decl_kind k, unsigned arity);
|
||||
void check_arity(unsigned arity, unsigned expected_arity);
|
||||
func_decl * mk_num_decl(unsigned num_parameters, parameter const * parameters, unsigned arity);
|
||||
|
||||
public:
|
||||
|
@ -206,10 +197,6 @@ public:
|
|||
|
||||
app * mk_e() const { return m_e; }
|
||||
|
||||
app * mk_0_pw_0_int() const { return m_0_pw_0_int; }
|
||||
|
||||
app * mk_0_pw_0_real() const { return m_0_pw_0_real; }
|
||||
|
||||
virtual expr * get_some_value(sort * s);
|
||||
|
||||
virtual bool is_considered_uninterpreted(func_decl * f) {
|
||||
|
@ -217,12 +204,7 @@ public:
|
|||
return false;
|
||||
switch (f->get_decl_kind())
|
||||
{
|
||||
case OP_0_PW_0_INT:
|
||||
case OP_0_PW_0_REAL:
|
||||
case OP_NEG_ROOT:
|
||||
case OP_DIV_0:
|
||||
case OP_IDIV_0:
|
||||
case OP_MOD_0:
|
||||
case OP_U_ASIN:
|
||||
case OP_U_ACOS:
|
||||
return true;
|
||||
|
@ -275,9 +257,9 @@ public:
|
|||
bool is_uminus(expr const * n) const { return is_app_of(n, m_afid, OP_UMINUS); }
|
||||
bool is_mul(expr const * n) const { return is_app_of(n, m_afid, OP_MUL); }
|
||||
bool is_div(expr const * n) const { return is_app_of(n, m_afid, OP_DIV); }
|
||||
bool is_div0(expr const * n) const { return is_app_of(n, m_afid, OP_DIV_0); }
|
||||
//bool is_div0(expr const * n) const { return is_app_of(n, m_afid, OP_DIV_0); }
|
||||
bool is_idiv(expr const * n) const { return is_app_of(n, m_afid, OP_IDIV); }
|
||||
bool is_idiv0(expr const * n) const { return is_app_of(n, m_afid, OP_IDIV_0); }
|
||||
//bool is_idiv0(expr const * n) const { return is_app_of(n, m_afid, OP_IDIV_0); }
|
||||
bool is_mod(expr const * n) const { return is_app_of(n, m_afid, OP_MOD); }
|
||||
bool is_rem(expr const * n) const { return is_app_of(n, m_afid, OP_REM); }
|
||||
bool is_to_real(expr const * n) const { return is_app_of(n, m_afid, OP_TO_REAL); }
|
||||
|
@ -388,16 +370,16 @@ public:
|
|||
app * mk_lt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_LT, arg1, arg2); }
|
||||
app * mk_gt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_GT, arg1, arg2); }
|
||||
|
||||
app * mk_add(unsigned num_args, expr * const * args) { return m_manager.mk_app(m_afid, OP_ADD, num_args, args); }
|
||||
app * mk_add(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2); }
|
||||
app * mk_add(expr * arg1, expr * arg2, expr* arg3) { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2, arg3); }
|
||||
app * mk_add(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_ADD, num_args, args); }
|
||||
app * mk_add(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2); }
|
||||
app * mk_add(expr * arg1, expr * arg2, expr* arg3) const { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2, arg3); }
|
||||
|
||||
app * mk_sub(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_SUB, arg1, arg2); }
|
||||
app * mk_sub(unsigned num_args, expr * const * args) { return m_manager.mk_app(m_afid, OP_SUB, num_args, args); }
|
||||
app * mk_mul(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2); }
|
||||
app * mk_mul(expr * arg1, expr * arg2, expr* arg3) { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2, arg3); }
|
||||
app * mk_mul(unsigned num_args, expr * const * args) { return m_manager.mk_app(m_afid, OP_MUL, num_args, args); }
|
||||
app * mk_uminus(expr * arg) { return m_manager.mk_app(m_afid, OP_UMINUS, arg); }
|
||||
app * mk_sub(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_SUB, arg1, arg2); }
|
||||
app * mk_sub(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_SUB, num_args, args); }
|
||||
app * mk_mul(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2); }
|
||||
app * mk_mul(expr * arg1, expr * arg2, expr* arg3) const { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2, arg3); }
|
||||
app * mk_mul(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_MUL, num_args, args); }
|
||||
app * mk_uminus(expr * arg) const { return m_manager.mk_app(m_afid, OP_UMINUS, arg); }
|
||||
app * mk_div(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_DIV, arg1, arg2); }
|
||||
app * mk_idiv(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_IDIV, arg1, arg2); }
|
||||
app * mk_rem(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_REM, arg1, arg2); }
|
||||
|
@ -424,11 +406,6 @@ public:
|
|||
app * mk_pi() { return plugin().mk_pi(); }
|
||||
app * mk_e() { return plugin().mk_e(); }
|
||||
|
||||
app * mk_0_pw_0_int() { return plugin().mk_0_pw_0_int(); }
|
||||
app * mk_0_pw_0_real() { return plugin().mk_0_pw_0_real(); }
|
||||
app * mk_div0(expr * arg) { return m_manager.mk_app(m_afid, OP_DIV_0, arg); }
|
||||
app * mk_idiv0(expr * arg) { return m_manager.mk_app(m_afid, OP_IDIV_0, arg); }
|
||||
app * mk_mod0(expr * arg) { return m_manager.mk_app(m_afid, OP_MOD_0, arg); }
|
||||
app * mk_neg_root(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_NEG_ROOT, arg1, arg2); }
|
||||
app * mk_u_asin(expr * arg) { return m_manager.mk_app(m_afid, OP_U_ASIN, arg); }
|
||||
app * mk_u_acos(expr * arg) { return m_manager.mk_app(m_afid, OP_U_ACOS, arg); }
|
||||
|
|
|
@ -17,10 +17,10 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<sstream>
|
||||
#include"array_decl_plugin.h"
|
||||
#include"warning.h"
|
||||
#include"ast_pp.h"
|
||||
#include"ast_ll_pp.h"
|
||||
#include "ast/array_decl_plugin.h"
|
||||
#include "util/warning.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
|
||||
array_decl_plugin::array_decl_plugin():
|
||||
m_store_sym("store"),
|
||||
|
@ -546,7 +546,7 @@ expr * array_decl_plugin::get_some_value(sort * s) {
|
|||
return m_manager->mk_app(m_family_id, OP_CONST_ARRAY, 1, &p, 1, &v);
|
||||
}
|
||||
|
||||
bool array_decl_plugin::is_fully_interp(sort const * s) const {
|
||||
bool array_decl_plugin::is_fully_interp(sort * s) const {
|
||||
SASSERT(s->is_sort_of(m_family_id, ARRAY_SORT));
|
||||
unsigned sz = get_array_arity(s);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -556,9 +556,9 @@ bool array_decl_plugin::is_fully_interp(sort const * s) const {
|
|||
return m_manager->is_fully_interp(get_array_range(s));
|
||||
}
|
||||
|
||||
func_decl * array_recognizers::get_as_array_func_decl(app * n) const {
|
||||
func_decl * array_recognizers::get_as_array_func_decl(expr * n) const {
|
||||
SASSERT(is_as_array(n));
|
||||
return to_func_decl(n->get_decl()->get_parameter(0).get_ast());
|
||||
return to_func_decl(to_app(n)->get_decl()->get_parameter(0).get_ast());
|
||||
}
|
||||
|
||||
array_util::array_util(ast_manager& m):
|
||||
|
|
|
@ -19,7 +19,7 @@ Revision History:
|
|||
#ifndef ARRAY_DECL_PLUGIN_H_
|
||||
#define ARRAY_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include "ast/ast.h"
|
||||
|
||||
|
||||
inline sort* get_array_range(sort const * s) {
|
||||
|
@ -127,7 +127,7 @@ class array_decl_plugin : public decl_plugin {
|
|||
|
||||
virtual expr * get_some_value(sort * s);
|
||||
|
||||
virtual bool is_fully_interp(sort const * s) const;
|
||||
virtual bool is_fully_interp(sort * s) const;
|
||||
};
|
||||
|
||||
class array_recognizers {
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
bool is_const(func_decl* f) const { return is_decl_of(f, m_fid, OP_CONST_ARRAY); }
|
||||
bool is_map(func_decl* f) const { return is_decl_of(f, m_fid, OP_ARRAY_MAP); }
|
||||
bool is_as_array(func_decl* f) const { return is_decl_of(f, m_fid, OP_AS_ARRAY); }
|
||||
func_decl * get_as_array_func_decl(app * n) const;
|
||||
func_decl * get_as_array_func_decl(expr * n) const;
|
||||
};
|
||||
|
||||
class array_util : public array_recognizers {
|
||||
|
|
116
src/ast/ast.cpp
116
src/ast/ast.cpp
|
@ -18,14 +18,14 @@ Revision History:
|
|||
--*/
|
||||
#include<sstream>
|
||||
#include<cstring>
|
||||
#include"ast.h"
|
||||
#include"ast_pp.h"
|
||||
#include"ast_ll_pp.h"
|
||||
#include"buffer.h"
|
||||
#include"warning.h"
|
||||
#include"string_buffer.h"
|
||||
#include"ast_util.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
#include "ast/ast.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/ast_ll_pp.h"
|
||||
#include "util/buffer.h"
|
||||
#include "util/warning.h"
|
||||
#include "util/string_buffer.h"
|
||||
#include "ast/ast_util.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
|
||||
// -----------------------------------
|
||||
//
|
||||
|
@ -35,7 +35,7 @@ Revision History:
|
|||
|
||||
parameter::~parameter() {
|
||||
if (m_kind == PARAM_RATIONAL) {
|
||||
reinterpret_cast<rational *>(m_rational)->~rational();
|
||||
dealloc(m_rational);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,14 @@ parameter& parameter::operator=(parameter const& other) {
|
|||
return *this;
|
||||
}
|
||||
if (m_kind == PARAM_RATIONAL) {
|
||||
reinterpret_cast<rational *>(m_rational)->~rational();
|
||||
dealloc(m_rational);
|
||||
}
|
||||
m_kind = other.m_kind;
|
||||
switch(other.m_kind) {
|
||||
case PARAM_INT: m_int = other.get_int(); break;
|
||||
case PARAM_AST: m_ast = other.get_ast(); break;
|
||||
case PARAM_SYMBOL: new (m_symbol) symbol(other.get_symbol()); break;
|
||||
case PARAM_RATIONAL: new (m_rational) rational(other.get_rational()); break;
|
||||
case PARAM_SYMBOL: m_symbol = other.m_symbol; break;
|
||||
case PARAM_RATIONAL: m_rational = alloc(rational, other.get_rational()); break;
|
||||
case PARAM_DOUBLE: m_dval = other.m_dval; break;
|
||||
case PARAM_EXTERNAL: m_ext_id = other.m_ext_id; break;
|
||||
default:
|
||||
|
@ -188,18 +188,14 @@ decl_info::decl_info(decl_info const& other) :
|
|||
|
||||
|
||||
void decl_info::init_eh(ast_manager & m) {
|
||||
vector<parameter>::iterator it = m_parameters.begin();
|
||||
vector<parameter>::iterator end = m_parameters.end();
|
||||
for (; it != end; ++it) {
|
||||
it->init_eh(m);
|
||||
for (parameter & p : m_parameters) {
|
||||
p.init_eh(m);
|
||||
}
|
||||
}
|
||||
|
||||
void decl_info::del_eh(ast_manager & m) {
|
||||
vector<parameter>::iterator it = m_parameters.begin();
|
||||
vector<parameter>::iterator end = m_parameters.end();
|
||||
for (; it != end; ++it) {
|
||||
it->del_eh(m, m_family_id);
|
||||
for (parameter & p : m_parameters) {
|
||||
p.del_eh(m, m_family_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1291,10 +1287,8 @@ decl_kind user_sort_plugin::register_name(symbol s) {
|
|||
|
||||
decl_plugin * user_sort_plugin::mk_fresh() {
|
||||
user_sort_plugin * p = alloc(user_sort_plugin);
|
||||
svector<symbol>::iterator it = m_sort_names.begin();
|
||||
svector<symbol>::iterator end = m_sort_names.end();
|
||||
for (; it != end; ++it)
|
||||
p->register_name(*it);
|
||||
for (symbol const& s : m_sort_names)
|
||||
p->register_name(s);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1414,26 +1408,20 @@ ast_manager::~ast_manager() {
|
|||
dec_ref(m_true);
|
||||
dec_ref(m_false);
|
||||
dec_ref(m_undef_proof);
|
||||
ptr_vector<decl_plugin>::iterator it = m_plugins.begin();
|
||||
ptr_vector<decl_plugin>::iterator end = m_plugins.end();
|
||||
for (; it != end; ++it) {
|
||||
if (*it)
|
||||
(*it)->finalize();
|
||||
for (decl_plugin* p : m_plugins) {
|
||||
if (p)
|
||||
p->finalize();
|
||||
}
|
||||
it = m_plugins.begin();
|
||||
for (; it != end; ++it) {
|
||||
if (*it)
|
||||
dealloc(*it);
|
||||
for (decl_plugin* p : m_plugins) {
|
||||
if (p)
|
||||
dealloc(p);
|
||||
}
|
||||
m_plugins.reset();
|
||||
while (!m_ast_table.empty()) {
|
||||
DEBUG_CODE(std::cout << "ast_manager LEAKED: " << m_ast_table.size() << std::endl;);
|
||||
ptr_vector<ast> roots;
|
||||
ast_mark mark;
|
||||
ast_table::iterator it_a = m_ast_table.begin();
|
||||
ast_table::iterator end_a = m_ast_table.end();
|
||||
for (; it_a != end_a; ++it_a) {
|
||||
ast* n = (*it_a);
|
||||
for (ast * n : m_ast_table) {
|
||||
switch (n->get_kind()) {
|
||||
case AST_SORT: {
|
||||
sort_info* info = to_sort(n)->get_info();
|
||||
|
@ -1466,9 +1454,7 @@ ast_manager::~ast_manager() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
it_a = m_ast_table.begin();
|
||||
for (; it_a != end_a; ++it_a) {
|
||||
ast* n = *it_a;
|
||||
for (ast * n : m_ast_table) {
|
||||
if (!mark.is_marked(n)) {
|
||||
roots.push_back(n);
|
||||
}
|
||||
|
@ -1543,12 +1529,15 @@ void ast_manager::raise_exception(char const * msg) {
|
|||
throw ast_exception(msg);
|
||||
}
|
||||
|
||||
#include "ast/ast_translation.h"
|
||||
|
||||
void ast_manager::copy_families_plugins(ast_manager const & from) {
|
||||
TRACE("copy_families_plugins",
|
||||
tout << "target:\n";
|
||||
for (family_id fid = 0; m_family_manager.has_family(fid); fid++) {
|
||||
tout << "fid: " << fid << " fidname: " << get_family_name(fid) << "\n";
|
||||
});
|
||||
ast_translation trans(const_cast<ast_manager&>(from), *this, false);
|
||||
for (family_id fid = 0; from.m_family_manager.has_family(fid); fid++) {
|
||||
SASSERT(from.is_builtin_family_id(fid) == is_builtin_family_id(fid));
|
||||
SASSERT(!from.is_builtin_family_id(fid) || m_family_manager.has_family(fid));
|
||||
|
@ -1569,6 +1558,9 @@ void ast_manager::copy_families_plugins(ast_manager const & from) {
|
|||
SASSERT(new_p->get_family_id() == fid);
|
||||
SASSERT(has_plugin(fid));
|
||||
}
|
||||
if (from.has_plugin(fid)) {
|
||||
get_plugin(fid)->inherit(from.get_plugin(fid), trans);
|
||||
}
|
||||
SASSERT(from.m_family_manager.has_family(fid) == m_family_manager.has_family(fid));
|
||||
SASSERT(from.get_family_id(fid_name) == get_family_id(fid_name));
|
||||
SASSERT(!from.has_plugin(fid) || has_plugin(fid));
|
||||
|
@ -1663,11 +1655,8 @@ bool ast_manager::is_bool(expr const * n) const {
|
|||
|
||||
#ifdef Z3DEBUG
|
||||
bool ast_manager::slow_not_contains(ast const * n) {
|
||||
ast_table::iterator it = m_ast_table.begin();
|
||||
ast_table::iterator end = m_ast_table.end();
|
||||
unsigned num = 0;
|
||||
for (; it != end; ++it) {
|
||||
ast * curr = *it;
|
||||
for (ast * curr : m_ast_table) {
|
||||
if (compare_nodes(curr, n)) {
|
||||
TRACE("nondet_bug",
|
||||
tout << "id1: " << curr->get_id() << ", id2: " << n->get_id() << "\n";
|
||||
|
@ -1935,6 +1924,35 @@ sort * ast_manager::mk_sort(symbol const & name, sort_info * info) {
|
|||
return register_node(new_node);
|
||||
}
|
||||
|
||||
sort * ast_manager::substitute(sort* s, unsigned n, sort * const * src, sort * const * dst) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
if (s == src[i]) return dst[i];
|
||||
}
|
||||
|
||||
vector<parameter> ps;
|
||||
bool change = false;
|
||||
sort_ref_vector sorts(*this);
|
||||
for (unsigned i = 0; i < s->get_num_parameters(); ++i) {
|
||||
parameter const& p = s->get_parameter(i);
|
||||
if (p.is_ast()) {
|
||||
SASSERT(is_sort(p.get_ast()));
|
||||
change = true;
|
||||
sorts.push_back(substitute(to_sort(p.get_ast()), n, src, dst));
|
||||
ps.push_back(parameter(sorts.back()));
|
||||
}
|
||||
else {
|
||||
ps.push_back(p);
|
||||
}
|
||||
}
|
||||
if (!change) {
|
||||
return s;
|
||||
}
|
||||
decl_info dinfo(s->get_family_id(), s->get_decl_kind(), ps.size(), ps.c_ptr(), s->private_parameters());
|
||||
sort_info sinfo(dinfo, s->get_num_elements());
|
||||
return mk_sort(s->get_name(), &sinfo);
|
||||
}
|
||||
|
||||
|
||||
sort * ast_manager::mk_uninterpreted_sort(symbol const & name, unsigned num_parameters, parameter const * parameters) {
|
||||
user_sort_plugin * plugin = get_user_sort_plugin();
|
||||
decl_kind kind = plugin->register_name(name);
|
||||
|
@ -2177,7 +2195,10 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar
|
|||
throw ast_exception(buffer.str().c_str());
|
||||
}
|
||||
app * r = 0;
|
||||
if (num_args > 2 && !decl->is_flat_associative()) {
|
||||
if (num_args == 1 && decl->is_chainable() && decl->get_arity() == 2) {
|
||||
r = mk_true();
|
||||
}
|
||||
else if (num_args > 2 && !decl->is_flat_associative()) {
|
||||
if (decl->is_right_associative()) {
|
||||
unsigned j = num_args - 1;
|
||||
r = mk_app_core(decl, args[j-1], args[j]);
|
||||
|
@ -2206,7 +2227,7 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar
|
|||
r = mk_app_core(decl, num_args, args);
|
||||
}
|
||||
SASSERT(r != 0);
|
||||
TRACE("app_ground", tout << "ground: " << r->is_ground() << "\n" << mk_ll_pp(r, *this) << "\n";);
|
||||
TRACE("app_ground", tout << "ground: " << r->is_ground() << " id: " << r->get_id() << "\n" << mk_ll_pp(r, *this) << "\n";);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -2351,6 +2372,7 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort *
|
|||
SASSERT(num_decls > 0);
|
||||
DEBUG_CODE({
|
||||
for (unsigned i = 0; i < num_patterns; ++i) {
|
||||
TRACE("ast", tout << i << " " << mk_pp(patterns[i], *this) << "\n";);
|
||||
SASSERT(is_pattern(patterns[i]));
|
||||
}});
|
||||
unsigned sz = quantifier::get_obj_size(num_decls, num_patterns, num_no_patterns);
|
||||
|
@ -2576,7 +2598,7 @@ expr * ast_manager::get_some_value(sort * s) {
|
|||
return mk_model_value(0, s);
|
||||
}
|
||||
|
||||
bool ast_manager::is_fully_interp(sort const * s) const {
|
||||
bool ast_manager::is_fully_interp(sort * s) const {
|
||||
if (is_uninterp(s))
|
||||
return false;
|
||||
family_id fid = s->get_family_id();
|
||||
|
|
|
@ -19,32 +19,32 @@ Revision History:
|
|||
#ifndef AST_H_
|
||||
#define AST_H_
|
||||
|
||||
#include"vector.h"
|
||||
#include"hashtable.h"
|
||||
#include"buffer.h"
|
||||
#include"symbol.h"
|
||||
#include"rational.h"
|
||||
#include"hash.h"
|
||||
#include"optional.h"
|
||||
#include"trace.h"
|
||||
#include"bit_vector.h"
|
||||
#include"symbol_table.h"
|
||||
#include"tptr.h"
|
||||
#include"memory_manager.h"
|
||||
#include"small_object_allocator.h"
|
||||
#include"obj_ref.h"
|
||||
#include"ref_vector.h"
|
||||
#include"ref_buffer.h"
|
||||
#include"obj_mark.h"
|
||||
#include"obj_hashtable.h"
|
||||
#include"id_gen.h"
|
||||
#include"map.h"
|
||||
#include"parray.h"
|
||||
#include"dictionary.h"
|
||||
#include"chashtable.h"
|
||||
#include"z3_exception.h"
|
||||
#include"dependency.h"
|
||||
#include"rlimit.h"
|
||||
#include "util/vector.h"
|
||||
#include "util/hashtable.h"
|
||||
#include "util/buffer.h"
|
||||
#include "util/symbol.h"
|
||||
#include "util/rational.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/optional.h"
|
||||
#include "util/trace.h"
|
||||
#include "util/bit_vector.h"
|
||||
#include "util/symbol_table.h"
|
||||
#include "util/tptr.h"
|
||||
#include "util/memory_manager.h"
|
||||
#include "util/small_object_allocator.h"
|
||||
#include "util/obj_ref.h"
|
||||
#include "util/ref_vector.h"
|
||||
#include "util/ref_buffer.h"
|
||||
#include "util/obj_mark.h"
|
||||
#include "util/obj_hashtable.h"
|
||||
#include "util/id_gen.h"
|
||||
#include "util/map.h"
|
||||
#include "util/parray.h"
|
||||
#include "util/dictionary.h"
|
||||
#include "util/chashtable.h"
|
||||
#include "util/z3_exception.h"
|
||||
#include "util/dependency.h"
|
||||
#include "util/rlimit.h"
|
||||
|
||||
#define RECYCLE_FREE_AST_INDICES
|
||||
|
||||
|
@ -102,8 +102,8 @@ private:
|
|||
union {
|
||||
int m_int; // for PARAM_INT
|
||||
ast* m_ast; // for PARAM_AST
|
||||
char m_symbol[sizeof(symbol)]; // for PARAM_SYMBOL
|
||||
char m_rational[sizeof(rational)]; // for PARAM_RATIONAL
|
||||
void const* m_symbol; // for PARAM_SYMBOL
|
||||
rational* m_rational; // for PARAM_RATIONAL
|
||||
double m_dval; // for PARAM_DOUBLE (remark: this is not used in float_decl_plugin)
|
||||
unsigned m_ext_id; // for PARAM_EXTERNAL
|
||||
};
|
||||
|
@ -114,12 +114,10 @@ public:
|
|||
explicit parameter(int val): m_kind(PARAM_INT), m_int(val) {}
|
||||
explicit parameter(unsigned val): m_kind(PARAM_INT), m_int(val) {}
|
||||
explicit parameter(ast * p): m_kind(PARAM_AST), m_ast(p) {}
|
||||
explicit parameter(symbol const & s): m_kind(PARAM_SYMBOL) { new (m_symbol) symbol(s); }
|
||||
explicit parameter(rational const & r): m_kind(PARAM_RATIONAL) { new (m_rational) rational(r); }
|
||||
explicit parameter(symbol const & s): m_kind(PARAM_SYMBOL), m_symbol(s.c_ptr()) {}
|
||||
explicit parameter(rational const & r): m_kind(PARAM_RATIONAL), m_rational(alloc(rational, r)) {}
|
||||
explicit parameter(double d):m_kind(PARAM_DOUBLE), m_dval(d) {}
|
||||
explicit parameter(const char *s):m_kind(PARAM_SYMBOL) {
|
||||
new (m_symbol) symbol(s);
|
||||
}
|
||||
explicit parameter(const char *s):m_kind(PARAM_SYMBOL), m_symbol(symbol(s).c_ptr()) {}
|
||||
explicit parameter(unsigned ext_id, bool):m_kind(PARAM_EXTERNAL), m_ext_id(ext_id) {}
|
||||
parameter(parameter const&);
|
||||
|
||||
|
@ -156,8 +154,8 @@ public:
|
|||
|
||||
int get_int() const { SASSERT(is_int()); return m_int; }
|
||||
ast * get_ast() const { SASSERT(is_ast()); return m_ast; }
|
||||
symbol const & get_symbol() const { SASSERT(is_symbol()); return *(reinterpret_cast<const symbol *>(m_symbol)); }
|
||||
rational const & get_rational() const { SASSERT(is_rational()); return *(reinterpret_cast<const rational *>(m_rational)); }
|
||||
symbol get_symbol() const { SASSERT(is_symbol()); return symbol::mk_symbol_from_c_ptr(m_symbol); }
|
||||
rational const & get_rational() const { SASSERT(is_rational()); return *m_rational; }
|
||||
double get_double() const { SASSERT(is_double()); return m_dval; }
|
||||
unsigned get_ext_id() const { SASSERT(is_external()); return m_ext_id; }
|
||||
|
||||
|
@ -337,13 +335,17 @@ public:
|
|||
unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false):
|
||||
decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) {
|
||||
}
|
||||
sort_info(sort_info const& other) : decl_info(other), m_num_elements(other.m_num_elements) {
|
||||
sort_info(sort_info const& other) : decl_info(other), m_num_elements(other.m_num_elements) {
|
||||
}
|
||||
sort_info(decl_info const& di, sort_size const& num_elements) :
|
||||
decl_info(di), m_num_elements(num_elements) {}
|
||||
|
||||
~sort_info() {}
|
||||
|
||||
bool is_infinite() const { return m_num_elements.is_infinite(); }
|
||||
bool is_very_big() const { return m_num_elements.is_very_big(); }
|
||||
sort_size const & get_num_elements() const { return m_num_elements; }
|
||||
void set_num_elements(sort_size const& s) { m_num_elements = s; }
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, sort_info const & info);
|
||||
|
@ -569,6 +571,7 @@ public:
|
|||
bool is_very_big() const { return get_info() == 0 || get_info()->is_very_big(); }
|
||||
bool is_sort_of(family_id fid, decl_kind k) const { return get_family_id() == fid && get_decl_kind() == k; }
|
||||
sort_size const & get_num_elements() const { return get_info()->get_num_elements(); }
|
||||
void set_num_elements(sort_size const& s) { get_info()->set_num_elements(s); }
|
||||
unsigned get_size() const { return get_obj_size(); }
|
||||
};
|
||||
|
||||
|
@ -892,6 +895,8 @@ struct ast_eq_proc {
|
|||
}
|
||||
};
|
||||
|
||||
class ast_translation;
|
||||
|
||||
class ast_table : public chashtable<ast*, obj_ptr_hash<ast>, ast_eq_proc> {
|
||||
public:
|
||||
void erase(ast * n);
|
||||
|
@ -927,6 +932,8 @@ protected:
|
|||
m_family_id = id;
|
||||
}
|
||||
|
||||
virtual void inherit(decl_plugin* other_p, ast_translation& ) { }
|
||||
|
||||
friend class ast_manager;
|
||||
|
||||
public:
|
||||
|
@ -990,7 +997,7 @@ public:
|
|||
|
||||
// Return true if the interpreted sort s does not depend on uninterpreted sorts.
|
||||
// This may be the case, for example, for array and datatype sorts.
|
||||
virtual bool is_fully_interp(sort const * s) const { return true; }
|
||||
virtual bool is_fully_interp(sort * s) const { return true; }
|
||||
|
||||
// Event handlers for deleting/translating PARAM_EXTERNAL
|
||||
virtual void del(parameter const & p) {}
|
||||
|
@ -1657,6 +1664,8 @@ public:
|
|||
|
||||
sort * mk_sort(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0);
|
||||
|
||||
sort * substitute(sort* s, unsigned n, sort * const * src, sort * const * dst);
|
||||
|
||||
sort * mk_bool_sort() const { return m_bool_sort; }
|
||||
|
||||
sort * mk_proof_sort() const { return m_proof_sort; }
|
||||
|
@ -1669,7 +1678,7 @@ public:
|
|||
\brief A sort is "fully" interpreted if it is interpreted,
|
||||
and doesn't depend on other uninterpreted sorts.
|
||||
*/
|
||||
bool is_fully_interp(sort const * s) const;
|
||||
bool is_fully_interp(sort * s) const;
|
||||
|
||||
func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range = 0);
|
||||
|
@ -2021,8 +2030,8 @@ public:
|
|||
app * mk_not(expr * n) { return mk_app(m_basic_family_id, OP_NOT, n); }
|
||||
app * mk_distinct(unsigned num_args, expr * const * args);
|
||||
app * mk_distinct_expanded(unsigned num_args, expr * const * args);
|
||||
app * mk_true() { return m_true; }
|
||||
app * mk_false() { return m_false; }
|
||||
app * mk_true() const { return m_true; }
|
||||
app * mk_false() const { return m_false; }
|
||||
app * mk_bool_val(bool b) { return b?m_true:m_false; }
|
||||
app * mk_interp(expr * arg) { return mk_app(m_basic_family_id, OP_INTERP, arg); }
|
||||
|
||||
|
@ -2472,6 +2481,7 @@ public:
|
|||
void operator()(AST * n) { m_manager.inc_ref(n); }
|
||||
};
|
||||
|
||||
|
||||
#endif /* AST_H_ */
|
||||
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
--*/
|
||||
|
||||
#include<iostream>
|
||||
#include"for_each_ast.h"
|
||||
#include"arith_decl_plugin.h"
|
||||
#include "ast/for_each_ast.h"
|
||||
#include "ast/arith_decl_plugin.h"
|
||||
|
||||
// #define AST_LL_PP_SHOW_FAMILY_NAME
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ Revision History:
|
|||
#ifndef AST_LL_PP_H_
|
||||
#define AST_LL_PP_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include "ast/ast.h"
|
||||
#include<iostream>
|
||||
|
||||
void ast_ll_pp(std::ostream & out, ast_manager & m, ast * n, bool only_exprs=true, bool compact=true);
|
||||
|
|
|
@ -16,7 +16,7 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"ast.h"
|
||||
#include "ast/ast.h"
|
||||
|
||||
#define check_symbol(S1,S2) if (S1 != S2) return lt(S1,S2)
|
||||
#define check_value(V1,V2) if (V1 != V2) return V1 < V2
|
||||
|
|
|
@ -21,7 +21,7 @@ Revision History:
|
|||
#ifndef AST_PP_H_
|
||||
#define AST_PP_H_
|
||||
|
||||
#include"ast_smt2_pp.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
|
||||
struct mk_pp : public mk_ismt2_pp {
|
||||
mk_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0):
|
||||
|
|
|
@ -17,9 +17,9 @@ Revision History:
|
|||
|
||||
--*/
|
||||
|
||||
#include "ast_pp_util.h"
|
||||
#include "ast_smt2_pp.h"
|
||||
#include "ast_smt_pp.h"
|
||||
#include "ast/ast_pp_util.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ast/ast_smt_pp.h"
|
||||
|
||||
void ast_pp_util::collect(expr* e) {
|
||||
coll.visit(e);
|
||||
|
|
|
@ -19,7 +19,7 @@ Revision History:
|
|||
#ifndef AST_PP_UTIL_H_
|
||||
#define AST_PP_UTIL_H_
|
||||
|
||||
#include "decl_collector.h"
|
||||
#include "ast/decl_collector.h"
|
||||
|
||||
class ast_pp_util {
|
||||
ast_manager& m;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue