{-# LANGUAGE DeriveDataTypeable #-}
{- |
Module      :  ./CoCASL/CoCASLSign.hs
Description :  Signatures for CoCASL, as extension of CASL signatures
Copyright   :  (c) Till Mossakowski, Uni Bremen 2004
License     :  GPLv2 or higher, see LICENSE.txt
Maintainer  :  hausmann@informatik.uni-bremen.de
Stability   :  provisional
Portability :  portable

Signatures for CoCASL, as extension of CASL signatures.
-}

module CoCASL.CoCASLSign where

import CASL.Sign
import CASL.AS_Basic_CASL (SORT)

import qualified Common.Lib.Rel as Rel
import qualified Common.Lib.MapSet as MapSet

import Data.Data

data CoCASLSign = CoCASLSign
  { CoCASLSign -> Rel SORT
sees :: Rel.Rel SORT
  , CoCASLSign -> Rel SORT
constructs :: Rel.Rel SORT
  , CoCASLSign -> OpMap
constructors :: OpMap
  } deriving (Int -> CoCASLSign -> ShowS
[CoCASLSign] -> ShowS
CoCASLSign -> String
(Int -> CoCASLSign -> ShowS)
-> (CoCASLSign -> String)
-> ([CoCASLSign] -> ShowS)
-> Show CoCASLSign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoCASLSign] -> ShowS
$cshowList :: [CoCASLSign] -> ShowS
show :: CoCASLSign -> String
$cshow :: CoCASLSign -> String
showsPrec :: Int -> CoCASLSign -> ShowS
$cshowsPrec :: Int -> CoCASLSign -> ShowS
Show, CoCASLSign -> CoCASLSign -> Bool
(CoCASLSign -> CoCASLSign -> Bool)
-> (CoCASLSign -> CoCASLSign -> Bool) -> Eq CoCASLSign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoCASLSign -> CoCASLSign -> Bool
$c/= :: CoCASLSign -> CoCASLSign -> Bool
== :: CoCASLSign -> CoCASLSign -> Bool
$c== :: CoCASLSign -> CoCASLSign -> Bool
Eq, Eq CoCASLSign
Eq CoCASLSign =>
(CoCASLSign -> CoCASLSign -> Ordering)
-> (CoCASLSign -> CoCASLSign -> Bool)
-> (CoCASLSign -> CoCASLSign -> Bool)
-> (CoCASLSign -> CoCASLSign -> Bool)
-> (CoCASLSign -> CoCASLSign -> Bool)
-> (CoCASLSign -> CoCASLSign -> CoCASLSign)
-> (CoCASLSign -> CoCASLSign -> CoCASLSign)
-> Ord CoCASLSign
CoCASLSign -> CoCASLSign -> Bool
CoCASLSign -> CoCASLSign -> Ordering
CoCASLSign -> CoCASLSign -> CoCASLSign
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CoCASLSign -> CoCASLSign -> CoCASLSign
$cmin :: CoCASLSign -> CoCASLSign -> CoCASLSign
max :: CoCASLSign -> CoCASLSign -> CoCASLSign
$cmax :: CoCASLSign -> CoCASLSign -> CoCASLSign
>= :: CoCASLSign -> CoCASLSign -> Bool
$c>= :: CoCASLSign -> CoCASLSign -> Bool
> :: CoCASLSign -> CoCASLSign -> Bool
$c> :: CoCASLSign -> CoCASLSign -> Bool
<= :: CoCASLSign -> CoCASLSign -> Bool
$c<= :: CoCASLSign -> CoCASLSign -> Bool
< :: CoCASLSign -> CoCASLSign -> Bool
$c< :: CoCASLSign -> CoCASLSign -> Bool
compare :: CoCASLSign -> CoCASLSign -> Ordering
$ccompare :: CoCASLSign -> CoCASLSign -> Ordering
$cp1Ord :: Eq CoCASLSign
Ord, Typeable, Typeable CoCASLSign
Constr
DataType
Typeable CoCASLSign =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> CoCASLSign -> c CoCASLSign)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CoCASLSign)
-> (CoCASLSign -> Constr)
-> (CoCASLSign -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CoCASLSign))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CoCASLSign))
-> ((forall b. Data b => b -> b) -> CoCASLSign -> CoCASLSign)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r)
-> (forall u. (forall d. Data d => d -> u) -> CoCASLSign -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CoCASLSign -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign)
-> Data CoCASLSign
CoCASLSign -> Constr
CoCASLSign -> DataType
(forall b. Data b => b -> b) -> CoCASLSign -> CoCASLSign
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CoCASLSign -> c CoCASLSign
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CoCASLSign
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CoCASLSign -> u
forall u. (forall d. Data d => d -> u) -> CoCASLSign -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CoCASLSign
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CoCASLSign -> c CoCASLSign
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CoCASLSign)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CoCASLSign)
$cCoCASLSign :: Constr
$tCoCASLSign :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
gmapMp :: (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
gmapM :: (forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CoCASLSign -> m CoCASLSign
gmapQi :: Int -> (forall d. Data d => d -> u) -> CoCASLSign -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CoCASLSign -> u
gmapQ :: (forall d. Data d => d -> u) -> CoCASLSign -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CoCASLSign -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CoCASLSign -> r
gmapT :: (forall b. Data b => b -> b) -> CoCASLSign -> CoCASLSign
$cgmapT :: (forall b. Data b => b -> b) -> CoCASLSign -> CoCASLSign
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CoCASLSign)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CoCASLSign)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CoCASLSign)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CoCASLSign)
dataTypeOf :: CoCASLSign -> DataType
$cdataTypeOf :: CoCASLSign -> DataType
toConstr :: CoCASLSign -> Constr
$ctoConstr :: CoCASLSign -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CoCASLSign
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CoCASLSign
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CoCASLSign -> c CoCASLSign
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CoCASLSign -> c CoCASLSign
$cp1Data :: Typeable CoCASLSign
Data)

emptyCoCASLSign :: CoCASLSign
emptyCoCASLSign :: CoCASLSign
emptyCoCASLSign = Rel SORT -> Rel SORT -> OpMap -> CoCASLSign
CoCASLSign Rel SORT
forall a. Rel a
Rel.empty Rel SORT
forall a. Rel a
Rel.empty OpMap
forall a b. MapSet a b
MapSet.empty

closeConsRel :: CoCASLSign -> CoCASLSign
closeConsRel :: CoCASLSign -> CoCASLSign
closeConsRel s :: CoCASLSign
s =
  CoCASLSign
s { constructs :: Rel SORT
constructs = Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a
Rel.transClosure (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
constructs CoCASLSign
s
    , sees :: Rel SORT
sees = Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a
Rel.transClosure (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
sees CoCASLSign
s }

addCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
addCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
addCoCASLSign a :: CoCASLSign
a b :: CoCASLSign
b = CoCASLSign -> CoCASLSign
closeConsRel CoCASLSign
a
  { sees :: Rel SORT
sees = Rel SORT -> Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a -> Rel a
Rel.union (CoCASLSign -> Rel SORT
sees CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
sees CoCASLSign
b
  , constructs :: Rel SORT
constructs = Rel SORT -> Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a -> Rel a
Rel.union (CoCASLSign -> Rel SORT
constructs CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
constructs CoCASLSign
b
  , constructors :: OpMap
constructors = OpMap -> OpMap -> OpMap
addOpMapSet (CoCASLSign -> OpMap
constructors CoCASLSign
a) (OpMap -> OpMap) -> OpMap -> OpMap
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> OpMap
constructors CoCASLSign
b }

interCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
interCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
interCoCASLSign a :: CoCASLSign
a b :: CoCASLSign
b = CoCASLSign -> CoCASLSign
closeConsRel CoCASLSign
a
  { sees :: Rel SORT
sees = Rel SORT -> Rel SORT -> Rel SORT
forall a. (Show a, Ord a) => Rel a -> Rel a -> Rel a
interRel (CoCASLSign -> Rel SORT
sees CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
sees CoCASLSign
b
  , constructs :: Rel SORT
constructs = Rel SORT -> Rel SORT -> Rel SORT
forall a. (Show a, Ord a) => Rel a -> Rel a -> Rel a
interRel (CoCASLSign -> Rel SORT
constructs CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
constructs CoCASLSign
b
  , constructors :: OpMap
constructors = OpMap -> OpMap -> OpMap
interOpMapSet (CoCASLSign -> OpMap
constructors CoCASLSign
a) (OpMap -> OpMap) -> OpMap -> OpMap
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> OpMap
constructors CoCASLSign
b }

diffCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
diffCoCASLSign :: CoCASLSign -> CoCASLSign -> CoCASLSign
diffCoCASLSign a :: CoCASLSign
a b :: CoCASLSign
b = CoCASLSign -> CoCASLSign
closeConsRel CoCASLSign
a
  { sees :: Rel SORT
sees = Rel SORT -> Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a -> Rel a
Rel.difference (CoCASLSign -> Rel SORT
sees CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
sees CoCASLSign
b
  , constructs :: Rel SORT
constructs = Rel SORT -> Rel SORT -> Rel SORT
forall a. Ord a => Rel a -> Rel a -> Rel a
Rel.difference (CoCASLSign -> Rel SORT
constructs CoCASLSign
a) (Rel SORT -> Rel SORT) -> Rel SORT -> Rel SORT
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> Rel SORT
constructs CoCASLSign
b
  , constructors :: OpMap
constructors = OpMap -> OpMap -> OpMap
diffOpMapSet (CoCASLSign -> OpMap
constructors CoCASLSign
a) (OpMap -> OpMap) -> OpMap -> OpMap
forall a b. (a -> b) -> a -> b
$ CoCASLSign -> OpMap
constructors CoCASLSign
b }

isSubCoCASLSign :: CoCASLSign -> CoCASLSign -> Bool
isSubCoCASLSign :: CoCASLSign -> CoCASLSign -> Bool
isSubCoCASLSign a :: CoCASLSign
a b :: CoCASLSign
b =
    Rel SORT -> Rel SORT -> Bool
forall a. Ord a => Rel a -> Rel a -> Bool
Rel.isSubrelOf (CoCASLSign -> Rel SORT
sees CoCASLSign
a) (CoCASLSign -> Rel SORT
sees CoCASLSign
b)
    Bool -> Bool -> Bool
&& Rel SORT -> Rel SORT -> Bool
forall a. Ord a => Rel a -> Rel a -> Bool
Rel.isSubrelOf (CoCASLSign -> Rel SORT
constructs CoCASLSign
a) (CoCASLSign -> Rel SORT
constructs CoCASLSign
b)
    Bool -> Bool -> Bool
&& OpMap -> OpMap -> Bool
isSubOpMap (CoCASLSign -> OpMap
constructors CoCASLSign
a) (CoCASLSign -> OpMap
constructors CoCASLSign
b)