I am interested, whether, in some programming language, there can be something like a Donkey Sentence, a sentence that defies straightforward attempts to translate it into a formal language, but is nevertheless meaningful?
An example of a Donkey Sentence is "Every farmer who owns a donkey beats it.", a straightforward attempt to translate it into a formal language would be:
$$\forall x. (\mathrm{FARMER}(x) \land \exists y. (\mathrm{DONKEY}(y) \land \mathrm{OWNS}(x, y)) \to \mathrm{BEAT}(x, y))$$
But that's not a valid sentence ("y" at the end is out of scope).
A correct translation seems to be:
$$\forall x. \forall y. ((\mathrm{FARMER}(x) \land \mathrm{DONKEY}(y) \land \mathrm{OWNS}(x, y)) \to \mathrm{BEAT}(x, y))$$
But it's not obvious how it follows from the syntax of the sentence (notice that the translation says "all donkeys", whereas the original sentence says "a donkey").
In my Bachelor Thesis, on page 13, I claim that there isn't. However, given how diverse programming languages are, I am not really sure. Can there be such a sentence in some declarative (rather than imperative) language?
Sentences such as "More people have been to Russia than I have." (that seem acceptable at first although they are ungrammatical) obviously can exist in programming languages: ungrammatical expression 5**
, in the first versions of my AEC-to-x86 compiler, passed through the parser (producing the AST (* 5 *)
) and crashed the compiler. Sentences such as "Time flies like an arrow." (where without context it is unclear which word is of which type and so can be parsed in different ways because of that) can also exist in some programming languages, that's what's the typedef problem is about. So I am wondering whether Donkey Sentences can exist in some programming language.