1. Introduction
Assembly Theory (AT) aims to quantify the historical contingency and structural complexity of objects by counting the minimal number of composition steps required to build them from simple components, under a specified set of admissible joins and with reuse of previously assembled substructures [
1,
2,
3]. In its string-based form, one considers the free semigroup
over a finite alphabet
, with binary concatenation as the only join operation. The canonical assembly index of a string
is then the minimal length of an assembly plan that produces at least one copy of
w, using only substrings of
w as intermediate objects and charging unit cost per join. This canonical, “no-trash” variant captures a universal lower bound for more operational, domain-specific versions of Assembly Theory.
In [
4] it was conjectured and in [
5] it was shown that computing the assembly index of a given string—or even deciding whether the index is at most a given bound
k—is NP-complete, via a reduction from the smallest grammar problem and a correspondence between assembly plans and straight-line programs. From a structural perspective, the canonical index is sensitive to hierarchical reuse of substrings, especially repeated motifs that can be assembled once and then copied in subsequent joins.
However, many natural systems exhibit forms of templated or pattern-based assembly that are not fully captured by pure concatenation. For instance, a fixed molecular scaffold may contain multiple sites where the same functional group is attached, or a regulatory DNA sequence may contain recurrent binding motifs embedded in varying local contexts. From the perspective of string assembly, these phenomena resemble the use of templates: patterns with holes (wildcard positions) that are subsequently filled by previously assembled motifs, possibly at many positions in parallel.
The central aim of this paper is to formalise this intuition in a way that remains faithful to the operational ethos of Assembly Theory. We introduce a new variant of the canonical string-based model in which intermediate objects may contain a special symbol * denoting a placeholder for an arbitrary non-empty string. Crucially, we restrict templates to those that arise as block-compressed substrings of the target string: roughly, a template is obtained by taking a substring u of the target w and replacing some contiguous blocks of u by *, thereby compressing entire blocks into a single wildcard. Assembly operations now include not only concatenation, but also template instantiation steps, where a previously available motif x is substituted for one or all occurrences of * in a template T, in a single step.
This yields a new complexity measure, the templated assembly index . By design, the canonical index appears as the special case where wildcard templates are never used, and we show that for all w. At the same time, can be strictly smaller than for strings that exhibit non-local, templated reuse of motifs, making sensitive to a different aspect of structure—which we term templated modularity.
2. Background: Canonical String-Based Assembly Theory
We briefly recall the canonical string-based formulation of Assembly Theory and fix notation. Let be a finite alphabet and let denote the set of all non-empty strings over . We consider the free semigroup with concatenation as the binary operation.
Definition 1.
Let . The canonical assembly space for w is the pair
where:
Informally, O contains exactly the substrings of the target w, and we may join two substrings in a single assembly step whenever their concatenation is again a substring of w. Intermediate objects are thus constrained by a no-trash condition: every object appearing in any assembly plan is a substring of the target w.
Definition 2.
Let and as above. An assembly plan for w is a sequence
of objects in O such that:
- (a)
each is either a single letter in Σ or is obtained from two earlier objects by a rule in R, i.e. there exist with and ;
- (b)
at least one occurrence of w appears among the .
The length of the assembly plan is the number of composite steps, i.e. the number of indices i for which is obtained by some join rule in R. The canonical assembly index of w, denoted , is the minimal length of an assembly plan for w.
This formulation captures the intuition that we start from monomeric building blocks (single letters) and in each step join two previously available objects, paying unit cost for each join, until we have built the target w at least once. Crucially, the reuse principle is built in: once an object x has appeared in the assembly plan, it is available for use in arbitrary many subsequent joins, effectively at zero marginal cost.
3. Templated Assembly Spaces
We now introduce a templated extension of the canonical assembly space model. Throughout this section we fix a finite alphabet and a distinguished wildcard symbol .
Intuitively, a template is obtained from a substring of the target word by compressing whole contiguous blocks into a single wildcard symbol *. The wildcard positions will later be instantiated by inserting previously assembled motifs.
Definition 3.
Let . A string is called a block-compressed template for w if there exist indices and a partition
of the positions of the substring of length into contiguous blocks
together with a bit vector such that:
We write for the set of all block-compressed templates for w.
Note that templates are not assumed to be given independently of the input: for a fixed target string w the only admissible templates are those in (i.e. mined from substrings of w by block-compression), and any such template can be used in an assembly plan only after it has been explicitly constructed from monomers via rules in (possibly reusing previously assembled objects).
Thus, T is obtained from some contiguous substring u of w by compressing one or more entire blocks into a single wildcard; at least one block remains literal, and at least one block is compressed. The wildcard symbol * can be thought of as a “hole” that marks a region where an arbitrary non-empty string may later be inserted.
Note that block boundaries are arbitrary, so compressed blocks may have length 1. In particular, templates can encode “single-site” variability: a wildcard position may correspond to a single symbol in the underlying substring, and instantiating it with different monomers in captures patterns that differ only at specific positions.
Remark 1. The restriction to block-compressions of substrings enforces a templated version of the no-trash condition: every template T is anchored in w by its literal segments, which appear in the same order as in w. In particular, any instantiation of T by compressible blocks that themselves occur as substrings of w yields again a substring of w.
We now define the objects and operations in a templated assembly space associated with a target string w.
Definition 4.
Let . The templated assembly space for w is the triple
where
Remark 2. Each rule application in has unit cost.
Templates are not external primitives. The only templates that may be used when assembling w are those in , i.e. templates mined from substrings of the target string (Definition above). Moreover, a template can appear in an assembly plan only after it has first been built using the usual binary concatenation rules in from monomers (letters in Σ and the wildcard *). In particular, the construction of a template may reuse any objects that have already been constructed earlier in the same plan (including substrings and previously assembled templates).
Thus the total cost of “constructing” a template is exactly the number of concatenation steps used in its assembly, while each subsequent template instantiation step from is counted as a separate unit-cost operation.
Remark 3. The instantiation rules allow both single-star substitutions (when ) and fully parallel substitutions (when ) as special cases. In this sense, the present templated model subsumes both the single-star and all-star variants.
Thus, assembly operations now include both ordinary concatenation of objects and templated insertion of previously assembled motifs into block-compressed templates. We stress that templates themselves are not introduced by a special rule: they are statically determined by w via block-compression of substrings and are part of from the outset. All dynamic operations are binary and of unit cost, consistent with the canonical model.
We next define assembly plans in the templated setting and the associated complexity measure.
Definition 5.
Let and . A templated assembly plan for w is a finite sequence
of objects in such that:
- (a)
each is either a monomer (a single letter in Σ or the wildcard *) or is obtained by applying a rule in to earlier objects;
- (b)
at least one occurrence of w appears among the .
The length of the assembly plan is the number of composite steps, i.e. the number of indices i for which is obtained via a rule in .
We are now ready to define the templated assembly index.
Definition 6. Let . The templated assembly index of w, denoted , is the minimal length (number of composite steps) among all templated assembly plans for w in .
By construction, we may always ignore templates and restrict to substrings and concatenation, yielding a canonical assembly plan.
Proposition 1.
Moreover, if w admits no templated assembly plan that uses a rule in , then .
Proof (Sketch). Any canonical assembly plan in is also a valid templated assembly plan in : the set of substrings is contained in , and all canonical concatenation rules appear in . Hence , as a minimum over a larger set of assembly plans, cannot exceed .
If no templated rule in can be applied along any optimal templated assembly plan without violating the object constraint (), then any optimal templated assembly plan uses only concatenation rules; restricting to substrings recovers a canonical assembly plan of the same length, and thus . □
In practice, can be strictly smaller than for strings that contain repeated motifs embedded in non-local contexts describable by block-compressed templates. We illustrate this effect in the next subsection.
Remark 4.
More generally, let O be a fixed object universe and let be two sets of assembly rules on O. For , let denote the minimal length of an assembly plan for w when only rules from are allowed. Then for every w we have , since any -plan is also a valid -plan. In particular, any more restrictive templated model obtained by removing some instantiation rules from would give rise to an index satisfying
Thus the present can be seen as the smallest member of a family of canonical indices obtained by varying the strength of the templated rule set.
3.1. Illustrative Example. Selective Template Mining and When Wildcards Help
A key point of the present model is that templates are mined from the target string w: the admissible templates are exactly the block-compressed templates in . The index is defined by minimising over all templated assembly plans in . Consequently, templates are used only if they are beneficial: if no plan that employs a rule in improves upon the best purely concatenative plan, then an optimal plan simply refrains from using templates and we obtain (Proposition above).
To understand when the wildcard mechanism can reduce the number of steps, it is useful to separate two issues: (i) the cost of assembling a template skeleton (counted via ), and (ii) the cost of instantiating wildcard sites (counted via ).
Single-use templates. If a template T is assembled and instantiated only once, then introducing it typically does not help: since T is not a primitive object, one must pay (via ) for constructing its skeleton, and then pay an additional unit-cost instantiation step in . In particular, when (i.e. T has a single wildcard position), an instantiation step provides no parallelism across multiple sites; any advantage over purely concatenative assembly is therefore not automatic and depends on how the surrounding context is reused elsewhere in the plan.
Amortisation by reuse. Templates can become beneficial once the same assembled skeleton is instantiated multiple times within an assembly plan (possibly with different fillers). In that case, the one-time cost of constructing T can be amortised across several instantiations. This effect can already occur for , but it requires repeated use of the same contextual “frame” represented by T.
Parallel filling of several sites. Even for a fixed target w, a single instantiation rule may fill several wildcard positions at once (choose ). Thus, templates with enable a genuinely new mechanism: one operation in can realise multiple occurrences of a motif simultaneously, which is the main source of potential step savings relative to purely concatenative assembly.
As a schematic example, consider a string of the form
where
are fixed “anchors” and
are two motifs. The template skeleton
is an element of
(it is mined from
w by compressing each occurrence of the motif block), and after constructing
T once, we may instantiate it twice to obtain
P and
S. When the anchor context is large and the number of wildcard sites is at least two, this may yield a shorter overall plan than assembling
P and
S separately by concatenation alone. The worked example in the next subsection provides a concrete instance of this separation mechanism.
3.2. A Worked Example: Separating and
Considering the string
we now present a concrete worked example over the alphabet
which illustrates that the templated assembly index
can be strictly smaller than the canonical assembly index
for the same target string.
In the canonical assembly space
, we restrict attention to substrings of
w and binary concatenation. One possible assembly plan for
w proceeds as follows (each line is one unit-cost step):
This gives a canonical assembly plan of length 12. We have verified computationally that no canonical assembly plan of length at most 11 exists. Hence
For readability, we decompose the string
w into three contiguous blocks
where
Both
P and
S share the same “anchor” skeleton
in which the placeholder □ is realised as
22 in
P and as
00 in
S. This is precisely the situation where block-compressed templates with a wildcard symbol * capture a non-local form of modularity. Therefore in the templated assembly space
we may additionally use the wildcard symbol * and the block-compressed template
which is obtained by block-compressing the substring
1100110011 of
w into three anchor blocks
11 separated by two wildcards. Starting from monomers, we can build
T via the following steps:
We also build the motifs
22 and
00:
Using the parallel substitution rule, we obtain the prefix and suffix of
w in two single steps:
We construct the middle block and final concatenations as
Thus the above described templated assembly plan can be written as a step-by-step derivation (where each line is one unit-cost operation):
Counting composite steps, this templated assembly plan has length 11: four steps to build
T, two steps to build
22 and
00, two parallel substitutions to obtain
P and
S, one step for
000, and two final concatenations. Thus
Moreover, for this instance the canonical plan given above has length 12 and this bound is tight, so that
Consequently, we obtain a strict separation for the same target string:
3.3. Additional Worked Example I: Separating ASI and TAI
Considering the string
we present another worked example over the alphabet
illustrating a strict separation between the canonical assembly index and the templated assembly index.
In the canonical assembly space
we restrict attention to substrings of
and binary concatenation. One possible assembly plan for
proceeds as follows (each line is one unit-cost step):
This gives a canonical assembly plan of length 13. We have verified computationally that no canonical assembly plan of length at most 12 exists. Hence
For readability, factor
into contiguous blocks
The two frequently reused blocks 1011 and 1211 share the same anchor skeleton
where the placeholder □ is realised as 0 in 1011 and as 2 in 1211. Accordingly, in the templated assembly space
we use the wildcard symbol * and the block-compressed template
A step-by-step templated derivation (each line is one unit-cost operation) is:
Counting steps, we have 3 steps to build
T, 2 instantiation steps to obtain 1011 and 1211, and 7 concatenations to assemble the final word, for a total of 12 steps. Thus
With
this yields a strict separation:
3.4. Additional Worked Example II: Separating ASI and TAI
Considering the string
we obtain an analogous separation.
One possible canonical assembly plan is (each line is one unit-cost step):
This gives a canonical assembly plan of length 14. We have verified computationally that no canonical assembly plan of length at most 13 exists. Hence
As before, use the skeleton
captured by the template
. A step-by-step templated derivation is:
Counting steps: 3 to build
T, 2 instantiations, and 8 concatenations (for 9 blocks), totalling 13. Hence
and with
we again obtain
4. Relation to Grammars and Pattern-Based Formalisms
The introduction of wildcard templates in connects templated Assembly Theory to established formalisms in theoretical computer science and formal language theory.
First, the canonical string-based assembly index is closely related to the smallest grammar problem: given a string
w, find a smallest context-free grammar (or straight-line program) that generates exactly
w. In [
5] this correspondence is made precise, and NP-completeness of computing
is established.
Templated assembly extends this picture in the direction of: macro grammars and grammars with parameters, where non-terminals can take arguments and effectively encode templates with holes; pattern languages, where patterns are strings over an alphabet of terminals and variables, and variables can be instantiated by arbitrary strings; and insertion systems, where strings grow by insertion of substrings into designated positions.
Our block-compressed templates correspond to patterns whose literal segments are constrained to appear in the same order as in w, and whose variables (wildcards) represent compressible blocks between these anchors.
The templated assembly index can thus be viewed as an operational measure of how economically w can be generated by a restricted class of pattern-based constructions that combine concatenation with a limited form of parameterised copying. This perspective suggests both algorithmic strategies (e.g. approximate via grammar-based compression with macro rules) and complexity-theoretic results, to which we now turn.
4.1. A Greedy Macro-Grammar Heuristic for Approximating
The connection to macro grammars suggests practical heuristics for obtaining computable upper bounds on . Informally, one may treat a frequently instantiable pattern as a “macro rule” whose body is a template (the skeleton) and whose argument is the filler block u used to instantiate wildcard sites via .
Fix a template
. For each
such that the fully instantiated string
is a substring of
w (hence
), let
denote the number of occurrences of
in
w (or in the current working representation of
w maintained by the heuristic). Instead of selecting a single pair
, it is natural to select one skeleton
T together with a family of fillers
for which
. This reflects the fact that the cost of constructing the skeleton
T (via
) can be amortised over multiple instantiations, possibly with different fillers. In practice, it is often beneficial to restrict to templates with at least two wildcard sites,
, since a single instantiation step can then fill several sites at once (choose
).
To decide whether committing to a skeleton
T and a filler family
U is likely to reduce the number of steps, we compare: (i) assembling all occurrences of the instantiated substrings
“directly” in the canonical model, and (ii) assembling the skeleton
T once (via
), assembling each filler
once, and then producing each occurrence of
by one instantiation in
. Let
be any efficiently computable cost proxy for canonical (concatenation-only) assembly complexity, intended to approximate (or upper bound)
by taking classical reuse into account. In the simplest baseline one may take
. Using such a proxy, define
A positive score indicates that (under this proxy) it is worthwhile to pay for constructing T (once) and the fillers in U in order to amortise them over instantiations. In a greedy implementation, one typically accepts only candidates with and uses the magnitude of as a priority score (larger gain indicates a more promising template under the chosen proxy). Conversely, suggests that the template is unlikely to be beneficial in this approximation, although one cannot exclude indirect benefits through later reuse effects in the full model.
Starting from the explicit target word w, iterate:
Mine candidate skeletons together with admissible fillers u for which , and compute in the current working representation.
For each T, choose a filler family U (e.g. all admissible fillers, or the best-scoring subset) and compute .
Select a skeleton T with a filler family U of maximum positive gain.
Commit to constructing T once (using ), constructing each once, and generating each chosen occurrence of via a single rule application in (fully parallel substitution, ).
“Compress” the working representation of w by treating each generated occurrence of each as an available object, and continue searching for further profitable candidates on the remaining structure.
The resulting set of committed constructions and instantiations can be translated directly into a templated assembly plan in , and therefore yields an explicit computable upper bound on . We leave a detailed experimental evaluation of such heuristics for future work.
This viewpoint is consistent with Example 3.2: the skeleton
is instantiated in
w with two different fillers,
and
, producing
and
. For the baseline choice
, we have
and thus
, while
and hence
. Moreover,
, so
, and in this example
. Taking
, the aggregate score becomes
which is positive precisely because the one-time cost of constructing the skeleton
T is amortised across two instantiations with different fillers. Accordingly, a gain-based greedy strategy would naturally commit to assembling the single skeleton
T once and then instantiating it for each filler, capturing the step savings exhibited by the templated assembly plan in that example.
paragraphGain calculations for the additional worked examples I and II. We reuse the baseline proxy .
Example I (
). Take the skeleton
and the filler family
, which produces
Here
, so
, and
, hence
. Moreover
, so
. In the block factorisation
we have
and
. Therefore
Example II (
). With the same
and
, we still have
,
, and
. Using the factorisation
we obtain
and
, hence
5. Computational Complexity
We consider the decision problem associated with the templated assembly index .
Definition 7.
The decision problemTAI-DEC is defined as follows:
Instance: a string and a non-negative integer k (given in unary or binary).
Question: does there exist a templated assembly plan for w of total cost at most k in the templated assembly space ?
Lemma 1.
TAI-DEC belongs to .
Sketch. A certificate is a sequence of rule applications (concatenations and template instantiations), together with the intermediate objects they produce. Since every step strictly increases the length of at least one constructed object, the length of a valid plan is polynomially bounded in . Verification proceeds by simulating each operation and checking that the produced object belongs to . All checks can be carried out in time polynomial in , hence TAI-DEC is in . □
The canonical decision problem
is NP-complete for fixed finite alphabets [
5]. Since
for all
w, the templated model is a genuine extension of the canonical one. However, this extension goes in the easier direction (it potentially shortens optimal plans), so NP-hardness of
TAI-DEC does not follow immediately from NP-hardness of
ASI-DEC.
One can nevertheless view ASI-DEC as the restriction of TAI-DEC to assembly plans that never apply a rule in . Equivalently, under the promise that w admits no beneficial template instantiation (so that ), the problems TAI-DEC and ASI-DEC coincide.
This observation does not, however, settle the unconditional worst-case complexity of TAI-DEC. Indeed, once beneficial template instantiations are allowed, deciding whether requires simultaneously reasoning about the classical reuse-vs.-concatenation trade-off and about whether it is worthwhile to invest concatenation steps into constructing templates in order to amortize them through one or more instantiation steps. For this reason, we strongly conjecture that TAI-DEC remains NP-hard (already over fixed alphabets): the templated model preserves the combinatorial “hard core” of canonical assembly planning, while adding an additional layer of discrete structure selection (identifying and exploiting profitable templates). While this is not a proof, it provides compelling evidence that intractability should persist in the worst case. Establishing unconditional NP-hardness (or polynomial-time solvability) of TAI-DEC for fixed alphabets remains an interesting open question.
6. Discussion
We have proposed an extension of the canonical string-based formulation of Assembly Theory in which intermediate objects may contain a wildcard symbol * representing compressed blocks, and templates are restricted to block-compressed substrings of the target string. This leads to the templated assembly index , a new complexity measure that generalises the canonical assembly index and is sensitive to templated modularity: the presence of modules that recur in multiple, possibly distant contexts linked by a common scaffold.
Formally, we defined templated assembly spaces, specified concatenation and template instantiation rules, and established basic relationships between and . We established membership in NP and clarified why NP-hardness does not follow from a trivial embedding argument. We conjecture that TAI-DEC is NP-hard (already for fixed alphabets), while leaving unconditional NP-hardness open. We also outlined connections to grammar-based compression and to formalisms such as pattern languages.
Some domains where and its future variants may offer novel insights are:
Chemistry and molecular design: Many molecules can be described as relatively rigid scaffolds decorated by repeated functional groups: aromatic cores bearing several identical substituents, oligomers with the same side chain attached at multiple positions, or dendritic architectures built from a small set of branching units. In a string-based representation of molecules (for example a linearised encoding of a core with substituents), such patterns correspond to templates where wildcard positions mark sites of functionalisation. Canonical assembly indices quantify reuse of repeated fragments, but they do not distinguish between independent repetitions and repetitions coordinated by a shared backbone. In contrast, templated assembly makes this distinction explicit: a common scaffold with wildcard sites is built once, and then instantiated with chosen functional groups. Molecules or families of molecules with a large gap would then correspond to structures where much of the apparent combinatorial complexity comes from templated substitution patterns rather than from genuinely unrelated submotifs, suggesting applications in quantifying scaffold–decoration modularity in medicinal chemistry, combinatorial library design, and polymer or supramolecular engineering.
Sequence analysis and genomics: Many genomic regions exhibit modular architectures, with recurring motifs (e.g. transcription factor binding sites, protein domains) embedded in diverse local contexts. Canonical assembly indices already provide a measure of hierarchical reuse, but templated indices could more directly reflect shared scaffolds with multiple occurrences of the same motif. Differential behaviour of and across genomic regions might highlight functionally relevant templated structures.
Biosignatures and origins of life: Assembly Theory has been proposed as a framework for defining universal biosignatures based on complexity measures derived from putative assembly paces [
1,
2,
3]. The templated assembly index offers a complementary axis: high
together with a large gap
might signal systems that exploit templated copying of modules in ways characteristic of evolved biological organisation, for example gene families under common regulatory architectures.
Future work may include a more detailed classification of the gap for various families of strings, refined complexity and approximation results, and empirical studies of on biological and artificial datasets. On the conceptual side, templated Assembly Theory suggests a broader programme: to systematically explore how different classes of templates and rewriting operations give rise to distinct families of assembly indices, each probing a different facet of structure and history in complex systems.
References
- Marshall, S.M.; Murray, A.R.G.; Cronin, L. A probabilistic framework for identifying biosignatures using Pathway Complexity. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 2017, 375, 20160342. [Google Scholar] [CrossRef] [PubMed]
- Marshall, S.M.; Moore, D.G.; Murray, A.R.G.; Walker, S.I.; Cronin, L. Formalising the Pathways to Life Using Assembly Spaces. Entropy 2022, 24, 884. [Google Scholar] [CrossRef] [PubMed]
- Sharma, A.; Czégel, D.; Lachmann, M.; Kempes, C.P.; Walker, S.I.; Cronin, L. Assembly theory explains and quantifies selection and evolution. Nature 2023, 622, 321–328. [Google Scholar] [CrossRef] [PubMed]
- Łukaszyk, S.; Bieniawski, W. Assembly Theory of Binary Messages. Mathematics 2024, 12, 1600. [Google Scholar] [CrossRef]
- Masierak, P. Computational Complexity of Determining the Assembly Index. IPI Letters 2026, 9–12. [Google Scholar] [CrossRef]
|
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).