]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/tactics/primitiveTactics.ml
1. PrimitiveTactics.new_metasenv_for_apply changed a little bit, moved to
[helm.git] / helm / ocaml / tactics / primitiveTactics.ml
1 (* Copyright (C) 2002, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 open ProofEngineHelpers
27 open ProofEngineTypes
28
29 exception TheTypeOfTheCurrentGoalIsAMetaICannotChooseTheRightElimiantionPrinciple
30 exception NotAnInductiveTypeToEliminate
31 exception WrongUriToVariable of string
32
33 (* lambda_abstract newmeta ty *)
34 (* returns a triple [bo],[context],[ty'] where              *)
35 (* [ty] = Pi/LetIn [context].[ty'] ([context] is a vector!) *)
36 (* and [bo] = Lambda/LetIn [context].(Meta [newmeta])       *)
37 (* So, lambda_abstract is the core of the implementation of *)
38 (* the Intros tactic.                                       *)
39 (* howmany = -1 means Intros, howmany > 0 means Intros n    *)
40 let lambda_abstract ?(howmany=(-1)) metasenv context newmeta ty mk_fresh_name =
41  let module C = Cic in
42   let rec collect_context context howmany ty =
43    match howmany with
44    | 0 ->  
45         let irl =
46           CicMkImplicit.identity_relocation_list_for_metavariable context
47         in
48          context, ty, (C.Meta (newmeta,irl))
49    | _ -> 
50       match ty with 
51         C.Cast (te,_)   -> collect_context context howmany te 
52       | C.Prod (n,s,t)  ->
53          let n' = mk_fresh_name metasenv context n ~typ:s in
54           let (context',ty,bo) =
55            collect_context ((Some (n',(C.Decl s)))::context) (howmany - 1) t 
56           in
57            (context',ty,C.Lambda(n',s,bo))
58       | C.LetIn (n,s,t) ->
59          let (context',ty,bo) =
60           collect_context ((Some (n,(C.Def (s,None))))::context) (howmany - 1) t
61          in
62           (context',ty,C.LetIn(n,s,bo))
63       | _ as t ->
64         if howmany <= 0 then
65          let irl =
66           CicMkImplicit.identity_relocation_list_for_metavariable context
67          in
68           context, t, (C.Meta (newmeta,irl))
69         else
70          raise (Fail "intro(s): not enough products or let-ins")
71   in
72    collect_context context howmany ty 
73
74 let eta_expand metasenv context t arg =
75  let module T = CicTypeChecker in
76  let module S = CicSubstitution in
77  let module C = Cic in
78   let rec aux n =
79    function
80       t' when t' = S.lift n arg -> C.Rel (1 + n)
81     | C.Rel m  -> if m <= n then C.Rel m else C.Rel (m+1)
82     | C.Var (uri,exp_named_subst) ->
83        let exp_named_subst' = aux_exp_named_subst n exp_named_subst in
84         C.Var (uri,exp_named_subst')
85     | C.Meta (i,l) ->
86        let l' =
87         List.map (function None -> None | Some t -> Some (aux n t)) l
88        in
89         C.Meta (i, l')
90     | C.Sort _
91     | C.Implicit _ as t -> t
92     | C.Cast (te,ty) -> C.Cast (aux n te, aux n ty)
93     | C.Prod (nn,s,t) -> C.Prod (nn, aux n s, aux (n+1) t)
94     | C.Lambda (nn,s,t) -> C.Lambda (nn, aux n s, aux (n+1) t)
95     | C.LetIn (nn,s,t) -> C.LetIn (nn, aux n s, aux (n+1) t)
96     | C.Appl l -> C.Appl (List.map (aux n) l)
97     | C.Const (uri,exp_named_subst) ->
98        let exp_named_subst' = aux_exp_named_subst n exp_named_subst in
99         C.Const (uri,exp_named_subst')
100     | C.MutInd (uri,i,exp_named_subst) ->
101        let exp_named_subst' = aux_exp_named_subst n exp_named_subst in
102         C.MutInd (uri,i,exp_named_subst')
103     | C.MutConstruct (uri,i,j,exp_named_subst) ->
104        let exp_named_subst' = aux_exp_named_subst n exp_named_subst in
105         C.MutConstruct (uri,i,j,exp_named_subst')
106     | C.MutCase (sp,i,outt,t,pl) ->
107        C.MutCase (sp,i,aux n outt, aux n t,
108         List.map (aux n) pl)
109     | C.Fix (i,fl) ->
110        let tylen = List.length fl in
111         let substitutedfl =
112          List.map
113           (fun (name,i,ty,bo) -> (name, i, aux n ty, aux (n+tylen) bo))
114            fl
115         in
116          C.Fix (i, substitutedfl)
117     | C.CoFix (i,fl) ->
118        let tylen = List.length fl in
119         let substitutedfl =
120          List.map
121           (fun (name,ty,bo) -> (name, aux n ty, aux (n+tylen) bo))
122            fl
123         in
124          C.CoFix (i, substitutedfl)
125   and aux_exp_named_subst n =
126    List.map (function uri,t -> uri,aux n t)
127   in
128    let argty,_ = 
129     T.type_of_aux' metasenv context arg CicUniv.empty_ugraph (* TASSI: FIXME *)
130    in
131     let fresh_name =
132      FreshNamesGenerator.mk_fresh_name ~subst:[]
133       metasenv context (Cic.Name "Heta") ~typ:argty
134     in
135      (C.Appl [C.Lambda (fresh_name,argty,aux 0 t) ; arg])
136
137 (*CSC: ma serve solamente la prima delle new_uninst e l'unione delle due!!! *)
138 let classify_metas newmeta in_subst_domain subst_in metasenv =
139  List.fold_right
140   (fun (i,canonical_context,ty) (old_uninst,new_uninst) ->
141     if in_subst_domain i then
142      old_uninst,new_uninst
143     else
144      let ty' = subst_in canonical_context ty in
145       let canonical_context' =
146        List.fold_right
147         (fun entry canonical_context' ->
148           let entry' =
149            match entry with
150               Some (n,Cic.Decl s) ->
151                Some (n,Cic.Decl (subst_in canonical_context' s))
152             | Some (n,Cic.Def (s,None)) ->
153                Some (n,Cic.Def ((subst_in canonical_context' s),None))
154             | None -> None
155             | Some (_,Cic.Def (_,Some _)) -> assert false
156           in
157            entry'::canonical_context'
158         ) canonical_context []
159      in
160       if i < newmeta then
161        ((i,canonical_context',ty')::old_uninst),new_uninst
162       else
163        old_uninst,((i,canonical_context',ty')::new_uninst)
164   ) metasenv ([],[])
165
166 (* Useful only inside apply_tac *)
167 let
168  generalize_exp_named_subst_with_fresh_metas context newmeta uri exp_named_subst
169 =
170  let module C = Cic in
171   let params =
172     let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
173     CicUtil.params_of_obj o
174   in
175    let exp_named_subst_diff,new_fresh_meta,newmetasenvfragment,exp_named_subst'=
176     let next_fresh_meta = ref newmeta in
177     let newmetasenvfragment = ref [] in
178     let exp_named_subst_diff = ref [] in
179      let rec aux =
180       function
181          [],[] -> []
182        | uri::tl,[] ->
183           let ty =
184             let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
185               match o with
186                   C.Variable (_,_,ty,_,_) ->
187                     CicSubstitution.subst_vars !exp_named_subst_diff ty
188                 | _ -> raise (WrongUriToVariable (UriManager.string_of_uri uri))
189           in
190 (* CSC: patch to generate ?1 : ?2 : Type in place of ?1 : Type to simulate ?1 :< Type
191            (match ty with
192                C.Sort (C.Type _) as s -> (* TASSI: ?? *)
193                  let fresh_meta = !next_fresh_meta in
194                  let fresh_meta' = fresh_meta + 1 in
195                   next_fresh_meta := !next_fresh_meta + 2 ;
196                   let subst_item = uri,C.Meta (fresh_meta',[]) in
197                    newmetasenvfragment :=
198                     (fresh_meta,[],C.Sort (C.Type (CicUniv.fresh()))) ::
199                      (* TASSI: ?? *)
200                      (fresh_meta',[],C.Meta (fresh_meta,[])) :: !newmetasenvfragment ;
201                    exp_named_subst_diff := !exp_named_subst_diff @ [subst_item] ;
202                    subst_item::(aux (tl,[]))
203              | _ ->
204 *)
205               let irl =
206                 CicMkImplicit.identity_relocation_list_for_metavariable context
207               in
208               let subst_item = uri,C.Meta (!next_fresh_meta,irl) in
209                newmetasenvfragment :=
210                 (!next_fresh_meta,context,ty)::!newmetasenvfragment ;
211                exp_named_subst_diff := !exp_named_subst_diff @ [subst_item] ;
212                incr next_fresh_meta ;
213                subst_item::(aux (tl,[]))(*)*)
214        | uri::tl1,((uri',_) as s)::tl2 ->
215           assert (UriManager.eq uri uri') ;
216           s::(aux (tl1,tl2))
217        | [],_ -> assert false
218      in
219       let exp_named_subst' = aux (params,exp_named_subst) in
220        !exp_named_subst_diff,!next_fresh_meta,
221         List.rev !newmetasenvfragment, exp_named_subst'
222    in
223     new_fresh_meta,newmetasenvfragment,exp_named_subst',exp_named_subst_diff
224 ;;
225
226 let new_metasenv_and_unify_and_t newmeta' metasenv' context term' ty termty =
227   let (consthead,newmetasenv,arguments,_) =
228    saturate_term newmeta' metasenv' context termty in
229   let subst,newmetasenv',_ = 
230    CicUnification.fo_unif newmetasenv context consthead ty CicUniv.empty_ugraph
231   in
232   let t = 
233     if List.length arguments = 0 then term' else Cic.Appl (term'::arguments)
234   in
235   subst,newmetasenv',t
236
237 let apply_tac_verbose ~term (proof, goal) =
238   (* Assumption: The term "term" must be closed in the current context *)
239  let module T = CicTypeChecker in
240  let module R = CicReduction in
241  let module C = Cic in
242   let (_,metasenv,_,_) = proof in
243   let metano,context,ty = CicUtil.lookup_meta goal metasenv in
244   let newmeta = new_meta_of_proof ~proof in
245    let exp_named_subst_diff,newmeta',newmetasenvfragment,term' =
246     match term with
247        C.Var (uri,exp_named_subst) ->
248         let newmeta',newmetasenvfragment,exp_named_subst',exp_named_subst_diff =
249          generalize_exp_named_subst_with_fresh_metas context newmeta uri
250           exp_named_subst
251         in
252          exp_named_subst_diff,newmeta',newmetasenvfragment,
253           C.Var (uri,exp_named_subst')
254      | C.Const (uri,exp_named_subst) ->
255         let newmeta',newmetasenvfragment,exp_named_subst',exp_named_subst_diff =
256          generalize_exp_named_subst_with_fresh_metas context newmeta uri
257           exp_named_subst
258         in
259          exp_named_subst_diff,newmeta',newmetasenvfragment,
260           C.Const (uri,exp_named_subst')
261      | C.MutInd (uri,tyno,exp_named_subst) ->
262         let newmeta',newmetasenvfragment,exp_named_subst',exp_named_subst_diff =
263          generalize_exp_named_subst_with_fresh_metas context newmeta uri
264           exp_named_subst
265         in
266          exp_named_subst_diff,newmeta',newmetasenvfragment,
267           C.MutInd (uri,tyno,exp_named_subst')
268      | C.MutConstruct (uri,tyno,consno,exp_named_subst) ->
269         let newmeta',newmetasenvfragment,exp_named_subst',exp_named_subst_diff =
270          generalize_exp_named_subst_with_fresh_metas context newmeta uri
271           exp_named_subst
272         in
273          exp_named_subst_diff,newmeta',newmetasenvfragment,
274           C.MutConstruct (uri,tyno,consno,exp_named_subst')
275      | _ -> [],newmeta,[],term
276    in
277    let metasenv' = metasenv@newmetasenvfragment in
278    let termty,_ = 
279      CicTypeChecker.type_of_aux' metasenv' context term' CicUniv.empty_ugraph in
280    let termty =
281      CicSubstitution.subst_vars exp_named_subst_diff termty
282    in
283 (*CSC: this code is suspect and/or bugged: we try first without reduction
284   and then using whd. However, the saturate_term always tries with full
285   reduction without delta. *)
286    let subst,newmetasenv',t = 
287     try
288       new_metasenv_and_unify_and_t newmeta' metasenv' context term' ty
289         termty
290     with CicUnification.UnificationFailure _ ->
291       new_metasenv_and_unify_and_t newmeta' metasenv' context term' ty
292         (CicReduction.whd context termty)
293    in
294    let in_subst_domain i = List.exists (function (j,_) -> i=j) subst in
295    let apply_subst = CicMetaSubst.apply_subst subst in
296    let old_uninstantiatedmetas,new_uninstantiatedmetas =
297      (* subst_in doesn't need the context. Hence the underscore. *)
298      let subst_in _ = CicMetaSubst.apply_subst subst in
299      classify_metas newmeta in_subst_domain subst_in newmetasenv'
300    in
301    let bo' = apply_subst t in
302    let newmetasenv'' = new_uninstantiatedmetas@old_uninstantiatedmetas in
303 (*    prerr_endline ("me: " ^ CicMetaSubst.ppmetasenv newmetasenv'' subst); *)
304    let subst_in =
305      (* if we just apply the subtitution, the type is irrelevant:
306               we may use Implicit, since it will be dropped *)
307      CicMetaSubst.apply_subst ((metano,(context,bo',Cic.Implicit None))::subst)
308    in
309    let (newproof, newmetasenv''') = 
310      subst_meta_and_metasenv_in_proof proof metano subst_in newmetasenv''
311    in
312      (subst_in,
313        (newproof, 
314           List.map (function (i,_,_) -> i) new_uninstantiatedmetas))
315
316 let apply_tac ~term status = snd (apply_tac_verbose ~term status)
317
318 let apply_tac_verbose ~term status =
319   try
320     apply_tac_verbose ~term status
321       (* TODO cacciare anche altre eccezioni? *)
322   with 
323   | CicUnification.UnificationFailure _ as e -> 
324       raise (Fail (Printexc.to_string e))
325   | CicTypeChecker.TypeCheckerFailure _ as e ->
326       raise (Fail (Printexc.to_string e))
327
328   (* TODO per implementare i tatticali e' necessario che tutte le tattiche
329   sollevino _solamente_ Fail *)
330 let apply_tac ~term =
331  let apply_tac ~term status =
332   try
333     apply_tac ~term status
334       (* TODO cacciare anche altre eccezioni? *)
335   with 
336   | CicUnification.UnificationFailure _ as e ->
337       raise (Fail (Printexc.to_string e))
338   | CicTypeChecker.TypeCheckerFailure _ as e ->
339       raise (Fail (Printexc.to_string e))
340  in
341   mk_tactic (apply_tac ~term)
342
343 let intros_tac ?howmany ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) ()=
344  let intros_tac
345   ?(mk_fresh_name_callback = (FreshNamesGenerator.mk_fresh_name ~subst:[])) ()
346   (proof, goal)
347  =
348   let module C = Cic in
349   let module R = CicReduction in
350    let (_,metasenv,_,_) = proof in
351    let metano,context,ty = CicUtil.lookup_meta goal metasenv in
352     let newmeta = new_meta_of_proof ~proof in
353      let (context',ty',bo') =
354       lambda_abstract ?howmany metasenv context newmeta ty mk_fresh_name_callback
355      in
356       let (newproof, _) =
357         subst_meta_in_proof proof metano bo' [newmeta,context',ty']
358       in
359        (newproof, [newmeta])
360  in
361   mk_tactic (intros_tac ~mk_fresh_name_callback ())
362   
363 let cut_tac ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) term =
364  let cut_tac
365   ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[])
366   term (proof, goal)
367  =
368   let module C = Cic in
369    let curi,metasenv,pbo,pty = proof in
370    let metano,context,ty = CicUtil.lookup_meta goal metasenv in
371     let newmeta1 = new_meta_of_proof ~proof in
372     let newmeta2 = newmeta1 + 1 in
373     let fresh_name =
374      mk_fresh_name_callback metasenv context (Cic.Name "Hcut") ~typ:term in
375     let context_for_newmeta1 =
376      (Some (fresh_name,C.Decl term))::context in
377     let irl1 =
378      CicMkImplicit.identity_relocation_list_for_metavariable
379       context_for_newmeta1
380     in
381     let irl2 =
382       CicMkImplicit.identity_relocation_list_for_metavariable context
383     in
384      let newmeta1ty = CicSubstitution.lift 1 ty in
385      let bo' =
386       C.Appl
387        [C.Lambda (fresh_name,term,C.Meta (newmeta1,irl1)) ;
388         C.Meta (newmeta2,irl2)]
389      in
390       let (newproof, _) =
391        subst_meta_in_proof proof metano bo'
392         [newmeta2,context,term; newmeta1,context_for_newmeta1,newmeta1ty];
393       in
394        (newproof, [newmeta1 ; newmeta2])
395  in
396   mk_tactic (cut_tac ~mk_fresh_name_callback term)
397
398 let letin_tac ?(mk_fresh_name_callback=FreshNamesGenerator.mk_fresh_name ~subst:[]) term =
399  let letin_tac
400   ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[])
401   term (proof, goal)
402  =
403   let module C = Cic in
404    let curi,metasenv,pbo,pty = proof in
405    let metano,context,ty = CicUtil.lookup_meta goal metasenv in
406     let _,_ = (* TASSI: FIXME *)
407       CicTypeChecker.type_of_aux' metasenv context term CicUniv.empty_ugraph in
408      let newmeta = new_meta_of_proof ~proof in
409      let fresh_name =
410       mk_fresh_name_callback metasenv context (Cic.Name "Hletin") ~typ:term in
411      let context_for_newmeta =
412       (Some (fresh_name,C.Def (term,None)))::context in
413      let irl =
414       CicMkImplicit.identity_relocation_list_for_metavariable
415        context_for_newmeta
416      in
417       let newmetaty = CicSubstitution.lift 1 ty in
418       let bo' = C.LetIn (fresh_name,term,C.Meta (newmeta,irl)) in
419        let (newproof, _) =
420          subst_meta_in_proof
421            proof metano bo'[newmeta,context_for_newmeta,newmetaty]
422        in
423         (newproof, [newmeta])
424  in
425   mk_tactic (letin_tac ~mk_fresh_name_callback term)
426
427   (** functional part of the "exact" tactic *)
428 let exact_tac ~term =
429  let exact_tac ~term (proof, goal) =
430   (* Assumption: the term bo must be closed in the current context *)
431   let (_,metasenv,_,_) = proof in
432   let metano,context,ty = CicUtil.lookup_meta goal metasenv in
433   let module T = CicTypeChecker in
434   let module R = CicReduction in
435   let ty_term,u = T.type_of_aux' metasenv context term CicUniv.empty_ugraph in
436   let b,_ = R.are_convertible context ty_term ty u in (* TASSI: FIXME *)
437   if b then
438    begin
439     let (newproof, metasenv') =
440       subst_meta_in_proof proof metano term [] in
441     (newproof, [])
442    end
443   else
444    raise (Fail "The type of the provided term is not the one expected.")
445  in
446   mk_tactic (exact_tac ~term)
447
448 (* not really "primitive" tactics .... *)
449 let elim_tac ~term = 
450  let elim_tac ~term (proof, goal) =
451   let module T = CicTypeChecker in
452   let module U = UriManager in
453   let module R = CicReduction in
454   let module C = Cic in
455    let (curi,metasenv,proofbo,proofty) = proof in
456    let metano,context,ty = CicUtil.lookup_meta goal metasenv in
457     let termty,_ = T.type_of_aux' metasenv context term CicUniv.empty_ugraph in
458     let uri,exp_named_subst,typeno,args =
459      match termty with
460         C.MutInd (uri,typeno,exp_named_subst) -> (uri,exp_named_subst,typeno,[])
461       | C.Appl ((C.MutInd (uri,typeno,exp_named_subst))::args) ->
462           (uri,exp_named_subst,typeno,args)
463       | _ -> raise NotAnInductiveTypeToEliminate
464     in
465      let eliminator_uri =
466       let buri = U.buri_of_uri uri in
467       let name = 
468         let o,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
469        match o with
470           C.InductiveDefinition (tys,_,_,_) ->
471            let (name,_,_,_) = List.nth tys typeno in
472             name
473         | _ -> assert false
474       in
475       let ty_ty,_ = T.type_of_aux' metasenv context ty CicUniv.empty_ugraph in
476       let ext =
477        match ty_ty with
478           C.Sort C.Prop -> "_ind"
479         | C.Sort C.Set  -> "_rec"
480         | C.Sort C.CProp -> "_rec"
481         | C.Sort (C.Type _)-> "_rect" 
482         | C.Meta (_,_) -> raise TheTypeOfTheCurrentGoalIsAMetaICannotChooseTheRightElimiantionPrinciple
483         | _ -> assert false
484       in
485        U.uri_of_string (buri ^ "/" ^ name ^ ext ^ ".con")
486      in
487       let eliminator_ref = C.Const (eliminator_uri,exp_named_subst) in
488        let ety,_ = 
489          T.type_of_aux' metasenv context eliminator_ref CicUniv.empty_ugraph in
490         let rec find_args_no =
491          function
492             C.Prod (_,_,t) -> 1 + find_args_no t
493           | C.Cast (s,_) -> find_args_no s
494           | C.LetIn (_,_,t) -> 0 + find_args_no t
495           | _ -> 0
496         in
497          let args_no = find_args_no ety in
498          let term_to_refine =
499           let rec make_tl base_case =
500            function
501               0 -> [base_case]
502             | n -> (C.Implicit None)::(make_tl base_case (n - 1))
503           in
504            C.Appl (eliminator_ref :: make_tl term (args_no - 1))
505          in
506           let metasenv', term_to_refine' =
507            CicMkImplicit.expand_implicits metasenv [] context term_to_refine in
508           let refined_term,_,metasenv'',_ = 
509            CicRefine.type_of_aux' metasenv' context term_to_refine' 
510              CicUniv.empty_ugraph
511           in
512            let new_goals =
513             ProofEngineHelpers.compare_metasenvs
514              ~oldmetasenv:metasenv ~newmetasenv:metasenv''
515            in
516            let proof' = curi,metasenv'',proofbo,proofty in
517             let proof'', new_goals' =
518              apply_tactic (apply_tac ~term:refined_term) (proof',goal)
519             in
520              (* The apply_tactic can have closed some of the new_goals *)
521              let patched_new_goals =
522               let (_,metasenv''',_,_) = proof'' in
523                List.filter
524                 (function i -> List.exists (function (j,_,_) -> j=i) metasenv'''
525                 ) new_goals @ new_goals'
526              in
527               proof'', patched_new_goals
528  in
529   mk_tactic (elim_tac ~term)
530 ;;
531
532 let elim_intros_tac ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) 
533                     ?depth ?using what =
534  Tacticals.then_ ~start:(elim_tac ~term:what)
535   ~continuation:(intros_tac ~mk_fresh_name_callback ?howmany:depth ())
536 ;;
537
538 (* The simplification is performed only on the conclusion *)
539 let elim_intros_simpl_tac ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[])
540                           ?depth ?using what =
541  Tacticals.then_ ~start:(elim_tac ~term:what)
542   ~continuation:
543    (Tacticals.thens
544      ~start:(intros_tac ~mk_fresh_name_callback ?howmany:depth ())
545      ~continuations:
546        [ReductionTactics.simpl_tac
547          ~pattern:(ProofEngineTypes.conclusion_pattern None)])
548 ;;