A small non-Turing-complete programming language
The set SLP of all Straight-Line programs is the smallest set which can be constructed inductively from the following BNF.
<program> ::= <instruction>
| <instruction> ";" <program>
<instruction> ::= <variable> ":=" <expression>
<expression> ::= <constant>
| <variable> "+" <variable>
| <variable> "*" <variable>
<variable> ::= "o"
| "i0" | "i1" | "i2" | ...
| "x0" | "x1" | "x2ʺ | ...
<constant> ::= "0" | "1" | "2" | ...
All programs P ∈ SLP model a function f : ℕk → ℕ. This function is calculated as follows:
- The variables
i0
,i1
, ... are input parameters, they have to be set when the program is run. - All other variables are initialised to
0
. x := c
assigns a constantc
to a variablex
.x := a + b
andx := a * b
assign the sum/product of variablesa
andb
to a variablex
.- The function's result is the content of the variable
o
.
The following program (source code here) calculates the function f(x, y) = x²y² + x²:
x0 := i0 * i0;
i1 := i1 * i1;
o := x0 * i1;
o := o + x0