Next: The primitive data type
Up: Unit 04
Previous: Boolean algebra: domain and
We can obtain the value of a boolean expression with variables by substituting
each variable with its truth value, and simplifying according to the meaning of
the operators. To characterize the meaning of a boolean expression, we can
construct a table in which, for each possible combination of truth values for
the variables, we specify the truth value of the whole expression. Such a
table is called a truth table.
Truth tables for the boolean operators
|
a |
b |
a and b |
true |
true |
true |
false |
true |
false |
true |
false |
false |
false |
false |
false |
|
|
a |
b |
a or b |
true |
true |
true |
false |
true |
true |
true |
false |
true |
false |
false |
false |
|
|
a |
not a |
true |
false |
false |
true |
|
Example:
a |
b |
c |
(a and (not b)) or c |
true |
true |
true |
true |
false |
true |
true |
true |
true |
false |
true |
true |
false |
false |
true |
true |
true |
true |
false |
false |
false |
true |
false |
false |
true |
false |
false |
true |
false |
false |
false |
false |
Next: The primitive data type
Up: Unit 04
Previous: Boolean algebra: domain and