Tải bản đầy đủ (.pdf) (63 trang)

Slide trí tuệ nhân tạo chapter7 1 using logic

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (238.39 KB, 63 trang )

Using Logic
Chapter 7

CuuDuongThanCong.com

/>

Using Propositional Logic
Representing simple facts
It is raining
RAINING
It is sunny
SUNNY
It is windy
WINDY
If it is raining, then it is not sunny
RAINING  SUNNY

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

2
4 April, 2012
/>

Propositional Logic Syntax
• Logical constants: true, false
• Propositional symbols: P, Q, …
• Logical connectives: , , , , 
• Sentences (formulas):







Logical constants
Proposition symbols
If  is a sentence, then so are  and ()
If  and  are sentences, then so are  , , ,
and  

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

3
4 April, 2012
/>

Propositional Logic Semantics
• Interpretation: propositional symbol  true/false
• The truth value of a sentence is defined by the truth
table
P

Q

P

PQ


PQ

PQ

PQ

false

false

true

false

false

true

true

false

true

true

false

true


true

false

true

false

false

false

true

false

false

true

true

false

true

true

true


true

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

4
4 April, 2012
/>

Propositional Logic Semantics
• Satisfiable: true under an interpretation
• Valid: true under all interpretations
P

Q

P  P

(P  Q)  Q

((P  Q)  Q)  P

false

false

false


false

true

false

true

false

false

true

true

false

false

true

true

true

true

false


false

true

satisfiable

valid

unsatisfiable
Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

5
4 April, 2012
/>

Propositional Logic Semantics
• Model: an interpretation under which the sentence is
true
PQ

PQ



PQ

P


PQ


P

CuuDuongThanCong.com

Q

PQ



Cao Hoang Tru
CSE Faculty - HCMUT



Q



PQ

6
4 April, 2012
/>

Propositional Logic Semantics
• Entailment: KB =  iff every model of KB is a model of 

 is a logical consequence of KB

P

Q

PQ

P  Q, P

false

false

true

false

false

true

true

false

true

false


false

false

true

true

true

true

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

{P  Q, P} = Q

7
4 April, 2012
/>

Propositional Logic Semantics
• Equivalence:   iff  =  and  = 
P

Q

PQ


P  Q

false

false

true

true

false

true

true

true

true

false

false

false

true

true


true

true

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

P  Q  P  Q

8
4 April, 2012
/>

Propositional Logic Semantics
• Theorems:
–  =  iff    is valid
KB =  can be proved by validity of KB  

–  =  iff    is unsatisfiable
KB =  can be proved by refutation of KB  

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

9
4 April, 2012
/>


Using Propositional Logic
• Theorem proving is decidable
• Cannot represent objects and quantification

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

10
4 April, 2012
/>

Predicate Logic Syntax
• Constant symbols: a, b, c, John, …
to represent primitive objects

• Variable symbols: x, y, z, …
to represent unknown objects

• Predicate symbols: safe, married, love, …
to represent relations
married(John)
love(John, Mary)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

11
4 April, 2012

/>

Predicate Logic Syntax
• Function symbols: square, father, …
to represent simple objects
safe(square(1, 2))
love(father(John), mother(John))

• Terms:
to represent complex objects
– Constant symbols
– If f is a function symbol, and t1, t2, …, tn are terms,
then so is f(t1, t2, …, tn)
love(mother(father(John)), John)
Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

12
4 April, 2012
/>

Predicate Logic Syntax
• Logical connectives: , , , , 
• Universal quantifier: "x: p(x)
"x: love(father(x), mother(x))

• Existential quantifier: $x: p(x)  "x: p(x)
$x: married(x)


Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

13
4 April, 2012
/>

Predicate Logic Syntax
• Sentences:
– Atomic sentences: p(t1, t2, …, tn)
– If  is a sentence, then so are  and ()
– If  and  are sentences, then so are  , , ,
and  
– If  is a sentence, then so are " and $

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

14
4 April, 2012
/>

Using Predicate Logic
• Can represent objects and quantification
• Theorem proving is semi-decidable

Cao Hoang Tru
CSE Faculty - HCMUT

CuuDuongThanCong.com

15
4 April, 2012
/>

Using Predicate Logic
1.

Marcus was a man.

2.

Marcus was a Pompeian.

3.

All Pompeians were Romans.

4.

Caesar was a ruler.

5.

All Pompeians were either loyal to Caesar or hated him.

6.

Every one is loyal to someone.


7.

People only try to assassinate rulers they are not loyal to.

8.

Marcus tried to assassinate Caesar.

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

16
4 April, 2012
/>

Using Predicate Logic
1.

Marcus was a man.
man(Marcus)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

17
4 April, 2012
/>


Using Predicate Logic
2.

Marcus was a Pompeian.
Pompeian(Marcus)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

18
4 April, 2012
/>

Using Predicate Logic
3.

All Pompeians were Romans.
"x: Pompeian(x)  Roman(x)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

19
4 April, 2012
/>

Using Predicate Logic

4.

Caesar was a ruler.
ruler(Caesar)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

20
4 April, 2012
/>

Using Predicate Logic
5.

All Pompeians were either loyal to Caesar or hated him.
inclusive-or
"x: Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)

exclusive-or
"x: Roman(x)  (loyalto(x, Caesar)  hate(x, Caesar)) 
(loyalto(x, Caesar)  hate(x, Caesar))

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

21
4 April, 2012

/>

Using Predicate Logic
6.

Every one is loyal to someone.
"x: $y: loyalto(x, y)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

$y: "x: loyalto(x, y)

22
4 April, 2012
/>

Using Predicate Logic
7.

People only try to assassinate rulers they are not loyal to.

"x: "y: person(x)  ruler(y)  tryassassinate(x, y)
 loyalto(x, y)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com


23
4 April, 2012
/>

Using Predicate Logic
7.

People only try to assassinate rulers they are not loyal to.

"x: "y: person(x)  ruler(y)  tryassassinate(x, y)
 loyalto(x, y)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com

24
4 April, 2012
/>

Using Predicate Logic
8.

Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)

Cao Hoang Tru
CSE Faculty - HCMUT
CuuDuongThanCong.com


25
4 April, 2012
/>

×