Friday, February 25, 2011

"Any" Considered Harmful

Edsger Dijkstra wrote a famous letter in the Communications of the ACM that appeared under the heading "Go To Statement Considered Harmful".

I'd like to make a case against the use of "any" in mathematical discourse.

The problem with "any" is that it can mean both "for all" and "there exists", and it's not always clear what is meant. "It's true for any x" probably means "for all x". But "The theorem is true for S if any element of S is a square" probably means "it's true if S contains at least one square".

I was just attending a meeting at Dagstuhl in Germany where one speaker said something like "If L is regular, then u is equivalent to v if and only if for any state q of the minimal DFA for L we have δ(q,u) = δ(q,v)". Now if you know the theorem, the meaning is clear. But if you don't, you might be left wondering, does he mean "u is equivalent to v if there exists some state q such that δ(q,u) = δ(q,v)" or "u is equivalent to v if for all states q we have δ(q,u) = δ(q,v)"?

Because of this ambiguity, I think we should avoid the use of "any" in mathematical discourse. We can replace it by "all x" or by "some x", according to what we mean.

Who's with me?


Unknown said...

Are you aware of any other examples of words used in mathematics with similar ambiguity?

I'm on board—though currently about as uninvolved with the mathematics community as one can be.

Jeff said...

This has always bothered me, and I'm glad to see that I'm not alone. (However, despite the fact that I often cringe when I see someone else write the word "any", I do sometimes make this mistake myself. As you pointed out, when you're familiar with the material, the distinction is clear and not at all troubling.)

David Swart said...

How might you rework:

"The goal of our algorithm is to take an image of any shape and to conformally map it to another target shape." ?

I can't seem to bring myself to change it to "all shapes".

Adrian Petrescu said...

Definitely; I've had this thought myself several times, as a student.

In analysis, particularly, there are cases where it's genuinely confusing, because of the frequent interplay of quantifiers in those types of theorems.

Jonathan Lubin said...

I used "any" in a similar way at an important point in an abstract algebra course and managed to confuse my students thoroughly. I'm with you all the way.

Takis Konstantopoulos said...

More generally, we should be careful in making sure that we write clearly and unambiguously. If I saw the sentence
"The theorem is true for S if any element of S is a square"
I, too, would have been puzzled. The word "any", to me, sounds closer to ∀.

In Greek schools and universities, an unfortunate word is chosen as a substitute for the word "arbitrary". The word is ΤΥΧΟΝ and means, essentially, random. So, for instance, Euclidean geometry pupils hear the phrase "let ABC be a τυχον triangle" (the meaning being "let ABC be an arbitrary triangle") and this makes it difficult, later, to talk about a random triangle (a random element of the set of triangles).

John Stockwell said...

Yes. I agree that "any" is tacky.

I would also argue that "Since"
used to mean "Because" is similarly

"Since" should be used purely to designate
a chronological ordering.

John Stockwell said...

I would have to say that

"any" should be replaced for "an
arbitrary" in the case where it seems
to mean "for all".

Anonymous said...

"Since" should be used purely to designate a chronological ordering.

How come? I've heard other people say this, so I know you aren't the only one, but I've never understood why.

In principle, the two meanings of "since" could introduce ambiguity, but in practice this doesn't happen. It's easy to make up hypothetical examples, but I've never seen it occur in real life. By contrast, ambiguity from "any" really does matter in practice.

I agree that the chronological usage of "since" is the original meaning, but by now both meanings are in widespread use. Furthermore, using "since" to mean "because" is actually convenient for mathematical writing. It's a lighter weight, less formal version of "because", mainly used in cases where the reason is pretty clear but is being spelled out for readability and completeness. From a strictly logical perspective, there's no reason we couldn't use "because" instead. However, it' s psychologically convenient to be able to distinguish between deep and shallow reasons.

fudo said...

Good point, I shall try to avoid all unnecessary use of "any", from now on.

Anonymous said...


I took a course on formal specification of software. It was very challenging for the whole class to convert any (all :]) sentence that contains the word "any", into either \forall or \exists.

Anonymous said...

Semanticists have recognized this for a while and have gone to great lengths to explain "any". There is a classic paper by Kadmon and Landman 1993 called "Any" and Alissa Levy of Bar-Ilan University wrote a entire dissertation on the term.

Needless to say, mathematicians are better off avoiding the use of a term that can mean "all" or "some" in certain contexts. The fact that "any" is only sometimes ambiguous makes it especially dangerous.