Sign.hs revision ace03c3051e5c5144e43ae78cae73f6a29dde6d5
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaModule : $Header$
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaDescription : CASL signatures and local environments for basic analysis
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaCopyright : (c) Christian Maeder and Uni Bremen 2002-2006
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaMaintainer : Christian.Maeder@dfki.de
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaStability : provisional
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaPortability : portable
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaCASL signatures also serve as local environments for the basic static analysis
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport qualified Data.Map as Map
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport qualified Data.Set as Set
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport qualified Common.Lib.Rel as Rel
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaimport qualified Common.Lib.State as State
d117004902c767d46430848b6ef1c11c3ad82835Pavel Březinaimport Data.List (isPrefixOf)
2a25713afc6beefb11a799903a43f695c5d7a4f9Adam Tkacimport Control.Monad (when, unless)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina-- constants have empty argument lists
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinadata OpType = OpType {opKind :: OpKind, opArgs :: [SORT], opRes :: SORT}
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina deriving (Show, Eq, Ord)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinadata PredType = PredType {predArgs :: [SORT]} deriving (Show, Eq, Ord)
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorcedata SymbType = SortAsItemType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina | OtherTypeKind String
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina | OpAsItemType OpType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina -- since symbols do not speak about totality, the totality
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina -- information in OpType has to be ignored
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina | PredAsItemType PredType
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce deriving (Show, Eq, Ord)
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorcedata Symbol = Symbol {symName :: Id, symbType :: SymbType}
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce deriving (Show, Eq, Ord)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance GetRange Symbol where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina getRange = getRange . symName
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai KondrashovidToSortSymbol :: Id -> Symbol
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaidToSortSymbol idt = Symbol idt SortAsItemType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaidToOpSymbol :: Id -> OpType -> Symbol
4f3a9d837a55b49448eca3c713c85a406207e523Simo SorceidToOpSymbol idt = Symbol idt . OpAsItemType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaidToPredSymbol :: Id -> PredType -> Symbol
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai KondrashovidToPredSymbol idt = Symbol idt . PredAsItemType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinadummy :: Sign f s -> a -> ()
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorcedummy _ _ = ()
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinadummyMin :: b -> c -> Result ()
4f3a9d837a55b49448eca3c713c85a406207e523Simo SorcedummyMin _ _ = return ()
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinatype CASLSign = Sign () ()
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina{- | the data type for the basic static analysis to accumulate variables,
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinasentences, symbols, diagnostics and annotations, that are removed or ignored
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinawhen looking at signatures from outside, i.e. during logic-independent
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinaprocessing. -}
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinadata Sign f e = Sign
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina { sortSet :: Set.Set SORT
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , emptySortSet :: Set.Set SORT
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina -- ^ a subset of the sort set of possibly empty sorts
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , sortRel :: Rel.Rel SORT
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , opMap :: OpMap
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , assocOps :: OpMap -- ^ the subset of associative operators
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , varMap :: Map.Map SIMPLE_ID SORT -- ^ temporary variables
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , sentences :: [Named (FORMULA f)] -- ^ current sentences
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina , declaredSymbols :: Set.Set Symbol -- ^ introduced or redeclared symbols
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov , envDiags :: [Diagnosis] -- ^ diagnostics for basic spec
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov , annoMap :: Map.Map Symbol (Set.Set Annotation) -- ^ annotated symbols
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina , globAnnos :: GlobalAnnos -- ^ global annotations to use
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina , extendedInfo :: e
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina } deriving Show
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina-- better ignore assoc flags for equality
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance Eq e => Eq (Sign f e) where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina a == b = compare a {extendedInfo = ()} b {extendedInfo = ()} == EQ
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina && extendedInfo a == extendedInfo b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance Ord e => Ord (Sign f e) where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina compare a b = compare
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina (sortSet a, emptySortSet a, sortRel a, opMap a, predMap a, extendedInfo a)
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina (sortSet b, emptySortSet b, sortRel b, opMap b, predMap b, extendedInfo b)
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaemptySign :: e -> Sign f e
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaemptySign e = Sign
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina , emptySortSet = Set.empty
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel Březina , sentences = []
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina , declaredSymbols = Set.empty
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel Březina , envDiags = []
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov , globAnnos = emptyGlobalAnnos
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov , extendedInfo = e }
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březinaclass SignExtension e where
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina isSubSignExtension :: e -> e -> Bool
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel Březina symOfExtension :: e -> Set.Set Symbol
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel Březina symOfExtension _ = Set.empty
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel Březinainstance SignExtension () where
55fdd0d28e7c88f333ad78183b0ba37a1da34160Pavel Březina isSubSignExtension _ _ = True
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov-- | proper subsorts (possibly excluding input sort)
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel BřezinasubsortsOf :: SORT -> Sign f e -> Set.Set SORT
c9aab1c04c399ca2d1abef74f6df22ced34983dcPavel BřezinasubsortsOf s e = Rel.predecessors (sortRel e) s
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina-- | proper supersorts (possibly excluding input sort)
7379170a0860790f2739e07fffe3d6ec85264566Pavel BřezinasupersortsOf :: SORT -> Sign f e -> Set.Set SORT
710472d946f6c337a095699dfd79134fa8b9eab9Pavel BřezinasupersortsOf s e = Rel.succs (sortRel e) s
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoOP_TYPE :: OpType -> OP_TYPE
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoOP_TYPE OpType { opArgs = args, opRes = res, opKind = k } =
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina Op_type k args res nullRange
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoPRED_TYPE :: PredType -> PRED_TYPE
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoPRED_TYPE PredType { predArgs = args } = Pred_type args nullRange
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoOpType :: OP_TYPE -> OpType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoOpType (Op_type k args r _) = OpType k args r
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoPredType :: PRED_TYPE -> PredType
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinatoPredType (Pred_type args _) = PredType args
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance Pretty OpType where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina pretty = pretty . toOP_TYPE
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance Pretty PredType where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina pretty = pretty . toPRED_TYPE
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březinainstance (Show f, Pretty e) => Pretty (Sign f e) where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina pretty = printSign pretty
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březinainstance Pretty Symbol where
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina pretty sy = let n = pretty (symName sy) in
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina case symbType sy of
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina SortAsItemType -> n
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina OtherTypeKind s -> text s <+> n
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov PredAsItemType pt -> let p = n <+> colon <+> pretty pt in
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina case predArgs pt of
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina [_] -> text predS <+> p
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina OpAsItemType ot -> let o = n <+> colon <> pretty ot in
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina case opArgs ot of
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina [] | opKind ot == Total -> text opS <+> o
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březinainstance Pretty SymbType where
76db25eab9010a33657f35e5afc8477c996df7a3Pavel Březina pretty st = case st of
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina OpAsItemType ot -> pretty ot
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina PredAsItemType pt -> space <> pretty pt
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinaprintSign :: (e -> Doc) -> Sign f e -> Doc
4f3a9d837a55b49448eca3c713c85a406207e523Simo SorceprintSign fE s = let
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce printRel (supersort, subsorts) =
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina ppWithCommas (Set.toList subsorts) <+> text lessS <+>
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina idDoc supersort
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina esorts = emptySortSet s
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina srel = sortRel s
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel Březina nsorts = Set.difference (sortSet s) esorts in
1509d1723d39124f840c214327e698aff3b3f683Pavel Březina (if Set.null nsorts then empty else text (sortS ++ sS) <+>
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov sepByCommas (map idDoc (Set.toList nsorts))) $+$
1509d1723d39124f840c214327e698aff3b3f683Pavel Březina (if Set.null esorts then empty else text (esortS ++ sS) <+>
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina sepByCommas (map idDoc (Set.toList esorts))) $+$
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina (if Rel.null srel then empty
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina else text (sortS ++ sS) <+>
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina fsep (punctuate semi $
41ef946f3f74a46b9e26118116e4811e259b30efPavel Březina map (fsep . punctuate (space <> equals) . map pretty)
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina (filter ((> 1) . length) $ map Set.toList cs)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov ++ map printRel (Map.toList
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina $ Rel.toMap $ Rel.transpose $ Rel.transReduce $ Rel.irreflex
41ef946f3f74a46b9e26118116e4811e259b30efPavel Březina $+$ printSetMap (text opS) empty (opMap s)
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce $+$ printSetMap (text predS) space (predMap s)
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce $+$ fE (extendedInfo s)
04b3ab7658985af749460010123bbe37eccf50edPavel Březina-- working with Sign
b510d909cbe8d8216b60ee070730dd5c41294303Pavel BřezinairreflexClosure :: Ord a => Rel.Rel a -> Rel.Rel a
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai KondrashovirreflexClosure = Rel.irreflex . Rel.transClosure
b510d909cbe8d8216b60ee070730dd5c41294303Pavel BřezinacloseSortRel :: Sign f e -> Sign f e
b510d909cbe8d8216b60ee070730dd5c41294303Pavel BřezinacloseSortRel s =
b510d909cbe8d8216b60ee070730dd5c41294303Pavel Březina s { sortRel = irreflexClosure $ sortRel s }
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai KondrashovdiffSig :: (e -> e -> e) -> Sign f e -> Sign f e -> Sign f e
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai KondrashovdiffSig dif a b = let s = sortSet a `Set.difference` sortSet b in
b510d909cbe8d8216b60ee070730dd5c41294303Pavel Březina closeSortRel a
b510d909cbe8d8216b60ee070730dd5c41294303Pavel Březina { sortSet = s
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov , emptySortSet = Set.difference s
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov $ nonEmptySortSet a `Set.difference` nonEmptySortSet b
04b3ab7658985af749460010123bbe37eccf50edPavel Březina , sortRel = Rel.difference (sortRel a) $ sortRel b
04b3ab7658985af749460010123bbe37eccf50edPavel Březina , opMap = opMap a `diffOpMapSet` opMap b
04b3ab7658985af749460010123bbe37eccf50edPavel Březina , assocOps = assocOps a `diffOpMapSet` assocOps b
04b3ab7658985af749460010123bbe37eccf50edPavel Březina , predMap = predMap a `diffMapSet` predMap b
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina , annoMap = annoMap a `diffMapSet` annoMap b
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce , extendedInfo = dif (extendedInfo a) $ extendedInfo b }
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina -- transClosure needed: {a < b < c} - {a < c; b}
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov -- is not transitive!
b0abb3bfdfd95951a23c9fc223c735805ffd2969Pavel BřezinadiffOpMapSet :: OpMap -> OpMap -> OpMap
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinadiffOpMapSet m = diffMapSet m . Map.map (rmOrAddParts False)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel BřezinadiffMapSet :: (Ord a, Ord b) => Map.Map a (Set.Set b)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina -> Map.Map a (Set.Set b) -> Map.Map a (Set.Set b)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina (\ s t -> let d = Set.difference s t in
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel Březina if Set.null d then Nothing else Just d)
15d41c8f28259061e39715acdbbbaea778b6ecc8Pavel BřezinaaddMapSet :: (Ord a, Ord b) => Map.Map a (Set.Set b) -> Map.Map a (Set.Set b)
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel BřezinamkPartial :: OpType -> OpType
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinamkPartial o = o { opKind = Partial }
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinamkTotal :: OpType -> OpType
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinamkTotal o = o { opKind = Total }
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel BřezinamakePartial :: Set.Set OpType -> Set.Set OpType
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinamakePartial = Set.mapMonotonic mkPartial
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina-- | remove (True) or add (False) partial op if it is included as total
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinarmOrAddParts :: Bool -> Set.Set OpType -> Set.Set OpType
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel BřezinarmOrAddParts b s =
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina let t = makePartial $ Set.filter ((== Total) . opKind) s
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel Březina in (if b then Set.difference else Set.union) s t
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinaaddOpMapSet :: OpMap -> OpMap -> OpMap
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel BřezinaaddOpMapSet m = Map.map (rmOrAddParts True) . addMapSet m
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinainterMapSet :: (Ord a, Ord b) => Map.Map a (Set.Set b) -> Map.Map a (Set.Set b)
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinainterMapSet m =
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina Map.filter (not . Set.null) . Map.intersectionWith Set.intersection m
d38ffc9c92daeb62de7d28c409bdaeff98f82775Pavel BřezinainterOpMapSet :: OpMap -> OpMap -> OpMap
b3ca35780617b2e5a7637f9888b089e8e26a4e8cPavel Březina (\ s t -> rmOrAddParts True $ Set.intersection (rmOrAddParts False s)
46d3d2c731e8c7e138462e5b60a39a279dc77d81Pavel Březina $ rmOrAddParts False t) m
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinauniteCASLSign :: Sign () () -> Sign () () -> Sign () ()
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinauniteCASLSign = addSig (\ _ _ -> ())
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinanonEmptySortSet :: Sign f e -> Set.Set Id
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinanonEmptySortSet s = Set.difference (sortSet s) $ emptySortSet s
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel BřezinaaddSig :: (e -> e -> e) -> Sign f e -> Sign f e -> Sign f e
76db25eab9010a33657f35e5afc8477c996df7a3Pavel BřezinaaddSig ad a b = let s = sortSet a `Set.union` sortSet b in
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina closeSortRel a
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel Březina { sortSet = s
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina , emptySortSet = Set.difference s
710472d946f6c337a095699dfd79134fa8b9eab9Pavel Březina $ nonEmptySortSet a `Set.union` nonEmptySortSet b
76db25eab9010a33657f35e5afc8477c996df7a3Pavel Březina , sortRel = Rel.union (sortRel a) $ sortRel b
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel Březina , opMap = addOpMapSet (opMap a) $ opMap b
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel Březina , assocOps = addOpMapSet (assocOps a) $ assocOps b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , predMap = addMapSet (predMap a) $ predMap b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , annoMap = addMapSet (annoMap a) $ annoMap b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , extendedInfo = ad (extendedInfo a) $ extendedInfo b }
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinainterRel :: Ord a => Rel.Rel a -> Rel.Rel a -> Rel.Rel a
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinainterSig :: (e -> e -> e) -> Sign f e -> Sign f e -> Sign f e
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel BřezinainterSig ef a b = let s = sortSet a `Set.intersection` sortSet b in
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina closeSortRel a
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina { sortSet = s
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , emptySortSet = Set.difference s
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina $ nonEmptySortSet a `Set.intersection` nonEmptySortSet b
c47e9d522f0d87259e5074ea643daaa3dfcb8d92Pavel Březina , sortRel = interRel (sortRel a) $ sortRel b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , opMap = interOpMapSet (opMap a) $ opMap b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , assocOps = interOpMapSet (assocOps a) $ assocOps b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , predMap = interMapSet (predMap a) $ predMap b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , annoMap = interMapSet (annoMap a) $ annoMap b
2827b0d03f7b6bafa504d22a5d7ca39cbda048b3Pavel Březina , extendedInfo = ef (extendedInfo a) $ extendedInfo b }
Set.null (sortSet s) &&
Rel.null (sortRel s) &&
Map.null (opMap s) &&
Map.null (predMap s) && ie (extendedInfo s)
isSubOpMap = Map.isSubmapOfBy $ \ s t ->
Partial -> Set.member (mkTotal e) t
isSubSig isSubExt a b = Set.isSubsetOf (sortSet a) (sortSet b)
&& Rel.isSubrelOf (sortRel a) (sortRel b)
addDiags :: [Diagnosis] -> State.State (Sign f e) ()
e <- State.get
State.put e { envDiags = reverse ds ++ envDiags e }
addAnnoSet :: Annoted a -> Symbol -> State.State (Sign f e) ()
unless (Set.null v) $ do
e <- State.get
addSymbol :: Symbol -> State.State (Sign f e) ()
e <- State.get
addSort :: SortsKind -> Annoted a -> SORT -> State.State (Sign f e) ()
e <- State.get
known = Set.member s m
NonEmptySorts -> when (Set.member s em) $ do
e2 <- State.get
e2 <- State.get
| not $ Set.member s $ sortSet e ]
checkSorts :: [SORT] -> State.State (Sign f e) ()
e <- State.get
addSubsort :: SORT -> SORT -> State.State (Sign f e) ()
addSubsortOrIso :: Bool -> SORT -> SORT -> State.State (Sign f e) ()
e <- State.get
$ Rel.insert sub super r }
if Rel.path super sub r then
if Rel.path sub super r
else when (Rel.path sub super r)
else if Rel.path super sub r then
if Rel.path sub super r
else when (Rel.path sub super r)
closeSubsortRel :: State.State (Sign f e) ()
do e <- State.get
checkWithOtherMap :: String -> String -> Map.Map Id a -> Id -> [Diagnosis]
case Map.lookup i m of
addVars :: VAR_DECL -> State.State (Sign f e) ()
addVar :: SORT -> SIMPLE_ID -> State.State (Sign f e) ()
do e <- State.get
ds = case Map.lookup v m of