disc03-regular-sols

pdf

School

Hong Kong Polytechnic University *

*We aren’t endorsed by this school

Course

273

Subject

Computer Science

Date

Nov 24, 2024

Type

pdf

Pages

2

Uploaded by lixun73230

Report
CS 188 Spring 2023 Regular Discussion 3 Solutions 1 Local Search 1. Give the name of the algorithm that results from each of the following special cases: (a) Local beam search with k = 1. Local beam search with k = 1 is hill-climbing search. (b) Local beam search with one initial state and no limit on the number of states retained. Local beam search with one initial state and no limit on the number of states retained, resembles breadth-first search in that it adds one complete layer of nodes before adding the next layer. Starting from one state, the algorithm would be essentially identical to breadth-first search except that each layer is generated all at once. (c) Simulated annealing with T = 0 at all times (and omitting the termination test). Simulated annealing with T = 0 at all times: ignoring the fact that the termination step would be triggered immediately, the search would be identical to first-choice hill climbing because every downward successor would be rejected with probability 1. (d) Simulated annealing with T = at all times. Simulated annealing with T = at all times is a random-walk search: it always accepts a new state. (e) Genetic algorithm with population size N = 1. Genetic algorithm with population size N = 1: if the population size is 1, then the two selected parents will be the same individual; crossover yields an exact copy of the individual; then there is a small chance of mutation. Thus, the algorithm executes a random walk in the space of individuals. 2. When might local search (i.e. hill climbing) be better than using A* search? When might it be worse? There are many possible answers. Many answers are possible here: local search helps to solve computationally difficult problems like TSP (shown below), local search can converge to a local optimum, but not global optimum. Another useful characteristic of local searches is that if something changes (e.g., a bridge is closed or a flight is cancelled), one can simply resume the search and get a good solution that is close to the current one. A* has to be restarted and may generate a quite different path. 1
Q2. Propositional Logic (a) Provide justification for whether each of the following are correct or incorrect. (i) ( X Y ) | = Y Incorrect: ( X Y ) | = Y if and only if ( X Y ) ∧ ¬ Y is unsatisfiable; however, the latter is satisfied by X = true and Y = false . (ii) ¬ X ( Y Z ) | = ( X = Y ) Correct: Via the same reasoning as the previous part, we can attempt to show that ( ¬ X ( Y Z )) ¬ ( X = Y ) is unsatisfiable as follows: ( ¬ X ( Y Z )) ∧ ¬ ( X = Y ) ( ¬ X ( Y Z )) ∧ ¬ ( ¬ X Y ) ( ¬ X ( Y Z )) ( X ∧ ¬ Y ) Its clear that for the RHS to evaluate to true, X = true and Y = false . However, setting that automatically makes the LHS evaluate to false. Thus, the whole thing is unsatisfiable, so the original must be correct. (iii) ( X Y ) ( Z ∨ ¬ Y ) | = ( X Z ) Correct: In general, A | = B if and only if A = B is valid. To show that this works for this problem, we can write it as an implication and prove by counterexample that the statement is always valid. Consider ( X Y ) ( Z ∨ ¬ Y ) = ( X Z ). In general, A = B only evaluates to false if A = true and B = false . In order for the RHS to evaluate to false, X = false and Z = false . Plugging those in, the LHS evaluates to ( false Y ) ( false ∨¬ Y ), which can never evaluate to true. Therefore, that case never holds, so the implication is valid. (b) Consider the following sentence: [( Food = Party ) ( Drinks = Party )] = [( Food Drinks ) = Party ] . (i) Determine, using enumeration, whether this sentence is valid, satisfiable (but not valid), or unsatis- fiable. A simple truth table has eight rows, and shows that the sentence is true for all models and hence valid. (ii) Convert the left-hand and right-hand sides of the main implication into CNF. For the left-hand side we have: ( Food = Party ) ( Drinks = Party ) ( ¬ Food Party ) ( ¬ Drinks Party ) ( ¬ Food Party ∨ ¬ Drinks Party ) ( ¬ Food ∨ ¬ Drinks Party ) For the right-hand side we have: ( Food Drinks ) = Party ¬ ( Food Drinks ) Party ( ¬ Food ∨ ¬ Drinks ) Party ( ¬ Food ∨ ¬ Drinks Party ) (iii) What do you observe about the LHS and RHS after converting to CNF? Explain how your results prove the answer to part b.i. The two sides are identical in CNF, and hence the original sentence is of the form P = P , which is valid for any P . 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help