Lecture 10 First-Order Logic 4 th February 2020 Outline 2 / 24 - - PowerPoint PPT Presentation

lecture 10 first order logic
SMART_READER_LITE
LIVE PREVIEW

Lecture 10 First-Order Logic 4 th February 2020 Outline 2 / 24 - - PowerPoint PPT Presentation

Claudia Chirita School of Informatics, University of Edinburgh Based on slides by: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle Informatics 2D Agents and Reasoning 2019/2020 Lecture 10 First-Order Logic 4 th


slide-1
SLIDE 1

Informatics 2D ⋅ Agents and Reasoning ⋅ 2019/2020

Lecture 10 ⋅ First-Order Logic

Claudia Chirita

School of Informatics, University of Edinburgh

4th February 2020

Based on slides by: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle

slide-2
SLIDE 2

Outline

  • Why FOL?
  • Syntax and semantics of FOL
  • Using FOL
  • Wumpus world in FOL

2 / 24

slide-3
SLIDE 3

Propositional logic as a language

Compared to languages in Computer Science

  • serves as a basis for declarative languages
  • allows partial/disjunctive/negated information

⋅ unlike most data structures and databases

  • is compositional

⋅ e.g. the meaning of 𝐶, ∧ 𝑄

, is derived from that of

𝐶, and of 𝑄

,

⋅ unlike some instances of concurrent programming

Compared to natural languages

  • meaning is context-independent

⋅ unlike natural languages, where meaning depends on

context

  • propositional logic has very limited expressive power

⋅ e.g. we can say pits cause breezes in adjacent squares

  • nly by writing one sentence for each square

3 / 24

slide-4
SLIDE 4

First-order logic

Propositional logic deals with atomic facts (i.e. atomic, non-structured propositional symbols; usually fjnitely many). FOL brings structure to facts, which can be built from: Objects: people, houses, numbers, colours, football games Functions: father of, best friend, one more than, plus Relations: red, round, prime, brother of, bigger than, part of

4 / 24

slide-5
SLIDE 5

Example ⋅ Of brothers and kings

5 / 24

slide-6
SLIDE 6

Example ⋅ Of brothers and kings

Brother(KingJohn, RichardTheLionheart) Length(LeftLegOf(Richard)) > Length(LeftLegOf(John))

6 / 24

slide-7
SLIDE 7

Syntax ⋅ Signatures

A fjrst-order signature is a pair (𝐺, 𝑄)

𝐺 – indexed family (𝐺)∈ℕ of sets of function symbols

(operations)

𝑄 – indexed family (𝑄)∈ℕ of sets of relation symbols

(predicates) For 𝜏 ∈ 𝐺 and 𝜌 ∈ 𝑄, 𝑜 is called arity. Constant symbols are function symbols with arity zero. Example functions

𝐺 = {Richard, John}, 𝐺 = {LeftLegOf}

predicates

𝑄 = {Crown, King, Person} 𝑄 = {Brother, OnHead}

7 / 24

slide-8
SLIDE 8

Syntax ⋅ Sentences

Terms Least set 𝑈 such that 𝜏(𝑢, … , 𝑢) ∈ 𝑈 for every 𝜏 ∈ 𝐺 and 𝑢, … , 𝑢 ∈ 𝑈. In particular, 𝑈 contains all constants. Variables Every set of (𝐺, 𝑄)-variables 𝑌 determines an extended signature (𝐺 ∪ 𝑌, 𝑄) with the variables in 𝑌 added to 𝐺 as new constants. Sentences over a signature (𝐺, 𝑄) are defjned by the grammar

𝜒 ∶∶= 𝜌(𝑢, … , 𝑢) ∣ 𝑢 = 𝑢

atoms

∣ ¬𝜒 ∣ 𝜒 ∧ 𝜒 ∣ 𝜒 ∨ 𝜒 ∣ 𝜒 → 𝜒 ∣ 𝜒 ↔ 𝜒

boolean connectives

∣ ∀𝑌.𝜒 ∣ ∃𝑌.𝜒

quantifjers

where 𝜌 ∈ 𝑄 is a predicate symbol, 𝑢, 𝑢, 𝑢, … , 𝑢 are terms, and 𝑌 is a set of variables. Precedence: ∀𝑌, ∃𝑌, ¬, ∧, ∨, →, ↔

8 / 24

slide-9
SLIDE 9

Syntax ⋅ Sentences

Sentences over a signature (𝐺, 𝑄) are defjned by the grammar

𝜒 ∶∶= 𝜌(𝑢, … , 𝑢) ∣ 𝑢 = 𝑢

atoms

∣ ¬𝜒 ∣ 𝜒 ∧ 𝜒 ∣ 𝜒 ∨ 𝜒 ∣ 𝜒 → 𝜒 ∣ 𝜒 ↔ 𝜒

boolean connectives

∣ ∀𝑌.𝜒 ∣ ∃𝑌.𝜒

quantifjers

where 𝜌 ∈ 𝑄 is a predicate symbol, 𝑢, 𝑢, 𝑢, … , 𝑢 are terms, and 𝑌 is a set of variables. Precedence: ∀𝑌, ∃𝑌, ¬, ∧, ∨, →, ↔ Example

Brother(John, Richard) Brother(John, Richard) ∧ Brother(Richard, John) ¬Brother(LeftLegOf(Richard), John) ¬King(Richard) → King(John) ∀𝑦.King(𝑦) → Person(𝑦)

9 / 24

slide-10
SLIDE 10

Semantics ⋅ Models

Given a signature (𝐺, 𝑄), a model 𝑁 consists of

  • a non-empty set |𝑁|, called the carrier set (domain)
  • f 𝑁, whose elements are called objects
  • a function 𝑁 ∶ |𝑁| → |𝑁| for each operation symbol

𝜏 ∈ 𝐺

  • a subset 𝑁 ⊆ |𝑁| for each relation symbol 𝜌 ∈ 𝑄

Examples

10 / 24

slide-11
SLIDE 11

Satisfaction relation

The satisfaction relation links the syntax and the semantics.

  • We write 𝑁 ⊧ 𝜒 and read “𝑁 satisfjes 𝜒”, for 𝑁 a model

and 𝜒 a sentence, both for the same signature (𝐺, 𝑄).

  • To make (𝐺, 𝑄) explicit, we sometimes write 𝑁 ⊧(,) 𝜒.
  • The satisfaction relation is defjned according to the

structure of sentences (in the following slides), based on the evaluation of terms in models. Evaluation of terms

  • 𝑁 denotes the interpretation of a term 𝑢 in a model 𝑁.
  • 𝑁(,…,) = 𝑁(𝑁, … , 𝑁)

e.g. 𝑁LeftLegOf(John) = 𝑁LeftLegOf(𝑁John)

= 𝑁LeftLegOf( ) =

11 / 24

slide-12
SLIDE 12

Satisfaction relation ⋅ 𝑁 ⊧ 𝜒

Atoms

  • 𝑁 ⊧ 𝑢 = 𝑢

ifg

𝑁 = 𝑁

  • 𝑁 ⊧ 𝜌(𝑢, … , 𝑢)

ifg

(𝑁, … , 𝑁) ∈ 𝑁

Boolean connectives

  • 𝑁 ⊧ ¬𝜒

ifg

𝑁 ⊭ 𝜒

  • 𝑁 ⊧ 𝜒 ∧ 𝜒

ifg

𝑁 ⊧ 𝜒 and 𝑁 ⊧ 𝜒

  • 𝑁 ⊧ 𝜒 ∨ 𝜒

ifg

𝑁 ⊧ 𝜒 or 𝑁 ⊧ 𝜒

  • 𝑁 ⊧ 𝜒 → 𝜒

ifg

𝑁 ⊧ 𝜒 whenever 𝑁 ⊧ 𝜒

  • 𝑁 ⊧ 𝜒 ↔ 𝜒

ifg

𝑁 ⊧ 𝜒 → 𝜒 and 𝑁 ⊧ 𝜒 → 𝜒

12 / 24

slide-13
SLIDE 13

Satisfaction relation ⋅ 𝑁 ⊧ 𝜒

Quantifjers A model 𝑁 for (𝐺 ∪ 𝑌, 𝑄) is called an expansion of a model

𝑁 for (𝐺, 𝑄) if it interprets all symbols in 𝐺 and in 𝑄 the same

as 𝑁. Expansions formalize assignments of elements from 𝑁 to the variables in 𝑌. Example 𝑁 𝑁′

13 / 24

slide-14
SLIDE 14

Satisfaction relation ⋅ 𝑁 ⊧ 𝜒

Quantifjers A model 𝑁 for (𝐺 ∪ 𝑌, 𝑄) is called an expansion of a model

𝑁 for (𝐺, 𝑄) if it interprets all symbols in 𝐺 and in 𝑄 the same

as 𝑁. Expansions formalize assignments of elements from 𝑁 to the variables in 𝑌.

  • 𝑁 ⊧(,) ∀𝑌.𝜒

ifg

𝑁 ⊧(∪,) 𝜒

for all expansions 𝑁 along the inclusion (𝐺, 𝑄) ⊆ (𝐺 ∪ 𝑌, 𝑄)

  • 𝑁 ⊧(,) ∃𝑌.𝜒

ifg there exists an expansion 𝑁 along the inclusion (𝐺, 𝑄) ⊆ (𝐺 ∪ 𝑌, 𝑄) such that 𝑁 ⊧(∪,) 𝜒

14 / 24

slide-15
SLIDE 15

Satisfaction relation ⋅ Example

True or False?

Brother(John, Richard) ∧ Brother(Richard, John) ¬Brother(LeftLegOf(Richard), John) ¬King(Richard) → King(John)

15 / 24

slide-16
SLIDE 16

Satisfaction relation ⋅ Example

True or False?

∀𝑦.King(𝑦) → Person(𝑦)

𝑦 ↦ 𝑃 (i.e. 𝑁

= 𝑃)

𝑃 (John) is a king → 𝑃 is a person. 𝑦 ↦ 𝑃 𝑃 (Richard) is a king → 𝑃 is a person. 𝑦 ↦ 𝑃 𝑃 (John’s left leg) is a king → 𝑃 is a person. 𝑦 ↦ 𝑃 𝑃 (Richard’s left leg) is a king → 𝑃 is a person. 𝑦 ↦ 𝑃 𝑃 (crown) is a king → 𝑃 is a person.

16 / 24

slide-17
SLIDE 17

Expressivity ⋅ Quantifjers

∀𝑦.King(𝑦) → Person(𝑦) ∀𝑦.King(𝑦) ∧ Person(𝑦)

17 / 24

slide-18
SLIDE 18

Expressivity ⋅ Quantifjers

∀𝑦.King(𝑦) → Person(𝑦) ∀𝑦.King(𝑦) ∧ Person(𝑦)

17 / 24

slide-19
SLIDE 19

Expressivity ⋅ Quantifjers

∀𝑦.King(𝑦) → Person(𝑦) ∀𝑦.King(𝑦) ∧ Person(𝑦)

17 / 24

slide-20
SLIDE 20

Expressivity ⋅ Quantifjers

∀𝑦.King(𝑦) → Person(𝑦) ∀𝑦.King(𝑦) ∧ Person(𝑦)

17 / 24

slide-21
SLIDE 21

Expressivity ⋅ Quantifjers

∃𝑦.Crown(𝑦) ∧ OnHead(𝑦, John) ∃𝑦.Crown(𝑦) → OnHead(𝑦, John)

18 / 24

slide-22
SLIDE 22

Expressivity ⋅ Quantifjers

∃𝑦.Crown(𝑦) ∧ OnHead(𝑦, John) ∃𝑦.Crown(𝑦) → OnHead(𝑦, John)

18 / 24

slide-23
SLIDE 23

Expressivity ⋅ Quantifjers

∃𝑦.Crown(𝑦) ∧ OnHead(𝑦, John) ∃𝑦.Crown(𝑦) → OnHead(𝑦, John)

18 / 24

slide-24
SLIDE 24

Expressivity ⋅ Quantifjers

∃𝑦.Crown(𝑦) ∧ OnHead(𝑦, John) ∃𝑦.Crown(𝑦) → OnHead(𝑦, John)

18 / 24

slide-25
SLIDE 25

Expressivity ⋅ Quantifjers

The order of quantifjers

∃𝑌.∀𝑍.𝜒 is not the same thing as ∀𝑍.∃𝑌.𝜒 ∃𝑦.∀𝑧.Loves(𝑦, 𝑧)

There is a person who loves everyone in the world.

∀𝑧.∃𝑦.Loves(𝑦, 𝑧)

Everyone in the world is loved by someone. Duality

𝜒 ∧ 𝜒 ≡ ¬(¬𝜒 ∨ ¬𝜒)

and

𝜒 ∨ 𝜒 ≡ ¬(¬𝜒 ∧ ¬𝜒) ∀𝑌.𝜒 ≡ ¬∃𝑌.¬𝜒 ∀𝑦.Likes(𝑦, IceCream) ≡ ¬∃𝑦.¬Likes(𝑦, IceCream) ∃𝑌.𝜒 ≡ ¬∀𝑌.¬𝜒 ∃𝑦.Likes(𝑦, Broccoli) ≡ ¬∀𝑦.¬Likes(𝑦, Broccoli)

19 / 24

slide-26
SLIDE 26

Using FOL ⋅ Kinship domain

Axioms: defjnitions, theorems One’s mother is one’s female parent.

∀𝑛, 𝑑.𝑛 = Mother(𝑑) ↔ (Female(𝑛) ∧ Parent(𝑛, 𝑑))

Parent and child are inverse relations.

∀𝑞, 𝑑.Parent(𝑞, 𝑑) ↔ Child(𝑑, 𝑞)

A sibling is another child of one’s parents.

∀𝑦, 𝑧.Sibling(𝑦, 𝑧) ↔ 𝑦 ≠ 𝑧 ∧ ∃𝑞.Parent(𝑞, 𝑦) ∧ Parent(𝑞, 𝑧)

Brothers are siblings.

∀𝑦, 𝑧.Brother(𝑦, 𝑧) → Sibling(𝑦, 𝑧)

The sibling relation is symmetric.

∀𝑦, 𝑧.Sibling(𝑦, 𝑧) ↔ Sibling(𝑧, 𝑦)

20 / 24

slide-27
SLIDE 27

Interacting with FOL KBs

Tell/Ask interface Assertions Tell(KB, King(John)) Tell(KB, Person(Richard)) Tell(KB, ∀𝑦.King(𝑦) → Person(𝑦)) Queries (goals) Ask(KB, Person(John)) true Ask(KB, ∃𝑦.Person(𝑦)) true Ask(KB, Person(𝑦))

{𝑦/John}, {𝑦/Richard}

Idea Ask(KB, 𝜒) returns all substitutions 𝜄 such that KB ⊧ 𝜄(𝜒).

21 / 24

slide-28
SLIDE 28

Example ⋅ Wumpus world

Suppose a wumpus-world agent is using an FOL KB and perceives a smell and a breeze (but no glitter) at 𝑢 = 5. Tell(KB, Percept([Smell, Breeze, None], 5)) Does the KB entail some best action at 𝑢 = 5? Ask(KB, ∃𝑏.BestAction(𝑏, 5)) Answer: true, {𝑏/Shoot} Perception

∀𝑢, 𝑡, 𝑐.Percept([𝑡, 𝑐, Glitter], 𝑢) → Glitter(𝑢)

Refmex

∀𝑢.Glitter(𝑢) → BestAction(Grab, 𝑢)

22 / 24

slide-29
SLIDE 29

Example ⋅ Wumpus world

The environment

∀𝑦, 𝑧, 𝑏, 𝑐.Adjacent([𝑦, 𝑧]) ↔ [𝑏, 𝑐]∈{[𝑦+1, 𝑧], [𝑦−1, 𝑧], [𝑦, 𝑧+1], [𝑦, 𝑧−1]} ∀𝑡, 𝑢.At(Agent, 𝑡, 𝑢) ∧ Breeze(𝑢) → Breezy(𝑡)

Squares are breezy near a pit. Diagnostic rule: infer cause from efgect

∀𝑡.Breezy(𝑡) → ∃𝑠.Adjacent(𝑠, 𝑡) ∧ Pit(𝑠)

Causal rule: infer efgect from cause

∀𝑠.Pit(𝑠) → (∀𝑡.Adjacent(𝑠, 𝑡) → Breezy(𝑡))

23 / 24

slide-30
SLIDE 30

Summary

First-order logic:

  • Objects and relations are semantic primitives.
  • Syntax: constants, functions, predicates, quantifjers.
  • Increased expressive power – suffjcient to defjne the

Wumpus world.

24 / 24