Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

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.

share|improve this question
    
It's a pretty basic concept for optimizing compiler design. –  keshlam May 14 at 23:08
    
I can represent any math equation by graph. What is the point? –  Val May 15 at 9:22
    
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 :) –  hadsed May 17 at 14:22

2 Answers 2

up vote 9 down vote accepted

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.

share|improve this answer
1  
You could also take a Turing-complete general purpose (preferably structured) programming language. Also, in static analysis programs are represented as graphs with cycles. –  bellpeace May 14 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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