{'fraction_non_alphanumeric': 0.058519793459552494, 'fraction_numerical': 0.02084528590552687, 'mean_word_length': 3.5644457375618273, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Binary Linear Codes, Dimers and Hypermatrices

We show that the weight enumerator of any binary linear code is equal to the permanent of a 3-dimensional hypermatrix (3-matrix). We also show that each permanent is a determinant of a 3-matrix. As an application we write the dimer partition function of a finite 3-dimensional cubic lattice as the determinant of the vertex-adjacency 3-matrix of a 2-dimensional simplicial complex which preserves the natural embedding of the cubic lattice.


Introduction
The Kasteleyn method is a way how to calculate the Ising partition function on a finite graph G. It goes as follows. We first realize that the Ising partition function is equivalent to a multivariable weight enumerator of the cut space of G. We modify G to graph G ′ so that this weight enumerator is equal to the generating function of the perfect matchings of G ′ , perhaps better known as the dimer partition function on G ′ . Such generating functions are hard to calculate. In particular, if G ′ is bipartite then the generating function of the perfect matchings of G ′ is equal to the permanent of the biadjacency matrix of G ′ . If however this permanent may be turned into the determinant of a modified matrix then the calculation can be successfully carried over since the determinants may be calculated efficiently. Already in 1913 Polya [6] asked for which non-negative matrix M we can change signs of its entries so that, denoting by M ′ the resulting matrix, we have per(M ) = det(M ′ ). We call these matrices Kasteleyn after the physicist Kasteleyn who invented the Kasteleyn method [2,3,4,10]. Kasteleyn [4] proved in 1960's that all biadjacency matrices of the planar bipartite graphs are Kasteleyn. We say that a bipartite graph is Pfaffian if its biadjacency matrix is Kasteleyn. The problem to characterize the Kasteleyn matrices (or equivalently Pfaffian bipartite graphs) was open until 1993, when Robertson, Seymour and Thomas [7] found a polynomial recognition method and a structural description of the Kasteleyn matrices. They showed that the class of the Kasteleyn matrices is rather restricted and extends only moderately beyond the biadjacency matrices of the planar bipartite graphs.
In this paper we carry out the Kasteleyn method for general binary linear codes. We show that the weight enumerator of any binary linear code is polynomial reducible to the permanent of the triadjacency 3-matrix of a 2-dimensional simplicial complex. In analogy to the standard (2-dimensional) matrices we say that a 3-dimensional non-negative matrix A is Kasteleyn if signs of its entries may be changed so that, denoting by A ′ the resulting 3-dimensional matrix, we have per(A) = det(A ′ ). We show that in contrast with the 2-dimensional case the class of Kasteleyn 3-dimensional matrices is rich; namely, for each 2-dimensional non-negative matrix M there is a 3-dimensional non-negative Kasteleyn matrix A so that per(M ) = per(A). Finally we conclude with some remarks directed towards possible application for the 3-dimensional Ising and dimer problems.
1.1. Basic definitions. We start with basic definitions. A linear code C of length n and dimension d over a field F is a linear subspace with dimension d of the vector space F n . Each vector in C is called a codeword. The weight w(c) of a codeword c is the number of non-zero entries of c. The weight enumerator of a finite code C is defined according to the formula A simplex X is the convex hull of an affine independent set V in R d . The dimension of X is |V | − 1, denoted by dim X. The convex hull of any non-empty subset of V that defines a simplex is called a face of the simplex. A simplicial complex ∆ is a set of simplices fulfilling the following conditions: Every face of a simplex from ∆ belongs to ∆ and the intersection of every two simplices of ∆ is a face of both. The dimension of ∆ is max {dim X|X ∈ ∆}. Let ∆ be a d-dimensional simplicial complex. We define the incidence matrix A = (A ij ) as follows: The rows are indexed by (d − 1)-dimensional simplices and the columns by d-dimensional simplices. We set This paper studies 2-dimensional simplicial complexes where each maximal simplex is a triangle or an edge. We call them triangular configurations. We denote the set of vertices of ∆ by V (∆), the set of edges by E(∆) and the set of triangles by T (∆). The cycle space of ∆ over a field F, denoted ker ∆, is the kernel of the incidence matrix A of ∆ over F, that is {x|Ax = 0}. Let ∆ be a triangular configuration. A matching of ∆ is a subconfiguration M of ∆ such that t 1 ∩ t 2 does not contain an edge for every distinct t 1 , t 2 ∈ T (M ). Let ∆ be a triangular configuration. Let M be a matching of ∆. Then the defect of M is the set E(T ) \ E(M ). The perfect matching of ∆ is a matching with empty defect. We denote the set of all perfect matchings of ∆ by P(∆). Let w : T (∆) → R be weights of the triangles of ∆. The generating function of perfect matchings in ∆ is defined to be P ∆ (x) = P ∈P(∆) x w(P ) , where w(P ) := t∈P w(t).
A triangular configuration ∆ is tripartite if the edges of ∆ can be divided into three disjoint sets E 1 , E 2 , E 3 such that every triangle of ∆ contains edges from all sets E 1 , E 2 , E 3 . We call the sets E 1 , E 2 , E 3 tripartition of ∆.
The triadjacency 3-matrix A(x) = (a ijk ) of a tripartite triangular configuration ∆ with tripartition E 1 , E 2 , E 3 is the |E 1 | × |E 2 | × |E 3 | three dimensional array of numbers, defined as follows: We set The permanent of a n × n × n 3-matrix A is defined to be The determinant of a n × n × n 3-matrix A is defined to be We recall that biadjacency matrix A(x) = (a ij ) of a bipartite graph G = (V, W, E) is the |V |× |W | matrix, defined as follows: We set where e is an integer linear in length of C.
Theorem 2 (Rytíř [9]). Let C be a linear code over GF (p), where p is a prime. Then there exists a triangular configuration ∆ such that: if m i=0 a i x i is the weight enumerator of ker ∆ then where e is an integer linear in length of C.
Theorem 3 (Rytíř [8]). Let ∆ be a triangular configuration. Then there exists a triangular configuration ∆ ′ and weights w ′ : Theorem 4. Let ∆ be a triangular configuration with weights w : T (∆) → R. Then there exists a tripartite triangular configuration ∆ ′ and weights w ′ : Proof. Follows directly from Proposition 2.10 and Proposition 2.11 of Section 2. Theorem 5 is proved in Section 3.

Triangular configurations and permanents
In this section we prove Theorem 4. We use basic building blocks as in Rytíř [8]. However, the use is novel and we need to stress the tripartitness of basic blocks. Hence we briefly describe them again.
2.1. Triangular tunnel. Triangular tunnel is depicted in Figure 1. An empty triangle is a set of three edges forming a boundary of a triangle. We call the empty triangles {a, b, c} and  2.2. Triangular configuration S 5 . Triangular configuration S 5 is depicted in Figure 3. Letter "X" denotes empty triangles. We call these empty triangles ending. Proof. The unique perfect matching is {t 1 , t 2 , t 4 , t 5 }. We denote it by M 1 (S 5 ). The unique matching with defect on edges of all empty triangles is {t 3 }. We denote it by M 0 (S 5 ). The matching triangular triangle is obtained from the triangular configuration S 5 and three triangular tunnels in the following way: Let T 1 , T 2 and T 3 be triangular tunnels. Let t T1 1 , p T1 ; t T2 1 , q T2 and t T3 1 , r T3 be the ending empty triangles of T 1 , T 2 and T 3 , respectively. Let t S 5 1 , t S 5 2 , t S 5 3 be ending empty triangles of S 5 . We identify t T1 The matching triangular triangle is defined to be T 1 ∪ S 5 ∪ T 2 ∪ T 3 . The matching triangular triangle is depicted in Figure 5.
Proof. Follows from Figure 4 and Figure 2. 2.4. Linking three triangles by matching triangular triangle. Let ∆ be a triangular configuration. Let t 1 , t 2 and t 3 be three edge disjoint triangles of ∆.
Second step: For every triangle t of ∆, we link t 1 , t 2 , t 3 in ∆ ′ 1 by triangular matching triangle T . We denote this triangular matching triangle by T t . Then we remove triangles t 1 , t 2 , t 3 from ∆ ′ 1 . We choose a triangle t ′ from M 1 (T t ) and set w ′ (t ′ ) := w(t). We set w ′ (t ′ ) := 0 for t ′ ∈ T (T t ) \ {t}. The resulting configuration is desired configuration ∆ ′ . Proposition 2.7. Triangular configuration ∆ ′ is tripartite.
Proof. The triangular configuration ∆ ′ is constructed from three disjoint triangular configurations ∆ 1 , ∆ 2 , ∆ 3 . From these configurations all triangles are removed. Hence, we can put edges E(∆ i ) to set E i for i = 1, 2, 3. The remainder of ∆ ′ is formed by matching triangular triangles. Every matching triangular triangle connects edges of ∆ 1 , ∆ 2 , ∆ 3 . By Proposition 2.6 the matching triangular triangle is tripartite and its ends belong to different partities.
We recall 2 X denotes the set of all subsets X. We define a mapping f : 2 T (∆) → 2 T (∆ ′ ) as: Let S be a subset of T (∆) then Proof. By definition, the mapping f is an injection. By Proposition 2.5, every inner edge of T t , t ∈ T (∆), is covered by f (S) for any subset S of T (∆). Let M be a perfect matching of ∆. We show that f (M ) is perfect matching of ∆ ′ .
Let e be an edge of ∆ and let e 1 , e 2 , e 3 be corresponding copies in ∆ 1 , ∆ 2 ,   Proof. Follows directly from Propositions 2.7 and 2.8 and Corollary 2.9.
Proof. We have Every perfect triangular matching between partities E 1 , E 2 , E 3 can be encoded by two permutations σ 1 , σ 2 and vice versa. If matching M is a subset of T (∆), then where [ijk] denotes a triangle of ∆ with edges i, j, k. If M is not a subset of T (∆), then there is i such that a iσ1(i)σ2(i) = 0. Hence
Theorem 6. If A is such that both G A 1 , G A 2 are Pfaffian bipartite graphs then A is Kasteleyn. Proof. Let M i be the biadjacency matrix of G i and let sign i : By the construction of sign 2 we have that for each σ 2 and each σ 1 , if j A jσ1(j)σ2(j) = 0 then Analogously by the construction of sign 1 we have that for each σ 1 and each σ 2 , if j A jσ1(j)σ2(j) = 0 then sign(σ 1 ) j sign 1 ({j, σ 1 (j)}) = 1.
In the introduction we defined the triadjacency 3-matrix of a triangular configuration as the adjacency matrix of the edges of the triangles. We also defined a matching of a triangular configuration as a set of edge-disjoint triangles. In this section it is advantageous to consider any 3-matrix with 0, 1 entries as the adjacency matrix of vertices of a triangular configuration. Hence we need the following notions.
A triangular configuration ∆ is vertex-tripartite if vertices of ∆ can be divided into three disjoint sets V 1 , V 2 , V 3 such that every triangle of ∆ contains one vertex from each set V 1 , V 2 , V 3 . We call the sets V 1 , V 2 , V 3 vertex-tripartition of ∆.
The vertex-adjacency 3-matrix A(x) = (a ijk ) of a tripartite triangular configuration ∆ with vertextripartition V 1 , V 2 , V 3 is the |V 1 | × |V 2 | × |V 3 | three dimensional array of numbers, defined as follows: We set forms a triangle t with weight w(t), 0 otherwise.
We will need the following modification of the notion of a matching. A set of triangles of a triangular configuration is called strong matching if its triangles are mutually vertex-disjoint.
Proof of Theorem 5. Let M be a n × n matrix and let G = (V 1 , V 2 , E) be the adjacency bipartite graph of its non-zero entries. We have |V 1 | = |V 2 | = n. We order vertices of each V i , i = 1, 2 arbitrarily and let , 1), . . . , v ′ (i, n)} be disjoint copy of V i , i = 1, 2. We next define three sets of vertices W 1 , W 2 , W 0 and system of triangles ∆(G) = ∆ so that each triangle intersects each W i in exactly one vertex. {(a, b, w(0, e)), (w(0, e), w(1, e), w(2, e))}∪ j), w(2, e))|v(2, j) ∈ e}. We let A be the vertex-adjacency 3-matrix of the triangular configuration T (G) = T = (W 0 , W 1 , W 2 , ∆). We first observe that both bipartite graphs G 1 , G 2 of this triangular configuration are planar; let us consider only G 1 , the reasoning for G 2 is the same. First, vertices v ′ (1, j) and w(0, 2, j) are connected only among themselves in G 1 . Further, the component of G 1 containing vertex v(1, j) contains also vertex w(0, 1, j) and consists of deg G (v(1, j)) disjoint paths of length 3 between these two vertices. Here deg G (v(1, j)) denotes the degree of v(1, j) in graph G, i.e., the number of edges of G incident with v(1, j). Thus, by Theorem 6, A is Kasteleyn.
We next observe that Kasteleyn signing is trivial. Let D 1 be the orientation of G 1 in which each edge is directed from W 0 to W 1 . In each planar drawing of G 1 , each inner face has an odd number of edges directed in D 1 clockwise. This means that D 1 is a Pfaffian orientation of G 1 , and per(A) = det(A) (see e.g. Loebl [5] for basic facts on Pfaffian orientations and Pfaffian signings).
Finally there is a bijection between the perfect matchings of G and the perfect strong matchings of T : if P ⊂ E is a perfect matching of G then let P (T ) = {(a, b, w(0, e))|e = ab ∈ P }.
On the other hand, if Q is a perfect strong matching of T then Q contains P (T ) for some perfect matching P of G.

Application to 3D dimer problem
Let Q be cubic n × n × n lattice. The dimer partition function of Q, which is equal to the generating function of the perfect matchings of Q, can be by Theorem 5 identified with the permanent of the Kasteleyn vertex-adjacency matrix of triangular configuration T (Q). Natural question arises whether this observation can be used to study the 3D dimer problem.
We first observe that the natural embedding of Q in 3-space can be simply modified to yield an embedding of T (Q) in 3-space. This can perhaps best be understood by figures, see Figure 6; this figure depicts configuration T (Q) around vertex v of Q with neighbors u 1 , . . . , u 6 . Triangular configuration T (Q) is obtained by identification of vertices v i , i = 1, . . . , 6 in the left and right parts of Figure 6. Now assume that the embedding of left part of Figure 6 is such that for each vertex v of Q, the vertices v 1 , . . . , v 6 belong to the same plane and the convex closure of v 1 , . . . , v 6 intersects the rest of Figure 6. Configuration T (Q) around vertex v of Q with neighbors u1, . . . , u6 so that u1, u3, u4, u6 belong to the same plane in the 3-space, u2 is 'behind' this plane and u5 is 'in front of' this plane. Empty vertices belong to W0, square vertices belong to W1 and full vertices belong to W2.
the configuration only in v 1 , . . . , v 6 . Then we add the embedding of the right part, for each vertex v of Q, so that x 1 belongs to the plane of the v i 's and x 2 is very near to x 1 but outside of this plane. Summarizing, the dimer partition function of a finite 3-dimensional cubic lattice Q may be written as the determinant of the vertex-adjacency 3-matrix of triangular configuration T (Q) which preserves the natural embedding of the cubic lattice. Calculating the determinant of a 3-matrix is hard, but perhaps formulas for the determinant of the particular vertex-adjacency 3-matrix of T (Q), illuminating the 3-dimensional dimer problem, may be found. An example of a formula valid for the determinant of a 3-matrix is shown in the next subsection. It is new as far as we know but its proof is basically identical to the proof of Lemma 3.3 of Barvinok [1]. 4.1. Binet-Cauchy formula for the determinant of 3-matrices. We recall from the introduction that the permanent of a n × n × n 3-matrix A is defined to be per(A) = σ1,σ2∈Sn n i=1 a iσ1(i)σ2(i) .
The next formula is a generalization of Binet-Cauchy formula (see the proof of Lemma 3.3 in Barvinok [1]).