Source code on Github
{-# OPTIONS --cubical-compatible --safe #-}
module Relation.Nullary.Reflects where
open import Agda.Builtin.Equality
open import Data.Bool.Base
open import Data.Empty
open import Level
open import Relation.Nullary
private
variable
p : Level
P : Set p
of : ∀ {b} → if b then P else ¬ P → Reflects P b
of {b = false} ¬p = ofⁿ ¬p
of {b = true } p = ofʸ p
invert : ∀ {b} → Reflects P b → if b then P else ¬ P
invert (ofʸ p) = p
invert (ofⁿ ¬p) = ¬p
fromEquivalence : ∀ {b} → (T b → P) → (P → T b) → Reflects P b
fromEquivalence {b = true} sound complete = ofʸ (sound _)
fromEquivalence {b = false} sound complete = ofⁿ complete
det : ∀ {b b′} → Reflects P b → Reflects P b′ → b ≡ b′
det (ofʸ p) (ofʸ p′) = refl
det (ofʸ p) (ofⁿ ¬p′) = ⊥-elim (¬p′ p)
det (ofⁿ ¬p) (ofʸ p′) = ⊥-elim (¬p p′)
det (ofⁿ ¬p) (ofⁿ ¬p′) = refl