StatAna.hs revision 98890889ffb2e8f6f722b00e265a211f13b5a861
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederModule : $Header$
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian MaederDescription : static analysis for CoCASL
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) Till Mossakowski, Uni Bremen 2004-2005
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill MossakowskiMaintainer : hausmann@informatik.uni-bremen.de
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederStability : provisional
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederPortability : portable
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maederstatic analysis for CoCASL
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport qualified Data.Set as Set
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederimport qualified Common.Lib.Rel as Rel
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maederimport Data.List (partition)
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maedertype CSign = Sign C_FORMULA CoCASLSign
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederinstance FreeVars C_FORMULA where
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder freeVarsOfExt sign cf = case cf of
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder BoxOrDiamond _ _ f _ -> freeVars sign f
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederbasicCoCASLAnalysis
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maeder :: (BASIC_SPEC C_BASIC_ITEM C_SIG_ITEM C_FORMULA,
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder Sign C_FORMULA CoCASLSign, GlobalAnnos)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder -> Result (BASIC_SPEC C_BASIC_ITEM C_SIG_ITEM C_FORMULA,
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder ExtSign (Sign C_FORMULA CoCASLSign) Symbol,
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maeder [Named (FORMULA C_FORMULA)])
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederbasicCoCASLAnalysis =
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder basicAnalysis minExpForm ana_C_BASIC_ITEM ana_C_SIG_ITEM ana_CMix
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maederana_CMix :: Mix C_BASIC_ITEM C_SIG_ITEM C_FORMULA CoCASLSign
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederana_CMix = emptyMix
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder { getBaseIds = ids_C_BASIC_ITEM
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , getSigIds = ids_C_SIG_ITEM
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maeder , getExtIds = \ e -> let c = constructors e in
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder mkIdSets (opMapConsts c) (nonConsts c) Set.empty
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , putParen = mapC_FORMULA
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , mixResolve = resolveC_FORMULA
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_C_BASIC_ITEM :: C_BASIC_ITEM -> IdSets
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_C_BASIC_ITEM ci = case ci of
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder CoFree_datatype al _ ->
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder (unite2 $ map (ids_CODATATYPE_DECL . item) al, Set.empty)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder CoSort_gen al _ -> unite $ map (ids_SIG_ITEMS ids_C_SIG_ITEM . item) al
10a92a06296c3c8d522543de7e3a4534bf528505Paolo Torriniids_C_SIG_ITEM :: C_SIG_ITEM -> IdSets
10a92a06296c3c8d522543de7e3a4534bf528505Paolo Torriniids_C_SIG_ITEM (CoDatatype_items al _) =
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder (unite2 $ map (ids_CODATATYPE_DECL . item) al, Set.empty)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_CODATATYPE_DECL :: CODATATYPE_DECL -> (Set.Set Id, Set.Set Id)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_CODATATYPE_DECL (CoDatatype_decl _ al _) =
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder unite2 $ map (ids_COALTERNATIVE . item) al
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_COALTERNATIVE :: COALTERNATIVE -> (Set.Set Id, Set.Set Id)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_COALTERNATIVE a = let e = Set.empty in case a of
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder Co_construct _ mi cs _ -> let s = maybe Set.empty Set.singleton mi in
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder if null cs then (s, e) else
eaa2614d79ad5ef6a6b9b08c7e6dde46c5ad1fb3Till Mossakowski (e, Set.unions $ s : map ids_COCOMPONENTS cs)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder CoSubsorts _ _ -> (e, e)
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_COCOMPONENTS :: COCOMPONENTS -> Set.Set Id
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederids_COCOMPONENTS (CoSelect l _ _) = Set.unions $ map Set.singleton l
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maederdata CoRecord a b c d = CoRecord
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder { foldBoxOrDiamond :: C_FORMULA -> Bool -> d -> a -> Range -> c
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , foldCoSort_gen_ax :: C_FORMULA -> [SORT] -> [OP_SYMB] -> Bool -> c
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , foldTerm_mod :: MODALITY -> b -> d
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder , foldSimple_mod :: MODALITY -> SIMPLE_ID -> d
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederfoldC_Formula :: Record C_FORMULA a b -> CoRecord a b c d -> C_FORMULA -> c
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederfoldC_Formula r cr c = case c of
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maeder BoxOrDiamond b m f ps ->
13ed13e06a5dd4aad12044ed7e7503cbe7f62990Christian Maeder foldBoxOrDiamond cr c b (foldModality r cr m) (foldFormula r f) ps
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder CoSort_gen_ax s o b -> foldCoSort_gen_ax cr c s o b
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederfoldModality :: Record C_FORMULA a b -> CoRecord a b c d -> MODALITY -> d
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian MaederfoldModality r cr m = case m of
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder Term_mod t -> foldTerm_mod cr m $ foldTerm r t
d5ef5a29a89fa5548f81fcd49fcf0ffda69d45b0Christian Maeder Simple_mod i -> foldSimple_mod cr m i
if Set.member srt ops
if Set.member (simpleIdToId tm) ops
let totalSels = Set.unions $ map snd constr
showDoc (Set.toList totalSels)
-> State CSign (Maybe (Component, Set.Set Component))
return $ Just (Component i' ty, Set.fromList ts)
let sortList = Set.toList sorts
(toOP_TYPE $ compType c) $ posOfId ide) $ Set.toList ops
(Op_type Total [s] t p) p) $ Rel.toList rel
Set.unions (map (getOps . item) al))
rel = foldr (\ (t, a) r -> foldr (`Rel.insert` t) r $ getCoSubsorts a)
Rel.empty subs