./configure --enable-language-bindings=java \
JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include
-There is also a "C++ compatibility API" (#include <cvc4/cvc3_compat.h>
-and link against libcvc4compat.so) that attempts to maintain
-source-level backwards-compatibility with the CVC3 C++ API. The
-compatibility library is built by default, and
---enable-language-bindings=java enables the Java compatibility library
-(CVC4compat.jar and libcvc4compatjni.so).
---enable-language-bindings=c enables the C compatibility library
-(#include <cvc4/bindings/compat/c/c_interface.h> and link against
-libcvc4bindings_c_compat.so), and if you want both C and Java
-bindings, use --enable-language-bindings=c,java. These compatibility
-language bindings do NOT require SWIG.
-
-The examples/ directory includes some basic examples (the "simple vc"
-and "simple vc compat" family of examples) of all these interfaces.
+The examples/ directory includes some basic examples (the "simple vc" family of
+examples) of all these interfaces.
In principle, since we use SWIG to generate the native Java API, we
could support other languages as well. However, using CVC4 from other
doc/libcvc4.3.in \
doc/SmtEngine.3cvc_template.in \
doc/options.3cvc_template.in \
- doc/libcvc4parser.3.in \
- doc/libcvc4compat.3.in
+ doc/libcvc4parser.3.in
man_MANS = \
doc/cvc4.1 \
doc/libcvc4.3 \
doc/SmtEngine.3cvc \
doc/options.3cvc \
- doc/libcvc4parser.3 \
- doc/libcvc4compat.3
+ doc/libcvc4parser.3
doc/pcvc4.1: doc/cvc4.1
rm -f doc/pcvc4.1
doc/pcvc4.1 \
doc/cvc4.5 \
doc/libcvc4.3 \
- doc/libcvc4compat.3 \
doc/libcvc4parser.3 \
doc/SmtEngine.3cvc \
doc/SmtEngine.3cvc_template \
SHELL = @SHELL@
LIBTOOL = $(CURRENT_BUILD)/libtool
-# Are we building the libcvc4compat library ?
-CVC4_BUILD_LIBCOMPAT = @CVC4_BUILD_LIBCOMPAT@
-
# @
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
test -d ../src/parser/.libs && \
ln -sf ../src/parser/.libs/libcvc4parser.* \
.
-ifeq ($(CVC4_BUILD_LIBCOMPAT),yes)
-# symlink libcvc4compat
- $(AM_V_at)cd $(CURRENT_BUILD)/lib && \
- ln -sf ../src/compat/libcvc4compat.* \
- .
- -$(AM_V_at)cd $(CURRENT_BUILD)/lib && \
- test -d ../src/compat/.libs && \
- ln -sf ../src/compat/.libs/libcvc4compat.* \
- .
-endif
# symlink the binaries
$(AM_V_at)cd $(CURRENT_BUILD)/bin && \
for binary in $(CVC4_BINARIES); do \
m4_define(_CVC4_LIBRARY_VERSION, library_version([libcvc4]))dnl
m4_define(_CVC4_PARSER_LIBRARY_VERSION, library_version([libcvc4parser]))dnl
-m4_define(_CVC4_COMPAT_LIBRARY_VERSION, library_version([libcvc4compat]))dnl
m4_define(_CVC4_BINDINGS_LIBRARY_VERSION, library_version([libcvc4bindings]))dnl
m4_define([fatal_error], [m4_errprint(__program__:__file__:__line__[: fatal error: $*
m4_ifblank(_CVC4_LIBRARY_VERSION,[fatal_error([no CVC4_LIBRARY_VERSION defined for release version "]_CVC4_RELEASE_STRING[" in library_versions file])])dnl
m4_ifblank(_CVC4_PARSER_LIBRARY_VERSION,[fatal_error([no CVC4_PARSER_LIBRARY_VERSION defined for release version "]_CVC4_RELEASE_STRING[" in library_versions file])])dnl
-m4_ifblank(_CVC4_COMPAT_LIBRARY_VERSION,[fatal_error([no CVC4_COMPAT_LIBRARY_VERSION defined for release version "]_CVC4_RELEASE_STRING[" in library_versions file])])dnl
m4_ifblank(_CVC4_BINDINGS_LIBRARY_VERSION,[fatal_error([no CVC4_BINDINGS_LIBRARY_VERSION defined for release version "]_CVC4_RELEASE_STRING[" in library_versions file])])dnl
CVC4_LIBRARY_VERSION=_CVC4_LIBRARY_VERSION
CVC4_PARSER_LIBRARY_VERSION=_CVC4_PARSER_LIBRARY_VERSION
-CVC4_COMPAT_LIBRARY_VERSION=_CVC4_COMPAT_LIBRARY_VERSION
CVC4_BINDINGS_LIBRARY_VERSION=_CVC4_BINDINGS_LIBRARY_VERSION
# Using AX_CXX_COMPILE_STDCXX_11 and the AC_CANONICAL_* macros destroy the
AC_DEFINE_UNQUOTED([READLINE_COMPENTRY_FUNC_RETURNS_CHARP], $readline_compentry_func_returns_charp, [Define to 1 if rl_completion_entry_function is declared to return pointer to char])
AC_SUBST([READLINE_LIBS])
-# Whether to build compatibility library
-CVC4_BUILD_LIBCOMPAT=yes
-AC_ARG_WITH([compat],
- AS_HELP_STRING([--with-compat], [build compatibility library (CVC3 API layer)]),
- [if test "$withval" = no; then CVC4_BUILD_LIBCOMPAT=no; fi])
-AC_MSG_CHECKING([whether to build compatibility library (CVC3 API layer)])
-if test "$CVC4_BUILD_LIBCOMPAT" = yes; then
- AC_MSG_RESULT([yes])
-else
- AC_MSG_RESULT([no, disabled by user])
-fi
-AC_SUBST(CVC4_BUILD_LIBCOMPAT)
-AM_CONDITIONAL([CVC4_BUILD_LIBCOMPAT], [test "$CVC4_BUILD_LIBCOMPAT" = yes])
-
# Whether to compile with google profiling tools
cvc4_use_google_perftools=0
AC_ARG_WITH(
AC_SUBST(CVC4_LIBRARY_VERSION)
AC_SUBST(CVC4_PARSER_LIBRARY_VERSION)
-AC_SUBST(CVC4_COMPAT_LIBRARY_VERSION)
AC_SUBST(CVC4_BINDINGS_LIBRARY_VERSION)
AC_DEFINE_UNQUOTED(CVC4_MAJOR, ${CVC4_MAJOR}, [Major component of the version of CVC4.])
if test "$gpl" = yes; then isgpl=1; else isgpl=0; fi
AC_DEFINE_UNQUOTED(CVC4_GPL_DEPS, $isgpl, [Whether CVC4 is built with the (optional) GPLed library dependences.])
-CVC4_COMPAT_LIBRARY_VERSION_or_nobuild="$CVC4_COMPAT_LIBRARY_VERSION"
CVC4_BINDINGS_LIBRARY_VERSION_or_nobuild="$CVC4_BINDINGS_LIBRARY_VERSION"
-if test "$CVC4_BUILD_LIBCOMPAT" = no; then
- CVC4_COMPAT_LIBRARY_VERSION_or_nobuild="N/A"
-fi
if test -z "$CVC4_LANGUAGE_BINDINGS"; then
CVC4_BINDINGS_LIBRARY_VERSION_or_nobuild="N/A"
fi
bindings_to_be_built=none
if test -n "$CVC4_LANGUAGE_BINDINGS"; then
bindings_to_be_built="$CVC4_LANGUAGE_BINDINGS"
- if test -z "$SWIG"; then
- bindings_to_be_built="$bindings_to_be_built (for CVC3 compatibility layer only; SWIG not found)"
- fi
fi
CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/util/floatingpoint.h])
CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/SmtEngine.3cvc_template])
CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/options.3cvc_template])
CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/libcvc4parser.3])
-CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/libcvc4compat.3])
AC_OUTPUT
Static libs : $enable_static
Shared libs : $enable_shared
Static binary: $enable_static_binary
-Compat lib : $CVC4_BUILD_LIBCOMPAT
Bindings : $bindings_to_be_built
Multithreaded: $support_multithreaded
libcvc4 version : $CVC4_LIBRARY_VERSION
libcvc4parser version : $CVC4_PARSER_LIBRARY_VERSION
-libcvc4compat version : $CVC4_COMPAT_LIBRARY_VERSION_or_nobuild
libcvc4bindings version: $CVC4_BINDINGS_LIBRARY_VERSION_or_nobuild
Install into : $prefix
my $excluded_directories = '^(CVS|generated)$';
my $excluded_paths = '^(';
-$excluded_paths .= 'src/bindings/compat/.*';
# different license
$excluded_paths .= '|src/util/channel.h';
# minisat license
contributors.
.SH "SEE ALSO"
.BR libcvc4 (3),
-.BR libcvc4parser (3),
-.BR libcvc4compat (3)
+.BR libcvc4parser (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
contributors.
.SH "SEE ALSO"
.BR libcvc4 (3),
-.BR libcvc4parser (3),
-.BR libcvc4compat (3)
+.BR libcvc4parser (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
.SH "SEE ALSO"
.BR cvc4 (1),
.BR libcvc4 (3),
-.BR libcvc4parser (3),
-.BR libcvc4compat (3)
+.BR libcvc4parser (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
.SH "SEE ALSO"
.BR cvc4 (1),
-.BR libcvc4parser (3),
-.BR libcvc4compat (3)
+.BR libcvc4parser (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
+++ /dev/null
-.\" Process this file with
-.\" groff -man -Tascii libcvc4compat.3
-.\"
-.TH LIBCVC4COMPAT 3 "@MAN_DATE@" "CVC4 release @VERSION@" "CVC4 Library Interfaces"
-.SH NAME
-libcvc4compat \- a CVC3 compatibility library interface for the CVC4 theorem prover
-.SH DESCRIPTION
-.SH "SEE ALSO"
-.BR cvc4 (1),
-.BR libcvc4 (3),
-.BR libcvc4parser (3)
-
-Additionally, the CVC4 wiki contains useful information about the
-design and internals of CVC4. It is maintained at
-.BR http://cvc4.cs.stanford.edu/wiki/ .
.SH DESCRIPTION
.SH "SEE ALSO"
.BR cvc4 (1),
-.BR libcvc4 (3),
-.BR libcvc4compat (3)
+.BR libcvc4 (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
contributors.
.SH "SEE ALSO"
.BR libcvc4 (3),
-.BR libcvc4parser (3),
-.BR libcvc4compat (3)
+.BR libcvc4parser (3)
Additionally, the CVC4 wiki contains useful information about the
design and internals of CVC4. It is maintained at
simple_vc_cxx \
translator
-
-if CVC4_BUILD_LIBCOMPAT
-noinst_PROGRAMS += \
- simple_vc_compat_cxx
-if CVC4_LANGUAGE_BINDING_C
-noinst_PROGRAMS += \
- simple_vc_compat_c
-endif
-endif
-
noinst_DATA =
if CVC4_LANGUAGE_BINDING_JAVA
noinst_DATA += \
SimpleVC.class
-if CVC4_BUILD_LIBCOMPAT
-noinst_DATA += \
- SimpleVCCompat.class
-endif
endif
@builddir@/../src/parser/libcvc4parser.la \
@builddir@/../src/libcvc4.la
-simple_vc_compat_cxx_SOURCES = \
- simple_vc_compat_cxx.cpp
-simple_vc_compat_cxx_LDADD = \
- @builddir@/../src/compat/libcvc4compat.la \
- @builddir@/../src/parser/libcvc4parser.la \
- @builddir@/../src/libcvc4.la
-
-simple_vc_compat_c_SOURCES = \
- simple_vc_compat_c.c
-simple_vc_compat_c_LDADD = \
- @builddir@/../src/bindings/compat/c/libcvc4bindings_c_compat.la
-
translator_SOURCES = \
translator.cpp
translator_LDADD = \
SimpleVC.class: SimpleVC.java
$(AM_V_JAVAC)$(JAVAC) -classpath "@builddir@/../src/bindings/CVC4.jar" -d "@builddir@" $<
-SimpleVCCompat.class: SimpleVCCompat.java
- $(AM_V_JAVAC)$(JAVAC) -classpath "@builddir@/../src/bindings/compat/java/CVC4compat.jar" -d "@builddir@" $<
EXTRA_DIST = \
SimpleVC.java \
- SimpleVCCompat.java \
SimpleVC.ml \
SimpleVC.php \
SimpleVC.pl \
if STATIC_BINARY
simple_vc_cxx_LINK = $(CXXLINK) -all-static
-simple_vc_compat_cxx_LINK = $(CXXLINK) -all-static
-simple_vc_compat_c_LINK = $(LINK) -all-static
else
simple_vc_cxx_LINK = $(CXXLINK)
-simple_vc_compat_cxx_LINK = $(CXXLINK)
-simple_vc_compat_c_LINK = $(LINK)
endif
# for installation
AM_V_JAVAC = $(am__v_JAVAC_$(V))
am__v_JAVAC_ = $(am__v_JAVAC_$(AM_DEFAULT_VERBOSITY))
am__v_JAVAC_0 = @echo " JAVAC " $@;
-
+++ /dev/null
-/********************* */
-/*! \file SimpleVCCompat.java
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief A simple demonstration of the Java compatibility interface
- ** (quite similar to the old CVC3 Java interface)
- **
- ** A simple demonstration of the Java compatibility interface
- ** (quite similar to the old CVC3 Java interface).
- **
- ** To run the resulting class file, you need to do something like the
- ** following:
- **
- ** java \
- ** -classpath path/to/CVC4compat.jar \
- ** -Djava.library.path=/dir/containing/libcvc4bindings_java_compat.so \
- ** SimpleVCCompat
- **
- ** For example, if you are building CVC4 without specifying your own
- ** build directory, the build process puts everything in builds/, and
- ** you can run this example (after building it with "make") like this:
- **
- ** java \
- ** -classpath builds/examples:builds/src/bindings/compat/java/CVC4compat.jar \
- ** -Djava.library.path=builds/src/bindings/compat/java/.libs \
- ** SimpleVCCompat
- **/
-
-import cvc3.*;
-
-public class SimpleVCCompat {
- public static void main(String[] args) {
- ValidityChecker vc = ValidityChecker.create();
-
- // Prove that for integers x and y:
- // x > 0 AND y > 0 => 2x + y >= 3
-
- Type integer = vc.intType();
-
- Expr x = vc.varExpr("x", integer);
- Expr y = vc.varExpr("y", integer);
- Expr zero = vc.ratExpr(0);
-
- Expr x_positive = vc.gtExpr(x, zero);
- Expr y_positive = vc.gtExpr(y, zero);
-
- Expr two = vc.ratExpr(2);
- Expr twox = vc.multExpr(two, x);
- Expr twox_plus_y = vc.plusExpr(twox, y);
-
- Expr three = vc.ratExpr(3);
- Expr twox_plus_y_geq_3 = vc.geExpr(twox_plus_y, three);
-
- Expr formula = vc.impliesExpr(vc.andExpr(x_positive, y_positive),
- twox_plus_y_geq_3);
-
- System.out.println("Checking validity of formula " + formula + " with CVC4.");
- System.out.println("CVC4 should report VALID.");
- System.out.println("Result from CVC4 is: " + vc.query(formula));
- }
-}
+++ /dev/null
-/********************* */
-/*! \file simple_vc_compat_c.c
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters, Tim King
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief A simple demonstration of the C compatibility interface
- ** (quite similar to the old CVC3 C interface)
- **
- ** A simple demonstration of the C compatibility interface
- ** (quite similar to the old CVC3 C interface).
- **/
-
-#include <stdio.h>
-#include <stdlib.h>
-
-// Use this after CVC4 is properly installed.
-// #include <cvc4/bindings/compat/c/c_interface.h>
-#include "bindings/compat/c/c_interface.h"
-
-int main() {
- VC vc = vc_createValidityChecker(NULL);
-
- /* Prove that for integers x and y:
- * x > 0 AND y > 0 => 2x + y >= 3 */
-
- Type integer = vc_intType(vc);
-
- Expr x = vc_varExpr(vc, "x", integer);
- Expr y = vc_varExpr(vc, "y", integer);
- Expr zero = vc_ratExpr(vc, 0, 1);
-
- Expr x_positive = vc_gtExpr(vc, x, zero);
- Expr y_positive = vc_gtExpr(vc, y, zero);
-
- Expr two = vc_ratExpr(vc, 2, 1);
- Expr twox = vc_multExpr(vc, two, x);
- Expr twox_plus_y = vc_plusExpr(vc, twox, y);
-
- Expr three = vc_ratExpr(vc, 3, 1);
- Expr twox_plus_y_geq_3 = vc_geExpr(vc, twox_plus_y, three);
-
- Expr formula = vc_impliesExpr(vc, vc_andExpr(vc, x_positive, y_positive),
- twox_plus_y_geq_3);
-
- char* formulaString = vc_printExprString(vc, formula);
-
- printf("Checking validity of formula %s with CVC4.\n", formulaString);
- printf("CVC4 should return 1 (meaning VALID).\n");
- printf("Result from CVC4 is: %d\n", vc_query(vc, formula));
-
- free(formulaString);
-
- return 0;
-}
+++ /dev/null
-/********************* */
-/*! \file simple_vc_compat_cxx.cpp
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief A simple demonstration of the C++ compatibility interface
- ** (quite similar to the old CVC3 C++ interface)
- **
- ** A simple demonstration of the C++ compatibility interface (quite
- ** similar to the old CVC3 C++ interface). Note that the library is
- ** named "libcvc4compat," to mark it as being part of CVC4, but the
- ** header file is "cvc3_compat.h" to indicate the similarity to the
- ** CVC3 interface, and the namespace is "CVC3". CVC3::Expr and
- ** CVC4::Expr are incompatible; to avoid confusion, it is best to not
- ** include both the CVC3 and CVC4 interface headers.
- **/
-
-#include <iostream>
-
-// #include <cvc4/compat/cvc3_compat.h> // use this after CVC4 is properly installed
-#include "compat/cvc3_compat.h"
-
-using namespace std;
-using namespace CVC3;
-
-int main() {
- ValidityChecker* vc = ValidityChecker::create();
-
- // Prove that for integers x and y:
- // x > 0 AND y > 0 => 2x + y >= 3
-
- Type integer = vc->intType();
-
- Expr x = vc->varExpr("x", integer);
- Expr y = vc->varExpr("y", integer);
- Expr zero = vc->ratExpr(0);
-
- Expr x_positive = vc->gtExpr(x, zero);
- Expr y_positive = vc->gtExpr(y, zero);
-
- Expr two = vc->ratExpr(2);
- Expr twox = vc->multExpr(two, x);
- Expr twox_plus_y = vc->plusExpr(twox, y);
-
- Expr three = vc->ratExpr(3);
- Expr twox_plus_y_geq_3 = vc->geExpr(twox_plus_y, three);
-
- Expr formula = vc->impliesExpr(vc->andExpr(x_positive, y_positive),
- twox_plus_y_geq_3);
-
- cout << "Checking validity of formula " << formula << " with CVC4." << endl;
- cout << "CVC4 should report VALID." << endl;
- cout << "Result from CVC4 is: " << vc->query(formula) << endl;
-
- return 0;
-}
# CVC4 release numbers and the corresponding interface version
# information of libraries.
#
-# For now, libcvc4bindings' version info is used for all language
-# bindings libraries, and _also_ for all "compatibility" bindings
-# libraries (i.e., the old CVC3-esque C and Java bindings). This
-# may need to be split out in future, if some bindings (particularly
-# the compatibility ones) change more(/less) frequently than the
-# others.
+# For now, libcvc4bindings' version info is used for all language bindings
+# libraries. This may need to be split out in future, if some bindings change
+# more(/less) frequently than the others.
#
0\..* libcvc4:0:0:0 libcvc4parser:0:0:0 libcvc4compat:0:0:0 libcvc4bindings:0:0:0
1\.0 libcvc4:0:0:0 libcvc4parser:0:0:0 libcvc4compat:0:0:0 libcvc4bindings:0:0:0
1\.5 libcvc4:4:0:0 libcvc4parser:4:0:0 libcvc4compat:4:0:0 libcvc4bindings:4:0:0
1\.6-prerelease libcvc4:4:0:0 libcvc4parser:4:0:0 libcvc4compat:4:0:0 libcvc4bindings:4:0:0
1\.6 libcvc4:5:0:0 libcvc4parser:5:0:0 libcvc4compat:5:0:0 libcvc4bindings:5:0:0
-1\.7-prerelease libcvc4:5:0:0 libcvc4parser:5:0:0 libcvc4compat:5:0:0 libcvc4bindings:5:0:0
+1\.7-prerelease libcvc4:5:0:0 libcvc4parser:5:0:0 libcvc4bindings:5:0:0
-I@builddir@ -I@srcdir@/include -I@srcdir@
AM_CXXFLAGS = -Wall -Wno-unknown-pragmas -Wno-parentheses $(FLAG_VISIBILITY_HIDDEN)
-SUBDIRS = lib base options util expr smt_util prop/minisat prop/bvminisat . parser compat bindings main
+SUBDIRS = lib base options util expr smt_util prop/minisat prop/bvminisat . parser bindings main
# The THEORIES list has been moved to Makefile.theories
include @top_srcdir@/src/Makefile.theories
d="$$(echo "$$f" | sed 's,^include/,,')"; \
rm -f "$(DESTDIR)$(includedir)/cvc4/$$d"; \
done
- -rmdir "$(DESTDIR)$(includedir)/cvc4/bindings/compat"
-rmdir "$(DESTDIR)$(includedir)/cvc4/bindings"
-rmdir "$(DESTDIR)$(includedir)/cvc4"
-rmdir "$(DESTDIR)$(libdir)/ocaml/cvc4"
-I@builddir@/.. -I@srcdir@/../include -I@srcdir@/..
AM_CXXFLAGS = -Wall
-SUBDIRS = compat
-
# any binding-specific flags to pass to swig
java_cpp_SWIGFLAGS = -package edu.nyu.acsys.CVC4
+++ /dev/null
-topdir = ../../..
-srcdir = src/bindings/compat
-
-include $(topdir)/Makefile.subdir
+++ /dev/null
-AM_CPPFLAGS = \
- -D__BUILDING_CVC4BINDINGSLIB \
- -I@builddir@/../.. -I@srcdir@/../../include -I@srcdir@/../..
-AM_CXXFLAGS = -Wall
-
-if CVC4_BUILD_LIBCOMPAT
-SUBDIRS = c java
-endif
-
+++ /dev/null
-topdir = ../../../..
-srcdir = src/bindings/compat/c
-
-include $(topdir)/Makefile.subdir
+++ /dev/null
-# LIBCVC4BINDINGS_VERSION (-version-info) is in the form current:revision:age
-#
-# current -
-# increment if interfaces have been added, removed or changed
-# revision -
-# increment if source code has changed
-# set to zero if current is incremented
-# age -
-# increment if interfaces have been added
-# set to zero if interfaces have been removed
-# or changed
-#
-LIBCVC4BINDINGS_VERSION = @CVC4_BINDINGS_LIBRARY_VERSION@
-
-AM_CPPFLAGS = \
- -D__BUILDING_CVC4BINDINGSLIB \
- -I@builddir@/../../.. -I@srcdir@/../../../include -I@srcdir@/../../..
-AM_CXXFLAGS = -Wall -Wno-return-type
-
-lib_LTLIBRARIES =
-
-if CVC4_LANGUAGE_BINDING_C
-
-lib_LTLIBRARIES += libcvc4bindings_c_compat.la
-libcvc4bindings_c_compat_la_LDFLAGS = \
- -version-info $(LIBCVC4BINDINGS_VERSION)
-libcvc4bindings_c_compat_la_LIBADD = \
- @builddir@/../../../compat/libcvc4compat.la \
- @builddir@/../../../libcvc4.la
-
-endif
-
-libcvc4bindings_c_compat_la_SOURCES = \
- c_interface_defs.h \
- c_interface.h \
- c_interface.cpp
+++ /dev/null
-/*****************************************************************************/
-/*!
- * \file c_interface.cpp
- *
- * Authors: Clark Barrett
- * Cristian Cadar
- *
- * Created: Thu Jun 5 10:34:02 2003
- *
- * <hr>
- *
- * License to use, copy, modify, sell and/or distribute this software
- * and its documentation for any purpose is hereby granted without
- * royalty, subject to the terms and conditions defined in the \ref
- * LICENSE file provided with this distribution.
- *
- * <hr>
- *
- */
-/*****************************************************************************/
-
-
-#include <strings.h>
-#include "bindings/compat/c/c_interface_defs.h"
-#include "compat/cvc3_compat.h"
-//#include "vc.h"
-//#include "command_line_flags.h"
-//#include "parser.h"
-//#include "vc_cmd.h"
-//#include "theory_bitvector.h"
-//#include "fdstream.h"
-#include <string>
-#include <cassert>
-#include <cerrno>
-#include <unistd.h>
-
-#ifdef CVC4_DEBUG
-# define DebugAssert(cond, str) assert(cond)
-# define IF_DEBUG(x) x
-#else
-# define DebugAssert(...)
-# define IF_DEBUG(x)
-#endif
-
-using namespace std;
-
-
-// -------------------------------------------------------------------------
-// Debugging
-// -------------------------------------------------------------------------
-
-// + will mean OK
-// - will mean error
-int c_interface_error_flag = 1;
-const int error_int = -100;
-const char* c_interface_error_message = "An Exception Occured: System in a compromised state.";
-string c_interface_error_string;
-// Used to return char* values. Note that the value is only good until
-// the next call to a function returning char*
-static string tmpString;
-
-void signal_error(const char* message,int flag_val,CVC3::Exception ex){
- ostringstream ss;
- ss << c_interface_error_message << endl;
- ss << "Message: " << message << endl;
- ss << "Exception: " << ex << endl;
- IF_DEBUG(cerr << ss.str();)
- c_interface_error_string = ss.str();
- c_interface_error_flag = flag_val;
-}
-
-extern "C" int vc_get_error_status(){
- return c_interface_error_flag;
-}
-
-extern "C" void vc_reset_error_status(){
- c_interface_error_flag = 1;
- c_interface_error_string = "";
-}
-
-extern "C" char* vc_get_error_string() {
- return (char*) (c_interface_error_string.c_str());
-}
-
-
-// Private to implementation
-
-class CInterface {
-public:
- static CVC3::Type fromType(Type t);
- static Type toType(const CVC3::Type& t);
- static CVC3::Expr fromExpr(Expr e);
- static Expr toExpr(const CVC3::Expr& e);
- static CVC3::Op fromOp(Op op);
- static Op toOp(VC vc, const CVC3::Op& op);
- // static CVC3::Proof fromProof(Proof proof);
- // static Proof toProof(const CVC3::Proof& proof);
- static void deleteExpr(Expr e);
- static void deleteType(Type t);
- static void deleteVector(Expr* vec);
-};
-
-
-CVC3::Type CInterface::fromType(Type t)
-{
- return *(CVC3::Type*)t;
-}
-
-
-Type CInterface::toType(const CVC3::Type& t)
-{
- if(t.isNull()) return NULL;
- return Type(new CVC3::Type(t));
-}
-
-
-CVC3::Expr CInterface::fromExpr(Expr e)
-{
- return *(CVC3::Expr*)e;
-}
-
-
-Expr CInterface::toExpr(const CVC3::Expr& e)
-{
- if(e.isNull()) return NULL;
- return Expr(new CVC3::Expr(e));
-}
-
-
-CVC3::Op CInterface::fromOp(Op op)
-{
- return *(CVC3::Op*)op;
-}
-
-
-Op CInterface::toOp(VC vc, const CVC3::Op& op)
-{
- if (op.isNull()) return NULL;
- return Op(new CVC3::Op(op));
-}
-
-
-// CVC3::Proof CInterface::fromProof(Proof proof)
-// {
-// return CVC3::Proof(fromExpr(proof));
-// }
-
-
-// Proof CInterface::toProof(const CVC3::Proof& proof)
-// {
-// return toExpr(proof.getExpr());
-// }
-
-
-void CInterface::deleteExpr(Expr e)
-{
- if (e) delete (CVC3::Expr*)e;
-}
-
-void CInterface::deleteType(Type t)
-{
- if (t) delete (CVC3::Type*)t;
-}
-
-void CInterface::deleteVector(Expr* e)
-{
- if (e) delete [] e;
-}
-
-
-static CVC3::Type fromType(Type t) { return CInterface::fromType(t); }
-static Type toType(const CVC3::Type& t) { return CInterface::toType(t); }
-static CVC3::Expr fromExpr(Expr e) { return CInterface::fromExpr(e); }
-static Expr toExpr(const CVC3::Expr& e) { return CInterface::toExpr(e); }
-static CVC3::Op fromOp(Op op) { return CInterface::fromOp(op); }
-static Op toOp(VC vc, const CVC3::Op& op) { return CInterface::toOp(vc, op); }
-// static CVC3::Proof fromProof(Proof proof) { return CInterface::fromProof(proof); }
-// static Proof toProof(const CVC3::Proof& proof) { return CInterface::toProof(proof); }
-
-
-static char *val_to_binary_str(unsigned nbits, unsigned long val) {
- char s[65];
-
- assert(nbits < sizeof s);
- strcpy(s, "");
- while(nbits-- > 0) {
- if((val >> nbits) & 1)
- strcat(s, "1");
- else
- strcat(s, "0");
- }
- return strdup(s);
-}
-
-
-///////////////////////////////////////////////////////////////////////////
-// Begin implementation of C interface //
-///////////////////////////////////////////////////////////////////////////
-
-
-extern "C" VC vc_createValidityChecker(Flags flags) {
- try{
- CVC3::CLFlags f = (flags==NULL)? CVC3::ValidityChecker::createFlags()
- : *((CVC3::CLFlags*)flags);
- return (VC)CVC3::ValidityChecker::create(f);
- } catch (CVC3::Exception ex){
- signal_error("vc_createValidityChecker",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Flags vc_createFlags() {
- try{
- return new CVC3::CLFlags(CVC3::ValidityChecker::createFlags());
- } catch (CVC3::Exception ex){
- signal_error("vc_createFlags",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" void vc_destroyValidityChecker(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- delete cvc;
- } catch (CVC3::Exception ex){
- signal_error("vc_destroyVelidityChecker",error_int,ex);
- }
-}
-
-
-extern "C" void vc_deleteFlags(Flags flags) {
- try{
- delete ((CVC3::CLFlags*)flags);
- } catch (CVC3::Exception ex){
- signal_error("vc_deleteFlags",error_int,ex);
- }
-}
-
-
-extern "C" void vc_deleteExpr(Expr e)
-{
- try{
- CInterface::deleteExpr(e);
- } catch (CVC3::Exception ex){
- signal_error("vc_deleteExpr",error_int,ex);
- }
-}
-
-
-extern "C" void vc_deleteType(Type t)
-{
- try{
- CInterface::deleteType(t);
- } catch (CVC3::Exception ex){
- signal_error("vc_deleteType",error_int,ex);
- }
-}
-
-
-extern "C" void vc_deleteOp(Op op)
-{
- vc_deleteExpr(op);
-}
-
-
-extern "C" void vc_deleteVector(Expr* e)
-{
- try{
- CInterface::deleteVector(e);
- } catch (CVC3::Exception ex){
- signal_error("vc_deleteVector",error_int,ex);
- }
-}
-
-
-extern "C" void vc_deleteTypeVector(Type* e)
-{
- vc_deleteVector(e);
-}
-
-
-extern "C" void vc_setBoolFlag(Flags flags, char* name, int val) {
- try{
- CVC3::CLFlags& f = *((CVC3::CLFlags*)flags);
- f.setFlag(name, (val!=0));
- } catch (CVC3::Exception ex){
- signal_error("vc_setBoolFlag",error_int,ex);
- }
-}
-
-
-extern "C" void vc_setIntFlag(Flags flags, char* name, int val) {
- try{
- CVC3::CLFlags& f = *((CVC3::CLFlags*)flags);
- f.setFlag(name, val);
- } catch (CVC3::Exception ex){
- signal_error("vc_setIntFlag",error_int,ex);
- }
-}
-
-
-extern "C" void vc_setStringFlag(Flags flags, char* name, char* val) {
- try{
- CVC3::CLFlags& f = *((CVC3::CLFlags*)flags);
- f.setFlag(name, string(val));
- } catch (CVC3::Exception ex){
- signal_error("vc_setStringFlag",error_int,ex);
- }
-}
-
-
-extern "C" void vc_setStrSeqFlag(Flags flags, char* name, char* str, int val) {
- try{
- CVC3::CLFlags& f = *((CVC3::CLFlags*)flags);
- f.setFlag(name, pair<string,bool>(string(str), val!=0));
- } catch (CVC3::Exception ex){
- signal_error("vc_setStrSeqFlag",error_int,ex);
- }
-}
-
-
-extern "C" Type vc_boolType(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->boolType());
- } catch (CVC3::Exception ex){
- signal_error("vc_boolType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_realType(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->realType());
- }catch (CVC3::Exception ex){
- signal_error("vc_realType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_intType(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->intType());
- }catch (CVC3::Exception ex){
- signal_error("vc_intType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_subRangeType(VC vc, int lowerEnd, int upperEnd)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->subrangeType(cvc->ratExpr(lowerEnd),
- cvc->ratExpr(upperEnd)));
- }catch (CVC3::Exception &ex){
- signal_error("vc_subRangeType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_subtypeType(VC vc, Expr pred, Expr witness)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->subtypeType(fromExpr(pred), fromExpr(witness)));
- }catch (CVC3::Exception &ex){
- signal_error("vc_subtypeType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_tupleType2(VC vc, Type type0, Type type1)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->tupleType(fromType(type0), fromType(type1)));
- }catch (CVC3::Exception ex){
- signal_error("vc_tupleType2",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_tupleType3(VC vc, Type type0, Type type1, Type type2)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->tupleType(fromType(type0), fromType(type1),
- fromType(type2)));
- }catch (CVC3::Exception ex){
- signal_error("vc_tupleType3",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_tupleTypeN(VC vc, Type* types, int numTypes)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Type> cvcTypes;
- for (int i = 0; i < numTypes; ++i) {
- cvcTypes.push_back(fromType(types[i]));
- }
- return toType(cvc->tupleType(cvcTypes));
- }catch(CVC3::Exception ex){
- signal_error("vc_tupleTypeN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_recordType1(VC vc, char* field, Type type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->recordType(field, fromType(type)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordType1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_recordType2(VC vc, char* field0, Type type0,
- char* field1, Type type1)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->recordType(field0, fromType(type0),
- field1, fromType(type1)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordType2",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_recordType3(VC vc, char* field0, Type type0,
- char* field1, Type type1,
- char* field2, Type type2)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->recordType(field0, fromType(type0),
- field1, fromType(type1),
- field2, fromType(type2)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordType3",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_recordTypeN(VC vc, char** fields, Type* types,
- int numFields)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<std::string> cvcFields;
- vector<CVC3::Type> cvcTypes;
- for (int i = 0; i < numFields; ++i) {
- cvcFields.push_back(fields[i]);
- cvcTypes.push_back(fromType(types[i]));
- }
- return toType(cvc->recordType(cvcFields, cvcTypes));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordTypeN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_dataType1(VC vc, char* name, char* constructor, int arity,
- char** selectors, Expr* types)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- string cvcName(name);
- string cvcConstructor(constructor);
- vector<string> cvcSelectors;
- vector<CVC3::Expr> cvcTypes;
- for (int i = 0; i < arity; ++i) {
- cvcSelectors.push_back(selectors[i]);
- cvcTypes.push_back(fromExpr(types[i]));
- }
- return toType(cvc->dataType(cvcName, cvcConstructor, cvcSelectors, cvcTypes));
- }catch(CVC3::Exception ex){
- signal_error("vc_dataType1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_dataTypeN(VC vc, char* name, int numCons, char** constructors,
- int* arities, char*** selectors, Expr** types)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- string cvcName(name);
- vector<string> cvcConstructors;
- vector<vector<string> > cvcSelectors(numCons);
- vector<vector<CVC3::Expr> > cvcTypes(numCons);
- for (int i = 0; i < numCons; ++i) {
- cvcConstructors.push_back(constructors[i]);
- for (int j = 0; j < arities[i]; ++j) {
- cvcSelectors[i].push_back(selectors[i][j]);
- cvcTypes[i].push_back(fromExpr(types[i][j]));
- }
- }
- return toType(cvc->dataType(cvcName, cvcConstructors,
- cvcSelectors, cvcTypes));
- }catch(CVC3::Exception ex){
- signal_error("vc_dataTypeN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type* vc_dataTypeMN(VC vc, int numTypes, char** names,
- int* numCons, char*** constructors,
- int** arities, char**** selectors,
- Expr*** types)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<string> cvcNames;
- vector<vector<string> > cvcConstructors(numTypes);
- vector<vector<vector<string> > > cvcSelectors(numTypes);
- vector<vector<vector<CVC3::Expr> > > cvcTypes(numTypes);
- int i;
- for (i = 0; i < numTypes; ++i) {
- cvcNames.push_back(names[i]);
- cvcSelectors[i].resize(numCons[i]);
- cvcTypes[i].resize(numCons[i]);
- for (int j = 0; i < numCons[i]; ++j) {
- cvcConstructors[i].push_back(constructors[i][j]);
- for (int k = 0; k < arities[i][j]; ++k) {
- cvcSelectors[i][j].push_back(selectors[i][j][k]);
- cvcTypes[i][j].push_back(fromExpr(types[i][j][k]));
- }
- }
- }
- vector<CVC3::Type> cvcReturnTypes;
- cvc->dataType(cvcNames, cvcConstructors,
- cvcSelectors, cvcTypes, cvcReturnTypes);
- Type* returnTypes = new Type[numTypes];
- for (i = 0; i < numTypes; ++i) {
- returnTypes[i] = toType(cvcReturnTypes[i]);
- }
- return returnTypes;
- }catch(CVC3::Exception ex){
- signal_error("vc_dataTypeN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_arrayType(VC vc, Type typeIndex, Type typeData)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->arrayType(fromType(typeIndex), fromType(typeData)));
- }catch(CVC3::Exception ex){
- signal_error("vc_arrayType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_bvType(VC vc, int n)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->bitvecType(n));
- }catch (CVC3::Exception ex){
- signal_error("vc_bvType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_funType1(VC vc, Type typeDom, Type typeRan)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->funType(fromType(typeDom), fromType(typeRan)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funType1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_funType2(VC vc, Type a1, Type a2, Type typeRan)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Type> args;
- args.push_back(fromType(a1));
- args.push_back(fromType(a2));
- return toType(cvc->funType(args, fromType(typeRan)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funType2",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_funType3(VC vc, Type a1, Type a2, Type a3, Type typeRan)
-{
- try {
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Type> args;
- args.push_back(fromType(a1));
- args.push_back(fromType(a2));
- args.push_back(fromType(a3));
- return toType(cvc->funType(args, fromType(typeRan)));
- } catch(CVC3::Exception ex){
- signal_error("vc_funType3",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_funTypeN(VC vc, Type* a, Type typeRan, int numArgs)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Type> args;
- for(int i=0; i<numArgs; ++i)
- args.push_back(fromType(*(a+i)));
- return toType(cvc->funType(args, fromType(typeRan)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funTypeN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_createType(VC vc, char* typeName)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->createType(typeName));
- }catch(CVC3::Exception ex){
- signal_error("vc_createType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_lookupType(VC vc, char* typeName)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->lookupType(typeName));
- }catch(CVC3::Exception ex){
- signal_error("vc_lookupType",error_int,ex);
- return NULL;
- }
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Expr manipulation methods //
-/////////////////////////////////////////////////////////////////////////////
-
-
-extern "C" ExprManager vc_getEM(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return (ExprManager)cvc->getEM();
- }catch(CVC3::Exception ex){
- signal_error("vc_getEM",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_varExpr(VC vc, char* name, Type type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->varExpr(name, fromType(type)));
- }catch(CVC3::Exception ex){
- signal_error("vc_varExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_varExprDef(VC vc, char* name, Type type, Expr def)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->varExpr(name, fromType(type), fromExpr(def)));
- }catch(CVC3::Exception ex){
- signal_error("vc_varExprDef",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_lookupVar(VC vc, char* name, Type* type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Type t;
- Expr e = toExpr(cvc->lookupVar(name, &t));
- *type = toType(t);
- return e;
- }catch(CVC3::Exception ex){
- signal_error("vc_lookupVar",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_getType(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->getType(fromExpr(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_getType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_getBaseType(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->getBaseType(fromExpr(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_getBaseType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_getBaseTypeOfType(VC vc, Type t)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->getBaseType(fromType(t)));
- }catch(CVC3::Exception ex){
- signal_error("vc_getBaseTypeOfType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_getTypePred(VC vc, Type t, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->getTypePred(fromType(t), fromExpr(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_getTypePred",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_stringExpr(VC vc, char* str)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->stringExpr(str));
- }catch(CVC3::Exception ex){
- signal_error("vc_stringExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_idExpr(VC vc, char* str)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->idExpr(str));
- }catch(CVC3::Exception ex){
- signal_error("vc_idExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_listExpr(VC vc, int numKids, Expr* kids)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> args;
- for(int i=0; i<numKids; ++i)
- args.push_back(fromExpr(kids[i]));
- return toExpr(cvc->listExpr(args));
- }catch(CVC3::Exception ex){
- signal_error("vc_listExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" void vc_printExpr(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->printExpr(fromExpr(e));
- }catch(CVC3::Exception ex){
- signal_error("vc_printExpr",error_int,ex);
- }
-}
-
-
-extern "C" char* vc_printExprString(VC vc, Expr e)
-{
- try{
- ostringstream os;
- string aa;
- char* result;
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->printExpr(fromExpr(e), os);
- os.flush();
- aa=os.str();
- result=new char[aa.length()+1];
- strcpy(result,aa.c_str());
- return result;
- } catch(CVC3::Exception ex) {
- signal_error("vc_printExprString",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" void vc_deleteString(char* str)
-{
- if (str) delete [] str;
-}
-
-
-extern "C" void vc_printExprFile(VC vc, Expr e, int fd)
-{
- try {
- stringstream ss;
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->printExpr(fromExpr(e), ss);
- string s = ss.str();
- ssize_t e = write(fd, s.c_str(), s.size());
- if(e < 0) {
- IF_DEBUG(cerr << "write() failed, errno == " << errno << endl;)
- c_interface_error_string = "write() failed";
- c_interface_error_flag = errno;
- }
- } catch(CVC3::Exception ex) {
- signal_error("vc_printExpr",error_int,ex);
- }
-}
-
-
-extern "C" Expr vc_importExpr(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->importExpr(fromExpr(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_importExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_importType(VC vc, Type e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toType(cvc->importType(fromType(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_importType",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_eqExpr(VC vc, Expr child0, Expr child1)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->eqExpr(fromExpr(child0), fromExpr(child1)));
- }catch(CVC3::Exception ex){
- signal_error("vc_eqExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_distinctExpr(VC vc, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->distinctExpr(cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_distinctExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_trueExpr(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->trueExpr());
- }catch(CVC3::Exception ex){
- signal_error("vc_trueExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_falseExpr(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->falseExpr());
- }catch(CVC3::Exception ex){
- signal_error("vc_falseExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_notExpr(VC vc, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->notExpr(fromExpr(child)));
- }catch(CVC3::Exception ex){
- signal_error("vc_notExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_andExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->andExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_andExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_andExprN(VC vc, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->andExpr(cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_andExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_orExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->orExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_orExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_orExprN(VC vc, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->orExpr(cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_orExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_impliesExpr(VC vc, Expr hyp, Expr conc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->impliesExpr(fromExpr(hyp), fromExpr(conc)));
- }catch(CVC3::Exception ex){
- signal_error("vc_impliesExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_iffExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->iffExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_iffExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_iteExpr(VC vc, Expr ifpart, Expr thenpart, Expr elsepart)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->iteExpr(fromExpr(ifpart), fromExpr(thenpart),
- fromExpr(elsepart)));
- }catch(CVC3::Exception ex){
- signal_error("vc_iteExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_substExpr(VC vc, Expr e,
- Expr* oldTerms, int numOldTerms,
- Expr* newTerms, int numNewTerms)
-{
- try{
- vector<CVC3::Expr> oldExprs, newExprs;
- CVC3::Expr ex = fromExpr(e);
- //CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- for (int i = 0; i < numOldTerms; ++i) {
- oldExprs.push_back(fromExpr(oldTerms[i]));
- }
- for (int i = 0; i < numNewTerms; ++i) {
- newExprs.push_back(fromExpr(newTerms[i]));
- }
- return toExpr(ex.substExpr(oldExprs, newExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_substExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-
-extern "C" Op vc_createOp(VC vc, char* name, Type type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toOp(vc, cvc->createOp(name, fromType(type)));
- }catch(CVC3::Exception ex){
- signal_error("vc_createOp",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Op vc_createOpDef(VC vc, char* name, Type type, Expr def)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toOp(vc, cvc->createOp(name, fromType(type), fromExpr(def)));
- }catch(CVC3::Exception ex){
- signal_error("vc_createOpDef",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Op vc_lookupOp(VC vc, char* name, Type* type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Type t;
- Op op = toOp(vc, cvc->lookupOp(name, &t));
- *type = toType(t);
- return op;
- } catch(CVC3::Exception ex){
- signal_error("vc_lookupOp",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_funExpr1(VC vc, Op op, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->funExpr(fromOp(op), fromExpr(child)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funExpr1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_funExpr2(VC vc, Op op, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->funExpr(fromOp(op), fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funExpr2",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_funExpr3(VC vc, Op op, Expr child0, Expr child1,
- Expr child2)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->funExpr(fromOp(op), fromExpr(child0), fromExpr(child1),
- fromExpr(child2)));
- }catch(CVC3::Exception ex){
- signal_error("vc_funExpr3",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_funExprN(VC vc, Op op, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->funExpr(fromOp(op), cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_funExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_ratExpr(VC vc, int n, int d)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->ratExpr(n, d));
- }catch(CVC3::Exception ex){
- signal_error("vc_ratExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_ratExprFromStr(VC vc, char* n, char* d, int base)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->ratExpr(n, d, base));
- }catch(CVC3::Exception ex){
- signal_error("vc_ratExprFromStr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_ratExprFromStr1(VC vc, char* n, int base)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->ratExpr(n, base));
- }catch(CVC3::Exception ex){
- signal_error("vc_ratExprFromStr1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_uminusExpr(VC vc, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->uminusExpr(fromExpr(child)));
- }catch(CVC3::Exception ex){
- signal_error("vc_uminusExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_plusExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->plusExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_plusExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_plusExprN(VC vc, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->plusExpr(cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_plusExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_minusExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->minusExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_minusExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_multExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->multExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_multExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_powExpr(VC vc, Expr pow, Expr base)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->powExpr(fromExpr(pow), fromExpr(base)));
- }catch(CVC3::Exception ex){
- signal_error("vc_powExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_divideExpr(VC vc, Expr numerator, Expr denominator)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->divideExpr(fromExpr(numerator), fromExpr(denominator)));
- }catch(CVC3::Exception ex){
- signal_error("vc_divideExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_ltExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->ltExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_ltExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_leExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->leExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_leExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_gtExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->gtExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_gtExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_geExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->geExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_geExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recordExpr1(VC vc, char* field, Expr expr)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->recordExpr(field, fromExpr(expr)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordExpr1",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recordExpr2(VC vc, char* field0, Expr expr0,
- char* field1, Expr expr1)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->recordExpr(field0, fromExpr(expr0),
- field1, fromExpr(expr1)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordExpr2",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recordExpr3(VC vc, char* field0, Expr expr0,
- char* field1, Expr expr1,
- char* field2, Expr expr2)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->recordExpr(field0, fromExpr(expr0),
- field1, fromExpr(expr1),
- field2, fromExpr(expr2)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordExpr3",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recordExprN(VC vc, char** fields, Expr* exprs,
- int numFields)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<std::string> cvcFields;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numFields; ++i) {
- cvcFields.push_back(fields[i]);
- cvcExprs.push_back(fromExpr(exprs[i]));
- }
- return toExpr(cvc->recordExpr(cvcFields, cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_recordExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recSelectExpr(VC vc, Expr record, char* field)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->recSelectExpr(fromExpr(record), field));
- }catch(CVC3::Exception ex){
- signal_error("vc_recSelectExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_recUpdateExpr(VC vc, Expr record, char* field,
- Expr newValue)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->recUpdateExpr(fromExpr(record), field,
- fromExpr(newValue)));
- }catch(CVC3::Exception ex){
- signal_error("vc_recUpdateExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_readExpr(VC vc, Expr array, Expr index)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->readExpr(fromExpr(array), fromExpr(index)));
- }catch(CVC3::Exception ex){
- signal_error("vc_readExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_writeExpr(VC vc, Expr array, Expr index, Expr newValue)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->writeExpr(fromExpr(array), fromExpr(index),
- fromExpr(newValue)));
- }catch(CVC3::Exception ex){
- signal_error("vc_writeExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_bv32Type(VC vc)
-{
- return vc_bvType(vc, 32);
-}
-
-
-extern "C" Expr vc_bvConstExprFromStr(VC vc, char* binary_repr)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->parseExpr(cvc->listExpr("_BVCONST", cvc->stringExpr(binary_repr))));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvConstExpr",error_int, ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvConstExprFromInt(VC vc, int n_bits, unsigned int value)
-{
- char* s = val_to_binary_str(n_bits, value);
- return vc_bvConstExprFromStr(vc, s);
-}
-
-
-extern "C" Expr vc_bv32ConstExprFromInt(VC vc, unsigned int value)
-{
- return vc_bvConstExprFromInt(vc, 32, value);
-}
-
-
-extern "C" Expr vc_bvConstExprFromLL(VC vc, int n_bits, unsigned long value)
-{
- char* s = val_to_binary_str(n_bits, value);
- return vc_bvConstExprFromStr(vc, s);
-}
-
-
-extern "C" Expr vc_bvConcatExpr(VC vc, Expr left, Expr right) {
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newConcatExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception &ex){
- signal_error("vc_bvConcatExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvConcatExprN(VC vc, Expr* children, int numChildren) {
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->newConcatExpr(cvcExprs));
- }catch(CVC3::Exception &ex){
- signal_error("vc_concatExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvExtract(VC vc, Expr child, int high_bit_no, int low_bit_no)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVExtractExpr(fromExpr(child), high_bit_no, low_bit_no));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvExtract",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvBoolExtract(VC vc, Expr child, int bit_no)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BOOLEXTRACT", fromExpr(child), cvc->ratExpr(bit_no));
- return toExpr(cvc->parseExpr(lExpr));
-
- }catch(CVC3::Exception ex){
- signal_error("vc_bvBoolExtract",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvNotExpr(VC vc, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVNegExpr(fromExpr(child)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvNotExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvAndExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVAndExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvAndExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvOrExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVOrExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvOrExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvXorExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVXorExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvXorExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvLtExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVLTExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvLtExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvLeExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVLEExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvLeExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvGtExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BVGT", fromExpr(left), fromExpr(right));
- return toExpr(cvc->parseExpr(lExpr));
-
- }catch(CVC3::Exception ex){
- signal_error("vc_bvGtExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvGeExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BVGE", fromExpr(left), fromExpr(right));
- return toExpr(cvc->parseExpr(lExpr));
-
- }catch(CVC3::Exception ex){
- signal_error("vc_bvGeExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvSLtExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVSLTExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSLtExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvSLeExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVSLEExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSLeExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvSGtExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BVSGT", fromExpr(left), fromExpr(right));
- return toExpr(cvc->parseExpr(lExpr));
-
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSGtExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvSGeExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BVSGE", fromExpr(left), fromExpr(right));
- return toExpr(cvc->parseExpr(lExpr));
-
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSGeExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvSignExtend(VC vc, Expr child, int nbits)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newSXExpr(fromExpr(child), nbits));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSignExtend",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvUMinusExpr(VC vc, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVUminusExpr(fromExpr(child)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvUMinusExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvPlusExpr(VC vc, int n_bits, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> args;
- args.push_back(fromExpr(left));
- args.push_back(fromExpr(right));
- return toExpr(cvc->newBVPlusExpr(n_bits, args));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvPlusExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bv32PlusExpr(VC vc, Expr left, Expr right)
-{
- return vc_bvPlusExpr(vc, 32, left, right);
-}
-
-
-extern "C" Expr vc_bvMinusExpr(VC vc, int n_bits, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::Expr lExpr = cvc->listExpr("_BVSUB", cvc->ratExpr(n_bits), fromExpr(left), fromExpr(right));
- return toExpr(cvc->parseExpr(lExpr));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvMinusExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bv32MinusExpr(VC vc, Expr left, Expr right)
-{
- return vc_bvMinusExpr(vc, 32, left, right);
-}
-
-
-extern "C" Expr vc_bvMultExpr(VC vc, int n_bits, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVMultExpr(n_bits, fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvMultExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bv32MultExpr(VC vc, Expr left, Expr right)
-{
- return vc_bvMultExpr(vc, 32, left, right);
-}
-
-
-extern "C" Expr vc_bvLeftShiftExpr(VC vc, int sh_amt, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newFixedLeftShiftExpr(fromExpr(child), sh_amt));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvLeftShiftExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvRightShiftExpr(VC vc, int sh_amt, Expr child)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newFixedRightShiftExpr(fromExpr(child), sh_amt));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvRightShiftExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_bvUDivExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVUDivExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvUDivExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_bvURemExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVURemExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvURemExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_bvSDivExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVSDivExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSDivExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_bvSRemExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVSRemExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSRemExpr",error_int,ex);
- return NULL;
- }
-}
-
-extern "C" Expr vc_bvSModExpr(VC vc, Expr left, Expr right)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->newBVSModExpr(fromExpr(left), fromExpr(right)));
- }catch(CVC3::Exception ex){
- signal_error("vc_bvSModExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-/* Same as vc_bvLeftShift only that the answer in 32 bits long */
-extern "C" Expr vc_bv32LeftShiftExpr(VC vc, int sh_amt, Expr child) {
- return vc_bvExtract(vc, vc_bvLeftShiftExpr(vc, sh_amt, child), 31, 0);
-}
-
-
-/* Same as vc_bvRightShift only that the answer in 32 bits long */
-extern "C" Expr vc_bv32RightShiftExpr(VC vc, int sh_amt, Expr child) {
- return vc_bvExtract(vc, vc_bvRightShiftExpr(vc, sh_amt, child), 31, 0);
-}
-
-extern "C" Expr vc_bvVar32LeftShiftExpr(VC vc, Expr sh_amt, Expr child) {
- try{
- Expr ifpart;
- Expr thenpart;
- Expr elsepart = vc_trueExpr(vc);
- Expr ite = vc_trueExpr(vc);
-
- for(int count=32; count >= 0; count--){
- if(count != 32) {
- ifpart = vc_eqExpr(vc, sh_amt,
- vc_bvConstExprFromInt(vc, 32, count));
- thenpart = vc_bvExtract(vc,
- vc_bvLeftShiftExpr(vc, count, child),
- 31, 0);
-
- ite = vc_iteExpr(vc,ifpart,thenpart,elsepart);
- elsepart = ite;
- } else {
- elsepart = vc_bvConstExprFromInt(vc,32, 0);
- }
- }
- return ite;
- }catch(CVC3::Exception ex){
- signal_error("vc_bvVar32LeftShiftExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvVar32DivByPowOfTwoExpr(VC vc, Expr child, Expr rhs) {
- try{
- Expr ifpart;
- Expr thenpart;
- Expr elsepart = vc_trueExpr(vc);
- Expr ite = vc_trueExpr(vc);
-
- for(int count=32; count >= 0; count--){
- if(count != 32) {
- ifpart = vc_eqExpr(vc, rhs,
- vc_bvConstExprFromInt(vc, 32, 1 << count));
- thenpart = vc_bvRightShiftExpr(vc, count, child);
- ite = vc_iteExpr(vc,ifpart,thenpart,elsepart);
- elsepart = ite;
- } else {
- elsepart = vc_bvConstExprFromInt(vc,32, 0);
- }
- }
- return ite;
- }catch(CVC3::Exception ex){
- signal_error("vc_bvVar32DivByPowOfTwoExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_bvVar32RightShiftExpr(VC vc, Expr sh_amt, Expr child)
-{
- try{
- Expr ifpart;
- Expr thenpart;
- Expr elsepart = vc_trueExpr(vc);
- Expr ite = vc_trueExpr(vc);
-
- for(int count=32; count >= 0; count--){
- if(count != 32) {
- ifpart = vc_eqExpr(vc, sh_amt,
- vc_bvConstExprFromInt(vc, 32, count));
- thenpart = vc_bvRightShiftExpr(vc, count, child);
- ite = vc_iteExpr(vc,ifpart,thenpart,elsepart);
- elsepart = ite;
- } else {
- elsepart = vc_bvConstExprFromInt(vc,32, 0);
- }
- }
- return ite;
- }catch(CVC3::Exception ex){
- signal_error("vc_bvVar32LeftShiftExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-/* C pointer support: C interface to support C memory arrays in CVC3 */
-extern "C" Expr vc_bvCreateMemoryArray(VC vc, char * arrayName) {
- Type bv8 = vc_bvType(vc,8);
- Type bv32 = vc_bvType(vc,32);
-
- Type malloced_mem0 = vc_arrayType(vc,bv32,bv8);
- return vc_varExpr(vc, arrayName, malloced_mem0);
-}
-
-/*OLD VERSIONS C pointer theory functions. DO NOT DELETE */
-
-// //Warning: Type checking needed to ensure that the function is run
-// //correctly is not being done. it is assumed that the function
-// //recieves inputs of the correct types
-// extern "C" Expr vc_bvReadMemoryArray(VC vc,
-// Expr array,
-// Expr byteIndex, int newBitsPerElem) {
-// DebugAssert(newBitsPerElem%8 == 0,
-// "new bits per element must be a multiple of 8\n");
-
-// Expr numerator = vc_bvMultExpr(vc,32,
-// vc_bvConstExprFromInt(vc,32,newBitsPerElem),
-// byteIndex);
-// int numOfBytes = newBitsPerElem/8;
-// DebugAssert(numOfBytes > 0,
-// "numOfBytes must be greater than 0");
-
-// if(numOfBytes == 1)
-// return vc_readExpr(vc,array,numerator);
-// else {
-// int count = 1;
-// Expr a = vc_readExpr(vc,array,numerator);
-// while(--numOfBytes > 0) {
-// Expr b = vc_readExpr(vc,array,
-// vc_bvPlusExpr(vc,32,numerator,vc_bvConstExprFromInt(vc,32,count)));
-// a = vc_bvConcatExpr(vc,a,b);
-// count++;
-// }
-// return a;
-// }
-// }
-
-// extern "C" Expr vc_bvWriteToMemoryArray(VC vc,
-// Expr array, Expr byteIndex,
-// Expr element, int newBitsPerElem) {
-// DebugAssert(newBitsPerElem%8 == 0,
-// "new bits per element must be a multiple of 8\n");
-
-// Expr numerator = vc_bvMultExpr(vc,32,
-// vc_bvConstExprFromInt(vc,32,newBitsPerElem),
-// byteIndex);
-// int numOfBytes = newBitsPerElem/8;
-// DebugAssert(numOfBytes > 0,
-// "numOfBytes must be greater than 0");
-
-// if(numOfBytes == 1)
-// return vc_writeExpr(vc,array,numerator, element);
-// else {
-// int count = 1;
-// int hi = newBitsPerElem - 1;
-// int low = newBitsPerElem - 8;
-// Expr c = vc_bvExtract(vc,element,hi,low);
-// Expr newarray = vc_writeExpr(vc,array,numerator,c);
-// while(--numOfBytes > 0) {
-// hi = low-1;
-// low = low-8;
-// c = vc_bvExtract(vc,element,hi,low);
-// newarray = vc_writeExpr(vc,newarray,numerator,c);
-// count++;
-// }
-// return newarray;
-// }
-// }
-
-
-extern "C" Expr vc_bvReadMemoryArray(VC vc,
- Expr array,
- Expr byteIndex, int numOfBytes) {
-
- DebugAssert(0 < numOfBytes,
- "number of Bytes must be greater than 0\n");
-
- if(numOfBytes == 1)
- return vc_readExpr(vc,array,byteIndex);
- else {
- int count = 1;
- Expr a = vc_readExpr(vc,array,byteIndex);
- while(--numOfBytes > 0) {
- Expr b = vc_readExpr(vc,array,
- /*vc_simplify(vc, */
- vc_bvPlusExpr(vc, 32,
- byteIndex,
- vc_bvConstExprFromInt(vc,32,count)))/*)*/;
- a = vc_bvConcatExpr(vc,b,a);
- count++;
- }
- return a;
- }
-}
-
-
-extern "C" Expr vc_bvWriteToMemoryArray(VC vc,
- Expr array, Expr byteIndex,
- Expr element, int numOfBytes) {
- DebugAssert(numOfBytes > 0,
- "numOfBytes must be greater than 0");
-
- //int newBitsPerElem = numOfBytes*8;
- if(numOfBytes == 1)
- return vc_writeExpr(vc, array, byteIndex, element);
- else {
- int count = 1;
- //int hi = newBitsPerElem - 1;
- //int low = newBitsPerElem - 8;
- int low_elem = 0;
- int hi_elem = low_elem + 7;
- Expr c = vc_bvExtract(vc, element, hi_elem, low_elem);
- Expr newarray = vc_writeExpr(vc, array, byteIndex, c);
- while(--numOfBytes > 0) {
- //hi = low-1;
- //low = low-8;
-
- low_elem = low_elem + 8;
- hi_elem = low_elem + 7;
-
- c = vc_bvExtract(vc, element, hi_elem, low_elem);
- newarray =
- vc_writeExpr(vc, newarray,
- vc_bvPlusExpr(vc, 32, byteIndex, vc_bvConstExprFromInt(vc,32,count)),
- c);
- count++;
- }
- return newarray;
- }
-}
-
-extern "C" Expr vc_tupleExprN(VC vc, Expr* children, int numChildren)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcExprs;
- for (int i = 0; i < numChildren; ++i) {
- cvcExprs.push_back(fromExpr(children[i]));
- }
- return toExpr(cvc->tupleExpr(cvcExprs));
- }catch(CVC3::Exception ex){
- signal_error("vc_tupleExprN",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_tupleSelectExpr(VC vc, Expr tuple, int index)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->tupleSelectExpr(fromExpr(tuple), index));
- }catch(CVC3::Exception ex){
- signal_error("vc_tupleSelectExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_tupleUpdateExpr(VC vc, Expr tuple, int index, Expr newValue)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->tupleUpdateExpr(fromExpr(tuple), index,
- fromExpr(newValue)));
- }catch(CVC3::Exception ex){
- signal_error("vc_tupleUpdateExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_datatypeConsExpr(VC vc, char* constructor,
- int numArgs, Expr* args)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcArgs;
- for (int i = 0; i < numArgs; ++i) {
- cvcArgs.push_back(fromExpr(args[i]));
- }
- return toExpr(cvc->datatypeConsExpr(constructor, cvcArgs));
- }catch(CVC3::Exception ex){
- signal_error("vc_datatypeConsExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_datatypeSelExpr(VC vc, char* selector, Expr arg)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->datatypeSelExpr(selector, fromExpr(arg)));
- }catch(CVC3::Exception ex){
- signal_error("vc_datatypeSelExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_datatypeTestExpr(VC vc, char* constructor, Expr arg)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->datatypeTestExpr(constructor, fromExpr(arg)));
- }catch(CVC3::Exception ex){
- signal_error("vc_datatypeTestExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_boundVarExpr(VC vc, char* name, char *uid, Type type)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->boundVarExpr(name, uid, fromType(type)));
- }catch(CVC3::Exception ex){
- signal_error("vc_getEM",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Type vc_forallExpr(VC vc, Expr* Bvars, int numBvars, Expr f)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcBvars;
- for (int i = 0; i < numBvars; ++i) {
- cvcBvars.push_back(fromExpr(Bvars[i]));
- }
- return toExpr(cvc->forallExpr(cvcBvars,fromExpr(f)));
- }catch(CVC3::Exception ex){
- signal_error("vc_forallExpr",error_int,ex);
- return NULL;
- }
-}
-
-// triggers must be an array of listExpr
-// each listExpr represent a trigger
-// if a listExpr contains more than one Expr, then it is a multi-trigger
-extern "C" void vc_setTriggers(VC vc, Expr e, int numTrigs, Expr* triggers)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<vector<CVC3::Expr> >cvcTriggers;
- for (int i = 0; i < numTrigs; ++i) {
- vector<CVC3::Expr> curTrig;
- CVC3::Expr trigExpr = fromExpr(triggers[i]);
- if(trigExpr.isRawList()){
- for(int j = 0 ; j < trigExpr.arity(); j++){
- curTrig.push_back(trigExpr[j]);
- }
- }
- else{
- curTrig.push_back(trigExpr);
- }
- cvcTriggers.push_back(curTrig);
- }
-
- cvc->setTriggers(fromExpr(e), cvcTriggers);
- }catch(CVC3::Exception ex){
- signal_error("vc_setTriggers",error_int,ex);
- }
-}
-
-
-extern "C" Expr vc_existsExpr(VC vc, Expr* Bvars, int numBvars, Expr f)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcBvars;
- for (int i = 0; i < numBvars; ++i) {
- cvcBvars.push_back(fromExpr(Bvars[i]));
- }
- return toExpr(cvc->existsExpr(cvcBvars,fromExpr(f)));
- }catch(CVC3::Exception ex){
- signal_error("vc_existsExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Op vc_lambdaExpr(VC vc, int numVars, Expr* vars, Expr body)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcVars;
- for (int i = 0; i < numVars; ++i) {
- cvcVars.push_back(fromExpr(vars[i]));
- }
- return toOp(vc, cvc->lambdaExpr(cvcVars, fromExpr(body)));
- }catch(CVC3::Exception ex){
- signal_error("vc_lambdaExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Context-related methods //
-/////////////////////////////////////////////////////////////////////////////
-
-
-extern "C" void vc_setResourceLimit(VC vc, unsigned limit)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->setResourceLimit(limit);
- }catch(CVC3::Exception ex){
- signal_error("vc_setResourceLimit",error_int,ex);
- }
-}
-
-
-extern "C" void vc_assertFormula(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->assertFormula(fromExpr(e));
- }catch(CVC3::Exception ex){
- signal_error("vc_assertFormula",error_int,ex);
- }
-}
-
-
-extern "C" void vc_registerAtom(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->registerAtom(fromExpr(e));
- }catch(CVC3::Exception ex){
- signal_error("vc_registerAtom",error_int,ex);
- }
-}
-
-
-extern "C" Expr vc_getImpliedLiteral(VC vc)
-{
- try {
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->getImpliedLiteral());
- } catch(CVC3::Exception ex){
- signal_error("vc_getImpliedLiteral",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_simplify(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->simplify(fromExpr(e)));
- }catch(CVC3::Exception ex){
- signal_error("vc_simplify",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" int vc_query(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return (int)cvc->query(fromExpr(e));
- }catch(CVC3::Exception ex){
- signal_error("vc_query",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" int vc_checkContinue(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return (int)cvc->checkContinue();
- }catch(CVC3::Exception ex){
- signal_error("vc_checkContinue",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" int vc_restart(VC vc, Expr e)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return (int)cvc->restart(fromExpr(e));
- }catch(CVC3::Exception ex){
- signal_error("vc_restart",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" void vc_returnFromCheck(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->returnFromCheck();
- }catch(CVC3::Exception ex){
- signal_error("vc_returnFromCheck",error_int,ex);
- }
-}
-
-
-extern "C" Expr* vc_getUserAssumptions(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getUserAssumptions(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getUserAssumptions",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getInternalAssumptions(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getInternalAssumptions(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getInternalAssumptions",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getAssumptions(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getAssumptions(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getAssumptions",error_int,ex);
- return NULL;
- }
-}
-
-//yeting, this is for proof translation,
-extern "C" Expr vc_getProofAssumptions(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getUserAssumptions(cvcAssumptions);
- return toExpr(cvc->listExpr(cvcAssumptions));
- }catch(CVC3::Exception ex){
- signal_error("vc_getProofAssumptions",error_int,ex);
- return NULL;
- }
-}
-
-//yeting, this is for proof translation
-extern "C" Expr vc_getProofQuery(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->getProofQuery());
- }catch(CVC3::Exception ex){
- signal_error("vc_getProofQuery",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getAssumptionsUsed(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getAssumptionsUsed(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getAssumptionsUsed",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getCounterExample(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getCounterExample(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getCounterExample",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getConcreteModel(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- CVC3::ExprMap<CVC3::Expr> assertions;
- cvc->getConcreteModel(assertions);
- Expr* locAssumptions = new Expr[assertions.size()];
- int n = 0;
- CVC3::ExprMap<CVC3::Expr>::iterator it = assertions.begin(), end = assertions.end();
- for (; it != end; it++) {
- locAssumptions[n] = toExpr(cvc->eqExpr(it->first, it->second));
- n++;
- }
- *size = n;
- return locAssumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getConcreteModel",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" int vc_inconsistent(VC vc, Expr** assumptions, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> assertions;
- bool ret = cvc->inconsistent(assertions);
- Expr* locAssumptions = new Expr[assertions.size()];
- for (unsigned i = 0; i < assertions.size(); ++i) {
- locAssumptions[i] = toExpr(assertions[i]);
- }
- *assumptions = locAssumptions;
- *size = assertions.size();
- return (int)ret;
- }catch(CVC3::Exception ex){
- signal_error("vc_inconsistent",error_int,ex);
- return 0;
- }
-}
-
-
-extern "C" char* vc_incomplete(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<string> reasons;
- bool ret = cvc->incomplete(reasons);
- if (!ret) return NULL;
- string allReasons = "";
- for (unsigned i = 0; i < reasons.size(); ++i) {
- allReasons += '\n';
- allReasons += reasons[i];
- }
- char* retStr = new char[allReasons.length()+1];
- allReasons.copy(retStr, allReasons.length());
- retStr[allReasons.length()] = '\0';
- return retStr;
- }catch(CVC3::Exception ex){
- signal_error("vc_incomplete",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_getProof(VC vc)
-{
- signal_error("vc_getProofTCC",error_int,CVC3::Exception("Unimplemented"));
- return NULL;
-}
-
-
-extern "C" Expr vc_getProofOfFile(VC vc, char* fileName){
- signal_error("vc_getProofTCC",error_int,CVC3::Exception("Unimplemented"));
- return NULL;
-}
-
-
-extern "C" Expr vc_getTCC(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->getTCC());
- }catch(CVC3::Exception ex){
- signal_error("vc_getTCC",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr* vc_getAssumptionsTCC(VC vc, int* size)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- vector<CVC3::Expr> cvcAssumptions;
- cvc->getAssumptionsTCC(cvcAssumptions);
- Expr* assumptions = new Expr[cvcAssumptions.size()];
- unsigned n = 0;
- for (; n < cvcAssumptions.size(); ++n) {
- assumptions[n] = toExpr(cvcAssumptions[n]);
- }
- *size = int(n);
- return assumptions;
- }catch(CVC3::Exception ex){
- signal_error("vc_getAssumptionsTCC",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_getProofTCC(VC vc)
-{
- signal_error("vc_getProofTCC",error_int,CVC3::Exception("Unimplemented"));
- return NULL;
-}
-
-
-extern "C" Expr vc_getClosure(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return toExpr(cvc->getClosure());
- }catch(CVC3::Exception ex){
- signal_error("vc_getClosure",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_getProofClosure(VC vc)
-{
- signal_error("vc_getProofTCC",error_int,CVC3::Exception("Unimplemented"));
- return NULL;
-}
-
-
-extern "C" int vc_stackLevel(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return cvc->stackLevel();
- }catch(CVC3::Exception ex){
- signal_error("vc_stackLevel",error_int,ex);
- return 0;
- }
-}
-
-
-extern "C" void vc_push(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->push();
- }catch(CVC3::Exception ex){
- signal_error("vc_push",error_int,ex);
- }
-}
-
-
-extern "C" void vc_pop(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->pop();
- }catch(CVC3::Exception ex){
- signal_error("vc_pop",error_int,ex);
- }
-}
-
-
-extern "C" void vc_popto(VC vc, int stackLevel)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->popto(stackLevel);
- }catch(CVC3::Exception ex){
- signal_error("vc_popto",error_int,ex);
- }
-}
-
-
-extern "C" Context vc_getCurrentContext(VC vc)
-{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return (Context)cvc->getCurrentContext();
-}
-
-
-// -------------------------------------------------------------------------
-// Util
-// -------------------------------------------------------------------------
-
-
-extern "C" int vc_compare_exprs(Expr e1,Expr e2){
- try{
- return (compare(fromExpr(e1),fromExpr(e2)));
- } catch (CVC3::Exception ex){
- signal_error("vc_compare_exprs",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" const char* vc_exprString(Expr e){
- try{
- tmpString =(fromExpr(e)).toString();
- return tmpString.c_str();
- } catch (CVC3::Exception ex){
- signal_error("vc_exprString",error_int,ex);
- return "ERROR";
- }
-}
-
-
-extern "C" const char* vc_typeString(Type t){
- try{
- tmpString = (fromExpr(t)).toString();
- return tmpString.c_str();
- } catch (CVC3::Exception ex){
- signal_error("vc_typeString",error_int,ex);
- return "ERROR";
- }
-}
-
-
-extern "C" bool vc_isClosure(Expr e){
- signal_error("vc_isClosure",error_int,CVC3::Exception("Unimplemented"));
- return false;
-}
-
-
-extern "C" bool vc_isQuantifier(Expr e){
- signal_error("vc_isQuantifier",error_int,CVC3::Exception("Unimplemented"));
- return false;
-}
-
-
-extern "C" bool vc_isLambda(Expr e){
- signal_error("vc_isLambda",error_int,CVC3::Exception("Unimplemented"));
- return false;
-}
-
-
-extern "C" bool vc_isVar(Expr e){
- try{
- return (fromExpr(e)).isVar();
- } catch (CVC3::Exception ex){
- signal_error("vc_isVar",error_int,ex);
- return false;
- }
-}
-
-
-extern "C" int vc_arity(Expr e){
- try{
- return (fromExpr(e)).arity();
- } catch (CVC3::Exception ex){
- signal_error("vc_arity",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" int vc_getKind(Expr e){
- try{
- return (fromExpr(e)).getKind();
- } catch (CVC3::Exception ex){
- signal_error("vc_getKind",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" Expr vc_getChild(Expr e, int i){
- try{
- return toExpr(((fromExpr(e))[i]));
- } catch (CVC3::Exception ex){
- signal_error("vc_getChild",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" int vc_getNumVars(Expr e){
- signal_error("vc_getNumVars",error_int,CVC3::Exception("Unimplemented"));
- return 0;
-}
-
-
-extern "C" Expr vc_getVar(Expr e, int i){
- signal_error("vc_getVar",error_int,CVC3::Exception("Unimplemented"));
- return 0;
-}
-
-
-extern "C" Expr vc_getBody(Expr e){
- signal_error("vc_getBody",error_int,CVC3::Exception("Unimplemented"));
- return 0;
-}
-
-extern "C" Expr vc_getExistential(Expr e){
- signal_error("vc_getExistential",error_int,CVC3::Exception("Unimplemented"));
- return 0;
-}
-
-
-extern "C" Expr vc_getFun(VC vc, Expr e)
-{
- try{
- return toExpr((fromExpr(e)).getOp().getExpr());
- }catch(CVC3::Exception ex){
- signal_error("vc_getFun",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" Expr vc_toExpr(Type t){
- try{
- return toExpr(fromExpr(t));
- } catch (CVC3::Exception ex){
- signal_error("vc_toExpr",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" const char* vc_getKindString(VC vc,int kind)
-{
- try{
- tmpString = CVC4::kind::kindToString(CVC4::Kind(kind));
- return tmpString.c_str();
- } catch (CVC3::Exception ex){
- signal_error("vc_getKindString",error_int,ex);
- return NULL;
- }
-}
-
-
-extern "C" int vc_getKindInt(VC vc,char* kind_name)
-{
- signal_error("vc_getKindInt",error_int,CVC3::Exception("Unimplemented"));
- return 0;
-}
-
-
-extern "C" int vc_getInt(Expr e){
- try{
- CVC3::Expr ex = fromExpr(e);
- return int(ex.getConst<CVC3::Rational>().getNumerator().getLong());
- } catch (CVC3::Exception ex){
- signal_error("vc_getInt",error_int,ex);
- return error_int;
- }
-}
-
-
-extern "C" int vc_getBVInt(VC vc, Expr e){
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return int(cvc->computeBVConst(fromExpr(e)).getNumerator().getLong());
- } catch (CVC3::Exception ex){
- signal_error("vc_getBVInt",error_int,ex);
- return 0;
- }
-}
-
-
-extern "C" unsigned int vc_getBVUnsigned(VC vc, Expr e){
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- return unsigned(cvc->computeBVConst(fromExpr(e)).getNumerator().getUnsignedLong());
- } catch (CVC3::Exception ex){
- signal_error("vc_getBVUnsigned",error_int,ex);
- return 0;
- }
-}
-
-
-extern "C" void vc_print_statistics(VC vc)
-{
- try{
- CVC3::ValidityChecker* cvc = (CVC3::ValidityChecker*) vc;
- cvc->printStatistics();
- } catch (CVC3::Exception ex){
- signal_error("vc_print_statistics",error_int,ex);
- }
-}
+++ /dev/null
-/*****************************************************************************/
-/*!
- * \file c_interface.h
- *
- * Authors: Clark Barrett
- * Cristian Cadar
- *
- * Created: Thu Jun 5 10:34:02 2003
- *
- * <hr>
- *
- * License to use, copy, modify, sell and/or distribute this software
- * and its documentation for any purpose is hereby granted without
- * royalty, subject to the terms and conditions defined in the \ref
- * COPYING file provided with this distribution.
- *
- * <hr>
- *
- */
-/*****************************************************************************/
-
-#include "cvc4_public.h"
-
-#ifndef _cvc3__include__c_interface_h_
-#define _cvc3__include__c_interface_h_
-
-#include "bindings/compat/c/c_interface_defs.h"
-
-//! Flags can be NULL
-VC vc_createValidityChecker(Flags flags);
-//! Create validity checker's flags
-Flags vc_createFlags();
-//! Destroy the validity checker.
-/*! Must be called after all other objects are deleted, except the flags */
-void vc_destroyValidityChecker(VC vc);
-//! Delete the flags
-void vc_deleteFlags(Flags flags);
-//! Delete type
-void vc_deleteType(Type t);
-//! Delete expression
-void vc_deleteExpr(Expr e);
-//! Delete operator
-void vc_deleteOp(Op op);
-//! Delete vector of expressions
-void vc_deleteVector(Expr* e);
-//! Delete vector of types
-void vc_deleteTypeVector(Type* e);
-
-// Setting the flags
-//! Set a boolean flag to true or false
-void vc_setBoolFlag(Flags flags, char* name, int val);
-//! Set an integer flag to the given value
-void vc_setIntFlag(Flags flags, char* name, int val);
-//! Set a string flag to the given value
-void vc_setStringFlag(Flags flags, char* name, char* val);
-//! Add a (string, bool) pair to the multy-string flag
-void vc_setStrSeqFlag(Flags flags, char* name, char* str, int val);
-
-// Basic types
-Type vc_boolType(VC vc);
-Type vc_realType(VC vc);
-Type vc_intType(VC vc);
-
-//! Create a subrange type
-Type vc_subRangeType(VC vc, int lowerEnd, int upperEnd);
-
-//! Creates a subtype defined by the given predicate
-/*!
- * \param vc the validity checker
- *
- * \param pred is a predicate taking one argument of type T and returning
- * Boolean. The resulting type is a subtype of T whose elements x are those
- * satisfying the predicate pred(x).
- *
- * \param witness is an expression of type T for which pred holds (if a Null
- * expression is passed as a witness, cvc will try to prove \f$\exists x. pred(x))\f$.
- * if the witness check fails, a TypecheckException is thrown.
- */
-Type vc_subtypeType(VC vc, Expr pred, Expr witness);
-
-// Tuple types
-Type vc_tupleType2(VC vc, Type type0, Type type1);
-Type vc_tupleType3(VC vc, Type type0, Type type1, Type type2);
-//! Create a tuple type. 'types' is an array of types of length numTypes.
-Type vc_tupleTypeN(VC vc, Type* types, int numTypes);
-
-// Record types
-Type vc_recordType1(VC vc, char* field, Type type);
-Type vc_recordType2(VC vc, char* field0, Type type0,
- char* field1, Type type1);
-Type vc_recordType3(VC vc, char* field0, Type type0,
- char* field1, Type type1,
- char* field2, Type type2);
-//! Create a record type.
-/*! 'fields' and 'types' are arrays of length numFields. */
-Type vc_recordTypeN(VC vc, char** fields, Type* types, int numFields);
-
-// Datatypes
-
-//! Single datatype, single constructor
-/*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined. */
-Type vc_dataType1(VC vc, char* name, char* constructor, int arity,
- char** selectors, Expr* types);
-
-//! Single datatype, multiple constructors
-/*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined. */
-Type vc_dataTypeN(VC vc, char* name, int numCons, char** constructors,
- int* arities, char*** selectors, Expr** types);
-
-//! Multiple datatypes
-/*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined.
- * Returns an array of size numTypes which must be freed by calling
- * vc_deleteTypeVector.
- */
-Type* vc_dataTypeMN(VC vc, int numTypes, char** names,
- int* numCons, char*** constructors,
- int** arities, char**** selectors,
- Expr*** types);
-
-//! Create an array type
-Type vc_arrayType(VC vc, Type typeIndex, Type typeData);
-
-//! Create a bitvector type of length n
-Type vc_bvType(VC vc, int n);
-
-//! Create a function type with 1 argument
-Type vc_funType1(VC vc, Type a1, Type typeRan);
-//! Create a function type with 2 arguments
-Type vc_funType2(VC vc, Type a1, Type a2, Type typeRan);
-//! Create a function type with 3 arguments
-Type vc_funType3(VC vc, Type a1, Type a2, Type a3, Type typeRan);
-//! Create a function type with N arguments
-Type vc_funTypeN(VC vc, Type* args, Type typeRan, int numArgs);
-
-// User-defined types
-
-//! Create an uninterpreted named type
-Type vc_createType(VC vc, char* typeName);
-//! Lookup a user-defined (uninterpreted) type by name
-Type vc_lookupType(VC vc, char* typeName);
-
-/////////////////////////////////////////////////////////////////////////////
-// Expr manipulation methods //
-/////////////////////////////////////////////////////////////////////////////
-
-//! Return the ExprManager
-ExprManager* vc_getEM(VC vc);
-
-//! Create a variable with a given name and type
-/*! The type cannot be a function type. */
-Expr vc_varExpr(VC vc, char* name, Type type);
-
-//! Create a variable with a given name, type, and value
-Expr vc_varExprDef(VC vc, char* name, Type type,
- Expr def);
-
-//! Get the expression and type associated with a name.
-/*! If there is no such Expr, a NULL Expr is returned. */
-Expr vc_lookupVar(VC vc, char* name, Type* type);
-
-//! Get the type of the Expr.
-Type vc_getType(VC vc, Expr e);
-
-//! Get the largest supertype of the Expr.
-Type vc_getBaseType(VC vc, Expr e);
-
-//! Get the largest supertype of the Type.
-Type vc_getBaseTypeOfType(VC vc, Type t);
-
-//! Get the subtype predicate
-Expr vc_getTypePred(VC vc, Type t, Expr e);
-
-//! Create a string Expr
-Expr vc_stringExpr(VC vc, char* str);
-
-//! Create an ID Expr
-Expr vc_idExpr(VC vc, char* name);
-
-//! Create a list Expr
-/*! Intermediate representation for DP-specific expressions.
- * Normally, the first element of the list is a string Expr
- * representing an operator, and the rest of the list are the
- * arguments. For example,
- *
- * kids.push_back(vc->stringExpr("PLUS"));
- * kids.push_back(x); // x and y are previously created Exprs
- * kids.push_back(y);
- * Expr lst = vc->listExpr(kids);
- *
- * Or, alternatively (using its overloaded version):
- *
- * Expr lst = vc->listExpr("PLUS", x, y);
- *
- * or
- *
- * vector<Expr> summands;
- * summands.push_back(x); summands.push_back(y); ...
- * Expr lst = vc->listExpr("PLUS", summands);
- */
-Expr vc_listExpr(VC vc, int numKids, Expr* kids);
-
-// Expr I/O
-//! Expr vc_parseExpr(VC vc, char* s);
-void vc_printExpr(VC vc, Expr e);
-//! Print e into a char*
-/*! Note that the ownership of the char* is given to the caller
- which should free the memory when it is done with it. This
- can be done by calling vc_deleteString. */
-char* vc_printExprString(VC vc, Expr e);
-//! Delete char* returned by previous function
-void vc_deleteString(char* str);
-//! Print 'e' into an open file descriptor
-void vc_printExprFile(VC vc, Expr e, int fd);
-
-//! Import the Expr from another instance of VC
-/*! When expressions need to be passed among several instances of
- * VC, they need to be explicitly imported into the
- * corresponding instance using this method. The return result is
- * an identical expression that belongs to the current instance of
- * VC, and can be safely used as part of more complex
- * expressions from the same instance.
- \param vc is the instance to be imported into
- \param e is the expression created using a different (not vc) instance
- */
-Expr vc_importExpr(VC vc, Expr e);
-
-//! Import the Type from another instance of VC
-/*! \sa vc_importExpr() */
-Type vc_importType(Type t);
-
-//! Create an equality expression. The two children must have the same type.
-Expr vc_eqExpr(VC vc, Expr child0, Expr child1);
-
-//! Create an all distinct expression. All children must ahve the same type.
-Expr vc_distinctExpr(VC vc, Expr* children, int numChildren);
-
-// Boolean expressions
-
-// The following functions create Boolean expressions. The children provided
-// as arguments must be of type Boolean.
-Expr vc_trueExpr(VC vc);
-Expr vc_falseExpr(VC vc);
-Expr vc_notExpr(VC vc, Expr child);
-Expr vc_andExpr(VC vc, Expr left, Expr right);
-Expr vc_andExprN(VC vc, Expr* children, int numChildren);
-Expr vc_orExpr(VC vc, Expr left, Expr right);
-Expr vc_orExprN(VC vc, Expr* children, int numChildren);
-Expr vc_impliesExpr(VC vc, Expr hyp, Expr conc);
-Expr vc_iffExpr(VC vc, Expr left, Expr right);
-Expr vc_iteExpr(VC vc, Expr ifpart, Expr thenpart, Expr elsepart);
-
-// Substitution
-
-// Substitutes oldTerms for newTerms in e.
-// This function doesn't actually exist in ValidityChecker interface,
-// but it does in Expr, and its functionality is needed in the C interface.
-// For consistency, it is represented here as if it were in ValidityChecker.
-Expr vc_substExpr(VC vc, Expr e,
- Expr* oldTerms, int numOldTerms,
- Expr* newTerms, int numNewTerms);
-
-// User-defined (uninterpreted) functions.
-
-//! Create an operator from a function with a given name and type.
-/*! Name is given as an ID Expr, and the type must be a function type. */
-Op vc_createOp(VC vc, char* name, Type type);
-
-//! Create a named user-defined function with a given type
-Op vc_createOpDef(VC vc, char* name, Type type, Expr def);
-
-//! Lookup an operator by name.
-/*! Returns the operator and the type if the operator exists.
- * Returns NULL otherwise
- */
-Op vc_lookupOp(VC vc, char* name, Type* type);
-
-//! Create expressions with a user-defined operator.
-/*! op must have a function type. */
-Expr vc_funExpr1(VC vc, Op op, Expr child);
-Expr vc_funExpr2(VC vc, Op op, Expr left, Expr right);
-Expr vc_funExpr3(VC vc, Op op, Expr child0, Expr child1, Expr child2);
-Expr vc_funExprN(VC vc, Op op, Expr* children, int numChildren);
-
-// Arithmetic
-
-//! Create a rational number with numerator n and denominator d.
-/*! d cannot be 0. */
-Expr vc_ratExpr(VC vc, int n, int d);
-
-//! Create a rational number n/d; n and d are given as strings
-/*! n and d are converted to arbitrary-precision integers according to
- * the given base. d cannot be 0. */
-Expr vc_ratExprFromStr(VC vc, char* n, char* d, int base);
-
-//! Create a rational from a single string.
-/*!
- \param vc the validity checker
- \param n can be a string containing an integer, a pair of integers
- "nnn/ddd", or a number in the fixed or floating point format.
- \param base is the base in which to interpret the string.
-*/
-Expr vc_ratExprFromStr1(VC vc, char* n, int base);
-
-//! Unary minus. Child must have a numeric type.
-Expr vc_uminusExpr(VC vc, Expr child);
-
-// plus, minus, mult. Children must have numeric types.
-Expr vc_plusExpr(VC vc, Expr left, Expr right);
-Expr vc_plusExprN(VC vc, Expr* children, int numChildren);
-Expr vc_minusExpr(VC vc, Expr left, Expr right);
-Expr vc_multExpr(VC vc, Expr left, Expr right);
-Expr vc_powExpr(VC vc, Expr pow, Expr base);
-Expr vc_divideExpr(VC vc, Expr numerator, Expr denominator);
-
-// The following functions create less-than, less-than or equal,
-// greater-than, and greater-than or equal expressions of type Boolean.
-// Their arguments must be of numeric types.
-Expr vc_ltExpr(VC vc, Expr left, Expr right);
-Expr vc_leExpr(VC vc, Expr left, Expr right);
-Expr vc_gtExpr(VC vc, Expr left, Expr right);
-Expr vc_geExpr(VC vc, Expr left, Expr right);
-
-// Records
-
-// Create record literals;
-Expr vc_recordExpr1(VC vc, char* field, Expr expr);
-Expr vc_recordExpr2(VC vc, char* field0, Expr expr0,
- char* field1, Expr expr1);
-Expr vc_recordExpr3(VC vc, char* field0, Expr expr0,
- char* field1, Expr expr1,
- char* field2, Expr expr2);
-Expr vc_recordExprN(VC vc, char** fields, Expr* exprs, int numFields);
-
-//! Create an expression representing the selection of a field from a record.
-Expr vc_recSelectExpr(VC vc, Expr record, char* field);
-
-//! Record update; equivalent to "record WITH .field := newValue"
-Expr vc_recUpdateExpr(VC vc, Expr record, char* field, Expr newValue);
-
-// Arrays
-
-//! Create an expression for the value of array at the given index
-Expr vc_readExpr(VC vc, Expr array, Expr index);
-
-//! Array update; equivalent to "array WITH [index] := newValue"
-Expr vc_writeExpr(VC vc, Expr array, Expr index, Expr newValue);
-
-// Bitvectors
-// Additional type constructor
-Type vc_bv32Type(VC vc);
-
-// Bitvector constants
-Expr vc_bvConstExprFromStr(VC vc, char* binary_repr);
-Expr vc_bvConstExprFromInt(VC vc, int n_bits, unsigned int value);
-Expr vc_bv32ConstExprFromInt(VC vc, unsigned int value);
-Expr vc_bvConstExprFromLL(VC vc, int n_bits, unsigned long value);
-
-// Concat and extract
-Expr vc_bvConcatExpr(VC vc, Expr left, Expr right);
-Expr vc_bvConcatExprN(VC vc, Expr* children, int numChildren);
-Expr vc_bvExtract(VC vc, Expr child, int high_bit_no, int low_bit_no);
-Expr vc_bvBoolExtract(VC vc, Expr child, int bit_no);
-
-// Bitwise Boolean operators: Negation, And, Or, Xor
-Expr vc_bvNotExpr(VC vc, Expr child);
-Expr vc_bvAndExpr(VC vc, Expr left, Expr right);
-Expr vc_bvOrExpr(VC vc, Expr left, Expr right);
-Expr vc_bvXorExpr(VC vc, Expr left, Expr right);
-
-// Unsigned bitvector inequalities
-Expr vc_bvLtExpr(VC vc, Expr left, Expr right);
-Expr vc_bvLeExpr(VC vc, Expr left, Expr right);
-Expr vc_bvGtExpr(VC vc, Expr left, Expr right);
-Expr vc_bvGeExpr(VC vc, Expr left, Expr right);
-
-// Signed bitvector inequalities
-Expr vc_bvSLtExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSLeExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSGtExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSGeExpr(VC vc, Expr left, Expr right);
-
-// Sign-extend child to a total of nbits bits
-Expr vc_bvSignExtend(VC vc, Expr child, int nbits);
-
-// Bitvector arithmetic: unary minus, plus, subtract, multiply
-Expr vc_bvUMinusExpr(VC vc, Expr child);
-Expr vc_bvPlusExpr(VC vc, int n_bits, Expr left, Expr right);
-Expr vc_bv32PlusExpr(VC vc, Expr left, Expr right);
-Expr vc_bvMinusExpr(VC vc, int n_bits, Expr left, Expr right);
-Expr vc_bv32MinusExpr(VC vc, Expr left, Expr right);
-Expr vc_bvMultExpr(VC vc, int n_bits, Expr left, Expr right);
-Expr vc_bv32MultExpr(VC vc, Expr left, Expr right);
-Expr vc_bvUDivExpr(VC vc, Expr left, Expr right);
-Expr vc_bvURemExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSDivExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSRemExpr(VC vc, Expr left, Expr right);
-Expr vc_bvSModExpr(VC vc, Expr left, Expr right);
-
-// Shift operators
-Expr vc_bvLeftShiftExpr(VC vc, int sh_amt, Expr child);
-Expr vc_bvRightShiftExpr(VC vc, int sh_amt, Expr child);
-Expr vc_bv32LeftShiftExpr(VC vc, int sh_amt, Expr child);
-Expr vc_bv32RightShiftExpr(VC vc, int sh_amt, Expr child);
-Expr vc_bvVar32LeftShiftExpr(VC vc, Expr sh_amt, Expr child);
-Expr vc_bvVar32RightShiftExpr(VC vc, Expr sh_amt, Expr child);
-Expr vc_bvVar32DivByPowOfTwoExpr(VC vc, Expr child, Expr rhs);
-
-/*C pointer support: C interface to support C memory arrays in CVC3 */
-Expr vc_bvCreateMemoryArray(VC vc, char * arrayName);
-Expr vc_bvReadMemoryArray(VC vc,
- Expr array, Expr byteIndex, int numOfBytes);
-Expr vc_bvWriteToMemoryArray(VC vc,
- Expr array, Expr byteIndex,
- Expr element, int numOfBytes);
-
-// Tuples
-
-//! Create a tuple expression
-/*! 'children' is an array of elements of length numChildren */
-Expr vc_tupleExprN(VC vc, Expr* children, int numChildren);
-
-//! Tuple select; equivalent to "tuple.n", where n is an numeral (e.g. tup.5)
-Expr vc_tupleSelectExpr(VC vc, Expr tuple, int index);
-
-//! Tuple update; equivalent to "tuple WITH index := newValue"
-Expr vc_tupleUpdateExpr(VC vc, Expr tuple, int index, Expr newValue);
-
-// Datatypes
-
-//! Datatype constructor expression
-Expr vc_datatypeConsExpr(VC vc, char* constructor, int numArgs, Expr* args);
-
-//! Datatype selector expression
-Expr vc_datatypeSelExpr(VC vc, char* selector, Expr arg);
-
-//! Datatype tester expression
-Expr vc_datatypeTestExpr(VC vc, char* constructor, Expr arg);
-
-// Quantifiers
-
-//! Create a bound variable.
-/*! \param vc the validity checker
- * \param name
- * \param uid is a fresh unique string to distinguish this variable
- * from other bound variables with the same name
- * \param type
- */
-Expr vc_boundVarExpr(VC vc, char* name, char *uid, Type type);
-
-//! Create a FORALL quantifier.
-/*! Bvars is an array of bound variables of length numBvars. */
-Type vc_forallExpr(VC vc, Expr* Bvars, int numBvars, Expr f);
-
-//! Set triggers for a forallExpr
-void vc_setTriggers(VC vc, Expr e, int numTrigs, Expr* triggers);
-
-//! Create an EXISTS quantifier.
-/*! Bvars is an array of bound variables of length numBvars. */
-Expr vc_existsExpr(VC vc, Expr* Bvars, int numBvars, Expr f);
-
-//! Lambda-expression
-Op vc_lambdaExpr(VC vc, int numVars, Expr* vars, Expr body);
-
-/////////////////////////////////////////////////////////////////////////////
-// Context-related methods //
-/////////////////////////////////////////////////////////////////////////////
-
-//! Set the resource limit (0==unlimited, 1==exhausted).
-/*! Currently, the limit is the total number of processed facts. */
-void vc_setResourceLimit(VC vc, unsigned limit);
-
-//! Assert a new formula in the current context.
-/*! The formula must have Boolean type. */
-void vc_assertFormula(VC vc, Expr e);
-
-//! Register an atomic formula of interest.
-/*! Registered atoms are tracked by the decision procedures. If one of them
- is deduced to be true or false, it is added to a list of implied literals.
- Implied literals can be retrieved with the getImpliedLiteral function */
-void vc_registerAtom(VC vc, Expr e);
-
-//! Return next literal implied by last assertion. Null if none.
-/*! Returned literals are either registered atomic formulas or their negation
- */
-Expr vc_getImpliedLiteral(VC vc);
-
-//! Simplify e with respect to the current context
-Expr vc_simplify(VC vc, Expr e);
-
-//! Check validity of e in the current context.
-/*! Possible results are: 0 = invalid, 1 = valid, 2 = abort, 3 = unknown,
- * -100 = exception (type error, internal error, etc).
- * If the result is 1, then the resulting context is the same as
- * the starting context. If the result is 0 or 3, then the resulting
- * context is a context in which e is false (though the context may be
- * inconsistent in the case of an unknown result). e must have Boolean
- * type. In the case of a result of -100, refer to vc_get_error_string()
- * to see what went wrong. */
-int vc_query(VC vc, Expr e);
-
-//! Get the next model
-/*! This method should only be called after a query which returns
- 0. Its return values are as for vc_query(). */
-int vc_checkContinue(VC vc);
-
-//! Restart the most recent query with e as an additional assertion.
-/*! This method should only be called after a query which returns
- 0. Its return values are as for vc_query(). */
-int vc_restart(VC vc, Expr e);
-
-//! Returns to context immediately before last invalid query.
-/*! This method should only be called after a query which returns 0.
- */
-void vc_returnFromCheck(VC vc);
-
-//! Get assumptions made by the user in this and all previous contexts.
-/*! User assumptions are created either by calls to assertFormula or by a
- * call to query. In the latter case, the negated query is added as an
- * assumption. The caller is responsible for freeing the array when
- * finished with it.
- */
-Expr* vc_getUserAssumptions(VC vc, int* size);
-
-//! Get assumptions made internally in this and all previous contexts.
-/*! Internal assumptions are literals assumed by the sat solver.
- * The caller is responsible for freeing the array when finished with it by
- * calling vc_deleteVector.
- */
-Expr* vc_getInternalAssumptions(VC vc, int* size);
-
-//! Get all assumptions made in this and all previous contexts.
-/*!
- * The caller is responsible for freeing the array when finished with it by
- * calling vc_deleteVector.
- */
-Expr* vc_getAssumptions(VC vc, int* size);
-
-//yeting, for proof translation, get the assumptions used.
-//the assumptions used are different from the user assumptions.
-//the assumptions used are preprocessed if 'preprocess' is ena
-Expr vc_getProofAssumptions(VC vc);
-
-//yeting, for proof translation,
-Expr vc_getProofQuery(VC vc);
-
-//! Returns the set of assumptions used in the proof of queried formula.
-/*! It returns a subset of getAssumptions(). If the last query was false
- * or there has not yet been a query, it does nothing.
- * The caller is responsible for freeing the array when finished with it by
- * calling vc_deleteVector.
- */
-Expr* vc_getAssumptionsUsed(VC vc, int* size);
-
-//! Return the counterexample after a failed query.
-/*! This method should only be called after a query which returns
- * false. It will try to return the simplest possible set of
- * assertions which are sufficient to make the queried expression
- * false. The caller is responsible for freeing the array when finished with
- * it by calling vc_deleteVector.
- */
-Expr* vc_getCounterExample(VC vc, int* size);
-
-//! Will assign concrete values to all user created variables
-/*! This function should only be called after a query which return false.
- * Returns an array of Exprs with size *size.
- * The caller is responsible for freeing the array when finished with it by
- * calling vc_deleteVector.
- */
-Expr* vc_getConcreteModel(VC vc, int* size);
-
-// Returns true if the current context is inconsistent.
-/*! Also returns a minimal set of assertions used to determine the
- * inconsistency. The caller is responsible for freeing the array when finished
- * with it by calling vc_deleteVector.
- */
-int vc_inconsistent(VC vc, Expr** assumptions, int* size);
-
-//! Returns non-NULL if the invalid result from last query() is imprecise
-/*!
- * The return value is filled with the reasons for incompleteness (it
- * is intended to be shown to the end user). The caller is responsible for
- * freeing the string returned by calling vc_deleteString.
- */
-char* vc_incomplete(VC vc);
-
-//! Returns the proof for the last proven query
-Expr vc_getProof(VC vc);
-
-//! Returns the proof of a .cvc file, if it is valid.
-Expr vc_getProofOfFile(VC vc, char * filename);
-
-//! Returns the TCC of the last assumption or query
-/*! Returns Null Expr if no assumptions or queries were performed. */
-Expr vc_getTCC(VC vc);
-
-//! Return the set of assumptions used in the proof of the last TCC
-/*! The caller is responsible for freeing the array when finished with it by
- * calling vc_deleteVector.
- */
-Expr* vc_getAssumptionsTCC(VC vc, int* size);
-
-//! Returns the proof of TCC of the last assumption or query
-/*! Returns Null Expr if no assumptions or queries were performed. */
-Expr vc_getProofTCC(VC vc);
-
-//! After successful query, return its closure |- Gamma => phi
-/*! Turn a valid query Gamma |- phi into an implication
- * |- Gamma => phi.
- *
- * Returns Null Expr if last query was invalid.
- */
-Expr vc_getClosure(VC vc);
-
-//! Construct a proof of the query closure |- Gamma => phi
-/*! Returns Null if last query was Invalid. */
-Expr vc_getProofClosure(VC vc);
-
-//! Returns the current stack level. Initial level is 0.
-int vc_stackLevel(VC vc);
-
-//! Checkpoint the current context and increase the scope level
-void vc_push(VC vc);
-
-//! Restore the current context to its state at the last checkpoint
-void vc_pop(VC vc);
-
-//! Restore the current context to the given stackLevel.
-/*! stackLevel must be less than or equal to the current stack level.
- */
-void vc_popto(VC vc, int stackLevel);
-
-//! Get the current context
-Context* vc_getCurrentContext(VC vc);
-
-/* ---------------------------------------------------------------------- */
-/* Util */
-/* ---------------------------------------------------------------------- */
-
-// Order
-
-//! Compares two expressions
-/*! If e1 < e2, e1==e2, and e1 > e2, it returns -1, 0, 1
- * respectively. A return value of -100 signals an error (refer to
- * vc_get_error_string() for details).
- *
- * Can't be 'compare' because already defined in ocaml */
-int vc_compare_exprs(Expr e1,Expr e2);
-
-// Printing
-
-//! Convert Expr to string
-char* vc_exprString(Expr e);
-//! Convert Type to string
-char* vc_typeString(Type t);
-
-// What kind of Expr?
-int vc_isClosure(Expr e);
-int vc_isQuantifier(Expr e);
-int vc_isLambda(Expr e);
-Expr vc_isVar(Expr e);
-
-int vc_arity(Expr e);
-int vc_getKind(Expr e);
-Expr vc_getChild(Expr e, int i);
-int vc_getNumVars(Expr e);
-Expr vc_getVar(Expr e, int i);
-Expr vc_getBody(Expr e);
-Expr vc_getExistential(Expr e);
-Expr vc_getFun(VC vc, Expr e);
-Expr vc_toExpr(Type t);
-
-//! Translate a kind int to a string
-const char* vc_getKindString(VC vc,int kind);
-
-//! Translate a kind string to an int
-int vc_getKindInt(VC vc,char* kind_name);
-
-//! Return an int from a rational expression
-int vc_getInt(Expr e);
-
-//! Return an int from a constant bitvector expression
-int vc_getBVInt(VC vc, Expr e);
-//! Return an unsigned int from a constant bitvector expression
-unsigned int vc_getBVUnsigned(VC vc, Expr e);
-
-// Debug
-int vc_get_error_status();
-void vc_reset_error_status();
-char* vc_get_error_string();
-
-//! Print statistics
-void vc_print_statistics(VC vc);
-
-#endif
-
-
+++ /dev/null
-/*****************************************************************************/
-/*!
- * \file c_interface_defs.h
- *
- * Author: Clark Barrett
- *
- * Created: Thu Jun 5 13:16:26 2003
- *
- * <hr>
- *
- * License to use, copy, modify, sell and/or distribute this software
- * and its documentation for any purpose is hereby granted without
- * royalty, subject to the terms and conditions defined in the \ref
- * COPYING file provided with this distribution.
- *
- * <hr>
- *
- */
-/*****************************************************************************/
-
-#include "cvc4_public.h"
-
-#ifndef _cvc3__include__c_interface_defs_h_
-#define _cvc3__include__c_interface_defs_h_
-
-//#include "kinds.h"
-
-#ifdef CVC3_STRONG_TYPING
-
- typedef struct _cvc_VC *VC;
- typedef struct _cvc_Context *Context;
- typedef struct _cvc_ExprManager *ExprManager;
- typedef struct _cvc_Flags *Flags;
-
- typedef struct _cvc_Expr * Expr;
- typedef struct _cvc_Op * Op;
- typedef struct _cvc_Type* Type;
-#else
-
- //This gives absolutely no static pointer typing.
- typedef void* VC;
- typedef void* Context;
- typedef void* ExprManager;
- typedef void* Flags;
-
- typedef void* Expr;
- typedef void* Op;
- typedef void* Type;
- typedef void* Proof;
-
-#endif
-#endif
-
+++ /dev/null
-Main-Class: cvc3/Cvc3
-Class-Path: libcvc3.jar
+++ /dev/null
-topdir = ../../../..
-srcdir = src/bindings/compat/java
-
-include $(topdir)/Makefile.subdir
+++ /dev/null
-# LIBCVC4BINDINGS_VERSION (-version-info) is in the form current:revision:age
-#
-# current -
-# increment if interfaces have been added, removed or changed
-# revision -
-# increment if source code has changed
-# set to zero if current is incremented
-# age -
-# increment if interfaces have been added
-# set to zero if interfaces have been removed
-# or changed
-#
-LIBCVC4BINDINGS_VERSION = @CVC4_BINDINGS_LIBRARY_VERSION@
-
-AM_CPPFLAGS = \
- -D__BUILDING_CVC4BINDINGSLIB \
- -I@builddir@/../../.. -I@srcdir@/../../../include -I@srcdir@/../../.. \
- -I@builddir@/cvc3 -I@srcdir@/include/cvc3
-AM_CXXFLAGS = -Wall -Wno-unused-variable
-
-javadatadir = $(datadir)/java
-javalibdir = $(libdir)/jni
-javadata_DATA =
-javalib_LTLIBRARIES=
-BUILT_SOURCES =
-
-if CVC4_LANGUAGE_BINDING_JAVA
-
-javalib_LTLIBRARIES += libcvc4compatjni.la
-javadata_DATA += CVC4compat.jar
-libcvc4compatjni_la_LDFLAGS = \
- -no-undefined \
- -module \
- -shrext $(CVC4_JAVA_MODULE_EXT) \
- -version-info $(LIBCVC4BINDINGS_VERSION)
-libcvc4compatjni_la_LIBADD = \
- @builddir@/../../../compat/libcvc4compat.la \
- @builddir@/../../../libcvc4.la
-BUILT_SOURCES += $(JNI_CPP_FILES)
-
-endif
-
-# source files
-# java files of the library wrapper
-LIB_FILES = \
- Cvc3Exception \
- TypecheckException \
- SoundException \
- EvalException \
- CLException \
- ParserException \
- SmtlibException \
- DebugException \
- Embedded \
- EmbeddedManager \
- InputLanguage \
- QueryResult \
- SatResult \
- FormulaValue \
- Expr \
- ExprMut \
- ExprManager \
- ExprManagerMut \
- Type \
- TypeMut \
- Op \
- OpMut \
- Rational \
- RationalMut \
- Theorem \
- TheoremMut \
- Proof \
- ProofMut \
- Context \
- ContextMut \
- Flag \
- Flags \
- FlagsMut \
- Statistics \
- StatisticsMut \
- ValidityChecker
-
-# java files of the test program
-TEST_FILES = Test
-# java files of the stand alone program
-PROG_FILES = TimeoutHandler Cvc3
-# all java files, library and stand alone
-JAVA_FILES = JniUtils $(LIB_FILES) $(TEST_FILES) $(PROG_FILES)
-# generated files
-JNI_CPP_FILES = \
- EmbeddedManager.cpp \
- Expr.cpp \
- ExprMut.cpp \
- ExprManager.cpp \
- ValidityChecker.cpp
-# Type.cpp \
-# TypeMut.cpp \
-# Op.cpp \
-# OpMut.cpp \
-# Rational.cpp \
-# RationalMut.cpp \
-# Theorem.cpp \
-# TheoremMut.cpp \
-# Proof.cpp \
-# ProofMut.cpp \
-# Context.cpp \
-# ContextMut.cpp \
-# Flag.cpp \
-# Flags.cpp \
-# FlagsMut.cpp \
-# Statistics.cpp \
-# StatisticsMut.cpp \
-# non-generated files
-SRC_CPP_FILES = src/cvc3/JniUtils.cpp
-# all cpp files (to compile)
-CPP_FILES = $(SRC_CPP_FILES) $(JNI_CPP_FILES)
-
-dist_libcvc4compatjni_la_SOURCES = $(SRC_CPP_FILES) include/cvc3/JniUtils.h
-nodist_libcvc4compatjni_la_SOURCES = $(JNI_CPP_FILES)
-
-EXTRA_DIST = \
- formula_value.h \
- create_impl.py \
- Cvc3_manifest \
- $(JNI_CPP_FILES:%.cpp=src/cvc3/%_impl.cpp) \
- $(JAVA_FILES:%=src/cvc3/%.java)
-
-# compile each cpp file
-$(JNI_CPP_FILES): %.cpp: src/cvc3/%_impl.cpp $(builddir)/cvc3/%.h include/cvc3/JniUtils.h
- $(AM_V_GEN)$(PYTHON) $(srcdir)/create_impl.py \
- cvc3/$*.h \
- $(srcdir)/src/cvc3/$*_impl.cpp \
- $*.cpp
-
-JniUtils.lo: src/cvc3/JniUtils.cpp .headers
- $(AM_V_CXX)$(LTCXXCOMPILE) -c $(JAVA_INCLUDES) $(JAVA_CPPFLAGS) -I . -o $@ $<
-%.lo: %.cpp .headers
- $(AM_V_CXX)$(LTCXXCOMPILE) -c $(JAVA_INCLUDES) $(JAVA_CPPFLAGS) -I . -o $@ $<
-
-$(LIB_FILES:%=classes/cvc3/%.class) classes/cvc3/JniUtils.class: .classes
-.classes:
- $(AM_V_GEN)mkdir -p classes && $(JAVAC) -source 1.6 -target 1.6 -sourcepath $(srcdir)/src -d classes $(LIB_FILES:%=$(srcdir)/src/cvc3/%.java)
- @touch .classes
-.headers: $(LIB_FILES:%=cvc3/%.h)
- @touch .headers
-$(LIB_FILES:%=cvc3/%.h): %.h: classes/%.class .cvc3dir
- $(AM_V_GEN)$(JAVAH) -jni -force -classpath classes -o $@ cvc3.$(@:cvc3/%.h=%)
-.cvc3dir:
- @mkdir -p cvc3 && touch $@
-CVC4compat.jar: $(LIB_FILES:%=classes/cvc3/%.class) classes/cvc3/JniUtils.class
- $(AM_V_GEN)$(JAR) cf $@ -C classes .
-
-clean-local:
- rm -fr classes cvc3
-MOSTLYCLEANFILES = .cvc3dir .classes .headers CVC4compat.jar $(JNI_CPP_FILES)
+++ /dev/null
-#!/usr/bin/env python
-
-import sys
-import os
-import re
-
-
-### output cpp file
-
-# qualifiers:
-# c : embedded constant
-# m : embedded mutable
-# n : native
-# plus:
-# v : vector
-# vv : vector vector
-# vvv : vector vector vector
-
-# types:
-# - native: void, bool, int, string
-# - objects: the rest
-
-def is_native(arg_qual):
- return (arg_qual[0] == 'n')
-
-def is_mutable(arg_qual):
- return (arg_qual[0] == 'm')
-
-def is_const(arg_qual):
- return (arg_qual[0] == 'c')
-
-def forall(p, s):
- for x in s:
- if not p(s):
- return False
-
- return True
-
-def check_arg_qual(arg_qual):
- return \
- (is_native(arg_qual) or is_mutable(arg_qual) or is_const(arg_qual)) \
- and \
- forall(lambda q: q == 'v', arg_qual[1:])
-
-def is_vector(arg_qual):
- return (len(arg_qual) > 1 and arg_qual[1] == 'v')
-
-def is_vector2(arg_qual):
- return (is_vector(arg_qual) and len(arg_qual) > 2 and arg_qual[2] == 'v')
-
-def is_vector3(arg_qual):
- return (is_vector2(arg_qual) and len(arg_qual) > 3 and arg_qual[3] == 'v')
-
-
-# returns the jni type corresponding to the pseudo type signature
-def arg_type_to_java(arg):
- arg_qual, arg_type, arg_name = arg
- check_arg_qual(arg_qual);
- if arg_type == "jobject":
- if (not is_native(arg_qual)) or is_vector(arg_qual):
- print("Error: native defined in implementation with qualifier: " + arg_qual)
- sys.exit(1)
- return "jobject"
- elif arg_type == "bool":
- if not is_native(arg_qual):
- print("Error: bool defined in implementation with qualifier: " + arg_qual)
- sys.exit(1)
- if is_vector(arg_qual):
- return "jbooleanArray"
- else:
- return "jboolean"
- elif arg_type == "int":
- if not is_native(arg_qual):
- print("Error: int defined in implementation with qualifier: " + arg_qual)
- sys.exit(1)
- if is_vector(arg_qual):
- return "jintArray"
- else:
- return "jint"
- elif arg_type == "string":
- if not is_native(arg_qual):
- print("Error: string defined in implementation with qualifier: " + arg_qual)
- sys.exit(1)
- if is_vector(arg_qual):
- return "jobjectArray"
- else:
- return "jstring"
- else:
- if is_vector(arg_qual):
- return "jobjectArray"
- else:
- return "jobject"
-
-def print_unembed_arg(cpp_file, arg):
- arg_qual, arg_type, arg_name = arg
- check_arg_qual(arg_qual);
- if arg_type == "jobject":
- ()
- elif arg_type == "bool":
- if is_vector3(arg_qual):
- cpp_file.write(" vector<vector<vector<bool> > > " + arg_name \
- + "(toCppVVV(env, j" + arg_name + "));\n");
- elif is_vector2(arg_qual):
- cpp_file.write(" vector<vector<bool> > " + arg_name \
- + "(toCppVV(env, j" + arg_name + "));\n");
- elif is_vector(arg_qual):
- cpp_file.write(" vector<bool> " + arg_name \
- + "(toCppV(env, j" + arg_name + "));\n");
- else:
- cpp_file.write(" bool " + arg_name + "(j" + arg_name + ");\n");
- elif arg_type == "int":
- if is_vector3(arg_qual):
- cpp_file.write(" vector<vector<vector<int> > > " + arg_name \
- + "(toCppVVV(env, j" + arg_name + "));\n");
- elif is_vector2(arg_qual):
- cpp_file.write(" vector<vector<int> > " + arg_name \
- + "(toCppVV(env, j" + arg_name + "));\n");
- elif is_vector(arg_qual):
- cpp_file.write(" vector<int> " + arg_name \
- + "(toCppV(env, j" + arg_name + "));\n");
- else:
- cpp_file.write(" int " + arg_name + "(j" + arg_name + ");\n");
- elif arg_type == "string":
- if is_vector3(arg_qual):
- cpp_file.write(" vector<vector<vector<string> > > " + arg_name \
- + "(toCppVVV(env, j" + arg_name + "));\n");
- elif is_vector2(arg_qual):
- cpp_file.write(" vector<vector<string> > " + arg_name \
- + "(toCppVV(env, j" + arg_name + "));\n");
- elif is_vector(arg_qual):
- cpp_file.write(" vector<string> " + arg_name \
- + "(toCppV(env, j" + arg_name + "));\n");
- else:
- cpp_file.write(" string " + arg_name + "(toCpp(env, j" + arg_name + "));\n");
- else:
- if is_vector3(arg_qual):
- cpp_file.write(" vector<vector<vector<" + arg_type + "> > > " + arg_name \
- + "(toCppVVV<" + arg_type + ">(env, j" + arg_name + "));\n");
- elif is_vector2(arg_qual):
- cpp_file.write(" vector<vector<" + arg_type + "> > " + arg_name \
- + "(toCppVV<" + arg_type + ">(env, j" + arg_name + "));\n");
- elif is_vector(arg_qual):
- cpp_file.write(" vector<" + arg_type + "> " + arg_name \
- + "(toCppV<" + arg_type + ">(env, j" + arg_name + "));\n");
- elif is_const(arg_qual):
- cpp_file.write(" const " + arg_type + "* " + arg_name \
- + " = unembed_const<" + arg_type + ">(env, j" + arg_name + ");\n");
- else:
- cpp_file.write(" " + arg_type + "* " + arg_name \
- + " = unembed_mut<" + arg_type + ">(env, j" + arg_name + ");\n");
-
-def print_unembed_args(cpp_file, args):
- for arg in args:
- print_unembed_arg(cpp_file, arg)
-
-
-# check that declaration and definition signatures match
-def match_signatures(decl, defn):
- decl_result, decl_args = decl
- def_result, def_args, _ = defn
- if decl_result != def_result or len(decl_args) != len(def_args):
- return False
- for i in range(0, len(decl_args)):
- java_type = arg_type_to_java(def_args[i])
- #print java_type
- if decl_args[i] != java_type:
- return False
- return True
-
-def print_header(cpp_file, includes):
- cpp_file.writelines(map(lambda name: "#include " + name + "\n", includes))
-
- cpp_file.writelines(
- [
- "#include \"JniUtils.h\"\n",
- "\n",
- "using namespace std;\n",
- "using namespace Java_cvc3_JniUtils;\n",
- "using namespace CVC3;\n",
- "\n"
- ])
-
-def print_signature(cpp_file, name, result, args):
- arg_strings = ["JNIEnv* env", "jclass"]
- arg_strings.extend( \
- map(lambda arg: \
- arg_type_to_java(arg) \
- + " j" + arg[2], args))
- cpp_file.writelines([
- "JNIEXPORT " + result + " JNICALL " + name + "\n",
- "(" + ", ".join(arg_strings) + ")\n"])
-
-def print_definition(cpp_file, name, defn):
- result, args, body = defn
- cpp_file.writelines(["extern \"C\"\n"])
- print_signature(cpp_file, name, result, args)
- cpp_file.writelines([
- "{\n",
- " try {\n"])
- print_unembed_args(cpp_file, args)
- cpp_file.writelines([
- " " + " ".join(body),
- " } catch (const Exception& e) {\n",
- " toJava(env, e);\n"])
- if result in [ "jobject", "jobjectArray", "jstring" ]:
- cpp_file.writelines([" return NULL;\n"])
- elif result == "jboolean":
- cpp_file.writelines([" return false;\n"])
- elif result == "jint":
- cpp_file.writelines([" return -1;\n"])
- elif result != "void":
- print("BUG: return type " + result + " is not handled in print_definition")
- sys.exit(1)
- cpp_file.writelines([" };\n",
- "}\n\n"])
-
-def print_cpp(cpp_name, declarations, definitions, includes):
- try:
- cpp_file = open(cpp_name, 'w')
-
- print_header(cpp_file, includes)
-
- #names = declarations.keys()
- #names.sort()
- for name in declarations[0]:
- if name not in definitions:
- #continue
- print("Error: " + name + " is declared in header" \
- + " but not defined in implementation.")
- sys.exit(1)
-
- declaration = declarations[1][name]
- definition = definitions[name]
- definitions.pop(name)
- if not match_signatures(declaration, definition):
- print("Error: signature for " + name \
- + " in definition and implementation do not match:")
- print(declaration)
- print (definition[0], definition[1])
- sys.exit(1)
-
- print_definition(cpp_file, name, definition)
-
- if not len(definitions) == 0:
- print("Error: found definitions in implementation" \
- " without declaration in header file:")
- print(definitions)
- sys.exit(1)
-
-
- except IOError as err:
- error_nr, error_string = err
- print ("Couldn't open " + cpp_name + ": " + error_string)
- sys.exit(1)
-
-
-### header file function declarations
-
-# header file function declaration:
-# - name: function name
-# - result: result type
-# - args: list of argument types, except for the first two (JNIEnv*, jclass)
-def register_declaration(declarations, name, result, args):
- assert(name not in declarations[1]);
- declarations[0].append(name)
- declarations[1][name] = (result, args)
-
-# extract function signatures from generated JNI header file
-def read_header(header_name):
- # 0.: names of declared functions in same order as in input
- # 1.: map from names to signature
- declarations = ([], {})
- try:
- header_file = open(header_name)
-
- line = header_file.readline()
- while (line):
- # look for start of signature
- # declaration will look like:
- # JNIEXPORT <result> JNICALL <name> (JNIENV *env, jclass, jobject);
- # with an optional linebreak before the parameter list, and
- # perhaps missing the "env"
- if re.search("^JNIEXPORT", line):
- # extract name and return type
- elements = re.sub('[,();]+',' ',line).split();
- assert(elements[0] == "JNIEXPORT");
- assert(elements[2] == "JNICALL");
- name = elements[3]
- result = elements[1]
-
- # If there are no more elements on this line,
- # read and tokenize the next line
- if len(elements) > 4:
- elements = elements[4:]
- else:
- line = header_file.readline ()
- elements = re.sub('[,();]+',' ',line).split();
-
- # extract argument types
- assert(elements[0] == "JNIEnv");
- assert(elements[1] == "*" or elements[1] == "*env");
- assert(elements[2] == "jclass")
- args = elements[3:]
-
- register_declaration(declarations, name, result, args)
-
- line = header_file.readline ()
-
- header_file.close()
-
-
- except IOError as err:
- error_nr, error_string = err
- print ("Couldn't open " + header_name + ": " + error_string)
- sys.exit(1)
-
- return declarations
-
-
-
-
-# function definitions:
-
-# cpp file function definition:
-# - name: function name
-# - result: result type
-# - args: list of pairs of argument types and argument names,
-# except for the first two (JNIEnv*, jclass)
-def register_definition(definitions, name, result, args, body):
- if name in definitions:
- print("Error: redefinition of " + name + " in implementation.")
- sys.exit(1)
-
- definitions[name] = (result, args, body)
- #print_definition(name, declarations[name])
-
-# extract function definition from implementation file
-def read_impl(impl_name):
- definitions = {}
- includes = []
- try:
- impl_file = open(impl_name)
-
- line = impl_file.readline()
- while (line):
- # look for include
- if re.search("^INCLUDE:", line):
- elements = line.split();
- assert(len(elements) == 2);
- assert(elements[0] == "INCLUDE:")
- includes.append(elements[1])
- line = impl_file.readline()
-
- #print line
- # look for start of definition
- elif re.search("^DEFINITION:", line):
- #print line,
- # get name
- elements = line.split();
- if not (len(elements) == 2):
- print("Error: misformed signature: " + line)
- sys.exit(1)
-
- assert(elements[0] == "DEFINITION:")
- name = elements[1]
-
- # get signature
- line = impl_file.readline ()
- elements = line.split();
- assert(len(elements) > 0);
- if not (len(elements) % 3 == 1):
- print("Error: misformed signature for: " + name)
- print(line)
- sys.exit(1)
- result = elements.pop(0)
- args = []
- while len(elements) > 0:
- argQual = elements.pop(0)
- argType = elements.pop(0)
- argName = elements.pop(0)
- args.append((argQual, argType, argName))
-
- # get body
- body = []
- line = impl_file.readline ()
- while line and not re.search("^DEFINITION:", line):
- body.append(line)
- line = impl_file.readline()
-
- while body and body[len(body) - 1] == "\n":
- body.pop(len(body) - 1)
- assert(len(body) > 0)
-
- register_definition(definitions, name, result, args, body)
-
- else:
- line = impl_file.readline()
-
- impl_file.close()
-
- except IOError as err:
- error_nr, error_string = err
- print ("Couldn't open " + impl_name + ": " + error_string)
- sys.exit(1)
-
- return definitions, includes
-
-
-# read name of input file
-if (len(sys.argv) != 4):
- print("Expected path to header, implementation, and target file.")
- print("")
- print("./create_impl.py <H_FILE> <IMPL_FILE> <CPP_FILE>")
-
- sys.exit(0)
-
-else:
- #print(sys.argv)
- header_name = sys.argv[1]
- impl_name = sys.argv[2]
- cpp_file = sys.argv[3]
-
- # extract information from header
- declarations = read_header(header_name)
- #print declarations
-
- # extract information from template
- definitions, includes = read_impl(impl_name)
- #print definitions
-
- # create implementation
- print_cpp(cpp_file, declarations, definitions, includes)
+++ /dev/null
-/*****************************************************************************/
-/*!
- *\file formula_value.h
- *\brief enumerated type for value of formulas
- *
- * Author: Alexander Fuchs
- *
- * Created: Fri Dec 07 08:00:00 2007
- *
- * <hr>
- *
- * License to use, copy, modify, sell and/or distribute this software
- * and its documentation for any purpose is hereby granted without
- * royalty, subject to the terms and conditions defined in the \ref
- * LICENSE file provided with this distribution.
- *
- * <hr>
- */
-/*****************************************************************************/
-
-#ifndef _cvc3__include__formulavalue_h_
-#define _cvc3__include__formulavalue_h_
-
-namespace CVC3 {
-
-/*****************************************************************************/
-/*
- * Type for truth value of formulas.
- */
-/*****************************************************************************/
-typedef enum FormulaValue {
- TRUE_VAL,
- FALSE_VAL,
- UNKNOWN_VAL
-} FormulaValue;
-
-}
-
-#endif
+++ /dev/null
-#ifndef _java__cvc3__jni_utils_h_
-#define _java__cvc3__jni_utils_h_
-
-#include <cassert>
-#include <string>
-#include <jni.h>
-#include <typeinfo>
-#include "compat/cvc3_compat.h"
-//#include "vcl.h"
-//#include "hash_map.h"
-//#include "exception.h"
-
-#define DebugAssert(cond, str) assert(cond)
-
-namespace Java_cvc3_JniUtils {
-
- /// Embedding of c++ objects in java objects
-
- // generic delete function for any type T
- template <class T> class DeleteEmbedded {
- public:
- static void deleteEmbedded(void* cobj) {
- delete (T*) cobj;
- }
- };
-
- typedef void (*TDeleteEmbedded)(void*);
-
-
- // Encapsulates a c++ object so that:
- // - (un)embedding casting is type safe
- // - deallocation is automatic (if needed)
- // This has probably quit a bit of overhead, because now for each
- // wrapper object (even if only a temporary reference) an instance
- // of Embedded is created.
- // But considering the above two benefits it should be worth it
- // because it should simplify maintenance quite a bit,
- // as changes in the cvc API should lead to assertion failures
- // instead of strange bugs.
- class Embedded {
- private:
- // the actual embedded c++ object,
- // as void* to make Embedded independent of its type
- void* d_cobj;
-
- // the type info of d_cobj,
- // to make sure that later unembeddings are type safe
- // actually only needed in debugging, so might be guarded with IF_DEBUG
- const std::type_info& d_typeInfo;
-
- // the type correct delete function for d_cobj,
- // or NULL if this embedding is merely a reference
- // and not responsible for its deallocation
- TDeleteEmbedded d_delete;
-
- public:
- Embedded(void* cobj, const std::type_info& ti, TDeleteEmbedded del) :
- d_cobj(cobj), d_typeInfo(ti), d_delete(del) {
- assert(d_cobj != NULL);
- }
-
- ~Embedded() {
- assert(d_cobj != NULL);
- if (d_delete != NULL) d_delete(d_cobj);
- }
-
- const void* getCObj() const {
- return d_cobj;
- }
-
- const std::type_info& getType() const {
- return d_typeInfo;
- }
- };
-
-
-
- // embed functions
-
- // embeds a c++ object of type T into a jobject
- // by first wrapping it into an Embedded object.
- template <class T> jobject embed(JNIEnv* env, T* cobj, const std::type_info& ti,
- TDeleteEmbedded del) {
- DebugAssert(cobj != NULL, "JniUtils::embed: null object given");
- Embedded* embedded = new Embedded((void*)cobj, ti, del);
- return (jobject)env->NewDirectByteBuffer(embedded, sizeof(Embedded));
- }
-
- // embeds a constant reference to a c++ object into a jobject
- template <class T> jobject embed_const_ref(JNIEnv* env, const T* cobj) {
- DebugAssert(cobj != NULL, "JniUtils::embed_const: null object given");
- return embed<T>(env, (T*) cobj, typeid(cobj), NULL);
- }
-
- // embeds a mutable reference to a c++ object into a jobject
- template <class T> jobject embed_mut_ref(JNIEnv* env, T* cobj) {
- DebugAssert(cobj != NULL, "JniUtils::embed_mut_ref: null object given");
- return embed<T>(env, (T*) cobj, typeid(cobj), NULL);
- }
-
- // embeds a fresh copy of a (probably temporary) c++ object into a jobject
- template <class T> jobject embed_copy(JNIEnv* env, const T& cobj) {
- DebugAssert(&cobj != NULL, "JniUtils::embed_copy: null object given");
- T* copy = new T(cobj);
- assert(copy != NULL);
- return embed<T>(env, copy, typeid(copy), &DeleteEmbedded<T>::deleteEmbedded);
- }
-
- // embeds a c++ object into a jobject,
- // and takes over the responsibility to deallocate it
- template <class T> jobject embed_own(JNIEnv* env, T* cobj) {
- DebugAssert(cobj != NULL, "JniUtils::embed_own: null object given");
- return embed<T>(env, cobj, typeid(cobj), &DeleteEmbedded<T>::deleteEmbedded);
- }
-
-
- // unembed functions
-
- // extract Embedded* from a jobject
- Embedded* unembed(JNIEnv* env, jobject jobj);
-
- // extract a constant c++ object of type T from a jobject
- template <class T> const T* unembed_const(JNIEnv* env, jobject jobj) {
- Embedded* embedded = unembed(env, jobj);
- return (const T*) embedded->getCObj();
- }
-
- // extract a mutable c++ object of type T from a jobject
- template <class T> T* unembed_mut(JNIEnv* env, jobject jobj) {
- Embedded* embedded = unembed(env, jobj);
- // check that the wrapped object is not const
- DebugAssert(embedded->getType() == typeid(T*),
- "JniUtils::unembed_mut: type mismatch");
- return (T*) embedded->getCObj();
- }
-
-
- // delete embedded
-
- // delete the Embedded object contained in a jobject,
- // and also destruct the wrapped c++ object if necessary.
- void deleteEmbedded(JNIEnv* env, jobject jobj);
-
-
-
-
- /// Conversions between c++ and java
-
- // bool
- bool toCpp(jboolean j);
-
- // string
- jstring toJava(JNIEnv* env, const std::string& cstring);
- jstring toJava(JNIEnv* env, const char* cstring);
- std::string toCpp(JNIEnv* env, const jstring& string);
-
- // enums
- jstring toJava(JNIEnv* env, CVC3::QueryResult result);
- jstring toJava(JNIEnv* env, CVC3::FormulaValue result);
- jstring toJava(JNIEnv* env, CVC3::InputLanguage result);
- CVC3::InputLanguage toCppInputLanguage(JNIEnv* env, const std::string& lang);
-
- // exceptions
- void toJava(JNIEnv* env, const CVC3::Exception& e);
-
- // vectors
- template <class T> jobjectArray toJavaVCopy(JNIEnv* env, const std::vector<T>& v) {
- jobjectArray jarray = (jobjectArray)
- env->NewObjectArray(
- v.size(),
- env->FindClass("java/lang/Object"),
- NULL);
-
- for (size_t i = 0; i < v.size(); ++i) {
- env->SetObjectArrayElement(jarray, i, embed_copy<T>(env, v[i]));
- }
-
- return jarray;
- }
-
- template <class T> jobjectArray toJavaVConstRef(JNIEnv* env, const std::vector<T>& v) {
- jobjectArray jarray = (jobjectArray)
- env->NewObjectArray(
- v.size(),
- env->FindClass("java/lang/Object"),
- NULL);
-
- for (size_t i = 0; i < v.size(); ++i) {
- env->SetObjectArrayElement(jarray, i, embed_const_ref<T>(env, &v[i]));
- }
-
- return jarray;
- }
-
- template<class T>
- jobjectArray
- toJavaVVConstRef(JNIEnv* env, const std::vector<std::vector<T> >& v)
- {
- jobjectArray jarray = (jobjectArray) env->NewObjectArray(v.size(),
- env->FindClass("[Ljava/lang/Object;"), NULL);
- for (size_t i = 0; i < v.size(); ++i)
- {
- env->SetObjectArrayElement(jarray, i, toJavaVConstRef(env, v[i]));
- }
- return jarray;
- }
-
- template <class T> std::vector<T> toCppV(JNIEnv* env, const jobjectArray& jarray) {
- std::vector<T> v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- v.push_back(*unembed_const<T>(env, env->GetObjectArrayElement(jarray, i)));
- }
- return v;
- }
-
- template <class T> std::vector<std::vector<T> > toCppVV(JNIEnv* env, const jobjectArray& jarray) {
- std::vector<std::vector<T> > v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- jobjectArray jsub = static_cast<jobjectArray>(env->GetObjectArrayElement(jarray, i));
- v.push_back(toCppV<T>(env, jsub));
- }
- return v;
- }
-
- template <class T> std::vector<std::vector<std::vector<T> > >
- toCppVVV(JNIEnv* env, const jobjectArray& jarray) {
- std::vector<std::vector<std::vector<T> > > v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- jobjectArray jsub = static_cast<jobjectArray>(env->GetObjectArrayElement(jarray, i));
- v.push_back(toCppVV<T>(env, jsub));
- }
- return v;
- }
-
- // string vectors
- std::vector<std::string> toCppV(JNIEnv* env, const jobjectArray& jarray);
- std::vector<std::vector<std::string> > toCppVV(JNIEnv* env, const jobjectArray& jarray);
- std::vector<std::vector<std::vector<std::string> > > toCppVVV(JNIEnv* env, const jobjectArray& jarray);
- jobjectArray toJavaV(JNIEnv* env, const std::vector<std::string>& v);
-
- // primitive vectors
- std::vector<bool> toCppV(JNIEnv* env, const jbooleanArray& jarray);
-
-
- // hash map
- /*template <class K, class V> jobjectArray toJavaHCopy(JNIEnv* env, const Hash::hash_map<K, V>& hm) {
- jobjectArray jarray = (jobjectArray)
- env->NewObjectArray(
- hm.size() * 2,
- env->FindClass("java/lang/Object"),
- NULL);
-
- int i = 0;
- typename Hash::hash_map<K, V>::const_iterator it;
- for (it = hm.begin(); it != hm.end(); ++it) {
- assert(i < env->GetArrayLength(jarray));
- env->SetObjectArrayElement(jarray, i, embed_copy<K>(env, it->first));
- ++i;
- assert(i < env->GetArrayLength(jarray));
- env->SetObjectArrayElement(jarray, i, embed_copy<V>(env, it->second));
- ++i;
- }
- return jarray;
- }*/
-
- template <class V> jobjectArray toJavaHCopy(JNIEnv* env, const CVC3::ExprMap<V>& hm) {
- jobjectArray jarray = (jobjectArray)
- env->NewObjectArray(
- hm.size() * 2,
- env->FindClass("java/lang/Object"),
- NULL);
-
- int i = 0;
- typename CVC3::ExprMap<V>::const_iterator it;
- for (it = hm.begin(); it != hm.end(); ++it) {
- assert(i < env->GetArrayLength(jarray));
- env->SetObjectArrayElement(jarray, i, embed_copy<CVC3::Expr>(env, it->first));
- ++i;
- assert(i < env->GetArrayLength(jarray));
- env->SetObjectArrayElement(jarray, i, embed_copy<V>(env, it->second));
- ++i;
- }
- return jarray;
- }
-
-}
-
-
-#endif
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::CLException */
-class CLException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public CLException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Context extends Embedded {
- // jni methods
-
- /// Constructor
-
- public Context(Object Context, EmbeddedManager embeddedManager) {
- super(Context, embeddedManager);
- }
-
-
- /// API (immutable)
-
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class ContextMut extends Context {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public ContextMut(Object ContextMut, EmbeddedManager embeddedManager) {
- super(ContextMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-class Cvc3 {
- static boolean useObjManager = false;
-
- static void timeoutHandler(Object o) {
- System.out.println("self-timeout.");
- System.exit(1);
- }
-
- public static void main(String args[]) throws Cvc3Exception {
-
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
-
- // parse input
- String fileName = "";
- try {
- fileName = parse_args(args, flags);
- } catch(CLException e) {
- System.err.print("*** " + e);
- System.err.println("\n\nRun with -help option for usage information.");
- System.exit(1);
- }
-
- // Set the timeout, if given in the command line options
- int timeout = flags.getFlag("timeout").getInt();
- if (timeout > 0) {
- new Timer().schedule(new TimeoutHandler(), timeout * 1000);
- }
-
- /*
- * Create and run the validity checker
- */
-
- // Debugging code may throw an exception
- vc = ValidityChecker.create(flags);
- flags.delete();
-
- // -h flag sets "help" to false (+h would make it true, but that's
- // not what the user normally types in).
- if(!vc.getFlags().getFlag("help").getBool()) {
- String programName = "cvc3"; //:TODO:
- printUsage(vc.getFlags(), programName);
- System.exit(0);
- }
-
- // Similarly, -version sets the flag "version" to false
- if(!vc.getFlags().getFlag("version").getBool()) {
- System.out.println("This is CVC3 version " + "UNKNOWN"); //:TODO:
- System.out.println("Copyright (C) 2003-2006 by the Board of Trustees of Leland Stanford Junior");
- System.out.println("University, New York University, and the University of Iowa.");
- System.out.println();
- System.out.print("THIS SOFTWARE PROVIDED AS-IS, WITHOUT ANY WARRANTIES. ");
- System.out.println("USE IT AT YOUR OWN RISK.");
- System.out.println();
- System.exit(0);
- }
-
- // Test if the output language is correctly specified; if not, an
- // exception will be thrown
- vc.getExprManager().getOutputLanguage();
- // Read the input file
- vc.loadFile(fileName, vc.getExprManager().getInputLanguage());
-
- // Print statistics
- if (vc.getFlags().getFlag("stats").getBool()) {
- vc.printStatistics();
- }
- } catch (Cvc3Exception e) {
- System.err.println("*** Fatal exception: " + e);
- System.exit(1);
- } finally {
- if (flags != null) flags.delete();
- if (vc != null) vc.delete();
- }
-
- // to avoid waiting for timer to finish
- System.exit(0);
- }
-
-
-
- // evaluates command line flags, returns problem file name
- public static String parse_args(String[] args, FlagsMut flags) throws Cvc3Exception {
- // keep track that exactly one file name is given
- String fileName = "";
- boolean seenFileName = false;
-
- // iterate over the arguments
- for (int i = 0; i < args.length; ++i) {
- String arg = args[i];
-
- // A command-line option
- if (arg.startsWith("-") || arg.startsWith("+")) {
- List names = flags.getFlags(arg.substring(1));
-
- // no match
- if (names.size() == 0)
- throw new CLException(arg + " does not match any known option");
-
- // ambiguous
- else if (names.size() > 1) {
- StringBuffer s = new StringBuffer();
- s.append(arg + " is ambiguous. Possible matches are:\n");
- for (Iterator name = names.iterator(); name.hasNext(); ) {
- s.append(" " + name.next() + "\n");
- }
- throw new CLException(s.toString());
- }
-
- // Single match; process the option by name, type, and parameters
- else {
- String name = (String) names.iterator().next();
- boolean val = arg.startsWith("+");
- Flag flag = flags.getFlag(name);
-
- if (flag.isBool()) {
- flags.setFlag(name, val);
- }
-
- else if (flag.isInt()) {
- ++i;
- if (i >= args.length)
- throw new CLException (arg + " (-" + name + ") expects an integer argument.");
- int parameter = Integer.parseInt(args[i]);
- flags.setFlag(name, parameter);
- }
-
- else if (flag.isString()) {
- ++i;
- if (i >= args.length)
- throw new CLException (arg + " (-" + name + ") expects a string argument.");
- flags.setFlag(name, args[i]);
- }
-
- // else if (flag.isStringVec())
- // {
- // bool hasMore = iter.MoveNext();
- // if (!hasMore)
- // {
- // throw new CLException
- // (arg + " (-" + name + ") expects a string argument.");
- // }
- // flags.setFlag(name, (string)iter.Current, val);
- // }
-
- else {
- throw new CLException("parse_args: Bad flag : " + name);
- }
- }
- }
-
- // no flag, so should be a file name
- // second no flag argument
- else if(seenFileName) {
- throw new CLException("More than one file name given: " + fileName + " and " + arg);
- }
-
- // first no flag argument
- else {
- fileName = arg;
- seenFileName = true;
- }
- }
-
- return fileName;
- }
-
-
- public static void printUsage(Flags flags, String programName) throws Cvc3Exception {
- System.out.println("Usage: " + programName + " [options]");
- System.out.println(programName + " will read the input from STDIN and ");
- System.out.println("print the result on STDOUT.");
- System.out.println("Boolean (b) options are set 'on' by +option and 'off' by -option");
- System.out.println("(for instance, +sat or -sat).");
- System.out.println("Integer (i), string (s) and vector (v) options ");
- System.out.println("require a parameter, e.g. -width 80");
- System.out.println("Also, (v) options can appear multiple times setting args on and off,");
- System.out.println("as in +trace \"enable this\" -trace \"disable that\".");
- System.out.println("Option names can be abbreviated to the shortest unambiguous prefix.");
- System.out.println();
- System.out.println("The options are:");
-
- // Get all the names of options (they all match the empty string)
- List names = flags.getFlags("");
- for (Iterator i = names.iterator(); i.hasNext(); ) {
- String name = (String) i.next();
- Flag flag = flags.getFlag(name);
- String prefix = "";
- if (flag.isNull()) {
- prefix = " (null)";
- }
- else if (flag.isBool()) {
- String enabled = flag.getBool() ? "+" : "-";
- prefix = " (b) " + enabled + name;
- }
- else if (flag.isInt()) {
- prefix = " (i) -" + name + " " + flag.getInt();
- }
- else if (flag.isString()) {
- prefix = " (s) -" + name + " " + flag.getString();
- }
- else if (flag.isStringVec()) {
- prefix = " (s) -" + name;
- }
- else {
- assert(false);
- }
-
- while (prefix.length() < 21) {
- prefix += " ";
- }
- System.out.println(prefix + " " + flag.getHelp());
- }
- System.out.println();
- }
-}
+++ /dev/null
-package cvc3;
-
-
-/** mirrors CVC3::Exception */
-public class Cvc3Exception extends RuntimeException {
-
- private final static long serialVersionUID = 1L;
-
- public Cvc3Exception(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::DebugException */
-public class DebugException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public DebugException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-import java.io.*;
-
-/** Wrapper for a c++ object as a java Object.
-
- see README for details on garbage collection,
- i.e. interplay of delete, finalize, and EmbeddedManager to destruct
- the embedded c++ object. */
-public abstract class Embedded {
-
- // load jni c++ library
- static {
- System.loadLibrary("cvc4");
- System.loadLibrary("cvc4parser");
- System.loadLibrary("cvc4compatjni");
-
- /*
- // for debugging: stop here by waiting for a key press,
- // and attach c++ debugger
- System.out.println("Loadded cvc3jni");
-
- try {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- br.readLine();
- } catch (IOException ioe) {
- }
- */
- }
-
-
- /// Attributes
-
-
- // embedded object
- protected Object d_embedded;
-
- // embedded object manager
- private final EmbeddedManager d_embeddedManager;
-
-
- /// Constructor
-
-
- // initialize with embedded object and EmbeddedManager
- // if EmbeddedManager is null then delete must be called before
- // Embedded is garbage collected
- protected Embedded(Object Embedded, EmbeddedManager embeddedManager) {
- //System.out.println("Create: Embedded");
- assert(Embedded != null);
- d_embedded = Embedded;
- d_embeddedManager = embeddedManager;
- }
-
- // access to embedded c++ object
- public synchronized Object embedded() {
- return d_embedded;
- }
-
- // access to EmbeddedManager (might be null if none used)
- public EmbeddedManager embeddedManager() {
- return d_embeddedManager;
- }
-
- // check if already destructed
- // (or queued for destruction in embeddedManager)
- public synchronized boolean isDeleted() {
- return (d_embedded == null);
- }
-
- // delete embedded object or enqueue it for deletion
- public synchronized void delete() throws Cvc3Exception {
- if (isDeleted()) return;
-
- // no embedded manager, so should be in main thread:
- // destruct right away
- if (d_embeddedManager == null) {
- EmbeddedManager.jniDelete(d_embedded);
- }
- // could be in finalizer, so queue in embeddedManager;
- // unless the embeddedManager is already deleted,
- // then its (and this') ValidityChecker has been delete.
- // assuming this is an Expr or a Theorem it's embedded object
- // has then already been deleted as well.
- else {
- synchronized(d_embeddedManager) {
- if (!d_embeddedManager.isDeleted()) {
- d_embeddedManager.register(this);
- }
- }
- }
- d_embedded = null;
- }
-
- // ensure that delete is called if finalization occurs
- public void finalize() throws Throwable {
- try {
- // no embeddedManager, so deleted should have been called
- if (d_embeddedManager == null) {
- if (d_embedded != null) {
- assert(false);
-// System.out.println("Embedded.Finalizer: should never be called");
- throw new Error("Embedded.Finalizer: should never be called");
- }
- }
- else if (!d_embeddedManager.isDeleted()) {
- delete();
- }
- } finally {
- super.finalize();
- }
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** Helps to enforce deallocation of a set of embedded objects
-
- See also Embedded.java
-
- Cvc3 requires on the C++ level that the ValidityChecker is destructed
- last, after all other Cvc3 objects (i.e. subclasses of Embedded).
-
- A 'simple' (but not too cheap) way to achieve this effect of deterministic
- deallocation in Java without introducing much error prone code is to
- register all embedded objects (except for the ValidityChecker)
- with an EmbeddedManager.
-
- When the ValidityChecker is deleted/finalized it uses the EmbeddedManager
- to destruct all other Cvc3 objects first.
-*/
-public class EmbeddedManager {
- // jni methods
-
- // call the destructor of the c++ object
- public static native void jniDelete(Object Embedded) throws Cvc3Exception;
-
-
- // c++ objects which have been registered for deletion
- private List d_deleted;
-
-
- /// Constructor
-
- // delete must be called before EmbeddedManager is garbage collected
- public EmbeddedManager() {
- d_deleted = new ArrayList();
- }
-
-
- /// Methods
-
- // true iff delete has been called
- public synchronized boolean isDeleted() {
- return (d_deleted == null);
- }
-
- // signals that the ValidityChecker destructs itself
- public synchronized void delete() throws Cvc3Exception {
- d_deleted = null;
- }
-
- // registers a c++ object for deletion
- public synchronized void register(Embedded embedded) {
- d_deleted.add(embedded.embedded());
- }
-
- // destruct all registered objects
- public synchronized void cleanUp() throws Cvc3Exception {
- assert(!isDeleted());
- Iterator i = d_deleted.iterator();
- while (i.hasNext()) {
- jniDelete(i.next());
- }
- d_deleted.clear();
- }
-
- // ensure that all embedded objects are deallocated eventually
- public void finalize() throws Throwable {
- try {
- if (!isDeleted()) {
- assert(false);
-// System.out.println("EmbeddedManager.Finalizer: should never be called");
- throw new Error("EmbeddedManager.Finalizer: should never be called");
- }
- } finally {
- super.finalize();
- }
- }
-}
+++ /dev/null
-DEFINITION: Java_cvc3_EmbeddedManager_jniDelete
-void n jobject obj
-deleteEmbedded(env, jobj);
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::EvalException */
-public class EvalException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public EvalException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Expr extends Embedded {
- // jni methods
- private static native boolean
- jniEquals(Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native String
- jniToString(Object Expr) throws Cvc3Exception;
- private static native void
- jniPrint(Object Expr, String InputLanguage, boolean dagify) throws Cvc3Exception;
- private static native int
- jniHash(Object Expr) throws Cvc3Exception;
-
- private static native String
- jniGetKind(Object Expr) throws Cvc3Exception;
-
- private static native boolean
- jniIsFalse(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsTrue(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBoolConst(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsVar(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBoundVar(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsString(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsClosure(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsQuantifier(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsLambda(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsApply(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsSymbol(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsTheorem(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsType(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsTerm(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsAtomic(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsAtomicFormula(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsAbsAtomicFormula(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsLiteral(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsAbsLiteral(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBoolConnective(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsPropAtom(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsPropLiteral(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsArrayLiteral(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsEq(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsNot(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsAnd(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsOr(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsITE(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsIff(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsImpl(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsXor(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsForall(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsExists(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsRational(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsUminus(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsPlus(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsMinus(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsMult(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsPow(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsDivide(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsLt(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsLe(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsGt(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsGe(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsSkolem(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsRead(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsWrite(Object Expr) throws Cvc3Exception;
-
- private static native String
- jniGetName(Object Expr) throws Cvc3Exception;
- private static native String
- jniGetUid(Object Expr) throws Cvc3Exception;
- private static native String
- jniGetString(Object Expr) throws Cvc3Exception;
- private static native Object[]
- jniGetVars(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetExistential(Object Expr) throws Cvc3Exception;
- private static native int
- jniGetBoundIndex(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetBody(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetRational(Object Expr) throws Cvc3Exception;
- private static native Object[][]
- jniGetTriggers(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetTheorem(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetType(Object Expr) throws Cvc3Exception;
- private static native Object
- jniMkOp(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetOp(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetOpExpr(Object Expr) throws Cvc3Exception;
-
- private static native boolean
- jniIsNull(Object Expr) throws Cvc3Exception;
- private static native int
- jniArity(Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetKid(Object Expr, int i) throws Cvc3Exception;
- private static native Object[]
- jniGetKids(Object Expr) throws Cvc3Exception;
-
- private static native Object
- jniSubstExpr(Object Expr, Object[] oldExprs, Object[] newExprs) throws Cvc3Exception;
-
- private static native boolean
- jniIsBvLt(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvLe(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvGt(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvGe(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvPlus(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvSub(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvConst(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvExtract(Object Expr) throws Cvc3Exception;
- private static native boolean
- jniIsBvConcat(Object Expr) throws Cvc3Exception;
-
-
- /// Constructor
-
- public Expr(Object Expr, EmbeddedManager embeddedManager) {
- super(Expr, embeddedManager);
- }
-
-
- /// API (immutable)
-
-
- // 'Problem' with equals/hashCode:
- // this is based on the wrapped c++ expressions.
- // as a consequence two Expr objects are equal iff
- // the wrapped expression is equal,
- // and are indistinguishable for example in a HashMap.
-
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (!(o instanceof Expr)) return false;
- boolean result = false;
- try {
- result = jniEquals(embedded(), ((Embedded)o).embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- // must return the same hash code for two objects if equals returns true
- public int hashCode() {
- try {
- if (!jniIsNull(embedded())) {
- return jniHash(embedded());
- }
- } catch (Cvc3Exception e) {
- assert(false);
- }
- assert(false);
- return 0;
- }
-
- public Expr subst(List oldExprs, List newExprs) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(oldExprs, Expr.class));
- assert(JniUtils.listInstanceof(newExprs, Expr.class));
- return new Expr(jniSubstExpr(embedded(), JniUtils.unembedList(oldExprs),
- JniUtils.unembedList(newExprs)), embeddedManager());
- }
-
- public String toString() {
- String result = "";
- try {
- result = jniToString(embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- public void print(InputLanguage lang, boolean dagify) throws Cvc3Exception {
- jniPrint(embedded(), lang.toString(), dagify);
- }
-
- public void print(boolean dagify) throws Cvc3Exception {
- print(InputLanguage.PRESENTATION, dagify);
- }
-
- public void print() throws Cvc3Exception {
- print(false);
- }
-
- public String getKind() throws Cvc3Exception {
- return jniGetKind(embedded());
- }
-
- // Core expression testers
-
-
- public boolean isFalse() throws Cvc3Exception {
- return jniIsFalse(embedded());
- }
-
- public boolean isTrue() throws Cvc3Exception {
- return jniIsTrue(embedded());
- }
-
- public boolean isBooleanConst() throws Cvc3Exception {
- return jniIsBoolConst(embedded());
- }
-
- public boolean isVar() throws Cvc3Exception {
- return jniIsVar(embedded());
- }
-
- public boolean isBoundVar() throws Cvc3Exception {
- return jniIsBoundVar(embedded());
- }
-
- public boolean isString() throws Cvc3Exception {
- return jniIsString(embedded());
- }
-
- public boolean isClosure() throws Cvc3Exception {
- return jniIsClosure(embedded());
- }
-
- public boolean isQuantifier() throws Cvc3Exception {
- return jniIsQuantifier(embedded());
- }
-
- public boolean isLambda() throws Cvc3Exception {
- return jniIsLambda(embedded());
- }
-
- public boolean isApply() throws Cvc3Exception {
- return jniIsApply(embedded());
- }
-
- public boolean isSymbol() throws Cvc3Exception {
- return jniIsSymbol(embedded());
- }
-
- public boolean isTheorem() throws Cvc3Exception {
- return jniIsTheorem(embedded());
- }
-
- public boolean isType() throws Cvc3Exception {
- return jniIsType(embedded());
- }
-
-
-
-
- public boolean isTerm() throws Cvc3Exception {
- return jniIsTerm(embedded());
- }
-
- public boolean isAtomic() throws Cvc3Exception {
- return jniIsAtomic(embedded());
- }
-
- public boolean isAtomicFormula() throws Cvc3Exception {
- return jniIsAtomicFormula(embedded());
- }
-
- public boolean isAbsAtomicFormula() throws Cvc3Exception {
- return jniIsAbsAtomicFormula(embedded());
- }
-
- public boolean isLiteral() throws Cvc3Exception {
- return jniIsLiteral(embedded());
- }
-
- public boolean isAbsLiteral() throws Cvc3Exception {
- return jniIsAbsLiteral(embedded());
- }
-
- public boolean isBoolConnective() throws Cvc3Exception {
- return jniIsBoolConnective(embedded());
- }
-
- public boolean isPropAtom() throws Cvc3Exception {
- return jniIsPropAtom(embedded());
- }
-
- public boolean isPropLiteral() throws Cvc3Exception {
- return jniIsPropLiteral(embedded());
- }
-
- public boolean isArrayLiteral() throws Cvc3Exception {
- return jniIsArrayLiteral(embedded());
- }
-
- public boolean isEq() throws Cvc3Exception {
- return jniIsEq(embedded());
- }
-
- public boolean isNot() throws Cvc3Exception {
- return jniIsNot(embedded());
- }
-
-
- public boolean isAnd() throws Cvc3Exception {
- return jniIsAnd(embedded());
- }
-
-
- public boolean isOr() throws Cvc3Exception {
- return jniIsOr(embedded());
- }
-
-
- public boolean isITE() throws Cvc3Exception {
- return jniIsITE(embedded());
- }
-
-
- public boolean isIff() throws Cvc3Exception {
- return jniIsIff(embedded());
- }
-
-
- public boolean isImpl() throws Cvc3Exception {
- return jniIsImpl(embedded());
- }
-
-
- public boolean isXor() throws Cvc3Exception {
- return jniIsXor(embedded());
- }
-
-
- public boolean isForall() throws Cvc3Exception {
- return jniIsForall(embedded());
- }
-
-
- public boolean isExists() throws Cvc3Exception {
- return jniIsExists(embedded());
- }
-
-
- public boolean isRational() throws Cvc3Exception {
- return jniIsRational(embedded());
- }
-
- public boolean isUminus() throws Cvc3Exception {
- return jniIsUminus(embedded());
- }
-
- public boolean isPlus() throws Cvc3Exception {
- return jniIsPlus(embedded());
- }
-
- public boolean isMinus() throws Cvc3Exception {
- return jniIsMinus(embedded());
- }
-
- public boolean isMult() throws Cvc3Exception {
- return jniIsMult(embedded());
- }
-
- public boolean isPow() throws Cvc3Exception {
- return jniIsPow(embedded());
- }
-
- public boolean isDivide() throws Cvc3Exception {
- return jniIsDivide(embedded());
- }
-
- public boolean isLt() throws Cvc3Exception {
- return jniIsLt(embedded());
- }
-
- public boolean isLe() throws Cvc3Exception {
- return jniIsLe(embedded());
- }
-
- public boolean isGt() throws Cvc3Exception {
- return jniIsGt(embedded());
- }
-
- public boolean isGe() throws Cvc3Exception {
- return jniIsGe(embedded());
- }
-
- public boolean isSkolem() throws Cvc3Exception {
- return jniIsSkolem(embedded());
- }
-
- public boolean isRead() throws Cvc3Exception {
- return jniIsRead(embedded());
- }
-
- public boolean isWrite() throws Cvc3Exception {
- return jniIsWrite(embedded());
- }
-
- public boolean isBvLe() throws Cvc3Exception {
- return jniIsBvLe(embedded());
- }
-
- public boolean isBvLt() throws Cvc3Exception {
- return jniIsBvLt(embedded());
- }
-
- public boolean isBvGe() throws Cvc3Exception {
- return jniIsBvGe(embedded());
- }
-
- public boolean isBvGt() throws Cvc3Exception {
- return jniIsBvGt(embedded());
- }
-
- public boolean isBvPlus() throws Cvc3Exception {
- return jniIsBvPlus(embedded());
- }
-
- public boolean isBvSub() throws Cvc3Exception {
- return jniIsBvSub(embedded());
- }
-
- public boolean isBvConstant() throws Cvc3Exception {
- return jniIsBvConst(embedded());
- }
-
- public boolean isBvConcat() throws Cvc3Exception {
- return jniIsBvConcat(embedded());
- }
-
- public boolean isBvExtract() throws Cvc3Exception {
- return jniIsBvExtract(embedded());
- }
-
-
- public String getName() throws Cvc3Exception {
- assert(!jniIsNull(embedded()));
- return jniGetName(embedded());
- }
-
- public String getUid() throws Cvc3Exception {
- assert(jniIsBoundVar(embedded()));
- return jniGetUid(embedded());
- }
-
- public String getString() throws Cvc3Exception {
- assert(jniIsString(embedded()));
- return jniGetString(embedded());
- }
-
- public List getVars() throws Cvc3Exception {
- assert(jniIsClosure(embedded()));
- Object[] vars = jniGetVars(embedded());
- return JniUtils.embedList(vars, Expr.class, embeddedManager());
- }
-
- public List getTriggers() throws Cvc3Exception {
- assert (jniIsClosure(embedded()));
- return JniUtils.embedListList(jniGetTriggers(embedded()), Expr.class, embeddedManager());
- }
-
- public Expr getExistential() throws Cvc3Exception {
- assert(jniIsSkolem(embedded()));
- return new Expr(jniGetExistential(embedded()), embeddedManager());
- }
-
- public int getBoundIndex() throws Cvc3Exception {
- assert(jniIsSkolem(embedded()));
- return jniGetBoundIndex(embedded());
- }
-
- public Expr getBody() throws Cvc3Exception {
- assert(jniIsClosure(embedded()));
- return new Expr(jniGetBody(embedded()), embeddedManager());
- }
-
- public Rational getRational() throws Cvc3Exception {
- assert(isRational());
- return new Rational(jniGetRational(embedded()), embeddedManager());
- }
-
- public Theorem getTheorem() throws Cvc3Exception {
- assert(jniIsTheorem(embedded()));
- return new Theorem(jniGetTheorem(embedded()), embeddedManager());
- }
-
- public TypeMut getType() throws Cvc3Exception {
- return new TypeMut(jniGetType(embedded()), embeddedManager());
- }
-
- public OpMut mkOp() throws Cvc3Exception {
- return new OpMut(jniMkOp(embedded()), embeddedManager());
- }
-
- public OpMut getOp() throws Cvc3Exception {
- return new OpMut(jniGetOp(embedded()), embeddedManager());
- }
-
- public ExprMut getOpExpr() throws Cvc3Exception {
- return new ExprMut(jniGetOpExpr(embedded()), embeddedManager());
- }
-
- public boolean isNull() throws Cvc3Exception {
- return jniIsNull(embedded());
- }
-
- public int arity() throws Cvc3Exception {
- return jniArity(embedded());
- }
-
- public Expr getChild(int i) throws Cvc3Exception {
- assert(i >= 0 && i < arity());
- return new Expr(jniGetKid(embedded(), i), embeddedManager());
- }
-
- public List getChildren() throws Cvc3Exception {
- return JniUtils.embedList(jniGetKids(embedded()), Expr.class, embeddedManager());
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class ExprManager extends Embedded {
- // jni methods
- private static native String jniGetInputLanguage(Object ExprManager) throws Cvc3Exception;
- private static native String jniGetOutputLanguage(Object ExprManager) throws Cvc3Exception;
-
- /// Constructor
-
- public ExprManager(Object ExprManager, EmbeddedManager embeddedManager) {
- super(ExprManager, embeddedManager);
- }
-
-
- /// API (immutable)
-
- public InputLanguage getInputLanguage() throws Cvc3Exception {
- return InputLanguage.get(jniGetInputLanguage(embedded()));
- }
-
- public InputLanguage getOutputLanguage() throws Cvc3Exception {
- return InputLanguage.get(jniGetOutputLanguage(embedded()));
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class ExprManagerMut extends ExprManager {
- // jni methods
-
- /// Constructor
-
- public ExprManagerMut(Object ExprManagerMut, EmbeddedManager embeddedManager) {
- super(ExprManagerMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-DEFINITION: Java_cvc3_ExprManager_jniGetInputLanguage
-jstring c ExprManager exprManager
-return toJava(env, exprManager->getInputLang());
-
-DEFINITION: Java_cvc3_ExprManager_jniGetOutputLanguage
-jstring c ExprManager exprManager
-return toJava(env, exprManager->getOutputLang());
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class ExprMut extends Expr {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public ExprMut(Object ExprMut, EmbeddedManager embeddedManager) {
- super(ExprMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-//INCLUDE: <expr.h>
-//INCLUDE: <theory_array.h>
-//INCLUDE: <theory_arith.h>
-//INCLUDE: <theory_bitvector.h>
-
-DEFINITION: Java_cvc3_Expr_jniEquals
-jboolean c Expr expr1 c Expr expr2
-return *expr1 == *expr2;
-
-DEFINITION: Java_cvc3_Expr_jniToString
-jstring c Expr expr
-return toJava(env, expr->toString());
-
-DEFINITION: Java_cvc3_Expr_jniPrint
-void c Expr expr n string lang n bool dagify
-dagify ? expr->pprint() : expr->pprintnodag();
-
-DEFINITION: Java_cvc3_Expr_jniHash
-jint c Expr expr
-return expr->hash();
-
-DEFINITION: Java_cvc3_Expr_jniGetKind
-jstring c Expr expr
-return toJava(env, expr->getEM()->getKindName( expr->getKind() ));
-
-DEFINITION: Java_cvc3_Expr_jniIsFalse
-jboolean c Expr expr
-return expr->isFalse();
-
-DEFINITION: Java_cvc3_Expr_jniIsTrue
-jboolean c Expr expr
-return expr->isTrue();
-
-DEFINITION: Java_cvc3_Expr_jniIsBoolConst
-jboolean c Expr expr
-return expr->isBoolConst();
-
-DEFINITION: Java_cvc3_Expr_jniIsVar
-jboolean c Expr expr
-return expr->isVar();
-
-DEFINITION: Java_cvc3_Expr_jniIsBoundVar
-jboolean c Expr expr
-return expr->isBoundVar();
-
-DEFINITION: Java_cvc3_Expr_jniIsString
-jboolean c Expr expr
-return expr->isString();
-
-DEFINITION: Java_cvc3_Expr_jniIsClosure
-jboolean c Expr expr
-return expr->isClosure();
-
-DEFINITION: Java_cvc3_Expr_jniIsQuantifier
-jboolean c Expr expr
-return expr->isQuantifier();
-
-DEFINITION: Java_cvc3_Expr_jniIsLambda
-jboolean c Expr expr
-return expr->isLambda();
-
-DEFINITION: Java_cvc3_Expr_jniIsApply
-jboolean c Expr expr
-return expr->isApply();
-
-DEFINITION: Java_cvc3_Expr_jniIsSymbol
-jboolean c Expr expr
-return expr->isSymbol();
-
-DEFINITION: Java_cvc3_Expr_jniIsTheorem
-jboolean c Expr expr
-return expr->isTheorem();
-
-DEFINITION: Java_cvc3_Expr_jniIsType
-jboolean c Expr expr
-return expr->isType();
-
-
-
-DEFINITION: Java_cvc3_Expr_jniIsTerm
-jboolean c Expr expr
-return expr->isTerm();
-
-DEFINITION: Java_cvc3_Expr_jniIsAtomic
-jboolean c Expr expr
-return expr->isAtomic();
-
-DEFINITION: Java_cvc3_Expr_jniIsAtomicFormula
-jboolean c Expr expr
-return expr->isAtomicFormula();
-
-DEFINITION: Java_cvc3_Expr_jniIsAbsAtomicFormula
-jboolean c Expr expr
-return expr->isAbsAtomicFormula();
-
-DEFINITION: Java_cvc3_Expr_jniIsLiteral
-jboolean c Expr expr
-return expr->isLiteral();
-
-DEFINITION: Java_cvc3_Expr_jniIsAbsLiteral
-jboolean c Expr expr
-return expr->isAbsLiteral();
-
-DEFINITION: Java_cvc3_Expr_jniIsBoolConnective
-jboolean c Expr expr
-return expr->isBoolConnective();
-
-DEFINITION: Java_cvc3_Expr_jniIsPropAtom
-jboolean c Expr expr
-return expr->isPropAtom();
-
-DEFINITION: Java_cvc3_Expr_jniIsPropLiteral
-jboolean c Expr expr
-return expr->isPropLiteral();
-
-DEFINITION: Java_cvc3_Expr_jniIsArrayLiteral
-jboolean c Expr expr
-return CVC3::isArrayLiteral(*expr);
-
-
-DEFINITION: Java_cvc3_Expr_jniIsEq
-jboolean c Expr expr
-return expr->isEq();
-
-DEFINITION: Java_cvc3_Expr_jniIsNot
-jboolean c Expr expr
-return expr->isNot();
-
-DEFINITION: Java_cvc3_Expr_jniIsAnd
-jboolean c Expr expr
-return expr->isAnd();
-
-DEFINITION: Java_cvc3_Expr_jniIsOr
-jboolean c Expr expr
-return expr->isOr();
-
-DEFINITION: Java_cvc3_Expr_jniIsITE
-jboolean c Expr expr
-return expr->isITE();
-
-DEFINITION: Java_cvc3_Expr_jniIsIff
-jboolean c Expr expr
-return expr->isIff();
-
-DEFINITION: Java_cvc3_Expr_jniIsImpl
-jboolean c Expr expr
-return expr->isImpl();
-
-DEFINITION: Java_cvc3_Expr_jniIsXor
-jboolean c Expr expr
-return expr->isXor();
-
-DEFINITION: Java_cvc3_Expr_jniIsForall
-jboolean c Expr expr
-return expr->isForall();
-
-DEFINITION: Java_cvc3_Expr_jniIsExists
-jboolean c Expr expr
-return expr->isExists();
-
-DEFINITION: Java_cvc3_Expr_jniIsRational
-jboolean c Expr expr
-return expr->isRational();
-
-DEFINITION: Java_cvc3_Expr_jniIsUminus
-jboolean c Expr expr
-return expr->getKind() == UMINUS;
-
-DEFINITION: Java_cvc3_Expr_jniIsPlus
-jboolean c Expr expr
-return expr->getKind() == PLUS;
-
-DEFINITION: Java_cvc3_Expr_jniIsMinus
-jboolean c Expr expr
-return expr->getKind() == MINUS;
-
-DEFINITION: Java_cvc3_Expr_jniIsMult
-jboolean c Expr expr
-return expr->getKind() == MULT;
-
-DEFINITION: Java_cvc3_Expr_jniIsPow
-jboolean c Expr expr
-return expr->getKind() == POW;
-
-DEFINITION: Java_cvc3_Expr_jniIsDivide
-jboolean c Expr expr
-return expr->getKind() == DIVIDE;
-
-DEFINITION: Java_cvc3_Expr_jniIsLt
-jboolean c Expr expr
-return expr->getKind() == LT;
-
-DEFINITION: Java_cvc3_Expr_jniIsLe
-jboolean c Expr expr
-return expr->getKind() == LE;
-
-DEFINITION: Java_cvc3_Expr_jniIsGt
-jboolean c Expr expr
-return expr->getKind() == GT;
-
-DEFINITION: Java_cvc3_Expr_jniIsGe
-jboolean c Expr expr
-return expr->getKind() == GE;
-
-DEFINITION: Java_cvc3_Expr_jniIsSkolem
-jboolean c Expr expr
-return expr->isSkolem();
-
-
-DEFINITION: Java_cvc3_Expr_jniIsRead
-jboolean c Expr expr
-return expr->getKind() == READ;
-
-DEFINITION: Java_cvc3_Expr_jniIsWrite
-jboolean c Expr expr
-return expr->getKind() == WRITE;
-
-
-DEFINITION: Java_cvc3_Expr_jniGetName
-jstring c Expr expr
-return toJava(env, expr->getName());
-
-DEFINITION: Java_cvc3_Expr_jniGetUid
-jstring c Expr expr
-return toJava(env, expr->getUid());
-
-DEFINITION: Java_cvc3_Expr_jniGetString
-jstring c Expr expr
-return toJava(env, expr->getString());
-
-DEFINITION: Java_cvc3_Expr_jniGetVars
-jobjectArray c Expr expr
-return toJavaVConstRef(env, expr->getVars());
-
-DEFINITION: Java_cvc3_Expr_jniGetExistential
-jobject c Expr expr
-return embed_copy<Expr>(env, expr->getExistential());
-
-DEFINITION: Java_cvc3_Expr_jniGetBoundIndex
-jint c Expr expr
-return expr->getBoundIndex();
-
-DEFINITION: Java_cvc3_Expr_jniGetBody
-jobject c Expr expr
-return embed_copy<Expr>(env, expr->getBody());
-
-DEFINITION: Java_cvc3_Expr_jniGetRational
-jobject c Expr expr
-return embed_const_ref<Rational>(env, &expr->getRational());
-
-DEFINITION: Java_cvc3_Expr_jniGetTriggers
-jobjectArray c Expr expr
-return toJavaVVConstRef(env, expr->getTriggers());
-
-DEFINITION: Java_cvc3_Expr_jniGetTheorem
-jobject c Expr expr
-return embed_copy<Theorem>(env, expr->getTheorem());
-
-DEFINITION: Java_cvc3_Expr_jniGetType
-jobject c Expr expr
-return embed_copy<Type>(env, expr->getType());
-
-DEFINITION: Java_cvc3_Expr_jniMkOp
-jobject c Expr expr
-return embed_copy<Op>(env, expr->mkOp());
-
-DEFINITION: Java_cvc3_Expr_jniGetOp
-jobject c Expr expr
-return embed_copy<Op>(env, expr->getOp());
-
-DEFINITION: Java_cvc3_Expr_jniGetOpExpr
-jobject c Expr expr
-return embed_copy<Expr>(env, expr->getOpExpr());
-
-DEFINITION: Java_cvc3_Expr_jniIsNull
-jboolean c Expr expr
-return expr->isNull();
-
-DEFINITION: Java_cvc3_Expr_jniArity
-jint c Expr expr
-return expr->arity();
-
-DEFINITION: Java_cvc3_Expr_jniGetKid
-jobject c Expr expr n int i
-return embed_copy<Expr>(env, (*expr)[ji]);
-
-DEFINITION: Java_cvc3_Expr_jniGetKids
-jobjectArray c Expr expr
-return toJavaVConstRef(env, expr->getKids());
-
-DEFINITION: Java_cvc3_Expr_jniSubstExpr
-jobject c Expr e cv Expr oldExprs cv Expr newExprs
-return embed_copy(env, e->substExpr(oldExprs,newExprs));
-
-DEFINITION: Java_cvc3_Expr_jniIsBvLt
-jboolean c Expr expr
-return expr->getKind() == BVLT;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvLe
-jboolean c Expr expr
-return expr->getKind() == BVLE;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvGt
-jboolean c Expr expr
-return expr->getKind() == BVGT;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvGe
-jboolean c Expr expr
-return expr->getKind() == BVGE;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvPlus
-jboolean c Expr expr
-return expr->getKind() == BVPLUS;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvSub
-jboolean c Expr expr
-return expr->getKind() == BVSUB;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvConst
-jboolean c Expr expr
-return expr->getKind() == BVCONST;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvExtract
-jboolean c Expr expr
-return expr->getKind() == EXTRACT;
-
-DEFINITION: Java_cvc3_Expr_jniIsBvConcat
-jboolean c Expr expr
-return expr->getKind() == CONCAT;
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Flag extends Embedded {
- // jni methods
- private static native boolean jniIsNull(Object Flag) throws Cvc3Exception;
- private static native boolean jniIsBool(Object Flag) throws Cvc3Exception;
- private static native boolean jniIsInt(Object Flag) throws Cvc3Exception;
- private static native boolean jniIsString(Object Flag) throws Cvc3Exception;
- private static native boolean jniIsStringVec(Object Flag) throws Cvc3Exception;
- private static native boolean jniGetBool(Object Flag) throws Cvc3Exception;
- private static native int jniGetInt(Object Flag) throws Cvc3Exception;
- private static native String jniGetString(Object Flag) throws Cvc3Exception;
- private static native String jniGetHelp(Object Flag) throws Cvc3Exception;
-
-
- /// Constructor
-
- // create embedded object
- public Flag(Object Flag, EmbeddedManager embeddedManager) {
- super(Flag, embeddedManager);
- }
-
-
- /// API immutable
-
- boolean isNull() throws Cvc3Exception {
- return jniIsNull(embedded());
- }
-
- boolean isBool() throws Cvc3Exception {
- return jniIsBool(embedded());
- }
-
- boolean isInt() throws Cvc3Exception {
- return jniIsInt(embedded());
- }
-
- boolean isString() throws Cvc3Exception {
- return jniIsString(embedded());
- }
-
- boolean isStringVec() throws Cvc3Exception {
- return jniIsStringVec(embedded());
- }
-
- boolean getBool() throws Cvc3Exception {
- return jniGetBool(embedded());
- }
-
- int getInt() throws Cvc3Exception {
- return jniGetInt(embedded());
- }
-
- String getString() throws Cvc3Exception {
- return jniGetString(embedded());
- }
-
- String getHelp() throws Cvc3Exception {
- return jniGetHelp(embedded());
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class FlagException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public FlagException(String message) {
- super(message);
- }
-}
+++ /dev/null
-DEFINITION: Java_cvc3_Flag_jniIsNull
-jboolean c CLFlag flag
-return (flag->getType() == CLFLAG_NULL);
-
-DEFINITION: Java_cvc3_Flag_jniIsBool
-jboolean c CLFlag flag
-return (flag->getType() == CLFLAG_BOOL);
-
-DEFINITION: Java_cvc3_Flag_jniIsInt
-jboolean c CLFlag flag
-return (flag->getType() == CLFLAG_INT);
-
-DEFINITION: Java_cvc3_Flag_jniIsString
-jboolean c CLFlag flag
-return (flag->getType() == CLFLAG_STRING);
-
-DEFINITION: Java_cvc3_Flag_jniIsStringVec
-jboolean c CLFlag flag
-return (flag->getType() == CLFLAG_STRVEC);
-
-
-DEFINITION: Java_cvc3_Flag_jniGetBool
-jboolean c CLFlag flag
-return flag->getBool();
-
-DEFINITION: Java_cvc3_Flag_jniGetInt
-jint c CLFlag flag
-return flag->getInt();
-
-DEFINITION: Java_cvc3_Flag_jniGetString
-jstring c CLFlag flag
-return toJava(env, flag->getString());
-
-DEFINITION: Java_cvc3_Flag_jniGetHelp
-jstring c CLFlag flag
-return toJava(env, flag->getHelp());
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public abstract class Flags extends Embedded {
- // jni methods
- private static native Object[] jniGetFlags(Object Flags, String prefix) throws Cvc3Exception;
- private static native Object jniGetFlag(Object Flags, String name) throws Cvc3Exception;
-
-
- /// Constructor
-
- // create embedded object
- public Flags(Object Flags, EmbeddedManager embeddedManager) {
- super(Flags, embeddedManager);
- }
-
- /// API (immutable)
-
-
- // get names of all flags starting with prefix
- public List getFlags(String prefix) throws Cvc3Exception {
- Object[] flags = jniGetFlags(embedded(), prefix);
- assert(flags instanceof String[]);
- return Arrays.asList(flags);
- }
-
- // get the value of a flag by name (without prefix -/+)
- public Flag getFlag(String name) throws Cvc3Exception {
- return new Flag(jniGetFlag(embedded(), name), embeddedManager());
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class FlagsMut extends Flags {
- // jni methods
- private static native void jniSetFlag1(Object Flags, String name, boolean value) throws Cvc3Exception;
- private static native void jniSetFlag2(Object Flags, String name, int value) throws Cvc3Exception;
- private static native void jniSetFlag3(Object Flags, String name, String value) throws Cvc3Exception;
- private static native void jniSetFlag4(Object Flags, String map, String name, boolean value) throws Cvc3Exception;
-
-
- /// Constructor
-
- // create embedded object
- public FlagsMut(Object FlagsMut, EmbeddedManager embeddedManager) {
- super(FlagsMut, embeddedManager);
- }
-
-
- /// API (mutable)
-
- public void setFlag(String name, boolean value) throws Cvc3Exception {
- jniSetFlag1(embedded(), name, value);
- }
-
- public void setFlag(String name, int value) throws Cvc3Exception {
- jniSetFlag2(embedded(), name, value);
- }
-
- public void setFlag(String name, String value) throws Cvc3Exception {
- jniSetFlag3(embedded(), name, value);
- }
-
- // flag representing set of options, e.g. trace
- public void setFlag(String map, String name, boolean value) throws Cvc3Exception {
- jniSetFlag4(embedded(), map, name, value);
- }
-}
+++ /dev/null
-DEFINITION: Java_cvc3_FlagsMut_jniSetFlag1
-void m CLFlags flags n string name n bool value
-flags->setFlag(name, value);
-
-DEFINITION: Java_cvc3_FlagsMut_jniSetFlag2
-void m CLFlags flags n string name n int value
-flags->setFlag(name, value);
-
-DEFINITION: Java_cvc3_FlagsMut_jniSetFlag3
-void m CLFlags flags n string name n string value
-flags->setFlag(name, value);
-
-DEFINITION: Java_cvc3_FlagsMut_jniSetFlag4
-void m CLFlags flags n string map n string name n bool value
-flags->setFlag(map, std::make_pair(name, value));
+++ /dev/null
-DEFINITION: Java_cvc3_Flags_jniGetFlags
-jobjectArray c CLFlags flags n string prefix
-
-// get flag names
-vector<string> names;
-flags->countFlags(prefix, names);
-return toJavaV(env, names);
-
-
-DEFINITION: Java_cvc3_Flags_jniGetFlag
-jobject c CLFlags flags n string name
-const CLFlag& flag = flags->getFlag(name);
-return embed_const_ref(env, &flag);
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** A truth value of a formula. */
-public class FormulaValue {
- private final String d_result;
-
- protected FormulaValue(String result) {
- d_result = result;
- }
-
-
- // names of c++ enum values
- public static final FormulaValue TRUE = new FormulaValue("TRUE_VAL");
- public static final FormulaValue FALSE = new FormulaValue("FALSE_VAL");
- public static final FormulaValue UNKNOWN = new FormulaValue("UNKNOWN_VAL");
-
- // the FormulaValue corresponding to a c++ enum value by name
- public static FormulaValue get(String value) throws DebugException {
- if (value.equals(TRUE.toString())) {
- return TRUE;
- } else if (value.equals(FALSE.toString())) {
- return FALSE;
- } else if (value.equals(UNKNOWN.toString())) {
- return UNKNOWN;
- } else {
- throw new DebugException("FormulaValue.constructor: unknown enum value: " + value);
- }
- }
-
- // the FormulaValue's c++ enum value
- public String toString() {
- return d_result;
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** See comments about mapping c++ enums to java in QueryResult */
-public class InputLanguage {
- private final String d_lang;
-
- private InputLanguage(String lang) {
- d_lang = lang;
- }
-
-
- // names of c++ enum values
- public static final InputLanguage PRESENTATION = new InputLanguage("PRESENTATION");
- public static final InputLanguage SMTLIB = new InputLanguage("SMTLIB");
- public static final InputLanguage LISP = new InputLanguage("LISP");
-
- // the InputLanguage corresponding to a c++ enum value by name
- public static InputLanguage get(String value) throws DebugException {
- if (value.equals(PRESENTATION.toString())) {
- return PRESENTATION;
- } else if (value.equals(SMTLIB.toString())) {
- return SMTLIB;
- } else if (value.equals(LISP.toString())) {
- return LISP;
- } else {
- throw new DebugException("InputLanguage.constructor: unknown enum value: " + value);
- }
- }
-
- // the InputLanguage's c++ enum value
- public String toString() {
- return d_lang;
- }
-}
+++ /dev/null
-#include "JniUtils.h"
-
-// for CVC4: removed; don't need these
-//#include <typecheck_exception.h>
-//#include <sound_exception.h>
-//#include <eval_exception.h>
-//#include <command_line_exception.h>
-//#include <parser_exception.h>
-//#include <smtlib_exception.h>
-
-// for CVC4: need these for compatibility layer
-#include "compat/cvc3_compat.h"
-#include "Embedded.h"
-
-using namespace std;
-using namespace CVC3;
-
-namespace Java_cvc3_JniUtils {
-
- /// Embedding of c++ objects in java objects
-
- Embedded* unembed(JNIEnv* env, jobject jobj) {
- Embedded* embedded = (Embedded*) env->GetDirectBufferAddress(jobj);
- DebugAssert(embedded != NULL, "JniUtils::unembed: embedded object is NULL");
- return embedded;
- }
-
- void deleteEmbedded(JNIEnv* env, jobject jobj) {
- Embedded* embedded = unembed(env, jobj);
- DebugAssert(embedded != NULL, "JniUtils::deleteEmbedded: embedded object is NULL");
- delete embedded;
- }
-
-
-
- /// Conversions between c++ and java
-
- bool toCpp(jboolean j) {
- return (bool)j;
- }
-
- jstring toJava(JNIEnv* env, const string& cstring) {
- return env->NewStringUTF(cstring.c_str());
- }
-
- jstring toJava(JNIEnv* env, const char* cstring) {
- return env->NewStringUTF(cstring);
- }
-
- string toCpp(JNIEnv* env, const jstring& jstring) {
- const char* cstring = env->GetStringUTFChars(jstring, NULL);
- string string(cstring);
- env->ReleaseStringUTFChars(jstring, cstring);
- return string;
- }
-
- jstring toJava(JNIEnv* env, CVC3::QueryResult result) {
- switch (result) {
- case SATISFIABLE: return toJava(env, "SATISFIABLE");
- case UNSATISFIABLE: return toJava(env, "UNSATISFIABLE");
- case ABORT: return toJava(env, "ABORT");
- case UNKNOWN: return toJava(env, "UNKNOWN");
- }
-
- DebugAssert(false, "JniUtils::toJava(QueryResult): unreachable");
- return toJava(env, ""); // to avoid compiler warning
- }
-
- jstring toJava(JNIEnv* env, CVC3::FormulaValue result) {
- switch (result) {
- case TRUE_VAL: return toJava(env, "TRUE_VAL");
- case FALSE_VAL: return toJava(env, "FALSE_VAL");
- case UNKNOWN_VAL: return toJava(env, "UNKNOWN_VAL");
- }
-
- DebugAssert(false, "JniUtils::toJava(FormulaValue): unreachable");
- return toJava(env, "UNDEFINED");
- }
-
- jstring toJava(JNIEnv* env, CVC3::InputLanguage lang) {
- switch (lang) {
- case PRESENTATION_LANG: return toJava(env, "PRESENTATION");
- case SMTLIB_LANG: return toJava(env, "SMTLIB");
- case SMTLIB_V2_LANG: return toJava(env, "SMTLIB_V2");
- //case LISP_LANG: return toJava(env, "LISP");
- default: /* fall through */;
- }
-
- DebugAssert(false, "JniUtils::toJava(InputLanguage): unreachable");
- return toJava(env, "UNDEFINED");
- }
-
- InputLanguage toCppInputLanguage(JNIEnv* env, const string& lang) {
- if (lang.compare("PRESENTATION") == 0) {
- return PRESENTATION_LANG;
- } else if (lang.compare("SMTLIB") == 0) {
- return SMTLIB_LANG;
- } else if (lang.compare("SMTLIB_V2") == 0) {
- return SMTLIB_V2_LANG;
- /*
- } else if (lang.compare("LISP") == 0) {
- return LISP_LANG;
- */
- }
-
- DebugAssert(false, "JniUtils::toCpp(InputLanguage): unreachable");
- return CVC4::language::input::LANG_MAX;
- }
-
- void toJava(JNIEnv* env, const Exception& e) {
- /* for CVC4: don't worry about legacy exception mapping
- string exceptionName("cvc3/");
- if (dynamic_cast<const TypecheckException*>(&e) != NULL) {
- exceptionName += "TypecheckException";
- } else if (dynamic_cast<const CVC3::SoundException*>(&e) != NULL) {
- exceptionName += "SoundException";
- } else if (dynamic_cast<const CVC3::EvalException*>(&e) != NULL) {
- exceptionName += "EvalException";
- } else if (dynamic_cast<const CVC3::CLException*>(&e) != NULL) {
- exceptionName += "CLException";
- } else if (dynamic_cast<const CVC3::ParserException*>(&e) != NULL) {
- exceptionName += "ParserException";
- } else if (dynamic_cast<const CVC3::SmtlibException*>(&e) != NULL) {
- exceptionName += "SmtlibException";
- } else if (dynamic_cast<const CVC3::DebugException*>(&e) != NULL) {
- exceptionName += "DebugException";
- } else {
- exceptionName += "Cvc3Exception";
- }
- */
-
- jclass exceptionClass = env->FindClass("java/lang/RuntimeException");
- // queues up the exception in the Java layer
- env->ThrowNew(exceptionClass, e.toString().c_str());
- }
-
-
- vector<string> toCppV(JNIEnv* env, const jobjectArray& jarray) {
- vector<string> v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- v.push_back(toCpp(env, (jstring)env->GetObjectArrayElement(jarray, i)));
- }
- return v;
- }
-
- vector<vector<string> > toCppVV(JNIEnv* env, const jobjectArray& jarray) {
- vector<vector<string> > v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- jobjectArray jsub = static_cast<jobjectArray>(env->GetObjectArrayElement(jarray, i));
- v.push_back(toCppV(env, jsub));
- }
- return v;
- }
-
- vector<vector<vector<string> > > toCppVVV(JNIEnv* env, const jobjectArray& jarray) {
- vector<vector<vector<string> > > v;
- int length = env->GetArrayLength(jarray);
- for (int i = 0; i < length; ++i) {
- jobjectArray jsub = static_cast<jobjectArray>(env->GetObjectArrayElement(jarray, i));
- v.push_back(toCppVV(env, jsub));
- }
- return v;
- }
-
- jobjectArray toJavaV(JNIEnv* env, const vector<string>& v) {
- jobjectArray jarray = (jobjectArray)
- env->NewObjectArray(
- v.size(),
- env->FindClass("java/lang/String"),
- env->NewStringUTF(""));
-
- for(unsigned i = 0; i < v.size(); ++i) {
- env->SetObjectArrayElement(jarray, i, toJava(env, v[i]));
- }
-
- return jarray;
- }
-
-
- vector<bool> toCppV(JNIEnv* env, const jbooleanArray& jarray) {
- int length = env->GetArrayLength(jarray);
- jboolean* jboolean = env->GetBooleanArrayElements(jarray, NULL);
-
- vector<bool> v;
- for (int i = 0; i < length; ++i) {
- v.push_back(jboolean[i]);
- }
- env->ReleaseBooleanArrayElements(jarray, jboolean, JNI_ABORT);
-
- return v;
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-import java.lang.reflect.Constructor;
-
-public class JniUtils {
-
- // check that list is an instance of a class -
- // generics would avoid that
- public static boolean listInstanceof(List list, Class c) {
- Iterator i = list.iterator();
- while (i.hasNext()) {
- if (!(c.isInstance(i.next()))) return false;
- }
- return true;
- }
-
- public static boolean listListInstanceof(List listList, Class c) {
- Iterator i = listList.iterator();
- while (i.hasNext()) {
- Object list = i.next();
- assert(list instanceof List);
- if (!(listInstanceof((List)list, c))) return false;
- }
- return true;
- }
-
- public static boolean listListListInstanceof(List listListList, Class c) {
- Iterator i = listListList.iterator();
- while (i.hasNext()) {
- Object list = i.next();
- assert(list instanceof List);
- if (!(listListInstanceof((List)list, c))) return false;
- }
- return true;
- }
-
-
- // embed an array of c++ objects in a list
- public static List embedList(Object[] cobjects, Class c, EmbeddedManager embeddedManager) {
- List embedded = new ArrayList();
-
- try {
- Class[] argsC = new Class[2];
- argsC[0] = Object.class;
- argsC[1] = EmbeddedManager.class;
- Constructor constr = c.getConstructor(argsC);
-
- Object[] args = new Object[2];
- for (int i = 0; i < cobjects.length; ++i) {
- args[0] = cobjects[i];
- args[1] = embeddedManager;
- embedded.add(constr.newInstance(args));
- }
- } catch (NoSuchMethodException e) {
- System.out.println(e);
- assert(false);
- } catch (InstantiationException e) {
- System.out.println(e);
- assert(false);
- } catch (IllegalAccessException e) {
- System.out.println(e);
- assert(false);
- } catch (java.lang.reflect.InvocationTargetException e) {
- System.out.println(e);
- assert(false);
- }
- return embedded;
- }
-
- public static List embedListList(Object[][] cobjects, Class c, EmbeddedManager embeddedManager) {
- List embedded = new ArrayList(cobjects.length);
- for (int i = 0; i < cobjects.length; ++i) {
- Object[] cobject = cobjects[i];
- embedded.add( embedList(cobject,c,embeddedManager) );
- }
- return embedded;
- }
-
- // embed an array of c++ objects in a hash map
- public static HashMap embedHashMap(Object[] cobjects, Class ck, Class cv,
- EmbeddedManager embeddedManager) {
- HashMap embedded = new HashMap(cobjects.length / 2);
-
- try {
- Class[] argsCK = new Class[2];
- argsCK[0] = Object.class;
- argsCK[1] = EmbeddedManager.class;
- Constructor constrK = ck.getConstructor(argsCK);
-
- Class[] argsCV = new Class[2];
- argsCV[0] = Object.class;
- argsCV[1] = EmbeddedManager.class;
- Constructor constrV = cv.getConstructor(argsCV);
-
- Object[] argsK = new Object[2];
- Object[] argsV = new Object[2];
- for (int i = 0; i < cobjects.length; ++i) {
- argsK[0] = cobjects[i];
- argsK[1] = embeddedManager;
-
- ++i;
- assert(i < cobjects.length);
- argsV[0] = cobjects[i];
- argsV[1] = embeddedManager;
-
- embedded.put(constrK.newInstance(argsK), constrV.newInstance(argsV));
- }
- } catch (NoSuchMethodException e) {
- System.out.println(e);
- assert(false);
- } catch (InstantiationException e) {
- System.out.println(e);
- assert(false);
- } catch (IllegalAccessException e) {
- System.out.println(e);
- assert(false);
- } catch (java.lang.reflect.InvocationTargetException e) {
- System.out.println(e);
- assert(false);
- }
- return embedded;
- }
-
-
- // unembed a list of Embedded objects to a list
- public static Object[] unembedList(List embedded) {
- Object[] unembedded = new Object[embedded.size()];
-
- for (int i = 0; i < embedded.size(); ++i) {
- assert(embedded.get(i) instanceof Embedded);
- unembedded[i] = ((Embedded)embedded.get(i)).embedded();
- }
-
- return unembedded;
- }
-
- public static Object[][] unembedListList(List embedded) {
- Object[][] unembedded = new Object[embedded.size()][];
-
- for (int i = 0; i < embedded.size(); ++i) {
- Object list = embedded.get(i);
- assert(list instanceof List);
- unembedded[i] = unembedList((List)list);
- }
-
- return unembedded;
- }
-
- public static Object[][][] unembedListListList(List embedded) {
- Object[][][] unembedded = new Object[embedded.size()][][];
-
- for (int i = 0; i < embedded.size(); ++i) {
- Object list = embedded.get(i);
- assert(list instanceof List);
- unembedded[i] = unembedListList((List)list);
- }
-
- return unembedded;
- }
-
-
- // unembed a list of Embedded objects to a list
- public static Object[] unembedArray(Object[] embedded) {
- Object[] unembedded = new Object[embedded.length];
-
- for (int i = 0; i < embedded.length; ++i) {
- assert(embedded[i] instanceof Embedded);
- unembedded[i] = ((Embedded)embedded[i]).embedded();
- }
-
- return unembedded;
- }
-
- public static Object[] unembedArrayArray(Object[][] embedded) {
- Object[] unembedded = new Object[embedded.length];
-
- for (int i = 0; i < embedded.length; ++i) {
- unembedded[i] = unembedArray(embedded[i]);
- }
-
- return unembedded;
- }
-
- public static Object[] unembedArrayArrayArray(Object[][][] embedded) {
- Object[] unembedded = new Object[embedded.length];
-
- for (int i = 0; i < embedded.length; ++i) {
- unembedded[i] = unembedArrayArray(embedded[i]);
- }
-
- return unembedded;
- }
-
-
- // copy a list of strings to a list
- public static Object[] toArray(List list) {
- assert(listInstanceof(list, String.class));
- assert(list.isEmpty() || !listInstanceof(list, Embedded.class));
- return list.toArray();
- }
-
- public static Object[] toArrayArray(List listList) {
- Object[] arrayArray = new Object[listList.size()];
-
- for (int i = 0; i < listList.size(); ++i) {
- Object list = listList.get(i);
- assert(list instanceof List);
- arrayArray[i] = toArray(((List)list));
- }
-
- return arrayArray;
- }
-
- public static Object[] toArrayArrayArray(List listListList) {
- Object[] arrayArrayArray = new Object[listListList.size()];
-
- for (int i = 0; i < listListList.size(); ++i) {
- Object list = listListList.get(i);
- assert(list instanceof List);
- arrayArrayArray[i] = toArrayArray((List)list);
- }
-
- return arrayArrayArray;
- }
-}
-
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Op extends Embedded {
- // jni methods
- private static native boolean
- jniEquals(Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native String
- jniToString(Object Expr) throws Cvc3Exception;
-
- private static native Object
- jniGetExpr(Object op) throws Cvc3Exception;
- private static native boolean
- jniIsNull(Object Op) throws Cvc3Exception;
-
- /// Constructor
-
- public Op(Object Op, EmbeddedManager embeddedManager) {
- super(Op, embeddedManager);
- }
-
-
- /// API (immutable)
-
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (!(o instanceof Op)) return false;
- boolean result = false;
- try {
- result = jniEquals(embedded(), ((Embedded)o).embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- // must return the same hash code for two objects if equals returns true
- public int hashCode() {
- try {
- return getExpr().hashCode();
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return 0;
- }
-
- public String toString() {
- String result = "";
- try {
- result = jniToString(embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- public ExprMut getExpr() throws Cvc3Exception {
- return new ExprMut(jniGetExpr(embedded()), embeddedManager());
- }
-
- public boolean isNull() throws Cvc3Exception {
- return jniIsNull(embedded());
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class OpMut extends Op {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public OpMut(Object OpMut, EmbeddedManager embeddedManager) {
- super(OpMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-INCLUDE: <expr_op.h>
-
-DEFINITION: Java_cvc3_Op_jniEquals
-jboolean c Op op1 c Op op2
-return *op1 == *op2;
-
-DEFINITION: Java_cvc3_Op_jniToString
-jstring c Op op
-return toJava(env, op->toString());
-
-
-DEFINITION: Java_cvc3_Op_jniGetExpr
-jobject c Op op
-return embed_const_ref<Expr>(env, &op->getExpr());
-
-DEFINITION: Java_cvc3_Op_jniIsNull
-jboolean c Op op
-return op->isNull();
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::ParserException */
-public class ParserException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public ParserException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Proof extends Embedded {
- // jni methods
-
- /// Constructor
-
- public Proof(Object Proof, EmbeddedManager embeddedManager) {
- super(Proof, embeddedManager);
- }
-
-
- /// API (immutable)
-
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class ProofMut extends Proof {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public ProofMut(Object ProofMut, EmbeddedManager embeddedManager) {
- super(ProofMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/**
- * QueryResult is an enum in Cvc3, but as we have to use java 1.4 we have to
- * use one of the usual tricks instead of java's Enum.
- *
- * To be independent of changes of the actual values of the c++ enum elements
- * they are passed by name from the JNI interface, so that changing them will
- * violently break the code (though unfortunately only at runtime).
- */
-public class QueryResult {
- private final String d_result;
-
- private QueryResult(String result) {
- d_result = result;
- }
-
- // value constants
- public static final QueryResult INVALID = new QueryResult("INVALID");
- public static final QueryResult VALID = new QueryResult("VALID");
- public static final QueryResult ABORT = new QueryResult("ABORT");
- public static final QueryResult UNKNOWN = new QueryResult("UNKNOWN");
-
- // names of c++ enum values, CVC3 maps INVALID->SAT and VALID->UNSAT
- private static Map valueMap = new HashMap() {
- {
- put("SATISFIABLE", INVALID);
- put("UNSATISFIABLE", VALID);
- put("UNKNOWN", UNKNOWN);
- put("ABORT", ABORT);
- }
-
- public static final long serialVersionUID = 1L;
- };
-
- // the QueryResult corresponding to a c++ enum value by name
- public static QueryResult get(String value) throws DebugException {
- QueryResult queryResult = (QueryResult) valueMap.get(value);
- if (queryResult == null) {
- throw new DebugException("QueryResult.constructor: unknown enum value: "
- + value);
- }
- return queryResult;
- }
-
- public String toString() {
- return d_result;
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Rational extends Embedded {
- // jni methods
- private static native Object
- jniRational1(int n, int d) throws Cvc3Exception;
- private static native Object
- jniRational2(String n, int base) throws Cvc3Exception;
- private static native Object
- jniRational3(String n, String d, int base) throws Cvc3Exception;
-
- private static native boolean
- jniEquals(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native String
- jniToString(Object Rational) throws Cvc3Exception;
- private static native int
- jniHash(Object Rational) throws Cvc3Exception;
-
- private static native boolean
- jniIsLe(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native boolean
- jniIsLt(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native boolean
- jniIsGe(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native boolean
- jniIsGt(Object Rational1, Object Rational2) throws Cvc3Exception;
-
- private static native Object
- jniPlus(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniMinus(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniMult(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniDivide(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniMod(Object Rational1, Object Rational2) throws Cvc3Exception;
-
-
- private static native Object
- jniGetNumerator(Object Rational) throws Cvc3Exception;
- private static native Object
- jniGetDenominator(Object Rational) throws Cvc3Exception;
- private static native boolean
- jniIsInteger(Object Rational) throws Cvc3Exception;
- private static native int
- jniGetInteger(Object Rational) throws Cvc3Exception;
-
-
- private static native Object
- jniGcd(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniLcm(Object Rational1, Object Rational2) throws Cvc3Exception;
- private static native Object
- jniAbs(Object Rational) throws Cvc3Exception;
- private static native Object
- jniFloor(Object Rational) throws Cvc3Exception;
- private static native Object
- jniCeil(Object Rational) throws Cvc3Exception;
-
- /// Constructor
-
- public Rational(Object Rational, EmbeddedManager embeddedManager) {
- super(Rational, embeddedManager);
- }
-
-
- public Rational(int n, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational1(n, 10), embeddedManager);
- }
-
- public Rational(int n, int d, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational1(n, d), embeddedManager);
- }
-
- public Rational(String n, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational2(n, 10), embeddedManager);
- }
-
- public Rational(String n, int base, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational2(n, base), embeddedManager);
- }
-
- public Rational(String n, String d, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational3(n, d, 10), embeddedManager);
- }
-
- public Rational(String n, String d, int base, EmbeddedManager embeddedManager) throws Cvc3Exception {
- this(jniRational3(n, d, base), embeddedManager);
- }
-
-
-
- /// API (immutable)
-
- // 'Problem' with equals/hashCode:
- // this is based on the wrapped c++ expressions.
- // as a consequence two Expr objects are equal iff
- // the wrapped expression is equal,
- // and are indistinguishable for example in a HashMap.
-
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (!(o instanceof Rational)) return false;
- boolean result = false;
- try {
- result = jniEquals(embedded(), ((Embedded)o).embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- // must return the same hash code for two objects if equals returns true
- public int hashCode() {
- try {
- return jniHash(embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- assert(false);
- return 0;
- }
-
-
- public String toString() {
- String result = "";
- try {
- result = jniToString(embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
-
- public boolean isLt(Rational r) throws Cvc3Exception {
- return jniIsLt(embedded(), r.embedded());
- }
-
- public boolean isLe(Rational r) throws Cvc3Exception {
- return jniIsLe(embedded(), r.embedded());
- }
-
- public boolean isGt(Rational r) throws Cvc3Exception {
- return jniIsGt(embedded(), r.embedded());
- }
-
- public boolean isGe(Rational r) throws Cvc3Exception {
- return jniIsGe(embedded(), r.embedded());
- }
-
-
-
- public Rational plus(Rational r) throws Cvc3Exception {
- return new Rational(jniPlus(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational minus(Rational r) throws Cvc3Exception {
- return new Rational(jniPlus(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational mult(Rational r) throws Cvc3Exception {
- return new Rational(jniPlus(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational divide(Rational r) throws Cvc3Exception {
- return new Rational(jniPlus(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational mod(Rational r) throws Cvc3Exception {
- return new Rational(jniPlus(embedded(), r.embedded()), embeddedManager());
- }
-
-
-
- public Rational getNumerator() throws Cvc3Exception {
- return new Rational(jniGetNumerator(embedded()), embeddedManager());
- }
-
- public Rational getDenominator() throws Cvc3Exception {
- return new Rational(jniGetDenominator(embedded()), embeddedManager());
- }
-
- public boolean isInteger() throws Cvc3Exception {
- return jniIsInteger(embedded());
- }
-
- public int getInteger() throws Cvc3Exception {
- assert(isInteger());
- return jniGetInteger(embedded());
- }
-
-
-
- public Rational gcd(Rational r) throws Cvc3Exception {
- return new Rational(jniGcd(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational lcm(Rational r) throws Cvc3Exception {
- return new Rational(jniLcm(embedded(), r.embedded()), embeddedManager());
- }
-
- public Rational abs() throws Cvc3Exception {
- return new Rational(jniAbs(embedded()), embeddedManager());
- }
-
- public Rational floor() throws Cvc3Exception {
- return new Rational(jniFloor(embedded()), embeddedManager());
- }
-
- public Rational ceil() throws Cvc3Exception {
- return new Rational(jniCeil(embedded()), embeddedManager());
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class RationalMut extends Rational {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public RationalMut(Object RationalMut, EmbeddedManager embeddedManager) {
- super(RationalMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-INCLUDE: <rational.h>
-
-DEFINITION: Java_cvc3_Rational_jniRational1
-jobject n int n n int d
-return embed_copy(env, Rational(n, d));
-
-DEFINITION: Java_cvc3_Rational_jniRational2
-jobject n string n n int d
-return embed_copy(env, Rational(n, d));
-
-DEFINITION: Java_cvc3_Rational_jniRational3
-jobject n string n n string d n int base
-return embed_copy(env, Rational(n, d, base));
-
-
-
-DEFINITION: Java_cvc3_Rational_jniEquals
-jboolean c Rational r1 c Rational r2
-return *r1 == *r2;
-
-DEFINITION: Java_cvc3_Rational_jniToString
-jstring c Rational r
-return toJava(env, r->toString());
-
-DEFINITION: Java_cvc3_Rational_jniHash
-jint c Rational r
-return r->hash();
-
-
-
-DEFINITION: Java_cvc3_Rational_jniIsLt
-jboolean c Rational r1 c Rational r2
-return *r1 < *r2;
-
-DEFINITION: Java_cvc3_Rational_jniIsLe
-jboolean c Rational r1 c Rational r2
-return *r1 <= *r2;
-
-DEFINITION: Java_cvc3_Rational_jniIsGt
-jboolean c Rational r1 c Rational r2
-return *r1 > *r2;
-
-DEFINITION: Java_cvc3_Rational_jniIsGe
-jboolean c Rational r1 c Rational r2
-return *r1 >= *r2;
-
-
-
-DEFINITION: Java_cvc3_Rational_jniPlus
-jobject c Rational r1 c Rational r2
-return embed_copy(env, *r1 + *r2);
-
-DEFINITION: Java_cvc3_Rational_jniMinus
-jobject c Rational r1 c Rational r2
-return embed_copy(env, *r1 + *r2);
-
-DEFINITION: Java_cvc3_Rational_jniMult
-jobject c Rational r1 c Rational r2
-return embed_copy(env, *r1 + *r2);
-
-DEFINITION: Java_cvc3_Rational_jniDivide
-jobject c Rational r1 c Rational r2
-return embed_copy(env, *r1 + *r2);
-
-DEFINITION: Java_cvc3_Rational_jniMod
-jobject c Rational r1 c Rational r2
-return embed_copy(env, *r1 % *r2);
-
-
-
-DEFINITION: Java_cvc3_Rational_jniGetNumerator
-jobject c Rational r
-return embed_copy(env, r->getNumerator());
-
-DEFINITION: Java_cvc3_Rational_jniGetDenominator
-jobject c Rational r
-return embed_copy(env, r->getDenominator());
-
-DEFINITION: Java_cvc3_Rational_jniIsInteger
-jboolean c Rational r
-return r->isInteger();
-
-DEFINITION: Java_cvc3_Rational_jniGetInteger
-jint c Rational r
-return r->getInt();
-
-DEFINITION: Java_cvc3_Rational_jniGcd
-jobject c Rational r1 c Rational r2
-return embed_copy(env, gcd(*r1, *r2));
-
-DEFINITION: Java_cvc3_Rational_jniLcm
-jobject c Rational r1 c Rational r2
-return embed_copy(env, lcm(*r1, *r2));
-
-DEFINITION: Java_cvc3_Rational_jniAbs
-jobject c Rational r
-return embed_copy(env, abs(*r));
-
-DEFINITION: Java_cvc3_Rational_jniFloor
-jobject c Rational r
-return embed_copy(env, floor(*r));
-
-DEFINITION: Java_cvc3_Rational_jniCeil
-jobject c Rational r
-return embed_copy(env, ceil(*r));
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/**
- * SatResult is derived from the QueryResult enum in Cvc3, but as we have to
- * use java 1.4 we have to use one of the usual tricks instead of java's Enum.
- *
- * To be independent of changes of the actual values of the c++ enum elements
- * they are passed by name from the JNI interface, so that changing them will
- * violently break the code (though unfortunately only at runtime).
- */
-public class SatResult {
- private final String d_result;
-
- private SatResult(String result) {
- d_result = result;
- }
-
- // names of c++ enum values
- public static final SatResult SATISFIABLE = new SatResult("SATISFIABLE");
- public static final SatResult UNSATISFIABLE = new SatResult("UNSATISFIABLE");
- public static final SatResult ABORT = new SatResult("ABORT");
- public static final SatResult UNKNOWN = new SatResult("UNKNOWN");
-
- // the SatResult corresponding to a c++ enum value by name
- public static SatResult get(String value) throws DebugException {
- if (value.equals(SATISFIABLE.toString())) {
- return SATISFIABLE;
- } else if (value.equals(UNSATISFIABLE.toString())) {
- return UNSATISFIABLE;
- } else if (value.equals(ABORT.toString())) {
- return ABORT;
- } else if (value.equals(UNKNOWN.toString())) {
- return UNKNOWN;
- } else {
- throw new DebugException("SatResult.constructor: unknown enum value: "
- + value);
- }
- }
-
- // the SatResult's c++ enum value
- public String toString() {
- return d_result;
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::SmtlibException */
-public class SmtlibException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public SmtlibException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::SoundException */
-public class SoundException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public SoundException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Statistics extends Embedded {
- // jni methods
-
- /// Constructor
-
- public Statistics(Object Statistics, EmbeddedManager embeddedManager) {
- super(Statistics, embeddedManager);
- }
-
-
- /// API (immutable)
-
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class StatisticsMut extends Statistics {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public StatisticsMut(Object StatisticsMut, EmbeddedManager embeddedManager) {
- super(StatisticsMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-class Test {
-
- public static void main(String args[]) {
- int regressLevel = 3;
- if (args.length > 1) {
- regressLevel = Integer.parseInt(args[0]);
- }
-
- boolean allPassed = true;
- System.out.println("Running API test, regress level = " + regressLevel);
- try {
- System.out.println("\ntest():");
- allPassed = test() && allPassed;
- System.out.println("\n}\ntest1():");
- allPassed = test1() && allPassed;
- System.out.println("\n}\ntest2():");
- allPassed = test2() && allPassed;
- System.out.println("\n}\ntest3():");
- allPassed = test3() && allPassed;
- System.out.println("\n}\ntest4():");
- allPassed = test4() && allPassed;
- if (regressLevel > 0) {
- System.out.println("\n}\n\ntest5():");
- allPassed = test5() && allPassed;
- }
- System.out.println("\n}\ntest6():");
- allPassed = test6() && allPassed;
- System.out.println("\n}\ntest7():");
- allPassed = test7() && allPassed;
- System.out.println("\n}\ntest8():");
- allPassed = test8() && allPassed;
- System.out.println("\n}\ntest9():");
- allPassed = test9(10 * regressLevel + 10) && allPassed;
- System.out.println("\n}\nbvtest9():");
- allPassed = bvtest9(regressLevel*3+2) && allPassed;
-
- // Test for obvious memory leaks
- int limit = 100 * regressLevel + 10;
- for (int i = 0; i < limit; ++i) {
- if (i % 100 == 0) System.out.println("test10[" + i + "]");
- allPassed = test10() && allPassed;
- }
-
- System.out.println("\n}\ntest11():");
- allPassed = test11() && allPassed;
- System.out.println("\n}\ntest12():");
- allPassed = test12() && allPassed;
- System.out.println("\n}\ntest13():");
- allPassed = test13() && allPassed;
- System.out.println("\n}\ntest14():");
- allPassed = test14() && allPassed;
- System.out.println("\n}\ntest15():");
- allPassed = test15() && allPassed;
- System.out.println("\n}\ntest16():");
- allPassed = test16() && allPassed;
- System.out.println("\n}\ntest17():");
- allPassed = test17() && allPassed;
- System.out.println("\n}\ntest18():");
- allPassed = test18() && allPassed;
- System.out.println("\n}\ntest19():");
- allPassed = test19() && allPassed;
- System.out.println("\n}\ntest22():");
- allPassed = test22() && allPassed;
- System.out.println("\n}\ntest23():");
- allPassed = test23() && allPassed;
- /* :TODO:
- if (regressLevel > 1) {
- System.out.println("\n}\ntestgeorge1():");
- George.testgeorge1();
- System.out.println("\n}\ntestgeorge2():");
- George.testgeorge2();
- System.out.println("\n}\ntestgeorge3():");
- George.testgeorge3();
- System.out.println("\n}\ntestgeorge4():");
- George.testgeorge4();
- System.out.println("\n}\ntestgeorge5():");
- George.testgeorge5();
- }
- */
- System.out.println("\n}\ntestNonlinearBV():");
- allPassed = testNonlinearBV() && allPassed;
- System.out.println("\n}\ntestDistinct():");
- allPassed = testDistinct() && allPassed;
- System.out.println("\n}");
- } catch (Exception e) {
- System.out.println("*** Exception caught: \n" + e);
- e.printStackTrace(System.out);
- allPassed = false;
- }
-
- if (allPassed) {
- System.out.println("Program exits successfully.");
- }
- else {
- System.out.println("Program exits with error status = " + allPassed + ".");
- }
- System.exit(allPassed ? 0 : 1);
- }
-
-
- public static void DebugAssert(boolean condition, String message) throws Cvc3Exception {
- if (!condition) {
- throw new DebugException(message);
- }
- }
-
- // Check whether e is valid
- public static boolean check(ValidityChecker vc, Expr e) throws Cvc3Exception {
- return check(vc, e, true);
- }
-
- public static boolean check(ValidityChecker vc, Expr e, boolean verbose) throws Cvc3Exception {
- if(verbose) {
- System.out.println("Query: " + e.toString());
- }
- QueryResult result = vc.query(e);
- if (result == QueryResult.VALID) {
- if (verbose) System.out.println("Valid\n");
- return true;
- }
- else if (result == QueryResult.INVALID) {
- if (verbose) System.out.println("Invalid\n");
- return false;
- }
- if (verbose) System.out.println("Returned neither valid nor invalid\n");
- return false;
- }
-
- public static void printResult(QueryResult result) throws Cvc3Exception {
- if (result == QueryResult.VALID) {
- System.out.println("Result Valid");
- }
- else if (result == QueryResult.INVALID) {
- System.out.println("Result Invalid");
- }
- else if (result == QueryResult.UNKNOWN) {
- System.out.println("Result Unknown");
- }
- else if (result == QueryResult.ABORT) {
- System.out.println("Aborted");
- } else {
- assert(false);
- }
- }
-
- // Make a new assertion - disposes expression
- public static void newAssertion(ValidityChecker vc, Expr e) throws Cvc3Exception {
- System.out.println("Assert: " + e);
- vc.assertFormula(e);
- }
-
-
-
- public static boolean test() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Type it = vc.intType(); //int
- Op f = vc.createOp("f", vc.funType(it, it));
- Expr z = vc.varExpr("z", it);
- Expr e = vc.funExpr(f, vc.funExpr(f, z));
- e = e.getChild(0);
- Expr f2 = vc.funExpr(f, e);
- Expr f3 = vc.funExpr(f, f2);
-
- DebugAssert(!e.equals(f2) && !e.equals(f3), "Refcount problems");
-
- Expr x = vc.boundVarExpr("x", "0", it); //x0:int
- List xs = new ArrayList();
- xs.add(x); //<x0:int>
- Op lxsx = vc.lambdaExpr(xs, x); //\<x0:int>. x0:int
- Expr y = vc.ratExpr(1, 1); //1
- List ys = new ArrayList();
- ys.add(y); //<1>
- Expr lxsxy = vc.funExpr(lxsx, y); //(\<x0:int>. x0:int)1
- Expr lxsxys = vc.funExpr(lxsx, ys); //(\<x0:int>. x0:int)<1>
- System.out.println("Lambda application: " + lxsxy);
- System.out.println("Simplified: " + vc.simplify(lxsxy));
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
- public static boolean test1() throws Cvc3Exception {
- // It is important that all Expr objects are deleted before vc is
- // deleted. Therefore, we enclose them in a scope of try{ }catch
- // block.
- //
- // Also, vc methods may throw an Exception, and we want to delete vc
- // even in those exceptional cases.
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- flags.setFlag("dump-log", ".test1.cvc");
- vc = ValidityChecker.create(flags);
-
- boolean b = check(vc, vc.trueExpr());
- DebugAssert(b, "Should be valid");
-
- vc.push();
- b = check(vc, vc.falseExpr());
- DebugAssert(!b, "Should be invalid");
- vc.pop();
-
- // Check p OR ~p
-
- Expr p = vc.varExpr("p", vc.boolType());
- Expr e = vc.orExpr(p, vc.notExpr(p));
-
- b = check(vc, e);
- DebugAssert(b, "Should be valid");
-
- // Check x = y . f(x) = f(y)
-
- Expr x = vc.varExpr("x", vc.realType());
- Expr y = vc.varExpr("y", vc.realType());
-
- Type real2real = vc.funType(vc.realType(), vc.realType());
- Op f = vc.createOp("f", real2real);
- Expr fx = vc.funExpr(f, x);
- Expr fy = vc.funExpr(f, y);
-
- e = vc.impliesExpr(vc.eqExpr(x,y),vc.eqExpr(fx, fy));
- b = check(vc, e);
- DebugAssert(b, "Should be valid");
-
- // Check f(x) = f(y) . x = y
-
- e = vc.impliesExpr(vc.eqExpr(fx,fy),vc.eqExpr(x, y));
- int scopeLevel = vc.scopeLevel();
- vc.push();
- b = check(vc, e);
- DebugAssert(!b, "Should be invalid");
-
- // Get counter-example
-
- System.out.println("Scope level: " + vc.scopeLevel());
- System.out.println("Counter-example:");
- List assertions = vc.getCounterExample();
- for (int i = 0; i < assertions.size(); ++i) {
- System.out.println((Expr)assertions.get(i));
- }
- System.out.println("End of counter-example");
- System.out.println();
-
- // Reset to initial scope
- System.out.println("Resetting");
- vc.pop();
- DebugAssert(scopeLevel == vc.scopeLevel(), "scope error");
- System.out.println("Scope level: " + vc.scopeLevel());
- System.out.println();
-
- // Check w = x & x = y & y = z & f(x) = f(y) & x = 1 & z = 2
-
- Expr w = vc.varExpr("w", vc.realType());
- Expr z = vc.varExpr("z", vc.realType());
-
- System.out.println("Push Scope");
- System.out.println();
- vc.push();
-
- newAssertion(vc, vc.eqExpr(w, x));
- newAssertion(vc, vc.eqExpr(x, y));
- newAssertion(vc, vc.eqExpr(y, z));
- newAssertion(vc, vc.eqExpr(fx, fy));
- newAssertion(vc, vc.eqExpr(x, vc.ratExpr(1)));
-
- System.out.println("simplify(w) = " + vc.simplify(w));
- DebugAssert(vc.simplify(w).equals(vc.ratExpr(1)), "Expected simplify(w) = 1");
-
- newAssertion(vc, vc.eqExpr(z, vc.ratExpr(2)));
- System.out.println("Inconsistent?: " + vc.inconsistent());
-
- System.out.println("Assumptions Used:");
- assertions = vc.inconsistentReasons();
- for (int i = 0; i < assertions.size(); ++i) {
- System.out.println((Expr)assertions.get(i));
- }
-
- System.out.println("Pop Scope");
- System.out.println();
- vc.pop();
-
- System.out.println("simplify(w) = " + vc.simplify(w));
- DebugAssert(vc.simplify(w).equals(w), "Expected simplify(w) = w");
-
- System.out.println("Inconsistent?: " + vc.inconsistent());
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test1(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static boolean test2() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- Expr bexpr = vc.varExpr("b", vc.intType());
- vc.assertFormula(vc.ltExpr(bexpr, vc.ratExpr(10)));
-
- Expr c = vc.varExpr("c", vc.intType());
- vc.assertFormula(vc.orExpr(vc.eqExpr(c, vc.ratExpr(0)), vc.eqExpr(c, vc.ratExpr(1))));
-
- boolean b = check(vc, vc.leExpr(bexpr, vc.ratExpr(10)));
- DebugAssert(b, "Should be valid");
-
- b = check(vc, vc.falseExpr());
- DebugAssert(!b, "Should be invalid");
- vc.returnFromCheck();
-
- // Check x = y . g(x,y) = g(y,x)
-
- Expr x = vc.varExpr("x", vc.realType());
- Expr y = vc.varExpr("y", vc.realType());
-
- Type real = vc.realType();
- List RxR = new ArrayList();
- RxR.add(real);
- RxR.add(real);
-
- Type realxreal2real = vc.funType(RxR, real);
- Op g = vc.createOp("g", realxreal2real);
-
- Expr gxy = vc.funExpr(g, x, y);
- Expr gyx = vc.funExpr(g, y, x);
-
- Expr e = vc.impliesExpr(vc.eqExpr(x,y),vc.eqExpr(gxy, gyx));
- b = check(vc, e);
- DebugAssert(b, "Should be valid");
-
- Op h = vc.createOp("h", realxreal2real);
-
- Expr hxy = vc.funExpr(h, x, y);
- Expr hyx = vc.funExpr(h, y, x);
-
- e = vc.impliesExpr(vc.eqExpr(x,y),vc.eqExpr(hxy, hyx));
- b = check(vc, e);
- DebugAssert(b, "Should be valid");
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test2(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static ExprMut ltLex(ValidityChecker vc, Expr i1, Expr i2, Expr j1, Expr j2) throws Cvc3Exception {
- Expr res = vc.ltExpr(i1, j1);
- return vc.orExpr(res, vc.andExpr(vc.eqExpr(i1, j1), vc.ltExpr(i2, j2)));
- }
-
- public static ExprMut createTestFormula(ValidityChecker vc, Expr i1, Expr i2, Expr r1, Expr r2)
- throws Cvc3Exception {
- Expr lt1 = ltLex(vc, r1, r2, i1, i2);
- Expr lt2 = ltLex(vc, i2, i1, r2, r1);
- return vc.andExpr(lt1, lt2);
- }
-
- public static boolean test3() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- Expr i = vc.varExpr("i", vc.realType());
- Expr j = vc.varExpr("j", vc.realType());
- Expr k = vc.varExpr("k", vc.realType());
-
- Expr one = vc.ratExpr(1);
-
- Expr test = createTestFormula(vc, i, j,
- vc.minusExpr(i, one), vc.minusExpr(j, k));
-
- System.out.println("Trying test: " + test);
-
- vc.push();
- QueryResult result = vc.query(test);
- if (result == QueryResult.VALID) {
- System.out.println("Test Valid");
- vc.pop();
- }
- else {
- List assertions = vc.getCounterExample();
- System.out.println("Test Invalid Under Conditions:");
- for (int index = 0; index < assertions.size(); ++index) {
- System.out.println(assertions.get(index));
- }
-
- // Try assertions one by one
- for (int index = 0; index < assertions.size(); ++index) {
- Expr condition = vc.notExpr((Expr)assertions.get(index));
- System.out.println("Trying test under condition: " + condition);
- vc.pop();
- vc.push();
- printResult(vc.query(vc.impliesExpr(condition, test)));
- }
- }
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test3(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static boolean test4() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- Expr i = vc.varExpr("i", vc.realType());
- Expr j = vc.varExpr("j", vc.realType());
- Expr k = vc.varExpr("k", vc.realType());
-
- Expr one = vc.ratExpr(1);
-
- Expr test = createTestFormula(vc, i, j,
- vc.minusExpr(i, one), vc.minusExpr(j, k));
-
- System.out.println("Trying test: " + test);
-
- vc.push();
- QueryResult result = vc.query(test);
- if (result == QueryResult.VALID) {
- System.out.println("Test Valid");
- }
- else {
- List assertions = vc.getCounterExample();
- System.out.println("Test Invalid Under Conditions:");
- for (int index = 0; index < assertions.size(); ++index) {
- System.out.println(assertions.get(index));
- }
-
- // Try assertions one by one
- for (int index = 0; index < assertions.size(); ++index) {
- Expr condition = vc.notExpr((Expr)assertions.get(index));
- System.out.println("Trying test under condition: " + condition);
- vc.pop();
- vc.push();
- printResult(vc.query(vc.impliesExpr(condition, test)));
- }
- }
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test4(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static void findLeaves(Expr e, List l) throws Cvc3Exception {
- int ar = e.arity();
- if (ar > 0) {
- for (int i = 0; i < ar; ++i) {
- findLeaves(e.getChild(i), l);
- }
- return;
- }
- l.add(e);
- }
-
- public static boolean hasij(Expr e, Expr i, Expr j) throws Cvc3Exception {
- int ar = e.arity();
- if (ar > 0) {
- for (int k = 0; k < ar; ++k)
- if (hasij(e.getChild(k), i, j)) return true;
- return false;
- }
- if (e.equals(i) || e.equals(j)) return true;
- return false;
- }
-
- public static Expr plusExpr(ValidityChecker vc, List kids) throws Cvc3Exception {
- if (kids.size() == 0) return vc.ratExpr(0);
- else if (kids.size() == 1) return (Expr)kids.get(0);
- else if (kids.size() == 2) return vc.plusExpr((Expr)kids.get(0), (Expr)kids.get(1));
- else {
- Expr r = (Expr)kids.get(kids.size() - 1);
- kids.remove(kids.size() - 1);
- return vc.plusExpr(plusExpr(vc, kids), r);
- }
- }
-
- public static boolean test5() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- Expr i = vc.varExpr("i1", vc.realType());
- Expr j = vc.varExpr("i2", vc.realType());
- Expr p = vc.varExpr("p", vc.realType());
- Expr q = vc.varExpr("q", vc.realType());
- Expr r = vc.varExpr("r", vc.realType());
- Expr a = vc.varExpr("arb_addr", vc.realType());
- Expr N = vc.varExpr("N", vc.realType());
-
- Expr M = vc.varExpr("M", vc.arrayType(vc.realType(), vc.realType()));
-
- Expr M2 = vc.writeExpr(M, vc.plusExpr(q, i), vc.readExpr(M, vc.plusExpr(r, i)));
-
- Expr M1 = vc.writeExpr(M, vc.plusExpr(p, j), vc.readExpr(M, vc.plusExpr(r, j)));
-
- Expr e = vc.eqExpr(vc.readExpr(vc.writeExpr(M2, vc.plusExpr(p, j),
- vc.readExpr(M2, vc.plusExpr(r, j))), a),
- vc.readExpr(vc.writeExpr(M1, vc.plusExpr(q, i),
- vc.readExpr(M1, vc.plusExpr(r, i))), a));
-
- Expr one = vc.ratExpr(1);
- Expr zero = vc.ratExpr(0);
-
- Expr qmp = vc.minusExpr(q, p);
- Expr qmr = vc.minusExpr(q, r);
-
- List hyp = new ArrayList();
- hyp.add(vc.ltExpr(i, j));
- // hyp.add(vc.orExpr(vc.geExpr(qmp, N), vc.leExpr(qmp, zero)));
- // hyp.add(vc.orExpr(vc.geExpr(qmr, N), vc.leExpr(qmr, zero)));
-
- Expr test = vc.impliesExpr(vc.andExpr(hyp), e);
- Expr query;
-
- System.out.println("Checking verification condition:" + test);
-
- vc.push();
- QueryResult result = vc.query(test);
- if (result == QueryResult.VALID) {
- System.out.println("Test Valid");
- }
- else {
- List conditions = new ArrayList();
- int req;
-
- List assertions = vc.getCounterExample();
-
- System.out.println("Invalid Under Conditions:");
- for (int index = 0; index < assertions.size(); ++index) {
- if (((Expr)assertions.get(index)).equals(vc.notExpr(test))) {
- for (; index < assertions.size()-1; ++index) {
- assertions.set(index, assertions.get(index+1));
- }
- assertions.remove(assertions.size() - 1);
- break;
- }
- }
- for (int index = 0; index < assertions.size(); ++index) {
- System.out.println(assertions.get(index));
- }
-
- System.out.println();
-
- // Try assertions one by one
- for (int index = 0; index < assertions.size(); ++index) {
- e = (Expr)assertions.get(index);
-
- // Check condition for eligibility
- if (e.isNot()) {
- System.out.println("Condition ineligible: negation: " + e);
- System.out.println();
- continue;
- }
- if (e.isEq()) {
- req = 2;
- }
- else req = 1;
-
- List leaves = new ArrayList();
- findLeaves(e, leaves);
- for (int index2 = 0; index2 < leaves.size(); ++index2) {
- if (!((Expr)leaves.get(index2)).isVar() ||
- ((Expr)leaves.get(index2)).equals(i) ||
- ((Expr)leaves.get(index2)).equals(j) ||
- ((Expr)leaves.get(index2)).equals(a))
- continue;
- req--;
- }
- if (req > 0) {
- System.out.println("Condition ineligible: not enough non-loop variables: " + e);
- System.out.println();
- continue;
- }
-
- System.out.println("Condition selected: " + e);
- System.out.println();
-
- conditions.add(vc.notExpr(e));
- System.out.println("Trying verification condition with hypothesis: "
- + vc.andExpr(conditions));
- vc.pop();
- vc.push();
- query = vc.impliesExpr(vc.andExpr(conditions), test);
- result = vc.query(test);
- if (result == QueryResult.VALID) {
- System.out.println("Result Valid");
- break;
- }
- else {
- assertions = vc.getCounterExample();
-
- System.out.println("Invalid Under Conditions:");
- for (int index2 = 0; index2 < assertions.size(); ++index2) {
- if (((Expr)assertions.get(index2)).equals(vc.notExpr(query))) {
- for (; index2 < assertions.size()-1; ++index2) {
- assertions.set(index2, assertions.get(index2+1));
- }
- assertions.remove(assertions.size() - 1);
- break;
- }
- }
-
- for (int index2 = 0; index2 < assertions.size(); ++index2) {
- System.out.println(assertions.get(index2));
- }
- System.out.println();
- index = assertions.size();
- }
- }
-
- System.out.println();
- System.out.println("Attempting to remove loop variables");
- // replace loop variables in conditions
- List newConditions = new ArrayList();
- List newPlus = new ArrayList();
- boolean foundi, foundj, negi, negj;
- Expr minusone = vc.ratExpr(-1);
- int index;
- for (index = 0; index < conditions.size(); ++index) {
- if (((Expr)conditions.get(index)).getChild(0).isEq()) {
- e = vc.simplify(
- vc.minusExpr(((Expr)conditions.get(index)).getChild(0).getChild(0),
- ((Expr)conditions.get(index)).getChild(0).getChild(1)));
- if (hasij(e, i, j)) {
- if (e.isPlus()) {
- newPlus.clear();
- newPlus.add(e.getChild(0));
- foundi = foundj = negi = negj = false;
- for (int index2 = 1; index2 < e.arity(); index2++) {
- Expr term = e.getChild(index2);
- if (term.equals(i) && !foundi) foundi = true;
- else if (term.equals(j) && !foundj) {
- foundj = true;
- negj = true;
- }
- else if (term.isMult()
- && term.getChild(0).equals(minusone)
- && term.getChild(1).equals(i)
- && !foundi) {
- foundi = true;
- negi = true;
- }
- else if (term.isMult()
- && term.getChild(0).equals(minusone)
- && term.getChild(1).equals(j)
- && !foundj)
- foundj = true;
- else newPlus.add(term);
- }
- if (foundi && foundj && (negi && negj || (!negi && !negj))) {
- e = plusExpr(vc, newPlus);
- if (negi && negj) e = vc.uminusExpr(e);
- e = vc.simplify(e);
- if (!hasij(e, i, j)) {
- newConditions.add(vc.orExpr(vc.geExpr(e, N), vc.leExpr(e, zero)));
- continue;
- }
- }
- }
- System.out.println("Unable to remove loop variables:" + e);
- break;
- }
- }
- newConditions.add(conditions.get(index));
- }
- if (index == conditions.size()) {
- System.out.println("Loop variables successfully removed:");
- Expr cond = (newConditions.size()>0)?
- vc.andExpr(newConditions) : vc.trueExpr();
- System.out.println(cond);
-
- List loopConditions = new ArrayList();
- loopConditions.add(cond);
- loopConditions.add(vc.geExpr(i, one));
- loopConditions.add(vc.geExpr(j, one));
- loopConditions.add(vc.leExpr(i, N));
- loopConditions.add(vc.leExpr(j, N));
- vc.pop();
- vc.push();
- System.out.println("Final query");
- printResult(vc.query(vc.impliesExpr(vc.andExpr(loopConditions), test)));
- }
- }
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test5(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
-
- public static boolean test6() throws Cvc3Exception {
- ValidityChecker vc1 = null;
- ValidityChecker vc2 = null;
- try {
- vc1 = ValidityChecker.create();
- vc2 = ValidityChecker.create();
-
- Type real1 = vc1.realType();
-
- Expr x1 = vc1.varExpr("x", real1);
- Expr y1 = vc1.boundVarExpr("y", "0", real1);
-
- System.out.println("vc1 variables: " + x1 + ", " + y1);
-
- Expr x2 = vc2.varExpr("x", vc2.importType(real1));
- Expr y2 = vc2.boundVarExpr("y", "0", vc2.realType());
-
- System.out.println("vc2 variables: " + x2 + ", " + y2);
- System.out.println("vars imported to vc2 from vc1: "
- + vc2.importExpr(x1) + ", " + vc2.importExpr(y1));
- Expr t1 = vc1.trueExpr();
- Expr and1 = vc1.andExpr(t1, vc1.falseExpr());
- Op f1 = vc1.createOp("f", vc1.funType(real1, real1));
- Expr fx1 = vc1.funExpr(f1, x1);
- Expr f5_1 = vc1.funExpr(f1, vc1.ratExpr(5,1));
- Type rt1 = vc1.recordType("foo", real1, "bar", real1);
- Expr r1 = vc1.recordExpr("foo", fx1, "bar", f5_1);
- Expr r1_eq = vc1.eqExpr(r1, vc1.recUpdateExpr(r1, "foo", f5_1));
- Type art1 = vc1.arrayType(real1, rt1);
- Expr ar1 = vc1.varExpr("ar", art1);
- Expr ar_eq1 = vc1.eqExpr(vc1.writeExpr(ar1, x1, r1), ar1);
- Expr query1 = vc1.eqExpr(vc1.recSelectExpr(vc1.readExpr(ar1, x1), "foo"),
- vc1.recSelectExpr(r1, "bar"));
-
- System.out.println("*** VC #1:");
- newAssertion(vc1, r1_eq);
- newAssertion(vc1, ar_eq1);
- check(vc1, query1);
-
- System.out.println("*** VC #2:");
- newAssertion(vc2, vc2.importExpr(r1_eq));
- newAssertion(vc2, vc2.importExpr(ar_eq1));
- check(vc2, vc2.importExpr(query1));
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test6(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc1 != null) vc1.delete();
- if (vc2 != null) vc2.delete();
- }
- }
-
-
-
- public static boolean test7() throws Cvc3Exception {
- ValidityChecker vc1 = null;
- ValidityChecker vc2 = null;
- try {
- vc1 = ValidityChecker.create();
- vc2 = ValidityChecker.create();
-
- Expr e1 = vc1.varExpr("e1", vc1.realType());
- Expr e2 = vc2.varExpr("e2", vc2.realType());
- newAssertion(vc2, vc2.eqExpr(vc2.importExpr(e1), e2));
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test7(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc1 != null) vc1.delete();
- if (vc2 != null) vc2.delete();
- }
- }
-
-
-
- public static boolean test8() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- List vec = new ArrayList();
- vec.add(vc.boundVarExpr("x", "x", vc.realType()));
- Expr lambda = vc.lambdaExpr(vec, vc.falseExpr()).getExpr();
- try {
- Type t = vc.subtypeType(lambda, vc.nullExpr());
- DebugAssert(false, "Typechecking exception expected");
- } catch(TypecheckException e) {
- // fall through
- }
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test5(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
-
- public static ExprMut adder(ValidityChecker vc, Expr a, Expr b, Expr c) throws Cvc3Exception {
- return vc.notExpr(vc.iffExpr(vc.notExpr(vc.iffExpr(a,b)),c));
- }
-
- public static ExprMut carry(ValidityChecker vc, Expr a, Expr b, Expr c) throws Cvc3Exception {
- return vc.orExpr(vc.andExpr(a,b), vc.orExpr(vc.andExpr(b,c),vc.andExpr(a,c)));
- }
-
- public static List add(ValidityChecker vc, List a, List b) throws Cvc3Exception {
- int N = a.size();
- Expr c = vc.falseExpr();
-
- List sum = new ArrayList();
- for (int i = 0; i < N; i++) {
- sum.add(adder(vc,(Expr)a.get(i),(Expr)b.get(i),c));
- c = carry(vc,(Expr)a.get(i),(Expr)b.get(i),c);
- }
- return sum;
- }
-
- public static ExprMut vectorEq(ValidityChecker vc, List a, List b) throws Cvc3Exception {
- int N = a.size();
- ExprMut result = vc.trueExpr();
-
- for (int i = 0; i < N; i++) {
- result = vc.andExpr(result, vc.iffExpr((Expr)a.get(i), (Expr)b.get(i)));
- }
- return result;
- }
-
-
- public static boolean test9(int N) throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- int i;
- List a = new ArrayList();
- List b = new ArrayList();
-
- for (i=0; i < N; i++) {
- a.add(vc.varExpr("a" + Integer.toString(i), vc.boolType()));
- b.add(vc.varExpr("b" + Integer.toString(i), vc.boolType()));
- }
-
- List sum1 = add(vc,a,b);
- List sum2 = add(vc,b,a);
-
- Expr q = vectorEq(vc,sum1,sum2);
-
- check(vc, q);
-
- // Proof p = vc.getProof();
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test9(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test22() throws Cvc3Exception {
- ValidityChecker vc = null;
-
- try {
- vc = ValidityChecker.create();
- Type intType = vc.intType();
- Type fType = vc.funType(intType, intType);
-
- Op f = vc.createOp("f", fType);
- Expr x = vc.varExpr("x", intType);
- Expr fx = vc.exprFromString("f(x)");
-
- Expr p = vc.exprFromString("FORALL (x:INT) : x < f(x)");
-
- List patternvv = new ArrayList();
- List patternv = new ArrayList();
- patternv.add(fx);
- patternvv.add(patternv);
-
- vc.setTriggers(p, patternv);
- DebugAssert(patternvv.equals(p.getTriggers()),
- "Expected p.getTriggers() == patternvv: " + p.toString());
-
- vc.setMultiTriggers(p, patternvv);
-
- DebugAssert(patternvv.equals(p.getTriggers()),
- "Expected p.getTriggers() == patternvv: " + p.toString());
-
- List vars = new ArrayList();
- vars.add(x);
- Expr r = vc.forallExpr(vars, vc.ltExpr(x, fx), patternv);
-
- DebugAssert(patternvv.equals(r.getTriggers()),
- "Expected r.getTriggers() == patternvv: " + r.toString());
-
- Expr s = vc.exprFromString("FORALL (x:INT) : x > f(x)");
- vc.setTrigger(s, fx);
-
- List trigsvv = s.getTriggers();
- DebugAssert(trigsvv.size() == 1, "Expected s.getTriggers().size() == 1: "
- + trigsvv.size());
-
- List trigsv = (List)trigsvv.get(0);
- DebugAssert(trigsv.size() == 1, "Expected s.getTriggers()[0].size() == 1: "
- + trigsv.size());
-
- DebugAssert(fx.equals(trigsv.get(0)),
- "Expected s.getTriggers()[0][0] == fx: " + (trigsv.get(0)));
-
- Expr t = vc.exprFromString("FORALL (x:INT) : x > f(x)");
- vc.setMultiTrigger(t, patternv);
- trigsvv = t.getTriggers();
- DebugAssert(trigsvv.size() == 1, "Expected t.getTriggers().size() == 1: "
- + trigsvv.size());
-
- trigsv = (List)trigsvv.get(0);
- DebugAssert(trigsv.size() == 1, "Expected t.getTriggers()[0].size() == 1: "
- + trigsv.size());
-
- DebugAssert(fx.equals(trigsv.get(0)),
- "Expected t.getTriggers()[0][0] == fx: " + (trigsv.get(0)));
-
- Expr u = vc.forallExprMultiTriggers(vars, vc.ltExpr(x, fx), patternvv);
-
- DebugAssert(patternvv.equals(u.getTriggers()),
- "Expected u.getTriggers() == patternvv: " + u.toString());
-
- } catch (Exception e) {
- System.out.println("*** Exception caught in test22(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null)
- vc.delete();
- }
- return true;
- }
-
- private static boolean test23() throws Cvc3Exception {
- ValidityChecker vc = null;
-
- try {
- vc = ValidityChecker.create();
- Type intType = vc.intType();
-
- Expr x = vc.varExpr("x",intType);
- Expr y= vc.varExpr("y",intType);
- Expr a = vc.varExpr("a",intType);
- Expr b = vc.varExpr("b",intType);
-
- Expr s = vc.exprFromString("x < y");
- Expr t = vc.exprFromString("a < b");
-
- System.out.println( "s=" + s + "\nt=" + t );
-
- List oldExprs = new ArrayList(), newExprs = new ArrayList();
- oldExprs.add(x);
- oldExprs.add(y);
- newExprs.add(a);
- newExprs.add(b);
-
- Expr u = s.subst(oldExprs,newExprs);
- System.out.println( "u=" + u );
-
- DebugAssert( t.equals(u), "Expected t==u" );
- } catch(Throwable e) {
- System.out.println( "*** Exception caught in test23(): ");
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null)
- vc.delete();
- }
- return true;
- }
-
- public static ExprMut bvadder(ValidityChecker vc, Expr a, Expr b, Expr c) throws Cvc3Exception {
- return vc.newBVXorExpr(a, vc.newBVXorExpr(b, c));
- }
-
-
- public static ExprMut bvcarry(ValidityChecker vc, Expr a, Expr b, Expr c) throws Cvc3Exception {
- return vc.newBVOrExpr(vc.newBVAndExpr(a,b), vc.newBVOrExpr(vc.newBVAndExpr(b,c),vc.newBVAndExpr(a,c)));
- }
-
- public static List bvadd(ValidityChecker vc, List a, List b) throws Cvc3Exception {
- int N=a.size();
- Expr c = vc.newBVConstExpr(new Rational(0, vc.embeddedManager()), 1);
-
- List sum = new ArrayList();
- for (int i = 0; i < N; i++) {
- sum.add(bvadder(vc,(Expr)a.get(i),(Expr)b.get(i),c));
- c = bvcarry(vc,(Expr)a.get(i),(Expr)b.get(i),c);
- }
- return sum;
- }
-
-
- public static ExprMut bvvectorEq(ValidityChecker vc, List a, List b) throws Cvc3Exception {
- int N = a.size();
- ExprMut result = vc.newBVConstExpr("1");
-
- for (int i = 0; i < N; i++) {
- result = vc.newBVAndExpr(result, vc.newBVXnorExpr((Expr)a.get(i), (Expr)b.get(i)));
- }
- return result;
- }
-
-
- public static boolean bvtest9(int N) throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Expr a, b, sum1;
- a = vc.varExpr("a", vc.bitvecType(N));
- b = vc.varExpr("b", vc.bitvecType(N));
- List kids = new ArrayList();
- kids.add(a);
- kids.add(b);
- sum1 = vc.newBVPlusExpr(N, kids);
-
- List avec = new ArrayList();
- List bvec = new ArrayList();
- List sum1vec = new ArrayList();
- for (int i = 0; i < N; i++) {
- avec.add(vc.newBVExtractExpr(a, i, i));
- bvec.add(vc.newBVExtractExpr(b, i, i));
- sum1vec.add(vc.newBVExtractExpr(sum1, i, i));
- }
-
- List sum2 = bvadd(vc,avec,bvec);
-
- Expr q = bvvectorEq(vc,sum1vec,sum2);
-
- check(vc, vc.eqExpr(q,vc.newBVConstExpr("1")));
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in bvtest9(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test10() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Expr x = vc.varExpr("x", vc.realType());
- Expr y = vc.varExpr("y", vc.realType());
-
- Type real = vc.realType();
- List RxR = new ArrayList();
- RxR.add(real);
- RxR.add(real);
-
- Type realxreal2real = vc.funType(RxR, real);
- Op g = vc.createOp("g", realxreal2real);
-
- Expr gxy = vc.funExpr(g, x, y);
- Expr gyx = vc.funExpr(g, y, x);
-
- Expr ia = vc.eqExpr(x,y);
- Expr ib = vc.eqExpr(gxy, gyx);
-
- Expr e = vc.impliesExpr(vc.eqExpr(x,y),vc.eqExpr(gxy, gyx));
- check(vc, e, false);
-
- Op h = vc.createOp("h", realxreal2real);
-
- Expr hxy = vc.funExpr(h, x, y);
- Expr hyx = vc.funExpr(h, y, x);
-
- e = vc.impliesExpr(vc.eqExpr(x,y),vc.eqExpr(hxy, hyx));
- check(vc, e, false);
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test10(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
-
- public static int printImpliedLiterals(ValidityChecker vc) throws Cvc3Exception {
- int count = 0;
- System.out.println("Implied Literals:");
- Expr impLit = vc.getImpliedLiteral();
- while (!impLit.isNull()) {
- ++count;
- System.out.println(impLit);
- impLit = vc.getImpliedLiteral();
- }
- return count;
- }
-
- public static boolean test11() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Expr x = vc.varExpr("x", vc.realType());
- Expr y = vc.varExpr("y", vc.realType());
- Expr z = vc.varExpr("z", vc.realType());
-
- Type real = vc.realType();
- Type real2real = vc.funType(real, real);
- Type real2bool = vc.funType(real, vc.boolType());
- Op f = vc.createOp("f", real2real);
- Op p = vc.createOp("p", real2bool);
-
- Expr fx = vc.funExpr(f, x);
- Expr fy = vc.funExpr(f, y);
-
- Expr px = vc.funExpr(p, x);
- Expr py = vc.funExpr(p, y);
-
- Expr xeqy = vc.eqExpr(x, y);
- Expr yeqx = vc.eqExpr(y, x);
- Expr xeqz = vc.eqExpr(x, z);
- Expr zeqx = vc.eqExpr(z, x);
- Expr yeqz = vc.eqExpr(y, z);
- Expr zeqy = vc.eqExpr(z, y);
-
- int c;
-
- vc.registerAtom(vc.eqExpr(x,vc.ratExpr(0,1)));
- vc.registerAtom(xeqy);
- vc.registerAtom(yeqx);
- vc.registerAtom(xeqz);
- vc.registerAtom(zeqx);
- vc.registerAtom(yeqz);
- vc.registerAtom(zeqy);
- vc.registerAtom(px);
- vc.registerAtom(py);
- vc.registerAtom(vc.eqExpr(fx, fy));
-
- System.out.println("Push");
- vc.push();
-
- System.out.println("Assert x = y");
- vc.assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- DebugAssert(c==3,"Implied literal error 0");
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert x /= z");
- vc.assertFormula(vc.notExpr(xeqz));
- c = printImpliedLiterals(vc);
- DebugAssert(c==4,"Implied literal error 1");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert y /= z");
- vc.assertFormula(vc.notExpr(yeqz));
- c = printImpliedLiterals(vc);
- DebugAssert(c==4,"Implied literal error 2");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert p(x)");
- vc.assertFormula(px);
- c = printImpliedLiterals(vc);
- DebugAssert(c==2,"Implied literal error 3");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert p(y)");
- vc.assertFormula(py);
- c = printImpliedLiterals(vc);
- DebugAssert(c==2,"Implied literal error 4");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert y = x");
- vc.assertFormula(yeqx);
- c = printImpliedLiterals(vc);
- DebugAssert(c==3,"Implied literal error 5");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert p(x)");
- vc.assertFormula(px);
- c = printImpliedLiterals(vc);
- DebugAssert(c==1,"Implied literal error 6");
- System.out.println("Assert x = y");
- vc.assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- DebugAssert(c==4,"Implied literal error 7");
- System.out.println("Pop");
- vc.pop();
-
- System.out.println("Push");
- vc.push();
- System.out.println("Assert NOT p(x)");
- vc.assertFormula(vc.notExpr(px));
- c = printImpliedLiterals(vc);
- DebugAssert(c==1,"Implied literal error 8");
- System.out.println("Assert x = y");
- vc.assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- DebugAssert(c==4,"Implied literal error 9");
- System.out.println("Pop");
- vc.pop();
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test11(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test12() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Type realType = vc.realType();
- Type intType = vc.intType();
- Type boolType = vc.boolType();
- vc.push();
- int initial_layer = vc.stackLevel();
- int initial_scope = vc.scopeLevel();
- Expr exprObj_trueID = vc.trueExpr();
- Expr exprObj_falseID = vc.notExpr(vc.trueExpr());
- vc.popTo(initial_layer);
- DebugAssert(vc.scopeLevel() == initial_scope, "Expected no change");
- DebugAssert(vc.stackLevel() == initial_layer, "Expected no change");
- // TODO: what happens if we push and then popscope?
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test12(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test13() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- flags.setFlag("dump-log", ".test13.cvc");
- vc = ValidityChecker.create(flags);
-
- Expr rat_one = vc.ratExpr(1);
- Expr rat_two = vc.ratExpr(2);
- Expr rat_minus_one = vc.ratExpr(-1);
-
- QueryResult query_result;
- query_result = vc.query(vc.eqExpr(rat_two,rat_one));
- System.out.println("2=1 " + query_result);
- query_result = vc.query(vc.eqExpr(rat_two,rat_minus_one));
- System.out.println("2=-1 " + query_result);
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test13(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static Expr func1(ValidityChecker vc) throws Cvc3Exception {
- // local Expr 'tmp'
- Expr tmp = vc.varExpr("tmp", vc.boolType());
- return vc.trueExpr();
- }
-
-
- public static boolean test14() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- // func call: ok
- Expr test1 = func1(vc);
-
- // func call: fail
- Expr test2 = func1(vc);
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test13(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test15() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- /*****************************************************
- * array declaration *
- *****************************************************/
-
- // array: index type
- Type index_type = vc.subrangeType(vc.ratExpr(0),
- vc.ratExpr(3));
- // array: data type
- Type data_type = vc.subrangeType(vc.ratExpr(0),
- vc.ratExpr(3));
- // array type: [0 .. 3] of 0 .. 3
- Type array_type = vc.arrayType(index_type, data_type);
- Expr arr = vc.varExpr("array", array_type);
-
- // array: [1,1,0,0]
- arr = vc.writeExpr(arr, vc.ratExpr(0), vc.ratExpr(1));
- arr = vc.writeExpr(arr, vc.ratExpr(1), vc.ratExpr(1));
- arr = vc.writeExpr(arr, vc.ratExpr(2), vc.ratExpr(0));
- arr = vc.writeExpr(arr, vc.ratExpr(3), vc.ratExpr(0));
-
-
-
- /*****************************************************
- * forall Expr *
- *****************************************************/
-
- // for loop: index
- Expr id = vc.boundVarExpr("id", "0", vc.subrangeType(vc.ratExpr(0),
- vc.ratExpr(2)));
- List vars = new ArrayList();
- vars.add(id);
-
- // for loop: body
- Expr for_body = vc.leExpr(vc.readExpr(arr, id),
- vc.readExpr(arr, vc.plusExpr(id, vc.ratExpr(1))));
- // forall expr
- Expr forall_expr = vc.forallExpr(vars, for_body);
-
- vc.push();
- check(vc, forall_expr);
-
- System.out.println("Scope level: " + vc.scopeLevel());
- System.out.println("Counter-example:");
- List assertions = vc.getCounterExample();
- for (int i = 0; i < assertions.size(); ++i) {
- System.out.println(assertions.get(i));
- }
- System.out.println("End of counter-example");
- System.out.println("");
- vc.pop();
-
- /*****************************************************
- * manual expansion *
- *****************************************************/
-
- Expr e1 = vc.leExpr(vc.readExpr(arr, vc.ratExpr(0)),
- vc.readExpr(arr, vc.ratExpr(1)));
- Expr e2 = vc.leExpr(vc.readExpr(arr, vc.ratExpr(1)),
- vc.readExpr(arr, vc.ratExpr(2)));
- Expr e3 = vc.leExpr(vc.readExpr(arr, vc.ratExpr(2)),
- vc.readExpr(arr, vc.ratExpr(3)));
- Expr manual_expr = vc.andExpr(e1, vc.andExpr(e2, e3));
-
-
-
- /*****************************************************
- * exists Expr *
- *****************************************************/
-
- // exists: index
- Expr id_ex = vc.varExpr("id_ex", vc.subrangeType(vc.ratExpr(0),
- vc.ratExpr(2)));
- List vars_ex = new ArrayList();
- vars_ex.add(id_ex);
-
- // exists: body
- Expr ex_body = vc.gtExpr(vc.readExpr(arr, id_ex),
- vc.readExpr(arr, vc.plusExpr(id_ex, vc.ratExpr(1))));
- // exists expr
- Expr ex_expr = vc.existsExpr(vars_ex, ex_body);
-
-
-
-
- /*****************************************************
- * ??? forall <==> manual expansion *
- *****************************************************/
- System.out.println("Checking forallExpr <==> manual expansion ...");
- if (vc.query(vc.iffExpr(forall_expr, manual_expr)) == QueryResult.VALID)
- System.out.println(" -- yes.");
- else {
- System.out.println(" -- no, with counter examples as ");
-
- List assert1 = vc.getCounterExample();
- for (int i = 0; i < assert1.size(); i ++)
- System.out.println(assert1.get(i));
- }
- System.out.println();
-
-
-
- /*****************************************************
- * ??? !forall <==> existsExpr *
- *****************************************************/
- System.out.println();
- System.out.println("Checking !forallExpr <==> existsExpr ...");
- if (vc.query(vc.iffExpr(vc.notExpr(forall_expr), ex_expr)) == QueryResult.VALID)
- System.out.println(" -- yes.");
- else if (vc.incomplete()) {
- System.out.println(" -- incomplete:");
- List reasons = vc.incompleteReasons();
- for (int i = 0; i < reasons.size(); ++i)
- System.out.println(reasons.get(i));
- }
- else {
- System.out.println(" -- no, with counter examples as ");
-
- List assert2 = vc.getCounterExample();
- for (int i = 0; i < assert2.size(); i ++)
- System.out.println(assert2.get(i));
- }
-
- System.out.println();
- System.out.println("End of testcases.");
- System.out.println();
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test15(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static boolean test16() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
-
- Type zto100 = vc.subrangeType(vc.ratExpr(0), vc.ratExpr(100));
- Expr mem = vc.varExpr("mem", vc.arrayType(zto100, vc.intType()));
- Expr a = vc.varExpr("a", zto100);
- Expr b = vc.varExpr("b", zto100);
-
- Expr lhs = vc.readExpr(vc.writeExpr(mem, a, vc.ratExpr(30)), b);
- Expr rhs = vc.readExpr(vc.writeExpr(mem, b, vc.ratExpr(40)), a);
-
- Expr q = vc.impliesExpr(vc.notExpr(vc.eqExpr(a, b)), vc.eqExpr(lhs, rhs));
-
- check(vc, q);
-
- System.out.println("Scope level: " + vc.scopeLevel());
- System.out.println("Counter-example:");
- List assertions = vc.getCounterExample();
- DebugAssert(assertions.size() > 0, "Expected non-empty counter-example");
- for (int i = 0; i < assertions.size(); ++i) {
- System.out.println(assertions.get(i));
- }
- System.out.println("End of counter-example");
- System.out.println();
-
- HashMap m = vc.getConcreteModel();
- if(m.isEmpty())
- System.out.println(" Did not find concrete model for any vars");
- else {
- System.out.println("%Satisfiable Variable Assignment: %");
- Iterator it = m.entrySet().iterator();
- while(it.hasNext()) {
- Map.Entry next = (Map.Entry)it.next();
- Expr eq;
- Expr key = (Expr)next.getKey();
- Expr value = (Expr)next.getValue();
- if (key.getType().isBoolean()) {
- DebugAssert(value.isBooleanConst(),
- "Bad variable assignement: e = "+ key
- +"\n\n val = "+ value);
- if(value.isTrue())
- eq = key;
- else
- eq = vc.notExpr(key);
- }
- else
- eq = vc.eqExpr(key, value);
- //:TODO:System.out.println(Expr(ASSERT, eq));
- System.out.println(eq);
- }
- }
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test16(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test17() throws Cvc3Exception {
- ValidityChecker vc = null;
- try {
- vc = ValidityChecker.create();
- try {
- List selectors = new ArrayList();
- List types = new ArrayList();
-
- selectors.add("car");
- types.add(vc.intType().getExpr());
- selectors.add("cdr");
- types.add(vc.stringExpr("list"));
-
- Type badList = vc.dataType("list", "cons", selectors, types);
- DebugAssert(false, "Typechecking exception expected");
- } catch(TypecheckException e) {
- // fall through
- }
-
- vc.delete();
-
- vc = ValidityChecker.create();
- {
- List constructors = new ArrayList();
- List selectors = new ArrayList();
- List selectors0 = new ArrayList();
- List selectors1 = new ArrayList();
- selectors.add(selectors0);
- selectors.add(selectors1);
- List types = new ArrayList();
- List types0 = new ArrayList();
- List types1 = new ArrayList();
- types.add(types0);
- types.add(types1);
-
- constructors.add("cons");
- selectors0.add("car");
- types0.add(vc.intType().getExpr());
- selectors0.add("cdr");
- types0.add(vc.stringExpr("list"));
- constructors.add("null");
-
- Type list = vc.dataType("list", constructors, selectors, types);
-
- Expr x = vc.varExpr("x", vc.intType());
- Expr y = vc.varExpr("y", list);
-
- List args = new ArrayList();
- args.add(x);
- args.add(y);
- Expr cons = vc.datatypeConsExpr("cons", args);
-
- Expr sel = vc.datatypeSelExpr("car", cons);
- boolean b = check(vc, vc.eqExpr(sel, x));
- DebugAssert(b, "Should be valid");
- }
- vc.delete();
-
- vc = ValidityChecker.create();
- try {
- List names = new ArrayList();
- List constructors = new ArrayList();
- List constructors0 = new ArrayList();
- List constructors1 = new ArrayList();
- constructors.add(constructors0);
- constructors.add(constructors1);
- List selectors = new ArrayList();
- List selectors0 = new ArrayList();
- List selectors1 = new ArrayList();
- List selectors00 = new ArrayList();
- List selectors10 = new ArrayList();
- selectors.add(selectors0);
- selectors0.add(selectors00);
- selectors.add(selectors1);
- selectors1.add(selectors10);
- List types = new ArrayList();
- List types0 = new ArrayList();
- List types1 = new ArrayList();
- List types00 = new ArrayList();
- List types10 = new ArrayList();
- types.add(types0);
- types0.add(types00);
- types.add(types1);
- types1.add(types10);
-
- names.add("list1");
-
- constructors0.add("cons1");
- selectors00.add("car1");
- types00.add(vc.intType().getExpr());
- selectors00.add("cdr1");
- types00.add(vc.stringExpr("list2"));
-
- names.add("list2");
-
- constructors1.add("cons2");
- selectors10.add("car2");
- types10.add(vc.intType().getExpr());
- selectors10.add("cdr2");
- types10.add(vc.stringExpr("list1"));
- constructors1.add("null");
-
- List returnTypes = vc.dataType(names, constructors, selectors, types);
-
- Type list1 = (Type)returnTypes.get(0);
- Type list2 = (Type)returnTypes.get(1);
-
- Expr x = vc.varExpr("x", vc.intType());
- Expr y = vc.varExpr("y", list2);
- Expr z = vc.varExpr("z", list1);
-
- List args = new ArrayList();
- args.add(x);
- args.add(y);
- Expr cons1 = vc.datatypeConsExpr("cons1", args);
-
- Expr isnull = vc.datatypeTestExpr("null", y);
- Expr hyp = vc.andExpr(vc.eqExpr(z, cons1), isnull);
-
- Expr nullE = vc.datatypeConsExpr("null", new ArrayList());
-
- args = new ArrayList();
- args.add(x);
- args.add(nullE);
- Expr cons1_2 = vc.datatypeConsExpr("cons1", args);
-
- boolean b = check(vc, vc.impliesExpr(hyp, vc.eqExpr(z, cons1_2)));
- DebugAssert(b, "Should be valid");
- } catch(TypecheckException e) {
- // fall through
- }
-
- vc.delete();
-
- vc = ValidityChecker.create();
- {
- List constructors = new ArrayList();
- List selectors = new ArrayList();
- selectors.add(new ArrayList());
- selectors.add(new ArrayList());
- List types = new ArrayList();
- types.add(new ArrayList());
- types.add(new ArrayList());
-
- constructors.add("A");
- constructors.add("B");
-
- Type two = vc.dataType("two", constructors, selectors, types);
-
- Expr x = vc.varExpr("x", two);
- Expr y = vc.varExpr("y", two);
- Expr z = vc.varExpr("z", two);
-
- List args = new ArrayList();
- args.add(vc.notExpr(vc.eqExpr(x,y)));
- args.add(vc.notExpr(vc.eqExpr(y,z)));
- args.add(vc.notExpr(vc.eqExpr(x,z)));
-
- boolean b = check(vc, vc.notExpr(vc.andExpr(args)));
- DebugAssert(b, "Should be valid");
- }
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test17(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- }
- }
-
-
- public static boolean test18() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("tcc", true);
- vc = ValidityChecker.create(flags);
-
- List names = new ArrayList();
- List constructors = new ArrayList();
- List constructors0 = new ArrayList();
- List constructors1 = new ArrayList();
- List constructors2 = new ArrayList();
- constructors.add(constructors0);
- constructors.add(constructors1);
- constructors.add(constructors2);
- List selectors = new ArrayList();
- List selectors0 = new ArrayList();
- List selectors1 = new ArrayList();
- List selectors2 = new ArrayList();
- List selectors00 = new ArrayList();
- List selectors01 = new ArrayList();
- List selectors10 = new ArrayList();
- List selectors11 = new ArrayList();
- List selectors20 = new ArrayList();
- List selectors21 = new ArrayList();
- selectors.add(selectors0);
- selectors0.add(selectors00);
- selectors0.add(selectors01);
- selectors.add(selectors1);
- selectors1.add(selectors10);
- selectors1.add(selectors11);
- selectors.add(selectors2);
- selectors2.add(selectors20);
- selectors2.add(selectors21);
- List types = new ArrayList();
- List types0 = new ArrayList();
- List types1 = new ArrayList();
- List types2 = new ArrayList();
- List types00 = new ArrayList();
- List types01 = new ArrayList();
- List types10 = new ArrayList();
- List types11 = new ArrayList();
- List types20 = new ArrayList();
- List types21 = new ArrayList();
- types.add(types0);
- types0.add(types00);
- types0.add(types01);
- types.add(types1);
- types1.add(types10);
- types1.add(types11);
- types.add(types2);
- types2.add(types20);
- types2.add(types21);
-
- names.add("nat");
-
- constructors0.add("zero");
- constructors0.add("succ");
- selectors01.add("pred");
- types01.add(vc.stringExpr("nat"));
-
- names.add("list");
-
- constructors1.add("cons");
- selectors10.add("car");
- types10.add(vc.stringExpr("tree"));
- selectors10.add("cdr");
- types10.add(vc.stringExpr("list"));
- constructors1.add("null");
-
- names.add("tree");
-
- constructors2.add("leaf");
- constructors2.add("node");
- selectors21.add("data");
- types21.add(vc.stringExpr("nat"));
- selectors21.add("children");
- types21.add(vc.stringExpr("list"));
-
- List returnTypes = vc.dataType(names, constructors, selectors, types);
-
- Type nat = (Type)returnTypes.get(0);
- Type listType = (Type)returnTypes.get(1);
- Type tree = (Type)returnTypes.get(2);
-
- Expr x = vc.varExpr("x", nat);
-
- List args = new ArrayList();
- Expr zero = vc.datatypeConsExpr("zero", args);
- Expr nullE = vc.datatypeConsExpr("null", args);
- Expr leaf = vc.datatypeConsExpr("leaf", args);
-
- vc.push();
- try {
- check(vc, vc.notExpr(vc.eqExpr(zero, nullE)));
- DebugAssert(false, "Should have caught tcc exception");
- } catch (TypecheckException e) { }
-
- vc.pop();
- args.add(vc.datatypeSelExpr("pred",x));
- Expr spx = vc.datatypeConsExpr("succ", args);
- Expr spxeqx = vc.eqExpr(spx, x);
- vc.push();
- try {
- check(vc, spxeqx);
- DebugAssert(false, "Should have caught tcc exception");
- } catch(TypecheckException e) { }
-
- vc.pop();
- boolean b = check(vc, vc.impliesExpr(vc.datatypeTestExpr("succ", x), spxeqx));
- DebugAssert(b, "Should be valid");
-
- b = check(vc, vc.orExpr(vc.datatypeTestExpr("zero", x),
- vc.datatypeTestExpr("succ", x)));
- DebugAssert(b, "Should be valid");
-
- Expr y = vc.varExpr("y", nat);
- Expr xeqy = vc.eqExpr(x, y);
- args.clear();
- args.add(x);
- Expr sx = vc.datatypeConsExpr("succ", args);
- args.clear();
- args.add(y);
- Expr sy = vc.datatypeConsExpr("succ", args);
- Expr sxeqsy = vc.eqExpr(sx,sy);
- b = check(vc, vc.impliesExpr(xeqy, sxeqsy));
- DebugAssert(b, "Should be valid");
-
- b = check(vc, vc.notExpr(vc.eqExpr(sx, zero)));
- DebugAssert(b, "Should be valid");
-
- b = check(vc, vc.impliesExpr(sxeqsy, xeqy));
- DebugAssert(b, "Should be valid");
-
- b = check(vc, vc.notExpr(vc.eqExpr(sx, x)));
- DebugAssert(b, "Should be valid");
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test18(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-
- public static boolean test19() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- Type RealType= vc.realType();
- Type IntType= vc.intType();
- Type BoolType= vc.boolType();
- Type PtrType = RealType;
- Type HeapType = vc.arrayType(PtrType, RealType);
-
- // -----------------
- //ASSERT(FORALL (CVCi: REAL): (Hs[CVCi] = Ht[CVCi]));
- //QUERY(Hs[(t6 + (3 * 1))] = Ht[(t6 + (3 * 1))]);
- Expr Ad = vc.boundVarExpr("CVCi", "CVCi", RealType);
- Expr Hs = vc.varExpr("Hs", HeapType);
- Expr Ht = vc.varExpr("Ht", HeapType);
- Expr t6 = vc.varExpr("t6", RealType);
-
- List Vars = new ArrayList();
- Vars.add(Ad);
- // Body = (Hs[Ad] = Ht[Ad])
- Expr Body = vc.eqExpr(vc.readExpr(Hs, Ad), vc.readExpr(Ht, Ad));
-
- //A = forall (~i:REAL): Body
- Expr A = vc.forallExpr(Vars, Body);
-
- // Q = (Hs[t6] = Ht[t6])
- Expr Q = vc.eqExpr(vc.readExpr(Hs, t6), vc.readExpr(Ht, t6));
-
- // ----------- CHECK A . Q
- vc.push();
-
- vc.assertFormula(A);
-
- System.out.println("Checking formula " + Q);
- System.out.println(" in context " + A);
-
- QueryResult Succ = vc.query(Q);
-
- DebugAssert(Succ == QueryResult.VALID, "Expected valid formula");
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test19(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
- public static boolean testNonlinearBV() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- flags.setFlag("dagify-exprs",false);
- vc = ValidityChecker.create(flags);
-
- int bvLength = 8;
-
- Rational zero = new Rational(0, vc.embeddedManager());
-
- Expr x = vc.varExpr("x", vc.bitvecType(bvLength));
- Expr y = vc.varExpr("y", vc.bitvecType(bvLength));
- Expr bv0 = vc.newBVConstExpr(zero, bvLength);
-
- // BVUDIV
- vc.push();
- System.out.println("Checking BVUDIV:");
- Expr udiv = vc.newBVUDivExpr(x, y);
- Expr umult = vc.newBVMultExpr(bvLength, udiv, y);
- Expr test = vc.eqExpr(bv0, y);
- boolean result = check(vc, vc.impliesExpr(vc.notExpr(test), vc.newBVLEExpr(umult, x)), true);
- DebugAssert(result, "Expected valid formula");
- vc.pop();
-
- // BVUREM
- vc.push();
- System.out.println("Checking BVUREM:");
- Expr urem = vc.newBVURemExpr(x, y);
- result = check(vc, vc.impliesExpr(vc.notExpr(test), vc.newBVLTExpr(urem, y)), true);
- DebugAssert(result, "Expected valid formula");
- vc.pop();
-
- // BVSDIV
- vc.push();
- System.out.println("Checking BVSDIV:");
- Expr sdiv = vc.newBVSDivExpr(x, y);
- Expr smult = vc.newBVMultExpr(bvLength, sdiv, y);
- Expr signed_test = vc.newBVSLEExpr(bv0, x);
- signed_test = vc.andExpr(signed_test, vc.newBVSLTExpr(bv0, y));
- result = check(vc, vc.impliesExpr(signed_test, vc.newBVSLEExpr(smult, x)), true);
- DebugAssert(result, "Expected valid formula");
- vc.pop();
-
- // BVSREM
- vc.push();
- System.out.println("Checking BVSREM:");
- Expr srem = vc.newBVSRemExpr(x, y);
- result = check(vc, vc.impliesExpr(signed_test, vc.newBVLTExpr(srem, y)), true);
- DebugAssert(result, "Expected valid formula");
- vc.pop();
-
- // BVSMOD
- vc.push();
- System.out.println("Checking BVSMOD:");
- Expr smod = vc.newBVSModExpr(x, y);
- result = check(vc, vc.impliesExpr(signed_test, vc.newBVLTExpr(smod, y)), true);
- DebugAssert(result, "Expected valid formula");
- vc.pop();
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test19(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
- public static boolean testDistinct() throws Cvc3Exception {
- ValidityChecker vc = null;
- FlagsMut flags = null;
- try {
- flags = ValidityChecker.createFlags(null);
- vc = ValidityChecker.create(flags);
-
- int bvLength = 2;
- int elements_count = bvLength*bvLength + 1;
-
- List elements = new ArrayList();
- for (int i = 0; i < elements_count; i ++)
- elements.add(vc.varExpr("x" + i, vc.bitvecType(bvLength)));
- Expr distinct = vc.distinctExpr(elements);
- boolean result = check(vc, vc.notExpr(distinct), true);
- DebugAssert(result, "Expected valid formula");
-
- return true;
- } catch (Exception e) {
- System.out.println("*** Exception caught in test19(): \n" + e);
- e.printStackTrace(System.out);
- return false;
- } finally {
- if (vc != null) vc.delete();
- if (flags != null) flags.delete();
- }
- }
-
-}
-
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class Theorem extends Embedded {
- // jni methods
-
- /// Constructor
-
- public Theorem(Object Theorem, EmbeddedManager embeddedManager) {
- super(Theorem, embeddedManager);
- }
-
-
- /// API (immutable)
-
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class TheoremMut extends Theorem {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public TheoremMut(Object TheoremMut, EmbeddedManager embeddedManager) {
- super(TheoremMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-// used to enforce timeout in class Cvc3
-class TimeoutHandler extends TimerTask {
- public void run() {
- System.out.println("self-timeout.");
- System.exit(1);
- }
-}
+++ /dev/null
-package cvc3;
-
-public class Type extends Embedded {
- // jni methods
- private static native boolean
- jniIsAny(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsArray(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsBitvector(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsBool(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsDatatype(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsFunction(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsNull(Object Type) throws Cvc3Exception;
- private static native boolean
- jniIsSubtype(Object Type) throws Cvc3Exception;
-
- private static native Object
- jniGetExpr(Object Type) throws Cvc3Exception;
- private static native int
- jniArity(Object Type) throws Cvc3Exception;
- private static native Type
- jniGetChild(Object Type, int i) throws Cvc3Exception;
-
- private static native boolean
- jniEquals(Object Type1, Object Type2) throws Cvc3Exception;
- private static native String
- jniToString(Object Type) throws Cvc3Exception;
-
- private static native Object jniConstr(Object expr) throws Cvc3Exception;
-
- public static Type valueOf(Expr expr) throws Cvc3Exception {
- return new Type(jniConstr(expr.embedded()), expr.embeddedManager());
- }
-
- /// Constructor
-
- public Type(Object Type, EmbeddedManager embeddedManager) {
- super(Type, embeddedManager);
- }
-
-
- /// API (immutable)
-
- public boolean isAny() throws Cvc3Exception {
- return jniIsAny(embedded());
- }
-
- public boolean isArray() throws Cvc3Exception {
- return jniIsArray(embedded());
- }
-
- public boolean isBitvector() throws Cvc3Exception {
- return jniIsBitvector(embedded());
- }
-
- public boolean isBoolean() throws Cvc3Exception {
- return jniIsBool(embedded());
- }
-
- public boolean isDatatype() throws Cvc3Exception {
- return jniIsDatatype(embedded());
- }
-
- public boolean isFunction() throws Cvc3Exception {
- return jniIsFunction(embedded());
- }
-
- public boolean isNull() throws Cvc3Exception {
- return jniIsNull(embedded());
- }
-
- public boolean isSubtype() throws Cvc3Exception {
- return jniIsSubtype(embedded());
- }
-
-
-
-
-
- public Expr getExpr() throws Cvc3Exception {
- return new Expr(jniGetExpr(embedded()), embeddedManager());
- }
-
- public int arity() throws Cvc3Exception {
- return jniArity(embedded());
- }
-
- public Type getChild(int i) throws Cvc3Exception {
- assert(i >= 0 && i < arity());
- return new Type(jniGetChild(embedded(), i), embeddedManager());
- }
-
-
- // Printing
- public String toString() {
- String result = "";
- try {
- result = jniToString(embedded());
- } catch (Cvc3Exception e) {
- System.out.println(e);
- assert(false);
- }
- return result;
- }
-
- public boolean equals(Object o) {
- if (this == o) return true;
-
- if (!(o instanceof Type)) return false;
- boolean result = false;
- try {
- result = jniEquals(embedded(), ((Embedded)o).embedded());
- } catch (Cvc3Exception e) {
- assert(false);
- }
- return result;
- }
-
- // must return the same hash code for two exprs if equals returns true
-
- public int hashCode() {
- try {
- return getExpr().hashCode();
- } catch (Cvc3Exception e) {
- assert(false);
- }
- assert(false);
- return 0;
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-public class TypeMut extends Type {
- // jni methods
-
-
- /// Constructor
-
- // create embedded object
- public TypeMut(Object TypeMut, EmbeddedManager embeddedManager) {
- super(TypeMut, embeddedManager);
- }
-
-
- /// API (mutable)
-}
+++ /dev/null
-//INCLUDE: "kinds.h"
-//INCLUDE: "type.h"
-//INCLUDE: "theory_array.h"
-//INCLUDE: "theory_bitvector.h"
-//INCLUDE: "theory_datatype.h"
-
-DEFINITION: Java_cvc3_Type_jniConstr
-jobject c Expr expr
-return embed_copy<Type>(env, Type(*expr));
-
-DEFINITION: Java_cvc3_Type_jniIsAny
-jboolean c Type type
-return type->getExpr().getKind() == ANY_TYPE;
-
-DEFINITION: Java_cvc3_Type_jniIsArray
-jboolean c Type type
-return type->getExpr().getKind() == ARRAY;
-
-DEFINITION: Java_cvc3_Type_jniIsBitvector
-jboolean c Type type
-return type->getExpr().getKind() == BITVECTOR;
-
-DEFINITION: Java_cvc3_Type_jniIsBool
-jboolean c Type type
-return type->isBool();
-
-DEFINITION: Java_cvc3_Type_jniIsDatatype
-jboolean c Type type
-return ::isDatatype(*type);
-
-DEFINITION: Java_cvc3_Type_jniIsFunction
-jboolean c Type type
-return type->isFunction();
-
-DEFINITION: Java_cvc3_Type_jniIsNull
-jboolean c Type type
-return type->isNull();
-
-DEFINITION: Java_cvc3_Type_jniIsSubtype
-jboolean c Type type
-return type->isSubtype();
-
-
-
-DEFINITION: Java_cvc3_Type_jniGetExpr
-jobject c Type type
-return embed_const_ref<Expr>(env, &type->getExpr());
-
-DEFINITION: Java_cvc3_Type_jniArity
-jint c Type type
-return type->arity();
-
-DEFINITION: Java_cvc3_Type_jniGetChild
-jobject c Type type n int i
-return embed_copy<Type>(env, (*type)[i]);
-
-
-
-
-DEFINITION: Java_cvc3_Type_jniEquals
-jboolean c Type type1 c Type type2
-return *type1 == *type2;
-
-DEFINITION: Java_cvc3_Type_jniToString
-jstring c Type type
-return toJava(env, type->toString());
-
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-/** mirrors CVC3::TypecheckException */
-public class TypecheckException extends Cvc3Exception {
-
- private final static long serialVersionUID = 1L;
-
- public TypecheckException(String message) {
- super(message);
- }
-}
+++ /dev/null
-package cvc3;
-
-import java.util.*;
-
-import cvc3.Expr;
-import cvc3.JniUtils;
-
-public class ValidityChecker extends Embedded {
- // jni methods
- private static native Object
- jniCreate1() throws Cvc3Exception;
- private static native Object
- jniCreate2(Object Flags) throws Cvc3Exception;
- private static native Object
- jniCreateFlags() throws Cvc3Exception;
- private static native Object
- jniGetFlags(Object ValidityChecker) throws Cvc3Exception;
-
-
- private static native Object
- jniBoolType(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniRealType(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniIntType(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniSubrangeType(Object ValidityChecker, Object lExpr, Object rExpr) throws Cvc3Exception;
- private static native Object
- jniSubtypeType(Object ValidityChecker, Object predExpr, Object witnessExpr) throws Cvc3Exception;
- private static native Object
- jniTupleType1(Object ValidityChecker, Object Type0, Object Type1) throws Cvc3Exception;
- private static native Object
- jniTupleType2(Object ValidityChecker, Object Type0, Object Type1, Object Type2) throws Cvc3Exception;
- private static native Object
- jniTupleType3(Object ValidityChecker, Object[] Types) throws Cvc3Exception;
- private static native Object
- jniRecordType1(Object ValidityChecker, String field, Object Type) throws Cvc3Exception;
- private static native Object
- jniRecordType2(Object ValidityChecker, String field0, Object Type0,
- String field1, Object Type1) throws Cvc3Exception;
- private static native Object
- jniRecordType3(Object ValidityChecker, String field0, Object Type0,
- String field1, Object Type1, String field2, Object Type2) throws Cvc3Exception;
- private static native Object
- jniRecordType4(Object ValidityChecker, Object[] fields, Object[] types) throws Cvc3Exception;
- private static native Object
- jniDataType1(Object ValidityChecker, String name, String constructor,
- Object[] selectors, Object[] types) throws Cvc3Exception;
- private static native Object
- jniDataType2(Object ValidityChecker, String name, Object[] constructors,
- Object[] selectors, Object[] types) throws Cvc3Exception;
- private static native Object[]
- jniDataType3(Object ValidityChecker, Object[] names, Object[] constructors,
- Object[] selectors, Object[] types) throws Cvc3Exception;
- private static native Object
- jniAnyType(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniArrayLiteral(Object ValidityChecker, Object indexVar, Object bodyExpr) throws Cvc3Exception;
- private static native Object
- jniArrayType(Object ValidityChecker, Object TypeIndex, Object TypeData) throws Cvc3Exception;
- private static native Object
- jniBitvecType(Object ValidityChecker, int n) throws Cvc3Exception;
- private static native Object
- jniFunType1(Object ValidityChecker, Object typeDom, Object TypeRan) throws Cvc3Exception;
- private static native Object
- jniFunType2(Object ValidityChecker, Object[] typeDom, Object TypeRan) throws Cvc3Exception;
- private static native Object
- jniCreateType1(Object ValidityChecker, String typeName) throws Cvc3Exception;
- private static native Object
- jniCreateType2(Object ValidityChecker, String typeName, Object TypeDef) throws Cvc3Exception;
- private static native Object
- jniLookupType(Object ValidityChecker, String typeName) throws Cvc3Exception;
-
-
- private static native Object
- jniGetExprManager(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniNullExpr(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniVarExpr1(Object ValidityChecker, String name, Object Type) throws Cvc3Exception;
- private static native Object
- jniVarExpr2(Object ValidityChecker, String name, Object Type, Object defExpr) throws Cvc3Exception;
- private static native Object
- jniBoundVarExpr(Object ValidityChecker, String name, String uid, Object Type) throws Cvc3Exception;
- /*private static native Object
- jniBoundVarExpr2(Object ValidityChecker, Object Type) throws Cvc3Exception;
- */
- private static native Object
- jniLookupVar(Object ValidityChecker, String name) throws Cvc3Exception;
- private static native Object
- jniLookupOp(Object ValidityChecker, String name) throws Cvc3Exception;
- private static native Object
- jniGetType(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetBaseType1(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetBaseType2(Object ValidityChecker, Object Type) throws Cvc3Exception;
- private static native Object
- jniGetTypePred(Object ValidityChecker, Object Type, Object Expr) throws Cvc3Exception;
- private static native Object
- jniStringExpr(Object ValidityChecker, String str) throws Cvc3Exception;
- private static native Object
- jniIdExpr(Object ValidityChecker, String name) throws Cvc3Exception;
- private static native Object
- jniListExpr1(Object ValidityChecker, Object[] kids) throws Cvc3Exception;
- private static native Object
- jniListExpr2(Object ValidityChecker, Object Expr1) throws Cvc3Exception;
- private static native Object
- jniListExpr3(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniListExpr4(Object ValidityChecker, Object Expr1, Object Expr2, Object Expr3) throws Cvc3Exception;
- private static native Object
- jniListExpr5(Object ValidityChecker, String op, Object[] kids) throws Cvc3Exception;
- private static native Object
- jniListExpr6(Object ValidityChecker, String op, Object Expr1) throws Cvc3Exception;
- private static native Object
- jniListExpr7(Object ValidityChecker, String op, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniListExpr8(Object ValidityChecker, String op, Object Expr1, Object Expr2, Object Expr3) throws Cvc3Exception;
- private static native void
- jniPrintExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniParseExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniParseType(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniImportExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniImportType(Object ValidityChecker, Object Type) throws Cvc3Exception;
- private static native void
- jniCmdsFromString(Object ValidityChecker, String s) throws Cvc3Exception;
- private static native Object
- jniExprFromString(Object ValidityChecker, String s) throws Cvc3Exception;
- private static native Object
- jniTrueExpr(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniFalseExpr(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniNotExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniAndExpr1(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniAndExpr2(Object ValidityChecker, Object[] ExprChildren) throws Cvc3Exception;
- private static native Object
- jniOrExpr1(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniOrExpr2(Object ValidityChecker, Object[] Exprchildren) throws Cvc3Exception;
- private static native Object
- jniImpliesExpr(Object ValidityChecker, Object ExprHyp, Object ExprConc) throws Cvc3Exception;
- private static native Object
- jniIffExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniEqExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniDistinctExpr(Object ValidityChecker, Object[] ExprChildren) throws Cvc3Exception;
- private static native Object
- jniIteExpr(Object ValidityChecker, Object ExprIf, Object ExprThen, Object ExprElse) throws Cvc3Exception;
- private static native Object
- jniCreateOp1(Object ValidityChecker, String name, Object Type) throws Cvc3Exception;
- private static native Object
- jniCreateOp2(Object ValidityChecker, String name, Object Type, Object ExprDef) throws Cvc3Exception;
- private static native Object
- jniEqOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniLtOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniLeOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGtOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGeOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniPlusOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniMinusOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniMultOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniDivideOp(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniFunExpr1(Object ValidityChecker, Object Op, Object Expr) throws Cvc3Exception;
- private static native Object
- jniFunExpr2(Object ValidityChecker, Object Op, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniFunExpr3(Object ValidityChecker, Object Op, Object Expr1, Object Expr2, Object Expr3) throws Cvc3Exception;
- private static native Object
- jniFunExpr4(Object ValidityChecker, Object Op, Object[] ExprChildren) throws Cvc3Exception;
- private static native Object
- jniRatExpr1(Object ValidityChecker, int n, int d) throws Cvc3Exception;
- private static native Object
- jniRatExpr2(Object ValidityChecker, String n, String d, int base) throws Cvc3Exception;
- private static native Object
- jniRatExpr3(Object ValidityChecker, String n, int base) throws Cvc3Exception;
- private static native Object
- jniUminusExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniPlusExpr1(Object ValidityChecker, Object Exprleft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniPlusExpr2(Object ValidityChecker, Object[] kids) throws Cvc3Exception;
- private static native Object
- jniMinusExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniMultExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniPowExpr(Object ValidityChecker, Object ExprX, Object ExprN) throws Cvc3Exception;
- private static native Object
- jniDivideExpr(Object ValidityChecker, Object ExprNumerator, Object ExprDenominator) throws Cvc3Exception;
- private static native Object
- jniLtExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniLeExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniGtExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniGeExpr(Object ValidityChecker, Object ExprLeft, Object ExprRight) throws Cvc3Exception;
- private static native Object
- jniRecordExpr1(Object ValidityChecker, String field, Object Expr) throws Cvc3Exception;
- private static native Object
- jniRecordExpr2(Object ValidityChecker, String field1, Object Expr1,
- String field2, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniRecordExpr3(Object ValidityChecker, String field1, Object Expr1, String field2, Object Expr2,
- String field3, Object Expr3) throws Cvc3Exception;
- private static native Object
- jniRecordExpr4(Object ValidityChecker, Object[] StringFields, Object[] Exprs) throws Cvc3Exception;
- private static native Object
- jniRecSelectExpr(Object ValidityChecker, Object ExprRecord, String field) throws Cvc3Exception;
- private static native Object
- jniRecUpdateExpr(Object ValidityChecker, Object ExprRecord, String field,
- Object ExprNewValue) throws Cvc3Exception;
- private static native Object
- jniReadExpr(Object ValidityChecker, Object ExprArray, Object ExprIndex) throws Cvc3Exception;
- private static native Object
- jniWriteExpr(Object ValidityChecker, Object ExprArray, Object ExprIndex,
- Object ExprNewValue) throws Cvc3Exception;
- private static native Object
- jniNewBVConstExpr1(Object ValidityChecker, String s, int base) throws Cvc3Exception;
- private static native Object
- jniNewBVConstExpr2(Object ValidityChecker, boolean[] bits) throws Cvc3Exception;
- private static native Object
- jniNewBVConstExpr3(Object ValidityChecker, Object RationalR, int len) throws Cvc3Exception;
- private static native Object
- jniNewConcatExpr1(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewConcatExpr2(Object ValidityChecker, Object[] Exprkids) throws Cvc3Exception;
- private static native Object
- jniNewBVExtractExpr(Object ValidityChecker, Object ExprE, int hi, int low) throws Cvc3Exception;
- private static native Object
- jniNewBVNegExpr(Object ValidityChecker, Object Expr1) throws Cvc3Exception;
- private static native Object
- jniNewBVAndExpr1(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVAndExpr2(Object ValidityChecker, Object[] ExprKids) throws Cvc3Exception;
- private static native Object
- jniNewBVOrExpr1(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVOrExpr2(Object ValidityChecker, Object[] ExprKids) throws Cvc3Exception;
- private static native Object
- jniNewBVXorExpr1(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVXorExpr2(Object ValidityChecker, Object[] ExprKids) throws Cvc3Exception;
- private static native Object
- jniNewBVXnorExpr1(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVXnorExpr2(Object ValidityChecker, Object[] ExprKids) throws Cvc3Exception;
- private static native Object
- jniNewBVNandExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVNorExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVLTExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVLEExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVSLTExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVSLEExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewSXExpr(Object ValidityChecker, Object Expr1, int len) throws Cvc3Exception;
- private static native Object
- jniNewBVUminusExpr(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniNewBVSubExpr(Object ValidityChecker, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVPlusExpr(Object ValidityChecker, int numbits, Object[] ExprK) throws Cvc3Exception;
- private static native Object
- jniNewBVMultExpr(Object ValidityChecker, int numbits, Object Expr1, Object Expr2) throws Cvc3Exception;
- private static native Object
- jniNewBVUDivExpr(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVURemExpr(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVSDivExpr(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVSRemExpr(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVSModExpr(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVSHL(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVLSHR(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewBVASHR(Object ValidityChecker, Object left, Object right) throws Cvc3Exception;
- private static native Object
- jniNewFixedLeftShiftExpr(Object ValidityChecker, Object Expr1, int r) throws Cvc3Exception;
- private static native Object
- jniNewFixedConstWidthLeftShiftExpr(Object ValidityChecker, Object Expr1, int r) throws Cvc3Exception;
- private static native Object
- jniNewFixedRightShiftExpr(Object ValidityChecker, Object Expr1, int r) throws Cvc3Exception;
- private static native Object
- jniComputeBVConst(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniTupleExpr(Object ValidityChecker, Object[] Exprs) throws Cvc3Exception;
- private static native Object
- jniTupleUpdateExpr(Object ValidityChecker, Object ExprTuple, int index,
- Object ExprNewValue) throws Cvc3Exception;
- private static native Object
- jniDatatypeConsExpr(Object ValidityChecker, String constructor, Object[] ExprArgs) throws Cvc3Exception;
- private static native Object
- jniDatatypeSelExpr(Object ValidityChecker, String selector, Object ExprArg) throws Cvc3Exception;
- private static native Object
- jniDatatypeTestExpr(Object ValidityChecker, String constructor, Object ExprArg) throws Cvc3Exception;
- private static native Object
- jniForallExpr1(Object ValidityChecker, Object[] ExprVars, Object ExprBody) throws Cvc3Exception;
- private static native Object
- jniForallExpr2(Object ValidityChecker, Object[] ExprVars, Object ExprBody,
- Object ExprTrigger) throws Cvc3Exception;
- private static native Object
- jniForallExpr3(Object ValidityChecker, Object[] ExprVars, Object ExprBody,
- Object[] ExprTriggers) throws Cvc3Exception;
- private static native Object
- jniForallExpr4(Object ValidityChecker, Object[] ExprVars, Object ExprBody,
- Object[][] ExprTriggers) throws Cvc3Exception;
- private static native void
- jniSetTrigger(Object ValidityChecker, Object ExprClosure, Object ExprTrigger) throws Cvc3Exception;
- private static native void
- jniSetTriggers(Object ValidityChecker, Object ExprClosure, Object[] ExprTriggers) throws Cvc3Exception;
- private static native void
- jniSetTriggers2(Object ValidityChecker, Object ExprClosure, Object[][] ExprTriggers) throws Cvc3Exception;
- private static native void
- jniSetMultiTrigger(Object ValidityChecker, Object ExprClosure, Object[] ExprMultiTrigger) throws Cvc3Exception;
- private static native Object
- jniExistsExpr(Object ValidityChecker, Object[] ExprVars, Object ExprBody) throws Cvc3Exception;
- private static native Object
- jniLambdaExpr(Object ValidityChecker, Object[] ExprVars, Object ExprBody) throws Cvc3Exception;
- private static native Object
- jniTransClosure(Object ValidityChecker, Object Op) throws Cvc3Exception;
- private static native Object
- jniSimulateExpr(Object ValidityChecker, Object ExprF, Object ExprS,
- Object[] ExprInputs, Object ExprN) throws Cvc3Exception;
-
- private static native void
- jniSetResourceLimit(Object ValidityChecker, int limit) throws Cvc3Exception;
- private static native void
- jniAssertFormula(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native void
- jniRegisterAtom(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native Object
- jniGetImpliedLiteral(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniSimplify(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native String
- jniQuery(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native String
- jniCheckUnsat(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native String
- jniCheckContinue(Object ValidityChecker) throws Cvc3Exception;
- private static native String
- jniRestart(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native void
- jniReturnFromCheck(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetUserAssumptions(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetInternalAssumptions(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetAssumptions(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetAssumptionsUsed(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetCounterExample(Object ValidityChecker, boolean inOrder) throws Cvc3Exception;
- private static native Object[]
- jniGetConcreteModel(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetValue(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native String
- jniValue(Object ValidityChecker, Object Expr) throws Cvc3Exception;
- private static native boolean
- jniInconsistent1(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniInconsistent2(Object ValidityChecker) throws Cvc3Exception;
- private static native boolean
- jniIncomplete1(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniIncomplete2(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetProof(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetTCC(Object ValidityChecker) throws Cvc3Exception;
- private static native Object[]
- jniGetAssumptionsTCC(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetProofTCC(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetClosure(Object ValidityChecker) throws Cvc3Exception;
- private static native Object
- jniGetProofClosure(Object ValidityChecker) throws Cvc3Exception;
-
- private static native int
- jniStackLevel(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPush(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPop(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPopTo(Object ValidityChecker, int stackLevel) throws Cvc3Exception;
- private static native int
- jniScopeLevel(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPushScope(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPopScope(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPopToScope(Object ValidityChecker, int scopeLevel) throws Cvc3Exception;
- private static native Object
- jniGetCurrentContext(Object ValidityChecker) throws Cvc3Exception;
-
- private static native void
- jniLoadFile1(Object ValidityChecker, String fileName, String lang) throws Cvc3Exception;
-
- private static native Object
- jniGetStatistics(Object ValidityChecker) throws Cvc3Exception;
- private static native void
- jniPrintStatistics(Object ValidityChecker) throws Cvc3Exception;
-
- private static native void
- jniSetTimeLimit(Object ValidityChecker, int limit) throws Cvc3Exception;
-
-
-
- // delete ValidityChecker, all expressions created using it,
- // and all embedded objects registered with its embeddedManager
- public synchronized void delete() throws Cvc3Exception {
- if (isDeleted()) return;
-
- //:TEST:
- embeddedManager().cleanUp();
-
- embeddedManager().delete();
- EmbeddedManager.jniDelete(embedded());
- d_embedded = null;
- }
-
- // ensure that all embedded objects are deallocated eventually
- public void finalize() throws Throwable {
- try {
- if (!isDeleted()) {
- assert(false);
-// System.out.println("ValidityChecker.Finalizer: should never be called");
- throw new Error("ValidityChecker.Finalizer: should never be called");
- }
- } finally {
- super.finalize();
- }
- }
-
- /// Constructor
-
- // create embedded object
- protected ValidityChecker(Object ValidityChecker) {
- super(ValidityChecker, new EmbeddedManager());
- }
-
-
- /// API: ValidityChecker
-
-
- // Creation
-
- // delete must be called before ValidityChecker is garbage collected
- public static ValidityChecker create() throws Cvc3Exception {
- return new ValidityChecker(jniCreate1());
- }
-
- // delete must be called before ValidityChecker is garbage collected
- public static ValidityChecker create(Flags flags) throws Cvc3Exception {
- return new ValidityChecker(jniCreate2(flags.embedded()));
- }
-
-
- // Flags
-
- // if embeddedManger is null then delete must be called before
- // the returned Flags is garbage collected
- public static FlagsMut createFlags(EmbeddedManager embeddedManager) throws Cvc3Exception {
- return new FlagsMut(jniCreateFlags(), embeddedManager);
- }
-
- public FlagsMut getFlags() throws Cvc3Exception {
- return new FlagsMut(jniGetFlags(embedded()), embeddedManager());
- }
-
-
-
- // Type-related methods
-
- public TypeMut boolType() throws Cvc3Exception {
- return new TypeMut(jniBoolType(embedded()), embeddedManager());
- }
-
- public TypeMut realType() throws Cvc3Exception {
- return new TypeMut(jniRealType(embedded()), embeddedManager());
- }
-
- public TypeMut intType() throws Cvc3Exception {
- return new TypeMut(jniIntType(embedded()), embeddedManager());
- }
-
- public TypeMut subrangeType(Expr l, Expr r) throws Cvc3Exception {
- return new TypeMut(
- jniSubrangeType(embedded(), l.embedded(), r.embedded()),
- embeddedManager());
- }
-
- public TypeMut subtypeType(Expr pred, Expr witness) throws Cvc3Exception {
- return new TypeMut(
- jniSubtypeType(embedded(), pred.embedded(), witness.embedded()),
- embeddedManager());
- }
-
- public TypeMut tupleType(Type type0, Type type1) throws Cvc3Exception {
- return new TypeMut(
- jniTupleType1(embedded(), type0.embedded(), type1.embedded()),
- embeddedManager());
- }
-
- public TypeMut tupleType(Type type0, Type type1, Type type2) throws Cvc3Exception {
- return new TypeMut(
- jniTupleType2(embedded(), type0.embedded(), type1.embedded(), type2.embedded()),
- embeddedManager());
- }
-
- public TypeMut tupleType(List types) throws Cvc3Exception {
- return new TypeMut(
- jniTupleType3(embedded(), JniUtils.unembedList(types)),
- embeddedManager());
- }
-
- public TypeMut recordType(String field, Type type) throws Cvc3Exception {
- return new TypeMut(
- jniRecordType1(embedded(), field, type.embedded()),
- embeddedManager());
- }
-
- public TypeMut recordType(String field0, Type type0, String field1, Type type1) throws Cvc3Exception {
- return new TypeMut(
- jniRecordType2(embedded(), field0, type0.embedded(), field1, type1.embedded()),
- embeddedManager());
- }
-
- public TypeMut recordType(String field0, Type type0, String field1, Type type1,
- String field2, Type type2) throws Cvc3Exception {
- return new TypeMut(
- jniRecordType3(embedded(), field0, type0.embedded(), field1, type1.embedded(),
- field2, type2.embedded()),
- embeddedManager());
- }
-
- public TypeMut recordType(List fields, List types) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(fields, String.class));
- return new TypeMut(
- jniRecordType4(embedded(), JniUtils.toArray(fields), JniUtils.unembedList(types)),
- embeddedManager());
- }
-
- public TypeMut dataType(String name, String constructor,
- List selectors, List types) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(selectors, String.class));
- assert(JniUtils.listInstanceof(types, Expr.class));
- return new TypeMut(
- jniDataType1(embedded(), name, constructor,
- JniUtils.toArray(selectors), JniUtils.unembedList(types)),
- embeddedManager());
- }
-
- public TypeMut dataType(String name, String[] constructors,
- String[][] selectors, Expr[][] types) throws Cvc3Exception {
- return new TypeMut(
- jniDataType2(embedded(), name, constructors, selectors, JniUtils.unembedArrayArray(types)),
- embeddedManager());
- }
-
- public TypeMut dataType(String name, List constructors,
- List selectors, List types) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(constructors, String.class));
- assert(JniUtils.listListInstanceof(selectors, String.class));
- assert(JniUtils.listListInstanceof(types, Expr.class));
- return new TypeMut(
- jniDataType2(embedded(), name, JniUtils.toArray(constructors),
- JniUtils.toArrayArray(selectors), JniUtils.unembedListList(types)),
- embeddedManager());
- }
-
- public List dataType(List names, List constructors,
- List selectors, List types) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(names, String.class));
- assert(JniUtils.listListInstanceof(constructors, String.class));
- assert(JniUtils.listListListInstanceof(selectors, String.class));
- assert(JniUtils.listListListInstanceof(types, Expr.class));
- Object[] dataTypes =
- jniDataType3(embedded(), JniUtils.toArray(names), JniUtils.toArrayArray(constructors),
- JniUtils.toArrayArrayArray(selectors), JniUtils.unembedListListList(types));
- return JniUtils.embedList(dataTypes, TypeMut.class, embeddedManager());
- }
-
- public ExprMut arrayLiteral(Expr var, Expr body) throws Cvc3Exception {
- return new ExprMut(jniArrayLiteral(embedded(), var.embedded(), body.embedded()),embeddedManager());
- }
-
- public TypeMut anyType() throws Cvc3Exception {
- return new TypeMut(jniAnyType(embedded()),embeddedManager());
- }
-
- public TypeMut arrayType(Type typeIndex, Type typeData) throws Cvc3Exception {
- return new TypeMut(
- jniArrayType(embedded(), typeIndex.embedded(), typeData.embedded()),
- embeddedManager());
- }
-
- public TypeMut bitvecType(int n) throws Cvc3Exception {
- return new TypeMut(
- jniBitvecType(embedded(), n),
- embeddedManager());
- }
-
- public TypeMut funType(Type typeDom, Type typeRange) throws Cvc3Exception {
- return new TypeMut(
- jniFunType1(embedded(), typeDom.embedded(), typeRange.embedded()),
- embeddedManager());
- }
-
- public TypeMut funType(List typeDom, Type typeRange) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(typeDom, Type.class));
- return new TypeMut(
- jniFunType2(embedded(), JniUtils.unembedList(typeDom), typeRange.embedded()),
- embeddedManager());
- }
-
- public TypeMut createType(String typeName) throws Cvc3Exception {
- return new TypeMut(
- jniCreateType1(embedded(), typeName),
- embeddedManager());
- }
-
- public TypeMut createType(String typeName, Type typeDef) throws Cvc3Exception {
- return new TypeMut(
- jniCreateType2(embedded(), typeName, typeDef.embedded()),
- embeddedManager());
- }
-
- public TypeMut lookupType(String typeName) throws Cvc3Exception {
- return new TypeMut(
- jniLookupType(embedded(), typeName),
- embeddedManager());
- }
-
-
-
- // Expressions
-
- public ExprManagerMut getExprManager() throws Cvc3Exception {
- return new ExprManagerMut(jniGetExprManager(embedded()), embeddedManager());
- }
-
- public Expr nullExpr() throws Cvc3Exception {
- return new Expr(jniNullExpr(embedded()), embeddedManager());
- }
-
- public ExprMut varExpr(String name, Type type) throws Cvc3Exception {
- return new ExprMut(
- jniVarExpr1(embedded(), name, type.embedded()),
- embeddedManager());
- }
-
- public ExprMut varExpr(String name, Type type, Expr def) throws Cvc3Exception {
- return new ExprMut(
- jniVarExpr2(embedded(), name, type.embedded(), def.embedded()),
- embeddedManager());
- }
-
- public ExprMut boundVarExpr(String name, String uid, Type type) throws Cvc3Exception {
- return new ExprMut(
- jniBoundVarExpr(embedded(), name, uid, type.embedded()),
- embeddedManager());
- }
-
-/* public ExprMut boundVarExpr(Type type) throws Cvc3Exception {
- return new ExprMut(
- jniBoundVarExpr(embedded(), type.embedded()),
- embeddedManager());
- }*/
-
- public ExprMut lookupVar(String name) throws Cvc3Exception {
- return new ExprMut(
- jniLookupVar(embedded(), name),
- embeddedManager());
- }
-
- public OpMut lookupOp(String name) throws Cvc3Exception {
- return new OpMut(
- jniLookupOp(embedded(), name),
- embeddedManager());
- }
-
- public TypeMut getType(Expr expr) throws Cvc3Exception {
- return new TypeMut(
- jniGetType(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public TypeMut getBaseType(Expr expr) throws Cvc3Exception {
- return new TypeMut(
- jniGetBaseType1(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public TypeMut getBaseType(Type type) throws Cvc3Exception {
- return new TypeMut(
- jniGetBaseType2(embedded(), type.embedded()),
- embeddedManager());
- }
-
- public ExprMut getTypePred(Type type, Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniGetTypePred(embedded(), type.embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut stringExpr(String str) throws Cvc3Exception {
- return new ExprMut(
- jniStringExpr(embedded(), str),
- embeddedManager());
- }
-
- public ExprMut idExpr(String name) throws Cvc3Exception {
- return new ExprMut(
- jniIdExpr(embedded(), name),
- embeddedManager());
- }
-
- public ExprMut listExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniListExpr1(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut listExpr(Expr expr1) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr2(embedded(), expr1.embedded()),
- embeddedManager());
- }
-
- public ExprMut listExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr3(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut listExpr(Expr expr1, Expr expr2, Expr expr3) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr4(embedded(), expr1.embedded(), expr2.embedded(), expr3.embedded()),
- embeddedManager());
- }
-
- public ExprMut listExpr(String op, List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniListExpr5(embedded(), op, JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut listExpr(String op, Expr expr1) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr6(embedded(), op, expr1.embedded()),
- embeddedManager());
- }
-
- public ExprMut listExpr(String op, Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr7(embedded(), op, expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut listExpr(String op, Expr expr1, Expr expr2, Expr expr3) throws Cvc3Exception {
- return new ExprMut(
- jniListExpr8(embedded(), op, expr1.embedded(), expr2.embedded(), expr3.embedded()),
- embeddedManager());
- }
-
- public void printExpr(Expr expr) throws Cvc3Exception {
- jniPrintExpr(embedded(), expr.embedded());
- }
-
- public ExprMut parseExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniParseExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public TypeMut parseType(Expr expr) throws Cvc3Exception {
- return new TypeMut(
- jniParseType(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut importExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniImportExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public TypeMut importType(Type type) throws Cvc3Exception {
- return new TypeMut(
- jniImportType(embedded(), type.embedded()),
- embeddedManager());
- }
-
- public void cmdsFromString(String s) throws Cvc3Exception {
- jniCmdsFromString(embedded(), s);
- }
-
- public ExprMut exprFromString(String s) throws Cvc3Exception {
- return new ExprMut( jniExprFromString(embedded(), s), embeddedManager() );
- }
-
-
- public ExprMut trueExpr() throws Cvc3Exception {
- return new ExprMut(jniTrueExpr(embedded()), embeddedManager());
- }
-
- public ExprMut falseExpr() throws Cvc3Exception {
- return new ExprMut(jniFalseExpr(embedded()), embeddedManager());
- }
-
- public ExprMut notExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniNotExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut andExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniAndExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut andExpr(List children) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(children, Expr.class));
- return new ExprMut(
- jniAndExpr2(embedded(), JniUtils.unembedList(children)),
- embeddedManager());
- }
-
- public ExprMut orExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniOrExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut orExpr(List children) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(children, Expr.class));
- return new ExprMut(
- jniOrExpr2(embedded(), JniUtils.unembedList(children)),
- embeddedManager());
- }
-
- public ExprMut impliesExpr(Expr hyp, Expr conc) throws Cvc3Exception {
- return new ExprMut(
- jniImpliesExpr(embedded(), hyp.embedded(), conc.embedded()),
- embeddedManager());
- }
-
- public ExprMut iffExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniIffExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut eqExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniEqExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut distinctExpr(List children) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(children, Expr.class));
- return new ExprMut(
- jniDistinctExpr(embedded(), JniUtils.unembedList(children)), embeddedManager());
- }
-
- public ExprMut iteExpr(Expr ifPart, Expr thenPart, Expr elsePart) throws Cvc3Exception {
- return new ExprMut(
- jniIteExpr(embedded(), ifPart.embedded(), thenPart.embedded(), elsePart.embedded()),
- embeddedManager());
- }
-
- public OpMut createOp(String name, Type type) throws Cvc3Exception {
- return new OpMut(
- jniCreateOp1(embedded(), name, type.embedded()),
- embeddedManager());
- }
-
- public OpMut createOp(String name, Type type, Expr expr) throws Cvc3Exception {
- return new OpMut(
- jniCreateOp2(embedded(), name, type.embedded(), expr.embedded()),
- embeddedManager());
- }
-
- // '='
- public OpMut eqOp() throws Cvc3Exception {
- return new OpMut(jniEqOp(embedded()), embeddedManager());
- }
-
- // '<'
- public OpMut ltOp() throws Cvc3Exception {
- return new OpMut(jniLtOp(embedded()), embeddedManager());
- }
-
- // '<='
- public OpMut leOp() throws Cvc3Exception {
- return new OpMut(jniLeOp(embedded()), embeddedManager());
- }
-
- // '>'
- public OpMut gtOp() throws Cvc3Exception {
- return new OpMut(jniGtOp(embedded()), embeddedManager());
- }
-
- // '>='
- public OpMut geOp() throws Cvc3Exception {
- return new OpMut(jniGeOp(embedded()), embeddedManager());
- }
-
- // '+'
- public OpMut plusOp() throws Cvc3Exception {
- return new OpMut(jniPlusOp(embedded()), embeddedManager());
- }
-
- // '-'
- public OpMut minusOp() throws Cvc3Exception {
- return new OpMut(jniMinusOp(embedded()), embeddedManager());
- }
-
- // '*'
- public OpMut multOp() throws Cvc3Exception {
- return new OpMut(jniMultOp(embedded()), embeddedManager());
- }
-
- // '/' for rationals
- public OpMut divideOp() throws Cvc3Exception {
- return new OpMut(jniDivideOp(embedded()), embeddedManager());
- }
-
- public ExprMut funExpr(Op op, Expr expr1) throws Cvc3Exception {
- return new ExprMut(
- jniFunExpr1(embedded(), op.embedded(), expr1.embedded()),
- embeddedManager());
- }
-
- public ExprMut funExpr(Op op, Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniFunExpr2(embedded(), op.embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut funExpr(Op op, Expr expr1, Expr expr2, Expr expr3) throws Cvc3Exception {
- return new ExprMut(
- jniFunExpr3(embedded(), op.embedded(), expr1.embedded(), expr2.embedded(), expr3.embedded()),
- embeddedManager());
- }
-
- public ExprMut funExpr(Op op, List children) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(children, Expr.class));
- return new ExprMut(
- jniFunExpr4(embedded(), op.embedded(), JniUtils.unembedList(children)),
- embeddedManager());
- }
-
- public ExprMut ratExpr(int n) throws Cvc3Exception {
- return ratExpr(n, 1);
- }
-
- public ExprMut ratExpr(int n, int d) throws Cvc3Exception {
- return new ExprMut(
- jniRatExpr1(embedded(), n, d),
- embeddedManager());
- }
-
- public ExprMut ratExpr(String n, String d, int base) throws Cvc3Exception {
- return new ExprMut(
- jniRatExpr2(embedded(), n, d, base),
- embeddedManager());
- }
-
- public ExprMut ratExpr(String n) throws Cvc3Exception {
- return ratExpr(n, 10);
- }
-
- public ExprMut ratExpr(String n, int base) throws Cvc3Exception {
- return new ExprMut(
- jniRatExpr3(embedded(), n, base),
- embeddedManager());
- }
-
- public ExprMut uminusExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniUminusExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut plusExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniPlusExpr1(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut plusExpr(List kids) throws Cvc3Exception {
- return new ExprMut(
- jniPlusExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut minusExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniMinusExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut multExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniMultExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut powExpr(Expr x, Expr n) throws Cvc3Exception {
- return new ExprMut(
- jniPowExpr(embedded(), x.embedded(), n.embedded()),
- embeddedManager());
- }
-
- public ExprMut divideExpr(Expr numerator, Expr denominator) throws Cvc3Exception {
- return new ExprMut(
- jniDivideExpr(embedded(), numerator.embedded(), denominator.embedded()),
- embeddedManager());
- }
-
- public ExprMut ltExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniLtExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut leExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniLeExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut gtExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniGtExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut geExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniGeExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut recordExpr(String field, Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniRecordExpr1(embedded(), field, expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut recordExpr(String field1, Expr expr1, String field2, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniRecordExpr2(embedded(), field1, expr1.embedded(), field2, expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut recordExpr(String field1, Expr expr1, String field2, Expr expr2,
- String field3, Expr expr3) throws Cvc3Exception {
- return new ExprMut(
- jniRecordExpr3(embedded(), field1, expr1.embedded(), field2, expr2.embedded(),
- field3, expr3.embedded()),
- embeddedManager());
- }
-
- public ExprMut recordExpr(List fields, List exprs) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(fields, String.class));
- assert(JniUtils.listInstanceof(exprs, Expr.class));
- return new ExprMut(
- jniRecordExpr4(embedded(), JniUtils.toArray(fields), JniUtils.unembedList(exprs)),
- embeddedManager());
- }
-
- public ExprMut recSelectExpr(Expr record, String field) throws Cvc3Exception {
- return new ExprMut(
- jniRecSelectExpr(embedded(), record.embedded(), field),
- embeddedManager());
- }
-
- public ExprMut recUpdateExpr(Expr record, String field, Expr newValue) throws Cvc3Exception {
- return new ExprMut(
- jniRecUpdateExpr(embedded(), record.embedded(), field, newValue.embedded()),
- embeddedManager());
- }
-
- public ExprMut readExpr(Expr array, Expr index) throws Cvc3Exception {
- return new ExprMut(
- jniReadExpr(embedded(), array.embedded(), index.embedded()),
- embeddedManager());
- }
-
- public ExprMut writeExpr(Expr array, Expr index, Expr newValue) throws Cvc3Exception {
- return new ExprMut(
- jniWriteExpr(embedded(), array.embedded(), index.embedded(), newValue.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVConstExpr(String s) throws Cvc3Exception {
- return newBVConstExpr(s, 2);
- }
-
- public ExprMut newBVConstExpr(String s, int base) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVConstExpr1(embedded(), s, base),
- embeddedManager());
- }
-
- public ExprMut newBVConstExpr(boolean[] bits) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVConstExpr2(embedded(), bits),
- embeddedManager());
- }
-
- public ExprMut newBVConstExpr(Rational r, int len) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVConstExpr3(embedded(), r.embedded(), len),
- embeddedManager());
- }
-
- public ExprMut newConcatExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewConcatExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newConcatExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniNewConcatExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut newBVExtractExpr(Expr e, int hi, int low) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVExtractExpr(embedded(), e.embedded(), hi, low),
- embeddedManager());
- }
-
- public ExprMut newBVNegExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVNegExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVAndExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVAndExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVAndExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniNewBVAndExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut newBVOrExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVOrExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVOrExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniNewBVOrExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut newBVXorExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVXorExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVXorExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniNewBVXorExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut newBVXnorExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVXnorExpr1(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVXnorExpr(List kids) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(kids, Expr.class));
- return new ExprMut(
- jniNewBVXnorExpr2(embedded(), JniUtils.unembedList(kids)),
- embeddedManager());
- }
-
- public ExprMut newBVNandExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVNandExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVNorExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVNorExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVLTExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVLTExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVLEExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVLEExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSLTExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSLTExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSLEExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSLEExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newSXExpr(Expr expr, int len) throws Cvc3Exception {
- return new ExprMut(
- jniNewSXExpr(embedded(), expr.embedded(), len),
- embeddedManager());
- }
-
- public ExprMut newBVUminusExpr(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVUminusExpr(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSubExpr(Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSubExpr(embedded(), expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVPlusExpr(int numbits, List exprs) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(exprs, Expr.class));
- return new ExprMut(
- jniNewBVPlusExpr(embedded(), numbits, JniUtils.unembedList(exprs)),
- embeddedManager());
- }
-
- public ExprMut newBVMultExpr(int numbits, Expr expr1, Expr expr2) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVMultExpr(embedded(), numbits, expr1.embedded(), expr2.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVUDivExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVUDivExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVURemExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVURemExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSDivExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSDivExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSRemExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSRemExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSModExpr(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSModExpr(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVSHL(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVSHL(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVLSHR(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVLSHR(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newBVASHR(Expr left, Expr right) throws Cvc3Exception {
- return new ExprMut(
- jniNewBVASHR(embedded(), left.embedded(), right.embedded()),
- embeddedManager());
- }
-
- public ExprMut newFixedLeftShiftExpr(Expr expr, int r) throws Cvc3Exception {
- return new ExprMut(
- jniNewFixedLeftShiftExpr(embedded(), expr.embedded(), r),
- embeddedManager());
- }
-
- public ExprMut newFixedConstWidthLeftShiftExpr(Expr expr, int r) throws Cvc3Exception {
- return new ExprMut(
- jniNewFixedConstWidthLeftShiftExpr(embedded(), expr.embedded(), r),
- embeddedManager());
- }
-
- public ExprMut newFixedRightShiftExpr(Expr expr, int r) throws Cvc3Exception {
- return new ExprMut(
- jniNewFixedRightShiftExpr(embedded(), expr.embedded(), r),
- embeddedManager());
- }
-
- public Rational computeBVConst(Expr expr) {
- Rational rat = new Rational(
- jniComputeBVConst(embedded(),expr.embedded()),
- embeddedManager());
- assert( rat.isInteger() );
- return rat;
- }
-
- public ExprMut tupleExpr(List exprs) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(exprs, Expr.class));
- return new ExprMut(
- jniTupleExpr(embedded(), JniUtils.unembedList(exprs)),
- embeddedManager());
- }
-
- public ExprMut tupleUpdateExpr(Expr tuple, int index, Expr newValue) throws Cvc3Exception {
- return new ExprMut(
- jniTupleUpdateExpr(embedded(), tuple.embedded(), index, newValue.embedded()),
- embeddedManager());
- }
-
- public ExprMut datatypeConsExpr(String constructor, List exprs) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(exprs, Expr.class));
- return new ExprMut(
- jniDatatypeConsExpr(embedded(), constructor, JniUtils.unembedList(exprs)),
- embeddedManager());
- }
-
- public ExprMut datatypeSelExpr(String selector, Expr arg) throws Cvc3Exception {
- return new ExprMut(
- jniDatatypeSelExpr(embedded(), selector, arg.embedded()),
- embeddedManager());
- }
-
- public ExprMut datatypeTestExpr(String constructor, Expr arg) throws Cvc3Exception {
- return new ExprMut(
- jniDatatypeTestExpr(embedded(), constructor, arg.embedded()),
- embeddedManager());
- }
-
- public ExprMut forallExpr(List vars, Expr body) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(vars, Expr.class));
- return new ExprMut(
- jniForallExpr1(embedded(), JniUtils.unembedList(vars), body.embedded()),
- embeddedManager());
- }
-
- public ExprMut forallExpr(List vars, Expr body, Expr trigger) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(vars, Expr.class));
- return new ExprMut(
- jniForallExpr2(embedded(), JniUtils.unembedList(vars), body.embedded(),
- trigger.embedded()),
- embeddedManager());
- }
-
- public ExprMut forallExpr(List vars, Expr body, List triggers) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(vars, Expr.class));
- assert(JniUtils.listInstanceof(triggers, Expr.class));
- return new ExprMut(
- jniForallExpr3(embedded(), JniUtils.unembedList(vars), body.embedded(),
- JniUtils.unembedList(triggers)),
- embeddedManager());
- }
-
- public ExprMut forallExprMultiTriggers(List vars, Expr body, List multiTriggers)
- throws Cvc3Exception {
- assert (JniUtils.listInstanceof(vars, Expr.class));
- assert (JniUtils.listListInstanceof(multiTriggers, Expr.class));
- return new ExprMut(jniForallExpr4(embedded(), JniUtils.unembedList(vars),
- body.embedded(), JniUtils.unembedListList(multiTriggers)),
- embeddedManager());
- }
-
- public void setTrigger(Expr closure, Expr trigger) throws Cvc3Exception {
- jniSetTrigger(embedded(), closure.embedded(), trigger.embedded());
- }
-
- public void setTriggers(Expr closure, List triggers) throws Cvc3Exception {
- jniSetTriggers(embedded(), closure.embedded(), JniUtils.unembedList(triggers));
- }
-
- public void setMultiTrigger(Expr closure, List multiTrigger) throws Cvc3Exception {
- jniSetMultiTrigger(embedded(), closure.embedded(), JniUtils.unembedList(multiTrigger));
- }
-
- public void setMultiTriggers(Expr closure, List triggers) throws Cvc3Exception {
- jniSetTriggers2(embedded(), closure.embedded(), JniUtils.unembedListList(triggers));
- }
-
- public ExprMut existsExpr(List vars, Expr body) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(vars, Expr.class));
- return new ExprMut(
- jniExistsExpr(embedded(), JniUtils.unembedList(vars), body.embedded()),
- embeddedManager());
- }
-
- public OpMut lambdaExpr(List vars, Expr body) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(vars, Expr.class));
- return new OpMut(
- jniLambdaExpr(embedded(), JniUtils.unembedList(vars), body.embedded()),
- embeddedManager());
- }
-
- public OpMut transClosure(Op p) throws Cvc3Exception {
- return new OpMut(
- jniTransClosure(embedded(), p.embedded()),
- embeddedManager());
- }
-
- public ExprMut simulateExpr(Expr f, Expr s, List inputs, Expr n) throws Cvc3Exception {
- assert(JniUtils.listInstanceof(inputs, Expr.class));
- return new ExprMut(
- jniSimulateExpr(embedded(), f.embedded(), s.embedded(), JniUtils.unembedList(inputs), n.embedded()),
- embeddedManager());
- }
-
-
- public void setResourceLimit(int limit) throws Cvc3Exception {
- jniSetResourceLimit(embedded(), limit);
- }
-
- // Validity checking methods
-
- public void assertFormula(Expr expr) throws Cvc3Exception {
- embeddedManager().cleanUp();
- jniAssertFormula(embedded(), expr.embedded());
- embeddedManager().cleanUp();
- }
-
- public void registerAtom(Expr expr) throws Cvc3Exception {
- jniRegisterAtom(embedded(), expr.embedded());
- }
-
- public ExprMut getImpliedLiteral() throws Cvc3Exception {
- return new ExprMut(
- jniGetImpliedLiteral(embedded()),
- embeddedManager());
- }
-
- public ExprMut simplify(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniSimplify(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public QueryResult query(Expr expr) throws Cvc3Exception {
- embeddedManager().cleanUp();
- QueryResult result = QueryResult.get(jniQuery(embedded(), expr.embedded()));
-
- //:TEST:
- embeddedManager().cleanUp();
- return result;
- }
-
- public SatResult checkUnsat(Expr expr) throws Cvc3Exception {
- embeddedManager().cleanUp();
- SatResult result = SatResult.get(jniCheckUnsat(embedded(), expr.embedded()));
-
- //:TEST:
- embeddedManager().cleanUp();
- return result;
- }
-
- public QueryResult checkContinue() throws Cvc3Exception {
- embeddedManager().cleanUp();
- QueryResult result = QueryResult.get(jniCheckContinue(embedded()));
-
- //:TEST:
- embeddedManager().cleanUp();
- return result;
- }
-
- public QueryResult restart(Expr expr) throws Cvc3Exception {
- embeddedManager().cleanUp();
- QueryResult result = QueryResult.get(jniRestart(embedded(), expr.embedded()));
-
- //:TEST:
- embeddedManager().cleanUp();
- return result;
- }
-
- public void returnFromCheck() throws Cvc3Exception {
- jniReturnFromCheck(embedded());
-
- //:TEST:
- embeddedManager().cleanUp();
- }
-
- public List getUserAssumptions() throws Cvc3Exception {
- Object[] assumptions = jniGetUserAssumptions(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public List getInternalAssumptions() throws Cvc3Exception {
- Object[] assumptions = jniGetInternalAssumptions(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public List getAssumptions() throws Cvc3Exception {
- Object[] assumptions = jniGetAssumptions(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public List getAssumptionsUsed() throws Cvc3Exception {
- Object[] assumptions = jniGetAssumptionsUsed(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public List getCounterExample() throws Cvc3Exception {
- return getCounterExample(true);
- }
-
- public List getCounterExample(boolean inOrder) throws Cvc3Exception {
- Object[] assumptions = jniGetCounterExample(embedded(), inOrder);
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public HashMap getConcreteModel() throws Cvc3Exception {
- Object[] model = jniGetConcreteModel(embedded());
- return JniUtils.embedHashMap(model, Expr.class, Expr.class, embeddedManager());
- }
-
- public FormulaValue value(Expr expr) throws Cvc3Exception {
- return FormulaValue.get(jniValue(embedded(), expr.embedded()));
- }
-
- public Expr getValue(Expr expr) throws Cvc3Exception {
- return new ExprMut(
- jniGetValue(embedded(), expr.embedded()),
- embeddedManager());
- }
-
- public boolean inconsistent() throws Cvc3Exception {
- return jniInconsistent1(embedded());
- }
-
- // makes only sense if inconsistent is true
- public List inconsistentReasons() throws Cvc3Exception {
- Object[] assumptions = jniInconsistent2(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public boolean incomplete() throws Cvc3Exception {
- return jniIncomplete1(embedded());
- }
-
- // makes only sense if incomplete is true
- public List incompleteReasons() throws Cvc3Exception {
- Object[] assumptions = jniIncomplete2(embedded());
- return JniUtils.embedList(assumptions, String.class, embeddedManager());
- }
-
- public ProofMut getProof() throws Cvc3Exception {
- return new ProofMut(
- jniGetProof(embedded()),
- embeddedManager());
- }
-
- public ExprMut getTCC() throws Cvc3Exception {
- return new ExprMut(
- jniGetTCC(embedded()),
- embeddedManager());
- }
-
- public List getAssumptionsTCC() throws Cvc3Exception {
- Object[] assumptions = jniGetAssumptionsTCC(embedded());
- return JniUtils.embedList(assumptions, ExprMut.class, embeddedManager());
- }
-
- public ProofMut getProofTCC() throws Cvc3Exception {
- return new ProofMut(
- jniGetProofTCC(embedded()),
- embeddedManager());
- }
-
- public ExprMut getClosure() throws Cvc3Exception {
- return new ExprMut(
- jniGetClosure(embedded()),
- embeddedManager());
- }
-
- public ProofMut getProofClosure() throws Cvc3Exception {
- return new ProofMut(
- jniGetProofClosure(embedded()),
- embeddedManager());
- }
-
-
-
-
- // Context Methods
-
- public int stackLevel() throws Cvc3Exception {
- return jniStackLevel(embedded());
- }
-
- public void push() throws Cvc3Exception {
- jniPush(embedded());
- }
-
- public void pop() throws Cvc3Exception {
- jniPop(embedded());
- //:TEST:
- embeddedManager().cleanUp();
- }
-
- public void popTo(int stackLevel) throws Cvc3Exception {
- jniPopTo(embedded(), stackLevel);
- //:TEST:
- embeddedManager().cleanUp();
- }
-
- public int scopeLevel() throws Cvc3Exception {
- return jniScopeLevel(embedded());
- }
-
- public void pushScope() throws Cvc3Exception {
- jniPushScope(embedded());
- }
-
- public void popScope() throws Cvc3Exception {
- jniPopScope(embedded());
- }
-
- public void popToScope(int scopeLevel) throws Cvc3Exception {
- jniPopToScope(embedded(), scopeLevel);
- }
-
- public ContextMut getCurrentContext() throws Cvc3Exception {
- return new ContextMut(
- jniGetCurrentContext(embedded()),
- embeddedManager());
- }
-
-
-
-
- // Reading Files
-
- public void loadFile(String fileName) throws Cvc3Exception {
- loadFile(fileName, InputLanguage.PRESENTATION);
- }
-
- public void loadFile(String fileName, InputLanguage lang) throws Cvc3Exception {
- jniLoadFile1(embedded(), fileName, lang.toString());
- }
-
- // Reporting Statistics
-
- public void printStatistics() throws Cvc3Exception {
- jniPrintStatistics(embedded());
- }
-
- public StatisticsMut getStatistics() throws Cvc3Exception {
- return new StatisticsMut(
- jniGetStatistics(embedded()),
- embeddedManager());
- }
-
- public void setTimeLimit(int limit) throws Cvc3Exception {
- jniSetTimeLimit(embedded(), limit);
- }
-}
+++ /dev/null
-INCLUDE: <sstream>
-//INCLUDE: <theory_arith.h>
-//INCLUDE: <theory_array.h>
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreate1
-jobject
-return embed_own<ValidityChecker>(env, ValidityChecker::create());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreate2
-jobject c CLFlags flags
-return embed_own<ValidityChecker>(env, ValidityChecker::create(*flags));
-
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreateFlags
-jobject
-return embed_copy(env, ValidityChecker::createFlags());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetFlags
-jobject c ValidityChecker vc
-return embed_mut_ref(env, &vc->getFlags());
-
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniBoolType
-jobject m ValidityChecker vc
-return embed_copy(env, vc->boolType());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRealType
-jobject m ValidityChecker vc
-return embed_copy(env, vc->realType());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIntType
-jobject m ValidityChecker vc
-return embed_copy(env, vc->intType());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSubrangeType
-jobject m ValidityChecker vc c Expr l c Expr r
-return embed_copy(env, vc->subrangeType(*l, *r));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSubtypeType
-jobject m ValidityChecker vc c Expr pred c Expr witness
-return embed_copy(env, vc->subtypeType(*pred, *witness));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTupleType1
-jobject m ValidityChecker vc c Type type0 c Type type1
-return embed_copy(env, vc->tupleType(*type0, *type1));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTupleType2
-jobject m ValidityChecker vc c Type type0 c Type type1 c Type type2
-return embed_copy(env, vc->tupleType(*type0, *type1, *type2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTupleType3
-jobject m ValidityChecker vc cv Type types
-return embed_copy(env, vc->tupleType(types));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordType1
-jobject m ValidityChecker vc n string field c Type type
-return embed_copy(env, vc->recordType(field, *type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordType2
-jobject m ValidityChecker vc n string field0 c Type type0 n string field1 c Type type1
-return embed_copy(env, vc->recordType(field0, *type0, field1, *type1));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordType3
-jobject m ValidityChecker vc n string field0 c Type type0 n string field1 c Type type1 n string field2 c Type type2
-return embed_copy(env, vc->recordType(field0, *type0, field1, *type1, field2, *type2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordType4
-jobject m ValidityChecker vc nv string fields cv Type types
-return embed_copy(env, vc->recordType(fields, types));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDataType1
-jobject m ValidityChecker vc n string name n string constructor nv string selectors cv Expr types
-return embed_copy(env, vc->dataType(name, constructor, selectors, types));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDataType2
-jobject m ValidityChecker vc n string name nv string constructors nvv string selectors cvv Expr types
-return embed_copy(env, vc->dataType(name, constructors, selectors, types));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDataType3
-jobjectArray m ValidityChecker vc nv string names nvv string constructors nvvv string selectors cvvv Expr types
-vector<Type> result;
-vc->dataType(names, constructors, selectors, types, result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniAnyType
-jobject m ValidityChecker vc
-assert(false);// Unimplemented
-return NULL;
-
-DEFINITION: Java_cvc3_ValidityChecker_jniArrayLiteral
-jobject m ValidityChecker vc c Expr indexVar c Expr bodyExpr
-assert(false);// Unimplemented
-return NULL;
-
-DEFINITION: Java_cvc3_ValidityChecker_jniArrayType
-jobject m ValidityChecker vc c Type typeIndex c Type typeData
-return embed_copy(env, vc->arrayType(*typeIndex, *typeData));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniBitvecType
-jobject m ValidityChecker vc n int n
-return embed_copy(env, vc->bitvecType(n));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunType1
-jobject m ValidityChecker vc c Type typeDom c Type typeRange
-return embed_copy(env, vc->funType(*typeDom, *typeRange));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunType2
-jobject m ValidityChecker vc cv Type typeDom c Type typeRange
-return embed_copy(env, vc->funType(typeDom, *typeRange));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreateType1
-jobject m ValidityChecker vc n string typeName
-return embed_copy(env, vc->createType(typeName));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreateType2
-jobject m ValidityChecker vc n string typeName c Type typeDef
-return embed_copy(env, vc->createType(typeName, *typeDef));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLookupType
-jobject m ValidityChecker vc n string typeName
-return embed_copy(env, vc->lookupType(typeName));
-
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetExprManager
-jobject m ValidityChecker vc
-return embed_mut_ref(env, vc->getEM());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNullExpr
-jobject m ValidityChecker vc
-return embed_copy(env, Expr());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniVarExpr1
-jobject m ValidityChecker vc n string name c Type type
-return embed_copy(env, vc->varExpr(name, *type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniVarExpr2
-jobject m ValidityChecker vc n string name c Type type c Expr def
-return embed_copy(env, vc->varExpr(name, *type, *def));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniBoundVarExpr
-jobject m ValidityChecker vc n string name n string uid c Type type
-return embed_copy(env, vc->boundVarExpr(name, uid, *type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLookupVar
-jobject m ValidityChecker vc n string name
-Type* type = new Type;
-jobject result = embed_copy(env, vc->lookupVar(name, type));
-delete type;
-return result;
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLookupOp
-jobject m ValidityChecker vc n string name
-Type* type = new Type;
-jobject result = embed_copy(env, vc->lookupOp(name, type));
-delete type;
-return result;
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetType
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->getType(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetBaseType1
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->getBaseType(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetBaseType2
-jobject m ValidityChecker vc c Type type
-return embed_copy(env, vc->getBaseType(*type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetTypePred
-jobject m ValidityChecker vc c Type type c Expr expr
-return embed_copy(env, vc->getTypePred(*type, *expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniStringExpr
-jobject m ValidityChecker vc n string str
-return embed_copy(env, vc->stringExpr(str));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIdExpr
-jobject m ValidityChecker vc n string name
-return embed_copy(env, vc->idExpr(name));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr1
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->listExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr2
-jobject m ValidityChecker vc c Expr expr1
-return embed_copy(env, vc->listExpr(*expr1));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr3
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->listExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr4
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2 c Expr expr3
-return embed_copy(env, vc->listExpr(*expr1, *expr2, *expr3));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr5
-jobject m ValidityChecker vc n string op cv Expr kids
-return embed_copy(env, vc->listExpr(op, kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr6
-jobject m ValidityChecker vc n string op c Expr expr1
-return embed_copy(env, vc->listExpr(op, *expr1));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr7
-jobject m ValidityChecker vc n string op c Expr expr1 c Expr expr2
-return embed_copy(env, vc->listExpr(op, *expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniListExpr8
-jobject m ValidityChecker vc n string op c Expr expr1 c Expr expr2 c Expr expr3
-return embed_copy(env, vc->listExpr(op, *expr1, *expr2, *expr3));
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPrintExpr
-void m ValidityChecker vc c Expr expr
-vc->printExpr(*expr);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniParseExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->parseExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniParseType
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->parseType(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniImportExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->importExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniImportType
-jobject m ValidityChecker vc c Type type
-return embed_copy(env, vc->importType(*type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCmdsFromString
-void m ValidityChecker vc n string s
-vc->cmdsFromString(s);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniExprFromString
-jobject m ValidityChecker vc n string s
-return embed_copy<Expr>(env, vc->exprFromString(s));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTrueExpr
-jobject m ValidityChecker vc
-return embed_copy<Expr>(env, vc->trueExpr());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFalseExpr
-jobject m ValidityChecker vc
-return embed_copy<Expr>(env, vc->falseExpr());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNotExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->notExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniAndExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->andExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniAndExpr2
-jobject m ValidityChecker vc cv Expr children
-return embed_copy(env, vc->andExpr(children));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniOrExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->orExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniOrExpr2
-jobject m ValidityChecker vc cv Expr children
-return embed_copy(env, vc->orExpr(children));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniImpliesExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->impliesExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIffExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->iffExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniEqExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->eqExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDistinctExpr
-jobject m ValidityChecker vc cv Expr children
-return embed_copy(env, vc->distinctExpr(children));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIteExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2 c Expr expr3
-return embed_copy(env, vc->iteExpr(*expr1, *expr2, *expr3));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreateOp1
-jobject m ValidityChecker vc n string name c Type type
-return embed_copy(env, vc->createOp(name, *type));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCreateOp2
-jobject m ValidityChecker vc n string name c Type type c Expr expr
-return embed_copy(env, vc->createOp(name, *type, *expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniEqOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), EQ));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLtOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), LT));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLeOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), LE));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGtOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), GT));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGeOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), GE));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPlusOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), PLUS));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniMinusOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), MINUS));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniMultOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), MULT));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDivideOp
-jobject m ValidityChecker vc
-return embed_copy<Op>(env, Op(vc->getEM(), DIVIDE));
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunExpr1
-jobject m ValidityChecker vc c Op op c Expr expr1
-return embed_copy(env, vc->funExpr(*op, *expr1));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunExpr2
-jobject m ValidityChecker vc c Op op c Expr expr1 c Expr expr2
-return embed_copy(env, vc->funExpr(*op, *expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunExpr3
-jobject m ValidityChecker vc c Op op c Expr expr1 c Expr expr2 c Expr expr3
-return embed_copy(env, vc->funExpr(*op, *expr1, *expr2, *expr3));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniFunExpr4
-jobject m ValidityChecker vc c Op op cv Expr children
-return embed_copy(env, vc->funExpr(*op, children));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRatExpr1
-jobject m ValidityChecker vc n int n n int d
-return embed_copy(env, vc->ratExpr(n, d));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRatExpr2
-jobject m ValidityChecker vc n string n n string d n int base
-return embed_copy(env, vc->ratExpr(n, d, base));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRatExpr3
-jobject m ValidityChecker vc n string n n int base
-return embed_copy(env, vc->ratExpr(n, base));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniUminusExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->uminusExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPlusExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->plusExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPlusExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->plusExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniMinusExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->minusExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniMultExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->multExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPowExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->powExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDivideExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->divideExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLtExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->ltExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLeExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->leExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGtExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->gtExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGeExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->geExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordExpr1
-jobject m ValidityChecker vc n string field c Expr expr
-return embed_copy(env, vc->recordExpr(field, *expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordExpr2
-jobject m ValidityChecker vc n string field1 c Expr expr1 n string field2 c Expr expr2
-return embed_copy(env, vc->recordExpr(field1, *expr1, field2, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordExpr3
-jobject m ValidityChecker vc n string field1 c Expr expr1 n string field2 c Expr expr2 n string field3 c Expr expr3
-return embed_copy(env, vc->recordExpr(field1, *expr1, field2, *expr2, field3, *expr3));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecordExpr4
-jobject m ValidityChecker vc nv string fields cv Expr exprs
-return embed_copy(env, vc->recordExpr(fields, exprs));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecSelectExpr
-jobject m ValidityChecker vc c Expr record n string field
-return embed_copy(env, vc->recSelectExpr(*record, field));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRecUpdateExpr
-jobject m ValidityChecker vc c Expr record n string field c Expr update
-return embed_copy(env, vc->recUpdateExpr(*record, field, *update));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniReadExpr
-jobject m ValidityChecker vc c Expr array c Expr index
-return embed_copy(env, vc->readExpr(*array, *index));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniWriteExpr
-jobject m ValidityChecker vc c Expr array c Expr index c Expr value
-return embed_copy(env, vc->writeExpr(*array, *index, *value));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVConstExpr1
-jobject m ValidityChecker vc n string s n int base
-return embed_copy(env, vc->newBVConstExpr(s, jbase));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVConstExpr2
-jobject m ValidityChecker vc nv bool bits
-return embed_copy(env, vc->newBVConstExpr(bits));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVConstExpr3
-jobject m ValidityChecker vc c Rational rational n int len
-return embed_copy(env, vc->newBVConstExpr(*rational, len));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewConcatExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newConcatExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewConcatExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->newConcatExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVExtractExpr
-jobject m ValidityChecker vc c Expr expr n int hi n int low
-return embed_copy(env, vc->newBVExtractExpr(*expr, hi, low));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVNegExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->newBVNegExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVAndExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVAndExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVAndExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->newBVAndExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVOrExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVOrExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVOrExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->newBVOrExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVXorExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVXorExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVXorExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->newBVXorExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVXnorExpr1
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVXnorExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVXnorExpr2
-jobject m ValidityChecker vc cv Expr kids
-return embed_copy(env, vc->newBVXnorExpr(kids));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVNandExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVNandExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVNorExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVNorExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVLTExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVLTExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVLEExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVLEExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSLTExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSLTExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSLEExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSLEExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewSXExpr
-jobject m ValidityChecker vc c Expr expr n int len
-return embed_copy(env, vc->newSXExpr(*expr, len));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVUminusExpr
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->newBVUminusExpr(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSubExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSubExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVPlusExpr
-jobject m ValidityChecker vc n int numbits cv Expr exprs
-return embed_copy(env, vc->newBVPlusExpr(numbits, exprs));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVMultExpr
-jobject m ValidityChecker vc n int numbits c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVMultExpr(numbits, *expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVUDivExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVUDivExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVURemExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVURemExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSDivExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSDivExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSRemExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSRemExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSModExpr
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSModExpr(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVSHL
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVSHL(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVLSHR
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVLSHR(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewBVASHR
-jobject m ValidityChecker vc c Expr expr1 c Expr expr2
-return embed_copy(env, vc->newBVASHR(*expr1, *expr2));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewFixedLeftShiftExpr
-jobject m ValidityChecker vc c Expr expr n int r
-return embed_copy(env, vc->newFixedLeftShiftExpr(*expr, r));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewFixedConstWidthLeftShiftExpr
-jobject m ValidityChecker vc c Expr expr n int r
-return embed_copy(env, vc->newFixedConstWidthLeftShiftExpr(*expr, r));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniNewFixedRightShiftExpr
-jobject m ValidityChecker vc c Expr expr n int r
-return embed_copy(env, vc->newFixedRightShiftExpr(*expr, r));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniComputeBVConst
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->computeBVConst(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTupleExpr
-jobject m ValidityChecker vc cv Expr exprs
-return embed_copy(env, vc->tupleExpr(exprs));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTupleUpdateExpr
-jobject m ValidityChecker vc c Expr tuple n int index c Expr value
-return embed_copy(env, vc->tupleUpdateExpr(*tuple, index, *value));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDatatypeConsExpr
-jobject m ValidityChecker vc n string constructor cv Expr exprs
-return embed_copy(env, vc->datatypeConsExpr(constructor, exprs));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDatatypeSelExpr
-jobject m ValidityChecker vc n string selector c Expr expr
-return embed_copy(env, vc->datatypeSelExpr(selector, *expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniDatatypeTestExpr
-jobject m ValidityChecker vc n string constructor c Expr expr
-return embed_copy(env, vc->datatypeTestExpr(constructor, *expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniForallExpr1
-jobject m ValidityChecker vc cv Expr vars c Expr body
-return embed_copy(env, vc->forallExpr(vars, *body));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniForallExpr2
-jobject m ValidityChecker vc cv Expr vars c Expr body c Expr trigger
-return embed_copy(env, vc->forallExpr(vars, *body, *trigger));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniForallExpr3
-jobject m ValidityChecker vc cv Expr vars c Expr body cv Expr triggers
-return embed_copy(env, vc->forallExpr(vars, *body, triggers));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniForallExpr4
-jobject m ValidityChecker vc cv Expr vars c Expr body cvv Expr triggers
-return embed_copy(env, vc->forallExpr(vars, *body, triggers));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetTrigger
-void m ValidityChecker vc c Expr closure c Expr trigger
-vc->setTrigger(*closure, *trigger);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetTriggers
-void m ValidityChecker vc c Expr closure cv Expr triggers
-vc->setTriggers(*closure, triggers);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetTriggers2
-void m ValidityChecker vc c Expr closure cvv Expr triggers
-vc->setTriggers(*closure, triggers);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetMultiTrigger
-void m ValidityChecker vc c Expr closure cv Expr multiTrigger
-vc->setMultiTrigger(*closure, multiTrigger);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniExistsExpr
-jobject m ValidityChecker vc cv Expr vars c Expr body
-return embed_copy(env, vc->existsExpr(vars, *body));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLambdaExpr
-jobject m ValidityChecker vc cv Expr vars c Expr body
-return embed_copy(env, vc->lambdaExpr(vars, *body));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniTransClosure
-jobject m ValidityChecker vc c Op p
-return embed_copy(env, vc->transClosure(*p));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSimulateExpr
-jobject m ValidityChecker vc c Expr f c Expr s cv Expr inputs c Expr n
-return embed_copy(env, vc->simulateExpr(*f, *s, inputs, *n));
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetResourceLimit
-void m ValidityChecker vc n int limit
-vc->setResourceLimit(limit);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniAssertFormula
-void m ValidityChecker vc c Expr expr
-vc->assertFormula(*expr);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRegisterAtom
-void m ValidityChecker vc c Expr expr
-vc->registerAtom(*expr);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetImpliedLiteral
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getImpliedLiteral());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSimplify
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->simplify(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniQuery
-jstring m ValidityChecker vc c Expr expr
-return toJava(env, vc->query(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCheckUnsat
-jstring m ValidityChecker vc c Expr expr
-return toJava(env, vc->checkUnsat(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniCheckContinue
-jstring m ValidityChecker vc
-return toJava(env, vc->checkContinue());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniRestart
-jstring m ValidityChecker vc c Expr expr
-return toJava(env, vc->restart(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniReturnFromCheck
-void m ValidityChecker vc
-vc->returnFromCheck();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetUserAssumptions
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-vc->getUserAssumptions(result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetInternalAssumptions
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-vc->getInternalAssumptions(result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetAssumptions
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-vc->getAssumptions(result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetAssumptionsUsed
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-vc->getAssumptionsUsed(result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetCounterExample
-jobjectArray m ValidityChecker vc n bool inOrder
-vector<Expr> result;
-vc->getCounterExample(result, inOrder);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniValue
-jstring m ValidityChecker vc c Expr expr
-return toJava(env, vc->value(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetValue
-jobject m ValidityChecker vc c Expr expr
-return embed_copy(env, vc->getValue(*expr));
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetConcreteModel
-jobjectArray m ValidityChecker vc
-ExprMap<Expr> result;
-vc->getConcreteModel(result);
-return toJavaHCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniInconsistent1
-jboolean m ValidityChecker vc
-return vc->inconsistent();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniInconsistent2
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-bool inconsistent = vc->inconsistent(result);
-assert(inconsistent);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIncomplete1
-jboolean m ValidityChecker vc
-return vc->incomplete();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniIncomplete2
-jobjectArray m ValidityChecker vc
-vector<std::string> result;
-bool incomplete = vc->incomplete(result);
-assert(incomplete);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetProof
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getProof());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetTCC
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getTCC());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetAssumptionsTCC
-jobjectArray m ValidityChecker vc
-vector<Expr> result;
-vc->getAssumptionsTCC(result);
-return toJavaVCopy(env, result);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetProofTCC
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getProofTCC());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetClosure
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getClosure());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetProofClosure
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getProofClosure());
-
-
-
-
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniStackLevel
-jint m ValidityChecker vc
-return vc->stackLevel();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPush
-void m ValidityChecker vc
-vc->push();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPop
-void m ValidityChecker vc
-vc->pop();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPopTo
-void m ValidityChecker vc n int stackLevel
-vc->popto(stackLevel);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniScopeLevel
-jint m ValidityChecker vc
-return vc->scopeLevel();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPushScope
-void m ValidityChecker vc
-vc->pushScope();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPopScope
-void m ValidityChecker vc
-vc->popScope();
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPopToScope
-void m ValidityChecker vc n int stackLevel
-vc->poptoScope(stackLevel);
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetCurrentContext
-jobject m ValidityChecker vc
-return embed_mut_ref(env, vc->getCurrentContext());
-
-
-
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniLoadFile1
-void m ValidityChecker vc n string fileName n string lang
-vc->loadFile(fileName, toCppInputLanguage(env, lang), false);
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniGetStatistics
-jobject m ValidityChecker vc
-return embed_copy(env, vc->getStatistics());
-
-DEFINITION: Java_cvc3_ValidityChecker_jniPrintStatistics
-void m ValidityChecker vc
-vc->printStatistics();
-
-
-DEFINITION: Java_cvc3_ValidityChecker_jniSetTimeLimit
-void m ValidityChecker vc n int n
-vc->setTimeLimit((unsigned int)n);
+++ /dev/null
-topdir = ../..
-srcdir = src/compat
-
-include $(topdir)/Makefile.subdir
+++ /dev/null
-# LIBCVC4COMPAT_VERSION (-version-info) is in the form current:revision:age
-#
-# current -
-# increment if interfaces have been added, removed or changed
-# revision -
-# increment if source code has changed
-# set to zero if current is incremented
-# age -
-# increment if interfaces have been added
-# set to zero if interfaces have been removed
-# or changed
-#
-LIBCVC4COMPAT_VERSION = @CVC4_COMPAT_LIBRARY_VERSION@
-
-AM_CPPFLAGS = \
- -D__BUILDING_CVC4COMPATLIB \
- -I@builddir@/.. $(ANTLR_INCLUDES) -I@srcdir@/../include -I@srcdir@/..
-AM_CXXFLAGS = -Wall -Wno-unknown-pragmas
-
-if CVC4_BUILD_LIBCOMPAT
-
-lib_LTLIBRARIES = libcvc4compat.la
-
-libcvc4compat_la_LDFLAGS = \
- -no-undefined \
- -version-info $(LIBCVC4COMPAT_VERSION)
-
-libcvc4compat_la_LIBADD = \
- @builddir@/../libcvc4.la \
- @builddir@/../parser/libcvc4parser.la \
- @builddir@/../lib/libreplacements.la
-
-libcvc4compat_la_SOURCES = \
- cvc3_compat.h \
- cvc3_compat.cpp
-libcvc4compat_la_CXXFLAGS = -fno-strict-aliasing
-
-else
-
-EXTRA_DIST = \
- cvc3_kinds.h \
- cvc3_compat.h \
- cvc3_compat.cpp
-
-endif
+++ /dev/null
-/********************* */
-/*! \file cvc3_compat.cpp
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters, Tim King, Andrew Reynolds
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief CVC3 compatibility layer for CVC4
- **
- ** CVC3 compatibility layer for CVC4.
- **/
-
-#include "compat/cvc3_compat.h"
-
-#include <algorithm>
-#include <cassert>
-#include <iosfwd>
-#include <iterator>
-#include <sstream>
-
-#include "api/cvc4cpp.h"
-#include "base/exception.h"
-#include "base/output.h"
-#include "expr/expr_iomanip.h"
-#include "expr/kind.h"
-#include "options/options.h"
-#include "options/set_language.h"
-#include "parser/parser.h"
-#include "parser/parser_builder.h"
-#include "smt/command.h"
-#include "util/bitvector.h"
-#include "util/sexpr.h"
-
-using namespace std;
-
-// Matches base/cvc4_assert.h's PrettyCheckArgument.
-// base/cvc4_assert.h cannot be directly included.
-#define CompatCheckArgument(cond, arg, msg...) \
- do { \
- if(__builtin_expect( ( ! (cond) ), false )) { \
- throw ::CVC4::IllegalArgumentException(#cond, #arg, __PRETTY_FUNCTION__, \
- ::CVC4::IllegalArgumentException::formatVariadic(msg).c_str()); \
- } \
- } while(0)
-
-#define Unimplemented(str) throw Exception(str)
-
-namespace CVC3 {
-
-// Connects ExprManagers to ValidityCheckers. Needed to clean up the
-// emmcs on ValidityChecker destruction (which are used for
-// ExprManager-to-ExprManager import).
-static std::map<CVC4::ExprManager*, ValidityChecker*> s_validityCheckers;
-
-static std::unordered_map<Type, Expr, CVC4::TypeHashFunction> s_typeToExpr;
-static std::unordered_map<Expr, Type, CVC4::ExprHashFunction> s_exprToType;
-
-static bool typeHasExpr(const Type& t) {
- std::unordered_map<Type, Expr, CVC4::TypeHashFunction>::const_iterator i = s_typeToExpr.find(t);
- return i != s_typeToExpr.end();
-}
-
-static Expr typeToExpr(const Type& t) {
- std::unordered_map<Type, Expr, CVC4::TypeHashFunction>::const_iterator i = s_typeToExpr.find(t);
- assert(i != s_typeToExpr.end());
- return (*i).second;
-}
-
-static Type exprToType(const Expr& e) {
- std::unordered_map<Expr, Type, CVC4::ExprHashFunction>::const_iterator i = s_exprToType.find(e);
- assert(i != s_exprToType.end());
- return (*i).second;
-}
-
-std::string int2string(int n) {
- std::ostringstream ss;
- ss << n;
- return ss.str();
-}
-
-std::ostream& operator<<(std::ostream& out, CLFlagType clft) {
- switch (clft) {
- case CLFLAG_NULL:
- out << "CLFLAG_NULL";
- break;
- case CLFLAG_BOOL:
- out << "CLFLAG_BOOL";
- break;
- case CLFLAG_INT:
- out << "CLFLAG_INT";
- break;
- case CLFLAG_STRING:
- out << "CLFLAG_STRING";
- break;
- case CLFLAG_STRVEC:
- out << "CLFLAG_STRVEC";
- break;
- default:
- out << "CLFlagType!UNKNOWN";
- break;
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, QueryResult qr) {
- switch(qr) {
- case SATISFIABLE: out << "SATISFIABLE/INVALID"; break;
- case UNSATISFIABLE: out << "VALID/UNSATISFIABLE"; break;
- case ABORT: out << "ABORT"; break;
- case UNKNOWN: out << "UNKNOWN"; break;
- default: out << "QueryResult!UNKNOWN";
- }
-
- return out;
-}
-
-std::string QueryResultToString(QueryResult qr) {
- stringstream sstr;
- sstr << qr;
- return sstr.str();
-}
-
-std::ostream& operator<<(std::ostream& out, FormulaValue fv) {
- switch(fv) {
- case TRUE_VAL: out << "TRUE_VAL"; break;
- case FALSE_VAL: out << "FALSE_VAL"; break;
- case UNKNOWN_VAL: out << "UNKNOWN_VAL"; break;
- default: out << "FormulaValue!UNKNOWN";
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, CVC3CardinalityKind c) {
- switch(c) {
- case CARD_FINITE: out << "CARD_FINITE"; break;
- case CARD_INFINITE: out << "CARD_INFINITE"; break;
- case CARD_UNKNOWN: out << "CARD_UNKNOWN"; break;
- default: out << "CVC3CardinalityKind!UNKNOWN";
- }
-
- return out;
-}
-
-static string toString(CLFlagType clft) {
- stringstream sstr;
- sstr << clft;
- return sstr.str();
-}
-
-bool operator==(const Cardinality& c, CVC3CardinalityKind d) {
- switch(d) {
- case CARD_FINITE:
- return c.isFinite();
- case CARD_INFINITE:
- return c.isInfinite();
- case CARD_UNKNOWN:
- return c.isUnknown();
- }
-
- throw Exception("internal error: CVC3 cardinality kind unhandled");
-}
-
-bool operator==(CVC3CardinalityKind d, const Cardinality& c) {
- return c == d;
-}
-
-bool operator!=(const Cardinality& c, CVC3CardinalityKind d) {
- return !(c == d);
-}
-
-bool operator!=(CVC3CardinalityKind d, const Cardinality& c) {
- return !(c == d);
-}
-
-Type::Type() :
- CVC4::Type() {
-}
-
-Type::Type(const CVC4::Type& type) :
- CVC4::Type(type) {
-}
-
-Type::Type(const Type& type) :
- CVC4::Type(type) {
-}
-
-Expr Type::getExpr() const {
- if(typeHasExpr(*this)) {
- return typeToExpr(*this);
- }
- Expr e = getExprManager()->mkVar("compatibility-layer-expr-type", *this);
- s_typeToExpr[*this] = e;
- s_exprToType[e] = *this;
- s_validityCheckers[e.getExprManager()]->d_exprTypeMapRemove.push_back(e);
- return e;
-}
-
-int Type::arity() const {
- return isSort() ? CVC4::SortType(*this).getParamTypes().size() : 0;
-}
-
-Type Type::operator[](int i) const {
- return Type(CVC4::Type(CVC4::SortType(*this).getParamTypes()[i]));
-}
-
-bool Type::isBool() const {
- return isBoolean();
-}
-
-bool Type::isSubtype() const {
- return false;
-}
-
-Cardinality Type::card() const {
- return getCardinality();
-}
-
-Expr Type::enumerateFinite(Unsigned n) const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Unsigned Type::sizeFinite() const {
- return getCardinality().getFiniteCardinality().getUnsignedLong();
-}
-
-Type Type::typeBool(ExprManager* em) {
- return Type(CVC4::Type(em->booleanType()));
-}
-
-Type Type::funType(const std::vector<Type>& typeDom,
- const Type& typeRan) {
- const vector<CVC4::Type>& dom =
- *reinterpret_cast<const vector<CVC4::Type>*>(&typeDom);
- return Type(typeRan.getExprManager()->mkFunctionType(dom, typeRan));
-}
-
-Type Type::funType(const Type& typeRan) const {
- return Type(getExprManager()->mkFunctionType(*this, typeRan));
-}
-
-Expr::Expr() : CVC4::Expr() {
-}
-
-Expr::Expr(const Expr& e) : CVC4::Expr(e) {
-}
-
-Expr::Expr(const CVC4::Expr& e) : CVC4::Expr(e) {
-}
-
-Expr::Expr(ExprManager* em, const CVC4::Kind k) : CVC4::Expr() {
- *this = em->operatorOf(k);
-}
-
-Expr Expr::eqExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::EQUAL, *this, right);
-}
-
-Expr Expr::notExpr() const {
- return getEM()->mkExpr(CVC4::kind::NOT, *this);
-}
-
-Expr Expr::negate() const {
- // avoid double-negatives
- return (getKind() == CVC4::kind::NOT) ?
- (*this)[0] :
- Expr(getEM()->mkExpr(CVC4::kind::NOT, *this));
-}
-
-Expr Expr::andExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::AND, *this, right);
-}
-
-Expr Expr::orExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::OR, *this, right);
-}
-
-Expr Expr::iteExpr(const Expr& thenpart, const Expr& elsepart) const {
- return getEM()->mkExpr(CVC4::kind::ITE, *this, thenpart, elsepart);
-}
-
-Expr Expr::iffExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::EQUAL, *this, right);
-}
-
-Expr Expr::impExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::IMPLIES, *this, right);
-}
-
-Expr Expr::xorExpr(const Expr& right) const {
- return getEM()->mkExpr(CVC4::kind::XOR, *this, right);
-}
-
-Expr Expr::substExpr(const std::vector<Expr>& oldTerms,
- const std::vector<Expr>& newTerms) const {
- const vector<CVC4::Expr>& o =
- *reinterpret_cast<const vector<CVC4::Expr>*>(&oldTerms);
- const vector<CVC4::Expr>& n =
- *reinterpret_cast<const vector<CVC4::Expr>*>(&newTerms);
-
- return Expr(substitute(o, n));
-}
-
-Expr Expr::substExpr(const ExprHashMap<Expr>& oldToNew) const {
- const unordered_map<CVC4::Expr, CVC4::Expr, CVC4::ExprHashFunction>& o2n =
- *reinterpret_cast<const unordered_map<CVC4::Expr, CVC4::Expr, CVC4::ExprHashFunction>*>(&oldToNew);
-
- return Expr(substitute(o2n));
-}
-
-Expr Expr::operator!() const {
- return notExpr();
-}
-
-Expr Expr::operator&&(const Expr& right) const {
- return andExpr(right);
-}
-
-Expr Expr::operator||(const Expr& right) const {
- return orExpr(right);
-}
-
-size_t Expr::hash(const Expr& e) {
- return CVC4::ExprHashFunction()(e);
-}
-
-size_t Expr::hash() const {
- return CVC4::ExprHashFunction()(*this);
-}
-
-bool Expr::isFalse() const {
- return getKind() == CVC4::kind::CONST_BOOLEAN && getConst<bool>() == false;
-}
-
-bool Expr::isTrue() const {
- return getKind() == CVC4::kind::CONST_BOOLEAN && getConst<bool>() == true;
-}
-
-bool Expr::isBoolConst() const {
- return getKind() == CVC4::kind::CONST_BOOLEAN;
-}
-
-bool Expr::isVar() const {
- return isVariable();
-}
-
-bool Expr::isString() const {
- return getType().isString();
-}
-
-bool Expr::isBoundVar() const {
- return getKind() == CVC4::kind::BOUND_VARIABLE;
-}
-
-bool Expr::isForall() const {
- return getKind() == CVC4::kind::FORALL;
-}
-
-bool Expr::isExists() const {
- return getKind() == CVC4::kind::EXISTS;
-}
-
-bool Expr::isLambda() const {
- return getKind() == CVC4::kind::LAMBDA;
-}
-
-bool Expr::isClosure() const {
- return isQuantifier() || isLambda();
-}
-
-bool Expr::isQuantifier() const {
- return getKind() == CVC4::kind::FORALL || getKind() == CVC4::kind::EXISTS;
-}
-
-bool Expr::isApply() const {
- return hasOperator();
-}
-
-bool Expr::isSymbol() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-bool Expr::isTheorem() const {
- return false;
-}
-
-bool Expr::isType() const {
- return s_exprToType.find(*this) != s_exprToType.end();
-}
-
-bool Expr::isTerm() const {
- return !getType().isBool();
-}
-
-bool Expr::isConstant() const {
- return isConst();
-}
-
-bool Expr::isRawList() const {
- return false;
-}
-
-bool Expr::isAtomic() const {
- if (getType().isBool()) {
- return isBoolConst();
- }
- for (int k = 0; k < arity(); ++k) {
- if (!(*this)[k].isAtomic()) {
- return false;
- }
- }
- return true;
-}
-
-bool Expr::isAtomicFormula() const {
- if (!getType().isBool()) {
- return false;
- }
- switch(getKind()) {
- case CVC4::kind::FORALL:
- case CVC4::kind::EXISTS:
- case CVC4::kind::XOR:
- case CVC4::kind::NOT:
- case CVC4::kind::AND:
- case CVC4::kind::OR:
- case CVC4::kind::ITE:
- case CVC4::kind::IMPLIES:
- return false;
- case CVC4::kind::EQUAL:
- return (*this)[0].getType().isBool();
- break;
- default:
- ; /* fall through */
- }
- for (Expr::iterator k = begin(), kend=end(); k != kend; ++k) {
- if (!CVC3::Expr(*k).isAtomic()) {
- return false;
- }
- }
- return true;
-}
-
-bool Expr::isAbsAtomicFormula() const {
- return isQuantifier() || isAtomicFormula();
-}
-
-bool Expr::isLiteral() const {
- return isAtomicFormula() || (isNot() && (*this)[0].isAtomicFormula());
-}
-
-bool Expr::isAbsLiteral() const {
- return isAbsAtomicFormula() || (isNot() && (*this)[0].isAbsAtomicFormula());
-}
-
-bool Expr::isBoolConnective() const {
- if (!getType().isBool()) {
- return false;
- }
- switch (getKind()) {
- case CVC4::kind::NOT:
- case CVC4::kind::AND:
- case CVC4::kind::OR:
- case CVC4::kind::IMPLIES:
- case CVC4::kind::XOR:
- case CVC4::kind::ITE:
- return true;
- case CVC4::kind::EQUAL:
- return (*this)[0].getType().isBool();
- break;
- default:
- return false;
- }
-}
-
-bool Expr::isPropLiteral() const {
- return (isNot() && (*this)[0].isPropAtom()) || isPropAtom();
-}
-
-bool Expr::isPropAtom() const {
- return !isTerm() && !isBoolConnective();
-}
-
-std::string Expr::getName() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-std::string Expr::getUid() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-std::string Expr::getString() const {
- CompatCheckArgument(getKind() == CVC4::kind::CONST_STRING, *this, "CVC3::Expr::getString(): not a string Expr: `%s'", toString().c_str());
- return getConst<CVC4::String>().toString();
-}
-
-std::vector<Expr> Expr::getVars() const {
- CompatCheckArgument(isClosure(), *this, "CVC3::Expr::getVars(): not a closure Expr: `%s'", toString().c_str());
- const vector<CVC4::Expr>& kids = (*this)[0].getChildren();
- vector<Expr> v;
- for(vector<CVC4::Expr>::const_iterator i = kids.begin(); i != kids.end(); ++i) {
- v.push_back(*i);
- }
- return v;
-}
-
-Expr Expr::getExistential() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-int Expr::getBoundIndex() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr Expr::getBody() const {
- CompatCheckArgument(isClosure(), *this, "CVC3::Expr::getBody(): not a closure Expr: `%s'", toString().c_str());
- return (*this)[1];
-}
-
-Theorem Expr::getTheorem() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-bool Expr::isEq() const {
- return getKind() == CVC4::kind::EQUAL;
-}
-
-bool Expr::isNot() const {
- return getKind() == CVC4::kind::NOT;
-}
-
-bool Expr::isAnd() const {
- return getKind() == CVC4::kind::AND;
-}
-
-bool Expr::isOr() const {
- return getKind() == CVC4::kind::OR;
-}
-
-bool Expr::isITE() const {
- return getKind() == CVC4::kind::ITE;
-}
-
-bool Expr::isIff() const {
- return getKind() == CVC4::kind::EQUAL && (*this)[0].getType().isBool();;
-}
-
-bool Expr::isImpl() const {
- return getKind() == CVC4::kind::IMPLIES;
-}
-
-bool Expr::isXor() const {
- return getKind() == CVC4::kind::XOR;
-}
-
-bool Expr::isRational() const {
- return getKind() == CVC4::kind::CONST_RATIONAL;
-}
-
-bool Expr::isSkolem() const {
- return getKind() == CVC4::kind::SKOLEM;
-}
-
-const Rational& Expr::getRational() const {
- CompatCheckArgument(isRational(), *this, "CVC3::Expr::getRational(): not a rational Expr: `%s'", toString().c_str());
- return getConst<CVC4::Rational>();
-}
-
-Op Expr::mkOp() const {
- return *this;
-}
-
-Op Expr::getOp() const {
- return getOperator();
-}
-
-Expr Expr::getOpExpr() const {
- return getOperator();
-}
-
-int Expr::getOpKind() const {
- Expr op = getOperator();
- int k = op.getKind();
- return k == BUILTIN ? getKind() : k;
-}
-
-Expr Expr::getExpr() const {
- return *this;
-}
-
-std::vector< std::vector<Expr> > Expr::getTriggers() const {
- CompatCheckArgument(isClosure(), *this,
- "getTriggers() called on non-closure expr");
- if(getNumChildren() < 3) {
- // no triggers for this quantifier
- return vector< vector<Expr> >();
- } else {
- // get the triggers from the third child
- Expr triggers = (*this)[2];
- vector< vector<Expr> > v;
- for(const_iterator i = triggers.begin(); i != triggers.end(); ++i) {
- v.push_back(vector<Expr>());
- for(const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
- v.back().push_back(*j);
- }
- }
- return v;
- }
-}
-
-ExprManager* Expr::getEM() const {
- return reinterpret_cast<ExprManager*>(getExprManager());
-}
-
-std::vector<Expr> Expr::getKids() const {
- vector<CVC4::Expr> v = getChildren();
- return *reinterpret_cast<vector<Expr>*>(&v);
-}
-
-ExprIndex Expr::getIndex() const {
- return getId();
-}
-
-int Expr::arity() const {
- return getNumChildren();
-}
-
-Expr Expr::unnegate() const {
- return isNot() ? Expr((*this)[0]) : *this;
-}
-
-bool Expr::isInitialized() const {
- return !isNull();
-}
-
-Type Expr::getType() const {
- return Type(this->CVC4::Expr::getType());
-}
-
-Type Expr::lookupType() const {
- return getType();
-}
-
-void Expr::pprint() const {
- std::cout << *this << std::endl;
-}
-
-void Expr::pprintnodag() const {
- CVC4::expr::ExprDag::Scope scope(std::cout, 0);
- std::cout << *this << std::endl;
-}
-
-bool isArrayLiteral(const Expr& e) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-std::string ExprManager::getKindName(int kind) {
- return CVC4::kind::kindToString(CVC4::Kind(kind));
-}
-
-InputLanguage ExprManager::getInputLang() const {
- return getOptions().getInputLanguage();
-}
-
-InputLanguage ExprManager::getOutputLang() const {
- return CVC4::language::toInputLanguage(getOptions().getOutputLanguage());
-}
-
-Expr Expr::operator[](int i) const {
- return Expr(this->CVC4::Expr::operator[](i));
-}
-
-CLFlag::CLFlag(bool b, const std::string& help, bool display) :
- d_tp(CLFLAG_BOOL) {
- d_data.b = b;
-}
-
-CLFlag::CLFlag(int i, const std::string& help, bool display) :
- d_tp(CLFLAG_INT) {
- d_data.i = i;
-}
-
-CLFlag::CLFlag(const std::string& s, const std::string& help, bool display) :
- d_tp(CLFLAG_STRING) {
- d_data.s = new string(s);
-}
-
-CLFlag::CLFlag(const char* s, const std::string& help, bool display) :
- d_tp(CLFLAG_STRING) {
- d_data.s = new string(s);
-}
-
-CLFlag::CLFlag(const std::vector<std::pair<string,bool> >& sv,
- const std::string& help, bool display) :
- d_tp(CLFLAG_STRVEC) {
- d_data.sv = new vector<pair<string, bool> >(sv);
-}
-
-CLFlag::CLFlag() :
- d_tp(CLFLAG_NULL) {
-}
-
-CLFlag::CLFlag(const CLFlag& f) :
- d_tp(f.d_tp) {
- switch(d_tp) {
- case CLFLAG_STRING:
- d_data.s = new string(*f.d_data.s);
- break;
- case CLFLAG_STRVEC:
- d_data.sv = new vector<pair<string, bool> >(*f.d_data.sv);
- break;
- default:
- d_data = f.d_data;
- }
-}
-
-CLFlag::~CLFlag() {
- switch(d_tp) {
- case CLFLAG_STRING:
- delete d_data.s;
- break;
- case CLFLAG_STRVEC:
- delete d_data.sv;
- break;
- default:
- ; // nothing to do
- }
-}
-
-CLFlag& CLFlag::operator=(const CLFlag& f) {
- if(this == &f) {
- // self-assignment
- return *this;
- }
-
- // try to preserve the existing heap objects if possible
- if(d_tp == f.d_tp) {
- switch(d_tp) {
- case CLFLAG_STRING:
- *d_data.s = *f.d_data.s;
- break;
- case CLFLAG_STRVEC:
- *d_data.sv = *f.d_data.sv;
- break;
- default:
- d_data = f.d_data;
- }
- } else {
- switch(d_tp) {
- case CLFLAG_STRING:
- delete d_data.s;
- break;
- case CLFLAG_STRVEC:
- delete d_data.sv;
- break;
- default:
- ; // nothing to do here
- }
-
- switch(f.d_tp) {
- case CLFLAG_STRING:
- d_data.s = new string(*f.d_data.s);
- break;
- case CLFLAG_STRVEC:
- d_data.sv = new vector<pair<string, bool> >(*f.d_data.sv);
- break;
- default:
- d_data = f.d_data;
- }
- }
- d_tp = f.d_tp;
- return *this;
-}
-
-CLFlag& CLFlag::operator=(bool b) {
- CompatCheckArgument(d_tp == CLFLAG_BOOL, this);
- d_data.b = b;
- return *this;
-}
-
-CLFlag& CLFlag::operator=(int i) {
- CompatCheckArgument(d_tp == CLFLAG_INT, this);
- d_data.i = i;
- return *this;
-}
-
-CLFlag& CLFlag::operator=(const std::string& s) {
- CompatCheckArgument(d_tp == CLFLAG_STRING, this);
- *d_data.s = s;
- return *this;
-}
-
-CLFlag& CLFlag::operator=(const char* s) {
- CompatCheckArgument(d_tp == CLFLAG_STRING, this);
- *d_data.s = s;
- return *this;
-}
-
-CLFlag& CLFlag::operator=(const std::pair<string, bool>& p) {
- CompatCheckArgument(d_tp == CLFLAG_STRVEC, this);
- d_data.sv->push_back(p);
- return *this;
-}
-
-CLFlag& CLFlag::operator=(const std::vector<std::pair<string, bool> >& sv) {
- CompatCheckArgument(d_tp == CLFLAG_STRVEC, this);
- *d_data.sv = sv;
- return *this;
-}
-
-CLFlagType CLFlag::getType() const {
- return d_tp;
-}
-
-bool CLFlag::modified() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-bool CLFlag::display() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-const bool& CLFlag::getBool() const {
- CompatCheckArgument(d_tp == CLFLAG_BOOL, this);
- return d_data.b;
-}
-
-const int& CLFlag::getInt() const {
- CompatCheckArgument(d_tp == CLFLAG_INT, this);
- return d_data.i;
-}
-
-const std::string& CLFlag::getString() const {
- CompatCheckArgument(d_tp == CLFLAG_STRING, this);
- return *d_data.s;
-}
-
-const std::vector<std::pair<string, bool> >& CLFlag::getStrVec() const {
- CompatCheckArgument(d_tp == CLFLAG_STRVEC, this);
- return *d_data.sv;
-}
-
-const std::string& CLFlag::getHelp() const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void CLFlags::addFlag(const std::string& name, const CLFlag& f) {
- d_map[name] = f;
-}
-
-size_t CLFlags::countFlags(const std::string& name) const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-size_t CLFlags::countFlags(const std::string& name,
- std::vector<std::string>& names) const {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-const CLFlag& CLFlags::getFlag(const std::string& name) const {
- FlagMap::const_iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- return (*i).second;
-}
-
-const CLFlag& CLFlags::operator[](const std::string& name) const {
- return getFlag(name);
-}
-
-void CLFlags::setFlag(const std::string& name, const CLFlag& f) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- CompatCheckArgument((*i).second.getType() == f.getType(), f,
- "Command-line flag `%s' has type %s, but caller tried to set to a %s.",
- name.c_str(),
- toString((*i).second.getType()).c_str(),
- toString(f.getType()).c_str());
- (*i).second = f;
-}
-
-void CLFlags::setFlag(const std::string& name, bool b) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*i).second = b;
-}
-
-void CLFlags::setFlag(const std::string& name, int i) {
- FlagMap::iterator it = d_map.find(name);
- CompatCheckArgument(it != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*it).second = i;
-}
-
-void CLFlags::setFlag(const std::string& name, const std::string& s) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*i).second = s;
-}
-
-void CLFlags::setFlag(const std::string& name, const char* s) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*i).second = s;
-}
-
-void CLFlags::setFlag(const std::string& name, const std::pair<string, bool>& p) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*i).second = p;
-}
-
-void CLFlags::setFlag(const std::string& name,
- const std::vector<std::pair<string, bool> >& sv) {
- FlagMap::iterator i = d_map.find(name);
- CompatCheckArgument(i != d_map.end(), name, "No command-line flag by that name, or not supported.");
- (*i).second = sv;
-}
-
-void ValidityChecker::setUpOptions(CVC4::Options& options, const CLFlags& clflags) {
- // Note: SIMPLIFICATION_MODE_INCREMENTAL, which was used
- // for CVC3 compatibility, is not supported by CVC4
- // anymore.
-
- // always incremental and model-producing in CVC3 compatibility mode
- // also incrementally-simplifying and interactive
- d_smt->setOption("incremental", string("true"));
- // disable this option by default for now, because datatype models
- // are broken [MGD 10/4/2012]
- //d_smt->setOption("produce-models", string("true"));
- d_smt->setOption("interactive-mode", string("true"));// support SmtEngine::getAssertions()
-
- d_smt->setOption("statistics", string(clflags["stats"].getBool() ? "true" : "false"));
- d_smt->setOption("random-seed", int2string(clflags["seed"].getInt()));
- d_smt->setOption("parse-only", string(clflags["parse-only"].getBool() ? "true" : "false"));
- d_smt->setOption("input-language", clflags["lang"].getString());
- if(clflags["output-lang"].getString() == "") {
- stringstream langss;
- langss << CVC4::language::toOutputLanguage(options.getInputLanguage());
- d_smt->setOption("output-language", langss.str());
- } else {
- d_smt->setOption("output-language", clflags["output-lang"].getString());
- }
-}
-
-ValidityChecker::ValidityChecker()
- : d_clflags(new CLFlags()),
- d_options(),
- d_em(NULL),
- d_emmc(),
- d_reverseEmmc(),
- d_smt(NULL),
- d_parserContext(NULL),
- d_exprTypeMapRemove(),
- d_stackLevel(0),
- d_constructors(),
- d_selectors()
-{
- d_solver.reset(new CVC4::api::Solver(&d_options));
- d_smt = d_solver->getSmtEngine();
- d_em = reinterpret_cast<ExprManager*>(d_solver->getExprManager());
- s_validityCheckers[d_em] = this;
- setUpOptions(d_options, *d_clflags);
- d_parserContext = CVC4::parser::ParserBuilder(d_solver.get(), "<internal>")
- .withInputLanguage(CVC4::language::input::LANG_CVC4)
- .withStringInput("")
- .build();
-}
-
-ValidityChecker::ValidityChecker(const CLFlags& clflags)
- : d_clflags(new CLFlags(clflags)),
- d_options(),
- d_em(NULL),
- d_emmc(),
- d_reverseEmmc(),
- d_smt(NULL),
- d_parserContext(NULL),
- d_exprTypeMapRemove(),
- d_stackLevel(0),
- d_constructors(),
- d_selectors()
-{
- d_solver.reset(new CVC4::api::Solver(&d_options));
- d_smt = d_solver->getSmtEngine();
- d_em = reinterpret_cast<ExprManager*>(d_solver->getExprManager());
- s_validityCheckers[d_em] = this;
- setUpOptions(d_options, *d_clflags);
- d_parserContext = CVC4::parser::ParserBuilder(d_solver.get(), "<internal>")
- .withInputLanguage(CVC4::language::input::LANG_CVC4)
- .withStringInput("")
- .build();
-}
-
-ValidityChecker::~ValidityChecker() {
- for(vector<Expr>::iterator i = d_exprTypeMapRemove.begin(); i != d_exprTypeMapRemove.end(); ++i) {
- s_typeToExpr.erase(s_exprToType[*i]);
- s_exprToType.erase(*i);
- }
- d_exprTypeMapRemove.clear();
- delete d_parserContext;
- d_emmc.clear();
- for(set<ValidityChecker*>::iterator i = d_reverseEmmc.begin(); i != d_reverseEmmc.end(); ++i) {
- (*i)->d_emmc.erase(d_em);
- }
- d_reverseEmmc.clear();
- s_validityCheckers.erase(d_em);
- delete d_clflags;
-}
-
-CLFlags& ValidityChecker::getFlags() const {
- return *d_clflags;
-}
-
-void ValidityChecker::reprocessFlags() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-CLFlags ValidityChecker::createFlags() {
- CLFlags flags;
-
- // We expect the user to type cvc3 -h to get help, which will set
- // the "help" flag to false; that's why it's initially true.
-
- // Overall system control flags
- flags.addFlag("timeout", CLFlag(0, "Kill cvc3 process after given number of seconds (0==no limit)"));
- flags.addFlag("stimeout", CLFlag(0, "Set time resource limit in tenths of seconds for a query(0==no limit)"));
- flags.addFlag("resource", CLFlag(0, "Set finite resource limit (0==no limit)"));
- flags.addFlag("mm", CLFlag("chunks", "Memory manager (chunks, malloc)"));
-
- // Information printing flags
- flags.addFlag("help",CLFlag(true, "print usage information and exit"));
- flags.addFlag("unsupported",CLFlag(true, "print usage for old/unsupported/experimental options"));
- flags.addFlag("version",CLFlag(true, "print version information and exit"));
- flags.addFlag("interactive", CLFlag(false, "Interactive mode"));
- flags.addFlag("stats", CLFlag(false, "Print run-time statistics"));
- flags.addFlag("seed", CLFlag(91648253, "Set the seed for random sequence"));
- flags.addFlag("printResults", CLFlag(true, "Print results of interactive commands."));
- flags.addFlag("dump-log", CLFlag("", "Dump API call log in CVC3 input "
- "format to given file "
- "(off when file name is \"\")"));
- flags.addFlag("parse-only", CLFlag(false,"Parse the input, then exit."));
-
- //Translation related flags
- flags.addFlag("expResult", CLFlag("", "For smtlib translation. Give the expected result", false));
- flags.addFlag("category", CLFlag("unknown", "For smtlib translation. Give the category", false));
- flags.addFlag("translate", CLFlag(false, "Produce a complete translation from "
- "the input language to output language. "));
- flags.addFlag("real2int", CLFlag(false, "When translating, convert reals to integers.", false));
- flags.addFlag("convertArith", CLFlag(false, "When translating, try to rewrite arith terms into smt-lib subset", false));
- flags.addFlag("convert2diff", CLFlag("", "When translating, try to force into difference logic. Legal values are int and real.", false));
- flags.addFlag("iteLiftArith", CLFlag(false, "For translation. If true, ite's are lifted out of arith exprs.", false));
- flags.addFlag("convertArray", CLFlag(false, "For translation. If true, arrays are converted to uninterpreted functions if possible.", false));
- flags.addFlag("combineAssump", CLFlag(false, "For translation. If true, assumptions are combined into the query.", false));
- flags.addFlag("convert2array", CLFlag(false, "For translation. If true, try to convert to array-only theory", false));
- flags.addFlag("convertToBV",CLFlag(0, "For translation. Set to nonzero to convert ints to bv's of that length", false));
- flags.addFlag("convert-eq-iff",CLFlag(false, "Convert equality on Boolean expressions to iff.", false));
- flags.addFlag("preSimplify",CLFlag(false, "Simplify each assertion or query before translating it", false));
- flags.addFlag("dump-tcc", CLFlag(false, "Compute and dump TCC only"));
- flags.addFlag("trans-skip-pp", CLFlag(false, "Skip preprocess step in translation module", false));
- flags.addFlag("trans-skip-difficulty", CLFlag(false, "Leave out difficulty attribute during translation to SMT v2.0", false));
- flags.addFlag("promote", CLFlag(true, "Promote undefined logic combinations to defined logic combinations during translation to SMT", false));
-
- // Parser related flags
- flags.addFlag("old-func-syntax",CLFlag(false, "Enable parsing of old-style function syntax", false));
-
- // Pretty-printing related flags
- flags.addFlag("dagify-exprs",
- CLFlag(true, "Print expressions with sharing as DAGs"));
- flags.addFlag("lang", CLFlag("presentation", "Input language "
- "(presentation, smt, smt2, internal)"));
- flags.addFlag("output-lang", CLFlag("", "Output language "
- "(presentation, smtlib, simplify, internal, lisp, tptp, spass)"));
- flags.addFlag("indent", CLFlag(false, "Print expressions with indentation"));
- flags.addFlag("width", CLFlag(80, "Suggested line width for printing"));
- flags.addFlag("print-depth", CLFlag(-1, "Max. depth to print expressions "));
- flags.addFlag("print-assump", CLFlag(false, "Print assumptions in Theorems "));
-
- // Search Engine (SAT) related flags
- flags.addFlag("sat",CLFlag("minisat", "choose a SAT solver to use "
- "(sat, minisat)"));
- flags.addFlag("de",CLFlag("dfs", "choose a decision engine to use "
- "(dfs, sat)"));
-
- // Proofs and Assumptions
- flags.addFlag("proofs", CLFlag(false, "Produce proofs"));
- flags.addFlag("check-proofs", CLFlag(false, "Check proofs on-the-fly"));
- flags.addFlag("minimizeClauses", CLFlag(false, "Use brute-force minimization of clauses", false));
- flags.addFlag("dynack", CLFlag(false, "Use dynamic Ackermannization", false));
- flags.addFlag("smart-clauses", CLFlag(true, "Learn multiple clauses per conflict"));
- // Core framework switches
- flags.addFlag("tcc", CLFlag(false, "Check TCCs for each ASSERT and QUERY"));
- flags.addFlag("cnf", CLFlag(true, "Convert top-level Boolean formulas to CNF", false));
- flags.addFlag("ignore-cnf-vars", CLFlag(false, "Do not split on aux. CNF vars (with +cnf)", false));
- flags.addFlag("orig-formula", CLFlag(false, "Preserve the original formula with +cnf (for splitter heuristics)", false));
- flags.addFlag("liftITE", CLFlag(false, "Eagerly lift all ITE exprs"));
- flags.addFlag("iflift", CLFlag(false, "Translate if-then-else terms to CNF (with +cnf)", false));
- flags.addFlag("circuit", CLFlag(false, "With +cnf, use circuit propagation", false));
- flags.addFlag("un-ite-ify", CLFlag(false, "Unconvert ITE expressions", false));
- flags.addFlag("ite-cond-simp",
- CLFlag(false, "Replace ITE condition by TRUE/FALSE in subexprs", false));
- flags.addFlag("preprocess", CLFlag(true, "Preprocess queries"));
- flags.addFlag("pp-pushneg", CLFlag(false, "Push negation in preprocessor"));
- flags.addFlag("pp-bryant", CLFlag(false, "Enable Bryant algorithm for UF", false));
- flags.addFlag("pp-budget", CLFlag(0, "Budget for new preprocessing step", false));
- flags.addFlag("pp-care", CLFlag(true, "Enable care-set preprocessing step", false));
- flags.addFlag("simp-and", CLFlag(false, "Rewrite x&y to x&y[x/true]", false));
- flags.addFlag("simp-or", CLFlag(false, "Rewrite x|y to x|y[x/false]", false));
- flags.addFlag("pp-batch", CLFlag(false, "Ignore assumptions until query, then process all at once"));
-
- // Negate the query when translate into tptp
- flags.addFlag("negate-query", CLFlag(true, "Negate the query when translate into TPTP format"));;
-
- // Concrete model generation (counterexamples) flags
- flags.addFlag("counterexample", CLFlag(false, "Dump counterexample if formula is invalid or satisfiable"));
- flags.addFlag("model", CLFlag(false, "Dump model if formula is invalid or satisfiable"));
- flags.addFlag("unknown-check-model", CLFlag(false, "Try to generate model if formula is unknown"));
- flags.addFlag("applications", CLFlag(true, "Add relevant function applications and array accesses to the concrete countermodel"));
- // Debugging flags (only for the debug build)
- // #ifdef _CVC3_DEBUG_MODE
- vector<pair<string,bool> > sv;
- flags.addFlag("trace", CLFlag(sv, "Tracing. Multiple flags add up."));
- flags.addFlag("dump-trace", CLFlag("", "Dump debugging trace to "
- "given file (off when file name is \"\")"));
- // #endif
- // DP-specific flags
-
- // Arithmetic
- flags.addFlag("arith-new",CLFlag(false, "Use new arithmetic dp", false));
- flags.addFlag("arith3",CLFlag(false, "Use old arithmetic dp that works well with combined theories", false));
- flags.addFlag("var-order",
- CLFlag(false, "Use simple variable order in arith", false));
- flags.addFlag("ineq-delay", CLFlag(0, "Accumulate this many inequalities before processing (-1 for don't process until necessary)"));
-
- flags.addFlag("nonlinear-sign-split", CLFlag(true, "Whether to split on the signs of nontrivial nonlinear terms"));
-
- flags.addFlag("grayshadow-threshold", CLFlag(-1, "Ignore gray shadows bigger than this (makes solver incomplete)"));
- flags.addFlag("pathlength-threshold", CLFlag(-1, "Ignore gray shadows bigger than this (makes solver incomplete)"));
-
- // Arrays
- flags.addFlag("liftReadIte", CLFlag(true, "Lift read of ite"));
-
- //for LFSC stuff, disable Tseitin CNF conversion, by Yeting
- flags.addFlag("cnf-formula", CLFlag(false, "The input must be in CNF. This option automatically enables '-de sat' and disable preprocess"));
-
- //for LFSC print out, by Yeting
- //flags.addFlag("lfsc", CLFlag(false, "the input is already in CNF. This option automatically enables -de sat and disable -preprocess"));
-
- // for LFSC print, allows different modes by Liana
- flags.addFlag("lfsc-mode",
- CLFlag(0, "lfsc mode 0: off, 1:normal, 2:cvc3-mimic etc."));
-
-
- // Quantifiers
- flags.addFlag("max-quant-inst", CLFlag(200, "The maximum number of"
- " naive instantiations"));
-
- flags.addFlag("quant-new",
- CLFlag(true, "If this option is false, only naive instantiation is called"));
-
- flags.addFlag("quant-lazy", CLFlag(false, "Instantiate lazily", false));
-
- flags.addFlag("quant-sem-match",
- CLFlag(false, "Attempt to match semantically when instantiating", false));
-
-// flags.addFlag("quant-const-match",
-// CLFlag(true, "When matching semantically, only match with constants", false));
-
- flags.addFlag("quant-complete-inst",
- CLFlag(false, "Try complete instantiation heuristic. +pp-batch will be automatically enabled"));
-
- flags.addFlag("quant-max-IL",
- CLFlag(100, "The maximum Instantiation Level allowed"));
-
- flags.addFlag("quant-inst-lcache",
- CLFlag(true, "Cache instantiations"));
-
- flags.addFlag("quant-inst-gcache",
- CLFlag(false, "Cache instantiations", false));
-
- flags.addFlag("quant-inst-tcache",
- CLFlag(false, "Cache instantiations", false));
-
-
- flags.addFlag("quant-inst-true",
- CLFlag(true, "Ignore true instantiations"));
-
- flags.addFlag("quant-pullvar",
- CLFlag(false, "Pull out vars", false));
-
- flags.addFlag("quant-score",
- CLFlag(true, "Use instantiation level"));
-
- flags.addFlag("quant-polarity",
- CLFlag(false, "Use polarity ", false));
-
- flags.addFlag("quant-eqnew",
- CLFlag(true, "Use new equality matching"));
-
- flags.addFlag("quant-max-score",
- CLFlag(0, "Maximum initial dynamic score"));
-
- flags.addFlag("quant-trans3",
- CLFlag(true, "Use trans heuristic"));
-
- flags.addFlag("quant-trans2",
- CLFlag(true, "Use trans2 heuristic"));
-
- flags.addFlag("quant-naive-num",
- CLFlag(1000, "Maximum number to call naive instantiation"));
-
- flags.addFlag("quant-naive-inst",
- CLFlag(true, "Use naive instantiation"));
-
- flags.addFlag("quant-man-trig",
- CLFlag(true, "Use manual triggers"));
-
- flags.addFlag("quant-gfact",
- CLFlag(false, "Send facts to core directly", false));
-
- flags.addFlag("quant-glimit",
- CLFlag(1000, "Limit for gfacts", false));
-
- flags.addFlag("print-var-type", //by yeting, as requested by Sascha Boehme for proofs
- CLFlag(false, "Print types for bound variables"));
-
- // Bitvectors
- flags.addFlag("bv32-flag",
- CLFlag(false, "assume that all bitvectors are 32bits with no overflow", false));
-
- // Uninterpreted Functions
- flags.addFlag("trans-closure",
- CLFlag(false,"enables transitive closure of binary relations", false));
-
- // Datatypes
- flags.addFlag("dt-smartsplits",
- CLFlag(true, "enables smart splitting in datatype theory", false));
- flags.addFlag("dt-lazy",
- CLFlag(false, "lazy splitting on datatypes", false));
-
- return flags;
-}
-
-ValidityChecker* ValidityChecker::create(const CLFlags& flags) {
- return new ValidityChecker(flags);
-}
-
-ValidityChecker* ValidityChecker::create() {
- return new ValidityChecker(createFlags());
-}
-
-Type ValidityChecker::boolType() {
- return d_em->booleanType();
-}
-
-Type ValidityChecker::realType() {
- return d_em->realType();
-}
-
-Type ValidityChecker::intType() {
- return d_em->integerType();
-}
-
-Type ValidityChecker::subrangeType(const Expr& l, const Expr& r) {
- Unimplemented("Subrange types not supported by CVC4 (sorry!)");
-}
-
-Type ValidityChecker::subtypeType(const Expr& pred, const Expr& witness) {
- Unimplemented("Predicate subtyping not supported by CVC4 (sorry!)");
- /*
- if(witness.isNull()) {
- return d_em->mkPredicateSubtype(pred);
- } else {
- return d_em->mkPredicateSubtype(pred, witness);
- }
- */
-}
-
-Type ValidityChecker::tupleType(const Type& type0, const Type& type1) {
- vector<CVC4::Type> types;
- types.push_back(type0);
- types.push_back(type1);
- return d_em->mkTupleType(types);
-}
-
-Type ValidityChecker::tupleType(const Type& type0, const Type& type1, const Type& type2) {
- vector<CVC4::Type> types;
- types.push_back(type0);
- types.push_back(type1);
- types.push_back(type2);
- return d_em->mkTupleType(types);
-}
-
-Type ValidityChecker::tupleType(const std::vector<Type>& types) {
- const vector<CVC4::Type>& v =
- *reinterpret_cast<const vector<CVC4::Type>*>(&types);
- return Type(d_em->mkTupleType(v));
-}
-
-Type ValidityChecker::recordType(const std::string& field, const Type& type) {
- std::vector< std::pair<std::string, CVC4::Type> > fields;
- fields.push_back(std::make_pair(field, (const CVC4::Type&) type));
- return d_em->mkRecordType(CVC4::Record(fields));
-}
-
-Type ValidityChecker::recordType(const std::string& field0, const Type& type0,
- const std::string& field1, const Type& type1) {
- std::vector< std::pair<std::string, CVC4::Type> > fields;
- fields.push_back(std::make_pair(field0, (const CVC4::Type&) type0));
- fields.push_back(std::make_pair(field1, (const CVC4::Type&) type1));
- return d_em->mkRecordType(CVC4::Record(fields));
-}
-
-Type ValidityChecker::recordType(const std::string& field0, const Type& type0,
- const std::string& field1, const Type& type1,
- const std::string& field2, const Type& type2) {
- std::vector< std::pair<std::string, CVC4::Type> > fields;
- fields.push_back(std::make_pair(field0, (const CVC4::Type&) type0));
- fields.push_back(std::make_pair(field1, (const CVC4::Type&) type1));
- fields.push_back(std::make_pair(field2, (const CVC4::Type&) type2));
- return d_em->mkRecordType(CVC4::Record(fields));
-}
-
-Type ValidityChecker::recordType(const std::vector<std::string>& fields,
- const std::vector<Type>& types) {
- CompatCheckArgument(fields.size() == types.size() && fields.size() > 0,
- "invalid vector length(s) in recordType()");
- std::vector< std::pair<std::string, CVC4::Type> > fieldSpecs;
- for(unsigned i = 0; i < fields.size(); ++i) {
- fieldSpecs.push_back(std::make_pair(fields[i], (const CVC4::Type&) types[i]));
- }
- return d_em->mkRecordType(CVC4::Record(fieldSpecs));
-}
-
-Type ValidityChecker::dataType(const std::string& name,
- const std::string& constructor,
- const std::vector<std::string>& selectors,
- const std::vector<Expr>& types) {
- CompatCheckArgument(selectors.size() == types.size(), types,
- "expected selectors and types vectors to be of equal"
- "length");
- vector<string> cv;
- vector< vector<string> > sv;
- vector< vector<Expr> > tv;
- cv.push_back(constructor);
- sv.push_back(selectors);
- tv.push_back(types);
- return dataType(name, cv, sv, tv);
-}
-
-Type ValidityChecker::dataType(const std::string& name,
- const std::vector<std::string>& constructors,
- const std::vector<std::vector<std::string> >& selectors,
- const std::vector<std::vector<Expr> >& types) {
- CompatCheckArgument(constructors.size() == selectors.size(), selectors,
- "Expected constructors and selectors vectors to be of "
- "equal length.");
- CompatCheckArgument(constructors.size() == types.size(), types,
- "Expected constructors and types vectors to be of equal "
- "length.");
- vector<string> nv;
- vector< vector<string> > cv;
- vector< vector< vector<string> > > sv;
- vector< vector< vector<Expr> > > tv;
- nv.push_back(name);
- cv.push_back(constructors);
- sv.push_back(selectors);
- tv.push_back(types);
- vector<Type> dtts;
- dataType(nv, cv, sv, tv, dtts);
- assert(dtts.size() == 1);
- return dtts[0];
-}
-
-void ValidityChecker::dataType(const std::vector<std::string>& names,
- const std::vector<std::vector<std::string> >& constructors,
- const std::vector<std::vector<std::vector<std::string> > >& selectors,
- const std::vector<std::vector<std::vector<Expr> > >& types,
- std::vector<Type>& returnTypes) {
-
- CompatCheckArgument(names.size() == constructors.size(), constructors,
- "Expected names and constructors vectors to be of equal "
- "length.");
- CompatCheckArgument(names.size() == selectors.size(), selectors,
- "Expected names and selectors vectors to be of equal "
- "length.");
- CompatCheckArgument(names.size() == types.size(), types,
- "Expected names and types vectors to be of equal "
- "length.");
- vector<CVC4::Datatype> dv;
-
- // Set up the datatype specifications.
- for(unsigned i = 0; i < names.size(); ++i) {
- CVC4::Datatype dt(names[i], false);
- CompatCheckArgument(constructors[i].size() == selectors[i].size(),
- "Expected sub-vectors in constructors and selectors "
- "vectors to match in size.");
- CompatCheckArgument(constructors[i].size() == types[i].size(),
- "Expected sub-vectors in constructors and types "
- "vectors to match in size.");
- for(unsigned j = 0; j < constructors[i].size(); ++j) {
- CVC4::DatatypeConstructor ctor(constructors[i][j]);
- CompatCheckArgument(selectors[i][j].size() == types[i][j].size(), types,
- "Expected sub-vectors in selectors and types vectors "
- "to match in size.");
- for(unsigned k = 0; k < selectors[i][j].size(); ++k) {
- if(types[i][j][k].getType().isString()) {
- CVC4::DatatypeUnresolvedType unresolvedName =
- types[i][j][k].getConst<CVC4::String>().toString();
- ctor.addArg(selectors[i][j][k], unresolvedName);
- } else {
- ctor.addArg(selectors[i][j][k], exprToType(types[i][j][k]));
- }
- }
- dt.addConstructor(ctor);
- }
- dv.push_back(dt);
- }
-
- // Make the datatypes.
- vector<CVC4::DatatypeType> dtts = d_em->mkMutualDatatypeTypes(dv);
-
- // Post-process to register the names of everything with this validity checker.
- // This is necessary for the compatibility layer because cons/sel operations are
- // constructed without appealing explicitly to the Datatype they belong to.
- for(vector<CVC4::DatatypeType>::iterator i = dtts.begin(); i != dtts.end(); ++i) {
- // For each datatype...
- const CVC4::Datatype& dt = (*i).getDatatype();
- // ensure it's well-founded (the check is done here because
- // that's how it is in CVC3)
- CompatCheckArgument(dt.isWellFounded(), "datatype is not well-founded");
- for(CVC4::Datatype::const_iterator j = dt.begin(); j != dt.end(); ++j) {
- // For each constructor, register its name and its selectors names.
- CompatCheckArgument(
- d_constructors.find((*j).getName()) == d_constructors.end(),
- constructors,
- "Cannot have two constructors with the same name in a "
- "ValidityChecker.");
- d_constructors[(*j).getName()] = &dt;
- for(CVC4::DatatypeConstructor::const_iterator k = (*j).begin(); k != (*j).end(); ++k) {
- CompatCheckArgument(
- d_selectors.find((*k).getName()) == d_selectors.end(), selectors,
- "Cannot have two selectors with the same name in a "
- "ValidityChecker.");
- d_selectors[(*k).getName()] = make_pair(&dt, (*j).getName());
- }
- }
- }
-
- // Copy into the output buffer.
- returnTypes.clear();
- copy(dtts.begin(), dtts.end(), back_inserter(returnTypes));
-}
-
-Type ValidityChecker::arrayType(const Type& typeIndex, const Type& typeData) {
- return d_em->mkArrayType(typeIndex, typeData);
-}
-
-Type ValidityChecker::bitvecType(int n) {
- CompatCheckArgument(n >= 0, n,
- "Cannot construct a bitvector type of negative size.");
- return d_em->mkBitVectorType(n);
-}
-
-Type ValidityChecker::funType(const Type& typeDom, const Type& typeRan) {
- return d_em->mkFunctionType(typeDom, typeRan);
-}
-
-Type ValidityChecker::funType(const std::vector<Type>& typeDom, const Type& typeRan) {
- const vector<CVC4::Type>& dom =
- *reinterpret_cast<const vector<CVC4::Type>*>(&typeDom);
- return Type(d_em->mkFunctionType(dom, typeRan));
-}
-
-Type ValidityChecker::createType(const std::string& typeName) {
- return d_em->mkSort(typeName);
-}
-
-Type ValidityChecker::createType(const std::string& typeName, const Type& def) {
- d_parserContext->defineType(typeName, def);
- return def;
-}
-
-Type ValidityChecker::lookupType(const std::string& typeName) {
- return d_parserContext->getSort(typeName);
-}
-
-ExprManager* ValidityChecker::getEM() {
- return d_em;
-}
-
-Expr ValidityChecker::varExpr(const std::string& name, const Type& type) {
- return d_parserContext->mkVar(name, type);
-}
-
-Expr ValidityChecker::varExpr(const std::string& name, const Type& type,
- const Expr& def) {
- CompatCheckArgument(def.getType() == type, def, "expected types to match");
- d_parserContext->defineVar(name, def);
- return def;
-}
-
-Expr ValidityChecker::lookupVar(const std::string& name, Type* type) {
- return d_parserContext->getVariable(name);
-}
-
-Type ValidityChecker::getType(const Expr& e) {
- return d_em->getType(e);
-}
-
-Type ValidityChecker::getBaseType(const Expr& e) {
- return getBaseType(e.getType());
-}
-
-Type ValidityChecker::getBaseType(const Type& t) {
- return t.getBaseType();
-}
-
-Expr ValidityChecker::getTypePred(const Type&t, const Expr& e) {
- // This function appears to be TCC-related---it doesn't just get the pred of a
- // subtype predicate, but returns a predicate describing the type.
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::stringExpr(const std::string& str) {
- return d_em->mkConst(CVC4::String(str));
-}
-
-Expr ValidityChecker::idExpr(const std::string& name) {
- // represent as a string expr, CVC4 doesn't have id exprs
- return d_em->mkConst(CVC4::String(name));
-}
-
-Expr ValidityChecker::listExpr(const std::vector<Expr>& kids) {
- return d_em->mkExpr(CVC4::kind::SEXPR, vector<CVC4::Expr>(kids.begin(), kids.end()));
-}
-
-Expr ValidityChecker::listExpr(const Expr& e1) {
- return d_em->mkExpr(CVC4::kind::SEXPR, e1);
-}
-
-Expr ValidityChecker::listExpr(const Expr& e1, const Expr& e2) {
- return d_em->mkExpr(CVC4::kind::SEXPR, e1, e2);
-}
-
-Expr ValidityChecker::listExpr(const Expr& e1, const Expr& e2, const Expr& e3) {
- return d_em->mkExpr(CVC4::kind::SEXPR, e1, e2, e3);
-}
-
-Expr ValidityChecker::listExpr(const std::string& op,
- const std::vector<Expr>& kids) {
- return d_em->mkExpr(CVC4::kind::SEXPR, d_em->mkConst(CVC4::String(op)), vector<CVC4::Expr>(kids.begin(), kids.end()));
-}
-
-Expr ValidityChecker::listExpr(const std::string& op, const Expr& e1) {
- return d_em->mkExpr(CVC4::kind::SEXPR, d_em->mkConst(CVC4::String(op)), e1);
-}
-
-Expr ValidityChecker::listExpr(const std::string& op, const Expr& e1,
- const Expr& e2) {
- return d_em->mkExpr(CVC4::kind::SEXPR, d_em->mkConst(CVC4::String(op)), e1, e2);
-}
-
-Expr ValidityChecker::listExpr(const std::string& op, const Expr& e1,
- const Expr& e2, const Expr& e3) {
- return d_em->mkExpr(CVC4::kind::SEXPR, d_em->mkConst(CVC4::String(op)), e1, e2, e3);
-}
-
-void ValidityChecker::printExpr(const Expr& e) {
- printExpr(e, Message());
-}
-
-void ValidityChecker::printExpr(const Expr& e, std::ostream& os) {
- CVC4::expr::ExprSetDepth::Scope sd(os, -1);
- CVC4::expr::ExprPrintTypes::Scope pt(os, false);
- CVC4::language::SetLanguage::Scope sl(
- os, d_em->getOptions().getOutputLanguage());
- os << e;
-}
-
-Expr ValidityChecker::parseExpr(const Expr& e) {
- return e;
-}
-
-Type ValidityChecker::parseType(const Expr& e) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::importExpr(const Expr& e) {
- if(e.getExprManager() == d_em) {
- return e;
- }
-
- s_validityCheckers[e.getExprManager()]->d_reverseEmmc.insert(this);
- return e.exportTo(d_em, d_emmc[e.getExprManager()]);
-}
-
-Type ValidityChecker::importType(const Type& t) {
- if(t.getExprManager() == d_em) {
- return t;
- }
-
- s_validityCheckers[t.getExprManager()]->d_reverseEmmc.insert(this);
- return t.exportTo(d_em, d_emmc[t.getExprManager()]);
-}
-
-void ValidityChecker::cmdsFromString(const std::string& s, InputLanguage lang) {
- std::stringstream ss(s, std::stringstream::in);
- return loadFile(ss, lang, false);
-}
-
-Expr ValidityChecker::exprFromString(const std::string& s, InputLanguage lang) {
- std::stringstream ss;
-
- if( lang != PRESENTATION_LANG && lang != SMTLIB_V2_LANG ) {
- ss << lang;
- throw Exception("Unsupported language in exprFromString: " + ss.str());
- }
-
- CVC4::parser::Parser* p =
- CVC4::parser::ParserBuilder(d_solver.get(), "<internal>")
- .withStringInput(s)
- .withInputLanguage(lang)
- .build();
- p->useDeclarationsFrom(d_parserContext);
- Expr e = p->nextExpression();
- if( e.isNull() ) {
- throw CVC4::parser::ParserException("Parser result is null: '" + s + "'");
- }
-
- delete p;
-
- return e;
-}
-
-Expr ValidityChecker::trueExpr() {
- return d_em->mkConst(true);
-}
-
-Expr ValidityChecker::falseExpr() {
- return d_em->mkConst(false);
-}
-
-Expr ValidityChecker::notExpr(const Expr& child) {
- return d_em->mkExpr(CVC4::kind::NOT, child);
-}
-
-Expr ValidityChecker::andExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::AND, left, right);
-}
-
-Expr ValidityChecker::andExpr(const std::vector<Expr>& children) {
- // AND must have at least 2 children
- CompatCheckArgument(children.size() > 0, children);
- return (children.size() == 1) ? children[0] : Expr(d_em->mkExpr(CVC4::kind::AND, *reinterpret_cast<const vector<CVC4::Expr>*>(&children)));
-}
-
-Expr ValidityChecker::orExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::OR, left, right);
-}
-
-Expr ValidityChecker::orExpr(const std::vector<Expr>& children) {
- // OR must have at least 2 children
- CompatCheckArgument(children.size() > 0, children);
- return (children.size() == 1) ? children[0] : Expr(d_em->mkExpr(CVC4::kind::OR, *reinterpret_cast<const vector<CVC4::Expr>*>(&children)));
-}
-
-Expr ValidityChecker::impliesExpr(const Expr& hyp, const Expr& conc) {
- return d_em->mkExpr(CVC4::kind::IMPLIES, hyp, conc);
-}
-
-Expr ValidityChecker::iffExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::EQUAL, left, right);
-}
-
-Expr ValidityChecker::eqExpr(const Expr& child0, const Expr& child1) {
- return d_em->mkExpr(CVC4::kind::EQUAL, child0, child1);
-}
-
-Expr ValidityChecker::iteExpr(const Expr& ifpart, const Expr& thenpart,
- const Expr& elsepart) {
- return d_em->mkExpr(CVC4::kind::ITE, ifpart, thenpart, elsepart);
-}
-
-Expr ValidityChecker::distinctExpr(const std::vector<Expr>& children) {
- CompatCheckArgument(children.size() > 1, children, "it makes no sense to create a `distinct' expression with only one child");
- const vector<CVC4::Expr>& v =
- *reinterpret_cast<const vector<CVC4::Expr>*>(&children);
- return d_em->mkExpr(CVC4::kind::DISTINCT, v);
-}
-
-Op ValidityChecker::createOp(const std::string& name, const Type& type) {
- return d_parserContext->mkVar(name, type);
-}
-
-Op ValidityChecker::createOp(const std::string& name, const Type& type,
- const Expr& def) {
- CompatCheckArgument(def.getType() == type, type,
- "Type mismatch in ValidityChecker::createOp(): `%s' defined to an "
- "expression of type %s but ascribed as type %s", name.c_str(),
- def.getType().toString().c_str(), type.toString().c_str());
- d_parserContext->defineFunction(name, def);
- return def;
-}
-
-Op ValidityChecker::lookupOp(const std::string& name, Type* type) {
- Op op = d_parserContext->getFunction(name);
- *type = op.getType();
- return op;
-}
-
-Expr ValidityChecker::funExpr(const Op& op, const Expr& child) {
- return d_em->mkExpr(CVC4::kind::APPLY_UF, op, child);
-}
-
-Expr ValidityChecker::funExpr(const Op& op, const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::APPLY_UF, op, left, right);
-}
-
-Expr ValidityChecker::funExpr(const Op& op, const Expr& child0,
- const Expr& child1, const Expr& child2) {
- return d_em->mkExpr(CVC4::kind::APPLY_UF, op, child0, child1, child2);
-}
-
-Expr ValidityChecker::funExpr(const Op& op, const std::vector<Expr>& children) {
- vector<CVC4::Expr> opkids;
- opkids.push_back(op);
- opkids.insert(opkids.end(), children.begin(), children.end());
- return d_em->mkExpr(CVC4::kind::APPLY_UF, opkids);
-}
-
-bool ValidityChecker::addPairToArithOrder(const Expr& smaller, const Expr& bigger) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::ratExpr(int n, int d) {
- return d_em->mkConst(Rational(n, d));
-}
-
-Expr ValidityChecker::ratExpr(const std::string& n, const std::string& d, int base) {
- return d_em->mkConst(Rational(n + '/' + d, base));
-}
-
-Expr ValidityChecker::ratExpr(const std::string& n, int base) {
- if(n.find(".") == string::npos) {
- return d_em->mkConst(Rational(n, base));
- } else {
- CompatCheckArgument(base == 10, base, "unsupported base for decimal parsing");
- return d_em->mkConst(Rational::fromDecimal(n));
- }
-}
-
-Expr ValidityChecker::uminusExpr(const Expr& child) {
- return d_em->mkExpr(CVC4::kind::UMINUS, child);
-}
-
-Expr ValidityChecker::plusExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::PLUS, left, right);
-}
-
-Expr ValidityChecker::plusExpr(const std::vector<Expr>& children) {
- // PLUS must have at least 2 children
- CompatCheckArgument(children.size() > 0, children);
- return (children.size() == 1) ? children[0] : Expr(d_em->mkExpr(CVC4::kind::PLUS, *reinterpret_cast<const vector<CVC4::Expr>*>(&children)));
-}
-
-Expr ValidityChecker::minusExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::MINUS, left, right);
-}
-
-Expr ValidityChecker::multExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::MULT, left, right);
-}
-
-Expr ValidityChecker::powExpr(const Expr& x, const Expr& n) {
- return d_em->mkExpr(CVC4::kind::POW, x, n);
-}
-
-Expr ValidityChecker::divideExpr(const Expr& numerator,
- const Expr& denominator) {
- return d_em->mkExpr(CVC4::kind::DIVISION, numerator, denominator);
-}
-
-Expr ValidityChecker::ltExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::LT, left, right);
-}
-
-Expr ValidityChecker::leExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::LEQ, left, right);
-}
-
-Expr ValidityChecker::gtExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::GT, left, right);
-}
-
-Expr ValidityChecker::geExpr(const Expr& left, const Expr& right) {
- return d_em->mkExpr(CVC4::kind::GEQ, left, right);
-}
-
-Expr ValidityChecker::recordExpr(const std::string& field, const Expr& expr) {
- CVC4::Type t = recordType(field, expr.getType());
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, dt[0].getConstructor(), expr);
-}
-
-Expr ValidityChecker::recordExpr(const std::string& field0, const Expr& expr0,
- const std::string& field1, const Expr& expr1) {
- CVC4::Type t = recordType(field0, expr0.getType(),
- field1, expr1.getType());
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, dt[0].getConstructor(), expr0, expr1);
-}
-
-Expr ValidityChecker::recordExpr(const std::string& field0, const Expr& expr0,
- const std::string& field1, const Expr& expr1,
- const std::string& field2, const Expr& expr2) {
- CVC4::Type t = recordType(field0, expr0.getType(),
- field1, expr1.getType(),
- field2, expr2.getType());
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, dt[0].getConstructor(), expr0, expr1, expr2);
-}
-
-Expr ValidityChecker::recordExpr(const std::vector<std::string>& fields,
- const std::vector<Expr>& exprs) {
- std::vector<Type> types;
- for(unsigned i = 0; i < exprs.size(); ++i) {
- types.push_back(exprs[i].getType());
- }
- CVC4::Type t = recordType(fields, types);
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, dt[0].getConstructor(), *reinterpret_cast<const vector<CVC4::Expr>*>(&exprs));
-}
-
-Expr ValidityChecker::recSelectExpr(const Expr& record, const std::string& field) {
- Type t = record.getType();
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- unsigned index = CVC4::Datatype::indexOf( dt[0].getSelector(field) );
- return d_em->mkExpr(CVC4::kind::APPLY_SELECTOR_TOTAL, dt[0].getSelectorInternal( t, index ), record);
-}
-
-Expr ValidityChecker::recUpdateExpr(const Expr& record, const std::string& field,
- const Expr& newValue) {
- return d_em->mkExpr(d_em->mkConst(CVC4::RecordUpdate(field)), record, newValue);
-}
-
-Expr ValidityChecker::readExpr(const Expr& array, const Expr& index) {
- return d_em->mkExpr(CVC4::kind::SELECT, array, index);
-}
-
-Expr ValidityChecker::writeExpr(const Expr& array, const Expr& index,
- const Expr& newValue) {
- return d_em->mkExpr(CVC4::kind::STORE, array, index, newValue);
-}
-
-Expr ValidityChecker::newBVConstExpr(const std::string& s, int base) {
- return d_em->mkConst(CVC4::BitVector(s, base));
-}
-
-Expr ValidityChecker::newBVConstExpr(const std::vector<bool>& bits) {
- Integer value = 0;
- for(vector<bool>::const_iterator i = bits.begin(); i != bits.end(); ++i) {
- value *= 2;
- value += *i ? 1 : 0;
- }
- return d_em->mkConst(CVC4::BitVector(bits.size(), value));
-}
-
-Expr ValidityChecker::newBVConstExpr(const Rational& r, int len) {
- // implementation based on CVC3's TheoryBitvector::newBVConstExpr()
-
- CompatCheckArgument(r.getDenominator() == 1, r,
- "ValidityChecker::newBVConstExpr: "
- "not an integer: `%s'", r.toString().c_str());
- CompatCheckArgument(len > 0, len, "ValidityChecker::newBVConstExpr: "
- "len = %d", len);
-
- string s(r.toString(2));
- size_t strsize = s.size();
- size_t length = len;
- Expr res;
- if(length > 0 && length != strsize) {
- //either (length > strsize) or (length < strsize)
- if(length < strsize) {
- s = s.substr(strsize - length, length);
- } else {
- string zeros("");
- for(size_t i = 0, pad = length - strsize; i < pad; ++i)
- zeros += "0";
- s = zeros + s;
- }
- }
-
- return newBVConstExpr(s, 2);
-}
-
-Expr ValidityChecker::newConcatExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only concat a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only concat a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_CONCAT, t1, t2);
-}
-
-Expr ValidityChecker::newConcatExpr(const std::vector<Expr>& kids) {
- const vector<CVC4::Expr>& v =
- *reinterpret_cast<const vector<CVC4::Expr>*>(&kids);
- return d_em->mkExpr(CVC4::kind::BITVECTOR_CONCAT, v);
-}
-
-Expr ValidityChecker::newBVExtractExpr(const Expr& e, int hi, int low) {
- CompatCheckArgument(e.getType().isBitVector(), e,
- "can only bvextract from a bitvector, not a `%s'",
- e.getType().toString().c_str());
- CompatCheckArgument(hi >= low, hi,
- "extraction [%d:%d] is bad; possibly inverted?", hi, low);
- CompatCheckArgument(low >= 0, low,
- "extraction [%d:%d] is bad (negative)", hi, low);
- CompatCheckArgument(CVC4::BitVectorType(e.getType()).getSize() > unsigned(hi),
- hi,
- "bitvector is of size %u, extraction [%d:%d] is off-the-end",
- CVC4::BitVectorType(e.getType()).getSize(), hi, low);
- return d_em->mkExpr(CVC4::kind::BITVECTOR_EXTRACT,
- d_em->mkConst(CVC4::BitVectorExtract(hi, low)), e);
-}
-
-Expr ValidityChecker::newBVNegExpr(const Expr& t1) {
- // CVC3's BVNEG => SMT-LIBv2 bvnot
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvneg a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_NOT, t1);
-}
-
-Expr ValidityChecker::newBVAndExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvand a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvand a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_AND, t1, t2);
-}
-
-Expr ValidityChecker::newBVAndExpr(const std::vector<Expr>& kids) {
- // BITVECTOR_AND is not N-ary in CVC4
- CompatCheckArgument(kids.size() > 1, kids,
- "BITVECTOR_AND must have at least 2 children");
- std::vector<Expr>::const_reverse_iterator i = kids.rbegin();
- Expr e = *i++;
- while(i != kids.rend()) {
- e = d_em->mkExpr(CVC4::kind::BITVECTOR_AND, *i++, e);
- }
- return e;
-}
-
-Expr ValidityChecker::newBVOrExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvor a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvor a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_OR, t1, t2);
-}
-
-Expr ValidityChecker::newBVOrExpr(const std::vector<Expr>& kids) {
- // BITVECTOR_OR is not N-ary in CVC4
- CompatCheckArgument(kids.size() > 1, kids,
- "BITVECTOR_OR must have at least 2 children");
- std::vector<Expr>::const_reverse_iterator i = kids.rbegin();
- Expr e = *i++;
- while(i != kids.rend()) {
- e = d_em->mkExpr(CVC4::kind::BITVECTOR_OR, *i++, e);
- }
- return e;
-}
-
-Expr ValidityChecker::newBVXorExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvxor a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvxor a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_XOR, t1, t2);
-}
-
-Expr ValidityChecker::newBVXorExpr(const std::vector<Expr>& kids) {
- // BITVECTOR_XOR is not N-ary in CVC4
- CompatCheckArgument(kids.size() > 1, kids,
- "BITVECTOR_XOR must have at least 2 children");
- std::vector<Expr>::const_reverse_iterator i = kids.rbegin();
- Expr e = *i++;
- while(i != kids.rend()) {
- e = d_em->mkExpr(CVC4::kind::BITVECTOR_XOR, *i++, e);
- }
- return e;
-}
-
-Expr ValidityChecker::newBVXnorExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvxnor a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvxnor a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_XNOR, t1, t2);
-}
-
-Expr ValidityChecker::newBVXnorExpr(const std::vector<Expr>& kids) {
- // BITVECTOR_XNOR is not N-ary in CVC4
- CompatCheckArgument(kids.size() > 1, kids,
- "BITVECTOR_XNOR must have at least 2 children");
- std::vector<Expr>::const_reverse_iterator i = kids.rbegin();
- Expr e = *i++;
- while(i != kids.rend()) {
- e = d_em->mkExpr(CVC4::kind::BITVECTOR_XNOR, *i++, e);
- }
- return e;
-}
-
-Expr ValidityChecker::newBVNandExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvnand a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvnand a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_NAND, t1, t2);
-}
-
-Expr ValidityChecker::newBVNorExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1,
- "can only bvnor a bitvector, not a `%s'",
- t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2,
- "can only bvnor a bitvector, not a `%s'",
- t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_NOR, t1, t2);
-}
-
-Expr ValidityChecker::newBVCompExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvcomp a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvcomp a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_COMP, t1, t2);
-}
-
-Expr ValidityChecker::newBVLTExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvlt a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvlt a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_ULT, t1, t2);
-}
-
-Expr ValidityChecker::newBVLEExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvle a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvle a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_ULE, t1, t2);
-}
-
-Expr ValidityChecker::newBVSLTExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvslt a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvslt a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SLT, t1, t2);
-}
-
-Expr ValidityChecker::newBVSLEExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvsle a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvsle a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SLE, t1, t2);
-}
-
-Expr ValidityChecker::newSXExpr(const Expr& t1, int len) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only sx a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(len >= 0, len, "must sx by a positive integer");
- CompatCheckArgument(unsigned(len) >= CVC4::BitVectorType(t1.getType()).getSize(), len, "cannot sx by something smaller than the bitvector (%d < %u)", len, CVC4::BitVectorType(t1.getType()).getSize());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SIGN_EXTEND,
- d_em->mkConst(CVC4::BitVectorSignExtend(len)), t1);
-}
-
-Expr ValidityChecker::newBVUminusExpr(const Expr& t1) {
- // CVC3's BVUMINUS => SMT-LIBv2 bvneg
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvuminus a bitvector, not a `%s'", t1.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_NEG, t1);
-}
-
-Expr ValidityChecker::newBVSubExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvsub a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvsub by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SUB, t1, t2);
-}
-
-// Copied from CVC3's bitvector theory: makes bitvector expression "e"
-// into "len" bits, by zero-padding, or extracting least-significant bits.
-Expr ValidityChecker::bvpad(int len, const Expr& e) {
- CompatCheckArgument(len >= 0, len,
- "padding length must be a non-negative integer, not %d", len);
- CompatCheckArgument(e.getType().isBitVector(), e,
- "input to bitvector operation must be a bitvector");
-
- unsigned size = CVC4::BitVectorType(e.getType()).getSize();
- Expr res;
- if(size == len) {
- res = e;
- } else if(len < size) {
- res = d_em->mkExpr(d_em->mkConst(CVC4::BitVectorExtract(len - 1, 0)), e);
- } else {
- // size < len
- Expr zero = d_em->mkConst(CVC4::BitVector(len - size, 0u));
- res = d_em->mkExpr(CVC4::kind::BITVECTOR_CONCAT, zero, e);
- }
- return res;
-}
-
-Expr ValidityChecker::newBVPlusExpr(int numbits, const std::vector<Expr>& kids) {
- // BITVECTOR_PLUS is not N-ary in CVC4
- CompatCheckArgument(kids.size() > 1, kids, "BITVECTOR_PLUS must have at least 2 children");
- std::vector<Expr>::const_reverse_iterator i = kids.rbegin();
- Expr e = *i++;
- while(i != kids.rend()) {
- e = d_em->mkExpr(CVC4::kind::BITVECTOR_PLUS, bvpad(numbits, *i++), e);
- }
- unsigned size = CVC4::BitVectorType(e.getType()).getSize();
- CompatCheckArgument(unsigned(numbits) == size, numbits,
- "argument must match computed size of bitvector sum: "
- "passed size == %u, computed size == %u", numbits, size);
- return e;
-}
-
-Expr ValidityChecker::newBVPlusExpr(int numbits, const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvplus a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvplus a bitvector, not a `%s'", t2.getType().toString().c_str());
- Expr e = d_em->mkExpr(CVC4::kind::BITVECTOR_PLUS, bvpad(numbits, t1), bvpad(numbits, t2));
- unsigned size = CVC4::BitVectorType(e.getType()).getSize();
- CompatCheckArgument(unsigned(numbits) == size, numbits,
- "argument must match computed size of bitvector sum: "
- "passed size == %u, computed size == %u", numbits, size);
- return e;
-}
-
-Expr ValidityChecker::newBVMultExpr(int numbits, const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvmult a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvmult by a bitvector, not a `%s'", t2.getType().toString().c_str());
- Expr e = d_em->mkExpr(CVC4::kind::BITVECTOR_MULT, bvpad(numbits, t1), bvpad(numbits, t2));
- unsigned size = CVC4::BitVectorType(e.getType()).getSize();
- CompatCheckArgument(unsigned(numbits) == size, numbits,
- "argument must match computed size of bitvector product: "
- "passed size == %u, computed size == %u", numbits, size);
- return e;
-}
-
-Expr ValidityChecker::newBVUDivExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvudiv a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvudiv by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_UDIV, t1, t2);
-}
-
-Expr ValidityChecker::newBVURemExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvurem a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvurem by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_UREM, t1, t2);
-}
-
-Expr ValidityChecker::newBVSDivExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvsdiv a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvsdiv by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SDIV, t1, t2);
-}
-
-Expr ValidityChecker::newBVSRemExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvsrem a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvsrem by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SREM, t1, t2);
-}
-
-Expr ValidityChecker::newBVSModExpr(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only bvsmod a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only bvsmod by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SMOD, t1, t2);
-}
-
-Expr ValidityChecker::newFixedLeftShiftExpr(const Expr& t1, int r) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only left-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(r >= 0, r, "left shift amount must be >= 0 (you passed %d)", r);
- // Defined in:
- // http://www.cs.nyu.edu/acsys/cvc3/doc/user_doc.html#user_doc_pres_lang_expr_bit
- return d_em->mkExpr(CVC4::kind::BITVECTOR_CONCAT, t1, d_em->mkConst(CVC4::BitVector(r)));
-}
-
-Expr ValidityChecker::newFixedConstWidthLeftShiftExpr(const Expr& t1, int r) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only right-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(r >= 0, r, "const-width left shift amount must be >= 0 (you passed %d)", r);
- // just turn it into a BVSHL
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SHL, t1, d_em->mkConst(CVC4::BitVector(CVC4::BitVectorType(t1.getType()).getSize(), unsigned(r))));
-}
-
-Expr ValidityChecker::newFixedRightShiftExpr(const Expr& t1, int r) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only right-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(r >= 0, r, "right shift amount must be >= 0 (you passed %d)", r);
- // Defined in:
- // http://www.cs.nyu.edu/acsys/cvc3/doc/user_doc.html#user_doc_pres_lang_expr_bit
- // Should be equivalent to a BVLSHR; just turn it into that.
- return d_em->mkExpr(CVC4::kind::BITVECTOR_LSHR, t1, d_em->mkConst(CVC4::BitVector(CVC4::BitVectorType(t1.getType()).getSize(), unsigned(r))));
-}
-
-Expr ValidityChecker::newBVSHL(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only right-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only right-shift by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_SHL, t1, t2);
-}
-
-Expr ValidityChecker::newBVLSHR(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only right-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only right-shift by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_LSHR, t1, t2);
-}
-
-Expr ValidityChecker::newBVASHR(const Expr& t1, const Expr& t2) {
- CompatCheckArgument(t1.getType().isBitVector(), t1, "can only right-shift a bitvector, not a `%s'", t1.getType().toString().c_str());
- CompatCheckArgument(t2.getType().isBitVector(), t2, "can only right-shift by a bitvector, not a `%s'", t2.getType().toString().c_str());
- return d_em->mkExpr(CVC4::kind::BITVECTOR_ASHR, t1, t2);
-}
-
-Rational ValidityChecker::computeBVConst(const Expr& e) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::tupleExpr(const std::vector<Expr>& exprs) {
- std::vector< Type > types;
- std::vector<CVC4::Expr> v;
- for( unsigned i=0; i<exprs.size(); i++ ){
- types.push_back( exprs[i].getType() );
- v.push_back( exprs[i] );
- }
- Type t = tupleType( types );
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- v.insert( v.begin(), dt[0].getConstructor() );
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, v);
-}
-
-Expr ValidityChecker::tupleSelectExpr(const Expr& tuple, int index) {
- CompatCheckArgument(index >= 0 && index < ((CVC4::DatatypeType)tuple.getType()).getTupleLength(),
- "invalid index in tuple select");
- Type t = tuple.getType();
- const CVC4::Datatype& dt = ((CVC4::DatatypeType)t).getDatatype();
- return d_em->mkExpr(CVC4::kind::APPLY_SELECTOR_TOTAL, dt[0].getSelectorInternal( t, index ), tuple);
-}
-
-Expr ValidityChecker::tupleUpdateExpr(const Expr& tuple, int index,
- const Expr& newValue) {
- CompatCheckArgument(index >= 0 && index < tuple.getNumChildren(),
- "invalid index in tuple update");
- return d_em->mkExpr(d_em->mkConst(CVC4::TupleUpdate(index)), tuple, newValue);
-}
-
-Expr ValidityChecker::datatypeConsExpr(const std::string& constructor, const std::vector<Expr>& args) {
- ConstructorMap::const_iterator i = d_constructors.find(constructor);
- CompatCheckArgument(i != d_constructors.end(), constructor, "no such constructor");
- const CVC4::Datatype& dt = *(*i).second;
- const CVC4::DatatypeConstructor& ctor = dt[constructor];
- CompatCheckArgument(ctor.getNumArgs() == args.size(), args, "arity mismatch in constructor application");
- return d_em->mkExpr(CVC4::kind::APPLY_CONSTRUCTOR, ctor.getConstructor(), vector<CVC4::Expr>(args.begin(), args.end()));
-}
-
-Expr ValidityChecker::datatypeSelExpr(const std::string& selector, const Expr& arg) {
- SelectorMap::const_iterator i = d_selectors.find(selector);
- CompatCheckArgument(i != d_selectors.end(), selector, "no such selector");
- const CVC4::Datatype& dt = *(*i).second.first;
- string constructor = (*i).second.second;
- const CVC4::DatatypeConstructor& ctor = dt[constructor];
- unsigned sindex = CVC4::Datatype::indexOf( ctor.getSelector(selector) );
- return d_em->mkExpr(CVC4::kind::APPLY_SELECTOR, ctor.getSelectorInternal( arg.getType(), sindex ), arg);
-}
-
-Expr ValidityChecker::datatypeTestExpr(const std::string& constructor, const Expr& arg) {
- ConstructorMap::const_iterator i = d_constructors.find(constructor);
- CompatCheckArgument(i != d_constructors.end(), constructor, "no such constructor");
- const CVC4::Datatype& dt = *(*i).second;
- const CVC4::DatatypeConstructor& ctor = dt[constructor];
- return d_em->mkExpr(CVC4::kind::APPLY_TESTER, ctor.getTester(), arg);
-}
-
-Expr ValidityChecker::boundVarExpr(const std::string& name, const std::string& uid,
- const Type& type) {
- return d_em->mkBoundVar(name, type);
-}
-
-Expr ValidityChecker::forallExpr(const std::vector<Expr>& vars, const Expr& body) {
- Expr boundVarList = d_em->mkExpr(CVC4::kind::BOUND_VAR_LIST, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&vars));
- return d_em->mkExpr(CVC4::kind::FORALL, boundVarList, body);
-}
-
-Expr ValidityChecker::forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const Expr& trigger) {
- // trigger
- Expr boundVarList = d_em->mkExpr(CVC4::kind::BOUND_VAR_LIST, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&vars));
- Expr triggerList = d_em->mkExpr(CVC4::kind::INST_PATTERN_LIST, d_em->mkExpr(CVC4::kind::INST_PATTERN, trigger));
- return d_em->mkExpr(CVC4::kind::FORALL, boundVarList, body, triggerList);
-}
-
-Expr ValidityChecker::forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const std::vector<Expr>& triggers) {
- // set of triggers
- Expr boundVarList = d_em->mkExpr(CVC4::kind::BOUND_VAR_LIST, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&vars));
- std::vector<CVC4::Expr> pats;
- for(std::vector<Expr>::const_iterator i = triggers.begin(); i != triggers.end(); ++i) {
- pats.push_back(d_em->mkExpr(CVC4::kind::INST_PATTERN, *i));
- }
- Expr triggerList = d_em->mkExpr(CVC4::kind::INST_PATTERN_LIST, pats);
- return d_em->mkExpr(CVC4::kind::FORALL, boundVarList, body, triggerList);
-}
-
-Expr ValidityChecker::forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const std::vector<std::vector<Expr> >& triggers) {
- // set of multi-triggers
- Expr boundVarList = d_em->mkExpr(CVC4::kind::BOUND_VAR_LIST, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&vars));
- std::vector<CVC4::Expr> pats;
- for(std::vector< std::vector<Expr> >::const_iterator i = triggers.begin(); i != triggers.end(); ++i) {
- pats.push_back(d_em->mkExpr(CVC4::kind::INST_PATTERN, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&*i)));
- }
- Expr triggerList = d_em->mkExpr(CVC4::kind::INST_PATTERN_LIST, pats);
- return d_em->mkExpr(CVC4::kind::FORALL, boundVarList, body, triggerList);
-}
-
-void ValidityChecker::setTriggers(const Expr& e, const std::vector<std::vector<Expr> > & triggers) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::setTriggers(const Expr& e, const std::vector<Expr>& triggers) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::setTrigger(const Expr& e, const Expr& trigger) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::setMultiTrigger(const Expr& e, const std::vector<Expr>& multiTrigger) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::existsExpr(const std::vector<Expr>& vars, const Expr& body) {
- Expr boundVarList = d_em->mkExpr(CVC4::kind::BOUND_VAR_LIST, *reinterpret_cast<const std::vector<CVC4::Expr>*>(&vars));
- return d_em->mkExpr(CVC4::kind::EXISTS, boundVarList, body);
-}
-
-Op ValidityChecker::lambdaExpr(const std::vector<Expr>& vars, const Expr& body) {
- Unimplemented("Lambda expressions not supported by CVC4 yet (sorry!)");
-}
-
-Op ValidityChecker::transClosure(const Op& op) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::simulateExpr(const Expr& f, const Expr& s0,
- const std::vector<Expr>& inputs,
- const Expr& n) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::setResourceLimit(unsigned limit) {
- // Set a resource limit for CVC4, cumulative (rather than
- // per-query), starting from now.
- d_smt->setResourceLimit(limit, true);
-}
-
-void ValidityChecker::setTimeLimit(unsigned limit) {
- // Set a time limit for CVC4, cumulative (rather than per-query),
- // starting from now. Note that CVC3 uses tenths of a second,
- // while CVC4 uses milliseconds.
- d_smt->setTimeLimit(limit * 100, true);
-}
-
-void ValidityChecker::assertFormula(const Expr& e) {
- d_smt->assertFormula(e);
-}
-
-void ValidityChecker::registerAtom(const Expr& e) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::getImpliedLiteral() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::simplify(const Expr& e) {
- return d_smt->simplify(e);
-}
-
-static QueryResult cvc4resultToCvc3result(CVC4::Result r) {
- switch(r.isSat()) {
- case CVC4::Result::SAT:
- return SATISFIABLE;
- case CVC4::Result::UNSAT:
- return UNSATISFIABLE;
- default:
- ;
- }
-
- switch(r.isValid()) {
- case CVC4::Result::VALID:
- return VALID;
- case CVC4::Result::INVALID:
- return INVALID;
- default:
- return UNKNOWN;
- }
-}
-
-QueryResult ValidityChecker::query(const Expr& e) {
- return cvc4resultToCvc3result(d_smt->query(e));
-}
-
-QueryResult ValidityChecker::checkUnsat(const Expr& e) {
- return cvc4resultToCvc3result(d_smt->checkSat(e));
-}
-
-QueryResult ValidityChecker::checkContinue() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-QueryResult ValidityChecker::restart(const Expr& e) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::returnFromCheck() {
- // CVC4 has this behavior by default
-}
-
-void ValidityChecker::getUserAssumptions(std::vector<Expr>& assumptions) {
- CompatCheckArgument(assumptions.empty(), assumptions, "assumptions arg must be empty");
- vector<CVC4::Expr> v = d_smt->getAssertions();
- assumptions.swap(*reinterpret_cast<vector<Expr>*>(&v));
-}
-
-void ValidityChecker::getInternalAssumptions(std::vector<Expr>& assumptions) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::getAssumptions(std::vector<Expr>& assumptions) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::getAssumptionsUsed(std::vector<Expr>& assumptions) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::getProofQuery() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::getCounterExample(std::vector<Expr>& assumptions,
- bool inOrder) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::getConcreteModel(ExprMap<Expr>& m) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-QueryResult ValidityChecker::tryModelGeneration() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-FormulaValue ValidityChecker::value(const Expr& e) {
- CompatCheckArgument(e.getType() == d_em->booleanType(), e, "argument must be a formula");
- try {
- return d_smt->getValue(e).getConst<bool>() ? TRUE_VAL : FALSE_VAL;
- } catch(CVC4::Exception& e) {
- return UNKNOWN_VAL;
- }
-}
-
-Expr ValidityChecker::getValue(const Expr& e) {
- try {
- return d_smt->getValue(e);
- } catch(CVC4::ModalException& e) {
- // by contract, we return null expr
- return Expr();
- }
-}
-
-bool ValidityChecker::inconsistent(std::vector<Expr>& assumptions) {
- CompatCheckArgument(assumptions.empty(), assumptions, "assumptions vector should be empty on entry");
- if(d_smt->checkSat() == CVC4::Result::UNSAT) {
- // supposed to be a minimal set, but CVC4 doesn't support that
- d_smt->getAssertions().swap(*reinterpret_cast<std::vector<CVC4::Expr>*>(&assumptions));
- return true;
- }
- return false;
-}
-
-bool ValidityChecker::inconsistent() {
- return d_smt->checkSat() == CVC4::Result::UNSAT;
-}
-
-bool ValidityChecker::incomplete() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-bool ValidityChecker::incomplete(std::vector<std::string>& reasons) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Proof ValidityChecker::getProof() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::getTCC() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-void ValidityChecker::getAssumptionsTCC(std::vector<Expr>& assumptions) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Proof ValidityChecker::getProofTCC() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Expr ValidityChecker::getClosure() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-Proof ValidityChecker::getProofClosure() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-int ValidityChecker::stackLevel() {
- return d_stackLevel;
-}
-
-void ValidityChecker::push() {
- ++d_stackLevel;
- d_smt->push();
-}
-
-void ValidityChecker::pop() {
- d_smt->pop();
- --d_stackLevel;
-}
-
-void ValidityChecker::popto(int stackLevel) {
- CompatCheckArgument(stackLevel >= 0, stackLevel,
- "Cannot pop to a negative stack level %d", stackLevel);
- CompatCheckArgument(unsigned(stackLevel) <= d_stackLevel, stackLevel,
- "Cannot pop to a stack level higher than the current one! "
- "At stack level %u, user requested stack level %d",
- d_stackLevel, stackLevel);
- while(unsigned(stackLevel) < d_stackLevel) {
- pop();
- }
-}
-
-int ValidityChecker::scopeLevel() {
- return d_parserContext->scopeLevel();
-}
-
-void ValidityChecker::pushScope() {
- d_parserContext->pushScope();
-}
-
-void ValidityChecker::popScope() {
- d_parserContext->popScope();
-}
-
-void ValidityChecker::poptoScope(int scopeLevel) {
- CompatCheckArgument(scopeLevel >= 0, scopeLevel,
- "Cannot pop to a negative scope level %d", scopeLevel);
- CompatCheckArgument(unsigned(scopeLevel) <= d_parserContext->scopeLevel(),
- scopeLevel,
- "Cannot pop to a scope level higher than the current one! "
- "At scope level %u, user requested scope level %d",
- d_parserContext->scopeLevel(), scopeLevel);
- while(unsigned(scopeLevel) < d_parserContext->scopeLevel()) {
- popScope();
- }
-}
-
-Context* ValidityChecker::getCurrentContext() {
- Unimplemented("Contexts are not part of the public interface of CVC4");
-}
-
-void ValidityChecker::reset() {
- // reset everything, forget everything
- d_smt->reset();
- delete d_parserContext;
- d_parserContext = CVC4::parser::ParserBuilder(d_solver.get(), "<internal>")
- .withInputLanguage(CVC4::language::input::LANG_CVC4)
- .withStringInput("")
- .build();
- s_typeToExpr.clear();
- s_exprToType.clear();
-}
-
-void ValidityChecker::logAnnotation(const Expr& annot) {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
-}
-
-static void doCommands(CVC4::parser::Parser* parser, CVC4::SmtEngine* smt, CVC4::Options& opts) {
- while(CVC4::Command* cmd = parser->nextCommand()) {
- if(opts.getVerbosity() >= 0) {
- cmd->invoke(smt, *opts.getOut());
- } else {
- cmd->invoke(smt);
- }
- delete cmd;
- }
-}
-
-void ValidityChecker::loadFile(const std::string& fileName,
- InputLanguage lang,
- bool interactive,
- bool calledFromParser) {
- CVC4::Options opts;
- opts.copyValues(d_em->getOptions());
- stringstream langss;
- langss << lang;
- d_smt->setOption("input-language", CVC4::SExpr(langss.str()));
- d_smt->setOption("interactive-mode", CVC4::SExpr(interactive ? true : false));
- CVC4::parser::ParserBuilder parserBuilder(d_solver.get(), fileName, opts);
- CVC4::parser::Parser* p = parserBuilder.build();
- p->useDeclarationsFrom(d_parserContext);
- doCommands(p, d_smt, opts);
- delete p;
-}
-
-void ValidityChecker::loadFile(std::istream& is,
- InputLanguage lang,
- bool interactive) {
- CVC4::Options opts;
- opts.copyValues(d_em->getOptions());
-
- stringstream langss;
- langss << lang;
- d_smt->setOption("input-language", CVC4::SExpr(langss.str()));
- d_smt->setOption("interactive-mode", CVC4::SExpr(interactive ? true : false));
- CVC4::parser::ParserBuilder parserBuilder(d_solver.get(), "[stream]", opts);
- CVC4::parser::Parser* p = parserBuilder.withStreamInput(is).build();
- d_parserContext = p;
- p->useDeclarationsFrom(d_parserContext);
- doCommands(p, d_smt, opts);
- delete p;
-}
-
-Statistics ValidityChecker::getStatistics() {
- return d_smt->getStatistics();
-}
-
-void ValidityChecker::printStatistics() {
- d_smt->getStatistics().flushInformation(Message.getStream());
-}
-
-int compare(const Expr& e1, const Expr& e2) {
- // Quick equality check (operator== is implemented independently
- // and more efficiently)
- if(e1 == e2) return 0;
-
- if(e1.isNull()) return -1;
- if(e2.isNull()) return 1;
-
- // Both are non-Null. Check for constant
- bool e1c = e1.isConstant();
- if (e1c != e2.isConstant()) {
- return e1c ? -1 : 1;
- }
-
- // Compare the indices
- return (e1.getIndex() < e2.getIndex())? -1 : 1;
-}
-
-}/* CVC3 namespace */
+++ /dev/null
-/********************* */
-/*! \file cvc3_compat.h
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters, Tim King, Aina Niemetz
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief CVC3 compatibility layer for CVC4
- **
- ** CVC3 compatibility layer for CVC4. This version was derived from
- ** the following CVS revisions of the following files in CVC3. If
- ** those files have a later revision, then this file might be out of
- ** date. Note that this compatibility layer is not safe for use in
- ** multithreaded contexts where multiple threads are accessing this
- ** compatibility layer functionality.
- **
- ** src/include/vc.h 1.36
- ** src/include/expr.h 1.39
- ** src/include/command_line_flags.h 1.3
- ** src/include/queryresult.h 1.2
- ** src/include/formula_value.h 1.1
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__CVC3_COMPAT_H
-#define __CVC4__CVC3_COMPAT_H
-
-// keep the CVC3 include guard also
-#if defined(_cvc3__include__vc_h_) || \
- defined(_cvc3__expr_h_) || \
- defined(_cvc3__command_line_flags_h_) || \
- defined(_cvc3__include__queryresult_h_) || \
- defined(_cvc3__include__formula_value_h_)
-
-#error "A CVC3 header file was included before CVC4's cvc3_compat.h header. Please include cvc3_compat.h rather than any CVC3 headers."
-
-#else
-
-// define these so the files are skipped if the user #includes them too
-#define _cvc3__expr_h_
-#define _cvc3__include__vc_h_
-#define _cvc3__command_line_flags_h_
-#define _cvc3__include__queryresult_h_
-#define _cvc3__include__formula_value_h_
-
-#include <stdlib.h>
-
-#include <map>
-#include <string>
-#include <unordered_map>
-#include <utility>
-
-#include "base/exception.h"
-#include "expr/expr.h"
-#include "expr/expr_manager.h"
-#include "expr/type.h"
-#include "parser/parser.h"
-#include "smt/smt_engine.h"
-#include "util/integer.h"
-#include "util/rational.h"
-
-//class CInterface;
-
-namespace CVC3 {
-
-const CVC4::Kind EQ = CVC4::kind::EQUAL;
-const CVC4::Kind LE = CVC4::kind::LEQ;
-const CVC4::Kind GE = CVC4::kind::GEQ;
-const CVC4::Kind DIVIDE = CVC4::kind::DIVISION;
-const CVC4::Kind BVLT = CVC4::kind::BITVECTOR_ULT;
-const CVC4::Kind BVLE = CVC4::kind::BITVECTOR_ULE;
-const CVC4::Kind BVGT = CVC4::kind::BITVECTOR_UGT;
-const CVC4::Kind BVGE = CVC4::kind::BITVECTOR_UGE;
-const CVC4::Kind BVPLUS = CVC4::kind::BITVECTOR_PLUS;
-const CVC4::Kind BVSUB = CVC4::kind::BITVECTOR_SUB;
-const CVC4::Kind BVCONST = CVC4::kind::CONST_BITVECTOR;
-const CVC4::Kind EXTRACT = CVC4::kind::BITVECTOR_EXTRACT;
-const CVC4::Kind CONCAT = CVC4::kind::BITVECTOR_CONCAT;
-
-std::string int2string(int n) CVC4_PUBLIC;
-
-//! Different types of command line flags
-typedef enum CVC4_PUBLIC {
- CLFLAG_NULL,
- CLFLAG_BOOL,
- CLFLAG_INT,
- CLFLAG_STRING,
- CLFLAG_STRVEC //!< Vector of pair<string, bool>
-} CLFlagType;
-
-std::ostream& operator<<(std::ostream& out, CLFlagType clft) CVC4_PUBLIC;
-
-/*!
- Class CLFlag (for Command Line Flag)
-
- Author: Sergey Berezin
-
- Date: Fri May 30 14:10:48 2003
-
- This class implements a data structure to hold a value of a single
- command line flag.
-*/
-class CVC4_PUBLIC CLFlag {
- //! Type of the argument
- CLFlagType d_tp;
- //! The argument
- union {
- bool b;
- int i;
- std::string* s;
- std::vector<std::pair<std::string,bool> >* sv;
- } d_data;
-
-public:
-
- //! Constructor for a boolean flag
- CLFlag(bool b, const std::string& help, bool display = true);
- //! Constructor for an integer flag
- CLFlag(int i, const std::string& help, bool display = true);
- //! Constructor for a string flag
- CLFlag(const std::string& s, const std::string& help, bool display = true);
- //! Constructor for a string flag from char*
- CLFlag(const char* s, const std::string& help, bool display = true);
- //! Constructor for a vector flag
- CLFlag(const std::vector<std::pair<std::string,bool> >& sv,
- const std::string& help, bool display = true);
- //! Default constructor
- CLFlag();
- //! Copy constructor
- CLFlag(const CLFlag& f);
- //! Destructor
- ~CLFlag();
-
- //! Assignment from another flag
- CLFlag& operator=(const CLFlag& f);
- //! Assignment of a boolean value
- /*! The flag must already have the right type */
- CLFlag& operator=(bool b);
- //! Assignment of an integer value
- /*! The flag must already have the right type */
- CLFlag& operator=(int i);
- //! Assignment of a string value
- /*! The flag must already have a string type. */
- CLFlag& operator=(const std::string& s);
- //! Assignment of an string value from char*
- /*! The flag must already have a string type. */
- CLFlag& operator=(const char* s);
- //! Assignment of a string value with a boolean tag to a vector flag
- /*! The flag must already have a vector type. The pair of
- <string,bool> will be appended to the vector. */
- CLFlag& operator=(const std::pair<std::string,bool>& p);
- //! Assignment of a vector value
- /*! The flag must already have a vector type. */
- CLFlag& operator=(const std::vector<std::pair<std::string,bool> >& sv);
-
- // Accessor methods
- //! Return the type of the flag
- CLFlagType getType() const;
- /*! @brief Return true if the flag was modified from the default
- value (e.g. set on the command line) */
- bool modified() const;
- //! Return true if flag should be displayed in regular help
- bool display() const;
-
- // The value accessors return a reference. For the system-wide
- // flags, this reference will remain valid throughout the run of the
- // program, even if the flag's value changes. So, the reference can
- // be cached, and the value can be checked directly (which is more
- // efficient).
- const bool& getBool() const;
-
- const int& getInt() const;
-
- const std::string& getString() const;
-
- const std::vector<std::pair<std::string,bool> >& getStrVec() const;
-
- const std::string& getHelp() const;
-
-};/* class CLFlag */
-
-///////////////////////////////////////////////////////////////////////
-// Class CLFlag (for Command Line Flag)
-//
-// Author: Sergey Berezin
-// Date: Fri May 30 14:10:48 2003
-//
-// Database of command line flags.
-///////////////////////////////////////////////////////////////////////
-
-class CVC4_PUBLIC CLFlags {
- typedef std::map<std::string, CLFlag> FlagMap;
- FlagMap d_map;
-
-public:
- // Public methods
- // Add a new flag. The name must be a complete flag name.
- void addFlag(const std::string& name, const CLFlag& f);
- // Count how many flags match the name prefix
- size_t countFlags(const std::string& name) const;
- // Match the name prefix and add all the matching names to the vector
- size_t countFlags(const std::string& name,
- std::vector<std::string>& names) const;
- // Retrieve an existing flag. The 'name' must be a full name of an
- // existing flag.
- const CLFlag& getFlag(const std::string& name) const;
-
- const CLFlag& operator[](const std::string& name) const;
-
- // Setting the flag to a new value, but preserving the help string.
- // The 'name' prefix must uniquely resolve to an existing flag.
- void setFlag(const std::string& name, const CLFlag& f);
-
- // Variants of setFlag for all the types
- void setFlag(const std::string& name, bool b);
- void setFlag(const std::string& name, int i);
- void setFlag(const std::string& name, const std::string& s);
- void setFlag(const std::string& name, const char* s);
- void setFlag(const std::string& name, const std::pair<std::string, bool>& p);
- void setFlag(const std::string& name,
- const std::vector<std::pair<std::string, bool> >& sv);
-
-};/* class CLFlags */
-
-class CVC4_PUBLIC ExprManager;
-class CVC4_PUBLIC Context;
-class CVC4_PUBLIC Proof {};
-class CVC4_PUBLIC Theorem {};
-
-namespace api {
-class CVC4_PUBLIC Solver;
-}
-using CVC4::InputLanguage;
-using CVC4::Integer;
-using CVC4::Rational;
-using CVC4::Exception;
-using CVC4::Cardinality;
-using namespace CVC4::kind;
-
-typedef size_t ExprIndex;
-typedef CVC4::TypeCheckingException TypecheckException;
-typedef size_t Unsigned;
-
-static const int READ = ::CVC4::kind::SELECT;
-static const int WRITE = ::CVC4::kind::STORE;
-
-// CVC4 has a more sophisticated Cardinality type;
-// but we can support comparison against CVC3's more
-// coarse-grained Cardinality.
-enum CVC4_PUBLIC CVC3CardinalityKind {
- CARD_FINITE,
- CARD_INFINITE,
- CARD_UNKNOWN
-};/* enum CVC3CardinalityKind */
-
-std::ostream& operator<<(std::ostream& out, CVC3CardinalityKind c) CVC4_PUBLIC;
-
-bool operator==(const Cardinality& c, CVC3CardinalityKind d) CVC4_PUBLIC;
-bool operator==(CVC3CardinalityKind d, const Cardinality& c) CVC4_PUBLIC;
-bool operator!=(const Cardinality& c, CVC3CardinalityKind d) CVC4_PUBLIC;
-bool operator!=(CVC3CardinalityKind d, const Cardinality& c) CVC4_PUBLIC;
-
-class CVC4_PUBLIC Expr;
-
-template <class T>
-class CVC4_PUBLIC ExprMap : public std::map<Expr, T> {
-};/* class ExprMap<T> */
-
-template <class T>
-class CVC4_PUBLIC ExprHashMap : public std::unordered_map<Expr, T, CVC4::ExprHashFunction> {
-public:
- void insert(Expr a, Expr b);
-};/* class ExprHashMap<T> */
-
-class CVC4_PUBLIC Type : public CVC4::Type {
-public:
- Type();
- Type(const CVC4::Type& type);
- Type(const Type& type);
- Expr getExpr() const;
-
- // Reasoning about children
- int arity() const;
- Type operator[](int i) const;
-
- // Core testers
- bool isBool() const;
- bool isSubtype() const;
- //! Return cardinality of type
- Cardinality card() const;
- //! Return nth (starting with 0) element in a finite type
- /*! Returns NULL Expr if unable to compute nth element
- */
- Expr enumerateFinite(Unsigned n) const;
- //! Return size of a finite type; returns 0 if size cannot be determined
- Unsigned sizeFinite() const;
-
- // Core constructors
- static Type typeBool(ExprManager* em);
- static Type funType(const std::vector<Type>& typeDom, const Type& typeRan);
- Type funType(const Type& typeRan) const;
-
-};/* class CVC3::Type */
-
-class CVC4_PUBLIC Expr;
-typedef Expr Op;
-
-/**
- * Expr class for CVC3 compatibility layer.
- *
- * This class is identical to (and convertible to/from) a CVC4 Expr,
- * except that a few additional functions are supported to provide
- * naming compatibility with CVC3.
- */
-class CVC4_PUBLIC Expr : public CVC4::Expr {
-public:
- typedef CVC4::Expr::const_iterator iterator;
-
- Expr();
- Expr(const Expr& e);
- Expr(const CVC4::Expr& e);
- Expr(ExprManager* em, CVC4::Kind k);
-
- // Compound expression constructors
- Expr eqExpr(const Expr& right) const;
- Expr notExpr() const;
- Expr negate() const; // avoid double-negatives
- Expr andExpr(const Expr& right) const;
- Expr orExpr(const Expr& right) const;
- Expr iteExpr(const Expr& thenpart, const Expr& elsepart) const;
- Expr iffExpr(const Expr& right) const;
- Expr impExpr(const Expr& right) const;
- Expr xorExpr(const Expr& right) const;
-
- Expr substExpr(const std::vector<Expr>& oldTerms,
- const std::vector<Expr>& newTerms) const;
- Expr substExpr(const ExprHashMap<Expr>& oldToNew) const;
-
- Expr operator!() const;
- Expr operator&&(const Expr& right) const;
- Expr operator||(const Expr& right) const;
-
- static size_t hash(const Expr& e);
-
- size_t hash() const;
-
- // Core expression testers
-
- bool isFalse() const;
- bool isTrue() const;
- bool isBoolConst() const;
- bool isVar() const;
- bool isBoundVar() const;
- bool isString() const;
- bool isSymbol() const;
- bool isTerm() const;
- bool isType() const;
- bool isClosure() const;
- bool isQuantifier() const;
- bool isForall() const;
- bool isExists() const;
- bool isLambda() const;
- bool isApply() const;
- bool isTheorem() const;
- bool isConstant() const;
- bool isRawList() const;
-
- bool isAtomic() const;
- bool isAtomicFormula() const;
- bool isAbsAtomicFormula() const;
- bool isLiteral() const;
- bool isAbsLiteral() const;
- bool isBoolConnective() const;
- bool isPropLiteral() const;
- bool isPropAtom() const;
-
- std::string getName() const;
- std::string getUid() const;
-
- std::string getString() const;
- std::vector<Expr> getVars() const;
- Expr getExistential() const;
- int getBoundIndex() const;
- Expr getBody() const;
- Theorem getTheorem() const;
-
- bool isEq() const;
- bool isNot() const;
- bool isAnd() const;
- bool isOr() const;
- bool isITE() const;
- bool isIff() const;
- bool isImpl() const;
- bool isXor() const;
-
- bool isRational() const;
- bool isSkolem() const;
-
- const Rational& getRational() const;
-
- Op mkOp() const;
- Op getOp() const;
- Expr getOpExpr() const;
- int getOpKind() const;
- Expr getExpr() const;// since people are used to doing getOp().getExpr() in CVC3
-
- //! Get the manual triggers of the closure Expr
- std::vector< std::vector<Expr> > getTriggers() const;
-
- // Get the expression manager. The expression must be non-null.
- ExprManager* getEM() const;
-
- // Return a ref to the vector of children.
- std::vector<Expr> getKids() const;
-
- // Get the index field
- ExprIndex getIndex() const;
-
- // Return the number of children. Note, that an application of a
- // user-defined function has the arity of that function (the number
- // of arguments), and the function name itself is part of the
- // operator.
- int arity() const;
-
- // Return the ith child. As with arity, it's also the ith argument
- // in function application.
- Expr operator[](int i) const;
-
- //! Remove leading NOT if any
- Expr unnegate() const;
-
- // Check if Expr is not Null
- bool isInitialized() const;
-
- //! Get the type. Recursively compute if necessary
- Type getType() const;
- //! Look up the current type. Do not recursively compute (i.e. may be NULL)
- Type lookupType() const;
-
- //! Pretty-print the expression
- void pprint() const;
- //! Pretty-print without dagifying
- void pprintnodag() const;
-
-};/* class CVC3::Expr */
-
-bool isArrayLiteral(const Expr&) CVC4_PUBLIC;
-
-class CVC4_PUBLIC ExprManager : public CVC4::ExprManager {
-public:
- std::string getKindName(int kind);
- //! Get the input language for printing
- InputLanguage getInputLang() const;
- //! Get the output language for printing
- InputLanguage getOutputLang() const;
-};/* class CVC3::ExprManager */
-
-typedef CVC4::Statistics Statistics;
-
-#define PRESENTATION_LANG ::CVC4::language::input::LANG_CVC4
-#define SMTLIB_LANG ::CVC4::language::input::LANG_SMTLIB_V1
-#define SMTLIB_V2_LANG ::CVC4::language::input::LANG_SMTLIB_V2
-#define TPTP_LANG ::CVC4::language::input::LANG_TPTP
-#define AST_LANG ::CVC4::language::input::LANG_AST
-
-/*****************************************************************************/
-/*
- * Type for result of queries. VALID and UNSATISFIABLE are treated as
- * equivalent, as are SATISFIABLE and INVALID.
- */
-/*****************************************************************************/
-typedef enum CVC4_PUBLIC QueryResult {
- SATISFIABLE = 0,
- INVALID = 0,
- VALID = 1,
- UNSATISFIABLE = 1,
- ABORT,
- UNKNOWN
-} QueryResult;
-
-std::ostream& operator<<(std::ostream& out, QueryResult qr);
-std::string QueryResultToString(QueryResult query_result);
-
-/*****************************************************************************/
-/*
- * Type for truth value of formulas.
- */
-/*****************************************************************************/
-typedef enum CVC4_PUBLIC FormulaValue {
- TRUE_VAL,
- FALSE_VAL,
- UNKNOWN_VAL
-} FormulaValue;
-
-std::ostream& operator<<(std::ostream& out, FormulaValue fv) CVC4_PUBLIC;
-
-/*****************************************************************************/
-/*!
- *\class ValidityChecker
- *\brief CVC3 API (compatibility layer for CVC4)
- *
- * All terms and formulas are represented as expressions using the Expr class.
- * The notion of a context is also important. A context is a "background" set
- * of formulas which are assumed to be true or false. Formulas can be added to
- * the context explicitly, using assertFormula, or they may be added as part of
- * processing a query command. At any time, the current set of formulas making
- * up the context can be retrieved using getAssumptions.
- */
-/*****************************************************************************/
-class CVC4_PUBLIC ValidityChecker {
-
- CLFlags* d_clflags;
- CVC4::Options d_options;
- std::unique_ptr<CVC4::api::Solver> d_solver;
- CVC3::ExprManager* d_em;
- std::map<CVC4::ExprManager*, CVC4::ExprManagerMapCollection> d_emmc;
- std::set<ValidityChecker*> d_reverseEmmc;
- CVC4::SmtEngine* d_smt;
- CVC4::parser::Parser* d_parserContext;
- std::vector<Expr> d_exprTypeMapRemove;
- unsigned d_stackLevel;
-
- friend class Type; // to reach in to d_exprTypeMapRemove
-
- typedef std::unordered_map<std::string, const CVC4::Datatype*> ConstructorMap;
- typedef std::unordered_map<std::string, std::pair<const CVC4::Datatype*, std::string>> SelectorMap;
-
- ConstructorMap d_constructors;
- SelectorMap d_selectors;
-
- ValidityChecker(const CLFlags& clflags);
-
- void setUpOptions(CVC4::Options& options, const CLFlags& clflags);
-
- // helper function for bitvectors
- Expr bvpad(int len, const Expr& e);
-
-public:
- //! Constructor
- ValidityChecker();
- //! Destructor
- virtual ~ValidityChecker();
-
- //! Return the set of command-line flags
- /*! The flags are returned by reference, and if modified, will have an
- immediate effect on the subsequent commands. Note that not all flags will
- have such an effect; some flags are used only at initialization time (like
- "sat"), and therefore, will not take effect if modified after
- ValidityChecker is created.
- */
- virtual CLFlags& getFlags() const;
- //! Force reprocessing of all flags
- virtual void reprocessFlags();
-
- /***************************************************************************/
- /*
- * Static methods
- */
- /***************************************************************************/
-
- //! Create the set of command line flags with default values;
- /*!
- \return the set of flags by value
- */
- static CLFlags createFlags();
- //! Create an instance of ValidityChecker
- /*!
- \param flags is the set of command line flags.
- */
- static ValidityChecker* create(const CLFlags& flags);
- //! Create an instance of ValidityChecker using default flag values.
- static ValidityChecker* create();
-
- /***************************************************************************/
- /*!
- *\name Type-related methods
- * Methods for creating and looking up types
- *\sa class Type
- *@{
- */
- /***************************************************************************/
-
- // Basic types
- virtual Type boolType(); //!< Create type BOOLEAN
-
- virtual Type realType(); //!< Create type REAL
-
- virtual Type intType(); //!< Create type INT
-
- //! Create a subrange type [l..r]
- /*! l and r can be Null; l=Null represents minus infinity, r=Null is
- * plus infinity.
- */
- virtual Type subrangeType(const Expr& l, const Expr& r);
-
- //! Creates a subtype defined by the given predicate
- /*!
- * \param pred is a predicate taking one argument of type T and returning
- * Boolean. The resulting type is a subtype of T whose elements x are those
- * satisfying the predicate pred(x).
- *
- * \param witness is an expression of type T for which pred holds (if a Null
- * expression is passed as a witness, cvc will try to prove \f$\exists x. pred(x))\f$.
- * if the witness check fails, a TypecheckException is thrown.
- */
- virtual Type subtypeType(const Expr& pred, const Expr& witness);
-
- // Tuple types
- //! 2-element tuple
- virtual Type tupleType(const Type& type0, const Type& type1);
-
- //! 3-element tuple
- virtual Type tupleType(const Type& type0, const Type& type1,
- const Type& type2);
- //! n-element tuple (from a vector of types)
- virtual Type tupleType(const std::vector<Type>& types);
-
- // Record types
- //! 1-element record
- virtual Type recordType(const std::string& field, const Type& type);
-
- //! 2-element record
- /*! Fields will be sorted automatically */
- virtual Type recordType(const std::string& field0, const Type& type0,
- const std::string& field1, const Type& type1);
- //! 3-element record
- /*! Fields will be sorted automatically */
- virtual Type recordType(const std::string& field0, const Type& type0,
- const std::string& field1, const Type& type1,
- const std::string& field2, const Type& type2);
- //! n-element record (fields and types must be of the same length)
- /*! Fields will be sorted automatically */
- virtual Type recordType(const std::vector<std::string>& fields,
- const std::vector<Type>& types);
-
- // Datatypes
-
- //! Single datatype, single constructor
- /*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined. */
- virtual Type dataType(const std::string& name,
- const std::string& constructor,
- const std::vector<std::string>& selectors,
- const std::vector<Expr>& types);
-
- //! Single datatype, multiple constructors
- /*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined. */
- virtual Type dataType(const std::string& name,
- const std::vector<std::string>& constructors,
- const std::vector<std::vector<std::string> >& selectors,
- const std::vector<std::vector<Expr> >& types);
-
- //! Multiple datatypes
- /*! The types are either type exressions (obtained from a type with
- * getExpr()) or string expressions containing the name of (one of) the
- * dataType(s) being defined. */
- virtual void dataType(const std::vector<std::string>& names,
- const std::vector<std::vector<std::string> >& constructors,
- const std::vector<std::vector<std::vector<std::string> > >& selectors,
- const std::vector<std::vector<std::vector<Expr> > >& types,
- std::vector<Type>& returnTypes);
-
- //! Create an array type (ARRAY typeIndex OF typeData)
- virtual Type arrayType(const Type& typeIndex, const Type& typeData);
-
- //! Create a bitvector type of length n
- virtual Type bitvecType(int n);
-
- //! Create a function type typeDom -> typeRan
- virtual Type funType(const Type& typeDom, const Type& typeRan);
-
- //! Create a function type (t1,t2,...,tn) -> typeRan
- virtual Type funType(const std::vector<Type>& typeDom, const Type& typeRan);
-
- //! Create named user-defined uninterpreted type
- virtual Type createType(const std::string& typeName);
-
- //! Create named user-defined interpreted type (type abbreviation)
- virtual Type createType(const std::string& typeName, const Type& def);
-
- //! Lookup a user-defined (uninterpreted) type by name. Returns Null if none.
- virtual Type lookupType(const std::string& typeName);
-
- /*@}*/ // End of Type-related methods
-
- /***************************************************************************/
- /*!
- *\name General Expr methods
- *\sa class Expr
- *\sa class ExprManager
- *@{
- */
- /***************************************************************************/
-
- //! Return the ExprManager
- virtual ExprManager* getEM();
-
- //! Create a variable with a given name and type
- /*!
- \param name is the name of the variable
- \param type is its type. The type cannot be a function type.
- \return an Expr representation of a new variable
- */
- virtual Expr varExpr(const std::string& name, const Type& type);
-
- //! Create a variable with a given name, type, and value
- virtual Expr varExpr(const std::string& name, const Type& type,
- const Expr& def);
-
- //! Get the variable associated with a name, and its type
- /*!
- \param name is the variable name
- \param type is where the type value is returned
-
- \return a variable by the name. If there is no such Expr, a NULL \
- Expr is returned.
- */
- virtual Expr lookupVar(const std::string& name, Type* type);
-
- //! Get the type of the Expr.
- virtual Type getType(const Expr& e);
-
- //! Get the largest supertype of the Expr.
- virtual Type getBaseType(const Expr& e);
-
- //! Get the largest supertype of the Type.
- virtual Type getBaseType(const Type& t);
-
- //! Get the subtype predicate
- virtual Expr getTypePred(const Type&t, const Expr& e);
-
- //! Create a string Expr
- virtual Expr stringExpr(const std::string& str);
-
- //! Create an ID Expr
- virtual Expr idExpr(const std::string& name);
-
- //! Create a list Expr
- /*! Intermediate representation for DP-specific expressions.
- * Normally, the first element of the list is a string Expr
- * representing an operator, and the rest of the list are the
- * arguments. For example,
- *
- * kids.push_back(vc->stringExpr("PLUS"));
- * kids.push_back(x); // x and y are previously created Exprs
- * kids.push_back(y);
- * Expr lst = vc->listExpr(kids);
- *
- * Or, alternatively (using its overloaded version):
- *
- * Expr lst = vc->listExpr("PLUS", x, y);
- *
- * or
- *
- * vector<Expr> summands;
- * summands.push_back(x); summands.push_back(y); ...
- * Expr lst = vc->listExpr("PLUS", summands);
- */
- virtual Expr listExpr(const std::vector<Expr>& kids);
-
- //! Overloaded version of listExpr with one argument
- virtual Expr listExpr(const Expr& e1);
-
- //! Overloaded version of listExpr with two arguments
- virtual Expr listExpr(const Expr& e1, const Expr& e2);
-
- //! Overloaded version of listExpr with three arguments
- virtual Expr listExpr(const Expr& e1, const Expr& e2, const Expr& e3);
-
- //! Overloaded version of listExpr with string operator and many arguments
- virtual Expr listExpr(const std::string& op,
- const std::vector<Expr>& kids);
-
- //! Overloaded version of listExpr with string operator and one argument
- virtual Expr listExpr(const std::string& op, const Expr& e1);
-
- //! Overloaded version of listExpr with string operator and two arguments
- virtual Expr listExpr(const std::string& op, const Expr& e1,
- const Expr& e2);
-
- //! Overloaded version of listExpr with string operator and three arguments
- virtual Expr listExpr(const std::string& op, const Expr& e1,
- const Expr& e2, const Expr& e3);
-
- //! Prints e to the standard output
- virtual void printExpr(const Expr& e);
-
- //! Prints e to the given ostream
- virtual void printExpr(const Expr& e, std::ostream& os);
-
- //! Parse an expression using a Theory-specific parser
- virtual Expr parseExpr(const Expr& e);
-
- //! Parse a type expression using a Theory-specific parser
- virtual Type parseType(const Expr& e);
-
- //! Import the Expr from another instance of ValidityChecker
- /*! When expressions need to be passed among several instances of
- * ValidityChecker, they need to be explicitly imported into the
- * corresponding instance using this method. The return result is
- * an identical expression that belongs to the current instance of
- * ValidityChecker, and can be safely used as part of more complex
- * expressions from the same instance.
- */
- virtual Expr importExpr(const Expr& e);
-
- //! Import the Type from another instance of ValidityChecker
- /*! \sa getType() */
- virtual Type importType(const Type& t);
-
- //! Parse a sequence of commands from a presentation language string
- virtual void cmdsFromString(const std::string& s,
- InputLanguage lang = PRESENTATION_LANG);
-
- //! Parse an expression from a presentation language string
- /*! Only PRESENTATION_LANG and SMTLIB_V2_LANG are supported. Any other
- * value for lang will raise an exception.
- */
- virtual Expr exprFromString(const std::string& e,
- InputLanguage lang = PRESENTATION_LANG);
-
- /*@}*/ // End of General Expr Methods
-
- /***************************************************************************/
- /*!
- *\name Core expression methods
- * Methods for manipulating core expressions
- *
- * Except for equality and ite, the children provided as arguments must be of
- * type Boolean.
- *@{
- */
- /***************************************************************************/
-
- //! Return TRUE Expr
- virtual Expr trueExpr();
-
- //! Return FALSE Expr
- virtual Expr falseExpr();
-
- //! Create negation
- virtual Expr notExpr(const Expr& child);
-
- //! Create 2-element conjunction
- virtual Expr andExpr(const Expr& left, const Expr& right);
-
- //! Create n-element conjunction
- virtual Expr andExpr(const std::vector<Expr>& children);
-
- //! Create 2-element disjunction
- virtual Expr orExpr(const Expr& left, const Expr& right);
-
- //! Create n-element disjunction
- virtual Expr orExpr(const std::vector<Expr>& children);
-
- //! Create Boolean implication
- virtual Expr impliesExpr(const Expr& hyp, const Expr& conc);
-
- //! Create left IFF right (boolean equivalence)
- virtual Expr iffExpr(const Expr& left, const Expr& right);
-
- //! Create an equality expression.
- /*!
- The two children must have the same type, and cannot be of type
- Boolean.
- */
- virtual Expr eqExpr(const Expr& child0, const Expr& child1);
-
- //! Create IF ifpart THEN thenpart ELSE elsepart ENDIF
- /*!
- \param ifpart must be of type Boolean.
- \param thenpart and \param elsepart must have the same type, which will
- also be the type of the ite expression.
- */
- virtual Expr iteExpr(const Expr& ifpart, const Expr& thenpart,
- const Expr& elsepart);
-
- /**
- * Create an expression asserting that all the children are different.
- * @param children the children to be asserted different
- */
- virtual Expr distinctExpr(const std::vector<Expr>& children);
-
- /*@}*/ // End of Core expression methods
-
- /***************************************************************************/
- /*!
- *\name User-defined (uninterpreted) function methods
- * Methods for manipulating uninterpreted function expressions
- *@{
- */
- /***************************************************************************/
-
- //! Create a named uninterpreted function with a given type
- /*!
- \param name is the new function's name (as ID Expr)
- \param type is a function type ( [range -> domain] )
- */
- virtual Op createOp(const std::string& name, const Type& type);
-
- //! Create a named user-defined function with a given type
- virtual Op createOp(const std::string& name, const Type& type,
- const Expr& def);
-
- //! Get the Op associated with a name, and its type
- /*!
- \param name is the operator name
- \param type is where the type value is returned
-
- \return an Op by the name. If there is no such Op, a NULL \
- Op is returned.
- */
- virtual Op lookupOp(const std::string& name, Type* type);
-
- //! Unary function application (op must be of function type)
- virtual Expr funExpr(const Op& op, const Expr& child);
-
- //! Binary function application (op must be of function type)
- virtual Expr funExpr(const Op& op, const Expr& left, const Expr& right);
-
- //! Ternary function application (op must be of function type)
- virtual Expr funExpr(const Op& op, const Expr& child0,
- const Expr& child1, const Expr& child2);
-
- //! n-ary function application (op must be of function type)
- virtual Expr funExpr(const Op& op, const std::vector<Expr>& children);
-
- /*@}*/ // End of User-defined (uninterpreted) function methods
-
- /***************************************************************************/
- /*!
- *\name Arithmetic expression methods
- * Methods for manipulating arithmetic expressions
- *
- * These functions create arithmetic expressions. The children provided
- * as arguments must be of type Real.
- *@{
- */
- /***************************************************************************/
-
- /*!
- * Add the pair of variables to the variable ordering for aritmetic solving.
- * Terms that are not arithmetic will be ignored.
- * \param smaller the smaller variable
- * \param bigger the bigger variable
- */
- virtual bool addPairToArithOrder(const Expr& smaller, const Expr& bigger);
-
- //! Create a rational number with numerator n and denominator d.
- /*!
- \param n the numerator
- \param d the denominator, cannot be 0.
- */
- virtual Expr ratExpr(int n, int d = 1);
-
- //! Create a rational number with numerator n and denominator d.
- /*!
- Here n and d are given as strings. They are converted to
- arbitrary-precision integers according to the given base.
- */
- virtual Expr ratExpr(const std::string& n, const std::string& d, int base);
-
- //! Create a rational from a single string.
- /*!
- \param n can be a string containing an integer, a pair of integers
- "nnn/ddd", or a number in the fixed or floating point format.
- \param base is the base in which to interpret the string.
- */
- virtual Expr ratExpr(const std::string& n, int base = 10);
-
- //! Unary minus.
- virtual Expr uminusExpr(const Expr& child);
-
- //! Create 2-element sum (left + right)
- virtual Expr plusExpr(const Expr& left, const Expr& right);
-
- //! Create n-element sum
- virtual Expr plusExpr(const std::vector<Expr>& children);
-
- //! Make a difference (left - right)
- virtual Expr minusExpr(const Expr& left, const Expr& right);
-
- //! Create a product (left * right)
- virtual Expr multExpr(const Expr& left, const Expr& right);
-
- //! Create a power expression (x ^ n); n must be integer
- virtual Expr powExpr(const Expr& x, const Expr& n);
-
- //! Create expression x / y
- virtual Expr divideExpr(const Expr& numerator, const Expr& denominator);
-
- //! Create (left < right)
- virtual Expr ltExpr(const Expr& left, const Expr& right);
-
- //! Create (left <= right)
- virtual Expr leExpr(const Expr& left, const Expr& right);
-
- //! Create (left > right)
- virtual Expr gtExpr(const Expr& left, const Expr& right);
-
- //! Create (left >= right)
- virtual Expr geExpr(const Expr& left, const Expr& right);
-
- /*@}*/ // End of Arithmetic expression methods
-
- /***************************************************************************/
- /*!
- *\name Record expression methods
- * Methods for manipulating record expressions
- *@{
- */
- /***************************************************************************/
-
- //! Create a 1-element record value (# field := expr #)
- /*! Fields will be sorted automatically */
- virtual Expr recordExpr(const std::string& field, const Expr& expr);
-
- //! Create a 2-element record value (# field0 := expr0, field1 := expr1 #)
- /*! Fields will be sorted automatically */
- virtual Expr recordExpr(const std::string& field0, const Expr& expr0,
- const std::string& field1, const Expr& expr1);
-
- //! Create a 3-element record value (# field_i := expr_i #)
- /*! Fields will be sorted automatically */
- virtual Expr recordExpr(const std::string& field0, const Expr& expr0,
- const std::string& field1, const Expr& expr1,
- const std::string& field2, const Expr& expr2);
-
- //! Create an n-element record value (# field_i := expr_i #)
- /*!
- * \param fields
- * \param exprs must be the same length as fields
- *
- * Fields will be sorted automatically
- */
- virtual Expr recordExpr(const std::vector<std::string>& fields,
- const std::vector<Expr>& exprs);
-
- //! Create record.field (field selection)
- /*! Create an expression representing the selection of a field from
- a record. */
- virtual Expr recSelectExpr(const Expr& record, const std::string& field);
-
- //! Record update; equivalent to "record WITH .field := newValue"
- /*! Notice the `.' before field in the presentation language (and
- the comment above); this is to distinguish it from datatype
- update.
- */
- virtual Expr recUpdateExpr(const Expr& record, const std::string& field,
- const Expr& newValue);
-
- /*@}*/ // End of Record expression methods
-
- /***************************************************************************/
- /*!
- *\name Array expression methods
- * Methods for manipulating array expressions
- *@{
- */
- /***************************************************************************/
-
- //! Create an expression array[index] (array access)
- /*! Create an expression for the value of array at the given index */
- virtual Expr readExpr(const Expr& array, const Expr& index);
-
- //! Array update; equivalent to "array WITH index := newValue"
- virtual Expr writeExpr(const Expr& array, const Expr& index,
- const Expr& newValue);
-
- /*@}*/ // End of Array expression methods
-
- /***************************************************************************/
- /*!
- *\name Bitvector expression methods
- * Methods for manipulating bitvector expressions
- *@{
- */
- /***************************************************************************/
-
- // Bitvector constants
- // From a string of digits in a given base
- virtual Expr newBVConstExpr(const std::string& s, int base = 2);
- // From a vector of bools
- virtual Expr newBVConstExpr(const std::vector<bool>& bits);
- // From a rational: bitvector is of length 'len', or the min. needed length when len=0.
- virtual Expr newBVConstExpr(const Rational& r, int len = 0);
-
- // Concat and extract
- virtual Expr newConcatExpr(const Expr& t1, const Expr& t2);
- virtual Expr newConcatExpr(const std::vector<Expr>& kids);
- virtual Expr newBVExtractExpr(const Expr& e, int hi, int low);
-
- // Bitwise Boolean operators: Negation, And, Nand, Or, Nor, Xor, Xnor
- virtual Expr newBVNegExpr(const Expr& t1);
-
- virtual Expr newBVAndExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVAndExpr(const std::vector<Expr>& kids);
-
- virtual Expr newBVOrExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVOrExpr(const std::vector<Expr>& kids);
-
- virtual Expr newBVXorExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVXorExpr(const std::vector<Expr>& kids);
-
- virtual Expr newBVXnorExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVXnorExpr(const std::vector<Expr>& kids);
-
- virtual Expr newBVNandExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVNorExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVCompExpr(const Expr& t1, const Expr& t2);
-
- // Unsigned bitvector inequalities
- virtual Expr newBVLTExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVLEExpr(const Expr& t1, const Expr& t2);
-
- // Signed bitvector inequalities
- virtual Expr newBVSLTExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVSLEExpr(const Expr& t1, const Expr& t2);
-
- // Sign-extend t1 to a total of len bits
- virtual Expr newSXExpr(const Expr& t1, int len);
-
- // Bitvector arithmetic: unary minus, plus, subtract, multiply
- virtual Expr newBVUminusExpr(const Expr& t1);
- virtual Expr newBVSubExpr(const Expr& t1, const Expr& t2);
- //! 'numbits' is the number of bits in the result
- virtual Expr newBVPlusExpr(int numbits, const std::vector<Expr>& k);
- virtual Expr newBVPlusExpr(int numbits, const Expr& t1, const Expr& t2);
- virtual Expr newBVMultExpr(int numbits,
- const Expr& t1, const Expr& t2);
-
- virtual Expr newBVUDivExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVURemExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVSDivExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVSRemExpr(const Expr& t1, const Expr& t2);
- virtual Expr newBVSModExpr(const Expr& t1, const Expr& t2);
-
- // Left shift by r bits: result is old size + r bits
- virtual Expr newFixedLeftShiftExpr(const Expr& t1, int r);
- // Left shift by r bits: result is same size as t1
- virtual Expr newFixedConstWidthLeftShiftExpr(const Expr& t1, int r);
- // Logical right shift by r bits: result is same size as t1
- virtual Expr newFixedRightShiftExpr(const Expr& t1, int r);
- // Left shift with shift parameter an arbitrary bit-vector expr
- virtual Expr newBVSHL(const Expr& t1, const Expr& t2);
- // Logical right shift with shift parameter an arbitrary bit-vector expr
- virtual Expr newBVLSHR(const Expr& t1, const Expr& t2);
- // Arithmetic right shift with shift parameter an arbitrary bit-vector expr
- virtual Expr newBVASHR(const Expr& t1, const Expr& t2);
- // Get value of BV Constant
- virtual Rational computeBVConst(const Expr& e);
-
- /*@}*/ // End of Bitvector expression methods
-
- /***************************************************************************/
- /*!
- *\name Other expression methods
- * Methods for manipulating other kinds of expressions
- *@{
- */
- /***************************************************************************/
-
- //! Tuple expression
- virtual Expr tupleExpr(const std::vector<Expr>& exprs);
-
- //! Tuple select; equivalent to "tuple.n", where n is an numeral (e.g. tup.5)
- virtual Expr tupleSelectExpr(const Expr& tuple, int index);
-
- //! Tuple update; equivalent to "tuple WITH index := newValue"
- virtual Expr tupleUpdateExpr(const Expr& tuple, int index,
- const Expr& newValue);
-
- //! Datatype constructor expression
- virtual Expr datatypeConsExpr(const std::string& constructor, const std::vector<Expr>& args);
-
- //! Datatype selector expression
- virtual Expr datatypeSelExpr(const std::string& selector, const Expr& arg);
-
- //! Datatype tester expression
- virtual Expr datatypeTestExpr(const std::string& constructor, const Expr& arg);
-
- //! Create a bound variable with a given name, unique ID (uid) and type
- /*!
- \param name is the name of the variable
- \param uid is the unique ID (a string), which must be unique for
- each variable
- \param type is its type. The type cannot be a function type.
- \return an Expr representation of a new variable
- */
- virtual Expr boundVarExpr(const std::string& name,
- const std::string& uid,
- const Type& type);
-
- //! Universal quantifier
- virtual Expr forallExpr(const std::vector<Expr>& vars, const Expr& body);
- //! Universal quantifier with a trigger
- virtual Expr forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const Expr& trigger);
- //! Universal quantifier with a set of triggers.
- virtual Expr forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const std::vector<Expr>& triggers);
- //! Universal quantifier with a set of multi-triggers.
- virtual Expr forallExpr(const std::vector<Expr>& vars, const Expr& body,
- const std::vector<std::vector<Expr> >& triggers);
-
- //! Set triggers for quantifier instantiation
- /*!
- * \param e the expression for which triggers are being set.
- * \param triggers Each item in triggers is a vector of Expr containing one
- * or more patterns. A pattern is a term or Atomic predicate sub-expression
- * of e. A vector containing more than one pattern is treated as a
- * multi-trigger. Patterns will be matched in the order they occur in
- * the vector.
- */
- virtual void setTriggers(const Expr& e, const std::vector<std::vector<Expr> > & triggers);
- //! Set triggers for quantifier instantiation (no multi-triggers)
- virtual void setTriggers(const Expr& e, const std::vector<Expr>& triggers);
- //! Set a single trigger for quantifier instantiation
- virtual void setTrigger(const Expr& e, const Expr& trigger);
- //! Set a single multi-trigger for quantifier instantiation
- virtual void setMultiTrigger(const Expr& e, const std::vector<Expr>& multiTrigger);
-
- //! Existential quantifier
- virtual Expr existsExpr(const std::vector<Expr>& vars, const Expr& body);
-
- //! Lambda-expression
- virtual Op lambdaExpr(const std::vector<Expr>& vars, const Expr& body);
-
- //! Transitive closure of a binary predicate
- virtual Op transClosure(const Op& op);
-
- //! Symbolic simulation expression
- /*!
- * \param f is the next state function (LAMBDA-expression)
- * \param s0 is the initial state
- * \param inputs is the vector of LAMBDA-expressions representing
- * the sequences of inputs to f
- * \param n is a constant, the number of cycles to run the simulation.
- */
- virtual Expr simulateExpr(const Expr& f, const Expr& s0,
- const std::vector<Expr>& inputs,
- const Expr& n);
-
- /*@}*/ // End of Other expression methods
-
- /***************************************************************************/
- /*!
- *\name Validity checking methods
- * Methods related to validity checking
- *
- * This group includes methods for asserting formulas, checking
- * validity in the given logical context, manipulating the scope
- * level of the context, etc.
- *@{
- */
- /***************************************************************************/
-
- //! Set the resource limit (0==unlimited, 1==exhausted).
- /*! Currently, the limit is the total number of processed facts. */
- virtual void setResourceLimit(unsigned limit);
-
- //! Set a time limit in tenth of a second,
- /*! counting the cpu time used by the current process from now on.
- * Currently, when the limit is reached, cvc3 tries to quickly
- * terminate, probably with the status unknown.
- */
- virtual void setTimeLimit(unsigned limit);
-
- //! Assert a new formula in the current context.
- /*! This creates the assumption e |- e. The formula must have Boolean type.
- */
- virtual void assertFormula(const Expr& e);
-
- //! Register an atomic formula of interest.
- /*! Registered atoms are tracked by the decision procedures. If one of them
- is deduced to be true or false, it is added to a list of implied literals.
- Implied literals can be retrieved with the getImpliedLiteral function */
- virtual void registerAtom(const Expr& e);
-
- //! Return next literal implied by last assertion. Null Expr if none.
- /*! Returned literals are either registered atomic formulas or their negation
- */
- virtual Expr getImpliedLiteral();
-
- //! Simplify e with respect to the current context
- virtual Expr simplify(const Expr& e);
-
- //! Check validity of e in the current context.
- /*! If it returns VALID, the scope and context are the same
- * as when called. If it returns INVALID, the context will be one which
- * falsifies the query. If it returns UNKNOWN, the context will falsify the
- * query, but the context may be inconsistent. Finally, if it returns
- * ABORT, the context will be one which satisfies as much as possible.
- *
- * \param e is the queried formula
- */
- virtual QueryResult query(const Expr& e);
-
- //! Check satisfiability of the expr in the current context.
- /*! Equivalent to query(!e) */
- virtual QueryResult checkUnsat(const Expr& e);
-
- //! Get the next model
- /*! This method should only be called after a query which returns
- INVALID. Its return values are as for query(). */
- virtual QueryResult checkContinue();
-
- //! Restart the most recent query with e as an additional assertion.
- /*! This method should only be called after a query which returns
- INVALID. Its return values are as for query(). */
- virtual QueryResult restart(const Expr& e);
-
- //! Returns to context immediately before last invalid query.
- /*! This method should only be called after a query which returns false.
- */
- virtual void returnFromCheck();
-
- //! Get assumptions made by the user in this and all previous contexts.
- /*! User assumptions are created either by calls to assertFormula or by a
- * call to query. In the latter case, the negated query is added as an
- * assumption.
- * \param assumptions should be empty on entry.
- */
- virtual void getUserAssumptions(std::vector<Expr>& assumptions);
-
- //! Get assumptions made internally in this and all previous contexts.
- /*! Internal assumptions are literals assumed by the sat solver.
- * \param assumptions should be empty on entry.
- */
- virtual void getInternalAssumptions(std::vector<Expr>& assumptions);
-
- //! Get all assumptions made in this and all previous contexts.
- /*! \param assumptions should be empty on entry.
- */
- virtual void getAssumptions(std::vector<Expr>& assumptions);
-
- //! Returns the set of assumptions used in the proof of queried formula.
- /*! It returns a subset of getAssumptions(). If the last query was false
- * or there has not yet been a query, it does nothing.
- * NOTE: this functionality is not supported yet
- * \param assumptions should be empty on entry.
- */
- virtual void getAssumptionsUsed(std::vector<Expr>& assumptions);
-
- virtual Expr getProofQuery();
-
-
- //! Return the internal assumptions that make the queried formula false.
- /*! This method should only be called after a query which returns
- false. It will try to return the simplest possible subset of
- the internal assumptions sufficient to make the queried expression
- false.
- \param assumptions should be empty on entry.
- \param inOrder if true, returns the assumptions in the order they
- were made. This is slightly more expensive than inOrder = false.
- */
- virtual void getCounterExample(std::vector<Expr>& assumptions,
- bool inOrder=true);
-
- //! Will assign concrete values to all user created variables
- /*! This function should only be called after a query which return false.
- */
- virtual void getConcreteModel(ExprMap<Expr> & m);
-
- //! If the result of the last query was UNKNOWN try to actually build the model
- //! to verify the result.
- /*! This function should only be called after a query which return unknown.
- */
- virtual QueryResult tryModelGeneration();
-
- //:ALEX: returns the current truth value of a formula
- // returns UNKNOWN_VAL if e is not associated
- // with a boolean variable in the SAT module,
- // i.e. if its value can not determined without search.
- virtual FormulaValue value(const Expr& e);
-
- //! Returns true if the current context is inconsistent.
- /*! Also returns a minimal set of assertions used to determine the
- inconsistency.
- \param assumptions should be empty on entry.
- */
- virtual bool inconsistent(std::vector<Expr>& assumptions);
-
- //! Returns true if the current context is inconsistent.
- virtual bool inconsistent();
-
- //! Returns true if the invalid result from last query() is imprecise
- /*!
- * Some decision procedures in CVC are incomplete (quantifier
- * elimination, non-linear arithmetic, etc.). If any incomplete
- * features were used during the last query(), and the result is
- * "invalid" (query() returns false), then this result is
- * inconclusive. It means that the system gave up the search for
- * contradiction at some point.
- */
- virtual bool incomplete();
-
- //! Returns true if the invalid result from last query() is imprecise
- /*!
- * \sa incomplete()
- *
- * The argument is filled with the reasons for incompleteness (they
- * are intended to be shown to the end user).
- */
- virtual bool incomplete(std::vector<std::string>& reasons);
-
- //! Returns the proof term for the last proven query
- /*! If there has not been a successful query, it should return a NULL proof
- */
- virtual Proof getProof();
-
- //! Evaluate an expression and return a concrete value in the model
- /*! If the last query was not invalid, should return NULL expr */
- virtual Expr getValue(const Expr& e);
-
- //! Returns the TCC of the last assumption or query
- /*! Returns Null if no assumptions or queries were performed. */
- virtual Expr getTCC();
-
- //! Return the set of assumptions used in the proof of the last TCC
- virtual void getAssumptionsTCC(std::vector<Expr>& assumptions);
-
- //! Returns the proof of TCC of the last assumption or query
- /*! Returns Null if no assumptions or queries were performed. */
- virtual Proof getProofTCC();
-
- //! After successful query, return its closure |- Gamma => phi
- /*! Turn a valid query Gamma |- phi into an implication
- * |- Gamma => phi.
- *
- * Returns Null if last query was invalid.
- */
- virtual Expr getClosure();
-
- //! Construct a proof of the query closure |- Gamma => phi
- /*! Returns Null if last query was Invalid. */
- virtual Proof getProofClosure();
-
- /*@}*/ // End of Validity checking methods
-
- /***************************************************************************/
- /*!
- *\name Context methods
- * Methods for manipulating contexts
- *
- * Contexts support stack-based push and pop. There are two
- * separate notions of the current context stack. stackLevel(), push(),
- * pop(), and popto() work with the user-level notion of the stack.
- *
- * scopeLevel(), pushScope(), popScope(), and poptoScope() work with
- * the internal stack which is more fine-grained than the user
- * stack.
- *
- * Do not use the scope methods unless you know what you are doing.
- * *@{
- */
- /***************************************************************************/
-
- //! Returns the current stack level. Initial level is 0.
- virtual int stackLevel();
-
- //! Checkpoint the current context and increase the scope level
- virtual void push();
-
- //! Restore the current context to its state at the last checkpoint
- virtual void pop();
-
- //! Restore the current context to the given stackLevel.
- /*!
- \param stackLevel should be greater than or equal to 0 and less
- than or equal to the current scope level.
- */
- virtual void popto(int stackLevel);
-
- //! Returns the current scope level. Initially, the scope level is 1.
- virtual int scopeLevel();
-
- /*! @brief Checkpoint the current context and increase the
- * <strong>internal</strong> scope level. Do not use unless you
- * know what you're doing!
- */
- virtual void pushScope();
-
- /*! @brief Restore the current context to its state at the last
- * <strong>internal</strong> checkpoint. Do not use unless you know
- * what you're doing!
- */
- virtual void popScope();
-
- //! Restore the current context to the given scopeLevel.
- /*!
- \param scopeLevel should be less than or equal to the current scope level.
-
- If scopeLevel is less than 1, then the current context is reset
- and the scope level is set to 1.
- */
- virtual void poptoScope(int scopeLevel);
-
- //! Get the current context
- virtual Context* getCurrentContext();
-
- //! Destroy and recreate validity checker: resets everything except for flags
- virtual void reset();
-
- //! Add an annotation to the current script - prints annot when translating
- virtual void logAnnotation(const Expr& annot);
-
- /*@}*/ // End of Context methods
-
- /***************************************************************************/
- /*!
- *\name Reading files
- * Methods for reading external files
- *@{
- */
- /***************************************************************************/
-
- //! Read and execute the commands from a file given by name ("" means stdin)
- virtual void loadFile(const std::string& fileName,
- InputLanguage lang = PRESENTATION_LANG,
- bool interactive = false,
- bool calledFromParser = false);
-
- //! Read and execute the commands from a stream
- virtual void loadFile(std::istream& is,
- InputLanguage lang = PRESENTATION_LANG,
- bool interactive = false);
-
- /*@}*/ // End of methods for reading files
-
- /***************************************************************************/
- /*!
- *\name Reporting Statistics
- * Methods for collecting and reporting run-time statistics
- *@{
- */
- /***************************************************************************/
-
- //! Get statistics object
- virtual Statistics getStatistics();
-
- //! Print collected statistics to stdout
- virtual void printStatistics();
-
- /*@}*/ // End of Statistics Methods
-
-};/* class ValidityChecker */
-
-template <class T>
-void ExprHashMap<T>::insert(Expr a, Expr b) {
- (*this)[a] = b;
-}
-
-// Comparison (the way that CVC3 does it)
-int compare(const Expr& e1, const Expr& e2);
-
-}/* CVC3 namespace */
-
-#endif /* _cvc3__include__vc_h_ */
-#endif /* __CVC4__CVC3_COMPAT_H */
#ifndef __CVC4_PRIVATE_LIBRARY_H
#define __CVC4_PRIVATE_LIBRARY_H
-#if ! (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST) || defined(__BUILDING_CVC4PARSERLIB) || defined(__BUILDING_CVC4PARSERLIB_UNIT_TEST) || defined(__BUILDING_CVC4COMPATLIB) || defined(__BUILDING_CVC4DRIVER))
+#if ! (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST) || defined(__BUILDING_CVC4PARSERLIB) || defined(__BUILDING_CVC4PARSERLIB_UNIT_TEST) || defined(__BUILDING_CVC4DRIVER))
# error A "private library" CVC4 header was included when not building the library, driver, or private unit test code.
#endif /* ! (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST || __BUILDING_CVC4PARSERLIB || __BUILDING_CVC4PARSERLIB_UNIT_TEST || __BUILDING_CVC4DRIVER) */
statistics \
sep_log_api
-if CVC4_BUILD_LIBCOMPAT
-#CPLUSPLUS_TESTS += \
-# cvc3_main
-endif
-
TESTS = $(CPLUSPLUS_TESTS)
if CVC4_LANGUAGE_BINDING_JAVA
# Things that aren't tests but that tests rely on and need to
# go into the distribution
TEST_DEPS_DIST = \
- cvc3_main.cpp \
CVC4JavaTest.java \
run_java_test
$(abs_top_builddir)/src/libcvc4.la \
$(abs_top_builddir)/src/parser/libcvc4parser.la
-if CVC4_BUILD_LIBCOMPAT
-TEST_DEPS_NODIST += \
- $(abs_top_builddir)/src/compat/libcvc4compat.la
-endif
-
TEST_DEPS = \
$(TEST_DEPS_DIST) \
$(TEST_DEPS_NODIST)
-D __BUILDING_CVC4_SYSTEM_TEST \
$(TEST_CPPFLAGS)
-LIBADD =
-if CVC4_BUILD_LIBCOMPAT
-LIBADD += \
- @abs_top_builddir@/src/compat/libcvc4compat.la
-endif
-LIBADD += \
+LIBADD = \
@abs_top_builddir@/src/parser/libcvc4parser.la \
@abs_top_builddir@/src/libcvc4.la
+++ /dev/null
-/********************* */
-/*! \file cvc3_main.cpp
- ** \verbatim
- ** Top contributors (to current version):
- ** Morgan Deters, Andrew Reynolds
- ** This file is part of the CVC4 project.
- ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
- ** in the top-level source directory) and their institutional affiliations.
- ** All rights reserved. See the file COPYING in the top-level source
- ** directory for licensing information.\endverbatim
- **
- ** \brief Test of CVC3 compatibility interface
- **
- ** This is part of a test of the CVC3 compatibility interface present in
- ** CVC4. It is a test copied from CVC3's "test" directory. Only #includes
- ** were changed to support this test in CVC4.
- **
- ** The original file comment is preserved in the source.
- **/
-
-///////////////////////////////////////////////////////////////////////////////
-// //
-// File: main.cpp //
-// Author: Clark Barrett //
-// Created: Sat Apr 19 01:47:47 2003 //
-// //
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include "compat/cvc3_compat.h"
-//#include "vc.h"
-//#include "theory_arith.h" // for arith kinds and expressions
-//#include "theory_array.h"
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <deque>
-//#include "exception.h"
-//#include "typecheck_exception.h"
-//#include "command_line_flags.h"
-//#include "debug.h"
-
-
-using namespace std;
-using namespace CVC3;
-
-int exitStatus;
-
-inline void __expect__(const std::string& file,
- int line,
- bool cond,
- const std::string& cond_s,
- const std::string& msg) {
- if(!cond) {
- std::cerr << file << ":" << line
- << ": Expected: (" << cond_s << "). "
- << msg << std::endl;
- exitStatus = 1;
- }
-}
-
-#define EXPECT(cond, msg) __expect__(__FILE__, __LINE__, (cond), #cond, (msg))
-
-// Check whether e is valid
-bool check(ValidityChecker* vc, Expr e, bool verbose=true)
-{
- if(verbose) {
- cout << "Query: ";
- vc->printExpr(e);
- }
- bool res = vc->query(e);
- if (res) {
- if(verbose) cout << "Valid" << endl << endl;
- } else {
- if(verbose) cout << "Invalid" << endl << endl;
- }
- return res;
-}
-
-
-// Make a new assertion
-void newAssertion(ValidityChecker* vc, Expr e)
-{
- cout << "Assert: ";
- vc->printExpr(e);
- vc->assertFormula(e);
-}
-
-int eqExprVecs(const vector<Expr>& v1,
- const vector<Expr>& v2) {
- if( v1.size() != v2.size() ) {
- return 0;
- }
-
- for( unsigned int i=0; i < v1.size(); ++i ) {
- if( v1[i] != v2[i] ) {
- return 0;
- }
- }
-
- return 1;
-}
-
-int eqExprVecVecs(const vector<vector<Expr> > vv1,
- const vector<vector<Expr> > vv2) {
- if( vv1.size() != vv2.size() ) {
- return 0;
- }
-
- for( unsigned int i=0; i < vv1.size(); ++i ) {
- if( !eqExprVecs(vv1[i],vv2[i]) ) {
- return 0;
- }
- }
-
- return 1;
-}
-
-
-void test ()
-{
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type it (vc->intType ()); //int
- Op f = vc->createOp("f",vc->funType(it,it));
- Expr z = vc->varExpr("z",it);
- Expr e = vc->funExpr(f, vc->funExpr(f, z));
- e = e[0];
- Expr f2 = vc->funExpr(f, e);
- Expr f3 = vc->funExpr(f, f2);
-
- EXPECT(e != f2 && e != f3, "Refcount problems");
-
- Expr x (vc->boundVarExpr ("x", "0", it));//x0:int
- vector<Expr> xs;
- xs.push_back (x); //<x0:int>
- Op lxsx (vc->lambdaExpr (xs,x)); //\<x0:int>. x0:int
- Expr y (vc->ratExpr (1,1)); //1
- vector<Expr> ys;
- ys.push_back (y); //<1>
- Expr lxsxy = vc->funExpr (lxsx, y); //(\<x0:int>. x0:int)1
- Expr lxsxys = vc->funExpr (lxsx, ys); //(\<x0:int>. x0:int)<1>
- cout << "Lambda application: " << lxsxy << endl;
- cout << "Simplified: " << vc->simplify(lxsxy) << endl;
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test (): \n" << e << endl;
- }
- delete vc;
-}
-
-void test1()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs",false);
- flags.setFlag("dump-log", ".test1.cvc");
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- // It is important that all Expr objects are deleted before vc is
- // deleted. Therefore, we enclose them in a scope of try{ }catch
- // block.
- //
- // Also, vc methods may throw an Exception, and we want to delete vc
- // even in those exceptional cases.
- try {
-
- bool b = check(vc, vc->trueExpr());
- EXPECT(b, "Should be valid");
-
- vc->push();
- b = check(vc, vc->falseExpr());
- EXPECT(!b, "Should be invalid");
- vc->pop();
-
- // Check p OR ~p
-
- Expr p = vc->varExpr("p", vc->boolType());
- Expr e = vc->orExpr(p, vc->notExpr(p));
-
- b = check(vc, e);
- EXPECT(b, "Should be valid");
-
- // Check x = y -> f(x) = f(y)
-
- Expr x = vc->varExpr("x", vc->realType());
- Expr y = vc->varExpr("y", vc->realType());
-
- Type real2real = vc->funType(vc->realType(), vc->realType());
- Op f = vc->createOp("f", real2real);
- Expr fx = vc->funExpr(f, x);
- Expr fy = vc->funExpr(f, y);
-
- e = vc->impliesExpr(vc->eqExpr(x,y),vc->eqExpr(fx, fy));
- b = check(vc, e);
- EXPECT(b, "Should be valid");
-
- // Check f(x) = f(y) -> x = y
-
- e = vc->impliesExpr(vc->eqExpr(fx,fy),vc->eqExpr(x, y));
- int scopeLevel = vc->scopeLevel();
- vc->push();
- b = check(vc, e);
- EXPECT(!b, "Should be invalid");
-
- // Get counter-example
-
- vector<Expr> assertions;
- cout << "Scope level: " << vc->scopeLevel() << endl;
- cout << "Counter-example:" << endl;
- //vc->getCounterExample(assertions);
- for (unsigned i = 0; i < assertions.size(); ++i) {
- vc->printExpr(assertions[i]);
- }
- cout << "End of counter-example" << endl << endl;
-
- // Reset to initial scope
- cout << "Resetting" << endl;
- vc->pop();
- EXPECT(scopeLevel == vc->scopeLevel(), "scope error");
- cout << "Scope level: " << vc->scopeLevel() << endl << endl;
-
- // Check w = x & x = y & y = z & f(x) = f(y) & x = 1 & z = 2
-
- Expr w = vc->varExpr("w", vc->realType());
- Expr z = vc->varExpr("z", vc->realType());
-
- cout << "Push Scope" << endl << endl;
- vc->push();
-
- newAssertion(vc, vc->eqExpr(w, x));
- newAssertion(vc, vc->eqExpr(x, y));
- newAssertion(vc, vc->eqExpr(y, z));
- newAssertion(vc, vc->eqExpr(fx, fy));
- newAssertion(vc, vc->eqExpr(x, vc->ratExpr(1)));
-
- cout << endl << "simplify(w) = ";
- vc->printExpr(vc->simplify(w));
- cout << endl;
- EXPECT(vc->simplify(w)==vc->ratExpr(1), "Expected simplify(w) = 1");
-
- newAssertion(vc, vc->eqExpr(z, vc->ratExpr(2)));
- assertions.clear();
- cout << "Inconsistent?: " << vc->inconsistent(assertions) << endl;
-
- cout << "Assumptions Used:" << endl;
- for (unsigned i = 0; i < assertions.size(); ++i) {
- vc->printExpr(assertions[i]);
- }
-
- cout << endl << "Pop Scope" << endl << endl;
- vc->pop();
-
- cout << "simplify(w) = ";
- vc->printExpr(vc->simplify(w));
- EXPECT(vc->simplify(w)==w, "Expected simplify(w) = w");
- cout << endl;
-
- assertions.clear();
- cout << "Inconsistent?: " << vc->inconsistent(assertions) << endl;
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test1(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test2()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs",false);
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
-
- Expr bexpr = vc->varExpr("b", vc->intType());
- vc->assertFormula(vc->ltExpr(bexpr, vc->ratExpr(10)));
-
- Expr c = vc->varExpr("c", vc->intType());
- vc->assertFormula(c.eqExpr(vc->ratExpr(0)) || c.eqExpr(vc->ratExpr(1)));
-
- bool b = check(vc, vc->leExpr(bexpr, vc->ratExpr(10)));
- EXPECT(b, "Should be valid");
-
- b = check(vc, vc->falseExpr());
- EXPECT(!b, "Should be invalid");
- vc->returnFromCheck();
-
- // Check x = y -> g(x,y) = g(y,x)
-
- Expr x = vc->varExpr("x", vc->realType());
- Expr y = vc->varExpr("y", vc->realType());
-
- Type real = vc->realType();
- vector<Type> RxR;
- RxR.push_back(real);
- RxR.push_back(real);
-
- Type realxreal2real = vc->funType(RxR, real);
- Op g = vc->createOp("g", realxreal2real);
-
- Expr gxy = vc->funExpr(g, x, y);
- Expr gyx = vc->funExpr(g, y, x);
-
- Expr e = vc->impliesExpr(vc->eqExpr(x,y),vc->eqExpr(gxy, gyx));
- b = check(vc, e);
- EXPECT(b, "Should be valid");
-
- Op h = vc->createOp("h", realxreal2real);
-
- Expr hxy = vc->funExpr(h, x, y);
- Expr hyx = vc->funExpr(h, y, x);
-
- e = vc->impliesExpr(vc->eqExpr(x,y),vc->eqExpr(hxy, hyx));
- b = check(vc, e);
- EXPECT(b, "Should be valid");
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test2(): \n" << e << endl;
- }
-
- delete vc;
-}
-
-
-Expr ltLex(ValidityChecker* vc, Expr i1, Expr i2, Expr j1, Expr j2)
-{
- Expr res = vc->ltExpr(i1, j1);
- return vc->orExpr(res, vc->andExpr(vc->eqExpr(i1, j1), vc->ltExpr(i2, j2)));
-}
-
-
-Expr createTestFormula(ValidityChecker* vc, Expr i1, Expr i2, Expr r1, Expr r2)
-{
- Expr lt1 = ltLex(vc, r1, r2, i1, i2);
- Expr lt2 = ltLex(vc, i2, i1, r2, r1);
- return vc->andExpr(lt1, lt2);
-}
-
-
-void test3()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs",false);
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Expr i = vc->varExpr("i", vc->realType());
- Expr j = vc->varExpr("j", vc->realType());
- Expr k = vc->varExpr("k", vc->realType());
-
- Expr one = vc->ratExpr(1);
-
- cout << "i: " << i.getIndex() << endl;
-
- Expr test = createTestFormula(vc, i, j,
- vc->minusExpr(i, one), vc->minusExpr(j, k));
-
- cout << "Trying test: ";
- vc->printExpr(test);
- cout << endl;
-
- vc->push();
- bool result = vc->query(test);
- if (result) {
- cout << "Test Valid" << endl;
- vc->pop();
- }
- else {
- Expr condition;
- vector<Expr> assertions;
- unsigned index;
-
- //vc->getCounterExample(assertions);
-
- cout << "Test Invalid Under Conditions:" << endl;
- for (index = 0; index < assertions.size(); ++index) {
- vc->printExpr(assertions[index]);
- }
-
- // Try assertions one by one
- for (index = 0; index < assertions.size(); ++index) {
- condition = vc->notExpr(assertions[index]);
- cout << "Trying test under condition: ";
- vc->printExpr(condition);
- cout << endl;
- vc->pop();
- vc->push();
- result = vc->query(vc->impliesExpr(condition, test));
- if (result) {
- cout << "Result Valid" << endl;
- break;
- }
- else {
- cout << "Result Invalid" << endl;
- }
- }
- }
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test3(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test4()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs",false);
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Expr i = vc->varExpr("i", vc->realType());
- Expr j = vc->varExpr("j", vc->realType());
- Expr k = vc->varExpr("k", vc->realType());
-
- Expr one = vc->ratExpr(1);
-
- cout << "i: " << i.getIndex() << endl;
-
- Expr test = createTestFormula(vc, i, j,
- vc->minusExpr(i, one), vc->minusExpr(j, k));
-
- cout << "Trying test: ";
- vc->printExpr(test);
- cout << endl;
-
- vc->push();
- bool result = vc->query(test);
- if (result) {
- cout << "Test Valid" << endl;
- }
- else {
- Expr condition;
- vector<Expr> assertions;
- unsigned index;
-
- //vc->getCounterExample(assertions);
-
- cout << "Test Invalid Under Conditions:" << endl;
- for (index = 0; index < assertions.size(); ++index) {
- vc->printExpr(assertions[index]);
- }
-
- // Try assertions one by one
- for (index = 0; index < assertions.size(); ++index) {
- condition = vc->notExpr(assertions[index]);
- cout << "Trying test under condition: ";
- vc->printExpr(condition);
- cout << endl;
- vc->pop();
- vc->push();
- result = vc->query(vc->impliesExpr(condition, test));
- if (result) {
- cout << "Result Valid" << endl;
- break;
- }
- else {
- cout << "Result Invalid" << endl;
- }
- }
- }
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test4(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void findLeaves(Expr e, vector<Expr>& l)
-{
- int ar = e.arity();
- if (ar > 0) {
- for (int i = 0; i < ar; ++i)
- findLeaves(e[i], l);
- return;
- }
- l.push_back(e);
-}
-
-
-bool hasij(Expr e, Expr i, Expr j)
-{
- int ar = e.arity();
- if (ar > 0) {
- for (int k = 0; k < ar; ++k)
- if (hasij(e[k], i, j)) return true;
- return false;
- }
- if (e == i || e == j) return true;
- return false;
-}
-
-
-Expr plusExpr(ValidityChecker* vc, vector<Expr>& kids)
-{
- if (kids.size() == 0) return vc->ratExpr(0);
- else if (kids.size() == 1) return kids[0];
- else if (kids.size() == 2) return vc->plusExpr(kids[0], kids[1]);
- else {
- Expr r = kids.back();
- kids.pop_back();
- return vc->plusExpr(plusExpr(vc, kids), r);
- }
-}
-
-
-void test5()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs",false);
- flags.setFlag("dump-log", ".test5.cvc");
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Expr i = vc->varExpr("i1", vc->realType());
- Expr j = vc->varExpr("i2", vc->realType());
- Expr p = vc->varExpr("p", vc->realType());
- Expr q = vc->varExpr("q", vc->realType());
- Expr r = vc->varExpr("r", vc->realType());
- Expr a = vc->varExpr("arb_addr", vc->realType());
- Expr N = vc->varExpr("N", vc->realType());
-
- Expr M = vc->varExpr("M", vc->arrayType(vc->realType(), vc->realType()));
-
- Expr M2 = vc->writeExpr(M, vc->plusExpr(q, i), vc->readExpr(M, vc->plusExpr(r, i)));
-
- Expr M1 = vc->writeExpr(M, vc->plusExpr(p, j), vc->readExpr(M, vc->plusExpr(r, j)));
-
- Expr e = vc->eqExpr(vc->readExpr(vc->writeExpr(M2, vc->plusExpr(p, j), vc->readExpr(M2, vc->plusExpr(r, j))), a),
- vc->readExpr(vc->writeExpr(M1, vc->plusExpr(q, i), vc->readExpr(M1, vc->plusExpr(r, i))), a));
-
- Expr one = vc->ratExpr(1);
- Expr zero = vc->ratExpr(0);
-
- Expr qmp = vc->minusExpr(q, p);
- Expr qmr = vc->minusExpr(q, r);
-
- vector<Expr> hyp;
- hyp.push_back(vc->ltExpr(i, j));
-// hyp.push_back(vc->orExpr(vc->geExpr(qmp, N), vc->leExpr(qmp, zero)));
-// hyp.push_back(vc->orExpr(vc->geExpr(qmr, N), vc->leExpr(qmr, zero)));
-
- Expr test = vc->impliesExpr(vc->andExpr(hyp), e);
- Expr query;
-
- cout << "Checking verification condition:" << endl;
- vc->printExpr(test);
- cout << endl;
-
- vc->push();
- bool result = vc->query(test);
- if (result) {
- cout << "Valid" << endl;
- }
- else {
- vector<Expr> conditions;
- vector<Expr> assertions;
- unsigned index, index2;
- int req;
- vector<Expr> leaves;
-
- //vc->getCounterExample(assertions);
-
- cout << "Invalid Under Conditions:" << endl;
- for (index = 0; index < assertions.size(); ++index) {
- if (assertions[index] == (!test)) {
- for (; index < assertions.size()-1; ++index) {
- assertions[index] = assertions[index+1];
- }
- assertions.pop_back();
- break;
- }
- }
- for (index = 0; index < assertions.size(); ++index) {
- vc->printExpr(assertions[index]);
- }
-
- cout << endl;
-
- // Try assertions one by one
- for (index = 0; index < assertions.size(); ++index) {
- e = assertions[index];
-
- // Check condition for eligibility
- if (e.isNot()) {
- cout << "Condition ineligible: negation" << endl;
- vc->printExpr(e);
- cout << endl;
- continue;
- }
- if (e.isEq()) {
- req = 2;
- }
- else req = 1;
-
- leaves.clear();
- findLeaves(e, leaves);
- for (index2 = 0; index2 < leaves.size(); ++index2) {
- if (!leaves[index2].isVar() ||
- leaves[index2] == i ||
- leaves[index2] == j ||
- leaves[index2] == a)
- continue;
- req--;
- }
- if (req > 0) {
- cout << "Condition ineligible: not enough non-loop variables" << endl;
- vc->printExpr(e);
- cout << endl;
- continue;
- }
-
- cout << "Condition selected:" << endl;
- vc->printExpr(e);
- cout << endl << endl;
-
- conditions.push_back(vc->notExpr(e));
- cout << "Trying verification condition with hypothesis:" << endl;
- vc->printExpr(vc->andExpr(conditions));
- cout << endl;
- vc->pop();
- vc->push();
- query = vc->impliesExpr(vc->andExpr(conditions), test);
- result = vc->query(query);
- if (result) {
- cout << "Result Valid" << endl;
- break;
- }
- else {
- assertions.clear();
- vc->getCounterExample(assertions);
-
- cout << "Invalid Under Conditions:" << endl;
- for (index2 = 0; index2 < assertions.size(); ++index2) {
- if (assertions[index2] == (!query)) {
- for (; index2 < assertions.size()-1; ++index2) {
- assertions[index2] = assertions[index2+1];
- }
- assertions.pop_back();
- break;
- }
- }
-
- for (index2 = 0; index2 < assertions.size(); ++index2) {
- vc->printExpr(assertions[index2]);
- }
- cout << endl;
- index = (unsigned)-1;
- }
- }
-
- cout << endl << "Attempting to remove loop variables" << endl;
- // replace loop variables in conditions
- vector<Expr> newConditions;
- vector<Expr> newPlus;
- bool foundi, foundj, negi, negj;
- Expr minusone = vc->ratExpr(-1);
- for (index = 0; index < conditions.size(); ++index) {
- if (conditions[index][0].isEq()) {
- e = vc->simplify(vc->minusExpr(conditions[index][0][0], conditions[index][0][1]));
- if (hasij(e, i, j)) {
- if (e.getKind() == CVC3::PLUS) {
- newPlus.clear();
- newPlus.push_back(e[0]);
- foundi = foundj = negi = negj = false;
- for (index2 = 1; index2 < (unsigned)e.arity(); index2++) {
- Expr term = e[index2];
- if (term == i && !foundi) foundi = true;
- else if (term == j && !foundj) {
- foundj = true;
- negj = true;
- }
- else if (term.getKind() == CVC3::MULT && term[0] == minusone && term[1] == i && !foundi) {
- foundi = true;
- negi = true;
- }
- else if (term.getKind() == CVC3::MULT && term[0] == minusone && term[1] == j && !foundj) foundj = true;
- else newPlus.push_back(term);
- }
- if (foundi && foundj && ((negi && negj) || (!negi && !negj))) {
- e = plusExpr(vc, newPlus);
- if (negi && negj) e = vc->uminusExpr(e);
- e = vc->simplify(e);
- if (!hasij(e, i, j)) {
- newConditions.push_back(vc->orExpr(vc->geExpr(e, N), vc->leExpr(e, zero)));
- continue;
- }
- }
- }
- cout << "Unable to remove loop variables:" << endl;
- vc->printExpr(e);
- break;
- }
- }
- newConditions.push_back(conditions[index]);
- }
- if (index == conditions.size()) {
- cout << "Loop variables successfully removed:" << endl;
- Expr cond = (newConditions.size()>0)?
- vc->andExpr(newConditions) : vc->trueExpr();
- vc->printExpr(cond);
- cout << endl;
-
- vector<Expr> loopConditions;
- loopConditions.push_back(cond);
- loopConditions.push_back(vc->geExpr(i, one));
- loopConditions.push_back(vc->geExpr(j, one));
- loopConditions.push_back(vc->leExpr(i, N));
- loopConditions.push_back(vc->leExpr(j, N));
- vc->pop();
- vc->push();
- cout << "Final query" << endl;
- result = vc->query(vc->impliesExpr(vc->andExpr(loopConditions), test));
- if (result) {
- cout << "Result Valid" << endl;
- }
- else {
- cout << "Result Invalid" << endl;
- }
- }
- }
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test5(): \n" << e << endl;
- }
- delete vc;
-}
-
-//#include "debug.h"
-
-// Test importing of Exprs from a different validity checker
-void test6() {
- ValidityChecker* vc1 = ValidityChecker::create();
- ValidityChecker* vc2 = ValidityChecker::create();
-
- try {
- Type real1 = vc1->realType();
-
- Expr x1 = vc1->varExpr("x", real1);
- Expr y1 = vc1->boundVarExpr("y", "0", real1);
-
- cout << "vc1 variables: " << x1 << ", " << y1 << endl;
-
- Expr x2 = vc2->varExpr("x", vc2->importType(real1));
- Expr y2 = vc2->boundVarExpr("y", "0", vc2->realType());
-
- cout << "vc2 variables: " << x2 << ", " << y2 << endl;
- cout << "vars imported to vc2 from vc1: "
- << vc2->importExpr(x1) << ", " << vc2->importExpr(y1) << endl;
- Expr t1 = vc1->trueExpr();
- Expr and1 = vc1->andExpr(t1, vc1->falseExpr());
- Op f1 = vc1->createOp("f", vc1->funType(real1, real1));
- Expr fx1 = vc1->funExpr(f1, x1);
- Expr f5_1 = vc1->funExpr(f1, vc1->ratExpr(5,1));
- Type rt1 = vc1->recordType("foo", real1, "bar", real1);
- Expr r1 = vc1->recordExpr("foo", fx1, "bar", f5_1);
- Expr r1_eq = vc1->eqExpr(r1, vc1->recUpdateExpr(r1, "foo", f5_1));
- Type art1 = vc1->arrayType(real1, rt1);
- Expr ar1 = vc1->varExpr("ar", art1);
- Expr ar_eq1 = vc1->eqExpr(vc1->writeExpr(ar1, x1, r1), ar1);
- Expr query1 = vc1->eqExpr(vc1->recSelectExpr(vc1->readExpr(ar1, x1), "foo"),
- vc1->recSelectExpr(r1, "bar"));
-
- cout << "*** VC #1:" << endl;
- newAssertion(vc1, r1_eq);
- newAssertion(vc1, ar_eq1);
- check(vc1, query1);
-
- //cout << "*** VC #2:" << endl;
- //newAssertion(vc2, vc2->importExpr(r1_eq));
- //newAssertion(vc2, vc2->importExpr(ar_eq1));
- //check(vc2, vc2->importExpr(query1));
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test6(): \n" << e << endl;
- }
- delete vc1;
- delete vc2;
-}
-
-
-void test7() {
- ValidityChecker* vc1 = ValidityChecker::create();
- ValidityChecker* vc2 = ValidityChecker::create();
- try {
- Expr e1 = vc1->varExpr("e1", vc1->realType());
- Expr e2 = vc2->varExpr("e2", vc2->realType());
- newAssertion(vc2, vc2->eqExpr(vc2->importExpr(e1), e2));
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test7(): \n" << e << endl;
- }
- delete vc1;
- delete vc2;
-}
-
-
-void test8() {
- ValidityChecker* vc = ValidityChecker::create();
- try {
- vector<Expr> vec;
- vec.push_back(vc->boundVarExpr("x", "x", vc->realType()));
- Expr lambda = vc->lambdaExpr(vec, vc->falseExpr()).getExpr();
- Expr witness;
- try {
- Type t = vc->subtypeType(lambda, witness);
- EXPECT(false, "Typechecking exception expected");
- } catch(const TypecheckException&) {
- // fall through
- }
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test8(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-Expr adder(ValidityChecker* vc, const Expr& a, const Expr& b, const Expr& c)
-{
- return vc->notExpr(vc->iffExpr(vc->notExpr(vc->iffExpr(a,b)),c));
-}
-
-
-Expr carry(ValidityChecker* vc, const Expr& a, const Expr& b, const Expr& c)
-{
- return vc->orExpr(vc->andExpr(a,b), vc->orExpr(vc->andExpr(b,c),vc->andExpr(a,c)));
-}
-
-
-void add(ValidityChecker* vc, vector<Expr> a, vector<Expr> b, vector<Expr>& sum)
-{
- int i,N=a.size();
- Expr c = vc->falseExpr();
-
- for (i=0; i < N; i++)
- {
- sum.push_back(adder(vc,a[i],b[i],c));
- c = carry(vc,a[i],b[i],c);
- }
-}
-
-
-Expr vectorEq(ValidityChecker* vc, vector<Expr> a, vector<Expr> b)
-{
- int i, N=a.size();
- Expr result = vc->trueExpr();
-
- for (i=0; i < N; i++) {
- result = result && a[i].iffExpr(b[i]);
- }
- return result;
-}
-
-
-void test9(int N) {
- CLFlags flags = ValidityChecker::createFlags();
- // flags.setFlag("proofs",true);
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- int i;
- vector<Expr> a,b,sum1,sum2;
-
- for (i=0; i < N; i++) {
- a.push_back(vc->varExpr("a" + int2string(i), vc->boolType()));
- b.push_back(vc->varExpr("b" + int2string(i), vc->boolType()));
- }
-
- add(vc,a,b,sum1);
- add(vc,b,a,sum2);
-
- Expr q = vectorEq(vc,sum1,sum2);
-
- check(vc, q);
-
- // Proof p = vc->getProof();
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test9(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-Expr bvadder(ValidityChecker* vc, const Expr& a, const Expr& b, const Expr& c)
-{
- return vc->newBVXorExpr(a, vc->newBVXorExpr(b, c));
-}
-
-
-Expr bvcarry(ValidityChecker* vc, const Expr& a, const Expr& b, const Expr& c)
-{
- return vc->newBVOrExpr(vc->newBVAndExpr(a,b), vc->newBVOrExpr(vc->newBVAndExpr(b,c),vc->newBVAndExpr(a,c)));
-}
-
-
-void bvadd(ValidityChecker* vc, vector<Expr> a, vector<Expr> b, vector<Expr>& sum)
-{
- int i,N=a.size();
- Expr c = vc->newBVConstExpr(Rational(0), 1);
-
- for (i=0; i < N; i++)
- {
- sum.push_back(bvadder(vc,a[i],b[i],c));
- c = bvcarry(vc,a[i],b[i],c);
- }
-}
-
-
-Expr bvvectorEq(ValidityChecker* vc, vector<Expr> a, vector<Expr> b)
-{
- int i, N=a.size();
- Expr result = vc->newBVConstExpr(string("1"));
-
- for (i=0; i < N; i++) {
- result = vc->newBVAndExpr(result, vc->newBVXnorExpr(a[i], b[i]));
- }
- return result;
-}
-
-
-void bvtest9(int N) {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- int i;
- vector<Expr> avec,bvec,sum1vec,sum2;
-
- Expr a, b, sum1;
- a = vc->varExpr("a", vc->bitvecType(N));
- b = vc->varExpr("b", vc->bitvecType(N));
- vector<Expr> kids;
- kids.push_back(a);
- kids.push_back(b);
- sum1 = vc->newBVPlusExpr(N, kids);
-
- for (i=0; i < N; i++) {
- avec.push_back(vc->newBVExtractExpr(a, i, i));
- bvec.push_back(vc->newBVExtractExpr(b, i, i));
- sum1vec.push_back(vc->newBVExtractExpr(sum1, i, i));
- }
-
- bvadd(vc,avec,bvec,sum2);
-
- Expr q = bvvectorEq(vc,sum1vec,sum2);
-
- check(vc, vc->eqExpr(q,vc->newBVConstExpr(string("1"))));
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in bvtest9(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-// Test for memory leaks (run silently)
-void test10()
-{
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- // Create all expressions in a separate scope, so that they are
- // destroyed before vc is deleted.
-
- try {
- // Check x = y -> g(x,y) = g(y,x)
-
- Expr x = vc->varExpr("x", vc->realType());
- Expr y = vc->varExpr("y", vc->realType());
-
- Type real = vc->realType();
- vector<Type> RxR;
- RxR.push_back(real);
- RxR.push_back(real);
-
- Type realxreal2real = vc->funType(RxR, real);
- Op g = vc->createOp("g", realxreal2real);
-
- Expr gxy = vc->funExpr(g, x, y);
- Expr gyx = vc->funExpr(g, y, x);
-
- Expr e = vc->impliesExpr(vc->eqExpr(x,y),vc->eqExpr(gxy, gyx));
- check(vc, e, false);
-
- Op h = vc->createOp("h", realxreal2real);
-
- Expr hxy = vc->funExpr(h, x, y);
- Expr hyx = vc->funExpr(h, y, x);
-
- e = vc->impliesExpr(vc->eqExpr(x,y),vc->eqExpr(hxy, hyx));
- check(vc, e, false);
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test10(): \n" << e << endl;
- }
- // Make sure all Expr's are deleted first
- delete vc;
-}
-
-unsigned int printImpliedLiterals(ValidityChecker* vc)
-{
- unsigned int count = 0;
- cout << "Implied Literals:" << endl;
- Expr impLit = vc->getImpliedLiteral();
- while (!impLit.isNull()) {
- ++count;
- vc->printExpr(impLit);
- impLit = vc->getImpliedLiteral();
- }
- return count;
-}
-
-
-void test11()
-{
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Expr x = vc->varExpr("x", vc->realType());
- Expr y = vc->varExpr("y", vc->realType());
- Expr z = vc->varExpr("z", vc->realType());
-
- Type real = vc->realType();
- Type real2real = vc->funType(real, real);
- Type real2bool = vc->funType(real, vc->boolType());
- Op f = vc->createOp("f", real2real);
- Op p = vc->createOp("p", real2bool);
-
- Expr fx = vc->funExpr(f, x);
- Expr fy = vc->funExpr(f, y);
-
- Expr px = vc->funExpr(p, x);
- Expr py = vc->funExpr(p, y);
-
- Expr xeqy = vc->eqExpr(x, y);
- Expr yeqx = vc->eqExpr(y, x);
- Expr xeqz = vc->eqExpr(x, z);
- Expr zeqx = vc->eqExpr(z, x);
- Expr yeqz = vc->eqExpr(y, z);
- Expr zeqy = vc->eqExpr(z, y);
-
- unsigned int c;
-
- vc->registerAtom(vc->eqExpr(x,vc->ratExpr(0,1)));
- vc->registerAtom(xeqy);
- vc->registerAtom(yeqx);
- vc->registerAtom(xeqz);
- vc->registerAtom(zeqx);
- vc->registerAtom(yeqz);
- vc->registerAtom(zeqy);
- vc->registerAtom(px);
- vc->registerAtom(py);
- vc->registerAtom(vc->eqExpr(fx, fy));
-
- cout << "Push" << endl;
- vc->push();
-
- cout << "Assert x = y" << endl;
- vc->assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- EXPECT(c==3,"Implied literal error 0");
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert x /= z" << endl;
- vc->assertFormula(!xeqz);
- c = printImpliedLiterals(vc);
- EXPECT(c==4,"Implied literal error 1");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert y /= z" << endl;
- vc->assertFormula(!yeqz);
- c = printImpliedLiterals(vc);
- EXPECT(c==4,"Implied literal error 2");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert p(x)" << endl;
- vc->assertFormula(px);
- c = printImpliedLiterals(vc);
- EXPECT(c==2,"Implied literal error 3");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert p(y)" << endl;
- vc->assertFormula(py);
- c = printImpliedLiterals(vc);
- EXPECT(c==2,"Implied literal error 4");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert y = x" << endl;
- vc->assertFormula(yeqx);
- c = printImpliedLiterals(vc);
- EXPECT(c==3,"Implied literal error 5");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert p(x)" << endl;
- vc->assertFormula(px);
- c = printImpliedLiterals(vc);
- EXPECT(c==1,"Implied literal error 6");
- cout << "Assert x = y" << endl;
- vc->assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- EXPECT(c==4,"Implied literal error 7");
- cout << "Pop" << endl;
- vc->pop();
-
- cout << "Push" << endl;
- vc->push();
- cout << "Assert NOT p(x)" << endl;
- vc->assertFormula(!px);
- c = printImpliedLiterals(vc);
- EXPECT(c==1,"Implied literal error 8");
- cout << "Assert x = y" << endl;
- vc->assertFormula(xeqy);
- c = printImpliedLiterals(vc);
- EXPECT(c==4,"Implied literal error 9");
- cout << "Pop" << endl;
- vc->pop();
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test11(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test12()
-{
- ValidityChecker * vc = ValidityChecker::create( );
- try {
- Type realType = vc->realType();
- Type intType = vc->intType();
- Type boolType = vc->boolType();
- vc -> push();
- int initial_layer = vc->stackLevel();
- int initial_scope = vc->scopeLevel();
- Expr exprObj_trueID = vc->trueExpr();
- Expr exprObj_falseID = vc->notExpr(vc->trueExpr());
- vc->popto(initial_layer);
- EXPECT(vc->scopeLevel() == initial_scope, "Expected no change");
- EXPECT(vc->stackLevel() == initial_layer, "Expected no change");
- // TODO: what happens if we push and then popscope?
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test12(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test13()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs", false);
- flags.setFlag("dump-log", ".test13.cvc");
- ValidityChecker* vc = ValidityChecker::create(flags);
- try {
- Expr rat_one = vc->ratExpr(1);
- Expr rat_two = vc->ratExpr(2);
- Expr rat_minus_one = vc->ratExpr(-1);
-
- bool query_result;
- query_result = vc->query(vc->eqExpr(rat_two,rat_one));
- cout << "2=1 " << query_result << endl;
- query_result = vc->query(vc->eqExpr(rat_two,rat_minus_one));
- cout << "2=-1 " << query_result << endl;
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test13(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-Expr func1(ValidityChecker *vc) {
- // local Expr 'tmp'
- Expr tmp = vc->varExpr("tmp", vc->boolType());
- return vc->trueExpr();
-}
-
-
-void test14() {
- ValidityChecker *vc = ValidityChecker::create();
- try {
- // func call: ok
- Expr test1 = func1(vc);
-
- // func call: fail
- Expr test2 = func1(vc);
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test14(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test15() {
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs", false);
- ValidityChecker *vc = ValidityChecker::create(flags);
- try {
-
- /*****************************************************
- * array declaration *
- *****************************************************/
-/*
- // array: index type
- Type index_type = vc->subrangeType(vc->ratExpr(0),
- vc->ratExpr(3));
- // array: data type
- Type data_type = vc->subrangeType(vc->ratExpr(0),
- vc->ratExpr(3));
- // array type: [0 .. 3] of 0 .. 3
- Type array_type = vc->arrayType(index_type, data_type);
- Expr arr = vc->varExpr("array", array_type);
-
- // array: [1,1,0,0]
- arr = vc->writeExpr(arr, vc->ratExpr(0), vc->ratExpr(1));
- arr = vc->writeExpr(arr, vc->ratExpr(1), vc->ratExpr(1));
- arr = vc->writeExpr(arr, vc->ratExpr(2), vc->ratExpr(0));
- arr = vc->writeExpr(arr, vc->ratExpr(3), vc->ratExpr(0));
-*/
-
-
- /*****************************************************
- * forall Expr *
- *****************************************************/
-/*
- // for loop: index
- Expr id = vc->boundVarExpr("id", "0", vc->subrangeType(vc->ratExpr(0),
- vc->ratExpr(2)));
- vector<Expr> vars;
- vars.push_back(id);
-
- // for loop: body
- Expr for_body = vc->leExpr(vc->readExpr(arr, id),
- vc->readExpr(arr, vc->plusExpr(id, vc->ratExpr(1))));
- // forall expr
- Expr forall_expr = vc->forallExpr(vars, for_body);
-
- vc->push();
- check(vc, forall_expr);
-
- vector<Expr> assertions;
- cout << "Scope level: " << vc->scopeLevel() << endl;
- cout << "Counter-example:" << endl;
- //vc->getCounterExample(assertions);
- for (unsigned i = 0; i < assertions.size(); ++i) {
- vc->printExpr(assertions[i]);
- }
- cout << "End of counter-example" << endl << endl;
- vc->pop();
- */
- /*****************************************************
- * manual expansion *
- *****************************************************/
-/*
- Expr e1 = vc->leExpr(vc->readExpr(arr, vc->ratExpr(0)),
- vc->readExpr(arr, vc->ratExpr(1)));
- Expr e2 = vc->leExpr(vc->readExpr(arr, vc->ratExpr(1)),
- vc->readExpr(arr, vc->ratExpr(2)));
- Expr e3 = vc->leExpr(vc->readExpr(arr, vc->ratExpr(2)),
- vc->readExpr(arr, vc->ratExpr(3)));
- Expr manual_expr = vc->andExpr(e1, vc->andExpr(e2, e3));
-*/
-
-
- /*****************************************************
- * exists Expr *
- *****************************************************/
-/*
- // exists: index
- Expr id_ex = vc->varExpr("id_ex", vc->subrangeType(vc->ratExpr(0),
- vc->ratExpr(2)));
- vector<Expr> vars_ex;
- vars_ex.push_back(id_ex);
-
- // exists: body
- Expr ex_body = vc->gtExpr(vc->readExpr(arr, id_ex),
- vc->readExpr(arr, vc->plusExpr(id_ex, vc->ratExpr(1))));
- // exists expr
- Expr ex_expr = vc->existsExpr(vars_ex, ex_body);
-*/
-
-
-
- /*****************************************************
- * ??? forall <==> manual expansion *
- *****************************************************/
- /*
- cout << endl << "Checking forallExpr <==> manual expansion ..." << endl;
- if (vc->query(vc->iffExpr(forall_expr, manual_expr)))
- cout << " -- yes." << endl;
- else {
- cout << " -- no, with counter examples as " << endl;
-
- vector<Expr> assert1;
- vc->getCounterExample(assert1);
- for (unsigned int i = 0; i < assert1.size(); i ++)
- vc->printExpr(assert1[i]);
-
- }
- cout << endl;
-*/
-
-
- /*****************************************************
- * ??? !forall <==> existsExpr *
- *****************************************************/
- /*
- cout << endl << "Checking !forallExpr <==> existsExpr ..." << endl;
- if (vc->query(vc->iffExpr(vc->notExpr(forall_expr), ex_expr)))
- cout << " -- yes." << endl;
- else if (vc->incomplete()) {
- cout << " -- incomplete:" << endl;
- vector<string> reasons;
- vc->incomplete(reasons);
- for (unsigned int i = 0; i < reasons.size(); ++i)
- cout << reasons[i] << endl;
- }
- else {
- cout << " -- no, with counter examples as " << endl;
-
- vector<Expr> assert2;
- //vc->getCounterExample(assert2);
- for (unsigned int i = 0; i < assert2.size(); i ++)
- vc->printExpr(assert2[i]);
- }
-
- cout << endl << "End of testcases." << endl << endl;
-*/
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test15(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test16() {
- ValidityChecker *vc = ValidityChecker::create();
- try {
- /*
- Type zto100 = vc->subrangeType(vc->ratExpr(0), vc->ratExpr(100));
- Expr mem = vc->varExpr("mem", vc->arrayType(zto100, vc->intType()));
- Expr a = vc->varExpr("a", zto100);
- Expr b = vc->varExpr("b", zto100);
-
- Expr lhs = vc->readExpr(vc->writeExpr(mem, a, vc->ratExpr(30)), b);
- Expr rhs = vc->readExpr(vc->writeExpr(mem, b, vc->ratExpr(40)), a);
-
- Expr q = vc->impliesExpr(vc->notExpr(vc->eqExpr(a, b)), vc->eqExpr(lhs, rhs));
-
- check(vc, q);
-
- vector<Expr> assertions;
- cout << "Scope level: " << vc->scopeLevel() << endl;
- cout << "Counter-example:" << endl;
- vc->getCounterExample(assertions);
- EXPECT(assertions.size() > 0, "Expected non-empty counter-example");
- for (unsigned i = 0; i < assertions.size(); ++i) {
- vc->printExpr(assertions[i]);
- }
- cout << "End of counter-example" << endl << endl;
-
- ExprMap<Expr> m;
- vc->getConcreteModel(m);
- ExprMap<Expr>::iterator it = m.begin(), end = m.end();
- if(it == end)
- cout << " Did not find concrete model for any vars" << endl;
- else {
- cout << "%Satisfiable Variable Assignment: % \n";
- for(; it!= end; it++) {
- Expr eq;
- if(it->first.getType().isBool()) {
- EXPECT((it->second).isBoolConst(),
- "Bad variable assignement: e = "+(it->first).toString()
- +"\n\n val = "+(it->second).toString());
- if((it->second).isTrue())
- eq = it->first;
- else
- eq = !(it->first);
- }
- else
- eq = (it->first).eqExpr(it->second);
- //cout << Expr(ASSERT, eq) << "\n";
- }
- }
-*/
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test16(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test17() {
- ValidityChecker *vc = ValidityChecker::create();
- try {
- try {
- vector<string> selectors;
- vector<Expr> types;
-
- selectors.push_back("car");
- types.push_back(vc->intType().getExpr());
- selectors.push_back("cdr");
- types.push_back(vc->stringExpr("list"));
-
- Type badList = vc->dataType("list", "cons", selectors, types);
- EXPECT(false, "Typechecking exception expected");
- } catch(const TypecheckException&) {
- // fall through
- }
- delete vc;
- vc = ValidityChecker::create();
- {
- vector<string> constructors;
- vector<vector<string> > selectors(2);
- vector<vector<Expr> > types(2);
-
- constructors.push_back("cons");
- selectors[0].push_back("car");
- types[0].push_back(vc->intType().getExpr());
- selectors[0].push_back("cdr");
- types[0].push_back(vc->stringExpr("list"));
- constructors.push_back("null");
-
- Type list = vc->dataType("list", constructors, selectors, types);
-
- Expr x = vc->varExpr("x", vc->intType());
- Expr y = vc->varExpr("y", list);
-
- vector<Expr> args;
- args.push_back(x);
- args.push_back(y);
- Expr cons = vc->datatypeConsExpr("cons", args);
-
- Expr sel = vc->datatypeSelExpr("car", cons);
- bool b = check(vc, vc->eqExpr(sel, x));
- EXPECT(b, "Should be valid");
-
- }
- delete vc;
- vc = ValidityChecker::create();
- try {
- vector<string> names;
- vector<vector<string> > constructors(2);
- vector<vector<vector<string> > > selectors(2);
- vector<vector<vector<Expr> > > types(2);
- vector<Type> returnTypes;
-
- names.push_back("list1");
-
- selectors[0].resize(1);
- types[0].resize(1);
- constructors[0].push_back("cons1");
- selectors[0][0].push_back("car1");
- types[0][0].push_back(vc->intType().getExpr());
- selectors[0][0].push_back("cdr1");
- types[0][0].push_back(vc->stringExpr("list2"));
-
- names.push_back("list2");
-
- selectors[1].resize(1);
- types[1].resize(1);
- constructors[1].push_back("cons2");
- selectors[0][0].push_back("car2");
- types[0][0].push_back(vc->intType().getExpr());
- selectors[0][0].push_back("cdr2");
- types[0][0].push_back(vc->stringExpr("list1"));
-
- vc->dataType(names, constructors, selectors, types, returnTypes);
- EXPECT(false, "Typechecking exception expected");
- } catch(const TypecheckException&) {
- // fall through
- }
- delete vc;
- vc = ValidityChecker::create();
- {
- vector<string> names;
- vector<vector<string> > constructors(2);
- vector<vector<vector<string> > > selectors(2);
- vector<vector<vector<Expr> > > types(2);
- vector<Type> returnTypes;
-
- names.push_back("list1");
-
- selectors[0].resize(1);
- types[0].resize(1);
- constructors[0].push_back("cons1");
- selectors[0][0].push_back("car1");
- types[0][0].push_back(vc->intType().getExpr());
- selectors[0][0].push_back("cdr1");
- types[0][0].push_back(vc->stringExpr("list2"));
-
- names.push_back("list2");
-
- selectors[1].resize(2);
- types[1].resize(2);
- constructors[1].push_back("cons2");
- selectors[1][0].push_back("car2");
- types[1][0].push_back(vc->intType().getExpr());
- selectors[1][0].push_back("cdr2");
- types[1][0].push_back(vc->stringExpr("list1"));
- constructors[1].push_back("null");
-
- vc->dataType(names, constructors, selectors, types, returnTypes);
-
- Type list1 = returnTypes[0];
- Type list2 = returnTypes[1];
-
- Expr x = vc->varExpr("x", vc->intType());
- Expr y = vc->varExpr("y", list2);
- Expr z = vc->varExpr("z", list1);
-
- vector<Expr> args;
- args.push_back(x);
- args.push_back(y);
- Expr cons1 = vc->datatypeConsExpr("cons1", args);
-
- Expr isnull = vc->datatypeTestExpr("null", y);
- Expr hyp = vc->andExpr(vc->eqExpr(z, cons1), isnull);
-
- args.clear();
- Expr null = vc->datatypeConsExpr("null", args);
-
- args.push_back(x);
- args.push_back(null);
- Expr cons1_2 = vc->datatypeConsExpr("cons1", args);
-
- bool b = check(vc, vc->impliesExpr(hyp, vc->eqExpr(z, cons1_2)));
- EXPECT(b, "Should be valid");
-
- }
- delete vc;
- vc = ValidityChecker::create();
- {
- vector<string> constructors;
- vector<vector<string> > selectors(2);
- vector<vector<Expr> > types(2);
-
- constructors.push_back("A");
- constructors.push_back("B");
-
- Type two = vc->dataType("two", constructors, selectors, types);
-
- Expr x = vc->varExpr("x", two);
- Expr y = vc->varExpr("y", two);
- Expr z = vc->varExpr("z", two);
-
- vector<Expr> args;
- args.push_back(!vc->eqExpr(x,y));
- args.push_back(!vc->eqExpr(y,z));
- args.push_back(!vc->eqExpr(x,z));
-
- bool b = check(vc, !vc->andExpr(args));
- EXPECT(b, "Should be valid");
-
- }
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test17(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test18()
-{
- CLFlags flags = ValidityChecker::createFlags();
- flags.setFlag("tcc", true);
- ValidityChecker *vc = ValidityChecker::create(flags);
- try {
- vector<string> names;
- vector<vector<string> > constructors(3);
- vector<vector<vector<string> > > selectors(3);
- vector<vector<vector<Expr> > > types(3);
- vector<Type> returnTypes;
-
- names.push_back("nat");
-
- selectors[0].resize(2);
- types[0].resize(2);
- constructors[0].push_back("zero");
- constructors[0].push_back("succ");
- selectors[0][1].push_back("pred");
- types[0][1].push_back(vc->stringExpr("nat"));
-
- names.push_back("list");
-
- selectors[1].resize(2);
- types[1].resize(2);
- constructors[1].push_back("cons");
- selectors[1][0].push_back("car");
- types[1][0].push_back(vc->stringExpr("tree"));
- selectors[1][0].push_back("cdr");
- types[1][0].push_back(vc->stringExpr("list"));
- constructors[1].push_back("null");
-
- names.push_back("tree");
-
- selectors[2].resize(2);
- types[2].resize(2);
- constructors[2].push_back("leaf");
- constructors[2].push_back("node");
- selectors[2][1].push_back("data");
- types[2][1].push_back(vc->stringExpr("nat"));
- selectors[2][1].push_back("children");
- types[2][1].push_back(vc->stringExpr("list"));
-
- vc->dataType(names, constructors, selectors, types, returnTypes);
-
- Type nat = returnTypes[0];
- Type listType = returnTypes[1];
- Type tree = returnTypes[2];
-
- Expr x = vc->varExpr("x", nat);
-
- vector<Expr> args;
- Expr zero = vc->datatypeConsExpr("zero", args);
- Expr null = vc->datatypeConsExpr("null", args);
- Expr leaf = vc->datatypeConsExpr("leaf", args);
-
- vc->push();
- try {
- check(vc, vc->notExpr(vc->eqExpr(zero, null)));
- // TCCs not supported by CVC4 yet
- //EXPECT(false, "Should have caught tcc exception");
- } catch(const TypecheckException&) { }
-
- vc->pop();
- args.push_back(vc->datatypeSelExpr("pred",x));
- Expr spx = vc->datatypeConsExpr("succ", args);
- Expr spxeqx = vc->eqExpr(spx, x);
- vc->push();
- try {
- check(vc, spxeqx);
- // TCCs not supported by CVC4 yet
- //EXPECT(false, "Should have caught tcc exception");
- } catch(const TypecheckException&) { }
-
- vc->pop();
- bool b = check(vc, vc->impliesExpr(vc->datatypeTestExpr("succ", x), spxeqx));
- EXPECT(b, "Should be valid");
-
- b = check(vc, vc->orExpr(vc->datatypeTestExpr("zero", x),
- vc->datatypeTestExpr("succ", x)));
- EXPECT(b, "Should be valid");
-
- Expr y = vc->varExpr("y", nat);
- Expr xeqy = vc->eqExpr(x, y);
- args.clear();
- args.push_back(x);
- Expr sx = vc->datatypeConsExpr("succ", args);
- args.clear();
- args.push_back(y);
- Expr sy = vc->datatypeConsExpr("succ", args);
- Expr sxeqsy = vc->eqExpr(sx,sy);
- b = check(vc, vc->impliesExpr(xeqy, sxeqsy));
- EXPECT(b, "Should be valid");
-
- b = check(vc, vc->notExpr(vc->eqExpr(sx, zero)));
- EXPECT(b, "Should be valid");
-
- b = check(vc, vc->impliesExpr(sxeqsy, xeqy));
- EXPECT(b, "Should be valid");
-
- b = check(vc, vc->notExpr(vc->eqExpr(sx, x)));
- EXPECT(b, "Should be valid");
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test18(): \n" << e << endl;
- }
- delete vc;
-}
-
-void test19()
-{
- CVC3::CLFlags flags = CVC3::ValidityChecker::createFlags();
- flags.setFlag("dagify-exprs", false);
- CVC3::ValidityChecker* vc = CVC3::ValidityChecker::create(flags);
- try {
- CVC3::Type RealType=(vc->realType());
- CVC3::Type IntType=(vc->intType());
- CVC3::Type BoolType=(vc->boolType());
- CVC3::Type PtrType=(RealType);
- CVC3::Type HeapType=(vc->arrayType(PtrType, RealType));
-
- // -----------------
- //ASSERT(FORALL (CVCi: REAL): (Hs[CVCi] = Ht[CVCi]));
- //QUERY(Hs[(t6 + (3 * 1))] = Ht[(t6 + (3 * 1))]);
- CVC3::Expr Ad = vc->boundVarExpr("CVCi", "CVCi", RealType);
- CVC3::Expr Hs = vc->varExpr("Hs", HeapType);
- CVC3::Expr Ht = vc->varExpr("Ht", HeapType);
- CVC3::Expr t6 = vc->varExpr("t6", RealType);
-
- vector<CVC3::Expr> Vars;
- Vars.push_back(Ad);
- // Body= (Hs[Ad] = Ht[Ad])
- CVC3::Expr Body = vc->eqExpr(vc->readExpr(Hs, Ad), vc->readExpr(Ht, Ad));
-
- //A = forall (~i:REAL): Body
- CVC3::Expr A = vc->forallExpr(Vars, Body);
-
- // Q = (Hs[t6] = Ht[t6])
- CVC3::Expr Q = vc->eqExpr(vc->readExpr(Hs, t6), vc->readExpr(Ht, t6));
-
- // ----------- CHECK A -> Q
- vc->push();
-
- vc->assertFormula(A);
-
- cout<<"Checking formula "<<Q<<"\n in context "<<A<<"\n";
-
- bool Succ = vc->query(Q);
-
- EXPECT(Succ, "Expected valid formula");
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test19(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test20() {
- ValidityChecker *vc = ValidityChecker::create();
- try {
- vector<string> names;
- vector<vector<string> > constructors(3);
- vector<vector<vector<string> > > selectors(3);
- vector<vector<vector<Expr> > > types(3);
- vector<Type> returnTypes;
-
- names.push_back("pair");
-
- selectors[0].resize(1);
- types[0].resize(1);
- constructors[0].push_back("p");
- selectors[0][0].push_back("p1");
- types[0][0].push_back(vc->stringExpr("t1"));
- selectors[0][0].push_back("p2");
- types[0][0].push_back(vc->stringExpr("t2"));
-
- names.push_back("t1");
-
- selectors[1].resize(5);
- types[1].resize(5);
- constructors[1].push_back("a");
- constructors[1].push_back("b");
- constructors[1].push_back("c");
- constructors[1].push_back("d");
- constructors[1].push_back("e");
-
- names.push_back("t2");
-
- selectors[2].resize(1);
- types[2].resize(1);
- constructors[2].push_back("cons");
- selectors[2][0].push_back("s0");
- types[2][0].push_back(vc->bitvecType(2).getExpr());
- //selectors[2][0].push_back("s1");
- //types[2][0].push_back(vc->arrayType(vc->intType(), vc->subrangeType(vc->ratExpr(0), vc->ratExpr(0))).getExpr());
-
- vc->dataType(names, constructors, selectors, types, returnTypes);
-
- EXPECT(returnTypes[0].card() == CARD_FINITE, "Expected finite");
- Unsigned size = returnTypes[0].sizeFinite();
- Unsigned i = 0;
- for (; i < size; ++i) {
- cout << i << ": ";
- vc->printExpr(returnTypes[0].enumerateFinite(i));
- }
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test20(): \n" << e << endl;
- }
- delete vc;
-}
-
-void test21() {
- ValidityChecker *vc = ValidityChecker::create();
-
- try {
- Type t = vc->realType();
-
- Expr x1 = vc->varExpr("x",t);
-
- Expr x2 = vc->exprFromString("x");
- cout << "x1: " << x1;
- cout << "\nx2: " << x2;
- EXPECT(x1 == x2, "Expected x1 == x2");
-
- Expr x3 = vc->exprFromString("x", SMTLIB_V2_LANG);
- cout << "\nx3: " << x3;
- EXPECT(x1 == x3, "Expected x1 == x3");
-
- Expr y1 = vc->varExpr("y",t);
- Expr y2 = vc->exprFromString("y");
- cout << "\ny1: " << y1;
- cout << "\ny2: " << y2;
- EXPECT(y1 == y2, "Expected y1 == y2");
-
- Expr y3 = vc->exprFromString("y", SMTLIB_V2_LANG);
- cout << "\ny3: " << y3;
- EXPECT(y1 == y3, "Expected y1 == y3");
-
- Expr a1 = vc->gtExpr(x1,vc->ratExpr(0,1));
- Expr a2 = vc->exprFromString("x > 0");
- cout << "\na1: " << a1;
- cout << "\na2: " << a2;
- EXPECT(a1 == a2, "Expected a1 == a2");
-
- Expr a3 = vc->exprFromString("(> x 0)", SMTLIB_V2_LANG);
- cout << "\na3: " << a3;
- EXPECT(a1 == a3, "Expected a1 == a3");
-
- Expr b1 = vc->ltExpr(x1,y1);
- Expr b2 = vc->exprFromString ("x < y");
- cout << "\nb1: " << b1;
- cout << "\nb2: " << b2;
- EXPECT(b1 == b2, "Expected b1 == b2");
-
- Expr b3 = vc->exprFromString ("(< x y)", SMTLIB_V2_LANG);
- cout << "\nb3: " << b3;
- EXPECT(b1 == b3, "Expected b1 == b3");
-
- Expr e1 = a1 && b1;
- Expr e2 = vc->exprFromString("x > 0 AND x < y");
- cout << "\ne1: " << e1;
- cout << "\ne2: " << e2;
- EXPECT(e1 == e2, "Expected e1 == e2");
-
- Expr e3 = vc->exprFromString("(and (> x 0) (< x y))", SMTLIB_V2_LANG);
- cout << "\ne3: " << e3;
- EXPECT(e1 == e3, "Expected e1 == e3");
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test21(): \n" << e << endl;
- }
- delete vc;
-}
-
-void test22() {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type intType(vc->intType());
- Type fType(vc->funType(intType,intType));
-
- Op f(vc->createOp("f",fType));
- Expr x(vc->varExpr("x",intType));
- Expr fx(vc->exprFromString("f(x)"));
-
- Expr p(vc->exprFromString("FORALL (x:INT) : x < f(x)"));
-
- vector<vector<Expr> > patternvv;
- vector<Expr> patternv;
- patternv.push_back(fx);
- patternvv.push_back(patternv);
-
- vc->setTriggers(p,patternv);
- EXPECT( eqExprVecVecs(p.getTriggers(), patternvv),
- "Expected p.getTriggers() == patternvv: " + p.toString() );
-
- vc->setTriggers(p,patternvv);
-
- EXPECT( eqExprVecVecs(p.getTriggers(), patternvv),
- "Expected p.getTriggers() == patternvv: " + p.toString() );
-
- // [chris 10/4/2009] Not sure why, but this fails
-
- // Expr q(vc->exprFromString("FORALL (x:INT) : PATTERN (f(x)) : x < f(x)"));
-
- // EXPECT( eqExprVecVecs(q.getTriggers(), patternvv),
- // "Expected q.getTriggers() == patternvv" + q.toString());
-
- vector<Expr> vars;
- vars.push_back(x);
- Expr r(vc->forallExpr( vars, vc->ltExpr(x,fx), patternvv ));
-
- EXPECT( eqExprVecVecs(r.getTriggers(), patternvv),
- "Expected r.getTriggers() == patternvv: " + r.toString() );
-
- Expr s(vc->exprFromString("FORALL (x:INT) : x > f(x)"));
- vc->setTrigger(s,fx);
-
- std::ostringstream stringHolder("");
- std::vector<std::vector<Expr> > trigsvv = s.getTriggers();
- stringHolder << trigsvv.size();
- EXPECT( trigsvv.size() == 1,
- "Expected s.getTriggers().size() == 1: " + stringHolder.str() );
-
- stringHolder.str("");
- std::vector<Expr> trigsv = trigsvv[0];
- stringHolder << trigsv.size();
-
- EXPECT( trigsv.size() == 1,
- "Expected s.getTriggers()[0].size() == 1: "
- + stringHolder.str() );
-
- EXPECT( trigsv[0] == fx,
- "Expected s.getTriggers()[0][0] == fx: "
- + (trigsv[0].toString()) );
-
- stringHolder.str("");
- Expr t(vc->exprFromString("FORALL (x:INT) : x > f(x)"));
- vc->setMultiTrigger(t,patternv);
- trigsvv = t.getTriggers();
- stringHolder << trigsvv.size();
- EXPECT( trigsvv.size() == 1,
- "Expected t.getTriggers().size() == 1: " + stringHolder.str() );
-
- stringHolder.str("");
- trigsv = trigsvv[0];
- stringHolder << trigsv.size();
- EXPECT( trigsv.size() == 1,
- "Expected t.getTriggers()[0].size() == 1: "
- + stringHolder.str() );
-
- EXPECT( trigsv[0] == fx,
- "Expected t.getTriggers()[0][0] == fx: "
- + (trigsv[0].toString()) );
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test22(): \n" << e << endl;
- }
- delete vc;
-}
-
-void test23() {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type intType(vc->intType());
- Type fType(vc->funType(intType,intType));
-
- Expr x(vc->varExpr("x",intType));
- Expr y(vc->varExpr("y",intType));
- Expr a(vc->varExpr("a",intType));
- Expr b(vc->varExpr("b",intType));
-
- Expr s(vc->exprFromString("x < y"));
- Expr t(vc->exprFromString("a < b"));
-
- cout << "s=" << s << "\nt=" << t << "\n";
-
- std::vector<Expr> oldExprs, newExprs;
- oldExprs.push_back(x);
- oldExprs.push_back(y);
- newExprs.push_back(a);
- newExprs.push_back(b);
-
- Expr u(s.substExpr(oldExprs,newExprs));
- cout << "u=" << u << "\n";
-
- EXPECT( t == u, "Expected t==u" );
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test23(): \n" << e << endl;
- }
- delete vc;
-}
-
-void test24() {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type intType(vc->intType());
- Type aType(vc->arrayType(intType,intType));
-
- Expr a(vc->varExpr("a",aType));
- Expr x(vc->varExpr("x",intType));
- Expr ax(vc->exprFromString("a[x]"));
-
- Expr p(vc->exprFromString("FORALL (x:INT) : PATTERN (a[x]) : x < a[x]"));
-
- cout << p << "\n";
-
- vector<vector<Expr> > pTriggers(p.getTriggers());
- EXPECT( pTriggers.size() == 1,
- "Actual: " + int2string(pTriggers.size()));
- EXPECT( pTriggers[0].size() == 1,
- "Actual: " + int2string( pTriggers[0].size()));
- /* We can't check that the trigger == ax, because x will have
- * been replaced with a bvar
- */
- EXPECT( pTriggers[0][0].getKind() == READ,
- "Actual: " + int2string(pTriggers[0][0].getKind()));
- EXPECT( pTriggers[0][0][0] == a,
- "Actual: " + pTriggers[0][0][0].toString() );
-
- Expr aPrime(vc->varExpr("a'",aType));
- Expr axPrime(vc->exprFromString("a'[x]"));
-
- ExprHashMap<Expr> substMap;
- substMap.insert(a,aPrime);
-
- Expr q(p.substExpr(substMap));
-
- cout << q << "\n";
-
- vector<vector<Expr> > qTriggers(q.getTriggers());
- EXPECT( qTriggers.size() == 1,
- "Actual: " +
- int2string(qTriggers.size()));
- EXPECT( qTriggers[0].size() == 1,
- "Actual: " +
- int2string(qTriggers[0].size()));
- EXPECT( qTriggers[0][0].getKind() == READ,
- "Actual: " +
- int2string(qTriggers[0][0].getKind()));
- EXPECT( qTriggers[0][0][0] == aPrime,
- "Actual: " + qTriggers[0][0][0].toString() );
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test24(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test25() {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type realType(vc->realType());
-
- Expr x = vc->ratExpr("-0.1");
- cout << "-0.1: " << x << endl;
- Expr y = vc->ratExpr("-1/10");
- cout << "-1/10: " << y << endl;
- Expr z = vc->ratExpr("-1","10",10);
- cout << "-1 over 10: " << z << endl;
- Expr w = vc->ratExpr(-1,10);
- cout << "-1 over 10 (ints): " << w << endl;
-
- EXPECT(x == y && y == z && z == w, "Error in rational constants");
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test25(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-void test26() {
- CLFlags flags = ValidityChecker::createFlags();
- ValidityChecker* vc = ValidityChecker::create(flags);
-
- try {
- Type bvType(vc->bitvecType(32));
-
- Expr x = vc->varExpr("x", bvType);
- Expr e1 = vc->newFixedConstWidthLeftShiftExpr(x, 16);
- Expr e2 = vc->newBVSHL(x, vc->newBVConstExpr(16, 32));
-
- bool b = check(vc, vc->eqExpr(e1, e2));
- EXPECT(b, "Should be valid");
-
- e1 = vc->newFixedRightShiftExpr(x, 16);
- e2 = vc->newBVLSHR(x, vc->newBVConstExpr(16, 32));
-
- b = check(vc, vc->eqExpr(e1, e2));
- EXPECT(b, "Should be valid");
-
- e2 = vc->newBVASHR(x, vc->newBVConstExpr(16, 32));
- b = check(vc, vc->eqExpr(e1, e2));
- EXPECT(!b, "Should be invalid");
-
- } catch(const Exception& e) {
- exitStatus = 1;
- cout << "*** Exception caught in test26(): \n" << e << endl;
- }
- delete vc;
-}
-
-
-int main(int argc, char** argv)
-{
- int regressLevel = 3;
- if (argc > 1) regressLevel = atoi(argv[1]);
- cout << "Running API test, regress level = " << regressLevel << endl;
- exitStatus = 0;
-
- try {
- // [MGD for CVC4] This is a CVC3 test, and many tests had to be commented
- // out for CVC4 since the functionality is either unsupported or
- // as-yet-unimplemented in CVC4's compatibility layer. For example,
- // subranges, predicate subtyping, quantifiers, and string expressions
- // are unavailable. Also, Exprs and Types are distinct in CVC4 and it's
- // not clear how to implement Type::getExpr(), and Exprs and Ops are
- // indistinguishable, so getOp() and getOpExpr() have the same result.
-
- cout << "\n}\ntest26(): {" << endl;
- test26();
- //cout << "\ntest(): {" << endl;
- //test();
- cout << "\n}\ntest1(): {" << endl;
- test1();
- cout << "\n}\n\ntest2(): {" << endl;
- test2();
- cout << "\n}\n\ntest3(): {" << endl;
- test3();
- cout << "\n}\n\ntest4(): {" << endl;
- test4();
- if (regressLevel > 0) {
- cout << "\n}\n\ntest5(): {" << endl;
- test5();
- }
- cout << "\n}\n\ntest6(): {" << endl;
- test6();
- cout << "\n}\n\ntest7(): {" << endl;
- test7();
- //cout << "\n}\n\ntest8(): {" << endl;
- //test8();
- cout << "\n}\n\ntest9(" << 10*regressLevel+10 << "): {" << endl;
- test9(10*regressLevel+10);
- cout << "\nbvtest9(): {" << endl;
- bvtest9(regressLevel*3+2);
- cout << "\n}" << endl;
-
- // Test for obvious memory leaks
- int limit = 100 * regressLevel+10;
- for(int i=0; i<limit; ++i) {
- if(i % 100 == 0) cout << "test10[" << i << "]" << endl;
- test10();
- }
-
- //cout << "\ntest11(): {" << endl;
- //test11();
- cout << "\n}\ntest12(): {" << endl;
- test12();
- cout << "\n}\ntest13(): {" << endl;
- test13();
- cout << "\n}\ntest14(): {" << endl;
- test14();
- //cout << "\n}\ntest15(): {" << endl;
- //test15();
- //cout << "\n}\ntest16(): {" << endl;
- //test16();
- cout << "\n}\ntest17(): {" << endl;
- test17();
- cout << "\n}\ntest18(): {" << endl;
- test18();
- cout << "\n}\ntest19(): {" << endl;
- test19();
- cout << "\ntest20(): {" << endl;
- test20();
- cout << "\n}\ntest21(): {" << endl;
- test21();
- //cout << "\n}\ntest22(): {" << endl;
- //test22();
- cout << "\n}\ntest23(): {" << endl;
- test23();
- cout << "\n}\ntest24(): {" << endl;
- test24();
- cout << "\n}\ntest25(): {" << endl;
- test25();
-
- cout << "\n}" << endl;
-
- } catch(const Exception& e) {
- cout << "*** Exception caught: \n" << e << endl;
- exitStatus = 1;
- }
- if(exitStatus == 0)
- cout << "Program exits successfully." << endl;
- else
- cout << "Program exits with error status = " << exitStatus << "." << endl;
- return exitStatus;
-}