Paul He


Wednesday, April 17, 2019

Coinduction is the mathematical dual to an indispensible mathematical tool: induction. While mathematical induction has been known for thousands of years, coinduction has only been studied for a few decades. It is still primarily used in computer science, from which it originated in the field of concurrency theory. Coinduction allows us to define circular or infinite objects (such as streams, lists that can be infinitely long), and to prove things about them.

It should not be confused with this coinduction, which may put you to sleep instead.

Inductive definitions

Inductive (or recursive) definitions are ubiquitous in mathematics, to the point where they are often implicit. They follow a common pattern to build up a set of objects incrementally. A base case (or multiple) is first established, and then rules for building up objects based on previous levels are defined.

The set of finite strings on an alphabet is the set inductively defined by the following rules, in inference rule notation:

So (the empty string) is a string, and for any symbol in the alphabet, we can prepend that onto another string to yield a string. Only the objects generated from the rules are in .

Inductive definitions can be thought of as an iterative process: we start with the empty set and keep adding objects according to the definition, until in the limit, we reach a fixed point, when applying the rules no longer adds anything new to the set. We add , then the length 1 strings, then the length 2 strings, and so on, until we have the infinite set of strings over of any length in .

An inductive definition is thus the smallest set closed forward under its defining rules. That is, is the smallest set such that and that if , then for any . We apply the rules from premises to conclusion.

Coinductive definitions

Since coinduction is the dual to induction, let’s try “flipping” the inductive definition. A coinductive definition is the largest set closed backward under its defining rules.

What does this mean? For an inductive definition, we can think of the set as starting from and iteratively adding elements according to the rules. For a coinductive definition, we can think of the set as starting from the set of all possible objects (even infinite ones), and iterative removing objects that contradict the rules.

If we use the same rules that inductive defined above, the coinductively defined set is the largest set such that and that if , then (and ). Here, the backward closure goes from the conclusion to the premises, the opposite of the forward closure. The set of finite strings, , is included in . But we also have some new strings in , the infinitely long strings. Consider the string , where . We cannot construct it using the base case, but it doesn’t lead to a contradiction either, since if , taking off the first results in the same infinite string , and as desired.

The proof tree for is infinite, and looks like the following:

While objects of inductive definitions require finite derivations, objects of coinductive definitions can have infinite derivations.

Proof principles

For the following, I will skip over some (many) details.

The function can be thought of as the set of rules for a given (co)inductive definition. is the set of conclusions obtained after applying the rules using as the set of premises.

Recall that an inductive definition is the least fixed point of a set of rules, and that a coinductive definition is the greatest fixed point. Now here is a specialization of the Knaster–Tarski fixpoint theorem:

The least fixed point of .
The greatest fixed point of .

captures the meaning of the informal “closed forwards” definition from earlier. Given a set where the premises , we can apply all rules in the “forwards” direction, obtaining the set of conclusions which are also in : .

Dually, captures the meaning of “closed backwards”. Given a set where the conclusions from some set of premises , we can apply some rule for each in the “backwards” direction, obtaining the set of premises which are also in : .

Simple corollaries of the fixpoint theorem gives us proof principles for inductive and coinductive definitions:

Lemma (Induction Principle):
If , then .
Lemma (Coinduction Principle):
If , then .

Proof by induction

Using the induction principle, we can show that every element of a inductively defined set satisfies some condition, by showing that the condition is preserved for each rule of the definition.

We can derive the more familiar principle of mathematical induction using this. Let . This is the set of rules for the natural numbers. It may be more familiar if I write it as the following:

Then to prove some fact about the natural numbers, we just need to show that it is preserved when applying these rules in the forwards direction. For example, we will show that is true for all natural numbers. Let’s take . Then we will prove that . This is exactly the conclusion of the Induction Principle, so we need to show that .

An element of can either be (the base case), which we can easily verify is in , or (the inductive case) where (the inductive hypothesis). This should look familiar. Some fiddling will show that the second case is true as well, and we are done!

Proof by coinduction

Dually, using the coinduction principle, we can show that an element is in the coinductively defined set.

Using just , our only coinductively defined set so far, would not be very interesting, since it would involve only the membership proofs we saw earlier. Let’s make another coinductive definition, this time a relation on elements of : let , where is some ordering on the alphabet (the usual one on the English alphabet, for instance). Can you tell what relation this defines? Let’s write down the inference rules:

The notation should help: is the lexicographic ordering relation on our (possibly) infinite strings, displayed here as .

Now we can prove that some strings are related by this relation. For an example, we will show . Note that these are infinitely long strings.

Using the coinduction principle, we just need to show that is in some set of pairs of strings that is closed backwards under . Let’s try the singleton set first. Then . But then , since the second string of every pair in has a as the second symbol.

is our “coinductive hypothesis”. Like how during induction we sometimes have to strengthen the inductive hypothesis, here we have to strengthen the coinductive hypothesis by making it bigger.

Recall the “backwards closed” intuition. We want to show that by applying some rule “backwards”, we obtain something still in . If we start with , we can only apply the second rule, stripping off the first symbol of each string. , so that premise is fine, and we just need to show that now. It looks like we need to grow by adding this new pair to it, strengthening the coinductive hypothesis.

Now , and

Let’s check that .
, and .
, and .

And since , we’re done!


Recently I’ve been working on Interaction Trees, a library that provides a coinductive data structure for reasoning about interactive programs in Coq. Coinduction is less convenient than induction in Coq. For example, in the coinductive proof above the “coinductive hypothesis” included exactly the conclusion we were trying to prove. When doing the proof informally, we know we must apply one of the rules backwards and only then can we apply the coinductive hypothesis.

Doing this in a proof assistant like Coq is more complex. Using “vanilla” Coq, it will allow you to apply the coinductive hypothesis immediately, and then complain that you got it wrong when you try to finish the proof. The paco library solves this problem, but more complex reasoning quickly gets complex, which is why I started learning more about the theory behind coinduction.

I find it really intriguing how (relatively) new coinduction is and how useful it has become. There’s been a lot of work recently on areas related to coinduction, and I’m excited to do more work in this area.


I first encountered coinduction in Types and Programming Languages by Benjamin C. Pierce, where they are introduced to talk about the metatheory of recursive types. While I wouldn’t recommend reading this if you’re just interested in coinduction, it serves as an excellent introduction to programming languages and type systems.

Introduction to Bisimulation and Coinduction by Davide Sangiorgi is a very accessible textbook that goes into detail about all of this and more. It cleared up a lot of questions I had about coinduction, and helped me understand it more rigorously.


Submit a comment below. Emails will not be published.

wooo00oo+: So coinduction is induction on coins?

Paul: Not quite, it's more like duction on coins or ions on coinducts.

Your comment will be posted after it is reviewed.