]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_refiner/nCicRefiner.ml
- pretty printer made robust in face of list_nth
[helm.git] / helm / software / components / ng_refiner / nCicRefiner.ml
index 4807e5271938291a8e63e3b921ea7f220029caef..e38842ac82c57c6c454582438a5726f6f89ba86a 100644 (file)
@@ -538,19 +538,19 @@ let typeof_obj hdb
   ?(localise=fun _ -> Stdpp.dummy_loc) 
   ~look_for_coercion (uri,height,metasenv,subst,obj)
 = 
-  let check_type metasenv subst (ty as orig_ty) =  (* XXX fattorizza *)
+  let check_type metasenv subst context (ty as orig_ty) =  (* XXX fattorizza *)
     let metasenv, subst, ty, sort = 
-      typeof hdb ~localise ~look_for_coercion metasenv subst [] ty None
+      typeof hdb ~localise ~look_for_coercion metasenv subst context ty None
     in
     let metasenv, subst, ty, sort = 
       force_to_sort hdb ~look_for_coercion 
-        metasenv subst [] ty orig_ty localise sort
+        metasenv subst context ty orig_ty localise sort
     in
       metasenv, subst, ty, sort
   in
   match obj with 
   | C.Constant (relevance, name, bo, ty , attr) ->
-       let metasenv, subst, ty, _ = check_type metasenv subst ty in
+       let metasenv, subst, ty, _ = check_type metasenv subst [] ty in
        let metasenv, subst, bo, ty, height = 
          match bo with
          | Some bo ->
@@ -569,7 +569,7 @@ let typeof_obj hdb
       let types, metasenv, subst, rev_fl =
         List.fold_left
          (fun (types, metasenv, subst, fl) (relevance,name,k,ty,bo) ->
-           let metasenv, subst, ty, _ = check_type metasenv subst ty in
+           let metasenv, subst, ty, _ = check_type metasenv subst [] ty in
            let dbo = NCicTypeChecker.debruijn uri len [] bo in
            let localise = relocalise localise dbo bo in
             (name,C.Decl ty)::types,
@@ -606,7 +606,7 @@ let typeof_obj hdb
      let metasenv,subst,rev_itl,tys =
       List.fold_left
        (fun (metasenv,subst,res,ctx) (relevance,n,ty,cl) ->
-         let metasenv, subst, ty, _ = check_type metasenv subst ty in
+          let metasenv, subst, ty, _ = check_type metasenv subst [] ty in
           metasenv,subst,(relevance,n,ty,cl)::res,(n,NCic.Decl ty)::ctx
        ) (metasenv,subst,[],[]) itl in
      let metasenv,subst,itl,_ =
@@ -666,7 +666,9 @@ let typeof_obj hdb
                 ) (metasenv,subst,[]) sx_context_ty_rev sx_context_te_rev
               with Invalid_argument "List.fold_left2" -> assert false
              in
-             let metasenv, subst, te, con_sort = check_type metasenv subst te in
+             let metasenv, subst, te, con_sort = 
+               check_type metasenv subst context te 
+             in
               (match
                 NCicReduction.whd ~subst context con_sort,
                 NCicReduction.whd ~subst [] ty_sort
@@ -698,11 +700,18 @@ let typeof_obj hdb
                     (lazy (localise te,
                       "Non positive occurence in " ^ NUri.string_of_uri uri)))
               else
+               let te = 
+                 NCicSubstitution.psubst 
+                  (fun i -> NCic.Const (NReference.reference_of_spec uri
+                     (NReference.Ind (ind,i,leftno))))
+                  (List.rev (HExtlib.list_seq 0 (List.length itl)))
+                   te 
+               in      
                metasenv,subst,(k_relev,n,te)::res
               ) cl (metasenv,subst,[])
          in
-          metasenv,subst,(it_relev,n,ty,cl)::res,i-1
-       ) (metasenv,subst,[],List.length rev_itl) rev_itl
+          metasenv,subst,(it_relev,n,ty,cl)::res,i+1
+       ) (metasenv,subst,[],1) rev_itl
      in
       uri, height, metasenv, subst, C.Inductive (ind, leftno, itl, attr)
 ;;