Skip to content

[ add ] eta law for ¬¬ monad #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ Additions to existing modules
≟-≢ : (m≢n : m ≢ n) → (m ≟ n) ≡ no m≢n
∸-suc : m ≤ n → suc n ∸ m ≡ suc (n ∸ m)
```

* In `Relation.Nullary.Negation.Core`
```agda
¬¬-η : A → ¬ ¬ A
```
6 changes: 3 additions & 3 deletions src/Data/List/Relation/Unary/First/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Data.Sum.Base as Sum
open import Function.Base using (_∘′_; _∘_; id)
open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_; refl; _≗_)
open import Relation.Nullary.Decidable.Core as Dec
open import Relation.Nullary.Negation.Core using (contradiction)
open import Relation.Nullary.Negation.Core using (¬¬-η; contradiction)
open import Relation.Nullary.Reflects using (invert)
open import Relation.Unary using (Pred; _⊆_; ∁; Irrelevant; Decidable)

Expand Down Expand Up @@ -54,7 +54,7 @@ module _ {a p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where
module _ {a p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where

All⇒¬First : P ⊆ ∁ Q → All P ⊆ ∁ (First P Q)
All⇒¬First p⇒¬q (px ∷ pxs) [ qx ] = contradiction qx (p⇒¬q px)
All⇒¬First p⇒¬q (px ∷ pxs) [ qx ] = p⇒¬q px qx
All⇒¬First p⇒¬q (_ ∷ pxs) (_ ∷ hf) = All⇒¬First p⇒¬q pxs hf

First⇒¬All : Q ⊆ ∁ P → First P Q ⊆ ∁ (All P)
Expand Down Expand Up @@ -97,7 +97,7 @@ module _ {a p} {A : Set a} {P : Pred A p} where

first? : Decidable P → Decidable (First P (∁ P))
first? P? = Dec.fromSum
∘ Sum.map₂ (All⇒¬First contradiction)
∘ Sum.map₂ (All⇒¬First ¬¬-η)
∘ first (Dec.toSum ∘ P?)

cofirst? : Decidable P → Decidable (First (∁ P) P)
Expand Down
4 changes: 2 additions & 2 deletions src/Relation/Nullary/Decidable/Core.agda
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ open import Relation.Nullary.Recomputable.Core as Recomputable
open import Relation.Nullary.Reflects as Reflects
hiding (recompute; recompute-constant)
open import Relation.Nullary.Negation.Core
using (¬_; Stable; negated-stable; contradiction; DoubleNegation)
using (¬_; ¬¬-η; Stable; negated-stable; contradiction; DoubleNegation)


private
Expand Down Expand Up @@ -215,7 +215,7 @@ decidable-stable (true because [a]) ¬¬a = invert [a]
decidable-stable (false because [¬a]) ¬¬a = contradiction (invert [¬a]) ¬¬a

¬-drop-Dec : Dec (¬ ¬ A) → Dec (¬ A)
¬-drop-Dec ¬¬a? = map′ negated-stable contradiction (¬? ¬¬a?)
¬-drop-Dec ¬¬a? = map′ negated-stable ¬¬-η (¬? ¬¬a?)

-- A double-negation-translated variant of excluded middle (or: every
-- nullary relation is decidable in the double-negation monad).
Expand Down
2 changes: 1 addition & 1 deletion src/Relation/Nullary/Negation.agda
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ open import Relation.Nullary.Negation.Core public
¬¬-Monad : RawMonad {a} DoubleNegation
¬¬-Monad = mkRawMonad
DoubleNegation
contradiction
¬¬-η
(λ x f → negated-stable (¬¬-map f x))

¬¬-push : DoubleNegation Π[ P ] → Π[ DoubleNegation ∘ P ]
Expand Down
7 changes: 6 additions & 1 deletion src/Relation/Nullary/Negation/Core.agda
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open import Level using (Level; _⊔_)

private
variable
a p q w : Level
a w : Level
A B C : Set a
Whatever : Set w

Expand All @@ -33,6 +33,11 @@ infix 3 ¬_
DoubleNegation : Set a → Set a
DoubleNegation A = ¬ ¬ A

-- Eta law for double-negation

¬¬-η : A → ¬ ¬ A
¬¬-η a ¬a = ¬a a

-- Stability under double-negation.
Stable : Set a → Set a
Stable A = ¬ ¬ A → A
Expand Down