Skip to main content

PartialOrderChecker

Struct PartialOrderChecker 

Source
pub struct PartialOrderChecker<T> {
    pub elements: Vec<T>,
    pub le: Box<dyn Fn(&T, &T) -> bool>,
}
Expand description

Checker for partial-order properties on a finite set encoded as a comparison closure.

Fields§

§elements: Vec<T>

Elements of the poset.

§le: Box<dyn Fn(&T, &T) -> bool>

The underlying partial order relation: returns true iff a ≤ b.

Implementations§

Source§

impl<T: Clone + PartialEq> PartialOrderChecker<T>

Source

pub fn new(elements: Vec<T>, le: impl Fn(&T, &T) -> bool + 'static) -> Self

Create a new checker.

Source

pub fn check_reflexive(&self) -> bool

Verify reflexivity: ∀ a, a ≤ a.

Source

pub fn check_transitive(&self) -> bool

Verify transitivity: ∀ a b c, a ≤ b ∧ b ≤ c → a ≤ c.

Source

pub fn check_antisymmetric(&self) -> bool

Verify antisymmetry: ∀ a b, a ≤ b ∧ b ≤ a → a = b.

Source

pub fn is_partial_order(&self) -> bool

Check all three partial-order axioms at once.

Source

pub fn maximal_elements(&self) -> Vec<T>

Find all maximal elements (no strictly larger element exists).

Source

pub fn minimal_elements(&self) -> Vec<T>

Find all minimal elements.

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.