module SndOrder.Morphism.CommutingSquares (
commutingMorphism
, commutingMorphismSameDomain
, commutingMorphismSameCodomain
) where
import Abstract.Morphism
import TypedGraph.Morphism
output :: String -> [TypedGraphMorphism a b] -> TypedGraphMorphism a b
output fname morphisms =
case morphisms of
[] -> error $ "("++fname++") Error when commuting monomorphic morphisms (must be generating an invalid rule)"
[x] -> x
(_:_:_) -> error $ "("++fname++") Error when commuting monomorphic morphisms (non unique commuting morphism)"
commutingMorphism :: TypedGraphMorphism a b -> TypedGraphMorphism a b
-> TypedGraphMorphism a b -> TypedGraphMorphism a b -> TypedGraphMorphism a b
commutingMorphism a1 b1 a2 b2 = buildTypedGraphMorphism (domain a1) (domain b1) select
where
mats = findMonomorphisms (domain a1) (domain b1)
filt = filter (\m -> compose m b1 == a1 && compose m b2 == a2) mats
select = mapping $ output "commutingMorphism" filt
commutingMorphismSameDomain :: TypedGraphMorphism a b -> TypedGraphMorphism a b
-> TypedGraphMorphism a b -> TypedGraphMorphism a b -> TypedGraphMorphism a b
commutingMorphismSameDomain k1 s1 k2 s2 = buildTypedGraphMorphism (codomain k1) (codomain s1) select
where
mats = findMonomorphisms (codomain k1) (codomain s1)
filt = filter (\m -> compose k1 m == s1 && compose k2 m == s2) mats
select = mapping $ output "commutingMorphismSameDomain" filt
commutingMorphismSameCodomain :: TypedGraphMorphism a b -> TypedGraphMorphism a b
-> TypedGraphMorphism a b -> TypedGraphMorphism a b -> TypedGraphMorphism a b
commutingMorphismSameCodomain k1 s1 k2 s2 = buildTypedGraphMorphism (domain k1) (domain s1) select
where
mats = findMonomorphisms (domain k1) (domain s1)
filt = filter (\m -> compose m s1 == k1 && compose k2 m == s2) mats
select = mapping $ output "commutingMorphismSameCodomain" filt