answers to russell and norvig question 7.3

Post on 11-Jul-2016

384 Views

Category:

Documents

20 Downloads

Preview:

Click to see full reader

DESCRIPTION

Answers to question 7.3 of the book "Intelligence: A Modern Approach"

TRANSCRIPT

Intelligent Systems

Group 3: Question 7.3

7.3a) Write a recursive algorithm PL-TRUE?(s,m) that returns true if and only if the sentence

s is true in the model m (where m assigns a truth value for every symbol in s). The algorithm

should run in time linear in the size of the sentence. Assumptions: • The sentence s is made unambiguous by the use of parentheses.• For brevity, we only include the symbols ∧, ∨, and ¬• We use m[a] to denote the true/false value of a in model mfunction PL-TRUE?(s, m) returns true or false:1) Let LHS = ‘’, RHS=‘’, logic_operator = ‘’2) Scan s from left to right, looking for a ¬, left parenthesis, or symbol. 3) If symbol found, LHS = symbol, and goto line 114) If ¬ found, logic_operator = ¬. Goto line 2.5) If left parenthesis found:6) Let n = 17) While n > 0:8) LHS += next character9) if next character == right parenthesis: n = n -110) if next character == left parenthesis: n = n +111) If logic_operator == ‘’, logic_operator = next character.12) Repeat lines 3 - 11, replacing LHS with RHS13) If LHS or RHS is not a symbol, LHS = PL_TRUE?(LHS, m), RHS = PL_TRUE?(RHS, m) as needed14) If logic_operator == ¬:15) return true if LHS is false, false otherwise.16) else If logic_operator == ∧:17) return true if LHS and RHS are both true, false otherwise18) else If logic_operator == ∨:19) return true if either LHS or RHS are equal to true, false otherwise

7.3b) Give three examples of sentences that can be determined to be true or false in

a partial model that does not specify a truth value for some of the symbols.

• true• false• A ∨ true

7.3c) Show that the truth value (if any) of a sentence in a partial model cannot be

determined efficiently in general.

• Let k be the number of symbols in s that do not appear in the partial model m.

• Some sentences are always true or always false, no matter the truth-table assignment of the symbols in the sentence.

• The only way to be sure is to evaluate the 2k rows of the truth table one-by-one, waiting to see one true and one false evaluation, to determine if the sentence has indeterminate truth value.

• However, due to the existence of always true and always false sentences, it is in the worst case a O(2k) operation determining the truth value of a sentence.

7.3c) Modify your PL-TRUE? algorithm so that it can sometimes judge truth from

partial models, while retaining its recursive structure and linear run time. Give three

examples of sentences whose truth in a partial model is not detected by your algorithm. • The modification occurs when evaluating ∧, ∨

logical operations• In line 13,(If LHS or RHS is not a symbol, LHS = PL_TRUE?(LHS, m), RHS = PL_TRUE?(RHS, m) as needed)the LHS and RHS come back as variables, or sentences containing symbols not included in the partial model. • When evaluating ∨, if either the LHS or RHS

are true values, PL-TRUE? can return true• When evaluating ∧, if either of LHS or RHS

values are false, PL-TRUE? can return false• Example of sentences modified PL-TRUE?

cannot determine as true or false, if Q is not defined in the model

Q ∨ ¬QQ ∧ ¬Q¬Q

7.3c) Investigate whether the modified algorithm makes TT-ENTAILS? more efficient.

Yes, because in many cases involving the ∧ and ∨ operators, the value of the truth assignment can be returned without needing to evaluate both sides of the operator. This may further mean that there is no need to recurse.

top related