Inferencing in First-Order Logic: Unification and Resolution - Prof. Christopher H. Brooks, Study notes of Computer Science

This document from the university of san francisco's department of computer science discusses how to perform inference in first-order logic (fol), specifically focusing on unification and resolution. The basics of fol, the need for variable bindings, converting fol sentences to propositional sentences, removing quantifiers, propositionalization, unification, and generalized modus ponens. It also introduces forward and backward chaining, as well as resolution in fol.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-1gj
koofers-user-1gj 🇺🇸

5

(1)

8 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Artificial Intelligence Programming
Inference in FOL
Chris Brooks
Department of Computer Science
University of San Francisco
Departmentof Computer Science —University of San Francisco p.1/??
10-0: Propositional Logic Review
Recall that propositional logic concerns:
facts about the world that are true or false.
These facts can be used to construct sentences using
logical connectives (,,¬,,)
Example: P1,1P2,2.
We can convert these sentences to CNF and use
resolution as an inference mechanism.
Resolution is sound and complete.
Departmentof Computer Science —University of San Francisco p.2/??
10-1: Propositional Logic Review
First order logic concerns:
Objects and relations between them, which form
atomic sentences.
Atomic sentences can be joined with logical
connectives.
We can introduce variables and quantifiers to refer to
indefinite objects.
Example: Siblings(B art, Lisa)
xlikes(x, M arge)likes(x,homer)
Departmentof Computer Science —University of San Francisco p.3/??
10-2: Inference in FOL
Can we do the same sorts of inference with First-order
logic that we do with propositional logic?
Yes, with some extra details.
Need to keep track of variable bindings (substitution)
Departmentof Computer Science —University of San Francisco p.4/??
10-3: Inference in FOL
As with propositional logic, we’ll need to convert our
knowledge base into a canonical form.
In the simplest approach, we can convert our FOL
sentences to propositional sentences. We do this by
removing quantification.
we leave in predicates for readability, but remove all
variables.
Departmentof Computer Science —University of San Francisco p.5/??
10-4: Removing quantifiers
Universal Instantiation: we can always substitute a ground
term for a variable.
This will typically be a term that occurs in some other
sentence of interest.
xLivesIn(x, S pringf ield)knows(x, H omer)
Since this is true for all x, we can substitute {x=Bart}
LivesIn(B art, Spring field)k nows(Bart, Homer )
The classical approach: make this substitution for every
object in our domain.
Departmentof Computer Science —University of San Francisco p.6/??
pf3
pf4
pf5

Partial preview of the text

Download Inferencing in First-Order Logic: Unification and Resolution - Prof. Christopher H. Brooks and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence Programming

Inference in FOL

Chris Brooks Department of Computer Science University of San Francisco ?? Department of Computer Science — University of San Francisco – p.1/

Propositional Logic Review 10-0:

Recall that propositional logic concerns: facts about the world that are true or false. These facts can be used to construct sentences using )⇔ , ⇒ ,¬ ,∨ ,∧ logical connectives (

.^2 ,^2 P ∨^1 ,^1 P Example: We can convert these sentences to CNF and use resolution as an inference mechanism. Resolution is sound and complete. ?? Department of Computer Science — University of San Francisco – p.2/

Propositional Logic Review 10-1:

First order logic concerns: Objects and relations between them, which form atomic sentences. Atomic sentences can be joined with logical connectives. We can introduce variables and quantifiers to refer to indefinite objects. ) Bart, Lisa( Siblings Example: ) x, homer( likes ⇒ ) x, M arge( xlikes ∀ ?? Department of Computer Science — University of San Francisco – p.3/

Inference in FOL 10-2:

Can we do the same sorts of inference with First-order logic that we do with propositional logic? Yes, with some extra details. Need to keep track of variable bindings (substitution) ?? Department of Computer Science — University of San Francisco – p.4/

Inference in FOL 10-3:

As with propositional logic, we’ll need to convert our knowledge base into a canonical form. In the simplest approach, we can convert our FOL sentences to propositional sentences. We do this by removing quantification. we leave in predicates for readability, but remove all variables.

Removing quantifiers 10-4:

Universal Instantiation: we can always substitute a ground term for a variable. This will typically be a term that occurs in some other sentence of interest. ) x, Homer( knows ⇒ ) x, Springf ield( xLivesIn ∀ } Bart = x{ , we can substitutex Since this is true for all ) Bart, Homer( knows ⇒ ) Bart, Springf ield( LivesIn The classical approach: make this substitution for every object in our domain.

Removing quantifiers 10-5:

Existential Instantiation: we can give a name to the object that satisfies a sentence. ) x, Homer( knows ∧ ) x, Springf ield( xLivesIn ∃ We know this must hold for at least one object. Let’s .k call that object ) k, Homer( knows ∧ ) k, Springf ield( LivesIn

. Skolem constant is called a k must be unused - gives us a way of referring to an k existential object. Once we’ve removed quantifiers, we can use propositional inference rules. ?? Department of Computer Science — University of San Francisco – p.7/

Propositionalization 10-6:

We can replace every existential sentence with a Skolemized version. every For universally quantified sentences, substitute in possible substitution. This will (in theory) allow us to use propositional inference rules. Problem: very inefficient! This was the state of the art until about 1960. Unification of variables is much more efficient. ?? Department of Computer Science — University of San Francisco – p.8/

Unification 10-7:

The key to unification is that we only want to make substitutions for those sentences that help us prove things. For example, if we know: ∧ ) x, Springf ield( xLivesIn ∀ ) x, Homer( knows ⇒ ) x, P owerP lant( W orksAt ) y, Springf ield( yLivesIn ∀ ) M rSmithers, P owerP lant( W orksAt We should be able to conclude directly. ) M rSmithers, Homer( knows } x/M rSmithers, y/M rSmithers{ Substitution: ?? Department of Computer Science — University of San Francisco – p.9/

Generalized Modus Ponens 10-8:

This reasoning is a generalized form of Modus Ponens. Basic idea: Let’s say we have: Q ⇒^ iP ∧ ... ∧^2 P ∧^1 P An implication of the form ′^ i , ..., P′^2 , P′^1 P^ Sentences a set of substitutions such that nP =^ ′ n , ..., P′ 2 P = (^2) , P′ 1 P = (^1) P We can then apply the substitution and apply Modus .Q Ponens to conclude this technique of using substitutions to pair up sentences

. unification for inference is called ?? Department of Computer Science — University of San Francisco – p.10/

Unification 10-9:

Our inference process now becomes one of finding substitutions that will allow us to derive new sentences. The Unify algorithm: takes two sentences, returns a set of substitutions that unifies the sentences. produces ) Homer, P owerP lant( , W orksAt) x, P owerP lant( W orksAt .} x/Homer { produces ) Homer, y( , W orksAt) x, P owerP lant( W orksAt } x/Homer, y/P owerP lant { produces ), y) Bart ( F atherOf( , W orksAt) x, P owerP lant( W orksAt } , y/P owerP lant) Bart( x/F atherOf { fails - x can’t bind to both ) Homer, x( , W orksAt) x, P owerP lant( W orksAt Homer and PowerPlant.

Unification 10-10:

This last sentence is a problem only because we in both sentences. x happened to use ) is one^21 x with a unique variable (say x We can replace sentence. This is called standardizing apart.

Example 10-17:

Algorithm: Repeatedly fire all rules whose antecedents are satisfied. .)^1 M( W eapon. Add}^1 x/M{ Rule 6 matches with Fact 4.

. Add}^1 x/M{ Rule 5 matches with 3 and 4. ) , N ono^1 W est, M( Sells ) N ono( Hostile. Add} x/N ono{ Rule 7 matches with 9. Iterate again. } , z/N ono^1 x/W est, y/M{ Now we can match rule 1 with .) W est( Criminal and conclude ?? Department of Computer Science — University of San Francisco – p.19/

Analyzing basic forward 10-18:

chaining

Forward chaining is sound, since it uses Modus Ponens. Forward chaining is complete for definite clauses. Works much like BFS This basic algorithm is not very efficient, though. Finding all possible unifiers is expensive Every rule is rechecked on every iteration. Facts that do not lead to the goal are generated. ?? Department of Computer Science — University of San Francisco – p.20/

Backward Chaining 10-19:

Basic idea: work backward from the goal to the facts that must be asserted for the goal to hold. Uses Modus Ponens (in reverse) to focus search on finding clauses that can lead to a goal. Also uses definite clauses. Search proceeds in a depth-first manner. ?? Department of Computer Science — University of San Francisco – p.21/

Backward Chaining Algorithm 10-20:

= [goal_to_prove] goals [] = substitution_list : (empty(goals))) (not while goals.dequeue = goal substitution_list) unify(goals, KB in sentence foreach q))) (unify(consequent(sentence, if goals.push(antecedents(sentence)) ?? Department of Computer Science — University of San Francisco – p.22/

Backward Chaining Example 10-21:

) W est( .Criminal 1 To Prove: To prove 1, prove: ) W est, y, z( .Sells)5z( .Hostile)4y( .W eapon 3 ,) W est( .American 2 2 unifies with 8. To prove: ) W est, y, z( .Sells)5z( .Hostile)4y( .W eapon 3

. To prove:}^1 x/M{ 6 unifies with 3 ), z^1 W est, M( .Sells)5z( .Hostile 4 ,)^1 M( .M issile 6. )^1 N ono, M( Owns and add }^1 x/M{ We can unify 6 with 2 ), z^1 W est, M( .Sells)5z( .Hostile 4 to the KB. To prove: . To prove:) z, America( Enemy , prove)z( Hostile To prove )^1 M( .M issile 6 ,), z^1 W est, M( .Sells 5 ,) z, America( .Enemy 7

Backward Chaining Example 10-22:

. To} x/N ono{) N ono, America( Enemy We can unify 7 with )^1 M( .M issile 6 ,) , N ono^1 W est, M( .Sells 5 prove: and )^1 M( M issile , prove) , N ono^1 W est, M( Sells To prove To prove: )^1 N ono, M( Owns )^1 M( .M issile 6 ,)^1 N ono, M( .Owns 8 8 resolves with the fact we added earlier. To prove: )^1 M( .M issile 6 resolves with 5. The list of goals is empty, so )^1 M( M issile we are done.

Analyzing Backward Chaining 10-23:

Backward chaining uses depth-first search. This means that it suffers from repeated states. Also, it is not complete. Can be very effective for query-based systems Most backward chaining systems (esp. Prolog) give the programmer control over the search process, including backtracking. ?? Department of Computer Science — University of San Francisco – p.25/

Resolution 10-24:

Recall Resolution in Propositional Logic:

)C ∨ B( ⇒ )B ∨ A¬( ∧ )C ∨ A (

Resolution in FOL works similarly. Requires that sentences be in CNF. ?? Department of Computer Science — University of San Francisco – p.26/

Conversion to CNF 10-25:

The recipe for converting FOL sentences to CNF is similar to propositional logic.

  1. Eliminate Implications inwards ¬ 2. Move
  2. Standardize apart
  3. Skolemize Existential sentences
  4. Drop universal quantifiers ∨ over ∧ 6. Distribute ?? Department of Computer Science — University of San Francisco – p.27/

CNF conversion example 10-26:

Sentence: Everyone who loves all animals is loved by someone. ))y, x( yLoves∃( ⇒ ))x, y( loves ⇒ )y( yAnimal∀(x∀ Translation: Eliminate implication ))y, x( yLoves∃( ∨ ))x, y( loves ∨ )y( Animal¬y¬∀(x ∀ Move negation inwards ))y, x( yLoves∃( ∨ )))x, y( Loves ∨ )y( Animal¬(¬y∃(x ∀ ))y, x( yLoves∃( ∨ )))x, y( Loves∧ ¬ )y( Animal¬¬y∃(x ∀ ))y, x( yLoves∃( ∨ )))x, y( Loves∧ ¬ )y( yAnimal∃(x ∀ Standardize apart ))z, x( zLoves∃( ∨ )))x, y( Loves∧ ¬ )y( yAnimal∃(x ∀ ?? Department of Computer Science — University of San Francisco – p.28/

CNF conversion example 10-27:

, rather than a constant. Skolem function Skolemize. In this case we need a )), x)x(G(( Loves( ∨ )))x, y( Loves∧ ¬ ))x( F( Animal(x ∀ Drop universals )), x)x(G(( Loves( ∨ ))))x( x, F( Loves∧ ¬ ))x (F( Animal ( ∨ over ∧ Distribute )), x)x(G(( Loves( ∨ ))))x( x, F( Loves¬( ∧ )), x)x(G( Loves ∨ ))x (F( Animal (

Resolution Theorem Proving 10-28:

Resolution proofs work by inserting the negated form of the sentence to prove into the knowledge base, and then attempting to derive a contradiction. is used to help guide search set of support A These are facts that are likely to be helpful in the proof. This provides a heuristic.

Rete Example 10-35:

Let’s say we have the following rules: drink-beer (defrule homer) (thirsty => homer))) (drink-beer (assert go-to-moes (defrule homer) (thirsty ˜moes) homer (at => moes))) homer (at (assert happy-homer (defrule homer) (drink-beer moes) homer (at (friday) => homer))) (happy (assert What would the network look like? ?? Department of Computer Science — University of San Francisco – p.37/

Rete Example 10-36:

Single-input nodes receive a fact, test it, and propagate. Two-input nodes group and unify facts that match each parent. We can also share nodes among rules, which improves efficiency. (watch compilations) in Jess shows the network structure generated by a rule. +1+1+1+1+1+1+2+2+t indicates 6 new 1-input nodes and 2 new 2-input nodes, plus one new terminal node. =1=1=1=1+2+t indicates four shared one input nodes, plus a new two-input node and a terminal node. ?? Department of Computer Science — University of San Francisco – p.38/

Practical Expert Systems 10-37:

Rete inspired a whole generation of expert systems. One of the most successful AI technologies. Nice fit with the way human experts describe problems. Made it possible to construct large-scale rule-based systems. Locating oil deposits, controlling factories, diagnosing illness, troubleshooting networks, etc. uncertainty Most expert systems also include a notion of We’ll examine this in the context of Bayesian networks. We will see this idea of networks of information again. ?? Department of Computer Science — University of San Francisco – p.39/