]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/tactics/tacticals.ml
A few other tactics made available to matita.
[helm.git] / helm / ocaml / tactics / tacticals.ml
index 5ea64913d0debbeacac87bcd4673a060f134c88c..3c89150adb96f80b1e1721e433eccce810c0d3e4 100644 (file)
@@ -31,11 +31,12 @@ open UriManager
 
   (** perform debugging output? *)
 let debug = false
+let debug_print = fun _ -> ()
 
   (** debugging print *)
 let warn s =
   if debug then
-    prerr_endline ("TACTICALS WARNING: " ^ s)
+    debug_print ("TACTICALS WARNING: " ^ s)
 
 
 (** TACTIC{,AL}S *)
@@ -47,7 +48,6 @@ let id_tac =
  in 
   mk_tactic tac
 
-
   (**
     naive implementation of ORELSE tactical, try a sequence of tactics in turn:
     if one fails pass to the next one and so on, eventually raises (failure "no
@@ -94,7 +94,12 @@ let thens ~start ~continuations =
        (proof',goals@new_goals')
     ) (proof,[]) new_goals continuations
   with
-   Invalid_argument _ -> raise (Fail "thens: wrong number of new goals")
+   Invalid_argument _ -> 
+(* FG: more debugging information *)
+    let debug = Printf.sprintf "thens: expected %i new goals, found %i"
+     (List.length continuations) (List.length new_goals)
+    in
+    raise (Fail debug)
  in
   mk_tactic (thens ~start ~continuations )
 
@@ -110,9 +115,11 @@ let then_ ~start ~continuation =
  in
   mk_tactic (then_ ~start ~continuation)
 
-(* Galla *)
-(* si suppone che tutte le tattiche sollevino solamente Fail? *)
-
+let rec seq ~tactics =
+  match tactics with
+  | [] -> assert false
+  | [tac] -> tac
+  | hd :: tl -> then_ ~start:hd ~continuation:(seq ~tactics:tl)
 
 (* TODO: x debug: i due tatticali seguenti non contano quante volte hanno applicato la tattica *)
 
@@ -187,6 +194,7 @@ let try_tactic ~tactic =
   mk_tactic (try_tactic ~tactic)
 ;;
 
+let fail_tac = mk_tactic (fun _ -> raise (Fail "fail tactical"))
 
 (* This tries tactics until one of them doesn't _solve_ the goal *)
 (* TODO: si puo' unificare le 2(due) chiamate ricorsive? *)
@@ -218,55 +226,3 @@ let solve_tactics ~tactics =
  in
   mk_tactic (solve_tactics ~tactics)
 ;;
-
-
-
-
-
-
-
-
-
-
-  (** tattica di prova per debuggare i tatticali *)
-(*
-let thens' ~start ~continuations status =
- let (proof,new_goals) = start status in
-  try
-   List.fold_left2
-    (fun (proof,goals) goal tactic ->
-      let (proof',new_goals') = tactic (proof,goal) in
-       (proof',goals@new_goals')
-    ) (proof,[]) new_goals continuations
-  with
-   Invalid_argument _ -> raise (Fail "thens: wrong number of new goals")
-
-let prova_tac =
- let apply_T_tac status =
-  let (proof, goal) = status in
-  let curi,metasenv,pbo,pty = proof in
-  let metano,context,gty = CicUtil.lookup_meta goal metasenv in
-   let rel =
-    let rec find n =
-     function
-        [] -> assert false
-      | (Some (Cic.Name name,_))::_ when name = "T" -> n
-      | _::tl -> find (n+1) tl
-    in
-     prerr_endline ("eseguo find");
-     find 1 context
-   in
-    prerr_endline ("eseguo apply");    
-    apply_tac ~term:(Cic.Rel rel) status
- in
-(*  do_tactic ~n:2 *)
-  repeat_tactic
-   ~tactic:
-    (then_
-      ~start:(intros_tac ~name:"pippo")
-      ~continuation:(thens' ~start:apply_T_tac ~continuations:[id_tac ; apply_tac ~term:(Cic.Rel 1)]))
-(* id_tac *)
-;;
-*)
-
-