pulsatrix
Loading...
Searching...
No Matches
pulsatrix::datalog::Term Class Reference

A Datalog term: either a constant (e.g. a) or a variable (e.g. X) – never a compound/function-symbol term. More...

#include <datalog_term.hpp>

Public Member Functions

TermKind kind () const
 Whether this term is a constant or a variable.
 
bool is_constant () const
 True iff this term is a constant.
 
bool is_variable () const
 True iff this term is a variable.
 
const std::string & value () const
 The constant's value, or the variable's name – whichever this term is.
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 

Static Public Member Functions

static Term make_constant (std::string value)
 Constructs a constant term with the given value (e.g. "a").
 
static Term make_variable (std::string name)
 Constructs a variable term with the given name (e.g. "X").
 

Detailed Description

A Datalog term: either a constant (e.g. a) or a variable (e.g. X) – never a compound/function-symbol term.

Note
Enforced structurally, not just documented: the only state this class stores is a TermKind tag plus a single std::string payload (the constant's value or the variable's name). There is no member, constructor, or accessor through which a Term could ever hold another Term or a list of Terms – the decidable-fragment restriction (campaign doc Risk Register: "no function symbols, no unbounded recursion over complex/nested terms") is a property of this type's shape, not a runtime check that could be bypassed.

Representation choice (mission Stage 3 design question 2): interned as plain std::strings, compared/hashed via std::string's own operator==/std::hash, not small integer IDs. Rationale: this mission's stated scope is the boolean semiring on toy-scale knowledge bases (campaign Risk Register: "keep Phase 3's exit-gate knowledge base deliberately small ... until proven") – correctness and readability of hand-verified fixpoint traces matter far more than string-comparison performance at this stage. An integer-interning table is a legitimate future optimization if Mission 1/2's real-valued semiring work hits an actual bottleneck, but building it now would be optimizing ahead of a need this mission doesn't have.

Member Function Documentation

◆ is_constant()

bool pulsatrix::datalog::Term::is_constant ( ) const
inline

True iff this term is a constant.

◆ is_variable()

bool pulsatrix::datalog::Term::is_variable ( ) const
inline

True iff this term is a variable.

◆ kind()

TermKind pulsatrix::datalog::Term::kind ( ) const
inline

Whether this term is a constant or a variable.

◆ make_constant()

static Term pulsatrix::datalog::Term::make_constant ( std::string  value)
inlinestatic

Constructs a constant term with the given value (e.g. "a").

◆ make_variable()

static Term pulsatrix::datalog::Term::make_variable ( std::string  name)
inlinestatic

Constructs a variable term with the given name (e.g. "X").

◆ operator!=()

bool pulsatrix::datalog::Term::operator!= ( const Term &  other) const
inline

◆ operator==()

bool pulsatrix::datalog::Term::operator== ( const Term &  other) const
inline

◆ value()

const std::string & pulsatrix::datalog::Term::value ( ) const
inline

The constant's value, or the variable's name – whichever this term is.


The documentation for this class was generated from the following file: