open_hypergraphs/category/
spider.rs

1use super::traits::*;
2use crate::array::*;
3use crate::finite_function::*;
4
5/// Categories with [hypergraph structure](https://ncatlab.org/nlab/show/hypergraph+category).
6/// We call this `Spider` to avoid confusion with the [crate::strict::Hypergraph] struct.
7pub trait Spider<K: ArrayKind>: Arrow {
8    /// Given an `Arrow` with type `f : A → B`,
9    /// construct its dagger `f† : B → A`
10    /// by using Hypergraph structure to bend sources to targets and vice-versa.
11    fn dagger(&self) -> Self;
12
13    /// Construct a spider using a type `w`, and source `s` and target `t` interface maps.
14    fn spider(s: FiniteFunction<K>, t: FiniteFunction<K>, w: Self::Object) -> Option<Self>;
15
16    /// Construct a "half-spider": a spider whose `t` leg is identity.
17    fn half_spider(s: FiniteFunction<K>, w: Self::Object) -> Option<Self> {
18        let t = FiniteFunction::<K>::identity(s.target());
19        Self::spider(s, t, w)
20    }
21}