Section 1.1 Statements, Symbolic Representation, and Tautologies
11
“used cars” AND (Ford OR Buick)
This would tend to limit your search to sites that mention only particular brands
of used cars, although you could still wind up with a link to Jim Bob Ford’s Loan
Shark Agency, which will lend you money for any used car. The query
“used cars” AND (Ford OR Buick) AND NOT trucks
would eliminate sites mentioning trucks. Many search engines use + (a plus sign)
in place of AND, and − (a minus sign) in place of AND NOT.
The logical connectives AND, OR, and NOT are also available in many programming languages, as well as on programmable graphing calculators. These
connectives, in accordance with the truth tables we have defined, act on combinations of true or false expressions to produce an overall truth value. Such
truth values provide the decision-making capabilities fundamental to the flow of
control in computer programs. Thus, at a conditional branch in a program, if the
truth value of the conditional expression is true, the program will next execute
one section of code; if the value is false, the program will next execute a different
section of code. If the conditional expression is replaced by a simpler, equivalent
expression, the truth value of the expression and hence the flow of control of
the program is not affected, but the new code is easier to understand and may
execute faster.
eXAMPLe 7
Consider a statement in a computer program that has the form
if ((outflow > inflow) and not ((outflow > inflow) and (pressure < 1000)))
do something;
else
do something else;
Here the conditional expression has the form
A ` (A ` B)′
where A is “outflow > inflow” and B is “pressure <1000.” This expression can be
simplified by replacing some wffs with equivalent wffs.
A ` (A ` B)′ 3 A ` (A′ ~ B′)
(De Morgan’s laws)
3 (A ` A′) ~ (A ` B′)
(tautology 3b)
3 0 ~ (A ` B′)
(tautology 5b)
3 (A ` B′) ~ 0
(tautology 1a)
3 A ` B′
(tautology 4a)
The statement form can therefore be written
if ((outflow > inflow) and not (pressure < 1000))
do something;
else
do something else;
Précédent

- 28/986

Suivant