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 o β o' β' : Level 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 inl : G .Edge gβ gβ β Box-edge gβ gβ hβ hβ inr : H .Edge hβ hβ β Box-edge gβ gβ hβ hβ
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) H-Level-Box-edge {G = G} {H} {gβ = gβ} {gβ} {hβ} {hβ} = basic-instance 2 $ retractβis-hlevel 2 from to coh (hlevel 2) where T : Type _ T = (hβ β‘α΅’ hβ Γ G .Edge gβ gβ) β (gβ β‘α΅’ gβ Γ H .Edge hβ hβ) from : T β Box-edge G H gβ gβ hβ hβ from (inl (reflα΅’ , x)) = inl x from (inr (reflα΅’ , x)) = inr x to : Box-edge G H gβ gβ hβ hβ β T to (inl x) = inl (reflα΅’ , x) to (inr x) = inr (reflα΅’ , x) coh : is-left-inverse from to coh (inl x) = refl coh (inr x) = refl
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' β β') Box-product G H .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