0% found this document useful (0 votes)
29 views42 pages

AI07

The document discusses first-order logic and how it overcomes limitations of propositional logic by introducing objects, properties, and relations to represent concepts involving groups of objects. It covers new concepts in first-order logic like relations, functions, models, syntax including terms, quantifiers, and equality. Examples of modeling different domains in first-order logic like kinship relationships, numbers, sets, and lists are provided.

Uploaded by

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

AI07

The document discusses first-order logic and how it overcomes limitations of propositional logic by introducing objects, properties, and relations to represent concepts involving groups of objects. It covers new concepts in first-order logic like relations, functions, models, syntax including terms, quantifiers, and equality. Examples of modeling different domains in first-order logic like kinship relationships, numbers, sets, and lists are provided.

Uploaded by

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

Chapter 7 First-order logic

Propositional logic
 not expressive enough
 needs a huge amount of rules
 for even for the simple 4x4 wumpus world
 previous examples on chapter 7

 no power on handling groups of objects


 every object is specified indvidually

First-order logic (FOL)


 introduces the concepts to overcome that
 objects and properties
Why we need logic?
Natural language?
 the expressive power – high but ambiguous
 can it be used as a representation language
 in AI?
 serves as a medium of communication
 rather than pure representation
 since 1 syntax  too many (hidden) semantics

For logic?
 it’s like a function: one-to-one mapping.
New concepts
Relations
 are the links among objects
 can be functions – only one output for a given input
Examples:
 Objects: people, houses, number, colors, baseball,
centuries
 Relations: either unary (property) or n-ary
 unary: tall, large, small, red, round, prime, boring
 n-ary: brother of, greater than, part of, inside, after, is
 Functions: father of, best friend, one more than
Almost any fact (assertion) can be thought
of a combination of
 objects
 and properties or relations

“One plus two equals three”


 Objects: one, two, three, one plus two
 Relation: equals

 Function: plus
A name of the object
obtained by applying the
function plus to the
objects one and two
“Squares neighboring the wumpus are
smelly.”
 Objects: Squares, wumpus
 Property: smelly Not a function because
many squares may satisfy
 Relation: neighboring
the constraints, but there
is only one three

FOL is important
 almost any of our concept/knowledge
 can be expressed as FOL
Pros & Cons of FOL
Drawback
 first-order logic doesn't have the things
 Categories / Classification
 Time (Temporal Logic)

 Events

Advantage
 it can express
 anything that can be programmed
  Prolog
Difference of FOL and PL
PL
 consider the facts: True or False
 use compositionality to see
 whether the sentence is true or false
FOL
 consider the RELATIONS with OBJECTS:
 True or False
 also use compositionality
Models for FOL
What is a model?
 in PL: A  B => C
 then how many possible combinations?
 this set of truth values = a model for this world
 only True or False exists
in FOL, a model contains more.
 objects
 domain of an FOL model
 = set of objects (domain elements) it contains
There are five objects in this model
 two binary relations
 three unary relations

 one unary function: left-leg


Formally speaking, relation is
 a set of tuples of objects that are related
 e.g., for relation brother, it is the set
 { < Richard, King John>, <King John, Richard>}
Strictly speaking,
 the functions used in FOL must be total functions
 i.e., a function returns a value for every input tuple
 constituted by the domain elements
 e.g., brother:X  Y, any body must have a brother?
 left_leg:X  Y, anything must have a left leg?
 left_leg(Leftleg1) = Leftleg2?
Syntax of FOL
Terms
 a logical expression of objects
 Terms =
 constant symbols (1, a, b, peter)
 variables (X, Y, Human)

 and function symbols (fatherof(peter), plus(1,2))

Atomic sentences
 the facts in Prolog
 = Predicate symbol + Terms
 = Relation + Objects

 e.g., brother(Richard, John).


 married(Father(Richard), Mother(John))
Complex sentences
 multiple atomic sentences combined with
logical connectives
 Example:
 Brother(Richard, John)  Brother(John,
Richard)
 Older(John, 30)  Younger(John, 30)
Quantifiers
Quantifiers
 For expressing properties of
 entire collection of objects – projection of a subset
Universal quantification ()
 Meaning all, •called a variable,
•lowercase
 reading as “For all” •if it’s a constant,
•ground term
 Example: “All Kings are Persons”
x King(x)  Person(x)
If X is a King, then X is a Person
Here x King(x)  Person(x) is true
 if x = any domain element,
 and the sentence is still true.
 x  Richard
 x  King John

 x  Richard’s left leg

 x  John’s left leg

 x  the crown

 the above list is called the extended


interpretation
 By applying this list, what we have?
Are they true in the model?
Yes!!!! (but only for interpretation)
 from the table of implication ( =>)
 whenever the premise is false
 the result is true, regardless of the conclusion
So, Universal quantifier
 asserts a list of sentences (reduce our work!)
Existential quantification ()
 Meaning some
 reading as “There exist” or “For some”
 Example
 x Crown(x)  OnHead(x, John)
Here, we can see
 => is the natural connective with 
 while  with 

if  with , too strong, if => with , too


weak
Nested Quantifiers
When using multiple quantifiers, e.g.,
 x y Brother(x, y) => Sibling (x, y)
 we can write x, y instead of separate ones

x y Loves (x, y)
 meaning?
 Everybody x loves somebody y

 then y x Loves (x, y)?

 any difference?
Somebody y, whom is loved by
everybody x.
Problem?
 Quantifiers are not commutative
 The order cannot be interchanged

 Similar to a query

If we want to specify the precedence,


 we should use ( )
 e.g., y ( x Loves (x, y) )
Connections between  and 
 is a conjunction over the universe
While  is a disjunction
 De Morgan rules can apply to them:
 x P  x P
 x P  x P
 x P  x  P
 x P  x P

So, only one of the  or  is necessary


 we don’t need both
Equality
Equality is represented as
 “=”
 instead of a predicate

 Example: FatherOf(John) = Henry

To ensure two objects are not the same


 negation with equality is used
 E.g., x,y Sister(Felix, x)  Sister(Felix, y) 
(x = y)
without that, what is the
meaning?
The uniqueness quantifier !
 just specifies
 One or more different objects
! is used to specify
 a unique one object
Example: “There is only one king”
 !x King(x)
 Or x King(x)  y King(y)  (x = y)
 If X is a King & Y is a King then X must be Y
Using first-order logic
domain
 a section of the world
 about which we wish to express some knowledge

 database, networking, architecture, etc.

The followings are the examples


 The kinship domain
 The domain of numbers, sets and lists
The kinship domain
Also called family relationships domain
 The objects in the domain are people
 The properties of the objects include
 Gender
 Age

 Height, …

 The relations are:


 parenthood, brotherhood, marriage, …
Some Examples
 m,c Mother(c)=m  Female(m)  Parent(m,c)
 w,h Husband(h,w)  Male(h)  Spouse(h,w)
 Disjoint categories:
 x Male(x)  Female(x)
 Inverse relations:
 p,c Parent(p,c)  Child(c,p)
 g,c Grandparent(g,c)  p Parent(g,p) 
Parent(p,c)
 x,y Sibling(x,y)  x≠y  p Parent(p,x) 
Parent(p,y)
we can have many more axioms like these.
 this will be one of your exercises in PJ.3
Must the Male, Female, Parent be
 the set of primitive predicates?
 Of course, not.

 We may use other predicates as the


primitive set
And also, in some domains
 we have no clearly identifiable basic set
The domain of numbers
Here is the theory of natural numbers
 to check if a number is natural
 NatNum
 a constant symbol (basis)
 0
a function symbol S, meaning successor
NatNum(0).
n NatNum(n) => NatNum(S(n)).
After that, we define constraints about
the function S
n 0 ≠ S(n)
m, n m ≠ n => S(m) ≠ S(n)
addition of natural numbers
m NatNum(m) => ( + (m, 0) = m )
m, n NatNum(m)  NatNum(n) => +
(S(m) , n) = S(+(m,n))
The domain of sets
We want to represent individual sets,
including empty set.
What we need?
 a way to building up a set
 by adding an element to a set (adjoining)
 take union of two sets

 take intersection of two sets

 Checking?
 membership of an element
 whether it is a set or other objects
Hence we want to define the followings
Constant symbol:
 {}
Predicates:
 Set, Member, Subset
Functions:
 Adjoining, Union, Intersection
The domain of lists
Lists are similar to sets
 difference?
 Lists are ordered
 An element can appear more than once

 Here is the summary of their difference


Ø ={ } [] = Nil
{x} = {x | { } } [x] = Cons(x, Nil)
{x, y} = {x | {y | { } } } [x,y] = Cons(x, Cons(y,
Nil))
{x, y|s} = {x | { y | s} }, s is a set [x,y|l] = Cons(x, Cons(y, l))
r  s = Union(r, s)
r  s = Intersection(r, s)
x  s = Member(x, s)
r  s = Subset(r, s)
The wumpus world
Recall the wumpus agent receives
 a percept vector [S, B, G, BUMP, S]
As the percept is time critical,
 we add an integer as the time step
 percept([S, B, G, None, None], 5)

 S, B, G, etc. are constant symbols

The actions in wumpus world


 Turn(Right), Turn(Left), Forward, …
 we want to pick up a best action for any time
To choose a best action, we may ask
 a BestAction(a, 5), for example
 the result may be a = Grab (a Glitter!!)

 But is it some straightforward?

 we have to first tell KB what happens!!


  s,b,u,c,t Percept([s, Breeze, g, m, c], t)  Breeze(t)
  s,b,u,c,t Percept([s, b, Glitter, m, c], t)  Glitter(t)

 and so on.

 but it’s not enough


 since we need to define additional rules

 t Glitter(t) => BestAction(Grab, t)

 and so on.
Defining environments
Objects in the environment
 squares
 pits

 the wumpus x, y, a, b Adjacent([ x, y ], [a, b]) 


[a, b]  {[ x  1, y ], [ x  1, y ], [ x, y  1], [ x, y  1]}
For any square,
 named as Square1,2 and so on.
 for adjacent squares, we have to define them
 pair by pair!!
 hence using a rule is much better
For the pits,
 we don’t need name them individually
 we just need to use a unary predicate
 Pit(S), to indicate a square has a pit or not
For the wumpus,
 there exists only one
 it lives only in exactly one square

 so, we may use Home(Wumpus) to name


the square
 where Wumpus is a constant and Home a
function
As the agent moves
 it changes over time
 we use At(Agent, s, t) to specify
 at a time step, Agent is at s
For the properties of the environment
 it is constant over time.
 e.g., a square is breezy (has a breeze)

s, t At(Agent, s, t)  Breeze(t) =>


Breezy(s)
The same for smelly (has a stench).
Diagnostic rules
For a given percept, what does it mean?
 what results can be concluded?
 e.g., if a square is breezy, then what?
implies “some adjacent square has a pit!”
s Breezy(s) => r Adjacent(r, s)  Pit(r)
 For the reverse direction, is it true?
yes, so we have
s Breezy(s) <=> r Adjacent(r, s)  Pit(r)
Causal rules
For a given result, what facts can be
deduced?
 if r is a pit, then?
 all adjacent squares of r are breezy

r Pit(r) => [s Adjacent(r, s)  Breezy(s)]


 if all squares adjacent to a square s are not
pits, then s is not breezy
s [r Adjacent(r, s) => Pit(r)] => Breezy(s)
Basically, these rules are equivalent to previous
bidirectional rule
Conclusion
the facts or world description
Whichever kind representation
if the axioms correctly and completely
 describe the way the world works
 and the way the percepts are produced

then any complete logical inference


procedure successor function
 will infer the strongest possible description
of the world state
 given the available percepts

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy