module Analysis.EssentialCriticalPairs
( namedEssentialCriticalPairs,
findAllEssentialDeleteUse,
findAllEssentialProduceForbid,
findAllEssentialProduceDangling
) where
import Abstract.AdhesiveHLR as RW
import Abstract.DPO as RW
import Abstract.Morphism
import Analysis.CriticalPairs
import Analysis.EpimorphicPairs
type NamedRule m = (String, Production m)
type NamedCriticalPairs m = (String,String,[CriticalPair m])
namedEssentialCriticalPairs :: (EpiPairs m, DPO m) =>
MorphismsConfig -> [NamedRule m] -> [NamedCriticalPairs m]
namedEssentialCriticalPairs conf namedRules =
map (uncurry getCPs) [(a,b) | a <- namedRules, b <- namedRules]
where
getCPs (n1,r1) (n2,r2) =
(n1, n2, findEssentialCriticalPairs conf r1 r2)
findEssentialCriticalPairs :: (EpiPairs m, DPO m) =>
MorphismsConfig -> Production m -> Production m -> [CriticalPair m]
findEssentialCriticalPairs conf p1 p2 =
findAllEssentialDeleteUse conf p1 p2 ++
findAllEssentialProduceDangling conf p1 p2 ++
findAllEssentialProduceForbid conf p1 p2
findAllEssentialDeleteUse :: (EpiPairs m, DPO m) =>
MorphismsConfig -> Production m -> Production m -> [CriticalPair m]
findAllEssentialDeleteUse conf p1 p2 =
map (\(_,_,m1,m2) -> CriticalPair (m1,m2) Nothing Nothing DeleteUse) essentialCPs
where
essentialCPs =
filter
(isEssentialDeleteUse conf)
(findPotentialEssentialCPs conf p1 p2)
findPotentialEssentialCPs :: (DPO m, EpiPairs m) => MorphismsConfig -> Production m -> Production m -> [(m, m, m, m)]
findPotentialEssentialCPs conf p1 p2 = satisfyingPairs
where
(_,l1',c) = calculateInitialPushout (getLHS p1)
pairs = createJointlyEpimorphicPairsFromCodomains (matchRestriction conf) l1' (getLHS p2)
shiftedPairs =
map
(\(e1,e2) ->
let (m1,d1') = calculatePushout e1 c
m2 = compose e2 d1'
in (l1', c, m1, m2)
)
pairs
satisfyingPairs = filter (\(_,_,m1,m2) -> satisfyRewritingConditions conf (p1,m1) (p2,m2)) shiftedPairs
isEssentialDeleteUse :: DPO m => MorphismsConfig -> (m, m, m, m) -> Bool
isEssentialDeleteUse conf (l1',c,m1,m2) = null commuting
where
(_,o1) = calculatePullback (compose c m1) m2
alls1 = findMorphismsFromDomains conf o1 l1'
commuting = filter (\s1 -> compose s1 l1' == o1) alls1
findMorphismsFromDomains :: FindMorphism m => MorphismsConfig -> m -> m -> [m]
findMorphismsFromDomains conf a b =
findMorphisms (matchRestrictionToMorphismType $ matchRestriction conf) (domain a) (domain b)
findAllEssentialProduceDangling ::
MorphismsConfig -> Production m -> Production m -> [CriticalPair m]
findAllEssentialProduceDangling _ _ _ = []
findAllEssentialProduceForbid ::
MorphismsConfig -> Production m -> Production m -> [CriticalPair m]
findAllEssentialProduceForbid _ _ _ = []