module Cat.Instances.Graphs.Box where
The box product of graphsπ
The box product of two graphs and is the graph with node set and, provided that there are edges (resp. edges of the form and
open Graph
private variable
: Level
o β o' β' : Graph o β
G
module _ {o β o' β'} (G : Graph o β) (H : Graph o' β') where
private variable
: β G β
gβ gβ : β H β hβ hβ
We define the edges as an indexed inductive type. Note that the indices corresponding to the graph weβre including an edge from vary, but the indices corresponding to the other graph remain fixed.
data Box-edge : (gβ gβ : β G β) (hβ hβ : β H β) β Type (o β o' β β β β') where
: G .Edge gβ gβ β Box-edge gβ gβ hβ hβ
inl : H .Edge hβ hβ β Box-edge gβ gβ hβ hβ inr
We can prove that this type is a set by showing that it is equivalent to a sum, with a summand for each constructor, replacing the usage of indexing by an inductive identity.
instance
H-Level-Box-edge: β {G : Graph o β} {H : Graph o' β'} {gβ gβ hβ hβ n}
β H-Level (Box-edge G H gβ gβ hβ hβ) (2 + n)
{G = G} {H} {gβ = gβ} {gβ} {hβ} {hβ} =
H-Level-Box-edge 2 $ retractβis-hlevel 2 from to coh (hlevel 2)
basic-instance where
: Type _
T = (hβ β‘α΅’ hβ Γ G .Edge gβ gβ) β (gβ β‘α΅’ gβ Γ H .Edge hβ hβ)
T
: T β Box-edge G H gβ gβ hβ hβ
from (inl (reflα΅’ , x)) = inl x
from (inr (reflα΅’ , x)) = inr x
from
to : Box-edge G H gβ gβ hβ hβ β T
to (inl x) = inl (reflα΅’ , x)
to (inr x) = inr (reflα΅’ , x)
: is-left-inverse from to
coh (inl x) = refl
coh (inr x) = refl coh
We note that because the Box-edge
type has to βstoreβ the endpoint
nodes of the paths being included, the edges of a box product live in
the least universe that contains both the edges and nodes of
the operand graphs.
Box-product: Graph o β β Graph o' β' β Graph (o β o') (o β β β o' β β')
.Node = β G β Γ β H β
Box-product G H .Edge (gβ , hβ) (gβ , hβ) = Box-edge G H gβ gβ hβ hβ
Box-product G H .Node-set = hlevel 2
Box-product G H .Edge-set = hlevel 2 Box-product G H