Definition

To specify a type, we need:

Formation rule

A formation rule tells you when a type is well-formed, .. when you are allowed to form a new type expression.

Constructors

how to construct elements of that type

Eliminators

An eliminator is the canonical principle for using (eliminating) values of a type

The eliminator states the elimination principle by giving a term with a specific type

.. defining functions out of that type by analyzing how the value could have been constructed.

There are two common forms:

Non-dependent eliminator (recursor)

it defines a function into a constant target type.

Comment

What a bad name!, a recursor is not recursive

defines a plain function:

where does not depend on the input

Dependent eliminator (induction)

Defines a dependent function (Π-types (Dependent function types)):

where type depend on .

Computation rule

how an eliminator acts on a constructor

The computation rule (β-rule) states how that recursor reduces/evaluates when you apply it to a constructor.

Examples

Example: Product type A×B

Formation rule: If and , then

Constructor: If and , then

or the constructor is pairing:

Eliminator (recursor):

Meaning: we choose a result type we give a rule telling how to produce a from components and , then is the function

Computation rule (β):

We can define special cases:

  • with computation rule
  • with computation rule

Uniqueness:

NOTE

actually we could define Note that could be constructed as an indexed one over the two-element type 2

Example: Coproduct type A+B

Formation rule: If and , then

Constructors:

Eliminator (recursor):

Computation rules (β):

NOTE

actually we could define Note that could be constructed as an indexed one over the two-element type 2

Example: Unit type 1

Formation rule:

Constructor (introduction rule):

Eliminator (recursor):

Induction: This means, if you have a family , to produce it suffices to give

Computation rule (β-rule):

prove the propositional uniqueness principle for 1

Step 1: Define family by so a term of is exactly a term of

Step 2: Induction for the unit type says: so it suffices to give a term of

Step 3: base case Compute: and we always have

Step 4: we define

check:

  • for any ,
  • by computation rule

Example: Empty type 0

Formation rule:

Constructor: (none)

Eliminator (recursor / ex falso):

Computation rule: (none)

Example: Natural numbers N

Formation rule:

Constructors:

Eliminator (recursor / primitive recursion):

Computation rules (β):

Example: Lists List(A)

Formation rule: If , then

Constructors:

Eliminator (recursor / fold):

Computation rules (β):

Other examples

Similarly we can also define types like , or

Propositions

We treat propositions as types and the evidence (proofs) as elements of this type.

means: we can find a function such that it matches all elements of to elements of . For every proof of we can find a proof of . Case 1: if is true there is a proof of there is a proof of is true Case 2: if is false it is easy to define a function from to , (any mapping would do the job, since the function is never called) is true

We see (type theory) and (first order logic) are equivalent.