SignCSP.hs revision 57221209d11b05aa0373cc3892d5df89ba96ebf9
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder{-# LANGUAGE TypeSynonymInstances #-}
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederDescription : CspCASL signatures
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederCopyright : (c) Markus Roggenbach and Till Mossakowski and Uni Bremen 2004
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederMaintainer : M.Roggenbach@swansea.ac.uk
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederStability : provisional
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaederPortability : portable
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedersignatures for CSP-CASL
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport CspCASL.AS_CspCASL_Process (CHANNEL_NAME, PROCESS_NAME,
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder PROCESS (..), CommAlpha, CommType (..), TypedChanName (..))
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport CASL.AS_Basic_CASL (CASLFORMULA, SORT, TERM)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport CASL.Sign (CASLSign, emptySign, Sign, extendedInfo, sortRel)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport Common.Lib.Rel (predecessors)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport qualified Data.Map as Map
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederimport qualified Data.Set as Set
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder-- | A process has zero or more parameter sorts, and a communication
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maederdata ProcProfile = ProcProfile [SORT] CommAlpha
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder deriving (Eq, Ord, Show)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedertype ChanNameMap = Map.Map CHANNEL_NAME SORT
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedertype ProcNameMap = Map.Map PROCESS_NAME ProcProfile
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedertype ProcVarMap = Map.Map SIMPLE_ID SORT
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maedertype ProcVarList = [(SIMPLE_ID, SORT)]
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder-- Close a communication alphabet under CASL subsort
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercloseCspCommAlpha :: CspCASLSign -> CommAlpha -> CommAlpha
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercloseCspCommAlpha sig =
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder Set.unions . Set.toList . Set.map (closeOneCspComm sig)
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder-- Close one CommType under CASL subsort
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercloseOneCspComm :: CspCASLSign -> CommType -> CommAlpha
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian MaedercloseOneCspComm sig x = let
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder mkTypedChan c s = CommTypeChan $ TypedChanName c s
4654dbb45f8a4aea7aa5fed6be22c9efff19bfcaChristian Maeder subsorts s' =
fd28ce71068bc46a4e1bba587a978206959c62abChristian Maeder Set.singleton s' `Set.union` predecessors (sortRel sig) s'
fd28ce71068bc46a4e1bba587a978206959c62abChristian Maeder CommTypeSort s ->
fd28ce71068bc46a4e1bba587a978206959c62abChristian Maeder Set.map CommTypeSort (subsorts s)
fd28ce71068bc46a4e1bba587a978206959c62abChristian Maeder CommTypeChan (TypedChanName c s) ->
fd28ce71068bc46a4e1bba587a978206959c62abChristian Maeder Set.map CommTypeSort (subsorts s)
ec676ed8bdc0f0a1d52793db1d75eb0c8d6f0f05Christian Maeder `Set.union` Set.map (mkTypedChan c) (subsorts s)
ec676ed8bdc0f0a1d52793db1d75eb0c8d6f0f05Christian Maeder{- Will probably be useful, but doesn't appear to be right now.
ec676ed8bdc0f0a1d52793db1d75eb0c8d6f0f05Christian Maeder-- Extract the sorts from a process alphabet
procAlphaSorts :: CommAlpha -> Set.Set SORT
procAlphaSorts a = stripMaybe $ Set.map justSort a
procAlphaChans :: CommAlpha -> Set.Set TypedChanName
procAlphaChans a = stripMaybe $ Set.map justChan a
Set.unions subsort_sets
CspSign { chans = Map.union (chans sign1) (chans sign2)
, procSet = Map.union (procSet sign1) (procSet sign2)
{ chans = Map.empty
, procSet = Map.empty
{ chans = chans a `Map.union` chans b
, procSet = procSet a `Map.union` procSet b
{ chans = chans a `Map.difference` chans b
, procSet = procSet a `Map.difference` procSet b
chans a `Map.isSubmapOf` chans b &&
procSet a `Map.isSubmapOf` procSet b
case Map.size $ chans sigma of
vcat $ punctuate semi $ map printChan $ Map.toList chanMap
vcat $ punctuate semi $ map printProcName $ Map.toList procNameMap
printArgs sorts <+> colon <+> ppWithCommas (Set.toList commAlpha)
-- | TERMs i.e. constructed via the TERM constructor Qual_var.
emptyAlphabet = Set.empty