Documentation

PnP2023.Lec_02_15.PropsAsTypes

Propositions as Types #

Main correspondence #

def functionApplication {A : Type u} {B : Type u} (f : AB) (a : A) :
B
Instances For
    def modus_ponens {A : Prop} {B : Prop} (h₁ : AB) (h₂ : A) :
    B
    Instances For

      Other Combination #

      All these can be constructed by our rules.

      Conjuction and Product #

      structure And (a b : Prop) : Prop where
        /-- `And.intro : a → b → a ∧ b` is the constructor for the And operation. -/
        intro ::
        /-- Extract the left conjunct from a conjunction. `h : a ∧ b` then
        `h.left`, also notated as `h.1`, is a proof of `a`. -/
        left : a
        /-- Extract the right conjunct from a conjunction. `h : a ∧ b` then
        `h.right`, also notated as `h.2`, is a proof of `b`. -/
        right : b
      

      This is the same as the product type:

      structure Prod (α : Type u) (β : Type v) where
        /-- The first projection out of a pair. if `p : α × β` then `p.1 : α`. -/
        fst : α
        /-- The second projection out of a pair. if `p : α × β` then `p.2 : β`. -/
        snd : β
      
      inductive MyOr (A : Prop) (B : Prop) :
      Instances For

        Disjunction and Sum #

        inductive Or (a b : Prop) : Prop where
          /-- `Or.inl` is "left injection" into an `Or`. If `h : a` then `Or.inl h : a ∨ b`. -/
          | inl (h : a) : Or a b
          /-- `Or.inr` is "right injection" into an `Or`. If `h : b` then `Or.inr h : a ∨ b`. -/
          | inr (h : b) : Or a b
        

        This is the same as the sum type:

        inductive Sum (α : Type u) (β : Type v) where
          /-- Left injection into the sum type `α ⊕ β`. If `a : α` then `.inl a : α ⊕ β`. -/
          | inl (val : α) : Sum α β
          /-- Right injection into the sum type `α ⊕ β`. If `b : β` then `.inr b : α ⊕ β`. -/
          | inr (val : β) : Sum α β
        

        True and False #

        These are analogues of Unit and Empty:

        inductive True : Prop where
          /-- `True` is true, and `True.intro` (or more commonly, `trivial`)
          is the proof. -/
          | intro : True
        
        inductive False : Prop
        

        Negation #

        The negation of a type (or proposition) A is ¬ A, which is the type (or proposition) A → False.

        If and only if #

        structure Iff (a b : Prop) : Prop where
          /-- If `a → b` and `b → a` then `a` and `b` are equivalent. -/
          intro ::
          /-- Modus ponens for if and only if. If `a ↔ b` and `a`, then `b`. -/
          mp : a → b
          /-- Modus ponens for if and only if, reversed. If `a ↔ b` and `b`, then `a`. -/
          mpr : b → a
        

        Universal Quantifiers #

        Existential Quantifiers #

        inductive Exists {α : Sort u} (p : α → Prop) : Prop where
          /-- Existential introduction. If `a : α` and `h : p a`,
          then `⟨a, h⟩` is a proof that `∃ x : α, p x`. -/
          | intro (w : α) (h : p w) : Exists p
        

        Basic types #

        We have seen can be constructed as indexed inductive type:

        inductive Nat.le (n : Nat) : Nat → Prop
          /-- Less-equal is reflexive: `n ≤ n` -/
          | refl     : Nat.le n n
          /-- If `n ≤ m`, then `n ≤ m + 1`. -/
          | step {m} : Nat.le n m → Nat.le n (succ m)
        

        The equality type is also indexed inductive type:

        inductive Eq : α → α → Prop where
          /-- `Eq.refl a : a = a` is reflexivity, the unique constructor of the
          equality type. See also `rfl`, which is usually used instead. -/
          | refl (a : α) : Eq a a