uor-foundation 0.1.3

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
// @generated by uor-crate from uor-ontology — do not edit manually

//! `predicate/` namespace — Boolean-valued functions on kernel objects. Formalizes resolver dispatch, cascade guard evaluation, and conditional resolution paths..
//!
//! Space: Kernel

use crate::Primitives;

/// A total, pure, boolean-valued function on a kernel object. Evaluation terminates for all inputs and produces no side effects.
pub trait Predicate<P: Primitives> {
    /// The OWL class of objects this predicate accepts as input.
    fn evaluates_over(&self) -> &P::String;
    /// Associated type for `DescentMeasure`.
    type DescentMeasure: crate::kernel::recursion::DescentMeasure<P>;
    /// A termination witness for user-declared predicates. Kernel predicates are total by construction; user-declared predicates must carry a descent measure certifying termination.
    fn bounded_evaluator(&self) -> &[Self::DescentMeasure];
}

/// A predicate over type:TypeDefinition. Used for resolver dispatch.
pub trait TypePredicate<P: Primitives>: Predicate<P> {}

/// A predicate over state:Context or cascade:CascadeState. Used for cascade stage guards.
pub trait StatePredicate<P: Primitives>: Predicate<P> {}

/// A predicate over partition:FiberCoordinate. Used for fiber-level selection in geodesic resolution.
pub trait FiberPredicate<P: Primitives>: Predicate<P> {}

/// A pair (Predicate, Target) where Target is a resolver:Resolver class. The kernel evaluates the predicate; if true, the target resolver is selected.
pub trait DispatchRule<P: Primitives> {
    /// Associated type for `Predicate`.
    type Predicate: Predicate<P>;
    /// The predicate that triggers this dispatch rule.
    fn dispatch_predicate(&self) -> &Self::Predicate;
    /// Associated type for `Resolver`.
    type Resolver: crate::bridge::resolver::Resolver<P>;
    /// The resolver selected when the predicate is satisfied.
    fn dispatch_target(&self) -> &Self::Resolver;
    /// Position in the dispatch table (evaluation order).
    fn dispatch_index(&self) -> P::NonNegativeInteger;
}

/// An ordered set of DispatchRules for a single dispatch point. Must satisfy exhaustiveness and mutual exclusion.
pub trait DispatchTable<P: Primitives> {
    /// Associated type for `DispatchRule`.
    type DispatchRule: DispatchRule<P>;
    /// The ordered set of rules in this table.
    fn dispatch_rules(&self) -> &[Self::DispatchRule];
    /// True iff the disjunction of all dispatch predicates is a tautology over the input class.
    fn is_exhaustive(&self) -> P::Boolean;
    /// True iff no two dispatch predicates can be simultaneously true for any input.
    fn is_mutually_exclusive(&self) -> P::Boolean;
}

/// A triple (StatePredicate, effect:Effect, cascade:CascadeStage). The guard is a StatePredicate; if true, the effect is applied and the cascade advances to the target stage.
pub trait GuardedTransition<P: Primitives> {
    /// Associated type for `StatePredicate`.
    type StatePredicate: StatePredicate<P>;
    /// The guard predicate for this transition.
    fn guard_predicate(&self) -> &Self::StatePredicate;
    /// Associated type for `Effect`.
    type Effect: crate::kernel::effect::Effect<P>;
    /// The effect applied when the guard is satisfied.
    fn guard_effect(&self) -> &Self::Effect;
    /// Associated type for `CascadeStage`.
    type CascadeStage: crate::kernel::cascade::CascadeStage<P>;
    /// The cascade stage to advance to.
    fn guard_target(&self) -> &Self::CascadeStage;
}

/// A single case in a pattern match: a Predicate and a result Term. The match evaluates predicates in order and returns the result of the first matching arm.
pub trait MatchArm<P: Primitives> {
    /// Associated type for `Predicate`.
    type Predicate: Predicate<P>;
    /// The predicate guarding this arm.
    fn arm_predicate(&self) -> &Self::Predicate;
    /// Associated type for `Term`.
    type Term: crate::kernel::schema::Term<P>;
    /// The result term if this arm matches.
    fn arm_result(&self) -> &Self::Term;
    /// Position in the match expression (evaluation order).
    fn arm_index(&self) -> P::NonNegativeInteger;
}

/// A term formed by evaluating a sequence of MatchArms. Extends the term language with deterministic conditional evaluation.
pub trait MatchExpression<P: Primitives>: crate::kernel::schema::Term<P> {
    /// Associated type for `MatchArm`.
    type MatchArm: MatchArm<P>;
    /// The ordered arms of this match expression.
    fn match_arms(&self) -> &[Self::MatchArm];
}