aboutsummaryrefslogtreecommitdiffhomepage
path: root/tactics/contradiction.ml
diff options
context:
space:
mode:
authorGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2016-01-21 23:28:40 +0100
committerGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2016-09-15 18:39:58 +0200
commit6eede071cb97e1e39772c2bdecb5189c4fa2adb0 (patch)
tree33187ddeb6e48a59fe2cfcc69d97d05d2bdaa7f6 /tactics/contradiction.ml
parentccbb78b17fada5d9f0f5937dc276cb0b0960f4c3 (diff)
Extending "contradiction" so that it recognizes statements such as "~x=x" or ~True.
Found 1 incompatibility in tested contribs and 3 times the same pattern of incompatibility in the standard library. In all cases, it is an improvement in the form of the script. New behavior deactivated when version is <= 8.5.
Diffstat (limited to 'tactics/contradiction.ml')
-rw-r--r--tactics/contradiction.ml17
1 files changed, 17 insertions, 0 deletions
diff --git a/tactics/contradiction.ml b/tactics/contradiction.ml
index c3796b484..445a104d6 100644
--- a/tactics/contradiction.ml
+++ b/tactics/contradiction.ml
@@ -42,6 +42,8 @@ let absurd c = absurd c
(* Contradiction *)
+let use_negated_unit_or_eq_type () = Flags.version_strictly_greater Flags.V8_5
+
(** [f] does not assume its argument to be [nf_evar]-ed. *)
let filter_hyp f tac =
let rec seek = function
@@ -67,6 +69,21 @@ let contradiction_context =
simplest_elim (mkVar id)
else match kind_of_term typ with
| Prod (na,t,u) when is_empty_type u ->
+ let is_unit_or_eq =
+ if use_negated_unit_or_eq_type () then match_with_unit_or_eq_type t
+ else None in
+ Tacticals.New.tclORELSE
+ (match is_unit_or_eq with
+ | Some _ ->
+ let hd,args = decompose_app t in
+ let (ind,_ as indu) = destInd hd in
+ let nparams = Inductiveops.inductive_nparams_env env ind in
+ let params = Util.List.firstn nparams args in
+ let p = applist ((mkConstructUi (indu,1)), params) in
+ (* Checking on the fly that it type-checks *)
+ simplest_elim (mkApp (mkVar id,[|p|]))
+ | None ->
+ Tacticals.New.tclZEROMSG (Pp.str"Not a negated unit type."))
(Proofview.tclORELSE
(Proofview.Goal.enter { enter = begin fun gl ->
let is_conv_leq = Tacmach.New.pf_apply is_conv_leq gl in