module 1Lab.Biimp where

BiimplicationsπŸ”—

A biimplication between a pair of types is a pair of functions

record _↔_ {β„“} {β„“'} (A : Type β„“) (B : Type β„“') : Type (β„“ βŠ” β„“') where
  no-eta-equality
  constructor biimp
  field
    to : A β†’ B
    from : B β†’ A

open _↔_

If and n-types, then the type of biimplications is also an n-type.

↔-is-hlevel : βˆ€ n β†’ is-hlevel A n β†’ is-hlevel B n β†’ is-hlevel (A ↔ B) n
↔-is-hlevel n A-hl B-hl =
  Iso→is-hlevel n eqv $
  Γ—-is-hlevel n
    (Ξ -is-hlevel n Ξ» _ β†’ B-hl)
    (Ξ -is-hlevel n Ξ» _ β†’ A-hl)

Working with biimplicationsπŸ”—

There is an identity biimplication, and biimplications compose.

id↔ : A ↔ A
id↔ .to = id
id↔ .from = id

_βˆ™β†”_ : A ↔ B β†’ B ↔ C β†’ A ↔ C
(f βˆ™β†” g) .to = g .to ∘ f .to
(f βˆ™β†” g) .from = f .from ∘ g .from

Moreover, every biimplication induces a biimplication

_↔⁻¹ : A ↔ B β†’ B ↔ A
(f ↔⁻¹) .to = f .from
(f ↔⁻¹) .from = f .to

Biimplications and equivalencesπŸ”—

Every equivalence is a biimplication.

equivβ†’biimp : A ≃ B β†’ A ↔ B
equiv→biimp f .to = Equiv.to f
equiv→biimp f .from = Equiv.from f

Every biimplication between propositions is an equivalence. In light of this, biimplications are often referred to as logical equivalences.

biimpβ†’equiv : is-prop A β†’ is-prop B β†’ A ↔ B β†’ A ≃ B
biimp→equiv A-prop B-prop f =
  prop-ext A-prop B-prop (f .to) (f .from)