Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip 7.6-7.7)

Similar presentations


Presentation on theme: "Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip 7.6-7.7)"— Presentation transcript:

1 Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip 7.6-7.7)

2 Rutgers CS440, Fall 2003 Logic for knowledge representation Important problem: knowledge representation = solving the problems of –How to represent knowledge about problem domain –How to reason using this knowledge in order to answer queries or make decisions Knowledge-based agents –Have knowledge representation in a formal language –Can reason about world using inference in the language –Can decide what action to take by inferring that the action is good Declarative agents –Declare to agents facts about world –Pose questions to get answers

3 Rutgers CS440, Fall 2003 Declarative knowledge-based agents

4 Rutgers CS440, Fall 2003 Wumpus world Performance measure Gold +1000, death –1000, step –1, arrow –10 Environment - squares adjacent to wumpus are smelly - squares adjacent to pits are breezy - glitter iff gold is in the same square - shooting kills wumpus if you are facing it - shooting uses up the only arrow - grabbing picks up gold if in the same square - releasing drops the gold in same square Sensors Breeze, glitter, smell Actuators Left, right turn, forward, grab, release, shoot

5 Rutgers CS440, Fall 2003 Wumpus world characterization Observable –No – only local perception Deterministic –Yes – outcomes explicite Episodic –No – sequential actions Discrete –Yes Single-agent –Yes

6 Rutgers CS440, Fall 2003 Exploring wumpus world A ok

7 Rutgers CS440, Fall 2003 Exploring wumpus world B A ok P?

8 Rutgers CS440, Fall 2003 Exploring wumpus world B A ok P?

9 Rutgers CS440, Fall 2003 Exploring wumpus world B S A ok P? W?

10 Rutgers CS440, Fall 2003 Exploring wumpus world B S A ok P? W? ok P W How can we make these inferences automatically?

11 Rutgers CS440, Fall 2003 Logic Logic is a formal language for representing information such that conclusions can be drawn A logic includes –Syntax: specifies symbols in the language and how they can be combined to form sentences –Semantics: specifies what facts in the world a semantics refers to. Assigns truth values to sentences based on their meaning in the world. –Inference procedure: mechanical method for computing (deriving) new (true) sentences from existing sentences entails Sentences Facts Representation: World: semantics follows

12 Rutgers CS440, Fall 2003 Example Language of arithmetic –4x+y > 0 is a sentence, 4x<y0 is not –4x+y > 0 is true iff number 4x+y is greater than zero –4x+y > 0 is true in a world where x=0, y = 1 –4x+y > 0 is false in a world where x=0, y = 0 Hence, to build a logic-based representation: 1.Define a set of primitive symbols and the associated semantics 2.Logic defines the ways of putting there symbols together in order to represent true facts about world 3.Logic defines ways of inferring new sentences from existing ones

13 Rutgers CS440, Fall 2003 Propositional (Boolean) logic Simple language (but useful for key ideas and definitions) Language syntax –Atoms/Symbols: P 12, B 11, W 33,, IS_HOT, IS_BREEZY, , … User defines meaning of symbols. –Connectives:  (and),  (or),  (implies),  (iff),  (not) –Sentences or Well-formed-formulae (wff): 1.A symbol is a sentence 2.If S is a sentence,  S (negation) is a sentence 3.If S and T are sentences, S  T (conjunction), S  T (disjunction), S  T (implication), S  T (equivalence) are sentences 4.A finite number of applications of (1)-(3) is a sentence

14 Rutgers CS440, Fall 2003 Symbols & Sentences of Wumpus world P ij is “pit in (i,j)” B ij is “breeze in (i,j)” W ij is “wumpus in (i,j)”  B 11 “Pits cause breezes in adjacent squares” –B 11  ( P 12  P 21 ) –B 12  ( P 11  P 22  P 13 ) –…–…

15 Rutgers CS440, Fall 2003 Semantics Association of elements of logical language (atoms & sentences) with real world Propositional logic = associate atoms with propositions E.g., –P 12 is associated with “pit is in cell (1,2)” –B 11 is associated with “breeze is felt in cell (1,1)” –W 33 is associated with “wumpus is in (3,3)” –IS_HOT is associated with “I am taking cs440” Association of atoms with propositions = interpretation If atom  has value TRUE (1), then its interpretation P is true in the world; otherwise  has value FALSE (0) E.g., P 12 = 1 means “pit is in cell (1,2) is true”

16 Rutgers CS440, Fall 2003 Propositional truth tables Used to compute values of any sentence, given values of atoms Establishes meaning of propositional connectives AB AAABABABABABABABAB 0010011 0111010 1001000 1101111 The basic truth table can be used to evaluate any sentence by applying the rules recursively  A  ( A  B ) =  0  ( 0  1 ) = 1  ( 0  1 ) = 1  1 = 1

17 Rutgers CS440, Fall 2003 Models A model is an interpretation of a set of sentences such that each sentence is True:  is a model of a sentence S if S is true in  ( an interpretation of S satisfies  ) A mathematical structure that represents the (problem in) real world. Some other notions: –Unsatisfiable: there is no interpretation that satisfies S

18 Rutgers CS440, Fall 2003 Models of Wumpus world Situation after detecting nothing in (1,1), moving up, breeze in (2,1) What are the possible models for P?, assuming only pits? P 12, P 22, P 31  {0,1} 8 possible models B A P?

19 Rutgers CS440, Fall 2003 Models of Wumpus world P B A B A P B A P B A P P B A P P P B A P P B A P P B A Are these the models of Wumpus world?

20 Rutgers CS440, Fall 2003 Wumpus Knowledge Base (KB) KB = { S 1, S 2, …, S N } – set of all sentences describing our current knowledge of the world, where each sentence is in propositional logic Wumpus world KB S 1 :  B 11 S 2 : B 21 S 3 : B 11  ( P 12  P 21 ) S 4 : B 21  ( P 11  P 22  P 31 ) S 5 :  P 11 Remember, models are interpretations where all S i are true How to find models?

21 Rutgers CS440, Fall 2003 Model checking: Enumeration of symbols in sentences Check for valid models by enumerating all possible symbols interpretations: KB = S 1  S 2  S 3  S 4  S 5 B 11 B 21 P 11 P 12 P 21 P 22 P 31 S1S1 S2S2 S3S3 S4S4 S5S5 KB 0000000101110 0000001101010 ………… 0100000111010 0100001111111 0100010111111 0100011111111 0100100110010 ………… 1111111011100

22 Rutgers CS440, Fall 2003 Model checking: Enumeration of symbols in sentences Models are shown in red! How many enumerations? 2 7 B 11 B 21 P 11 P 12 P 21 P 22 P 31 S1S1 S2S2 S3S3 S4S4 S5S5 KB 0000000101110 0000001101010 ………… 0100000111010 0100001111111 0100010111111 0100011111111 0100100110010 ………… 1111111011100

23 Rutgers CS440, Fall 2003 Models of Wumpus world Rows of the truth table where the last column (KB) is true (I.e., all sentences are true) P B A B A P B A P B A P P B A P P P B A P P B A P P B A KB

24 Rutgers CS440, Fall 2003 Inference & entailment Given KB, what else can we conclude about the world? E.g., does a goal (a.k.a. query, conclusion, theorem) sentence G follow from KB? Note: we do not know semantics. Hence: we have to determine if all models of KB are models of G. I.e., KB entails G, ( KB |= G ) iff G is true whenever KB is true KB |= G iff KB  G is valid (A sentence is valid iff it is true under all possible interpretations) KB |= G iff KB   G is unsatisfiable

25 Rutgers CS440, Fall 2003 Wumpus world entailment G = “(1,2) is safe” Does KB |= G ? P B A B A P B A P B A P P B A P P P B A P P B A P P B A KB G YES! M(KB)  M(G)

26 Rutgers CS440, Fall 2003 Wumpus world entailment (II) G:  P 12 Column KB  G is all 1, hence it is valid. Thus, KB |= G. Conclusion G follows from KB no matter what the interpretations B 11 B 21 P 11 P 12 P 21 P 22 P 31 S1S1 S2S2 S3S3 S4S4 S5S5 KBG KB  G 000000010111011 000000110101011 …………… 010000011101011 010000111111111 010001011111111 010001111111111 010010011001011 …………… 111111101110001

27 Rutgers CS440, Fall 2003 Inference by enumeration properties The truth table method of inference is complete for Propositional Logic because we can always enumerate all 2 N rows for the N propositional symbols that occur. But this is exponential in N. In general, it has been shown that the problem of checking if a set of sentences in PL is satisfiable is NP-complete. Can be implemented using which search procedure? –Depth-first search. (The truth table method of inference is not complete for First- Order Logic.)

28 Rutgers CS440, Fall 2003 Inference procedures Inference methods 1.Model checking –Enumeration (seen previously) –Improved backtracking & local search 2.Inference using sound rules of inference Derive new sentences that are true in all cases where premises are true. E.g., ( P = 1 and P  Q = 1 )  Q = 1 Construct a proof that a given sentence G can be derived from KB using a sequence of inference rules Rules R are sound if, for a KB and sentence G, KB |- G under rules R implies KB |= G If when KB |= G there exists a proof of G from KB using R, then the R is complete If R is sound and complete we can prove entailment by searching for a proof

29 Rutgers CS440, Fall 2003 (Some) Sound rules of inference NamePremise(s)Derived sentence Modus ponens (mode that affirms) A, A  B B And introductionsA, B ABAB And elimination ABAB A Double negations  A A A Unit resolutions A  B,  B A Resolution A  B,  B  CA  C Equivalence elimination ABAB(A  B)  (B  A)

30 Rutgers CS440, Fall 2003 Using SRI in Wumpus world 1.S 1 :  B 11 S 2 : B 21 S 3 : B 11  ( P 12  P 21 )KB S 4 : B 21  ( P 11  P 22  P 31 ) S 5 :  P 11 2.S 6 : (B 11  (P 12  P 21 ))  ( P 12  P 21 )  B 11 ) S3 & equivalence elimin. 3.S 7 : (P 12  P 21 )  B 11 S6 & and elimination 4.S 8 :  B 11   ( P 12  P 21 ) S7 & negation 5.S 9 :  ( P 12  P 21 ) S1, S8, & modus ponens 6.S 10 :  P 12   P 21 S9 & DeMorgan Monotonicity property: adding new sentences to a KB does not change entailment ( KB |= G  KB  S |= G ). It can only lead to new conclusions.

31 Rutgers CS440, Fall 2003 Inference using Resolution A single rule sufficient for complete inference procedure, when coupled with a complete search algorithm ( A  B,  A) leads to B ( A  B,  A  C) leads to B  C

32 Rutgers CS440, Fall 2003 Resolution in Wumpus world Continue from previous example by moving A into (1,2) and not feeling breeze 1.S 1 :  B 11, S 2 : B 21, S 3 : B 11  ( P 12  P 21 ), S 4 : B 21  ( P 11  P 22  P 31 ), S 5 :  P 11 KB 2.S 10 :  P 12   P 21 previously inferred 3.S 11 :  B 12 percept 4.S 12 : B 12  ( P 11  P 22  P 13 )rule 5.S 13 :  P 22 S11 & S12 & equiv. elim., add elim, modus ponens 6.S 14 :  P 13 7.S 15 : P 11  P 22  P 31 S4 & S2 & equiv. elim. & modus ponens 8.S 16 : P 11  P 31 S15, S13 & resolution 9.S 17 : P 31 S16, S5 & resolution

33 Rutgers CS440, Fall 2003 Resolution algorithm & CNF How to effectively use resolution? It only applies to disjunctions of symbols. CNF: conjunctive normal forms –Every KB can be represented as a CNF –Every sentence can be represented as a conjunction of disjunctions of literals Method: 1.Eliminate equivalences (conjunction of implications) 2.Eliminate implications (disjunctions of negation & symbols/sent) 3.Propagate negations to literals (DeMorgan) 4.Done!

34 Rutgers CS440, Fall 2003 CNF in Wumpus world 1.S 3 : B 11  ( P 12  P 21 ) 2.( B 11  ( P 12  P 21 ) )  ( ( P 12  P 21 )  B 11 ) 3.(  B 11  ( P 12  P 21 ) )  (  ( P 12  P 21 )  B 11 ) 4.(  B 11  P 12  P 21 )  ( (  P 12   P 21 )  B 11 ) 5.(  B 11  P 12  P 21 )  (  P 12  B 11 )  (  P 21  B 11 ) 6.:CNF

35 Rutgers CS440, Fall 2003 Resolution refutation algorithm Relies on proof by contradiction (refutation): Assume goal sentence is false, prove KB does not hold. Remember, KB |= G iff KB   G is unsatisfiable, i.e., KB   G = {} Algorithm: 1.Convert all sentences in KB to CNFs 2.Resolve all pairs of CNFs into new clauses 3.Check for contradiction –Resolution refutation is complete

36 Rutgers CS440, Fall 2003 Resolution refutation in Wumpus world KB G

37 Rutgers CS440, Fall 2003 Special case: Horn clauses and forward- backward chaining Restricted set of clauses: Horn clauses disjunction of literals where at most one is positive, e.g.,  A   B  C or  A   B Why Horn clauses? –Every Horn clause can be written as an implication, e.g.,  A   B  C =  ( A  B )  C = ( A  B )  C  A   B =  ( A  B ) = ( A  B )  0(integrity constraint) –Inference in Horn clauses can be done using forward-backward (F-B) chaining in linear time

38 Rutgers CS440, Fall 2003 Example of FC

39 Rutgers CS440, Fall 2003 How good is PL as a representational language? Not very expressive –Cannot express complex environments concisely –E.g., need to write separate rules for every square in Wumpus world even though they do not change from square to square B ij  ( P i,j-1  P i,j+1  P i-1,j  P i+1,j ), for all (i,j) –E.g., to specify there is exactly one wumpus in the world, need to specify There is at least one: ? There is at most one: ?

40 Rutgers CS440, Fall 2003 Announcement New assignment type: mini project-presentations Prepared by a team of two students Related to a topic discussed in class Presented in class, 15-20 mins Will be graded, 15% of total grade (new grade distribution: final 30%, midterm 30%, hw 25%, presentation 15%) First presentation: Oct 15, Bayesian network software Prepare slides and handouts (web page, pdf file is ok) for the class


Download ppt "Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip 7.6-7.7)"

Similar presentations


Ads by Google