symbolic
formula.h
1 
10 #ifndef SYMBOLIC_FORMULA_H_
11 #define SYMBOLIC_FORMULA_H_
12 
13 #include <functional> // std::function
14 #include <optional> // std::optional
15 #include <ostream> // std::ostream
16 #include <set> // std::set
17 #include <vector> // std::vector
18 
19 #include "symbolic/object.h"
20 #include "symbolic/proposition.h"
21 #include "symbolic/state.h"
22 #include "symbolic/utils/parameter_generator.h"
23 
24 namespace VAL {
25 
26 class goal;
27 
28 } // namespace VAL
29 
30 namespace symbolic {
31 
32 class Pddl;
33 
34 class Action;
35 
36 class Formula {
37  public:
38  Formula() = default;
39 
40  Formula(const Pddl& pddl, const VAL::goal* symbol)
41  : Formula(pddl, symbol, {}) {}
42 
43  Formula(const Pddl& pddl, const VAL::goal* symbol,
44  const std::vector<Object>& parameters);
45 
46  const VAL::goal* symbol() const { return symbol_; }
47 
48  bool operator()(const State& state,
49  const std::vector<Object>& arguments) const {
50  return P_(state, arguments);
51  };
52 
53  bool operator()(const State& state) const { return P_(state, {}); };
54 
55  std::optional<bool> operator()(const PartialState& state,
56  const std::vector<Object>& arguments) const;
57 
58  std::optional<bool> operator()(const PartialState& state) const;
59 
60  const std::string& to_string() const { return str_formula_; }
61 
62  friend std::ostream& operator<<(std::ostream& os, const Formula& F);
63 
68  static std::function<const std::vector<Object>&(const std::vector<Object>&)>
69  CreateApplicationFunction(const std::vector<Object>& action_params,
70  const std::vector<Object>& prop_params);
71 
72  private:
73  const VAL::goal* symbol_ = nullptr;
74 
75  std::function<bool(const State& state, const std::vector<Object>& arguments)>
76  P_;
77 
78  std::function<bool(const PartialState& state,
79  const std::vector<Object>& arguments)>
80  PP_;
81 
82  std::string str_formula_;
83 };
84 
85 } // namespace symbolic
86 
87 #endif // SYMBOLIC_FORMULA_H_
symbolic::Formula::CreateApplicationFunction
static std::function< const std::vector< Object > &(const std::vector< Object > &)> CreateApplicationFunction(const std::vector< Object > &action_params, const std::vector< Object > &prop_params)
Definition: formula.cc:379
VAL
Definition: pddl.cc:27
symbolic
Definition: action.cc:329
symbolic::Pddl
Definition: pddl.h:40
symbolic::State
Definition: state.h:40
symbolic::Formula
Definition: formula.h:36
symbolic::PartialState
Definition: state.h:126