knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::Formula Class Referenceabstract

#include <Formula.h>

Inheritance diagram for knowrob::Formula:
Collaboration diagram for knowrob::Formula:

Public Member Functions

 Formula (const FormulaType &type)
 
virtual ~Formula ()=default
 
bool operator== (const Formula &other) const
 
FormulaType type () const
 
bool isAtomic () const
 
bool isGround () const
 
bool isTop () const
 
bool isBottom () const
 
 Formula (const FormulaType &type)
 
virtual ~Formula ()=default
 
bool operator== (const Formula &other) const
 
FormulaType type () const
 
bool isAtomic () const
 
bool isGround () const
 
bool isTop () const
 
bool isBottom () const
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual void write (std::ostream &os) const =0
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual void write (std::ostream &os) const =0
 
virtual std::string format () const
 

Protected Member Functions

virtual bool isEqual (const Formula &other) const =0
 
virtual bool isEqual (const Formula &other) const =0
 

Protected Attributes

const FormulaType type_
 
bool isGround_ = true
 

Detailed Description

A propositional formula. Note that all formulas are immutable.

Definition at line 34 of file Formula.h.

Constructor & Destructor Documentation

◆ Formula() [1/2]

Formula::Formula ( const FormulaType type)
explicit
Parameters
typethe type of the formula.

Definition at line 22 of file Formula.cpp.

23  : type_(type) {}
const FormulaType type_
Definition: Formula.h:77
FormulaType type() const
Definition: Formula.h:52

◆ ~Formula() [1/2]

virtual knowrob::Formula::~Formula ( )
virtualdefault

◆ Formula() [2/2]

knowrob::Formula::Formula ( const FormulaType type)
explicit
Parameters
typethe type of the formula.

◆ ~Formula() [2/2]

virtual knowrob::Formula::~Formula ( )
virtualdefault

Member Function Documentation

◆ isAtomic() [1/2]

bool Formula::isAtomic ( ) const

Is this formula free of subformulas?

Returns
true if this formula is atomic.

Definition at line 30 of file Formula.cpp.

30  {
31  return type() == FormulaType::PREDICATE;
32 }

◆ isAtomic() [2/2]

bool knowrob::Formula::isAtomic ( ) const

Is this formula free of subformulas?

Returns
true if this formula is atomic.

◆ isBottom() [1/2]

bool Formula::isBottom ( ) const
Returns
true if this is the bottom concept.

Definition at line 34 of file Formula.cpp.

34  {
35  return (this == Bottom::get().get());
36 }
static const std::shared_ptr< Bottom > & get()
Definition: Bottom.cpp:12

◆ isBottom() [2/2]

bool knowrob::Formula::isBottom ( ) const
Returns
true if this is the bottom concept.

◆ isEqual() [1/2]

◆ isEqual() [2/2]

◆ isGround() [1/2]

bool knowrob::Formula::isGround ( ) const
inline
Returns
true if this formula isMoreGeneralThan no free variables.

Definition at line 64 of file Formula.h.

64 { return isGround_; }
bool isGround_
Definition: Formula.h:78

◆ isGround() [2/2]

bool knowrob::Formula::isGround ( ) const
inline
Returns
true if this formula isMoreGeneralThan no free variables.

Definition at line 64 of file Formula.h.

64 { return isGround_; }

◆ isTop() [1/2]

bool Formula::isTop ( ) const
Returns
true if this is the top concept.

Definition at line 38 of file Formula.cpp.

38  {
39  return (this == Top::get().get());
40 }
static const std::shared_ptr< Top > & get()
Definition: Top.cpp:11

◆ isTop() [2/2]

bool knowrob::Formula::isTop ( ) const
Returns
true if this is the top concept.

◆ operator==() [1/2]

bool Formula::operator== ( const Formula other) const
Parameters
otheranother formula
Returns
true if both formulas are syntactically equal

Definition at line 25 of file Formula.cpp.

25  {
26  // note: isEqual can safely perform static cast as type id's do match
27  return typeid(*this) == typeid(other) && isEqual(other);
28 }
virtual bool isEqual(const Formula &other) const =0

◆ operator==() [2/2]

bool knowrob::Formula::operator== ( const Formula other) const
Parameters
otheranother formula
Returns
true if both formulas are syntactically equal

◆ type() [1/2]

FormulaType knowrob::Formula::type ( ) const
inline
Returns
the type of this formula.

Definition at line 52 of file Formula.h.

52 { return type_; }

◆ type() [2/2]

FormulaType knowrob::Formula::type ( ) const
inline
Returns
the type of this formula.

Definition at line 52 of file Formula.h.

52 { return type_; }

Member Data Documentation

◆ isGround_

bool knowrob::Formula::isGround_ = true
protected

Definition at line 78 of file Formula.h.

◆ type_

const FormulaType knowrob::Formula::type_
protected

Definition at line 77 of file Formula.h.


The documentation for this class was generated from the following files: