Logic Logic Formal languages and syntax: propositional variables: P , Q , R , S operators (connectives): ¬ , ∨ , ∧ Logic: A Summary formulae: P , ¬ Q ∧ R , ¬ ( Q ∨ R ) Language : Jacek Malec the set of all well-formed formulae (wff): Dept. of Computer Science, Lund University, Sweden { P , Q , ¬ P , ¬ Q , P ∧ Q , P ∨ Q , . . . } February 20, 2019 Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 1(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 2(18) Logic Logic Assigning truth values to symbols: Logical equivalence: P is TRUE Q ∨ ¬ P Q is FALSE ¬ Q ∨ P Interpretation : an assignment to all of the variables. ¬ P ∨ P It determines the truth values for more complex formulae: ¬ P ∧ P ¬ P ∨ Q P ∨ Q ¬ P ∨ P ¬ ( ¬ P ∧ ¬ Q ) a tautology ¬ P ∧ P ¬ P ∨ Q a contradiction P → Q Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 3(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 4(18)
Logic Logic Formal systems: Rules of inference: Modus Ponens: A A → B Axioms B Axiom schemas Rules of inference Conjunction: A B A ∧ B Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 5(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 6(18) Logic Logic Theoremhood: Satisfiability: P → Q 1 assume this is given as true Is there an assignment to the variables such that the following Q → R 2 formula is true? assume this is given as true P 3 ¬ P ∧ ( Q ∨ ¬ ( R ∧ . . . )) assume this is given as true Satisfiability problem is O ( 2 n ) Q 4 Similar questions: Modus Ponens using 1 and 3 Is it a tautology? R 5 Modus Ponens using 2 and 4 Is it a contradiction? Lines 1–4 constitute a proof of Q . Lines 1–5 constitute a proof of R . Q is a theorem . Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 7(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 8(18)
Logic Logic Knowledge representation: Knowledge representation: P = temp(pump45) < 85 o C P = temp(pump45) < 85 o C Q = correctly_functioning(pump45) Q = correctly_functioning(pump45) P → Q P → Q B 1 , 1 = no breeze in (1, 1) P 1 , 2 = no pit in (1, 2) P 2 , 1 = no pit in (2, 1) B 1 , 1 → P 1 , 2 ∨ P 2 , 1 Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 9(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 9(18) Logic Logic Knowledge representation: Knowledge representation: P = temp(pump45) < 85 o C P = temp(pump45) < 85 o C Q = correctly_functioning(pump45) Q = correctly_functioning(pump45) P → Q P → Q B 1 , 1 = no breeze in (1, 1) B 1 , 1 = no breeze in (1, 1) P 1 , 2 = no pit in (1, 2) P 1 , 2 = no pit in (1, 2) P 2 , 1 = no pit in (2, 1) P 2 , 1 = no pit in (2, 1) B 1 , 1 → P 1 , 2 ∨ P 2 , 1 B 1 , 1 → P 1 , 2 ∨ P 2 , 1 B 1 , 1 ← P 1 , 2 ∨ P 2 , 1 B 1 , 1 ← P 1 , 2 ∨ P 2 , 1 B 1 , 1 ↔ P 1 , 2 ∨ P 2 , 1 Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 9(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 9(18)
Logic Logic Expert or Rule-Based Systems: A note on Resolution: (if (and p1 p2 ... pn) q) It is a generalization of Modus Ponens Tasks: prediction A 1 ∨ A 2 ∨ . . . ∨ ¬ C ∨ . . . ∨ A m B 1 ∨ B 2 ∨ . . . ∨ C ∨ . . . B n (if (and john_is_in_the_building (not john_is_in_his_office) A 1 ∨ A 2 ∨ . . . ∨ A m ∨ B 1 ∨ B 2 ∨ . . . ∨ B n (not john_is_in_the_copy_room)) Modus Ponens: john_is_in_the_conference_room) ¬ P ∨ Q P diagnosis Q (if (and engine_is_running_hot engine_coolant_levels_within_spec) evidence_of_a_lubrication_problem) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 10(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 11(18) Logic Logic First Order Predicate Logic: Syntax First Order Predicate Logic: Syntax Predicates (relations, properties): Predicates (relations, properties): AgeOf , Bald , CapitalOf , YoungerThan , < , = , P , Q , . . . Constants : Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 12(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 12(18)
Logic Logic First Order Predicate Logic: Syntax First Order Predicate Logic: Syntax Predicates (relations, properties): Predicates (relations, properties): AgeOf , Bald , CapitalOf , YoungerThan , < , = , P , Q , . . . AgeOf , Bald , CapitalOf , YoungerThan , < , = , P , Q , . . . Constants : Constants : Jacek , 61, Stockholm , Lund , Sweden , Pierre , pump 59, c , d , Jacek , 61, Stockholm , Lund , Sweden , Pierre , pump 59, c , d , . . . . . . Functions : Functions : fatherOf , ageOf , lengthOf , locationOf , . . . Terms : constants, variables, functions thereof Atomic sentences : relation over appropriate amount of terms AgeOf ( Jacek , 61 ) , Bald ( Jacek ) , 8 < x , YoungerThan ( Jacek , fatherOf ( Jacek )) , YoungerThan ( x , fatherOf ( x )) , P ( x , y , z ) , locationOf ( TJR 048 ) = PDammgården, . . . Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 12(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 12(18) Logic Logic First Order Predicate Logic: Syntax Quantifiers: Predicates (relations, properties): AgeOf , Bald , CapitalOf , YoungerThan , < , = , P , Q , . . . ∀ x ( swedish − citizen ( x ) → has − pnr ( x )) Constants : Jacek , 61, Stockholm , Lund , Sweden , Pierre , pump 59, c , d , ∃ y ( polish − citizen ( y ) ∧ has − pnr ( y )) . . . Functions : fatherOf , ageOf , lengthOf , locationOf , . . . Terms : constants, variables, functions thereof ∀ xA and ∃ xA are wffs if A is a wff Atomic sentences : relation over appropriate amount of terms scope of a quantifier AgeOf ( Jacek , 61 ) , Bald ( Jacek ) , 8 < x , free variable YoungerThan ( Jacek , fatherOf ( Jacek )) , YoungerThan ( x , fatherOf ( x )) , P ( x , y , z ) , closed formula locationOf ( TJR 048 ) = PDammgården, . . . ground formula Well-formed formulae : as before plus ∀ xA and ∃ xA are wffs if A is a wff Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 12(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 13(18)
Logic Logic Formal System for FOPC: Formal System for FOPC: language of FOPC, axioms + RES and UI language of FOPC, axioms + RES and UI where Universal Instantiation: where Universal Instantiation: ∀ xA ∀ xA A 0 ( x → t ) A 0 ( x → t ) e.g. from e.g. from ∀ x , y ( Pit ( x , y ) → Breeze ( x , y + 1 ) ∧ Breeze ( x + 1 , y )) ∀ x , y ( Pit ( x , y ) → Breeze ( x , y + 1 ) ∧ Breeze ( x + 1 , y )) we can infer we can infer Pit ( 1 , 2 ) → Breeze ( 1 , 3 ) ∧ Breeze ( 2 , 2 ) , Pit ( 1 , 2 ) → Breeze ( 1 , 3 ) ∧ Breeze ( 2 , 2 ) , and Pit ( 2 , 1 ) → Breeze ( 2 , 2 ) ∧ Breeze ( 3 , 1 ) , and ... Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 14(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 14(18) Logic Logic Theories: Logically equivalent formulae: 1. ∀ x , y ( clown ( x ) → loves ( y , x )) ∀ x , y ¬ clown ( x ) ∨ loves ( y , x ) ∀ x ( clown ( x ) → ∀ y ( loves ( y , x ))) Everybody loves a clown. 2. ∀ xA ↔ ¬ ∃ x ¬ A ∀ x , y ¬ winner ( x ) ∨ ¬ game ( y ) ∨ ¬ plays ( x , y ) ∨ wins ( x , y ) ∃ xA ↔ ¬ ∀ x ¬ A A winner wins every game (s)he plays. Example: Pattern: ( ∀ x , y ) ¬ clown ( x ) ∨ loves ( y , x ) ∀ x 1 , ..., x n A ( ∀ y ) ¬ (( ∃ x )( clown ( x ) ∧ ¬ loves ( y , x ))) where A is in CNF ( ∀ x ) clown ( x ) → ¬ (( ∃ y ) ¬ loves ( y , x )) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 15(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 16(18)
Logic Logic Theorem proving: Search, search everywhere... Show loves ( Pia , Kalle ) given axioms: ∀ x , yclown ( x ) → loves ( y , x ) 1 clown ( Kalle ) 2 Proof: Theorem proving ∀ x , yclown ( x ) → loves ( y , x ) (AXIOM) 1 is clown ( Kalle ) (AXIOM) 2 ∀ yclown ( Kalle ) → loves ( y , Kalle ) 3 a search in the space of proofs UI x → Kalle clown ( Kalle ) → loves ( Pia , Kalle ) 4 UI y → Pia loves ( Pia , Kalle ) 5 MP 2,4 Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 17(18) Jacek Malec, http://rss.cs.lth.se, jacek.malec@cs.lth.se 18(18)
Recommend
More recommend