Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.sti-innsbruck.at © Copyright 2008 STI INNSBRUCK www.sti-innsbruck.at Intelligent Systems Propositional Logic.

Similar presentations


Presentation on theme: "Www.sti-innsbruck.at © Copyright 2008 STI INNSBRUCK www.sti-innsbruck.at Intelligent Systems Propositional Logic."— Presentation transcript:

1 www.sti-innsbruck.at © Copyright 2008 STI INNSBRUCK www.sti-innsbruck.at Intelligent Systems Propositional Logic

2 www.sti-innsbruck.at Logics Logics are formal languages for representing information such that conclusions can be drawn. Syntax defines the sentences in the language. Semantics defines the "meaning" of sentences. –more precisely, defines the truth of each sentence w.r.t. each possible world (model) E.g., the language of arithmetic –x+2 ≥ y is a sentence; x2+y > {} is not a sentence –x+2 ≥ y is true iff the number x+2 is no less than the number y –Sentence x+2 ≥ y is true in a world where x = 7, y = 1 –Sentence x+2 ≥ y is false in a world where x = 0, y = 6

3 www.sti-innsbruck.at Entailment Entailment means that one thing follows from another KB╞ α Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true –E.g., the KB containing “Innsbruck is in Tirol” and “Tirol is in Austria” entails “Innsbruck is in Austria” –E.g., the KB containing x+y = 4 entails 4 = x+y Entailment is a relationship between sentences (i.e., syntax) that is based on semantics

4 www.sti-innsbruck.at Models Possible worlds – environments in which the agent might or might not be in Models – mathematical abstractions, formally structured worlds with respect to which truth of sentences can be evaluated m is a model of a sentence α if α is true in m M(α) is the set of all models of α KB ╞ α iff M(KB)  M(α) Knowledge base KB entails sentence α if and only if all models of the KB are models of α

5 www.sti-innsbruck.at Inference KB ├ i α : sentence α can be derived from KB by procedure i, i proves α Soundness: i is sound if whenever KB ├ i α, it is also true that KB╞ α Completeness: i is complete if whenever KB╞ α, it is also true that KB ├ i α A sound and complete procedure answers any question whose answer follows from what is known by the KB correctly.

6 www.sti-innsbruck.at Propositional logic: Syntax Propositional logic is the simplest logic and illustrates basic ideas of logic The proposition symbols P 1, P 2,…are sentences (formulae) –If S is a sentence,  S is a sentence (negation) –If S 1 and S 2 are sentences, S 1  S 2 is a sentence (conjunction) –If S 1 and S 2 are sentences, S 1  S 2 is a sentence (disjunction) –If S 1 and S 2 are sentences, S 1  S 2 is a sentence (implication) –If S 1 and S 2 are sentences, S 1  S 2 is a sentence (biconditional)

7 www.sti-innsbruck.at Propositional logic: Semantics Each model specifies true/false values for each proposition symbol (8 possible models) –E.g. P 1,2 P 2,2 P 3,1 falsetruefalse Rules for evaluating truth with respect to an interpretation m:  Sis true iff S is false S 1  S 2 is true iff S 1 is true and S 2 is true S 1  S 2 is trueiff S 1 is true or S 2 is true S 1  S 2 is trueiffS 1 is false or S 2 is true S 1  S 2 is false iffS 1 is true and S 2 is false S 1  S 2 is true iffS 1  S 2 is true and S 2  S 1 is true Simple recursive process evaluates an arbitrary sentence w.r.t. an interpretation, e.g.,  P 1,2  (P 2,2  P 3,1 ) : true  (true  false) = true  true = true

8 www.sti-innsbruck.at Truth tables for connectives

9 www.sti-innsbruck.at Truth tables for inference α1 = "[1,2] is safe"

10 www.sti-innsbruck.at Inference by enumeration Depth-first enumeration of all models is sound and complete –PL-TRUE evaluates a sentence recursively wrt. to an interpretation –EXTEND(s,v,m) extends the partial model m by assigning value v to symbol s. For n symbols, time complexity is O(2 n ), space complexity is O(n)

11 www.sti-innsbruck.at Validity and satisfiability A sentence is valid if it is true in all models, e.g., True,A  A, A  A, (A  (A  B))  B Validity is connected to inference via the Deduction Theorem: KB ╞ α if and only if (KB  α) is valid A sentence is satisfiable if it is true in some model e.g., A  B, C A sentence is unsatisfiable if it is true in no models e.g., A  A Satisfibility is connected to inference via the following KB ╞ α if and only if (KB  α) is unsatisfiable

12 www.sti-innsbruck.at Logical equivalence Two sentences are logically equivalent iff they are true in same models: α ≡ ß iff α╞ β and β╞ α

13 www.sti-innsbruck.at Proof methods Proof methods divide into (roughly) two kinds –Application of inference rules Legitimate (sound) generation of new sentences from old ones Proof = a sequence of inference rule applications Can use inference rules as operators in a standard search algorithm Typically requires transformation of sentences into a normal form –Model checking Truth table enumeration (always exponential in n) Improved backtracking, e.g., Davis-Putnam-Logemann-Loveland (DPLL) Heuristic search in model space (sound but incomplete) e.g., min-conflicts- like hill-climbing algorithms

14 www.sti-innsbruck.at Resolution Conjunctive Normal Form (CNF) conjunction of disjunctions of literals often called clauses E.g., (A   B)  (B   C   D) Resolution inference rule (for CNF): l i  …  l k, m 1  …  m n l i  …  l i-1  l i+1  …  l k  m 1  …  m j-1  m j+1 ...  m n where l i and m j are complementary literals. E.g., P 1,3  P 2,2,  P 2,2 P 1,3 Resolution is sound and complete for propositional logic

15 www.sti-innsbruck.at Conversion to CNF B 1,1  (P 1,2  P 2,1 ) 1.Eliminate , replacing α  β with (α  β)  (β  α). (B 1,1  (P 1,2  P 2,1 ))  ((P 1,2  P 2,1 )  B 1,1 ) 2.Eliminate , replacing α  β with  α  β. (  B 1,1  P 1,2  P 2,1 )  (  (P 1,2  P 2,1 )  B 1,1 ) 3.Move  inwards using de Morgan's rules: (  B 1,1  P 1,2  P 2,1 )  ((  P 1,2   P 2,1 )  B 1,1 ) 4.Apply distributivity law (  over  ) and flatten: (  B 1,1  P 1,2  P 2,1 )  (  P 1,2  B 1,1 )  (  P 2,1  B 1,1 )

16 www.sti-innsbruck.at Soundness Whenever KB ├ r α, it is also true that KB╞ α l i  …  l k, m 1  …  m n l i  …  l i-1  l i+1  …  l k  m 1  …  m j-1  m j+1 ...  m n l i and m j are complementary literals.  ( l i  …  l i-1  l i+1  …  l k )  l i  m j  ( m 1  …  m j-1  m j+1 ...  m n )  ( l i  …  l i-1  l i+1  …  l k )  ( m 1  …  m j-1  m j+1 ...  m n ) using the rule (a   b)  (b  a) which can be written also as (a  b)  (  a  b).

17 www.sti-innsbruck.at Completeness Whenever KB╞ α, it is also true that KB ├ r α KB ╞ α if and only if (KB  α) is unsatisfiable Ground resolution theorem –If a set of clauses is unsatisfiable, then the resolution closure of those clauses contains the empty clause. Proof by contradiction –Assume KB ╞ α and that the closure does not contain the empty clause.

18 www.sti-innsbruck.at Forward and backward chaining Horn clauses: disjunction of literals of which at most one is positive –Important because Horn clauses can be written as an implication whose premise is a conjuction of positive literals and whose conclusion is a single positive literal Definite clauses: exactly one positive literal –Positive literal forms the head –Negative literals form the body Inference with Horn clauses can be done by forward or backward chaining in a time that is linear in the size of the KB.

19 www.sti-innsbruck.at Forward chaining Fire any rule whose premises are satisfied in the KB Add its conclusion to the KB, until query is found

20 www.sti-innsbruck.at Forward chaining algorithm agenda: true symbols not yet processed count: how many premises are unknown for each new symbol processed, count is reduced by one for each implication in whose premise this symbol appears Count = 0  conclusion can be added to the agenda Forward chaining is sound and complete for Horn KB

21 www.sti-innsbruck.at Forward chaining example

22 www.sti-innsbruck.at Forward chaining example

23 www.sti-innsbruck.at Forward chaining example

24 www.sti-innsbruck.at Forward chaining example

25 www.sti-innsbruck.at Forward chaining example

26 www.sti-innsbruck.at Forward chaining example

27 www.sti-innsbruck.at Forward chaining example

28 www.sti-innsbruck.at Forward chaining example

29 www.sti-innsbruck.at Proof of completeness FC derives every atomic sentence that is entailed by KB 1.FC reaches a fixed point where no new atomic sentences are derived 2.Consider the final state as a model m, assigning true/false to symbols 3.Every clause in the original KB is true in m 4.Hence m is a model of KB 5.If KB╞ q, q is true in every model of KB, including m Computes the minimal model for Horn Knowledge Bases (some rules are not expressible in Horn !)

30 www.sti-innsbruck.at Backward chaining Work backwards from the query q To prove q by BC, check if q is known already, or prove by BC all premises of some rule concluding q Avoid loops: check if new sub-goal is already on the goal stack Avoid repeated work: check if new sub-goal has already been proved true, or has already failed

31 www.sti-innsbruck.at Backward chaining example

32 www.sti-innsbruck.at Backward chaining example

33 www.sti-innsbruck.at Backward chaining example

34 www.sti-innsbruck.at Backward chaining example

35 www.sti-innsbruck.at Backward chaining example

36 www.sti-innsbruck.at Backward chaining example

37 www.sti-innsbruck.at Backward chaining example

38 www.sti-innsbruck.at Backward chaining example

39 www.sti-innsbruck.at Backward chaining example

40 www.sti-innsbruck.at Backward chaining example

41 www.sti-innsbruck.at Forward vs. backward chaining FC is data-driven, automatic, unconscious processing, –e.g., object recognition, routine decisions May do lots of work that is irrelevant to the goal !!! BC is goal-driven, appropriate for problem-solving, –e.g., Where are my keys? How do I get into a PhD program? Complexity of BC can be much less than linear in size of KB (only relevant facts are considered)

42 www.sti-innsbruck.at Efficient propositional inference Two families of efficient algorithms for propositional inference –Complete backtracking search algorithms DPLL algorithm (Davis, Putnam, Logemann, Loveland) –Incomplete local search algorithms WalkSAT algorithm (Incomplete, local search algorithm)

43 www.sti-innsbruck.at The DPLL algorithm Determine if an input propositional logic sentence (in CNF) is satisfiable. Improvements over truth table enumeration 1.Early termination A clause is true if any literal is true (disjunction of literals) A sentence is false if any clause is false (conjunction of clauses) 2.Pure symbol heuristic Pure symbol: always appears with the same "sign" in all clauses. e.g., In the three clauses (A   B), (  B   C), (C  A), A and B are pure, C is impure. If a sentence has a model then the it has a model with the pure symbols assigned so as to make their literals true. 3.Unit clause heuristic Unit clause: only one literal in the clause The only literal in a unit clause must be true.

44 www.sti-innsbruck.at The DPLL algorithm

45 www.sti-innsbruck.at

46 Expressiveness limitation of propositional logic KB contains “physics” sentences for every single square For every time t and every location [x,y], Rapid proliferation of clauses

47 www.sti-innsbruck.at Summary Logical agents apply inference to a knowledge base to derive new information and make decisions Basic concepts of logic: –syntax: formal structure of sentences –semantics: truth of sentences wrt models –entailment: necessary truth of one sentence given another –inference: deriving sentences from other sentences –soundness: derivations produce only entailed sentences –completeness: derivations can produce all entailed sentences Resolution is complete for propositional logic Forward, backward chaining are linear-time, complete for Horn clauses Propositional logic lacks expressive power


Download ppt "Www.sti-innsbruck.at © Copyright 2008 STI INNSBRUCK www.sti-innsbruck.at Intelligent Systems Propositional Logic."

Similar presentations


Ads by Google