Changeset 12787

Show
Ignore:
Timestamp:
05.11.2009 17:56:58 (2 weeks ago)
Author:
mgross
Message:

Replaced Node- and Edge-Info in CMDL to display the same output as in the GUI.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/CMDL/InfoCommands.hs

    r12730 r12787  
    4848                   obtainNodeList, prettyPrintErrList) 
    4949 
    50 import Static.GTheory (G_theory(G_theory), BasicProof, sublogicOfTh) 
     50import Static.GTheory (G_theory(G_theory), BasicProof) 
    5151import Static.DevGraph 
    52 import Static.PrintDevGraph (dgLinkOriginHeader, dgOriginHeader) 
     52import Static.PrintDevGraph (showLEdge) 
    5353 
    5454import Common.AS_Annotation (SenAttr(isAxiom)) 
    5555import Common.DocUtils (showDoc) 
    56 import Common.ExtSign (ExtSign(ExtSign)) 
    5756import Common.Taxonomy (TaxoGraphKind(..)) 
    5857import Common.Utils (trim) 
     
    6160import Data.Graph.Inductive.Graph (LNode, LEdge, Node) 
    6261import Data.List 
    63 import qualified Data.Set as Set 
    64  
    65 import Logic.Logic (Sentences(sym_of)) 
     62 
    6663import Logic.Prover (SenStatus) 
    6764import Logic.Comorphism (AnyComorphism) 
     
    160157  getInfoFromNodes input (concatMap (\ n -> getGoalThS Do_translate n st)) st 
    161158 
    162 -- | Given a node it returns the information that needs to 
    163 -- be printed as a string 
    164 showNodeInfo::CmdlState -> LNode DGNodeLab -> String 
    165 showNodeInfo state (nb,nd) = 
    166   let 
    167     -- node name 
    168       name'= "dgn_name : " ++ showName (dgn_name nd) ++ "\n" 
    169       -- origin of the node 
    170       orig'= if isDGRef nd then "dgn_orig : no origin (ref node)" 
    171              else "dgn_orig : " ++ dgOriginHeader (dgn_origin nd) ++ "\n" 
    172       -- conservativity annotations 
    173       th = getTh Do_translate nb state 
    174   in 
    175    case th of 
    176     Nothing ->name' ++ orig'++"Theory could not be evaluated\n" 
    177     Just t@(G_theory x (ExtSign y _) _ thSens _) -> 
    178      let 
    179       -- find out the sublogic of the theory if we found 
    180       -- a theory 
    181       sublog = "   sublogic: "++ show 
    182                               (sublogicOfTh t) ++ "\n" 
    183       -- compute the number of axioms by counting the 
    184       -- number of symbols of the signature !? 
    185       nbAxm = "   number of axioms: "++ show (OMap.size $ 
    186                                    OMap.filter isAxiom thSens) ++"\n" 
    187       -- compute the number of symbols as the number of 
    188       -- sentences that are axioms in the senstatus of the 
    189       -- theory 
    190       nbSym = "   number of symbols: "++ show (Set.size $ sym_of x y) ++ "\n" 
    191       -- compute the number of proven theorems as the 
    192       -- number of sentences that have no theorem status 
    193       -- left 
    194       nbThm = let n'=OMap.size $ OMap.filter (\s -> not (isAxiom s) 
    195                       && isProvenSenStatus s) thSens 
    196               in "   number of proven theorems: " ++ show n' ++ "\n" 
    197       -- compute the number of unproven theorems as the 
    198       -- sentences that have something in their theorem 
    199       -- status 
    200       nbUThm = let n'= OMap.size $ OMap.filter(\s -> not (isAxiom s) 
    201                        && not (isProvenSenStatus s)) thSens 
    202                in "   number of unproven theorems: " ++ show n' ++ "\n" 
    203       -- compute the final theory (i.e.just add partial 
    204       -- results obtained before (sublogic, nbAxm..) 
    205       th' = "dgl_theory:\n"++ sublog ++ nbAxm ++ nbSym ++ nbThm ++ nbUThm 
    206      in name' ++ orig' ++ th' 
    207  
    208  
    209 -- | Given an edge it returns the information that needs to 
    210 --   be printed as a string 
    211 showEdgeInfo::CmdlState -> LEdge DGLinkLab -> String 
    212 showEdgeInfo state (x, y, dglab) 
    213  = case i_state $ intState state of 
    214    Nothing -> "" 
    215    Just dgS -> 
    216     let 
    217      ls = getAllNodes dgS 
    218      nameOf x' l = case find ((== x') . fst) l of 
    219                    Nothing -> "Unknown node" 
    220                    Just (_, n) -> showName $ dgn_name n 
    221      nm = "dgl_name: "++ nameOf x ls ++ " -> " ++ 
    222                nameOf y ls 
    223      orig = "dgl_origin: " ++ dgLinkOriginHeader (dgl_origin dglab) 
    224      defS = "definition" 
    225      mkDefS = (++ ' ':defS) 
    226      ltype= "dgl_type: " ++ 
    227        case edgeTypeModInc $  getRealDGLinkType dglab of 
    228          GlobalDef -> mkDefS "global" 
    229          HetDef -> mkDefS "het" 
    230          HidingDef -> mkDefS "hiding" 
    231          LocalDef -> mkDefS "local" 
    232          FreeOrCofreeDef -> defS 
    233          ThmType thm isPrvn _ _ -> 
    234            let prvn = (if isPrvn then "" else "un") ++ "proven" 
    235                thmS = "theorem" 
    236            in case thm of 
    237                 HidingThm -> unwords [prvn, "hiding", thmS] 
    238                 FreeOrCofreeThm -> unwords [prvn, thmS] 
    239                 GlobalOrLocalThm scope isHom -> 
    240                    let het = if isHom then [] else ["het"] 
    241                        sc = case scope of 
    242                               Local -> "local" 
    243                               Global -> "global" 
    244                    in unwords $ het ++ [sc, prvn, thmS] 
    245     in unlines [nm, orig, ltype] 
     159showNodeInfo :: LNode DGNodeLab -> String 
     160showNodeInfo (i, l) = 
     161  (if isDGRef l 
     162     then ("reference " ++) 
     163     else if isInternalNode l then ("internal " ++) else id) 
     164  "node " ++ getDGNodeName l ++ " " ++ show i ++ "\n" ++ showDoc l "" 
     165 
     166showEdgeInfo :: LEdge DGLinkLab -> String 
     167showEdgeInfo e@(_, _, l) = showLEdge e ++ "\n" ++ showDoc l "" 
    246168 
    247169-- show all information of selection 
     
    273195                (errs'',listEdges) = obtainEdgeList edg nbEdg lsNodes lsEdges 
    274196                (errs',listNodes) = obtainNodeList nds lsNodes 
    275                 strsNode = map (showNodeInfo state) listNodes 
    276                 strsEdge = map (showEdgeInfo state) listEdges 
     197                strsNode = map showNodeInfo listNodes 
     198                strsEdge = map showEdgeInfo listEdges 
    277199                tmpErrs' = tmpErrs ++ prettyPrintErrList errs' 
    278200                tmpErrs''= tmpErrs'++ prettyPrintErrList errs'' 
    279              in return $ genMessage tmpErrs'' (unlines (strsNode ++ strsEdge)) 
    280                            state 
     201             in return $ genMessage tmpErrs'' 
     202                         (intercalate "\n\n" (strsNode ++ strsEdge)) state 
    281203 
    282204taxoShowGeneric:: TaxoGraphKind -> CmdlState