Foundations #

We have seen all the ingredients of the foundations of mathematics as implemented in Lean. Our goal now is to:

Foundations of foundations #

The starting assumption is that we are in agreement with the meaning of syntax, including pattern matching and substitution. For example, we can understand the following definition is valid in Lean, assuming we know what means:

def cube : ℕ → ℕ := fun n → n * n * n

and that we can deduce from the above that cube 3 = 3 * 3 * 3.

We have rules for foundations based on syntax. We also assume that the rules can be checked mechanically, i.e., by a computer program, and we are convinced that some such program is correct. For a flexible syntax, this is a non-trivial task. So we may want to restrict to a simpler syntax (as we will when we consider classical foundations).

We have to also check that we correctly represent the corresponding "real world" concept.

Context, Rules, Terms #

We assume that at any point we have a Context. In Lean this means that we have terms that we can refer to by name, and that these terms have a type, though this may be an expression.

In any context, we have Rules to

Generative grammars #

Expressions and Rules are based on a generative grammar. Thus, we do not specify whether an expression or judgement is valid or not. Instead, we specify how we can make well-formed expressions and valid judgements.

Local Contexts #

In addition to the names in the context, we can have some names that are only valid in a particular expression. These are called local variables.

Initial Context #

Even an empty Lean file does not have an empty context. Instead the context has Foundational Types.

Axioms #

We can add axioms to the context. This means that we introduce a term and give an expression for its type. This should be done with care so that the context does not become inconsistent.

Rules for Lean #

The rules for Lean let us introduce expressions and at the same time make judgements about them.

Propositions as Types #

Remarkably, the same set of rules let us encode both objects of mathematics and statements about them. The statements (called propositions) are encoded as types with a proof of the proposition being a term of that type.

Logical connectives are encoded as function types, Π-types, and inductive types. The rules for deduction follow from the rules for Lean.

In Lean, there is an additional rule for a proposition α : Prop, namely if p : α and q : α then p = q.

We use various rules:

def addTwo :

Adding 2 to a natural number.

Instances For

    A theorem is just like a definition, except

    theorem one_addTwo :
    addTwo 1 = 3

    one plus two is three

    Π-types #

    These can be viewed as:

    We consider an example

    def NatTuple :
    Instances For

      We define a dependent function associating to a natural number n the tuple of n natural numbers (n, n-1, ..., 0).

      def descending (n : ) :
      NatTuple (n + 1)
      Instances For