1 / 38

Introduction to Artificial Intelligence LECTURE 8 : First Order Logic

Introduction to Artificial Intelligence LECTURE 8 : First Order Logic. Motivation for First Order Logic (FOL) FOL syntax Quantifiers FOL semantics Building KB in FOL Inference rules for FOL. History. First Order Logic (FOL) was essentially developed by Gottlob Frege around 1879.

min
Download Presentation

Introduction to Artificial Intelligence LECTURE 8 : First Order Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Artificial IntelligenceLECTURE 8: First Order Logic • Motivation for First Order Logic (FOL) • FOL syntax • Quantifiers • FOL semantics • Building KB in FOL • Inference rules for FOL

  2. History • First Order Logic (FOL) was essentially developed by Gottlob Frege around 1879. • The goal was to create a sound and complete system from which all logical truths could be derived. • In 1930, Kurt Godel showed that such a system does not exist (Godel’s completeness theorem).

  3. First-order logic -- rationale (1) • Extended language to express general statements of the form: “every person has a father and a mother”without explicitly listing all instances • The extension requires: • variables: X, Y, … that can refer to specific objects • relations: father(X,Y), mother(Z,Y) • quantifiers: for all , there exists,  to specify the scope of the variables XY Zfather(Y,X) and mother(Z,X) • syntax, semantics, and deduction rules

  4. First order logic -- rationale (2) • First order logic (FOL) and its properties have been widely studied in Mathematics and Logic • FOL can express anything that can be programmed • Issues for knowledge representation: • how to effectively represent the world -- many ontologies possible  KB design. • how to make sound, complete, and computationally effective deductions with it.

  5. Elements of First Order Logic (1) Terms are primitive objects: they are built out of individual variables and function symbols (and individual constants). • individual constants: name of a single object in the world: sarah, 55, blue (True, False) • individual variables: place holder for objects: X, Y • function symbols: they are just symbols but will be interpreted as operations on objects -- return an object father(sarah), father(X), color(block), sarah(), father(block)

  6. Elements of First Order Logic (2) Predicate symbols will be interpreted as relations between objects: they act on terms father_of 2-place father_of(sarah, moshe) color_of 2-place color_of(block123, blue), color 1-place color(blue) bird 1-place bird(Tweety) Functions: father(sarah) = moshe Atomic Formulas

  7. Elements of First Order Logic (3) Formulas are built out of atomic formulas with propositional connectives (/\, \/, ~, =>, <=>) and quantifiers:  (universal) and  (existential): father_of(sarah, husband(tal)) father(sarah) = husband(tal) ( X = father(sarah) ) /\ (X = husband(tal))  X (X = father(sarah) => X = moshe)  X  Y father_of(X, Y)  Y  X father_of(X, Y)

  8. Elements of First Order Logic (4) • A sentence is a formula in which all variables are quantified (no free variable) • KB is a set of sentenceson(a,b) /\on(b,c) clear(a) color_of(a, blue) a b c

  9. First Order Logic -- Syntax Formula ----> Atomic_Formula | Formula Connective Formula | Quantifier VariableFormula | (Formula) |~Formula Atomic_Formula ----> PredicateS( Term, ..., Term) | Term = Term Term ----> Constant | Variable | FunctionS( Term, …, Term) Connective ----> /\ | \/ | => | <=> Quantifier ---->  |  Constant ----> sara, 55, blue,... (lower case letters) Variable -----> X, Y, …. (upper case letters) PredicateS ----> before(_,_) …. (n-ary relation) FunctionS ----> mother(_,_), >, ..(n-ary function)

  10. Terminology • A literal is an atomic formula or its negation • A clause is a disjunction of literals • A term without variables is called a groundterm. • A clause without variables is called a ground clausefather_of(sarah, moshe) \/ father (lea, moshe) • Our convention: • ground terms start with lower case letters • uninstantiated variables start with capital letters

  11. Universal Quantifier • States that a sentence is true for allobjects in the world being modeled.  X ( block(X) => color_of(X,red)) is used to claim that every object in the world that is a block is red.  X (X = a \/ X = b \/ X = c ) says thatthere are at most three objects in the world and that they are denoted by a, b, c. It is only in such a world that  X ( block(X) => color_of(X,red)) is equivalent to: block(a) => color_of(a,red)/\ block(b) => color_of(b,red) /\ block(c) => color_of(c,red) 

  12. Existential Quantifier • States that a sentence is true for someobjects in the world being modeled.  X block(X) /\ color_of(X,red) is equivalent to block(a) /\ color_of(a,red) \/ block(b) /\ color_of(b,red) \/ block(c) /\ color_of(c,red) in a world with at most three objects named bya,b,c. Otherwise there may be a red block that is not a, b or c.

  13. Expressiveness • How can we say that the only objects in the world are a, b and c? • X (X = a)\/ (X = b)\/ (X = c) ~(a = b) /\ ~(a = c) /\ ~(b = c)

  14. Quantifiers scope • Scope: in XS the scope of thequantifier is the whole formula S.X [block(X) => color_of(X,red)] \/ on(a,Y) • Order: existential quantifiers commute and universal quantifiers commute X (Y (Sentence)) equivalent toY (X (Sentence)) X (Y(Sentence)) equivalent toY(X (Sentence)) • Mixed quantifiers do NOT commuteX Y loves(X,Y) vs. Y X loves(X,Y) everybody loves somebody vs. somebody is loved by everybody

  15. Relations between quantifiers • Existential and universal quantifiers are related to each other through negation • DeMorgan’s laws for quantifiers X ~P  ~ X P ~P /\ ~ Q  ~(P \/ Q) ~X P  X ~ P ~(P Q)  ~P  ~Q X P  ~X ~ P P Q  ~(~P  ~Q) X P  ~ X ~ P P  Q  ~ (~P ~Q) • Example: every person has a father there is no person that does not have a father

  16. Equality and its use • The equality symbol indicates that two terms refer to the same objectfather(sarah) = moshe indicates thatthe object refered to by father(sarah) and by moshe are the same • Equality can be viewed as the identity relation=(sarah,sarah), … • Used to distinguish between objects X Y sister_of(sarah, X) /\ sister(sarah, Y)/\~(X=Y) to specify that sarah has two sisters (at least)

  17. First Order Logic – Semantics (1) • We define the meaning of terms and formulas in structures with the help of an assignment for the individual variables. • A structure consists of a non-empty domain, A, a suitable function: An  A for every n-place function symbol of , a subset of An for every n-place predicate symbol. • An variable assignment associates an element of A with each individual variable.

  18. First Order Logic – Semantics (2) Every termis interpreted as an element of the domain A: • individualvariables using the variable assignment • complex terms by applying the function corresponding to the function symbol to the interpretations of the arguments.

  19. First Order Logic – Semantics (3) • Truth value of formulas is defined recursively from the truth value of atomic formulas, as in Propositional Logic • Atomic formula: using the interpretation of the predicate symbol and the interpretations of the terms: father_of(sarah, moshe) is true iff the pair < sarah, moshe > of interpretations is in the interpretation father_of. • _father_ofis a subset of A2

  20. First Order Logic – Semantics (4) • Formulas such as A \/ B, A /\ B, ~A, A=>B are interpreted as in propositional calculus • X S is true iff there is some element w of the domain A, such that S gets the value True, when one uses not the original variable assignment but the modified assignment in which X gets associated with w. • X S is true iff S gets the value true with all variable assignments that differ from the original one only in the value associated with X.

  21. Variable assignement and satisfiability • A sentence S is satisfied by a variable assignment U when the ground sentence S[U] is valid |= S[U] for U ={X/a, Y/b, ….} • The satisfiability of logical sentences is determined by the logical connective |=(S1/\S2 /\ … /\ Sn)[U] iff |= Si[U]for all i = 1 .. n |=(S1\/ S2 \/ … \/ Sn)[U] iff |= Si[U]for some i = 1 .. n

  22. Expressing knowledge in FOL • Given a world or domain, identify and define constant objects, functions, and relation predicates • Define relevant domain knwoledge stated informally in English as a set of FOL sentences • KB usually has two types of statements • statements about the specific objects -- • statements about general relationships -- axioms • Many possible ways of defining the KB! aim for parsimony and soundness

  23. Example:family relations domain • Objects: members of the family • Functions: father, mother • Relations: male, female, parent_of, sibling_of, brother_of, sister_of, child_of, daughter_of, son_of, spouse_of, wife_of, husband_of, …. • statements about the specific familyfemale(sarah), father(sarah) = moshe • statements about family relationshipsXY : (Z = father(X) /\ Z =mother(X) ) => sibling(X, Y)

  24. Some family relationships rules • A mother is a female parent MC mother(M) = C <=> female(C)/\ parent_of(M,C) • A grandparent is a parent of one’s parent GC grandparent_of(G,C) <=>Pparent_of(G,P)/\parent_of(P,C) • Parent and child are inverse relationsP C parent_of(P,C) <=> child_of(C,P) • A sibling is another child of one’s parents X Y sibling_of(X,Y) <=> X  Y /\Pparent_of(P,X)/\parent_of(P,Y)

  25. Inference in First Order Logic • As for propositional logic, will work only on the syntactic form of the sentences • Extend the rules of propositional logic to deal with quantifiers and variables. The rules will deal with variable assignment, using (syntactic) substitutions. • You have seen, in Mathematical Logic I, a list of axioms and rules of inference that make a sound and complete proof system for FOL (Godel’s Completeness Theorem). This is not the best system for automatic inferencing.

  26. Inference Rules: examples (1) From KB: 1. M C mother(C) = M <=> female(M)/\ parent(M,C) 2. mother(sarah) = ruth Deduce:female(ruth) /\parent(ruth,sarah)

  27. Inference Rules: examples (2) From KB = 1. X father_of(Y, X) \/ husband_of(mother(Y), X) 2. husband_of(mother(Y), Z) Deduce: father_of(Y, Z) From KB = {X R(Y, X) \/ ~P(f(Y), X) P(f(Y), Z)} Deduce: R(Y, Z)

  28. Substitution • Substitution is a syntactic operation that takes a formula and replaces a variable everywhere it appears by a term. • Subst(,S)is theresult ofreplacing the variables X, Y, …. by the terms t1, t2, …respectively in a formula S. The result is denoted S[]. ={X/t1, Y/t2, …} • For example father_of(X, Y)[ X/sarah, Y/moshe ] is father_of(sarah, moshe) Substitution is syntactic, variable assignment is semantic.

  29. Other rules: good and bad • Universal Elimination: X S for any t S[X/t] In particular: X S S • Universal Introduction: S X S If KB does not mention the variable X

  30. FOL -- Inference Rules for quantifiers • Substitution operation Subst(,S)is theresult ofapplying the variable assignement ={X/x, Y/y, …} to S, i.e, S[] • Universal and Existential Elimination • Existential Introduction

  31. Example of a proof “It is a crime for an American to sell weapons to hostile nations. North Korea is an enemy of America, has some missiles, and all of its missiles were sold to it by Coronel West, who is American.” Prove that Coronel West is a criminal!

  32. Formalization 1. X,Y,Z american(X) /\ weapon(Y) /\ nation(Z) /\hostile(Z) /\ sells(X,Z,Y) =>criminal(X) 2.Xmissile(X) /\owns(nkorea,X) 3. X missile(X)/\ owns(nkorea,X) => sells(west,nkorea,X) 4. Xmissile(X) => weapon(X) 5. Xenemy(X,america) =>hostile(X) 6. american(west) 7. nation(nkorea) 8. enemy(nkorea,america) 9. nation(america)

  33. Proof (1) 2. and Existential elimination 10. missile(m) /\owns(nkorea,m) X/m 10. and And-Elimination 11. owns(nkorea,m) 12. missile(m) 4. And Universal Elimination 13. missile(m) => weapon(m) X/m 12, 13 and Modus Ponens 14.weapon(m) 3 and Universal Elimination 15. missile(m) /\ owns(nkorea,m) => sells(west,nkorea,m)

  34. Proof (2) 15, 10 and Modus Ponens 16.sells(west, nkorea,m) 1 and Universal Elimination (three times) 17.american(west) /\ weapon(m) /\ nation(nkorea) /\hostile(nkorea) /\ sells(west,nkorea,m) =>criminal(west) 5 and Universal Elimination 18.enemy(nkorea,america) =>hostile(nkorea) 8, 18 and Modus Ponens

  35. Proof (3) 19.hostile(nkorea) 6, 7, 14, 16, 19 and And-Introduction 20. american(west) /\weapon(m) /\nation(nkorea) /\ hostile(nkorea) /\sells(west,nkorea,m) 17, 20 and Modus Ponens21. criminal(west)

  36. FOL inferences • Soundness: Rules for propositional logic are sound. • Godel proposed a system R and proved in 1931 that in FOL any sentence that logically follows from a KB can be proven: if KB |= S then KB |=RS • Robinson developed in 1965 a mechanizable proof procedure based on resolution -- we will study it in detail next.

  37. Main differences with propositional logic • There are infinitely many possible models: we cannot just enumerate all the models to see whether a sentence is satisfied in all models. • There still exist refutation-complete rules • Godel’s incompleteness theorem says that we cannot hope for the application of these rules to terminate always when the formula C is not entailed by KB.

  38. Key issues in developing an effective inference procedure • Have as few inference rules as possible to reduce the search’s branching factor • The complexity is still exponential in the number of atomic sentences • More efficient procedures for restricted forms of logic sentences (Horn clauses)

More Related