Skip to main content

OperatorSet

Struct OperatorSet 

Source
pub struct OperatorSet { /* private fields */ }
Expand description

A set of deduction operators that compose via propagate-forward semantics.

An OperatorSet applies each operator in sequence to a hypothesis and evidence. If an operator abstains, the abstention is recorded but does not prevent subsequent operators from running on the best-known hypothesis so far.

Invariant: The result of apply_set is always ⊑ the input hypothesis (INV-PS-03). Invariant: Operators and metadata are kept in lockstep registration order.

Implementations§

Source§

impl OperatorSet

Source

pub fn new() -> Self

Creates a new empty operator set.

Source

pub fn register(self, op: Box<dyn Operator>, meta: OperatorMetadata) -> Self

Registers an operator with the set and returns self for chaining.

Panics if an operator with the same name is already registered. Operator names must be unique to ensure the audit trail in SetOutcome.abstentions unambiguously identifies each operator that abstains.

Source

pub fn len(&self) -> usize

Returns the number of operators in the set.

Source

pub fn is_empty(&self) -> bool

Returns true if the operator set is empty.

Source

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

Returns the names of all registered operators in registration order.

Source

pub fn iter_operators(&self) -> impl Iterator<Item = &dyn Operator>

Returns an iterator over references to the registered operators.

This allows proposers (e.g., lattice search) to invoke each operator individually and collect refinements, rather than using the propagate-forward semantics of apply_set.

Source

pub fn apply_set(&self, h: &Hyp, e: &Evidence) -> SetOutcome

Applies all operators in sequence, propagating refinements forward.

Algorithm:

  1. Start with current_h = h.clone().
  2. For each operator (in registration order):
    • Call operator.apply(&current_h, e).
    • If Refined(h'): assert h' ⊑ current_h, then set current_h = h'.
    • If Abstain(r): record (operator_name, r) and leave current_h unchanged.
  3. Return SetOutcome { result: current_h, abstentions }.

Semantics: Abstention from one operator does not silence the next; each operator sees the best-known hypothesis so far. Final result ⊑ input always (OBL-PS-03).

§Safety

The refinement invariant (INV-PS-03) is checked via debug_assert! and only fires in debug builds. In release builds, this invariant is unchecked; correctness depends on each registered operator satisfying INV-PS-03 in its own implementation. For clinical use, register only operators whose unit tests verify monotonicity.

Trait Implementations§

Source§

impl Default for OperatorSet

Source§

fn default() -> Self

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> 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, 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.