Algorithm Search⌘K

Theoremcore

Kleene fixed-point theorem

Also called Kleene iteration theorem.

A continuous function on a complete partial order with a bottom has a least fixed point, the limit of the iterates from bottom.

The Kleene fixed-point theorem says how to compute a least fixed point. Start from the least element ⊥\bot, apply the function again and again, and take the limit of the values. If the order is a complete partial order and the function is continuous, the limit is the least fixed point. This is the reason that iterative solvers for dataflow analysis and abstract interpretation give the right answer, and the reason that a recursive definition has a meaning. It is not the Kleene recursion theorem of computability, which is a different result about programs that can refer to their own code.

Statement

Orders. A partial order (D,⊑)(D, \sqsubseteq) is a set with a reflexive, antisymmetric and transitive relation. A chain is a sequence x0⊑x1⊑x2⊑⋯x_0 \sqsubseteq x_1 \sqsubseteq x_2 \sqsubseteq \cdots. The least upper bound ⨆ixi\bigsqcup_i x_i, when it exists, is an element above every xix_i and below every other element above every xix_i. DD is a complete partial order, or cpo, if it has a least element ⊥\bot and every chain has a least upper bound.

Functions. f:D→Df : D \to D is monotone if x⊑yx \sqsubseteq y implies f(x)⊑f(y)f(x) \sqsubseteq f(y). It is continuous, in the sense of Scott, if it keeps the least upper bounds of chains: f(⨆ixi)=⨆if(xi)f(\bigsqcup_i x_i) = \bigsqcup_i f(x_i) for every chain. A fixed point is an xx with f(x)=xf(x) = x, and a pre-fixed point is an xx with f(x)⊑xf(x) \sqsubseteq x.

Theorem. Let DD be a cpo and f:D→Df : D \to D continuous. Then:

  1. ff is monotone, and the iterates ⊥,f(⊥),f2(⊥),…\bot, f(\bot), f^2(\bot), \ldots form a chain.
  2. μf=⨆n≥0fn(⊥)\mu f = \bigsqcup_{n \ge 0} f^n(\bot) is a fixed point of ff.
  3. μf⊑x\mu f \sqsubseteq x for every pre-fixed point xx. So μf\mu f is the least pre-fixed point and the least fixed point of ff.

The dual. Turn the order upside down. If DD has a greatest element ⊤\top, every chain x0⊒x1⊒⋯x_0 \sqsupseteq x_1 \sqsupseteq \cdots has a greatest lower bound, and ff keeps these bounds, then ⊓nfn(⊤)\mathop{\large\sqcap}_n f^n(\top) is the greatest fixed point and the greatest post-fixed point, that is the greatest xx with x⊑f(x)x \sqsubseteq f(x). Dataflow analysis in the meet convention of Kildall uses this form: the maximal fixed-point solution is the limit of the iterates from ⊤\top.

In plain words

Start with no knowledge at all. Apply one step of the definition and you know a little more. Apply it again and you know more again. The knowledge only grows, so the steps settle down to a limit.

The theorem says the limit is a solution, and that it is the smallest solution: it contains only what the definition forces and nothing else. This needs one condition. The function must not jump at the limit. Whatever it does to the limit must be the limit of what it does to the steps. When the set of possible values is finite, the condition always holds, and the steps stop after a finite number of rounds.

Proof

Part 1. Continuous implies monotone. Let x⊑yx \sqsubseteq y. The sequence x,y,y,y,…x, y, y, y, \ldots is a chain with least upper bound yy. Continuity gives f(y)=f(x)⊔f(y)⊔f(y)⊔⋯f(y) = f(x) \sqcup f(y) \sqcup f(y) \sqcup \cdots, the least upper bound of f(x),f(y),f(y),…f(x), f(y), f(y), \ldots. So f(y)f(y) is above f(x)f(x). The iterates form a chain. ⊥⊑f(⊥)\bot \sqsubseteq f(\bot) because ⊥\bot is least. If fn(⊥)⊑fn+1(⊥)f^n(\bot) \sqsubseteq f^{n+1}(\bot), monotonicity gives fn+1(⊥)⊑fn+2(⊥)f^{n+1}(\bot) \sqsubseteq f^{n+2}(\bot). By induction the sequence is a chain, and since DD is a cpo, μf\mu f exists. □\square

Part 2. By continuity, applied to the chain of part 1,

f(μf)=f(⨆n≥0fn(⊥))=⨆n≥0fn+1(⊥)=⨆n≥1fn(⊥).f(\mu f) = f\Big(\bigsqcup_{n \ge 0} f^n(\bot)\Big) = \bigsqcup_{n \ge 0} f^{n+1}(\bot) = \bigsqcup_{n \ge 1} f^n(\bot).

The last chain is the first one without its first element ⊥\bot. Adding ⊥\bot to a set does not change its upper bounds, because every element is above ⊥\bot. So the two chains have the same least upper bound, and f(μf)=μff(\mu f) = \mu f. □\square

Part 3. Let f(x)⊑xf(x) \sqsubseteq x. We show fn(⊥)⊑xf^n(\bot) \sqsubseteq x for every nn by induction. For n=0n = 0, ⊥⊑x\bot \sqsubseteq x. If fn(⊥)⊑xf^n(\bot) \sqsubseteq x, monotonicity gives fn+1(⊥)⊑f(x)⊑xf^{n+1}(\bot) \sqsubseteq f(x) \sqsubseteq x. So xx is an upper bound of the chain, and μf⊑x\mu f \sqsubseteq x because μf\mu f is the least upper bound. Every fixed point is a pre-fixed point, and μf\mu f is itself a fixed point by part 2, so it is the least fixed point and the least pre-fixed point. ■\blacksquare

The dual. Apply the theorem to DD with the order reversed. Its least element is ⊤\top, its chains are the decreasing chains of DD, and their least upper bounds are the greatest lower bounds in DD.

A worked example. Take the recursive definition fact(n) = if n == 0 then 1 else n * fact(n - 1) on the natural numbers. Let DD be the set of partial functions from N\mathbb{N} to N\mathbb{N}, ordered by inclusion of their graphs, so g⊑g′g \sqsubseteq g' when g′g' agrees with gg wherever gg is defined. The least element is the empty function. A chain of partial functions agrees wherever two of them are defined, so the union of their graphs is a partial function, and it is the least upper bound. So DD is a cpo. The definition gives the function

Φ(g)(n)={1n=0,n⋅g(n−1)n>0 and g(n−1) defined,undefinedotherwise.\Phi(g)(n) = \begin{cases} 1 & n = 0, \\ n \cdot g(n - 1) & n > 0 \text{ and } g(n - 1) \text{ defined}, \\ \text{undefined} & \text{otherwise.} \end{cases}

Φ(g)(n)\Phi(g)(n) reads only one value of gg, so Φ\Phi is continuous: that value is already in some element of a chain. The iterates are Φ0(⊥)\Phi^0(\bot), defined nowhere, Φ1(⊥)={0↦1}\Phi^1(\bot) = \{0 \mapsto 1\}, Φ2(⊥)={0↦1,1↦1}\Phi^2(\bot) = \{0 \mapsto 1, 1 \mapsto 1\} and Φ3(⊥)={0↦1,1↦1,2↦2}\Phi^3(\bot) = \{0 \mapsto 1, 1 \mapsto 1, 2 \mapsto 2\}. By induction, Φk(⊥)\Phi^k(\bot) is the factorial function restricted to {0,…,k−1}\{0, \ldots, k - 1\}. Their union is the factorial function on all of N\mathbb{N}, which is μΦ\mu \Phi. Each iterate is what a program can compute with at most k−1k - 1 nested recursive calls.

Consequences

  • Finite height makes every monotone function continuous. If every chain in DD is eventually constant, its least upper bound is its last value, and a monotone ff maps it to the last value of the image chain. So the iteration stops after at most hh steps on a lattice of height hh. This is the case of the fixed point page and of the classic dataflow problems. On a CFG with nn blocks, the product lattice has height nhn h, which bounds the number of rounds of the maximal fixed-point solution.
  • Dataflow analysis. In the dual form, the maximal fixed-point solution is ⊓nFn(⊤)\mathop{\large\sqcap}_n F^n(\top), and the MOP-MFP coincidence theorem describes each iterate Fn(⊤)F^n(\top) exactly. Any fair order of updates, such as the worklist dataflow algorithm, reaches the same fixed point, because every value it computes stays above the greatest fixed point and it stops only at a fixed point.
  • Abstract interpretation. An abstract interpreter computes the least fixed point of an abstract transformer. On a lattice with infinite chains, such as the interval domain, the iteration from ⊥\bot may not stop, and a widening operator jumps ahead to a pre-fixed point. By part 3, any pre-fixed point is above the least fixed point, so the result is safe.
  • Recursion and loops. In denotational semantics, the meaning of a recursive function or a while loop is the least fixed point of a continuous function on partial functions, as in the factorial example. Recursion in the lambda calculus gets its meaning the same way.
  • Datalog. The least model of a Datalog program is the least fixed point of its immediate-consequence function on sets of facts, which keeps unions of chains. Semi-naive evaluation computes the Kleene iterates with less repeated work.
  • Process networks. The output of a Kahn process network is the least fixed point of the continuous function that the processes define on the histories of the channels.
  • Proof by fixed-point induction. Part 3 gives a proof rule: to show μf⊑x\mu f \sqsubseteq x, show f(x)⊑xf(x) \sqsubseteq x. Dataflow and abstract interpretation use it to check that a candidate result is safe without running the solver.

Tightness

Continuity is needed for the limit at ω\omega. Let D={0,1,2,…}∪{ω,ω+1}D = \{0, 1, 2, \ldots\} \cup \{\omega, \omega + 1\} with the usual order, so ω\omega is above every number and ω+1\omega + 1 is above ω\omega. Every chain has a least upper bound: an eventually constant chain has its last value, and a chain that grows without bound in N\mathbb{N} has ω\omega. Let f(k)=k+1f(k) = k + 1, f(ω)=ω+1f(\omega) = \omega + 1 and f(ω+1)=ω+1f(\omega + 1) = \omega + 1. Then ff is monotone, and the iterates are 0,1,2,…0, 1, 2, \ldots with least upper bound ω\omega. But f(ω)=ω+1≠ωf(\omega) = \omega + 1 \ne \omega, so the limit is not a fixed point. The least fixed point is ω+1\omega + 1. Here ff is not continuous: f(⨆kk)=ω+1f(\bigsqcup_k k) = \omega + 1 but ⨆kf(k)=ω\bigsqcup_k f(k) = \omega. For monotone functions in general, the iteration must go on through the ordinals; Cousot and Cousot (1979) gave this construction.

A least element is needed. Let DD be the integers ≤0\le 0 with the usual order. Every chain is bounded by 0 and has a least upper bound, but there is no least element. The identity function is continuous, every element is a fixed point, and there is no least fixed point.

Completeness is needed. Let D=ND = \mathbb{N} with ⊥=0\bot = 0, and f(k)=k+1f(k) = k + 1. The function keeps every least upper bound that exists, but the chain 0,1,2,…0, 1, 2, \ldots has none, and ff has no fixed point at all.

The iteration need not stop. Let D=[0,1]D = [0, 1], the real numbers between 0 and 1, and f(x)=(x+1)/2f(x) = (x + 1) / 2. DD is a cpo, ff is continuous, and the iterates 0,1/2,3/4,…,1−2−n0, 1/2, 3/4, \ldots, 1 - 2^{-n} never reach the least fixed point 1. They reach it only at the limit. The bound of hh steps needs finite height.

Knaster-Tarski is a different trade. The Knaster-Tarski theorem needs only monotonicity, but it needs a complete lattice and it gives the least fixed point as the meet of all pre-fixed points, a formula that does not suggest a computation. The Kleene theorem asks for more of the function and less of the order, and it gives a computation in ω\omega steps.

History

The theorem is named after Kleene because of his first recursion theorem (1952), which says that a recursive definition of a partial function has a least solution, the union of finite approximations. Tarski (1955) proved the existence of fixed points of monotone functions on complete lattices. In the 1970s, Scott made continuous functions on complete partial orders the basis of denotational semantics, and the iteration from ⊥\bot became a standard tool, both there and in the dataflow analysis of Kildall. Lassez, Nguyen and Sonenberg (1982) wrote a short history of these fixed-point theorems and of how they came to carry their usual names. Cousot and Cousot (1979) extended the iteration to monotone functions with ordinal steps.

References

  1. Jean-Louis Lassez, V. L. Nguyen and Elizabeth A. Sonenberg, Fixed point theorems and semantics: a folk tale, Information Processing Letters 14(3), 1982, 112-116, the whole note (the history of the fixed-point theorems used in semantics, and how the iteration theorem came to carry the names of Kleene and Tarski)
  2. Alfred Tarski, A lattice-theoretical fixpoint theorem and its applications, Pacific Journal of Mathematics 5(2), 1955, 285-309, Theorem 1 (fixed points of a monotone function on a complete lattice, the version without continuity)
  3. Patrick Cousot and Radhia Cousot, Constructive versions of Tarski's fixed point theorems, Pacific Journal of Mathematics 82(1), 1979, 43-57, the least fixed point of a monotone function as the limit of an iteration from the bottom element through the ordinals
  4. B. A. Davey and H. A. Priestley, Introduction to Lattices and Order, second edition, Cambridge University Press, 2002, Chapter 8 (fixpoint theorems, complete partial orders and continuous maps, and the iteration of a continuous map from the bottom element)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/XVZ2Y8/text.yaml