0% found this document useful (0 votes)
11 views27 pages

AI-Lec05-add-slides

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)
11 views27 pages

AI-Lec05-add-slides

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/ 27

RMIT Classification: Trusted


Artificial Intelligence

Week 5: First-order Logic (FOL)

COSC2129
RMIT Classification: Trusted

Material

• Chapter 7, Book: Artificial Intelligence: A Modern


Approach Global edition

• Book - TOC of Artificial Intelligence: A Modern Approach,


4th Global ed.
• AIMA: Pseudo code
• Good practices Python
RMIT Classification: Trusted

Propositional logic: Limitation

• Example 1: Represent in PL
– The table has three legs ➢ Properties of ONE
– The table is made of wood and glass object
– The table is expensive

• Example 2
– Table 1 is broken ➢ The same
– Table 2 is broken property of
difference objects
• Example 3
– Table 2 is next to Table 1 • ?
– Table 2 is smaller than Table 1
– The bag is on Table 2
RMIT Classification: Trusted

First-order logic

• First-order logic (FOL):


– built on the foundation of PL
– more expressive than PL
– useful representational ideas (objects, relations,
functions) from nature language.
• Objects: Table, wumpus, people, houses, numbers, colors,…
• Relations/properties: next, red, round, prime, brother of,
smaller than, bigger than, part of, between, …
• Functions: father of, best friend, one more than, plus,…
RMIT Classification: Trusted

First-order logic

• First-order logic (FOL) models the world in terms of


– Objects, which are things with individual identities
– Properties of objects that distinguish them from other objects
– Relations that hold among sets of objects
– Functions, which are a subset of relations where there is only
one “value” for any given “input”

• Examples:
– Objects: Students, lectures, companies, cars ...
– Relations: Brother-of, bigger-than, outside, part-of, has-color,
occurs-after, owns, visits, precedes, ...
– Properties: blue, wood, oval, even, large, ...
– Functions: father-of, best-friend, second-half, one-more-than
...
RMIT Classification: Trusted

FOL: Syntax

Basic syntactic elements of FOL:


• Constant symbols, which represent individuals in the world
– Daisy (name)
– 3 (legs)
– Wood
• Predicate symbols, which map individuals to truth values
– greater(3>2)
– blue(Sky)
– color(Grass, Green)
• Function symbols, which map individuals to individuals
– Sqrt(4)
– father-of(Daisy) = John
– color-of(Sky) = Blue
– legOfTable
RMIT Classification: Trusted

FOL: Syntax

• Variable symbols
– E.g., x, y,…
• Connectives
– Same as in PL: not (), and (), or (), implies
(→), if and only if (biconditional )
• Quantifiers
– Universal x or (Ax)
– Existential x or (Ex)
• Equality: =
RMIT Classification: Trusted

FOL: Sentences

Sentences are built from terms and atoms.


• A term (a real-world individual) is a constant symbol, a
variable symbol, or an n-place function of n terms.
− x and f(x1, ..., xn) are terms, where each xi is a term.
− A term with no variables is a ground term
• An atomic sentence (which has value true or false) is an n-
place predicate of n terms
₋ broken(Table1, Table2) (term: objects, fact)
₋ mother(Jody, Tim) (predicate: relation, fact)
• A complex sentence is formed from atomic sentences
connected by the logical connectives:
P, PQ, PQR, P→Q, PQ where P, Q, R are sentences
RMIT Classification: Trusted

FOL: Sentences (con’t)

• A quantified sentence adds quantifiers  and 


• A well-formed formula (wff) is a sentence containing
no “free” variables. That is, all variables are “bound” by
universal or existential quantifiers.
(x)P(x,y) has x bound as a universally quantified
variable, but y is free.

Examples:
Somebody likes Jane: ∃x : (likes (x, Jane)).
Somebody likes everybody: ∃x :(∀y : (likes (x, y)))
∀x : (even (x) ∧ prime (x) ⇒ (x = 2)) (a mathematical fact)
RMIT Classification: Trusted

Quantifiers

• Universal quantification
– (x)P(x) means that P holds for all values of x in
the domain associated with that variable
– E.g., (x) dolphin(x) → mammal(x)

• Existential quantification
– ( x)P(x) means that P holds for some value of x
in the domain associated with that variable
– E.g., ( x) study(x,AI)  smart(x)
RMIT Classification: Trusted

Quantifiers

• Universal quantifiers: often used with “implies” to form “rules”:


(x) student(x) → smart(x) means “All students are smart”
(x)student(x)smart(x) means “Everyone in the world is a student and
is smart”
• Existential quantifiers: usually used with “and” to specify a list of
properties about an individual:
(x) student(x)  smart(x) means “There is a student who is smart”

• A common mistake is to represent this English sentence as the


FOL sentence:
(x) student(x) → smart(x)
– But what happens when there is a person who is not a student?
RMIT Classification: Trusted

Multiple quantifiers (Scope)

• Switching the order of universal quantifiers does not


change the meaning:
– (x)(y)P(x,y) (y)(x) P(x,y)
• Similarly, you can switch the order of existential
quantifiers:
– (x)(y)P(x,y) (y)(x) P(x,y)
• Switching the order of universals and existentials
does change meaning:
– Everyone likes someone: (x)(y) likes(x,y)
– Someone is liked by everyone: (y)(x) likes(x,y)
RMIT Classification: Trusted

Connections between All and Exists

We can relate sentences involving  and 


using De Morgan’s laws:
(x) P(x) (x) P(x)
(x) P (x) P(x)
(x) P(x)  (x) P(x)
(x) P(x) (x) P(x)
RMIT Classification: Trusted

Semantics of FOL

• Domain M: the set of all objects in the world (of interest)


• Interpretation: includes
– Assign each constant to an object in M
– Define functions (a mapping Mn => M)
– Define predicates (a mapping Mn => {T, F})
• Every ground predicate with any instantiation will have a truth value
– In general there is an infinite number of interpretations
because |M| is infinite
• Define logical connectives: ~, ^, , =>, <=> as in PL
• Define semantics of (x) and (x)
– (x) P(x) is true iff P(x) is true under all interpretations
– (x) P(x) is true iff P(x) is true under some interpretation
RMIT Classification: Trusted

Semantics of FOL

• Model: an interpretation of a set of sentences such that


every sentence is True
• A sentence is
– satisfiable if it is true under some interpretation
– valid if it is true under all possible interpretations
– inconsistent if there does not exist any interpretation under
which the sentence is true
• Logical consequence:
S |= X if all models of S are also models of X
RMIT Classification: Trusted

Inference in FOL
RMIT Classification: Trusted

Quantified inference rules

• Universal instantiation
– x P(x)  P(A)
• Universal generalization
– P(A)  P(B) …  x P(x)
• Existential instantiation
– x P(x) P(F)  skolem constant F
• Existential generalization
– P(A)  x P(x)
RMIT Classification: Trusted

Universal instantiation (universal elimination)

• If (x) P(x) is true, then P(C) is true, where C is any


constant in the domain of x
• Example:
(x) learn(Man, x)  learn(Man, painting)
• The variable symbol can be replaced by any ground
term (any constant symbol or function symbol
applied to ground terms only).
RMIT Classification: Trusted

Existential instantiation (existential elimination)

• From (x) P(x) infer P(c)


• Example:
(x) learn(Man, x) → learn(Man, Subject)
• Note that the variable is replaced by a brand-new
constant not occurring in this or any other sentence in
the KB
• Also known as skolemization; constant is a skolem
constant
• Convenient to use this to reason about the unknown
object, rather than constantly manipulating the
existential quantifier.
RMIT Classification: Trusted

Existential generalization (existential introduction)

• If P(c) is true, then (x) P(x) is inferred.


• Example
learn(Man, Painting)  (x) learn(Man, x)
• All instances of the given constant symbol are
replaced by the new variable symbol
• Note that the variable symbol cannot already exist
anywhere in the expression.
RMIT Classification: Trusted

Propositionalization (FOL → PL)

• Inference in FOL is an extension of inference in PL.


• We can reduce FOL inference to PL inference via
propositionalization.
(Need to deal with substitutions and quantifiers)
• The basic idea
– A variable of sentences with existential quantifier can
be substituted by one instantiation.
– A variable of sentences with universal quantifier can
be substituted by the set of all possible instantiations
RMIT Classification: Trusted

Generalized Modus Ponens (GMP)

• All variables assumed universally quantified


RMIT Classification: Trusted

GMP example

Cre.: Philipp Koehn, AI: Inference in FOL, 2024


RMIT Classification: Trusted

Unification

• The process of finding substitutions


• A unification algorithm takes two sentences and returns a
unifier (substitution) for them if one exists.
RMIT Classification: Trusted

Example of Inference in F

• Prove that Colonel West is a criminal. See slides.


RMIT Classification: Trusted

Most general unifier (MGU)

• Unification should only return the most general one,


which makes the least commitment to constants.
• The algorithm for computing MGUs can be found in the
textbook.
RMIT Classification: Trusted

Question?

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