أخر الاخبار

sheet solutions for smart systems



Q-A robot has an empty 9-gallon jug and an empty 4-gallon jug. A water tap and a drain are available. The robot can perform the following primitive functions only: 
1- Completely fill a jug from the water tap; 
2- Completely empty a jug down the drain; 
3- Pour from one jug into the other until either the first jug is empty, or the second jug is full.
 a- Represent this problem as a set of production rules. 
b- Show the execution of this production system that makes the robot get exactly 6 gallons of water into the 9 gallon jug.

sol//

x represents the quantity of  water in the 4-gallon jug  x= 0,1,2,3,4

y represents the quantity of water in 3-gallon jug y=0,1,2,3

Start State: (0,0)

Goal State: (2,0)

Generate production rules for the water jug problem

We basically perform three operations to achieve the goal.

  1. Fill water jug.
  2. Empty water jug
  3. and Transfer water jug


Rule

State

Process

1

(X,Y | X<4)

(4,Y)

{Fill 4-gallon jug}

2

(X,Y |Y<3)

(X,3)

{Fill 3-gallon jug}

3

(X,Y |X>0)

(0,Y)

{Empty 4-gallon jug}

4

(X,Y | Y>0)

(X,0)

{Empty 3-gallon jug}

5

(X,Y | X+Y>=4 ^ Y>0)

(4,Y-(4-X))

{Pour water from 3-gallon jug into 4-gallon jug until 4-gallon jug is full}

6

(X,Y | X+Y>=3 ^X>0)

(X-(3-Y),3)

{Pour water from 4-gallon jug into 3-gallon jug until 3-gallon jug is full}

7

(X,Y | X+Y<=4 ^Y>0)

(X+Y,0)

{Pour all water from 3-gallon jug into 4-gallon jug}

8

(X,Y | X+Y <=3^ X>0)

(0,X+Y)

{Pour all water from 4-gallon jug into 3-gallon jug}

9

(0,2)

(2,0)

{Pour 2 gallon water from 3 gallon jug into 4 gallon jug}


Initialization:

Start State: (0,0)

Apply Rule 2:

Fill 3-gallon jug
Now the state is (x,3)

Iteration 1:

Current State: (x,3)

Apply Rule 7:

Pour all water from 3-gallon jug into 4-gallon jug

Now the state is (3,0)

Iteration 2:

Current State : (3,0)

Apply Rule 2:

Fill 3-gallon jug
Now the state is (3,3)

Iteration 3:

Current State:(3,3)

Apply Rule 5:

Pour water from 3-gallon jug into 4-gallon jug until 4-gallon jug is full

Now the state is (4,2)

Iteration 4:

Current State : (4,2)

Apply Rule 3:

Empty 4-gallon jug
Now state is (0,2)

Iteration 5:

Current State : (0,2)

Apply Rule 9:

Pour 2 gallon water from 3 gallon jug into 4 gallon jug


Now the state is (2,0)-- Goal Achieved.

Water Jug Solution using DFS (Depth First Search)



Q-Consider the following production system.

R1: IF (( X is a man and Y is a woman ) AND (X and Y are lovers))
THEN (X is a friend of Y).
R2: IF ((X is a man and Y is a woman) AND ( X married Y))
THEN (X loves Y).
R3: IF ((X is a man and Y is a woman) AND (Y married X))
THEN (Y loves X).
R4: IF ((X loves Y ) AND (Y loves X))
THEN (X and Y are lovers).
If the working memory contains: Ahmed is a man, Ban is a woman, Ahmed
married Ban, Ban married Ahmed. Prove that “Ahmed is a friend of Ban”.

sol//

((Ahmed is a man and Ban is a woman) AND (Ahmed married Ban)) THEN (Ahmed loves Ban).

Also ((Ahmed is a man and Ban is a woman) AND (Ban married Ahmed)) THEN (Ban loves Ahmed).

Now ((Ahmed loves Ban) AND (Ban loves Ahmed)) THEN (Ahmed and Ban are lovers).

Also (( Ahmed is a man and Ban is a woman ) AND (Ahmed and Ban are lovers)) THEN (Ahmed is a friend of Ban).


Q-Consider the following rules:-

R1: IF blood pressure is likely to be high THEN risk of heart failure is high
R2: IF blood pressure is likely to be low THEN risk of heart failure is low
R3: IF alcohol consumption is high AND patient salt intake is high
THEN blood pressure is likely to be high
R4: IF alcohol consumption is low AND patient salt intake is low
THEN blood pressure is likely to be low
R5: IF units of alcohol per week are > 30 THEN alcohol consumption is high
R6: IF units of alcohol per week are < 20 THEN alcohol consumption is low
R7: IF units of alcohol per week are >= 20 AND <= 30
THEN alcohol consumption is average
And the following facts: units of alcohol >30, salt intake is high.
Using forward chaining, determine a patient's risk of heart failure.

sol//

If A is true then B has to be true, it can't be false.

Given facts (which are always true):

GF1: unit of alcohol>30

GF2: Salt intake is high

Using rule R5:

D1: We get, alcohol consumption is high.

In rule R3:

Using GF2 and D1 , we get,

D2: Blood pressure is high

Using R1 :

D3: Risk of heart failure is high.






Q- A monkey is in a room containing a box and a bunch of bananas. The bananas are hanging from the ceiling out of reach of the monkey. How can the monkey obtain the bananas? (The monkey is supposed to go to the box, push it under the bananas, climb on top of it and grasp the bananas.) Specify the rules for a production system to solve the monkey-and-bananas problem.

sol//





Q-Consider the following production rules:

 R1: IF has(Animal,hair) or give(Animal.milk) THEN isa(Animal,mammal)

 R2: IF has((flies(Animal) and lays(Animal,eggs)) THEN isa(Animal,bird)

 R3: IF isa(Animal,mammal) and (eats(Animal,meat) or (has(Animal,pointed_teeth) and has(Animal,claws) and has(Animal,forward_pointing_eyes))) THEN isa(Animal,carnivore)

 R4: IF isa(Animal,carnivore) and has(Animal,tawny_colour) and has(Animal,dark_spots) THEN isa(Animal,cheetah) 

R5: IF isa(Animal,carnivore) and has(Animal,tawny_colour) and has(Animal,black_stripes) THEN isa(Animal,tiger)

 R6: IF isa(Animal,bird) and not flies(Animal) and swims(Animal) THEN isa(Animal,penguin)

 R7: IF isa(Animal,bird) and has(Animal,large_wingspan) THEN isa(Animal,albatros) 

Assume there are the following facts in the working memory: has(jimmy,hair), has(jimmy,pointed_teeth), has(jimmy,claws), has(jimmy,forward_pointed_eyes), has(jimmy,black_stripes), has(jimmy,tawny_colour). Prove isa(jimmy,tiger) using backward chaining.


sol//

  hobbes is a tiger                animal is a tiger
          |
          |  R4       
          |
  hobbes has black stripes         animal has black stripes 
          |
          |  succeeds due to A1
          |
  hobbes is a carnivore            animal is a carnivore 
          |
          |  R3 
          |
  hobbes eats meat                 animal eats meat 
          |
          |  succeeds due to A2
          |
  hobbes is a mammal               animal is a mammal 
          |
          |  R1 
          |
  hobbes gives milk                animal gives milk 

Q-



sol//



تعليقات



حجم الخط
+
16
-
تباعد السطور
+
2
-