X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_unification%2FcicRefine.ml;h=25af88f4feffb1b46ec477571b4848aab35fb7c1;hb=349a0e23813a7f33853e1f8fe48230276ac22934;hp=351104f56f7806917a9e4a89ea6b92ef3ed7b8d4;hpb=6602157f06b241e992add8b201d14f245b8f54e7;p=helm.git diff --git a/helm/ocaml/cic_unification/cicRefine.ml b/helm/ocaml/cic_unification/cicRefine.ml index 351104f56..25af88f4f 100644 --- a/helm/ocaml/cic_unification/cicRefine.ml +++ b/helm/ocaml/cic_unification/cicRefine.ml @@ -434,7 +434,7 @@ and type_of_aux' metasenv context t ugraph = (match outtype with | C.Meta (n,l) -> - (let candidate,ugraph5,metasenv = + (let candidate,ugraph5,metasenv,subst = let exp_name_subst, metasenv = let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri @@ -460,9 +460,13 @@ and type_of_aux' metasenv context t ugraph = function 0 -> [] | n -> (Cic.Rel n)::(mk_right_args (n - 1)) + in + let right_args_no = List.length right_args in + let lifted_left_args = + List.map (CicSubstitution.lift right_args_no) left_args in Cic.Appl (Cic.MutInd(uri,i,exp_name_subst):: - (left_args @ mk_right_args (List.length right_args))) + (lifted_left_args @ mk_right_args right_args_no)) in let fresh_name = FreshNamesGenerator.mk_fresh_name ~subst metasenv @@ -471,13 +475,16 @@ and type_of_aux' metasenv context t ugraph = match outtypeinstances with | [] -> let extended_context = - let rec add_right_args b = + let rec add_right_args = function Cic.Prod (name,ty,t) -> - Some (name,Cic.Decl ty)::(add_right_args b t) - | _ -> (Some (fresh_name,Cic.Decl ty))::b + Some (name,Cic.Decl ty)::(add_right_args t) + | _ -> [] in - add_right_args context arity_instantiated_with_left_args + (Some (fresh_name,Cic.Decl ty)):: + (List.rev + (add_right_args arity_instantiated_with_left_args))@ + context in let metasenv,new_meta = CicMkImplicit.mk_implicit metasenv subst extended_context @@ -496,19 +503,19 @@ and type_of_aux' metasenv context t ugraph = add_lambdas (Cic.Meta (new_meta,irl)) arity_instantiated_with_left_args in - (Some candidate),ugraph4,metasenv + (Some candidate),ugraph4,metasenv,subst | (constructor_args_no,_,instance,_)::tl -> try let instance' = CicSubstitution.delift constructor_args_no (CicMetaSubst.apply_subst subst instance) in - let candidate,ugraph,metasenv = + let candidate,ugraph,metasenv,subst = List.fold_left ( - fun (candidate_oty,ugraph,metasenv) + fun (candidate_oty,ugraph,metasenv,subst) (constructor_args_no,_,instance,_) -> match candidate_oty with - | None -> None,ugraph,metasenv + | None -> None,ugraph,metasenv,subst | Some ty -> try let instance' = @@ -516,6 +523,14 @@ and type_of_aux' metasenv context t ugraph = constructor_args_no (CicMetaSubst.apply_subst subst instance) in +prerr_endline ("PRIMA subst:\n" ^ CicMetaSubst.ppsubst subst ^ "\nmetasenv:\n" ^ CicMetaSubst.ppmetasenv metasenv subst); + let subst,metasenv,ugraph = + fo_unif_subst subst context metasenv + instance' ty ugraph + in +prerr_endline ("DOPO subst:\n" ^ CicMetaSubst.ppsubst subst ^ "\nmetasenv:\n" ^ CicMetaSubst.ppmetasenv metasenv subst); + candidate_oty,ugraph,metasenv,subst +(* CSC: XXX let b,ugraph1 = CicReduction.are_convertible context instance' ty ugraph @@ -524,11 +539,16 @@ and type_of_aux' metasenv context t ugraph = candidate_oty,ugraph1,metasenv else None,ugraph,metasenv - with Failure s -> None,ugraph,metasenv - ) (Some instance',ugraph4,metasenv) tl +*) + with + Failure _ + | CicUnification.UnificationFailure _ + | CicUnification.Uncertain _ -> + None,ugraph,metasenv,subst + ) (Some instance',ugraph4,metasenv,subst) tl in match candidate with - | None -> None, ugraph,metasenv + | None -> None, ugraph,metasenv,subst | Some t -> let rec add_lambdas n b = function @@ -540,19 +560,20 @@ and type_of_aux' metasenv context t ugraph = in Some (add_lambdas 0 t arity_instantiated_with_left_args), - ugraph,metasenv + ugraph,metasenv,subst with Failure s -> - None,ugraph4,metasenv + None,ugraph4,metasenv,subst in match candidate with | None -> raise (Uncertain "can't solve an higher order unification problem") | Some candidate -> - let s,m,u = + let subst,metasenv,ugraph = fo_unif_subst subst context metasenv candidate outtype ugraph5 in C.MutCase (uri, i, outtype, term', pl'), - (Cic.Appl (outtype::right_args@[term'])),s,m,u) + (Cic.Appl (outtype::right_args@[term'])), + subst,metasenv,ugraph) | _ -> (* easy case *) let _,_, subst, metasenv,ugraph5 = type_of_aux subst metasenv context