Documentation

PfsProgs25.Unit02.PropsProofs

Propositions and Proofs #

As we have mentioned, proofs and propositions are terms, with propositions as types. The universe Prop is the type of propositions. To start with, it is best to ignore the difference between Prop and Type and treat them as the same.

A logical statement like 1 ≤ 2 is a proposition and has type Prop.

The proposition 0 ≤ 2 is true and has proof Nat.zero_le 2.

A proposition may be neither proved nor disproved. So we cannot evaluate it. We can evaluate it if it is decidable.

We can combine propositions to make propositions:

The key idea is that function application is exactly analogous to the logical rule of inference called modus ponens.

def modus_ponens {P Q : Prop} (h₁ : P) (h₂ : PQ) :
Q
Equations
  • =
Instances For
    def application {α β : Type} (a : α) (f : αβ) :
    β
    Equations
    Instances For

      We apply modus-ponens with P being 0 ≤ 2 and P → Q being Nat.succ_le_succ applied to 0 and 2.

      Some proofs at term level

      def one_le_three :
      1 3
      Equations
      Instances For
        def two_le_five :
        2 5
        Equations
        Instances For
          def wrong_three_le_one (h : 2 0) :
          3 1
          Equations
          • =
          Instances For

            Proof Irrelevance #

            In Lean, any two proof terms of the same proposition are equal by definition. This is called proof irrelevance.

            theorem proof_irrelevance {P : Prop} (h₁ h₂ : P) :
            h₁ = h₂

            Universes #

            Dependent Function Types #

            The type of Nat.zero_le is ∀ (n : Nat), 0 ≤ n. We will write it more like a function type

            def my_zero_le (n : Nat) :
            Nat.le 0 n
            Equations
            • =
            Instances For

              We saw that if α and β are types (or props), then α → β is the type of functions from α to β.

              If instead we have β : α → Typeor β : α → Prop, then (a : α) → β a (more formally Π (a : α), β a) is the type of dependent functions from a : α to β a.