6133N/ADescription : Definition of signature morphisms for
6133N/A first-order logic with dependent types (DFOL)
6133N/A-- morphisms for DFOL - maps of symbol names
6133N/A-- constructs an identity morphism
6133N/AcompMorph :: Morphism -> Morphism -> Result Morphism
6147N/A then fail $ "Codomain of the first morphism "
6147N/A ++ "must equal the domain of the second."
6147N/A else return $ Morphism (source m1) (target m2) $
6147N/A-- determines whether a morphism is valid
6133N/AisValidMorph :: Morphism -> Bool
6147N/AisValidMorph m@(Morphism sig1 sig2 map1) =
6147N/A in and $ [checkDom,checkCod] ++ checkTypes
6133N/AcheckTypePres:: Morphism -> NAME -> Bool
6133N/A let Just type1 = getSymbolType n $ source m
6133N/A Just type2 = getSymbolType (mapSymbol m n) $ target m
in (applyMorphism m type1) == type2
{- converts the morphism into its canonical form where the symbol map contains
morphCanForm :: Morphism -> Morphism
morphCanForm (Morphism sig1 sig2 map1) =
in Morphism sig1 sig2 map2
-- applies a morphism to a symbol
mapSymbol :: Morphism -> NAME -> NAME
-- translates a term, type or formula along the given morphism
applyMorphism :: Translatable a => Morphism -> a -> a
let syms = getSymbols (target m)
instance Pretty Morphism where
printMorph :: Morphism -> Doc
if m == (idMorph $ source m)
then vcat [text "Identity morphism on:", pretty $ source m]
else vcat [text "Source signature:", pretty $ source m,
text "Target signature:", pretty $ target m,
text "Mapping:", printSymMap $ symMap m]
printSymMap ::
Map.Map NAME NAME -> Doc
printSymMap m = vcat $ map (\ (k,a) -> pretty k <+> text "|->" <+> pretty a)