|
|
|
In reference to Meredith Broussard's Unartificial Intelligence: How Computers Misunderstand the World ...
Basically:
Boolean "numbers" are 0 and 1, representing false and true, respectively.
If A is a Boolean number, then not A is the opposite of A. If A is true, then not A is false, and vice-versa. The possible inputs and results of a Boolean operator can be shown in a truth table:
A | not A |
---|---|
T | F |
F | T |
If A and B are Boolean numbers, then A and B is only true if both A and B are true:
A | B | A and B |
---|---|---|
T | T | T |
T | F | F |
F | T | F |
F | F | F |
A or B is true if either A or B (or both) is true. It is only false if both A and B are false:
A | B | A or B |
---|---|---|
T | T | T |
T | F | T |
F | T | T |
F | F | F |
These simple Boolean expressions can be combined into more complex expressions that can be evaluated in the same way. For example, not(A or B) and C is evaluated much like the arithmetic expression "−(1+2) × 3".
A programmer uses basic Boolean algebra a lot to define conditions under which some action is to be taken. Here's a simple program a person might run over before heading out — always take your money and car keys, but only take your umbrella if the weather is threatening:
Take your wallet or purse. Take your automobile keys. IF not(the sun is out) or (weather forecast predicts rain) Take your umbrella. ENDIF