From 8a49ad7c7475e5486ea9ecacc82a07b15fcded6e Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Tue, 19 Feb 2008 16:55:40 +0000 Subject: [PATCH] snapshot inverse tranformation --- helm/software/components/ng_kernel/.depend | 23 +++++---- helm/software/components/ng_kernel/Makefile | 2 +- .../components/ng_kernel/nCic2OCic.ml | 51 +++++++++++++++++++ .../components/ng_kernel/nCic2OCic.mli | 1 + .../components/ng_kernel/oCic2NCic.ml | 1 + 5 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 helm/software/components/ng_kernel/nCic2OCic.ml create mode 100644 helm/software/components/ng_kernel/nCic2OCic.mli diff --git a/helm/software/components/ng_kernel/.depend b/helm/software/components/ng_kernel/.depend index c56514948..77deeaeec 100644 --- a/helm/software/components/ng_kernel/.depend +++ b/helm/software/components/ng_kernel/.depend @@ -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 diff --git a/helm/software/components/ng_kernel/Makefile b/helm/software/components/ng_kernel/Makefile index 3bc7f1a19..cda5a9950 100644 --- a/helm/software/components/ng_kernel/Makefile +++ b/helm/software/components/ng_kernel/Makefile @@ -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 index 000000000..13c703dae --- /dev/null +++ b/helm/software/components/ng_kernel/nCic2OCic.ml @@ -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 index 000000000..ab08d1bd9 --- /dev/null +++ b/helm/software/components/ng_kernel/nCic2OCic.mli @@ -0,0 +1 @@ +val convert_nobj: NCic.obj -> Cic.obj diff --git a/helm/software/components/ng_kernel/oCic2NCic.ml b/helm/software/components/ng_kernel/oCic2NCic.ml index 407f705e2..bb5862fda 100644 --- a/helm/software/components/ng_kernel/oCic2NCic.ml +++ b/helm/software/components/ng_kernel/oCic2NCic.ml @@ -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 ([],[]) -- 2.39.2