From 3c3d2dbeda88b83b05baf307409c808e779a05b2 Mon Sep 17 00:00:00 2001 From: herbelin Date: Sat, 18 Oct 2003 19:33:08 +0000 Subject: Extension de Contradiction au cas d'hypotheses ~A et A dans le contexte git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@4673 85f007b7-540e-0410-9357-904b9bb8a0f7 --- tactics/contradiction.ml | 74 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/tactics/contradiction.ml b/tactics/contradiction.ml index 58b85297f0..ab7f0c550a 100644 --- a/tactics/contradiction.ml +++ b/tactics/contradiction.ml @@ -1,3 +1,13 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* raise Not_found + | (id,_,t)::rest when f t -> tac id gl + | _::rest -> seek rest in + seek (pf_hyps gl) + +let contradiction_context gl = + let env = pf_env gl in + let sigma = project gl in + let rec seek_neg l gl = match l with + | [] -> error "No such contradiction" + | (id,_,typ)::rest -> + let typ = whd_betadeltaiota env sigma typ in + if is_empty_type typ then + simplest_elim (mkVar id) gl + else match kind_of_term typ with + | Prod (na,t,u) when is_empty_type u -> + (try + filter_hyp (fun typ -> pf_conv_x_leq gl typ t) + (fun id' -> simplest_elim (mkApp (mkVar id,[|mkVar id'|]))) + gl + with Not_found -> seek_neg rest gl) + | _ -> seek_neg rest gl in + seek_neg (pf_hyps gl) gl + +let contradiction = tclTHEN intros contradiction_context + +let is_negation_of env sigma typ t = + match kind_of_term (whd_betadeltaiota env sigma t) with + | Prod (na,t,u) -> is_empty_type u & is_conv_leq env sigma typ t + | _ -> false + +let contradiction_term c gl = + let env = pf_env gl in + let sigma = project gl in + let typ = pf_type_of gl c in + if is_empty_type typ then + simplest_elim c gl + else + try + (match kind_of_term (whd_betadeltaiota env sigma typ) with + | Prod (na,t,u) when is_empty_type u -> + filter_hyp (fun typ -> pf_conv_x_leq gl typ t) + (fun id -> simplest_elim (mkApp (c,[|mkVar id|]))) gl + | _ -> + filter_hyp (is_negation_of env sigma typ) + (fun id -> simplest_elim (mkApp (mkVar id,[|c|]))) gl) + with Not_found -> error "Not a contradiction" -- cgit v1.2.3