X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_kernel%2FnCic2OCic.ml;h=5f8279d7e67cb3660652e392b882a49cc4fa63a7;hb=bd3680d6b90f6c8bdda4eb4a915a86a0e806de63;hp=e6a15d3158902099616a4fd0a47ec33e7dacef97;hpb=4a4703054e9f022479ac7ab9cb96007984da7ef2;p=helm.git diff --git a/helm/software/components/ng_kernel/nCic2OCic.ml b/helm/software/components/ng_kernel/nCic2OCic.ml index e6a15d315..5f8279d7e 100644 --- a/helm/software/components/ng_kernel/nCic2OCic.ml +++ b/helm/software/components/ng_kernel/nCic2OCic.ml @@ -1,35 +1,66 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department, University of Bologna, Italy. + ||I|| + ||T|| HELM is free software; you can redistribute it and/or + ||A|| modify it under the terms of the GNU General Public License + \ / version 2 or (at your option) any later version. + \ / This software is distributed as is, NO WARRANTY. + V_______________________________________________________________ *) + +(* $Id$ *) + +let ouri_of_nuri u = UriManager.uri_of_string (NUri.string_of_uri u);; + +let ouri_of_reference (NReference.Ref (u,_)) = ouri_of_nuri u;; + +let cprop = [false, NUri.uri_of_string ("cic:/matita/pts/CProp.univ")];; + +let nn_2_on = function + | "_" -> Cic.Anonymous + | s -> Cic.Name s +;; + let convert_term uri n_fl t = let rec convert_term k = function (* pass k along *) | NCic.Rel i -> Cic.Rel i | NCic.Meta _ -> assert false | NCic.Appl l -> Cic.Appl (List.map (convert_term k) l) | NCic.Prod (n,s,t) -> - Cic.Prod (Cic.Name n,convert_term k s, convert_term (k+1) t) + Cic.Prod (nn_2_on n,convert_term k s, convert_term (k+1) t) | NCic.Lambda (n,s,t) -> - Cic.Lambda(Cic.Name n,convert_term k s, convert_term (k+1) t) - | NCic.LetIn (n,_,s,t) -> - Cic.LetIn (Cic.Name n,convert_term k s, convert_term (k+1) t) + Cic.Lambda(nn_2_on n,convert_term k s, convert_term (k+1) t) + | NCic.LetIn (n,ty_s,s,t) -> + Cic.LetIn (nn_2_on n,convert_term k s,convert_term k ty_s, convert_term (k+1) t) | NCic.Sort NCic.Prop -> Cic.Sort Cic.Prop - | NCic.Sort NCic.CProp -> Cic.Sort Cic.CProp - | NCic.Sort NCic.Set -> Cic.Sort Cic.Set + | NCic.Sort (NCic.Type u) when + (* BUG HERE: I should use NCicEnvironment.universe_eq, but I do not + want to add this recursion between the modules *) + (*NCicEnvironment.universe_eq*) u=cprop -> Cic.Sort (Cic.CProp (CicUniv.fresh ())) | NCic.Sort (NCic.Type _) -> Cic.Sort (Cic.Type (CicUniv.fresh ())) | NCic.Implicit _ -> assert false - | NCic.Const (NReference.Ref (_,u,NReference.Ind i)) -> - Cic.MutInd (NUri.ouri_of_nuri u,i,[]) - | NCic.Const (NReference.Ref (_,u,NReference.Con (i,j))) -> - Cic.MutConstruct (NUri.ouri_of_nuri u,i,j,[]) - | NCic.Const (NReference.Ref (_,u,NReference.Def)) - | NCic.Const (NReference.Ref (_,u,NReference.Decl)) -> - Cic.Const (NUri.ouri_of_nuri u,[]) - | NCic.Match (NReference.Ref (_,u,NReference.Ind i),oty,t,pl) -> - Cic.MutCase (NUri.ouri_of_nuri u,i, convert_term k oty, convert_term k t, + | NCic.Const (NReference.Ref (u,NReference.Ind (_,i,_))) -> + Cic.MutInd (ouri_of_nuri u,i,[]) + | NCic.Const (NReference.Ref (u,NReference.Con (i,j,_))) -> + Cic.MutConstruct (ouri_of_nuri u,i,j,[]) + | NCic.Const (NReference.Ref (u,NReference.Def _)) + | NCic.Const (NReference.Ref (u,NReference.Decl)) -> + Cic.Const (ouri_of_nuri u,[]) + | NCic.Match (NReference.Ref (u,NReference.Ind (_,i,_)),oty,t,pl) -> + Cic.MutCase (ouri_of_nuri u,i, convert_term k oty, convert_term k t, List.map (convert_term k) pl) - | NCic.Const (NReference.Ref (_,u,NReference.Fix (i,_))) - | NCic.Const (NReference.Ref (_,u,NReference.CoFix i)) -> + | NCic.Const (NReference.Ref (u,NReference.Fix (i,_,_))) + | NCic.Const (NReference.Ref (u,NReference.CoFix i)) -> if NUri.eq u uri then Cic.Rel (n_fl - i + k) else - Cic.Const (NUri.ouri_of_nuri u,[]) + let ouri = ouri_of_nuri u in + let ouri = + UriManager.uri_of_string + (UriManager.buri_of_uri ouri ^ "/" ^ + UriManager.name_of_uri ouri ^ string_of_int i ^ ".con") in + Cic.Const (ouri,[]) | _ -> assert false in convert_term 0 t @@ -57,12 +88,30 @@ let convert_fix is_fix uri k fl = let convert_nobj = function | u,_,_,_,NCic.Constant (_, name, Some bo, ty, _) -> - Cic.Constant (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[]) + [ouri_of_nuri u,Cic.Constant + (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[])] | u,_,_,_,NCic.Constant (_, name, None, ty, _) -> - Cic.Constant (name, None, convert_term u 0 ty, [],[]) + [ouri_of_nuri u,Cic.Constant (name, None, convert_term u 0 ty, [],[])] | u,_,_,_,NCic.Fixpoint (is_fix, fl, _) -> - Cic.Constant (UriManager.name_of_uri (NUri.ouri_of_nuri u), - Some (convert_fix is_fix u 0 fl), - convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], []) - | _,_,_,_,NCic.Inductive _ -> assert false + List.map + (fun nth -> + let name = + UriManager.name_of_uri (ouri_of_nuri u) ^ string_of_int nth in + let buri = UriManager.buri_of_uri (ouri_of_nuri u) in + let uri = UriManager.uri_of_string (buri ^"/"^name^".con") in + uri, + Cic.Constant (name, + Some (convert_fix is_fix u nth fl), + convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], [])) + (let rec seq = function 0 -> [0]|n -> n::seq (n-1) in + seq (List.length fl-1)) + | u,_,_,_,NCic.Inductive (inductive,leftno,itl,_) -> + let itl = + List.map + (function (_,name,ty,cl) -> + let cl=List.map (function (_,name,ty) -> name,convert_term u 0 ty) cl in + name,inductive,convert_term u 0 ty,cl + ) itl + in + [ouri_of_nuri u, Cic.InductiveDefinition (itl,[],leftno,[])] ;;