### 2.1.4. Declaring a global constraint

Declaring a global constraint consists of providing the following information:

• A term $\mathrm{𝚌𝚘𝚗𝚜𝚝𝚛𝚊𝚒𝚗𝚝}\left({A}_{1},{A}_{2},...,{A}_{n}\right)$, where $\mathrm{𝚌𝚘𝚗𝚜𝚝𝚛𝚊𝚒𝚗𝚝}$ corresponds to the name of the global constraint and ${A}_{1},{A}_{2},...,{A}_{n}$ to its arguments.

• A possibly empty list of type declarations, where each declaration has the form $\mathrm{𝚝𝚢𝚙𝚎}$:$\mathrm{𝚝𝚢𝚙𝚎}_\mathrm{𝚍𝚎𝚌𝚕𝚊𝚛𝚊𝚝𝚒𝚘𝚗}$; $\mathrm{𝚝𝚢𝚙𝚎}$ is the name of the new type we define and $\mathrm{𝚝𝚢𝚙𝚎}_\mathrm{𝚍𝚎𝚌𝚕𝚊𝚛𝚊𝚝𝚒𝚘𝚗}$ is a basic data type, a compound data type or a type previously defined.

• An argument declaration ${A}_{1}$:${T}_{1},{A}_{2}$:${T}_{2},...,{A}_{n}$:${T}_{n}$ giving for each argument ${A}_{1},{A}_{2},$ $...,{A}_{n}$ of the global constraint $\mathrm{𝚌𝚘𝚗𝚜𝚝𝚛𝚊𝚒𝚗𝚝}$ its type. Each type is a basic data type, a compound data type, or a type that was declared in the list of type declarations.

• A possibly empty list of restrictions, where each restriction is one of the restrictions described in Section 2.1.3 on page 2.1.3.

EXAMPLE: The arguments of the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚍𝚒𝚏𝚏𝚎𝚛}_\mathrm{𝚏𝚛𝚘𝚖}_\mathrm{𝚊𝚝}_\mathrm{𝚕𝚎𝚊𝚜𝚝}_𝚔_\mathrm{𝚙𝚘𝚜}$ constraint are described by:

Constraint

$\mathrm{𝚊𝚕𝚕}_\mathrm{𝚍𝚒𝚏𝚏𝚎𝚛}_\mathrm{𝚏𝚛𝚘𝚖}_\mathrm{𝚊𝚝}_\mathrm{𝚕𝚎𝚊𝚜𝚝}_𝚔_\mathrm{𝚙𝚘𝚜}$$\left(𝙺,\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂}\right)$

Type(s)

$\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁}-\mathrm{𝚌𝚘𝚕𝚕𝚎𝚌𝚝𝚒𝚘𝚗}\left(\mathrm{𝚟𝚊𝚛}-\mathrm{𝚍𝚟𝚊𝚛}\right)$

Argument(s)

$𝙺-\mathrm{𝚒𝚗𝚝}$

$\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂}-\mathrm{𝚌𝚘𝚕𝚕𝚎𝚌𝚝𝚒𝚘𝚗}\left(\mathrm{𝚟𝚎𝚌}-\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁}\right)$

Restriction(s)

$\mathrm{𝚛𝚎𝚚𝚞𝚒𝚛𝚎𝚍}\left(\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁},\mathrm{𝚟𝚊𝚛}\right)$

$𝙺\ge 0$

$\mathrm{𝚛𝚎𝚚𝚞𝚒𝚛𝚎𝚍}\left(\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂},\mathrm{𝚟𝚎𝚌}\right)$

$\mathrm{𝚜𝚊𝚖𝚎}_\mathrm{𝚜𝚒𝚣𝚎}\left(\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂},\mathrm{𝚟𝚎𝚌}\right)$

The first line indicates that the $\mathrm{𝚊𝚕𝚕}_\mathrm{𝚍𝚒𝚏𝚏𝚎𝚛}_\mathrm{𝚏𝚛𝚘𝚖}_\mathrm{𝚊𝚝}_\mathrm{𝚕𝚎𝚊𝚜𝚝}_𝚔_\mathrm{𝚙𝚘𝚜}$ constraint has two arguments: $𝙺$ and $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂}$. The second line declares a new type $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁}$, which corresponds to a collection of variables. The third line indicates that the first argument $𝙺$ is an integer, while the fourth line tells that the second argument $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂}$ corresponds to a collection of vectors of type $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁}$. Finally the four restrictions respectively enforce that:

• All the items of the $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁}$ collection mention the $\mathrm{𝚟𝚊𝚛}$ attribute,

• $𝙺$ be greater than or equal to 0,

• All the items of the $\mathrm{𝚅𝙴𝙲𝚃𝙾𝚁𝚂}$ collection mention the $\mathrm{𝚟𝚎𝚌}$ attribute,

• All the vectors have the same number of components.