module Data.Bool.Base where
true≠false : ¬ true ≡ false
true≠false p = subst P p tt where
  P : Bool → Type
  P false = ⊥
  P true = ⊤
not : Bool → Bool
not true = false
not false = true

and or : Bool → Bool → Bool
and false y = false
and true y = y

or false y = y
or true y = true
instance
  Discrete-Bool : Discrete Bool
  Discrete-Bool .decide false false = yes refl
  Discrete-Bool .decide false true  = no false≠true
  Discrete-Bool .decide true  false = no true≠false
  Discrete-Bool .decide true  true  = yes refl
x≠true→x≡false : (x : Bool) → x ≠ true → x ≡ false
x≠true→x≡false false p = refl
x≠true→x≡false true p = absurd (p refl)

x≠false→x≡true : (x : Bool) → x ≠ false → x ≡ true
x≠false→x≡true false p = absurd (p refl)
x≠false→x≡true true p = refl
record So (b : Bool) : Type where
  constructor oh
  field
    ⦃ is-so ⦄ : if b then ⊤ˢ else ⊥ˢ

The “not” equivalence🔗

The construction of not as an equivalence factors through showing that not is an isomorphism. In particular, not is its own inverse, so we need a proof that it’s involutive, as is proven in not-involutive. With this, we can get a proof that it’s an equivalence:

not-involutive : (x : Bool) → not (not x) ≡ x
not-involutive false i = false
not-involutive true  i = true

not-is-equiv : is-equiv not
not-is-equiv = is-involutive→is-equiv not-involutive

not≃ : Bool ≃ Bool
not≃ = not , not-is-equiv