Hybrid2CASL.hs revision db9680b2bbd9d091b198eaa4e324762921965fb3
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringModule : $Header$
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringCopyright : nevrenato@gmail.com
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringLicense : GPLv2 or higher, see LICENSE.txt
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringMaintainer : Christian.Maeder@dfki.de
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringStability : experimental
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringPortability : non-portable (imports Logic.Logic)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringComorphism HybridCASL to CASL.
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering ( Hybrid2CASL (..)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringimport qualified Common.Lib.Rel as Rel
4aa4d2ae9717d0f8656528a3197bbc0c256380b1Zbigniew Jędrzejewski-Szmekimport qualified Common.Lib.MapSet as MapSet
4aa4d2ae9717d0f8656528a3197bbc0c256380b1Zbigniew Jędrzejewski-Szmekimport qualified Data.Set as Set
4aa4d2ae9717d0f8656528a3197bbc0c256380b1Zbigniew Jędrzejewski-Szmekimport qualified Data.Map as Map
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringdata Hybrid2CASL = Hybrid2CASL deriving Show
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- Just to make things easier to understand
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringtype HForm = HybridFORMULA
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringtype CForm = CASLFORMULA
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringtype CSign = CASLSign
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poetteringinstance Language Hybrid2CASL where
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering language_name Hybrid2CASL = "Hybrid2CASL"
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poetteringinstance Comorphism Hybrid2CASL
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering H_BASIC_SPEC HForm SYMB_ITEMS SYMB_MAP_ITEMS
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering Symbol RawSymbol ()
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering CASL_Sublogics
ecabcf8b6edcc856ec2fd5bd43fc675a8fe04731Lennart Poettering CASLBasicSpec CForm SYMB_ITEMS SYMB_MAP_ITEMS
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek Symbol RawSymbol ProofTree where
ecabcf8b6edcc856ec2fd5bd43fc675a8fe04731Lennart Poettering sourceLogic Hybrid2CASL = Hybrid
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek sourceSublogic Hybrid2CASL = ()
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering targetLogic Hybrid2CASL = CASL
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poettering mapSublogic Hybrid2CASL _ = Just SL.caslTop
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poettering { SL.cons_features = SL.emptyMapConsFeature
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering map_theory Hybrid2CASL = transTheory
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering has_model_expansion Hybrid2CASL = True
4aa4d2ae9717d0f8656528a3197bbc0c256380b1Zbigniew Jędrzejewski-Szmek is_weakly_amalgamable Hybrid2CASL = True
4aa4d2ae9717d0f8656528a3197bbc0c256380b1Zbigniew Jędrzejewski-Szmek is_model_transportable Hybrid2CASL = True
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poettering isInclusionComorphism Hybrid2CASL = True
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poettering-- Translates the given theory in an HybridCASL form to an equivalent
755bde375f4db393ad06e73340bfcf4d0cf91bb2Lennart Poettering-- theory in CASL form
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- Question : Why some sentences are in the sig and other sentences are
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- in the 2nd argument ? (this is scary)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- fs'' is needed for special sentences, refering about datatypes
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- for which hybridization has nothing to do
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringtransTheory :: (HSign, [Named HForm]) -> Result (CSign, [Named CForm])
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringtransTheory (s,fs) = let
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek newSig = transSig s
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering fs' = fmap (mapNamed trans) fs
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering fs'' = dataTrans (fs ++ sentences s)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering newSens = fs' ++ sentences newSig ++ fs''
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering rigidP = applRig (rigidPreds $ extendedInfo s) "RigidPred" gnPCons
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering rigidO = applRig (rigidOps $ extendedInfo s) "RigidOp" gnOCons
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering in return (newSig,rigidP ++ rigidO ++ newSens)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering-- Special formulas not covered by normal hybridization
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringdataTrans :: [Named HForm] -> [Named CForm]
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart PoetteringdataTrans = foldr f []
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek f a b = if sentence x == (Nothing :: Maybe HForm) then b
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt else mapNamed (\(Just x') -> x') x : b
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek x = mapNamed f' a
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering f' h = case h of
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-Szmek (Sort_gen_ax a' b') -> Just $ Sort_gen_ax a' b'
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-SzmektransSig :: HSign -> CSign
7dbb1d08f66cd44b1296be3ee8e3629b989e19a8Zbigniew Jędrzejewski-SzmektransSig hs = let workflow = (transSens hs) . (addWrldArg hs)
8ea48dfcd33e8db0c01bf8c57c3bbcfdc3c86d4bLennart Poettering workflow' = (addRels hs) . (addWorlds hs)
{ sortRel = Rel.insertKey worldSort $ sortRel hs
kl = Map.keys $ nomies s
ins = foldr (\k m -> MapSet.insert k getWorld m) (opMap cs) il
kl = Map.keys $ modies s
ins = foldl (\m k -> MapSet.insert k accRelT m) (predMap cs) il
mods = Map.elems (modies $ extendedInfo hs)
noms = Map.elems (nomies $ extendedInfo hs)
_ -> error "Hybrid2CASL.trForm"
_ -> error "Hybrid2CASL.trTerm"
applRig :: (Ord k) => MapSet.MapSet k a ->
MapSet.MapSet k a ->
where g k = glueDe k (MapSet.lookup k m) f
glueDe :: k -> Set.Set a -> (k -> a -> CForm) -> [CForm]
glueDe n s f = foldr (\a b -> (f n) a : b) [] $ Set.elems s
-- proper variables/terms for the quantifiers,predications and operations.