5394N/A{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
5394N/ADescription : Extension of CFOL2IsabelleHOL to CoCASL
5394N/ACopyright : (c) Till Mossakowski and Uni Bremen 2003-2005
5394N/AMaintainer : hausmann@informatik.uni-bremen.de
5394N/AThe embedding comorphism from CoCASL to Isabelle-HOL.
5394N/A-- | The identity of the comorphism
5394N/Adata CoCFOL2IsabelleHOL = CoCFOL2IsabelleHOL deriving Show
5394N/Ainstance Language CoCFOL2IsabelleHOL where
5394N/A language_name CoCFOL2IsabelleHOL = "CoCASL2Isabelle"
5394N/Ainstance Comorphism CoCFOL2IsabelleHOL
5714N/A C_BASIC_SPEC CoCASLFORMULA SYMB_ITEMS SYMB_MAP_ITEMS
5394N/A IsabelleMorphism () () () where
5394N/A sourceLogic CoCFOL2IsabelleHOL = CoCASL
6399N/A targetLogic CoCFOL2IsabelleHOL = Isabelle
5394N/A mapSublogic cid sl = if sl `isSubElem` sourceSublogic cid
5394N/A map_theory CoCFOL2IsabelleHOL =
5394N/A return . transTheory sigTrCoCASL formTrCoCASL
5394N/A map_sentence CoCFOL2IsabelleHOL sign =
5394N/A return . mapSen formTrCoCASL sign (typeToks sign)
5394N/A has_model_expansion CoCFOL2IsabelleHOL = True
5394N/A is_weakly_amalgamable CoCFOL2IsabelleHOL = True
5394N/Axvar i = if i <= 26 then [chr (i + ord 'a')] else 'x' : show i
5947N/Arvar i = if i <= 9 then [chr (i + ord 'R' )] else 'R' : show i
5947N/A-- | extended signature translation for CoCASL
5947N/AsigTrCoCASL :: SignTranslator C_FORMULA CoCASLSign
5947N/Aconjs l = if null l then true else foldr1 binConj l
5947N/A-- | extended formula translation for CoCASL
5947N/AformTrCoCASL :: FormulaTranslator C_FORMULA CoCASLSign
5947N/AformTrCoCASL sign tyToks (CoSort_gen_ax sorts ops _) =
5947N/A foldr (quantifyIsa "All") phi $ predDecls ++ [("u", ts), ("v", ts)]
5947N/A ts = transSort $ head sorts
5947N/A -- phi expresses: all bisimulations are the equality
5947N/A phi = prems `binImpl` concls
5947N/A -- indices and predicates for all involved sorts
5394N/A indexedSorts = number sorts
5394N/A predDecls = map (\ (s, i) -> (rvar i, binPred s)) indexedSorts
5395N/A binPred s = let s' = transSort s in mkCurryFunType [s', s'] boolType
5394N/A -- premises: all relations are bisimulations
5394N/A prems = conjs (map prem indexedSorts)
5394N/A {- generate premise for s, where s is the i-th sort
5394N/A if all sel_j(x) R_j sel_j(y), where sel_j ranges over the selectors for s
5947N/A here, R_i is the relation for the result type of sel_j, or the equality
5394N/A let -- get all selectors with first argument sort s
5394N/A sels = filter isSelForS ops
5394N/A isSelForS (Qual_op_name _ t _) = case args_OP_TYPE t of
5394N/A premSel opsymb@(Qual_op_name _n t _) =
5394N/A let -- get extra parameters of the selectors
5394N/A args = tail $ args_OP_TYPE t
5394N/A -- variables for the extra parameters
5394N/A varDecls = map (\ (a, j) -> (xvar j, transSort a))
5394N/A topC = con (transOpSymb sign tyToks opsymb)
5394N/A -- applied to x and extra parameter vars
5394N/A rhs = appFold (termAppl topC $ mkFree "x")
5394N/A $ map (mkFree . xvar . snd) indicesArgs
5394N/A -- applied to y and extra parameter vars
5457N/A lhs = appFold (termAppl topC $ mkFree "y")
5394N/A $ map (mkFree . xvar . snd) indicesArgs
5394N/A chi = -- is the result of selector non-observable?
5423N/A -- then apply corresponding relation
5947N/A then termAppl (termAppl (mkFree $
5947N/A $ lookup res indexedSorts )
5947N/A in foldr (quantifyIsa "All") chi varDecls
5947N/A prem1 = conjs (map premSel sels)
5947N/A concl1 = termAppl (termAppl (mkFree $ rvar i) $ mkFree "x")
5443N/A psi = concl1 `binImpl` prem1
5423N/A in foldr (quantifyIsa "All") psi [("x", typS), ("y", typS)]
5454N/A -- conclusion: all relations are the equality
5423N/A concls = conjs (map concl indexedSorts)
5423N/A concl (_, i) = binImpl (termAppl (termAppl (mkFree $ rvar i) $ mkFree "u")
5454N/A $ binEq (mkFree "u") $ mkFree "v"
5454N/AformTrCoCASL _sign _ (BoxOrDiamond _ _mod _phi _) =