



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Chris Brooks Department of Computer Science University of San Francisco ?? Department of Computer Science — University of San Francisco – p.1/
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/
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/
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/
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.
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.
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/
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/
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/
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/
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.
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.
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/
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/
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/
= [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/
) 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
. 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.
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/
Recall Resolution in Propositional Logic:
Resolution in FOL works similarly. Requires that sentences be in CNF. ?? Department of Computer Science — University of San Francisco – p.26/
The recipe for converting FOL sentences to CNF is similar to propositional logic.
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/
, 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 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.
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/
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/
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/