Sankhy¯ a : The Indian Journal of Statistics 2010, Volume 72-A, Part 1, pp. 276-292 c 2010, Indian Statistical Institute
Mapcode Characterization of Partial Recursive Maps K. Venkata Rao Government College (A), Rajahmundhry, India
Kasturi Viswanath International Institute of Information Technology, Hyderabad, India Abstract We define the class of primal maps using the concepts of mapcode theory and show that a map is primal if and only if it is partial recursive. AMS (2000) subject classification. Primary 03D99. Keywords and phrases. Partial recursive, primal, Godel number, mapcode.
1
Introduction
Students of computer science learn the concept of computability in the theory of computation by studying one or more of many equivalent models. These include Turing machines, partial recursive functions, λ-calculus, Post machines, and register machines. When the same students need to study practical computing problems they learn a programming language and study how to express algorithms in that language. Thus there is a disconnect between theory and practice. The collection of ideas surrounding the B¨ ohm-Jacopini theorem (Bohm and Jacopini, 1966) addresses this gap. In elementary terms they try to show that all computable functions may be computed using only substitution and the constructs of if · · · then · · · else and while. This article addresses this question and gives a similar answer but from a different point of view. In a series of articles by Viswanath (2003, 2004, 2005, 2006a, 2006b) and a book by Viswanath (2008) a theory called the ‘mapcode formalism’ has been presented. This builds on a mathematical definition of an algorithm given by Knuth and defines a ‘mapcode machine’ as a mathematical model for computation. It has been shown that this formalism gives
Mapcode characterization of partial recursive maps
277
a simple mathematical method of building algorithms and proving their termination and correctness, without the use of formal logic. At the same time the formalism subsumes the more standard models of computation such as finite automata, Turing machines and von Neumann machines. Thus a student can learn about both the theoretical and practical issues in terms of a single framework. Here we continue our efforts to bring theory and practice together by characterizing partial recursive maps in terms of mapcode theory. Let N and P denote the set of all non-negative integers and the set of all positive integers respectively. We consider maps from Np to Nq for p, q ∈ P. q can have any value when we talk of a ‘map’, but when we say ‘function’ that necessarily means that q = 1. By default all maps we consider are partial maps. A map f with domain D ⊆ Np and codomain Nq will be denoted by f : D ⊆ Np → Nq . When it is necessary to indicate the dependence of D . on f we write Df . If Df = Np , f is said to be total. The symbol = may be read as ‘is defined as’. In Section 2 we introduce the reader to the mapcode formalism. In Section 3 we define a class of maps that we call primal maps. Just as partial recursive maps are generated from the set of initial functions by recursion and minimization, primal maps are generated from the initial functions by conditioning and taking limits of iterates of maps. In Section 4 we show that the class of primal maps coincides with the set of partial recursive maps. 2
Mapcode formalism
On pages 10 and 13, Mitchell (2002) says: From a mathematical point of view, a program defines a function. The output of a program is computed as a function of the program inputs and the state of the machine before the program starts. .. . Intuitively, a function is computable if there is some program that computes it. More specifically, a function f : A → B is computable if there is an algorithm that, given any x ∈ A as input, halts with y = f (x) as output. One problem with this intuitive definition of computable is that a program has to be written out in some programming language,
278
K. Venkata Rao and Kasturi Viswanath and we need to have some implementation to execute the program. It might very well be that, in one programming language, there is a program to compute some mathematical function and in another language there is not.
The ‘problem’ mentioned above is addressed by Knuth by giving a mathematical definition of an algorithm. He says on page 7 of Volume 1 of Knuth (2002) that an algorithm may be modeled by a self-map F : X → X on a set X, augmented with some additional structure. The definition of algorithm given below is different from Knuth’s but is equivalent to it. Here we confine ourselves to sets of the form Np . For a more general setup and more details the reader is referred to Viswanath (2008). Definitions 2.1. Let F : D ⊆ Np → Np . 1. A nonempty subset A ⊆ D is said to be invariant under F if F (A) ⊆ A. 2. x ∈ D is called a fixed point of F if F (x) = x. The set fix (F ) = {x ∈ D | F (x) = x} is called the fixed point set of F . . 3. If x ∈ D and F (x) ∈ D, then F 2 (x) = F (F (x)). More generally, if . x, F (x), · · · , F n (x) are all in D then F n+1 (x) = F (F n (x)). 4. The set stab(F ) = {x ∈ D | F n (x) ∈ D, ∀n ∈ N} is called the stable set of F . Elements of stab(F ) are called stable points of F . 5. The set con(F ) = {x ∈ D | F n (x) ∈ fix (F ) for some n ≥ 0} is called the convergent set of F , and elements of con(F ) are called convergent points of F . 6. x is said to be divergent if x is not convergent. The set of all divergent points of F is written div(F ). 7. For any x ∈ con(F ), let N (x) be the least n ≥ 0 such that F n (x) ∈ fix (F ). N (x) is called the runtime of F at x. 8. The map F ∞ : con(F ) → fix (F ) defined by F ∞ (x) = F N (x) (x) is called the limit map of F . 9. If F (x) = y we write x 7→ y and if F ∞ (x) = y we write x 7→∗ y. Remarks 2.1. 1. The sets fix (F ), con(F ) and stab(F ) are invariant under F and every invariant set A of F is a subset of stab(F ). In particular con(F ) ⊆ stab(F ).
Mapcode characterization of partial recursive maps
279
2. If F = Id : Np → Np is the identity map then con(F ) = fix (F ) = Np and F ∞ = Id. Further, the runtime N (x) = 0 for every x ∈ Np . We think of F as defining a computation. Given a state x ∈ X the computation proceeds by evaluating in turn F (x), F 2 (x), · · · . If x ∈ con(F ) then there comes a stage when F n (x) ∈ f ix(F ). The computation is considered then to terminate. Quoting Mitchell (2002) again, on page 11 he says that there are two different reasons why an expression may not have a value in a computation: Error Termination : Evaluation of the expression cannot proceed because of a conflict between operator and operand. Nontermination : Evaluation of the expression proceeds indefinitely. We note here that for elements of X not in stab(F ) evaluation fails for the first reason above. For elements of stab(F ) that are not in con(F ) evaluation fails for the second reason above. con(F ) is precisely the set of initial states for which the computation is guaranteed to terminate. Definitions 2.2. 1. Let ρ : S ⊆ Np → Nq , F : D ⊆ Nq → Nq , and π : H ⊆ Nq → Nr be partial maps. Then the ordered triple M = (ρ, F, π) is called a mapcode machine (over N). The maps ρ, F, and π are called the coding map, program map, and decoding map of the machine respectively. 2. The set Ω = {s ∈ S | ρ(s) ∈ con(F ), F ∞ (ρ(s)) ∈ H} is called the halting set of the mapcode machine M . 3. The map Φ = π ◦ F ∞ ◦ ρ : Ω ⊆ Np → Nr is called the input-output map (or i-o map) of the mapcode machine M . 4. The mapcode machine (ρ, F, π) is said to be an algorithm for computing the i-o map Φ. The terminology of ‘halting set’ and ‘input-output map’ and the notations for them are borrowed from Blum et al. (1998). However, our context is more general than theirs. The components of a mapcode machine, namely the maps ρ, F , and π, constitute its syntax. The input-output map Φ gives the semantics of the machine. The examples below illustrate the ideas discussed above.
280
K. Venkata Rao and Kasturi Viswanath Examples 2.1. 1. Suppose ρ : N → N3 , F : N3 → N3 , and π : N3 → N are defined by ρ(x) = (x, 0, 0), π(x, y, z) = z and ( (x, y, z), if x = y; F (x, y, z) = (x, y + 1, y), if x 6= y. We claim that the halting set Ω is N and that Φ(x) = decr(x), where decr(x) is the decrement function defined by ( x − 1, if x > 0; decr(x) = 0, if x = 0. Let x > 0. Then ρ(x) = (x, 0, 0). We have (x, 0, 0) 7→ (x, 1, 0) 7→ (x, 2, 1) 7→∗ (x, x, x − 1). So Φ(x) = π(F ∞ (ρ(x))) = π(x, x, x − 1) = x − 1. It is easy to check that Φ(0) = 0. Hence Ω = N and Φ(x) = decr(x). On occasion we write decr(x) = x −. 1.
2. Suppose ρ : N2 → N3 , F : N3 → N3 , and π : N3 → N are defined by ρ(x, y) = (x, 0, y), π(x, y, z) = z and ( (x, y, z), if x = y; F (x, y, z) = (x, y + 1, z + 1), if x 6= y. Note that if x > 0 then ρ(x, y) = (x, 0, y) 7→ (x, 1, y + 1) 7→ (x, 2, y + 2) 7→∗ (x, x, y + x). If x = 0, then ρ(0, y) = (0, 0, y) ∈ f ix(F ). In either case Φ(x, y) = x + y. Also Ω = N2 . 3. Suppose ρ : N2 → N4 , F : N4 → N4 , and π : N4 → N are defined by ρ(x, y) = (x, y, 0, 0), π(x, y, z, w) = w, and ( (x, y, z, w), if x = z; F (x, y, z, w) = (x, y, z + 1, w + y), if x 6= z. For x > 0, ρ(x, y) = (x, y, 0, 0) 7→ (x, y, 1, y) 7→ (x, y, 2, 2y) 7→∗ (x, y, x, xy). So Φ(x, y) = xy. This last equality is true even if x = 0. So Ω = N2 and Φ(x, y) = xy.
Mapcode characterization of partial recursive maps
281
The definition of an algorithm given above in terms of a mapcode machine, while it does not seem to appear quite so explicitly in the literature (except for Knuth’s definition), nevertheless seems to be not new in spirit. See for example what Mills (2006) has to say on page 13: One technique, and a common theme in this book, is that we have an initial state, a body of code that is applied repeatedly to the state, a test that indicates when the computation is complete, and a method for extracting the desired information from the final state. The distinction between iterative, recursive, logical, machine and combinator code is merely in the way in which this theme is expressed. The concept is the same, regardless of the specific language or paradigm. 3
Primal maps
Consider the set of all maps from Np to Nq , with p and q varying in P. In this very large collection of maps that may theoretically be defined, we are interested in identifying a sub-collection of maps that may ‘reasonably’ be considered to be ‘computable’. Classical theory has addressed this problem and come up with the class of partial recursive maps, see Cutland (1980). Here we take another point of view and define the class of primal maps. Definitions 3.1. 1. Let A ⊆ N p . The indicator function IA : N p → N of A is defined by ( 1, if x ∈ A; IA (x) = 0, if x ∈ / A. 2. For any maps f : Df ⊆ Np → Nq , and g : Dg ⊆ Np → Nq define the functions If =g and If 6=g by ( 1, if f (x) = g(x), If =g (x) = 0, if f (x) = 6 g(x), ( 1, if f (x) = 6 g(x), If 6=g (x) = 0, if f (x) = g(x). These functions are defined on the set Df ∩ Dg . 3. Let f : Df ⊆ Np → Nq and g : Dg ⊆ Nq → Nr . Define D = {x ∈ Df | f (x) ∈ Dg }. Then the composition g ◦ f : D ⊆ Np → Nr is given by (g ◦ f )(x) = g(f (x)).
282
K. Venkata Rao and Kasturi Viswanath
4. If f : Df ⊆ Np → Nq and g : Dg ⊆ Np → Nr are two maps then their juxtaposition (f, g) : Df ∩ Dg ⊆ Np → Nq+r is defined by (f, g)(x) = (f (x), g(x)). 5. Let fi : Dfi ⊆ Np → Nq , gi : Dgi ⊆ Np → Nr for i = 1, 2. The conditional map (f1 , f2 )|(g1 , g2 ) is defined by ( f1 (x), if g1 (x) = g2 (x); (f1 , f2 )|(g1 , g2 )(x) = f2 (x), if g1 (x) 6= g2 (x). . . If Dg1 =g2 = {x ∈ Dg1 ∩ Dg2 | g1 (x) = g2 (x)} and Dg1 6=g2 = {x ∈ Dg1 ∩ Dg2 | g1 (x) 6= g2 (x)} then the two sets are called guards of the conditional map and the maps f1 and f2 are called command maps. The maps f1 , f2 , g1 and g2 are called components of the conditional map. The map (f1 , f2 )|(g1 , g2 ) is said to be obtained by conditioning (f1 , f2 ) with respect to (g1 , g2 ). It is defined on the set (Df1 ∩Dg1 =g2 )∪ (Df2 ∩ Dg1 6=g2 ). The conditional map (f1 , f2 )|(g1 , g2 ) could be a total map even if f1 , f2 are partial. This happens when g1 , g2 are total, Dg1 =g2 ⊆ Df1 and Dg1 6=g2 ⊆ Df2 . If g1 , g2 are not total then the conditional map is not total. 6. (a) zero : N → N is defined by zero(x) = 0 for all x ∈ N. (b) succ : N → N is defined by succ(x) = x + 1 for all x ∈ N. (c) For 1 ≤ i ≤ m the projection map Pim : Nm → N is defined by Pim (x) = xi for all x = (x1 , x2 , . . . , xm ) ∈ Nm . The functions zero, succ, and Pim are called initial functions. Definition 3.2. The class of primal maps is the smallest class of maps that contains the initial functions and is closed under juxtaposition, conditional maps and input-output maps of mapcode machines (ρ, F, π). It is to be noted that the maps ρ, F , and π are always chosen from the initial functions or from those primal maps that have already been constructed. A set is said to be primal if its indicator function is primal. From the definition of primal maps, the i-o map Φ = π ◦F ∞ ◦ρ is a primal map whenever ρ, F, π are primal, and the conditional map (f1 , f2 )|(g1 , g2 ) is a primal map whenever f1 , f2 , g1 , g2 are primal. The examples below help the reader become familiar with the mode of reasoning when using primal maps.
Mapcode characterization of partial recursive maps
283
Examples 3.1. 1. The initial functions zero, succ, and Pim are primal maps by definition. 2. For each p, the identity map Id : Np → Np is a primal map because it can be expressed as a juxtaposition of projection maps. 3. Compositions of primal maps are primal. To see this let f : Df ⊆ Np → Nq , and g : Dg ⊆ Nq → Nr be primal maps. Let ρ = f , F = Id on Nq , and π = g. The ordered triple (ρ, Id, π) is a mapcode machine. The halting set Ω = {s ∈ Df | f (s) ∈ Dg }, and Φ = π ◦ F ∞ ◦ ρ = g ◦ Id ◦ f = g ◦ f , so that g ◦ f is a primal map. 4. Constant maps are primal. For any c ∈ N, the function fc (x) = c, for all x ∈ N, is given by fc = succ c ◦ zero : N → N. Thus fc is a primal map. Given a projection map Pim , the map fc ◦ Pim : Nm → N is the constant function sending x 7→ c. The juxtaposition of l constant functions produces the constant map x 7→ (c1 , c2 , . . . , cl ) for any x ∈ Nm . 5. Referring to Examples 2.1 and using the definition of primal maps along with the results above we see that the functions sum(x, y) = x + y, prod(x, y) = xy and decr are all primal functions. It follows that addition of vector tuples and scalar multiplication of vectors are also primal. Further the sum and product of primal functions are primal. 6. The proper subtraction map psub(x, y) = x −. y from N2 to N is defined by ( x − y, if x ≥ y ; psub(x, y) = 0, if x < y. To show that psub is primal, let ρ : N2 → N4 , F : N4 → N4 , and π : N4 → N be defined by ρ(x, y) = (x, y, 0, x), π(x, y, z, w) = w, and ( (x, y, z, w), if y = z; F (x, y, z, w) = . (x, y, z + 1, w − 1), if y 6= z. We illustrate what happens in the two cases when (x, y) = (5, 3) and (x, y) = (2, 3). ρ(5, 3) = (5, 3, 0, 5) 7→ (5, 3, 1, 4) 7→ (5, 3, 2, 3) 7→ (5, 3, 3, 2) ∈ f ix(F );
284
K. Venkata Rao and Kasturi Viswanath and ρ(2, 3) = (2, 3, 0, 2) 7→ (2, 3, 1, 1) 7→ (2, 3, 2, 0) 7→ (2, 3, 3, 0) ∈ f ix(F ). We leave it to the reader to prove that psub is primal. It follows that if f : Np → N and g : Np → N are primal then f −. g is also primal.
7. The map diff : N2 → N sending (x, y) to |x − y| can be written as diff (x, y) = psub(x, y) + psub(y, x). Consequently, diff is primal and if f : Np → N and g : Np → N are primal then so is |f − g|. 8. The set P of positive integers is primal. To see this let ρ,F ,and π all map N to N. Define ρ = Id = π, and ( 0, if x = 0; F (x) = 1, if x 6= 0. Then 0 and 1 are both fixed points of F and F ∞ (0) = 0 and F ∞ (x) = 1 if x 6= 0. Consequently the indicator function of P is primal. The set {0} is primal since its indicator function is given by I{0} = 1 −. IP . 9. More generally if A, B ⊆ Np are primal then so are Ac , A ∩ B, A ∪ B, and A × B. 10. Let f : Np → N and g : Np → N be primal. Then the indicator functions If =g and If 6=g defined in Definitions 3.1 are primal. So the sets A = {x ∈ Np | f (x) = g(x)} and B = {x ∈ Np | f (x) 6= g(x)} are primal. In particular the sets A = {(x, y) ∈ N2 | x = y} and B = {(x, y) ∈ N2 | x 6= y} are primal. By definition, the class of primal maps contains the initial functions and is closed under juxtaposition. We have shown that the class is also closed under composition. To continue, we recall the definition of recursion in the theory of partial recursive functions. Definitions 3.3. equations
1. Let a ∈ N and let g : Dg ⊆ N2 → N. The two h(0) = a h(x + 1) = g(x, h(x))
define a unique map h : Dh ⊆ N → N where Dh is defined by
Mapcode characterization of partial recursive maps
285
(a) 0 ∈ Dh ; (b) If 0, 1, . . . , x ∈ Dh and (x, h(x)) ∈ Dg then x + 1 ∈ Dh . h is said to be defined by recursion from a and g. 2. Let f : Df ⊆ Np → N and g : Dg ⊆ Np × N2 → N. The two equations h(x, 0) = f (x) h(x, y + 1) = g(x, y, h(x, y)) define a unique map h : Dh ⊆ Np × N → N on the subset Dh defined by (a) (x, 0) ∈ Dh if and only if x ∈ Df ; (b) If (x, 0), (x, 1), · · · , (x, y) ∈ Dh and (x, y, h(x, y)) ∈ Dg , then (x, y + 1) ∈ Dh . h is said to be defined by recursion from f and g. Theorem 3.1. The class of primal maps is closed under recursion. Proof. Let a ∈ N and let g : Dg ⊆ N2 → N be a primal map. Let h be defined recursively by a and g as in Definition 3.3. We must prove that h is a primal map. Define ρ : N → N3 by ρ(x) = (x, 0, a). ρ is total and also primal because it is a juxtaposition of the identity with two constant functions. Define the output map π to be the projection function P33 . Then π is total and also primal. Let DF = {(x, y, z) | x = y} ∪ {(x, y, z) | x 6= y, (y, z) ∈ Dg } and define F : DF ⊆ N3 → N3 by ( (x, y, z), if x = y; F (x, y, z) = (x, y + 1, g(y, z)), if x = 6 y. F is primal because all its components are primal. We claim that the halting set Ω = Dh and Φ = h. Recall that if F (x, y, z) = (x′ , y ′ , z ′ ) we write (x, y, z) 7→ (x′ , y ′ , z ′ ). Let x ∈ Dh . We then have ρ(x) = (x, 0, h(0)) 7→ (x, 1, h(1)) 7→ · · · 7→ (x, x, h(x)) ∈ f ix(F ).
286
K. Venkata Rao and Kasturi Viswanath
So Dh ⊆ Ω and for x ∈ Dh , Φ(x) = π(F ∞ (ρ(x))) = h(x). Suppose that x∈ / Dh . Then there exists u < x such that (u, h(u)) ∈ / Dg . Without loss of generality let us suppose that u is the least such. So (x, u, h(u)) ∈ / D. This means that (x, 0, a) ∈ / stab(F ) and so can not be in con(F ). In turn, we conclude that x ∈ / Ω. So Ω = Dh and h = Φ. So h is primal. Let us now consider the general case and suppose that h is defined recursively by f and g as in Definition 3.3. Assume that f and g are primal. We need to prove that h is a primal map. Let X = Np × N × N × N and let (x, y, z, w) ∈ X be a general element of X. Define ρ : Df × N ⊆ Np × N → X by ρ(x, y) = (x, y, 0, f (x)). Then ρ is primal with domain Df × N. Define π : X → N by π(x, y, z, w) = w. π is primal and total. Let F : DF ⊆ X → X be given by ( (x, y, z, w), if y = z F (x, y, z, w) = (x, y, z + 1, g(x, z, w)), if y 6= z. where DF = {(x, y, z, w) | y = z} ∪ {(x, y, z, w) | y 6= z, (x, z, w) ∈ Dg }. F is primal because all its components are primal. We claim that the halting set Ω = Dh and Φ = h. Let (x, y) ∈ Dh . We then have ρ(x, y) = (x, y, 0, f (x)) and (x, y, 0, f (x)) 7→ (x, y, 1, h(x, 1)) 7→ · · · 7→ (x, y, y, h(x, y)) ∈ f ix(F ). So Dh ⊆ Ω and Φ(x) = π(F ∞ (ρ(x))) = h(x). The reverse inequality follows as in the above case. So Ω = Dh and h = Φ. Thus h is primal. 2 Definition 3.4. Let f : Df ⊆ Np × N → N. Call x ∈ Np a special point of f if there exists z ∈ N such that (x, 0), (x, 1), . . . , (x, z) ∈ Df , and f (x, z) = 0. Let D be the set of all special points of f . For x ∈ D, define (µf )(x) = min{z ∈ N | f (x, z) = 0}. Then µf : D ⊆ Np → N is said to be defined by minimization on f . Theorem 3.2. The class of primal maps is closed under minimization. Proof. Let f : Df ⊆ Np × N → N be a primal map. We prove that µf is primal. Define ρ : Np → Np × N by ρ(x) = (x, 0), π : Np × N → N by π(x, y) = y, and F : Np × N → Np × N by ( (x, y + 1), if f (x, y) 6= 0 F (x, y) = (x, y), if f (x, y) = 0.
Mapcode characterization of partial recursive maps
287
Then the maps ρ, π and F are primal maps, and (ρ, F, π) is a mapcode machine with µf = Φ. Thus the class of primal maps is closed under minimization. 2 4
Partial recursive maps
We recall the definition of partial recursive maps and some of their properties that are needed here from the classical theory of computation, see Blum et al. (1998). Definition 4.1. The class of partial recursive maps is the smallest class of maps that contains the initial functions and is closed under juxtaposition, composition, recursion and minimization. Remarks 4.1. sive.
1. The indicator functions I0 and IP are partial recur-
2. If f and g are partial recursive maps then f + g, f · g, f g , f −. g, and |f − g| are partial recursive. Further the indicator functions If =g and If 6=g defined in Definition 3.1 are partial recursive. 3. Let F : D ⊆ Nm → Nm be partial recursive. Then IF =Id : D ⊆ Nm → N and IF 6=Id : D ⊆ Nm → N are partial recursive. However, it is to be noted that these maps are different from the total indicator functions If ix(F ) : Nm → N and ID\f ix(F ) : Nm → N which may not be partial recursive. Apart from the simple results above we need to collect together some further results featuring Godel numbers. Let p1 , p2 , . . . be the sequence of prime numbers in their natural ordering. So p1 = 2, p2 = 3, p3 = 5, and so on. Definition 4.2. Let x = (x1 , x2 , . . . , xk ) ∈ Nk . Define ξk : Nk → N by ξk (x) = px1 1 +1 px2 2 +1 . . . pxk k +1 . ξk (x) is called the Godel number of x. Remark 4.2. ξk is clearly a total function and also injective. It is known that ξk is partial recursive. Definition 4.3. Let m ∈ N. If m > 0 define (m)i to be the exponent of pi in the prime factorization of m. If m = 0 define (m)i = 0 for all i. Define ηk : N → Nk by ηk (m) = ((m)1 −. 1, (m)2 −. 1, . . . , (m)k −. 1).
288
K. Venkata Rao and Kasturi Viswanath
Remark 4.3. Clearly ηk is total. It may be shown that ηk is partial recursive and that ηk ◦ ξk = Id. That is to say, ηk is a left inverse of ξk . The example below may help fix these ideas. Example 4.1. We have ξ2 (0, 0) = 6, ξ2 (1, 0) = 12, ξ2 (0, 1) = 18. Also η2 (0) = η2 (1) = η2 (2) = η2 (3) = η2 (6) = (0, 0) and η2 (4) = η2 (12) = (1, 0), η2 (18) = (0, 1). Hence η2 (ξ2 (0, 0)) = η2 ( 6) = (0, 0), η2 (ξ2 (1, 0)) = η2 (12) = (1, 0), η2 (ξ2 (0, 1)) = η2 (18) = (0, 1). This illustrates the left inverse property. In the definition of recursion given in the usual form as in Definition 3.3 the codomain of the functions f , g, and h is N. This form of recursion needs to be generalized to the case when the codomain is of the form Nq . Theorem 4.1 below is simple but we are not aware of any reference in the literature. Definitions 4.4. two equations
1. Let a ∈ Nq and let g : Dg ⊆ N × Nq → Nq . The
h(0) = a, h(x + 1) = g(x, h(x)), define a unique partial map h : N → Nq on the subset Dh defined by (a) 0 ∈ Dh ; (b) if 0, 1, . . . , x ∈ Dh and (x, h(x)) ∈ Dg then x + 1 ∈ Dh . h is said to be defined by general recursion from a and g.
Mapcode characterization of partial recursive maps
289
2. Let f : Df ⊆ Np → Nq and g : Dg ⊆ Np × N × Nq → Nq . The two equations h(x, 0) = f (x), h(x, y + 1) = g(x, y, h(x, y)), define a unique partial map h : Np × N → Nq on the subset Dh by (a) (x, 0) ∈ Dh if and only if x ∈ Df ; (b) if (x, 0), (x, 1), · · · , (x, y) ∈ Dh and (x, y, h(x, y)) ∈ Dg , then (x, y + 1) ∈ Dh . h is said to be defined by general recursion from f and g. Theorem 4.1. The class of partial recursive maps is closed under general recursion. Proof. Let a ∈ Nq and let g : Dg ⊆ N × Nq → Nq be a partial recursive map. Let h : N → Nq be the partial map defined by a and g by general recursion. We prove that h is a partial recursive map. Consider the partial recursive maps ξ = ξq : Nq → N and η = ηq : N → Let e a = ξ(a) and define e g : N × N → N by ge(x, y) = ξ(g(x, η(y))). Then e g is partial recursive. Let h : N → N be the map obtained from e e a and e g by recursion. Then e h is also a partial recursive map and it is given by Nq .
e h(0) = e a,
e h(x + 1) = ge(x, e h(x)).
We shall prove by induction that e h = ξ◦h. Clearly e h(0) = ξ(a) = ξ(h(0)).
Assume that 0, 1, . . . , x ∈ Deh and that e h(x) = ξ(h(x)) so that η(e h(x)) = h(x). Then x + 1 ∈ Deh
⇔
(x, e h(x)) ∈ Deg ⇔ (x, η(e h(x)) ∈ Dg
⇔ (x, h(x)) ∈ Dg ⇔ x + 1 ∈ Dh . Further,
e h(x + 1) = ge(x, e h(x)) = ξ(g(x, η(e h(x)))) = ξ(g(x, h(x))) = ξ(h(x + 1)). This proves that h = η ◦ e h is a partial recursive map.
290
K. Venkata Rao and Kasturi Viswanath
Consider next two partial recursive maps f : Df ⊆ Np → Nq and g : Dg ⊆ Np × N × Nq → Nq . Let h be the map obtained from f and g by general recursion. Consider the maps ξ = ξq : Nq → N and η = ηq : N → Nq . Let fe = ξ ◦ f , and let ge : Np × N2 → N be given by ge(x, y, z) = ξ(g(x, y, η(z))). Clearly, the maps fe and ge are partial recursive. Let e h : Np × N → N be the map obtained from fe and ge by recursion. Then e h is partial recursive and is given by e h(x, 0) = fe(x),
and
e h(x, y + 1) = e g(x, y, e h(x, y)).
We shall prove by induction that e h = ξ ◦ h.
Clearly e h(x, 0) = fe(x) = ξ(f (x)) = ξ(h(x, 0)). Assume that (x, 0), (x, 1), . . . , (x, y) ∈ Deh and e h(x, y) = ξ(h(x, y)) for some (x, y) so that e η(h(x, y)) = h(x, y). Then h(x, y)) ∈ Deg ⇔ (x, y, h(x, y)) ∈ Dg (x, y + 1) ∈ Deh ⇔ (x, y, e ⇔ (x, y + 1) ∈ Dh .
Further,
e h(x, y + 1) = e g(x, y, e h(x, y)) = ξ(g(x, y, η(e h(x, y)))) = ξ(g(x, y, h(x, y))) = ξ(h(x, y + 1)).
This proves that h = η ◦ e h is a partial recursive map. Theorem 4.2. If F : D ⊆ map (x, n) 7→ F n (x).
Np
→
Np
2
is partial recursive then so is the
Proof. Define a map G : Np × N × Np → Np by G(x, n, z) = F (z). Then the maps Id : Np → Np and G are partial recursive maps. If H : Np ×N → Np is obtained from Id and G by general recursion then H is a partial recursive map. We prove by induction that H(x, n) = F n (x). Clearly, H(x, 0) = x = F 0 (x). Assume that (x, n) ∈ DH and that H(x, n) = F n (x) for some (x, n). Then (x, n + 1) ∈ DH ⇔ (x, n, H(x, n)) ∈ DG ⇔ H(x, n) ∈ DF ⇔ F n (x) ∈ DF ⇔ F n+1 (x) is defined and H(x, n + 1) = G(x, n, H(x, n)) = G(x, n, F n (x)) = F (F n (x)) = F n+1 (x). This proves the theorem.
2
Mapcode characterization of partial recursive maps
291
Theorem 4.3. The class of primal maps coincides with the class of partial recursive maps. Proof. We have already seen that the class of primal maps contains the initial functions and is closed under juxtaposition, composition, recursion and minimization. Since the class of partial recursive maps is the smallest such class this proves that every partial recursive map is primal. To prove that every primal map is partial recursive it is enough to prove that the class of partial recursive maps is closed under conditioning and input-output maps of mapcode machines. We first prove closure under conditional maps. Let f1 , f2 : Np → Nq , and g1 , g2 : Np → Nr be partial recursive. Then the conditional map f = (f1 , f2 )|(g1 , g2 ) defined in Definition 3.1 can be written as f (x) = f1 (x) · Ig1 =g2 (x) + f2 (x) · Ig1 6=g2 (x). By Remarks 4.1 f is partial recursive. Next we prove closure under input-output maps. Let ρ : S ⊆ Np → Nq , F : D ⊆ Nq → Nq , and π : H ⊆ Nq → Nr be partial recursive. Let A = D\fix (F ). By Remarks 4.1 and Theorem 4.2 the maps (IA |D ) : D ⊆ Nq → N and (x, k) 7→ F k (x) are partial recursive. By composition the map f (s, k) = (IA |D )(F k (ρ(s))) is partial recursive. But ( / fix (F ), 1, if F k (ρ(s)) ∈ f (s, k) = k 0, if F (ρ(s)) ∈ fix (F ). Recalling the definition of the runtime map given in Definitions 2.1 and by minimization on f , the map s 7→ N (ρ(s)) is partial recursive. By Remarks 4.1, the map s 7→ F N (ρ(s)) (ρ(s)) = F ∞ (ρ(s)) is partial recursive. Hence the input-output map Φ(s) = π(F ∞ (ρ(s))) is a partial recursive map. This proves the theorem.
2
Acknowledgement. Ashok Maitra (2006) sent us a proof that the limit map of a partial recursive map is partial recursive. An analysis of his proof led us to the theorem on general recursion proved here. We are grateful to Kesav Nori for advice and guidance. The second author also gratefully acknowledges the financial support by Tata Consultancy Services Ltd.
292
K. Venkata Rao and Kasturi Viswanath References
Blum, L., Cucker, F., Shub, M. and Smale, S. (1998). Complexity and Real Computation. Springer-Verlag, New York, USA. Bohm, C. and Jacopini, G. (1966). Flow diagrams, Turing machines and languages with only two formation rules. Comm. ACM, 9, 366–371. Cutland, N. (1980). Computability: An Introduction to Recursive Function Theory. Cambridge University Press, Cambridge, UK. Knuth, D.E. (2002). The Art of Computer Programming, Vol. I - III, 3rd ed. Pearson Education Asia, New Delhi, India. Maitra, A.P. (2006). Mapcode theory and recursive functions. Personal Communication. Mills, B. (2006). Theoretical Introduction to Programming. Springer, London. Mitchell, J.C. (2002). Concepts in Programming Languages. Cambridge University Press, New York, USA. Viswanath, K (2003). Dynamical systems and computer science. Mathematics Newsletter of the Ramanujan Math. Soc., 13, 33–48. Viswanath, K. (2004). Building programs and proving them correct with dynamical systems. In Proceedings of the International Conference on Computing, Communications and Control Technologies. International Institute of Informatics and Systemics, Orlando, Florida, USA, 372–377. Viswanath, K. (2005). Simple foundations for computing. In Proceedings of the 40th Annual Convention of the Computer Society of India. Hyderabad, India. Viswanath, K. (2006a). An invitation to mathematical computer science. In Discrete Mathematics and Its Applications, (M. Sethumadhavan, ed.). Narosa, New Delhi, India. Viswanath, K. (2006b). Computing with dynamical systems. Differential Equations Dynam. Systems, 14, 1–24. Viswanath, K. (2008). An Introduction to Mathematical Computer Science. The Universities Press, Hyderabad, India.
K. Venkata Rao Department of Mathematics Government College (A) Rajahmundry 533105 Andhra Pradesh, India. E-mail:
[email protected]
Paper received June 2009; revised November 2009.
Kasturi Viswanath International Institute of Information Technology Hyderabad 500032 Andhra Pradesh, India E-mail:
[email protected]