ArticleslgStudy

mathematics

Coinduction

Coinduction is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Coinduction rather than just read about it. In short: In computer science, coinduction is a technique for defining and proving properties of systems of concurrent interacting objects. Coinduction is the mathematical dual to structural induction.

Key takeaways

  • Coinduction belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Coinduction to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Coinduction from memory before moving on to harder problems.

Reference excerpt

In computer science, coinduction is a technique for defining and proving properties of systems of concurrent interacting objects. Coinduction is the mathematical dual to structural induction. Coinductively defined data types are known as codata and are typically infinite data structures, such as streams. As a definition or specification, coinduction describes how an object may be "observed", "broken down" or "destructed" into simpler objects. As a proof technique, it may be used to show that an equation is satisfied by all possible implementations of such a specification. To generate and manipulate codata, one typically uses corecursive functions, in conjunction with lazy evaluation. Informally, rather than defining a function by pattern-matching on each of the inductive constructors, one defines each of the "destructors" or "observers" over the function result. In programming, co-logic programming (co-LP for brevity) "is a natural generalization of logic programming and coinductive logic programming, which in turn generalizes other extensions of logic programming, such as infinite trees, lazy predicates, and concurrent communicating predicates. Co-LP has applications to rational trees, verifying infinitary properties, lazy evaluation, concurrent logic programming, model checking, bisimilarity proofs, etc." Experimental implementations of co-LP are available from the University of Texas at Dallas and in the language Logtalk (for examples see ) and SWI-Prolog.

Description In his book Types and Programming Languages, Benjamin C. Pierce gives a concise statement of both the principle of induction and the principle of coinduction. While this article is not primarily concerned with induction, it is useful to consider their somewhat generalized forms at once. In order to state the principles, a few preliminaries are required.

Preliminaries Let U be a set and F be a monotone function 2U→2U, that is: X⊆Y⇒F(X)⊆F(Y) Unless otherwise stated, F will be assumed to be monotone.

X is F-closed if F(X)⊆X X is F-consistent if X⊆F(X) X is a fixed point if X=F(X) These terms can be intuitively understood in the following way. Suppose that X is a set of assertions, and F(X) is the operation that yields the consequences of X. Then X is F-closed when one cannot conclude any more than has already been asserted, while X is F-consistent when all of the assertions are supported by other assertions (i.e. there are no "non-F-logical assumptions"). The Knaster–Tarski theorem tells us that the least fixed-point of F (denoted μF) is given by the intersection of all F-closed sets, while the greatest fixed-point (denoted νF) is given by the union of all F-consistent sets. We can now state the principles of induction and coinduction.

Definition Principle of induction: If X is F-closed, then μF⊆X Principle of coinduction: If X is F-consistent, then X⊆νF

Discussion The principles, as stated, are somewhat opaque, but can be usefully thought of in the following way. Suppose you wish to prove a property of μF. By the principle of induction, it suffices to exhibit an F-closed set X for which the property holds. Dually, suppose you wish to show that x∈νF. Then it suffices to exhibit an F-consistent set that x is known to be a member of.

Examples

Proving a program can't crash Many programs or machines can be viewed abstractly as a collection of states s∈S, each of which has possible continuation states Next(s)⊆S. Suppose crash∈S is some undesirable state we wish to avoid, it is then useful to know from which starting states this undesirable state is impossible to reach. Let NeverCrashes(s) be the property that crash is impossible to reach from s via state transitions. One way that one might wish to define NeverCrashes(s) is via recursion: NeverCrashes(s)⟺(s≠crash)∧(∀n∈Next(s).NeverCrashes(n)) But as intuitive as this definition is it doesn't work as written because the recursion is not well-founded; If we have two states a,b∈S such that a∈Next(b) and b∈Next(a) then the definition is circular. A way to avoid this problem is by encoding the same recursive relation via a monotone function and then taking its greatest fixed-point: F:P(S)→P(S)F(X):={s∈X∣(s≠crash)∧(∀n∈Next(s).n∈X)}NeverCrashes(s)⟺s∈νF Now suppose there is a specific state initial∈S for which we want to prove NeverCrashes(initial). This can be done by constructing a subset of states V⊆S for which the following hold: initial∈Vcrash∉V∀s∈V.Next(s)⊆V Then the logic goes as follows: The machine starts at initial, which is in V, and each state transition after that gives another state from V, so at all points in time the machine's state must be among the ones in V. Then since crash∉V the machine's state can never be crash. This can be formalized into a proof via the principle of coinduction: crash∉V and ∀s∈V.Next(s)⊆V are precisely the conditions under which V is F-consistent, and thus by the principle of coinduction V⊆νF. Then since initial∈V it directly follows that initial∈νF, and thus NeverCrashes(initial).

Defining a set of data types

Consider the following grammar of datatypes: T=⊥|⊤|T×T That is, the set of types includes the "bottom type" ⊥, the "top type" ⊤, and product types. These types can be identified with strings over the alphabet Σ={⊥,⊤,×}. Let Σ≤ω denote all (possibly infinite) strings over Σ. Consider the function F:2Σ≤ω→2Σ≤ω: F(X)={⊥,⊤}∪{x×y:x,y∈X} In this context, x×y means "the concatenation of string x, the symbol ×, and string y." We should now define our set of datatypes as a fixpoint of F, but it matters whether we take the least or greatest fixpoint. Suppose we take μF as our set of datatypes. Using the principle of induction, we can prove the following claim:

To arrive at this conclusion, consider the set of all finite strings over Σ. Clearly F cannot produce an infinite string, so it turns out this set is F-closed and the conclusion follows. Now suppose that we take νF as our set of datatypes. We would like to use the principle of coinduction to prove the following claim:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Coinduction

Start with the simplest possible case. Write down what Coinduction claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Coinduction before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Coinduction ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Coinduction

In research
Coinduction appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Coinduction in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Coinduction is common in secondary-school and first-year university syllabi. It links to neighbouring topics Category theory, Functional programming, Logic programming, so understanding it makes those chapters shorter.
In everyday life
Look for Coinduction outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Coinduction” →

How to study Coinduction in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Coinduction means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Coinduction out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Coinduction in simple terms?

In computer science, coinduction is a technique for defining and proving properties of systems of concurrent interacting objects. Coinduction is the mathematical dual to structural induction.

Why does Coinduction matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Coinduction?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Coinduction.

Tags

  • Category theory
  • Functional programming
  • Logic programming
  • Mathematical induction
  • Theoretical computer science

Keep exploring