Professor Office: 521 Van Vleck Email: ude.csiw.htam@rellimj Fax: (608) 263-8891 University of Wisconsin–Madison Department of Mathematics 480 Lincoln Drive Madison, WI 53706
Ambigrams
 Notice that the stylized text to the left, which is supposed to be my name, is symmetric: it looks the same right side up as upside down. Such things are called ambigrams. Other examples you might enjoy: Scott Kim has a gallery (he calls them inversions). John Langdon has a gallery too. 01101001 has an extensive collection as well. The 20th Anniversary edition of Princess Bride has a beautiful ambigram title. I used to own this doormat, but an animal thought it looked tasty.
Quines
Long ago, I wrote self printing programs in various languages. Douglas Hofstadter called such programs quines, after the philosopher and logician Willard van Orman Quine. Many examples of quines (including some of mine) can me found on The Quine Page. My old pastime is not unrelated to my chosen profession; the recursion theorem from Computability Theory (née Recursion Theory) guarantees that any computationally complete language admits programs which print out their own source code. But tracing through the proof of the recursion theorem to produce a C quine, for example, would result in a fairly large program which has a C interpreter built into the code. A more elegant solution would be:

 main(a){printf(a="main(a){printf(a=%c%s%c,34,a,34);}",34,a,34);} 

This particular example is due to Dario Dariol, who makes nice use of an implicit type declaration and an implicit type cast to squeeze it into so few characters. Ah, the good old days of weakly typed languages!

I have included some of my examples of quines below. Three of them are not only quines, but polyglots, i.e., programs which are valid in more than one language. A pair of languages need not admit a polyglot and the existence of polyglottal quines is certainly not guaranteed by the recursion theorem.

A C/Lisp Polyglottal Quine
The trick to writing a polyglot is to figure out a valid way to start the program and good way to comment out parts of the code in one language at a time; the rest is easy, if tedious.

A TeX/PostScript Polyglottal Quine
As advertised, this is both valid TeX code and valid PostScript and produces itself as the typeset output in both languages. In other words, if you view the code as PostScript, then you will see the code itself (in Courier). On the other hand, if you TeX the code, convert it to PostScript, and view the result, then you will again see the original code (in Computer Modern TeleType).

A C/Tcl Polyglottal Quine
This is probably less interesting than the previous examples because C and Tcl have a similar syntax. Also, I would guess that Tcl is less well known than the languages in the other examples.

A TeX Quine
This was the basis for the TeX portion of the polyglottal quine above.

An HTML–JavaScript Quine
Not a polyglot; this is an HTML–JavaScript file which displays its own source when rendered.
On top of Niesen, in Switzerland. For the record, I ascended by funicular, not foot.
In front of the Fajing (formally Daming) temple pagoda in Yangzhou, China.

August 26, 2015