]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/sequent2pres.ml
4c47bc51aa47fe28320627d88706614e52b729f0
[helm.git] / helm / ocaml / cic_transformations / 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 let p_mtr a b = Mpresentation.Mtr(a,b)
36 let p_mtd a b = Mpresentation.Mtd(a,b)
37 let p_mtable a b = Mpresentation.Mtable(a,b)
38 let p_mtext a b = Mpresentation.Mtext(a,b)
39 let p_mi a b = Mpresentation.Mi(a,b)
40 let p_mo a b = Mpresentation.Mo(a,b)
41 let p_mrow a b = Mpresentation.Mrow(a,b)
42 let p_mphantom a b = Mpresentation.Mphantom(a,b)
43
44 let sequent2pres term2pres (_,_,context,ty) =
45  let module K = Content in
46  let module P = Mpresentation in
47    let make_tr r =
48       p_mtr [] [p_mtd [] r] in
49    let context2pres context = 
50      let rec aux accum =
51      function 
52        [] -> accum 
53      | None::tl -> aux accum tl
54      | (Some (`Declaration d))::tl ->
55          let
56            { K.dec_name = dec_name ;
57              K.dec_id = dec_id ;
58              K.dec_type = ty } = d in
59          let r = 
60            p_mrow [Some "helm", "xref", dec_id] 
61              [ p_mi []
62                (match dec_name with
63                   None -> "_"
64                 | Some n -> n) ;
65                p_mo [] ":" ;
66                term2pres ty] in
67          aux ((make_tr r)::accum) tl
68      | (Some (`Definition d))::tl ->
69          let
70            { K.def_name = def_name ;
71              K.def_id = def_id ;
72              K.def_term = bo } = d in
73          let r = 
74             p_mrow [Some "helm", "xref", def_id]
75               [ p_mi []
76                 (match def_name with
77                    None -> "_"
78                  | Some n -> n) ;
79                  p_mo [] ":=" ;
80                 term2pres bo] in
81          aux ((make_tr r)::accum) tl
82       | _::_ -> assert false in
83       aux [] context in
84  let pres_context = 
85    make_tr 
86     (p_mtable
87       [None,"align","baseline 1"; None,"equalrows","false"; 
88        None,"columnalign","left"]
89       (context2pres context)) in
90  let pres_goal = 
91    make_tr (term2pres ty) in 
92  (p_mtable
93    [None,"align","baseline 1"; None,"equalrows","false"; 
94     None,"columnalign","left"; None,"rowlines","solid"] 
95     [pres_context;pres_goal])
96 ;;
97
98 let sequent2pres ~ids_to_inner_sorts =
99  sequent2pres 
100   (function p -> 
101    (Cexpr2pres.cexpr2pres_charcount 
102     (Content_expressions.acic2cexpr ids_to_inner_sorts p)))
103 ;;
104
105
106
107