Logics for Data and Knowledge Representation Propositional Logic Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese Outline Introduction Syntax Semantics 2 Truth valuation Satisfiability Validity Entailment Logical implication Reasoning Services Normal Forms INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Propositions All knowledge representation languages deal with sentences “All men are mortals” “Obama is the president of the USA” Sentences denote propositions (by definition), namely they express something true or false (the mental image of what you mean when you write the sentence) Logic languages deal with propositions Propositional logic is the simplest logic that does this (no individuals, no quantifiers) Mortal Man 3 ObamaPresident INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Introduction: example Mental Model World Language L Monkey SEMANTIC GAP 4 PROPOSITION SENTENCE INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Introduction: the famous triangle CONCEPT (what we have in mind) refers to symbolizes Monkey REFERENT (the real object) 5 stands for SYMBOL (what we write) INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Language (Syntax) Alphabet of symbols: The first step in setting up a formal language is to list the symbols of the alphabet Propositional Logic (PL) is a symbolic language Σ0: the alphabet of a PL language Σ0 Logical , , , … Descriptive Constants Variables one proposition only they can be substituted by any proposition or formula A, B, C … P, Q, ψ … NOTE: not only characters but also words (composed by several characters) like “monkey” are descriptive symbols 6 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Additional Symbols Auxiliary symbols Parentheses: ( ) Defined symbols Logical defined constants are, for all propositions P: ⊥ (falsehood symbol, false, bottom) ⊥ =df P∧¬P T (truth symbol, true, top) T =df ¬⊥ 7 Defined symbols are not strictly necessary However, they increase the usability by reducing the syntactic complexity of propositions INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Formation Rules (FR): well formed formulas Well formed formulas (wff) in PL can be described by the following BNF grammar (codifying the FR): <Atomic Formula> ::= A | B | ... | P | Q | ... | ⊥ | ⊤ <wff> ::= <Atomic Formula> | ¬<wff> | <wff>∧ <wff> | <wff> ∨ <wff> Σ0 + FR define a propositional language Atomic formulas are also called atomic propositions while wff are propositional formulas (or just propositions) A formula is correct if and only if it is a wff ψ, PL 8 Yes, ψ is correct! PARSER No INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: the Monkey-Banana problem “There is a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A box is available that will enable the monkey to reach the bananas if he climbs on it. The monkey and box have height Low, but if the monkey climbs onto the box he will have height High, the same as the bananas. At this point the monkey can get a banana [...]” Significant data: monkey, bananas, box Significant knowledge: Low, High, Climb, GetBanana All other data and knowledge are irrelevant! Both data and knowledge are codified as (atomic or more complex) formulas in the language Language (any language you want to define): L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana} 9 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Examples of formulas Formula inLab-Monkey inlab-monkey in-lab-monkey inLab(Monkey) (Monkey ∧ GetBanana) ∨ ¬ High inLab(Monkey)∧ P ¬∧Q Correct Yes (wff) No NOTE: In PL we do not have individuals (it is not so expressive). Parentheses in inLab(Monkey) are not the auxiliary symbols like in e.g. (Monkey ∧ GetBanana) ∨ ¬ High (problem of ambiguity) 10 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Propositional Theory Propositional (or sentential) theory A set of propositions It is a (propositional) knowledge base (containing true facts) It corresponds to a TBox (terminology) only, where no meaning is specified yet, i.e. it is a syntactic notion Recall that: knowledge is a set of facts, i.e. statements we assumed statements are propositions 11 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Propositional Theories and Databases A propositional theory is not a database! Propositions don’t show data explicitly (no individuals) In PL the form P(a) must be interpreted as P-a (so the use of form P(a) is ambiguous). Example: In the sentence ‘inLab(Monkey)’, the string ‘Monkey’ does not refer to an individual from some data domain 12 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS The Monkey-Banana problem “There is a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A box is available that will enable the monkey to reach the bananas if he climbs on it. The monkey and box have height Low, but if the monkey climbs onto the box he will have height High, the same as the bananas. At this point the monkey can get a banana [...]” L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana, , , } T = { (MonkeyLow BananaHigh MonkeyGetBanana) (MonkeyLow MonkeyClimbBox) ( MonkeyLow BananaHigh MonkeyGetBanana)} NOTE: We still need to assign semantics to the symbols in the language. 13 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Semantics means providing an interpretation So far the elements of our propositional language are simply strings of symbols without formal meaning The meanings which are intended to be attached to the symbols and propositions form the intended interpretation ν (nu) of the language 14 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS The Monkey-Banana problem (II) “There is a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A box is available that will enable the monkey to reach the bananas if he climbs on it. The monkey and box have height Low, but if the monkey climbs onto the box he will have height High, the same as the bananas. At this point the monkey can get a banana [...]” L = {A, B, C, D, , , } T = { (A B D) (A C) ( A B D)} NOTE: Symbols are without meaning. What each symbol mean? 15 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Semantics: formal model Intensional interpretation We must make sure to assign the formal meanings out of our intended interpretation to the (symbols of the) language, so that formulas (propositions) really express what we intended (in terms of true/false) The mental model: What we have in mind? In our mind (mental model) we have a set of properties that we associate to propositions. We need to make explicit (as much as possible) what we mean. The formal model This is done by defining a formal model M. Technically: we have to define a pair (M,⊨) for our propositional language Truth-values In PL a sentence A is true (false) iff A denotes a formal object which satisfies (does not satisfy) the properties of the object in the real world. 16 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS The Monkey-Banana problem (III) T = { (A C) } L = {A, C} Domain D 17 D = {T, F} Model M Formal model M(A) = T M(C) = F Truth values SEMANTIC GAP Mental Model Entailment World Intensional Interpretation I(A) = T I(C) = F Theory T M⊨T Language L INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: Banana (I) 18 Bananas may differ in many ways, but when using the proposition Banana we have in mind some specific properties: e.g. a given shape, a given color ... These specific properties determine the intension of the proposition Banana The intentional interpretation of the proposition Banana determines its truth-value (true or false). INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: Banana (II) Mental Model World Language L Language L’ Banana Banana (Yellow Curve) SENTENCE SENTENCE PROPOSITION What we have in mind? 1) There is at least a banana 2) The banana is yellow 3) The banana has curve shape 4) No matter if opened SEMANTIC GAP 19 OUR MENTAL MODEL MATCHES WITH THE REAL WORLD, SO THE SENTENCES ARE TRUE INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: Banana (III) Mental Model World Language L Language L’ Banana Banana (Yellow Curve) SENTENCE SENTENCE PROPOSITION What we have in mind? 1) There is at least a banana 2) The banana is yellow 3) The banana has curve shape 4) No matter if opened SEMANTIC GAP 20 OUR MENTAL MODEL DOES NOT MATCH WITH THE REAL WORLD, SO THE SENTENCES ARE FALSE INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: Banana (IV) THE WORLD MENTAL MODEL I mean banana as something yellow and curve, no matter if partially opened MENTAL MODEL T F FORMAL MODEL M1 21 T F FORMAL MODEL M2 I mean banana as something yellow or red, which can be one or many together, no matter how big they are, and whether they are opened or not INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Truth-values Definition: a truth valuation on a propositional language L is a mapping ν assigning to each formula A of L a truth value ν(A), namely in the domain D = {T, F} ν(A) ν(¬A) ν(A∧B) ν(A∨B) = T or F according to the modeler, with A atomic = T iff ν(A) = F = T iff ν(A) = T and ν(B) = T = T iff ν(A) = T or ν(B) = T ν(⊥) = F (since ⊥=df P∧¬P) ν(⊤) = T (since ⊤=df ¬⊥) 22 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example of truth valuation ν L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana, , , } T = { (MonkeyLow BananaHigh MonkeyGetBanana) (MonkeyLow MonkeyClimbBox) ( MonkeyLow BananaHigh MonkeyGetBanana)} MODEL 23 Informal Semantics: Formal Semantics: “If the monkey is low and the banana is high in position, then the monkey cannot get the banana. “ ν(BananaHigh) =T ν(MonkeyClimbBox) = F ν(MonkeyGetBanana) = F ν(MonkeyLow) =T INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Truth Tables To compute (in polynomial time) truth valuations, the method of truth tables was introduced (Wittgenstein, 1921). Truth tables are well-known: Truth-table (TT) for the logical constants ¬ , ∧, ∨ 24 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Truth Relation (Satisfaction Relation) Let ν be a truth valuation on language L, we define the truthrelation (or satisfaction-relation) ⊨ and write ν ⊨A (read: ν satisfies A) iff ν(A) = True Given a set of propositions Γ, we define ν⊨Γ iff if ν ⊨ θ for all formulas θ ∈ Γ 25 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Model and Satisfiability Let ν be a truth valuation on language L. ν is a model of a proposition P (set of propositions Γ) iff ν satisfies P (Γ). P (Γ) is satisfiable if there is some (at least one) truth valuation ν such that ν ⊨ P (ν ⊨ Γ). 26 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Truth and Validity Let P ν be a truth valuation on language L. is true under ν if ν ⊨ P is valid if ν ⊨ P for all ν (notation: ⊨ P) P is called a tautology P 27 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana, , , } MODEL Informal Semantics: Formal Semantics: “If the monkey is low and the banana is high in position, then the monkey cannot get the banana. “ ν(BananaHigh) =T ν(MonkeyClimbBox) = F ν(MonkeyGetBanana) = F ν(MonkeyLow) =T ν ⊨ MonkeyLow and ν ⊨ BananaHigh ν ⊨ MonkeyClimbBox and ν ⊨ MonkeyGetBanana [SATISFIABLE] MonkeyLow MonkeyLow is a tautology 28 [SATISFIABLE] [VALID] INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Entailment Propositional entailment ⊨ψ where = {θ1, ..., θn} is a finite set of propositions ν ⊨ θi for all θi in implies ν ⊨ ψ We call entailment in a model v if it holds for one model 29 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana, , , } MODEL Informal Semantics: Formal Semantics: “If the monkey is low and the banana is high in position, then the monkey cannot get the banana. “ ν(BananaHigh) =T ν(MonkeyClimbBox) = F ν(MonkeyGetBanana) = F ν(MonkeyLow) =T = {MonkeyLow, BananaHigh} ν ⊨ MonkeyLow and ν ⊨ BananaHigh implies ν ⊨ MonkeyLow BananaHigh therefore ⊨ MonkeyLow BananaHigh 30 [ENTAILMENT] INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Entailment Difference in notation ⊨ ψ iff ⊨ ψ Left side means we have already filtered out all the models that do not satisfy Right side means that we start from all models. In any case the final result is the same. 31 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Implication: Premise (I) Propositional entailment in the finite, i.e. ⊨ψ where = {θ1, ..., θn} is a finite set of propositions How to embed such a notion directly in the language? As we will see, this would allow us to use truth tables and directly reformulate entailment in terms of the other reasoning services 32 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Implication: Premise (II) Entailment can be viewed as the logical implication (θ1 ∧ θ2 ∧ ... ∧ θn) → ψ to be read θ1 ∧ θ2 ∧ ... ∧ θn logically implies ψ → 33 is a new symbol that we add to the language INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Implication and equivalence We extend our alphabet of symbols with the following defined logical constants: → (implication) ↔ (double implication or equivalence) <Atomic Formula> ::= A | B | ... | P | Q | ... | ⊥ | ⊤ <wff> ::= <Atomic Formula> | ¬<wff> | <wff>∧ <wff> | <wff>∨ <wff> | <wff> → <wff> | <wff> ↔ <wff> (new rules) The operator precedence is (from higher to lower): ¬, ∧, ∨, →, ↔ Let propositions ψ, θ, and finite set {θ1,...,θn} of propositions be given. We define: ⊨ θ → ψ iff θ ⊨ ψ ⊨ (θ1∧...∧θn) → ψ iff {θ1,...,θn} ⊨ ψ ⊨ θ ↔ ψ iff θ → ψ and ψ → θ 34 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Truth Table of → defining the semantics of → in terms of ⊨ we have the following truth-table for the logical implication P→Q: By REMEMBER: Given ν, P ⊨ Q iff ν ⊨ P then ν ⊨ Q. 35 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Three Properties of Logical Implication Property 1: For all ψ and θ: ψ → θ iff ¬ψ ∨ θ Property 2: For all ψ: ¬ψ iff ψ →⊥ Property 3: For all ψ: ⊥ ⊨ ψ (inconsistent theories imply any proposition) 36 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Examples (tautologies) Laws for ∧, ¬ and →: (A ∧ ¬B) → ¬(A → B) ¬(A → B) → (A ∧ ¬B) Pierce’s law: ((A → B) → A) → A De Morgan’s laws: ¬(A ∨ B) → (¬A ∧ ¬B) (¬A ∧ ¬B) → ¬(A ∨ B) ¬(A ∧ B) → (¬A ∨ ¬B) (¬A ∨ ¬B) → ¬(A ∧ B) 37 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Exercise (tautologies) Prove the following double implications (i.e., logical equivalences) by using truth tables. 38 (α ∧ β) ↔ (β ∧ α) Commutativity of ∧ (α ∨ β) ↔ (β ∨ α) Commutativity of ∨ ((α ∧ β) ∧ γ) ↔ (α ∧ (β ∧ γ)) Associativity of ∧ ((α ∨ β) ∨ γ) ↔ (α ∨ (β ∨ γ)): Associativity of ∨ ¬(¬α) ↔ α Double-negation elimination (α →β) ↔ (¬β →¬α) Contraposition INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Exercise (tautologies) Prove the following double implications (i.e., logical equivalences) by using truth tables. 39 (α → β) ↔ (¬α ∨ β) →-elimination (α ↔ β) ↔ ((α → β) ∧ (β → α)) ↔-elimination ¬(α ∧ β) ↔ (¬α ∨ ¬β) DeMorgan Law for ∧ ¬(α ∨ β) ↔ (¬α ∧ ¬β) DeMorgan Law for ∨ (α ∧ (β ∨ γ)) ↔ ((α ∧ β) ∨ (α ∧ γ)) Distributivity of ∧ over ∨ (α ∨ (β ∧ γ)) ↔ ((α ∨ β) ∧ (α ∨ γ)) Distributivity of ∨ over ∧ INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services The basic reasoning tasks (or “services”) we can represent (and compute) using ⊨ are: Model Checking Satisfiability Unsatisfiability Validity Entailment 40 (EVAL) (SAT) (UnSAT) (VAL) (ENT) INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: EVAL Model Checking (EVAL) Is a proposition P true under a truth-valuation ν? Check ν ⊨ P P,ν Yes EVAL No Does ν ⊨ MonkeyLow MonkeyGetBanana ? 41 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: SAT Satisfiability (SAT) Is there a truth-valuation ν where P is true? find ν such that ν ⊨ P P ν SAT No Find a ν that ν ⊨ MonkeyLow GetBanana For instance, the truth-valuation ν where both are true 42 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services (unSAT) Unsatisfiability is the impossibility to find a truth-valuation ν Monkey is satisfiable. Monkey ∨¬ Monkey is satisfiable. Monkey ∧¬ Monkey is unsatisfiable (inconsistent). In fact, for every truth-valuation ν, either ν(A) = T, so ν(¬A) = F, hence ν(P) = F; or ν(A) = F, so ν(¬A) = T, hence ν(P) = T. 43 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: VAL Validity (VAL) Is P true according to all possible truth-valuation ν? Check whether for all ν, ν ⊨ P P Yes VAL No Is P = MonkeyLow ∨ MonkeyLow valid? Yes! 44 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: ENT Entailment (ENT) All θ ∈ Γ true in ν (in all ν) implies ψ true in ν (in all ν) check Γ ⊨ ψ in ν (in all ν) by checking that: given that ν ⊨ θ for all θ ∈ Γ implies ν ⊨ ψ Γ , ψ, ν Yes ENT No Does MonkeyLow ⊨ MonkeyGetBanana ? No! Does MonkeyLow BananaHigh ⊨ MonkeyGetBanana? Yes! 45 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services (Entailment) Exercises: Demonstrate that {today} ⊨ today ∨ tomorrow Demonstrate that {today} ⊭ tomorrow Suppose P = today ∨ tomorrow. Then: 46 Define Γ such that Γ ⊨ P Define Γ such that Γ ⊭ P INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: properties (I) EVAL is the easiest task. We just test one assignment. SAT is NP complete. We need to test in the worst case all the assignments. We stop when we find one which is true. UnSAT is CO-NP. We need to test in the worst case all the assignments. We stop when we find one which is true. VAL is CO-NP. We need to test all the assignments and verify that they are all true. We stop when we find one which is false. ENT is CO-NP. It can be computed using VAL (see next slide) 47 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: properties (II) VAL(ψ) iff UnSAT( ψ) ψ = (A A) is valid, while ( A A) is unsatisfiable SAT(ψ) VAL(ψ) iff SAT( ψ) VAL( ψ) ψ = A is satisfiable in all models where ν(A) = T. Informally, the left side says that there is at least an assignment which makes A true and there is at least an assignment which makes A false; the right side says that there is at least an assignment which makes A true (in other words it makes A false) and there is at least an assignment which makes A false (in other words it makes A true). This means that not all assignments make A true (false). ⊨ ψ, where = {θ1, …, θn} iff VAL(θ1 … θn ψ) Take A ⊨ A B. the formula (A A B) is valid. 48 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Reasoning Services: properties (III) EVAL is easy. ENT can be computed using VAL VAL can be computed using UnSAT UnSAT is the opposite of SAT All reasoning tasks can be reduced to SAT!!! SAT is the most important reasoning service. 49 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Normal Forms: Literals A literal is either an atomic proposition or the negation of an atomic proposition, i.e., for all propositional variables P P and ¬P are literals. P is a positive literal ¬P is a negative literal Monkey 50 HighBanana ¬GetBanana ¬ClimbBox INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Normal Forms: Clauses A (disjunctive) clause is a disjunction of literals α1 … αn B ∨ ¬C ∨ ¬D A unit clause is a clause that contains only a single literal B and ¬C are unit clauses Monkey ∨ ¬Monkey B ∨ ¬C is not An empty clause does not contain literals 51 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Conjunctive Normal Form (CNF) A proposition is in conjunctive normal form (CNF) if it is a (finite) conjunction of (disjunctive) clauses Examples of formulas in CNF: ¬A ∧ B (A ∨ ¬B) ∧ (B ∨ ¬C ∨ ¬D) A ∧ (B ∨ C ∨ ¬D) A B (¬ A C) (B ¬ D E) Examples of formulas NOT in CNF: ¬(A ∧ B) ¬ is the outmost operator A ∧ (B ∨ C ∧ ¬D) ∧ is nested within ∨ 52 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Conversion of a formula to CNF Theorem (e.g. Mendelson, 1987 [Prop. 1.4, Ex. 1.41(a)]) Every formula P has an equivalent CNF, namely P can be converted (in polynomial time) into a proposition Q such that: Q is in CNF P and Q are equivalent (i.e., have the same truth table) A conversion to a CNF that operates as in the theorem above is said to be complete The algorithm implementing the conversion to a CNF is based on the tautologies about logical equivalence (or double implication): 53 Double-negation law (i.e. elimination of ¬¬) De Morgan’s laws Distributive laws Elimination of → and INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Conversion to CNF: Basic Tautologies (α → β) ↔ (¬α ∨ β)c →-elimination (α ↔ β) ↔ ((α → β) ∧ (β → α)) ↔-elimination ¬(α ∧ β) ↔ (¬α ∨ ¬β) DeMorgan Law for ∧ ¬(α ∨ β) ↔ (¬α ∧ ¬β) DeMorgan Law for ∨ (α ∧ (β ∨ γ)) ↔ ((α ∧ β) ∨ (α ∧ γ)) Distributivity of ∧ over ∨ (α ∨ (β ∧ γ)) ↔ ((α ∨ β) ∧ (α ∨ γ)) Distributivity of ∨ over ∧ ¬(¬α) ↔ α Double-negation elimination 54 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Example: Conversion to CNF of A ↔ (B ∨ C) 1. Eliminate ↔: (A→(B ∨C)) ∧ ((B ∨C) →A) 2. Eliminate →: (¬A∨B ∨C) ∧ (¬(B ∨C) ∨A) 3. Move ¬ inwards using de Morgan’s laws: (¬A∨B ∨C) ∧ ((¬B ∧¬C) ∨A) 4. Apply distributivity of ∨ over ∧ and flatten: (¬A∨B ∨C) ∧ (¬B ∨A) ∧ (¬C ∨A) (*) (*) in CNF and equivalent to ‘A↔(B∨C)’. 55 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Normal Forms: Conjunctive clauses A conjunctive clause is a conjunction of literals α1 … αn B ¬C ¬D Monkey ¬Monkey NOTE: a conjunctive clause IS NOT a clause! 56 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Disjunctive Normal Form (DNF) A proposition is in disjunctive normal form (DNF) if it is a (finite) disjunction of conjunctive clauses Examples of formulas in DNF: ¬A ∨ B (A ∧ ¬B) ∨ (B ∧ ¬C ∧ ¬D) A ∨ (B ∧ C ∧ ¬D) A ∨ B ∨ (¬ A ∧ C) ∨ (B ∧ ¬ D ∧ E) Examples of formulas NOT in DNF: ¬(A ∨ B) ¬ is the outmost operator A ∨ (B ∨ C ∧ ¬D) ∧ is nested within ∨ 57 INTRODUCTION :: SYNTAX :: SEMANTICS :: LOGICAL IMPLICATION :: REASONING SERVICES :: NORMAL FORMS Horn clauses A Horn clause is a (disjunctive) clause with at most one positive literal. ¬A A¬B¬D ¬AB¬D NOTE: ¬ A ¬ B D is equivalent to A B D 58