a. Syntax Checking for Boolean Expressions

Such expressions contain the following symbols: variable symbols, negation symbol, operation symbols, parentheses symbols, and space symbol that is needed for the separation of expressions. The symbols in question are coded in bit sequences.

Sa(x): <<x is a 'meaningful expression', i.e. a (syntactically correct) Boolean expression>>.

(i) A variable symbol is a meaningful expression.

(ii) A meaningful expression, prefixed by a negation symbol, yields a meaningful expression.

(iii) Two meaningful expressions, connected by an operation symbol, yield a meaningful expression.

(iv) A meaningful expression, put in parentheses, yields a meaningful expression.

Va(x): <<x is a variable symbol>>

Op(x): <<x is operation symbol>>

Neg(x): <<x is negation symbol>>

Kla(x): <<x is opening patenthesis>>

Klz(x): <<x is closing parenthesis>>



Az(x): Va(x) V Neg(x) V Kla(x)

Sz(x): Va(x) V Klz(x)

Sq(x,y): (Sz(x) ^ ¬ Az(y)) V (¬Sz(x) ^ Az(y))



1. The first symbol x has to fulfill Az(x)

2. Two symbols x, y following each other have to fulfill Sq(x, y)

3. The last symbol x has to fulfill Sz(x).



4. The number of opening parenthesis has to be equal to the number of closing parentheses.

5. For any segment of the symbol sequences, the number of opening parentheses must not be smaller than the number of closing parentheses.



The program (Figure 3) checks these conditions: (2) serves for the special case of condition 1. (3) and (4) are initializations for the repetitive statement which checks condition 2 and the count 5. Condition 3 for the final case is then checked in (11) and the count 4 in (12) . The program, by the way, contains mistakes: for example, a count corresponding to (7) is missing for the first symbol. More seriously, the condition x V0[0] in (5) should be read as x = V0[i] ^ i 0.

For a direct transliteration of Zuse's (corrected) procedure, we assume first that suitable Boolean procedures Va(x), Op(x), etc., are declared. Using these predicates, we obtain in ALGOL 68 (the encircled numbers refer to Figure 3):