### 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{\beta }{q}$ (resp.Β $\stackrel{\beta }{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{\beta }{q},\stackrel{\beta }{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{\pi \pi \pi \pi }$$\left(\mathrm{\pi ½},\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\right)$, which holds if $\mathrm{\pi ½}$ is equal to the number of peaks of the sequence of variables $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$. 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{\pi  \pi °\pi }}_{i},{\mathrm{\pi  \pi °\pi }}_{i+1}\right)$ corresponds a signature variable ${S}_{i}$ passed to the automaton. The following signature constraint links ${\mathrm{\pi  \pi °\pi }}_{i}$, ${\mathrm{\pi  \pi °\pi }}_{i+1}$ and ${S}_{i}$: $\left({\mathrm{\pi  \pi °\pi }}_{i}<{\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=0\right)\beta §\left({\mathrm{\pi  \pi °\pi }}_{i}={\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=1\right)\beta §\left({\mathrm{\pi  \pi °\pi }}_{i}>{\mathrm{\pi  \pi °\pi }}_{i+1}\beta {S}_{i}=2\right)$.

FigureΒ 3.7.33 illustrates the use of the glue matrix of the $\mathrm{\pi \pi \pi \pi }$ 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{\pi \pi \pi \pi }$ 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$.