]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaProof.ml
17b44ffd3ee600ca79af6e2d7d123c2fd01ef7b6
[helm.git] / helm / matita / matitaProof.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
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, [])
31
32 class proof ?uri ~typ ~metasenv ~body () =
33   object (self)
34
35     inherit [MatitaTypes.hist_metadata]
36       StatefulProofEngine.status ?uri ~typ ~body ~metasenv
37         (fun proof ->
38           Cic2acic.acic_object_of_cic_object (currentProof (fst proof)))
39         (fun (old_proof, old_metadata) new_proof ->
40           Cic2acic.acic_object_of_cic_object (currentProof (fst new_proof)))
41         ()
42
43     method toXml =
44       let currentproof = currentProof self#proof in
45       let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
46         Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
47       in
48       let uri = MatitaTypes.unopt_uri self#uri in
49       let xml, bodyxml =
50         match Cic2Xml.print_object uri ~ids_to_inner_sorts
51           ~ask_dtd_to_the_getter:true acurrentproof
52         with
53         | xml, Some bodyxml -> xml, bodyxml
54         | _, None -> assert false
55       in
56       (xml, bodyxml)
57
58     method toString =
59       let (xml, bodyxml) = self#toXml in
60       let buf = Buffer.create 10240 in
61       List.iter (Buffer.add_string buf)
62         [ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
63           "<!DOCTYPE ConstantType SYSTEM \"http://mowgli.cs.unibo.it:58081/getdtd?uri=cic.dtd\">\n";
64           "<ProofStatus>\n";
65           (Misc.strip_xml_headings (Xml.pp_to_string xml));
66           (Misc.strip_xml_headings(Xml.pp_to_string bodyxml));
67           (if not (self#proof_completed) then
68             Printf.sprintf "<CurrentGoal>%d</CurrentGoal>" self#goal
69           else
70             "<CurrentGoal />");
71           "\n</ProofStatus>"
72         ];
73       Buffer.contents buf
74
75   end
76
77 let proof ?uri ~metasenv ~typ () =
78   let metasenv = (1, [], typ) :: metasenv in
79   let body = Cic.Meta (1,[]) in
80   let _  = CicTypeChecker.type_of_aux' metasenv [] typ in
81   new proof ~typ ~metasenv ~body ?uri ()
82