pub struct Rule {
pub head: Atom,
pub body: Vec<Literal>,
}Expand description
Datalog rule: head :- body_1, ..., body_n.
Fields§
§head: AtomHead atom.
body: Vec<Literal>Body literals. An empty body represents a fact.
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn positive(head: Atom, body: Vec<Atom>) -> Self
pub fn positive(head: Atom, body: Vec<Atom>) -> Self
Construct a rule whose body contains only positive literals.
Convenience for the common case — callers that do not need
negation never have to name Literal.
Sourcepub fn new(head: Atom, body: Vec<Literal>) -> Self
pub fn new(head: Atom, body: Vec<Literal>) -> Self
Construct a rule with an explicit literal body.
Sourcepub fn is_safe(&self) -> bool
pub fn is_safe(&self) -> bool
Returns true when the rule satisfies Datalog¬ safety.
A rule is safe when:
- Every variable appearing in the head is bound by some positive body
atom or
Bind. - Every variable appearing in a negative body literal is bound by
some positive body atom or
Bind(range restriction — negation-as-failure requires the negated atom to be ground by the time it is evaluated). - Every variable appearing inside a
Literal::Filteris bound by some positive body atom orBind— filters guard candidate bindings, they do not produce them. - Every variable inside a
Literal::Bindexpression is bound by an earlier positive body atom orBind, and theBind’s output variable is fresh (not bound by any earlier positive atom orBind).
Trait Implementations§
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more