This PR eliminates the Output macro together with the associated output stream (stored in a static variable). It is replaces by a set of simple utility functions of the Env class, and we instead use the output stream from options.base.out.
To achieve this, a couple of quantifier classes are now derived from EnvObj.
options/options_handler.h
options/options_listener.h
options/options_public.h
- options/outputc.cpp
- options/outputc.h
options/set_language.cpp
options/set_language.h
preprocessing/assertion_pipeline.cpp
#include "options/option_exception.h"
#include "options/options.h"
#include "options/options_public.h"
-#include "options/outputc.h"
#include "options/smt_options.h"
#include "proof/unsat_core.h"
+#include "smt/env.h"
#include "smt/model.h"
#include "smt/smt_engine.h"
#include "smt/smt_mode.h"
bool Solver::isOutputOn(const std::string& tag) const
{
- // `Output(tag)` may raise an `OptionException`, which we do not want to
+ // `isOutputOn(tag)` may raise an `OptionException`, which we do not want to
// forward as such. We thus do not use the standard exception handling macros
// here but roll our own.
try
{
- return cvc5::OutputChannel.isOn(tag);
+ return d_smtEngine->getEnv().isOutputOn(tag);
}
catch (const cvc5::Exception& e)
{
std::ostream& Solver::getOutput(const std::string& tag) const
{
- // `Output(tag)` may raise an `OptionException`, which we do not want to
+ // `getOutput(tag)` may raise an `OptionException`, which we do not want to
// forward as such. We thus do not use the standard exception handling macros
// here but roll our own.
try
{
- return Output(tag);
+ return d_smtEngine->getEnv().getOutput(tag);
}
catch (const cvc5::Exception& e)
{
+++ /dev/null
-#include "options/outputc.h"
-
-#include <iostream>
-
-namespace cvc5 {
-
-OutputC OutputChannel(&std::cout);
-
-Cvc5ostream OutputC::operator()(const options::OutputTag tag) const
-{
- if (options::outputTagHolder()[static_cast<size_t>(tag)])
- {
- return Cvc5ostream(d_os);
- }
- else
- {
- return Cvc5ostream();
- }
-}
-
-Cvc5ostream OutputC::operator()(const std::string& tag) const
-{
- return (*this)(options::stringToOutputTag(tag));
-}
-
-bool OutputC::isOn(const options::OutputTag tag) const
-{
- return options::outputTagHolder()[static_cast<size_t>(tag)];
-}
-bool OutputC::isOn(const std::string& tag) const
-{
- return (*this).isOn(options::stringToOutputTag(tag));
-}
-
-} // namespace cvc5
+++ /dev/null
-#include "cvc5_private_library.h"
-
-#ifndef CVC5__OPTIONS__OUTPUTC_H
-#define CVC5__OPTIONS__OUTPUTC_H
-
-#include <iostream>
-
-#include "cvc5_export.h"
-#include "base/output.h"
-#include "options/base_options.h"
-
-namespace cvc5 {
-
-class OutputC
-{
- public:
- explicit OutputC(std::ostream* os) : d_os(os) {}
-
- Cvc5ostream operator()(const options::OutputTag tag) const;
- Cvc5ostream operator()(const std::string& tag) const;
-
- bool isOn(const options::OutputTag tag) const;
- bool isOn(const std::string& tag) const;
-
- private:
- std::ostream* d_os;
-
-}; /* class OutputC */
-
-extern OutputC OutputChannel CVC5_EXPORT;
-
-#ifdef CVC5_MUZZLE
-#define Output ::cvc5::__cvc5_true() ? ::cvc5::nullStream : ::cvc5::OutputChannel
-#else /* CVC5_MUZZLE */
-#define Output ::cvc5::OutputChannel
-#endif /* CVC5_MUZZLE */
-
-}
-
-#endif /* CVC5__OPTIONS__OUTPUTC_H */
std::ostream& Env::getDumpOut() { return *d_options.base.out; }
+bool Env::isOutputOn(options::OutputTag tag) const
+{
+ return d_options.base.outputTagHolder[static_cast<size_t>(tag)];
+}
+bool Env::isOutputOn(const std::string& tag) const
+{
+ return isOutputOn(options::stringToOutputTag(tag));
+}
+std::ostream& Env::getOutput(options::OutputTag tag) const
+{
+ if (isOutputOn(tag))
+ {
+ return *d_options.base.out;
+ }
+ return cvc5::null_os;
+}
+std::ostream& Env::getOutput(const std::string& tag) const
+{
+ return getOutput(options::stringToOutputTag(tag));
+}
+
Node Env::evaluate(TNode n,
const std::vector<Node>& args,
const std::vector<Node>& vals,
#include <memory>
+#include "options/base_options.h"
#include "options/options.h"
#include "proof/method_id.h"
#include "theory/logic_info.h"
*/
std::ostream& getDumpOut();
+ /**
+ * Check whether the output for the given output tag is enabled. Output tags
+ * are enabled via the `output` option (or `-o` on the command line).
+ */
+ bool isOutputOn(options::OutputTag tag) const;
+ /**
+ * Check whether the output for the given output tag (as a string) is enabled.
+ * Output tags are enabled via the `output` option (or `-o` on the command
+ * line).
+ */
+ bool isOutputOn(const std::string& tag) const;
+ /**
+ * Return the output stream for the given output tag. If the output tag is
+ * enabled, this returns the output stream from the `out` option. Otherwise,
+ * a null stream (`cvc5::null_os`) is returned.
+ */
+ std::ostream& getOutput(options::OutputTag tag) const;
+ /**
+ * Return the output stream for the given output tag (as a string). If the
+ * output tag is enabled, this returns the output stream from the `out`
+ * option. Otherwise, a null stream (`cvc5::null_os`) is returned.
+ */
+ std::ostream& getOutput(const std::string& tag) const;
+
/* Rewrite helpers--------------------------------------------------------- */
/**
* Evaluate node n under the substitution args -> vals. For details, see
namespace inst {
HigherOrderTrigger::HigherOrderTrigger(
+ Env& env,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
Node q,
std::vector<Node>& nodes,
std::map<Node, std::vector<Node> >& ho_apps)
- : Trigger(qs, qim, qr, tr, q, nodes), d_ho_var_apps(ho_apps)
+ : Trigger(env, qs, qim, qr, tr, q, nodes), d_ho_var_apps(ho_apps)
{
NodeManager* nm = NodeManager::currentNM();
// process the higher-order variable applications
class HigherOrderTrigger : public Trigger
{
public:
- HigherOrderTrigger(QuantifiersState& qs,
+ HigherOrderTrigger(Env& env,
+ QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr,
#include "theory/quantifiers/ematching/inst_strategy.h"
+#include "smt/env.h"
#include "theory/quantifiers/quantifiers_state.h"
namespace cvc5 {
namespace theory {
namespace quantifiers {
-InstStrategy::InstStrategy(inst::TriggerDatabase& td,
+InstStrategy::InstStrategy(Env& env,
+ inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr)
- : d_td(td), d_qstate(qs), d_qim(qim), d_qreg(qr), d_treg(tr)
+ : EnvObj(env), d_td(td), d_qstate(qs), d_qim(qim), d_qreg(qr), d_treg(tr)
{
}
InstStrategy::~InstStrategy() {}
#define CVC5__THEORY__QUANTIFIERS__INST_STRATEGY_H
#include <vector>
+
#include "expr/node.h"
#include "options/quantifiers_options.h"
+#include "smt/env_obj.h"
#include "theory/theory.h"
namespace cvc5 {
/**
* A base class for instantiation strategies within E-matching.
*/
-class InstStrategy
+class InstStrategy : protected EnvObj
{
public:
- InstStrategy(inst::TriggerDatabase& td,
+ InstStrategy(Env& env,
+ inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
#include "theory/quantifiers/ematching/inst_strategy_e_matching.h"
#include "options/base_options.h"
-#include "options/outputc.h"
#include "theory/quantifiers/ematching/pattern_term_selector.h"
#include "theory/quantifiers/ematching/trigger_database.h"
#include "theory/quantifiers/quant_relevance.h"
};
InstStrategyAutoGenTriggers::InstStrategyAutoGenTriggers(
+ Env& env,
inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr,
QuantRelevance* qrlv)
- : InstStrategy(td, qs, qim, qr, tr), d_quant_rel(qrlv)
+ : InstStrategy(env, td, qs, qim, qr, tr), d_quant_rel(qrlv)
{
//how to select trigger terms
d_tr_strategy = options::triggerSelMode();
&& d_auto_gen_trigger[1][f].empty() && !QuantAttributes::hasPattern(f))
{
Trace("trigger-warn") << "Could not find trigger for " << f << std::endl;
- Output(options::OutputTag::TRIGGER)
- << "(no-trigger " << f << ")" << std::endl;
+ if (d_env.isOutputOn(options::OutputTag::TRIGGER))
+ {
+ d_env.getOutput(options::OutputTag::TRIGGER)
+ << "(no-trigger " << f << ")" << std::endl;
+ }
}
}
if (options::triggerActiveSelMode() != options::TriggerActiveSelMode::ALL)
std::map<Node, bool> d_hasUserPatterns;
public:
- InstStrategyAutoGenTriggers(inst::TriggerDatabase& td,
+ InstStrategyAutoGenTriggers(Env& env,
+ inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
namespace quantifiers {
InstStrategyUserPatterns::InstStrategyUserPatterns(
+ Env& env,
inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr)
- : InstStrategy(td, qs, qim, qr, tr)
+ : InstStrategy(env, td, qs, qim, qr, tr)
{
}
InstStrategyUserPatterns::~InstStrategyUserPatterns() {}
class InstStrategyUserPatterns : public InstStrategy
{
public:
- InstStrategyUserPatterns(inst::TriggerDatabase& td,
+ InstStrategyUserPatterns(Env& env,
+ inst::TriggerDatabase& td,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
d_isup(),
d_i_ag(),
d_quants(),
- d_trdb(qs, qim, qr, tr),
+ d_trdb(d_env, qs, qim, qr, tr),
d_quant_rel(nullptr)
{
if (options::relevantTriggers())
// user-provided patterns
if (options::userPatternsQuant() != options::UserPatMode::IGNORE)
{
- d_isup.reset(new InstStrategyUserPatterns(d_trdb, qs, qim, qr, tr));
+ d_isup.reset(
+ new InstStrategyUserPatterns(d_env, d_trdb, qs, qim, qr, tr));
d_instStrategies.push_back(d_isup.get());
}
// auto-generated patterns
d_i_ag.reset(new InstStrategyAutoGenTriggers(
- d_trdb, qs, qim, qr, tr, d_quant_rel.get()));
+ d_env, d_trdb, qs, qim, qr, tr, d_quant_rel.get()));
d_instStrategies.push_back(d_i_ag.get());
}
}
#include "expr/skolem_manager.h"
#include "options/base_options.h"
-#include "options/outputc.h"
#include "options/quantifiers_options.h"
+#include "smt/env.h"
#include "theory/quantifiers/ematching/candidate_generator.h"
#include "theory/quantifiers/ematching/inst_match_generator.h"
#include "theory/quantifiers/ematching/inst_match_generator_multi.h"
namespace inst {
/** trigger class constructor */
-Trigger::Trigger(QuantifiersState& qs,
+Trigger::Trigger(Env& env,
+ QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr,
Node q,
std::vector<Node>& nodes)
- : d_qstate(qs), d_qim(qim), d_qreg(qr), d_treg(tr), d_quant(q)
+ : EnvObj(env), d_qstate(qs), d_qim(qim), d_qreg(qr), d_treg(tr), d_quant(q)
{
// We must ensure that the ground subterms of the trigger have been
// preprocessed.
extNodes.push_back(ns);
}
d_trNode = NodeManager::currentNM()->mkNode(SEXPR, extNodes);
- if (Output.isOn(options::OutputTag::TRIGGER))
+ if (d_env.isOutputOn(options::OutputTag::TRIGGER))
{
QuantAttributes& qa = d_qreg.getQuantAttributes();
- Output(options::OutputTag::TRIGGER) << "(trigger " << qa.quantToString(q)
- << " " << d_trNode << ")" << std::endl;
+ d_env.getOutput(options::OutputTag::TRIGGER)
+ << "(trigger " << qa.quantToString(q) << " " << d_trNode << ")"
+ << std::endl;
}
QuantifiersStatistics& stats = qs.getStats();
if( d_nodes.size()==1 ){
#define CVC5__THEORY__QUANTIFIERS__TRIGGER_H
#include "expr/node.h"
+#include "smt/env_obj.h"
#include "theory/inference_id.h"
namespace cvc5 {
* required to ensure the correctness of instantiation lemmas we generate.
*
*/
-class Trigger {
+class Trigger : protected EnvObj
+{
friend class IMGenerator;
public:
/** trigger constructor */
- Trigger(QuantifiersState& qs,
+ Trigger(Env& env,
+ QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr,
namespace quantifiers {
namespace inst {
-TriggerDatabase::TriggerDatabase(QuantifiersState& qs,
+TriggerDatabase::TriggerDatabase(Env& env,
+ QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr)
- : d_qs(qs), d_qim(qim), d_qreg(qr), d_treg(tr)
+ : EnvObj(env), d_qs(qs), d_qim(qim), d_qreg(qr), d_treg(tr)
{
}
TriggerDatabase::~TriggerDatabase() {}
Trigger* t;
if (!hoApps.empty())
{
- t = new HigherOrderTrigger(d_qs, d_qim, d_qreg, d_treg, q, trNodes, hoApps);
+ t = new HigherOrderTrigger(
+ d_env, d_qs, d_qim, d_qreg, d_treg, q, trNodes, hoApps);
}
else
{
- t = new Trigger(d_qs, d_qim, d_qreg, d_treg, q, trNodes);
+ t = new Trigger(d_env, d_qs, d_qim, d_qreg, d_treg, q, trNodes);
}
d_trie.addTrigger(trNodes, t);
return t;
#include <vector>
#include "expr/node.h"
+#include "smt/env_obj.h"
#include "theory/quantifiers/ematching/trigger_trie.h"
namespace cvc5 {
/**
* A database of triggers, which manages how triggers are constructed.
*/
-class TriggerDatabase
+class TriggerDatabase : protected EnvObj
{
public:
- TriggerDatabase(QuantifiersState& qs,
+ TriggerDatabase(Env& env,
+ QuantifiersState& qs,
QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr,
TermRegistry& tr);
#include "expr/node_algorithm.h"
#include "options/base_options.h"
-#include "options/outputc.h"
#include "options/printer_options.h"
#include "options/quantifiers_options.h"
#include "options/smt_options.h"
<< " * " << i.second << " for " << i.first << std::endl;
}
}
- if (Output.isOn(options::OutputTag::INST))
+ if (d_env.isOutputOn(options::OutputTag::INST))
{
bool req = !options::printInstFull();
for (std::pair<const Node, uint32_t>& i : d_instDebugTemp)
{
continue;
}
- Output(options::OutputTag::INST) << "(num-instantiations " << name << " "
- << i.second << ")" << std::endl;
+ d_env.getOutput(options::OutputTag::INST)
+ << "(num-instantiations " << name << " " << i.second << ")"
+ << std::endl;
}
}
}
#include "expr/skolem_manager.h"
#include "options/base_options.h"
#include "options/datatypes_options.h"
-#include "options/outputc.h"
#include "options/quantifiers_options.h"
#include "printer/printer.h"
#include "smt/logic_exception.h"
}
}
- bool printDebug = Output.isOn(options::OutputTag::SYGUS);
+ bool printDebug = d_env.isOutputOn(options::OutputTag::SYGUS);
if (!constructed_cand)
{
// get the model value of the relevant terms from the master module
}
}
Trace("sygus-engine") << std::endl;
- Output(options::OutputTag::SYGUS)
- << "(sygus-enum" << sygusEnumOut.str() << ")" << std::endl;
+ if (d_env.isOutputOn(options::OutputTag::SYGUS))
+ {
+ d_env.getOutput(options::OutputTag::SYGUS)
+ << "(sygus-enum" << sygusEnumOut.str() << ")" << std::endl;
+ }
}
Assert(candidate_values.empty());
constructed_cand = d_master->constructCandidates(