match NCicReduction.whd ~subst context ty with
| C.Meta (_,(0,(C.Irl 0 | C.Ctx []))) as ty ->
metasenv, subst, t, ty
- | C.Meta (i,(_,(C.Irl 0 | C.Ctx []))) ->
- metasenv, subst, t, C.Meta(i,(0,C.Irl 0))
+ | C.Meta (i,(_,(C.Irl 0 | C.Ctx []))) -> assert false (*CSC: ???
+ metasenv, subst, t, C.Meta(i,(0,C.Irl 0)) *)
| C.Meta (i,(_,lc)) ->
let len = match lc with C.Irl len->len | C.Ctx l->List.length l in
let metasenv, subst, newmeta =
let undebruijnate inductive ref t rev_fl =
NCicSubstitution.psubst (fun x -> x)
- (HExtlib.list_mapi
+ (List.rev (HExtlib.list_mapi
(fun (_,_,rno,_,_,_) i ->
NCic.Const
(if inductive then NReference.mk_fix i rno ref
else NReference.mk_cofix i ref))
- rev_fl)
+ rev_fl))
t
;;
?(localise=fun _ -> Stdpp.dummy_loc)
~look_for_coercion (uri,height,metasenv,subst,obj)
=
- let check_type metasenv subst (ty as orig_ty) = (* XXX fattorizza *)
+prerr_endline ("===============\n" ^ NCicPp.ppobj (uri,height,metasenv,subst,obj));
+ 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 ->
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,
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,_ =
let metasenv,subst,cl =
List.fold_right
(fun (k_relev,n,te) (metasenv,subst,res) ->
- let _,k_relev = HExtlib.split_nth leftno k_relev in
+ let k_relev =
+ try snd (HExtlib.split_nth leftno k_relev)
+ with Failure _ -> k_relev in
let te = NCicTypeChecker.debruijn uri len [] te in
+ let metasenv, subst, te, _ = check_type metasenv subst tys te in
let context,te = NCicReduction.split_prods ~subst tys leftno te in
let _,chopped_context_rev =
HExtlib.split_nth (List.length tys) (List.rev context) in
else
metasenv,subst,item1::context
) (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
+ with Invalid_argument "List.fold_left2" -> assert false in
+ let con_sort= NCicTypeChecker.typeof ~subst ~metasenv context te in
(match
NCicReduction.whd ~subst context con_sort,
NCicReduction.whd ~subst [] ty_sort
(lazy (localise te,
"Non positive occurence in " ^ NUri.string_of_uri uri)))
else
- metasenv,subst,(k_relev,n,te)::res
+ let relsno = List.length itl + leftno in
+ let te =
+ NCicSubstitution.psubst
+ (fun i ->
+ if i <= leftno then
+ NCic.Rel i
+ else
+ NCic.Const (NReference.reference_of_spec uri
+ (NReference.Ind (ind,relsno - i,leftno))))
+ (HExtlib.list_seq 1 (relsno+1))
+ te in
+ let te =
+ List.fold_right
+ (fun (name,decl) te ->
+ match decl with
+ NCic.Decl ty -> NCic.Prod (name,ty,te)
+ | NCic.Def (bo,ty) -> NCic.LetIn (name,ty,bo,te)
+ ) sx_context_te_rev 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)
;;