1 (* Copyright (C) 2002, HELM Team.
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.
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.
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.
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,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 open HelmLibraryObjects
28 let rec injection_tac ~term ~status:((proof, goal) as status) =
30 let module U = UriManager in
31 let module P = PrimitiveTactics in
32 let module T = Tacticals in
33 let _,metasenv,_,_ = proof in
34 let _,context,_ = CicUtil.lookup_meta goal metasenv in
35 let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
37 (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
38 when (U.eq equri Logic.eq_URI) -> (
40 (C.MutInd (turi,typeno,exp_named_subst))
41 | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) -> (
43 ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
44 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
45 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
46 (* raise (ProofEngineTypes.Fail "Injection: nothing to do") ; *) T.id_tac
47 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
48 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
49 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
50 let rec traverse_list i l1 l2 =
53 | hd1::tl1,hd2::tl2 ->
55 ~start:(injection1_tac ~i ~term)
56 ~continuation:(traverse_list (i+1) tl1 tl2)
57 | _ -> raise (ProofEngineTypes.Fail "Discriminate: i 2 termini hanno in testa lo stesso costruttore, ma applicato a un numero diverso di termini. possibile???") ; T.id_tac
58 in traverse_list 1 applist1 applist2
59 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
60 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
61 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
62 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
63 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
64 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
65 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
66 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
67 when (consno1 <> consno2) || (exp_named_subst1 <> exp_named_subst2) ->
68 (* raise (ProofEngineTypes.Fail "Injection: not a projectable equality but a discriminable one") ; *) T.id_tac
69 | _ -> (* raise (ProofEngineTypes.Fail "Injection: not a projectable equality") ; *) T.id_tac
71 | _ -> raise (ProofEngineTypes.Fail "Injection: not a projectable equality")
73 | _ -> raise (ProofEngineTypes.Fail "Injection: not an equation")
77 and injection1_tac ~term ~i ~status:((proof, goal) as status) =
78 (* precondizione: t1 e t2 hanno in testa lo stesso costruttore ma differiscono (o potrebbero differire?) nell'i-esimo parametro del costruttore *)
80 let module S = CicSubstitution in
81 let module U = UriManager in
82 let module P = PrimitiveTactics in
83 let module T = Tacticals in
84 let _,metasenv,_,_ = proof in
85 let _,context,_ = CicUtil.lookup_meta goal metasenv in
86 let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
87 match termty with (* an equality *)
88 (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
89 when (U.eq equri Logic.eq_URI) -> (
90 match tty with (* some inductive type *)
91 (C.MutInd (turi,typeno,exp_named_subst))
92 | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) ->
93 prerr_endline ("XXXX term " ^ CicPp.ppterm term) ;
94 prerr_endline ("XXXX termty " ^ CicPp.ppterm termty) ;
95 prerr_endline ("XXXX t1 " ^ CicPp.ppterm t1) ;
96 prerr_endline ("XXXX t2 " ^ CicPp.ppterm t2) ;
97 prerr_endline ("XXXX tty " ^ CicPp.ppterm tty) ;
98 let t1',t2',consno = (* sono i due sottotermini che differiscono *)
100 ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
101 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
102 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) -> (* controllo ridondante *)
103 (List.nth applist1 (i-1)),(List.nth applist2 (i-1)),consno2
104 | _ -> raise (ProofEngineTypes.Fail "Injection: qui non dovrei capitarci mai")
106 let tty' = (CicTypeChecker.type_of_aux' metasenv context t1') in
107 prerr_endline ("XXXX tty' " ^ CicPp.ppterm tty') ;
108 prerr_endline ("XXXX t1' " ^ CicPp.ppterm t1') ;
109 prerr_endline ("XXXX t2' " ^ CicPp.ppterm t2') ;
110 prerr_endline ("XXXX consno " ^ string_of_int consno) ;
112 match (CicEnvironment.get_obj turi) with
113 C.InductiveDefinition (ind_type_list,_,nr_ind_params_dx) ->
114 let _,_,_,constructor_list = (List.nth ind_type_list typeno) in
115 let i_constr_id,_ = List.nth constructor_list (consno - 1) in
117 (function (id,cty) ->
118 let reduced_cty = CicReduction.whd context cty in
121 C.Prod (_,_,target) when (k <= nr_ind_params_dx) ->
123 | C.Prod (binder,source,target) when (k > nr_ind_params_dx) ->
127 | C.Anonymous -> C.Name "y"
129 C.Lambda (binder',source,(aux target (k+1)))
131 let nr_param_constr = k - 1 - nr_ind_params_dx in
132 if (id = i_constr_id)
133 then C.Rel (nr_param_constr - i + 1)
134 else S.lift (nr_param_constr + 1) t1' (* + 1 per liftare anche il lambda agguinto esternamente al case *)
138 | _ -> raise (ProofEngineTypes.Fail "Discriminate: object is not an Inductive Definition: it's imposible")
140 prerr_endline ("XXXX cominciamo!") ;
142 ~start:(P.cut_tac (C.Appl [(C.MutInd (equri,0,[])) ; tty' ; t1' ; t2']))
145 ~start:(injection_tac ~term:(C.Rel 1))
146 ~continuation:T.id_tac (* !!! qui devo anche fare clear di term tranne al primo passaggio *)
150 (fun ~status:((proof,goal) as status) ->
151 let _,metasenv,_,_ = proof in
152 let _,context,gty = CicUtil.lookup_meta goal metasenv in
153 prerr_endline ("XXXX goal " ^ string_of_int goal) ;
154 prerr_endline ("XXXX gty " ^ CicPp.ppterm gty) ;
155 prerr_endline ("XXXX old t1' " ^ CicPp.ppterm t1') ;
156 prerr_endline ("XXXX change " ^ CicPp.ppterm (C.Appl [ C.Lambda (C.Name "x", tty, C.MutCase (turi, typeno, (C.Lambda ((C.Name "x"),(S.lift 1 tty),(S.lift 2 tty'))), (C.Rel 1), pattern)); t1])) ;
159 (C.Appl (C.MutInd (_,_,_)::arglist)) ->
161 | _ -> raise (ProofEngineTypes.Fail "Injection: goal after cut is not correct")
163 prerr_endline ("XXXX new t1' " ^ CicPp.ppterm new_t1') ;
185 ~start:(EqualityTactics.rewrite_simpl_tac ~term)
186 ~continuation:EqualityTactics.reflexivity_tac
190 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
192 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not an equality")
197 exception TwoDifferentSubtermsFound of int
199 (* term ha tipo t1=t2; funziona solo se t1 e t2 hanno in testa costruttori
202 let discriminate'_tac ~term ~status:((proof, goal) as status) =
203 let module C = Cic in
204 let module U = UriManager in
205 let module P = PrimitiveTactics in
206 let module T = Tacticals in
207 let _,metasenv,_,_ = proof in
208 let _,context,_ = CicUtil.lookup_meta goal metasenv in
209 let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
211 (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
212 when (U.eq equri Logic.eq_URI) -> (
214 (C.MutInd (turi,typeno,exp_named_subst))
215 | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) ->
217 let consno2 = (* bruuutto: uso un eccezione per terminare con successo! buuu!! :-/ *)
219 let rec traverse t1 t2 =
220 prerr_endline ("XXXX t1 " ^ CicPp.ppterm t1) ;
221 prerr_endline ("XXXX t2 " ^ CicPp.ppterm t2) ;
223 ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
224 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
225 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
227 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
228 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
229 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
230 let rec traverse_list l1 l2 =
233 | hd1::tl1,hd2::tl2 -> traverse hd1 hd2; traverse_list tl1 tl2
234 | _ -> raise (ProofEngineTypes.Fail "Discriminate: i 2 termini hanno in testa lo stesso costruttore, ma applicato a un numero diverso di termini. possibile???")
235 in traverse_list applist1 applist2
237 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
238 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
239 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
240 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
241 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
242 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
243 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
244 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
245 when (consno1 <> consno2) || (exp_named_subst1 <> exp_named_subst2) ->
246 raise (TwoDifferentSubtermsFound consno2)
247 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
249 with (TwoDifferentSubtermsFound consno2) -> consno2
251 prerr_endline ("XXXX consno2 " ^ (string_of_int consno2)) ;
253 then raise (ProofEngineTypes.Fail "Discriminate: Discriminating terms are structurally equal")
257 (* a list of "True" except for the element in position consno2 which is "False" *)
258 match (CicEnvironment.get_obj turi) with
259 C.InductiveDefinition (ind_type_list,_,nr_ind_params) ->
260 prerr_endline ("XXXX nth " ^ (string_of_int (List.length ind_type_list)) ^ " " ^ (string_of_int typeno)) ;
261 let _,_,_,constructor_list = (List.nth ind_type_list typeno) in
262 prerr_endline ("XXXX nth " ^ (string_of_int (List.length constructor_list)) ^ " " ^ (string_of_int consno2)) ;
263 let false_constr_id,_ = List.nth constructor_list (consno2 - 1) in
264 prerr_endline ("XXXX nth funzionano ") ;
266 (function (id,cty) ->
267 let red_ty = CicReduction.whd context cty in (* dubbio: e' corretto ridurre in questo context ??? *)
270 C.Prod (_,_,target) when (k <= nr_ind_params) ->
272 | C.Prod (binder,source,target) when (k > nr_ind_params) ->
273 C.Lambda (binder,source,(aux target (k+1)))
275 if (id = false_constr_id)
276 then (C.MutInd(Logic.false_URI,0,[]))
277 else (C.MutInd(Logic.true_URI,0,[]))
281 | _ -> raise (ProofEngineTypes.Fail "Discriminate: object is not an Inductive Definition: it's imposible")
284 let (proof',goals') =
285 EliminationTactics.elim_type_tac
286 ~term:(C.MutInd(Logic.false_URI,0,[]))
291 let _,metasenv',_,_ = proof' in
292 let _,context',gty' =
293 CicUtil.lookup_meta goal' metasenv'
305 (C.Lambda ((C.Name "x"),tty,(C.Sort C.Prop))),
314 prerr_endline ("XXXX rewrite<-: " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1 ; t2])));
315 prerr_endline ("XXXX rewrite<-: " ^ CicPp.ppterm (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1 ; t2])) ;
316 prerr_endline ("XXXX equri: " ^ U.string_of_uri equri) ;
317 prerr_endline ("XXXX tty : " ^ CicPp.ppterm tty) ;
318 prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1)) ;
319 prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2)) ;
320 if (CicTypeChecker.type_of_aux' metasenv' context' t1) <> tty then prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1)) ;
321 if (CicTypeChecker.type_of_aux' metasenv' context' t2) <> tty then prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2)) ;
322 if (CicTypeChecker.type_of_aux' metasenv' context' t1) <> (CicTypeChecker.type_of_aux' metasenv' context' t2)
323 then prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1)) ; prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2)) ;
324 prerr_endline ("XXXX rewrite<- " ^ CicPp.ppterm term ^ " : " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' term));
326 ~start:(EqualityTactics.rewrite_back_simpl_tac ~term)
327 ~continuation:(IntroductionTactics.constructor_tac ~n:1)
329 ~status:(proof',goal')
330 | _ -> raise (ProofEngineTypes.Fail "Discriminate: ElimType False left more (or less) than one goal")
332 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
334 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not an equality")
338 let discriminate_tac ~term ~status =
340 ~start:(* (injection_tac ~term) *) Tacticals.id_tac
341 ~continuation:(discriminate'_tac ~term) (* NOOO!!! non term ma una (qualunque) delle nuove hyp introdotte da inject *)
347 let decide_equality_tac =
348 (* il goal e' un termine della forma t1=t2\/~t1=t2; la tattica decide se l'uguaglianza
349 e' vera o no e lo risolve *)
355 let compare_tac ~term ~status:((proof, goal) as status) = Tacticals.id_tac ~status
357 (* term is in the form t1=t2; the tactic leaves two goals: in the first you have to *)
358 (* demonstrate the goal with the additional hyp that t1=t2, in the second the hyp is ~t1=t2 *)
359 let module C = Cic in
360 let module U = UriManager in
361 let module P = PrimitiveTactics in
362 let module T = Tacticals in
363 let _,metasenv,_,_ = proof in
364 let _,context,gty = CicUtil.lookup_meta goal metasenv in
365 let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
367 (C.Appl [(C.MutInd (uri, 0, [])); _; t1; t2]) when (uri = (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind")) ->
369 let term' = (* (t1=t2)\/~(t1=t2) *)
371 (C.MutInd ((U.uri_of_string "cic:/Coq/Init/Logic/or.ind"), 0, [])) ;
374 (C.MutInd ((U.uri_of_string "cic:/Coq/Init/Logic/eq.ind"), 1, [])) ;
376 C.Appl [C.Const ((U.uri_of_string "cic:/Coq/Init/Logic/not.con"), []) ; t2]
381 ~start:(P.cut_tac ~term:term')
383 T.then_ ~start:(P.intros_tac) ~continuation:(P.elim_intros_simpl_tac ~term:(C.Rel 1)) ;
386 | (C.Appl [(C.MutInd (uri, 0, [])); _; t1; t2]) when (uri = (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) ->
387 let term' = (* (t1=t2) \/ ~(t1=t2) *)
389 (C.MutInd ((U.uri_of_string "cic:/Coq/Init/Logic/or.ind"), 0, [])) ;
392 (C.MutInd ((U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind"), 1, [])) ;
394 C.Appl [C.Const ((U.uri_of_string "cic:/Coq/Init/Logic/not.con"), []) ; t2]
399 ~start:(P.cut_tac ~term:term')
401 T.then_ ~start:(P.intros_tac) ~continuation:(P.elim_intros_simpl_tac ~term:(C.Rel 1)) ;
404 | _ -> raise (ProofEngineTypes.Fail "Compare: Not an equality")
410 (* DISCRIMINTATE SENZA INJECTION
412 exception TwoDifferentSubtermsFound of (Cic.term * Cic.term * int)
414 let discriminate_tac ~term ~status:((proof, goal) as status) =
415 let module C = Cic in
416 let module U = UriManager in
417 let module P = PrimitiveTactics in
418 let module T = Tacticals in
419 let _,metasenv,_,_ = proof in
420 let _,context,_ = CicUtil.lookup_meta goal metasenv in
421 let termty = (CicTypeChecker.type_of_aux' metasenv context term) in
423 (C.Appl [(C.MutInd (equri, 0, [])) ; tty ; t1 ; t2])
424 when (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic/eq.ind"))
425 or (U.eq equri (U.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind")) -> (
427 (C.MutInd (turi,typeno,exp_named_subst))
428 | (C.Appl (C.MutInd (turi,typeno,exp_named_subst)::_)) ->
430 let (t1',t2',consno2') = (* bruuutto: uso un eccezione per terminare con successo! buuu!! :-/ *)
432 let rec traverse t1 t2 =
433 prerr_endline ("XXXX t1 " ^ CicPp.ppterm t1) ;
434 prerr_endline ("XXXX t2 " ^ CicPp.ppterm t2) ;
436 ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
437 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
438 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
440 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::applist1)),
441 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::applist2)))
442 when (uri1 = uri2) && (typeno1 = typeno2) && (consno1 = consno2) && (exp_named_subst1 = exp_named_subst2) ->
443 let rec traverse_list l1 l2 =
446 | hd1::tl1,hd2::tl2 -> traverse hd1 hd2; traverse_list tl1 tl2
447 | _ -> raise (ProofEngineTypes.Fail "Discriminate: i 2 termini hanno in testa lo stesso costruttore, ma applicato a un numero diverso di termini. possibile???")
448 in traverse_list applist1 applist2
450 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
451 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
452 | ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1)),
453 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
454 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
455 (C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2)))
456 | ((C.Appl ((C.MutConstruct (uri1,typeno1,consno1,exp_named_subst1))::_)),
457 (C.Appl ((C.MutConstruct (uri2,typeno2,consno2,exp_named_subst2))::_)))
458 when (consno1 <> consno2) || (exp_named_subst1 <> exp_named_subst2) ->
459 raise (TwoDifferentSubtermsFound (t1,t2,consno2))
460 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
462 with (TwoDifferentSubtermsFound (t1,t2,consno2)) -> (t1,t2,consno2)
464 prerr_endline ("XXXX consno2' " ^ (string_of_int consno2')) ;
466 then raise (ProofEngineTypes.Fail "Discriminate: Discriminating terms are structurally equal")
470 (* a list of "True" except for the element in position consno2' which is "False" *)
471 match (CicEnvironment.get_obj turi) with
472 C.InductiveDefinition (ind_type_list,_,nr_ind_params) ->
473 prerr_endline ("XXXX nth " ^ (string_of_int (List.length ind_type_list)) ^ " " ^ (string_of_int typeno)) ;
474 let _,_,_,constructor_list = (List.nth ind_type_list typeno) in
475 prerr_endline ("XXXX nth " ^ (string_of_int (List.length constructor_list)) ^ " " ^ (string_of_int consno2')) ;
476 let false_constr_id,_ = List.nth constructor_list (consno2' - 1) in
477 prerr_endline ("XXXX nth funzionano ") ;
479 (function (id,cty) ->
480 let red_ty = CicReduction.whd context cty in (* dubbio: e' corretto ridurre in questo context ??? *)
483 C.Prod (_,_,target) when (k <= nr_ind_params) ->
485 | C.Prod (binder,source,target) when (k > nr_ind_params) ->
486 C.Lambda (binder,source,(aux target (k+1)))
488 if (id = false_constr_id)
489 then (C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/False.ind") 0 [])
490 else (C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/True.ind") 0 [])
494 | _ -> raise (ProofEngineTypes.Fail "Discriminate: object is not an Inductive Definition: it's imposible")
497 let (proof',goals') =
498 EliminationTactics.elim_type_tac
499 ~term:(C.MutInd (U.uri_of_string "cic:/Coq/Init/Logic/False.ind") 0 [] )
504 let _,metasenv',_,_ = proof' in
505 let _,context',gty' =
506 CicUtil.lookup_meta goal' metasenv'
518 (C.Lambda ((C.Name "x"),tty,(C.Sort C.Prop))),
527 prerr_endline ("XXXX rewrite<-: " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1' ; t2'])));
528 prerr_endline ("XXXX rewrite<-: " ^ CicPp.ppterm (C.Appl [(C.MutInd (equri,0,[])) ; tty ; t1' ; t2'])) ;
529 prerr_endline ("XXXX equri: " ^ U.string_of_uri equri) ;
530 prerr_endline ("XXXX tty : " ^ CicPp.ppterm tty) ;
531 prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1')) ;
532 prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2')) ;
533 if (CicTypeChecker.type_of_aux' metasenv' context' t1') <> tty then prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1')) ;
534 if (CicTypeChecker.type_of_aux' metasenv' context' t2') <> tty then prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2')) ;
535 if (CicTypeChecker.type_of_aux' metasenv' context' t1') <> (CicTypeChecker.type_of_aux' metasenv' context' t2')
536 then prerr_endline ("XXXX tt1': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t1')) ; prerr_endline ("XXXX tt2': " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' t2')) ;
538 let termty' = ProofEngineReduction.replace_lifting ~equality:(==) ~what:t1 ~with_what:t1' ~where:termty in
539 let termty'' = ProofEngineReduction.replace_lifting ~equality:(==) ~what:t2 ~with_what:t2' ~where:termty' in
541 prerr_endline ("XXXX rewrite<- " ^ CicPp.ppterm term ^ " : " ^ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv' context' term));
543 ~start:(EqualityTactics.rewrite_back_simpl_tac ~term:term)
544 ~continuation:(IntroductionTactics.constructor_tac ~n:1)
546 ~status:(proof',goal')
547 | _ -> raise (ProofEngineTypes.Fail "Discriminate: ElimType False left more (or less) than one goal")
549 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not a discriminable equality")
551 | _ -> raise (ProofEngineTypes.Fail "Discriminate: not an equality")