I am trying to get a big picture on the importance of least fixed point (lfp) in program analysis. For instance abstract interpretation seems to use the existence of lfp. Many research papers on program analysis also focus heavily on finding least fixed point.

More specifically, this article in wikipedia : Knaster-Tarski Theorem mentions that lfp are used to define program semantics.

Why is it important? Any simple example helps me. (I am trying to get a big picture).


I think my wording is incorrect. I donot challenge the importance of lfp. My exact question (beginner) is: How does computing lfp help in program analysis? For e.g., why/how abstract interpretation uses lfp? what happens if there is no lfp in the abstract domain?

Hopefully my question is more concrete now.

  • $\begingroup$ @D.W. This is a beginner question in program analysis. I debated myself several times before posting the question if it looks too vague. What I am looking for is: What role does lfp play in program analysis (It sure is important, but how?). I am looking for an answer that does not delve into lot of math details. I think the wording in my question is also not clear. I'll edit the question. $\endgroup$
    – Ram
    Sep 5, 2015 at 14:35
  • $\begingroup$ @D.W. I agree this may not be well-researched question. However whenever I keep reading papers, lot of math detail and I quickly loose the big picture. For instance, more concretely, this paper [Widening for Control-Flow] (berkeleychurchill.com/research/papers/vmcai14.pdf) appears very abstract to me. It directly appeals to computing least fix point. Most of the papers in program analysis seem to be concerned with this question in similar lines. I lost the big picture. I'll be happy to know why computing lfp is important. $\endgroup$
    – Ram
    Sep 5, 2015 at 14:40

2 Answers 2


Any form of recursion or iteration in programming is actually a fixed point. For instance, a while loop is characterized by the equation

while b do c done  ≡  if b then (c ; while b do c done)

which is to say that while b do c done is a solution W of the equation

W  ≡  Φ(W)

where Φ(x) ≡ if b then (c ; x). But what if Φ has many fixed points? Which one corresponds to the while loop? One of the basic insights of programming semantics is that it is the least fixed point.

Let us take a simple example, this time recursion. I will use Haskell. The recursive function f defined by

f :: a -> a
f x = f x

is the everywhere undefined function, because it just runs forever. We can rewrite this definition in a more unusual way (but it still works in Haskell) as

f :: a -> a
f = f

So f is a fixed point of the identity function:

f ≡ id f

But every function is a fixed point of id. Under the usual domain-theoretic ordering, "undefined" is the least element. And indeed, our function f is the everywhere undefined function.

Added on request: in the comments OP asked about the partial order for semantics while loops (you presumed it was a lattice but it need not be). A more general question is what is the domain-theoretic interpretation of a procedural language which can manipulate variables and has the basic control structures (conditionals and loops). There are several ways of doing this, depending on what exactly you want to capture, but to keep things simple, let's assume that we have a fixed number $n$ of global variables $x_1, \ldots, x_n$ that the program can read and update, and nothing else (no I/O or exceptions, or allocation of new variables). In that case a program can be seen as a transformation of the initial state of the variables to the final state, or the undefined value if the program cycles. So, if each variable holds an element of a set $V$, a program will correspond to a mapping $V^n \to V^n \cup \{\bot\}$: for every initial configuration $(v_1, \ldots, v_n) \in V^n$ of the variables, the program will either diverge and yield $\bot$, or it will terminate and produce the final state, which is an element of $V^n$. The set of all maps $V^n \to V^n \cup \{\bot\}$ is a domain:

  • we use the flat ordering on $V^n \cup \{\bot\}$ which has $\bot$ at the bottom and all the elements of $V^n$ "flat" above it, and then $V^n \to V^n \cup \{\bot\}$ is ordered pointwise,
  • the least element is the function which always maps to $\bot$, corresponding to the program while true do skip done (and many others),
  • every increasing sequence has a supremum

Just to give you an idea of how this works, the semantics of the program

x_1 := e

would be the function which takes as input $(v_1, \ldots, v_n) \in V^n$, calculates the value $v_e$ of the expression e in state $(v_1, \ldots, v_n)$, and returns $(v_e, v_2, \ldots, v_n)$.

  • 1
    $\begingroup$ +1 for the while example. However, I am a bit confused. But what if Φ has many fixed points? While I understand the fixed point equation, in this context, does W \in L? How do we define lattice here? I appreciate your further elaboration on that. $\endgroup$
    – Ram
    Sep 5, 2015 at 20:56
  • $\begingroup$ In the above comment, I am using "L" to stand for a lattice (or a poset) $\endgroup$
    – Ram
    Sep 5, 2015 at 21:03
  • $\begingroup$ I amended the answer. $\endgroup$ Sep 5, 2015 at 21:12
  • $\begingroup$ Thanks for the update. I especially appreciate it because it gave me a different view of looking at programs. I am now reading "Fixed point Theory" from "Semantics with applications: A formal introduction" by Nielson, which completed the view on constructing a lattice out of partial functions for IMP language. $\endgroup$
    – Ram
    Sep 5, 2015 at 22:29

Here is the intuition: least fixed points help you analyze loops.

Program analysis involves executing the program -- but abstracting away some details of the data. This is all good. The abstraction helps the analysis go faster than actually running the program, because it allows you to ignore aspects you don't care about. For instance, that's how abstract interpretation works: it basically simulates execution of the program, but only keeping track of partial information about the state of the program.

The tricky bit is when you get to a loop. The loop could execute many, many times. Typically, you don't want your program analysis to have to execute all of those iterations of the loop, because then the program analysis will take a long time ... or might not even terminate. So, that's where you use a least fixed point. The least fixed point basically characterizes what you can say for sure will be true after the loop finishes, if you don't know how many times the loop will iterate.

That's what the least fixed point is used for. Because loops are present throughout programs, least fixed points are used throughout program analysis. Least fixed points are important because loops are everywhere, and it's important to be able to analyze loops.

Incidentally, recursion and mutual recursion are just another form of loop -- so they too tend to be handled with a least fixed point.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.