pub trait BuiltinPredicate {
// Required methods
fn name(&self) -> &'static str;
fn kind(&self) -> Kind;
fn arg_groundness(&self) -> &'static [bool];
fn apply(&self, lit: &Literal) -> Option<Literal>;
// Provided method
fn select(&self, lit: &Literal) -> SelectBuiltinResult { ... }
}
Required Methods§
fn name(&self) -> &'static str
Sourcefn kind(&self) -> Kind
fn kind(&self) -> Kind
The kind of this predicate or operator. Should match https://github.com/modus-continens/docs/blob/main/src/library/README.md
Sourcefn arg_groundness(&self) -> &'static [bool]
fn arg_groundness(&self) -> &'static [bool]
Return if the argument is allowed to be ungrounded. This means that a “false” here will force a constant.
Sourcefn apply(&self, lit: &Literal) -> Option<Literal>
fn apply(&self, lit: &Literal) -> Option<Literal>
Return a new literal specifically constructed to unify with the input literal. The returned literal will essentially be used as the head of a new “hidden” rule, which will hopefully unify with the input literal. The rule will contain no body literals.
For example, the implementation of run should simply return the input literal, after checking that it only contains a constant. (Returning any unresolved variables can make the actual generation of build instructions impossible)
Renaming will not be done on this literal, so if variables are needed they must all be either auxillary or some existing variables from the input.