I was thinking the other day, and it occurred to me that computer programs all seem to be representable as a graph (an abstract syntax tree for example), or, once common expressions are combined, an abstract syntax graph.

It occured to me that perhaps any computer program can be represented as one of these graphs + evaluation semantics attached to it. I'm curious if anyone knows if this is universally true for a turing machine (I assume you can get a potentially infinite graph, but this is math so that's OK). I've been pondering on it and a lot of things like strong type systems and such fit well in this abstraction (they impose structural constraints on the graph). You might even be able to consider the type system its own program and represent that as a different graph + evaluation semantics operating on the program graph...

Just curious if this is a known equivalence or not.

  • $\begingroup$ It's a pretty basic concept for optimizing compiler design. $\endgroup$
    – keshlam
    Commented May 14, 2014 at 23:08
  • 1
    $\begingroup$ I can represent any math equation by graph. What is the point? $\endgroup$
    – Val
    Commented May 15, 2014 at 9:22
  • $\begingroup$ a rather bizarre answer: continuous-time quantum random walks are known to be capable of universal computation--in fact so are adiabatic quantum computers. even circuit diagrams are technically graphs with vertices acting as functions, and those are also capable of universal computation. not quite what you were thinking of, it seemed :) $\endgroup$
    – hadsed
    Commented May 17, 2014 at 14:22

2 Answers 2


I don't know if it's a particularly well known equivalence, but it's fairly simple when you think about it.

Turing Machines are known to be equivalent to the (untyped) Lambda Calculus. The Church-Turing thesis proposes that this is they are the most powerful form of computation.

The Lambda Calculus is a syntactically defined term re-writing system. Essentially, it's a very simple programming language. So, it can be parsed into an abstract syntax tree (graph).

So, we have:

  1. Every computer program is representable in the untyped lambda calculus.
  2. Every lambda calculus program can be parsed into an abstract syntax tree

This means that every computer program can be represented as a Lambda Calculus abstract syntax tree.

These trees might not have much in the way of interesting properties. For example, they're definitely not unique i.e. two different trees can perform identical computations.

  • 1
    $\begingroup$ You could also take a Turing-complete general purpose (preferably structured) programming language. Also, in static analysis programs are represented as graphs with cycles. $\endgroup$ Commented May 14, 2014 at 17:53

yes there is a close connection between graphs and programming in quite a few areas. the simplest way to picture this is as loops, branch, or subroutine entry points in code as destinations in a directed graph. see also

see also Visual Programming languages cs.se


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.