Changeset 12779
- Timestamp:
- 04.11.2009 03:14:21 (3 weeks ago)
- Location:
- trunk/GUI
- Files:
-
- 2 removed
- 8 modified
-
ConsistencyChecker.hs (deleted)
-
Glade/ConsistencyChecker.glade (modified) (4 diffs)
-
Glade/GenericATP.glade (modified) (2 diffs)
-
Glade/ProverGUI.glade (modified) (2 diffs)
-
GtkConsistencyChecker.hs (modified) (7 diffs)
-
GtkGenericATP.hs (modified) (11 diffs)
-
GtkProverGUI.hs (modified) (8 diffs)
-
GtkTextView.hs (deleted)
-
GtkUtils.hs (modified) (7 diffs)
-
HTkGenericATP.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/GUI/Glade/ConsistencyChecker.glade
r12754 r12779 277 277 <property name="label" translatable="yes">No sublogic</property> 278 278 <property name="use_markup">True</property> 279 <property name="selectable">True</property> 280 <property name="max_width_chars">30</property> 279 281 </widget> 280 282 </child> … … 293 295 </widget> 294 296 <packing> 297 <property name="expand">False</property> 295 298 <property name="position">1</property> 296 299 </packing> … … 311 314 <property name="visible">True</property> 312 315 <property name="xalign">0</property> 316 <property name="yalign">0</property> 313 317 <property name="label" translatable="yes">No path selected</property> 314 <property name="wrap">True</property>315 318 <property name="selectable">True</property> 316 319 </widget> … … 330 333 </widget> 331 334 <packing> 335 <property name="expand">False</property> 332 336 <property name="position">2</property> 333 337 </packing> -
trunk/GUI/Glade/GenericATP.glade
r12754 r12779 90 90 <property name="can_focus">True</property> 91 91 <property name="invisible_char">●</property> 92 <property name="adjustment">20 0 40 1 0 0</property>92 <property name="adjustment">20 1 3600 1 0 0</property> 93 93 </widget> 94 94 <packing> … … 148 148 <property name="can_focus">True</property> 149 149 <property name="receives_default">False</property> 150 <property name="active">True</property>151 150 <property name="draw_indicator">True</property> 152 151 </widget> -
trunk/GUI/Glade/ProverGUI.glade
r12754 r12779 241 241 <property name="label" translatable="yes">No sublogic given</property> 242 242 <property name="use_markup">True</property> 243 <property name="selectable">True</property> 243 244 </widget> 244 245 </child> … … 277 278 <property name="visible">True</property> 278 279 <property name="xalign">0</property> 280 <property name="yalign">0</property> 279 281 <property name="label" translatable="yes">No path selected</property> 280 <property name="wrap">True</property>281 282 <property name="selectable">True</property> 282 283 </widget> -
trunk/GUI/GtkConsistencyChecker.hs
r12755 r12779 51 51 import Data.Maybe 52 52 53 data Finder = Finder { f name :: String53 data Finder = Finder { fName :: String 54 54 , finder :: G_cons_checker 55 , comorph s:: [AnyComorphism]55 , comorphism :: [AnyComorphism] 56 56 , selected :: Int } 57 57 … … 125 125 spinButtonSetValue sbTimeout $ fromIntegral guiDefaultTimeLimit 126 126 127 let widgets = [ toWidget trvFinder 128 , toWidget btnFineGrained 127 let widgets = [ toWidget btnFineGrained 129 128 , toWidget sbTimeout 130 129 , toWidget lblComorphism 131 , toWidget lblSublogic 132 ] 130 , toWidget lblSublogic ] 133 131 checkWidgets = widgets ++ [ toWidget btnClose 134 , toWidget trvNodes135 132 , toWidget btnNodesAll 136 133 , toWidget btnNodesNone … … 138 135 , toWidget btnNodesUnchecked 139 136 , toWidget btnNodesTimeout 140 , toWidget btnResults 141 ] 137 , toWidget btnResults ] 142 138 switch b = do 143 139 widgetSetSensitive btnStop $ not b … … 167 163 $ map (\ (n@(_,l),s) -> FNode (getDGNodeName l) n s CSUnchecked) 168 164 $ zip nodes sls 169 listFinder <- setListData trvFinder f name []165 listFinder <- setListData trvFinder fName [] 170 166 171 167 -- setup view selection actions 172 let update = do mf <- getSelectedSingle trvFinder listFinder 173 case mf of 174 Just (_,f) -> do 175 case comorphs f !! selected f of 176 Comorphism cid -> 177 let cName = language_name cid 178 dName = drop 1 $ dropWhile (/= ';') cName 179 in labelSetLabel lblComorphism 180 $ if null dName then "identity" else dName 181 widgetSetSensitive btnCheck True 182 Nothing -> do 183 labelSetLabel lblComorphism "No path selected" 184 widgetSetSensitive btnCheck False 168 let update = do 169 mf <- getSelectedSingle trvFinder listFinder 170 case mf of 171 Just (_,f) -> do 172 case comorphism f !! selected f of 173 Comorphism cid ->let cN = language_name cid 174 dN = drop 1 $ dropWhile (/= ';') cN in 175 labelSetLabel lblComorphism $ if null dN then "identity" else dN 176 widgetSetSensitive btnCheck True 177 Nothing -> do 178 labelSetLabel lblComorphism "No path selected" 179 widgetSetSensitive btnCheck False 185 180 setListSelectorSingle trvFinder update 186 181 187 selection <- setListSelectorMultiple trvNodes btnNodesAll btnNodesNone 188 btnNodesInvert $ updateNodes trvNodes listNodes 189 (\ s -> do 190 labelSetLabel lblSublogic $ show s 191 updateFinder trvFinder listFinder s) 192 (do labelSetLabel lblSublogic "No sublogic" 193 listStoreClear listFinder 194 activate widgets False 195 widgetSetSensitive btnCheck False) 196 (do activate widgets True 197 widgetSetSensitive btnCheck False) 182 setListSelectorMultiple trvNodes btnNodesAll btnNodesNone btnNodesInvert 183 $ updateNodes trvNodes listNodes 184 (\ s -> do labelSetLabel lblSublogic $ show s 185 updateFinder trvFinder listFinder s) 186 (do labelSetLabel lblSublogic "No sublogic" 187 listStoreClear listFinder 188 activate widgets False 189 widgetSetSensitive btnCheck False) 190 (do activate widgets True; widgetSetSensitive btnCheck False) 198 191 199 192 -- bindings 200 193 let selectWith f = do 201 mModel <- treeViewGetModel trvNodes 202 case mModel of 203 Nothing -> return () 204 Just m -> do 205 writeIORef selection [] 206 selector <- treeViewGetSelection trvNodes 207 treeModelForeach m $ \ iter -> do 208 path@(row:[]) <- treeModelGetPath m iter 209 (FNode { status = s }) <- listStoreGetValue listNodes row 210 if f s then do 211 treeSelectionSelectIter selector iter 212 modifyIORef selection (path:) 213 else treeSelectionUnselectIter selector iter 214 return False 194 model <- treeViewGetModel trvNodes 195 sel <- treeViewGetSelection trvNodes 196 treeModelForeach (fromJust model) $ \ i -> do 197 (row:[]) <- treeModelGetPath (fromJust model) i 198 (FNode { status = s }) <- listStoreGetValue listNodes row 199 (if f s then treeSelectionSelectIter else treeSelectionUnselectIter) 200 sel i 201 return False 215 202 216 203 onClicked btnNodesUnchecked $ selectWith (== CSUnchecked) … … 276 263 let n = getPName cc 277 264 f = Map.findWithDefault (Finder n cc [] 0) n m in 278 Map.insert n (f { comorph s = c : comorphsf}) m265 Map.insert n (f { comorphism = c : comorphism f}) m 279 266 ) Map.empty 280 267 $ getConsCheckers $ findComorphismPaths logicGraph sl) … … 287 274 check :: LibName -> LibEnv -> DGraph -> Finder -> Int 288 275 -> (Double -> String -> IO ()) -> [(Int,FNode)] -> IO [(Int, FNode)] 289 check ln le dg (Finder { finder = cc, comorph s= cs, selected = i}) timeout276 check ln le dg (Finder { finder = cc, comorphism = cs, selected = i}) timeout 290 277 update nodes = do 291 278 let count' = fromIntegral $ length nodes … … 306 293 (\ (n,_,c) -> n ++ ": " ++ show c) $ concatMap expand paths 307 294 case ret of 308 Just (_,(n,_,c)) -> case findIndex ((n ==) . fname) paths of 309 Just i -> let f = paths !! i in case findIndex (c ==) $ comorphs f of 310 Just i' -> do 311 listStoreSetValue list i $ f { selected = i' } 312 treeSelectionSelectPath selector [i] 313 unlock 314 Nothing -> return () 295 Just (_,(n,_,c)) -> case findIndex ((n ==) . fName) paths of 296 Just i -> let f = paths !! i in 297 case findIndex (c ==) $ comorphism f of 298 Just i' -> do 299 listStoreSetValue list i $ f { selected = i' } 300 treeSelectionSelectPath selector [i] 301 unlock 302 Nothing -> return () 315 303 Nothing -> return () 316 304 Nothing -> return () 317 305 318 306 expand :: Finder -> [(String, G_cons_checker, AnyComorphism)] 319 expand (Finder { f name = n, finder = cc, comorphs= cs }) =307 expand (Finder { fName = n, finder = cc, comorphism = cs }) = 320 308 map (\ c -> (n,cc,c)) cs 321 309 -
trunk/GUI/GtkGenericATP.hs
r12755 r12779 12 12 -} 13 13 14 module GUI.GtkGenericATP ( genericATPgui) where14 module GUI.GtkGenericATP ( genericATPgui ) where 15 15 16 16 import Graphics.UI.Gtk … … 36 36 37 37 import Logic.Prover 38 39 data Goal = Goal { name :: String40 , status :: GStatus }41 42 data GStatus = GOpen43 | GTimeout44 | GDisproved45 | GInconsistent46 | GProved47 deriving (Eq, Ord)48 49 instance Show Goal where50 show (Goal { name = n, status = s }) = spanString s $ statusToPrefix s ++ n51 52 statusToColor :: GStatus -> String53 statusToColor s = case s of54 GOpen -> "black"55 GProved -> "green"56 GDisproved -> "red"57 GTimeout -> "blue"58 GInconsistent -> "orange"59 60 statusToPrefix :: GStatus -> String61 statusToPrefix s = case s of62 GOpen -> "[ ] "63 GProved -> "[+] "64 GDisproved -> "[-] "65 GTimeout -> "[t] "66 GInconsistent -> "[*] "67 68 spanString :: GStatus -> String -> String69 spanString s m = "<span color=\"" ++ statusToColor s ++ "\">" ++ m ++ "</span>"70 71 instance Show GStatus where72 show GProved = spanString GProved "Proved"73 show GInconsistent = spanString GInconsistent "Proved (Theory inconsistent!)"74 show GDisproved = spanString GDisproved "Disproved"75 show GOpen = spanString GOpen "Open"76 show GTimeout = spanString GTimeout "Open (Timeout!)"77 38 78 39 genericATPgui :: (Ord proof_tree, Ord sentence) … … 117 78 windowSetTitle window $ prName ++ ": " ++ thName 118 79 119 let widgets = [ toWidget trvGoals , toWidget btnClose80 let widgets = [ toWidget btnClose , toWidget btnShowDetails 120 81 , toWidget btnHelp , toWidget btnSaveConfig 121 82 , toWidget sbTimeout , toWidget entryOptions 122 83 , toWidget cbIncludeProven , toWidget btnProveSelected 123 84 , toWidget btnProveSelected, toWidget btnProveAll 124 , toWidget lblStatus , toWidget trvAxioms 125 , toWidget btnSaveProblem , toWidget btnShowDetails 126 ] 85 , toWidget lblStatus , toWidget btnSaveProblem ] 127 86 switch = activate widgets 128 87 switchAll b = do … … 140 99 141 100 -- setting up lists 142 listGoals <- setListData trvGoals show $ 143 map (\ g -> let n = AS_Anno.senAttr g 144 cfg = Map.findWithDefault (error "Config not found!") n 145 $ configsMap initState 146 in Goal { name = n 147 , status = toGStatus cfg }) initGoals 101 listGoals <- setListData trvGoals show $ toGoals initState 148 102 listAxioms <- setListData trvAxioms id [] 149 103 … … 161 115 -- setting new selected goal 162 116 mSelected <- getSelectedSingle trvGoals listGoals 163 let s = maybe s' (\ (_, Goal { name = n }) -> s' { currentGoal = Just n})117 let s = maybe s' (\ (_, Goal { gName = n }) -> s' { currentGoal = Just n}) 164 118 mSelected 165 119 putMVar stateMVar s … … 221 175 222 176 -- show details of selected goal 223 onClicked btnStop $ tryTakeMVar threadId >>=maybe (return ()) killThread 177 onClicked btnStop $ do 178 tryTakeMVar threadId >>=maybe (return ()) killThread 179 putMVar threadId tid' 224 180 225 181 -- show details of selected goal … … 277 233 ATPError m -> errorDialog "Error" m 278 234 _ -> return () 279 postGUI Sync $ do235 postGUIAsync $ do 280 236 let progress = fromIntegral gPSF / fromIntegral numGoals 281 237 if cont then updat progress $ AS_Anno.senAttr $ fromJust nextSen … … 286 242 s' <- readMVar stateMVar 287 243 update' s' 288 return cont)244 return cont) 289 245 updat 0 firstGoalName 290 246 switchAll False … … 367 323 let newGoals = goalsList s 368 324 oldGoals = foldl (\ gs g -> (g, length gs):gs) [] oldGoals' 369 mapM_ (\ g -> do370 let n = AS_Anno.senAttr g 371 (g ', idx) = fromMaybe (error "Goal not found!")372 $ find (\ (Goal { name = n' }, _) -> n == n') oldGoals373 c fg= Map.findWithDefault (error "Config not found!") n $ configsMap s374 listStoreSetValue listGoals idx $ g ' { status = toGStatus cfg}325 mapM_ (\ g' -> do 326 let n = AS_Anno.senAttr g' 327 (g, idx) = fromMaybe (error "Goal not found!") 328 $ find (\ (Goal { gName = n' }, _) -> n == n') oldGoals 329 c = Map.findWithDefault (error "Config not found!") n $ configsMap s 330 listStoreSetValue listGoals idx $ g { gStatus = genericConfigToGStatus c } 375 331 ) newGoals 376 332 … … 378 334 selected <- getSelectedSingle trvGoals listGoals 379 335 case selected of 380 Just (_, Goal { name = n, status = stat }) -> do336 Just (_, Goal { gName = n, gStatus = stat }) -> do 381 337 let cfg = Map.findWithDefault (error "GUI.GenericATP.updateDisplay") n 382 338 $ configsMap s … … 396 352 setExtraOpts opts c = c { extraOpts = opts } 397 353 398 -- | Converts a ProofStatus into a GStatus 399 toGStatus :: GenericConfig proof_tree -> GStatus 400 toGStatus cfg = case goalStatus $ proofStatus cfg of 401 Proved (Just True) -> GProved 402 Proved _ -> GInconsistent 403 Disproved -> GDisproved 404 Open _ -> if timeLimitExceeded cfg then GTimeout else GOpen 354 toGoals :: GenericState sign sentence proof_tree pst -> [Goal] 355 toGoals s = map (\ g -> 356 let n = AS_Anno.senAttr g 357 c = Map.findWithDefault (error "Config not found!") n $ configsMap s 358 in Goal { gName = n, gStatus = genericConfigToGStatus c }) $ goalsList s -
trunk/GUI/GtkProverGUI.hs
r12754 r12779 12 12 -} 13 13 14 module GUI.GtkProverGUI 15 (showProverGUI) 16 where 14 module GUI.GtkProverGUI ( showProverGUI ) where 17 15 18 16 import Graphics.UI.Gtk … … 21 19 import GUI.GtkUtils 22 20 import qualified GUI.Glade.ProverGUI as ProverGUI 21 import GUI.HTkProofDetails -- not implemented in Gtk 23 22 24 23 import Common.AS_Annotation as AS_Anno 25 24 import qualified Common.Doc as Pretty 26 import qualified Common.Result asResult25 import Common.Result 27 26 import qualified Common.OrderedMap as OMap 28 27 import Common.ExtSign 29 28 29 import Control.Monad ((<=<)) 30 30 import Control.Concurrent.MVar 31 31 … … 40 40 import Static.GTheory 41 41 42 import Monad (when)43 44 import Data.IORef45 42 import qualified Data.Map as Map 46 43 import Data.List 44 import Data.Maybe ( fromJust, fromMaybe, isJust ) 45 46 data GProver = GProver { pName :: String 47 , prover :: G_prover 48 , comorphism :: [AnyComorphism] 49 , selected :: Int } 47 50 48 51 {- ProverGUI -} 49 52 50 53 -- | Displays the consistency checker window 51 showProverGUI :: 52 (Logic lid sublogics basic_spec sentence symb_items symb_map_items 53 sign morphism symbol raw_symbol proof_tree) 54 showProverGUI :: Logic lid sublogics basic_spec sentence symb_items 55 symb_map_items sign morphism symbol raw_symbol proof_tree 54 56 => lid 55 57 -> ProofActions lid sentence -- ^ record of possible GUI actions … … 60 62 -> [(G_prover,AnyComorphism)] -- ^ list of suitable comorphisms to provers 61 63 -- for sublogic of G_theory 62 -> IO (Result .ResultG_theory)63 showProverGUI lid prGuiAcs thName warn ingTxtth knownProvers comorphList = do64 -> IO (Result G_theory) 65 showProverGUI lid prGuiAcs thName warn th knownProvers comorphList = do 64 66 initState <- (initialState lid thName th knownProvers comorphList 65 67 >>= recalculateSublogicF prGuiAcs) … … 106 108 107 109 -- set list data 108 listProvers <- setListData trvProvers id $ Map.keys $ proversMap initState 109 listGoals <- setListData trvGoals id $ OMap.keys $ goalMap initState 110 listAxioms <- setListData trvAxioms id 111 $ map (\ (k,s) -> if wasTheorem s then "(Th) " ++ k else k) 112 $ OMap.toList axioms 113 listTheorems <- setListData trvTheorems (id) $ OMap.keys $ goalMap initState 110 listProvers <- setListData trvProvers pName [] 111 listGoals <- setListData trvGoals show $ toGoals initState 112 listAxioms <- setListData trvAxioms id $ toAxioms axioms 113 listTheorems <- setListData trvTheorems id $ toTheorem initState 114 115 let noProver = [ toWidget btnFineGrained 116 , toWidget btnProve 117 , toWidget lblComorphism 118 , toWidget lblSublogic ] 119 noAxiom = [ toWidget btnAxiomsAll 120 , toWidget btnAxiomsNone 121 , toWidget btnAxiomsInvert 122 , toWidget btnAxiomsFormer ] 123 noTheory = [ toWidget btnTheoremsAll 124 , toWidget btnTheoremsNone 125 , toWidget btnTheoremsInvert ] 126 noGoal = [ toWidget btnGoalsAll 127 , toWidget btnGoalsNone 128 , toWidget btnGoalsInvert 129 , toWidget btnGoalsSelectOpen ] 130 prove = noProver ++ noAxiom ++ noTheory ++ noGoal ++ 131 [ toWidget btnShowTheory 132 , toWidget btnShowSelectedTheory 133 , toWidget btnClose 134 , toWidget btnProofDetails 135 , toWidget btnDisplay ] 136 update s' = do 137 s <- updateGoals trvGoals listGoals =<< 138 updateComorphism lblComorphism trvProvers listProvers =<< 139 updateProver trvProvers listProvers =<< 140 updateSublogic lblSublogic prGuiAcs knownProvers =<< 141 setSelectedGoals trvGoals listGoals =<< 142 setSelectedSens trvAxioms listAxioms trvTheorems listTheorems s' 143 activate noProver 144 (isJust (selectedProver s) && not (null $ selectedGoals s)) 145 return s 146 147 activate noGoal (not $ OMap.null $ goalMap initState) 148 activate noAxiom (not $ OMap.null axioms) 149 activate noTheory (not $ OMap.null $ goalMap initState) 114 150 115 151 -- setup provers list 116 setListSelectorSingle trvProvers $ modifyMVar_ state 117 $ selectProver trvProvers listProvers 118 setSelectedProver trvProvers initState 119 120 let update = updateStatusSublogic lblSublogic trvGoals listGoals trvAxioms 121 listAxioms trvTheorems listTheorems trvProvers listProvers 122 prGuiAcs knownProvers 123 action = modifyMVar_ state $ update 152 setListSelectorSingle trvProvers $ modifyMVar_ state $ 153 update <=< setSelectedProver trvProvers listProvers 124 154 125 155 -- setup goal list 126 selectedGoals' <- setListSelectorMultiple trvGoals btnGoalsAll btnGoalsNone 127 btnGoalsInvert action 128 onClicked btnGoalsSelectOpen $ modifyMVar_ state $ (\ s -> do 129 (Just model) <- treeViewGetModel trvGoals 130 selector <- treeViewGetSelection trvGoals 131 let 132 isOpen st = 133 let thst = thmStatus st 134 in if null thst 135 then True 136 else case maximum $ map snd $ thst of 156 setListSelectorMultiple trvGoals btnGoalsAll btnGoalsNone btnGoalsInvert $ 157 modifyMVar_ state update 158 159 onClicked btnGoalsSelectOpen $ modifyMVar_ state $ \ s -> do 160 model <- treeViewGetModel trvGoals 161 sel <- treeViewGetSelection trvGoals 162 let isOpen st = let thst = thmStatus st in 163 null thst || case maximum $ map snd thst of 137 164 BasicProof _ pst -> isOpenGoal $ goalStatus pst 138 165 _ -> False 139 select iter = do 140 (row:[]) <- treeModelGetPath model iter 141 key <- listStoreGetValue listGoals row 142 if maybe (error "goal lookup") isOpen $ OMap.lookup key $ goalMap s 143 then do 144 modifyIORef selectedGoals' ((row:[]):) 145 treeSelectionSelectIter selector iter 146 else treeSelectionUnselectIter selector iter 147 return False 148 writeIORef selectedGoals' [] 149 treeModelForeach model select 150 s' <- update s 151 return s') 166 treeModelForeach (fromJust model) $ \ i -> do 167 (row:[]) <- treeModelGetPath (fromJust model) i 168 key <- listStoreGetValue listGoals row 169 (if isOpen $ fromJust $ OMap.lookup (gName key) $ goalMap s 170 then treeSelectionSelectIter else treeSelectionUnselectIter) sel i 171 return False 172 update s 152 173 153 174 -- setup axioms list 154 se lectedAxioms <- setListSelectorMultiple trvAxioms btnAxiomsAll155 btnAxiomsNone btnAxiomsInvert action156 onClicked btnAxiomsFormer $ modifyMVar_ state $ (\ s -> do175 setListSelectorMultiple trvAxioms btnAxiomsAll btnAxiomsNone btnAxiomsInvert 176 $ modifyMVar_ state update 177 onClicked btnAxiomsFormer $ modifyMVar_ state $ \ s -> do 157 178 aM <- axiomMap s 158 (Just model) <- treeViewGetModel trvAxioms 159 selector <- treeViewGetSelection trvAxioms 160 let 161 isNotFormerTheorem st = not $ wasTheorem st 162 select iter = do 163 (row:[]) <- treeModelGetPath model iter 164 key <- listStoreGetValue listAxioms row 165 k <- case stripPrefix "(Th) " key of 166 Just k -> return k 167 Nothing -> return key 168 if maybe (error "axiom lookup") isNotFormerTheorem $ OMap.lookup k aM 169 then do 170 modifyIORef selectedAxioms ((row:[]):) 171 treeSelectionSelectIter selector iter 172 else treeSelectionUnselectIter selector iter 173 return False 174 writeIORef selectedAxioms [] 175 treeModelForeach model select 176 s' <- update s 177 return s') 179 model <- treeViewGetModel trvAxioms 180 sel <- treeViewGetSelection trvAxioms 181 treeModelForeach (fromJust model) $ \ i -> do 182 (row:[]) <- treeModelGetPath (fromJust model) i 183 key <- listStoreGetValue listAxioms row 184 k <- case stripPrefix "(Th) " key of 185 Just k -> return k 186 Nothing -> return key 187 (if not $ wasTheorem $ fromJust $ OMap.lookup k aM 188 then treeSelectionSelectIter else treeSelectionUnselectIter) sel i 189 return False 190 update s 191 192 modifyMVar_ state $ update <=< updateProver trvProvers listProvers 178 193 179 194 -- setup theorems list 180 195 setListSelectorMultiple trvTheorems btnTheoremsAll btnTheoremsNone 181 btnTheoremsInvert action196 btnTheoremsInvert $ modifyMVar_ state update 182 197 183 198 -- button bindings … … 185 200 186 201 onClicked btnShowTheory $ 187 displayTheoryWithWarning "Theory" thName warn ingTxtth202 displayTheoryWithWarning "Theory" thName warn th 188 203 189 204 onClicked btnShowSelectedTheory $ do 190 205 s <- readMVar state 191 displayTheoryWithWarning "Selected Theory" thName warningTxt 192 (selectedTheory s) 193 194 onClicked btnDisplay $ do 206 displayTheoryWithWarning "Selected Theory" thName warn $ selectedTheory s 207 208 onClicked btnDisplay $ readMVar state >>= displayGoals 209 210 onClicked btnProofDetails $ do 195 211 s <- readMVar state 196 displayGoals s 197 198 onClicked btnProofDetails $ return () 199 200 onClicked btnProve $ return () 201 202 onClicked btnFineGrained $ forkIO_ $ modifyMVar_ state $ (\ s -> do 203 let s' = s { proverRunning = True } 204 prState <- update s' 205 Result.Result ds ms'' <- fineGrainedSelectionF prGuiAcs prState 206 s'' <- case ms'' of 207 Nothing -> do 208 -- Is error needed? 209 --errorDialog "Error" (showRelDiags 2 ds) 210 return s' 211 Just res -> return res 212 return s'' { proverRunning = False 213 , accDiags = accDiags s'' ++ ds }) 212 forkIO_ $ doShowProofDetails s 213 214 onClicked btnProve $ do 215 activate prove False 216 forkIOWithPostProcessing (readMVar state >>= proveF prGuiAcs) 217 $ \ (Result ds ms) -> do 218 s <- case ms of 219 Nothing -> do 220 errorDialog "Error" (showRelDiags 2 ds) 221 takeMVar state 222 Just res -> do 223 takeMVar state 224 return res 225 activate prove True 226 putMVar state =<< update s { proverRunning = False 227 , accDiags = accDiags s ++ ds} 228 229 onClicked btnFineGrained $ modifyMVar_ state $ \ s -> do 230 mp <- fineGrainedSelection trvProvers listProvers 231 update <=< updateProver trvProvers listProvers 232 $ maybe s (\ p -> s { selectedProver = Just $ pName p }) mp 214 233 215 234 onDestroy window $ putMVar wait () … … 218 237 219 238 _ <- takeMVar wait 220 return $ Result.Result { Result.diags = [] 221 , Result.maybeResult = Nothing } 239 s <- takeMVar state 240 case theory s of 241 G_theory lidT sigT indT sensT _ -> do 242 gMap <- coerceThSens (logicId s) lidT "ProverGUI last coerce" $ goalMap s 243 return Result { diags = accDiags s 244 , maybeResult = Just $ G_theory lidT sigT indT 245 (Map.union sensT gMap) startThId } 222 246 223 247 -- | Called whenever the button "Display" is clicked. 224 displayGoals :: 225 (Logic lid sublogics basic_spec sentence symb_items symb_map_items 226 sign morphism symbol raw_symbol proof_tree) 227 => ProofState lid sentence 228 -> IO () 248 displayGoals :: Logic lid sublogics basic_spec sentence symb_items 249 symb_map_items sign morphism symbol raw_symbol proof_tree 250 => ProofState lid sentence -> IO () 229 251 displayGoals s = case theory s of 230 252 G_theory lid1 (ExtSign sig1 _) _ _ _ -> do 231 253 let thName = theoryName s 232 goalsText s' = show $ Pretty.vsep $ 233 map (print_named lid1 . 234 AS_Anno.mapNamed (simplify_sen lid1 sig1)) $ 235 toNamedList s' 254 goalsText = show . Pretty.vsep 255 . map (print_named lid1 . AS_Anno.mapNamed (simplify_sen lid1 sig1)) 256 . toNamedList 236 257 sens = selectedGoalMap s 237 258 sens' <- coerceThSens (logicId s) lid1 "" sens … … 239 260 $ Just (thName ++ "-goals.txt") 240 261 241 setSelectedProver :: 242 TreeView 243 -> ProofState lid sentence 244 -> IO () 245 setSelectedProver view s = do 262 fineGrainedSelection :: TreeView -> ListStore GProver -> IO (Maybe GProver) 263 fineGrainedSelection view list = do 264 ps <- listStoreToList list 246 265 selector <- treeViewGetSelection view 247 let ind = case selectedProver s of 248 Just sp -> findIndex (==sp) $ Map.keys (proversMap s) 249 Nothing -> Nothing 250 maybe (return ()) (\i -> treeSelectionSelectPath selector [i]) ind 251 252 updateStatusSublogic :: 253 Label -- ^ sublogic label 254 -> TreeView -- ^ goals list 255 -> ListStore String -- ^ goals list 256 -> TreeView -- ^ axioms list 257 -> ListStore String -- ^ axioms list store 258 -> TreeView -- ^ theorems list 259 -> ListStore String -- ^ theorems list store 260 -> TreeView -- ^ provers list 261 -> ListStore String -- ^ provers list store 262 -> ProofActions lid sentence -- ^ record of possible GUI actions 263 -> KnownProvers.KnownProversMap -- ^ map of known provers 264 -> ProofState lid sentence 265 -> IO (ProofState lid sentence) 266 updateStatusSublogic lbl gls listGls axs listAxs ths listThs prs listPrs 267 prGuiAcs knownProvers s' = do 268 s'' <- updateStateGetSelectedSens axs listAxs ths listThs s' 269 s''' <- updateStateGetSelectedGoals gls listGls s'' 270 s <- recalculateSublogicF prGuiAcs $ (s''' {proversMap = knownProvers}) 271 setSublogic lbl $ show $ sublogicOfTheory s 272 when (Map.keys (proversMap s') /= Map.keys (proversMap s)) 273 (do updateListData listPrs $ Map.keys $ proversMap s' 274 setSelectedProver prs s) 275 return s{ selectedProver = 276 maybe Nothing (\ sp -> find (==sp) $ Map.keys (proversMap s)) 277 (selectedProver s) } 278 279 updateStateGetSelectedGoals :: 280 TreeView 281 -> ListStore String 282 -> ProofState lid sentence 283 -> IO (ProofState lid sentence) 284 updateStateGetSelectedGoals view listGoals s = do 285 selector <- treeViewGetSelection view 286 rows <- treeSelectionGetSelectedRows selector 287 goals <- mapM (\ (row:[]) -> listStoreGetValue listGoals row) rows 288 return s { selectedGoals = goals } 289 290 updateStateGetSelectedSens :: 291 TreeView -- ^ axioms listbox 292 -> ListStore String 293 -> TreeView -- ^ theorems listbox 294 -> ListStore String 295 -> ProofState lid sentence 296 -> IO (ProofState lid sentence) 297 updateStateGetSelectedSens axs listAxs ths listThs s = do 298 selectorAxs <- treeViewGetSelection axs 299 selectorThs <- treeViewGetSelection ths 300 rowsAxs <- treeSelectionGetSelectedRows selectorAxs 301 rowsThs <- treeSelectionGetSelectedRows selectorThs 302 axioms <- mapM (\ (row:[]) -> listStoreGetValue listAxs row) rowsAxs 303 theorems <- mapM (\ (row:[]) -> listStoreGetValue listThs row) rowsThs 304 return s { includedAxioms = axioms 305 , includedTheorems = theorems } 266 if null ps then error "Cant make selection without sublogic!" 267 else do 268 ret <- listChoiceAux "Choose a translation" 269 (\ (n,_,c) -> n ++ ": " ++ show c) $ concatMap expand ps 270 case ret of 271 Just (_,(n,_,c)) -> case findIndex ((n ==) . pName) ps of 272 Just i -> let p = ps !! i in case findIndex (c ==) $ comorphism p of 273 Just i' -> do 274 let p' = p { selected = i' } 275 listStoreSetValue list i p' 276 treeSelectionSelectPath selector [i] 277 return $ Just p' 278 Nothing -> error "can't find selected comorphism" 279 Nothing -> error "can't find selected prover" 280 Nothing -> return Nothing 281 282 expand :: GProver -> [(String, G_prover, AnyComorphism)] 283 expand (GProver { pName = n, prover = p, comorphism = cs }) = 284 map (\ c -> (n, p, c)) cs 285 286 updateSublogic :: Label -> ProofActions lid sentence 287 -> KnownProvers.KnownProversMap -> ProofState lid sentence 288 -> IO (ProofState lid sentence) 289 updateSublogic lbl prGuiAcs knownProvers s' = do 290 s <- recalculateSublogicF prGuiAcs s' { proversMap = knownProvers } 291 labelSetLabel lbl $ show $ sublogicOfTheory s 292 return s 293 294 updateComorphism :: Label -> TreeView -> ListStore GProver 295 -> ProofState lid sentence -> IO (ProofState lid sentence) 296 updateComorphism lbl trvProvers listProvers s = do 297 mprover <- getSelectedSingle trvProvers listProvers 298 case mprover of 299 Just (_, p) -> case comorphism p !! selected p of 300 Comorphism cid -> let dN = drop 1 $ dropWhile (/= ';') $ language_name cid 301 in labelSetLabel lbl $ if null dN then "identity" else dN 302 Nothing -> return () 303 return s 304 305 updateProver :: TreeView -> ListStore GProver -> ProofState lid sentence 306 -> IO (ProofState lid sentence) 307 updateProver trvProvers listProvers s = do 308 let new = toProvers s 309 old <- listStoreToList listProvers 310 let prvs = map (\ p -> case find ((pName p ==) . pName) old of 311 Nothing -> p 312 Just p' -> let oldC = comorphism p' !! selected p' in 313 p { selected = fromMaybe 0 $ findIndex (== oldC) $ comorphism p } 314 ) new 315 selFirst = do 316 selectFirst trvProvers 317 setSelectedProver trvProvers listProvers s 318 updateListData listProvers prvs 319 case selectedProver s of 320 Just p -> case findIndex ((p ==) . pName) prvs of 321 Just i -> do 322 sel <- treeViewGetSelection trvProvers 323 treeSelectionSelectPath sel [i] 324 return s 325 Nothing -> selFirst 326 Nothing -> selFirst 327 328 updateGoals :: TreeView -> ListStore Goal -> ProofState lid sentence 329 -> IO (ProofState lid sentence) 330 updateGoals trvGoals listGoals s = do 331 updateListData listGoals $ toGoals s 332 model <- treeViewGetModel trvGoals 333 sel <- treeViewGetSelection trvGoals 334 treeModelForeach (fromJust model) $ \ i -> do 335 (row:[]) <- treeModelGetPath (fromJust model) i 336 g <- listStoreGetValue listGoals row 337 (if any (gName g ==) $ selectedGoals s 338 then treeSelectionSelectIter else treeSelectionUnselectIter) sel i 339 return False 340 return s 341 342 setSelectedGoals :: TreeView -> ListStore Goal -> ProofState lid sentence 343 -> IO (ProofState lid sentence) 344 setSelectedGoals trvGoals listGoals s = do 345 goals <- getSelectedMultiple trvGoals listGoals 346 return s { selectedGoals = map (gName . snd) goals } 347 348 setSelectedSens :: TreeView -> ListStore String -> TreeView -> ListStore String 349 -> ProofState lid sentence -> IO (ProofState lid sentence) 350 setSelectedSens axs listAxs ths listThs s = do 351 axioms <- getSelectedMultiple axs listAxs 352 theorems <- getSelectedMultiple ths listThs 353 return s { includedAxioms = map snd axioms 354 , includedTheorems = map snd theorems } 306 355 307 356 -- | Called whenever a prover is selected from the "Pick Theorem Prover" list. 308 selectProver :: 309 TreeView 310 -> ListStore String 311 -> ProofState lid sentence 312 -> IO (ProofState lid sentence) 313 selectProver view listPrs s = do 314 selector <- treeViewGetSelection view 315 ((row:[]):[]) <- treeSelectionGetSelectedRows selector 316 prover <- listStoreGetValue listPrs row 317 return s { selectedProver = Just prover } 318 319 -- | Called to set sublogic label 320 setSublogic :: Label -> String -> IO () 321 setSublogic label text = labelSetLabel label $ "<b>" ++ text ++ "</b>" 322 357 setSelectedProver :: TreeView -> ListStore GProver -> ProofState lid sentence 358 -> IO (ProofState lid sentence) 359 setSelectedProver trvProvers listProvers s = do 360 mprover <- getSelectedSingle trvProvers listProvers 361 return s { selectedProver = maybe Nothing (Just . pName . snd) mprover } 362 363 toAxioms :: ThSens sentence (AnyComorphism, BasicProof) -> [String] 364 toAxioms = 365 map (\ (k,s) -> if wasTheorem s then "(Th) " ++ k else k) . OMap.toList 366 367 toGoals :: ProofState lid sentence -> [Goal] 368 toGoals = map toGoal . OMap.toList . goalMap 369 where toGoal (n, st) = let ts = thmStatus st in 370 Goal { gName = n 371 , gStatus = if null ts then GOpen 372 else basicProofToGStatus $ maximum $ map snd ts } 373 374 toTheorem :: ProofState lid sentence -> [String] 375 toTheorem = OMap.keys . goalMap 376 377 toProvers :: ProofState lid sentence -> [GProver] 378 toProvers = Map.elems . foldr (\ (p', c) m -> 379 let n = getPName p' 380 p = Map.findWithDefault (GProver n p' [] 0) n m in 381 Map.insert n (p { comorphism = c : comorphism p}) m 382 ) Map.empty . comorphismsToProvers -
trunk/GUI/GtkUtils.hs
r12754 r12779 72 72 73 73 , activate 74 75 -- * Datatypes and functions for prover 76 , Goal (..) 77 , GStatus (..) 78 , proofStatusToGStatus 79 , basicProofToGStatus 80 , genericConfigToGStatus 74 81 ) 75 82 where … … 80 87 import qualified GUI.Glade.Utils as Utils 81 88 82 import Static.GTheory (G_theory) 89 import Static.GTheory 90 83 91 import Common.DocUtils (showDoc) 84 92 … … 91 99 import System.IO (hFlush, hClose, hPutStr, openTempFile) 92 100 93 import Data.IORef 101 import Logic.Prover 102 103 import Interfaces.GenericATPState 94 104 95 105 -- | Returns a GladeXML Object of a xmlstring. … … 501 511 -- | Setup list with multiple selection 502 512 setListSelectorMultiple :: TreeView -> Button -> Button -> Button -> IO () 503 -> IO ( IORef [TreePath])513 -> IO () 504 514 setListSelectorMultiple view btnAll btnNone btnInvert action = do 505 515 selector <- treeViewGetSelection view 506 516 treeSelectionSetMode selector SelectionMultiple 507 ioRefSelection <- newIORef ([] :: [TreePath])508 517 509 518 -- setup selector 510 onCursorChanged view $ do 511 s' <- treeSelectionGetSelectedRows selector 512 s <- readIORef ioRefSelection 513 let newSelection = [ x | x <- s', notElem x s] 514 ++ [ x | x <- s, notElem x s'] 515 writeIORef ioRefSelection newSelection 516 treeSelectionUnselectAll selector 517 mapM_ (treeSelectionSelectPath selector) newSelection 518 action 519 onCursorChanged view action 519 520 520 521 treeSelectionSelectAll selector 521 522 522 523 -- setup buttons 523 onClicked btnAll $ do selectAll view ioRefSelection; action 524 onClicked btnNone $ do selectNone view ioRefSelection; action 525 onClicked btnInvert $ do selectInvert view ioRefSelection; action 526 527 return ioRefSelection 524 onClicked btnAll $ do selectAll view; action 525 onClicked btnNone $ do selectNone view; action 526 onClicked btnInvert $ do selectInvert view; action 527 return () 528 528 529 529 -- | Selects the first item if possible … … 542 542 path <- treeModelGetPath model iter 543 543 treeViewSetCursor view path Nothing 544 545 -- | Select all rows 546 selectAll :: TreeView -> IO () 547 selectAll view = treeViewGetSelection view >>= treeSelectionSelectAll 548 549 -- | Deselect all rows 550 selectNone :: TreeView -> IO () 551 selectNone view = treeViewGetSelection view >>= treeSelectionUnselectAll 552 553 -- | Invert selection of list 554 selectInvert :: TreeView -> IO () 555 selectInvert view = do 556 sel <- treeViewGetSelection view 557 selected <- treeSelectionGetSelectedRows sel 558 treeSelectionSelectAll sel 559 rows <- treeSelectionGetSelectedRows sel 560 mapM_ (\ row -> (if elem row selected 561 then treeSelectionUnselectPath else treeSelectionSelectPath) sel row 562 ) rows 544 563 545 564 -- | Get selected item … … 571 590 return $ zip rows items 572 591 573 -- | Select all rows574 selectAll :: TreeView -> IORef [TreePath] -> IO ()575 selectAll view ioRefSelection = do576 selector <- treeViewGetSelection view577 treeSelectionSelectAll selector578 s <- treeSelectionGetSelectedRows selector579 writeIORef ioRefSelection s580 581 -- | Deselect all rows582 selectNone :: TreeView -> IORef [TreePath] -> IO ()583 selectNone view ioRefSelection = do584 selector <- treeViewGetSelection view585 treeSelectionUnselectAll selector586 writeIORef ioRefSelection []587 588 -- | Invert selection of list589 selectInvert :: TreeView -> IORef [TreePath] -> IO ()590 selectInvert view ioRefSelection = do591 selector <- treeViewGetSelection view592 old <- treeSelectionGetSelectedRows selector593 treeSelectionSelectAll selector594 mapM_ (treeSelectionUnselectPath selector) old595 new <- treeSelectionGetSelectedRows selector596 writeIORef ioRefSelection new597 598 592 -- | Sets data of list 599 593 setListData :: TreeView -> (a -> String) -> [a] -> IO (ListStore a) … … 619 613 activate :: [Widget] -> Bool -> IO () 620 614 activate widgets active = mapM_ (\ w -> widgetSetSensitive w active) widgets 615 616 617 -- * Datatypes and functions for prover 618 619 data Goal = Goal { gName :: String 620 , gStatus :: GStatus } 621 622 data GStatus = GOpen 623 | GTimeout 624 | GDisproved 625 | GInconsistent 626 | GProved 627 | GGuessed 628 | GConjectured 629 | GHandwritten 630 deriving (Eq, Ord) 631 632 instance Show Goal where 633 show (Goal { gName = n, gStatus = s }) = spanString s $ statusToPrefix s ++ n 634 635 statusToColor :: GStatus -> String 636 statusToColor s = case s of 637 GOpen -> "black" 638 GProved -> "green" 639 GDisproved -> "red" 640 GTimeout -> "blue" 641 GInconsistent -> "orange" 642 GGuessed -> "darkgreen" 643 GConjectured -> "darkgreen" 644 GHandwritten -> "darkgreen" 645 646 statusToPrefix :: GStatus -> String 647 statusToPrefix s = case s of 648 GOpen -> "[ ] " 649 GProved -> "[+] " 650 GDisproved -> "[-] " 651 GTimeout -> "[t] " 652 GInconsistent -> "[*] " 653 GGuessed -> "[.] " 654 GConjectured -> "[:] " 655 GHandwritten -> "[/] " 656 657 spanString :: GStatus -> String -> String 658 spanString s m = "<span color=\"" ++ statusToColor s ++ "\">" ++ m ++ "</span>" 659 660 instance Show GStatus where 661 show GProved = spanString GProved "Proved" 662 show GInconsistent = spanString GInconsistent "Proved by contradiction" 663 show GDisproved = spanString GDisproved "Disproved" 664 show GOpen = spanString GOpen "Open" 665 show GTimeout = spanString GTimeout "Open (Timeout!)" 666 show GGuessed = spanString GGuessed "Guessed" 667 show GConjectured = spanString GConjectured "Conjectured" 668 show GHandwritten = spanString GHandwritten "Handwritten" 669 670 -- | Converts a ProofStatus into a GStatus 671 proofStatusToGStatus :: forall a . ProofStatus a -> GStatus 672 proofStatusToGStatus p = case goalStatus p of 673 Proved (Just True) -> GProved 674 Proved _ -> GInconsistent 675 Disproved -> GDisproved 676 Open _ -> GOpen 677 678 -- | Converts a BasicProof into a GStatus 679 basicProofToGStatus :: BasicProof -> GStatus 680 basicProofToGStatus p = case p of 681 BasicProof _ st -> proofStatusToGStatus st 682 Guessed -> GGuessed 683 Conjectured -> GConjectured 684 Handwritten -> GHandwritten 685 686 -- | Converts a GenericConfig into a GStatus 687 genericConfigToGStatus :: GenericConfig a -> GStatus 688 genericConfigToGStatus cfg = case proofStatusToGStatus $ proofStatus cfg of 689 GOpen -> if timeLimitExceeded cfg then GTimeout else GOpen 690 s -> s -
trunk/GUI/HTkGenericATP.hs
r12754 r12779 86 86 -} 87 87 statusProvedButInconsistent :: (ProofStatusColour, String) 88 statusProvedButInconsistent = (Brown, "Proved (Theory inconsistent!)")88 statusProvedButInconsistent = (Brown, "Proved by contradiction") 89 89 90 90 {- |