1 (* Copyright (C) 2004, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 (** create a Cic.CurrentProof from a given proof *)
27 let currentProof (uri, metasenv, bo, ty) =
28 let uri = MatitaTypes.unopt_uri uri in
29 (* TODO CSC: Wrong: [] is just plainly wrong *)
30 Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [])
32 let init_metadata status =
33 let ((_, metasenv, _, _) as proof, _) = status in
34 let proof_object_metadata = (* compute proof annotations *)
35 Cic2acic.acic_object_of_cic_object (currentProof proof)
37 let sequents_metadata = (* compute all sequent annotations from scratch *)
39 (fun ((metano, context, term) as sequent) ->
40 (metano, Cic2acic.asequent_of_sequent metasenv sequent))
43 (proof_object_metadata, sequents_metadata)
45 let compute_metadata (old_status, old_metadata) new_status =
46 let ((_, new_metasenv, _, _) as new_proof, _) = new_status in
47 let proof_object_metadata = (* compute proof annotations *)
48 Cic2acic.acic_object_of_cic_object (currentProof new_proof)
50 let sequents_metadata = (* compute all sequent annotations from scratch *)
51 (** TODO Zack could we reuse some of the annotations from the previous
52 * status to avoid recomputing all of them? uhm ... we have to which
53 * sequents haven't been changed by last tactic applications ... doh! *)
55 (fun ((metano, context, term) as sequent) ->
56 (metano, Cic2acic.asequent_of_sequent new_metasenv sequent))
59 (proof_object_metadata, sequents_metadata)
61 class proof ?uri ~typ ~metasenv ~body () =
64 inherit [MatitaTypes.hist_metadata]
65 StatefulProofEngine.status
66 ~history_size:BuildTimeConf.undo_history_size ?uri ~typ ~body ~metasenv
67 init_metadata compute_metadata ()
70 let currentproof = currentProof self#proof in
71 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
72 Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
74 let uri = MatitaTypes.unopt_uri self#uri in
76 match Cic2Xml.print_object uri ~ids_to_inner_sorts
77 ~ask_dtd_to_the_getter:true acurrentproof
79 | xml, Some bodyxml -> xml, bodyxml
80 | _, None -> assert false
85 let (xml, bodyxml) = self#toXml in
86 let buf = Buffer.create 10240 in
87 List.iter (Buffer.add_string buf)
88 [ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
89 "<!DOCTYPE ConstantType SYSTEM \"http://mowgli.cs.unibo.it:58081/getdtd?uri=cic.dtd\">\n";
91 (Misc.strip_xml_headings (Xml.pp_to_string xml));
92 (Misc.strip_xml_headings(Xml.pp_to_string bodyxml));
93 (if not (self#proof_completed) then
94 Printf.sprintf "<CurrentGoal>%d</CurrentGoal>" self#goal
103 let proof ?uri ~metasenv ~typ () =
104 let metasenv = (1, [], typ) :: metasenv in
105 let body = Cic.Meta (1,[]) in
106 let _ = CicTypeChecker.type_of_aux' metasenv [] typ in
107 new proof ~typ ~metasenv ~body ?uri ()