P′′
| P′′ | |
|---|---|
| Paradigm | Imperative, structured |
| Designed by | Corrado Böhm |
| First appeared | 1964 |
| Typing discipline | untyped |
| Dialects | |
| Brainfuck | |
| Influenced | |
| Brainfuck | |
P′′ (P double prime)[1] is a primitive computer programming language created by Corrado Böhm[2][3] in 1964 to describe a family of Turing machines.
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 with left-infinite tape, being the blank symbol, equivalent to .
- All instructions in P′′ are permutations 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 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 other words, the instruction is performed before .
- means iterate in a while loop, with the condition .
Relation to other programming languages
- P′′ was the first "GOTO-less" imperative structured programming language to be proven Turing-complete[2][4]
- The Brainfuck 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, using only , and the four words where with denoting the -th iterate 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[2] gives the following program to compute the predecessor of an integer :[5] where (the -th iterate of ),
The program expects an integer to be represented in 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 , as .) At the beginning and end of the computation, the tape‑head is on the preceding the digit‑string. The output is , the bijective base‑2 encoding for 7. Here, .
This example translates directly to the equivalent Brainfuck program:
>[>]<[−[<[<]]−<]>+
Notes
- ^ GitHub 2021.
- ^ a b c Böhm 1964.
- ^ Böhm & Jacopini (1966) (Note: This is the most-cited paper on the structured program theorem.)
- ^ Böhm & Jacopini 1966.
- ^ R(R)(λRλRλ)((λRλR)((λRλRλ)(λRλRλ))(λRλR)(λRλRλ))R(λR)
References
- Böhm, Corrado (1964). "On a family of Turing machines and the related programming language" (PDF). ICC Bulletin. 3: 185–194.
- Böhm, Corrado; Jacopini, Giuseppe [in Italian] (May 1966). "Flow Diagrams, Turing Machines and Languages with Only Two Formation Rules". Communications of the ACM. 9 (5): 366–371. CiteSeerX 10.1.1.119.9119. doi:10.1145/355592.365646. S2CID 10236439.. Republished in Yourdon 1979, pp. 13–25
- GitHub (4 September 2021). "PDBL: A tool for Turing machine simulation". GitHub.
- Yourdon, E. N., ed. (1979). Classics in Software Engineering. New York, NY: Yourdon Press. pp. xi, 424. ISBN 978-0-917072-14-7. LCCN 79-63449.
External links
- Barendregt, Henk (6 November 2019). "Gems of Corrado Böhm" (PDF). Radboud University Nijmegen. Retrieved 6 December 2025.
- Elsner, Mathias. "Esoteric Programming Languages — P′′ in ›Production Mode‹". www.mathiaselsner.de. Retrieved 6 December 2025.: Demonstrating the iterative 99 Bottles of Beer song construed in 337568 P′′ instructions.
- Esolangs Wiki. "P′′". Esolangs. Retrieved 6 December 2025.