4-bit adhesion logic enables universal multicellular interface patterning

Multicellular systems, from bacterial biofilms to human organs, form interfaces (or boundaries) between different cell collectives to spatially organize versatile functions1,2. The evolution of sufficiently descriptive genetic toolkits probably triggered the explosion of complex multicellular life and patterning3,4. Synthetic biology aims to engineer multicellular systems for practical applications and to serve as a build-to-understand methodology for natural systems5–8. However, our ability to engineer multicellular interface patterns2,9 is still very limited, as synthetic cell–cell adhesion toolkits and suitable patterning algorithms are underdeveloped5,7,10–13. Here we introduce a synthetic cell–cell adhesin logic with swarming bacteria and establish the precise engineering, predictive modelling and algorithmic programming of multicellular interface patterns. We demonstrate interface generation through a swarming adhesion mechanism, quantitative control over interface geometry and adhesion-mediated analogues of developmental organizers and morphogen fields. Using tiling and four-colour-mapping concepts, we identify algorithms for creating universal target patterns. This synthetic 4-bit adhesion logic advances practical applications such as human-readable molecular diagnostics, spatial fluid control on biological surfaces and programmable self-growing materials5–8,14. Notably, a minimal set of just four adhesins represents 4 bits of information that suffice to program universal tessellation patterns, implying a low critical threshold for the evolution and engineering of complex multicellular systems3,5.

1 Text S1: Modeling and Simulations

Minimal continuum model
We introduce a minimal continuum model that captures the following key physical e ects. (1) The local bacterial density increases over time due to growth, and where the growth rate is limited by a carrying capacity. (2) The edge of the swarm grows and expands into regions that have not yet been colonized via chemotaxis [2,3]. (3) When cells with complementary adhesin pairs interact, they form non-motile clusters and do not subsequently contribute to the dynamics.
(4) The simulations are restricted to 2D as the primary mode of E. coli migration is parallel to the planar surface of the gel.
To construct such a model for two species, we track the fields, ⇢ 1 , ⇢ 2 , representing the number density of unbound cells, as well as the field ⇢ 12 , representing the density of bound clusters. As the cells are primarily confined to a thin layer on the surface, we take two dimensional density fields, representing the number of cells per unit area. Motile cells perform chemotaxis and move in a direction determined by the gradient of the nutrient concentration, and to fully capture these chemotactic dynamics, additional equations for the concentration field are needed [2]. However, to construct a minimal model of the expansion, we only use di usion and growth terms, resulting in a Fisher-Kolmogorov like equation which admits propagating fronts [4]. The di usion term results in a net mass flux from high density to low density regions, whilst the growth term models cells growing exponentially at a rate determined by the nutrient concentration, which we approximate as an instantaneous function of the total cell density. Finally, cells with complementary adhesin pairs bind with an e ective rate K and are subsequently immobile. Altogether, where g 1 , and g 2 are growth rate constants, D 1 , D 2 are di usion constants, ⇢ max is the carrying capacity for total growth, ⇢ is the total cell density, ⇢ 1 and ⇢ 2 are the densities of the two mobile cell populations, ⇢ 12 is the density of immobile cells,K = K/⇢ max , and c is our approximation of the instantaneous nutrient field concentration, allowing for logistic growth until⇢ = ⇢ max .

Quantitative model parameter fitting from experiments
We determine these parameters directly from experimental data. Based on our confocal data (Figs. 3a, c, S16), the maximum density achieved during the experiments is ⇢ max = 0.155 ± 0.012cells/µm 2 , which we note is far from spacefilling. We also measure that colonies expand at a rate of v = 3.04 ± 0.40mm/h (Fig. S14b). Further experiments find that in the absence of interactions (K = 0), the width of the interface between the two colonies is b K=0 = 1.29 ± 0.02mm, and with maximally expressed complementary adhesin pairs the interface width is around b K=max = 0.50 ± 0.01mm (Fig.   S11). To calibrate physical parameters, we note that the Fisher-Kolmogorov equations admit fronts that propagate at speed v = 2 p Dg [4], which in our model would be the expansion speed of an isolated colony. We therefore ensure that the parameters g, D satisfy 2 p Dg = 3.04 ± 0.40mm/h. To calibrate the interface measurements, we performed simulations with initial seeding diameters of d = 1.5mm and separation L = 5mm, running simulations until 65min had elapsed and the interface has formed either with or without interactions, and with identical parameters in both colonies (g = g 1 = g 2 ,

b c a
. From this, the interface width was measured as the distance between the points where the total amount of species 1, ⇢ 1 + 1 2 ⇢ 12 , is equal to 10% of the bulk value ⇢ max , and the equivalent point for species 2. A clear length scale is apparent for the interface width, so other definitions of width will also find a similar value. Simulating without interactions (K = 0), for various values of g, D, with v = 2 p gD fixed, we find the values g = 14/h, and D = 47µm 2 /s ensure that the interface is of width 1.29mm (Fig. S1). To gain uncertainty bounds, we re-calibrated with the extreme ranges of the measured physical parameters, namely with b K=max = 1.27mm, v = 3.44mm/h and with b K=max = 1.31mm, v = 2.64mm/h, finding that g = 14 ± 6/h, and D = 47 ± 8µm 2 /s (Fig. S1). Whilst our e ective di usion coe cient agrees with the di usion coe cient of cells in soft agar (D = 41.5µm 2 /s [2]), the e ective growth rate is an order of magnitude higher than the experimental measurements (growth rate a = 0.244 ± 0.053h 1 , which we now distinguish from our e ective growth rate g). This is due to our minimal model not explicitly modeling chemotaxis-driven expansion. We must therefore have a larger growth rate to achieve the same expansion speed. However, even with these e ective parameters, we can accurately predict experimental patterns, Fig. 2.
Next, by including interactions and requiring the interface width to be w = 0.50 ± 0.01mm, we determine that after formation the subsequent evolution is slow. All simulations were performed using the pseudo-spectral PDE solver Dedalus [5].
In order to simulate two strains which have di erent expansion speeds, we give each strain its own di usion coe cient (D 1 6 = D 2 ). By giving each species a di erent di usion coe cient D i , each species will have an expansion speed of v i = 2 p D i g. Therefore, to simulate a strain with half the normal expansion speed, we use a di usion coe cient D i = 0.25 ⇥ 47µm 2 /s.
The typical interface length scale depends on the di usion constant D, the e ective growth rate g, and the cell adhesion length K. When K = 0, dimensional analysis finds that the length scale as L ⇠ p D/g, whereas in the limit of K g, dimensional analysis would suggest L ⇠ p D/K. From our fitted values of K and g, these two regimes suggest that the length scale of the adhesin free interface would be a factor of p K/g ⇠ 2.7, larger than the interface with adhesin, indeed experimentally they di er by a factor of around 2.1.
The cell adhesion rate K can also be estimated as follows. The maximum cell density is ⇢ max = 0.155±0.012cells/µm 2 ., so if cells are present at density ⇢ max , the characteristic separation length scale between cells is 1/ p ⇢ max ⇡ 3µm. The typical velocity of cells is around 10µm s, hence the characteristic time scale for collision will be around 0.3s. Since adhesion occurs after collision, this gives a cell adhesion rate of 3/s, or 10, 000/h. This is a factor of 80 higher than the previously fitted value of K = 130/h. This discrepancy occurs as our scaling argument does not account for the fact that not every collision results in a binding, and that once many cells become bound, it may take significantly longer for any two unbound cells to find each other and collide.
We conclude that the parameters in our model show reasonable consistency with published data as well other theoretical models [2,6] (see also discussion in supplementary text S1.7).

Delayed swarm expansion
To simulate unequal seeding ratios, we note that experimentally, cells initially grow with no motility until a critical cell concentration is reached. Diluting the cells experimentally by, say a factor of two, would require the passage of one doubling time to reach the critical cell concentration to initiate swarming. Therefore if one colony starts with N cells, and the other with 2 k N cells, the first colony will begin expanding, whilst the second will not until t = k⌧ double , where ⌧ double is the experimentally measured doubling time, before the cells are motile. In simulations, we therefore allow the first colony to expand starting at t = 0, but only allow the second colony to expand starting at t = k⌧ double , after which the system evolves according to Eq. S1, with results shown in Fig. 2i, with ⌧ double = 14.4min (the doubling rate for Ag2, see section 4.6, which is the strain being diluted).
This captures the experimental behavior of the interface angle as the Ag2 cells are diluted, Fig. 2i, however there is a slight systematic disagreement between theory and experiment. This can be removed by taking into account two additional experimental factors; without dilution Ag2 begins expanding around 10 minutes before Nb2, and that once expanding, Nb2 is slightly faster than Ag2 (0.0506 mm/min vs 0.0491 mm/min, see section 4.6). Recalibrating the e ective growth rates using these di erent speeds, and delaying the expansion of Nb2 by 10 minutes removes the systematic disagreement, Fig S2. However, in the main text and elsewhere in the supplementary, to make a minimal model we use the same parameters for Ag2 as for Nb2, (g 1 = g 2 , D 1 = D 2 in Eq. (S1)), and we calibrate the expansion velocity to that of Nb2.
We see from comparing Fig. 2i and Fig. S2, that this will only result in a minor adjustment to the model output.
1.4 Accounting for systematic shifts in interface angle simulations with differential growth and speed

Experiment Model
Interface angle α (degrees) Cell seeding ra�os Figure S2: In our minimal model, we simplified the bacterial growth and expansion dynamics by assuming all strains divide and swarm at the same rate. While this is su ciently accurate in most cases, we noticed a systematic downward shift when tuning the interface angle between swarms in the models (see Fig. 2i). However, experimental measurements suggest a possible di erence in growth and expansion rates between strains (Figs. S14, S13). A more accurate model can be achieved by allowing di erential growth and expansion rates in the simulation, and applying the experimentally measure values for the relevant strains (Ag2, Nb2) (see Fig S14 for the values). Here, we note that swarming initiates in the 2-3 hour range, and assume a lag phase duration of 1 hour. Applying these adjustments results in a systematic shift upwards and better alignment with experimental measurements. However, for the sake of consistency throughout the paper, in the main text ( Fig. 2i) we retain the simplified model.

Adhesin inhibitor
We model the e ect of the adhesin inhibitor as acting on the binding rate through K = K(I), where I is the concentration of the inhibitor. We assume first order Hill-type interaction based on the inhibitor concentration, the half-max inhibitor concentration I 1/2 and the maximal adhesion K max = 130/h, However, to calibrate simulations with the inhibitor to the results in Fig. 2d, we note that whilst the interface width for no peptides added at all is b K=max = 0.50mm, the data with low inhibitor concentration only approaches b K=max = 0.7mm.
This discrepancy is due to the fact that for the inhibitor experiment, small peptides were added to the media. It is generally known that changes in media conditions can a ect growth rates of bacteria [3,7], and hence these two values do not match perfectly. Specifically, in these inhibitor experiments a mixture of specific and unspecific inhibitor peptide was added in order to keep total amount of peptide constant and maintain consistency across inhibitor concentrations. Therefore, for Fig. 2d, we first calibrate using b K=max = 0.7mm and b K=0 = 1.5mm, finding that K = 70/h, D = 67µm 2 /s, g = 9/h, which we use only for Fig. 2d, and note that these are of consistent magnitude with the previously found parameters.
With these new parameters, we find that I 1/2 = 5 ⇥ 10 6 M, when fitting to the experimental data in Fig. 2d.

Multi-species extension
Our framework readily extends to multiple adhesion pairs. For instance, if species 1 and 2 formed an adhesion pair as did 3 and 4, then the density fields would evolve as where now the strength of adhesion,K 1 ,K 2 could vary across di erent adhesin pairs. To represent a mixture of, for instance, species 1 and 3, we seed both 1 and 3 in the same location, each at density ⇢ 1 = ⇢ 3 = 0.5⇢ max , so that locallȳ ⇢ = ⇢ max , and they will remain mixed as the simulation evolves. An example with 3 species, where species 1 and 2 form an adhesin pair, and species 3 does not interact with either, and initial seeding conditions mix species 2 and 3, as experimentally realized in Fig. 3, is shown in Fig. S3. This can be similarly extended to 3 adhesin pairs, as was done in section 4.20.  Figure S3: Simulated interface between three species, reproducing the experimental results in Fig. 3b. Species 1 (red) and 2 (yellow) form an adhesin pair, whilst species 3 (blue) does not interact with either of them. Species 1 was initially seeded to the left, whilst a mixture of species 2 and 3 was seeded to the right, and the separation between seeding sites was 5mm. The simulation was run until 65min had elapsed.

Comparison to other models
Mathematical models describing the expansion of bacterial populations have been widely used [8][9][10], including the Fisher-Kolmogorov equation [2,4]. Whilst Fisher-Kolmogorov dynamics are su cient to describe fronts propagating at a fixed velocity, additional terms are required to model branching instabilities [8,9], or exponential growth [10]. Cremer et al. [2] proposed a model with additional nutrient and attractant fields, which match experiments both in expansion dynamics and density profile. They also compared against Fisher-Kolmogorov dynamics, finding that the expansion dynamics broadly agree for times less than 5h [2], which describes the relevant regime for the experiments analyzed here. Whilst the Fisher-Kolmogorov equation leads to a less realistic profile of a freely expanding front than a model with nutrient and attractant fields [2], we find that, together with the adhesion terms, our model does reproduce well the stationary interface between two colonies, Fig. 2. Therefore, to find a minimal model which reproduces the expansion and interaction behavior seen in experiments, we use a simple Fisher-Kolmogorov type dynamics with adhesion term, and do not explicitly model the nutrient or attractant fields as it is beyond the scope of the current work.
In the next subsection we provide an example for such a model extension. Kymograph of the simulation using the horizonal line drawn through the centers of the two initial colonies. We can see that the first expansion wave begins at t = 0 min, whereas the second starts at t = 100 min. Both have similar slopes indicating expansion occurs at the same speed for each wave. An initial interface begins to form at around t = 130 min, but the full interface does not form until around t = 230 min, when the second chemotactic wave reaches the interface.
Scale bar is 5mm.
While the model in Eq. (S1) represents a minimal model that quantitatively reproduces many aspects of the experiments, it does not capture all behavior. In particular, the growth of colonies is experimentally observed to occur through multiple chemotactic waves (Video S1), whereas the minimal model assumes that this growth occurred through a single expansion wave. These waves occur as a result of cells specializing to consume a specific nutrient, with these specialized cells di ering in their growth rate, resulting in multiple waves as some cells start expanding before others [11,12].
Other theoretical models of expansion also have focused on the case of a single expansion wave [2,10], however it is straightforward to extend our model to the case of multiple waves.
To include this behavior into our model, we consider the case of two di erent chemoattractants, u and v, giving rise to di erent cell subpopulations, ⇢ u i and ⇢ v i , which begin swarming at di erent times. Once expansion starts, the velocity does not di er significantly between waves, so we assume the same e ective growth rates g, and di usion constant D for both subpopulations. As these subpopulations consume di erent nutrients, the maximum density of each subpopulation di ers and is given by ⇢ u max and ⇢ v max , which combine to give the total measured maximum density, ⇢ max . In total, the model in Eq. (S1) becomes, We simulate this model with ⇢ u max = 0.25 ⇥ ⇢ max , ⇢ v max = 0.75 ⇥ ⇢ max and t c = 40min, to approximately match to experimental observations. We set D,K, and g to be the same as the previously calibrated parameters, which were calibrated to the second and largest expansion wave. As the expansion speeds are comparable, the initial wave and the main wave will end up forming an interface in the same place ( Fig. S4, Video S6). As the final interface pattern is una ected by the presence of the first wave, elsewhere we use the model of Eq. (S1), which provides a minimal model of the dynamics.
1.9 Analytical model of interface angles with differential growth and expansion To gain intuition into the determinants of interface geometry, we developed a simple analytical model of our experimental platform. The shape of the interfaces between two expanding colonies can be modeled by starting at each seed, drawing successively larger circles, and defining the interfaces at the points the circles intersect.
To arrive at an analytical model, we begin with the general form for the equation of a circle: Now, consider two strains seeded in the Cartesian plane, with strain 1 seeded at the origin, and strain 2 seeded at , where x p is the seeding distance between the two strains. Now, the following pair of equations describes the circles drawn by the two strains: Where the subscripts indicate strains 1 and 2.
At any point in time, we know the radii of the circles given the time elapsed (t) and the expansion speed (k). We can also account for the delay in initiation of swarming by introducing a delay term ⌧ . Altogether: However, we can further simplify this by assuming strain 2 has a longer delay than swarm 1, defining ⌧ = ⌧ 2 ⌧ 1 , and restricting the model to t > ⌧ 1 . For simplicity, we restrict the model to t ⌧ 1 , and with some abuse of notation we arrive at the following: Finally, we note that the interface is defined by the points where x 1 = x 2 = x and y 1 = y 2 = y. After substituting and solving for x and y, we find the interface shape is described analytically with the following set of parametric equations Where k 1 and k 2 are the expansion speeds of the strains, ⌧ is the delay before initiating expansion for the two strains, and x p is the initial seeding distance between the strains which are seeded along the y = 0 axis. Measurements of the expansion rates between our Ag2, Nb2, Ag3, Nb3 and null lines show all strains expand at similar rate of 0.0506 ± 0.0067 mm/min, with a doubling time of 14.6 ± 3.2 min (see supplementary text S4.6). x p was experimentally fixed at 9 mm.
The analytical solution for cells growing at the same rate k 1 = k 2 is a straight line perpendicular to the axis defined by the two seeding points (Fig. S5A). However, introducing a delay ⌧ > 0 into the initial timepoint of cell expansion causes this line to deviate from perpendicular at some angle ( Fig. S5a) that linearly scales with the delay time (Fig. S5b). See also the experimentally and phase-field model derived relationship shown in Fig. 2f,i.
Varying the expansion rates (k 1 6 = k 2 ) results in the faster growing colony engulfing the slower colony (Fig. S5c) in a circular interface geometry. The greater the expansion rate di erence, the smaller the radius of the engulfed region ( Fig.   S5d). See also experimental and phase-field models in Fig. 2g.
2 Text S2: Mathematical and Algorithmic Aspects of Interface Pattern

Formation
In this section we first provide some general background on related tiling, tessellation and map coloring problems. We then classify some mathematical problems that are motivated by our observations and results, and which ultimately allow us to systematically prove that four adhesins are sufficient from a mathematical point of view to generate any arbitrary interface pattern. Finally, we discuss solutions to more specific patterning cases with certain constraints. This section also motivates open questions for future mathematical research.

Tiling, tessellation and map-coloring problems; definitions
Geometric tiling, tessellation, map coloring, and related problems have a long history; see for example [13][14][15][16][17][18]. Here we briefly review a few concepts of special interest for the present work.
The primary literature (as well as other informal resources) often use the terms 'tiling' and 'tessellation' interchangeably, and when definitions are provided they are not necessarily consistent. We find the following concepts appropriate: We define map in the following context as a space filling division of the plane.
A tiling starts with a countable set of geometric elements and one then aims to completely fill a space with those elements without gaps or overlaps. A formal definition is provided by [17]: "A plane tiling is a countable family of closed sets T = {T 1 , T 2 , ...} which cover the plane without gaps or overlaps." Hence the classic tiling problems raise the question whether and how specific tile geometries (one or multiple tile types) can completely fill a space, and whether specific complete or partial symmetries emerge in this larger pattern [17] (Fig. S6a). Reference [17] provides a detailed overview of the field, and [18] provides a more recent perspective and update.
A tessellation starts with a number of seeding positions distributed in space from which (according to certain rules) interfaces between seeding positions are constructed that ultimately lead to a space-filling division of this space into compartments. An example of a formal definition of the Voronoi tessellation is provided by [19]: "The Voronoi diagram (also commonly referred to as Dirichlet tesselation, or Thiessen polygon) of a set S of n points is a PSLG [planar straight- Figure S6: Examples tiling, tessellation, and map coloring.
line graph] with n cells, where each cell belongs to one point from S and consists of all points in the plane that are closer to that point than to any other in S." Generalizations exist, e.g., the lines may be defined by some other metric instead of the closest point, and those lines also do not have to be straight -using bacteria with di erent growth rates as demonstrated in the main paper in Fig. 2g provides an illustrative example. Here the term 'line' is synonymous with the term 'interface' in the main paper. The inverse Voronoi problem seeks to determine the position of these points S given a PSLG -but this is not possible for every PSLG. However, it can be shown that the interfaces of any given pattern are the subset of some other Voronoi tessellation pattern [20]. This implies that if enough originating points are used and if some interfaces can be hidden afterwards, any pattern of interfaces can be generated that way. Finding the positions of the set S in this case is also termed the 'Generalized Inverse Voronoi Problem (GIVP)' [21][22][23].
Note that the concepts of tiling and tessellation have significant overlap. For example, a tessellation problem on a regular grid (or at least where the grid points have certain generative properties) will lead to a corresponding tiling problem, but not every tessellation corresponds to a tiling. Similarly, a tiling problem where every tile can be generated through a tessellation process corresponds to tessellation problem, but not every tiling corresponds to a tessellation.
The four-color map theorem states that only four di erent colors (or attributes) are required to ensure that no adjacent tiles of any map in the 2D plane have the same color [14,15,24] (Fig. S6c). (see text).

Classes of interface patterning problems and their general solutions
In the following we now introduce a classification of possible interface patterns with increasing complexity. This classification is motivated by the di erent algorithms discussed in the paper that systematically generate patterns of increasing complexity. The logic and mathematical problems presented here could of course be implemented by various physical means other than adhesive bacteria, and they therefore would apply much more general to other systems. For simplicity, we use language as if all interface patterns are generated through bacteria that swarm out from various point sources ('organizers') across a plane. Wherever now any two such bacterial strains meet they may or may not form a distinct and visible interface based on pairwise adhesive properties of these strains. Furthermore, they stop each other from moving beyond this interface. This motivates several questions. What type of interface patterns can be generated in general? What types of and how many adhesins are required? At what positions do they need to be placed in order to generate a desired pattern? We do not consider any experimental limitations due the non-finite size of seeding position, or the precision and accuracy associated with any liquid handling device; and hence we assume that the diameter of any seeding position and the width of any interface are su ciently small compared to feature sizes of the desired pattern.
Overall, this also represents a new class of problems that is distinct from the classic tiling and tessellation problems (see above), as it adds the question of whether any particular interface is generated or not (i.e., 'visible' vs. 'hidden'), where interfaces also can have open ends (Fig. 4d). Hence this problem is not only about generating a map of tiles, but also about generating a pattern (or 'graph' or 'network') of interfaces.
We can classify the desired patterning problems in four levels of increasing complexity (Fig. S7), which are primarily chosen as the key steps to prove that four adhesins (i.e., two adhesin pairs) are su cient to generate any arbitrary interface pattern. Other classifications and more specific scenarios are also possible.

Voronoi tessellation; interface pattern without open interfaces
Problem: Given is a desired 2D tiling in the plane with 'interfaces' (boundaries) being present between any two adjacent tiles, where this tiling corresponds to a Voronoi tessellation, i.e., the seeding positions ('organizers') are predetermined at the proper location, and all bacterial strains have identical growth and movement properties (Fig. S7a). What adhesin combinations are required at each seeding position, and how many adhesins are required in total, in order to generate this pattern?
Solution: The solution is detailed and solved in the main paper (Fig. 4b) and corresponding text. The solution essentially rests on utilizing the four-color map theorem.

Arbitrary interface positioning; but no interface with open interfaces
Problem: As before, but now the seeding positions have not yet been identified, and the desired pattern is not necessarily a Voronoi tessellation, but both ends of each interface still end at another interface (Fig. S7b). Where should organizers be placed, what adhesin combinations are required at each organizer, and how many adhesins are required in total, in order to generate this pattern?
Solution: A complete mathematical solution is provided in the main paper (Fig. 4c)  Solution: One needs to introduce hidden interfaces (see Fig. 4c, d). Di erent algorithms are possible, for example: (1) An algorithm as detailed in the paper: Using the four doublet strains (Fig. 3d) together with a null strain while minimizing hidden interfaces, and where then also the Generalized Inverse Voronoi Problem needs to be solved.
(2) A (semi-trivial) algorithm can be achieved with a single adhesin pair and just three strains (two with one adhesins each and a third with the null element), and where on each side of each interface one of two complementary adhesins are placed. Then a large number of 'hidden triangles' is added at any place where an undesired interface would form. This algorithm has the potential downside of requiring in general a larger number of seeding positions. (Note that a completely trivial extension of this algorithm is to just 'draw' lines with either adhesin on both sides of any desired interface, and which is then further sandwiched by two lines with the null strain. In this case there is no emergent patterning process happening, instead the desired interface pattern is essentially already drawn 1:1.)

Most general case
Problem: As in previous problem, but now we also allow for all sorts of extensions. For example, we now allow curved interfaces, or other more complex features (Fig. S7d). Question as in previous problem, but now extended to various other dynamic and biophysical properties that can be associated with these adhesins and thereby a ect the positioning and geometry of these interfaces. Further extensions are represented by environmentally dependent logic, as illustrated in figure 4g.

Solution:
The paper provides an illustration for one specific pattern in figure 4f. The accompanying continuum model ( Fig. 2b) allows for quantitative exploration of pattern spaces prior to experimental implementation.
Here an iterative algorithm could be implemented that guesses a first seeding position, models the outcome, determines how close the match is (based on a user-chosen metric), and then updates the seed. The solution is not unique, and with su ciently many seeding positions an arbitrary shape can be approximated arbitrarily well. Constraints would also have to be decided upfront, e.g., whether the number of seeding positions should be minimized, or within what resolution and error the achieved pattern should match with the desired one.
A deeper analysis and classification is beyond the present work. But in the following subsection we also provide solutions to some more specific cases that all fall under problem 3 (or even problem 2).

Regular periodic tilings with seeding positions at circumcenters, all interfaces visible
For square and triangular tillings one adhesin pair is su cient, for hexagonal tilings two adhesin pairs are required as illustrated in figures 4a and Fig. S26. A hexagonal tiling cannot be achieved with one adhesin pair as three tiles border each other in a pairwise manner, and as neighboring tiles need to have di erent adhesins in order to form an interface.
In general, multiple seeding configurations can lead to the same interface pattern, as illustrated with a hexagonal tiling which can be achieved with both three or four of the adhesin doublets (Fig. S8a).
1-D chain of square tiles with seeding positions predefined at circumcenters, hidden interfaces possible If tiles form a 1D chain (either being infinite or bounded on each side), a single adhesin pair is su cient to generate any desired interface pattern by linearly going through the tiles -always adding the complementary or the same adhesin to the next tile, depending on whether an interface is or is not desired between adjacent tiles, respectively (Fig. S8b). Note that for a 1-D chain with periodic boundary conditions (i.e., the last tile on one end directly connecting to the first tile on the other end forming a closed loop) one adhesin pair is generally not su cient, as the last interface to be generated cannot be chosen freely, but instead is automatically determined (Fig. S8c, red arrow indicating the inconsistency). Even including the null element as a third strain cannot always resolve this issue, although in some scenarios it can.
Minimally required number of adhesin pairs for regular 2D tilings, seeding positions predefined at circum-

centers, hidden interfaces possible
In general, at least two adhesin pairs are required to generate every possible interface pattern for any 2D tiling, as one can easily construct a 'closed loop' with one inconsistent interface (similar to the closed 1-D chains shown in figure S8c with the red arrows marking the inconsistencies). Should no closed loop exist at all -then this in not truly a 2D tiling, instead it is a quasi 1D tiling without periodic boundary conditions.
In the case of triangular lattices, we found an algorithm that requires only two adhesin pairs (Fig. S8d, Fig. 4e  triangles that point their tip downwards. If an interface above that triangle is desired, then add the complementary adhesin to this triangle in regards to the adhesin already being in the triangle above. As the last step does not influence interface formation within any row, every desired pattern can be achieved with this algorithm. Note that this algorithm uses up to eight di erent strain mixtures (the four single adhesin strains, and the four pairwise adhesin strains). Note also that finding a solution to a desired pattern scales linearly with the number of tiles. (The pattern shown in Fig. 4e is surrounded by the null elements for convenience, but the null element is not necessary, i.e., based on the above algorithm the same could be achieved with the adhesive strains alone. The pattern shown in Fig. 1d-f could have also been established with the algorithm described here, but instead was determined by trial and error while making use of multiple symmetries not present in the general case; therefore it has a di erent seeding structure and which again emphasizes that In the case of square lattice we found an algorithm with a similar idea that requires only three adhesin pairs (as illustrated in Fig. S8e). We consider rows modulo 3, each of which is patterned horizontally (i.e., selecting for the vertical interfaces) using pair 1, 2, and 3 respectively. The horizontal interfaces are then filled in by going along each row and alternating between adding the complementary adhesin to what is in the row above or in the row below -in case any particular interface should be formed. We did not identify an algorithm that requires only two adhesin pairs, and we conjecture that none exists.
In the case of the hexagonal lattice we found an algorithm using six adhesin pairs: Each of the three main directions is solved with two di erent adhesin pairs with the 1-D chain approach (Fig. S8c). Along any direction, the odd rows are solved with the first of the two adhesins, the even rows with the second adhesins. This leads to using three di erent adhesins per hexagon, and three adhesin pairs in total. Potentially other algorithms exist that require fewer adhesins.
Note that for an infinite lattice, one can always start at an arbitrary tile, and then pursue these algorithms into all directions independently.
In conclusion, for the regular triangular tiling this proves that two adhesins are necessary as well as su cient to generate any arbitrary interface patterns, i.e., where every interface can be selected to be visible or hidden. For the square and hexagonal tiling we now identified a lower vs. an upper bound, i.e., two vs. three and two vs. six adhesin pairs, respectively. We have not yet identified algorithms in these cases that would have a lower upper bound on required adhesin numbers; the reader is invited to search for those. Note that it is the restriction of seeding point positions that ultimately prevents using the GIVP and four-color map approach to directly restrict the number of required adhesins to four.
Regular 4xN rectangular or triangular lattice, seeding positions predefined at circumcenters, hidden interfaces possible For a 4xN square lattice, it is possible to form any pattern using only two adhesin pairs. This lattice is interesting as it corresponds to the commonly used 7-segment digital display, and as adding additional triangles in the two middle rows a 16-segment display can be generated (Fig. 4h). These problems can then be solved with just two adhesin pairs, as they are dealing essentially with two 1D chains of tiles, where each chain can be solved with one adhesin pair, and where the lines between the rows can be forced by adding additional adhesins of the opposite type in rows above and below. Note that this algorithm may require all nine possible strain combinations (Fig. 3d). For more rows this algorithm does not work in general.
Patterning complexity vs. number of available adhesins; regular tilings and hidden interfaces possible As we saw, if the number of adhesin pairs is limited, not all possible interface patterns can be generated. But this raises the question: "Given a set of seeding positions and a specific number of adhesin pairs, what fraction of all interfaces can certainly be instructed to be either visible or hidden (while the remaining interfaces cannot be forced)?" (Note that this provides one way of quantifying the overall patterning complexity, but there are certainly other ways of doing so.) For example, in the case of the 1-D chain consisting of N tiles and which has periodic boundary conditions (Fig.   S8c, d), only one of these interfaces cannot be determined at will, which implies that as N goes to infinity, the fraction of properly determined interfaces approaches 1.
In the case of the triangular lattice that fraction is at least 5/6 for one adhesion pair, which can be seen as follows: Moving along any given horizontal row all interfaces in that row can be determined as described above, which is 2/3 of all interfaces. The row below is then determined again the same way, again fixing 2/3 of these interfaces correctly. But at the same time, the remaining 1/3 of the interfaces between these two rows are now determined at random. In case at least half of these interfaces are determined as desired, one continues with the next row the same way. In case less than half of interfaces between both rows are correct, then one just swaps in the lower row the two adhesin from that pair, which will have no a ect for any interface within that row while all interfaces between rows will now swap, i.e., hidden interfaces become visible and visible ones become hidden. This has the e ect that whatever the fraction of correctly determined interfaces between rows was before, it is now 1 minus that fraction. Hence at least half of all interfaces between any two rows can be forced as desired. In conclusion, that leads to 5/6 = 2/3 + 1/2 ⇤ 1/3 of all interfaces can be determined.
Similar strategies lead to 3/4 and 2/3 of all interfaces for one adhesion pair for the square and hexagonal lattice, respectively. The reader is invited to check.
We do not know whether algorithms exist that can do better than this for one adhesin pair, and we do not know what the corresponding limits for square and hexagonal lattice are if more than one adhesin pair can be used (see also Fig. S8f for a summary for best performing algorithms identified so far). We conjecture that for square lattice and two adhesin pairs an algorithm exist that allows one to fix at least 7/8 of all interfaces. The reader is invited to identify algorithms that perform better.

How many bits are truly utilized in the demonstrated adhesion logic?
As illustrated in Fig. 3d and associated text, utilizing any of the four di erent adhesins provides in principle 16 possible combinations, which corresponds to log 2 (16) = 4 bit of information, i.e., '4-bit adhesion logic'. In practice, not all combinations are possible due to self-interaction among the complementary adhesion pairs. Specifically, out of the 2 4 = 16 combinations, 7 have to be excluded (the quadruplet, all triplets, and the two doublets consisting of complementary adhesins) due to self-interaction, which leaves 9 possible combinations corresponding to log 2 (9) = 3.16 bits. We also showed that general interface patterns with open ends can already be achieved with just the four doublets and the null, leading to log 2 (5) = 2.32 bits. Patterns without open ends can be achieved with just the four doublets, leading to log 2 (4) = 2 bits. Future natural or synthetic adhesin systems may potentially utilize these self-interactions in interesting ways for spatial patterning and would thereby utilize all four bits.
Adhesion logic with more than 4 adhesins Using more than 4 adhesins (4-bit strategy) is possible in principle (see simulations in Fig. S28), which leads to tangible benefits and also potential limitations. Benefits include the need for fewer seeding positions, and it was also explicitly shown that certain patterns on a square lattice with prefixed seeding positions are achievable with six adhesins but not with four (Fig. S8e, f).
Practical (experimental) limitations include the challenge that with increasing number of strains on a given seeding position the strength of the individual adhesive interactions is diluted and the formed interfaces are potentially weakened, e.g., when seeding 3 di erent adhesins at the same position instead of just 2. But note that such limitations could be avoided, for example, when using a 6 bit adhesin code for the overall pattern while still never using more than two adhesins per seeding positions (Fig. S8e).

Text S3: Practical Considerations for Applying Adhesin Logic as a Biosensor
The application of living cells as whole-cell biosensors is attractive due to the potential for low-cost, portability and robustness [25,26]. However, there are still very few examples of commercially implemented whole-cell biosensors [26], highlighting the relative novelty of this approach and the corresponding challenges. Here we discuss some considerations for applying soft agar based adhesin logic as a whole-cell biosensor.
Time to result: The time it takes for the interface readout can be estimated with the following equation: Where T is the time to result, ⌧ 0 is the delay for the onset of swarming, d is the seeding distance, and v is the average speed of the two swarms.
The distance d can easily be tuned by designing the seeding positions to be closer or further apart. However, we have found that with a standard pipette and 0.5-1µl volumes, 1.5mm is the minimum practical seeding distance due to the finite size of the droplet and non-motile expansion of the initial seeds at early time-points. ⌧ 0 can be tuned by adjusting the seeding density, as well as the storage conditions of the inoculate. Both ⌧ 0 and v can be tuned by adjusting the temperature of the assay. Experimentally, we found that ⌧ 0 requires approximately 2 hours for the bacteria to go through lag phase and a few cell divisions when inoculated from saturated overnight cultures.
Stability and storage: Standard 1.5% agar plates with antibiotics can be stored sealed at 4°C for up to a month.
We expect similar performance for soft agar. However, soft agar is succeptible to moisture loss, and is significantly more mechanically fragile than standard 1.5% agar plates. Rough handling, and prolonged storage at an angle could disrupt the mechanical integrity of the gel. However soft agar gels are very easy to make from powder, which has a long shelf life at room temperature. While autoclaving is the preferred method, we have found that microwaving the suspended powder in water produces a gel that is comparable to the autoclaved product.
Susceptibility to variance in environmental conditions: The assay is relatively robust to environmental conditions. The most important environmental variables for the soft agar assay are humidity and temperature. For humidity, it is su cient to keep the assay locally humidified. For example, standard petri dish with the lid on inside of a unhumidified incubator is su cient. However, it is also important that the cells have access to oxygen, so the assay cannot be airtight.
For temperature, we have found that 37°C works well, although we noticed certain strains form stronger interfaces at room temperature. On the other end of the spectrum, temperatures exceeding 37°C results in unpredictable selfclumping behavior even in the absence of adhesins. Regardless, the assay is ideally designed for and run at some optimal temperature, as relative growth and migration dynamics between strains can be di erentially impacted by temperature fluctuations.
Susceptibility to colony-to-colony variation: With consistent protocols in storing and inoculating cultures, colony-to-colony variations do not have a significant impact on the assays. However, consistent protocols may not be possible in an application setting. In general, while the formation of visible interfaces is robust to changes in conditions, the location and curvature of the interface can be strongly a ected. For this reason, complex patterns may be undesirable in applications where culturing conditions cannot be well controlled.
Susceptibility to variance in metabolic load: The bacterial strains reported here had roughly comparable growth and migration rates. However, this may not always be the case, especially when designing more complex circuits with heavier metabolic loads. In these cases, computational tools could potentially be used to predict and aid design of gene circuits [27]. If these approaches fail, computational simulations like those presented here could be utilized to rapidly iterate over seeding designs in order to accommodate di erences between strains.
Persistence of pattern: The interfaces shown in the paper are stable long-term. Stored at 4°C, the patterns have remain clear for several months, with the largest risk coming from water droplets formed by condensation. At room temperature or 37°C, the plates eventually dry out. The patterns usually remain visible on dried out plates, especially after gently rinsing with water.
Susceptibility to variance in agar preparation: We have observed pattern formation with a wide range of agar percentages (0.15-0.35%) [12]. At percentages below 0.2% however, the agar falls apart easily. At percentages above 0.35%, the cells tend to not swarm. Furthermore, the pattern formation seems robust to small variations in LB concentration [28].
Assay sensitivity and specificity: The specificity of the assay is dependent on the nanobody portion of the adhesin.
Nanobodies themselves can be highly specific and nanobodies (and ultimately their coding sequences) against virtually any target can be obtained commercially on the time scale of a few months [29,30], a ording this assay the potential to be highly specific as well. Furthermore, positive and negative controls can easily be implemented into the assay to validate the readout of the assay, improving reliability.
The sensitivity of such assays is likely in the range of micromolar concentrations as demonstrated here (Fig. 2d).
However, higher sensitivities might be achievable with further optimization (which we did not attempt here), for example by varying the adhesion strength between cells using di erent expression levels or alternate nanobody clones [1]; furthermore, it may be possible to introduce amplification strategies by integrating higher level genetic circuits, or introducing secondary molecular amplifiers.   Tukey's honestly significant di erence test (HSD). Red and yellow colors correspond to RFP and YFP expressing cells respectively, dashed green lines correspond to cumulative cell density, and black lines correspond to fits. n = 3 replicates for all conditions. Box-plots label the median, quartiles, and extremes.

ATc induction sweep
ATc concentra�on (ng/mL) Interface width (mm) 10 1 0 10 2 10 3 Figure S12: Interface widths for titrating anhydrotetracycline (ATc) sweep. Because adhesin expression is regulated by a TetR repressor, ATc concentration can be used to regulate adhesin expression levels [1]. In this experiment, we used the strains Ag2-RFP|Nb2-YFP, and varied the concentration of ATc over several orders of magnitude up to 2 µg/ml. By fitting the profiles to Eq. 1, we found the interface width is roughly 1.3 mm without ATc, and sharply decreases around 100 ng/mL ATc (the 1x concentration used throughout the paper). The interface width then plateaus to a minimum of roughly 0.4 mm starting roughly at 200 ng/mL ATc, with deviating behavior beyond that. We note that the TetR response function is likely non-linear at extremely low and high ATc concentrations. Consequently, in the main paper we kept the induction level constant at 100 ng/mL ATc and employed competitive peptide inhibitors, whose inhibitory e ects has a much clearer physical interpretation. Red and yellow dots correspond to Ag2-RFP and Nb2-YFP cell respectively. n = 3 replicates for each concentration. Note that Nb3-1 has on average a much longer delay (and also appears more variable), while all other strains show very similar behavior. n = 3 replicates for Ag2, Nb2, Ag3, and Nb3-1. n = 4 replicates for null and Nb3. (b) Swarm expansion rates for various strains. We report the mean expansion rates for Ag2 as 0.0491 ± 0.0087 mm/min, for Nb2 as 0.0506 ± 0.0047 mm/min, for Ag3 as 0.0518 ± 0.0037 mm/min, for Nb3 as 0.0461 ± 0.0074 mm/min, for Nb3-1 as 0.0260 ± 0.0124 mm/min, and for null as 0.0552 ± 0.0038 mm/min. The average expansion rate for all strains excluding Nb3-1 was 0.0506 ± 0.0067 mm/min. Errors are reported as standard deviation, and (*) indicates multiple comparison adjusted p < 0.05 calculated using Tukey's HSD. Standard box-and-whisker plots report median, quartiles and extremes. n = 3 replicates for all strains. Box plots label the median, quartiles, and extremes. Methods: Overnight cultures were seeded on 0.225 % (w/v) soft agar with antibiotics and ATc, placed in a 37 C incubator, and imaged overnight using a custom Raspberry Pi imaging platform. Frames were captured every 5 minutes. To measure cell doubling times, we seeded four 1:2 serial dilution of overnight cultures of cells expressing adhesins. Taking images every five minutes, we measured the delay to reach an 8 mm radius. The doubling time was calculated by dividing the total time delay by the number of 1:2 serial dilutions. To measure migration speed, the radius of the chemotactic front was measured using ImageJ. The migration speed was calculated from the slope using linear regression. The interface corresponds to the bright grey stripe running diagonally from the upper left to the lower right. (b) To localize the z-position of the beads, the images were tiled into bins of 20x20 pixels, and the Laplacian of the Gaussian was used to define the z-slice with best focus. These measurements reveal a systematic change in height diagonally across the the image of approximately 10 µm which we attribute to an uneven imaging surface. Nonetheless, we do not observe any systematic fluctuations in the agar height across the interface. These results indicate that any potential changes in surface height due to adhesins are smaller than 10 µm. (c) The inoculation site was also imaged, using the same conditions as described in (a). (d) Measuring the z-position of the inoculation site reveals the inoculation site is tens of microns higher than the rest of the agar, which is consistent with visual observations, and serves as a positive control for this analysis.

Growth and expansion rate measurements
The color bars are in units of z-steps, where each z-step is 10 µm. With small bins, some subtiles lack any beads resulting in noisy measurements. To minimize this artifact, we clipped the measurements to a range of ± 2 standard deviation around the mean. Three independent experiments produced similar results.  This periodicity has a characteristic spacing of roughly 25µm, which likely corresponds to center-to-center intercluster spacing.       All plates were grown at room temperature (RT) for 48h, which produced sharper Nb3|Ag3 interfaces than at 37 C and seems to make wetting e ects more robust. (Note: When grown at RT, Nb3 and Ag3 cells often do not leave a high density mark at the seeding position as seen at 37 C). (a) Generating an alternating Nb3 and Ag3 pattern with curved interfaces (top) and then pouring a liquid (1x PBS) onto the agar reveals that liquid flow is strongly a ected by the patterning (image sequence), indicating that the wetting properties of the agar surface are locally changed in correlation with the formed Nb3|Ag3 interfaces (Video S10). Experiments with Nb2|Ag2 interfaces showed a similar but weaker e ect. Control experiments with an equivalent pattern using Nb2|Ag3 or Nb3|Ag2 interfaces neither produced visible interfaces nor changes in wettability, i.e., the liquid just flowed across these invisible interfaces unhindered. Experiments were repeated at least three times. (b) To explore spatially constrained liquid droplets using these interfaces, we patterned checkerboard-like grids of alternating Ag3 and Nb3 squares and pipetted 10µl PBS droplets onto either squares. Droplet morphologies di ered depending on the strain: Droplets on Ag3 squares (red arrow head) were angular and aligned with the shape of the underlying grid, while droplets on Nb3 squares (green arrow head) were more compact and round.

Extensibility of bits
Droplets on a lawn of Ag3 cells (light red arrow head) far from any interfaces also produced rounder droplets -in contrast to those on Ag3 squares. (c) To quantify these di erences in droplet shape, we measured their compactness, which is defined as 4⇡A/p 2 , with droplet area, A, and perimeter, p. A and p were measured by tracing droplets in ImageJ FIJI.
A circle and square have a compactness of 1 and ⇡/4, respectively. Compactness measurements show that droplets on Nb3 squares and Ag3 lawns are significantly rounder than Ag3 squares (p < 0.001 for both, independent t-test). This shows that interface patterns can a ect droplet shapes, but depends on the specific adhesins, i.e., the presence of a visible interface by itself is not su cient for restricting liquid flow. Conversely, the round droplet morphology on the Ag3 lawn shows that the material property of the substrate by itself is insu cient to restrict liquid flow. A possible mechanism consistent with these observations is that Ag3 strains create a more hydrophilic surface, while Nb3 strains create a more hydrophobic surface, and a sharp interface between the strains is necessary to create sharp gradients in hydrophobicity to contain droplets. However, we cannot rule out the possibility that the interfaces themselves have inhomogenous properties. This is not a comprehensive analysis of this wetting phenomena, which is left to future work. However, it demonstrates the ability to pattern surface wetting properties, which could have useful applications in generating novel biomaterials, or studying biofilm surface properties [33]. The non-circular droplets in squares were not achieved in every experiment, and were dependent on the formation of strong interfaces. Plates grown at 37 C did not produce as strong of a wetting e ect, which may be correlated with the strength of the interface formed. We observed the square like droplets inside an Ag3 grid on two independent days (7 and 5 square-like droplets each). In contrast, we never observed square-like droplets on Nb3 grids (2 and 10 droplets) or on Ag3 lawns far from interfaces (16 droplets). Scale bars are 1cm.