module Order.Heyting where

Heyting algebrasπŸ”—

A Heyting algebra is a lattice which is equipped to handle implication: it has a binary operation for which we have an equivalence between and Reading this from the perspective of logic, we may interpret the parameter as a context, so that our equivalence says we have inference rules

When we enrich our poset of propositions to a category of contexts, the notion of Heyting algebra is generalised to that of Cartesian closed category (with finite coproducts).

record is-heyting-algebra {o β„“} (P : Poset o β„“) : Type (o βŠ” β„“) where
  open Poset P

  field
    has-top    : Top P
    has-bottom : Bottom P

    _βˆͺ_      : Ob β†’ Ob β†’ Ob
    βˆͺ-joins  : βˆ€ x y β†’ is-join P x y (x βˆͺ y)

    _∩_      : Ob β†’ Ob β†’ Ob
    ∩-meets  : βˆ€ x y β†’ is-meet P x y (x ∩ y)

    _⇨_  : ⌞ P ⌟ β†’ ⌞ P ⌟ β†’ ⌞ P ⌟
    Ζ›    : βˆ€ {x y z} β†’ x ∩ y ≀ z β†’ x ≀ y ⇨ z
    ev   : βˆ€ {x y z} β†’ x ≀ y ⇨ z β†’ x ∩ y ≀ z

Elementary propertiesπŸ”—

The first thing we note about Heyting algebras is that they are distributive lattices. This is because, for an arbitrary we can reduce the problem of showing

by adjointness, to showing

where the universal property of the join is actually applicable β€” allowing us further reductions to showing showing and The following calculation formalises this sketch:

  ∩-βˆͺ-distrib≀ : βˆ€ {x y z} β†’ x ∩ (y βˆͺ z) ≀ (x ∩ y) βˆͺ (x ∩ z)
  ∩-βˆͺ-distrib≀ {x} {y} {z} =
    let
      case₁ : y ∩ x ≀ (x ∩ y) βˆͺ (x ∩ z)
      case₁ = ≀-trans (≀-refl' ∩-comm) l≀βˆͺ

      caseβ‚‚ : z ∩ x ≀ (x ∩ y) βˆͺ (x ∩ z)
      caseβ‚‚ = ≀-trans (≀-refl' ∩-comm) r≀βˆͺ

      body : (y βˆͺ z) ≀ x ⇨ (x ∩ y) βˆͺ (x ∩ z)
      body = βˆͺ-universal _ (Ζ› case₁) (Ζ› caseβ‚‚)
    in x ∩ (y βˆͺ z)    =⟨ ∩-comm ⟩=
       (y βˆͺ z) ∩ x    β‰€βŸ¨ ev body βŸ©β‰€
       x ∩ y βˆͺ x ∩ z  β‰€βˆŽ