The problem of Boolean matrix multiplication has a wide range of fundamental applications, for instance, in graph algorithms (see, e.g., ). The Boolean product of two Boolean matrices can be computed using Boolean AND and OR binary operations following its definition. This is optimal if only these two types of operations are allowed [8, 9, 10]. If also the one argument NOT operation is allowed then the product can be computed using operations, where stands for the exponent of the so called fast arithmetic matrix multiplication. The bound follows by a straightforward reduction of Boolean matrix multiplication to the arithmetic one for matrices. Already five decades ago, Strassen presented an algorithm for arithmetic matrix multiplication breaking out of the standard method and using only multiplications, additions and subtractions . The following series of improvements of the exponent of fast matrix multiplication culminates in the recent results of Le Gall and Vassilevska Williams showing [6, 12]. On the other hand, Alman et al. have recently shown that there is an such that one cannot derive an upper bound on better than by using the known approaches . Also, the substantially sub-cubic algebraic algorithms for matrix multiplication have very large overhead which makes them hardly practical. Unfortunately, no the so called combinatorial (i.e., with small constants) algorithm for Boolean matrix multiplication running in time, for a fixed is known [2, 13]. The fastest known combinatorial algorithm for Boolean matrix multiplication due to Yu runs in time . Hence, a natural question arises about the complexity of Boolean matrix multiplication in different models of computation, possibly more powerful or unconventional.
To begin with, if one uses huge integers, requiring bits then the Boolean product of two Boolean matrices can computed in steps on RAM as observed in . Recently, also a nondeterministic algorithm for matrix multiplication using arithmetic operations has been presented by Korec and Wiedermann in . It results from a derandomization of Freivalds’ -time randomized algorithm for integer matrix product verification . Simply, the algorithm guesses first the product matrix and then verifies its correctness. Again, the derandomization involves huge numbers requiring times more bits than the input numbers . More recently, Wiedermann has presented two further, slightly slower nondeterministic algorithms for matrix multiplication, both running in time and relying on the derandomization of Freivalds’ algorithm. The first runs on a real RAM, the second on a unit-cost RAM using only integers of size proportional to that of the largest entry in the input matrices . On the other hand, no quantum algorithm for Boolean matrix product faster than those based on fast algebraic matrix multiplication in the standard computational model has been devised so far .
From the perspective of modern electronic computing, mechanical computing seems not only old-fashioned but even unconventional. The history of mechanical devices assisting computing stretches several thousands years back, e.g., the so called Roman abacus was used as early as 2700-2300 B.C. in Babylonia . Under several thousands of years mechanical devices assisted astronomical and navigation calculations. The slide-rule has been used since 1620 and mechanical calculators were intensively developed in 17, 18 and 19 centuries (e.g., by Pascal, Leibniz and Babbage).
In this paper, we study the problem of determining the Boolean product of two Boolean matrices in an unconventional computational model allowing for mechanical operations. We show that the Boolean product of an Boolean matrix with an -dimensional Boolean column vector can be computed using operations. Hence, we can infer that operations are sufficient to compute the Boolean product of two Boolean matrices in this model. For smaller matrices the mechanical operations can be performed even manually while for the larger ones the operations can be automatized using electric power. Our result demonstrates that already ancient civilizations had sufficient technology to perform relatively fast matrix multiplication of moderately large Boolean matrices. To the best of our knowledge, we are not familiar with any prior mechanical approach to (Boolean) matrix multiplication.
1.1 Basic ideas
Our mechanical algorithm for Boolean matrix multiplication computes the Boolean product of the two input Boolean matrices by repetitive multiplication of the first matrix with consecutive columns of the second matrix. While computing the Boolean product of a fixed Boolean matrix with a Boolean column vector one encounters two major bottlenecks that prohibit obtaining a substantially sub-quadratic in number of operations in the standard computational model (solely poly-logarithmic speedups are known after preprocessing ). Note that only the -th columns of the fixed matrix where the -th coordinate of the input column vector is can affect the output product vector. The first bottleneck is the selection of the aforementioned columns (alternatively, activating them and deactivating the remaining ones). The other bottleneck is the computation of the disjunction of entries belonging to active columns for each row of the fixed matrix. We design a special purpose mechanical processor for computing the Boolean product of a Boolean matrix with a Boolean -dimensional column vector that solves each of the two bottleneck problems using mechanical operations. The matrix-vector processor (MVP) needs also to perform a number of other operations, e.g., reading the input vector or the input matrix or outputting the product vector etc., that can be implemented purely mechanically (if one insists on that) in many ways. We leave here the details to the reader.
2 Requirements on a processor for matrix-vector product
We shall use a special purpose processor for computing the Boolean product of a Boolean matrix with a Boolean -dimensional column vector. We shall term such a processor MVP for short. In particular, an MVP has an input array part, an input -dimensional vector part, and an output -dimensional vector part, see Fig. 3. In this section, we shall provide solely general requirements that an MVP should satisfy. In Section 4, we shall outline implementations of MVP including mechanical operations that allow for fulfillment of these requirements. The list of requirements is as follows.
A Boolean matrix can be read into the MVP input array using operations.
A Boolean -dimensional vector can be read into the MVP input vector using operations.
The MVP output vector can be reported using operations.
All -th columns of the MVP input array can be appropriately activated/deactivated (if necessary) such that afterwards the -th column is active if and only if the -th coordinate of the MVP input vector is set to , using totally operations.
For all -th rows of the MVP input array that include at least one belonging to an active column of the array the -th coordinate of the MVP output vector can be set to while all other coordinates of the output vector can be set to using totally operations.
The MVP output vector can be reset to an initial state using operations.
3 The algorithms for Boolean matrix-vector and matrix-matrix products
In this section, we present two simple mechanical algorithms for Boolean matrix-vector product and Boolean matrix-matrix product, respectively. Both are based on the use of an MVP. It will be convenient to refer to the first algorithm as a functional procedure in order to facilitate its repetitive use in the second algorithm.
The procedure Matvec(A,V) computes the Boolean column vector product of and correctly, using operations.
The correctness of the procedure follows from the following two facts.
The -th coordinate of the MVP output vector is set to if and only if the -th row of the MVP input array includes at least one belonging to an active column of the array.
The -th column of the MVP input array is active if and only if the -th coordinate of the MVP input vector is set to
The upper bound on the number of operations necessary to implement follows from the requirements on an MVP (see the previous section). In particular the upper bound on the total number of operations necessary to implement the first loop follows from Requirement 4 while that for the second loop from Requirement 5. ∎
By repetitively applying to consecutive columns of the second input Boolean matrix we obtain our algorithm (Algorithm 1) for Boolean matrix-matrix product.
Algorithm 1 computes the Boolean product of the matrices and correctly, using operations.
The correctness of the algorithm follows from the fact
that it computes the consecutive columns of
the Boolean product of and correctly
Lemma 1. The calls of the procedure require totally operations by Lemma 1. Reading the matrix in the input array requires operations by Requirement 1 on an MVP. Reading the consecutive columns of the matrix into the MVP input vector totally requires operations by Requirement 2. Finally, resetting the MVP output vectors requires operations by Requirement 6. ∎
Observe that all the requirements on MVP but for the bottleneck ones 4 and 5 can be easily realized up to logarithmic factors in such standard sequential computational nmodels as RAM, Turing machine or Boolean circuits. Hence, if the bottleneck requirements could be realized in substantially subquadratic intime (even allowing for a subcubic in preprocessing of the matrix) in the aforementioned standard models, it would yield substantially subcubic in combinatorial algorithms for Boolean matrix multiplication, which would be a breakthrough (cf. [17, 15]).
4 A mechanical MVP
In this section, we outline an idea of implementation of an MVP with help of mechanical operations.
Each column of the MVP input array is modelled by an axis with attached equal size segments representing consecutive column entries. Each such a segment is either aligned to the axis which is interpreted as the corresponding entry is set to or it is set into a perpendicular to the axis position which is interpreted as the corresponding entry is set to See Fig. 4 for an example. If the column modelled by the axis is not active, the perpendicular segments are placed horizontally. If the column should be activated then the axis rotates degrees so all the attached perpendicular segments take vertical positions under the axis. Symmetrically, if the column is active and it should be deactivated the axis modelling it is rotated in the reverse direction by degrees. Such an activation/deactivation of a column is counted as a single operation. There are many possible ways to implement the rotation of the axis by degrees that we omit here. The whole process of activating/deactivating (if necessary) the -th columns of the input array such that afterwards the -th column is active if and only if the -th coordinate of the MVP input vector is set to requires at most operations of column activations/deactivations and scanning the representation of the input MVP vector. For instance, we may assume that the representation of the input vector is placed perpendicularly to the column axes close to their start-points so the whole process of activating/deactivating columns requires walking and scanning steps besides the activation/deactivation operations. In this way, Requirement 4 can be fulfilled.
In order to fulfill Requirement 5 for each row of the MVP input array, we place a ladder under the segments attached to the axes corresponding to the row, in the initial state when no column is active. The ladders are placed perpendicularly to the axes, see Fig. 5, 6. They can have some wheels to facilitate their horizontal movements in the direction perpendicular to the axes. We shall term the rectangular space between two successive ladder steps and the arms of the ladder as an opening. Each opening of the ladder lies exactly under one of the segments attached to an axis in the initial state when no column is active. Importantly, the placements and sizes of the axes, ladders, segments etc. are so chosen that the rotations of the axes with attached perpendicular segments are not obstructed by the ladders. If a segment is placed vertically after the rotation then it goes through and a bit sticks out under the corresponding ladder opening, see Fig. 5. A representation of the MVP output vector is placed along the rightmost axis. Initially, all coordinates of the output vector are set to In order to set the -th coordinate of the output vector, the ladder corresponding to the -th row of the input array is moved from the left to the right at most by the length of one opening, see Fig. 6. If no perpendicular segment sticks through any of its openings such a movement by the length of one opening is possible and the ladder hits the representation of the output vector in the section corresponding to its -th coordinate switching its state from to (Again, there are many possible technical ways of representing the MVP output vector and implementing such a switch that we omit here.) Otherwise, such a full movement is not possible and the state of the section remains set to In effect, the -th coordinate of the output vector is set to if and only if the -th row of the input array includes at least one belonging to an active column of the array. Each such a movement of the ladder with a possible triggering the switch of the state of the corresponding section is counted as ,say, operations. Hence, setting all the coordinates of the output vector requires operations and Requirement 5 is fulfilled.
To read a Boolean matrix into the MVP input array one can traverse the array for example in a column-wise snake fashion and pull out segments corresponding to the entries of the matrix that are aligned to their axis and push back the pulled out segments that correspond to the entries of the matrix Thus, we may assume that the reading of a Boolean matrix in the input array requires operations.
Similarly, reading a Boolean -dimensional vector into the MVP input vector as well as outputting the MVP output vector require operations. Finally, to reset the MVP output vector, we need to pull back the ladders to the left to their initial positions and switch all the coordinates of the output vector back to using operations. It follows that the remaining requirements can be fulfilled in this way.
4.1 A parallel mechanical MVP
In fact, the activations/deactivations of the appropriate columns of the MVP input array as well as setting the values of the coordinates of the MVP output vector can be done in parallel.
It is not difficult to design a bit more complex mechanical MVP where an appropriate representation of the MVP input vector is moved towards the start-points of the axes and the s in the representation hit the start-pints triggering the activation of the corresponding columns of the input array. More exactly, if the -th coordinate of the input vector is set to then the representation of this hits the start-point of the axis modelling the -th column casing its activation. Hence, the activations of all the columns can be done in one step of the movement of the representation of the input vector. In order to fulfill Requirement 4, we need to deactivate all columns first before the activation movement. The deactivation of all the columns can be obtained by the reverse movement of the representation of the previous input vector.
As for setting the output vector, i.e., Requirement 5, all the movements of the ladders to the right can be done independently of each other in one parallel step. (Still, if one would like to count the ladder movements as a single operation, one could elevate slightly the whole left part of the processor to cause sliding the ladders to the right at most by one opening length etc.) The same holds for the reverse movements of the ladders back to the left, i.e., resetting the output vector. Finally, the reading of an input vector into the MVP input vector can be also done in a single parallel step using operations while the reading of the input matrix into the input array can be done in parallel steps, each using operations.
Hence, we obtain the following lemma and theorem.
By using the parallel mechanical MVP, the procedure can be implemented in parallel steps using operations.
By using the parallel mechanical MVP, the Boolean product of two Boolean matrices can be computed in parallel steps, each using operations.
5 An alternative implementation of MVP
Here, we shall outline an alternative implementation of MVP using mechanical and light operations. Each column of the MVP input array is modelled by a thin movable wall vertically divided into sections. Each even numbered section has an always open round window of the same size in its middle. The -st section models the -th entry of the column in the input array. It has also a window of the same shape and size in the middle. The window can be either open or closed. The former is interpreted as setting the -th entry in the column to while the latter as setting this entry to Now, the activation of a column in the input array consists in shifting the corresponding wall by the length of a single section down. See Fig. 7 for an example. The deactivation of the column is obtained by the reverse move of the wall up. Both moves are counted as single operations. Hence, arguing similarly as in the previous section, we infer that Requirement 4 can be fulfilled.
To fulfill Requirement 5, lights are placed in front of even sections of the first wall in its initial deactivated position. See Fig. 7. The distance between two consecutive walls is very small. Such an -th light can be observed on the other side at the last wall through the windows of walls modelling deactivated columns and the open windows of walls modelling active columns if and only if the -th row of the input array does not contain any belonging to an active column. Thus, in case the light is observed the -th coordinate of the MVP output vector is set to and otherwise it is set to Since the observation of the light is counted as a single observation, Requirement 5 can be also fulfilled. The fulfillment of the remaining MVP requirements do not require any involved ideas and can be achieved in many ways so we omit its discussion.
6 Final remarks
Mechanical operations are very slow compared to the electronic ones. Also, it would be technically hard to apply the mechanical operations to very large matrices. For these reasons, in the range of matrix sizes feasible for mechanical operations, Boolean matrix multiplication can be performed much faster by electronic computers, even if they run the straightforward cubic-time algorithm.’ Still, it seems of at least theoretical interest that in the realm of mechanical computations one can design an algorithm for Boolean matrix multiplication using a quadratic number of operations in contrast to the straightforward one using a cubic number of operations. The two ideas behind our mechanical algorithm for Boolean matrix multiplication are switching on/off all entries of an array column in a single mechanical step and computing the disjunction of switched on entries of an array row in a single mechanical step. It would be interesting to study the complexity of other matrix/graph problems assuming that the aforementioned operations can be performed in single steps.
The research has been supported in part by Swedish Research Council grant 621-2017-03750.
-  J. Alman and V. Vassilevska Williams. Limits on All Known (and Some Unknown) Approaches to Matrix Multiplication. Proc. FOCS 2018.
-  N. Bansal and R. Williams. Regularity Lemmas and Combinatorial Algorithms.Theory of Computing, Vol. 8, No. 1, pp. 69-94, 2012.
-  R. Freivalds. Probabilistic Machines Can Use Less Running Time. IFIP Congress 1977, pp. 839–842.
-  I. Korec and J. Widermann. Deterministic Verification of Integer Matrix Multiplication in Quadratic Time. SOFSEM 2014: Theory and Practice of Computer Science, Lecture Notes in Computer Science Volume 8327, pp 375-382, 2014.
-  F. Le Gall. A Time-Efficient Output-Sensitive Quantum Algorithm for Boolean Matrix Multiplication. ISAAC 2012, PP. 639–648, 2012.
F. Le Gall.
Powers of Tensors and Fast Matrix Multiplication. 39th International Symposium on Symbolic and Algebraic Computation, July 2014.
-  A. Lingas, M. Persson, and D. Sledneu. Bounds for Semi-disjoint Bilinear Forms in a Unit-cost Computational Model. Proc. of the 13th annual conference on Theory and Applications of Models of Computation (TAMC 2016/2017), Lecture Notes in Computer Science, pp. 412-424, April 2017..
-  K. Mehlhorn and Z. Galil. Monotone Switching Circuits and Boolean Matrix Product. Computing 16, pp. 99-111, 1976.
-  M. Paterson. Complexity of Monotone Networks for Boolean Matrix Product. Theor. Comput. Sci. 1(1), pp. 13-20 (1975)
-  V.R. Pratt. The Power of Negative Thinking in Multiplying Boolean Matrices. SIAM J. Comput. 4(3), pp. 326-330, 1975.
-  V. Strassen. Gaussian elimination is not optimal. Numerische Mathematik 13, pp. 354-356, 1969.
-  V. Vassilevska Williams. Multiplying matrices faster than Coppersmith-Winograd. Proc. STOC 2012, pp. 887–898.
-  Vassilevska Williams, V. and Williams, R.: Subcubic Equivalences Between Path, Matrix, and Triangle Problems, J. ACM, Vol. 65(5), September 2018 (preliminary version FOCS 2010)
-  J. Wiedermann Fast Nondeterministic Matrix Multiplication via Derandomization of Freivalds’ Algorithm. IFIP TCS 2014, pp. 123–135
-  R. Williams, Matrix-vector multiplication in sub-quadratic time (some preprocessing required). Proc. of SODA 2007, pp. 995-2001.
-  The history of computing hardware. Wikipedia, 21 November 2019.
-  H. Yu. An Improved Combinatorial Algorithm for Boolean Matrix Multiplication. Proc. of ICALP 2015. pp 1094-1105.
-  U. Zwick. All pairs shortest paths using bridging sets and rectangular matrix multiplication. Journal of the ACM, 49(3), pp. 289-317, 2002.