Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

Similar presentations


Presentation on theme: "1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material."— Presentation transcript:

1 1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material

2 2 Propositional Logic Limitations Stating similar facts is cumbersome Can’t make generalizations The world (in propositional logic) contains facts, not objects Natural language deals with objects (nouns) and relations (verbs), hence is more expressive Ontological commitment of PL is limited

3 3 First Order Logic World consists of Objects Relations Functions Sentences are made up of Symbols: for constant objects, predicates, and functions Connectives: as in PL Quantifiers and variables:  x,  y

4 4 FOL Syntax Sentence Atomic Sentence ( Sentence Connective Sentence )  Sentence Quantifier Variable Sentence Atomic Sentence Predicate-Symbol( Term, … ) Term = Term

5 5 FOL Syntax Term (refers to an object) Function-Symbol( Term, … ) Constant-Symbol Variable Connective: , , , , Quantifier: ,  Variable: x, y, z, …

6 6 Example

7 7 Symbols Constants: John, Richard, C, L1, L2 Predicates: Person={John, Richard} King={Richard} Crown={C} Brother={(John,Richard),(Richard,John)} OnHead={(C,Richard)} Functions: LeftLeg={(Richard->L1),(John->L2)} (strictly speaking, the function should be total)

8 8 Models and Interpretations A model in FOL consists of the objects (domain elements) and relations (including functions) See example diagram “conceptual” view of world An interpretation associates the symbols to the objects, relations, and functions in the model Number of interpretations for a given set of symbols is combinatorially explosive

9 9 Semantics Truth of a sentence in FOL: Determined with respect to a model and an interpretation Analogous notions for entailment, validity, and satisfiability Model enumeration is impractical in FOL

10 10 Sample Sentences Person(John)  Person(Richard) OnHead(C, John) LeftLeg(John) = L1  LeftLeg(Richard) = L1 Richard, and LeftLeg(John) are examples of terms (a term is an expression that refers to an object) Atomic Sentences: constructed by equating terms (=) or by a predicate (with terms as arguments) Complex Sentences: sentences with connectives

11 11 Quantifiers Universal Quantification  x P is true in a model m iff P is true with x being each possible object in the model A conjunction of instantiations Existential Quantification  x P is true in a model m iff P is true with x being some object in the model A disjunction of instantiations

12 12 Sample Sentences Using Quantifiers  x King(x)  Person(x)  x Crown(x)  OnHead(x,John) “John has a crown on his head”  x  y Brother(x,y)  Brother(y,x)  x  y Brother(x,Richard)  Brother(y,Richard)   (x=y) “Richard has at least 2 brothers”

13 13 Properties of Quantifiers Nested Quantifiers  x  y P equivalent to  y  x P  y  x P equivalent to  y  x P Does not apply if quantifiers are different De Morgan’s law for quantifiers  x  P   x P  x P   x  P  x  P   x P  x P   x  P

14 14 More About Quantifiers Be careful when: Using quantifiers ( ,  ) in combination with ,  The domain consists of multiple kinds of objects In the quantified sentence (such as  x P or  x P), P would typically contain terms that are variables Not just ground terms (terms that have no variables)  x P as a query: binding list more important than truth of the sentence

15 15 Axioms and Theorems Axioms are sentences that represent first principles Plain facts Definitions Theorems are sentences entailed by axioms

16 16 Some Useful Domains Natural Numbers Built from 0, successor function S, and Peano axioms Sets , , , , and element insertion Lists Nil, Cons, Append, First, Rest, Find, …

17 17 FOL and the Wumpus World We can represent the Wumpus World in a more compact fashion Less sentences needed to represent rules We can include time and percept objects in the world A percept is represented as a list of constant symbols Predicates with time arguments capture the dynamic nature of the agent moving in this world

18 18 Knowledge Engineering Identify the task Assemble the relevant knowledge Decide on a vocabulary Encode general knowledge of the domain Encode the specific problem instance Pose queries to the inference procedure Debug the knowledge base

19 19 Inference Algorithms in FOL Reduction to Propositional Inference (Propositionalization) Lifting and Unification Resolution

20 20 Propositionalization Strategy: convert KB to propositional logic and then use PL inference Ground atomic sentences become propositional symbols What about the quantifiers?

21 21 Example KB in FOL:  x King(x)  Greedy(x)  Evil(x) King(John) Greedy(John) Brother(Richard,John) The last 3 sentences can be symbols in PL Apply Universal Instantiation to the first sentence

22 22 Universal Instantiation UI says that from a universally quantified sentence, we can infer any sentence obtained by substituting a ground term for the variable Back to Example From:  x King(x)  Greedy(x)  Evil(x) To: King(John)  Greedy(John)  Evil(John) King(Richard)  Greedy(Richard)  Evil(Richard) …

23 23 Issue with UI Ground terms: all symbols that refer to objects as well as function applications (recall that function applications return objects) For example, suppose Father is a function: Father(John) and Father(Richard) are also objects/ground terms But so are Father(Father(John)) and Father(Father(Father(John))) Infinitely many ground terms/instantiations

24 24 Existential Instantiation Whenever there is a sentence,  x P, introduce a new object symbol called the skolem constant and then add the unquantified sentence P, substituting the variable with that constant Example: From:  x Crown(x)  OnHead(x, John) To: Crown(C new )  OnHead(C new, John)

25 25 Substitution UI and EI apply substitutions A substitution is represented by a variable v and a ground term g; {v/g} Can have sets of these pairs if there are more variables involved Let  be a sentence (possibly containing v) SUBST( {v/g},  ) stands for the sentence that applies the substitution to 

26 26 UI and EI Defined UI:  v α ___ for any ground term g SUBST({v/g}, α) EI:  v α ___ for some constant symbol k not SUBST({v/k}, α) yet in the knowledge base

27 27 Back to Propositionalization Given a KB in FOL, convert KB to PL by 1. applying UI and EI to quantified sentences 2. converting atomic sentences to symbols If there are no functions (Datalog KB), UI application does not result in infinitely many sentences Regular PL Inference can now be carried out without problems What if there are functions?

28 28 Dealing with Infinitely Many Ground Terms Can set a depth-limit for ground terms Depth specifies levels of function nesting allowed Carry out reduction and inference process for depth 1, then 2, then 3, … Stop when entailment can be concluded This works if there is such a proof, but goes into an endless loop if there is not The strategy is complete The entailment problem in this sense is semidecidable

29 29 Inefficiencies in Propositionalization An inordinate number of irrelevant sentences may be generated, resulting from UI This motivates generating only those sentences that are important in entailment

30 30 Example Suppose KB contains:  x King(x)  Greedy(x)  Evil(x)  y Greedy(y) King(John) Suppose we want to conclude Evil(John) Because of the existence of objects other than John (such as Richard) and the existence of functions, UI will generate many sentences

31 31 Example, continued It is sufficient to generate: King(John)  Greedy(John)  Evil(John) Greedy(John) Which is just: SUBST( {x/John}, King(x)  Greedy(x)  Evil(x) ) SUBST( {y/John}, Greedy(y) ) Applying the substitution matches the Premises: King(x)  Greedy(x) With other sentences in the KB: Greedy(y), King(John)

32 32 Lifted Modus Ponens Lifting: Raising propositional inference rules to first order logic Example: Generalized Modus Ponens If there is a substitution θ, such that SUBST(θ, p i ) = SUBST(θ, p i ’) for all i, then p 1 ', p 2 ', …, p n ’, ( p 1  p 2  …  p n  q) _______________________________________________________________________________ SUBST(θ,q) In our example,  = {x/John, y/John}

33 33 Unification Process that makes logical expressions identical Goal: match the premises of implications so that conclusions can be derived UNIFY algorithm takes two sentences and returns a unifier (substitution) if it exists

34 34 Unification Algorithm

35 35 Unification Algorithm

36 36 About UNIFY UNIFY returns a Most General Unifier (MGU) There are efficiency issues with OCCUR-CHECK function May need to standardize apart: rename variables to avoid name clashes Unification is a key component of all first-order algorithms

37 37 Algorithms that use unification Forward and backward chaining algorithms Will not be discussed Resolution-based theorem proving systems

38 38 PL Resolution Revisited Recall PL Resolution algorithm: Convert (KB   ) to CNF Repeatedly get pairs of clauses and eliminate complementary literals If an empty clause results, KB ╞  Resolution applies to FOL, but we need to refine definitions of: CNF (for quantified sentences) Resolution inference rule / complimentary literals

39 39 CNF Conversion in FOL 1. Eliminate biconditionals and implications 2. Move  inwards (De Morgan’s) For quantifiers:  x P   x  P,  x P   x  P 3. Standardize variables Eliminate possible name clashes 4. Skolemize (Apply EI to existential sentences) Introduce Skolem constants or functions 5. Drop universal quantifiers 6. Distribute  over 

40 40 Example Everyone who loves all animals is loved by someone:  x [  y Animal(y)  Loves(x,y)]  [  y Loves(y,x)] 1. Eliminate biconditionals and implications  x [  y  Animal(y)  Loves(x,y)]  [  y Loves(y,x)] 2. Move  inwards:  x [  y  (  Animal(y)  Loves(x,y))]  [  y Loves(y,x)]  x [  y  Animal(y)   Loves(x,y)]  [  y Loves(y,x)]  x [  y Animal(y)   Loves(x,y)]  [  y Loves(y,x)] 3. Standardize variables: each quantifier should use a different one  x [  y Animal(y)   Loves(x,y)]  [  z Loves(z,x)]

41 41 Example, continued 4. Skolemize: a more general form of existential instantiation. Each existential variable is replaced by a Skolem function of the enclosing universally quantified variables:  x [Animal(F(x))   Loves(x,F(x))]  Loves(G(x),x) 5. Drop universal quantifiers: [Animal(F(x))   Loves(x,F(x))]  Loves(G(x),x) 6. Distribute  over  : [Animal(F(x))  Loves(G(x),x)]  [  Loves(x,F(x))  Loves(G(x),x)]

42 42 Resolution Lifted version of resolution inference rule: l 1  ···  l k, m 1  ···  m n (l 1  ···  l i-1  l i+1  ···  l k  m 1  ···  m j-1  m j+1  ···  m n )θ where Unify (l i,  m j ) = θ. The two clauses are assumed to be standardized apart so that they share no variables For example,  Rich(x)  Unhappy(x), Rich(Ken) Unhappy(Ken) with θ = {x/Ken}

43 43

44 44 Making Resolution More Efficient Can favor particular clauses in the KB Unit preference (unit clauses) Sets of support Input resolution (e.g. “single spine”) Subsumption Reduces size of KB by eliminating redundant sentences


Download ppt "1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material."

Similar presentations


Ads by Google