<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Italian Conference on Theoretical Computer Science, Palermo, Italy, September</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Termination of Rewriting on Reversible Boolean Circuits as a Free 3-Category Problem</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Adriano Barile</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefano Berardi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Luca Roversi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Turin</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>1</volume>
      <fpage>3</fpage>
      <lpage>15</lpage>
      <abstract>
        <p>Reversible Boolean Circuits are an interesting computational model under many aspects and in diferent ifelds, ranging from Reversible Computing to Quantum Computing. Our contribute is to describe a specific class of Reversible Boolean Circuits - which is as expressive as classical circuits - as a bi-dimensional diagrammatic programming language. We uniformly represent the Reversible Boolean Circuits we focus on as a free 3-category Tof . This formalism allows us to incorporate the representation of circuits and of rewriting rules on them, and to prove termination of rewriting. Termination follows from defining a non-identities-preserving functor from our free 3-category Tof into a suitable 3-category Move that traces the “moves" applied to wires inside circuits.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Reversible Boolean Circuits</kwd>
        <kwd>Reversible Computing</kwd>
        <kwd>n-Categories</kwd>
        <kwd>Polygraphs</kwd>
        <kwd>Rewriting</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        The class of Reversible Boolean circuits (from now on, RBC) constitutes an interesting
computational model, for many reasons. We name just some of them: once implemented, they
may help to reduce electronic devices energy consumption [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], easing miniaturization, due to a
limited heat dissipation; they are at the core of cryptographic block cyphers analysis [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], and of
quantum circuits synthesis [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. Moreover, reversibility means that if we execute the circuits
in the opposite direction, e.g. bottom-up instead of top-down, we are able to recover the input.
RBC can nevertheless simulate all non-reversible classical circuits [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>N
1− 
 
T2
 +</p>
      <p>T3
  +
(a) Generators of RBC and their semantics
T3</p>
      <p>T3
⇛</p>
      <p>T3
T3</p>
      <p>⇛
(b) An example of reduction on a Reversible</p>
      <p>
        Boolean Circuit
Our focus is to study a class of RBC in the lines of [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], i.e. as a bi-dimensional diagrammatic
formal language built by series and parallel composition of the generators; the diagrams can
be rewritten by rewriting rules preserving generator interpretation, as given in Fig. 1a. The
inputs of the generators are on top. We assume , ,  ∈ {0, 1}, and from left to right we have
the gates: “Identity”, “Swap”, “Negation” (which we also call “Tofoli-one ”), “Tofoli-two ”, and
“Tofoli-three ”. We denote the boolean XOR operation with +; the AND is by juxtaposition.
Tofoli-two performs a controlled negation (CNOT): when the controller  is set to 1,  is negated,
and is unchanged otherwise. The input  is always carried over as an output. Tofoli-three can
be used to build conjuctions: if  = 0, (, , 0) ↦→ (, , ).
      </p>
      <p>All classical boolean functions can be expressed in RBC, provided we add extra inputs/outputs
in order to make the boolean functions invertible: in a reversible setting, the number of ouputs
must be always equal to that of inputs.</p>
      <p>All gates depicted in Fig. 1a represent invertible functions; moreover, they are self-inverse,
i.e., if they yield an identity when applied twice.</p>
      <p>Our goal in the long term is to answer specific domain questions related to the reversible
language purposes. Such questions in the short term require to answer more classical questions
about rewriting.</p>
      <p>
        An example of specific reversibility question is: “Can we partition RBC into equivalence
classes to find those containing the most eficient circuits, according to measures which depend
on ancillae or the number of generators involved?”. We recall that “ancillae” is a technical
notion, to identify variables used as temporary storage in a circuit  ∈ RBC. Ancillae allow 
to compute the desired function while preserving the possibility of reverting the computation.
A good reference to frame the role of ancillae in various contexts can be [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>Another specific reversibility question can be: “How can we decide the equivalence of
reversible circuits that we obtain by compilers which translate classical boolean circuits into
reversible ones, driven by some heuristic aimed at optimizing specific parameters of the output?”.
The heuristic in [8] is just an example, of the many proposed in the literature, whose purpose,
for instance, is to obtain good translations minimizing the quantity of ancillae.</p>
      <p>Answering questions like the two above requires to formally and unambiguously know the
representatives of equivalence classes in RBC. This amounts to asking basic questions about
rewriting, such as: “What is and how do we get normal forms of RBC?”
Contributions. A natural strategy to answer the last question is to look for normal forms w.r.t.
an interpretation-preserving rewriting on the circuits of RBC. Fig. 1b suggests what we mean
by a simple example, in which we move a Tofoli-three gate next to another Tofoli-three so that
they annihilate each other, because Tofoli-three are self-inverse operators. All base reversible
gates are self-inverse, while, in general, reversible circuits do not need to be self-inverse.</p>
      <p>Rewriting bi-dimensional diagrammatic formal languages has well-know dificulties, mainly
concerning their relations with the usual (linear) syntaxes expressing the same problem.</p>
      <p>
        We here explore the use of a free 3-category to represent both the reversible circuits and
the rewriting rules on them. We build over Burroni’s work [9], who introduced the notion
of polygraphs to express algebraic theories and their reductions. Lafont [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] used
bidimensional diagrammatic syntax on product categories and an informal measure on them to prove
termination results on several classes of boolean functions; Guiraud used 3-polygraphs and
diagrammatic reasoning to represent rewriting of circuit-like objects in [10, 11], together with
a formal method to build terminating measures. We focus on freely generated 3-categories
instead of polygraphs, to have access to the rewriting paths as 3-morphisms; we call “Tofoli
3-category” the free 3-category we introduce, and we denote it with Tof .
      </p>
      <p>We remind the reader that an Abstract Rewriting System (ARS) is said to be terminating when
there are no infinite chains of subsequent reductions, i.e. all reductions eventually yield a
(not necessarily unique) normal form. We show termination of the rewriting system in Tof :
termination follows from defining a functor from Tof into a suitable 3-category Move of moves
applied to wires inside circuits.</p>
      <p>We remark that the functor we introduce simplifies the functorial and diferential
interpretations in [12, 10, 11]: our approach does not require to identify both a non-increasing measure
on diagrams, which recalls a current flowing, and a strictly decreasing measure, connected to
the “current”, which recalls heat, generated by the “current” itself. We just need to identify a
decreasing measure on a monoid of strings. The measure keeps track of the “moves” being
applied to each individual wire, and assigns them a cost.</p>
      <p>
        Plan of our work. We sketch the definition of 3-categories (§2), then we provide a
bi-dimensional graphic representation for 3-categories representing circuits (§3). Next, we
formally define the free 3-category Tof (§4), and a functor from Tof to a 3-category Move of
movements through circuits (§5),which we show to be a decreasing measure of reductions.
Eventually we prove termination of reductions on RBC (§6). The reduction rules we utilized are
syntactic in nature; the normal form under algebraic equivalences remains an open problem [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. 3-Categories, 3-Functors and Free 3-Categories</title>
      <p>In this section we will briefly go over the definition of -categories. We provide enough details
for the purposes of representing circuits and syntactic reductions on them (level 3). For a
complete description of higher categories we refer to e.g. [13, 14].</p>
      <p>
        Motivations for using categories. The literature using product categories to describe
circuits is extensive; we follow Burroni and Guiraud and use higher category theory to describe
reduction systems on algebraic structures, with particular attention to circuits [
        <xref ref-type="bibr" rid="ref6">9, 11, 6</xref>
        ]. The
“multi-level” structure of -categories provides a suitable model for bi-dimensional objects such
as circuits; the third level efortlessly captures the notion of a rewriting system on circuits.
Moreover, the use of categories allows us to reason up to “bureaucratic” identities such as those
invoked when shortening/lengthening the wires by adding/removing identities.
      </p>
      <p>We give an anticipation on our 3-categorial model.</p>
      <p>• The “base” level will contain a single token object * representing the empty space between
wires in a circuit.
• A first level will contain input and output wires, with a “monoidal” product to generate
bundles of multiple wires. In our model, we will consider a single wire as a formal cell
* → * between two “empty spaces” * .
• A second level will contain circuits as morphisms between  input wires and  output
wires (in our context  =  because of reversibility), with appropriate series and parallel
compositions.
• A third level will contain syntactic rewriting rules, considered as morphisms between
circuits. Reductions should preserve the number of input/output wires of a circuit.</p>
      <p>We have that each level consists of morphisms, named cells, with domain and codomain (here
source and target) objects at the adjacent lower level. Source/target of a reduction is a circuit,
source/target of a circuit is a set of I/O wires, and source/target of a wire is the empty space
* . The -compositions will provide an unified entity that captures both concatenation of wires,
series and parallel composition of circuits, as well as three diferent ways to compose reductions.
Also, the properties of 0-, 1-, 2-composition will capture equations between circuits and between
reductions. The levels up to the second one yield a description of circuits isomorphic to the
product categories formalization.</p>
      <p>We now provide an equational definition for -categories following [15].</p>
      <p>Definition 1 (-categories). A (strict) -category  contains the following.
• A list of sets , 0 ≤  ≤ , called levels, whose elements are called -cells.
• The maps s, called -source, and t, called -target, that associate to each -cell  with
0 ≤  &lt;  ≤  two -cells s(), t() we respectively call the -source and the -target
of ;
• The -cells  ⋆ , defined for all -cells ,  and indices 0 ≤  &lt;  ≤  such that
t() = s(), called the -composition of  and , with -source/target given by:
1. s( ⋆ ) = s() and t( ⋆ ) = t() when 0 ≤  ≤ ;
2. s( ⋆ ) = s() ⋆ s() and t( ⋆ ) = t() ⋆ t() when  &gt;  &gt; .</p>
      <p>The -composition is denoted in diagrammatic order (left-to-right).</p>
      <p>The data above define an -category if they satisfy the following further conditions.
• Globularity.</p>
      <p>s− 2(s− 1()) = s− 2(t− 1()),</p>
      <p>t− 2(s− 1()) = t− 2(t− 1())
for all -cells  with 2 ≤  ≤ . Globularity means that all -cells connect two ( − 1)-cells
with the same ( − 2)-source and ( − 2)-target.
• Associativity of each ⋆.
• Local Units. For all -cells  with 0 ≤  &lt;  ≤ , there exists an identity -cell id,,,
or id for short, such that s(id,,) = t(id,,) = , the lower index source/targets
of id,,are those of , and for all -cells  we have
– if  = s( ) then id,, ⋆  =  , and
– if  = t( ) then  ⋆ id,, =  .</p>
      <p>Any -composition of -identity is a -identity, for all 0 ≤  &lt;  ≤ .
• Exchange Rule.</p>
      <p>for , , ,  
 ≤ .</p>
      <p>( ⋆   ) ⋆ ( ⋆   ) = ( ⋆   ) ⋆ ( ⋆   )
-cells such that the above compositions are defined and all 0 ≤  &lt;  &lt;</p>
      <p>In order to build the measure that proves termination of circuits reductions, we need the
notion of 3-functor which we define for the general case.</p>
      <p>Definition 2 (-functor). Let ,  be -categories. An -functor  :  →  is a map such
that for all 0 ≤  ≤ ,  sends -cells of  into -cells of , and such that for all -cells ,  of ,
for all 0 ≤  &lt;  ≤ , and for all -cells  we have:
1. Source/Target preservation. s ( ( )) =  (s ( )), t ( ( )) =  (t ( ))
2. Identity preservation (for -cells and ⋆ ).  (id,,) = id,, ()
3. Composition preservation.  ( ⋆ ) =  ( ) ⋆  ()
Free -Categories
In the next section, we will represent circuits and reductions on them with a free 3-category. A
free -category consists of all well-formed expressions for objects in an -category that are
generated by a set of names for cells, identities and compositions, modulo all the equations we
have for -categories.</p>
      <p>Definition 3 (Free -Categories). Let ⃗ be a signature, i.e. a list of sets ⃗ = (0, . . . , ),
with  sets of names for -cells for 1 ≤  ≤ , equipped with two maps s, t :  → − 1,
1 ≤  ≤  such that the globularity requirement is met. We define the free -category 
generated by the signature ⃗ by induction on .</p>
      <p>The 0-category 0 is just the set 0. Assume we have defined the free ( − 1)-category − 1
generated by the signature ⃗− 1 as the ( − 1)-category with levels 0, 1, . . . , − 1.
• An -generator of  is any name  ∈ − 1 such that  = 1 or  ≥ 2 and  satisfies
the Globularity condition: s− 2(s− 1( )) = s− 2(t− 1( )) and t− 2(s− 1( )) =
t− 2(t− 1( )).
• Let  be the set of -constants of , containing all -generators and all expressions
id,, denoting the -identity on , for 0 ≤  ≤  − 1,  ∈ .
• Let * be the smallest set containing  and all expressions  ⋆  such that ,  ∈ *,
0 ≤  ≤  − 1 and t( ) = s(). Source/target maps are defined on * by the
source/target equations for -categories.</p>
      <p>is defined as the -category with levels 0, . . . , − 1,  and  = */ ∼ , where ∼
is the smallest equivalence relation compatible with ⋆0, . . . , ⋆− 1 and including Associativity,
Local Units and Exchange.</p>
      <p>Alternatively, the readers who are familiar with the definition of polygraphs [ 9, 10, 12] will
notice that the free -category generated by the signature  is isomorphic to the -category
generated by the corresponding -polygraph, which itself lacks categorial structure at the -th
level [16].</p>
    </sec>
    <sec id="sec-3">
      <title>3. A Bi-dimensional Diagrammatic Syntax for 3-Categories</title>
      <p>In this section we restrict to free 3-categories with a single 0-cell * and a unique generator for
1-cell, i.e. the wire , and we describe them as formal circuits and circuit reductions, by specifying
what role the -compositions take in the context of circuits. We introduce a diagrammatic syntax
that represents such free 3-categories and the associated circuits. A great incentive to use a
bi-dimensional syntax is that diagrams actually look like circuits. We stress the fact that the
categorial setting together with a diagrammatic formalism give a thorough, compact and sound
presentation for circuital theories. We invite the reader to think of -compositions as a gluing
operator of two objects along their common -target and source, respectively.
Definition 4 (Diagrams for a free 3-category). Let us assume that  is a free 3-category with
generator sets ⃗ = (0, 1, 2), source and target maps s, t, a single 0-cell and a unique
generator for 1-cells. The diagrammatic representation of  is as follows.</p>
      <p>• Generators.
• -cells.</p>
      <p>– 0 = {*} consists of a unique 0-cell, representing a separator between input/output
wires. We depict * as a white area in the sheet of paper the diagram is drawn on.
– 1 = { } consists of a unique 1-cell, which we call a wire. A wire is a formal cell
between the two portions of sheet that it divides, both marked with * .
– Each gate in 2 is depicted as a circuit-like box with input and output wires
representing 1-source and 1-target of the circuit.</p>
      <p>2 = ¶ , . . . ,
, . . . ,
, . . . ,
, . . .© .</p>
      <p>If  is a gate with  input and output wires, we write  :  ⇒ . The diagrams
depicting gates preserve the meaning of 2-cells as formal maps between 1-cells
(wires).
– 3-cells in 3, or reductions, are written as  ⇛  . We include no diagram for
3-cells: this would involve 3-dimensional objects [10].
– The set *0 of all 0-cells is again 0 = {*} .
– The set *1 of all 1-cells consists of all possible 0-compositions ⋆0 between 1-cell
generators. Any element of *1 has the form * * · · · * or simply . . . , freely
generated as 0-composition along their common * white area.
– The set *2 of all 2-cells represents circuits, and it is obtained from gates in 2
by closure w.r.t. 0-composition ⋆0 (parallel composition, or composition along a
common * area), and 1-composition ⋆1 (sequential composition, or composition
along a common bundle of wires).
– Compositions of 2-cells.</p>
      <p>∗ Every two 2-cells are 0-composable, since they have as inputs and outputs
1-cells with the same source and target (the only 0-cell * ). The 0-composition
of 2-cells is depicted by putting the circuits next to each other along their
common * white area:   . This operation corresponds to the usual parallel
composition and is read left-to-right.
∗ 1-composition of 2-cells is defined for pairs of 2-cells such that 1-target of the
ifrst one (its output wires) is equal to the 1-source of the second one (its input
wires). 1-composition vertically stacks circuits by connecting common I/O set


of wires:</p>
      <p>. This operation corresponds to series composition and is read
top-to-bottom.
– Circuit equivalences.</p>
      <p>∗ The degenerate 1-composition id ⋆1  corresponds to prolonging the wires
of  = s1( ). The Unit rule  =  =  graphically shows that circuits
are defined independently from the length of wires.
∗ The Exchange rule ( ⋆1 ) ⋆0 (ℎ ⋆1 ) = ( ⋆0 ℎ) ⋆1 ( ⋆0 ) says that the
diagram
defines a single circuit which we can be equivalently read left-to-right, or
top-to-bottom.
• 3-cells, or circuit reductions, can be composed with ⋆0, ⋆1, ⋆2. If  :  ⇛  and  : ℎ ⇛ ,
then the compositions behave as follows.</p>
      <p>ℎ
⇛
ℎ



 ⋆ 1 
(, ℎ and ,  1-composable)

ℎ ⇛</p>
      <p>⋆ 0 
 ⇛ 
 ⋆ 2 
( = ℎ)
Remark 1. The diagrammatic notation, inspired by the string diagrams of categories, can be
treated as a full 2-dimensional syntax for product categories, as explained in [17]. Again in [17]
there is a termination result for the rewriting system where associativity, local units and the
exchange rule are understood as rewriting rules and not as equivalences, and the concepts of
squeezed form and longest normal form are introduced. In this paper, we shall limit ourselves to
reasoning on diagrams modulo the above equivalences.</p>
    </sec>
    <sec id="sec-4">
      <title>4. The Free 3-Category of Reversible Boolean Circuits</title>
      <p>
        In this section we will describe, as a free 3-category Tof , both all reversible circuits we can
obtain from the generators SWAP, NOT, CNOT (or T2, for Tofoli two), and T3 (or CCNOT), and a
particular set of reductions on such circuits. This set of gates is proven to be universal (with
ancillae) in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The 3-category Tof includes, as its 3-generators, a reduction set composed
of rules that replace each pair of consecutive SWAP or consecutive Tofoli gates by an identity,
implementing involutivity of reversible gates. We also arrange circuits in a canonical form, with
a “leaning” to moving a SWAP down, and when this is not possible, to the right. All reductions
preserve the associated boolean function.
      </p>
      <p>Definition 5 (The free 3-category Tof of Reversible Circuits). The free 3-category of Reversible
Circuits is the free 3-category specified by the following sets of 0-, 1-, 2- and 3-generators.
• 0 = {*} , 1 = { }, where : * → *
• 2 contains the following generators for reversible circuits, in this order: SWAP, NOT, T2,
T3
2 = ¶</p>
      <p>: 2 ⇒ 2, N : 1 ⇒ 1, T2 : 2 ⇒ 2, T3 : 3 ⇒ 3 ©
• 3 =  ∪  ∪  ∪ , where  contains the following permutation rules:
 =
ß
⇛
,
⇛
™
,
 contains the following annihilation rules:
 =
® N</p>
      <p>N
⇛ , TT22 ⇛
,</p>
      <p>T3
T3
⇛
 contains the following sliding rules:
 =
⎧
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎨
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎪
⎩</p>
      <p>T2
T3</p>
      <p>N
⇛
⇛
⇛</p>
      <p>N
T2
T3
,
,
,
and  contains the following Swapped Tofoli rule :
 =
ß
⇛</p>
    </sec>
    <sec id="sec-5">
      <title>5. The Interpreting 3-Functor</title>
      <p>In this section, we will define a 3-category Move of strings of “moves”, each of them
corresponding to the action of a gate on a single wire. Moves are elements of an ordered monoid
that expresses the cost of series of singular moves along the wires of the circuit. The circuits
are then measured by a componentwise order on all moves on all wires. The reduced circuit
should describe an equivalent boolean function with a reduced total cost. The interpretation
of circuits into moves will be given as a 3-functor from the free 3-category Tof of reversible
circuits and a Tofoli base to Move.</p>
      <p>Definition 6 (The ordered monoid (M, &lt;M) of moves).</p>
      <p>erated from the letters l, r, t.</p>
      <sec id="sec-5-1">
        <title>1. M is the free monoid of words gen</title>
        <p>2. We order 1, 2 ∈ M first by length, and when the lengths are the same, by the
lexicographic order induced by the following order on letters: t &lt;M r &lt;M l.</p>
      </sec>
      <sec id="sec-5-2">
        <title>3. We write &lt;M for the order on M.</title>
        <p>The letters l, r, t correspond to the three moves “left-to-right", “right-to-left" on the two
wires of a SWAP, and to the move “Tofoli" on any wire of a Tofoli circuit. From M we define a
3-category Move.</p>
        <p>Definition 7 (Move). Move is a collection of the following sets and ordered sets of -cells ,
0 ≤  ≤ 3.</p>
        <p>• 0 = {*} , a single element set.
• (1, &lt;1) is the set of all cartesian powers M for  ∈ N; the singleton M0 is the identical
1-cell, identified with the unique 0-cell * . We define an order on 1-cells as M &lt;1 M if
and only if  &lt; . We order vectors ⃗ ∈ M componentwise, with the product order &lt;M
on M.
• (2, &lt;2) is the set of all &lt;1-increasing maps  : M → M for some  ∈ N (all the
identities idM are included). Let ,  : M → M be 2-cells with the same source and
target. We define a strictly pointwise order  &lt;2  on 2-cells by:  &lt;2  if and only if
 () &lt;M () for all  ∈ M. We write  ≤ 2  for  =  ∨  &lt;2 , that is: either
 (⃗) = (⃗) for all ⃗, or  (⃗) &lt;M (⃗) for all ⃗ ∈ M.
• 3 contains all pairs  = ⟨, ⟩ of 2-cells with the same source and target M for some
, such that  ≥ 2 . There is at most one 3-cell between , , which merely signals the
existence of a ≤ 2-relation between the two functions. We think of each pair ⟨, ⟩ as a
reduction from  to . The reduction is identical if  = , it is non-identical if  &lt;2 .
The -compositions on the -cells are defined as follows.</p>
        <p>• 0-composition on 1-cells is M ⋆0 M = M+.
• 0-composition on 2-cells is the cartesian product of maps.
• 1-composition on 2-cells is the usual (sequential) composition of maps.
• 0-composition on 3-cells is defined as ⟨, ⟩ ⋆0 ⟨ ′, ′⟩ = ⟨ ×  ′,  × ′⟩.
• 1-composition on 3-cells is defined as ⟨, ⟩ ⋆1 ⟨ ′, ′⟩ = ⟨ ′, ′⟩.</p>
        <p>• 2-composition on 3-cells is defined as ⟨, ⟩ ⋆2 ⟨, ℎ⟩ = ⟨, ℎ⟩.</p>
        <p>Remark 2. The order &lt;M on words is well-founded, and in fact (M, &lt;M) is order-isomorphic to
the order (N, &lt;) on natural numbers. The order &lt;2 on maps is well-founded. In fact, each
decreasing sequence  &gt;2  ′ &gt;2  ′′ &gt;2 . . . defines a decreasing sequence ⃗( ) &gt;M  ′⃗( ) &gt;M
 ”⃗( ) &gt;M . . ., where⃗ = (, , . . . ,  ) and  is the monoid unit (empty word). Therefore, every
decresing sequence from  has length at most the number of words which are less than ⃗( ) in
M.</p>
        <sec id="sec-5-2-1">
          <title>Proposition 1. Move is a 3-category.</title>
          <p>Proof. We first prove that ⋆0, ⋆1 are increasing on 2-cells of Move. Assume  ≤ 2  ′ and  ≤ 2 ′,
and either  &lt;2  ′ or  &lt;2 ′. Then ⋆0 is increasing: for all  ∈ M = s1 ,  ∈ M = s1, we
have ( × )(, ) = ( (), ()) &lt;M+ ( ′(), ′()) = ( ′ × ′)(, ). ⋆1 is increasing: if
t1( ) = M = s1(), then for all  ∈ s1( ) we have ( )() = ( ()) ≤ M ( ′()) ≤ M
′( ′(), and one of the two inequalities is strict, therefore ( ()) &lt;M ′( ′(). We then
have also that ⋆0 and ⋆1 are increasing on 3-cells of Move. As a consequence, -cells are closed
w.r.t. -compositions. Associativity, unit and exchange axioms are straightforward.</p>
        </sec>
        <sec id="sec-5-2-2">
          <title>Definition 8.</title>
          <p>A 3-functor  : Tof
→ Move is strict in a 3-cell  if
 is an identity 3-cell in Tof
⇐⇒  ( ) is an identity 3-cell in Move.
 is strict if  is strict on all 3-cells  of Tof .</p>
        </sec>
        <sec id="sec-5-2-3">
          <title>Proposition 2. Assume  : Tof</title>
          <p>Then  is strict.</p>
          <p>→ Move is a 3-functor which is strict on all generators of  .</p>
          <p>Proof. By induction on  , using the fact that  is a 3-functor and 0-, 1-, 2- and 3-composition
are increasing.</p>
          <p>We define a 3-functor  : Tof → Move which is strict on all generators for 0-, 1- ,2-cells.
Recall that a word is written left-to-right, the last letter being the last move.
Definition 9 (Move interpretation). We define a map  by the following assignments on the
generator gates of Tof .</p>
          <p>(* ) = *
 ( ) = M
 (</p>
          <p>)(, ) = (l, r)
 ( N )() = t</p>
          <p>( T2 )(, ) = (t, t)
 ( T3 )(, , ) = (t, t, t)
 () = ⟨ (s2),  (t2)⟩
Lemma 1. The map  of Def. 9 extends in a unique way to a 3-functor Tof
→ Move.</p>
          <p>Lemma 2 (Termination Lemma). If the free 3-category Tof has a 3-functor to Move which is
strict on all generators for 3-cells, then all chains of non-identical 3-cells in Tof terminate.</p>
          <p>Tof is freely generated from a free 3-category, therefore  is entirely and uniquely defined
by the assignments on the generators of Tof , provided we recursively check that the 3-functor
 preserves sources and targets, and sources and targets of sources.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>6. A Termination Result for Reversible Boolean Circuits</title>
      <p>Theorem 1. The free 3-category of Reversible Boolean Circuits terminates (all reduction sequences
are finite).
s1( ) = M. By definition of the pointwise order on
 (s2 )(1, . . . , ) &gt;M  (t2 )(1, . . . , ) for all 1, . . . ,  ∈ M.
of Termination for Reversible Boolean Circuits with the Tofoli base. By Lemma 2, we have to
prove that  is strict on all generators for 3-cells. By definition of strictness, it is enough
to prove that for all</p>
      <p>∈ 3 in Tof we have that  ( ) is not an identity. By definition,  ( )
is equal to the pair ⟨ (s2 ),  (t2 )⟩.  ( ) is not an identity if  (s2 ) &gt;2  (t2 ). Suppose</p>
      <sec id="sec-6-1">
        <title>2-cells of Move, we have to prove that</title>
        <p>• Permutation rules.</p>
        <p>The thesis follows from lr &gt; rl.
• Annihilation rules.</p>
        <p>Å
Ç
ã
‖
T3
T3
å
‖
(, , )
Å
ã
‖</p>
        <p>(, , )
(ll, lr, rr)
&gt;M</p>
        <p>(ll, rl, rr)
(, , )
 (</p>
        <p>) (, , )
(tt, tt, tt)
&gt;M</p>
        <p>‖
(, , )</p>
        <p>Words on the right-hand-size are all shorter and therefore smaller.
• Left-to-Right Sliding rules.</p>
        <p>The reduction moving the Tofoli gate upwards and to the right swaps the lowest letter of
the monoid t, with a higher letter, l, in all movements , , ,  but . Below, we consider
the case of the circuit Tofoli 3.</p>
        <p>Å</p>
        <p>T3</p>
        <p>(, , , )
ã
‖
Å</p>
        <p>T3</p>
        <p>(, , , )
ã
‖
(lt, lt, lt, rrr)
&gt;M
(tl, tl, tl, rrr)</p>
        <p>The thesis follows from lt &gt;M tl. The Right-to-Left Sliding rules are the mirror case.
• Swapped Tofoli.</p>
      </sec>
      <sec id="sec-6-2">
        <title>This case follows from lt &gt; tl and rt &gt; tr.</title>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>7. Conclusion</title>
      <p>This work explores 3-categories as a unified formal framework for modeling two concepts.
First, it examines Reversible Boolean Circuits, which are treated as diagrams generated from
a base through the iterative application of series/parallel compositions. Then, it investigates
the termination of a rewriting system on these circuits. Tof is the free 3-category which
efectively formalizes circuits and rewriting rules. Move is the 3-category supplying the well
founded-order in a monoid of strings. Termination follows from interpreting Tof into Move by
means of a (strict) functor  that intuitively represent traces of moves inside the circuit being
rewritten, by exploiting the common 3-category structure. A possible extension of this work
is to evaluate its efectiveness in proving the termination of reductions of free 3-polygraphs
generated from alternative bases which include Fredkin and Peres gates. A second development
must focus on confluence: rewriting in Tof is not. We claim that the following circuits has two
non-confluent normal forms:</p>
      <p>T2
(left-sliding)</p>
      <p>(permutation)
T2</p>
      <p>T2</p>
      <p>We are pursuing various directions in order to obtain confluence. However, the problem at
hand is known to be non-obvious. Guiraud warns that a 3-polygraph may generate an infinite
number of critical pairs which, in specific cases, can be categorized into a finite set of patterns,
eventually leading to confluence [12].
[8] G. Meuli, M. Soeken, M. Roetteler, N. Bjorner, G. D. Micheli, Reversible Pebbling Game
for Quantum Memory Management, in: 2019 Design, Automation &amp; Test in Europe
Conference &amp; Exhibition (DATE), 2019, pp. 288–291.
[9] A. Burroni, Higher-dimensional Word Problems with Applications to Equational
Logic, Theoret. Comput. Sci. 115 (1993) 43–62. doi:https://doi.org/10.1016/
0304-3975(93)90054-W.
[10] Y. Guiraud, G. Bonfante, Polygraphic programs and polynomial-time functions, Log.</p>
      <p>Methods Comput. Sci. 5 (2009).
[11] Y. Guiraud, P. Malbos, Higher-dimensional Categories with Finite Derivation Type, Theory</p>
      <p>Appl. Categ. 22 (2009) 420–478.
[12] Y. Guiraud, Termination orders for three-dimensional rewriting, Journal of Pure and
Applied Algebra 207 (2006) 341–371. doi:https://doi.org/10.1016/j.jpaa.2005.
10.011.
[13] J. C. Baez, An introduction to n-categories, in: E. Moggi, G. Rosolini (Eds.), Category
Theory and Computer Science, Springer Berlin Heidelberg, Berlin, Heidelberg, 1997, pp.
1–33.
[14] E. Cheng, A. Lauda, Higher-dimensional categories: an illustrated guide book, https:
//eugeniacheng.com/wp-content/uploads/2017/02/cheng-lauda-guidebook.pdf, 2004.
[15] R. Street, The algebra of oriented simplexes, Journal of Pure and Applied Algebra 49 (1987)
304–305.
[16] F. Métayer, Cofibrant objects among higher-dimensional categories, Homology, Homotopy
and Applications 10 (2008) 185–188. doi:10.4310/HHA.2008.v10.n1.a7.
[17] M. Acclavio, String Diagram Rewriting: Applications in Category and Proof-theory, Ph.D.
thesis, Aix-Marseille Université, 2016.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>R.</given-names>
            <surname>Landauer</surname>
          </string-name>
          ,
          <article-title>Irreversibility and heat generation in the computing process</article-title>
          ,
          <source>IBM J. Res. Dev</source>
          .
          <volume>5</volume>
          (
          <year>1961</year>
          )
          <fpage>183</fpage>
          -
          <lpage>191</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Táborský</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. F.</given-names>
            <surname>Larsen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. K.</given-names>
            <surname>Thomsen</surname>
          </string-name>
          ,
          <article-title>Encryption and reversible computations</article-title>
          , in: J.
          <string-name>
            <surname>Kari</surname>
          </string-name>
          , I. Ulidowski (Eds.),
          <source>Reversible Computation</source>
          , Springer International Publishing, Cham,
          <year>2018</year>
          , pp.
          <fpage>331</fpage>
          -
          <lpage>338</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>A.</given-names>
            <surname>Barenco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. H.</given-names>
            <surname>Bennett</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Cleve</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. P.</given-names>
            <surname>DiVincenzo</surname>
          </string-name>
          , N. Margolus,
          <string-name>
            <given-names>P.</given-names>
            <surname>Shor</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Sleator</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. A.</given-names>
            <surname>Smolin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Weinfurter</surname>
          </string-name>
          ,
          <article-title>Elementary gates for quantum computation</article-title>
          ,
          <source>Phys. Rev. A</source>
          <volume>52</volume>
          (
          <year>1995</year>
          )
          <fpage>3457</fpage>
          -
          <lpage>3467</lpage>
          . URL: https://link.aps.org/doi/10.1103/PhysRevA.52.3457. doi:
          <volume>10</volume>
          .1103/ PhysRevA.52.3457.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M.</given-names>
            <surname>Saeedi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. L.</given-names>
            <surname>Markov</surname>
          </string-name>
          ,
          <article-title>Synthesis and optimization of reversible circuits-a survey</article-title>
          ,
          <source>ACM Comput. Surv</source>
          .
          <volume>45</volume>
          (
          <year>2013</year>
          ). URL: https://doi.org/10.1145/2431211.2431220. doi:
          <volume>10</volume>
          .1145/ 2431211.2431220.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>T.</given-names>
            <surname>Tofoli</surname>
          </string-name>
          ,
          <article-title>Reversible computing</article-title>
          , in: J. W. de Bakker, J. van Leeuwen (Eds.),
          <source>Automata, Languages and Programming, 7th Colloquium, Noordweijkerhout, The Netherland, July 14-18</source>
          ,
          <year>1980</year>
          , Proceedings, volume
          <volume>85</volume>
          of Lecture Notes in Computer Science, Springer,
          <year>1980</year>
          , pp.
          <fpage>632</fpage>
          -
          <lpage>644</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Lafont</surname>
          </string-name>
          ,
          <article-title>Towards an algebraic theory of boolean circuits</article-title>
          ,
          <source>Journal of Pure and Applied Algebra</source>
          <volume>184</volume>
          (
          <year>2003</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>K. S.</given-names>
            <surname>Perumalla</surname>
          </string-name>
          , Introduction to Reversible Computing, Chapman &amp; Hall/CRC Computational Science, CRC Press,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>