6 #include <knowrob/formulas/Disjunction.h>
7 #include "knowrob/integration/python/utils.h"
11 static inline std::vector<FormulaPtr> getFormulae(
const FormulaPtr &phi,
const FormulaPtr &psi) {
14 auto formulae = phi0->formulae();
17 auto &psiFormulae = psi0->formulae();
18 formulae.insert(formulae.end(), psiFormulae.begin(), psiFormulae.end());
20 formulae.push_back(psi);
25 auto &psiFormulae = psi0->formulae();
26 std::vector<FormulaPtr> formulae = {phi};
27 formulae.insert(formulae.end(), psiFormulae.begin(), psiFormulae.end());
38 bool Disjunction::isEqual(
const Formula &other)
const {
39 const auto &x =
static_cast<const Disjunction &
>(other);
40 if (
formulae_.size() != x.formulae_.size())
return false;
42 bool hasEqual =
false;
43 for (
auto &y2: x.formulae_) {
49 if (!hasEqual)
return false;
56 if (phi->isBottom())
return psi;
57 else if (psi->isBottom())
return phi;
58 else if (phi->isTop())
return phi;
59 else if (psi->isTop())
return psi;
64 formulae.insert(formulae.end(), psi0.begin(), psi0.end());
66 formulae.push_back(psi);
68 return std::make_shared<Disjunction>(formulae);
71 std::vector<FormulaPtr> formulae = {phi};
72 formulae.insert(formulae.end(), psi0.begin(), psi0.end());
73 return std::make_shared<Disjunction>(formulae);
75 return std::make_shared<Disjunction>(std::vector<FormulaPtr>({phi, psi}));
84 class_<Disjunction, std::shared_ptr<Disjunction>, bases<CompoundFormula>>
85 (
"Disjunction", init<const std::vector<FormulaPtr> &>());
Disjunction(const std::vector< FormulaPtr > &formulae)
void createType< Disjunction >()
FormulaPtr operator|(const FormulaPtr &phi, const FormulaPtr &psi)
std::shared_ptr< Formula > FormulaPtr