]> matita.cs.unibo.it Git - helm.git/commitdiff
Rendering of InductiveDefinitions, Variables and Axioms implemented.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 18 Nov 2002 09:54:54 +0000 (09:54 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 18 Nov 2002 09:54:54 +0000 (09:54 +0000)
helm/gTopLevel/cic2Xml.ml
helm/gTopLevel/cic2acic.ml
helm/gTopLevel/cic2acic.mli

index 57d4fc7e4e086386d05919cc9c349e6248b11cac..d76df870eb48d9f4cf26bd4e89df2bc23daf0c77 100644 (file)
@@ -251,8 +251,6 @@ let print_term ~ids_to_inner_sorts =
    aux
 ;;
 
-exception NotImplemented;;
-
 let print_object uri ~ids_to_inner_sorts =
  let rec aux =
   let module C = Cic in
@@ -341,7 +339,57 @@ let print_object uri ~ids_to_inner_sorts =
          >]
         in
          xmlty, xmlbo
-     | _ -> raise NotImplemented
+     | C.AVariable (id,n,bo,ty,params) ->
+        let params' = param_attribute_of_params params in
+        let xmlbo =
+         match bo with
+            None -> [< >]
+          | Some bo ->
+             X.xml_nempty "body" [] [< print_term ids_to_inner_sorts bo >]
+        in
+        let aobj =
+         [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
+            X.xml_cdata ("<!DOCTYPE Variable SYSTEM \"" ^ dtdname ^ "\">\n");
+             X.xml_nempty "Variable"
+              ["name",n ; "params",params' ; "id", id]
+              [< xmlbo ;
+                 X.xml_nempty "type" [] (print_term ids_to_inner_sorts ty)
+              >]
+         >]
+        in
+         aobj, None
+     | C.AInductiveDefinition (id,tys,params,nparams) ->
+        let params' = param_attribute_of_params params in
+         [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
+            X.xml_cdata ("<!DOCTYPE InductiveDefinition SYSTEM \"" ^
+             dtdname ^ "\">\n") ;
+            X.xml_nempty "InductiveDefinition"
+             ["noParams",string_of_int nparams ;
+              "id",id ;
+              "params",params']
+             [< (List.fold_left
+                  (fun i (id,typename,finite,arity,cons) ->
+                    [< i ;
+                       X.xml_nempty "InductiveType"
+                        ["id",id ; "name",typename ;
+                         "inductive",(string_of_bool finite)
+                        ]
+                        [< X.xml_nempty "arity" []
+                            (print_term ids_to_inner_sorts arity) ;
+                           (List.fold_left
+                            (fun i (name,lc) ->
+                              [< i ;
+                                 X.xml_nempty "Constructor"
+                                  ["name",name]
+                                  (print_term ids_to_inner_sorts lc)
+                              >]) [<>] cons
+                           )
+                        >]
+                    >]
+                  ) [< >] tys
+                )
+             >]
+         >], None
  in
   aux
 ;;
index 8d849634dd0726fba35c6f0aaca9c3b7e1b92e89..93277121428a9b7bc1346d817e9452ec191c6d5e 100644 (file)
@@ -23,8 +23,6 @@
  * http://cs.unibo.it/helm/.
  *)
 
-exception NotImplemented;;
-
 type anntypes =
  {annsynthesized : Cic.annterm ; annexpected : Cic.annterm option}
 ;;
@@ -303,8 +301,19 @@ let acic_object_of_cic_object obj =
        let aty = acic_term_of_cic_term' ty None in
         C.AConstant
          ("mettereaposto",Some "mettereaposto2",id,Some abo,aty, params)
-    | C.Constant (id,None,ty,params) -> raise NotImplemented
-    | C.Variable (id,bo,ty,params) -> raise NotImplemented
+    | C.Constant (id,None,ty,params) ->
+       let aty = acic_term_of_cic_term' ty None in
+        C.AConstant
+         ("mettereaposto",None,id,None,aty, params)
+    | C.Variable (id,bo,ty,params) ->
+       let abo =
+        match bo with
+           None -> None
+         | Some bo -> Some (acic_term_of_cic_term' bo (Some ty))
+       in
+       let aty = acic_term_of_cic_term' ty None in
+        C.AVariable
+         ("mettereaposto",id,abo,aty, params)
     | C.CurrentProof (id,conjectures,bo,ty,params) ->
        let aconjectures =
         List.map
@@ -357,7 +366,25 @@ let acic_object_of_cic_object obj =
        let aty = acic_term_of_cic_term_context' conjectures [] [] ty None in
         C.ACurrentProof
          ("mettereaposto","mettereaposto2",id,aconjectures,abo,aty,params)
-    | C.InductiveDefinition (tys,params,paramsno) -> raise NotImplemented
+    | C.InductiveDefinition (tys,params,paramsno) ->
+       let context =
+        List.map
+         (fun (name,_,arity,_) -> Some (C.Name name, C.Decl arity)) tys in
+       let idrefs = List.map (function _ -> gen_id seed) tys in
+       let atys =
+        List.map2
+         (fun id (name,inductive,ty,cons) ->
+           let acons =
+            List.map
+             (function (name,ty) ->
+               (name,
+                 acic_term_of_cic_term_context' [] context idrefs ty None)
+             ) cons
+           in
+            (id,name,inductive,acic_term_of_cic_term' ty None,acons)
+         ) (List.rev idrefs) tys
+       in
+        C.AInductiveDefinition ("mettereaposto",atys,params,paramsno)
    in
     aobj,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,ids_to_inner_types,
      ids_to_conjectures,ids_to_hypotheses
index bc174d12196e50d2df8be84af126e18e84c87e4b..0cd607bb67888aaa05fe472c49f8af0a9da53e91 100644 (file)
@@ -23,7 +23,6 @@
  * http://cs.unibo.it/helm/.
  *)
 
-exception NotImplemented
 exception NotEnoughElements
 exception NameExpected