F
RANÇOIS
L
AUBIE
A recursive definition of p-ary addition without carry
Journal de Théorie des Nombres de Bordeaux, tome
11, n
o2 (1999),
p. 307-315
<http://www.numdam.org/item?id=JTNB_1999__11_2_307_0>
© Université Bordeaux 1, 1999, tous droits réservés.
L’accès aux archives de la revue « Journal de Théorie des Nombres de Bordeaux » (http://jtnb.cedram.org/) implique l’accord avec les condi-tions générales d’utilisation (http://www.numdam.org/conditions). Toute uti-lisation commerciale ou impression systématique est constitutive d’une infraction pénale. Toute copie ou impression de ce fichier doit conte-nir la présente mention de copyright.
Article numérisé dans le cadre du programme Numérisation de documents anciens mathématiques
A
recursive
definition
of
p-ary
addition without
carry
par
FRANÇOIS
LAUBIERÉSUMÉ. Soit p un nombre premier. Nous montrons dans cet
article que l’addition en base p sans retenue
possède
une définitionrécursive à l’instar des cas où p = 2 et p = 3 qui étaient
deja
connus.
ABSTRACT. Let p be a
prime
number. In this paper we prove that the addition in p-ary without carry admits a recursive definition like in thealready
known cases p = 2 and p = 3.1. INTRODUCTION
Let p be a
prime
number. For any two naturalintegers
a andb,
let usdenote
by
a+p
b the naturalinteger
obtainedwriting
a and b in p-ary andthen
adding
them without carry.In the case where p =
2,
thisoperation
callednim-addition,
plays
a crucialrole in the
theory
of some games[1]
and in thetheory
oflexicographic
codesof Levenstein
[6],
Conway
and Sloane[2].
The map(a, b)
H a +2 b is theGrundy
function of the directedgraph
whose vertices are thepairs
(a, b)
of natural
integers
and arcs thepairs
of vertices((a’,
b’),
(a, b))
such thateither a’ a and b’ = b or a~’ = a and b’ b. Therefore the nim-addition
can be defined
recursively
as follows:Thus the nim-addition is the first
regular
law on N in the sensethat, given
all a’ +2 b and a +2 b’ with a’ a and b’
b,
a +2 b is the smallest naturalinteger
which is not excludedby
the rule:Surprisingly,
it is a group law on N.For any
prime
numberp > 3,
the addition+p
takesplace
in thetheory
of somegeneralized nim-games
~7~, [8]
and also in thetheory
of somegreedy
codes
[4].
Moreover this additionplays
a crucial role in the recentdeter-mination of the least
possible
size of the sumset of two subsets ofand he asked the
question
if such a recursive definition exists for-I-p
when-ever p is aprime
number.The aim of this paper is to answer
positively.
This answerprovides
uswith a definition "a la
Conway"
ofprime
numbers.2. THE
-I-p-ADDITION
TABLE AS A GRAPHLet
lFp
be the finite field with pelements;
for A EFp,
let A
be therepresentative
number of the class Abelonging
to{0,1, - " p -1~
and,
fora E
N,
defineA.pa=
a -p a =
a +p a +p w +p a
with a
terms a.The
operations +p
and -pprovide N
with a structure ofFp-vector
spaceisomorphic
to theIFp-vector
space ofpolynomials
We define a directed
graph!gp
as follows:- the set of its vertices is N x
N,
- thearcs of
gp
are thepairs
of vertices( (a’, b’ ),
(a, b) )
such that-aa
6’ 6,
-
a - a, -,
- a’
= b +p ( 1- a)
-p r for some r Eand A e Fp .
The
graph
gp
does not admitcircuit;
thus theGrundy
function of~p
isthe
unique
map g of N x N-N such that:Proposition
1. TheGrundy
function of
Gp
is the addition map:(a, b)
Ha +p b.
First of
all,
wegive
some lemmas on the naturalordering
of therepre-sentative set
{0,1,’"
p -1}
ofFp .
It is sometimes more convenient to express them in terms of thefollowing ordering
onFp:
where ü
(resp. v)
is therepresentative
number of u EFp (resp. v
EFp)
belonging
to{0,1," - ip -
1}-Lemma 1. For all u, v E
Fp
2Thus
Lemma 2. Let u, r, s be elements
of
Fp
such that r ~ s and u + r - u.Lemma 3. Let u, v, r be elements
o, f
IFp
such that u - u + r, v - v + r andu --i- v -~- r ~ u -f- v. Then there
E IFp
suchthat s -~- t = r,
u + s -~ uand v + t - v.
Proof.
Conditions:are
equivalent
to:Since
v
> p - r with f p - 1 -n,
we havev
Hence >max(fi,,b)
+ 1. Moreovern+~2013p~ ~T~.
Therefore, by
Lemmal,M+~p20131
and the conditions(C)
areequivalent
to:or, more
simply,
to:-f -1 p - r u -f - v .
We are
looking
for s and t EI~p
such that:or
equivalently
such that:with p =
p - f, u
=p - s
and T =p - t.
>bbom the conditionv )
+
v,
it is clear that suchintegers a
and r do exist. Thus the lemmais
proved.
0Now,
for any naturalinteger
x, let a? be its class modulo p, let a~ =Ei>O Xipi
with Xi E~0,1, ~ ~ ~ ,
p -11
its p-aryexpansion,
and letiz
bethe largest
index i > 0 such that 0. In order to summarize all theseProof of Proposition
1. Let a, b be naturalintegers.
For any naturalinteger
c a
+p b,
there exists r E N* so that c = a+p
b+p
r. We will prove thatfor any r E N* such that a
+p
b+p
r a+p b,
there exists A EFp
such thata
+p A .p
r a and b+p
(1 - A)
.p r b. With the notations of Lemma4,
we have:
There exist
s, t
EFp
such that q - s+ t,
as,. + s -~
az,, andbzr
-f - t ~ Let A = s EIFp ;
then: s =Aq, t
=( 1 -- ~ ) rZr ,
q
+ « air and+ ( 1 - ^)TZr ~
bz,. ;
in other words :a +p A .p r
a and v(Lemma 4).
Therefore a
+p
b =min(NBEp)
whereEp
is the set of all the naturalintegers a’
+p
b’ with a’ a, b’ b and such that there exist A E1Fp
andr E N*
satisfying a’ =
a+p
A -p r, b’ = b+p
( 1 -
A)
-p r. This means that(a, b)
H a+p
b is theGrundy
function ofgp .
0Corollary.
(S.
Eliahou,
M. Kervaire[3]) -
Let us denoteby
[0, a]
theinter-val
~a’
a~ ,
for
a E Thenfor
all a, b E ~1 there exists c a + b such that~0, a~
+p
[0, b]
=[0, c~ .
Proof.
Let c =max([O,
a]
+p
[0, b])
and let a,bl
:5
b such that c =al
+p bl.
For all d c there exist A EIFp
and r E N* such that d = A .p a,+p
( 1 - A)
-pbi,
A -p ai al and( 1 -
A)
pbl
bl ;
therefored E ~~ ~ a~ +p ~~ ~ b~ -
DRemark. With the notations of the
proof
ofProposition
1,
we have:1.
E2
= {a
+2b’, a’
+2b ;
a’a, b’
&},
2.
E3 -
{a
+3b’, a’
+3b ; a’
a, b’
b~
Ufall
+3b", a"
a, b"
b,
a +3 b" = a" +36}
because in this case, A = 0 or A = 1 or A = 1 - A. 3. In the case wherep > 5,
the situation is a little morecomplicated
because the formula a
+p
b = will beeffectively
recursive,
only
when we can describe the setEp
using only
pairs
(a, #)
E N x Nwith a a,
,Ci
b and(a,,C3)
#
(a,
b).
3. A RECURSIVE EXCLUSION ALGORITHM FOR a
+p
bGiven a
prime
number p and apair
(a,
b)
of naturalintegers,
we willintegers
of the kind a’+p b’
~
a+p
b with a’ a and b’ b withoutusing
anypair
ofintegers
(a", b")
such that a" > a or b" > b.For all S C
N,
S* meansS)(0).
Let J~I
and N
be two finite sets of naturalintegers
such thatn N
=~0,1~
and let and(bn)nEN
be two sequences of naturalintegers
(respectively
indexedby
,Nl andJU)
satisfying
the conditions:-ao=a~bo=b~
-
al
+p b = a +p bl7
-V(m,n)
E M* xN*,
am a,bn
b,
- dm E E J~I * such that and
am
+p
b =ak
+p
bm-k ~
>- Vn E E
N*
such and a+p bn
=+p bl.
Such a
pair
of sequences(bn)nEN)
is called ap-chain
of(a, b)
of
length
card J1~! * + cardN* .
Remark. 1- The
p-chains
of(a, b)
oflength
2 are thepairs
lb,
with a, a,
b1
b and a+p bl
= a,+p
b(see
the formula of S. Norton inthe
introduction).
2 - For a
p-chain
of(a, b)
oflength
>3,
we have a2+p
b = al+p b,
or a+p b2 =
a,+p bi,
a3+p
b =a2
+p bl
provided
that(a2,
bl )
lies in thep-chain,
or a3+p
b = al+p b2 provided
that(a1, b2)
lies in thep-chain.
For convenience we extend our definition tolength
1p-chain
of(a, b):
it is thepairs
(a,
or(la, a, 1, b)
with al a,b¡
b.A
p-chain
(a, b)
is called ap-exclusion
chain for a+p
b(or
of(a,
b))
if V n EU N*,
Finally
the set of allintegers
a’+p
b’ where(a’, b’)
belongs
to anyp-exclusion chain for a
+p
b oflength
p -1
is called thep-exclusion
set fora
+p
b(or
of(a, b));
it’s denotedby
Ep(a,
b).
We will prove:
Theorem.
((a’, b’),
(a, b))
is an arcof
gp
if
andonly if
there exists ap-exclusion chain
for
a+p
bof
p -1 containing
(a’,
b’).
In otherwords : a
+p
b =b)).
Lemma 5. Let
(bn)nEN) be
ap-chain of
(a, b)
of length >
2.There exists r E ~1* such that am = a
+p
rn .p r andbn
= b+p
n .p rfor
all(m,
n)
E xJlf.
Thusif ptm
+ n then am+p bn
= a+p
b.Proof.
Let r E N* such that al =a +p r;
thena +p bi
= al+p b
=a +p r +p b,
thereforebl -
b+p
r.Suppose
that for any k E and IE N
with1 k m - l and 1 ~ r~ - l we have ak =
a +p k ~p r
andbt
= then there existsko
E J~l such that andProposition
2. Let(bn)nEN) be
ap-chairt of
(a, b).
Let(m, n)
E J1~ x
,N
such then((am, bn), (a, b))
is an arcof
Qp.
Proo f . -
If thelength
of this chain is1,
this isclear;
ifnot,
let r E N* such that am =a+pm~pr
andbn
=b+pn~pr (Lemma
5).
Let IA
be the class modulo p of m + n. then a,~ = a(Lemma 5)
and((a~, bn), (a, b))
isan arc of
gp
sincebn
b.If pf m
and + n, let A EFp (A 7~ 0, 1)
be the class modulo p of~+n
then m -p r= A -p ~
and n -P r =(1- A)
-p s where
s = p .p r. Thus
( (a~,,
bn ), (a,
b) )
is an arc of C7We
just proved
that if((am)mEM, (bn)nEN)
is ap-exclusion
chain for a+p
bthen,
for every(m, n)
E xN*,
7
((am, bn), (a, b))
is an arc ofGp.
Now,
in order to prove the converse, we will describe analgorithm looking
like the Euclid
algorithm
for thegcd.
Let uo, such that
uo 0
vo. Define vi EIF#
as follows:. - ... ,
Lemma 6. There is an
integer
N p - 2 such that uN = VN.Proof.
Ifun 0 vn
then un+1 + =min(un,
i vn);
moreover if un « Vnthen un « un - vn =
(Lemma
2)
and un
vn+1(=
vn);
thereforemin(un,vn) - mk(un+i, vn+i)
and the sequence isstrictly
increasing
aslong
as vn-,. Thus:min( 11,0, vo)
-min(u1, vl)
-~ ... ~min(UN-1,
UN = VN where N = 1 +maxf k E
N
Ul, 34
Finally
N p - 2 becausemin( uo, vo) =1=
0. 0Let w = UN = vN E
K
and define twoincreasing
sequences of naturalintegers
and follows:1
- if
vN-n then + vn and vn,
- if
uN-n then and vn+1 = Jln + vn.
Setting
M 1 ~N +
1 ~
weget
by
iteration:Lemma 7.
V p
E3p,’
EV v E 3v’ E
~ ~ - ~
E MProof.
= uN, vlzu =VN and for 1 n
N,
we have either uN-n =+ and VN-n = VN-n+17 or and
uN-n+l + · The lemma follows
by
recurrence. 0Lemma 9. For 1 n N
+ 1,
ptiln
Proof.
Obviousby
thepreceding
lemma. DLemma 10. CardM* +
CardN*
Proof.
For 1 nN7Un+Vn
= therefore the sequence((Itn
isstrictly decreasing
in for theordering
-~. MoreoverCardM* +
CardN*
=Card(fwl
U +vn)w ;
1 nNJ).
D Now we cancomplete
theProof of
the theorem. Let( (a’, b’),
(a,
b) )
be an arc ofgp
with a’ = a+p
A .p ra, b’
= b+p
(1 - A)
-p rb,
A E1Fp ,
r E I~’’‘ . We will construct ap-exclusion
chain for a+p b,
containing
(a’, b’),
oflength
p -1.
If A = 0 or 1 there exists such an obvious chain of
length
1.If A
= 1
7(p ~ 3),
is sucha p-exclusion
chain oflength
2 for a+p
b.Now we suppose
that A #
0,1,
and therefore thatp >
5.Writing
r = p-ary, let us recallthat ir
denotes thelargest
index isuch that rir
~
0. Let uo -Aq
E vo =(1 -
A)F,7,-
EJB;;
thenuo + 0 and uo - 0. So we can construct as above the sequences
with w, the
increasing
sequences ofintegers
with P,1 =
v1 - 1 and their associated1nN-~-1~.
Lemma 11. The
equality
ILN+1(1 -
À)
=vN+iA
holds in1F’‘p .
Proof. By
Lemma8,
IIN+LW = uo -Àrir
and vn+lw = vo =(1 - À)rir
with ~.u
# 0
andq
~
0. 0Thus there exists a
unique
naturalinteger R
such that R =a -p
r and vN+1 -p R =(1 -
A)
.p r.
Lemma 12.
Rïr
= w.Proof.
=up =
Xrir
0For every
(p, v)
E M x let a~ = andbv
=b +p v .p R.
Lemma 13. For every(p, v)
E x.IV*,
a~ a andbp.
b.Now
clearly a p-chain
of(a, b) (Lemmas 7
and13),
containing
(a’, b’) (Lemma 11),
oflength
p - 1(Lemma 10),
which is ap-exclusion
chain for a+p
b(Lemma
9).
Remark. 1. In the cases where p = 2 or
3,
everyp-chain
of(a, b)
oflength
p - 1 is ap-exclusion
chain for a+p
b.2. In the case where p =
5,
a 5-chain oflength
4 is notnecessarily
a5-exclusion
chain;
we can however write acomplete
readable formulaof the same kind as Norton’s formula for p = 3: let a, b E
N;
a’, a",
a"’
(resp.
b’, b",
b"’)
are variablestaking
their values in{0,1, -",
a -1}
(resp.
{0,1, -" ,
b -1);
let us consider the sets:r . 1
Then a +5 b = U
S2
US3
US4).
3. Given a natural
integer v >
2 notnecessarily
prime
and two natural numbers a,b,
let usgeneralize
the definition of thep-exclusion
setEp(a,
b)
of(a, b)
replacing
pby
v in theprevious
definition.Thus a v-exclusion chain
(bn)nEN)
of(a,b)
is oflength
v - 1 and such that V m E
,M*,
V n EN*, vf m
and Thensetting
a *, b =min(NBEv (a,
b)),
*v is a group law on N if andonly
ifv is a
prime
number.Proof.
In fact if v is acomposite
number then *v is not an associativelaw. Let d be a proper divisor of v; the
following equalities
hold:exclusion chain
oflength
Therefore:((v-d)*v(d-1))*"1
= 0 and:(v - d)
*"((d - 1)
*w1)
= v. 04. If we
replace
in the definition of *£1 theprevious
conditions(m, n)
EM* x
N*
v t m
andby v
isrelatively
prime
to m and n, then weget
*v =+p
where p is the smallestprime
divisor of v.Acknowledgments.
I thank T. Moreno and P.Segalas,
students at theUniversity
ofLimoges,
fortesting
severalalgorithms
in Turbo Pascal on aPC.
REFERENCES
[1] C. L. Bouton, Nim, a game with a complete mathematical theory. Ann. Math. Princeton 3
(1902), 35-39.
[2] J. H. Conway, N.J.A. Sloane, Lexicographic Codes, Error Corrrecting Codes from Game
The-ory. IEEE Trans. Inform. Theory 32 (1986), 337-348.
[3] S. Eliahou, M. Kervaire, Sumsets in vector spaces over finite fields. J. Number Theory 71
(1998), 12-39.
[4] F. Laubie, On linear greedy codes. to appear.
[5] H. W. Lenstra, Nim Multiplication. Séminaire de Théorie des Nombres de Bordeaux 1977-78,
exposé 11, (1978).
[6] V. Levenstein, A class of Systematic Codes. Soviet Math Dokl. 1 (1960), 368-371.
[7] S. Y. R. Li, N-person Nim and N-person Moore’s Games. Int. J. Game Theory 7 (1978),
31-36.
[8] E. H. Moore, A generalization of the Game called Nim. Ann. Math. Princeton 11 (1910),
93-94.
Francois LAUBIE
UPRESA CNRS 6090 et INRIA de Rocquencourt
Departement de Mathematiques Facult6 des Sciences de Limoges
123, avenue Albert Thomas
87060 LIMOGES Cedex E-mail : laubieihmilim. f r