Self-graphing equations July 4, 2013 Figure 1: The graph used to define F : R2 → {0, 1}. It consists of thirteen line segments-two vertical, five horizontal and six diagonal-and two Bézier curves, arranged in a particular layout. Can you find an xy-equation that, when graphed, writes itself on the plane? This idea became internet-famous when a Wikipedia article on Tupper's selfreferential formula went viral in 2012. Under scrutiny, the question has two flaws: it is meaningless (it depends on fonts) and it is trivial. To see the latter, let F : R2 → {0, 1} be the function such that the graph F (x, y) = 1 is given by Figure 1. The equation F (x, y) = 1 is self-graphing by construction. (Objection: this equation is not in closed form! But what does that mean? Closed form is not a formally defined, or universally agreed upon, notion [2].) In Section 1 we fix these two flaws by formalizing the problem. In Sections 2 and 3 we use mathematical logic to prove existence of self-graphing equations in a conceptual way (no messy details required). The proof resembles the abstract proof that there are self-printing computer programs (or quines). 1 Formalization "What was a compelling proof in 1810 may well not be now; what is a fine closed form in 2010 may have been anathema a century ago."-J. Borwein and R. Crandall [2] Definition 1. If A = ∅ is a finite alphabet, let A<N be the set of finite strings from A. By a notion of equations we mean a finite alphabet A together with a graphing function Gr: A<N → P(R2) assigning to every σ ∈ A<N a subset Gr(σ) of R2 called the graph of σ. If A contains symbols x, y, 2, +, =, and 1, Gr(x2 + y2 = 1) might (or might not) be the unit circle in R2. Gr(y = +) might (or might not) be the empty set, or even an error message written on the plane. Definition 2. By a glyphed notion of equations we mean a triple (A,Gr,Gl) where (A,Gr) is a notion of equations and Gl: A → P([0, 1]2) is an injective function assigning to each a ∈ A a distinct Gl(a) ⊆ [0, 1]2 called the glyph of a. If A contains a symbol X, Gl(X) might (or might not) be the union of the line segment from (0, 0) to (1, 1) and the line segment from (0, 1) to (1, 0). Definition 3. If X ⊆ R2 and n ∈ R, let X→n = {(x + n, y) : (x, y) ∈ X} be the result of translating X to the right by n units. Let (A,Gr,Gl) be a glyphed notion of equations. For each finite string σ = σ0 . . . σn in A<N, let Gl(σ) ∈ P(R × [0, 1]) be the union Gl(σ0)→0 ∪ * * * ∪ Gl(σn)→n. Thus Gl(σ) is the result of writing σ out in the xy-plane, using the glyphs of A and writing from left to right starting at the origin. Definition 4. Given a glyphed notion (A,Gr,Gl) of equations, a self-graphing equation is a string σ ∈ A<N such that Gr(σ) = Gl(σ). 1 Disregarding canonicity, one can arbitrarily choose a glyphed notion of equations and go to work. Say that σ is weakly self-graphing if Gr(σ) is a translation of Gl(σ) after rescaling some symbols. With enough arbitrary choices, constructing weakly self-graphing equations is doable. Jakub Trávńık found [7] such an equation (or rather, an inequality) in three evenings. Tupper claims [9] such an inequality with arithmetic, floors, moduli, absolute values, and ≈1800 decimal digits (see Figure 2). Would 500 digits suffice? Are absolute values necessary? (Incidentally, it was a simpler inequality of Tupper's, from [8] or [5], that went viral. Despite the name Tupper's self-referential formula, it is not self-referential. Its graph includes all possible j × 17 bitmaps, and the formula is merely one. Tupper's actual self-referentials [9] are less known.) Figure 2: An inequality (and its graph, rearranged) due to Jeff Tupper (used with his kind permission). 2 A Constructive Existence Proof For self-containment, we will informally describe some computability theoretical notions. For rigorous details see [1], [6], or any computability theory textbook. Casually, a Turing machine is a finite set of states and rules according to which an automaton reads and writes values (from some alphabet) on an infinitely long tape. Mike Davey recently filmed a physical model of Turing machines [3]. Such machines can do any computation that can be described by an effective, unambiguous algorithm. This computational power is independent of arbitrary choices such as the particular alphabet printed on the tape. In the following definition we exploit that alphabetic freedom. Definition 5. (See Figure 3) Let A be a finite nonempty alphabet, ∈ A a blank symbol. An A-Turing machine is a Turing machine over alphabet A ∪ { }. We fix an effective ordering of the A-Turing machines and write TAn for the nth one. For each n, φ A n denotes the following function. The domain of φ A n is {σ ∈ A<N : TAn halts on input σ}. For σ ∈ domain(φ A n ), φ A n (σ) ∈ A <N is the output of TAn on input σ. A function f : ⊆A<N → A<N (i.e., f : X → A<N for some X ⊆ A<N) is computable if f = φAn for some n (we call n a code for f), and f is total computable if in addition domain(f) = A<N. The notions of computability and total computability extend to functions f : ⊆N → A<N and f : ⊆ N → N by identifying N with A<N via some canonical bijection. Figure 3: An A-Turing machine in action. We will show the following condition is sufficient for existence of self-graphing equations. Definition 6. A glyphed notion A = (A,Gr,Gl) of equations is Turing complete if there is a computable (i.e. given by an effective non-ambiguous algorithm) function f : N → A<N such that ∀n ∈ N, if TAn halts on input ∅ then Gr(f(n)) = Gl(φAn (∅)). (If T A n runs forever on input ∅, the output of f(n) is unimportant.) Thus, A is Turing complete if there is an algorithm that takes (the index of) an A-Turing machine TAn and produces an equation f(n) whose graph is the output of TAn if T A n halts when run on empty input (if not, f(n) can be anything, but must be defined). Hereafter, when we say that a machine halts, we mean it halts on empty input. There do exist Turing complete glyphed notions of equations not too far from our intuition of Cartesian equations. In Section 3 we sketch an argument that such a notion is provided by basic arithmetic, decimal digits, absolute values, and infinite series or products. 2 Theorem 1. For any Turing complete glyphed notion A = (A,Gr,Gl), there is a self-graphing equation. To prove Theorem 1 we will use two theorems from computability theory. Informally, one thinks of algorithms as being made of very simple instructions like "Add 1 to x" or "Goto line 20". Glossed informally, computability theory's Smn Theorem says that it is safe for algorithms to include complex meta-instructions of the form "Let x be (a numerical encoding of) the following algorithm: . . . ". To avoid detour, we only formally state one special case. Loosely speaking, if we have an algorithm Af for f : ⊆N → A<N, then we can form the algorithm in Figure 4. 1. Take input n. 2. Let x be (a code of) the algorithm: 1'. Take input m. 2'. Ignore m. Run Af on input n. 3. Output x. Figure 4: Pseudocode for a special case of the Smn Theorem. Lemma 2. (The Smn Theorem, special case) For any total computable f : N → A<N, there is a total computable F : N → N such that ∀n, φAF (n)(∅) = f(n). We will also use the Recursion Theorem, surely one of computability theory's most treasured jewels. Informally, it says it is safe for algorithms to include self-referential meta-instructions of the form "Let x be a numerical code for this algorithm." Lemma 3. (The Recursion Theorem) For any total computable F : N → N, there is some n ∈ N such that φAn = φ A F (n). Note that the function φAn given by Lemma 3 is not necessarily total. A fun informal way to see this is as follows. Using the informal interpretations of Lemmas 2 and 3, there is a function φAn : ⊆A <N → A<N (given by Lemma 3) with the following pseudocode: "Take input m. Ignore m. Let x be a code for this algorithm. Simulate TAx on empty input. If it halts with output y, then output the next A-string after y lexicographically." What is φAn (∅)? If it exists, it is the next string after φ A n (∅). Impossible. Proof of Theorem 1. Since A is Turing complete, there is a total computable f : N → A<N such that ∀n ∈ N, if φAn (∅) is defined then Gr(f(n)) = Gl(φ A n (∅)). By Lemma 2, let F : N → N be total computable such that ∀n ∈ N, φAF (n)(∅) = f(n). By Lemma 3, there is some n ∈ N such that φAn = φ A F (n). In particular, φAn (∅) = φ A F (n)(∅) = f(n) is defined. (∗) Let σ = f(n), then Gr(σ) = Gr(f(n)) = Gl(φAn (∅)) (By ∗ and choice of f) = Gl(f(n)) (By ∗) = Gl(σ). By Definition 4, σ is a self-graphing equation. Theorem 1 is constructive up to applying the Smn Theorem and the Recursion Theorem. It turns out that these two computability theoretical theorems are themselves fully constructive, making Theorem 1 fully constructive as well. In principle, one could design an algorithm to take specifications of Turing complete glyphed notions of equations and mechanically generate self-graphing equations from them. 3 A Turing Complete Notion of Equations Let A = {a1, . . . , aN} be a finite alphabet with symbols for arithmetic, decimal digits, absolute values, and infinite series or products. For σ ∈ A<N, if σ is a grammatically correct xy-equation, let Gr(σ) be its graph in the ordinary sense. For grammatically incorrect σ, let Gr(σ) be some nonempty subset (e.g. an error 3 message) of the left half-plane, this will ensure Theorem 1 produces a grammatically correct equation. The graph of (x − |x|)2 + (1 − x − |1 − x|)2 = 0 is the line segment from (0, 0) to (1, 0); using this it is easy to find equations for line segments with rational endpoints. Such line segments can be combined to design glyphs (based on typography) such that ∀a ∈ A there is an equation La(x, y) ∈ A<N (not involving infinite series or products) with Gr(La(x, y)) = Gl(a). Arithmetic can be used to simulate propositional logic: xy = 0 if and only if x = 0 or y = 0; x2 + y2 = 0 if and only if x = 0 and y = 0; and (see [4]) 0x 2 = 0 if and only if x = 0. Infinite series or products can simulate logical quantifiers ranging over N, for example ∞ ! i=0 0f(i) 2 = " 1 if ∀x ∈ N, f(x) = 0, 0 otherwise. To see (A,Gr,Gl) is Turing complete, we must convince ourselves there is an algorithm that, given n ∈ N, produces an equation f(n) ∈ A<N such that if TAn halts then Gr(f(n)) = Gl(φ A n (∅)). We can say more: there is a fixed equation f0 ∈ (A ∪ {n})<N (where n is a special new symbol) such that if we define f(n) to be the result of replacing n by (the decimal digits for) n in f0, then f works. By the previous paragraph, it suffices to find a logical formula θ(x, y,n) in the language of arithmetic and absolute values, with all quantifiers ranging over N, such that for all x, y ∈ R and n ∈ N, θ(x, y, n) is true if and only if TAn halts and (x, y) ∈ Gl(φAn (∅)). Such a formula is as follows (we use #N k=1 ψ(k) to abbreviate "ψ(1) or . . . or ψ(N)"): ∃m ∈ N such that TA n halts after ≤ m steps and ∃l ∈ N such that #N k=1 $ ak is the lth symbol of φA n (∅), and Lak(x − l, y) holds [i.e., (x, y) lies in Gl(ak)→l] % . That the subclauses "TA n halts after ≤ m steps" and "ak is the lth symbol of φAn (∅)" can really be formalized with only arithmetic, absolute values, and quantifiers ranging over N, follows from a course in first-order mathematical logic [1]. References [1] S. Bilaniuk, A Problem Course in Mathematical Logic, self-published, 1991, available at http://euclid.trentu.ca/math/sb/pcml/pcml-16.pdf. [2] J. Borwein, R. Crandall, Closed Forms: What They Are and Why We Care, Notices Amer. Math. Soc. 60 (2013) 50–65. [3] M. Davey, A Turing Machine, Webpage published in March 2010 (accessed 30 June 2013), available at http://aturingmachine.com/ [4] D. Knuth, Two notes on notation, Amer. Math. Monthly 99 (1992) 403–422. [5] Self-answering Problems, Math Horizons 13 (2006) 19. [6] M. Sipser, Introduction to the Theory of Computation, PWS Publishing, 1997. [7] J. Trávńık, Self Referential Formula in Math. Webpage published 23 Jun 2011 (accessed 6 June 2013), available at http://jtra.cz/stuff/essays/math-self-reference/index.html [8] J. Tupper, Reliable Two-Dimensional Graphing Methods for Mathematical Formulae with Two Free Variables, in Proceedings of the 28th annual conference on Computer graphics and interactive techniques, ACM, 2001, 77–86. [9] J. Tupper, Index of /selfplot. Webpage (accessed 6 June 2013), available at http://www.peda.com/selfplot/