theory_test_utils.h
Go to the documentation of this file.
/********************* */
#include "cvc4_public.h"
#ifndef __CVC4__THEORY__THEORY_TEST_UTILS_H
#define __CVC4__THEORY__THEORY_TEST_UTILS_H
#include "util/cvc4_assert.h"
#include "expr/node.h"
#include "theory/output_channel.h"
#include "theory/interrupted.h"
#include <vector>
#include <utility>
#include <iostream>
namespace CVC4 {
namespace theory {
enum OutputChannelCallType {
CONFLICT,
PROPAGATE,
PROPAGATE_AS_DECISION,
AUG_LEMMA,
LEMMA,
EXPLANATION
};/* enum OutputChannelCallType */
}/* CVC4::theory namespace */
inline std::ostream& operator<<(std::ostream& out, theory::OutputChannelCallType type) {
switch(type) {
case theory::CONFLICT: return out << "CONFLICT";
case theory::PROPAGATE: return out << "PROPAGATE";
case theory::PROPAGATE_AS_DECISION: return out << "PROPAGATE_AS_DECISION";
case theory::AUG_LEMMA: return out << "AUG_LEMMA";
case theory::LEMMA: return out << "LEMMA";
case theory::EXPLANATION: return out << "EXPLANATION";
default: return out << "UNDEFINED-OutputChannelCallType!" << int(type);
}
}
namespace theory {
class TestOutputChannel : public theory::OutputChannel {
public:
std::vector< std::pair<enum OutputChannelCallType, Node> > d_callHistory;
TestOutputChannel() {}
~TestOutputChannel() {}
void safePoint() throw(Interrupted, AssertionException) {}
void conflict(TNode n)
throw(AssertionException) {
push(CONFLICT, n);
}
bool propagate(TNode n)
throw(AssertionException) {
push(PROPAGATE, n);
return true;
}
void propagateAsDecision(TNode n)
throw(AssertionException) {
push(PROPAGATE_AS_DECISION, n);
}
LemmaStatus lemma(TNode n, bool removable, bool preprocess) throw(AssertionException) {
push(LEMMA, n);
return LemmaStatus(Node::null(), 0);
}
void requirePhase(TNode, bool) throw(Interrupted, AssertionException) {
}
bool flipDecision() throw(Interrupted, AssertionException) {
return true;
}
void setIncomplete() throw(AssertionException) {}
void handleUserAttribute( const char* attr, theory::Theory* t ){}
void clear() {
d_callHistory.clear();
}
LemmaStatus splitLemma(TNode n, bool removable = false) throw(TypeCheckingExceptionPrivate, AssertionException){
push(LEMMA, n);
return LemmaStatus(Node::null(), 0);
}
Node getIthNode(int i) {
Node tmp = (d_callHistory[i]).second;
return tmp;
}
OutputChannelCallType getIthCallType(int i) {
return (d_callHistory[i]).first;
}
unsigned getNumCalls() {
return d_callHistory.size();
}
void printIth(std::ostream& os, int i){
os << "[TestOutputChannel " << i;
os << " " << getIthCallType(i);
os << " " << getIthNode(i) << "]";
}
private:
void push(OutputChannelCallType call, TNode n) {
d_callHistory.push_back(std::make_pair(call, n));
}
};/* class TestOutputChannel */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
#endif /* __CVC4__THEORY__THEORY_TEST_UTILS_H */
CVC4::NodeTemplate
Definition smt_engine.h:46
CVC4::theory::TestOutputChannel
Definition theory_test_utils.h:64
CVC4::theory::TestOutputChannel::d_callHistory
std::vector< std::pair< enum OutputChannelCallType, Node > > d_callHistory
Definition theory_test_utils.h:66
CVC4::theory::TestOutputChannel::handleUserAttribute
void handleUserAttribute(const char *attr, theory::Theory *t)
Definition theory_test_utils.h:104
CVC4::theory::TestOutputChannel::~TestOutputChannel
~TestOutputChannel()
Definition theory_test_utils.h:70
CVC4::theory::TestOutputChannel::propagateAsDecision
void propagateAsDecision(TNode n)
Definition theory_test_utils.h:85
CVC4::theory::TestOutputChannel::getIthCallType
OutputChannelCallType getIthCallType(int i)
Definition theory_test_utils.h:120
CVC4::theory::TestOutputChannel::conflict
void conflict(TNode n)
Definition theory_test_utils.h:74
CVC4::theory::TestOutputChannel::splitLemma
LemmaStatus splitLemma(TNode n, bool removable=false)
Definition theory_test_utils.h:110
CVC4::theory::TestOutputChannel::setIncomplete
void setIncomplete()
Definition theory_test_utils.h:102
CVC4::theory::TestOutputChannel::propagate
bool propagate(TNode n)
Definition theory_test_utils.h:79
CVC4::theory::TestOutputChannel::TestOutputChannel
TestOutputChannel()
Definition theory_test_utils.h:68
CVC4::theory::TestOutputChannel::requirePhase
void requirePhase(TNode, bool)
Definition theory_test_utils.h:95
CVC4::theory::TestOutputChannel::getIthNode
Node getIthNode(int i)
Definition theory_test_utils.h:115
CVC4::theory::TestOutputChannel::clear
void clear()
Definition theory_test_utils.h:106
CVC4::theory::TestOutputChannel::getNumCalls
unsigned getNumCalls()
Definition theory_test_utils.h:124
CVC4::theory::TestOutputChannel::flipDecision
bool flipDecision()
Definition theory_test_utils.h:98
CVC4::theory::TestOutputChannel::lemma
LemmaStatus lemma(TNode n, bool removable, bool preprocess)
Definition theory_test_utils.h:90
CVC4::theory::TestOutputChannel::printIth
void printIth(std::ostream &os, int i)
Definition theory_test_utils.h:128
CVC4::theory::TestOutputChannel::safePoint
void safePoint()
Definition theory_test_utils.h:72
cvc4_public.h
Macros that should be defined everywhere during the building of the libraries and driver binary,...
CVC4::theory::OutputChannelCallType
OutputChannelCallType
Very basic OutputChannel for testing simple Theory Behaviour.
Definition theory_test_utils.h:39
CVC4::theory::EXPLANATION
@ EXPLANATION
Definition theory_test_utils.h:45
CVC4::theory::PROPAGATE_AS_DECISION
@ PROPAGATE_AS_DECISION
Definition theory_test_utils.h:42
CVC4::theory::CONFLICT
@ CONFLICT
Definition theory_test_utils.h:40
CVC4::theory::PROPAGATE
@ PROPAGATE
Definition theory_test_utils.h:41
CVC4::theory::LEMMA
@ LEMMA
Definition theory_test_utils.h:44
CVC4::theory::AUG_LEMMA
@ AUG_LEMMA
Definition theory_test_utils.h:43
CVC4
Definition expr.h:106
CVC4::operator<<
std::ostream & operator<<(std::ostream &out, const TypeCheckingException &e)