### 3.7.109. Glue matrix

A reversible constraint for which the catalogue provides an automaton with counters and a glue matrix. A glue matrix is indexed by the states of the automaton associated with the considered constraint as well as by the states of the automaton associated with the reverse of the considered constraint. In the following we assume that the signature constraint involves $a$ consecutive variables of the sequence of variables of the reversible constraint (the signature constraint encodes the mapping of the sequence of variables of the constraint to symbols of the alphabet of the automaton). We consider a sequence of variables and a prefix and suffix of this sequence such that the prefix and suffix have $a-1$ variables in common. Let $\stackrel{\to }{q}$ (resp. $\stackrel{←}{q}$) be the state of the automaton associated with the constraint (resp. the reverse constraint) upon reading the prefix (resp. the reverse of the suffix). The entry of the glue matrix corresponding to the state pair $\left(\stackrel{\to }{q},\stackrel{←}{q}\right)$ provides a function for computing the result associated with the sequence from the counters values associated with the prefix and the reverse suffix.

As an example consider the $\mathrm{𝚙𝚎𝚊𝚔}$$\left(𝙽,\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}\right)$, which holds if $𝙽$ is equal to the number of peaks of the sequence of variables $\mathrm{𝚅𝙰𝚁𝙸𝙰𝙱𝙻𝙴𝚂}$. A peak corresponds to an increase between consecutive variables followed by a decrease between consecutive variables. Figure 3.7.32 gives the corresponding automaton that returns the number of peak of a sequence where, to each pair of consecutive variables $\left({\mathrm{𝚅𝙰𝚁}}_{i},{\mathrm{𝚅𝙰𝚁}}_{i+1}\right)$ corresponds a signature variable ${S}_{i}$ passed to the automaton. The following signature constraint links ${\mathrm{𝚅𝙰𝚁}}_{i}$, ${\mathrm{𝚅𝙰𝚁}}_{i+1}$ and ${S}_{i}$: $\left({\mathrm{𝚅𝙰𝚁}}_{i}<{\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=0\right)\wedge \left({\mathrm{𝚅𝙰𝚁}}_{i}={\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=1\right)\wedge \left({\mathrm{𝚅𝙰𝚁}}_{i}>{\mathrm{𝚅𝙰𝚁}}_{i+1}⇔{S}_{i}=2\right)$.

Figure 3.7.33 illustrates the use of the glue matrix of the $\mathrm{𝚙𝚎𝚊𝚔}$ constraint on the sequence $1,1,4,8,6,2,7,1$ decomposed in a prefix $1,1,4,8$ and a suffix $8,6,2,7,1$ that overlap by one position, one position since the arity of the signature constraint is equal to two. Since the automaton of the $\mathrm{𝚙𝚎𝚊𝚔}$ constraint ends up in state $u$ when applied to the prefix and to the reverse suffix we use the lower rightmost entry of the glue matrix to link the total number of peaks of the sequence $1,1,4,8,6,2,7,1$ with the number of peaks of the prefix $1,1,4,8$ and the suffix $8,6,2,7,1$.