Proofs.hs revision 38f350357e92da312d2c344352180b3dc5c1fc8a
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuModule : $Header$
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuCopyright : (c) Jorina F. Gerken, Till Mossakowski, Uni Bremen 2002-2004
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
2eeec5240b424984e3ee26296da1eeab6c6d739eChristian MaederMaintainer : hets@tzi.de
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuStability : provisional
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuPortability : non-portable(Logic)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Proofs in development graphs.
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Follows Sect. IV:4.4 of the CASL Reference Manual.
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu T. Mossakowski, S. Autexier and D. Hutter:
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Extending Development Graphs With Hiding.
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu H. Hussmann (ed.): Fundamental Approaches to Software Engineering 2001,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Lecture Notes in Computer Science 2029, p. 269-283,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Springer-Verlag 2001.
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuIntegrate stuff from Saarbr�cken
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuAdd proof status information
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu what should be in proof status:
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu- proofs of thm links according to rules
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu- cons, def and mono annos, and their proofs
da955132262baab309a50fdffe228c9efe68251dCui Jianimport List(nub)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- proof status = (DG0,[(R1,DG1),...,(Rn,DGn)])
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu DG0 is the development graph resulting from the static analysis
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Ri is a list of rules that transforms DGi-1 to DGi
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu With the list of intermediate proof states, one can easily implement
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu an undo operation
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescutype ProofStatus = (GlobalContext,[([DGRule],[DGChange])],DGraph)
da955132262baab309a50fdffe228c9efe68251dCui Jiandata DGRule =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu TheoremHideShift
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | HideTheoremShift
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | Composition
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | GlobDecomp (LEdge DGLinkLab) -- edge in the conclusion
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | LocDecomp (LEdge DGLinkLab)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | GlobSubsumption (LEdge DGLinkLab)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | LocalInference
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | BasicInference Edge BasicProof
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | BasicConsInference Edge BasicConsProof
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescudata DGChange = InsertNode (LNode DGNodeLab)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | DeleteNode Node
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | InsertEdge (LEdge DGLinkLab)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | DeleteEdge (LEdge DGLinkLab)
2df3a08c43f067ba532151ade20b1e4e2d2efd90Mihai Codescudata BasicProof =
4c7f058cdd19ce67b2b5d4b7f69703d0f8a21e38Christian Maeder forall lid sublogics
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu basic_spec sentence symb_items symb_map_items
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu sign morphism symbol raw_symbol proof_tree .
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Logic lid sublogics
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu basic_spec sentence symb_items symb_map_items
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu sign morphism symbol raw_symbol proof_tree =>
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu BasicProof lid (Proof_status sentence proof_tree)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | Conjectured
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu | Handwritten
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescudata BasicConsProof = BasicConsProof -- more detail to be added ...
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- todo: implement apply for GlobDecomp and Subsumption
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu the list of DGChage must be constructed in parallel to the
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu new DGraph -}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuapplyRule :: DGRule -> DGraph -> Maybe ([DGChange],DGraph)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuapplyRule = error "Proofs.hs:applyRule"
da955132262baab309a50fdffe228c9efe68251dCui Jian-- ---------------------
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu-- global decomposition
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu-- ---------------------
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- apply rule GlobDecomp to all global theorem links in the current DG
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu current DG = DGm
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu add to proof status the pair ([GlobDecomp e1,...,GlobDecomp en],DGm+1)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu where e1...en are the global theorem links in DGm
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu DGm+1 results from DGm by application of GlobDecomp e1,...,GlobDecomp en -}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- applies global decomposition to all unproven global theorem edges
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu if possible -}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecomp :: ProofStatus -> ProofStatus
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecomp proofStatus@(globalContext,history,dgraph) =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (globalContext, ((newHistoryElem):history), newDgraph)
da955132262baab309a50fdffe228c9efe68251dCui Jian globalThmEdges = filter isUnprovenGlobalThm (labEdges dgraph)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (newDgraph, newHistoryElem) = globDecompAux dgraph globalThmEdges ([],[])
2df3a08c43f067ba532151ade20b1e4e2d2efd90Mihai Codescu{- auxiliary function for globDecomp (above)
2df3a08c43f067ba532151ade20b1e4e2d2efd90Mihai Codescu actual implementation -}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompAux :: DGraph -> [LEdge DGLinkLab] -> ([DGRule],[DGChange])
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu -> (DGraph,([DGRule],[DGChange]))
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompAux dgraph [] historyElem = (dgraph, historyElem)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompAux dgraph (edge:edges) historyElem =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu globDecompAux newDGraph edges newHistoryElem
4c7f058cdd19ce67b2b5d4b7f69703d0f8a21e38Christian Maeder (newDGraph, newChanges) = globDecompForOneEdge dgraph edge
4c7f058cdd19ce67b2b5d4b7f69703d0f8a21e38Christian Maeder newHistoryElem =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu if null newChanges then historyElem
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu else (((GlobDecomp edge):(fst historyElem)),
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (newChanges++(snd historyElem)))
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu-- applies global decomposition to a single edge
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompForOneEdge :: DGraph -> LEdge DGLinkLab -> (DGraph,[DGChange])
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompForOneEdge dgraph edge =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu globDecompForOneEdgeAux dgraph edge [] paths
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu pathsToSource = getAllLocGlobDefPathsTo dgraph (getSourceNode edge) []
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu paths = [(node, path++(edge:[]))| (node,path) <- pathsToSource]
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- auxiliary funktion for globDecompForOneEdge (above)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu actual implementation -}
da955132262baab309a50fdffe228c9efe68251dCui JianglobDecompForOneEdgeAux :: DGraph -> LEdge DGLinkLab -> [DGChange] ->
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu [(Node, [LEdge DGLinkLab])] -> (DGraph,[DGChange])
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu{- if the list of paths is empty from the beginning, nothing is done
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu otherwise the unprovenThm edge is replaced by a proven one -}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompForOneEdgeAux dgraph edge@(source,target,edgeLab) changes [] =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu if null changes then (dgraph, [])
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu else ((insEdge provenEdge (delLEdge edge dgraph)),
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu ((DeleteEdge edge):((InsertEdge provenEdge):changes)))
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (GlobalThm _ conservativity conservStatus) = (dgl_type edgeLab)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu proofBasis = getLabelsOfInsertedEdges changes
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu provenEdge = (source,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu DGLink {dgl_morphism = dgl_morphism edgeLab,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (GlobalThm (Proven proofBasis)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu conservativity conservStatus),
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu dgl_origin = DGProof}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu-- for each path an unproven localThm edge is inserted
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobDecompForOneEdgeAux dgraph edge@(source,target,edgeLab) changes
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu ((node,path):list) =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu globDecompForOneEdgeAux newGraph edge newChanges list
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu morphism = case calculateMorphismOfPath path of
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu Just morph -> morph
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu error "globDecomp: could not determine morphism of new edge"
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu newEdge = (node,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu DGLink {dgl_morphism = morphism,
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu dgl_type = (LocalThm (Static.DevGraph.Open)
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu dgl_origin = DGProof}
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu newGraph = insEdge newEdge dgraph
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu newChanges = ((InsertEdge newEdge):changes)
da955132262baab309a50fdffe228c9efe68251dCui Jian-- -------------------
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu-- global subsumption
4c7f058cdd19ce67b2b5d4b7f69703d0f8a21e38Christian Maeder-- -------------------
da955132262baab309a50fdffe228c9efe68251dCui Jian-- applies global subsumption to all unproven global theorem edges if possible
da955132262baab309a50fdffe228c9efe68251dCui JianglobSubsume :: ProofStatus -> ProofStatus
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai CodescuglobSubsume proofStatus@(globalContext,history,dGraph) =
fe649b05d4faaf8ba7b408384843d33e5937ef31Mihai Codescu (globalContext, nextHistoryElem:history, nextDGraph)
{- getAllLocGlobPathsOfTypesBetween :: DGraph -> Node -> Node -> [LEdge DGLinkLab -> Bool] -> [LEdge DGLinkLab -> Bool] -> [[LEdge DGLinkLab]]
(GlobalThm Static.DevGraph.Open _ _) -> True
(LocalThm (Static.DevGraph.Open) _ _) -> True
if this fails the same is done for the rest of the given paths, i.e.
i.e. the list of all DGLinkLabs the proofs of the edges contained in the path