Boolean Variables and Clauses in CP-SAT
Boolean variables in CP-SAT are integer variables restricted to the domain {0, 1}. This lesson introduces Boolean variables and their negated literals, then builds up the core CP-SAT clause types (AddBoolOr, AddBoolAnd, AddAtMostOne, AddExactlyOne, AddImplication) and shows how to combine them to model logical conditions.
Tutorial
Boolean Variables and Literals
In CP-SAT, a Boolean variable is an integer variable whose domain is restricted to . We create one with the call
The value represents true and the value represents false.
Every Boolean variable has an associated negated literal, written , whose value is
So if , then ; if , then .
A literal is either a Boolean variable or its negation. All of the clauses introduced in this lesson take lists of literals as arguments.
For example, if and , the literals
have values respectively.