On Folk Theorems
David itarel
IBM Thomas J Watson Research Center
Yorktowr~ Heights, New York
- - ~ i f e d a are sug\gesied fbr gg a we prefer and wit~ adopt the second approach. Accord-
statement is a folk theorem~ The ideas are t:he~ ingly, in Secdon 3 we pro;sent strong evidence ~o the
illustrated wi~h a detailed example from the theory of effect that a particular theorem about flowcharts is a t~lk
program.mi~g. theorem.
Key Words and Phrases: flowchart, folk theorem,
stn~¢tured pr~gammlng, white-programs
CR Categories: 2,1, 4,2, 5~:N 2. What is a Folk Theorem?
379
c~f Volume '23
~he ACM N~mbef 7
4 e 6 n m o n of/}d£~o~: quo:ed s: ~h¢ s:a:":: k~af:e:.uamong
c o m m o n peo[:@" imphe> p,%Aarny. "b<:heA+ }e~:ends
a:~d :;us:os:~s ~ ~nd:ca:es a n o n y tne:.~,s ~::::h w'q::p+ a n d ~'m:.+ : ~::~,:s, b~{CC{:q. +++ :~+>~: :%:' H14:1~1 : hc :>4::: ot+~ )y. :{
d@onaF+ adds. {he d:memo~on o} :H::¢ V:¢ CAM~P{ IH:d +::: $::':i:U+: ::lC{:/h H: {}Wig ~:¢ ~k, ,+, {~
v~ he:: :q, :~g :o da+J,, @e::~e:hr::e:~:~pc<{>,<d {:a>&:: } n
@era f:om @ e :eMma: o{ :ell:rig:ale:.~4rid rag:rig ~,"ng>
:o :ha: of p:o~:::g @eo:en::,: :{ :shou:d h< nosed :h~:~:
neHhe: one <q' {h¢:~: :> :o be t & c n m at', s¢n<: :::(::4:
:,once The p<>p:Aari:) of a thecwen: ::ex:d so: mx<.,~<:rd~,
b~: ¢s~abhshed b) ;: he,ad ~,oun: ,of ~:e~'a:cher~ :h,> hay{:
used {',rquo:ed H. :ho~:h {~::~::h:s£:a:ed m :he :~e::
se<:th2:) s:a:~sdcs can be h d p G i R4:he< :{ usua: b sho::~
::p when o:e ::eat ask:n: ~ hm~dfi.A ofco:}e;:guex whe:h~::
{he s:a:eme~:: + ~nm. WiJ~ ~he "+:w+ he+wd :<>{ne~hmg "+:'c.'~] {(:k ::::'<::<qy we:: b: :cpRv, cd ,..'~¢'~:he :,e:~o a~L~H:
hke :ha+ heR,re" :<x>k on h~ f:H~< :he :x:r:~on que~noned
wi{~ ~s~m::v be ab}e ~o gave :.he <or:w{ :nss~e~ a n d mo:q <on:~p}c:¢~ +u>{~fied .:,~d ~hou{d tw +v~a:-dcd, ,,> par: o+
ofle:a he w{l be a b k ~o ~<x, mDw:y ~{ ,a'i~ha p~.w+f Rx'x :he C::~:::f~ :}Hg a m a : c : : r hl~{o~:a¢1 :n:\ {h~:% ::oco;:::e
Ofkon ~he :heo+'em is qe#~ed by v+~ue of h b<'~s~ ~er y
s:mila~ +x>~nother £a{eme{~: which > he:rag p:o~ed+ This hob{> ~:~ch ~+o, ~:an:p coHeca+n}{
bring:+ +a.s~o :he +R4{,en have many vem:oa::s++phoneme+ }{esc~ ~h:ie :he p~>:>,,au(h-+:£¢ pro{~cr::es +ecru :v ~,
non.. which :s ck+,-se~yre:aRx+ ~o pc~p@ar+:y Sure:y+ w::h ~e<ess.~ws :rid a4~[l~cie::I . t ~ + n d i h o ~ , - ~%.>~' o t~he~w:;s:.:n {0 b<
~he size of our :eseareh comma.bait: k~@'~gwha: ~: as.+sheL
co:::pac{ s:a:ement's of {heovems :end :o be ~e.memb~+red
even by pmop:e no: +aorkmg in {he a d u a : area ++~ +e~ea+~.,h
to the Theorem or its parts, we have found (4 A 5) + (2 outgoing edge and test nodes have two, labeled 1 and 0.
A 2(;)) + (2 A 2 A l) printed occurrences of its proof; '~ There is one START node with no incoming edges and
which evaluates to 27, 36, or 64, depending, respectively, one outgoing edge, and at least one STOP node with no
upon whether "A" is interpreted as "max", " + ' , or outgoing edges. An interpretation I of a flowchart F
" × ' . These proof!s, which span forty-four years, also consists of a set of domains, an appropriate association
span the complete spectrum of recognized scientific lit- of domains with the variables of F, and an appropriate
erature: textbooks, monographs, survey articles, journal association of f~nctions and predicates over various
papers, conference proceedings, newsletters, theses, tech- cross-products of the domains with the fimction and
nical reports, lecture notes, letters to editors, and self- predicate symbols of F. Given an interpretatmn I and
referemial folk tales~ initiM values for the variables appearing in F, the way in
Quile a fblk theorem, it seems. which F proceeds to compute its values is straightforward
and is assumed to be known m the reader. Denote by' F~
the lunction, associating with each set of input vMues for
4. The Future F its output values, or a special "undefined" symbol if F
We have postulated the appropriately adapted prop- does not terminate. Also, let ash(F) and test(F) be the
erties of popularity, age, and anonymous authorship as sets of assignments and tests appearing in F.
criteria fbr determining if a statement is a tblk theorem, Next, we define an appropriate set ofwMle-programs,
and have illustrated by exhibiting a theorem:, the folkish- relative to sets of assignments and tests A and T. Define
hess of which seems to be beyond doubt. WH(A, T) as the least set such that:
As lbr the ff~ture, we envision three possible direc- (1) AC WH(A, T)
tions for further research: (2) if W~, V¢~ E WH(A, T) and P E T, then
(1) Compiling an encyclopedic list of folk theorems in (i) (W~; W~) E WH(A, T),
computer sdence. (it) ff P then W:1 else W~. E WH(A, T), and
(2) Investigating the related concepts of folk definition (iii) while P do W~ E WH(A, T).
andfi)lk technique (that is, proof=technique)~ Again, given an appropriate interpretation and initial
(3) Showing that folk facts such as P # NiP are fotk values for the variables appearing in a while-program W,
theorems~ the standard method of defining the computation of" W
is assumed to be knowm We use Wi simila@ as with
5. Appetldix flowcharts. Let WHdA, T) be the set of those elements
of WH(A, T) which contain at most one occurrence of
First, some definitions. Aflowehart is a finite directed wMie-do,
graph with nodes l a d l e d either with an assignment of Now. to be able to rigorously state the Boolean
the tbrm x ~- f(~/7) for vafiaNe x, function symbol t: and version of our Theorem. we let
vector of variables j~ or with a test which is a Boolean- Basra F) = ash(F) U { p~ ~- true. p~ ~-. r i s e }. I ~ t < w.
combination of e×pressions of the fom~ p ( f ) fi:~rpredicate
symbol p and vector j~\ Assignment nodes have one and
we would greatly appreciate poimer~ te ~ho~se¢~t~r~aces of preo£~ Btest ~ the set of Boolean combinations of tests m test(Fj
we might ha;'e mitred ia our ignor~nce~ia oui' haste, or e~herw~se, and expressions of the tbrm p~?. for t ~ i < ~.
Commurficafi~ns J u l y ~980
of V o l t , m e 23
the ACM Nu,mbe~ 7
Fig. 2. Cooper's Global Proof.
/ /
Fig. 3. Elgot'sProof.
where pl, p2 . . . are new variables and F is an arbitrary In order to illustrate the B6hm and Jacopini [15] A
flowchart. An interpretation is called nice if the pi range Mirkowska [70] "local" proof, we provide one of the
over the domain (true, false} and the test pi? is true (i.e., transformations of Mirkowska [70]:
evaluates to 1) iff the value of pi is true. Denote the set
while Pl do (Wg while P2 do W2)
of nice interpretations by NICE. Then the Boolean ver-
sion o f our Folk Theorem states:
(*) (VF) (3W E WH, (Basn(F), Btest(F)))
"pl ~-- Px"; pz ~-- false; while (pl V p2) do (if p2 then W2 else W1; "p2
(VI ~ NICE) (F, = WO. ~- e2"; ','pi "~- Pi"),
386 Communications , July 1980
of Volume 23
the ACM Number 7
where, e.go "'p: .......
P " >4ands tbr tf P~ ¢hen p~ ........tn, e As aa ilh>{ration of the {[331 ,./ {231) /' ([2~ V [38]) A
else p: ..... false {42] proof of tbi.~ver~don+ we provide the ~rans%rmafion
of Iliro e ~nd Oya {42] analogow, ~o that of Mirkowe, ka
(~.×~per':, global proof I22] proceeds a/~ tbllows: (}ive~
[70] given a~xvee:
a llowcharl {;~ denote the axs,ignmen: r~odes of F in m:'ne
arbitral T, b:a~ fixed order by o,,'n . . . . a ; < , and the test
node> s~mda:'ly by rose,,, . . . . to.re..... Think of alt {he
S T O P taxies a~ b~:ing n:m:bered rn + ]. }"or each I :~; a
5 n te~ ne.~¢(i) be she ~::bscrip: cor:'esponding So the ~ ....f; g P~ th¢:t~ Wi; ~hlfe ¢J4~}{ P~ ~:h~g~W e~*~ iii .....2 if P~
node adjaceru So ax< (by it5 outgoing edge) and f'or each {hera W~+
~ + t ~:: i ~ m let wue(i) and/}d.~e(i) be she ~ubscrip:~s
correG~onding ~o {he node:~, adjacent So to.< (by the i and where k is the vector o f aI{ va:lable:~ appearing in the
0 outgoing edges, respectively). Let i~ be ~he s:.~v;cript original F,/~ is a vector of new variable:< and P~ is ~he
corresp,.,r}di::g :o the node a<:tjacem So she S T A R T node, result of sub:stimting she ~/s for ~he x% in P Here° fbr
As:tutor now thin a new variable B rar~ges over file set clarity, the clause else 2 +.--.-2 has b<ve~ omit~e,d.
{l, 2 .... m + 1}, and that we have assignments g ...... i
and tests g +~ i? fbr each i in that so< with the meaning Received tW7% ~evi,~d a n d accepted 2gJ0
obvious, is should be clear that B can be replaced by
[ log m ] + I Boolean vafiable:~ encoding the val:~e o f B, Acknow[edgmems We are hTdebted ~0 N Pippenge~-
with B ~...-i and B = i? being replaced by the appropriate t\;',r helpful discussions aN?ut ffAk theorems i~ getters]
sequences of m<signments and conjunctions o f te~:~ and about the one described in Section 3 m par~ic~ta~
The white.-program W G:: W H d B a x n ( F l , Bge':g{F)) Ak~:~,, thaeks go to M.I the people we have pestered
which is equivalent to F in the sense of (~), is Nve~ recently with questions aba:mt folk (~eorerms and trans-
{using :he obvious translation into wbile-lbrm) by the lations l¥om flowcharts to ~bt|e's; m a y this. work help
flowchart in Figure 2, erase the p~?sded lc~oks we often saw o~ their facee~ as a
To illustrate Elgofs proof' {32]. we will ::or provide a rea~flL
rigorous definition of his multiwire flowchart.s, but :rust
that the reader will be able to gather aa much as is R
L A : ~ J. U~ t:m~ge de pr%ramma::~n ~msasb~ch,eme.a~. Re~'.
aee;ded from the folIowiag. For positive integers j and p
where j :~ p, the 'errtrial scheme j / ' o f [32] is simNy she
"'cable" of width p wish all but :he j'th compvment ~o "wbi~e- p~cVg~am~~a ICgbe~: ~rg~: 7L }97L pp. ~47,-i52,
disconnected:
ak Baker~8.5;. An algorithm 1:orsm~ae~nng~%weEam.J. ACM 2~
: i+: j j+: p (;Jan. ]977), 9$-,{20.
5. Baker.B.S. amJ Kes~r~ju, SR. A e v m ~ n ~ m of m~al;~k*:~¢~
break ~ d ~mx{~a{emerds..st A CM 26, ~ {3~ty ~¢d%,55S.-Pg%.
6. B oL {~v~Bgm~oa~o(peo~r~m of ipmg.~'am~by
(YI)(F, ,~ W 0.
ef V~m~e 23
~.b~ACM N~mb~ "r
18. Burks, A.W., Goldstine, H.H., and von Neumann, J. Preliminary 50. Kleene, S.C. Introduction to Metamathematics. Van Nostrand
discussion of the logical design of an electronic computing Co., New York, 1952.
instrument, 1946. In J. yon Neumann, Collected Works, Vol. V, A.H. 51. Kleene, S.C. General recursive functions of natural numbers.
Taub, Ed., MacMillan, New York, 1963, pp. 34-79. Math. Annalen 112 (1936), 727-742.
19. Chandra, A.K. Degrees of translatability and canonical forms in 52. Knuth, D.E. Structured programming with go to statements.
program schemas. Proc. 6th ACM(SIGACT) Syrup, on Theory of Comptng. Surv. 6, 4 (Dec. 1974), 261-301.
Comptng., 1974, pp. 1-12. 53. Knuth, D.E., and Floyd, R.W. Notes on avoiding "go to"
20. Clark, K., and Cowell, D. Programs, Machines. and Computations: statements. Inform. Processing Letters' 1, (t971), 23-3 i.
An Introduction to the Theory of Computing. McGraw-Hill, New 54. Kosaraju, S.R. Analysis of structured programs. Z of Comptr.
York, 1976. and Syst. Sciences 9, (1974), 232-255.
21. Cohen, A.T., and Levi, L.S. Structured flowcharts for 55. Kreczmar, A. Effectivity problems of algorithmic logic. In Annal.
multiprocessiug. Comptr. Languages 3, 4 (1978), 209-226. Soc. Math. Pol. Series IV," b)mdamenta lnformaticae l, 1 (1977), 19-
22. Cooper, D.C. B6hm and Jacopini's reduction of flow charts. 32.
Comm. ACM 10, 8 (Aug. 1967), 463,473. 56. Leavenworth, B.M. Programming with(out) the goto. SIGPLAN
23. Cooper, D.C. Programs for mechanical program verification. Notices (ACM) 7, 11 (Nov. 1972), 54-58; Proc. ACM Ann. Conf.,
Machine Intell. 6, Edinburgh Univ. Press, 1971, pp. 43-59. Boston, 1972.
24. Culik, K. Structured algorithms and structured programming. 57. Ledgard, H.F., and Marcotty, M. A genealogy of control
Rep. CS-79-40, Dept. ofComptr. Sci., Penn. State Univ., Aug. 1979. structures. Comm. ACM 18, 11 (Nov. 1975), 629-639.
25. Culik, K. Entry strong components and their applications (in 58. Lee, R.C,T., and Chang, S,K. Structured programming and
computer science). Rep. TR Nov. 79-01, Dept. of Comptr. Sci., automatic program synthesis. SIGPLAN Notices (ACM) 9, 4 (April
Wayne State Univ., Nov. 1979. 1974), 60-70; Proc. Syrup. on Very High Level Languages, Santa
26. Culik, K. What is a flowchart loop and about structured Monica, Calif., March 1974.
programming. SIGPLAN Notices (ACM) 15, 1 (Jan. 1980), 45-57. 59. Linger, R.C., and Mills, H.D. On the development of large
27. Denning, P.J. Comments on mathematical overkill. SIGPLAN reliable programs. In Current Trends in Programming Methodology,
Notices (ACM) 10, 9 (Sept. 1975), 10-11. Vol. 1, R.T. Yeh, Ed., Prentice-Hall, Englewood, Cliffs, N.J., 1977,
28. Denning, P.J. Two misconceptions about structured pp. 120-139.
programming. Proc. Ann. ACM Conf., Minneapolis, Minn., Oct. 60. Linger, R.C., Mills, H.D., and Witt, B.I. Structured Programming."
1975, pp. 214-215. Theory and Practice. Addison-Wesley, Reading, Mass., 1979.
29. Dijkstra, E,W. Go to statement considered harmful. Comm. 61. Martin, J.J. The "natural" set of basic control structures.
A C M 11, 3 (March 1968), 147-148. SIGPLAN Notices (ACM) 8, 12 (Dec. 1973), 5-14.
30. Donaldson, J.R. Structured programming. Datamation 19, 12 62. McGowan, C. Structured programming: A review of some
(Dec. 1973), 52-54. practical concepts. Computer 8, 6 (1975) 25-30.
31. Elgot, C.C. Monodic computation and iterative algebraic 63. McGowan, C.L., and Kelly, J,R. Top-Down Structured
theories. In Logic Colloquium '73, North-Holland Pub. Co., Programming Techniques. Petrocelli/Charter, New York, 1975.
Amsterdam, 1975, pp. 175-230. 64. Merton, R.K. On the Shoulders of Giants: A Shandean Postscript.
32. Elgot, C.C. Structured programming with and without go to Harcourt, Brace and World, New York, 1965.
statements. IEEE Trans. Software Eng. SE-2, 1 (March 1976), 41-54. 65. Meyer, A.R., and Ritchie, D.M. The complexity of loop
33. Engeler, E. Structure and meaning of elementary programs. Proc. programs. IBM Res. Rep. RC-1817, 1966.
Syrup. Semantics of Algorithmic Languages, Lecture Notes in Math., 66. Miller, E.F., Jr., and Lindamood, G.E. Structured programming:
Vol. 188, Springer-Verlag, New York, 1971, pp. 89-101. Top-down approach. Datamation 19, 12 (Dec. 1973), 55-57.
34. Engelfriet, J. Simple Program Schemes and b~rmal Languages. 67. Mills, H.D. Mathematical foundations for structured
Lecture Notes in Comptr. Sci., Vol. 20, Springer-Verlag, New York, programming. IBM rep. FSC 72-6012, Fed. Syst. Div., Gaithersburg,
1974. Md., 1972.
35. Fischer, B., and Fischer, H. Structured Programming in P L / I and 68. Mills, H.D. The new math of computer programming. Comm.
PL/C. Marcel Dekker, Inc., New York and Basel, 1976. ACM 18, 1 (Jan. 1975), 43-48.
36. Goldschlager, L.M. Synchronous parallel computation. Ph.D. th., 69. Mills, H.D. How to write correct programs and know it. Proc.
TR- 114, Univ. of Toronto, Dec. 1977. IEEE Tutorial on Structured Programming, Washington, D.C., Sept.
37. Goodman, S.E., and Hedetniemi, S.T. Introduction to the Design 1975, pp. 84-91.
and Analysis of Algorithms. McGraw-Hill, New York, 1977. 70. Mirkowska, G. Algorithmic logic and its applications. Doctoral
38. Greibach, S.A. Theory of Program Structures: Schemes, diss., Univ. of Warsaw, 1972 (In Polish).
Semantics, Verification. Lecture Notes in Comptr. Sci., Vol. 36, 71. Myers, G.J. Reliable Software through Composite Design. Van
Springer-Verlag, New York, 1975. Nostrand Reinhold Co., New York, 1975.
39. Harel, D. And/or programs: A new approach to structured 72. Myers, G.J. Composite~Structured Design. Van Nostrand
programming. Proc. IEEE Specifications for Reliable Software Conf., Reinhold Co., New York, 1978.
Cambridge, Mass., April 1979, pp. 80-90. 73. Nassi, I., and Shneiderman, B. Flowchart techniques for
40. Harel, D. On folk theorems. Comm. ACM 23, 7 (July 1980). structured programming. SIGPLAN Notices (ACM) 8, 8 (Aug. 1973),
41. Harel, D., Norvig, P., Rood, J., and To, T. A universal 12-26.
flowcharter. In Proc. A I A A / I E E E / A C M / N A S A Comptrs. in 74. Neely, P.M. On program control structure. Proc. Ann. ACM
Aerospace Conf. II, Los Angeles, Calif., Oct. 1979, pp. Conf., Atlanta, Ga., 1973, pp. 119-125.
218-224. 75. Nicholls, J.E. The Structure and Design of Programming
42. Hirose, K., and Oya, M. Some results in general theory of flow Languages. Addison-Wesley, Reading, Mass., 1975.
charts. Proc. of the First USA-Japan Comptr. Conf., Sponsored by 76. Partch, B. Improved technology for application development
AFIPS, Tokyo, Japan, Oct. 1972, pp. 367-37l. management overview. Proc. SHARE XLI, Miami, Florida, Aug.
43. Hirose, K., and Oya, M. General theory of flow charts. Comment. 1973, pp. 1281-1300.
Math. Univ. St. Pauli, XXI-2 (1972), 55-71. 77. Perkowska, E. Theorem on the normal form of a program. Bull.
44. Hopkins, M.E. A case for goto. SIGPLAN Notices (ACM) 7, 11 Acad. Pol. Sci., Ser. Sci. Math. Astr. Phys. 22, 4 (1974), 439-442.
(Nov. 1972), 59-62; Proc. ACM Ann. Conf., Boston, 1972. 78. Peterson, W.W., Kasami, T., and Tokura, N. On the capabilities
45. Hughes, J.K. P L / I Structured Programming. John Wiley and of while, repeat, and exit statements. Comm. ACM 16, 8 (Aug. 1973),
Sons, New York, 1973. 503-512.
46. Hughes, J.K., and Michtom, J.I. A Structured Approach to 79. Plum, T. W-S. Mathematical overkill and the structure theorem.
Programming. Prentice-Hall, Englewood Cliffs, N.J., 1977. SIGPLAN Notices (ACM) 10, 2 (Feb. 1975), 32-33.
47. Indermark, K. On a class of schematic languages. Technical rep. 80. Prather, R.E. Structured Turing machines. Inform. and Control
82, Inst. for Res. and Programming, Gesellschaft fur Mathematik und 35 (1977), 159-171.
Datenverarbeitung mbH, Bonn, Germany, Nov. I974. 81. Pratt, V.R. Semantical considerations on Floyd-Hoare logic.
48. Jensen, R.W., and Tonics, C.C; Software Engineering. Prentice- Proe. 17th Syrup. on Foundations of Comptr. Sci., Houston, Texas,
Hail, Engelwood Cliffs, N.J., 1979. Oct. 1976, pp. 109-129.
49. Kasai, T. Translatability of flowcharts into while programs. Z of 82. Rogers, H., Jr. Theory of Reeursive Functions and Effective
Comptr. and Syst. Sciences 9, 2 (Oct. 1974), 177-195. Computability. McGraw-Hill, New York, 1967.
V<YTL 2 !2
g~, W~ld, M A <:~f~cge~¢ aipr~ach ta~ b,,~r;~c{recur'sire dcfinhion3 Mann emem Science/ D, F, S ha a rio
H~>liam:lP~b Co~Am~e~dam, ~97? p p 331 3 4 1
Operations Research Edhor
g~ W~:/.:. {) S, F m q ~ ar~ i) P Sha?~rc,, S < , and Wand, M
g o , ~ e a ~ > v 0 l u e d k x p ::~::'tS V~75L431 4 5 i
87. W~A~ W A A Ca~< aga~ns~ @¢ p>~,:~ SI(]PIAN Nogice~' {A(M} 7o
Gamma Variate
1/ {Nov 1~)72),61 M< }>f>< ACM Aw< C o n f ;Bose{m, !972~
gag. Y~ urd<,~< ~,', levk~*N~e~ %tPe<~ge~um5.w~cmre a~d Deq.gtfn
P~eB~cedlall. Er~glewood Ctift%, N.J, t<&eS,
Gene Fa/ors
gJ)o Y'ou~'don E ,4fae~a~i#~ggke ,%'~r~.~ctur<'d7%'eh*uqmq. Scco~@ ed{{ior~,
Yovafdor'~ Pre:~< New 'Yo~k, :~29 {[ irsI edigiom How iv &f:a~age
with Increased Shape
S~rue~red Pr~Nr~mm*~g, 1~76}
1, Introduction
~NU~ UK~
Cornm~m~c~mB~s h d ) igN)