Documentation

PfsProgs25.Unit07.NatLogic

Logic: Curry-Howard Correspondence and Natural numbers #

The foundations of Lean represent "all" of Mathematics. This means:

We will illustrate the latter two points in the context of Natural numbers.

Classical logic: example Natural Numbers #

Logic in Lean #

Quantifiers #

Equations
Instances For
    Equations
    Instances For

      Constructing the Language of Natural Numbers #

      def MyNat.mul (m n : MyNat) :
      Equations
      Instances For

        The subtle point is to define relations such as and =. These are indexed inductive types.

        inductive MyNat.le :
        MyNatMyNatProp
        • refl (n : MyNat) : n.le n
        • step (m n : MyNat) : m.le nm.le n.succ
        Instances For
          Equations
          Instances For
            Equations
            Instances For
              Equations
              theorem MyNat.le_refl (n : MyNat) :
              n n

              The induction principle encodes not only that refl and step are constructors of le, but also that they are the only ways to prove le.

              Transitivity of is a theorem.

              theorem MyNat.le_trans {m n k : MyNat} :
              m nn km k

              What is recursion? #

              When an inductive type like MyNat is defined, the following are automatically defined:

              Further, some equality principles are automatically defined:

              For defining functions from MyNat to MyNat, we have a simple "motive".

              noncomputable def MyNat.fctrl :
              Equations
              Instances For