Skip to main content

Program

Struct Program 

Source
pub struct Program {
Show 14 fields pub imports: Vec<UseDecl>, pub functions: Vec<FuncDef>, pub domains: Vec<DomainDecl>, pub predicates: Vec<PredDecl>, pub rules: Vec<Rule>, pub constraints: Vec<Constraint>, pub queries: Vec<Query>, pub prob_facts: Vec<ProbFact>, pub annotated_disjunctions: Vec<AnnotatedDisjunction>, pub evidence: Vec<Evidence>, pub prob_queries: Vec<ProbQuery>, pub neural_predicates: Vec<NeuralPredDecl>, pub learnable_rules: Vec<LearnableRule>, pub directives: Directives,
}
Expand description

A complete XLOG program

Fields§

§imports: Vec<UseDecl>

Import declarations (use ...).

§functions: Vec<FuncDef>

User-defined function definitions.

§domains: Vec<DomainDecl>

Domain declarations.

§predicates: Vec<PredDecl>

Predicate type declarations.

§rules: Vec<Rule>

Rules and facts.

§constraints: Vec<Constraint>

Integrity constraints (:- ...).

§queries: Vec<Query>

Queries (?- ...).

§prob_facts: Vec<ProbFact>

Probabilistic facts (p::atom.).

§annotated_disjunctions: Vec<AnnotatedDisjunction>

Annotated disjunctions.

§evidence: Vec<Evidence>

Evidence statements.

§prob_queries: Vec<ProbQuery>

Probabilistic queries (query(atom).).

§neural_predicates: Vec<NeuralPredDecl>

Neural predicate declarations.

§learnable_rules: Vec<LearnableRule>

Learnable rule templates (ILP).

§directives: Directives

Compilation directives.

Implementations§

Source§

impl Program

Source

pub fn new() -> Self

Create an empty program.

Source

pub fn facts(&self) -> impl Iterator<Item = &Rule>

Iterate over ground facts (rules with empty bodies).

Source

pub fn proper_rules(&self) -> impl Iterator<Item = &Rule>

Iterate over proper rules (non-fact rules with bodies).

Source

pub fn defined_predicates(&self) -> Vec<&str>

Collect the set of predicate names defined (appearing as rule heads).

Source

pub fn is_probabilistic_profile(&self) -> bool

Returns true if this program uses probabilistic features.

Source

pub fn prob_engine(&self) -> ProbEngine

Return the probabilistic engine (from directives, or the default).

Source

pub fn merge_from( &mut self, other: &Program, imported_items: Option<&HashSet<String>>, )

Merge another program’s exports into this program. Used for importing modules - adds predicates, functions, rules from the imported module. Only merges public items (private items are not exported).

§Arguments
  • other - The program to merge from
  • imported_items - Optional set of specific items to import. If None, imports all public items.

Trait Implementations§

Source§

impl Clone for Program

Source§

fn clone(&self) -> Program

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Program

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Program

Source§

fn default() -> Program

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,