Skip to content

Commit

Permalink
Refactor atom class to include a sigma literal
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardodebenedictis committed Mar 27, 2024
1 parent 5d3c614 commit a1fc937
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace riddle
*
* @return std::shared_ptr<string_item> The string expression.
*/
[[nodiscard]] virtual std::shared_ptr<string_item> new_string() = 0;
[[nodiscard]] std::shared_ptr<string_item> new_string();
/**
* @brief Create a new string expression with a value.
*
Expand Down
7 changes: 5 additions & 2 deletions include/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ namespace riddle
class atom : public item, public env
{
public:
atom(predicate &t, bool is_fact, std::map<std::string, std::shared_ptr<item>> &&args = {});
atom(predicate &t, bool is_fact, const utils::lit &sigma, std::map<std::string, std::shared_ptr<item>> &&args = {});
virtual ~atom() = default;

[[nodiscard]] bool is_fact() const { return fact; }
[[nodiscard]] utils::lit &get_sigma() { return sigma; }
[[nodiscard]] const utils::lit &get_sigma() const { return sigma; }

private:
bool fact; // whether the atom is a fact or a goal..
bool fact; // whether the atom is a fact or a goal..
utils::lit sigma; // the literal indicating the status of the atom (i.e., true if active, false if unified, undefined if inactive)..
};
} // namespace riddle
1 change: 1 addition & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace riddle
std::shared_ptr<arith_item> core::new_real(const utils::rational &value) { return std::make_shared<arith_item>(real_tp, utils::lin(value)); }
std::shared_ptr<arith_item> core::new_time(const utils::rational &value) { return std::make_shared<arith_item>(time_tp, utils::lin(value)); }

std::shared_ptr<string_item> core::new_string() { return std::make_shared<string_item>(string_tp); }
std::shared_ptr<string_item> core::new_string(const std::string &value) { return std::make_shared<string_item>(string_tp, value); }

std::shared_ptr<component> core::new_item(component_type &tp) { return std::make_shared<component>(tp); }
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace riddle

component::component(type &t, std::shared_ptr<env> parent) : item(t), env(t.get_scope().get_core(), parent) {}

atom::atom(predicate &t, bool is_fact, std::map<std::string, std::shared_ptr<item>> &&args) : item(t), env(t.get_scope().get_core(), nullptr, std::move(args)), fact(is_fact) {}
atom::atom(predicate &t, bool is_fact, const utils::lit &sigma, std::map<std::string, std::shared_ptr<item>> &&args) : item(t), env(t.get_scope().get_core(), nullptr, std::move(args)), fact(is_fact), sigma(sigma) {}
} // namespace riddle

0 comments on commit a1fc937

Please sign in to comment.