]> matita.cs.unibo.it Git - helm.git/commitdiff
now it doesn't try to apply a cleared hypothesis
authorEnrico Tassi <enrico.tassi@inria.fr>
Wed, 6 Jul 2005 12:08:43 +0000 (12:08 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Wed, 6 Jul 2005 12:08:43 +0000 (12:08 +0000)
helm/ocaml/tactics/autoTactic.ml

index d0a44c561057b3d0a0b51dad25a7c5e31f602402..def8047901aaf9ced990e9b66af64debeb8149bf 100644 (file)
@@ -53,28 +53,34 @@ let search_theorems_in_context status =
   let module PT = PrimitiveTactics in 
   let _,metasenv,_,_ = proof in
   let _,context,ty = CicUtil.lookup_meta goal metasenv in
+  let ctxlen = List.length context 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 (ctxlen - n) = 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 +123,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 +229,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