4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder{-# LANGUAGE DeriveDataTypeable #-}
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederDescription : Maude Morphisms
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuCopyright : (c) Martin Kuehl, Uni Bremen 2008-2009
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederLicense : GPLv2 or higher, see LICENSE.txt
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederMaintainer : mkhl@informatik.uni-bremen.de
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaederStability : experimental
b1c064439793db60fd1a6bb514c4ca9690a90a2eChristian MaederPortability : portable
b1c064439793db60fd1a6bb514c4ca9690a90a2eChristian MaederDefinition of morphisms for Maude.
e1d5f2ade9a052564973099a7ab2fc3aec091abdChristian Maeder -- ** The Morphism type
e1d5f2ade9a052564973099a7ab2fc3aec091abdChristian Maeder Morphism (..),
4d5f32c7e4e49e726f5d10943be3718afdff73cdChristian Maeder -- ** Auxiliary type
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder -- * Construction
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder fromSignRenamings,
1db8436e3bc935eec7ae680e1a4f6c11eb013270Christian Maeder fromSignsRenamings,
4d5f32c7e4e49e726f5d10943be3718afdff73cdChristian Maeder -- * Combination
34b317241b7401a4b0a90472e73d769d64d69a2aChristian Maeder -- * Conversion
e1d5f2ade9a052564973099a7ab2fc3aec091abdChristian Maeder -- * Modification
e1d5f2ade9a052564973099a7ab2fc3aec091abdChristian Maeder qualifySorts,
e1d5f2ade9a052564973099a7ab2fc3aec091abdChristian Maeder applyRenamings,
b1c064439793db60fd1a6bb514c4ca9690a90a2eChristian Maeder extendWithSortRenaming,
414ffa281d82f05a2d742c702f8e06b0cb05b229Christian Maeder -- * Application
4d5f32c7e4e49e726f5d10943be3718afdff73cdChristian Maeder translateSentence,
4d5f32c7e4e49e726f5d10943be3718afdff73cdChristian Maeder translateSorts,
61091743da1a9ed6dfd5e077fdcc972553358962Christian Maederimport Maude.Sign (Sign, kindRel, KindRel)
import Maude.Sentence (Sentence)
import qualified Maude.Sign as Sign
import Data.Data
import Data.List (partition)
import Data.Maybe (fromJust)
import qualified Data.Set as Set
import qualified Data.Map as Map
import Common.Result (Result)
import Common.Doc hiding (empty)
import Common.DocUtils (Pretty (..))
import Control.Monad (unless)
pr'map fun = vcat . map (uncurry fun) . Map.toList
add'op = mapOpMap $ uncurry Map.insert syms
then mapTarget $ uncurry Sign.renameOp syms attrs
add'sort = mapSortMap $ uncurry Map.insert syms
then mapTarget $ uncurry Sign.renameSort syms
add'labl = mapLabelMap $ uncurry Map.insert syms
then mapTarget $ uncurry Sign.renameLabel syms
empty = identity Sign.empty
sortMap = Map.empty,
kindMap = Map.empty,
opMap = Map.empty,
labelMap = Map.empty
source = apply Sign.union source,
target = apply Sign.union target,
sortMap = apply Map.union sortMap,
kindMap = apply Map.union kindMap,
opMap = apply Map.union opMap,
labelMap = apply Map.union labelMap
in if x == y then id else Map.insert x y
compose'map mp items = if Map.null (mp g)
null'sortMap = Map.null (sortMap mor)
null'opMap = Map.null (opMap mor)
null'labelMap = Map.null (labelMap mor)
subset mp items = let mapped = Set.map $ mapAsFunction mp
in Set.isSubsetOf (mapped $ items src) $ items tgt
lg'source = Sign.isLegal src
lg'target = Sign.isLegal tgt
symbolMap mor = Map.unions [sortMap mor, opMap mor, labelMap mor]
insert symb = Map.insert symb $ qualify qid symb
smap = foldr insert Map.empty syms
x'smap = mapSortMap $ Map.union smap
add'sort = mapSortMap $ Map.insert src tgt
use'sort = mapTarget $ Sign.renameSort src tgt
sm = Map.toList $ sortMap morph
kindMorphAux _ [] _ = Map.empty
kindMorphAux kr1 ((s1, s2) : ls) kr2 = Map.union m m'
then Map.empty
else Map.singleton k1 k2