Quote o' the Week: Iversons convention

Posted on September 2, 2010 by Tommy McGuire
Labels: notation, quote, c, Knuth, math
While looking for a copy of Donald Knuth's "Notes on avoiding go to statements" (I am fairly sure the person I am looking for is Knuth, and the paper I am looking for is not "Structured programming with go to statements"), I found "Two Notes on Notation" at his Preprints of Recent Papers page. The first notation he found "considerably more useful than [he] had previously realized" is Iverson's convention:
"If α and β are arbitrary entities and R is any relation defined on them, the relational statement (αRβ) is a logical variable which is true (equal to 1) if and only if α stands in the relation R to β. For example, if x is any real number, then the function
(x > 0) − (x < 0)
(commonly called the sign function or sgn x) assumes the values 1, 0, or −1 according as x is strictly positive, 0, or strictly negative.”
(From Iverson's A Programming Language, 1962.)
Knuth goes on to say,

When I read that, long ago, I found it mildly interesting but not especially significant. I began using his convention informally but infrequently, in class discussions and in private notes. I allowed it to slip, undefined, into an obscure corner of one of my books[...]. But when I prepared the final manuscript of [Concrete Mathematics], I began to notice that Iverson’s idea led to substantial improvements in exposition and in technique.
Iverson's convention is almost the behavior of  Boolean relations in C and C++ (prior to the introduction of explicit Booleans), where the value of (x > 0) is either zero (for false) or non-zero (for true).
Since C is very nearly my native language, I was at first struck by the relationship between Knuth and Iverson's essentially mathematical notation and my oft-apologized-for programming idiom. Then, I realized that instead of apologizing for C's lack of explicit Booleans, I should have been apologizing for poor definition of the idea; rather than non-zero for true, it really, really should have been only one.
active directory applied formal logic ashurbanipal authentication books c c++ comics conference continuations coq data structure digital humanities Dijkstra eclipse virgo electronics emacs goodreads haskell http java job Knuth ldap link linux lisp math naming nimrod notation OpenAM osgi parsing pony programming language protocols python quote quotes R random REST ruby rust SAML scala scheme shell software development system administration theory tip toy problems unix vmware yeti
Member of The Internet Defense League
Site proudly generated by Hakyll.