Utils.hs revision 8abc7a96c009dd638d17f6eb07e18a0fd4403474
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenModule : $Header$
fd9abdda70912b99b24e3bf1a38f26fde908a74cndDescription : Utilities for CASL and its comorphisms
fd9abdda70912b99b24e3bf1a38f26fde908a74cndCopyright : (c) Klaus Luettich and Uni Bremen 2002-2004
fd9abdda70912b99b24e3bf1a38f26fde908a74cndLicense : GPLv2 or higher, see LICENSE.txt
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenMaintainer : Christian.Maeder@dfki.de
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenStability : provisional
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenPortability : portable
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenUtilities for CASL and its comorphisms
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenimport qualified Data.Set as Set
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenimport qualified Data.Map as Map
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenimport CASL.Sign (mkVarTerm)
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenreplacePropPredication replaces a propositional predication of a
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowengiven symbol with an also given formula. Optionally a given variable
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenis replaced in the predication of another predicate symbol with a
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowengiven term, the variable must occur in the first argument position
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenof the predication. -}
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenreplacePropPredication :: Maybe (PRED_NAME, VAR, TERM ())
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen {- ^ Just (pSymb,x,t) replace x
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen with t in Predication of pSymb -}
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen -> PRED_NAME -- ^ propositional symbol to replace
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen -> FORMULA () -- ^ Formula to insert
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen -> FORMULA () -- ^ Formula with placeholder
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen -> FORMULA ()
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowenreplacePropPredication mTerm pSymb frmIns =
205f749042ed530040a4f0080dbcb47ceae8a374rjung foldFormula (mapRecord $ const ())
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen { foldPredication = \ orig _ ts _ ->
0d0ba3a410038e179b695446bb149cce6264e0abnd let Predication qpn _ ps = orig
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd (pSymbT, var, term) = fromJust mTerm
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd in case qpn of
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd Qual_pred_name symb (Pred_type s _) _
a9d50067373f032c3c9678ad55de69bb3f9fcb70rbowen | symb == pSymb && null ts && null s -> frmIns
type FreshVARMap f = Map.Map VAR (TERM f)
Map.fromList (concat (zipWith toTups vDecls fVDecls))
else error "CASL.Utils.buildVMap"
. Map.lookup v
deleteVMap vDecls m = foldr Map.delete m
let v' = fromJust (find (not . flip Set.member aSet)
in (Set.insert v' aSet, v')
(vSet', vDecl') = freshVars Set.empty vDecl
_ -> error "codeOutCondRecord.foldExistl_equation"
_ -> error "codeOutCondRecord.foldStrong_equation"
_ -> error "codeOutCondRecord.foldMembership"
_ -> error "codeOutCondRecord.foldDefinedness"
codeOutCondPredication _ = error "CASL.Utils: Predication expected"
constructExpansion _ _ = error "CASL.Utils: Conditional expected"
'codeOutConditionalF' implemented via 'CASL.Fold.foldFormula'
eqSubstRecord :: Set.Set PRED_SYMB -- ^ equivalent predicates
if Set.member psymb eqPredSet
substEqPreds :: Set.Set PRED_SYMB -> (f -> f) -> FORMULA f -> FORMULA f