]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_kernel/nCic2OCic.ml
snapshot inverse tranformation
[helm.git] / helm / software / components / ng_kernel / nCic2OCic.ml
diff --git a/helm/software/components/ng_kernel/nCic2OCic.ml b/helm/software/components/ng_kernel/nCic2OCic.ml
new file mode 100644 (file)
index 0000000..13c703d
--- /dev/null
@@ -0,0 +1,51 @@
+
+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 t)
+ | NCic.Lambda  (n,s,t) -> Cic.Lambda(Cic.Name n,convert_term k s, convert_term k t)
+ | NCic.LetIn (n,_,s,t) -> Cic.LetIn (Cic.Name n,convert_term k s, convert_term k 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 _) -> 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,
+       List.map (convert_term k) pl)
+ | NCic.Const (NReference.Ref (_,u,NReference.Fix (i,_))) -> assert false
+    (* map to rel if is the self-fix, otherwise explode *)
+ | NCic.Const (NReference.Ref (_,u,NReference.CoFix i)) -> assert false
+    (* map to rel if is the self-fix, otherwise explode *)
+ | _ -> assert false
+;;
+
+let convert_fix k fl = 
+  let n_fl = List.length fl in
+  let fl = 
+    List.map
+    (fun (_, name,recno,ty,bo) -> 
+      name, recno, convert_term 0 ty, convert_term 0 bo)
+    fl
+  in 
+    Cic.Fix (k, fl)
+;;
+
+let convert_nobj = function 
+ | _,_,_,_,NCic.Constant (rel, name, Some bo, ty, _) ->
+     Cic.Constant (name, Some (convert_term 0 bo), convert_term 0 ty, [],[])
+ | _,_,_,_,NCic.Constant (rel, name,  None, ty, _) ->
+     Cic.Constant (name, None, convert_term 0 ty, [],[])
+ | _,_,_,_,NCic.Fixpoint (is_fix, fl, _) ->
+     Cic.Constant ("pippo", Some (convert_fix 0 fl), 
+       convert_term 0 (let _,_,_,ty,_ = List.hd fl in ty), [], [])
+ | _,_,_,_,NCic.Inductive _ -> assert false
+;;