8
Prepared by: TA. Latifa Alrashed 1 NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer rincess Nora Bint Abdulrahman University aculty of Computer and Information Sciences Department of Networks and Telecommunications Question 1: Using the symbols Has, Loves, Dog, and Cat for the predicates “has”, “loves”, ”is a dog”, and “is a cat” respectively, write the following sentences in predicate logic: a. John has a cat. [() (, )] b. John loves all cats. [() (, )] c. John loves Anne. (, ) d. Anne loves some dogs. [ (, )] e. Not everything John loves is a cat. [ , ¬()] Or ¬ [(, ) ()] f. Anne does not like some cats. [() ¬ (, ) ] g. If John loves a cat, Anne loves it. [ , , ] h. John loves a cat if and only if Anne loves it. [ , , ] i. If John doesn’t like a cat, Anne loves it. [ ¬ , , ] Question 2: write the following sentences in predicate logic: 1. All mammals have hair. [() (, )] 2. All rational numbers are natural numbers. [() ()] 3. There exists a MATH 218 student who has tried out for American Idol. [ (, )] 4. There exists a real number whose square is not positive. [ ( , ¬ )]

Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

  • Upload
    vutuyen

  • View
    228

  • Download
    8

Embed Size (px)

Citation preview

Page 1: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

1  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

Question 1: Using the symbols Has, Loves, Dog, and Cat for the predicates “has”, “loves”, ”is a dog”, and “is a cat” respectively, write the following sentences in predicate logic:

a. John has a cat. ∃𝒙  [𝑪𝒂𝒕(𝒙) ∧𝑯𝒂𝒔(𝑱𝒐𝒉𝒏,𝒙)]

b. John loves all cats. ∀𝒙  [𝑪𝒂𝒕(𝒙) → 𝑳𝒐𝒗𝒆𝒔(𝑱𝒐𝒉𝒏,𝒙)]

c. John loves Anne. 𝑳𝒐𝒗𝒆𝒔(𝑱𝒐𝒉𝒏,𝑨𝒏𝒏𝒆)

d. Anne loves some dogs. ∃𝒙  [𝑫𝒐𝒈 𝒙  ∧  𝑳𝒐𝒗𝒆𝒔(𝑨𝒏𝒏𝒆,𝒙)]

e. Not everything John loves is a cat. ∃𝒙  [𝑳𝒐𝒗𝒆𝒔 𝑱𝒐𝒉𝒏,𝒙  ∧  ¬𝑪𝒂𝒕(𝒙)]

Or  ¬∀𝒙  [𝑳𝒐𝒗𝒆𝒔(𝑱𝒐𝒉𝒏,𝒙) → 𝒄𝒂𝒕(𝒙)]

f. Anne does not like some cats.

∃𝒙  [𝑪𝒂𝒕(𝒙)  ∧ ¬  𝐋𝐨𝐯𝐞𝐬(𝐀𝐧𝐧𝐞, 𝐱)  ] g. If John loves a cat, Anne loves it.

∀𝒙  [ 𝑪𝒂𝒕 𝒙 ∧ 𝐋𝐨𝐯𝐞𝐬 𝐉𝐨𝐡𝐧, 𝐱 → 𝑳𝒐𝒗𝒆𝒔 𝑨𝒏𝒏𝒆,𝒙 ] h. John loves a cat if and only if Anne loves it.

∀𝒙  [ 𝑪𝒂𝒕 𝒙 ∧ 𝐋𝐨𝐯𝐞𝐬 𝐉𝐨𝐡𝐧, 𝐱 ↔ 𝑳𝒐𝒗𝒆𝒔 𝑨𝒏𝒏𝒆,𝒙 ] i. If John doesn’t like a cat, Anne loves it.

∀𝒙  [ 𝑪𝒂𝒕 𝒙 ∧ ¬  𝐋𝐨𝐯𝐞𝐬 𝐉𝐨𝐡𝐧, 𝐱 → 𝑳𝒐𝒗𝒆𝒔 𝑨𝒏𝒏𝒆,𝒙 ]

Question 2: write the following sentences in predicate logic:

1. All mammals have hair.

∀𝒙  [𝑴𝒂𝒎𝒎𝒂𝒍(𝒙) → 𝑯𝒂𝒔(𝒙,𝒉𝒂𝒊𝒓)]

2. All rational numbers are natural numbers.

∀𝒙  [𝒓𝒂𝒕𝒊𝒐𝒏𝒂𝒍(𝒙) → 𝒏𝒂𝒕𝒖𝒓𝒂𝒍(𝒙)]

3. There exists a MATH 218 student who has tried out for American Idol.

∃𝒙  [𝒔𝒕𝒖𝒅𝒆𝒏𝒕 𝒙  ∧  𝑻𝒓𝒚(𝒙,𝑨𝒎𝒆𝒓𝒊𝒄𝒂𝒏  𝑰𝒅𝒐𝒍)]

4. There exists a real number whose square is not positive.

∃𝒙  [𝒓𝒆𝒂𝒍 𝒙 ∧ 𝒔𝒒𝒖𝒂𝒓𝒆  (𝒙  ,¬  𝒑𝒐𝒔𝒊𝒕𝒊𝒗𝒆 𝒙  )]

Page 2: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

2  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

5. Every person in New Britain has seen a movie starring William Shatner.

∀𝒙  [𝑩𝒓𝒊𝒕𝒊𝒔𝒉𝑷𝒆𝒓𝒔𝒐𝒏 𝒙 → 𝒔𝒆𝒆(𝒙, 𝒔𝒂𝒓𝒓𝒊𝒏𝒈(𝑾𝒊𝒍𝒍𝒊𝒂𝒎  𝑺𝒉𝒂𝒕𝒏𝒆𝒓,𝒎𝒐𝒗𝒊𝒆)]

 Question 3: Let P(x), Q(x), and R(x) be the following predicates, all with domain (set) {students in this 218 class}.

P(x): x was born in the United States.

Q(x): x speaks more than one language.

R(x): x has a passport.

Translate the following into fluid English sentences that demonstrate understanding:

1. ∀x[Q(x) ∨ ¬R(x)]

For all students in this 218 class speak more than one language or don’t have a

passport

2. ∃x[¬P(x) ∧ (Q(x) ∨ R(x))]

There  is  a  student  in  this  218  class  who  wasn’t  born  in  the  United States and either

speaks more than one language or has a passport.

3. ∀x(R(x) → (P(x) ∧ Q(x)).

For   all   students   in   this   218   class  who  have   a   passport  were   born   in   the  United

States and speak more than one language.

Now translate the following statements into quantifier form:

1. “There is a student in this 218 class who wasn’t born in the U.S. and speaks more

than one language, but doesn’t have a passport.”

∃x [¬P(x) ∧ (Q(x) ∧ ¬R(x))]

2. “No one in this 218 class was both born abroad and speaks more than one

language.”

¬∃x [¬P(x) ∧ Q(x)]

Page 3: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

3  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

3. “No one in this 218 class who was born abroad speaks more than one language.”

∀x [¬P(x) → ¬Q(x)]

Question 4: By using the Breadth First Search technique. Find the node (L) from the following graph. (Note: consider the DOUBLE-LINED arrows and ignore the SINGLE-LINED arrows)

1. Convert the following graph into a tree (consider node (A) to be the root).

2. Determine the required path to find node (L).

Page 4: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

4  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

1. Convert the following graph into a tree (consider node (A) to be the root).

A

B F

D M

N

O

P Q

E

H

I G

L

K

J

C

Page 5: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

5  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

2. Determine the required path to find node (L).

Question 5: By using the Depth First Search technique. Find the node (L) from the graph below. (Note: consider the DOUBLE-LINED arrows and ignore the SINGLE-LINED arrows)

1. Use the tree that you already have drawn.

2. Determine the required path to find node (L).

A

B F

D M

N

O

P Q

E

H

I G

L

K

J

C

 

Page 6: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

6  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

 

Question 6: Apply the two previous searching techniques (BFS) and (DFS) to find node (P) and determine the path and number of movements for each.

a. BFS Path to find node ( P )

A

B F

D M

N

O

P Q

E

H

I G

L

K

J

C The  search  path  AFC  comes  to  a  dead  end,  so  we  backtrack  to  A  and  continue  the  search  along  the  path  ABMEHGL,  which  comes  to  a  goal    

The  path  to  find  node  (L)  using  the  DFS  technique:    

A  B  M  E  H  G  L  

 

Page 7: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

7  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

A

B F

D M

N

O

P Q

E

H

I G

L

K

J

C

The  path  to  find  node  (P)  using  the  BFS  technique:    

A  F  B  C  M  D  E  N  H  O  G  I  Q  P  

 

Page 8: Assignment#5 Model Answer - WordPress.com · Assignment 5 - Artificial Intelligence lecture Model answer Princess Nora Bint Abdulrahman University Faculty of Computer and Information

       

Prepared  by:  TA.  Latifa  Alrashed    

8  

NET201- Principles of Information & Technology Systems First Semester 1435/1436 H Assignment 5 - Artificial Intelligence lecture Model answer

Princess Nora Bint Abdulrahman University Faculty of Computer and Information Sciences Department of Networks and Telecommunications

b. DFS Path to find node ( P )

 

A

B F

D M

N

O

P Q

E

H

I G

L

K

J

C

The  search  path  AFC  comes  to  a  dead  end,  so  we  backtrack  to  A  and  continue  the  search  along  the  path  ABMEHGLkJ,  which  also  comes  to  a  dead  end.  

Backtracking  to  node  H  and  search  along  the  path  ABMEHI,  results  in  another  dead  end.  

Backtracking  to  node  B  and  search  along  the  path  ABDNOQ,  results  in  another  dead  end.  

Backtracking  to  node  O  and  search  along  the  path  ABDNOP,  we  hit  the  goal    

The  path  to  find  node  (E)  using  the  DFS  technique:    

A  B  D  N  O  P