HTkProofDetails.hs revision cf4e3ef8ae405824ae1bd39be9762e207836c0e0
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederModule : $Header$
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian MaederDescription : GUI for showing and saving proof details.
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) Rainer Grabbe 2006
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederMaintainer : rainer25@informatik.uni-bremen.de
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederStability : provisional
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederPortability : needs POSIX
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederAdditional window used by 'GUI.ProofManagement' for displaying proof details.
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maedermodule GUI.HTkProofDetails (doShowProofDetails) where
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederimport qualified Common.Doc as Pretty
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maederimport qualified Common.OrderedMap as OMap
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederimport qualified Data.Map as Map
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maederimport GUI.Utils (fileSaveDialog)
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski-- * record structures and basic functions for handling
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder Record structure containing proof details for a single proof.
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowskidata GoalDescription = GoalDescription {
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder proverInfo :: String, -- ^ standard proof details
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder tacticScriptText :: OpenText, -- ^ more details for tactic script
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder proofTreeText :: OpenText -- ^ more details for proof tree
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder Current state of a text tag providing additional information. The text can be
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder folded or unfolded.
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederdata OpenText = OpenText {
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder additionalText :: String, -- ^ additional information
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder textShown :: Bool, -- ^ if true, text is unfolded (default: false)
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder textStartPosition :: Position -- ^ start position in editor widget
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder Creates an initial 'GoalDescription' filled with just the standard prover
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian MaederemptyGoalDescription :: String -- ^ information about the used prover
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder -> GoalDescription -- ^ initiated GoalDescription
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian MaederemptyGoalDescription st =
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder GoalDescription {
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder proverInfo = st,
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder tacticScriptText = emptyOpenText,
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder proofTreeText = emptyOpenText }
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder Creates an empty 'OpenText' with start position (0,0).
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian MaederemptyOpenText :: OpenText
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaederemptyOpenText = OpenText {
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder additionalText = "",
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski textShown = False,
3c62e6ef442caf092adcbecf6fccd957dcd72689Christian Maeder textStartPosition = (Distance 0, Distance 0) }
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski-- | Determines the kind of content of a 'HTk.TextTag'.
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederdata Content = TacticScriptText | ProofTreeText deriving Eq
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- * GUI for show proof details
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder-- ** help functions
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder{- | Return number of new lines in a string.
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedernumberOfLines :: String
9cb4aa4ea6685489a38f9b609f5dbe5d37f25bc7Christian MaedernumberOfLines =
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder foldr (\ ch -> if ch == '\n' then (+ 1) else id) 0
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder Change the x-value of a 'Position' by a given arithmetical function and value.
836e72a3c413366ba9801726f3b249c7791cb9caChristian MaederchangePosition :: (Int -> Int -> Int) -- ^ mostly add or subtract values
836e72a3c413366ba9801726f3b249c7791cb9caChristian Maeder -> Int -- ^ (difference) value
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder -> Position -- ^ old position
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder -> Position -- ^ changed position with new x-value
149e43c4a2705a86a0e5fa301ba849fdf19db32eChristian MaederchangePosition f diff (Distance posX, Distance posY) =
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder (Distance $ f posX diff, Distance posY)
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Indentation of a 'String' (also multiple lines) by a number of spaces.
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederindent :: Int -- ^ number of spaces
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder -> String -- ^ input String
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder -> Pretty.Doc -- ^ output document
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederindent numSp st =
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Pretty.text (replicate numSp ' ') Pretty.<>
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski Standard indent width.
36c6cc568751e4235502cfee00ba7b597dae78dcChristian MaederstdIndent :: Int
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder An item of thmStatus will be put into 'GoalDescription' structure.
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Pretty printing of proof details, adding additional information
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder for text tags.
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederfillGoalDescription :: (AnyComorphism, BasicProof)
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder -> GoalDescription -- ^ contents in pretty format
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian MaederfillGoalDescription (cmo, basicProof) =
149e43c4a2705a86a0e5fa301ba849fdf19db32eChristian Maeder let gd = indent stdIndent $ show $ printCmWStat (cmo, basicProof)
149e43c4a2705a86a0e5fa301ba849fdf19db32eChristian Maeder stat str = Pretty.text "Status:" Pretty.<+> Pretty.text str
1738d16957389457347bee85075d3d33d002158fChristian Maeder printCmWStat (c, bp) =
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Pretty.text "Com:" Pretty.<+> Pretty.text (show c)
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder Pretty.$+$ indent stdIndent (show $ printBP bp)
33a5d53a412ba0a4e5847f7538d6da2e22bd116cChristian Maeder printBP bp = case bp of
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder BasicProof _ ps ->
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder stat (show $ goalStatus ps) Pretty.$+$
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder (case goalStatus ps of
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Proved _ -> Pretty.text "Used axioms:" Pretty.<+>
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski $ map (Pretty.text . show) $ usedAxioms ps)
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder Pretty.$+$ Pretty.text "Used time:" Pretty.<+>
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder Pretty.text (show $ usedTime ps)
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder Pretty.$+$ Pretty.text "Prover:" Pretty.<+>
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder Pretty.text (usedProver ps)
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder otherProof -> stat (show otherProof)
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder printTS bp = case bp of
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder BasicProof _ ps ->
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder indent (2 * stdIndent) $ (\(TacticScript xs) -> xs) $
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder tacticScript ps
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder printPT bp = case bp of
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder BasicProof _ ps ->
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder indent (2 * stdIndent) $ show $ proofTree ps
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder in (emptyGoalDescription $ show gd) {
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder tacticScriptText = emptyOpenText {
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder additionalText = show $ printTS basicProof },
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder proofTreeText = emptyOpenText {
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder additionalText = show $ printPT basicProof } }
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder Gets real 'EndOfText' index at the char position after (in x-direction)
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder the last written text. This is because 'EndOfText' only gives a value where a
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder text would be after an imaginary newline.
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedergetRealEndOfTextIndex :: Editor -- ^ the editor whose end index is determined
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder -> IO Position -- ^ position behind last char in widget
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedergetRealEndOfTextIndex ed = do
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder (Distance eotX, _) <- getIndexPosition ed EndOfText
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder lineBefore <- getTextLine ed $ IndexPos (Distance (eotX - 1), 0)
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder return (Distance eotX - 1, Distance $ length lineBefore)
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder For a given Ordered Map containing all proof values, this function adapts the
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder text positions lying behind after a given reference position. This is called
-> OMap.OMap (String, Int) GoalDescription
-> OMap.OMap (String, Int) GoalDescription -- ^ adapted Map
OMap.map $ \ gDesc ->
foldl (flip $ \ (s2, ind) -> OMap.insert (gN, ind) $
modifyIORef stateRef (OMap.update (\ _ -> Just goalDesc') (gName, ind))
) $ OMap.toList elementMap
let f = curDir ++ '/' : thName ++ "-proof-details.txt"
-> IORef (OMap.OMap (String, Int) GoalDescription)
) $ OMap.toList s
-> IORef (OMap.OMap (String, Int) GoalDescription)
$ OMap.lookup (gName, ind) s
s' = OMap.update
-> IORef (OMap.OMap (String, Int) GoalDescription)