Tài liệu này dành cho sinh viên, giáo viên khối ngành công nghệ thông tin tham khảo và có những bài học bổ ích hơn, bổ trợ cho việc tìm kiếm tài liệu, giáo án, giáo trình, bài giảng các môn học khối ngành công nghệ thông tin
Trang 3Limitations of Propositional Logic 2
\ Can't directly talk about properties of individuals
or relations between individuals
u E.g., how to represent the fact that John is tall?
\ We have no way to conclude that John is good at
Trang 4Predicate Logic Overview
\ Extensions and Variations
\ Proof in Predicate Logic
\ Important Concepts and Terms
Trang 5Delimiters
, ( )
Delimiters , ( )
Wff
P∧ Q → R
Wff P∧ Q → R
Trang 8\ Constants are used to name existing objects:
u The interpretation identifies the object in the real world
u No constant can name more than one object
u An object can have more than one name or no name at all
Trang 9BNF Grammar Predicate Logic
<Sentence> → <AtomicSentence>
| (<Sentence> <Connective> <Sentence>)
| <Quantifier> <Variable>, <Sentence>
<Constant> → a, b, c, max, carl, jim, jack
<Variable> → A, B, C, X1 , X2, COUNTER, POSITION
<Function> → father-of, square-position, sqrt, cosine
<Predicate> → P, Q, LARGER, BETWEEN, YOUNGER-THAN
Ambiguities are resolved through precedence or parentheses
Trang 10First Order Predicate Logics Syntax
term ::= variable
| function_symbol_of_arity_n(t1, …, tn) n>0
| function_symbol_of_arity_0 constantatom ::= predicate_symbol_of_arity_n(t1, …, tn) n>0
| predicate_symbol_of_arity_0 constantliteral ::= atom positive literal
| ¬ atom negative literalwff ::= atom well formed formula (sentence)
| (∀ variable wff) universal formula
| (∃ variable wff) existential formula
Trang 12Function Symbols
\ Function symbols
u function_name(arg1, arg2, …, argn)
u Identifies the object referred to by a tuple of objects
u May be defined implicitly through other functions, or explicitly
through tables
\ Function names begin with a lowercase letter or are
expressed with a symbol
u F = {f, g, h, …} = F0 ∪ F1 ∪ F2 ∪ …
\ Function arities:
u F0: function symbols of arity 0 (constants): a, b, max, jim
u F1: function symbols of arity 1 (one argument)
u F2: function symbols of arity 2 (two arguments)
Trang 13Functions Examples
\ A function is used to express complex names
u password(claire) Claire’s password
\ A function may be nested
u Max’s age’s double double(age(max))
u father(mother(max)) Max’s mother’s father
u starship(son(dr_crusher)) Dr_Crusher’s son’s starship
\ A function is never a predicate
u Can’t nest predicates TALL(TALL(max))
\ Function symbols of arity >1
u youngestChild(max, ann) Max and Ann’s youngest child
\ A predicate forms a sentence,
while a function names an individual
Trang 14\ Ví d các hàm sau đây đ m sau đây đ u là các h ng :
u successor(X, Y), weight(b), successor(b, wight(Z))
\ Nh ng các hàm sau đây không ph m sau đây không ph i là h ng :
u P(X, blue) vì P là v t
u weight (P(b))
vì P(b) không ph i là h ng (v t không làm đ m đ i cho hàm)
Trang 15Predicates
\ Predicate symbols :
u PREDICATE(arg1, arg2, …, argn)
u A (determinate) property possessed by an object: Shape, Size
u A (determinate) relationship among objects:
Shape relationship, size relationship, positional relationship…
u The number of arguments is called the predicate’s arity
u The order of the arguments is important
\ Predicates have names beginning with an uppercase letter
or are represented by an operator symbol
u P = P0 ∪ P1 ∪ P2 ∪ …
\ Predicate arities:
P0: predicate symbols of arity 0 (constants: proposition) : P, Q, R, …
P1: predicate symbols of arity 1 (one argument)
P2: predicate symbols of arity 2 (two arguments) …
Trang 16\ Ví d các v t sau đây l sau đây l à các nguyên t :
u P(X, blue), EMPTY, BETWEEN(table, X, sill(window))
\ Còn :
u successor (X, Y, sill (window)
không ph i nguyên t , mà là các hàm
Trang 17Atomic Sentences
\ A atomic sentence:
u Expresses a claim that is either true or false
u Formed by a single predicate followed by one or more arguments
Trang 20Well-formed Formula (wff)
\ Any atomic sentence is a wff
\ If A are B are wffs then so are
Trang 21Equality
\ Equality indicates that two terms refer to the same object
=(A, B)
u A and B are identical
u Usually, written in infix form A = B
u The equality symbol “=“ is an (in-fix) shorthand
u FATHER(jane) = jim, or =(FATHER(jane), jim)
u E.g Jim is Jane’s and John’s father
\ Equality by reference and equality by value
u Sometimes the distinction between referring to the same object and referring to two objects that are identical (indistinguishable) can be important
\ E ≠ E E is not identical to iteself
Trang 22m t nguyên t hay có d ng (¬G), v i G là m t nguyên t
u Trong m t CTC, tr c ho c sau các ký t n i, ký t phân
cách, các h ng, các bi n, các hàm, các v t , ng i ta có th
đ t tùy ý các d u cách (space hay blank)
Trang 23u Cu Tý quê Hà T nh : QUÊ(cutý, hàt nh), QUÊ(X, Y)
u Cu Tý xa quê Hà T nh : XAQUÊ(cutý, hàt nh), XAQUÊ(X, Y)
Trang 24Predicate Logics: some terminology
\ There is a predicate logic for each basis B=(F, P)
of function and predicate symbols
\ Terms formed on basis B are called B-terms:
the set of all B-terms is denoted TB
\ Formulas formed on basis B are called B-formulas:
the set of all B-formulas is denoted WFFB
\ Formulas with all variables bound to a quantifier
are called closed formulas
\ Formulas with no quantifier
are called quantifier free formulas
\ Formulas with no quantifier and no variable
are called ground formulas
Trang 25\ T nay ta quy c r ng, trong m t CTC :
u M t bi n đ n đ c l ng t hóa s xu t hi n ngay sau ∃ hay ∀
u Ph m vi l ng t hóa c a bi n k t v trí xu t hi n tr đi đi
Trang 26M t s nh n xét 2
\ Tri th c di n t theo ngôn ng t nhiên hay toán h c
không ph i luôn luôn d dàng chuy n đ n đ i thành các CTC trong lôgic v t b c m t
\ Ch ng h n, đ đ di n t r ng :
«N u hai v t y chang nhau thì chúng có cùng tính ch t»,
ng i ta có th vi t :
(∀P) (∀X) (∀Y) (EQUAL(X, Y) → (P(X) ↔ P(Y)))
\ Nh ng bi u th c trên không ph i là logic v t b c m t
vì có l ng t ∀ áp d ng cho m t ký t v t là P
\ Trong lôgic v t b c m t, s ki n trên đ n trên đ c vi t :
(∀X) (∀Y) (SAME_P(X, Y) → (P(X) ↔ P(Y))), ho c
(∀X) (∀Y) (SAME_P(X, Y) → (HAVE(X, p) ↔ HAVE (Y, p)))
Trang 27Example: Family Relationships
\ Objects: people
\ Properties: gender, …
u Expressed as unary predicates:
MALE(X), FEMALE(Y) ho c SEX(X, male), SEX(Y, female)
\ Relations: parenthood, brotherhood, marriage
u Expressed through binary predicates
PARENT(X, Y), BROTHER(X, Y), …
\ Functions: motherhood, fatherhood
u Because every person has exactly one mother and one father:
mother(X), father(Y)
u There may also be a relation
mother-of(X, Y), father-of(X, Y)
Trang 28Atomic Sentences Translation
Trang 29Examples Atomic Sentences
FATHER(jack, john), MOTHER(jill, john), SISTER(jane, john)
PARENTS(jack, jill, john, jane)
PARENTS(jack, jill, john, jane) ∧ MARRIED(jack, jill)
PARENTS(jack, jill, john, jane) → MARRIED(jack, jill)
OLDER-THAN(jane, john) ∨ OLDER-THAN(john, jane)
OLDER(father-of(john), 30) ∨ OLDER (mother-of(john), 20)
Trang 31\ The universal quantifier, represented by the symbol ∀
means “for every” or “for all”
\ The existential quantifier, represented by the symbol ∃
means “there exists”
\ Limitations of predicate logic – most quantifier
Trang 32Universal Quantifiers ∀ (for all)
Trang 33Usage of Universal Qualification
\ Universal quantification is frequently used to make
statements like:
u “all humans are mortal”
u “all cats are mammals”
u “all birds can fly” …
\ This can be expressed through sentences like
Trang 34Existential Quantifier ∃ (there exists)
\ ∃X P(x) states that
u a predicate P holds for some objects in the universe
u The sentence is true if and only if there is at least one true
individual sentence where the variable X is replaced by the
individual objects it can stand for
Trang 35Usage of Existential Quantification
\ Existential quantification is used to make statements like:
u “some humans are computer scientists”
u “john has a sister who is a computer scientist”
u “some birds can’t fly” …
\ This can be expressed through sentences like
Trang 36Multiple Quantifiers
\ More complex sentences can be formulated by multiple
variables and by nesting quantifiers
u The order of quantification is important
u Variables must be introduced by quantifiers, and belong to the
innermost quantifier that mention them
\ Examples
∀X, ∀Y PARENT(X, Y) → CHILD(Y, X)
∀X HUMAN(X) ∧ ∃Y MOTHER(Y, X) ⇒ ∀X ∃Y HUMAN(X) ∧ MOTHER(Y, X)
∀X HUMAN(X) ∧ ∃Y LOVES(X, Y) ⇒ ∀X ∃Y HUMAN(X) ∧ LOVES(X, Y)
∃X HUMAN(X) ∧ ∀Y LOVES(X, Y) ⇒ ∀X ∀Y HUMAN(X) ∧ LOVES(X, Y)
∃X HUMAN(X) ∧ ∀Y LOVES(Y, X) ⇒ ∃X ∀Y HUMAN(X) ∧ LOVES(Y, X)
\ They can translate to the form:
V: Variable
Trang 37\ All statements made with one quantifier can be converted into equivalent statements with the other quantifier by
using negation
∀ is a conjunction over all objects under discourse
∃ is a disjunction over all objects under discourse
\ De Morgan’s rules apply to quantified sentences
\ Strictly speaking, only one quantifier is necessary
u Using both is more convenient
Trang 38Family Relationships
\ One’s mother is one’s sibling’s mother
∀M, C, D MOTHER(M, C) ∧ SIBLING(C, D) → MOTHER(M, D)
\ Brothers are siblings
∀X, Y BROTHER(X, Y) → SIBLING(X, Y)
\ Sibling is transitive
∀X, Y, Z SIBLING(X, Y) ∧ SIBLING(Y, Z) → SIBLING(X, Z)
\ One’s mother is one’s sibling’s mother
∀M, C MOTHER(M, C) ∧ SIBLING(C, D) → MOTHER(M, D)
\ A first cousin is a child of a parent’s sibling
Trang 39¬(X=Y) ∧ ∃P PARENT(P, X) ∧ PARENT(P, Y)
Ng i này là m c a ng i kia kh m t ng i là ph n và là thân sinh c a ng i kia
Ng i này là m c a ng i kia kh m t ng i là ph n và là thân sinh c a ng i kia
Ng i này là ch ng c a ng i kia kh ng i này là đàn ông và ng i kia là v c a ng i này
Ng i này là ch ng c a ng i kia kh ng i này là đ đ àn ông và ng i kia là v c a ng i này
Trang 40Translating 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)
\ All purple mushrooms are poisonous
∀X (MUSHROOM(X) ∧ PURPLE(X)) → POISONOUS(X)
\ No purple mushroom is poisonous
¬(∃X) PURPLE(X) ∧ MUSHROOM(X) ∧ POISONOUS(X)
or, equivalently,
(∀X) (MUSHROOM(X) ∧ PURPLE(X)) → ¬POISONOUS(X)
Trang 41Translating English to FOL…
\ There are exactly two purple mushrooms
(∃X)(∃Y) MUSHROOM(X) ∧ PURPLE(X) ∧ MUSHROOM(Y) ∧ PURPLE(Y)
∧ ¬(X=Y) ∧ (∀Z) (MUSHROOM(Z) ∧ PURPLE(Z))
another starting with X and ending with Y
(∀X)(∀Y) ABOVE(X, Y) ↔ (ON(X, Y) ∨ (∃Z) (ON(X, Z) ∧ ABOVE(Z, Y)))
Trang 42Colonel West Example
\ Assume:
u It is a crime for an American to sell weapons to a hostile nation.The country Nono, an enemy of America, has some missiles, and all its missiles were sold to it by Colonel West, who is an American
u Constants: nono, america, west
u Predicates: CRIMINAL, AMERICAN, WEAPON, HOSTILE, NATION, ENEMY, MISSILE, OWNS, SELLS
\ Then
u It is a crime for an American to sell weapons to a hostile nation
⇒ If any american X sells any weapon Y to any hostile nation Z, then that american X is a criminal
∧ HOSTILE(Z) ∧ SELLS(X, Z, Y) → CRIMINAL(X))
Trang 43Other Translating
\ Nono’s missiles
u Nono has some missiles
u All of Nono’s missiles were sold to it by West
⇒ If X is a missile owned by Nono then West sold X to Nono
\ The other facts
u An enemy of America is hostile
u West is an American
u Nono is an enemy of America
∃ X (MISSILE(X) ∧ OWNS(nono, X))
∀ X ((MISSILE(X) ∧ OWNS(nono, X)) → SELLS(west, nono, X))
∀ X (ENEMY(X, america) → HOSTILE(X))
AMERICAN(west)
NATION(nono) ∧ NATION(america) ∧ ENEMY(nono, america)
Trang 44Other Examples
\ Love
u There is a girl who is loved by every boy
⇒ There is a girl X and if Y is a boy then Y loves her
u Every boy loves some girl
u For every boy Y there exists a girl X that he loves
\ Socrates Example
u All men are mortal
u Socrates is a man
u Socrates is mortal
∃X (GIRL(X) ∧ ∀Y(BOY(Y) → LOVES(Y,X)))
∀Y(BOY(Y) → ∃X (GIRL(X) ∧ LOVES(Y,X)))
∀X (MAN(X) → MORTAL(X))
MAN(socrates)
MORTAL(socrates)
Trang 45Curiosity Example
\ Assume:
Jack owns a dog
Every dog owner is an animal lover
No animal lover kills an animal
Either Jack or Curiosity killed the cat
The cat’s name is Tuna
Then
u Constants: jack, curiosity, tuna.
u Predicates: OWNS, DOG, ANIMALLOVER, KILLS, ANIMAL
Trang 46Curiosity Example
\ Dog owners
u Jack owns a dog
⇒ Some dog is owed by Jack
u Every dog owner is an animal lover
u No animal lover kills an animal
⇒ An animal lover does not kill an animal
⇒ For any animal lover X and any animal Y,
then Y is not killed by X
∃ X (DOG(X) ∧ OWNS(jack, X))
∀ X ((∃ Y (DOG(Y) ∧ OWNS(X,Y))) → ANIMALLOVER(X))
∀ X, Y ((ANIMALLOVER(X) ∧ ANIMAL(Y)) → ¬KILLS(X,Y))
Trang 47Curiosity Example
u The cat’s name is Tuna
u Either Jack or Curiosity killed the cat
u All cats are animals
CAT(tuna)
KILLS(jack, tuna) ∨ KILLS(curiosity, tuna)
∀X CAT(X) → ANIMAL(X)
Trang 49∀x : ROMAN(X) → LOYALTO(X, caesar) ∨ HATE(X, caesar)
\ Tuy nhiên khi s d ng v i ngh a ho c có lo i tr , có th vi t l i :
∀x : ROMAN(X) → ((LOYALTO(X, caesar) ∧ HATE(X, caesar)) ∧
(¬LOYALTO(X, caesar) ∧ HATE(X, caesar)))
Trang 50Bi u di n wff’s trong lôgic v t
\ M i ng i đ i đ u trung thành v i m t ng i nào đ o đ ó
∀X, ∃Y LOYALTO(X, Y) ho c ∃Y, ∀X LOYALTO(X, Y)
\ Nhân dân ch mu n gi t nh ng k c m quy n
mà h không trung thành
∀X, ∀Y PERSON(X) ∧ RULER(Y) ∧ TRYASSASSINATE(X, Y) →
¬LOYALTO(X, Y)
M nh đnh đ này t ra m p m (ambiguous) Có ph i ch nh ng k c m
quy n mà nhân dân mu n gi t là nh ng k h không trung thành (theo
nh ng k c m quy n mà h không trung thành ?
\ Marcus mu n gi t Ceresar
u TRYASSASSINATE(marcus, caesar)
\ Câu h i : Marcus có trung thành v i Caesar không ?
Trang 51vì núi l a phun vào n m 79 A.D.
u Không có ng i nào (không ai) s ng nhi u h n 150 tu i
Trang 52\ Marcus là m t ng i
MAN(marcus)
\ Marcus là ng i Pompeii
POMPEIAN (marcus)
\ Marcus sinh n m 40 trong công nguyên
(A.D.: Anno Domini)
BORN(marcus, 40)
\ M i ng i đ i đ u (ai c ng ph i) ch t
∀X MAN(X) Ø MORTAL(X)
\ T t c m i ng i dân Pompeii đ i dân Pompeii đ u b ch t
vì núi l a phun vào n m 79 A.D.
∀X ERUPTED(vocalno, 79) ∧ POMPEIAN(X) Ø DIED(X, 79)
Trang 54Di n gi i (Interpretation)
\ Cho G là m t CTC, m t di n gi i c a G, ký hi u I, đ đ c xác
đ nh t n m b c sau đây c sau đây :
u Ch n mi n di n gi i (Interpretation Domain) là các t p h p khác r ng, ký hi u D ≠ ∅
Trang 55H nga z
Hàm b c nf(X1, Xn)
Trang 56Quan h Translation-Interpretation
Ngôn ng
t nhiên
Ngôn nglôgic v tWFF
Trang 58Tính giá tr c a CTC theo di n gi i (ti p)
\ N u G có d ng (¬G’) :
u I(G) = T n u I(G’) = F trong D
u I(G) = F n u I(G’) = T trong D
Trang 63Bi n đ i các CTC : lo i b l ng t ∀ và ∃
\ Standardize Variables
in a single sentence (unless you really meant to)
Eg
\ Move all quantifiers left, but keep them in order!
\ Translation into the form:
Q<V> M<V>
with Q: quantifiers, in order ∀s and then ∃s
M: Matrix: wffs including V, <V>: Variable
Trang 64Bi n đ i các CTC
\ Skolemize: Eliminate Existential Quantifiers
u Existential quantifiers can be eliminated by the introduction
of a new constant that does not appear elsewhere
Trang 65Bi n đ i các CTC
\ Skolemize: Drop Existential Quantifiers
quantifiers… Consider
becomes by SUBST{Y|h}:
person to their HEART(f(x))
Trang 68Xây d ng c s lu t cho HCG
\ S ki n 1 :
u Con mèo mà trèo cây cau
H i th m chú chu t đi đâu vt đi đâu v ng nhà
Chú chu t đi cht đi ch đ đ ng xa
Mua m m, mua mu i v gi cha con mèo
Trang 69u Con mèo mà trèo cây cau : TREO(X, Y)
u H i th m chú chu t đi đâu vt đi đâu v ng nhà :THAM(X, Y), VANGNHA(X)
u Mua m m, mua mu i v gi cha con mèo