0N/ACopyright : (c) Christian Maeder, Uni Bremen 2004-2005
0N/ALicense : GPLv2 or higher
0N/AMaintainer : luecke@informatik.uni-bremen.de
0N/AStability : provisional
0N/APortability : portable
0N/Astatic analysis of modal logic parts
0N/Ainstance FreeVars M_FORMULA where
0N/A freeVarsOfExt sign (BoxOrDiamond _ _ f _) = freeVars sign f
644N/A :: (BASIC_SPEC M_BASIC_ITEM M_SIG_ITEM M_FORMULA,
0N/A Sign M_FORMULA ModalSign, GlobalAnnos)
1104N/A -> Result (BASIC_SPEC M_BASIC_ITEM M_SIG_ITEM M_FORMULA,
0N/A ExtSign (Sign M_FORMULA ModalSign) Symbol,
0N/A [Named (FORMULA M_FORMULA)])
0N/A basicAnalysis minExpForm ana_M_BASIC_ITEM ana_M_SIG_ITEM ana_Mix
0N/Aana_Mix :: Mix M_BASIC_ITEM M_SIG_ITEM M_FORMULA ModalSign
0N/A { getSigIds = ids_M_SIG_ITEM
0N/A , putParen = mapM_FORMULA
0N/A , mixResolve = resolveM_FORMULA
0N/A-- rigid ops will also be part of the CASL signature
0N/Aids_M_SIG_ITEM :: M_SIG_ITEM -> IdSets
(unite2 $ map (ids_OP_ITEM . item) al, e)
Rigid_pred_items _ al _ ->
((e, e),
Set.unions $ map (ids_PRED_ITEM . item) al)
mapMODALITY :: MODALITY -> MODALITY
mapMODALITY m = case m of
Term_mod t -> Term_mod $ mapTerm mapM_FORMULA t
mapM_FORMULA :: M_FORMULA -> M_FORMULA
mapM_FORMULA (BoxOrDiamond b m f ps) =
BoxOrDiamond b (mapMODALITY m) (mapFormula mapM_FORMULA f) ps
resolveMODALITY :: MixResolve MODALITY
resolveMODALITY ga ids m = case m of
Term_mod t -> fmap Term_mod $ resolveMixTrm mapM_FORMULA
resolveM_FORMULA ga ids t
resolveM_FORMULA :: MixResolve M_FORMULA
resolveM_FORMULA ga ids cf = case cf of
BoxOrDiamond b m f ps -> do
nm <- resolveMODALITY ga ids m
nf <- resolveMixFrm mapM_FORMULA resolveM_FORMULA ga ids f
return $ BoxOrDiamond b nm nf ps
minExpForm :: Min M_FORMULA ModalSign
let minMod md ps = case md of
Simple_mod i -> minMod (Term_mod (Mixfix_token i)) ps
t2 <- oneExpTerm minExpForm s t
else Result [mkDiag Error
("unknown term modality sort '"
++ showId srt "' for term") t ]
then return $ Simple_mod tm
[mkDiag Error "unknown modality" tm]
Application (Op_name (Id [tm] [] _)) [] _ ->
then return $ Simple_mod tm
f2 <- minExpFORMULA minExpForm s f
return $ BoxOrDiamond b nm f2 ps
ana_M_SIG_ITEM :: Ana M_SIG_ITEM M_BASIC_ITEM M_SIG_ITEM M_FORMULA ModalSign
Rigid_op_items r al ps ->
do ul <- mapM (ana_OP_ITEM minExpForm mix) al
Rigid -> mapM_ (\ aoi -> case item aoi of
mapM_ (updateExtInfo . addRigidOp (toOpType ty)) ops
updateExtInfo $ addRigidOp (toOpType $ headToType par)
return $ Rigid_op_items r ul ps
Rigid_pred_items r al ps ->
do ul <- mapM (ana_PRED_ITEM minExpForm mix) al
Rigid -> mapM_ (\ aoi -> case item aoi of
mapM_ (updateExtInfo . addRigidPred (toPredType ty)) ops
Pred_defn i (Pred_head args _) _ _ ->
updateExtInfo $ addRigidPred
(PredType $ sortsOfArgs args) i ) ul
return $ Rigid_pred_items r ul ps
addRigidOp :: OpType -> Id -> ModalSign -> Result ModalSign
addRigidOp ty i m = return
m { rigidOps = addOpTo i ty $ rigidOps m }
addRigidPred :: PredType -> Id -> ModalSign -> Result ModalSign
addRigidPred ty i m = return
m { rigidPreds = let rps = rigidPreds m in
Map.insert i
:: Ana M_BASIC_ITEM M_BASIC_ITEM M_SIG_ITEM M_FORMULA ModalSign
ana_M_BASIC_ITEM mix bi = case bi of
Simple_mod_decl al fs ps -> do
mapM_ ((updateExtInfo . preAddModId) . item) al
newFs <- mapAnM (ana_FORMULA mix) fs
resFs <- mapAnM (return . fst) newFs
anaFs <- mapAnM (return . snd) newFs
mapM_ ((updateExtInfo . addModId anaFs) . item) al
return $ Simple_mod_decl al resFs ps
Term_mod_decl al fs ps -> do
mapM_ ((updateExtInfo . preAddModSort e) . item) al
newFs <- mapAnM (ana_FORMULA mix) fs
resFs <- mapAnM (return . fst) newFs
anaFs <- mapAnM (return . snd) newFs
mapM_ ((updateExtInfo . addModSort anaFs) . item) al
return $ Term_mod_decl al resFs ps
preAddModId :: SIMPLE_ID -> ModalSign -> Result ModalSign
Result [mkDiag Hint "repeated modality" i] $ Just m
addModId :: [AnModFORM] -> SIMPLE_ID -> ModalSign -> Result ModalSign
addModId frms i m = return m
preAddModSort :: Sign M_FORMULA ModalSign -> SORT -> ModalSign
Result (mkDiag Hint "repeated term modality" i : ds) $ Just m
addModSort :: [AnModFORM] -> SORT -> ModalSign -> Result ModalSign
addModSort frms i m = return m
ana_FORMULA :: Mix M_BASIC_ITEM M_SIG_ITEM M_FORMULA ModalSign
-> FORMULA M_FORMULA -> State (Sign M_FORMULA ModalSign)
(FORMULA M_FORMULA, FORMULA M_FORMULA)
let ps = map (mkId . (: [])) $
Set.toList $ getFormPredToks f
mapM_ (addPred (emptyAnno ()) $ PredType []) ps
let Result es m = resolveFormula mapM_FORMULA
resolveM_FORMULA newGa (mixRules mix) f
n <- resultToState (minExpFORMULA minExpForm e) r
getFormPredToks :: FORMULA M_FORMULA ->
Set.Set Token
getFormPredToks frm = case frm of
Quantification _ _ f _ -> getFormPredToks f
Conjunction fs _ ->
Set.unions $ map getFormPredToks fs
Disjunction fs _ ->
Set.unions $ map getFormPredToks fs
Set.union (getFormPredToks f1) $ getFormPredToks f2
Set.union (getFormPredToks f1) $ getFormPredToks f2
Negation f _ -> getFormPredToks f
Mixfix_formula t -> getTermPredToks t
ExtFORMULA (BoxOrDiamond _ _ f _) -> getFormPredToks f
Predication _ ts _ ->
Set.unions $ map getTermPredToks ts
Definedness t _ -> getTermPredToks t
Existl_equation t1 t2 _ ->
Set.union (getTermPredToks t1) $ getTermPredToks t2
Strong_equation t1 t2 _ ->
Set.union (getTermPredToks t1) $ getTermPredToks t2
Membership t _ _ -> getTermPredToks t
getTermPredToks :: TERM M_FORMULA ->
Set.Set Token
getTermPredToks trm = case trm of
Application _ ts _ ->
Set.unions $ map getTermPredToks ts
Sorted_term t _ _ -> getTermPredToks t
Cast t _ _ -> getTermPredToks t
Conditional t1 f t2 _ ->
Set.union (getTermPredToks t1) $
Set.union (getFormPredToks f) $ getTermPredToks t2
Mixfix_term ts ->
Set.unions $ map getTermPredToks ts
Mixfix_parenthesized ts _ ->
Set.unions $ map getTermPredToks ts
Mixfix_bracketed ts _ ->
Set.unions $ map getTermPredToks ts
Mixfix_braced ts _ ->
Set.unions $ map getTermPredToks ts