#include "smt/sygus_solver.h"
#include "smt/unsat_core_manager.h"
#include "theory/quantifiers/instantiation_list.h"
+#include "theory/quantifiers/oracle_engine.h"
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers_engine.h"
#include "theory/rewriter.h"
qe->declarePool(p, initValue);
}
+void SolverEngine::declareOracleFun(
+ Node var, std::function<std::vector<Node>(const std::vector<Node>&)> fn)
+{
+ finishInit();
+ d_state->doPendingPops();
+ QuantifiersEngine* qe = getAvailableQuantifiersEngine("declareOracleFun");
+ qe->declareOracleFun(var);
+ NodeManager* nm = NodeManager::currentNM();
+ std::vector<Node> inputs;
+ std::vector<Node> outputs;
+ TypeNode tn = var.getType();
+ Node app;
+ if (tn.isFunction())
+ {
+ const std::vector<TypeNode>& argTypes = tn.getArgTypes();
+ for (const TypeNode& t : argTypes)
+ {
+ inputs.push_back(nm->mkBoundVar(t));
+ }
+ outputs.push_back(nm->mkBoundVar(tn.getRangeType()));
+ std::vector<Node> appc;
+ appc.push_back(var);
+ appc.insert(appc.end(), inputs.begin(), inputs.end());
+ app = nm->mkNode(kind::APPLY_UF, appc);
+ }
+ else
+ {
+ outputs.push_back(nm->mkBoundVar(tn.getRangeType()));
+ app = var;
+ }
+ // makes equality assumption
+ Node assume = nm->mkNode(kind::EQUAL, app, outputs[0]);
+ // no constraints
+ Node constraint = nm->mkConst(true);
+ // make the oracle constant which carries the method implementation
+ Oracle oracle(fn);
+ Node o = NodeManager::currentNM()->mkOracle(oracle);
+ // set the attribute, which ensures we remember the method implementation for
+ // the oracle function
+ var.setAttribute(theory::OracleInterfaceAttribute(), o);
+ // define the oracle interface
+ Node q = quantifiers::OracleEngine::mkOracleInterface(
+ inputs, outputs, assume, constraint, o);
+ // assert it
+ assertFormula(q);
+}
+
Node SolverEngine::simplify(const Node& ex)
{
SolverEngineScope smts(this);
const std::vector<Node>& formals,
Node formula,
bool global = false);
+
/**
* Add a formula to the current context: preprocess, do per-theory
* setup, use processAssertionList(), asserting to T-solver for
* of type T.
*/
void declarePool(const Node& p, const std::vector<Node>& initValue);
+
+ /**
+ * Add an oracle function to the state, also adds an oracle interface
+ * defining it.
+ *
+ * @param var The oracle function symbol
+ * @param fn The method for the oracle
+ */
+ void declareOracleFun(
+ Node var, std::function<std::vector<Node>(const std::vector<Node>&)> fn);
/**
* Simplify a formula without doing "much" work. Does not involve
* the SAT Engine in the simplification, but uses the current
void debugCheckFunctionBody(Node formula,
const std::vector<Node>& formals,
Node func);
-
/**
* Helper method to obtain both the heap and nil from the solver. Returns a
* std::pair where the first element is the heap expression and the second
/** Vector version of above. */
void ensureWellFormedTerms(const std::vector<Node>& ns,
const std::string& src) const;
-
/* Members -------------------------------------------------------------- */
/** Solver instance that owns this SolverEngine instance. */