X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=components%2Fcic_proof_checking%2FfreshNamesGenerator.ml;h=73b75ce18e7257e876a0d316d934fd95db15350d;hb=84d34c4d0b0a3c923a62cb686966ef66bccb54c8;hp=99c9e4d76c9d93f51e070fce5aca31487c6099af;hpb=7f2444c2670cadafddd8785b687ef312158376b0;p=helm.git diff --git a/components/cic_proof_checking/freshNamesGenerator.ml b/components/cic_proof_checking/freshNamesGenerator.ml index 99c9e4d76..73b75ce18 100755 --- a/components/cic_proof_checking/freshNamesGenerator.ml +++ b/components/cic_proof_checking/freshNamesGenerator.ml @@ -60,8 +60,10 @@ let rec guess_a_name context ty = | Cic.Implicit _ -> assert false | Cic.Cast (t1,t2) -> guess_a_name context t1 | Cic.Prod (na_,_,t) -> higher_name 1 t - | Cic.Lambda _ -> assert false - | Cic.LetIn (_,s,t) -> guess_a_name context (CicSubstitution.subst s t) +(* warning: on appl we should beta reduce before the recursive call + | Cic.Lambda _ -> assert false +*) + | Cic.LetIn (_,s,t) -> guess_a_name context (CicSubstitution.subst ~avoid_beta_redexes:true s t) | Cic.Appl [] -> assert false | Cic.Appl (he::_) -> guess_a_name context he | Cic.Const (uri,_) @@ -81,7 +83,8 @@ let mk_fresh_name ~subst metasenv context name ~typ = (try let ty,_ = CicTypeChecker.type_of_aux' ~subst metasenv context typ - CicUniv.empty_ugraph in + CicUniv.oblivion_ugraph + in (match ty with C.Sort C.Prop | C.Sort C.CProp -> "H" @@ -90,7 +93,7 @@ let mk_fresh_name ~subst metasenv context name ~typ = with CicTypeChecker.TypeCheckerFailure _ -> "H" ) | C.Name name -> - Str.global_replace (Str.regexp "[0-9]*$") "" name + Str.global_replace (Str.regexp "[0-9']*$") "" name in let already_used name = List.exists (function Some (n,_) -> n=name | _ -> false) context @@ -190,9 +193,13 @@ let rec mk_fresh_names ~subst metasenv context t = let pl' = List.map (mk_fresh_names ~subst metasenv context) pl in Cic.MutCase (sp, i, outty', t', pl') | Cic.Fix (i, fl) -> - let tys = List.map - (fun (n,_,ty,_) -> - Some (Cic.Name n,(Cic.Decl ty))) fl in + let tys,_ = + List.fold_left + (fun (types,len) (n,_,ty,_) -> + (Some (Cic.Name n,(Cic.Decl (CicSubstitution.lift len ty)))::types, + len+1) + ) ([],0) fl + in let fl' = List.map (fun (n,i,ty,bo) -> let ty' = mk_fresh_names ~subst metasenv context ty in @@ -200,9 +207,13 @@ let rec mk_fresh_names ~subst metasenv context t = (n,i,ty',bo')) fl in Cic.Fix (i, fl') | Cic.CoFix (i, fl) -> - let tys = List.map - (fun (n,_,ty) -> - Some (Cic.Name n,(Cic.Decl ty))) fl in + let tys,_ = + List.fold_left + (fun (types,len) (n,ty,_) -> + (Some (Cic.Name n,(Cic.Decl (CicSubstitution.lift len ty)))::types, + len+1) + ) ([],0) fl + in let fl' = List.map (fun (n,ty,bo) -> let ty' = mk_fresh_names ~subst metasenv context ty in