Quantum Gates from Wolfram Model Multiway Rewriting Systems Furkan Semih Dündar Xerxes D. Arsiwalla Hatem Elshatlawy Abstract We show how representations of finite-dimensional quantum operators can be constructed using nondeterministic rewriting systems. In particular, we investigate Wolfram model multiway rewriting systems based on string substitutions. Multiway systems were proposed by S. Wolfram as generic model systems for multicomputational processes, emphasizing their significance as a foundation for modeling complexity, nondeterminism, and branching structures of measurement outcomes. Here, we investigate a specific class of multiway systems based on cyclic character strings with a neighborhood constraint - the latter called Leibnizian strings. We show that such strings exhibit a Fermi-Dirac distribution for expectation values of occupation numbers of character neighborhoods. A Leibnizian string serves as an abstraction of a N N -fermion system. A multiway system of these strings encodes causal relations between rewriting events in a nondeterministic manner. The collection of character strings realizes a ℤ \mathbb{Z} -module with a symmetric ℤ \mathbb{Z} -bilinear form. For discrete spaces, this generalizes the notion of an inner product over a vector field. This admits a discrete analogue of the path integral and a S S -matrix for multiway systems of Leibnizian strings. The elements of this S S -matrix yield transition amplitudes between states of the multiway system based on an action defined over a sequence of Leibnizian strings. We then show that these S S -matrices give explicit representations of quantum gates for qubits and qudits, and also circuits composed of such gates. We find that, as formal models of nondeterministic computation, rewriting systems of Leibnizian strings with causal structure encode representations of the CNOT, π / 8 \pi/8 , and Hadamard gates. Hence, using multiway systems one can represent quantum circuits for qubits. Keywords: Nondeterministic Rewriting Systems, Leibnizian Strings, Causal N − N- Fermions, Discrete State Spaces, Representation of Quantum Operators. 1 Introduction Symbolic systems broadly constitute a framework of abstract entities, or symbols, and a collection of rules for manipulating these symbols. That is, a syntax equipped with a generative grammar or an algebra governing the composition of symbols. Although these symbols and their operations are purely syntactic, in practical use cases, they often refer to (in terms of formally admissible semantics) specific knowledge or information about objects and relations in the world (real or virtual). Common examples of symbolic systems are formal language, logic, algorithms, just to name a few. In this work, we focus on computational systems, in particular, nondeterministic rewriting systems based on string substitutions. Although much is known about these systems as formal models of computation [ 33 , 21 , 7 , 12 ] , here we seek to explore how rewriting systems encode representations of finite-dimensional quantum operators. A symbolic representation of the latter is often useful for the design of algorithms and protocols in quantum information and computation. Prior approaches towards a symbolic representation of finite-dimensional quantum theory include category-theoretic process theories such as ‘categorical quantum mechanics’ (CQM) based on string diagrams (where the “strings” of CQM refer to connectors between operators) [ 1 , 19 ] , and the related ZX-calculus [ 17 , 18 ] (one may also consider a multiway system of ZX diagrams, as shown in [ 28 , 30 , 29 ] ). The interesting feature about such symbolic approaches to quantum theory is that they offer a formulation that is independent of any background spacetime geometry. Instead, they make use of the more fundamental notion of causal order. This approach has led to various diagrammatic calculi that have proven useful for quantum computing protocols [ 17 , 19 , 57 , 41 ] . This is very much the spirit of the computational paradigm we espouse here, which is background-independent and makes use of the causal structure of the rewriting system. On the other hand, our formalism differs from some of the aforementioned ones in two important ways: (i) rather than working with instantaneous system configurations, here we consider a statistical mechanics approach based on an ensemble of paths referring to sequences of rewriting events; and (ii) the building blocks of our formalism are not themselves quantum states or operators (or direct references to those), but instead are syntactic entities of an abstract computational system. More specifically, we work with nondeterministic rewriting systems based on cyclic character strings. These strings are updated following all specified rewriting rules, and in all possible orders. Such a system is called a multiway rewriting system of character strings. The term “multiway system” was coined by S. Wolfram in [ 60 ] , and also refers to more generic rewriting systems based on graph and hypergraph rewriting. Rewriting systems are models of computation that are equivalent to Turing machines, and are commonly used in theorem proving protocols [ 21 , 7 , 12 ] . In [ 61 ] hypergraph rewriting systems were proposed as the computational basis underlying contemporary theories of physics. Subsequently, a mathematical formalization based on higher category theory established the construction of topological spaces from multiway rewriting systems [ 6 , 2 , 5 ] . A review of the implications and challenges of this computational approach for reformulating contemporary theories of physics can be found in [ 4 , 44 , 23 , 43 ] . Initial investigations seeking quantum theory from rewriting systems have been discussed in [ 61 , 31 , 28 , 30 ] . In this work, we go deeper into the specific issue of extracting finite-dimensional quantum operators from multiway systems. We solve this problem explicitly and compute representations of quantum gates from multiway data. For this, we consider an ensemble of cyclic character strings. Furthermore, we restrict ourselves to the so-called Leibnizian strings. These are inspired by a monadic interpretation of discernibility. We make use of a complexity measure on strings known as the Barbour-Smolin-Deutsch variety or the BSD variety , which was first proposed in [ 9 ] , and more recently elaborated in [ 22 ] . The ensemble of Leibnizian strings turns out to exhibit a Fermi-Dirac distribution for expectation values of occupation numbers referring to string neighborhoods. By considering only the Leibnizian strings in the multiway system, we study paths on the multiway graph formed by sequences of state transitions. We consider a summation over paths formed by sequences of such strings. This serves as a discrete analogue of the quantum mechanical path integral over trajectories in phase space. Using this, we then construct S -matrices whose entries consist of transition amplitudes weighted over an ensemble of paths over the multiway graph based on an action defined over a sequence of Leibnizian strings. These S -matrices provide us with a representation of unitary operators. The S -matrices we construct here capture the underlying statistical mechanics involved in the update sequences of a nondeterministic rewriting system. The nondeterministic causal structure (which itself follows from the rewriting rules) plays a crucial role for the purposes of determining transition amplitudes between multiway states. This suggests a statistical perspective on nondeterministic computation. Even though this work investigates only the very specific aspect of representations of quantum operators from nondeterministic computational systems, it is worth noting the broader significance of computational approaches that probe the foundations of quantum theory. In particular, the work of G. ‘t Hooft [ 63 , 62 , 64 ] and C. Wetterich [ 58 , 59 , 38 ] , both of whom have proposed the emergence of quantum theory from cellular automata, is the subject of considerable interest. The former advocates fundamental determinism, while the latter favors a statistical mechanics approach based on probabilistic cellular automata, and posits that quantum theory emerges from an underlying classical statistical system. The paper is organized as follows. Section 2 provides preliminary definitions and concepts. In Section 3 , we define Leibnizian strings and develop an information-theoretic characterization of their structure. Section 4 introduces the Wolfram model, abstract rewriting systems and multiway graphs. Section 5 identifies physical and maximal variety paths. In Section 6 , we demonstrate that Leibnizian strings exhibit Fermi-Dirac statistics for occupation numbers of monadic views. Section 7 develops the path-sum formalism and constructs S -matrices for multiway evolution. Section 8 presents applications to quantum computing, demonstrating how abstract computational systems can encode representations of finite-dimensional quantum gates, including for qubits and qudits. Finally, Section 9 concludes with a discussion of implications and future directions. 2 Preliminaries In this Section we provide preliminary materials from Ref. [ 9 ] . Sometimes we use a modified notation compared to the cited work. Definition 2.1 (Neighborhood of a character [ 9 ] ) . For given position ( i ) and radius ( m ) the neighborhood of the character at position ( i ) with radius ( m ) is the substring from position i-m to i+m considering cyclic topology, including the letter at position ( i ). If the string length is N , the maximum value of m is as follows: m_{\text{max}}=\begin{cases}N/2-1&N\text{ is even}\\ (N-1)/2&N\text{ is odd}\end{cases} (1) Definition 2.2 (String isomorphism [ 9 ] ) . Given two strings they are deemed isomorphic if they are the same or one is the mirror image of the other. Definition 2.3 (Relative indifference [ 9 ] ) . Relative indifference is calculated given two distinct positions in a string. It is the smallest radius of neighborhoods of these characters such that the neighborhoods are not isomorphic. We denote the relative indifference between characters at positions i,j as r_{ij} . Definition 2.4 (Leibnizian strings [ 9 ] ) . A string is Leibnizian if all character positions are mutually distinguishable by their neighborhoods. Specifically, for every pair of distinct positions i\neq j , there exists some radius m\leq m_{\max} such that the neighborhoods of radius m at positions i and j are non-isomorphic. A string is not Leibnizian if two or more positions have isomorphic neighborhoods at all radii. Example 2.1 . Consider the cyclic string “AAABBB”. The first and the third A’s share the same neighborhood. This is also the case of the first and the third B’s. Hence these positions are indistinguishable, so “AAABBB” is not Leibnizian. Example 2.2 . In contrast, consider “AABABB”. At the maximum radius m=2 (in order to determine whether a word is Leibnizian it is enough the check the maximum radius neighborhoods): • Position 1 (A): neighborhood = “BBAAB” • Position 2 (A): neighborhood = “BAABA” • Position 3 (B): neighborhood = “AABAB” • Position 4 (A): neighborhood = “ABABB” • Position 5 (B): neighborhood = “BABBA” • Position 6 (B): neighborhood = “ABBAA” All six neighborhoods are distinct, so “AABABB” is Leibnizian. The subtle point here is that although the entire string is cyclic, the neighborhoods are not . The motivation for the definition of Leibnizian strings comes from the monadology [ 39 ] of Leibniz. In his terms [ 39 ] : The monad […] is nothing else than a simple substance, which goes to make up composites; by simple we mean without parts. Due to the identity of indiscernibles principle of Leibniz [ 45 ] if two objects share the same properties then they are the same. For character strings, the properties are the neighborhoods of each position in a string. For that purpose, for Leibnizian strings we require that each neighborhood of characters is distinguished from the neighborhood of other characters. Thus, Leibnizian strings can model physical systems interpreted as consisting of monads. Monads themselves can be seen as ‘metaphysical atoms’. Leibnizian strings will be of prime importance in our work. Definition 2.5 (Absolute indifference [ 9 ] ) . Absolute indifference is calculated for a single position in a string. It is the maximum of relative indifference values between the given position ( i ) and other positions in the string. It is expressed as a_{i}=\max\{r_{ij}|j\neq i\} . Next, we discuss the ‘BSD Variety’, which was introduced in [ 9 ] as a complexity measure of a string of characters. The term ‘BSD’ refers to the names “Barbour-Smolin-Deutsch”, and was coined in this form in [ 22 ] (since the original paper by Barbour and Smolin [ 9 ] cites a private communication by Deutsch, dated 1989, as the suggestion for that specific variety function - Ref. [30] in [ 9 ] ). Definition 2.6 (BSD Variety [ 9 ] ) . Given a Leibnizian string the BSD variety is calculated as \variety=\sum_{i}1/a_{i} . Example 2.3 . The string “AABABB” is Leibnizian. The absolute indifference values of characters are 2,2,1,1,2,2 . Hence, its BSD variety is 4 . This definition is somewhat different from the one recently used by Smolin in Refs. [ 51 , 52 ] . In our study, since we consider only the Leibnizian strings, we set the variety value of a non -Leibnizian string to zero. However, in more general cases, one may sum over a_{i}\neq 0 and neglect the a_{i}=0 terms. The case a_{i}=0 arises when the full neighborhood of a character in position i is the same as that of some other character. In this way, one may also say that a_{i}\to\infty and these terms do not contribute to the sum to calculate the BSD variety. However, in our algorithm, we set a_{i}=0 in non-Leibnizian strings to store a numerical value on the computer. 3 Information-Theoretic Aspects of Leibnizian Strings & their Enumeration In this Section, we are concerned with information-theory related concepts for Leibnizian strings and the number of Leibnizian strings. 3.1 Information-Theoretic Considerations A cyclic character string is deemed Leibnizian if no two positions exhibit isomorphic local neighborhoods even when the whole string is covered. Let us give two examples: “AAABBB” is a non-Leibnizian string, whereas “AABABB” is Leibnizian. This definition prevents redundant symbolic structures, ensuring a meaningful interpretation of characters as monads [ 39 ] in Leibnizian terms, via the principle of identity of indiscernibles [ 45 ] . Because every neighborhood is unique in Leibnizian strings, they have in some sense more information than non-Leibnizian strings. For a non-Leibnizian string, about half of the string is redundant. For a detailed account of being a Leibnizian string and the calculation of (BSD) variety, please refer to [ 9 , 22 ] . Readers may refer to [ 10 ] as a complementary reading on Leibnizian ideas. Let us begin by defining the Shannon entropy. Definition 3.1 (Shannon entropy of a string of characters [ 48 ] ) . For a string of length n where letters are from an alphabet \{\lambda_{i}|i=1,\cdots,\nu\} where each letter has probability p_{i}=\#\lambda_{i}/n of occurrence the Shannon entropy is defined as the sum H=-\sum_{i=1}^{\nu}p_{i}\log_{2}p_{i} . By changing the base of logarithm in the definition above, one can obtain information in other untis, such as nats for natural logarithm. As is seen, the Shannon entropy is concerned only with the frequency of letters occurring in a string. Hence, it cannot reflect the complex structure of Leibnizian strings in terms of local neighborhoods of characters. On the other hand, the conditional Shannon entropy (see Ref. [ 32 ] for a discussion) is more useful in order to define the information content of a string. Definition 3.2 (Conditional Shannon entropy [ 32 ] ) . The conditional Shannon entropy is defined as H(Y|X)\equiv H(X,Y)-H(X) . The term H(Y|X) is the conditional entropy of Y given X , the term H(X,Y) is the joint entropy and H(X) is the Shannon entropy. Using the definition of conditional Shannon entropy we just provided, let us define it in the context of character strings. Definition 3.3 (Conditional Shannon entropy of a string of characters) . Let H(X) be the Shannon entropy of the whole string and H(X,Y) be the joint entropy. In order to calculate H(X,Y) , we consider a list of two consecutive letters in the string. Hence H(X,Y) is the Shannon entropy of a list consisting of two-letter ‘characters.’ We considered random Leibnizian strings of varying lengths and calculated the BSD variety and the conditional Shannon entropy. The results are provided in Figure 1 . As we can see, there is a correlation between these two concepts. This key observation suggests that the information content of a string is positively correlated with the BSD variety. Figure 1: The plot of BSD variety vs conditional Shannon entropy for a set of Leibnizian strings for different alphabets. It is seen that BSD variety is positively correlated with the information content of words. Two-letter alphabet: 1281 words of length between 8–50. Three-letter alphabet: 1289 words of length between 8–50. Four-letter alphabet: 1704 words of length between 8–65. Five-letter alphabet: 2490 words of length between 8–90. 3.2 Enumeration of Leibnizian strings The number of Leibnizian strings is countably infinite. The countably part is straightforward. However, we need to show that they are infinitely many. For a letter \lambda we denote by \lambda^{n} the repetition of letter \lambda n times. For example A^{2}=AA and A^{3}=AAA and so on. In this subsection, we consider an alphabet of letters where the number of distinct letters is \nu . Hence, the alphabet is the set \{\lambda_{i}|i=1,\cdots,\nu\} . Definition 3.4 (Fractal words) . A fractal word is a word of the form \otimes_{i=1}^{n}\lambda_{1}^{i}\cdots\lambda_{\nu}^{i} parameterized by the positive integer n . Example 3.1 (Two letter alphabet) . Let us consider a two letter alphabet: \{A,B\} . The fractal words for n=1,2,3 are “AB”, “ABAABB” and “ABAABBAAABBB” respectively. Proposition 3.1 . All fractal words are Leibnizian for n>1 . Proof. We will prove the proposition for a two letter alphabet. Its generalization to larger alphabets will be obvious once we present our method. Now we consider a two letter alphabet \{A,B\} and n>1 . If n=1 the word is just “AB” and hence non-Leibnizian. Suppose now that n>1 . Considering the block of A ’s in A^{i}B^{i} and A^{j}B^{j} for i2 , using the fact that the maximum of i is n . Because the string length is even, we should have m_{max}=(n+2)(n-1)/2 . If n=2 we have the string “ABAABB” and it is Leibnizian. One can do a similar analysis of letters ‘B’ and make sure that the fractal words are Leibnizian. That completes the proof. ∎ Corollary 3.1 (Leibnizian words are infinitely many) . Due to Proposition 3.1 for any n>1 the corresponding fractal word is Leibnizian. Hence, the cardinality of the set of Leibnizian words is \aleph_{0} . Using Proposition 3.1 one can also calculate the BSD variety of fractal words. 4 Wolfram Model and Abstract Rewriting Systems In this Section we present a brief overview of the Wolfram model and abstract rewriting (reduction) systems. The Wolfram model [ 60 , 61 ] is a computational framework based on nondeterministic rewriting systems. This model attempts to provide a description of fundamental physical phenomena starting from abstract rewriting systems. It seeks to capture ways in which simple computational programs lead to complex symbolic systems relevant to physical structure. This approach constitutes a constructivist formalization of the foundations of physics based on formal symbolic systems. This complements ongoing efforts in the category-theoretic foundations of physics and mathematics, for instance, in relation to the synthetic geometry and homotopy type theory program [ 47 , 25 , 42 , 49 ] . The mathematical foundations of the Wolfram model in terms of higher categories and homotopy type theory have been described in [ 6 , 2 , 5 ] . The philosophical underpinnings of the Wolfram model can be found in [ 44 , 4 , 43 ] . The general framework of the Wolfram model being grounded in formal computation, it does away with continuum structures in favor of discrete descriptions, including those referring to space, time and matter. The model posits a combinatorial description based on causal relations between events, which makes manifest the computational architecture that underlies contemporary physics. The archetypical structures that appear within this framework are the so-called “multiway systems”. These are nondeterministic abstract rewriting systems equipped with a causal structure. The term “multiway” refers to the fact that these systems instantiate all permissible applications of rewriting rules in all possible orders, thereby leading to multiple sequences of rewriting terms that are partially ordered by binary relations. The partial order realizes a causal structure. Depending upon the precise interpretation of the terms, Wolfram model multiway systems may be realized as rewriting systems over graphs, hypergraphs, character strings, or other symbolic structures. For what follows below, here we will mainly be concerned with multiway systems of character strings. Now let us begin with the definition of abstract rewriting (reduction) systems. Definition 4.1 (Abstract rewriting (reduction) system [ 12 ] ) . An abstract reduction system (ARS) is a structure \mathcal{A}=(A,\{\to_{\alpha}|\alpha\in I\}) consisting of a set A and a set of binary relations \to_{\alpha} on A , indexed by a set I . For \alpha\in I , the relations \to_{\alpha} are called reduction or rewriting relations. Beginning with a single element and a set of rules \{\to_{\alpha}\}_{\alpha} , an abstract rewriting system can generate a whole class of elements that can be obtained via these rules. The application of rules is known as reduction [ 12 ] . A Wolfram model is any abstract rewriting system with a designated initial state. The archetypical structure of a Wolfram model is a multiway rewriting system . Definition 4.2 (Multiway rewriting system [ 60 , 61 ] ) . A multiway rewriting system of a Wolfram model is an abstract rewriting system \mathcal{A}=(A,\{\to_{\alpha}|\alpha\in I\}) with a designated initial state a_{ini}\in A that generates sequences of rewriting events upon application of all possible rules from the set \{\to_{\alpha}|\alpha\in I\} , in all possible orders, to every element in each sequence (whenever rule application is valid). The Wolfram model multiway system is often represented by a multiway graph. Definition 4.3 (Multiway graph [ 61 ] ) . A multiway graph or multiway evolution graph is a directed graph corresponding to the evolution of an abstract rewriting system \mathcal{A}=(A,\{\to_{\alpha}|\alpha\in I\}) , in which the vertices of the graph refer to elements a\in A , and directed edges {a\to b} refer to the existence of a rewriting event that transforms element a to element b . Every multiway graph is further specified by a root vertex, which corresponds to the initial element of the rewriting sequences. See Figure 2 for an illustration of a string substitution (with character strings) multiway system with initial state “BBBAAACC”, and two rewriting rules \text{BA}\to\text{AB},\;\text{CB}\to\text{BC} . In this case, the multiway graph has finitely many elements, and the rewriting process will terminate. This is because after a certain number of rewriting events, the string will be sorted. In general, a multiway system needs not terminate though. Figure 2: Initial section of the multiway system graph of string “BBBAAACC” with the rules: \text{BA}\to\text{AB},\text{CB}\to\text{BC} . The physical multiway system that includes only the Leibnizian strings is highlighted in red. 5 Physical and Maximal Variety Paths Physical paths in the multiway system consist exclusively of Leibnizian strings. These paths evolve through a discrete substitution process. They can branch and merge within the multiway system. Definition 5.1 (Physical paths [ 22 ] ) . A physical or a Leibnizian path in a multiway system is a path such that all the vertices it includes are Leibnizian. Definition 5.2 (Maximal variety paths [ 22 ] ) . Maximal variety paths are physical paths in a multiway system of depth d such that they maximize the sum of (BSD) variety values of its vertices. One needs to be careful that the maximal variety paths are not additive. Consider maximal variety paths of depths d and d+1 . In these two cases, there may be string configurations in maximal variety paths of depth d where they may not be present at depth d+1 maximal variety paths. On the other hand, physical (Leibnizian) paths are additive. This expression means that physical paths of depth d+1 for some d can be obtained by continuation of physical paths of depth d one step ahead. For illustration purposes, we consider a small multiway system, see Figure 3 . In order to define maximal variety paths, we consider the sum of BSD variety values on all physical paths and choose the physical paths with the maximum sum as maximal variety paths. Figure 3: Representation of initial part (depth 4) of the multiway system specified by the following: Initial state: “AABAABBABAB”. Rewriting rule: BA \to AB. The paths highlighted in red are Leibnizian (physical) paths where as the path in green is the maximal variety path. 6 Leibnizian Strings and Fermi-Dirac Statistics Each monad is unique. This is dictated by Leibniz’s principle of Identity of Indiscernibles . For a detailed philosophical discussion of this principle, the esteemed reader may kindly consult [ 45 ] . What distinguishes a monad from another one in the present string ontology is their local neighborhoods. The smallest neighborhood of a letter that distinguishes it from other neighborhoods can be said to be the view of that monad. The term ‘view’ is also used in [ 51 ] . However, the context in [ 51 ] is closer to causal set theory. On the other hand, our use of the term ‘view’ is closer to the discussion in [ 9 ] ). The view of a monad is its local neighborhood that has an absolute indifference value as its radius. Monads can be defined through their views, and a specific view can occur only once or never in Leibnizian strings. In this sense, monads exhibit fermionic behavior. We will soon elaborate on this. The set of possible views consists of all possible combinations of letters in the alphabet, with radius m=1,2,\ldots where the length of view for a specific radius m is 2m+1 . For example, in a two letter alphabet the set of views of radius m=1 is \{\text{AAA},\text{AAB},\text{ABA},\text{ABB},\text{BAA},\text{BAB},\text{BBA},\text{BBB}\} Views with radius m=0 , that is, of only one letter, do not occur in Leibnizian strings. We denote a view of a monad with the letter \phi . Now we consider a gas of Leibnizian strings of the same length, that is, N . We parameterize each character in a string by the j parameter. In a way j is the position of a character. We denote by n_{\phi} the occupation number of view \phi . Because we only consider Leibnizian strings, n_{\phi} can be zero or one. This property of Leibnizian strings will be the key to show that they exhibit fermionic behavior. Our guide in the rest of this Section will be Ref. [ 8 ] and will follow this source as regards the derivation of expected value of occupation number of a view. The partition function of an ensemble of Leibnizian strings of length N is denoted by Z=\sum_{l}e^{-E_{l}/\kappa T}=\sum_{l}e^{-\beta E_{l}} where \beta=1/\kappa T , the index l goes over all the Leibnizian strings in the ensemble and \kappa is Boltzmann’s constant. For a specific view \phi the expectation value of its occupation number is defined as: \langle n_{\phi}\rangle=\frac{1}{Z}\sum_{l}n_{\phi}e^{-\beta E_{l}}. (2) Here we posit that the energy E_{l} is proportional to the BSD variety of the corresponding string \mathcal{S}_{l} and write E_{l}=\gamma\variety(\mathcal{S}_{l}) where \gamma is the proportionality constant that relates variety and energy. As a matter of notation, let us denote by a_{i} the absolute indifference value of view n_{\phi_{i}} , that is, the radius of view n_{\phi_{i}} . If a Leibnizian string consists of a number of views \{n_{\phi_{i}}\}_{i} where 1\leq i\leq M , where M is such that all views that can be found in a string of length N are included. This will be a finite set of views. we can write its BSD variety as the sum: \variety(S_{l})=\sum_{i}\frac{n_{\phi_{i}}}{a_{i}}. (3) This observation will be important in what follows. We expand the sum to compute Z in the calculation of n_{\phi_{1}} as follows: \langle n_{\phi_{1}}\rangle=\frac{1}{Z}\sum_{n_{\phi_{1}}}\sum_{n_{\phi_{2}}}\cdots n_{\phi_{1}}\exp\left[-\beta\gamma\left(\frac{n_{\phi_{1}}}{a_{1}}+\cdots+\frac{n_{\phi_{M}}}{a_{M}}\right)\right]. (4) under the condition n_{\phi_{1}}+\cdots+n_{\phi_{M}}=N . The triple dots denote summation operators over other possible views. The only contribution to the sum above comes from the value of n_{\phi_{1}}=1 , and we can write: \langle n_{\phi_{1}}\rangle=\frac{e^{-\beta\gamma/a_{1}}}{Z}\sum_{n_{\phi_{2}}}\cdots\exp\left[-\beta\gamma\left(\frac{n_{\phi_{2}}}{a_{2}}+\cdots+\frac{n_{\phi_{M}}}{a_{M}}\right)\right]. (5) under the condition n_{\phi_{2}}+\cdots+n_{\phi_{M}}=N-1 . The idea is to write the sum above as follows: \sum_{n_{\phi_{1}}}\sum_{n_{\phi_{2}}}\cdots(1-n_{\phi_{1}})\exp\left[-\beta\gamma\left(\frac{n_{\phi_{1}}}{a_{1}}+\cdots+\frac{n_{\phi_{M}}}{a_{M}}\right)\right] (6) under the condition n_{\phi_{1}}+\cdots+n_{\phi_{M}}=N-1 . If we parameterize the partition function of an ensemble of Leibnizian strings of length N by Z(N) , it will be seen that the expression above is equal to Z(N-1)-\langle n_{\phi_{1}}\rangle_{N-1}Z(N-1) where the subscript N-1 in the expectation value indicates the fact that it is considered for an ensemble of strings of length N-1 . Hence, we obtain the following useful expression: \langle n_{\phi_{1}}\rangle=\frac{e^{-\beta\gamma/a_{1}}}{Z(N)}\left(Z(N-1)-\langle n_{\phi_{1}}\rangle_{N-1}Z(N-1)\right) (7) When considered for a single Leibnizian string if a view is found once, it will not be found in the sub-string when the corresponding letter is removed. However, we are considering an ensemble of Leibnizian strings, so it can be found in others as well. What this means is that \langle n_{\phi_{1}}\rangle_{N-1} is not trivially zero. In the large N limit, we can write \langle n_{\phi_{1}}\rangle\approx\langle n_{\phi_{1}}\rangle_{N-1} . Moreover, the chemical potential ( \mu ) is expressed as e^{\beta\mu}=Z(N-1)/Z(N) . When we solve the equation above under these considerations, we obtain the final result of this Section: \langle n_{\phi_{1}}\rangle=\frac{1}{e^{\beta(\gamma/a_{1}-\mu)}+1} (8) Now we have shown that Leibnizian strings exhibit fermionic behavior. The important step from a Leibnizian string to this expression is to realize that monads are defined by their views. The expectation value of the occupation number is that of a view, and the corresponding energy-like term is \gamma/a_{1} . To iterate, \gamma is the proportionality constant that relates the BSD variety to energy, and a_{1} is the radius of that view, or its absolute indifference value, in other words. Similar calculations are also valid for the occupation number of other views. Hence, one can drop the subscript ‘ 1 ’ in the Equation above. 7 Multiway Path-Sums and the S -Matrix The multiway system with Leibnizian strings is a purely symbolic system. What is the physical abstraction of such a formal system? In this regard, a Leibnizian string consisting of N characters can be interpreted as a N -fermion system, where each character (fermion) occupies a distinct neighborhood (state). This serves as the analogue of the Pauli exclusion principle for character strings. Moreover, besides the fermion-like strings, the multiway system carries a causal structure, which comes from state transitions facilitated via a given set of rewriting rules. Hence, transitions between strings (which constitute states of the multiway system) can be thought of as scattering processes between in-coming and out-going N -fermion states. To obtain the above-mentioned scattering amplitudes, we shall construct a multiway path-sum based on an action defined over a sequence of Leibnizian strings, and then use that to compute S -matrices corresponding to unitary transformations. First, we define the action on Leibnizian paths in the multiway system: Definition 7.1 (Action for Leibnizian paths (Adapted from [ 22 ] )) . Given a Leibnizian path of the form of a_{1}\to a_{2}\to\cdots\to a_{n} , where the a_{i} are nodes/vertices on the multiway graph, the action along this path is defined as {\cal S}\,(a_{1}\to a_{2}\to\cdots\to a_{n})=-\sum_{i=1}^{n-1}\variety(a_{i}) for n>1 . For example, given a path from a\to b , the action \mathcal{S}(a\to b)=-\variety(a) ; or, given \mathcal{S}(a\to b\to c)=-\variety(a)-\variety(b) . The use of minus sign in the definition will become clear in the next subsection. Transition amplitudes between string states are computed using a discrete path-sum defined akin to the Feynman path integral. Path integrals over multiway systems have been discussed before in [ 61 , 31 ] . The construction we use here is based on the BSD variety over a sequence of Leibnizian strings. Hence, the summand in the path-sum is \exp(i\mathcal{S}/k) , where \mathcal{S} is the action defined above. A real dimensionless coupling constant ( k ) generalizes the reduced Planck’s constant ( \hbar ). In what follows, the elements of the S -matrix encode transition amplitudes that capture the evolution of strings under symbolic substitution rules. Next, we define the S -matrix as follows: Definition 7.2 ( S -matrix) . The elements of the S-matrix are defined as \langle\text{out}|\text{in}\rangle=\sum_{\gamma}\omega(\gamma)\,e^{i\mathcal{S}(\gamma)/k} (9) This is the transition amplitude of obtaining |\text{out}\rangle beginning with |\text{in}\rangle , the sum is evaluated on every physical path \gamma connecting ‘in’ and ‘out’ words, \mathcal{S}(\gamma) is defined in Definition 7.1 and \omega(\gamma) is a suitable \mathbb{R} valued weight function, which may be constant, for paths. Normalization of transition amplitudes can be done by choosing the weight \omega(\gamma) accordingly. The transition amplitude vanishes for words that are not connected by causal paths in the multiway system since the weights \omega are identically zero in that case. Note that the use of the term ‘ S -matrix’ here is not intended in the sense of quantum field theory. Instead, we used the term in order to indicate transitions between in-words and out-words corresponding to string transformations. Remark 7.1 . When we think about the path integral representation of standard non-relativistic quantum mechanics (for example, see [ 46 ] ), the path weights are the same for every path, and it is the action whose evaluation will be different on different paths. However, in our path-sum here, the path weights are \mathbb{R} -valued free parameters. As we shall see in the case of the Hadamard gate, we also need negative weight values. The only case where we can have all \omega(\gamma)>0 on existing paths is the case of what we call the non-interacting case, meaning that there are only single paths from a definite in-word to a definite out-word. In that sense, the combinatorial path-sum defined here is a more general structure than the strict counterpart of a path integral. The in-words and out-words are elements of a discrete space that generalizes conventional vector spaces. More specifically, the character strings we use above are elements of a {\mathbb{Z}}- module. Modules over rings are natural algebraic structures that go beyond vector spaces over fields. For the discrete setting employed here, this is realized via direct sums of abelian groups. Consider a string w of length l , with characters c_{i} in position i\in\{1,2,...,l\} w=c_{1}\,c_{2}\,\cdots c_{l} Each c_{i} is an element of a finite character set of cardinality n . Upon endowing this set with modular arithmetic, it maps to the cyclic abelian group {\mathbb{Z}}_{n} . Then, we have: w\in\bigoplus_{i=1}^{l}\,{\mathbb{Z}}_{n} where the right-hand side is a direct sum of l copies of {\mathbb{Z}}_{n} , which itself is a {\mathbb{Z}}- module of order n^{l} . If the multiway system consists of strings of different lengths, then the choice of l is made based on the string of maximum length (which is always a finite positive integer). Furthermore, for our purposes here, we only work with character strings that are symmetric under cyclic permutations. Therefore, one has to additionally quotient the module above with cyclic permutations over strings. Now, over any {\mathbb{Z}}- module M , one can define a symmetric {\mathbb{Z}}- bilinear complex-valued form: \langle\cdot\,,\,\cdot\rangle\,:\,M\times M\to{\mathbb{C}} This replaces the notion of an inner product over a vector space. In our case, this map is specified as in Equation ( 9 ), and enables the computation of the transition amplitude between in-words and out-words. Note that the map in Equation ( 9 ) is a partial map (with respect to the module of strings) since its definition makes use of causal paths of the given multiway system. What kind of compositional properties do the S -matrices defined by the map in Equation ( 9 ) admit? Since edge weights in the multiway graph are free parameters, constraints on these weights determine how successive S -matrices in the multiway system compose, and the ensuing associativity of the product. We will now solve these constraints to show that matrix multiplication of the kind \displaystyle\sum_{c}\langle w_{out}|w_{c}\rangle\langle w_{c}|w_{in}\rangle=\langle w_{out}|w_{in}\rangle (10) is satisfied as a construct on the multiway system such that the S -matrix obtained from paths traversing several layers of the multiway system is identical to that obtained by matrix multiplication of S -matrices associated to intermediate layers. First, let us consider three successive multiway layers. See Figure 4 . The incoming word is denoted by the index i , the outgoing word is denoted by the index j , and the word in the middle layer is denoted by c . We compute the j,i component of the S -matrix. For this, the index c runs over all words in the intermediate layer. For this three-layer setup, Equation ( 10 ) yields the following: \sum_{c}\omega_{jc}\omega_{ci}e^{i(S_{ci}+S_{jc})/k}=\sum_{c}\omega_{jci}e^{i(S_{ci}+S_{jc})/k} (11) where we have used the notation \omega_{ci}=\omega(\gamma_{ci}) , \omega_{jc}=\omega(\gamma_{jc}) and \omega_{jci}=\omega(\gamma_{jci}) . Likewise, the subscripts appearing in terms referring to the action, denote paths over which the action is evaluated. A straightforward solution to Equation ( 11 ) happens to be \displaystyle\omega_{jc}\;\omega_{ci}=\omega_{jci} (12) That is, the weight of a composite path is simply the product of multiway edge weights (viewed as irreducible paths). This solution ensures that the S -matrix obtained from paths traversing several layers of the multiway system is identical to that obtained by matrix multiplication of individual S -matrices constructed from each of the intermediate layers. That is, matrix multiplication is now guaranteed as a non-trivial composition obtained exclusively from operations on the multiway system. Furthermore, when more than one intermediate level is involved, where each level is parameterized by index c_{i} for i=1,\ldots,n , the above solution generalizes to \displaystyle\omega(\gamma)=\omega_{jc_{n}\ldots c_{1}i}=\omega_{jc_{n}}\omega_{c_{n}c_{n-1}}\cdots\omega_{c_{2}c_{1}}\omega_{c_{1}i} (13) The above also ensures that the composition of S -matrices is associative. Figure 4: An illustration of a three-layer system. An in-word is denoted with i and an out-word with j . The elements of the second layer are denoted with labels c , which one sums over. Two remarks are in order here: Remark 7.2 . Regarding the matrix entries that constitute the S -matrix, the action \mathcal{S}(\gamma) along a path \gamma is fully determined by the words / strings that specify the path \gamma . However, the edge weights and, correspondingly, the path weights \omega(\gamma) are free parameters. This yields a family of S -matrices (not necessarily unitary). The multiway system in fact encodes multiple S -matrices between any fixed set of in-words and out-words. A specific choice of a S -matrix can be extracted only after fixing the edge weights, which is what we shall show in the next section. Remark 7.3 . If there are two different multiway systems that share the same causal structure (up to, say, some order of evolution steps), then their respective S -matrices, corresponding to the same multiway layers with identical connectivity, will be related in a specific way. This is because S -matrices constructed from two successive layers of a multiway system decompose into a product of the matrix of path weights \omega_{ji} and a diagonal matrix with entries e^{i\mathcal{S}_{i}/k} , where j runs over all in-words \langle w_{out}|w_{in}\rangle_{ji}=\omega_{ji}\;(e^{i\mathcal{S}_{i}/k})_{ii} (no Einstein summation implied above). In this case, the form of the matrix of weights \omega_{ji} is the same for both S -matrices, meaning that non-zero entries are in the same positions of the weight matrices. Only the diagonal matrix differs with entries of the form e^{i\mathcal{S}_{i}/k} . Furthermore, successive S -matrices compose via matrix multiplication. Hence, respective S -matrices, associated with multiway systems having an identical causal structure, will have a similar structural form. 7.1 Two-Dimensional S -Matrices: Non-Interacting We begin with the construction of the simplest type of S -matrices: 2D and without interactions. For this we consider two in-words and two out-words. In the non-interacting case, an in-word connects to one and only one out-word. For instance, when the connectivity graph is \{1_{in}\to 1_{out},\;2_{in}\to 2_{out}\} (the case \{1_{in}\to 2_{out},\;2_{in}\to 1_{out}\} is also non-interacting, as we will see at the end of this subsection), the S -matrix takes the form: U=\begin{pmatrix}\omega_{11}e^{i\mathcal{S}_{1}/k}&0\\ 0&\omega_{22}e^{i\mathcal{S}_{2}/k}\end{pmatrix}. (14) where \omega are real-valued weights. Unitarity requires that \omega_{11}^{2}=\omega_{22}^{2}=1 . We choose the values as one. Hence the S -matrix for non-interacting case becomes: U=\begin{pmatrix}e^{i\mathcal{S}_{1}/k}&0\\ 0&e^{i\mathcal{S}_{2}/k}\end{pmatrix}. (15) Expressing this S -matrix as a time-evolution operator of a discrete-time system U=\exp(-iH\Delta t) yields the Hamiltonian: H=\frac{1}{\Delta t}\begin{pmatrix}-\mathcal{S}_{1}/k&0\\ 0&-\mathcal{S}_{2}/k\end{pmatrix}. (16) Notice that in order to make the Hamiltonian positive definite, we need to define the action calculated on the words 1 and 2 as the negative of the BSD variety of those words. This motivates the use of variety as a measure of potential energy. In [ 51 , 52 ] Smolin also uses variety as a form of potential energy. Up to a global phase factor, the general form of a 2D non-interacting S -matrix can be written in one of the following forms: U=\begin{pmatrix}1&0\\ 0&e^{i\alpha}\end{pmatrix},\quad\text{or}\quad U=\begin{pmatrix}0&1\\ e^{i\alpha}&0\end{pmatrix} (17) for some suitable values of the phase \alpha . The second one above is obtained from the first one if we change the order of in-words, that is, if the connectivity data is \{1_{in}\to 2_{out},\;2_{in}\to 1_{out}\} . When \alpha=\pi/4 one obtains a realization of the \pi/8 -gate. 7.2 Two-Dimensional S -Matrices: Interacting Now, we discuss 2D interacting S -matrices. We add edges to the multiway graph that constitute interactions between words. Such as, between in-1 and out-2 or in-2 and out-1 words. However, there is a subtle detail here. If the interaction is one-sided, for example, if in-1 and out-2 are connected, but in-2 and out-1 are not connected, or vice versa, the off-diagonal elements must vanish. The main reason is the transpose operation in computing the inverse of unitary matrices. More generally, for an interacting system of N in-words and N out-words, the i,j element of a S -matrix, which is also unitary, will be non-zero if and only if the j,i element is non-zero. That is, the interaction has to be mutual at the level of the multiway system to ensure unitarity: if in- j and out- i are path-connected, then in- i and out- j are also path-connected. When we consider an interacting 2D S -matrix, every in-word is connected to every out-word. The S -matrix then reads as follows: U=\begin{pmatrix}\omega_{11}e^{i\mathcal{S}_{1}/k}&\omega_{12}e^{i\mathcal{S}_{2}/k}\\ \omega_{21}e^{i\mathcal{S}_{1}/k}&\omega_{22}e^{i\mathcal{S}_{2}/k}\end{pmatrix}. (18) Imposing unitarity gives: U=\begin{pmatrix}\sqrt{1-\lambda^{2}}e^{i\mathcal{S}_{1}/k}&\lambda e^{i\mathcal{S}_{2}/k}\\ -\lambda e^{i\mathcal{S}_{1}/k}&\sqrt{1-\lambda^{2}}e^{i\mathcal{S}_{2}/k}\end{pmatrix} (19) for a real parameter \lambda\in[-1,1] . Here, \lambda is a free parameter that controls the magnitude of interactions. See Figure 5 for the anatomy of 2D systems. Figure 5: Anatomy of 2D systems. (a) non-interacting case, (b) interacting case. All the nodes are supposed to be Leibnizian strings. Note that there is a symmetry of permutation of words. So the case when in-1 and out-2, and in-2 and out-1 are connected is also a non-interacting set-up. Up to a global phase factor, we can then write U in Equation ( 19 ) as follows: U=\begin{pmatrix}\cos(\theta)&-\sin(\theta)e^{i\alpha}\\ \sin(\theta)&\cos(\theta)e^{i\alpha}\end{pmatrix} (20) 7.3 Higher Dimensional S -Matrices Let us now consider more general forms of S -matrices consisting of n in-words and m out-words. We begin with square S -matrices. In general, due to the structure of the S -matrix, for a square unitary matrix U (that is, n\times n ) we can write the matrix elements as follows: U_{ij}=\omega_{ij}e^{i\mathcal{S}_{j}/k} (21) Each column vector c_{i} of U consists of elements \{\omega_{li}\}_{l} multiplied with the constant phase e^{i\mathcal{S}_{l}/k} . The unitarity requirement of U implies c_{i}^{\dagger}c_{j}=\delta_{ij} . Hence, if we write U=\omega\;\text{diag}(e^{i\mathcal{S}_{1}/k},e^{i\mathcal{S}_{2}/k},\ldots,e^{i\mathcal{S}_{n}/k}) (22) it is seen that the \omega matrix is orthogonal. The general 3\times 3 orthogonal \omega matrix can be expressed as follows [ 27 ] (without the factor \pm 1 ): \omega=\pm\begin{pmatrix}\cos\psi\cos\phi-\cos\theta\sin\phi\sin\psi&\cos\psi\sin\phi+\cos\theta\cos\phi\sin\psi&\sin\psi\sin\theta\\ -\sin\psi\cos\phi-\cos\theta\sin\phi\cos\psi&-\sin\psi\sin\phi+\cos\theta\cos\phi\cos\psi&\cos\psi\sin\theta\\ \sin\theta\sin\phi&-\sin\theta\cos\phi&\cos\theta\end{pmatrix} (23) where we used the Euler angles to denote a generic element of SO(3) and added the factor \pm 1 , in order to construct elements of O(3) . Hence, the generic S -matrix we can represent is expressed as follows: U_{3\times 3}=\omega\,\text{diag}(e^{i\mathcal{S}_{1}/k},e^{i\mathcal{S}_{2}/k},e^{i\mathcal{S}_{3}/k}) (24) In particular, the 4\times 4 S -matrices have the following forms: \displaystyle U_{4\times 4} \displaystyle=\begin{pmatrix}\omega_{11}e^{i\mathcal{S}_{1}/k}&\omega_{12}e^{i\mathcal{S}_{2}/k}&\omega_{13}e^{i\mathcal{S}_{3}/k}&\omega_{14}e^{i\mathcal{S}_{4}/k}\\ \omega_{21}e^{i\mathcal{S}_{1}/k}&\omega_{22}e^{i\mathcal{S}_{2}/k}&\omega_{23}e^{i\mathcal{S}_{3}/k}&\omega_{24}e^{i\mathcal{S}_{4}/k}\\ \omega_{31}e^{i\mathcal{S}_{1}/k}&\omega_{32}e^{i\mathcal{S}_{2}/k}&\omega_{33}e^{i\mathcal{S}_{3}/k}&\omega_{34}e^{i\mathcal{S}_{4}/k}\\ \omega_{41}e^{i\mathcal{S}_{1}/k}&\omega_{42}e^{i\mathcal{S}_{2}/k}&\omega_{43}e^{i\mathcal{S}_{3}/k}&\omega_{44}e^{i\mathcal{S}_{4}/k}\end{pmatrix} (25) Here \omega\in O(4) . A few definitions will be useful in what follows. Definition 7.3 (Fully interacting system) . A fully interacting system (as a subsystem of the multiway system) is a complete bipartite graph (as a subgraph of the multiway graph). That is, all of the n in-words in the designated S -matrix construction are connected to all of the m out-words. In the presence of n in-words and m out-words, the dimensions of the S -matrix is m\times n . In general, the S -matrix will be non-square. Hence, the definition of unitarity requires more care. Note that when we define the S -matrix, the columns are multiplied by a pure phase function of the form \exp(i\mathcal{S}_{i}/k) , where \mathcal{S}_{i} is proportional to the BSD variety of the i^{th} in-word. When we neglect these pure phases, the remaining matrix that consists of the \omega ’s will be orthogonal since these parameters are real valued. Hence, it is sufficient to consider orthogonal matrices and to include pure phases in the columns of these matrices. Generalization of unitarity or orthogonality to non-square matrices is known as semi-unitary or semi-orthogonal matrices, respectively. Definition 7.4 (Semi-unitary matrix) . If U is a m\times n matrix that satisfies U^{\dagger}U=I_{n} , we say that U is a semi-unitary matrix. In the literature, the above definition can either be U^{\dagger}U=I_{n} or UU^{\dagger}=I_{m} . However, because we consider S as acting on the initial states, we have chosen the specific form of the definition. Definition 7.5 (Semi-orthogonal matrix) . If U is a m\times n matrix that satisfies U^{T}U=I_{n} , we say that U is a semi-orthogonal matrix. A general form of the S -matrix (possibly rectangular) will have entries as follows. Consider a two layer system, suppose there are n in-words and m out-words. If the i^{th} in-word is connected to j^{th} out-word, then the j,i element of the S -matrix is of the form \omega_{ji}e^{i\mathcal{S}_{i}/k} , where \omega_{ji} is a free \mathbb{R} -valued parameter. If these words are not connected, then the j,i element of the S -matrix is zero. The analogous pattern holds for constructions using more than two layers of the multiway system (in that case one has to consider path weights and the action evaluated along a path). As an example, let us consider a two by three system. This system has two in-words and three out-words. The S -matrix will be of the following form: U=\begin{pmatrix}\omega_{11}e^{i\mathcal{S}_{1}/k}&\omega_{12}e^{i\mathcal{S}_{2}/k}\\ \omega_{21}e^{i\mathcal{S}_{1}/k}&\omega_{22}e^{i\mathcal{S}_{2}/k}\\ \omega_{31}e^{i\mathcal{S}_{1}/k}&\omega_{32}e^{i\mathcal{S}_{2}/k}\end{pmatrix}. (26) Equation U^{\dagger}U=I_{2} can be solved since there are enough parameters. Hence, in this case we can find a semi-unitary S -matrix. We now consider a three by two system. This system consists of three in-words and two out-words. The S -matrix is as follows: U=\begin{pmatrix}\omega_{11}e^{i\mathcal{S}_{1}/k}&\omega_{12}e^{i\mathcal{S}_{2}/k}&\omega_{13}e^{i\mathcal{S}_{3}/k}\\ \omega_{21}e^{i\mathcal{S}_{1}/k}&\omega_{22}e^{i\mathcal{S}_{2}/k}&\omega_{23}e^{i\mathcal{S}_{3}/k}\end{pmatrix}. (27) If this matrix is to be semi-unitary, then the matrix equation U^{\dagger}U=I_{3} should be satisfied, where I_{3} is the 3\times 3 identity matrix. However, there are no solutions for this equation. That is, unitarity does not hold in this case, no matter what choice of parameter values are taken. 7.4 A Comment on Restoring Unitarity Typically, unitarity is associated to a system being closed. Whereas, when unitarity breaks down, it is suggestive of an open system. As we shall see, if there are unconnected words, we cannot have a unitary S -matrix. Also, in cases where the number of words decreases in the next layer, we might not have a unitary S -matrix. On the other hand, if the number of words in a layer stays the same or increases, we can always have (semi)-unitary S -matrices. Let us now discuss how the unitarity of S -matrices can be restored by extending the system. As an example, consider the multiway system represented in Figure 6 that relates two qubits to a single qubit. That means we have four in-words and two out-words. The quantum gate that arises from the multiway system in Figure 6 can map |00\rangle\to|0\rangle and |11\rangle\to e^{i\alpha}|1\rangle , and |01\rangle\to 0,|10\rangle\to 0 . Hence, the S -matrix cannot be unitary for such a multiway system. That process describes a non -interacting system. If we would like to associate an extension to this system, it can be thought of as consisting of two in-words that do not interact with the rest of the system in any way. In cases where there is at least one unconnected in-word or out-word, the system on its own does not yield a unitary S -matrix. That would mean either at least one zero column or row. Figure 6: A non-interacting system with four in-words and two out-words. In Figure 7 we see an example of a situation where a rewriting rule does not match at least one word in a multiway system. When we consider the two consecutive layers, we can write U=U_{2}U_{1} where U_{1} is unitary. However, U_{2} cannot be a unitary matrix, since the second column is identically zero. The zero column of U_{2} removes all the contribution from the second word of the second layer to the composite S -matrix U due to the structure of matrix multiplication. Figure 7: An example for a multiway system where a re-write rule does not match at least one word. Every word in the illustration is supposed to be Leibnizian. For such a case, we can consider a transition matrix from the first layer to the third layer. Because there is only one path that connects a given in-word to any out-word, the S -matrix will be as follows: U=\begin{pmatrix}\Omega_{11}e^{i(\mathcal{S}_{A}+\mathcal{S}_{C})/k}&\Omega_{12}e^{i(\mathcal{S}_{B}+\mathcal{S}_{C})/k}\\ \Omega_{21}e^{i(\mathcal{S}_{A}+\mathcal{S}_{C})/k}&\Omega_{22}e^{i(\mathcal{S}_{B}+\mathcal{S}_{C})/k}\end{pmatrix} (28) where we used \Omega_{ij} instead of \omega_{ij} in order to indicate that we have an S -matrix that relates non-adjacent layers. In terms of complex phases, this form is equivalent to a 2\times 2 interacting system. Hence, even though there is a word in the second layer where a rewriting does not match, one can find a unitary transition matrix that connects the first and third layers. On the other hand, there can be no completely zero rows in the S -matrix which is because when we generate the multiway system an out-word should have been found out via application of rewriting rule that is applied to at least one of the in-words. From now on we suppose there are no completely zero columns of S -matrix in addition to existence of no zero rows. Suppose now that there are n in-words and m out-words and there are no unconnected words considering these adjacent layers in the multiway system. The shape of S -matrix is m\times n . Hence, the matrix equation U^{\dagger}U=I_{n} consists of n^{2} individual equations. However, the number of independent equations is n(n+1)/2 . On the other hand, the number of free parameters in U is mn . Hence, the matrix equation can be solved if mn\geq n(n+1)/2\implies 2m\geq n+1\implies m\geq(n+1)/2 . So, if the number of in-words ( m ) satisfies this inequality we can find U such that U^{\dagger}U=I_{n} . The number of free parameters of U after the condition of (semi)-unitarity is found as follows: mn-\frac{n(n+1)}{2}=\frac{n}{2}(2m-n-1). (29) For the case of a square S -matrix where m=n the number of free parameters is n(n-1)/2 . Since n\geq 1 the number of free parameters is a non-negative integer. However, if there are quite less out-words than in-words, such that the inequality is not satisfied, in other words, if the multiway system quickly decreases in number of words in the next layer, equation U^{\dagger}U=I_{n} cannot be solved due to lack of free parameters. These free parameters are path weights ( \omega ) that we have discussed above. The most economic way to solve the problem is to introduce \Delta m auxiliary words on the second layer such that 2(m+\Delta m)\geq n+1 . The minimum number of \Delta m hence satisfies \Delta m\geq(n+1)/2-m . If n is even \Delta m_{\text{even}}=n/2+1-m and if n is odd \Delta m_{\text{odd}}=(n+1)/2-m . If U denotes the S -matrix that relates in-words and out-words and U_{e} is a suitable matrix that has the shape \Delta m\times n we can write the composite U_{c} matrix as follows: U_{c}\equiv\begin{pmatrix}U\\ U_{e}\end{pmatrix} (30) where U_{e} is considered as a part of the composite U_{c} matrix that provides a means to capture information loss. The matrix U_{c} has enough parameters that it can be put in to a (semi)-unitary matrix form. When we write U_{c}^{\dagger}U_{c}=I_{n} we see that the parameters of U and U_{e} are not independent of each other. U has mn free parameters and U_{e} has \Delta m\,n free parameters, and in total there are enough free parameters in U_{c} , which guaranties that we can solve U_{c}^{\dagger}U_{c}=I_{n} . If we consider U_{e} as a function of U , that means that the parameters of U_{e} can be solved. One can also do the reverse and try to solve U as a function of U_{e} . Hence, the unitarity of U_{c} imposes restrictions on the connection structure of the auxiliary words in the multiway system. In the next layer, we should consider \Delta m auxiliary words. In other words, the rewriting rule should not match these auxiliary words. That means that some columns of the S -matrix for the next layer are zero, and the existence of auxiliary words has no effect on the S -matrix when we consider one more layer and matrix product of S -matrices. This is expected because in Definition 7.2 we consider Leibnizian paths that connect in and out-words. Hence, words in intermediate layers where the rewriting rule does not match are not included in the calculation of the matrix. In general, the multiway system will produce many S -matrices that are not unitary. This may be useful for considering operators related to open systems, including non-unitary ZX diagrams. On the other hand, when it is necessary to work with unitary transition matrices, then the prescription for restoring unitarity described above can be implemented: namely, one considers composite U_{c} matrices as in Equation ( 30 ) and specifies the extension of the system at each step where 2m