
This mathematical treat was inspired by Jane Street‘s puzzle: Traversing the Infinite Sidewalk. I shared the puzzle with my mathematical friend Éric, and we had quite some fun discovering its properties.1
It is also a testimony to the richness derived from the irrationality of
Here goes Jane’s story: Jane owns an infinite rosary. It has a single end and is comprised of an infinite number of black and white beads. Starting from the end, the bead positions are numbered
Jane tells the beads of her rosary in a special way: each time she is done with a bead (say bead
Starting at bead
Prelude: names
To weave the magic of a thing, you see, one must find its true name out.
Ursula K. Le Guin, A Wizard of Earthsea
- Bead: a natural number
(the number represents the position of the bead in Jane’s rosary). - Black bead: a bead
divisible by (denoted ).
When we know for sure that a bead is black, we may indicate it with: . - White bead: a bead
not divisible by (denoted ).
When we know for sure that a bead is white, we may indicate it with: . - Even bead: a bead
divisible by 2 (denoted ). - Odd bead: a bead
not divisible by 2 (denoted ). - Label: the label of bead
is: , where denotes the floor function. is an increasing function. - Up: going up from bead
, Jane reaches bead also denoted (postfix notation for unary operator ). is a strictly increasing function. - Down: going down from bead
, Jane reaches bead also denoted (postfix notation for unary operator ). is an increasing function. - Lambda: Jane can reach white bead
by performing one up move from bead also denoted (postfix notation for unary operator ). is a strictly increasing function. Also, it holds that: - Mu: given any
, there is a unique way for Jane to reach bead while moving down from an odd bead, which we denote or (postfix notation for unary operator ). is a strictly increasing function. Also, it holds that: - Nu: given any
, there is a unique way for Jane to reach bead while moving down from an even bead, which we denote or (postfix notation for unary operator ). is a strictly increasing function. Also, it holds that: - Recitation: starting at bead
and randomly moving up or down finitely or infinitely many times, Janes performs a recitation. In other words a recitation is a sequence of natural numbers such that and . - Length: the length of a recitation is the number of moves it comprises, finite or infinite. For a finite recitation of length
, we can write: is the start of the recitation. is the end of the recitation. - Minimal recitation: a recitation from bead
to bead , with minimal length. By convention, a minimal recitation to bead means a minimal recitation from bead to bead . - Height: the height of bead
(denoted ) is the length of a minimal recitation to bead . As we are about to see, every bead has a finite height.
The height of a bead
By definition
What about the height of bean
Given
where , where , where .
This shows (by induction on
This also gives two upper bounds:
The logarithmic bound was suggested by Jianing Song.
Computing the height of a bead
The following simple exploration-based algorithm will do:
def height(n: int) -> int:
if n < 0: raise Exception("n must be a nonnegative integer")
if n == 0: return 0
if n == 1: return 1
visited = {0, 1} # the beads we have visited so far
rings = [{0}, {1}] # the beads ordered by height (min length of path from 0)
for height in itertools.count(2):
new_ring = set()
for bead in rings[height - 1]:
label = (bead >> 1) + 1
for next_bead in {bead - label, bead + label}:
if not next_bead in visited:
if next_bead == n: return height
visited.add(next_bead)
new_ring.add(next_bead)
rings.append(new_ring)
Below is a plot of the height function.
Minimal recitations
In this section, we study some properties of minimal recitations.
Minimal recitations ending in a white bead
The following property holds for any white bead
The proof is by induction on the height of
Further assume (by contradiction) the existence of a white bead
Being a white bead,
Let’s first deal with the case where
Case 1
Case 2
Case 3
The ending of recitation
- Case 1:
ends in . Since is a white bead of height , it must have a minimal recitation ending in up. Which produces a minimal recitation ending in – i.e., down–down–up. - Case 2:
ends in . Since is a white bead of height , it must have a minimal recitation ending in up. Which produces another minimal recitation ending in – i.e., down–down–up. - Case 3:
ends in . Since is a white bead of height it must have a minimal recitation ending in up. Which produces another minimal recitation ending in – i.e., down–up.
Each time there is a contradiction because a minimal recitation is produced, which is ending in an up move.
Next let’s deal with the case where
Case 4
Case 5
Case 6
Again, we have a contradiction since in all cases we can construct a minimal recitation ending in an up move. This shows that property (
Minimal recitations ending in a black bead
An consequence of property (
The proof is similar as for the white beads, with the following two commutative diagrams.
Interlude: more names
Hey, Louie. The man is dry. Give him one on the house, okay?
Ridley Scott, Blade Runner (1982)
- Eager recitation: a recitation that only moves up.
- Seed: the seed of bead
(denoted ) is the black bead from which can be reached via an eager recitation (only up moves). - Lambex: the lambex of bead
(denoted ) is the number of up moves required to reach from its seed . In other words: or equivalently - Up-chains: we call up-chain starting at bead
(denoted ) the set of beads reachable by an eager recitation (only up moves) from bead :
Note that: - Down-chains: we call down-chain starting at bead
(denoted ) the set of beads reachable by downwards recitation (only down moves) from bead :
Note that every down-chain is finite and ends in . - Jane’s reluctant recitation: Jane starts the reluctant recitation at bead
and always moves down rather than up, unless moving down would lead to a bead that Jane has already visited, in which case Jane reluctantly moves up. See figure 9 for an illustration. - Rho:
is the th bead in Jane’s reluctant recitation. For instance, , , . See figure 10 for an illustration.
By construction, is an injective function. And is actually well defined for all , as we will see later.
The structure of Jane’s rosary
The partitioning of Jane’s rosary in up-chains produces an interesting one-to-one mapping
This is illustrated by Figure 6.
With this mapping, the beads’ heights have a clean representation:
Theorem 1: minimal recitations ending in a black bead
Theorem 1 further studies the properties of minimal recitations ending in a black bead. Let
The following properties hold:
In particular, this shows that which of
This is illustrated in figure 7: the solid arrows point to predecessors with lower lambex, the dashed arrows point to predecessors with larger lambex.
Theorem 1 guarantees the correctness of the following improved algorithm for computing
def height(n: int) -> int:
if n < 0: raise 'param must be nonnegative'
h = 0
while True:
if n == 0: return h
h += 1
match n%3:
case 0:
h += 1
n=(4*n+2)//3
while True:
h += 1
match n%3:
case 0:
n = (2*n)//3
break
case 1:
n = (2*n)//3
case 2:
n = (2*n)//3 + 1
break
case _:
n = (2*n)//3
(
The remainder of the proof is by induction on the height of
We can easily check that (
Now assume
The following diagram (where
Observe that
So depending on
Assuming four white beads
Applying a «
Where
This shows that the «
On the one hand, if
and the following deductions can be made:
, belongs to a minimal recitation to . If it did not, would belong to a minimal recitation to , we would have , and by induction hypothesis ( ) we could write the following contradiction:- there is a minimal recitation to
ending in , - there is a minimal recitation to
ending in , , , and by induction hypothesis ( ) we can write: .
On the other hand, if
and similarly, the following deductions can be made:
, belongs to a minimal recitation to ,- there is a minimal recitation to
ending in , , .
Overall, properties (
Jane’s reluctant recitation
The reluctant recitation was suggested by Neal Gersh Tolunsky. The recitation starts at bead
The following figure illustrate the moves of the reluctant recitation.
The following algorithm computes
def rho(i: int) -> int:
if i < 0: raise Exception("argument must be nonnegative")
if i == 0: return 0
visited = {0: 0}
bead = 1
for age in range(1, i):
visited[bead] = age
label = 1 + bead//2
if not bead - label in visited:
bead -= label # moving down
else:
bead += label # moving up
return bead
Theorem 2: Jane’s reluctant recitation never halts
While performing the reluctant recitation, Jane moving on to bead
This ensures that the reluctant-recitation never halts.
The proof is by contradiction and by induction on the index
Looking at Figure 10, we see that moves up to the
Now assume (by contradiction) the existence of
Since an up move cannot create a gap in an up-chain, it holds that
Since a gap is created,
We must consider two cases:
Gap « to the left » of
Consider the case
If
The left hand side diagram brings a contradiction, since from
The right hand side diagram also brings a contradiction: since
Consequently
Subcase:
If
On the left hand side diagram, since after
On the right hand side diagram, since
Subcase:
If
On the left hand side diagram, since after
On the right hand side diagram, since
At this point, we conclude that it is not possible that
Gap « to the left » of
Consider now the case
The same reasoning as previously brings contradictions.
If
If
If
This concludes the proof that Jane’s reluctant recitation never halts.
Conjecture 3: Jane’s reluctant recitation tells all beads
We have demonstrated (just above) that Jane’s reluctant recitation is a well defined sequence
We have been able to check with a computer that
Lemma 1
Let
Lemma 2
Let
The proof requires a short detour via analysis. First observe the following inequalities, true for all
Further observe that since
Now let’s assume
Now perform the following:
- Choose
such that is less than away from in . - Choose
such that is more than away from in . - Choose
such that:
Finally define the bound
Observe that for all
Proof of theorem 3
Assume that there is no finite bound on the number of times the reluctant recitation visits maximal up-chains
Take
Then there is a
Interlude: for a few names more
Colonnello Mortimer: Che succede ragazzo?
Sergio Leone, Per qualche dollaro in più (1965)
Il Monco: No, niente vecchio, non mi tornavano i conti. Ne mancava uno.
- Canonical recitation: the canonical recitation to bead
(denoted )is the minimal recitation , defined by: - Jane’s onyx rosary: Jane’s onyx rosary is obtained by removing all white beads from Jane’s full rosary. A bead in Jane’s onyx rosary is called an onyx bead, to distinguish it from the same bead in the Jane’s full rosary.
- Onyx bead: a bead in Jane’s onyx rosary. Onyx beads positions are numbered from
. Onyx bead is the same as (black) bead in Jane’s full rosary. - Onyx ordering: we define the partial ordering
on the set of onyx beads: given two onyx beads , - Onyx height: The onyx height of bead
(denoted ) is defined as one less than the number of black beads in the canonical recitation of : - Onyx down: Onyx down on onyx bead
(denoted or ) is defined as: - Onyx mu: Onyx mu on bead
(denoted or ) is defined as: - Onyx nu: Onyx nu on bead
(denoted or ) is defined as:
Jane’s onyx rosary
Jane’s onyx rosary is obtained by removing all white beads from Jane’s full rosary. We call a bead in Jane’s onyx rosary an onyx bead, to distinguish it from the same bead in Jane’s full rosary. Beads positions in Jane’s onyx rosary are numbered from
In this section, we leave the black beads aside and focus solely on onyx beads.
Onyx ordering
Given two onyx beads
The onyx ordering is a well founded partial order on
The Hasse diagram for the onyx partial order is a tree rooted in
In the onyx ordering, every non-zero element
By construction (and also as can be seen on Figure 12), the onyx ordering is embedded in
Theorem 4: every bead in the onyx ordering has infinitely many successors
Let us first establish a few lemmas that will help proving theorem 4.
Lemma 3
The following property holds:
The proof is achieved by considering the four cases for the respective parities of
Lemma 4
Let
The proof is by contradiction.
Assume
This equation is solvable and the unique solution is:
This is a contradiction since
Conversely, assume
This equation is solvable and the unique solution is:
This is a contradiction since again,
Lemma 5
For any
Proof of theorem 4
The proof proceeds with the construction of subsets of (non-onyx) beads
By lemma 3 and lemma 4 we know that
Let
Now consider
- It holds that
. - Thus by lemma 5,
contains at most elements.
To conclude, consider
has infinitely many elements,- For each
, , say , - k is the lower of
and .
This designates
Corollary of theorem 4: canonical onyx mapping
Given any onyx bead
Conversely, given a non-zero onyx bead
For instance (refer to Figure 12):
We define the canonical onyx mapping
As an illustration, the following table gives
Work in progress
Jane’s onyx height sequence
Jane’s onyx reluctant sequence
Jane’s inverse onyx reluctant sequence
Jane’s foraging sequence
Jane’s foraging sequence
- each
is replaced with , - then direct repetitions are removed.
The foraging sequence goes like this:
The foraging sequence is infinite. If conjecture
The following algorithm computes
def Phi(n: int) -> int:
import itertools
if n < 0: raise Exception("argument must be nonnegative")
visited = {0: 0}
bead = 1
res = 0
for i in itertools.count(1):
if n == 0: return res
visited[bead] = i
label = 1 + bead//2
if not bead - label in visited:
bead -= label # moving down
else:
bead += label # moving up
nxt = bead
while nxt%3: nxt = (2*nxt)//3 # compute seed
nxt = nxt//3
if nxt != res:
res = nxt
n -= 1
References
- See also the On-Line Encyclopedia of Integer Sequences:
- OEIS sequence A358838: Minimum number of jumps needed to go from slab 0 to slab n in Jane Street’s infinite sidewalk,
- OEIS sequence A359005: Jane Street’s infinite sidewalk’s greedy walk,
- OEIS sequence A359008: Jane Street’s infinite sidewalk’s greedy walk inverse mapping.
- Since whenever the reluctant recitation visits a bead
, it also visits all beads in .
Laisser un commentaire