[outer Igor loop first implementation running (bug)
martin.hofmann@uni-bamberg.de**20081203144705
 <<loop>> somewhere in HypoSpace when deleting a hypo
] hunk ./src/Advancement.hs 9
-advanceRule :: RuleFrag -> IM ()
-advanceRule rf = do
-    part <- partition rf 
-    call <- functionCall rf
-    sub  <- subfunction rf
-    -- propagate advancemet of 'rf -> part' to all hypos in HSpace 
-    --
-    --
-    
-    return ()
hunk ./src/Advancement.hs 10
--- creates new partitions (i.e. RuleFragements) from one RuleFragement
--- the resulting rules may be closed by antiunification
--- and it should be assured, that each RuleFrag has only one open position
--- --> closing pairwise with functionCall and subfunction
-partition :: RuleFrag -> IM [(RuleFrag,[RuleFrag])]
-partition r = return []     --FIXME
-
--- introduces a function call
-functionCall :: 
-    RuleFrag ->             -- ^the rule to partition 
-                            --  FIXME: need covered target rules here) 
-    IM (RuleFrag,[RuleFrag]) -- ^the modified rule(now closed), and the 
-                            -- synthesised subfunctions
-functionCall r = return (r,[])          -- FIXME
--- TODO:
--- * uses abduce :: Rules -> Rules -> IM FunFragment
--- * find a Funfragment 'frag' in background knowledge which contains a rule f
---   for each rule in the rules covered by r (covering(r)) which matches its rhs
--- * create a new rule from 'r' by replacing its rhs by a function call to 'frag'
--- * for each argument of 'frag' abduce the I/O pairs for a subfunction which
---   returns the argument value from the input of r
--- * call Igor recursively to synthesise the subfunction. 
-   
-subfunction :: 
-    RuleFrag ->                 -- ^the rule to partition 
-                            --  FIXME: need covered target rules here) 
-    IM (RuleFrag,[RuleFrag]) -- ^the modified rule (now closed), and the 
-                            -- synthesised subfunctions
-subfunction r = return (r,[])          -- FIXME
--- TODO:
--- * uses abduce :: Rules -> Rules -> IM FunFragment
--- * replace every open variable by a call to a subfunction 
--- * abduce I/O pairs for every subfunction
--- * the abduced I/O pairs of each subfunction are added to the background 
---   knowledge (check if it is feasible to modify the IM at this point or 
---   better at top-level 
--- * synthesize every subfunction recursively. 
---   !!! 
---       If inserting the synthesized function into a hypothese,
---       a hypothese should never be strict  
---   !!!
- 
hunk ./src/Data/IgorData.hs 4
-import Data.IOData (IOData, emptyIOData, getByName)
+import Data.IOData (IOData, emptyIOData, getAll, getSpecifics)
hunk ./src/Data/IgorData.hs 12
-import Data.Hypotheses (Hypo, hypo)
+import Data.Hypotheses (Hypo, hypo, Call)
hunk ./src/IgorMonad.hs 6
-import Data.IgorData
+import Data.IgorData 
hunk ./src/IgorMonad.hs 11
-import qualified Data.Hypotheses as H (map, null,toList)
-import Data.Rules (Rules)
+
+--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/IgorMonad.hs 25
-import Advancement
+import Terms.Antiunifier
+import Logging 
+
+import Debug.Trace
hunk ./src/IgorMonad.hs 30
-type IM a = State Igor a 
+type IM a = StateT Igor LM a 
hunk ./src/IgorMonad.hs 32
-runIM = evalState
+runIM = evalStateT
hunk ./src/IgorMonad.hs 37
-synthesise :: Q [Dec] -> Q [Dec] -> Q [Dec] 
+startSynthesis :: Q [Dec] -> Q [Dec] -> IO()
+startSynthesis a b = runQ $
+    do tgt <- a
+       bgk <- b
+       let (r,l) = runEL  (synthesise tgt bgk)
+       runIO $ putStrLn "*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*"
+       runIO $ putStrLn "|                                 Logging Result                                |"
+       runIO $ putStrLn "*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*"
+       runIO $ putStrLn (view l)
+       runIO $ putStrLn "*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*"
+       runIO $ putStrLn "|                              Computational Result                             |"
+       runIO $ putStrLn "*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*"
+       runIO $ (printQ.return) r 
+    
+
+synthesise :: [Dec] -> [Dec] -> LM [Dec] 
hunk ./src/IgorMonad.hs 54
-    tgts <- liftM decs2rules tgtsQ --  [(Name,Rules)]
-    bgks <- liftM decs2rules bgksQ
-    tnms <- return $ map fst tgts
-    let igordata = setupIgor.initIOData $ tgts ++ bgks
-    return $ rules2decs $ runIM (synthesiseTargets tnms) igordata
+    tgts <- return $  decs2rules tgtsQ --  [(Name,Rules)]
+    bgks <- return $  decs2rules bgksQ
+    tnms <- return $  (map fst) tgts
+    allrs <- return $  (++) tgts bgks 
+    igordata <- return $  (setupIgor.initIOData) allrs
+    result <- runIM ( synthesiseTargets tnms) igordata 
+    return $ rules2decs result
hunk ./src/IgorMonad.hs 78
-closeHypos hs =  do
-    let rules = H.map open hs
-    if S.null rules
-      then return $ M.toList.clsd.chooseOneHypo $ H.toList hs
-      else advanceRule.chooseOneRule rules >> bestHypos >>= closeHypos
+closeHypos hs =  do  
+    let openrules = H.fold collect F.empty hs
+    if F.null openrules
+      then stopWith hs
+      else do -- advanceRule (chooseOneRule openrules) >> bestHypos >>= stopWith -- >>= closeHypos
+              advanceRule (chooseOneRule openrules) 
+              best <- bestHypos 
+              trace ("CurrentBEST: " ++ show best ) $ closeHypos best
+    where
+    chooseOneRule = S.findMin.F.toSet
+    collect = (\h rs -> F.union (open h) rs)
+     
+stopWith  :: Hypos -> IM [(Name,Rules)]
+stopWith hs = return $ M.toList.clsd.chooseOneHypo $ H.toList hs
hunk ./src/IgorMonad.hs 94
-    chooseOneRule = S.findMin
+  
+advanceRule :: RuleFrag -> IM ()
+advanceRule rf = do
+    (rf,rfs) <- trivialPartition rf
+    modify $! propagate $! (rf,rfs,[])
+    return ()
+
+trivialPartition :: RuleFrag -> IM (RuleFrag,RuleFrags)
+trivialPartition rf = do
+    iod <- gets iodata
+    let cov = covr rf
+    let n   = name rf
+    let (part1,part2) =  ([head cov],(tail cov))
+    let first = coverRules iod n part1
+    let rest  = coverRules iod n part2
+    return (rf,ruleFrags [first,rest])
+
+
+-- creates new partitions (i.e. RuleFragements) from one RuleFragement
+-- the resulting rules may be closed by antiunification
+-- and it should be assured, that each RuleFrag has only one open position
+-- --> closing pairwise with functionCall and subfunction
+partition :: RuleFrag -> IM [(RuleFrag,[RuleFrag])]
+partition r = return []     --FIXME
+
+-- introduces a function call
+functionCall :: 
+    RuleFrag ->             -- ^the rule to partition 
+                            --  FIXME: need covered target rules here) 
+    IM (RuleFrag,[RuleFrag]) -- ^the modified rule(now closed), and the 
+                            -- synthesised subfunctions
+functionCall r = return (r,[])          -- FIXME
+-- TODO:
+-- * uses abduce :: Rules -> Rules -> IM FunFragment
+-- * find a Funfragment 'frag' in background knowledge which contains a rule f
+--   for each rule in the rules covered by r (covering(r)) which matches its rhs
+-- * create a new rule from 'r' by replacing its rhs by a function call to 'frag'
+-- * for each argument of 'frag' abduce the I/O pairs for a subfunction which
+--   returns the argument value from the input of r
+-- * call Igor recursively to synthesise the subfunction. 
+   
+subfunction :: 
+    RuleFrag ->                 -- ^the rule to partition 
+                            --  FIXME: need covered target rules here) 
+    IM (RuleFrag,[RuleFrag]) -- ^the modified rule (now closed), and the 
+                            -- synthesised subfunctions
+subfunction r = return (r,[])          -- FIXME
+-- TODO:
+-- * uses abduce :: Rules -> Rules -> IM FunFragment
+-- * replace every open variable by a call to a subfunction 
+-- * abduce I/O pairs for every subfunction
+-- * the abduced I/O pairs of each subfunction are added to the background 
+--   knowledge (check if it is feasible to modify the IM at this point or 
+--   better at top-level 
+-- * synthesize every subfunction recursively. 
+--   !!! 
+--       If inserting the synthesized function into a hypothese,
+--       a hypothese should never be strict  
+--   !!!
+ 