0% found this document useful (0 votes)
123 views24 pages

First Order Logic: Artificial Intelligence COSC-3112 Ms. Humaira Anwer

This document provides an overview of first-order logic (FOL). FOL improves on propositional logic by allowing quantification over objects and relations between objects. The syntax of FOL includes constants, predicates, functions, equality, and quantifiers. Truth in FOL is determined by a model and interpretation. Quantifiers like "for all" and "there exists" allow expressing general statements about objects. Nesting quantifiers enables more complex expressions. FOL has greater expressive power than propositional logic.

Uploaded by

Khizrah Rafique
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views24 pages

First Order Logic: Artificial Intelligence COSC-3112 Ms. Humaira Anwer

This document provides an overview of first-order logic (FOL). FOL improves on propositional logic by allowing quantification over objects and relations between objects. The syntax of FOL includes constants, predicates, functions, equality, and quantifiers. Truth in FOL is determined by a model and interpretation. Quantifiers like "for all" and "there exists" allow expressing general statements about objects. Nesting quantifiers enables more complex expressions. FOL has greater expressive power than propositional logic.

Uploaded by

Khizrah Rafique
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Lecture 22

First Order Logic


Chapter 08

Artificial Intelligence
COSC-3112

Ms. Humaira Anwer


humaira.anwer@kfueit.edu.pk

Lecture 22- First Order Logic 1


Outline
• Why FOL?
• Syntax and semantics of FOL

Lecture 22- First Order Logic 2


Pros and cons of propositional
logic
 Propositional logic is declarative

Propositional logic allows partial/disjunctive/negated information

Propositional logic is compositional:


• meaning of B1,1  P1,2 is derived from meaning of B1,1 and of P1,2

 Meaning in propositional logic is context-independent


• (unlike natural language, where meaning depends on context)
 Propositional logic has very limited expressive power
• (unlike natural language)
• E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing one sentence for each square

Lecture 22- First Order Logic 3


First-order logic
• Whereas propositional logic assumes the world
contains facts,
• first-order logic (like natural language) assumes the
world contains
• Objects: people, houses, numbers, colors, baseball
games, wars, …
• Relations: red, round, prime, brother of, bigger than,
part of, comes between, …
• Functions: father of, best friend, one more than, plus, …

Lecture 22- First Order Logic 4


Logics in General

Lecture 22- First Order Logic 5


FOL: Examples
• “One plus two equals three.”
• Objects: one, two, three;
• Relation: equals;
• Function: plus.
• “Squares neighboring the wumpus are smelly.”
• Objects: wumpus, squares;
• Property: smelly;
• Relation: neighboring.
• “Evil King John ruled England in 1200.”
• Objects: John, England, 1200;
• Relation: ruled;
• Properties: evil, king.

Lecture 22- First Order Logic 6


Syntax of FOL: Basic elements
• Constants KingJohn, 2, KFUEIT,...
• Predicates Brother, Mother, Parent,...
• Functions Sqrt, LeftLegOf,...
• Variables x, y, a, b,...
• Connectives , , , , 
• Equality =
• Quantifiers , 

Lecture 22- First Order Logic 7


Atomic sentences
Term
―Constant e.g. Red
―Function of constant, e.g. Color(Block1)
―Variable
Atomic sentence
―Predicate relating objects
• Predicate (term1,...,termn)
• Brother(John, Richard)
• Married(Mother(John),Father(John))
• E.g., Brother(KingJohn,RichardTheLionheart) >
(Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn)))

Lecture 22- First Order Logic 8


Complex sentences
• Complex sentences are made from atomic
sentences using connectives
• Atomic sentences + logical connectives
S, S1  S2, S1  S2, S1  S2, S1  S2,

• Sibling(KingJohn,Richard)  Sibling(Richard,KingJohn)
• Brother(John, Richard)  Brother (John, Father(John))

Lecture 22- First Order Logic 9


Truth in first-order logic
• Sentences are true with respect to a model and an
interpretation
• Model contains objects (domain elements) and relations
among them
• Interpretation specifies referents for
constant symbols → objects

predicate symbols → relations

function symbols → functional relations


• An atomic sentence predicate(term1,...,termn) is true
iff the objects referred to by term1,...,termn
are in the relation referred to by predicate

Lecture 22- First Order Logic 10


Models for FOL: Example

Lecture 22- First Order Logic 11


Quantifiers
• Quantifier defines a variable for the duration of
following expression, and indicates truth of the
expression.

• Types of Quantifiers
• Universal Quantifier “for all” 
• Existential Quantifier “there exists” 

Lecture 22- First Order Logic 12


Universal quantification
• Universal Quantifier “for all” 
• The expression is true for every possible value of the variable

• <variables> <sentence>

• Everyone at KFUEIT is smart:


• x At(x,KFUEIT)  Smart(x)

• x P is true in a model m iff P is true with x being each possible object in the
model

• Roughly speaking, equivalent to the conjunction of instantiations of P


At(KingJohn,KFUEIT)  Smart(KingJohn)
 At(Richard,KFUEIT)  Smart(Richard)
 At(KFUEIT,KFUEIT)  Smart(KFUEIT)
 ...
Lecture 22- First Order Logic 13
A common mistake to avoid
• Typically,  is the main connective with 
• Common mistake: using  as the main connective
with :
• x, At(x,KFUEIT)  Smart(x)
• means “Everyone is at KFUEIT and everyone is smart”

Lecture 22- First Order Logic 14


Existential quantification
• Existential Quantifier “there exists” 
• The expression is true for atleast one value of the variable
• <variables> <sentence>

• Someone at KFUEIT is smart:


• x At(x,KFUEIT)  Smart(x)
• x P is true in a model m iff P is true with x being some possible object
in the model

• Roughly speaking, equivalent to the disjunction of instantiations of P


At(KingJohn,KFUEIT)  Smart(KingJohn)
 At(Richard,KFUEIT)  Smart(Richard)
 At(KFUEIT,KFUEIT)  Smart(KFUEIT)
 ...
Lecture 22- First Order Logic 15
Another common mistake to
avoid
• Typically,  is the main connective with 

• Common mistake: using  as the main connective


with :
x At(x,KFUEIT)  Smart(x)

is true if there is anyone who is not at KFUEIT!

Lecture 22- First Order Logic 16


Examples
• Everyone likes McDonalds
• x, Likes(x, McDonalds)
• Someone likes Mcdonalds
• x, Likes(x, McDonalds)
• All Children like McDonalds
• x, child(x)  Likes (x, McDonalds)
• Everyone likes McDonalds unless they are
allergic to it
• x,  allergic(x, McDonalds)  Likes(x,
McDonalds)
Lecture 22- First Order Logic 17
Properties of quantifiers
• x y is the same as y x
• x y is the same as y x
• x y is not the same as y x
• x y Loves(x,y)
• “There is a person who loves everyone in the world”
• y x Loves(x,y)
• “Everyone in the world is loved by at least one person”
• Quantifier duality: each can be expressed using the other

Lecture 22- First Order Logic 18


Nesting Quantifiers
• Everyone likes some kind of food
• y x, Food(x)  Likes(y, x)
• There is a kind of food that everyone likes
• x y, Food(x)  Likes(y, x)
• Someone likes all kinds of food
• y x, Food(x)  Likes(y, x)
• Every food has someone who likes it
• x y , Food(x)  Likes(y, x)

Lecture 22- First Order Logic 19


Quantifier Duality Examples
• Quantifier duality: each can be expressed using the
other
• Not everyone likes McDonalds
•  (x, Likes(x, McDonalds))
• x, Likes(x, McDonalds)

• No one likes McDonalds


•  (x, Likes(x, McDonalds))
• x,  Likes(x, McDonalds)

Lecture 22- First Order Logic 20


Using FOL
The kinship domain:

• Brothers are siblings


x,y, Brother(x,y)  Sibling(x,y)

• “Sibling” is symmetric
x,y Sibling(x,y)  Sibling(y,x)

Lecture 22- First Order Logic 21


Fun with sentences
• One's mother is one's female parent
• m,c, Mother(m,c)  (Female(m)  Parent(m,c))
• A first cousin is a child of parent’s sibling
• x,y, FirstCousin(x,y)  p, ps, parent(p,x) 
sibling(p,ps)  parent(ps,y)

Lecture 22- First Order Logic 22


Equality
• term1 = term2 is true under a given interpretation if
and only if term1 and term2 refer to the same
object
• E.g., definition of Sibling in terms of Parent:
• x,y Sibling(x,y)  [(x = y) x,y m,f  (m = f) 
Parent(m,x)  Parent(f,x)  Parent(m,y)  Parent(f,y)]
• Generally we also allow mathematical expressions
when needed
• x,y, NatNum(x)  NatNum(y)  x = (y + 1)  x > y

Lecture 22- First Order Logic 23


Summary
• First-order logic:
• objects and relations are semantic primitives
• syntax: constants, functions, predicates, equality,
quantifiers

• Increased expressive power: sufficient to define


wumpus world

Lecture 22- First Order Logic 24

You might also like