X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Ftactics%2FautoTactic.ml;h=568e12ca40c4b303bd182ea3688efba78070ea0f;hb=12cc5b2b8e7f7bb0b5e315094b008a293a4df6b1;hp=d0a44c561057b3d0a0b51dad25a7c5e31f602402;hpb=1db44a3e28f767afea3b87f21aaeb81c586b1733;p=helm.git diff --git a/helm/ocaml/tactics/autoTactic.ml b/helm/ocaml/tactics/autoTactic.ml index d0a44c561..568e12ca4 100644 --- a/helm/ocaml/tactics/autoTactic.ml +++ b/helm/ocaml/tactics/autoTactic.ml @@ -54,27 +54,32 @@ let search_theorems_in_context status = let _,metasenv,_,_ = proof in let _,context,ty = CicUtil.lookup_meta goal metasenv in let rec find n = function - [] -> [] + | [] -> [] | hd::tl -> - let res = - try - let (subst,(proof, goal_list)) = - PT.apply_tac_verbose ~term:(C.Rel n) status in - (* - let goal_list = - List.stable_sort (compare_goal_list proof) goal_list in - *) - Some (subst,(proof, goal_list)) - with - PET.Fail _ -> None in - (match res with - Some res -> res::(find (n+1) tl) - | None -> find (n+1) tl) + let res = + (* we should check that the hypothesys has not been cleared *) + if List.nth context (n-1) = None then + None + else + try + let (subst,(proof, goal_list)) = + PT.apply_tac_verbose ~term:(C.Rel n) status + in + (* + let goal_list = + List.stable_sort (compare_goal_list proof) goal_list in + *) + Some (subst,(proof, goal_list)) + with + PET.Fail _ -> None + in + (match res with + | Some res -> res::(find (n+1) tl) + | None -> find (n+1) tl) in try find 1 context - with Failure s -> - [] + with Failure s -> [] ;; @@ -117,7 +122,7 @@ let is_in_metasenv goal metasenv = let (_, ey ,ty) = CicUtil.lookup_meta goal metasenv in true - with _ -> false + with CicUtil.Meta_not_found _ -> false let rec auto_single dbd proof goal ey ty depth width sign already_seen_goals universe @@ -223,21 +228,21 @@ let rec auto_single dbd proof goal ey ty depth width sign already_seen_goals end and auto_new dbd width already_seen_goals universe = function - [] -> [] + | [] -> [] | (subst,(proof, goals, sign))::tl -> let _,metasenv,_,_ = proof in let is_in_metasenv (goal, _) = - try - let (_, ey ,ty) = - CicUtil.lookup_meta goal metasenv in - true - with _ -> false in + try + let (_, ey ,ty) = CicUtil.lookup_meta goal metasenv in + true + with CicUtil.Meta_not_found _ -> false + in let goals'= List.filter is_in_metasenv goals in - auto_new_aux dbd width already_seen_goals universe - ((subst,(proof, goals', sign))::tl) + auto_new_aux dbd + width already_seen_goals universe ((subst,(proof, goals', sign))::tl) and auto_new_aux dbd width already_seen_goals universe = function - [] -> [] + | [] -> [] | (subst,(proof, [], sign))::tl -> (subst,(proof, [], sign))::tl | (subst,(proof, (goal,0)::_, _))::tl -> auto_new dbd width already_seen_goals universe tl