Morphism.hs revision be00381168b3f10192afabbba136fb06d3a9f358
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder{- |
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederModule : $Header$
e47d29b522739fbf08aac80c6faa447dde113fbcChristian MaederDescription : OWL Morphisms
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian MaederCopyright : (c) Dominik Luecke, 2008
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : luecke@informatik.uni-bremen.de
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederStability : provisional
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaederPortability : portable
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederMorphisms for OWL
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder-}
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maedermodule OWL2.Morphism
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder ( OWLMorphism (..)
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder , isOWLInclusion
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder , inclOWLMorphism
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder , legalMor
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder , composeMor
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder , cogeneratedSign
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder , generatedSign
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder , matchesSym
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder , statSymbItems
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder , statSymbMapItems
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder , inducedFromMor
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder , symMapOf
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder , mapSen
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder ) where
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maederimport OWL2.AS
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maederimport OWL2.MS
62925f4a144f45b5ed1e7c841f891d13f51e553dChristian Maederimport OWL2.Sign
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederimport OWL2.ManchesterPrint ()
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maederimport OWL2.StaticAnalysis
53301de22afd7190981b363b57c48df86fcb50f7Christian Maederimport OWL2.Symbols
cdaff0507c1b7240e2660dbb311f9c4646a6d14aChristian Maederimport OWL2.Rename
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian Maeder
ff9a53595208f532c25ac5168f772f48fd80fdb5Christian Maederimport Common.DocUtils
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maederimport Common.Doc
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maederimport Common.Result
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maederimport Common.Utils (composeMap)
975642b989852fc24119c59cf40bc1af653608ffChristian Maederimport Common.Lib.State (execState)
e47d29b522739fbf08aac80c6faa447dde113fbcChristian Maederimport Common.Lib.MapSet (setToMap)
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder
35cd0c10843c2cdbbe29f00a2a5d7e5e4f2d0064Christian Maederimport Control.Monad
975642b989852fc24119c59cf40bc1af653608ffChristian Maederimport Data.Maybe
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederimport qualified Data.Map as Map
975642b989852fc24119c59cf40bc1af653608ffChristian Maederimport qualified Data.Set as Set
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder
836e72a3c413366ba9801726f3b249c7791cb9caChristian Maederdata OWLMorphism = OWLMorphism
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder { osource :: Sign
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder , otarget :: Sign
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder , mmaps :: Map.Map Entity IRI
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder , pmap :: TranslationMap
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder } deriving (Show, Eq, Ord)
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederinclOWLMorphism :: Sign -> Sign -> OWLMorphism
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederinclOWLMorphism s t = OWLMorphism
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder { osource = s
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder , otarget = t
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder , pmap = Map.empty
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder , mmaps = Map.empty }
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederisOWLInclusion :: OWLMorphism -> Bool
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederisOWLInclusion m = Map.null (pmap m)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder && Map.null (mmaps m) && isSubSign (osource m) (otarget m)
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maeder
fa45d098e1c9d468f128be9505eb7e5b2705b304Christian MaedersymMap :: Map.Map Entity IRI -> Map.Map Entity Entity
25612a7b3ce708909298d5426406592473880a20Christian MaedersymMap = Map.mapWithKey (\ (Entity ty _) -> Entity ty)
35cd0c10843c2cdbbe29f00a2a5d7e5e4f2d0064Christian Maeder
35cd0c10843c2cdbbe29f00a2a5d7e5e4f2d0064Christian MaederinducedElems :: Map.Map Entity IRI -> [Entity]
c1db3d36c29a6324745a86dbcba18b8e4cd9f338Christian MaederinducedElems = Map.elems . symMap
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder
36c6cc568751e4235502cfee00ba7b597dae78dcChristian MaederinducedSign :: Map.Map Entity IRI -> TranslationMap -> Sign -> Sign
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederinducedSign m t s =
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian Maeder let new = execState (do
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder mapM_ (modEntity Set.delete) $ Map.keys m
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder mapM_ (modEntity Set.insert) $ inducedElems m) s
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder in mv t new
18b709ce961d68328da768318dcc70067f066d86Christian Maeder
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian MaederinducedPref :: String -> String -> Sign -> (Map.Map Entity IRI, TranslationMap)
18b709ce961d68328da768318dcc70067f066d86Christian Maeder -> (Map.Map Entity IRI, TranslationMap)
ac142c1b088711f911018d8108a64be80b2f2a58Christian MaederinducedPref v u sig (m, t) =
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder let pm = prefixMap sig
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder in if Set.member v $ Map.keysSet pm
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder then if u == v then (m, t) else (m, Map.insert v u t)
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder else error $ "unknown symbol: " ++ showDoc v "\n" ++ shows sig ""
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder
9c5b1136299d9052e4e995614a3a36a051a2682fChristian MaederinducedFromMor :: Map.Map RawSymb RawSymb -> Sign -> Result OWLMorphism
9c5b1136299d9052e4e995614a3a36a051a2682fChristian MaederinducedFromMor rm sig = do
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder let syms = symOf sig
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder (mm, tm) <- foldM (\ (m, t) p -> case p of
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder (ASymbol s@(Entity _ v), ASymbol (Entity _ u)) ->
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian Maeder if Set.member s syms
fe5dbb45b6a8abf34375b4bc5f2a81cda664c0e4Christian Maeder then return $ if u == v then (m, t) else (Map.insert s u m, t)
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder else fail $ "unknown symbol: " ++ showDoc s "\n" ++ shows sig ""
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder (AnUri v, AnUri u) -> case filter (`Set.member` syms)
18b709ce961d68328da768318dcc70067f066d86Christian Maeder $ map (`Entity` v) entityTypes of
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski [] -> let v2 = showQU v
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder u2 = showQU u
b52ad1aed6b1eb8b8416aaf100695f54ea59aea0Christian Maeder in return $ inducedPref v2 u2 sig (m, t)
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder l -> return $ if u == v then (m, t) else
18b709ce961d68328da768318dcc70067f066d86Christian Maeder (foldr (`Map.insert` u) m l, t)
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder (APrefix v, APrefix u) -> return $ inducedPref v u sig (m, t)
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder _ -> error "OWL2.Morphism.inducedFromMor") (Map.empty, Map.empty)
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder $ Map.toList rm
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder return OWLMorphism
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder { osource = sig
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder , otarget = inducedSign mm tm sig
e9490701e16d1e8abd995ef876d6f937da93b412Christian Maeder , pmap = tm
e9490701e16d1e8abd995ef876d6f937da93b412Christian Maeder , mmaps = mm }
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaedersymMapOf :: OWLMorphism -> Map.Map Entity Entity
d5c415f6373274fed04d83b9322891f3b82e9c26Christian MaedersymMapOf mor = Map.union (symMap $ mmaps mor) $ setToMap $ symOf $ osource mor
22fc8a1bd14dc53c5c7f482d2e0c04eb5ee4beb4Christian Maeder
22fc8a1bd14dc53c5c7f482d2e0c04eb5ee4beb4Christian Maederinstance Pretty OWLMorphism where
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder pretty m = let
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder s = osource m
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder srcD = specBraces $ space <> pretty s
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder t = otarget m
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder in if isOWLInclusion m then
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder if isSubSign t s then
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder fsep [text "identity morphism over", srcD]
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder else fsep
e9490701e16d1e8abd995ef876d6f937da93b412Christian Maeder [ text "inclusion morphism of"
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder , srcD
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder , text "extended with"
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder , pretty $ Set.difference (symOf t) $ symOf s ]
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder else fsep
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder [ pretty $ mmaps m
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder , colon <+> srcD, mapsto <+> specBraces (space <> pretty t) ]
9e0472be46104307b974fe5079bf5cc9e94a1a96Christian Maeder
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaederlegalMor :: OWLMorphism -> Bool
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian MaederlegalMor m = let mm = mmaps m in
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder Set.isSubsetOf (Map.keysSet mm) (symOf $ osource m)
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder && Set.isSubsetOf (Set.fromList $ inducedElems mm) (symOf $ otarget m)
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maeder
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian MaedergetIri :: EntityType -> IRI -> Map.Map Entity IRI -> IRI
9c5b1136299d9052e4e995614a3a36a051a2682fChristian MaedergetIri ty u = fromMaybe u . Map.lookup (Entity ty u)
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder
ac142c1b088711f911018d8108a64be80b2f2a58Christian MaedercomposeMor :: OWLMorphism -> OWLMorphism -> Result OWLMorphism
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian MaedercomposeMor m1 m2 =
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian Maeder let nm = Set.fold (\ s@(Entity ty u) -> let
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder t = getIri ty u $ mmaps m1
b52ad1aed6b1eb8b8416aaf100695f54ea59aea0Christian Maeder r = getIri ty t $ mmaps m2
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder in if r == u then id else Map.insert s r) Map.empty
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder . symOf $ osource m1
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder in return m1
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder { otarget = otarget m2
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian Maeder , pmap = composeMap (prefixMap $ osource m1) (pmap m1) $ pmap m2
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder , mmaps = nm }
f454c20b6c126bea7d31d400cc8824b9ee8cc6eaChristian Maeder
b52ad1aed6b1eb8b8416aaf100695f54ea59aea0Christian MaedercogeneratedSign :: Set.Set Entity -> Sign -> Result OWLMorphism
65835942d66905c377fa503e0d577df5aade58feChristian MaedercogeneratedSign s sign =
65835942d66905c377fa503e0d577df5aade58feChristian Maeder let sig2 = execState (mapM_ (modEntity Set.delete) $ Set.toList s) sign
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder in if isSubSign sig2 sign then return $ inclOWLMorphism sig2 sign else
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder fail "non OWL2 subsignatures for (co)generatedSign"
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedergeneratedSign :: Set.Set Entity -> Sign -> Result OWLMorphism
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedergeneratedSign s sign = cogeneratedSign (Set.difference (symOf sign) s) sign
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaedermatchesSym :: Entity -> RawSymb -> Bool
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedermatchesSym e@(Entity _ u) r = case r of
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder ASymbol s -> s == e
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian Maeder AnUri s -> s == u || namePrefix u == localPart s && null (namePrefix s)
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder APrefix p -> p == namePrefix u
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder
statSymbItems :: [SymbItems] -> [RawSymb]
statSymbItems = concatMap
$ \ (SymbItems m us) -> case m of
AnyEntity -> map AnUri us
EntityType ty -> map (ASymbol . Entity ty) us
Prefix -> map (APrefix . showQN) us
statSymbMapItems :: [SymbMapItems] -> Result (Map.Map RawSymb RawSymb)
statSymbMapItems =
foldM (\ m (s, t) -> case Map.lookup s m of
Nothing -> return $ Map.insert s t m
Just u -> case (u, t) of
(AnUri su, ASymbol (Entity _ tu)) | su == tu ->
return $ Map.insert s t m
(ASymbol (Entity _ su), AnUri tu) | su == tu -> return m
(AnUri su, APrefix tu) | showQU su == tu ->
return $ Map.insert s t m
(APrefix su, AnUri tu) | su == showQU tu -> return m
_ -> if u == t then return m else
fail $ "differently mapped symbol: " ++ showDoc s "\nmapped to "
++ showDoc u " and " ++ showDoc t "")
Map.empty
. concatMap (\ (SymbMapItems m us) ->
let ps = map (\ (u, v) -> (u, fromMaybe u v)) us in
case m of
AnyEntity -> map (\ (s, t) -> (AnUri s, AnUri t)) ps
EntityType ty ->
let mS = ASymbol . Entity ty
in map (\ (s, t) -> (mS s, mS t)) ps
Prefix ->
map (\ (s, t) -> (APrefix (showQU s), APrefix $ showQU t)) ps)
mapAnno :: Map.Map Entity IRI -> Annotation -> Annotation
mapAnno m annt = case annt of
Annotation l a e -> Annotation l (getIri AnnotationProperty a m) e
mapAnnoList :: Map.Map Entity IRI -> Annotations -> Annotations
mapAnnoList m = map (mapAnno m)
mapSen :: OWLMorphism -> Axiom -> Result Axiom
mapSen m a = do
let new = mapAxiom (mmaps m) a
return $ mv (pmap m) new
mapObjExpr :: Map.Map Entity IRI -> ObjectPropertyExpression
-> ObjectPropertyExpression
mapObjExpr m ope = case ope of
ObjectProp u -> ObjectProp $ getIri ObjectProperty u m
ObjectInverseOf o -> ObjectInverseOf $ mapObjExpr m o
mapDRange :: Map.Map Entity IRI -> DataRange -> DataRange
mapDRange m dr = case dr of
DataType u l -> DataType (getIri Datatype u m) l
DataJunction j l -> DataJunction j (map (mapDRange m) l)
DataComplementOf d -> DataComplementOf $ mapDRange m d
DataOneOf _ -> dr
mapDataExpr :: Map.Map Entity IRI -> DataPropertyExpression
-> DataPropertyExpression
mapDataExpr m dpe = getIri DataProperty dpe m
getClassIri :: IRI -> Map.Map Entity IRI -> IRI
getClassIri = getIri Class
getIndIri :: IRI -> Map.Map Entity IRI -> IRI
getIndIri = getIri NamedIndividual
mapCard :: (a -> b) -> (c -> d) -> Cardinality a c -> Cardinality b d
mapCard f g (Cardinality ty i a mb) =
Cardinality ty i (f a) $ fmap g mb
mapDescr :: Map.Map Entity IRI -> ClassExpression -> ClassExpression
mapDescr m desc = case desc of
Expression u -> Expression $ getClassIri u m
ObjectJunction ty ds -> ObjectJunction ty $ map (mapDescr m) ds
ObjectComplementOf d -> ObjectComplementOf $ mapDescr m d
ObjectOneOf is -> ObjectOneOf $ map (`getIndIri` m) is
ObjectValuesFrom ty o d -> ObjectValuesFrom ty (mapObjExpr m o)
$ mapDescr m d
ObjectHasSelf o -> ObjectHasSelf $ mapObjExpr m o
ObjectHasValue o i -> ObjectHasValue (mapObjExpr m o) $ getIndIri i m
ObjectCardinality c -> ObjectCardinality
$ mapCard (mapObjExpr m) (mapDescr m) c
DataValuesFrom ty d dr -> DataValuesFrom ty (mapDataExpr m d)
$ mapDRange m dr
DataHasValue d c -> DataHasValue (mapDataExpr m d) c
DataCardinality c -> DataCardinality
$ mapCard (mapDataExpr m) (mapDRange m) c
mapFact :: Map.Map Entity IRI -> Fact -> Fact
mapFact m f = case f of
ObjectPropertyFact pn op i -> ObjectPropertyFact
pn (mapObjExpr m op) (i `getIndIri` m)
DataPropertyFact pn dp l -> DataPropertyFact
pn (mapDataExpr m dp) l
mapAnnList :: Map.Map Entity IRI -> (a -> a) ->
AnnotatedList a -> AnnotatedList a
mapAnnList m f anl =
let ans = map fst anl
l = map snd anl
in zip (map (mapAnnoList m) ans) (map f l)
mapLFB :: Map.Map Entity IRI -> ListFrameBit -> ListFrameBit
mapLFB m lfb = case lfb of
AnnotationBit a -> AnnotationBit
$ mapAnnList m (flip (getIri AnnotationProperty) m) a
ObjectBit a -> ObjectBit $ mapAnnList m (mapObjExpr m) a
DataBit a -> DataBit $ mapAnnList m (mapDataExpr m) a
IndividualSameOrDifferent a ->
IndividualSameOrDifferent $ mapAnnList m (`getIndIri` m) a
DataPropRange a -> DataPropRange $ mapAnnList m (mapDRange m) a
IndividualFacts a -> IndividualFacts $ mapAnnList m (mapFact m) a
ExpressionBit a -> ExpressionBit $ mapAnnList m (mapDescr m) a
ObjectCharacteristics _ -> lfb
mapAFB :: Map.Map Entity IRI -> AnnFrameBit -> AnnFrameBit
mapAFB m afb = case afb of
DatatypeBit dr -> DatatypeBit $ mapDRange m dr
ClassDisjointUnion ce -> ClassDisjointUnion $ map (mapDescr m) ce
ClassHasKey op dp -> ClassHasKey (map (mapObjExpr m) op)
(map (mapDataExpr m) dp)
ObjectSubPropertyChain op -> ObjectSubPropertyChain
(map (mapObjExpr m) op)
_ -> afb
mapFB :: Map.Map Entity IRI -> FrameBit -> FrameBit
mapFB m fb = case fb of
ListFrameBit mr lfb -> ListFrameBit mr $ mapLFB m lfb
AnnFrameBit ans afb -> AnnFrameBit (mapAnnoList m ans)
$ mapAFB m afb
mapAxiom :: Map.Map Entity IRI -> Axiom -> Axiom
mapAxiom m (PlainAxiom eith fb) = case eith of
SimpleEntity (Entity ty ent) -> PlainAxiom
(SimpleEntity $ Entity ty $ getIri ty ent m) $ mapFB m fb
Misc ans -> PlainAxiom (Misc $ mapAnnoList m ans) $ mapFB m fb
ObjectEntity ope -> PlainAxiom (ObjectEntity $ mapObjExpr m ope)
$ mapFB m fb
ClassEntity ce -> PlainAxiom (ClassEntity $ mapDescr m ce) $ mapFB m fb