P′′ (P double prime
) is a primitive computer
programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
created by
Corrado Böhm
Corrado Böhm (17 January 1923 – 23 October 2017) was a Professor Emeritus at the University of Rome "La Sapienza" and a computer scientist known especially for his contributions to the theory of structured programming, constructive mathemati ...
[Böhm, C.: "On a family of Turing machines and the related programming language", ICC Bull. 3, 185-194, July 1964.][Böhm, C. and Jacopini, G.: "Flow diagrams, Turing machines and languages with only two formation rules", CACM 9(5), 1966. (Note: This is the most-cited paper on the ]structured program theorem
The structured program theorem, also called the Böhm–Jacopini theorem, is a result in programming language theory. It states that a class of control-flow graphs (historically called flowcharts in this context) can compute any computable function ...
.) in 1964 to describe a family of
Turing machine
A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
s.
Definition
(hereinafter written P′′) is formally defined as a set of words on the four-instruction alphabet
, as follows:
Syntax
#
and
are words in P′′.
# If
and
are words in P′′, then
is a word in P′′.
# If
is a word in P′′, then
is a word in P′′.
# Only words derivable from the previous three rules are words in P′′.
Semantics
*
is the tape-alphabet of a
Turing machine
A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer algori ...
with left-infinite tape,
being the ''blank'' symbol, equivalent to
.
* All instructions in P′′ are
permutation
In mathematics, a permutation of a set is, loosely speaking, an arrangement of its members into a sequence or linear order, or if the set is already ordered, a rearrangement of its elements. The word "permutation" also refers to the act or proc ...
s of the set
of all possible tape configurations; that is, all possible configurations of both the contents of the tape and the position of the tape-head.
*
is a
predicate
Predicate or predication may refer to:
* Predicate (grammar), in linguistics
* Predication (philosophy)
* several closely related uses in mathematics and formal logic:
**Predicate (mathematical logic)
**Propositional function
**Finitary relation, o ...
saying that the current symbol is not
. It is not an instruction and is not used in programs, but is instead used to help define the language.
*
means move the tape-head rightward one cell (if possible).
*
means replace the current symbol
with
, and then move the tape-head leftward one cell.
*
means the
function composition
In mathematics, function composition is an operation that takes two functions and , and produces a function such that . In this operation, the function is applied to the result of applying the function to . That is, the functions and ...
. In other words, the instruction
is performed before
.
*
means iterate
in a
while loop
In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The ''while'' loop can be thought of as a repeating if statement.
Overview
The '' ...
, with the condition
.
Relation to other programming languages
* P′′ was the first "
GOTO
GoTo (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function ca ...
-less" imperative
structured programming
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection ( if/then/else) and repetition ( ...
language to be proven
Turing-complete
In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be used to simulate any Tur ...
* The
Brainfuck
Brainfuck is an esoteric programming language created in 1993 by Urban Müller.
Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing com ...
language (apart from its I/O commands) is a minor informal variation of P′′. Böhm gives explicit P′′ programs for each of a set of basic functions sufficient to compute any
computable function
Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
, using only
,
and the four words
where
with
denoting the
th
iterate
Iteration is the repetition of a process in order to generate a (possibly unbounded) sequence of outcomes. Each repetition of the process is a single iteration, and the outcome of each iteration is then the starting point of the next iteration. ...
of
, and
. These are the equivalents of the six respective Brainfuck commands , , , , , . Note that since
, incrementing the current symbol
times will wrap around so that the result is to "decrement" the symbol in the current cell by one (
).
Example program
Böhm
gives the following program to compute the predecessor (''x''-1) of an integer ''x'' > 0:
:
which translates directly to the equivalent
Brainfuck
Brainfuck is an esoteric programming language created in 1993 by Urban Müller.
Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing com ...
program:
> ˆ’[<[<−<.html"_;"title="[<.html"_;"title="ˆ’[<[<">ˆ’[<[<−<">[<.html"_;"title="ˆ’[<[<">ˆ’[<[<−<+
The_program_expects_an_integer_to_be_represented_in_''bijective_numeration.html" ;"title=".html"_;"title="ˆ’[<[<">ˆ’[<[<−<.html" ;"title="[<.html" ;"title="ˆ’[<[<">ˆ’[<[<−<">[<.html" ;"title="ˆ’[<[<">ˆ’[<[<−<+
The program expects an integer to be represented in ''bijective numeration">bijective base-k'' notation, with
encoding the digits
respectively, and to have
before and after the digit-string. (E.g., in bijective base-2, the number eight would be encoded as
, because 8 in bijective base-2 is 112.) At the beginning and end of the computation, the tape-head is on the
preceding the digit-string.
References
Weblinks
''P′′Online interpreter'' Demonstrating the iterative 99 Bottles of Beer song construed in 337568 P′′ instructions.
{{DEFAULTSORT:P
Models of computation
Academic programming languages
Experimental programming languages