Prop2CASLHelpers.hs revision 94e112d16f89130a688db8b03ad3224903f5e97e
{- |
Module : $Header$
Description : Helper functions for Prop2CASL
Copyright : (c) Dominik Luecke and Uni Bremen 2007
License : GPLv2 or higher, see LICENSE.txt
Maintainer : luecke@informatik.uni-bremen.de
Stability : experimental
Portability : portable (imports Logic.Logic)
The helpers for translating comorphism from Propositional to CASL.
-}
where
import qualified Data.Set as Set
import qualified Data.Map as Map
import qualified Common.AS_Annotation as AS_Anno
import qualified Common.Id as Id
import qualified Common.Result as Result
import qualified Common.Lib.MapSet as MapSet
-- Propositional
import qualified Propositional.AS_BASIC_Propositional as PBasic
import qualified Propositional.Sublogic as PSL
import qualified Propositional.Sign as PSign
import qualified Propositional.Morphism as PMor
import qualified Propositional.Symbol as PSymbol
-- CASL
import qualified CASL.AS_Basic_CASL as CBasic
import qualified CASL.Sublogic as CSL
import qualified CASL.Sign as CSign
import qualified CASL.Morphism as CMor
-- | Translation of the signature
mapSig :: PSign.Sign -> CSign.CASLSign
mapSig sign = (CSign.emptySign ())
MapSet.empty $ PSign.items sign }
-- | Which is the target sublogic?
mapSub :: PSL.PropSL -> CSL.CASL_Sublogics
mapSub sl = CSL.bottom
, CSL.has_pred = True
, CSL.has_eq = False
-- | Translation of morphisms
mapMor mor = Result.Result [] $ Just (CMor.embedMorphism ()
(mapSig $ PMor.source mor) $ mapSig $ PMor.target mor)
{ CMor.pred_map = trMor $ PMor.propMap mor }
-- | Mapping of a theory
mapTheory (sig, form) = Result.Result [] $
Just (mapSig sig, map trNamedForm form)
-- | Translation of symbols
mapSym sym = Set.singleton $
-- | Translation of sentence
mapSentence _ form = Result.Result [] $ Just $ trForm form
{- -----------------------------------------------------------------------------
Helpers --
----------------------------------------------------------------------------- -}
-- | Helper for map theory
trNamedForm = AS_Anno.mapNamed trForm
-- | Helper for map sentence and map theory
trForm :: PBasic.FORMULA -> CBasic.CASLFORMULA
trForm form =
case form of
PBasic.Negation fn rn -> CBasic.Negation (trForm fn) rn
PBasic.Conjunction fn rn ->
CBasic.Junction CBasic.Con (map trForm fn) rn
PBasic.Disjunction fn rn ->
CBasic.Junction CBasic.Dis (map trForm fn) rn
PBasic.Implication f1 f2 rn ->
CBasic.Relation (trForm f1) CBasic.Implication (trForm f2) rn
PBasic.Equivalence f1 f2 rn ->
CBasic.Relation (trForm f1) CBasic.Equivalence (trForm f2) rn
PBasic.True_atom rn -> CBasic.Atom True rn
PBasic.False_atom rn -> CBasic.Atom False rn
(CBasic.mkQualPred (Id.simpleIdToId pid)
)
[]
-- | Helper for map mor
trMor mp =
let
pt = CSign.PredType {CSign.predArgs = []}
in
(\ k a ->
Map.insert (k, pt) a
)
mp