Logics for Data and Knowledge Representation

Slides:



Advertisements
Similar presentations
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Advertisements

Logic.
Existential Graphs and Davis-Putnam April 3, 2002 Bram van Heuveln Department of Cognitive Science.
Knoweldge Representation & Reasoning
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
LDK R Logics for Data and Knowledge Representation Exercise 2: PL, ClassL, Ground ClassL.
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 19, 2012.
Pattern-directed inference systems
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Logical Agents Logic Propositional Logic Summary
1 Knowledge Representation. 2 Definitions Knowledge Base Knowledge Base A set of representations of facts about the world. A set of representations of.
Propositional Logic Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma Guadalajara
LDK R Logics for Data and Knowledge Representation Propositional Logic Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia,
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
LECTURE LECTURE Propositional Logic Syntax 1 Source: MIT OpenCourseWare.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
CS6133 Software Specification and Verification
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation Exercises: ClassL Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
LDK R Logics for Data and Knowledge Representation Propositional Logic Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia,
Propositional Logic Rather than jumping right into FOL, we begin with propositional logic A logic involves: §Language (with a syntax) §Semantics §Proof.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
March 3, 2016Introduction to Artificial Intelligence Lecture 12: Knowledge Representation & Reasoning I 1 Back to “Serious” Topics… Knowledge Representation.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Propositional Logic (a.k.a. Sentential Logic)
Chapter 7. Propositional and Predicate Logic
Logics for Data and Knowledge Representation
Knowledge Representation and Reasoning
COMP 1380 Discrete Structures I Thompson Rivers University
Logics for Data and Knowledge Representation
Exercises: First Order Logics (FOL)
The Propositional Calculus
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Logical Inference: Through Proof to Truth
Lecture 2 Propositional Logic
Propositional Calculus: Boolean Algebra and Simplification
Elementary Metamathematics
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
CS 270 Math Foundations of CS
Artificial Intelligence
Propositional Equivalences
Logics for Data and Knowledge Representation
Back to “Serious” Topics…
Computer Security: Art and Science, 2nd Edition
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Chapter 7. Propositional and Predicate Logic
CSNB234 ARTIFICIAL INTELLIGENCE
Logics for Data and Knowledge Representation
TRUTH TABLES.
Bottom Up: Soundness and Completeness
COMP 1380 Discrete Structures I Thompson Rivers University
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Artificial Intelligence Propositional Logic
Logical and Rule-Based Reasoning Part I
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Presentation transcript:

Logics for Data and Knowledge Representation Exercises: Propositional Logic Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

Outline Syntax Modeling a problem Semantics Logical implication Symbols and formation rules Modeling a problem Semantics Assignments, models Logical implication Reasoning Satisfiability and validity Some nice problems

Symbols in PL Which of the following symbols are used in PL? SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Which of the following symbols are used in PL? ⊓  ⊤ ∨ ≡ ⊔ ⊑ → ↔ ⊥ ∧ ⊨ Which of the following symbols are in well formed formulas?

Symbols in PL (solution) SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Which of the following symbols are used in PL? ⊓  ⊤ ∨ ≡ ⊔ ⊑ → ↔ ⊥ ∧ ⊨ Which of the following symbols are in well formed formulas? Remember the BNF grammar: <Atomic Formula> ::= A | B | ... | P | Q | ... | ⊥ | ⊤ <wff> ::= <Atomic Formula> | ¬<wff> | <wff>∧ <wff> | <wff>∨ <wff> | <wff> → <wff> | <wff> ↔ <wff> 4

Formation rules Which of the following is not a wff? SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Which of the following is not a wff?  MonkeyLow ∨ BananaHigh   MonkeyLow  BananaHigh MonkeyLow   BananaHigh MonkeyLow →  GetBanana NUM. 3 IS WRONG! 5

Modeling: Bananas SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Highlight relevant words, define a PL language and a theory for the problem below. Bananas may differ in many ways. However, there are red and yellow bananas. I like bananas, but I eat only yellow bananas. If I do not eat at least a banana I get crazy. CHANGED 6

Modeling: Bananas (possible solution) SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Bananas may differ in many ways. However, there are red and yellow bananas. I like bananas, but I eat only yellow bananas. If I do not eat at least a banana I get crazy. CHANGED L = {RedBanana, YellowBanana, EatBanana, GetCrazy} T = {EatBanana → YellowBanana,  EatBanana → GetCrazy} 7

Truth valuations and Truth Tables SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL A truth valuation on a PL language L is a mapping ν that assigns to each formula P of L a truth value ν(P). A truth table is composed of one column for each input variable and one (or more) final column for all of the possible results of the logical operation that the table is meant to represent. Each row of the truth table therefore contains one possible assignment of the input variables, and the result of the operation for those values. LOGICAL OPERATION VARIABLES A B A∧B T F POSSIBLE ASSIGNEMENTS

Example Calculate the Truth Table of the following formulas: SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Calculate the Truth Table of the following formulas: (1) A ∧ B; (2) P ∨ Q; (3) X ↔ Y. VARIABLES (1) (2) (3) A B A∧B A∨B A↔B T F POSSIBLE ASSIGNEMENTS

Exercise: Truth Valuations SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Compute truth valuations for the formulas: (A∨B)∧¬C (A∨B)→C (A∨B→C∨D∨E)∧(¬F↔A)∧(¬F∨G∧¬H∨F)∧(¬I→¬(D∧J))∧(¬J∨¬ D∨E)∧F 10

Provide the models for the propositions SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL RECALL: a truth valuation ν is a model for a proposition P iff ν(P) = true List the models for the following formulas: A ∧ ¬B (A ∧ B) ∨ (B ∧ C) A ∨ B → C ¬A ↔ B ↔ C A B A ∧ ¬ B T F MODEL 11

Entailment SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL RECALL:  ⊨ ψ iff all models satisfying the formulas in  also satisfy ψ Let A, B, C be propositional sentences. (a) If A ⊨ B ∧ C, then A ⊨ B or A ⊨ C or both? (b) What if A ⊨ B ∨ C? Proof: The only model satisfying ‘B ∧ C’ is ν = {B=T, C=T}. If ‘A ⊨ B ∧ C’ then ν should be also a model of ‘A’. However, since ν assigns true to B, ν is a model of ‘B’. Similarly, ν is also a model of ‘C’. So, (a) above is true for both. Assume now that ‘A ⊨ B ∨ C’. A model of ‘B ∨ C’ is ν = {B=T, C=F}. ν is not a model of ‘C’, therefore A ⊭ C. The other cases are similar.

Exercise: prove entailment SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Given that: P = (A ∨ B ) ∧ (C ∨ D ∨ E) Q1 = A ∨ B Q2 = (A ∨ B ∨ C) ∧ ((B ∧ C ∧ D) → E) Q3 = (A ∨ B) ∧ (D ∨ E) Does P ⊨ Qi ? Proof: Let X = A ∨ B, Y = D ∨ E, then we can rewrite: P = X ∧ (¬C ∨ Y); Q1 = X; Q2 = (X ∨ C) ∧ (¬B ∨ ¬C ∨ Y); Q3 = X ∧ Y P ⊨ Q1 is obvious. Since ‘X ⊨ X ∨ C’ and ‘(¬ C ∨ Y) ⊨ (¬B ∨ ¬C ∨ Y)’, then P ⊨ Q2. Since ‘Y ⊨ (¬C ∨ Y)’, then Q3 ⊨ P (and not vice versa).

Exercise: prove entailment using truth tables SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Given that: P = (A ∨ B ) ∧ (C ∨ D ∨ E) Q1 = A ∨ B Q2 = (A ∨ B ∨ C) ∧ (B ∧ C ∧ D → E) Q3 = (A ∨ B) ∧ (D ∨ E) (1) List all truth assignments such that P ⊨ Qi (2) Is there any assignment such that P ⊨ Qi for all i? Solution to (1): First compute the truth tables for all the propositions above. Then, list all rows for which both P and Qi are true. Solution to (2): Check whether there is any assignment for which all the sentences above are true. 14

Logical implication and deduction SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Deduction (⊢) is the process of inferring new knowledge from known facts. Logical implication (→) is a way to include deduction directly in the language. It is an alternative way to implement deduction. For instance: ¬(A ∨ B) → (¬A ∧ ¬B) iff ¬(A ∨ B) ⊢ (¬A ∧ ¬B) We provided some well known tautologies in the theoretical part (e.g. the De Morgan Law above) 15

Prove using truth tables, the following deductions SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Double negative elimination  P ⊢ P Conjunction introduction / elimination (a) {P, Q} ⊢ P∧Q; (b) P ∧ Q ⊢ P; (c) P ∧ Q ⊢ Q. Disjunction introduction / elimination  (a) P ⊢P ∨ Q; (a) Q ⊢ P ∨ Q; (c) {P ∨ Q, P → R, Q → R} ⊢ R Bi-conditional introduction / elimination (P → Q) ∧ (Q → P) ⊢ (P ↔ Q)  De Morgan (a) (P ∧ Q) ⊢ P ∨ Q; (b) (P ∨ Q) ⊢ P ∧ Q 16

Proofs of the Deduction Rules SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL P Q P∧Q P∨Q P↔Q T F P Q ¬¬P P→Q Q→P ¬(P∧Q) ¬P∨¬Q ¬(P∨Q) ¬P∧¬Q T F 17

Soundness and Completeness SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL A deductive system is sound if any sentence P that is derivable from a set Г of sentences is also a logical consequence of that set Г. A deductive system is complete if every sentence P that is a semantic consequence of a set of sentences Γ can be derived in the deduction system from that set. A soundness property provides the initial reason for counting a logical system as desirable. The completeness property means that every validity (truth) is provable. 18

A = (p → r) ∧ (q → s) ∧ (r ∨ s) →(p ∨ q) Prove validity (I) SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Suppose p, q, r, s are four propositional sentences, is the following sentence valid? A = (p → r) ∧ (q → s) ∧ (r ∨ s) →(p ∨ q) A way to prove validity is to show that the proposition entails ⊤. This can be done by applying well known tautologies (e.g. De Morgan). In alternative we can show using truth tables that all the assignments are true. (p → r) ∧ (q → s) ∧ (¬r ∨ ¬s) → (¬p ∨ ¬q) = ¬((p → r) ∧ (q → s) ∧ (¬r ∨ ¬s)) ∨ ¬p ∨ ¬q = (p ∧ ¬r) ∨ (q ∧ ¬s) ∨ (r ∧ s) ∨ ¬p ∨ ¬q = = ⊤

Prove validity (II) 20 p q r s A T F SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL p q r s A T F 20

Calculus with Tableaux SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Γ = {A B, B, A} Γ = {B A, B} Γ = {(A  B), A} A B A B B  A A  B A B A B A  B closed closed A B closed closed 21

Calculus with Tableaux SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL Γ = {(A B)  (B  A), B} B (A  B)  ( B  A) (A  B)  B  A A  B B A closed A B closed 22

Are you ‘Sherlock Holmes’? SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL There was a robbery in which a lot of goods were stolen. The robber(s) left in a truck. It is known that : (1) Nobody else could have been involved other than A, B and C. (2) C never commits a crime without A's participation. (3) B does not know how to drive. Is A innocent or guilty? Proof: The 3 points above can be translated in PL as follows: (1) θ1 = A ∨ B ∨ C; (2) θ2 = C → A; (3) θ3 = B → (B ∧ A) ∨ (B ∧ C) Does {θ1 , θ2 , θ3} ⊨ A ? Yes! We can prove it by showing that θ1 ∧ θ2 ∧ θ3 → A is a tautology.

Knights and Knaves SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL A very special island is inhabited only by knights and knaves. Knights always tell the truth, and knaves always lie. You meet two inhabitants: Zoey and Mel. Zoey tells you that Mel is a knave. Mel says ‘Neither Zoey nor I are knaves’. Can you determine what are they? (who is a knight and who is a knave?) Proof: The two sentences above can be translated in PL as follows: (1) Z → M; (2) M → Z ∧ M. We can use truth tables to prove that there are two possible situations: - Both lie (they are both knaves) - Zoey tells the true (is a Knight) and Mel lies (is a knave)

Recall the DPLL algorithm SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL REVIEW :: REASONING IN PL :: THE DPLL PROCEDURE :: OBSERVTIONS :: CONCLUSIONS Input: a proposition P in CNF Output: true if "P satisfiable" or false if "P unsatisfiable" boolean function DPLL(P) { if consistent(P) then return true; if hasEmptyClause(P) then return false; foreach unit clause C in P do P = unit-propagate(C, P); foreach pure-literal L in P do P = pure-literal-assign(L, P); L = choose-literal(P); return DPLL(P  L) OR DPLL(P  L); } Consistency Check Empty Close Test Unit Propagation Pure Literal Elimination Splitting rule 25

Use DPLL to prove satisfiability SYNTAX :: MODELING A PROBLEM :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING :: SOME NICE PROBLEMS :: DPLL B  ¬A  (¬C  A)  (B  C) 1. Is it consistent? YES, there are no contradictions 2. Are there any empty clauses? No, go ahead. 3. Assign the right truth value to all literals and simplify the formula: Assign B = T, A = F and then the formula simplifies to ¬C 4. Assign the right value to pure literals: Assign C = F. Done. 5. No need for the splitting rule The formula is satisfiable at least for the assignment (a model for it): {A = F, B = T, C = F}