Lecture 34 Ticket
In preparation of class on 12/05; not to be turned in
A Boolean variable is a variable that stores one of two values: true or false. We can combine boolean variables using operations known as logical connectives: and, or, and not. In logic, these connectives are represented by the following symbols: \(\wedge\), \(\vee\), \(\neg\). If \(x\) and \(y\) are Boolean variables, then:
- \(x \wedge y\) evaluates to true if both \(x\) and \(y\) are true;
- \(x \vee y\) evaluates to true if either \(x\) or \(y\) (or both) is true;
- \(\neg x\) evaluates to true if \(x\) is false.
When applying negation (\(\neg\)) to a single variable, say \(x\), we sometimes use the shorthand \(\bar{x}\) for \(\neg x\).
More specifically, the operations \(\wedge\), \(\vee\) and \(\neg\) are defined by their truth table, which is a table that shows the values of these operators for all possible input values (true or false):
\(x\) | \(y\) | \(x \wedge y\) | \(x \vee y\) | \(\neg x\) |
---|---|---|---|---|
T | T | T | T | F |
T | F | F | T | F |
F | T | F | T | T |
F | F | F | F | T |
Each row corresponds to a single setting of the variables \(x\) and \(y\) indicated in the first two columns. The subesequent columns indicate the value of the operation (\(\wedge\), \(\vee\), or \(\neg\)) applied to \(x\) and \(y\) with the values in the first two columns.
A Boolean formula is a formula defined by stringing together multiple variables and logical connectives. To make such expressions unambiguous, we also use parentheses. The standard operator precedence or “order of operations” is \(\neg\), \(\wedge\), \(\vee\) if expressions are not paranthesized.
For example, consider the Boolean formula \((x \wedge y) \vee (y \vee \bar{z})\). Again, we can evaluate this expression for every possible value of \(x, y\) and \(z\) using a truth table. The first three columns the possible values of \(x, y\) and \(z\) and each row corresponds to a setting of these values. Since there are 3 variables and two possible values for each variable, there are \(8 = 2^3\) rows. The fourth and fifth columns give the corresponding values of \(x \wedge y\) and \(y \vee \bar{z}\), respectively. The final column gives the value of \((x \wedge y) \vee (y \vee \bar{z})\).
\(x\) | \(y\) | \(z\) | \(x \wedge y\) | \(y \vee \bar{z}\) | \((x \wedge y) \vee (y \vee \bar{z})\) |
---|---|---|---|---|---|
T | T | T | T | T | T |
T | T | F | T | T | T |
T | F | T | F | F | F |
T | F | F | F | T | T |
F | T | T | F | T | T |
F | T | F | F | T | T |
F | F | T | F | F | F |
F | F | F | F | T | T |
A Boolean formula \(\varphi\) in variables \(x_1, x_2, \ldots, x_n\) is called satisfiable if there is some setting of the variables such that the resulting formula evalues to T. The truth table above shows that \((x \wedge y) \vee (y \vee \bar{z})\) is satisfiable. For example, if we set \(x, y, z\) all to T, the formula evaluates to T. Some formulae are not satisfiable. For example, \(\varphi(x) = x \wedge \bar{x}\) is not satisfiable, as \(\varphi(x) =\) F regardless of the value of \(x\).
The Boolean satisfiability problem, often denoted SAT is the following: given a Boolean formula \(\varphi(x_1, x_2, \ldots, x_n)\), determine if \(\varphi\) is satisfiable. That is, determine if there are T/F values for \(x_1, x_2, \ldots, x_n\) such that \(\varphi(x_1, x_2, \ldots, x_n)\) evaluates to T.
Exercise. Determine which of the following Boolean formulae are satisfiable and which are not.
- \[(x \vee \bar{y}) \wedge (\bar{x} \vee y)\]
- \[(x \vee y) \wedge (\bar x \vee \bar y) \wedge (x \vee \bar y) \wedge (\bar x \vee y)\]
- \[(x \vee y \vee z) \wedge (\bar x \wedge \bar y \wedge \bar z)\]