]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_tactics/nTactics.ml
auto and auto_paramod are in nAuto
[helm.git] / helm / software / components / ng_tactics / nTactics.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 (* $Id: nCic.ml 9058 2008-10-13 17:42:30Z tassi $ *)
13
14 open Printf
15
16 let debug = false
17 let debug_print s = if debug then prerr_endline (Lazy.force s) else ()
18
19 open Continuationals.Stack
20 open NTacStatus
21 module Ast = CicNotationPt
22
23 let id_tac status = status ;;
24 let print_tac print_status message status = 
25   if print_status then pp_status status;
26   prerr_endline message; 
27   status
28 ;;
29
30 let dot_tac status =
31   let gstatus = 
32     match status#stack with
33     | [] -> assert false
34     | ([], _, [], _) :: _ as stack ->
35         (* backward compatibility: do-nothing-dot *)
36         stack
37     | (g, t, k, tag) :: s ->
38         match filter_open g, k with
39         | loc :: loc_tl, _ -> 
40              (([ loc ], t, loc_tl @+ k, tag) :: s) 
41         | [], loc :: k ->
42             assert (is_open loc);
43             (([ loc ], t, k, tag) :: s)
44         | _ -> fail (lazy "can't use \".\" here")
45   in
46    status#set_stack gstatus
47 ;;
48
49 let branch_tac status =
50   let gstatus = 
51     match status#stack with
52     | [] -> assert false
53     | (g, t, k, tag) :: s ->
54           match init_pos g with (* TODO *)
55           | [] | [ _ ] -> fail (lazy "too few goals to branch");
56           | loc :: loc_tl ->
57                ([ loc ], [], [], `BranchTag) :: (loc_tl, t, k, tag) :: s
58   in
59    status#set_stack gstatus
60 ;;
61
62 let shift_tac status =
63   let gstatus = 
64     match status#stack with
65     | (g, t, k, `BranchTag) :: (g', t', k', tag) :: s ->
66           (match g' with
67           | [] -> fail (lazy "no more goals to shift")
68           | loc :: loc_tl ->
69                 (([ loc ], t @+ filter_open g @+ k, [],`BranchTag)
70                 :: (loc_tl, t', k', tag) :: s))
71      | _ -> fail (lazy "can't shift goals here")
72   in
73    status#set_stack gstatus
74 ;;
75
76 let pos_tac i_s status =
77   let gstatus = 
78     match status#stack with
79     | [] -> assert false
80     | ([ loc ], t, [],`BranchTag) :: (g', t', k', tag) :: s
81       when is_fresh loc ->
82         let l_js = List.filter (fun (i, _) -> List.mem i i_s) ([loc] @+ g') in
83           ((l_js, t , [],`BranchTag)
84            :: (([ loc ] @+ g') @- l_js, t', k', tag) :: s)
85     | _ -> fail (lazy "can't use relative positioning here")
86   in
87    status#set_stack gstatus
88 ;;
89
90 let case_tac lab status =
91   let gstatus = 
92     match status#stack with
93     | [] -> assert false
94     | ([ loc ], t, [],`BranchTag) :: (g', t', k', tag) :: s
95       when is_fresh loc ->
96         let l_js =
97           List.filter 
98            (fun curloc -> 
99               let _,_,metasenv,_,_ = status#obj in
100               match NCicUtils.lookup_meta (goal_of_loc curloc) metasenv with
101                   attrs,_,_ when List.mem (`Name lab) attrs -> true
102                 | _ -> false) ([loc] @+ g') in
103           ((l_js, t , [],`BranchTag)
104            :: (([ loc ] @+ g') @- l_js, t', k', tag) :: s)
105     | _ -> fail (lazy "can't use relative positioning here")
106   in
107    status#set_stack gstatus
108 ;;
109
110 let wildcard_tac status =
111   let gstatus = 
112     match status#stack with
113     | [] -> assert false
114     | ([ loc ] , t, [], `BranchTag) :: (g', t', k', tag) :: s
115        when is_fresh loc ->
116             (([loc] @+ g', t, [], `BranchTag) :: ([], t', k', tag) :: s)
117     | _ -> fail (lazy "can't use wildcard here")
118   in
119    status#set_stack gstatus
120 ;;
121
122 let merge_tac status =
123   let gstatus = 
124     match status#stack with
125     | [] -> assert false
126     | (g, t, k,`BranchTag) :: (g', t', k', tag) :: s ->
127         ((t @+ filter_open g @+ g' @+ k, t', k', tag) :: s)
128     | _ -> fail (lazy "can't merge goals here")
129   in
130    status#set_stack gstatus
131 ;;
132       
133 let focus_tac gs status =
134   let gstatus = 
135     match status#stack with
136     | [] -> assert false
137     | s -> assert(gs <> []);
138           let stack_locs =
139             let add_l acc _ _ l = if is_open l then l :: acc else acc in
140             fold ~env:add_l ~cont:add_l ~todo:add_l [] s
141           in
142           List.iter
143             (fun g ->
144               if not (List.exists (fun l -> goal_of_loc l = g) stack_locs) then
145                 fail (lazy (sprintf "goal %d not found (or closed)" g)))
146             gs;
147           (zero_pos gs, [], [], `FocusTag) :: deep_close gs s
148   in
149    status#set_stack gstatus
150 ;;
151
152 let unfocus_tac status =
153   let gstatus = 
154     match status#stack with
155     | [] -> assert false
156     | ([], [], [], `FocusTag) :: s -> s
157     | _ -> fail (lazy "can't unfocus, some goals are still open")
158   in
159    status#set_stack gstatus
160 ;;
161
162 let skip_tac status =
163   let gstatus = 
164     match status#stack with
165     | [] -> assert false
166     | (gl, t, k, tag) :: s -> 
167         let gl = List.map switch_of_loc gl in
168         if List.exists (function Open _ -> true | Closed _ -> false) gl then 
169           fail (lazy "cannot skip an open goal")
170         else 
171           ([],t,k,tag) :: s
172   in
173    status#set_stack gstatus
174 ;;
175
176 let block_tac l status =
177   List.fold_left (fun status tac -> tac status) status l
178 ;;
179
180
181 let compare_statuses ~past ~present =
182  let _,_,past,_,_ = past#obj in 
183  let _,_,present,_,_ = present#obj in 
184  List.map fst (List.filter (fun (i,_) -> not(List.mem_assoc i past)) present),
185  List.map fst (List.filter (fun (i,_) -> not (List.mem_assoc i present)) past)
186 ;;
187
188
189
190 (* Exec and distribute_tac form a retraction pair:
191     1) exec (distribute_tac low_tac) (s,i) = low_tac (s,i)
192     2) tac [s]::G = G1::...::Gn::G' && G' is G with some goals closed =>
193          distribute_tac (exec tac) [s]::G = (G1@...Gn)::G'
194     3) tac G = distribute_tac (exec tac) G if  
195        tac = distribute_tac lowtac
196     4) atomic_tac t === distribute_tac (exec t)
197
198    Note that executing an high tactic on a set of goals may be stronger
199    than executing the same tactic on those goals, but once at a time
200    (e.g. the tactic could perform a global analysis of the set of goals)
201 *)
202
203 let exec tac (low_status : #lowtac_status) g =
204   let stack = [ [0,Open g], [], [], `NoTag ] in
205   let status =
206    (new NTacStatus.status low_status#obj stack)#set_estatus low_status
207   in
208   let status = tac status in
209    (low_status#set_estatus status)#set_obj status#obj
210 ;;
211
212 let distribute_tac tac (status : #tac_status) =
213   match status#stack with
214   | [] -> assert false
215   | (g, t, k, tag) :: s ->
216       debug_print (lazy ("context length " ^string_of_int (List.length g)));
217       let rec aux s go gc =
218         function
219         | [] -> 
220             debug_print (lazy "no selected goals");
221             s, go, gc
222         | loc :: loc_tl ->
223             debug_print (lazy "inner eval tactical");
224             let s, go, gc =
225               if List.exists ((=) (goal_of_loc loc)) gc then
226                 s, go, gc
227               else
228                 match switch_of_loc loc with
229                 | Closed _ -> fail (lazy "cannot apply to a Closed goal")
230                 | Open n -> 
231                    let sn = tac s n in
232                    let go', gc' = compare_statuses ~past:s ~present:sn in
233                    sn, ((go @+ [n]) @- gc') @+ go', gc @+ gc'
234             in
235             aux s go gc loc_tl
236       in
237       let s0 = (new NTacStatus.status status#obj ())#set_estatus status in
238       let s0, go0, gc0 = s0, [], [] in
239       let sn, gon, gcn = aux s0 go0 gc0 g in
240       debug_print (lazy ("opened: "
241         ^ String.concat " " (List.map string_of_int gon)));
242       debug_print (lazy ("closed: "
243         ^ String.concat " " (List.map string_of_int gcn)));
244       let stack =
245         (zero_pos gon, t @~- gcn, k @~- gcn, tag) :: deep_close gcn s
246       in
247        ((status#set_stack stack)#set_obj(sn:>lowtac_status)#obj)#set_estatus sn
248 ;;
249
250 let atomic_tac htac : #tac_status as 'a -> 'a = distribute_tac (exec htac) ;;
251
252 let repeat_tac t s = 
253   let rec repeat t (status : #tac_status as 'a) : 'a = 
254     try repeat t (t status)
255     with NTacStatus.Error _ -> status
256   in
257     atomic_tac (repeat t) s
258 ;;
259
260
261 let try_tac tac status =
262   try
263     tac status
264   with NTacStatus.Error _ ->
265     status
266 ;;
267
268 let first_tac tacl status =
269   let res = 
270    HExtlib.list_findopt
271     (fun tac _ -> try Some (tac status) with NTacStatus.Error _ -> None) tacl
272   in
273     match res with
274       | None -> fail (lazy "No tactics left")
275       | Some x -> x
276 ;;
277
278 let exact_tac t : 's tactic = distribute_tac (fun status goal ->
279  let goalty = get_goalty status goal in
280  let status, t = disambiguate status t (Some goalty) (ctx_of goalty) in
281  instantiate status goal t)
282 ;;
283
284 let assumption_tac status = distribute_tac (fun status goal ->
285   let gty = get_goalty status goal in
286   let context = ctx_of gty in
287   let htac = 
288    first_tac
289     (List.map (fun (name,_) -> exact_tac ("",0,(Ast.Ident (name,None))))
290       context)
291   in
292     exec htac status goal) status
293 ;;
294
295 let find_in_context name context =
296   let rec aux acc = function
297     | [] -> raise Not_found
298     | (hd,_) :: tl when hd = name -> acc
299     | _ :: tl ->  aux (acc + 1) tl
300   in
301   aux 1 context
302 ;;
303
304 let clear_tac names =
305  if names = [] then id_tac
306  else
307   distribute_tac (fun status goal ->
308    let goalty = get_goalty status goal in
309    let js =
310      List.map 
311      (fun name -> 
312         try find_in_context name (ctx_of goalty)
313         with Not_found -> 
314           fail (lazy ("hypothesis '" ^ name ^ "' not found"))) 
315      names
316    in
317    let n,h,metasenv,subst,o = status#obj in
318    let metasenv,subst,_ = NCicMetaSubst.restrict metasenv subst goal js in
319     status#set_obj (n,h,metasenv,subst,o))
320 ;;
321
322 let generalize0_tac args =
323  if args = [] then id_tac
324  else exact_tac ("",0,Ast.Appl (Ast.Implicit `JustOne :: args))
325 ;;
326
327 let select0_tac ~where:(wanted,hyps,where) ~job  =
328  let found, postprocess = 
329    match job with
330    | `Substexpand argsno -> mk_in_scope, mk_out_scope argsno
331    | `Collect l -> (fun s t -> l := t::!l; mk_in_scope s t), mk_out_scope 1
332    | `ChangeWith f -> f,(fun s t -> s, t)
333  in
334  distribute_tac (fun status goal ->
335    let goalty = get_goalty status goal in
336    let path = 
337      match where with None -> NCic.Implicit `Term | Some where -> where 
338    in
339    let status, newgoalctx =
340       List.fold_right
341        (fun (name,d as entry) (status,ctx) ->
342          try
343           let path = List.assoc name hyps in
344            match d with
345               NCic.Decl ty ->
346                let status,ty =
347                 select_term status ~found ~postprocess (mk_cic_term ctx ty)
348                  (wanted,path) in
349                let status,ty = term_of_cic_term status ty ctx in
350                 status,(name,NCic.Decl ty)::ctx
351             | NCic.Def (bo,ty) ->
352                let status,bo =
353                 select_term status ~found ~postprocess (mk_cic_term ctx bo)
354                  (wanted,path) in
355                let status,bo = term_of_cic_term status bo ctx in
356                 status,(name,NCic.Def (bo,ty))::ctx
357          with
358           Not_found -> status, entry::ctx
359        ) (ctx_of goalty) (status,[])
360    in
361    let status, newgoalty = 
362      select_term status ~found ~postprocess goalty (wanted,path) in
363    (* WARNING: the next two lines simply change the context of newgoalty
364       from the old to the new one. Otherwise mk_meta will do that herself,
365       calling relocate that calls delift. However, newgoalty is now
366       ?[out_scope] and thus the delift would trigger the special unification
367       case, which is wrong now :-( *)
368    let status,newgoalty = term_of_cic_term status newgoalty (ctx_of goalty) in
369    let newgoalty = mk_cic_term newgoalctx newgoalty in
370
371    let status, instance = 
372      mk_meta status newgoalctx (`Decl newgoalty) 
373    in
374    instantiate status goal instance)
375 ;;
376
377 let select_tac ~where ~job move_down_hyps = 
378  let (wanted,hyps,where) = GrafiteDisambiguate.disambiguate_npattern where in
379  let path = 
380   match where with None -> NCic.Implicit `Term | Some where -> where in
381  if not move_down_hyps then
382   select0_tac ~where:(wanted,hyps,Some path) ~job
383  else
384   let path = 
385    List.fold_left
386      (fun path (name,path_name) -> NCic.Prod ("_",path_name,path))
387      path (List.rev hyps)
388   in
389    block_tac [ 
390      generalize0_tac (List.map (fun (name,_) -> Ast.Ident (name,None)) hyps);
391      select0_tac ~where:(wanted,[],Some path) ~job;
392      clear_tac (List.map fst hyps) ]
393 ;;
394
395 let generalize_tac ~where = 
396  let l = ref [] in
397  block_tac [ 
398    select_tac ~where ~job:(`Collect l) true; 
399    print_tac true "ha selezionato?";
400    (fun s -> distribute_tac (fun status goal ->
401       let goalty = get_goalty status goal in
402       let status,canon,rest =
403        match !l with
404           [] ->
405            (match where with
406                _,_,(None,_,_)  -> fail (lazy "No term to generalize")
407              | txt,txtlen,(Some what,_,_) ->
408                 let status, what =
409                  disambiguate status (txt,txtlen,what) None (ctx_of goalty)
410                 in
411                  status,what,[]
412            )
413         | he::tl -> status,he,tl in
414       let status = 
415        List.fold_left 
416          (fun s t -> unify s (ctx_of goalty) canon t) status rest in
417       let status, canon = term_of_cic_term status canon (ctx_of goalty) in
418       instantiate status goal 
419        (mk_cic_term (ctx_of goalty) (NCic.Appl [NCic.Implicit `Term ; canon ]))
420    ) s) ]
421 ;;
422
423 let cut_tac t = 
424  block_tac [ 
425   exact_tac ("",0, Ast.Appl [Ast.Implicit `JustOne; Ast.Implicit `JustOne]);
426   branch_tac;
427    pos_tac [2]; exact_tac t;
428    shift_tac; pos_tac [1]; skip_tac;
429   merge_tac ]
430 ;;
431
432 let lapply_tac (s,n,t) = 
433  exact_tac (s,n, Ast.Appl [Ast.Implicit `JustOne; t])
434 ;;
435
436 let reduce_tac ~reduction ~where =
437   let change status t = 
438     match reduction with
439     | `Normalize perform_delta ->
440         normalize status
441          ?delta:(if perform_delta then None else Some max_int) (ctx_of t) t
442     | `Whd perform_delta -> 
443         whd status
444          ?delta:(if perform_delta then None else Some max_int) (ctx_of t) t
445   in
446   let where = GrafiteDisambiguate.disambiguate_npattern where in
447   select0_tac ~where ~job:(`ChangeWith change)
448 ;;
449
450 let change_tac ~where ~with_what =
451   let change status t = 
452     let status, ww = disambiguate status with_what  None (ctx_of t) in
453     let status = unify status (ctx_of t) t ww in
454     status, ww
455   in
456   let where = GrafiteDisambiguate.disambiguate_npattern where in
457   select0_tac ~where ~job:(`ChangeWith change)
458 ;;
459
460 let letin_tac ~where ~what:(_,_,w) name =
461  block_tac [
462   select_tac ~where ~job:(`Substexpand 1) true;
463   exact_tac
464    ("",0,Ast.LetIn((Ast.Ident (name,None),None),w,Ast.Implicit `JustOne));
465  ]
466 ;;
467
468 let apply_tac (s,n,t) = 
469   let t = Ast.Appl [t; Ast.Implicit `Vector] in
470   exact_tac (s,n,t)
471 ;;
472
473 type indtyinfo = {
474         rightno: int;
475         leftno: int;
476         consno: int;
477         lefts: NCic.term list;
478         rights: NCic.term list;
479         reference: NReference.reference;
480  }
481 ;;
482
483 let analyze_indty_tac ~what indtyref =
484  distribute_tac (fun status goal ->
485   let goalty = get_goalty status goal in
486   let status, what = disambiguate status what None (ctx_of goalty) in
487   let status, ty_what = typeof status (ctx_of what) what in 
488   let status, (r,consno,lefts,rights) = analyse_indty status ty_what in
489   let leftno = List.length lefts in
490   let rightno = List.length rights in
491   indtyref := Some { 
492     rightno = rightno; leftno = leftno; consno = consno;
493     lefts = lefts; rights = rights; reference = r;
494   };
495   exec id_tac status goal)
496 ;;
497
498 let sort_of_goal_tac sortref = distribute_tac (fun status goal ->
499   let goalty = get_goalty status goal in
500   let status,sort = typeof status (ctx_of goalty) goalty in
501   let sort = fix_sorts sort in
502   let status, sort = term_of_cic_term status sort (ctx_of goalty) in
503    sortref := sort;
504    status)
505 ;;
506
507 let elim_tac ~what:(txt,len,what) ~where = 
508   let what = txt, len, Ast.Appl [what; Ast.Implicit `Vector] in
509   let indtyinfo = ref None in
510   let sort = ref (NCic.Rel 1) in
511   atomic_tac (block_tac [
512     analyze_indty_tac ~what indtyinfo;    
513     (fun s -> select_tac 
514       ~where ~job:(`Substexpand ((HExtlib.unopt !indtyinfo).rightno+1)) true s);
515     sort_of_goal_tac sort;
516     (fun status ->
517      let ity = HExtlib.unopt !indtyinfo in
518      let NReference.Ref (uri, _) = ity.reference in
519      let name = 
520        NUri.name_of_uri uri ^ "_" ^
521         snd (NCicElim.ast_of_sort 
522           (match !sort with NCic.Sort x -> x | _ -> assert false))
523      in
524      let eliminator = 
525        let _,_,w = what in
526        Ast.Appl [ Ast.Ident (name,None) ; Ast.Implicit `Vector ; w ]
527      in
528      exact_tac ("",0,eliminator) status) ]) 
529 ;;
530
531 let rewrite_tac ~dir ~what:(_,_,what) ~where status =
532  let sortref = ref (NCic.Rel 1) in
533  let status = sort_of_goal_tac sortref status in
534  let suffix = "_" ^ snd (NCicElim.ast_of_sort 
535    (match !sortref with NCic.Sort x -> x | _ -> assert false))
536  in
537  let name =
538   match dir with
539      `LeftToRight -> "eq" ^ suffix ^ "_r"
540    | `RightToLeft -> "eq" ^ suffix
541  in
542   block_tac
543    [ select_tac ~where ~job:(`Substexpand 1) true;
544      exact_tac
545       ("",0,
546        Ast.Appl(Ast.Ident(name,None)::HExtlib.mk_list (Ast.Implicit `JustOne) 5@
547         [what]))] status
548 ;;
549
550 let intro_tac name =
551  block_tac
552   [ exact_tac
553      ("",0,(Ast.Binder (`Lambda,
554       (Ast.Ident (name,None),None),Ast.Implicit `JustOne)));
555     if name = "_" then clear_tac [name] else id_tac ]
556 ;;
557
558 let cases ~what status goal =
559  let gty = get_goalty status goal in
560  let status, what = disambiguate status what None (ctx_of gty) in
561  let status, ty = typeof status (ctx_of what) what in
562  let status, (ref, consno, _, _) = analyse_indty status ty in
563  let status, what = term_of_cic_term status what (ctx_of gty) in
564  let t =
565   NCic.Match (ref,NCic.Implicit `Term, what,
566     HExtlib.mk_list (NCic.Implicit `Term) consno)
567  in
568  let ctx = ctx_of gty in
569  let status,t,ty = refine status ctx (mk_cic_term ctx t) (Some gty) in
570  instantiate status goal t
571 ;;
572
573 let cases_tac ~what:(txt,len,what) ~where = 
574   let what = txt, len, Ast.Appl [what; Ast.Implicit `Vector] in
575   let indtyinfo = ref None in
576   atomic_tac 
577    (block_tac [
578       analyze_indty_tac ~what indtyinfo;
579       (fun s -> select_tac 
580        ~where ~job:(`Substexpand ((HExtlib.unopt !indtyinfo).rightno+1))true s);
581       distribute_tac (cases ~what) ])
582 ;;
583
584 let case1_tac name =
585  let name = if name = "_" then "_clearme" else name in
586  block_tac [ intro_tac name; 
587              cases_tac 
588               ~where:("",0,(None,[],None)) 
589               ~what:("",0,Ast.Ident (name,None));
590              if name = "_clearme" then clear_tac ["_clearme"] else id_tac ]
591 ;;
592
593 let constructor ?(num=1) ~args status goal = 
594   if num < 1 then fail (lazy "constructor numbers begin with 1");
595   let gty = get_goalty status goal in
596   let status, (r,_,_,_) = analyse_indty status gty in
597   let ref = NReference.mk_constructor num r in
598   let t = 
599     if args = [] then Ast.NRef ref else
600     Ast.Appl (HExtlib.list_concat ~sep:[Ast.Implicit `Vector]
601       ([Ast.NRef ref] :: List.map (fun _,_,x -> [x]) args))
602   in
603   exec (apply_tac ("",0,t)) status goal
604 ;;
605
606 let constructor_tac ?num ~args = distribute_tac (constructor ?num ~args);;
607
608 let assert0_tac (hyps,concl) = distribute_tac (fun status goal ->
609  let gty = get_goalty status goal in
610  let eq status ctx t1 t2 =
611   let status,t1 = disambiguate status t1 None ctx in
612   let status,t1 = apply_subst status ctx t1 in
613   let status,t1 = term_of_cic_term status t1 ctx in
614   let t2 = mk_cic_term ctx t2 in
615   let status,t2 = apply_subst status ctx t2 in
616   let status,t2 = term_of_cic_term status t2 ctx in
617   prerr_endline ("COMPARING: " ^ NCicPp.ppterm ~subst:[] ~metasenv:[] ~context:ctx t1 ^ " vs " ^ NCicPp.ppterm ~subst:[] ~metasenv:[] ~context:ctx t2);
618   assert (t1=t2);
619   status
620  in
621  let status,gty' = term_of_cic_term status gty (ctx_of gty) in
622  let status = eq status (ctx_of gty) concl gty' in
623  let status,_ =
624   List.fold_right2
625    (fun (id1,e1) ((id2,e2) as item) (status,ctx) ->
626      assert (id1=id2 || (prerr_endline (id1 ^ " vs " ^ id2); false));
627      match e1,e2 with
628         `Decl t1, NCic.Decl t2 ->
629           let status = eq status ctx t1 t2 in
630           status,item::ctx
631       | `Def (b1,t1), NCic.Def (b2,t2) ->
632           let status = eq status ctx t1 t2 in
633           let status = eq status ctx b1 b2 in
634           status,item::ctx
635       | _ -> assert false
636    ) hyps (ctx_of gty) (status,[])
637  in
638   exec id_tac status goal)
639 ;;
640
641 let assert_tac seqs status =
642  match status#stack with
643   | [] -> assert false
644   | (g,_,_,_) :: s ->
645      assert (List.length g = List.length seqs);
646      (match seqs with
647          [] -> id_tac
648        | [seq] -> assert0_tac seq
649        | _ ->
650          block_tac
651           (branch_tac::
652           HExtlib.list_concat ~sep:[shift_tac]
653             (List.map (fun seq -> [assert0_tac seq]) seqs)@
654           [merge_tac])
655      ) status
656 ;;
657