# 4.2.1.7. Conditionals¶

These functions implement conditional (if-then-else-endif) constraints.

In this section: if_then_else, if_then_else_partiality.

## if_then_else¶

 predicate if_then_else(array [int] of var bool: c, array [int] of int: x, var int: y) predicate if_then_else(array [int] of var bool: c, array [int] of var int: x, var int: y) predicate if_then_else(array [int] of var bool: c, array [int] of opt int: x, var opt int: y) predicate if_then_else(array [int] of var bool: c, array [int] of var opt int: x, var opt int: y) predicate if_then_else(array [int] of var bool: c, array [int] of bool: x, var bool: y) predicate if_then_else(array [int] of var bool: c, array [int] of var bool: x, var bool: y) predicate if_then_else(array [int] of var bool: c, array [int] of opt bool: x, var opt bool: y) predicate if_then_else(array [int] of var bool: c, array [int] of var opt bool: x, var opt bool: y) predicate if_then_else(array [int] of var bool: c, array [int] of float: x, var float: y) predicate if_then_else(array [int] of var bool: c, array [int] of var float: x, var float: y) predicate if_then_else(array [int] of var bool: c, array [int] of opt float: x, var opt float: y) predicate if_then_else(array [int] of var bool: c, array [int] of var opt float: x, var opt float: y) predicate if_then_else(array [int] of var bool: c, array [int] of set of int: x, var set of int: y) predicate if_then_else(array [int] of var bool: c, array [int] of var set of int: x, var set of int: y)  Conditional constraint $$\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ {\bf y}={\bf x}[i] \}$$ This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

## if_then_else_partiality¶

 predicate if_then_else_partiality(array [int] of var bool: c, array [int] of var bool: d, var bool: b)  Conditional partiality constraint This constraint is generated by the compiler for if-then-else expressions with potentially undefined cases. The last entry in the c array is always the constant true, corresponding to the else case. The d[i] variable represents whether case i is defined. Constrains that if b is defined, then the selected case must be defined, and if the selected case is undefined, then b must be undefined.