Solved Problems on First Order Logic in Artificial Intelligence | CPSC 625, Assignments of Computer Science

Material Type: Assignment; Class: ARTIFICIAL INTELLIGNCE; Subject: COMPUTER SCIENCE; University: Texas A&M University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 02/10/2009

koofers-user-v4a
koofers-user-v4a 🇺🇸

9 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 625-600 Homework #2
SOLUTION
Total: 100 pts
Yoonsuck Choe
November 1, 2007
1 First-Order Logic
Important: In this section, assume that w, x, y, z are variables; A, B, C, D are constants; and f(·), g(·), h(·)
are functions; and P(·), Q(·), R(·)are predicates.
1.1 Standard Forms
To do automatic theorem proving in first-order logic, you need to go through three steps to convert your
initial first-order logic expression into a standard form. These are:
1. Prenex normal form,
2. Conjunctive normal form, and
3. Skolemization.
Question 1 (12 pts): Convert to prenex normal form (4 points each):
1. x¬(y P (x, y))
2. ¬∀x(¬P(x) ¬(y, Q(x, y)))
3. ¬∀x((y Q(x, y)) P(x))
SOLUTION:
1. x¬(y P (x, y))
x(¬∀y P (x, y))
x(y¬P(x, y))
xy¬P(x, y)
2. ¬∀x(¬P(x) ¬(y, Q(x, y)))
x(¬¬P(x) ¬¬(y, Q(x, y)))
x(P(x)(y, Q(x, y)))
xy(P(x)Q(x, y))
1
pf3
pf4
pf5

Partial preview of the text

Download Solved Problems on First Order Logic in Artificial Intelligence | CPSC 625 and more Assignments Computer Science in PDF only on Docsity!

CPSC 625-600 Homework

SOLUTION

Total: 100 pts

Yoonsuck Choe

November 1, 2007

1 First-Order Logic

Important: In this section, assume that w, x, y, z are variables; A, B, C, D are constants; and f (·), g(·), h(·) are functions; and P (·), Q(·), R(·) are predicates.

1.1 Standard Forms

To do automatic theorem proving in first-order logic, you need to go through three steps to convert your initial first-order logic expression into a standard form. These are:

  1. Prenex normal form,
  2. Conjunctive normal form, and
  3. Skolemization.

Question 1 (12 pts): Convert to prenex normal form (4 points each):

  1. ∀x ¬ (∀y P (x, y))
  2. ¬∀x (¬P (x) ∨ ¬(∃y, Q(x, y)))
  3. ¬∀x ((∃y Q(x, y)) → P (x))

SOLUTION:

  1. ∀x ¬ (∀y P (x, y)) ∀x (¬∀y P (x, y)) ∀x (∃y¬P (x, y)) ∀x∃y¬P (x, y)
  2. ¬∀x (¬P (x) ∨ ¬(∃y, Q(x, y))) ∃x (¬¬P (x) ∧ ¬¬(∃y, Q(x, y))) ∃x (P (x) ∧ (∃y, Q(x, y))) ∃x∃y (P (x) ∧ Q(x, y))
  1. ¬∀x ((∃y Q(x, y)) → P (x)) ∃x¬ (¬(∃y Q(x, y)) ∨ P (x)) ∃x (¬¬(∃y Q(x, y)) ∧ ¬P (x)) ∃x ((∃y Q(x, y)) ∧ ¬P (x)) ∃x∃y (Q(x, y) ∧ ¬P (x))

Question 2 (10 pts): Skolemize the expressions (2 points each):

  1. ∃xP (x)
  2. ∀x∃yP (x, y)
  3. ∃x∃y∀zP (x, y) ∧ Q(y, z)
  4. ∀x∃y∀zP (x, y) ∧ Q(y, z)
  5. ∀x∀y∃zP (x, y) ∧ Q(y, z)

SOLUTION:

1. P (A)

  1. P (x, f (x))
  2. P (A, B) ∧ Q(B, z)
  3. P (x, f (x)) ∧ Q(f (x), z)
  4. P (x, y) ∧ Q(y, f (x, y))

Question 3 (9 pts): Convert the following into a standard form:

∀x [P (x) → (∃yQ(x, y))]

SOLUTION: ∀x [¬P (x) ∨ (∃yQ(x, y))] ∀x∃y [¬P (x) ∨ Q(x, y)] ¬P (x) ∨ Q(x, f (x))

1.2 Substitution and Unification

Question 1 (9 pts): Apply the following substitutions to the expressions (3 point each);

  1. Apply {x/f (A)} to P (x, y) ∨ Q(x).
  2. Apply {x/A, y/f (z)} to P (x, y) ∨ Q(x).
  3. Apply {y/x)} to P (x, y) ∨ Q(x).

SOLUTION:

  1. P (f (A), y) ∨ Q(f (A))

B T^ T^ F^  F^ 

E T  F T  F

P(A) . . .

.

P(B) .

P(E)

Alarm



Earthquake

JohnCalls MaryCalls



Burglary

A P(J) T^ F  .90. A P(M) T^ F^  . .

.

Figure 1: Belief Network. See problem 1.

2 Uncertainty and Probabilistic Reasoning

Question 1 (14 pts): Given the Belief network as shown in figure 1, calculate the two joint probability values and answer the question. Note that in this section P (·) denotes the probability of the event. (7 points each):

  1. P (¬M aryCalls ∧ JohnCalls ∧ Alarm ∧ ¬Earthquake ∧ Burglary)
  2. P (¬M aryCalls ∧ JohnCalls ∧ ¬Alarm ∧ Earthquake ∧ ¬Burglary)

SOLUTION:

  1. P (¬M aryCalls ∧ JohnCalls ∧ Alarm ∧ ¬Earthquake ∧ Burglary) = P (¬M |A)P (J|A)P (A|¬E, B)P (¬E)P (B) = (1 − 0 .7) × 0. 9 × 0. 94 × (1 − 0 .002) × 0. 001
  2. P (¬M aryCalls ∧ JohnCalls ∧ ¬Alarm ∧ Earthquake ∧ ¬Burglary) = P (¬M |¬A)P (J|¬A)P (¬A|E, ¬B)P (E)P (¬B) = (1 − 0 .01) × 0. 05 × (1 − 0 .29) × 0. 002 × (1 − 0 .001)

3 Learning

3.1 Decision Tree Learning

Consider the following set of examples where you are trying to make a decision whether to buy a car or not, given three decision criteria (or attributes): Resale value, Dealer location, and Type.

Example# Resale value Dealer location Type Accept Job Offer? 1 High San Antonio SUV Y 2 High Houston Sedan Y 3 Low San Antonio SUV N 4 High Dallas SUV Y 5 Medium Dallas SUV N 6 Low Dallas Sedan N 7 Low Austin Sedan N 8 Low San Antonio SUV Y 9 Low Houston Sedan N 10 High Austin SUV Y 11 Medium San Antonio Sedan N 12 Low Dallas SUV Y

Question 1 (15 pts): For each of the three attributes above, draw a decision tree rooted at that attribute with a single depth. See slide06, page 12, (a) and (b) which shows an example. (5 points each)

SOLUTION:

  1. Resale High: (+: 1,2,4,10) (-: ) Medium: (+: ) (-: 5,11) Low: (+: 8,12) (-: 3,6,7,9)
  2. Location San Antonio: (+: 1, 8) (-: 3, 11) Houston: (+: 2) (-: 9) Dallas: (+: 4, 12) (-: 5, 6 ) Austin: (+: 10) (-: 7 )
  3. Type SUV: (+: 1, 4, 8, 10, 12) (-: 3, 5) Sedan: (+: 2) (-: 6, 7, 9, 11)

Question 2 (15 pts): Calculate the information gain for each of the three attributes and explain which attribute should be picked to be tested first. (5 points each)

SOLUTION:

  1. Define Ent(x, y) = −x log 2 x − y log 2 y. Ent(6/ 12 , 6 /12) − (4/ 12 Ent(4/ 4 , 0 /4) + 2/ 12 Ent(0/ 2 , 2 /2) + 6/ 12 Ent(2/ 6 , 4 /6) = 1 − 0 .46915 = 0. 54085
  2. Ent(6/ 12 , 6 /12) − (4/ 12 Ent(2/ 4 , 2 /4) + 2/ 12 Ent(1/ 2 , 1 /2) + 4/ 12 Ent(2/ 4 , 2 /4) + Ent(1/ 2 , 1 /2) = 1 − 1 = 0
  3. Ent(6/ 12 , 6 /12) − (7/ 12 Ent(5/ 7 , 2 /7) + 5/ 12 Ent(1/ 5 , 4 /5) = 1 − 0 .80429 = 0. 19571