{-# OPTIONS --without-K --safe #-}
module Relation.Nullary where
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
open import Data.Empty hiding (⊥-elim)
open import Data.Empty.Irrelevant
open import Level
infix 3 ¬_
infix 2 _because_
¬_ : ∀ {ℓ} → Set ℓ → Set ℓ
¬ P = P → ⊥
data Reflects {p} (P : Set p) : Bool → Set p where
ofʸ : ( p : P) → Reflects P true
ofⁿ : (¬p : ¬ P) → Reflects P false
record Dec {p} (P : Set p) : Set p where
constructor _because_
field
does : Bool
proof : Reflects P does
open Dec public
pattern yes p = true because ofʸ p
pattern no ¬p = false because ofⁿ ¬p
recompute : ∀ {a} {A : Set a} → Dec A → .A → A
recompute (yes x) _ = x
recompute (no ¬p) x = ⊥-elim (¬p x)
Irrelevant : ∀ {p} → Set p → Set p
Irrelevant P = ∀ (p₁ p₂ : P) → p₁ ≡ p₂