]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_transformations/sequent2pres.ml
Added all transformations for sequents.
[helm.git] / helm / ocaml / cic_transformations / sequent2pres.ml
diff --git a/helm/ocaml/cic_transformations/sequent2pres.ml b/helm/ocaml/cic_transformations/sequent2pres.ml
new file mode 100644 (file)
index 0000000..4c47bc5
--- /dev/null
@@ -0,0 +1,107 @@
+(* Copyright (C) 2000, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(***************************************************************************)
+(*                                                                         *)
+(*                            PROJECT HELM                                 *)
+(*                                                                         *)
+(*                Andrea Asperti <asperti@cs.unibo.it>                     *)
+(*                              19/11/2003                                 *)
+(*                                                                         *)
+(***************************************************************************)
+
+let p_mtr a b = Mpresentation.Mtr(a,b)
+let p_mtd a b = Mpresentation.Mtd(a,b)
+let p_mtable a b = Mpresentation.Mtable(a,b)
+let p_mtext a b = Mpresentation.Mtext(a,b)
+let p_mi a b = Mpresentation.Mi(a,b)
+let p_mo a b = Mpresentation.Mo(a,b)
+let p_mrow a b = Mpresentation.Mrow(a,b)
+let p_mphantom a b = Mpresentation.Mphantom(a,b)
+
+let sequent2pres term2pres (_,_,context,ty) =
+ let module K = Content in
+ let module P = Mpresentation in
+   let make_tr r =
+      p_mtr [] [p_mtd [] r] in
+   let context2pres context = 
+     let rec aux accum =
+     function 
+       [] -> accum 
+     | None::tl -> aux accum tl
+     | (Some (`Declaration d))::tl ->
+         let
+           { K.dec_name = dec_name ;
+             K.dec_id = dec_id ;
+             K.dec_type = ty } = d in
+         let r = 
+           p_mrow [Some "helm", "xref", dec_id] 
+             [ p_mi []
+               (match dec_name with
+                  None -> "_"
+                | Some n -> n) ;
+               p_mo [] ":" ;
+               term2pres ty] in
+         aux ((make_tr r)::accum) tl
+     | (Some (`Definition d))::tl ->
+         let
+           { K.def_name = def_name ;
+             K.def_id = def_id ;
+             K.def_term = bo } = d in
+         let r = 
+            p_mrow [Some "helm", "xref", def_id]
+              [ p_mi []
+                (match def_name with
+                   None -> "_"
+                 | Some n -> n) ;
+                 p_mo [] ":=" ;
+                term2pres bo] in
+         aux ((make_tr r)::accum) tl
+      | _::_ -> assert false in
+      aux [] context in
+ let pres_context = 
+   make_tr 
+    (p_mtable
+      [None,"align","baseline 1"; None,"equalrows","false"; 
+       None,"columnalign","left"]
+      (context2pres context)) in
+ let pres_goal = 
+   make_tr (term2pres ty) in 
+ (p_mtable
+   [None,"align","baseline 1"; None,"equalrows","false"; 
+    None,"columnalign","left"; None,"rowlines","solid"] 
+    [pres_context;pres_goal])
+;;
+
+let sequent2pres ~ids_to_inner_sorts =
+ sequent2pres 
+  (function p -> 
+   (Cexpr2pres.cexpr2pres_charcount 
+    (Content_expressions.acic2cexpr ids_to_inner_sorts p)))
+;;
+
+
+
+