]> matita.cs.unibo.it Git - helm.git/blob - components/content_pres/content2Procedural.ml
M logic/coimplication.ma
[helm.git] / components / content_pres / content2Procedural.ml
1 (* Copyright (C) 2003-2005, 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://cs.unibo.it/helm/.
24  *)
25
26 module H = HExtlib
27 module C = Content
28 module G = GrafiteAst
29 module N = CicNotationPt
30
31 (* grafite ast constructors *************************************************)
32
33 let floc = H.dummy_floc
34
35 let mk_note str = G.Comment (floc, G.Note (floc, str))
36
37 let mk_theorem name t = 
38    let obj = N.Theorem (`Theorem, name, t, None) in
39    G.Executable (floc, G.Command (floc, G.Obj (floc, obj)))
40
41 let mk_tactic tactic =
42    let sep = G.Dot floc in
43    G.Executable (floc, G.Tactical (floc, G.Tactic (floc, tactic), Some sep))
44
45 let mk_intros xi ids =
46    let tactic = G.Intros (floc, xi, ids) in
47    mk_tactic tactic
48    
49 let mk_exact t =
50    let tactic = G.Exact (floc, t) in
51    mk_tactic tactic
52
53 (* internal functions *******************************************************)
54
55 let mk_intros_arg = function
56    | `Declaration {C.dec_name = Some name}
57    | `Hypothesis {C.dec_name = Some name}
58    | `Definition {C.def_name = Some name} -> name 
59    | _ -> assert false
60
61 let mk_intros_args pc = List.map mk_intros_arg pc
62
63 let rec mk_proof p = 
64    let cmethod = p.C.proof_conclude.C.conclude_method in
65    let cargs = p.C.proof_conclude.C.conclude_args in
66    match cmethod, cargs with
67       | "Intros+LetTac", [C.ArgProof q] -> 
68          let names = mk_intros_args q.C.proof_context in
69          let num = List.length names in
70          let text = String.concat " " names in
71          mk_intros (Some num) [] :: mk_note text :: mk_proof q
72       | _ -> [mk_note (Printf.sprintf "%s %u" cmethod (List.length cargs))] 
73
74 (* interface functions ******************************************************)
75
76 let content2procedural ~ids_to_inner_sorts prefix (_, params, xmenv, obj) = 
77    if List.length params > 0 || xmenv <> None then assert false;
78    match obj with
79       | `Def (C.Const, t, `Proof ({C.proof_name = Some name} as p)) ->
80            mk_theorem name t :: mk_proof p
81       | _ -> assert false