### On The Ambiguity Problem of Backus SystemsOn The Ambiguity Problem of Backus Systems Access Restriction
Subscribed

 Author Cantor, David G. Source ACM Digital Library Content type Text Publisher Association for Computing Machinery (ACM) File Format PDF Copyright Year ©1962 Language English
 Subject Domain (in DDC) Computer science, information & general works ♦ Data processing & computer science Abstract Backus  has developed an elegant method of defining well-formed formulas for computer languages such as ALGOL. It consists of (our notation is slightly different from that of Backus):A finite alphabet: $\textit{a}1,$ $\textit{a}2,$ …, $\textit{at};Predicates:$ $\textit{P}1,$ $\textit{P}2,$ …, $\textit{P}@@@@;Productions,$ either of the form (a) $\textit{aj}$ ∈ $\textit{Pi};$ or of the form (b) $\textit{P}\textit{i}2\textit{P}\textit{i}1$ … $\textit{Pit}$ → $\textit{Pj}.$ A $\textit{word}$ is a finite sequence of letters from the alphabet. Then IIIa states that certain words (containing only one letter) belong initially to some of the predicates, and IIIb states that if words $\textit{W}1,$ $\textit{W}2,$ …, $\textit{Wt}$ belong to the predicates $\textit{P}\textit{i}1,$ $\textit{P}\textit{i}2,$ …, $\textit{P}it$ respectively, then the concatenation $\textit{W}1\textit{W}2$ … $\textit{Wt}$ belongs to $\textit{Pj}.$ We call this a $\textit{Backus}$ system.A simple example of such a system is: Alphabet: $\textit{a},$ $\textit{b};$ Predicates: $\textit{P},$ $\textit{Q},$ $\textit{R};$ Productions: $\textit{a}$ ∈ $\textit{P},$ $\textit{b}$ ∈ $\textit{Q},$ $\textit{PQ}$ → $\textit{R},$ $\textit{QP}$ → $\textit{R};$ $\textit{RR}$ → $\textit{R},$ $\textit{PRQ}$ → $\textit{R},$ $\textit{QRP}$ → $\textit{R}.$ Then $\textit{P}$ and $\textit{Q}$ contain only the words $\textit{a}$ and $\textit{b},$ respectively, while $\textit{R}$ contains all words which have the same number of $\textit{a}'s$ and $\textit{b}'s.$ In the above example, $\textit{abab}$ belongs to $\textit{R}$ and can be produced in two ways. Namely, as $\textit{ab}$ ∈ $\textit{R}$ and $\textit{RR}$ → $\textit{R},$ $\textit{abab}$ ∈ $\textit{R};$ also as $\textit{ba}$ ∈ $\textit{R}$ and $\textit{PRQ}$ → $\textit{R},$ $\textit{abab}$ ∈ $\textit{R}.$ We call a Backus system $\textit{ambiguous}$ if one of its predicates contains a word which can be produced in more than one way. As, in practice, the meaning of a word is determined by the way it is produced, an ambiguous Backus System must be avoided.As the following example illustrates, ALGOL 60  is ambiguous: if $\textit{B}$ ∧ $\textit{C}$ then for $\textit{I}:$ = 1 step 1 until $\textit{N}$ do if $\textit{D}$ ∨ $\textit{E}$ then $\textit{A}[\textit{I}]$ : = 0 else $\textit{K}$ : = $\textit{K}$ + 1; $\textit{K}$ : = $\textit{K}$ - 1 In fact, both for $\textit{I}$ := 1 step 1 until $\textit{N}$ do if $\textit{D}$ ∨ $\textit{E}$ then $\textit{A}[\textit{I}]$ := 0 and for $\textit{I}$ := 1 step 1 until $\textit{N}$ do if $\textit{D}$ ∨ $\textit{E}$ then $\textit{A}[\textit{I}]$ := 0 else $\textit{K}$ := $\textit{K}$ + 1 are valid for statements of ALGOL 60. Combining the first with if $\textit{B}$ ∧ $\textit{C}$ then … else $\textit{K}$ = $\textit{K}$ + 1; or the second with if $\textit{B}$ ∧ $\textit{C}$ then … gives rise to the above example, and these two methods of construction correspond to the two possible meanings of the example. D. Dahm and H. Trotter, in a private communication, have raised the question: “Does there exist an algorithm to determine whether a Backus system is ambiguous?” We call this the ambiguity problem. The purpose of this paper is to show that no such algorithm exist, i.e., that the ambiguity problem is unsolvable.We first define a normal system. It consists of:A finite alphabet: $\textit{a}1,$ $\textit{a}2,$ …, $\textit{at};A$ finite collection of ordered pairs: $(\textit{g}1,$ $\textit{g}1),$ $(\textit{g}2,$ $\textit{g}2),$ …, $(\textit{gr},$ $\textit{gr}),$ where the $\textit{gi}$ and $\textit{gi}$ are words.An axiom $\textit{A}$ which is some fixed word. If $\textit{U}$ and $\textit{V}$ are words, we say $\textit{U}$ → $\textit{V}$ if $\textit{U}$ is of the form $\textit{gP}$ and $\textit{V}$ is of the form $\textit{Pg}$ where $(\textit{g,g})$ is one of the ordered pairs. We also write, in this case, $\textit{giP}$ → $\textit{Pgi}.$ Also, if $\textit{U}1,$ $\textit{U}2,$ …, $\textit{Un}$ are words with $\textit{Ui}$ → $\textit{U}\textit{i}+1,$ 1 ≦ $\textit{i}$ ≦ $\textit{n}-1,$ then $\textit{U}1$ → $\textit{Un},$ and we say $\textit{Un}$ is derived from $\textit{U}1.$ The words which may be derived from the axiom $\textit{A}$ are called $\textit{theorems}.A$ normal system is called $\textit{undecidable}$ if there does not exist an algorithm for determining whether a word is a theorem of the system. It is implicit in [2, sec. 6.5] that there exists an undecidable normal system, which we denote by $\textit{NS},$ with the property that in each ordered pair (g, g), the words $\textit{g}$ and $\textit{g}$ have no common letters. LEMMA. If U and V are words of NS, then U → V, if and only if there exists indices j1, $\textit{j}2,$ …, jm such that $\textit{Ug}\textit{j}1\textit{g}\textit{j}2$ … $\textit{gjm}$ = $\textit{g}\textit{j}1\textit{g}\textit{j}2$ … $\textit{gjmV}.PROOF.$ Suppose the equality holds. As $\textit{g}\textit{j}1$ and $\textit{g}\textit{j}1$ have no common letters, $\textit{U}$ is of the form $\textit{g}\textit{j}1\textit{R}1$ ; let $\textit{U}1$ = $\textit{R}1\textit{g}\textit{j}1.$ Then we have $\textit{U}$ → $\textit{U}1$ and $\textit{U}1\textit{g}\textit{j}2$ … $\textit{gjm}$ = $\textit{g}\textit{j}2\textit{g}\textit{j}3$ … $\textit{gjmV}.$ Proceeding inductively, we obtain a sequence of words, $\textit{U},$ $\textit{U}1,$ $\textit{U}2,$ …, $\textit{Um}$ = $\textit{V}$ with $\textit{U}$ → $\textit{U}1$ → … → $\textit{Um}$ ; hence $\textit{U}$ → $\textit{V}.$ Conversely, if $\textit{U}$ → $\textit{V},$ then there exist words $\textit{U}0,$ $\textit{U}1,$ …, $\textit{Um}$ with $\textit{U}0$ = $\textit{U}$ and $\textit{Um}$ = $\textit{V},$ and indices $\textit{j}1,$ $\textit{j}2,$ …, $\textit{jm}$ such that $\textit{U}\textit{i}-1\textit{gji}$ = $\textit{gji}\textit{Ui},$ 1 ≦ $\textit{i}$ ≦ $\textit{m}.$ Then $\textit{U}0\textit{g}\textit{j}1$ = $\textit{g}\textit{j}1$ $\textit{U}1$ or $\textit{U}0\textit{g}\textit{j}1\textit{g}\textit{j}2$ = $\textit{g}\textit{j}1\textit{U}1\textit{g}\textit{j}2$ = $\textit{g}\textit{j}1\textit{g}\textit{j}2\textit{U}2.$ By induction the proof is complete. THEOREM. The ambiguity problem is unsolvable.PROOF. We describe certain predicates and Backus systems; to save space we omit the formal definitions. It is easy to construct predicates and systems with the required properties. We use as alphabet the alphabet $\textit{a}1,$ $\textit{a}2,$ …, $\textit{at}$ of $\textit{NS}$ and in addition the letters $\textit{b}1,$ $\textit{b}2,$ …, $\textit{br},$ one for each ordered pair (gi, gi) of $\textit{NS}.$ If $\textit{A}$ is the axiom of $\textit{NS},$ form the predicate $\textit{P}$ which contains all words of the form $\textit{bjm}\textit{b}\textit{jm}-1$ … $\textit{b}\textit{j}1\textit{Ag}\textit{j}1\textit{g}\textit{j}2$ … $\textit{gjm};$ if $\textit{W}$ is any word on the alphabet $\textit{a}1,$ $\textit{a}2,$ …, $\textit{ar},$ let $\textit{Qw}$ be the predicate containing all words of the form $\textit{bjm}\textit{b}\textit{jm}-1$ … $\textit{b}\textit{j}1\textit{g}\textit{j}1\textit{g}\textit{j}2$ … $\textit{gjmW}.$ It is possible to construct the predicates $\textit{P}$ and $\textit{Qw}$ so that there is no ambiguity in their definition, and we assume that this is done. Then form the Backus system $\textit{Bw}$ which contains the predicates $\textit{P},$ $\textit{Qw},$ and $\textit{Sw},$ where $\textit{Sw}$ is defined by $\textit{P}$ → $\textit{Sw}$ and $\textit{Qw}$ → $\textit{Sw}.$ Now, in order for $\textit{Bw}$ to be ambiguous, $\textit{Bw}$ must contain a predicate which contains a word which comes about in two ways. The predicates $\textit{P}$ and $\textit{Qw},$ and all predicates used in their definition, do not have this property. Thus $\textit{Bw}$ is ambiguous if and only if $\textit{Sw}$ contains a word which comes about in two ways. From the definition of $\textit{Sw},$ it is clear that $\textit{Bw}$ is ambiguous if and only if $\textit{P}$ and $\textit{Qw}$ have a word in common. Observing the form of the words in $\textit{P}$ and $\textit{Qw}$ we see that $\textit{Bw}$ is ambiguous if and only if there exists indices $\textit{j}1,$ $\textit{j}2,$ …, $\textit{jm}$ such that $\textit{bjm}$ … $\textit{b}\textit{j}1\textit{A}\textit{g}\textit{j}1$ … $\textit{gjm}$ = $\textit{bjm}$ … $\textit{b}\textit{j}1\textit{g}\textit{j}1$ … $\textit{gjmW}.$ By the lemma, this is true if and only if $\textit{A}$ → $\textit{W}.$ Thus if the ambiguity problem for Backus systems were solvable, then the decision problem for $\textit{NS}$ would be solvable, which is not the case. Hence the ambiguity problem is unsolvable. ISSN 00045411 Age Range 18 to 22 years ♦ above 22 year Educational Use Research Education Level UG and PG Learning Resource Type Article Publisher Date 1962-10-01 Publisher Place New York e-ISSN 1557735X Journal Journal of the ACM (JACM) Volume Number 9 Issue Number 4 Page Count 3 Starting Page 477 Ending Page 479

#### Open content in new tab

Source: ACM Digital Library