Skip to main content

HypergraphRule

Struct HypergraphRule 

Source
pub struct HypergraphRule {
    pub head_predicate: String,
    pub vertices: Vec<Vertex>,
    pub hyperedges: Vec<Hyperedge>,
    pub head_has_aggregation: bool,
    pub has_negation: bool,
    pub has_is_expr: bool,
    pub comparison_count: usize,
    pub is_fact: bool,
}
Expand description

A rule body represented as a hypergraph.

Vertices are body variables (named only — anonymous wildcards do not participate in the graph). Hyperedges are positive body atoms. Negated, Comparison, and IsExpr body literals are NOT hyperedges; their presence is recorded in HypergraphRule::has_negation / HypergraphRule::has_is_expr so the eligibility analyzer can flag them as boundaries without the IR pretending they’re join structure.

Construction is total: every Rule produces a HypergraphRule. Whether the rule is eligible for multiway planning is a separate question handled by crate::hypergraph::eligibility::analyze.

Fields§

§head_predicate: String

Predicate name of the rule head.

§vertices: Vec<Vertex>

Variables in first-appearance order across the body. Empty for ground facts and bodies that contain only constants.

§hyperedges: Vec<Hyperedge>

Positive body atoms in source order.

§head_has_aggregation: bool

True if the head contains an crate::ast::AggExpr.

§has_negation: bool

True if any body literal is BodyLiteral::Negated.

§has_is_expr: bool

True if any body literal is BodyLiteral::IsExpr.

§comparison_count: usize

Number of body BodyLiteral::Comparison literals (filters). Comparisons do NOT block multiway eligibility — they are applied as filters on top of the join — but the count is recorded so the explain output can show them and so future PRs can reason about filter selectivity.

§is_fact: bool

True if the rule is a ground fact (body.is_empty()).

Implementations§

Source§

impl HypergraphRule

Source

pub fn from_rule(rule: &Rule) -> Self

Build a HypergraphRule from an AST Rule. Total: never fails. Anonymous wildcards (Term::Anonymous) and constants (Term::Integer / Float / String / Symbol) leave the hyperedge position as None. Aggregate terms in body atoms are not allowed by the parser (aggregates appear only in rule heads), but if one is encountered it is treated as a constant position — the head-aggregation flag captures the eligibility boundary regardless.

Source

pub fn vertex_count(&self) -> usize

Number of distinct variables referenced by the body. Equals self.vertices.len().

Source

pub fn hyperedge_count(&self) -> usize

Number of positive body atoms.

Source

pub fn vertex(&self, id: VertexId) -> &Vertex

Look up a vertex by id. Panics if id is out of range — VertexIds are only allocated by Self::from_rule, so an out-of-range id is a programmer error, not a data error.

Source

pub fn vertex_ids(&self) -> impl Iterator<Item = VertexId> + '_

Iterate over vertex ids in allocation (first-appearance) order.

Trait Implementations§

Source§

impl Clone for HypergraphRule

Source§

fn clone(&self) -> HypergraphRule

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 HypergraphRule

Source§

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

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

impl PartialEq for HypergraphRule

Source§

fn eq(&self, other: &HypergraphRule) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HypergraphRule

Source§

impl StructuralPartialEq for HypergraphRule

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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,