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 February 2020
Outline 2 / 24 • Why FOL? • Syntax and semantics of FOL • Using FOL • Wumpus world in FOL
Propositional logic as a language Compared to languages in Computer Science only by writing one sentence for each square context Compared to natural languages 3 / 24 • 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 • meaning is context-independent ⋅ unlike natural languages, where meaning depends on • propositional logic has very limited expressive power ⋅ e.g. we can say pits cause breezes in adjacent squares
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
5 / 24 Example ⋅ Of brothers and kings
6 / 24 Example ⋅ Of brothers and kings Brother ( KingJohn , RichardTheLionheart ) Length ( LeftLegOf ( Richard )) > Length ( LeftLegOf ( John ))
(operations) (predicates) Constant symbols are function symbols with arity zero. Example functions predicates 7 / 24 Syntax ⋅ Signatures A fjrst-order signature is a pair (𝐺, 𝑄) 𝐺 – indexed family (𝐺 � ) �∈ℕ of sets of function symbols 𝑄 – indexed family (𝑄 � ) �∈ℕ of sets of relation symbols For 𝜏 ∈ 𝐺 � and 𝜌 ∈ 𝑄 � , 𝑜 is called arity. 𝐺 � = { Richard , John } , 𝐺 � = { LeftLegOf } 𝑄 � = { Crown , King , Person } 𝑄 � = { Brother , OnHead }
8 / 24 Terms quantifjers boolean connectives atoms Variables Syntax ⋅ Sentences Least set 𝑈 � such that 𝜏(𝑢 � , … , 𝑢 � ) ∈ 𝑈 � for every 𝜏 ∈ 𝐺 � and 𝑢 � , … , 𝑢 � ∈ 𝑈 � . In particular, 𝑈 � contains all constants. 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 𝜒 ∶∶= 𝜌(𝑢 � , … , 𝑢 � ) ∣ 𝑢 = 𝑢 � ∣ ¬𝜒 ∣ 𝜒 ∧ 𝜒 � ∣ 𝜒 ∨ 𝜒 � ∣ 𝜒 → 𝜒 � ∣ 𝜒 ↔ 𝜒 � ∣ ∀𝑌.𝜒 ∣ ∃𝑌.𝜒 where 𝜌 ∈ 𝑄 � is a predicate symbol, 𝑢, 𝑢 � , 𝑢 � , … , 𝑢 � are terms, and 𝑌 is a set of variables. Precedence: ∀𝑌, ∃𝑌, ¬, ∧, ∨, →, ↔
9 / 24 boolean connectives Example atoms quantifjers Syntax ⋅ Sentences Sentences over a signature (𝐺, 𝑄) are defjned by the grammar 𝜒 ∶∶= 𝜌(𝑢 � , … , 𝑢 � ) ∣ 𝑢 = 𝑢 � ∣ ¬𝜒 ∣ 𝜒 ∧ 𝜒 � ∣ 𝜒 ∨ 𝜒 � ∣ 𝜒 → 𝜒 � ∣ 𝜒 ↔ 𝜒 � ∣ ∀𝑌.𝜒 ∣ ∃𝑌.𝜒 where 𝜌 ∈ 𝑄 � is a predicate symbol, 𝑢, 𝑢 � , 𝑢 � , … , 𝑢 � are terms, and 𝑌 is a set of variables. Precedence: ∀𝑌, ∃𝑌, ¬, ∧, ∨, →, ↔ Brother ( John , Richard ) Brother ( John , Richard ) ∧ Brother ( Richard , John ) ¬ Brother ( LeftLegOf ( Richard ), John ) ¬ King ( Richard ) → King ( John ) ∀𝑦. King (𝑦) → Person (𝑦)
10 / 24 Examples Semantics ⋅ Models Given a signature (𝐺, 𝑄) , a model 𝑁 consists of • a non-empty set |𝑁| , called the carrier set (domain) of 𝑁 , whose elements are called objects • a function 𝑁 � ∶ |𝑁| � → |𝑁| for each operation symbol 𝜏 ∈ 𝐺 � • a subset 𝑁 � ⊆ |𝑁| � for each relation symbol 𝜌 ∈ 𝑄 �
Satisfaction relation The satisfaction relation links the syntax and the semantics. structure of sentences (in the following slides), based on the evaluation of terms in models. Evaluation of terms 11 / 24 • 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 • 𝑁 � denotes the interpretation of a term 𝑢 in a model 𝑁 . • 𝑁 �(� � ,…,� � ) = 𝑁 � (𝑁 � � , … , 𝑁 � � ) e.g. 𝑁 LeftLegOf ( John ) = 𝑁 LeftLegOf (𝑁 John ) = 𝑁 LeftLegOf ( ) =
12 / 24 ifg ifg ifg ifg ifg ifg ifg Boolean connectives Atoms Satisfaction relation ⋅ 𝑁 ⊧ 𝜒 • 𝑁 ⊧ 𝑢 = 𝑢 � 𝑁 � = 𝑁 � � • 𝑁 ⊧ 𝜌(𝑢 � , … , 𝑢 � ) (𝑁 � � , … , 𝑁 � � ) ∈ 𝑁 � • 𝑁 ⊧ ¬𝜒 𝑁 ⊭ 𝜒 • 𝑁 ⊧ 𝜒 � ∧ 𝜒 � 𝑁 ⊧ 𝜒 � and 𝑁 ⊧ 𝜒 � • 𝑁 ⊧ 𝜒 � ∨ 𝜒 � 𝑁 ⊧ 𝜒 � or 𝑁 ⊧ 𝜒 � • 𝑁 ⊧ 𝜒 � → 𝜒 � 𝑁 ⊧ 𝜒 � whenever 𝑁 ⊧ 𝜒 � • 𝑁 ⊧ 𝜒 � ↔ 𝜒 � 𝑁 ⊧ 𝜒 � → 𝜒 � and 𝑁 ⊧ 𝜒 � → 𝜒 �
Example Quantifjers 13 / 24 Satisfaction relation ⋅ 𝑁 ⊧ 𝜒 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 𝑌 . 𝑁 𝑁′
Quantifjers ifg ifg 14 / 24 Satisfaction relation ⋅ 𝑁 ⊧ 𝜒 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 𝑌 . 𝑁 � ⊧ (�∪�,�) 𝜒 • 𝑁 ⊧ (�,�) ∀𝑌.𝜒 for all expansions 𝑁 � along the inclusion (𝐺, 𝑄) ⊆ (𝐺 ∪ 𝑌, 𝑄) there exists an expansion 𝑁 � along the • 𝑁 ⊧ (�,�) ∃𝑌.𝜒 inclusion (𝐺, 𝑄) ⊆ (𝐺 ∪ 𝑌, 𝑄) such that 𝑁 � ⊧ (�∪�,�) 𝜒
True or False? 15 / 24 Satisfaction relation ⋅ Example Brother ( John , Richard ) ∧ Brother ( Richard , John ) ¬ Brother ( LeftLegOf ( Richard ), John ) ¬ King ( Richard ) → King ( John )
16 / 24 True or False? Satisfaction relation ⋅ Example ∀𝑦. 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.
∀𝑦. King (𝑦) ∧ Person (𝑦) 17 / 24 Expressivity ⋅ Quantifjers ∀𝑦. King (𝑦) → Person (𝑦)
∀𝑦. King (𝑦) ∧ Person (𝑦) 17 / 24 Expressivity ⋅ Quantifjers ∀𝑦. King (𝑦) → Person (𝑦)
17 / 24 Expressivity ⋅ Quantifjers ∀𝑦. King (𝑦) → Person (𝑦) ∀𝑦. King (𝑦) ∧ Person (𝑦)
17 / 24 Expressivity ⋅ Quantifjers ∀𝑦. King (𝑦) → Person (𝑦) ∀𝑦. King (𝑦) ∧ Person (𝑦)
∃𝑦. Crown (𝑦) → OnHead (𝑦, John ) 18 / 24 Expressivity ⋅ Quantifjers ∃𝑦. Crown (𝑦) ∧ OnHead (𝑦, John )
∃𝑦. Crown (𝑦) → OnHead (𝑦, John ) 18 / 24 Expressivity ⋅ Quantifjers ∃𝑦. Crown (𝑦) ∧ OnHead (𝑦, John )
18 / 24 Expressivity ⋅ Quantifjers ∃𝑦. Crown (𝑦) ∧ OnHead (𝑦, John ) ∃𝑦. Crown (𝑦) → OnHead (𝑦, John )
18 / 24 Expressivity ⋅ Quantifjers ∃𝑦. Crown (𝑦) ∧ OnHead (𝑦, John ) ∃𝑦. Crown (𝑦) → OnHead (𝑦, John )
The order of quantifjers There is a person who loves everyone in the world. Everyone in the world is loved by someone. Duality and 19 / 24 Expressivity ⋅ Quantifjers ∃𝑌.∀𝑍.𝜒 is not the same thing as ∀𝑍.∃𝑌.𝜒 ∃𝑦.∀𝑧. Loves (𝑦, 𝑧) ∀𝑧.∃𝑦. Loves (𝑦, 𝑧) 𝜒 ∧ 𝜒 � ≡ ¬(¬𝜒 ∨ ¬𝜒 � ) 𝜒 ∨ 𝜒 � ≡ ¬(¬𝜒 ∧ ¬𝜒 � ) ∀𝑌.𝜒 ≡ ¬∃𝑌.¬𝜒 ∀𝑦. Likes (𝑦, IceCream ) ≡ ¬∃𝑦.¬ Likes (𝑦, IceCream ) ∃𝑌.𝜒 ≡ ¬∀𝑌.¬𝜒 ∃𝑦. Likes (𝑦, Broccoli ) ≡ ¬∀𝑦.¬ Likes (𝑦, Broccoli )
Axioms: defjnitions, theorems One’s mother is one’s female parent. Parent and child are inverse relations. A sibling is another child of one’s parents. Brothers are siblings. The sibling relation is symmetric. 20 / 24 Using FOL ⋅ Kinship domain ∀𝑛, 𝑑.𝑛 = Mother (𝑑) ↔ ( Female (𝑛) ∧ Parent (𝑛, 𝑑)) ∀𝑞, 𝑑. Parent (𝑞, 𝑑) ↔ Child (𝑑, 𝑞) ∀𝑦, 𝑧. Sibling (𝑦, 𝑧) ↔ 𝑦 ≠ 𝑧 ∧ ∃𝑞. Parent (𝑞, 𝑦) ∧ Parent (𝑞, 𝑧) ∀𝑦, 𝑧. Brother (𝑦, 𝑧) → Sibling (𝑦, 𝑧) ∀𝑦, 𝑧. Sibling (𝑦, 𝑧) ↔ Sibling (𝑧, 𝑦)
Recommend
More recommend