pulsatrix
Loading...
Searching...
No Matches
datalog_fact_database.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <cstddef>
9#include <unordered_set>
10
12
13namespace pulsatrix::datalog {
14
16using FactSet = std::unordered_set<Atom, AtomHash>;
17
24public:
25 FactDatabase() = default;
27
34 bool insert(Atom fact);
35
36 [[nodiscard]] bool contains(const Atom& fact) const { return facts_.find(fact) != facts_.end(); }
37 [[nodiscard]] std::size_t size() const { return facts_.size(); }
38 [[nodiscard]] bool empty() const { return facts_.empty(); }
39 [[nodiscard]] const FactSet& facts() const { return facts_; }
40
41 [[nodiscard]] bool operator==(const FactDatabase& other) const { return facts_ == other.facts_; }
42 [[nodiscard]] bool operator!=(const FactDatabase& other) const { return !(*this == other); }
43
44private:
45 FactSet facts_;
46};
47
48} // namespace pulsatrix::datalog
An atom is a predicate name applied to a tuple of Terms, e.g. edge(a, b) or ancestor(X,...
Definition datalog_atom.hpp:24
A fact database: a set of ground atoms. Boolean semiring only (Mission 0's scope) – a fact is simply ...
Definition datalog_fact_database.hpp:23
bool operator!=(const FactDatabase &other) const
Definition datalog_fact_database.hpp:42
bool contains(const Atom &fact) const
Definition datalog_fact_database.hpp:36
bool operator==(const FactDatabase &other) const
Definition datalog_fact_database.hpp:41
bool insert(Atom fact)
Adds a fact.
std::size_t size() const
Definition datalog_fact_database.hpp:37
const FactSet & facts() const
Definition datalog_fact_database.hpp:39
bool empty() const
Definition datalog_fact_database.hpp:38
A Datalog atom: a predicate name plus a tuple of terms, no function symbols. Phase 3 Mission 0 of cam...
Definition datalog_atom.hpp:14
std::unordered_set< Atom, AtomHash > FactSet
The concrete set type a FactDatabase stores facts in and the engine derives into.
Definition datalog_fact_database.hpp:16