## 5.27. among_modulo

Origin
Constraint

$\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi ½\pi  \pi °\pi },\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi },\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }\right)$

Arguments
 $\mathrm{\pi ½\pi  \pi °\pi }$ $\mathrm{\pi \pi \pi \pi }$ $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi }-\mathrm{\pi \pi \pi \pi }\right)$ $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ $\mathrm{\pi \pi \pi }$ $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }$ $\mathrm{\pi \pi \pi }$
Restrictions
 $\mathrm{\pi ½\pi  \pi °\pi }\beta ₯0$ $\mathrm{\pi ½\pi  \pi °\pi }\beta €|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$ $\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi },\mathrm{\pi \pi \pi }\right)$ $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }\beta ₯0$ $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }<\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }$ $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }>0$
Purpose

$\mathrm{\pi ½\pi  \pi °\pi }$ is the number of variables of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ taking a value that is congruent to $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ modulo $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }$.

Example
$\left(3,β©4,5,8,4,1βͺ,0,2\right)$

In this example $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }=0$ and $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=2$ specifies that we count the number of even values taken by the different variables. As a consequence the $\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }$ constraint holds since exactly 3 values of the collection $\beta ©4,5,8,4,1\beta ͺ$ are even.

Typical
 $\mathrm{\pi ½\pi  \pi °\pi }>0$ $\mathrm{\pi ½\pi  \pi °\pi }<|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$ $|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|>1$ $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }>1$ $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }<$$\mathrm{\pi \pi \pi ‘\pi \pi \pi }$$\left(\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }\right)$
Symmetries
• Items of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ are permutable.

• An occurrence of a value $u$ of $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }.\mathrm{\pi \pi \pi }$ such that $u\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ (resp. ) can be replaced by any other value $v$ such that $v\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ (resp. ).

Arg. properties
• Functional dependency: $\mathrm{\pi ½\pi  \pi °\pi }$ determined by $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$, $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ and $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }$.

• Contractible wrt. $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ when $\mathrm{\pi ½\pi  \pi °\pi }=0$.

• Contractible wrt. $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ when $\mathrm{\pi ½\pi  \pi °\pi }=|\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }|$.

• Aggregate: $\mathrm{\pi ½\pi  \pi °\pi }\left(+\right)$, $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }\left(\mathrm{\pi \pi \pi \pi \pi }\right)$, $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }\left(\mathrm{\pi \pi }\right)$, $\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }\left(\mathrm{\pi \pi }\right)$.

Remark

By giving explicitly all values $v$ that satisfy the equality $v\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$, the $\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }$ constraint can be modelled with the $\mathrm{\pi \pi \pi \pi \pi }$ constraint. However the $\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }$ constraint provides a more compact form.

generalisation: $\mathrm{\pi \pi \pi \pi \pi }$Β (list of $\mathrm{\pi \pi \pi \pi \pi \pi }$ $\mathrm{\pi }$ such that $\mathrm{\pi }\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }$ = $\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$ replaced by list of $\mathrm{\pi \pi \pi \pi \pi \pi }$).

Keywords
Arc input(s)

$\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$

Arc generator
$\mathrm{\pi \pi Έ\pi Ώ\pi Ή}$$\beta ¦\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi \pi }\left(\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }\right)$

Arc arity
Arc constraint(s)
$\mathrm{\pi \pi \pi \pi \pi \pi \pi \pi \pi }.\mathrm{\pi \pi \pi }\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }$
Graph property(ies)
$\mathrm{\pi \pi \pi \pi }$$=\mathrm{\pi ½\pi  \pi °\pi }$

Graph model

The arc constraint corresponds to a unary constraint. For this reason we employ the $\mathrm{\pi \pi Έ\pi Ώ\pi Ή}$ arc generator in order to produce a graph with a single loop on each vertex.

PartsΒ (A) andΒ (B) of FigureΒ 5.27.1 respectively show the initial and final graph associated with the Example slot. Since we use the $\mathrm{\pi \pi \pi \pi }$ graph property, the loops of the final graph are stressed in bold.

Automaton

FigureΒ 5.27.2 depicts the automaton associated with the $\mathrm{\pi \pi \pi \pi \pi }_\mathrm{\pi \pi \pi \pi \pi \pi }$ constraint. To each variable ${\mathrm{\pi  \pi °\pi }}_{i}$ of the collection $\mathrm{\pi  \pi °\pi \pi Έ\pi °\pi ±\pi »\pi ΄\pi }$ corresponds a 0-1 signature variable ${S}_{i}$. The following signature constraint links ${\mathrm{\pi  \pi °\pi }}_{i}$ and ${S}_{i}$: ${\mathrm{\pi  \pi °\pi }}_{i}\mathrm{mod}\mathrm{\pi \pi \pi Ύ\pi \pi Έ\pi ΄\pi ½\pi }=\mathrm{\pi \pi ΄\pi Ό\pi °\pi Έ\pi ½\pi ³\pi ΄\pi }\beta {S}_{i}$.