10 #ifndef SYMBOLIC_PROPOSITION_H_
11 #define SYMBOLIC_PROPOSITION_H_
19 #include "symbolic/object.h"
27 virtual const std::string& name()
const = 0;
29 virtual const std::vector<Object>& arguments()
const = 0;
31 virtual std::string to_string()
const;
32 virtual std::string to_pddl()
const;
34 size_t hash()
const {
return hash_; }
36 static std::string ParseHead(
const std::string& atom) {
37 return atom.substr(0, atom.find_first_of(
'('));
42 return std::tie(lhs.name(), lhs.arguments()) <
43 std::tie(rhs.name(), rhs.arguments());
47 return std::tie(lhs.hash_, lhs.name(), lhs.arguments()) ==
48 std::tie(rhs.hash_, rhs.name(), rhs.arguments());
55 friend std::ostream& operator<<(std::ostream& os,
const PropositionBase& P);
61 void PrecomputeHash() { hash_ = Hash(*
this); }
62 void PrecomputeHash(
size_t predicate_hash) { hash_ = Hash(*
this, predicate_hash); }
72 std::vector<Object>&& arguments)
73 : name_(name_predicate), arguments_(std::move(arguments)) {
78 const std::vector<Object>& arguments)
79 : name_(name_predicate), arguments_(arguments) {
84 : name_(ParseHead(str_prop)),
85 arguments_(Object::ParseArguments(pddl, str_prop)) {
98 arguments_(other.arguments()) {}
100 const std::string& name()
const override {
return name_; }
102 const std::vector<Object>& arguments()
const override {
return arguments_; }
106 std::vector<Object> arguments_;
112 const std::vector<Object>* arguments,
113 size_t predicate_hash)
114 : name_(name_predicate), arguments_(arguments) {
115 PrecomputeHash(predicate_hash);
118 const std::string& name()
const override {
return *name_; }
120 const std::vector<Object>& arguments()
const override {
return *arguments_; }
123 const std::string* name_;
124 const std::vector<Object>* arguments_;
133 std::vector<Object>&& arguments,
bool is_pos)
134 :
Proposition(name_predicate, std::move(arguments)), is_pos_(is_pos) {}
136 bool is_pos()
const {
return is_pos_; }
138 std::string sign()
const {
return Sign(is_pos()); };
140 static std::string Sign(
bool is_pos) {
return is_pos ?
"+" :
"-"; };
152 using is_transparent = void;
160 using is_transparent = void;
168 using is_transparent = void;
176 #endif // SYMBOLIC_PROPOSITION_H_