pub enum RuleHead {
Atom(Atom),
Conjunction(HeadConjunction),
Existential {
variables: ExistentialVariables,
conjunction: HeadConjunction,
},
Disjunction(HeadDisjunction),
Falsum,
}Expand description
The head of a Rule.
Every head reads as a disjunction of conjunctions of atoms: an atom is one
disjunct of one atom, and Self::Falsum has no disjunct at all. Atoms
are addressed by HeadAtomPath in that reading.
Variants§
Atom(Atom)
One atom: plain Datalog.
Conjunction(HeadConjunction)
Several atoms derived together from one body match.
Existential
∃ variables . conjunction: each body match requires witnesses for
the existential variables.
Fields
variables: ExistentialVariablesThe existentially quantified variables.
conjunction: HeadConjunctionThe atoms over body and existential variables.
Disjunction(HeadDisjunction)
At least one of the disjuncts holds for each body match.
Falsum
false: the body must have no match. An inconsistency constraint.
Implementations§
Source§impl RuleHead
impl RuleHead
Sourcepub fn as_atom(&self) -> Option<&Atom>
pub fn as_atom(&self) -> Option<&Atom>
The single atom of a Self::Atom head; None for any other head.
Sourcepub fn as_atom_mut(&mut self) -> Option<&mut Atom>
pub fn as_atom_mut(&mut self) -> Option<&mut Atom>
Mutable access to the single atom of a Self::Atom head.
Sourcepub fn disjunct_count(&self) -> usize
pub fn disjunct_count(&self) -> usize
Number of disjuncts: zero for Self::Falsum, otherwise at least one.
Sourcepub fn disjunct(&self, index: HeadDisjunctIndex) -> Option<&[Atom]>
pub fn disjunct(&self, index: HeadDisjunctIndex) -> Option<&[Atom]>
The atoms of one disjunct, or None past the last disjunct.
Sourcepub fn atoms(&self) -> impl Iterator<Item = (HeadAtomPath, &Atom)>
pub fn atoms(&self) -> impl Iterator<Item = (HeadAtomPath, &Atom)>
Every head atom with its path, disjunct by disjunct in authored order.
Sourcepub fn atoms_mut(&mut self) -> Box<dyn Iterator<Item = &mut Atom> + '_>
pub fn atoms_mut(&mut self) -> Box<dyn Iterator<Item = &mut Atom> + '_>
Mutable access to every head atom, disjunct by disjunct.
Sourcepub fn existential_variables(&self) -> &[VariableSymbol]
pub fn existential_variables(&self) -> &[VariableSymbol]
The existentially quantified variables; empty unless existential.
Sourcepub fn is_existential(&self, variable: &VariableSymbol) -> bool
pub fn is_existential(&self, variable: &VariableSymbol) -> bool
Whether variable is existentially quantified by this head.
Sourcepub fn variables(&self) -> BTreeSet<VariableSymbol>
pub fn variables(&self) -> BTreeSet<VariableSymbol>
Distinct variables of every head atom, existential ones included.