Changeset 12726
- Timestamp:
- 26.10.2009 16:00:16 (4 weeks ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
CASL/ColimSign.hs (modified) (3 diffs)
-
Common/SetColimit.hs (modified) (3 diffs)
-
Propositional/Analysis.hs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CASL/ColimSign.hs
r12314 r12726 15 15 -} 16 16 17 module CASL.ColimSign(signColimit, extCASLColimit , renameSorts) where17 module CASL.ColimSign(signColimit, extCASLColimit) where 18 18 19 19 import CASL.Sign … … 57 57 sortGraph = emap getSortMap $ nmap sortSet graph 58 58 (setSort0, funSort0) = computeColimitSet sortGraph 59 (setSort, funSort) = renameSorts (setSort0, funSort0)59 (setSort, funSort) = addIntToSymbols (setSort0, funSort0) 60 60 sigmaSort = (emptySign $ error "err"){sortSet=setSort} 61 61 phiSort = Map.fromList … … 80 80 phiAssoc 81 81 in (sigmaExt, phiExt) 82 83 -- method for adding the number as suffix of the id it pairs84 addSuffixToId :: (Id, Node) -> Id85 addSuffixToId (idN, n) = appendNumber idN n86 87 --method for applying the renaming to the colimit of sorts88 renameSorts :: (Set.Set (Id, Node), Map.Map Node (Map.Map Id (Id, Node))) ->89 (Set.Set Id, Map.Map Node (EndoMap Id))90 renameSorts (set, fun) = let91 fstEqual (x1,_) (x2,_) = x1 == x292 partList pairSet = leqClasses fstEqual pairSet93 namePartitions elemList f0 s1 f1 = case elemList of94 [] -> (s1, f1)95 p:ps -> if length p == 1 then96 -- a single element with this name,it can be kept97 let s2 = Set.insert (fst $ head p) s198 updateF node = Map.union (Map.findWithDefault (error "f1") node f1) $99 Map.fromList $ map (\x -> (x, fst $ head p)) $100 filter (\x -> Map.findWithDefault (error "fo(node)") x101 (Map.findWithDefault (error "f0") node f0)102 == head p) $103 Map.keys $ Map.findWithDefault (error "f0")104 node f0105 f2 = Map.fromList $ zip (Map.keys f0) $ map updateF $ Map.keys f0106 in namePartitions ps f0 s2 f2107 else108 --several elements with same name, the number is added at the end109 let s2 = Set.union s1 $ Set.fromList $ map addSuffixToId p110 updateF node = Map.union (Map.findWithDefault (error "f1") node f1) $111 Map.fromList $112 map ( \x -> (x, addSuffixToId $113 Map.findWithDefault (error "addSuffixToId") x114 (Map.findWithDefault (error "f0") node f0))) $115 filter (\x -> (Map.findWithDefault (error "fo(node)") x116 (Map.findWithDefault (error "f0") node f0))117 `elem` p) $118 Map.keys $ Map.findWithDefault (error "f0") node f0119 f2 = Map.fromList $ zip (Map.keys f0) $ map updateF $ Map.keys f0120 in namePartitions ps f0 s2 f2121 in namePartitions (partList set) fun (Set.empty) $122 Map.fromList $ zip (Map.keys fun) (repeat Map.empty)123 82 124 83 -- computing subsorts in the colimit -
trunk/Common/SetColimit.hs
r11854 r12726 18 18 19 19 module Common.SetColimit( 20 computeColimitSet 20 computeColimitSet, 21 addIntToSymbols 21 22 ) 22 23 where … … 27 28 import qualified Data.Set as Set 28 29 import Data.List 30 import CASL.Overload(leqClasses) 31 import Common.Id 29 32 30 33 compose :: (Ord a) => Set.Set (a, Int) -> … … 102 105 in computeCoeqs graph (colim', morMap') edges' 103 106 107 class (Eq a, Ord a) => SymbolName a where 108 addIntAsSuffix :: (a, Int) -> a 109 110 instance SymbolName Id where 111 addIntAsSuffix (x,y) = appendNumber x y 112 113 addIntToSymbols :: (SymbolName a) => 114 (Set.Set (a, Node), Map.Map Node (Map.Map a (a, Node))) -> 115 (Set.Set a, Map.Map Node (Map.Map a a)) 116 addIntToSymbols (set, fun) = let 117 fstEqual (x1,_) (x2,_) = x1 == x2 118 partList pairSet = leqClasses fstEqual pairSet 119 namePartitions elemList f0 s1 f1 = case elemList of 120 [] -> (s1, f1) 121 p:ps -> if length p == 1 then 122 -- a single element with this name,it can be kept 123 let s2 = Set.insert (fst $ head p) s1 124 updateF node = Map.union (Map.findWithDefault (error "f1") node f1) $ 125 Map.fromList $ map (\x -> (x, fst $ head p)) $ 126 filter (\x -> Map.findWithDefault (error "fo(node)") x 127 (Map.findWithDefault (error "f0") node f0) 128 == head p) $ 129 Map.keys $ Map.findWithDefault (error "f0") 130 node f0 131 f2 = Map.fromList $ zip (Map.keys f0) $ map updateF $ Map.keys f0 132 in namePartitions ps f0 s2 f2 133 else 134 --several elements with same name, the number is added at the end 135 let s2 = Set.union s1 $ Set.fromList $ map addIntAsSuffix p 136 updateF node = Map.union (Map.findWithDefault (error "f1") node f1) $ 137 Map.fromList $ 138 map ( \x -> (x, addIntAsSuffix $ 139 Map.findWithDefault (error "addSuffixToId") x 140 (Map.findWithDefault (error "f0") node f0))) $ 141 filter (\x -> (Map.findWithDefault (error "fo(node)") x 142 (Map.findWithDefault (error "f0") node f0)) 143 `elem` p) $ 144 Map.keys $ Map.findWithDefault (error "f0") node f0 145 f2 = Map.fromList $ zip (Map.keys f0) $ map updateF $ Map.keys f0 146 in namePartitions ps f0 s2 f2 147 in namePartitions (partList set) fun (Set.empty) $ 148 Map.fromList $ zip (Map.keys fun) (repeat Map.empty) 104 149 105 150 106 -
trunk/Propositional/Analysis.hs
r11534 r12726 43 43 import Data.Graph.Inductive.Graph 44 44 import Common.SetColimit 45 import CASL.ColimSign(renameSorts)46 45 47 46 -- | Datatype for formulas with diagnosis data … … 393 392 signatureColimit graph = do 394 393 let graph1 = nmap Sign.items $ emap (\(x,y) -> (x, Morphism.propMap y)) graph 395 (set, maps) = renameSorts $ computeColimitSet graph1394 (set, maps) = addIntToSymbols $ computeColimitSet graph1 396 395 cSig = Sign.Sign{Sign.items = set} 397 396 return (cSig,