From d6770f633286d3292ad3a700c9af89e2704901d0 Mon Sep 17 00:00:00 2001 From: Andres Erbsen Date: Thu, 4 Aug 2016 13:07:16 -0400 Subject: address code review comments --- src/Util/Decidable.v | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Util/Decidable.v') diff --git a/src/Util/Decidable.v b/src/Util/Decidable.v index e19e23ca4..7b412caf0 100644 --- a/src/Util/Decidable.v +++ b/src/Util/Decidable.v @@ -1,6 +1,7 @@ (** Typeclass for decidable propositions *) Require Import Coq.Logic.Eqdep_dec. +Require Import Crypto.Util.FixCoqMistakes. Require Import Crypto.Util.Sigma. Require Import Crypto.Util.HProp. Require Import Crypto.Util.Equality. @@ -97,6 +98,15 @@ Global Instance dec_eq_nat : DecidableRel (@eq nat) | 10. exact _. Defined. Global Instance dec_eq_N : DecidableRel (@eq N) | 10 := N.eq_dec. Global Instance dec_eq_Z : DecidableRel (@eq Z) | 10 := Z.eq_dec. +Lemma not_not P {d:Decidable P} : not (not P) <-> P. +Proof. destruct (dec P); intuition. Qed. + +Global Instance dec_ex_forall_not T (P:T->Prop) {d:Decidable (exists b, P b)} : Decidable (forall b, ~ P b). +Proof. + destruct (dec (~ exists b, P b)) as [Hd|Hd]; [left|right]; + [abstract eauto | abstract (rewrite not_not in Hd by eauto; destruct Hd; eauto) ]. +Defined. + Lemma eqsig_eq {T} {U} {Udec:DecidableRel (@eq U)} (f g:T->U) (x x':T) pf pf' : (exist (fun x => f x = g x) x pf) = (exist (fun x => f x = g x) x' pf') <-> (x = x'). Proof. apply path_sig_hprop_iff; auto using UIP_dec, Udec. Qed. -- cgit v1.2.3