Do problems 1-19 (inclusive), less the practice-problems (which already have a solution). Due 2004.Jan.27 (Tue), either at the start of class or under the instructor's door (DH3117) by 17:00, to avoid the late penalty.
/home/scheme/bin/waterworld.
To run Waterworld on your home computer,
download (from owlnet) the directory
/home/scheme/plt/203/collects/waterworld/,
and (from drscheme) add it as a teachpack.
[practice] 0pts
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] 0pts
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.
(1pt) Choose just one of the following informal arguments. For your choice, give a different conclusion -- a counterexample -- which is equally well justified by the provided argument, yet is false (or at least, clearly more false than the original). For this exercise, strive for realistic counterexample, rather than exagguratedly trivial as on the previous exercises.
[practice] 0pts
Let
(1pt) Translate the following English sentences into propositional logic. Your answers should be WFFs.
[practice] 0pts
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
(1pt)
It further happens to be the case that:
If a Logicanian page contains the word "weasel",
then it also contains either "words" or "eyed";
and
whenever a Logiconian page contains the word "mongoose",
it does not also contain the word "weasel";
and
finally, all Logiconian pages contain the word "Logiconia",
rather patriotically.
Write a formula expressing all this.
(Your formula will involve six propositions --
If a web page in Logiconia does not contain "weasel", does it contain "mongoose"?
Let's go meta for a moment: What can you conclude about this web page? (Yes, this one you're looking at now -- the one with the homework problems.) Why?
No, a Logiconian web page may contain neither of those words.
This web page contains both words; you may conclude that this web page isn't Logiconian! (If you are buying into the truth of what this page says about Logiconian pages.)
(3pts) Different search engines on the web have their own syntax for specifying searches.
Read over the search syntax for the search language of eBay®.
eBay uses sequencing for conjunction, parentheses for disjunction, and a preceding minus sign for negation.
border -common (foreign,foreign)
(pilaf,superb bowl).
(pilaf,superb bowl)
(pilaf,bowl superb)
pilaf
superb bowl
(superb,pilaf) (bowl,pilaf),
we get a search returning 88 results.
Hmm, we should get 5+84, from above.
An inspection shows that ebay's results are a bit weird;
in fact Pilaf and
pilaf both return
different results, even though both sets of matches
have the word "pilaf" in varying cases.
Their search-code is perhaps as confused as their query syntax?
Note that there are other problematic queries:
It's not entirely clear how to directly encode the query
a b
and put a - in front,
but that gives us
-a b,
which is the query for
[practice] 0pts
![]() |
Consider the particular board shown in the above figure.
(4pts) In that same board, is location W safe? What is your informal reasoning? (List all your small steps.) Similarly for location P.
X has exactly one neighboring pirate, so exactly one of W and Y must have a pirate. Y does not have a pirate. Therefore W does.
We use this fact to continue: Q has exactly one neighboring pirate, so exactly one of P, R, and W must have a pirate. W contains a pirate (by the previous step). Therefore, P and R do not, so P is safe.
(1pt) Give a domain axiom of WaterWorld which is not explicitly shown in the WaterWorld domain axioms. (Just show one that's omitted in the ellipses.)
(3pts) Give one WFF which meets all three conditions:
One way to do this is to include weaker formulas.
For example, instead of
A more interesting theorem to deduce is
(1pt) Write the truth-table for "xnor", the negation of exclusive-or, What is a more common name for this Boolean function?
| xnor | ||
|---|---|---|
This the "equals" (for Booleans). (If you said something like "logical equivalence" or "the both-or-neither function", that is a point off, as it's a roundabout way of expressing the simple idea "equals". Granted, it takes some practice to internalize Booleans as values, and that equality is as valid for them as for any other value.) This function is also represented by the connective "↔", and can also called "if-and-only-if".
(4pts)
Using truth-tables, show that
We'll name the three formulas of interest.
Let
| note | ||||||
|---|---|---|---|---|---|---|
| wffy, wffz differ | ||||||
| wffy, wffz differ | ||||||
Sure enough, the first two functions
(4pts) 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 formula (not using a conditional if).
For the graders' sake, please use either Java or scheme syntax,
and in the former case please parenthesize to make your formula unambiguous
(rather than rely having me having memorized
Java's 13 levels (with ?:) of operator precedence).
int i;
bool a,b;
…
return ________________;
When simplifying, you should treat i > 0 as
proposition, with i <= 0 as its negation.
One possible answer is
( ( a && b)
|| (!a && !b)) && (i > 0)
in Java,
or in scheme, (and (or (and a b) (and (not a) (not b))) (> i 0)).
While our particular syntax for logic formulas doesn't contain an
if-and-only-if connective, programming languages do: boolean=? or ==.
Using this could shorten our answer:
((a == b) && (i > 0)) in Java,
or in Scheme (and (boolean=? a b) (> i 0)).
[practice] 0pts
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.
(6pts)
Using
algebraic identities (.ps),
show that
This is an algebraic hand-evaluation:
a series of formulas joined by
Some issues to think about (w/o turning in): in a previous exercise we showed this same fact by using truth tables. Which approach appeals more to you? If trying to show equivalent to formulas with 10 propositions (instead of just 3) equivalent, which approach might you try? What about the rest of the previous problem -- showing two formulas non-equivalent -- it is possible to approach this with boolean algebra rather than truth tables. How? Is there some hybrid approach, that would convince you of the non/equivalence of formulas?
| 1 | ||
| 2 | Commutativity of |
|
| 3 | Associativity of |
|
| 4 | |
|
| 5 | Commutativity of |
|
| 6 | Distributivity of |
|
| 7 | Commutativity of |
|
| 8 | Commutativity of |
|
| 9 | Absorption with |
|
| 10 | Commutativity of |
|
| 11 | Commutativity of |
Ta-dum!
We could have saved some repeated-writing by
showing as a lemma that
(6pts)
Using
algebraic identities (.ps),
rewrite the formula
| 1 | ||
| 2 | Definition of |
|
| 3 | Distributivity of |
|
| 4 | Complement of |
|
| 5 | Dominance of |
|
| 6 | Distributivity of |
|
| 7 | Commutativity of |
|
| 8 | Definition of |
Ugh, that sure was tedious, and also (when done by hand) error-prone.
[practice] 0pts
Using
algebraic identities (.ps),
and the definition
NOR
First we show that we can write negation in terms of NOR, or
more specifically,
| 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,
|
|
| 6 | definition of |
Note that we judiciously used new meta-variables
For proofs on this homework, Remember that each step must be justified by one of: "premise", a listed inference rule (.ps) (a previous line number and, if ambiguous, substitutions for the inference rule's metavariables), or a WaterWorld domain axiom.
Postponed -- this problem postponed until the next homework; it uses one of the less obvious inference rules which we haven't discussed yet, but will touch upon in lecture Tuesday, 2004.jan.27.
Fill in the blank reasons in the following proof that
| 1 | premise | |||
| 2 | subproof: | |||
| 2.a | premise for subproof | |||
| 2.b | |
|||
| 3 | subproof: | |||
| 3.a | premise for subproof | |||
| 3.b | ____________ | |||
| 4 | ____________ | |||
| 1 | premise | |||
| 2 | subproof: | |||
| 2.a | premise | |||
| 2.b | |
|||
| 3 | subproof: | |||
| 3.a | premise | |||
| 3.b | |
|||
| 4 | |
|||