go-v.orgcodex
Menu
Page tools

codex · Philosophy

LOOP (programming language)

LOOP is a simple register language designed to precisely capture the primitive recursive functions. The language is derived from the counter-machine model. Like the Counter machines the LOOP language comprises a set of one or more unbounded registers, each of which can hold a single non-negative integer. A few arithmetic instructions operate on the registers: inc x (increment), dec x (decrement: max⁡(0,x−1)), x = 0 (clear), and x = y (copy). The only control flow instruction is LOOP x: .... It causes the instructions within its scope to be repeated x times. In contrast to GOTO programs and WHILE programs, LOOP programs always terminate. The running time is known in advance.

Therefore, the set of functions computable by LOOP-programs is a proper subset of computable functions (and thus a proper subset of the functions computable by WHILE and GOTO programs). The LOOP language admits several variants, distinguished by their set of basic instructions. Four such variants, L0 – L3, are distinguished in this article. Despite differences in syntactic convenience and loop-nesting depth, all variants compute exactly the primitive recursive functions. At shallow nesting depths, the choice of basic instructions affects which functions are reachable.

The simple functions are exactly the functions computable at depth 1 in L1; the Presburger-definable functions are exactly the functions computable at depth 1 in L3; the Kalmár elementary functions are exactly the functions computable at depth 2 in L1, L2 and L3. From depth 3 onward all variants agree. An example of a total computable function that is not LOOP-computable is the Ackermann function.

Wikipedia contributors, "LOOP (programming language)", Wikipedia, revision 1386218534, retrieved 20 November 2026, source, CC BY-SA 4.0.

More Philosophy · Search the codex