8 #include "knowrob/formulas/Predicate.h"
9 #include "knowrob/terms/Function.h"
10 #include "knowrob/integration/python/utils.h"
20 functor_(std::move(functor)),
21 arguments_(arguments),
22 variables_(getVariables1()) {
27 const auto &x =
static_cast<const Predicate &
>(other);
29 for (std::size_t i = 0; i <
arguments_.size(); ++i) {
30 if (!(*(
arguments_[i]) == *(x.arguments_[i])))
return false;
39 std::set<std::string_view> out;
41 out.insert(arg->variables().begin(), arg->variables().end());
47 static const auto GOLDEN_RATIO_HASH =
static_cast<size_t>(0x9e3779b9);
48 auto seed =
static_cast<size_t>(0);
54 seed ^= std::hash<std::string_view>{}(
functor_->stringForm()) + GOLDEN_RATIO_HASH + (seed << 6) + (seed >> 2);
56 seed ^= arg->hash() + GOLDEN_RATIO_HASH + (seed << 6) + (seed >> 2);
73 for (uint32_t i = 0; i <
arguments_.size(); i++) {
90 return std::make_shared<Predicate>(fn->functor(), fn->arguments());
97 class_<Predicate, std::shared_ptr<Predicate>, bases<Formula>>
98 (
"Predicate", init<std::string_view, const std::vector<TermPtr> &>())
99 .def(init<
const AtomPtr &,
const std::vector<TermPtr> &>())
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
const std::set< std::string_view > variables_
const std::vector< TermPtr > & arguments() const
std::set< std::string_view > getVariables1() const
bool isEqual(const Formula &other) const override
static FunctionPtr toFunction(const std::shared_ptr< Predicate > &predicate)
static std::shared_ptr< Predicate > fromFunction(const FunctionPtr &fn)
const std::vector< TermPtr > arguments_
Predicate(std::string_view functor, const std::vector< TermPtr > &arguments={})
void write(std::ostream &os) const override
PREDICATE(mng_collections, 2)
void createType< Predicate >()
std::shared_ptr< Function > FunctionPtr
std::shared_ptr< Atom > AtomPtr