-- | General function for implementing dg all style commands
commandDgAll :: String->( LIB_NAME->LibEnv->LibEnv) -> CMDLState
commandDgAll name fn state
= case devGraphState state of
Nothing -> return state {
-- just an error message and leave
-- the internal state intact so that
-- the interface can recover
errorMsg = "No library loaded"
let nwLibEnv = fn (ln dgState) (libEnv dgState)
return $ register2history name state {
devGraphState = Just dgState {
-- are nodes left alone!?
allEdgesUpToDate = False},
-- delete any selection if a dg command is used
-- | Generic function for a dg command, all other dg
-- commands are derived from this command by simply
-- specifing the function
commandDg :: String->(LIB_NAME -> [LEdge DGLinkLab]->LibEnv->
LibEnv) -> String -> CMDLState
commandDg name fn input state
= case devGraphState state of
Nothing -> return state {
-- leave the internal state intact so
-- that the interface can recover
errorMsg = "No library loaded"
let (_,edg,nbEdg,errs) = decomposeIntoGoals input
tmpErrs = prettyPrintErrList errs
-- leave the internal state intact so
-- that the interface can recover
errorMsg = tmpErrs++"No edges in input string\n"
let lsNodes = getAllNodes dgState
lsEdges = getAllEdges dgState
-- compute the list of edges from the input
(errs',listEdges) = obtainEdgeList edg nbEdg lsNodes
tmpErrs' = tmpErrs ++ (prettyPrintErrList errs')
errorMsg = tmpErrs' ++ "No edge in input string\n"
nwLibEnv = fn (ln dgState) listEdges
return $register2history(name++" "++input)
-- are nodes left alone!?
-- delete any selection if a dg command is
-- | The function 'cUse' implements the Use commands,
i.e. -- given a path it tries to load the library at that path
cUse::String ->CMDLState -> IO CMDLState
let opts = defaultHetcatsOpts
tmp <- case devGraphState state of
Nothing -> anaLib opts file
anaLibExt opts file $ libEnv dgState
Nothing -> return state {
-- leave internal state intact so that
-- the interface can recover
errorMsg = ("Unable to load library "++input)
return$register2history ("use "++input)
allNodesUpToDate = False,
prompter = (file ++ "> "),
-- delete any selection if a dg command is
-- The only command that requires a list of nodes instead
cDgThmHideShift :: String -> CMDLState -> IO CMDLState
cDgThmHideShift input state
= case devGraphState state of
Nothing -> return state {
-- leave internal state intact so
-- that the interface can recover
errorMsg = "No library loaded"
let (nds,_,_,errs) = decomposeIntoGoals input
tmpErrs = prettyPrintErrList errs
-- leave internal state intact so
-- that the interface can recover
errorMsg = tmpErrs++"No nodes in input string\n"
let lsNodes = getAllNodes dgState
(errs',listNodes) = obtainNodeList nds lsNodes
tmpErrs' = tmpErrs ++ (prettyPrintErrList errs')
errorMsg = tmpErrs' ++ "No nodes in input string\n"
nwLibEnv = theoremHideShiftFromList (ln dgState)
listNodes (libEnv dgState)
return $register2history ("do thm-hide "++input) state {
-- are nodes left alone!?
-- are edges left alone!?
shellDgThmHideShift :: String -> Sh CMDLState ()
= shellComWith cDgThmHideShift False False "dg thm-hide"
shellDgUse :: String -> Sh CMDLState ()
= shellComWith cUse False False "use"
shellDgAuto :: String -> Sh CMDLState ()
= shellComWith (commandDg "dg auto" automaticFromList)
shellDgGlobSubsume:: String -> Sh CMDLState ()
= shellComWith (commandDg "dg glob-subsume" globSubsumeFromList)
False False "dg glob-subsume"
shellDgGlobDecomp:: String -> Sh CMDLState ()
= shellComWith (commandDg "dg glob-decomp" globDecompFromList)
False False "dg glob-decomp"
shellDgLocInfer :: String -> Sh CMDLState ()
= shellComWith (commandDg "dg loc-infer" localInferenceFromList)
False False "dg loc-infer"
shellDgLocDecomp :: String -> Sh CMDLState ()
= shellComWith (commandDg "dg loc-decomp" locDecompFromList)
False False "dg loc-decomp"
shellDgComp :: String -> Sh CMDLState ()
= shellComWith (commandDg "dg comp" compositionFromList)
shellDgCompNew :: String-> Sh CMDLState ()
= shellComWith (commandDg "dg comp-new"
compositionCreatingEdgesFromList) False False "dg comp-new"
shellDgHideThm :: String-> Sh CMDLState ()
= shellComWith (commandDg "dg hide-thm"
automaticHideTheoremShiftFromList) False False "dg hide-thm"
shellDgAllAuto:: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all auto" automatic)
False False "dg-all auto"
shellDgAllGlobSubsume :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all glob-subsume" globSubsume)
False False "dg-all glob-subsume"
shellDgAllGlobDecomp :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all glob-decomp" globDecomp)
False False "dg-all glob-decomp"
shellDgAllLocInfer :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all loc-infer" localInference)
False False "dg-all loc-infer"
shellDgAllLocDecomp :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all loc-decomp" locDecomp)
False False "dg-all loc-decomp"
shellDgAllComp :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all comp" composition)
False False "dg-all comp"
shellDgAllCompNew :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all comp-new"
compositionCreatingEdges) False False "dg-all comp-new"
shellDgAllHideThm :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all hide-thm"
automaticHideTheoremShift) False False "dg-all hide-thm"
shellDgAllThmHide :: Sh CMDLState ()
= shellComWithout (commandDgAll "dg-all thm-hide"
theoremHideShift) False False "dg-all thm-hide"
selectANode :: Int -> CMDLDevGraphState
-> [CMDLProofAbstractState]
-- computes the theory of a given node
-- (
i.e. solves DGRef cases and so on,
-- see CASL Reference Manual, p.294, Def 4.9)
gth n = computeTheory (libEnv dgState)
nodeName t=case find(\(n,_)-> n==t)$getAllNodes dgState of
Nothing -> "Unknown node"
Just (_,ll)-> getDGNodeName ll
case knownProversWithKind ProveCMDLautomatic of
-- if compute theory was successful give the
-- result as one element list, otherwise an
Result _ (Just th@(G_theory lid _ _ _ _)) ->
(getLIB_ID$ ln dgState) "_" ++(nodeName x)
(shrinkKnownProvers (sublogicOfTh th) kpMap)
(getProvers ProveCMDLautomatic $
filter hasModelExpansion $
findComorphismPaths logicGraph $
-- make so that nothing (no goals, no axioms) are
-- selected initialy in the goal proof status
return (initCMDLProofAbstractState tmp{
selectedGoals =case selectedGoals tmp of
-- | function swithces interface in proving mode and also
-- selects a list of nodes to be used inside this mode
cDgSelect :: String -> CMDLState -> IO CMDLState
=case devGraphState state of
Nothing -> return state {
-- leave internal state intact so
-- that the interface can recover
errorMsg = "No library loaded"
let (nds,_,_,errs) = decomposeIntoGoals input
tmpErrs = prettyPrintErrList errs
-- leave internal state intact so
-- that the interface can recover
errorMsg = tmpErrs++"No nodes in input string\n"
case knownProversWithKind ProveCMDLautomatic of
Result _ Nothing -> return
-- leave internal state intact
-- so that the interface can
errorMsg=tmpErrs++"No prover found\n"
let lsNodes = getAllNodes dgState
(errs',listNodes) = obtainNodeList nds lsNodes
tmpErrs' = tmpErrs ++ (prettyPrintErrList errs')
errorMsg = tmpErrs'++ "No nodes in input string\n"
-- elems is the list of all results (
i.e. -- concat of all one element lists)
(n,_) -> selectANode n dgState
return $register2history ("select "++input) state {
-- keep the list of nodes as up to date
-- add the prove state to the status
-- containing all information selected
shellDgSelect :: String -> Sh CMDLState ()
= shellComWith cDgSelect False False "select"
-- | Function switches the interface in proving mode by
cDgSelectAll :: CMDLState -> IO CMDLState
=case devGraphState state of
Nothing -> return state {
-- leave internal state intact so
-- that the interface can recover
errorMsg = "No library loaded"
case knownProversWithKind ProveCMDLautomatic of
Result _ Nothing -> return
-- leave internal state intact so
-- that the interface can recover
errorMsg="No prover found"
let lsNodes = getAllNodes dgState
-- elems is the list of all results (
i.e. concat
-- of all one element lists)
(n,_) -> selectANode n dgState
return $register2history "select-all" state {
-- keep the list of nodes as up to date
-- add the prove state to the status containing
-- all information selected in the input
shellDgSelectAll :: Sh CMDLState ()
= shellComWithout cDgSelectAll False False "select-all"