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,
impl<V, E, S> FpCategory<V, E, S>where
S: Default,
Source§impl<V, E, S> FpCategory<V, E, S>
impl<V, E, S> FpCategory<V, E, S>
Sourcepub fn generators(&self) -> &(impl FinGraph<V = V, E = E> + use<V, E, S>)
pub fn generators(&self) -> &(impl FinGraph<V = V, E = E> + use<V, E, S>)
Gets the generating graph of the category presentation.
Sourcepub fn equations(&self) -> impl Iterator<Item = &PathEq<V, E>>
pub fn equations(&self) -> impl Iterator<Item = &PathEq<V, E>>
Gets the path equations of the category presentation.
Sourcepub fn add_ob_generator(&mut self, v: V)
pub fn add_ob_generator(&mut self, v: V)
Adds an object generator.
Sourcepub fn add_ob_generators(&mut self, iter: impl IntoIterator<Item = V>)
pub fn add_ob_generators(&mut self, iter: impl IntoIterator<Item = V>)
Adds several object generators at once.
Sourcepub fn add_mor_generator(&mut self, e: E, dom: V, cod: V)
pub fn add_mor_generator(&mut self, e: E, dom: V, cod: V)
Adds a morphism generator.
Sourcepub fn make_mor_generator(&mut self, e: E)
pub fn make_mor_generator(&mut self, e: E)
Adds a morphism generator without declaring its (co)domain.
Sourcepub fn add_equation(&mut self, eq: PathEq<V, E>)
pub fn add_equation(&mut self, eq: PathEq<V, E>)
Adds a path equation to the presentation.
Sourcepub fn equate(&mut self, lhs: Path<V, E>, rhs: Path<V, E>)
pub fn equate(&mut self, lhs: Path<V, E>, rhs: Path<V, E>)
Equates two path in the presentation.
Sourcepub fn iter_invalid(&self) -> impl Iterator<Item = InvalidFpCategory<E>> + '_
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>
impl<V, E, S> Category for FpCategory<V, E, S>
Source§fn has_mor(&self, path: &Self::Mor) -> bool
fn has_mor(&self, path: &Self::Mor) -> bool
Source§fn compose(&self, path: Path<Self::Ob, Self::Mor>) -> Self::Mor
fn compose(&self, path: Path<Self::Ob, Self::Mor>) -> Self::Mor
Source§fn compose2(&self, path1: Self::Mor, path2: Self::Mor) -> Self::Mor
fn compose2(&self, path1: Self::Mor, path2: Self::Mor) -> Self::Mor
Source§impl<V: Clone, E: Clone, S: Clone> Clone for FpCategory<V, E, S>
impl<V: Clone, E: Clone, S: Clone> Clone for FpCategory<V, E, S>
Source§fn clone(&self) -> FpCategory<V, E, S>
fn clone(&self) -> FpCategory<V, E, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<V, E, S> Debug for FpCategory<V, E, S>
impl<V, E, S> Debug for FpCategory<V, E, S>
Source§impl<V, E, S> Default for FpCategory<V, E, S>where
S: Default,
impl<V, E, S> Default for FpCategory<V, E, S>where
S: Default,
Source§impl<V, E, S> FgCategory for FpCategory<V, E, S>
impl<V, E, S> FgCategory for FpCategory<V, E, S>
Source§fn ob_generators(&self) -> impl Iterator<Item = Self::ObGen>
fn ob_generators(&self) -> impl Iterator<Item = Self::ObGen>
Source§fn mor_generators(&self) -> impl Iterator<Item = Self::MorGen>
fn mor_generators(&self) -> impl Iterator<Item = Self::MorGen>
Source§fn mor_generator_dom(&self, f: &Self::MorGen) -> Self::Ob
fn mor_generator_dom(&self, f: &Self::MorGen) -> Self::Ob
Source§fn mor_generator_cod(&self, f: &Self::MorGen) -> Self::Ob
fn mor_generator_cod(&self, f: &Self::MorGen) -> Self::Ob
Source§impl<V, E, S> PartialEq for FpCategory<V, E, S>
impl<V, E, S> PartialEq for FpCategory<V, E, S>
Source§impl<V, E, S> Validate for FpCategory<V, E, S>
impl<V, E, S> Validate for FpCategory<V, E, S>
Source§type ValidationError = InvalidFpCategory<E>
type ValidationError = InvalidFpCategory<E>
impl<V, E, S> Eq for FpCategory<V, E, S>
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>
impl<V, E, S = RandomState> !UnwindSafe for FpCategory<V, E, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.