[module structure reorganisation
martin.hofmann@uni-bamberg.de**20090112142025
 Major reorganisation of the module structure. A lot of renaming, import/export organisation (more import). An overview of the module structure is summarised in the file ModuleDependencies.dia (a Dia diagram).
] move ./src/Data/IgorData.hs ./src/Data/IgorMonad.hs
move ./src/IgorMonad.hs ./src/SynthesisEngine.hs
addfile ./ModuleDependencies.dia
binary ./ModuleDependencies.dia
oldhex
*
newhex
*1f8b0800000000000203ed9d6d73e23812c7dfcfa7a098b789b064cb0fcb265bb3b3b7b55b755b
*53753bf33a254001df1a9bb34d32bcb9cf7e92710043006361b25cfe54cd03d0a8d5c6b4f5eb6e
*b57ffce9fb34ea3cc9340b93f8ae4b89d5edc878988cc2787cd7fdf6f5d75bbffbd3fd871f47a1
*f841fd19a762da519f8833fdecae3bc9f3d90fbddef3f333891699c8939444e19c64b2f75f1145
*a2a7847addfb0f9dcee60023910bfd5af9aac8f3341ccc73d989c554de750762f8d7384de6f1a8
*bb942ae5864994a49d2711dd753f3e168f6eaf1ca65719e7c0d833319683548abff60f6da94710
*34197a26d3ed61a7b3240b9548be98ed88ec1947ffbd21534a654a281edf7ffce47c5c4ea97c61
*3dd66b13ddab249f8a741cc6bb7ad4b189960782119f31a60e060ffcc0f21c8fbe1c93d3d50d2e
*ab2ebaacbaf4b2eac2ec6196a4792ac27c57e520492229e2a5d63c9dcbe67ab2a188d42976c82c
*032b1ec33c4f8eccff5144591d03962faf7e6da7fe72c769383afcc3ad48ec19e5391ce59387ef
*2d1daee5e88b96467f0ab37010c9d7661fc6f9d9865f9c67f8ed6fa7f0deeb8f1b9e0dcbd1f65e
*1e46bee4929f7e7918cfc391cc8e9c6655993d234d4ab1deb1a3be2d57f7c02c5fdaba58172a22
*b1906939fccfebcb74a7fc824b8fb3711492c1bfe5302fcdfbf6c73f3bb79dcf91c8b2ee7ac9a1
*161ce1e8aefbc5aa1e9b6d6bd448caeded1c9c59b23a8318bbb975b6adddf515fb061f0cb6c74e
*d5d4453c8e64393e2501572a88c5fb2c20beab9e50e2f1662a6524a70fc3248d775704e7b1a950
*50b88d5dbb5e5c86477ccaad8d8789ae890cc7937cbf324668507978cd946d2d902acba3cf6ad5
*f98b9cc978a416b1a1cc5e5d2c9da22ccb652a137dfeee5369ac42fd20a732ce5b1b5f0cd467c5
*7047c1a14bed4987683e9ba532cb1e566f64adab4ad4425ae4ca7fb4a6eae59a55d3a8ea52ab89
*a29a26992b2acfb7d68edc732a66ed5b5368118feae7f9309c881d1fbaf2a08ed56cfcf2283da8
*25b07c88643cdef5a3ebb58b67a62317e37175a57dd62fa430a1baacd9c3bd56c383f51846d171
*0d55683f4d432ebfe7edda10278ae3a287c764d715ebd73a8f621a468bbbee3489936c2686b2db
*c9f2855ef4a815cc7288cfc93c0d65da4cff8b9b6e3203dfdf9ac2edcf4934fa3288c2ff34fd7d
*cd9268314dd2d9241c369ad1f6848c2633d46b46fddfe353c9847239ab59acbe9adf64f424f370
*288a2363f80d359e8efffa74cc8e4de9444e9ccaee4c8c66b1f1eb39ba10b4886f551fce79ced1
*cb69aefc582fa7b67ae21dd54bcf7a9eb7a56ef304ae7128dd2a44046e4323d7ebbade61365caf
*647a472e51d3592472d9d665fc65fcac1a7c58227633e6a6a6cc6dfb0a806f38715be46ead43a9
*e0bcef50c25dc66f14b6b64add8656d5216f463c65c9864760574edeff9a47c06de036701bb80d
*dc066e03b781dbc06de036701bb80ddc2e719b99e2b602607ac39862e116795b29b178a1a5efd8
*c40a6e9843fc3671dbd4aa3abc4d4960574fe42be7ed6f791801b781dbc06de036701bb80ddc06
*6e03b781dbc06de03670bbc06ddb38bbed11e7863262b789db4a89cd0b2d7d476f1352ff778c32
*cfc7d3db8666d5e16d4e6ca3caf8bf03627f95e93423c5d905d2066983b441da206d9036481ba4
*0dd2066983b441da20ed82b49d3390b6b7dc5add2e69bbc5066eaa49dbb559b181db6f19b58dec
*aa83da0ef1fd4a29b97de5dcfd6b2ac6055980ba41dda06e5037a81bd40dea067583ba41dda06e
*50f73ba3ee5543abc5067ad312bdb9714db945a84d6dbda9daf13daf4dfe0e14747b7afbb61728
*4d7da599ebe7943585f024cd270f852d8d2cdc2f1a107f337dfdaaa0a544ea0b9a9411682b1375
*1ddebd44c8783e7dad7f62f53debc07bd4604e629e2769326ff34753ae1be7ad2d1c57cbebf654
*1c8a755c438863948ae70791a6c9f399687098c4b1720dda2bef1cf297773a13118fcaf5799e14
*bd2a3aeb77f512a877fcb3b4fcac5dfd2cdded89b93521f390a86b1c12a584ea0065e308653d9f
*acf7de144a78df76953f562a03b39d38c783a2a696d52c40b2afbd00e9b7c52cc9273243630d44
*42110945241491504442110945241491504442110945241491d0cd48a8674cdc36f1a9570070ab
*fd2c6de2b9a51a5e044103ca6e6eedc64a6b05415f37ee809c4f6c762cb2491d3df3fa9206055e
*88812206faee63a06e358ee99e120375da8b811e74cbfe95b865c689c3576e592b2d9cb4ddbcd9
*526b7ef9909c3223b04e9173e090e190e1902fef90adcb27a5823324a574d53cb31b7760af9b95
*6285964027a5748dc02da32d6f8a37b6ac5e564af95cebffa8edbb4e51fda92366c8502143850c
*153254c8502143850c153254c8502143850c153254c850ad43a1d43a432cd4f35f7098b79ba4b2
*dd5291d7b71dc28a67949a55b1d70987be6ae001491a5490fd40e8f404496ab425017151c445df
*755c3430888bba978f8b52e31b61728fd8cb88658b4e592929639401efbbea02ed1b5d08ea0546
*4d2dab131655171bbbb26aa3571e16fdfdcb2f2217888922268a982862a2888922268a982862a2
*888922268a982862a2e81abaa46ef3fb613ac54e72db52ffb479474c476f92575a58df0908d52a
*9967c4c3c7ef89696c59bdd6a101bdf64df2bf8f93f48f241623d036681bb40dda066d83b641db
*a06dd036681bb40dda4605d2460592f13d311d97b8c5be4145c07e63a0ab5d836497aa0227f0fa
*5a77b14593d9c469b563e85e230fc972e27b4e50ab66e9245983cd56d75d8cd49c18508b845aa4
*55e35066d0393478a35df3d4b92247ad5471bee9a879401c5afa69feb774d46a31714896fb2470
*4f146d5efb052f0d2f0d2f6de0a5297d2b377d96f6fb456f24daf296fa80b8fe524f50349dd24f
*5cb37e4cb53aefbf62dc7e414a9ce3ada47483feda82dca8ad160af9e196dfb55b760c0af9e91b
*14f21bb7dde79c58b64575af3aceda74c8dc21815f2af278df65c4f5b87aca08f3da2de83f8385
*758a0b3cc2150c6c3cfc2baf34f82ad369463ec579388fc3c750a6a83840c5012a0e5071808a03
*541ca0e2001507a83840c5012a0e5071808a838d08a9715bfe558245ef74b7ec4b353db12c5be7
*b12c7a89b6277b6ddc2f4aebb58bae2b8686278893224eda3c7d65727b52f7adb257fe597db3dd
*6ab8d427b6e7b9a56fb6b9f6cdac78c1d13d952fe69c6d5ec739fbe4a89ccff4e46b0b9a84a3e1
*a1e1a1e1a14d3c347d8ba654c6ddfa3d462cbd89d423adba668f153a9cbee713a61b54d99cd036
*3358e676d5c95fb984b26bdf1cfb69f424e2a1d4048c6415925548562159856415925548562159
*856415925548562159856654056d33cb3c167a73ebf0c61b536b36800ef8520befbb5ce16f7107
*4fdbac49d4f18a5123cbead58adad51be35d7b03e83f17713e915998fd2356eb59dc1d0ff00df8
*067c03be01df806fc037e01bf00df8067ca35274a31a8919df84c92d0a74bc92887db7dd9627f4
*05be99e5bb7db7284b52ba59403c2768b52069bf9d0764750380235be65f1aa49c226a69984661
*120a935098d4b0308959268549fbdba6b45b3bcad815796badca2a5515dedae384bb45a9926bd4
*b5e9ad5cb59a3fa58c9f26ea996d6280a386a386a36eeca8dfaa9320336ef9baf6209c58ad7712
*5c2eab7509a9ee24a875178e5a2fab9beffeaae5abf7db7948961db94ff57aa95c5fd252572923
*5bd14d10aefa5d17fb076fbaa65e3e8fc442a6f71f964fd49f712aa6f71ffe07bf941157720501
*00
hunk ./src/Data/Fragments.hs 9
-    RuleFrags, ruleFrags, insert, delete, replace, union,
-    fold, map, empty, null, size,
+    RuleFrags, ruleFrags, insertFs, deleteFs, replaceFs, unionFs,
+    foldFs, mapFs, emptyFs, nullFs, countFs,
hunk ./src/Data/Fragments.hs 12
-    toSet, toList,
+    fragsToSet, fragsToList,
hunk ./src/Data/Fragments.hs 14
-    openPositions, freeVars, hasFreeVars
+    openPositions, freeVars, hasFreeVars,
+    
+    module Data.Rules
hunk ./src/Data/Fragments.hs 23
-import Data.Rules (Rule, Rateable(..), rhs, lhs)
+import Data.Rules
hunk ./src/Data/Fragments.hs 100
-ruleFrags = fromList
+ruleFrags = fragsFromList
hunk ./src/Data/Fragments.hs 102
-null :: RuleFrags -> Bool
-null = S.null.unRFS
+nullFs :: RuleFrags -> Bool
+nullFs = S.null.unRFS
hunk ./src/Data/Fragments.hs 105
-size = S.size.unRFS
+countFs = S.size.unRFS
hunk ./src/Data/Fragments.hs 107
-empty :: RuleFrags
-empty = RFS $ S.empty
+emptyFs :: RuleFrags
+emptyFs = RFS $ S.empty
hunk ./src/Data/Fragments.hs 110
-fold :: (RuleFrag -> a -> a) -> a -> RuleFrags -> a
-fold f i rs = foldl' (flip f) i (toList rs) --S.fold f i (unRFS rs)
+foldFs :: (RuleFrag -> a -> a) -> a -> RuleFrags -> a
+foldFs f i rs = foldl' (flip f) i (fragsToList rs) --S.fold f i (unRFS rs)
hunk ./src/Data/Fragments.hs 113
-map :: (RuleFrag -> RuleFrag) -> RuleFrags -> RuleFrags
-map f rs  = RFS $ (S.map f) (unRFS rs)
+mapFs :: (RuleFrag -> RuleFrag) -> RuleFrags -> RuleFrags
+mapFs f rs  = RFS $ (S.map f) (unRFS rs)
hunk ./src/Data/Fragments.hs 116
-union :: RuleFrags -> RuleFrags -> RuleFrags
-union (RFS rs1) (RFS rs2) = RFS $ S.union rs1 rs2
+unionFs :: RuleFrags -> RuleFrags -> RuleFrags
+unionFs (RFS rs1) (RFS rs2) = RFS $ S.union rs1 rs2
hunk ./src/Data/Fragments.hs 119
-insert :: RuleFrag -> RuleFrags -> RuleFrags
-insert r rs = RFS $ (S.insert r) $ unRFS rs
+insertFs :: RuleFrag -> RuleFrags -> RuleFrags
+insertFs r rs = RFS $ (S.insert r) $ unRFS rs
hunk ./src/Data/Fragments.hs 126
-delete :: RuleFrag -> RuleFrags -> RuleFrags
-delete r rs = RFS $ (S.delete r) $ unRFS rs
+deleteFs :: RuleFrag -> RuleFrags -> RuleFrags
+deleteFs r rs = RFS $ (S.delete r) $ unRFS rs
hunk ./src/Data/Fragments.hs 139
-replace :: RuleFrag ->  -- ^replace old rule 
+replaceFs :: RuleFrag ->  -- ^replace old rule 
hunk ./src/Data/Fragments.hs 143
-replace r1 r2 = (insert r2).(delete r1)
+replaceFs r1 r2 = (insertFs r2).(deleteFs r1)
hunk ./src/Data/Fragments.hs 149
-fromList :: [RuleFrag] -> RuleFrags
-fromList rs  = RFS $ S.fromList rs
+fragsFromList :: [RuleFrag] -> RuleFrags
+fragsFromList rs  = RFS $ S.fromList rs
hunk ./src/Data/Fragments.hs 157
-toList = S.toList.unRFS
-toSet = unRFS
+fragsToList = S.toList.unRFS
+fragsToSet = unRFS
hunk ./src/Data/HypoSpace.hs 4
-    HSpace, initHSpace,setupHSpace, 
+    HSpace, initHSpace, emptyHSpace, 
hunk ./src/Data/HypoSpace.hs 6
-    bestHypos, propagate
+    bestHypos, propagateHSp,
+    
+    module Data.Hypotheses
hunk ./src/Data/HypoSpace.hs 16
+import Data.Hypotheses
hunk ./src/Data/HypoSpace.hs 19
-import Data.Fragments (RuleFrag, RuleFrags)
-import qualified Data.Fragments as F
-
-import qualified Data.Hypotheses as H 
-import Data.Hypotheses (Hypo, Hypos, hypos, open, develop, Call)
-
-import Data.Rules (RatingData, Rateable(..))
-
hunk ./src/Data/HypoSpace.hs 100
-        frgs = F.toList.open $ h in
+        frgs = fragsToList.open $ h in
hunk ./src/Data/HypoSpace.hs 115
-setupHSpace :: HSpace
-setupHSpace = HSpace 
+emptyHSpace :: HSpace
+emptyHSpace = HSpace 
hunk ./src/Data/HypoSpace.hs 123
--- | /O(1)/, initialise a search space setting a hypothese as inital hypothese
-initHSpace :: Hypo ->  HSpace
-initHSpace = flip insert setupHSpace
+-- | /O(1)/, initialise a search space with a 'RuleFrag' as inital hypothese
+initHSpace :: RuleFrag ->  HSpace
+initHSpace rf = insert initHypo emptyHSpace
+    where
+    initHypo = hypo $ ruleFrags [rf]
hunk ./src/Data/HypoSpace.hs 129
+    
hunk ./src/Data/HypoSpace.hs 175
-propagate :: (RuleFrag,RuleFrags,[Call]) -> HSpace -> HSpace
-propagate pdata@(ro,_,_) hsp   =  
+propagateHSp :: (RuleFrag,RuleFrags,[Call]) -> HSpace -> HSpace
+propagateHSp pdata@(ro,_,_) hsp   =  
hunk ./src/Data/HypoSpace.hs 179
-    devAndRep  = (develop pdata) >>= flip replace  
+    devAndRep  = (developH pdata) >>= flip replace  
hunk ./src/Data/Hypotheses.hs 8
-    Hypos, hypos,  empty, singleton, null, size,
-    merge, insert, delete, replace, 
-    develop, shrink, extend, modify,
-    mbDelete, mbInsert,
-    toList,
+    Hypos, hypos,  emptyHs, singletonHs, nullHs, countHs,
+    mergeHs, insertHs, deleteHs, replaceHs, 
+    developH, shrinkH, extendH, modifyH,
+    mbDeleteHs, mbInsertHs,
+    hyposToList,
hunk ./src/Data/Hypotheses.hs 14
-    map, map', fold,
+    mapHs, mapHs', foldHs,
hunk ./src/Data/Hypotheses.hs 16
-    module Data.CallDependencies
+    module Data.CallDependencies,
+    module Data.Fragments
hunk ./src/Data/Hypotheses.hs 21
-import Prelude hiding (null, map)
+import Prelude
hunk ./src/Data/Hypotheses.hs 27
+
hunk ./src/Data/Hypotheses.hs 34
-import Data.Rules (Rules, Rateable(..))
-import qualified Data.Rules as R 
-
-import Data.Fragments (RuleFrag, RuleFrags,name, frag )
-import qualified Data.Fragments as F 
+import Data.Fragments 
hunk ./src/Data/Hypotheses.hs 68
-    rate h       = F.size (open h)--F.fold (\r d -> (rate r) + d) 0 (open h)
+    rate h       = countFs (open h)--F.fold (\r d -> (rate r) + d) 0 (open h)
hunk ./src/Data/Hypotheses.hs 89
-develop ::  (Monad m) => 
+developH ::  (Monad m) => 
hunk ./src/Data/Hypotheses.hs 95
-develop (rf,rfs,calls) h = do 
-    let (HH open clsd cdps) = modify rf rfs h
+developH (rf,rfs,calls) h = do 
+    let (HH open clsd cdps) = modifyH rf rfs h
hunk ./src/Data/Hypotheses.hs 105
-extend :: RuleFrag -> Hypo -> Hypo
-extend rf h@(HH os cs _ ) 
-    | F.isOpen rf  = h{open = F.insert rf os}
-    | otherwise    = h{clsd = M.alter (R.insertM (frag rf)) (name rf) cs}
+extendH :: RuleFrag -> Hypo -> Hypo
+extendH rf h@(HH os cs _ ) 
+    | isOpen rf  = h{open = insertFs rf os}
+    | otherwise    = h{clsd = M.alter (insertRsM (frag rf)) (name rf) cs}
hunk ./src/Data/Hypotheses.hs 111
-shrink :: RuleFrag -> Hypo -> Hypo
-shrink rf h@(HH os cs _ ) 
-    | F.isOpen rf  = h{open = F.delete rf os}
-    | otherwise    = h{clsd = M.alter (R.deleteM (frag rf)) (name rf) cs}
+shrinkH :: RuleFrag -> Hypo -> Hypo
+shrinkH rf h@(HH os cs _ ) 
+    | isOpen rf  = h{open = deleteFs rf os}
+    | otherwise    = h{clsd = M.alter (deleteRsM (frag rf)) (name rf) cs}
hunk ./src/Data/Hypotheses.hs 117
-modify 
+modifyH 
hunk ./src/Data/Hypotheses.hs 122
-modify rold newrs h =     
-    let shrnk = shrink rold h in
-    F.fold extend shrnk newrs 
+modifyH rold newrs h =     
+    let shrnk = shrinkH rold h in
+    foldFs extendH shrnk newrs 
hunk ./src/Data/Hypotheses.hs 136
-singleton :: Hypo -> Hypos
-singleton h = HHs $ S.singleton h
+singletonHs :: Hypo -> Hypos
+singletonHs h = HHs $ S.singleton h
hunk ./src/Data/Hypotheses.hs 143
-empty :: Hypos
-empty = HHs $ S.empty
+emptyHs :: Hypos
+emptyHs = HHs $ S.empty
hunk ./src/Data/Hypotheses.hs 146
-null :: Hypos -> Bool   
-null = S.null.unHHs  
+nullHs :: Hypos -> Bool   
+nullHs = S.null.unHHs  
hunk ./src/Data/Hypotheses.hs 149
-size :: Hypos -> Int
-size = S.size.unHHs
+countHs :: Hypos -> Int
+countHs = S.size.unHHs
hunk ./src/Data/Hypotheses.hs 152
-fold :: (Hypo -> a -> a) -> a -> Hypos -> a
-fold f i rs = foldl' (flip f) i (toList rs) -- S.fold f i (unHHs rs)
+foldHs :: (Hypo -> a -> a) -> a -> Hypos -> a
+foldHs f i rs = foldl' (flip f) i (hyposToList rs) -- S.fold f i (unHHs rs)
hunk ./src/Data/Hypotheses.hs 155
-map :: (Ord a) => (Hypo -> a) -> Hypos -> (Set a)
-map f hs  = (S.map f) (unHHs hs)
+mapHs :: (Ord a) => (Hypo -> a) -> Hypos -> (Set a)
+mapHs f hs  = (S.map f) (unHHs hs)
hunk ./src/Data/Hypotheses.hs 158
-map' :: (Hypo -> Maybe Hypo) -> Hypos -> Hypos
-map' f hs = 
-    case mapM f (toList hs) of
+mapHs' :: (Hypo -> Maybe Hypo) -> Hypos -> Hypos
+mapHs' f hs = 
+    case mapM f (hyposToList hs) of
hunk ./src/Data/Hypotheses.hs 162
-        Nothing -> empty 
+        Nothing -> emptyHs 
hunk ./src/Data/Hypotheses.hs 165
-merge :: Hypos -> Hypos -> Hypos
-merge hs1 hs2 = HHs $ S.union (unHHs hs1) (unHHs hs2)
+mergeHs :: Hypos -> Hypos -> Hypos
+mergeHs hs1 hs2 = HHs $ S.union (unHHs hs1) (unHHs hs2)
hunk ./src/Data/Hypotheses.hs 168
-insert :: Hypo -> Hypos -> Hypos  
-insert h hs = HHs $ S.insert  h (unHHs hs)
+insertHs :: Hypo -> Hypos -> Hypos  
+insertHs h hs = HHs $ S.insert  h (unHHs hs)
hunk ./src/Data/Hypotheses.hs 171
-mbInsert :: Hypo -> Maybe Hypos -> Maybe Hypos
-mbInsert h hs = 
+mbInsertHs :: Hypo -> Maybe Hypos -> Maybe Hypos
+mbInsertHs h hs = 
hunk ./src/Data/Hypotheses.hs 174
-        Just hs' -> return $ insert h hs'
-        Nothing  -> return $ singleton h
+        Just hs' -> return $ insertHs h hs'
+        Nothing  -> return $ singletonHs h
hunk ./src/Data/Hypotheses.hs 177
-delete :: Hypo -> Hypos -> Hypos
-delete h hs = HHs $ S.delete h (unHHs hs)
+deleteHs :: Hypo -> Hypos -> Hypos
+deleteHs h hs = HHs $ S.delete h (unHHs hs)
hunk ./src/Data/Hypotheses.hs 180
-mbDelete :: Hypo -> Maybe Hypos -> Maybe Hypos
-mbDelete _ Nothing   = Nothing 
-mbDelete h (Just hs) = 
-    let hs' =  delete h hs
-    in if null hs' 
+mbDeleteHs :: Hypo -> Maybe Hypos -> Maybe Hypos
+mbDeleteHs _ Nothing   = Nothing 
+mbDeleteHs h (Just hs) = 
+    let hs' =  deleteHs h hs
+    in if nullHs hs' 
hunk ./src/Data/Hypotheses.hs 188
-replace :: Hypo -> Hypo -> Hypos -> Hypos
-replace h1 h2 hs = insert h1 (delete h2 hs)
+replaceHs :: Hypo -> Hypo -> Hypos -> Hypos
+replaceHs h1 h2 hs = insertHs h1 (deleteHs h2 hs)
hunk ./src/Data/Hypotheses.hs 191
-toList :: Hypos -> [Hypo]
-toList = S.toList.unHHs
+hyposToList :: Hypos -> [Hypo]
+hyposToList = S.toList.unHHs
hunk ./src/Data/IOData.hs 4
-import Data.Rules (Rules, Rule, rulesToList, RHS, LHS, rhs, lhs)
hunk ./src/Data/IOData.hs 5
-import qualified Data.Hypotheses as H
+--import Data.Rules (Rules, Rule, rulesToList, RHS, LHS, rhs, lhs)
+--import qualified Data.Hypotheses as H
+import Data.Fragments
+
+--import Terms
+import Terms.Antiunifier
+
+import Logging
hunk ./src/Data/IOData.hs 20
-import Data.List (foldl')
+import Data.List (foldl', transpose)
hunk ./src/Data/IOData.hs 22
-import Terms
hunk ./src/Data/IOData.hs 90
---  background knowledge (zero based)      
+--  background knowledge (zero based)
+-- TODO is really guaranteed that a rule has always the same index?      
hunk ./src/Data/IOData.hs 97
+-- TODO is really guaranteed that a rule has always the same index?
hunk ./src/Data/IOData.hs 109
+-- | Create a 'RuleFrag' which covers all 'Rule's in 'IOData' with the given 'Name'
+coverAll :: IOData -> Name -> RuleFrag
+coverAll iod n =
+    let rules = getAll n iod 
+        rule  = noLog $ antiunifyRules rules
+        opos  = openPositions rule
+        is    = [0.. (length rules) - 1]
+    in ruleFrag n rule is opos
+    
+-- | Create a 'RuleFrag' which covers all 'Rule's in 'IOData' with the given 
+--   'Name' and and index in '[Int]'
+coverRules :: IOData -> Name -> [Int] -> RuleFrag
+coverRules iod n is =
+    let rules = getSpecifics n iod is
+        rule  = noLog $ antiunifyRules rules
+        opos  = openPositions rule
+    in ruleFrag n rule is opos
+    
+antiunifyRules :: [Rule] -> LM Rule
+antiunifyRules rules  = do
+        let tlhss   = transpose $ map lhs rules
+        let rhss    = map rhs rules
+        (left,right)<-  antiunify2 tlhss rhss
+        return $ rule left right
hunk ./src/Data/IgorMonad.hs 2
-module Data.IgorData where
+module Data.IgorMonad (
+    
+    initIgor, setupTarget, propagate,
+    Igor(..), 
+    
+    runIM, IM, 
+    setTarget, currentBestHypos, getEvidence,
+    
+    module Data.IOData,
+    module Data.HypoSpace
hunk ./src/Data/IgorMonad.hs 13
-import Data.IOData (IOData, getAll, getSpecifics)
-import Data.HypoSpace (initHSpace, setupHSpace)
+    )where
hunk ./src/Data/IgorMonad.hs 15
-import Data.HypoSpace (HSpace)
-import qualified Data.HypoSpace as HS
+import Data.List (transpose)
+import Control.Monad.State
hunk ./src/Data/IgorMonad.hs 18
-import Data.Hypotheses (Hypo, hypo, Call)
-import qualified Data.Hypotheses as H
+import Data.IOData (IOData, getAll, getSpecifics, coverAll, coverRules, initIOData)
hunk ./src/Data/IgorMonad.hs 20
-import Data.Fragments (RuleFrag, RuleFrags)
-import qualified Data.Fragments as F
+import Data.HypoSpace 
hunk ./src/Data/IgorMonad.hs 22
-import Terms
hunk ./src/Data/IgorMonad.hs 24
+
+-- | Igor in a Monad
+type IM a = StateT Igor LM a 
+
+runIM :: IM a -> Igor -> LM a
+runIM = evalStateT
+
+setTarget :: Name -> IM()
+setTarget n = do
+    igor <- get
+    put $ setupTarget igor n
+
+currentBestHypos :: IM Hypos
+currentBestHypos = liftM bestHypos $ gets searchSpace
+
+getEvidence :: IM IOData
+getEvidence = gets iodata
+
+
hunk ./src/Data/IgorMonad.hs 46
-setupIgor :: IOData -> Igor
-setupIgor = flip Igor setupHSpace
-
-initIgor :: IOData -> Name -> Igor
-initIgor iod n = Igor iod $! initHSpace $! (mkInitialHypo iod n) 
+-- | Set the target for the given 'Igor' to a function with name 'Name'. If no 
+--   evidence for such a function exists in 'Igor' an error is thrown. 
+setupTarget :: Igor -> Name -> Igor
+setupTarget ( Igor iod _ ) n  = Igor iod $! initHSpace (coverAll iod n)
hunk ./src/Data/IgorMonad.hs 51
--- TODO: should be in IOData    
-mkInitialHypo :: IOData -> Name -> Hypo
-mkInitialHypo iod n = 
-    let rules = getAll n iod
-        rule  = noLog $! antiunify rules
-        cover = [0..(length rules)-1]
-        opos  = F.openPositions rule
-        ih = hypo $ F.ruleFrags [F.ruleFrag n rule cover opos]
-    in ih
-    
--- TODO: should be in IOData
-coverRules :: IOData -> Name -> [Int] -> RuleFrag
-coverRules iod n is =
-    let rules = getSpecifics n iod is
-        rule  = noLog $ antiunify rules
-        opos  = F.openPositions rule
-    in F.ruleFrag n rule is opos
+-- | Initialise an 'Igor' (data object) with '[(Name,Rules)]' as evidence for 
+--   the target function and background knowledge. Each '(Name,Rules)' is the
+--   the evidence of a function with 'Name' and IO examples 'Rules' 
+initIgor :: [(Name,Rules)] -> Igor
+initIgor nr = Igor (initIOData nr) emptyHSpace
+ 
hunk ./src/Data/IgorMonad.hs 59
-propagate p (Igor iod sp) = Igor iod (HS.propagate p sp)
+propagate p (Igor iod sp) = Igor iod (propagateHSp p sp)
hunk ./src/Data/Rules.hs 7
-    insert, delete, replace,
-    insertM, deleteM, replaceM, 
-    map , fold,
-    
+    insertRs, deleteRs, replaceRs,
+    insertRsM, deleteRsM, replaceRsM, 
+    mapRs , foldRs,
hunk ./src/Data/Rules.hs 16
-    LHS, RHS
+    LHS, RHS,
hunk ./src/Data/Rules.hs 18
+    module Terms.Class    
hunk ./src/Data/Rules.hs 22
-import Prelude hiding (map, null)
-import Data.Util 
+import Prelude
+ 
+import Data.List (foldl', transpose)
+import qualified Data.List as L
+
hunk ./src/Data/Rules.hs 28
-import qualified Data.Set as S (empty, fromList, toList, map, null, insert, delete)
-import Terms.Class 
-import Data.List (foldl')
+import qualified Data.Set as S (empty, fromList, toAscList, map, null, insert, delete)
+
+import Data.Util 
+import Terms.Class
+import Logging
hunk ./src/Data/Rules.hs 85
-
+-- | 'Rules' are a collection of 'Rule's with no duplicates
hunk ./src/Data/Rules.hs 90
-    show rs = showAsSet ((S.toList.rulesToSet) rs) $ ""
+    show rs = showAsSet (rulesToList rs) $ ""
hunk ./src/Data/Rules.hs 95
-fold :: (Rule -> a -> a) -> a -> Rules -> a
-fold f i rs =  foldl' (flip f) i (rulesToList rs) -- S.fold f i (unRS rs)
+foldRs :: (Rule -> a -> a) -> a -> Rules -> a
+foldRs f i rs =  foldl' (flip f) i (rulesToList rs) -- S.fold f i (unRS rs)
hunk ./src/Data/Rules.hs 98
-map :: (Rule -> Rule) -> Rules -> Rules
-map f rs  = RS $ (S.map f) (unRS rs)
+mapRs :: (Rule -> Rule) -> Rules -> Rules
+mapRs f rs  = RS $ (S.map f) (unRS rs)
hunk ./src/Data/Rules.hs 101
-null :: Rules -> Bool
-null = S.null.unRS
+nullRs :: Rules -> Bool
+nullRs = S.null.unRS
hunk ./src/Data/Rules.hs 104
-empty :: Rules
-empty = RS $ S.empty
+emptyRs :: Rules
+emptyRs = RS $ S.empty
hunk ./src/Data/Rules.hs 107
-insert :: Rule -> Rules -> Rules
-insert r rs = RS $ (S.insert r) $ unRS rs
+insertRs :: Rule -> Rules -> Rules
+insertRs r rs = RS $ (S.insert r) $ unRS rs
hunk ./src/Data/Rules.hs 110
-insertM :: Rule -> Maybe Rules -> Maybe Rules
-insertM  r rs   = 
+insertRsM :: Rule -> Maybe Rules -> Maybe Rules
+insertRsM  r rs   = 
hunk ./src/Data/Rules.hs 113
-        (Just rs') -> return $ insert r rs'
-        Nothing    -> return $ insert r empty
+        (Just rs') -> return $ insertRs r rs'
+        Nothing    -> return $ insertRs r emptyRs
hunk ./src/Data/Rules.hs 116
-delete :: Rule -> Rules -> Rules
-delete r rs = RS $ (S.delete r) $ unRS rs
+deleteRs :: Rule -> Rules -> Rules
+deleteRs r rs = RS $ (S.delete r) $ unRS rs
hunk ./src/Data/Rules.hs 119
-deleteM :: Rule -> Maybe Rules -> Maybe Rules
-deleteM r rs = do
+deleteRsM :: Rule -> Maybe Rules -> Maybe Rules
+deleteRsM r rs = do
hunk ./src/Data/Rules.hs 122
-    d   <- return $ delete r rs'
-    if null d
+    d   <- return $ deleteRs r rs'
+    if nullRs d
hunk ./src/Data/Rules.hs 127
-replace :: Rule ->  -- ^replace old rule 
+replaceRs :: Rule ->  -- ^replace old rule 
hunk ./src/Data/Rules.hs 131
-replace r1 r2 = (insert r2).(delete r1) 
-
-replaceM r1 r2 = (insertM r2).(deleteM r1)
-
-
+replaceRs r1 r2 = (insertRs r2).(deleteRs r1) 
hunk ./src/Data/Rules.hs 133
+replaceRsM r1 r2 = (insertRsM r2).(deleteRsM r1)
hunk ./src/Data/Rules.hs 146
--- *FIXME* necessary?
-rulesToList = S.toList.unRS
+-- | An ascending ordered list of 'Rule's 
+rulesToList = S.toAscList.unRS
hunk ./src/Main.hs 10
-import IgorMonad
-import Data.IgorData
+import SynthesisEngine
+import Data.IgorMonad
hunk ./src/Main.hs 308
-testinit :: Dec -> Dec -> LM Dec
-testinit d1 d2 = do logIN $ ["Dec1 is ", skip (view d1),"Dec2 is ", skip (view d2) ]
-
-                    logIN $ ["Transforming Dec1 to FunDef"] 
-                    let fdef1 = toFunDef d1
-                    logIN $ ["Resulting FunDef is:", skip (show fdef1)]
-                    
-                    logIN $ ["Transforming Dec2 to FunDef"]
-                    let fdef2 = toFunDef d2
-                    logIN $ ["Resulting FunDef is:", skip (show fdef2)]
-                    return d1
+--testinit :: Dec -> Dec -> LM Dec
+--testinit d1 d2 = do logIN $ ["Dec1 is ", skip (view d1),"Dec2 is ", skip (view d2) ]
+--
+--                    logIN $ ["Transforming Dec1 to FunDef"] 
+--                    let fdef1 = toFunDef d1
+--                    logIN $ ["Resulting FunDef is:", skip (show fdef1)]
+--                    
+--                    logIN $ ["Transforming Dec2 to FunDef"]
+--                    let fdef2 = toFunDef d2
+--                    logIN $ ["Resulting FunDef is:", skip (show fdef2)]
+--                    return d1
hunk ./src/SynthesisEngine.hs 2
-module IgorMonad where
+module SynthesisEngine where
hunk ./src/SynthesisEngine.hs 5
+
+import Data.IgorMonad 
hunk ./src/SynthesisEngine.hs 8
-import Data.IgorData (initIgor, propagate, coverRules, iodata, searchSpace, setupIgor, Igor) 
-import Data.IOData
-import qualified Data.HypoSpace as HS (bestHypos)
hunk ./src/SynthesisEngine.hs 9
-import Data.Hypotheses (Hypos, open, clsd)
-
---import qualified Data.Hypotheses as F (fold, null)
-import qualified Data.Hypotheses as H (map, null,toList, fold)
-
-import Data.Rules (Rules, rulesToList, rulesToSet)
-
-import Data.Fragments (RuleFrag, RuleFrags, ruleFrags,  covr, name)
-import qualified Data.Fragments as F (empty, union, fold, null, toSet)
-
-import Data.HypoSpace (HSpace)
-
hunk ./src/SynthesisEngine.hs 16
-type IM a = StateT Igor LM a 
hunk ./src/SynthesisEngine.hs 17
-runIM = evalStateT
hunk ./src/SynthesisEngine.hs 46
-    igordata <- return $  (setupIgor.initIOData) allrs
+    igordata <- return $ initIgor allrs
hunk ./src/SynthesisEngine.hs 55
-synthesiseTarget n =  setTarget n >> bestHypos >>= closeHypos
-
-setTarget :: Name -> IM()
-setTarget n = do
-    iod <- gets iodata
-    put $ initIgor iod n
-
-bestHypos :: IM Hypos
-bestHypos = liftM HS.bestHypos $ gets searchSpace
+synthesiseTarget n =  setTarget n >> currentBestHypos >>= closeHypos
hunk ./src/SynthesisEngine.hs 59
-    let openrules = H.fold collect F.empty hs
-    if F.null openrules
+    let openrules = foldHs collect emptyFs hs
+    if nullFs openrules
hunk ./src/SynthesisEngine.hs 62
-      else do advanceRule (chooseOneRule openrules) >> bestHypos >>= closeHypos
+      else do advanceRule (chooseOneRule openrules) >> currentBestHypos >>= closeHypos
hunk ./src/SynthesisEngine.hs 64
-    chooseOneRule = S.findMin.F.toSet
-    collect = (\h rs -> F.union (open h) rs)
+    chooseOneRule = S.findMin.fragsToSet
+    collect = (\h rs -> unionFs (open h) rs)
hunk ./src/SynthesisEngine.hs 68
-stopWith hs = return $ M.toList.clsd.chooseOneHypo $ H.toList hs
+stopWith hs = return $ M.toList.clsd.chooseOneHypo $ hyposToList hs
hunk ./src/Terms.hs 10
---                           ( Dec (FunD)
---                           , Clause (Clause)
---                           , Body (NormalB)
---                           , Name, mkName
---                           , Exp (VarE, ConE, LitE, ListE, TupE, InfixE, AppE, CondE)
---                           , Pat (VarP, ConP, LitP, ListP, TupP, IifixP)
---                           , Q(..))
+                           ( Dec (FunD)
+                           , Clause (Clause)
+                           , Body (NormalB)
+                           , Name, mkName
+                           , Exp (VarE, ConE, LitE, ListE, TupE, InfixE, AppE, CondE)
+                           , Pat (VarP, ConP, LitP, ListP, TupP, InfixP)
+                           , Q(..))
hunk ./src/Terms/Antiunifier.hs 8
-      Antiunifieable (
-        antiunify      -- :: (Antiunifieable k v t) => [t] -> t
+    Antiunifieable (
+        antiunify,        -- :: (Antiunifieable k v t) => [t] -> t
+        antiunifyWithMap, -- ::  (Antiunifieable k v t) => (VarMap k v) -> [t] -> LM t
+        antiunify2        -- :: (Antiunifieable k v t') => [[t]] -> [t'] -> LM ([t],t')
hunk ./src/Terms/Antiunifier.hs 22
-import Data.Rules (Rule, rule, lhs, rhs)    
hunk ./src/Terms/Antiunifier.hs 99
-class (Show v, Show k, Show t) => Antiunifieable k v t |t -> k v where
+class (Term v, Term k, Term t) => Antiunifieable k v t |t -> k v where
hunk ./src/Terms/Antiunifier.hs 108
+    {- | Convenience function to antiunify different kind of terms, but keeping 
+         track of the VarMap. @antiunify2 t1 t2@ corresponds approcimately to 
+         @liftM2 (,) (mapM antiunify t1) (antiunify t2)@, where the latter 
+         antiunify uses the VarMap of the further. 
+         This is needed to antiunify all patterns on the lhs and the rhs of 
+         multiple rules.
+    -}
+    antiunify2        :: (Antiunifieable k v t') => [[t]] -> [t'] -> LM ([t],t')
+    antiunify2 ts ts' = do
+            (ait,varmap) <- runAU ((mapM aunify) ts) M.empty
+            ait'         <- antiunifyWithMap varmap ts'
+            return (ait,ait')    
+        
hunk ./src/Terms/Antiunifier.hs 147
-  TODO: good coding style??? 
+  TODO: good coding style??? NO, Dec, body etc are not terms!!
hunk ./src/Terms/Antiunifier.hs 150
-instance Antiunifieable Exp Exp Dec where    
-    toKey                      = 
-        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
-                   "function definitions!"
-    fromVal  = 
-        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
-               "function definitions!"
-    mkVar                      = 
-        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
-               "function definitions!"
-    aunify [FunD name clauses] = 
-        do ai_clauses <- lift $ antiunify clauses
-           return $ FunD name [ai_clauses]
-    aunify [] = 
-        fail $ "Antiunifier.aunify: empty list of Dec, no terms to antiunify"
-    aunify (_:_)               =
-        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
-                "function definitions!"
-
-{-
-   The result state of anitunifying the patterns is passed to the 
-   antiunification of the expression on the right-hand side. This is necessary 
-   because the same terms may occur both on the lhs and on the rhs, here as 
-   patterns 'Pat' there as expressions 'Exp'.
-   
-   Same as with 'Antiunifieable Exp Exp Dec', all other functions yield a 
-   'fail'.   
-    
--}        
-instance Antiunifieable Exp Exp Clause where 
-    toKey = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Clause!"
-    fromVal = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Clause!"
-    mkVar = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Clause!"
-                
-    {- If all elements in the provided list are 'Clauses's the result is just 
-       a tuple with their patterns 'pat' i.e. a list of patern lists, their 
-       'bodies' and their declarations 'dec', 'Nothing' otherwise.
-       To antiunify the patterns we transpose the pattern list, to antiunify
-       all nth pattern of the clauses. 
-       We don't care about the 'dec' so we just put them all together. 
-       After antiunifying all patterns we pss the result state to the 
-       antiunification of the expressions.
-    -}
-    aunify l@((Clause _ _ _):xs)  =
-        case collectSubtermsC  l of
-            Just (pats,bodies,decs) -> 
-                do let tpats   = transpose pats
-                   let alldecs = concat decs
-                   (ai_pats,varmap) <- lift $ runAU ((mapM aunify) tpats) M.empty
-                   ai_bodies <- lift $ antiunifyWithMap varmap bodies
-                   return $ Clause ai_pats ai_bodies alldecs
-            Nothing   ->  
-                fail "Antiunifier.aunify: Cannot generalise over arbitrary clauses!"
-  
-  
-
-                
-{-|
-  Same as in the previous instance declarations. Here the state of antiunifying 
-  'Body's is simply passed to antiunifying 'Exp's.
--}                
-instance Antiunifieable Exp Exp Body where  
-    toKey (NormalB e)         = e
-    fromVal e                 = (NormalB e)
-    mkVar                     = (\_d i -> VarE $ mkName $ "x" ++ (show i))
-    
-    {-|
-       Same as above. Collect subterms, and antiunify them with the current 
-       state.
-    -}
-    aunify l@((NormalB _):xs) =
-        case collectSubtermsB l of
-            Just subterms -> 
-                do varmap <- get 
-                   ai_exps <- lift $ antiunifyWithMap varmap  subterms
-                   return $ NormalB ai_exps
-            Nothing       -> 
-                computeAntiInstance l
-    aunify [] = fail "Antiunifier.aunify: empty list, no terms to antiunify"
-    aunify (x:_) = 
-        fail $ "Antiunifier.aunify: Antiunification for " ++ show x ++
-                "of Type Body is not implemented!"
-                
-instance Antiunifieable Exp Exp Rule where 
-    toKey = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Rule!"
-    fromVal = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Rule!"
-    mkVar = 
-        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
-                "number of patterns in Rule!"
-       
-    aunify rules  = do
-        let tlhss   = transpose $ map lhs rules
-        let rhss    = map rhs rules
-        (ailhs,varmap) <- lift $ runAU ((mapM aunify) tlhss) M.empty
-        airhs         <- lift $ antiunifyWithMap varmap rhss
-        return $ rule ailhs airhs                
+--instance Antiunifieable Exp Exp Dec where    
+--    toKey                      = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
+--                   "function definitions!"
+--    fromVal  = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
+--               "function definitions!"
+--    mkVar                      = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
+--               "function definitions!"
+--    aunify [FunD name clauses] = 
+--        do ai_clauses <- lift $ antiunify clauses
+--           return $ FunD name [ai_clauses]
+--    aunify [] = 
+--        fail $ "Antiunifier.aunify: empty list of Dec, no terms to antiunify"
+--    aunify (_:_)               =
+--        fail $ "Antiunifier.aunify: Cannot generalise over arbitrary " ++
+--                "function definitions!"
+--
+--{-
+--   The result state of anitunifying the patterns is passed to the 
+--   antiunification of the expression on the right-hand side. This is necessary 
+--   because the same terms may occur both on the lhs and on the rhs, here as 
+--   patterns 'Pat' there as expressions 'Exp'.
+--   
+--   Same as with 'Antiunifieable Exp Exp Dec', all other functions yield a 
+--   'fail'.   
+--    
+---}        
+--instance Antiunifieable Exp Exp Clause where 
+--    toKey = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Clause!"
+--    fromVal = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Clause!"
+--    mkVar = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Clause!"
+--                
+--    {- If all elements in the provided list are 'Clauses's the result is just 
+--       a tuple with their patterns 'pat' i.e. a list of patern lists, their 
+--       'bodies' and their declarations 'dec', 'Nothing' otherwise.
+--       To antiunify the patterns we transpose the pattern list, to antiunify
+--       all nth pattern of the clauses. 
+--       We don't care about the 'dec' so we just put them all together. 
+--       After antiunifying all patterns we pss the result state to the 
+--       antiunification of the expressions.
+--    -}
+--    aunify l@((Clause _ _ _):xs)  =
+--        case collectSubtermsC  l of
+--            Just (pats,bodies,decs) -> 
+--                do let tpats   = transpose pats
+--                   let alldecs = concat decs
+--                   (ai_pats,varmap) <- lift $ runAU ((mapM aunify) tpats) M.empty
+--                   ai_bodies <- lift $ antiunifyWithMap varmap bodies
+--                   return $ Clause ai_pats ai_bodies alldecs
+--            Nothing   ->  
+--                fail "Antiunifier.aunify: Cannot generalise over arbitrary clauses!"
+--  
+--  
+--
+--                
+--{-|
+--  Same as in the previous instance declarations. Here the state of antiunifying 
+--  'Body's is simply passed to antiunifying 'Exp's.
+---}                
+--instance Antiunifieable Exp Exp Body where  
+--    toKey (NormalB e)         = e
+--    fromVal e                 = (NormalB e)
+--    mkVar                     = (\_d i -> VarE $ mkName $ "x" ++ (show i))
+--    
+--    {-|
+--       Same as above. Collect subterms, and antiunify them with the current 
+--       state.
+--    -}
+--    aunify l@((NormalB _):xs) =
+--        case collectSubtermsB l of
+--            Just subterms -> 
+--                do varmap <- get 
+--                   ai_exps <- lift $ antiunifyWithMap varmap  subterms
+--                   return $ NormalB ai_exps
+--            Nothing       -> 
+--                computeAntiInstance l
+--    aunify [] = fail "Antiunifier.aunify: empty list, no terms to antiunify"
+--    aunify (x:_) = 
+--        fail $ "Antiunifier.aunify: Antiunification for " ++ show x ++
+--                "of Type Body is not implemented!"
+--                
+--instance Antiunifieable Exp Exp Rule where 
+--    toKey = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Rule!"
+--    fromVal = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Rule!"
+--    mkVar = 
+--        fail $ "Antiunifier.aunify: Cannot generalise over an arbitrary " ++
+--                "number of patterns in Rule!"
+--       
+--    aunify rules  = do
+--        let tlhss   = transpose $ map lhs rules
+--        let rhss    = map rhs rules
+--        (ailhs,varmap) <- lift $ runAU ((mapM aunify) tlhss) M.empty
+--        airhs         <- lift $ antiunifyWithMap varmap rhss
+--        return $ rule ailhs airhs                