CSE 472/572, Spring 2002 ========================================================================= HW 5 ANSWERS ========================================================================= 6.2. To see the answers for these, try out the logic software from our text! It's all in /projects/rapaport/572/NEW. What follows is a script that gives the answers to this problem, and shows you another function from the text's software that you might find fun to play with. > old-acl Allegro CL Enterprise Edition 5.0.1 [SPARC] (8/20/99 10:07) Copyright (C) 1985-1999, Franz Inc., Berkeley, CA, USA. All Rights Reserved. ;; Optimization settings: safety 1, space 1, speed 1, debug 2. ;; For a complete description of all compiler switches given the ;; current optimization settings evaluate (EXPLAIN-COMPILER-SETTINGS). USER(1): :ld aima.lisp ; Loading /projects/rapaport/572/NEW/aima.lisp ; Fast loading /projects/rapaport/572/NEW/utilities/utilities.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/binary-tree.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/queue.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/cltl2.fasl ; Fast loading ; /projects/rapaport/572/NEW/utilities/test-utilities.fasl USER(2): (aima-load 'logic) ; Fast loading /projects/rapaport/572/NEW/agents/test-agents.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/basic-env.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/grid-env.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/vacuum.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/wumpus.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/agent.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/vacuum.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/wumpus.fasl ; Fast loading /projects/rapaport/572/NEW/agents/algorithms/grid.fasl ; Fast loading /projects/rapaport/572/NEW/logic/test-logic.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/tell-ask.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/unify.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/normal.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/prop.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/horn.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/fol.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/infix.fasl ; Fast loading ; /projects/rapaport/572/NEW/logic/environments/shopping.fasl T USER(3): (truth-table "P ^ (Q | R) <=> (P ^ Q) | (P ^ R)") ----------------------------------------------------------------------------------------------------- P Q R Q | R P ^ (Q | R) P ^ Q P ^ R (P ^ Q) | (P ^ R) (P ^ (Q | R)) <=> ((P ^ Q) | (P ^ R)) ----------------------------------------------------------------------------------------------------- F F F F F F F F T T F F F F F F F T F T F T F F F F T T T F T T T F T T F F T T F F F F T T F T T T F T T T F T T T F F F F T T T T T T T T T T ----------------------------------------------------------------------------------------------------- NIL USER(4): (truth-table "~(P ^ Q) <=> (~P | ~Q)") ---------------------------------------------------------------------------------- P Q P ^ Q ~ (^ P Q) ~ P ~ Q (~ P) | (~ Q) (~ (^ P Q)) <=> ((~ P) | (~ Q)) ---------------------------------------------------------------------------------- F F F T T T T T T F F T F T T T F T F T T F T T T T T F F F F T ---------------------------------------------------------------------------------- NIL USER(11): (validity "(~(~P) <=> P)") VALID USER(12): (exit) ; Exiting Lisp > x exit script done on Tue 05 Mar 2002 02:58:32 PM EST 6.4. This is a well-known puzzle in the philosophy of logic. Historically, people have answered this question in 3 different ways: (1) Since "2+2=4" is a true, indeed *necessarily* true sentence of arithmetic (and, hence, according to some "logicist" philosophers, such as Bertrand Russell), a necessarily true sentence of logic), the sentence in the text is logically valid; i.e., it's a tautology, and so it is not about arithmetic *or* the weather (since it's true under all interpretations)! (Logicists believe that all of mathematics is reducible to logic (or logic + set theory).) (2) Since the sentence in the text is logically equivalent to "2+2=4", it is about arithmetic. (This is the answer given by relevance-logicians and situation- semanticists, as well as by R&N.) (3) Since the sentence mentions both arithmetic *and* the weather, it is about both. (This is the answer given by classical logicians who are not logicists like Russell.) 6.5. Using the following syntax and semantics: MYTH means: the unicorn is mythical MORT means: the unicorn is mortal MAMM means: the unicorn is a mammal HORN means: the unicorn is horned MAGIC means: the unicorn is magical represent the argument as follows: 1. MYTH => ~MORT 2. ~MYTH => (MORT ^ MAMM) 3. (~MORT v MAMM) => HORN 4. HORN => MAGIC Then argue as follows (I will leave it to you to fill in the missing steps): 5. ~MYTH => MAMM ; from 2 6. (MYTH v ~MYTH) => (~MORT v MAMM) ; from 1, 5 7. HORN ; from 3, 6 8. MAGIC ; from 4, 7 So HORN and MAGIC can be inferred. But MYTH cannot: If MYTH is F and MORT, MAMM, HORN, and MAGIC are all T, then the premises are all T, but MYTH is F. So the truth-value of MYTH need not be T even if all the premises are T. There's software for you to try this out. Here's a sample run. > old-acl Allegro CL Enterprise Edition 5.0.1 [SPARC] (8/20/99 10:07) Copyright (C) 1985-1999, Franz Inc., Berkeley, CA, USA. All Rights Reserved. ;; Optimization settings: safety 1, space 1, speed 1, debug 2. ;; For a complete description of all compiler switches given the ;; current optimization settings evaluate (EXPLAIN-COMPILER-SETTINGS). USER(1): (load "aima.lisp") ; Loading /projects/rapaport/572/NEW/aima.lisp ; Fast loading /projects/rapaport/572/NEW/utilities/utilities.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/binary-tree.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/queue.fasl ; Fast loading /projects/rapaport/572/NEW/utilities/cltl2.fasl ; Fast loading ; /projects/rapaport/572/NEW/utilities/test-utilities.fasl T USER(2): (aima-load 'logic) ; Fast loading /projects/rapaport/572/NEW/agents/test-agents.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/basic-env.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/grid-env.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/vacuum.fasl ; Fast loading ; /projects/rapaport/572/NEW/agents/environments/wumpus.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/agent.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/vacuum.fasl ; Fast loading /projects/rapaport/572/NEW/agents/agents/wumpus.fasl ; Fast loading /projects/rapaport/572/NEW/agents/algorithms/grid.fasl ; Fast loading /projects/rapaport/572/NEW/logic/test-logic.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/tell-ask.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/unify.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/normal.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/prop.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/horn.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/fol.fasl ; Fast loading /projects/rapaport/572/NEW/logic/algorithms/infix.fasl ; Fast loading ; /projects/rapaport/572/NEW/logic/environments/shopping.fasl T USER(3): (setf kb (make-prop-kb)) # USER(4): (tell kb "MYTH => ~MORT") T USER(5): (tell kb "~MYTH => (MORT ^ MAMM)") T USER(6): (tell kb "(~MORT | MAMM) => HORN") T USER(7): (tell kb "HORN => MAGIC") T USER(8): (ask kb "MYTH") NIL USER(9): (ask kb "~MYTH") NIL USER(10): (ask kb "MAGIC") T USER(11): (ask kb "HORN") T USER(12): (exit) ; Exiting Lisp > x exit script done on Tue 05 Mar 2002 03:01:50 PM EST Problem 4: P Q R if P, then Q, else R - - - -------------------- F F F F F F T T F T F F F T T T T F F F T F T F T T F T T T T T (if P then Q else R) is logically equivalent to ((P => Q) ^ (~P => R)) or (if P then Q else R) is logically equivalent to ((~P v Q) ^ (P v R)) (Actually, if-then-else is ambiguous. I will soon post a lengthier discussion of this problem.) ========================================================================= When I gave HW 4 2 years ago, there was some confusion on the if-then-else question. Here is some correspondence I had on this from my TAs for that course. ------------------------------------------------------------------------- From feit Thu Mar 2 14:52 EST 1995 You requested the tt for if P then Q else R, and you told people NOT to confuse it with the if-then-else of a programming language. But this is exactly the tt you gave: in the cases where P was t, you based the value of the formula on Q. In the places that P was false, you based the value on R. This is the first time I've looked at it closely. I had assumed you wanted: P | Q | R | if P then Q | if P then Q else R --+---+---+-------------+------------------- F | F | F | T | T F | F | T | T | T F | T | F | T | T F | T | T | T | T T | F | F | F | F T | F | T | F | T T | T | F | T | T T | T | T | T | T Clearly, my confusion was over what piece of the formula "else" ranged over. ------------------------------------------------------------------------- Date: Thu, 2 Mar 1995 15:18:10 -0500 From: "William J. Rapaport" To: feit, goetz, rapaport Subject: Re: HW4, q4 Ah, so you were interpreting it as: let the truth value be that of P=>Q if P=>Q is true otherwise let its truth value be that of R Interesting, but not what I had in mind. My admonition not to confuse the propositional wff if P then Q else R with the programming language if-then-else was simply that in the latter case, Q and R are not wffs, hence have no truth value (they are commands, not boolean-valued expressions). ------------------------------------------------------------------------- From goetz Fri Mar 3 12:00 EST 1995 "If P then Q else R": Some students are interpreting this as If P then . Should I give them full credit? It seems to me the student should know that the "else" matches the "if". ------------------------------------------------------------------------- Rapaport's reply: I agree