Thursday, August 25, 2016

Syntax and semantics

One of the things that I've been puzzled by for a long time is the distinction between syntax and semantics. Start with this syntactically flawed bit of English:

  1. Obama equals.
It is syntactically flawed, because "to equal" is a transitive verb, and a sentence that applies an intransitive verb to a single argument is ungrammatical, just as an atomic sentence in First Order Logic that applies a binary predicate to one argument is ungrammatical. (I leave open the further question whether "Obama equals Obama" is grammatically correct; maybe the arguments of the English "equals" have to be quantities.) This is a matter of syntax. But now consider this more complicated bit of language:
  1. Let xyzzing be sitting if the temperature is more than 34 degrees and let it be equalling otherwise. Obama xyzzes.
My second sentence makes perfect sense when the temperature is 40 degrees, but is ungrammatical in exactly the same way that (1) is when the temperature is 30 degrees. Its grammaticality is, thus, semantically dependent.

One might object that the second sentence of (2) is syntactically correct even when the temperature is 30 degrees. It's just that it then has a semantic value of undefined. This move is similar to how we might analyze this bit of Python code:

def a(f): print(f(1))
def g(x,y): x+y
def h(x): 2*x
a(h if temperatureSensor()>34 else g)
This code will crash with
TypeError: <lambda>() takes exactly 2 arguments (1 given)
when the temperature sensor value is, say, 30. But the behavior of a program, including crashing, is a matter of semantics. The Python standard (I assume) specifies that the program is going to crash in this way. I could catch the TypeError if I liked with try/except, and make the program politely print "Sorry!" when that happens instead of crashing. There is no syntactic problem: print(f(1)) is always a perfectly syntactically correct bit of code, even though it throws a TypeError whenever it's called with f having only one argument.

I think the move to say that it is the semantic value of the second sentence of (2) that depends on temperature, not its grammaticality, is plausible. But this move allows for a different way of attacking the distinction between syntax and semantics. Once we've admitted that the second sentence of (2) is always grammatical but sometimes has the undefined value, we can say that (1) is grammatically correct, but always has the semantic value of undefined, and the same is true for anything else that we didn't want to consider grammatically correct.

One might then try to recapture something like the syntax/semantics distinction by saying things like this: an item is syntactically incorrect in a given context provided that it's a priori that its semantic value in that context is undefined. This would mean that (2) is syntactically correct, but the following is not:

  1. Let xyzzing be sitting if Fermat's Last Theorem is false and let it be equalling otherwise. Obama xyzzes.
For it's a priori that Fermat's Last Theorem is true. I think, though, that a syntax/semantics distinction that distinguishes (2) from (3) is too far from the classical distinction to count as an account of it.

It may, however, be the case that even if there is no general distinction between syntax and semantics, in the case of particular languages or families of languages one can draw a line in the sand for convenience of linguistic analysis. But as a rule of thumb, nothing philosophically or semantically deep should rely on that line.

Now it's time to be a bit of a hypocrite and prepare my intermediate logic lecture, where instilling the classical distinction between syntax and semantics is one of my course objectives. But FOL is a special case where the distinction makes good sense.

1 comment:

  1. The original version of the post assumed that "to swim" had no transitive use, but Trent Dougherty pointed out to me that one can swim a river, and so I had to change my examples.

    ReplyDelete