pub enum Literal {
Positive(Atom),
Negative(Atom),
Filter(BuiltinFilter),
Bind {
var: VariableSymbol,
expr: BindExpr,
},
Aggregate(AggregateBody),
}Expand description
Datalog body literal — a positive or negated atom, a built-in
filter expression, or a built-in BIND(expr AS ?var) form.
Rule bodies in Datalog¬ are conjunctions of literals. Positive literals must match facts in the database; negative literals must not match. Negation semantics follow the stratified negation-as-failure convention: every negated atom references only predicates in strictly lower strata, so the set of facts the negation is evaluated against is already closed by the time the rule fires.
Filter literals carry a BuiltinFilter expression that
guards the current candidate binding — the evaluator drops a
binding whenever the filter does not evaluate to true.
Bind literals carry a BindExpr expression and a fresh
variable name; the evaluator extends the current candidate
binding with var → eval(expr, binding) and the new variable
is then visible to all subsequent body literals (including
further Binds, Filters, the rule head, and SPARQL-style
constraints over computed values). Filter and bind literals
participate in safety analysis but contribute no edges to the
predicate dependency graph used by stratification.
Variants§
Positive(Atom)
Positive literal — the body atom must match a fact.
Negative(Atom)
Negative literal — the body atom must not match any fact.
Filter(BuiltinFilter)
Built-in filter expression evaluated against the current candidate binding.
Bind
BIND(expr AS ?var) — extend the current candidate
binding with a computed value. var must be fresh
(untouched by any earlier positive atom or Bind); every
variable inside expr must be bound by an earlier
positive atom or Bind.
Fields
var: VariableSymbolThe fresh variable produced by this bind.
Aggregate(AggregateBody)
Aggregation sub-query — fold the inner body into a
per-group aggregate result that the outer body sees as a
freshly-bound variable. See AggregateBody for the
scoping and inner-body restrictions; the evaluator wiring
is a deferred extension follow-up.
Implementations§
Source§impl Literal
impl Literal
Sourcepub fn atom(&self) -> Option<&Atom>
pub fn atom(&self) -> Option<&Atom>
Access the underlying atom, when this literal carries one.
Returns None for Literal::Filter, Literal::Bind,
and Literal::Aggregate — none of which carries a
single fact-matching atom in its top-level position.
(An aggregate’s inner literals live inside
AggregateBody::inner_body.)
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
True when the literal is positive.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
True when the literal is negated.
Sourcepub fn is_filter(&self) -> bool
pub fn is_filter(&self) -> bool
True when the literal is a BuiltinFilter guard.
Sourcepub fn is_aggregate(&self) -> bool
pub fn is_aggregate(&self) -> bool
True when the literal is an aggregation sub-query.