Struct FpCategory

Source
pub struct FpCategory<V, E, S = RandomState> { /* private fields */ }
Expand description

A finitely presented category backed by an e-graph.

A data structure for a f.p. category in which the congruence relation generated by the path equations is maintained by an e-graph. The question of whether paths in the presented category are equivalent is referred to the e-graph.

§Interior mutability

Checking equivalence of paths requires mutating the underlying e-graph. However, we do not want to regard this check as mutating, for the theoretical reason that the check does not change the category presented and the practical reason that it would cause mutable references to be aggressively propagated throughout the codebase. Thus, we use the interior mutability pattern to encapsulate the mutability of the e-graph and perform borrow checking at runtime. The current implementation allows only single-threaded usage.

Implementations§

Source§

impl<V, E, S> FpCategory<V, E, S>
where S: Default,

Source

pub fn new() -> Self

Creates a default value for this type.

Source§

impl<V, E, S> FpCategory<V, E, S>
where V: Eq + Clone + Hash, E: Eq + Clone + Hash, S: BuildHasher,

Source

pub fn generators(&self) -> &(impl FinGraph<V = V, E = E> + use<V, E, S>)

Gets the generating graph of the category presentation.

Source

pub fn equations(&self) -> impl Iterator<Item = &PathEq<V, E>>

Gets the path equations of the category presentation.

Source

pub fn is_free(&self) -> bool

Is the category freely generated?

Source

pub fn add_ob_generator(&mut self, v: V)

Adds an object generator.

Source

pub fn add_ob_generators(&mut self, iter: impl IntoIterator<Item = V>)

Adds several object generators at once.

Source

pub fn add_mor_generator(&mut self, e: E, dom: V, cod: V)

Adds a morphism generator.

Source

pub fn make_mor_generator(&mut self, e: E)

Adds a morphism generator without declaring its (co)domain.

Source

pub fn get_dom(&self, e: &E) -> Option<&V>

Gets the domain of a morphism generator.

Source

pub fn get_cod(&self, e: &E) -> Option<&V>

Gets the codomain of a morphism generator.

Source

pub fn set_dom(&mut self, e: E, v: V)

Sets the domain of a morphism generator.

Source

pub fn set_cod(&mut self, e: E, v: V)

Sets the codomain of a morphism generator.

Source

pub fn add_equation(&mut self, eq: PathEq<V, E>)

Adds a path equation to the presentation.

Source

pub fn equate(&mut self, lhs: Path<V, E>, rhs: Path<V, E>)

Equates two path in the presentation.

Source

pub fn iter_invalid(&self) -> impl Iterator<Item = InvalidFpCategory<E>> + '_

Iterates over failures to be a well-defined presentation of a category.

Trait Implementations§

Source§

impl<V, E, S> Category for FpCategory<V, E, S>
where V: Eq + Clone + Hash, E: Eq + Clone + Hash, S: BuildHasher,

Source§

type Ob = V

Type of objects in category.
Source§

type Mor = Path<V, E>

Type of morphisms in category.
Source§

fn has_ob(&self, x: &Self::Ob) -> bool

Does the category contain the value as an object?
Source§

fn has_mor(&self, path: &Self::Mor) -> bool

Does the category contain the value as a morphism?
Source§

fn dom(&self, path: &Self::Mor) -> Self::Ob

Gets the domain of a morphism in the category.
Source§

fn cod(&self, path: &Self::Mor) -> Self::Ob

Gets the codomain of a morphism in the category.
Source§

fn compose(&self, path: Path<Self::Ob, Self::Mor>) -> Self::Mor

Composes a path of morphisms in the category.
Source§

fn compose2(&self, path1: Self::Mor, path2: Self::Mor) -> Self::Mor

Composes a pair of morphisms with compatible (co)domains.
Source§

fn morphisms_are_equal(&self, path1: Self::Mor, path2: Self::Mor) -> bool

Are the two morphisms in the category equal? Read more
Source§

fn id(&self, x: Self::Ob) -> Self::Mor

Constructs the identity morphism at an object.
Source§

impl<V: Clone, E: Clone, S: Clone> Clone for FpCategory<V, E, S>

Source§

fn clone(&self) -> FpCategory<V, E, S>

Returns a copy 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<V, E, S> Debug for FpCategory<V, E, S>
where V: Debug, E: Debug, S: Debug,

Source§

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

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

impl<V, E, S> Default for FpCategory<V, E, S>
where S: Default,

Source§

fn default() -> Self

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

impl<V, E, S> FgCategory for FpCategory<V, E, S>
where V: Eq + Clone + Hash, E: Eq + Clone + Hash, S: BuildHasher,

Source§

type ObGen = V

Type of an object generator. Read more
Source§

type MorGen = E

Type of a morphism generator Read more
Source§

fn ob_generators(&self) -> impl Iterator<Item = Self::ObGen>

Iterates over object generators.
Source§

fn mor_generators(&self) -> impl Iterator<Item = Self::MorGen>

Iterates over morphism generators.
Source§

fn mor_generator_dom(&self, f: &Self::MorGen) -> Self::Ob

The domain of a morphism generator
Source§

fn mor_generator_cod(&self, f: &Self::MorGen) -> Self::Ob

The codomain of a morphism generator
Source§

fn objects(&self) -> impl Iterator<Item = Self::Ob>

Iterates over basic objects.
Source§

fn morphisms(&self) -> impl Iterator<Item = Self::Mor>

Iterates over basic morphisms.
Source§

impl<V, E, S> PartialEq for FpCategory<V, E, S>
where V: Eq + Hash, E: Eq + Hash, S: BuildHasher,

Source§

fn eq(&self, other: &Self) -> 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<V, E, S> Validate for FpCategory<V, E, S>
where V: Eq + Clone + Hash, E: Eq + Clone + Hash, S: BuildHasher,

Source§

type ValidationError = InvalidFpCategory<E>

The type of a validation error. Read more
Source§

fn validate(&self) -> Result<(), NonEmpty<Self::ValidationError>>

Validates the object.
Source§

impl<V, E, S> Eq for FpCategory<V, E, S>
where V: Eq + Hash, E: Eq + Hash, S: BuildHasher,

Auto Trait Implementations§

§

impl<V, E, S = RandomState> !Freeze for FpCategory<V, E, S>

§

impl<V, E, S = RandomState> !RefUnwindSafe for FpCategory<V, E, S>

§

impl<V, E, S = RandomState> !Send for FpCategory<V, E, S>

§

impl<V, E, S = RandomState> !Sync for FpCategory<V, E, S>

§

impl<V, E, S> Unpin for FpCategory<V, E, S>
where E: Unpin, V: Unpin, S: Unpin,

§

impl<V, E, S = RandomState> !UnwindSafe for FpCategory<V, E, S>

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

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,