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
PGS.TS. Phan Huy Kh PGS.TS. Phan Huy Kh á á nh nh khanhph@vnn.vn khanhph@vnn.vn H H chuyên gia chuyên gia ( ( Expert System Expert System ) ) Chng 2 Biu din tri thc nh logic v t bc mt 2.3 2/ 2/ 69 69 Chng Chng 2 2 Bi Bi u di u di n tri th n tri th c nh c nh logic v logic v t t b b c m c m t t \ \ Ph Ph n 2.3 : n 2.3 : u u Lôgic v Lôgic v t t b b c m c m t t u u Bi Bi u di u di n tri th n tri th c nh c nh logic v logic v t t b b c m c m t t 3/ 3/ 69 69 Limitations of Propositional Logic 2 Limitations of Propositional Logic 2 \ \ Can't directly talk about properties of individuals Can't directly talk about properties of individuals or relations between individuals or relations between individuals u u E.g., E.g., how to represent the fact that John is tall? how to represent the fact that John is tall? \ \ We have no way to conclude that We have no way to conclude that John is good at John is good at basketball basketball ! ! \ \ Generalizations, patterns, regularities can't easily be Generalizations, patterns, regularities can't easily be represented represented u u E.g., E.g., all triangles have 3 sides all triangles have 3 sides 4/ 4/ 69 69 Predicate Logic Overview Predicate Logic Overview \ \ Predicate Logic Predicate Logic u u Principles Principles u u Objects Objects u u Relations Relations u u properties properties \ \ Syntax Syntax \ \ Semantics Semantics \ \ Extensions and Variations Extensions and Variations \ \ Proof in Predicate Logic Proof in Predicate Logic \ \ Important Important Concepts and Terms Concepts and Terms 5/ 5/ 69 69 Delimiters , ( ) Delimiters , ( ) Constants a z Constants a z Variale A Z Variale A Z Function f g h Function f g h Predicate P 0 P Q R Predicate P 0 P Q R Connective ¬∧∨→↔ Connective ¬∧∨→↔ Quantifier ∀∃ Quantifier ∀∃ Term t i Term t i Term f(t 1 , …t n ) Term f(t 1 , …t n ) Atom P Q R Atom P Q R Atom P(t 1 , …t n ) Atom P(t 1 , …t n ) Wff P∧ Q → R Wff P∧ Q → R W ff ∃X ∀Y (P(X, Y) → R(Y)) Wff ∃X ∀Y (P(X, Y) → R(Y)) Alphabet Alphabet 6/ 6/ 69 69 B B ng ký hi ng ký hi u ( u ( Alphabet Alphabet ) ) \ \ B B ng ký hi ng ký hi u đ u đ xây d xây d ng c ng c á á c bi c bi u th u th c đ c đ ú ú ng g ng g m : m : u u C C á á c c d d u phân c u phân c á á ch ch (separator signs) : (separator signs) : d d u ph u ph y ( y ( , , ), d ), d u m u m ngo ngo c ( c ( ( ( ) v ) v à à d d u đ u đ ó ó ng ngo ng ngo c ( c ( ) ) ) ) u u C C á á c c h h ng ng (constant) : (constant) : c c ó ó d d ng chu ng chu i s i s d d ng c ng c á á c ch c ch c c á á i in th i in th ng ng a a z z V V í í d d : a, block : a, block u u C C á á c c bi bi n n (variable) : (variable) : c c ó ó d d ng chu ng chu i s i s d d ng c ng c á á c ch c ch c c á á i in hoa i in hoa A A Z Z V V í í d d : X, NAME. : X, NAME. u u C C á á c c v v t t (predicate) : (predicate) : đ đ c vi c vi t tng t t tng t c c á á c c bi bi n n , s , s d d ng c ng c á á c ch c ch c c á á i in hoa i in hoa A A Z Z V V í í d d : ISRAINING, ON(table), P(X, blue), BETWEEN(X, Y, Z) : ISRAINING, ON(table), P(X, blue), BETWEEN(X, Y, Z) 7/ 7/ 69 69 B B ng ký hi ng ký hi u ( u ( Alphabet Alphabet ) ) \ \ C C á á c ph c ph é é p n p n i logic (logical connector) : i logic (logical connector) : u u ¬ ¬ , , ∧ ∧ , , ∨ ∨ , , → → v v à à ↔ ↔ tng tng ng v ng v i c i c á á c ph c ph é é p ph p ph đ đ nh, v nh, v à à , ho , ho c, k c, k é é o theo v o theo v à à k k é é o o theo l theo l n nhau ( n nhau ( tng đng tng đng ) ) \ \ C C á á c c d d u l u l ng t ng t u u ∃ ∃ l l ng t ng t t t n t n t i (existential quantifier) i (existential quantifier) u u ∀ ∀ l l ng t ng t to to à à n th n th (universal quantifier) (universal quantifier) 8/ 8/ 69 69 Names Names \ \ Constants are used to name existing Constants are used to name existing objects: objects: u u The interpretation identifies the object in the real world The interpretation identifies the object in the real world u u No No constant can name more than one object constant can name more than one object u u An object can have more than one An object can have more than one name or name or no name at no name at all all \ \ Variables: Variables: V = {X, Y, Z, V = {X, Y, Z, … … } } Leonard Euler Leonard Euler Honest Abe Honest Abe Lincoln Lincoln Gaius Gaius Sempronius Sempronius Gracchus Gracchus Tiberius Tiberius Sempronius Sempronius Gracchus Gracchus 9/ 9/ 69 69 BNF Grammar Predicate Logic BNF Grammar Predicate Logic <Sentence> <Sentence> → → <AtomicSentence <AtomicSentence > > | | ( ( < < Sentence> Sentence> < < Connective> Connective> < < Sentence>) Sentence>) | | < < Quantifier> Quantifier> < < Variable>, Variable>, < < Sentence> Sentence> | | ¬ ¬ < < Sentence Sentence > > < < AtomicSentence> AtomicSentence> → → < < Predicate>(<Term>, Predicate>(<Term>, ) ) | | < < Term>= Term>= < < Term> Term> < < Term> Term> → → < < Function>(<Term> Function>(<Term> , , ) ) | | < < Constant> | Constant> | < < Variable Variable > > < < Connective> Connective> → → ∧ ∧ | | ∨ ∨ | | → → | | ↔ ↔ < < Quantifier> Quantifier> → → ∀ ∀ | | ∃ ∃ < < Constant> Constant> → → a, b, c, max, carl a, b, c, max, carl , jim, jack , jim, jack < < Variable> Variable> → → A, B, C, X A, B, C, X 1 1 , X , X 2 2 , COUNTER, POSITION , COUNTER, POSITION <Function> <Function> → → father father - - of, square of, square - - position, sqrt, cosine position, sqrt, cosine < < Predicate> Predicate> → → P, Q, P, Q, LARGER, BETWEEN LARGER, BETWEEN , YOUNGER , YOUNGER - - THAN THAN Ambiguities Ambiguities are resolved through precedence or parentheses are resolved through precedence or parentheses 10/ 10/ 69 69 First Order Predicate Logics Syntax First Order Predicate Logics Syntax term term ::= ::= variable variable | function_symbol_of_arity_n(t | function_symbol_of_arity_n(t 1 1 , , … … , t , t n n ) ) n>0 n>0 | function_symbol_of_arity_0 | function_symbol_of_arity_0 constant constant atom atom ::= ::= predicate_symbol_of_arity_n(t predicate_symbol_of_arity_n(t 1 1 , , … … , t , t n n ) ) n>0 n>0 | predicate_symbol_of_arity_0 | predicate_symbol_of_arity_0 constant constant literal literal ::= ::= atom atom positive literal positive literal | | ¬ ¬ atom atom negative literal negative literal wff wff ::= ::= atom atom well formed formula ( well formed formula ( sentence) sentence) | ( | ( ¬ ¬ wff) wff) negation negation | (wff | (wff ∧ ∧ wff) wff) conjunction conjunction | (wff | (wff ∨ ∨ wff) wff) disjunction disjunction | (wff | (wff → → wff) wff) implication implication | (wff | (wff ↔ ↔ wff) wff) equivalence equivalence | ( | ( ∀ ∀ variable wff) variable wff) universal universal formula formula | ( | ( ∃ ∃ variable wff) variable wff) existential existential formula formula [...]... Hà T nh : XAQUÊ(cutý, hàt nh), XAQUÊ(X, Y) u Cu Tý nh quê Hà T nh : NH QUÊ(cutý, hàt nh), NH QUÊ(X, Y) \ Xây d ng CTC X, Y (QUÊ(X, Y) XAQUÊ(X, Y) NH QUÊ(X, Y)) u 23/69 Predicate 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... c l ng t hóa u Ví d : P(X) và ( Y) Q(X, Y) có ch a bi n t do X c g i là «b c m t» (first order) : \ Logic v t ng t cho v t hay cho hàm u Trong CTC không nh ngh a l u Ví d : ( P)P(a) và ( f) ( f) ( X) P(f (X), b) không ph i là nh ng v t b c m t, mà có b c cao h n (higher-order) 25/69 M 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 i thành các CTC... lôgic v t b c m t di n t r ng : \ Ch ng h n, «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 c vi t : P(Y))), ho c ( X) ( Y) (SAME_P(X, Y) (P(X) ( X) ( Y) (SAME_P(X, Y) (HAVE(X, p) HAVE (Y, p)))... all objects \ 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 31/69 Universal Quantifiers (for all) \ X P(x) states that u a predicate P is holds for all objects X in the universe (domain) under discourse u The sentence is true if and only... Y) X HUMAN(X) Y LOVES(Y, X) X X X X Y HUMAN(X) Y HUMAN(X) Y HUMAN(X) Y HUMAN(X) MOTHER(Y, X) LOVES(X, Y) LOVES(X, Y) LOVES(Y, X) \ They can translate to the form: Q M, with Q: quantifiers, M: Matrix, wffs including V: Variable 36/69 . Kh á á nh nh khanhph@vnn.vn khanhph@vnn.vn H H chuyên gia chuyên gia ( ( Expert System Expert System ) ) Chng 2 Biu din tri thc nh logic v t bc mt 2. 3 2/ 2/ 69 69 Chng Chng 2 2 Bi Bi u di u. m t t Ph Ph n 2. 3 : n 2. 3 : u u Lôgic v Lôgic v t t b b c m c m t t u u Bi Bi u di u di n tri th n tri th c nh c nh logic v logic v t t b b c m c m t t 3/ 3/ 69 69 Limitations. symbols of arity 1 (one argument) u u F F 2 2 : function symbols of arity 2 (two arguments) : function symbols of arity 2 (two arguments) u u … … 13/ 13/ 69 69 Functions Examples Functions Examples A