SlideShare a Scribd company logo
1 of 32
Propositional and
First-Order Logic



                    1
Propositional Logic




                      2
Propositional logic
• Proposition : A proposition is classified as a declarative
  sentence which is either true or false.
  eg: 1) It rained yesterday.
• Propositional symbols/variables: P, Q, S, ... (atomic
  sentences)
• Sentences are combined by Connectives:
   ∧ ...and            [conjunction]
   ∨ ...or             [disjunction]
   ⇒ ...implies        [implication / conditional]
   ⇔ ..is equivalent   [biconditional]
   ¬ ...not            [negation]
• Literal: atomic sentence or negated atomic sentence
                                                               3
Propositional logic (PL)
  Sentence or well formed formula
• A sentence (well formed formula) is defined as follows:
  – A symbol is a sentence
  – If S is a sentence, then ¬S is a sentence
  – If S is a sentence, then (S) is a sentence
  – If S and T are sentences, then (S ∨ T), (S ∧ T), (S → T), and (S ↔ T) are
    sentences
  – A sentence results from a finite number of applications of the above rules




                                                                                 5
Laws of Algebra of Propositions
• Idempotent:
  pVp≡p              pΛp≡p

• Commutative:
  pVq≡qVp            pΛq≡qΛp

• Complement:
  p V ~p ≡ T         p Λ ~p ≡ F

• Double Negation:
  ~(~p) ≡ p

                                    7
• Associative:
  p V (q V r) ≡ (p V q) V r
  p Λ (q Λ r) ≡ (p Λ q) Λ r

• Distributive:
  p V (q Λ r) ≡ (p V q) Λ (p V r)
  p Λ (q V r) ≡ (p Λ q) V (p Λ r)

• Absorbtion:
  p V (p Λ q) ≡ p
  p Λ (p V q) ≡ p

• Identity:
  pVT≡T                             pΛT≡p
  pVF≡p                             pΛF≡F   8
• De Morgan’s
  ~(p V q) ≡ ~p Λ ~q
  ~(p Λ q) ≡ ~p V ~q

• Equivalence of Contrapositive:
  p → q ≡ ~q → ~p

• Others:
  p → q ≡ ~p V q
  p ↔ q ≡ (p → q) Λ (q → p)




                                   9
Tautologies and contradictions
• A tautology is a sentence that is True under all
  interpretations.
• An contradiction is a sentence that is False under all
  interpretations.
   p       ¬p     p ∨¬p          p       ¬p     p ∧¬p
   F       T        T            F       T        F
   T       F        T            T       F        F



                                                       10

                                                            L3
Tautology by truth table
p q ¬p p ∨q ¬p ∧(p ∨q )   [¬p ∧(p ∨q )]→q

T T    F   T      F             T

T F    F   T      F             T

F T    T   T      T             T

F F    T   F      F             T

                                       11

                                            L3
Propositional Logic - one last proof
  Show that [p ∧ (p → q)] → q is a tautology.
  We use ≡ to show that [p ∧ (p → q)] → q ≡ T.
[p ∧ (p → q)] → q
          ≡ [p ∧ (¬p ∨ q)] → q         substitution for →
          ≡ [(p ∧ ¬p) ∨ (p ∧ q)] → q   distributive
          ≡ [ F ∨ (p ∧ q)] → q         complement
          ≡ (p ∧ q) → q                identity
          ≡ ¬(p ∧ q) ∨ q               substitution for →
          ≡ (¬p ∨ ¬q) ∨ q              DeMorgan’s
          ≡ ¬p ∨ (¬q ∨ q )             associative
          ≡ ¬p ∨ T                     complement
          ≡T                           identity
            11/09/12

                                                            12
Logical Equivalence of
 Conditional and Contrapositive
The easiest way to check for logical equivalence is to
 see if the truth tables of both variants have
 identical last columns:

 p     q    p →q      p     q   ¬q    ¬p    ¬q→¬p
 T     T      T       T     T   F     F       T
 T     F      F       T     F   T     F       F
 F     T      T       F     T   F     T       T
 F     F      T       F     F   T     T       T

                                                    13

                                                         L3
Table of Logical Equivalences

• Identity laws
   Like adding 0
• Domination laws
   Like multiplying by 0
• Idempotent laws
   Delete redundancies
• Double negation
   “I don’t like you, not”
• Commutativity
   Like “x+y = y+x”
• Associativity
   Like “(x+y)+z = y+(x+z)”
• Distributivity
   Like “(x+y)z = xz+yz”                 14

• De Morgan                                   L3
Table of Logical Equivalences




• Excluded middle
• Negating creates opposite
• Definition of implication in terms
  of Not and Or




                                        15

                                             L3
Inference rules
• Logical inference is used to create new sentences that
  logically follow from a given set of predicate calculus
  sentences (KB).




                                                            16
Sound rules of inference
• Here are some examples of sound rules of inference
  – A rule is sound if its conclusion is true whenever the premise is true
• Each can be shown to be sound using a truth table
  RULE                             PREMISE                     CONCLUSION
  Modus Ponens                 A, A → B                                 B
  And Introduction/Conjuction A, B                                      A∧B
  And Elimination/SimplificationA ∧ B                                   A
  Double Negation              ¬¬A                                      A
  Unit Resolution              A ∨ B, ¬B                                A
  Resolution                   A ∨ B, ¬B ∨ C                            A∨ C


                                                                               17
Soundness of modus ponens

        A           B       A→B   OK?
True        True        True
                                  √
True        False       False
                                  √
False       True        True
                                  √
False       False       True
                                  √
                                        18
Soundness of the
resolution inference rule




                            19
Proving things
• A proof is a sequence of sentences, where each sentence is either a
  premise or a sentence derived from earlier sentences in the proof
  by one of the rules of inference.
• The last sentence is the theorem (also called goal or query) that
  we want to prove.
• Example for the “weather problem” given above.
  1 Hu          Premise                 “It is humid”

  2 Hu→Ho       Premise                 “If it is humid, it is hot”

  3 Ho          Modus Ponens(1,2)       “It is hot”

  4 (Ho∧Hu)→R Premise                   “If it’s hot & humid, it’s raining”

  5 Ho∧Hu       And Introduction(1,3)   “It is hot and humid”

  6R            Modus Ponens(4,5)       “It is raining”
                                                                              20
Problems with Propositional Logic




                                    21
Propositional logic is a weak language
• Hard to identify “individuals” (e.g., Mary, 3)
• Can’t directly talk about properties of individuals or
  relations between individuals (e.g., “Bill is tall”)
• Generalizations, patterns, regularities can’t easily be
  represented (e.g., “all triangles have 3 sides”)
• First-Order Logic (abbreviated FOL or FOPC) is expressive
  enough to concisely represent this kind of information
  FOL adds relations, variables, and quantifiers, e.g.,
   • “Every elephant is gray”: ∀ x (elephant(x) → gray(x))
   • “There is a white alligator”: ∃ x (alligator(X) ^ white(X))


                                                                   22
First-Order Logic




                    23
First-order logic
• First-order logic (FOL) models the world in terms of
  –   Objects, which are things with individual identities
  –   Properties of objects that distinguish them from other objects
  –   Relations that hold among sets of objects
  –   Functions, which are a subset of relations where there is only one
      “value” for any given “input”
• Examples:
  – Objects: Students, lectures, companies, cars ...
  – Relations: Brother-of, bigger-than, outside, part-of, has-color,
    occurs-after, owns, visits, precedes, ...
  – Properties: blue, oval, even, large, ...
  – Functions: father-of, best-friend, second-half, one-more-than ...


                                                                           24
User provides
• Constant symbols, which represent individuals in the world
   – Mary
   –3
   – Green
• Function symbols, which map individuals to individuals
   – father-of(Mary) = John
   – color-of(Sky) = Blue
• Predicate symbols, which map individuals to truth values
   – greater(5,3)
   – green(Grass)
   – color(Grass, Green)
                                                               25
FOL Provides
• Variable symbols
   – E.g., x, y, foo
• Connectives
   – Same as in PL: not (¬), and (∧), or (∨), implies (→), if
     and only if (biconditional ↔)
• Quantifiers
   – Universal ∀x or (Ax)
   – Existential ∃x or (Ex)




                                                                26
Quantifiers
• Universal quantification
   – (∀x)P(x) means that P holds for all values of x in the
     domain associated with that variable
   – E.g., (∀x) dolphin(x) → mammal(x)
• Existential quantification
   – (∃ x)P(x) means that P holds for some value of x in the
     domain associated with that variable
   – E.g., (∃ x) mammal(x) ∧ lays-eggs(x)
   – Permits one to make a statement about some object
     without naming it



                                                               27
Quantifiers
• Universal quantifiers are often used with “implies” to form “rules”:
  (∀x) student(x) → smart(x) means “All students are smart”
• Universal quantification is rarely used to make blanket statements
  about every individual in the world:
  (∀x)student(x)∧smart(x) means “Everyone in the world is a student and is smart”
• Existential quantifiers are usually used with “and” to specify a list of
  properties about an individual:
  (∃x) student(x) ∧ smart(x) means “There is a student who is smart”
• A common mistake is to represent this English sentence as the FOL
  sentence:
  (∃x) student(x) → smart(x)
  – But what happens when there is a person who is not a student?


                                                                               28
Quantifier Scope
• Switching the order of universal quantifiers does not change
  the meaning:
   – (∀x)(∀y)P(x,y) ↔ (∀y)(∀x) P(x,y)
• Similarly, you can switch the order of existential
  quantifiers:
   – (∃x)(∃y)P(x,y) ↔ (∃y)(∃x) P(x,y)
• Switching the order of universals and existentials does
  change meaning:
   – Everyone likes someone: (∀x)(∃y) likes(x,y)
   – Someone is liked by everyone: (∃y)(∀x) likes(x,y)

                                                                 29
Connections between All and Exists

 We can relate sentences involving ∀ and ∃
 using De Morgan’s laws:
     (∀x) ¬P(x) ↔ ¬(∃x) P(x)
     ¬(∀x) P ↔ (∃x) ¬P(x)
     (∀x) P(x) ↔ ¬ (∃x) ¬P(x)
     (∃x) P(x) ↔ ¬(∀x) ¬P(x)




                                             30
Quantified inference rules
• Universal instantiation
    ∀x P(x) ∴ P(A)
• Universal generalization
  – P(A) ∧ P(B) … ∴ ∀x P(x)
• Existential instantiation
    ∃x P(x) ∴P(F)
• Existential generalization
  – P(A) ∴ ∃x P(x)




                                     31
Universal instantiation
        (a.k.a. universal elimination)
• If (∀x) P(x) is true, then P(C) is true, where C is any
  constant in the domain of x
• Example:
   (∀x) eats(Ziggy, x) ⇒ eats(Ziggy, IceCream)




                                                            32
Translating English to FOL
Every gardener likes the sun.
    ∀x gardener(x) → likes(x,Sun)
You can fool some of the people all of the time.
    ∃x ∀t person(x) ∧time(t) → can-fool(x,t)
You can fool all of the people some of the time.
    ∀x ∃t (person(x) → time(t) ∧can-fool(x,t))
                                                   Equivalent
    ∀x (person(x) → ∃t (time(t) ∧can-fool(x,t))
All purple mushrooms are poisonous.
    ∀x (mushroom(x) ∧ purple(x)) → poisonous(x)
No purple mushroom is poisonous.
    ¬∃x purple(x) ∧ mushroom(x) ∧ poisonous(x)
    ∀x (mushroom(x) ∧ purple(x)) → ¬poisonous(x)      Equivalent
Clinton is not tall.
    ¬tall(Clinton)




                                                                   33
34

More Related Content

What's hot

Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and LiftingMegha Sharma
 
Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3SURBHI SAROHA
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR Zahid Parvez
 
First order predicate logic(fopl)
First order predicate logic(fopl)First order predicate logic(fopl)
First order predicate logic(fopl)surbhi jha
 
NAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERNAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERKnoldus Inc.
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionAdnan Masood
 
Goal stack planning.ppt
Goal stack planning.pptGoal stack planning.ppt
Goal stack planning.pptSadagopanS
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)ananth
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 
Spell checker using Natural language processing
Spell checker using Natural language processing Spell checker using Natural language processing
Spell checker using Natural language processing Sandeep Wakchaure
 
Introdution and designing a learning system
Introdution and designing a learning systemIntrodution and designing a learning system
Introdution and designing a learning systemswapnac12
 

What's hot (20)

Bayesian networks
Bayesian networksBayesian networks
Bayesian networks
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and Lifting
 
Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3Knowledge Representation & Reasoning AI UNIT 3
Knowledge Representation & Reasoning AI UNIT 3
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
First order predicate logic(fopl)
First order predicate logic(fopl)First order predicate logic(fopl)
First order predicate logic(fopl)
 
NAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIERNAIVE BAYES CLASSIFIER
NAIVE BAYES CLASSIFIER
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief Introduction
 
Goal stack planning.ppt
Goal stack planning.pptGoal stack planning.ppt
Goal stack planning.ppt
 
First order logic
First order logicFirst order logic
First order logic
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
First order logic
First order logicFirst order logic
First order logic
 
An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)An overview of Hidden Markov Models (HMM)
An overview of Hidden Markov Models (HMM)
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Spell checker using Natural language processing
Spell checker using Natural language processing Spell checker using Natural language processing
Spell checker using Natural language processing
 
Introdution and designing a learning system
Introdution and designing a learning systemIntrodution and designing a learning system
Introdution and designing a learning system
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 

Viewers also liked

Viewers also liked (7)

Propositional logic & inference
Propositional logic & inferencePropositional logic & inference
Propositional logic & inference
 
Per3 logika&pembuktian
Per3 logika&pembuktianPer3 logika&pembuktian
Per3 logika&pembuktian
 
Bayes Theorem
Bayes TheoremBayes Theorem
Bayes Theorem
 
Translating English to Propositional Logic
Translating English to Propositional LogicTranslating English to Propositional Logic
Translating English to Propositional Logic
 
Logic
LogicLogic
Logic
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logic
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 

Similar to Propositional First-Order Logic Rules Quantifiers

Similar to Propositional First-Order Logic Rules Quantifiers (20)

L01.ppt
L01.pptL01.ppt
L01.ppt
 
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكروDiscrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
 
logic_lec4.ppt
logic_lec4.pptlogic_lec4.ppt
logic_lec4.ppt
 
DS Lecture 2.ppt
DS Lecture 2.pptDS Lecture 2.ppt
DS Lecture 2.ppt
 
DMS UNIT-1 ppt.pptx
DMS UNIT-1 ppt.pptxDMS UNIT-1 ppt.pptx
DMS UNIT-1 ppt.pptx
 
UGC NET Computer Science & Application book.pdf [Sample]
UGC NET Computer Science & Application book.pdf  [Sample]UGC NET Computer Science & Application book.pdf  [Sample]
UGC NET Computer Science & Application book.pdf [Sample]
 
Discrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.pptDiscrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.ppt
 
CS202Ch1.ppt
CS202Ch1.pptCS202Ch1.ppt
CS202Ch1.ppt
 
MFCS PPT.pdf
MFCS PPT.pdfMFCS PPT.pdf
MFCS PPT.pdf
 
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
Unit III  Knowledge Representation in AI   K.Sundar,AP/CSE,VECUnit III  Knowledge Representation in AI   K.Sundar,AP/CSE,VEC
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
 
Discrete mathematics
Discrete mathematicsDiscrete mathematics
Discrete mathematics
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Logic
LogicLogic
Logic
 
Slide subtopic 4
Slide subtopic 4Slide subtopic 4
Slide subtopic 4
 
Slide subtopic 2
Slide subtopic 2Slide subtopic 2
Slide subtopic 2
 
Slide subtopic 2
Slide subtopic 2Slide subtopic 2
Slide subtopic 2
 
dm-logic.pdf
dm-logic.pdfdm-logic.pdf
dm-logic.pdf
 
Logic
LogicLogic
Logic
 
dma_ppt.pdf
dma_ppt.pdfdma_ppt.pdf
dma_ppt.pdf
 
Discrete structures & optimization unit 1
Discrete structures & optimization unit 1Discrete structures & optimization unit 1
Discrete structures & optimization unit 1
 

More from ankush_kumar

mathematical induction
mathematical inductionmathematical induction
mathematical inductionankush_kumar
 
mathematical induction
mathematical inductionmathematical induction
mathematical inductionankush_kumar
 
mathematical induction
mathematical inductionmathematical induction
mathematical inductionankush_kumar
 
mathematical induction
mathematical inductionmathematical induction
mathematical inductionankush_kumar
 
Soacial networking 3
Soacial networking  3Soacial networking  3
Soacial networking 3ankush_kumar
 
Soacial networking 1
Soacial networking  1Soacial networking  1
Soacial networking 1ankush_kumar
 
Memory organisation
Memory organisationMemory organisation
Memory organisationankush_kumar
 
Social networking 2
Social networking 2Social networking 2
Social networking 2ankush_kumar
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloadingankush_kumar
 
Set theory and relation
Set theory and relationSet theory and relation
Set theory and relationankush_kumar
 

More from ankush_kumar (14)

Social Networking
Social NetworkingSocial Networking
Social Networking
 
mathematical induction
mathematical inductionmathematical induction
mathematical induction
 
mathematical induction
mathematical inductionmathematical induction
mathematical induction
 
mathematical induction
mathematical inductionmathematical induction
mathematical induction
 
mathematical induction
mathematical inductionmathematical induction
mathematical induction
 
Inheritance
InheritanceInheritance
Inheritance
 
Oops
OopsOops
Oops
 
Soacial networking 3
Soacial networking  3Soacial networking  3
Soacial networking 3
 
Soacial networking 1
Soacial networking  1Soacial networking  1
Soacial networking 1
 
Memory organisation
Memory organisationMemory organisation
Memory organisation
 
Social networking 2
Social networking 2Social networking 2
Social networking 2
 
Linked list
Linked listLinked list
Linked list
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
Set theory and relation
Set theory and relationSet theory and relation
Set theory and relation
 

Propositional First-Order Logic Rules Quantifiers

  • 3. Propositional logic • Proposition : A proposition is classified as a declarative sentence which is either true or false. eg: 1) It rained yesterday. • Propositional symbols/variables: P, Q, S, ... (atomic sentences) • Sentences are combined by Connectives: ∧ ...and [conjunction] ∨ ...or [disjunction] ⇒ ...implies [implication / conditional] ⇔ ..is equivalent [biconditional] ¬ ...not [negation] • Literal: atomic sentence or negated atomic sentence 3
  • 4. Propositional logic (PL) Sentence or well formed formula • A sentence (well formed formula) is defined as follows: – A symbol is a sentence – If S is a sentence, then ¬S is a sentence – If S is a sentence, then (S) is a sentence – If S and T are sentences, then (S ∨ T), (S ∧ T), (S → T), and (S ↔ T) are sentences – A sentence results from a finite number of applications of the above rules 5
  • 5. Laws of Algebra of Propositions • Idempotent: pVp≡p pΛp≡p • Commutative: pVq≡qVp pΛq≡qΛp • Complement: p V ~p ≡ T p Λ ~p ≡ F • Double Negation: ~(~p) ≡ p 7
  • 6. • Associative: p V (q V r) ≡ (p V q) V r p Λ (q Λ r) ≡ (p Λ q) Λ r • Distributive: p V (q Λ r) ≡ (p V q) Λ (p V r) p Λ (q V r) ≡ (p Λ q) V (p Λ r) • Absorbtion: p V (p Λ q) ≡ p p Λ (p V q) ≡ p • Identity: pVT≡T pΛT≡p pVF≡p pΛF≡F 8
  • 7. • De Morgan’s ~(p V q) ≡ ~p Λ ~q ~(p Λ q) ≡ ~p V ~q • Equivalence of Contrapositive: p → q ≡ ~q → ~p • Others: p → q ≡ ~p V q p ↔ q ≡ (p → q) Λ (q → p) 9
  • 8. Tautologies and contradictions • A tautology is a sentence that is True under all interpretations. • An contradiction is a sentence that is False under all interpretations. p ¬p p ∨¬p p ¬p p ∧¬p F T T F T F T F T T F F 10 L3
  • 9. Tautology by truth table p q ¬p p ∨q ¬p ∧(p ∨q ) [¬p ∧(p ∨q )]→q T T F T F T T F F T F T F T T T T T F F T F F T 11 L3
  • 10. Propositional Logic - one last proof Show that [p ∧ (p → q)] → q is a tautology. We use ≡ to show that [p ∧ (p → q)] → q ≡ T. [p ∧ (p → q)] → q ≡ [p ∧ (¬p ∨ q)] → q substitution for → ≡ [(p ∧ ¬p) ∨ (p ∧ q)] → q distributive ≡ [ F ∨ (p ∧ q)] → q complement ≡ (p ∧ q) → q identity ≡ ¬(p ∧ q) ∨ q substitution for → ≡ (¬p ∨ ¬q) ∨ q DeMorgan’s ≡ ¬p ∨ (¬q ∨ q ) associative ≡ ¬p ∨ T complement ≡T identity 11/09/12 12
  • 11. Logical Equivalence of Conditional and Contrapositive The easiest way to check for logical equivalence is to see if the truth tables of both variants have identical last columns: p q p →q p q ¬q ¬p ¬q→¬p T T T T T F F T T F F T F T F F F T T F T F T T F F T F F T T T 13 L3
  • 12. Table of Logical Equivalences • Identity laws Like adding 0 • Domination laws Like multiplying by 0 • Idempotent laws Delete redundancies • Double negation “I don’t like you, not” • Commutativity Like “x+y = y+x” • Associativity Like “(x+y)+z = y+(x+z)” • Distributivity Like “(x+y)z = xz+yz” 14 • De Morgan L3
  • 13. Table of Logical Equivalences • Excluded middle • Negating creates opposite • Definition of implication in terms of Not and Or 15 L3
  • 14. Inference rules • Logical inference is used to create new sentences that logically follow from a given set of predicate calculus sentences (KB). 16
  • 15. Sound rules of inference • Here are some examples of sound rules of inference – A rule is sound if its conclusion is true whenever the premise is true • Each can be shown to be sound using a truth table RULE PREMISE CONCLUSION Modus Ponens A, A → B B And Introduction/Conjuction A, B A∧B And Elimination/SimplificationA ∧ B A Double Negation ¬¬A A Unit Resolution A ∨ B, ¬B A Resolution A ∨ B, ¬B ∨ C A∨ C 17
  • 16. Soundness of modus ponens A B A→B OK? True True True √ True False False √ False True True √ False False True √ 18
  • 17. Soundness of the resolution inference rule 19
  • 18. Proving things • A proof is a sequence of sentences, where each sentence is either a premise or a sentence derived from earlier sentences in the proof by one of the rules of inference. • The last sentence is the theorem (also called goal or query) that we want to prove. • Example for the “weather problem” given above. 1 Hu Premise “It is humid” 2 Hu→Ho Premise “If it is humid, it is hot” 3 Ho Modus Ponens(1,2) “It is hot” 4 (Ho∧Hu)→R Premise “If it’s hot & humid, it’s raining” 5 Ho∧Hu And Introduction(1,3) “It is hot and humid” 6R Modus Ponens(4,5) “It is raining” 20
  • 20. Propositional logic is a weak language • Hard to identify “individuals” (e.g., Mary, 3) • Can’t directly talk about properties of individuals or relations between individuals (e.g., “Bill is tall”) • Generalizations, patterns, regularities can’t easily be represented (e.g., “all triangles have 3 sides”) • First-Order Logic (abbreviated FOL or FOPC) is expressive enough to concisely represent this kind of information FOL adds relations, variables, and quantifiers, e.g., • “Every elephant is gray”: ∀ x (elephant(x) → gray(x)) • “There is a white alligator”: ∃ x (alligator(X) ^ white(X)) 22
  • 22. First-order logic • First-order logic (FOL) models the world in terms of – Objects, which are things with individual identities – Properties of objects that distinguish them from other objects – Relations that hold among sets of objects – Functions, which are a subset of relations where there is only one “value” for any given “input” • Examples: – Objects: Students, lectures, companies, cars ... – Relations: Brother-of, bigger-than, outside, part-of, has-color, occurs-after, owns, visits, precedes, ... – Properties: blue, oval, even, large, ... – Functions: father-of, best-friend, second-half, one-more-than ... 24
  • 23. User provides • Constant symbols, which represent individuals in the world – Mary –3 – Green • Function symbols, which map individuals to individuals – father-of(Mary) = John – color-of(Sky) = Blue • Predicate symbols, which map individuals to truth values – greater(5,3) – green(Grass) – color(Grass, Green) 25
  • 24. FOL Provides • Variable symbols – E.g., x, y, foo • Connectives – Same as in PL: not (¬), and (∧), or (∨), implies (→), if and only if (biconditional ↔) • Quantifiers – Universal ∀x or (Ax) – Existential ∃x or (Ex) 26
  • 25. Quantifiers • Universal quantification – (∀x)P(x) means that P holds for all values of x in the domain associated with that variable – E.g., (∀x) dolphin(x) → mammal(x) • Existential quantification – (∃ x)P(x) means that P holds for some value of x in the domain associated with that variable – E.g., (∃ x) mammal(x) ∧ lays-eggs(x) – Permits one to make a statement about some object without naming it 27
  • 26. Quantifiers • Universal quantifiers are often used with “implies” to form “rules”: (∀x) student(x) → smart(x) means “All students are smart” • Universal quantification is rarely used to make blanket statements about every individual in the world: (∀x)student(x)∧smart(x) means “Everyone in the world is a student and is smart” • Existential quantifiers are usually used with “and” to specify a list of properties about an individual: (∃x) student(x) ∧ smart(x) means “There is a student who is smart” • A common mistake is to represent this English sentence as the FOL sentence: (∃x) student(x) → smart(x) – But what happens when there is a person who is not a student? 28
  • 27. Quantifier Scope • Switching the order of universal quantifiers does not change the meaning: – (∀x)(∀y)P(x,y) ↔ (∀y)(∀x) P(x,y) • Similarly, you can switch the order of existential quantifiers: – (∃x)(∃y)P(x,y) ↔ (∃y)(∃x) P(x,y) • Switching the order of universals and existentials does change meaning: – Everyone likes someone: (∀x)(∃y) likes(x,y) – Someone is liked by everyone: (∃y)(∀x) likes(x,y) 29
  • 28. Connections between All and Exists We can relate sentences involving ∀ and ∃ using De Morgan’s laws: (∀x) ¬P(x) ↔ ¬(∃x) P(x) ¬(∀x) P ↔ (∃x) ¬P(x) (∀x) P(x) ↔ ¬ (∃x) ¬P(x) (∃x) P(x) ↔ ¬(∀x) ¬P(x) 30
  • 29. Quantified inference rules • Universal instantiation ∀x P(x) ∴ P(A) • Universal generalization – P(A) ∧ P(B) … ∴ ∀x P(x) • Existential instantiation ∃x P(x) ∴P(F) • Existential generalization – P(A) ∴ ∃x P(x) 31
  • 30. Universal instantiation (a.k.a. universal elimination) • If (∀x) P(x) is true, then P(C) is true, where C is any constant in the domain of x • Example: (∀x) eats(Ziggy, x) ⇒ eats(Ziggy, IceCream) 32
  • 31. Translating English to FOL Every gardener likes the sun. ∀x gardener(x) → likes(x,Sun) You can fool some of the people all of the time. ∃x ∀t person(x) ∧time(t) → can-fool(x,t) You can fool all of the people some of the time. ∀x ∃t (person(x) → time(t) ∧can-fool(x,t)) Equivalent ∀x (person(x) → ∃t (time(t) ∧can-fool(x,t)) All purple mushrooms are poisonous. ∀x (mushroom(x) ∧ purple(x)) → poisonous(x) No purple mushroom is poisonous. ¬∃x purple(x) ∧ mushroom(x) ∧ poisonous(x) ∀x (mushroom(x) ∧ purple(x)) → ¬poisonous(x) Equivalent Clinton is not tall. ¬tall(Clinton) 33
  • 32. 34