A weighted fact database: a map from ground atom to a semiring value type T (bool for the trivial/boolean instantiation, double/float for the real-valued (+, x) instantiation).
More...
#include <datalog_weighted_fact_database.hpp>
template<typename T>
class pulsatrix::datalog::WeightedFactDatabase< T >
A weighted fact database: a map from ground atom to a semiring value type T (bool for the trivial/boolean instantiation, double/float for the real-valued (+, x) instantiation).
- Note
- Phase 3 Mission 2 additive extension:
T = DualNumber<double> (see datalog_dual_semiring.hpp) is a third instantiation, added alongside the original bool/double/float set – Mission 1's own Decision 3 rationale ("only a closed,
known set of Value types is ever needed") is a scoped, revisitable choice, not a permanent ceiling; Mission 2's forward-mode-AD requirement is exactly the kind of genuine new need Mission 1's own notes anticipated as a "contained, mechanical
follow-up." No existing instantiation's behavior changes.
-
Stage 3 design decision 1 (FactDatabase generalization shape): this is a new templated type introduced alongside Mission 0's
FactDatabase, not a rewrite of it in place. Verified achievable (not assumed) by direct inspection of Mission 0's shipped FactDatabase: its own public contract (insert/contains/size/empty/ facts()/operator==, all over a set, no weight parameter anywhere) is a strictly narrower shape than a weighted map would need (set(fact, weight)/weight_of(fact)), so "generalize `FactDatabase` in place" would have meant either breaking its existing call sites (naive_evaluate/semi_naive_evaluate/all of datalog_fact_database_test.cpp) or bolting an unused weight parameter onto every boolean-only call site for no benefit. Introducing WeightedFactDatabase<T> alongside it instead makes the campaign doc's own phrasing – "boolean semiring re-expressed as the trivial case" – literally true: Mission 0's FactDatabase/naive_evaluate/semi_naive_evaluate are untouched (zero diff against Mission 0's shipped files), and the "trivial case" is demonstrated by running the new generic naive_evaluate_weighted<BooleanSemiring> against a WeightedFactDatabase<bool> built from the identical toy KB and checking it reproduces Mission 0's own naive_evaluate fixpoint exactly (the regression/equivalence test).
◆ WeightedFactDatabase() [1/2]
◆ WeightedFactDatabase() [2/2]
◆ contains()
◆ empty()
◆ facts()
◆ operator!=()
◆ operator==()
◆ set()
Sets (overwrites) a fact's weight.
- Exceptions
-
| std::invalid_argument | if fact is not ground (contains a variable term). |
◆ size()
◆ weight_of()
The fact's current weight, or default_weight (conventionally Semiring::zero()) if the fact is not present – "zero derivation paths" reads as "absent from the
map," never as an explicit zero-weight entry.
The documentation for this class was generated from the following file: