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) | 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) | 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,_))) | 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,[]) | _ -> assert false in convert_term 0 t ;; let convert_fix is_fix uri k fl = let n_fl = List.length fl in if is_fix then let fl = List.map (fun (_, name,recno,ty,bo) -> name, recno, convert_term uri n_fl ty, convert_term uri n_fl bo) fl in Cic.Fix (k, fl) else let fl = List.map (fun (_, name,_,ty,bo) -> name, convert_term uri n_fl ty, convert_term uri n_fl bo) fl in Cic.CoFix (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, [],[]) | u,_,_,_,NCic.Constant (_, name, None, ty, _) -> 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 ;;