LOGIC4FUN

Cryptic Error MessagesNuts And Bolts

This is a collection of the less illuminating error messages returned by the parser, with explanations.

It is important to see that the parser makes only one pass through each formula, so it will always keep going as long as there is a possibility that the string it has seen so far can be extended to something well-formed. This means that if there is a mistake in a formula, the error is often reported not immediately but a symbol or two later. Two other sources of obscurity are (1) that in clause form the quantifiers binding variables are implicit, so almost any character string that is not otherwise in the lexicon is treated as a variable, while in first order form an undeclared string is treated as a name, and (2) that binary operators may be writen either in infix or in prefix position.

Example 1.

    Input error on line 4:
      f(f(x)) == f
                  (x).

f found where a left parenthesis was expected

You can stare at this for ages without seeing why the “f” should have been a left parenthesis. In fact, it shouldn’t. The error is in the identity symbol just before it. “==” is not an allowable symbol in the input language: it should be a single character “=”. The parser sees “==” as two separate identity symbols, the first in infix position and the second in prefix. As a prefix operator, it expects two arguments separated by a comma and enclosed in parentheses – hence the “missing parenthesis” error message.

Example 2.

    Input error on line 4:
      f(f(x)) < 2 f
                   (x).

f found where a binary operator was expected

“2 f(x)” is probably intended to represent f(x)+f(x). Writing “2f(x)” without the space results in an error message saying that “2f” starts numerically but isn’t a numeral, so the user here has tried inserting a space to separate the “2” from the “f(x)”. Unfortunately, there is no notation for multiplication in the language, so the parser does its best: “2” is a constant, so the only way it can begin a compound expression is by being the left subformula of something with an infixed binary main operator.

Example 3.

    Input error on line 4:
      f(f(x)) = 2(
                  f(x)+1).

( found where a function symbol was expected

“2(f(x)+1)” is again an attempt to represent multiplication. The “2” is a constant and the only thing that can legitimately follow it is a binary operator in infix, not a parenthesis.

Example 4.

    Input error on line 4:
      funny(funy(
                 x)) < funny(x).

( found where a function symbol was expected

This is a classic. The error, of course, is the typo – the missing “n” in “funy”. The parser decides that must be either a variable or a name, but that only makes sense in this position if it is the left argument of a binary operator in infix. The next symbol should therefore be the binary operator, not a parenthesis.

Example 5.

   Input error on line 7: #constraint {

constraint found where “name”, “predicate” or “function” expected

The hash symbol is a clue here. It occurs as part of the invisible input text marking the end of one box (here the Vocabulary box) and the start of the next (the Constraints box). There is probably a missing curly brace in the last vocabulary declaration, causing the keyword “constraint” to be read as though it were part of the text in that box.