Coinduction

Last updated

In computer science, coinduction is a technique for defining and proving properties of systems of concurrent interacting objects.

Contents

Coinduction is the mathematical dual to structural induction.[ citation needed ] 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." [1] Experimental implementations of co-LP are available from the University of Texas at Dallas [2] and in the language Logtalk (for examples see [3] ) and SWI-Prolog.

Description

In [4] a concise statement is given 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 be a set and be a monotone function , that is:

Unless otherwise stated, will be assumed to be monotone.

X is F-closed if
X is F-consistent if
X is a fixed point if

These terms can be intuitively understood in the following way. Suppose that is a set of assertions, and is the operation that yields the consequences of . Then is F-closed when you cannot conclude anymore than you've already asserted, while is F-consistent when all of your 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 (denoted ) is given by the intersection of all F-closed sets, while the greatest fixed-point (denoted ) 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 is F-closed, then
Principle of coinduction: If is F-consistent, then

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 . By the principle of induction, it suffices to exhibit an F-closed set for which the property holds. Dually, suppose you wish to show that . Then it suffices to exhibit an F-consistent set that is known to be a member of.

Examples

Defining a set of datatypes

Consider the following grammar of datatypes:

That is, the set of types includes the "bottom type" , the "top type" , and (non-homogenous) lists. These types can be identified with strings over the alphabet . Let denote all (possibly infinite) strings over . Consider the function :

In this context, means "the concatenation of string , the symbol , and string ." We should now define our set of datatypes as a fixpoint of , but it matters whether we take the least or greatest fixpoint.

Suppose we take as our set of datatypes. Using the principle of induction, we can prove the following claim:

All datatypes in are finite

To arrive at this conclusion, consider the set of all finite strings over . Clearly cannot produce an infinite string, so it turns out this set is F-closed and the conclusion follows.

Now suppose that we take as our set of datatypes. We would like to use the principle of coinduction to prove the following claim:

The type

Here denotes the infinite list consisting of all . To use the principle of coinduction, consider the set:

This set turns out to be F-consistent, and therefore . This depends on the suspicious statement that

The formal justification of this is technical and depends on interpreting strings as sequences, i.e. functions from . Intuitively, the argument is similar to the argument that (see Repeating decimal).

Coinductive datatypes in programming languages

Consider the following definition of a stream: [5]

dataStreama=Sa(Streama)-- Stream "destructors"head(Saastream)=atail(Saastream)=astream

This would seem to be a definition that is not well-founded, but it is nonetheless useful in programming and can be reasoned about. In any case, a stream is an infinite list of elements from which you may observe the first element, or place an element in front of to get another stream.

Relationship with F-coalgebras

Source: [6]

Consider the endofunctor in the category of sets:

The final F-coalgebra has the following morphism associated with it:

This induces another coalgebra with associated morphism . Because is final, there is a unique morphism

such that

The composition induces another F-coalgebra homomorphism . Since is final, this homomorphism is unique and therefore . Altogether we have:

This witnesses the isomorphism , which in categorical terms indicates that is a fixpoint of and justifies the notation.

Stream as a final coalgebra

We will show that

Stream A

is the final coalgebra of the functor . Consider the following implementations:

outastream=(headastream,tailastream)out'(a,astream)=Saastream

These are easily seen to be mutually inverse, witnessing the isomorphism. See the reference for more details.

Relationship with mathematical induction

We will demonstrate how the principle of induction subsumes mathematical induction. Let be some property of natural numbers. We will take the following definition of mathematical induction:

Now consider the function :

It should not be difficult to see that . Therefore, by the principle of induction, if we wish to prove some property of , it suffices to show that is F-closed. In detail, we require:

That is,

This is precisely mathematical induction as stated.

See also

Related Research Articles

<span class="mw-page-title-main">Lorentz transformation</span> Family of linear transformations

In physics, the Lorentz transformations are a six-parameter family of linear transformations from a coordinate frame in spacetime to another frame that moves at a constant velocity relative to the former. The respective inverse transformation is then parameterized by the negative of this velocity. The transformations are named after the Dutch physicist Hendrik Lorentz.

<span class="mw-page-title-main">Stefan–Boltzmann law</span> Physical law on the emissive power of black body

The Stefan–Boltzmann law, also known as Stefan's law, describes the intensity of the thermal radiation emitted by matter in terms of that matter's temperature. It is named for Josef Stefan, who empirically derived the relationship, and Ludwig Boltzmann who derived the law theoretically.

<span class="mw-page-title-main">Student's t-distribution</span> Probability distribution

In probability and statistics, Student's t distribution is a continuous probability distribution that generalizes the standard normal distribution. Like the latter, it is symmetric around zero and bell-shaped.

In mathematics, the tensor algebra of a vector space V, denoted T(V) or T(V), is the algebra of tensors on V (of any rank) with multiplication being the tensor product. It is the free algebra on V, in the sense of being left adjoint to the forgetful functor from algebras to vector spaces: it is the "most general" algebra containing V, in the sense of the corresponding universal property (see below).

In theoretical computer science, the π-calculus is a process calculus. The π-calculus allows channel names to be communicated along the channels themselves, and in this way it is able to describe concurrent computations whose network configuration may change during the computation.

In mathematics, the total variation identifies several slightly different concepts, related to the (local or global) structure of the codomain of a function or a measure. For a real-valued continuous function f, defined on an interval [a, b] ⊂ R, its total variation on the interval of definition is a measure of the one-dimensional arclength of the curve with parametric equation xf(x), for x ∈ [a, b]. Functions whose total variation is finite are called functions of bounded variation.

In mathematics, particularly in operator theory and C*-algebra theory, the continuous functional calculus is a functional calculus which allows the application of a continuous function to normal elements of a C*-algebra.

In mathematics, specifically in category theory, an -coalgebra is a structure defined according to a functor , with specific properties as defined below. For both algebras and coalgebras, a functor is a convenient and general way of organizing a signature. This has applications in computer science: examples of coalgebras include lazy evaluation, infinite data structures, such as streams, and also transition systems.

<i>F</i>-algebra

In mathematics, specifically in category theory, F-algebras generalize the notion of algebraic structure. Rewriting the algebraic laws in terms of morphisms eliminates all references to quantified elements from the axioms, and these algebraic laws may then be glued together in terms of a single functor F, the signature.

In mathematics, the disintegration theorem is a result in measure theory and probability theory. It rigorously defines the idea of a non-trivial "restriction" of a measure to a measure zero subset of the measure space in question. It is related to the existence of conditional probability measures. In a sense, "disintegration" is the opposite process to the construction of a product measure.

In differential geometry, normal coordinates at a point p in a differentiable manifold equipped with a symmetric affine connection are a local coordinate system in a neighborhood of p obtained by applying the exponential map to the tangent space at p. In a normal coordinate system, the Christoffel symbols of the connection vanish at the point p, thus often simplifying local calculations. In normal coordinates associated to the Levi-Civita connection of a Riemannian manifold, one can additionally arrange that the metric tensor is the Kronecker delta at the point p, and that the first partial derivatives of the metric at p vanish.

In statistics, the inverse Wishart distribution, also called the inverted Wishart distribution, is a probability distribution defined on real-valued positive-definite matrices. In Bayesian statistics it is used as the conjugate prior for the covariance matrix of a multivariate normal distribution.

In probability theory, regular conditional probability is a concept that formalizes the notion of conditioning on the outcome of a random variable. The resulting conditional probability distribution is a parametrized family of probability measures called a Markov kernel.

In statistics, the reduced chi-square statistic is used extensively in goodness of fit testing. It is also known as mean squared weighted deviation (MSWD) in isotopic dating and variance of unit weight in the context of weighted least squares.

In mathematics, especially measure theory, a set function is a function whose domain is a family of subsets of some given set and that (usually) takes its values in the extended real number line which consists of the real numbers and

<span class="mw-page-title-main">Weyl equation</span> Relativistic wave equation describing massless fermions

In physics, particularly in quantum field theory, the Weyl equation is a relativistic wave equation for describing massless spin-1/2 particles called Weyl fermions. The equation is named after Hermann Weyl. The Weyl fermions are one of the three possible types of elementary fermions, the other two being the Dirac and the Majorana fermions.

<span class="mw-page-title-main">Complexification (Lie group)</span> Universal construction of a complex Lie group from a real Lie group

In mathematics, the complexification or universal complexification of a real Lie group is given by a continuous homomorphism of the group into a complex Lie group with the universal property that every continuous homomorphism of the original group into another complex Lie group extends compatibly to a complex analytic homomorphism between the complex Lie groups. The complexification, which always exists, is unique up to unique isomorphism. Its Lie algebra is a quotient of the complexification of the Lie algebra of the original group. They are isomorphic if the original group has a quotient by a discrete normal subgroup which is linear.

Lagrangian field theory is a formalism in classical field theory. It is the field-theoretic analogue of Lagrangian mechanics. Lagrangian mechanics is used to analyze the motion of a system of discrete particles each with a finite number of degrees of freedom. Lagrangian field theory applies to continua and fields, which have an infinite number of degrees of freedom.

In optimal transport, a branch of mathematics, polar factorization of vector fields is a basic result due to Brenier (1987), with antecedents of Knott-Smith (1984) and Rachev (1985), that generalizes many existing results among which are the polar decomposition of real matrices, and the rearrangement of real-valued functions.

In set theory and logic, Buchholz's ID hierarchy is a hierarchy of subsystems of first-order arithmetic. The systems/theories are referred to as "the formal theories of ν-times iterated inductive definitions". IDν extends PA by ν iterated least fixed points of monotone operators.

References

  1. "Co-Logic Programming | Lambda the Ultimate".
  2. "Gopal Gupta's Home Page".
  3. "Logtalk3/Examples/Coinduction at master · LogtalkDotOrg/Logtalk3". GitHub .
  4. Benjamin C. Pierce. "Types and Programming Languages". The MIT Press.
  5. Dexter Kozen, Alexandra Silva. "Practical Coinduction". CiteSeerX   10.1.1.252.3961 .
  6. Ralf Hinze (2012). "Generic Programming with Adjunctions". Generic and Indexed Programming. Lecture Notes in Computer Science. Vol. 7470. Springer. pp. 47–129. doi:10.1007/978-3-642-32202-0_2. ISBN   978-3-642-32201-3.

Further reading

Textbooks
Introductory texts
History
Miscellaneous