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/
28 let init_metadata _ = ()
29 let compute_metadata _ _ = ()
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 (cicCurrentProof 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, goal_opt) = new_status in
47 let proof_object_metadata = (* compute proof annotations *)
50 | Some _ -> cicCurrentProof new_proof
51 | None -> cicConstant new_proof
53 Cic2acic.acic_object_of_cic_object obj
55 let sequents_metadata = (* compute all sequent annotations from scratch *)
56 (** TODO Zack could we reuse some of the annotations from the previous
57 * status to avoid recomputing all of them? uhm ... we have to which
58 * sequents haven't been changed by last tactic applications ... doh! *)
60 (fun ((metano, context, term) as sequent) ->
61 (metano, Cic2acic.asequent_of_sequent new_metasenv sequent))
64 (proof_object_metadata, sequents_metadata)
67 class proof ?uri ~typ ~metasenv ~body () =
71 StatefulProofEngine.status
72 ~history_size:BuildTimeConf.undo_history_size ?uri ~typ ~body ~metasenv
73 init_metadata compute_metadata ()
76 let currentproof = cicCurrentProof self#proof in
77 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
78 Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
80 let uri = MatitaTypes.unopt_uri self#uri in
82 match Cic2Xml.print_object uri ~ids_to_inner_sorts
83 ~ask_dtd_to_the_getter:true acurrentproof
85 | xml, Some bodyxml -> xml, bodyxml
86 | _, None -> assert false
91 let (xml, bodyxml) = self#toXml in
92 let buf = Buffer.create 10240 in
93 List.iter (Buffer.add_string buf)
94 [ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
95 "<!DOCTYPE ConstantType SYSTEM \"http://mowgli.cs.unibo.it:58081/getdtd?uri=cic.dtd\">\n";
97 (Misc.strip_xml_headings (Xml.pp_to_string xml));
98 (Misc.strip_xml_headings(Xml.pp_to_string bodyxml));
99 (if not (self#proof_completed) then
100 Printf.sprintf "<CurrentGoal>%d</CurrentGoal>" self#goal
109 let proof ?uri ~metasenv ~typ () =
110 let metasenv = (1, [], typ) :: metasenv in
111 let body = Cic.Meta (1,[]) in
112 let _ = CicTypeChecker.type_of_aux' metasenv [] typ in
113 new proof ~typ ~metasenv ~body ?uri ()