Asynchronous approach in the plane: A deterministic polynomial algorithm

In this paper we study the task of approach of two mobile agents having the same limited range of vision and moving asynchronously in the plane. This task consists in getting them in finite time within each other's range of vision. The agents execute the same deterministic algorithm and are assumed to have a compass showing the cardinal directions as well as a unit measure. On the other hand, they do not share any global coordinates system (like GPS), cannot communicate and have distinct labels. Each agent knows its label but does not know the label of the other agent or the initial position of the other agent relative to its own. The route of an agent is a sequence of segments that are subsequently traversed in order to achieve approach. For each agent, the computation of its route depends only on its algorithm and its label. An adversary chooses the initial positions of both agents in the plane and controls the way each of them moves along every segment of the routes, in particular by arbitrarily varying the speeds of the agents. A deterministic approach algorithm is a deterministic algorithm that always allows two agents with any distinct labels to solve the task of approach regardless of the choices and the behavior of the adversary. The cost of a complete execution of an approach algorithm is the length of both parts of route travelled by the agents until approach is completed. Let $\Delta$ and $l$ be the initial distance separating the agents and the length of the shortest label, respectively. Assuming that $\Delta$ and $l$ are unknown to both agents, does there exist a deterministic approach algorithm always working at a cost that is polynomial in $\Delta$ and $l$? In this paper, we provide a positive answer to the above question by designing such an algorithm.


Model and Problem
The distributed system considered in this paper consists of two mobile agents that are initially placed by an adversary at arbitrary but distinct positions in the plane. Both agents have a limited sensory radius (in the sequel also referred to as radius of vision), the value of which is denoted by , allowing them to sense (or, to see) all their surroundings at distance at most from their respective current locations. We assume that the agents know the value of . As stated in [12], when = 0, if agents start from arbitrary positions of the plane and can freely move on it, making them occupy the same location at the same time is impossible in a deterministic way. So, we assume that > 0 and we consider the task of approach which consists in bringing them at distance at most so that they can see each other. In other words, the agents completed their approach once they mutually sense each other and they can even get closer. Without loss of generality, we assume in the rest of this paper that = 1.
The initial positions of the agents, arbitrarily chosen by the adversary, are separated by a distance ∆ that is initially unknown to both agents and that is greater than = 1. In addition to the initial positions, the adversary also assigns a different non-negative integer (called label) to each agent. The label of an agent is the only input of the deterministic algorithm executed by the agent. While the labels are distinct, the algorithm is the same for both agents. Each agent is equipped with a compass showing the cardinal directions and with a unit of length. The cardinal directions and the unit of length are the same for both agents.
To describe how and where each agent moves, we need to introduce two important notions that are borrowed from [12]: The route and the walk of an agent. The route of an agent is a sequence (S 1 , S 2 , S 3 . . .) of segments S i = [a i , a i+1 ] traversed in stages as follows. The route starts from a 1 , the initial position of the agent. For every i ≥ 1, starting from the position a i , the agent initiates Stage i by choosing a direction α (using its compass) as well as a distance x. Stage i ends as soon as the agent either sees the other agent or reaches a i+1 corresponding to the point at distance x from a i in direction α. Stages are repeated indefinitely (until the approach is completed). Since both agents never know their positions in a global coordinate system, the directions they choose at each stage can only depend on their (deterministic) algorithm and their labels. So, the route (the actual sequence of segments) followed by an agent depends on its algorithm and its label, but also on its initial position. By contrast, the walk of each agent along every segment of its route is controlled by the adversary. More precisely, within each stage S i and while the approach is not achieved, the adversary can arbitrarily vary the speed of the agent, stop it and even move it back and forth as long as the walk of the agent is continuous, does not leave S i , and ends at a i+1 . Roughly speaking, the goal of the adversary is to prevent the agents from solving the task, or at least to ensure that the agents have covered as much distance as possible before seeing each other. We assume that at any time an agent can remember the route it has followed since the beginning. A deterministic approach algorithm is a deterministic algorithm that always allows two agents to solve the task of approach regardless of the choices and the behavior of the adversary. The cost of an accomplished approach is the length of both parts of route travelled by the agents until they see each other. An approach algorithm is said to be polynomial in ∆ and in the length of the binary representation of the shortest label between both agents if it always permits to solve the problem of approach at a cost that is polynomial in the two aforementioned parameters, no matter what the adversary does.
It is worth mentioning that the use of distinct labels is not fortuitous. In the absence of a way of distinguishing the agents, the task of approach would have no deterministic solution. This is especially the case if the adversary handles the agents in a perfect synchronous manner. Indeed, if the agents act synchronously and have the same label, they will always follow the same deterministic rules leading to a situation in which the agents will always be exactly at distance ∆ from each other.

Our Results
In this paper, we prove that the task of approach can be solved deterministically in the above asynchronous model, at a cost that is polynomial in the unknown initial distance separating the agents and in the length of the binary representation of the shortest label. To obtain this result, we go through the design of a deterministic algorithm for a very close problem, that of rendezvous in an infinite oriented grid which consists in ensuring that both agents end up meeting either at a node or on an edge of the grid. The tasks of approach and rendezvous are very close as the former can be reduced to the latter. It should be noticed that our result turns out to be an important advance, from a computational point of view, in resolving the task of approach. Indeed, the other existing algorithms allowing to solve the same problem either have an exponential cost in the initial separating distance and in the labels of the agents [12], or require each agent to know its starting position in a global system of coordinates [10], or only work under a much less powerful adversary [18] which initially assigns a possibly different speed to each agent but cannot vary it afterwards.

Related Work
The task of approach is closely linked to the task of rendezvous. Historically, the first mention of the rendezvous problem appeared in [33]. From this publication until now, the problem has been extensively studied so that there is henceforth a huge literature about this subject. This is mainly due to the fact that there are a lot of alternatives for the combinations we can make when addressing the problem, e.g., playing on the environment in which the agents are supposed to evolve, the way of applying the sequences of instructions (i.e., deterministic or randomized) or the ability to leave some traces in the visited locations, etc. Naturally, in this paper we focus on the work related to deterministic rendezvous. This is why we will mostly dwell on this scenario in the rest of this subsection. However, for the curious reader wishing to consider the matter in greater depth, regarding randomized rendezvous, a good starting point is to go through [2,3,28]. Concerning deterministic rendezvous, the literature is divided according to the way of modeling the environment: agents can either move in a graph representing a network, or in the plane.
For the problem of rendezvous in networks, a lot of papers considered synchronous settings, i.e., a context where the agents move in the graph in synchronous rounds. This is particularly the case of [17] in which the authors presented a deterministic protocol for solving the rendezvous problem, which guarantees a meeting of the two involved agents after a number of rounds that is polynomial in the size n of the graph, the length l of the shortest of the two labels and the time interval τ between their wake-up times. As an open problem, the authors asked whether it was possible to obtain a polynomial solution to this problem which would be independent of τ . A positive answer to this question was given, independently of each other, in [27] and [35]. While these algorithms ensure rendezvous in polynomial time (i.e., a polynomial number of rounds), they also ensure it at polynomial cost because the cost of a rendezvous protocol in a graph is the number of edges traversed by the agents until they meet-each agent can make at most one edge traversal per round. Note that despite the fact a polynomial time implies a polynomial cost in this context, the reciprocal is not always true as the agents can have very long waiting periods, sometimes interrupted by a movement. Thus these parameters of cost and time are not always linked to each other. This was highlighted in [31] where the authors studied the tradeoffs between cost and time for the deterministic rendezvous problem. More recently, some efforts have been dedicated to analyse the impact on time complexity of rendezvous when in every round the agents are brought with some pieces of information by making a query to some device or some oracle [14,30]. Along with the work aiming at optimizing the parameters of time and/or cost of rendezvous, some other work have examined the amount of required memory to solve the problem, e.g., [24,25] for tree networks and in [11] for general networks. In [6], the problem is approached in a fault-prone framework, in which the adversary can delay an agent for a finite number of rounds, each time it wants to traverse an edge of the network.
Rendezvous is the term that is usually used when the task of meeting is restricted to a team of exactly two agents. When considering a team of two agents or more, the term of gathering is commonly used. Still in the context of synchronous networks, we can cite some work about gathering two or more agents. In [19], the task of gathering is studied for anonymous agents while in [5,15,20] the same task is studied in presence of byzantine agents that are, roughly speaking, malicious agents with an arbitrary behavior.
Some studies have been also dedicated to the scenario in which the agents move asynchronously in a network [12,21,29], i.e., assuming that the agent speed may vary, controlled by the adversary. In [29], the authors investigated the cost of rendezvous for both infinite and finite graphs. In the former case, the graph is reduced to the (infinite) line and bounds are given depending on whether the agents know the initial distance between them or not. In the latter case (finite graphs), similar bounds are given for ring shaped networks. They also proposed a rendezvous algorithm for an arbitrary graph provided the agents initially know an upper bound on the size of the graph. This assumption was subsequently removed in [12]. However, in both [29] and [12], the cost of rendezvous was exponential in the size of the graph. The first rendezvous algorithm working for arbitrary finite connected graphs at cost polynomial in the size of the graph and in the length of the shortest label was presented in [21]. (It should be stressed that the algorithm from [21] cannot be used to obtain the solution described in the present paper: this point is fully explained in the end of this subsection). In all the aforementioned studies, the agents can remember all the actions they have made since the beginning. A different asynchronous scenario for networks was studied in [13]. In this paper, the authors assumed that agents are oblivious, but they can observe the whole graph and make navigation decisions based on these observations. Concerning rendezvous or gathering in the plane, we also found the same dichotomy of synchronicity vs. asynchronicity. The synchronous case was introduced in [34] and studied from a fault-tolerance point of view in [1,16,22]. In [26], rendezvous in the plane is studied for oblivious agents equipped with unreliable compasses under synchronous and asynchronous models. Asynchronous gathering of many agents in the plane has been studied in various settings in [7,8,9,23,32]. However, the common feature of all these papers related to rendezvous or gathering in the plane -which is not present in our model -is that the agents can observe all the positions of the other agents or at least the global graph of visibility is always connected (i.e., the team cannot be split into two groups so that no agent of the first group can detect at least one agent of the second group).
Finally, the closest works to ours allowing to solve the problem of approach under an asynchronous framework are [10,4,12,18]. In [10,12,18], the task of approach is solved by reducing it to the task of rendezvous in an infinite oriented grid. In [4], the authors present a solution to solve the task of approach in a multidimensional space by reducing it to the task of rendezvous in an infinite multidimensional grid. Let us give some more details concerning these four works to highlight the contrasts with our present contribution. The result from [12] leads to a solution to the problem of approach in the plane but has the disadvantage of having an exponential cost. The result from [10] and [4] also implies a solution to the problem of approach in the plane at cost polynomial in the initial distance of the agents. However, in both these works, the authors use the powerful assumption that each agent knows its starting position in a global system of coordinates (while in our paper, the agents are completely ignorant of where they are). Lastly, the result from [18] provides a solution at cost polynomial in the initial distance between agents and in the length of the shortest label. However, the authors of this study also used a powerful assumption: The adversary initially assigns a possibly different and arbitrary speed to each agent but cannot vary it afterwards. Hence, each agent moves at constant speed and uses clock to achieve approach. By contrast, in our paper, we assume basic asynchronous settings, i.e., the adversary arbitrarily and permanently controls the speed of each agent.
To close this subsection, it is worth mentioning that it is unlikely that the algorithm from [21] that we referred to above, which is especially designed for asynchronous rendez-vous in arbitrary finite graphs, could be used to obtain our present result. First, in [21] the algorithm has not a cost polynomial in the initial distance separating the agents and in the length of the smaller label. Actually, ensuring rendezvous at this cost is even impossible in an arbitrary graph, as witnessed by the case of the clique with two agents labeled 0 and 1: the adversary can hold one agent at a node and make the other agent traverse Θ(n) edges before rendezvous, in spite of the initial distance 1. Moreover, the validity of the algorithm given in [21] closely relies on the fact that both agents must evolve in the same finite graph, which is clearly not the case in our present scenario. In particular even when considering the task of rendezvous in an infinite oriented grid, the natural attempt consisting in making each agent apply the algorithm from [21] within bounded grids of increasing size and centered in its initial position, does not permit to claim that rendezvous ends up occurring. Indeed, the bounded grid considered by an agent is never exactly the same than the bounded grid considered by the other one (although they may partly overlap), and thus the agents never evolve in the same finite graph which is a necessary condition to ensure the validity of the solution of [21] and by extension of this natural attempt.

Roadmap
The next section (Section 2) is dedicated to the computational model and basic definitions. We sketch our solution in Section 3, formally described in Sections 4 and 5. Section 6 presents the correctness proof and cost analysis of the algorithm. Finally, we make some concluding remarks in Section 7.

Preliminaries
We know from [12,18] that the problem of approach in the plane can be reduced to that of rendezvous in an infinite grid specified in the next paragraph.
Consider an infinite square grid in which every node u is adjacent to 4 nodes located North, East, South, and West from node u. We call such a grid a basic grid. Two agents with distinct labels (corresponding to non-negative integers) starting from arbitrary and distinct nodes of a basic grid G have to meet either at some node or inside some edge of G. As for the problem of approach (in the plane), each agent is equipped with a compass showing the cardinal directions. The agents can see each other and communicate only when they share the same location in G. In other words, in the basic grid G we assume that the sensory radius (or, radius of vision) of the agents is equal to zero. In such settings, the only initial input that is given to a rendezvous algorithm is the label of the executing agent. When occupying a node u, an agent decides (according to its algorithm) to move to an adjacent node v via one of the four cardinal directions: the movement of the agent along the edge {u, v} is controlled by the adversary in the same way as in a section of a route (refer to Subsection 1.1), i.e., the adversary can arbitrarily vary the speed of the agent, stop it and even move it back and forth as long as the walk of the agent is continuous, does not leave the edge, and ends at v.
The cost of a rendezvous algorithm in a basic grid is the total number of edge traversals by both agents until their meeting.
From the reduction described in [18], we have the following theorem.
Theorem 1. If there exists a deterministic algorithm solving the problem of rendezvous between any two agents in a basic grid at cost polynomial in D and in the length of the binary representation of the shortest of their labels where D is the distance (in the Manhattan metric) between the two starting nodes occupied by the agents, then there exists a deterministic algorithm solving the problem of approach in the plane between any two agents at cost polynomial in ∆ and in the length of the binary representation of the shortest of their labels where ∆ is the initial Euclidean distance separating the agents.
For completeness let us now outline the reduction described in [18]. Consider an infinite square grid with edge length 1. More precisely, for any point v in the plane, we define the basic grid G v to be the infinite graph, one of whose nodes is v, and in which every node u is adjacent to 4 nodes at Euclidean distance 1 from it, and located North, East, South, and West from node u. We now focus on how to transform any rendezvous algorithm in the grid G v to an algorithm for the task of approach in the plane.
Let A be any rendezvous algorithm for any basic grid. Algorithm A can be executed in the grid G w , for any point w in the plane. Consider two agents in the plane starting respectively from point v and from another point w in the plane. Let V be the set of nodes in G v that are the closest nodes from w. Let v be a node in V , arbitrarily chosen. Notice that v is at distance at most √ 2/2 < 1 from w. Let α be the vector v w. Execute algorithm A on the grid G v with agents starting at nodes v and v . Let p be the point in G v (either a node of it or a point inside an edge), in which these agents meet at some time t. The transformed algorithm A * for approach in the plane works as follows: Execute the same algorithm A but with one agent starting at v and traveling in G v and the other agent starting at w and traveling in G w , so that the starting time of the agent starting at w is the same as the starting time of the agent starting at v in the execution of A in G v . The starting time of the agent starting at v does not change. If approach has not been accomplished before, in time t the agent starting at v and traveling in G v will be at point p, as previously. In the same way, the agent starting at w and traveling in G w will get to some point q at time t. Clearly, q = p + α. Hence both agents will be at distance less than 1 at time t, which means that they accomplish approach in the plane because = 1 (refer to Subsection 1.1).
Hence in the rest of the paper we will consider rendezvous in a basic grid, instead of the task of approach. We use N (resp. E, S, W ) to denote the cardinal direction North (resp. East, South, West) and an instruction like "Perform N S" means that the agent traverses one edge to the North and then traverses one edge to the South (by the way, coming back to its initial position). We denote by D the initial (Manhattan) distance separating two agents in a basic grid. A route followed by an agent in a basic grid corresponds to a path in the grid (i.e., a sequence of edges e 1 , e 2 , e 3 , e 4 , . . .) that are consecutively traversed by the agent until rendezvous is done. For any integer k, we define the reverse path to the path e 1 , . . . , e k as the path e k , e k−1 , . . . , e 1 = e 1 , . . . , e k−1 , e k . We denote by C(p) the number of edge traversals performed by an agent during the execution of a procedure p.
Consider two distinct nodes u and v. We define a specific path from u to v, denoted P (u, v), as follows. If there exists a unique shortest path from u to v, this shortest path is P (u, v). Otherwise, consider the smallest rectangle R (u,v) such that u and v are two of its corners. P (u, v) is the unique path among the shortest path from u to v that traverses all the edges on the northern side of R (u,v) . Note that P (u, v) = P (v, u).
An illustration of P (u, v) is given in Figure 1.

Idea of the algorithm
In this section we give the high level idea of our solution: more detailed explanations are given in section 5.

Informal Description in a Nutshell
We aim at achieving rendezvous of two asynchronous mobile agents in an infinite grid and in a deterministic way. It is well known that solving rendezvous deterministically is impossible in some symmetric graphs (like a basic grid) unless both agents are given distinct identifiers called labels. We use them to break the symmetry, i.e., in our context, to make the agents follow different routes. The idea is to make each agent "read" its label binary representation, one bit at a time from the most to the least significant bits, and for each bit it reads, follow a route depending on the read bit. Our algorithm ensures rendezvous during some of the periods when they follow different routes i.e., when the two agents process two different bits. Furthermore, to design the routes that both agents will follow, our approach would require to know an upper bound on two parameters, namely the initial distance between the agents and the length (of the binary representation) of the shortest label. As we suppose that the agents have no knowledge of these parameters, they both perform successive "assumptions", in the sequel called phases, in order to find out such an upper bound. Roughly speaking, each agent attempts to estimate such an upper bound by successive tests, and for each of these tests, acts as if the upper bound estimation was correct. Both agents first perform Phase 0. When Phase i does not lead to rendezvous, they perform Phase i + 1, and so on. More precisely, within Phase i, the route of each agent is built in such a way that it ensures rendezvous if 2 i is a good upper bound on the parameters of the problem. Hence, in our approach two requirements are needed: both agents are assumed (1) to process two different bits (i.e., 0 and 1) almost concurrently and (2) to perform Phase i = α almost at the same time-where α is the smallest integer such that the two aforementioned parameters are upper bounded by 2 α .
However, to meet these requirements, we have to face two major issues. First, since the adversary can vary both agent speeds, the idea described above does not prevent the adversary from making the agents always process the same type of bit at the same time. Moreover, the route cost depends on the phase number, and thus, if an agent were performing some Phase i with i exponential in the initial distance and in the length of the binary representation of the smallest label, then our algorithm would not be polynomial. To tackle these two issues, we use a mechanism that prevents the adversary from making an agent execute the algorithm arbitrarily faster than the other without meeting. Each of both these issues is circumvented via a specific "synchronization mechanism". Roughly speaking, the first one makes the agents read and process the bits of the binary representation of their labels at nearly the same speed, while the second ensures that they start Phase α at almost the same time. This is particularly where our feat of strength is: orchestrating in a subtle manner these synchronizations in a fully asynchronous context while ensuring a polynomial cost. Now that we have described the very high level idea of our algorithm, let us give more details.

Under the hood
The approach described above allows us to solve rendezvous when there exists an index for which the binary representations of both labels differ. However, this is not always the case especially when a binary representation is a prefix of the other one (e.g., 100 and 1000). Hence, instead of considering its own label, each agent will consider a transformed label: The transformation borrowed from [17] will guarantee the existence of the desired difference over the new labels. In the rest of this description, we assume for convenience that the initial Manhattan distance D separating the agents is at least the length of the shortest binary representation of the two transformed labels (the complementary case adds an unnecessary level of complexity to understand the intuition).
As mentioned previously, our solution (cf. Algorithm 5 in Section 5) works in phases numbered 0, 1, 2, 3, 4, . . . During Phase i (cf. Procedure Assumption called at line 3 in Algorithm 5), the agent supposes that the initial distance D is at most 2 i and processes one by one the first 2 i bits of its transformed label: In the case where 2 i is greater than the binary representation of its transformed label, the agent will consider that each of the last "missing" bits is 0. When processing a bit, the agent executes a particular route which depends on the bit value and the phase number. The route related to bit 0 (relying in particular on Procedure Berry called at line 9 in Algorithm 6) and the route related to bit 1 (relying in particular on Procedure Cloudberry called at line 11 in Algorithm 6) are obviously different and designed in such a way that if both these routes are executed almost simultaneously by two agents within a phase corresponding to a correct upper bound, then rendezvous occurs by the time any of them has been completed.
In the light of this, if we denote by α the smallest integer such that 2 α ≥ D, it turns out that an ideal situation would be that the agents concurrently start phase α and process the bits at quite the same rate within this phase. Indeed, we would then obtain the occurrence of rendezvous by the time the agents complete the process of the λth bit of their transformed label in phase α, where λ is the smallest index for which the binary representations of their transformed labels differ. However, getting such an ideal situation in presence of a fully asynchronous adversary appears to be really challenging. This is where the two synchronization mechanisms briefly mentioned above come into the picture.
If the agents start Phase α approximately at the same time, the first synchronization mechanism (cf. Procedure RepeatSeed called at line 15 in Algorithm 6) permits to force the adversary to make the agents process their respective bits at similar speed within Phase α, as otherwise rendezvous would occur prematurely during this phase before the process by any agent of the λth bit. This constraint is imposed on the adversary by dividing each bit process into some predefined steps and by ensuring that after each step s of the kth bit process, for any k ≤ 2 α , an agent follows a specific route that forces the other agent to complete the step s of its kth bit process. This route, on which the first synchronization is based, is constructed by relying on a simple principle that enables an agent to "push" the other. The principle is as follows: if an agent performs a given route X included in a given area S of the basic grid, then the other agent can force it to finish route X by covering S as many times as there are edge traversals in X. More precisely, each covering of S allows to traverse all the edges of X at least once: so, in each covering the agent executing X must complete at least one edge traversal or rendezvous occurs. Hence, one of the major difficulties we have to face lies in the setting up of the second synchronization mechanism guaranteeing that the agents start Phase α around the same time. At first glance, it might be tempting to use an analogous principle to the one used for dealing with the first synchronization. Indeed, if an agent a 1 follows a route covering r times an area Y of the grid, such that Y is where the first α − 1 phases of an agent a 2 take place and r is the maximal number of edge traversals an agent can make during these phases, then agent a 1 pushes agent a 2 to complete its first α − 1 phases and to start Phase α. Nevertheless, a strict application of this principle to the case of the second synchronization directly leads to an algorithm having a cost that is superpolynomial in D and the length of the smallest label, due to a cumulative effect that does not appear for the case of the first synchronization. As a consequence, to force an agent to start its Phase α, the second synchronization mechanism does not depend on the kind of route described above, but on a much more complicated route that permits an agent to "push" the second one. This works by considering the "pattern" that is drawn on the grid by the second agent rather than just the number of edges that are traversed (cf. Procedure Harvest called at line 1 in Algorithm 6). This is the most tricky part of our algorithm, one of the main idea of which relies in particular on the fact that some routes made of an arbitrarily large sequence of edge traversals can be pushed at a relative low cost by some other routes that are of comparatively small length, provided they are judiciously chosen. Let us illustrate this point through the following example. Consider an agent a 1 following from a node v 1 an arbitrarily large sequence of X i , in which each X i corresponds either to AA or BB where A and B are any routes (A and B corresponding to their respective backtrack i.e., the sequence of edge traversals followed in the reverse order). An agent a 2 starting from an initial node v 2 located at a distance at most d from v 1 can force agent a 1 to finish its sequence of X i (or otherwise rendezvous occurs), regardless of the number of X i , simply by executing AABB from each node at distance at most d from v 2 . To support this claim, let us suppose by contradiction that it does not hold. At some point, agent a 2 necessarily follows AABB from v 1 . However, note that if either agent starts following AA (resp. BB) from node v 1 while the other is following AA (resp. BB) from node v 1 , then the agents meet. Indeed, this implies that the more ahead agent eventually follows A (resp. B) from a node v 3 to v 1 while the other is following A (resp. B) from v 1 to v 3 , which leads to rendezvous. Hence, when agent a 2 starts following BB from node v 1 , agent a 1 is following AA, and is not in v 1 , so that it has at least started the first edge traversal of AA. This means that when agent a 2 finishes following AA from v 1 , a 1 is following AA, which implies, using the same arguments as before, that they meet before either of them completes this route. Hence, in this example, agent a 2 can force a 1 to complete an arbitrarily large sequence of edge traversals with a single and simple route. Actually, our second synchronization mechanism implements this idea (this point is refined in Section 5). This was the most complicated thing to set up, as each part of route in every phase had to be orchestrated very carefully to permit, in the end, this low cost synchronization while still ensuring rendezvous. However, it is through this original and novel way of moving that we finally get the polynomial cost.

Basic patterns
In this section we define some sequences of moving instructions, i.e., patterns of moves, that will serve in turn as building blocks in the construction of our rendezvous algorithm. The main roles of these patterns are given in the next section when presenting our general solution. Figure 2: An illustration of the movements executed by an agent during the first period of Seed(3) from a node u 0 . An arrow from a node x to a node y represents an edge traversal from x to y. Depending on the shape of the arrow, the represented movement is performed in a different phase.

Pattern Seed
Pattern Seed is involved as a subpattern in the design of all the other patterns presented in this section.
The description of Pattern Seed is given in Algorithm 1. It is made of two periods. For a given non-negative integer x, the first period of Pattern Seed(x) corresponds to the execution of x phases, while the second period is a complete backtrack of the path travelled during the first period. Pattern Seed is designed in such a way that it offers some properties that are shown in Section 6.1.2 and that are necessary to conduct the proof of correctness. One of the main purpose of this pattern is the following: starting from a node v, Pattern Seed(x) allows to visit all nodes of the grid at distance at most x from v and to traverse all edges of the grid linking two nodes at distance at most x from v (informally, the procedure permits to cover an area of radius x). An illustration of Pattern Seed is given in Figure 2.
: end for 6: /* Second period */ 7: L ← the path followed by the agent during the first period 8: Backtrack by following the reverse path L

Pattern RepeatSeed
Following the high level description of our solution (Section 3), Pattern RepeatSeed is the basic primitive procedure that implements the first synchronization mechanism (between two consecutive steps of a bit process). An agent a 1 executing pattern RepeatSeed(x, n) from a node u processes n times pattern Seed(x) from node u. All along this execution, a 1 stays at distance at most x from u. Moreover, once the execution is over, the agent is back at u.
The description of pattern RepeatSeed is given in Algorithm 2.

Algorithm 2 Pattern
RepeatSeed(x, n) Execute n times Pattern Seed(x)

Pattern Berry
According to Section 3, Pattern Berry is used in particular to design the specific route that an agent follows when processing bit 0. The description of Pattern Berry is given in Algorithm 3. It is made of two periods, the second of which is a backtrack of the first one. Pattern Berry offers several properties that are proved in Section 6.1.4 and used in the proof of correctness. Note that, Pattern Berry(x, y) executed from a node u for any two integers x and y allows, in particular, an agent to perform Pattern Seed(x) from each node at distance at most y from u. An illustration of Pattern Berry is given in Figure 3.

Algorithm 3 Pattern Berry(x, y)
1: /* First period */ 2: Let u be the current node for each node v at distance j from u ordered in the clockwise direction from the North do 6: Follow P (u, v)

7:
Execute Seed(i − j) 8: end for 10: end for 11: end for 12: /* Second period */ 13: L ← the path followed by the agent during the first period 14: Backtrack by following the reverse path L Figure 3: Illustration of a part of the route followed by an agent executing Pattern Berry(2, 3) from a node u 0 . When executing this pattern the agent has to execute many patterns Seed interleaved with executions of paths P from all nodes at distance at most 3 from u 0 . Some of these patterns and paths are depicted in the figure. It is particularly the case of the dotted square centered at u 1 (resp. u 2 and u 3 ) that delimits the set of nodes that are visited when executing a pattern Seed(2) from node u 1 (resp. u 2 and u 3 ). Before executing Seed(2) from node u 1 (resp. u 2 or u 3 ), the agent follows P (u 0 , u 1 ) (resp. P (u 0 , u 2 ) or P (u 0 , u 3 )), and after executing Seed(2) from node u 1 (resp. u 2 or u 3 ), the agent follows the path P (u 1 , u 0 ) (resp. P (u 2 , u 0 ) or P (u 3 , u 0 )). These different paths P are represented by arrows.

Pattern Cloudberry
According to Section 3, Pattern Cloudberry is used in particular to design the specific route that an agent follows when processing bit 1. The description of Pattern Cloudberry is given in Algorithm 4. As for Patterns Seed and Berry, the pattern is made of two periods, the second of which corresponds to a backtrack of the first one. Properties related to this pattern are given in Section 6.1.5. Note that, Pattern Cloudberry(x, y, z, h) executed from a node u for any integers x, y, z and h allows an agent to perform Patterns Berry(x, y) and Seed(x) from each node at distance at most z from u. Parameter h is an integer input that indicates in which order the agent has to visit each node at distance at most z from u (to execute Patterns Berry(x, y) and Seed(x) from each of these nodes). Playing on this order is used for technical reasons that are detailed in the proof of Theorem 22. An illustration of Pattern Cloudberry is given in Figure 4.

Algorithm 4 Pattern
Cloudberry(x, y, z, h) 1: /* First period */ 2: Let u be the current node 3: Let U be the list of nodes at distance at most z from u ordered in the order of the first visit when applying Seed(z) from node u 4: for i ← 0; i ≤ 2z(z + 1); i ← i + 1 do

9:
Follow P (v, u) 10: end for 11: /* Second period */ 12: L ← the path followed by the agent during the first period 13: Backtrack by following the reverse path L

Main Algorithm
In this section, we give the formal description of our solution allowing to solve rendezvous in a basic grid. We also give the main objectives of the involved subroutines and how they work at a high level. The main algorithm that solves the rendezvous in a basic grid is Algorithm RV (shown in Algorithm 5). As mentioned in Subsection 3.2, we use the label of an agent only when it has been transformed. Let us describe this transformation that is borrowed from [17]. Let (b 0 b 1 . . . b n−1 ) be the binary representation of the label of an agent. We define its transformed label as the binary sequence ). This transformation permits to obtain the feature that is highlighted by the following remark.
Remark 2. Given two distinct labels l a and l b , their transformed labels are never prefixes of each other. In other words, there exists an index λ such that the λth bit of the transformed label of l a is different from the λth bit of the transformed label of l b .
As explained in Section 3, we need such a feature because our solution requires that at some point both agents follow different routes by processing different bit values. Illustration of a part of the route followed by an agent executing Pattern Cloudberry(1, 2, 3, 0) from a node u 0 . When executing this pattern the agent has to execute paths P as well as patterns Seed and Berry from all nodes at distance at most 3 from u 0 and in particular from nodes u 1 , u 2 and u 3 . To go to these nodes from u 0 , the agent respectively follows P (u 0 , u 1 ), P (u 0 , u 2 ) and P (u 0 , u 3 ). Once in node u 1 (resp. u 2 and u 3 ) the agent executes Seed(1), which is represented by the smallest dotted square centered at u 1 (resp. u 2 and u 3 ) and then executes Berry(1, 2), which is represented by the largest dotted square centered at u 1 (resp. u 2 and u 3 ), followed by P (u 1 , u 0 ) (resp. P (u 2 , u 0 ) and P (u 3 , u 0 )). All paths P are represented by arrows. Algorithm RV makes use of a subroutine, i.e., Procedure Assumption. When an agent executes this procedure with a parameter α that is a "good" assumption i.e., that upperbounds the initial distance D and the value λ of the smallest bit position for which both transformed labels differ, we have the guarantee that rendezvous occurs by the end of this execution. In the rest of this section, we assume that α is the smallest good assumption that upperbounds D and λ.
The code of Procedure Assumption is given in Algorithm 6. It can be divided into two parts. The first part consists of the execution of Procedure Harvest (line 1 of Algorithm 6) and corresponds to the second synchronization mechanism mentioned in Section 3. The main feature of this procedure is the following: when the earlier agent finishes the execution of Harvest(α) within the execution of Assumption(α), we have the guarantee that the later agent has at least started to execute Assumption with parameter α (actually, as explained below, we have even the guarantee that most of Harvest(α) has been executed by the later agent). Procedure Harvest is presented below. The second part of Procedure Assumption (cf. lines 2 − 19 of Algorithm 6) consists in processing the bits of the transformed label one by one. More precisely when processing a given bit in a call to Procedure Assumption(d), the agent acts in steps 0, 1, . . . , 2d(d + 1): After each of these steps, the agent executes Pattern RepeatSeed whose role is described below. In each of these steps, the agent executes Berry (resp. Cloudberry) if the bit it is processing is 0 (resp. 1). These patterns of moves (cf. Algorithms 3 and 4 in Section 4) are made in such a way that rendezvous occurs by the time any agent finishes the process of its λth bit in Assumption(α) if we have the following synchronization property. Each time any of the agents starts executing a step j during the process of its ith bit in Assumption(α), the other agent has finished the execution of either step j − 1 in the ith bit process of Assumption(α) if j > 0, or the last step of the (i − 1)th bit process of Assumption(α) if j = 0 and i > 0. To obtain such a synchronization, an agent executes what we called the first synchronization mechanism in the previous section (cf. line 15 in Algorithm 6) after each step of a bit process. Actually, this mechanism relies on procedure RepeatSeed, the code of which is given in Algorithm 1. Note that the total number of steps, and thus of executions of RepeatSeed, in Assumption(α) is 2α 2 (α + 1) + α. For every 0 ≤ k ≤ 2α 2 (α + 1) + α, the kth execution of RepeatSeed in Assumption(α) by an agent permits to force the other agent to finish the execution of its kth step in Assumption(α) by repeating a pattern Seed (its main purpose is described just above its code given by Algorithm 2): with the appropriate parameters, this pattern Seed covers any pattern (Berry or Cloudberry) made in the kth step of Assumption(α) and the number of times it is repeated is at least the maximal number of edge traversals we can make in the kth step of Assumption(α).
Algorithm 7 gives the code of Procedure Harvest. Procedure Harvest is made of two parts: the executions of Procedure P ushP attern (lines 1 − 3 of Algorithm 7), and the calls to the patterns Cloudberry and RepeatSeed (lines 4 − 5 of Algorithm 7). When Harvest is executed with parameter α (which is a good assumption), the first part ensures that the later agent has at least completed every execution of Assumption with a parameter that is smaller than α, while the second part ensures that the later agent has completed almost the entire execution of Harvest(α) (more precisely, when the earlier agent finishes the second part, we have the guarantee that it remains for the later agent to execute at most the last line before completing its own execution of Harvest(α)).

Algorithm 6 Assumption(d)
1: Execute Harvest(d) 2: radius ← 2d 4 + 3d 3: i ← 1 4: while i ≤ d do 5: j ← 0 6: while j ≤ 2d(d + 1) do 7: // Begin of step j 8: if the length of the transformed label is strictly greater than i, or its ith bit is 0 then 9: Execute Berry(radius, d) 10: else 11: Execute Cloudberry(radius, d, d, j) 12: end if 13: // End of step j 14: radius ← radius + 3d 15: Execute RepeatSeed(radius, C(Cloudberry(radius − 3d, d, d, j))) 16: j ← j + 1 17: end while 18: i ← i + 1 19: end while To give further details on Procedure Harvest, let us first describe Procedure P ushP attern (its code is given in Algorithm 8). When the earlier agent completes the execution of P ushP attern(2i, d) with i some power of two, assuming that the later agent had already completed Assumption(i), we have the guarantee that the later agent has completed its execution of Assumption(2i). To ensure this, we regard the execution of Assumption(2i) as a sequence of calls to basic patterns (namely RepeatSeed, Berry and Cloudberry), which is formally defined in Definition 3. This sequence is what we meant when talking about "the pattern drawn on the grid" in Subsection 3.2. The sequence of calls to basic patterns of the earlier agent in Assumption(2i) is quite similar to the one of the later agent: they have the same length and the sth pattern of one sequence is RepeatSeed iff the sth pattern of the other sequence is RepeatSeed. In fact, the only difference, due to distinct transformed labels, is that if the sth pattern of one sequence is Berry (resp. Cloudberry), the sth pattern of the other sequence may be either Berry or Cloudberry.
For each basic pattern p s in its sequence, the earlier agent executes another pattern p s at the end of which we ensure that the later agent has completed the execution of the sth basic pattern of its own sequence. Whether p s is Berry or Cloudberry, p s is the same so that the earlier agent does not need to know the type of the sth basic pattern in the sequence of the later agent in order to push it (and by extension, does not require the knowledge of the label of the later agent). More precisely, p s is chosen as follows.
If p s is either Pattern Berry or Pattern Cloudberry, then p s is Pattern RepeatSeed: we use the same idea here as for the first synchronization mechanism. If p s is Pattern RepeatSeed, then p s is Pattern Berry, relying on a property of the route XX (with X any non-empty route) introduced in the last paragraph of Subsection 3.2: if both agents follow this route concurrently from the same node, then they meet. Pattern Seed can be seen as such a route, and Procedure Berry (whose code is shown in Algorithm 3) consists in executing Pattern Seed from each node at distance at most α. Hence, unless they meet, the later agent completes its execution of Pattern RepeatSeed before the earlier one starts executing Seed from the same node. Note that P ushP attern uses as many patterns as the number of basic patterns in the sequence it is supposed to push: this and the fact of doubling the value of the input parameter of Procedure Assumption in Algorithm 5 contribute in particular to keep the polynomiality of our solution.
Thus, once the earlier agent completes the first part of Harvest(α), the later one has at least started the execution of Assumption(α) (and thus of the first part of Harvest(α)). At this point, we might think at first glance that we just shifted the problem. Indeed, the number of edge traversals that has to be made to complete all the executions of Assumption prior to Assumption(α) is quite the same, if not higher, than the number of edge traversals that has to be made when executing the first part of Harvest(α). Hence the difference between both agents in terms of edge traversals has not been improved here. However, a crucial and decisive progress has nonetheless been done: contrary a priori to the series of Assumption executed before Assumption(α), the first part of Harvest(α) can be pushed at low cost via the execution of Pattern Cloudberry (line 4 of Algorithm 7) by the earlier agent. Actually this pattern corresponds to the kind of route, described at the end of Subsection 3.2 for the second synchronization mechanism, which is of small length compared to the sequence of patterns it can push. Indeed, the first part of Harvest(α) can be viewed as a "large" sequence of Patterns Seed and Berry: however Seed and Berry can be seen (by analogy with Subsection 3.2) as routes of the form AA and BB respectively, while Pattern Cloudberry executes Seed and Berry (i.e., AABB) once from at least each node at distance at most α.
Note that when the earlier agent has completed the execution of Cloudberry in Harvest(α), the later agent has at least started the execution of Pattern Cloudberry in Harvest(α). Hence, there is still a difference between both agents, but it has been considerably reduced: it is now relatively small so that we can handle it pretty easily afterwards.

Algorithm 7 Harvest(d)
Execute P ushP attern(i, d) 3: end for 4: Execute Cloudberry(2d 4 , d, d, 0) 5: Execute RepeatSeed(2d 4 + 3d, C (Cloudberry(2d 4 , d, d, 0))) Definition 3 (Basic and Perfect Decomposition). Given a call P to an algorithm, we say that the basic decomposition of P , denoted by BD(P ), is P itself if P corresponds to a basic pattern, the type of which belongs to {RepeatSeed; Berry; Cloudberry}. Otherwise, if P contains no call or contains a moving instruction outside of every call then BD(P ) =⊥, else BD(P ) = BD(x 1 ), BD(x 2 ), . . . , BD(x n ) where x 1 , x 2 , . . . , x n is the sequence (in the order of execution) of all the calls in P that are children of P . We say that BD(P ) is a perfect decomposition if it does not contain any ⊥. if p is a call to pattern RepeatSeed with value x as first parameter then 3: Execute Berry(x, d) 4: else 5: /* pattern p is either a call to pattern Berry or a call to pattern Cloudberry (in view of the above remark) and has at least two parameters */ 6: Let x (resp. y) be the first (resp. the second) parameter of p 7: Execute RepeatSeed(d + x + 2y, C(Cloudberry(x, y, y, 0))) 8: end if 9: end for

Proof of correctness and cost analysis
The purpose of this section is to prove that Algorithm RV ensures rendezvous in the basic grid at cost ∈ O((D + l) 33 ) with D the initial distance between the agents and l, the length of the shortest label. To this end, the section is made of four subsections. The first two subsections are dedicated to technical results about the basic patterns presented in Section 4 and synchronization properties of Algorithm RV, which are used in turn to carry out the proof of correctness and the cost analysis of Algorithm RV that are presented in the last two subsections.

Properties of the basic patterns
This subsection is dedicated to the presentation of some technical results about the basic patterns described in Section 4. They are used in the following subsections to prove the correctness of Algorithm 5.

Vocabulary
Before going any further, we need to introduce some extra vocabulary in order to facilitate the presentation of the next properties and lemmas.

Definition 5. A pattern execution A precedes another pattern execution B iff the beginning of A occurs by the beginning of B.
Definition 6. Two pattern executions A and B are concurrent iff: • pattern execution A does not finish before pattern execution B starts • pattern execution B does not finish before pattern execution A starts By misuse of language, in the rest of this paper we will sometimes say "a pattern" instead of "a pattern execution".
Hereafter we say that a pattern A concurrently precedes a pattern B, iff A and B are concurrent, and A precedes B.

Definition 7.
A pattern A pushes a pattern B if for every execution in which B precedes A, agents meet before the end of the execution of A or B finishes before A.
In the sequel, given two sequences of moving instructions X and Y , we will say that X is a prefix of Y if Y can be viewed as the execution of the sequence X followed by another (possibly empty) sequence.

Pattern Seed
In this section, we show some properties related to Pattern Seed.
Proposition 8 follows by induction on the input parameter of Pattern Seed and Proposition 9 follows from Algorithm 1.
Proposition 8. Let x be any positive integer. Starting from a node v, Pattern Seed(x) guarantees the following properties: 1. it allows to visit all nodes of the grid at distance at most x from v 2. it allows to traverse all edges of the grid linking two nodes at distance at most x from v Proposition 9. Given two integers x 1 ≤ x 2 , the first period of Pattern Seed(x 1 ) is a prefix of the first period of Pattern Seed(x 2 ). Lemma 10. Let x 1 and x 2 be two positive integers such that x 1 ≤ x 2 . Let a 1 and a 2 be two agents executing respectively Patterns Seed(x 1 ) and Seed(x 2 ) both from the same node such that the execution of Pattern Seed(x 1 ) concurrently precedes the execution of Pattern Seed(x 2 ). Let t 1 (resp. t 2 ) be the time when agent a 1 (resp. a 2 ) completes the execution of Pattern Seed(x 1 ) (resp. Seed(x 2 )). Agents a 1 and a 2 meet by time min(t 1 , t 2 ).
Proof. In view of Proposition 9, the first period of Seed(x 1 ) is a prefix of the first period of Pattern Seed(x 2 ). If the path followed by agent a 1 during its execution of Seed(x 1 ) is e 1 , e 2 , . . . , e n , e 1 , e 2 , . . . , e n (the overlined part of the path corresponds to the backtrack), then the path followed by agent a 2 during the execution of Pattern Seed(x 2 ) is e 1 , e 2 , . . . , e n , s, e 1 , e 2 , . . . , e n , s where s corresponds to the edges traversed at a distance ∈ {x 1 + 1; . . . ; x 2 }.
We have two cases to consider. If agent a 2 completes e 1 , e 2 , . . . , e n by the time a 1 completes e 1 , e 2 , . . . , e n , then agents a 1 and a 2 meet while they are following e 1 , e 2 , . . . , e n as agent a 1 is the first agent that starts following e 1 , e 2 , . . . , e n . Otherwise, agent a 1 starts following e 1 , e 2 , . . . , e n while a 2 is still following e 1 , e 2 , . . . , e n : this implies that the agents meet by the time a 1 (resp. a 2 ) finishes e 1 , e 2 , . . . , e n (resp. e 1 , e 2 , . . . , e n ). So, in both cases the agents meet by time min(t 1 , t 2 ), which concludes the proof of this lemma.

Pattern RepeatSeed
This section is dedicated to some properties of Pattern RepeatSeed. Informally speaking, Lemmas 11 and 12 describe the fact that Pattern RepeatSeed pushes respectively Pattern Berry and Cloudberry when it is given appropriate parameters.
Lemma 11. Consider two nodes v 1 and v 2 separated by a distance δ. Let Berry(x 1 , y) and Repeat-Seed(x 2 , n) be two patterns respectively executed from v 1 and v 2 with x 1 , x 2 , y and n positive integers. If x 2 ≥ x 1 + y + δ and n ≥ C(Berry(x 1 , y)) then Pattern RepeatSeed(x 2 , n) pushes Pattern Berry(x 1 , y).
Proof. Denote by a 1 and a 2 the agents executing respectively Berry(x 1 , y) and RepeatSeed(x 2 , n). Let us suppose by contradiction that RepeatSeed(x 2 , n) does not push Berry(x 1 , y), which means, by Definition 7 that there exists an execution in which Pattern Berry(x 1 , y) precedes Pattern Repeat-Seed(x 2 , n) such that a 1 neither meets a 2 nor completes Berry(x 1 , y) before a 2 completes Repeat-Seed(x 2 , n). Remark that this implies in particular that these patterns are concurrent.
When executing its Berry(x 1 , y) agent a 1 cannot be at a distance greater than x 1 + y from its initial position v 1 and thus cannot be at a distance greater than δ + x 1 + y from node v 2 . Also, in view of Proposition 8, each Pattern Seed(x 2 ) executed from node v 2 which composes Pattern RepeatSeed(x 2 , n) allows to visit all nodes and to traverse all edges at distance at most x 2 from node v 2 . Thus, each Pattern Seed(x 2 ) executed from node v 2 allows to visit all nodes and to traverse all edges (although not necessarily in the same order) that are traversed during the execution of Pattern Berry(x 1 , y) from node v 1 .
Consider the number of edge traversals completed by agent a 1 between the moment when a 2 starts executing any of the Seed(x 2 ) which compose RepeatSeed(x 2 , n) and the moment when a 2 completes this Seed(x 2 ). If a 1 has not completed a single edge traversal, then whether it was in a node or traversing an edge, it has met a 2 which traverses every edge a 1 traverses during its execution of Berry(x 1 , y). This contradicts our hypothesis, which implies that each time a 2 completes one of its executions of Pattern Seed(x 2 ), a 1 has completed at least one edge traversal. Since agent a 2 executes n ≥ C(Berry(x 1 , y)) times Pattern Seed(x 2 ), a 1 traverses at least C(Berry(x 1 , y)) edges before a 2 finishes executing its RepeatSeed(x 2 , n). As C (Berry(x 1 , y)) is the number of edge traversals in Berry(x 1 , y), when a 2 finishes executing Pattern RepeatSeed(x 2 , n), a 1 has finished executing its Pattern Berry(x 1 , y), which contradicts our assumption and proves the lemma.
Using similar arguments to those used in the proof of Lemma 11, we can prove the following lemma.

Pattern Berry
This section is dedicated to the properties of Pattern Berry. Informally speaking, Lemma 14 describes the fact that Pattern Berry permits to push Pattern RepeatSeed when it is given appropriate parameters. Proposition 13 and Lemma 15 are respectively analogous to Proposition 9 and Lemma 10.
In view of Algorithm 3, we have the following proposition.
Proposition 13. Given four positive integers x 1 + y 1 ≤ x 2 + y 2 , the first period of Berry(x 1 , y 1 ) is a prefix of the first period of Berry(x 2 , y 2 ).

Lemma 14.
Consider two nodes v 1 and v 2 separated by a distance δ. Let RepeatSeed(x 1 , n) and Berry(x 2 , y) be two patterns respectively executed from v 1 and v 2 with x 1 , x 2 , y and n positive integers. If y ≥ δ and x 1 ≤ x 2 then Pattern Berry(x 2 , y) pushes Pattern RepeatSeed(x 1 , n).
Proof. Denote by a 1 and a 2 the agents executing respectively RepeatSeed(x 1 , n) and Berry(x 2 , y). Let us suppose by contradiction that Berry(x 2 , y) does not push RepeatSeed(x 1 , n) which means by Definition 7 that there exists an execution in which Pattern RepeatSeed(x 1 , n) precedes Pattern Berry(x 2 , y) such that a 1 neither meets a 2 nor completes RepeatSeed(x 1 , n) before a 2 completes Berry(x 2 , y). When executing Berry(x 2 , y), agent a 2 performs Seed(x 2 ) from each node at distance at most y from v 2 with y ≥ δ. Thus, at some point, a 2 executes Seed(x 2 ) from node v 1 . In view of Lemma 10, since x 2 ≥ x 1 and since by assumption, a 1 has not finished executing its Repeat-Seed(x 1 , n) when a 2 starts executing Pattern Seed(x 2 ) from v 1 , agents meet by the end of the latter and thus before the end of Berry(x 2 , y) which contradicts our assumption and proves the lemma.
Lemma 15. Consider two agents a 1 and a 2 executing respectively Patterns Berry(x 1 , y 1 ) and Berry(x 2 , y 2 ) both from node v with x 1 , x 2 , y 1 and y 2 positive integers such that x 2 + y 2 ≥ x 1 + y 1 . Suppose that the execution of Berry(x 1 , y 1 ) by a 1 concurrently precedes the execution of Berry(x 2 , y 2 ) by a 2 . Let t 1 (resp. t 2 ) be the time when agent a 1 (resp. a 2 ) completes its execution of Pattern Berry(x 1 , y 1 ) (resp. Berry(x 2 , y 2 )). Agents a 1 and a 2 meet by time min(t 1 , t 2 ).
Proof. This proof is similar to the proof of Lemma 10. In view of Proposition 13, if the path followed by agent a 1 during its execution of Berry(x 1 , y 1 ) is e 1 , e 2 , . . . , e n , e 1 , e 2 , . . . , e n (the overlined part of the path corresponds to the backtrack), then the path followed by agent a 2 during the execution of Pattern Berry(x 2 , y 2 ) is e 1 , e 2 , . . . , e n , s, e 1 , e 2 , . . . , e n , s where s corresponds to the edges traversed from the (x 1 + y 1 + 1)-th iteration of the main loop of Pattern Berry to its (x 2 + y 2 )-th iteration. We have two cases to consider. If agent a 2 completes e 1 , e 2 , . . . , e n by the time a 1 completes e 1 , e 2 , . . . , e n , then agents a 1 and a 2 meet while they are following e 1 , e 2 , . . . , e n as agent a 1 is the first agent that starts following e 1 , e 2 , . . . , e n . Otherwise, agent a 1 starts following e 1 , e 2 , . . . , e n while a 2 is still following e 1 , e 2 , . . . , e n : this implies that the agents meet by the time a 1 (resp. a 2 ) finishes e 1 , e 2 , . . . , e n (resp. e 1 , e 2 , . . . , e n ). So, in both cases the agents meet by time min(t 1 , t 2 ), which concludes the proof of this lemma.

Pattern Cloudberry
Informally speaking, the following lemma highlights the fact that Pattern Cloudberry can push "a lot of basic patterns" under some conditions. In other words, we can force an agent to make a lot of edge traversals "at relative low cost".
Lemma 16. Consider two nodes v 1 and v 2 separated by a distance δ. Let S and Cloudberry(x 1 , y 1 , z, h) be respectively a sequence of Patterns RepeatSeed and Berry executed from v 1 and a pattern executed from v 2 with x 1 , y 1 , z and h four positive integers. If z ≥ δ and for each Pattern RepeatSeed R and Pattern Berry B belonging to S, x 1 + y 1 is greater than or equal to the sum of the parameters of B, and x 1 is greater than or equal to the first parameter of R, then Pattern Cloudberry(x 1 , y 1 , z, h) pushes S.
Proof. Denote by a 1 and a 2 the agents executing respectively S and Cloudberry(x 1 , y 1 , z, h). In order to prove that the execution of Pattern Cloudberry(x 1 , y 1 , z, h) by a 2 pushes the sequence of patterns S, let us suppose by contradiction that there exists an execution in which S precedes Pattern Cloudberry(x 1 , y 1 , z, h) such that a 1 neither meets a 2 nor completes its whole sequence of patterns before a 2 completes Cloudberry(x 1 , y 1 , z, h).
In view of Algorithm 4, when executing Cloudberry(x 1 , y 1 , z, h), a 2 executes Pattern Seed(x 1 ) followed by Pattern Berry(x 1 , y 1 ) on each node at distance at most z from v 2 . Since z ≥ δ, during its execution of Cloudberry(x 1 , y 1 , z, h), a 2 follows P (v 2 , v 1 ), executes Pattern Seed(x 1 ) (denoted by p 1 ) and then Pattern Berry(x 1 , y 1 ) (denoted by p 2 ) both from node v 1 . In order to prove that the execution of Cloudberry(x 1 , y 1 , z, h) by a 2 pushes the execution of S by a 1 , we are going to prove that the agents meet by the time a 2 completes its executions of p 1 and p 2 .
By assumption, a 1 has not finished executing S when a 2 arrives on v 1 to execute p 1 and p 2 . Let us consider what it can be executing at this moment. If it is executing Pattern Seed(x 2 ) with x 2 ≤ x 1 a positive integer, then in view of Lemma 10, the agents meet by the end of the execution of p 1 , which contradicts the assumption that the agents do not meet before the end of Cloudberry(x 1 , y 1 , z, h). This means that when a 2 starts executing p 1 , a 1 is executing Pattern Berry(x 2 , y 2 ) for some positive integers x 2 and y 2 such that x 2 + y 2 ≤ x 1 + y 1 . After p 1 , a 2 executes p 2 . By Lemma 15, if a 1 is still executing Pattern Berry(x 2 , y 2 ) for some positive integers x 2 and y 2 such that x 2 + y 2 ≤ x 1 + y 1 (the same as above, or another) then the agents meet by the end of the execution of p 2 which contradicts our assumption once again. As a consequence, when a 2 starts executing p 2 , a 1 is executing Pattern Seed(x 3 ) for some positive integer x 3 ≤ x 1 . Denote by p 3 this pattern, and remember that a 1 starts it after a 2 starts p 1 . Moreover, when a 2 starts executing p 2 , a 1 can not be in v 1 as it is the node where a 2 starts p 2 , thus it has at least started the first edge traversal of p 3 . Hence, p 1 concurrently precedes p 3 , and a 2 completes the execution of p 1 before a 1 completes the execution of p 3 .
In view of Algorithm 1, like in the proof of Lemma 10, we can denote by e 1 , . . . , e n , e 1 , . . . , e n the route followed by a 1 when executing p 3 and by e 1 , . . . , e n , s, e 1 , . . . , e n , s the route followed by a 2 when executing p 1 where s corresponds to edges traversed at a distance belonging to {x 3 +1; . . . ; x 1 }. Remark that in view of the definition of a backtrack, e 1 , . . . , e n , s = s, e 1 , . . . , e n . Consider the moment t 1 when a 1 completes the first period of p 3 and begins the second one. It has just traversed e 1 , . . . , e n , and is about to follow e 1 , . . . , e n . At this moment, a 2 can not have started the edge traversals e 1 , . . . , e n , or else agents have met by t 1 , which would contradict our assumption. However, as p 1 is completed before p 3 , a 2 must finish executing some non-empty part of ss followed by e 1 , . . . , e n before a 1 finishes executing e 1 , . . . , e n which implies that the agents meet by the end of the execution of p 1 and contradicts once again the hypothesis that they do not meet by the end of p 2 .
So, in every case, the assumption that before the end of the execution of Cloudberry(x 1 , y 1 , z, h), a 1 neither meets a 2 nor finishes executing S is contradicted. Hence, the execution of Pattern Cloudberry(x 1 , y 1 , z, h) by a 2 pushes the execution of S by a 1 , and the lemma holds.

Agents synchronizations
We recall the reader that D is the initial distance separating the two agents in the basic grid.
The aim of this subsection is to introduce and prove several synchronization properties our algorithms offer (cf., Lemmas 20 and 21). By "synchronization" we mean that if one agent has completed some part of its rendezvous algorithm, then either it must have met the other agent or this other agent has also completed some part (not necessarily the same one) of its algorithm i.e., it must have made progress.
To prove Lemmas 20 and 21, we first need to show some more technical results-Lemmas 17, 18, and 19.

Lemma 17.
Let v 1 and v 2 be the two nodes separated by a distance D that are initially occupied by the agents a 1 and a 2 respectively. Let c 1 and d 1 be two non-negative integers such that d 1 ≥ D. Assume the prefix of the execution of agent a 1 is the sequence S 1 = Assumption(1), . . . , Assumption(2 c 1 ). Assume that a part of the execution of agent a 2 is the sequence S 2 = P ushP attern (1, d 1 ), . . . , P ush-P attern(2 c 1 , d 1 ). Either the agents meet before the end of the execution of S 2 or S 1 finishes before S 2 .
Proof. Assume by contradiction that there exists some scenario E 1 in which neither the agents meet before the end of the execution of S 2 by agent a 2 nor the execution of S 1 by a 1 finishes before the execution of S 2 by a 2 .
In view of Algorithm 8, and since there are as many occurrences of Procedure Assumption in S 1 as of Procedure P ushP attern in S 2 , there are as many basic patterns (from {RepeatSeed; Berry; Cloud-berry}) in BD(S 1 ) as in BD(S 2 ). Each basic pattern inside BD(S 1 ) and BD(S 2 ) is given an index between 1 and n according to its order of appearance. In view of Remark 4, for any integer d 2 , BD(Assumption(d 2 )) is perfect, which implies that BD(S 1 ) is perfect too. This has the following consequences. When agent a 1 starts the execution of S 1 , this agent starts the execution of the first basic pattern in BD(S 1 ). Moreover, when agent a 1 completes the execution of S 1 , it completes the execution of the n-th basic pattern in BD(S 1 ). Lastly, for any integer i between 1 and n − 1, agent a 1 does not make any edge traversal between the i-th and the (i + 1)-th basic pattern in BD(S 1 ). In other words, every edge traversal agent a 1 makes during the execution of S 1 is performed during one of the basic patterns inside BD(S 1 ). Remark that BD(S 2 ) is perfect too.
Let us show by induction on i that for every integer i between 1 and n, a 1 either meets a 2 or completes the execution of the i-th pattern inside BD(S 1 ) before a 2 completes the execution of the i-th pattern inside BD(S 2 ). If i = 1, we distinguish two cases. In the first case, the first pattern of BD(S 2 ) starts before the first pattern of BD(S 1 ), while in the second case it does not i.e.,, in view of Definition 5, the first pattern of BD(S 1 ) precedes the first pattern of BD(S 2 ).
In the first case, since it does not make any edge traversal before the moment t 1 when it starts executing the first pattern of BD(S 1 ), we assume that a 1 is in v 1 from the moment t 2 when a 2 starts executing the first pattern in BD(S 2 ) to t 1 . We can build another scenario E 2 in which a 1 (resp. a 2 ) executes S 1 (resp. S 2 ) from v 1 (resp. v 2 ) as in E 1 , at every moment of E 2 both a 1 and a 2 are at the exact same place as in E 1 , but in which the first pattern of BD(S 1 ) precedes the first pattern of BD(S 2 ). We achieve this by designing the behavior of the adversary in E 2 as follows. The adversary handles a 2 in the same way in E 2 as in E 1 . From the moment t 3 at which a 1 starts executing S 1 in E 2 to the moment t 2 at which a 2 starts executing S 2 (both in E 1 and E 2 ), as well as from t 2 to the moment t 1 at which a 1 starts executing S 1 in E 1 , in E 2 , the adversary prevents a 1 from moving from v 1 . Moreover, from t 1 on, in E 2 , the adversary handles a 1 as in E 1 . Since at every moment both a 1 and a 2 are at the same place in E 1 and E 2 , if we prove in E 2 that a 1 either meets a 2 or completes the execution of the first pattern inside BD(S 1 ) before a 2 completes the execution of the first pattern inside BD(S 2 ), then this also holds in E 1 . Also, in E 2 , the first pattern of BD(S 1 ) precedes the first pattern of BD(S 2 ), this is the second of the two cases we distinguish. Hence, when i = 1 it is enough to consider the second case only.
If the first pattern of BD(S 1 ) precedes the first pattern of BD(S 2 ), then in view of Lemmas 11, 12 and 14, Algorithm 8 and the fact that d 1 ≥ D, whatever the type of the first pattern inside BD(S 1 ) (Berry, Cloudberry or RepeatSeed), a 1 either meets a 2 or completes the first pattern inside BD(S 1 ) before a 2 completes the first pattern inside BD(S 2 ).
Let us now assume that there exists an integer j in {1, . . . , (n − 1)} such that a 1 either meets a 2 or completes the j-th pattern inside BD(S 1 ) before a 2 completes the j-th pattern inside BD(S 2 ) and show that a 1 either meets a 2 or completes the (j + 1)-th pattern inside BD(S 1 ) before a 2 completes the (j + 1)-th pattern inside BD(S 2 ). In order to achieve this, let us suppose that the agents do not meet before the end of the execution of the (j + 1)-th pattern inside BD(S 2 ) and show that the execution of the (j + 1)-th pattern inside BD(S 1 ) finishes before the execution of the (j + 1)-th pattern inside BD(S 2 ). In view of the induction hypothesis, and the assumption that the agents do not meet before the end of the execution of the (j + 1)-th pattern inside BD(S 2 ), the j-th pattern inside BD(S 1 ) finishes before the j-th pattern inside BD(S 2 ) which means that the (j + 1)-th pattern inside BD(S 1 ) precedes the (j +1)-th pattern inside BD(S 2 ). Again, in view of Lemmas 11, 12 and 14, Algorithm 8 and the fact that d 1 ≥ D, whatever the type of the (j + 1)-th pattern inside BD(S 1 ), it finishes before the (j + 1)-th pattern inside BD(S 2 ). In particular, if the (j + 1)-th pattern inside BD(S 1 ) is a Berry or a Cloudberry called after the test at line 8, at line 9 or 11, of Algorithm 6, regardless of which of the two patterns it is, a 1 completes its execution before the end of the (j +1)-th pattern inside BD(S 2 ). Indeed, for any positive integers x, y, z and h, Cloudberry(x, y, z, h) can be viewed as composed of several Berry(x, y) so that C(Cloudberry(x, y, z, h)) ≥ C (Berry(x, y)).
This means in particular that before the end of the n-th pattern inside BD(S 2 ) and thus before the end of S 2 , a 1 either meets a 2 or completes the n-th pattern inside BD(S 1 ) and thus S 1 itself, which completes the proof.
Lemma 18. Let d 1 and x 1 be some integers such that the first parameter of each basic pattern inside BD(Assumption(d 1 )) is assigned a value which is at most x 1 . For every integer d 2 ≥ d 1 , the first parameter of each basic pattern inside BD(P ushP attern(d 1 , d 2 )) is less than or equal to x 1 + 3d 2 .
Proof. In view of Algorithm 8, each basic pattern inside BD(Assumption(d 1 )) and BD(P ush-P attern(d 1 , d 2 )) (with d 2 ≥ d 1 some integer) is given an index from 1 to n according to its order of appearance, with n the number of basic patterns in either of these decompositions. Thus, for any integer i from 1 to n, there is a pair of patterns (p 1 , p 2 ) such that p 1 is the i-th basic pattern inside BD(Assumption(d 1 )), and p 2 is the i-th pattern inside BD (P ushP attern(d 1 , d 2 )). Let us show that there is no such pair (p 1 , p 2 ) such that the first parameter of p 2 is given a value greater than x 1 + 3d 2 . To this end, we analyse three cases depending on the type of pattern p 1 .
Let us first consider the case in which p 1 is Pattern RepeatSeed(x 2 , n 1 ) with x 2 ≤ x 1 and n 1 two positive integers. In view of Algorithm 8, since p 1 is Pattern RepeatSeed(x 2 , n 1 ), p 2 is Berry(x 2 , d 2 ), which means that its first parameter is at most x 1 and thus at most x 1 + 3d 2 .
Let us now consider the cases in which p 1 is either Pattern Berry or Pattern Cloudberry. We first make the following remark. In BD(Assumption(d 1 )), whether it is called directly by Procedure Assumption(d 1 ), or inside its call to Harvest(d 1 ), or inside the call of the latter to P ush-P attern(d 3 , d 1 ) with some integer d 3 < d 1 , the second parameter of Pattern Berry is always d 1 , and the second and third parameters of Pattern Cloudberry are always d 1 as well.
Hence, within BD(P ushP attern(d 1 , d 2 )), there cannot be any call to a basic pattern in which the first parameter is assigned a value greater than x 1 + 3d 2 , which proves the lemma.
Lemma 19. The first parameter of each basic pattern inside BD(Assumption(d 1 )) (with d 1 any power of two) is at most 32d 4 1 − 6d 1 .
Proof. We prove this lemma by induction on d 1 .
Let us first consider that d 1 = 1. We enumerate the basic patterns inside BD(Assumption (1)) and show that for each of them the first parameter is given a value which is less than or equal to 32d 4 1 − 6d 1 = 26. Procedure Assumption(1) begins with Harvest(1) which is composed of calls to Cloudberry(2, 1, 1, 0) and RepeatSeed(5, C(Cloudberry (2, 1, 1, 0))), with both first parameters lower than 26. After Harvest(1) too, the first parameter that is given to the patterns called in Procedure Assumption(1) is always at most 26. Indeed, the first parameter is assigned its maximum value when j = 2d 1 (d 1 + 1) = 4 and i = d 1 = 1 i.e., when 3d 1 = 3 has been added i(j + 1) = 5 times to the initial value of radius i.e., 5, which gives a maxiuml value equal to 5 + 15 = 20 < 26. This concludes the analysis of the case when d 1 = 1.
Before presenting the next lemma, we need to introduce the following notions. We say that the first four lines of Algorithm Harvest are its first part, and that the last line is the second part. Procedure Assumption begins with a call to Procedure Harvest: We will consider that the first part of Procedure Assumption is the first part of this call, and that the second part of Procedure Assumption is the second part of this call. After these two parts, there is a third part in Procedure Assumption which consists of calls to basic patterns. Moreover, note that the execution of Algorithm RV can be viewed as a sequence of consecutive calls to Procedure Assumption with an increasing parameter. We will say that the (i + 1)-th call to Procedure Assumption (i.e., the call to Procedure Assumption(2 i )) by an agent executing Algorithm RV is Phase i. Lemma 20. Consider two agents a 1 and a 2 executing Algorithm RV. Let i 1 and d 1 be two integers such that 2 i 1 = d 1 ≥ D. Agent a 1 either meets a 2 or completes the execution of the first part of Phase i 1 before agent a 2 completes the execution of the second part of Phase i.
Proof. Assume by contradiction that the lemma is false. This implies in particular that when a 2 finishes executing the second part of Phase i 1 , a 1 is either executing Phase i 2 for an integer i 2 < i 1 , or the first part of Phase i 1 .
First of all, in view of Lemma 17 and since d 1 ≥ D, we know that a 1 either meets a 2 or finishes executing the sequence Assumption(1), . . . , Assumption(2 i 1 −1 ) before a 2 completes the sequence P ushP attern (1, d 1 ), . . . , P ushP attern(2 i 1 −1 , d 1 ) (i.e., the loop at the beginning of procedure Harvest(d 1 )). Given that by assumption, agents do not meet before a 2 completes its execution of the second part of Phase i 1 , a 1 starts executing the first part of Phase i 1 before a 2 finishes executing the loop at the beginning of Procedure Harvest(d 1 ), which means that the execution of the loop at the beginning of Procedure Harvest(d 1 ) by a 1 precedes the execution of Cloudberry(2d 4 1 , d 1 , d 1 , 0) by a 2 .
Let us build on this to show that when a 2 finishes executing Cloudberry(2d 4 1 , d 1 , d 1 , 0), a 1 has finished executing the loop at the beginning of Procedure Harvest(d 1 ). In view of Lemmas 18 and 19, while executing this loop, a 1 executes a sequence of Patterns RepeatSeed and Berry called by Procedure P ushP attern whose the first parameter is at most 2d 4 1 . Since d 1 ≥ D, in view of Lemma 16 and the assumption that the agents do not meet before the end of the execution of the second part of Phase i 1 by a 2 , when a 2 finishes executing Cloudberry(2d 4 1 , d 1 , d 1 , 0), a 1 has finished executing the loop.
In the following lemma, we focus on the calls to Pattern RepeatSeed in the second and in the third part of Procedure Assumption(d 1 ) for any power of two d 1 . In the statement and proof of this lemma, they are called "synchronization RepeatSeed", and indexed from 1 to (d 1 (2d 1 (d 1 +1)+1)+1) in their ascending execution order in these two parts of the procedure. During any execution of Procedure Assumption(d 1 ) for any power of two d 1 , the call to Pattern RepeatSeed in the second part of Procedure Assumption is the first (indexed by 1) synchronization RepeatSeed of this procedure. Proof. Suppose that agent a 2 has just finished executing the i-th synchronization RepeatSeed inside Procedure Assumption(d 1 ) for any power of two d 1 ≥ D and any positive integer i ≤ d 1 (2d 1 (d 1 + 1) + 1) + 1. Let us prove by induction on i that if rendezvous has not occurred yet then a 1 has at least started executing this i-th synchronization RepeatSeed.
Let us first consider the case in which i = 1. The synchronization RepeatSeed a 2 has just finished executing is called at the end of the execution of Procedure Harvest(d 1 ) called at line 1 of Procedure Assumption(d 1 ). Since d 1 ≥ D, in view of Lemma 20, when a 2 completes the execution of the first synchronization RepeatSeed and thus the execution of Harvest(d 1 ), either the agents have met or a 1 has completed the execution of the first part of Procedure Assumption(d 1 ) i.e., begun the execution of the first synchronization RepeatSeed.
Let us now make the assumption that for any power of two d 1 ≥ D, during any execution of Procedure Assumption(d 1 ), there exists an integer j from 1 to d 1 (2d 1 (d 1 + 1) + 1) + 1 such that when agent a 2 completes the execution of the j-th synchronization RepeatSeed, either the agents have met or a 1 has at least started the execution of the j-th synchronization RepeatSeed, and prove that when a 2 completes the execution of the (j +1)-th synchronization RepeatSeed, either the agents have met or a 1 has at least started the execution of the same synchronization RepeatSeed. Let us assume by contradiction that when a 2 finishes executing the (j + 1)-th synchronization RepeatSeed, a 1 has neither met a 2 nor started executing the (j + 1)-th synchronization RepeatSeed.
After executing the j-th synchronization RepeatSeed, a 2 executes line 9 or line 11 of Algorithm Assumption(d 1 ) and thus either Pattern Berry or Pattern Cloudberry, depending on the bits of its transformed label. The induction hypothesis implies that the execution of the j-th synchronization RepeatSeed by a 1 precedes the execution by a 2 of either Berry or Cloudberry between the j-th and the (j + 1)-th synchronisation RepeatSeed. In view of Lemmas 14 and 16, as d 1 ≥ D, whichever pattern a 2 executes, it pushes the execution of the j-th synchronization RepeatSeed by a 1 . By assumption, when a 2 finishes executing line 9 or line 11 of Algorithm Assumption(d 1 ) after the j-th synchronization RepeatSeed, the agents have not met which implies that a 1 has finished executing the j-th synchronization RepeatSeed.
The next pattern that a 2 executes is the (j + 1)-th synchronization RepeatSeed. Given the above assumptions and statements, when a 2 starts executing this synchronization RepeatSeed, a 1 has finished executing the j-th synchronization RepeatSeed and has started executing line 9 or line 11 of Algorithm Assumption(d 1 ). In view of Lemmas 11 and 12, since d 1 ≥ D, whichever pattern a 1 executes, it is pushed by the execution of the (j + 1)-th synchronization RepeatSeed by a 2 . Given that, still by assumption, the agents do not meet before a 2 completes the execution of the (j + 1)th synchronization RepeatSeed, when this occurs, a 1 has completed the execution of line 9 or 11 of Algorithm Assumption(d 1 ), just after the j-th, and just before the (j + 1)-th synchronization RepeatSeed. Hence, when a 2 completes the execution of the (j + 1)-th synchronization RepeatSeed, a 1 has at least started executing the (j + 1)-th synchronization RepeatSeed, which contradicts the hypothesis that when a 2 completes the execution of the (j + 1)-th synchronization RepeatSeed, a 1 has neither met a 2 nor started executing the (j + 1)-th synchronization RepeatSeed, and proves the lemma. Proof. To prove this theorem, it is enough to prove the following claim. First, in view of Remark 2, l exists. Respectively denote by v 1 and v 2 , the initial nodes of two agents denoted by a 1 and a 2 . This proof is made by contradiction. Suppose that the agents a 1 and a 2 execute Algorithm RV but do not meet by the time any agent completes an execution of Procedure Assumption(d 1 ) where d 1 is the smallest power of two such that d 1 ≥ max(D, l ).

Correctness of Algorithm RV
This in particular means that one of the agents eventually starts executing Assumption(d 1 ). Since d 1 ≥ D, in view of Lemma 20, we know that as soon as this agent completes the execution of Procedure Harvest(d 1 ), both agents have started executing Assumption(d 1 ). Otherwise, agents have met which contradicts our assumption. Without loss of generality, suppose that the bits in the transformed labels of agents a 1 and a 2 with the index l are respectively 1 and 0.
In order to prove this claim, we first show that there exists an iteration of the loop at line 6 of Algorithm 6 during which the two following properties are satisfied: 1. the value of variable i is equal to l 2. the value of variable j is such that when executing Pattern Cloudberry at line 11, the first pair of Patterns Seed and Berry executed inside this Cloudberry by a 1 starts from v 2 The first property follows from the fact that d 1 ≥ l . We now show that the second property is also satisfied. Let U be a list of all the nodes at distance at most d 1 from v 1 and ordered in the order of the first visit when executing Seed(d 1 ) from node v 1 . The same list is considered in the algorithm of Pattern Cloudberry(x, d 1 , d 1 , h) for any positive integers x and h. First of all, there are 2d 1 (d 1 + 1) + 1 nodes at distance at most d 1 from v 1 , and thus in U . Since the distance between v 1 and v 2 is D ≤ d 1 , v 2 belongs to U . Denote by j 1 its index (between 0 and 2d 1 (d 1 + 1)) in U . According to Procedure Assumption, the value of variable j is incremented at each iteration of the loop at line 6 and takes one after another each integer value between 0 and 2d 1 (d 1 + 1). Consider the iteration when it is equal to j 1 . According to Algorithm Cloudberry, the first node from which a 1 executes Seed and Berry is the node which has index j 1 +0 (mod 2d 1 (d 1 + 1) + 1) = j 1 . This node is v 2 , which proves that there exists an iteration of the loop at line 6 during which the second property is verified too. Let us denote it by I. It is the iteration after the (1 + (l − 1)(2d 1 (d 1 + 1) + 1) + j 1 )-th synchronization RepeatSeed inside Phase d 1 .
In view of Lemma 21, we know that when an agent completes its execution of the i-th synchronization RepeatSeed inside the second and the third part of any execution of Procedure Assumption(d 1 ) (for any positive integer i less than or equal to (d 1 (2d 1 (d 1 + 1) + 1) + 1), the other agent has at least begun the execution of this synchronization RepeatSeed. Thus, when an agent is the first one which starts executing I, it has just finished executing the (1 + (l − 1)(2d 1 (d 1 + 1) + 1) + j 1 )-th synchronization RepeatSeed and the other agent is executing (or finishing executing) the same RepeatSeed. Let us prove that rendezvous occurs before any of the agents starts the next synchronization RepeatSeed.
Let us consider the patterns both agents execute between the beginning of the (1+(l −1)(2d 1 (d 1 + 1) + 1) + j 1 )-th synchronization RepeatSeed, and the beginning of the next one. Agent a 1 executes Pattern RepeatSeed(x, n) with x and n two positive integers (call this pattern p 1 ) and Pattern Cloudberry(x, d 1 , d 1 , j 1 ) from node v 1 while a 2 executes RepeatSeed(x, n) (let us call it p 2 ) and Berry(x, d 1 ) (this is p 3 ) from node v 2 . During its execution of Pattern Cloudberry(x, d 1 , d 1 , j 1 ) from node v 1 , a 1 first follows P (v 1 , v 2 ), and then executes Pattern Seed(x) followed by Pattern Berry(x, d 1 ) both from node v 2 (call them respectively p 4 and p 5 ). Recall that during any execution of Pattern Berry(x, d 1 ) from node v 2 , there are two periods, the second one consisting in backtracking every edge traversal made during the first one. During the first period, in particular, an agent executes a Pattern Seed(x) from every node at distance at most d 1 , among which there are node v 1 and node v 2 . Since backtracking Seed(x) allows to perform exactly the same edge traversals as Seed(x), during the second period of Pattern Berry(x, d 1 ), there is also an execution of Pattern Seed(x) from node v 1 and another from v 2 .
Let us consider two different cases. In the first one, when a 1 starts executing p 4 from v 2 , inside p 3 , a 2 has not yet started following P (v 2 , v 1 ) to go executing Seed(x) from v 1 . In the second one, when a 1 starts executing p 4 from v 2 , a 2 has at least started following P (v 2 , v 1 ) to go executing Seed(x) from v 1 . In the following, we analyse both these cases.
In the first case, consider what a 2 can be executing when a 1 starts executing p 4 from node v 2 after following P (v 1 , v 2 ). First, it can still be executing the synchronization RepeatSeed p 2 from node v 2 . Then, in view of Lemma 10, rendezvous occurs. The only other pattern that a 2 can be executing at this moment is p 3 . However, in this case, we know that a 2 will have finished its execution of p 3 before a 1 starts p 5 , just after p 4 . Otherwise, in view of Lemma 15, rendezvous occurs.
We have just reminded the reader that during any execution of Pattern Berry(x, d 1 ) from v 2 , agent a 2 performs, among the patterns Seed(x) from every node at distance at most d 1 from v 2 , Pattern Seed(x) from v 2 . If it executes one of these Patterns Seed(x) while a 1 is executing its p 4 from node v 2 after following P (v 1 , v 2 ), in view of Lemma 10, rendezvous occurs. This implies that before a 1 finishes following P (v 1 , v 2 ), a 2 has completed each execution of Pattern Seed(x) from v 2 inside its execution of Berry(x, d 1 ).
This means that, each execution of Pattern Seed(x) from node v 2 during the second period of p 3 has already been completed by a 2 when a 1 starts executing its own Seed(x) from v 2 . Since inside the second period of p 3 , a 2 executes Pattern Seed(x) from node v 2 , a 2 has already executed the whole first period of p 3 when a 1 starts executing p 4 from v 2 including Pattern Seed(x) performed from node v 1 , since v 1 is at distance at most d 1 from v 2 . This contradicts the definition of this first case: according to this definition, when a 1 starts executing p 4 from v 2 , inside p 3 , a 2 has not followed P (v 2 , v 1 ) yet, and thus has not executed Seed(x) from v 1 .
In the second case, we prove that rendezvous occurs, which is a contradiction. Recall that in this case, when a 1 starts executing p 4 from v 2 , a 2 has at least started following P (v 2 , v 1 ) to go executing Seed(x) from v 1 . If a 2 has not finished following P (v 2 , v 1 ) when a 1 starts following P (v 1 , v 2 ), then if we denote by t 1 (resp. t 2 ) the time when a 1 (resp. a 2 ) finishes following P (v 1 , v 2 ) (resp. P (v 2 , v 1 )), agents meet by time min(t 1 , t 2 ) since P (v 1 , v 2 ) = P (v 2 , v 1 ). If a 2 has finished following P (v 2 , v 1 ) before a 1 starts executing P (v 1 , v 2 ), then it has started executing Seed(x) from v 1 before a 1 finishes executing p 1 (before it executes Cloudberry(x, d 1 , d 1 , j 1 )), which means in view of Lemma 10 that the agents achieve rendezvous.
So, whatever the execution chosen by the adversary, rendezvous occurs in the worst case by the time any agent completes Assumption(d 1 ), which proves the claim, and by extension the theorem. Proof. In order to prove this theorem, we first need to show the following two claims.

Cost analysis
Claim 25. The cost of each basic pattern inside BD(Assumption(d 1 )) (with d 1 any power of two) is in O(d 30 1 ). To prove this claim, we are going to exhibit the most costly basic pattern which could belong to BD(Assumption(d 1 )) and prove that its cost is in O(d 30 1 ).
From their algorithms, we get the following upper bounds on the costs of our various basic patterns: C(Seed(x)) ∈ O(x 2 ), C(RepeatSeed(x, n)) ∈ O(n×C(Seed(x))), C(Berry(x, y)) ∈ O((x+ y) 5 ), and C(Cloudberry(x, y, z, h)) ∈ O(z 2 × (z + C(Seed(x)) + C(Berry(x, y)))). Remark that the higher the values of their parameters are, the higher the costs of our patterns are (except for the fourth parameter of Cloudberry which does not impact its cost).
Also notice that pattern Seed does not belong to BD(Assumption(d 1 )). It is called when executing the other basic patterns. Moreover, if they are given the same values for their two first parameters, Pattern Cloudberry is more costly than Berry, which makes it a good candidate for being our most costly pattern. But, when called with a second parameter which is the cost of Cloudberry, Pattern RepeatSeed is much more costly than the latter which makes it the most costly pattern inside BD(Assumption(d 1 )). Remark that in our algorithm, the second parameter of Pattern RepeatSeed is the cost of either Berry or Cloudberry. In particular, it cannot be the cost of another RepeatSeed.
In view of Lemma 19, for any power of two d 1 , inside BD(Assumption(d 1 )), the value of the first parameter given to our patterns is at most 32d 4 1 − 6d 1 . In addition, for each basic pattern Berry or Cloudberry inside BD(Assumption(d 1 )), the value given to its second parameter is always d 1 . This gives us upper bounds on the values of the parameters our most costly pattern can be given. Hence, the cost of each pattern we call inside BD(Assumption(d 1 )) is at most C(Repeat-Seed(32d 4 1 −6d 1 , C(Cloudberry(32d 4 1 −6d 1 , d 1 , d 1 , h)))) with h any positive integer. This cost belongs to O(C(RepeatSeed(d 4 1 , d 2 1 (d 1 + (d 4 1 ) 2 + (d 4 1 ) 5 )))) and thus to O((d 4 1 ) 2 d 22 1 ) i.e., to O(d 30 1 ). Claim 26. The cost of Procedure Assumption(d 1 ) (with d 1 any power of two) belongs to O(d 33 1 ). In view of Definition 3 and Remark 4, for any power of two d 1 , the cost of Procedure Assumption(d 1 ) is the same as the sum of the costs of all the basic patterns inside BD(Assumption(d 1 )). In view of Claim 25, we know that for any power of two d 1 , inside BD(Assumption(d 1 )), the cost of each basic pattern is in O(d 30 1 ). Thus, to prove this claim it is enough to show that BD(Assumption(d 1 )) contains a number of basic patterns which is in O(d 3 1 ). For any power of two d 1 , Procedure Assumption(d 1 ) is composed of a call to Harvest(d 1 ) and the nested loops. These loops consist in 2d 1 (2d 1 (d 1 + 1) + 1) calls to basic patterns. Half of them are made to RepeatSeed and the others either to Berry or to Cloudberry. In its turn, Harvest(d 1 ) is composed of two parts: a loop calling Procedure P ushP attern and two basic patterns. For any power of two d 2 , in view of Algorithm 8, and since they are both perfect, the number of basic patterns inside BD(P ushP attern(d 2 , d 1 )) or BD(Assumption(d 2 )) is the same. As a consequence, if d 1 ≥ 2, BD(P ushP attern(1, d 1 )), . . . , BD(P ushP attern( d 1 2 , d 1 )) is composed of as many basic patterns as there are in BD(Assumption(1)), . . . , BD(Assumption( d 1 2 )). For any power of two i, let us denote by L 1 (i) (resp. L 2 (i)) the number of calls to basic patterns inside BD(Assumption(i)) (resp. BD(Harvest(i))). We then have the following equations: L 1 (i) = L 2 (i) + 2i(2i(i + 1) + 1) L 2 (i) = log 2 (i)−1 j=0 (L 1 (2 j )) + 2 They imply the following: (2 log 2 (i)−j · 2 j (2 j (2 j−1 + 1) + 1)) L 2 (i) = 2i + i log 2 (i)

j=1
(2 j (2 j−1 + 1) + 1) (2 2j−1 + 2 j + 1) L 2 (i) = 2i + i(log 2 (i) + 2(i 2 − 1) 3 + 2(i − 1)) Hence, both L 2 (i) and L 1 (i) belong to O(i 3 ). This means that for any power of two d 1 , BD(Assumption(d 1 )) is composed of a number of basic patterns which is in O(d 3 1 ). Hence, in view of Claim 25, the cost of Assumption(d 1 ) indeed belongs to O(d 33 1 ), which proves the claim. Now, it remains to conclude the proof of the theorem. In view of Claim 23, rendezvous is achieved by the end of the execution of Assumption(δ) by any of the agents, where δ is the smallest power of two such that δ ≥ max(D, l ) and l is the index of the first bit which differs in the transformed labels of the agents. Moreover, in view of Claim 26, the cost of each call to Assumption(d 1 ) for some power of two d 1 ≤ δ belongs to O(d 33 1 ). Since log δ i=0 (2 i 33 ) ≤ 2δ 33 , the sum of the costs of these calls to Procedure Assumption and thus the cost of our algorithm until rendezvous is achieved belongs to O(δ 33 ). Moreover, by construction, we have l ≤ 2l + 2. This means that the cost of our algorithm belongs to O((D + l) 33 ).

Conclusion
From Theorems 1, 22 and 24, we obtain the following result concerning the task of approach in the plane. Theorem 27. The task of approach can be solved at cost polynomial in the unknown initial distance ∆ separating the agents and in the length of (the binary representation) of the shortest of their labels.
Throughout the paper, we made no attempt at optimizing the cost. Actually, as the attentive reader will have noticed, our main concern was only to prove the polynomiality. Hence, a natural open problem is to find out the optimal cost to solve the task of approach. This would be all the more important as in turn we could compare this optimal cost with the cost of solving the same task with agents that can position themselves in a global system of coordinates (the almost optimal cost for this case is given in [10]) in order to determine whether the use of such a system (e.g., GPS) is finally relevant to minimize the travelled distance.