]> matita.cs.unibo.it Git - helm.git/commitdiff
snapshot inverse tranformation
authorEnrico Tassi <enrico.tassi@inria.fr>
Tue, 19 Feb 2008 16:55:40 +0000 (16:55 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Tue, 19 Feb 2008 16:55:40 +0000 (16:55 +0000)
helm/software/components/ng_kernel/.depend
helm/software/components/ng_kernel/Makefile
helm/software/components/ng_kernel/nCic2OCic.ml [new file with mode: 0644]
helm/software/components/ng_kernel/nCic2OCic.mli [new file with mode: 0644]
helm/software/components/ng_kernel/oCic2NCic.ml

index c565149481a22ee26ff71cfd059f476feb00d9ab..77deeaeec4da316be4d587c80cfc3ea2980ad132 100644 (file)
@@ -1,28 +1,33 @@
-nCicEnvironment.cmi: nUri.cmi nCic.cmo 
+nCicEnvironment.cmi: nUri.cmi nReference.cmi nCic.cmo 
 nCicTypeChecker.cmi: nCic.cmo 
 nReference.cmi: nUri.cmi 
 oCic2NCic.cmi: nCic.cmo 
 nCicSubstitution.cmi: nCic.cmo 
 nCicUtils.cmi: nCic.cmo 
+nCic2OCic.cmi: nCic.cmo 
 nCic.cmo: nUri.cmi nReference.cmi 
 nCic.cmx: nUri.cmx nReference.cmx 
-nCicEnvironment.cmo: oCic2NCic.cmi nUri.cmi nCicEnvironment.cmi 
-nCicEnvironment.cmx: oCic2NCic.cmx nUri.cmx nCicEnvironment.cmi 
+nCicEnvironment.cmo: oCic2NCic.cmi nUri.cmi nReference.cmi nCic.cmo \
+    nCicEnvironment.cmi 
+nCicEnvironment.cmx: oCic2NCic.cmx nUri.cmx nReference.cmx nCic.cmx \
+    nCicEnvironment.cmi 
 nCicTypeChecker.cmo: nCicTypeChecker.cmi 
 nCicTypeChecker.cmx: nCicTypeChecker.cmi 
 nReference.cmo: nUri.cmi nReference.cmi 
 nReference.cmx: nUri.cmx nReference.cmi 
 oCicTypeChecker.cmo: oCic2NCic.cmi nCicTypeChecker.cmi oCicTypeChecker.cmi 
 oCicTypeChecker.cmx: oCic2NCic.cmx nCicTypeChecker.cmx oCicTypeChecker.cmi 
-oCic2NCic.cmo: nUri.cmi nCic.cmo oCic2NCic.cmi 
-oCic2NCic.cmx: nUri.cmx nCic.cmx oCic2NCic.cmi 
+oCic2NCic.cmo: nUri.cmi nReference.cmi nCic.cmo oCic2NCic.cmi 
+oCic2NCic.cmx: nUri.cmx nReference.cmx nCic.cmx oCic2NCic.cmi 
 nUri.cmo: nUri.cmi 
 nUri.cmx: nUri.cmi 
 nCicSubstitution.cmo: nCicUtils.cmi nCic.cmo nCicSubstitution.cmi 
 nCicSubstitution.cmx: nCicUtils.cmx nCic.cmx nCicSubstitution.cmi 
 nCicUtils.cmo: nCic.cmo nCicUtils.cmi 
 nCicUtils.cmx: nCic.cmx nCicUtils.cmi 
-nCicReduction.cmo: nReference.cmi nCicSubstitution.cmi nCicEnvironment.cmi \
-    nCic.cmo nCicReduction.cmi 
-nCicReduction.cmx: nReference.cmx nCicSubstitution.cmx nCicEnvironment.cmx \
-    nCic.cmx nCicReduction.cmi 
+nCicReduction.cmo: nReference.cmi nCicUtils.cmi nCicSubstitution.cmi \
+    nCicEnvironment.cmi nCic.cmo nCicReduction.cmi 
+nCicReduction.cmx: nReference.cmx nCicUtils.cmx nCicSubstitution.cmx \
+    nCicEnvironment.cmx nCic.cmx nCicReduction.cmi 
+nCic2OCic.cmo: nUri.cmi nReference.cmi nCic.cmo nCic2OCic.cmi 
+nCic2OCic.cmx: nUri.cmx nReference.cmx nCic.cmx nCic2OCic.cmi 
index 3bc7f1a190e715544d0f678d8bf0c6bd57cf6550..cda5a99504e3afc3d7f3ead1e76bd7ac8e0d4ad8 100644 (file)
@@ -2,7 +2,7 @@ PACKAGE = ng_kernel
 PREDICATES =
 
 INTERFACE_FILES = \
-       nCicEnvironment.mli nCicTypeChecker.mli nReference.mli oCicTypeChecker.mli oCic2NCic.mli nUri.mli nCicSubstitution.mli nCicUtils.mli nCicReduction.mli
+       nCicEnvironment.mli nCicTypeChecker.mli nReference.mli oCicTypeChecker.mli oCic2NCic.mli nUri.mli nCicSubstitution.mli nCicUtils.mli nCicReduction.mli nCic2OCic.mli
 IMPLEMENTATION_FILES = \
   nCic.ml $(INTERFACE_FILES:%.mli=%.ml)
 EXTRA_OBJECTS_TO_INSTALL = 
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
+;;
diff --git a/helm/software/components/ng_kernel/nCic2OCic.mli b/helm/software/components/ng_kernel/nCic2OCic.mli
new file mode 100644 (file)
index 0000000..ab08d1b
--- /dev/null
@@ -0,0 +1 @@
+val convert_nobj: NCic.obj -> Cic.obj
index 407f705e28d4b2a33ac8b77b6a384586c37d06ca..bb5862fda85f5981516944e860cd9a3db06175c3 100644 (file)
@@ -88,6 +88,7 @@ let convert_term uri t =
             (fun (name,rno,ty,bo) (l,fixpoints) -> 
                let ty, fixpoints_ty = aux octx ctx n_fix uri ty in
                let bo, fixpoints_bo = aux boctx bctx (n_fix + n_fl) buri bo in
+               let rno = rno + List.length ctx - n_fix in
                (([],name,rno,splat true ctx ty, splat false ctx bo)::l),
                fixpoints_ty @ fixpoints_bo @ fixpoints)
             fl ([],[])