Global.hs revision 767e78dd0b080bc40892d0fbaff1b1528adfe36b
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherModule : $Header$
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherDescription : global proof rules for development graphs
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherCopyright : (c) Jorina F. Gerken, Till Mossakowski, Uni Bremen 2002-2006
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherMaintainer : ken@informatik.uni-bremen.de
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherStability : provisional
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherPortability : non-portable(DevGraph)
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagherglobal proof rules for development graphs.
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher Follows Sect. IV:4.4 of the CASL Reference Manual.
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher , globDecompAux -- for Test.hs
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher , globDecompFromList
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher , globSubsumeFromList
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagherimport qualified Data.Map as Map
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherglobDecompRule :: LEdge DGLinkLab -> DGRule
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherglobDecompRule = DGRuleWithEdge "Global-Decomposition"
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher{- apply rule GlobDecomp to all global theorem links in the current DG
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher current DG = DGm
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher add to proof status the pair ([GlobDecomp e1,...,GlobDecomp en],DGm+1)
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher where e1...en are the global theorem links in DGm
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher DGm+1 results from DGm by application of GlobDecomp e1,...,GlobDecomp en -}
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria{- | applies global decomposition to the list of edges given (global
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria theorem edges) if possible, if empty list is given then to all
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria unproven global theorems.
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria Notice: (for ticket 5, which solves the problem across library border)
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria 1. before the actual global decomposition is applied, the whole DGraph is
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria updated firstly by calling the function updateDGraph.
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel Barria 2. The changes of the update action should be added as the head of the
1b171c456ff901ab622e44bcfd213f7de86fd787Ariel BarriaglobDecompFromList :: LibName -> [LEdge DGLinkLab] -> LibEnv -> LibEnv
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherglobDecompFromList ln globalThmEdges proofStatus =
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher let dgraph = lookupDGraph ln proofStatus
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher finalGlobalThmEdges = filter (liftE isUnprovenGlobalThm) globalThmEdges
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher auxGraph = foldl (updateDGraph proofStatus) dgraph
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher $ nubOrd $ map (\ (src, _, _) -> src) finalGlobalThmEdges
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher newDGraph = foldl globDecompAux auxGraph finalGlobalThmEdges
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher in Map.insert ln newDGraph proofStatus
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher{- | update the given DGraph with source nodes of all global unproven
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher The idea is, to expand the given DGraph by adding all the referenced
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher nodes related to the given source nodes in other libraries and the
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher corresponding links as well.
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher If a certain node is a referenced node and not expanded yet, then its
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher parents will be found by calling getRefParents.
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher These parents will be added into current DGraph using updateDGraphAux
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherupdateDGraph :: LibEnv -> DGraph
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher -> Node -- source nodes of all global unproven links
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallagherupdateDGraph le dg x =
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher {- checks if it is an unexpanded referenced node
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher the function lookupInRefNodesDG only checks the
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher nodes which are not expanded. -}
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher case lookupInRefNodesDG x dg of
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher Just (refl, refn) ->
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher parents = getRefParents le refl refn
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher {- important for those, who's doing redo/undo function:
7800c9da75ad0dc3b4a530b15adce86d6c4f26e5Lukas Slebodnik notice that if the node is expanded, then it should be
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher deleted out of the unexpanded map using
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher deleteFromRefNodesDG -}
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher auxDG = foldl (updateDGraphAux le x refl)
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher{- | get all the parents, namely the related referenced nodes and the links
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher between them and the present to be expanded node.
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallaghergetRefParents :: LibEnv -> LibName
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher -> Node -- the present to be expanded node
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher -> [(LNode DGNodeLab, [DGLinkLab])]
3441d0c2d11aea0c39b009751a1898333c009674Stephen GallaghergetRefParents le refl refn =
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher {- get the previous objects to the current one -}
3441d0c2d11aea0c39b009751a1898333c009674Stephen Gallagher dg = lookupDGraph refl le
e.g. if the list is like:
Notice for those who are doing undo/redo, because the DGraph is actually
_ -> error "Proofs.Global.globDecompForOneEdgeAux"
in Map.insert ln nextDGraph libEnv