Volume 106 - No. 4, November 2014
Mapcode Theory in Designing Programs
Venkata Rao Kuchibhotla
Government College (A),Rajahmundry, A.P., India-533101
B.Gayatri Devi
Godavari Institute of Engineering and Technology, Rajanagaram,
A.P., India-533296
ABSTRACT
A methodology is proposed for designing a program that takes care of safety (semantics) and termination using Mapcode theory.
General Terms:
Theory of Computation, program designing
Keywords:
partial recursive functions, primal maps, mapcode theory
1. INTRODUCTION
The concept of computability in the theory of computation is introduced to the students through many models like Turing machines, Partial Recursive Functions,λ-calculus, Post machines, and Register machines. When dealing with practical computing problems, the same students need to learn a programming language and study how to express algorithms in that language. Thus there is a disconnect between theory and practice.
In addition to the problem mentioned above, there are issues like analysis and design of programs which require a study on the prin-ciples involved in it. David Gries in his book [4] pointed out that
“Programming began as an art, and even to day most people learn only by watching others perform (e.g. a lecturer, a friend) and through habit, with little direc-tion as to the principles involved. ... we are reaching the point where we can begin to teach the principles so that they can be consciously applied”.
In a series of articles [9, 10, 11, 12, 13] and a book [14] a theory called ‘mapcode formalism’ has been presented as an alternative approach so that a student can learn both the theoretical and practical issues in terms of a single framework. In the article [7] a class of maps called primal maps using mapcode theory was introduced and it was proved that the class of primal maps coincide with the class of partial recursive maps.
In continuation of the work, in the article [8] a mathematical framework was proposed that systematically helps in analyzing programs, particularly when dealing with ideas as in [2]. The present article addresses some of the issues related to design of programs. Certain structures are identified in designing a program
and certain classes of primal maps are identified based on the programing structure for computing them. It is proposed that the identified classes of maps act as building blocks in designing a program for computing a primal map. This is verified with some of the standard examples discussed in [5] which are used to train students in the discipline of programming. However, it is not claimed that the classification is complete. But this kind of study helps in understanding design of algorithms and ensuring safety and termination simultaneously. This article presents a class of primal maps called maps admitting variations and a program structure which works for any map in the class.
LetNandPdenote the set of all non-negative integers and the set
of all positive integers respectively. Maps under consideration are those maps which are defined on subsets ofNpintoNrforp, r∈P.
A function is a map from a subset ofNpintoN. A mapf with
domainD ⊆ Npand codomainNris called a partial map. It will
be denoted by eitherf :Np → Nrorf : D ⊆ Np → Nr. The
domainDoff can also be written asDf ordom(f)when it is necessary to indicate the dependence ofDonf. IfDf =Np,fis
said to betotal. The symbol=. may be read as ‘is defined as’. The symbolsS, X, T are used for specific purposes. They are subsets ofNnpossibly for different values ofn.
2. MAPCODE FORMALISM
The definition of algorithm and other concepts given below are par-ticular cases of a more general setup presented in [14]. This article is confined to the subsets ofNqfor someq∈P.
DEFINITION 1. A mapF:D⊆Nq→Nqis called a Program
Map onNq. LetFbe a program map onNq.
(1) x∈ D is called afixed pointofF ifF(x) = x. The set of all fixed points ofFis denoted byfix(F). It is called the fixed point set ofF.
(2) Ifx∈DandF(x)∈D, thenF2(x)=. F(F(x)). More gen-erally, ifx, F(x),· · ·, Fn(x)are all in DthenFn+1(x) =. F(Fn(x)). By convention, F0(x) = x for any x, and F1(x) =F(x).
(3) con(F) =. {x ∈ D|Fn(x) ∈ fix(F)for somen ≥ 0}is called theconvergent setofF, and elements ofcon(F)are calledconvergent pointsofF.
(4) For anyx∈ con(F), letN(x)be the leastn≥ 0such that Fn(x)∈fix(F).N(x)is called theruntimeofFatx. (5) The mapF∞ : con(F) → fix(F) defined by F∞(x) =
Volume 106 - No. 4, November 2014
REMARK 2. IfF =Id :Nq → Nq is the identity map then
con(F) = fix(F) = Nq andF∞ = Id. Further, the runtime
N(x) = 0for everyx∈Nq. 2
One can think ofF as defining a computation. Knuth [6] says the same thing when he observes that a mathematical theory of algo-rithms can be built by modeling an algorithm as a mapF. Given a statex ∈ Nq the computation proceeds by evaluating in turn
F(x), F2(x),· · ·. Ifx∈ con(F)then there comes a stage when Fn(x) ∈ f ix(F). The computation is then considered to termi-nate.
DEFINITION 3. (1) Letρ:S ⊆ Np →Nq,F :X ⊆Nq →
Nq, andπ:H ⊆Nq→Nrbe partial maps. Then the ordered
tripleM = (ρ, F, π)is called amapcode machine(overN).
The mapsρ, F,andπare called thecoding map, program map, anddecoding mapof the machine respectively.
(2) The setΩ =. {s ∈ S|ρ(s) ∈con(F), F∞(ρ(s)) ∈ H}is
called thehalting setof the mapcode machineM. (3) The mapφ = π◦F∞◦ρ : Ω ⊆
Np → Nr is called the
semantic mapof the mapcode machineM.
(4) Letf:Np→Nrbe a partial map with its domainDf, and let M = (ρ, F, π)be a mapcode machine.M computesforM is analgorithmfor computingf, ifDf = Ω, the halting set of Mandf(s) =φ(s)for everys∈Df. 2 The terminology of ‘halting set’ and the notations for halt-ing set and semantic map are borrowed from [1]. However, this terminology in the mapcode theory [14] is more general than theirs.
The components of a mapcode machine, namely the mapsρ,F, and π, constitute its syntax. The semantic mapφgives the semantics of the machine.
3. SAFETY AND PROGRESS THEOREMS
Given a mapcode machine(ρ, F, π), to prove that a statexis con-vergent and the output is the specified one, there is a need to have some way of showing safety and progress. The concept of invariant principle ensures safety and the concept of a bound function [14] is useful for verifying the progress.
DEFINITION 4. Letf:Df ⊆Np→Nrbe a partial map and
M = (ρ, F, π)be a mapcode machine withρ :S ⊆Np → Nq,
F : X ⊆ Nq → Nq, andπ : H ⊆ Nq → Nr. Suppose that
Df ⊆S.
(1) A nonempty subsetV ⊆Xis said to beinvariantunderF if F(V)⊆V.
(2) A subsetV ⊆ Xis called aninvariant principleforfats∈ Df, ifV is invariant underF,ρ(s)∈V,V∩fix(F)⊆Hand π(V ∩fix(F)) ={f(s)}.
(3) A mapλ:X →Nis called abound functionforFif for every
x∈XwithF(x)∈Xeitherx∈fix(F)orλ(F(x))< λ(x). (4) For anys∈SdefineVs={Fn(ρ(s))|n≥0}. 2
REMARK 5. (1) Ifρ(s) ∈/ X thenF is not defined onρ(s).
ThenVs={ρ(s)}andVsis not invariant underF. Ifρ(s)∈ X, butF(ρ(s))∈/XthenFis not defined onF(ρ(s)). Then Vs ={ρ(s), F(ρ(s))}andVsis not invariant underF. Con-tinuing the argument inductively,Vsis invariant underFif and only ifFn(ρ(s))∈Xfor everyn≥0.
(2) Letx ∈ X and letλ(x) = 0. Then eitherx ∈ fix(F) or
F(x)∈/X. 2
THEOREM 6. Letf:Df ⊆Np→Nrbe a partial map,M =
(ρ, F, π)a mapcode machine andDf ⊆S. Ifλis a bound function forF and ifVs is an invariant principle forf at everys ∈ Df thenDf ⊆ Ωandφ(s) = f(s) for everys ∈ Df. Further, if ‘F(Vs)⊆Vs⇒s∈Df’ holds, thenMis an algorithm forf.
PROOF. Take anys∈Df. SinceVsis invariant underFby the remark [5],Fn(ρ(s))∈Xfor everyn∈
N. Letλ(ρ(s)) =n. If
Fn(ρ(s))∈/fix(F)then by the remark [5],λ(Fn(ρ(s)))>0. But on the other hand,
λ(F(ρ(s)))< λ(ρ(s)) =n ⇒ λ(F(ρ(s)))≤n−1, λ(F2(ρ(s)))< λ(F(ρ(s))) ⇒ λ(F2(ρ(s)))≤n−2,
. . . .
and finallyλ(Fn(ρ(s)))≤0, which is a contradiction.
It follows thatFn(ρ(s))∈fix(F). SinceV
sis an invariant prin-ciple,Fn(ρ(s))∈fix(F)∩V
s ⊆ Handπ(Fn(ρ(s))) = f(s). Thens ∈ Ωand φ(s) = f(s). This proves thatDf ⊆ Ωand φ(s) =f(s)fors∈Df.
Further suppose that ‘F(Vs)⊆Vs ⇒s∈Df’. Take anys ∈Ω. ThenFk(ρ(s))∈fix(F)for somek, so thatFn(ρ(s))is defined for alln. ThenF(Vs)⊆Vs. By hypothesis,s∈Df. This proves thatΩ⊆Df. HenceDf = ΩandM is an algorithm forf.
REMARK 7. The concept of a bound function can be
general-ized to a mapλ : X → P whereP is a partial order set. Let P be a partial order set such that there is no sequence{an}inP withan > an+1 for every n. A mapλ : X → P is called a bound function forF if for everyx∈ X withF(x) ∈X either x∈fix(F)orλ(F(x))< λ(x). With this concept, ifλis a bound function and ifVsis an invariant principle forf at everys∈Df thenDf ⊆ Ωand f(s) = φ(s)for every s ∈ Df. Further, if ‘F(Vs)⊆Vs⇒s∈Df’ thenMis an algorithm forf. 2 4. PRIMAL MAPS
In this section, a collection of maps called primal maps is intro-duced. It is a sub collection of the set of all maps fromNptoNr,
withpandrvarying inP.
DEFINITION 8. (1) Letf : Df ⊆ Np → Nqandg :Dg ⊆
Nq → Nr. DefineD ={x ∈ Df |f(x) ∈ Dg}. Then the compositiong◦f :D⊆Np→Nris given by(g◦f)(x) =
g(f(x)).
(2) Iff:Df ⊆Np→Nqandg:Dg ⊆Np→Nrare two maps
then theirjuxtaposition(f, g) :Df ∩Dg ⊆ Np → Nq+r is
defined by(f, g)(x) = (f(x), g(x)). (3) Letfi:Dfi⊆N
p→
Nq,gi:Dgi⊆N p→
Nrfori= 1,2.
The conditional map(f1, f2)|(g1, g2)is defined by
(f1, f2)|(g1, g2)(x) =
f1(x) ifg1(x) =g2(x); f2(x) ifg1(x)6=g2(x).
The sets Dg1=g2
.
= {x∈Dg1∩Dg2|g1(x) =g2(x)},and Dg16=g2
.
= {x∈Dg1∩Dg2|g1(x)6=g2(x)}
Volume 106 - No. 4, November 2014 (4) (a) zero:N→Nis defined byzero(x) = 0for allx∈N.
(b) succ : N → Nis defined bysucc(x) = x+ 1for all
x∈N.
(c) For 0 ≤ i < m the projection mapPm
i : Nm →
N is defined by Pm
i (x) = x[i − 1] for all x = (x[0], x[1], . . . , x[m−1])∈Nm.
The functionszero,succ,andPm
i are called initial functions. (5) For any setAdefine a functionχAbyχA(x) = 1ifx ∈A
andχA(x) = 0ifx /∈A. The functionχAis called indicator
function ofA. 2
DEFINITION 9. The class ofprimal mapsis the smallest class
of maps that contains the initial functions and is closed under jux-taposition, conditional maps and semantic maps of mapcode ma-chines(ρ, F, π).
A set is said to beprimalif its indicator function is primal. 2
REMARK 10. The term ‘closed under an operation’ needs
some explanation. It is explained in the case of semantic maps, and argument is similar for the other cases. A classCis closed under semantic maps of mapcode machines ifφ=π◦F∞◦ρ∈ C
when-everρ, F, π∈ C. 2
It is proved in [7] that the class of primal maps is the class of partial recursive maps from the classical theory of computation [3]. This shows that the set of operations involved in generating partial recursive maps from initial maps can be replaced by the set of operations involved in generating primal maps.
A class of maps called “maps admitting variations” is introduced in the next section and a design for computing such maps is proposed.
5. MAPS ADMITTING VARIATIONS
For any x = (x[0], x[1], . . . , x[k − 1]) ∈ Nk and y ∈ N,
the juxtaposition ofx, y is denoted by (x, y) so that(x, y) = (x[0], x[1], . . . , x[k−1], x[k])∈Nk+1withx[k] =y.
DEFINITION 11. (1) Letf1:D1 ⊆Nk→Nrandf2:D2⊆
Nk+1 → Nr. The mapf1 is called avariationoff2 if there exists a mapL : D3 ⊆ Nk+1×Nr → Nr as a nontrivial
solution of the equationf2(x, y) = L(x, y, f1(x)), for any (x, y) ∈ D1. The map Lis called lifting off1 to f2 ( or simply alift map). The equationf2(x, y) =L(x, y, f1(x))is referred aslift equation.
(2) Letp < n, and letfk :Dk ⊆ Nk →Nrforp≤ k≤ nbe given. Iffkis a variation offk+1forp≤k≤n−1then the mapsfp, fp+1, . . . , fn−1are calledvariationsoffn. 2
REMARK 12. (1) The mapL(x, y, t) =f2(x, y)for everyt,
is always a solution for the lift equation and it is called a trivial solution.
(2) Suppose thatfp, fp+1, . . . , fn−1 are variations offn. Then (x1, x2, . . . , xn) ∈ dom(fn) ⇔ (x1, x2, . . . , xk) ∈
dom(fk)forp≤k≤n.
(3) More general concept of variations of a mapfis given as a col-lection of mapsfiindexed by elementsiof a partial order set P. In this case,fiis a variation offjwheneverjis a successor
ofiinP. 2
EXAMPLE 1. Finding maximum (or minimum) of nintegers
and sum ofnintegers are simple examples to understand the idea behind the definition of variations of a map.
(1) Maximum Problem: For any 1 ≤ k ≤ n, and any x = (x[0], x[1], . . . , x[k − 1]) ∈ Nk, define
fk(x) = Max{x[0], x[1], . . . , x[k−1]}. Thenfk : Nk → N. It is easy to see that Max{x[0], x[1], . . . , x[k]} = Max{x[k],Max{x[0], x[1], . . . , x[k−1]} }orfk+1(x, y) = Max{y, fk(x)}, forx∈Nk, y∈N.
More precisely, ifLk+1 : Nk+1×N → Nis defined by
Lk+1(x, y, t) = Max{y, t}for anyx ∈ Nk, y, t ∈ N, then
fk+1(x, y) = Lk+1(x, y, fk(x)). The mapLk+1 is lifting of fk to fk+1. The maps f1, f2, . . . , fn−1 are variations of f=fn.
(2) Summation Problem:For any1 ≤ k ≤ n, and anyx = (x[0], x[1], . . . , x[k−1])∈Nk, definefk(x) =x[0] +x[1] + . . .+x[k−1]. Then fk : Nk → N. It is easy to see that
x[0] +x[1] +. . .+x[k] =x[k] + (x[0] +x[1] +. . .+x[k−1]) orfk+1(x, y) =y+fk(x), forx∈Nk, y∈N.
IfLk+1 : Nk+1×N → Nis defined byLk+1(x, y, t) = y +t, for any x ∈ Nk, y, t ∈ N, then fk+1(x, y) = Lk+1(x, y, fk(x)). Then the mapsf1, f2, . . . , fn−1 are
vari-ations off=fn. 2
Two more standard examples in the discipline of programming are given to fix the idea of variation in mind.
EXAMPLE 2. Checking Equality Problem:Choose and fix an
elementx0 = (x0[0], x0[1], . . . , x0[p−1])
inNp. Fork ∈Pwith 1≤k≤p, andx= (x[0], . . . , x[k−1])∈Nk, define
fk(x) = 1,if(x[0], . . . , x[k−1]) = (x0[0], . . . , x0[k−1]) = 0,if(x[0], . . . , x[k−1])6= (x0
[0], . . . , x0[k−1]).
The maps{f1, f2, . . . , fp−1}are variations off =fp. IfLk+1 :
Nk+1×N→Nis defined by
Lk+1(x, y, t) = t, ify=s0[k], and Lk+1(x, y, t) = 0, y6=s0[k],
thenfk+1(x, y) =Lk+1(x, y, fk(x)). The mapLk+1is lifting of
fktofk+1. 2
EXAMPLE 3. Pattern Matching Problem: The question is :
how many times the patterns0= (s0[0], s0[1], . . . s0[p−1])
occur in the sequences= (s[0], s[1], . . . s[n−1]), assuming thatnis many times larger thanp.
Consider the notation and terminology used in the example [2]. For any k ∈ P with p ≤ k ≤ n, define fk : Nk → Nby
fk(x)- the number of times the patternx0occurs inx. The maps {fp, fp+1, . . . , fn−1}are variations offn.
To findLk+1−lifting offktofk+1, the mapψkwhich picks up the lastpentries of the array(s[0], s[1], . . . , s[k−1])is needed. For any p ≤ k ≤ n, define the map ψk : Nk → Np by
ψk(x[0], x[1], . . . , x[k−1]) = (x[k−p], x[k−p+1], . . . , x[k−1]). Then for anyx= (x[0], x[1], . . . , x[k])∈Nk+1,
fk+1(x) = fk(x[0], x[1], . . . , x[k−1]) + 1, ifψk+1(x) =x0, fk+1(x) = fk(x[0], x[1], . . . , x[k−1]), ifψk+1(x)6=x0.
Volume 106 - No. 4, November 2014
THEOREM 13. suppose that {fp, fp+1, . . . , fn−1}are
varia-tions off =fn. LetLk+1be a lifting offktofk+1. Iffpand the mapLkare primal maps thenfis a primal map.
PROOF. Suppose thatfk : Nk → Nr forp ≤ k ≤ n. Given
thatfk+1(x, y) = Lk+1(x, y, fk(x))forp ≤ k ≤ n−1. Let ηk :Nn→ Nkbe defined byηk(x) = (x[0], x[1], . . . , x[k−1]) forx = (x[0], x[1], . . . , x[n−1]) ∈ Nn. Then the mapsηk are primal maps.
Withs = (s[0], s[1], . . . , s[n−1]) ∈ Nn,k ∈ Nandt ∈ Nr,
letx= (s, k, t)be a general element ofNn×N×Nr. Consider
the partial mapsρ:Nn →Nn×N×Nr,F :Nn×N×Nr → Nn×N×Nrandπ:Nn×N×Nr→Nrgiven by
ρ(s) = (s, p, fp(ηp(s))),
F(s, k, t) =
(s, k+ 1, Lk+1(ηk+1(s), t) ),ifk < n, (s, k, t), otherwise
andπ(s, k, t) = t.
Then the mapsρ, Fandπare all primal maps. Let the domains of the maps beS, XandHrespectively. Then
S = {s∈Np|ηp(s)∈dom(fp)},
X = {(s, k, t)|(ηk+1(s), t)∈dom(Lk+1), p≤k≤n−1}, H = Nn×N×Nr.
Clearly the mapλ(s, k, t) =n−kis a bound function. Further,
s∈Ω ⇔ ρ(s)∈X, Fk(ρ(s))∈fix(F),for somek
⇔
(s, p, tp)∈X,withtp=fp ◦ ηp(s)
(s, p+ 1, tp+1)∈X,withtp+1=fp+1 ◦ ηp+1(s) . . .
(s, n, tn)∈X,withtn=fn ◦ ηn(s)
⇔
ηp(s)∈dom(fp), ηp+1(s)∈dom(fp+1) . . .
ηn(s)∈dom(fn)
⇔ s∈dom(fn), from remark[12].
This proves thatDfn= Ω. For anys∈Dfn,Vsis an invariant set underF, andVscan also be seen as
Vs = {(s, k, t)|s∈Dfn,1≤k≤n, t=fk(ηk(s))}
so thatVs∩fix(F) ={(s, n, fn(s))}, fors ∈Dfn. This proves thatVsis an invariant principle forfnand(ρ, F, π)is an algorithm for computing the mapfn. Hence the mapfnis a primal map.
6. DOCUMENTATION
This section deals with a method of documentation for the mapcode computation. At the outset, the mapcode machine
ρ(s) = (s, p, fp◦ηp(s))
F(s, k, t) =
(s, k+ 1, Lk+1(ηk+1(s), t) ),ifk < n, (s, k, t), otherwise
andπ(s, k, t) = t.
itself is a documentation for computingf. But tabular form may be a better option.a←bstands for “a is replaced by b”.
Mapcode Documentation Variables s[0], s[1], . . . s[n−1],
required k,t[0], t[1], . . . , t[r−1]
Initialisation
0≤i≤n−1 input fors[i] t=fp(s[0], . . . , s[p−1])
k=p
Program
Guard Command
k < n t←Lk+1(ηk+1(s), t), k←k+ 1
Output t
7. APPLICATION
The proposed computation model will be used in the case of exam-ples discussed earlier. The advantage of this theory is that the safety and termination are ensured by the theorem and there is no need to verify for each example.
(1) Maximum Problem:With the notation and terminology given in the example 1,
(a) the mapf1is identity map onN, so that it is a primal map.
(b) The lift mapLk(x, y, t) =Max{y, t}is a primal map. Then the maximum functionf is a primal map and the map-code machine computingfis given by
ρ(s) = (s,1, s[0])
F(s, k, t) =
(s, k+ 1,Max{s[k], t}), ifk < n, (s, k, t),otherwise,
andπ(s, k, t) = t.
Documentation of the computation in tabular form is given by
Mapcode Documentation Variables s[0], s[1], . . . s[n−1],
required k,t
Initialisation
0≤i≤n−1 input fors[i] t=s[0]
k= 1
Program
Guard Command
k < n t←Max{s[k], t}, k←k+ 1
Output t
(2) Checking Equality Problem:With the terminology and nota-tion given in the example [2]
(a) s0= (s0[0], s0[1], . . . , s0[p−1])∈
Npis initially choosen
and fixed.
(b) The mapf1:N→Nis given byf1(x) = 1, ifx=s0[0], andf1(x) = 0, otherwise. It is a primal map.
(c) For any(s, y) ∈ Nk−1 ×N = Nk andt ∈ N, the lift
Volume 106 - No. 4, November 2014
ρ(s, s0) = (s, s0,1, f1(s))
F(s, s0, k, t) = (s, s0, k+ 1, Lk(s[k], t)), ifk < p = (s, s0, k, t),otherwise and π(s, s0, k, t) = t.
In other words,
ρ(s, s0) =
(s, s0,1,1),
ifs[0] =s0[0]
(s, s0,1,0),
ifs[0]6=s0[0]
F(s, s0, k, t) =
(s, s0, k+ 1, t),ifs[k] =s0[k], andk < p (s, s0, k+ 1,0),ifs[k]6=s0[k], andk < p = (s, s0, k, t),otherwise and
π(s, s0, k, t) = t.
However, a close observation of the machine will reveal that the following machine will also compute the mapf.
ρ(s, s0) = (s, s0,0,1)
F(s, s0, k, t) =
(s, s0, k+ 1, t), ifk < p,s[k] =s0[k]
(s, s0, n,0), ifk < p,s[k]6=s0[k] = (s, s0, k, t), otherwise;
π(s, s0, k, t) = t.
Mapcode Documentation Variables s[0], . . . s[n−1],
required s0[0], . . . s0[n−1],
k,t
Initialisation
0≤i≤n−1 input fors[i] 0≤i≤n−1 input fors0[i]
k= 0,t= 1
Program Guard Command
k < p,s[k] =s0[k] k←k+ 1 s[k]6=s0[k] k←n, t←0
Output t
This mapcode machine is referred byM1.
(3) Pattern Matching Problem: This famous problem has been tackled by many programmers. One can see how the proposed method simplifies the problem of designing a program. Assume the notation and terminology used in the example [3].
(a) Choose and fix anys0= (s0[0], s0[1], . . . s0[p−1])∈
Np.
(b) The mapfpin the example 3 is same as the mapfpin the example 2 and hencefpis a primal map.
(c) The lift mapLkgiven byLk(s[0], s[1], . . . , s[k−1], t) = t+fp(s[k−p], s[k−p+ 1], . . . , s[k−1])is also a primal map.
By theorem 13, the functionf = fn is a primal map. The mapcode machine(ρ, F, π)computingfis given by
ρ(s, s0) = (s, s0, p, fp(s[0], . . . , s[p−1]) ) π(x) = t.
and for anyx= (s, s0, k, t)∈X,
F(x) = (s, s0, k+ 1, t+fp(s[k+ 1−p], . . . , s[k]) ), ifk < n,
= (s, s0, k, t), otherwise
Mapcode Documentation Variables s[0], . . . s[n−1],
required s0[0], . . . s0[n−1],
k,t
Initialisation
0≤i≤n−1 input fors[i] 0≤i≤n−1 input fors0[i]
t=fp(s[0], . . . , s[p−1]) k=p
Program Guard Command
k < n, k←k+ 1
t←t+fp(s[k+ 1−p], . . . , s[k]) )
Output t
This mapcode machine computingfnis referred byM2.
8. CONCLUSION
The mapcode machine M2 involves maps which are again computable with the machineM1. Then one has to combine the mapcode machines M1 and M2 so that relatively elementary operations will be involved for carrying out the computation. This is an essential part of writing a program.
As in the case of ‘maps admitting variations’, some other classes of maps are identified and proposed a mapcode machine for each class. Though the approach is successfully adopted for several standard problems, some of them are even harder, it is not claimed that these classes are exhaustive. These results and the techniques involved in combining two mapcode machines will be published subsequently.
In the present article, simple illustrations are chosen only for bet-ter exposition of the content. Two standard examples are chosen to show how the proposed method helps in the construction of an algorithm. However, as quoted by David Gries [4],
One cannot learn to write large programs effectively until one has learned to write small ones effectively.
9. REFERENCES
[1] Blum, L., Cucker, F., Shub, M., and Smale, S.:Complexity and Real Computation, Springer-Verlag, New York, USA, 1998.
[2] Chandy, K.M., Misra, J.:Parallel Program Design: A Foun-dation,Addison-Wesley, Reading, 1988.
[3] Cutland, N.: Computability:An Introduction to Recursive Function Theory,Cambridge University Press, Cambridge, UK, 1980.
[4] David Gries.:The Scinece of ProgrammingSpringer-Verlag New York Inc, 1981.
Volume 106 - No. 4, November 2014 [6] Knuth, D.E.:The Art of Computer Programming, Volumes 1
-III, Third Edition, Pearson Education Asia, New Delhi, India, 2002.
[7] Venkata Rao, K., and Viswanath, K.:Mapcode Characteriza-tion of Partial Recursive Maps,Sankhya, The Indian Journal of Statistics, 2010, Volume 72-A, Part 1, pp. 276-292. [8] Venkata Rao, K., and Viswanath, K.:Computing with
Mul-tiple Discrete Flows, Journal of Differential Equations and Dynamical Systems, 2010, Volume 18 (4), pp. 401-414. [9] Viswanath, K:Dynamical Systems and Computer Science,
Mathematics Newsletter of the Ramanujan Mathematical So-ciety, 13(3), 2003, pp.33-48.
[10] Viswanath, K.:Building Programs and proving them correct with Dynamical Systems, Proceedings of the International Conference on Computing and Control, Austin, Texas, USA, August, 2004, International Institute of Informatics and Sys-temics,Orlando, Florida, USA, pp. 372-377.
[11] Viswanath, K.:An Invitation to Mathematical Computer Sci-ence, Discrete Mathematics and its Applications, Ed. M. Sethumadhavan, Narosa, 2006.
[12] Viswanath, K.:Simple Foundations for Computing, Proceed-ings of the 40th Annual Convention of the Computer Society of India, November 10-12, 2005, Hyderabad, India. [13] Viswanath, K.:Computing with Dynamical Systems, Journal
of Differential Equations and Dynamical Systems, Vol.14(1), pp.1-24, 2006.