]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaProof.ml
98b9cf02c85178f85c71e528759b891075caa07e
[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 class proof ?uri ~typ ~metasenv ~body () =
27   object (self)
28
29     inherit [unit] StatefulProofEngine.status ?uri ~typ ~body ~metasenv
30       (fun _ -> ())
31       (fun _ _ -> ())
32       ()
33
34     method private currentProof =
35       let (uri, metasenv, bo, ty) = self#proof in
36       let uri =
37         match uri with
38         | Some uri -> uri
39         | None -> MatitaTypes.untitled_con_uri
40       in
41         (* TODO CSC: Wrong: [] is just plainly wrong *)
42       Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, [])
43
44     method toXml =
45       let currentproof = self#currentProof in
46       let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
47         Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
48       in
49       let uri = MatitaTypes.unopt_uri self#uri in
50       let xml, bodyxml =
51         match Cic2Xml.print_object uri ~ids_to_inner_sorts
52           ~ask_dtd_to_the_getter:true acurrentproof
53         with
54         | xml, Some bodyxml -> xml, bodyxml
55         | _, None -> assert false
56       in
57       (xml, bodyxml)
58
59     method toString =
60       let (xml, bodyxml) = self#toXml in
61       let buf = Buffer.create 10240 in
62       List.iter (Buffer.add_string buf)
63         [ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
64           "<!DOCTYPE ConstantType SYSTEM \"http://mowgli.cs.unibo.it:58081/getdtd?uri=cic.dtd\">\n";
65           "<ProofStatus>\n";
66           (Misc.strip_xml_headings (Xml.pp_to_string xml));
67           (Misc.strip_xml_headings(Xml.pp_to_string bodyxml));
68           (if not (self#proof_completed) then
69             Printf.sprintf "<CurrentGoal>%d</CurrentGoal>" self#goal
70           else
71             "<CurrentGoal />");
72           "\n</ProofStatus>"
73         ];
74       Buffer.contents buf
75
76   end
77
78 let proof ?uri ~metasenv ~typ () =
79   let metasenv = (1, [], typ) :: metasenv in
80   let body = Cic.Meta (1,[]) in
81   let _  = CicTypeChecker.type_of_aux' metasenv [] typ in
82   new proof ~typ ~metasenv ~body ?uri ()
83