knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Negation.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #include "knowrob/formulas/Negation.h"
7 #include "knowrob/formulas/Predicate.h"
8 #include "knowrob/formulas/Top.h"
9 #include "knowrob/formulas/Bottom.h"
10 #include "knowrob/integration/python/utils.h"
11 
12 using namespace knowrob;
13 
16 }
17 
18 bool Negation::isEqual(const Formula &other) const {
19  const auto &x = static_cast<const Negation &>(other); // NOLINT
20  return (*negatedFormula()) == (*x.negatedFormula());
21 }
22 
23 namespace knowrob {
25  if (phi->type() == FormulaType::NEGATION) {
26  return ((Negation *) phi.get())->negatedFormula();
27  } else if (phi->isBottom()) {
28  return Top::get();
29  } else if (phi->isTop()) {
30  return Bottom::get();
31  } else {
32  return std::make_shared<Negation>(phi);
33  }
34  }
35 }
36 
37 namespace knowrob::py {
38  template<>
40  using namespace boost::python;
41  class_<Negation, std::shared_ptr<Negation>, bases<CompoundFormula>>
42  ("Negation", init<const FormulaPtr &>())
43  .def("negatedFormula", &Negation::negatedFormula, return_value_policy<copy_const_reference>());
44  }
45 }
static const std::shared_ptr< Bottom > & get()
Definition: Bottom.cpp:12
bool isEqual(const Formula &other) const override
Definition: Negation.cpp:18
const FormulaPtr & negatedFormula() const
Definition: Negation.h:23
Negation(const FormulaPtr &formula)
Definition: Negation.cpp:14
static const std::shared_ptr< Top > & get()
Definition: Top.cpp:11
FormulaRule & formula()
Definition: formula.cpp:283
void createType< Negation >()
Definition: Negation.cpp:39
std::shared_ptr< Formula > FormulaPtr
Definition: Formula.h:99
FormulaPtr operator~(const FormulaPtr &phi)
Definition: Negation.cpp:24
FormulaType
Definition: Formula.h:17