Valid HTML 4.01!
Valid CSS!

The Unification Algorithm implemented in Javascript

The unification algorithm is used in Prolog to infer queries from a knowledge base using substitutions or for type inference in programming languages. I am a student at the Berne University of Applied Sciences. In the course Theoretical Computer Science we got the exercise to implement the unification algorithm in a programming language of our choice. I choose Javascript. This page is the result of my assignment. Please click here to read more about my choice of Javascript as a programming language (and about the unification algorithm). It seems that the programming language of the Web is being underestimated as a "real" or "academic" programming language. Did you know that Javascript is a very functional programming language, for example?

Try it out

You can enter two rules and find the unifier. The calls of Unify and Unify-Var are logged so you can see how the algorithm works. Please click here for examples of rules and a rule syntax overview (Opens a popup).


Unification mode (What's the difference?)
Use values and variables Use only variables

Start the Unification algorithm...

Unification result:

Call logs:

The source code

The source code of the Javascript function implementing the Unification algorithm and enabling the user interface to the algorithm. Please click here to get the source code. And here you find a high-level overview about the implementation in Javascript.

Credits, Comments

Written by nalpdii, last change

The page only works well with standards conforming browsers with Javascript enabled.