50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlDescription : static analysis of DL parts
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlCopyright : (c) Klaus Luettich, Uni Bremen 2005
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlLicense : GPLv2 or higher, see LICENSE.txt
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlMaintainer : luecke@informatik.uni-bremen.de
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlStability : provisional
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlPortability : portable
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlstatic analysis of DL parts especially cardinalities, predefined datatypes
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichland additional annottations
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlmodule CASL_DL.StatAna ( basicCASL_DLAnalysis
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl , checkSymbolMapDL
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl , DLSign) where
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlimport qualified Common.Lib.MapSet as MapSet
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlimport qualified Common.Lib.Rel as Rel
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlimport qualified Data.Map as Map
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlimport qualified Data.Set as Set
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichlinstance TermExtension DL_FORMULA where
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl freeVarsOfExt sign (Cardinality _ _ t1 t2 mf _) =
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl Set.union (freeTermVars sign t1) $ Set.union (freeTermVars sign t2)
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl $ case mf of
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl Just f -> freeVars sign f
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlbasicCASL_DLAnalysis
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl :: (BASIC_SPEC () () DL_FORMULA, Sign DL_FORMULA CASL_DLSign, GlobalAnnos)
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl -> Result (BASIC_SPEC () () DL_FORMULA,
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl ExtSign (Sign DL_FORMULA CASL_DLSign) Symbol,
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl [Named (FORMULA DL_FORMULA)])
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlbasicCASL_DLAnalysis (bs, sig, ga) =
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl do ga' <- mergeGlobalAnnos ga $ globAnnos predefSign
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl let sig' = addSig addCASL_DLSign sig $ predefinedSign emptyCASL_DLSign
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl bs' = transformSortDeclarations True bs
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl case basicAnalysis minDLForm (const return)
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl (const return) ana_Mix (bs', sig', ga') of
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl r@(Result ds1 mr) ->
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl maybe r (cleanStatAnaResult . postAna ds1 sig') mr
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl True -> extend all sort declarations without a supersort
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl with supersort Thing
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel Reichl False -> remove Thing from all sort declarations with supersort Thing
50b8a36b0932a510e825ed1ad8103f81ead2b7d8Pavel ReichlgenerateSubsorting :: Sign f e -> Sign f e
statAnaMarker = Range [SourcePos ">:>added for DL.StaticAna<:<" 0 0]
Set.delete (idToSortSymbol thing) sys
chkSorts = Set.fold chSort [] (sortSet diff_sig) ++
| Set.member dataS (supersortsOf thing acc_sig) ||
Set.member dataS (subsortsOf thing acc_sig) ||
| not $ Set.member thing $ supersortsOf s acc_sig]
| Set.member thing (subsortsOf s acc_sig)]
Set.insert dataS
checkPreds = MapSet.foldWithKey chPred [] (predMap diff_sig)
checkOps = MapSet.foldWithKey chOp [] (opMap diff_sig)
Set.member thing (supersortsOf s acc_sig)
pn_RelTypes = Set.filter isBinPredType
$ MapSet.lookup pn (predMap sign)
if Set.null pn_RelTypes then
[] -> error "CASL_DL.StatAna: Internal error"
) (Result [] Nothing) $ Set.toList typeSet
use from Logic.Logic.Logic and from CASL:
syms = Map.foldWithKey checkSourceSymbol [] rsm