ruby.cpp \
tcl.cpp
-EXTRA_DIST = swig.h
+EXTRA_DIST = \
+ swig.h \
+ java_iterator_adapter.h \
+ java_output_stream_adapter.h
MOSTLYCLEANFILES = \
.swig_deps \
$(AM_V_CXX)$(LTCXXCOMPILE) -c $(JAVA_CPPFLAGS) $(java_libcvc4jni_la_CXXFLAGS) -o $@ $<
CVC4.jar: java.cpp
$(AM_V_GEN) \
- (cd java; \
- rm -fr classes; \
- mkdir -p classes; \
- $(JAVAC) -classpath . -d classes `find . -name '*.java'`; \
- cd classes); \
+ (cd java && \
+ rm -fr classes && \
+ mkdir -p classes && \
+ $(JAVAC) -classpath . -d classes `find . -name '*.java'` && \
+ cd classes) && \
$(JAR) cf $@ -C java/classes .
#java.cpp:;
csharp.lo: csharp.cpp
--- /dev/null
+namespace CVC4 {
+
+template <class T>
+class JavaIteratorAdapter {
+ const T& d_t;
+ typename T::const_iterator d_it;
+
+public:
+ JavaIteratorAdapter(const T& t) :
+ d_t(t),
+ d_it(d_t.begin()) {
+ }
+
+ bool hasNext() {
+ return d_it != d_t.end();
+ }
+
+ typename T::const_iterator::value_type getNext() {
+ typename T::const_iterator::value_type ret = *d_it;
+ ++d_it;
+ return ret;
+ }
+};/* class JavaIteratorAdapter<T> */
+
+}/* CVC4 namespace */
--- /dev/null
+namespace CVC4 {
+
+class JavaOutputStreamAdapter {
+ std::stringstream d_ss;
+
+public:
+ JavaOutputStreamAdapter() { }
+
+ std::string toString() { return d_ss.str(); }
+
+};/* class JavaOutputStreamAdapter */
+
+}/* CVC4 namespace */
%include "java/arrays_java.i" // C arrays to Java arrays
%include "java/various.i" // map char** to java.lang.String[]
+%typemap(jni) std::ostream& "jlong"
+%typemap(jtype) std::ostream& "long"
+%typemap(jstype) std::ostream& "java.io.OutputStream"
+%typemap(javain, pre=" edu.nyu.acsys.CVC4.JavaOutputStreamAdapter temp$javainput = new edu.nyu.acsys.CVC4.JavaOutputStreamAdapter();", pgcppname="temp$javainput", post=" new java.io.PrintStream($javainput).print(temp$javainput.toString());") std::ostream& "edu.nyu.acsys.CVC4.JavaOutputStreamAdapter.getCPtr(temp$javainput)"
+
#endif /* SWIGJAVA */
%include "util/integer.i"
%include "util/rational.i"
-%include "util/statistics.i"
%include "util/exception.i"
%include "util/language.i"
%include "options/options.i"
%include "util/cardinality.i"
%include "util/bool.i"
%include "util/sexpr.i"
+%include "util/statistics.i"
%include "util/output.i"
%include "util/result.i"
%include "util/configuration.i"
%include "util/subrange_bound.i"
%include "util/array.i"
%include "util/array_store_all.i"
+%include "util/predicate.i"
%include "util/hash.i"
%include "expr/type.i"
%include "util/ascription_type.i"
%include "util/datatype.i"
+%include "util/uninterpreted_constant.i"
%include "expr/kind.i"
%include "expr/expr.i"
%include "expr/symbol_table.i"
%include "expr/expr_manager.i"
%include "expr/expr_stream.i"
+%include "expr/variable_type_map.i"
+
+%include "theory/logic_info.i"
%include "smt/smt_engine.i"
%include "smt/modal_exception.i"
command.i \
type.i \
kind.i \
- expr.i
+ expr.i \
+ variable_type_map.i
BUILT_SOURCES = \
kind.h \
%ignore CVC4::operator<<(std::ostream&, const Command*) throw();
%ignore CVC4::operator<<(std::ostream&, BenchmarkStatus status) throw();
+%ignore CVC4::GetProofCommand;
+
%rename(beginConst) CVC4::CommandSequence::begin() const throw();
%rename(endConst) CVC4::CommandSequence::end() const throw();
%ignore CVC4::ExprManager::mkExpr(Expr, const std::vector<Expr>&);
#endif /* SWIGOCAML */
+%ignore CVC4::stats::getStatisticsRegistry(ExprManager*);
+
%include "expr/expr_manager.h"
%template(mkConst) CVC4::ExprManager::mkConst<CVC4::TypeConstant>;
--- /dev/null
+%{
+#include "expr/variable_type_map.h"
+%}
+
+%rename(get) CVC4::VariableTypeMap::operator[](Expr);
+%rename(get) CVC4::VariableTypeMap::operator[](Type);
+
+%include "expr/variable_type_map.h"
}
static void toStream(std::ostream& out, const SetBenchmarkLogicCommand* c) throw() {
- out << "% (set-logic " << c->getLogic() << ")";
+ out << "OPTION \"logic\" \"" << c->getLogic() << "\";";
}
static void toStream(std::ostream& out, const SetInfoCommand* c) throw() {
}
static void toStream(std::ostream& out, const CommentCommand* c) throw() {
- out << "(set-info :notes \"" << c->getComment() << "\")";
+ string s = c->getComment();
+ size_t pos = 0;
+ while((pos = s.find_first_of('"', pos)) != string::npos) {
+ s.replace(pos, 1, "\\\"");
+ pos += 2;
+ }
+ out << "(set-info :notes \"" << s << "\")";
}
static void toStream(std::ostream& out, const EmptyCommand* c) throw() {
d_assertionList = new(true) AssertionList(d_userContext);
}
+ // dump out a set-logic command
+ if(Dump.isOn("benchmark")) {
+ // Dump("benchmark") << SetBenchmarkLogicCommand(logic.getLogicString());
+ LogicInfo everything;
+ everything.lock();
+ Dump("benchmark") << CommentCommand("CVC4 always dumps the most general, \"all-supported\" logic (above), as some internals might require the use of a logic more general than the input.")
+ << SetBenchmarkLogicCommand(everything.getLogicString());
+ }
+
// dump out any pending declaration commands
for(unsigned i = 0; i < d_dumpCommands.size(); ++i) {
Dump("declarations") << *d_dumpCommands[i];
void SmtEngine::setLogic(const LogicInfo& logic) throw(ModalException) {
SmtScope smts(this);
- if(Dump.isOn("benchmark")) {
- Dump("benchmark") << SetBenchmarkLogicCommand(logic.getLogicString());
- }
-
d_logic = logic;
setLogicInternal();
}
return d_statisticsRegistry->getStatistic(name);
}
-void SmtEngine::setUserAttribute(std::string& attr, Expr expr) {
+void SmtEngine::setUserAttribute(const std::string& attr, Expr expr) {
SmtScope smts(this);
d_theoryEngine->setUserAttribute(attr, expr.getNode());
}
#ifndef __CVC4__SMT_ENGINE_H
#define __CVC4__SMT_ENGINE_H
+#include <string>
#include <vector>
#include "context/cdlist_forward.h"
* This function is called when an attribute is set by a user.
* In SMT-LIBv2 this is done via the syntax (! expr :attr)
*/
- void setUserAttribute( std::string& attr, Expr expr );
+ void setUserAttribute(const std::string& attr, Expr expr);
};/* class SmtEngine */
#include "smt/smt_engine.h"
%}
+%ignore CVC4::SmtEngine::getProof;
+%ignore CVC4::stats::getStatisticsRegistry(SmtEngine*);
+
%include "smt/smt_engine.h"
@builddir@/rewriterules/librewriterules.la
EXTRA_DIST = \
+ logic_info.i \
options_handlers.h \
rewriter_tables_template.h \
instantiator_tables_template.cpp \
std::string LogicInfo::getLogicString() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
if(d_logicString == "") {
- size_t seen = 0; // make sure we support all the active theories
+ LogicInfo qf_all_supported;
+ qf_all_supported.disableQuantifiers();
+ qf_all_supported.lock();
+ if(hasEverything()) {
+ d_logicString = "ALL_SUPPORTED";
+ } else if(*this == qf_all_supported) {
+ d_logicString = "QF_ALL_SUPPORTED";
+ } else {
+ size_t seen = 0; // make sure we support all the active theories
- stringstream ss;
- if(!isQuantified()) {
- ss << "QF_";
- }
- if(d_theories[THEORY_ARRAY]) {
- ss << (d_sharingTheories == 1 ? "AX" : "A");
- ++seen;
- }
- if(d_theories[THEORY_UF]) {
- ss << "UF";
- ++seen;
- }
- if(d_theories[THEORY_BV]) {
- ss << "BV";
- ++seen;
- }
- if(d_theories[THEORY_DATATYPES]) {
- ss << "DT";
- ++seen;
- }
- if(d_theories[THEORY_ARITH]) {
- if(isDifferenceLogic()) {
- ss << (areIntegersUsed() ? "I" : "");
- ss << (areRealsUsed() ? "R" : "");
- ss << "DL";
- } else {
- ss << (isLinear() ? "L" : "N");
- ss << (areIntegersUsed() ? "I" : "");
- ss << (areRealsUsed() ? "R" : "");
- ss << "A";
+ stringstream ss;
+ if(!isQuantified()) {
+ ss << "QF_";
+ }
+ if(d_theories[THEORY_ARRAY]) {
+ ss << (d_sharingTheories == 1 ? "AX" : "A");
+ ++seen;
+ }
+ if(d_theories[THEORY_UF]) {
+ ss << "UF";
+ ++seen;
+ }
+ if(d_theories[THEORY_BV]) {
+ ss << "BV";
+ ++seen;
+ }
+ if(d_theories[THEORY_DATATYPES]) {
+ ss << "DT";
+ ++seen;
+ }
+ if(d_theories[THEORY_ARITH]) {
+ if(isDifferenceLogic()) {
+ ss << (areIntegersUsed() ? "I" : "");
+ ss << (areRealsUsed() ? "R" : "");
+ ss << "DL";
+ } else {
+ ss << (isLinear() ? "L" : "N");
+ ss << (areIntegersUsed() ? "I" : "");
+ ss << (areRealsUsed() ? "R" : "");
+ ss << "A";
+ }
+ ++seen;
}
- ++seen;
- }
- if(seen != d_sharingTheories) {
- Unhandled("can't extract a logic string from LogicInfo; at least one "
- "active theory is unknown to LogicInfo::getLogicString() !");
- }
+ if(seen != d_sharingTheories) {
+ Unhandled("can't extract a logic string from LogicInfo; at least one "
+ "active theory is unknown to LogicInfo::getLogicString() !");
+ }
- if(seen == 0) {
- ss << "SAT";
- }
+ if(seen == 0) {
+ ss << "SAT";
+ }
- d_logicString = ss.str();
+ d_logicString = ss.str();
+ }
}
return d_logicString;
}
--- /dev/null
+%{
+#include "theory/logic_info.h"
+%}
+
+%ignore CVC4::LogicInfo::LogicInfo(const char*);
+
+%rename(less) CVC4::LogicInfo::operator<(const LogicInfo&) const;
+%rename(lessEqual) CVC4::LogicInfo::operator<=(const LogicInfo&) const;
+%rename(greater) CVC4::LogicInfo::operator>(const LogicInfo&) const;
+%rename(greaterEqual) CVC4::LogicInfo::operator>=(const LogicInfo&) const;
+
+%rename(equals) CVC4::LogicInfo::operator==(const LogicInfo&) const;
+%ignore CVC4::LogicInfo::operator!=(const LogicInfo&) const;
+
+%include "theory/logic_info.h"
* This function is called when an attribute is set by a user. In SMT-LIBv2 this is done
* via the syntax (! n :attr)
*/
- virtual void setUserAttribute( std::string& attr, Node n ) {
+ virtual void setUserAttribute(const std::string& attr, Node n) {
Unimplemented("Theory %s doesn't support Theory::setUserAttribute interface",
identify().c_str());
}
}
-void TheoryEngine::setUserAttribute( std::string& attr, Node n ){
+void TheoryEngine::setUserAttribute(const std::string& attr, Node n) {
Trace("te-attr") << "set user attribute " << attr << " " << n << std::endl;
if( d_attr_handle.find( attr )!=d_attr_handle.end() ){
for( size_t i=0; i<d_attr_handle[attr].size(); i++ ){
- d_attr_handle[attr][i]->setUserAttribute( attr, n );
+ d_attr_handle[attr][i]->setUserAttribute(attr, n);
}
- }else{
+ } else {
//unhandled exception?
}
}
-
-void TheoryEngine::handleUserAttribute( const char* attr, Theory* t ){
+void TheoryEngine::handleUserAttribute(const char* attr, Theory* t) {
Trace("te-attr") << "Handle user attribute " << attr << " " << t << std::endl;
std::string str( attr );
d_attr_handle[ str ].push_back( t );
}
-
void TheoryEngine::checkTheoryAssertionsWithModel()
{
for (TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
* This function is called when an attribute is set by a user. In SMT-LIBv2 this is done
* via the syntax (! n :attr)
*/
- void setUserAttribute( std::string& attr, Node n );
+ void setUserAttribute(const std::string& attr, Node n);
/** Handle user attribute
* Associates theory t with the attribute attr. Theory t will be
* notifed whenever an attribute of name attr is set.
*/
- void handleUserAttribute( const char* attr, theory::Theory* t );
+ void handleUserAttribute(const char* attr, theory::Theory* t);
/** Check that the theory assertions are satisfied in the model
* This function is called from the smt engine's checkModel routine
array_store_all.i \
ascription_type.i \
rational.i \
- hash.i
+ hash.i \
+ predicate.i \
+ uninterpreted_constant.i
DISTCLEANFILES = \
integer.h.tmp \
#include "util/output.h"
%}
-%feature("valuewrapper") CVC4::null_streambuf;
+%ignore CVC4::null_streambuf;
%feature("valuewrapper") std::ostream;
// There are issues with SWIG's attempted wrapping of these variables when
%ignore CVC4::ScopedTrace::ScopedTrace(std::string);
%ignore CVC4::ScopedTrace::ScopedTrace(std::string, bool);
-%rename(getostream) operator std::ostream&;
-%rename(getCVC4ostream) operator CVC4ostream;
+%ignore CVC4::WarningC::getStream();
+%ignore CVC4::MessageC::getStream();
+%ignore CVC4::NoticeC::getStream();
+%ignore CVC4::ChatC::getStream();
+%ignore CVC4::TraceC::getStream();
+%ignore CVC4::DebugC::getStream();
+%ignore CVC4::DumpOutC::getStream();
+
+%ignore CVC4::WarningC::setStream(std::ostream&);
+%ignore CVC4::MessageC::setStream(std::ostream&);
+%ignore CVC4::NoticeC::setStream(std::ostream&);
+%ignore CVC4::ChatC::setStream(std::ostream&);
+%ignore CVC4::TraceC::setStream(std::ostream&);
+%ignore CVC4::DebugC::setStream(std::ostream&);
+%ignore CVC4::DumpOutC::setStream(std::ostream&);
+
+%ignore operator std::ostream&;
+%ignore operator CVC4ostream;
+
%rename(get) operator();
%rename(ok) operator bool;
--- /dev/null
+%{
+#include "util/predicate.h"
+%}
+
+%rename(equals) CVC4::Predicate::operator==(const Predicate&) const;
+%rename(toExpr) CVC4::Predicate::operator Expr() const;
+
+%include "util/predicate.h"
%ignore CVC4::operator<<(std::ostream&, enum Result::Validity);
%ignore CVC4::operator<<(std::ostream&, enum Result::UnknownExplanation);
+%ignore CVC4::operator==(enum Result::Sat, const Result&);
+%ignore CVC4::operator==(enum Result::Validity, const Result&);
+%ignore CVC4::operator!=(enum Result::Sat, const Result&);
+%ignore CVC4::operator!=(enum Result::Validity, const Result&);
+
%include "util/result.h"
%{
#include "util/statistics.h"
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_output_stream_adapter.h"
%}
%rename(assign) CVC4::Statistics::operator=(const StatisticsBase&);
%rename(assign) CVC4::Statistics::operator=(const Statistics& stats);
+%ignore CVC4::StatisticsBase::begin();
+%ignore CVC4::StatisticsBase::end();
+%ignore CVC4::StatisticsBase::begin() const;
+%ignore CVC4::StatisticsBase::end() const;
+%extend CVC4::StatisticsBase {
+ CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>(*$self);
+ }
+}
+
+%typemap(javainterfaces) CVC4::StatisticsBase "java.lang.Iterable<Object>";
+
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "java.util.Iterator";
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public Object next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+
+%typemap(jni) CVC4::StatisticsBase::const_iterator::value_type "jobjectArray";
+%typemap(jtype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
+%typemap(jstype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
+%typemap(javaout) CVC4::StatisticsBase::const_iterator::value_type { return $jnicall; }
+%typemap(out) CVC4::StatisticsBase::const_iterator::value_type {
+ $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null);
+ jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str()));
+ jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/SExpr");
+ jmethodID methodid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
+ jenv->SetObjectArrayElement($result, 1, jenv->NewObject(jenv->FindClass("edu/nyu/acsys/CVC4/SExpr"), methodid, reinterpret_cast<long>(new CVC4::SExpr($1.second)), true));
+ };
+
%include "util/statistics.h"
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_output_stream_adapter.h"
+
+%template(JavaIteratorAdapter_StatisticsBase) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>;
--- /dev/null
+%{
+#include "util/uninterpreted_constant.h"
+%}
+
+%rename(less) CVC4::UninterpretedConstant::operator<(const UninterpretedConstant&) const;
+%rename(lessEqual) CVC4::UninterpretedConstant::operator<=(const UninterpretedConstant&) const;
+%rename(greater) CVC4::UninterpretedConstant::operator>(const UninterpretedConstant&) const;
+%rename(greaterEqual) CVC4::UninterpretedConstant::operator>=(const UninterpretedConstant&) const;
+
+%rename(equals) CVC4::UninterpretedConstant::operator==(const UninterpretedConstant&) const;
+%ignore CVC4::UninterpretedConstant::operator!=(const UninterpretedConstant&) const;
+
+%include "util/uninterpreted_constant.h"
info.lock();
TS_ASSERT( info.isLocked() );
- TS_ASSERT_EQUALS( info.getLogicString(), "AUFBVDTLIRA" );// for now, nonlinear not included in ALL_SUPPORTED
+ TS_ASSERT_EQUALS( info.getLogicString(), "ALL_SUPPORTED" );
TS_ASSERT( info.isSharingEnabled() );
TS_ASSERT( info.isTheoryEnabled( THEORY_BUILTIN ) );
TS_ASSERT( info.isTheoryEnabled( THEORY_BOOL ) );