Logic_CASL_DL.hs revision e5636f167d8113960d320407cbbd7cd3580241d4
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuModule : $Header$
734257b9ea9fcaa18d4e3627f54f5295a99aa1f7Felix Gabriel ManceDescription : Instance of class Logic for CASL DL
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuCopyright : (c) Klaus L�ttich, Uni Bremen 2005
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuMaintainer : luecke@informatik.uni-bremen.de
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuStability : provisional
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuPortability : portable
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae BungiuInstance of class Logic for CASL DL
c038fcf2030a6cfac7a261dee48a9eb29edb78eaFelix Gabriel Mancemodule CASL_DL.Logic_CASL_DL (CASL_DL(..), DLMor, DLFORMULA) where
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae Bungiuimport qualified Data.Set as Set
ccb84c1cb43fb0ed70c5bf2d364e671820473ed5Francisc Nicolae Bungiuimport qualified Common.Lib.Rel as Rel
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mancedata CASL_DL = CASL_DL deriving Show
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Manceinstance Language CASL_DL where
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance description _ =
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance "CASL_DL is at the same time an extension and a restriction of CASL.\n\
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance \It additionally provides cardinality restrictions in a description logic\n\
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance \sense; and it limits the expressivity of CASL to the description logic\n\
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance \SHOIN(D). Hence it provides the following sublogics: \n\
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance \ * Card -- CASL plus cardinality restrictions on binary relations\n\
2c0c0264249b8d2a3f465e22cb3c6d9c4ac8924aFelix Gabriel Mance \ * DL -- SHOIN(D)\n\
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mancetype DLMor = Morphism DL_FORMULA CASL_DLSign ()
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mancetype DLFORMULA = FORMULA DL_FORMULA
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Manceinstance Category CASL_DL DLSign DLMor
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance -- ide :: id -> object -> morphism
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance ide CASL_DL = idMor ()
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance -- comp :: id -> morphism -> morphism -> Maybe morphism
120b4b5a0f61d93eeaa17ff2c7867f58c7325e3bFelix Gabriel Mance comp CASL_DL = compose (const id)
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance -- dom, cod :: id -> morphism -> object
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance dom CASL_DL = msource
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance cod CASL_DL = mtarget
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance -- legal_obj :: id -> object -> Bool
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance legal_obj CASL_DL = legalSign
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance -- legal_mor :: id -> morphism -> Bool
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance legal_mor CASL_DL = legalMor
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance-- abstract syntax, parsing (and printing)
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel Manceinstance Syntax CASL_DL DL_BASIC_SPEC
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance SYMB_ITEMS SYMB_MAP_ITEMS
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance parse_basic_spec CASL_DL = Just $ basicSpec casl_DL_reserved_words
9c3f6477a95da46a907326206673b4a5c2164164Felix Gabriel Mance parse_symb_items CASL_DL = Just $ symbItems casl_DL_reserved_words
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance parse_symb_map_items CASL_DL =
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance Just $ symbMapItems casl_DL_reserved_words
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance-- CASL_DL logic
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mancemap_DL_FORMULA :: MapSen DL_FORMULA CASL_DLSign ()
9c3f6477a95da46a907326206673b4a5c2164164Felix Gabriel Mancemap_DL_FORMULA mor (Cardinality ct pn varT natT qualT r) =
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance Cardinality ct pn' varT' natT' qualT' r
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance where pn' = mapPrSymb mor pn
31a5ba51cd6d24e28a23abf64ce4043a45eabbefFelix Gabriel Mance varT' = mapTrm varT
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance natT' = mapTrm natT
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance qualT' = case qualT of
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance Nothing -> Nothing
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance Just x -> Just $ mapTrm x
316ef492799cd45fea0f5c26932f49adddfda3f7Felix Gabriel Mance mapTrm = mapTerm map_DL_FORMULA mor
31a5ba51cd6d24e28a23abf64ce4043a45eabbefFelix Gabriel Manceinstance Sentences CASL_DL DLFORMULA DLSign DLMor Symbol where
0be7a9c012366ada63d587898a15c551b499b76dFelix Gabriel Mance map_sen CASL_DL m = return . mapSen map_DL_FORMULA m
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance parse_sentence CASL_DL = Nothing
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance sym_of CASL_DL = symOf
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance symmap_of CASL_DL = morphismToSymbMap
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance sym_name CASL_DL = symName
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel Mance simplify_sen CASL_DL = simplifySen minDLForm simplifyCD
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel MancesimplifyCD :: DLSign -> DL_FORMULA -> DL_FORMULA
e5e3f128bbd44dd393e1038718038bd323f5e415Felix Gabriel MancesimplifyCD sign (Cardinality ct ps t1 t2 t3 r) = simpCard
734257b9ea9fcaa18d4e3627f54f5295a99aa1f7Felix Gabriel Mance where simpCard = maybe (card ps)
31a5ba51cd6d24e28a23abf64ce4043a45eabbefFelix Gabriel Mance (const $ card $ Pred_name pn)
3e0eb79b52a3078a12531efc3f66d0d94fd9938dFelix Gabriel Mance (resultToMaybe $
e5ea4eeaeefd3521ae3475719e18c96cf91637d5Felix Gabriel Mance minDLForm sign $ card $ Pred_name pn)
15d62726781e67fe6458fbcf0a8c46832a7bb8daFelix Gabriel Mance simp = rmTypesT minDLForm simplifyCD sign
dda7065c0c0f383558d7d4e8072969c8c41a8ed7Francisc Nicolae Bungiu card psy = Cardinality ct psy (simp t1) (simp t2)
e5ea4eeaeefd3521ae3475719e18c96cf91637d5Felix Gabriel Mance Nothing -> Nothing
e5ea4eeaeefd3521ae3475719e18c96cf91637d5Felix Gabriel Mance Just x -> Just $ simp x
c4076ff1721f8901a30e4b7aa004479ecb2631e0Felix Gabriel Mance pn = case ps of
30e9cf458094e5970bc06be667558961c2eccff4Felix Gabriel Mance Pred_name n -> n
12078a24d49ba36b83cda9d07c8e8a480c493fe8Felix Gabriel Mance Qual_pred_name n _pType _ -> n
matches CASL_DL = CASL.Morphism.matches
$ Set.map (\ x -> (x,topSort))