| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Core properties related to negation |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Relation.Nullary.Negation.Core where |
| 10 |
|
| 11 |
open import Data.Empty using (⊥; ⊥-elim-irr) |
| 12 |
open import Data.Sum.Base using (_⊎_; [_,_]; inj₁; inj₂) |
| 13 |
open import Function.Base using (flip; _∘_; const) |
| 14 |
open import Level using (Level; _⊔_) |
| 15 |
|
| 16 |
private |
| 17 |
variable |
| 18 |
a p q w : Level |
| 19 |
A B C : Set a |
| 20 |
Whatever : Set w |
| 21 |
|
| 22 |
------------------------------------------------------------------------ |
| 23 |
-- Negation. |
| 24 |
|
| 25 |
infix 3 ¬_ |
| 26 |
¬_ : Set a → Set a |
| 27 |
¬ A = A → ⊥ |
| 28 |
|
| 29 |
------------------------------------------------------------------------ |
| 30 |
-- Stability. |
| 31 |
|
| 32 |
-- Double-negation |
| 33 |
DoubleNegation : Set a → Set a |
| 34 |
DoubleNegation A = ¬ ¬ A |
| 35 |
|
| 36 |
-- Stability under double-negation. |
| 37 |
Stable : Set a → Set a |
| 38 |
Stable A = ¬ ¬ A → A |
| 39 |
|
| 40 |
------------------------------------------------------------------------ |
| 41 |
-- Relationship to sum |
| 42 |
|
| 43 |
infixr 1 _¬-⊎_ |
| 44 |
_¬-⊎_ : ¬ A → ¬ B → ¬ (A ⊎ B) |
| 45 |
_¬-⊎_ = [_,_] |
| 46 |
|
| 47 |
------------------------------------------------------------------------ |
| 48 |
-- Uses of negation |
| 49 |
|
| 50 |
contradiction-irr : .A → ¬ A → Whatever |
| 51 |
contradiction-irr a ¬a = ⊥-elim-irr (¬a a) |
| 52 |
|
| 53 |
contradiction : A → ¬ A → Whatever |
| 54 |
contradiction a = contradiction-irr a |
| 55 |
|
| 56 |
contradiction₂ : A ⊎ B → ¬ A → ¬ B → Whatever |
| 57 |
contradiction₂ (inj₁ a) ¬a ¬b = contradiction a ¬a |
| 58 |
contradiction₂ (inj₂ b) ¬a ¬b = contradiction b ¬b |
| 59 |
|
| 60 |
contraposition : (A → B) → ¬ B → ¬ A |
| 61 |
contraposition f ¬b a = contradiction (f a) ¬b |
| 62 |
|
| 63 |
-- Self-contradictory propositions are false by 'diagonalisation' |
| 64 |
|
| 65 |
contra-diagonal : (A → ¬ A) → ¬ A |
| 66 |
contra-diagonal self a = self a a |
| 67 |
|
| 68 |
-- Everything is stable in the double-negation monad. |
| 69 |
stable : ¬ ¬ Stable A |
| 70 |
stable ¬[¬¬a→a] = ¬[¬¬a→a] (contradiction (¬[¬¬a→a] ∘ const)) |
| 71 |
|
| 72 |
-- Negated predicates are stable. |
| 73 |
negated-stable : Stable (¬ A) |
| 74 |
negated-stable ¬¬¬a a = ¬¬¬a (contradiction a) |
| 75 |
|
| 76 |
¬¬-map : (A → B) → ¬ ¬ A → ¬ ¬ B |
| 77 |
¬¬-map f = contraposition (contraposition f) |
| 78 |
|
| 79 |
-- Note also the following use of flip: |
| 80 |
private |
| 81 |
note : (A → ¬ B) → B → ¬ A |
| 82 |
note = flip |
| 83 |
|