123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778-------------------------------------------------------------------------- The Agda standard library---- Core properties related to negation------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Relation.Nullary.Negation.Core where open import Data.Empty using (⊥; ⊥-elim-irr)open import Data.Sum.Base using (_⊎_; [_,_]; inj₁; inj₂)open import Function.Base using (flip; _∘_; const)open import Level private variable a p q w : Level A B C : Set a Whatever : Set w -------------------------------------------------------------------------- Negation. infix 3 ¬_¬_ : Set a → Set a¬ A = A → ⊥ -------------------------------------------------------------------------- Stability. -- Double-negationDoubleNegation : Set a → Set aDoubleNegation A = ¬ ¬ A -- Stability under double-negation.Stable : Set a → Set aStable A = ¬ ¬ A → A -------------------------------------------------------------------------- Relationship to sum infixr 1 _¬-⊎__¬-⊎_ : ¬ A → ¬ B → ¬ (A ⊎ B)_¬-⊎_ = [_,_] -------------------------------------------------------------------------- Uses of negation contradiction-irr : .A → ¬ A → Whatevercontradiction-irr a ¬a = ⊥-elim-irr (¬a a) contradiction : A → ¬ A → Whatevercontradiction a = contradiction-irr a contradiction₂ : A ⊎ B → ¬ A → ¬ B → Whatevercontradiction₂ (inj₁ a) ¬a ¬b = contradiction a ¬acontradiction₂ (inj₂ b) ¬a ¬b = contradiction b ¬b contraposition : (A → B) → ¬ B → ¬ Acontraposition f ¬b a = contradiction (f a) ¬b -- Everything is stable in the double-negation monad.stable : ¬ ¬ Stable Astable ¬[¬¬a→a] = ¬[¬¬a→a] (contradiction (¬[¬¬a→a] ∘ const)) -- Negated predicates are stable.negated-stable : Stable (¬ A)negated-stable ¬¬¬a a = ¬¬¬a (contradiction a) ¬¬-map : (A → B) → ¬ ¬ A → ¬ ¬ B¬¬-map f = contraposition (contraposition f) -- Note also the following use of flip:private note : (A → ¬ B) → B → ¬ A note = flip