Download Lecture Notes on First-Order Logic | CS 1571 and more Study notes Computer Science in PDF only on Docsity!
CS 1571 Intro to AI M. Hauskrecht
CS 1571 Introduction to AI
Lecture 18
Milos Hauskrecht [email protected] 5329 Sennott Square
First-order logic
Tic-tac-toe competition
Results:
- Richard Matchett
- Vinay Sarpeshkar
- Brandon Blatnick
CS 1571 Intro to AI M. Hauskrecht
First-order logic (FOL)
- More expressive than propositional logic
- Eliminates deficiencies of PL by:
- Representing objects, their properties, relations and statements about them;
- Introducing variables that refer to an arbitrary objects and can be substituted by a specific object
- Introducing quantifiers allowing us to make statements over groups objects without the need to represent each of them separately
Logic
Logic is defined by :
- A set of sentences
- A sentence is constructed from a set of primitives according to syntax rules.
- A set of interpretations
- An interpretation gives a semantic to primitives. It associates primitives with objects, values in the real world.
- The valuation (meaning) function V
- Assigns a truth value to a given sentence under some interpretation V : sentence ×interpretation →{ True , False }
CS 1571 Intro to AI M. Hauskrecht
First order logic. Syntax.
Sentences in FOL:
- Complex sentences:
Assume are sentences in FOL. Then:
and
Symbols
- stand for the existential and the universal quantifier
∀ x φ ∃ y φ
Semantics. Interpretation.
An interpretation I is defined by a mapping to the domain of discourse D or relations on D
- domain of discourse: a set of objects in the world we represent and refer to; An interpretation I maps :
- Constant symbols to objects in D I( John ) =
- Predicate symbols to relations, properties on D
- Function symbols to functional relations on D
I( brother ) =
I( father-of ) =
CS 1571 Intro to AI M. Hauskrecht
Semantics of sentences.
Meaning (evaluation) function :
A predicate predicate(term-1, term-2, term-3, term-n) is true for the interpretation I , iff the objects referred to by term-1, term- 2, term-3, term-n are in the relation referred to by predicate
V : sentence × interpretation →{ True , False }
V( brother(John, Paul), I ) = True
I( brother ) =^ ;^ ; ….
I( John ) = I( Paul ) =
brother(John, Paul) = in I( brother )
Semantics of sentences.
- Equality
- Boolean expressions: standard
- Quantifications
V( term-1= term-2, I ) = True Iff I( term-1 ) =I( term-2 )
V( sentence-1 ∨ sentence-2, I ) = True
Iff V( sentence-1,I )= True or V( sentence-2,I )= True
E.g.
V( , I ) = True Iff for all V( ,I[x/d] )= True
∀ x φ
d ∈ D φ
V( , I ) = True Iff there is a , s.t. V( ,I[x/d] )= True
∃ x φ
d ∈ D φ
substitution of x with d
CS 1571 Intro to AI M. Hauskrecht
Inference in First order logic
Logical inference in FOL
Logical inference problem :
- Given a knowledge base KB (a set of sentences) and a sentence , does the KB semantically entail?
In other words: In all interpretations in which sentences in the KB are true, is also true?
Logical inference problem in the first-order logic is undecidable !!!. No procedure that can decide the entailment for all possible input sentences in a finite number of steps.
KB |= α?
α
α α
CS 1571 Intro to AI M. Hauskrecht
Logical inference problem in the Propositional logic
Computational procedures that answer:
Three approaches:
- Truth-table approach
- Inference rules
- Conversion to the inverse SAT problem
KB |= α?
Inference in FOL: Truth table
- Is the Truth-table approach a viable approach for the FOL?
CS 1571 Intro to AI M. Hauskrecht
Inference in FOL: Inference rules
- Is the Inference rule approach a viable approach for the FOL?
- Yes.
- The inference rules represent sound inference patterns one can apply to sentences in the KB
- What is derived follows from the KB
- Caveat: we need to add rules for handling quantifiers
Inference rules
- Inference rules from the propositional logic:
- Modus ponens
- Resolution
- and others: And-introduction, And-elimination, Or- introduction, Negation elimination
- Additional inference rules are needed for sentences with quantifiers and variables - Must involve variable substitutions
B
A ⇒ B , A
A C
A B B C
CS 1571 Intro to AI M. Hauskrecht
Sentences with variables
First-order logic sentences can include variables.
- Variable is:
- Bound – if it is in the scope of some quantifier
- Free – if it is not bound.
Examples:
∀ xP ( x )
∃ x P ( y )∧ Q ( x ) y is free
∀ x ∃ yLikes ( x , y )
Sentences with variables
First-order logic sentences can include variables.
- Variable is:
- Bound – if it is in the scope of some quantifier
- Free – if it is not bound.
Examples:
∀ xP ( x )
∃ x P ( y )∧ Q ( x ) y is free
∀ x ∃ yLikes ( x , y )
∀ x ( Likes ( x , y )∧∃ yLikes ( y , Raymond ))
CS 1571 Intro to AI M. Hauskrecht
Variable substitutions
- Variables in the sentences can be substituted with terms. (terms = constants, variables, functions)
- Substitution:
- Is represented by a mapping from variables to terms
- Application of the substitution to sentences
{ x 1 / t 1 , x 2 / t 2 ,K}
SUBST ({ x / Sam , y / Pam }, Likes ( x , y ))= Likes ( Sam , Pam )
SUBST ({ x / z , y / fatherof ( John )}, Likes ( x , y ))=?
Variable substitutions
- Variables in the sentences can be substituted with terms. (terms = constants, variables, functions)
- Substitution:
- Is represented by a mapping from variables to terms
- Application of the substitution to sentences
{ x 1 / t 1 , x 2 / t 2 ,K}
SUBST ({ x / Sam , y / Pam }, Likes ( x , y ))= Likes ( Sam , Pam )
Likes z fatherof John
SUBST x z y fatherof John Likes x y =
CS 1571 Intro to AI M. Hauskrecht
Inference rules for quantifiers
- Universal elimination
- substitutes a variable with a constant symbol
- Existential elimination.
- Substitutes a variable with a constant symbol that does not appear elsewhere in the KB
a
x x
a
x x
a - is a constant symbol
∀ x Likes ( x , IceCream ) Likes ( Ben , IceCream )
∃ x Kill ( x , Victim ) Kill ( Murderer , Victim )
Inference rules for quantifiers
- Universal instantiation (introduction)
- Introduces a universal variable which does not affect or its assumptions
- Existential instantiation (introduction)
- Substitutes a ground term in the sentence with a variable and an existential statement
x x
a
φ
φ
∀ x
x – is not free in φ
a – is a ground term in x – is not free in
φ φ
φ
Likes ( Ben , IceCream ) ∃ xLikes ( x , IceCream )
Sister ( Amy , Jane ) ∀ xSister ( Amy , Jane )
CS 1571 Intro to AI M. Hauskrecht
Unification. Examples.
UNIFY ( Knows ( John , x ), Knows ( John , Jane ))={ x / Jane }
UNIFY ( Knows ( John , x ), Knows ( y , Ann ))={ x / Ann , y / John }
UNIFY Knows John x Knows y MotherOf y
UNIFY ( p , q )= σ s.t. SUBST( σ , p )= SUBST ( σ, q )
Unification. Examples.
UNIFY ( Knows ( John , x ), Knows ( John , Jane ))={ x / Jane }
UNIFY ( Knows ( John , x ), Knows ( y , Ann ))={ x / Ann , y / John }
UNIFY ( Knows ( John , x ), Knows ( x , Elizabeth ))=?
x MotherOf John y John
UNIFY Knows John x Knows y MotherOf y
UNIFY ( p , q )= σ s.t. SUBST( σ , p )= SUBST ( σ, q )
CS 1571 Intro to AI M. Hauskrecht
Unification. Examples.
UNIFY ( Knows ( John , x ), Knows ( John , Jane ))={ x / Jane }
UNIFY ( Knows ( John , x ), Knows ( y , Ann ))={ x / Ann , y / John }
UNIFY ( Knows ( John , x ), Knows ( x , Elizabeth ))= fail
x MotherOf John y John
UNIFY Knows John x Knows y MotherOf y
UNIFY ( p , q )= σ s.t. SUBST( σ , p )= SUBST ( σ, q )
Generalized inference rules.
- Use substitutions that let us make inferences Example: Modus Ponens
- If there exists a substitution such that
- Substitution that satisfies the generalized inference rule can be build via unification process
- Advantage of the generalized rules: they are focused
- only substitutions that allow the inferences to proceed
1 2 ,^1 ', 2 ', '
SUBST B
A A An B A A An
σ
∧ ∧K ⇒ K
SUBST ( σ , Ai )= SUBST ( σ, Ai ' )
for all i=1,2, n