# What is an eliminator?

What is an eliminator?

• Are there any differences between an eliminator and an elimination form (such as $$\pi_1$$ and $$\pi_2$$ for binary products)?
• Does every type have exactly one?
• Is the type of the eliminator completely determined by the types of the constructors?

The motivation for this question is: I'm trying to understand a $$\Pi$$-type definition of $$\mathbb{N}$$ quoted from an answer on this site.

The definition, with the notation changed only slightly, is given below.

$$\mathbb{N} \;\;{\small\text{is defined as}}\;\; \bigg(\Pi (N : *) \mathop. \Pi (A : *) \mathop. A \to (N \to A \to A) \to (N \to A)\bigg) : *$$

According to the body of the answer, $$A \to (N \to A \to A) \to (N \to A)$$ is the type of the eliminator of the natural numbers.

• I don't understand the question. What exactly are you asking? Feb 12, 2022 at 5:04
• The definition of $f$ is not correct (it loops). You need two cases: $f(x, g, 0) = x$ and $f(x, g S(n)) = g(x, g, f(x, g, n))$. The function $f$ is realizes primitive recursion, and is the proof relevant counter-part of induction. I don't understand what you're asking, by the way. Feb 12, 2022 at 7:14
• I should point out that the definition of $\mathbb{N}$ given is not complete. It is insufficient for showing that $\mathbb{N}$ has the desired properties. You need something else in addition, such as parametricity. Feb 12, 2022 at 7:15
• I misspoke: eliminators are proof relevant eliminations. Regarding $S$ and $0$, of course you need to define them as suitable $\lambda$-terms. And the recursor can also be similarly defined using just $\lambda$-terms. Feb 12, 2022 at 8:19
• A constructor for X is a way of making things of type X, and an eliminator for X is a way of using things of type X to make other stuff (i.e. a way to make functions from X to other types). Is that the answer you're looking for? Feb 12, 2022 at 15:49

The role of constructors and eliminators can be understood through category theory. For every type former (for example $$A\times B$$, $$A+B$$, $$A^B$$, $$\mathbb N$$, etc...) we can ask

• How can we construct a morphism into this type?
• How can we construct a morphism out of this type?

We might as well call the morphisms into the type constructors and morphisms out of the type as eliminators.

The product type, for example, has the following universal property:

Given $$P,Q$$, there exists morphisms $$\pi_1 : P\times Q\to P$$, $$\pi_2 : P\times Q\to Q$$, such that for every object $$R$$, and morphisms $$p : R\to P$$, $$q:R\to Q$$ such that $$\pi_1\circ p = \pi_2\circ q$$, there exists a unique morphism $$\langle p,q\rangle : R\to P\times Q$$ such that $$\langle p,q\rangle\circ \pi_1 = p$$ and $$\langle p,q\rangle\circ\pi_2 = q$$.

From this, we see that the eliminators are $$\pi_1 : P\times Q\to P\\\pi_2 : P\times Q\to Q$$ and the only constructor is $$\frac{p : R\to P\quad q : R\to Q}{\langle p,q\rangle : R\to P\times Q}.$$

Similarly, the universal property of the natural numbers gives constructors $$z : 1\to \mathbb N\\ s : \mathbb N\to \mathbb N$$ and eliminators $$\frac{q : 1\to A\quad f : A\to A}{\text{rec}(q,f) : \mathbb N\to A}$$

Note that this is slightly different from require $$f : \mathbb N\to A\to A$$, but this is an equivalent, and often more convenient presentation.

So there is no reason why we can't have more than one eliminator, or that constructors/eliminators can't be more complicated. As a final example, function types have constructor $$\frac{f : A\to B}{\lambda f : B^A}$$ and eliminator $$\text{eval} : B^A\times A\to B,$$ where the only way to eliminate something of type $$B^A$$ is to pair it with something of type $$A$$.

It's also interesting to note that $$\mathbb N$$ belongs to a class of inductive types, which means the eliminator has a specific form. $$\newcommand{\mc}{\mathcal}$$ Indeed, for an inductive type defined by an endofunctor $$F:\mc C\to\mc C$$ (where $$\mc C$$ is the category of types) (in the case of $$\mathbb N$$, $$F(X) := X\times (X\to X)$$), the inductive type is defined to be the initial algebra for $$F$$. If $$A$$ is initial for $$F$$, this briefly means that for every other type $$X$$, there is a unique map of algebras $$F(A)\to F(X)$$. This map is the eliminator for $$A$$.

• How does this fit with the picture where product types have only one eliminator (of type $(P \to Q \to R) \to P \times Q \to R$? Feb 13, 2022 at 18:59
• @JasonGross Should $R$ be universally quantified?
– Couchy
Feb 13, 2022 at 19:08
• all type variables in eliminators are always universally quantified. So, yes $R$ (and $P$ and $Q$) is universally quantified. Feb 14, 2022 at 16:55
• The two pictures corresponds to viewing the product type as positive or negative. In polarized notation we can write them as $\otimes$ and $\&$, respectively.
– Trebor
Feb 15, 2022 at 7:41
• In linear logic they are not equivalent, but with weakening and contraction, they are, so we often confuse them.
– Trebor
Feb 15, 2022 at 7:42