Practice problems - final exam, Jana Kosecka CS580.

6.5.  Here are the corresponding sentences in propositional logic.

  Mythical => Immortal
~Mythical => ~Immortal ^ Mammal
  Immortal  v Mammal => Horned
  Horned => Magical

Proof whether unicorn is mythical, magical,  horned.

First convert the sentences in KB into some standard from CNF or Horn Clauses.
Doing inference in propositional logic, we can use resolution, forward chaining or backward
chaining.

In order to proof Mythical we use backward chaining:
We have  to look for a clause which implies mythical and then check  what needs
to be true in order  for mythical to follow. Since none of the clauses implies  mythical
hence mythical is NIL - is not true.

in almost CNF:
1.  (~Mythical v Immortal  ) ^
2.  (Mythical v (~Immortal ^ Mammal)^
3.  (~(Immortal v Mammal) v Horned) ^
4.  (~Horned v Magical)

to proof  Magical :

resolving  1 and 2  yields  (Immortal) v (~Immortal ^ Mammal)   which is 5.  (Immortal v Mammal)
resolving  5 and 3 yields  6. Horned
resolving  6  and 4 yields  7. Mythical

Hence both Horned and Magical  are True.

6.12.

You have to represent following facts using propositional logic.
First you need a symbol for each person/job assignment
e.g.  JM, JP, JE   stands for Jones manager, Jones Programmer and Jones Enginneer
SM, SP, SE  and CM, CP, CE  similarly. Then you need to specify that each person
can have one job and each job can be held by only one person.
(JM ^ ~JP ^ ~JE)  v (~JM ^ JP ^ ~JE) v  (~JM ^ ~JP ^ JE)   states that Jones  has one job.
etc for the others.  From the statements you can deduce that Smith is not married, hence he cannot
be the manager ~SM  and from the other statements you also ~JP and ~JM.

The thorough mechanical proof is rather lengthy. You can conclude immediatelly
that JE is true and since you know that ~SM and also ~SE  then SP has to be true
and then CM must be true, since that's the only job which is left.

7.3. Here are few examples :

a) while naturally you would write Outburst => Contempt this is not correct meaning.
     you should have Outburst ^ Contempt
b) correct  AnnieHallOn ^ (Interested => CanWatch)
     intended Interested = >  AnnieHallOn
etc.

9.5. a. If you try to prove  ThereExist h Horse (h)   you get into an infinite loop

                                               Horse (h)
                                    /                                   \
                         Offspring(h,y)            Horse(Bluebeard)
                                 |                                          |
                          Parent(y,h)                  Offspring(Bluebeard, y)
                      Yes y/Bluebeard              Parent(y,Bluebeard)
                           h/Charlie                     Offspring(Bluebeard, y)
                                                                           ....

          b. particular rule above generates infinite loops
          c.  Both Charlie and Bluebeard cane proven to be horses

9.8.    ForAll x  Horse(x) = > Animal(x)
           ForAll x,h  Horse(x) ^ HeadOf(h,x) => ThereExist y Animal(y) ^ HeadOf(h,y)

           after converting to  CNF , negating the conclusion, skolemization, removing quantifiers
           we get following (where H, G are Skolem constants)

          1. ~Horse(x) v Animal(x)
          2.  Horse(G),
          3. HeadOf(H,G)
          4. ~Animal(y) v ~HeadOf(H,y)   where H and G are Skolem constants
           Resolving 4 and 3 yields  5. ~Animal(G)
           Resolving 5. and 1. yields  ~Horse(G)

         This is a contradiction with 2.

14.3.  We are given following information:

          P(test | disease) = 0.99
          P(~test | ~disease) = 0.99
          P(disease) = 0.0001
          test   which means that test is positive

          What needs to be computed is P(disease | test)  from the available information

                                                                   P(test | disease) P(disease)
           P(disease | test) = ------------------------------------
                                         P(test | disease) P(disease) +  P(test | ~disease) P(~disease)

14.4.   Rational beliefs are those who obey axioms of probability hence:

         We know that P(A) = 0.4  regardless B                              B   ~B      is the probability table
                           and P(B) = 0.3  regardless A                       A     a     b
                                                                                                     ~A     c     d

         P(A) = a + b = 0.4
         P(B) = a + c = 0.3
         P(A v B) = a + b + c = 0.5
         From there we can compute a = 0.2 , b = 0.2, c = 0.1  and d = 0.5 and any other query.
         hence it is rational to believe that  P(A ^ B) = 0.2;

        if P(A v B) = 0.7 then a = 0, but it is still rational.
        if P(A v B) = 0.8 as in the example in the text the axioms of probability are not obeyed.
 

14.6.  In oder to do the excercise you have to use apply the definition of   conditional probablity

P(X | Y) = P( X, Y) / P(Y)

first express the left hand side of both statements in terms of their joint distribution

P(A,B,C)                      P(B ,C)                          P(A, B, C)
------- = P(A | C) ------         and           -------    = P(A | C)
   P(C)                             P(C)                                 P(B, C)

with little more algebra you can show that they are the same.

14. 7. I did in the class.

14.11. We need two random variables LB - looked blue  and B - was blue
              The statement in the  excercise says that :
        P(LB | B) = 0.75    and also  P(~LB | ~B) = 0.75
        We need to know probability P(B | LB) = using Bayes Rule  ~ P(LB | B) P(B) ~ 0.75 *P(B)
        P(~B | LB)  ~ P(LB | ~B) P(~B) ~ (1 - P(LB | B)) P(~B)  ~ 0.25*(1-P(B))

       where we use ~ insted of = to denote equiaility within constant factor (scale)  which is
       in this case P(LB) .    We are still missing probability of P(B), so if we assume that the
       possibilities are equally  likely P(B) = 0.5 we can compute the probability that taxi was blue.

19.1.  First check whether XOR is linearly separable => it is not, hence we need a hidden layer.

                                  w = 0.3
          w = 0.3     ------------
                              \        w =-0.6          \
                          t = 0.5  --- -- -- t = 0.2
                              /                              /
            w = 0.3     -------- ----
                                                    w = 0.3

          XOR is like OR with the  AND case ruled out , so we need just one hidden node the which
       implements the AND . There are different choices of weights you can make as long as the
       function is preserved.

19.2.   This depends on the number of examples and inputs. Initially the data may be linearly
         separable, and the hyperplane will successfully separate them. But they won't be implementing
         XOR.   Once the data are inseperable the hyperplane plane will start moving around is different direct
         with XOR (or parity data), if we have the same number of positive and negative examples then
         the hyperplane will converge exactly in the middle  such that weight configurations will be
          such that output will be 0.5. But when there  is more examples of one kind the hyperplane will
          move around a lot.
 

14.5. Some of you asked me about the derivation of the equation on page 429. The idea is related to
        the excercise 14.5 and the story goes as follows. We know that Bayesian rule is good for computing
        the probabilities of some hypothesis given
        evidence P(H | E)  It lets us do it  by  having some idea how  often when the hypothesis was observed with a
        particular evidence .etc. ..  P(H|E) = P(E|H) P(H)/ P(E) . If we have multiple pieces of evidence E1 and E2 , then
        we eventhough we can still  use Bayes rule, we would end up on the left hand side with expression
        P(E1 ^ E2 | H),  which would have to be represented using some conditional probaility table by
         n^2 entries . So the point of the excersise is  to figure out how we can do it by understanding
        (and hence needing to store) only individual conditional probablities P(E1|H) and P(E2| H) .

        The derivation in formula on page 429, is using the relationship derived in excercise 14.5. b)
        where you are asked to prove that following statement holds

        P(A|B,C) = P(B|A, C) P(A|C) / P(B|C)

        Everytime when you have to show some relationship regarding the  conditional probabilities,
         you have to related them to joing probability, since that  is what they have in common.

 
        So LHS can be written in terms of joints as P(A,B,C)/P(B,C)
        RHS can be written in terms of joints as

        P(A,B,C)     P(A,C)         P(C)
        ------  . -----   . ------
          P(A,C)           P(C)       P(B,C)

        which is the same as LHS.

        Now is you then apply the result from 14b to the derivation of P(Cavity | Tootache ^ Catch)  and
        also substitute the expression from P(Cavity|Tootach) from page 428 , you will get the desired result.