Changeset 11229
- Timestamp:
- 07.01.2009 14:11:49 (10 months ago)
- Location:
- trunk
- Files:
-
- 11 modified
-
GUI/GraphDisplay.hs (modified) (4 diffs)
-
GUI/GraphLogic.hs (modified) (26 diffs)
-
GUI/GraphMenu.hs (modified) (11 diffs)
-
GUI/GraphTypes.hs (modified) (7 diffs)
-
GUI/History.hs (modified) (1 diff)
-
GUI/ShowGraph.hs (modified) (2 diffs)
-
GUI/ShowLibGraph.hs (modified) (5 diffs)
-
Interfaces/History.hs (modified) (1 diff)
-
PGIP/DataTypesUtils.hs (modified) (1 diff)
-
PGIP/DgCommands.hs (modified) (4 diffs)
-
Proofs/InferBasic.hs (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/GUI/GraphDisplay.hs
r11173 r11229 44 44 import Control.Concurrent.MVar 45 45 46 import Interfaces.DataTypes 47 46 48 initializeConverter :: IO (GInfo,HTk.HTk) 47 49 initializeConverter = do … … 54 56 graphInfo it is contained in and the conversion maps. -} 55 57 convertGraph :: ConvFunc 56 convertGraph gInfo@(GInfo { libEnvIORef = ioRefProofStatus 57 , gi_GraphInfo = actGraphInfo 58 , gi_LIB_NAME = libname 58 convertGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 59 59 , windowCount = wc 60 60 }) 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 63 68 Just dgraph -> do 64 69 case openlock dgraph of … … 87 92 Nothing -> do 88 93 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 91 97 convertGraph gInfo title showLib 92 98 Nothing -> error $ "development graph with libname " ++ show libname … … 96 102 -- return type equals the one of convertGraph 97 103 initializeGraph :: 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) 104 initializeGraph 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 107 107 import Control.Concurrent.MVar 108 108 109 import Interfaces.History 110 import Interfaces.DataTypes 111 109 112 -- | Locks the global lock and runs function 110 113 runAndLock :: GInfo -> IO () -> IO () … … 127 130 -- | Undo one step of the History 128 131 undo :: 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 132 undo 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 168 138 169 139 -- | reloads the Library of the DevGraph 170 140 reload :: GInfo -> IO() 171 reload gInfo@(GInfo { libEnvIORef = ioRefProofStatus 172 , gi_LIB_NAME = ln 173 , gi_hetcatsOpts = opts 141 reload gInfo@(GInfo { gi_hetcatsOpts = opts 174 142 , gi_GraphInfo = actGraphInfo 175 143 }) = do 176 144 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 180 155 $ getLibDeps oldle 181 ioruplibs <- newIORef ([] :: [LIB_NAME])182 writeIORef ioruplibs []183 reloadLibs ioRefProofStatusopts libdeps ioruplibs ln184 unlockGlobal gInfo185 libs <- readIORef ioruplibs186 case libs of187 [] -> GA.showTemporaryMessage actGraphInfo "Reload not needed!"188 _ -> remakeGraph gInfo156 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 189 164 190 165 -- | Creates a list of all LIB_NAME pairs, which have a dependency … … 199 174 200 175 -- | Reloads a library 201 reloadLib :: IORef LibEnv-> HetcatsOpts -> IORef [LIB_NAME] -> LIB_NAME176 reloadLib :: IORef IntState -> HetcatsOpts -> IORef [LIB_NAME] -> LIB_NAME 202 177 -> IO () 203 reloadLib iorle opts ioruplibs ln = do 204 mfile <- existsAnSource opts {intype = GuessIn} 178 reloadLib 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} 205 184 $ rmSuffix $ libNameToFile opts ln 206 case mfile of185 case mfile of 207 186 Nothing -> return () 208 187 Just file -> do 209 le <- readIORef iorle188 let le = i_libEnv ist 210 189 mFunc <- case openlock $ lookupDGraph ln le of 211 190 Just lock -> tryTakeMVar lock … … 224 203 "Reload: Can't set openlock in DevGraph" 225 204 Nothing -> return () 226 writeIORef iorle $ newle 205 let nwst = ost { i_state = Just ist { 206 i_libEnv = newle } } 207 writeIORef iorst $ nwst 227 208 Nothing -> 228 209 errorDialog "Error" $ "Error when reloading file " ++ show file 229 210 230 211 -- | Reloads libraries if nessesary 231 reloadLibs :: IORef LibEnv-> HetcatsOpts -> [(LIB_NAME, LIB_NAME)]212 reloadLibs :: IORef IntState -> HetcatsOpts -> [(LIB_NAME, LIB_NAME)] 232 213 -> 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 214 reloadLibs 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 236 221 True -> return True 237 222 False -> do 238 223 let 239 224 deps' = map (snd) $ filter (\ (ln',_) -> ln == ln') deps 240 res <- mapM (reloadLibs ior leopts deps ioruplibs) deps'225 res <- mapM (reloadLibs iorst opts deps ioruplibs) deps' 241 226 let 242 227 libupdate = foldl (\ u r -> if r then True else u) False res 243 228 case libupdate of 244 229 True -> do 245 reloadLib ior leopts ioruplibs ln230 reloadLib iorst opts ioruplibs ln 246 231 return True 247 232 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 257 246 libupdate' = (getModTime $ getLIB_ID newln) < newmt 258 case libupdate' of247 case libupdate' of 259 248 False -> return False 260 249 True -> do 261 reloadLib ior leopts ioruplibs ln250 reloadLib iorst opts ioruplibs ln 262 251 return True 263 252 264 253 -- | Deletes the old edges and nodes of the Graph and makes new ones 265 254 remakeGraph :: GInfo -> IO () 266 remakeGraph gInfo@(GInfo { libEnvIORef = ioRefProofStatus 267 , gi_LIB_NAME = ln 268 , gi_GraphInfo = actGraphInfo 255 remakeGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 269 256 }) = 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 277 268 278 269 -- | Toggles to display internal node names … … 301 292 -- | hides all unnamed internal nodes that are proven 302 293 hideNodes :: GInfo -> IO () 303 hideNodes (GInfo { libEnvIORef = ioRefProofStatus 304 , gi_LIB_NAME = ln 305 , gi_GraphInfo = actGraphInfo 294 hideNodes gInfo@(GInfo { gi_GraphInfo = actGraphInfo 306 295 }) = do 307 296 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 316 310 {nonRefType = NonRefType 317 311 {isProvenCons = True 318 312 , isInternalSpec = True} 319 313 , isLocallyEmpty = True}] 320 edges = getCompressedEdges dg nodes321 GA.hideNodes actGraphInfo nodes edges314 edges = getCompressedEdges dg nodes 315 GA.hideNodes actGraphInfo nodes edges 322 316 323 317 -- | selects all nodes of a type with outgoing edges … … 382 376 -- | Let the user select a Node to focus 383 377 focusNode :: 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) 378 focusNode 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) 389 386 $ labNodesDG $ lookupDGraph ln le 390 selection <- listBox "Select a node to focus"391 $ map (\ (n, l) -> shows n " " ++ getDGNodeName l) idsnodes392 case selection of387 selection <- listBox "Select a node to focus" 388 $ map (\ (n, l) -> shows n " " ++ getDGNodeName l) idsnodes 389 case selection of 393 390 Just idx -> GA.focusNode grInfo $ fst $ idsnodes !! idx 394 391 Nothing -> return () 395 392 396 393 translateGraph :: GInfo -> ConvFunc -> LibFunc -> IO () 397 translateGraph (GInfo {libEnvIORef = ioRefProofStatus, 398 gi_LIB_NAME = ln, 399 gi_hetcatsOpts = opts 394 translateGraph gInfo@(GInfo { gi_hetcatsOpts = opts 400 395 }) 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 403 403 404 404 showLibGraph :: GInfo -> LibFunc -> IO () … … 431 431 432 432 saveProofStatus :: GInfo -> FilePath -> IO () 433 saveProofStatus (GInfo { libEnvIORef = ioRefProofStatus 434 , gi_LIB_NAME = ln 435 , gi_hetcatsOpts = opts 433 saveProofStatus gInfo@(GInfo { gi_hetcatsOpts = opts 436 434 }) 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 438 441 writeShATermFile file (ln, lookupHistory ln proofStatus) 439 442 putIfVerbose opts 2 $ "Wrote " ++ file … … 442 445 openProofStatus :: GInfo -> FilePath -> ConvFunc -> LibFunc 443 446 -> IO () 444 openProofStatus gInfo@(GInfo { libEnvIORef = ioRefProofStatus 445 , gi_LIB_NAME = ln 446 , gi_hetcatsOpts = opts 447 openProofStatus gInfo@(GInfo { gi_hetcatsOpts = opts 447 448 }) 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 448 454 mh <- readVerbose opts ln file 449 455 case mh of … … 462 468 Just dg -> do 463 469 lockGlobal gInfo 464 oldEnv <- readIORef ioRefProofStatus465 letproofStatus = Map.insert ln470 let oldEnv = i_libEnv ist 471 proofStatus = Map.insert ln 466 472 (applyProofHistory h dg) oldEnv 467 writeIORef ioRefProofStatus proofStatus 473 nwst = ost { i_state = Just ist { 474 i_libEnv = proofStatus } } 475 writeIORef (intState gInfo) nwst 468 476 unlockGlobal gInfo 469 477 gInfo' <- copyGInfo gInfo ln … … 475 483 GA.activateGraphWindow actGraphInfo 476 484 477 -- | apply a rule of the development graph calculus 485 -- | apply a rule of the development graph calculus 478 486 proofMenu :: GInfo 479 487 -> (LibEnv -> IO (Res.Result LibEnv)) 480 488 -> IO () 481 proofMenu gInfo@(GInfo { libEnvIORef = ioRefProofStatus 482 , gi_LIB_NAME = ln 483 , gi_GraphInfo = actGraphInfo 489 proofMenu gInfo@(GInfo { gi_GraphInfo = actGraphInfo 484 490 , gi_hetcatsOpts = hOpts 485 491 , proofGUIMVar = guiMVar 486 , globalHist = gHist487 492 }) 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 490 500 then readMVar guiMVar >>= 491 501 (maybe (putIfVerbose hOpts 0 "proofMenu: ignored Nothing") … … 497 507 else do 498 508 lockGlobal gInfo 499 proofStatus <- readIORef ioRefProofStatus509 let proofStatus = i_libEnv ist 500 510 putIfVerbose hOpts 4 "Proof started via \"Proofs\" menu" 501 511 Res.Result ds res <- proofFun proofStatus … … 508 518 let newGr = lookupDGraph ln newProofStatus 509 519 history = snd $ splitHistory (lookupDGraph ln proofStatus) newGr 510 (guHist, grHist) <- takeMVar gHist511 520 doDump hOpts "PrintHistory" $ do 512 521 putStrLn "History" 513 522 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) 516 527 applyChanges actGraphInfo $ reverse 517 528 $ flatHistory history 518 writeIORef ioRefProofStatus newProofStatus 529 let nwst = nst { i_state = Just ist { i_libEnv=newProofStatus}} 530 writeIORef (intState gInfo) nwst 519 531 unlockGlobal gInfo 520 532 hideShowNames gInfo False … … 545 557 fetches the theory from a node inside the IO Monad 546 558 (added by KL based on code in getTheoryOfNode) -} 547 lookupTheoryOfNode :: IORefLibEnv -> LIB_NAME -> Int559 lookupTheoryOfNode :: LibEnv -> LIB_NAME -> Int 548 560 -> IO (Res.Result (LibEnv, Node, G_theory)) 549 lookupTheoryOfNode proofStatusRef ln descr = do 550 libEnv <- readIORef proofStatusRef 561 lookupTheoryOfNode libEnv ln descr = do 551 562 return $ do 552 563 (libEnv', gth) <- computeTheory True libEnv ln descr … … 562 573 used by the node menu defined in initializeGraph-} 563 574 getTheoryOfNode :: GInfo -> Int -> DGraph -> IO () 564 getTheoryOfNode gInfo@(GInfo { gi_LIB_NAME = ln 565 , gi_GraphInfo = actGraphInfo 566 , libEnvIORef = le 575 getTheoryOfNode gInfo@(GInfo { gi_GraphInfo = actGraphInfo 567 576 }) 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 573 588 (Just (le', n, gth)) -> do 574 589 lockGlobal gInfo … … 576 591 (addHasInHidingWarning dgraph n) gth 577 592 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 580 594 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 582 597 unlockGlobal gInfo 583 598 _ -> return () … … 587 602 translateTheoryOfNode :: GInfo -> Int -> DGraph -> IO () 588 603 translateTheoryOfNode 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 592 612 case mEnv of 593 613 Just (_, th@(G_theory lid sign _ sens _)) -> do … … 645 665 -- | start local theorem proving or consistency checking at a node 646 666 proveAtNode :: 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 667 proveAtNode 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 653 677 True -> return (dgraph, dgn) 654 678 False -> do 655 679 lockGlobal gInfo 656 le <- readIORef ioRefProofStatus657 680 (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 659 684 unlockGlobal gInfo 660 685 return (dgraph',dgn') 661 locked <- tryLockLocal dgn'662 case locked of686 locked <- tryLockLocal dgn' 687 case locked of 663 688 False -> do 664 689 errorDialog "Error" "Proofwindow already open" 665 690 True -> do 666 691 let action = do 667 le <- readIORef ioRefProofStatus668 692 guiMVar <- newMVar Nothing 669 693 res <- basicInferenceNode checkCons logicGraph libNode ln 670 guiMVar le ch 694 guiMVar le 695 -- add to history ch 671 696 runProveAtNode checkCons gInfo (descr, dgn') res 672 697 unlockLocal dgn' … … 685 710 -> Res.Result (LibEnv, Res.Result G_theory) -> IO () 686 711 runProveAtNode 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 689 719 when checkCons $ case maybeResult tres of 690 720 Just gth -> createTextSaveDisplay … … 695 725 $ unlines $ "could not (re-)construct a model" : map diagString ds 696 726 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 () 699 729 700 730 mergeDGNodeLab :: 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 731 mergeDGNodeLab 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 705 740 theory <- joinG_sentences (dgn_theory old_dgn) $ dgn_theory new_dgn 706 741 let new_dgn' = old_dgn { dgn_theory = theory } … … 723 758 -- | check conservativity of the edge 724 759 checkconservativityOfEdge :: Int -> GInfo -> Maybe (LEdge DGLinkLab) -> IO () 725 checkconservativityOfEdge _ gInfo@(GInfo{gi_LIB_NAME = ln, 726 gi_GraphInfo = _actGraphInfo, 727 libEnvIORef = le}) 760 checkconservativityOfEdge _ gInfo@(GInfo{ gi_GraphInfo = _actGraphInfo}) 728 761 (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) = 735 773 case computeTheory True libEnv' ln target of 736 774 Res.Result _ (Just th1) -> th1 737 775 _ -> error "checkconservativityOfEdge: computeTheory" 738 G_theory lid _sign _ sensTar _ <- return thTar739 GMorphism cid _ _ morphism2 _ <- return $ dgl_morphism linklab740 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 $ 741 779 dgn_sigma $ labDG (lookupDGraph ln libEnv') target 742 morphism2' <- coerceMorphism (targetLogic cid) lid780 morphism2' <- coerceMorphism (targetLogic cid) lid 743 781 "checkconservativityOfEdge2" morphism2 744 morphism3' <- coerceMorphism (targetLogic cid') lid782 morphism3' <- coerceMorphism (targetLogic cid') lid 745 783 "checkconservativityOfEdge3" morphism3 746 let compMor = case comp morphism2' morphism3' of747 Res.Result _ (Just phi) -> phi748 _ -> error "checkconservativtiyOfEdge: comp"749 let (_le', thSrc) =750 case computeTheory False libEnv' (gi_LIB_NAME gInfo)source of784 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 751 789 Res.Result _ (Just th1) -> th1 752 790 _ -> error "checkconservativityOfEdge: computeTheory" 753 G_theory lid1 sign1 _ sensSrc1 _ <- return thSrc754 sign2 <- coerceSign lid1 lid "checkconservativityOfEdge.coerceSign" sign1755 sensSrc2 <- coerceThSens lid1 lid "checkconservativityOfEdge1" sensSrc1756 let transSensSrc = propagateErrors791 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 757 795 $ mapThSensValueM (map_sen lid compMor) sensSrc2 758 if length (conservativityCheck lid) < 1759 then796 if length (conservativityCheck lid) < 1 797 then 760 798 do 761 799 infoDialog "Result of conservativity check" 762 800 "No conservativity checkers available" 763 writeIORef le libEnv' 801 let nwst = ost {i_state = Just $ist{ i_libEnv=libEnv'}} 802 writeIORef (intState gInfo) nwst 764 803 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 " 787 827 ++ "can be discharged:\n" 788 828 ++ concatMap (flip showDoc "\n") obls 789 showRes = case res of829 showRes = case res of 790 830 Just (Just (cst, obls)) -> "The link is " 791 831 ++ showConsistencyStatus cst ++ showObls obls 792 832 _ -> "Could not determine whether link is conservative" 793 myDiags = showRelDiags 2 ds794 createTextDisplay "Result of conservativity check"795 (showRes ++ "\n" ++ myDiags)796 let833 myDiags = showRelDiags 2 ds 834 createTextDisplay "Result of conservativity check" 835 (showRes ++ "\n" ++ myDiags) 836 let 797 837 consShow = case res of 798 838 Just (Just (cst, _)) -> cst … … 813 853 changes = [ DeleteEdge (source,target,linklab) 814 854 , InsertEdge provenEdge ] 815 let newGr = lookupDGraph ln libEnv'816 nextGr = changesDGH newGr changes817 newLibEnv = Map.insert ln855 let newGr = lookupDGraph ln libEnv' 856 nextGr = changesDGH newGr changes 857 newLibEnv = Map.insert ln 818 858 (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 822 863 823 864 checkconservativityOfEdge descr _ Nothing = … … 876 917 -- | show library referened by a DGRef node (=node drawn as a box) 877 918 showReferencedLibrary :: Int -> GInfo -> ConvFunc -> LibFunc -> IO () 878 showReferencedLibrary descr gInfo@(GInfo { libEnvIORef = ioRefProofStatus 879 , gi_LIB_NAME = ln }) 919 showReferencedLibrary descr gInfo 880 920 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 886 931 Just _ -> do 887 932 gInfo' <- copyGInfo gInfo refLibname … … 946 991 showDiagMess opts $ diagsSl ++ diagsTrans 947 992 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}) 952 1003 "translation Graph" showLib) 953 1004 Nothing -> myErrMess $ diagsSl ++ diagsTrans … … 972 1023 -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) -> IO () 973 1024 saveUDGraph gInfo@(GInfo { gi_GraphInfo = graphInfo 974 , gi_LIB_NAME = ln975 1025 , gi_hetcatsOpts = opts 976 1026 }) 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") 978 1033 [ ("uDrawGraph",["*.udg"]) 979 1034 , ("All Files", ["*"])] Nothing 980 case maybeFilePath of981 Just filepath -> do1035 case maybeFilePath of 1036 Just filepath -> do 982 1037 GA.showTemporaryMessage graphInfo "Converting graph..." 983 1038 nstring <- nodes2String gInfo nodemap linkmap 984 1039 writeFile filepath nstring 985 1040 GA.showTemporaryMessage graphInfo $ "Graph stored to " ++ filepath ++ "!" 986 Nothing -> GA.showTemporaryMessage graphInfo $ "Aborted!"1041 Nothing -> GA.showTemporaryMessage graphInfo $ "Aborted!" 987 1042 988 1043 -- | Converts the nodes of the graph to String representation … … 990 1045 -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) 991 1046 -> 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) 1047 nodes2String 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) 999 1056 $ labNodesDG $ lookupDGraph ln le 1000 nstring <- foldM (\s node -> do1057 nstring <- foldM (\s node -> do 1001 1058 s' <- (node2String gInfo nodemap linkmap node) 1002 1059 return $ s ++ (if s /= "" then ",\n " else "") ++ s') 1003 1060 "" nodes 1004 return $ "[" ++ nstring ++ "]"1061 return $ "[" ++ nstring ++ "]" 1005 1062 1006 1063 -- | Converts a node to String representation … … 1026 1083 links2String :: GInfo -> Map.Map DGEdgeType (EdgePattern GA.EdgeValue, String) 1027 1084 -> Int -> IO String 1028 links2String (GInfo { gi_GraphInfo = graphInfo 1029 , gi_LIB_NAME = ln 1030 , libEnvIORef = ioRefProofStatus 1085 links2String gInfo@(GInfo { gi_GraphInfo = graphInfo 1031 1086 }) 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 1034 1094 let eid = dgl_id edge 1035 1095 b <- GA.isHiddenEdge graphInfo eid 1036 1096 return $ (not b) && src == nodeid) 1037 1097 $ labEdgesDG $ lookupDGraph ln le 1038 foldM (\s edge -> do1098 foldM (\s edge -> do 1039 1099 s' <- link2String linkmap edge 1040 1100 return $ s ++ (if s /= "" then ",\n " else "") ++ s') "" edges -
trunk/GUI/GraphMenu.hs
r11173 r11229 55 55 56 56 import Control.Concurrent.MVar 57 58 59 import Interfaces.DataTypes 60 import Interfaces.History 57 61 58 62 -- | Adds to the DGNodeType list style options for each type … … 135 139 -- | Creates the graph. Runs makegraph 136 140 createGraph :: GInfo -> String -> ConvFunc -> LibFunc -> IO () 137 createGraph gInfo@(GInfo { gi_LIB_NAME = ln 138 , gi_GraphInfo = actGraphInfo 141 createGraph gInfo@(GInfo { gi_GraphInfo = actGraphInfo 139 142 , gi_hetcatsOpts = opts 140 143 }) 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 144 153 title 145 154 (createOpen gInfo file convGraph showLib) … … 148 157 (createClose gInfo) 149 158 (Just (createExit gInfo)) 150 (createGlobalMenu gInfo convGraph showLib deselectEdgeTypes)159 globMenu 151 160 (createNodeTypes gInfo convGraph showLib) 152 161 (createEdgeTypes gInfo) … … 182 191 -- | Returns the save-function 183 192 createClose :: GInfo -> IO Bool 184 createClose (GInfo { gi_LIB_NAME = ln 185 , libEnvIORef = ioRefProofStatus 186 , windowCount = wc 193 createClose gInfo@(GInfo { windowCount = wc 187 194 , exitMVar = exit 188 195 }) = 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 191 203 Just dgraph -> do 192 204 case openlock dgraph of … … 199 211 Nothing -> error $ "development graph with libname " ++ show ln 200 212 ++" does not exist" 201 count <- takeMVar wc202 case count == 1 of213 count <- takeMVar wc 214 case count == 1 of 203 215 True -> putMVar exit () 204 216 False -> putMVar wc $ count - 1 205 return True217 return True 206 218 207 219 -- | Returns the save-function … … 212 224 -- | Creates the global menu 213 225 createGlobalMenu :: 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] 227 createGlobalMenu gInfo@(GInfo { gi_hetcatsOpts = opts 218 228 #ifdef GTKGLADE 219 229 , gi_GraphInfo = gi … … 222 232 }) convGraph showLib _ = 223 233 #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") 230 247 [ Button "Hide/show names" $ ral $ hideShowNames gInfo True 231 248 , Button "Hide nodes" $ ral $ hideNodes gInfo 232 249 , Button "Show nodes" $ ral $ showNodes gInfo 233 250 ] 234 , Button "Focus node" $ ral $ focusNode gInfo251 , Button "Focus node" $ ral $ focusNode gInfo 235 252 #ifdef GTKGLADE 236 , Button "Select Linktypes" $ showLinkTypeChoice deselectEdgeTypes253 , Button "Select Linktypes" $ showLinkTypeChoice deselectEdgeTypes 237 254 $ (\ eList -> ral $ do 238 255 GA.showAll gi … … 241 258 ) 242 259 #endif 243 , Menu (Just "Proofs") $ map (\ (str, cmd) ->244 Button str $ addMenuItemToHist ch str >>245 (ral $ performProofAction gInfo260 , Menu (Just "Proofs") $ map (\ (str, cmd) -> 261 -- History ? or just some partial history in ch ? 262 Button str $ (ral $ performProofAction gInfo 246 263 $ proofMenu gInfo $ return . return . cmd ln 247 264 . 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") >> 258 275 (ral $ performProofAction gInfo 259 276 $ proofMenu gInfo $ fmap return . interactiveHideTheoremShift ln) 260 ] ++261 map (\ (str, cmd) ->262 Button str $(addMenuItemToHist ch str) >>263 (ral $ performProofAction gInfo264 $ 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 gInfo271 $ 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" $ do279 le <- readIORef $ libEnvIORef gInfo280 print $ prettyLibEnv le281 , Button "Translate Graph" $ ral $ translateGraph gInfo convGraph showLib282 , Button "Show Logic Graph" $ ral $ showLogicGraph daVinciSort283 , Button "Show Library Graph" $ ral $ showLibGraph gInfo showLib284 , Button "Save Graph for uDrawGraph" $ ral285 $ saveUDGraph gInfo (mapNodeTypes opts) $ mapEdgeTypes opts286 , Button "Save proof-script" $ ral287 $ askSaveProofScript (gi_GraphInfo gInfo) ch288 ])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 ] 290 307 291 308 -- | A list of all Node Types … … 383 400 (Button title 384 401 (\ (_, 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 387 410 runAndLock gInfo $ menuFun descr dGraph 388 411 return () … … 403 426 -} 404 427 createLocalMenuTaxonomy :: GInfo -> ButtonMenu GA.NodeValue 405 createLocalMenuTaxonomy ginfo@(GInfo { gi_LIB_NAME = ln 406 , libEnvIORef = le }) = 428 createLocalMenuTaxonomy ginfo = 407 429 (Menu (Just "Taxonomy graphs") 408 430 [ createMenuButton "Subsort graph" (passTh displaySubsortGraph) ginfo … … 410 432 ]) 411 433 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 413 442 case r of 414 443 Res.Result [] (Just (_le',n, gth)) -> -
trunk/GUI/GraphTypes.hs
r11173 r11229 28 28 import GUI.GraphAbstraction(GraphInfo, initgraphs) 29 29 import GUI.ProofManagement (GUIMVar) 30 import GUI.History(CommandHistory, emptyCommandHistory)30 -- import GUI.History(CommandHistory, emptyCommandHistory) 31 31 import GUI.UDGUtils 32 32 … … 42 42 43 43 import Control.Concurrent.MVar 44 45 import Interfaces.DataTypes 46 import Interfaces.Utils 47 44 48 45 49 data InternalNames = InternalNames … … 51 55 data GInfo = GInfo 52 56 { -- Global 53 libEnvIORef :: IORef LibEnv 57 intState :: IORef IntState 58 -- libEnvIORef :: IORef LibEnv 54 59 , gi_hetcatsOpts :: HetcatsOpts 55 60 , windowCount :: MVar Integer 56 61 , exitMVar :: MVar () 57 62 , globalLock :: MVar () 58 , globalHist :: MVar ([[LIB_NAME]],[[LIB_NAME]])59 , commandHist :: CommandHistory63 -- , globalHist :: MVar ([[LIB_NAME]],[[LIB_NAME]]) 64 -- , commandHist :: CommandHistory 60 65 , functionLock :: MVar () 61 66 -- Local 62 , gi_LIB_NAME :: LIB_NAME67 -- , gi_LIB_NAME :: LIB_NAME 63 68 , gi_GraphInfo :: GraphInfo 64 69 , internalNamesIORef :: IORef InternalNames … … 94 99 emptyGInfo :: IO GInfo 95 100 emptyGInfo = 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 97 112 graphInfo <- initgraphs 98 113 iorIN <- newIORef $ InternalNames False [] … … 102 117 exit <- newEmptyMVar 103 118 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 108 125 , gi_GraphInfo = graphInfo 109 126 , internalNamesIORef = iorIN … … 113 130 , exitMVar = exit 114 131 , globalLock = gl 115 , globalHist = gh116 , commandHist = ch132 -- , globalHist = gh 133 -- , commandHist = ch 117 134 , functionLock = fl 118 135 } … … 124 141 iorIN <- newIORef $ InternalNames False [] 125 142 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 128 153 , internalNamesIORef = iorIN 129 154 , proofGUIMVar = guiMVar -
trunk/GUI/History.hs
r11173 r11229 149 149 -- If at least one goal was proved and the prove is not the same as last time 150 150 -- the prove gets added, otherwise not. 151 addProveToHist :: CommandHistory 151 addProveToHist :: CommandHistory 152 152 -> ProofState lid sentence -- current proofstate 153 153 -> Maybe (G_prover, AnyComorphism) -- possible used translation -
trunk/GUI/ShowGraph.hs
r11173 r11229 40 40 import Control.Concurrent.MVar 41 41 42 import Interfaces.DataTypes 43 42 44 showGraph :: FilePath -> HetcatsOpts -> 43 45 Maybe (LIB_NAME, -- filename … … 55 57 useHTk -- All messages are displayed in TK dialog windows 56 58 -- 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 } 63 67 showLibGraph gInfo' 64 68 mShowGraph gInfo' ln -
trunk/GUI/ShowLibGraph.hs
r11173 r11229 36 36 import Control.Concurrent(threadDelay) 37 37 38 import Interfaces.DataTypes 39 38 40 type NodeArcList = ([DaVinciNode LIB_NAME],[DaVinciArc (IO String)]) 39 41 … … 65 67 -- | Reloads all Libraries and the Library Dependency Graph 66 68 reload :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeArcList -> IO() 67 reload gInfo@(GInfo {gi_LIB_NAME = ln, 68 gi_hetcatsOpts = opts 69 reload gInfo@(GInfo {gi_hetcatsOpts = opts 69 70 }) 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 73 79 libfile = libNameToFile opts ln 74 m <- anaLib opts { outtypes = [] } libfile75 case m of80 m <- anaLib opts { outtypes = [] } libfile 81 case m of 76 82 Nothing -> fail $ 77 83 "Error when reloading file '" ++ libfile ++ "'" … … 85 91 -- | Adds the Librarys and the Dependencies to the Graph 86 92 addNodesAndArcs :: GInfo -> DaVinciGraphTypeSyn -> IORef NodeArcList -> IO () 87 addNodesAndArcs gInfo@(GInfo { libEnvIORef = ioRefProofStatus 88 , gi_hetcatsOpts = opts}) depG nodeArcRef = do 89 le <- readIORef ioRefProofStatus 90 let 93 addNodesAndArcs 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 91 100 lookup' x y = Map.findWithDefault (error "lookup': node not found") y x 92 101 keys = Map.keys le … … 99 108 Color (getColor opts Green True True) $$$ 100 109 emptyNodeTypeParms 101 subNodeType <- newNodeType depG subNodeTypeParms102 subNodeList <- mapM (newNode depG subNodeType) keys103 let110 subNodeType <- newNodeType depG subNodeTypeParms 111 subNodeList <- mapM (newNode depG subNodeType) keys 112 let 104 113 nodes' = Map.fromList $ zip keys subNodeList 105 114 subArcMenu = LocalMenu(UDG.Menu Nothing []) … … 108 117 Color (getColor opts Black False False) $$$ 109 118 emptyArcTypeParms 110 subArcType <- newArcType depG subArcTypeParms111 let119 subArcType <- newArcType depG subArcTypeParms 120 let 112 121 insertSubArc = \ (node1, node2) -> newArc depG subArcType (return "") 113 122 (lookup' nodes' node1) (lookup' nodes' node2) 114 subArcList <- mapM insertSubArc $ Rel.toList $ Rel.intransKernel $123 subArcList <- mapM insertSubArc $ Rel.toList $ Rel.intransKernel $ 115 124 Rel.transClosure $ Rel.fromList $ getLibDeps le 116 writeIORef nodeArcRef (subNodeList, subArcList)125 writeIORef nodeArcRef (subNodeList, subArcList) 117 126 118 127 mShowGraph :: GInfo -> LIB_NAME -> IO() -
trunk/Interfaces/History.hs
r11082 r11229 37 37 38 38 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 46 add2history :: String -> IntState -> [UndoRedoElem] -> IntState 47 add2history name st descr 41 48 = case undoList $ i_hist st of 42 49 [] -> let nwEl = Int_CmdHistoryDescription { -
trunk/PGIP/DataTypesUtils.hs
r11082 r11229 61 61 add2hist :: [UndoRedoElem] -> CMDL_State -> CMDL_State 62 62 add2hist descr st 63 = let intst = add2history (intState st) []descr63 = let intst = add2history [] (intState st) descr 64 64 in st { 65 65 intState = intst } -
trunk/PGIP/DgCommands.hs
r11082 r11229 294 294 (n,_) -> selectANode n dgState 295 295 ) listNodes 296 -- oldH = history state297 296 nwist = emptyIntIState (i_libEnv dgState) (i_ln dgState) 298 297 return $ add2hist [IStateChange $ Just dgState] $ … … 307 306 cComorphism = getIdComorphism elems 308 307 } } 309 -- history = oldH {310 -- undoInstances = ([],[]):(undoInstances oldH),311 -- redoInstances = []},312 308 } 313 309 … … 332 328 (n,_) -> selectANode n dgState 333 329 ) lsNodes 334 -- oldH = history state335 330 nwist = emptyIntIState (i_libEnv dgState) (i_ln dgState) 336 331 -- ADD TO HISTORY … … 343 338 cComorphism = getIdComorphism elems 344 339 } } 345 -- history = oldH {346 -- undoInstances= ([],[]):(undoInstances oldH),347 -- redoInstances= []348 -- },349 340 } -
trunk/Proofs/InferBasic.hs
r11117 r11229 51 51 import GUI.Utils 52 52 import GUI.ProofManagement 53 import GUI.History(CommandHistory, addProveToHist)53 -- import GUI.History(CommandHistory, addProveToHist) 54 54 55 55 import qualified Common.Lib.Graph as Tree … … 153 153 basicInferenceNode :: Bool -- ^ True = CheckConsistency; False = Prove 154 154 -> LogicGraph -> (LIB_NAME,Node) -> LIB_NAME 155 -> GUIMVar -> LibEnv -> CommandHistory 155 -> GUIMVar -> LibEnv 156 -- -> CommandHistory 156 157 -> IO (Result (LibEnv, Result G_theory)) 157 basicInferenceNode checkCons lg (ln, node) libname guiMVar libEnv ch = do 158 basicInferenceNode checkCons lg (ln, node) libname guiMVar libEnv 159 -- ch 160 = do 158 161 let dGraph = lookupDGraph libname libEnv 159 162 runResultT $ do … … 211 214 newTh <- ResultT $ 212 215 proofManagementGUI lid1 ProofActions { 213 proveF = (proveKnownPMap lg chfreedefs),214 fineGrainedSelectionF = (proveFineGrainedSelect lg chfreedefs),216 proveF = (proveKnownPMap lg freedefs), 217 fineGrainedSelectionF = (proveFineGrainedSelect lg freedefs), 215 218 recalculateSublogicF = 216 219 recalculateSublogicAndSelectedTheory } … … 238 241 -> (LIB_NAME,Node) 239 242 -> GUIMVar 240 - > CommandHistory243 -- -> CommandHistory 241 244 -> LibEnv 242 245 -> IO (Result (LibEnv, Result G_theory)) 243 basicInferenceSubTree checkCons lg (ln, node) guiMVar chlibEnv = do246 basicInferenceSubTree checkCons lg (ln, node) guiMVar libEnv = do 244 247 let dGraph = lookupDGraph ln libEnv 245 248 runResultT $ do … … 308 311 newTh <- ResultT $ 309 312 proofManagementGUI lid1 ProofActions { 310 proveF = (proveKnownPMap lg chfreedefs),311 fineGrainedSelectionF = (proveFineGrainedSelect lg chfreedefs),313 proveF = (proveKnownPMap lg freedefs), 314 fineGrainedSelectionF = (proveFineGrainedSelect lg freedefs), 312 315 recalculateSublogicF = 313 316 recalculateSublogicAndSelectedTheory } … … 340 343 raw_symbol1 341 344 proof_tree1) => 342 LogicGraph -> CommandHistory 345 LogicGraph 346 -- -> CommandHistory 343 347 -> [FreeDefMorphism sentence morphism1] 344 348 -> ProofState lid sentence -> IO (Result (ProofState lid sentence)) 345 proveKnownPMap lg chfreedefs st =346 maybe (proveFineGrainedSelect lg chfreedefs st)347 (callProver st chFalse freedefs) $349 proveKnownPMap lg freedefs st = 350 maybe (proveFineGrainedSelect lg freedefs st) 351 (callProver st False freedefs) $ 348 352 lookupKnownProver st ProveGUI 349 353 … … 359 363 proof_tree1) => 360 364 ProofState lid sentence 361 -> CommandHistory -> Bool -- indicates if a translation was chosen 365 -- -> CommandHistory 366 -> Bool -- indicates if a translation was chosen 362 367 -> [FreeDefMorphism sentence morphism1] 363 368 -> (G_prover,AnyComorphism) -> IO (Result (ProofState lid sentence)) 364 callProver st chtrans_chosen freedefs p_cm@(_,acm) =369 callProver st trans_chosen freedefs p_cm@(_,acm) = 365 370 runResultT $ do 366 371 G_theory_with_prover lid th p <- liftR $ prepareForProving st p_cm … … 372 377 -- lift $ putStrLn $ show ps 373 378 let st' = markProved acm lid ps st 374 lift $ addProveToHist ch st'375 (if trans_chosen then Just p_cm else Nothing) ps379 -- lift $ addProveToHist ch st' 380 -- (if trans_chosen then Just p_cm else Nothing) ps 376 381 return st' 377 382 … … 387 392 raw_symbol1 388 393 proof_tree1) => 389 LogicGraph - > CommandHistory394 LogicGraph -- -> CommandHistory 390 395 -> [FreeDefMorphism sentence morphism1] 391 396 -> ProofState lid sentence -> IO (Result (ProofState lid sentence)) 392 proveFineGrainedSelect lg chfreedefs st =397 proveFineGrainedSelect lg freedefs st = 393 398 runResultT $ do 394 399 let sl = sublogicOfTheory st … … 400 405 pr <- selectProver cmsToProvers 401 406 ResultT $ callProver st{lastSublogic = sublogicOfTheory st, 402 comorphismsToProvers = cmsToProvers} chTrue freedefs pr407 comorphismsToProvers = cmsToProvers} True freedefs pr