Summary: Problems on propositional logic, including truth-tables, boolean algebra, and inference rules.
Please write logic formulas using the syntax
previously defined,
using
/home/comp280/bin/waterworld.
[Practice problem
Your friend Tracy argues: “ It is bad to be depressed. Watching the news makes me feel depressed. Thus, it's good to avoid watching the news. ”
Regardless of whether the premises and conclusion are true, show that the argument is not, by showing it doesn't hold for all domains. Replace “depressed” and “watching news” with expressions which leave the premises true, but the conclusion false (or at least, what most reasonable people would consider false).
Lots of possible counterexamples. “ It is bad to be depressed. Doing homework makes me depressed; so it's good to not do my homework. ” Or, “ It is bad for people to be in physical pain. Childbirth causes pain. Therefore childbirth needs be avoided by all people. ” If the original conclusion is really correct, Tracy needs to elucidate some of his unspoken assumptions.
The flaw seems to be along the lines of, “ avoiding bad in the short run may not always be good in the long run ” (or equivalently, sometimes you have to choose the lesser of two evils). No, you weren't asked to name a specific flaw, and reasonable people can differ on precisely what the flaw is. (And, formal logic is not particularly helpful here.) Nonetheless, uncovering hidden assumptions in arguments often helps understand the real issues involved.
[Practice problem
An acquaintance says the following to you: “ Chris claims knowledge is more important than grades. But she spent yesterday doing an extra-credit assignment which she already knew how to do. Therefore, she's a hypocrite and deserves no respect. ”
Regardless of whether the premises and conclusion are true, show that the argument is not, by showing it doesn't hold for all domains. Replace “knowledge” and “grades” with expressions which give you true premises, but a false conclusion (or at least, what most reasonable people would consider false).
“ Terry claims that encouraging human-rights is more important than playing Tetris. But Terry played Tetris yesterday rather than volunteering with Amnesty International. ” Most people wouldn't condemn Terry as a hypocrite just because of this; even the most dedicated of people are entitled to some free time. If your friend wants to prove Terry hypocritical, they'll have to provide further evidence or arguments.
Or similarly, “ Politician X claims to support science funding, but voted against a proposal to shift all Medicare funds to NASA. ”
[Practice problem
While the following argument may sound plausible initially, give a particular situation where the conclusion doesn't hold (even though the premises do). Then, in a sentence or two, sketch why your counterexample may still represent rational behavior by pointing out a real-world subtlety that the initial argument ignored.
If a certain outfit meets a dress code, then per force all less-revealing outfits also meet that dress code.
In public transportation projects, out of two alternatives, the cheaper one which gets the job done is the better choice.
It can be socially acceptable to wear my swimsuit into a fast-food restaurant. My underwear is less revealing than my swimsuit, and yet it would still raise many more eyebrows to go to that restaurant in my underwear, than my swimsuit.
Clothes (and style in general) somehow encompass a form of communication, and people may object to an outfit's mood or message without actually objecting to how much the outfit reveals. (Other examples of communication-through-style include team logos, t-shirts with humorous slogans, and arm bands.)
Buses are a lot cheaper than light rail. Yet, the light-rail here in Houston demonstrates that many people who wouldn't routinely take a bus are willing to take light rail. (Only after we recognize this, can we try to figure out what why the difference exists, and then brainstorm to find a better overall solution.)
Choose just one of the following informal arguments. While the argument sounds plausible initially, give a particular situation where the conclusion doesn't hold (even though the premises do). Then, briefly state why your counterexample may still represent rational behavior by pointing out a real-world subtlety that the initial argument ignored.
[cell phone] Talking on a cell phone while driving increases the likelihood of an accident. Interestingly, hands-free phones do not significantly help. It's just the distraction of a phone conversation that causes the problem.
[equivalent products] If two companies offer two materially equivalent products, then most everybody will buy the cheaper one.
[service] In a free market, if a company doesn't offer good service, individual customers will become fed up and take their business elsewhere.
[web browser] If there are two versions of a free web browser, and they run equally quickly, users will use the one with better features/interface.
[door-locking] Anybody who really wants to break into your house while you're gone will be able to. (For instance, using a towel to muffle sound, break the corner of a back window, reach in and unlatch the window, and climb through.) So there's no point in locking your front door.
[Practice problem
Let
You get an A in this class, but you do not do every exercise in the book.
To get an A in this class, it is necessary for you to get an A on the final.
Getting an A on the final and doing every exercise in the book is sufficient for getting an A in this class.
Think of the English being reworded to “ If you got an A in this class, you must have gotten an A on the final. ”
Translate the following English sentences into propositional logic. Your answers should be WFFs.
If the Astros win the series (“
Pigs will not fly, and/or
bacon will be free (“
The Astros will win the series, or bacon will be free, but not both.
[Practice problem
It just so happens that all the web pages in Logiconia
which contain the word
“Poppins” also contain the word “Mary”.
Write a formula (a query) expressing this.
Use the proposition
Write a formula expressing all this.
(Your formula will involve five propositions:
Given the above statements, if a web page in Logiconia does not contain “weasel”, does it contain “mongoose”?
Let's go meta for a moment: Is this web page Logiconian? (Yes, this one you're looking at now, the one with the homework problems.) Explain why or why not.
Different search engines on the web have their own syntax for specifying searches.
Read about the search syntax for the search language of eBay®. Write an eBay query for auctions which contain “border”, do not contain “common”, and contain at least one of “foreign” or “foriegn” [sic, misspellings are a great way to find underexposed auctions].
Google£'s advanced search
is typical for the online search engines.
In particular, you can search for results containing
all of
Give an example of a Boolean formula which cannot be rewritten to conform to Google's advanced search interface.
[Practice problem
![]() |
Consider the particular board shown in the above figure.
There are many simple answers, such as
There are many simple answers, such as
For each, there are also many such formulas composed with connectives such as ∧ and ∨.
In that
same board, is location
Give a domain axiom of WaterWorld which was omitted in the ellipses in the WaterWorld domain axioms.
Even allowing for ellision, the list of WaterWorld domain axioms is incomplete, in a sense. The game reports how many pirates exist in total, but that global information is not reflected in the propositions or axioms.
First, assume we only use the default WaterWorld board size and number of pirates, i.e., five. Give samples of the additional axioms that we need.
Next, generalize your answer to model the program's ability to play the game with a different number of pirates.
Give one WFF which meets all three conditions:
When writing truth tables, please list rows in the order used in all examples: FF, FT, TF, TT. For three-input tables, use the above four lines preceded by F, then the above four lines preceded by T.
In a truth table for two inputs, provide a column for each of the sixteen possible distinct functions. Give a small formula for each of these functions.
[Practice problem
Write the truth table for xnor, the negation of exclusive-or, What is a more common name for this Boolean function?
|
|
||
|---|---|---|
This is the “equals” for Booleans. It is also represented by the connective if-and-only-if.
If you said something like “the both-or-neither function”, that's not quite good enough, as it's a roundabout way of expressing the simple idea of equivalence. Granted, it takes some practice to internalize Booleans as values, and that equality is as valid for them as for any other value.
How many years would it take to build a truth table for a formula with 1000 propositions? Assume it takes 1 nanosecond to evaluate each formula.
A formula with 1000 propositions clearly isn't something you would create by hand. However, such formulas easily arise when modeling the behavior of a program with a 1000-element data structure.
Use truth tables to answer each of the following. Showing whether the connectives obey such properties via truth tables is one way of establishing which equivalences or inference rules we should use.
Show whether ⇒ is commutative.
Show whether ⊕ is commutative.
Show whether ⊕ is associative.
Prove that ∧ distributes over ∨:
Prove that ∨ distributes over ∧:
Show whether ∧ or ∨ distribute over ⇒.
Show whether ⇒ distributes over ∧ or ∨.
Show whether ∧ or ∨ distribute over ⊕.
Show whether ⊕ distributes over ∧ or ∨.
For each of the following, find a satisfying truth assignment, (values of the propositions which make the formula true), if any exists.
For each of the following, find a falsifying truth assignment, (values of the propositions which make the formula false), if any exists.
Formula
As one important use of this concept, if we know that
Similarly,
Show which of the following hold.
When true, show
Using truth tables, show that
[Practice problem
When writing a complicated conditional that involves multiple pieces of data, it is easy to incorrectly oversimplify. One strategy for avoid mistakes is to write such code in a two-step process. First, write a conditional with a case for every possible combination, as in a truth table. Second, simplify the conditional.
Using this approach, we might obtain the following code after the first step. Simplify this code.
list merge_sorted_lists(list list1, list list2)
{
if (is_empty(list1) && is_empty(list2))
return empty_list;
else if (is_empty(list1) && !is_empty(list2))
return list2;
else if (!is_empty(list1) && is_empty(list2))
return list1;
else if (!is_empty(list1) && !is_empty(list2)) {
if (first_element(list1) < first_element(list2))
return make_list(first_element(list1),
merge_sorted_lists(rest_elements(list1),list2));
else if (first_element(list1) >= first_element(list2))
return make_list(first_element(list2),
merge_sorted_lists(list1,rest_elements(list2)));
}
}
list merge_sorted_lists(list list1, list list2)
{
if (is_empty(list1))
return list2;
else if (is_empty(list2))
return list1;
else {
if (first_element(list1) < first_element(list2))
return make_list(first_element(list1),
merge_sorted_lists(rest_elements(list1),list2));
else
return make_list(first_element(list2),
merge_sorted_lists(list1,rest_elements(list2)));
}
}
Alternatively, we could test the emptiness of the lists in the other order.
Consider the following conditional code, which returns a boolean value.
int i;
bool a,b;
…
if (a && (i > 0))
return b;
else if (a && i <= 0)
return false;
else if (a || b)
return a;
else
return (i > 0);
Simplify it by filling in the following blank with a single
Boolean expression.
Do not use a conditional
(such as if or ?:).
int i;
bool a,b;
…
return ________________;
Use either Java/C++ or Scheme syntax. In the former case, please fully parenthesize to make your formula unambiguous, rather than relying on Java's or C++'s many levels of operator precedence.
[Practice problem
Using
algebraic identities,
and the definition or nor (mnemonic: “not or”),
written
First we show that we can write negation in terms of
| 1 | ||
| 2 | Idempotency of ∧ | |
| 3 | DeMorgan's law | |
| 4 | Definition of nor |
We use this lemma to show our ultimate goal:
| 1 | ||
| 2 | Double Complementation | |
| 3 | DeMorgan's law | |
| 4 |
Lemma,
with |
|
| 5 |
Lemma, with |
|
| 6 |
Definition of nor,
where |
Note that we judiciously used new meta-variables
Similar to the previous exercise, express each of the following using nand only, and prove correctness using the algebraic identities.
This operation is particularly interesting, since making a NAND gate in hardware requires only two transistors.
Using
algebraic identities,
show that
This is an algebraic hand-evaluation:
a series of formulas joined by
In two exercises, you've shown the same equivalence by truth tables and by algebraic identities.
What is an advantage of using truth tables? What is an advantage of using identities?
In that
truth table exercise,
you also showed two
formulas
Describe a hybrid approach, combining truth tables and Boolean algebra, to prove the equivalence and non-equivalence of formulas.
To ponder on your own without turning it in: Which approach appeals more to you?
Using
algebraic identities,
rewrite the formula