cs 440 midterms p 11 sol

11
CS440/ECE448: Introduction to Artificial Intelligence Midterm exam — Solutions Instructor: Prof. Julia Hockenmaier March 3, 2011 Your score Question Points Score Search 11 Propositional logic 10 First-order predicate logic 10 Constraint satisfaction 10 Agents, and planning 9 Total: 50 1

Upload: yigit

Post on 14-Dec-2015

6 views

Category:

Documents


1 download

DESCRIPTION

Test

TRANSCRIPT

Page 1: Cs 440 Midterms p 11 Sol

CS440/ECE448: Introduction to Artificial IntelligenceMidterm exam — Solutions

Instructor: Prof. Julia Hockenmaier

March 3, 2011

Your score

Question Points Score

Search 11

Propositional logic 10

First-order predicate logic 10

Constraint satisfaction 10

Agents, and planning 9

Total: 50

1

Page 2: Cs 440 Midterms p 11 Sol

Solutions

Part 1: Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . (11 points total)(a)[1 point] Assume you have been give the state space graph of a search problem, and you need to

define the corresponding search tree. How many nodes in the search tree correspond toone node in the state space graph?

Solution: As many as there are paths from the initial state to the node. An infinitenumber if there are loops.

(b)[2 points] Fill in the following table to list the steps in which DFS traverses the search tree given infigure 1 (bottom of page).

Step Node Queue0. A {B,C}1. B {D,E,C}2. D {G,H,E,C}3. G {H,E,C}4. H {E,C}5. E {C}

Solution:

(c)[2 points] Why is graph-search DFS complete (for problems with a finite set of states), but tree-search DFS is not?

Solution: Graph-search DFS does not get stuck in infinite loops becauseit keepstrack of visited nodes. So it will always terminate with failure or find a solutionwhenever one exists.

Figure 1: A search tree. The goal state is E.A

B

ED

G H

F

C

Page 2/11 CS440/ECE448 Midterm March 3, 2011

Page 3: Cs 440 Midterms p 11 Sol

Solutions

(d)[1 point] How do heuristic search techniques such as Uniform-Cost Search and A* search differfrom systematic search techniques such as DFS/BFS?

Solution: Heuristic search algorithms use a priority queue where items are sorted bycost. Systematic search algorithms use a deterministic queuing function.

(e)[1 point] How do the two heuristic search algorithms Uniform-Cost Search and A* search differfrom each other?

Solution: Uniform-cost considers only the cost to get from start to current state; A*also considers the estimated cost of getting to the goal state.

(f)[2 points] In the traveling salesman problem a list of cities(including one home city) and theirpairwise distances is given. The task is to find the shortest route that starts and ends inthe home city and visits all cities on the list exactly once.Our salesman travels by plane, and can fly directly between any two cities on this list.Flying distances obey the triangle inequality: flying from Ato B is always shorter than orequally long as flying from A to C and then from C to B.If we define the home city as unvisited until we get back to it, is the distance to the nearestunvisited city an admissible heuristic? Why?

Solution: Yes, because due to the triangle inequality it will never overestimate thetrue distance.

(g)[1 point] When does regular hill-climbing search fail to findthe optimal solution?

Solution: If it gets stuck in a local maximum

(h)[1 point] How does k-best hill climbing differ from random restart hill climbing?

Solution:

• k-best: maintain k searches in parallel (always pick k best next options acrossall k searches).

• random restart: k independent searches from random positions.

March 3, 2011 CS440/ECE448 Midterm Page 3/11

Page 4: Cs 440 Midterms p 11 Sol

Solutions

Part 2: Propositional logic . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . (10 points total)(a)[1 point] Is p∨¬p valid?

Solution: Yes.

(b)[1 point] In which models is¬p→ q valid?

Solution: In the models in whichp = trueand in the model wherep = falseandq =true

(c)[2 points] Show that¬[p∨¬(¬q∨¬r)] is logically equivalent to(p∨q) →¬(p∨ r).

¬[p∨¬(¬q∨¬r)] ≡ . . .

≡ . . .

≡ . . .

≡ . . .

≡ (p∨q)→¬(p∨ r)

Solution: for example:

¬[p∨¬(¬q∨¬r)] ≡ ¬p∧ (¬q∨¬r)

≡ (¬p∧¬q)∨ (¬p∧¬r)

≡ ¬(p∨q)∨ (¬p∧¬r)

≡ (p∨q) → (¬p∧¬r)

≡ (p∨q) →¬(p∨ r)

(d)[1 point] What is a literal in propositional logic?

Solution: A propositional variable (atomic formula), or the negationof a proposi-tional variable (atomic formula).

(e)[1 point] What is a clause in propositional logic?

Solution: A disjunction of literals

Page 4/11 CS440/ECE448 Midterm March 3, 2011

Page 5: Cs 440 Midterms p 11 Sol

Solutions

(f)[1 point] When is a formula in propositional logic in conjunctive normal form?

Solution: When it is a conjunction of clauses.

(g)[1 point] Define Modus Ponens in propositional logic.

Solution: p→ q pq

(h)[1 point] Show how resolution can be used to derive a contradiction betweenp and¬p.

Solution: p ¬p

/0

(i)[1 point] How can we prove thatα |= β using resolution?

Solution: Show thatα ∧¬β is not satisfiable/derives a contradiction.

March 3, 2011 CS440/ECE448 Midterm Page 5/11

Page 6: Cs 440 Midterms p 11 Sol

Solutions

Part 3: First-order predicate logic . . . . . . . . . . . . . . . . . . . .. . . . (10 points total)(a)[2 points] Translate into predicate logic:

A. “All birds that are not penguins fly”.

Solution: ∀x [bird(x)∧¬p(x)) → f ly(x)]or ∀x [bird(x) → [¬p(x)) → f ly(x)]]

B. “Every child has exactly two parents.”

Solution: ∀x∃y∃z[c(x) → (p(y,x)∧ p(z,x)∧z 6= y∧∀wp(w,x) → (w= y∨w = z))]∀x∃y∃z[c(x) → (p(y,x)∧ p(z,x)∧z 6= y∧ 6= ∃wp(w,x)∧ (w = y∨w = z))]

(b)[1 point] What is a interpretation of a unary function such asmotherOf(x)?

Solution: A function D → D from entities in the domain to other entities in the do-main.

(c)[1 point] When is the formula∀x student(x) true?

Solution: If all entities in the domain are in the set that is the interpretation of student.

(d)[1 point] When is the formulastudent(John′) true? (John′ is a constant)

Solution: If the entity that is the interpretation ofJohn is in the interpretation ofstudent.

Page 6/11 CS440/ECE448 Midterm March 3, 2011

Page 7: Cs 440 Midterms p 11 Sol

Solutions

(e)[1 point] Are the following formulas in prenex normal form?

A. ∀xP(x) →¬∃yQ(x,y).

B. ∀x¬∃P(x) → Q(x,y)

Solution: No, neither is in prenex NF.

(f)[2 points] Skolemize the following formulas:

A. ∀x∃y∀zP(x,y,z)

Solution: ∀x∀zP(x,S(x),z)

B. ∃y∀x∀zP(x,y,z)

Solution: ∀x∀zP(x,S,z)

(g)[2 points] Do the following sets of formulas unify? If they do, what is the most general unifier, andwhat is the resulting unification instance? If they don’t, give the reason. (Variables arewritten as lowercase letters, constants as uppercase letters).

A. P(x,y,y) andP( f (C),C,v)

Solution: MGU = x/ f (C),y/C,v/y (0.5), result:P( f (C),C,C) (0.5)

B. P(x, f (x)), P(x,y), P(g(u),u)

Solution: no, there is a loop.

March 3, 2011 CS440/ECE448 Midterm Page 7/11

Page 8: Cs 440 Midterms p 11 Sol

Solutions

Part 4: Constraint satisfaction . . . . . . . . . . . . . . . . . . . . . . .. . . . . (10 points total)(a)[1 point] How does a constraint graph express binary constraints?

Solution: nodes = variables; edges: binary constraints

(b)[1 point] How does a constraint hypergraph express global constraints?

Solution: One hyperedge for each global constraint.

(c)[1 point] What does it mean for node X to be arc-consistent with node Y?

Solution: For each value in the domain of X there has to be a value in the domain ofY such that the constraint between X and Y is obeyed.

(d)[1 point] What is a solution of a constraint-satisfaction problem?

Solution: A complete legal assignment (of values to variables).

(e)[1 point] When does a constraint-satisfaction problem fail?

Solution: When one variable has an empty domain.

Figure 2: In KenKen, the numbers in each set of cells (indiciated by a thicker border) have to becombined using an arithmetic operation (e.g.×) to yield a result (e.g. 6). The Latin Square on theright is a solution to the KenKen puzzle on the left.

1 2 3

3

3

2

2

1

1

3x3 Latin square 3x3 KenKen

3+3

x6 x6

Page 8/11 CS440/ECE448 Midterm March 3, 2011

Page 9: Cs 440 Midterms p 11 Sol

Solutions

(f)[1 point] A Latin square (see Figure 2) is ann×n table whose cells are filled with numbers from1 to n in such a way that each row and column of the table contains each number ex-actly once. How do you formalize the task of generating a Latin square as a constraintsatisfaction problem?

Solution: Variables = cells. Domains = numbers from 1 ton. Constraints: one all-Diff constraint for each row and column.

(g)[1 point] What is the constraint graph for the Latin square task?

Solution: nodes/variables = boxes; edges: no two boxes in the same cellor row canbe equal (alternative: binarized allDiff)

(h)[1 point] KenKen (see Figure 2) is a logic puzzle similar to Sudoku. The task is to find a Latinsquare for an emptyn×n table. The twist is that the cells of this table are partitionedinto sets (indicated by a thicker border) whose numbers haveto be combined by additionor multiplication to yield a prespecified result. What are the additional global constraintsthat KenKen introduces beyond the Latin square problem?

Solution: one global constraint for each box.

(i)[1 point] How can the arithmetic constraints in KenKen be expressed in a constrainthypergraph?(You do not have to draw a hypergraph).

Solution: One hyperedge for each arithmetic constraint

(j)[1 point] How can the arithmetic constraints in KenKen be expressed in a constraintgraph?

Solution: This requires the introduction of one auxiliary variable for each globalarithmetic constraint.

March 3, 2011 CS440/ECE448 Midterm Page 9/11

Page 10: Cs 440 Midterms p 11 Sol

Solutions

Part 5: Agents, and planning . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . (9 points total)(a)[2 points] Describe what it means for a task environment to be...

A. ... partially observable:

Solution: Thesensors don’t provide complete informationabout the en-vironment

B. ... non-deterministic:

Solution: The actions have a non-deterministic effecton the environ-ment.

C. ... dynamic

Solution: The environment can change on its own accord, even whenthe agent does not perform an action.

D. ... episodic:

Solution: The agent has toreact to a single percept(rather than a perceptsequence).

(b)[1 point] What is a fluent?

Solution: A predicate that can be true or false, depending on the situation/state

(c)[2 points] What does the definition of an operator (e.g.move(x,y,z)(move x from y to z) consist of?

Solution: Preconditions (a set of fluents that have to be true for the operator to beapplicable) and effects (a set of fluents that will be true after the operator has beenapplied).

(d)[1 point] What is the difference between an operator and a corresponding action?

Solution: The action is a ground instance of the operator (i.e.: all variables are re-placed by constants.)

Page 10/11 CS440/ECE448 Midterm March 3, 2011

Page 11: Cs 440 Midterms p 11 Sol

Solutions

(e)[1 point] What is the frame problem?

Solution: We need to know what remains true when we apply an action.

(f)[1 point] How do Situation Calculus and STRIPS differ in how they solve the frame problem?Which approach is better, and why?

Solution: Situation Calculus specifies which fluents remain the same, STRIPS spec-ifies which fluents change. It is better/easier/more efficient to specify which fluentschange, because typically fewer things change than remain the same.

(g)[1 point] The basic insight behind SATplan is that a plan of fixed lengthn can be translated into aformula of propositional logic. Why is this always the case in classical planning?

Solution: Because in classical planning we always deal with a finite domain (databasesemantics) as well as a finite number of operators and predicates, and thus have onlya finite number of possible actions and fluents.

March 3, 2011 CS440/ECE448 Midterm Page 11/11