George A. Madrid
6.034 - Artificial Intelligence
Problem Set 2
Carl Manning - R10-11



Problem 1

We know:

  splashy has feathers
  splashy lays eggs
  splashy does not fly
  splashy is black and white
  splashy swims.

Now, we hypothesize that Splashy is a [sic] Ostrich.  

o To show that splashy is a ostrich, we can use rule z13.  First, we have to
  show first that splashy is a bird, does not fly, has long legs and a long
  neck, and is black and white.  We will start by hypothesizing that he is a
  bird.  We can show this using rules z3 and z4.  

o To show that splashy is a bird by z3, we have to show that splashy has
  feathers.  We know that he has feathers, so we go back to z13.

o We know that splashy does not fly.  We don't know that he has long legs, and
  there is no way to show it, so splashy is not a [sic] Ostrich.

Now, we hypothesize that Splashy is a Penguin.

o To show that splashy is a penguin, we can use rule z14.  First, we have to
  show that he is a bird, does not fly, swims, and is black and white.  We
  will start by hypothesizing that he is a bird.  We can show this using rules
  z3 and z4.

o To show that splashy is a bird by z3, we have to show that he has feathers.
  We know that he has feathers, so we go back to z14.

o We know that he does not fly.

o We know that he swims.

o We know that he is black and white.  

o So, splashy is a penguin.

Now we hypothesize that Splashy is a [sic] Albatross.

o To show that splashy is a albatross, we can use rule z15.  To do this, we
  have to show that he is a bird, and that he flies well.  We will start by
  hypothesizing that he is a bird.  We can show this using rules z3 and z4.  

o To show that splashy is a bird by z3, we have to show that he has feathers.
  We know that he has feathers, so we go back to z15.

o Now we hypothesize that splashy flies well.  There is no rule to help us
  show this, and we don't know it, so splashy is not a albatross.

Problem 2

Problem 2.1

Output
==-> > (assertions-21)
==-> (STIPE-COLOR IS RED)
==-> > (chain)
==-> 
==-> Rule MUSH1 indicates (GENUS IS AMANITA).
==-> Rule MUSH4 indicates (SECTION IS MAPPAE).
==-> Rule MUSH10 indicates (IDENTITY IS FLAVIVOLVATA).
==-> > =->

We determine that the identity is FLAVIVOLVATA.  We also get its genus and
section.

Problem 2.2.

Output
==> > (assertions-22)
==> (BASE-SHAPE IS BULBOUS)
==> > (chain)
==>
==> Rule MUSH3 indicates (GENUS IS LIMACELLA).
==> > =->

We cannot identify it given the rules that we have.  

Problem 2.2.1 & 2.2.2
To update the rulebase, I run my procedure (new-rules-221).  
Then to test them, I run my various tests.

Output
==> > (make-mushroom-rules)
==> 
==> Mushroom rules recorded
==> > (new-rules-221)
==> (NEW-MUSH4 IF (GENUS IS AMANITA) (MARGIN-TYPE IS STRIATE) ADD (SECTION IS VALIDAE))
==> > (test1-222)
==> (BASE-SHAPE IS BULBOUS)
==> > (chain)
==> 
==> Rule MUSH3 indicates (GENUS IS LIMACELLA).
==> Rule NEW-MUSH1 indicates (IDENTITY IS GEMMATA).
==> > (clear-assertions)
==> NIL
==> > (test2-222)
==> (MARGIN-TYPE IS STRIATE)
==> > (chain)
==> 
==> Rule NEW-MUSH2 indicates (IDENTITY IS INAURARA).
==> > (clear-assertions)
==> NIL
==> > (test3-222)
==> (MARGIN-TYPE IS TUBERCULATE-STRIATE)
==> > (chain)
==> 
==> Rule NEW-MUSH3 indicates (IDENTITY IS INAURARA).
==> > (clear-assertions)
==> NIL
==> > (test4-222)
==> (MARGIN-TYPE IS STRIATE)
==> > (chain)
==> 
==> Rule MUSH1 indicates (GENUS IS AMANITA).
==> Rule NEW-MUSH4 indicates (SECTION IS VALIDAE).
==> > =->

Problem 3

The assertions are the same as 2.1, so I'll use that.

So, we see that it isn't californica.  But we can show that it is
flavivolvata. 

Output:
==> > (assertions-21)
==> (STIPE-COLOR IS RED)
==> > (hypothesize '(identity is californica))
==> 
==> Trying to establish IDENTITY IS CALIFORNICA using rule MUSH11.
==> Trying to establish SECTION IS MAPPAE using rule MUSH4.
==> Trying to establish GENUS IS AMANITA using rule MUSH1.
==> Rule MUSH1 establishes GENUS IS AMANITA.
==> Rule MUSH4 establishes SECTION IS MAPPAE.
==> Trying to establish GENUS IS AMANITA using rule MUSH2.
==> Rule MUSH2 fails to establish GENUS IS AMANITA.
==> Rule MUSH11 fails to establish IDENTITY IS CALIFORNICA.
==> Evidently IDENTITY IS CALIFORNICA is false.
==> NIL
==> > (hypothesize '(identity is FLAVIVOLVATA))
==> 
==> Trying to establish IDENTITY IS FLAVIVOLVATA using rule MUSH10.
==> Trying to establish SECTION IS MAPPAE using rule MUSH4.
==> Trying to establish GENUS IS AMANITA using rule MUSH1.
==> Rule MUSH1 establishes GENUS IS AMANITA.
==> Rule MUSH4 establishes SECTION IS MAPPAE.
==> Rule MUSH10 establishes IDENTITY IS FLAVIVOLVATA.
==> Evidently IDENTITY IS FLAVIVOLVATA is true.
==> T
==> > =->


Problem 4

Problem 4.1

The test for (make-sandy)

==> > (make-sandy)
==> 
==> Sandy's characteristics recorded:
==> (SANDY HAS LONG LEGS) 
==> (SANDY HAS LONG NECK) 
==> (SANDY HAS FEATHERS) 
==> (SANDY LAYS EGGS) 
==> (SANDY DOES NOT FLY) 
==> (SANDY IS BLACK AND WHITE) 
==> (SANDY SWIMS) 
==> (HYPOTHESIS (SANDY IS A OSTRICH)) 
==> > (chain)
==> 
==> Rule Z13B indicates (HYPOTHESIS (SANDY IS A BIRD)).
==> Rule Z13B indicates (HYPOTHESIS (SANDY DOES NOT FLY)).
==> Rule Z13B indicates (HYPOTHESIS (SANDY HAS LONG LEGS)).
==> Rule Z13B indicates (HYPOTHESIS (SANDY HAS LONG NECK)).
==> Rule Z13B indicates (HYPOTHESIS (SANDY IS BLACK AND WHITE)).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY DOES NOT FLY)).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY HAS LONG LEGS)).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY HAS LONG NECK)).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY IS BLACK AND WHITE)).
==> Rule Z3A indicates (SANDY IS A BIRD).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY IS A BIRD)).
==> Rule Z13A indicates (SANDY IS A OSTRICH).
==> Rule Z0 indicates (HYPOTHESIS SATISFIED (SANDY IS A OSTRICH)).
==> > =->

Problem 4.2

==> > (new-rules42)
==> (MUSH13B IF (HYPOTHESIS (IDENTITY IS CONSTRICTA)) ADD (HYPOTHESIS (SECTION IS LEPIDELLA)) (HYPOTHESIS (STIPE-COLOR IS GRAY)))
==> > (test1-42)
==> (HYPOTHESIS (IDENTITY IS CONSTRICTA))
==> > (chain)
==> 
==> Rule MUSH13B indicates (HYPOTHESIS (SECTION IS LEPIDELLA)).
==> Rule MUSH13B indicates (HYPOTHESIS (STIPE-COLOR IS GRAY)).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (STIPE-COLOR IS GRAY)).
==> Rule MUSH8B indicates (HYPOTHESIS (GENUS IS LIMACELLA)).
==> Rule MUSH8B indicates (HYPOTHESIS (CONTEXT-ODOR IS STRONG-AND-PUNGENT)).
==> Rule MUSH8B indicates (HYPOTHESIS (BASE-SHAPE IS BULBOUS)).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (CONTEXT-ODOR IS STRONG-AND-PUNGENT)).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (BASE-SHAPE IS BULBOUS)).
==> Rule MUSH3A indicates (GENUS IS LIMACELLA).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (GENUS IS LIMACELLA)).
==> Rule MUSH8A indicates (SECTION IS LEPIDELLA).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (SECTION IS LEPIDELLA)).
==> Rule MUSH13A indicates (IDENTITY IS CONSTRICTA).
==> Rule MUSH0 indicates (HYPOTHESIS SATISFIED (IDENTITY IS CONSTRICTA)).
==> > =->

However, if I use something like (test2-42) it will loop forever.  It will
just keep trying to satisfy MUSH8b and MUSH0.  Since 8b causes it to set
'(hypothesis (base-shape is bulbous)) but '(base-shape is bulbous) is already
set, so it will just pop back and forth hypothesizing and removing the
hypothesis, over and over again.  So, I haven't included the output, since it
doesn't end.

Problem 4.3

Well, if we left in z0, then we would add the consequent whether we
hypothesized it or not.

Well, here's a stab in the dark.  If we were just trying to find out
everything that we could about an object, this might be nice, I guess.
Perhaps being a carnivore doesn't help us prove that some animal is a quuxfoo,
but it's nice to know it anyway.  How's that?

Problem 4.4

No, it will never try to prove that splashy eats meat because both of the
antecedents of z5b2 will never be met.  Specifically, '(splashy is a mammal)
will never be met.  

I *think* that this will prevent the sort of looping that I mentioned in 4.2.
Since only one hypothesis is made at a time, we won't be able to hypothesize
anything that we already know which is the condition that creates that loop.

