Changeset 12653

Show
Ignore:
Timestamp:
16.10.2009 01:57:16 (5 months ago)
Author:
mkhl
Message:

Document and refactor Morphism.

Location:
trunk/Maude
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/Maude/Logic_Maude.hs

    r12345 r12653  
    7272    -- sentences -- 
    7373    is_of_sign Maude = flip Sign.includesSentence 
    74     map_sen Maude = Morphism.mapSentence 
     74    map_sen Maude = Morphism.translateSentence 
    7575    simplify_sen Maude = Sign.simplifySentence 
    7676    -- parse_sentence Maude = Nothing 
  • trunk/Maude/Maude2DG.hs

    r12607 r12653  
    338338         where (tok, tim', morph, _, dg') = processModExp tim Map.empty dg modExp 
    339339               (_, _, fs, _, _) = fromJust $ Map.lookup tok tim' 
    340                fs' = renameSorts morph fs 
     340               fs' = translateSorts morph fs 
    341341               morph' = qualifySorts morph (HasName.getName sort) fs' 
    342342               toks' = (HasName.getName sort, tok, fs') : toks 
     
    357357                           (n1, _, ss1, _, _) = fromJust $ Map.lookup tok1 tim2 
    358358                           (n2, _, ss2, _, _) = fromJust $ Map.lookup tok2 tim2 
    359                            ss1' = renameSorts morph1 ss1 
    360                            ss2' = renameSorts morph1 ss2 
     359                           ss1' = translateSorts morph1 ss1 
     360                           ss2' = translateSorts morph1 ss2 
    361361                           sg1 = target morph1 
    362362                           sg2 = target morph2 
     
    443443              morph'' = setTarget usg morph' 
    444444morphismView name p ss (n, th, morph, rnms, False) morph1 = 
    445                          (name, morph4, vmorph', n, [(p, th, getNewSorts ss morph)]) 
     445                         (name, morph4, vmorph', n, [(p, th, translateSorts morph ss)]) 
    446446        where rnms' = qualifyRenamings2 p rnms 
    447447              morph2 = applyRenamings morph1 rnms' 
  • trunk/Maude/Morphism.hs

    r12347 r12653  
    1313 
    1414module Maude.Morphism ( 
     15    -- * Types 
     16    -- ** The Morphism type 
    1517    Morphism(..), 
     18    -- ** Auxiliary type 
    1619    SortMap, 
    1720    OpMap, 
    18     applyRenamings, 
     21    -- * Construction 
    1922    fromSignRenamings, 
    2023    fromSignsRenamings, 
    21     symbolMap, 
    2224    empty, 
    2325    identity, 
     26    inclusion, 
     27    -- * Combination 
     28    inverse, 
     29    union, 
     30    compose, 
     31    -- * Testing 
    2432    isIdentity, 
    25     inclusion, 
    26     inverse, 
    27     compose, 
     33    isInclusion, 
    2834    isLegal, 
    29     isInclusion, 
    30     mapSentence, 
    31     renameSorts, 
    32     union, 
     35    -- * Conversion 
     36    symbolMap, 
     37    -- * Modification 
    3338    setTarget, 
    3439    qualifySorts, 
     40    applyRenamings, 
    3541    extendWithSortRenaming, 
    36     getNewSorts 
     42    -- * Application 
     43    translateSentence, 
     44    translateSorts, 
    3745) where 
    3846 
     
    5967import Common.DocUtils (Pretty(..)) 
    6068 
     69-- * Types 
     70 
     71-- ** Auxiliary types 
    6172 
    6273type SortMap = SymbolMap 
    6374type OpMap = SymbolMap 
    6475type LabelMap = SymbolMap 
     76 
     77-- ** The Morphism type 
    6578 
    6679data Morphism = Morphism { 
     
    7285    } deriving (Show, Ord, Eq) 
    7386 
     87-- ** 'Morphism' instances 
    7488 
    7589instance Pretty Morphism where 
    7690    pretty mor = let 
    77             pr'pair txt left right = hsep 
    78                 [txt, pretty left, text "to", pretty right] 
    79             pr'ops src tgt = pr'pair (text "op") src (getName tgt) 
    80             pr'map fun = vcat . map (uncurry fun) . Map.toList 
    81             smap = pr'map (pr'pair $ text "sort") $ sortMap mor 
    82             omap = pr'map pr'ops $ opMap mor 
    83             lmap = pr'map (pr'pair $ text "label") $ labelMap mor 
     91        pr'pair txt left right = hsep  
     92            [txt, pretty left, text "to", pretty right] 
     93        pr'ops src tgt = pr'pair (text "op") src (getName tgt) 
     94        pr'map fun = vcat . map (uncurry fun) . Map.toList 
     95        smap = pr'map (pr'pair $ text "sort") $ sortMap mor 
     96        omap = pr'map pr'ops $ opMap mor 
     97        lmap = pr'map (pr'pair $ text "label") $ labelMap mor 
    8498        in vcat [ smap, omap, lmap ] 
    85         -- text "\n\nTarget:" <$$> pretty $ target mor 
    86  
     99 
     100-- * Helper functions 
     101 
     102-- ** to modify Morphisms 
    87103 
    88104-- mapSource :: (Sign -> Sign) -> Morphism -> Morphism 
     
    91107mapTarget func mor = mor { target = func $ target mor } 
    92108 
    93 mapSortMap  :: (SymbolMap -> SymbolMap) -> Morphism -> Morphism 
     109mapSortMap  :: (SortMap -> SortMap)  -> Morphism -> Morphism 
    94110mapSortMap  func mor = mor { sortMap  = func $ sortMap  mor } 
    95 mapOpMap    :: (SymbolMap -> SymbolMap) -> Morphism -> Morphism 
     111mapOpMap    :: (OpMap -> OpMap)      -> Morphism -> Morphism 
    96112mapOpMap    func mor = mor { opMap    = func $ opMap    mor } 
    97 mapLabelMap :: (SymbolMap -> SymbolMap) -> Morphism -> Morphism 
     113mapLabelMap :: (LabelMap -> LabelMap) -> Morphism -> Morphism 
    98114mapLabelMap func mor = mor { labelMap = func $ labelMap mor } 
    99115 
    100  
    101 -- | Separate Operator and other Renamings. 
    102 partitionRenamings :: [Renaming] -> ([Renaming], [Renaming]) 
    103 partitionRenamings = let 
    104         is'op renaming = case renaming of 
    105             OpRenaming1 _ _ -> True 
    106             OpRenaming2 _ _ _ _ -> True 
    107             _ -> False 
    108     in partition is'op 
    109  
     116-- ** to handle Renamings 
     117 
     118-- TODO: Handle Attrs in Op Renamings. 
    110119renamingSymbolsMaybe :: Renaming -> Maybe (Symbol, Symbol) 
    111120renamingSymbolsMaybe rename = case rename of 
     
    114123    OpRenaming1 src (To tgt _) -> Just (asSymbol src, asSymbol tgt) 
    115124    OpRenaming2 src dom cod (To tgt _) -> let 
    116             src' = getName src 
    117             tgt' = getName tgt 
    118             dom' = map asSymbol dom 
    119             cod' = asSymbol cod 
    120         in Just (Operator src' dom' cod', Operator tgt' dom' cod') 
     125        src' = Op src dom cod [] 
     126        tgt' = Op tgt dom cod [] 
     127        in Just (asSymbol src', asSymbol tgt') 
    121128    TermMap _ _ -> Nothing 
    122129 
     130-- | Extract the 'Symbol's from a 'Renaming', if possible. 
    123131renamingSymbols :: Renaming -> (Symbol, Symbol) 
    124132renamingSymbols = fromJust . renamingSymbolsMaybe 
    125133 
    126 applyRenamings :: Morphism -> [Renaming] -> Morphism 
    127 applyRenamings mor rens = let 
    128         (ops, rest) = partitionRenamings rens 
    129         add'ops  = flip (foldr applyOpRenaming) ops 
    130         add'rest = flip (foldr applyRenaming) rest 
    131     in add'rest . add'ops $ mor 
    132  
    133 -- | create a Morphism from an initial signature and a list of Renamings 
    134 fromSignRenamings :: Sign -> [Renaming] -> Morphism 
    135 fromSignRenamings = applyRenamings . identity 
    136  
    137  
    138 -- TODO: Handle Attrs in Op Renamings. 
    139 applyOpRenaming :: Renaming -> Morphism -> Morphism 
    140 applyOpRenaming rename = let 
    141         syms = renamingSymbols rename 
    142         add'op = mapOpMap $ uncurry Map.insert syms 
    143         use'op = mapTarget . uncurry Sign.renameOp syms 
     134-- | Separate Operator and other Renamings. 
     135partitionRenamings :: [Renaming] -> ([Renaming], [Renaming]) 
     136partitionRenamings = let 
     137    is'op renaming = case renaming of 
     138        OpRenaming1 _ _ -> True 
     139        OpRenaming2 _ _ _ _ -> True 
     140        _ -> False 
     141    in partition is'op 
     142 
     143-- ** to apply Renamings to Morphisms 
     144 
     145-- | Insert an 'Operator' 'Renaming' into a 'Morphism'. 
     146-- Iff apply is True, apply the Renaming to the Morphism's target Signature. 
     147insertOpRenaming :: Bool -> Renaming -> Morphism -> Morphism 
     148insertOpRenaming apply rename = let 
     149    syms = renamingSymbols rename 
     150    add'op = mapOpMap $ uncurry Map.insert syms 
     151    use'op attrs = if apply 
     152        then mapTarget $ uncurry Sign.renameOp syms attrs 
     153        else id 
    144154    in case rename of 
    145155        OpRenaming1 _ (To _ attrs) -> use'op attrs . add'op 
     
    147157        _ -> id 
    148158 
    149 applyRenaming :: Renaming -> Morphism -> Morphism 
    150 applyRenaming rename = let 
    151         syms = renamingSymbols rename 
    152         add'sort = mapSortMap $ uncurry Map.insert syms 
    153         use'sort = mapTarget $ uncurry Sign.renameSort syms 
    154         ren'sort = mapOpMap $ uncurry renameSortOpMap syms 
    155         add'labl = mapLabelMap $ uncurry Map.insert syms 
    156         use'labl = mapTarget $ uncurry Sign.renameLabel syms 
     159-- | Insert a non-Operator 'Renaming' into a 'Morphism'. 
     160-- ^ iff True, apply the Renaming to the target Sign 
     161insertRenaming :: Bool -> Renaming -> Morphism -> Morphism 
     162insertRenaming apply rename = let 
     163    syms = renamingSymbols rename 
     164    add'sort = mapSortMap $ uncurry Map.insert syms 
     165    use'sort = if apply 
     166        then mapTarget $ uncurry Sign.renameSort syms 
     167        else id 
     168    ren'sort = mapOpMap $ uncurry renameSortOpMap syms 
     169    add'labl = mapLabelMap $ uncurry Map.insert syms 
     170    use'labl = if apply  
     171        then mapTarget $ uncurry Sign.renameLabel syms 
     172        else id 
    157173    in case rename of 
    158174        SortRenaming _ _ -> ren'sort . use'sort . add'sort 
     
    160176        _ -> id 
    161177 
    162  
    163 -- | create a Morphism from the initial signatures and a list of Renamings 
    164 fromSignsRenamings :: Sign -> Sign -> [Renaming] -> Morphism 
    165 fromSignsRenamings sign1 sign2 rens = let 
    166         (ops, rest) = partitionRenamings rens 
    167         add'ops  = flip (foldr insertOpRenaming) ops 
    168         add'rest = flip (foldr insertRenaming) rest 
    169         mor = inclusion sign1 sign2 
    170     in add'rest . add'ops $ mor 
    171  
    172 -- TODO: Handle Attrs in Op Renamings. 
    173 insertOpRenaming :: Renaming -> Morphism -> Morphism 
    174 insertOpRenaming rename = let 
    175         syms = renamingSymbols rename 
    176         add'op = mapOpMap $ uncurry Map.insert syms 
    177     in case rename of 
    178         OpRenaming1 _ _ -> add'op 
    179         OpRenaming2 _ _ _ _ -> add'op 
    180         _ -> id 
    181  
    182 insertRenaming :: Renaming -> Morphism -> Morphism 
    183 insertRenaming rename = let 
    184         syms = renamingSymbols rename 
    185         add'sort = mapSortMap $ uncurry Map.insert syms 
    186         ren'sort = mapOpMap $ uncurry renameSortOpMap syms 
    187         add'labl = mapLabelMap $ uncurry Map.insert syms 
    188     in case rename of 
    189         SortRenaming _ _ -> ren'sort . add'sort 
    190         LabelRenaming _ _ -> add'labl 
    191         _ -> id 
    192  
    193178-- | Rename sorts in the profiles of an operator map. 
    194179renameSortOpMap :: Symbol -> Symbol -> OpMap -> OpMap 
    195180renameSortOpMap from to = Map.map $ mapSorts $ Map.singleton from to 
    196181 
    197 -- | extract the SymbolMap of a Morphism 
    198 symbolMap :: Morphism -> SymbolMap 
    199 symbolMap mor = Map.unions [sortMap mor, opMap mor, labelMap mor] 
    200  
    201 -- | the empty Morphism 
     182-- | Insert 'Renaming's into a 'Morphism'. 
     183insertRenamings :: Bool -> Morphism -> [Renaming] -> Morphism 
     184insertRenamings apply mor rens = let 
     185    (ops, rest) = partitionRenamings rens 
     186    add'ops  = flip (foldr $ insertOpRenaming apply) ops 
     187    add'rest = flip (foldr $ insertRenaming apply) rest 
     188    in add'rest . add'ops $ mor 
     189 
     190-- * Construction 
     191 
     192-- | Create a 'Morphism' from an initial 'Sign'ature and a list of 'Renaming's. 
     193fromSignRenamings :: Sign -> [Renaming] -> Morphism 
     194fromSignRenamings = insertRenamings True . identity 
     195 
     196-- | Create a 'Morphism' from a pair of 'Sign'atures and a list of 'Renaming's. 
     197fromSignsRenamings :: Sign -> Sign -> [Renaming] -> Morphism 
     198fromSignsRenamings sign1 sign2 = insertRenamings False $ inclusion sign1 sign2 
     199 
     200-- | the empty 'Morphism' 
    202201empty :: Morphism 
    203202empty = identity Sign.empty 
    204203 
    205 -- | the identity Morphism 
     204-- | the identity 'Morphism' 
    206205identity :: Sign -> Morphism 
    207206identity sign = inclusion sign sign 
    208207 
    209 -- | the inclusion Morphism 
     208-- | the inclusion 'Morphism' 
    210209inclusion :: Sign -> Sign -> Morphism 
    211210inclusion src tgt = Morphism { 
    212211        source = src, 
    213212        target = tgt, 
    214         sortMap = Map.empty, 
    215         opMap = Map.empty, 
     213        sortMap  = Map.empty, 
     214        opMap    = Map.empty, 
    216215        labelMap = Map.empty 
    217216    } 
    218217 
    219  
    220 -- | the inverse Morphism 
     218-- * Combination 
     219 
     220-- | the inverse 'Morphism' 
    221221inverse :: Morphism -> Result Morphism 
    222222inverse mor = let 
    223         invertMap = Map.foldWithKey (flip Map.insert) Map.empty 
     223    invertMap = Map.foldWithKey (flip Map.insert) Map.empty 
    224224    in return Morphism { 
    225225        source = target mor, 
     
    230230    } 
    231231 
    232  
    233 -- | the composition of two Morphisms 
    234 compose :: Morphism -> Morphism -> Result Morphism 
    235 compose f g 
    236     | target f /= source g = fail 
    237         "target of the first and source of the second morphism are different" 
    238     | otherwise = let 
    239             -- Take SymbolMap |mp| of each Morphism. 
    240             -- Convert each SymbolMap to a function. 
    241             -- Compose those functions. 
    242             map'map :: (Morphism -> SymbolMap) -> Symbol -> Symbol 
    243             map'map mp = mapAsFunction (mp g) . mapAsFunction (mp f) 
    244             -- Map |x| via the composed SymbolMaps |mp| of both Morphisms. 
    245             -- Insert the renaming mapping into a SymbolMap. 
    246             insert :: (Morphism -> SymbolMap) -> Symbol -> SymbolMap -> SymbolMap 
    247             insert mp x = let y = map'map mp x 
    248                 in if x == y then id else Map.insert x y 
    249             -- Map each symbol in |items| via the combined SymbolMaps |mp|. 
    250             compose'map :: (Morphism -> SymbolMap) -> (Sign -> SymbolSet) -> SymbolMap 
    251             compose'map mp items = if Map.null (mp g) 
    252                 -- if the SymbolMap of |g| is empty, we use the one from |f| 
    253                 then mp f 
    254                 -- otherwise we start with the SymbolSet from |source f| 
    255                 -- and construct a combined SymbolMap by applying both 
    256                 -- SymbolMaps (from |f| and |g|) to each item in |insert| 
    257                 else Set.fold (insert mp) Map.empty $ items (source f) 
    258             -- We want a morphism from |source f| to |target g|. 
    259             mor = inclusion (source f) (target g) 
    260         in return mor { 
    261                 sortMap = compose'map sortMap getSorts, 
    262                 opMap = compose'map opMap getOps, 
    263                 labelMap = compose'map labelMap getLabels 
    264             } 
    265  
    266 -- | check that a Morphism is legal 
    267 isLegal :: Morphism -> Bool 
    268 isLegal mor = let 
    269         src = source mor 
    270         tgt = target mor 
    271         smap = sortMap mor 
    272         omap = opMap mor 
    273         lmap = labelMap mor 
    274         subset mp items = let mapped = Set.map $ mapAsFunction mp 
    275             in Set.isSubsetOf (mapped $ items src) $ items tgt 
    276         lg'source = Sign.isLegal src 
    277         lg'sortMap = subset smap getSorts 
    278         lg'opMap = subset omap getOps 
    279         lg'labelMap = subset lmap getLabels 
    280         lg'target = Sign.isLegal tgt 
    281     in all id [lg'source, lg'sortMap, lg'opMap, lg'labelMap, lg'target] 
    282  
    283 -- | check that a Morphism is the identity 
    284 isIdentity :: Morphism -> Bool 
    285 isIdentity mor = source mor == target mor 
    286  
    287 -- | check that a Morphism is an Inclusion 
    288 isInclusion :: Morphism -> Bool 
    289 isInclusion mor = let 
    290         null'sortMap  = Map.null (sortMap mor) 
    291         null'opMap    = Map.null (opMap mor) 
    292         null'labelMap = Map.null (labelMap mor) 
    293     in all id [null'sortMap, null'opMap, null'labelMap] 
    294  
    295 -- | translate a Sentence along a Morphism 
    296 mapSentence :: Morphism -> Sentence -> Result Sentence 
    297 mapSentence mor = let 
    298         smap = mapSorts (sortMap mor) 
    299         omap = mapOps (opMap mor) 
    300         lmap = mapLabels (labelMap mor) 
    301     in return . lmap . smap . omap 
    302  
     232-- | the union of two 'Morphism's 
    303233union :: Morphism -> Morphism -> Morphism 
    304 union m1 m2 = let apply func items = func (items m1) (items m2) 
     234union mor1 mor2 = let 
     235    apply func items = func (items mor1) (items mor2) 
    305236    in Morphism { 
    306237        source = apply Sign.union source, 
     
    311242    } 
    312243 
     244-- Just a shorthand for types inside compose. 
     245type Extraction = Morphism -> SymbolMap 
     246 
     247-- | the composition of two 'Morphism's 
     248compose :: Morphism -> Morphism -> Result Morphism 
     249compose f g 
     250    | target f /= source g = fail 
     251        "target of the first and source of the second morphism are different" 
     252    | otherwise = let 
     253        -- Take SymbolMap |mp| of each Morphism. 
     254        -- Convert each SymbolMap to a function. 
     255        -- Compose those functions. 
     256        map'map :: Extraction -> Symbol -> Symbol 
     257        map'map mp = mapAsFunction (mp g) . mapAsFunction (mp f) 
     258        -- Map |x| via the composed SymbolMaps |mp| of both Morphisms. 
     259        -- Insert the renaming mapping into a SymbolMap. 
     260        insert :: Extraction -> Symbol -> SymbolMap -> SymbolMap 
     261        insert mp x = let y = map'map mp x 
     262            in if x == y then id else Map.insert x y 
     263        -- Map each symbol in |items| via the combined SymbolMaps |mp|. 
     264        compose'map :: Extraction -> (Sign -> SymbolSet) -> SymbolMap 
     265        compose'map mp items = if Map.null (mp g) 
     266            -- if the SymbolMap of |g| is empty, we use the one from |f| 
     267            then mp f 
     268            -- otherwise we start with the SymbolSet from |source f| 
     269            -- and construct a combined SymbolMap by applying both 
     270            -- SymbolMaps (from |f| and |g|) to each item in |insert| 
     271            else Set.fold (insert mp) Map.empty $ items (source f) 
     272        -- We want a morphism from |source f| to |target g|. 
     273        mor = inclusion (source f) (target g) 
     274        in return mor { 
     275            sortMap = compose'map sortMap getSorts, 
     276            opMap = compose'map opMap getOps, 
     277            labelMap = compose'map labelMap getLabels 
     278        } 
     279 
     280-- * Testing 
     281 
     282-- | True iff the 'Morphism' is the identity 
     283isIdentity :: Morphism -> Bool 
     284isIdentity mor = source mor == target mor 
     285 
     286-- | True iff the 'Morphism' is an inclusion 
     287isInclusion :: Morphism -> Bool 
     288isInclusion mor = let 
     289    null'sortMap  = Map.null (sortMap mor) 
     290    null'opMap    = Map.null (opMap mor) 
     291    null'labelMap = Map.null (labelMap mor) 
     292    in all id [null'sortMap, null'opMap, null'labelMap] 
     293 
     294-- | True iff the 'Morphism' is legal 
     295isLegal :: Morphism -> Bool 
     296isLegal mor = let 
     297    src = source mor 
     298    tgt = target mor 
     299    smap = sortMap mor 
     300    omap = opMap mor 
     301    lmap = labelMap mor 
     302    subset mp items = let mapped = Set.map $ mapAsFunction mp 
     303        in Set.isSubsetOf (mapped $ items src) $ items tgt 
     304    lg'source = Sign.isLegal src 
     305    lg'sortMap = subset smap getSorts 
     306    lg'opMap = subset omap getOps 
     307    lg'labelMap = subset lmap getLabels 
     308    lg'target = Sign.isLegal tgt 
     309    in all id [lg'source, lg'sortMap, lg'opMap, lg'labelMap, lg'target] 
     310 
     311-- * Conversion 
     312 
     313-- | extract the complete 'SymbolMap' of a 'Morphism' 
     314symbolMap :: Morphism -> SymbolMap 
     315symbolMap mor = Map.unions [sortMap mor, opMap mor, labelMap mor] 
     316 
     317-- * Modification 
     318 
     319-- | set a new target for a 'Morphism' 
    313320setTarget :: Sign -> Morphism -> Morphism 
    314 setTarget sign morph = morph {target = sign} 
    315  
    316 renameSorts :: Morphism -> Symbols -> Symbols 
    317 renameSorts = mapSorts . sortMap 
    318  
     321setTarget = mapTarget . const 
     322 
     323-- | qualify a list of 'Symbol's inside a 'Morphism' 
    319324qualifySorts :: Morphism -> Qid -> Symbols -> Morphism 
    320325qualifySorts mor qid syms = let 
    321         insert symb = Map.insert symb $ qualify qid symb 
    322         smap = foldr insert Map.empty syms 
    323         q'tgt  = mapTarget $ mapSorts smap 
    324         q'smap = mapSortMap $ mapSorts smap 
    325         x'smap = mapSortMap $ Map.union smap 
     326    insert symb = Map.insert symb $ qualify qid symb 
     327    smap = foldr insert Map.empty syms 
     328    q'tgt  = mapTarget $ mapSorts smap 
     329    q'smap = mapSortMap $ mapSorts smap 
     330    x'smap = mapSortMap $ Map.union smap 
    326331    in q'tgt . x'smap .  q'smap $ mor 
    327332 
    328 -- FIXME: Code duplication! 
     333-- | apply a list of 'Renaming's to a 'Morphism' 
     334applyRenamings :: Morphism -> [Renaming] -> Morphism 
     335applyRenamings = insertRenamings True 
     336 
     337-- | apply a 'Sort' 'Renaming' to a 'Morphism' 
    329338extendWithSortRenaming :: Symbol -> Symbol -> Morphism -> Morphism 
    330339extendWithSortRenaming src tgt = let 
    331         add'sort = mapSortMap $ Map.insert src tgt 
    332         use'sort = mapTarget $ Sign.renameSort src tgt 
    333         ren'sort = mapOpMap $ renameSortOpMap src tgt 
     340    add'sort = mapSortMap $ Map.insert src tgt 
     341    use'sort = mapTarget $ Sign.renameSort src tgt 
     342    ren'sort = mapOpMap $ renameSortOpMap src tgt 
    334343    in ren'sort . use'sort . add'sort 
    335344 
    336 getNewSorts :: [Symbol] -> Morphism -> [Symbol] 
    337 getNewSorts ss morph = mapSorts (sortMap morph) ss 
     345-- * Application 
     346 
     347-- | translate a 'Sentence' along a 'Morphism' 
     348translateSentence :: Morphism -> Sentence -> Result Sentence 
     349translateSentence mor = let 
     350    smap = mapSorts (sortMap mor) 
     351    omap = mapOps (opMap mor) 
     352    lmap = mapLabels (labelMap mor) 
     353    in return . lmap . smap . omap 
     354 
     355-- | translate 'Sort's along a 'Morphism' 
     356translateSorts :: (HasSorts a) => Morphism -> a -> a 
     357translateSorts = mapSorts . sortMap