knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Formula.h
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 #ifndef KNOWROB_FORMULA_H_
7 #define KNOWROB_FORMULA_H_
8 
9 #include <memory>
10 #include <ostream>
11 #include "knowrob/Printable.h"
12 
13 namespace knowrob {
17  enum class FormulaType {
18  // A formula of the form `P(t_1,..,t_n)` where each ti is a term
19  // and "P" is a n-ary predicate symbol (or functor).
20  PREDICATE,
21  // A formula of the form `phi_1 AND ... AND phi_n` where each phi_i is a formula.
23  // A formula of the form `phi_1 OR ... OR phi_n` where each phi_i is a formula.
25  NEGATION,
27  MODAL
28  };
29 
34  class Formula : public Printable {
35  public:
39  explicit Formula(const FormulaType &type);
40 
41  virtual ~Formula() = default;
42 
47  bool operator==(const Formula &other) const;
48 
52  FormulaType type() const { return type_; }
53 
59  bool isAtomic() const;
60 
64  bool isGround() const { return isGround_; }
65 
69  bool isTop() const;
70 
74  bool isBottom() const;
75 
76  protected:
77  const FormulaType type_;
78  bool isGround_ = true;
79 
80  virtual bool isEqual(const Formula &other) const = 0;
81  };
82 
86  class FormulaLabel {
87  public:
88  FormulaLabel() = default;
89 
90  virtual ~FormulaLabel() = default;
91 
92  bool operator==(const FormulaLabel &other);
93 
94  protected:
95  virtual bool isEqual(const FormulaLabel &other) const = 0;
96  };
97 
98  // alias declaration
99  using FormulaPtr = std::shared_ptr<Formula>;
100  using FormulaLabelPtr = std::shared_ptr<FormulaLabel>;
101 }
102 
103 #endif //KNOWROB_FORMULA_H_
const FormulaType type_
Definition: Formula.h:77
FormulaType type() const
Definition: Formula.h:52
bool operator==(const Formula &other) const
bool isBottom() const
Formula(const FormulaType &type)
virtual bool isEqual(const Formula &other) const =0
bool isGround() const
Definition: Formula.h:64
virtual ~Formula()=default
bool isTop() const
bool isAtomic() const
bool isGround_
Definition: Formula.h:78
virtual bool isEqual(const FormulaLabel &other) const =0
virtual ~FormulaLabel()=default
bool operator==(const FormulaLabel &other)
std::shared_ptr< Formula > FormulaPtr
Definition: Formula.h:99
std::shared_ptr< FormulaLabel > FormulaLabelPtr
Definition: Formula.h:100
FormulaType
Definition: Formula.h:17