]> matita.cs.unibo.it Git - helm.git/blob - components/tactics/discriminationTactics.ml
1. the default for the default equality/absurd/true/false URIs used to be
[helm.git] / components / tactics / discriminationTactics.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 (* $Id$ *)
27
28 let debug_print = fun _ -> ()
29
30 let rec injection_tac ~term =
31  let injection_tac ~term status = 
32   let (proof, goal) = status in
33   let module C = Cic in
34   let module U = UriManager in
35   let module P = PrimitiveTactics in
36   let module T = Tacticals in
37   let _,metasenv,_,_ = proof in
38   let _,context,_ = CicUtil.lookup_meta goal metasenv in
39   let termty,_ = (* TASSI: FIXME *)
40     CicTypeChecker.type_of_aux' metasenv context term CicUniv.empty_ugraph in  
41     ProofEngineTypes.apply_tactic
42       (match termty with
43           (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
44              when LibraryObjects.is_eq_URI equri -> (
45            match tty with
46               (C.MutInd (turi,typeno,exp_named_subst))
47             | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) -> (
48                    match t1,t2 with
49                       ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
50                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
51                          when (uri1 = uri2) && (typeno1 = typeno2) && 
52                               (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
53                        (* raise (ProofEngineTypes.Fail "Injection: nothing to do") ; *) T.id_tac
54                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
55                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
56                          when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
57                        let rec traverse_list i l1 l2 =
58                          match l1,l2 with
59                             [],[] -> T.id_tac
60                           | hd1::tl1,hd2::tl2 -> 
61                              T.then_ 
62                               ~start:(injection1_tac ~i ~term)
63                               ~continuation:(traverse_list (i+1) tl1 tl2)
64                           | _ -> raise (ProofEngineTypes.Fail (lazy "Discriminate: i 2 termini hanno in testa lo stesso costruttore, ma applicato a un numero diverso di termini. possibile???"))
65                        in traverse_list 1 applist1 applist2
66                     | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
67                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
68                     | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
69                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
70                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
71                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
72                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
73                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
74                          when (consno1 <> consno2) || (exp_named_subst1 <> exp_named_subst2) ->
75                        (* raise (ProofEngineTypes.Fail "Injection: not a projectable equality but a discriminable one") ; *) T.id_tac
76                     | _ -> (* raise (ProofEngineTypes.Fail "Injection: not a projectable equality") ; *) T.id_tac
77                    )
78             | _ -> raise (ProofEngineTypes.Fail (lazy "Injection: not a projectable equality"))
79            )
80         | _ -> raise (ProofEngineTypes.Fail (lazy "Injection: not an equation"))
81       ) status
82  in 
83   ProofEngineTypes.mk_tactic (injection_tac ~term)
84
85 and injection1_tac ~term ~i = 
86  let injection1_tac ~term ~i status =
87   let (proof, goal) = status in
88   (* precondizione: t1 e t2 hanno in testa lo stesso costruttore ma differiscono (o potrebbero differire?) nell'i-esimo parametro del costruttore *)
89    let module C = Cic in
90    let module S = CicSubstitution in
91    let module U = UriManager in
92    let module P = PrimitiveTactics in
93    let module T = Tacticals in
94    let _,metasenv,_,_ = proof in
95    let _,context,_ = CicUtil.lookup_meta goal metasenv in
96    let termty,_ = (* TASSI: FIXME *)
97      CicTypeChecker.type_of_aux' metasenv context term CicUniv.empty_ugraph in
98      match termty with (* an equality *)
99          (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
100              when LibraryObjects.is_eq_URI equri -> (
101            match tty with (* some inductive type *)
102               (C.MutInd (turi,typeno,exp_named_subst))
103             | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) ->
104                let t1',t2',consno = (* sono i due sottotermini che differiscono *)
105                 match t1,t2 with
106                    ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
107                     (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
108                       when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) -> (* controllo ridondante *)
109                     (List.nth applist1 (i-1)),(List.nth applist2 (i-1)),consno2
110                  | _ -> assert false
111                in
112                 let tty',_ = 
113                   CicTypeChecker.type_of_aux' metasenv context t1' 
114                     CicUniv.empty_ugraph  in
115                 let pattern =
116                       match fst(CicEnvironment.get_obj 
117                                   CicUniv.empty_ugraph turi ) with
118                          C.InductiveDefinition (ind_type_list,_,nr_ind_params_dx,_)  ->
119                           let _,_,_,constructor_list = (List.nth ind_type_list typeno) in
120                            let i_constr_id,_ = List.nth constructor_list (consno - 1) in
121                             List.map
122                              (function (id,cty) ->
123                                let reduced_cty = CicReduction.whd context cty in
124                                 let rec aux t k =
125                                  match t with
126                                     C.Prod (_,_,target) when (k <= nr_ind_params_dx) ->
127                                      aux target (k+1)
128                                   | C.Prod (binder,source,target) when (k > nr_ind_params_dx) ->
129                                     let binder' =
130                                       match binder with
131                                          C.Name b -> C.Name b
132                                        | C.Anonymous -> C.Name "y"
133                                      in
134                                       C.Lambda (binder',source,(aux target (k+1)))
135                                   | _ ->
136                                      let nr_param_constr = k - 1 - nr_ind_params_dx in
137                                       if (id = i_constr_id)
138                                        then C.Rel (nr_param_constr - i + 1)
139                                        else S.lift (nr_param_constr + 1) t1' (* + 1 per liftare anche il lambda agguinto esternamente al case *)
140                                 in aux reduced_cty 1
141                              )
142                              constructor_list
143                        | _ -> raise (ProofEngineTypes.Fail (lazy "Discriminate: object is not an Inductive Definition: it's imposible"))
144                 in
145                 ProofEngineTypes.apply_tactic   
146                  (T.thens 
147                   ~start:(P.cut_tac (C.Appl [(C.MutInd (equri,0,[])) ; tty' ; t1' ; t2']))
148                   ~continuations:[
149                     T.then_ 
150                      ~start:(injection_tac ~term:(C.Rel 1))
151                      ~continuation:T.id_tac (* !!! qui devo anche fare clear di term tranne al primo passaggio *) 
152                     ;
153                     T.then_ 
154                      ~start:(ProofEngineTypes.mk_tactic 
155                        (fun status ->    
156                          let (proof, goal) = status in
157                          let _,metasenv,_,_ = proof in
158                           let _,context,gty = CicUtil.lookup_meta goal metasenv in
159                            let new_t1' = 
160                             match gty with 
161                                (C.Appl (C.MutInd (_,_,_)::arglist)) -> 
162                                 List.nth arglist 1
163                              | _ -> raise (ProofEngineTypes.Fail (lazy "Injection: goal after cut is not correct"))
164                            in
165                             ProofEngineTypes.apply_tactic 
166                             (ReductionTactics.change_tac
167                                ~pattern:(ProofEngineTypes.conclusion_pattern
168                                 (Some new_t1'))
169                                (fun _ m u ->
170                                  C.Appl [ C.Lambda (C.Name "x", tty,
171                                   C.MutCase (turi, typeno,
172                                    (C.Lambda ((C.Name "x"),
173                                     (S.lift 1 tty),
174                                     (S.lift 2 tty'))),
175                                    (C.Rel 1), pattern
176                                   )
177                                  );
178                                  t1], m, u))
179                         status
180                        ))
181                      ~continuation:
182                        (T.then_
183                          ~start:
184                            (EqualityTactics.rewrite_simpl_tac
185                              ~direction:`LeftToRight
186                              ~pattern:(ProofEngineTypes.conclusion_pattern None)
187                              term)
188                          ~continuation:EqualityTactics.reflexivity_tac
189                        )
190                    ])     
191                   status
192             | _ -> raise (ProofEngineTypes.Fail (lazy "Discriminate: not a discriminable equality"))
193            )
194         | _ -> raise (ProofEngineTypes.Fail (lazy "Discriminate: not an equality"))
195  in
196   ProofEngineTypes.mk_tactic (injection1_tac ~term ~i)
197 ;;
198
199 exception TwoDifferentSubtermsFound of int 
200
201 (* term ha tipo t1=t2; funziona solo se t1 e t2 hanno in testa costruttori
202 diversi *)
203
204 let discriminate'_tac ~term =
205  let module C = Cic in
206  let module U = UriManager in
207  let module P = PrimitiveTactics in
208  let module T = Tacticals in
209  let true_URI =
210   match LibraryObjects.true_URI () with
211      Some uri -> uri
212    | None -> raise (ProofEngineTypes.Fail (lazy "You need to register the default \"true\" definition first. Please use the \"default\" command")) in
213  let false_URI =
214   match LibraryObjects.false_URI () with
215      Some uri -> uri
216    | None -> raise (ProofEngineTypes.Fail (lazy "You need to register the default \"false\" definition first. Please use the \"default\" command")) in
217  let fail msg = raise (ProofEngineTypes.Fail (lazy ("Discriminate: " ^ msg))) in
218  let find_discriminating_consno t1 t2 =
219    let rec aux t1 t2 =
220      match t1, t2 with
221      | C.MutConstruct _, C.MutConstruct _ when t1 = t2 -> None
222      | C.Appl ((C.MutConstruct _ as constr1) :: args1),
223        C.Appl ((C.MutConstruct _ as constr2) :: args2)
224        when constr1 = constr2 ->
225          let rec aux_list l1 l2 =
226            match l1, l2 with
227            | [], [] -> None
228            | hd1 :: tl1, hd2 :: tl2 ->
229                (match aux hd1 hd2 with
230                | None -> aux_list tl1 tl2
231                | Some _ as res -> res)
232            | _ -> (* same constructor applied to a different number of args *)
233                assert false
234          in
235          aux_list args1 args2
236      | ((C.MutConstruct (_,_,consno1,subst1)),
237        (C.MutConstruct (_,_,consno2,subst2)))
238      | ((C.MutConstruct (_,_,consno1,subst1)),
239        (C.Appl ((C.MutConstruct (_,_,consno2,subst2)) :: _)))
240      | ((C.Appl ((C.MutConstruct (_,_,consno1,subst1)) :: _)),
241        (C.MutConstruct (_,_,consno2,subst2)))
242      | ((C.Appl ((C.MutConstruct (_,_,consno1,subst1)) :: _)),
243        (C.Appl ((C.MutConstruct (_,_,consno2,subst2)) :: _)))
244        when (consno1 <> consno2) || (subst1 <> subst2) ->
245          Some consno2
246      | _ -> fail "not a discriminable equality"
247    in
248    aux t1 t2
249  in
250  let mk_pattern turi typeno consno context left_args =
251     (* a list of "True" except for the element in position consno which
252      * is "False" *)
253     match fst (CicEnvironment.get_obj CicUniv.empty_ugraph turi) with
254     | C.InductiveDefinition (ind_type_list,_,nr_ind_params,_)  ->
255         let _,_,_,constructor_list = List.nth ind_type_list typeno in 
256         let false_constr_id,_ = List.nth constructor_list (consno - 1) in
257         List.map 
258           (fun (id,cty) ->
259             (* dubbio: e' corretto ridurre in questo context ??? *)
260             let red_ty = CicReduction.whd context cty in
261             let rec aux t k =
262               match t with
263               | C.Prod (_,_,target) when (k <= nr_ind_params) ->
264                   CicSubstitution.subst (List.nth left_args (k-1))
265                     (aux target (k+1))
266               | C.Prod (binder,source,target) when (k > nr_ind_params) ->
267                   C.Lambda (binder, source, (aux target (k+1)))
268               | _ -> 
269                   if (id = false_constr_id)
270                   then (C.MutInd(false_URI,0,[]))
271                   else (C.MutInd(true_URI,0,[]))
272             in
273             (CicSubstitution.lift 1 (aux red_ty 1)))
274           constructor_list
275     | _ -> (* object is not an inductive definition *)
276         assert false
277  in
278  let discriminate'_tac ~term status = 
279   let (proof, goal) = status in
280   let _,metasenv,_,_ = proof in
281   let _,context,_ = CicUtil.lookup_meta goal metasenv in
282   let termty,_ = 
283     CicTypeChecker.type_of_aux' metasenv context term CicUniv.empty_ugraph
284   in
285   match termty with
286   | (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
287     when LibraryObjects.is_eq_URI equri ->
288       let turi,typeno,exp_named_subst,left_args = 
289         match tty with
290         | (C.MutInd (turi,typeno,exp_named_subst)) ->
291             turi,typeno,exp_named_subst,[]
292         | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::left_args)) ->
293             turi,typeno,exp_named_subst,left_args
294         | _ -> fail "not a discriminable equality"
295       in
296       let consno =
297         match find_discriminating_consno t1 t2 with
298         | Some consno -> consno
299         | None -> fail "discriminating terms are structurally equal"
300       in
301       let pattern = mk_pattern turi typeno consno context left_args in
302       let (proof',goals') = 
303         ProofEngineTypes.apply_tactic 
304           (EliminationTactics.elim_type_tac
305             (C.MutInd (false_URI, 0, [])))
306           status 
307       in
308       (match goals' with
309       | [goal'] -> 
310           let _,metasenv',_,_ = proof' in
311           let _,context',gty' = CicUtil.lookup_meta goal' metasenv' in
312           ProofEngineTypes.apply_tactic
313             (T.then_
314               ~start:
315                 (ReductionTactics.change_tac 
316                   ~pattern:(ProofEngineTypes.conclusion_pattern (Some gty'))
317                   (fun _ m u ->
318                     C.Appl [
319                       C.Lambda ( C.Name "x", tty,
320                         C.MutCase (turi, typeno,
321                           (C.Lambda ((C.Name "x"),
322                            (CicSubstitution.lift 1 tty),
323                            (C.Sort C.Prop))),
324                           (C.Rel 1), pattern));
325                       t2 ], m, u))
326               ~continuation:
327                 (T.then_
328                   ~start:
329                     (EqualityTactics.rewrite_simpl_tac
330                       ~direction:`RightToLeft
331                       ~pattern:(ProofEngineTypes.conclusion_pattern None)
332                       term)
333                   ~continuation:
334                     (IntroductionTactics.constructor_tac ~n:1)))
335             (proof',goal')
336       | [] -> fail "ElimType False left no goals"
337       | _ -> fail "ElimType False left more than one goal")
338     | _ -> fail "not an equality"
339   in
340   ProofEngineTypes.mk_tactic (discriminate'_tac ~term)
341
342 let discriminate_tac ~term = 
343  let discriminate_tac ~term status =
344   ProofEngineTypes.apply_tactic 
345   (Tacticals.then_
346     ~start:(* (injection_tac ~term) *) Tacticals.id_tac
347     ~continuation:(discriminate'_tac ~term)) (* NOOO!!! non term ma una (qualunque) delle nuove hyp introdotte da inject *)
348    status
349  in
350   ProofEngineTypes.mk_tactic (discriminate_tac ~term)
351
352 (* DISCRIMINTATE SENZA INJECTION 
353
354 exception TwoDifferentSubtermsFound of (Cic.term * Cic.term * int) 
355
356 let discriminate_tac ~term status =
357   let module C = Cic in
358   let module U = UriManager in
359   let module P = PrimitiveTactics in
360   let module T = Tacticals in
361   let (proof, goal) = status in
362    let _,metasenv,_,_ = proof in
363     let _,context,_ = CicUtil.lookup_meta goal metasenv in
364      let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
365       match termty with
366          (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2]) 
367           when (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) 
368             or (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) -> (
369            match tty with
370               (C.MutInd (turi,typeno,exp_named_subst))
371             | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) ->
372
373                 let (t1',t2',consno2') = (* bruuutto: uso un eccezione per terminare con successo! buuu!! :-/ *)
374                  try
375                   let rec traverse t1 t2 =
376 debug_print (lazy ("XXXX t1 " ^ CicPp.ppterm t1)) ;
377 debug_print (lazy ("XXXX t2 " ^ CicPp.ppterm t2)) ;
378                    match t1,t2 with
379                       ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
380                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
381                          when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
382                        t1,t2,0
383                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
384                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2))) 
385                          when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
386                        let rec traverse_list l1 l2 =
387                          match l1,l2 with
388                             [],[] -> t1,t2,0
389                           | hd1::tl1,hd2::tl2 -> traverse hd1 hd2; traverse_list tl1 tl2
390                           | _ -> raise (ProofEngineTypes.Fail "Discriminate: i 2 termini hanno in testa lo stesso costruttore, ma applicato a un numero diverso di termini. possibile???")
391                        in traverse_list applist1 applist2
392
393                     | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
394                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
395                     | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
396                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
397                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
398                        (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
399                     | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
400                        (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
401                          when (consno1 <> consno2) || (exp_named_subst1 <> exp_named_subst2) ->
402                        raise (TwoDifferentSubtermsFound (t1,t2,consno2))
403                     | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
404                   in traverse t1 t2
405                  with (TwoDifferentSubtermsFound (t1,t2,consno2)) -> (t1,t2,consno2)
406                 in
407 debug_print (lazy ("XXXX consno2' " ^ (string_of_int consno2'))) ;
408                  if consno2' = 0 
409                   then raise (ProofEngineTypes.Fail "Discriminate: Discriminating terms are structurally equal")
410                   else
411
412                    let pattern = 
413                      (* a list of "True" except for the element in position consno2' which is "False" *)
414                      match fst(CicEnvironment.get_obj turi 
415                                  CicUniv.empty_ugraph) with
416                         C.InductiveDefinition (ind_type_list,_,nr_ind_params)  ->
417 debug_print (lazy ("XXXX nth " ^ (string_of_int (List.length ind_type_list)) ^ " " ^ (string_of_int typeno))) ;
418                          let _,_,_,constructor_list = (List.nth ind_type_list typeno) in 
419 debug_print (lazy ("XXXX nth " ^ (string_of_int (List.length constructor_list)) ^ " " ^ (string_of_int consno2'))) ;
420                           let false_constr_id,_ = List.nth constructor_list (consno2' - 1) in
421 debug_print (lazy "XXXX nth funzionano ") ;
422                            List.map 
423                             (function (id,cty) ->
424                               let red_ty = CicReduction.whd context cty in (* dubbio: e' corretto ridurre in questo context ??? *)
425                                let rec aux t k =
426                                 match t with
427                                    C.Prod (_,_,target) when (k <= nr_ind_params) ->
428                                     aux target (k+1)
429                                  | C.Prod (binder,source,target) when (k > nr_ind_params) -> 
430                                     C.Lambda (binder,source,(aux target (k+1)))
431                                  | _ -> 
432                                     if (id = false_constr_id)
433                                      then (C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/False.ind") 0 [])
434                                      else (C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/True.ind") 0 [])
435                                in aux red_ty 1
436                             ) 
437                             constructor_list
438                       | _ -> raise (ProofEngineTypes.Fail "Discriminate: object is not an Inductive Definition: it's imposible")
439                    in
440
441                     let (proof',goals') = 
442                      EliminationTactics.elim_type_tac 
443                       ~term:(C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/False.ind") 0 [] ) 
444                       status 
445                     in
446                      (match goals' with
447                          [goal'] -> 
448                           let _,metasenv',_,_ = proof' in
449                            let _,context',gty' =
450                              CicUtil.lookup_meta goal' metasenv'
451                            in
452                             T.then_
453                              ~start:
454                               (P.change_tac 
455                                ~what:gty' 
456                                ~with_what:
457                                 (C.Appl [
458                                   C.Lambda (
459                                    C.Name "x", tty, 
460                                    C.MutCase (
461                                     turi, typeno,
462                                     (C.Lambda ((C.Name "x"),tty,(C.Sort C.Prop))),
463                                     (C.Rel 1), pattern
464                                    )
465                                   ); 
466                                   t2']
467                                 )
468                               )
469                              ~continuation:
470                               (
471 debug_print (lazy ("XXXX rewrite<-: " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1' ; t2']))));
472 debug_print (lazy ("XXXX rewrite<-: " ^ CicPp.ppterm (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1' ; t2']))) ;
473 debug_print (lazy ("XXXX equri: " ^ U.string_of_uri equri)) ;
474 debug_print (lazy ("XXXX tty : " ^ CicPp.ppterm tty)) ;
475 debug_print (lazy ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1'))) ;
476 debug_print (lazy ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2'))) ;
477 if (CicTypeChecker.type_of_aux' metasenv' context' t1') <> tty then debug_print (lazy ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1'))) ;
478 if (CicTypeChecker.type_of_aux' metasenv' context' t2') <> tty then debug_print (lazy ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2'))) ;
479 if (CicTypeChecker.type_of_aux' metasenv' context' t1') <> (CicTypeChecker.type_of_aux' metasenv' context' t2') 
480  then debug_print (lazy ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux'
481  metasenv' context' t1'))) ; debug_print (lazy ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2'))) ;
482
483                                let termty' = ProofEngineReduction.replace_lifting ~equality:(==) ~what:t1 ~with_what:t1' ~where:termty in
484                                 let termty'' = ProofEngineReduction.replace_lifting ~equality:(==) ~what:t2 ~with_what:t2' ~where:termty' in
485
486 debug_print (lazy ("XXXX rewrite<- " ^ CicPp.ppterm term ^ " : " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' term)));
487                                  T.then_
488                                    ~start:(EqualityTactics.rewrite_back_simpl_tac ~term:term)
489                                    ~continuation:(IntroductionTactics.constructor_tac ~n:1) 
490                               )
491                              (proof',goal')
492                        | _ -> raise (ProofEngineTypes.Fail "Discriminate: ElimType False left more (or less) than one goal")
493                      )    
494             | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
495            )
496        | _ -> raise (ProofEngineTypes.Fail "Discriminate: not an equality")
497 ;;
498
499 *)
500
501
502