A farmer needs to transport a lion, fox, goose, and corn across a river using a boat that can only carry himself and one other item/passenger per trip. The problem is modeled as a search problem to find the sequence of trips needed to transport everything safely without the lion eating the goose or fox eating the corn. Operators represent possible trips using the boat and the search space includes all configurations of items on the left and right banks of the river.
A farmer needs to transport a lion, fox, goose, and corn across a river using a boat that can only carry himself and one other item/passenger per trip. The problem is modeled as a search problem to find the sequence of trips needed to transport everything safely without the lion eating the goose or fox eating the corn. Operators represent possible trips using the boat and the search space includes all configurations of items on the left and right banks of the river.
A farmer needs to transport a lion, fox, goose, and corn across a river using a boat that can only carry himself and one other item/passenger per trip. The problem is modeled as a search problem to find the sequence of trips needed to transport everything safely without the lion eating the goose or fox eating the corn. Operators represent possible trips using the boat and the search space includes all configurations of items on the left and right banks of the river.
boat, but the farmer can only take one passenger in addition to himself on each trip, or else both the goose and the corn, or both the fox .
A -What is the search space?
All [<left-bank>,<right-bank>], where <leftbank> and <right-bank> are lists together containing the symbols man, lion, fox, goose, corn, and boat. And <left-bank> is things on the left side of the river,<right-bank> things on the right. B - Give the starting and ending states. The start is[[man,lion,fox,goose,corn,boat],[]] and goal is [[], [man,lion,fox,goose,corn,boat]]. C - Give the operators. Man and boat; man, lion, and boat; man, fox, and boat; man, goose, and boat; man, corn, and boat; man, fox, corn, and boat; or man, goose, corn, and boat move from one side of the river to the other. D - Draw the first two levels of the search graph. Thats two besides the starting state. The starting state has only one successor, [[lion,goose],[man,fox,corn,boat]], which has three successors of its own (besides the
Suppose for a search problem there are
three operators Op1, Op2, and Op3. Suppose in the starting state you can apply any of the three. Then suppose if the first operator was not Op3 you can apply a different operator for the second action than the first operator. Assume no other operator applications are possible. No goal is given, so a search must eventually explore every possible state. (a)Suppose you do breadth-first search using the heuristic that Op1 branches are preferred to Op2 branches, and Op2 to Op3. Draw the state diagram, and label the states in the order in which you try to find their successors. Use labels a, b, c, d, e, f, g, and h.
(b)Suppose you do best-first search for which
the evaluation function is 6 after Op1 then Op2 4 after Op1 then Op3 9 after Op2 then Op1 11 after Op2 then Op3 8 after Op1 7 after Op2 5 after Op3 10 for the starting state List the states in the order in which you try to find their successors. Choose the state (among those so far discovered at some point in the problem) that has lowest evaluation function value. State sequence: a, d, c, b, f, e, g, h. (c)Suppose you do A* search for which the evaluation function in part (b) and the cost function is 2 for Op1 5 for Op2 9 for Op3 List the states in the order in which you try to find their successors. Add the cost to reach a state to the evaluation function. Costs to states: a: 0, b: 2, c: 5, d: 9,
Suppose state a is the starting state, and
states shown are the only possible states (and none of the states shown is the goal). Numbers written next the states represent the evaluation function at those states, and numbers written next to branches represent the cost function on those branches. (Some of this information may be irrelevant.) (a) Which is the fourth state whose successors are attempted to be found by a depth-first search using the heuristic that states whose names are vowels (a, e, i, o, or u) are preferred to states whose names are not? (b) Which is the fourth state whose successors are attempted to be found by a best-first search? b (c) Suppose you do A* search. List the states in the order in which you try to find their successors. b
Here is the append predicate definition:
append([ ], L, L). append([X|L1], L2, [X|L3]) :- append(L1, L2, L3). (a) Rewrite the definition so it fails when the first argument is empty, but otherwise behaves the same as before. Do not use fail or any built-in Prolog predicates. solution append([X], L, [X|L]). append([X|L1], L2, [X|L3]) :- append(L1, L2, L3). (b) Rewrite the original definition so it fails when the first-argument list contains negative numbers, but otherwise behaves the same as originally. Assume the first argument is always bound, and always is a list of numbers. Do not use fail or any built-in Prolog predicates expect for >= (greater-than-or-equal-to). solution append([ ], L, L). append([X|L1], L2, [X|L3]) :- X >= 0, append(L1, L2, L3). (c)Consider this slightly different definition: append(L, [ ], L). append(L1, [X|L2], [X|L3]) :- append(L1, L2, L3). Suppose this is the only thing in the Prolog database, and you query: ?- append([a, b, c], [d, e, f, g, h, i, j, k, l, m, n, o], A).
Suppose part_of(X, Y) means X is part of Y, and
owns(X, Y) means X owns Y. Define a Prolog predicate interesting of two arguments, which is true if the first argument owns something which is part of something which itself is part of the second arguments. Solution interesting(X, Y) :- owns(X, Y), part_(Z, W), part_of(W, Y). Consider the Prolog query: ?- a(X, Y) , b(X, Y). Assume the Prolog database: a(1, 1). a(2, 1). a(3, 2). a(4, 4). b(1, 2). b(1, 3). b(2, 3). b(3, 2). b(4, 4). Draw a zigzag diagram to show what happens in backtracking to find the first answer to this query. Write out successful matches; write fails when no more matches are possible. Do not write unsuccessful matches.
Consider the Prolog database:
p(4, 2). p(3, 3). p(4, 4). And consider this Prolog query: ?- p(X, X), p(X, Y), p(Y, Z). Draw a Zigzag diagram showing all bindings, successes, and failures that happen in Prolog-interpreter backtracking to get all answers to the query and then get a "no" answer.
Translate these sentences in English after
defining appropriate predicate symbols. (a) Not all birds can fly. (b) No politician is honest. (c) Everyone loves somebody and no one loves everybody, or somebody loves everybody and someone loves nobody. (d) There is only one god. (e) All fish except sharks are kind to children. solution