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 class proofStatus ~typ ~metasenv ~uri () =
28 inherit MatitaTypes.subject
30 val mutable _proof = (uri, (1, [], typ) :: metasenv, Cic.Meta (1, []), typ)
31 val mutable _goal = Some 1
34 method setProof p = _proof <- p
36 method setGoal g = _goal <- g
39 (match _goal with Some g -> g | None -> raise MatitaTypes.No_proof)
40 method setStatus (p, g) =
45 let (uri, metasenv, bo, ty) = _proof in
47 (* TODO CSC: Wrong: [] is just plainly wrong *)
48 Cic.CurrentProof (UriManager.name_of_uri uri,metasenv, bo, ty, [])
50 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
51 Cic2acic.acic_object_of_cic_object ~eta_fix:false currentproof
54 match Cic2Xml.print_object uri ~ids_to_inner_sorts
55 ~ask_dtd_to_the_getter:true acurrentproof
57 | xml, Some bodyxml -> xml, bodyxml
58 | _, None -> assert false
63 let (xml, bodyxml) = self#toXml in
64 let buf = Buffer.create 10240 in
65 Buffer.add_string buf "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
66 Buffer.add_string buf "<!DOCTYPE ConstantType SYSTEM \"http://mowgli.cs.unibo.it:58081/getdtd?uri=cic.dtd\">\n";
67 Buffer.add_string buf "<ProofStatus>\n";
68 Buffer.add_string buf (Misc.strip_xml_headings (Xml.pp_to_string xml));
69 Buffer.add_string buf (Misc.strip_xml_headings(Xml.pp_to_string bodyxml));
72 | None -> "<CurrentGoal />"
73 | Some goal -> Printf.sprintf "<CurrentGoal>%d</CurrentGoal>" goal);
74 Buffer.add_string buf "\n</ProofStatus>";
79 let proofStatus ~typ ?(metasenv = []) ?(uri = MatitaTypes.untitled_con_uri) () =
80 new proofStatus ~typ ~metasenv ~uri ()
82 let proofStatus_of_string s =
83 MatitaTypes.not_implemented "MatitaProof.proofStatus_of_string"
85 class proof ~typ ?metasenv ?uri () =
87 val mutable _status = proofStatus ~typ ?metasenv ?uri ()
88 method status = _status
89 method setStatus s = _status <- s
94 class tacticCommand ~(tactic:ProofEngineTypes.tactic) (status: proofStatus) =
96 val statusBackup = status#status
99 let (new_proof, new_goals) = tactic status#status in
100 status#setProof new_proof;
102 (match new_goals, new_proof with
103 | goal :: _, _ -> Some goal
104 | [], (_, (goal, _, _) :: _, _, _) ->
105 (* the tactic left no open goal: let's choose the first open goal *)
106 (* TODO CSC: here we could implement and use a proof-tree like
113 status#setStatus statusBackup;
119 ~tactic:(PrimitiveTactics.intros_tac ?mk_fresh_name_callback:namer ())
121 let reflexivity = new tacticCommand ~tactic:EqualityTactics.reflexivity_tac
122 let symmetry = new tacticCommand ~tactic:EqualityTactics.symmetry_tac
123 let transitivity term =
124 new tacticCommand ~tactic:(EqualityTactics.transitivity_tac ~term)
126 let exists = new tacticCommand ~tactic:IntroductionTactics.exists_tac
127 let split = new tacticCommand ~tactic:IntroductionTactics.split_tac
128 let left = new tacticCommand ~tactic:IntroductionTactics.left_tac
129 let right = new tacticCommand ~tactic:IntroductionTactics.right_tac
131 let assumption = new tacticCommand ~tactic:VariousTactics.assumption_tac