Structured program theorem

From Wikipedia, the free encyclopedia
Jump to: navigation, search

The structured program theorem, also called Böhm-Jacopini theorem,[1][2] is a result in programming language theory. It states that a given class of algorithms can compute any computable function if those algorithms combine subprograms in only three specific ways. In other words, any algorithm can be expressed using only three control structures. They are

  1. Executing one subprogram, and then another subprogram (sequence)
  2. Executing one of two subprograms according to the value of a boolean expression (selection)
  3. Executing a subprogram until a boolean expression is true (iteration)

Note that these can be represented, respectively, by the concatenation, union, and star operations of a regular expression.

The theorem is credited to a 1966 paper by Corrado Böhm and Giuseppe Jacopini. However, David Harel traced its origins to the 1946 description of the von Neumann architecture and Stephen Kleene's normal form theorem[citation needed].

The Böhm-Jacopini proof describes how to construct a structured flow chart from an arbitrary chart, using the bits in an extra integer variable to keep track of information that the original program represents by the program location. This construction was based on Böhm's programming language P′′. The Böhm-Jacopini proof did not settle the question of whether to adopt structured programming for software development, partly because the construction was more likely to obscure a program than to improve it. On the contrary, it signalled the beginning of the debate. Edsger Dijkstra's famous letter, "Go To Statement Considered Harmful," followed in 1968. Subsequent proofs of the theorem addressed practical shortcomings of the Böhm-Jacopini proof with constructions that maintained or improved the clarity of the original program.[3]

Application to Cobol[edit]

In the 1980s IBM researcher Harlan Mills oversaw the development of the COBOL Structuring Facility, which applied a structuring algorithm to COBOL code. Mills's transformation involved the following steps for each procedure.

  1. Identify the basic blocks in the procedure.
  2. Assign a unique label to each block's entry path, and label each block's exit paths with the labels of the entry paths they connect to. Use 0 for return from the procedure and 1 for the procedure's entry path.
  3. Break the procedure into its basic blocks.
  4. For each block that is the destination of only one exit path, reconnect that block to that exit path.
  5. Declare a new variable in the procedure (called L for reference).
  6. On each remaining unconnected exit path, add a statement that sets L to the label value on that path.
  7. Combine the resulting programs into a selection statement that executes the program with the entry path label indicated by L
  8. Construct a loop that executes this selection statement as long as L is not 0.
  9. Construct a sequence that initializes L to 1 and executes the loop.

Note that this construction can be improved by converting some cases of the selection statement into subprocedures.

See also[edit]



  1. ^ "The Böhm–Jacopini Theorem Is False, Propositionally - Springer". Retrieved 2013-08-24. 
  2. ^ "CSE 111, Fall 2004, BOEHM-JACOPINI THEOREM". 2004-11-22. Retrieved 2013-08-24. 
  3. ^ "CSE 111, Fall 2004, BOEHM-JACOPINI THEOREM". 2004-11-22. Retrieved 2013-08-24.