HTkProverGUI.hs revision ad15c42a0fcf132bf31a3f986325c61ac35dced2
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeModule : $Header$
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeDescription : Goal management GUI.
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeCopyright : (c) Rene Wagner, Klaus Luettich, Uni Bremen 2005
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeMaintainer : luecke@informatik.uni-bremen.de
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeStability : provisional
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckePortability : needs POSIX
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeGoal management GUI for the structured level similar to how 'SPASS.Prove'
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeworks for SPASS.
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckemodule GUI.HTkProverGUI (proofManagementGUI,GUIMVar) where
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport qualified Common.Doc as Pretty
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport Common.Result as Result
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport qualified Data.Map as Map
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport qualified Common.OrderedMap as OMap
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport qualified Control.Concurrent as Conc
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke (createTextSaveDisplay, displayTheoryWithWarning)
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Lueckeimport qualified Comorphisms.KnownProvers as KnownProvers
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke-- * Proof Management GUI
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke-- ** Defining the view
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke Colors used by the GUI to indicate the status of a goal.
548f3850942936a8c6021185c8391dfcd3b03018Dominik Lueckedata ProverStatusColour
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- | Not running
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke deriving (Bounded,Enum,Show)
548f3850942936a8c6021185c8391dfcd3b03018Dominik Lueckedata SelButtonFrame = SBF { selAllEv :: Event ()
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke , deselAllEv :: Event ()
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke , sbfBtns :: [Button]
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke , sbfBtnFrame :: Frame}
548f3850942936a8c6021185c8391dfcd3b03018Dominik Lueckedata SelAllListbox = SAL SelButtonFrame (ListBox String)
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke Generates a ('ProverStatusColour', 'String') tuple.
548f3850942936a8c6021185c8391dfcd3b03018Dominik LueckestatusNotRunning :: (ProverStatusColour, String)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckestatusNotRunning = (Black, "No Prover Running")
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke Generates a ('ProverStatusColour', 'String') tuple.
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckestatusRunning :: (ProverStatusColour, String)
548f3850942936a8c6021185c8391dfcd3b03018Dominik LueckestatusRunning = (Blue, "Waiting for Prover")
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke{- | Converts a 'ProofState' into a ('ProverStatusColour',
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke 'String') tuple to be displayed by the GUI.
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LuecketoGuiStatus :: ProofState lid sentence
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> (ProverStatusColour, String)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LuecketoGuiStatus st = if proverRunning st
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke then statusRunning
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke else statusNotRunning
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke Generates a list of 'GUI.HTkUtils.LBGoalView' representations of all goals
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke Uses a status indicator internally.
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckegoalsView :: ProofState lid sentence -- ^ current global state
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> [LBGoalView] -- ^ resulting ['LBGoalView'] list
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckegoalsView = map toStatus . OMap.toList . goalMap
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke where toStatus (l,st) =
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke let tStatus = thmStatus st
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke si = if null tStatus
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke then LBIndicatorOpen
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke else indicatorFromBasicProof
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke (maximum $ map snd tStatus)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke in LBGoalView { statIndicator = si
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke , goalDescription = l}
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke-- ** GUI Implementation
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke-- *** Utility Functions
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke Populates the "Pick Theorem Prover" 'ListBox' with prover names (or possibly
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke paths to provers).
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckepopulatePathsListBox :: ListBox String
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckepopulatePathsListBox lb prvs = do
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke lb # value (Map.keys prvs)
548f3850942936a8c6021185c8391dfcd3b03018Dominik LueckepopulateAxiomsList ::
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke (Logic lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke sign1 morphism1 symbol1 raw_symbol1 proof_tree1) =>
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke ListBox String
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> ProofState lid1 sentence1
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckepopulateAxiomsList lbAxs s =
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke do aM' <- axiomMap s
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke lbAxs # value (map (\ (k, sen) -> if wasTheorem sen then "(Th) " ++ k
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckesetSelectedProver :: ListBox String
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> ProofState lid1 sentence1
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckesetSelectedProver lb st = do
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke let ind = case selectedProver st of
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke Just sp -> findIndex (==sp) $ Map.keys (proversMap st)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke Nothing -> Nothing
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke maybe (return ()) (\i -> selection i lb >> return ()) ind
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke-- *** Callbacks
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke Updates the display of the status of the selected goals.
548f3850942936a8c6021185c8391dfcd3b03018Dominik LueckeupdateDisplay :: ProofState lid sentence -- ^ current global state
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- ^ set to 'True' if you want the 'ListBox' to be updated
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -> ListBox String
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- ^ 'ListBox' displaying the status of all goals (see 'goalsView')
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -> ListBox String
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- ^ 'ListBox' displaying possible morphism paths to prover logics
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- ^ 'Label' displaying the status of the currently selected goal(s)
548f3850942936a8c6021185c8391dfcd3b03018Dominik LueckeupdateDisplay st updateLb goalsLb pathsLb statusLabel = do
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke -- update goals listbox
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke when updateLb
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke (offScreen,_) <- view Vertical goalsLb
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke populateGoalsListBox goalsLb (goalsView st)
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke moveto Vertical goalsLb offScreen)
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke setSelectedProver pathsLb st
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke -- update status label
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke let (color, label) = toGuiStatus st
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke statusLabel # text label
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke statusLabel # foreground (show color)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckeupdateStateGetSelectedGoals ::
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke (Logic lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke sign1 morphism1 symbol1 raw_symbol1 proof_tree1) =>
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke ProofState lid1 sentence1
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> ListBox String
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke -> IO (ProofState lid1 sentence1)
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik LueckeupdateStateGetSelectedGoals s lb =
648e803bb79a00b1c246d093fe2a2707c6b2cf7bDominik Luecke do sel <- getSelection lb :: IO (Maybe [Int])
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke return s {selectedGoals =
548f3850942936a8c6021185c8391dfcd3b03018Dominik Luecke maybe [] (map (OMap.keys (goalMap s) !!)) sel}
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeupdateStateGetSelectedSens ::
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke (Logic lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke sign1 morphism1 symbol1 raw_symbol1 proof_tree1) =>
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke ProofState lid1 sentence1
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke -> ListBox String -- ^ axioms listbox
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke -> ListBox String -- ^ theorems listbox
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke -> IO (ProofState lid1 sentence1)
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik LueckeupdateStateGetSelectedSens s lbAxs lbThs =
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke do aM <- axiomMap s
4df63f7187b1ba16cbe5c781db187a42f2f49579Dominik Luecke selA <- getSelection lbAxs :: IO (Maybe [Int])
where fil = map . (!!) . OMap.keys
goalsText = show . Pretty.vsep .
AS_Anno.mapNamed (simplify_sen lid1 sig1))
(thName ++ "-goals.txt") (goalsText sens')
Just (Map.keys (proversMap s) !! index))
-> KnownProvers.KnownProversMap -- ^ map of known provers
-> IO (Result.Result G_theory)
-- KnownProvers.showKnownProvers knownProvers
stateMVar <- Conc.newMVar initState
lockMVar <- Conc.newMVar ()
Conc.tryTakeMVar guiMVar >>=
(maybe (Conc.putMVar guiMVar $ Just main)
-- HBox for the upper part (goals on the left, options/results on the right)
-- right frame (options/results)
lbThs # value (OMap.keys (goalMap initState))
(\ sp -> find (==sp) $ Map.keys (proversMap s'))
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
s <- Conc.takeMVar stateMVar
(findIndices isOpen $ OMap.toList $ goalMap s)
Conc.putMVar stateMVar s'
s <- Conc.takeMVar stateMVar
let axiomList = OMap.toList aM
Conc.putMVar stateMVar s'
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
Conc.modifyMVar_ stateMVar updateStatusSublogic
s <- Conc.readMVar stateMVar
Conc.modifyMVar_ stateMVar (flip doSelectProverPath pathsLb)
s <- Conc.readMVar stateMVar
Result.Result ds ms'' <- fineGrainedSelectionF prGuiAcs prState
|| diagString (head ds) /= "Proofs.Proofs: selection")
Conc.tryTakeMVar stateMVar -- ensure that MVar is empty
Conc.putMVar stateMVar s'''
s <- Conc.takeMVar stateMVar
Result.Result ds ms'' <- proveF prGuiAcs prState
Conc.putMVar stateMVar s'''
mv <- Conc.tryTakeMVar lockMVar
Conc.tryPutMVar lockMVar ()
s <- Conc.readMVar stateMVar
s <- Conc.readMVar stateMVar
+> closeWindow >>> Conc.takeMVar lockMVar
Conc.tryTakeMVar guiMVar >>=
(const $ Conc.putMVar guiMVar Nothing))
s <- Conc.takeMVar stateMVar
return $ Result.Result (accDiags s)
$ Just $ G_theory lidT sigT indT (Map.union sensT gMap) startThId