Profiles.hs revision ee87c7423bf599b4f29e9b31945e00482a8b31ca
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikModule : $Header$
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikCopyright : (c) Felix Gabriel Mance
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikLicense : GPLv2 or higher, see LICENSE.txt
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikMaintainer : f.mance@jacobs-university.de
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikStability : provisional
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikPortability : portable
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikContains : OWL2 Profiles (EL, QL and RL)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikReferences : <http://www.w3.org/TR/owl2-profiles/>
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikdata Profiles = Profiles {
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik } deriving (Show, Eq, Ord)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikbottomProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikbottomProfile = Profiles False False False
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodniktopProfile :: Profiles
7c30eade4ae794ed809845f2ef70dda849b6e7c9Lukas SlebodniktopProfile = Profiles True True True
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelProfile = Profiles True False False
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikqlProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikqlProfile = Profiles False True False
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikrlProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikrlProfile = Profiles False False True
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelqlProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelqlProfile = Profiles True True False
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelrlProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikelrlProfile = Profiles True False True
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikqlrlProfile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikqlrlProfile = Profiles False True True
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikall3Profile :: Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikall3Profile = Profiles True True True
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikprintProfile :: Profiles -> String
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikprintProfile p@(Profiles e q r) = case p of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik (Profiles False False False) -> "NP"
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> (if e then "EL" else "")
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ++ (if q then "QL" else "")
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ++ (if r then "RL" else "")
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikandProfileList :: [Profiles] -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikandProfileList pl = bottomProfile {
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik el = all el pl,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ql = all ql pl,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik rl = all rl pl
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikandList :: (a -> Profiles) -> [a] -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikandList f cel = andProfileList (map f cel)
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikminimalCovering :: Profiles -> [Profiles] -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikminimalCovering c pl = andProfileList [c, andProfileList pl]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikdataType :: Datatype -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikdataType _ = topProfile -- needs to be implemented, of course
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikliteral :: Literal -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikliteral _ = topProfile -- needs to be implemented
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikindividual :: Individual -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnikindividual i = if isAnonymous i then rlProfile else topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikobjProp :: ObjectPropertyExpression -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikobjProp ope = case ope of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectInverseOf _ -> qlrlProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikdataRange :: DataRange -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodnikdataRange dr = case dr of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik DataType dt cfl ->
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik if null cfl then dataType dt
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik else bottomProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik DataJunction IntersectionOf drl -> andProfileList $ map dataRange drl
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik DataOneOf ll -> bottomProfile {
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik el = el (andList literal ll) && length ll == 1
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> bottomProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodniksubClass :: ClassExpression -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodniksubClass cex = case cex of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Expression c -> if isThing c then elqlProfile else topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectJunction jt cel -> minimalCovering (case jt of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik IntersectionOf -> elrlProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik UnionOf -> rlProfile) $ map subClass cel
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectOneOf il -> bottomProfile {
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik el = el (andList individual il) && length il == 1,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik rl = ql $ andList individual il
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectValuesFrom SomeValuesFrom ope ce -> andProfileList [objProp ope,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Expression c -> if isThing c then topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik else elrlProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> minimalCovering elrlProfile [subClass ce]]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectHasValue ope i -> minimalCovering elrlProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik [objProp ope, individual i]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectHasSelf ope -> minimalCovering elProfile [objProp ope]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik DataValuesFrom SomeValuesFrom _ dr -> dataRange dr
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik DataHasValue _ l -> literal l
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> bottomProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodniksuperClass :: ClassExpression -> Profiles
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas SlebodniksuperClass cex = case cex of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Expression c -> if isThing c then elqlProfile else topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectJunction IntersectionOf cel -> andList superClass cel
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectComplementOf ce -> minimalCovering qlrlProfile [subClass ce]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectOneOf il -> bottomProfile {
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik el = el (andList individual il) && length il == 1,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik rl = ql $ andList individual il
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectValuesFrom qt ope ce -> case qt of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik SomeValuesFrom -> andProfileList [objProp ope, case ce of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Expression _ -> elqlProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik _ -> elProfile]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik AllValuesFrom -> andProfileList [superClass ce, rlProfile]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectHasValue ope i -> andProfileList [elrlProfile, objProp ope,
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik individual i]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectHasSelf ope -> andProfileList [elProfile, objProp ope]
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik ObjectCardinality (Cardinality MaxCardinality i _ mce) ->
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik if elem i [0, 1] then andProfileList [rlProfile, case mce of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Nothing -> topProfile
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Just ce -> case ce of
558ec7d717735bb16c210c675c2cc5bee1da4576Lukas Slebodnik Expression _ -> topProfile