Changeset 11229

Show
Ignore:
Timestamp:
07.01.2009 14:11:49 (10 months ago)
Author:
rpascanu
Message:

Changes to GUI to use common datatypes in Interfaces

Location:
trunk
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/GUI/GraphDisplay.hs

    r11173 r11229  
    4444import Control.Concurrent.MVar 
    4545 
     46import Interfaces.DataTypes 
     47 
    4648initializeConverter :: IO (GInfo,HTk.HTk) 
    4749initializeConverter = do 
     
    5456    graphInfo it is contained in and the conversion maps. -} 
    5557convertGraph :: ConvFunc 
    56 convertGraph gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    57                           , gi_GraphInfo = actGraphInfo 
    58                           , gi_LIB_NAME = libname 
     58convertGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    5959                          , windowCount = wc 
    6060                          }) title showLib = do 
    61   libEnv <- readIORef ioRefProofStatus 
    62   case Map.lookup libname libEnv of 
     61 ost <- readIORef $ intState gInfo 
     62 case i_state ost of  
     63  Nothing -> error "Something went wrong, no library loaded" 
     64  Just ist -> do 
     65   let libEnv = i_libEnv ist 
     66       libname = i_ln ist 
     67   case Map.lookup libname libEnv of 
    6368    Just dgraph -> do 
    6469      case openlock dgraph of 
     
    8792        Nothing -> do 
    8893          lock <- newEmptyMVar 
    89           writeIORef ioRefProofStatus 
    90             $ Map.insert libname dgraph{openlock = Just lock} libEnv 
     94          let nwle = Map.insert libname dgraph{openlock = Just lock} libEnv 
     95              nwst = ost { i_state = Just $ ist { i_libEnv = nwle}} 
     96          writeIORef (intState gInfo) nwst 
    9197          convertGraph gInfo title showLib 
    9298    Nothing -> error $ "development graph with libname " ++ show libname 
     
    96102-- return type equals the one of convertGraph 
    97103initializeGraph :: GInfo -> String -> LibFunc -> IO () 
    98 initializeGraph gInfo@(GInfo { gi_LIB_NAME = ln }) title showLib = do 
    99   let title' = (title ++ " for " ++ show ln) 
    100   createGraph gInfo title' (convertGraph) (showLib) 
     104initializeGraph gInfo title showLib = do 
     105 ost <- readIORef $ intState gInfo 
     106 case i_state ost of  
     107  Nothing -> return () 
     108  Just ist -> do 
     109   let ln = i_ln ist 
     110       title' = (title ++ " for " ++ show ln) 
     111   createGraph gInfo title' (convertGraph) (showLib) 
  • trunk/GUI/GraphLogic.hs

    r11173 r11229  
    107107import Control.Concurrent.MVar 
    108108 
     109import Interfaces.History 
     110import Interfaces.DataTypes 
     111 
    109112-- | Locks the global lock and runs function 
    110113runAndLock :: GInfo -> IO () -> IO () 
     
    127130-- | Undo one step of the History 
    128131undo :: GInfo -> Bool -> IO () 
    129 undo gInfo@(GInfo { globalHist = gHist 
    130                   , gi_GraphInfo = actGraph 
    131                   }) isUndo = do 
    132   (guHist, grHist) <- takeMVar gHist 
    133   case if isUndo then guHist else grHist of 
    134     [] -> do 
    135        GA.showTemporaryMessage actGraph "History is empty..." 
    136        putMVar gHist (guHist, grHist) 
    137     lns : gHist' -> do 
    138       undoDGraphs gInfo isUndo lns 
    139       putMVar gHist $ if isUndo then (gHist', reverse lns : grHist) 
    140                                 else (reverse lns : guHist, gHist') 
    141  
    142 undoDGraphs :: GInfo -> Bool -> [LIB_NAME] -> IO () 
    143 undoDGraphs g u = mapM_ $ undoDGraph g u 
    144  
    145 undoDGraph :: GInfo -> Bool -> LIB_NAME -> IO () 
    146 undoDGraph gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    147                         , gi_GraphInfo = actGraph 
    148                         }) isUndo ln = do 
    149   GA.showTemporaryMessage actGraph $ 
    150         (if isUndo then "Un" else "Re") ++ "do last change to " 
    151         ++ show ln ++ "..." 
    152   lockGlobal gInfo 
    153   le <- readIORef ioRefProofStatus 
    154   let 
    155     dg = lookupDGraph ln le 
    156     (dg', changes) = (if isUndo then undoHistStep else redoHistStep) dg 
    157   writeIORef ioRefProofStatus $ Map.insert ln dg' le 
    158   case openlock dg' of 
    159     Nothing -> return () 
    160     Just lock -> do 
    161       mvar <- tryTakeMVar lock 
    162       case mvar of 
    163         Nothing -> return () 
    164         Just applyHist -> do 
    165           applyHist changes 
    166           putMVar lock applyHist 
    167   unlockGlobal gInfo 
     132undo gInfo@(GInfo { gi_GraphInfo = actGraph }) isUndo =  
     133 do 
     134  intSt <- readIORef $ intState gInfo 
     135  let nwSt = if isUndo then undoOneStep intSt else redoOneStep intSt  
     136  writeIORef (intState gInfo) nwSt 
     137  remakeGraph gInfo 
    168138 
    169139-- | reloads the Library of the DevGraph 
    170140reload :: GInfo -> IO() 
    171 reload gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    172                     , gi_LIB_NAME = ln 
    173                     , gi_hetcatsOpts = opts 
     141reload gInfo@(GInfo { gi_hetcatsOpts = opts 
    174142                    , gi_GraphInfo = actGraphInfo 
    175143                    }) = do 
    176144  lockGlobal gInfo 
    177   oldle <- readIORef ioRefProofStatus 
    178   let 
    179     libdeps = Rel.toList $ Rel.intransKernel $ Rel.transClosure $ Rel.fromList 
     145  oldst <- readIORef $ intState gInfo 
     146  case i_state oldst of  
     147   Nothing -> do  
     148               unlockGlobal gInfo 
     149               return () 
     150   Just ist -> do 
     151    let 
     152     oldle = i_libEnv ist 
     153     ln = i_ln ist 
     154     libdeps =Rel.toList$ Rel.intransKernel$ Rel.transClosure$ Rel.fromList 
    180155              $ getLibDeps oldle 
    181   ioruplibs <- newIORef ([] :: [LIB_NAME]) 
    182   writeIORef ioruplibs [] 
    183   reloadLibs ioRefProofStatus opts libdeps ioruplibs ln 
    184   unlockGlobal gInfo 
    185   libs <- readIORef ioruplibs 
    186   case libs of 
    187     [] -> GA.showTemporaryMessage actGraphInfo "Reload not needed!" 
    188     _ -> remakeGraph gInfo 
     156    ioruplibs <- newIORef ([] :: [LIB_NAME]) 
     157    writeIORef ioruplibs [] 
     158    reloadLibs (intState gInfo) opts libdeps ioruplibs ln 
     159    unlockGlobal gInfo 
     160    libs <- readIORef ioruplibs 
     161    case libs of 
     162      [] -> GA.showTemporaryMessage actGraphInfo "Reload not needed!" 
     163      _ -> remakeGraph gInfo 
    189164 
    190165-- | Creates a list of all LIB_NAME pairs, which have a dependency 
     
    199174 
    200175-- | Reloads a library 
    201 reloadLib :: IORef LibEnv -> HetcatsOpts -> IORef [LIB_NAME] -> LIB_NAME 
     176reloadLib :: IORef IntState -> HetcatsOpts -> IORef [LIB_NAME] -> LIB_NAME 
    202177          -> IO () 
    203 reloadLib iorle opts ioruplibs ln = do 
    204   mfile <- existsAnSource opts {intype = GuessIn} 
     178reloadLib iorst opts ioruplibs ln = do 
     179 ost <- readIORef iorst  
     180 case i_state ost of  
     181  Nothing -> return () 
     182  Just ist -> do 
     183   mfile <- existsAnSource opts {intype = GuessIn} 
    205184           $ rmSuffix $ libNameToFile opts ln 
    206   case mfile of 
     185   case mfile of 
    207186    Nothing -> return () 
    208187    Just file -> do 
    209       le <- readIORef iorle 
     188      let le = i_libEnv ist 
    210189      mFunc <- case openlock $ lookupDGraph ln le of 
    211190        Just lock -> tryTakeMVar lock 
     
    224203                                     "Reload: Can't set openlock in DevGraph" 
    225204            Nothing -> return () 
    226           writeIORef iorle $ newle 
     205          let nwst = ost { i_state = Just ist {  
     206                                       i_libEnv = newle } } 
     207          writeIORef iorst $ nwst 
    227208        Nothing -> 
    228209          errorDialog "Error" $ "Error when reloading file " ++ show file 
    229210 
    230211-- | Reloads libraries if nessesary 
    231 reloadLibs :: IORef LibEnv -> HetcatsOpts -> [(LIB_NAME, LIB_NAME)] 
     212reloadLibs :: IORef IntState -> HetcatsOpts -> [(LIB_NAME, LIB_NAME)] 
    232213           -> IORef [LIB_NAME] -> LIB_NAME -> IO Bool 
    233 reloadLibs iorle opts deps ioruplibs ln = do 
    234   uplibs <- readIORef ioruplibs 
    235   case elem ln uplibs of 
     214reloadLibs iorst opts deps ioruplibs ln = do 
     215 ost <- readIORef iorst 
     216 case i_state ost of  
     217  Nothing -> return False 
     218  Just ist -> do 
     219   uplibs <- readIORef ioruplibs 
     220   case elem ln uplibs of 
    236221    True -> return True 
    237222    False -> do 
    238223      let 
    239224        deps' = map (snd) $ filter (\ (ln',_) -> ln == ln') deps 
    240       res <- mapM (reloadLibs iorle opts deps ioruplibs) deps' 
     225      res <- mapM (reloadLibs iorst opts deps ioruplibs) deps' 
    241226      let 
    242227        libupdate = foldl (\ u r -> if r then True else u) False res 
    243228      case libupdate of 
    244229        True -> do 
    245           reloadLib iorle opts ioruplibs ln 
     230          reloadLib iorst opts ioruplibs ln 
    246231          return True 
    247232        False -> do 
    248           le <- readIORef iorle 
    249           let 
    250             newln:_ = filter (ln ==) $ Map.keys le 
    251           mfile <- existsAnSource opts $ rmSuffix $ libNameToFile opts ln 
    252           case mfile of 
    253             Nothing -> return False 
    254             Just file -> do 
    255               newmt <- getModificationTime file 
    256               let 
     233          ost' <- readIORef iorst 
     234          case i_state ost' of  
     235           Nothing -> return False 
     236           Just ist' -> do 
     237            let le = i_libEnv ist' 
     238            let 
     239             newln:_ = filter (ln ==) $ Map.keys le 
     240            mfile <- existsAnSource opts $ rmSuffix $ libNameToFile opts ln 
     241            case mfile of 
     242              Nothing -> return False 
     243              Just file -> do 
     244               newmt <- getModificationTime file 
     245               let 
    257246                libupdate' = (getModTime $ getLIB_ID newln) < newmt 
    258               case libupdate' of 
     247               case libupdate' of 
    259248                False -> return False 
    260249                True -> do 
    261                   reloadLib iorle opts ioruplibs ln 
     250                  reloadLib iorst opts ioruplibs ln 
    262251                  return True 
    263252 
    264253-- | Deletes the old edges and nodes of the Graph and makes new ones 
    265254remakeGraph :: GInfo -> IO () 
    266 remakeGraph gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    267                          , gi_LIB_NAME = ln 
    268                          , gi_GraphInfo = actGraphInfo 
     255remakeGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    269256                         }) = do 
    270   le <- readIORef ioRefProofStatus 
    271   let 
    272     dgraph = lookupDGraph ln le 
    273   showNodes gInfo 
    274   GA.clear actGraphInfo 
    275   convert actGraphInfo dgraph 
    276   hideNodes gInfo 
     257  ost <- readIORef $ intState gInfo 
     258  case i_state ost of  
     259   Nothing -> return () 
     260   Just ist -> do 
     261    let le = i_libEnv ist 
     262        ln = i_ln ist 
     263        dgraph = lookupDGraph ln le 
     264    showNodes gInfo 
     265    GA.clear actGraphInfo 
     266    convert actGraphInfo dgraph 
     267    hideNodes gInfo 
    277268 
    278269-- | Toggles to display internal node names 
     
    301292-- | hides all unnamed internal nodes that are proven 
    302293hideNodes :: GInfo -> IO () 
    303 hideNodes (GInfo { libEnvIORef = ioRefProofStatus 
    304                  , gi_LIB_NAME = ln 
    305                  , gi_GraphInfo = actGraphInfo 
     294hideNodes gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    306295                 }) = do 
    307296  hhn <- GA.hasHiddenNodes actGraphInfo 
    308   case hhn of 
    309     True -> 
    310       GA.showTemporaryMessage actGraphInfo "Nodes already hidden ..." 
    311     False -> do 
    312       GA.showTemporaryMessage actGraphInfo "Hiding unnamed nodes..." 
    313       le <- readIORef ioRefProofStatus 
    314       let dg = lookupDGraph ln le 
    315           nodes = selectNodesByType dg [DGNodeType 
     297  ost <- readIORef $ intState gInfo 
     298  case i_state ost of  
     299   Nothing -> return () 
     300   Just ist -> do  
     301    case hhn of 
     302     True -> 
     303       GA.showTemporaryMessage actGraphInfo "Nodes already hidden ..." 
     304     False -> do 
     305       GA.showTemporaryMessage actGraphInfo "Hiding unnamed nodes..." 
     306       let le = i_libEnv ist 
     307           ln = i_ln ist 
     308           dg = lookupDGraph ln le 
     309           nodes = selectNodesByType dg [DGNodeType 
    316310                                         {nonRefType = NonRefType 
    317311                                           {isProvenCons = True 
    318312                                           , isInternalSpec = True} 
    319313                                         , isLocallyEmpty = True}] 
    320           edges = getCompressedEdges dg nodes 
    321       GA.hideNodes actGraphInfo nodes edges 
     314           edges = getCompressedEdges dg nodes 
     315       GA.hideNodes actGraphInfo nodes edges 
    322316 
    323317-- | selects all nodes of a type with outgoing edges 
     
    382376-- | Let the user select a Node to focus 
    383377focusNode :: GInfo -> IO () 
    384 focusNode GInfo { libEnvIORef = ioRefProofStatus 
    385                 , gi_LIB_NAME = ln 
    386                 , gi_GraphInfo = grInfo } = do 
    387   le <- readIORef ioRefProofStatus 
    388   idsnodes <- filterM (fmap not . GA.isHiddenNode grInfo . fst) 
     378focusNode gInfo@(GInfo { gi_GraphInfo = grInfo }) = do 
     379 ost <- readIORef $ intState gInfo 
     380 case i_state ost of  
     381  Nothing -> return () 
     382  Just ist -> do 
     383   let le = i_libEnv ist 
     384       ln = i_ln ist 
     385   idsnodes <- filterM (fmap not . GA.isHiddenNode grInfo . fst) 
    389386                    $ labNodesDG $ lookupDGraph ln le 
    390   selection <- listBox "Select a node to focus" 
    391     $ map (\ (n, l) -> shows n " " ++ getDGNodeName l) idsnodes 
    392   case selection of 
     387   selection <- listBox "Select a node to focus" 
     388     $ map (\ (n, l) -> shows n " " ++ getDGNodeName l) idsnodes 
     389   case selection of 
    393390    Just idx -> GA.focusNode grInfo $ fst $ idsnodes !! idx 
    394391    Nothing -> return () 
    395392 
    396393translateGraph :: GInfo -> ConvFunc -> LibFunc -> IO () 
    397 translateGraph (GInfo {libEnvIORef = ioRefProofStatus, 
    398                        gi_LIB_NAME = ln, 
    399                        gi_hetcatsOpts = opts 
     394translateGraph gInfo@(GInfo { gi_hetcatsOpts = opts 
    400395                      }) convGraph showLib = do 
    401   le <- readIORef ioRefProofStatus 
    402   openTranslateGraph le ln opts (getDGLogic le) convGraph showLib 
     396 ost <- readIORef $ intState gInfo 
     397 case i_state ost of  
     398  Nothing -> return () 
     399  Just ist -> do  
     400   let le = i_libEnv ist 
     401       ln = i_ln ist 
     402   openTranslateGraph le ln opts (getDGLogic le) convGraph showLib 
    403403 
    404404showLibGraph :: GInfo -> LibFunc -> IO () 
     
    431431 
    432432saveProofStatus :: GInfo -> FilePath -> IO () 
    433 saveProofStatus (GInfo { libEnvIORef = ioRefProofStatus 
    434                        , gi_LIB_NAME = ln 
    435                        , gi_hetcatsOpts = opts 
     433saveProofStatus gInfo@(GInfo { gi_hetcatsOpts = opts 
    436434                       }) file = encapsulateWaitTermAct $ do 
    437     proofStatus <- readIORef ioRefProofStatus 
     435  ost <- readIORef $ intState gInfo 
     436  case i_state ost of  
     437   Nothing -> return () 
     438   Just ist -> do  
     439    let proofStatus = i_libEnv ist 
     440        ln = i_ln ist 
    438441    writeShATermFile file (ln, lookupHistory ln proofStatus) 
    439442    putIfVerbose opts 2 $ "Wrote " ++ file 
     
    442445openProofStatus :: GInfo -> FilePath -> ConvFunc -> LibFunc 
    443446                -> IO () 
    444 openProofStatus gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    445                              , gi_LIB_NAME = ln 
    446                              , gi_hetcatsOpts = opts 
     447openProofStatus gInfo@(GInfo { gi_hetcatsOpts = opts 
    447448                             }) file convGraph showLib = do 
     449 ost <- readIORef $ intState gInfo 
     450 case i_state ost of  
     451  Nothing -> return () 
     452  Just ist -> do 
     453    let ln = i_ln ist 
    448454    mh <- readVerbose opts ln file 
    449455    case mh of 
     
    462468                Just dg -> do 
    463469                    lockGlobal gInfo 
    464                     oldEnv <- readIORef ioRefProofStatus 
    465                     let proofStatus = Map.insert ln 
     470                    let oldEnv = i_libEnv ist 
     471                        proofStatus = Map.insert ln 
    466472                                      (applyProofHistory h dg) oldEnv 
    467                     writeIORef ioRefProofStatus proofStatus 
     473                        nwst = ost { i_state = Just ist { 
     474                                      i_libEnv = proofStatus } } 
     475                    writeIORef (intState gInfo) nwst 
    468476                    unlockGlobal gInfo 
    469477                    gInfo' <- copyGInfo gInfo ln 
     
    475483                    GA.activateGraphWindow actGraphInfo 
    476484 
    477 -- | apply a rule of the development graph calculus 
     485-- | apply a rule of the development graph calculus  
    478486proofMenu :: GInfo 
    479487             -> (LibEnv -> IO (Res.Result LibEnv)) 
    480488             -> IO () 
    481 proofMenu gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    482                        , gi_LIB_NAME = ln 
    483                        , gi_GraphInfo = actGraphInfo 
     489proofMenu gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    484490                       , gi_hetcatsOpts = hOpts 
    485491                       , proofGUIMVar = guiMVar 
    486                        , globalHist = gHist 
    487492                       }) proofFun = do 
    488   filled <- tryPutMVar guiMVar Nothing 
    489   if not filled 
     493 ost <- readIORef $ intState gInfo 
     494 case i_state ost of  
     495  Nothing -> return () 
     496  Just ist -> do 
     497   let ln = i_ln ist 
     498   filled <- tryPutMVar guiMVar Nothing 
     499   if not filled 
    490500    then readMVar guiMVar >>= 
    491501                  (maybe (putIfVerbose hOpts 0 "proofMenu: ignored Nothing") 
     
    497507    else do 
    498508      lockGlobal gInfo 
    499       proofStatus <- readIORef ioRefProofStatus 
     509      let proofStatus = i_libEnv ist 
    500510      putIfVerbose hOpts 4 "Proof started via \"Proofs\" menu" 
    501511      Res.Result ds res <- proofFun proofStatus 
     
    508518          let newGr = lookupDGraph ln newProofStatus 
    509519              history = snd $ splitHistory (lookupDGraph ln proofStatus) newGr 
    510           (guHist, grHist) <- takeMVar gHist 
    511520          doDump hOpts "PrintHistory" $ do 
    512521            putStrLn "History" 
    513522            print $ prettyHistory history 
    514           putMVar gHist 
    515            (calcGlobalHistory proofStatus newProofStatus : guHist, grHist) 
     523          let lln = map (\x-> [DgCommandChange x]) $ calcGlobalHistory  
     524                                                   proofStatus newProofStatus 
     525              nst = foldl (add2history "dg rule") ost lln  
     526      --        (calcGlobalHistory proofStatus newProofStatus : guHist, grHist) 
    516527          applyChanges actGraphInfo $ reverse 
    517528            $ flatHistory history 
    518           writeIORef ioRefProofStatus newProofStatus 
     529          let nwst = nst { i_state = Just ist { i_libEnv=newProofStatus}} 
     530          writeIORef (intState gInfo) nwst 
    519531          unlockGlobal gInfo 
    520532          hideShowNames gInfo False 
     
    545557   fetches the theory from a node inside the IO Monad 
    546558   (added by KL based on code in getTheoryOfNode) -} 
    547 lookupTheoryOfNode :: IORef LibEnv -> LIB_NAME -> Int 
     559lookupTheoryOfNode :: LibEnv -> LIB_NAME -> Int 
    548560                   -> IO (Res.Result (LibEnv, Node, G_theory)) 
    549 lookupTheoryOfNode proofStatusRef ln descr = do 
    550   libEnv <- readIORef proofStatusRef 
     561lookupTheoryOfNode libEnv ln descr = do 
    551562  return $ do 
    552563    (libEnv', gth) <- computeTheory True libEnv ln descr 
     
    562573used by the node menu defined in initializeGraph-} 
    563574getTheoryOfNode :: GInfo -> Int -> DGraph -> IO () 
    564 getTheoryOfNode gInfo@(GInfo { gi_LIB_NAME = ln 
    565                              , gi_GraphInfo = actGraphInfo 
    566                              , libEnvIORef = le 
     575getTheoryOfNode gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    567576                             }) descr dgraph = do 
    568  r <- lookupTheoryOfNode le ln descr 
    569  case r of 
    570   Res.Result ds res -> do 
    571     showDiagMess (gi_hetcatsOpts gInfo) ds 
    572     case res of 
     577 ost <- readIORef $ intState gInfo 
     578 case i_state ost of  
     579  Nothing -> return () 
     580  Just ist -> do 
     581   let le = i_libEnv ist 
     582       ln = i_ln ist 
     583   r <- lookupTheoryOfNode le ln descr 
     584   case r of 
     585    Res.Result ds res -> do 
     586     showDiagMess (gi_hetcatsOpts gInfo) ds 
     587     case res of 
    573588      (Just (le', n, gth)) -> do 
    574589        lockGlobal gInfo 
     
    576591                                 (addHasInHidingWarning dgraph n) gth 
    577592        let newGr = lookupDGraph ln le' 
    578         libEnv <- readIORef le 
    579         let history = snd $ splitHistory (lookupDGraph ln libEnv) newGr 
     593        let history = snd $ splitHistory (lookupDGraph ln le) newGr 
    580594        applyChanges actGraphInfo $ reverse $ flatHistory history 
    581         writeIORef le le' 
     595        let nwst = ost { i_state = Just $ist { i_libEnv = le'} } 
     596        writeIORef (intState gInfo) nwst 
    582597        unlockGlobal gInfo 
    583598      _ -> return () 
     
    587602translateTheoryOfNode :: GInfo -> Int -> DGraph -> IO () 
    588603translateTheoryOfNode 
    589   gInfo@(GInfo {gi_hetcatsOpts = opts, libEnvIORef = le}) node dgraph = do 
    590     libEnv <- readIORef le 
    591     let Res.Result ds mEnv = computeTheory False libEnv (gi_LIB_NAME gInfo) node 
     604  gInfo@(GInfo {gi_hetcatsOpts = opts}) node dgraph = do 
     605 ost <- readIORef $ intState gInfo 
     606 case i_state ost of  
     607  Nothing -> return () 
     608  Just ist -> do 
     609    let libEnv = i_libEnv ist 
     610        ln = i_ln ist 
     611        Res.Result ds mEnv = computeTheory False libEnv ln node 
    592612    case mEnv of 
    593613      Just (_, th@(G_theory lid sign _ sens _)) -> do 
     
    645665-- | start local theorem proving or consistency checking at a node 
    646666proveAtNode :: Bool -> GInfo -> Int -> DGraph -> IO () 
    647 proveAtNode checkCons gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    648                                    , gi_LIB_NAME = ln 
    649                                    , commandHist = ch }) descr dgraph = do 
    650   let dgn = labDG dgraph descr 
    651       libNode = (ln,descr) 
    652   (dgraph',dgn') <- case hasLock dgn of 
     667proveAtNode checkCons gInfo descr dgraph = do 
     668 ost <- readIORef $ intState gInfo 
     669 case i_state ost of  
     670  Nothing -> return () 
     671  Just ist -> do 
     672   let ln = i_ln ist 
     673       le = i_libEnv ist 
     674       dgn = labDG dgraph descr 
     675       libNode = (ln,descr) 
     676   (dgraph',dgn') <- case hasLock dgn of 
    653677    True -> return (dgraph, dgn) 
    654678    False -> do 
    655679      lockGlobal gInfo 
    656       le <- readIORef ioRefProofStatus 
    657680      (dgraph',dgn') <- initLocking (lookupDGraph ln le) (descr, dgn) 
    658       writeIORef ioRefProofStatus $ Map.insert ln dgraph' le 
     681      let nwle = Map.insert ln dgraph' le 
     682          nwst = ost { i_state = Just $ ist { i_libEnv = nwle} } 
     683      writeIORef (intState gInfo) nwst 
    659684      unlockGlobal gInfo 
    660685      return (dgraph',dgn') 
    661   locked <- tryLockLocal dgn' 
    662   case locked of 
     686   locked <- tryLockLocal dgn' 
     687   case locked of 
    663688    False -> do 
    664689      errorDialog "Error" "Proofwindow already open" 
    665690    True -> do 
    666691      let action = do 
    667             le <- readIORef ioRefProofStatus 
    668692            guiMVar <- newMVar Nothing 
    669693            res <- basicInferenceNode checkCons logicGraph libNode ln 
    670                 guiMVar le ch 
     694                guiMVar le 
     695            -- add to history ch 
    671696            runProveAtNode checkCons gInfo (descr, dgn') res 
    672697            unlockLocal dgn' 
     
    685710               -> Res.Result (LibEnv, Res.Result G_theory) -> IO () 
    686711runProveAtNode checkCons gInfo (v, dgnode) res = case maybeResult res of 
    687     Just (le, tres) -> do 
    688         let nodetext = getDGNodeName dgnode ++ " node: " ++ show v 
     712  Just (le, tres) -> do 
     713   ost <- readIORef $ intState gInfo 
     714   case i_state ost of  
     715    Nothing -> return () 
     716    Just ist -> do 
     717        let ln = i_ln ist 
     718            nodetext = getDGNodeName dgnode ++ " node: " ++ show v 
    689719        when checkCons $ case maybeResult tres of 
    690720          Just gth -> createTextSaveDisplay 
     
    695725              $ unlines $ "could not (re-)construct a model" : map diagString ds 
    696726        proofMenu gInfo $ mergeDGNodeLab gInfo 
    697           (v, labDG (lookupDGraph (gi_LIB_NAME gInfo) le) v) 
    698     Nothing -> return () 
     727          (v, labDG (lookupDGraph ln le) v) 
     728  Nothing -> return () 
    699729 
    700730mergeDGNodeLab :: GInfo -> LNode DGNodeLab -> LibEnv -> IO (Res.Result LibEnv) 
    701 mergeDGNodeLab (GInfo{gi_LIB_NAME = ln}) (v, new_dgn) le = do 
    702   let dg = lookupDGraph ln le 
    703       old_dgn = labDG dg v 
    704   return $ do 
     731mergeDGNodeLab gInfo (v, new_dgn) le = do 
     732 ost <- readIORef $ intState gInfo 
     733 case i_state ost of  
     734  Nothing -> return (Result [] (Just le)) 
     735  Just ist -> do 
     736   let ln = i_ln ist 
     737       dg = lookupDGraph ln le 
     738       old_dgn = labDG dg v 
     739   return $ do 
    705740    theory <- joinG_sentences (dgn_theory old_dgn) $ dgn_theory new_dgn 
    706741    let new_dgn' = old_dgn { dgn_theory = theory } 
     
    723758-- | check conservativity of the edge 
    724759checkconservativityOfEdge :: Int -> GInfo -> Maybe (LEdge DGLinkLab) -> IO () 
    725 checkconservativityOfEdge _ gInfo@(GInfo{gi_LIB_NAME = ln, 
    726                                          gi_GraphInfo = _actGraphInfo, 
    727                                          libEnvIORef = le}) 
     760checkconservativityOfEdge _ gInfo@(GInfo{ gi_GraphInfo = _actGraphInfo}) 
    728761                           (Just (source,target,linklab)) = do 
    729   lockGlobal gInfo 
    730   libEnv <- readIORef $ libEnvIORef gInfo 
    731   let libEnv' = case convertToNf ln libEnv target of 
    732                   Result _ (Just lE) -> lE 
    733                   _ -> error "checkconservativityOfEdge: convertToNf" 
    734   let (_, thTar) = 
     762 ost <- readIORef $ intState gInfo 
     763 case i_state ost of  
     764  Nothing -> return () 
     765  Just ist -> do 
     766   let ln = i_ln ist 
     767       libEnv = i_libEnv ist 
     768   lockGlobal gInfo 
     769   let libEnv' = case convertToNf ln libEnv target of 
     770                   Result _ (Just lE) -> lE 
     771                   _ -> error "checkconservativityOfEdge: convertToNf" 
     772   let (_, thTar) = 
    735773        case computeTheory True libEnv' ln target of 
    736774          Res.Result _ (Just th1) -> th1 
    737775          _ -> error "checkconservativityOfEdge: computeTheory" 
    738   G_theory lid _sign _ sensTar _ <- return thTar 
    739   GMorphism cid _ _ morphism2 _ <- return $ dgl_morphism linklab 
    740   Just (GMorphism cid' _ _ morphism3 _) <- return $ 
     776   G_theory lid _sign _ sensTar _ <- return thTar 
     777   GMorphism cid _ _ morphism2 _ <- return $ dgl_morphism linklab 
     778   Just (GMorphism cid' _ _ morphism3 _) <- return $ 
    741779                  dgn_sigma $ labDG (lookupDGraph ln libEnv') target 
    742   morphism2' <- coerceMorphism (targetLogic cid) lid 
     780   morphism2' <- coerceMorphism (targetLogic cid) lid 
    743781                "checkconservativityOfEdge2" morphism2 
    744   morphism3' <- coerceMorphism (targetLogic cid') lid 
     782   morphism3' <- coerceMorphism (targetLogic cid') lid 
    745783                "checkconservativityOfEdge3" morphism3 
    746   let compMor = case comp morphism2' morphism3' of 
    747                Res.Result _ (Just phi) -> phi 
    748                _ -> error "checkconservativtiyOfEdge: comp" 
    749   let (_le', thSrc) = 
    750         case computeTheory False libEnv' (gi_LIB_NAME gInfo) source of 
     784   let compMor = case comp morphism2' morphism3' of 
     785                Res.Result _ (Just phi) -> phi 
     786                _ -> error "checkconservativtiyOfEdge: comp" 
     787   let (_le', thSrc) = 
     788        case computeTheory False libEnv' ln source of 
    751789          Res.Result _ (Just th1) -> th1 
    752790          _ -> error "checkconservativityOfEdge: computeTheory" 
    753   G_theory lid1 sign1 _ sensSrc1 _ <- return thSrc 
    754   sign2 <- coerceSign lid1 lid "checkconservativityOfEdge.coerceSign" sign1 
    755   sensSrc2 <- coerceThSens lid1 lid "checkconservativityOfEdge1" sensSrc1 
    756   let transSensSrc = propagateErrors 
     791   G_theory lid1 sign1 _ sensSrc1 _ <- return thSrc 
     792   sign2 <- coerceSign lid1 lid "checkconservativityOfEdge.coerceSign" sign1 
     793   sensSrc2 <- coerceThSens lid1 lid "checkconservativityOfEdge1" sensSrc1 
     794   let transSensSrc = propagateErrors 
    757795        $ mapThSensValueM (map_sen lid compMor) sensSrc2 
    758   if length (conservativityCheck lid) < 1 
    759    then 
     796   if length (conservativityCheck lid) < 1 
     797    then 
    760798       do 
    761799        infoDialog "Result of conservativity check" 
    762800                   "No conservativity checkers available" 
    763         writeIORef le libEnv' 
     801        let nwst = ost {i_state = Just $ist{ i_libEnv=libEnv'}} 
     802        writeIORef (intState gInfo) nwst 
    764803        unlockGlobal gInfo 
    765    else 
    766     do 
    767      checkerR <- conservativityChoser $ conservativityCheck lid 
    768      if Res.hasErrors $ Res.diags checkerR 
    769       then 
    770        do 
    771         infoDialog "Result of conservativity check" 
    772                    "No conservativity checker chosen" 
    773         writeIORef le libEnv' 
    774         unlockGlobal gInfo 
    775       else 
    776        do 
    777         let chCons =  checkConservativity $ 
    778                       maybe (error "checkconservativityOfEdge4") id 
    779                             $ Res.maybeResult $ checkerR 
    780         let Res.Result ds res = 
    781                 chCons 
    782                    (plainSign sign2, toNamedList sensSrc2) 
    783                    compMor $ toNamedList 
    784                                (sensTar `OMap.difference` transSensSrc) 
    785             showObls [] = "" 
    786             showObls obls = ", provided that the following proof obligations " 
     804    else 
     805     do 
     806      checkerR <- conservativityChoser $ conservativityCheck lid 
     807      if Res.hasErrors $ Res.diags checkerR 
     808       then 
     809        do 
     810         infoDialog "Result of conservativity check" 
     811                    "No conservativity checker chosen" 
     812         let nwst = ost {i_state = Just $ ist { i_libEnv = libEnv'}} 
     813         writeIORef (intState gInfo) nwst 
     814         unlockGlobal gInfo 
     815       else 
     816        do 
     817         let chCons =  checkConservativity $ 
     818                       maybe (error "checkconservativityOfEdge4") id 
     819                             $ Res.maybeResult $ checkerR 
     820         let Res.Result ds res = 
     821                 chCons 
     822                    (plainSign sign2, toNamedList sensSrc2) 
     823                    compMor $ toNamedList 
     824                                (sensTar `OMap.difference` transSensSrc) 
     825             showObls [] = "" 
     826             showObls obls= ", provided that the following proof obligations " 
    787827                            ++ "can be discharged:\n" 
    788828                            ++ concatMap (flip showDoc "\n") obls 
    789             showRes = case res of 
     829             showRes = case res of 
    790830                       Just (Just (cst, obls)) -> "The link is " 
    791831                        ++ showConsistencyStatus cst ++ showObls obls 
    792832                       _ -> "Could not determine whether link is conservative" 
    793             myDiags = showRelDiags 2 ds 
    794         createTextDisplay "Result of conservativity check" 
    795                         (showRes ++ "\n" ++ myDiags) 
    796         let 
     833             myDiags = showRelDiags 2 ds 
     834         createTextDisplay "Result of conservativity check" 
     835                         (showRes ++ "\n" ++ myDiags) 
     836         let 
    797837            consShow = case res of 
    798838                        Just (Just (cst, _)) -> cst 
     
    813853            changes = [ DeleteEdge (source,target,linklab) 
    814854                      , InsertEdge provenEdge ] 
    815         let newGr = lookupDGraph ln libEnv' 
    816             nextGr = changesDGH newGr changes 
    817             newLibEnv = Map.insert ln 
     855         let newGr = lookupDGraph ln libEnv' 
     856             nextGr = changesDGH newGr changes 
     857             newLibEnv = Map.insert ln 
    818858              (groupHistory newGr conservativityRule nextGr) libEnv' 
    819         -- applyChanges actGraphInfo history 
    820         writeIORef le newLibEnv 
    821         unlockGlobal gInfo 
     859         -- applyChanges actGraphInfo history 
     860         let nwst = ost { i_state = Just $ ist { i_libEnv = newLibEnv}} 
     861         writeIORef (intState gInfo) nwst 
     862         unlockGlobal gInfo 
    822863 
    823864checkconservativityOfEdge descr _ Nothing = 
     
    876917-- | show library referened by a DGRef node (=node drawn as a box) 
    877918showReferencedLibrary :: Int -> GInfo -> ConvFunc -> LibFunc -> IO () 
    878 showReferencedLibrary descr gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    879                                          , gi_LIB_NAME = ln }) 
     919showReferencedLibrary descr gInfo 
    880920                      convGraph showLib = do 
    881   le <- readIORef ioRefProofStatus 
    882   let refNode =  labDG (lookupDGraph ln le) descr 
    883       refLibname = if isDGRef refNode then dgn_libname refNode 
    884                    else error "showReferencedLibrary" 
    885   case Map.lookup refLibname le of 
     921 ost <- readIORef $ intState gInfo 
     922 case i_state ost of  
     923  Nothing -> return () 
     924  Just ist -> do 
     925   let ln = i_ln ist 
     926       le = i_libEnv ist 
     927       refNode =  labDG (lookupDGraph ln le) descr 
     928       refLibname = if isDGRef refNode then dgn_libname refNode 
     929                    else error "showReferencedLibrary" 
     930   case Map.lookup refLibname le of 
    886931    Just _ -> do 
    887932      gInfo' <- copyGInfo gInfo refLibname 
     
    946991                   showDiagMess opts $ diagsSl ++ diagsTrans 
    947992                   dg_showGraphAux 
    948                                    (\gI@(GInfo{libEnvIORef = iorLE}) -> do 
    949                                      writeIORef iorLE newLibEnv 
    950                                      convGraph (gI{ gi_LIB_NAME = ln 
    951                                                   , gi_hetcatsOpts = opts}) 
     993                                   (\gI -> do 
     994                                     ost <- readIORef $ intState gI 
     995                                     let nwst = case i_state ost of 
     996                                                 Nothing -> ost 
     997                                                 Just ist ->  
     998                                                  ost{i_state = Just ist{ 
     999                                                       i_libEnv = newLibEnv, 
     1000                                                       i_ln = ln }} 
     1001                                     writeIORef (intState gI) nwst 
     1002                                     convGraph (gI{ gi_hetcatsOpts = opts}) 
    9521003                                               "translation Graph" showLib) 
    9531004                 Nothing -> myErrMess $ diagsSl ++ diagsTrans 
     
    9721023            -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) -> IO () 
    9731024saveUDGraph gInfo@(GInfo { gi_GraphInfo = graphInfo 
    974                          , gi_LIB_NAME = ln 
    9751025                         , gi_hetcatsOpts = opts 
    9761026                         }) nodemap linkmap = do 
    977   maybeFilePath <- fileSaveDialog ((rmSuffix $ libNameToFile opts ln) ++ ".udg") 
     1027  ost <- readIORef $ intState gInfo 
     1028  case i_state ost of  
     1029   Nothing -> return () 
     1030   Just ist -> do 
     1031    let ln = i_ln ist 
     1032    maybeFilePath <- fileSaveDialog ((rmSuffix $ libNameToFile opts ln) ++ ".udg") 
    9781033                                  [ ("uDrawGraph",["*.udg"]) 
    9791034                                  , ("All Files", ["*"])] Nothing 
    980   case maybeFilePath of 
    981     Just filepath -> do 
     1035    case maybeFilePath of 
     1036     Just filepath -> do 
    9821037      GA.showTemporaryMessage graphInfo "Converting graph..." 
    9831038      nstring <- nodes2String gInfo nodemap linkmap 
    9841039      writeFile filepath nstring 
    9851040      GA.showTemporaryMessage graphInfo $ "Graph stored to " ++ filepath ++ "!" 
    986     Nothing -> GA.showTemporaryMessage graphInfo $ "Aborted!" 
     1041     Nothing -> GA.showTemporaryMessage graphInfo $ "Aborted!" 
    9871042 
    9881043-- | Converts the nodes of the graph to String representation 
     
    9901045             -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) 
    9911046             -> IO String 
    992 nodes2String gInfo@(GInfo { gi_GraphInfo = graphInfo 
    993                           , gi_LIB_NAME = ln 
    994                           , libEnvIORef = ioRefProofStatus 
    995                           }) nodemap linkmap = do 
    996   le <- readIORef ioRefProofStatus 
    997   nodes <- filterM (\(n,_) -> do b <- GA.isHiddenNode graphInfo n 
    998                                  return $ not b) 
     1047nodes2String gInfo@(GInfo { gi_GraphInfo = graphInfo }) nodemap linkmap = do 
     1048 ost <- readIORef $ intState gInfo 
     1049 case i_state ost of  
     1050  Nothing -> return [] 
     1051  Just ist -> do 
     1052   let le = i_libEnv ist 
     1053       ln = i_ln ist 
     1054   nodes <- filterM (\(n,_) -> do b <- GA.isHiddenNode graphInfo n 
     1055                                  return $ not b) 
    9991056                    $ labNodesDG $ lookupDGraph ln le 
    1000   nstring <- foldM (\s node -> do 
     1057   nstring <- foldM (\s node -> do 
    10011058                     s' <- (node2String gInfo nodemap linkmap node) 
    10021059                     return $ s ++ (if s /= "" then ",\n " else "") ++ s') 
    10031060                   "" nodes 
    1004   return $ "[" ++ nstring ++ "]" 
     1061   return $ "[" ++ nstring ++ "]" 
    10051062 
    10061063-- | Converts a node to String representation 
     
    10261083links2String :: GInfo -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) 
    10271084             -> Int -> IO String 
    1028 links2String (GInfo { gi_GraphInfo = graphInfo 
    1029                     , gi_LIB_NAME = ln 
    1030                     , libEnvIORef = ioRefProofStatus 
     1085links2String gInfo@(GInfo { gi_GraphInfo = graphInfo 
    10311086                    })  linkmap nodeid = do 
    1032   le <- readIORef ioRefProofStatus 
    1033   edges <- filterM (\(src,_,edge) -> do 
     1087 ost <- readIORef $ intState gInfo 
     1088 case i_state ost of  
     1089  Nothing -> return [] 
     1090  Just ist -> do  
     1091   let ln = i_ln ist 
     1092       le = i_libEnv ist 
     1093   edges <- filterM (\(src,_,edge) -> do 
    10341094                      let eid = dgl_id edge 
    10351095                      b <- GA.isHiddenEdge graphInfo eid 
    10361096                      return $ (not b) && src == nodeid) 
    10371097                     $ labEdgesDG $ lookupDGraph ln le 
    1038   foldM (\s edge -> do 
     1098   foldM (\s edge -> do 
    10391099          s' <- link2String linkmap edge 
    10401100          return $ s ++ (if s /= "" then ",\n   " else "") ++ s') "" edges 
  • trunk/GUI/GraphMenu.hs

    r11173 r11229  
    5555 
    5656import Control.Concurrent.MVar 
     57 
     58 
     59import Interfaces.DataTypes 
     60import Interfaces.History  
    5761 
    5862-- | Adds to the DGNodeType list style options for each type 
     
    135139-- | Creates the graph. Runs makegraph 
    136140createGraph :: GInfo -> String -> ConvFunc -> LibFunc -> IO () 
    137 createGraph gInfo@(GInfo { gi_LIB_NAME = ln 
    138                          , gi_GraphInfo = actGraphInfo 
     141createGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 
    139142                         , gi_hetcatsOpts = opts 
    140143                         }) title convGraph showLib = do 
    141   let file = rmSuffix (libNameToFile opts ln) ++ prfSuffix 
    142   deselectEdgeTypes <- newIORef [] 
    143   GA.makegraphExt actGraphInfo 
     144 ost <- readIORef $ intState gInfo 
     145 case i_state ost of  
     146  Nothing -> return () 
     147  Just ist -> do 
     148   let ln = i_ln ist  
     149       file = rmSuffix (libNameToFile opts ln) ++ prfSuffix 
     150   deselectEdgeTypes <- newIORef [] 
     151   globMenu <- createGlobalMenu gInfo convGraph showLib deselectEdgeTypes 
     152   GA.makegraphExt actGraphInfo 
    144153                  title 
    145154                  (createOpen gInfo file convGraph showLib) 
     
    148157                  (createClose gInfo) 
    149158                  (Just (createExit gInfo)) 
    150                   (createGlobalMenu gInfo convGraph showLib deselectEdgeTypes) 
     159                  globMenu 
    151160                  (createNodeTypes gInfo convGraph showLib) 
    152161                  (createEdgeTypes gInfo) 
     
    182191-- | Returns the save-function 
    183192createClose :: GInfo -> IO Bool 
    184 createClose (GInfo { gi_LIB_NAME = ln 
    185                    , libEnvIORef = ioRefProofStatus 
    186                    , windowCount = wc 
     193createClose gInfo@(GInfo { windowCount = wc 
    187194                   , exitMVar = exit 
    188195                   }) = do 
    189   le <- readIORef ioRefProofStatus 
    190   case Map.lookup ln le of 
     196 ost <- readIORef $ intState gInfo 
     197 case i_state ost of  
     198  Nothing -> return False 
     199  Just ist -> do 
     200   let le = i_libEnv ist 
     201       ln = i_ln ist 
     202   case Map.lookup ln le of 
    191203    Just dgraph -> do 
    192204      case openlock dgraph of 
     
    199211    Nothing -> error $ "development graph with libname " ++ show ln 
    200212                       ++" does not exist" 
    201   count <- takeMVar wc 
    202   case count == 1 of 
     213   count <- takeMVar wc 
     214   case count == 1 of 
    203215    True -> putMVar exit () 
    204216    False -> putMVar wc $ count - 1 
    205   return True 
     217   return True 
    206218 
    207219-- | Returns the save-function 
     
    212224-- | Creates the global menu 
    213225createGlobalMenu :: GInfo -> ConvFunc -> LibFunc -> IORef [String] 
    214                  -> [GlobalMenu] 
    215 createGlobalMenu gInfo@(GInfo { gi_LIB_NAME = ln 
    216                               , gi_hetcatsOpts = opts 
    217                               , commandHist = ch 
     226                 -> IO [GlobalMenu] 
     227createGlobalMenu gInfo@(GInfo { gi_hetcatsOpts = opts 
    218228#ifdef GTKGLADE 
    219229                              , gi_GraphInfo = gi 
     
    222232                              }) convGraph showLib _ = 
    223233#endif 
    224   let ral x = runAndLock gInfo x in 
    225   [GlobalMenu (Menu Nothing 
    226     [ Button "Undo" $ ral $ undo gInfo True 
    227     , Button "Redo" $ ral $ undo gInfo False 
    228     , Button "Reload" $ ral $ reload gInfo 
    229     , Menu (Just "Unnamed nodes") 
     234 do  
     235 ost <- readIORef $ intState gInfo 
     236 case i_state ost of  
     237  Nothing -> return [] 
     238  Just ist -> do 
     239   let ral x = runAndLock gInfo x  
     240       ln = i_ln ist 
     241   return  
     242    [GlobalMenu (Menu Nothing 
     243     [ Button "Undo" $ ral $ undo gInfo True 
     244     , Button "Redo" $ ral $ undo gInfo False 
     245     , Button "Reload" $ ral $ reload gInfo 
     246     , Menu (Just "Unnamed nodes") 
    230247        [ Button "Hide/show names" $ ral $ hideShowNames gInfo True 
    231248        , Button "Hide nodes" $ ral $ hideNodes gInfo 
    232249        , Button "Show nodes" $ ral $ showNodes gInfo 
    233250      ] 
    234     , Button "Focus node" $ ral $ focusNode gInfo 
     251     , Button "Focus node" $ ral $ focusNode gInfo 
    235252#ifdef GTKGLADE 
    236     , Button "Select Linktypes" $ showLinkTypeChoice deselectEdgeTypes 
     253     , Button "Select Linktypes" $ showLinkTypeChoice deselectEdgeTypes 
    237254                                $ (\ eList -> ral $ do 
    238255                                    GA.showAll gi 
     
    241258                                  ) 
    242259#endif 
    243     , Menu (Just "Proofs") $ map (\ (str, cmd) -> 
    244        Button str $ addMenuItemToHist ch str >> 
    245                   (ral $ performProofAction gInfo 
     260     , Menu (Just "Proofs") $ map (\ (str, cmd) -> 
     261       -- History ? or just some partial history in ch ? 
     262        Button str $ (ral $ performProofAction gInfo 
    246263                  $ proofMenu gInfo $ return . return . cmd ln 
    247264                  . Map.map undoRedo)) 
    248        [ ("Automatic", automatic) 
    249        , ("Global Subsumption", globSubsume) 
    250        , ("Global Decomposition", globDecomp) 
    251        , ("Local Inference", localInference) 
    252        , ("Local Decomposition (merge of rules)", locDecomp) 
    253        , ("Composition (merge of rules)", composition) 
    254        , ("Composition - creating new links", compositionCreatingEdges) 
    255        ] ++ 
    256        [Button "Hide Theorem Shift" $ 
    257                (addMenuItemToHist ch "Hide Theorem Shift") >> 
     265        [ ("Automatic", automatic) 
     266        , ("Global Subsumption", globSubsume) 
     267        , ("Global Decomposition", globDecomp) 
     268        , ("Local Inference", localInference) 
     269        , ("Local Decomposition (merge of rules)", locDecomp) 
     270        , ("Composition (merge of rules)", composition) 
     271        , ("Composition - creating new links", compositionCreatingEdges) 
     272        ] ++ 
     273        [Button "Hide Theorem Shift" $ 
     274               -- (addMenuItemToHist ch "Hide Theorem Shift") >> 
    258275               (ral $ performProofAction gInfo 
    259276               $ proofMenu gInfo $ fmap return . interactiveHideTheoremShift ln) 
    260        ] ++ 
    261        map (\ (str, cmd) -> 
    262               Button str $ (addMenuItemToHist ch str) >> 
    263                   (ral $ performProofAction gInfo 
    264                   $ proofMenu gInfo $ return . cmd ln)) 
    265        [ ("Theorem Hide Shift", theoremHideShift) 
    266        , ("Compute Colimit", computeColimit) 
    267        , ("Compute normal forms", convertNodesToNf) 
    268        ] ++ 
    269        [ Menu (Just "Flattening") $ map ( \ (str, cmd) -> 
    270           Button str $ ral $ performProofAction gInfo 
    271                      $ proofMenu gInfo $ return . cmd) 
    272              [ ("Importings", libEnv_flattening_imports) 
    273              , ("Disjoint unions", libEnv_flattening_dunions) 
    274              , ("Importings and renamings", libEnv_flattening_renamings) 
    275              , ("Hiding", libEnv_flattening_hiding) 
    276              , ("Heterogeneity", libEnv_flattening_heterogen) 
    277              , ("Qualify all names", qualifyLibEnv)]] 
    278     , Button "Dump LibEnv" $ do 
    279          le <- readIORef $ libEnvIORef gInfo 
    280          print $ prettyLibEnv le 
    281     , Button "Translate Graph" $ ral $ translateGraph gInfo convGraph showLib 
    282     , Button "Show Logic Graph" $ ral $ showLogicGraph daVinciSort 
    283     , Button "Show Library Graph" $ ral $ showLibGraph gInfo showLib 
    284     , Button "Save Graph for uDrawGraph" $ ral 
    285              $ saveUDGraph gInfo (mapNodeTypes opts) $ mapEdgeTypes opts 
    286     , Button "Save proof-script" $ ral 
    287              $ askSaveProofScript (gi_GraphInfo gInfo) ch 
    288     ]) 
    289   ] 
     277        ] ++ 
     278        map (\ (str, cmd) -> 
     279               Button str $ -- (addMenuItemToHist ch str) >> 
     280                   (ral $ performProofAction gInfo 
     281                   $ proofMenu gInfo $ return . cmd ln)) 
     282        [ ("Theorem Hide Shift", theoremHideShift) 
     283        , ("Compute Colimit", computeColimit) 
     284        , ("Compute normal forms", convertNodesToNf) 
     285        ] ++ 
     286        [ Menu (Just "Flattening") $ map ( \ (str, cmd) -> 
     287           Button str $ ral $ performProofAction gInfo 
     288                      $ proofMenu gInfo $ return . cmd) 
     289              [ ("Importings", libEnv_flattening_imports) 
     290              , ("Disjoint unions", libEnv_flattening_dunions) 
     291              , ("Importings and renamings", libEnv_flattening_renamings) 
     292              , ("Hiding", libEnv_flattening_hiding) 
     293              , ("Heterogeneity", libEnv_flattening_heterogen) 
     294              , ("Qualify all names", qualifyLibEnv)]] 
     295     , Button "Dump LibEnv" $ do 
     296          let le = i_libEnv ist 
     297          print $ prettyLibEnv le 
     298     , Button "Translate Graph" $ ral $ translateGraph gInfo convGraph showLib 
     299     , Button "Show Logic Graph" $ ral $ showLogicGraph daVinciSort 
     300     , Button "Show Library Graph" $ ral $ showLibGraph gInfo showLib 
     301     , Button "Save Graph for uDrawGraph" $ ral 
     302              $ saveUDGraph gInfo (mapNodeTypes opts) $ mapEdgeTypes opts 
     303--     , Button "Save proof-script" $ ral 
     304--              $ askSaveProofScript (gi_GraphInfo gInfo) ch 
     305     ]) 
     306    ] 
    290307 
    291308-- | A list of all Node Types 
     
    383400                    (Button title 
    384401                      (\ (_, descr) -> 
    385                         do le <- readIORef $ libEnvIORef gInfo 
    386                            let dGraph = lookupDGraph (gi_LIB_NAME gInfo) le 
     402                        do  
     403                         ost <- readIORef $ intState gInfo 
     404                         case i_state ost of  
     405                          Nothing -> return () 
     406                          Just ist -> do  
     407                           let le = i_libEnv ist 
     408                               ln = i_ln ist 
     409                               dGraph = lookupDGraph ln le 
    387410                           runAndLock gInfo $  menuFun descr dGraph 
    388411                           return () 
     
    403426-} 
    404427createLocalMenuTaxonomy :: GInfo -> ButtonMenu GA.NodeValue 
    405 createLocalMenuTaxonomy ginfo@(GInfo { gi_LIB_NAME = ln 
    406                                      , libEnvIORef = le }) = 
     428createLocalMenuTaxonomy ginfo = 
    407429  (Menu (Just "Taxonomy graphs") 
    408430        [ createMenuButton "Subsort graph" (passTh displaySubsortGraph) ginfo 
     
    410432        ]) 
    411433  where passTh displayFun descr _ = 
    412           do r <- lookupTheoryOfNode le ln descr 
     434         do  
     435          ost <- readIORef $ intState ginfo 
     436          case i_state ost of  
     437           Nothing -> return () 
     438           Just ist -> do  
     439             let ln = i_ln ist 
     440                 le = i_libEnv ist 
     441             r <- lookupTheoryOfNode le ln descr 
    413442             case r of 
    414443               Res.Result [] (Just (_le',n, gth)) -> 
  • trunk/GUI/GraphTypes.hs

    r11173 r11229  
    2828import GUI.GraphAbstraction(GraphInfo, initgraphs) 
    2929import GUI.ProofManagement (GUIMVar) 
    30 import GUI.History(CommandHistory, emptyCommandHistory) 
     30-- import GUI.History(CommandHistory, emptyCommandHistory) 
    3131import GUI.UDGUtils 
    3232 
     
    4242 
    4343import Control.Concurrent.MVar 
     44 
     45import Interfaces.DataTypes 
     46import Interfaces.Utils 
     47 
    4448 
    4549data InternalNames = InternalNames 
     
    5155data GInfo = GInfo 
    5256             { -- Global 
    53                libEnvIORef :: IORef LibEnv 
     57               intState :: IORef IntState 
     58--               libEnvIORef :: IORef LibEnv 
    5459             , gi_hetcatsOpts :: HetcatsOpts 
    5560             , windowCount :: MVar Integer 
    5661             , exitMVar :: MVar () 
    5762             , globalLock :: MVar () 
    58              , globalHist :: MVar ([[LIB_NAME]],[[LIB_NAME]]) 
    59              , commandHist :: CommandHistory 
     63--             , globalHist :: MVar ([[LIB_NAME]],[[LIB_NAME]]) 
     64--             , commandHist :: CommandHistory 
    6065             , functionLock :: MVar () 
    6166               -- Local 
    62              , gi_LIB_NAME :: LIB_NAME 
     67--             , gi_LIB_NAME :: LIB_NAME 
    6368             , gi_GraphInfo :: GraphInfo 
    6469             , internalNamesIORef :: IORef InternalNames 
     
    9499emptyGInfo :: IO GInfo 
    95100emptyGInfo = do 
    96   iorLE <- newIORef emptyLibEnv 
     101  let ihist = IntHistory {  
     102                 undoList = [],  
     103                 redoList = [] } 
     104      istate = emptyIntIState emptyLibEnv $ Lib_id $ Indirect_link  
     105                                        "" nullRange "" noTime 
     106      st = IntState {  
     107            i_state = Just istate, 
     108            i_hist  = ihist } 
     109   
     110  intSt <- newIORef st 
     111--  iorLE <- newIORef emptyLibEnv 
    97112  graphInfo <- initgraphs 
    98113  iorIN <- newIORef $ InternalNames False [] 
     
    102117  exit <- newEmptyMVar 
    103118  wc <- newMVar 0 
    104   gh <- newMVar ([],[]) 
    105   ch <- emptyCommandHistory 
    106   return $ GInfo { libEnvIORef = iorLE 
    107                   , gi_LIB_NAME = Lib_id $ Indirect_link "" nullRange "" noTime 
     119--  gh <- newMVar ([],[]) 
     120--  ch <- emptyCommandHistory 
     121  return $ GInfo { 
     122  --              libEnvIORef = iorLE 
     123  --             , gi_LIB_NAME = Lib_id $ Indirect_link "" nullRange "" noTime 
     124                   intState = intSt 
    108125                 , gi_GraphInfo = graphInfo 
    109126                 , internalNamesIORef = iorIN 
     
    113130                 , exitMVar = exit 
    114131                 , globalLock = gl 
    115                  , globalHist = gh 
    116                  , commandHist = ch 
     132  --             , globalHist = gh 
     133  --             , commandHist = ch 
    117134                 , functionLock = fl 
    118135                 } 
     
    124141  iorIN <- newIORef $ InternalNames False [] 
    125142  guiMVar <- newEmptyMVar 
    126   return $ gInfo { gi_LIB_NAME = newLN 
    127                  , gi_GraphInfo = graphInfo 
     143  intSt <- readIORef $ intState gInfo 
     144  let intSt' = intSt {  
     145                i_state = case i_state intSt of  
     146                           Nothing -> Nothing 
     147                           Just st -> Just $ st { 
     148                                                 i_ln = newLN} 
     149                    } 
     150  writeIORef (intState gInfo) $ intSt' 
     151  return $ gInfo { -- gi_LIB_NAME = newLN 
     152                   gi_GraphInfo = graphInfo 
    128153                 , internalNamesIORef = iorIN 
    129154                 , proofGUIMVar = guiMVar 
  • trunk/GUI/History.hs

    r11173 r11229  
    149149-- If at least one goal was proved and the prove is not the same as last time 
    150150-- the prove gets added, otherwise not. 
    151 addProveToHist :: CommandHistory 
     151addProveToHist :: CommandHistory  
    152152        -> ProofState lid sentence         -- current proofstate 
    153153        -> Maybe (G_prover, AnyComorphism) -- possible used translation 
  • trunk/GUI/ShowGraph.hs

    r11173 r11229  
    4040import Control.Concurrent.MVar 
    4141 
     42import Interfaces.DataTypes 
     43 
    4244showGraph :: FilePath -> HetcatsOpts -> 
    4345             Maybe (LIB_NAME, -- filename 
     
    5557    useHTk -- All messages are displayed in TK dialog windows 
    5658    -- from this point on 
    57     writeIORef (libEnvIORef gInfo) le 
    58     ch <- (initCommandHistory file) 
    59     let gInfo' = gInfo { gi_LIB_NAME = ln 
    60                        , gi_hetcatsOpts = opts 
    61                        , commandHist = ch 
    62                        } 
     59    ost <- readIORef $ intState gInfo 
     60    let nwst = case i_state ost of  
     61                Nothing -> ost 
     62                Just ist -> ost{ i_state = Just $ ist { i_libEnv = le 
     63                                                      , i_ln = ln} } 
     64    writeIORef (intState gInfo) nwst 
     65--    ch <- (initCommandHistory file) 
     66    let gInfo' = gInfo { gi_hetcatsOpts = opts     } 
    6367    showLibGraph gInfo' 
    6468    mShowGraph gInfo' ln 
  • trunk/GUI/ShowLibGraph.hs

    r11173 r11229  
    3636import Control.Concurrent(threadDelay) 
    3737 
     38import Interfaces.DataTypes 
     39 
    3840type NodeArcList = ([DaVinciNode LIB_NAME],[DaVinciArc (IO String)]) 
    3941 
     
    6567-- | Reloads all Libraries and the Library Dependency Graph 
    6668reload :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeArcList -> IO() 
    67 reload gInfo@(GInfo {gi_LIB_NAME = ln, 
    68                      gi_hetcatsOpts = opts 
     69reload gInfo@(GInfo {gi_hetcatsOpts = opts 
    6970                    }) depGRef nodeArcRef = do 
    70   depG <- readIORef depGRef 
    71   (nodes', arcs) <- readIORef nodeArcRef 
    72   let 
     71 ost <- readIORef $ intState gInfo 
     72 case i_state ost of  
     73  Nothing -> return () 
     74  Just ist -> do   
     75   let ln = i_ln ist 
     76   depG <- readIORef depGRef 
     77   (nodes', arcs) <- readIORef nodeArcRef 
     78   let 
    7379    libfile = libNameToFile opts ln 
    74   m <- anaLib opts { outtypes = [] } libfile 
    75   case m of 
     80   m <- anaLib opts { outtypes = [] } libfile 
     81   case m of 
    7682    Nothing -> fail $ 
    7783      "Error when reloading file '" ++ libfile ++  "'" 
     
    8591-- | Adds the Librarys and the Dependencies to the Graph 
    8692addNodesAndArcs :: GInfo -> DaVinciGraphTypeSyn -> IORef NodeArcList -> IO () 
    87 addNodesAndArcs gInfo@(GInfo { libEnvIORef = ioRefProofStatus 
    88                              , gi_hetcatsOpts = opts}) depG nodeArcRef = do 
    89   le <- readIORef ioRefProofStatus 
    90   let 
     93addNodesAndArcs gInfo@(GInfo { gi_hetcatsOpts = opts}) depG nodeArcRef = do 
     94 ost <- readIORef $ intState gInfo 
     95 case i_state ost of  
     96  Nothing -> return () 
     97  Just ist -> do 
     98   let  
     99    le = i_libEnv ist 
    91100    lookup' x y = Map.findWithDefault (error "lookup': node not found") y x 
    92101    keys = Map.keys le 
     
    99108                       Color (getColor opts Green True True) $$$ 
    100109                       emptyNodeTypeParms 
    101   subNodeType <- newNodeType depG subNodeTypeParms 
    102   subNodeList <- mapM (newNode depG subNodeType) keys 
    103   let 
     110   subNodeType <- newNodeType depG subNodeTypeParms 
     111   subNodeList <- mapM (newNode depG subNodeType) keys 
     112   let 
    104113    nodes' = Map.fromList $ zip keys subNodeList 
    105114    subArcMenu = LocalMenu(UDG.Menu Nothing []) 
     
    108117                      Color (getColor opts Black False False) $$$ 
    109118                      emptyArcTypeParms 
    110   subArcType <- newArcType depG subArcTypeParms 
    111   let 
     119   subArcType <- newArcType depG subArcTypeParms 
     120   let 
    112121    insertSubArc = \ (node1, node2) -> newArc depG subArcType (return "") 
    113122                       (lookup' nodes' node1) (lookup' nodes' node2) 
    114   subArcList <- mapM insertSubArc $  Rel.toList $ Rel.intransKernel $ 
     123   subArcList <- mapM insertSubArc $  Rel.toList $ Rel.intransKernel $ 
    115124    Rel.transClosure $ Rel.fromList $ getLibDeps le 
    116   writeIORef nodeArcRef (subNodeList, subArcList) 
     125   writeIORef nodeArcRef (subNodeList, subArcList) 
    117126 
    118127mShowGraph :: GInfo -> LIB_NAME -> IO() 
  • trunk/Interfaces/History.hs

    r11082 r11229  
    3737 
    3838 
    39 add2history :: IntState -> String -> [UndoRedoElem] -> IntState 
    40 add2history st name descr 
     39-- write2Hist :: IORef IntState -> String -> [UndoRedoElem] -> IO() 
     40-- write2Hist iost name descr 
     41--  = do  
     42--    ost <- readIORef iost  
     43--    let nwst = add2history name ost descr 
     44--    writeIORef iost nwst 
     45 
     46add2history :: String -> IntState -> [UndoRedoElem] -> IntState 
     47add2history name st descr 
    4148 = case undoList $ i_hist st of 
    4249    [] ->  let nwEl = Int_CmdHistoryDescription { 
  • trunk/PGIP/DataTypesUtils.hs

    r11082 r11229  
    6161add2hist :: [UndoRedoElem] -> CMDL_State ->  CMDL_State 
    6262add2hist descr st 
    63  = let intst = add2history (intState st) [] descr 
     63 = let intst = add2history [] (intState st) descr 
    6464   in st { 
    6565         intState = intst } 
  • trunk/PGIP/DgCommands.hs

    r11082 r11229  
    294294                               (n,_) -> selectANode n dgState 
    295295                               ) listNodes 
    296           --      oldH = history state 
    297296                nwist = emptyIntIState (i_libEnv dgState) (i_ln dgState) 
    298297             return $ add2hist [IStateChange $ Just dgState] $ 
     
    307306                                          cComorphism = getIdComorphism elems 
    308307                                          } } 
    309                --    history = oldH { 
    310                --         undoInstances = ([],[]):(undoInstances oldH), 
    311                --         redoInstances = []}, 
    312308                   } 
    313309 
     
    332328                           (n,_) -> selectANode n dgState 
    333329                           ) lsNodes 
    334          -- oldH = history state 
    335330          nwist = emptyIntIState (i_libEnv dgState) (i_ln dgState) 
    336331               -- ADD TO HISTORY 
     
    343338                                          cComorphism = getIdComorphism elems 
    344339                                            } } 
    345         --      history = oldH { 
    346         --                 undoInstances= ([],[]):(undoInstances oldH), 
    347         --                 redoInstances= [] 
    348         --                 }, 
    349340              } 
  • trunk/Proofs/InferBasic.hs

    r11117 r11229  
    5151import GUI.Utils 
    5252import GUI.ProofManagement 
    53 import GUI.History(CommandHistory, addProveToHist) 
     53-- import GUI.History(CommandHistory, addProveToHist) 
    5454 
    5555import qualified Common.Lib.Graph as Tree 
     
    153153basicInferenceNode :: Bool -- ^ True = CheckConsistency; False = Prove 
    154154                   -> LogicGraph -> (LIB_NAME,Node) -> LIB_NAME 
    155                    -> GUIMVar -> LibEnv -> CommandHistory 
     155                   -> GUIMVar -> LibEnv  
     156                   -- -> CommandHistory 
    156157                   -> IO (Result (LibEnv, Result G_theory)) 
    157 basicInferenceNode checkCons lg (ln, node) libname guiMVar libEnv ch = do 
     158basicInferenceNode checkCons lg (ln, node) libname guiMVar libEnv  
     159 -- ch  
     160 = do 
    158161      let dGraph = lookupDGraph libname libEnv 
    159162      runResultT $ do 
     
    211214            newTh <- ResultT $ 
    212215                   proofManagementGUI lid1 ProofActions { 
    213                        proveF = (proveKnownPMap lg ch freedefs), 
    214                        fineGrainedSelectionF = (proveFineGrainedSelect lg ch freedefs), 
     216                       proveF = (proveKnownPMap lg freedefs), 
     217                       fineGrainedSelectionF = (proveFineGrainedSelect lg freedefs), 
    215218                       recalculateSublogicF  = 
    216219                                     recalculateSublogicAndSelectedTheory } 
     
    238241                   -> (LIB_NAME,Node) 
    239242                   -> GUIMVar 
    240                    -> CommandHistory 
     243                   -- -> CommandHistory 
    241244                   -> LibEnv 
    242245                   -> IO (Result (LibEnv, Result G_theory)) 
    243 basicInferenceSubTree checkCons lg (ln, node) guiMVar ch libEnv = do 
     246basicInferenceSubTree checkCons lg (ln, node) guiMVar libEnv = do 
    244247      let dGraph = lookupDGraph ln libEnv 
    245248      runResultT $ do 
     
    308311            newTh <- ResultT $ 
    309312                   proofManagementGUI lid1 ProofActions { 
    310                        proveF = (proveKnownPMap lg ch freedefs), 
    311                        fineGrainedSelectionF = (proveFineGrainedSelect lg ch freedefs), 
     313                       proveF = (proveKnownPMap lg freedefs), 
     314                       fineGrainedSelectionF = (proveFineGrainedSelect lg freedefs), 
    312315                       recalculateSublogicF  = 
    313316                                     recalculateSublogicAndSelectedTheory } 
     
    340343               raw_symbol1 
    341344               proof_tree1) => 
    342        LogicGraph -> CommandHistory 
     345       LogicGraph  
     346       -- -> CommandHistory 
    343347    -> [FreeDefMorphism sentence morphism1] 
    344348    -> ProofState lid sentence -> IO (Result (ProofState lid sentence)) 
    345 proveKnownPMap lg ch freedefs st = 
    346     maybe (proveFineGrainedSelect lg ch freedefs st) 
    347           (callProver st ch False freedefs) $ 
     349proveKnownPMap lg freedefs st = 
     350    maybe (proveFineGrainedSelect lg freedefs st) 
     351          (callProver st False freedefs) $ 
    348352          lookupKnownProver st ProveGUI 
    349353 
     
    359363               proof_tree1) => 
    360364       ProofState lid sentence 
    361     -> CommandHistory -> Bool -- indicates if a translation was chosen 
     365    -- -> CommandHistory  
     366    -> Bool -- indicates if a translation was chosen 
    362367    -> [FreeDefMorphism sentence morphism1] 
    363368    -> (G_prover,AnyComorphism) -> IO (Result (ProofState lid sentence)) 
    364 callProver st ch trans_chosen freedefs p_cm@(_,acm) = 
     369callProver st trans_chosen freedefs p_cm@(_,acm) = 
    365370       runResultT $ do 
    366371        G_theory_with_prover lid th p <- liftR $ prepareForProving st p_cm 
     
    372377        -- lift $ putStrLn $ show ps 
    373378        let st' = markProved acm lid ps st 
    374         lift $ addProveToHist ch st' 
    375             (if trans_chosen then Just p_cm else Nothing) ps 
     379--        lift $ addProveToHist ch st' 
     380--            (if trans_chosen then Just p_cm else Nothing) ps 
    376381        return st' 
    377382 
     
    387392               raw_symbol1 
    388393               proof_tree1) => 
    389        LogicGraph -> CommandHistory 
     394       LogicGraph -- -> CommandHistory 
    390395    -> [FreeDefMorphism sentence morphism1] 
    391396    -> ProofState lid sentence -> IO (Result (ProofState lid sentence)) 
    392 proveFineGrainedSelect lg ch freedefs st = 
     397proveFineGrainedSelect lg freedefs st = 
    393398    runResultT $ do 
    394399       let sl = sublogicOfTheory st 
     
    400405       pr <- selectProver cmsToProvers 
    401406       ResultT $ callProver st{lastSublogic = sublogicOfTheory st, 
    402                                comorphismsToProvers = cmsToProvers} ch True freedefs pr 
     407                               comorphismsToProvers = cmsToProvers} True freedefs pr