0% found this document useful (0 votes)
18 views36 pages

Lecture First Order Logic

The document introduces first-order logic, which extends propositional logic by allowing predicates and quantifiers over objects, relations, and functions. It covers the syntax and semantics of first-order logic, including atomic and complex sentences, truth in models under interpretations, and universal and existential quantification. Common mistakes involving quantifiers and connectives are also discussed.

Uploaded by

SK SALIM ALI
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)
18 views36 pages

Lecture First Order Logic

The document introduces first-order logic, which extends propositional logic by allowing predicates and quantifiers over objects, relations, and functions. It covers the syntax and semantics of first-order logic, including atomic and complex sentences, truth in models under interpretations, and universal and existential quantification. Common mistakes involving quantifiers and connectives are also discussed.

Uploaded by

SK SALIM ALI
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/ 36

First Order Logic

Philipp Koehn

10 March 2020

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Wittgenstein: Tractatus Logico-Philosophicus 1

1. The world is everything that is the case.

2. What is the case (a fact) is the existence of states of affairs.

3. A logical picture of facts is a thought.

4. A thought is a proposition with a sense.

5. A proposition is a truth-function of elementary propositions. (An elementary


proposition is a truth-function of itself.)

6. The general form of a proposition is the general form of a truth function, which
¯ N (ξ)].
is: [p̄, ξ, ¯ This is the general form of a proposition.

7. Whereof one cannot speak, thereof one must be silent.

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Outline 2

● Why first order logic?

● Syntax and semantics of first order logic

● Fun with sentences

● Wumpus world in first order logic

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


3

why?

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Pros and Cons of Propositional Logic 4

● PRO: Propositional logic is declarative: pieces of syntax correspond to facts

● PRO: Propositional logic allows partial/disjunctive/negated information


(unlike most data structures and databases)

● PRO: Propositional logic is compositional:


meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,2

● PRO: Meaning in propositional logic is context-independent


(unlike natural language, where meaning depends on context)

● CON: 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

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


First-Order Logic 5

● Propositional logic: world contains facts

● First-order logic: the world contains objects, relations, and functions

● Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball


games, wars, centuries . . .

● Relations: red, round, bogus, prime, multistoried . . .,


brother of, bigger than, inside, part of, has color, occurred after, owns, comes
between, . . .

● Functions: father of, best friend, third inning of, one more than, end of . . .

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


More Logics 6

Language Ontological Epistemological


Commitment Commitment
Propositional logic facts true/false/unknown
First-order logic facts, objects, relations true/false/unknown
Temporal logic facts, objects, relations, times true/false/unknown
Probability theory facts degree of belief
Fuzzy logic facts + degree of truth known interval value

Higher-order logic:
relations and functions operate not only on objects,
but also on relations and functions

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


7

syntax and semantics

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Syntax of FOL: Basic Elements 8

● Constants: KingJohn, 2, U CB, . . .


● Predicates: Brother, >, . . .
● Functions: Sqrt, Lef tLegOf, . . .
● Variables: x, y, a, b, . . .
● Connectives: ∧ ∨ ¬ Ô⇒ ⇔
● Equality: =
● Quantifiers: ∀∃

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Atomic Sentences 9

● Atomic sentence = predicate(term1, . . . , termn)


or term1 = term2

● Term = f unction(term1, . . . , termn)


or constant or variable

● E.g., Brother(KingJohn, RichardT heLionheart)


> (Length(Lef tLegOf (Richard)), Length(Lef tLegOf (KingJohn)))

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Complex Sentences 10

● Complex sentences are made from atomic sentences using connectives

¬S, S1 ∧ S2, S1 ∨ S2, S1 Ô⇒ S2, S1 ⇔ S2

● For instance
– Sibling(KingJohn, Richard) Ô⇒ Sibling(Richard, KingJohn)
– >(1, 2) ∨ ≤(1, 2)
– >(1, 2) ∧ ¬>(1, 2)

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Truth in First-Order Logic 11

● Sentences are true with respect to a model and an interpretation

● Model contains ≥ 1 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

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Models for FOL: Example 12

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Truth Example 13

● Object symbols
– Richard → Richard the Lionheart
– John → the evil King John

● Predicat symbol
– Brother → the brotherhood relation

● Atomic sentence
– Brother(Richard, John)
true iff Richard the Lionheart and the evil King John
are in the brotherhood relation in the model

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Models for FOL: Lots! 14

● Entailment in propositional logic can be computed by enumerating models

● We can enumerate the FOL models for a given KB vocabulary:

● For each number of domain elements n from 1 to ∞


For each k-ary predicate Pk in the vocabulary
For each possible k-ary relation on n objects
For each constant symbol C in the vocabulary
For each choice of referent for C from n objects . . .

● Computing entailment by enumerating FOL models is not easy!

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Universal Quantification 15

● Syntax: ∀ ⟨variables⟩ ⟨sentence⟩

● Everyone at JHU is smart:


∀ x At(x, JHU ) Ô⇒ 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, JHU ) Ô⇒ Smart(KingJohn))


∧ (At(Richard, JHU ) Ô⇒ Smart(Richard))
∧ (At(Jane, JHU ) Ô⇒ Smart(Jane))
∧ ...

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


A Common Mistake to Avoid 16

● Typically, Ô⇒ is the main connective with ∀

● Common mistake: using ∧ as the main connective with ∀:

∀ x At(x, JHU ) ∧ Smart(x)

means “Everyone is at JHU and everyone is smart”

● Correct
∀ x At(x, JHU ) Ô⇒ Smart(x)

means “For everyone, if she is at JHU, then she is smart”

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Existential Quantification 17

● Syntax: ∃ ⟨variables⟩ ⟨sentence⟩

● Someone at JHU is smart:


∃ x At(x, JHU ) ∧ 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, JHU ) ∧ Smart(KingJohn))


∨ (At(Richard, JHU ) ∧ Smart(Richard))
∨ (At(JHU, JHU ) ∧ Smart(JHU ))
∨ ...

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Another Common Mistake to Avoid 18

● Typically, ∧ is the main connective with ∃

● Common mistake: using Ô⇒ as the main connective with ∃:

∃ x At(x, JHU ) Ô⇒ Smart(x)

is true if there is anyone who is not at JHU

● Correct
∃ x At(x, JHU ) ∧ Smart(x)

is true if there is someone who is at JHU and smart

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Properties of Quantifiers 19

● ∀ 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

● ∀ x Likes(x, IceCream) ¬∃ x ¬Likes(x, IceCream)

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

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Equality 20

● term1 = term2 is true under a given interpretation


if and only if term1 and term2 refer to the same object

● For instance
– 1 = 2 and ∀ x ×(Sqrt(x), Sqrt(x)) = x are satisfiable
– 2 = 2 is true
(note: syntax does not imply anything about the semantics of 1, 2, Sqrt(x), etc.)

● Definition of (full) Sibling in terms of P arent


∀ x, y Sibling(x, y) ⇔ [¬(x = y) ∧ ∃ m, f ¬(m = f ) ∧
P arent(m, x) ∧ P arent(f, x) ∧ P arent(m, y) ∧ P arent(f, y)]

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


21

fun with sentences

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Fun with Sentences 22

● Brothers are siblings


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

● “Sibling” is symmetric
∀ x, y Sibling(x, y) ⇔ Sibling(y, x)

● One’s mother is one’s female parent


∀ x, y M other(x, y) ⇔ (F emale(x) ∧ P arent(x, y))

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


∀ x, y F irstCousin(x, y) ⇔ ∃ p, ps P arent(p, x) ∧ Sibling(ps, p) ∧ P arent(ps, y)

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Lincoln Quote 23

You can fool all the people some of the time,


and some of the people all the time,
but you cannot fool all the people all the time.

∀ p ∃ t F ool(p, t)

∃ p ∀ t F ool(p, t)

¬ ∀ p ∀ t F ool(p, t)

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Donkey Sentences 24

● Every farmer owns a donkey.


– ∀ f (F armer(f ) Ô⇒ ∃ d (Donkey(d) ∧ Own(f, d)))
– ∃ d (Donkey(d) ∧ ∀ f (F armer(f ) ∧ Own(f, d)))

● Every human lives on a planet.


– ∃ p (P lanet(p) ∧ ∀ h (Human(h) ∧ LivesOn(h, p)))

● Every farmer who owns a donkey beats it.


– ∀ f F armer(f ) ∧ ∃ d (Donkey(d) ∧ Own(f, d) Ô⇒ Beats(f, d))
but what if a farmer has a donkey d1 and a pig d2 and he beats neither
Donkey(d2) ∧ Own(f, d2) Ô⇒ Beats(f, d2) is true (f alse ∧ true Ô⇒ f alse)
– ∀ f ∀ d (F armer(f ) ∧ Donkey(d) ∧ Own(f, d) Ô⇒ Beats(f, d))
but this means “Every farmer beats every donkey he owns.“

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Natural Language 25

● First order logic is close to the semantics of natural language

● But there are limitations


– “There is at least one thing John has in common with Peter.”
Requires a quantifier over predicates.
– “The cake is very good.”
∃ c Cake(c) ∧ Good(c) but not V ery(c)
Functions and relations cannot be qualified.

● Natural language sentences are often intentionally vague and ambiguous

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


26

wampus world

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Knowledge Base for the Wumpus World 27

● “Perception”: at current square, three perceptions


– b either Breeze or ¬Breeze
– s either Smell or ¬Smell
– g either Glitter or ¬Glitter

● Shorthands
– ∀ b, g, t P ercept([Smell, b, g], t) Ô⇒ Smelt(t)
– ∀ s, b, t P ercept([s, b, Glitter], t) Ô⇒ AtGold(t)

● Reflex: ∀ t AtGold(t) Ô⇒ Action(Grab, t)

● Reflex with internal state: do we have the gold already?


∀ t AtGold(t) ∧ ¬Holding(Gold, t) Ô⇒ Action(Grab, t)

● Holding(Gold, t) cannot be observed


⇒ keeping track of change is essential

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Deducing Hidden Properties 28

● Properties of locations:
∀ x, t At(Agent, x, t) ∧ Smelt(t) Ô⇒ Smelly(x)
∀ x, t At(Agent, x, t) ∧ Breeze(t) Ô⇒ Breezy(x)

● Squares are breezy near a pit

● Diagnostic rule—infer cause from effect


∀ y Breezy(y) Ô⇒ ∃ x P it(x) ∧ Adjacent(x, y)

● Causal rule—infer effect from cause


∀ x, y P it(x) ∧ Adjacent(x, y) Ô⇒ Breezy(y)

● Neither of these is complete—e.g., the causal rule doesn’t say whether squares
far away from pits can be breezy

● Definition for the Breezy predicate:


∀ y Breezy(y) ⇔ [∃ x P it(x) ∧ Adjacent(x, y)]

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


States and Fluents 29

● By acting, the agent moves through a sequence of situations s

● Fluents: aspects of the world that may change


– current position
– having an arrow
– holding the gold

● Taking actions requires updates to the fluents

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Keeping Track of Change 30

● Facts hold in situations, rather than eternally


E.g., Holding(Gold, N ow) rather than just Holding(Gold)

● Situation calculus is one way to represent change in FOL:


Adds a situation argument to each non-eternal predicate
E.g., N ow in Holding(Gold, N ow) denotes a situation

● Situations are connected by the Result function


s′ = Result(a, s) is the situation that results from doing a in s

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Describing Actions 31

● “Effect” axiom—describe changes due to action


∀ s AtGold(s) Ô⇒ Holding(Gold, Result(Grab, s))

● “Frame” axiom—describe non-changes due to action


∀ s HaveArrow(s) Ô⇒ HaveArrow(Result(Grab, s))

● Frame problem: find an elegant way to handle non-change


(a) representation: too many frame axioms
(b) inference: too many repeated “copy-overs” to keep track of state

● Qualification problem: true descriptions of real actions require endless caveats—


what if gold is slippery or nailed down or . . .

● Ramification problem: real actions have many secondary consequences—what


about the dust on the gold, wear and tear on gloves, . . .

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Describing Actions 32

● Successor-state axioms solve the representational frame problem

● Each axiom is “about” a predicate (not an action per se):

P true afterwards ⇔ [an action made P true


∨ P true already and no action made P false]

● For holding the gold:


∀ a, s Holding(Gold, Result(a, s)) ⇔
[(a = Grab ∧ AtGold(s))
∨ (Holding(Gold, s) ∧ a ≠ Release)]

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Making Plans 33

● Initial condition in KB:


At(Agent, [1, 1], S0)
At(Gold, [1, 2], S0)

● Query: Ask(KB, ∃ s Holding(Gold, s))


i.e., in what situation will I be holding the gold?

● Answer: {s/Result(Grab, Result(F orward, S0))}


i.e., go forward and then grab the gold

● This assumes that the agent is interested in plans starting at S0 and that S0 is the
only situation described in the KB

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Making Plans: A Better Way 34

● Represent plans as action sequences [a1, a2, . . . , an]

● P lanResult(p, s) is the result of executing p in s

● Then the query Ask(KB, ∃ p Holding(Gold, P lanResult(p, S0)))


has the solution {p/[F orward, Grab]}

● Definition of P lanResult in terms of Result:


∀ s P lanResult([ ], s) = s
∀ a, p, s P lanResult([a∣p], s) = P lanResult(p, Result(a, s))

● Planning systems are special-purpose reasoners designed to do this type of


inference more efficiently than a general-purpose reasoner

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020


Summary 35

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

● Increased expressive power: sufficient to define wumpus world

● Situation calculus
– conventions for describing actions and change in FOL
– can formulate planning as inference on a situation calculus KB

Philipp Koehn Artificial Intelligence: First Order Logic 10 March 2020

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