CS 440ECE448 – Introduction to Artificial Intelligence

Document Sample
CS 440ECE448 – Introduction to Artificial Intelligence Powered By Docstoc
					     CS 440/ECE448 – Introduction to Artificial Intelligence
                                 Homework 3 – Solution



Part 1 – Propositional Logic

Problem 1.1 Given the following statements use Modus Ponens to find the values of A,
B, and C. Explain.
              (1) A ⇒ B
               (2) B ⇒ C
               (3) C ⇒ A
               (4) A ∨ B ∨ C

Answer (10 points):
According to statement (4) at least one of A, B or C must be true. Assume that A is false.
Then, we can derive that (H stands for hypothesis):
       (H1) ¬A                                Hypothesis
       (H2) ¬C                               Modus Tollens (3) and (H1)
      (H3) ¬B                               Modus Tollens (2) and (H2)
Statements (H1), (H2), and (H3) together contradict statement (4). Thus, A must be true.
Now, we can conclude that:
      (5) A                                 from the derivation above
      (6) B                                 Modus Ponens (1) and (5)
      (7) C                                 Modus Ponens (2) and (6)

Thus, A, B and C are all true.

Note:
Modus Tollens (mode that denies) is defined as follows:
((A ⇒ B) ∧ ¬B) ⇒ ¬A

Problem 1.2 If the unicorn is mythical, then it is immortal, but if it is not mythical, then
it is a mortal mammal. If the unicorn is either immortal or a mammal, then it is horned.
The unicorn is magical if it is horned.
     a) Write the above statements in propositional logic.
     b) Is the unicorn mythical? Explain.
     c) Is the unicorn horned? Explain.
     d) Is the unicorn magical? Explain.
Answer:
a) (8 points)
        (1) Mythical ⇒ ¬Mortal
       (2) ¬Mythical ⇒ Mortal ∧ Mammal
       (3) ¬Mortal ∨ Mammal ⇒ Horned
       (4) Horned ⇒ Magical

b) (2 points) Given the statements above, we cannot conclude whether the unicorn is
mythical or not.

c) (8 points)
Note: MP means Modus Ponens

       (5) Mythical ∨ ¬Mythical                      A ∨ ¬A is always true
       (6) ¬Mortal ∨ ¬Mythical                       MP (1) and Mythical in (5)
       (7) ¬Mortal ∨ (Mortal ∧ Mammal)               MP (2) and ¬Mythical in (6)
       (8) ¬Mortal ∨ Mammal                          from (7), Mortal∧Mammal⇒Mammal
       (9) Horned                                    MP (3) and (8)

Thus, the unicorn is horned.

d) (2 points)
        (10) Magical                                 MP (4) and (9)

Thus, the unicorn is magical.

Problem 1.3 Julia says that Sarah and Fred say the truth. Sarah says that Peter is lying.
Peter says that Fred says the truth. Fred says that Peter lies or Julia lies. Dick says, he
lies.
    a) Write the above statements in propositional logic.
    b) Who is lying?
    c) What about Dick?

Answer:
a) (0 points)
For this problem, note that that if A lies then the opposite of A’s statement is true. I.e., if
A claims that B and C tell the truth but A lies, then
¬A ⇒ ¬(B ∧ C)
Using de Morgan laws, we can further conclude
¬A ⇒ ¬B ∨ ¬C
        (1) Julia ⇒ Sarah ∧ Fred
        (2) ¬Julia ⇒ ¬Sarah ∨ ¬Fred
        (3) Sarah ⇒ ¬Peter
        (4) ¬Sarah ⇒ Peter
        (5) Peter ⇒ Fred
        (6) ¬Peter ⇒ ¬Fred
        (7) Fred ⇒ ¬Peter ∨ ¬Julia
        (8) ¬Fred ⇒ Peter ∧ Julia
        (9) Dick ⇒ ¬Dick
        (10) ¬Dick ⇒ Dick

b) (2 points for right answer)
In order to figure out who is lying, we must first make a guess. Assume that Peter is
lying. Then we can derive that:
        (H1) ¬Peter                       Hypothesis
        (H2) ¬Fred                              MP (6) and (H1)
        (H3) Peter ∧ Julia                      MP (8) and (H2)
      (H4) Peter                         Peter ∧ Julia ⇒ Peter
Statements (H1) and (H4) contradict each other. Thus Peter must be saying the truth.
Now, we conclude that:
      (11) Peter                         from the derivation above
      (12) Fred                          MP (5) and (11)
      (13) ¬Peter ∨ ¬Julia               MP (7) and (12)
        (14) Peter ⇒ ¬Julia                     implication from (13)
        (15) ¬Julia                             MP (11) and (14)
        (16) ¬Sarah ∨ ¬Fred                     MP (2) and (15)
        (17) Fred ⇒ ¬Sarah                      implication from (16)
        (18) ¬Sarah                             MP (12) and (17)

Thus, we can conclude that both Julia and Sarah lie. Peter and Fred tell the truth.

c) (0 points) If Dick tells the truth, he lies. But if he lies, he tells the truth. Dick does not
have a truth value in propositional logic.
Part 2 – First-Order Logic to English Translation

Instructions: State each of the following first-order logic statements in English.

Problem 2.1 ∀x [BornIn(x,USA) ∨ (∃y Parent(y,x) ∧ USCitizen(y))] ⇒ USCitizen(x)
Answer (8 points): Any person who is born in the USA or has a parent who is a US
citizen, then the person is a US citizen.

Problem 2.2 ∀x Airplane(x) ⇒ [∃w1,w2 Wing(w1) ∧ Wing(w2) ∧ w1≠w2]
Answer (6 points): For every airplane there are two wings. (The wings do not
necessarily belong to the airplane)

Problem 2.3 ∀x,y [List(x) ∧ Item(y) ∧ Append(x,y)] ⇒ ItemOf(x,y)
Answer (6 points): If an item y is appended to a list x, then y is an item of x.

Problem 2.4 ∀x Person(x) ⇒ [∃y,z Person(y) ∧ Speaks(x,z) ∧ Speaks(y,z)]
Answer (0 points): For every person, there is a language z that is spoken by that person
and some other person. (Other interpretations are possible.)

Problem 2.5 ∀x,y R(x,y) ⇒ [∀z R(x,z) ⇒ z=y] ∧ [∀ z R(z,y) ⇒ z=x]
               Give an example of a relationship between two humans x and y that can be
               substituted for R.
Answer (10 points): R is an exclusive relationship, i.e. if x and y are in a relationship R
then neither x nor y have the same relationship R with some other z. If x and y are
humans, then marriage would be such a relationship.


Part 3 – English to First-Order Logic Translation

Instructions: Provide a first-order logic representation for each of the statements below.
Use appropriate predicate names.

Problem 3.1 Politicians can fool some people all of the time, and they can fool all
people some of the time, but they can’t fool all of the people all of the time.

Answer (0 points):
Let Fool(x,y,t) mean that x can fool y at time t.

∀ x Politician(x) ⇒
               (∃ y Person(y) ⇒ (∀ t Time(t) ⇒ Fool(x,y,t))) ∧
               (∃ t Time(t) ⇒ (∀ y Person(y) ⇒ Fool(x,y,t)) ∧
               (∃ t,y Time(t) ∧ Person(y) ⇒ ¬Fool(x,y,t))
Problem 3.2 For anybody who loves everybody there is always somebody who hates
everybody.

Answer (10 points):
Let Loves(x,y) mean that x loves y, and Hates(z,y) mean that z hates y.

∀ x Person(x) ∧ (∀ y Person(y) ⇒ Loves(x,y)) ⇒
                              ∃ z Person(z) ∀ (∀ y Person(y) ⇒ Hates(z,y))

Problem 3.3 No two persons are separated by more than 6 degrees. (This is the 6
degrees of Kevin Bacon statement. Do not use any numbers or a function that computes
the degree of a person. Rather, just use the predicate Knows(x,y) to express that x and y
are separated by degree 1.)

Answer (10 points):
∀ x, y Person(x) ∧ Person(y) ⇒ ∃ z1, z2, z3, z4, z5
               Person(z1) ∧ Person(z2) ∧ Person(z3) ∧ Person(z4) ∧ Person(z5) ∧
               Knows(x,z1) ∧ Knows(z1,z2) ∧ Knows(z2,z3) ∧ Knows(z3,z4) ∧
               Knows(z4,z5) ∧ Knows(z5,y)

Problem 3.4 Fool me once, shame on you. Fool me twice, shame on me. (If you fool
me more than twice, still shame on me.)

Answer (0 points):
Let Fool(x,y,t) mean that x fools y at time t. The two sentences above have to be
expressed with two first order logic statements.

(1) ∀ me,you Person(me) ∧ Person(you) ∧ (∃ t1 Time(t1) ∧ Fool(you,me,t1) ∧
       (∀ t2 Time(t2) ∧ Fool(you,me,t2) ⇒ t1=t2)) => ShameOn(you)
(2) ∀ me,you Person(me) ∧ Person(you) and (∃ t1, t2 Time(t1) ∧ Time(t2) ∧ t1≠t2 ∧
       Fool(you,me,t1) ∧ Fool(you,me,t2)) ⇒ ShameOn(me)

Problem 3.5 Every question is more challenging than the previous question.

Answer (0 points):
Let MoreChallenging(q1,q2) be true if q1 is more challenging than q2. Let Previous(q) be a
function that return the question before question q.

∀ q Question(q) ⇒ MoreChallenging(q, Previous(q))
Problem 3.6 No person except a natural born citizen, shall be eligible to the office of
President; neither shall any person be eligible to that office who shall not have attained to
the age of thirty five years, and been fourteen years a resident within the United States.
(Excerpt from the US Constitution, Article 2, Section 1.)

Answer (10 points):
Let NBC(x) be true if and only if x is a natural born citizen. Let LessThan(x,y) be true if
and only if x is less than y. Let Age(x) be a function that returns the age of x. Let
YearsResidentInUS(x) be a function that returns the number of years x has been a
resident in the US. Let Eligible(x) be true if and only if x is eligible to the office of the
president.

∀ x Person(x) ∧ (¬NBC(x) ∨ LessThan(Age(x),35) ∨
                   LessThan(YearsResidentInUS(x),14)) ⇒ ¬Eligible(x)

Part 4 – Resolution

Problem 4.1 Assume that the following facts are true.

∀x Quail(x) ⇒ HasFeathers(x)
∀x,y [IsHuntingQuail(x) ∧ Shoots(x,y) ] ⇒ Quail(y)
American(HarryWhittington)
IsHuntingQuail(DickCheney)
Shoots(DickCheney,HarryWhittington)

     a) Restate the above statements in conjunctive normal form.
     b) Given the facts above, use resolution to prove the statement
        ∃x American(x) ∧ HasFeathers(x)
        Show each step of the resolution.

Answer (4 points):

a)
     (1) ¬Quail(x) ∨ HasFeathers(x)
     (2)   ¬IsHuntingQuail(x) ∨ ¬Shoots(x,y) ∨ Quail(y)
     (3)   American(HarryWhittington)
     (4)   IsHuntingQuail(DickCheney)
     (5)   Shoots(DickCheney,HarryWhittington)
b)
We first negate the statement that we want to prove:
¬∃x American(x) ∧ HasFeathers(x)
Next, we convert it to conjunctive normal form and add it as a statement to the
knowledge base:
   (6) ¬American(x) ∨ ¬HasFeathers(x)

Now, we show a contradiction using resolution:
  (7) ¬HasFeathers(HarryWhittington)                  (3) and (6), {x/HarryWhittington}
   (8) ¬Quail(HarryWhittington)                       (1) and (7), {x/HarryWhittington}
   (9) ¬IsHuntingQuail(x) ∨                           (2) and (8), {y/HarryWhittington}
       ¬Shoots(x, HarryWhittington)
   (10) ¬Shoots(DickCheney,HarryWhittington)          (4) and (9), {x/DickCheney}
   (11) {}                                            (5) and (10)

Thus, we can conclude that there exists an American who has feathers.




Problem 4.2 Assume that the following facts are true.

∀x (∀y Eats(x,y) ⇒ FastFood(y)) ⇒ (∃y HasHealthProblem(x,y))
∀x (∃y HasHealthProblem(x,y)) ⇒ HighCholesterol(x) ∨ Cold(x)
∀x KeepsWarm(x) ⇒ ¬Cold(x)
∀x (HighCholesterol(x) ∧ ¬WorksOut(x)) ⇒ ShortLife(x)
¬∃x Lazy(x) ∧ WorksOut(x)
∀x Eats(Donald,x) ⇒ FastFood(x)
KeepsWarm(Donald)
Lazy(Donald)

   a) Restate the above statements in conjunctive normal form.
   b) Given the facts above, use resolution to prove the statement
       ShortLife(Donald)
       Show each step of the resolution.
Answer (4 points):

a)
     (1) Eats(x,F(x)) ∨ HasHealthProblem(x,G(x))
     (2) ¬FastFood(F(x)) ∨ HasHealthProblem(x,G(x))
     (3) ¬HasHealthProblem(x,y) ∨ HighCholesterol(x) ∨ Cold(x)
     (4) ¬KeepsWarm(x) ∨ ¬Cold(x)
     (5) ¬HighCholesterol(x) ∨ WorksOut(x) ∨ ShortLife(x)
     (6) ¬Lazy(x) ∨ ¬WorksOut(x)
     (7) ¬Eats(Donald,x) ∨ FastFood(x)
     (8) KeepsWarm(Donald)
     (9) Lazy(Donald)


b)
We negate the statement that we want to prove and add to the knowledge base:
   (10) ¬ShortLife(Donald)

Now, we show a contradiction using resolution:
  (11) ¬HighCholesterol(Donald) ∨ WorksOut(Donald)          (5) and (10), {x/Donald}
     (12) ¬HighCholesterol(Donald) ∨ ¬Lazy(Donald)          (6) and (11), {x/Donald}
     (13) ¬HighCholesterol(Donald)                          (9) and (12)
     (14) ¬HasHealthProblem(Donald,y) ∨ Cold(Donald)        (3) and (13), {x/Donald}
     (15) ¬HasHealthProblem(Donald,y) ∨                     (4) and (14), {x/Donald}
          ¬KeepsWarm(Donald)
     (16) ¬HasHealthProblem(Donald,y)                       (8) and (15)
     (17) ¬FastFood(F(Donald))                              (2) and (16),
                                                            {x/Donald, y/G(Donald)}
     (18) ¬Eats(Donald,F(Donald))                           (7) and (17), {x/F(Donald)}
     (19) Eats(Donald,F(Donald))                            (1) and (16),
                                                            {x/Donald, y/G(Donald)}
     (20) {}                                                (18) and (19)

Thus, we can conclude that Donald has a short life.