]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/content_pres/sequent2pres.ml
test branch
[helm.git] / helm / ocaml / content_pres / sequent2pres.ml
1 (* Copyright (C) 2000, 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 (***************************************************************************)
27 (*                                                                         *)
28 (*                            PROJECT HELM                                 *)
29 (*                                                                         *)
30 (*                Andrea Asperti <asperti@cs.unibo.it>                     *)
31 (*                              19/11/2003                                 *)
32 (*                                                                         *)
33 (***************************************************************************)
34
35 (* $Id$ *)
36
37 let p_mtr a b = Mpresentation.Mtr(a,b)
38 let p_mtd a b = Mpresentation.Mtd(a,b)
39 let p_mtable a b = Mpresentation.Mtable(a,b)
40 let p_mtext a b = Mpresentation.Mtext(a,b)
41 let p_mi a b = Mpresentation.Mi(a,b)
42 let p_mo a b = Mpresentation.Mo(a,b)
43 let p_mrow a b = Mpresentation.Mrow(a,b)
44 let p_mphantom a b = Mpresentation.Mphantom(a,b)
45 let b_ink a = Box.Ink a
46
47 module K = Content
48 module P = Mpresentation
49
50 let sequent2pres term2pres (_,_,context,ty) =
51    let context2pres context = 
52      let rec aux accum =
53      function 
54        [] -> accum 
55      | None::tl -> aux accum tl
56      | (Some (`Declaration d))::tl ->
57          let
58            { K.dec_name = dec_name ;
59              K.dec_id = dec_id ;
60              K.dec_type = ty } = d in
61          let r = 
62            Box.b_h [Some "helm", "xref", dec_id] 
63              [ Box.b_object (p_mi []
64                (match dec_name with
65                   None -> "_"
66                 | Some n -> n)) ;
67                Box.b_text [] ":" ;
68                term2pres ty] in
69          aux (r::accum) tl
70      | (Some (`Definition d))::tl ->
71          let
72            { K.def_name = def_name ;
73              K.def_id = def_id ;
74              K.def_term = bo } = d in
75          let r = 
76             Box.b_h [Some "helm", "xref", def_id]
77               [ Box.b_object (p_mi []
78                 (match def_name with
79                    None -> "_"
80                  | Some n -> n)) ;
81                  Box.b_text [] (Utf8Macro.unicode_of_tex "\\def") ;
82                 term2pres bo] in
83          aux (r::accum) tl
84       | _::_ -> assert false in
85       aux [] context in
86  let pres_context = (Box.b_v [] (context2pres context)) in
87  let pres_goal = term2pres ty in 
88  (Box.b_h [] [
89    Box.b_space; 
90    (Box.b_v []
91       [Box.b_space;
92        pres_context;
93        b_ink [None,"width","4cm"; None,"height","2px"]; (* sequent line *)
94        Box.b_space; 
95        pres_goal])])
96
97 let sequent2pres ~ids_to_inner_sorts =
98   sequent2pres
99     (fun annterm ->
100       let ast, ids_to_uris =
101         TermAcicContent.ast_of_acic ids_to_inner_sorts annterm
102       in
103       CicNotationPres.box_of_mpres
104         (CicNotationPres.render ids_to_uris
105           (TermContentPres.pp_ast ast)))
106