[2][3] A Janus inverter and interpreter is made freely available by the TOPPS research group at DIKU.
As a reversible programming language, Janus performs deterministic computations in both forward and backward directions.
An extension of Janus features procedure parameters and local variable declarations (local-delocal).
[3] Additionally, other variants of Janus support dynamic data structures such as lists.
A Janus program is a sequence of one or more variable declarations, followed by a sequence of one or more procedure declarations: Note, Janus as specified in the 2007 paper,[2] allows zero or more variables, but a program that starts with an empty store, produces an empty store.
Note however, that the Janus interpreter hosted by TOPPS uses regular two's complement 32-bit integers, so all values there are between −231 = −2147483648 and 231 − 1 = 2147483647.
(Since all values in Janus are integers, the usual C-semantics that 0 indicates false are employed.)
An additional
There are no parameters to procedures, so all variable passing is done by side-effects on the global store.
An expression is a constant (integer), a variable, an indexed variable, or an application of a binary operation: The constants in Janus (and the Janus interpreter hosted by TOPPS) have already been discussed above.
Assuming the following prelude to the procedure, we end up with the 4th Fibonacci number in x2: Note, our main would have to do a bit more work if we were to make it handle n≤2, especially negative integers.
The inverse of fib is: As you can see, Janus programs can be transformed by local inversion, where the loop test and assertion are swapped, the order of statements is reversed, and every statement in the loop is itself reversed.