smt_engine.h
Go to the documentation of this file.
/********************* */
#include "cvc4_public.h"
#ifndef __CVC4__SMT_ENGINE_H
#define __CVC4__SMT_ENGINE_H
#include <string>
#include <vector>
#include "context/cdlist_forward.h"
#include "context/cdhashmap_forward.h"
#include "context/cdhashset_forward.h"
#include "expr/expr.h"
#include "expr/expr_manager.h"
#include "util/proof.h"
#include "smt/modal_exception.h"
#include "smt/logic_exception.h"
#include "options/options.h"
#include "util/result.h"
#include "util/sexpr.h"
#include "util/hash.h"
#include "util/statistics.h"
#include "theory/logic_info.h"
// In terms of abstraction, this is below (and provides services to)
// ValidityChecker and above (and requires the services of)
// PropEngine.
namespace CVC4 {
template <bool ref_count> class NodeTemplate;
typedef NodeTemplate<true> Node;
typedef NodeTemplate<false> TNode;
struct NodeHashFunction;
class Command;
class GetModelCommand;
class SmtEngine;
class DecisionEngine;
class TheoryEngine;
class ProofManager;
class Model;
class LogicRequest;
class StatisticsRegistry;
namespace context {
class Context;
class UserContext;
}/* CVC4::context namespace */
namespace prop {
class PropEngine;
}/* CVC4::prop namespace */
namespace smt {
class DefinedFunction;
struct SmtEngineStatistics;
class SmtEnginePrivate;
class SmtScope;
class BooleanTermConverter;
void beforeSearch(std::string, bool, SmtEngine*) throw(ModalException);
ProofManager* currentProofManager();
struct CommandCleanup;
typedef context::CDList<Command*, CommandCleanup> CommandList;
}/* CVC4::smt namespace */
namespace theory {
class TheoryModel;
}/* CVC4::theory namespace */
namespace stats {
StatisticsRegistry* getStatisticsRegistry(SmtEngine*);
}/* CVC4::stats namespace */
// TODO: SAT layer (esp. CNF- versus non-clausal solvers under the
// hood): use a type parameter and have check() delegate, or subclass
// SmtEngine and override check()?
//
// Probably better than that is to have a configuration object that
// indicates which passes are desired. The configuration occurs
// elsewhere (and can even occur at runtime). A simple "pass manager"
// of sorts determines check()'s behavior.
//
// The CNF conversion can go on in PropEngine.
class CVC4_PUBLIC SmtEngine {
typedef context::CDHashMap<Node, smt::DefinedFunction, NodeHashFunction>
DefinedFunctionMap;
typedef context::CDList<Expr> AssertionList;
typedef context::CDHashSet<Node, NodeHashFunction> AssignmentSet;
context::Context* d_context;
std::vector<int> d_userLevels;
context::UserContext* d_userContext;
ExprManager* d_exprManager;
NodeManager* d_nodeManager;
DecisionEngine* d_decisionEngine;
TheoryEngine* d_theoryEngine;
prop::PropEngine* d_propEngine;
ProofManager* d_proofManager;
DefinedFunctionMap* d_definedFunctions;
AssertionList* d_assertionList;
AssignmentSet* d_assignments;
std::vector<Command*> d_modelGlobalCommands;
smt::CommandList* d_modelCommands;
std::vector<Command*> d_dumpCommands;
LogicInfo d_logic;
unsigned d_pendingPops;
bool d_fullyInited;
bool d_problemExtended;
bool d_queryMade;
bool d_needPostsolve;
/*
* Whether to call theory preprocessing during simplification - on by default* but gets turned off if arithRewriteEq is on
*/
bool d_earlyTheoryPP;
unsigned long d_timeBudgetCumulative;
unsigned long d_timeBudgetPerCall;
unsigned long d_resourceBudgetCumulative;
unsigned long d_resourceBudgetPerCall;
unsigned long d_cumulativeTimeUsed;
unsigned long d_cumulativeResourceUsed;
Result d_status;
std::string d_filename;
std::map<std::string, Integer> d_commandVerbosity;
smt::SmtEnginePrivate* d_private;
void checkProof();
void checkModel(bool hardFailure = true);
Node postprocess(TNode n, TypeNode expectedType) const;
void finalOptionsAreSet();
void setDefaults();
void finishInit();
void shutdown();
Result check();
Result quickCheck();
void ensureBoolean(const Expr& e) throw(TypeCheckingException);
void internalPush();
void internalPop(bool immediate = false);
void doPendingPops();
void setLogicInternal() throw();
friend class ::CVC4::smt::SmtEnginePrivate;
friend class ::CVC4::smt::SmtScope;
friend class ::CVC4::smt::BooleanTermConverter;
friend ::CVC4::StatisticsRegistry* ::CVC4::stats::getStatisticsRegistry(SmtEngine*);
friend void ::CVC4::smt::beforeSearch(std::string, bool, SmtEngine*) throw(ModalException);
friend ProofManager* ::CVC4::smt::currentProofManager();
friend class ::CVC4::LogicRequest;
// to access d_modelCommands
friend class ::CVC4::Model;
friend class ::CVC4::theory::TheoryModel;
// to access getModel(), which is private (for now)
friend class GetModelCommand;
StatisticsRegistry* d_statisticsRegistry;
smt::SmtEngineStatistics* d_stats;
void addToModelCommandAndDump(const Command& c, uint32_t flags = 0, bool userVisible = true, const char* dumpTag = "declarations");
Model* getModel() throw(ModalException);
// disallow copy/assignment
SmtEngine(const SmtEngine&) CVC4_UNDEFINED;
SmtEngine& operator=(const SmtEngine&) CVC4_UNDEFINED;
public:
SmtEngine(ExprManager* em) throw();
~SmtEngine() throw();
void setLogic(const std::string& logic) throw(ModalException, LogicException);
void setLogic(const char* logic) throw(ModalException, LogicException);
void setLogic(const LogicInfo& logic) throw(ModalException);
LogicInfo getLogicInfo() const;
void setInfo(const std::string& key, const CVC4::SExpr& value)
throw(OptionException, ModalException);
CVC4::SExpr getInfo(const std::string& key) const
throw(OptionException, ModalException);
void setOption(const std::string& key, const CVC4::SExpr& value)
throw(OptionException, ModalException);
CVC4::SExpr getOption(const std::string& key) const
throw(OptionException);
void defineFunction(Expr func,
const std::vector<Expr>& formals,
Expr formula);
Result assertFormula(const Expr& e) throw(TypeCheckingException, LogicException);
Result query(const Expr& e) throw(TypeCheckingException, ModalException, LogicException);
Result checkSat(const Expr& e = Expr()) throw(TypeCheckingException, ModalException, LogicException);
Expr simplify(const Expr& e) throw(TypeCheckingException, LogicException);
Expr expandDefinitions(const Expr& e) throw(TypeCheckingException, LogicException);
Expr getValue(const Expr& e) const throw(ModalException, TypeCheckingException, LogicException);
bool addToAssignment(const Expr& e) throw();
CVC4::SExpr getAssignment() throw(ModalException);
Proof* getProof() throw(ModalException);
void printInstantiations( std::ostream& out );
std::vector<Expr> getAssertions() throw(ModalException);
void push() throw(ModalException, LogicException);
void pop() throw(ModalException);
void interrupt() throw(ModalException);
void setResourceLimit(unsigned long units, bool cumulative = false);
void setTimeLimit(unsigned long millis, bool cumulative = false);
unsigned long getResourceUsage() const;
unsigned long getTimeUsage() const;
unsigned long getResourceRemaining() const throw(ModalException);
unsigned long getTimeRemaining() const throw(ModalException);
ExprManager* getExprManager() const {
return d_exprManager;
}
Statistics getStatistics() const throw();
SExpr getStatistic(std::string name) const throw();
Result getStatusOfLastCommand() const throw() {
return d_status;
}
void setUserAttribute(const std::string& attr, Expr expr);
void setPrintFuncInModel(Expr f, bool p);
};/* class SmtEngine */
}/* CVC4 namespace */
#endif /* __CVC4__SMT_ENGINE_H */
Context
void * Context
Definition c_interface_defs.h:42
cdhashmap_forward.h
This is a forward declaration header to declare the CDHashMap<> template.
cdhashset_forward.h
This is a forward declaration header to declare the CDSet<> template.
cdlist_forward.h
This is a forward declaration header to declare the CDList<> template.
CVC4::Command
Definition command.h:184
CVC4::ExprManager
Definition expr_manager.h:124
CVC4::Expr
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Definition expr.h:227
CVC4::GetModelCommand
Definition command.h:553
CVC4::LogicException
Definition logic_exception.h:29
CVC4::LogicInfo
A LogicInfo instance describes a collection of theory modules and some basic configuration about them...
Definition logic_info.h:45
CVC4::ModalException
Definition modal_exception.h:29
CVC4::NodeTemplate
Definition smt_engine.h:46
CVC4::OptionException
Class representing an option-parsing exception such as badly-typed or missing arguments,...
Definition option_exception.h:32
CVC4::Proof
Definition proof.h:27
CVC4::Result
Three-valued SMT result, with optional explanation.
Definition result.h:36
CVC4::SExpr
A simple S-expression.
Definition sexpr.h:51
CVC4::SmtEngine
Definition smt_engine.h:113
CVC4::SmtEngine::setPrintFuncInModel
void setPrintFuncInModel(Expr f, bool p)
Set print function in model.
CVC4::SmtEngine::setUserAttribute
void setUserAttribute(const std::string &attr, Expr expr)
Set user attribute.
CVC4::SmtEngine::getStatistics
Statistics getStatistics() const
Export statistics from this SmtEngine.
CVC4::Statistics
Definition statistics.h:103
CVC4::TypeCheckingException
Exception thrown in the case of type-checking errors.
Definition expr.h:151
cvc4_public.h
Macros that should be defined everywhere during the building of the libraries and driver binary,...
CVC4_PUBLIC
#define CVC4_PUBLIC
Definition cvc4_public.h:30
CVC4_UNDEFINED
#define CVC4_UNDEFINED
Definition cvc4_public.h:52
expr.h
expr_manager.h
hash.h
[[ Add one-line brief description here ]]
logic_exception.h
An exception that is thrown when a feature is used outside the logic that CVC4 is currently using.
logic_info.h
A class giving information about a logic (group a theory modules and configuration information)
modal_exception.h
An exception that is thrown when an interactive-only feature while CVC4 is being used in a non-intera...
CVC4::smt::beforeSearch
void beforeSearch(std::string, bool, SmtEngine *)
CVC4::smt::currentProofManager
ProofManager * currentProofManager()
CVC4::smt::CommandList
context::CDList< Command *, CommandCleanup > CommandList
Definition smt_engine.h:91
CVC4::stats::getStatisticsRegistry
StatisticsRegistry * getStatisticsRegistry(ExprManager *)
CVC4
Definition expr.h:106
CVC4::TNode
NodeTemplate< false > TNode
Definition smt_engine.h:48
CVC4::Node
NodeTemplate< true > Node
Definition smt_engine.h:47
std
STL namespace.
options.h
Global (command-line, set-option, ...) parameters for SMT.
proof.h
[[ Add one-line brief description here ]]
result.h
Encapsulation of the result of a query.
sexpr.h
Simple representation of S-expressions.
statistics.h
[[ Add one-line brief description here ]]