@fedebruzzone7: From a category theory perspective: Categorical Foundations for CuTe Layouts https://arxiv.org/abs/2601.05972
Summary
This paper introduces a categorical framework to formalize the layout algebra in NVIDIA's CUTLASS library, defining categories and morphisms to characterize tensor layouts, and provides a Python implementation with proofs of compatibility.
View Cached Full Text
Cached at: 08/18/26, 04:35 PM
From a category theory perspective: Categorical Foundations for CuTe Layouts
🔗https://t.co/BuL7RnPHkH https://t.co/6UcrRiH2m8
Categorical Foundations for CuTe Layouts
Source: https://arxiv.org/html/2601.05972 Colfax [email protected] 2026
Abstract
NVIDIA’s CUTLASS library provides a robust and expressive set of methods for describing and manipulating multi-dimensional tensor data on the GPU. These methods are conceptually grounded in the abstract notion of a CuTe layout and a rich algebra of such layouts, including operations such as composition, logical product, and logical division. In this paper, we present a categorical framework for understanding this layout algebra by focusing on a naturally occurring class oftractable layouts. To this end, we define two categories𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}and𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}whose morphisms give rise to layouts. We define a suite of operations on morphisms in these categories and prove their compatibility with the corresponding layout operations. Moreover, we give a complete characterization of the layouts which arise from our construction. Finally, we provide a Python implementation of our categorical constructions, along with tests that demonstrate alignment with CUTLASS behavior. This implementation can be found at our git repositoryhttps://github.com/ColfaxResearch/layout-categories.
Contents
- 1Introduction1. 1.1Summary of main results 2. 1.2Organization 3. 1.3Related work 4. 1.4Implementation 5. 1.5Notation
- 2Layouts and their algebra1. 2.1Flat Layouts1. 2.1.1Tuples 2. 2.1.2Basic definitions 3. 2.1.3Basic operations 4. 2.1.4Flat coalesce 5. 2.1.5Compact flat layouts 6. 2.1.6Complements 7. 2.1.7Further operations 8. 2.1.8Tractable flat layouts 2. 2.2Nested Tuples1. 2.2.1Profiles 2. 2.2.2Basic definitions 3. 2.2.3Substitution 4. 2.2.4Refinement 3. 2.3Layouts1. 2.3.1Basic definitions 2. 2.3.2Basic operations 3. 2.3.3Coalesce 4. 2.3.4Relative coalesce 5. 2.3.5Compact layouts 6. 2.3.6Complements 7. 2.3.7Composition 8. 2.3.8Logical division 9. 2.3.9Logical product 10. 2.3.10Tractable layouts
- 3Categories of layouts1. 3.1The category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}1. 3.1.1Basic definitions 2. 3.1.2From tuple morphisms to flat layouts 3. 3.1.3Examples 4. 3.1.4Realization of tuple morphisms 5. 3.1.5Operations on tuple morphisms 2. 3.2The category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}1. 3.2.1Basic definitions 2. 3.2.2From nested tuple morphisms to layouts 3. 3.2.3Examples 4. 3.2.4Realization of nested tuple morphisms 5. 3.2.5Refinements 6. 3.2.6Operations on nested tuple morphisms
- 4Computations1. 4.1Composition of tractable layouts1. 4.1.1Mutual refinements 2. 4.1.2From mutual refinements to composable morphisms 3. 4.1.3The composition algorithm 4. 4.1.4Examples 5. 4.1.5More general compositions 6. 4.1.6Admissibility for composition 2. 4.2Logical division and logical product1. 4.2.1Logical division examples 2. 4.2.2Logical product examples
- AAn introduction to categories1. A.1What is a category? 2. A.2What is a functor?
- Bibliography
Chapter 1Introduction
In modern computing, particularly in GPU programming, performance depends critically on how multi-dimensional data is stored and accessed in memory. While most data that we care about—such as images, videos, and tensors in machine learning—are inherently multi-dimensional, a computer’s memory is fundamentally one-dimensional. This means that when we want to load, store, or otherwise manipulate data, we need to map its multi-dimensional logical coordinates to one-dimensional physical coordinates. This mapping, known as alayout, is essential for reading from and writing to memory correctly and efficiently. Moreover, with respect to the GPU’s SIMT execution model, layouts are used to describe and manipulate partitionings of threads over data. This is important to ensure optimized memory access patterns and correct invocation of specialized hardware instructions such as those used to target tensor cores.
As a motivating example, suppose we want to store the4×84\times 8matrix
A=[12.4787.2134.0856.9345.659.1773.0221.3964.8830.411.7288.0492.5517.0650.9168.773.3377.1961.5829.4615.8280.7544.6239.2891.4026.126.9753.0358.6633.7911.2070.55]A=\begin{bmatrix}12.47&87.21&34.08&56.93&45.65&9.17&73.02&21.39\\ 64.88&30.41&1.72&88.04&92.55&17.06&50.91&68.77\\ 3.33&77.19&61.58&29.46&15.82&80.75&44.62&39.28\\ 91.40&26.12&6.97&53.03&58.66&33.79&11.20&70.55\end{bmatrix}in memory. In order to do so, we need to specify a memory address for each entry ofAA. We do this by choosing some address for the(0,0)(0,0)th entry ofAA, and specifying anoffsetfor each other entry ofAA. One common choice is therow-majorlayout
012345678910111213141516171819202122232425262728293031L𝗋𝗈𝗐=(4,8):(8,1)=L^{\mathsf{row}}=(4,8):(8,1)=
The notationL𝗋𝗈𝗐=(4,8):(8,1)L^{\mathsf{row}}=(4,8):(8,1)indicates that the offset of the(i,j)(i,j)th entry of our matrix is
(i,j)⋅(8,1)=8i+j.(i,j)\cdot(8,1)=8i+j. Another common choice is thecolumn-majorlayout
048121620242815913172125292610141822263037111519232731L𝖼𝗈𝗅=(4,8):(1,4)=L^{\mathsf{col}}=(4,8):(1,4)=
Again, the notationL𝖼𝗈𝗅=(4,8):(1,4)L^{\mathsf{col}}=(4,8):(1,4)indicates that the offset of the(i,j)(i,j)th entry of our matrix is
(i,j)⋅(1,4)=i+4j.(i,j)\cdot(1,4)=i+4j. These layouts are extremely useful, but do not suffice for all purposes. For example, in high-performance computing, one often computes matrix productsABABby
- 1.dividing the operand matricesAAandBBinto tiles,
- 2.computing matrix products of the various tiles, and
- 3.combining these partial results to obtain the full resultABAB.
For instance, we could divide our4×84\times 8matrixAAinto2×22\times 2tiles, as depicted below.
A=[[12.4787.2164.8830.41][34.0856.931.7288.04][45.659.1792.5517.06][73.0221.3950.9168.77][3.3377.1991.4026.12][61.5829.466.9753.03][15.8280.7558.6633.79][44.6239.2811.2070.55]]A=\left[\begin{array}[]{cccc}\begin{bmatrix}12.47&87.21\\ 64.88&30.41\end{bmatrix}&\begin{bmatrix}34.08&56.93\\ 1.72&88.04\end{bmatrix}&\begin{bmatrix}45.65&9.17\\ 92.55&17.06\end{bmatrix}&\begin{bmatrix}73.02&21.39\\ 50.91&68.77\end{bmatrix}\\[8.61108pt] \begin{bmatrix}3.33&77.19\\ 91.40&26.12\end{bmatrix}&\begin{bmatrix}61.58&29.46\\ 6.97&53.03\end{bmatrix}&\begin{bmatrix}15.82&80.75\\ 58.66&33.79\end{bmatrix}&\begin{bmatrix}44.62&39.28\\ 11.20&70.55\end{bmatrix}\end{array}\right] Suppose now that we wanted to slice out individual tiles ofAA, which we assume is laid out in column-major format in memory. To do this, one could manually compute offsets as follows: for the(i,j)(i,j)th tile, the offset to index into the top-left entry of the tile is given by2i+8j2i+8j. On the other hand, to better organize this computation, we could use theinterleavedlayout of tiles
028101618242613911171925274612142022283057131521232931L𝗍𝗂𝗅𝖾𝖽=L^{\mathsf{tiled}}=
where the columns are given by tiles ofAAand the rows are given by coordinates within the tile shape. Here, we usecolexicographic orderingto linearly enumerate tiles and coordinates within tiles, hence the top-level shape(4,8)(4,8)of the layoutL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}.
However, note that the interleaving pattern shown forL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}means that it can’t be expressed as a layout(4,8):(a,b)(4,8):(a,b)for any stridesa,ba,b. Instead, we can factor the modes of the shape(4,8)(4,8)and define
L𝗍𝗂𝗅𝖾𝖽=((2,2),(2,4)):((1,4),(2,8)).L^{\mathsf{tiled}}=((2,2),(2,4)):((1,4),(2,8)). The prior offset calculation2i+8j2i+8jthen appears through evaluatingL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}on the coordinate(0,(i,j))(0,(i,j)), and the tile layout itself is given by the first mode. Thus, after endowingAAwith the layoutL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}to formA𝗍𝗂𝗅𝖾𝖽A^{\mathsf{tiled}}, we can obtain the(i,j)(i,j)th tile ofAAas the slice
Ai,j=A𝗍𝗂𝗅𝖾𝖽(,(i,j)).A_{i,j}=A^{\mathsf{tiled}}(\;\rule{6.99997pt}{0.4pt}\;,(i,j)). A key idea developed in CUTLASS is that useful but more complex auxiliary layouts such asL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}may be systematically deduced from simpler layouts via certain fundamental operations. In the case ofL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}, the operation in question is calledlogical division. If we write
0145T=(2,2):(1,4)=T=(2,2):(1,4)=
for the tile layout, thenL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}is the logical division
L𝗍𝗂𝗅𝖾𝖽=L𝖼𝗈𝗅⊘TL^{\mathsf{tiled}}=L^{\mathsf{col}}\oslash Tas depicted below.
048121620242815913172125292610141822263037111519232731L𝖼𝗈𝗅=L^{\mathsf{col}}=T=T=0145
028101618242613911171925274612142022283057131521232931L𝖼𝗈𝗅⊘T=L^{\mathsf{col}}\oslash T=
In addition to logical division, other fundamental layout operations includelogical products,complements, and most importantly,composition. These layout operations are the backbone of CUTLASS, and a deep understanding of their behavior is helpful for writing correct and highly performant code. However, the definitions and constructions of these operations are fairly subtle. For example, the compositionB∘AB\circ Aof layoutsAAandBBis well-defined only ifAAandBBsatisfy certain divisibility constraints, which CUTLASS checks under the hood. In particular, it is not always obvious when two layouts are composable, or how to interpret their composition.
1.1Summary of main results
The main idea of this work is that we can develop an intuitive and powerful mathematical framework for working with layouts by restricting our attention totractable layouts, whose entries satisfy a simple divisibility condition (see Definition2.3.10.1). Tractable layouts include almost all layouts one encounters in practice, such as
- •row-majorandcolumn-majorlayouts, which are ubiquitous,
- •compactlayouts, which store data in consecutive memory addresses,
- •projections, which broadcast multiple copies of data, and
- •dilations, which enable padded loads and stores.
IfLLis a tractable layout, then we can representLLwith adiagram. For example, the layoutsL𝗋𝗈𝗐L^{\mathsf{row}},L𝖼𝗈𝗅L^{\mathsf{col}}, andL𝗍𝗂𝗅𝖾𝖽L^{\mathsf{tiled}}are represented by the following diagrams.
8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}(4,8):(8,1){\lx@inpgf@ignorespaces(4,8):(8,1)}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}(4,8):(1,4){\lx@inpgf@ignorespaces(4,8):(1,4)}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}((2,2),(2,4)):((1,4),(2,8)){\lx@inpgf@ignorespaces((2,2),(2,4)):((1,4),(2,8))}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2} These diagrams may be interpreted as morphisms in acategory. This allows us to leverage the power ofcategory theoryto describe layouts and their operations.111We provide a primer on category theory in AppendixAfor those unfamiliar with the subject.
More precisely, we define a category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}whose objects are nested tuples of positive integers, and whose morphismsf:S→Tf:S\to Tcorrespond to diagrams such as those above (see Definition3.1.1.13and Definition3.2.1.1for details). IfLLis anon-degeneratetractable layout (see Definition2.3.1.24), then there is an essentially unique𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphismffwhich encodesLL, as illustrated by the following correspondence theorem.
Theorem A.
(see3.2.2.15) There is a one-to-one correspondence
{Non-degeneratetractable layouts}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ \text{tractable layouts}\end{Bmatrix}}{Non-degenerate𝗡𝗲𝘀𝘁-morphismsof standard form}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ {\boldsymbol{\mathsf{Nest}}}\text{-morphisms}\\ \text{ of standard form}\end{Bmatrix}}
Layout operations such as composition, logical division, and logical products may be interpreted naturally in the category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}. If
S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}f\scriptstyle{\lx@inpgf@ignorespaces f}g\scriptstyle{\lx@inpgf@ignorespaces g}are𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms, then we may form the composite
S{\lx@inpgf@ignorespaces S}U{\lx@inpgf@ignorespaces U}g∘f\scriptstyle{\lx@inpgf@ignorespaces g\circ f}by pasting the associated diagrams together. For example,
2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}g∘f{\lx@inpgf@ignorespaces\mathclap{g\circ f}}We prove that composition in𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}is compatible with layout composition.
Theorem B.
(see3.2.6.21) Ifffandggare non-degenerate composable𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms, then
Lg∘f=Lg∘Lf.L_{g\circ f}=L_{g}\circ L_{f}.
We can coalesce a𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphismffby collapsing adjacent arrows. For example,
10{\lx@inpgf@ignorespaces 10}10{\lx@inpgf@ignorespaces 10}10{\lx@inpgf@ignorespaces 10}10{\lx@inpgf@ignorespaces 10}2{\lx@inpgf@ignorespaces 2}100{\lx@inpgf@ignorespaces 100}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}100{\lx@inpgf@ignorespaces 100}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}f{\lx@inpgf@ignorespaces f}𝖼𝗈𝖺𝗅(f){\lx@inpgf@ignorespaces\mathclap{\mathsf{coal}(f)}}We prove that this operation is compatible with layout coalesce.
Theorem C.
(see3.2.6.13) Ifffis a𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphism, then
L𝖼𝗈𝖺𝗅(f)=𝖼𝗈𝖺𝗅(Lf).L_{\mathsf{coal}(f)}=\mathsf{coal}(L_{f}).
The complement of a𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphismffis the inclusion of the entries not hit byff. For example,
5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}↝{\lx@inpgf@ignorespaces\rightsquigarrow}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}fc{\lx@inpgf@ignorespaces f^{c}}We prove that complements in𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}are compatible with layout complements.
Theorem D.
(see3.2.6.20) Iff:S→Tf:S\to Tis an injective𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphism andN=𝗌𝗂𝗓𝖾(T)N=\mathsf{size}(T), then
𝖼𝗈𝖺𝗅(Lfc)=𝖼𝗈𝗆𝗉(Lf,N).\mathsf{coal}(L_{f^{c}})=\mathsf{comp}(L_{f},N).
We define divisibility of𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms, and a logical division operation
f,g↦f⊘gf,g\mapsto f\oslash gwhenggdividesff. For example,
8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}64{\lx@inpgf@ignorespaces 64}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}↝{\lx@inpgf@ignorespaces\rightsquigarrow}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}f⊘g{\lx@inpgf@ignorespaces\mathclap{f\oslash g}} We prove that logical division in𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}is compatible with logical division of layouts.
Theorem E.
(see3.2.6.26) Ifffandggare non-degenerate𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms andggdividesff, then
𝖼𝗈𝖺𝗅(Lf⊘g)=𝖼𝗈𝖺𝗅(Lf⊘Lg).\mathsf{coal}(L_{f\oslash g})=\mathsf{coal}(L_{f}\oslash L_{g}).
We define product admissibility of𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms, and a logical product operation
f,g↦f⊗gf,g\mapsto f\otimes gwhenffandggare product admissible. For example,
5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}↝{\lx@inpgf@ignorespaces\rightsquigarrow}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}f⊗g{\lx@inpgf@ignorespaces\mathclap{f\otimes g}} We prove that the logical products in𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}are compatible with logical products of layouts.
Theorem F.
(see3.2.6.31) Ifffandggare non-degenerate𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphisms andffandggare product admissible, then
Lf⊗g=Lf⊗Lg.L_{f\otimes g}=L_{f}\otimes L_{g}.
In Chapter4, we illustrate how our new framework may be used to compute important layout operations such as composition, logical division, and logical products. In particular, we present an algorithm (Algorithm4.1.3) for computing the compositionB∘AB\circ Aof tractable layoutsAAandBB. Eliding details, the basic idea of our algorithm is that if we want to compute the compositionB∘AB\circ A, we can representAAandBBby suitably chosen𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}-morphismsffandgg, compose these morphisms to formg∘fg\circ f, then take the encoded layout to obtain
B∘A=Lg∘f.B\circ A=L_{g\circ f}.We illustrate this algorithm with many examples.
1.2Organization
The current work is organized as follows.
In section1.4, we provide details regarding thecuteimplementation of layouts. We provide a Python implementation of the category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}in the form of a moduletract, and illustrate the compatibility oftractwithcute. Our Python implementation may be found at our git repositoryhttps://github.com/ColfaxResearch/layout-categories.
Chapter2serves as a comprehensive reference for layouts and their algebra. It provides rigorous definitions of layouts and the operations they support, and establishes the fundamental properties of these operations. This chapter is replete with examples, and may be of use to the working programmer.
In Chapter3, we present a new mathematical framework for working with tractable layouts. In particular, we connect layouts and their algebra to the theory ofcategoriesandoperads. The content of this chapter is of independent mathematical interest. It is also of practical value, as it provides a new framework for visualizing layouts and computing their various operations.
In Chapter4, we provide an algorithm for computing the composite of tractable layoutsAAandBBusing the framework developed in Chapter3. We illustrate the composition algorithm with many examples.
1.3Related work
While the current work is theoretical in nature, it is motivated by practical applications in GPU programming, most notably CUTLASS. We emphasize that the theory developed here is implementation-agnostic: it is independent of the particular programming language or runtime system used to realize layouts in practice. Nevertheless, certain practical considerations arise when working with concrete implementations. For instance, CUTLASS distinguishes between compile-time constants (static variables) and runtime values (dynamic variables). This information enables compiler optimizations during code generation. Such implementation-specific details, while important for performance, lie outside the scope of our mathematical framework. Further discussion of this can be found in the CuTe documentation[5].
The mathematical framework we develop for layouts draws connections to several areas of computer science and mathematics. We briefly review relevant work on GPU programming and adjacent areas to provide a greater context for our contributions.
- •Applications of CUTLASS.State-of-the-art applications of CUTLASS include FlashAttention[7,16], EVT[4], and SonicMoE[10]. For readers seeking a deeper understanding of CUTLASS and CuTe in practice, we recommend the comprehensive tutorial series from NVIDIA[3,24,25]and Colfax Research[17,20,18,19]on GPU programming with these libraries.
- •Data layout optimizationData layout optimization techniques seek to improve cache locality and memory access patterns by carefully considering how tensors are stored in memory[30,8,15,11],[22]. Choosing efficient memory storage and access patterns is crucial for GPU performance, where memory bandwidth is often a bottleneck.
- •Modern layout systemsLayout systems such as CuTe[5,6,21]and Triton Linear Layouts[14,32]have become industry standards for managing memory storage and access in tensor computations. Triton linear layouts are based on𝔽2\mathbb{F}_{2}-linear algebra, and inheret compositional structure from the composition of𝔽2\mathbb{F}_{2}-linear operators. These are also naturally compatible with layout swizzles, which can generally not be represented as a CuTe layout. On the other hand, these layouts are not as expressive as CuTe layouts since they are required to have size and cosize equal to a power of22, and can not express transformations such as scaling by a non power-of-two integer. Recently, it was shown that both of these layout systems may be expressed in terms of integer set relations[1]. This provides a common ground for working with CuTe and Triton linear layouts, as well as more general layouts, such as those with non-rectangular shapes.
- •Polyhedral compilationThe polyhedral model[28],[29],[26]provides a mathematical framework for analyzing and transforming loop nests with affine bounds and array accesses. The primary abstraction of this model is the representation of an iteration space as the collection of integer points in some polyhedron. This formalism allows for complex loop transformations that preserve program semantics while optimizing for locality and parallelism. Tools such as Pluto[2], Polly[9], and Tensor Comprehensions[27]leverage polyhedral techniques to automatically generate optimized code.
- •Tensor contraction/decompositionTensor contractions[23,31,12]generalize matrix multiplication to higher-rank tensors, and are ubiquitous in machine learning and scientific computing. The efficient implementation of tensor contractions relies on optimal choices of contraction order and intermediate tensor layouts.
1.4Implementation
In this section, we illustrate how to work with layouts in NVIDIA’s CuTe DSL, which we denote ascute. We provide an implementation of our categorical framework in the form of aPythonmoduletractin our git repositoryhttps://github.com/ColfaxResearch/layout-categories. Here, we show the compatibility ofcuteandtract.
- 1.Constructing tuples and nested tuples:We construct tuples and nested tuples inPythonas follows. 1S=(2,2,2) 2T=((2,2),(5,5)) 3U=((2,2),4,(9,(3,3))) Note that if we want to construct a tuple of length11, we must include a comma following the tuple’s entry. For example, returns
- 2.Constucting layouts and morphisms:We construct a layout incuteas follows. 1L=cute.make_layout(shape=S,stride=D) For example, 1A=cute.make_layout(shape=((4,4),4),stride=((16,1),4)) 2B=cute.make_layout(shape=(8,64),stride=(64,1)) 3C=cute.make_layout(shape=100,stride=2) returns 1A=((4,4),4):((16,1),4) 2B=(8,64):(64,1) 3C=100:2 We construct a nested tuple morphism S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}intractas follows. 1f=tract.make_morphism(domain=S,codomain=T,map_=alpha) For example, 1f=tract.make_morphism(domain=(4,4),codomain=(4,2,4),map_=(1,3)) 2g=tract.make_morphism(domain=(2,2,2,2),codomain=(2,2,2,2),map_=(1,0,4,2)) 3h=tract.make_morphism(domain=(16,(4,4),(4,4)),codomain=(16,4,4),map_=(1,2,0,3,0)) returns 1f=(4,4)--(1,3)-->(4,2,4) 2g=(2,2,2,2)--(1,0,4,2)-->(2,2,2,2) 3h=(16,(4,4),(4,4))--(1,2,0,3,0)-->(16,4,4) Note that we use the symbol0rather than∗\astwhen specifying maps intract.
- 3.Translating between tractable layouts and morphisms:IfLLis a layout, we can check ifLLis tractable with For example, 1A=cute.make_layout(shape=(2,2,2),stride=(1,2,4)) 2B=cute.make_layout(shape=(2,2,2),stride=(1,7,4)) 3A_is_tractable=tract.is_tractable(A) 4B_is_tractable=tract.is_tractable(B) returns 1A=(2,2,2):(1,2,4) 2B=(2,2,2):(1,7,4) 3A_is_tractable=True 4B_is_tractable=False IfLLis a tractable layout, then we can construct the standard representationfLf_{L}with 1tract.compute_morphism(L) For example, 1L=cute.make_layout(shape=(2,2,2),stride=(1,2,4)) 2f_L=tract.compute_morphism(L) returns 1L=(2,2,2):(1,2,4) 2f_L=(2,2,2)--(1,2,3)-->(2,2,2) Ifffis a nested tuple morphism, we can construct the layoutLfL_{f}encoded byffwith 1tract.compute_layout(f) For example, 1f=tract.make_morphism(domain=((5,5),8),codomain=(5,8,5),map_=(1,3,2)) 2L_f=tract.compute_layout(f) returns 1f=((5,5),8)--(1,3,2)-->(5,8,5) 2L_f=((5,5),8):((1,40),5)
- 4.Composition: When defined, this operation produces a layoutB∘AB\circ Afrom a pair of layoutsAAandBB. See Definition2.3.7.1for a precise definition. We can compute the compositionB∘AB\circ Aincutewith For example, running 1A=cute.make_layout(shape=((4,4),4),stride=((16,1),4)) 2B=cute.make_layout(shape=(8,64),stride=(64,1)) 3B_o_A=cute.composition(B,A) returns 1A=((4,4),4):((16,1),4) 2B=(8,64):(64,1) 3B_o_A=((4,4),(2,2)):((2,64),(256,1)) Ifffandggare composable nested tuple morphisms, we can compute the compositiong∘fg\circ fintractwith For example, 1f=tract.make_morphism(domain=((2,2),(2,2)),codomain=((2,2,2),(2,2,2)),map_=(3,2,6,5)) 2g=tract.make_morphism(domain=((2,2,2),(2,2,2)),codomain=(2,2,2,2),map_=(1,0,2,0,3,4)) 3g_o_f=tract.compose(f,g) returns 1f=((2,2),(2,2))--(3,2,6,5)-->((2,2,2),(2,2,2)) 2g=((2,2,2),(2,2,2))--(1,0,2,0,3,4)-->(2,2,2,2) 3g_o_f=((2,2),(2,2))--(2,0,4,3)-->(2,2,2,2)
- 5.Coalesce: This operation produces a layout𝖼𝗈𝖺𝗅(A)\mathsf{coal}(A)from a layoutAA. See Definition2.3.3.1for details. We can compute𝖼𝗈𝖺𝗅(A)\mathsf{coal}(A)incutewith For example, 1A=cute.make_layout(shape=((2,2),(2,2),(5,5)),stride=((1,2),(16,32),(64,640))) 2coal_A=cute.coalesce(A) returns 1A=((2,2),(2,2),(5,5)):((1,2),(16,32),(64,640)) 2coal_A=(4,20,5):(1,16,640) There is also arelative coalesceoperationA↦𝖼𝗈𝖺𝗅(A,S)A\mapsto\mathsf{coal}(A,S), which receives as input an additional nested tupleSSwhich isrefinedby the shape ofAA. See Definition2.3.4.7for details. We can compute𝖼𝗈𝖺𝗅(A,S)\mathsf{coal}(A,S)incutewith 1A=cute.make_layout(shape=((2,2),(3,3),(5,5)),stride=((1,2),(4,12),(36,180))) 2S=((2,2),9,25) 3coal_A_over_S=cute.coalesce(A,target_profile=S) returns 1A=((2,2),(3,3),(5,5)):((1,2),(4,12),(36,180)) 2S=((2,2),9,25) 3coal_A_over_S=((2,2),9,25):((1,2),4,36) Ifffis a nested tuple morphism, we may form𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f). See Definition3.2.6.11for details. We compute𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)intractwith For example, 1f=tract.make_morphism(domain=(2,2,10,10),codomain=(2,2,2,10,10),map_=(1,2,4,5)) 2coal_f=tract.coalesce(f) returns 1f=(2,2,10,10)--(1,2,4,5)-->(2,2,2,10,10) 2coal_f=(4,100)--(1,3)-->(4,2,100)
- 6.Complement: When defined, this operation produces a layout𝖼𝗈𝗆𝗉(A,N)\mathsf{comp}(A,N)from a layoutAAand positive integerNN. See Definition2.3.6.5for details. We can compute𝖼𝗈𝗆𝗉(A,N)\mathsf{comp}(A,N)incutewith For example, 1A=cute.make_layout(shape=((2,2),(2,2)),stride=((8,2),(64,256))) 2comp_A=cute.complement(A,4096) returns 1A=((2,2),(2,2)):((8,2),(64,256)) 2comp_A=(2,2,4,2,8):(1,4,16,128,512) Ifffis a nested tuple morphism, then we may form the complementfcf^{c}offf. See Definition3.2.6.17for details. We computefcf^{c}intractwith For example, 1f=tract.make_morphism(domain=(2,2),codomain=(2,5,2,5),map_=(1,3)) 2comp_f=tract.complement(f) returns 1f=(2,2)--(1,3)-->(2,5,2,5) 2comp_A=(5,5)--(2,4)-->(2,5,2,5)
- 7.Logical Division: When defined, this operation produces a layoutA⊘BA\oslash Bfrom a pair of layoutsAAandBB. See Definition2.3.8.1for details. We computeA⊘BA\oslash Bincutewith 1cute.logical_divide(A,B) For example, 1A=cute.make_layout((64,32),stride=(32,1)) 2B=cute.make_layout((4,4),stride=(1,64)) 3quotient=cute.logical_divide(A,B) returns 1A=(64,32):(32,1) 2B=(4,4):(1,64) 3quotient=((4,4),(16,8)):((32,1),(128,4)) Ifffandggare nested tuple morphisms andggdividesff, then we may form the logical divisionf⊘gf\oslash g. See Definition3.2.6.23for details. We computef⊘gf\oslash gintractwith 1tract.logical_divide(f,g) For example, 1f=tract.make_morphism(domain=(4,8,4,8),codomain=(4,8,4,8),map_=(1,2,3,4)) 2g=tract.make_morphism(domain=(4,4),codomain=(4,8,4,8),map_=(1,3)) 3quotient=tract.logical_divide(f,g) returns 1f=(4,8,4,8)--(1,2,3,4)-->(4,8,4,8) 2g=(4,4)--(1,3)-->(4,8,4,8) 3quotient=((4,4),(8,8))--(1,3,2,4)-->(4,8,4,8)
- 8.Logical Product: When defined, this operation produces a layoutA⊗BA\otimes Bfrom a pair of layoutsAAandBB. See Definition2.3.9.1for details. We computeA⊗BA\otimes Bincutewith 1cute.logical_product(A,B) For example, running 1A=cute.make_layout((3,10,10),stride=(200,1,20)) 2B=cute.make_layout((2,2),stride=(1,2)) 3product=cute.logical_product(A,B) returns 1A=(3,10,10):(200,1,20) 2B=(2,2):(1,2) 3product=((3,10,10),(2,2)):((200,1,20),(10,600))
Ifffandggare nested tuple morphisms andffandggare product admissible, then we may form the logical productf⊗gf\otimes g. See Definition3.2.6.28for details. We computef⊗gf\otimes gintractwith
1tract.logical_product(f,g)
For example,
1f=tract.make_morphism(domain=(2,2),codomain=(2,2,5,5),map_=(1,2))
2g=tract.make_morphism(domain=(5,5),codomain=(5,5),map_=(2,1))
3product=tract.logical_product(f,g)
returns
1f=(2,2)--(1,2)-->(2,2,5,5)
2g=(5,5)--(2,1)-->(5,5)
3product=((2,2),(5,5))--(1,2,4,3)-->(2,2,5,5)
1.5Notation
ℤ\displaystyle\mathbb{Z}={…,−1,0,1,2,…}\displaystyle=\{\dots,-1,0,1,2,\dots\}ℕ\displaystyle\mathbb{N}={0,1,2,…}\displaystyle=\{0,1,2,\dots\}ℤ>0\displaystyle\mathbb{Z}_{>0}={1,2,…}\displaystyle=\{1,2,\dots\}𝔽2\displaystyle\mathbb{F}_{2}={0,1}, the finite field of order2.\displaystyle=\{0,1\}\text{, the finite field of order }2.[0,n)\displaystyle[0,n)={0,…,n−1}, and[0,0)=∅.\displaystyle=\{0,\dots,n-1\}\text{, and }[0,0)=\varnothing.⟨n⟩\displaystyle\langle n\rangle={1,2,…,n}, and⟨0⟩=∅.\displaystyle=\{1,2,\dots,n\}\text{, and }\langle 0\rangle=\varnothing.⟨n⟩∗\displaystyle\langle n\rangle_{*}={∗,1,2,…,n}\displaystyle=\{*,1,2,\dots,n\}δim\displaystyle\delta_{i}^{m}=(0,…,1,…,0), the tuple of lengthmwith\displaystyle=(0,\dots,1,\dots,0)\text{, the tuple of length }m\text{ with }ith entry1and all other entries0.\displaystyle\hskip 14.45377pti\text{th entry }1\text{ and all other entries }0.Σn\displaystyle\Sigma_{n}=the symmetric group on⟨n⟩.\displaystyle=\text{ the symmetric group on }\langle n\rangle.Xσ\displaystyle X^{\sigma}=(xσ(1),…,xσ(m))for a tupleX=(x1,…,xm)\displaystyle=(x_{\sigma(1)},\dots,x_{\sigma(m)})\text{ for a tuple }X=(x_{1},\dots,x_{m})and a permutationσ∈Σm.\displaystyle\hskip 14.45377pt\text{ and a permutation }\sigma\in\Sigma_{m}.X⋆Y\displaystyle X\star Y=the flat concatenation ofXandY.\displaystyle=\text{ the flat concatenation of }X\text{ and }Y.X♭\displaystyle X^{\flat}=the flattening of a nested tupleX.\displaystyle=\text{ the flattening of a nested tuple }X.𝗉𝗋𝗈𝖿(X)\displaystyle\mathsf{prof}(X)=the profile of a nested tupleX.\displaystyle=\text{ the profile of a nested tuple }X.(X1,…,Xk)\displaystyle(X_{1},\dots,X_{k})=the (nested) concatenation ofX1,…,Xk.\displaystyle=\text{ the (nested) concatenation of }X_{1},\dots,X_{k}.(X1,…,Xk)Q\displaystyle(X_{1},\dots,X_{k})_{Q}=theQ-substitution ofX1,…,Xkfor a profileQ.\displaystyle=\text{ the }Q\text{-substitution of }X_{1},\dots,X_{k}\text{ for a profile }Q.𝖳𝗎𝗉𝗅𝖾(V)\displaystyle\mathsf{Tuple}(V)=the set of tuples with entries in a setV.\displaystyle=\text{ the set of tuples with entries in a set }V.𝖭𝖾𝗌𝗍(V)\displaystyle\mathsf{Nest}(V)=the set of nested tuples with entries in a setV.\displaystyle=\text{ the set of nested tuples with entries in a set }V.𝖯𝗋𝗈𝖿𝗂𝗅𝖾\displaystyle\mathsf{Profile}=the set of profiles.\displaystyle=\text{ the set of profiles.}𝖥𝗅𝖺𝗍𝖫𝖺𝗒𝗈𝗎𝗍\displaystyle\mathsf{FlatLayout}=the set of flat layouts.\displaystyle=\text{ the set of flat layouts.}𝖫𝖺𝗒𝗈𝗎𝗍\displaystyle\mathsf{Layout}=the set of layouts.\displaystyle=\text{ the set of layouts.}B∘A\displaystyle B\circ A=the composition ofAandB.\displaystyle=\text{ the composition of }A\text{ and }B.A⊘B\displaystyle A\oslash B=the logical division ofAbyB.\displaystyle=\text{ the logical division of }A\text{ by }B.A⊗B\displaystyle A\otimes B=the logical product ofAandB.\displaystyle=\text{ the logical product of }A\text{ and }B.𝗦𝗲𝘁\displaystyle{\boldsymbol{\mathsf{Set}}}=the category of sets.\displaystyle=\text{ the category of sets.}𝗙𝗶𝗻𝗦𝗲𝘁\displaystyle{\boldsymbol{\mathsf{FinSet}}}=the category of finite sets.\displaystyle=\text{ the category of finite sets.}𝗙𝗶𝗻\displaystyle{\boldsymbol{\mathsf{Fin}}}=the full subcategory of𝗙𝗶𝗻𝗦𝗲𝘁spanned by⟨n⟩forn≥0.\displaystyle=\text{ the full subcategory of }{\boldsymbol{\mathsf{FinSet}}}\text{ spanned by }\langle n\rangle\text{ for }n\geq 0.𝗙𝗶𝗻𝗦𝗲𝘁∗\displaystyle{\boldsymbol{\mathsf{FinSet}}}_{*}=the category of pointed finite sets.\displaystyle=\text{ the category of pointed finite sets.}𝗙𝗶𝗻∗\displaystyle{\boldsymbol{\mathsf{Fin}}}_{*}=the full subcategory of𝗙𝗶𝗻𝗦𝗲𝘁∗spanned by⟨n⟩∗forn≥0.\displaystyle=\text{ the full subcategory of }{\boldsymbol{\mathsf{FinSet}}}_{*}\text{ spanned by }\langle n\rangle_{*}\text{ for }n\geq 0.𝗧𝘂𝗽𝗹𝗲\displaystyle{\boldsymbol{\mathsf{Tuple}}}=the category of tuples and tuple morphisms.\displaystyle=\text{ the category of tuples and tuple morphisms.}𝗡𝗲𝘀𝘁\displaystyle{\boldsymbol{\mathsf{Nest}}}=the category of nested tuples and nested tuple morphisms.\displaystyle=\text{ the category of nested tuples and nested tuple morphisms.}𝗥𝗲𝗳\displaystyle{\boldsymbol{\mathsf{Ref}}}=the category of nested tuples and refinements.\displaystyle=\text{ the category of nested tuples and refinements.}𝗖𝗮𝘁\displaystyle{\boldsymbol{\mathsf{Cat}}}=the category of (small) categories and functors.\displaystyle=\text{ the category of (small) categories and functors.}
Chapter 2Layouts and their algebra
The goal of this chapter is to provide a comprehensive and mathematically grounded theory of layouts. We begin by developing a theory of flat layouts in section2.1. We introduce the necessary background on nested tuples in section2.2, so that we may cover layouts in full generality in section2.3.
2.1Flat Layouts
In this section, we examineflat layouts, an important subclass of layouts in which both shape and stride are tuples, rather than more general nested tuples. To formalize our discussion, we begin by fixing notation related to tuples.
2.1.1Tuples
Definition 2.1.1.1.
IfVVis a set, then atuplewith entries inVVis a finite ordered list
X=(x1,…,xm)X=(x_{1},\dots,x_{m})of elementsxi∈Vx_{i}\in Vfor each1≤i≤m1\leq i\leq m. Thelengthof such a tupleX=(x1,…,xm)X=(x_{1},\dots,x_{m})is
𝗅𝖾𝗇(X)=m.\mathsf{len}(X)=m.We write𝖳𝗎𝗉𝗅𝖾(V)\mathsf{Tuple}(V)for the collection of all tuples with entries inVV. We are especially interested in the caseV=ℤV=\mathbb{Z}, in which case we refer toX∈𝖳𝗎𝗉𝗅𝖾(ℤ)X\in\mathsf{Tuple}(\mathbb{Z})as atuple of integers.IfXXis a tuple of integers, then thesizeofXXis the product
𝗌𝗂𝗓𝖾(X)=x1⋯xm.\mathsf{size}(X)=x_{1}\cdots x_{m}.
Example 2.1.1.2.
Here are some examples of tuples, together with their length and size:
X\displaystyle X=(3,128,128),\displaystyle=(3,128,128),𝗅𝖾𝗇(X)\displaystyle\quad\mathsf{len}(X)=3,𝗌𝗂𝗓𝖾(X)=49152\displaystyle=3,\quad\mathsf{size}(X)=49152X\displaystyle X=(512),\displaystyle=(512),𝗅𝖾𝗇(X)\displaystyle\quad\mathsf{len}(X)=1,𝗌𝗂𝗓𝖾(X)=512\displaystyle=1,\quad\mathsf{size}(X)=512X\displaystyle X=(),\displaystyle=(),𝗅𝖾𝗇(X)\displaystyle\quad\mathsf{len}(X)=0,𝗌𝗂𝗓𝖾(X)=1\displaystyle=0,\quad\mathsf{size}(X)=1
Definition 2.1.1.3.
IfX=(x1,…,xm)X=(x_{1},\dots,x_{m})andY=(y1,…,yn)Y=(y_{1},\dots,y_{n})are tuples, then we write
X⋆Y=(x1,…,xm,y1,…,yn)X\star Y=(x_{1},\dots,x_{m},y_{1},\dots,y_{n})for theconcatenationofXXandYY.
Example 2.1.1.4.
IfX=(64,32)X=(64,32)andY=(8,8,8)Y=(8,8,8), then
X⋆Y=(64,32,8,8,8).X\star Y=(64,32,8,8,8).
Definition 2.1.1.6.
IfXXandX′X^{\prime}are tuples, we sayX′X^{\prime}dividesXXif there exists a tupleX′′X^{\prime\prime}with
X′⋆X′′=X.X^{\prime}\star X^{\prime\prime}=X.
Example 2.1.1.7.
IfX′=(81,9)X^{\prime}=(81,9)andX=(81,9,64,8)X=(81,9,64,8), thenX′X^{\prime}dividesXX, since the tupleX′′=(64,8)X^{\prime\prime}=(64,8)satisfies
X′⋆X′′=X.X^{\prime}\star X^{\prime\prime}=X.
Definition 2.1.1.8.
IfX=(x1,…,xm)X=(x_{1},\dots,x_{m})is a tuple andσ∈Σm\sigma\in\Sigma_{m}is a permutation, then we write
Xσ=(xσ(1),…,xσ(m))X^{\sigma}=(x_{\sigma(1)},\dots,x_{\sigma(m)})for thepermutation ofXXbyσ\sigma. This specifies a right action ofΣm\Sigma_{m}onℤ×m\mathbb{Z}^{\times m}.
Example 2.1.1.9.
IfX=(8,16,32,64)X=(8,16,32,64)andσ=(1 2)(3 4)\sigma=(1\;2)(3\;4), then
Xσ=(16,8,64,32).X^{\sigma}=(16,8,64,32).
Notation 2.1.1.10.
Ifnnis a positive integer, we write
[0,n)={0,1,…,n−1},[0,n)=\{0,1,\dots,n-1\},and ifS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a tuple of positive integers, we write
[0,S)\displaystyle[0,S)=[0,s1)×⋯×[0,sm)\displaystyle=[0,s_{1})\times\cdots\times[0,s_{m})for the collection of tuples(x1,…,xm)(x_{1},\dots,x_{m})with0≤xi<si0\leq x_{i}<s_{i}.
Example 2.1.1.11.
IfS=(3,2)S=(3,2), then
[0,S)={(0,0),(1,0),(2,0),(0,1),(1,1),(2,1)}[0,S)=\{(0,0),(1,0),(2,0),(0,1),(1,1),(2,1)\}
2.1.2Basic definitions
Having fixed notation, we are ready to define flat layouts.
Definition 2.1.2.1.
Aflat layoutis a pair
L\displaystyle L=S:D\displaystyle=S:D=(s1,…,sm):(d1,…,dm)\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})consisting of a tuple of positive integers
𝗌𝗁𝖺𝗉𝖾(L)\displaystyle\mathsf{shape}(L)=S\displaystyle=S=(s1,…,sm)\displaystyle=(s_{1},\dots,s_{m})called theshapeofLL, and a tuple of non-negative integers
𝗌𝗍𝗋𝗂𝖽𝖾(L)\displaystyle\mathsf{stride}(L)=D\displaystyle=D=(d1,…,dm)\displaystyle=(d_{1},\dots,d_{m})called thestrideofLL.
Example 2.1.2.4.
Here are some examples of flat layouts:
L1\displaystyle L_{1}=(2,2,2):(1,2,4),\displaystyle=(2,2,2):(1,2,4),L2\displaystyle L_{2}=(128):(5),\displaystyle=(128):(5),L3\displaystyle L_{3}=(16,12,512,512):(0,0,1,512),\displaystyle=(16,12,512,512):(0,0,1,512),L4\displaystyle L_{4}=(6,1,12,2,2):(2,0,12,144,1),\displaystyle=(6,1,12,2,2):(2,0,12,144,1),L5\displaystyle L_{5}=():().\displaystyle=():().
Example 2.1.2.5.
We can depict the layoutL=(8):(5)L=(8):(5)as
05101520253035L=L=
and we can depict the layoutL=(3,5):(2,10)L=(3,5):(2,10)as
010203040212223242414243444L=L=
We make precise the sense in which these pictures represent the associated layout in Remark2.1.2.17.
Perhaps the most important examples of flat layouts are the column-major and row-major layouts, which we define below.
Definition 2.1.2.6.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. We sayLLiscolumn-majorif
di=s1⋯si−1d_{i}=s_{1}\cdots s_{i-1}for each1≤i≤m1\leq i\leq m. We sayLLisrow-majorif
di=si+1⋯sm.d_{i}=s_{i+1}\cdots s_{m}.for each1≤i≤m1\leq i\leq m.
Example 2.1.2.7.
The layout
03691471025811L=(3,4):(1,3)=L=(3,4):(1,3)=
is column-major, while the layout
01234567891011L=(3,4):(4,1)=L=(3,4):(4,1)=
is row-major. These pictures make clear the reason for the terminology: IfLLis a column-major layout of rank22, then the columns ofLLare contiguous, and ifLLis a row-major layout of rank22, then the rows ofLLare contiguous.
Example 2.1.2.8.
The layouts
L1\displaystyle L_{1}=(2,2,2,2,2):(1,2,4,8,16)\displaystyle=(2,2,2,2,2):(1,2,4,8,16)L2\displaystyle L_{2}=(3,128,128):(1,3,384)\displaystyle=(3,128,128):(1,3,384)L3\displaystyle L_{3}=(64):(1)\displaystyle=(64):(1)are column-major, while the layouts
L4\displaystyle L_{4}=(2,2,2,2,2):(16,8,4,2,1)\displaystyle=(2,2,2,2,2):(16,8,4,2,1)L5\displaystyle L_{5}=(3,128,128):(16384,128,1)\displaystyle=(3,128,128):(16384,128,1)L6\displaystyle L_{6}=(64):(1)\displaystyle=(64):(1)are row-major.
Now that we’ve seen a few examples, lets define some important attributes of flat layouts.
Definition 2.1.2.9.
SupposeL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout.
- •TherankofLLis 𝗋𝖺𝗇𝗄(L)=m.\mathsf{rank}(L)=m.
- •ThesizeofLLis 𝗌𝗂𝗓𝖾(L)=∏i=1msi.\mathsf{size}(L)=\prod_{i=1}^{m}s_{i}.
- •ThecosizeofLLis 𝖼𝗈𝗌𝗂𝗓𝖾(L)=1+∑i=1m(si−1)⋅di.\mathsf{cosize}(L)=1+\sum_{i=1}^{m}(s_{i}-1)\cdot d_{i}.
- •For any1≤i≤𝗋𝖺𝗇𝗄(L)1\leq i\leq\mathsf{rank}(L), theiith modeofLLis the pair 𝗆𝗈𝖽𝖾i(L)=si:di.\mathsf{mode}_{i}(L)=s_{i}:d_{i}.
Example 2.1.2.10.
The layout
L=(64,32):(1,128)L=(64,32):(1,128)has𝗋𝖺𝗇𝗄(L)=2\mathsf{rank}(L)=2,𝗌𝗂𝗓𝖾(L)=2048\mathsf{size}(L)=2048, and𝖼𝗈𝗌𝗂𝗓𝖾(L)=4032\mathsf{cosize}(L)=4032. The modes ofLLare
𝗆𝗈𝖽𝖾1(L)\displaystyle\mathsf{mode}_{1}(L)=64:1\displaystyle=64:1𝗆𝗈𝖽𝖾2(L)\displaystyle\mathsf{mode}_{2}(L)=32:128.\displaystyle=32:128.
Example 2.1.2.11.
The layout
L=(3,8,8,8):(1,3,24,192).L=(3,8,8,8):(1,3,24,192).has𝗋𝖺𝗇𝗄(L)=4\mathsf{rank}(L)=4,𝗌𝗂𝗓𝖾(L)=1536\mathsf{size}(L)=1536, and𝖼𝗈𝗌𝗂𝗓𝖾(L)=1536\mathsf{cosize}(L)=1536. The layoutLLhas four modes, for example𝗆𝗈𝖽𝖾3(L)=8:24\mathsf{mode}_{3}(L)=8:24.
Example 2.1.2.12.
The layout
L=(2,2,2,2,2):(160,80,40,20,10).L=(2,2,2,2,2):(160,80,40,20,10).has𝗋𝖺𝗇𝗄(L)=5\mathsf{rank}(L)=5,𝗌𝗂𝗓𝖾(L)=32\mathsf{size}(L)=32, and𝖼𝗈𝗌𝗂𝗓𝖾(L)=311\mathsf{cosize}(L)=311. The layoutLLhas55modes, for example𝗆𝗈𝖽𝖾5(L)=2:10\mathsf{mode}_{5}(L)=2:10.
IfLLis a flat layout, thenLLencodes acoordinate functionφL\varphi_{L}. The coordinate function ofLLis a multi-dimensional to one-dimensional transformation given by taking a dot product with𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L). Recall that ifS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a tuple of positive integers, then
[0,S)=[0,s1)×⋯×[0,sm)[0,S)=[0,s_{1})\times\cdots\times[0,s_{m})is the set of all tuples(x1,…,xm)(x_{1},\dots,x_{m})such that0≤xi<si0\leq x_{i}<s_{i}. In particular, ifS=()S=()is the empty tuple, then[0,S)={()}[0,S)=\{()\}.
Construction 2.1.2.13(Coordinate functions).
If
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout, then thecoordinate functionofLLis the function
[0,𝗌𝗁𝖺𝗉𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{shape}(L){)}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}φL\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L}}given by
φL(x1,…,xm)\displaystyle\varphi_{L}(x_{1},\dots,x_{m})=(x1,…,xm)⋅(d1,…,dm)\displaystyle=(x_{1},\dots,x_{m})\cdot(d_{1},\dots,d_{m})=x1d1+⋯+xmdm.\displaystyle=x_{1}d_{1}+\cdots+x_{m}d_{m}.The coordinate functionφL\varphi_{L}factors through the inclusion[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))⊂ℤ[0,\mathsf{cosize}(L))\subset\mathbb{Z}, and we write
[0,𝗌𝗁𝖺𝗉𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{shape}(L){)}}[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))⊂ℤ{\lx@inpgf@ignorespaces{[}0,\mathsf{cosize}(L){)}\subset\mathbb{Z}}φL𝖼𝗈𝗌𝗂𝗓𝖾(L)\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L}^{\mathsf{cosize}(L)}}for the factored map. More generally, for anyN≥𝖼𝗈𝗌𝗂𝗓𝖾(L)N\geq\mathsf{cosize}(L), we writeφLN\varphi_{L}^{N}for the factorization ofφL\varphi_{L}through[0,N)⊂ℤ[0,N)\subset\mathbb{Z}, and by a mild abuse of terminology, we refer to such a mapφLN\varphi_{L}^{N}as thecoordinate functionofLL.
Example 2.1.2.14.
IfL=(2,3):(1,5)L=(2,3):(1,5), then the coordinate function
φL:[0,2)×[0,3)→ℤ\varphi_{L}:[0,2)\times[0,3)\to\mathbb{Z}is given by
φL(0,0)\displaystyle\varphi_{L}(0,0)=(0,0)⋅(1,5)=0,\displaystyle=(0,0)\cdot(1,5)=0,φL(1,0)\displaystyle\varphi_{L}(1,0)=(1,0)⋅(1,5)=1,\displaystyle=(1,0)\cdot(1,5)=1,φL(0,1)\displaystyle\varphi_{L}(0,1)=(0,1)⋅(1,5)=5,\displaystyle=(0,1)\cdot(1,5)=5,φL(1,1)\displaystyle\varphi_{L}(1,1)=(1,1)⋅(1,5)=6,\displaystyle=(1,1)\cdot(1,5)=6,φL(0,2)\displaystyle\varphi_{L}(0,2)=(0,2)⋅(1,5)=10,\displaystyle=(0,2)\cdot(1,5)=10,φL(1,2)\displaystyle\varphi_{L}(1,2)=(1,2)⋅(1,5)=11.\displaystyle=(1,2)\cdot(1,5)=11.
Example 2.1.2.15.
IfL=(2,2):(64,2)L=(2,2):(64,2), then the coordinate function
φL:[0,2)×[0,2)→ℤ\varphi_{L}:[0,2)\times[0,2)\to\mathbb{Z}is given by
φL(0,0)\displaystyle\varphi_{L}(0,0)=(0,0)⋅(64,2)=0,\displaystyle=(0,0)\cdot(64,2)=0,φL(1,0)\displaystyle\varphi_{L}(1,0)=(1,0)⋅(64,2)=64,\displaystyle=(1,0)\cdot(64,2)=64,φL(0,1)\displaystyle\varphi_{L}(0,1)=(0,1)⋅(64,2)=2,\displaystyle=(0,1)\cdot(64,2)=2,φL(1,1)\displaystyle\varphi_{L}(1,1)=(1,1)⋅(64,2)=66.\displaystyle=(1,1)\cdot(64,2)=66.
Example 2.1.2.16.
IfE=():()E=():()is the empty layout, then the coordinate function ofEEis the map
φE:{()}→ℤ\varphi_{E}:\{()\}\to\mathbb{Z}given by
In practice, the most important invariant of a flat layoutLLis itslayout functionΦL\Phi_{L}, which is obtained by precomposing the coordinate function
φL:[0,S)→ℤ\varphi_{L}:[0,S)\to\mathbb{Z}with the inverse of thecolexicographic isomorphism
𝖼𝗈𝗅𝖾𝗑S:[0,S)→[0,𝗌𝗂𝗓𝖾(S)).\mathsf{colex}_{S}:[0,S)\to[0,\mathsf{size}(S)).
Definition 2.1.2.18.
SupposeS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a tuple of positive integers and recall that
[0,S)=[0,s1)×⋯×[0,sm).[0,S)=[0,s_{1})\times\cdots\times[0,s_{m}).Thecolexicographic isorphismis the map
[0,S){\lx@inpgf@ignorespaces{[}0,S{)}}[0,𝗌𝗂𝗓𝖾(S)){\lx@inpgf@ignorespaces\text{[}0,\mathsf{size}(S)\text{)}}(x1,…,xm){\lx@inpgf@ignorespaces(x_{1},\dots,x_{m})}∑i=1ms1⋯si−1xi.{\lx@inpgf@ignorespaces\sum_{i=1}^{m}s_{1}\cdots s_{i-1}x_{i}.}𝖼𝗈𝗅𝖾𝗑S\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S}}We sometimes write𝖼𝗈𝗅𝖾𝗑=𝖼𝗈𝗅𝖾𝗑S\mathsf{colex}=\mathsf{colex}_{S}when the tupleSSis clear from context. The inverse of the colexicographic isomorphism is the map
[0,𝗌𝗂𝗓𝖾(S)){\lx@inpgf@ignorespaces\text{[}0,\mathsf{size}(S)\text{)}}[0,S){\lx@inpgf@ignorespaces{[}0,S{)}}𝖼𝗈𝗅𝖾𝗑S−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S}^{-1}}given by
𝖼𝗈𝗅𝖾𝗑S−1(x)=(x1,…,xm)\mathsf{colex}_{S}^{-1}(x)=(x_{1},\dots,x_{m})where
xi=⌊xs1⋯si−1⌋modsi.x_{i}=\left\lfloor\dfrac{x}{s_{1}\cdots s_{i-1}}\right\rfloor\mod s_{i}.Note that ifS=()S=()is the empty tuple, then
𝖼𝗈𝗅𝖾𝗑():{()}→{0}\mathsf{colex}_{()}:\{()\}\to\{0\}and
𝖼𝗈𝗅𝖾𝗑()−1:{0}→{()}\mathsf{colex}_{()}^{-1}:\{0\}\to\{()\}are the canonical isomorphisms.
Construction 2.1.2.19(Layout functions).
If
L=(s1,…,sm):(d1,…,dm),L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),is a flat layout, then thelayout function ofLLis the composite
[0,𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(L){)}}ℤ.{\lx@inpgf@ignorespaces\mathbb{Z}.}[0,𝗌𝗁𝖺𝗉𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{shape}(L){)}}ΦL\scriptstyle{\lx@inpgf@ignorespaces\Phi_{L}}𝖼𝗈𝗅𝖾𝗑𝗌𝗁𝖺𝗉𝖾(L)−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}^{-1}_{\mathsf{shape}(L)}}φL\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L}}Explicitly,ΦL\Phi_{L}is given by
ΦL(x)=x1d1+⋯+xmdm\Phi_{L}(x)=x_{1}d_{1}+\cdots+x_{m}d_{m}where
xi=⌊xs1⋯si−1⌋modsi.x_{i}=\left\lfloor\dfrac{x}{s_{1}\cdots s_{i-1}}\right\rfloor\mod s_{i}.The layout functionΦL\Phi_{L}factors through the inclusion[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))⊂ℤ[0,\mathsf{cosize}(L))\subset\mathbb{Z}, and we write
[0,𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(L){)}}[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))⊂ℤ{\lx@inpgf@ignorespaces{[}0,\mathsf{cosize}(L){)}\subset\mathbb{Z}}ΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\scriptstyle{\lx@inpgf@ignorespaces\Phi_{L}^{\mathsf{cosize}(L)}}for the factored map. More generally, for anyN≥𝖼𝗈𝗌𝗂𝗓𝖾(L)N\geq\mathsf{cosize}(L), we writeΦLN\Phi_{L}^{N}for the factorization ofΦL\Phi_{L}through[0,N)⊂ℤ[0,N)\subset\mathbb{Z}, and by a mild abuse of terminology, we refer to such a mapφLN\varphi_{L}^{N}as thelayout functionofLL.
Example 2.1.2.20.
IfL=(2,3):(1,5)L=(2,3):(1,5), then the layout function
ΦL:[0,6)→ℤ\Phi_{L}:[0,6)\to\mathbb{Z}is given by
ΦL(0)\displaystyle\Phi_{L}(0)=(0,0)⋅(1,5)=0,\displaystyle=(0,0)\cdot(1,5)=0,ΦL(1)\displaystyle\Phi_{L}(1)=(1,0)⋅(1,5)=1,\displaystyle=(1,0)\cdot(1,5)=1,ΦL(2)\displaystyle\Phi_{L}(2)=(0,1)⋅(1,5)=5,\displaystyle=(0,1)\cdot(1,5)=5,ΦL(3)\displaystyle\Phi_{L}(3)=(1,1)⋅(1,5)=6,\displaystyle=(1,1)\cdot(1,5)=6,ΦL(4)\displaystyle\Phi_{L}(4)=(0,2)⋅(1,5)=10,\displaystyle=(0,2)\cdot(1,5)=10,ΦL(5)\displaystyle\Phi_{L}(5)=(1,2)⋅(1,5)=11.\displaystyle=(1,2)\cdot(1,5)=11.
Example 2.1.2.21.
IfL=(2,2):(64,2)L=(2,2):(64,2), then the layout function
ΦL:[0,4)→ℤ\Phi_{L}:[0,4)\to\mathbb{Z}is given by
ΦL(0)\displaystyle\Phi_{L}(0)=(0,0)⋅(64,2)=0,\displaystyle=(0,0)\cdot(64,2)=0,ΦL(1)\displaystyle\Phi_{L}(1)=(1,0)⋅(64,2)=64,\displaystyle=(1,0)\cdot(64,2)=64,ΦL(2)\displaystyle\Phi_{L}(2)=(0,1)⋅(64,2)=2,\displaystyle=(0,1)\cdot(64,2)=2,ΦL(3)\displaystyle\Phi_{L}(3)=(1,1)⋅(64,2)=66.\displaystyle=(1,1)\cdot(64,2)=66.
Example 2.1.2.22.
IfL=(4,2,2):(3,3,100)L=(4,2,2):(3,3,100), then for example, the layout function ofLLsatisfies
ΦL(7)\displaystyle\Phi_{L}(7)=(3,1,0)⋅(3,3,100)=12,\displaystyle=(3,1,0)\cdot(3,3,100)=12\text{,}ΦL(9)\displaystyle\Phi_{L}(9)=(1,0,1)⋅(3,3,100)=103.\displaystyle=(1,0,1)\cdot(3,3,100)=103.
Example 2.1.2.23.
IfE=():()E=():()is the empty layout, then
ΦE:{0}→ℤ\Phi_{E}:\{0\}\to\mathbb{Z}is given by
Example 2.1.2.24.
IfLLis any flat layout, then the layout functionΦL\Phi_{L}ofLLsatisfies
Before moving on to our discussion of layout operations, we need to define the notion of non-degeneracy.
Definition 2.1.2.27.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. We sayLLisnon-degenerateif for any1≤i≤m1\leq i\leq m, we have
si=1⇒di=0.s_{i}=1\quad\Rightarrow\quad d_{i}=0.
Example 2.1.2.28.
The layouts
L1\displaystyle L_{1}=(4,1):(1,0)\displaystyle=(4,1):(1,0)L2\displaystyle L_{2}=(8,1,8,1):(2,0,16,0)\displaystyle=(8,1,8,1):(2,0,16,0)are non-degenerate, while the layouts
L3\displaystyle L_{3}=(4,1):(1,4)\displaystyle=(4,1):(1,4)L4\displaystyle L_{4}=(8,1,8,1):(2,16,16,256)\displaystyle=(8,1,8,1):(2,16,16,256)are degenerate.
Observation 2.1.2.29.
There is no real loss of generality in assuming that a layoutLLis non-degenerate. More precisely, if
L\displaystyle L=(s1,…,sm):(d1,…,dm)\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})L′\displaystyle L^{\prime}=(s1,…,sm):(d1′,…,dm′)\displaystyle=(s_{1},\dots,s_{m}):(d_{1}^{\prime},\dots,d_{m}^{\prime})are flat layouts with the same shape, anddi=di′d_{i}=d_{i}^{\prime}wheneversi>1s_{i}>1, thenφL=φL′\varphi_{L}=\varphi_{L^{\prime}}, andΦL=ΦL′\Phi_{L}=\Phi_{L^{\prime}}. In particular, we are free to setdi=0d_{i}=0wheneversi=1s_{i}=1without altering the coordinate function or layout function ofLL.
2.1.3Basic operations
Having established the basic vocabulary for flat layouts, we turn to the operations they support. In this section, we define basic operations that will be needed to construct more sophisticated operations such ascoalesce,complement, andcomposition.
2.1.3.1Restriction
IfLLis a flat layout, it is often useful to restrict to a subset of the modes ofLL. Recall that for a non-negative integermm, we write
⟨m⟩={1,…,m}.\langle m\rangle=\{1,\dots,m\}.
Definition 2.1.3.1.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout, and suppose
I={i1<⋯<ik}⊂⟨m⟩I=\{i_{1}<\dots<i_{k}\}\subset\langle m\rangleis a subset. We define therestriction ofLLtoIIto be the flat layout
L∣I=(si1,…,sik):(di1,…,dik).L\mid_{I}=(s_{i_{1}},\dots,s_{i_{k}}):(d_{i_{1}},\dots,d_{i_{k}}).
Example 2.1.3.2.
If
0510152025101520253035202530354045L=(3,6):(10,5)=L=(3,6):(10,5)=andI={2}I=\{2\}, then
0510152025L∣I=(6):(5)=L\mid_{I}=(6):(5)=
Example 2.1.3.3.
If
L=(3,8,8,8):(1,3,24,192)L=(3,8,8,8):(1,3,24,192)andI={1,2,3}I=\{1,2,3\}, then
L∣I=(3,8,8):(1,3,24).L\mid_{I}=(3,8,8):(1,3,24).
Example 2.1.3.4.
If
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout andI=⟨m⟩I=\langle m\rangle, then
Example 2.1.3.5.
If
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout andI=∅I=\varnothingis the empty set, then
is the empty layout.
2.1.3.2Squeeze
IfLLis a flat layout, then the operationL↦𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)L\mapsto\mathsf{squeeze}(L)removes all modessi:dis_{i}:d_{i}ofLLwheresi=1s_{i}=1.
Construction 2.1.3.6.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout, and let
I={i∈⟨m⟩∣si>1}I=\{i\in\langle m\rangle\mid s_{i}>1\}be the collection of indices whose corresponding shape entry is not equal to11. We define
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=L∣I.\mathsf{squeeze}(L)=L\mid_{I}.
Example 2.1.3.7.
If
L=(64,64,1):(1,64,0),L=(64,64,1):(1,64,0),then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(64,64):(1,64).\mathsf{squeeze}(L)=(64,64):(1,64).
Example 2.1.3.8.
If
L=(64,64,1,32,1):(2048,32,0,1,0)L=(64,64,1,32,1):(2048,32,0,1,0)then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(64,64,32):(2048,32,1).\mathsf{squeeze}(L)=(64,64,32):(2048,32,1).
Example 2.1.3.9.
IfLLis a flat layout, then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=L\mathsf{squeeze}(L)=Lif and only if𝗌𝗁𝖺𝗉𝖾(L)\mathsf{shape}(L)contains no entries equal to11.
Example 2.1.3.10.
IfLLis a flat layout, then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=():()\mathsf{squeeze}(L)=():()is the empty layout if and only if all entries of𝗌𝗁𝖺𝗉𝖾(L)\mathsf{shape}(L)are equal to11.
An essential property of this construction is thatL↦𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)L\mapsto\mathsf{squeeze}(L)leaves the layout function ofLLunchanged.
Lemma 2.1.3.11.
IfLLis a flat layout, then
- 1.𝗌𝗂𝗓𝖾(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=𝗌𝗂𝗓𝖾(L)\mathsf{size}(\mathsf{squeeze}(L))=\mathsf{size}(L),
- 2.𝖼𝗈𝗌𝗂𝗓𝖾(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=𝖼𝗈𝗌𝗂𝗓𝖾(L)\mathsf{cosize}(\mathsf{squeeze}(L))=\mathsf{cosize}(L), and
- 3.Φ𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=ΦL\Phi_{\mathsf{squeeze}(L)}=\Phi_{L}.
Proof.
Let
I={i1<⋯<ik}⊂⟨m⟩I=\{i_{1}<\dots<i_{k}\}\subset\langle m\rangledenote the collection of indices withsij>1s_{i_{j}}>1, so that
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(si1,…,sik):(di1,…,dik).\mathsf{squeeze}(L)=(s_{i_{1}},\dots,s_{i_{k}}):(d_{i_{1}},\dots,d_{i_{k}}).For the first assertion, we compute
𝗌𝗂𝗓𝖾(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=∏j=1ksij=(∏j=1ksij)⋅(∏⟨m⟩∖I1)=∏i=1msi=𝗌𝗂𝗓𝖾(L).\displaystyle\mathsf{size}(\mathsf{squeeze}(L))=\prod_{j=1}^{k}s_{i_{j}}=\left(\prod_{j=1}^{k}s_{i_{j}}\right)\cdot\left(\prod_{\langle m\rangle\setminus I}1\right)=\prod_{i=1}^{m}s_{i}=\mathsf{size}(L).For the second assertion, we compute
𝖼𝗈𝗌𝗂𝗓𝖾(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=1+∑j=1k(sij−1)⋅dij\displaystyle\mathsf{cosize}(\mathsf{squeeze}(L))=1+\sum_{j=1}^{k}(s_{i_{j}}-1)\cdot d_{i_{j}}=1+∑j=1k(sij−1)⋅dij+(∑⟨m⟩∖I0)\displaystyle=1+\sum_{j=1}^{k}(s_{i_{j}}-1)\cdot d_{i_{j}}+\left(\sum_{\langle m\rangle\setminus I}0\right)=1+∑i=1m(si−1)⋅di\displaystyle=1+\sum_{i=1}^{m}(s_{i}-1)\cdot d_{i}=𝖼𝗈𝗌𝗂𝗓𝖾(L).\displaystyle=\mathsf{cosize}(L).For the third assertion, it suffices to show that removing a mode of the form1:di1:d_{i}from a flat layout leaves the layout function unchanged. SupposeL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}), and suppose that somesi=1s_{i}=1. Let
L′\displaystyle L^{\prime}=(s1′,…,sm−1′):(d1′,…,dm−1′)\displaystyle=(s_{1}^{\prime},\dots,s_{m-1}^{\prime}):(d_{1}^{\prime},\dots,d_{m-1}^{\prime})denote the flat layout obtained fromLLby removing itsiith mode, so that
sj′={sjj<isj+1i≤j<m,anddj′={djj<idj+1i≤j<m.s_{j}^{\prime}=\begin{cases}s_{j}&j<i\\ s_{j+1}&i\leq j<m,\end{cases}\hskip 14.45377pt\text{ and }\hskip 14.45377ptd_{j}^{\prime}=\begin{cases}d_{j}&j<i\\ d_{j+1}&i\leq j<m.\end{cases} The layout function forLLis given by
ΦL(x)=x1d1+⋯+xmdm\Phi_{L}(x)=x_{1}d_{1}+\cdots+x_{m}d_{m}wherexj=⌊xs1⋯sj−1⌋modsjx_{j}=\left\lfloor\dfrac{x}{s_{1}\cdots s_{j-1}}\right\rfloor\mod s_{j}, and the layout function forL′L^{\prime}is given by
ΦL′(x)=x1′d1′+⋯+xm−1′dm−1′\Phi_{L^{\prime}}(x)=x_{1}^{\prime}d_{1}^{\prime}+\cdots+x_{m-1}^{\prime}d_{m-1}^{\prime}wherexj′=⌊xs1′⋯sj−1′⌋modsj′x_{j}^{\prime}=\left\lfloor\dfrac{x}{s_{1}^{\prime}\cdots s_{j-1}^{\prime}}\right\rfloor\mod s_{j}^{\prime}. We observe that
xj′={xjj<ixj+1i≤j<m,x_{j}^{\prime}=\begin{cases}x_{j}&j<i\\ x_{j+1}&i\leq j<m,\end{cases}and sincexi∈[0,1)x_{i}\in{[}0,1{)}is necessarily00, we have
ΦL(x)\displaystyle\Phi_{L}(x)=x1d1+⋯+xmdm\displaystyle=x_{1}d_{1}+\cdots+x_{m}d_{m}=x1d1+⋯+xi−1di−1+xi+1di+1+⋯+xmdm\displaystyle=x_{1}d_{1}+\cdots+x_{i-1}d_{i-1}+x_{i+1}d_{i+1}+\cdots+x_{m}d_{m}=x1′d1′+⋯+xm−1′dm−1′\displaystyle=x_{1}^{\prime}d_{1}^{\prime}+\cdots+x_{m-1}^{\prime}d_{m-1}^{\prime}=ΦL′(x).\displaystyle=\Phi_{L^{\prime}}(x).∎
2.1.3.3Filter zeros
IfLLis a flat layout, then the operationL↦𝖿𝗂𝗅𝗍𝖾𝗋(L)L\mapsto\mathsf{filter}(L)removes all modessi:dis_{i}:d_{i}withdi=0d_{i}=0.
Definition 2.1.3.12.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout, and let
I={i∈⟨m⟩∣di>0}I=\{i\in\langle m\rangle\mid d_{i}>0\}be the collection of indices whose corresponding stride entry is not equal to00. We define
𝖿𝗂𝗅𝗍𝖾𝗋(L)=L∣I.\mathsf{filter}(L)=L\mid_{I}.
Example 2.1.3.13.
If
L=(64,8,8,128):(8,1,0,512)L=(64,8,8,128):(8,1,0,512)then
𝖿𝗂𝗅𝗍𝖾𝗋(L)=(64,8,128):(8,1,512).\mathsf{filter}(L)=(64,8,128):(8,1,512).
Example 2.1.3.14.
If
0012122424L=(3,2):(12,0)=L=(3,2):(12,0)=then
01224𝖿𝗂𝗅𝗍𝖾𝗋(L)=(3):(12)=\mathsf{filter}(L)=(3):(12)=
Example 2.1.3.15.
If
L=(3,8,8,8):(16,0,0,0)L=(3,8,8,8):(16,0,0,0)then
𝖿𝗂𝗅𝗍𝖾𝗋(L)=(3):(16).\mathsf{filter}(L)=(3):(16).
Example 2.1.3.16.
IfLLis a flat layout, then
𝖿𝗂𝗅𝗍𝖾𝗋(L)=L\mathsf{filter}(L)=Lif and only if all entries of𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L)are nonzero.
Example 2.1.3.17.
IfLLis a flat layout, then
𝖿𝗂𝗅𝗍𝖾𝗋(L)=():()\mathsf{filter}(L)=():()is the empty layout if and only if all entries of𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L)are equal to00.
2.1.3.4Permute
Recall that ifX=(x1,…,xm)X=(x_{1},\dots,x_{m})is a tuple of lengthmmandσ∈Σm\sigma\in\Sigma_{m}is a permutation, then we write
Xσ=(xσ(1),…,xσ(m)).X^{\sigma}=(x_{\sigma(1)},\dots,x_{\sigma(m)}).for the permutation ofXXbyσ\sigma.
Definition 2.1.3.18.
IfL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout of rankmmandσ∈Σm\sigma\in\Sigma_{m}is a permutation, we define
Lσ\displaystyle L^{\sigma}=𝗌𝗁𝖺𝗉𝖾(L)σ:𝗌𝗍𝗋𝗂𝖽𝖾(L)σ\displaystyle=\mathsf{shape}(L)^{\sigma}:\mathsf{stride}(L)^{\sigma}=(sσ(1),…,sσ(m)):(dσ(1),…,dσ(m)).\displaystyle=(s_{\sigma(1)},\dots,s_{\sigma(m)}):(d_{\sigma(1)},\dots,d_{\sigma(m)}).
Example 2.1.3.19.
If
02121424263638L=(4,2):(12,2)=L=(4,2):(12,2)=andσ=(1 2)∈Σ2\sigma=(1\;2)\in\Sigma_{2}is the transposition, then
01224362142638Lσ=(2,4):(2,12)=L^{\sigma}=(2,4):(2,12)=is the transposed layout.
Example 2.1.3.20.
If
L=(15,12,10):(240,1,24)L=(15,12,10):(240,1,24)andσ=(1 2)∈Σ3\sigma=(1\;2)\in\Sigma_{3}, then
Lσ=(12,15,10):(1,240,24).L^{\sigma}=(12,15,10):(1,240,24).
Example 2.1.3.21.
If
L=(2,2,2,2,2):(1,2,4,8,16)L=(2,2,2,2,2):(1,2,4,8,16)andσ=(1 5)(3 2 4)∈Σ5\sigma=(1\;5)(3\;2\;4)\in\Sigma_{5}, then
Lσ=(2,2,2,2,2):(16,8,2,4,1).L^{\sigma}=(2,2,2,2,2):(16,8,2,4,1).
Example 2.1.3.22.
If
L=(s,…,s):(d,…,d)L=(s,\dots,s):(d,\dots,d)is a flat layout all of whose modes are equal, then for anyσ∈Σm\sigma\in\Sigma_{m}, we have
2.1.3.5Sort
IfLLis a flat layout, it is often useful to permuteLLso that its modes are increasing, in the following sense.
Definition 2.1.3.23.
We define a linear ordering on pairss:ds:dof integers by
s:d⪯s′:d′⇔d<d′, ord=d′ands≤s′.s:d\preceq s^{\prime}:d^{\prime}\hskip 14.45377pt\Leftrightarrow\hskip 14.45377pt\begin{matrix}d<d^{\prime}\text{, or}\\ d=d^{\prime}\text{ and }s\leq s^{\prime}.\end{matrix}
Example 2.1.3.24.
We have
5:8⪯4:12⪯5:12.5:8\preceq 4:12\preceq 5:12.
Definition 2.1.3.25.
SupposeLLis a flat layout. We sayLLissortedif for any1≤i<𝗋𝖺𝗇𝗄(L)1\leq i<\mathsf{rank}(L), we have
𝗆𝗈𝖽𝖾i(L)⪯𝗆𝗈𝖽𝖾i+1(L).\mathsf{mode}_{i}(L)\preceq\mathsf{mode}_{i+1}(L).
Example 2.1.3.26.
The layouts
L1\displaystyle L_{1}=(128,64,2,2):(1,128,8192,16384)\displaystyle=(128,64,2,2):(1,128,8192,16384)L2\displaystyle L_{2}=(2,2,2):(1,1,1)\displaystyle=(2,2,2):(1,1,1)are sorted, while the layouts
L3\displaystyle L_{3}=(2,4,8,16):(64,1,2,4)\displaystyle=(2,4,8,16):(64,1,2,4)L4\displaystyle L_{4}=(5,32,16):(1,5,5)\displaystyle=(5,32,16):(1,5,5)are not sorted.
Example 2.1.3.27.
The empty layoutE=():()E=():()is sorted.
Example 2.1.3.28.
If
L=(s1,…,sm):(0,…,0)L=(s_{1},\dots,s_{m}):(0,\dots,0)is a flat layout with all entries of𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L)equal to00, thenLLis sorted if and only if
s1≤s2≤⋯≤sm.s_{1}\leq s_{2}\leq\cdots\leq s_{m}.
Whether or not a flat layoutLLis sorted is intimately related to the behavior of the layout functionΦL\Phi_{L}ofLL, as described in the following lemma.
Lemma 2.1.3.29.
SupposeLLis a flat layout. IfΦL\Phi_{L}is non-decreasing, thenLLis sorted.
Proof.
We prove the contrapositive. Suppose thatLLis not sorted. We will show that there exists somex≤yx\leq yin the domain ofΦL\Phi_{L}withΦL(x)>ΦL(y)\Phi_{L}(x)>\Phi_{L}(y). If there exists some1≤i<m1\leq i<msuch thatdi>di+1d_{i}>d_{i+1}, then we can let
x\displaystyle x=∏j<isj,andy=∏j<i+1sj,\displaystyle=\prod_{j<i}s_{j},\hskip 14.45377pt\text{and}\hskip 14.45377pty=\prod_{j<i+1}s_{j},in which casex<yx<y, but
ΦL(x)\displaystyle\Phi_{L}(x)=(0,…,1,0,…,0)⋅(d1,…,di,di+1,…,dm)\displaystyle=(0,\dots,1,0,\dots,0)\cdot(d_{1},\dots,d_{i},d_{i+1},\dots,d_{m})=di\displaystyle=d_{i}>di+1\displaystyle>d_{i+1}=(0,…,0,1,…,0)⋅(d1,…,dm)\displaystyle=(0,\dots,0,1,\dots,0)\cdot(d_{1},\dots,d_{m})=ΦL(y).\displaystyle=\Phi_{L}(y).On the other hand, if there exists some1≤i<m1\leq i<msuch thatdi=di+1d_{i}=d_{i+1}andsi>si+1s_{i}>s_{i+1}, we can set
x\displaystyle x=(si−1)(∏j<isj),andy=(si+1−1)(∏j<i+1sj),\displaystyle=(s_{i}-1)\left(\prod_{j<i}s_{j}\right),\hskip 14.45377pt\text{ and }\hskip 14.45377pty=(s_{i+1}-1)\left(\prod_{j<i+1}s_{j}\right),in which casex<yx<y, but
ΦL(x)\displaystyle\Phi_{L}(x)=(0,…,si−1,0,…,0)⋅(d1,…,di,di+1,…,dm)\displaystyle=(0,\dots,s_{i}-1,0,\dots,0)\cdot(d_{1},\dots,d_{i},d_{i+1},\dots,d_{m})=(si−1)di\displaystyle=(s_{i}-1)d_{i}>(si+1−1)di\displaystyle>(s_{i+1}-1)d_{i}=(si+1−1)di+1\displaystyle=(s_{i+1}-1)d_{i+1}=(0,…,0,si+1−1,…,0)⋅(d1,…,dm)\displaystyle=(0,\dots,0,s_{i+1}-1,\dots,0)\cdot(d_{1},\dots,d_{m})=ΦL(y).\displaystyle=\Phi_{L}(y).We conclude thatΦL\Phi_{L}is not non-decreasing. ∎
IfLLis a flat layout, then we can permute the modes ofLLto obtain a sorted layoutOPENL)L).
Construction 2.1.3.31.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. Define a linear ordering⪯\preceqon⟨m⟩\langle m\ranglebyi⪯ji\preceq jif
- 1.𝗆𝗈𝖽𝖾i(L)⪯𝗆𝗈𝖽𝖾j(L)\mathsf{mode}_{i}(L)\preceq\mathsf{mode}_{j}(L), and
- 2.if𝗆𝗈𝖽𝖾i(L)=𝗆𝗈𝖽𝖾j(L)\mathsf{mode}_{i}(L)=\mathsf{mode}_{j}(L)theni≤ji\leq j.
Letσ∈Σm\sigma\in\Sigma_{m}be the permutation associated to the linear ordering⪯\preceqof⟨m⟩\langle m\rangle. We defineOPENL)L)to be permutation ofLLbyσ\sigma:
Example 2.1.3.32.
If
L=(2,4,8,16):(64,1,2,4)L=(2,4,8,16):(64,1,2,4)then
OPENL)=(4,8,16,2):(1,2,4,64).L)=(4,8,16,2):(1,2,4,64).
Example 2.1.3.33.
If
L=(5,32,16):(1,5,5)L=(5,32,16):(1,5,5)then
OPENL)=(5,16,32):(1,5,5).L)=(5,16,32):(1,5,5).
Example 2.1.3.34.
IfLLis sorted, thenOPENL)=LL)=L. In particular, this implies thatOPEN−)-)is an idempotent operation:
Observation 2.1.3.35.
IfLLis a flat layout, then typicallyΦOPENL)≠ΦL\Phi_{L)}\neq\Phi_{L}. However, the layout functionsΦL\Phi_{L}andΦOPENL)\Phi_{L)}always have the same image. To see this, let’s write
L\displaystyle L=(s1,…,sm):(d1,…,dm), and\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})\text{, and}OPENL)\displaystyle L)=(sσ(1),…,sσ(m)):(dσ(1),…,dσ(m))\displaystyle=(s_{\sigma(1)},\dots,s_{\sigma(m)}):(d_{\sigma(1)},\dots,d_{\sigma(m)})for some permutationσ∈Σm\sigma\in\Sigma_{m}. If an integernnis in the image ofΦL\Phi_{L}, then there exists a tuple(x1,…,xm)∈∏i=1m[0,si)(x_{1},\dots,x_{m})\in\prod_{i=1}^{m}{[}0,s_{i}{)}such that
x1d1+⋯+xmdm=nx_{1}d_{1}+\cdots+x_{m}d_{m}=nin which case the tuple(xσ(1),…,xσ(m))∈∏i=1m[0,sσ(i))(x_{\sigma(1)},\dots,x_{\sigma(m)})\in\prod_{i=1}^{m}{[}0,s_{\sigma(i)}{)}satisfies
xσ(1)dσ(1)+⋯+xσ(m)dσ(m)=n.x_{\sigma(1)}d_{\sigma(1)}+\cdots+x_{\sigma(m)}d_{\sigma(m)}=n.This proves thatOPEN𝖨𝗆𝖺𝗀𝖾(ΦL))⊆𝖨𝗆𝖺𝗀𝖾(ΦL)\mathsf{Image}(\Phi_{L}))\subseteq\mathsf{Image}(\Phi_{L}), and the reverse inclusion is proved similarly.
2.1.3.6Concatenate
Recall that ifX=(x1,…,xm)X=(x_{1},\dots,x_{m})andY=(y1,…,yn)Y=(y_{1},\dots,y_{n})are tuples, then the concatenation ofXXandYYis the tuple
X⋆Y=(x1,…,xm,y1,…,yn).X\star Y=(x_{1},\dots,x_{m},y_{1},\dots,y_{n}).This definition extends naturally to the concatenation of flat layouts.
Definition 2.1.3.36.
Suppose
L1\displaystyle L_{1}=S1:D1\displaystyle=S_{1}:D_{1}L2\displaystyle L_{2}=S2:D2\displaystyle=S_{2}:D_{2}are flat layouts. Then theconcatenationofL1L_{1}andL2L_{2}is the flat layout
L1⋆L2=S1⋆S2:D1⋆D2.L_{1}\star L_{2}=S_{1}\star S_{2}:D_{1}\star D_{2}.Concatenation of flat layouts is associative, so more generally, ifL1,…,LkL_{1},\dots,L_{k}are flat layouts, we may form the concatenation
L1⋆⋯⋆Lk.L_{1}\star\cdots\star L_{k}.
Example 2.1.3.37.
IfL1=(7,2):(2,1)L_{1}=(7,2):(2,1)andL2=(3,3,3):(0,10,30)L_{2}=(3,3,3):(0,10,30), then
L1⋆L2=(7,2,3,3,3):(2,1,0,10,30).L_{1}\star L_{2}=(7,2,3,3,3):(2,1,0,10,30).
Example 2.1.3.38.
IfE=():()E=():()is the empty layout, then for any flat layoutLLwe have
L⋆E=L=E⋆L.L\star E=L=E\star L.
Observation 2.1.3.39.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. If we write
Li=(si):(di),L_{i}=(s_{i}):(d_{i}),then we can writeLLas the concatenation
L=L1⋆⋯⋆Lm.L=L_{1}\star\cdots\star L_{m}.
IfL1,…,LkL_{1},\dots,L_{k}are flat layouts, then the layout function of the concatenationL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is determined by the layout functions ofL1,…,LkL_{1},\dots,L_{k}as follows.
Proposition 2.1.3.40.
SupposeL1,…,LkL_{1},\dots,L_{k}are flat layouts of shapeS1,…,SkS_{1},\dots,S_{k}, and sizeN1,…,NkN_{1},\dots,N_{k}, respectively. Then the coordinate function
[0,S1⋆⋯⋆Sk){\lx@inpgf@ignorespaces{[}0,S_{1}\star\cdots\star S_{k}{)}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}φL1⋆⋯⋆Lk\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L_{1}\star\cdots\star L_{k}}}ofL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is equal to the composite
[0,S1⋆⋯⋆Sk){\lx@inpgf@ignorespaces{[}0,S_{1}\star\cdots\star S_{k}{)}}[0,S1)×⋯×[0,Sk){\lx@inpgf@ignorespaces{[}0,S_{1}{)}\times\cdots\times{[}0,S_{k}{)}}ℤ,{\lx@inpgf@ignorespaces\mathbb{Z},}X1⋆⋯⋆Xk{\lx@inpgf@ignorespaces X_{1}\star\cdots\star X_{k}}(X1,…,Xk){\lx@inpgf@ignorespaces(X_{1},\dots,X_{k})}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}φL1+⋯+φLk\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L_{1}}+\cdots+\varphi_{L_{k}}}and the layout function
[0,N1⋯Nk){\lx@inpgf@ignorespaces{[}0,N_{1}\cdots N_{k}{)}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}ΦL1⋆⋯⋆Lk\scriptstyle{\lx@inpgf@ignorespaces\Phi_{L_{1}\star\cdots\star L_{k}}}ofL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is equal to the composite
[0,N1⋯Nk){\lx@inpgf@ignorespaces{[}0,N_{1}\cdots N_{k}{)}}[0,N1)×⋯×[0,Nk){\lx@inpgf@ignorespaces{[}0,N_{1}{)}\times\cdots\times{[}0,N_{k}{)}}ℤ.{\lx@inpgf@ignorespaces\mathbb{Z}.}𝖼𝗈𝗅𝖾𝗑(N1,…,Nk)−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{(N_{1},\dots,N_{k})}^{-1}}ΦL1+⋯+ΦLk\scriptstyle{\lx@inpgf@ignorespaces\Phi_{L_{1}}+\cdots+\Phi_{L_{k}}}
Proof.
Let’s writeLi=Si:DiL_{i}=S_{i}:D_{i}for each1≤i≤k1\leq i\leq k. The first claim holds because if
X∈[0,S1⋆⋯⋆Sk)X\in[0,S_{1}\star\cdots\star S_{k})corresponds to
X1⋆⋯⋆Xk∈[0,S1)×⋯×[0,Sk)X_{1}\star\cdots\star X_{k}\in[0,S_{1})\times\cdots\times[0,S_{k})under the canonical isomorphism[0,S1⋆⋯⋆Sk)≅[0,S1)×⋯×[0,Sk)[0,S_{1}\star\cdots\star S_{k})\cong[0,S_{1})\times\cdots\times[0,S_{k}), then
φL1⋆⋯⋆Lk(X)\displaystyle\varphi_{L_{1}\star\cdots\star L_{k}}(X)=X⋅(D1⋆⋯⋆Dk)\displaystyle=X\cdot(D_{1}\star\cdots\star D_{k})=(X1⋆⋯⋆Xk)⋅(D1⋆⋯⋆Dk)\displaystyle=(X_{1}\star\cdots\star X_{k})\cdot(D_{1}\star\cdots\star D_{k})=(X1⋅D1)+⋯+(Xk⋅Dk)\displaystyle=(X_{1}\cdot D_{1})+\cdots+(X_{k}\cdot D_{k})=φL1(X1)+⋯+φLk(Xk).\displaystyle=\varphi_{L_{1}}(X_{1})+\cdots+\varphi_{L_{k}}(X_{k}). For the second claim, we argue that the diagram
[0,N1)×⋯×[0,N1){\lx@inpgf@ignorespaces{[}0,N_{1}{)}\times\cdots\times{[}0,N_{1}{)}}[0,S1)×⋯×[0,S1){\lx@inpgf@ignorespaces{[}0,S_{1}{)}\times\cdots\times{[}0,S_{1}{)}}[0,N1⋯Nk){\lx@inpgf@ignorespaces{[}0,N_{1}\cdots N_{k}{)}}[0,S1⋆⋯⋆Sk){\lx@inpgf@ignorespaces{[}0,S_{1}\star\cdots\star S_{k}{)}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}𝖼𝗈𝗅𝖾𝗑S1−1×⋯×𝖼𝗈𝗅𝖾𝗑Sk−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S_{1}}^{-1}\times\cdots\times\mathsf{colex}_{S_{k}}^{-1}}φL1+⋯+φLk\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L_{1}}+\cdots+\varphi_{L_{k}}}𝖼𝗈𝗅𝖾𝗑(N1,…,Nk)−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{(N_{1},\dots,N_{k})}^{-1}}𝖼𝗈𝗅𝖾𝗑S1⋆⋯⋆Sk−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S_{1}\star\cdots\star S_{k}}^{-1}}φL1⋆⋯⋆Lk\scriptstyle{\lx@inpgf@ignorespaces\varphi_{L_{1}\star\cdots\star L_{k}}}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}commutes. The left-hand square commutes since colexicographic isomorphisms are associative, and the right-hand triangle commutes by the first claim. ∎
We can describe the important attributes of a concatenated layout as follows.
Proposition 2.1.3.41.
SupposeL1,…,LkL_{1},\dots,L_{k}are flat layouts. Then
- 1.the rank ofL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is 𝗋𝖺𝗇𝗄(L1⋆⋯⋆Lk)=∑i=1k𝗋𝖺𝗇𝗄(Li),\mathsf{rank}(L_{1}\star\cdots\star L_{k})=\sum_{i=1}^{k}\mathsf{rank}(L_{i}),
- 2.the size ofL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is 𝗌𝗂𝗓𝖾(L1⋆⋯⋆Lk)=∏i=1k𝗌𝗂𝗓𝖾(Li),\mathsf{size}(L_{1}\star\cdots\star L_{k})=\prod_{i=1}^{k}\mathsf{size}(L_{i}),
- 3.the cosize ofL1⋆⋯⋆LkL_{1}\star\cdots\star L_{k}is 𝖼𝗈𝗌𝗂𝗓𝖾(L1⋆⋯⋆Lk)=1−k+∑i=1k𝖼𝗈𝗌𝗂𝗓𝖾(Li).\mathsf{cosize}(L_{1}\star\cdots\star L_{k})=1-k+\sum_{i=1}^{k}\mathsf{cosize}(L_{i}).
Proof.
Let’s writeLi=Si:DiL_{i}=S_{i}:D_{i}for each1≤i≤k1\leq i\leq k. For 1, we compute
𝗋𝖺𝗇𝗄(L1⋆⋯⋆Lk)\displaystyle\mathsf{rank}(L_{1}\star\cdots\star L_{k})=𝗅𝖾𝗇(S1⋆⋯⋆Sk)=∑i=1k𝗅𝖾𝗇(Si)=∑i=1k𝗋𝖺𝗇𝗄(Li).\displaystyle=\mathsf{len}(S_{1}\star\cdots\star S_{k})=\sum_{i=1}^{k}\mathsf{len}(S_{i})=\sum_{i=1}^{k}\mathsf{rank}(L_{i}).For 2, we compute
𝗌𝗂𝗓𝖾(L1⋆⋯⋆Lk)\displaystyle\mathsf{size}(L_{1}\star\cdots\star L_{k})=𝗌𝗂𝗓𝖾(S1⋆⋯⋆Sk)=∏i=1k𝗌𝗂𝗓𝖾(Si)=∏i=1k𝗌𝗂𝗓𝖾(Li).\displaystyle=\mathsf{size}(S_{1}\star\cdots\star S_{k})=\prod_{i=1}^{k}\mathsf{size}(S_{i})=\prod_{i=1}^{k}\mathsf{size}(L_{i}).For 3, we compute
𝖼𝗈𝗌𝗂𝗓𝖾(L1⋆⋯⋆Lk)\displaystyle\mathsf{cosize}(L_{1}\star\cdots\star L_{k})=1+𝗆𝖺𝗑(ΦL1⋆⋯⋆Lk)\displaystyle=1+\mathsf{max}(\Phi_{L_{1}\star\cdots\star L_{k}})=1+∑i=1k𝗆𝖺𝗑(ΦLi)\displaystyle=1+\sum_{i=1}^{k}\mathsf{max}(\Phi_{L_{i}})=1−k+(1+𝗆𝖺𝗑(ΦL1))+⋯+(1+𝗆𝖺𝗑(ΦL1))\displaystyle=1-k+\left(1+\mathsf{max}(\Phi_{L_{1}})\right)+\cdots+\left(1+\mathsf{max}(\Phi_{L_{1}})\right)=1−k+𝖼𝗈𝗌𝗂𝗓𝖾(L1)+⋯+𝖼𝗈𝗌𝗂𝗓𝖾(Lk).\displaystyle=1-k+\mathsf{cosize}(L_{1})+\cdots+\mathsf{cosize}(L_{k}).where we have used our identification ofΦL1⋆⋯⋆Lk\Phi_{L_{1}\star\cdots\star L_{k}}from Proposition2.1.3.40. ∎
2.1.4Flat coalesce
We have seen that the layout functionΦL\Phi_{L}of a flat layoutLLis an important invariant. In many cases, we are only interested in the layout functionΦL\Phi_{L}, and are free to work with any layout whose layout function isΦL\Phi_{L}. The flat coalesce operation
L↦𝖼𝗈𝖺𝗅♭(L)L\mapsto\mathsf{coal}^{\flat}(L)provides us with the simplest flat layout whose layout function isΦL\Phi_{L}(see Proposition2.1.4.19).
We begin by defining the notion of a coalesced flat layout.
Definition 2.1.4.1.
SupposeL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. We sayLLiscoalescedif
- 1.for any1≤i≤m1\leq i\leq m, we havesi≠1s_{i}\neq 1, and
- 2.for any1≤i<m1\leq i<m, we havesidi≠di+1s_{i}d_{i}\neq d_{i+1}.
Example 2.1.4.2.
The flat layout
L=(3,5,2):(7,21,4)\displaystyle L=(3,5,2):(7,21,4)is not coalesced because3⋅7=213\cdot 7=21.
Example 2.1.4.3.
The flat layout
L=(2,7,6):(1,3,10)L=(2,7,6):(1,3,10)is coalesced.
Example 2.1.4.4.
The empty layoutE=():()E=():()is coalesced.
Example 2.1.4.5.
IfL=(s):(d)L=(s):(d)ands≠1s\neq 1, thenLLis coalesced.
Example 2.1.4.6.
IfL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a column-major layout with𝗋𝖺𝗇𝗄(L)>1\mathsf{rank}(L)>1, thenLLis not coalesced, since for any1≤i<m1\leq i<m, we have
sidi=si(s1⋯si−1)=s1⋯si=di+1.s_{i}d_{i}=s_{i}(s_{1}\cdots s_{i-1})=s_{1}\cdots s_{i}=d_{i+1}.
Example 2.1.4.7.
IfL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a row-major layout withsi>1s_{i}>1for all1≤i≤m1\leq i\leq m, thenLLis coalesced: If1≤i<m1\leq i<m, then
sidi=sisi+1⋯sm>si+2⋯sm=di+1.s_{i}d_{i}=s_{i}s_{i+1}\cdots s_{m}>s_{i+2}\cdots s_{m}=d_{i+1}.
Example 2.1.4.8.
A flat layout of the form
L=(s1,…,sm):(0,…,0)L=(s_{1},\dots,s_{m}):(0,\dots,0)is coalesced if and only ifm≤1m\leq 1.
IfLLis a flat layout, then we may obtain a coalesced layout𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)with the same layout function asLLby removing modes withsi=1s_{i}=1, and combining modes withsidi=di+1s_{i}d_{i}=d_{i+1}. More precisely, we make the following construction.
Construction 2.1.4.9.
SupposeLLis a flat layout, and write
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Let∼\simbe the equivalence relation on⟨m⟩\langle m\ranglegenerated byi∼i+1i\sim i+1if
sidi=di+1.s_{i}d_{i}=d_{i+1}.The quotient⟨m⟩/∼\langle m\rangle/\simis ordered by[i]≤[i′][i]\leq[i^{\prime}]ifi≤i′i\leq i^{\prime}, so we may identify⟨m⟩/∼\langle m\rangle/\simwith⟨m¯⟩\langle\bar{m}\rangle, wherem¯\bar{m}is the size of⟨m⟩/∼\langle m\rangle/\sim. Ifi∈⟨m¯⟩i\in\langle\bar{m}\ranglecorresponds to the equivalence class
I={i′,i′+1,…,i′+k}∈⟨m⟩/∼,I=\{i^{\prime},i^{\prime}+1,\dots,i^{\prime}+k\}\in\langle m\rangle/\sim,then we define integerss¯i\bar{s}_{i}andd¯i\bar{d}_{i}as
s¯i\displaystyle\bar{s}_{i}=si′si′+1⋯si′+k\displaystyle=s_{i^{\prime}}s_{i^{\prime}+1}\cdots s_{i^{\prime}+k}and
d¯i\displaystyle\bar{d}_{i}=di′,\displaystyle=d_{i^{\prime}},and define
𝖼𝗈𝖺𝗅♭(L)=(s¯1,…,s¯m¯):(d¯1,…,d¯m¯).\mathsf{coal}^{\flat}(L)=(\bar{s}_{1},\dots,\bar{s}_{\bar{m}}):(\bar{d}_{1},\dots,\bar{d}_{\bar{m}}).
Observation 2.1.4.10.
Examining the definition, we could equivalently define𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)to be the flat layout obtained from
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(s1,…,sm):(d1,…,dm)\mathsf{squeeze}(L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})by iteratively performing the operation
si,si+1:di,sidi↝sisi+1:dis_{i},s_{i+1}:d_{i},s_{i}d_{i}\hskip 14.45377pt\rightsquigarrow\hskip 14.45377pts_{i}s_{i+1}:d_{i}until the result is coalesced.
Example 2.1.4.11.
IfL=(2,2,2,2,2):(8,16,1024,2048,4096)L=(2,2,2,2,2):(8,16,1024,2048,4096), then
𝖼𝗈𝖺𝗅♭(L)=(4,8):(8,1024).\mathsf{coal}^{\flat}(L)=(4,8):(8,1024).
Example 2.1.4.12.
IfL=(3,4,1,5):(1,8,3,32)L=(3,4,1,5):(1,8,3,32), then
𝖼𝗈𝖺𝗅♭(L)=(3,20):(1,8).\mathsf{coal}^{\flat}(L)=(3,20):(1,8).
Example 2.1.4.13.
IfL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is column-major, and not allsis_{i}are equal to11, then
𝖼𝗈𝖺𝗅♭(L)=(s1⋯sm):(1).\mathsf{coal}^{\flat}(L)=(s_{1}\cdots s_{m}):(1).
Example 2.1.4.14.
IfLLis row-major, then
𝖼𝗈𝖺𝗅♭(L)=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L).\mathsf{coal}^{\flat}(L)=\mathsf{squeeze}(L).
Let’s justify that the operationL↦𝖼𝗈𝖺𝗅♭(L)L\mapsto\mathsf{coal}^{\flat}(L)results in a coalesced layout.
Lemma 2.1.4.15.
IfLLis a flat layout, then𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)is coalesced.
Proof.
Borrowing the notation of Construction2.1.4.9, let
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(s1,…,sm):(d1,…,dm)\mathsf{squeeze}(L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})and let
𝖼𝗈𝖺𝗅♭(L)=(s¯1,…,s¯m¯):(d¯1,…,d¯m¯).\mathsf{coal}^{\flat}(L)=(\bar{s}_{1},\dots,\bar{s}_{\bar{m}}):(\bar{d}_{1},\dots,\bar{d}_{\bar{m}}).We want to show that𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)is coalesced. Suppose1≤i≤m¯1\leq i\leq\bar{m}. Theniicorresponds to a (non-empty) equivalence classI∈⟨m⟩/∼I\in\langle m\rangle/\sim, and
s¯i=∏i′∈Isi′\bar{s}_{i}=\prod_{i^{\prime}\in I}s_{i^{\prime}}is a product of integerssi′>1s_{i^{\prime}}>1, sos¯i>1\bar{s}_{i}>1.
Suppose1≤i<m¯1\leq i<\bar{m}. We claim thats¯id¯i≠d¯i+1\bar{s}_{i}\bar{d}_{i}\neq\bar{d}_{i+1}. Supposeiicorresponds to the equivalence class
{i′,i′+1,…,i′+k}∈⟨m⟩/∼,\{i^{\prime},i^{\prime}+1,\dots,i^{\prime}+k\}\in\langle m\rangle/\sim,and supposei+1i+1corresponds to the equivalence class
{i′+k+1,i′+k+2,…,i′+k+ℓ}∈⟨m⟩/∼.\{i^{\prime}+k+1,i^{\prime}+k+2,\dots,i^{\prime}+k+\ell\}\in\langle m\rangle/\sim.Then by using the equalitiessi′+tdi′+t=di′+t+1s_{i^{\prime}+t}d_{i^{\prime}+t}=d_{i^{\prime}+t+1}for0≤t<k0\leq t<k, we may write
s¯id¯i=d¯is¯i\displaystyle\bar{s}_{i}\bar{d}_{i}=\bar{d}_{i}\bar{s}_{i}=di′si′si′+1⋯si′+k\displaystyle=d_{i^{\prime}}s_{i^{\prime}}s_{i^{\prime}+1}\cdots s_{i^{\prime}+k}=di′+1si′+1⋯si′+k\displaystyle=d_{i^{\prime}+1}s_{i^{\prime}+1}\cdots s_{i^{\prime}+k}⋮\displaystyle\hskip 5.78172pt\vdots=di′+ksi′+k\displaystyle=d_{i^{\prime}+k}s_{i^{\prime}+k}=si′+kdi′+k\displaystyle=s_{i^{\prime}+k}d_{i^{\prime}+k}and sincei′+ki^{\prime}+kandi′+k+1i^{\prime}+k+1do not lie in the same equivalence class, we have
s¯id¯i=si′+kdi′+k≠di′+k+1=d¯i+1.\displaystyle\bar{s}_{i}\bar{d}_{i}=s_{i^{\prime}+k}d_{i^{\prime}+k}\neq d_{i^{\prime}+k+1}=\bar{d}_{i+1}.∎
Example 2.1.4.16.
IfLLis coalesced, then𝖼𝗈𝖺𝗅♭(L)=L\mathsf{coal}^{\flat}(L)=L. In particular, this implies that𝖼𝗈𝖺𝗅♭(−)\mathsf{coal}^{\flat}(-)is an idempotent operation:
𝖼𝗈𝖺𝗅♭(𝖼𝗈𝖺𝗅♭(L))=𝖼𝗈𝖺𝗅♭(L).\mathsf{coal}^{\flat}(\mathsf{coal}^{\flat}(L))=\mathsf{coal}^{\flat}(L).
Next, we argue that coalescing a flat layout leaves the layout function unchanged.
Lemma 2.1.4.17.
IfLLis a flat layout, thenΦ𝖼𝗈𝖺𝗅♭(L)=ΦL\Phi_{\mathsf{coal}^{\flat}(L)}=\Phi_{L}.
Proof.
By Observation2.1.4.10, it suffices to show that replacing an instance ofsi,si+1:di,sidis_{i},s_{i+1}:d_{i},s_{i}d_{i}withsisi+1:dis_{i}s_{i+1}:d_{i}leaves the layout function unchanged. Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout, and there exists some1≤i<m1\leq i<msuch thatdi+1=sidid_{i+1}=s_{i}d_{i}. Let
L′\displaystyle L^{\prime}=(s1′,…,sm−1′):(d1′,…,dm−1′)\displaystyle=(s_{1}^{\prime},\dots,s_{m-1}^{\prime}):(d_{1}^{\prime},\dots,d_{m-1}^{\prime})denote the flat layout obtained fromLLby combining theiith and(i+1)(i+1)th modes ofLL. More precisely, we have
sj′={sjj<isisi+1j=isj+1i<j<m,anddj′={djj≤idj+1i<j<m.s_{j}^{\prime}=\begin{cases}s_{j}&j<i\\ s_{i}s_{i+1}&j=i\\ s_{j+1}&i<j<m,\end{cases}\hskip 14.45377pt\text{ and }\hskip 14.45377ptd_{j}^{\prime}=\begin{cases}d_{j}&j\leq i\\ d_{j+1}&i<j<m.\end{cases}The layout function forLLis given by
ΦL(x)=x1d1+⋯+xmdm\Phi_{L}(x)=x_{1}d_{1}+\cdots+x_{m}d_{m}wherexj=⌊xs1⋯sj−1⌋modsjx_{j}=\left\lfloor\dfrac{x}{s_{1}\cdots s_{j-1}}\right\rfloor\mod s_{j}, and the layout function forL′L^{\prime}is given by
ΦL′(x)=x1′d1′+⋯+xm−1′dm−1′\Phi_{L^{\prime}}(x)=x_{1}^{\prime}d_{1}^{\prime}+\cdots+x_{m-1}^{\prime}d_{m-1}^{\prime}wherexj′=⌊xs1′⋯sj−1′⌋modsj′x_{j}^{\prime}=\left\lfloor\dfrac{x}{s_{1}^{\prime}\cdots s_{j-1}^{\prime}}\right\rfloor\mod s_{j}^{\prime}. We observe that
xj′={xjj<ixi+xi+1sij=ixj+1i<j<m,x_{j}^{\prime}=\begin{cases}x_{j}&j<i\\ x_{i}+x_{i+1}s_{i}&j=i\\ x_{j+1}&i<j<m,\end{cases}and so
ΦL(x)\displaystyle\Phi_{L}(x)=x1d1+⋯+xmdm\displaystyle=x_{1}d_{1}+\cdots+x_{m}d_{m}=x1d1+⋯+xidi+xi+1sidi+⋯+xmdm\displaystyle=x_{1}d_{1}+\cdots+x_{i}d_{i}+x_{i+1}s_{i}d_{i}+\cdots+x_{m}d_{m}=x1d1+⋯+(xi+xi+1si)di+⋯+xmdm\displaystyle=x_{1}d_{1}+\cdots+(x_{i}+x_{i+1}s_{i})d_{i}+\cdots+x_{m}d_{m}=x1′d1′+⋯+xm−1′dm−1′\displaystyle=x_{1}^{\prime}d_{1}^{\prime}+\cdots+x_{m-1}^{\prime}d_{m-1}^{\prime}=ΦL′(x).\displaystyle=\Phi_{L^{\prime}}(x). ∎
We can use the coalesce operation to characterize when two flat layouts have the same layout function.
Proposition 2.1.4.18.
SupposeAAandBBare flat layouts. Then
ΦA=ΦB⇔𝖼𝗈𝖺𝗅♭(A)=𝖼𝗈𝖺𝗅♭(B).\Phi_{A}=\Phi_{B}\quad\Leftrightarrow\quad\mathsf{coal}^{\flat}(A)=\mathsf{coal}^{\flat}(B).
Proof.
If𝖼𝗈𝖺𝗅♭(A)=𝖼𝗈𝖺𝗅♭(B)\mathsf{coal}^{\flat}(A)=\mathsf{coal}^{\flat}(B), then by Lemma2.1.4.17, we have
ΦA=Φ𝖼𝗈𝖺𝗅♭(A)=Φ𝖼𝗈𝖺𝗅♭(B)=ΦB.\Phi_{A}=\Phi_{\mathsf{coal}^{\flat}(A)}=\Phi_{\mathsf{coal}^{\flat}(B)}=\Phi_{B}. Inversely, suppose that𝖼𝗈𝖺𝗅♭(A)≠𝖼𝗈𝖺𝗅♭(B)\mathsf{coal}^{\flat}(A)\neq\mathsf{coal}^{\flat}(B). We will argue thatΦA≠ΦB\Phi_{A}\neq\Phi_{B}. Let’s write
𝖼𝗈𝖺𝗅♭(A)\displaystyle\mathsf{coal}^{\flat}(A)=(s1,…,sm):(d1,…,dm),\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})\text{,}𝖼𝗈𝖺𝗅♭(B)\displaystyle\mathsf{coal}^{\flat}(B)=(t1,…,tn):(e1,…,em).\displaystyle=(t_{1},\dots,t_{n}):(e_{1},\dots,e_{m}).If one ofm,nm,nis nonzero and the other is00, then clearlyΦA≠ΦB\Phi_{A}\neq\Phi_{B}, so we may assumem,n≥1m,n\geq 1. Letiidenote the least integer such that(si,di)≠(ti,ei)(s_{i},d_{i})\neq(t_{i},e_{i}). Then, in particular, we haves1⋯sj=t1⋯tjs_{1}\cdots s_{j}=t_{1}\cdots t_{j}for anyj<ij<i. There are two cases to consider:
- •(Case 1): Supposedi≠eid_{i}\neq e_{i}. LetN=s1⋯si−1=t1⋯ti−1N=s_{1}\cdots s_{i-1}=t_{1}\cdots t_{i-1}. Then Φ𝖼𝗈𝖺𝗅♭(A)(N)=di≠ei=Φ𝖼𝗈𝖺𝗅♭(B)(N)\Phi_{\mathsf{coal}^{\flat}(A)}(N)=d_{i}\neq e_{i}=\Phi_{\mathsf{coal}^{\flat}(B)}(N)soΦ𝖼𝗈𝖺𝗅♭(A)≠Φ𝖼𝗈𝖺𝗅♭(B)\Phi_{\mathsf{coal}^{\flat}(A)}\neq\Phi_{\mathsf{coal}^{\flat}(B)}, and henceΦA≠ΦB\Phi_{A}\neq\Phi_{B}.
- •(Case 2): Supposedi=eid_{i}=e_{i}, so thatsi≠tis_{i}\neq t_{i}. Without loss of generality we may assumesi<tis_{i}<t_{i}. LetN=s1⋯si=(t1⋯ti−1)siN=s_{1}\cdots s_{i}=(t_{1}\cdots t_{i-1})s_{i}. Then Φ𝖼𝗈𝖺𝗅♭(A)(N)=di+1\Phi_{\mathsf{coal}^{\flat}(A)}(N)=d_{i+1}while Φ𝖼𝗈𝖺𝗅♭(B)(N)\displaystyle\Phi_{\mathsf{coal}^{\flat}(B)}(N)=siei\displaystyle=s_{i}e_{i}=sidi,\displaystyle=s_{i}d_{i},and since𝖼𝗈𝖺𝗅♭(A)\mathsf{coal}^{\flat}(A)is coalesced, we havedi+1≠sidid_{i+1}\neq s_{i}d_{i}. We deduce thatΦ𝖼𝗈𝖺𝗅♭(A)≠Φ𝖼𝗈𝖺𝗅♭(B)\Phi_{\mathsf{coal}^{\flat}(A)}\neq\Phi_{\mathsf{coal}^{\flat}(B)}, and henceΦA≠ΦB\Phi_{A}\neq\Phi_{B}.
∎
The previous proposition affords us the following abstract characterization of𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L).
Proposition 2.1.4.19.
IfLLis a flat layout, then𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)is the unique flat layout of minimal rank whose layout function isΦL\Phi_{L}.
Proof.
SupposeL′L^{\prime}is a flat layout withΦL′=ΦL\Phi_{L^{\prime}}=\Phi_{L}. Then by Proposition2.1.4.18, we have
𝖼𝗈𝖺𝗅♭(L)=𝖼𝗈𝖺𝗅♭(L′),\mathsf{coal}^{\flat}(L)=\mathsf{coal}^{\flat}(L^{\prime}),and it follows that
𝗋𝖺𝗇𝗄(𝖼𝗈𝖺𝗅♭(L))=𝗋𝖺𝗇𝗄(𝖼𝗈𝖺𝗅♭(L′))≤𝗋𝖺𝗇𝗄(L′),\mathsf{rank}(\mathsf{coal}^{\flat}(L))=\mathsf{rank}(\mathsf{coal}^{\flat}(L^{\prime}))\leq\mathsf{rank}(L^{\prime}),where equality holds if and only if
L′=𝖼𝗈𝖺𝗅♭(L′)=𝖼𝗈𝖺𝗅♭(L).L^{\prime}=\mathsf{coal}^{\flat}(L^{\prime})=\mathsf{coal}^{\flat}(L).∎
2.1.5Compact flat layouts
Before treating layout complements, we must define an important family of layouts calledcompactflat layouts. These are the flat layouts whose layout functions are bijective. In terms of the standard grid diagrams depicting layouts, a flat layoutLLis compact if each integer0≤i<𝗌𝗂𝗓𝖾(L)0\leq i<\mathsf{size}(L)appears exactly once. For instance, the layout
03691215147101316258111417A=(3,6):(1,3)=A=(3,6):(1,3)=is compact, while the layouts
0612182430281420263241016222834B=(3,6):(2,6)=B=(3,6):(2,6)=and
0246810135791124681012C=(3,6):(1,2)=C=(3,6):(1,2)=are not compact. More precisely, we have the following definition.
Definition 2.1.5.1.
SupposeLLis a flat layout. We sayLLiscompactif
[0,𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(L){)}}[0,𝖼𝗈𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{cosize}(L){)}}ΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\scriptstyle{\lx@inpgf@ignorespaces\Phi_{L}^{\mathsf{cosize}(L)}}is an isomorphism.
Example 2.1.5.2.
The flat layout
L=(2,2,2,2):(1,2,4,8)L=(2,2,2,2):(1,2,4,8)is compact. More generally, ifLLis column-major, thenLLis compact.
Example 2.1.5.3.
The flat layout
L=(3,64,32):(2048,32,1)L=(3,64,32):(2048,32,1)is compact. More generally, ifLLis row-major, thenLLis compact.
Example 2.1.5.4.
The empty layout
is compact.
Example 2.1.5.5.
Suppose
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. If there is some mode ofLLwithsi>1s_{i}>1anddi=0d_{i}=0, thenLLis not compact.
We can give an explicit characterization of compact layouts as follows.
Proposition 2.1.5.6.
SupposeLLis a flat layout, and write
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).thenLLis compact if and only if there exists a permutationσ∈Σm\sigma\in\Sigma_{m}such that
dσ(i)=sσ(1)⋯sσ(i−1)d_{\sigma(i)}=s_{\sigma(1)}\cdots s_{\sigma(i-1)}for all1≤i≤m1\leq i\leq m. In other words,LLis compact if and only if there exists a permutationσ∈Σm\sigma\in\Sigma_{m}such that𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)σ\mathsf{squeeze}(L)^{\sigma}is column-major.
Proof.
SupposeLLis a flat layout, and write
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Suppose first thatLLis compact, so there exists a permutationσ∈Σm\sigma\in\Sigma_{m}such thatdσ(i)=sσ(1)⋯sσ(i−1)d_{\sigma(i)}=s_{\sigma(1)}\cdots s_{\sigma(i-1)}for each1≤i≤m1\leq i\leq m. If we writeSσ=(sσ(1),…,sσ(m))S^{\sigma}=(s_{\sigma(1)},\dots,s_{\sigma(m)}), then we can writeΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}as the composite
[0,𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(L){)}}[0,S){\lx@inpgf@ignorespaces{[}0,S{)}}[0,Sσ){\lx@inpgf@ignorespaces{[}0,S^{\sigma}{)}}[0,𝖼𝗈𝗌𝗂𝗓𝖾(L)){\lx@inpgf@ignorespaces{[}0,\mathsf{cosize}(L){)}}(x1,…,xm){\lx@inpgf@ignorespaces(x_{1},\dots,x_{m})}(xσ(1),…,xσ(m)){\lx@inpgf@ignorespaces(x_{\sigma(1)},\dots,x_{\sigma(m)})}𝖼𝗈𝗅𝖾𝗑S−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S}^{-1}}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}𝖼𝗈𝗅𝖾𝗑Sσ\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}_{S^{\sigma}}}and since each of these maps is an isomorphism, so is the compositeΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}.
Conversely, suppose thatΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}is an isomorphism. First, we note that the stridesd1,…,dmd_{1},\dots,d_{m}must be pairwise distinct: Supposedi=djd_{i}=d_{j}, and letδim\delta_{i}^{m}andδjm\delta_{j}^{m}denote the tuples whoseiith (resp.jjth) entry is11, and all of whose other entries are00. These tuples satisfy
δim⋅(d1,…,dm)=di=dj=δjm⋅(d1,…,dm),\delta_{i}^{m}\cdot(d_{1},\dots,d_{m})=d_{i}=d_{j}=\delta_{j}^{m}\cdot(d_{1},\dots,d_{m}),and sinceΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}is injective, we must havei=ji=j. Given that the stridesd1,…,dmd_{1},\dots,d_{m}are pairwise distinct, letσ∈Σm\sigma\in\Sigma_{m}be the permutation such that
dσ(1)<dσ(2)<⋯<dσ(m).d_{\sigma(1)}<d_{\sigma(2)}<\cdots<d_{\sigma(m)}.We will argue by induction oni≥1i\geq 1thatdσ(i)=sσ(1)⋯sσ(i−1)d_{\sigma(i)}=s_{\sigma(1)}\cdots s_{\sigma(i-1)}. For the base casei=1i=1, we note that11is in the image ofΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}, and the smallest non-zero value ofΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}isdσ(1)d_{\sigma(1)}, so it follows thatdσ(1)=1d_{\sigma(1)}=1. Supposei>1i>1, and that we have proved the claim for allj<ij<i. Consider the stridedσ(i)d_{\sigma(i)}. We know that there is no tuple of the form(x1,…,xi−1,0,…,0)σ(x_{1},\dots,x_{i-1},0,\dots,0)^{\sigma}such that
(x1,…,xi−1,0,…,0)σ⋅(d1,…,dm)=sσ(1)⋯sσ(i−1),(x_{1},\dots,x_{i-1},0,\dots,0)^{\sigma}\cdot(d_{1},\dots,d_{m})=s_{\sigma(1)}\cdots s_{\sigma(i-1)},since the largest possible value of such an expression is
∑j=1i−1(sσ(j)−1)(sσ(1)⋯sσ(j−1))=sσ(1)⋯sσ(i−1)−1.\sum_{j=1}^{i-1}(s_{\sigma(j)}-1)(s_{\sigma(1)}\cdots s_{\sigma(j-1)})=s_{\sigma(1)}\cdots s_{\sigma(i-1)}-1.SinceΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}}(L)is surjective, anddσ(i)<dσ(i+1)<⋯<dσ(m)d_{\sigma(i)}<d_{\sigma(i+1)}<\cdots<d_{\sigma(m)}, it follows that the next largest value ofΦL𝖼𝗈𝗌𝗂𝗓𝖾(L)\Phi_{L}^{\mathsf{cosize}(L)}isdσ(i)d_{\sigma(i)}, so we must havedσ(i)=sσ(1)⋯sσ(i−1)d_{\sigma(i)}=s_{\sigma(1)}\cdots s_{\sigma(i-1)}, as claimed. ∎
We conclude this section by giving a family of equivalent conditions for a flat layoutLLto be compact.
Proposition 2.1.5.7.
SupposeLLis a flat layout. Then the following are equivalent.
- 1.LLis compact.
- 2.𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)is compact.
- 3.𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)\mathsf{squeeze}(L)is compact.
- 4.OPENL)L)is compact.
Proof.
The equivalence of 1, 2, and 3, follows from the fact that
ΦL=Φ𝖼𝗈𝖺𝗅♭(L)=Φ𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L).\Phi_{L}=\Phi_{\mathsf{coal}^{\flat}(L)}=\Phi_{\mathsf{squeeze}(L)}.It remains to prove thatLLis compact if and only ifOPENL)L)is compact. Using the fact that
OPENOPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)),\mathsf{squeeze}(L))=\mathsf{squeeze}(L)),we have
OPENL)is compact.\displaystyle L)\text{ is compact.}\hskip 14.45377pt⇔𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))is compact.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{squeeze}(L))\text{ is compact.}⇔𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))is compact.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{squeeze}(L))\text{ is compact.}NowOPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)τ\mathsf{squeeze}(L))=\mathsf{squeeze}(L)^{\tau}for some permutationτ∈Σm\tau\in\Sigma_{m}, so there exists a permutationσ\sigmasuch that𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)σ\mathsf{squeeze}(L)^{\sigma}is column-major if and only if there exists a permutationσ′∈Σm\sigma^{\prime}\in\Sigma_{m}such thatOPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))\mathsf{squeeze}(L))is column-major, namelyσ′=τ−1σ\sigma^{\prime}=\tau^{-1}\sigma. It follows that
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L))is compact.\displaystyle\mathsf{squeeze}(L))\text{ is compact.}⇔𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)is compact.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{squeeze}(L)\text{ is compact.}⇔Lis compact.\displaystyle\Leftrightarrow\hskip 14.45377ptL\text{ is compact.}∎
2.1.6Complements
In this section, we define the notion of complementary flat layouts. Recall from Definition2.1.5.1that a flat layoutLLiscompactif the layout function
ΦL𝖼𝗈𝗌𝗂𝗓𝖾(L):[0,𝗌𝗂𝗓𝖾(L))→[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))\Phi_{L}^{\mathsf{cosize}(L)}:[0,\mathsf{size}(L))\to[0,\mathsf{cosize}(L))is an isomorphism.
Definition 2.1.6.1.
SupposeAAandBBare flat layouts. We sayBBis acomplementofAA, and writeA⟂BA\perp B, if the concatenated layoutA⋆BA\star Bis compact.
Example 2.1.6.2.
IfA=(3):(5)A=(3):(5)andB=(5):(1)B=(5):(1), thenA⟂BA\perp Bsince
A⋆B=(3,5):(5,1)A\star B=(3,5):(5,1)is compact.
01234B=B=0510A=A=01234567891011121314=A⋆B=A\star B
Example 2.1.6.3.
IfA=(4,2,10):(1400,2,20)A=(4,2,10):(1400,2,20)andB=(2,5,7,2):(1,4,200,5600)B=(2,5,7,2):(1,4,200,5600), thenA⟂BA\perp Bsince
A⋆B=(4,2,10,2,5,7,2):(1400,2,20,1,4,200,5600)A\star B=(4,2,10,2,5,7,2):(1400,2,20,1,4,200,5600)is compact.
Example 2.1.6.4.
IfAAis a flat layout andE=():()E=():()is the empty layout, thenA⟂AA\perp Aif and only ifAAis compact, since
Example 2.1.6.5.
IfAAandBBare flat layouts, then
A⟂B⇔B⟂A.A\perp B\quad\Leftrightarrow\quad B\perp A.
Example 2.1.6.6.
IfAAis a flat layout, thenA⟂AA\perp Aif and only if𝗌𝗂𝗓𝖾(A)=1\mathsf{size}(A)=1.
Observation 2.1.6.7.
In order forAAto admit a complement, it is necessary thatΦA\Phi_{A}is injective. There do, however, exist flat layoutsAAsuch thatΦA\Phi_{A}is injective, andAAdoes not admit a complement. For example, consider the layout
A=(2,2):(1,3).A=(2,2):(1,3).The layout function ofAAis injective since
ΦA(0)=0,ΦA(1)=1,ΦA(2)=3, andΦA(3)=4,\displaystyle\Phi_{A}(0)=0\text{, }\Phi_{A}(1)=1\text{, }\Phi_{A}(2)=3\text{, and }\Phi_{A}(3)=4,butAAdoes not admit a complement: Suppose
B=(s1,…,sm):(d1,…,dm)B=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is any other flat layout. If there does not exist a tuple
(x1,x2,y1,…,ym)∈[0,2)×[0,2)×[0,s1)×⋯×[0,sm)(x_{1},x_{2},y_{1},\dots,y_{m})\in[0,2)\times[0,2)\times[0,s_{1})\times\cdots\times[0,s_{m})such thatφA⋆B(x1,x2,y1,…,ym)=2\varphi_{A\star B}(x_{1},x_{2},y_{1},\dots,y_{m})=2, thenA⋆BA\star Bis not compact. Suppose otherwise that there is such a tuple(x1,x2,y1,…,ym)(x_{1},x_{2},y_{1},\dots,y_{m}). ThenφB(y1,…,ym)∈{0,1,2}\varphi_{B}(y_{1},\dots,y_{m})\in\{0,1,2\}.
- •(Case 1): IfφB(y1,…,ym)=0\varphi_{B}(y_{1},\dots,y_{m})=0, then φA⋆B(0,0,0,…,0)=0=φA⋆B(0,0,y1,…,ym).\displaystyle\varphi_{A\star B}(0,0,0,\dots,0)=0=\varphi_{A\star B}(0,0,y_{1},\dots,y_{m}).
- •(Case 2): IfφB(y1,…,ym)=1\varphi_{B}(y_{1},\dots,y_{m})=1, then φA⋆B(1,0,0,…,0)=1=φA⋆B(0,0,y1,…,ym).\displaystyle\varphi_{A\star B}(1,0,0,\dots,0)=1=\varphi_{A\star B}(0,0,y_{1},\dots,y_{m}).
- •(Case 3): IfφB(y1,…,ym)=2\varphi_{B}(y_{1},\dots,y_{m})=2, then φA⋆B(0,1,0,…,0)=3=φA⋆B(1,0,y1,…,ym).\varphi_{A\star B}(0,1,0,\dots,0)=3=\varphi_{A\star B}(1,0,y_{1},\dots,y_{m}).
In any case, we deduce thatφA⋆B\varphi_{A\star B}is not injective, hence neither isΦA⋆B\Phi_{A\star B}. This implies thatA⋆BA\star Bis not compact, soBBis not a complement ofAA.
Observation 2.1.6.8.
Complements are not unique. For example, if
A=(8,8):(2,32),A=(8,8):(2,32),then each of the layouts
B1\displaystyle B_{1}=(2,2):(1,16)\displaystyle=(2,2):(1,16)B2\displaystyle B_{2}=(2,2):(16,1)\displaystyle=(2,2):(16,1)B3\displaystyle B_{3}=(5,2,2,1):(256,1,16,0)\displaystyle=(5,2,2,1):(256,1,16,0)is a complement ofAA. Instead, there is a (possibly empty) set
𝖼𝗈𝗆𝗉𝗅𝖾𝗆𝖾𝗇𝗍𝗌♭(A)={flat layoutsB∣Bis a complement ofA}.\mathsf{complements}^{\flat}(A)=\{\text{flat layouts }B\mid B\text{ is a complement of }A\}.of layouts which are complementary toAA.
It will be useful to provide a family of equivalent conditions forBBto be a complement ofAA(see Proposition2.1.6.10). In order to do so, we need the following technical lemma, which describes the interplay between concatenation, and the operations𝗌𝗊𝗎𝖾𝖾𝗓𝖾(−)\mathsf{squeeze}(-),OPEN−)-), and𝖼𝗈𝖺𝗅♭(−)\mathsf{coal}^{\flat}(-).
Lemma 2.1.6.9.
SupposeAAandBBare flat layouts. Then
- 1.𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A⋆B)=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B)\mathsf{squeeze}(A\star B)=\mathsf{squeeze}(A)\star\mathsf{squeeze}(B),
- 2.A⋆B)=L⋆B))A\star B)=L\star B)), and
- 3.𝖼𝗈𝖺𝗅♭(A⋆B)=𝖼𝗈𝖺𝗅♭(A⋆𝖼𝗈𝖺𝗅♭(B))\mathsf{coal}^{\flat}(A\star B)=\mathsf{coal}^{\flat}(A\star\mathsf{coal}^{\flat}(B)).
Proof.
Write
A\displaystyle A=(s1,…,sm):(d1,…,dm)\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})B\displaystyle B=(t1,…,tn):(e1,…,en).\displaystyle=(t_{1},\dots,t_{n}):(e_{1},\dots,e_{n}).If we let{i1<⋯<im′}⊂⟨m⟩\{i_{1}<\dots<i_{m^{\prime}}\}\subset\langle m\rangledenote the indices withsik≠1s_{i_{k}}\neq 1, and{j1,…,jn′}⊂⟨n⟩\{j_{1},\dots,j_{n^{\prime}}\}\subset\langle n\rangledenote the indices withtjℓ≠1t_{j_{\ell}}\neq 1, then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A⋆B)\displaystyle\mathsf{squeeze}(A\star B)=(si1,…,sim′,tj1,…,tjn′):(di1,…,dim′,ej1,…,ejn′)\displaystyle=(s_{i_{1}},\dots,s_{i_{m^{\prime}}},t_{j_{1}},\dots,t_{j_{n^{\prime}}}):(d_{i_{1}},\dots,d_{i_{m^{\prime}}},e_{j_{1}},\dots,e_{j_{n^{\prime}}})=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B).\displaystyle=\mathsf{squeeze}(A)\star\mathsf{squeeze}(B).This proves 1. For 2, we note that for any flat layoutLL, and any permutationσ∈Σ𝗅𝖾𝗇(L)\sigma\in\Sigma_{\mathsf{len}(L)}, we haveOPENOPENL)=Lσ)L)=L^{\sigma}). The result follows from the observation that
OPENA⋆B)=(A⋆B)σA\star B)=(A\star B)^{\sigma}whereσ\sigmais a block permutation of the formσ=𝗂𝖽×σ′∈Σm×Σn⊂Σm+n\sigma=\mathsf{id}\times\sigma^{\prime}\in\Sigma_{m}\times\Sigma_{n}\subset\Sigma_{m+n}. For 3., it suffices to show thatA⋆BA\star BandA⋆𝖼𝗈𝖺𝗅♭(B)A\star\mathsf{coal}^{\flat}(B)have the same layout function. This follows from Proposition2.1.3.40. ∎
Proposition 2.1.6.10.
SupposeAAandBBare flat layouts. Then the following are equivalent.
- 1.A⟂BA\perp B.
- 2.B⟂AB\perp A.
- 3.A⟂𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B)A\perp\mathsf{squeeze}(B).
- 4.A⟂𝖼𝗈𝖺𝗅♭(B)A\perp\mathsf{coal}^{\flat}(B).
- 5.OPENA⟂B)A\perp B).
Proof.
We use Proposition2.1.5.7and Lemma2.1.6.9to prove the equivalence of these conditions. First, we note thatOPENOPENA⋆B)=B⋆A)A\star B)=B\star A), which implies the equivalence of 1 and 2. Next, we note that, by Lemma2.1.6.9, if𝗈𝗉(−)\mathsf{op}(-)is any of the operations𝗌𝗊𝗎𝖾𝖾𝗓𝖾(−)\mathsf{squeeze}(-),OPEN−)-), or𝖼𝗈𝖺𝗅♭(−)\mathsf{coal}^{\flat}(-), then
𝗈𝗉(A⋆B)=𝗈𝗉(A⋆𝗈𝗉(B)),\mathsf{op}(A\star B)=\mathsf{op}(A\star\mathsf{op}(B)),and so
A⟂B\displaystyle A\perp B\hskip 14.45377pt⇔A⋆Bis compact.\displaystyle\Leftrightarrow\hskip 14.45377ptA\star B\text{ is compact}.⇔𝗈𝗉(A⋆B)is compact.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{op}(A\star B)\text{ is compact}.⇔𝗈𝗉(A⋆𝗈𝗉(B))is compact.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{op}(A\star\mathsf{op}(B))\text{ is compact}.⇔𝗈𝗉(B)is a complement ofA.\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{op}(B)\text{ is a complement of }A.∎
We would like to characterize when a flat layout admits a complement. To this end, we make the following definition.
Definition 2.1.6.11.
SupposeAAis a flat layout, and write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).We sayAAiscomplementableif for any1≤i<m1\leq i<m, the integersidis_{i}d_{i}dividesdi+1d_{i+1}.
Example 2.1.6.12.
The flat layout
A1=(4,1,1,4,4):(64,0,0,1,8)A_{1}=(4,1,1,4,4):(64,0,0,1,8)is complementable, while the flat layout
A2=(4,4,4):(64,1,1)A_{2}=(4,4,4):(64,1,1)is not complementable.
Example 2.1.6.13.
The flat layout
A1=(10,2):(4,80)A_{1}=(10,2):(4,80)complementable, while the flat layout
A2=(10,2):(80,4)A_{2}=(10,2):(80,4)is not complementable.
Example 2.1.6.14.
IfAAis compact, then by Proposition2.1.5.6,AAis complementable.
Example 2.1.6.15.
Suppose
A=(s1,…,sm):(d1,…,dm)A=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout. If there is any1≤i≤m1\leq i\leq msuch thatsi≠1s_{i}\neq 1anddi=0d_{i}=0, thenAAis not complementable.
IfAAis complementable, then we can construct a complement ofAAas follows.
Construction 2.1.6.16.
SupposeAAis a flat layout, and write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).IfAAis complementable, then we define a flat layout𝖼𝗈𝗆𝗉♭(A)\mathsf{comp}^{\flat}(A)as
𝖼𝗈𝗆𝗉♭(A)=𝖼𝗈𝖺𝗅♭(C)\mathsf{comp}^{\flat}(A)=\mathsf{coal}^{\flat}(C)where
C=(d1,d2s1d1,d3s2d2,…,dmsm−1dm−1):(1,s1d1,s2d2,…,sm−1dm−1).C=\Bigl(d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dfrac{d_{3}}{s_{2}d_{2}},\dots,\dfrac{d_{m}}{s_{m-1}d_{m-1}}\Bigr):\Bigl(1,s_{1}d_{1},s_{2}d_{2},\dots,s_{m-1}d_{m-1}\Bigr).
Example 2.1.6.17.
IfA=(8,8):(1,8)A=(8,8):(1,8), then
𝖼𝗈𝗆𝗉♭(A)=():()\mathsf{comp}^{\flat}(A)=():()is the empty layout. More generally, ifAAis compact, then𝖼𝗈𝗆𝗉♭(A)=():()\mathsf{comp}^{\flat}(A)=():()is the empty layout.
Example 2.1.6.18.
IfA=(2,2):(2,8)A=(2,2):(2,8), then
𝖼𝗈𝗆𝗉♭(A)=(2,2):(1,4).\mathsf{comp}^{\flat}(A)=(2,2):(1,4).
Example 2.1.6.19.
IfA=(3,3,8):(16,96,1)A=(3,3,8):(16,96,1), then
𝖼𝗈𝗆𝗉♭(A)=(2,2):(8,48).\mathsf{comp}^{\flat}(A)=(2,2):(8,48).
Let’s justify that𝖼𝗈𝗆𝗉♭(A)\mathsf{comp}^{\flat}(A)is, in fact, a complement ofAA.
Lemma 2.1.6.20.
SupposeAAis a flat layout. IfAAis a complementable, then
A⟂𝖼𝗈𝗆𝗉♭(A).A\perp\mathsf{comp}^{\flat}(A).
Proof.
Lets write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm),\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),so that𝖼𝗈𝗆𝗉♭(A)=𝖼𝗈𝖺𝗅♭(C)\mathsf{comp}^{\flat}(A)=\mathsf{coal}^{\flat}(C)where
C=(d1,d2s1d1,d3s2d2,…,dmsm−1dm−1):(1,s1d1,s2d2,…,sm−1dm−1).C=\Bigl(d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dfrac{d_{3}}{s_{2}d_{2}},\dots,\dfrac{d_{m}}{s_{m-1}d_{m-1}}\Bigr):\Bigl(1,s_{1}d_{1},s_{2}d_{2},\dots,s_{m-1}d_{m-1}\Bigr).By Proposition2.1.6.10, it suffices to prove thatCCis a complement ofOPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))\mathsf{squeeze}(A)). This is the case since the concatenation
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))⋆C\mathsf{squeeze}(A))\star Cis equal to
(s1,…,sm,d1,d2s1d1,…,dmsm−1dm−1):(d1,…,dm,1,s1d1,…,sm−1dm−1),\displaystyle\left(s_{1},\dots,s_{m},d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dots,\dfrac{d_{m}}{s_{m-1}d_{m-1}}\right):(d_{1},\dots,d_{m},1,s_{1}d_{1},\dots,s_{m-1}d_{m-1}),and its sorting is equal to
(d1,s1,d2s1d1,…,dmsm−1dm−1,sm):(1,d1,s1d1,…,sm−1dm−1,dm)\left(d_{1},s_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dots,\dfrac{d_{m}}{s_{m-1}{d_{m-1}}},s_{m}\right):(1,d_{1},s_{1}d_{1},\dots,s_{m-1}d_{m-1},d_{m})which is column-major. ∎
We have shown that ifAAis complementable, thenAAadmits a complement. Next, we prove that the converse also holds.
Proposition 2.1.6.21.
SupposeAAis a flat layout. Then there exists a complementBBofAAif and only ifAAis complementable.
Proof.
IfAAis complementable, then by Lemma2.1.6.20the layoutB=𝖼𝗈𝗆𝗉♭(A)B=\mathsf{comp}^{\flat}(A)is a complement ofAA. Conversely, suppose there exists a complementBBofAA, and consider the flat layout
L\displaystyle L=(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B))\displaystyle=(\mathsf{squeeze}(A)\star\mathsf{squeeze}(B)\bigr)=(s1,…,sm):(d1,…,dn).\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{n}).SinceΦL(0)=0\Phi_{L}(0)=0, andΦL\Phi_{L}is injective, we know thatd1≠0d_{1}\neq 0. We will argue thatdi=s1⋯si−1d_{i}=s_{1}\cdots s_{i-1}, i.e., thatLLis column-major. Since
ΦL𝖼𝗈𝗌𝗂𝗓𝖾(L):[0,𝗌𝗂𝗓𝖾(L))→[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))\Phi_{L}^{\mathsf{cosize}(L)}:[0,\mathsf{size}(L))\to[0,\mathsf{cosize}(L))is a bijection, we know that11is in the image ofΦL\Phi_{L}, which implies thatd1=1d_{1}=1. Suppose1<i≤m1<i\leq m, and suppose we have proved thatdj=s1⋯sj−1d_{j}=s_{1}\cdots s_{j-1}for allj<ij<i. Consider the stridedid_{i}. We know that there is no(x1,…,xi−1,0,…,0)(x_{1},\dots,x_{i-1},0,\dots,0)such that(x1,…,xi−1,0,…,0)⋅(d1,…,dm)=s1⋯si−1(x_{1},\dots,x_{i-1},0,\dots,0)\cdot(d_{1},\dots,d_{m})=s_{1}\cdots s_{i-1}, since the largest possible value of such an expression is
∑j=1i−1(sj−1)(s1⋯sj−1)=s1⋯si−1.\sum_{j=1}^{i-1}(s_{j}-1)(s_{1}\cdots s_{j-1})=s_{1}\cdots s_{i}-1.SinceΦL\Phi_{L}is surjective, anddi≤di+1≤⋯≤dmd_{i}\leq d_{i+1}\leq\cdots\leq d_{m}, it follows that the next largest value ofΦL\Phi_{L}isdid_{i}, so we must havedi=s1⋯si−1d_{i}=s_{1}\cdots s_{i-1}, as claimed.
Returning to our main goal, consider the layout
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1′,…,sm′′):(d1′,…,dm′′).\mathsf{squeeze}(A))=(s_{1}^{\prime},\dots,s_{m^{\prime}}^{\prime}):(d_{1}^{\prime},\dots,d_{m^{\prime}}^{\prime}).Then there existj1<⋯<jm′j_{1}<\cdots<j_{m^{\prime}}such thatsi′=sjis_{i}^{\prime}=s_{j_{i}}anddi′=djid_{i}^{\prime}=d_{j_{i}}for each1≤i≤m′1\leq i\leq m^{\prime}. If1≤i<m′1\leq i<m^{\prime}, then
si′di′=sjidji=sjis1⋯sji−1s_{i}^{\prime}d_{i}^{\prime}=s_{j_{i}}d_{j_{i}}=s_{j_{i}}s_{1}\cdots s_{j_{i}-1}divides
di+1′=s1⋯sji+1−1,d_{i+1}^{\prime}=s_{1}\cdots s_{j_{i+1}-1},so we conclude thatAAis complementable. ∎
Our next goal is to give an abstract characterization of the complement𝖼𝗈𝗆𝗉♭(A)\mathsf{comp}^{\flat}(A)of a flat layoutAA. In order to do so, we need the following lemma.
Lemma 2.1.6.22.
SupposeAAis a flat layout. IfAAis complementable and sorted, then the layout function
ΦA:[0,𝗌𝗂𝗓𝖾(A))→ℤ\Phi_{A}:[0,\mathsf{size}(A))\to\mathbb{Z}is increasing.
Proof.
Write
A=(s1,…,sm):(d1,…,dm).A=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).If1≤k≤m1\leq k\leq m, we claim that
d1(s1−1)+d2(s2−1)+⋯+dk−1(sk−1−1)≤dk.d_{1}(s_{1}-1)+d_{2}(s_{2}-1)+\cdots+d_{k-1}(s_{k-1}-1)\leq d_{k}.Ifk=1k=1, this holds vacuously, and by induction onkk, we have
d1(s1−1)+⋯+dk−2(sk−2−1)+dk−1(sk−1−1)\displaystyle d_{1}(s_{1}-1)+\cdots+d_{k-2}(s_{k-2}-1)+d_{k-1}(s_{k-1}-1)≤dk−1+dk−1(sk−1)\displaystyle\leq d_{k-1}+d_{k-1}(s_{k}-1)=dk−1sk−1\displaystyle=d_{k-1}s_{k-1}≤dk.\displaystyle\leq d_{k}.Now, suppose we havex,y∈[0,𝗌𝗂𝗓𝖾(A))x,y\in[0,\mathsf{size}(A))withx≤yx\leq y. These integers correspond, under the colexicographic isomorphism, to tuples.
(x1,…,xm),(y1,…,ym)∈[0,s1)×⋯×[0,sm)(x_{1},\dots,x_{m}),(y_{1},\dots,y_{m})\in[0,s_{1})\times\cdots\times[0,s_{m})Sincex≤yx\leq y, we know there is some maximal1≤k≤m1\leq k\leq msuch thatxk<ykx_{k}<y_{k}, andxℓ=yℓx_{\ell}=y_{\ell}for allk<ℓ≤mk<\ell\leq m. Now we can compute
ΦA(x)\displaystyle\Phi_{A}(x)=d1x1+⋯+dk−1xk−1+dkxk+dk+1xk+1+⋯+dmxm\displaystyle=d_{1}x_{1}+\cdots+d_{k-1}x_{k-1}+d_{k}x_{k}+d_{k+1}x_{k+1}+\cdots+d_{m}x_{m}=d1x1+⋯+dk−1xk−1+dkxk+dk+1yk+1+⋯+dmym\displaystyle=d_{1}x_{1}+\cdots+d_{k-1}x_{k-1}+d_{k}x_{k}+d_{k+1}y_{k+1}+\cdots+d_{m}y_{m}≤d1(s1−1)+⋯+dk−1(sk−1−1)+dkxk+dk+1yk+1+⋯+dmym\displaystyle\leq d_{1}(s_{1}-1)+\cdots+d_{k-1}(s_{k-1}-1)+d_{k}x_{k}+d_{k+1}y_{k+1}+\cdots+d_{m}y_{m}≤dk+dkxk+dk+1yk+1+⋯+dmym\displaystyle\leq d_{k}+d_{k}x_{k}+d_{k+1}y_{k+1}+\cdots+d_{m}y_{m}=dk(xk+1)+dk+1yk+1+⋯+dmym\displaystyle=d_{k}(x_{k}+1)+d_{k+1}y_{k+1}+\cdots+d_{m}y_{m}≤dkyk+dk+1yk+1+⋯+dmym\displaystyle\leq d_{k}y_{k}+d_{k+1}y_{k+1}+\cdots+d_{m}y_{m}≤d1y1+…dmym\displaystyle\leq d_{1}y_{1}+\dots d_{m}y_{m}=ΦA(y).\displaystyle=\Phi_{A}(y).∎
Proposition 2.1.6.23.
SupposeAAandBBare flat layouts. If
- 1.A⟂BA\perp B,
- 2.𝗌𝗂𝗓𝖾(B)=𝗌𝗂𝗓𝖾(𝖼𝗈𝗆𝗉♭(A))\mathsf{size}(B)=\mathsf{size}(\mathsf{comp}^{\flat}(A)),
- 3.BBis coalesced, and
- 4.BBis sorted,
thenB=𝖼𝗈𝗆𝗉♭(A)B=\mathsf{comp}^{\flat}(A).
Proof.
Conditions 1 and 2 imply thatΦB\Phi_{B}andΦ𝖼𝗈𝗆𝗉♭(A)\Phi_{\mathsf{comp}^{\flat}(A)}have the same image. SinceBBand𝖼𝗈𝗆𝗉♭(A)\mathsf{comp}^{\flat}(A)are sorted, we know by Lemma2.1.6.22thatΦB\Phi_{B}andΦ𝖼𝗈𝗆𝗉♭(A)\Phi_{\mathsf{comp}^{\flat}(A)}are increasing. Combining these two facts, it follows thatΦB=Φ𝖼𝗈𝗆𝗉♭(A)\Phi_{B}=\Phi_{\mathsf{comp}^{\flat}(A)}. Proposition2.1.4.18and condition 3 then imply that
B=𝖼𝗈𝖺𝗅♭(B)=𝖼𝗈𝖺𝗅♭(𝖼𝗈𝗆𝗉♭(A))=𝖼𝗈𝗆𝗉♭(A).B=\mathsf{coal}^{\flat}(B)=\mathsf{coal}^{\flat}(\mathsf{comp}^{\flat}(A))=\mathsf{comp}^{\flat}(A).∎
Definition 2.1.6.24.
SupposeAAandBBare flat layouts, andNNis a positive integer. We sayBBis aNN-complementofAAifBBis a complement ofAAand
𝗌𝗂𝗓𝖾(A)⋅𝗌𝗂𝗓𝖾(B)=N.\mathsf{size}(A)\cdot\mathsf{size}(B)=N.
Definition 2.1.6.25.
SupposeAAis a flat layout, and write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm).\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).We sayAAisNN-complementable if
- 1.for all1≤i<m1\leq i<m, the integersidis_{i}d_{i}dividesdi+1d_{i+1}, and
- 2.the integersmdms_{m}d_{m}dividesNN.
Observation 2.1.6.26.
IfAAis complementable, andsm:dms_{m}:d_{m}is the last mode in the layoutOPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))\mathsf{squeeze}(A)), thenAAisNN-complementable exactly whenNNis a positive integer multiple ofsmdms_{m}d_{m}.
Observation 2.1.6.27.
NN-complements are not unique. For example, ifA=(2,2):(1,50)A=(2,2):(1,50)andN=100N=100, then each of the layoutsB1=(25):(2)B_{1}=(25):(2), andB2=(5,5):(2,10)B_{2}=(5,5):(2,10)is aNN-complement ofAA. As a more general example, ifBBis aNN-complement ofAA, then𝖼𝗈𝖺𝗅♭(B)\mathsf{coal}^{\flat}(B)is also aNN-complement ofAA.
Construction 2.1.6.29.
SupposeAAis a flat layout,NNis a positive integer, andAAisNN-complementable. If we write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm),\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),then we define a flat layout𝖼𝗈𝗆𝗉♭(A,N)\mathsf{comp}^{\flat}(A,N)by
𝖼𝗈𝗆𝗉♭(A,N)=𝖼𝗈𝖺𝗅♭(C)\mathsf{comp}^{\flat}(A,N)=\mathsf{coal}^{\flat}(C)where
C=(d1,d2s1d1,d3s2d2,…,Nsmdm):(1,s1d1,s2d2,…,smdm).C=\Bigl(d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dfrac{d_{3}}{s_{2}d_{2}},\dots,\dfrac{N}{s_{m}d_{m}}\Bigr):\Bigl(1,s_{1}d_{1},s_{2}d_{2},\dots,s_{m}d_{m}\Bigr).
Example 2.1.6.30.
IfA=(3,10):(80,4)A=(3,10):(80,4)andN=2400N=2400, then
𝖼𝗈𝗆𝗉♭(A,N)=(4,2,10):(1,40,240).\mathsf{comp}^{\flat}(A,N)=(4,2,10):(1,40,240).
Lemma 2.1.6.31.
SupposeAAis a flat layout,NNis a positive integer, andAAisNN-complementable. Then𝖼𝗈𝗆𝗉♭(A,N)\mathsf{comp}^{\flat}(A,N)is aNN-complement ofAA.
Proof.
Lets write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1,…,sm):(d1,…,dm),\mathsf{squeeze}(A))=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),so that𝖼𝗈𝗆𝗉♭(A,N)=𝖼𝗈𝖺𝗅♭(C)\mathsf{comp}^{\flat}(A,N)=\mathsf{coal}^{\flat}(C)where
C\displaystyle C=(d1,d2s1d1,d3s2d2,…,Nsmdm):(1,s1d1,s2d2,…,smdm).\displaystyle=\left(d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dfrac{d_{3}}{s_{2}d_{2}},\dots,\dfrac{N}{s_{m}d_{m}}\right):\left(1,s_{1}d_{1},s_{2}d_{2},\dots,s_{m}d_{m}\right).First, we compute
𝗌𝗂𝗓𝖾(A)⋅𝗌𝗂𝗓𝖾(B)\displaystyle\mathsf{size}(A)\cdot\mathsf{size}(B)=(∏i=1msi)⋅(d1⋅(∏i=2mdisi−1di−1)⋅Nsmdm)\displaystyle=\left(\prod_{i=1}^{m}s_{i}\right)\cdot\left(d_{1}\cdot\left(\prod_{i=2}^{m}\dfrac{d_{i}}{s_{i-1}d_{i-1}}\right)\cdot\dfrac{N}{s_{m}d_{m}}\right)=(∏i=1msi)(∏i=1mdi)(∏i=1msidi)⋅N\displaystyle=\dfrac{\left(\displaystyle\prod_{i=1}^{m}s_{i}\right)\left(\displaystyle\prod_{i=1}^{m}d_{i}\right)}{\left(\displaystyle\prod_{i=1}^{m}s_{i}d_{i}\right)}\cdot N=N.\displaystyle=N.We need to check thatA⋆BA\star Bis compact. Equivalently, we need to check thatΦA⋆BN\Phi_{A\star B}^{N}is an isomorphism. By Lemma2.1.5.6, it suffices to prove that
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B)\mathsf{squeeze}(A)\star\mathsf{squeeze}(B)is compact. This is the case since this layout is equal to
(s1,…,sm,d1,d2s1d1,…,Nsmdm):(d1,…,dm,1,s1d1,…,smdm)\displaystyle\left(s_{1},\dots,s_{m},d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dots,\dfrac{N}{s_{m}d_{m}}\right):(d_{1},\dots,d_{m},1,s_{1}d_{1},\dots,s_{m}d_{m})and so its sorting
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B))\mathsf{squeeze}(A)\star\mathsf{squeeze}(B))is equal to
(d1,s1,d2s1d1,…,dmsm−1dm−1,sm,Nsmdm):(1,d1,s1d1,…,sm−1dm−1,dm,smdm)\left(d_{1},s_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dots,\dfrac{d_{m}}{s_{m-1}{d_{m-1}}},s_{m},\dfrac{N}{s_{m}d_{m}}\right):(1,d_{1},s_{1}d_{1},\dots,s_{m-1}d_{m-1},d_{m},s_{m}d_{m})which is column-major. ∎
Proposition 2.1.6.32.
SupposeAAis a flat layout andNNis a positive integer. Then there exists aNN-complementBBofAAif and only ifAAisNN-complementable.
Proof.
IfAAisNN-complementable, then by Lemma2.1.6.31the layoutB=𝖼𝗈𝗆𝗉♭(L,N)B=\mathsf{comp}^{\flat}(L,N)is aNN-complement ofAA.
On the other hand, suppose there exists aNN-complementBBofAA. Consider the flat layout
L\displaystyle L≔(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A)⋆𝗌𝗊𝗎𝖾𝖾𝗓𝖾(B))\displaystyle\coloneq(\mathsf{squeeze}(A)\star\mathsf{squeeze}(B)\bigr)=(s1,…,sm):(d1,…,dn).\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{n}).SinceΦL(0)=0\Phi_{L}(0)=0, andΦL\Phi_{L}is injective, we know thatd1≠0d_{1}\neq 0. We will argue thatdi=s1⋯si−1d_{i}=s_{1}\cdots s_{i-1}, i.e., thatLLis column-major. Since
ΦLN:[0,N)→[0,N)\Phi_{L}^{N}:[0,N)\to[0,N)is a bijection, we know that11is in the image ofΦL\Phi_{L}, which implies thatd1=1d_{1}=1. Suppose1<i≤m1<i\leq m, and suppose we have proved thatdj=s1⋯sj−1d_{j}=s_{1}\cdots s_{j-1}for allj<ij<i. Consider the stridedid_{i}. We know that there is no(x1,…,xi−1,0,…,0)(x_{1},\dots,x_{i-1},0,\dots,0)such that(x1,…,xi−1,0,…,0)⋅(d1,…,dm)=s1⋯si−1(x_{1},\dots,x_{i-1},0,\dots,0)\cdot(d_{1},\dots,d_{m})=s_{1}\cdots s_{i-1}, since the largest possible value of such an expression is
∑j=1i−1(sj−1)(s1⋯sj−1)=s1⋯si−1.\sum_{j=1}^{i-1}(s_{j}-1)(s_{1}\cdots s_{j-1})=s_{1}\cdots s_{i}-1.SinceΦL\Phi_{L}is surjective, anddi≤di+1≤⋯≤dmd_{i}\leq d_{i+1}\leq\cdots\leq d_{m}, it follows that the next largest value ofΦL\Phi_{L}isdid_{i}, so we must havedi=s1⋯si−1d_{i}=s_{1}\cdots s_{i-1}, as claimed.
Returning to our main goal, consider the layout
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))=(s1′,…,sm′′):(d1′,…,dm′′).\mathsf{squeeze}(A))=(s_{1}^{\prime},\dots,s_{m^{\prime}}^{\prime}):(d_{1}^{\prime},\dots,d_{m^{\prime}}^{\prime}).Then there existj1<⋯<jm′j_{1}<\cdots<j_{m^{\prime}}such thatsi′=sjis_{i}^{\prime}=s_{j_{i}}anddi′=djid_{i}^{\prime}=d_{j_{i}}for each1≤i≤m′1\leq i\leq m^{\prime}. If1≤i<m′1\leq i<m^{\prime}, then
si′di′=sjidji=sjis1⋯sji−1s_{i}^{\prime}d_{i}^{\prime}=s_{j_{i}}d_{j_{i}}=s_{j_{i}}s_{1}\cdots s_{j_{i}-1}divides
di+1′=s1⋯sji+1−1.d_{i+1}^{\prime}=s_{1}\cdots s_{j_{i+1}-1}.Ifi=m′i=m^{\prime}, then
sm′′dm′′=sjm′djm′=sjm′s1⋯sjm′−1s_{m^{\prime}}^{\prime}d_{m^{\prime}}^{\prime}=s_{j_{m^{\prime}}}d_{j_{m^{\prime}}}=s_{j_{m^{\prime}}}s_{1}\cdots s_{j_{m^{\prime}}-1}divides
N=s1⋯sm.N=s_{1}\cdots s_{m}.We conclude thatAAisNN-complementable. ∎
Proposition 2.1.6.33.
SupposeNNis a positive integer, andAAis aNN-complementable flat layout. IfBBis a flat layout such that
- 1.BBis aNN-complement ofLL,
- 2.BBis coalesced, and
- 3.BBis sorted,
thenB=𝖼𝗈𝗆𝗉♭(A,N)B=\mathsf{comp}^{\flat}(A,N).
Proof.
Conditions 1 and 2 imply thatΦB\Phi_{B}andΦ𝖼𝗈𝗆𝗉♭(A,N)\Phi_{\mathsf{comp}^{\flat}(A,N)}have the same image. SinceBBand𝖼𝗈𝗆𝗉♭(A,N)\mathsf{comp}^{\flat}(A,N)are sorted, we know by Lemma2.1.6.22thatΦB\Phi_{B}andΦ𝖼𝗈𝗆𝗉♭(A,N)\Phi_{\mathsf{comp}^{\flat}(A,N)}are increasing. Combining these two facts, it follows thatΦB=Φ𝖼𝗈𝗆𝗉♭(A,N)\Phi_{B}=\Phi_{\mathsf{comp}^{\flat}(A,N)}. Proposition2.1.4.18and condition 3 then imply that
B=𝖼𝗈𝖺𝗅♭(B)=𝖼𝗈𝖺𝗅♭(𝖼𝗈𝗆𝗉♭(A,N))=𝖼𝗈𝗆𝗉♭(A,N).B=\mathsf{coal}^{\flat}(B)=\mathsf{coal}^{\flat}(\mathsf{comp}^{\flat}(A,N))=\mathsf{comp}^{\flat}(A,N).∎
Lemma 2.1.6.34.
SupposeAAis a flat layout. IfN1≤N2N_{1}\leq N_{2}are positive integers such thatAAisN1N_{1}-complementable andAAisN2N_{2}-complementable, then
Φ𝖼𝗈𝗆𝗉♭(A,N2)∣[0,N1)=Φ𝖼𝗈𝗆𝗉♭(A,N1).\Phi_{\mathsf{comp}^{\flat}(A,N_{2})}\mid_{[0,N_{1})}=\Phi_{\mathsf{comp}^{\flat}(A,N_{1})}.
Proof.
Write
OPEN𝗌𝗊𝗎𝖾𝖾𝗓𝖾(A))\displaystyle\mathsf{squeeze}(A))=(s1,…,sm):(d1,…,dm),\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),C\displaystyle C=(d1,d2s1d1,d3s2d2,…,dmsm−1dm−1):(1,s1d1,s2d2,…,sm−1dm−1)\displaystyle=\Bigl(d_{1},\dfrac{d_{2}}{s_{1}d_{1}},\dfrac{d_{3}}{s_{2}d_{2}},\dots,\dfrac{d_{m}}{s_{m-1}d_{m-1}}\Bigr):\Bigl(1,s_{1}d_{1},s_{2}d_{2},\dots,s_{m-1}d_{m-1}\Bigr)and write
E1\displaystyle E_{1}=(N1smdm):(smdm),\displaystyle=\left(\dfrac{N_{1}}{s_{m}d_{m}}\right):(s_{m}d_{m}),E2\displaystyle E_{2}=(N2smdm):(smdm),\displaystyle=\left(\dfrac{N_{2}}{s_{m}d_{m}}\right):(s_{m}d_{m}),C1\displaystyle C_{1}=C⋆E1,\displaystyle=C\star E_{1},C2\displaystyle C_{2}=C⋆E2,\displaystyle=C\star E_{2},so that
𝖼𝗈𝗆𝗉♭(A)\displaystyle\mathsf{comp}^{\flat}(A)=𝖼𝗈𝖺𝗅♭(C)\displaystyle=\mathsf{coal}^{\flat}(C)𝖼𝗈𝗆𝗉♭(A,N1)\displaystyle\mathsf{comp}^{\flat}(A,N_{1})=𝖼𝗈𝖺𝗅♭(C1)\displaystyle=\mathsf{coal}^{\flat}(C_{1})𝖼𝗈𝗆𝗉♭(A,N2)\displaystyle\mathsf{comp}^{\flat}(A,N_{2})=𝖼𝗈𝖺𝗅♭(C2).\displaystyle=\mathsf{coal}^{\flat}(C_{2}).Then we have a commuting diagram
[0,𝗌𝗂𝗓𝖾(C1)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(C_{1}){)}}[0,𝗌𝗂𝗓𝖾(C))×[0,N1){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(C){)}\times{[}0,N_{1}{)}}ℤ×ℤ{\lx@inpgf@ignorespaces\mathbb{Z}\times\mathbb{Z}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}[0,𝗌𝗂𝗓𝖾(C2)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(C_{2}){)}}[0,𝗌𝗂𝗓𝖾(C))×[0,N2){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(C){)}\times{[}0,N_{2}{)}}ℤ×ℤ{\lx@inpgf@ignorespaces\mathbb{Z}\times\mathbb{Z}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}colex(𝗌𝗂𝗓𝖾(C),N1)−1\scriptstyle{\lx@inpgf@ignorespaces\text{colex}_{(\mathsf{size}(C),N_{1})}^{-1}}⊆\scriptstyle{\lx@inpgf@ignorespaces\subseteq}ΦC×smdm\scriptstyle{\lx@inpgf@ignorespaces\Phi_{C}\times s_{m}d_{m}}𝗂𝖽×⊆\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}\times\subseteq}+\scriptstyle{\lx@inpgf@ignorespaces+}𝗂𝖽\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}}𝗂𝖽\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}}colex(𝗌𝗂𝗓𝖾(C),N2)−1\scriptstyle{\lx@inpgf@ignorespaces\text{colex}_{(\mathsf{size}(C),N_{2})}^{-1}}ΦC×smdm\scriptstyle{\lx@inpgf@ignorespaces\Phi_{C}\times s_{m}d_{m}}+\scriptstyle{\lx@inpgf@ignorespaces+}where, by Proposition2.1.3.40, the composite of the top row is the layout function ofC1=C⋆E1C_{1}=C\star E_{1}, and the composite of the bottom row is the layout function ofC2=C⋆E2C_{2}=C\star E_{2}. This tells us that the restriction ofΦC2\Phi_{C_{2}}to[0,𝗌𝗂𝗓𝖾(C2))[0,\mathsf{size}(C_{2}))isΦC1\Phi_{C_{1}}, and the result follow from the fact that
Φ𝖼𝗈𝗆𝗉♭(A,N1)\displaystyle\Phi_{\mathsf{comp}^{\flat}(A,N_{1})}=ΦC1\displaystyle=\Phi_{C_{1}}Φ𝖼𝗈𝗆𝗉♭(A,N2)\displaystyle\Phi_{\mathsf{comp}^{\flat}(A,N_{2})}=ΦC2.\displaystyle=\Phi_{C_{2}}.∎
2.1.7Further operations
In this section, we define several further operations on flat layouts, namelycomposition,flat division, andflat products. These are the flattened variants of more natural operations on (nested) layouts. We do not often work with these operations, but include them anyway for completeness.
2.1.7.1Composition
IfAAandBBare flat layouts, then the compositeB∘AB\circ Ais a flat layout whose layout function is the composite of the layout functions ofAAandBB. More precisely, we have the following definition.
Definition 2.1.7.1.
SupposeAAandBBare flat layouts. We say the flat layoutCCis thecompositionofAAandBB, and writeC=B∘AC=B\circ A, if
- 1.CCis non-degenerate,
- 2.𝗌𝗁𝖺𝗉𝖾(A)=𝗌𝗁𝖺𝗉𝖾(R)\mathsf{shape}(A)=\mathsf{shape}(R),
- 3.ΦR=ΦB∘ΦA𝗌𝗂𝗓𝖾(B)\Phi_{R}=\Phi_{B}\circ\Phi_{A}^{\mathsf{size}(B)}.
Example 2.1.7.3.
IfA=(2,3):(5,6)A=(2,3):(5,6)andB=(80):(10)B=(80):(10), then
B∘A=(2,3):(50,60).B\circ A=(2,3):(50,60).More generally, if
A=(s1,…,sm):(d1,…,dm)A=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a non-degenerate flat layout, and
is a rank11flat layout witht≥𝖼𝗈𝗌𝗂𝗓𝖾(A)t\geq\mathsf{cosize}(A), thenAAandBBare composable, and
B∘A=(s1,…,sm):(td1,…,tdm).B\circ A=(s_{1},\dots,s_{m}):(td_{1},\dots,td_{m}).
Example 2.1.7.4.
IfA=(128,128):(0,0)A=(128,128):(0,0)andB=(64,32):(1,64)B=(64,32):(1,64), then
B∘A=(128,128):(0,0).B\circ A=(128,128):(0,0).More generally, ifAAis a flat layout each of whose stride entries is zero, andBBis any flat layout, thenAAandBBare composable withB∘A=AB\circ A=A.
Example 2.1.7.5.
IfA=(64,32):(2,256)A=(64,32):(2,256)andB=(2048,2048):(1,2048)B=(2048,2048):(1,2048), then
B∘A=(64,32):(2,256).B\circ A=(64,32):(2,256).More generally, ifAAis any flat layout, andBBis a column-major flat layout with𝖼𝗈𝗌𝗂𝗓𝖾(A)≤𝗌𝗂𝗓𝖾(B)\mathsf{cosize}(A)\leq\mathsf{size}(B), thenB∘A=AB\circ A=A.
Example 2.1.7.6.
IfA=(4):(2)A=(4):(2)andB=(2,2,6):(12,6,1)B=(2,2,6):(12,6,1), then there is no flat layoutRRwithR=B∘AR=B\circ A.
2.1.7.2Flat division
IfAAandBBare flat layouts, then the flat division ofAAbyBBis a flattened version of the more naturallogical divisionof layouts. See Section2.3.8for details.
Definition 2.1.7.9.
SupposeAAandBBare flat layouts, and thatBBis𝗌𝗂𝗓𝖾(A)\mathsf{size}(A)-complementable, with
Bc=𝖼𝗈𝗆𝗉♭(B,𝗌𝗂𝗓𝖾(A)).B^{c}=\mathsf{comp}^{\flat}(B,\mathsf{size}(A)).We define theflat divisionofAAbyBBto be the flat layout
A⊘♭B=A∘(B⋆Bc).A\oslash^{\flat}B=A\circ(B\star B^{c}).
Example 2.1.7.10.
IfA=(2,2,2,2):(1,4,2,8)A=(2,2,2,2):(1,4,2,8)andB=(2,2):(4,2)B=(2,2):(4,2), then
A⊘♭B=(2,2,2,2):(4,2,1,8).A\oslash^{\flat}B=(2,2,2,2):(4,2,1,8).
Example 2.1.7.11.
IfA=(3,5,9,6):(54,0,6,1)A=(3,5,9,6):(54,0,6,1)andB=(6,3):(135,1)B=(6,3):(135,1), then
A⊘♭B=(6,3,5,9):(1,54,0,6).A\oslash^{\flat}B=(6,3,5,9):(1,54,0,6).
Example 2.1.7.12.
IfAAis any flat layout andB=():()B=():()is the empty layout, then
A⊘♭B=A.A\oslash^{\flat}B=A.
2.1.7.3Flat products
IfAAandBBare flat layouts, then the flat productA⊗♭BA\otimes^{\flat}BofAAandBBis a flattened version of the more naturallogical productof layouts. See Section2.3.9for details.
Definition 2.1.7.13.
SupposeAAandBBare flat layouts, and thatAAis𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B)\mathsf{size}(A)\cdot\mathsf{cosize}(B)-complementable, with
Ac=𝖼𝗈𝗆𝗉♭(A,𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B)).A^{c}=\mathsf{comp}^{\flat}(A,\mathsf{size}(A)\cdot\mathsf{cosize}(B)).We define the flat product ofAAandBBby
A⊗♭B=A⋆(Ac∘B).A\otimes^{\flat}B=A\star(A^{c}\circ B).
Example 2.1.7.14.
IfA=(2,2,2):(1,2,4)A=(2,2,2):(1,2,4)andB=(2,2,2):(1,2,4)B=(2,2,2):(1,2,4), then
A⊗♭B=(2,2,2,2,2,2):(1,2,4,8,16,32).A\otimes^{\flat}B=(2,2,2,2,2,2):(1,2,4,8,16,32).
Example 2.1.7.15.
IfA=(2,2,2):(1,2,4)A=(2,2,2):(1,2,4)andB=(3,5):(5,1)B=(3,5):(5,1), then
A⊗♭B=(2,2,2,3,5):(1,2,4,40,8).A\otimes^{\flat}B=(2,2,2,3,5):(1,2,4,40,8).
Example 2.1.7.16.
IfAAis any flat layout andB=():()B=():()is the empty layout, then
A⊗♭B=A.A\otimes^{\flat}B=A.
2.1.8Tractable flat layouts
In this section we define an especially well-behaved class of flat layouts, calledtractableflat layouts. Tractable flat layouts include the most important examples of interest, such as row-major, column-major, compact, and complementable layouts. Later on, we will see that tractable flat layouts are precisely the layouts which arise from a certain category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}.
Definition 2.1.8.1.
SupposeLLis a flat layout, and write
OPENL)=(s1,…,sm):(d1,…,dm).L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).We sayLListractableif for each1≤i<m1\leq i<m, we have
- 1.di=0d_{i}=0, or
- 2.sidis_{i}d_{i}dividesdi+1d_{i+1}.
Example 2.1.8.2.
The flat layout
is tractable. More generally, any flat layout of rank11is tractable.
Example 2.1.8.3.
The flat layout
L=(2,4,32):(1,2,8)L=(2,4,32):(1,2,8)is tractable. More generally, any column-major layout
L=(s1,…,sm):(1,s1,…,s1⋯sm−1)L=(s_{1},\dots,s_{m}):(1,s_{1},\dots,s_{1}\cdots s_{m-1})is tractable.
Example 2.1.8.4.
The flat layout
L=(2,4,32):(128,32,1)L=(2,4,32):(128,32,1)is tractable. More generally, any row-major layout
L=(s1,…,sm):(s2⋯sm,…,sm,1)L=(s_{1},\dots,s_{m}):(s_{2}\cdots s_{m},\dots,s_{m},1)is tractable.
Example 2.1.8.5.
The flat layout
L=(3,3,1,3,3,1,3):(81,1,0,9,3,0,27)L=(3,3,1,3,3,1,3):(81,1,0,9,3,0,27)is tractable. More generally, any compact flat layout is tractable.
Example 2.1.8.6.
The flat layout
L=(3,7,7):(0,15,0)L=(3,7,7):(0,15,0)is tractable. More generally, any flat layout with exactly one non-zero stride is tractable.
Example 2.1.8.7.
The flat layout
L=(2,2,2,2):(1,2048,16,64)L=(2,2,2,2):(1,2048,16,64)is tractable. More generally, any complementable flat layout is tractable.
Example 2.1.8.8.
SupposeLLis a flat layout. IfLLis tractable andI⊂⟨m⟩I\subset\langle m\rangleis any subset, then the restrictionL∣IL\mid_{I}is tractable. In particular, ifLLis tractable, then𝗌𝗊𝗎𝖾𝖾𝗓𝖾(L)\mathsf{squeeze}(L)and𝖿𝗂𝗅𝗍𝖾𝗋(L)\mathsf{filter}(L)are tractable.
Example 2.1.8.9.
The flat layout
L=(4,8):(3,3)L=(4,8):(3,3)is not tractable. In particular, this shows that the concatenationL1⋆L2L_{1}\star L_{2}of tractable flat layoutsL1L_{1}andL2L_{2}need not be tractable.
Observation 2.1.8.10.
IfLLis a tractable flat layout and no entry of𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L)is equal to00, thenLLis complementable. In particular, ifLLis tractable, then𝖿𝗂𝗅𝗍𝖾𝗋(L)\mathsf{filter}(L)is complementable.
We conclude this section by enumerating a family of equivalent conditions for a flat layoutLLto be tractable.
Proposition 2.1.8.11.
SupposeLLis a flat layout. Then the following conditions are equivalent.
- 1.LLis tractable.
- 2.OPENL)L)is tractable.
- 3.𝖿𝗂𝗅𝗍𝖾𝗋(L)\mathsf{filter}(L)is tractable.
- 4.𝖿𝗂𝗅𝗍𝖾𝗋(L)\mathsf{filter}(L)is complementable.
Proof.
SupposeLLis a flat layout.
- •(1⇔\Leftrightarrow2): This follows from the fact that
- •(1⇔\Leftrightarrow3): This follows from the fact that OPENOPEN𝖿𝗂𝗅𝗍𝖾𝗋(L))=𝖿𝗂𝗅𝗍𝖾𝗋(L)).\mathsf{filter}(L))=\mathsf{filter}(L)).
- •(3⇔\Leftrightarrow4): This follows from the fact that if L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout such that each of the stride entriesdid_{i}is nonzero, then the definition of tractability coincides with that of complementability.
∎
2.2Nested Tuples
In this section, we introduce nested tuples, which are the generalization of tuples needed to define layouts in full generality.
2.2.1Profiles
A nested tupleSSis determined by itsflattening, which is an ordinary tuple, and itsprofile, which describes parenthesization pattern onSS. We define profiles precisely as follows.
Definition 2.2.1.1.
AprofilePPis either
- 1.P=∗P=*, or
- 2.a tupleP=(P1,…,Pr)P=(P_{1},\dots,P_{r})of profilesP1,…,PrP_{1},\dots,P_{r}for somer≥0r\geq 0.
We write𝖯𝗋𝗈𝖿𝗂𝗅𝖾\mathsf{Profile}for the set of profiles.
Example 2.2.1.2.
Here are some examples of profiles.
P1\displaystyle P_{1}=(∗,∗)\displaystyle=(*,*)P2\displaystyle P_{2}=(∗,(∗,∗))\displaystyle=(*,(*,*))P3\displaystyle P_{3}=((∗,∗),(∗,∗))\displaystyle=((*,*),(*,*))P4\displaystyle P_{4}=((∗,∗,∗),(∗,()))\displaystyle=((*,*,*),(*,()))P5\displaystyle P_{5}=()\displaystyle=()P6\displaystyle P_{6}=∗\displaystyle=*
Let’s define some important attributes of profiles.
Definition 2.2.1.3.
SupposePPis a profile.
- •TherankofXXis 𝗋𝖺𝗇𝗄(P)={1P=∗rP=(P1,…,Pr)is a tuple of profiles..\mathsf{rank}(P)=\begin{cases}1&P=*\\ r&P=(P_{1},\dots,P_{r})\text{ is a tuple of profiles.}\end{cases}.
- •ThelengthofPPis 𝗅𝖾𝗇(P)={1P=∗∑i=1r𝗅𝖾𝗇(Pi)P=(P1,…,Pr)is a tuple of profiles.\mathsf{len}(P)=\begin{cases}1&P=*\\ \sum_{i=1}^{r}\mathsf{len}(P_{i})&P=(P_{1},\dots,P_{r})\text{ is a tuple of profiles.}\end{cases}
- •ThedepthofPPis 0pt(P)={0P=∗1+𝗆𝖺𝗑1≤i≤r(0pt(Pi))P=(P1,…,Pr)is a tuple of profiles.0pt(P)=\begin{cases}0&P=*\\ 1+\displaystyle\mathsf{max}_{1\leq i\leq r}(0pt(P_{i}))&P=(P_{1},\dots,P_{r})\text{ is a tuple of profiles.}\end{cases}
Example 2.2.1.4.
Here are some examples of profiles, together with their rank, length, and depth :
P\displaystyle P=∗\displaystyle=*𝗋𝖺𝗇𝗄(P)\displaystyle\quad\mathsf{rank}(P)=1,𝗅𝖾𝗇(P)=1,\displaystyle=1,\quad\mathsf{len}(P)=1,0pt(P)\displaystyle 0pt(P)=0\displaystyle=0P\displaystyle P=(∗,∗,∗)\displaystyle=(*,*,*)𝗋𝖺𝗇𝗄(P)\displaystyle\quad\mathsf{rank}(P)=3,𝗅𝖾𝗇(P)=3,\displaystyle=3,\quad\mathsf{len}(P)=3,0pt(P)\displaystyle 0pt(P)=1\displaystyle=1P\displaystyle P=(((∗,∗),∗,∗),∗,∗),\displaystyle=(((*,*),*,*),*,*),𝗋𝖺𝗇𝗄(P)\displaystyle\quad\mathsf{rank}(P)=3,𝗅𝖾𝗇(P)=6,\displaystyle=3,\quad\mathsf{len}(P)=6,0pt(P)\displaystyle 0pt(P)=3\displaystyle=3P\displaystyle P=(((),()),(∗,(∗,∗))),\displaystyle=(((),()),(*,(*,*))),𝗋𝖺𝗇𝗄(P)\displaystyle\quad\mathsf{rank}(P)=2,𝗅𝖾𝗇(P)=3,\displaystyle=2,\quad\mathsf{len}(P)=3,0pt(P)\displaystyle 0pt(P)=3\displaystyle=3
Definition 2.2.1.5.
SupposePPis a profile with𝗋𝖺𝗇𝗄(P)=r\mathsf{rank}(P)=r. If1≤i≤r1\leq i\leq r, then theiithmode ofPPis
𝗆𝗈𝖽𝖾i(P)={P0pt(P)=0(hencei=r=1),PiP=(P1,…,Pr)has depth≥1.\mathsf{mode}_{i}(P)=\begin{cases}P&0pt(P)=0\text{ (hence }i=r=1\text{),}\\ P_{i}&P=(P_{1},\dots,P_{r})\text{ has depth }\geq 1.\end{cases}
Example 2.2.1.6.
IfP=((∗,∗),(()),((,,,)))P=((*,*),(()),((*,(*,*))))then the modes ofPPare
𝗆𝗈𝖽𝖾1(P)\displaystyle\mathsf{mode}_{1}(P)=(∗,∗)\displaystyle=(*,*)𝗆𝗈𝖽𝖾2(P)\displaystyle\mathsf{mode}_{2}(P)=(())\displaystyle=(())𝗆𝗈𝖽𝖾3(P)\displaystyle\mathsf{mode}_{3}(P)=(∗,(∗,∗)).\displaystyle=(*,(*,*)).
The following notation will be useful.
Notation 2.2.1.7.
SupposePPis a profile of depth>0>0. For any1≤j≤𝗋𝖺𝗇𝗄(P)1\leq j\leq\mathsf{rank}(P), we write
𝗅𝖾𝗇j(X)\displaystyle\mathsf{len}_{j}(X)=𝗅𝖾𝗇(𝗆𝗈𝖽𝖾j(P)),\displaystyle=\mathsf{len}(\mathsf{mode}_{j}(P))\text{, }𝗅𝖾𝗇<j(P)\displaystyle\mathsf{len}_{<j}(P)=∑i=1j−1𝗅𝖾𝗇i(X),\displaystyle=\sum_{i=1}^{j-1}\mathsf{len}_{i}(X)\text{,}𝗅𝖾𝗇≤j(X)\displaystyle\mathsf{len}_{\leq j}(X)=𝗅𝖾𝗇<j(P)+𝗅𝖾𝗇j(P)\displaystyle=\mathsf{len}_{<j}(P)+\mathsf{len}_{j}(P)
The most important operation supported by profiles issubstitution: IfQQis a profile of lengthmm, andP1,…,PmP_{1},\dots,P_{m}are profiles, then we can obtain a new profile(P1,…,Pm)Q(P_{1},\dots,P_{m})_{Q}by substituting theiith entry ofQQwith the profilePiP_{i}, for each1≤i≤m1\leq i\leq m. More precisely, we have the following definition.
Definition 2.2.1.8.
SupposeQQis a profile of lengthmm, and supposeP1,…,PmP_{1},\dots,P_{m}are profiles. Then theQQ-substitutionofP1,…,PmP_{1},\dots,P_{m}is the profile
(P1,…,Pm)Q(P_{1},\dots,P_{m})_{Q}defined as follows. Write0pt(Q)=d0pt(Q)=dand𝗋𝖺𝗇𝗄(Q)=r\mathsf{rank}(Q)=r.
- •Ifd=0d=0, thenm=1m=1, and we define (P1)Q=P1.(P_{1})_{Q}=P_{1}.
- •Suppose next thatd>0d>0, and that we have definedQ′Q^{\prime}-substitution for all profilesQ′Q^{\prime}of depth<d<d. We can write Q=(Q1,…,Qr)Q=(Q_{1},\dots,Q_{r})where each modeQi=𝗆𝗈𝖽𝖾i(Q)Q_{i}=\mathsf{mode}_{i}(Q)has depth<d<d. If for each1≤i≤r1\leq i\leq r, we set ℓi=𝗅𝖾𝗇(P1)+⋯+𝗅𝖾𝗇(Pi−1),\ell_{i}=\mathsf{len}(P_{1})+\cdots+\mathsf{len}(P_{i-1}),then we define (P1,…,Pr)Q=((P1,…,Pℓ2)Q1,…,(Pℓr+1,…,Pℓr+1)Qr).(P_{1},\dots,P_{r})_{Q}=((P_{1},\dots,P_{\ell_{2}})_{Q_{1}},\dots,(P_{\ell_{r}+1},\dots,P_{\ell_{r+1}})_{Q_{r}}).
Example 2.2.1.9.
IfQ=(∗,∗)Q=(*,*)andP1=(∗,∗)P_{1}=(*,*),P2=(∗,∗,∗)P_{2}=(*,*,*),
(P1,P2)Q=((∗,∗),(∗,∗,∗)).(P_{1},P_{2})_{Q}=((*,*),(*,*,*)).More generally, ifQ=(∗,…,∗)Q=(*,\dots,*)is the profile with0pt(Q)=10pt(Q)=1and𝗅𝖾𝗇(Q)=𝗋𝖺𝗇𝗄(Q)=r\mathsf{len}(Q)=\mathsf{rank}(Q)=r, then
(P1,…,Pr)Q=(P1,…,Pr)(P_{1},\dots,P_{r})_{Q}=(P_{1},\dots,P_{r})is ordinary concatenation.
Aside 2.2.1.10.
There is an operadic interpretation ofQQ-substitution. The set𝖯𝗋𝗈𝖿𝗂𝗅𝖾\mathsf{Profile}of profiles has the structure of a (non-symmetric) operad: the set
𝖯𝗋𝗈𝖿𝗂𝗅𝖾(n)={P∈𝖯𝗋𝗈𝖿𝗂𝗅𝖾∣𝗅𝖾𝗇(P)=n}\mathsf{Profile}(n)=\{P\in\mathsf{Profile}\mid\mathsf{len}(P)=n\}forms the collection ofnn-ary operations of𝖯𝗋𝗈𝖿𝗂𝗅𝖾\mathsf{Profile}, and ifn=m1+⋯+mrn=m_{1}+\cdots+m_{r}, then the structure map
𝖯𝗋𝗈𝖿𝗂𝗅𝖾(m1)×⋯×𝖯𝗋𝗈𝖿𝗂𝗅𝖾(mr)×𝖯𝗋𝗈𝖿𝗂𝗅𝖾(n){\lx@inpgf@ignorespaces\mathsf{Profile}(m_{1})\times\dots\times\mathsf{Profile}(m_{r})\times\mathsf{Profile}(n)}𝖯𝗋𝗈𝖿𝗂𝗅𝖾(m1+⋯+mr){\lx@inpgf@ignorespaces\mathsf{Profile}(m_{1}+\cdots+m_{r})}(P1,…,Pr),Q{\lx@inpgf@ignorespaces(P_{1},\dots,P_{r}),Q}(P1,…,Pr)Q{\lx@inpgf@ignorespaces(P_{1},\dots,P_{r})_{Q}}is given byQQ-substitution. One can also form the cofree symmetric operad on this non-symmetric operad, which amounts to endowing the sets ofnn-ary operations with trivial symmetric group action.
2.2.2Basic definitions
Having defined profiles and their basic properties, we can now define nested tuples.
Definition 2.2.2.1.
IfVVis a set, then anested tupleXXwith entries inVVis a pair(X♭,P)(X^{\flat},P)consisting of
- 1.a tupleX♭=(x1,…,xm)X^{\flat}=(x_{1},\dots,x_{m})with entries inVV, called theflatteningofXX, and
- 2.a profile𝗉𝗋𝗈𝖿(X)=P\mathsf{prof}(X)=Pof lengthmm, called theprofileofXX.
We write𝖭𝖾𝗌𝗍(V)\mathsf{Nest}(V)for the set of all nested tuples with entries in a setVV.
Example 2.2.2.2.
Here are some examples of nested tuples, together with their flattening and profile.
X\displaystyle X=(2,(2,2))\displaystyle=(2,(2,2))\quadX♭\displaystyle X^{\flat}=(2,2,2)\displaystyle=(2,2,2)\quad𝗉𝗋𝗈𝖿(X)\displaystyle\mathsf{prof}(X)=(∗,(∗,∗))\displaystyle=(*,(*,*))X\displaystyle X=25\displaystyle=25\quadX♭\displaystyle X^{\flat}=(25)\displaystyle=(25)\quad𝗉𝗋𝗈𝖿(X)\displaystyle\mathsf{prof}(X)=∗\displaystyle=*X\displaystyle X=(((2,2,2),8),64)\displaystyle=(((2,2,2),8),64)\quadX♭\displaystyle X^{\flat}=(2,2,2,8,26)\displaystyle=(2,2,2,8,26)\quad𝗉𝗋𝗈𝖿(X)\displaystyle\mathsf{prof}(X)=(((∗,∗,∗),∗),∗)\displaystyle=(((*,*,*),*),*)X\displaystyle X=((,,,,)\displaystyle=((),(32,()),(4,8))\quadX♭\displaystyle X^{\flat}=(32,4,8)\displaystyle=(32,4,8)\quad𝗉𝗋𝗈𝖿(X)\displaystyle\mathsf{prof}(X)=((,,,,)\displaystyle=((),(*,()),(*,*))
Notation 2.2.2.3.
We sometimes write
X=(x1,…,xm)PX=(x_{1},\dots,x_{m})_{P}to denote a nested tuple withX♭=(x1,…,xm)X^{\flat}=(x_{1},\dots,x_{m})and profile𝗉𝗋𝗈𝖿(X)=P\mathsf{prof}(X)=P.
Observation 2.2.2.4.
IfVVis any set, then by definition, we have a pullback square
𝖭𝖾𝗌𝗍(V){\lx@inpgf@ignorespaces\mathsf{Nest}(V)}𝖯𝗋𝗈𝖿𝗂𝗅𝖾{\lx@inpgf@ignorespaces\mathsf{Profile}}𝖳𝗎𝗉𝗅𝖾(V){\lx@inpgf@ignorespaces\mathsf{Tuple}(V)}ℕ.{\lx@inpgf@ignorespaces\mathbb{N}.}𝗉𝗋𝗈𝖿(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{prof}(-)}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}⌟{\lx@inpgf@ignorespaces\lrcorner}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}
Let’s define some important attributes of nested tuples. Each such attribute of a nested tupleXXis inhereted by its flatteningX♭X^{\flat}or its profile𝗉𝗋𝗈𝖿(X)\mathsf{prof}(X).
Definition 2.2.2.6.
SupposeXXis a nested tuple with entries inVV.
- •TherankofXXis 𝗋𝖺𝗇𝗄(X)=𝗋𝖺𝗇𝗄(P)\mathsf{rank}(X)=\mathsf{rank}(P)
- •ThelengthofXXis 𝗅𝖾𝗇(X)=𝗅𝖾𝗇(P)=𝗅𝖾𝗇(X♭)\mathsf{len}(X)=\mathsf{len}(P)=\mathsf{len}(X^{\flat})
- •ThedepthofXXis 0pt(X)=0pt(P)0pt(X)=0pt(P)
- •IfV=ℤV=\mathbb{Z}, then thesizeofXXis 𝗌𝗂𝗓𝖾(X)=𝗌𝗂𝗓𝖾(X♭).\mathsf{size}(X)=\mathsf{size}(X^{\flat}).
Example 2.2.2.7.
Here are some examples of nested tuples of integers, together with their rank, length, depth, and size:
X\displaystyle X=27\displaystyle=27𝗋𝖺𝗇𝗄(X)\displaystyle\quad\mathsf{rank}(X)=1,𝗅𝖾𝗇(X)=1,\displaystyle=1,\quad\mathsf{len}(X)=1,0pt(X)\displaystyle 0pt(X)=0,𝗌𝗂𝗓𝖾(X)=27\displaystyle=0,\quad\mathsf{size}(X)=27X\displaystyle X=(2,10,5)\displaystyle=(2,10,5)𝗋𝖺𝗇𝗄(X)\displaystyle\quad\mathsf{rank}(X)=3,𝗅𝖾𝗇(X)=3,\displaystyle=3,\quad\mathsf{len}(X)=3,0pt(X)\displaystyle 0pt(X)=1,𝗌𝗂𝗓𝖾(X)=100\displaystyle=1,\quad\mathsf{size}(X)=100X\displaystyle X=(((3,4),2,2),8,9),\displaystyle=(((3,4),2,2),8,9),𝗋𝖺𝗇𝗄(X)\displaystyle\quad\mathsf{rank}(X)=3,𝗅𝖾𝗇(X)=6,\displaystyle=3,\quad\mathsf{len}(X)=6,0pt(X)\displaystyle 0pt(X)=3,𝗌𝗂𝗓𝖾(X)=3096\displaystyle=3,\quad\mathsf{size}(X)=3096X\displaystyle X=(((),()),(2,(5,5))),\displaystyle=(((),()),(2,(5,5))),𝗋𝖺𝗇𝗄(X)\displaystyle\quad\mathsf{rank}(X)=2,𝗅𝖾𝗇(X)=3,\displaystyle=2,\quad\mathsf{len}(X)=3,0pt(X)\displaystyle 0pt(X)=3,𝗌𝗂𝗓𝖾(X)=50\displaystyle=3,\quad\mathsf{size}(X)=50
Example 2.2.2.8.
A nested tuple of integers with depth00is simply an integer.
Example 2.2.2.9.
A nested tuple of integers with depth11is simply a tuple of integers. IfXXis such a nested tuple, then𝗋𝖺𝗇𝗄(X)=𝗅𝖾𝗇(X)\mathsf{rank}(X)=\mathsf{len}(X).
Definition 2.2.2.10.
SupposeX=(x1,…,xm)PX=(x_{1},\dots,x_{m})_{P}is a nested tuple with𝗋𝖺𝗇𝗄(X)=r\mathsf{rank}(X)=r. If1≤i≤r1\leq i\leq r, then theiithmode ofXXto be the nested tuple
𝗆𝗈𝖽𝖾i(X)=(x𝗅𝖾𝗇<i(P)+1,…,x𝗅𝖾𝗇≤i(P))𝗆𝗈𝖽𝖾i(P).\mathsf{mode}_{i}(X)=(x_{\mathsf{len}_{<i}(P)+1},\dots,x_{\mathsf{len}_{\leq i}(P)})_{\mathsf{mode}_{i}(P)}.
Example 2.2.2.11.
If
X=((3),4,((10,10),12)),X=((3),4,((10,10),12)),then the modes ofXXare
𝗆𝗈𝖽𝖾1(X)\displaystyle\mathsf{mode}_{1}(X)=(3)\displaystyle=(3)𝗆𝗈𝖽𝖾2(X)\displaystyle\mathsf{mode}_{2}(X)=4\displaystyle=4𝗆𝗈𝖽𝖾3(X)\displaystyle\mathsf{mode}_{3}(X)=((10,10),12)\displaystyle=((10,10),12)
Example 2.2.2.12.
IfX=(32,5,6,64)X=(32,5,6,64), then the modes ofXXare
𝗆𝗈𝖽𝖾1(X)\displaystyle\mathsf{mode}_{1}(X)=32\displaystyle=32𝗆𝗈𝖽𝖾2(X)\displaystyle\mathsf{mode}_{2}(X)=5\displaystyle=5𝗆𝗈𝖽𝖾3(X)\displaystyle\mathsf{mode}_{3}(X)=6\displaystyle=6𝗆𝗈𝖽𝖾4(X)\displaystyle\mathsf{mode}_{4}(X)=64\displaystyle=64
It will be convenient to introduce the following notation.
Notation 2.2.2.13.
SupposeXXis a nested tuple of integers with0pt(X)>00pt(X)>0. For any1≤j≤𝗋𝖺𝗇𝗄(X)1\leq j\leq\mathsf{rank}(X), we write
𝗅𝖾𝗇j(X)\displaystyle\mathsf{len}_{j}(X)=𝗅𝖾𝗇(𝗆𝗈𝖽𝖾j(X)),\displaystyle=\mathsf{len}(\mathsf{mode}_{j}(X))\text{, }𝗅𝖾𝗇<j(X)\displaystyle\mathsf{len}_{<j}(X)=∑i=1j−1𝗅𝖾𝗇i(X),\displaystyle=\sum_{i=1}^{j-1}\mathsf{len}_{i}(X)\text{,}𝗅𝖾𝗇≤j(X)\displaystyle\mathsf{len}_{\leq j}(X)=𝗅𝖾𝗇<j(X)+𝗅𝖾𝗇j(X)\displaystyle=\mathsf{len}_{<j}(X)+\mathsf{len}_{j}(X)and similarly, we write
𝗌𝗂𝗓𝖾j(X)\displaystyle\mathsf{size}_{j}(X)=𝗌𝗂𝗓𝖾(𝗆𝗈𝖽𝖾j(X)),\displaystyle=\mathsf{size}(\mathsf{mode}_{j}(X))\text{, }𝗌𝗂𝗓𝖾<j(X)\displaystyle\mathsf{size}_{<j}(X)=∏i=1j−1𝗌𝗂𝗓𝖾j(X), and\displaystyle=\prod_{i=1}^{j-1}\mathsf{size}_{j}(X)\text{, and}𝗌𝗂𝗓𝖾≤j(X)\displaystyle\mathsf{size}_{\leq j}(X)=𝗌𝗂𝗓𝖾<j(X)⋅𝗌𝗂𝗓𝖾j(X).\displaystyle=\mathsf{size}_{<j}(X)\cdot\mathsf{size}_{j}(X).
Definition 2.2.2.14.
IfX=(x1,…,xm)PX=(x_{1},\dots,x_{m})_{P}is a nested tuple and1≤i≤m1\leq i\leq m, then theiith entry ofXXis
OPENOPENX)=X♭)=xi.X)=X^{\flat})=x_{i}.
Example 2.2.2.15.
If
X=((3),4,((10,10),12)),X=((3),4,((10,10),12)),then the entries ofXXare
OPENX)\displaystyle X)=3\displaystyle=3OPENX)\displaystyle X)=4\displaystyle=4OPENX)\displaystyle X)=10\displaystyle=10OPENX)\displaystyle X)=10\displaystyle=10OPENX)\displaystyle X)=12.\displaystyle=12.
Example 2.2.2.16.
IfX=(32,5,6,64)X=(32,5,6,64), then the entries ofXXare
OPENX)\displaystyle X)=32\displaystyle=32OPENX)\displaystyle X)=5\displaystyle=5OPENX)\displaystyle X)=6\displaystyle=6OPENX)\displaystyle X)=4.\displaystyle=4.
Example 2.2.2.17.
IfXXis a nested tuple with depth11, thenOPEN𝗆𝗈𝖽𝖾i(X)=X)\mathsf{mode}_{i}(X)=X)for all1≤i≤𝗋𝖺𝗇𝗄(X)=𝗅𝖾𝗇(X)1\leq i\leq\mathsf{rank}(X)=\mathsf{len}(X).
Observation 2.2.2.18.
IfXXis a nested tuple of integers, then theentriesofXXare integers, while themodesofXXare themselves nested tuples of integers.
Finally, we introduce the notion ofcongruenceof nested tuples, which indicates when nested tuples have the same profile.
Definition 2.2.2.19.
IfX1X_{1}andX2X_{2}are nested tuples, we sayX1X_{1}andX2X_{2}arecongruent, if
𝗉𝗋𝗈𝖿(X1)=𝗉𝗋𝗈𝖿(X2).\mathsf{prof}(X_{1})=\mathsf{prof}(X_{2}).
Example 2.2.2.20.
Here are some examples of nested tuplesX1X_{1}andX2X_{2}, and whether or not they are congruent
X1\displaystyle X_{1}=27\displaystyle=27\quadX2\displaystyle X_{2}=100\displaystyle=100\quadcongruent\displaystyle\text{congruent}X1\displaystyle X_{1}=(2,2)\displaystyle=(2,2)\quadX2\displaystyle X_{2}=(8,64)\displaystyle=(8,64)\quadcongruent\displaystyle\text{congruent}X1\displaystyle X_{1}=((4,8),(4,8))\displaystyle=((4,8),(4,8))\quadX2\displaystyle X_{2}=((1,1),(5,10))\displaystyle=((1,1),(5,10))\quadcongruent\displaystyle\text{congruent}X1\displaystyle X_{1}=((64,(8,8)),(25,(5,5)))\displaystyle=((64,(8,8)),(25,(5,5)))\quadX2\displaystyle X_{2}=((2,(3,5)),(7,(11,13)))\displaystyle=((2,(3,5)),(7,(11,13)))\quadcongruent\displaystyle\text{congruent}X1\displaystyle X_{1}=27\displaystyle=27\quadX2\displaystyle X_{2}=(100)\displaystyle=(100)\quadnot congruent\displaystyle\text{not congruent}X1\displaystyle X_{1}=(2,2)\displaystyle=(2,2)\quadX2\displaystyle X_{2}=(8,64,128)\displaystyle=(8,64,128)\quadnot congruent\displaystyle\text{not congruent}X1\displaystyle X_{1}=((4,8),(4,8))\displaystyle=((4,8),(4,8))\quadX2\displaystyle X_{2}=(((1,1),(5,10)))\displaystyle=(((1,1),(5,10)))\quadnot congruent\displaystyle\text{not congruent}
2.2.3Substitution
Recall that ifQQis a profile of lengthrrandP1,…,PrP_{1},\dots,P_{r}are profiles, then we defined a profile
(P1,…,Pr)Q(P_{1},\dots,P_{r})_{Q}called theQQ-substitutionofP1,…,PrP_{1},\dots,P_{r}. This profile is obtained fromQQby replacing theiith entry ofQQwith the profilePiP_{i}. We can extend this to an operation on nested tuples as follows.
Definition 2.2.3.1.
SupposeX1,…,XmX_{1},\dots,X_{m}are nested tuples with profilesP1,…,PmP_{1},\dots,P_{m}, and supposeQQis a profile of lengthmm. We define theQQ-substitution
(X1,…,Xm)Q(X_{1},\dots,X_{m})_{Q}ofX1,…,XmX_{1},\dots,X_{m}to be the nested tuple with flattening
(X1,…,Xm)Q♭=X1♭⋆⋯⋆Xm♭(X_{1},\dots,X_{m})_{Q}^{\flat}=X_{1}^{\flat}\star\cdots\star X_{m}^{\flat}and profile
(P1,…,Pm)Q.(P_{1},\dots,P_{m})_{Q}.More generally, ifX1,…,XmX_{1},\dots,X_{m}are nested tuples andYYis a nested tuple of lengthmm, we define
(X1,…,Xm)Y=(X1,…,Xm)𝗉𝗋𝗈𝖿(Y).(X_{1},\dots,X_{m})_{Y}=(X_{1},\dots,X_{m})_{\mathsf{prof}(Y)}.
Example 2.2.3.2.
If(X1,X2,X3)=(64,16,4)(X_{1},X_{2},X_{3})=(64,16,4)andQ=(∗,(∗,∗))Q=(*,(*,*)), then
(X1,X2,X3)Q=(64,(32,4))(X_{1},X_{2},X_{3})_{Q}=(64,(32,4))
Example 2.2.3.3.
If(X1,X2,X3,X4)=((2,2),(3,3),(5,5),(7,7))(X_{1},X_{2},X_{3},X_{4})=((2,2),(3,3),(5,5),(7,7))andQ=((∗,∗),(∗,∗))Q=((*,*),(*,*)), then
(X1,X2,X3,X4)Q=(((2,2),(3,3)),((5,5),(7,7))).(X_{1},X_{2},X_{3},X_{4})_{Q}=(((2,2),(3,3)),((5,5),(7,7))).
Example 2.2.3.4.
IfX=(12)X=(12)andQ=∗Q=*, then
Example 2.2.3.5.
IfX1=2X_{1}=2,X2=2X_{2}=2,X3=(5,5)X_{3}=(5,5), andQ=(∗,∗,∗)Q=(*,*,*), then
(X1,X2,X3)Q=(2,2,(5,5))=(X1,X2,X3).\displaystyle(X_{1},X_{2},X_{3})_{Q}=(2,2,(5,5))=(X_{1},X_{2},X_{3}).More generally, ifX1,…,XmX_{1},\dots,X_{m}are any nested tuples andP=(∗,…,∗)P=(*,\dots,*)then
(X1,…,Xm)Q=(X1,…,Xk)(X_{1},\dots,X_{m})_{Q}=(X_{1},\dots,X_{k})is theconcatenationofX1,…,XmX_{1},\dots,X_{m}.
Aside 2.2.3.6.
There is anoperadicinterpretation of substitutions of nested tuples. The set𝖭𝖾𝗌𝗍(ℤ)\mathsf{Nest}(\mathbb{Z})of nested tuples of integers is analgebraover the operad𝖯𝗋𝗈𝖿𝗂𝗅𝖾\mathsf{Profile}, with structure maps given byQQ-substitution:
𝖭𝖾𝗌𝗍(ℤ)×⋯×𝖭𝖾𝗌𝗍(ℤ)×𝖯𝗋𝗈𝖿𝗂𝗅𝖾(n){\lx@inpgf@ignorespaces\mathsf{Nest}(\mathbb{Z})\times\dots\times\mathsf{Nest}(\mathbb{Z})\times\mathsf{Profile}(n)}𝖭𝖾𝗌𝗍(ℤ){\lx@inpgf@ignorespaces\mathsf{Nest}(\mathbb{Z})}(X1,…,Xm),Q{\lx@inpgf@ignorespaces(X_{1},\dots,X_{m}),Q}(X1,…,Xm)Q.{\lx@inpgf@ignorespaces(X_{1},\dots,X_{m})_{Q}.}
2.2.4Refinement
In this section, we introduce an important relation on nested tuples calledrefinement. Intuitively, ifX′X^{\prime}andXXare nested tuples of integers, we sayX′X^{\prime}refinesXXifX′X^{\prime}may be obtained fromXXby replacing each entry ofXXwith some nested tuple of the same size. More precisely, we have the following definition.
Definition 2.2.4.1.
IfX′X^{\prime}andXXare nested tuples, then we sayX′X^{\prime}refinesXXif either
- 1.X=𝗌𝗂𝗓𝖾(X′)X=\mathsf{size}(X^{\prime}), or
- 2.1. (a)0pt(X′),0pt(X)>00pt(X^{\prime}),0pt(X)>0, 2. (b)𝗋𝖺𝗇𝗄(X′)=𝗋𝖺𝗇𝗄(X)\mathsf{rank}(X^{\prime})=\mathsf{rank}(X), and 3. (c)for each1≤i≤𝗋𝖺𝗇𝗄(X)1\leq i\leq\mathsf{rank}(X),𝗆𝗈𝖽𝖾i(X′)\mathsf{mode}_{i}(X^{\prime})refines𝗆𝗈𝖽𝖾i(X)\mathsf{mode}_{i}(X).
Notation 2.2.4.2.
We write
X′↠XX^{\prime}\twoheadrightarrow Xto indicate thatX′X^{\prime}refinesXX.
Example 2.2.4.3.
Here are some examples of refinements of nested tuples.
(2,(2,2))↠\displaystyle(2,(2,2))\twoheadrightarrow8\displaystyle 8((2,2),(3,3),(5,5))↠\displaystyle((2,2),(3,3),(5,5))\twoheadrightarrow(4,9,25)\displaystyle(4,9,25)(64)↠\displaystyle(64)\twoheadrightarrow64\displaystyle 64(8,((2,2,2),((1,4),(2,2))))↠\displaystyle(8,((2,2,2),((1,4),(2,2))))\twoheadrightarrow(8,(8,8))\displaystyle(8,(8,8))
Observation 2.2.4.4.
Refinement of nested tuples is reflexive, transitive, and antisymmetric, so refinement specifies a partial ordering on the collection of nested tuples of positive integers.
IfX′X^{\prime}refinesXX, then we can think ofX′X^{\prime}as being obtained fromXXby replacing each entryxix_{i}ofXXwith some nested tupleXi′X_{i}^{\prime}of sizexix_{i}. We refer to the nested tupleXi′X_{i}^{\prime}as theiith mode ofX′X^{\prime}relative toXX. More precisely, we have the following definition.
Construction 2.2.4.5.
SupposeXXis a nested tuple of integers of lengthmm, and supposeX′X^{\prime}refinesXX. For any1≤i≤m1\leq i\leq m, we define a nested tuple
Xi′=𝗆𝗈𝖽𝖾i(X′,X),X_{i}^{\prime}=\mathsf{mode}_{i}(X^{\prime},X),called theiith mode ofX′X^{\prime}relative toXX, by the formula
𝗆𝗈𝖽𝖾i(X′,X)={X′0pt(X)=0(hencei=ℓ=1)𝗆𝗈𝖽𝖾i−N(𝗆𝗈𝖽𝖾j(X′),𝗆𝗈𝖽𝖾j(X))jis the largest integer such thatN≔𝗅𝖾𝗇<j(X)<i.\mathsf{mode}_{i}(X^{\prime},X)=\begin{cases}X^{\prime}&0pt(X)=0\text{ (hence }i=\ell=1\text{)}\\ \mathsf{mode}_{i-N}(\mathsf{mode}_{j}(X^{\prime}),\mathsf{mode}_{j}(X))&\begin{matrix}j\text{ is the largest integer such that }\\ N\coloneqq\mathsf{len}_{<j}(X)<i.\\ \end{matrix}\end{cases}
Example 2.2.4.6.
IfX=((4,9),(25,36))X=((4,9),(25,36)), andX′=(((2,2),(3,3)),(25,(6,(2,3))))X^{\prime}=(((2,2),(3,3)),(25,(6,(2,3)))), thenX′X^{\prime}refinesXXand the modes ofX′X^{\prime}relative toXXare
𝗆𝗈𝖽𝖾1(X′,X)\displaystyle\mathsf{mode}_{1}(X^{\prime},X)=(2,2)\displaystyle=(2,2)𝗆𝗈𝖽𝖾2(X′,X)\displaystyle\mathsf{mode}_{2}(X^{\prime},X)=(3,3)\displaystyle=(3,3)𝗆𝗈𝖽𝖾3(X′,X)\displaystyle\mathsf{mode}_{3}(X^{\prime},X)=25\displaystyle=25𝗆𝗈𝖽𝖾4(X′,X)\displaystyle\mathsf{mode}_{4}(X^{\prime},X)=(6,(2,3)).\displaystyle=(6,(2,3)).
Example 2.2.4.7.
IfXXis any nested tuple, thenXXrefinesXX, and for any1≤i≤𝗅𝖾𝗇(X)1\leq i\leq\mathsf{len}(X)we have
OPEN𝗆𝗈𝖽𝖾i(X,X)=X).\mathsf{mode}_{i}(X,X)=X).
Example 2.2.4.8.
IfX=X♭X=X^{\flat}is a tuple, andX′X^{\prime}refinesXX, then for any1≤i≤𝗅𝖾𝗇(X)1\leq i\leq\mathsf{len}(X), we have
𝗆𝗈𝖽𝖾i(X′,X)=𝗆𝗈𝖽𝖾i(X′).\mathsf{mode}_{i}(X^{\prime},X)=\mathsf{mode}_{i}(X^{\prime}).
Example 2.2.4.9.
IfX′X^{\prime}is a nested tuple with𝗌𝗂𝗓𝖾(X′)=N\mathsf{size}(X^{\prime})=N, thenX′X^{\prime}refinesNN, and the only mode ofX′X^{\prime}relative toNNis
𝗆𝗈𝖽𝖾1(X′,N)=X′.\mathsf{mode}_{1}(X^{\prime},N)=X^{\prime}.
Notation 2.2.4.10.
IfX′↠XX^{\prime}\twoheadrightarrow Xis a refinement and1≤i≤𝗅𝖾𝗇(X)1\leq i\leq\mathsf{len}(X), then we write
𝗅𝖾𝗇i(X′,X)\displaystyle\mathsf{len}_{i}(X^{\prime},X)=𝗅𝖾𝗇(𝗆𝗈𝖽𝖾i(X′,X))\displaystyle=\mathsf{len}(\mathsf{mode}_{i}(X^{\prime},X))𝗅𝖾𝗇<i(X′,X)\displaystyle\mathsf{len}_{<i}(X^{\prime},X)=∑j<i𝗅𝖾𝗇j(X′,X)\displaystyle=\sum_{j<i}\mathsf{len}_{j}(X^{\prime},X)𝗅𝖾𝗇≤i(X′,X)\displaystyle\mathsf{len}_{\leq i}(X^{\prime},X)=∑j≤i𝗅𝖾𝗇j(X′,X)\displaystyle=\sum_{j\leq i}\mathsf{len}_{j}(X^{\prime},X)
Definition 2.2.4.11.
SupposeX′X^{\prime}refinesXX, and writeXi′=𝗆𝗈𝖽𝖾i(X′,X)X_{i}^{\prime}=\mathsf{mode}_{i}(X^{\prime},X). Then theflattening ofX′X^{\prime}relative toXXis the nested tuple
𝖿𝗅𝖺𝗍(X′,X)=(X1′,…,Xm′).\mathsf{flat}(X^{\prime},X)=(X_{1}^{\prime},\dots,X_{m}^{\prime}).
Example 2.2.4.12.
IfX′=(((2,2),(3,3)),((5,5),(7,7)))X^{\prime}=(((2,2),(3,3)),((5,5),(7,7)))andX=((4,9),(25,49))X=((4,9),(25,49)), then
𝖿𝗅𝖺𝗍(X′,X)=((2,2),(3,3),(5,5),(7,7)).\mathsf{flat}(X^{\prime},X)=((2,2),(3,3),(5,5),(7,7)).
Example 2.2.4.13.
IfXXis any nested tuple, then the flattening ofXXrelative toXXis
𝖿𝗅𝖺𝗍(X,X)=X♭.\mathsf{flat}(X,X)=X^{\flat}.
Example 2.2.4.14.
IfX=X♭X=X^{\flat}is a tuple, andX′X^{\prime}refinesXX, then the flattening ofX′X^{\prime}relative toXXis
𝖿𝗅𝖺𝗍(X′,X)=X′.\mathsf{flat}(X^{\prime},X)=X^{\prime}.
Example 2.2.4.15.
IfX′X^{\prime}is a nested tuple with𝗌𝗂𝗓𝖾(X′)=N\mathsf{size}(X^{\prime})=N, thenX′X^{\prime}refinesNN, and the flattening ofX′X^{\prime}relative toNNis
𝖿𝗅𝖺𝗍(X′,N)=(N).\mathsf{flat}(X^{\prime},N)=(N).
Observation 2.2.4.16.
IfX′X^{\prime}refinesXX, then𝖿𝗅𝖺𝗍(X′,X)\mathsf{flat}(X^{\prime},X)refinesX♭X^{\flat}.
2.3Layouts
Having developed the necessary background on nested tuples, we turn our attention tolayouts. These are a generalization of flat layouts in which shapes and strides are allowed to be nested tuples, rather than (flat) tuples.
2.3.1Basic definitions
Definition 2.3.1.1.
Alayoutis a pair
consisting of a nested tuple of positive integers
𝗌𝗁𝖺𝗉𝖾(L)=S\mathsf{shape}(L)=Scalled theshapeofLL, and a nested tuple of non-negative integers
𝗌𝗍𝗋𝗂𝖽𝖾(L)=D\mathsf{stride}(L)=Dcalled thestrideofLL, such thatSSandDDare congruent.
Definition 2.3.1.2.
IfL=S:DL=S:Dis a layout, then therank,length,depth,size, andprofileofLLare defined to be the rank, length, depth, size, and profile ofSS, respectively.
Example 2.3.1.3.
The layoutL=(3,(3,2)):(3,(1,10))L=(3,(3,2)):(3,(1,10))may be pictured as follows.
012101112345131415678161718L=L=
Example 2.3.1.4.
The layoutL=((2,2),(2,2)):((1,4),(2,8))L=((2,2),(2,2)):((1,4),(2,8))may be pictured as follows.
0281013911461214571315L=L=
Example 2.3.1.5.
The layout
has𝗋𝖺𝗇𝗄(L)=1\mathsf{rank}(L)=1,𝗅𝖾𝗇(L)=1\mathsf{len}(L)=1,0pt(L)=00pt(L)=0,𝗌𝗂𝗓𝖾(L)=10\mathsf{size}(L)=10, and𝗉𝗋𝗈𝖿(L)=∗\mathsf{prof}(L)=*.
Example 2.3.1.6.
The layout
L=(7,(2,10,4),(3,7)):(1,(7,14,140),(560,1680))L=(7,(2,10,4),(3,7)):(1,(7,14,140),(560,1680))has𝗋𝖺𝗇𝗄(L)=3\mathsf{rank}(L)=3,𝗅𝖾𝗇(L)=6\mathsf{len}(L)=6,0pt(L)=20pt(L)=2,𝗌𝗂𝗓𝖾(L)=11760\mathsf{size}(L)=11760, and𝗉𝗋𝗈𝖿(L)=(∗,(∗,∗,∗),(∗,∗)).\mathsf{prof}(L)=(*,(*,*,*),(*,*)).
Example 2.3.1.7.
The layout
L=((,,,,,,,)):((,,,,,,,))L=((2,2,2,(2,2))):((1,0,8,(0,16)))has𝗋𝖺𝗇𝗄(L)=1\mathsf{rank}(L)=1,𝗅𝖾𝗇(L)=5\mathsf{len}(L)=5,0pt(L)=30pt(L)=3,𝗌𝗂𝗓𝖾(L)=32\mathsf{size}(L)=32, and𝗉𝗋𝗈𝖿(L)=((,,,,,,,))\mathsf{prof}(L)=((*,*,*,(*,*))).
Example 2.3.1.8.
The pair
S:D=(2,(2,2)):(1,2,4)S:D=(2,(2,2)):(1,2,4)is NOT a layout becauseSSandDDare not congruent.
Definition 2.3.1.9.
IfL=S:DL=S:Dis a layout, then for any1≤i≤𝗋𝖺𝗇𝗄(L)1\leq i\leq\mathsf{rank}(L)we define theiith mode ofLLto be the layout
𝗆𝗈𝖽𝖾i(L)=𝗆𝗈𝖽𝖾i(S):𝗆𝗈𝖽𝖾i(D),\mathsf{mode}_{i}(L)=\mathsf{mode}_{i}(S):\mathsf{mode}_{i}(D),and for any1≤i≤𝗅𝖾𝗇(L)1\leq i\leq\mathsf{len}(L), we define theiith entry ofLLto be the layout
Example 2.3.1.10.
IfL=((2,2),9):((3,6),12)L=\bigl((2,2),9\bigr):\bigl((3,6),12\bigr), then the modes ofLLare
𝗆𝗈𝖽𝖾1(L)\displaystyle\mathsf{mode}_{1}(L)=(2,2):(3,6)\displaystyle=(2,2):(3,6)𝗆𝗈𝖽𝖾2(L)\displaystyle\mathsf{mode}_{2}(L)=9:12\displaystyle=9:12and the entries ofLLare
OPENL)\displaystyle L)=2:3\displaystyle=2:3OPENL)\displaystyle L)=2:6\displaystyle=2:6OPENL)\displaystyle L)=9:12.\displaystyle=9:12.
Definition 2.3.1.13.
IfL=S:DL=S:Dis a layout, we define theflatteningofLLto be the flat layout
L♭=S♭:D♭.L^{\flat}=S^{\flat}:D^{\flat}.
Example 2.3.1.14.
The flattening ofL=10:4L=10:4isL♭=(10):(4)L^{\flat}=(10):(4).
Example 2.3.1.15.
The flattening of
L=((,,,,,,,)):((,,,,,,,))L=\bigl((2,2,2,(2,2))\bigr):\bigl((1,0,8,(0,16))\bigr)is
L♭=(2,2,2,2,2):(1,0,8,0,16).L^{\flat}=(2,2,2,2,2):(1,0,8,0,16).
We can use the flattening construction above to extend many concepts from flat layouts to nested layouts. For example:
Construction 2.3.1.17(Layout function).
IfLLis a nested layout, we define the layout functionΦL\Phi_{L}ofLLby
ΦL=ΦL♭,\Phi_{L}=\Phi_{L^{\flat}},whereΦL♭\Phi_{L^{\flat}}is the layout function of Construction2.1.2.19. Similarly, ifNNis such that𝖨𝗆𝖺𝗀𝖾(ΦL)⊂[0,N)\mathsf{Image}(\Phi_{L})\subset[0,N), we define
ΦLN=ΦL♭N\Phi_{L}^{N}=\Phi_{L^{\flat}}^{N}to be the factorization ofΦL\Phi_{L}through the inclusion[0,N)⊂ℤ[0,N)\subset\mathbb{Z}.
Example 2.3.1.18.
IfL=((2,2),2):((3,0),10)L=((2,2),2):((3,0),10), then the layout function
ΦL:[0,8)→ℤ\Phi_{L}:[0,8)\to\mathbb{Z}ofLLis given by
0{\lx@inpgf@ignorespaces 0}1{\lx@inpgf@ignorespaces 1}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}4{\lx@inpgf@ignorespaces 4}5{\lx@inpgf@ignorespaces 5}6{\lx@inpgf@ignorespaces 6}7{\lx@inpgf@ignorespaces 7}ΦL{\lx@inpgf@ignorespaces\Phi_{L}}0{\lx@inpgf@ignorespaces 0}3{\lx@inpgf@ignorespaces 3}0{\lx@inpgf@ignorespaces 0}3{\lx@inpgf@ignorespaces 3}10{\lx@inpgf@ignorespaces 10}13{\lx@inpgf@ignorespaces 13}10{\lx@inpgf@ignorespaces 10}13{\lx@inpgf@ignorespaces 13}
Given a layoutLL, we can obtain a flat layoutL♭L^{\flat}, and a profileP=𝗉𝗋𝗈𝖿(L)P=\mathsf{prof}(L). Conversely, if we are given a flat layoutLLand a profilePPwith the same length asLL, then we can construct a layout with flatteningLLand profilePPas follows.
Construction 2.3.1.19.
IfLLis a flat layout, andPPis a profile with𝗅𝖾𝗇(P)=𝗅𝖾𝗇(L)\mathsf{len}(P)=\mathsf{len}(L), then we can define
to be the layout with shape
𝗌𝗁𝖺𝗉𝖾(L)=𝗌𝗁𝖺𝗉𝖾(L)P\mathsf{shape}(L)=\mathsf{shape}(L)_{P}and stride
𝗌𝗍𝗋𝗂𝖽𝖾(L)=𝗌𝗍𝗋𝗂𝖽𝖾(L)P\mathsf{stride}(L)=\mathsf{stride}(L)_{P}where(−)P(-)_{P}is thePP-substitution operation of Definition2.2.1.8.
Example 2.3.1.20.
IfL=(8,8,8):(1,64,8)L=(8,8,8):(1,64,8)andP=(∗,(∗,∗))P=(*,(*,*)), then
LP=(8,(8,8)),(1,(64,8)).L_{P}=(8,(8,8)),(1,(64,8)).
Example 2.3.1.21.
IfL=(128):(2)L=(128):(2)andP=∗P=*, then
Proposition 2.3.1.22.
IfL′L^{\prime}is a flat layout andPPis a profile with𝗅𝖾𝗇(L′)=𝗅𝖾𝗇(P)\mathsf{len}(L^{\prime})=\mathsf{len}(P), then there exists a unique layoutLLwhose flattening isL♭=L′L^{\flat}=L^{\prime}and whose profile is𝗉𝗋𝗈𝖿(L)=P\mathsf{prof}(L)=P, namelyL=LP′L=L^{\prime}_{P}.
Proof.
This follows from the definition of nested tuples, since a nested tuple is uniquely determined by its flattening and its profile. ∎
Observation 2.3.1.23.
The previous proposition tells us that we have a pullback square
𝖫𝖺𝗒𝗈𝗎𝗍{\lx@inpgf@ignorespaces\mathsf{Layout}}𝖯𝗋𝗈𝖿𝗂𝗅𝖾{\lx@inpgf@ignorespaces\mathsf{Profile}}𝖥𝗅𝖺𝗍𝖫𝖺𝗒𝗈𝗎𝗍{\lx@inpgf@ignorespaces\mathsf{FlatLayout}}ℕ{\lx@inpgf@ignorespaces\mathbb{N}}𝗉𝗋𝗈𝖿(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{prof}(-)}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}⌟{\lx@inpgf@ignorespaces\lrcorner}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}
We can extend the notion of non-degeneracy to the nested case as follows.
Definition 2.3.1.24.
SupposeLLis a layout. We sayLLisnon-degenerateif for all1≤i≤𝗅𝖾𝗇(L)1\leq i\leq\mathsf{len}(L), the following condition holds:
𝗌𝗁𝖺𝗉𝖾(L))⇒𝗌𝗍𝗋𝗂𝖽𝖾(L))\mathsf{shape}(L))\quad\Rightarrow\quad\mathsf{stride}(L))
Example 2.3.1.25.
The layouts
L1\displaystyle L_{1}=((2,2),1):((1,2),0)\displaystyle=((2,2),1):((1,2),0)L2\displaystyle L_{2}=((8,8),(1,16)):((2,32),(0,128))\displaystyle=((8,8),(1,16)):((2,32),(0,128))are non-degenerate, while the layouts
L3\displaystyle L_{3}=((2,2),1):((1,2),4)\displaystyle=((2,2),1):((1,2),4)L4\displaystyle L_{4}=((8,8),(1,16)):((2,32),(1024,128))\displaystyle=((8,8),(1,16)):((2,32),(1024,128))are degenerate.
2.3.2Basic operations
Having established the basic vocabulary for layouts, we turn to the operations they support. In this section, we define basic operations that will be needed to construct more sophisticated operations such ascoalesce,complement,composition,logical division, andlogical product.
2.3.2.1Flattening
IfLLis a layout, then we may obtain a flat layoutL♭L^{\flat}by flattening the shape and stride ofLL.
Definition 2.3.2.1.
IfL=S:DL=S:Dis a layout, we define theflatteningofLLto be the flat layout
L♭=S♭:D♭.L^{\flat}=S^{\flat}:D^{\flat}.
Example 2.3.2.2.
The flattening of
L=((,,,,,,,)):((,,,,,,,))L=((2,2,2,(2,2))):((1,0,8,(0,16)))is
L♭=(2,2,2,2,2):(1,0,8,0,16).L^{\flat}=(2,2,2,2,2):(1,0,8,0,16).
Example 2.3.2.3.
The flattening ofL=10:4L=10:4isL♭=(10):(4)L^{\flat}=(10):(4).
Example 2.3.2.4.
SupposeLLis a layout. Then0pt(L)=10pt(L)=1if and only ifL=L♭L=L^{\flat}.
2.3.2.2Concatenate
We can concatenate layouts by concatenating their shapes and concatenating their strides.
Definition 2.3.2.5.
IfL=S:DL=S:DandL′=S′:D′L^{\prime}=S^{\prime}:D^{\prime}are layouts, then theconcatenationofLLandL′L^{\prime}is the layout(L,L′)(L,L^{\prime})
(L,L′)=(S,S′):(D,D′).(L,L^{\prime})=(S,S^{\prime}):(D,D^{\prime}).More generally, ifL1,…,LkL_{1},\dots,L_{k}is any finite collection of layouts, withLi=Si:DiL_{i}=S_{i}:D_{i}, then the concatenation ofL1,…,LkL_{1},\dots,L_{k}is the layout
(L1,…,Lk)=(S1,…,Sk):(D1,…,Dk).(L_{1},\dots,L_{k})=(S_{1},\dots,S_{k}):(D_{1},\dots,D_{k}).
Example 2.3.2.7.
IfL=(3,7,2):(1,3,6)L=(3,7,2):(1,3,6)andL′=(2,(2,(4,3))):(5,3,(2,2))L^{\prime}=(2,(2,(4,3))):(5,3,(2,2)), then
(L,L′)=((3,7,2),(2,(2,(4,3)))):((1,3,6),(5,(3,(2,2))))(L,L^{\prime})=((3,7,2),(2,(2,(4,3)))):((1,3,6),(5,(3,(2,2))))
Example 2.3.2.11.
If
L=((5,(7,7)),2,(4,5)):((1,(35,5)),0,(1,8))L=((5,(7,7)),2,(4,5)):((1,(35,5)),0,(1,8))thenL=(L1,L2,L3)L=(L_{1},L_{2},L_{3})where
L1\displaystyle L_{1}=(5,(7,7)):(1,(35,5)),\displaystyle=\bigl(5,(7,7)\bigr):\bigl(1,(35,5)\bigr),L2\displaystyle L_{2}=2:0, and\displaystyle=2:0\text{, and }L3\displaystyle L_{3}=(4,5):(1,8).\displaystyle=(4,5):(1,8).
2.3.2.3Substitution
Recall that ifX1,…,XkX_{1},\dots,X_{k}are nested tuples andPPis a profile with𝗅𝖾𝗇(P)=k\mathsf{len}(P)=k, then we may form thePP-substitution
(X1,…,Xk)P(X_{1},\dots,X_{k})_{P}which is obtained by replacing theiithe entry ofPPwith the nested tupleXiX_{i}. We can extend this construction from nested tuples to layouts as follows.
Definition 2.3.2.12.
SupposeL=S:DL=S:Dis a layout, and supposePPis a profile with𝗅𝖾𝗇(P)=𝗋𝖺𝗇𝗄(L)\mathsf{len}(P)=\mathsf{rank}(L). We define
LP=SP:DPL_{P}=S_{P}:D_{P}whereSPS_{P}andDPD_{P}are thePP-substitutions of (the modes of)SSandDD.
Example 2.3.2.13.
IfP=(∗,(∗,∗))P=(*,(*,*))andL=(8,8,8):(1,8,64)L=(8,8,8):(1,8,64), then
LP=(8,(8,8)):(1,(8,64)).L_{P}=(8,(8,8)):(1,(8,64)).
Example 2.3.2.14.
IfOPENP=(∗,(∗,∗)))P=(*,(*,*)))and
L=((2,2),(3,3),(5,5)):((2,1),(12,4),(180,36)),L=((2,2),(3,3),(5,5)):((2,1),(12,4),(180,36)),then
LP=((2,2),((3,3),(5,5))):((2,1),((12,4),(180,36))).L_{P}=((2,2),((3,3),(5,5))):((2,1),((12,4),(180,36))).
Example 2.3.2.15.
IfL=(16):(1)L=(16):(1)andP=∗P=*, then
2.3.3Coalesce
Recall that ifLLis a flat layout, then𝖼𝗈𝖺𝗅♭(L)\mathsf{coal}^{\flat}(L)is a the unique flat layout of minimal rank whose layout function isΦL\Phi_{L}. We can make a similar construction in the setting of arbitrary (nested) layouts. We begin by defining the notion of a coalesced layout.
Definition 2.3.3.1.
SupposeLLis a layout. We sayLLiscoalescedif one of the following conditions holds.
- 1.L=1:0L=1:0,
- 2.0pt(L)=00pt(L)=0and𝗌𝗁𝖺𝗉𝖾(L)>1\mathsf{shape}(L)>1, or
- 3.0pt(L)=10pt(L)=1,𝗋𝖺𝗇𝗄(L)>1\mathsf{rank}(L)>1, andLLis coalesced in the sense of Definition2.1.4.1.
Example 2.3.3.2.
The layout
L=(2,(2,2)):(1,(16,512))L=(2,(2,2)):(1,(16,512))is not coalesced since0pt(L)>10pt(L)>1.
Example 2.3.3.3.
The layout
is not coalesced, while the layout
is coalesced.
Example 2.3.3.4.
The layout
is not coalesced, while the layout
is coalesced.
Example 2.3.3.5.
The empty layout
is not coalesced.
Observation 2.3.3.6.
Recall that a layoutLLis non-degenerate if
𝗌𝗁𝖺𝗉𝖾(L))=1⇒𝗌𝗍𝗋𝗂𝖽𝖾(L))=0.\mathsf{shape}(L))=1\quad\Rightarrow\quad\mathsf{stride}(L))=0.IfLLis coalesced, thenLLis non-degenerate.
IfLLis any layout, we can obtain a coalesced layout𝖼𝗈𝖺𝗅(L)\mathsf{coal}(L)as follows.
Construction 2.3.3.7.
SupposeLLis a layout, and write
𝖼𝗈𝖺𝗅♭(L♭)=(s1,…,sm):(d1,…,dm).\mathsf{coal}^{\flat}(L^{\flat})=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).1. 1.Ifm>1m>1, we define 𝖼𝗈𝖺𝗅(L)=𝖼𝗈𝖺𝗅♭(L♭)\mathsf{coal}(L)=\mathsf{coal}^{\flat}(L^{\flat}) 2. 2.Ifm=1m=1, we define 𝖼𝗈𝖺𝗅(L)=s1:d1\mathsf{coal}(L)=s_{1}:d_{1} 3. 3.Ifm=0m=0, we define 𝖼𝗈𝖺𝗅(L)=1:0.\mathsf{coal}(L)=1:0.
Example 2.3.3.8.
IfE=():()E=():()is the empty layout, then
𝖼𝗈𝖺𝗅(E)=1:0.\mathsf{coal}(E)=1:0.
Example 2.3.3.9.
IfL=(1,1):(2,4)L=(1,1):(2,4), then
𝖼𝗈𝖺𝗅(L)=1:0.\mathsf{coal}(L)=1:0.
Example 2.3.3.10.
IfL=(512):(4)L=(512):(4), then
𝖼𝗈𝖺𝗅(L)=512:4.\mathsf{coal}(L)=512:4.
Example 2.3.3.11.
IfL=(2,2,2):(1,2,4)L=(2,2,2):(1,2,4), then
𝖼𝗈𝖺𝗅(L)=8:1.\mathsf{coal}(L)=8:1.
Example 2.3.3.12.
IfL=((2,2,2),(5,5)):((1,2,4),(10,50))L=((2,2,2),(5,5)):((1,2,4),(10,50)), then
𝖼𝗈𝖺𝗅(L)=(8,25):(1,10).\mathsf{coal}(L)=(8,25):(1,10).
Proposition 2.3.3.14.
IfAAandBBare layouts, then
ΦA=ΦB⇔𝖼𝗈𝖺𝗅(A)=𝖼𝗈𝖺𝗅(B).\Phi_{A}=\Phi_{B}\quad\Leftrightarrow\quad\mathsf{coal}(A)=\mathsf{coal}(B).
Proof.
Using Proposition2.1.4.18, we have
ΦA=ΦB\displaystyle\Phi_{A}=\Phi_{B}\hskip 14.45377pt⇔ΦA♭=ΦB♭\displaystyle\Leftrightarrow\hskip 14.45377pt\Phi_{A^{\flat}}=\Phi_{B^{\flat}}⇔𝖼𝗈𝖺𝗅♭(A♭)=𝖼𝗈𝖺𝗅♭(B♭)\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{coal}^{\flat}(A^{\flat})=\mathsf{coal}^{\flat}(B^{\flat})⇔𝖼𝗈𝖺𝗅(A)=𝖼𝗈𝖺𝗅(B).\displaystyle\Leftrightarrow\hskip 14.45377pt\mathsf{coal}(A)=\mathsf{coal}(B).∎
Definition 2.3.3.15.
IfLLis a layout, define thecomplexityofLLto be the integer
𝖼𝗈𝗆𝗉𝗅𝖾𝗑𝗂𝗍𝗒(L)=𝗅𝖾𝗇(L)+0pt(L).\mathsf{complexity}(L)=\mathsf{len}(L)+0pt(L).
Proposition 2.3.3.16.
IfLLis a layout and𝗌𝗂𝗓𝖾(L)>1\mathsf{size}(L)>1, then𝖼𝗈𝖺𝗅(L)\mathsf{coal}(L)is the unique complexity minimizing layout whose layout function isΦL\Phi_{L}.
Proof.
SupposeL′L^{\prime}is a layout with the same layout function asLL, and suppose𝖼𝗈𝖺𝗅(L′)≠1:0\mathsf{coal}(L^{\prime})\neq 1:0. Then
𝗅𝖾𝗇(L′)≥𝗅𝖾𝗇(𝖼𝗈𝖺𝗅(L′))=𝗅𝖾𝗇(𝖼𝗈𝖺𝗅(L)).\mathsf{len}(L^{\prime})\geq\mathsf{len}(\mathsf{coal}(L^{\prime}))=\mathsf{len}(\mathsf{coal}(L)).There are two cases to consider.
- •(Case 1): Suppose𝗅𝖾𝗇(L′)>1\mathsf{len}(L^{\prime})>1. Then0pt(L′)≥1≥0pt(𝖼𝗈𝖺𝗅(L))0pt(L^{\prime})\geq 1\geq 0pt(\mathsf{coal}(L)). Combining these inequalities, we observe that 𝖼𝗈𝗆𝗉𝗅𝖾𝗑𝗂𝗍𝗒(L′)≥𝖼𝗈𝗆𝗉𝗅𝖾𝗑𝗂𝗍𝗒(𝖼𝗈𝖺𝗅(L)),\mathsf{complexity}(L^{\prime})\geq\mathsf{complexity}(\mathsf{coal}(L)),where equality holds if and only ifL′=𝖼𝗈𝖺𝗅(L′)=𝖼𝗈𝖺𝗅(L)L^{\prime}=\mathsf{coal}(L^{\prime})=\mathsf{coal}(L).
- •(Case 2): Suppose𝗅𝖾𝗇(L′)=1\mathsf{len}(L^{\prime})=1. ThenL′=(s):(d)L^{\prime}=(s):(d)orL′=s:dL^{\prime}=s:dfor some integerss>1s>1andd≥0d\geq 0. In either case, we have𝖼𝗈𝖺𝗅(L′)=s:d\mathsf{coal}(L^{\prime})=s:d, and 𝖼𝗈𝗆𝗉𝗅𝖾𝗑𝗂𝗍𝗒(L′)≥𝖼𝗈𝗆𝗉𝗅𝖾𝗑𝗂𝗍𝗒(𝖼𝗈𝖺𝗅(L)),\mathsf{complexity}(L^{\prime})\geq\mathsf{complexity}(\mathsf{coal}(L)),where equality holds if and only ifL′=s:d=𝖼𝗈𝖺𝗅(L)L^{\prime}=s:d=\mathsf{coal}(L).
∎
2.3.4Relative coalesce
There is an important invariant of coalesce calledrelative coalesce, denoted𝖼𝗈𝖺𝗅(L,S¯)\mathsf{coal}(L,\bar{S}). This operation receives as an additional input a nested tupleS¯\bar{S}which is refined by𝗌𝗁𝖺𝗉𝖾(L)\mathsf{shape}(L). In this case, the relative coalesce operation simplifies the layoutLLhas much as possible, while ensuring that the resulting shape still refinesS¯\bar{S}.
Definition 2.3.4.1.
SupposeL=S:DL=S:Dis a layout, and supposeS¯\bar{S}is some nested tuple of lengthmmwhich is refined bySS. Recall that for any1≤i≤m1\leq i\leq m, we may consider theiith mode ofSSrelative toS¯\bar{S}, denoted
𝗆𝗈𝖽𝖾i(S,S¯).\mathsf{mode}_{i}(S,\bar{S}).SinceSSandDDare congruent, there is a nested tuple
𝗆𝗈𝖽𝖾i(D,S¯)\mathsf{mode}_{i}(D,\bar{S})corresponding to𝗆𝗈𝖽𝖾i(S,S¯)\mathsf{mode}_{i}(S,\bar{S}), and we define theiith mode ofLLrelative toS¯\bar{S}to be the layout
𝗆𝗈𝖽𝖾i(L,S¯)=𝗆𝗈𝖽𝖾i(S,S¯):𝗆𝗈𝖽𝖾i(D,S¯).\mathsf{mode}_{i}(L,\bar{S})=\mathsf{mode}_{i}(S,\bar{S}):\mathsf{mode}_{i}(D,\bar{S}).
Example 2.3.4.2.
IfS¯=(4,(9,25))\bar{S}=(4,(9,25))and
L=((2,2),((3,3),(5,(1,5)))):((1,2),((6,18),(90,(0,450))))L=((2,2),((3,3),(5,(1,5)))):((1,2),((6,18),(90,(0,450))))then
𝗆𝗈𝖽𝖾1(L,S¯)\displaystyle\mathsf{mode}_{1}(L,\bar{S})=(2,2):(1,2)\displaystyle=(2,2):(1,2)𝗆𝗈𝖽𝖾2(L,S¯)\displaystyle\mathsf{mode}_{2}(L,\bar{S})=(3,3):(6,18)\displaystyle=(3,3):(6,18)𝗆𝗈𝖽𝖾3(L,S¯)\displaystyle\mathsf{mode}_{3}(L,\bar{S})=(5,(1,5)):(90,(0,450)).\displaystyle=(5,(1,5)):(90,(0,450)).
Observation 2.3.4.3.
SupposeL=S:DL=S:Dis a layout, and supposeS¯\bar{S}is a nested tuple of lengthmmand profilePPwhich is refined bySS. If for any1≤i≤m1\leq i\leq m, we write
Li=𝗆𝗈𝖽𝖾i(L,S¯),L_{i}=\mathsf{mode}_{i}(L,\bar{S}),then
L=(L1,…,Lm)PL=(L_{1},\dots,L_{m})_{P}is thePP-substitution of its relative modes.
Definition 2.3.4.4.
SupposeL=S:DL=S:Dis a layout, and supposeS¯\bar{S}is a nested tuple of lengthmmand profilePPwhich is refined bySS. We sayLLiscoalesced overS¯\bar{S}if each relative mode
𝗆𝗈𝖽𝖾i(L,S¯)\mathsf{mode}_{i}(L,\bar{S})is coalesced.
Observation 2.3.4.5.
In the setting of Definition2.3.4.4, ifLLis coalesced overS¯\bar{S}, thenLLis non-degenerate.
Example 2.3.4.6.
IfLLis a layout, thenLLis coalesced over𝗌𝗁𝖺𝗉𝖾(L)\mathsf{shape}(L)if and only ifLLis non-degenerate, i.e.
𝗌𝗁𝖺𝗉𝖾(L))=1⇒𝗌𝗍𝗋𝗂𝖽𝖾(L))=0.\mathsf{shape}(L))=1\quad\Rightarrow\quad\mathsf{stride}(L))=0.
Definition 2.3.4.7(Relative coalesce).
SupposeL=S:DL=S:Dis a layout, and supposeS¯\bar{S}is a nested tuple of lengthmmand profilePPwhich is refined bySS. We define
𝖼𝗈𝖺𝗅(L,S¯)=(𝖼𝗈𝖺𝗅(L1),…,𝖼𝗈𝖺𝗅(Lm))P.\mathsf{coal}(L,\bar{S})=(\mathsf{coal}(L_{1}),\dots,\mathsf{coal}(L_{m}))_{P}.
Lemma 2.3.4.9.
IfL=S:DL=S:Dis a layout andSSrefinesS¯\bar{S}, then
Φ𝖼𝗈𝖺𝗅(L,S¯)=ΦL.\Phi_{\mathsf{coal}(L,\bar{S})}=\Phi_{L}.
Proof.
As above, let
Li=𝗆𝗈𝖽𝖾i(L,S)L_{i}=\mathsf{mode}_{i}(L,S)denote theiith mode ofLLrelative toSS, and setL¯i=𝖼𝗈𝖺𝗅(Li)\bar{L}_{i}=\mathsf{coal}(L_{i}). Then
Φ𝖼𝗈𝖺𝗅(L,S¯)\displaystyle\Phi_{\mathsf{coal}(L,\bar{S})}=Φ(L¯1,…,L¯m)S¯\displaystyle=\Phi_{(\bar{L}_{1},\dots,\bar{L}_{m})_{\bar{S}}}=Φ(L¯1,…,L¯m)\displaystyle=\Phi_{(\bar{L}_{1},\dots,\bar{L}_{m})}=Φ𝖼𝗈𝖺𝗅((,,,,,))\displaystyle=\Phi_{\mathsf{coal}((\bar{L}_{1},\dots,\bar{L}_{m}))}=Φ𝖼𝗈𝖺𝗅((,,,,,))\displaystyle=\Phi_{\mathsf{coal}((L_{1},\dots,L_{m}))}=Φ(L1,…,Lm)\displaystyle=\Phi_{(L_{1},\dots,L_{m})}=Φ(L1,…,Lm)S¯\displaystyle=\Phi_{(L_{1},\dots,L_{m})_{\bar{S}}}=ΦL.\displaystyle=\Phi_{L}.∎
Proposition 2.3.4.10.
SupposeAAandBBare layouts, and supposeS¯\bar{S}is a nested tuple of lengthmmsuch that𝗌𝗁𝖺𝗉𝖾(A)\mathsf{shape}(A)refinesS¯\bar{S}and𝗌𝗁𝖺𝗉𝖾(B)\mathsf{shape}(B)refinesS¯\bar{S}. Then
ΦA=ΦB⇔𝖼𝗈𝖺𝗅(A,S¯)=𝖼𝗈𝖺𝗅(B,S¯)\Phi_{A}=\Phi_{B}\quad\Leftrightarrow\quad\mathsf{coal}(A,\bar{S})=\mathsf{coal}(B,\bar{S})
Proof.
If𝖼𝗈𝖺𝗅(A,S¯)=𝖼𝗈𝖺𝗅(B,S¯)\mathsf{coal}(A,\bar{S})=\mathsf{coal}(B,\bar{S}), the using Lemma2.3.4.9, we have
ΦA=Φ𝖼𝗈𝖺𝗅(A,S¯)=Φ𝖼𝗈𝖺𝗅(B,S¯)=ΦB.\Phi_{A}=\Phi_{\mathsf{coal}(A,\bar{S})}=\Phi_{\mathsf{coal}(B,\bar{S})}=\Phi_{B}.Conversely, suppose thatΦA=ΦB\Phi_{A}=\Phi_{B}. We will argue that𝖼𝗈𝖺𝗅(A,S¯)=𝖼𝗈𝖺𝗅(B,S¯)\mathsf{coal}(A,\bar{S})=\mathsf{coal}(B,\bar{S}). SetP=𝗉𝗋𝗈𝖿(S¯)P=\mathsf{prof}(\bar{S}), and for any1≤i≤m1\leq i\leq m, set
Ai\displaystyle A_{i}=𝗆𝗈𝖽𝖾i(A,S¯)\displaystyle=\mathsf{mode}_{i}(A,\bar{S})Bi\displaystyle B_{i}=𝗆𝗈𝖽𝖾i(B,S¯).\displaystyle=\mathsf{mode}_{i}(B,\bar{S}).Since
𝖼𝗈𝖺𝗅(A,S¯)=(𝖼𝗈𝖺𝗅(A1),…,𝖼𝗈𝖺𝗅(Am))P\mathsf{coal}(A,\bar{S})=(\mathsf{coal}(A_{1}),\dots,\mathsf{coal}(A_{m}))_{P}and
𝖼𝗈𝖺𝗅(B,S¯)=(𝖼𝗈𝖺𝗅(B1),…,𝖼𝗈𝖺𝗅(Bm))P\mathsf{coal}(B,\bar{S})=(\mathsf{coal}(B_{1}),\dots,\mathsf{coal}(B_{m}))_{P}it suffices to prove that𝖼𝗈𝖺𝗅(Ai)=𝖼𝗈𝖺𝗅(Bi)\mathsf{coal}(A_{i})=\mathsf{coal}(B_{i})for all1≤i≤m1\leq i\leq m. By the associativity of colexicographic isomorphisms, we can write the layout functionΦA\Phi_{A}ofAAas
[0,𝗌𝗂𝗓𝖾(A)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(A){)}}∏j=1m[0,𝗌𝗂𝗓𝖾(Aj)){\lx@inpgf@ignorespaces\prod_{j=1}^{m}{[}0,\mathsf{size}(A_{j}){)}}∏j=1mℤ{\lx@inpgf@ignorespaces\prod_{j=1}^{m}\mathbb{Z}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}𝖼𝗈𝗅𝖾𝗑−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}^{-1}}∏ΦAj\scriptstyle{\lx@inpgf@ignorespaces\prod\Phi_{A_{j}}}+\scriptstyle{\lx@inpgf@ignorespaces+}and we can write the layout functionΦB\Phi_{B}ofBBas
[0,𝗌𝗂𝗓𝖾(B)){\lx@inpgf@ignorespaces{[}0,\mathsf{size}(B){)}}∏j=1m[0,𝗌𝗂𝗓𝖾(Bj)){\lx@inpgf@ignorespaces\prod_{j=1}^{m}{[}0,\mathsf{size}(B_{j}){)}}∏j=1mℤ{\lx@inpgf@ignorespaces\prod_{j=1}^{m}\mathbb{Z}}ℤ{\lx@inpgf@ignorespaces\mathbb{Z}}𝖼𝗈𝗅𝖾𝗑−1\scriptstyle{\lx@inpgf@ignorespaces\mathsf{colex}^{-1}}∏ΦBj\scriptstyle{\lx@inpgf@ignorespaces\prod\Phi_{B_{j}}}+\scriptstyle{\lx@inpgf@ignorespaces+}For a fixed1≤i≤m1\leq i\leq m, consider the subset
[0,𝗌𝗂𝗓𝖾(Ai))⊂∏j=1m[0,𝗌𝗂𝗓𝖾(Aj))[0,\mathsf{size}(A_{i}))\subset\prod_{j=1}^{m}[0,\mathsf{size}(A_{j}))and its image
𝖼𝗈𝗅𝖾𝗑([0,𝗌𝗂𝗓𝖾(Ai)))⊂[0,𝗌𝗂𝗓𝖾(A)).\mathsf{colex}([0,\mathsf{size}(A_{i})))\subset[0,\mathsf{size}(A)).Since𝗌𝗂𝗓𝖾(Aj)=𝗌𝗂𝗓𝖾(Bj)\mathsf{size}(A_{j})=\mathsf{size}(B_{j})for all1≤j≤m1\leq j\leq m, this is the same as the image
𝖼𝗈𝗅𝖾𝗑([0,𝗌𝗂𝗓𝖾(Bj)))⊂[0,𝗌𝗂𝗓𝖾(B))=[0,𝗌𝗂𝗓𝖾(B)).\mathsf{colex}([0,\mathsf{size}(B_{j})))\subset[0,\mathsf{size}(B))=[0,\mathsf{size}(B)).The restriction ofΦA\Phi_{A}to this subset isΦAi\Phi_{A_{i}}, and the restriction ofBBto this subset isΦBi\Phi_{B_{i}}, so it follows thatΦAi=ΦBi\Phi_{A_{i}}=\Phi_{B_{i}}, and by Proposition2.3.3.14, we have𝖼𝗈𝖺𝗅(Ai)=𝖼𝗈𝖺𝗅(Bi)\mathsf{coal}(A_{i})=\mathsf{coal}(B_{i}). We deduce that
𝖼𝗈𝖺𝗅(A,S¯)=𝖼𝗈𝖺𝗅(B,S¯),\mathsf{coal}(A,\bar{S})=\mathsf{coal}(B,\bar{S}),as desired. ∎
2.3.5Compact layouts
We can easily extend the concept of compact layouts to the nested case. Again, in terms of the standard grid diagrams depicting layouts, a layoutLLis compact if each integer0≤i<𝗌𝗂𝗓𝖾(L)0\leq i<\mathsf{size}(L)appears exactly once. More preciesly, we have the following definition.
Definition 2.3.5.1.
SupposeLLis a layout. We sayLLiscompactif the layout function
ΦL𝖼𝗈𝗌𝗂𝗓𝖾(L):[0,𝗌𝗂𝗓𝖾(L))→[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))\Phi_{L}^{\mathsf{cosize}(L)}:[0,\mathsf{size}(L))\to[0,\mathsf{cosize}(L))is an isomorphism.
Example 2.3.5.2.
The layout
0281013911461214571315A=((2,2),(2,2)):((1,4),(2,8))=A=((2,2),(2,2)):((1,4),(2,8))=is compact, while the layouts
023234133335463638573739B=((2,2),(2,2)):((1,4),(2,32))=B=((2,2),(2,2)):((1,4),(2,32))=and
0202131346465757C=((2,2),(2,2)):((1,4),(2,0))=C=((2,2),(2,2)):((1,4),(2,0))=are not compact.
Example 2.3.5.3.
The following layouts are compact:
L1\displaystyle L_{1}=(2,(2,2)):(8,(1,4))\displaystyle=(2,(2,2)):(8,(1,4))L2\displaystyle L_{2}=((8,1),(8,32)):((2,0),(16,128))\displaystyle=((8,1),(8,32)):((2,0),(16,128))L3\displaystyle L_{3}=64:1\displaystyle=64:1
Example 2.3.5.4.
The layout
L=(2,(2,2)):(4,(8,16))L=(2,(2,2)):(4,(8,16))is not compact since the integer1∈[0,29)=[0,𝖼𝗈𝗌𝗂𝗓𝖾(L))1\in[0,29)=[0,\mathsf{cosize}(L))is not in the image ofΦL\Phi_{L}. More generally, if𝗌𝗂𝗓𝖾(L)≠𝖼𝗈𝗌𝗂𝗓𝖾(L)\mathsf{size}(L)\neq\mathsf{cosize}(L), thenLLis not compact.
We conclude this section by listing some equivalent conditions for a layoutLLto be compact.
Proposition 2.3.5.5.
SupposeLLis a layout. Then the following conditions are equivalent.
- 1.LLis compact.
- 2.L♭L^{\flat}is compact.
- 3.𝖼𝗈𝖺𝗅(L)\mathsf{coal}(L)is compact.
Proof.
The equivalence of these conditions follows from the fact that
ΦL=ΦL♭=Φ𝖼𝗈𝖺𝗅(L).\Phi_{L}=\Phi_{L^{\flat}}=\Phi_{\mathsf{coal}(L)}.∎
2.3.6Complements
We can easily extend the concept of complement to the nested case as follows.
Definition 2.3.6.1.
SupposeAAandBBare layouts. We sayBBis acomplement ofAA, and writeA⟂BA\perp B, if the concatenated layout(A,B)(A,B)is compact.
Lemma 2.3.6.2.
SupposeAAandBBare layouts. Then
A⟂B⇔A♭⟂B♭.A\perp B\quad\Leftrightarrow\quad A^{\flat}\perp B^{\flat}.
Proof.
This follows from the observation that(A,B)♭=A♭⋆B♭(A,B)^{\flat}=A^{\flat}\star B^{\flat}. ∎
Definition 2.3.6.3.
SupposeAAis a layout. We sayAAiscomplementableifA♭A^{\flat}is complementable.
Lemma 2.3.6.4.
SupposeAAis a layout. Then there exists a complementBBofAAif and only ifAAis complementable.
Proof.
IfAAis complementable, thenA♭A^{\flat}is complementable, so there exists a flat layoutBBsuch that the flat concatenationA♭⋆BA^{\flat}\star Bis compact. It follows that the concatenation(A,B)(A,B)is also compact, soAAadmits a complement. Conversely, suppose there exists a layoutBBsuch that(A,B)(A,B)is compact. ThenB♭B^{\flat}is a complement ofA♭A^{\flat}, so by Proposition2.1.6.21,A♭A^{\flat}is complementable, hence, by definition, so isAA. ∎
Definition 2.3.6.5.
SupposeAAis a layout. IfAAis complementable, then we define
𝖼𝗈𝗆𝗉(A)=𝖼𝗈𝖺𝗅(𝖼𝗈𝗆𝗉♭(A♭)),\mathsf{comp}(A)=\mathsf{coal}(\mathsf{comp}^{\flat}(A^{\flat})),as in Construction2.1.6.16. IfNNis a positive integer andAAisNN-complementable, then we define
𝖼𝗈𝗆𝗉(A,N)=𝖼𝗈𝖺𝗅(𝖼𝗈𝗆𝗉♭(A♭,N))\mathsf{comp}(A,N)=\mathsf{coal}(\mathsf{comp}^{\flat}(A^{\flat},N))as in Construction2.1.6.29.
Definition 2.3.6.7.
SupposeAAis a layout andNNis a positive integer. We say a layoutBBis aNN-complementofAAifA⟂BA\perp B, and
𝗌𝗂𝗓𝖾(A)⋅𝗌𝗂𝗓𝖾(B)=N.\mathsf{size}(A)\cdot\mathsf{size}(B)=N.
Definition 2.3.6.8.
SupposeAAis a layout andNNis a positive integer. We sayAAisNN-complementableif the flat layoutA♭A^{\flat}isNN-complementable, as in Definition2.1.6.24.
Proposition 2.3.6.9.
SupposeAAis a layout. Then there exists aNN-complement ofAAif and only ifAAisNN-complementable.
Proof.
IfBBis aNN-complement ofAA, thenB♭B^{\flat}is aNN-complementA♭A^{\flat}, and so by Proposition2.1.6.32,A♭A^{\flat}isNN-complementable, hence, so isAA. Conversely, ifAAisNN-complementable, then𝖼𝗈𝗆𝗉(A,N)\mathsf{comp}(A,N)is aNN-complement ofAA. ∎
Example 2.3.6.10.
IfA=((4,2),(2,2)):((3,24),(192,96))A=((4,2),(2,2)):((3,24),(192,96))andN=768N=768then
𝖼𝗈𝗆𝗉(A,N)=(3,2,2,2):(1,12,48,384).\mathsf{comp}(A,N)=(3,2,2,2):(1,12,48,384).
Example 2.3.6.11.
IfA=((16,4),64):((1,16),64)A=((16,4),64):((1,16),64)andN=4096N=4096then
𝖼𝗈𝗆𝗉(A,N)\displaystyle\mathsf{comp}(A,N)=𝖼𝗈𝖺𝗅(():())\displaystyle=\mathsf{coal}(():())=1:0.\displaystyle=1:0.
Example 2.3.6.12.
IfA=((16,4),64):((1,16),64)A=((16,4),64):((1,16),64)andN=8192N=8192then
𝖼𝗈𝗆𝗉(A,N)\displaystyle\mathsf{comp}(A,N)=𝖼𝗈𝖺𝗅((2):(4096))\displaystyle=\mathsf{coal}((2):(4096))=2:4096.\displaystyle=2:4096.
Example 2.3.6.13.
IfA=((16,4),64):((8,1),128)A=((16,4),64):((8,1),128)andN=16384N=16384, then
𝖼𝗈𝗆𝗉(A,N)\displaystyle\mathsf{comp}(A,N)=𝖼𝗈𝖺𝗅((2,2):(4,8192))\displaystyle=\mathsf{coal}((2,2):(4,8192))=(2,2):(4,8192).\displaystyle=(2,2):(4,8192).
2.3.7Composition
In this section, we discuss the most important operation on layouts, namelycomposition. IfAAandBBare layouts, then the composition ofAAandBBis a layoutB∘AB\circ Awhose layout function is the composite of the layout functions ofAAandBB. More precisely, we have the following definition.
Definition 2.3.7.1(Composition of layouts).
SupposeAAandBBare layouts. ThecompositeofAAandBBis the unique layoutB∘AB\circ Asatisfying the following properties.
- 1.𝗌𝗁𝖺𝗉𝖾(B∘A)\mathsf{shape}(B\circ A)refines𝗌𝗁𝖺𝗉𝖾(A)\mathsf{shape}(A),
- 2.B∘AB\circ Ais coalesced over𝗌𝗁𝖺𝗉𝖾(A)\mathsf{shape}(A), and
- 3.ΦB∘A=ΦB∘ΦA𝗌𝗂𝗓𝖾(B)\Phi_{B\circ A}=\Phi_{B}\circ\Phi_{A}^{\mathsf{size}(B)}.
Example 2.3.7.5.
IfA=(3,5):(10,2)A=(3,5):(10,2)andB=(100):(7)B=(100):(7), then
B∘A=(3,5):(70,14).B\circ A=(3,5):(70,14).
Example 2.3.7.6.
IfA=(4):(2)A=(4):(2)andB=(2,2,6):(12,6,1)B=(2,2,6):(12,6,1), then the composition ofAAandBBis
B∘A=((2,2)):((6,1)).B\circ A=((2,2)):((6,1)).
Example 2.3.7.8.
IfA=((2,4),8):((4,8),8)A=((2,4),8):((4,8),8)andB=(4,4,4,4):(2,4,8,16)B=(4,4,4,4):(2,4,8,16), then
B∘A=((2,(2,2)),(2,4)):((4,(8,8)),(8,8)).B\circ A=((2,(2,2)),(2,4)):((4,(8,8)),(8,8)).
Example 2.3.7.9.
IfA=((3,(2,2)),24):((3,(9,18)),72)A=((3,(2,2)),24):((3,(9,18)),72)andB=(9,8,3,8):(24,3,1,384)B=(9,8,3,8):(24,3,1,384)then
B∘A=((3,(2,2)),(3,8)):((72,(3,6)),(1,384))B\circ A=((3,(2,2)),(3,8)):((72,(3,6)),(1,384))
Next, we develop some useful properties for computing the composition of layouts.
Proposition 2.3.7.10.
SupposeAAis a layout, and supposeBBandB~\tilde{B}are layouts such that
- •𝗌𝗂𝗓𝖾(B)≤𝗌𝗂𝗓𝖾(B~)\mathsf{size}(B)\leq\mathsf{size}(\tilde{B}), and
- •ΦB~∣𝗌𝗂𝗓𝖾(B)=ΦB\Phi_{\tilde{B}}\mid_{\mathsf{size}(B)}=\Phi_{B}.
IfAAandBBare composable, then
B∘A=B~∘A.B\circ A=\tilde{B}\circ A.
Proof.
SupposeAAandBBare composable. Then𝖼𝗈𝗌𝗂𝗓𝖾(A)≤𝗌𝗂𝗓𝖾(B)\mathsf{cosize}(A)\leq\mathsf{size}(B), and the fact thatB∘AB\circ Ais the composite ofAAandB~\tilde{B}follows from the equality
ΦB~∘ΦA𝗌𝗂𝗓𝖾(B~)\displaystyle\Phi_{\tilde{B}}\circ\Phi_{A}^{\mathsf{size}(\tilde{B})}=(ΦB~)∣𝗌𝗂𝗓𝖾(B)∘ΦA𝗌𝗂𝗓𝖾(B)\displaystyle=\left(\Phi_{\tilde{B}}\right)\mid_{\mathsf{size}(B)}\circ\Phi_{A}^{\mathsf{size}(B)}=ΦB∘ΦA𝗌𝗂𝗓𝖾(B).\displaystyle=\Phi_{B}\circ\Phi_{A}^{\mathsf{size}(B)}.∎
Corollary 2.3.7.11.
IfAAandBBare layouts, thenAAandBBare composable if and only ifAAand𝖼𝗈𝖺𝗅(B)\mathsf{coal}(B)are composable, and
B∘A=𝖼𝗈𝖺𝗅(B)∘A.B\circ A=\mathsf{coal}(B)\circ A.
Now that we have developed the basic properties of layout composition, we turn our attention to the two most important instances of composition, namelylogical divisionandlogical products.
2.3.8Logical division
In this section, we define thelogical divisionof layouts. As a motivating example, consider the layout
048121620242815913172125292610141822263037111519232731A=(4,8):(1,4)=A=(4,8):(1,4)=
For various purposes, we may want totilethe layoutAA. For example, here are the tilings ofAAby various layoutsBB.
048121620242815913172125292610141822263037111519232731A=A=B=B=0145048121620242815913172125292610141822263037111519232731A=A=B=B=02468101214048121620242815913172125292610141822263037111519232731A=A=B=B=024616182022
When working with such tiled layouts, we would like to index into our layout with coordinates of the form(tile_coordinate,tile)(\texttt{tile}\_\texttt{coordinate},\texttt{tile})wheretilespecifies which tile we are working with, andtile_coordinate\texttt{tile}\_\texttt{coordinate}specifies a coordinate within the specified tile. For example, if bothAAandBBhave rank22, we would like to write((i,j),(k,ℓ))((i,j),(k,\ell))as the index of the(i,j)(i,j)th entry of the(k,ℓ)(k,\ell)th tile ofAA. The logical division ofA⊘BA\oslash Bis precisely the layout which affords us this ability.
Definition 2.3.8.1.
SupposeAAandBBare layouts, and suppose
Bc=𝖼𝗈𝗆𝗉(B,𝗌𝗂𝗓𝖾(A))B^{c}=\mathsf{comp}(B,\mathsf{size}(A))is the complement ofBBwith respect to𝗌𝗂𝗓𝖾(A)\mathsf{size}(A). Then thelogical divisionofAAbyBBis the layout
A⊘B\displaystyle A\oslash B=A∘(B,Bc)\displaystyle=A\circ(B,B^{c})=(A∘B,A∘Bc).\displaystyle=(A\circ B,A\circ B^{c}).
Example 2.3.8.2.
IfA=(4,8):(1,4)A=(4,8):(1,4)andB=(2,2):(1,4)B=(2,2):(1,4), then
A⊘B=((2,2),(2,4)):((1,4),(2,8)),A\oslash B=((2,2),(2,4)):((1,4),(2,8)),as depicted below.
048121620242815913172125292610141822263037111519232731A=A=B=B=0145
028101618242613911171925274612142022283057131521232931A⊘B=A\oslash B=
Example 2.3.8.4.
IfA=(4,8):(1,4)A=(4,8):(1,4)andB=(2,2):(4,1)B=(2,2):(4,1), then
A⊘B=((2,2),(2,4)):((4,1),(2,8)),A\oslash B=((2,2),(2,4)):((4,1),(2,8)),as depicted below.
048121620242815913172125292610141822263037111519232731A=A=B=B=0415
028101618242646121420222830139111719252757131521232931A⊘B=A\oslash B=
Example 2.3.8.6.
IfA=(4,8):(1,4)A=(4,8):(1,4)andB=(2,4):(2,4)B=(2,4):(2,4), then
A⊘B=((2,4),(2,2)):((2,4),(1,16)).A\oslash B=((2,4),(2,2)):((2,4),(1,16)).
Example 2.3.8.7.
IfA=(4,6):(1,40)A=(4,6):(1,40)andB=6:4B=6:4, then
A⊘B=(6,4):(40,1).A\oslash B=(6,4):(40,1).
Example 2.3.8.8.
IfA=(4,6,2,4,2,5):(36,1,18,0,0,144)A=(4,6,2,4,2,5):(36,1,18,0,0,144)andB=(4,10):(1,192)B=(4,10):(1,192), then
A⊘B=(((4,(2,5)),(6,2,4)):((36,(0,144)),(1,18,0))CLOSEA\oslash B=(((4,(2,5)),(6,2,4)):((36,(0,144)),(1,18,0))
Example 2.3.8.9.
IfA=(8,(4,4))A=(8,(4,4))andB=(2,(8,16))B=(2,(8,16)), then
A⊘B=((2,2),(2,(4,4))):((4,8),(2,(8,16))).A\oslash B=((2,2),(2,(4,4))):((4,8),(2,(8,16))).
2.3.9Logical product
In this section, we define thelogical productof layouts.
Definition 2.3.9.1.
SupposeAAandBBare layouts, and suppose
Ac=𝖼𝗈𝗆𝗉(A,𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B))A^{c}=\mathsf{comp}\bigl(A,\mathsf{size}(A)\cdot\mathsf{cosize}(B)\bigr)is the complement ofAAwith respect to𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B)\mathsf{size}(A)\cdot\mathsf{cosize}(B). Then thelogical productofAAandBBis the layout
A⊗B=(A,Ac∘B).A\otimes B=(A,A^{c}\circ B).
Observation 2.3.9.2.
By Proposition2.3.7.10and Proposition2.3.7.11, if we let
A~c=𝖼𝗈𝗆𝗉(A,N)\widetilde{A}^{c}=\mathsf{comp}(A,N)for any validN≥𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B)N\geq\mathsf{size}(A)\cdot\mathsf{cosize}(B), then
Ac∘B=A~c∘B.A^{c}\circ B=\tilde{A}^{c}\circ B.This means that when computingA⊗BA\otimes B, we can takeAcA^{c}to be any sufficiently large (sorted) complement ofAA.
Example 2.3.9.3.
IfA=(2,2):(5,10)A=(2,2):(5,10)andB=(3,5):(5,1)B=(3,5):(5,1)are the layouts
01051501234567891011121314A=A=B=B=thenA⊗BA\otimes Bis the layout
A⊗B=((2,2),(3,5)):((5,10),(20,1))A\otimes B=((2,2),(3,5)):((5,10),(20,1))as depicted below.
02040121412224232343424445254562646727478284892949103050113151123252133353143454153555163656173757183858193959
Example 2.3.9.4.
IfA=(3,3):(6,1)A=(3,3):(6,1)andB=(10,12):(24,2)B=(10,12):(24,2), then
A⊗B=((3,3),(10,12)):((6,1),(216,18)).A\otimes B=\bigl((3,3),(10,12)\bigr):\bigl((6,1),(216,18)\bigr).
Example 2.3.9.5.
IfA=(2,10):(1680,4)A=(2,10):(1680,4)andB=(4,9):(2,56)B=(4,9):(2,56), then
A⊗B=((2,10),((2,2),(3,3))):((1680,4),((2,40),(560,3360))).A\otimes B=((2,10),((2,2),(3,3))):((1680,4),((2,40),(560,3360))).
Example 2.3.9.6.
IfA=(4,(2,2)):(9,(1,3))A=(4,(2,2)):(9,(1,3))andB=((2,4),8):((1,4),2)B=((2,4),8):((1,4),2), then
A⊗B=((4,(2,2)),((2,4),8)):((9,(1,3)),((36,144),72)).A\otimes B=((4,(2,2)),((2,4),8)):((9,(1,3)),((36,144),72)).
2.3.10Tractable layouts
In this section we define an especially well-behaved class of layouts, calledtractablelayouts. We will see that tractable layouts are precisely the layouts which arise from a certain category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}.
Definition 2.3.10.1.
We say a layoutLListractableif the flat layoutL♭L^{\flat}is tractable, in the sense of Definition2.1.8.1. Explicitly,LLis tractable if the flat layout
OPENL♭)=(s1,…,sm):(d1,…,dm)L^{\flat})=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is such that for each1≤i<m1\leq i<m, we have
- 1.di=0d_{i}=0, or
- 2.sidis_{i}d_{i}dividesdi+1d_{i+1}.
Example 2.3.10.2.
The layout
L=(((12))):(((17)))L=(((12))):(((17)))is tractable. More generally, any layoutLLof length11is tractable.
Example 2.3.10.3.
The layout
L=((2,4),32):((1,2),8)L=((2,4),32):((1,2),8)is tractable. More generally, any column-major layout is tractable.
Example 2.3.10.4.
The layout
L=(2,(4,32)):(128,(32,1))L=(2,(4,32)):(128,(32,1))is tractable. More generally, any row-major layoutLLis tractable.
Example 2.3.10.5.
The layout
L=((3,3),(1,3),(3,1,3)):((81,1),(0,8),(3,0,27))L=((3,3),(1,3),(3,1,3)):((81,1),(0,8),(3,0,27))is tractable. More generally, any compact layout is tractable.
Example 2.3.10.6.
The layout
L=((,,,,,)):((,,,,,))L=((3,7,7)):((0,15,0))is tractable. More generally, any layout with exactly one non-zero stride entry is tractable.
Example 2.3.10.7.
The layout
L=(2,(2,(2,2))):(1,(2048,(16,64)))L=(2,(2,(2,2))):(1,(2048,(16,64)))is tractable. More generally, any complementable layout is tractable.
Example 2.3.10.8.
The layout
L=((8,8),(5,5)):((8,1),(10,2))L=((8,8),(5,5)):((8,1),(10,2))is not tractable. In particular, this shows that the concatenation(L1,L2)(L_{1},L_{2})of tractable layoutsL1L_{1}andL2L_{2}need not be tractable.
Chapter 3Categories of layouts
Having thoroughly explored the algebra of layouts, we now turn our attention to the mathematical heart of this work: realizing layouts as morphisms in suitably-defined categories. Along the way, we develop agraphical calculus of layout diagramsthat affords more straightforward computation of layout operations.
3.1The category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}
In this section, we define a category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}whose objects are tuples of positive integers, and whose morphisms we calltuple morphisms. Each tuple morphismf:S→Tf:S\to Tencodes a flat layoutLfL_{f}. Composition of tuple morphisms is compatible with layout composition, in that ifffandggare composable tuple morphisms, then
Lg∘f=Lg∘Lf.L_{g\circ f}=L_{g}\circ L_{f}.We define a realization functor (3.1.4.4)
|⋅|:𝗧𝘂𝗽𝗹𝗲→𝗙𝗶𝗻𝗦𝗲𝘁|\cdot|:{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{FinSet}}}which recovers the layout function ofLfL_{f}via the formula
|f|=ΦLf𝗌𝗂𝗓𝖾(T).|f|=\Phi_{L_{f}}^{\mathsf{size}(T)}.We develop an “algebra of tuple morphisms” which includes operations such assort(Section3.1.5.3),coalesce(Section3.1.5.4),complement(Section3.1.5.6),concatenate(Section3.1.5.5),flat division(Section3.1.5.7), andflat products(Section3.1.5.8), which are compatible with the corresponding operations on flat layouts.
3.1.1Basic definitions
Definition 3.1.1.1.
Let𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}denote the category whose objects are the pointed finite sets
⟨m⟩∗={∗,1,2,…,m}\langle m\rangle_{*}=\{*,1,2,\dots,m\}form≥0m\geq 0, and whose morphismsα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}are functions satisfyingα(∗)=∗\alpha(*)=*. We call these morphismspointed maps, or simplymaps.
Aside 3.1.1.2.
𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}is askeletonof the category𝗙𝗶𝗻𝗦𝗲𝘁∗{\boldsymbol{\mathsf{FinSet}}}_{*}of finite pointed sets.
Notation 3.1.1.3.
If the codomain of a pointed mapα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}is understood, we sometimes write
α=(α(1),…,α(m))\alpha=(\alpha(1),\dots,\alpha(m))as a tuple of lengthmmwith entries in⟨n⟩∗\langle n\rangle_{*}.
Example 3.1.1.4.
There is a morphismα:⟨4⟩∗→⟨6⟩∗\alpha:\langle 4\rangle_{*}\to\langle 6\rangle_{*}in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}given by
α=(2,1,∗,6),\alpha=(2,1,*,6),which we can visualize using the following diagram.
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}α{\lx@inpgf@ignorespaces\alpha}Note that the bullet corresponding to entry 3 does not support an arrow, reflecting the fact that it gets sent to∗*.
Example 3.1.1.5.
There is a morphismβ:⟨5⟩∗→⟨3⟩∗\beta:\langle 5\rangle_{*}\to\langle 3\rangle_{*}in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}given by
β=(∗,1,2,3,∗),\beta=(*,1,2,3,*)~,which we can visualize using the following diagram.
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}β{\lx@inpgf@ignorespaces\beta}
Example 3.1.1.6.
For anym≥0m\geq 0, there is a unique morphism in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}of the formπ:⟨m⟩∗→⟨0⟩∗\pi:\langle m\rangle_{*}\to\langle 0\rangle_{*}, namely
π=(∗,…,∗).\pi=(*,\dots,*).
Example 3.1.1.7.
For anyn≥0n\geq 0, there is a unique morphism in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}of the formδ:⟨0⟩∗→⟨m⟩∗\delta:\langle 0\rangle_{*}\to\langle m\rangle_{*}, namely
Aside 3.1.1.8.
The category𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}is the category of operators for the commutative operad, so we sometimes write
𝗙𝗶𝗻∗=𝗖𝗼𝗺𝗺⊗.{\boldsymbol{\mathsf{Fin}}}_{*}={\boldsymbol{\mathsf{Comm}}}^{\otimes}.
We are especially interested intractablemorphisms in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}, which we define below.
Definition 3.1.1.9.
We say a pointed mapα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}istractableif for anyj∈⟨n⟩⊂⟨n⟩∗j\in\langle n\rangle\subset\langle n\rangle_{*}, the preimageα−1(j)\alpha^{-1}(j)is empty or consists of a single element.
Example 3.1.1.10.
The maps
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}α1{\lx@inpgf@ignorespaces\alpha_{1}}α2{\lx@inpgf@ignorespaces\alpha_{2}}α3{\lx@inpgf@ignorespaces\alpha_{3}}are tractable, while the maps
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}β1{\lx@inpgf@ignorespaces\beta_{1}}β2{\lx@inpgf@ignorespaces\beta_{2}}β3{\lx@inpgf@ignorespaces\beta_{3}}are not tractable
Aside 3.1.1.12.
The wide subcategory
𝗘0⊗⊂𝗖𝗼𝗺𝗺⊗=𝗙𝗶𝗻∗{\boldsymbol{\mathsf{E}}}_{0}^{\otimes}\subset{\boldsymbol{\mathsf{Comm}}}^{\otimes}={\boldsymbol{\mathsf{Fin}}}_{*}on the tractable pointed maps is the category of operators for the𝗘0{\boldsymbol{\mathsf{E}}}_{0}operad.
Definition 3.1.1.13.
Let𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}denote the category whose objects are tuples
S=(s1,…,sm)S=(s_{1},\dots,s_{m})of positive integers, where a morphism
f:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is specified by a tractable pointed mapα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}satisfying the property that
- •if1≤i≤m1\leq i\leq mandα(i)≠∗\alpha(i)\neq*, thensi=tα(i)s_{i}=t_{\alpha(i)}.
We say that such a morphismfflies overα\alpha, and refer toffas atuple morphism.
Notation 3.1.1.14.
Iff:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism which lies overα\alpha, then we sometimes depictffas
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn).{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n}).}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}
The graphical calculus of layouts we develop is based on the natural visualizations of morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, as exemplified below.
Example 3.1.1.15.
The tuple morphism
(3,128,128){\lx@inpgf@ignorespaces(3,128,128)}(3,2,128,2,128){\lx@inpgf@ignorespaces(3,2,128,2,128)}f\scriptstyle{\lx@inpgf@ignorespaces f}(1,3,5)\scriptstyle{\lx@inpgf@ignorespaces(1{,}3{,}5)}can be visualized using the following diagram.
128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}f{\lx@inpgf@ignorespaces f}
Example 3.1.1.16.
The tuple morphism
(3,128,128){\lx@inpgf@ignorespaces(3,128,128)}(128,128){\lx@inpgf@ignorespaces(128,128)}g\scriptstyle{\lx@inpgf@ignorespaces g}(∗,2,1)\scriptstyle{\lx@inpgf@ignorespaces(*{,}2{,}1)}can be visualized using the following diagram.
128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}3{\lx@inpgf@ignorespaces 3}128{\lx@inpgf@ignorespaces 128}g{\lx@inpgf@ignorespaces g}
Example 3.1.1.17.
The tuple morphism
(16,16,16,1,32){\lx@inpgf@ignorespaces(16,16,16,1,32)}(16,32,1,1){\lx@inpgf@ignorespaces(16,32,1,1)}h\scriptstyle{\lx@inpgf@ignorespaces h}(∗,∗,1,∗,2)\scriptstyle{\lx@inpgf@ignorespaces(*{,}*{,}1{,}*{,}2)}can be visualized using the following diagram.
32{\lx@inpgf@ignorespaces 32}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}16{\lx@inpgf@ignorespaces 16}1{\lx@inpgf@ignorespaces 1}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}h{\lx@inpgf@ignorespaces h}
Observation 3.1.1.18.
We can relate the category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}to some well-known operads as follows. Letℤ>0𝖽𝗂𝗏\mathbb{Z}_{>0}^{\mathsf{div}}denote the poset of positive integers under the divisibility relation, considered as a symmetric monoidal category with product given by multiplication of integers. Let(ℤ>0𝖽𝗂𝗏)⊗(\mathbb{Z}_{>0}^{\mathsf{div}})^{\otimes}denote the category of operators ofℤ>0𝖽𝗂𝗏\mathbb{Z}_{>0}^{\mathsf{div}}. Then there are evident functors
𝗧𝘂𝗽𝗹𝗲→(ℤ>0𝖽𝗂𝗏)⊗,{\boldsymbol{\mathsf{Tuple}}}\to(\mathbb{Z}_{>0}^{\mathsf{div}})^{\otimes},and
𝗧𝘂𝗽𝗹𝗲→𝗘0⊗,{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{E}}}_{0}^{\otimes},such that the diagram
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}(ℤ>0𝖽𝗂𝗏)⊗{\lx@inpgf@ignorespaces(\mathbb{Z}_{>0}^{\mathsf{div}})^{\otimes}}𝗘0⊗{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{E}}}_{0}^{\otimes}}𝗖𝗼𝗺𝗺⊗{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Comm}}}^{\otimes}}commutes. This exhibits𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}as the wide subcategory of the pullback operad
𝗧𝘂𝗽𝗹𝗲⊂𝗘0⊗×𝗖𝗼𝗺𝗺⊗(ℤ>0𝖽𝗂𝗏)⊗{\boldsymbol{\mathsf{Tuple}}}\subset{\boldsymbol{\mathsf{E}}}_{0}^{\otimes}\times_{{\boldsymbol{\mathsf{Comm}}}^{\otimes}}(\mathbb{Z}_{>0}^{\mathsf{div}})^{\otimes}on the morphisms
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}satisfying
α(i)≠1⇒si=tα(i).\alpha(i)\neq 1\quad\Rightarrow\quad s_{i}=t_{\alpha(i)}.
3.1.2From tuple morphisms to flat layouts
The impetus for working with the category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}is that each tuple morphismffencodes a flat layoutLfL_{f}. Moreover, each tractable layoutLLgives rise to a tuple morphismfLf_{L}. We prove asProposition3.1.2.10that these constructions are in some sense inverses, and that tractable layouts are precisely those encoded by tuple morphisms.
Construction 3.1.2.1.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a tuple morphism. We defineLfL_{f}to be the flat layout whose shape
𝗌𝗁𝖺𝗉𝖾(Lf)=(s1,…,sm)\mathsf{shape}(L_{f})=(s_{1},\dots,s_{m})is the domain offf, and whose stride
𝗌𝗍𝗋𝗂𝖽𝖾(Lf)=(d1,…,dm)\mathsf{stride}(L_{f})=(d_{1},\dots,d_{m})is defined by the formula
di={0α(i)=∗∏j<α(i)tjα(i)≠∗.d_{i}=\begin{cases}0&\alpha(i)=*\\ \prod_{j<\alpha(i)}t_{j}&\alpha(i)\neq*.\end{cases}We refer toLfL_{f}as thelayout encoded byffor thelayout associated toff.
Example 3.1.2.2.
The tuple morphism
128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}f{\lx@inpgf@ignorespaces f}of Example3.1.1.15encodes the layout
Lf=(3,128,128):(1,6,1536).L_{f}=(3,128,128):(1,6,1536).Note that computing the stride via the formula in3.1.2.1amounts to following the arrow from a specific shape entry to its target entry and multiplying together all entries below that one (taking the empty product to equal11).
Example 3.1.2.3.
The tuple morphism
(3,128,128){\lx@inpgf@ignorespaces(3,128,128)}(128,128){\lx@inpgf@ignorespaces(128,128)}g\scriptstyle{\lx@inpgf@ignorespaces g}(∗,2,1)\scriptstyle{\lx@inpgf@ignorespaces(*{,}2{,}1)}of Example3.1.1.16encodes the layout
Lg=(3,128,128):(0,128,1).L_{g}=(3,128,128):(0,128,1).
Example 3.1.2.4.
The tuple morphism
(16,16,16,1,32){\lx@inpgf@ignorespaces(16,16,16,1,32)}(16,32,1,1){\lx@inpgf@ignorespaces(16,32,1,1)}h\scriptstyle{\lx@inpgf@ignorespaces h}(∗,∗,1,∗,2)\scriptstyle{\lx@inpgf@ignorespaces(*{,}*{,}1{,}*{,}2)}of Example3.1.1.17encodes the layout
Lh=(16,16,16,1,32):(0,0,1,0,16).L_{h}=(16,16,16,1,32):(0,0,1,0,16).
We have seen how to compute the flat layoutLfL_{f}encoded by a tuple morphismff. On the other hand, ifLListractable, then we can go in the other direction, constructing a tuple morphismffwhich encodesLL. Recall from Definition2.1.8.1that a flat layoutLListractableif
OPENL)=(s1,…,sm):(d1,…,dm)L)=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})satisfies the following property:
If1≤i<m, thendi=0, orsididividesdi+1.\text{If }1\leq i<m\text{, then }d_{i}=0\text{, or }s_{i}d_{i}\text{ divides }d_{i+1}.
Construction 3.1.2.5.
SupposeL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is tractable, and set
OPENL)=(s1′,…,sm′):(d1′,…,dm′),L)=(s_{1}^{\prime},\dots,s_{m}^{\prime}):(d_{1}^{\prime},\dots,d_{m}^{\prime}),so there is some permutationσ∈Σm\sigma\in\Sigma_{m}such thatOPENL)=LσL)=L^{\sigma}. In other words,si′=sσ(i)s_{i}^{\prime}=s_{\sigma(i)}anddi′=dσ(i)d_{i}^{\prime}=d_{\sigma(i)}for each1≤i≤m1\leq i\leq m. If eachdi′d_{i}^{\prime}is nonzero, then letk=0k=0. Otherwise, letkkbe the largest integer such thatdk′=0d_{k}^{\prime}=0. Letℓ=2(m−k)\ell=2(m-k), and let
(t1′,…,tℓ′)=(dk+1′,sk+1′,dk+2′sk+1′dk+1′,sk+2′,dk+3′sk+2′dk+2′,…,dm′sm−1′dm−1′,sm′).\displaystyle(t_{1}^{\prime},\dots,t_{\ell}^{\prime})=\left(d_{k+1}^{\prime},s_{k+1}^{\prime},\dfrac{d_{k+2}^{\prime}}{s_{k+1}^{\prime}d_{k+1}^{\prime}},s_{k+2}^{\prime},\dfrac{d_{k+3}^{\prime}}{s^{\prime}_{k+2}d^{\prime}_{k+2}},\dots,\dfrac{d^{\prime}_{m}}{s^{\prime}_{m-1}d^{\prime}_{m-1}},s^{\prime}_{m}\right).We define
fL′:(s1,…,sm)→(t1′,…,tℓ′)f_{L}^{\prime}:(s_{1},\dots,s_{m})\to(t_{1}^{\prime},\dots,t_{\ell}^{\prime})to be the tuple morphism lying over the mapα:⟨m⟩∗→⟨ℓ⟩∗\alpha:\langle m\rangle_{*}\to\langle\ell\rangle_{*}given by
α′(i)={∗σ−1(i)≤k2(σ−1(i)−k)k+1≤σ−1(i)≤m.\alpha^{\prime}(i)=\begin{cases}*&\sigma^{-1}(i)\leq k\\ 2(\sigma^{-1}(i)-k)&k+1\leq\sigma^{-1}(i)\leq m.\end{cases}LetJ={j1<⋯<jn}⊂⟨ℓ⟩J=\{j_{1}<\dots<j_{n}\}\subset\langle\ell\rangledenote the collection of indices such thatjij_{i}is even ortji≠1t_{j_{i}}\neq 1. Let
(t1,…,tn)=(tj1′,…,tjn′),(t_{1},\dots,t_{n})=(t_{j_{1}}^{\prime},\dots,t_{j_{n}}^{\prime}),and letι:⟨n⟩∗→⟨ℓ⟩∗\iota:\langle n\rangle_{*}\to\langle\ell\rangle_{*}be the inclusion mapi↦jii\mapsto j_{i}. Then by construction, the mapα′\alpha^{\prime}factors asα′=ι∘α\alpha^{\prime}=\iota\circ\alpha, and we define thestandard representationofLLto be the tuple morphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn).{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n}).}fL\scriptstyle{\lx@inpgf@ignorespaces f_{L}}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}
Example 3.1.2.6.
If
L=(2,2):(3,30),L=(2,2):(3,30),thenLLis tractable, and the standard representation ofLLis the tuple morphism
2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}fL{\lx@inpgf@ignorespaces f_{L}}Note that, informally, computingfLf_{L}via3.1.2.5amounts to
- •initializing the codomain as()(),
- •traversing the non-zero strides ofLLin increasing order,
- •ifdjd_{j}is the current stride, anddid_{i}is the previously visited stride, appending - –(sj)(s_{j})ifsidi=djs_{i}d_{i}=d_{j}, or - –(djsidi,sj)\left(\frac{d_{j}}{s_{i}d_{i}},s_{j}\right)ifsidi<djs_{i}d_{i}<d_{j}, and
- •mappingsj↦sjs_{j}\mapsto s_{j}.
Example 3.1.2.7.
If
L=(128,128):(128,1),L=(128,128):(128,1),thenLLis tractable, and the standard representation ofLLis the tuple morphism
128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}fL{\lx@inpgf@ignorespaces f_{L}}
Example 3.1.2.8.
If
L=(2,2,2,2):(24,0,3,480),L=(2,2,2,2):(24,0,3,480),thenLLis tractable, and the standard representation ofLLis the tuple morphism
2{\lx@inpgf@ignorespaces 2}10{\lx@inpgf@ignorespaces 10}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}fL{\lx@inpgf@ignorespaces f_{L}}
Let’s justify that the tuple morphismfLf_{L}of3.1.2.5does, in fact, encode the layoutLL.
Lemma 3.1.2.9.
SupposeLLis a tractable flat layout, andf=fLf=f_{L}is the standard representation ofLL. Then the layout encoded byffis
Proof.
SupposeL=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is tractable, and let
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}be the standard representation ofLL. Clearly
𝗌𝗁𝖺𝗉𝖾(Lf)=(s1,…,sm)=𝗌𝗁𝖺𝗉𝖾(L).\mathsf{shape}(L_{f})=(s_{1},\dots,s_{m})=\mathsf{shape}(L).We need to check that𝗌𝗍𝗋𝗂𝖽𝖾(Lf)=𝗌𝗍𝗋𝗂𝖽𝖾(L)\mathsf{stride}(L_{f})=\mathsf{stride}(L). In other words, we need to check that for any1≤i≤m1\leq i\leq m, we have
di={0α(i)=∗∏j<α(i)tjα(i)≠∗.d_{i}=\begin{cases}0&\alpha(i)=*\\ \prod_{j<\alpha(i)}t_{j}&\alpha(i)\neq*.\end{cases}We borrow the notation of3.1.2.5. Ifα(i)=∗\alpha(i)=*, thenα′(i)=∗\alpha^{\prime}(i)=*, and soσ−1(i)≤k\sigma^{-1}(i)\leq k. This implies
di=dσ−1(i)′=0.d_{i}=d^{\prime}_{\sigma^{-1}(i)}=0.Suppose otherwise thatα(i)≠∗\alpha(i)\neq*. Thenα′(i)≠∗\alpha^{\prime}(i)\neq*, and sok+1≤σ−1(i)≤mk+1\leq\sigma^{-1}(i)\leq m. We compute
∏j<α(i)tj=∏j′<α′(i)tj′′≠1tj′′=∏j′<α′(i)tj′′=∏j′<2(σ−1(i)−k)tj′′\displaystyle\prod_{j<\alpha(i)}t_{j}=\prod_{\begin{subarray}{c}j^{\prime}<\alpha^{\prime}(i)\\ t_{j^{\prime}}^{\prime}\neq 1\end{subarray}}t_{j^{\prime}}^{\prime}=\prod_{j^{\prime}<\alpha^{\prime}(i)}t_{j^{\prime}}^{\prime}=\prod_{j^{\prime}<2(\sigma^{-1}(i)-k)}t_{j^{\prime}}^{\prime}=dk+1′⋅(∏v=1σ−1(i)−(k+1)sk+v′dk+v+1′sk+v′dk+v′)\displaystyle=d_{k+1}^{\prime}\cdot\left(\prod_{v=1}^{\sigma^{-1}(i)-(k+1)}s^{\prime}_{k+v}\dfrac{d^{\prime}_{k+v+1}}{s_{k+v}^{\prime}d_{k+v}^{\prime}}\right)=dσ−1(i)′\displaystyle=d_{\sigma^{-1}(i)}^{\prime}=di.\displaystyle=d_{i}.∎
We have proved that ifLLis a tractable flat layout, then there exists a tuple morphismffwhich encodesLL. Next, we prove the converse, which implies that tractable flat layouts are precisely the layouts encoded by tuple morphisms.
Proposition 3.1.2.10.
SupposeLLis a flat layout. Then there exists a tuple morphismffencodingLLif and only ifLLis tractable.
Proof.
First, supposeLLis a flat layout, andf:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism withLf=LL_{f}=L. We want to show thatLfL_{f}is tractable. Let
OPENL)=(s1′,…,sm′):(d1,…,dm)L)=(s_{1}^{\prime},\dots,s_{m}^{\prime}):(d_{1},\dots,d_{m})be the sorting ofLL, and suppose that1≤i<m1\leq i<m. We will argue thatdi=0d_{i}=0, orsi′dis_{i}^{\prime}d_{i}dividesdi+1d_{i+1}. Ifdi=0d_{i}=0, then we are done. Suppose otherwise thatdi≠0d_{i}\neq 0. Then
di=∏j<ktjd_{i}=\prod_{j<k}t_{j}for some1≤k≤n1\leq k\leq nwithsi′=tks_{i}^{\prime}=t_{k}. Sincedi+1≥did_{i+1}\geq d_{i}, we know thatdi+1≠0d_{i+1}\neq 0, sodi+1d_{i+1}has the form
di+1=∏j<ℓtjd_{i+1}=\prod_{j<\ell}t_{j}for some1≤ℓ≤n1\leq\ell\leq n. There are two cases to consider:
- •(Case 1) Ifℓ>k\ell>k, then di+1=∏j<ℓtj\displaystyle d_{i+1}=\prod_{j<\ell}t_{j}=(∏j≤ktj)(∏k<j<ℓtj)=si′di(∏k<j<ℓtj),\displaystyle=\left(\prod_{j\leq k}t_{j}\right)\left(\prod_{k<j<\ell}t_{j}\right)=s_{i}^{\prime}d_{i}\left(\prod_{k<j<\ell}t_{j}\right),sosi′dis_{i}^{\prime}d_{i}dividesdi+1d_{i+1}.
- •(Case 2) Ifℓ≤k\ell\leq k, then since ∏j<ℓtj=di+1≥di=∏j<ktj,\prod_{j<\ell}t_{j}=d_{i+1}\geq d_{i}=\prod_{j<k}t_{j},we must have tℓ=⋯=tk−1=1,t_{\ell}=\cdots=t_{k-1}=1,and In particular, we havesi+1′=tℓ=1s_{i+1}^{\prime}=t_{\ell}=1. But sinceOPENLf)L_{f})is sorted anddi+1=did_{i+1}=d_{i}, we havesi′≤si+1′=1s_{i}^{\prime}\leq s_{i+1}^{\prime}=1, sosi′=1s_{i}^{\prime}=1. We deduce that si′di=di+1,s_{i}^{\prime}d_{i}=d_{i+1},so in particular,si′dis_{i}^{\prime}d_{i}dividesdi+1d_{i+1}.
We conclude thatLLis tractable.
Next, suppose thatLLis tractable. Then we can takef=fLf=f_{L}to be the standard representation ofLL(see Construction3.1.2.5), in which case, by Lemma3.1.2.9, we haveL=LfL=L_{f}. ∎
Definition 3.1.2.12.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}f\scriptstyle{\lx@inpgf@ignorespaces f}is a tuple morphism. We sayffhasstandard formif the following conditions hold:
- 1.Ifn>1n>1, thenn∈𝖨𝗆𝖺𝗀𝖾(α)n\in\mathsf{Image}(\alpha).
- 2.If1≤j<n1\leq j<n, then j∉𝖨𝗆𝖺𝗀𝖾(α)⇒tj≠1, andj+1∈𝖨𝗆𝖺𝗀𝖾(α)j\notin\mathsf{Image}(\alpha)\quad\Rightarrow\quad\begin{matrix}t_{j}\neq 1\text{, and}\\ j+1\in\mathsf{Image}(\alpha)\end{matrix}
Example 3.1.2.13.
The tuple morphismsffof Remark3.1.2.11has standard form, whileggandhhdo not.
Example 3.1.2.14.
The tuple morphisms
64{\lx@inpgf@ignorespaces 64}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}128{\lx@inpgf@ignorespaces 128}512{\lx@inpgf@ignorespaces 512}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}64{\lx@inpgf@ignorespaces 64}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}3{\lx@inpgf@ignorespaces 3}f1{\lx@inpgf@ignorespaces f_{1}}f2{\lx@inpgf@ignorespaces f_{2}}f3{\lx@inpgf@ignorespaces f_{3}}have standard form, while the tuple morphisms
64{\lx@inpgf@ignorespaces 64}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}64{\lx@inpgf@ignorespaces 64}256{\lx@inpgf@ignorespaces 256}64{\lx@inpgf@ignorespaces 64}1{\lx@inpgf@ignorespaces 1}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}8{\lx@inpgf@ignorespaces 8}1{\lx@inpgf@ignorespaces 1}64{\lx@inpgf@ignorespaces 64}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}3{\lx@inpgf@ignorespaces 3}g1{\lx@inpgf@ignorespaces g_{1}}g2{\lx@inpgf@ignorespaces g_{2}}g3{\lx@inpgf@ignorespaces g_{3}}do not.
Example 3.1.2.15.
IfLLis a tractable layout, then by construction, the standard representationfLf_{L}ofLLhas standard form.
If we restrict to tuple morphisms of standard form, then there is almost a one-to-one correspondence with tractable layouts. However, there is one problematic case we need to exclude, as explicated in the following example.
Example 3.1.2.16.
Consider the tuple morphismsffandggshown below.
1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}Bothffandgghave standard form, and
Lf=(8,1,1):(1,8,8)=Lg.L_{f}=(8,1,1):(1,8,8)=L_{g}.This example illustrates that the presence of entries of the formsi=1s_{i}=1andα(i)≠∗\alpha(i)\neq*can lead to non-uniqueness of a representing tuple morphism of standard form. On the layout side, this corresponds to shape entriessi=1s_{i}=1with stridedi≠0d_{i}\neq 0. In order to exclude such pathological examples, we introduce the notion ofnon-degeneracy.
Definition 3.1.2.17.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a tuple morphism and
L=(s1,…,sm):(d1,…,dm)L=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout.
- 1.We sayffisnon-degenerateif si=1⇒α(i)=∗.s_{i}=1\quad\Rightarrow\quad\alpha(i)=*.
- 2.We sayLLisnon-degenerateif si=1⇒di=0.s_{i}=1\quad\Rightarrow\quad d_{i}=0.
Observation 3.1.2.18.
Ifffis a non-degenerate tuple morphism, then the layoutLfL_{f}encoded byffis non-degenerate. Conversely, ifLLis a non-degenerate flat layout, then the standard representationfLf_{L}ofLLis non-degenerate.
Observation 3.1.2.19.
Restricting to non-degenerate flat layouts is no real loss of generality. IfLLis an arbitrary flat layout, then𝖿𝗂𝗅𝗍𝖾𝗋(L)\mathsf{filter}(L)is a non-degenerate flat layout with the same coordinate function and layout function asLL.
The essential property of non-degenerate tuple morphisms of standard form is that they are characterized by the layouts which they encode. This is made precise as follows.
Lemma 3.1.2.20.
Supposeffandggare non-degenerate tuple morphisms of standard form. IfLf=LgL_{f}=L_{g}, thenf=gf=g.
Proof.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}and
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(u1,…,up){\lx@inpgf@ignorespaces(u_{1},\dots,u_{p})}g\scriptstyle{\lx@inpgf@ignorespaces g}β\scriptstyle{\lx@inpgf@ignorespaces\beta}are non-degenerate tuple morphisms of standard form with
Lf=(s1,…,sm):(d1,…,dm)=Lg.L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})=L_{g}.We want to show thatf=gf=g. First, we will argue that(t1,…,tn)=(u1,…,up)(t_{1},\dots,t_{n})=(u_{1},\dots,u_{p}). Let
X\displaystyle X={t1⋯tj∣1≤j≤n}\displaystyle=\{t_{1}\cdots t_{j}\mid 1\leq j\leq n\}Y\displaystyle Y={u1⋯uk∣1≤k≤p}\displaystyle=\{u_{1}\cdots u_{k}\mid 1\leq k\leq p\}denote the sets of prefix products of(t1,…,tn)(t_{1},\dots,t_{n})and(u1,…,up)(u_{1},\dots,u_{p}), respectively. We claimX=YX=Y, since each of these sets is equal to
Z={di,sidi∣1≤i≤manddi≠0}.Z=\{d_{i},s_{i}d_{i}\mid 1\leq i\leq m\text{ and }d_{i}\neq 0\}.Lets argue thatX=ZX=Z. Suppose1≤j≤n1\leq j\leq n. If there exists somei∈⟨m⟩i\in\langle m\ranglewithα(i)=j\alpha(i)=j, thent1⋯tj=sidit_{1}\cdots t_{j}=s_{i}d_{i}. On the other hand, ifjjis not in the image ofα\alpha, then sinceffhas standard form, there exists somei∈⟨m⟩i\in\langle m\ranglesuch thatα(i)=j+1\alpha(i)=j+1, in which caset1⋯tj=dit_{1}\cdots t_{j}=d_{i}. This proves thatX⊆ZX\subseteq Z. Conversely, if1≤i≤m1\leq i\leq manddi≠0d_{i}\neq 0, thendi=t1⋯tα(i)−1d_{i}=t_{1}\cdots t_{\alpha(i)-1}andsidi=t1⋯tα(i)s_{i}d_{i}=t_{1}\cdots t_{\alpha(i)}, which provesZ⊆XZ\subseteq X. We deduce thatX=ZX=Z. The same argument provesY=ZY=Z.
Sinceffandggare non-degenerate of standard form, we know that eachtjt_{j}and eachuku_{k}is greater than11, which implies
t1<t1t2<\displaystyle t_{1}<t_{1}t_{2}<⋯<t1⋯tn,\displaystyle\cdots<t_{1}\cdots t_{n},u1<u1u2<\displaystyle u_{1}<u_{1}u_{2}<⋯<u1⋯up,\displaystyle\cdots<u_{1}\cdots u_{p},and sinceX=YX=Y, it follows thatn=pn=p, andt1⋯tj=u1⋯ujt_{1}\cdots t_{j}=u_{1}\cdots u_{j}for each1≤j≤n1\leq j\leq n. We deduce that(t1,…,tn)=(u1,…,up)(t_{1},\dots,t_{n})=(u_{1},\dots,u_{p}).
Next, we need to argue thatα=β\alpha=\beta. Suppose for contradiction that there exists somei∈⟨m⟩i\in\langle m\ranglewithα(i)≠β(i)\alpha(i)\neq\beta(i). There are two cases to consider.
- •Ifα(i)=∗≠β(i)\alpha(i)=*\neq\beta(i), then 0=di=t1⋯tβ(i)−1,0=d_{i}=t_{1}\cdots t_{\beta(i)-1},a contradiction. The caseα(i)≠∗=β(i)\alpha(i)\neq*=\beta(i)is analogous.
- •Ifα(i)≠∗≠β(i)\alpha(i)\neq*\neq\beta(i), then without loss of generality we may assumeα(i)<β(j)\alpha(i)<\beta(j), in which case di=t1⋯tα(i)−1<t1⋯tβ(i)−1=di,d_{i}=t_{1}\cdots t_{\alpha(i)-1}<t_{1}\cdots t_{\beta(i)-1}=d_{i},a contradiction.
We deduce thatα=β\alpha=\beta, sof=gf=g. ∎
We are now ready to prove our correspondence theorem, which identifies non-degenerate tuple morphisms of standard form with non-degenerate tractable flat layouts.
Theorem 3.1.2.21.
The maps
f{\lx@inpgf@ignorespaces f}Lf{\lx@inpgf@ignorespaces L_{f}}{Non-degeneratetuple morphisms ofstandard form}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ \text{tuple morphisms of}\\ \text{standard form}\end{Bmatrix}}{Non-degeneratetractable flatlayouts}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ \text{tractable flat}\\ \text{layouts}\end{Bmatrix}}fL{\lx@inpgf@ignorespaces f_{L}}L{\lx@inpgf@ignorespaces L}of Constructions3.1.2.1and3.1.2.5determine a one-to-one correspondence between non-degenerate tuple morphisms of standard form, and non-degenerate tractable flat layouts.
Proof.
We want to show that the constructionsf↦Lff\mapsto L_{f}andL↦fLL\mapsto f_{L}are inverses, when restricted to tuple morphisms and layouts of the stated form. IfLLis a non-degenerate tractable flat layout, then by Lemma3.1.2.9we haveLfL=LL_{f_{L}}=L. Suppose next thatffis a non-degenerate tuple morphism of standard form andL=LfL=L_{f}is the layout encoded byff. SinceffandfLff_{L_{f}}are non-degenerate tuple morphisms of standard form, and the layouts encoded by these tuple morphsims are equal, it follows from Lemma3.1.2.20thatf=fLff=f_{L_{f}}. ∎
3.1.3Examples
In this section, we introduce some important families of tuple morphisms, and describe the flat layouts to which they give rise.
Example 3.1.3.1(Identity morphisms).
We say a tuple morphismffis anidentity morphismiff=𝗂𝖽Sf=\mathsf{id}_{S}for some tupleSS. Iff=𝗂𝖽Sf=\mathsf{id}_{S}is an identity morphism, thenLfL_{f}is the column-major layout with shapeSS. For instance, here is an example of an identity morphismfftogether with its associated layoutLfL_{f}.
4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(2,2,2,4,4):(1,2,4,8,32){\lx@inpgf@ignorespaces L_{f}=(2,2,2,4,4):(1,2,4,8,32)}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}
Example 3.1.3.2(Isomorphisms).
A tuple morphismf:S→Tf:S\to Tis anisomorphismif there is a tuple morphismg:T→Sg:T\to Ssuch thatg∘f=𝗂𝖽Sg\circ f=\mathsf{id}_{S}andf∘g=𝗂𝖽Tf\circ g=\mathsf{id}_{T}. Ifffis an isomorphism, then its associated layoutLfL_{f}is compact. For instance, here is an isomorphismfftogether with its associated layoutLfL_{f}.
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(2,2,2,4,4):(2,1,64,4,16){\lx@inpgf@ignorespaces L_{f}=(2,2,2,4,4):(2,1,64,4,16)}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}.
Observation 3.1.3.3.
Note that if a tuple morphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is an isomorphism, thenα:⟨m⟩∗→⟨m⟩∗\alpha:\langle m\rangle_{*}\to\langle m\rangle_{*}is a bijection, and soα∣⟨m⟩∈Σm\alpha\mid_{\langle m\rangle}\in\Sigma_{m}is a permutation. Conversely, ifσ∈Σm\sigma\in\Sigma_{m}is a permutation, and(s1,…,sm)(s_{1},\dots,s_{m})is a tuple of positive integers, then we may construct the isomorphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(sσ(1),…,sσ(m)).{\lx@inpgf@ignorespaces(s_{\sigma(1)},\dots,s_{\sigma(m)}).}f\scriptstyle{\lx@inpgf@ignorespaces f}σ∗\scriptstyle{\lx@inpgf@ignorespaces\sigma_{*}}We conclude that there is a one-to-one correspondence between tuple isomorphismsffwith domain(s1,…,sm)(s_{1},\dots,s_{m}), and permutations inΣm\Sigma_{m}.
Example 3.1.3.4(Projections).
SupposeS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a shape, and suppose
{i1<⋯<ir}⊂⟨m⟩\{i_{1}<\dots<i_{r}\}\subset\langle m\rangleis some subset. Let
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(si1,…,sir){\lx@inpgf@ignorespaces(s_{i_{1}},\dots,s_{i_{r}})}p\scriptstyle{\lx@inpgf@ignorespaces p}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}be the tuple morphism lying over the mapα\alphawith
α(x)={jx=ij∗else.\alpha(x)=\begin{cases}j&x=i_{j}\\ *&\text{else.}\end{cases}We callpptheprojection of(s1,…,sm)(s_{1},\dots,s_{m})onto(si1,…,sir)(s_{i_{1}},\dots,s_{i_{r}}). The layout encoded byppis
Lp=(s1,…,sm):(d1,…,dm),L_{p}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),where
di={si1⋯sij−1i=ijfor some1≤j≤r0otherwise.d_{i}=\begin{cases}s_{i_{1}}\cdots s_{i_{j-1}}&i=i_{j}\text{ for some }1\leq j\leq r\\ 0&\text{otherwise.}\\ \end{cases}For instance, here is a projectionppof(64,64,3,8)(64,64,3,8)onto(64,3)(64,3), together with its associated layout.
8{\lx@inpgf@ignorespaces 8}3{\lx@inpgf@ignorespaces 3}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lp=(64,64,3,8):(1,0,64,0){\lx@inpgf@ignorespaces L_{p}=(64,64,3,8):(1,0,64,0)}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}p{\lx@inpgf@ignorespaces p}
Example 3.1.3.5(Dilations).
SupposeS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a shape, and supposec1,…,cmc_{1},\dots,c_{m}are positive integers. The tuple morphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(c1,s1,…,cm,sm){\lx@inpgf@ignorespaces(c_{1},s_{1},\dots,c_{m},s_{m})}f\scriptstyle{\lx@inpgf@ignorespaces f}(∗,2,∗,4,…,∗,2m)\scriptstyle{\lx@inpgf@ignorespaces(*{,}2{,}*{,}4{,}\dots{,}*{,}2m)}is called thedilation of(s1,…,sm)(s_{1},\dots,s_{m})by(c1,…,cm)(c_{1},\dots,c_{m}). The layoutLfL_{f}associated to this morphism isLf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}), where
di=∏j<icjsj.d_{i}=\prod_{j<i}c_{j}s_{j}.For instance, here is the dilationffof(512,512)(512,512)by(2,4)(2,4), together with its associated layout.
512{\lx@inpgf@ignorespaces 512}4{\lx@inpgf@ignorespaces 4}512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(512,512):(2,4096){\lx@inpgf@ignorespaces L_{f}=(512,512):(2,4096)}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}
Example 3.1.3.6(Expansions).
SupposeS=(s1,…,sm)S=(s_{1},\dots,s_{m})is a tuple of positive integers, and suppose1≤i≤m′1\leq i\leq m^{\prime}, so thatS′=(s1,…,sm′)S^{\prime}=(s_{1},\dots,s_{m^{\prime}})dividesSS. Then the tuple morphism
(s1,…,sm′){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m^{\prime}})}(s1,…,sm′,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m^{\prime}},\dots,s_{m})}e\scriptstyle{\lx@inpgf@ignorespaces e}(1,2,…,m′)\scriptstyle{\lx@inpgf@ignorespaces(1{,}2{,}\dots{,}m^{\prime})}is called theexpansionofS′S^{\prime}toSS. The layout encoded byeeis the column-major layout with shape(s1,…,sm′)(s_{1},\dots,s_{m^{\prime}}). For instance, here is the expansion ofS′=(4,4)S^{\prime}=(4,4)toS=(4,4,8,8)S=(4,4,8,8).
8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Le=(4,4):(1,4){\lx@inpgf@ignorespaces L_{e}=(4,4):(1,4)}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}e{\lx@inpgf@ignorespaces e}An important property of expansions is that iff:S→Tf:S\to Tis any tuple morphism ande:T→T′e:T\to T^{\prime}is an expansion, then
Le∘f=Lf.L_{e\circ f}=L_{f}.In other words, post-composingffwith an expansion does not change the layout encoded byff.
Example 3.1.3.7(Restrictions).
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a tuple morphism, and suppose
I={i1<⋯<ir}⊂⟨m⟩I=\{i_{1}<\cdots<i_{r}\}\subset\langle m\rangleis a subset of indices. Then the tuple morphism
(si1,…,sir){\lx@inpgf@ignorespaces(s_{i_{1}},\dots,s_{i_{r}})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f∣I\scriptstyle{\lx@inpgf@ignorespaces f\mid_{I}}α∘ι\scriptstyle{\lx@inpgf@ignorespaces\alpha\circ\iota}is called therestriction offftoII. If the layout encoded byffis
Lf=(s1,…,sm):(d1,…,dm),L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),then the layout encoded byf∣If\mid_{I}is
Lf∣I=(si1,…,sir):(di1,…,dir).L_{f\mid_{I}}=(s_{i_{1}},\dots,s_{i_{r}}):(d_{i_{1}},\dots,d_{i_{r}}).For instance, here is the restrictionf∣If\mid_{I}of a tuple morphismff, whereI={2,4}I=\{2,4\}.
4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(2,16,8,4):(0,8,1,128){\lx@inpgf@ignorespaces L_{f}=(2,16,8,4):(0,8,1,128)}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}16{\lx@inpgf@ignorespaces 16}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf∣I=(16,4):(8,128){\lx@inpgf@ignorespaces L_{f\mid_{I}}=(16,4):(8,128)}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}f∣I{\lx@inpgf@ignorespaces f\mid_{I}}
Example 3.1.3.8(Entry inclusions).
An important special case of the previous construction is as follows. Iff:(s1,…,sm)→(t1,…,tm)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{m})is a tuple morphism and1≤i≤m1\leq i\leq m, then theiith entryfif_{i}offfis
(si){\lx@inpgf@ignorespaces(s_{i})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}fi\scriptstyle{\lx@inpgf@ignorespaces f_{i}}(i)\scriptstyle{\lx@inpgf@ignorespaces(i)}If the layout encoded byffis
Lf=(s1,…,sm):(d1,…,dm),L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),then the layout encoded byfif_{i}is
Lfi=(si):(di).L_{f_{i}}=(s_{i}):(d_{i}).For instance, here is a tuple morphismff, and its fourth entryf4f_{4}.
4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(2,16,8,4):(0,8,1,128){\lx@inpgf@ignorespaces L_{f}=(2,16,8,4):(0,8,1,128)}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}4{\lx@inpgf@ignorespaces 4}16{\lx@inpgf@ignorespaces 16}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf4=(4):(128){\lx@inpgf@ignorespaces L_{f_{4}}=(4):(128)}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}f4{\lx@inpgf@ignorespaces f_{4}}
Example 3.1.3.10(Factorizations).
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a tuple morphism, and suppose
J={j1<⋯<jℓ}⊂⟨n⟩J=\{j_{1}<\cdots<j_{\ell}\}\subset\langle n\rangleis a subset such that𝖨𝗆𝖺𝗀𝖾(α)⊆J∪{∗}\mathsf{Image}(\alpha)\subseteq J\cup\{*\}. If we writeι:⟨ℓ⟩∗→⟨n⟩∗\iota:\langle\ell\rangle_{*}\to\langle n\rangle_{*}for the mapk↦jkk\mapsto j_{k}, thenα\alphafactors asα=ι∘α¯\alpha=\iota\circ\bar{\alpha}for a unique mapα¯:⟨m⟩∗→⟨ℓ⟩∗\bar{\alpha}:\langle m\rangle_{*}\to\langle\ell\rangle_{*}, and we define thefactorization offfthroughJJto be the tuple morphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(tj1,…,tjℓ).{\lx@inpgf@ignorespaces(t_{j_{1}},\dots,t_{j_{\ell}}).}f∣J\scriptstyle{\lx@inpgf@ignorespaces f\mid^{J}}α¯\scriptstyle{\lx@inpgf@ignorespaces\bar{\alpha}}If the layout encoded byffis
Lf=(s1,…,sm):(d1,…,dm),L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}),then the layout encoded byf∣Jf\mid^{J}is
Lf∣J=(s1,…,sm):(d1′,…,dm′),L_{f\mid^{J}}=(s_{1},\dots,s_{m}):(d_{1}^{\prime},\dots,d_{m}^{\prime}),where
di′=di(∏k<α(i)andk∉Jtj).d_{i}^{\prime}=\dfrac{d_{i}}{\left(\displaystyle\prod_{k<\alpha(i)\text{ and }k\notin J}t_{j}\right)}.For instance, here is the factorizationf∣Jf\mid^{J}of a tuple morphismff, whereJ={2,4,5}J=\{2,4,5\}.
10{\lx@inpgf@ignorespaces 10}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf=(8,8):(32,2){\lx@inpgf@ignorespaces L_{f}=(8,8):(32,2)}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}10{\lx@inpgf@ignorespaces 10}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}↝{\lx@inpgf@ignorespaces\rightsquigarrow}Lf∣J=(8,8):(8,1){\lx@inpgf@ignorespaces L_{f\mid^{J}}=(8,8):(8,1)}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f∣J{\lx@inpgf@ignorespaces f\mid^{J}}
3.1.4Realization of tuple morphisms
As we have seen, a tuple morphismf:S→Tf:S\to Tencodes a flat layoutLfL_{f}. In this section, we will construct a realization functor
|⋅|:𝗧𝘂𝗽𝗹𝗲→𝗙𝗶𝗻𝗦𝗲𝘁.|\cdot|:{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{FinSet}}}.which makes this encoding explicit. The realization functor|⋅||\cdot|sends a tuple morphismffto the layout function|f||f|ofLfL_{f}. In order to construct our realization functor|⋅||\cdot|, we first construct an auxiliary functor
F:𝗧𝘂𝗽𝗹𝗲→𝗙𝗶𝗻𝗦𝗲𝘁F:{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{FinSet}}}which we will use in our construction.
Construction 3.1.4.1.
We define a functor
F:𝗧𝘂𝗽𝗹𝗲→𝗙𝗶𝗻𝗦𝗲𝘁F:{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{FinSet}}}as follows.
- •For an objectS=(s1,…,sm)S=(s_{1},\dots,s_{m})in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, we define FS=[0,S)=∏i=1m[0,si).FS=[0,S)=\prod_{i=1}^{m}[0,s_{i}).
- •For a morphismf:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}lying overα\alpha, we defineFfFfto be the map [0,S){\lx@inpgf@ignorespaces{[}0,S{)}}[0,T){\lx@inpgf@ignorespaces{[}0,T{)}}Ff\scriptstyle{\lx@inpgf@ignorespaces Ff}given by (Ff)(x1,…,xm)=(y1,…,yn)(Ff)(x_{1},\dots,x_{m})=(y_{1},\dots,y_{n})where yj={xithere exists1≤i≤mwithα(i)=j,0else.y_{j}=\begin{cases}x_{i}&\text{there exists }1\leq i\leq m\text{ with }\alpha(i)=j,\\ 0&\text{else}.\\ \end{cases}
One may easily verify thatF(g∘f)=Fg∘FfF(g\circ f)=Fg\circ FfandF𝗂𝖽S=𝗂𝖽FSF\mathsf{id}_{S}=\mathsf{id}_{FS}, soFFis in fact a functor.
Example 3.1.4.2.
Supposef:(4,4)→(4,4,4)f:(4,4)\to(4,4,4)is the tuple morphism lying overα=(1,3)\alpha=(1,3). Then
Ff:[0,(4,4))→[0,(4,4,4))Ff:[0,(4,4))\to[0,(4,4,4))is given by
(Ff)(x1,x2)=(x1,0,x2).(Ff)(x_{1},x_{2})=(x_{1},0,x_{2}).
Example 3.1.4.3.
Supposeg:(3,256,256,512)→(3,256,256)g:(3,256,256,512)\to(3,256,256)is the tuple morphism lying overβ=(∗,3,2,∗)\beta=(*,3,2,*). Then
Fg:[0,(3,256,256,512))→[0,(3,256,256))Fg:[0,(3,256,256,512))\to[0,(3,256,256))is given by
(Fg)(x1,x2,x3,x4)=(0,x3,x2).(Fg)(x_{1},x_{2},x_{3},x_{4})=(0,x_{3},x_{2}).
Construction 3.1.4.4.
We define a functor
|⋅|:𝗧𝘂𝗽𝗹𝗲→𝗙𝗶𝗻𝗦𝗲𝘁|\cdot|:{\boldsymbol{\mathsf{Tuple}}}\to{\boldsymbol{\mathsf{FinSet}}}as follows.
- •For an objectS=(s1,…,sm)S=(s_{1},\dots,s_{m})in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, we define |S|=[0,𝗌𝗂𝗓𝖾(S))={0,1,…,𝗌𝗂𝗓𝖾(S)−1}.|S|=[0,\mathsf{size}(S))=\{0,1,\dots,\mathsf{size}(S)-1\}.
- •For a tuple morphismf:S→Tf:S\to T, we define |f|=𝖼𝗈𝗅𝖾𝗑T∘Ff∘𝖼𝗈𝗅𝖾𝗑S−1|f|=\mathsf{colex}_{T}\circ Ff\circ\mathsf{colex}_{S}^{-1}(recallDefinition2.1.2.18).
Iff:S→Tf:S\to Tandg:T→Ug:T\to Uare composable tuple morphisms then
|g∘f|\displaystyle|g\circ f|=𝖼𝗈𝗅𝖾𝗑U∘F(g∘f)∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{U}\circ F(g\circ f)\circ\mathsf{colex}_{S}^{-1}=𝖼𝗈𝗅𝖾𝗑U∘Fg∘Ff∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{U}\circ Fg\circ Ff\circ\mathsf{colex}_{S}^{-1}=𝖼𝗈𝗅𝖾𝗑U∘Fg∘𝖼𝗈𝗅𝖾𝗑T−1∘𝖼𝗈𝗅𝖾𝗑T∘Ff∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{U}\circ Fg\circ\mathsf{colex}_{T}^{-1}\circ\mathsf{colex}_{T}\circ Ff\circ\mathsf{colex}_{S}^{-1}=|g|∘|f|\displaystyle=|g|\circ|f|and iff=𝗂𝖽Sf=\mathsf{id}_{S}is an identity morphism, then
|𝗂𝖽S|\displaystyle|\mathsf{id}_{S}|=𝖼𝗈𝗅𝖾𝗑S∘F𝗂𝖽S∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{S}\circ F\mathsf{id}_{S}\circ\mathsf{colex}_{S}^{-1}=𝖼𝗈𝗅𝖾𝗑S∘𝗂𝖽S∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{S}\circ\mathsf{id}_{S}\circ\mathsf{colex}_{S}^{-1}=𝖼𝗈𝗅𝖾𝗑S∘𝖼𝗈𝗅𝖾𝗑S−1\displaystyle=\mathsf{colex}_{S}\circ\mathsf{colex}_{S}^{-1}=𝗂𝖽|S|,\displaystyle=\mathsf{id}_{|S|}~,so|⋅||\cdot|does in fact specify a functor. Next, we observe that for a morphismffin𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, the map|f||f|is the layout function ofLfL_{f}. This allows us to easily deduce that composition of morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}is compatible with composition of flat layouts (see Corollary3.1.4.6).
Lemma 3.1.4.5.
Iff:S→Tf:S\to Tis a tuple morphism, then the realization|f||f|offfis the layout function ofLfL_{f}:
|f|=ΦLf𝗌𝗂𝗓𝖾(T)|f|=\Phi_{L_{f}}^{\mathsf{size}(T)}
Proof.
LetS=(s1,…,sm)S=(s_{1},\dots,s_{m}),T=(t1,…,tn)T=(t_{1},\dots,t_{n}), and let
Lf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})denote the layout associated toff, whose stridesdid_{i}are defined by the formula
di={0α(i)=∗∏j<α(i)tjelse.d_{i}=\begin{cases}0&\alpha(i)=*\\ \prod_{j<\alpha(i)}t_{j}&\text{else.}\end{cases}By precomposing with𝖼𝗈𝗅𝖾𝗑S:∏i=1m[0,si)→[0,𝗌𝗂𝗓𝖾(S))\mathsf{colex}_{S}:\prod_{i=1}^{m}[0,s_{i})\to[0,\mathsf{size}(S)), it suffices to prove that for any(x1,…,xm)∈∏i=1m[0,si)(x_{1},\dots,x_{m})\in\prod_{i=1}^{m}[0,s_{i}), we have
(𝖼𝗈𝗅𝖾𝗑T∘Ff)(x1,…,xm)=(x1,…,xm)⋅(d1,…,dm).(\mathsf{colex}_{T}\circ Ff)(x_{1},\dots,x_{m})=(x_{1},\dots,x_{m})\cdot(d_{1},\dots,d_{m}).For a general input(x1,…,xm)∈∏i=1m[0,si)(x_{1},\dots,x_{m})\in\prod_{i=1}^{m}[0,s_{i}), we have
(Ff)(x1,…,xm)=(y1,…,yn)(Ff)(x_{1},\dots,x_{m})=(y_{1},\dots,y_{n})whereyjy_{j}is equal toxix_{i}ifα(i)=j\alpha(i)=j, and00otherwise. It follows that
(𝖼𝗈𝗅𝖾𝗑T∘Ff)(x1,…,xm)\displaystyle(\mathsf{colex}_{T}\circ Ff)(x_{1},\dots,x_{m})=(y1,⋯,yn)⋅(1,t1,…,t1⋯tn−1)\displaystyle=(y_{1},\cdots,y_{n})\cdot(1,t_{1},\dots,t_{1}\cdots t_{n-1})=∑j=1nyj⋅t1⋯tj−1\displaystyle=\sum_{j=1}^{n}y_{j}\cdot t_{1}\cdots t_{j-1}=∑i=1mxidi\displaystyle=\sum_{i=1}^{m}x_{i}d_{i}=(x1,…,xm)⋅(d1,…,dm),\displaystyle=(x_{1},\dots,x_{m})\cdot(d_{1},\dots,d_{m}),as desired. ∎
Corollary 3.1.4.6.
Ifffandggare non-degenerate composable tuple morphisms, then
Lg∘f=Lg∘LfL_{g\circ f}=L_{g}\circ L_{f}
Proof.
Supposef:S→Tf:S\to Tandg:T→Ug:T\to Uare morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}lying overα\alphaandβ\beta, respectively. WriteS=(s1,…,sm)S=(s_{1},\dots,s_{m})andT=(t1,…,tn)T=(t_{1},\dots,t_{n}). We need to check that
- 1.𝗌𝗁𝖺𝗉𝖾(Lg∘f)\mathsf{shape}(L_{g\circ f})refines𝗌𝗁𝖺𝗉𝖾(Lf)\mathsf{shape}(L_{f}): This holds since the shape ofLfL_{f}andLg∘fL_{g\circ f}are both equal toSS.
- 2.Lg∘fL_{g\circ f}is coalesced over𝗌𝗁𝖺𝗉𝖾(Lf)\mathsf{shape}(L_{f}): This holds since the tuple morphismg∘fg\circ fis non-degenerate, hence so is the layoutLg∘fL_{g\circ f}.
- 3.ΦLg∘f=ΦLg∘ΦLf𝗌𝗂𝗓𝖾(Lg)\Phi_{L_{g\circ f}}=\Phi_{L_{g}}\circ\Phi_{L_{f}}^{\mathsf{size}(L_{g})}: Using Lemma3.1.4.5, we have ΦLg∘f𝗌𝗂𝗓𝖾(U)\displaystyle\Phi_{L_{g\circ f}}^{\mathsf{size}(U)}=|g∘f|\displaystyle=|g\circ f|=|g|∘|f|\displaystyle=|g|\circ|f|=ΦLg𝗌𝗂𝗓𝖾(U)∘ΦLf𝗌𝗂𝗓𝖾(T).\displaystyle=\Phi_{L_{g}}^{\mathsf{size}(U)}\circ\Phi_{L_{f}}^{\mathsf{size}(T)}.and by postcomposing with the inclusion[0,𝗌𝗂𝗓𝖾(U))⊂ℤ[0,\mathsf{size}(U))\subset\mathbb{Z}, and observing that𝗌𝗂𝗓𝖾(T)=𝗌𝗂𝗓𝖾(Lg)\mathsf{size}(T)=\mathsf{size}(L_{g}), the result follows.
∎
3.1.5Operations on tuple morphisms
Our next goal is to develop an “algebra of tuple morphisms”, which includes operations such ascoalesce,complement,composition,flat division, andflat products. We will prove that each of these operations is compatible with a corresponding operation on flat layouts.
3.1.5.1Sum
The sumf⊕gf\oplus gof tuple morphismsffandggis obtained by concatenating the domains and codomains offfandgg. In order to define this operations precisely, we first define a corresponding operation on morphisms in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}.
Definition 3.1.5.1.
Supposeα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}andβ:⟨p⟩∗→⟨q⟩∗\beta:\langle p\rangle_{*}\to\langle q\rangle_{*}are morphisms in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}. We define thesumofα\alphaandβ\betato be the morphism
α⊕β:⟨m+p⟩∗→⟨n+q⟩∗\alpha\oplus\beta:\langle m+p\rangle_{*}\to\langle n+q\rangle_{*}given by
(α⊕β)(x)={α(x)1≤x≤mn+β(x−m)m+1≤x≤m+p∗x=∗.(\alpha\oplus\beta)(x)=\begin{cases}\alpha(x)&1\leq x\leq m\\ n+\beta(x-m)&m+1\leq x\leq m+p\\ *&x=*.\end{cases}This operation is associative, so we can consider the sumα1⊕⋯⊕αk\alpha_{1}\oplus\cdots\oplus\alpha_{k}for any finite collection of morphismsα1,…,αk\alpha_{1},\dots,\alpha_{k}in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}.
Now we can define the sum of morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}.
Definition 3.1.5.3.
Supposef:S→Tf:S\to Tandg:U→Vg:U\to Vare tuple morphisms lying overα\alphaandβ\beta, respectively. We define thesumofffandggto be the tuple morphism
f⊕g:S⋆U→T⋆Vf\oplus g:S\star U\to T\star Vlying overα⊕β\alpha\oplus\beta. This operation is associative, so we can consider the sumf1⊕⋯⊕fkf_{1}\oplus\cdots\oplus f_{k}for any finite collection of morphismsf1,…,fkf_{1},\dots,f_{k}in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}.
Example 3.1.5.4.
Here is an example of the sumf⊕gf\oplus gof tuple morphismsffandgg.
4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}f⊕g{\lx@inpgf@ignorespaces f\oplus g}
Example 3.1.5.5.
Here is another example of the sumf⊕gf\oplus gof tuple morphismsffandgg.
64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}512{\lx@inpgf@ignorespaces 512}256{\lx@inpgf@ignorespaces 256}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}256{\lx@inpgf@ignorespaces 256}512{\lx@inpgf@ignorespaces 512}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}512{\lx@inpgf@ignorespaces 512}256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}256{\lx@inpgf@ignorespaces 256}512{\lx@inpgf@ignorespaces 512}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}f⊕g{\lx@inpgf@ignorespaces f\oplus g}
3.1.5.2Squeeze
It is often the case that we want to remove any instances of the integer11from our tuples. This is accomplished by thesqueezefunctor.
Definition 3.1.5.7.
We define a functor
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗌𝗊𝗎𝖾𝖾𝗓𝖾(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{squeeze}(-)}as follows. IfS=(s1,…,sm)S=(s_{1},\dots,s_{m})is an object in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, we define
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(S)=(si1,…,sik)\mathsf{squeeze}(S)=(s_{i_{1}},\dots,s_{i_{k}})where{i1<⋯<ik}⊂⟨m⟩\{i_{1}<\dots<i_{k}\}\subset\langle m\rangleare the indices withsij≠1s_{i_{j}}\neq 1. Iff:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism, we define
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f):𝗌𝗊𝗎𝖾𝖾𝗓𝖾(S)→𝗌𝗊𝗎𝖾𝖾𝗓𝖾(T)\mathsf{squeeze}(f):\mathsf{squeeze}(S)\to\mathsf{squeeze}(T)to be the tuple morphism
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)=(f∣I)∣J\mathsf{squeeze}(f)=(f\mid_{I})\mid^{J}wheref∣If\mid_{I}is the restriction offfto
I={i∈⟨m⟩∣si≠1}I=\{i\in\langle m\rangle\mid s_{i}\neq 1\}as in Definition3.1.3.7, and where(f∣I)∣J(f\mid_{I})\mid^{J}is be the factorization off∣If\mid_{I}through
J={j∈⟨n⟩∣tj≠1},J=\{j\in\langle n\rangle\mid t_{j}\neq 1\},as in Definition3.1.3.10.
Example 3.1.5.8.
Here is an example of a morphismffand the corresponding morphism𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)\mathsf{squeeze}(f).
256{\lx@inpgf@ignorespaces 256}256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}1{\lx@inpgf@ignorespaces 1}128{\lx@inpgf@ignorespaces 128}1{\lx@inpgf@ignorespaces 1}32{\lx@inpgf@ignorespaces 32}256{\lx@inpgf@ignorespaces 256}32{\lx@inpgf@ignorespaces 32}8{\lx@inpgf@ignorespaces 8}32{\lx@inpgf@ignorespaces 32}↝{\lx@inpgf@ignorespaces\rightsquigarrow}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}1{\lx@inpgf@ignorespaces 1}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f){\lx@inpgf@ignorespaces\mathclap{\mathsf{squeeze}(f)}}
Example 3.1.5.9.
Iff:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism, then
f=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)⇔nosi,tjis equal to1.f=\mathsf{squeeze}(f)\hskip 14.45377pt\Leftrightarrow\hskip 14.45377pt\text{no }s_{i}\text{, }t_{j}\text{ is equal to }1.
Proposition 3.1.5.10.
Ifffis a tuple morphism, then
L𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(Lf).L_{\mathsf{squeeze}(f)}=\mathsf{squeeze}(L_{f}).
Proof.
Supposef:(s1,…,sm)→(t1,…,tm)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{m})is a tuple morphism, and let
Lf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})be the flat layout associated toff. LetI={i1<⋯<im′}⊂⟨m⟩I=\{i_{1}<\cdots<i_{m^{\prime}}\}\subset\langle m\rangledenote the subset of indices withsik≠1s_{i_{k}}\neq 1. Then
Lf∣I\displaystyle L_{f\mid_{I}}=(si1,…,sik):(di1,…,dik)\displaystyle=(s_{i_{1}},\dots,s_{i_{k}}):(d_{i_{1}},\dots,d_{i_{k}})=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(Lf).\displaystyle=\mathsf{squeeze}(L_{f}). LetJ={j1<⋯<jn′}⊂⟨n⟩J=\{j_{1}<\dots<j_{n^{\prime}}\}\subset\langle n\rangledenote the subset of indices withtjk≠1t_{j_{k}}\neq 1, so that𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)=(f∣I)∣J\mathsf{squeeze}(f)=\left(f\mid_{I}\right)\mid^{J}. Letβ\betadenote the map over which𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)\mathsf{squeeze}(f)lies. Then
L𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)=L(f∣I)∣J\displaystyle L_{\mathsf{squeeze}(f)}=L_{\left(f\mid_{I}\right)\mid^{J}}=(si1,…,sik):(di1′,…,dik′)\displaystyle=(s_{i_{1}},\dots,s_{i_{k}}):(d_{i_{1}}^{\prime},\dots,d_{i_{k}}^{\prime})where
dik′\displaystyle d_{i_{k}}^{\prime}=dik(∏ℓ<β(k)andℓ∉Jtℓ)\displaystyle=\dfrac{d_{i_{k}}}{\left(\displaystyle\prod_{\ell<\beta(k)\text{ and }\ell\notin J}t_{\ell}\right)}=dik\displaystyle=d_{i_{k}}sincetℓ=1t_{\ell}=1for anyℓ∉J\ell\notin J. We conclude that
L𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)\displaystyle L_{\mathsf{squeeze}(f)}=(si1,…,sik):(di1,…,dik)\displaystyle=(s_{i_{1}},\dots,s_{i_{k}}):(d_{i_{1}},\dots,d_{i_{k}})=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(Lf).\displaystyle=\mathsf{squeeze}(L_{f}).∎
Observation 3.1.5.11.
Ifffis a tuple morphism, then
𝗌𝗊𝗎𝖾𝖾𝗓𝖾(𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f))=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f),\mathsf{squeeze}(\mathsf{squeeze}(f))=\mathsf{squeeze}(f),so
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗌𝗊𝗎𝖾𝖾𝗓𝖾(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{squeeze}(-)}is an idempotent functor.
3.1.5.3Sort
The sort operationOPENf↦f)f\mapsto f)permutes the domain offfso that the resulting morphism issorted, in the following sense.
Definition 3.1.5.12.
We say a tuple morphism
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}issortedif for any1≤i,j≤m1\leq i,j\leq m, the following conditions hold.
- 1.Ifα(i)=∗≠α(j)\alpha(i)=*\neq\alpha(j), theni<ji<j.
- 2.Ifα(i)=∗=α(j)\alpha(i)=*=\alpha(j), then i≤j⇒si≤sj.i\leq j\quad\Rightarrow\quad s_{i}\leq s_{j}.
- 3.Ifα(i)≠∗≠α(j)\alpha(i)\neq*\neq\alpha(j), then i≤j⇒α(i)≤α(j).i\leq j\quad\Rightarrow\quad\alpha(i)\leq\alpha(j).
Example 3.1.5.13.
The morphismsf1f_{1},f2f_{2}, andf3f_{3}shown below
4{\lx@inpgf@ignorespaces 4}60{\lx@inpgf@ignorespaces 60}60{\lx@inpgf@ignorespaces 60}128{\lx@inpgf@ignorespaces 128}4{\lx@inpgf@ignorespaces 4}1{\lx@inpgf@ignorespaces 1}20{\lx@inpgf@ignorespaces 20}2{\lx@inpgf@ignorespaces 2}512{\lx@inpgf@ignorespaces 512}128{\lx@inpgf@ignorespaces 128}1{\lx@inpgf@ignorespaces 1}8{\lx@inpgf@ignorespaces 8}32{\lx@inpgf@ignorespaces 32}20{\lx@inpgf@ignorespaces 20}3{\lx@inpgf@ignorespaces 3}512{\lx@inpgf@ignorespaces 512}1{\lx@inpgf@ignorespaces 1}64{\lx@inpgf@ignorespaces 64}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}f1{\lx@inpgf@ignorespaces f_{1}}f2{\lx@inpgf@ignorespaces f_{2}}f3{\lx@inpgf@ignorespaces f_{3}}are sorted, while the morphismsg1g_{1},g2g_{2}, andg3g_{3}shown below
512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}1{\lx@inpgf@ignorespaces 1}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}24{\lx@inpgf@ignorespaces 24}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}8{\lx@inpgf@ignorespaces 8}64{\lx@inpgf@ignorespaces 64}24{\lx@inpgf@ignorespaces 24}16{\lx@inpgf@ignorespaces 16}g1{\lx@inpgf@ignorespaces g_{1}}g2{\lx@inpgf@ignorespaces g_{2}}g3{\lx@inpgf@ignorespaces g_{3}}are not sorted. The morphismsg1g_{1},g2g_{2}, andg3g_{3}violate conditions33,11, and22, respectively.
Proposition 3.1.5.14.
Ifffis a sorted tuple morphism, then the flat layoutLfL_{f}is sorted.
Proof.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is sorted, and consider the layout
Lf=(s1,…,sm):(d1,…,dm).L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Suppose1≤i<m1\leq i<m. We want to show thatdi<di+1d_{i}<d_{i+1}, ordi=di+1d_{i}=d_{i+1}andsi≤si+1s_{i}\leq s_{i+1}. There are two cases to consider.
- •(Case 1) Suppose thatα(i)=∗\alpha(i)=*, so thatdi=0d_{i}=0. Ifα(i+1)=∗\alpha(i+1)=*, thendi+1=0d_{i+1}=0and sinceffis sorted we havesi≤si+1s_{i}\leq s_{i+1}. Ifα(i+1)≠∗\alpha(i+1)\neq*, thendi+1≥1>0=did_{i+1}\geq 1>0=d_{i}.
- •(Case 2) Suppose thatα(i)≠∗\alpha(i)\neq*, in which caseα(i+1)≠∗\alpha(i+1)\neq*andα(i)<α(i+1)\alpha(i)<\alpha(i+1). Then di=∏j<α(i)tj≤∏j<α(i+1)=di+1,d_{i}=\prod_{j<\alpha(i)}t_{j}\leq\prod_{j<\alpha(i+1)}=d_{i+1},where equality holds only ifsi=tα(i)=1s_{i}=t_{\alpha(i)}=1, which impliessi≤si+1s_{i}\leq s_{i+1}.
We conclude thatLfL_{f}is sorted. ∎
Next, we define ourOPEN−)-)operation on𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}. Ifffis a tuple morphism, thenOPENf)f)will be obtained by precomposingffwith an appropriate permutationgg.
Construction 3.1.5.15.
Suppose
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn){\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a tuple morphism. We define a permutationσ∈Σm\sigma\in\Sigma_{m}as follows. Set
P\displaystyle P={i∈⟨m⟩∣α(i)=∗},\displaystyle=\{i\in\langle m\rangle\mid\alpha(i)=*\},Q\displaystyle Q={i∈⟨m⟩∣α(i)≠∗},\displaystyle=\{i\in\langle m\rangle\mid\alpha(i)\neq*\},so⟨m⟩\langle m\rangleis the disjoint union ofPPandQQ. We define a linear ordering ofPPbyi1⪯Pi2i_{1}\preceq_{P}i_{2}if
- 1.si1<si2s_{i_{1}}<s_{i_{2}}, or
- 2.si1=si2s_{i_{1}}=s_{i_{2}}andi1≤i2i_{1}\leq i_{2}.
We define a linear ordering onQQbyj1⪯Qj2j_{1}\preceq_{Q}j_{2}ifα(i1)≤α(i2)\alpha(i_{1})\leq\alpha(i_{2}). We define a linear ordering on⟨m⟩\langle m\ranglebyi1⪯i2i_{1}\preceq i_{2}if
- 1.i1∈Pi_{1}\in Pandi2∈Qi_{2}\in Q,
- 2.i1,i2∈Pi_{1},i_{2}\in Pandi1⪯Pi2i_{1}\preceq_{P}i_{2}, or
- 3.i1,i2∈Qi_{1},i_{2}\in Qandi1⪯Qi2i_{1}\preceq_{Q}i_{2}.
Letσ\sigmabe permutation associated to the linear ordering⪯\preceqof⟨m⟩\langle m\rangle, and letσ−1\sigma^{-1}be its inverse. The mapσ∗−1:⟨m⟩∗→⟨m⟩∗\sigma^{-1}_{*}:\langle m\rangle_{*}\to\langle m\rangle_{*}is covered by a tuple morphism
g:(sσ−1(1),…,sσ−1(m))→(s1,…,sm),g:(s_{\sigma^{-1}(1)},\dots,s_{\sigma^{-1}(m)})\to(s_{1},\dots,s_{m}),and we defineOPENf)f)to be the composite
Example 3.1.5.16.
The sortings of the morphismsg1g_{1},g2g_{2}, andg3g_{3}of Example3.1.5.13are shown below.
512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}↝{\lx@inpgf@ignorespaces\rightsquigarrow}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}g1{\lx@inpgf@ignorespaces g_{1}}OPENg1){\lx@inpgf@ignorespaces\mathclap{g_{1})}}1{\lx@inpgf@ignorespaces 1}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}↝{\lx@inpgf@ignorespaces\rightsquigarrow}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}64{\lx@inpgf@ignorespaces 64}1{\lx@inpgf@ignorespaces 1}64{\lx@inpgf@ignorespaces 64}g2{\lx@inpgf@ignorespaces g_{2}}OPENg2){\lx@inpgf@ignorespaces\mathclap{g_{2})}}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}24{\lx@inpgf@ignorespaces 24}↝{\lx@inpgf@ignorespaces\rightsquigarrow}24{\lx@inpgf@ignorespaces 24}24{\lx@inpgf@ignorespaces 24}24{\lx@inpgf@ignorespaces 24}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}g3{\lx@inpgf@ignorespaces g_{3}}OPENg3){\lx@inpgf@ignorespaces\mathclap{g_{3})}}
Lemma 3.1.5.17.
Supposef:S→Tf:S\to Tis a tuple morphism. Thenffis sorted if and only if𝑂𝑃𝐸𝑁f)=ff)=f.
Proof.
Our construction ofOPEN−)-)guarantees thatOPENf)f)is sorted for any tuple morphismff. In particular, ifOPENf=f)f=f), thenffis sorted. Conversely, ifffis sorted, then the permutationσ∈Σm\sigma\in\Sigma_{m}from Construction3.1.5.15is the identity permutation, sog=𝗂𝖽Sg=\mathsf{id}_{S}, and so
OPENf)=f∘𝗂𝖽S=f.f)=f\circ\mathsf{id}_{S}=f.∎
Proposition 3.1.5.18.
Ifffis a tuple morphism, then
OPENLOPENf)=Lf).L_{f)}=L_{f}).
Proof.
Borrowing our notation form Construction3.1.5.15, we haveOPENf)=f∘gf)=f\circ gwhere
g:(sσ−1(1),…,sσ−1(m))→(s1,…,sm)g:(s_{\sigma^{-1}(1)},\dots,s_{\sigma^{-1}(m)})\to(s_{1},\dots,s_{m})lies overσ∗−1:⟨m⟩∗→⟨m⟩∗\sigma^{-1}_{*}:\langle m\rangle_{*}\to\langle m\rangle_{*}. IfLf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}), then
LOPENf)\displaystyle L_{f)}=(s1′,…,sm′):(d1′,…,dm′)\displaystyle=(s_{1}^{\prime},\dots,s_{m}^{\prime}):(d_{1}^{\prime},\dots,d_{m}^{\prime})=(sσ−1(1),…,sσ−1(m)):(dσ−1(1),…,dσ−1(m)).\displaystyle=(s_{\sigma^{-1}(1)},\dots,s_{\sigma^{-1}(m)}):(d_{\sigma^{-1}(1)},\dots,d_{\sigma^{-1}(m)}).Since the modes ofLOPENf)L_{f)}are a permutation of the modes ofLfL_{f}, it suffices to prove thatLOPENf)L_{f)}is sorted. Suppose1≤i<m1\leq i<m. Suppose first thatσ−1(i)∈P\sigma^{-1}(i)\in P, so thatdi′=dσ−1(i)=0d_{i}^{\prime}=d_{\sigma^{-1}(i)}=0. Ifσ−1(i+1)∈P\sigma^{-1}(i+1)\in P, thendi+1′=dσ−1(i+1)=0d^{\prime}_{i+1}=d_{\sigma^{-1}(i+1)}=0. By construction ofσ\sigma, we havesi′=sσ−1(i)≤sσ−1(i+1)=si+1′s_{i}^{\prime}=s_{\sigma^{-1}(i)}\leq s_{\sigma^{-1}(i+1)}=s_{i+1}^{\prime}. If insteadσ−1(i+1)∈Q\sigma^{-1}(i+1)\in Q, thendi+1′=dσ−1(i+1)′>0=di′d_{i+1}^{\prime}=d_{\sigma^{-1}(i+1)}^{\prime}>0=d_{i}^{\prime}. Suppose next thatσ−1(i)∈Q\sigma^{-1}(i)\in Q. Then by construction ofσ\sigma, we haveσ−1(i+1)∈Q\sigma^{-1}(i+1)\in Qandα(σ−1(i))<α(σ−1(i+1))\alpha(\sigma^{-1}(i))<\alpha(\sigma^{-1}(i+1)), and we have
di′=dσ−1(i)\displaystyle d_{i}^{\prime}=d_{\sigma^{-1}(i)}=∏j<α(σ−1(i))tj\displaystyle=\prod_{j<\alpha(\sigma^{-1}(i))}t_{j}≤∏j<α(σ−1(i+1))tj\displaystyle\leq\prod_{j<\alpha(\sigma^{-1}(i+1))}t_{j}=dσ−1(i+1)\displaystyle=d_{\sigma^{-1}(i+1)}=di+1′,\displaystyle=d_{i+1}^{\prime},where equality holds if and only iftα(σ−1(i))=⋯=tα(σ−1(i+1))−1=1t_{\alpha(\sigma^{-1}(i))}=\cdots=t_{\alpha(\sigma^{-1}(i+1))-1}=1. In particular, we havesi=sσ−1(i)=tα(σ−1(i))=1s_{i}=s_{\sigma^{-1}(i)}=t_{\alpha(\sigma^{-1}(i))}=1, and sosi′≤si+1′s_{i}^{\prime}\leq s_{i+1}^{\prime}. We conclude thatLsort(f)L_{\text{sort(f)}}is sorted, soOPENLOPENf)=Lf)L_{f)}=L_{f}). ∎
3.1.5.4Coalesce
We begin by introducing the notion of a coalesced tuple morphism.
Definition 3.1.5.20.
Supposef:S→Tf:S\to Tis a tuple morphism lying overα\alpha. We sayffiscoalescedif
- 1.S=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(S)S=\mathsf{squeeze}(S)and
- 2.for any1≤i<𝗅𝖾𝗇(S)1\leq i<\mathsf{len}(S), exactly one of the following conditions holds: 1. (a)α(i)=∗≠α(i+1)\alpha(i)=*\neq\alpha(i+1), 2. (b)α(i)≠∗=α(i+1)\alpha(i)\neq*=\alpha(i+1), 3. (c)α(i)>α(i+1)\alpha(i)>\alpha(i+1), or 4. (d)α(i)<α(i+1)\alpha(i)<\alpha(i+1), and there existsα(i)<j<α(i+1)\alpha(i)<j<\alpha(i+1)withtj>1t_{j}>1.
Example 3.1.5.21.
If there exists some1≤i<𝗅𝖾𝗇(S)1\leq i<\mathsf{len}(S)withα(i+1)=α(i)+1\alpha(i+1)=\alpha(i)+1, thenffis not coalesced.
Example 3.1.5.23.
The morphisms
4{\lx@inpgf@ignorespaces 4}48{\lx@inpgf@ignorespaces 48}4{\lx@inpgf@ignorespaces 4}32{\lx@inpgf@ignorespaces 32}2{\lx@inpgf@ignorespaces 2}48{\lx@inpgf@ignorespaces 48}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}2{\lx@inpgf@ignorespaces 2}f1{\lx@inpgf@ignorespaces f_{1}}f2{\lx@inpgf@ignorespaces f_{2}}f3{\lx@inpgf@ignorespaces f_{3}}are coalesced, while the morphisms
4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}32{\lx@inpgf@ignorespaces 32}2{\lx@inpgf@ignorespaces 2}32{\lx@inpgf@ignorespaces 32}48{\lx@inpgf@ignorespaces 48}2{\lx@inpgf@ignorespaces 2}1{\lx@inpgf@ignorespaces 1}1{\lx@inpgf@ignorespaces 1}8{\lx@inpgf@ignorespaces 8}48{\lx@inpgf@ignorespaces 48}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}16{\lx@inpgf@ignorespaces 16}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}1{\lx@inpgf@ignorespaces 1}g1{\lx@inpgf@ignorespaces g_{1}}g2{\lx@inpgf@ignorespaces g_{2}}g3{\lx@inpgf@ignorespaces g_{3}}are not coalesced.
Proposition 3.1.5.24.
Supposeffis a tuple morphism. Thenffis coalesced if and only ifLfL_{f}is coalesced.
Proof.
Supposef:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism, and let
Lf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})be the layout encoded byff.
Suppose first thatffis coalesced. Then no entry of𝗌𝗁𝖺𝗉𝖾(Lf)=𝖽𝗈𝗆𝖺𝗂𝗇(f)\mathsf{shape}(L_{f})=\mathsf{domain}(f)is equal to11. Suppose1≤i<m1\leq i<m. We want to show thatsidis_{i}d_{i}is not equal todi+1d_{i+1}. Ifdi=0d_{i}=0, thenα(i)=∗\alpha(i)=*, and we have
sidi=di+1\displaystyle s_{i}d_{i}=d_{i+1}⇔di+1=0\displaystyle\hskip 14.45377pt\Leftrightarrow\hskip 14.45377ptd_{i+1}=0⇔α(i+1)=∗\displaystyle\hskip 14.45377pt\Leftrightarrow\hskip 14.45377pt\alpha(i+1)=*but by our assumption thatffis coalesced, we haveα(i+1)≠∗\alpha(i+1)\neq*, hencesidi≠di+1s_{i}d_{i}\neq d_{i+1}. Ifdi≠0d_{i}\neq 0, thenα(i)≠∗\alpha(i)\neq*. Ifα(i+1)=∗\alpha(i+1)=*, thendi+1=0d_{i+1}=0, sosidi≠di+1s_{i}d_{i}\neq d_{i+1}. Ifα(i+1)<α(i)\alpha(i+1)<\alpha(i), thendi≥di+1d_{i}\geq d_{i+1}, and sincesi≠1s_{i}\neq 1, we havesidi>di+1s_{i}d_{i}>d_{i+1}. Finally, ifα(i)<α(i+1)\alpha(i)<\alpha(i+1), then
sidi=si⋅(∏j<α(i)tj)\displaystyle s_{i}d_{i}=s_{i}\cdot\left(\prod_{j<\alpha(i)}t_{j}\right)=∏j≤α(i)tj\displaystyle=\prod_{j\leq\alpha(i)}t_{j}<∏j<α(i+1)tj\displaystyle<\prod_{j<\alpha(i+1)}t_{j}=di+1.\displaystyle=d_{i+1}.We conclude thatLfL_{f}is coalesced.
Suppose next that the layoutLfL_{f}is coalesced. Then no entry in𝖽𝗈𝗆𝖺𝗂𝗇(f)=𝗌𝗁𝖺𝗉𝖾(Lf)\mathsf{domain}(f)=\mathsf{shape}(L_{f})is equal to11. Suppose1≤i<m1\leq i<m. Ifα(i)=∗\alpha(i)=*, thendi=0d_{i}=0, and sinceLfL_{f}is coalesced, we must havedi+1≠sidi=0d_{i+1}\neq s_{i}d_{i}=0, henceα(i+1)≠∗\alpha(i+1)\neq*. Supposeα(i)≠∗\alpha(i)\neq*, andα(i)<α(i+1)\alpha(i)<\alpha(i+1). SinceLfL_{f}is coalesced, we havesidi≠di+1s_{i}d_{i}\neq d_{i+1}. But if we write
sidi=∏j≤α(i)tj,s_{i}d_{i}=\prod_{j\leq\alpha(i)}t_{j},and
di+1=∏j<α(i+1)tj,d_{i+1}=\prod_{j<\alpha(i+1)}t_{j},this implies that∏α(i)<j<α(i+1)tj≠1\prod_{\alpha(i)<j<\alpha(i+1)}t_{j}\neq 1. In particular, there exists someα(i)<j<α(i+1)\alpha(i)<j<\alpha(i+1)withtj>1t_{j}>1. We conclude thatffis coalesced. ∎
Next, we define our𝖼𝗈𝖺𝗅(−)\mathsf{coal}(-)operation on tuple morphisms.
Construction 3.1.5.25.
Supposeffis a tuple morphism. We define a morphism𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)as follows:
- 1.First, we setg=𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f)g=\mathsf{squeeze}(f), and we writeβ:⟨m⟩∗→⟨n⟩∗\beta:\langle m\rangle_{*}\to\langle n\rangle_{*}for the map over whichgglies.
- 2.Next, we define an equivalence relation∼\simon⟨m⟩\langle m\ranglewherei∼i′i\sim i^{\prime}if either 1. (a)β(i′′)=∗\beta(i^{\prime\prime})=*fori≤i′′≤i′i\leq i^{\prime\prime}\leq i^{\prime}, or 2. (b)β(i′′)=β(i)+(i′′−i)\beta(i^{\prime\prime})=\beta(i)+(i^{\prime\prime}-i)fori≤i′′≤i′i\leq i^{\prime\prime}\leq i^{\prime}. The quotient⟨m⟩/∼\langle m\rangle/\simis ordered by[i1]≤[i2][i_{1}]\leq[i_{2}]ifi1≤i2i_{1}\leq i_{2}, so we can identify this quotient with⟨m¯⟩\langle\bar{m}\ranglewherem¯\bar{m}is the size of⟨m⟩/∼\langle m\rangle/\sim.
- 3.Next, define an equivalence relation∼\simon⟨n⟩\langle n\ranglewherej∼j′j\sim j^{\prime}if there existsi∈⟨m⟩i\in\langle m\ranglesuch that β(i+(j′′−j))=β(i)+(j′′−j)\beta(i+(j^{\prime\prime}-j))=\beta(i)+(j^{\prime\prime}-j)for allj≤j′′≤j′j\leq j^{\prime\prime}\leq j^{\prime}. The quotient⟨n⟩/∼\langle n\rangle/\simis ordered by[j1]≤[j2][j_{1}]\leq[j_{2}]ifj1≤j2j_{1}\leq j_{2}, so we can identify this quotient with⟨n¯⟩\langle\bar{n}\ranglewheren¯\bar{n}is the size of⟨n⟩/∼\langle n\rangle/\sim.
- 4.Next, we observe that the mapβ:⟨m⟩∗→⟨n⟩∗\beta:\langle m\rangle_{*}\to\langle n\rangle_{*}descends to a map β¯:⟨m¯⟩∗→⟨n¯⟩∗\bar{\beta}:\langle\bar{m}\rangle_{*}\to\langle\bar{n}\rangle_{*}given byβ¯([i])=[β(i)]\bar{\beta}([i])=[\beta(i)].
- 5.The domainS¯=(s¯1,…,s¯m¯)\bar{S}=(\bar{s}_{1},\dots,\bar{s}_{\bar{m}})of𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)is defined by setting s¯i=∏i′∈Isi′\bar{s}_{i}=\prod_{i^{\prime}\in I}s_{i^{\prime}}ifi∈⟨m¯⟩i\in\langle\bar{m}\ranglecorresponds to the equivalence classI∈⟨m⟩/∼I\in\langle m\rangle/\sim. The codomainT¯=(t¯1,…,t¯n¯)\bar{T}=(\bar{t}_{1},\dots,\bar{t}_{\bar{n}})of𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)is defined by setting t¯j=∏j′∈Jtj′\bar{t}_{j}=\prod_{j^{\prime}\in J}t_{j^{\prime}}ifj∈⟨n¯⟩j\in\langle\bar{n}\ranglecorresponds to the equivalence classJ∈⟨n⟩/∼J\in\langle n\rangle/\sim. We then define 𝖼𝗈𝖺𝗅(f):S¯→T¯\mathsf{coal}(f):\bar{S}\to\bar{T}to be the tuple morphism lying overβ¯\bar{\beta}.
Example 3.1.5.26.
Here is an example of a tuple morphismffand the coalesced morphism𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f).
7{\lx@inpgf@ignorespaces 7}7{\lx@inpgf@ignorespaces 7}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}7{\lx@inpgf@ignorespaces 7}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}7{\lx@inpgf@ignorespaces 7}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}25{\lx@inpgf@ignorespaces 25}9{\lx@inpgf@ignorespaces 9}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}9{\lx@inpgf@ignorespaces 9}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}𝖼𝗈𝖺𝗅(f){\lx@inpgf@ignorespaces\mathclap{\mathsf{coal}(f)}}
Example 3.1.5.27.
We can coalesce the morphismffof Example3.1.5.8as follows
256{\lx@inpgf@ignorespaces 256}256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}1{\lx@inpgf@ignorespaces 1}128{\lx@inpgf@ignorespaces 128}32768{\lx@inpgf@ignorespaces 32768}1{\lx@inpgf@ignorespaces 1}32{\lx@inpgf@ignorespaces 32}256{\lx@inpgf@ignorespaces 256}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}8{\lx@inpgf@ignorespaces 8}32{\lx@inpgf@ignorespaces 32}↝{\lx@inpgf@ignorespaces\rightsquigarrow}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}↝{\lx@inpgf@ignorespaces\rightsquigarrow}32768{\lx@inpgf@ignorespaces 32768}32{\lx@inpgf@ignorespaces 32}1{\lx@inpgf@ignorespaces 1}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}𝗌𝗊𝗎𝖾𝖾𝗓𝖾(f){\lx@inpgf@ignorespaces\mathclap{\mathsf{squeeze}(f)}}𝖼𝗈𝖺𝗅(f){\lx@inpgf@ignorespaces\mathclap{\mathsf{coal}(f)}}
Proposition 3.1.5.28.
Ifffis a tuple morphism, then
- 1.𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)is coalesced, and
- 2.L𝖼𝗈𝖺𝗅(f)=𝖼𝗈𝖺𝗅(Lf).L_{\mathsf{coal}(f)}=\mathsf{coal}(L_{f}).
Proof.
First, we will argue that𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)is coalesced. This is immediate from our construction, since applying𝗌𝗊𝗎𝖾𝖾𝗓𝖾\mathsf{squeeze}eliminates all modes equal to11, and passing to the quotient in our construction consolidated all adjacent modes withα(i+1)=α(i)+1\alpha(i+1)=\alpha(i)+1.
Next, we will prove thatL𝖼𝗈𝖺𝗅(f)=𝖼𝗈𝖺𝗅(Lf)L_{\mathsf{coal}(f)}=\mathsf{coal}(L_{f}). In light of Proposition2.1.4.18and Proposition3.1.5.24, it suffices to prove thatΦ𝖼𝗈𝖺𝗅(f)=Φf\Phi_{\mathsf{coal}(f)}=\Phi_{f}. Certainly applying𝗌𝗊𝗎𝖾𝖾𝗓𝖾(−)\mathsf{squeeze}(-)toffhas no impact on the associated layout function, so we need to argue that passing to the quotient in our construction does not change the layout function of the associated layout. This follows from the fact that forming our quotient can be formed in steps, where in each step we combine adjacent modes with eitherα(i)=∗=α(i+1)\alpha(i)=*=\alpha(i+1), orα(i+1)=α(i)+1\alpha(i+1)=\alpha(i)+1. These correspond to replacing adjacent modes of the formsi,si+1:0,0s_{i},s_{i+1}:0,0withsisi+1:0s_{i}s_{i+1}:0, andsi,si+1:di,sidis_{i},s_{i+1}:d_{i},s_{i}d_{i}withsisi+1:dis_{i}s_{i+1}:d_{i}, respectively. Neither such operation changes the layout function of a layout, and so we conclude thatΦL𝖼𝗈𝖺𝗅(f)=Φ𝖼𝗈𝖺𝗅(Lf)\Phi_{L_{\mathsf{coal}(f)}}=\Phi_{\mathsf{coal}(L_{f})}, as desired. ∎
3.1.5.5Concatenate
Next, we will define a concatenation operation on tuple morphisms. This operation may be performed on tuple morphisms satisfying a “disjointness” condition, which we specify below.
Definition 3.1.5.29.
Supposeα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}andβ:⟨p⟩∗→⟨n⟩∗\beta:\langle p\rangle_{*}\to\langle n\rangle_{*}are morphisms in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}with the same codomain. We sayα\alphaandβ\betahavedisjoint imagesif
𝖨𝗆𝖺𝗀𝖾(α)∩𝖨𝗆𝖺𝗀𝖾(β)={∗}.\mathsf{Image}(\alpha)\cap\mathsf{Image}(\beta)=\{*\}.
Construction 3.1.5.30.
Ifα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}andβ:⟨p⟩∗→⟨n⟩∗\beta:\langle p\rangle_{*}\to\langle n\rangle_{*}have disjoint images, then we have a well-defined morphism
α⋆β:⟨m+p⟩∗→⟨n⟩∗\alpha\star\beta:\langle m+p\rangle_{*}\to\langle n\rangle_{*}given by
(α⋆β)(i)={∗i=∗α(i)1≤i≤mβ(i−m)m+1≤i≤m+p.(\alpha\star\beta)(i)=\begin{cases}*&i=*\\ \alpha(i)&1\leq i\leq m\\ \beta(i-m)&m+1\leq i\leq m+p.\end{cases}This operation is associative, so we can considerα1⋆⋯⋆αk\alpha_{1}\star\cdots\star\alpha_{k}for any collection of morphismsα1,…,αk\alpha_{1},\dots,\alpha_{k}in𝗙𝗶𝗻∗{\boldsymbol{\mathsf{Fin}}}_{*}with pairwise disjoint images.
Definition 3.1.5.32.
Suppose
and
are tuple morphisms lying overα\alphaandβ\beta, respectively. We sayffandgghavedisjoint imagesif the morphismsα\alphaandβ\betahave disjoint images.
Example 3.1.5.33.
Consider the tuple morphismsff,gg, andhhshown below.
64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}32{\lx@inpgf@ignorespaces 32}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}h{\lx@inpgf@ignorespaces h}Thenffandgghave disjoint images, whilehhandggdo not have disjoint images.
Construction 3.1.5.34.
Suppose
f:S→T, andg:U→Tf:S\to T\text{, and }g:U\to Tare tuple morphisms lying overα\alphaandβ\beta, respectively, and thatffandgghave disjoint images. We define theconcatenationofffandggto be the morphism
f⋆g:S⋆U→Tf\star g:S\star U\to Tlying overα⋆β\alpha\star\beta. This operation is associative, so we can considerf1⋯fkf_{1}\cdots f_{k}for any finite collection of morphismsfif_{i}with pairwise disjoint images.
Example 3.1.5.35.
Ifffandggare the morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}from Example3.1.5.33, then the concatenation offfandggis the morphism shown below.
32{\lx@inpgf@ignorespaces 32}3{\lx@inpgf@ignorespaces 3}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}64{\lx@inpgf@ignorespaces 64}3{\lx@inpgf@ignorespaces 3}
Example 3.1.5.36.
Supposef:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a tuple morphism, and for any1≤i≤m1\leq i\leq m, let
fi:(si)→(t1,…,tn)f_{i}:(s_{i})\to(t_{1},\dots,t_{n})denote theiith entry offf, as in Example3.1.3.8. Then we can write
f=f1⋆⋯⋆fmf=f_{1}\star\cdots\star f_{m}as the concatenation of its entries.
Lemma 3.1.5.37.
Supposef1:S1→Tf_{1}:S_{1}\to Tandf2:S2→Tf_{2}:S_{2}\to Tare tuple morphisms with disjoint images. Ifg:T→Ug:T\to Uis any tuple morphism, then
g∘(f1⋆f2)=(g∘f1)⋆(g∘f2).g\circ(f_{1}\star f_{2})=(g\circ f_{1})\star(g\circ f_{2}).
Proof.
Supposef1f_{1},f2f_{2}, andgglie overα1:⟨m1⟩∗→⟨n⟩\alpha_{1}:\langle m_{1}\rangle_{*}\to\langle n\rangle,α2:⟨m2⟩∗→⟨n⟩\alpha_{2}:\langle m_{2}\rangle_{*}\to\langle n\rangle, andβ:⟨n⟩→⟨p⟩\beta:\langle n\rangle\to\langle p\rangle, respectively. The two maps in question have the same domains and the same codomains, so it suffices to prove that
β∘(α1⋆α2)=(β∘α1)⋆(β∘α2).\beta\circ(\alpha_{1}\star\alpha_{2})=(\beta\circ\alpha_{1})\star(\beta\circ\alpha_{2}).We compute
(β∘(α1⋆α2))(i)\displaystyle(\beta\circ(\alpha_{1}\star\alpha_{2}))(i)=β((α1⋆α2)(i))\displaystyle=\beta((\alpha_{1}\star\alpha_{2})(i))={β(∗)i=∗β(α1(i))1≤i≤m1β(α2(i−m1))m1+1≤i≤m1+m2\displaystyle=\begin{cases}\beta(*)&i=*\\ \beta(\alpha_{1}(i))&1\leq i\leq m_{1}\\ \beta(\alpha_{2}(i-m_{1}))&m_{1}+1\leq i\leq m_{1}+m_{2}\end{cases}={∗i=∗(β∘α1)(i)1≤i≤m1(β∘α2)(i−m1)m1+1≤i≤m1+m2\displaystyle=\begin{cases}*&i=*\\ (\beta\circ\alpha_{1})(i)&1\leq i\leq m_{1}\\ (\beta\circ\alpha_{2})(i-m_{1})&m_{1}+1\leq i\leq m_{1}+m_{2}\end{cases}=((β∘α1)⋆(β∘α2))(i).\displaystyle=((\beta\circ\alpha_{1})\star(\beta\circ\alpha_{2}))(i).∎
Proposition 3.1.5.38.
Supposef1,…,fkf_{1},\dots,f_{k}are morphisms in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}with the same codomain and with pairwise disjoint images. Then the layoutsLf1,…,LfkL_{f_{1}},\dots,L_{f_{k}}satisfy
Lf1⋆⋯⋆fk=Lf1⋆⋯⋆Lfk.L_{f_{1}\star\cdots\star f_{k}}=L_{f_{1}}\star\cdots\star L_{f_{k}}.
Proof.
First, we prove the result fork=2k=2. Suppose
f=(s1,…,sm)→(t1,…,tn), andg:(u1,…,up)→(t1,…,tn)f=(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})\text{, and }g:(u_{1},\dots,u_{p})\to(t_{1},\dots,t_{n})have disjoint images, and write
Lf=(s1,…,sm):(d1,…,dm), andLg=(u1,…,up):(d1′,…,dp′).L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})\text{, and }L_{g}=(u_{1},\dots,u_{p}):(d_{1}^{\prime},\dots,d_{p}^{\prime}).Then the layoutLf⋆gL_{f\star g}is given by
Lf⋆g=(s1,…,sm,u1,…,up):(e1,…,em+m′)L_{f\star g}=(s_{1},\dots,s_{m},u_{1},\dots,u_{p}):(e_{1},\dots,e_{m+m^{\prime}})where
ei\displaystyle e_{i}=∏j<(α⋆β)(i)tj\displaystyle=\prod_{j<(\alpha\star\beta)(i)}t_{j}={∏j<α(i)tj1≤i≤m∏j<β(i−m)tjm+1≤i≤m+m′.\displaystyle=\begin{cases}\displaystyle\prod_{j<\alpha(i)}t_{j}&1\leq i\leq m\\ \displaystyle\prod_{j<\beta(i-m)}t_{j}&m+1\leq i\leq m+m^{\prime}.\end{cases}={di1≤i≤mdi−m′m+1≤i≤m+m′.\displaystyle=\begin{cases}d_{i}&1\leq i\leq m\\ d_{i-m}^{\prime}&m+1\leq i\leq m+m^{\prime}.\end{cases}This concludes the proof of the result whenk=2k=2. The general case follows from the associativity of concatenation of tuple morphisms, and the associativity of concatenation of flat layouts. ∎
3.1.5.6Complement
We begin by defining the notion of complementary tuple morphisms.
Definition 3.1.5.39.
Supposef:S→Tf:S\to Tandg:U→Tg:U\to Tare tuple morphisms. We sayggis acomplementofffif
- 1.ffandgghave disjoint images, and
- 2.the concatenation f⋆g:S⋆U{\lx@inpgf@ignorespaces f\star g:S\star U}T{\lx@inpgf@ignorespaces T}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}is an isomorphism.
Example 3.1.5.40.
Ifffandggare the morphisms shown below
16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}10{\lx@inpgf@ignorespaces 10}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}10{\lx@inpgf@ignorespaces 10}16{\lx@inpgf@ignorespaces 16}10{\lx@inpgf@ignorespaces 10}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}thenggis a complement offf.
Example 3.1.5.41.
Ifffis the morphism shown below
256{\lx@inpgf@ignorespaces 256}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}256{\lx@inpgf@ignorespaces 256}f{\lx@inpgf@ignorespaces f}thenffdoes not admit a complement.
Next, we prove that complementary tuple morphisms give rise to complementary flat layouts.
Proposition 3.1.5.42.
Iff:S→Tf:S\to Tis a tuple morphism andggis a complement offf, thenLgL_{g}is a𝗌𝗂𝗓𝖾(T)\mathsf{size}(T)-complement ofLfL_{f}.
Proof.
WriteS=𝖽𝗈𝗆𝖺𝗂𝗇(f)S=\mathsf{domain}(f),U=𝖽𝗈𝗆𝖺𝗂𝗇(g)U=\mathsf{domain}(g), andT=𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(f)=𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)T=\mathsf{codomain}(f)=\mathsf{codomain}(g). First, we note that
𝗌𝗂𝗓𝖾(Lf)⋅𝗌𝗂𝗓𝖾(Lg)\displaystyle\mathsf{size}(L_{f})\cdot\mathsf{size}(L_{g})=𝗌𝗂𝗓𝖾(Lf⋆Lg)\displaystyle=\mathsf{size}(L_{f}\star L_{g})=𝗌𝗂𝗓𝖾(Lf⋆g)\displaystyle=\mathsf{size}(L_{f\star g})=𝗌𝗂𝗓𝖾(S⋆U)\displaystyle=\mathsf{size}(S\star U)=𝗌𝗂𝗓𝖾(T).\displaystyle=\mathsf{size}(T).Next, we note thatf⋆gf\star gis an isomorphism, hence so is
|f⋆g|=ΦLf⋆g𝗌𝗂𝗓𝖾(T)|f\star g|=\Phi_{L_{f\star g}}^{\mathsf{size}(T)}where we have used the identification ofΦLf⋆g𝗌𝗂𝗓𝖾(T)\Phi^{\mathsf{size}(T)}_{L_{f\star g}}of Lemma3.1.4.5. ∎
Proposition 3.1.5.43.
Ifffis an injective tuple morphism, then
𝖼𝗈𝖺𝗅♭(Lfc)=𝖼𝗈𝗆𝗉♭(Lf,𝗌𝗂𝗓𝖾(T)).\mathsf{coal}^{\flat}(L_{f^{c}})=\mathsf{comp}^{\flat}(L_{f},\mathsf{size}(T)).
Proof.
By Proposition3.1.5.42, we know thatLfcL_{f^{c}}is a𝗌𝗂𝗓𝖾(T)\mathsf{size}(T)-complement ofLfL_{f}. Sincefcf^{c}is sorted, so isLfcL_{f^{c}}and it follows from Proposition2.1.6.33, it follows that
𝖼𝗈𝖺𝗅♭(Lfc)=𝖼𝗈𝗆𝗉♭(Lf,𝗌𝗂𝗓𝖾(T)),\mathsf{coal}^{\flat}(L_{f^{c}})=\mathsf{comp}^{\flat}(L_{f},\mathsf{size}(T)),since both of these layouts are flat, sorted, coalesced complements ofLfL_{f}of the same size. ∎
Proposition 3.1.5.44.
Iff:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is an injective tuple morphism of standard form, then
Lfc=𝖼𝗈𝗆𝗉♭(Lf).L_{f^{c}}=\mathsf{comp}^{\flat}(L_{f}).
Proof.
Write
Lf=(s1,…,sm):(d1,…,dm)L_{f}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})for the layout encoded byff. By Proposition3.1.5.42, we know thatLfcL_{f^{c}}is a𝗌𝗂𝗓𝖾(T)\mathsf{size}(T)-complement ofLfL_{f}. Where
𝗌𝗂𝗓𝖾(T)=t1⋯tn\displaystyle\mathsf{size}(T)=t_{1}\cdots t_{n}=(t1⋯tn−1)tn\displaystyle=(t_{1}\cdots t_{n-1})t_{n}=dmsm.\displaystyle=d_{m}s_{m}.By construction,fcf^{c}is sorted, hence so isLfcL_{f^{c}}. Moreover, sinceffhas standard form, it follows thatfcf^{c}is coalesced. By Proposition2.1.6.23, we deduce that
Lfc=𝖼𝗈𝗆𝗉♭(Lf).L_{f^{c}}=\mathsf{comp}^{\flat}(L_{f}).∎
Definition 3.1.5.45.
Supposeffis a tuple morphism lying overα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}. We sayffis𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡𝑎𝑏𝑙𝑒{\it complementable}ifα\alphais injective.
Construction 3.1.5.46.
Supposef:(s1,…,sm)→(t1,…,tn)f:(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n})is a complementable tuple morphism. Letj1<⋯<jn−mj_{1}<\cdots<j_{n-m}denote the collection of indices in⟨n⟩\langle n\ranglewhich are not in the image ofα\alpha. We define thecomplement offfto be the tuple morphism
fc:(tj1,…,tjk)→(t1,…,tn)f^{c}:(t_{j_{1}},\dots,t_{j_{k}})\to(t_{1},\dots,t_{n})lying over the map𝖼𝗈𝗆𝗉𝗅𝖾𝗆𝖾𝗇𝗍(α):⟨n−m⟩∗→⟨n⟩∗\mathsf{complement}(\alpha):\langle n-m\rangle_{*}\to\langle n\rangle_{*}given byk↦jkk\mapsto j_{k}. By construction, we may observe thatfcf^{c}is a complement offf, in the sense of Definition3.1.5.39
Example 3.1.5.47.
Below is an example of a morphismffand its complementfcf^{c}.
512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}256{\lx@inpgf@ignorespaces 256}512{\lx@inpgf@ignorespaces 512}256{\lx@inpgf@ignorespaces 256}256{\lx@inpgf@ignorespaces 256}10{\lx@inpgf@ignorespaces 10}10{\lx@inpgf@ignorespaces 10}10{\lx@inpgf@ignorespaces 10}f{\lx@inpgf@ignorespaces f}fc{\lx@inpgf@ignorespaces f^{c}}
Proposition 3.1.5.48.
Ifffis a tuple morphism andggis a complement offf, then
Proof.
Supposefflies overα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*},OPENg)g)lies overβ:⟨n−m⟩∗→⟨n⟩∗\beta:\langle n-m\rangle_{*}\to\langle n\rangle_{*}andfcf^{c}lies overαc:⟨n−m⟩∗→⟨n⟩∗\alpha^{c}:\langle n-m\rangle_{*}\to\langle n\rangle_{*}. Thenβ\betaandαc\alpha^{c}are increasing maps with the same image, namely
𝖨𝗆𝖺𝗀𝖾(β)=⟨n⟩∖𝖨𝗆𝖺𝗀𝖾(α)=𝖨𝗆𝖺𝗀𝖾(αc),\mathsf{Image}(\beta)=\langle n\rangle\setminus\mathsf{Image}(\alpha)=\mathsf{Image}(\alpha^{c}),henceβ=αc\beta=\alpha^{c}, and henceOPENg)=fcg)=f^{c}. ∎
Proposition 3.1.5.49.
Supposeffis a tuple morphism. Thenffadmits a complement if and only ifffis complementable, in the sense of Definition3.1.5.45.
Proof.
Iffflies over a mapα\alphawhich is not injective, then for any morphismf∗f^{*}such thatffandf∗f^{*}have disjoint images, the morphismf⋆f∗f\star f^{*}lies over a map which is not injective, hencef⋆f∗f\star f^{*}is not an isomorphism. Conversely, iffflies over an injective map, then the morphismfcf^{c}of Construction3.1.5.46is a complement offf. ∎
Proposition 3.1.5.50.
Ifffis a complementable tuple morphism, then
OPENf)=(fc)c.f)=(f^{c})^{c}.
Proof.
Both maps are increasing, injective, and have the same image, so they are equal. ∎
3.1.5.7Flat division
In this section, we define a division operation on tuple morphisms.
Definition 3.1.5.51.
Ifffandggare tuple morphisms, we sayggdividesffifggandffare composable. In other words,
𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)=𝖽𝗈𝗆𝖺𝗂𝗇(f).\mathsf{codomain}(g)=\mathsf{domain}(f).
Definition 3.1.5.52.
Supposeg:S→Tg:S\to Tandf:T→Uf:T\to Uare tuple morphisms. Theflat divisionofffbyggis the tuple morphism
f⊘♭g=f∘(g⋆gc).f\oslash^{\flat}g=f\circ(g\star g^{c}).
Example 3.1.5.53.
Here is an example of tuple morphismsffandggtogether with their flat quotientf⊘♭gf\oslash^{\flat}g.
128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}128{\lx@inpgf@ignorespaces 128}2{\lx@inpgf@ignorespaces 2}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}f⊘♭g{\lx@inpgf@ignorespaces f\oslash^{\flat}g}
Example 3.1.5.54.
Here is an example of tuple morphismsffandggtogether with their flat quotientf⊘♭gf\oslash^{\flat}g.
5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}f⊘♭g{\lx@inpgf@ignorespaces f\oslash^{\flat}g}
Example 3.1.5.55.
Here is an example of tuple morphismsffandggtogether with their flat quotientf⊘♭gf\oslash^{\flat}g.
512{\lx@inpgf@ignorespaces 512}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}512{\lx@inpgf@ignorespaces 512}2{\lx@inpgf@ignorespaces 2}512{\lx@inpgf@ignorespaces 512}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}f⊘♭g{\lx@inpgf@ignorespaces f\oslash^{\flat}g}
Proposition 3.1.5.56.
Ifffandggare non-degenerate composable tuple morphisms, then
𝖼𝗈𝖺𝗅♭(Lf⊘♭g)=𝖼𝗈𝖺𝗅♭(Lf⊘♭Lg)\mathsf{coal}^{\flat}(L_{f\oslash^{\flat}g})=\mathsf{coal}^{\flat}(L_{f}\oslash^{\flat}L_{g})
Proof.
By Proposition3.2.6.20, we have
𝖼𝗈𝖺𝗅♭(Lgc)=𝖼𝗈𝗆𝗉♭(Lg,𝗌𝗂𝗓𝖾(Lf)),\mathsf{coal}^{\flat}(L_{g^{c}})=\mathsf{comp}^{\flat}(L_{g},\mathsf{size}(L_{f})),and we compute
𝖼𝗈𝖺𝗅♭(Lf⊘♭Lg)\displaystyle\mathsf{coal}^{\flat}(L_{f}\oslash^{\flat}L_{g})=𝖼𝗈𝖺𝗅♭(Lf∘(Lg⋆𝖼𝗈𝗆𝗉(Lg,𝗌𝗂𝗓𝖾(Lf))))\displaystyle=\mathsf{coal}^{\flat}(L_{f}\circ\left(L_{g}\star\mathsf{comp}(L_{g},\mathsf{size}(L_{f}))\right))=𝖼𝗈𝖺𝗅(Lf∘(Lg⋆Lgc))\displaystyle=\mathsf{coal}(L_{f}\circ\left(L_{g}\star L_{g^{c}}\right))=𝖼𝗈𝖺𝗅(Lf∘Lg⋆gc)\displaystyle=\mathsf{coal}(L_{f}\circ L_{g\star g^{c}})=𝖼𝗈𝖺𝗅(Lf∘(g⋆gc))\displaystyle=\mathsf{coal}(L_{f\circ(g\star g^{c})})=𝖼𝗈𝖺𝗅(Lf⊘♭g).\displaystyle=\mathsf{coal}(L_{f\oslash^{\flat}g}).∎
3.1.5.8Flat products
In this section we define a product operation on tuple morphisms.
Definition 3.1.5.57.
Supposeffandggare tuple morphisms. We sayffandggareproduct admissibleif𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)=𝖽𝗈𝗆𝖺𝗂𝗇(fc)\mathsf{codomain}(g)=\mathsf{domain}(f^{c}). Ifffandggare product admissible, then we defineflat productofffandggto be
f⊗♭g=f⋆(fc∘g).f\otimes^{\flat}g=f\star(f^{c}\circ g).
Example 3.1.5.58.
Ifffandggare the tuple morphisms shown below
16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}thenffandggare product-admissible, andf⊗♭gf\otimes^{\flat}gis the tuple morphism shown below.
16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f⊗♭g{\lx@inpgf@ignorespaces f\otimes^{\flat}g}
Example 3.1.5.59.
Ifffandggare the tuple morphisms shown below
128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}g{\lx@inpgf@ignorespaces g}f{\lx@inpgf@ignorespaces f}thenffandggare product-admissible, andf⊗♭gf\otimes^{\flat}gis the tuple morphism shown below.
128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}128{\lx@inpgf@ignorespaces 128}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}128{\lx@inpgf@ignorespaces 128}32{\lx@inpgf@ignorespaces 32}f⊗♭g{\lx@inpgf@ignorespaces f\otimes^{\flat}g}
Lemma 3.1.5.60.
Ifffandggare product admissible andggis injective, thenf⊗♭gf\otimes^{\flat}gis injective and
(f⊗♭g)c=fc∘gc.(f\otimes^{\flat}g)^{c}=f^{c}\circ g^{c}.
Proof.
The tuple morphisms(f⊗♭g)c(f\otimes^{\flat}g)^{c}andfc∘gcf^{c}\circ g^{c}are injective, increasing, and have the same codomain, so it suffices to show that they have the same image. The image of(f⊗♭g)c=(f⋆(fc∘g))c(f\otimes^{\flat}g)^{c}=(f\star(f^{c}\circ g))^{c}consists of those entries which are not in the image offf, and not in the image offc∘gf^{c}\circ g. The image offcf^{c}consists of those entries which are not in the image offf, and so the image of the compositionfc∘gcf^{c}\circ g^{c}consists of those entries which are not in the image offf, and not in the image offc∘gf^{c}\circ g. ∎
Proposition 3.1.5.61.
Supposeffandggare product admissible, andggandhhare product admissible. Then
- 1.f⊗♭gf\otimes^{\flat}gandhhare product admissible,
- 2.ffandg⊗♭hg\otimes^{\flat}hare product admissible, and
- 3.(f⊗♭g)⊗♭h=f⊗♭(g⊗♭h)(f\otimes^{\flat}g)\otimes^{\flat}h=f\otimes^{\flat}(g\otimes^{\flat}h).
Proof.
Using Lemma3.1.5.37and Lemma3.1.5.60, we compute
f⊗♭(g⊗♭h)\displaystyle f\otimes^{\flat}(g\otimes^{\flat}h)=f⋆(fc∘(g⊗♭h))\displaystyle=f\star(f^{c}\circ(g\otimes^{\flat}h))=f⋆(fc∘(g⋆(gc∘h)))\displaystyle=f\star(f^{c}\circ(g\star(g^{c}\circ h)))=f⋆((fc∘g)⋆(fc∘(gc∘h)))\displaystyle=f\star((f^{c}\circ g)\star(f^{c}\circ(g^{c}\circ h)))=f⋆((fc∘g)⋆((fc∘gc)∘h))\displaystyle=f\star((f^{c}\circ g)\star((f^{c}\circ g^{c})\circ h))=f⋆(fc∘g)⋆((f⊗♭g)c∘h)\displaystyle=f\star(f^{c}\circ g)\star((f\otimes^{\flat}g)^{c}\circ h)=(f⊗♭g)⋆((f⊗♭g)c∘h)\displaystyle=(f\otimes^{\flat}g)\star((f\otimes^{\flat}g)^{c}\circ h)=(f⊗♭g)⊗♭h.\displaystyle=(f\otimes^{\flat}g)\otimes^{\flat}h.∎
Proposition 3.1.5.62.
Supposeffandggare non-degenerate tuple morphisms and thatffandggare product admissible. Then
Lf⊗♭g=Lf⊗♭Lg.L_{f\otimes^{\flat}g}=L_{f}\otimes^{\flat}L_{g}.
Proof.
Supposef:S→Tf:S\to Tandg:U→Vg:U\to Vare product admissible, and set
Lf∗=𝖼𝗈𝗆𝗉♭(Lf,𝗌𝗂𝗓𝖾(Lf)⋅𝖼𝗈𝗌𝗂𝗓𝖾(Lg)).L_{f}^{*}=\mathsf{comp}^{\flat}(L_{f},\mathsf{size}(L_{f})\cdot\mathsf{cosize}(L_{g})).Sinceffis injective and the codomain ofggis the domain offcf^{c}, it follows that
𝗌𝗂𝗓𝖾(Lf)⋅𝖼𝗈𝗌𝗂𝗓𝖾(Lg)≤𝗌𝗂𝗓𝖾(S)⋅𝗌𝗂𝗓𝖾(V)=𝗌𝗂𝗓𝖾(T).\mathsf{size}(L_{f})\cdot\mathsf{cosize}(L_{g})\leq\mathsf{size}(S)\cdot\mathsf{size}(V)=\mathsf{size}(T).Using this fact, and the fact that
Φ𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(T))=ΦLfc,\Phi_{\mathsf{comp}(L_{f},\mathsf{size}(T))}=\Phi_{L_{f^{c}}},we have
Lf∗∘Lg\displaystyle L_{f}^{*}\circ L_{g}=𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(T))∘Lg\displaystyle=\mathsf{comp}(L_{f},\mathsf{size}(T))\circ L_{g}=Lfc∘Lg.\displaystyle=L_{f^{c}}\circ L_{g}.Using this fact, we compute
Lf⊗♭Lg\displaystyle L_{f}\otimes^{\flat}L_{g}=Lf⋆(Lf∗∘Lg)\displaystyle=L_{f}\star(L_{f}^{*}\circ L_{g})=Lf⋆(Lfc∘Lg)\displaystyle=L_{f}\star(L_{f^{c}}\circ L_{g})=Lf⋆Lfc∘g\displaystyle=L_{f}\star L_{f^{c}\circ g}=Lf⋆(fc∘g)\displaystyle=L_{f\star(f^{c}\circ g)}=Lf⊗♭g\displaystyle=L_{f\otimes^{\flat}g}∎
3.2The category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}
In the previous section, we introduced a category𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, whose morphisms encode flat tractable layouts. In this section, we introduce a category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}, whose morphisms encode tractable layouts with arbitrary nesting.
3.2.1Basic definitions
Recall that for a nested tupleSS, we writeS♭S^{\flat}for the flattening ofSS. For example, ifS=(64,(8,8))S=(64,(8,8)), thenS♭=(64,8,8)S^{\flat}=(64,8,8).
Definition 3.2.1.1.
Let𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}denote the category whose objects are nested tuples of positive integers, and in which a morphism
in𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}is specified by a tuple morphism
f♭:S♭→T♭.f^{\flat}:S^{\flat}\to T^{\flat}.In other words,
𝖧𝗈𝗆𝗡𝗲𝘀𝘁(S,T)=𝖧𝗈𝗆𝗧𝘂𝗽𝗹𝗲(S♭,T♭).\mathsf{Hom}_{{\boldsymbol{\mathsf{Nest}}}}(S,T)=\mathsf{Hom}_{{\boldsymbol{\mathsf{Tuple}}}}(S^{\flat},T^{\flat}).Explicitly, a morphismf:S→Tf:S\to Tin𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}is specified by a tractable pointed mapα:⟨𝗅𝖾𝗇(S)⟩∗→⟨𝗅𝖾𝗇(T)⟩∗\alpha:\langle\mathsf{len}(S)\rangle_{*}\to\langle\mathsf{len}(T)\rangle_{*}satisfying the following property:
- •If1≤i≤𝗅𝖾𝗇(S)1\leq i\leq\mathsf{len}(S)andα(i)≠∗\alpha(i)\neq*, thenOPENOPENS)=T)S)=T).
We say such a morphismfflies overα\alpha, and refer toffas anested tuple morphism.
Notation 3.2.1.2.
Iff:S→Tf:S\to Tis a nested tuple morphism which lies overα\alpha, we depictffas
S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}
Example 3.2.1.3.
Here are some examples of nested tuple morphisms.
(64,(8,8)){\lx@inpgf@ignorespaces(64,(8,8))}(64,8,8){\lx@inpgf@ignorespaces(64,8,8)}((2,2),2){\lx@inpgf@ignorespaces((2,2),2)}(10,2,2,(3,2,3)){\lx@inpgf@ignorespaces(10,2,2,(3,2,3))}64{\lx@inpgf@ignorespaces 64}((64,64),512).{\lx@inpgf@ignorespaces((64,64),512).}f\scriptstyle{\lx@inpgf@ignorespaces f}(1,2,3)\scriptstyle{\lx@inpgf@ignorespaces(1{,}2{,}3)}g\scriptstyle{\lx@inpgf@ignorespaces g}(∗,5,2)\scriptstyle{\lx@inpgf@ignorespaces(*{,}5{,}2)}h\scriptstyle{\lx@inpgf@ignorespaces h}(2)\scriptstyle{\lx@inpgf@ignorespaces(2)}
Observation 3.2.1.4.
IfXXis a set, lets writeX𝗂𝗇𝖽X^{\mathsf{ind}}for the indiscrete category onXX. This is the category whose objects are the elements ofXX, and in which there is a unique (iso)morphism between any two objects. Then by definition of𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}, we have a pullback square
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝖯𝗋𝗈𝖿𝗂𝗅𝖾𝗂𝗇𝖽{\lx@inpgf@ignorespaces\mathsf{Profile}^{\mathsf{ind}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}ℕ𝗂𝗇𝖽{\lx@inpgf@ignorespaces\mathbb{N}^{\mathsf{ind}}}𝗉𝗋𝗈𝖿(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{prof}(-)}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}⌟{\lx@inpgf@ignorespaces\lrcorner}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}𝗅𝖾𝗇(−)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{len}(-)}We may view this as a categorification of the pullback square2.2.2.4.
Example 3.2.1.5.
SupposeSSis a nested tuple of lengthmm. If1≤i≤m1\leq i\leq mthen there is a nested tuple morphism
lying over the map⟨1⟩∗→⟨m⟩∗\langle 1\rangle_{*}\to\langle m\rangle_{*}given by1↦i1\mapsto i. For instance, ifS=(64,(8,8))S=(64,(8,8))andi=1i=1, then we have a nested tuple morphism
64{\lx@inpgf@ignorespaces 64}(64,(8,8)).{\lx@inpgf@ignorespaces(64,(8,8)).}(1)\scriptstyle{\lx@inpgf@ignorespaces(1)}
Example 3.2.1.6.
SupposeSSis a nested tuple of rankrr. If1≤i≤r1\leq i\leq r, then there is a canonical nested tuple morphism
𝗆𝗈𝖽𝖾i(S)→S\mathsf{mode}_{i}(S)\to Slying over the map⟨𝗅𝖾𝗇i(S)⟩∗→⟨𝗅𝖾𝗇(S)⟩∗\langle\mathsf{len}_{i}(S)\rangle_{*}\to\langle\mathsf{len}(S)\rangle_{*}given byj↦j+𝗅𝖾𝗇<i(S)j\mapsto j+\mathsf{len}_{<i}(S). For instance, ifS=(64,(8,8))S=(64,(8,8)), then we have a nested tuple morphism
(8,8){\lx@inpgf@ignorespaces(8,8)}(64,(8,8)).{\lx@inpgf@ignorespaces(64,(8,8)).}(2,3)\scriptstyle{\lx@inpgf@ignorespaces(2{,}3)}
Observation 3.2.1.7.
There are functors relating the categories𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}and𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}. First, there is an inclusion functor
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}⊂\scriptstyle{\lx@inpgf@ignorespaces\subset}which considers a tuple morphismf:S→Tf:S\to Tas a nested tuple morphism. Next, there is aflatteningfunctor
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}which sends a nested tuple morphismf:S→Tf:S\to Tto the underlying tuple morphismf♭:S♭→T♭f^{\flat}:S^{\flat}\to T^{\flat}. The composite
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}⊂\scriptstyle{\lx@inpgf@ignorespaces\subset}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}is the identity functor on𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}, so𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}is a retractive subcategory of𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}. Moreover, these functors form an adjoint equivalence of categories.
3.2.2From nested tuple morphisms to layouts
The key feature of the category𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}is that iff:S→Tf:S\to Tis a nested tuple morphism, thenffencodes a layoutLfL_{f}. This layout is obtained by equipping the flat layoutLf♭L_{f^{\flat}}with the nesting profile ofSS. More precisely, we have the following construction.
Construction 3.2.2.1.
Suppose
is a nested tuple morphism, and supposeP=𝗉𝗋𝗈𝖿(S)P=\mathsf{prof}(S). We defineLfL_{f}to be the layout
Lf=(Lf♭)PL_{f}=(L_{f^{\flat}})_{P}where(−)P(-)_{P}is thePP-substitution operation of Definition2.3.1.19. We refer toLfL_{f}as thelayout encoded byff.
Construction 3.2.2.2.
Suppose
(s1,…,sm)P{\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})_{P}}(t1,…,tn)Q{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n})_{Q}}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a nested tuple morphism. We defineLfL_{f}to be the layout whose shape
𝗌𝗁𝖺𝗉𝖾(Lf)=(s1,…,sm)P\mathsf{shape}(L_{f})=(s_{1},\dots,s_{m})_{P}is the domain offf, and whose stride
𝗌𝗍𝗋𝗂𝖽𝖾(Lf)=(d1,…,dm)P\mathsf{stride}(L_{f})=(d_{1},\dots,d_{m})_{P}has entries defined by the formula
di={0α(i)=∗∏j<α(i)tjα(i)≠∗.d_{i}=\begin{cases}0&\alpha(i)=*\\ \prod_{j<\alpha(i)}t_{j}&\alpha(i)\neq*.\end{cases}We refer toLfL_{f}as thelayout encoded byff.
Example 3.2.2.3.
The layout encoded by
((8,8),(4,4)){\lx@inpgf@ignorespaces((8,8),(4,4))}(8,4,4,8){\lx@inpgf@ignorespaces(8,4,4,8)}f\scriptstyle{\lx@inpgf@ignorespaces f}(1,4,3,2)\scriptstyle{\lx@inpgf@ignorespaces(1{,}4{,}3{,}2)}is
Lf=((8,8),(4,4)):((1,128),(32,8)).L_{f}=((8,8),(4,4)):((1,128),(32,8)).
Example 3.2.2.4.
The layout encoded by
(128,(4,4,2)){\lx@inpgf@ignorespaces(128,(4,4,2))}((4,4),128){\lx@inpgf@ignorespaces((4,4),128)}g\scriptstyle{\lx@inpgf@ignorespaces g}(3,1,2,∗)\scriptstyle{\lx@inpgf@ignorespaces(3{,}1{,}2{,}*)}is
Lg=(128,(4,4,2)):(16,(1,4,0)).L_{g}=(128,(4,4,2)):(16,(1,4,0)).
Observation 3.2.2.5.
The flattening functor
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}is compatible with flattening of layouts, in that ifffis a nested tuple morphism, then
(Lf)♭=Lf♭.(L_{f})^{\flat}=L_{f^{\flat}}.
IfLLis a tractable layout, then we can construct a nested tuple morphism which encodesLLas follows.
Construction 3.2.2.6.
SupposeLLis a tractable layout. We define thestandard representationofLLto be the nested tuple morphism
where(fL)♭=fL♭(f_{L})^{\flat}=f_{L^{\flat}}is the standard representation ofL♭L^{\flat},S=𝗌𝗁𝖺𝗉𝖾(L)S=\mathsf{shape}(L)is the shape ofLL, andTTis the codomain offL♭f_{L^{\flat}}.
Example 3.2.2.7.
If
L=(32,(2,2)):(192,(24,3))L=(32,(2,2)):(192,(24,3))then the standard representation ofLLis
(32,(2,2)){\lx@inpgf@ignorespaces(32,(2,2))}(3,2,4,2,4,32).{\lx@inpgf@ignorespaces(3,2,4,2,4,32).}fL\scriptstyle{\lx@inpgf@ignorespaces f_{L}}(6,4,2)\scriptstyle{\lx@inpgf@ignorespaces(6{,}4{,}2)}
Lemma 3.2.2.8.
IfLLis a tractable layout, andf=fLf=f_{L}is the standard representation ofLL, then
Proof.
We have
(Lf)♭=Lf♭=L♭(L_{f})^{\flat}=L_{f^{\flat}}=L^{\flat}and
𝗌𝗁𝖺𝗉𝖾(Lf)=𝗌𝗁𝖺𝗉𝖾(L).\displaystyle\mathsf{shape}(L_{f})=\mathsf{shape}(L).∎
Proposition 3.2.2.9.
SupposeLLis a layout. Then there exists a nested tuple morphismffencodingLLif and only ifLLis tractable.
Proof.
Suppose first thatL=LfL=L_{f}for some nested tuple morphismff. Then(Lf)♭=Lf♭(L_{f})^{\flat}=L_{f^{\flat}}, and by Proposition3.1.2.10, we know thatL♭L^{\flat}is tractable, hence so isLL. Conversely, ifLLis tractable, then we can takef=fLf=f_{L}to be the standard representation ofLL, and by Lemma3.2.2.8, we haveLf=LL_{f}=L. ∎
In order to establish a one-to-one correspondence between tractable layouts and certain nested tuple morphisms, we introduce the notion ofstandard formfor nested tuple morphisms.
Definition 3.2.2.10.
Supposef:S→Tf:S\to Tis a nested tuple morphism. We sayffhasstandard formif
- 1.f♭f^{\flat}has standard form, as in Definition3.1.2.12, and
- 2.TTis flat.
Example 3.2.2.11.
The nested tuple morphism
((2,2),(3,3)){\lx@inpgf@ignorespaces((2,2),(3,3))}(10,3,3,2,10,2){\lx@inpgf@ignorespaces(10,3,3,2,10,2)}f\scriptstyle{\lx@inpgf@ignorespaces f}(4,6,2,3CLOSE\scriptstyle{\lx@inpgf@ignorespaces(4{,}6{,}2{,}3}has standard form.
Example 3.2.2.12.
The nested tuple morphism
((2,2),(3,3)){\lx@inpgf@ignorespaces((2,2),(3,3))}((10,3,3),(2,10,2)){\lx@inpgf@ignorespaces((10,3,3),(2,10,2))}f\scriptstyle{\lx@inpgf@ignorespaces f}(4,6,2,3CLOSE\scriptstyle{\lx@inpgf@ignorespaces(4{,}6{,}2{,}3}does not have standard form since the codomain ofggis not flat.
Just as in the flat case, we need to exclude non-degenerate nested tuple morphisms and non-degenerate layouts in order to obtain a one-to-one correspondence between nested tuple morphisms of standard form and tractable layouts. To this end, we make the following definition.
Definition 3.2.2.13.
Suppose
S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a nested tuple morphism, and suppose
is a layout.
- 1.We sayffisnon-degenerateif S)=1⇒α(i)=∗.S)=1\quad\Rightarrow\quad\alpha(i)=*.
- 2.We sayLLisnon-degenerateif S)=1⇒D)=0.S)=1\quad\Rightarrow\quad D)=0.
Proposition 3.2.2.15.
The maps
f{\lx@inpgf@ignorespaces f}Lf{\lx@inpgf@ignorespaces L_{f}}{Non-degeneratenested tuple morphismsof standard form}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ \text{nested tuple morphisms }\\ \text{ of standard form}\end{Bmatrix}}{Non-degeneratetractable layouts}{\lx@inpgf@ignorespaces\begin{Bmatrix}\text{Non-degenerate}\\ \text{tractable layouts}\end{Bmatrix}}fL{\lx@inpgf@ignorespaces f_{L}}L{\lx@inpgf@ignorespaces L}of Constructions3.2.2.2and3.2.2.6determine a one-to-one correspondence between nested tuple morphisms of standard form, and tractable layouts.
Proof.
We have already shown in Proposition3.2.2.9that ifLLis a tractable layout andf=fLf=f_{L}is the standard form ofLL, thenLf=LL_{f}=L. Suppose next thatffhas standard form, and letL=LfL=L_{f}be the layout encoded byff. We want to show thatffis equal to the standard representationfLf_{L}ofLL. By Proposition3.1.2.21, we know thatf♭f^{\flat}is equal to the standard representationfL♭f_{L^{\flat}}ofL♭L^{\flat}, and since
𝖽𝗈𝗆𝖺𝗂𝗇(f)=𝗌𝗁𝖺𝗉𝖾(L)=𝖽𝗈𝗆𝖺𝗂𝗇(fL),\mathsf{domain}(f)=\mathsf{shape}(L)=\mathsf{domain}(f_{L}),and
𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(f)=𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(f♭)=𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(fL♭)=𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(fL),\mathsf{codomain}(f)=\mathsf{codomain}(f^{\flat})=\mathsf{codomain}(f_{L^{\flat}})=\mathsf{codomain}(f_{L}),we deduce thatf=fLf=f_{L}. ∎
3.2.3Examples
In this section, we list some important families of nested tuple morphisms.
Example 3.2.3.1(Reparenthesizations).
SupposeS1S_{1}andS2S_{2}are nested tuples with the same flattening
S1♭=S2♭.S_{1}^{\flat}=S_{2}^{\flat}.Then there is areparenthesization isomorphism
𝗂𝖽S1S2:S1{\lx@inpgf@ignorespaces\mathsf{id}_{S_{1}}^{S_{2}}:S_{1}}S2{\lx@inpgf@ignorespaces S_{2}}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}lying over the identity. These morphisms are transitive, in that
𝗂𝖽S2S3∘𝗂𝖽S1S2=𝗂𝖽S1S3,\mathsf{id}_{S_{2}}^{S_{3}}\circ\mathsf{id}_{S_{1}}^{S_{2}}=\mathsf{id}_{S_{1}}^{S_{3}},and compatible with identities, in that
𝗂𝖽SS=𝗂𝖽S.\mathsf{id}_{S}^{S}=\mathsf{id}_{S}.Iff=𝗂𝖽S1S2f=\mathsf{id}_{S_{1}}^{S_{2}}is a reparenthesization isomorphism, thenLfL_{f}is the column major layout with shapeS1S_{1}.
Example 3.2.3.2(Flattenings).
As a special case of the previous example, ifSSis any nested tuple, then we have a flattening isomorphism
𝗂𝖽SS♭:S{\lx@inpgf@ignorespaces\mathsf{id}_{S}^{S^{\flat}}:S}S♭{\lx@inpgf@ignorespaces S^{\flat}}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}and an unflattening isomorphism
𝗂𝖽S♭S:S♭{\lx@inpgf@ignorespaces\mathsf{id}_{S^{\flat}}^{S}:S^{\flat}}S{\lx@inpgf@ignorespaces S}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}
Observation 3.2.3.3.
Iff:S→Tf:S\to Tis a nested tuple, thenffis equal to the composite
S{\lx@inpgf@ignorespaces S}S♭{\lx@inpgf@ignorespaces S^{\flat}}T♭{\lx@inpgf@ignorespaces T^{\flat}}T.{\lx@inpgf@ignorespaces T.}𝗂𝖽SS♭\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{S}^{S^{\flat}}}f\scriptstyle{\lx@inpgf@ignorespaces f}f♭\scriptstyle{\lx@inpgf@ignorespaces f^{\flat}}𝗂𝖽T♭T\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{T^{\flat}}^{T}}In other words, we have a canonical factorization
f=𝗂𝖽T♭T∘f♭∘𝗂𝖽SS♭.f=\mathsf{id}_{T^{\flat}}^{T}\circ f^{\flat}\circ\mathsf{id}_{S}^{S^{\flat}}.
Example 3.2.3.4(Entries).
Suppose
S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a nested tuple morphism. Suppose1≤i≤𝗅𝖾𝗇(S)1\leq i\leq\mathsf{len}(S), and writej=α(i)j=\alpha(i). Then we refer to the nested tuple morphism
OPENS){\lx@inpgf@ignorespaces S)}T{\lx@inpgf@ignorespaces T}OPENf)\scriptstyle{\lx@inpgf@ignorespaces f)}(j)\scriptstyle{\lx@inpgf@ignorespaces(j)}as theiith entry offf. The layout encoded byOPENf)f)is
OPENLOPENf)=Lf).L_{f)}=L_{f}).
Example 3.2.3.5(Entry inclusions).
As a special case of the previous example, ifSSis a nested tuple and1≤i≤𝗅𝖾𝗇(S)1\leq i\leq\mathsf{len}(S), we can takef=𝗂𝖽Sf=\mathsf{id}_{S}, in which case
OPENOPEN𝗂𝖽S):S){\lx@inpgf@ignorespaces\mathsf{id}_{S}):S)}S{\lx@inpgf@ignorespaces S}is the inclusion of theiith entry ofSS.
Example 3.2.3.6(Modes).
Suppose
S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f\scriptstyle{\lx@inpgf@ignorespaces f}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}is a nested tuple morphism. Suppose1≤i≤𝗋𝖺𝗇𝗄(S)1\leq i\leq\mathsf{rank}(S)and, write
N\displaystyle N=𝗅𝖾𝗇<i(S)\displaystyle=\mathsf{len}_{<i}(S)ℓ\displaystyle\ell=𝗅𝖾𝗇i(S).\displaystyle=\mathsf{len}_{i}(S).Then we refer to the nested tuple morphism
𝗆𝗈𝖽𝖾i(S){\lx@inpgf@ignorespaces\mathsf{mode}_{i}(S)}T{\lx@inpgf@ignorespaces T}𝗆𝗈𝖽𝖾i(f)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{mode}_{i}(f)}(N+1,…,N+ℓ)\scriptstyle{\lx@inpgf@ignorespaces(N+1{,}\dots{,}N+\ell)}as theiith mode ofSS. The layout encoded by𝗆𝗈𝖽𝖾i(Lf)\mathsf{mode}_{i}(L_{f})is
L𝗆𝗈𝖽𝖾i(f)=𝗆𝗈𝖽𝖾i(Lf).L_{\mathsf{mode}_{i}(f)}=\mathsf{mode}_{i}(L_{f}).
Example 3.2.3.7(Mode inclusions).
As a special case of the previous example we may takef=𝗂𝖽Sf=\mathsf{id}_{S}, in which case
𝗆𝗈𝖽𝖾i(𝗂𝖽S):𝗆𝗈𝖽𝖾i(S)→S\mathsf{mode}_{i}(\mathsf{id}_{S}):\mathsf{mode}_{i}(S)\to Sis the inclusion of theiith mode ofSS. We sometime denote this map by
𝗂𝗇𝖼𝗅i(S)=𝗆𝗈𝖽𝖾i(𝗂𝖽S).\mathsf{incl}_{i}(S)=\mathsf{mode}_{i}(\mathsf{id}_{S}).
3.2.4Realization of nested tuple morphisms
In the flat case, we constructed a realization functor
𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗙𝗶𝗻𝗦𝗲𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{FinSet}}}}|⋅|\scriptstyle{\lx@inpgf@ignorespaces{|}\;\cdot\;{|}}which sends a tuple morphismffto the layout function ofLfL_{f}. We can extend this to a realization functor
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗙𝗶𝗻𝗦𝗲𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{FinSet}}}}|⋅|\scriptstyle{\lx@inpgf@ignorespaces{|}\;\cdot\;{|}}by precomposing with the flattening functor𝗡𝗲𝘀𝘁→𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Nest}}}\to{\boldsymbol{\mathsf{Tuple}}}.
Definition 3.2.4.1.
We define therealization functor
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗙𝗶𝗻𝗦𝗲𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{FinSet}}}}|⋅|\scriptstyle{\lx@inpgf@ignorespaces{|}\;\cdot\;{|}}to be the composite
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗧𝘂𝗽𝗹𝗲{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Tuple}}}}𝗙𝗶𝗻𝗦𝗲𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{FinSet}}}}(−)♭\scriptstyle{\lx@inpgf@ignorespaces(-)^{\flat}}|⋅|\scriptstyle{\lx@inpgf@ignorespaces{|}\;\cdot\;{|}}
Lemma 3.2.4.2.
Iff:S→Tf:S\to Tis a nested tuple morphism, then the realization|f||f|offfis the layout function ofLfL_{f}:
|f|=ΦLf𝗌𝗂𝗓𝖾(T).|f|=\Phi_{L_{f}}^{\mathsf{size}(T)}.
Proof.
This follows immediately from3.1.4.5, since
|f|=|f♭|=ΦLf♭𝗌𝗂𝗓𝖾(T)=ΦLf𝗌𝗂𝗓𝖾(T)|f|=|f^{\flat}|=\Phi_{L_{f^{\flat}}}^{\mathsf{size}(T)}=\Phi_{L_{f}}^{\mathsf{size}(T)}∎
3.2.5Refinements
In this section, we revisit the refinement of nested tuples from a categorical perspective. Recall from section2.2.4that a nested tupleS′S^{\prime}refinesSS, denoted
S′{\lx@inpgf@ignorespaces S^{\prime}}S{\lx@inpgf@ignorespaces S}ifS′S^{\prime}may be obtained fromSSby replacing each entry ofSSwith some nested tuple of the same size. For example,
(2,(2,2))↠8,(2,(2,2))\twoheadrightarrow 8,and
((2,2),(3,3),(5,5))↠(4,9,25).((2,2),(3,3),(5,5))\twoheadrightarrow(4,9,25).If𝗅𝖾𝗇(S)=m\mathsf{len}(S)=mand𝗉𝗋𝗈𝖿(S)=P\mathsf{prof}(S)=P, then we can write
S′=(S1′,…,Sm′)PS^{\prime}=(S_{1}^{\prime},\dots,S_{m}^{\prime})_{P}as thePP-substitution of the relative modes
Si′=𝗆𝗈𝖽𝖾i(S′,S).S_{i}^{\prime}=\mathsf{mode}_{i}(S^{\prime},S).We refer to the ordinary concatenation
(S1′,…,Sm′)=𝖿𝗅𝖺𝗍(S′,S)(S_{1}^{\prime},\dots,S_{m}^{\prime})=\mathsf{flat}(S^{\prime},S)as the flattening ofS′S^{\prime}relative toSS.
Let𝗥𝗲𝗳{\boldsymbol{\mathsf{Ref}}}denote the poset category of nested tuples of positive integers under refinement, so that a morphism in𝗥𝗲𝗳{\boldsymbol{\mathsf{Ref}}}is a refinementS′↠SS^{\prime}\twoheadrightarrow S. IfSSis a nested tuple, let
𝗥𝗲𝗳(S)={S′∣S′refinesS}{\boldsymbol{\mathsf{Ref}}}(S)=\{S^{\prime}\mid S^{\prime}\text{ refines }S\}denote the poset of nested tuples refiningSS. Equivalently,𝗥𝗲𝗳(S){\boldsymbol{\mathsf{Ref}}}(S)is the slice category𝗥𝗲𝗳/S{\boldsymbol{\mathsf{Ref}}}_{/S}.
Construction 3.2.5.1.
[Relative mode inclusions] SupposeS′↠SS^{\prime}\twoheadrightarrow Sis a refinement, and write
Si′=𝗆𝗈𝖽𝖾i(S′,S)S_{i}^{\prime}=\mathsf{mode}_{i}(S^{\prime},S)for the modes ofS′S^{\prime}relative toSS. ThenS′S^{\prime}and(S1′,…,Sm′)(S_{1}^{\prime},\dots,S_{m}^{\prime})have the same flattening, so we have a reparenthesization isomorphism
𝗂𝖽(S1′,…,Sm′)S′:(S1′,…,Sm′){\lx@inpgf@ignorespaces\mathsf{id}_{(S_{1}^{\prime},\dots,S_{m}^{\prime})}^{S^{\prime}}:(S_{1}^{\prime},\dots,S_{m}^{\prime})}S′{\lx@inpgf@ignorespaces S^{\prime}}≅\scriptstyle{\lx@inpgf@ignorespaces\cong}and we define
𝗂𝗇𝖼𝗅i(S′,S):Si′→S′\mathsf{incl}_{i}(S^{\prime},S):S_{i}^{\prime}\to S^{\prime}to be the composite
Si′{\lx@inpgf@ignorespaces S_{i}^{\prime}}(S1′,…,Sm′){\lx@inpgf@ignorespaces(S_{1}^{\prime},\dots,S_{m}^{\prime})}S′{\lx@inpgf@ignorespaces S^{\prime}}𝗂𝗇𝖼𝗅i((,,,,,))\scriptstyle{\lx@inpgf@ignorespaces\mathsf{incl}_{i}((S_{1}^{\prime}{,}\dots{,}S_{m}^{\prime}))}𝗂𝖽(S1′,…,Sm′)S′\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{(S_{1}^{\prime},\dots,S_{m}^{\prime})}^{S^{\prime}}}of theiith mode inclusion of(S1′,…,Sm′)(S_{1}^{\prime},\dots,S_{m}^{\prime})with the reparenthesization isomorphism(S1′,…,Sm′)≅S′(S_{1}^{\prime},\dots,S_{m}^{\prime})\cong S^{\prime}.
Example 3.2.5.2.
IfS=(4,(9,25))S=(4,(9,25))andS′=((2,2),((3,3),25))S^{\prime}=((2,2),((3,3),25)), thenS′S^{\prime}refinesSS, and𝗂𝗇𝖼𝗅2(S′,S)\mathsf{incl}_{2}(S^{\prime},S)is the nested tuple morphism
(3,3){\lx@inpgf@ignorespaces(3,3)}((2,2),((3,3),25)).{\lx@inpgf@ignorespaces((2,2),((3,3),25)).}𝗂𝗇𝖼𝗅2(S′,S)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{incl}_{2}(S^{\prime}{,}S)}(3,4)\scriptstyle{\lx@inpgf@ignorespaces(3{,}4)}
Construction 3.2.5.3.
[Relative modes] Supposef′:S′→T′f^{\prime}:S^{\prime}\to T^{\prime}is a nested tuple morphism, and supposeS′S^{\prime}refinesSS. We define theiith mode off′f^{\prime}relative toSS, denoted
𝗆𝗈𝖽𝖾i(f′,S)=f′∘𝗂𝗇𝖼𝗅i(S′,S):Si′→T′\mathsf{mode}_{i}(f^{\prime},S)=f^{\prime}\circ\mathsf{incl}_{i}(S^{\prime},S):S_{i}^{\prime}\to T^{\prime}to be the composite
Si′{\lx@inpgf@ignorespaces S_{i}^{\prime}}S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}𝗂𝗇𝖼𝗅i(S′,S)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{incl}_{i}(S^{\prime}{,}S)}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}In particular, we have
𝗆𝗈𝖽𝖾i(𝗂𝖽S′,S)=𝗂𝗇𝖼𝗅i(S′,S).\mathsf{mode}_{i}(\mathsf{id}_{S^{\prime}},S)=\mathsf{incl}_{i}(S^{\prime},S).
Example 3.2.5.4.
SupposeS=(4,(9,25))S=(4,(9,25))andS′=((2,2),((3,3),25))S^{\prime}=((2,2),((3,3),25)), so thatS′S^{\prime}refinesSS. Iff′f^{\prime}is the nested tuple morphism
((2,2),((3,3),25)){\lx@inpgf@ignorespaces((2,2),((3,3),25))}(2,3,2,25).{\lx@inpgf@ignorespaces(2,3,2,25).}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}(1,3,2,∗,4)\scriptstyle{\lx@inpgf@ignorespaces(1{,}3{,}2{,}*{,}4)}then𝗆𝗈𝖽𝖾2(f′,S)\mathsf{mode}_{2}(f^{\prime},S)is the nested tuple morphism
(3,3){\lx@inpgf@ignorespaces(3,3)}(2,3,2,25).{\lx@inpgf@ignorespaces(2,3,2,25).}𝗆𝗈𝖽𝖾2(f′,S)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{mode}_{2}(f^{\prime}{,}S)}(2,∗)\scriptstyle{\lx@inpgf@ignorespaces(2{,}*)}
Construction 3.2.5.5(Pullbacks).
Supposef:S→Tf:S\to Tis a nested tuple morphism lying overα\alpha, and supposeT′↠TT^{\prime}\twoheadrightarrow Tis a refinement. Let
Tj′=𝗆𝗈𝖽𝖾j(T′,T)T_{j}^{\prime}=\mathsf{mode}_{j}(T^{\prime},T)denote thejjth mode ofT′T^{\prime}relative toTT, and for any1≤i≤𝗅𝖾𝗇(S)1\leq i\leq\mathsf{len}(S), set
Si′={OPENS)α(i)=∗Tj′α(i)=j.S_{i}^{\prime}=\begin{cases}S)&\alpha(i)=*\\ T^{\prime}_{j}&\alpha(i)=j.\end{cases}We define thepullback ofT′T^{\prime}alongffto be the nested tuple
S′=f∗T′=𝗌𝗎𝖻(S,(S1′,…,Sm′)).S^{\prime}=f^{*}T^{\prime}=\mathsf{sub}(S,(S_{1}^{\prime},\dots,S_{m}^{\prime})).For any1≤i≤m1\leq i\leq m, let
fi′:Si′→T′f_{i}^{\prime}:S_{i}^{\prime}\to T^{\prime}be the trivial map ifα(i)=∗\alpha(i)=*, and the inclusion
𝗂𝗇𝖼𝗅j(T′,T):Si′=Tj′→T′\mathsf{incl}_{j}(T^{\prime},T):S_{i}^{\prime}=T_{j}^{\prime}\to T^{\prime}ifα(i)=j\alpha(i)=j. The mapsf1′,…,fm′f_{1}^{\prime},\dots,f_{m}^{\prime}have disjoint images, so we form the concatenation
(f1′,…,fm′):(S1′,…,Sm′)→T′.(f_{1}^{\prime},\dots,f_{m}^{\prime}):(S_{1}^{\prime},\dots,S_{m}^{\prime})\to T^{\prime}.We definef′=T′∗ff^{\prime}=T^{\prime*}fto be the composite
S′{\lx@inpgf@ignorespaces S^{\prime}}(S1′,…,Sm′){\lx@inpgf@ignorespaces(S_{1}^{\prime},\dots,S_{m}^{\prime})}T′.{\lx@inpgf@ignorespaces T^{\prime}.}𝗂𝖽S′(S1′,…,Sm′)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{S^{\prime}}^{(S_{1}^{\prime}{,}\dots{,}S_{m}^{\prime})}}(f1′,…,fm′)\scriptstyle{\lx@inpgf@ignorespaces(f_{1}^{\prime}{,}\dots{,}f_{m}^{\prime})}We refer tof′f^{\prime}as the pullback offfalongTT, and depict such a pullback as a square
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T.{\lx@inpgf@ignorespaces T.}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌟{\lx@inpgf@ignorespaces\lrcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}
Example 3.2.5.6.
Supposef:(64,32)→(4,64,4,32)f:(64,32)\to(4,64,4,32)lies overα=(2,4)\alpha=(2,4). Then we have a pullback square
((16,4),(16,2)){\lx@inpgf@ignorespaces((16,4),(16,2))}((2,2),(16,4),(2,2),(16,2)){\lx@inpgf@ignorespaces((2,2),(16,4),(2,2),(16,2))}(64,32){\lx@inpgf@ignorespaces(64,32)}(4,64,4,32){\lx@inpgf@ignorespaces(4,64,4,32)}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌟{\lx@inpgf@ignorespaces\lrcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}wheref′f^{\prime}lies overα′=(3,4,7,8)\alpha^{\prime}=(3,4,7,8).
Example 3.2.5.7.
SupposeSSis a nested tuple with flattening
S♭=(s1,…,sm),S^{\flat}=(s_{1},\dots,s_{m}),and supposeS′↠SS^{\prime}\twoheadrightarrow Sis a refinement with relative flattening
(S1′,…,Sm′).(S_{1}^{\prime},\dots,S_{m}^{\prime}).Then the pullback ofS′↠SS^{\prime}\twoheadrightarrow Salong the unflattening isomorphism
𝗂𝖽(s1,…,sm)S:(s1,…,sm)→S\mathsf{id}_{(s_{1},\dots,s_{m})}^{S}:(s_{1},\dots,s_{m})\to Sis the reparenthesization isomorphism
(S1′,…,Sm′){\lx@inpgf@ignorespaces(S_{1}^{\prime},\dots,S_{m}^{\prime})}S′{\lx@inpgf@ignorespaces S^{\prime}}(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}S.{\lx@inpgf@ignorespaces S.}𝗂𝖽(S1′,…,Sm′)S′\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{(S_{1}^{\prime}{,}\dots{,}S_{m}^{\prime})}^{S^{\prime}}}⌟{\lx@inpgf@ignorespaces\lrcorner}𝗂𝖽(s1,…,sm)S\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{(s_{1}{,}\dots{,}s_{m})}^{S}}
Example 3.2.5.8.
SupposeS′↠SS^{\prime}\twoheadrightarrow Sis a refinement, and consider theiith entry inclusion
Then the pullback ofS′↠SS^{\prime}\twoheadrightarrow Salongsi→Ss_{i}\to Sis theiith relative mode inclusion
Si′{\lx@inpgf@ignorespaces S_{i}^{\prime}}S′{\lx@inpgf@ignorespaces S^{\prime}}si{\lx@inpgf@ignorespaces s_{i}}S.{\lx@inpgf@ignorespaces S.}𝗂𝗇𝖼𝗅i(S′,S)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{incl}_{i}(S^{\prime}{,}S)}⌟{\lx@inpgf@ignorespaces\lrcorner}
Observation 3.2.5.9.
The pullback construction above specifies a contravariant functor
𝗡𝗲𝘀𝘁op{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}^{\text{op}}}𝗖𝗮𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Cat}}}}S{\lx@inpgf@ignorespaces S}𝗥𝗲𝗳(S){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(S)}f∗T′←f∗T′′{\lx@inpgf@ignorespaces f^{*}T^{\prime}\leftarrow f^{*}T^{\prime\prime}}T{\lx@inpgf@ignorespaces T}𝗥𝗲𝗳(T){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(T)}T′←T′′{\lx@inpgf@ignorespaces T^{\prime}\leftarrow T^{\prime\prime}}f\scriptstyle{\lx@inpgf@ignorespaces f}f∗\scriptstyle{\lx@inpgf@ignorespaces f^{*}}
The key property of pullbacks is that the layout function off′f^{\prime}is equal to that offf.
Lemma 3.2.5.10.
Suppose
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌟{\lx@inpgf@ignorespaces\lrcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}is a pullback square, wherefflies overα\alpha. Let
fi′:Si′→Tf_{i}^{\prime}:S_{i}^{\prime}\to Tdenote theiith mode off′f^{\prime}relative toSS, and let
(Lf)♭=(s1,…,sm):(d1,…,dm).(L_{f})^{\flat}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Then for any1≤i≤m1\leq i\leq m, we have
𝖼𝗈𝖺𝗅(Lfi′)=si:di.\mathsf{coal}(L_{f_{i}^{\prime}})=s_{i}:d_{i}.
Proof.
Suppose1≤i≤m1\leq i\leq m. Ifα(i)=∗\alpha(i)=*, thenfi′f_{i}^{\prime}is the trivial map, so
Lfi′=si:0=si:di.L_{f_{i}^{\prime}}=s_{i}:0=s_{i}:d_{i}.In particular,𝖼𝗈𝖺𝗅(Lfi′)=si:0=si:di\mathsf{coal}(L_{f_{i}^{\prime}})=s_{i}:0=s_{i}:d_{i}. Suppose next thatα(i)=j≠∗\alpha(i)=j\neq*. By construction off′f^{\prime}, we have that
fi′=𝗂𝗇𝖼𝗅j(T′,T):Tj′→T′.f_{i}^{\prime}=\mathsf{incl}_{j}(T^{\prime},T):T_{j}^{\prime}\to T^{\prime}.which lies over the mapαi′\alpha^{\prime}_{i}given byt↦𝗅𝖾𝗇<j(T′,T)+tt\mapsto\mathsf{len}_{<j}(T^{\prime},T)+t. For each1≤t<𝗅𝖾𝗇(Tj′)1\leq t<\mathsf{len}(T^{\prime}_{j}), we haveαi′(t)=αi′(t+1)\alpha^{\prime}_{i}(t)=\alpha^{\prime}_{i}(t+1), soLfi′L_{f_{i}^{\prime}}is a column major layout with size𝗌𝗂𝗓𝖾(Tj′)=tj=si\mathsf{size}(T_{j}^{\prime})=t_{j}=s_{i}. This implies that𝖼𝗈𝖺𝗅(Lfi′)\mathsf{coal}(L_{f_{i}^{\prime}})is a depth00layout of the form
𝖼𝗈𝖺𝗅(Lfi′)=si:e\mathsf{coal}(L_{f_{i}^{\prime}})=s_{i}:efor some integere≥0e\geq 0. We claim thate=die=d_{i}. If we writeOPENtj′′=T′)t_{j^{\prime}}^{\prime}=T^{\prime}), then we have
OPENe=𝗌𝗍𝗋𝗂𝖽𝖾(Lfi′))\displaystyle e=\mathsf{stride}(L_{f_{i}^{\prime}}))=∏j′<αi′(1)tj′′\displaystyle=\prod_{j^{\prime}<\alpha_{i}^{\prime}(1)}t_{j^{\prime}}^{\prime}=∏j′≤𝗅𝖾𝗇<j(T′,T)tj′′\displaystyle=\prod_{j^{\prime}\leq\mathsf{len}_{<j}(T^{\prime},T)}t_{j^{\prime}}^{\prime}=∏j′<j𝗌𝗂𝗓𝖾(Tj′′)\displaystyle=\prod_{j^{\prime}<j}\mathsf{size}(T_{j^{\prime}}^{\prime})=∏j′<jtj′\displaystyle=\prod_{j^{\prime}<j}t_{j^{\prime}}=di.\displaystyle=d_{i}.∎
Proposition 3.2.5.11.
If
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌟{\lx@inpgf@ignorespaces\lrcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}is a pullback square, thenΦLf=ΦLf′\Phi_{L_{f}}=\Phi_{L_{f^{\prime}}}.
Proof.
We begin by fixing notation. Letm=𝗅𝖾𝗇(S)m=\mathsf{len}(S), and let
S♭\displaystyle S^{\flat}=(s1,…,sm),\displaystyle=(s_{1},\dots,s_{m}),Si′\displaystyle S_{i}^{\prime}=𝗆𝗈𝖽𝖾i(S′,S),\displaystyle=\mathsf{mode}_{i}(S^{\prime},S),Tj′\displaystyle T_{j}^{\prime}=𝗆𝗈𝖽𝖾j(T′,T),\displaystyle=\mathsf{mode}_{j}(T^{\prime},T),(Lf)♭\displaystyle(L_{f})^{\flat}=(s1,…,sm):(d1,…,dm).\displaystyle=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Consider the reparenthesization isomorphism
𝗂𝖽(S1′,…,Sm′)S′:(S1′,…,Sm′)→S′\mathsf{id}_{(S_{1}^{\prime},\dots,S_{m}^{\prime})}^{S^{\prime}}:(S_{1}^{\prime},\dots,S_{m}^{\prime})\to S^{\prime}The composite of this map withf′f^{\prime}is the concatenation(f1′,…,fm′)(f_{1}^{\prime},\dots,f_{m}^{\prime})wherefi′f_{i}^{\prime}is the trivial map ifα(i)=∗\alpha(i)=*, and the relative mode inclusion
𝗂𝗇𝖼𝗅i(T′,T):Si′=Tj′→T′\mathsf{incl}_{i}(T^{\prime},T):S_{i}^{\prime}=T_{j}^{\prime}\to T^{\prime}otherwise. Using Lemma3.2.5.10, and the fact thatLf′=L(f1′,…,fm′)L_{f^{\prime}}=L_{(f_{1}^{\prime},\dots,f_{m}^{\prime})}, we compute
𝖼𝗈𝖺𝗅(Lf′)\displaystyle\mathsf{coal}(L_{f^{\prime}})=𝖼𝗈𝖺𝗅(L(f1′,…,fm′))\displaystyle=\mathsf{coal}(L_{(f_{1}^{\prime},\dots,f_{m}^{\prime})})=𝖼𝗈𝖺𝗅((,,,,,))\displaystyle=\mathsf{coal}((L_{f_{1}^{\prime}},\dots,L_{f_{m}^{\prime}}))=𝖼𝗈𝖺𝗅((,,,,,))\displaystyle=\mathsf{coal}((\mathsf{coal}(L_{f_{1}^{\prime}}),\dots,\mathsf{coal}(L_{f_{m}^{\prime}})))=𝖼𝗈𝖺𝗅((s1,…,sm):(d1,…,dm))\displaystyle=\mathsf{coal}((s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}))=𝖼𝗈𝖺𝗅(Lf).\displaystyle=\mathsf{coal}(L_{f}).By Proposition2.3.3.14, we deduce thatΦLf′=ΦLf\Phi_{L_{f^{\prime}}}=\Phi_{L_{f}}. ∎
Construction 3.2.5.12(Pushforwards).
Supposef:S→Tf:S\to Tis a nested tuple morphism lying overα\alpha, and supposeS′↠SS^{\prime}\twoheadrightarrow Sis a refinement. Let
Si′=𝗆𝗈𝖽𝖾i(S′,S)S_{i}^{\prime}=\mathsf{mode}_{i}(S^{\prime},S)denote theiith mode ofS′S^{\prime}relative toSS, and for any1≤j≤𝗅𝖾𝗇(T)1\leq j\leq\mathsf{len}(T), set
Tj′={OPENT)j∉𝖨𝗆𝖺𝗀𝖾(α)Si′α(i)=j.T_{j}^{\prime}=\begin{cases}T)&j\notin\mathsf{Image}(\alpha)\\ S^{\prime}_{i}&\alpha(i)=j.\end{cases}We define thepushforward ofS′S^{\prime}alongffto be the nested tuple
T′=f∗S′=𝗌𝗎𝖻(T,(T1′,…,Tn′)).T^{\prime}=f_{*}S^{\prime}=\mathsf{sub}(T,(T_{1}^{\prime},\dots,T_{n}^{\prime})).For any1≤i≤m1\leq i\leq m, let
fi′:Si′→T′f_{i}^{\prime}:S_{i}^{\prime}\to T^{\prime}be the trivial map ifα(i)=∗\alpha(i)=*, and the relative mode inclusion
𝗂𝗇𝖼𝗅j(T′,T):Si′=Tj′→T′\mathsf{incl}_{j}(T^{\prime},T):S_{i}^{\prime}=T_{j}^{\prime}\to T^{\prime}ifα(i)=j\alpha(i)=j. The morphismsf1′,…,fm′f_{1}^{\prime},\dots,f_{m}^{\prime}have disjoint images, so we can form the concatenation
(f1′,…,fm′):(S1′,…,Sm′)→T′.(f_{1}^{\prime},\dots,f_{m}^{\prime}):(S_{1}^{\prime},\dots,S_{m}^{\prime})\to T^{\prime}.We definef′=S∗′ff^{\prime}=S^{\prime}_{*}fto be the composite
S′{\lx@inpgf@ignorespaces S^{\prime}}(S1′,…,Sm′){\lx@inpgf@ignorespaces(S_{1}^{\prime},\dots,S_{m}^{\prime})}T′.{\lx@inpgf@ignorespaces T^{\prime}.}𝗂𝖽S′(S1′,…,Sm′)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{S^{\prime}}^{(S_{1}^{\prime}{,}\dots{,}S_{m}^{\prime})}}(f1′,…,fm′)\scriptstyle{\lx@inpgf@ignorespaces(f_{1}^{\prime}{,}\dots{,}f_{m}^{\prime})}We refer tof′f^{\prime}as the pushforward offfalongTT. We depict such a pushforward as
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌞{\lx@inpgf@ignorespaces\llcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}
Example 3.2.5.13.
Iff:(64,32)→(4,64,4,32)f:(64,32)\to(4,64,4,32)lies overα=(2,4)\alpha=(2,4), then we have a pushforward square
((16,4),(16,2)){\lx@inpgf@ignorespaces((16,4),(16,2))}(4,(16,4),4,(16,2)){\lx@inpgf@ignorespaces(4,(16,4),4,(16,2))}(64,32){\lx@inpgf@ignorespaces(64,32)}(4,64,4,32){\lx@inpgf@ignorespaces(4,64,4,32)}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌞{\lx@inpgf@ignorespaces\llcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}
The key property of pullbacks is that the layout function off′f^{\prime}is equal to that offf.
Lemma 3.2.5.14.
Suppose
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌞{\lx@inpgf@ignorespaces\llcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}is a pushforward square, wherefflies overα\alpha. Let
fi′:Si′→Tf_{i}^{\prime}:S_{i}^{\prime}\to Tdenote theiith mode off′f^{\prime}relative toSS, and let
(Lf)♭=(s1,…,sm):(d1,…,dm).(L_{f})^{\flat}=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m}).Then for any1≤i≤m1\leq i\leq m, we have
𝖼𝗈𝖺𝗅(Lfi′)=si:di.\mathsf{coal}(L_{f_{i}^{\prime}})=s_{i}:d_{i}.
Proof.
The proof is identical to that of Lemma3.2.5.10∎
Proposition 3.2.5.15.
If
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}⌞{\lx@inpgf@ignorespaces\llcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}is a pushforward square, thenΦLf=ΦLf′\Phi_{L_{f}}=\Phi_{L_{f^{\prime}}}.
Proof.
The proof is identical to that of Proposition3.2.5.11. ∎
Observation 3.2.5.16.
The pushforward construction defined above specifies a covariant functor
𝗡𝗲𝘀𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Nest}}}}𝗖𝗮𝘁{\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Cat}}}}S{\lx@inpgf@ignorespaces S}𝗥𝗲𝗳(S){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(S)}S′′→S′{\lx@inpgf@ignorespaces S^{\prime\prime}\rightarrow S^{\prime}}T{\lx@inpgf@ignorespaces T}𝗥𝗲𝗳(T){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(T)}f∗S′′→f∗S′{\lx@inpgf@ignorespaces f_{*}S^{\prime\prime}\rightarrow f_{*}S^{\prime}}f\scriptstyle{\lx@inpgf@ignorespaces f}f∗\scriptstyle{\lx@inpgf@ignorespaces f_{*}}
Observation 3.2.5.17.
Iff:S→Tf:S\to Tis an isomorphism of nested tuples, then
𝗥𝗲𝗳(T){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(T)}𝗥𝗲𝗳(S){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(S)}f∗\scriptstyle{\lx@inpgf@ignorespaces f^{*}}and
𝗥𝗲𝗳(S){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(S)}𝗥𝗲𝗳(T){\lx@inpgf@ignorespaces{\boldsymbol{\mathsf{Ref}}}(T)}f∗\scriptstyle{\lx@inpgf@ignorespaces f_{*}}are inverse isomorphisms of categories. Specifically,
(f−1)∗=f∗and(f−1)∗=f∗.(f^{-1})^{*}=f_{*}\hskip 14.45377pt\text{and}\hskip 14.45377pt(f^{-1})_{*}=f^{*}.
Observation 3.2.5.18.
IfS1S_{1}andS2S_{2}are nested tuples with𝖿𝗅𝖺𝗍(S1)=𝖿𝗅𝖺𝗍(S2)\mathsf{flat}(S_{1})=\mathsf{flat}(S_{2}), then there is a canonical nested tuple isomorphismS1≅S2S_{1}\cong S_{2}, and hence, a canonical isomorphism of categories
𝗥𝗲𝗳(S1)≅𝗥𝗲𝗳(S2).{\boldsymbol{\mathsf{Ref}}}(S_{1})\cong{\boldsymbol{\mathsf{Ref}}}(S_{2}).
There is one more concept we need to specify, calledmutual refinements. The importance of this concept will be come clear in Chapter4, when we use this concept in our layout composition algorithm.
Definition 3.2.5.19.
SupposeTTandUUare nested tuples. Amutual refinementof(T,U)(T,U)is a diagram of the form
T′{\lx@inpgf@ignorespaces T^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}Explicitly, this is a pair of nested tuples(T′,U′)(T^{\prime},U^{\prime})such that
- 1.T′T^{\prime}refinesTT,
- 2.U′U^{\prime}refinesUU, and
- 3.T′T^{\prime}dividesU′U^{\prime}.
In addition to the definition of mutual refinements, we need the following fact.
Lemma 3.2.5.20.
SupposeTTandUUare nested tuples. Then there is a one-to-one correspondence between mutual refinements of(T,U)(T,U), and mutual refinements of(T♭,U♭)(T^{\flat},U^{\flat}).
Proof.
If(T′,U′)(T^{\prime},U^{\prime})is a mutual refinement of(T,U)(T,U), then pulling back along the unflattening isomorphisms𝗂𝖽T♭T\mathsf{id}_{T^{\flat}}^{T}and𝗂𝖽U♭U\mathsf{id}_{U^{\flat}}^{U}yields a mutual refinement
(𝗂𝖽T♭T)∗T′{\lx@inpgf@ignorespaces(\mathsf{id}_{T^{\flat}}^{T})^{*}T^{\prime}}(𝗂𝖽U♭U)∗U′{\lx@inpgf@ignorespaces(\mathsf{id}_{U^{\flat}}^{U})^{*}U^{\prime}}T♭{\lx@inpgf@ignorespaces T^{\flat}}U♭{\lx@inpgf@ignorespaces U^{\flat}}of(T♭,U♭)(T^{\flat},U^{\flat}). Conversely, if((T♭)′,(U♭)′)((T^{\flat})^{\prime},(U^{\flat})^{\prime})is a mutual refinement ofT♭,U♭T^{\flat},U^{\flat}, then pulling back along the flattening isomorphisms𝗂𝖽TT♭\mathsf{id}^{T^{\flat}}_{T}and𝗂𝖽UU♭\mathsf{id}^{U^{\flat}}_{U}yields a mutual refinement
(𝗂𝖽TT♭)∗(T♭)′{\lx@inpgf@ignorespaces(\mathsf{id}^{T^{\flat}}_{T})^{*}(T^{\flat})^{\prime}}(𝗂𝖽UU♭)∗(U♭)′{\lx@inpgf@ignorespaces(\mathsf{id}^{U^{\flat}}_{U})^{*}(U^{\flat})^{\prime}}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}of(T♭,U♭)(T^{\flat},U^{\flat}). ∎
3.2.6Operations on nested tuple morphisms
Our next task is to develop an “algebra of nested tuple morphisms”. Since we have already developed such an “algebra” for tuple morphisms, we can extend to the nested case by equipping the outputs of our various operations with an appropriate profile.
3.2.6.1Concatenate
Next, we define a concatenation operation on nested tuple morphisms, which is compatible with concatenation of layouts, in that
L(f,g)=(Lf,Lg).L_{(f,g)}=(L_{f},L_{g}).We concatenate nested tuple morphismsffandggby concatenating the domains offfandgg. In order for this to be well-defined, we needffandggto satisfy a disjointness condition, which we specify below.
Definition 3.2.6.1.
Supposeffandggare nested tuple morphisms with the same codomain. We sayffandgghavedisjoint imagesiff♭f^{\flat}andg♭g^{\flat}have disjoint images, as in Definition3.1.5.32.
Example 3.2.6.2.
If
f:(3,(512,512))→(2,512,2,512)f:(3,(512,512))\to(2,512,2,512)lies over(∗,2,4)(*,2,4)and
g:(2,2)→(2,512,2,512)g:(2,2)\to(2,512,2,512)lies over(1,3)(1,3), thenffandgghave disjoint images.
Example 3.2.6.3.
If
f:(2,(32,64))→(32,(2,2,2),64)f:(2,(32,64))\to(32,(2,2,2),64)lies overα=(3,1,5)\alpha=(3,1,5)and
g:((2,2))→(32,(2,2,2),64)g:((2,2))\to(32,(2,2,2),64)lies overβ=(2,4)\beta=(2,4), thenffandgghave disjoint images.
Construction 3.2.6.4.
Supposef:S→Tf:S\to Tandg:U→Tg:U\to Tare nested tuple morphisms lying overα\alphaandβ\beta, respectively, and thatffandgghave disjoint images. We define theconcatenationofffandggto be the nested tuple morphism
(f,g):(S,U)→T(f,g):(S,U)\to Twith
𝖿𝗅𝖺𝗍((,,,))\displaystyle\mathsf{flat}((f,g))=f♭⋆g♭.\displaystyle=f^{\flat}\star g^{\flat}.More generally, iffi:Si→Tf_{i}:S_{i}\to Tare nested tuple morphisms for1≤i≤k1\leq i\leq k, andf1,…,fkf_{1},\dots,f_{k}have pairwise disjoint images, then we define theconcatenation
(f1,…,fk):(S1,…,Sk)→T.(f_{1},\dots,f_{k}):(S_{1},\dots,S_{k})\to T.to be the nested tuple morphism with
(f1,…,fk)♭\displaystyle(f_{1},\dots,f_{k})^{\flat}=f1♭⋆⋯⋆fk♭.\displaystyle=f_{1}^{\flat}\star\cdots\star f_{k}^{\flat}.
Example 3.2.6.5.
The concatenation of the morphismsffandggof Example3.2.6.2is the nested tuple morphism
(f,g):((3,(512,512)),(2,2))→(2,512,2,512)(f,g):\left((3,(512,512)),(2,2)\right)\to(2,512,2,512)lying overα⋆β=(∗,2,4,1,3)\alpha\star\beta=(*,2,4,1,3).
Example 3.2.6.6.
The concatenation of the morphismsffandggof Example3.2.6.3is the nested tuple morphism
(f,g):((2,(32,64)),((2,2)))→(32,(2,2,2),64)(f,g):((2,(32,64)),((2,2)))\to(32,(2,2,2),64)lying overα⋆β=(3,1,5,2,4)\alpha\star\beta=(3,1,5,2,4).
Example 3.2.6.7.
If
f:(2,2)→(2,3,5,2,3,5)f:(2,2)\to(2,3,5,2,3,5)lies overα=(1,4)\alpha=(1,4)
g:(3,3)→(2,3,5,2,3,5)g:(3,3)\to(2,3,5,2,3,5)lies overβ=(2,5)\beta=(2,5), and
h:(5,5)→(2,3,5,2,3,5)h:(5,5)\to(2,3,5,2,3,5)lies overγ=(3,6)\gamma=(3,6), thenff,ggandhhhave pairwise disjoint images, and the concatenation
(f,g,h):((2,2),(3,3),(5,5))→(2,3,5,2,3,5)(f,g,h):((2,2),(3,3),(5,5))\to(2,3,5,2,3,5)lies overα⋆β⋆γ=(1,4,2,5,3,6)\alpha\star\beta\star\gamma=(1,4,2,5,3,6).
Example 3.2.6.8.
Supposef:S→Tf:S\to Tis a nested tuple morphism, and suppose
S♭=(s1,…,sm).S^{\flat}=(s_{1},\dots,s_{m}).Recall from example3.2.3.4that for any1≤i≤m1\leq i\leq m, there is a nested tuple morphism
fi:si→T.f_{i}:s_{i}\to T.called theiith entry offf. These morphisms have pairwise disjoint images, and the concatenation
(f1,…,fm):S♭→T(f_{1},\dots,f_{m}):S^{\flat}\to Tis the composite
(f1,…,fm)=f∘𝗂𝖽S♭S(f_{1},\dots,f_{m})=f\circ\mathsf{id}_{S^{\flat}}^{S}of Example3.2.3.2
Example 3.2.6.9.
Supposef:S→Tf:S\to Tis a nested tuple morphism, and suppose
S=(S1,…,Sr).S=(S_{1},\dots,S_{r}).Recall from example3.2.3.6that for any1≤i≤r1\leq i\leq r, there is a nested tuple morphism
fi:Si→T.f_{i}:S_{i}\to T.called theiith mode offf. These morphisms have pairwise disjoint images, and the concatenation
(f1,…,fr):S→T(f_{1},\dots,f_{r}):S\to Tis equal toff. In other words, every nested tuple morphismffmay be written as the concatenation of its modes:
f=(f1,…,fr).f=(f_{1},\dots,f_{r}).
Proposition 3.2.6.10.
Iff1,…,fkf_{1},\dots,f_{k}are nested tuple morphisms with the same codomain and with pairwise disjoint images, then
L(f1,…,fk)=(Lf1,…,Lfk).L_{(f_{1},\dots,f_{k})}=(L_{f_{1}},\dots,L_{f_{k}}).
Proof.
By construction, we have
𝗌𝗁𝖺𝗉𝖾((,,,,,))\displaystyle\mathsf{shape}((L_{f_{1}},\dots,L_{f_{k}}))=(𝗌𝗁𝖺𝗉𝖾(Lf1),…,𝗌𝗁𝖺𝗉𝖾(Lfk))\displaystyle=(\mathsf{shape}(L_{f_{1}}),\dots,\mathsf{shape}(L_{f_{k}}))=𝗌𝗁𝖺𝗉𝖾(L(f1,…,fk)).\displaystyle=\mathsf{shape}(L_{(f_{1},\dots,f_{k})}).and using Proposition3.1.5.38, we have
(Lf1,…,Lfk)♭\displaystyle(L_{f_{1}},\dots,L_{f_{k}})^{\flat}=Lf1♭⋆⋯⋆Lfk♭\displaystyle=L_{f_{1}}^{\flat}\star\cdots\star L_{f_{k}}^{\flat}=Lf1♭⋆⋯⋆Lfk♭\displaystyle=L_{f_{1}^{\flat}}\star\cdots\star L_{f_{k}^{\flat}}=Lf1♭⋆⋯⋆fk♭\displaystyle=L_{f_{1}^{\flat}\star\cdots\star f_{k}^{\flat}}=L(f1,…,fk)♭\displaystyle=L_{(f_{1},\dots,f_{k})^{\flat}}=(L(f1,…,fk))♭.\displaystyle=(L_{(f_{1},\dots,f_{k})})^{\flat}.∎
3.2.6.2Coalesce
Ifffis a nested tuple morphism, then we might define𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)to be𝖼𝗈𝖺𝗅♭(f♭)\mathsf{coal}^{\flat}(f^{\flat}). Theoretically, this is a sound definition. However, in order to make our definitions compatible with thecuteimplementation, we make a small modification to our definition of𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f).
Definition 3.2.6.11.
Supposef:S→Tf:S\to Tis a nested tuple morphism, and write
𝖼𝗈𝖺𝗅♭(f♭):(s1,…,sm)→(t1,…,tn).\mathsf{coal}^{\flat}(f^{\flat}):(s_{1},\dots,s_{m})\to(t_{1},\dots,t_{n}).- •(Case 1): Ifm>1m>1, we define 𝖼𝗈𝖺𝗅(f)=𝖼𝗈𝖺𝗅♭(f♭).\mathsf{coal}(f)=\mathsf{coal}^{\flat}(f^{\flat}).
- •(Case 2): Ifm=1m=1, we define𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)to be the composite s1{\lx@inpgf@ignorespaces s_{1}}(s1){\lx@inpgf@ignorespaces(s_{1})}(t1,…,tn).{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n}).}(1)\scriptstyle{\lx@inpgf@ignorespaces(1)}𝖼𝗈𝖺𝗅♭(f♭)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{coal}^{\flat}(f^{\flat})}
- •(Case 3): Ifm=0m=0, we define𝖼𝗈𝖺𝗅(f)\mathsf{coal}(f)to be the composite 1{\lx@inpgf@ignorespaces 1}(){\lx@inpgf@ignorespaces()}(t1,…,tn).{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n}).}(∗)\scriptstyle{\lx@inpgf@ignorespaces(*)}𝖼𝗈𝖺𝗅♭(f♭)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{coal}^{\flat}(f^{\flat})}
Example 3.2.6.12.
If
f:((2,2),(3,3),(5,5))→(5,5,3,3,2,2)f:((2,2),(3,3),(5,5))\to(5,5,3,3,2,2)lies overα=(5,6,3,4,1,2)\alpha=(5,6,3,4,1,2), then
𝖼𝗈𝖺𝗅(f):(4,9,25)→(25,9,4)\mathsf{coal}(f):(4,9,25)\to(25,9,4)lies overα′=(3,2,1)\alpha^{\prime}=(3,2,1).
Proposition 3.2.6.13.
Iff:S→Tf:S\to Tis a nested tuple morphism, then
𝖼𝗈𝖺𝗅(Lf)=L𝖼𝗈𝖺𝗅(f).\mathsf{coal}(L_{f})=L_{\mathsf{coal}(f)}.
Proof.
Let’s again write
(s1,…,sm){\lx@inpgf@ignorespaces(s_{1},\dots,s_{m})}(t1,…,tn).{\lx@inpgf@ignorespaces(t_{1},\dots,t_{n}).}𝖼𝗈𝖺𝗅♭(f♭)\scriptstyle{\lx@inpgf@ignorespaces\mathsf{coal}^{\flat}(f^{\flat})}α\scriptstyle{\lx@inpgf@ignorespaces\alpha}There are three cases to consider.
- •(Case 1): Supposem>1m>1. Then L𝖼𝗈𝖺𝗅(f)\displaystyle L_{\mathsf{coal}(f)}=L𝖼𝗈𝖺𝗅♭(f♭)\displaystyle=L_{\mathsf{coal}^{\flat}(f^{\flat})}=𝖼𝗈𝖺𝗅♭(Lf♭)\displaystyle=\mathsf{coal}^{\flat}(L_{f^{\flat}})=𝖼𝗈𝖺𝗅((Lf)♭)\displaystyle=\mathsf{coal}((L_{f})^{\flat})=𝖼𝗈𝖺𝗅(Lf).\displaystyle=\mathsf{coal}(L_{f}).
- •(Case 2): Supposem=1m=1. Then L𝖼𝗈𝖺𝗅(f)\displaystyle L_{\mathsf{coal}(f)}=s1:t1…,tα(1)−1\displaystyle=s_{1}:t_{1}\dots,t_{\alpha(1)-1}=𝖼𝗈𝖺𝗅((s1):(t1⋯tα(1)−1))\displaystyle=\mathsf{coal}((s_{1}):(t_{1}\cdots t_{\alpha(1)-1}))=𝖼𝗈𝖺𝗅(L𝖼𝗈𝖺𝗅♭(f♭))\displaystyle=\mathsf{coal}(L_{\mathsf{coal}^{\flat}(f^{\flat})})=𝖼𝗈𝖺𝗅(𝖼𝗈𝖺𝗅♭(Lf♭))\displaystyle=\mathsf{coal}(\mathsf{coal}^{\flat}(L_{f^{\flat}}))=𝖼𝗈𝖺𝗅((Lf)♭)\displaystyle=\mathsf{coal}((L_{f})^{\flat})=𝖼𝗈𝖺𝗅(Lf).\displaystyle=\mathsf{coal}(L_{f}).
- •(Case 3): Supposem=0m=0. Then L𝖼𝗈𝖺𝗅(f)\displaystyle L_{\mathsf{coal}(f)}=1:0\displaystyle=1:0=𝖼𝗈𝖺𝗅(():())\displaystyle=\mathsf{coal}(():())=𝖼𝗈𝖺𝗅(L𝖼𝗈𝖺𝗅♭(f♭))\displaystyle=\mathsf{coal}(L_{\mathsf{coal}^{\flat}(f^{\flat})})=𝖼𝗈𝖺𝗅(𝖼𝗈𝖺𝗅♭(Lf♭))\displaystyle=\mathsf{coal}(\mathsf{coal}^{\flat}(L_{f^{\flat}}))=𝖼𝗈𝖺𝗅((Lf)♭)\displaystyle=\mathsf{coal}((L_{f})^{\flat})=𝖼𝗈𝖺𝗅(Lf).\displaystyle=\mathsf{coal}(L_{f}).
∎
3.2.6.3Complement
In this section, we define the notion of complementary nested tuple morphisms.
Definition 3.2.6.14.
Supposef:S→Tf:S\to Tandg:U→Tg:U\to Tare nested tuple morphisms with disjoint images. We sayggis acomplementofffif
(f,g):(S,U)→T(f,g):(S,U)\to Tis an isomorphism.
Proposition 3.2.6.16.
Iff:S→Tf:S\to Tis a nested tuple morphism andg:U→Tg:U\to Tis a complement offf, thenLgL_{g}is a𝗌𝗂𝗓𝖾(T)\mathsf{size}(T)-complement ofLfL_{f}.
Proof.
Observation3.2.2.5implies that
(Lf)♭\displaystyle(L_{f})^{\flat}=Lf♭, and\displaystyle=L_{f^{\flat}}\text{, and }(Lg)♭\displaystyle(L_{g})^{\flat}=Lg♭\displaystyle=L_{g^{\flat}}and Lemma2.3.6.2allows us to reduce to the flat case (Proposition3.1.5.42). ∎
Construction 3.2.6.17.
Supposef:S→Tf:S\to Tis a nested nested tuple morphism. We define thecomplement offfto be the composite
U{\lx@inpgf@ignorespaces U}T{\lx@inpgf@ignorespaces T}T♭{\lx@inpgf@ignorespaces T^{\flat}}(f♭)c\scriptstyle{\lx@inpgf@ignorespaces(f^{\flat})^{c}}fc\scriptstyle{\lx@inpgf@ignorespaces f^{c}}𝗂𝖽T♭T\scriptstyle{\lx@inpgf@ignorespaces\mathsf{id}_{T^{\flat}}^{T}}where(f♭)c(f^{\flat})^{c}, is as defined in Construction3.1.5.46, and𝗂𝖽T♭T:T♭≅T\mathsf{id}_{T^{\flat}}^{T}:T^{\flat}\cong Tis the unflattening isomorphism.
Example 3.2.6.18.
The complement of the nested tuple morphism
((2,2),(5,5)){\lx@inpgf@ignorespaces((2,2),(5,5))}((2,5,7),(2,5,7)){\lx@inpgf@ignorespaces((2,5,7),(2,5,7))}f\scriptstyle{\lx@inpgf@ignorespaces f}(1,4,2,5)\scriptstyle{\lx@inpgf@ignorespaces(1{,}4{,}2{,}5)}is
(7,7){\lx@inpgf@ignorespaces(7,7)}((2,5,7),(2,5,7)).{\lx@inpgf@ignorespaces((2,5,7),(2,5,7)).}fc\scriptstyle{\lx@inpgf@ignorespaces f^{c}}(3,6)\scriptstyle{\lx@inpgf@ignorespaces(3{,}6)}
Proposition 3.2.6.19.
Supposef:S→Tf:S\to Tandg:U→Tg:U\to Tare nested tuple morphisms. Ifffis injective andggis a complement offf, thenLgL_{g}is a𝗌𝗂𝗓𝖾(T)\mathsf{size}(T)-complement ofLfL_{f}.
Proof.
This follows from Proposition3.1.5.42and Lemma2.3.6.2since
(Lf)♭\displaystyle(L_{f})^{\flat}=Lf♭\displaystyle=L_{f^{\flat}}(Lg)♭\displaystyle(L_{g})^{\flat}=Lg♭.\displaystyle=L_{g^{\flat}}.∎
Proposition 3.2.6.20.
Iff:S→Tf:S\to Tis an injective nested tuple morphism, then
𝖼𝗈𝖺𝗅(Lfc)=𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(T)).\mathsf{coal}(L_{f^{c}})=\mathsf{comp}(L_{f},\mathsf{size}(T)).
Proof.
Sincefcf^{c}is obtained from(f♭)c(f^{\flat})^{c}by post-composing with a reparenthesization isomorphism, it follows that
Lfc=L(f♭)cL_{f^{c}}=L_{(f^{\flat})^{c}}so by Proposition3.2.6.20, it follows that
𝖼𝗈𝖺𝗅♭(Lfc)=𝖼𝗈𝗆𝗉♭(Lf,𝗌𝗂𝗓𝖾(T)).\mathsf{coal}^{\flat}(L_{f^{c}})=\mathsf{comp}^{\flat}(L_{f},\mathsf{size}(T)).Applying𝖼𝗈𝖺𝗅(−)\mathsf{coal}(-)to both sides yields the result. ∎
3.2.6.4Composition
We can use the realization functor of Section3.2.4to prove that composition of nested tuple morphisms is compatible with composition of the associated layouts.
Theorem 3.2.6.21.
Ifffandggare non-degenerate composable nested tuple morphisms, then
Lg∘f=Lg∘Lf.L_{g\circ f}=L_{g}\circ L_{f}.
Proof.
Supposef:S→Tf:S\to Tandg:T→Ug:T\to Uare non-degenerate nested tuple morphisms. We need to check that
- 1.𝗌𝗁𝖺𝗉𝖾(Lg∘f)\mathsf{shape}(L_{g\circ f})refines𝗌𝗁𝖺𝗉𝖾(Lf)\mathsf{shape}(L_{f}): This holds since 𝗌𝗁𝖺𝗉𝖾(Lf)=S=𝗌𝗁𝖺𝗉𝖾(Lg∘f).\mathsf{shape}(L_{f})=S=\mathsf{shape}(L_{g\circ f}).
- 2.Lg∘fL_{g\circ f}is coalesced over𝗌𝗁𝖺𝗉𝖾(Lf)\mathsf{shape}(L_{f}): This holds since the nested tuple morphismg∘fg\circ fis non-degenerate, hence so is the layoutLg∘fL_{g\circ f}.
- 3.ΦLg∘f=ΦLg∘ΦLf𝗌𝗂𝗓𝖾(Lg)\Phi_{L_{g\circ f}}=\Phi_{L_{g}}\circ\Phi_{L_{f}}^{\mathsf{size}(L_{g})}: Using Lemma3.2.4.2, we have ΦLg∘f𝗌𝗂𝗓𝖾(U)\displaystyle\Phi_{L_{g\circ f}}^{\mathsf{size}(U)}=|g∘f|\displaystyle=|g\circ f|=|g|∘|f|\displaystyle=|g|\circ|f|=ΦLg𝗌𝗂𝗓𝖾(U)∘ΦLf𝗌𝗂𝗓𝖾(T)\displaystyle=\Phi_{L_{g}}^{\mathsf{size}(U)}\circ\Phi_{L_{f}}^{\mathsf{size}(T)}and by postcomposing with the inclusion[0,𝗌𝗂𝗓𝖾(U))⊂ℤ[0,\mathsf{size}(U))\subset\mathbb{Z}, and observing that𝗌𝗂𝗓𝖾(T)=𝗌𝗂𝗓𝖾(Lg)\mathsf{size}(T)=\mathsf{size}(L_{g}), the result follows.
∎
3.2.6.5Logical division
Next, we introduce logical division of nested tuple morphisms. This construction is obtained from flat division by introducing nesting profiles, with no compatibility constraints.
Definition 3.2.6.22.
Supposeffandggare nested tuple morphisms. We sayggdividesffifggandffare composable. In other words,
𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)=𝖽𝗈𝗆𝖺𝗂𝗇(f).\mathsf{codomain}(g)=\mathsf{domain}(f).
Definition 3.2.6.23.
Supposeg:S→Tg:S\to Tandf:T→Uf:T\to Uare nested tuple morphisms. We define the logical division offfbyggto be the nested tuple morphism
f⊘g=f∘(g,gc).f\oslash g=f\circ(g,g^{c}).
Example 3.2.6.24.
The logical division of
((2,2),2){\lx@inpgf@ignorespaces((2,2),2)}((4,2),(4,2)){\lx@inpgf@ignorespaces((4,2),(4,2))}f\scriptstyle{\lx@inpgf@ignorespaces f}(2,4,∗)\scriptstyle{\lx@inpgf@ignorespaces(2{,}4{,}*)}by
(2,2){\lx@inpgf@ignorespaces(2,2)}((2,2),2){\lx@inpgf@ignorespaces((2,2),2)}g\scriptstyle{\lx@inpgf@ignorespaces g}(1,3)\scriptstyle{\lx@inpgf@ignorespaces(1{,}3)}is
((2,2),2){\lx@inpgf@ignorespaces((2,2),2)}((4,2),(4,2)).{\lx@inpgf@ignorespaces((4,2),(4,2)).}f⊘g\scriptstyle{\lx@inpgf@ignorespaces f\oslash g}(2,∗,4)\scriptstyle{\lx@inpgf@ignorespaces(2{,}*{,}4)}
Example 3.2.6.25.
The logical division of
(8,8,512,512,512){\lx@inpgf@ignorespaces(8,8,512,512,512)}(512,512,512){\lx@inpgf@ignorespaces(512,512,512)}f\scriptstyle{\lx@inpgf@ignorespaces f}(∗,∗,1,2,3)\scriptstyle{\lx@inpgf@ignorespaces(*{,}*{,}1{,}2{,}3)}by
(8,512){\lx@inpgf@ignorespaces(8,512)}(8,8,512,512,512){\lx@inpgf@ignorespaces(8,8,512,512,512)}g\scriptstyle{\lx@inpgf@ignorespaces g}(1,5)\scriptstyle{\lx@inpgf@ignorespaces(1{,}5)}is
((8,512),(8,512,512)){\lx@inpgf@ignorespaces((8,512),(8,512,512))}((4,2),(4,2)).{\lx@inpgf@ignorespaces((4,2),(4,2)).}f⊘g\scriptstyle{\lx@inpgf@ignorespaces f\oslash g}(∗,1,∗,2,3)\scriptstyle{\lx@inpgf@ignorespaces(*{,}1{,}*{,}2{,}3)}
Proposition 3.2.6.26.
Ifg:S→Tg:S\to Tandf:T→Uf:T\to Uare non-degenerate nested tuple morphisms, then
𝖼𝗈𝖺𝗅(Lf⊘g)=𝖼𝗈𝖺𝗅(Lf⊘Lg).\mathsf{coal}(L_{f\oslash g})=\mathsf{coal}(L_{f}\oslash L_{g}).
Proof.
By Proposition3.2.6.20, we have
𝖼𝗈𝖺𝗅(𝖼𝗈𝗆𝗉(Lg,𝗌𝗂𝗓𝖾(Lf)))=𝖼𝗈𝖺𝗅(Lgc)\mathsf{coal}(\mathsf{comp}(L_{g},\mathsf{size}(L_{f})))=\mathsf{coal}(L_{g^{c}})and we compute
𝖼𝗈𝖺𝗅(Lf⊘Lg)\displaystyle\mathsf{coal}(L_{f}\oslash L_{g})=𝖼𝗈𝖺𝗅(Lf∘(Lg,𝖼𝗈𝗆𝗉(Lg,𝗌𝗂𝗓𝖾(Lf))))\displaystyle=\mathsf{coal}(L_{f}\circ\left(L_{g},\mathsf{comp}(L_{g},\mathsf{size}(L_{f}))\right))=𝖼𝗈𝖺𝗅(Lf∘(Lg,Lgc))\displaystyle=\mathsf{coal}(L_{f}\circ(L_{g},L_{g^{c}}))=𝖼𝗈𝖺𝗅(Lf∘L(g,gc))\displaystyle=\mathsf{coal}(L_{f}\circ L_{(g,g^{c})})=𝖼𝗈𝖺𝗅(Lf∘L(g,gc))\displaystyle=\mathsf{coal}(L_{f}\circ L_{(g,g^{c})})=𝖼𝗈𝖺𝗅(Lf∘(g,gc))\displaystyle=\mathsf{coal}(L_{f\circ(g,g^{c})})=𝖼𝗈𝖺𝗅(Lf⊘g).\displaystyle=\mathsf{coal}(L_{f\oslash g}).∎
Proposition 3.2.6.27.
Ifffandggare nested tuples andggdividesff, then
(f⊘g)♭=f♭⊘♭g♭.(f\oslash g)^{\flat}=f^{\flat}\oslash^{\flat}g^{\flat}.
Proof.
We compute
(f⊘g)♭\displaystyle(f\oslash g)^{\flat}=(f∘(g,gc))♭\displaystyle=(f\circ(g,g^{c}))^{\flat}=f♭∘(g,gc)♭\displaystyle=f^{\flat}\circ(g,g^{c})^{\flat}=f♭∘(g♭⋆(gc)♭)\displaystyle=f^{\flat}\circ(g^{\flat}\star(g^{c})^{\flat})=f♭∘(g♭⋆(g♭)c)\displaystyle=f^{\flat}\circ(g^{\flat}\star(g^{\flat})^{c})=f♭⊘♭g♭.\displaystyle=f^{\flat}\oslash^{\flat}g^{\flat}.∎
3.2.6.6Logical products
In this section, we define the logical product of nested tuple morphisms.
Definition 3.2.6.28.
Supposeffandggare nested tuple morphisms. We sayffandggareproduct admissibleif𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)=𝖽𝗈𝗆𝖺𝗂𝗇(fc)\mathsf{codomain}(g)=\mathsf{domain}(f^{c}). Ifffandggare product admissible we define thelogical productofffandggto be the nested tuple morphism
f⊗g=(f,fc∘g).f\otimes g=(f,f^{c}\circ g).
Example 3.2.6.29.
The nested tuple morphisms
(8,8){\lx@inpgf@ignorespaces(8,8)}(8,8,16,16){\lx@inpgf@ignorespaces(8,8,16,16)}f\scriptstyle{\lx@inpgf@ignorespaces f}(1,2)\scriptstyle{\lx@inpgf@ignorespaces(1{,}2)}and
(16,16){\lx@inpgf@ignorespaces(16,16)}(16,16){\lx@inpgf@ignorespaces(16,16)}g\scriptstyle{\lx@inpgf@ignorespaces g}(1,2)\scriptstyle{\lx@inpgf@ignorespaces(1{,}2)}are product admissible, and their logical product is
((8,8),(16,16)){\lx@inpgf@ignorespaces((8,8),(16,16))}(8,8,16,16).{\lx@inpgf@ignorespaces(8,8,16,16).}f⊗g\scriptstyle{\lx@inpgf@ignorespaces f\otimes g}(1,2,3,4)\scriptstyle{\lx@inpgf@ignorespaces(1{,}2{,}3{,}4)}
Example 3.2.6.30.
The nested tuple morphisms
(128,128){\lx@inpgf@ignorespaces(128,128)}(32,32,128,128){\lx@inpgf@ignorespaces(32,32,128,128)}f\scriptstyle{\lx@inpgf@ignorespaces f}(3,4)\scriptstyle{\lx@inpgf@ignorespaces(3{,}4)}and
(32){\lx@inpgf@ignorespaces(32)}(32,32){\lx@inpgf@ignorespaces(32,32)}g\scriptstyle{\lx@inpgf@ignorespaces g}(2)\scriptstyle{\lx@inpgf@ignorespaces(2)}are product admissible, and their logical product is
((128,128),(32)){\lx@inpgf@ignorespaces((128,128),(32))}(32,32,128,128).{\lx@inpgf@ignorespaces(32,32,128,128).}f⊗g\scriptstyle{\lx@inpgf@ignorespaces f\otimes g}(3,4,2)\scriptstyle{\lx@inpgf@ignorespaces(3{,}4{,}2)}
Proposition 3.2.6.31.
Supposeffandggare non-degenerate nested tuple morphisms and thatffandggare product-admissible. Then
Lf⊗g=Lf⊗Lg.L_{f\otimes g}=L_{f}\otimes L_{g}.
Proof.
Supposef:S→Tf:S\to Tandg:U→Vg:U\to Vare product admissible, and set
Lf∗=𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(Lf)⋅𝖼𝗈𝗌𝗂𝗓𝖾(Lg))L_{f}^{*}=\mathsf{comp}(L_{f},\mathsf{size}(L_{f})\cdot\mathsf{cosize}(L_{g}))Sinceffis injective and𝖼𝗈𝖽𝗈𝗆𝖺𝗂𝗇(g)=𝖽𝗈𝗆𝖺𝗂𝗇(fc)\mathsf{codomain}(g)=\mathsf{domain}(f^{c}), it follows that
𝗌𝗂𝗓𝖾(Lf)⋅𝖼𝗈𝗌𝗂𝗓𝖾(Lg)≤𝗌𝗂𝗓𝖾(S)⋅𝗌𝗂𝗓𝖾(V)=𝗌𝗂𝗓𝖾(T).\mathsf{size}(L_{f})\cdot\mathsf{cosize}(L_{g})\leq\mathsf{size}(S)\cdot\mathsf{size}(V)=\mathsf{size}(T).Using this fact, and the fact that
Φ𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(T))=ΦLfc,\Phi_{\mathsf{comp}(L_{f},\mathsf{size}(T))}=\Phi_{L_{f^{c}}},we have
Lf∗∘Lg\displaystyle L_{f}^{*}\circ L_{g}=𝖼𝗈𝗆𝗉(Lf,𝗌𝗂𝗓𝖾(T))∘Lg\displaystyle=\mathsf{comp}(L_{f},\mathsf{size}(T))\circ L_{g}=Lfc∘Lg.\displaystyle=L_{f^{c}}\circ L_{g}.Using this fact, we compute
Lf⊗Lg\displaystyle L_{f}\otimes L_{g}=(Lf,Lf∗∘Lg)\displaystyle=(L_{f},L_{f}^{*}\circ L_{g})=(Lf,Lfc∘Lg)\displaystyle=(L_{f},L_{f^{c}}\circ L_{g})=(Lf,Lfc∘g)\displaystyle=(L_{f},L_{f^{c}\circ g})=L(f,fc∘g)\displaystyle=L_{(f,f^{c}\circ g)}=Lf⊗g\displaystyle=L_{f\otimes g}∎
Chapter 4Computations
The categories𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}and𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}offer a powerful framework for computing with tractable layouts. It is frequently the case that in practice, however, one comes across tractable layoutsAAandBBthat are composable in the context ofcutebut whose standard representations are neither composable in𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}nor𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}. This chapter is dedicated to the explication of how one may nevertheless use the categories𝗧𝘂𝗽𝗹𝗲{\boldsymbol{\mathsf{Tuple}}}and𝗡𝗲𝘀𝘁{\boldsymbol{\mathsf{Nest}}}to compute thecomposition,logical division, andlogical productof tractable layouts, using the notion ofmutual refinement. We introduce this notion inSection4.1.1, present an algorithm for computing mutual refinements in Algorithm4.1.1, and work through many explicit examples.
4.1Composition of tractable layouts
Suppose we want to compute the compositionB∘AB\circ Aof the tractable layouts
A\displaystyle A=(6,6):(6,1),\displaystyle=(6,6):(6,1),B\displaystyle B=(12,3,6):(1,72,12).\displaystyle=(12,3,6):(1,72,12).We might try to computeB∘AB\circ Aby computing the composite of the standard representationsffandggofAAandBB:
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}However, these morphisms are not composable, since the codomain(6,6)(6,6)offfis not equal to the domain(12,3,6)(12,3,6)ofgg. This means that we can not use the morphismsffandggto compute the compositeB∘AB\circ Adirectly. We can, however, proceed with our computation by finding amutual refinementof(6,6)(6,6)and(12,3,6)(12,3,6), as depicted below
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12} This is a device which convertsffandgginto composable morphismsf′f^{\prime}andg′g^{\prime}:
6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}f{\lx@inpgf@ignorespaces f}f′{\lx@inpgf@ignorespaces f^{\prime}}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}↝{\lx@inpgf@ignorespaces\rightsquigarrow}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}g{\lx@inpgf@ignorespaces g}g′{\lx@inpgf@ignorespaces g^{\prime}}The morphismsf′f^{\prime}andg′g^{\prime}are composable, so we may form the composite
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}and computing the encoded layout yields
B∘A\displaystyle B\circ A=Lg′∘f′=((2,3),6):((6,72),1).\displaystyle=L_{g^{\prime}\circ f^{\prime}}=((2,3),6):((6,72),1). The goal of this section is to formalize this computational process into analgorithmfor computing the composite of tractable layoutsAAandBB. As we saw in our example, the non-trivial steps in our computation were
- 1.finding a mutual refinement of certain (nested) tuples, and
- 2.using the mutual refinement to convertffandgginto composable morphismsf′f^{\prime}andg′g^{\prime}.
We dedicate the following two sections to the explication of these steps.
4.1.1Mutual refinements
Before giving a precise definition of mutual refinements using the categorical framework of Chapter3, we give an informal overview. Consider the tuples(6,6)(6,6)and(12,3,6)(12,3,6)of our motivating example. We asserted that the diagram
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}is a mutual refinement of(6,6)(6,6)and(12,3,6)(12,3,6). We can give a more precise description of this mutual refinement as follows. The left half of the diagram represents the refinement(6,6)↞(6,(2,3))(6,6)\twoheadleftarrow(6,(2,3)), and the right half of the diagram represents the refinement((6,2),3,6)↠(12,3,6)((6,2),3,6)\twoheadrightarrow(12,3,6):
3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}(6,6){\lx@inpgf@ignorespaces(6,6)}(6,(2,3)){\lx@inpgf@ignorespaces(6,(2,3))}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}((6,2),3,6){\lx@inpgf@ignorespaces((6,2),3,6)}(12,3,6){\lx@inpgf@ignorespaces(12,3,6)}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}The fact that the two halves of the diagram may be glued together corresponds to the fact that the nested tuple(6,(2,3))(6,(2,3))divides((6,2),3,6)((6,2),3,6), which we denote
(6,(2,3)){\lx@inpgf@ignorespaces(6,(2,3))}((6,2),3,6).{\lx@inpgf@ignorespaces((6,2),3,6).}Putting these observations together, we may express our mutual refinement precisely as
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}(6,(2,3)){\lx@inpgf@ignorespaces(6,(2,3))}((6,2),3,6){\lx@inpgf@ignorespaces((6,2),3,6)}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}↭{\lx@inpgf@ignorespaces\leftrightsquigarrow}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}(6,6){\lx@inpgf@ignorespaces(6,6)}(12,3,6){\lx@inpgf@ignorespaces(12,3,6)}where we opt to depict the refinements(6,6)↞(6,(2,3))(6,6)\twoheadleftarrow(6,(2,3))and((6,2),3,6)↠(12,3,6)((6,2),3,6)\twoheadrightarrow(12,3,6)vertically. We can now give a precise definition of mutual refinements.
Definition 4.1.1.1.
SupposeTTandUUare nested tuples. Amutual refinementof(T,U)(T,U)is a diagram of the form
T′{\lx@inpgf@ignorespaces T^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}Explicitly, this is a pair of nested tuples(T′,U′)(T^{\prime},U^{\prime})such that
- 1.T′T^{\prime}refinesTT,
- 2.U′U^{\prime}refinesUU, and
- 3.T′T^{\prime}dividesU′U^{\prime}.
Example 4.1.1.2.
A mutual refinement ofT=(6,6)T=(6,6)andU=(2,6,3)U=(2,6,3)is given by
((2,3),(2,3)){\lx@inpgf@ignorespaces((2,3),(2,3))}(2,(3,2),3){\lx@inpgf@ignorespaces(2,(3,2),3)}(6,6){\lx@inpgf@ignorespaces(6,6)}(2,6,3){\lx@inpgf@ignorespaces(2,6,3)}We depict this mutual refinement as follows.
3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}
Example 4.1.1.3.
A mutual refinement ofT=(8,8,8)T=(8,8,8)andU=(2,8,8,8)U=(2,8,8,8)is given by
((2,4),(2,4),(2,4)){\lx@inpgf@ignorespaces((2,4),(2,4),(2,4))}(2,(4,2),(4,2),(4,2)){\lx@inpgf@ignorespaces(2,(4,2),(4,2),(4,2))}(8,8,8){\lx@inpgf@ignorespaces(8,8,8)}(2,8,8,8){\lx@inpgf@ignorespaces(2,8,8,8)}We depict this mutual refinement as follows.
2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}
Example 4.1.1.4.
A mutual refinement ofT=(4,2,2,32)T=(4,2,2,32)andU=(32,32)U=(32,32)is given by
(4,2,2,(2,16)){\lx@inpgf@ignorespaces(4,2,2,(2,16))}((4,2,2,2),(16,2)){\lx@inpgf@ignorespaces((4,2,2,2),(16,2))}(4,2,2,32){\lx@inpgf@ignorespaces(4,2,2,32)}(32,32){\lx@inpgf@ignorespaces(32,32)}We depict this mutual refinement as follows.
2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}32{\lx@inpgf@ignorespaces 32}32{\lx@inpgf@ignorespaces 32}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}32{\lx@inpgf@ignorespaces 32}
Example 4.1.1.5.
IfT=(8,8)T=(8,8)andU=(3,8,8)U=(3,8,8), then there does not exist a mutual refinement ofTTandUU.
Example 4.1.1.6.
IfTTandUUare tuples with𝗌𝗂𝗓𝖾(T)=2k\mathsf{size}(T)=2^{k}and𝗌𝗂𝗓𝖾(L)=2ℓ\mathsf{size}(L)=2^{\ell}withk≤ℓk\leq\ell, then there exists a mutual refinement ofTTandUU. More generally, ifTTandUUare tuples where𝗌𝗂𝗓𝖾(T)≤𝗌𝗂𝗓𝖾(U)\mathsf{size}(T)\leq\mathsf{size}(U)are powers of some fixed integer, then there exists a mutual refinement ofTTandUU.
Observation 4.1.1.7.
In each of the previous examples, we have considered mutual refinements offlattuplesTTandUU. The definition of mutual refinement, however, allowsTTandUUto be anynestedtuples. In any case, restricting to the flat case is no loss of generality, because there is a one-to-one correspondence between mutual refinements of a pair of nested tuples(T,U)(T,U), and mutual refinements of their flattenings(T♭,U♭)(T^{\flat},U^{\flat})(see Lemma3.2.5.20). In particular, there exists a mutual refinement of(T,U)(T,U)if and only if there exists a mutual refinement of(T♭,U♭)(T^{\flat},U^{\flat}).
Having made the appropriate definitions, we provide an algorithm for computing a mutual refinement of(T,U)(T,U).
Algorithm 4.1.1: Mutual refinement algorithm1Input:Nested tuplesTTandUU.2Output:A mutual refinement(T′,U′)(T^{\prime},U^{\prime})of(T,U)(T,U), if one exists, else𝐍𝐨𝐧𝐞\mathbf{None}.34X←TX\leftarrow T;Y←UY\leftarrow U5X′,Y′,X𝗆𝗈𝖽𝖾,Y𝗆𝗈𝖽𝖾←()X^{\prime},\,Y^{\prime},\,X_{\mathsf{mode}},\,Y_{\mathsf{mode}}\leftarrow()6i←1i\leftarrow 1;j←1j\leftarrow 17whilei≤𝗅𝖾𝗇(X)i\leq\mathsf{len}(X)andj≤𝗅𝖾𝗇(Y)j\leq\mathsf{len}(Y)do8ifOPENOPENX)=Y)X)=Y)then9appendOPENX)X)toX𝗆𝗈𝖽𝖾X_{\mathsf{mode}}; appendX𝗆𝗈𝖽𝖾X_{\mathsf{mode}}toX′X^{\prime};X𝗆𝗈𝖽𝖾←()X_{\mathsf{mode}}\leftarrow()10appendOPENY)Y)toY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}};11appendY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}}toY′Y^{\prime};12Y𝗆𝗈𝖽𝖾←()Y_{\mathsf{mode}}\leftarrow()13i←i+1i\leftarrow i+1;14j←j+1j\leftarrow j+115elseifOPENX)X)dividesOPENY)Y)then16appendOPENX)X)toX𝗆𝗈𝖽𝖾X_{\mathsf{mode}};17appendX𝗆𝗈𝖽𝖾X_{\mathsf{mode}}toX′X^{\prime};18X𝗆𝗈𝖽𝖾←()X_{\mathsf{mode}}\leftarrow()19appendOPENX)X)toY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}}20Y)←Y)/X)Y)\leftarrow Y)/X);21i←i+1i\leftarrow i+122elseifOPENY)Y)dividesOPENX)X)then23appendOPENY)Y)toX𝗆𝗈𝖽𝖾X_{\mathsf{mode}};24appendOPENY)Y)toY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}};25appendY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}}toY′Y^{\prime};26Y𝗆𝗈𝖽𝖾←()Y_{\mathsf{mode}}\leftarrow()27X)←X)/Y)X)\leftarrow X)/Y);28j←j+1j\leftarrow j+129else30return𝐍𝐨𝐧𝐞\mathbf{None}31endif32endwhile33ifY𝗆𝗈𝖽𝖾≠()Y_{\mathsf{mode}}\neq()then34appendOPENY)Y)toY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}};35appendY𝗆𝗈𝖽𝖾Y_{\mathsf{mode}}toY′Y^{\prime};36j←j+1j\leftarrow j+137endif38whilej<𝗅𝖾𝗇(Y)j<\mathsf{len}(Y)do39appendOPENY)Y)toY′Y^{\prime};40j←j+1j\leftarrow j+141endwhile42T′←(X′)𝗉𝗋𝗈𝖿(T)T^{\prime}\leftarrow(X^{\prime})_{\mathsf{prof}(T)};43U′←(Y′)𝗉𝗋𝗈𝖿(U)U^{\prime}\leftarrow(Y^{\prime})_{\mathsf{prof}(U)}44return(T′,U′)(T^{\prime},U^{\prime})
4.1.2From mutual refinements to composable morphisms
Recall that in order to compute the compositionB∘AB\circ Aof
A\displaystyle A=(6,6):(6,1)and\displaystyle=(6,6):(6,1)\text{ and }B\displaystyle B=(12,3,6):(1,72,12),\displaystyle=(12,3,6):(1,72,12),we constructed tuple morphisms
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}and a mutual refinement.
6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12} The next step in our computation is to use our mutual refinement to convertffandgginto composable morphismsf′f^{\prime}andg′g^{\prime}. Before giving a formal, categorical definition of this process, let’s illustrate the process with an example.
We constructf′f^{\prime}fromffand the left half of our mutual refinement:
6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}f{\lx@inpgf@ignorespaces f}f′{\lx@inpgf@ignorespaces f^{\prime}}This construction is made by making the replacement
6{\lx@inpgf@ignorespaces 6}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}and making the replacement
3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}↝{\lx@inpgf@ignorespaces\rightsquigarrow}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}More generally, we make the replacement
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}⋮{\lx@inpgf@ignorespaces\vdots}↝{\lx@inpgf@ignorespaces\rightsquigarrow}∙{\lx@inpgf@ignorespaces\bullet}⋮{\lx@inpgf@ignorespaces\vdots}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet} The process for constructingg′g^{\prime}fromgg, and the right half of our mutual refinement is similar.
6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}↝{\lx@inpgf@ignorespaces\rightsquigarrow}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}g{\lx@inpgf@ignorespaces g}g′{\lx@inpgf@ignorespaces g^{\prime}}This construction is made by making the replacements
6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}↝{\lx@inpgf@ignorespaces\rightsquigarrow}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}↝{\lx@inpgf@ignorespaces\rightsquigarrow}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6} More generally, we make the replacement
∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}⋮{\lx@inpgf@ignorespaces\vdots}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}↝{\lx@inpgf@ignorespaces\rightsquigarrow}⋮{\lx@inpgf@ignorespaces\vdots}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet}∙{\lx@inpgf@ignorespaces\bullet} Having given an informal description of our procedure, we make things precise as follows.
Construction 4.1.2.1.
Supposef:S→Tf:S\to Tandg:U→Vg:U\to Vare nested tuple morphisms, and(T′,U′)(T^{\prime},U^{\prime})is a mutual refinement of(T,U)(T,U). Then we may use thepullbackandpushforwardconstructions of section3.2.5to form the diagram:
S′{\lx@inpgf@ignorespaces S^{\prime}}T′{\lx@inpgf@ignorespaces T^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}V′{\lx@inpgf@ignorespaces V^{\prime}}S{\lx@inpgf@ignorespaces S}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}V{\lx@inpgf@ignorespaces V}f~\scriptstyle{\lx@inpgf@ignorespaces\tilde{f}}⌟{\lx@inpgf@ignorespaces\lrcorner}i\scriptstyle{\lx@inpgf@ignorespaces i}g~\scriptstyle{\lx@inpgf@ignorespaces\tilde{g}}⌞{\lx@inpgf@ignorespaces\llcorner}f\scriptstyle{\lx@inpgf@ignorespaces f}g\scriptstyle{\lx@inpgf@ignorespaces g}If we setf′=i∘f~f^{\prime}=i\circ\tilde{f}andg′=g~g^{\prime}=\tilde{g}, then
S′{\lx@inpgf@ignorespaces S^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}V′{\lx@inpgf@ignorespaces V^{\prime}}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}g′\scriptstyle{\lx@inpgf@ignorespaces g^{\prime}}are composable nested tuple morphisms.
4.1.3The composition algorithm
Algorithm 4.1.2: Tractable Layout Composition Algorithm1Input:Tractable layoutsAAandBB.2Output:A weak compositeCCofAAandBB, if one exists, else𝐍𝐨𝐧𝐞\mathbf{None}..34Take the standard representationsS{\lx@inpgf@ignorespaces S}TU{\lx@inpgf@ignorespaces T\qquad\qquad U}V{\lx@inpgf@ignorespaces V}f\scriptstyle{\lx@inpgf@ignorespaces f}g\scriptstyle{\lx@inpgf@ignorespaces g}ofAAand𝖼𝗈𝖺𝗅(B)\mathsf{coal}(B), respectively.5Use Algorithm4.1.1to produce a mutual refinementT′{\lx@inpgf@ignorespaces T^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}T{\lx@inpgf@ignorespaces T}U{\lx@inpgf@ignorespaces U}of(T,U)(T,U). If there does not exist a mutual refinement of(T,U)(T,U), return𝐍𝐨𝐧𝐞\mathbf{None}.6Use Construction4.1.2.1to obtain the composable nested tuple morphismsS′{\lx@inpgf@ignorespaces S^{\prime}}U′{\lx@inpgf@ignorespaces U^{\prime}}V′{\lx@inpgf@ignorespaces V^{\prime}}f′\scriptstyle{\lx@inpgf@ignorespaces f^{\prime}}g′\scriptstyle{\lx@inpgf@ignorespaces g^{\prime}}7Composef′f^{\prime}andg′g^{\prime}, and compute the encoded layoutC=Lg′∘f′C=L_{g^{\prime}\circ f^{\prime}}8returnCC
Theorem 4.1.3.1.
IfAAandBBare tractable layouts, then the outputCCof the previous algorithm is a weak composite ofAAandBB. Consequently,
B∘A=𝖼𝗈𝖺𝗅(C,𝗌𝗁𝖺𝗉𝖾(A)).B\circ A=\mathsf{coal}(C,\mathsf{shape}(A)).
Proof.
Proposition3.2.5.15and tells us that
ΦLg′=ΦLg=Φ𝖼𝗈𝖺𝗅(B)=ΦB,\Phi_{L_{g^{\prime}}}=\Phi_{L_{g}}=\Phi_{\mathsf{coal}(B)}=\Phi_{B},and Proposition3.2.5.11and Example3.1.3.6tell us that
ΦLf′=ΦLf=ΦA.\Phi_{L_{f^{\prime}}}=\Phi_{L_{f}}=\Phi_{A}.Theorem3.2.6.21then implies that
ΦC=ΦLg′∘f′\displaystyle\Phi_{C}=\Phi_{L_{g^{\prime}\circ f^{\prime}}}=Φg′∘Φf′𝗌𝗂𝗓𝖾(U′)\displaystyle=\Phi_{g^{\prime}}\circ\Phi_{f^{\prime}}^{\mathsf{size}(U^{\prime})}=ΦB∘ΦA𝗌𝗂𝗓𝖾(B).\displaystyle=\Phi_{B}\circ\Phi_{A}^{\mathsf{size}(B)}.By construction, the shapeS′S^{\prime}ofLf′L_{f^{\prime}}refines the shapeSSofAA, so we conclude thatCCis a weak composite ofAAandBB. ∎
4.1.4Examples
In this section we illustrate how Algorithm4.1.3may be used to compute the compositionB∘AB\circ Aof tractable layoutsAAandBB.
Example 4.1.4.1.
SupposeA=(4):(1)A=(4):(1), andB=(2,2):(2,1)B=(2,2):(2,1).
- 1.Take the standard representations ofAAand𝖼𝗈𝖺𝗅(B)=B\mathsf{coal}(B)=B. 2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply Algorithm4.1.1to obtain the mutual refinement 2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}
- 3.Form the diagram 2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram 2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}g′∘f′{\lx@inpgf@ignorespaces\mathclap{g^{\prime}\circ f^{\prime}}}
- 6.Compute the associated layout Lg′∘f′=((2,2)):((2,1)).L_{g^{\prime}\circ f^{\prime}}=((2,2)):((2,1)).
- 7.Lg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(4)(4), so B∘A=((2,2)):((2,1)).B\circ A=((2,2)):((2,1)).
Example 4.1.4.2.
SupposeA=(6,6):(6,1)A=(6,6):(6,1), andB=(12,3,6):(1,72,12)B=(12,3,6):(1,72,12).
- 1.Take the standard representations ofAAand𝖼𝗈𝖺𝗅(B)=B\mathsf{coal}(B)=B. 6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply Algorithm4.1.1to obtain the mutual refinement 6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}
- 3.Form the diagram 6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}12{\lx@inpgf@ignorespaces 12}12{\lx@inpgf@ignorespaces 12}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram to obtain 6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}
- 6.Compute the associated layout Lg′∘f′=((2,3),6):((6,72),1).L_{g^{\prime}\circ f^{\prime}}=((2,3),6):((6,72),1).
- 7.Lg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(6,6)(6,6), hence B∘A=((2,3),6):((6,72),1).B\circ A=((2,3),6):((6,72),1).
Example 4.1.4.3.
SupposeA=(8,8):(8,1)A=(8,8):(8,1), andB=(16,16):(16,1)B=(16,16):(16,1).
- 1.Take the standard representations ofAAand𝖼𝗈𝖺𝗅(B)=B\mathsf{coal}(B)=B. 8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply Algorithm4.1.1to obtain the mutual refinement 4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}
- 3.Form the diagram 4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram to obtain 4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}
- 6.Compute the associated layout Lg′∘f′=((2,4),8):((128,1),16)L_{g^{\prime}\circ f^{\prime}}=((2,4),8):((128,1),16)
- 7.Lg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(8,8)(8,8), hence B∘A=((2,4),8):((128,1),16)B\circ A=((2,4),8):((128,1),16)
Example 4.1.4.4.
SupposeA=(16,16):(16,1)A=(16,16):(16,1), andB=(8,8,8):(64,8,1)B=(8,8,8):(64,8,1).
- 1.Take the standard representations ofAAand𝖼𝗈𝖺𝗅(B)=B\mathsf{coal}(B)=B. 8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply Algorithm4.1.1to obtain the mutual refinement 2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}
- 3.Form the diagram 2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}16{\lx@inpgf@ignorespaces 16}16{\lx@inpgf@ignorespaces 16}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram to obtain 2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}16{\lx@inpgf@ignorespaces 16}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}
- 6.Compute the associated layout Lg′∘f′=((4,4),(8,2)):((16,1),(64,8)).L_{g^{\prime}\circ f^{\prime}}=((4,4),(8,2)):((16,1),(64,8)).
- 7.Lg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(16,16)(16,16), hence B∘A=((4,4),(8,2)):((16,1),(64,8)).B\circ A=((4,4),(8,2)):((16,1),(64,8)).
Example 4.1.4.5.
SupposeA=(6,6):(5,60)A=(6,6):(5,60), andB=(10,360):(2,60)B=(10,360):(2,60).
- 1.Take the standard representations ofAAand𝖼𝗈𝖺𝗅(B)=B\mathsf{coal}(B)=B. 6{\lx@inpgf@ignorespaces 6}360{\lx@inpgf@ignorespaces 360}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}360{\lx@inpgf@ignorespaces 360}10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}5{\lx@inpgf@ignorespaces 5}10{\lx@inpgf@ignorespaces 10}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply algorithm4.1.1to obtain the mutual refinement 10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}360{\lx@inpgf@ignorespaces 360}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}10{\lx@inpgf@ignorespaces 10}
- 3.Form the diagram 10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}360{\lx@inpgf@ignorespaces 360}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}360{\lx@inpgf@ignorespaces 360}10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}10{\lx@inpgf@ignorespaces 10}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram to obtain 10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}10{\lx@inpgf@ignorespaces 10}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}5{\lx@inpgf@ignorespaces 5}2{\lx@inpgf@ignorespaces 2}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 10{\lx@inpgf@ignorespaces 10}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}3{\lx@inpgf@ignorespaces 3}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}6{\lx@inpgf@ignorespaces 6}3{\lx@inpgf@ignorespaces 3}5{\lx@inpgf@ignorespaces 5}6{\lx@inpgf@ignorespaces 6}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}g′∘f′{\lx@inpgf@ignorespaces\mathclap{g^{\prime}\circ f^{\prime}}}
- 6.Compute the associated layout Lg′∘f′=((2,3),6):((10,60),360).L_{g^{\prime}\circ f^{\prime}}=((2,3),6):((10,60),360).
- 7.The layoutLg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(6,6)(6,6), so B∘A=((2,3),6):((10,60),360).B\circ A=((2,3),6):((10,60),360).
4.1.5More general compositions
The graphical calculus we have developed naturally extends to compute the compositionB∘AB\circ Aof a tractable layoutAAwith an arbitrary CuTe layoutBB. Informally, we do this by allowing our tuples to have entries inℚ>0⊃ℤ>0\mathbb{Q}_{>0}\supset\mathbb{Z}_{>0}. We illustrate this extension with an example computation.
Consider the layoutsA=(4,4):(4,1)A=(4,4):(4,1)andB=(8,8):(3,7)B=(8,8):(3,7). The layoutAAis tractable, and its standard representation is the tuple morphismffshown below.
4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}f{\lx@inpgf@ignorespaces f}The layoutBBis not tractable, but we may still depictBBusing the diagram
8{\lx@inpgf@ignorespaces 8}724{\lx@inpgf@ignorespaces\frac{7}{24}}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}3{\lx@inpgf@ignorespaces 3}g{\lx@inpgf@ignorespaces g}This diagram does not correspond to an honest tuple morphism since the “codomain tuple”(3,8,724,8)(3,8,\frac{7}{24},8)has non-integer entries. However, it still encodes the layoutBBvia the usual prefix product formula, and is still admissible as an input to our composition algorithm: We can apply Algorithm4.1.1to obtain the mutual refinement
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}form the diagram
4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}724{\lx@inpgf@ignorespaces\frac{7}{24}}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}8{\lx@inpgf@ignorespaces 8}3{\lx@inpgf@ignorespaces 3}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}resolve this diagram to obtain
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}724{\lx@inpgf@ignorespaces\frac{7}{24}}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}3{\lx@inpgf@ignorespaces 3}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}and composef′f^{\prime}andg′g^{\prime}to obtain the diagram
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}724{\lx@inpgf@ignorespaces\frac{7}{24}}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}3{\lx@inpgf@ignorespaces 3}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}The encoded layout is((2,2),4):((12,7),3)((2,2),4):((12,7),3), which is coalesced over(4,4)(4,4), so we conclude that
B∘A=((2,2),4):((12,7),3).B\circ A=((2,2),4):((12,7),3).
4.1.6Admissibility for composition
In[21], the author introduces the notion ofadmissibility for composition, which is a sufficient condition for the compositionB∘AB\circ Aof layoutsAAandBBto exist. Let’s recall the definition of admissibility for composition. As in[21], we restrict our attention to flat layouts with no shape entries equal to11, and we assume that the first layout in our composition has no strides equal to00.
Definition 4.1.6.1.
Suppose
A=(s1,…,sm):(d1,…,dm)A=(s_{1},\dots,s_{m}):(d_{1},\dots,d_{m})is a flat layout with nosi=1s_{i}=1and nodi=0d_{i}=0. SupposeBBis a flat layout with
𝗌𝗁𝖺𝗉𝖾(B)=(u1,…,up).\mathsf{shape}(B)=(u_{1},\dots,u_{p}).We sayAAandBBareadmissible for compositionif the following conditions hold.
- 1.For each1≤i≤m1\leq i\leq m, there exists1≤k≤ℓ≤p1\leq k\leq\ell\leq psuch that 1. (a)u1⋯uk−1u_{1}\cdots u_{k-1}dividesdid_{i}, 2. (b)did_{i}dividesu1⋯uku_{1}\cdots u_{k}(properly ifk<pk<p), 3. (c)u1⋯uℓ−1u_{1}\cdots u_{\ell-1}dividessidis_{i}d_{i}, 4. (d)sidis_{i}d_{i}dividesu1⋯uℓu_{1}\cdots u_{\ell}(properly ifℓ<p\ell<p).
- 2.The intervals [di,di(si−1)]∩[1,s1⋯sm−1)[d_{i},d_{i}(s_{i}-1)]\cap[1,s_{1}\cdots s_{m-1})are pairwise disjoint.
Lemma 4.1.6.4.
SupposeT=(t1,…,tn)T=(t_{1},\dots,t_{n})andU=(u1,…,up)U=(u_{1},\dots,u_{p})are tuples of positive integers, and suppose(T,U)(T,U)admits a mutual refinement. Then for any prefix productst1⋯tjt_{1}\cdots t_{j}andu1⋯uku_{1}\cdots u_{k}ofTTandUU, respectively, either
- 1.t1⋯tjt_{1}\cdots t_{j}is greater thanu1⋯uku_{1}\cdots u_{k}, or
- 2.t1⋯tjt_{1}\cdots t_{j}dividesu1⋯uku_{1}\cdots u_{k}.
Proof.
Let’s choose some mutual refinement(T′,U′)(T^{\prime},U^{\prime})of(T,U)(T,U), and write(u1′,…,up′′)(u_{1}^{\prime},\dots,u_{p^{\prime}}^{\prime})for the flattening ofU′U^{\prime}. Any prefix product ofTTorUUis also a prefix product ofU′U^{\prime}, and since prefix products of a fixed tuple of positive integers satisfyx≤y⇒x|yx\leq y\Rightarrow x\mid y, the result follows. ∎
Theorem 4.1.6.5.
SupposeAAis a flat tractable layout with no shape entries equal to11and no stride entries equal to00. SupposeBBis a flat tractable layout. Letf:S→Tf:S\to Tandg:U→Vg:U\to Vdenote the standard representation ofAAand𝖼𝗈𝖺𝗅(B)\mathsf{coal}(B), respectively. IfTTandUUadmit a mutual refinement, thenAAandBBare admissible for composition.
Proof.
Let’s writeS=(s1,…,sm)S=(s_{1},\dots,s_{m}),T=(t1,…,tn)T=(t_{1},\dots,t_{n}),U=(u1,…,up)U=(u_{1},\dots,u_{p}), and let’s writeα:⟨m⟩∗→⟨n⟩∗\alpha:\langle m\rangle_{*}\to\langle n\rangle_{*}for the map over whichfflies. We need to check that the conditions from Definition4.1.6.1hold.
- 1.Suppose1≤i≤m1\leq i\leq m. Thendi=t1⋯tj−1d_{i}=t_{1}\cdots t_{j-1}for somejj, namelyj=α(i)j=\alpha(i). Suppose we have a mutual refinement(T′,U′)(T^{\prime},U^{\prime})of(T,U)(T,U), and write(T′)♭=(t1′,…,tn′′)(T^{\prime})^{\flat}=(t_{1}^{\prime},\dots,t_{n^{\prime}}^{\prime})and(U′)♭=(u1′,…,up′′)(U^{\prime})^{\flat}=(u_{1}^{\prime},\dots,u_{p^{\prime}}^{\prime}). - •(a) and (b): SinceT′T^{\prime}refinesTT, there there exists some1≤a≤n′1\leq a\leq n^{\prime}such that di=t1⋯tj−1=t1′⋯ta′=u1′⋯ua′.d_{i}=t_{1}\cdots t_{j-1}=t_{1}^{\prime}\cdots t_{a}^{\prime}=u_{1}^{\prime}\cdots u_{a}^{\prime}.Take the maximalk∈⟨p⟩k\in\langle p\ranglesuch thatu1⋯uk−1≤u1′⋯ua′u_{1}\cdots u_{k-1}\leq u_{1}^{\prime}\cdots u_{a}^{\prime}. - –Supposek<pk<p. We observe that u1⋯uk−1≤di<u1⋯uk.u_{1}\cdots u_{k-1}\leq d_{i}<u_{1}\cdots u_{k}.where the second inequality holds by maximality ofk∈⟨p⟩k\in\langle p\rangle. Lemma4.1.6.4implies thatu1⋯uk−1u_{1}\cdots u_{k-1}dividesdid_{i}anddid_{i}dividesu1⋯uku_{1}\cdots u_{k}properly. - –Supposek=pk=p. We observe that u1⋯uk−1≤di=t1⋯tj−1<t1⋯tn≤u1⋯up=u1⋯uk.u_{1}\cdots u_{k-1}\leq d_{i}=t_{1}\cdots t_{j-1}<t_{1}\cdots t_{n}\leq u_{1}\cdots u_{p}=u_{1}\cdots u_{k}.Lemma4.1.6.4implies thatu1⋯uk−1u_{1}\cdots u_{k-1}dividesdid_{i}anddid_{i}dividesu1⋯uku_{1}\cdots u_{k}(properly, though we don’t require this). - •(c) and (d): Again, sinceT′T^{\prime}refinesTT, there exists some1≤b≤n′1\leq b\leq n^{\prime}such that sidi=t1⋯tj=t1′⋯tb′=u1′⋯ub′.s_{i}d_{i}=t_{1}\cdots t_{j}=t_{1}^{\prime}\cdots t_{b}^{\prime}=u_{1}^{\prime}\cdots u_{b}^{\prime}.Take the maximalℓ∈⟨p⟩\ell\in\langle p\ranglesuch thatu1⋯uℓ−1≤u1′⋯ub′u_{1}\cdots u_{\ell-1}\leq u_{1}^{\prime}\cdots u_{b}^{\prime}. - –Supposeℓ<p\ell<p. We observe that u1⋯uℓ−1≤sidi<u1⋯uℓ.u_{1}\cdots u_{\ell-1}\leq s_{i}d_{i}<u_{1}\cdots u_{\ell}.where the second inequality holds by maximality ofℓ∈⟨p⟩\ell\in\langle p\rangle. Lemma4.1.6.4implies thatu1⋯uℓ−1u_{1}\cdots u{\ell-1}dividessidis_{i}d_{i}andsidis_{i}d_{i}dividesu1⋯uℓu_{1}\cdots u_{\ell}properly. - –Supposeℓ=p\ell=p. We observe that u1⋯uℓ−1≤sidi=t1⋯tj≤t1⋯tn≤u1⋯up=u1⋯uk.u_{1}\cdots u_{\ell-1}\leq s_{i}d_{i}=t_{1}\cdots t_{j}\leq t_{1}\cdots t_{n}\leq u_{1}\cdots u_{p}=u_{1}\cdots u_{k}.Lemma4.1.6.4implies thatu1⋯uk−1u_{1}\cdots u_{k-1}dividesdid_{i}anddid_{i}dividesu1⋯uku_{1}\cdots u_{k}.
- 2.For anyi≠i′i\neq i^{\prime}in⟨m⟩\langle m\rangle, we havedi=t1⋯tj−1d_{i}=t_{1}\cdots t_{j-1},si=tjs_{i}=t_{j},di′=t1⋯tj′−1d_{i^{\prime}}=t_{1}\cdots t_{j^{\prime}-1}, andsi′=tj′s_{i^{\prime}}=t_{j^{\prime}}, wherej=α(i)j=\alpha(i)andj′=α(i′)j^{\prime}=\alpha(i^{\prime}). We then have [di,di(si−1)]=[t1⋯tj−1,t1⋯tj−1(tj−1)][d_{i},d_{i}(s_{i}-1)]=[t_{1}\cdots t_{j-1},t_{1}\cdots t_{j-1}(t_{j}-1)]and [di′,di′(si′−1)]=[t1⋯tj′−1,t1⋯tj′−1(tj′−1)][d_{i^{\prime}},d_{i^{\prime}}(s_{i^{\prime}}-1)]=[t_{1}\cdots t_{{j^{\prime}}-1},t_{1}\cdots t_{{j^{\prime}}-1}(t_{j^{\prime}}-1)]Ifj′>jj^{\prime}>j, then t1⋯tj−1(tj−1)<t1⋯tj′−1t_{1}\cdots t_{j-1}(t_{j}-1)<t_{1}\cdots t_{{j^{\prime}}-1}so the intervals do not overlap, and similarly ifj<j′j<j^{\prime}.
∎
4.2Logical division and logical product
In this section we illustrate how the composition algorithm4.1.3can be used to compute logical division and logical product.
4.2.1Logical division examples
Recall that ifAAandBBare layouts, the logical divisionA⊘BA\oslash Bis defined as
A⊘B=A∘(B,Bc)A\oslash B=A\circ(B,B^{c})where
Bc=𝖼𝗈𝗆𝗉(B,𝗌𝗂𝗓𝖾(A)).B^{c}=\mathsf{comp}(B,\mathsf{size}(A)).
Example 4.2.1.1.
Suppose we want to compute the logical divisionA⊘BA\oslash BwhereA=(8,8):(8,1)A=(8,8):(8,1)andB=(2,2):(1,4)B=(2,2):(1,4). Then we can writeA=LgA=L_{g},B=LhB=L_{h}andBc=LhcB^{c}=L_{h^{c}}whereffandfcf^{c}are the tuple morphisms shown below.
2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}h{\lx@inpgf@ignorespaces h}hc{\lx@inpgf@ignorespaces h^{c}}g{\lx@inpgf@ignorespaces g}It follows that(B,Bc)(B,B^{c})is encoded by the nested tuple morphismf=(h,hc)f=(h,h^{c})shown below.
2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}We then proceed with our composition algorithm as before. We use algorithm4.1.1to find the mutual refinement
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}form the diagram
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}8{\lx@inpgf@ignorespaces 8}8{\lx@inpgf@ignorespaces 8}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}resolve the diagram to obtain
4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}f{\lx@inpgf@ignorespaces f}g′{\lx@inpgf@ignorespaces g^{\prime}}and composeffandg′g^{\prime}to obtain
2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}4{\lx@inpgf@ignorespaces 4}4{\lx@inpgf@ignorespaces 4}2{\lx@inpgf@ignorespaces 2}2{\lx@inpgf@ignorespaces 2}g′∘f{\lx@inpgf@ignorespaces g^{\prime}\circ f}The layout encoded by this nested tuple morphism is
Lg′∘f=((2,2),(2,2)):((8,32),(16,1))L_{g^{\prime}\circ f}=((2,2),(2,2)):((8,32),(16,1))which is coalesced over((2,2),(2,2))((2,2),(2,2)), so we conclude that
A⊘B=((2,2),(2,2)):((8,32),(16,1)).A\oslash B=((2,2),(2,2)):((8,32),(16,1)).
4.2.2Logical product examples
Recall that ifAAandBBare layouts, the logical productA⊗BA\otimes Bis defined as
A⊗B=(A,Ac∘B)A\otimes B=(A,A^{c}\circ B)where
Ac=𝖼𝗈𝗆𝗉(A,𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B)).A^{c}=\mathsf{comp}(A,\mathsf{size}(A)\cdot\mathsf{cosize}(B)).In particular, if we want to computeA⊗BA\otimes Bby hand, it suffices to computeAc∘BA^{c}\circ B, and then concatenate the result withAA.
Example 4.2.2.1.
Suppose we want to compute the logical productA⊗BA\otimes BwhereA=(2,2):(1,2)A=(2,2):(1,2)andB=(5,5):(5,1)B=(5,5):(5,1). Then
Ac\displaystyle A^{c}=𝖼𝗈𝗆𝗉(A,𝗌𝗂𝗓𝖾(A)⋅𝖼𝗈𝗌𝗂𝗓𝖾(B))\displaystyle=\mathsf{comp}(A,\mathsf{size}(A)\cdot\mathsf{cosize}(B))=𝖼𝗈𝗆𝗉(A,100)\displaystyle=\mathsf{comp}(A,100)=(25):(4).\displaystyle=(25):(4).We proceed as in the previous section.
- 1.Take the standard representations ofBBand𝖼𝗈𝖺𝗅(Ac)=Ac\mathsf{coal}(A^{c})=A^{c}. 5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}4{\lx@inpgf@ignorespaces 4}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 2.Apply Algorithm4.1.1to obtain the mutual refinement 5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}
- 3.Form the diagram 5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}25{\lx@inpgf@ignorespaces 25}4{\lx@inpgf@ignorespaces 4}f{\lx@inpgf@ignorespaces f}g{\lx@inpgf@ignorespaces g}
- 4.Resolve the diagram to obtain 5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}4{\lx@inpgf@ignorespaces 4}f′{\lx@inpgf@ignorespaces f^{\prime}}g′{\lx@inpgf@ignorespaces g^{\prime}}
- 5.Composef′f^{\prime}andg′g^{\prime}to obtain 5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}5{\lx@inpgf@ignorespaces 5}4{\lx@inpgf@ignorespaces 4}g′∘f′{\lx@inpgf@ignorespaces g^{\prime}\circ f^{\prime}}
- 6.Compute the encoded layout Lg′∘f′=(5,5):(20,4).L_{g^{\prime}\circ f^{\prime}}=(5,5):(20,4).
- 7.The layoutLg′∘f′L_{g^{\prime}\circ f^{\prime}}is coalesced over(5,5)(5,5), so Ac∘B=(5,5):(20,4).A^{c}\circ B=(5,5):(20,4).
We conclude that
A⊗B=((2,2),(5,5)):((1,2),(20,4)).A\otimes B=((2,2),(5,5)):((1,2),(20,4)).
Appendix AAn introduction to categories
Throughout this work, we freely use the language ofcategorieswhich are mathematical objects which abstract the notion ofmorphismsand theircomposition. The purpose of this appendix is to provide a concise and user-friendly introduction to the basics of categories. In particular, we aim to the answer the following questions:
- 1.What is a category?
- 2.What is a functor?
Those capable of answering these questions with confidence, and with examples in mind, will be able to understand the most important conepts and constructions in the current work. For those interested in learning the more advanced concepts from category theory, such asnatural transformations,adjunctions, and(co)limits, we recommend[13].
A.1What is a category?
We begin by addressing the first question. Before giving a definition, let’s consider a motivating example. SupposeXXandYYare sets. Afunctionf:X→Yf:X\to Yassigns to each elementx∈Xx\in Xsome elementf(x)∈Yf(x)\in Y. We refer toXXas thedomainofffand toggas thecodomainofYY.
Example A.1.0.1.
There is a functionf:ℤ→ℤf:\mathbb{Z}\to\mathbb{Z}given by
Example A.1.0.2.
There is a functiong:ℤ→𝖡𝗈𝗈𝗅g:\mathbb{Z}\to\mathsf{Bool}, where𝖡𝗈𝗈𝗅={𝐓𝐫𝐮𝐞,𝐅𝐚𝐥𝐬𝐞}\mathsf{Bool}=\{\mathbf{True},\mathbf{False}\}, given by
g(x)={𝐓𝐫𝐮𝐞xis even,𝐅𝐚𝐥𝐬𝐞xis odd..g(x)=\begin{cases}\mathbf{True}&x\text{ is even,}\\ \mathbf{False}&x\text{ is odd.}\end{cases}.
Iff:X→Yf:X\to Yandg:Y→Zg:Y\to Zare functions, then we cancomposeffandgg: The composite offfandggis the functiong∘f:X→Zg\circ f:X\to Zgiven by
(g∘f)(x)=g(f(x)).(g\circ f)(x)=g(f(x)).
Example A.1.0.3.
Ifffandggare the functions of ExamplesA.1.0.1andA.1.0.2, then the compositeg∘f:ℤ→𝖡𝗈𝗈𝗅g\circ f:\mathbb{Z}\to\mathsf{Bool}is given by
(g∘f)(x)=𝐓𝐫𝐮𝐞.(g\circ f)(x)=\mathbf{True}.
Composition of functions satisfies two essential properties. First, composition isassociative: ifffandggare composable, andggandhhare composable, then
h∘(g∘f)=(h∘g)∘f.h\circ(g\circ f)=(h\circ g)\circ f.Second, every setXXhas anidentityfunction𝗂𝖽X:X→X\mathsf{id}_{X}:X\to Xgiven by
𝗂𝖽X(x)=x.\mathsf{id}_{X}(x)=x.Iff:X→Yf:X\to Yis any function, then precomposing with𝗂𝖽X\mathsf{id}_{X}or post-composing with𝗂𝖽Y\mathsf{id}_{Y}leaves the functionffunchanged:
f∘𝗂𝖽X=f=𝗂𝖽Y∘f.f\circ\mathsf{id}_{X}=f=\mathsf{id}_{Y}\circ f. In pure and applied mathematics, there are many instances where we have some collection ofobjects, andmorphismsbetween those objects, which have the same formal behavior of sets and functions: morphisms can be composed in an associative fashion, and objects admit identity morphisms. While functions between sets are the prototypical example, the objects in a category need not be sets, and the morphisms in a category need not be functions. We will see many such examples later on. To capture this recurring structure, we define the notion of acategory.
Definition A.1.0.4.
Acategory𝗖{\boldsymbol{\mathsf{C}}}consists of
- 1.a collection ofobjects: 𝗈𝖻(𝗖)={X,Y,Z,…}.\mathsf{ob}({\boldsymbol{\mathsf{C}}})=\{X,Y,Z,\dots\}.These objects may be sets, tuples, numbers, vector spaces, matrices, or some other mathematical structure, depending on the category𝗖{\boldsymbol{\mathsf{C}}}.
- 2.a collection ofmorphismsbetween those objects: 𝗆𝗈𝗋(𝗖)={f,g,h,…}.\mathsf{mor}({\boldsymbol{\mathsf{C}}})=\{f,g,h,\dots\}.Each morphismf:X→Yf:X\to Yin𝗖{\boldsymbol{\mathsf{C}}}has adomainXXand acodomainYY, which are objects in𝗖{\boldsymbol{\mathsf{C}}}.
- 3.acomposition rule: Iff:X→Yf:X\to Yandg:Y→Zg:Y\to Zare morphisms in𝗖{\boldsymbol{\mathsf{C}}}, then there is a morphism called thecompositeofffandgg. Composition of morphisms in𝗖{\boldsymbol{\mathsf{C}}}isassociative, in that h∘(g∘f)=(h∘g)∘f,h\circ(g\circ f)=(h\circ g)\circ f,when defined.
- 4.identity morphisms: IfXXis an object in𝗖{\boldsymbol{\mathsf{C}}}, then there is a morphism 𝗂𝖽X:X→X\mathsf{id}_{X}:X\to Xcalled theidentity morphismonXX. Iff:X→Yf:X\to Yis any morphism in𝗖{\boldsymbol{\mathsf{C}}}, then f∘𝗂𝖽X\displaystyle f\circ\mathsf{id}_{X}=f=𝗂𝖽Y∘f.\displaystyle=f=\mathsf{id}_{Y}\circ f.
Let’s take a look at some important examples of categories. We begin with the motivating example.
Example A.1.0.5.
There is a category𝗦𝗲𝘁{\boldsymbol{\mathsf{Set}}}whose objects are sets, and whose morphisms are functions. The composition of morphisms is given by functional composition:
(g∘f)(x)=g(f(x))(g\circ f)(x)=g(f(x))and the identity morphism on a setXXis the identity function
𝗂𝖽X(x)=x.\mathsf{id}_{X}(x)=x.
Example A.1.0.6.
There is a category𝗩𝗲𝗰𝘁{\boldsymbol{\mathsf{Vect}}}whose objects are the vector spacesℝn\mathbb{R}^{n}forn≥0n\geq 0, and whose morphisms arematrices. Specifically, a morphism
A:ℝn→ℝmA:\mathbb{R}^{n}\to\mathbb{R}^{m}in𝗩𝗲𝗰𝘁{\boldsymbol{\mathsf{Vect}}}is am×nm\times nmatrixAA. Composition in𝗩𝗲𝗰𝘁{\boldsymbol{\mathsf{Vect}}}is given by taking matrix products:
and the identity morphism onℝn\mathbb{R}^{n}is then×nn\times nmatrix
𝗂𝖽ℝn=In=[10⋯001⋱100⋯01].\mathsf{id}_{\mathbb{R}^{n}}=I_{n}=\begin{bmatrix}1&0&\cdots&&0\\ 0&1&&&\\ \vdots&&\ddots&&\vdots\\ &&&1&0\\ 0&&\cdots&0&1\end{bmatrix}.
Example A.1.0.7.
There is a category𝗗𝗶𝘃{\boldsymbol{\mathsf{Div}}}whose objects are integersa≥1a\geq 1, and in which there is a unique morphism
𝖽𝗂𝗏ab:a→b\mathsf{div}_{a}^{b}:a\to bifaadividesbb. Ifaadividesbbandbbdividescc, thenaadividescc, which means that we have a well defined composition rule
𝖽𝗂𝗏bc∘𝖽𝗂𝗏ab=𝖽𝗂𝗏ac,\mathsf{div}_{b}^{c}\circ\mathsf{div}_{a}^{b}=\mathsf{div}_{a}^{c},and the identity morphism
𝗂𝖽a=𝖽𝗂𝗏aa\mathsf{id}_{a}=\mathsf{div}_{a}^{a}exists since every positive integeraadivides itself.
In addition to the definition of a category, there are a few important categorical concepts that we need to understand. For instance, it is important to understand the notion of anisomorphism, which generalizes the notion of abijectionof sets.
Definition A.1.0.8.
Suppose𝗖{\boldsymbol{\mathsf{C}}}is a category, and supposef:X→Yf:X\to Yis a morphism in𝗖{\boldsymbol{\mathsf{C}}}. We sayffis anisomorphismif there exists a morphismf−1:Y→Xf^{-1}:Y\to Xin𝗖{\boldsymbol{\mathsf{C}}}such that
- 1.f−1∘f=𝗂𝖽Xf^{-1}\circ f=\mathsf{id}_{X}, and
- 2.f∘f−1=𝗂𝖽Yf\circ f^{-1}=\mathsf{id}_{Y}.
Example A.1.0.9.
In the category𝗦𝗲𝘁{\boldsymbol{\mathsf{Set}}}, an isomorphism is abijection: a functionf:X→Yf:X\to Ysuch that for eachy∈Yy\in Y, there exists a uniquex∈Xx\in Xwithf(x)=yf(x)=y. For example, the functionf:ℤ→ℤf:\mathbb{Z}\to\mathbb{Z}given by
is a bijection, with inversef−1:ℤ→ℤf^{-1}:\mathbb{Z}\to\mathbb{Z}given by
f−1(x)=x−10.f^{-1}(x)=x-10.
Example A.1.0.10.
In the category𝗩𝗲𝗰𝘁{\boldsymbol{\mathsf{Vect}}}, an isomorphism is aninvertible matrix. For example, the matrix
A=[3211]A=\begin{bmatrix}3&2\\ 1&1\\ \end{bmatrix}is invertible with inverse
A−1=[1−2−13]A^{-1}=\begin{bmatrix}1&-2\\ -1&3\\ \end{bmatrix}since
A−1A=[1001]=AA−1A^{-1}A=\begin{bmatrix}1&0\\ 0&1\\ \end{bmatrix}=AA^{-1}
Example A.1.0.11.
In the category𝗗𝗶𝘃{\boldsymbol{\mathsf{Div}}}, the only isomorphisms are the identity morphisms
𝗂𝖽a=𝖽𝗂𝗏aa.\mathsf{id}_{a}=\mathsf{div}_{a}^{a}.This is because ifaadividesbbandbbdividesaa, thena=ba=b.
A.2What is a functor?
Next, we turn our attention to the second question.
Definition A.2.0.1.
Suppose𝗖{\boldsymbol{\mathsf{C}}}and𝗗{\boldsymbol{\mathsf{D}}}are categories. AfunctorF:𝗖→𝗗F:{\boldsymbol{\mathsf{C}}}\to{\boldsymbol{\mathsf{D}}}consists of
- 1.for each objectXXin𝗖{\boldsymbol{\mathsf{C}}}, an objectFXFXin𝗗{\boldsymbol{\mathsf{D}}}, and
- 2.for each morphismf:X→Yf:X\to Yin𝗖{\boldsymbol{\mathsf{C}}}, a morphism in𝗗{\boldsymbol{\mathsf{D}}},
satisfying the following properties:
- 1.FFis compatible with composition: Ifffandggare composable morphisms in𝗖{\boldsymbol{\mathsf{C}}}, then F(g∘f)=Fg∘Ff.F(g\circ f)=Fg\circ Ff.
- 2.FFis compatible with identities: IfXXis an object in𝗖{\boldsymbol{\mathsf{C}}}, then F𝗂𝖽X=𝗂𝖽FX.F\mathsf{id}_{X}=\mathsf{id}_{FX}.
Example A.2.0.2.
There is a functorF:𝗗𝗶𝘃→𝗦𝗲𝘁F:{\boldsymbol{\mathsf{Div}}}\to{\boldsymbol{\mathsf{Set}}}defined as follows. On objects,FFis given by
Fa\displaystyle Fa=[0,a]={x∈ℝ∣0≤x≤a}.\displaystyle=[0,a]=\{x\in\mathbb{R}\mid 0\leq x\leq a\}.and on morphisms,FFis given by
F𝖽𝗂𝗏ab(x)=ba⋅x.{\lx@inpgf@ignorespaces F\mathsf{div}_{a}^{b}(x)=\frac{b}{a}\cdot x.}Let’s verify thatFFis a functor.
- 1.FFis compatible with composition: Ifaadividesbbandbbdividescc, then (F𝖽𝗂𝗏bc∘F𝖽𝗂𝗏ab)(x)=F𝖽𝗂𝗏bc(F𝖽𝗂𝗏ab(x))\displaystyle(F\mathsf{div}_{b}^{c}\circ F\mathsf{div}_{a}^{b})(x)=F\mathsf{div}_{b}^{c}(F\mathsf{div}_{a}^{b}(x))=cb⋅(ba⋅x)=ca⋅x=F𝖽𝗂𝗏ac(x).\displaystyle=\frac{c}{b}\cdot(\frac{b}{a}\cdot x)=\frac{c}{a}\cdot x=F\mathsf{div}_{a}^{c}(x).
- 2.FFis compatible with identities: Ifa≥1a\geq 1, then F𝗂𝖽a(x)=F𝖽𝗂𝗏aa(x)=aa⋅x=𝗂𝖽Fa(x).\displaystyle F\mathsf{id}_{a}(x)=F\mathsf{div}_{a}^{a}(x)=\frac{a}{a}\cdot x=\mathsf{id}_{Fa}(x).
Bibliography
- [1]S. G. Bhaskaracharya, A. Acharya, B. Hagedorn, and V. Grover(2025)Modeling layout abstractions using integer set relations.External Links:2511.10374,LinkCited by:3rd item.
- [2]U. Bondhugula, A. Hartono, J. Ramanujam, and P. Sadayappan(2008)A practical automatic polyhedral parallelizer and locality optimizer.InProceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation,PLDI ’08.External Links:DocumentCited by:4th item.
- [3]C. Cecka, V. Thakkar, and T. Shah(2025)CUTLASS: principled abstractions for handling multidimensional data through tensors and spatial microkernels.Note:NVIDIA Technical BlogExternal Links:LinkCited by:1st item.
- [4]Z. Chen, A. Kerr, R. Cai, J. Kosaian, H. Wu, Y. Ding, and Y. Xie(2024)EVT: accelerating deep learning training with epilogue visitor tree.InProceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS), Volume 3,pp.301–316.External Links:DocumentCited by:1st item.
- [5]N. Corporation(2024)CuTe — nvidia cute documentation(Website)External Links:LinkCited by:3rd item,§1.3.
- [6]N. Corporation(2025)CuTe dsl — nvidia cutlass documentation(Website)External Links:LinkCited by:3rd item.
- [7]T. Dao(2024)FlashAttention-2: faster attention with better parallelism and work partitioning.InInternational Conference on Learning Representations (ICLR),Cited by:1st item.
- [8]O. J. S. David F. Bacon(1994)Compiler transformations for high-performance computing.ACM Computing Surveys26(4),pp.345–420.External Links:DocumentCited by:2nd item.
- [9]T. Grosser, A. Größlinger, and C. Lengauer(2012)Polly—performing polyhedral optimizations on a low-level intermediate representation.Parallel Processing Letters22(4).Cited by:4th item.
- [10]W. Guo, M. Mishra, X. Cheng, I. Stoica, and T. Dao(2025)SonicMoE: accelerating moe with io and tile-aware optimizations.External Links:2512.14080,LinkCited by:1st item.
- [11]Y. Ju and H. Dietz(1992)Reduction of cache coherence overhead by compiler data layout and loop transformation.InLanguages and Compilers for Parallel Computing,U. Banerjee, D. Gelernter, A. Nicolau, and D. Padua (Eds.),Berlin, Heidelberg.External Links:DocumentCited by:2nd item.
- [12]T. G. Kolda and B. W. Bader(2009)Tensor decompositions and applications.SIAM Review51(3),pp.455–500.External Links:Document,LinkCited by:5th item.
- [13]S. Mac Lane(1998)Categories for the working mathematician.2edition,Graduate Texts in Mathematics, Vol.5,Springer.External Links:ISBN 978-0-387-98403-0Cited by:Appendix A.
- [14]OpenAI(2025)Linear layouts in triton(Website)External Links:LinkCited by:3rd item.
- [15]E. Raman, R. Hundt, and S. Mannarswamy(2007)Structure layout optimization for multithreaded programs.InProceedings of the International Symposium on Code Generation and Optimization,CGO ’07,Washington, DC, USA,pp.271–282.External Links:DocumentCited by:2nd item.
- [16]J. Shah, G. Bikshandi, Y. Zhang, V. Thakkar, P. Ramani, and T. Dao(2024)FlashAttention-3: fast and accurate attention with asynchrony and low-precision.InAdvances in Neural Information Processing Systems (NeurIPS),Cited by:1st item.
- [17]J. Shah, P. VanKoughnett, and R. Asai(2024)CUTLASS tutorial: persistent kernels and stream-K.Note:Colfax ResearchExternal Links:LinkCited by:1st item.
- [18]J. Shah, P. VanKoughnett, and R. Asai(2025)CUTLASS tutorial: GEMM with thread block clusters on NVIDIA Blackwell GPUs.Note:Colfax ResearchExternal Links:LinkCited by:1st item.
- [19]J. Shah, P. VanKoughnett, and R. Asai(2025)CUTLASS tutorial: sub-byte GEMM on NVIDIA Blackwell GPUs.Note:Colfax ResearchExternal Links:LinkCited by:1st item.
- [20]J. Shah, P. VanKoughnett, and R. Asai(2025)CUTLASS tutorial: writing GEMM kernels using tensor memory for NVIDIA Blackwell GPUs.Note:Colfax ResearchExternal Links:LinkCited by:1st item.
- [21]J. Shah(2024)A note on the algebra of CuTe layouts.Technical reportColfax Research.External Links:LinkCited by:3rd item,Remark 4.1.6.2,Remark 4.1.6.3,§4.1.6.
- [22]K. Sharma, I. Karlin, J. Keasler, J. R. McGraw, and V. Sarkar(2015)Data layout optimization for portable performance.InEuropean Conference on Parallel Processing,Euro-Par 2015,Berlin, Heidelberg.External Links:DocumentCited by:2nd item.
- [23]Y. Shi, U. N. Niranjan, A. Anandkumar, and C. Cecka(2016)Tensor contractions with extended blas kernels on cpu and gpu.arXiv preprint.External Links:arXiv:1606.05696,LinkCited by:5th item.
- [24]B. Sun, V. Wang, F. Xie, T. Shah, and V. Thakkar(2025)Achieve CUTLASS C++ performance with Python APIs using CuTe DSL.Note:NVIDIA Technical BlogExternal Links:LinkCited by:1st item.
- [25]V. Thakkar, C. Cecka, T. Shah, J. Shah, P. VanKoughnett, and R. Asai(2025)CUTLASS 3.x: orthogonal, reusable, and composable abstractions for GEMM kernel design.Note:NVIDIA Technical BlogExternal Links:LinkCited by:1st item.
- [26]A. Thangamani, V. Loechner, and S. Genaud(2024)A survey of general-purpose polyhedral compilers.ACM Transactions on Architecture and Code Optimization21(4),pp.1–26.External Links:DocumentCited by:4th item.
- [27]N. Vasilache, O. Zinenko, T. Theodoridis, P. Goyal, Z. DeVito, W. S. Moses, S. Verdoolaege, A. Adams, and A. Cohen(2018)Tensor comprehensions: framework-agnostic high-performance machine learning abstractions.arXiv preprint arXiv:1802.04730.Note:Facebook AI Research Technical ReportCited by:4th item.
- [28]S. Verdoolaege(2010)Isl: an integer set library for the polyhedral model.InMathematical Software – ICMS 2010,K. Fukuda, J. van der Hoeven, M. Joswig, and N. Takayama (Eds.),Lecture Notes in Computer Science, Vol.6327,Berlin, Heidelberg.External Links:DocumentCited by:4th item.
- [29]S. Verdoolaege(2021)Presburger formulas and polyhedral compilation.Technical Report / TutorialPolly Labs and KU Leuven.Note:https://libisl.sourceforge.io/tutorial.pdfVersion v0.02-13-g53eb23d, August 21, 2021Cited by:4th item.
- [30]Z. Xu, J. Xu, H. Peng, W. Wang, X. Wang, H. Wan, H. Dai, Y. Xu, H. Cheng, K. Wang, and G. Chen(2023)ALT: breaking the wall between data layout and loop optimizations for deep learning compilation.InProceedings of the Eighteenth European Conference on Computer Systems,EuroSys ’23,New York, NY, USA.External Links:DocumentCited by:2nd item.
- [31]T. Zhao, T. Popoola, M. Hall, C. Olschanowsky, and M. Strout(2022)Polyhedral specification and code generation of sparse tensor contraction with co-iteration.ACM Transactions on Architecture and Code Optimization20(1),pp.1–26.Note:Article 16External Links:DocumentCited by:5th item.
- [32]K. Zhou, M. Lezcano-Casado, A. P. Goucher, A. Rakhmati, J. Niu, J. Lebar, P. Szczerbuk, P. Bell, P. Tillet, T. Raoux, and Z. Moudallal(2026)Linear layouts: robust code generation of efficient tensor computation using f2.InProceedings of the 31st ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1,ASPLOS ’26,New York, NY, USA,pp.1–18.External Links:DocumentCited by:3rd item.
Federico Bruzzone (@fedebruzzone7): CuTe Layout Representation and Algebra
🔗
Similar Articles
@charles_irl: ^That's a sample of CuTe DSL, which is used in, among others, the FlashAttention-4 kernel. Below is the sample CuTe ker…
A tweet showcasing a CuTe DSL kernel sample that uses layouts to express transposition, part of the FlashAttention-4 kernel.
@charles_irl: The CuTe and CuTe DSL articles include minimal code snippets illustrating core principles and basic usage. These snippe…
The CuTe and CuTe DSL articles provide minimal code snippets with Modal Notebooks for hands-on learning.
Applied Category Theory Course (2018)
An online course on applied category theory taught by John Baez, based on the book 'Seven Sketches in Compositionality', covering ordered sets, resource theories, and databases through a series of lecture notes.
@charles_irl: New articles in the GPU Glossary for CuTe DSL, CUTLASS, and CuTe -- the tools used to write some of the highest-perform…
New articles in the GPU Glossary cover CuTe DSL, CUTLASS, and CuTe – tools for writing high-performance GPU kernels on data center GPUs, with examples in Python.
C++ CuTe / CUTLASS vs CuTeDSL (Python) in 2026 — what should new GPU kernel / LLM inference engineers actually learn?[D]
Discussion of the shift in GPU kernel engineering from C++ CuTe/CUTLASS to NVIDIA's Python-based CuTeDSL, questioning whether new engineers should learn legacy C++ templates or prioritize the emerging stack for LLM inference work.