1
Chapter 7
Propositional and Predicate Logic
2
What is Artificial Intelligence?
z A more difficult question is: What is intelligence?
z This question has puzzled philosophers,
biologists and psychologists for centuries.
z Artificial Intelligence is easier to define, although
there is no standard, accepted definition.
評判 搜尋解答 邏輯推理
記憶 控制 學習 創作
weak sub? strong
Fuzzy,NN,GA
In my opinion:
星艦戰將與
蝸蟲的學習
3
Chapter 7 Contents
z What is Logic?
z Logical Operators
z Translating between
English and Logic
z Truth Tables
z Complex Truth Tables
z Tautology
z Equivalence
z Propositional Logic
z Deduction
z Predicate Calculus
z Quantifiers ∀ and ∃
z Properties of logical
systems
z Abduction and
inductive reasoning
z (Modal logic)
4
What is Logic?
z Reasoning about the validity of arguments.
z An argument is valid if its conclusions follow
logically from its premises – even if the argument
doesn’t actually reflect the real world:
„ All lemons are blue
„ Mary is a lemon
„ Therefore, Mary is blue.
5
Logical Operators
z And Λ
z Or V
z Not
z Implies → (if… then…)
z Iff ↔ (if and only if)
6
Translating between English and Logic
z Facts and rules need to be translated into
logical notation.
z For example:
„ It is Raining and it is Thursday:
„ R Λ T
„ R means “It is Raining”, T means “it is Thursday”.
7
Translating between English and Logic
z More complex sentences need predicates.
E.g.:
„ It is raining in New York:
„ R(N)
„ Could also be written N(R), or even just R.
z It is important to select the correct level of
detail for the concepts you want to reason
about.
8
Truth Tables
z Tables that show truth values for all
possible inputs to a logical operator.
z For example:
z A truth table shows the semantics of
a logical operator.
9
Complex Truth Tables
z We can produce
truth tables for
complex logical
expressions, which
show the overall
value of the
expression for all
possible
combinations of
variables:
10
Tautology (恆真式)
z The expression A v ¬A is a tautology.
z This means it is always true, regardless of the
value of A.
z A is a tautology: this is written
╞
„ A tautology is true under any interpretation.
„ An expression which is false under any
interpretation is contradictory.
z 一切數學證明的動作來自: ╞ (P ^(PÆQ) Æ Q)
或者強調那是動作的結果: P ^(PÆQ)├ Q
11
Equivalence
z Two expressions are equivalent if
they always have the same logical
value under any interpretation:
„A Λ B ≡ B Λ A
z Equivalences can be proven by
examining truth tables.
12
Some Useful Equivalences
z A v A ≡ A
z A Λ A ≡ A
z A Λ (B Λ C) ≡ (A Λ B) Λ C
z A v (B v C) ≡ (A v B) v C
z A Λ (B v C) ≡ (A Λ B) v (A Λ C)
z A Λ (A v B) ≡ A
z A v (A Λ B) ≡ A
z A Λ true ≡ A A Λ false ≡ false
z A v true ≡ true A v false ≡ A
13
Propositional Logic (命題邏輯)
z Propositional logic is a logical system.
z It deals with propositions.
„ Inference (what results from assumptions?)
„ Reasoning (is it true or not?)
z Propositional Calculus is the language we
use to reason about propositional logic.
z A sentence in propositional logic is called
a well-formed formula (wff).
„ Wff: English Æ logic sentence
14
Propositional Logic
z The following are wff’s:
z P, Q, R…
z true, false
z (A)
z ¬A
z A Λ B
z A v B
z A → B
z A ↔ B
定義 PÆQ ≡ ¬ P V Q (真值表比對)
e.g.
Tall ^ Strong Æ Ball_Player
≡ ¬ (Tall ^ Strong) V Ball_Player
≡ ¬ Tall V ¬ Strong V Ball_Player
15
Chapter 7 Contents
z What is Logic?
z Logical Operators
z Translating between
English and Logic
z Truth Tables
z Complex Truth Tables
z Tautology
z Equivalence
z Propositional Logic
z Deduction
z Predicate Calculus
z Quantifiers ∀ and ∃
z Properties of logical
systems
z Abduction and
inductive reasoning
z (Modal logic)
Recall:
16
Deduction
z The process of deriving a conclusion from a set of
assumptions.
z Use a set of rules, such as:
A A → B
B
(modus ponens… 拉丁文:推論法)
z If we deduce a conclusion C from a set of
assumptions, we write:
z {A1, A2, …, An} ├ C
7.11(p.191 ~ p.195)
17
Deduction - Example
(1)以推導方式取代真值表驗證,更簡單而有意義;
(2)但盲目的推導方法類似盲目搜尋,在chap 8 有改良的方法。
18
Predicate Calculus (述語推算)
z Predicate Calculus extends the syntax of
propositional calculus with predicates and
quantifiers:
„ P(X) – P is a predicate.
z First Order Predicate Calculus (FOPC)
allows predicates to apply to objects or
terms, but not functions or predicates.
19
Quantifiers ∀ and ∃
z ∀ - For all:
„ ∀xP(x) is read “For all x’es, P (x) is true”.
z ∃ - There Exists:
„ ∃x P(x) is read “there exists an x such that P(x) is
true”.
z Relationship between the quantifiers:
„ ∃x P(x) ≡ ¬(∀x)¬P(x)
„ “If There exists an x for which P holds, then it is not
true that for all x P does not hold”.
∃x Like(x, War) ≡ ¬(∀x) ¬Like(x, War)
20
Deduction over FOPC --- Search
z Dog(X) ^ Meets(X,Y)^Dislikes(X,Y) Æ Barks_at(X,Y)
z Close_to(Z, DormG) Æ Meets(Snoopy, Z)
z Man(W) Æ Dislikes(Snoopy, W)
z Man(John), Dog(Snoopy), Close_to(John,DormG)
z Dog(X) ^ Meets(X,Y)^Dislikes(X,Y) Æ Barks_at(X,Y)
z Close_to(Z, DormG) Æ Meets(Snoopy, Z)
z Dislikes(Snoopy, John)
z Dog(Snoopy), Close_to(John,DormG)
{John/W}
Barks_at(Snoopy,John)
??
21
Deduction over FOPC --- Goal Tree
Barks_at(Snoopy,John)?
Dog(Snoopy) Meets(Snoopy,John) Dislikes(Snoopy,John)
Close_to(John,DormG) Man(John) Other_Resons
Yes Yes
Yes
{Snoopy/X}
{John/Y}
{John/Y}
{John/Z} {John/W}
Recall:
22
Properties of Logical Systems
z Soundness(可靠): Is every theorem valid?
z Completeness(週延): Is every tautology a
theorem?
z Decidability(可推導): Does an algorithm exist that
will determine if a wff is valid?
z Monotonicity(不受破壞): Can a valid logical proof
be made invalid by adding additional premises or
assumptions?
23
Abduction and Inductive Reasoning
z Abduction:
B A → B
A
z Not logically valid, BUT can still be useful.
z In fact, it models the way humans reason all the time:
„ Every non-flying bird I’ve seen before has been a penguin;
hence that non-flying bird must be a penguin.
z Not valid reasoning, but likely to work in many
situations.
過度演繹
24
Modal logic
z Modal logic is a higher order logic.
z Allows us to reason about certainties, and
possible worlds.
z If a statement A is contingent then we say that
A is possibly true, which is written:
◊A
z If A is non-contingent, then it is necessarily
true, which is written:
A
Skip:
cf. “fuzzy logic” … to appear later

Predicate Logic for ArtifiCIAL iNTELLIGENCE

  • 1.
  • 2.
    2 What is ArtificialIntelligence? z A more difficult question is: What is intelligence? z This question has puzzled philosophers, biologists and psychologists for centuries. z Artificial Intelligence is easier to define, although there is no standard, accepted definition. 評判 搜尋解答 邏輯推理 記憶 控制 學習 創作 weak sub? strong Fuzzy,NN,GA In my opinion: 星艦戰將與 蝸蟲的學習
  • 3.
    3 Chapter 7 Contents zWhat is Logic? z Logical Operators z Translating between English and Logic z Truth Tables z Complex Truth Tables z Tautology z Equivalence z Propositional Logic z Deduction z Predicate Calculus z Quantifiers ∀ and ∃ z Properties of logical systems z Abduction and inductive reasoning z (Modal logic)
  • 4.
    4 What is Logic? zReasoning about the validity of arguments. z An argument is valid if its conclusions follow logically from its premises – even if the argument doesn’t actually reflect the real world: „ All lemons are blue „ Mary is a lemon „ Therefore, Mary is blue.
  • 5.
    5 Logical Operators z AndΛ z Or V z Not z Implies → (if… then…) z Iff ↔ (if and only if)
  • 6.
    6 Translating between Englishand Logic z Facts and rules need to be translated into logical notation. z For example: „ It is Raining and it is Thursday: „ R Λ T „ R means “It is Raining”, T means “it is Thursday”.
  • 7.
    7 Translating between Englishand Logic z More complex sentences need predicates. E.g.: „ It is raining in New York: „ R(N) „ Could also be written N(R), or even just R. z It is important to select the correct level of detail for the concepts you want to reason about.
  • 8.
    8 Truth Tables z Tablesthat show truth values for all possible inputs to a logical operator. z For example: z A truth table shows the semantics of a logical operator.
  • 9.
    9 Complex Truth Tables zWe can produce truth tables for complex logical expressions, which show the overall value of the expression for all possible combinations of variables:
  • 10.
    10 Tautology (恆真式) z Theexpression A v ¬A is a tautology. z This means it is always true, regardless of the value of A. z A is a tautology: this is written ╞ „ A tautology is true under any interpretation. „ An expression which is false under any interpretation is contradictory. z 一切數學證明的動作來自: ╞ (P ^(PÆQ) Æ Q) 或者強調那是動作的結果: P ^(PÆQ)├ Q
  • 11.
    11 Equivalence z Two expressionsare equivalent if they always have the same logical value under any interpretation: „A Λ B ≡ B Λ A z Equivalences can be proven by examining truth tables.
  • 12.
    12 Some Useful Equivalences zA v A ≡ A z A Λ A ≡ A z A Λ (B Λ C) ≡ (A Λ B) Λ C z A v (B v C) ≡ (A v B) v C z A Λ (B v C) ≡ (A Λ B) v (A Λ C) z A Λ (A v B) ≡ A z A v (A Λ B) ≡ A z A Λ true ≡ A A Λ false ≡ false z A v true ≡ true A v false ≡ A
  • 13.
    13 Propositional Logic (命題邏輯) zPropositional logic is a logical system. z It deals with propositions. „ Inference (what results from assumptions?) „ Reasoning (is it true or not?) z Propositional Calculus is the language we use to reason about propositional logic. z A sentence in propositional logic is called a well-formed formula (wff). „ Wff: English Æ logic sentence
  • 14.
    14 Propositional Logic z Thefollowing are wff’s: z P, Q, R… z true, false z (A) z ¬A z A Λ B z A v B z A → B z A ↔ B 定義 PÆQ ≡ ¬ P V Q (真值表比對) e.g. Tall ^ Strong Æ Ball_Player ≡ ¬ (Tall ^ Strong) V Ball_Player ≡ ¬ Tall V ¬ Strong V Ball_Player
  • 15.
    15 Chapter 7 Contents zWhat is Logic? z Logical Operators z Translating between English and Logic z Truth Tables z Complex Truth Tables z Tautology z Equivalence z Propositional Logic z Deduction z Predicate Calculus z Quantifiers ∀ and ∃ z Properties of logical systems z Abduction and inductive reasoning z (Modal logic) Recall:
  • 16.
    16 Deduction z The processof deriving a conclusion from a set of assumptions. z Use a set of rules, such as: A A → B B (modus ponens… 拉丁文:推論法) z If we deduce a conclusion C from a set of assumptions, we write: z {A1, A2, …, An} ├ C 7.11(p.191 ~ p.195)
  • 17.
  • 18.
    18 Predicate Calculus (述語推算) zPredicate Calculus extends the syntax of propositional calculus with predicates and quantifiers: „ P(X) – P is a predicate. z First Order Predicate Calculus (FOPC) allows predicates to apply to objects or terms, but not functions or predicates.
  • 19.
    19 Quantifiers ∀ and∃ z ∀ - For all: „ ∀xP(x) is read “For all x’es, P (x) is true”. z ∃ - There Exists: „ ∃x P(x) is read “there exists an x such that P(x) is true”. z Relationship between the quantifiers: „ ∃x P(x) ≡ ¬(∀x)¬P(x) „ “If There exists an x for which P holds, then it is not true that for all x P does not hold”. ∃x Like(x, War) ≡ ¬(∀x) ¬Like(x, War)
  • 20.
    20 Deduction over FOPC--- Search z Dog(X) ^ Meets(X,Y)^Dislikes(X,Y) Æ Barks_at(X,Y) z Close_to(Z, DormG) Æ Meets(Snoopy, Z) z Man(W) Æ Dislikes(Snoopy, W) z Man(John), Dog(Snoopy), Close_to(John,DormG) z Dog(X) ^ Meets(X,Y)^Dislikes(X,Y) Æ Barks_at(X,Y) z Close_to(Z, DormG) Æ Meets(Snoopy, Z) z Dislikes(Snoopy, John) z Dog(Snoopy), Close_to(John,DormG) {John/W} Barks_at(Snoopy,John) ??
  • 21.
    21 Deduction over FOPC--- Goal Tree Barks_at(Snoopy,John)? Dog(Snoopy) Meets(Snoopy,John) Dislikes(Snoopy,John) Close_to(John,DormG) Man(John) Other_Resons Yes Yes Yes {Snoopy/X} {John/Y} {John/Y} {John/Z} {John/W} Recall:
  • 22.
    22 Properties of LogicalSystems z Soundness(可靠): Is every theorem valid? z Completeness(週延): Is every tautology a theorem? z Decidability(可推導): Does an algorithm exist that will determine if a wff is valid? z Monotonicity(不受破壞): Can a valid logical proof be made invalid by adding additional premises or assumptions?
  • 23.
    23 Abduction and InductiveReasoning z Abduction: B A → B A z Not logically valid, BUT can still be useful. z In fact, it models the way humans reason all the time: „ Every non-flying bird I’ve seen before has been a penguin; hence that non-flying bird must be a penguin. z Not valid reasoning, but likely to work in many situations. 過度演繹
  • 24.
    24 Modal logic z Modallogic is a higher order logic. z Allows us to reason about certainties, and possible worlds. z If a statement A is contingent then we say that A is possibly true, which is written: ◊A z If A is non-contingent, then it is necessarily true, which is written: A Skip: cf. “fuzzy logic” … to appear later