# MiniZinc Documentation - Standard Library

Functions and Predicates
predicate 'not'(var opt bool: x) =
absent(x) \/ not deopt(x)
(standard decomposition from stdlib.mzn:273)

Usage: not x

True iff x is absent or false

predicate absent(var opt bool: x) =
not occurs(x)
(standard decomposition from stdlib.mzn:238)

True iff x is absent

predicate absent(var opt int: x) =
not occurs(x)
(standard decomposition from stdlib.mzn:332)

True iff x is absent

predicate bool_eq(var opt bool: b0, var opt bool: b1) =
absent(b0) /\ absent(b1) \/ occurs(b0) /\ occurs(b1) /\ deopt(b0)==deopt(b1)
(standard decomposition from stdlib.mzn:252)

True iff both b0 and b1 are absent or both are present and have the same value.

predicate bool_eq(var opt bool: b0, var bool: b1) =
occurs(b0) /\ deopt(b0)==b1
(standard decomposition from stdlib.mzn:257)

True iff b0 occurs and is equal to b1

predicate bool_eq(var bool: b0, var opt bool: b1) =
occurs(b1) /\ deopt(b1)==b0
(standard decomposition from stdlib.mzn:261)

True iff b1 occurs and is equal to b0

predicate deopt(var opt bool: x) =
let { var bool: b = occurs_internal(x), var bool: dx = deopt_internal(x), constraint x==reverse_map(b, dx) :: is_reverse_map, } in (dx)
(standard decomposition from stdlib.mzn:230)

Return value of x (assumes that x is not absent)

function var int: deopt(var opt int: x) =
let { var bool: b = occurs_internal(x), var int: dx = deopt_internal(x), constraint x==reverse_map(b, dx) :: is_reverse_map, } in (dx)
(standard decomposition from stdlib.mzn:324)

Return value of x (assumes that x is not absent)

function var opt bool: element(var opt int: idx, array [int] of var bool: x) =
if absent(idx) then <> else element(deopt(idx), x) endif
(standard decomposition from stdlib.mzn:276)

Return absent if idx is absent, otherwise return x[idx]

function var opt bool: element(var opt int: idx1, var opt int: idx2, array [int,int] of var bool: x) =
if absent(idx1) \/ absent(idx2) then <> else element(deopt(idx1), deopt(idx2), x) endif
(standard decomposition from stdlib.mzn:280)

Return absent if idx1 or idx2 is absent, otherwise return x[idx1, idx2]

function var opt bool: element(var int: idx, array [int] of var opt bool: x) =
let { var opt bool: r, constraint occurs(r)==element(idx, array1d(index_set(x), [ occurs(x[i]) | i in index_set(x) ])), constraint deopt(r)==element(idx, array1d(index_set(x), [ deopt(x [i]) | i in index_set(x) ])), } in (r)
(standard decomposition from stdlib.mzn:284)

Return x[idx]

function var opt bool: element(var int: idx1, var int: idx2, array [int,int] of var opt bool: x) =
let { var opt bool: r, constraint occurs(r)==element(idx1, idx2, array2d(index_set_1of2(x), index_set_2of2(x), [ occurs(x[i, j]) | i in index_set_1of2(x), j in index_set_2of2(x) ])), constraint deopt(r)==element(idx1, idx2, array2d(index_set_1of2(x), index_set_2of2(x), [ deopt(x[i, j]) | i in index_set_1of2(x), j in index_set_2of2(x) ])), } in (r)
(standard decomposition from stdlib.mzn:292)

Return x[idx1, idx2]

function var opt bool: element(var opt int: idx, array [int] of var opt bool: x) =
if absent(idx) then <> else element(deopt(idx), x) endif
(standard decomposition from stdlib.mzn:302)

Return absent if idx is absent, otherwise return x[idx]

function var opt bool: element(var opt int: idx1, var opt int: idx2, array [int,int] of var opt bool: x) =
if absent(idx1) \/ absent(idx2) then <> else element(deopt(idx1), deopt(idx2), x) endif
(standard decomposition from stdlib.mzn:306)

Return absent if idx1 or idx2 is absent, otherwise return x[idx1, idx2]

predicate exists(array [int] of var opt bool: x) =
exists ( i in index_set(x) ) ( occurs(x[i]) /\ deopt(x[i]) )
(standard decomposition from stdlib.mzn:269)

True iff for at least one i, x[i] occurs and is true

predicate forall(array [int] of var opt bool: x) =
forall ( i in index_set(x) ) ( absent(x[i]) \/ deopt(x[i]) )
(standard decomposition from stdlib.mzn:265)

True iff for any i, x[i] is absent or true

predicate occurs(var opt bool: x) =
let { var bool: b = occurs_internal(x), var bool: dx = deopt_internal(x), constraint x==reverse_map(b, dx) :: is_reverse_map, } in (b)
(standard decomposition from stdlib.mzn:222)

True iff x is not absent