Changeset 12792

Show
Ignore:
Timestamp:
06.11.2009 14:50:45 (2 weeks ago)
Author:
csliam
Message:

Added Isabelle functions Image and Range. Drastically changed how the
process translation works. It now works for channels and term prefix
in a compatible way. All channel operations are now supported by
CspCASLProver. Renaming, hiding, chaos and run are still not supported.

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/CspCASLProver/Consts.hs

    r11854 r12792  
    2020    , classOp 
    2121    , classS 
     22    , convertChannelString 
    2223    , convertProcessName2String 
    2324    , convertSort2String 
     
    3031    , eventType 
    3132    , flatS 
     33    , flatOp 
    3234    , preAlphabetQuotType 
    3335    , preAlphabetS 
     
    3537    , preAlphabetType 
    3638    , projFlatS 
     39     , projFlatOp 
    3740    , mkChooseFunName 
    3841    , mkChooseFunOp 
    3942    , mkCompareWithFunName 
    40     , mkEventChannelConstructor 
    4143    , mkPreAlphabetConstructor 
    4244    , mkPreAlphabetConstructorOp 
    4345    , mkProcNameConstructor 
     46    , mkSortBarAbsString 
    4447    , mkSortBarAbsOp 
    4548    , mkSortBarRepOp 
    4649    , mkSortBarString 
    4750    , mkSortBarType 
    48     , mkSortDataSetString 
    4951    , mkSortFlatString 
    5052    , mkThyNameAlphabet 
     
    101103classS = "class" 
    102104 
     105-- | Function that takes a channel name produces the 
     106--   CspCASLProver's constructor for that channel. 
     107convertChannelString :: CHANNEL_NAME -> String 
     108convertChannelString = show 
     109 
    103110-- | Convert a SORT to a string 
    104111convertSort2String :: SORT -> String 
     
    112119cspFThyS :: String 
    113120cspFThyS  = "CSP_F" 
    114  
    115 -- | The string to use for the names of the data set types. See the channel 
    116 --   construction and the event data type. 
    117 dataSetS :: String 
    118 dataSetS = "DataSet" 
    119121 
    120122-- | String of the name of the function to compare eqaulity of two 
     
    154156flatS = "Flat" 
    155157 
     158-- | Function that takes a Term and adds a flat around it 
     159flatOp :: Term -> Term 
     160flatOp = termAppl (conDouble flatS) 
     161 
    156162-- | Function that takes a sort and outputs the function name for the 
    157163--   corresponing choose function 
     
    168174mkCompareWithFunName :: SORT -> String 
    169175mkCompareWithFunName sort = ("compare_with_" ++ (mkPreAlphabetConstructor sort)) 
    170  
    171 -- | Function that takes a channel name and a target sort and produces the 
    172 --   CspCASLProver's constructor for that channel with that target sort. 
    173 mkEventChannelConstructor :: CHANNEL_NAME -> SORT -> String 
    174 mkEventChannelConstructor c s = (show c) ++ "_" ++ (convertSort2String s) 
    175176 
    176177-- | Function that returns the constructor of PreAlphabet for a given 
     
    199200mkSortBarType sort = Type {typeId = (mkSortBarString sort), typeSort = [], typeArgs =[]} 
    200201 
    201 -- | Converts a sort in to the corresponding Data Set type for that sort 
    202 -- represented as a string. This is used in the construction of the channels and 
    203 -- is linked with the type event. 
    204 mkSortDataSetString :: SORT -> String 
    205 mkSortDataSetString s = (convertSort2String s) ++ "_" ++ dataSetS 
     202-- | Given a sort this function produces the function name (string) of the built 
     203--   in Isabelle fucntion that corresponds to the abstraction function of the 
     204--   type that sort_bar. 
     205mkSortBarAbsString :: SORT -> String 
     206mkSortBarAbsString s = "Abs_" ++ convertSort2String s ++ barExtS 
     207 
     208-- | Given a sort this function produces the a function on the abstract syntax 
     209--   of Isabelle that represents the built in Isabelle fucntion that corresponds 
     210--   to the abstraction function of the type sort_bar. 
     211mkSortBarAbsOp :: SORT -> Term -> Term 
     212mkSortBarAbsOp s = termAppl (conDouble (mkSortBarAbsString s)) 
     213 
     214-- | Given a sort this function produces the function name (string) of the built 
     215--   in Isabelle fucntion that corresponds to the representation function of the 
     216--   type sort_bar. 
     217mkSortBarRepString :: SORT -> String 
     218mkSortBarRepString s = "Rep_" ++ convertSort2String s ++ barExtS 
     219 
     220-- | Given a sort this function produces the a function on the abstract syntax 
     221--   of Isabelle that represents the built in Isabelle fucntion that corresponds 
     222--   to the representation function of the type sort_bar. 
     223mkSortBarRepOp :: SORT -> Term -> Term 
     224mkSortBarRepOp s = termAppl (conDouble (mkSortBarRepString s)) 
    206225 
    207226-- | Converts asort in to the corresponding flat type for that sort represented 
     
    211230mkSortFlatString s = (convertSort2String s) ++ "_" ++ flatS 
    212231 
    213 -- | Given a sort this function produces the function name (string) of the built 
    214 --   in Isabelle fucntion that corresponds to the abstraction function of the 
    215 --   type that sort_bar. 
    216 mkSortBarAbsString :: SORT -> String 
    217 mkSortBarAbsString s = "Abs_" ++ convertSort2String s ++ barExtS 
    218  
    219 -- | Given a sort this function produces the a function on the abstract syntax 
    220 --   of Isabelle that represents the built in Isabelle fucntion that corresponds 
    221 --   to the abstraction function of the type sort_bar. 
    222 mkSortBarAbsOp :: SORT -> Term -> Term 
    223 mkSortBarAbsOp s = termAppl (conDouble (mkSortBarAbsString s)) 
    224  
    225 -- | Given a sort this function produces the function name (string) of the built 
    226 --   in Isabelle fucntion that corresponds to the representation function of the 
    227 --   type sort_bar. 
    228 mkSortBarRepString :: SORT -> String 
    229 mkSortBarRepString s = "Rep_" ++ convertSort2String s ++ barExtS 
    230  
    231 -- | Given a sort this function produces the a function on the abstract syntax 
    232 --   of Isabelle that represents the built in Isabelle fucntion that corresponds 
    233 --   to the representation function of the type sort_bar. 
    234 mkSortBarRepOp :: SORT -> Term -> Term 
    235 mkSortBarRepOp s = termAppl (conDouble (mkSortBarRepString s)) 
    236  
    237232-- | Created a name for the theory file which stores the alphabet 
    238233--   construction for CspCASLProver. 
     
    303298projFlatS = "projFlat" 
    304299 
     300-- | Apply the CspCASLProvers projFlat function to an isabelle term 
     301projFlatOp :: Term -> Term 
     302projFlatOp = termAppl (conDouble projFlatS) 
     303 
    305304-- | Name for IsabelleHOL quot type 
    306305quotS :: String 
  • trunk/CspCASLProver/CspCASLProver.hs

    r12661 r12792  
    201201        -- Start with our empty isabelle theory and add the 
    202202        -- processes the the process refinement theorems. 
    203         (isaSign, isaSens) = addProcMap ccNnamedSens caslSign pcfolSign cfolSign 
     203        (isaSign, isaSens) = addProcMap ccNnamedSens ccSign pcfolSign cfolSign 
    204204                           $ addProcNameDatatype cspSign 
    205                            $ addDataSetTypes sortList 
    206205                           $ addFlatTypes sortList 
    207206                           $ addProjFlatFun 
  • trunk/CspCASLProver/CspProverConsts.hs

    r11854 r12792  
    3434    , cspProver_conditionalOp 
    3535    , cspProver_chan_nondeterministic_sendOp 
     36    , cspProver_chan_sendOp 
     37    , cspProver_chan_recOp 
    3638) where 
    3739 
     
    212214cspProver_chan_nondeterministic_sendAltArgOpPrio = 80 
    213215 
     216-- | Channel send operator symbols 
     217cspProver_chan_sendS :: String 
     218cspProver_chan_sendS = "Send_prefix" 
     219cspProver_chan_sendAltS :: String 
     220cspProver_chan_sendAltS = "(_ ! _ -> _)" 
     221cspProver_chan_sendAltArgPrios :: [Int] 
     222cspProver_chan_sendAltArgPrios = [900,1000,80] 
     223cspProver_chan_sendAltArgOpPrio :: Int 
     224cspProver_chan_sendAltArgOpPrio = 80 
     225 
     226-- | Channel receive operator symbols 
     227cspProver_chan_recS :: String 
     228cspProver_chan_recS = "Rec_prefix" 
     229cspProver_chan_recAltS :: String 
     230cspProver_chan_recAltS = "(_ ? _ : _ -> _)" 
     231cspProver_chan_recAltArgPrios :: [Int] 
     232cspProver_chan_recAltArgPrios = [900,900,1000,80] 
     233cspProver_chan_recAltArgOpPrio :: Int 
     234cspProver_chan_recAltArgOpPrio = 80 
     235 
    214236-- Isabelle Terms representing the operations for CspProver 
    215237 
     
    354376                        cspProver_chan_nondeterministic_sendAltArgOpPrio 
    355377 
    356  
     378-- | Channel send operator 
     379cspProver_chan_sendOp :: Term -> Term -> Term -> Term 
     380cspProver_chan_sendOp  = 
     381    makeTriCspProverOp cspProver_chan_sendS 
     382                       cspProver_chan_sendAltS 
     383                       cspProver_chan_sendAltArgPrios 
     384                       cspProver_chan_sendAltArgOpPrio 
     385 
     386-- | Channel receive operator 
     387cspProver_chan_recOp :: Term -> Term -> Term -> Term -> Term 
     388cspProver_chan_recOp  = 
     389    makeQuadCspProverOp cspProver_chan_recS 
     390                        cspProver_chan_recAltS 
     391                        cspProver_chan_recAltArgPrios 
     392                        cspProver_chan_recAltArgOpPrio 
    357393 
    358394-- | Create an Isabelle Term representing a (Unary) CspProver operator 
  • trunk/CspCASLProver/TransProcesses.hs

    r11854 r12792  
    1515module CspCASLProver.TransProcesses 
    1616    ( transProcess 
     17    , VarSource(..) 
    1718    )where 
    1819 
     
    2930 
    3031import CspCASL.AS_CspCASL_Process 
    31 import CspCASL.SignCSP (FQProcVarList) 
     32import CspCASL.SignCSP (CspCASLSign, CspSign(..), 
     33                        ccSig2CASLSign, ccSig2CspSign, ProcProfile(..)) 
    3234 
    3335import CspCASLProver.Consts 
     
    3537 
    3638import qualified Data.Set as Set 
     39import qualified Data.Map as Map 
    3740 
    3841import Isabelle.IsaSign 
    3942import Isabelle.IsaConsts 
     43 
     44 
     45 
     46-- | The origin of a variable 
     47data VarSource 
     48    -- | indicates that the variable originated from a prefix choice operator. 
     49    = PrefixChoice 
     50    -- | indicates that the variable originated from a channel nondeterministic 
     51    --   send or channel receive where the sort is the declared sort of the 
     52    --   channel. 
     53    | ChanSendOrRec CASL_AS_Basic_CASL.SORT 
     54    -- | indicates that the variable originated from global parameter to the 
     55    --   process. 
     56    | GlobalParameter 
     57 
     58-- | The target of the sort translation 
     59data SortTarget 
     60    -- | Indicates the translated sort will be used as a normal communication 
     61    --   e.g., as a prefix choice or event set. 
     62    = NormalComm 
     63    -- | Indicates that the sort will be used as a communication set with a 
     64    --   channel of certain declared sort. 
     65    | ChanComm CASL_AS_Basic_CASL.SORT 
     66 
     67-- | The taraget of the term translation 
     68data TermTarget 
     69    -- | Indicates the term will be used in the term prefix operator 
     70    = TermPrefix 
     71    -- | Indicates that the term will be used either as a parameter (where sort 
     72    -- | is declared sort of the parameter) or as a channel communication (where 
     73    -- | the sort is the declared sort of the channel). 
     74    | ChanSendOrParam CASL_AS_Basic_CASL.SORT 
     75 
     76-- | Variable source map, which maps variables to the source of the variable. 
     77type VSM = Map.Map CASL_AS_Basic_CASL.VAR VarSource 
    4078 
    4179-- | Translate a Process into CspProver (Isabelle). We need the data part (CASL 
     
    4482--   need the PCFOL and CFOL signature of the data part after translation to 
    4583--   PCFOL and CFOL to pass along to the term and formula translations. 
    46 transProcess :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
    47                 CASL_Sign.Sign () () -> FQProcVarList -> PROCESS -> Term 
    48 transProcess caslSign pcfolSign cfolSign globalVars pr = 
     84transProcess :: CspCASLSign -> CASL_Sign.Sign () () -> 
     85                CASL_Sign.Sign () () -> VSM -> PROCESS -> Term 
     86transProcess ccSign pcfolSign cfolSign vsm pr = 
    4987    let -- Make translations with all the signatures filled in 
    50         transFormula' = transFormula pcfolSign cfolSign globalVars 
    51         transProcess' = transProcess caslSign pcfolSign cfolSign globalVars 
    52         -- Union all the event sets together in Isabelle using the Isabelle 
    53         -- binary union operator 
    54         union esList = foldr1 binUnion esList 
     88        transFormula' = transFormula pcfolSign cfolSign 
     89        transProcess' = 
     90            transProcess ccSign pcfolSign cfolSign 
     91        cspSign = ccSig2CspSign ccSign 
     92        caslSign = ccSig2CASLSign ccSign 
     93        getProcParamSort procName index = 
     94            let procMap = procSet $ cspSign 
     95                paramSortList = case Map.lookup procName procMap of 
     96                             Nothing -> error "CspCASLProver.TransProcesses.transProcess: Process name not found in process map." 
     97                             Just pp -> case pp of 
     98                                          ProcProfile sorts _ -> sorts 
     99            in paramSortList !! index 
    55100    in case pr of 
    56101         -- precedence 0 
     
    58103         Stop _ -> cspProver_stopOp 
    59104         Div  _ -> cspProver_divOp 
    60          Run es _ -> App (cspProver_runOp) (head (transEventSet es)) NotCont 
    61          Chaos es _ -> App (cspProver_chaosOp) (head (transEventSet es)) NotCont 
     105         -- Run -> App (cspProver_runOp) (head (transEventSet es)) NotCont 
     106         Run _ _ -> conDouble "RunNotSupportedYet" 
     107         -- Chaos -> App (cspProver_chaosOp) (head (transEventSet es)) NotCont 
     108         Chaos _ _ -> conDouble "ChaosNotSupportedYet" 
    62109         NamedProcess pn fqParams _ -> 
    63110             let -- Make a process name term 
    64111                 pnTerm = conDouble $ convertProcessName2String pn 
    65                  -- Translate an argument(a term) as normal but make sure 
    66                  -- we land in the bar types and not in the alphabet 
    67                  transParam t = transTerm False caslSign pcfolSign cfolSign 
    68                                 globalVars t 
    69                  -- Create a list of translated parameters 
    70                  paramTerms = map transParam fqParams 
     112                 -- Translate an argument(a term), t is the sort of the declared 
     113                 -- parameter (the sort of the variable may be a subsort of the 
     114                 -- declared sort, so we must use the declared sort). 
     115                 transParam (term, declaredSortIndex) = 
     116                     let termTar = ChanSendOrParam $ 
     117                                   getProcParamSort pn declaredSortIndex 
     118                     in transCASLTerm caslSign pcfolSign cfolSign 
     119                        vsm termTar term 
     120                 -- Create a list of translated parameters, we number the 
     121                 -- parameters from zero 
     122                 paramTerms = map transParam $ zip fqParams [0..] 
    71123             in if (null fqParams) 
    72124                -- If there are no parameters we just get the process name term 
     
    77129         -- precedence 1 
    78130         ConditionalProcess fqFormula p q _ -> 
    79              cspProver_conditionalOp (transFormula' fqFormula) (transProcess' p) 
    80                                          (transProcess' q) 
     131             cspProver_conditionalOp (transFormula' vsm fqFormula) 
     132                                         (transProcess' vsm p) 
     133                                         (transProcess' vsm q) 
    81134         -- precedence 2 
    82          Hiding p es _ -> 
    83              cspProver_hidingOp (transProcess' p) (union (transEventSet es)) 
    84          RenamingProcess p re _ -> 
    85              cspProver_renamingOp (transProcess' p) (transRenaming re) 
     135         Hiding _ _ _ -> conDouble "HidingNotSupportedYet" 
     136             -- cspProver_hidingOp (transProcess' p) (union (transEventSet es)) 
     137         RenamingProcess _ _ _ -> conDouble "RenamingNotSupportedYet" 
     138             -- cspProver_renamingOp (transProcess' p) (transRenaming re) 
    86139         -- precedence 3 
    87140         Sequential p q _ -> 
    88              cspProver_sequenceOp (transProcess' p) (transProcess' q) 
     141             cspProver_sequenceOp (transProcess' vsm p) (transProcess' vsm q) 
    89142         PrefixProcess ev p _ -> 
    90143         -- All prefix events are dealt with inside the translation of events. 
    91              transEvent caslSign pcfolSign cfolSign globalVars ev p 
     144             transEvent ccSign pcfolSign cfolSign vsm ev p 
    92145         -- precedence 4 
    93146         InternalChoice p q _ -> 
    94              cspProver_internal_choiceOp (transProcess' p) (transProcess'  q) 
     147             cspProver_internal_choiceOp (transProcess' vsm p) 
     148                                             (transProcess' vsm q) 
    95149         ExternalChoice p q _ -> 
    96              cspProver_external_choiceOp (transProcess' p) (transProcess'  q) 
     150             cspProver_external_choiceOp (transProcess' vsm p) 
     151                                             (transProcess' vsm q) 
    97152         -- precedence 5 
    98153         Interleaving p q _ -> 
    99              cspProver_interleavingOp (transProcess' p) (transProcess' q) 
     154             cspProver_interleavingOp (transProcess' vsm p) 
     155                                          (transProcess' vsm q) 
    100156         SynchronousParallel p q _ -> 
    101              cspProver_synchronousOp (transProcess' p) (transProcess' q) 
     157             cspProver_synchronousOp (transProcess' vsm p) 
     158                                         (transProcess' vsm q) 
    102159         GeneralisedParallel p es q _ -> 
    103              cspProver_general_parallelOp (transProcess' p) 
    104                                               (union (transEventSet es)) 
    105                                               (transProcess' q) 
     160             cspProver_general_parallelOp (transProcess' vsm p) 
     161                                              (transEventSet es) 
     162                                              (transProcess' vsm q) 
    106163 
    107164         AlphabetisedParallel p les res q _ -> 
    108              cspProver_alphabetised_parallelOp (transProcess' p) 
    109                                                    (union (transEventSet les)) 
    110                                                    (union (transEventSet res)) 
    111                                                    (transProcess' q) 
     165             cspProver_alphabetised_parallelOp (transProcess' vsm p) 
     166                                                   (transEventSet les) 
     167                                                   (transEventSet res) 
     168                                                   (transProcess' vsm q) 
    112169         -- Just forget the fully qualified data i.e. the constituent 
    113170         -- communication alphabet. Translate as normal. 
    114171         FQProcess p _ _ -> 
    115              transProcess'  p 
    116  
    117 -- | Translate a fully qualified EventSet into a list Isabelle term.  Event Sets 
    118 --   are treated differently in different CSP operators, so its up to the 
    119 --   calling function to do somehting useful with the returned list. 
    120 transEventSet :: EVENT_SET -> [Term] 
     172             transProcess' vsm p 
     173 
     174-- | Translate a fully qualified EventSet into a list Isabelle term. 
     175transEventSet :: EVENT_SET -> Term 
    121176transEventSet evs = 
    122177    case evs of 
    123       EventSet _ _ -> error "CspCASLProver.TransProcesses.transEventSet: Expected a FQEventSet not a non-FQEventSet"; 
    124       FQEventSet comms _ -> map transCommType comms 
     178      EventSet _ _ -> 
     179          error "CspCASLProver.TransProcesses.transEventSet: Expected a FQEventSet not a non-FQEventSet"; 
     180      FQEventSet comms _ -> 
     181          -- This list will not be empty otherwise, if it was empty the static 
     182          -- analysis would have failed. 
     183          foldr1 binUnion (map transCommType comms) 
    125184 
    126185-- | Translate a fully qualified CommType into an Isabelle term. 
     
    128187transCommType comm = 
    129188    case comm of 
    130       CommTypeSort sort -> conDouble $ mkSortBarString sort 
     189      CommTypeSort sort -> transSort NormalComm sort 
    131190      CommTypeChan typedChanName -> 
    132191          case typedChanName of 
    133             TypedChanName _ _ -> 
    134                 error "CspCASLProver.TransProcesses.transCommType: Typed channel name translation not implemented" 
     192            TypedChanName cn _ -> rangeOp (conDouble $ convertChannelString cn) 
    135193 
    136194-- | Translate a process event into CspProver (Isabelle). We need to know the 
    137 --   data pat (CASL signature) inorder to use the same translation for CASL 
    138 --   terms as the data encoding into Isabelle did. We also need the global 
    139 --   variables so we can treat local and global variables different. We need the 
    140 --   PCFOL and CFOL signature of the data part after translation to PCFOL and 
    141 --   CFOL to pass along to the term and formula translations. 
    142 transEvent :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
    143               CASL_Sign.Sign () () -> FQProcVarList -> 
     195--   data part (CASL signature) in order to use the same translation for CASL 
     196--   terms as the data encoding into Isabelle did. We need the Csp signature for 
     197--   getting the declared channel sorts. We need the PCFOL and CFOL signature of 
     198--   the data part after translation to PCFOL and CFOL to pass along to the term 
     199--   and formula translations. We need the vsm to pass it on to the term 
     200--   translation. 
     201transEvent :: CspCASLSign -> CASL_Sign.Sign () () -> 
     202              CASL_Sign.Sign () () -> VSM -> 
    144203              EVENT -> PROCESS -> Term 
    145 transEvent caslSign pcfolSign cfolSign globalVars event p = 
     204transEvent ccSign pcfolSign cfolSign vsm event p = 
    146205    let -- Make translation with all the signatures filled in 
    147         transProcess' = transProcess caslSign pcfolSign cfolSign globalVars 
     206        transProcess' = transProcess ccSign pcfolSign cfolSign 
     207        chanMap = chans $ ccSig2CspSign ccSign 
     208        caslSign = ccSig2CASLSign ccSign 
     209        transCASLTerm' = transCASLTerm caslSign pcfolSign cfolSign 
    148210    in case event of 
    149211      -- To use the fully qualified data we need to know what the underlying 
     
    152214          case ev of 
    153215            TermEvent _ _ -> 
    154                 -- Translate the term and make sure we do land in the 
    155                 -- alphabet and not in the bar types 
    156                 cspProver_action_prefixOp(transTerm True 
    157                                           caslSign pcfolSign cfolSign globalVars 
    158                                                    fqTerm) 
    159                 (transProcess' p) 
     216                -- Translate the term for use in the term prefix operator 
     217                cspProver_action_prefixOp (transCASLTerm' vsm TermPrefix fqTerm) 
     218                (transProcess' vsm p) 
    160219            InternalPrefixChoice v s _ -> 
    161                 -- Use the nonfully qualified data instead of the fully 
     220                -- Use the non fully qualified data instead of the fully 
    162221                -- qualified data as it is easier in this case as the variable 
    163222                -- is not really a variable of that sort. Here the variable and 
    164                 -- sort are seperate operands of the CSPProver operator. 
     223                -- sort are separate operands of the CSPProver operator. 
    165224                cspProver_internal_prefix_choiceOp 
    166                 (transVar v) (transSort s True) (transProcess' p) 
     225                (transVar v) (transSort NormalComm s) 
     226                                 (transProcess' 
     227                                  (Map.insert v PrefixChoice vsm) p) 
    167228            ExternalPrefixChoice v s _ -> 
    168                 -- Use the nonfully qualified data instead of the fully 
     229                -- Use the non fully qualified data instead of the fully 
    169230                -- qualified data as it is easier in this case as the variable 
    170231                -- is not really a variable of that sort. Here the variable and 
    171                 -- sort are seperate operands of the CSPProver operator. 
     232                -- sort are separate operands of the CSPProver operator. 
    172233                cspProver_external_prefix_choiceOp 
    173                   (transVar v) (transSort s True) 
    174                                    (transProcess' p) 
    175             ChanSend _ _ _ -> conDouble "ChanSendNotYetDone" 
     234                  (transVar v) (transSort NormalComm s) 
     235                                   (transProcess' 
     236                                    (Map.insert v PrefixChoice vsm) p) 
     237            ChanSend _ _ _ -> 
     238                -- We do not use the non fully qualified term or channel name. 
     239                -- Instead we use the fully qualified term (fqTerm) and the 
     240                -- fully qualified channel (mfqc) 
     241                case mfqc of 
     242                  Nothing -> error "CspCASLProver.TransProcesses.transEvent: Missing fully qualified channel data" 
     243                  Just (chanName, chanSort) -> 
     244                      -- CspProver's channel send Op 
     245                      cspProver_chan_sendOp 
     246                      -- Name of channel 
     247                      (transChanName chanName) 
     248                      -- Term to send 
     249                      (transCASLTerm' vsm (ChanSendOrParam chanSort) fqTerm) 
     250                      -- The translated version of the rest of the process 
     251                      (transProcess' vsm p) 
     252 
    176253            ChanNonDetSend _ var varSort _ -> 
    177254                -- We do not use the fully qualified variable (fqTerm) instead 
     
    179256                case mfqc of 
    180257                  Nothing -> error "CspCASLProver.TransProcesses.transEvent: Missing fully qualified channel data" 
    181                   Just (chanName, chanSort) -> 
    182                       -- CspProvers channel non-deterministic channel send Op 
    183                       cspProver_chan_nondeterministic_sendOp 
    184                       -- The channel made of the name and the target sort of the 
    185                       -- channel 
    186                       (transChanName chanName chanSort) 
    187                       -- The translate variable 
     258                             -- Notice we do not use the derived channel's 
     259                             -- sort(second of Just) as this can be a sub type 
     260                             -- of the declared channel sort, which is what we 
     261                             -- need. 
     262                  Just (chanName, _) -> 
     263                      let declaredChanSort = case Map.lookup chanName chanMap of 
     264                                             Nothing -> error "CspCASLProver.TransProcesses.transEvent: Channel name not in channel map" 
     265                                             Just s -> s 
     266                      -- CspProvers non-deterministic channel send Op 
     267                      in cspProver_chan_nondeterministic_sendOp 
     268                      -- The channel name 
     269                      (transChanName chanName) 
     270                      -- The translated variable 
    188271                      (transVar var) 
    189272                      -- The translate sort (channel version) of the set to 
    190                       -- receive from 
    191                       (transSort varSort False) 
     273                      -- receive from. Note that the sort in the mfqc is the 
     274                      -- sort of the variable as specified, we want here the 
     275                      -- declaration sort of the channel. 
     276                      (transSort (ChanComm declaredChanSort) varSort) 
    192277                      -- The translated version of the rest of the process 
    193                       (transProcess' p) 
    194  
    195             ChanRecv _ _ _ _ -> conDouble "ChanRecvNotYetDone" 
     278                      (transProcess' (Map.insert var 
     279                                      (ChanSendOrRec declaredChanSort) vsm) p) 
     280 
     281            ChanRecv _ var varSort _ -> 
     282                -- We do not use the fully qualified variable (fqTerm) instead 
     283                -- we use the non fully qualified variable (var, varSort). 
     284                case mfqc of 
     285                  Nothing -> error "CspCASLProver.TransProcesses.transEvent: Missing fully qualified channel data" 
     286                  -- Notice we do not use the derived channel's sort(second of 
     287                  -- Just) as this can be a sub type of the declared channel 
     288                  -- sort, which is what we need. 
     289                  Just (chanName, _) -> 
     290                      let declaredChanSort = case Map.lookup chanName chanMap of 
     291                                             Nothing -> error "CspCASLProver.TransProcesses.transEvent: Channel name not in channel map" 
     292                                             Just s -> s 
     293                      -- CspProvers channel receive Op 
     294                      in cspProver_chan_recOp 
     295                      -- The channel name 
     296                      (transChanName chanName) 
     297                      -- The translated variable 
     298                      (transVar var) 
     299                      -- The translate sort (channel version) of the set to 
     300                      -- receive from. Note that the sort in the mfqc is the 
     301                      -- sort of the variable as specified, we want here the 
     302                      -- declaration sort of the channel. 
     303                      (transSort (ChanComm declaredChanSort) varSort) 
     304                      -- The translated version of the rest of the process 
     305                      (transProcess' (Map.insert var 
     306                                      (ChanSendOrRec declaredChanSort) vsm) p) 
     307 
    196308            FQEvent _ _ _ _ -> error "CspCASLProver.TransProcesses.transEvent: A FQEvent should not contain a non-FQEvent"; 
    197309      _ ->  error "CspCASLProver.TransProcesses.transEvent: Expected a FQEvent not a non-FQEvent"; 
     
    203315transVar v = conDouble $ tokStr v 
    204316 
    205 -- | Translate a sort into CspProver (Isabelle). If toFlat = true then the 
    206 --   result will be the corresponding flat type for a given sort else it will be 
    207 --   the data set type for the given sort i.e. toFlat = true for normal 
    208 --   communication, toFlat = false for channel communications 
    209 transSort :: CASL_AS_Basic_CASL.SORT -> Bool -> Term 
    210 transSort sort toFlat = if toFlat 
    211                         then conDouble $ mkSortFlatString sort 
    212                         else conDouble $ mkSortDataSetString sort 
    213  
    214 transChanName :: CHANNEL_NAME -> CASL_AS_Basic_CASL.SORT -> Term 
    215 transChanName chanName sort = 
    216     conDouble $ mkEventChannelConstructor chanName sort 
    217  
    218 transRenaming :: RENAMING -> Term 
    219 transRenaming _ = conDouble "RenamingNotDoneYet" 
     317-- | Translate a sort into CspProver (Isabelle) depending on the target of the 
     318-- | sort. 
     319transSort :: SortTarget -> CASL_AS_Basic_CASL.SORT -> Term 
     320transSort target s = 
     321    let sBar = conDouble $ mkSortBarString s 
     322    in case target of 
     323         NormalComm -> binImageOp (conDouble flatS) $ sBar 
     324         ChanComm t -> binImageOp 
     325                       (conDouble $ mkSortBarAbsString t) sBar 
     326 
     327-- | Translated the channel name to Isabelle code. 
     328transChanName :: CHANNEL_NAME -> Term 
     329transChanName chanName = 
     330    conDouble $ convertChannelString chanName 
     331 
     332-- transRenaming :: RENAMING -> Term 
     333-- transRenaming _ = conDouble "RenamingNotDoneYet" 
    220334 
    221335------------------------------------------------------------------------- 
     
    225339-- | Produce a record that is used to translate CASL terms and formulae to 
    226340--   Isabelle Terms. This record is the same as the CFOL2IsabelleHOL.transRecord 
    227 --   but deals with variables by adding various functions around them depending 
    228 --   on if the variable is global or local. 
    229 cspCaslTransRecord :: CASL_Sign.Sign f e -> FQProcVarList -> Set.Set String -> 
     341--   but deals with variables by applying a case on the origin of the 
     342--   variable. The Isabelle terms produced when this record is used are always 
     343--   of basic types i.e., can be used as parameters for function in the data 
     344--   encoding. 
     345cspCaslTransRecord :: CASL_Sign.Sign f e -> Set.Set String -> 
    230346                      CFOL2IsabelleHOL.FormulaTranslator f e -> 
    231                       Set.Set String -> Record f Term Term 
    232 cspCaslTransRecord caslSign globalVars tyToks trForm strs = 
     347                      Set.Set String -> VSM -> Record f Term Term 
     348cspCaslTransRecord caslSign tyToks trForm strs vsm = 
    233349     -- We use the existing record for translation but change its 
    234350     -- function in the case of a qualified variable. If we have a 
    235      -- variable then translate the variable but wrap it in the 
     351     -- variable then we must make a translate the variable but wrap it in the 
    236352     -- correct choose function for it's sort. 
    237353    (CFOL2IsabelleHOL.transRecord caslSign tyToks trForm strs) 
    238     { foldQual_var = \ _ v s r -> 
     354    { foldQual_var = \ _ v s _ -> 
    239355      let v' = mkFree $ CFOL2IsabelleHOL.transVar strs v 
    240       in -- If the variable is a global variable then add the 
    241          -- representation function before the choose function. 
    242         if ((CASL_AS_Basic_CASL.Qual_var v s r) `elem` globalVars) 
    243         then 
    244             -- Global variable 
    245             mkChooseFunOp s $ mkSortBarRepOp s $ v' 
    246         else 
    247             -- Local variable 
    248             mkChooseFunOp s $ v' 
     356      in case (Map.lookup v vsm) of 
     357           Nothing -> 
     358               error $ "CspCASLProver.TransProcesses.cspCaslTransRecord: Variable not found in vsm:" ++ show v 
     359           Just varSource -> 
     360               case varSource of 
     361                 PrefixChoice -> mkChooseFunOp s $ projFlatOp v' 
     362                 ChanSendOrRec declaredChanSort -> 
     363                     mkChooseFunOp s $ mkSortBarRepOp declaredChanSort v' 
     364                 GlobalParameter -> mkChooseFunOp s $ mkSortBarRepOp s v' 
    249365    } 
    250366 
    251 -- | Translate a process term in to Isabelle HOL. The first parameter 
    252 --   decides if we should land in the alphabet or in a bar type. Both 
    253 --   of these are related by Abstraction and Representation fucntions 
    254 --   in Isabelle. The second parameter is he global variables of the 
    255 --   process. The third parameter is the data part (CASL signature) 
    256 --   for translating the translation of terms. 
    257 transTerm :: Bool -> CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
    258              CASL_Sign.Sign () () -> FQProcVarList -> 
    259              CASL_AS_Basic_CASL.TERM () -> Term 
    260 transTerm toAlphabet  caslSign pcfolSign cfolSign globalVars caslTerm = 
    261     let strs = CFOL2IsabelleHOL.getAssumpsToks caslSign in 
    262     case caslTerm of 
    263       -- if the term is just a variable then we need to check if its 
    264       -- global and if we land in the alphabet or not. Each case has 
    265       -- different behaviour. 
    266       CASL_AS_Basic_CASL.Qual_var v s r -> 
    267           let v' = mkFree $ CFOL2IsabelleHOL.transVar strs v 
    268           in 
    269             -- Check if the variable is a global variabe 
    270             if ((CASL_AS_Basic_CASL.Qual_var v s r) `elem` globalVars) 
    271             then 
    272                 -- Its a global Variable 
    273                 -- Check if we are to land in the alphabet or now 
    274                 if (toAlphabet) 
    275                 then 
    276                     -- Land in the Alphabet 
    277                     (mkSortBarRepOp s) v' 
    278                 else 
    279                     -- Land in the Bar Types 
    280                     v' -- Its already in the Bar Ype as its global 
    281             else 
    282                 -- Its a local Variable 
    283                 -- Check if we are to land in the alphabet or now 
    284                 if (toAlphabet) 
    285                 then 
    286                     -- Land in the Alphabet 
    287                     v' -- Its already in the alphabet as its local 
    288                 else 
    289                     -- Land in the Bar Types 
    290                     (mkSortBarAbsOp s) v' 
    291  
    292       -- otherwise (not a variable) we add a classOp and constructor 
    293       -- around it and translate the arguments with the transCaslTermWithoutWrap 
    294       -- translator that adds a chooseOp, representation and 
    295       -- abstraction fucntiosn where needed. 
    296       _ -> let sort = CASL_Sign.sortOfTerm caslTerm 
    297                -- Make a haskell function that will apply the constructor around 
    298                -- an Isabelle term. 
    299                constructor = mkPreAlphabetConstructorOp sort 
    300                -- Build the translation of the term wrapped in the constructor 
    301                -- wrapped in the class operation. 
    302                isaCaslTerm = classOp $ constructor $ 
    303                              transCaslTermWithoutWrap pcfolSign cfolSign 
    304                                                       globalVars caslTerm 
    305            in if (toAlphabet) 
    306               then isaCaslTerm 
    307               else (mkSortBarAbsOp sort) isaCaslTerm 
     367-- | Translate a CASL term into an Isabelle term. The result of this function 
     368-- | depends on the term target. a target of TermPrefix indicates we must land 
     369-- | in the alphabet and have a flat constructor wrapped around the 
     370-- | translation. A ChanSendOrParam indicates that the translated term will be 
     371-- | used in a channel send operator or as a parameter to a named process. The 
     372-- | translation also changes depending on the source of the variables used. 
     373transCASLTerm :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
     374                 CASL_Sign.Sign () () -> VSM -> TermTarget -> 
     375                 CASL_AS_Basic_CASL.TERM () -> Term 
     376transCASLTerm caslSign pcfolSign cfolSign vsm termTarget caslTerm = 
     377    let strs = CFOL2IsabelleHOL.getAssumpsToks caslSign 
     378    -- We make a case on the type of term, then on the term target, then if we 
     379    -- have a variable we make a case on the source of the variable 
     380    in case caslTerm of 
     381         -- Variable 
     382         CASL_AS_Basic_CASL.Qual_var v s _ -> 
     383             let v' = mkFree $ CFOL2IsabelleHOL.transVar strs v 
     384             in case termTarget of 
     385               TermPrefix -> 
     386                   case (Map.lookup v vsm) of 
     387                     Nothing -> error $ "CspCASLProver.TransProcesses.transTerm: Variable not found in vsm:" ++ show v 
     388                     Just varSource -> 
     389                         case varSource of 
     390                           PrefixChoice -> v' -- the variable is already ok 
     391                           ChanSendOrRec declaredChanSort -> 
     392                               flatOp $ mkSortBarRepOp declaredChanSort v' 
     393                           GlobalParameter -> flatOp $ mkSortBarRepOp s v' 
     394               ChanSendOrParam t -> 
     395                   case Map.lookup v vsm of 
     396                     Nothing -> error $ "CspCASLProver.TransProcesses.transTerm: Variable not found in vsm:" ++ show v 
     397                     Just varSource -> 
     398                         case varSource of 
     399                           PrefixChoice -> 
     400                               mkSortBarAbsOp t $ projFlatOp v' 
     401                           ChanSendOrRec declaredChanSort -> 
     402                               if declaredChanSort == t 
     403                               then v' 
     404                               else mkSortBarAbsOp t $ 
     405                                    mkSortBarRepOp declaredChanSort v' 
     406                           GlobalParameter -> 
     407                               if s == t 
     408                               then v' 
     409                               else mkSortBarAbsOp t $ 
     410                                    mkSortBarRepOp s v' 
     411         -- Other (not a variable) 
     412         _ -> let sort = CASL_Sign.sortOfTerm caslTerm 
     413                  -- Make a Haskell function that will apply the constructor 
     414                  -- around an Isabelle term. 
     415                  constructor = mkPreAlphabetConstructorOp sort 
     416                  -- Build the translation of the term wrapped in the 
     417                  -- constructor wrapped in the class operation. 
     418                  isaCaslTerm = classOp $ constructor $ 
     419                                transCaslTermComputation pcfolSign cfolSign 
     420                                                         vsm caslTerm 
     421              in case termTarget of 
     422                   TermPrefix -> flatOp isaCaslTerm 
     423                   ChanSendOrParam t -> (mkSortBarAbsOp t) isaCaslTerm 
    308424 
    309425-- | Translate a CASL Term to an Isabelle Term using the exact translation as is 
    310426--   done in the comorphism composition 
    311 --   CASL2PCFOL;defaultCASL2SubCFOL;CFOL2IsabelleHOL. With one exception, If we 
    312 --   are translating a variable then we must first add the correct choose 
    313 --   function around it to change it from an equivalence class to value of the 
    314 --   underlying sort. Also if we are translating a variable and the variable is 
    315 --   a global process variable then we must first apply Isabelle's 
    316 --   representation function to the variable. This function will always return a 
    317 --   term that is in the basic Sorts. i.e. to make it part of the alphabet it 
    318 --   will need to be wrapped up in a class operation with the necessary 
    319 --   constructor. We need the PCFOL and CFOL signature of the data part after 
     427--   CASL2PCFOL;defaultCASL2SubCFOL;CFOL2IsabelleHOL with out customised 
     428--   variable translation (see cspCaslTransRecord for where that customisation 
     429--   is define). The resulting Isabelle term of this function will be of the 
     430--   underlying sort types, thus can be used as parameters of CASL functions in 
     431--   the data part. We need the PCFOL and CFOL signature of the data part after 
    320432--   translation to CFOL to translate the formula. 
    321 transCaslTermWithoutWrap :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
    322                             FQProcVarList -> CASL_AS_Basic_CASL.TERM () -> Term 
    323 transCaslTermWithoutWrap pcfolSign cfolSign globalVars term = 
    324     let -- Function to remove subsorting - from comorphism CAS2PCFOL 
     433transCaslTermComputation :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> 
     434                            VSM -> CASL_AS_Basic_CASL.TERM () -> Term 
     435transCaslTermComputation pcfolSign cfolSign vsm term = 
     436    let -- Function to remove subsorting - from comorphism CASL2PCFOL 
    325437        rmSub = CASL2PCFOL.t2Term 
    326438        -- Remove subsorting from the term 
    327439        termNoSub = rmSub term 
    328         -- Function to remove partiality - from comorphism CAS2SubPCFOL 
     440        -- Function to remove partiality - from comorphism CASL2SubPCFOL 
    329441        -- This needs to match the translation CASL2SubCFOL.defaultCASL2SubCFOL 
    330442        b = True -- We want unique bottom elements per sort 
     
    335447        rmPartial = CASL_Simplify.simplifyTerm id . 
    336448                    CASL2SubCFOL.codeTerm b bsrts 
    337         -- Function to tranalate to Isabelle - from comorphism CFOL2IsabelleHOL 
     449        -- Function to translate to Isabelle - from comorphism CFOL2IsabelleHOL 
    338450        -- We need the CFOL signature to translate the terms properly 
    339451        tyToks = CFOL2IsabelleHOL.typeToks cfolSign 
     
    341453        strs = CFOL2IsabelleHOL.getAssumpsToks cfolSign 
    342454        toIsabelle = foldTerm $ cspCaslTransRecord cfolSign 
    343                      globalVars tyToks trForm strs 
     455                     tyToks trForm strs vsm 
    344456        --CFOL2IsabelleHOL.transFORMULA cfolSign tyToks trForm strs 
    345457    in toIsabelle $ rmPartial $ termNoSub 
     
    347459-- | Translate a fully qualified CASL formula into an Isabelle Term using the 
    348460--   exact translation as is done in the comorphism composition 
    349 --   CASL2PCFOL;defaultCASL2SubCFOL;CFOL2IsabelleHOL with one exception. The 
    350 --   exception is that a variable must have a choose function wrapped around it 
    351 --   and possible also a representation function (if it is a global 
    352 --   variable). We need the PCFOL and CFOL signature of the data part after 
    353 --   translation to CFOL to translate the formula. 
    354 transFormula :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> FQProcVarList -> 
     461--   CASL2PCFOL;defaultCASL2SubCFOL;CFOL2IsabelleHOL except translate CASL terms 
     462--   using the CASL term translation for computation, where the terms will be 
     463--   translated such that they are of the underlying sort types and thus can be 
     464--   used as operands to the formula operators. 
     465transFormula :: CASL_Sign.Sign () () -> CASL_Sign.Sign () () -> VSM -> 
    355466                CASL_AS_Basic_CASL.FORMULA () -> Term 
    356 transFormula pcfolSign cfolSign globalVars formula = 
     467transFormula pcfolSign cfolSign vsm formula = 
    357468    let -- Function to remove subsorting - from comorphism CAS2PCFOL 
    358469        rmSub = CASL2PCFOL.f2Formula 
     
    369480                    CASL2SubCFOL.codeFormula b bsrts 
    370481        -- Function to tranalate to Isabelle - from comorphism CFOL2IsabelleHOL 
    371         -- We need the CFOL signature to translate the formulas properly 
     482        -- We need the CFOL signature to translate the formula properly 
    372483        tyToks = CFOL2IsabelleHOL.typeToks cfolSign 
    373484        trForm = CFOL2IsabelleHOL.formTrCASL 
    374485        strs = CFOL2IsabelleHOL.getAssumpsToks cfolSign 
    375486        toIsabelle = foldFormula $ cspCaslTransRecord cfolSign 
    376                      globalVars tyToks trForm strs 
     487                     tyToks trForm strs vsm 
    377488        --CFOL2IsabelleHOL.transFORMULA cfolSign tyToks trForm strs 
    378489    in toIsabelle $ rmPartial $ formulaNoSub 
  • trunk/CspCASLProver/Utils.hs

    r12763 r12792  
    2121    , addAllCompareWithFun 
    2222    , addAllIntegrationTheorems 
    23     , addDataSetTypes 
    2423    , addEqFun 
    2524    , addEventDataType 
     
    3332    ) where 
    3433 
    35 import CASL.AS_Basic_CASL (SORT, OpKind(..)) 
     34import CASL.AS_Basic_CASL (SORT, OpKind(..), TERM(..)) 
    3635import qualified CASL.Fold as CASL_Fold 
    3736import qualified CASL.Sign as CASLSign 
     
    4847 
    4948import CspCASL.AS_CspCASL_Process (PROCESS_NAME) 
    50 import CspCASL.SignCSP (ChanNameMap, CspSign(..), ProcProfile(..), 
    51                         CspCASLSen(..), isProcessEq) 
     49import CspCASL.SignCSP (CspCASLSign, ccSig2CASLSign, ChanNameMap, CspSign(..), 
     50                        ProcProfile(..), CspCASLSen(..), isProcessEq) 
    5251 
    5352import CspCASLProver.Consts 
    5453import CspCASLProver.IsabelleUtils 
    55 import CspCASLProver.TransProcesses (transProcess) 
     54import CspCASLProver.TransProcesses (transProcess, VarSource(..)) 
    5655 
    5756import qualified Data.List as List 
     
    134133                lhs = termAppl lhs_a lhs_b 
    135134                lhs_a = termAppl (conDouble funName) x 
    136                 lhs_b = termAppl (conDouble (sort'Constructor)) y 
     135                lhs_b = termAppl (conDouble sort'Constructor) y 
    137136                sort'SuperSet =CASLSign.supersortsOf sort' caslSign 
    138137                commonSuperList = Set.toList (Set.intersection 
     
    142141                -- If there are no tests then the rhs=false else 
    143142                -- combine all tests using binConj 
    144                 rhs = if (null allTests) 
     143                rhs = if null allTests 
    145144                      then false 
    146145                      else foldr1 binConj allTests 
     
    152151                -- Test 4 =  test equality at: super sorts  vs super sorts 
    153152                allTests = concat [test1, test2, test3, test4] 
    154                 test1 = if (sort == sort') then [binEq x y] else [] 
     153                test1 = if sort == sort' then [binEq x y] else [] 
    155154                test2 = if (Set.member sort sort'SuperSet) 
    156155                        then [binEq x (mkInjection sort' sort y)] 
     
    559558 
    560559-- | Add the Event datatype (built from a list of channels and the subsort 
    561 --  relation) to an Isabelle theory. BUG 
     560--  relation) to an Isabelle theory. 
    562561addEventDataType :: Rel.Rel SORT -> ChanNameMap -> IsaTheory -> IsaTheory 
    563562addEventDataType sortRel chanNameMap isaTh = 
     
    566565    in updateDomainTab eventDomainEntry isaTh 
    567566 
    568 -- | Make a Domain Entry for the Event from a list of sorts. BUG 
     567-- | Make a Domain Entry for the Event from a list of sorts. 
    569568mkEventDE :: Rel.Rel SORT -> ChanNameMap -> DomainEntry 
    570 mkEventDE sortRel chanNameMap = 
     569mkEventDE _ chanNameMap = 
    571570    let flat = (mkVName flatS, [alphabetType]) 
    572         -- Make a constuctor type pair for a channel with a target sort 
    573         mkCon (c, s) = (mkVName (mkEventChannelConstructor c s), 
    574                                  [mkSortBarType s]) 
    575         -- Make pairs of channel and sorts, where the sorts are all the possible 
    576         -- predecessors of the sort of the channel. 
    577         mkChanSortPairs (cn,sort) = 
    578                 -- get all predecessors including s 
    579             let subSorts = Set.insert sort (Rel.predecessors sortRel sort) 
    580                 mkPair s = (cn,s) 
    581             in Set.toList $ Set.map mkPair subSorts 
     571        -- Make a constuctor type for a channel with a target sort 
     572        mkChanCon (c, s) = (mkVName (convertChannelString c), 
     573                                        [mkSortBarType s]) 
     574        -- Make pairs of channel and sorts, where we only build the declared 
     575        -- channels and not the subsorted channels. 
     576        mkAllChanCons = map mkChanCon $ Map.toList chanNameMap 
    582577        -- We build the event type out of the flat constructions and the list of 
    583578        -- channel constructions 
    584     in (eventType, (flat:(map mkCon $ concat $ map mkChanSortPairs $ 
    585                               Map.toList chanNameMap))) 
     579    in (eventType, (flat:mkAllChanCons)) 
    586580 
    587581-- | Add the eq function to an Isabelle theory using a list of sorts 
     
    626620        sen = TypeDef flatType subset (IsaProof [] (By proof')) 
    627621        namedSen = (makeNamed sortFlatString sen) 
    628     in (isaTh_sign, isaTh_sen ++ [namedSen]) 
    629  
    630 -- | Function to add all the Data Set types. These capture the original sorts by 
    631 --   creating sets of the bar varients. We use these sets when communicating 
    632 --   over a channel. 
    633 addDataSetTypes :: [SORT] -> IsaTheory -> IsaTheory 
    634 addDataSetTypes sorts isaTh = foldl addDataSetType isaTh sorts 
    635  
    636 -- | Function to add the Data Set type of a sort to an Isabelle theory. 
    637 addDataSetType :: IsaTheory -> SORT -> IsaTheory 
    638 addDataSetType isaTh sort = 
    639     let sortDataSetString = mkSortDataSetString sort 
    640         dataSetType = Type {typeId = sortDataSetString, 
    641                             typeSort = [], 
    642                             typeArgs =[]} 
    643         isaTh_sign = fst isaTh 
    644         isaTh_sen = snd isaTh 
    645         x = mkFree "x" 
    646         y = mkFree "y" 
    647         -- y in sort_Bar 
    648         condition1 = binMembership y (conDouble $ mkSortBarString sort) 
    649         -- x = Abs_sort_Bar y 
    650         condition2 = binEq x ((mkSortBarAbsOp sort) y) 
    651         -- y in x_Bar /\ x = Flat y 
    652         condition_eq = binConj condition1 condition2 
    653         exist_eq = termAppl (conDouble exS) (Abs y condition_eq NotCont) 
    654         subset = SubSet x (mkSortBarType sort) exist_eq 
    655         proof' = AutoSimpAdd Nothing [(mkSortBarString sort) ++ "_def"] 
    656         sen = TypeDef dataSetType subset (IsaProof [] (By proof')) 
    657         namedSen = (makeNamed sortDataSetString sen) 
    658622    in (isaTh_sign, isaTh_sen ++ [namedSen]) 
    659623 
     
    698662--   signatures of the data part after translation to PCFOL and CFOL to pass 
    699663--   along the process translation. 
    700 addProcMap :: [Named CspCASLSen] -> CASLSign.Sign () () -> 
     664addProcMap :: [Named CspCASLSen] -> CspCASLSign -> 
    701665              CASLSign.Sign () () -> CASLSign.Sign () () -> 
    702666              IsaTheory -> IsaTheory 
    703 addProcMap namedSens caslSign pcfolSign cfolSign isaTh = 
    704     let 
     667addProcMap namedSens ccSign pcfolSign cfolSign isaTh = 
     668    let caslSign = ccSig2CASLSign ccSign 
    705669        -- Translate a fully qualified variable (CASL term) to Isabelle 
    706670        tyToks = CFOL2IsabelleHOL.typeToks caslSign 
     
    729693                varTerms = map transVar fqVars 
    730694                lhs = procMapTerm (foldl termAppl (procNameTerm) varTerms) 
    731                 rhs = transProcess caslSign pcfolSign cfolSign fqVars proc 
     695                addToVdm fqvar vdm' = 
     696                    case fqvar of 
     697                      Qual_var v _ _ -> Map.insert v GlobalParameter vdm' 
     698                      _ -> error "CspCASLProver.Utils.addProcMap: Term other than fully qualified variable in process parameter variable list" 
     699                vdm = foldr addToVdm Map.empty fqVars 
     700                rhs = transProcess ccSign pcfolSign cfolSign vdm proc 
    732701             in binEq lhs rhs 
    733702        -- to avoid warnings we specify the behaviour on CASL sentences. This 
  • trunk/Isabelle/IsaConsts.hs

    r11805 r12792  
    9696membershipS :: String 
    9797membershipS = "op :" 
     98 
     99-- | Imange of functions 
     100imageS :: String 
     101imageS = "image" 
     102 
     103rangeS :: String 
     104rangeS = "range" 
    98105 
    99106-- * some stuff for Isabelle 
     
    341348-- * TERM CONSTRUCTORS 
    342349-- | binary junctors 
    343 binConj, binDisj, binImpl, binEqv, binEq, binEqvSim, binUnion, binMembership 
     350binConj, binDisj, binImpl, binEqv, binEq, binEqvSim, binUnion, 
     351       binMembership, binImageOp 
    344352    :: Term -> Term -> Term 
    345353binConj = binVNameAppl conjV 
     
    351359binUnion = binVNameAppl unionV 
    352360binMembership = binVNameAppl membershipV 
     361binImageOp = binVNameAppl imageV 
     362 
     363rangeOp :: Term -> Term 
     364rangeOp t = termAppl (con rangeV) t 
    353365 
    354366-- | HOL function application 
     
    554566membershipV :: VName 
    555567membershipV = VName membershipS $ Just $ AltSyntax "(_ \\<in>/ _)" [65,66] 65 
     568 
     569imageV :: VName 
     570imageV = VName imageS $ Just $ AltSyntax "(_ `/ _)" [65,66] 65 
     571 
     572rangeV :: VName 
     573rangeV = VName rangeS Nothing 
    556574 
    557575-- **** keywords in theory files from the Isar Reference Manual 2005