First-Order Logic - Propositional Logic - Slides | CS 440, Study notes of Computer Science

Material Type: Notes; Professor: Draper; Class: Introduction to Artificial Intelligence; Subject: Computer Science; University: Colorado State University; Term: Fall 2008;

Typology: Study notes

Pre 2010

Uploaded on 03/18/2009

koofers-user-eub-2
koofers-user-eub-2 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Prepositional Logic
Prepositional Logic
(First
(First-
-order Logic)
order Logic)
Lecture #13
Lecture #13
10/07/08
10/07/08
Announcements
Announcements
Writing Assignment #2 is due now
Writing Assignment #2 is due now
Two printed copies, one anonymous
Two printed copies, one anonymous
Midterm is one week from today
Midterm is one week from today
Read Chapter 9
Read Chapter 9
This will be the last chapter on the midterm
This will be the last chapter on the midterm
Programming assignment #1
Programming assignment #1
Is being graded
Is being graded
Many of you were
Many of you were
loose
loose
in your output;
in your output;
some ignored the specification altogether.
some ignored the specification altogether.
Writing Assignment #2
Writing Assignment #2
What are the propositions?
What are the propositions?
What are the initial axioms?
What are the initial axioms?
What axioms are added with every guess?
What axioms are added with every guess?
How do we detect cheating?
How do we detect cheating?
Inconsistency implies lying
Inconsistency implies lying
Inconsistency detected through resolution
Inconsistency detected through resolution
These are the four elements that you should look for
in your critique. They should be clearly and correctly
identified, and not merely implicit
Propositional logic
Propositional logic
Propositional logic is declarative
Propositional logic is declarative
Propositional logic is compositional:
Propositional logic is compositional:
meaning of B
meaning of B1,1
1,1
P
P1,2
1,2 is derived from meaning of B
is derived from meaning of B1,1
1,1 and
and
of P
of P1,2
1,2
Meaning in propositional logic is context
Meaning in propositional logic is context-
-independent
independent
unlike natural language, where meaning depends on
unlike natural language, where meaning depends on
context
context
Propositional logic has limited expressive power
Propositional logic has limited expressive power
Unlike natural language
Unlike natural language
E.g., cannot say "pits cause breezes in adjacent squares
E.g., cannot say "pits cause breezes in adjacent squares
(except by writing one sentence for each square)
(except by writing one sentence for each square)
First Order Logic
First Order Logic
Examples of things we can say:
Examples of things we can say:
All men are mortal:
All men are mortal:
x Man(x)
x Man(x)
Mortal(x
Mortal(x)
)
Everybody loves somebody
Everybody loves somebody
x
x
y Loves(x, y)
y Loves(x, y)
The meaning of the word
The meaning of the word
above
above
x
x
y above(x,y)
y above(x,y)
(on(x,y)
(on(x,y)
z (on(x,z)
z (on(x,z)
above(z,y))
above(z,y))
First Order logic
First Order logic
Whereas propositional logic assumes the world
Whereas propositional logic assumes the world
contains facts,
contains facts,
first
first-
-order logic (like natural language) assumes
order logic (like natural language) assumes
the world contains
the world contains
Objects: people, houses, numbers, colors,
Objects: people, houses, numbers, colors,
Relations: red, round, prime, brother of, bigger than,
Relations: red, round, prime, brother of, bigger than,
part of,
part of,
Functions: father
Functions: father-
-of, plus,
of, plus,
pf3
pf4
pf5

Partial preview of the text

Download First-Order Logic - Propositional Logic - Slides | CS 440 and more Study notes Computer Science in PDF only on Docsity!

Prepositional Logic

Prepositional Logic

(First-(First-order Logic)order Logic)

Lecture #13Lecture

Announcements

Announcements

Writing Assignment #2 is due now Writing Assignment #2 is due now

  • – Two printed copies, one anonymousTwo printed copies, one anonymous

Midterm is one week from today

Midterm is one week from today

Read Chapter 9

Read Chapter 9

  • – This will be the last chapter on the midtermThis will be the last chapter on the midterm

Programming assignment #1 Programming assignment

  • Is being gradedIs being graded
  • – Many of you wereMany of you were ““looseloose”” in your output;in your output;

some ignored the specification altogether.some ignored the specification altogether.

Writing Assignment

Writing Assignment

What are the propositions?

What are the propositions?

What are the initial axioms?

What are the initial axioms?

What axioms are added with every guess?What axioms are added with every guess?

How do we detect cheating?How do we detect cheating?

  • – Inconsistency implies lyingInconsistency implies lying
  • – Inconsistency detected through resolutionInconsistency detected through resolution

These are the four elements that you should look for

in your critique. They should be clearly and correctly

identified, and not merely implicit

Propositional logic

Propositional logic

Propositional logic is declarative

Propositional logic is declarative

☺☺ Propositional logic is compositional:Propositional logic is compositional:

  • – meaning of Bmeaning of B

1,11,

∧∧ PP

1,21,

is derived from meaning of Bis derived from meaning of B

1,11,

andand

of Pof P

1,21,

☺☺ Meaning in propositional logic is contextMeaning in propositional logic is context--independentindependent

  • – unlike natural language, where meaning depends onunlike natural language, where meaning depends on

context

context

Propositional logic has limited expressive power

Propositional logic has limited expressive power

  • – Unlike natural languageUnlike natural language
  • – E.g., cannot say "pits cause breezes in adjacent squaresE.g., cannot say "pits cause breezes in adjacent squares““

(except by writing one sentence for each square)(except by writing one sentence for each square)

First Order LogicFirst Order Logic

Examples of things we can say:Examples of things we can say:

  • – All men are mortal:All men are mortal:

∀∀x Man(x)x Man(x) ⇒⇒ Mortal(xMortal(x))

  • – Everybody loves somebodyEverybody loves somebody

x

x

y Loves(x, y)

y Loves(x, y)

  • – The meaning of the wordThe meaning of the word ““aboveabove””

x

x

y above(x,y)

y above(x,y)

(on(x,y)

(on(x,y)

z (on(x,z)

z (on(x,z)

above(z,y))above(z,y))

First Order logicFirst Order logic

Whereas propositional logic assumes the world

Whereas propositional logic assumes the world

contains facts,contains facts,

first- first-order logic (like natural language) assumesorder logic (like natural language) assumes

the world contains

the world contains

  • Objects: people, houses, numbers, colors,Objects: people, houses, numbers, colors, ……
  • – Relations: red, round, prime, brother of, bigger than,Relations: red, round, prime, brother of, bigger than,

part of,part of, ……

  • – Functions: fatherFunctions: father--of, plus,of, plus, ……

Logics in General

Logics in General

Ontological Commitment: What exists in the world

Ontological Commitment: What exists in the world

—— TRUTHTRUTH

  • – PL : facts hold or do not hold.PL : facts hold or do not hold.
  • – FOL : objects with relations between them that hold or doFOL : objects with relations between them that hold or do

not holdnot hold

EpistemoligicalEpistemoligical Commitment: state of knowledgeCommitment: state of knowledge

allowed with respect to a factallowed with respect to a fact

Syntax of FOL

Syntax of FOL

User defines these primitives: User defines these primitives:

  • – Constant symbols (i.e., the "individuals" in the world)Constant symbols (i.e., the "individuals" in the world)

E.g., Mary, 3E.g., Mary, 3

  • – Function symbols (mapping individuals to individuals)Function symbols (mapping individuals to individuals)

E.g., fatherE.g., father--of(Mary) = John, colorof(Mary) = John, color--of(Sky) = Blueof(Sky) = Blue

  • – Predicate/relation symbols (mapping from individualsPredicate/relation symbols (mapping from individuals

to truth values) E.g., greater(5,3), green(Grass),to truth values) E.g., greater(5,3), green(Grass),

color(Grass, Green)color(Grass, Green)

Syntax (cont.)

Syntax (cont.)

FOL supplies these primitives:

FOL supplies these primitives:

  • – Variable symbols. E.g., x,yVariable symbols. E.g., x,y
  • Connectives. Same as in PL:Connectives. Same as in PL:
  • – Equality =Equality =
  • – Quantifiers: Universal (Quantifiers: Universal (∀∀) and Existential () and Existential (∃∃))

Atomic sentences

Atomic sentences

TermTerm == functionfunction (( termterm

11

,...,,..., termterm

nn

oror constantconstant oror variablevariable

Atomic sentence =Atomic sentence = predicatepredicate (( termterm

1

1

,...,,..., termterm

n

n

oror termterm

1

1

= term= term

2

2

Example terms:Example terms:

Brother(KingJohn,RichardTheLionheartBrother(KingJohn,RichardTheLionheart))

Greater(Length(LeftLegOf(RichardGreater(Length(LeftLegOf(Richard)),)),

Length(LeftLegOf(KingJohn

Length(LeftLegOf(KingJohn))))))

Complex sentencesComplex sentences

Complex sentences are made from atomicComplex sentences are made from atomic

sentences using connectivessentences using connectives

S

S

S

S

1

1

S

S

2

2

S

S

1

1

S

S

2

2

S

S

1

1

S

S

2

2

S

S

1

1

S

S

2

2

and by applying quantifiers.and by applying quantifiers.

Examples:Examples:

Sibling(KingJohn,RichardSibling(KingJohn,Richard)) ⇒⇒ Sibling(Richard,KingJohnSibling(Richard,KingJohn))

greater(1,2)greater(1,2) ∨∨ less-less-oror--equalequal(1,2)(1,2)

∀∀x,y Sibling(x,y)x,y Sibling(x,y) ⇒⇒ Sibling(y,x)Sibling(y,x)

Truth in firstTruth in first--order logicorder logic

Recall that a model is the set of all possible worlds under cons

Recall that a model is the set of all possible worlds under consideration.ideration.

Sentences are true with respect to a

Sentences are true with respect to a modelmodel and anand an interpretationinterpretation

Model contains objects (domain elements) and relations among them Model contains objects (domain elements) and relations among them

Interpretation specifies referents for Interpretation specifies referents for

constant symbolsconstant symbols →→ objectsobjects

predicate symbolspredicate symbols →→ relationsrelations

function symbolsfunction symbols →→ functional relationsfunctional relations

An atomic sentence An atomic sentence predicate(termpredicate(term

11

,...,,...,termterm

nn

)) is trueis true

iff theiffthe objectsobjects referred to byreferred to by termterm

11

,...,,...,termterm

nn

are in the relation are in therelation referred to byreferred to by predicatepredicate ..

Existential quantification (cont.)

Existential quantification (cont.)

Typically,Typically, ∧∧ is the main connective withis the main connective with ∃∃

Common mistake: using

Common mistake: using ⇒

with

with ∃

∃ ∃ xx At(x,At(x, CSUCSU )) ⇒⇒ Smart(x)Smart(x)

When is this true?When is this true?

Properties of quantifiers

Properties of quantifiers

∀∀xx ∀∀yy is the same asis the same as ∀∀yy ∀∀xx

∃∃xx ∃∃yy is the same asis the same as ∃∃yy ∃∃xx

∃∃xx ∀∀yy isis notnot the same asthe same as ∀∀yy ∃∃x:x:

∃∃xx ∀∀yy Loves(x,y)Loves(x,y)

  • – ““There is a person who loves everyone in the worldThere is a person who loves everyone in the world””

∀∀yy ∃∃x Loves(x,y)x Loves(x,y)

  • – ““Everyone in the world is loved by at least one personEveryone in the world is loved by at least one person””

Quantifier duality

Quantifier duality: each can be expressed using the other: each can be expressed using the other

∀ ∀xx Likes(x,IceCreamLikes(x,IceCream)) ¬∃¬∃xx ¬¬Likes(x,IceCream)Likes(x,IceCream)

∃ ∃x Likes(x,Broccoli)x Likes(x,Broccoli) ¬∀¬∀xx ¬¬Likes(x,Broccoli)Likes(x,Broccoli)

Equality

Equality

term

term

1

1

= term

= term

2

2

is true under a given interpretation

is true under a given interpretation

if and only ifif and only if termterm

11

andand termterm

22

refer to the samerefer to the same

objectobject

E.g., definition ofE.g., definition of SiblingSibling in terms ofin terms of ParentParent ::

x,y

x,y Sibling(x,y)Sibling(x,y)

[

[

(x = y)

(x = y)

m,f

m,f

(m = f)

(m = f)

Parent(m,x)Parent(m,x) ∧∧ Parent(f,x)Parent(f,x) ∧∧ Parent(m,y)Parent(m,y) ∧∧

Parent(f,y)]Parent(f,y)]

WumpusWumpus World (World (reduxredux))

An agent (e.g. in

An agent (e.g. in wumpuswumpus world) may keepworld) may keep

a knowledge base of objects, predicates &a knowledge base of objects, predicates &

inference rulesinference rules

  • Objects in this world are grid squares [Objects in this world are grid squares [w,hw,h]]
  • – Some predicates are sensationsSome predicates are sensations

E.g. Stench([w,h E.g.Stench([w,h]),]), Glitter([w,hGlitter([w,h]),]), Breeze([w.hBreeze([w.h])])

These are asserted over time, as the agent

These are asserted over time, as the agent

explores

explores

  • – Other predicates are facts about locationsOther predicates are facts about locations

E.g. Wumpus([w,h E.g.Wumpus([w,h]),]), Pit([w,hPit([w,h]),]), Gold([w,hGold([w,h])])

Warning: my presentation varies from

the book’s (which uses time, not location)

Interacting with FOL

Interacting with FOL KBsKBs

Suppose aSuppose a wumpuswumpus--world agent perceives a smell and aworld agent perceives a smell and a

breeze (but no glitter) in square [1,2]breeze (but no glitter) in square [1,2]

Tell(KB, Stench([1,2])Tell(KB, Stench([1,2])

Tell(KB

Tell(KB, Breeze([1,2])), Breeze([1,2]))

Tell(KB

Tell(KB,, ¬

Glitter([1,2]))

Glitter([1,2]))

This asserts a set of facts (axioms)

This asserts a set of facts (axioms)

Ask(KB, Safe([1,3]))Ask(KB, Safe([1,3]))

This asks the KB whether the statement Safe([1,3])This asks the KB whether the statement Safe([1,3])

is entailed by the known facts (axioms)

is entailed by the known facts (axioms)

DeductionsDeductions

These use a set of inference rules stored in These use a set of inference rules stored in

the KB

the KB

  • – ∀∀w,h Breeze([w,hw,hBreeze([w,h])]) ⇒⇒ Pit([w+1,h]) vPit([w+1,h]) v

Pit([w

Pit([w--1,h]) v Pit([w,h+1]) v Pit([w,h1,h]) v Pit([w,h+1]) v Pit([w,h--1])1])

  • – ∀∀w,h Safe([w,hw,hSafe([w,h])]) ⇔⇔ ((¬¬Pit([w,hPit([w,h]) ^]) ^

¬¬Wumpus([w,hWumpus([w,h]))]))

  • – ∃∃ w,h,w,h, Wumpus([w,hWumpus([w,h])])
  • – ∀∀w,h,x,y ((w=x) ^ ( h=y))w,h,x,y((w=x) ^ ( h=y))

v

v

(Wumpus([w,hWumpus([w,h]) ^]) ^ Wumpus([x,yWumpus([x,y]))]))

Creating a KB using FOL

Creating a KB using FOL

Identify the task (what will the KB be used for)

Identify the task (what will the KB be used for)

2.2. Assemble the relevant knowledge

Assemble the relevant knowledge

Knowledge acquisition.Knowledge acquisition.

3.3. Decide on a vocabulary of predicates, functions, and constantsDecide on a vocabulary of predicates, functions, and constants

Translate domainTranslate domain--level knowledge into logiclevel knowledge into logic--level names.level names.

4.4. Encode general knowledge about the domainEncode general knowledge about the domain

define axiomsdefine axioms

Encode a description of the specific problem instance

Encode a description of the specific problem instance

6.6. Pose queries to the inference procedure and get answers

Pose queries to the inference procedure and get answers

7.7. Debug the knowledge baseDebug the knowledge base

Examples

Examples

The

The kinship

kinship domain

domain

Basic predicates: Female, Parent.

Basic predicates: Female, Parent.

Other predicates in this domain:Other predicates in this domain:

One's mother is one's female parentOne's mother is one's female parent

∀∀m,cm,c Mother(c)Mother(c) = m= m ⇔⇔ (Female(m)(Female(m) ∧∧ Parent(m,c))Parent(m,c))

∀∀ x,yx,y Sibling(x,y)Sibling(x,y) ⇔⇔ [[¬¬(x = y)(x = y) ∧∧ ∃∃m,fm,f ¬¬(m = f)(m = f) ∧∧ Parent(m,x)Parent(m,x) ∧∧

Parent(f,x)

Parent(f,x) ∧

Parent(m,y)

Parent(m,y) ∧

Parent(f,y)]

Parent(f,y)]

A first cousin is a child of a parent

A first cousin is a child of a parent’’s siblings sibling

x,y

x,y FirstCousin(x,y

FirstCousin(x,y))

p,ps Parent(p,x)

p,ps Parent(p,x) ∧

Sibling(ps,p)

Sibling(ps,p) ∧

Parent(ps,y)Parent(ps,y)

These are the axioms of the domain (they are also definitions

These are the axioms of the domain (they are also definitions

since they usesince they use biconditionalsbiconditionals).).

Some sentences areSome sentences are ““theoremstheorems”” ---- they can be derived fromthey can be derived from

the axioms:the axioms:

  • – ““SiblingSibling”” is symmetricis symmetric

∀∀x,yx,y Sibling(x,y)Sibling(x,y) ⇔⇔ Sibling(y,x)Sibling(y,x)

Examples (cont)

Examples (cont)

TheThe setset domaindomain

Notation:Notation: {x|s} is the set resulting from adding x to the set s.{x|s} is the set resulting from adding x to the set s.

∀∀s Set(s)s Set(s) ⇔⇔ (s = {} )(s = {} ) ∨∨ ((∃∃xx ∃∃ss

2

2

Set(sSet(s

2

2

)) ∧∧ s = {x|ss = {x|s

2

2

x

x ∃

s {x|s} = {}

s {x|s} = {}

x

x ∀

s x

s x ∈

s

s ⇔

[

[

y,s

y,s

22

} (s = {y|s

} (s = {y|s

22

(x = y

(x = y ∨

x

x ∈

s

s

22

))]

))]

x

x ∀

s x

s x ∈

s

s ⇔

s = {x|s}

s = {x|s}

s

s

11

s

s

22

s

s

11

s

s

22

x x

x x ∈

s

s

11

x

x ∈

s

s

22

∀∀ss

11

∀∀ss

22

(s(s

11

= s= s

22

)) ⇔⇔ (s(s

11

⊆⊆ ss

22

∧∧ ss

22

⊆⊆ ss

11

∀∀xx ∀∀ss

11

,s,s

22

xx ∈∈ (s(s

11

∩∩ ss

22

)) ⇔⇔ (x(x ∈∈ ss

11

∧∧ xx ∈∈ ss

22

∀∀xx ∀∀ss

11

,s,s

22

xx ∈∈ (s(s

11

∪∪ ss

22

)) ⇔⇔ (x(x ∈∈ ss

11

∨∨ xx ∈∈ ss

22

Examples (cont)

Examples (cont)

TheThe natural numbersnatural numbers domaindomain

0 is a natural number: 0 is a natural number:

NatNum(0)NatNum(0)

The successor of a natural number is a natural number: The successor of a natural number is a natural number:

∀ ∀nn NatNum(nNatNum(n)) ⇒⇒ NatNum(S(nNatNum(S(n))))

Constraints on the successor function: Constraints on the successor function:

∀ ∀nn ¬¬(0 = S(n))(0 = S(n))

∀ ∀mm ∀∀nn ¬¬(m = n)(m = n) ⇒⇒ ¬¬(S(m) = S(n))(S(m) = S(n))

Defining addition:

Defining addition:

n

n NatNum(nNatNum(n)) ⇒

+(0, n) = n

+(0, n) = n

m

m ∀

n

n NatNum(mNatNum(m)) ∧

NatNum(n

NatNum(n)) ⇒

+(S(m), n) = S(+(m,n))

+(S(m), n) = S(+(m,n))